@carllee1983/dbcli 1.46.0 → 1.47.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 +5 -2
- package/.cursor/skills/dbcli/reference.md +30 -2
- package/.cursor-plugin/plugin.json +1 -1
- package/.github/skills/dbcli/SKILL.md +5 -2
- package/.github/skills/dbcli/reference.md +30 -2
- package/CHANGELOG.md +14 -0
- package/assets/SKILL.md +5 -2
- package/assets/SKILL.zh-TW.md +4 -2
- package/assets/reference.md +30 -2
- package/dist/cli.mjs +725 -11288
- package/dist/core.d.ts +59 -3
- package/dist/core.mjs +127 -8
- package/gemini-extension.json +1 -1
- package/package.json +1 -1
- package/plugins/dbcli-agent/.codex-plugin/plugin.json +1 -1
- package/plugins/dbcli-agent/skills/dbcli/SKILL.md +5 -2
- package/plugins/dbcli-agent/skills/dbcli/reference.md +30 -2
- package/skills/dbcli/SKILL.md +5 -2
- package/skills/dbcli/reference.md +30 -2
package/.cursor/rules/dbcli.mdc
CHANGED
|
@@ -77,7 +77,10 @@ When reporting a check's outcome use the vocabulary `verified` (evidence matched
|
|
|
77
77
|
`not_verified` (check ran and contradicted) / `indeterminate` (ran but ambiguous) /
|
|
78
78
|
`blocked` (could not run due to config, permission, schema, placeholder, or safety gate).
|
|
79
79
|
|
|
80
|
-
Prefer `--format json` for agent-friendly output.
|
|
80
|
+
Prefer `--format json` for agent-friendly output. Diagnostics (auto-limit notices,
|
|
81
|
+
warnings) go to stderr so stdout stays parseable — when piping JSON into a parser,
|
|
82
|
+
use `2>/dev/null` or leave stderr alone. **Never `2>&1`**: it merges those lines back
|
|
83
|
+
into stdout and the parse fails.
|
|
81
84
|
|
|
82
85
|
## Agent Task Packs
|
|
83
86
|
|
|
@@ -553,4 +556,4 @@ schema. Raw `query` / `export` invocations render a sortable table only.
|
|
|
553
556
|
- Blacklisted tables and columns are redacted from query output.
|
|
554
557
|
- `schema` reports `estimatedRowCount` and `sizeCategory` (small / medium / large / huge). For large/huge tables add `WHERE` or `LIMIT` — bands in reference.md.
|
|
555
558
|
- `doctor` on `mongodb+srv://` reports whether SRV resolves natively or through the DoH fallback — useful when the runtime restricts DNS.
|
|
556
|
-
- **Global flags:** `--version`, `--config <path>`, `--global`, `--use <name>`, `-v` / `--verbose` / `-vv`, `-q` / `--quiet`, `--no-color` (also honours `NO_COLOR`). Root-level flags must precede the command unless the command explicitly declares a command-level option.
|
|
559
|
+
- **Global flags:** `--version`, `--config <path>`, `--global`, `--use <name>`, `--timeout <ms>`, `-v` / `--verbose` / `-vv`, `-q` / `--quiet`, `--no-color` (also honours `NO_COLOR`). Root-level flags must precede the command unless the command explicitly declares a command-level option.
|
|
@@ -19,6 +19,28 @@ command-level option is only valid after the command that declares it.
|
|
|
19
19
|
| `--config <path>` | Select the `.dbcli` configuration path. |
|
|
20
20
|
| `--global` | Select the user-global registry at `~/.config/dbcli/config.json` instead of the current project's `.dbcli` config. Place it before the command path. |
|
|
21
21
|
| `--use <connection>` | Select a named connection for this invocation; place it before the command path unless that command explicitly lists a command-level `--use`. |
|
|
22
|
+
| `--timeout <ms>` | Connection timeout in milliseconds (integer, 100–600000), overriding the connection config's `timeout` field for this invocation. Applies to every engine adapter. Without either the flag or the config field, adapters fall back to their built-in 5000ms default. |
|
|
23
|
+
|
|
24
|
+
`--timeout` is applied only when the adapter is constructed for this invocation — it is
|
|
25
|
+
never written back to `config.json`. Set the connection's `timeout` field instead for a
|
|
26
|
+
value that persists across runs. On PostgreSQL, the same value is also used as the
|
|
27
|
+
session's `statement_timeout` (not just the connection timeout), so a low value can cut
|
|
28
|
+
off a long-running query with an error that looks like a connection timeout; the 100ms
|
|
29
|
+
floor exists specifically to keep that failure mode from being too easy to trigger.
|
|
30
|
+
Elasticsearch applies its timeout per request rather than once for the whole connection.
|
|
31
|
+
The `timeout` field itself always takes a literal number — unlike other connection
|
|
32
|
+
fields, it does not accept an `{"$env": "..."}` reference.
|
|
33
|
+
|
|
34
|
+
### Redirecting output
|
|
35
|
+
|
|
36
|
+
Results go to stdout; diagnostics (auto-limit notices, warnings, update hints) go to
|
|
37
|
+
stderr. That split is what keeps `--format json` machine-parseable, so do not collapse
|
|
38
|
+
it with `2>&1` — the diagnostic lines land in front of the JSON document and the parse
|
|
39
|
+
fails. Pipe stdout alone, or add `2>/dev/null` when the diagnostics are not wanted:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
dbcli query '{}' --collection events --format json 2>/dev/null | jq '.rows | length'
|
|
43
|
+
```
|
|
22
44
|
|
|
23
45
|
## Commands
|
|
24
46
|
|
|
@@ -118,6 +140,10 @@ agent mode disabled. A host that needs protection from a same-user hostile
|
|
|
118
140
|
process can set `DBCLI_CONFIG_INTEGRITY_ANCHOR_DIR` to a protected or read-only
|
|
119
141
|
directory; trusted writes publish detached digests there.
|
|
120
142
|
|
|
143
|
+
When a connection's config fails schema validation, dbcli reports the specific field
|
|
144
|
+
path(s) that are wrong for that connection's declared `system` — not the raw Zod union
|
|
145
|
+
error tree — so a broken `.dbcli` can be fixed without guessing which branch applies.
|
|
146
|
+
|
|
121
147
|
### list
|
|
122
148
|
|
|
123
149
|
List all tables (SQL), collections (MongoDB), keys (Redis), or indices (Elasticsearch).
|
|
@@ -2605,6 +2631,8 @@ MongoDB connections use a JSON-based query model instead of SQL. Treat MongoDB s
|
|
|
2605
2631
|
|
|
2606
2632
|
`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 unchanged non-interactive path via `--uri`. 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>`.
|
|
2607
2633
|
|
|
2634
|
+
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`.
|
|
2635
|
+
|
|
2608
2636
|
**Supported commands:** `init`, `use`, `list`, `schema`, `query`, `q`, `insert`, `update`, `delete`, `export`, `status`, `shell`, `doctor`, `upgrade`, `completion`
|
|
2609
2637
|
|
|
2610
2638
|
**Limited support:**
|
|
@@ -2669,7 +2697,7 @@ Redis connections speak Redis commands rather than SQL. The adapter uses Bun's n
|
|
|
2669
2697
|
|
|
2670
2698
|
- Required fields: `system: redis`, `host`, `port`. `password` and `database` are optional.
|
|
2671
2699
|
- `database` is the **logical DB index** (`"0"` … `"15"`), kept as a string to play nicely with env-ref bindings. `list` and the connection metadata both label it as the active DB.
|
|
2672
|
-
- `connection.timeout` (ms, default 5000) maps to the client's `connectionTimeout
|
|
2700
|
+
- `connection.timeout` (ms, default 5000) maps to the client's `connectionTimeout`; root-level `--timeout <ms>` overrides it for a single invocation.
|
|
2673
2701
|
|
|
2674
2702
|
### Permission classification
|
|
2675
2703
|
|
|
@@ -2799,7 +2827,7 @@ Elasticsearch connections speak the REST API. The adapter is fetch-based (no SDK
|
|
|
2799
2827
|
- Either `host` + `port` (default `https://localhost:9200`) or `nodes: [...]` (first node is used) or `cloudId`.
|
|
2800
2828
|
- Auth precedence: `apiKey` → `user`/`password` (HTTP Basic). Leave both unset for an open cluster.
|
|
2801
2829
|
- `protocol` defaults to `https`. For TLS quirks: `caPath` (path to a PEM bundle) and `rejectUnauthorized: false` (last resort).
|
|
2802
|
-
- `connection.timeout` (ms, default 5000) is wired to `AbortController` on every request.
|
|
2830
|
+
- `connection.timeout` (ms, default 5000) is wired to `AbortController` on every request; root-level `--timeout <ms>` overrides it for a single invocation.
|
|
2803
2831
|
|
|
2804
2832
|
### Permission classification
|
|
2805
2833
|
|
|
@@ -77,7 +77,10 @@ When reporting a check's outcome use the vocabulary `verified` (evidence matched
|
|
|
77
77
|
`not_verified` (check ran and contradicted) / `indeterminate` (ran but ambiguous) /
|
|
78
78
|
`blocked` (could not run due to config, permission, schema, placeholder, or safety gate).
|
|
79
79
|
|
|
80
|
-
Prefer `--format json` for agent-friendly output.
|
|
80
|
+
Prefer `--format json` for agent-friendly output. Diagnostics (auto-limit notices,
|
|
81
|
+
warnings) go to stderr so stdout stays parseable — when piping JSON into a parser,
|
|
82
|
+
use `2>/dev/null` or leave stderr alone. **Never `2>&1`**: it merges those lines back
|
|
83
|
+
into stdout and the parse fails.
|
|
81
84
|
|
|
82
85
|
## Agent Task Packs
|
|
83
86
|
|
|
@@ -553,4 +556,4 @@ schema. Raw `query` / `export` invocations render a sortable table only.
|
|
|
553
556
|
- Blacklisted tables and columns are redacted from query output.
|
|
554
557
|
- `schema` reports `estimatedRowCount` and `sizeCategory` (small / medium / large / huge). For large/huge tables add `WHERE` or `LIMIT` — bands in reference.md.
|
|
555
558
|
- `doctor` on `mongodb+srv://` reports whether SRV resolves natively or through the DoH fallback — useful when the runtime restricts DNS.
|
|
556
|
-
- **Global flags:** `--version`, `--config <path>`, `--global`, `--use <name>`, `-v` / `--verbose` / `-vv`, `-q` / `--quiet`, `--no-color` (also honours `NO_COLOR`). Root-level flags must precede the command unless the command explicitly declares a command-level option.
|
|
559
|
+
- **Global flags:** `--version`, `--config <path>`, `--global`, `--use <name>`, `--timeout <ms>`, `-v` / `--verbose` / `-vv`, `-q` / `--quiet`, `--no-color` (also honours `NO_COLOR`). Root-level flags must precede the command unless the command explicitly declares a command-level option.
|
|
@@ -19,6 +19,28 @@ command-level option is only valid after the command that declares it.
|
|
|
19
19
|
| `--config <path>` | Select the `.dbcli` configuration path. |
|
|
20
20
|
| `--global` | Select the user-global registry at `~/.config/dbcli/config.json` instead of the current project's `.dbcli` config. Place it before the command path. |
|
|
21
21
|
| `--use <connection>` | Select a named connection for this invocation; place it before the command path unless that command explicitly lists a command-level `--use`. |
|
|
22
|
+
| `--timeout <ms>` | Connection timeout in milliseconds (integer, 100–600000), overriding the connection config's `timeout` field for this invocation. Applies to every engine adapter. Without either the flag or the config field, adapters fall back to their built-in 5000ms default. |
|
|
23
|
+
|
|
24
|
+
`--timeout` is applied only when the adapter is constructed for this invocation — it is
|
|
25
|
+
never written back to `config.json`. Set the connection's `timeout` field instead for a
|
|
26
|
+
value that persists across runs. On PostgreSQL, the same value is also used as the
|
|
27
|
+
session's `statement_timeout` (not just the connection timeout), so a low value can cut
|
|
28
|
+
off a long-running query with an error that looks like a connection timeout; the 100ms
|
|
29
|
+
floor exists specifically to keep that failure mode from being too easy to trigger.
|
|
30
|
+
Elasticsearch applies its timeout per request rather than once for the whole connection.
|
|
31
|
+
The `timeout` field itself always takes a literal number — unlike other connection
|
|
32
|
+
fields, it does not accept an `{"$env": "..."}` reference.
|
|
33
|
+
|
|
34
|
+
### Redirecting output
|
|
35
|
+
|
|
36
|
+
Results go to stdout; diagnostics (auto-limit notices, warnings, update hints) go to
|
|
37
|
+
stderr. That split is what keeps `--format json` machine-parseable, so do not collapse
|
|
38
|
+
it with `2>&1` — the diagnostic lines land in front of the JSON document and the parse
|
|
39
|
+
fails. Pipe stdout alone, or add `2>/dev/null` when the diagnostics are not wanted:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
dbcli query '{}' --collection events --format json 2>/dev/null | jq '.rows | length'
|
|
43
|
+
```
|
|
22
44
|
|
|
23
45
|
## Commands
|
|
24
46
|
|
|
@@ -118,6 +140,10 @@ agent mode disabled. A host that needs protection from a same-user hostile
|
|
|
118
140
|
process can set `DBCLI_CONFIG_INTEGRITY_ANCHOR_DIR` to a protected or read-only
|
|
119
141
|
directory; trusted writes publish detached digests there.
|
|
120
142
|
|
|
143
|
+
When a connection's config fails schema validation, dbcli reports the specific field
|
|
144
|
+
path(s) that are wrong for that connection's declared `system` — not the raw Zod union
|
|
145
|
+
error tree — so a broken `.dbcli` can be fixed without guessing which branch applies.
|
|
146
|
+
|
|
121
147
|
### list
|
|
122
148
|
|
|
123
149
|
List all tables (SQL), collections (MongoDB), keys (Redis), or indices (Elasticsearch).
|
|
@@ -2605,6 +2631,8 @@ MongoDB connections use a JSON-based query model instead of SQL. Treat MongoDB s
|
|
|
2605
2631
|
|
|
2606
2632
|
`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 unchanged non-interactive path via `--uri`. 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>`.
|
|
2607
2633
|
|
|
2634
|
+
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`.
|
|
2635
|
+
|
|
2608
2636
|
**Supported commands:** `init`, `use`, `list`, `schema`, `query`, `q`, `insert`, `update`, `delete`, `export`, `status`, `shell`, `doctor`, `upgrade`, `completion`
|
|
2609
2637
|
|
|
2610
2638
|
**Limited support:**
|
|
@@ -2669,7 +2697,7 @@ Redis connections speak Redis commands rather than SQL. The adapter uses Bun's n
|
|
|
2669
2697
|
|
|
2670
2698
|
- Required fields: `system: redis`, `host`, `port`. `password` and `database` are optional.
|
|
2671
2699
|
- `database` is the **logical DB index** (`"0"` … `"15"`), kept as a string to play nicely with env-ref bindings. `list` and the connection metadata both label it as the active DB.
|
|
2672
|
-
- `connection.timeout` (ms, default 5000) maps to the client's `connectionTimeout
|
|
2700
|
+
- `connection.timeout` (ms, default 5000) maps to the client's `connectionTimeout`; root-level `--timeout <ms>` overrides it for a single invocation.
|
|
2673
2701
|
|
|
2674
2702
|
### Permission classification
|
|
2675
2703
|
|
|
@@ -2799,7 +2827,7 @@ Elasticsearch connections speak the REST API. The adapter is fetch-based (no SDK
|
|
|
2799
2827
|
- Either `host` + `port` (default `https://localhost:9200`) or `nodes: [...]` (first node is used) or `cloudId`.
|
|
2800
2828
|
- Auth precedence: `apiKey` → `user`/`password` (HTTP Basic). Leave both unset for an open cluster.
|
|
2801
2829
|
- `protocol` defaults to `https`. For TLS quirks: `caPath` (path to a PEM bundle) and `rejectUnauthorized: false` (last resort).
|
|
2802
|
-
- `connection.timeout` (ms, default 5000) is wired to `AbortController` on every request.
|
|
2830
|
+
- `connection.timeout` (ms, default 5000) is wired to `AbortController` on every request; root-level `--timeout <ms>` overrides it for a single invocation.
|
|
2803
2831
|
|
|
2804
2832
|
### Permission classification
|
|
2805
2833
|
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@ 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.47.0] - 2026-08-05 - 連線逾時可設定
|
|
9
|
+
|
|
10
|
+
決策記錄:`docs/adr/0003-connection-timeout-override-resolved-at-adapter-construction.md`。
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **新的 root-level 全域旗標 `--timeout <ms>`。** 覆寫連線設定中的 `timeout`;兩者都沒有時沿用各 adapter 內建的 5000ms。合法值為 100~600000 的整數,須放在子指令之前(和 `--global` / `--use` 一樣是 root-level flag)。對所有引擎有效,典型用途是 MongoDB 跨 VPN 或連 Atlas 時,預設 5 秒的 server selection timeout 太緊:`dbcli --timeout 20000 --use <conn> list`。這個覆寫只在建立連線時套用,不會寫回設定檔;要永久生效請在連線設定裡寫 `timeout` 欄位。
|
|
15
|
+
- **連線設定檔新增 `timeout` 欄位。** 四種連線 schema 皆支援,毫秒、100~600000 整數、可省略。
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- **設定檔驗證失敗的錯誤訊息改為可讀格式。** 過去會吐出整包 Zod `unionErrors` 巢狀 JSON;現在只列出與該連線 `system` 相符的分支問題,逐欄列出欄位路徑。
|
|
20
|
+
- **文件明確禁止 `2>&1`。** 診斷訊息走 stderr、結果走 stdout,合併兩者會讓 `--format json` 的輸出無法解析;SKILL 與 reference 都補上導管寫法。
|
|
21
|
+
|
|
8
22
|
## [1.46.0] - 2026-08-04 - MongoDB 逐欄連線設定
|
|
9
23
|
|
|
10
24
|
決策記錄:`docs/adr/0002-mongodb-connection-field-first-config.md`;規格:`docs/specs/2026-08-04-mongodb-field-first-connection.md`。
|
package/assets/SKILL.md
CHANGED
|
@@ -77,7 +77,10 @@ When reporting a check's outcome use the vocabulary `verified` (evidence matched
|
|
|
77
77
|
`not_verified` (check ran and contradicted) / `indeterminate` (ran but ambiguous) /
|
|
78
78
|
`blocked` (could not run due to config, permission, schema, placeholder, or safety gate).
|
|
79
79
|
|
|
80
|
-
Prefer `--format json` for agent-friendly output.
|
|
80
|
+
Prefer `--format json` for agent-friendly output. Diagnostics (auto-limit notices,
|
|
81
|
+
warnings) go to stderr so stdout stays parseable — when piping JSON into a parser,
|
|
82
|
+
use `2>/dev/null` or leave stderr alone. **Never `2>&1`**: it merges those lines back
|
|
83
|
+
into stdout and the parse fails.
|
|
81
84
|
|
|
82
85
|
## Agent Task Packs
|
|
83
86
|
|
|
@@ -553,4 +556,4 @@ schema. Raw `query` / `export` invocations render a sortable table only.
|
|
|
553
556
|
- Blacklisted tables and columns are redacted from query output.
|
|
554
557
|
- `schema` reports `estimatedRowCount` and `sizeCategory` (small / medium / large / huge). For large/huge tables add `WHERE` or `LIMIT` — bands in reference.md.
|
|
555
558
|
- `doctor` on `mongodb+srv://` reports whether SRV resolves natively or through the DoH fallback — useful when the runtime restricts DNS.
|
|
556
|
-
- **Global flags:** `--version`, `--config <path>`, `--global`, `--use <name>`, `-v` / `--verbose` / `-vv`, `-q` / `--quiet`, `--no-color` (also honours `NO_COLOR`). Root-level flags must precede the command unless the command explicitly declares a command-level option.
|
|
559
|
+
- **Global flags:** `--version`, `--config <path>`, `--global`, `--use <name>`, `--timeout <ms>`, `-v` / `--verbose` / `-vv`, `-q` / `--quiet`, `--no-color` (also honours `NO_COLOR`). Root-level flags must precede the command unless the command explicitly declares a command-level option.
|
package/assets/SKILL.zh-TW.md
CHANGED
|
@@ -60,7 +60,9 @@ legacy 單檔 `.dbcli`。若要防護同一 OS 使用者的惡意 process,host
|
|
|
60
60
|
|
|
61
61
|
回報驗證結果時使用詞彙:`verified`(證據符合)/ `not_verified`(驗證執行但結果矛盾)/ `indeterminate`(執行但證據不明確)/ `blocked`(因 config、權限、schema、placeholder 或安全閘門導致無法執行)。
|
|
62
62
|
|
|
63
|
-
優先用 `--format json`
|
|
63
|
+
優先用 `--format json` 取得代理友善的輸出。診斷訊息(auto-limit 提示、警告)一律走 stderr,
|
|
64
|
+
stdout 保持可解析——把 JSON 導進 parser 時請用 `2>/dev/null` 或不要動 stderr。
|
|
65
|
+
**絕對不要用 `2>&1`**:那會把那些訊息併回 stdout,解析必定失敗。
|
|
64
66
|
|
|
65
67
|
## Agent Task Packs
|
|
66
68
|
|
|
@@ -426,4 +428,4 @@ dbcli export "SELECT * FROM orders" --format html --output orders.html
|
|
|
426
428
|
- 被 blacklist 的 table / column 會從查詢輸出中遮蔽。
|
|
427
429
|
- `schema` 回報 `estimatedRowCount` 與 `sizeCategory`(small / medium / large / huge)。大 / 巨大表要加 `WHERE` 或 `LIMIT` — 分界值見 reference.md。
|
|
428
430
|
- 對 `mongodb+srv://` 連線,`doctor` 會回報 SRV 是用原生解析或走 DoH fallback — 在執行環境限制 DNS 時很有用。
|
|
429
|
-
- **全域旗標:** `--version`、`--config <path>`、`--global`、`--use <name>`、`-v` / `--verbose` / `-vv`、`-q` / `--quiet`、`--no-color`(也尊重 `NO_COLOR`)。除非指令明確宣告 command-level 選項,否則 root-level 旗標必須放在指令之前。
|
|
431
|
+
- **全域旗標:** `--version`、`--config <path>`、`--global`、`--use <name>`、`--timeout <ms>`、`-v` / `--verbose` / `-vv`、`-q` / `--quiet`、`--no-color`(也尊重 `NO_COLOR`)。除非指令明確宣告 command-level 選項,否則 root-level 旗標必須放在指令之前。
|
package/assets/reference.md
CHANGED
|
@@ -19,6 +19,28 @@ command-level option is only valid after the command that declares it.
|
|
|
19
19
|
| `--config <path>` | Select the `.dbcli` configuration path. |
|
|
20
20
|
| `--global` | Select the user-global registry at `~/.config/dbcli/config.json` instead of the current project's `.dbcli` config. Place it before the command path. |
|
|
21
21
|
| `--use <connection>` | Select a named connection for this invocation; place it before the command path unless that command explicitly lists a command-level `--use`. |
|
|
22
|
+
| `--timeout <ms>` | Connection timeout in milliseconds (integer, 100–600000), overriding the connection config's `timeout` field for this invocation. Applies to every engine adapter. Without either the flag or the config field, adapters fall back to their built-in 5000ms default. |
|
|
23
|
+
|
|
24
|
+
`--timeout` is applied only when the adapter is constructed for this invocation — it is
|
|
25
|
+
never written back to `config.json`. Set the connection's `timeout` field instead for a
|
|
26
|
+
value that persists across runs. On PostgreSQL, the same value is also used as the
|
|
27
|
+
session's `statement_timeout` (not just the connection timeout), so a low value can cut
|
|
28
|
+
off a long-running query with an error that looks like a connection timeout; the 100ms
|
|
29
|
+
floor exists specifically to keep that failure mode from being too easy to trigger.
|
|
30
|
+
Elasticsearch applies its timeout per request rather than once for the whole connection.
|
|
31
|
+
The `timeout` field itself always takes a literal number — unlike other connection
|
|
32
|
+
fields, it does not accept an `{"$env": "..."}` reference.
|
|
33
|
+
|
|
34
|
+
### Redirecting output
|
|
35
|
+
|
|
36
|
+
Results go to stdout; diagnostics (auto-limit notices, warnings, update hints) go to
|
|
37
|
+
stderr. That split is what keeps `--format json` machine-parseable, so do not collapse
|
|
38
|
+
it with `2>&1` — the diagnostic lines land in front of the JSON document and the parse
|
|
39
|
+
fails. Pipe stdout alone, or add `2>/dev/null` when the diagnostics are not wanted:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
dbcli query '{}' --collection events --format json 2>/dev/null | jq '.rows | length'
|
|
43
|
+
```
|
|
22
44
|
|
|
23
45
|
## Commands
|
|
24
46
|
|
|
@@ -118,6 +140,10 @@ agent mode disabled. A host that needs protection from a same-user hostile
|
|
|
118
140
|
process can set `DBCLI_CONFIG_INTEGRITY_ANCHOR_DIR` to a protected or read-only
|
|
119
141
|
directory; trusted writes publish detached digests there.
|
|
120
142
|
|
|
143
|
+
When a connection's config fails schema validation, dbcli reports the specific field
|
|
144
|
+
path(s) that are wrong for that connection's declared `system` — not the raw Zod union
|
|
145
|
+
error tree — so a broken `.dbcli` can be fixed without guessing which branch applies.
|
|
146
|
+
|
|
121
147
|
### list
|
|
122
148
|
|
|
123
149
|
List all tables (SQL), collections (MongoDB), keys (Redis), or indices (Elasticsearch).
|
|
@@ -2605,6 +2631,8 @@ MongoDB connections use a JSON-based query model instead of SQL. Treat MongoDB s
|
|
|
2605
2631
|
|
|
2606
2632
|
`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 unchanged non-interactive path via `--uri`. 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>`.
|
|
2607
2633
|
|
|
2634
|
+
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`.
|
|
2635
|
+
|
|
2608
2636
|
**Supported commands:** `init`, `use`, `list`, `schema`, `query`, `q`, `insert`, `update`, `delete`, `export`, `status`, `shell`, `doctor`, `upgrade`, `completion`
|
|
2609
2637
|
|
|
2610
2638
|
**Limited support:**
|
|
@@ -2669,7 +2697,7 @@ Redis connections speak Redis commands rather than SQL. The adapter uses Bun's n
|
|
|
2669
2697
|
|
|
2670
2698
|
- Required fields: `system: redis`, `host`, `port`. `password` and `database` are optional.
|
|
2671
2699
|
- `database` is the **logical DB index** (`"0"` … `"15"`), kept as a string to play nicely with env-ref bindings. `list` and the connection metadata both label it as the active DB.
|
|
2672
|
-
- `connection.timeout` (ms, default 5000) maps to the client's `connectionTimeout
|
|
2700
|
+
- `connection.timeout` (ms, default 5000) maps to the client's `connectionTimeout`; root-level `--timeout <ms>` overrides it for a single invocation.
|
|
2673
2701
|
|
|
2674
2702
|
### Permission classification
|
|
2675
2703
|
|
|
@@ -2799,7 +2827,7 @@ Elasticsearch connections speak the REST API. The adapter is fetch-based (no SDK
|
|
|
2799
2827
|
- Either `host` + `port` (default `https://localhost:9200`) or `nodes: [...]` (first node is used) or `cloudId`.
|
|
2800
2828
|
- Auth precedence: `apiKey` → `user`/`password` (HTTP Basic). Leave both unset for an open cluster.
|
|
2801
2829
|
- `protocol` defaults to `https`. For TLS quirks: `caPath` (path to a PEM bundle) and `rejectUnauthorized: false` (last resort).
|
|
2802
|
-
- `connection.timeout` (ms, default 5000) is wired to `AbortController` on every request.
|
|
2830
|
+
- `connection.timeout` (ms, default 5000) is wired to `AbortController` on every request; root-level `--timeout <ms>` overrides it for a single invocation.
|
|
2803
2831
|
|
|
2804
2832
|
### Permission classification
|
|
2805
2833
|
|