@carllee1983/dbcli 1.5.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.dev.md +51 -54
- package/README.md +27 -17
- package/README.zh-TW.md +25 -15
- package/assets/SKILL.md +63 -510
- package/assets/reference.md +371 -0
- package/dist/cli.mjs +797 -400
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ All notable changes to dbcli are documented here.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.6.0] - 2026-04-23
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Full MongoDB Support**: Extended all core operations to support MongoDB.
|
|
13
|
+
- Data operations: `query`, `insert`, `update`, `delete`.
|
|
14
|
+
- Safeguards: Integrated `blacklist` protection and `query-size-guard` for MongoDB commands.
|
|
15
|
+
- Discovery: Implemented schema inspection for MongoDB collections.
|
|
16
|
+
- Diagnostics: Added comprehensive MongoDB environment and connection diagnostics to `dbcli doctor`.
|
|
17
|
+
- **Improved AI Skill Installation**: `dbcli skill --install` now deploys both `SKILL.md` (high-level workflow) and `reference.md` (full command syntax and examples) to target platforms (Claude Code, Gemini CLI, Copilot, Cursor).
|
|
18
|
+
- **Security model enhancement**: `dbcli init` now defaults to a more secure storage model, placing sensitive connection details in `~/.config/dbcli/` rather than the local project workspace.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **Documentation Refactor**: Updated and synchronized documentation (README, README.zh-TW, SKILL.md) to reflect full MongoDB capabilities and first-step walkthroughs.
|
|
23
|
+
|
|
8
24
|
## [1.5.2] - 2026-04-22
|
|
9
25
|
|
|
10
26
|
### Fixed
|
package/README.dev.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Development Guide
|
|
2
2
|
|
|
3
|
+
Scoped package: **`@carllee1983/dbcli`**. All `npm` / `npx` examples below use this name.
|
|
4
|
+
|
|
3
5
|
## npm Publishing Process
|
|
4
6
|
|
|
5
7
|
### Pre-Publication Checklist
|
|
@@ -9,115 +11,110 @@ Before running `npm publish`:
|
|
|
9
11
|
1. **Verify build is clean:**
|
|
10
12
|
```bash
|
|
11
13
|
bun run build
|
|
12
|
-
ls -lh dist/cli.mjs
|
|
14
|
+
ls -lh dist/cli.mjs # expect a few MB (bundled CLI + dependencies)
|
|
13
15
|
```
|
|
14
16
|
|
|
15
|
-
2. **Verify
|
|
17
|
+
2. **Verify tests pass (pick one):**
|
|
16
18
|
```bash
|
|
17
|
-
|
|
19
|
+
# Fast path: unit + core only (matches CI-style smoke)
|
|
20
|
+
bun run test:unit
|
|
21
|
+
|
|
22
|
+
# Full suite (Bun test runner)
|
|
23
|
+
bun test
|
|
18
24
|
```
|
|
19
25
|
|
|
20
|
-
For live database integration tests,
|
|
26
|
+
For live database integration tests, set an explicit config if needed:
|
|
21
27
|
```bash
|
|
22
28
|
LIVE_DB_CONFIG_PATH=/path/to/.dbcli bun test tests/integration/live-db.test.ts
|
|
23
29
|
```
|
|
24
30
|
|
|
25
31
|
If no live config is available, `tests/integration/live-db.test.ts` skips
|
|
26
|
-
instead of falling back to the default PostgreSQL configuration.
|
|
32
|
+
instead of falling back to the default PostgreSQL configuration. Use
|
|
33
|
+
`SKIP_INTEGRATION_TESTS=true` to skip integration tests when running a broad `bun test`.
|
|
27
34
|
|
|
28
35
|
3. **Update version in package.json:**
|
|
29
36
|
```bash
|
|
30
|
-
npm version minor
|
|
31
|
-
# OR
|
|
37
|
+
npm version minor # bumps version + creates git tag (in this repo)
|
|
38
|
+
# OR edit the "version" field in package.json by hand
|
|
32
39
|
```
|
|
33
40
|
|
|
34
41
|
4. **Verify package contents (dry run):**
|
|
35
42
|
```bash
|
|
36
43
|
npm pack --dry-run
|
|
37
|
-
# Should list only: dist/*, README.md, CHANGELOG.md, package.json
|
|
38
44
|
```
|
|
45
|
+
Expect **`dist/`** (at least `cli.mjs`), **`assets/`** (e.g. `SKILL.md`, `reference.md` for `dbcli skill`), **`README.md`**, **`CHANGELOG.md`**, **`LICENSE`**, and **`package.json`**. There must be **no** `src/`, `tests/`, or `node_modules/`. The listing may also include other root `README*.md` files (npm can still pack them even when `files` is set); dev-only readmes are listed in **`.npmignore`** — re-check with dry-run if you add or remove docs.
|
|
39
46
|
|
|
40
47
|
5. **Check package size:**
|
|
41
48
|
```bash
|
|
42
49
|
npm pack
|
|
43
|
-
ls -lh dbcli-*.tgz
|
|
44
|
-
rm dbcli-*.tgz
|
|
50
|
+
ls -lh carllee1983-dbcli-*.tgz # compressed tarball (typically well under 5MB)
|
|
51
|
+
rm carllee1983-dbcli-*.tgz # cleanup
|
|
45
52
|
```
|
|
46
53
|
|
|
47
54
|
### Publication
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
Publication uses the `prepublishOnly` script in `package.json`:
|
|
50
57
|
|
|
51
58
|
```bash
|
|
52
59
|
npm publish
|
|
53
60
|
```
|
|
54
61
|
|
|
55
|
-
|
|
56
|
-
1. `prepublishOnly` hook: Runs `bun run build` → ensures fresh dist/cli.mjs
|
|
57
|
-
2. npm creates tarball with `files` whitelist → only intended files included
|
|
58
|
-
3. npm applies `.npmignore` rules → additional safety layer
|
|
59
|
-
4. npm publishes to registry
|
|
62
|
+
What runs (conceptually):
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
1. **`prepublishOnly`:** `bun run build` — rebuilds `dist/cli.mjs` from `src/cli.ts` via `scripts/build.ts`.
|
|
65
|
+
2. **Tarball** — paths from the **`files`** field in `package.json`, further filtered by **`.npmignore`**. (Some npm versions also merge in extra root `README*` files; use dry-run to see exactly what will ship.)
|
|
66
|
+
3. **Registry** — with `"publishConfig": { "access": "public" }`, the scoped package is published as **public**.
|
|
67
|
+
|
|
68
|
+
A failed `bun run build` will fail the publish, so you should not ship a stale `dist/` from a previous local build.
|
|
62
69
|
|
|
63
70
|
### Verification (Post-Publication)
|
|
64
71
|
|
|
65
72
|
After publishing:
|
|
66
73
|
|
|
67
|
-
1. **
|
|
74
|
+
1. **Global install:**
|
|
68
75
|
```bash
|
|
69
|
-
npm install -g dbcli
|
|
70
|
-
which dbcli
|
|
76
|
+
npm install -g @carllee1983/dbcli
|
|
77
|
+
which dbcli
|
|
71
78
|
dbcli --version
|
|
72
79
|
```
|
|
73
80
|
|
|
74
|
-
2. **
|
|
81
|
+
2. **Zero-install (npx / bunx):**
|
|
75
82
|
```bash
|
|
76
|
-
cd /tmp
|
|
77
|
-
|
|
78
|
-
npx dbcli --
|
|
79
|
-
|
|
83
|
+
cd /tmp && mkdir -p test-dbcli && cd test-dbcli
|
|
84
|
+
npx @carllee1983/dbcli --help
|
|
85
|
+
npx @carllee1983/dbcli --version
|
|
86
|
+
# or: bunx @carllee1983/dbcli --help
|
|
80
87
|
```
|
|
81
88
|
|
|
82
|
-
3. **
|
|
83
|
-
- On Windows machine: `npm install -g dbcli`
|
|
84
|
-
- Verify: `dbcli --help` and `dbcli --version` work
|
|
85
|
-
- npm creates .cmd wrapper automatically; no manual .cmd needed
|
|
89
|
+
3. **Windows (if available):** `npm install -g @carllee1983/dbcli`, then `dbcli --help`. npm creates the `.cmd` stub for the `bin` entry; no hand-written `.cmd` in the repo.
|
|
86
90
|
|
|
87
91
|
### Rollback (if needed)
|
|
88
92
|
|
|
89
|
-
If
|
|
93
|
+
If a bad release must be mitigated:
|
|
90
94
|
|
|
91
95
|
```bash
|
|
92
|
-
npm unpublish dbcli
|
|
93
|
-
#
|
|
94
|
-
npm deprecate dbcli
|
|
96
|
+
npm unpublish @carllee1983/dbcli@<VERSION>
|
|
97
|
+
# and/or
|
|
98
|
+
npm deprecate @carllee1983/dbcli@<VERSION> "Reason; use <SAFE_VERSION> instead"
|
|
95
99
|
```
|
|
96
100
|
|
|
97
|
-
Then
|
|
101
|
+
Then ship a patch version with the fix. Prefer **deprecate** over **unpublish** when consumers may already depend on the version.
|
|
98
102
|
|
|
99
103
|
### Configuration Details
|
|
100
104
|
|
|
101
|
-
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
- **
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
- npm warns if consumer's environment is too old
|
|
109
|
-
- **Cross-platform support:** Shebang `#!/usr/bin/env bun` works on all platforms
|
|
110
|
-
- macOS/Linux: Direct shebang execution
|
|
111
|
-
- Windows: npm creates .cmd wrapper automatically (no manual creation needed)
|
|
112
|
-
- **Live integration tests:** `tests/integration/live-db.test.ts` reads `.dbcli/config.json`
|
|
113
|
-
by default or `LIVE_DB_CONFIG_PATH` when you need to point at another config
|
|
114
|
-
directory. Set `SKIP_INTEGRATION_TESTS=true` to skip all integration tests.
|
|
105
|
+
- **`files` (in `package.json`):** Publishes `dist/`, `assets/`, `README.md`, `CHANGELOG.md`, `LICENSE`. The `assets/` tree is required for `dbcli skill` to copy bundled `SKILL.md` / `reference.md` from the installed package.
|
|
106
|
+
- **`prepublishOnly`:** `bun run build` so `dist/cli.mjs` matches current source.
|
|
107
|
+
- **`engines`:** Declares `node >= 18.0.0` and `bun >= 1.3.3` so npm can warn on outdated runtimes.
|
|
108
|
+
- **Shebang:** `scripts/build.ts` prepends `#!/usr/bin/env bun` to `dist/cli.mjs`; the `bin` field in `package.json` points at that file.
|
|
109
|
+
- **Live DB tests:** `tests/integration/live-db.test.ts` uses project `.dbcli` by default or `LIVE_DB_CONFIG_PATH` when you point at another config directory. Set `SKIP_INTEGRATION_TESTS=true` to skip all integration tests.
|
|
110
|
+
|
|
111
|
+
For contributor workflow and release process, see **[CONTRIBUTING.md](./CONTRIBUTING.md)** and the main **[README.md](./README.md)** Development section.
|
|
115
112
|
|
|
116
113
|
### Troubleshooting
|
|
117
114
|
|
|
118
|
-
| Issue |
|
|
119
|
-
|
|
120
|
-
| prepublishOnly
|
|
121
|
-
|
|
|
122
|
-
| Windows
|
|
123
|
-
| npx
|
|
115
|
+
| Issue | What to do |
|
|
116
|
+
|-------|------------|
|
|
117
|
+
| `prepublishOnly` / build fails | Fix TypeScript or build errors, run `bun run test:unit`, then `bun run build` again. |
|
|
118
|
+
| Tarball unexpectedly large or bloated | Inspect the bundle: e.g. `bun build ./src/cli.ts --outfile=dist/cli.mjs --target=bun --metafile=meta.json` and review the metafile; trim dependencies or dev-only code paths. |
|
|
119
|
+
| Windows: `dbcli` not found after global install | Confirm PATH includes npm’s global `bin`; reinstall `npm i -g @carllee1983/dbcli`. |
|
|
120
|
+
| `npx` download slow or cache weird | `npm cache clean --force` and retry `npx @carllee1983/dbcli --version`. |
|
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ A unified database CLI tool that enables AI agents (Claude Code, Gemini, Copilot
|
|
|
6
6
|
|
|
7
7
|
**Core Value:** AI agents can safely and intelligently access project databases through a single, permission-controlled CLI tool with sensitive data protection.
|
|
8
8
|
|
|
9
|
+
> **Security update:** `dbcli init` now writes only a small project binding stub into `./.dbcli/config.json`. The full connection configuration is stored under `~/.config/dbcli/projects/<project-id>/config.json`, so sensitive settings do not live inside the project workspace by default.
|
|
10
|
+
|
|
9
11
|
## Internationalization (i18n)
|
|
10
12
|
|
|
11
13
|
dbcli supports multiple languages via the `DBCLI_LANG` environment variable:
|
|
@@ -76,6 +78,9 @@ When `dbcli` is not on your `PATH`, use `bun run src/cli.ts <subcommand> ...` (s
|
|
|
76
78
|
# Initialize project with database connection
|
|
77
79
|
dbcli init
|
|
78
80
|
|
|
81
|
+
# Interactive shell (SQL + dbcli commands, tab completion)
|
|
82
|
+
dbcli shell
|
|
83
|
+
|
|
79
84
|
# List available tables
|
|
80
85
|
dbcli list
|
|
81
86
|
|
|
@@ -85,6 +90,9 @@ dbcli schema users
|
|
|
85
90
|
# Query data
|
|
86
91
|
dbcli query "SELECT * FROM users"
|
|
87
92
|
|
|
93
|
+
# Preview schema DDL (dry-run by default; add --execute to apply)
|
|
94
|
+
dbcli migrate create posts --column "id:serial:pk" --column "title:varchar(200):not-null"
|
|
95
|
+
|
|
88
96
|
# Generate AI agent skill
|
|
89
97
|
dbcli skill --install claude
|
|
90
98
|
```
|
|
@@ -112,6 +120,8 @@ For MongoDB, `list` and `query` operate on the database configured for the conne
|
|
|
112
120
|
|
|
113
121
|
dbcli supports multiple named database connections within a single project. This is useful for managing different environments (development, staging, production) or multiple databases.
|
|
114
122
|
|
|
123
|
+
The project `.dbcli` directory now acts as a binding + cache layer. The actual connection config is stored in `~/.config/dbcli/projects/<project-id>/`, which keeps sensitive settings out of the workspace by default.
|
|
124
|
+
|
|
115
125
|
### Initializing Named Connections
|
|
116
126
|
|
|
117
127
|
To create a named connection, use the `--conn-name` option during `init`. You can also specify a custom `.env` file for that connection.
|
|
@@ -170,13 +180,14 @@ dbcli init [OPTIONS]
|
|
|
170
180
|
```
|
|
171
181
|
|
|
172
182
|
**Options (Basic):**
|
|
173
|
-
- `--system <type>` — Database system: `postgresql`, `mysql`, `mariadb`
|
|
183
|
+
- `--system <type>` — Database system: `postgresql`, `mysql`, `mariadb`, `mongodb`
|
|
174
184
|
- `--host <host>` — Database host
|
|
175
185
|
- `--port <port>` — Database port
|
|
176
186
|
- `--user <user>` — Database user
|
|
177
187
|
- `--password <pass>` — Database password
|
|
178
188
|
- `--name <db>` — Database name
|
|
179
189
|
- `--permission <level>` — Permission level: `query-only`, `read-write`, `data-admin`, `admin`
|
|
190
|
+
- **MongoDB only:** `--uri <uri>` — full connection URI (`mongodb://…` or `mongodb+srv://…`); `--auth-source <db>` — auth database (default `admin` when using user/password)
|
|
180
191
|
- `--use-env-refs` — Store environment variable references instead of actual values in config
|
|
181
192
|
- `--skip-test` — Skip connection test
|
|
182
193
|
- `--no-interactive` — Non-interactive mode (requires all options)
|
|
@@ -191,7 +202,7 @@ dbcli init [OPTIONS]
|
|
|
191
202
|
**Behavior:**
|
|
192
203
|
- Reads `.env` file if present (auto-fills DATABASE_URL, DB_* variables)
|
|
193
204
|
- Prompts for missing values (host, port, user, password, database name, permission level)
|
|
194
|
-
- Creates `.dbcli`
|
|
205
|
+
- Creates a project binding stub in `.dbcli/config.json` and stores the full config under `~/.config/dbcli/projects/<project-id>/`
|
|
195
206
|
- Tests database connection before saving
|
|
196
207
|
|
|
197
208
|
**Examples:**
|
|
@@ -241,6 +252,8 @@ dbcli use --list
|
|
|
241
252
|
|
|
242
253
|
> **`--use-env-refs`:** When enabled, the config stores environment variable names (e.g., `{"$env": "DB_HOST"}`) instead of actual values. This avoids writing sensitive credentials into the config file, making it suitable for multi-environment deployments and CI/CD pipelines. At connection time, dbcli automatically reads the actual values from the referenced environment variables.
|
|
243
254
|
|
|
255
|
+
> **Storage model:** The project `.dbcli` directory is now a binding + cache layer, not the canonical home for secrets. If you inspect `./.dbcli/config.json`, you should only see the binding metadata; the full config lives in the home storage path shown above.
|
|
256
|
+
|
|
244
257
|
---
|
|
245
258
|
|
|
246
259
|
#### `dbcli list`
|
|
@@ -489,8 +502,8 @@ dbcli skill --install cursor # Install to Cursor IDE
|
|
|
489
502
|
```
|
|
490
503
|
|
|
491
504
|
**Behavior:**
|
|
492
|
-
- Ships
|
|
493
|
-
- Prints
|
|
505
|
+
- Ships canonical **`assets/SKILL.md`** + **`assets/reference.md`** (single source of truth: concise skill + long command reference)
|
|
506
|
+
- Prints the skill to **stdout**, writes it with **`--output`**, or copies it to a **platform-specific path** with **`--install`**
|
|
494
507
|
- Actual database access is still enforced by your `.dbcli` permission level and blacklist — the skill text describes the full CLI surface
|
|
495
508
|
|
|
496
509
|
**Examples:**
|
|
@@ -592,12 +605,8 @@ dbcli check users
|
|
|
592
605
|
dbcli check orders --checks nulls,orphans --format table
|
|
593
606
|
# Scan all tables
|
|
594
607
|
dbcli check --all
|
|
595
|
-
```
|
|
596
|
-
|
|
597
|
-
---
|
|
598
608
|
|
|
599
|
-
|
|
600
|
-
```bash
|
|
609
|
+
# Table view + all-tables with selected checks
|
|
601
610
|
dbcli check orders --format table
|
|
602
611
|
dbcli check --all --checks nulls,duplicates --format json
|
|
603
612
|
```
|
|
@@ -690,7 +699,7 @@ dbcli upgrade --check # Only check, do not upgrade
|
|
|
690
699
|
|
|
691
700
|
**Background checks (stderr, skipped when `--quiet` or for `upgrade` / `skill`):**
|
|
692
701
|
- **CLI version:** dbcli checks the npm registry (cached, about once per 24 hours). If a newer package exists, a one-line hint prints after normal command output.
|
|
693
|
-
- **Installed skills:** If you used `dbcli skill --install <platform>`, dbcli compares each installed
|
|
702
|
+
- **Installed skills:** If you used `dbcli skill --install <platform>`, dbcli compares each installed primary skill file (`SKILL.md` or `dbcli.mdc`) to the bundled `assets/SKILL.md`. When they differ, a short reminder lists which platforms to re-install (`dbcli skill --install <platform>`). Run `dbcli upgrade` to see the same skill status together with version info. Re-installing also refreshes `reference.md` next to the skill.
|
|
694
703
|
|
|
695
704
|
#### `dbcli shell`
|
|
696
705
|
|
|
@@ -950,7 +959,7 @@ A Query-only agent cannot write to any table, and also cannot read blacklisted t
|
|
|
950
959
|
|
|
951
960
|
## AI Integration Guide
|
|
952
961
|
|
|
953
|
-
dbcli ships AI-consumable skill
|
|
962
|
+
dbcli ships AI-consumable skill files (`assets/SKILL.md` and `assets/reference.md`) and can copy them into your favorite AI tool directories.
|
|
954
963
|
|
|
955
964
|
### Quick Start
|
|
956
965
|
|
|
@@ -982,7 +991,7 @@ After installation, the AI agent will have access to dbcli commands and can use
|
|
|
982
991
|
4. Restart Claude Code extension
|
|
983
992
|
5. In Claude Code chat, ask: "Show me the database schema" or "Query active users"
|
|
984
993
|
|
|
985
|
-
**Skill location:** `~/.claude/skills/dbcli
|
|
994
|
+
**Skill location:** `~/.claude/skills/dbcli/` (SKILL.md + reference.md)
|
|
986
995
|
|
|
987
996
|
---
|
|
988
997
|
|
|
@@ -994,7 +1003,7 @@ After installation, the AI agent will have access to dbcli commands and can use
|
|
|
994
1003
|
4. Start Gemini: `gemini start`
|
|
995
1004
|
5. In chat, request: "Query the users table" or "Show database tables"
|
|
996
1005
|
|
|
997
|
-
**Skill location:** `~/.gemini/skills/dbcli
|
|
1006
|
+
**Skill location:** `~/.gemini/skills/dbcli/` (SKILL.md + reference.md)
|
|
998
1007
|
|
|
999
1008
|
---
|
|
1000
1009
|
|
|
@@ -1006,7 +1015,7 @@ After installation, the AI agent will have access to dbcli commands and can use
|
|
|
1006
1015
|
4. Install Copilot CLI: `npm install -g @github-next/github-copilot-cli`
|
|
1007
1016
|
5. Use copilot preview: `copilot --help` and explore dbcli integration
|
|
1008
1017
|
|
|
1009
|
-
**Skill location:** `.github/skills/dbcli
|
|
1018
|
+
**Skill location:** `.github/skills/dbcli/` (SKILL.md + reference.md) when you run `dbcli skill --install copilot` in your project root.
|
|
1010
1019
|
|
|
1011
1020
|
---
|
|
1012
1021
|
|
|
@@ -1018,7 +1027,7 @@ After installation, the AI agent will have access to dbcli commands and can use
|
|
|
1018
1027
|
4. Open Cursor editor
|
|
1019
1028
|
5. Use Cursor's Composer: "Insert a new user" or "Export user data"
|
|
1020
1029
|
|
|
1021
|
-
**Skill location:** `.cursor/rules/dbcli.mdc` under the **current working directory** when you run `dbcli skill --install cursor
|
|
1030
|
+
**Skill location:** `.cursor/rules/dbcli.mdc` (summary + workflows) and `.cursor/skills/dbcli/reference.md` (full command flags and examples) under the **current working directory** when you run `dbcli skill --install cursor`.
|
|
1022
1031
|
|
|
1023
1032
|
---
|
|
1024
1033
|
|
|
@@ -1045,7 +1054,7 @@ dbcli skill --install claude
|
|
|
1045
1054
|
|
|
1046
1055
|
### Updating the skill after upgrades
|
|
1047
1056
|
|
|
1048
|
-
|
|
1057
|
+
`dbcli skill` copies the bundled **`assets/SKILL.md`** (and for `--install`, **`assets/reference.md`** next to it). It is **not** regenerated from your live config. When you **upgrade dbcli** or the bundled skill changes, re-copy it to each platform you use:
|
|
1049
1058
|
|
|
1050
1059
|
```bash
|
|
1051
1060
|
dbcli skill --install claude
|
|
@@ -1053,7 +1062,7 @@ dbcli skill --install gemini
|
|
|
1053
1062
|
# ... etc.
|
|
1054
1063
|
```
|
|
1055
1064
|
|
|
1056
|
-
If an installed
|
|
1065
|
+
If an installed primary skill file is older than the bundled `assets/SKILL.md`, dbcli prints a **stderr reminder** after most commands (see **`dbcli upgrade`**). Changing **permission level** or **blacklist** in `.dbcli` affects what the CLI allows at runtime — keep project context (e.g. `dbcli status`, `dbcli blacklist list`) in mind for agents even though the skill text lists the full command set.
|
|
1057
1066
|
|
|
1058
1067
|
---
|
|
1059
1068
|
|
|
@@ -1230,6 +1239,7 @@ chmod +x dist/cli.mjs
|
|
|
1230
1239
|
- **PostgreSQL:** 12.0+
|
|
1231
1240
|
- **MySQL:** 8.0+
|
|
1232
1241
|
- **MariaDB:** 10.5+
|
|
1242
|
+
- **MongoDB:** 4.4+ (query and collection listing via `mongodb://` and `mongodb+srv://`; see **MongoDB Atlas / SRV Connections** earlier in this document)
|
|
1233
1243
|
|
|
1234
1244
|
### Runtime
|
|
1235
1245
|
|
package/README.zh-TW.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
**核心價值:** AI 代理可透過單一、具權限控管的 CLI 工具,在敏感資料保護下安全且智慧地存取專案資料庫。
|
|
8
8
|
|
|
9
|
+
> **安全性更新:** `dbcli init` 現在只會在 `./.dbcli/config.json` 寫入一個很小的專案綁定 stub。完整的連線設定會存放在 `~/.config/dbcli/projects/<project-id>/config.json`,因此敏感設定預設不會留在專案工作區內。
|
|
10
|
+
|
|
9
11
|
## 國際化(i18n)
|
|
10
12
|
|
|
11
13
|
dbcli 透過環境變數 `DBCLI_LANG` 支援多語系:
|
|
@@ -88,8 +90,8 @@ dbcli schema users
|
|
|
88
90
|
# 查詢資料
|
|
89
91
|
dbcli query "SELECT * FROM users"
|
|
90
92
|
|
|
91
|
-
#
|
|
92
|
-
dbcli migrate create posts --column "id:
|
|
93
|
+
# 預覽結構變更(DDL,預設 dry-run;實際套用請加 --execute)
|
|
94
|
+
dbcli migrate create posts --column "id:serial:pk" --column "title:varchar(200):not-null"
|
|
93
95
|
|
|
94
96
|
# 產生 AI 代理 skill
|
|
95
97
|
dbcli skill --install claude
|
|
@@ -146,7 +148,7 @@ dbcli init --conn-name staging --env-file .env.staging
|
|
|
146
148
|
dbcli init --conn-name prod --env-file .env.production --use-env-refs
|
|
147
149
|
```
|
|
148
150
|
|
|
149
|
-
每一條具名連線可以設定不同的 **`--permission`**(例如正式環境只給 `query-only
|
|
151
|
+
每一條具名連線可以設定不同的 **`--permission`**(例如正式環境只給 `query-only`)。現在專案內的 `.dbcli` 主要扮演**綁定 + 快取層**;真正的連線設定會存到使用者家目錄下的 `~/.config/dbcli/projects/<project-id>/`,避免敏感設定留在工作區。
|
|
150
152
|
|
|
151
153
|
### 管理連線(`use` / 移除 / 更名)
|
|
152
154
|
|
|
@@ -187,13 +189,14 @@ dbcli init [OPTIONS]
|
|
|
187
189
|
```
|
|
188
190
|
|
|
189
191
|
**選項 (基本):**
|
|
190
|
-
- `--system <type>` — 資料庫系統:`postgresql`、`mysql`、`mariadb`
|
|
192
|
+
- `--system <type>` — 資料庫系統:`postgresql`、`mysql`、`mariadb`、`mongodb`
|
|
191
193
|
- `--host <host>` — 主機
|
|
192
194
|
- `--port <port>` — 埠號
|
|
193
195
|
- `--user <user>` — 使用者
|
|
194
196
|
- `--password <pass>` — 密碼
|
|
195
197
|
- `--name <db>` — 資料庫名稱
|
|
196
198
|
- `--permission <level>` — 權限等級:`query-only`、`read-write`、`data-admin`、`admin`
|
|
199
|
+
- **僅 MongoDB:** `--uri <uri>` — 完整連線 URI(`mongodb://…` 或 `mongodb+srv://…`);`--auth-source <db>` — 驗證資料庫(使用帳密時預設為 `admin`)
|
|
197
200
|
- `--use-env-refs` — 在設定檔中儲存環境變數名稱參照,而非實際值
|
|
198
201
|
- `--skip-test` — 略過連線測試
|
|
199
202
|
- `--no-interactive` — 非互動模式(須提供所有必要選項)
|
|
@@ -208,7 +211,7 @@ dbcli init [OPTIONS]
|
|
|
208
211
|
**行為:**
|
|
209
212
|
- 若存在 `.env` 會讀取(自動帶入 DATABASE_URL、DB_* 等變數)
|
|
210
213
|
- 缺少的欄位會互動提示(主機、埠、使用者、密碼、資料庫名、權限等級)
|
|
211
|
-
-
|
|
214
|
+
- 在 `.dbcli/config.json` 建立專案綁定 stub,並將完整設定儲存在 `~/.config/dbcli/projects/<project-id>/`
|
|
212
215
|
- 儲存前會測試資料庫連線
|
|
213
216
|
|
|
214
217
|
**範例:**
|
|
@@ -258,6 +261,8 @@ dbcli use --list
|
|
|
258
261
|
|
|
259
262
|
> **`--use-env-refs`:** 啟用後,設定檔會儲存環境變數名稱(例如 `{"$env": "DB_HOST"}`)而非實際值,避免將憑證寫入檔案,適合多環境與 CI/CD。連線時 dbcli 會自動從對應環境變數讀取實際值。
|
|
260
263
|
|
|
264
|
+
> **儲存模型:** 專案內的 `.dbcli` 現在是綁定 + 快取層,不再是秘密資訊的最終儲存地。若你查看 `./.dbcli/config.json`,應只會看到綁定 metadata;完整設定會放在前述 home storage 路徑中。
|
|
265
|
+
|
|
261
266
|
---
|
|
262
267
|
|
|
263
268
|
#### `dbcli list`
|
|
@@ -506,8 +511,8 @@ dbcli skill --install cursor # 安裝至 Cursor IDE
|
|
|
506
511
|
```
|
|
507
512
|
|
|
508
513
|
**行為:**
|
|
509
|
-
-
|
|
510
|
-
- 可輸出至 **stdout**、以 **`--output`**
|
|
514
|
+
- 內建 **`assets/SKILL.md`** 與 **`assets/reference.md`**(單一來源:精簡 skill+完整指令參考)
|
|
515
|
+
- 可輸出至 **stdout**、以 **`--output`** 寫入主要 skill 檔,或以 **`--install`** 複製到**各平台預設路徑**(`--install` 時一併寫入同目錄的 `reference.md`)
|
|
511
516
|
- 實際能否存取資料庫仍由 `.dbcli` 的**權限等級**與**黑名單**決定;skill 文字描述的是完整 CLI 能力
|
|
512
517
|
|
|
513
518
|
**範例:**
|
|
@@ -610,6 +615,10 @@ dbcli check orders --checks nulls,orphans --format table
|
|
|
610
615
|
|
|
611
616
|
# 掃描所有資料表
|
|
612
617
|
dbcli check --all
|
|
618
|
+
|
|
619
|
+
# 以表格顯示單表/掃全庫僅執行部分檢查
|
|
620
|
+
dbcli check orders --format table
|
|
621
|
+
dbcli check --all --checks nulls,duplicates --format json
|
|
613
622
|
```
|
|
614
623
|
|
|
615
624
|
---
|
|
@@ -700,7 +709,7 @@ dbcli upgrade --check # 僅檢查,不安裝
|
|
|
700
709
|
|
|
701
710
|
**背景檢查(stderr;使用 `--quiet` 或執行 `upgrade` / `skill` 時略過):**
|
|
702
711
|
- **CLI 版本:** dbcli 會查詢 npm registry(有快取,約每 24 小時一次)。若有新版,一般指令結束後會印一行提示。
|
|
703
|
-
- **已安裝的 skill:** 若曾執行 `dbcli skill --install <platform>`,dbcli
|
|
712
|
+
- **已安裝的 skill:** 若曾執行 `dbcli skill --install <platform>`,dbcli 會比對各平台**主 skill 檔**(`SKILL.md` 或 Cursor 的 `dbcli.mdc`)與套件內的 `assets/SKILL.md`;若不一致,會提示需重新安裝的平台(`dbcli skill --install <platform>`)。執行 `dbcli upgrade` 時也會一併顯示 skill 與版本資訊。重新安裝時也會一併更新技能旁的 `reference.md`。
|
|
704
713
|
|
|
705
714
|
#### `dbcli shell`
|
|
706
715
|
|
|
@@ -956,7 +965,7 @@ Query-only 代理無法寫入任何表,也無法讀取黑名單表或欄位
|
|
|
956
965
|
|
|
957
966
|
## AI 整合指南
|
|
958
967
|
|
|
959
|
-
dbcli
|
|
968
|
+
dbcli 內建供 AI 使用的 skill 文件(`assets/SKILL.md` 與 `assets/reference.md`),並可複製到常見 AI 開發工具的目錄。
|
|
960
969
|
|
|
961
970
|
### 快速開始
|
|
962
971
|
|
|
@@ -988,7 +997,7 @@ dbcli skill --install cursor
|
|
|
988
997
|
4. 重新啟動 Claude Code 擴充
|
|
989
998
|
5. 在對話中詢問:「顯示資料庫 schema」或「查詢作用中使用者」
|
|
990
999
|
|
|
991
|
-
**Skill 路徑:** `~/.claude/skills/dbcli
|
|
1000
|
+
**Skill 路徑:** `~/.claude/skills/dbcli/`(`SKILL.md` + `reference.md`)
|
|
992
1001
|
|
|
993
1002
|
---
|
|
994
1003
|
|
|
@@ -1000,7 +1009,7 @@ dbcli skill --install cursor
|
|
|
1000
1009
|
4. 啟動 Gemini:`gemini start`
|
|
1001
1010
|
5. 在對話中請求:「查詢 users 表」或「列出資料庫資料表」
|
|
1002
1011
|
|
|
1003
|
-
**Skill 路徑:** `~/.gemini/skills/dbcli
|
|
1012
|
+
**Skill 路徑:** `~/.gemini/skills/dbcli/`(`SKILL.md` + `reference.md`)
|
|
1004
1013
|
|
|
1005
1014
|
---
|
|
1006
1015
|
|
|
@@ -1012,7 +1021,7 @@ dbcli skill --install cursor
|
|
|
1012
1021
|
4. 安裝 Copilot CLI:`npm install -g @github-next/github-copilot-cli`
|
|
1013
1022
|
5. 使用 `copilot --help` 並探索與 dbcli 的整合
|
|
1014
1023
|
|
|
1015
|
-
**Skill 路徑:** 執行 `dbcli skill --install copilot`
|
|
1024
|
+
**Skill 路徑:** 執行 `dbcli skill --install copilot` 於專案根目錄時,寫入 **`.github/skills/dbcli/`**(`SKILL.md` + `reference.md`)。
|
|
1016
1025
|
|
|
1017
1026
|
---
|
|
1018
1027
|
|
|
@@ -1024,7 +1033,7 @@ dbcli skill --install cursor
|
|
|
1024
1033
|
4. 開啟 Cursor
|
|
1025
1034
|
5. 在 Composer 中:「新增一筆使用者」或「匯出使用者資料」
|
|
1026
1035
|
|
|
1027
|
-
**Skill 路徑:**
|
|
1036
|
+
**Skill 路徑:** 在**目前工作目錄**執行 `dbcli skill --install cursor` 時,寫入 **`.cursor/rules/dbcli.mdc`**(摘要與工作流程)及 **`.cursor/skills/dbcli/reference.md`**(完整旗標與範例)。
|
|
1028
1037
|
|
|
1029
1038
|
---
|
|
1030
1039
|
|
|
@@ -1051,7 +1060,7 @@ dbcli skill --install claude
|
|
|
1051
1060
|
|
|
1052
1061
|
### 升級後更新 skill
|
|
1053
1062
|
|
|
1054
|
-
`dbcli skill`
|
|
1063
|
+
`dbcli skill` 會複製套件內的 **`assets/SKILL.md`**;使用 **`--install`** 時另會複製 **`assets/reference.md`** 至技能旁。**不會**依你即時的 `.dbcli` 設定重新產生內文。當**升級 dbcli** 或內建 skill 變更時,請對所使用平台重新執行:
|
|
1055
1064
|
|
|
1056
1065
|
```bash
|
|
1057
1066
|
dbcli skill --install claude
|
|
@@ -1059,7 +1068,7 @@ dbcli skill --install gemini
|
|
|
1059
1068
|
# …依需求
|
|
1060
1069
|
```
|
|
1061
1070
|
|
|
1062
|
-
|
|
1071
|
+
若本機**主 skill 檔**早於套件內 `assets/SKILL.md`,多數指令結束後會在 **stderr** 提醒(見 **`dbcli upgrade`**)。**權限**與**黑名單**變更會影響執行期允許的操作—建議搭配 `dbcli status`、`dbcli blacklist list` 讓代理掌握現況;skill 內文仍可能列出完整指令表。
|
|
1063
1072
|
|
|
1064
1073
|
---
|
|
1065
1074
|
|
|
@@ -1230,6 +1239,7 @@ chmod +x dist/cli.mjs
|
|
|
1230
1239
|
- **PostgreSQL:** 12.0+
|
|
1231
1240
|
- **MySQL:** 8.0+
|
|
1232
1241
|
- **MariaDB:** 10.5+
|
|
1242
|
+
- **MongoDB:** 4.4+(`mongodb://` 與 `mongodb+srv://` 查詢與列集合;見前文 **MongoDB Atlas / SRV 連線**)
|
|
1233
1243
|
|
|
1234
1244
|
### 執行環境
|
|
1235
1245
|
|