@carllee1983/dbcli 9.1.2 → 11.0.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/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor/rules/dbcli.mdc +60 -21
- package/.cursor/skills/dbcli/reference.md +73 -20
- package/.cursor-plugin/plugin.json +1 -1
- package/.github/skills/dbcli/SKILL.md +60 -21
- package/.github/skills/dbcli/reference.md +73 -20
- package/CHANGELOG.md +144 -0
- package/README.dev.md +19 -6
- package/README.md +50 -11
- package/README.zh-TW.md +45 -12
- package/assets/SKILL.md +60 -21
- package/assets/reference.md +73 -20
- package/assets/ui-template.html +17 -17
- package/dist/cli-runtime.mjs +4663 -478
- package/dist/cli.mjs +3 -2
- package/dist/core.d.ts +23 -9
- package/dist/core.mjs +91 -18
- package/gemini-extension.json +1 -1
- package/package.json +3 -2
- package/plugins/dbcli-agent/.codex-plugin/plugin.json +1 -1
- package/plugins/dbcli-agent/skills/dbcli/SKILL.md +60 -21
- package/plugins/dbcli-agent/skills/dbcli/reference.md +73 -20
- package/scripts/postinstall-check-bun.mjs +1 -1
- package/skills/dbcli/SKILL.md +60 -21
- package/skills/dbcli/reference.md +73 -20
|
@@ -119,24 +119,24 @@ dbcli query '{}' --collection events --format json 2>/dev/null | jq '.rows | len
|
|
|
119
119
|
Initialize `.dbcli` configuration file. Typically run manually by the developer — avoid running on behalf of the user unless explicitly requested.
|
|
120
120
|
|
|
121
121
|
```bash
|
|
122
|
-
dbcli init #
|
|
123
|
-
dbcli init --system mysql --host localhost --port 3306 --user root --name mydb
|
|
122
|
+
dbcli init # Prompt for a name; create named v2
|
|
123
|
+
dbcli init --conn-name local --system mysql --host localhost --port 3306 --user root --name mydb
|
|
124
124
|
dbcli init --use-env-refs # Store env var references
|
|
125
|
-
dbcli init --no-interactive --force
|
|
125
|
+
dbcli init --conn-name local --no-interactive --force # Non-interactive; credentials from environment
|
|
126
126
|
|
|
127
127
|
# MongoDB — field-by-field (primary path, same shape as SQL)
|
|
128
|
-
dbcli init --system mongodb --host localhost --port 27017 --user admin --password secret --auth-source admin --name mydb
|
|
129
|
-
dbcli init --system mongodb --host localhost --port 27017 --name mydb # No auth
|
|
130
|
-
# MongoDB — full URI (
|
|
131
|
-
dbcli init --system mongodb --uri "mongodb://user:pass@host:27017/mydb?authSource=admin"
|
|
128
|
+
dbcli init --conn-name local --system mongodb --host localhost --port 27017 --user admin --password secret --auth-source admin --name mydb
|
|
129
|
+
dbcli init --conn-name local --system mongodb --host localhost --port 27017 --name mydb # No auth
|
|
130
|
+
# MongoDB — full URI (decomposed into fields on write; multi-host / secret-option strings stay as `uri` with a warning)
|
|
131
|
+
dbcli init --conn-name local --system mongodb --uri "mongodb://user:pass@host:27017/mydb?authSource=admin"
|
|
132
132
|
|
|
133
133
|
# Redis (database = logical DB index)
|
|
134
|
-
dbcli init --system redis --host localhost --port 6379
|
|
135
|
-
dbcli init --system redis --host localhost --port 6379 --password secret --name 0
|
|
134
|
+
dbcli init --conn-name local --system redis --host localhost --port 6379
|
|
135
|
+
dbcli init --conn-name local --system redis --host localhost --port 6379 --password secret --name 0
|
|
136
136
|
|
|
137
137
|
# Elasticsearch
|
|
138
|
-
dbcli init --system elasticsearch --host localhost --port 9200 --user elastic --password changeme
|
|
139
|
-
dbcli init --system elasticsearch --cloud-id "myCluster:dXMtZWFzdC0xLmF3..." --api-key "<base64>"
|
|
138
|
+
dbcli init --conn-name local --system elasticsearch --host localhost --port 9200 --user elastic --password changeme
|
|
139
|
+
dbcli init --conn-name local --system elasticsearch --cloud-id "myCluster:dXMtZWFzdC0xLmF3..." --api-key "<base64>"
|
|
140
140
|
|
|
141
141
|
# Multi-connection (v2 format)
|
|
142
142
|
dbcli init --conn-name staging --env-file .env.staging # Named connection with custom env file
|
|
@@ -151,17 +151,43 @@ dbcli --global init --conn-name shared --system postgresql --host db.example.com
|
|
|
151
151
|
dbcli --global use --list
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
+
Every new or additional connection needs a nonblank connection name. Pass `--conn-name <name>`, or run `dbcli init` in an interactive terminal to be asked for one. The name prompt has no suggested `default`; empty or whitespace-only answers explain the requirement and prompt again. Cancelling or ending the name prompt stops before any connection test or configuration/credential write. An explicit nonblank `--conn-name` skips this prompt, and `--conn-name default` is valid. An explicitly blank `--conn-name` is an error in every mode, before connection tests or writes. `--name` still means the database name (the logical DB index for Redis), never the connection name.
|
|
155
|
+
|
|
156
|
+
Without a TTY, with `--no-interactive`, or when `--use-env-refs` plus all five `--env-*` options automatically disables interaction, a missing or blank `--conn-name` fails with guidance to supply it, before database access or configuration/credential writes. Complete credentials, `--name`, `--env-file`, and `--force` do not supply a connection name.
|
|
157
|
+
|
|
158
|
+
New initialization always creates named v2 configuration, including plain `init` and explicit `--config` paths; it no longer creates an unnamed v1 configuration. Existing v1 configurations remain readable and their established named v2 import is retained. The first explicitly named connection is still the default in a new registry; adding a connection preserves an existing registry's default or no-default state. An explicitly chosen duplicate name still requires interactive overwrite confirmation or `--force`; a noninteractive duplicate without `--force`, or a declined confirmation, leaves files untouched. `--remove` and `--rename` do not ask for a new connection name.
|
|
159
|
+
|
|
154
160
|
**Key options:** `--system`, `--permission`, `--use-env-refs`, `--skip-test`, `--no-interactive`, `--force`, `--conn-name <name>`, `--env-file <path>`, `--remove <name>`, `--rename <old:new>`
|
|
155
161
|
|
|
156
162
|
**Environment-reference options:** `--env-host <var>`, `--env-port <var>`, `--env-user <var>`, `--env-password <var>`, `--env-database <var>`
|
|
157
163
|
|
|
158
|
-
**MongoDB-specific options:** `--uri <uri>` (full connection URI
|
|
164
|
+
**MongoDB-specific options:** `--uri <uri>` (full connection URI, decomposed into field config on write: `authSource`/`replicaSet`/`tls`(`ssl`) become dedicated fields, `mongodb+srv` becomes `srv: true`, the path database becomes `database`, other parameters go to `options`; multi-host strings, strings carrying `authMechanismProperties`/`tlsCertificateKeyFilePassword`/`proxyPassword`, strings repeating a query key, and strings whose `authMechanism` is not SCRAM-SHA-1/SCRAM-SHA-256 are stored as-is in `uri` with a plaintext-credentials warning; cannot be combined with `--host`/`--port`/`--user`/`--password`/`--auth-source`/`--replica-set`/`--srv`/`--tls`/`--no-tls` or `--use-env-refs`; `--name` may be combined), `--auth-source <db>` (auth database, default: `admin` when user/password set). `--replica-set <name>` (writes `replicaSet`), `--srv` (writes `srv: true` and no `port`; builds `mongodb+srv://` and resolves hosts via DNS SRV), `--tls` / `--no-tls` (writes `tls: true` / `tls: false`; neither flag writes no `tls` key, so the driver default applies). Interactive `init` skips the prompt for any of these given as a flag; otherwise it asks `srv` right after `host` (before `port`) and `replicaSet` / `tls` under an "advanced options?" prompt. The flags also apply with `--use-env-refs`.
|
|
159
165
|
|
|
160
166
|
**Elasticsearch-specific options:** `--cloud-id <id>` (Elastic Cloud), `--api-key <key>` (ApiKey auth). Other ES fields (`nodes[]`, `protocol`, `caPath`, `rejectUnauthorized`) can be edited directly in `.dbcli`.
|
|
161
167
|
|
|
162
168
|
**Redis note:** the `database` (or `--name`) field is the logical DB index (`"0"` … `"15"`), not a database name.
|
|
163
169
|
|
|
164
|
-
**Multi-connection:**
|
|
170
|
+
**Multi-connection:** Every newly created connection uses v2 with an explicitly supplied or interactively entered name. Each connection can have its own env file and permission level; `--env-file` does not replace the name requirement. Existing v1 configs are automatically imported as the `default` connection when upgrading.
|
|
171
|
+
|
|
172
|
+
V2 may omit the top-level `default` field; if supplied, it must be a nonempty
|
|
173
|
+
string naming an existing connection. `null`, `""`, and nonexistent names are
|
|
174
|
+
invalid. The first explicitly named connection defaults a new registry; adding
|
|
175
|
+
another preserves the existing default or no-default state. Existing v1 reads
|
|
176
|
+
and named v1 imports remain supported; neither configuration version changes.
|
|
177
|
+
|
|
178
|
+
Legacy project configuration compatibility: adding a connection cannot import a
|
|
179
|
+
direct-project v2 registry when an existing connection uses an `envFile` other
|
|
180
|
+
than `.env.local`. `init` refuses before writing and retains the existing config
|
|
181
|
+
and env files. An administrator must migrate the registry and custom env files
|
|
182
|
+
to supported home storage before retrying. Bound/home-storage v2 configs and
|
|
183
|
+
direct-project v2 configs with no `envFile` or only `.env.local` remain supported.
|
|
184
|
+
|
|
185
|
+
`init --remove <name>` clears `default` and reports that change when removing its
|
|
186
|
+
connection; it never chooses another connection. Removing a non-default keeps
|
|
187
|
+
the saved default, and removing a connection from a no-default config keeps that
|
|
188
|
+
state. The public `removeConnection` helper follows the same rules. Deleting
|
|
189
|
+
the last connection is rejected without changing the config. Renaming preserves
|
|
190
|
+
the no-default state, or updates the default name when renaming that connection.
|
|
165
191
|
|
|
166
192
|
Use root-level `--global` with `init`, `use`, `status`, `query`, or any other command to read or mutate the user-global v2 registry at `~/.config/dbcli/config.json`. Without it, the current project binding remains the source of truth. The global registry uses the same private file mode and integrity record as project home storage.
|
|
167
193
|
|
|
@@ -169,11 +195,12 @@ Use root-level `--global` with `init`, `use`, `status`, `query`, or any other co
|
|
|
169
195
|
|
|
170
196
|
### use
|
|
171
197
|
|
|
172
|
-
|
|
198
|
+
Set, clear, or display the default database connection (v2 multi-connection config).
|
|
173
199
|
|
|
174
200
|
```bash
|
|
175
|
-
dbcli use # Show current default
|
|
201
|
+
dbcli use # Show the current default, or describe no default
|
|
176
202
|
dbcli use staging # Switch default to 'staging'
|
|
203
|
+
dbcli use --unset # Clear the saved default; connections are unchanged
|
|
177
204
|
dbcli use --list # List all connections (* marks default)
|
|
178
205
|
dbcli use --list --format json # Credential-free connection identity inventory
|
|
179
206
|
```
|
|
@@ -188,17 +215,43 @@ Cloud ID-only Elasticsearch connections also return `null` instead of default
|
|
|
188
215
|
placeholders. It deliberately excludes user names, passwords, URIs, Cloud IDs,
|
|
189
216
|
API keys, and env variable names.
|
|
190
217
|
Misspelled selectors suggest nearby configured connection names.
|
|
218
|
+
Without a default, text inventory marks no connection as default and every JSON
|
|
219
|
+
item has `isDefault: false`. Inventory remains usable, and `doctor` accepts an
|
|
220
|
+
omitted default as valid v2 configuration. Its connection checks still require
|
|
221
|
+
an explicit selector, for example `dbcli --use staging doctor`.
|
|
191
222
|
|
|
192
|
-
Any command can also use `--use <name>`
|
|
223
|
+
Any command can also use root-level `--use <name>` before the command to
|
|
224
|
+
temporarily select a connection without changing the default. `query`, `schema`,
|
|
225
|
+
`list`, `export`, and `check` also accept it after the command:
|
|
193
226
|
|
|
194
227
|
```bash
|
|
195
228
|
dbcli query --use staging "SELECT * FROM users LIMIT 10"
|
|
196
229
|
dbcli list --use prod
|
|
197
230
|
```
|
|
198
231
|
|
|
232
|
+
Selection precedence is explicit `--use`, then `DBCLI_CONNECTION`, then the
|
|
233
|
+
saved default. Conflicting root-level and command-level selectors are an error;
|
|
234
|
+
blank CLI selectors are invalid, while a blank environment selector is ignored.
|
|
235
|
+
Without a default, connection-dependent commands require an explicit `--use` or
|
|
236
|
+
`DBCLI_CONNECTION` selection. Otherwise they fail before database access with
|
|
237
|
+
an error naming both selectors and listing available connection names, never
|
|
238
|
+
endpoints or credentials. No caller selects the first connection automatically.
|
|
239
|
+
Unknown names and production targets retain their validation and explicit
|
|
240
|
+
selection safeguards.
|
|
241
|
+
|
|
242
|
+
`use --unset` removes only the persisted v2 `default` field and reports that it
|
|
243
|
+
was cleared. It also succeeds when the field is already absent without changing
|
|
244
|
+
connections. It rejects a connection name, `--list`, `--confirm-production`, or
|
|
245
|
+
`--format json` in the same invocation before writing, and never converts or
|
|
246
|
+
overwrites v1. It uses the existing approved, integrity-protected configuration
|
|
247
|
+
write path and is blocked under `DBCLI_AGENT_MODE=1`. To set a default again, use
|
|
248
|
+
`dbcli use <name>`; production defaults still require the exact name repeated in
|
|
249
|
+
`--confirm-production <name>`, and production database access still requires an
|
|
250
|
+
explicit selector even if that connection is the saved default.
|
|
251
|
+
|
|
199
252
|
**Requires v2 config** (created with `dbcli init --conn-name`).
|
|
200
253
|
|
|
201
|
-
**Options:** `--list`, `--format <text|json>`, `--confirm-production <name>` (required when explicitly selecting a production connection as the default).
|
|
254
|
+
**Options:** `--list`, `--unset`, `--format <text|json>`, `--confirm-production <name>` (required when explicitly selecting a production connection as the default).
|
|
202
255
|
|
|
203
256
|
### password
|
|
204
257
|
|
|
@@ -3591,7 +3644,7 @@ Parser behaviour (`src/core/saved-queries/parser.ts::normaliseVisual`):
|
|
|
3591
3644
|
|
|
3592
3645
|
MongoDB connections use a JSON-based query model instead of SQL. Treat MongoDB support as a narrower document-database path, not as a full SQL feature equivalent.
|
|
3593
3646
|
|
|
3594
|
-
`init --system mongodb` defaults to a field-by-field wizard (`host`, `srv`, `port`, `user`, `password` + `authSource`, then optional `replicaSet` / `tls`); a full `uri` is an explicit advanced choice in the interactive flow and the
|
|
3647
|
+
`init --system mongodb` defaults to a field-by-field wizard (`host`, `srv`, `port`, `user`, `password` + `authSource`, then optional `replicaSet` / `tls`); a full `uri` is an explicit advanced choice in the interactive flow (stored as-is) and the non-interactive path via `--uri` (with the required `--conn-name`), where the string is decomposed into the field config on write. Optional fields `authSource`, `replicaSet`, `tls`, and `srv` express what previously required embedding options in the `uri` query string. Atlas-style `mongodb+srv://` URIs are supported both as a full `uri` and via the per-field `srv: true` option. `list` and `query` run against the database configured for the connection, and `query` always requires `--collection <name>`.
|
|
3595
3648
|
|
|
3596
3649
|
The 5000ms default server-selection timeout is often too tight for a connection over a VPN or to Atlas. Set a `timeout` field (ms) in the connection config, or override it per invocation with root-level `--timeout`, e.g. `dbcli --timeout 20000 --use <conn> list`.
|
|
3597
3650
|
|
|
@@ -3617,10 +3670,10 @@ The 5000ms default server-selection timeout is often too tight for a connection
|
|
|
3617
3670
|
|
|
3618
3671
|
```bash
|
|
3619
3672
|
# 1. Initialize — field-by-field (primary path)
|
|
3620
|
-
dbcli init --system mongodb --host localhost --port 27017 \
|
|
3673
|
+
dbcli init --conn-name local --system mongodb --host localhost --port 27017 \
|
|
3621
3674
|
--user admin --password '<secret>' --auth-source admin --name mydb
|
|
3622
3675
|
# ...or a full URI (advanced fallback, e.g. Atlas SRV clusters)
|
|
3623
|
-
dbcli init --system mongodb --uri "mongodb+srv://user:pass@cluster.example.mongodb.net/mydb"
|
|
3676
|
+
dbcli init --conn-name local --system mongodb --uri "mongodb+srv://user:pass@cluster.example.mongodb.net/mydb"
|
|
3624
3677
|
|
|
3625
3678
|
# 2. List collections
|
|
3626
3679
|
dbcli list --format json
|