@carllee1983/dbcli 1.38.1 → 1.39.2
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 +32 -6
- package/.cursor/skills/dbcli/reference.md +33 -5
- package/.cursor-plugin/plugin.json +1 -1
- package/.github/skills/dbcli/SKILL.md +32 -6
- package/.github/skills/dbcli/reference.md +33 -5
- package/CHANGELOG.md +40 -0
- package/assets/SKILL.md +32 -6
- package/assets/SKILL.zh-TW.md +28 -4
- package/assets/reference.md +33 -5
- package/assets/ui-template.html +8 -8
- package/dist/cli.mjs +682 -11334
- package/dist/core.mjs +21 -7
- package/dist/ui-style.css +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 +32 -6
- package/plugins/dbcli-agent/skills/dbcli/reference.md +33 -5
- package/skills/dbcli/SKILL.md +32 -6
- package/skills/dbcli/reference.md +33 -5
package/.cursor/rules/dbcli.mdc
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dbcli
|
|
3
|
-
description: Database CLI for AI agents with permission-based access control. Use to set up new connections, query, inspect schemas, insert/update/delete, export results, and blacklist sensitive columns/tables. Supports MySQL, PostgreSQL, MariaDB, MongoDB, Redis, and Elasticsearch with multiple named connections per project and custom env files. Trigger when configuring a database connection (`.dbcli` / `.env`), choosing between v1 single and v2 multi-connection layouts, picking auth modes (URI, env refs, Cloud ID, API key), running SQL / MongoDB JSON / Redis commands / Elasticsearch DSL, exploring table/collection/key/index structures, switching database environments, protecting sensitive data from AI access, or performing automated recovery and guided remediation after command failures. For exhaustive flags and examples, read the sibling `reference.md`.
|
|
3
|
+
description: Database CLI for AI agents with permission-based access control. Use to set up new connections, query, inspect schemas, insert/update/delete, export results, generate DB reports or interactive HTML dashboards, and blacklist sensitive columns/tables. Supports MySQL, PostgreSQL, MariaDB, MongoDB, Redis, and Elasticsearch with multiple named connections per project and custom env files. Trigger when configuring a database connection (`.dbcli` / `.env`), choosing between v1 single and v2 multi-connection layouts, picking auth modes (URI, env refs, Cloud ID, API key), running SQL / MongoDB JSON / Redis commands / Elasticsearch DSL, generating a report/dashboard/HTML UI from raw SQL or saved snippets, exploring table/collection/key/index structures, switching database environments, protecting sensitive data from AI access, or performing automated recovery and guided remediation after command failures. For exhaustive flags and examples, read the sibling `reference.md`.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# dbcli
|
|
@@ -18,7 +18,16 @@ the CLI package has not been installed globally.
|
|
|
18
18
|
|
|
19
19
|
1. `dbcli blacklist list` — confirm sensitive-data boundaries.
|
|
20
20
|
2. `dbcli schema <object> --format json` — confirm real column/field names. **Never guess.**
|
|
21
|
-
3. All writes: `--dry-run` (SQL/Mongo) → run → `query` read-back to confirm.
|
|
21
|
+
3. All writes: `--dry-run` (SQL/Mongo) → run → `query` read-back to confirm. Redis
|
|
22
|
+
`query` has **no `--dry-run`** (see **Redis**); Elasticsearch is **read-only**.
|
|
23
|
+
|
|
24
|
+
**`update` / `delete` `--where` is equality-only (SQL).** It accepts **only** `col=val` or
|
|
25
|
+
`col1=v1 AND col2=v2`. A comparison / pattern operator (`>`, `>=`, `<`, `!=`, `LIKE`, `IN`)
|
|
26
|
+
is a **parse error**; worse, `OR` is **silently swallowed into the value** — `a=1 OR b=2`
|
|
27
|
+
parses as `a = "1 OR b=2"` and matches the wrong rows (or none). For a range or compound
|
|
28
|
+
condition, first `query` / `export` the target rows' primary keys, then run one
|
|
29
|
+
`update` / `delete --where "id=<pk>"` per key — or escalate to a human. (MongoDB `--where`
|
|
30
|
+
takes a full JSON filter and is exempt.)
|
|
22
31
|
|
|
23
32
|
> `report` and `guide` already embed an `inspect` snapshot — you do **not** need to run
|
|
24
33
|
> `dbcli inspect` first. Run `dbcli inspect --for-agent` manually only when you want the
|
|
@@ -30,6 +39,7 @@ the CLI package has not been installed globally.
|
|
|
30
39
|
| --- | --- |
|
|
31
40
|
| A named workflow fits ("diagnose slow query", "audit permissions") | `skill tasks list` → `skill tasks plan <pack>` — **prefer this; do not invent steps** |
|
|
32
41
|
| A fixed diagnostic goal | `guide <goal>` (`slow-query` / `capacity` / `health` / `index-usage` / `permissions` / `schema-overview`; `guide --list`) |
|
|
42
|
+
| A DB report / dashboard / HTML UI | `blacklist list` → `queries search <keywords>` or `queries suggest <intent>` → `queries show @<name>` → browser: `q @<name> --param k=v --ui`; file: `q @<name> --format html > report.html` or `export "<SQL>" --format html --output report.html` |
|
|
33
43
|
| Setting up a connection | see **Connection setup** |
|
|
34
44
|
| Anything else | run commands manually; consult the **Developer workflows** cheat-sheet |
|
|
35
45
|
|
|
@@ -89,6 +99,7 @@ in **How to use dbcli** still applies.
|
|
|
89
99
|
| Situation | Minimum safe path |
|
|
90
100
|
| --- | --- |
|
|
91
101
|
| DB-backed feature | `blacklist list` → `schema <object>` → `queries suggest <intent>` |
|
|
102
|
+
| DB report / dashboard request | `blacklist list` → `queries search <keywords>` / `queries suggest <intent>` → `queries show @<name>` → `q @<name> --ui` or `--format html` |
|
|
92
103
|
| Application data bug | `audit tail --for-agent --n 10` → `blacklist list` → `schema <object>` → narrow query |
|
|
93
104
|
| ORM or migration work | `schema --format json` → `diff --snapshot <name>` → `migrate add-index`/`add-column` (preview SQL) → `diff --against <snapshot>` |
|
|
94
105
|
| PR database review | Review changed persistence paths, then propose concrete `schema` / `plan` / `dry-run` / `report` / `guide` commands per material claim. |
|
|
@@ -103,6 +114,11 @@ dbcli inspect --for-agent --format json
|
|
|
103
114
|
dbcli blacklist list --format json
|
|
104
115
|
dbcli schema <object> --format json
|
|
105
116
|
dbcli queries suggest <intent> --format json
|
|
117
|
+
dbcli queries search <report keywords> --format json
|
|
118
|
+
dbcli queries show @<name> --format json
|
|
119
|
+
dbcli q @<name> --param k=v --ui
|
|
120
|
+
dbcli q @<name> --param k=v --format html > report.html
|
|
121
|
+
dbcli export "<SQL>" --format html --output report.html
|
|
106
122
|
dbcli audit tail --for-agent --n 10
|
|
107
123
|
dbcli diff --snapshot <name>
|
|
108
124
|
dbcli report --section perf --format json
|
|
@@ -357,12 +373,18 @@ without changing the default. `--recovery` is honoured by `query`, `q`, `insert`
|
|
|
357
373
|
→ `data-admin`. A command not in the whitelist is refused.
|
|
358
374
|
- **No `--dry-run` for Redis `query`** — write safety comes from the permission gate and key
|
|
359
375
|
blacklist (matching reads/writes are rejected). To preview a delete, use `delete <key> --dry-run`.
|
|
360
|
-
- `database` is the logical DB index (default `0`). `dbcli blacklist add 'secrets:*'`
|
|
376
|
+
- `database` is the logical DB index (default `0`). `dbcli blacklist table add 'secrets:*'`
|
|
361
377
|
registers a key glob; an optional `redis.mask` block masks values on read. Size guards
|
|
362
378
|
(SCAN/HGETALL truncation, `--no-limit` to bypass) and masking details: reference.md Redis section.
|
|
363
379
|
|
|
364
380
|
## Elasticsearch
|
|
365
381
|
|
|
382
|
+
**dbcli is read-only against Elasticsearch — `insert` / `update` / `delete` are not supported.**
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
dbcli query '{"query":{"match":{"status":"active"}}}' --collection orders
|
|
386
|
+
```
|
|
387
|
+
|
|
366
388
|
- `query` takes a DSL (JSON body) or Lucene query string; `--collection <index>` is required.
|
|
367
389
|
- **Supported:** `init`, `list` (indices with doc count), `schema [index]` (flattened mapping),
|
|
368
390
|
`query`, `export` (v1.22), `shell` (v1.22), `status`, `use`, `doctor`. **Not supported:**
|
|
@@ -425,14 +447,18 @@ Run with `dbcli q @diag/<topic>` (engine variant auto-picked by the active conne
|
|
|
425
447
|
|
|
426
448
|
```bash
|
|
427
449
|
dbcli query "SELECT day, dau FROM dau_daily" --ui # open in browser
|
|
450
|
+
dbcli q @analytics/revenue --param days=30 --ui # snippet metadata + charts/KPIs
|
|
451
|
+
dbcli q @analytics/revenue --param days=30 --format html > report.html
|
|
428
452
|
dbcli query "SELECT * FROM orders" --format html > out.html # pipe HTML to stdout
|
|
429
453
|
dbcli export "SELECT * FROM orders" --format html --output orders.html
|
|
430
454
|
```
|
|
431
455
|
|
|
432
456
|
`--ui` implies `--format html` and opens the file; `--format html` alone prints to stdout.
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
457
|
+
When a saved snippet exists, prefer `q @<name> --ui` / `q @<name> --format html` because snippet
|
|
458
|
+
metadata can drive titles, KPI cards, and charts. Blacklist redaction is applied **before**
|
|
459
|
+
rendering. To get KPIs and charts instead of a plain table, add a `visual:` block (`title`,
|
|
460
|
+
`kpis[]`, `charts[]`) to the snippet frontmatter — see reference.md for the full `visual:`
|
|
461
|
+
schema. Raw `query` / `export` invocations render a sortable table only.
|
|
436
462
|
|
|
437
463
|
## Common workflows
|
|
438
464
|
|
|
@@ -249,6 +249,7 @@ dbcli q @analytics/revenue --param days=30 --format html > report.html
|
|
|
249
249
|
- `--dry-run` — print the bound SQL + values without executing
|
|
250
250
|
- `--use <name>` — pick a v2 named connection
|
|
251
251
|
- `--recovery` — emit a `RecoveryEnvelope` on failure (see `recover`)
|
|
252
|
+
- `--verify` — run the snippet's verification assertions after execution (only if the snippet defines them)
|
|
252
253
|
|
|
253
254
|
**Permission:** query-only+
|
|
254
255
|
|
|
@@ -474,9 +475,10 @@ Insert data into a table.
|
|
|
474
475
|
dbcli insert users --data '{"name":"Alice","email":"alice@example.com"}'
|
|
475
476
|
dbcli insert users --data '{"name":"Alice"}' --dry-run
|
|
476
477
|
dbcli insert users --data '{"name":"Alice"}' --force
|
|
478
|
+
dbcli insert users --data '{"name":"Alice"}' --plan --format json # risk analysis only; no DB connection
|
|
477
479
|
```
|
|
478
480
|
|
|
479
|
-
**Options:** `--data <json>`, `--dry-run`, `--force`
|
|
481
|
+
**Options:** `--data <json>`, `--dry-run`, `--force`, `--plan` (analyze risk without connecting or executing), `--format <text|json>` (`--plan` output), `--recovery`
|
|
480
482
|
**Permission:** read-write+
|
|
481
483
|
|
|
482
484
|
### update
|
|
@@ -486,11 +488,19 @@ Update existing data.
|
|
|
486
488
|
```bash
|
|
487
489
|
dbcli update users --where "id=1" --set '{"name":"Bob"}'
|
|
488
490
|
dbcli update users --where "id=1" --set '{"name":"Bob"}' --dry-run
|
|
491
|
+
dbcli update users --where "id=1" --set '{"name":"Bob"}' --plan --format json # risk analysis only; no DB connection
|
|
489
492
|
```
|
|
490
493
|
|
|
491
|
-
**Options:** `--where <condition>` (required), `--set <json>` (required), `--dry-run`, `--force`
|
|
494
|
+
**Options:** `--where <condition>` (required), `--set <json>` (required), `--dry-run`, `--force`, `--plan` (analyze risk without connecting or executing), `--format <text|json>` (`--plan` output), `--recovery`
|
|
492
495
|
**Permission:** read-write+
|
|
493
496
|
|
|
497
|
+
> **`--where` grammar (SQL `update` / `delete`)** — equality only: `col=val` or
|
|
498
|
+
> `col1=v1 AND col2=v2`. Comparison / pattern operators (`>`, `>=`, `<`, `!=`, `LIKE`, `IN`)
|
|
499
|
+
> raise a parse error, and `OR` is **silently folded into the value** (`a=1 OR b=2` parses as
|
|
500
|
+
> `a = "1 OR b=2"`, matching nothing intended). For ranges or compound predicates, select the
|
|
501
|
+
> target primary keys first, then issue one `update` / `delete --where "id=<pk>"` per key.
|
|
502
|
+
> (MongoDB `--where` accepts a full JSON filter and is exempt.)
|
|
503
|
+
|
|
494
504
|
### delete
|
|
495
505
|
|
|
496
506
|
Delete data from a table.
|
|
@@ -499,9 +509,10 @@ Delete data from a table.
|
|
|
499
509
|
dbcli delete users --where "id=1"
|
|
500
510
|
dbcli delete users --where "id=1" --dry-run
|
|
501
511
|
dbcli delete users --where "id=1" --force
|
|
512
|
+
dbcli delete users --where "id=1" --plan --format json # risk analysis only; no DB connection
|
|
502
513
|
```
|
|
503
514
|
|
|
504
|
-
**Options:** `--where <condition>` (required), `--dry-run`, `--force`
|
|
515
|
+
**Options:** `--where <condition>` (required), `--dry-run`, `--force`, `--plan` (analyze risk without connecting or executing), `--format <text|json>` (`--plan` output), `--recovery`
|
|
505
516
|
**Permission:** data-admin+
|
|
506
517
|
|
|
507
518
|
### export
|
|
@@ -521,7 +532,7 @@ dbcli export orders --format csv --output orders.csv # index name as query
|
|
|
521
532
|
dbcli export orders --no-limit --format jsonl # scroll the whole index in batches
|
|
522
533
|
```
|
|
523
534
|
|
|
524
|
-
**Options:** `--format <json|jsonl|csv|html>` (required), `--output <path>`, `--force`, `--recovery`, `--index <name>` (Elasticsearch), `--no-limit` (Elasticsearch full-index scroll)
|
|
535
|
+
**Options:** `--format <json|jsonl|csv|html>` (required), `--output <path>`, `--force`, `--recovery`, `--collection <name>` (MongoDB collection) / `--index <name>` (Elasticsearch index; alias for `--collection`), `--limit <number>` (overrides auto-limit), `--no-limit` (Elasticsearch full-index scroll)
|
|
525
536
|
**Permission:** query-only+ — SQL, MongoDB, and **(v1.22)** Elasticsearch.
|
|
526
537
|
|
|
527
538
|
The `html` format emits the same self-contained dashboard as `query --ui` (see [Interactive HTML dashboard](#interactive-html-dashboard)). Because `export` runs raw SQL (no snippet metadata), the HTML report is always rendered as a sortable / filterable table — no KPIs or charts. Use `dbcli q @<name> --format html` (or `--ui`) for the charted view.
|
|
@@ -892,6 +903,7 @@ Boundaries:
|
|
|
892
903
|
| `--from <path>` | Read the envelope from this file instead of `.dbcli/last-recovery.json`. Accepts raw `RecoveryEnvelope` or `SavedRecoveryEnvelope`. | — |
|
|
893
904
|
| `--allow-write <tier>` | Open the risk gate. Values: `readonly-cmd` (local-side writes) \| `write-cmd` (database writes). | `none` |
|
|
894
905
|
| `--no-verify` | Skip the verify step appended after a successful `--apply`. | off (verify runs by default) |
|
|
906
|
+
| `--write-verification-artifact` | After a successful `--apply`, persist a secret-free `VerificationArtifact` JSON under `.dbcli/verification/`. | off |
|
|
895
907
|
| `--format <format>` | `markdown` \| `json`. | `markdown` for inspect, `json` for `--apply` |
|
|
896
908
|
|
|
897
909
|
#### Plan source resolution
|
|
@@ -1650,6 +1662,7 @@ dbcli skill --install codex # install to ~/.codex/skills/dbcli/
|
|
|
1650
1662
|
**Options:**
|
|
1651
1663
|
- `--install <platform>` — `claude` | `gemini` | `antigravity` | `copilot` | `cursor` | `codex` | `windsurf`. Writes `SKILL.md` plus `reference.md` next to it so the agent gets progressive disclosure.
|
|
1652
1664
|
- `--output <path>` — write `SKILL.md` to a file instead of stdout. Does not install `reference.md`.
|
|
1665
|
+
- `--lang <en|zh-TW>` — source language for the emitted SKILL content (default `en`). It selects `assets/SKILL.md` vs `assets/SKILL.zh-TW.md`; the install/output filename stays `SKILL.md` regardless.
|
|
1653
1666
|
|
|
1654
1667
|
**Notes:**
|
|
1655
1668
|
- Both files come straight from `assets/SKILL.md` + `assets/reference.md` inside the dbcli package — no runtime rendering. Keep these in sync when shipping a release.
|
|
@@ -1662,6 +1675,21 @@ dbcli skill --install codex # install to ~/.codex/skills/dbcli/
|
|
|
1662
1675
|
|
|
1663
1676
|
**Permission:** n/a.
|
|
1664
1677
|
|
|
1678
|
+
### skill context
|
|
1679
|
+
|
|
1680
|
+
Emit an AI-friendly snapshot of the connected database's schema and saved-query snippets (blacklist-filtered) so an agent can be primed with the current context.
|
|
1681
|
+
|
|
1682
|
+
```bash
|
|
1683
|
+
dbcli skill context # XML (default)
|
|
1684
|
+
dbcli skill context --format json
|
|
1685
|
+
dbcli skill context --format markdown
|
|
1686
|
+
```
|
|
1687
|
+
|
|
1688
|
+
**Options:**
|
|
1689
|
+
- `--format <xml|json|markdown>` — output format (default: `xml`)
|
|
1690
|
+
|
|
1691
|
+
**Permission:** query-only+ — read-only; blacklisted objects are never emitted.
|
|
1692
|
+
|
|
1665
1693
|
### skill tasks (Agent Task Packs)
|
|
1666
1694
|
|
|
1667
1695
|
```bash
|
|
@@ -2201,7 +2229,7 @@ Rewrites emit a `REDIS_SIZE_REWRITE` warning; truncations emit `REDIS_SIZE_TRUNC
|
|
|
2201
2229
|
Blacklist rules are enforced as **Redis-native key globs** (`*`, `?`, `[abc]`, `[a-z]`):
|
|
2202
2230
|
|
|
2203
2231
|
```bash
|
|
2204
|
-
dbcli blacklist add 'secrets:*'
|
|
2232
|
+
dbcli blacklist table add 'secrets:*' # register a key-glob rule
|
|
2205
2233
|
dbcli query "GET secrets:api_key" # → BlacklistRejection (exit non-zero)
|
|
2206
2234
|
dbcli query "MGET safe:k secrets:api" # → rejected (any matching key fails the whole command)
|
|
2207
2235
|
dbcli query "KEYS secrets:*" # → rejected (pattern overlaps a rule)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dbcli
|
|
3
|
-
description: Database CLI for AI agents with permission-based access control. Use to set up new connections, query, inspect schemas, insert/update/delete, export results, and blacklist sensitive columns/tables. Supports MySQL, PostgreSQL, MariaDB, MongoDB, Redis, and Elasticsearch with multiple named connections per project and custom env files. Trigger when configuring a database connection (`.dbcli` / `.env`), choosing between v1 single and v2 multi-connection layouts, picking auth modes (URI, env refs, Cloud ID, API key), running SQL / MongoDB JSON / Redis commands / Elasticsearch DSL, exploring table/collection/key/index structures, switching database environments, protecting sensitive data from AI access, or performing automated recovery and guided remediation after command failures. For exhaustive flags and examples, read the sibling `reference.md`.
|
|
3
|
+
description: Database CLI for AI agents with permission-based access control. Use to set up new connections, query, inspect schemas, insert/update/delete, export results, generate DB reports or interactive HTML dashboards, and blacklist sensitive columns/tables. Supports MySQL, PostgreSQL, MariaDB, MongoDB, Redis, and Elasticsearch with multiple named connections per project and custom env files. Trigger when configuring a database connection (`.dbcli` / `.env`), choosing between v1 single and v2 multi-connection layouts, picking auth modes (URI, env refs, Cloud ID, API key), running SQL / MongoDB JSON / Redis commands / Elasticsearch DSL, generating a report/dashboard/HTML UI from raw SQL or saved snippets, exploring table/collection/key/index structures, switching database environments, protecting sensitive data from AI access, or performing automated recovery and guided remediation after command failures. For exhaustive flags and examples, read the sibling `reference.md`.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# dbcli
|
|
@@ -18,7 +18,16 @@ the CLI package has not been installed globally.
|
|
|
18
18
|
|
|
19
19
|
1. `dbcli blacklist list` — confirm sensitive-data boundaries.
|
|
20
20
|
2. `dbcli schema <object> --format json` — confirm real column/field names. **Never guess.**
|
|
21
|
-
3. All writes: `--dry-run` (SQL/Mongo) → run → `query` read-back to confirm.
|
|
21
|
+
3. All writes: `--dry-run` (SQL/Mongo) → run → `query` read-back to confirm. Redis
|
|
22
|
+
`query` has **no `--dry-run`** (see **Redis**); Elasticsearch is **read-only**.
|
|
23
|
+
|
|
24
|
+
**`update` / `delete` `--where` is equality-only (SQL).** It accepts **only** `col=val` or
|
|
25
|
+
`col1=v1 AND col2=v2`. A comparison / pattern operator (`>`, `>=`, `<`, `!=`, `LIKE`, `IN`)
|
|
26
|
+
is a **parse error**; worse, `OR` is **silently swallowed into the value** — `a=1 OR b=2`
|
|
27
|
+
parses as `a = "1 OR b=2"` and matches the wrong rows (or none). For a range or compound
|
|
28
|
+
condition, first `query` / `export` the target rows' primary keys, then run one
|
|
29
|
+
`update` / `delete --where "id=<pk>"` per key — or escalate to a human. (MongoDB `--where`
|
|
30
|
+
takes a full JSON filter and is exempt.)
|
|
22
31
|
|
|
23
32
|
> `report` and `guide` already embed an `inspect` snapshot — you do **not** need to run
|
|
24
33
|
> `dbcli inspect` first. Run `dbcli inspect --for-agent` manually only when you want the
|
|
@@ -30,6 +39,7 @@ the CLI package has not been installed globally.
|
|
|
30
39
|
| --- | --- |
|
|
31
40
|
| A named workflow fits ("diagnose slow query", "audit permissions") | `skill tasks list` → `skill tasks plan <pack>` — **prefer this; do not invent steps** |
|
|
32
41
|
| A fixed diagnostic goal | `guide <goal>` (`slow-query` / `capacity` / `health` / `index-usage` / `permissions` / `schema-overview`; `guide --list`) |
|
|
42
|
+
| A DB report / dashboard / HTML UI | `blacklist list` → `queries search <keywords>` or `queries suggest <intent>` → `queries show @<name>` → browser: `q @<name> --param k=v --ui`; file: `q @<name> --format html > report.html` or `export "<SQL>" --format html --output report.html` |
|
|
33
43
|
| Setting up a connection | see **Connection setup** |
|
|
34
44
|
| Anything else | run commands manually; consult the **Developer workflows** cheat-sheet |
|
|
35
45
|
|
|
@@ -89,6 +99,7 @@ in **How to use dbcli** still applies.
|
|
|
89
99
|
| Situation | Minimum safe path |
|
|
90
100
|
| --- | --- |
|
|
91
101
|
| DB-backed feature | `blacklist list` → `schema <object>` → `queries suggest <intent>` |
|
|
102
|
+
| DB report / dashboard request | `blacklist list` → `queries search <keywords>` / `queries suggest <intent>` → `queries show @<name>` → `q @<name> --ui` or `--format html` |
|
|
92
103
|
| Application data bug | `audit tail --for-agent --n 10` → `blacklist list` → `schema <object>` → narrow query |
|
|
93
104
|
| ORM or migration work | `schema --format json` → `diff --snapshot <name>` → `migrate add-index`/`add-column` (preview SQL) → `diff --against <snapshot>` |
|
|
94
105
|
| PR database review | Review changed persistence paths, then propose concrete `schema` / `plan` / `dry-run` / `report` / `guide` commands per material claim. |
|
|
@@ -103,6 +114,11 @@ dbcli inspect --for-agent --format json
|
|
|
103
114
|
dbcli blacklist list --format json
|
|
104
115
|
dbcli schema <object> --format json
|
|
105
116
|
dbcli queries suggest <intent> --format json
|
|
117
|
+
dbcli queries search <report keywords> --format json
|
|
118
|
+
dbcli queries show @<name> --format json
|
|
119
|
+
dbcli q @<name> --param k=v --ui
|
|
120
|
+
dbcli q @<name> --param k=v --format html > report.html
|
|
121
|
+
dbcli export "<SQL>" --format html --output report.html
|
|
106
122
|
dbcli audit tail --for-agent --n 10
|
|
107
123
|
dbcli diff --snapshot <name>
|
|
108
124
|
dbcli report --section perf --format json
|
|
@@ -357,12 +373,18 @@ without changing the default. `--recovery` is honoured by `query`, `q`, `insert`
|
|
|
357
373
|
→ `data-admin`. A command not in the whitelist is refused.
|
|
358
374
|
- **No `--dry-run` for Redis `query`** — write safety comes from the permission gate and key
|
|
359
375
|
blacklist (matching reads/writes are rejected). To preview a delete, use `delete <key> --dry-run`.
|
|
360
|
-
- `database` is the logical DB index (default `0`). `dbcli blacklist add 'secrets:*'`
|
|
376
|
+
- `database` is the logical DB index (default `0`). `dbcli blacklist table add 'secrets:*'`
|
|
361
377
|
registers a key glob; an optional `redis.mask` block masks values on read. Size guards
|
|
362
378
|
(SCAN/HGETALL truncation, `--no-limit` to bypass) and masking details: reference.md Redis section.
|
|
363
379
|
|
|
364
380
|
## Elasticsearch
|
|
365
381
|
|
|
382
|
+
**dbcli is read-only against Elasticsearch — `insert` / `update` / `delete` are not supported.**
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
dbcli query '{"query":{"match":{"status":"active"}}}' --collection orders
|
|
386
|
+
```
|
|
387
|
+
|
|
366
388
|
- `query` takes a DSL (JSON body) or Lucene query string; `--collection <index>` is required.
|
|
367
389
|
- **Supported:** `init`, `list` (indices with doc count), `schema [index]` (flattened mapping),
|
|
368
390
|
`query`, `export` (v1.22), `shell` (v1.22), `status`, `use`, `doctor`. **Not supported:**
|
|
@@ -425,14 +447,18 @@ Run with `dbcli q @diag/<topic>` (engine variant auto-picked by the active conne
|
|
|
425
447
|
|
|
426
448
|
```bash
|
|
427
449
|
dbcli query "SELECT day, dau FROM dau_daily" --ui # open in browser
|
|
450
|
+
dbcli q @analytics/revenue --param days=30 --ui # snippet metadata + charts/KPIs
|
|
451
|
+
dbcli q @analytics/revenue --param days=30 --format html > report.html
|
|
428
452
|
dbcli query "SELECT * FROM orders" --format html > out.html # pipe HTML to stdout
|
|
429
453
|
dbcli export "SELECT * FROM orders" --format html --output orders.html
|
|
430
454
|
```
|
|
431
455
|
|
|
432
456
|
`--ui` implies `--format html` and opens the file; `--format html` alone prints to stdout.
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
457
|
+
When a saved snippet exists, prefer `q @<name> --ui` / `q @<name> --format html` because snippet
|
|
458
|
+
metadata can drive titles, KPI cards, and charts. Blacklist redaction is applied **before**
|
|
459
|
+
rendering. To get KPIs and charts instead of a plain table, add a `visual:` block (`title`,
|
|
460
|
+
`kpis[]`, `charts[]`) to the snippet frontmatter — see reference.md for the full `visual:`
|
|
461
|
+
schema. Raw `query` / `export` invocations render a sortable table only.
|
|
436
462
|
|
|
437
463
|
## Common workflows
|
|
438
464
|
|
|
@@ -249,6 +249,7 @@ dbcli q @analytics/revenue --param days=30 --format html > report.html
|
|
|
249
249
|
- `--dry-run` — print the bound SQL + values without executing
|
|
250
250
|
- `--use <name>` — pick a v2 named connection
|
|
251
251
|
- `--recovery` — emit a `RecoveryEnvelope` on failure (see `recover`)
|
|
252
|
+
- `--verify` — run the snippet's verification assertions after execution (only if the snippet defines them)
|
|
252
253
|
|
|
253
254
|
**Permission:** query-only+
|
|
254
255
|
|
|
@@ -474,9 +475,10 @@ Insert data into a table.
|
|
|
474
475
|
dbcli insert users --data '{"name":"Alice","email":"alice@example.com"}'
|
|
475
476
|
dbcli insert users --data '{"name":"Alice"}' --dry-run
|
|
476
477
|
dbcli insert users --data '{"name":"Alice"}' --force
|
|
478
|
+
dbcli insert users --data '{"name":"Alice"}' --plan --format json # risk analysis only; no DB connection
|
|
477
479
|
```
|
|
478
480
|
|
|
479
|
-
**Options:** `--data <json>`, `--dry-run`, `--force`
|
|
481
|
+
**Options:** `--data <json>`, `--dry-run`, `--force`, `--plan` (analyze risk without connecting or executing), `--format <text|json>` (`--plan` output), `--recovery`
|
|
480
482
|
**Permission:** read-write+
|
|
481
483
|
|
|
482
484
|
### update
|
|
@@ -486,11 +488,19 @@ Update existing data.
|
|
|
486
488
|
```bash
|
|
487
489
|
dbcli update users --where "id=1" --set '{"name":"Bob"}'
|
|
488
490
|
dbcli update users --where "id=1" --set '{"name":"Bob"}' --dry-run
|
|
491
|
+
dbcli update users --where "id=1" --set '{"name":"Bob"}' --plan --format json # risk analysis only; no DB connection
|
|
489
492
|
```
|
|
490
493
|
|
|
491
|
-
**Options:** `--where <condition>` (required), `--set <json>` (required), `--dry-run`, `--force`
|
|
494
|
+
**Options:** `--where <condition>` (required), `--set <json>` (required), `--dry-run`, `--force`, `--plan` (analyze risk without connecting or executing), `--format <text|json>` (`--plan` output), `--recovery`
|
|
492
495
|
**Permission:** read-write+
|
|
493
496
|
|
|
497
|
+
> **`--where` grammar (SQL `update` / `delete`)** — equality only: `col=val` or
|
|
498
|
+
> `col1=v1 AND col2=v2`. Comparison / pattern operators (`>`, `>=`, `<`, `!=`, `LIKE`, `IN`)
|
|
499
|
+
> raise a parse error, and `OR` is **silently folded into the value** (`a=1 OR b=2` parses as
|
|
500
|
+
> `a = "1 OR b=2"`, matching nothing intended). For ranges or compound predicates, select the
|
|
501
|
+
> target primary keys first, then issue one `update` / `delete --where "id=<pk>"` per key.
|
|
502
|
+
> (MongoDB `--where` accepts a full JSON filter and is exempt.)
|
|
503
|
+
|
|
494
504
|
### delete
|
|
495
505
|
|
|
496
506
|
Delete data from a table.
|
|
@@ -499,9 +509,10 @@ Delete data from a table.
|
|
|
499
509
|
dbcli delete users --where "id=1"
|
|
500
510
|
dbcli delete users --where "id=1" --dry-run
|
|
501
511
|
dbcli delete users --where "id=1" --force
|
|
512
|
+
dbcli delete users --where "id=1" --plan --format json # risk analysis only; no DB connection
|
|
502
513
|
```
|
|
503
514
|
|
|
504
|
-
**Options:** `--where <condition>` (required), `--dry-run`, `--force`
|
|
515
|
+
**Options:** `--where <condition>` (required), `--dry-run`, `--force`, `--plan` (analyze risk without connecting or executing), `--format <text|json>` (`--plan` output), `--recovery`
|
|
505
516
|
**Permission:** data-admin+
|
|
506
517
|
|
|
507
518
|
### export
|
|
@@ -521,7 +532,7 @@ dbcli export orders --format csv --output orders.csv # index name as query
|
|
|
521
532
|
dbcli export orders --no-limit --format jsonl # scroll the whole index in batches
|
|
522
533
|
```
|
|
523
534
|
|
|
524
|
-
**Options:** `--format <json|jsonl|csv|html>` (required), `--output <path>`, `--force`, `--recovery`, `--index <name>` (Elasticsearch), `--no-limit` (Elasticsearch full-index scroll)
|
|
535
|
+
**Options:** `--format <json|jsonl|csv|html>` (required), `--output <path>`, `--force`, `--recovery`, `--collection <name>` (MongoDB collection) / `--index <name>` (Elasticsearch index; alias for `--collection`), `--limit <number>` (overrides auto-limit), `--no-limit` (Elasticsearch full-index scroll)
|
|
525
536
|
**Permission:** query-only+ — SQL, MongoDB, and **(v1.22)** Elasticsearch.
|
|
526
537
|
|
|
527
538
|
The `html` format emits the same self-contained dashboard as `query --ui` (see [Interactive HTML dashboard](#interactive-html-dashboard)). Because `export` runs raw SQL (no snippet metadata), the HTML report is always rendered as a sortable / filterable table — no KPIs or charts. Use `dbcli q @<name> --format html` (or `--ui`) for the charted view.
|
|
@@ -892,6 +903,7 @@ Boundaries:
|
|
|
892
903
|
| `--from <path>` | Read the envelope from this file instead of `.dbcli/last-recovery.json`. Accepts raw `RecoveryEnvelope` or `SavedRecoveryEnvelope`. | — |
|
|
893
904
|
| `--allow-write <tier>` | Open the risk gate. Values: `readonly-cmd` (local-side writes) \| `write-cmd` (database writes). | `none` |
|
|
894
905
|
| `--no-verify` | Skip the verify step appended after a successful `--apply`. | off (verify runs by default) |
|
|
906
|
+
| `--write-verification-artifact` | After a successful `--apply`, persist a secret-free `VerificationArtifact` JSON under `.dbcli/verification/`. | off |
|
|
895
907
|
| `--format <format>` | `markdown` \| `json`. | `markdown` for inspect, `json` for `--apply` |
|
|
896
908
|
|
|
897
909
|
#### Plan source resolution
|
|
@@ -1650,6 +1662,7 @@ dbcli skill --install codex # install to ~/.codex/skills/dbcli/
|
|
|
1650
1662
|
**Options:**
|
|
1651
1663
|
- `--install <platform>` — `claude` | `gemini` | `antigravity` | `copilot` | `cursor` | `codex` | `windsurf`. Writes `SKILL.md` plus `reference.md` next to it so the agent gets progressive disclosure.
|
|
1652
1664
|
- `--output <path>` — write `SKILL.md` to a file instead of stdout. Does not install `reference.md`.
|
|
1665
|
+
- `--lang <en|zh-TW>` — source language for the emitted SKILL content (default `en`). It selects `assets/SKILL.md` vs `assets/SKILL.zh-TW.md`; the install/output filename stays `SKILL.md` regardless.
|
|
1653
1666
|
|
|
1654
1667
|
**Notes:**
|
|
1655
1668
|
- Both files come straight from `assets/SKILL.md` + `assets/reference.md` inside the dbcli package — no runtime rendering. Keep these in sync when shipping a release.
|
|
@@ -1662,6 +1675,21 @@ dbcli skill --install codex # install to ~/.codex/skills/dbcli/
|
|
|
1662
1675
|
|
|
1663
1676
|
**Permission:** n/a.
|
|
1664
1677
|
|
|
1678
|
+
### skill context
|
|
1679
|
+
|
|
1680
|
+
Emit an AI-friendly snapshot of the connected database's schema and saved-query snippets (blacklist-filtered) so an agent can be primed with the current context.
|
|
1681
|
+
|
|
1682
|
+
```bash
|
|
1683
|
+
dbcli skill context # XML (default)
|
|
1684
|
+
dbcli skill context --format json
|
|
1685
|
+
dbcli skill context --format markdown
|
|
1686
|
+
```
|
|
1687
|
+
|
|
1688
|
+
**Options:**
|
|
1689
|
+
- `--format <xml|json|markdown>` — output format (default: `xml`)
|
|
1690
|
+
|
|
1691
|
+
**Permission:** query-only+ — read-only; blacklisted objects are never emitted.
|
|
1692
|
+
|
|
1665
1693
|
### skill tasks (Agent Task Packs)
|
|
1666
1694
|
|
|
1667
1695
|
```bash
|
|
@@ -2201,7 +2229,7 @@ Rewrites emit a `REDIS_SIZE_REWRITE` warning; truncations emit `REDIS_SIZE_TRUNC
|
|
|
2201
2229
|
Blacklist rules are enforced as **Redis-native key globs** (`*`, `?`, `[abc]`, `[a-z]`):
|
|
2202
2230
|
|
|
2203
2231
|
```bash
|
|
2204
|
-
dbcli blacklist add 'secrets:*'
|
|
2232
|
+
dbcli blacklist table add 'secrets:*' # register a key-glob rule
|
|
2205
2233
|
dbcli query "GET secrets:api_key" # → BlacklistRejection (exit non-zero)
|
|
2206
2234
|
dbcli query "MGET safe:k secrets:api" # → rejected (any matching key fails the whole command)
|
|
2207
2235
|
dbcli query "KEYS secrets:*" # → rejected (pattern overlaps a rule)
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,46 @@ 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.39.2] - 2026-07-03 - Windows 跨平台、skill 安裝安全與 plugin 版本對齊
|
|
9
|
+
|
|
10
|
+
> npm `1.39.1` 已於 2026-06-30 發布;本批修復在其後累積於同一版號下(npm 版本不可覆蓋),故獨立為 1.39.2 以便日後發布。
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- **Windows 跨平台修復(Windows CI 首次全綠)。** filesystem 操作與 path 檢查改為跨平台實作、修正 `emit` 子行程 import 與殘留的 path assertion,並以 portable `node:fs` 取代僅限 unix 的 coreutils spawns。此前 Windows job 從未通過(fail-fast 總是先取消它)。
|
|
15
|
+
- **Skill 安裝安全強化。** 修正 output / install 旗標衝突、強化安裝安全檢查與 task 過濾條件。
|
|
16
|
+
- **zh-TW skill 安裝不再被誤判為永遠過期。**
|
|
17
|
+
- **Skill 參考修正。** 移除文件中不存在的 `blacklist add`、補回缺漏的 reference flags。
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- **文件補齊。** 明示 `--where` 僅支援等值比較、補上 Redis / Elasticsearch 寫入模型說明、記錄 home-storage 綁定並重新同步 md/html parity、對齊 config-location-policy 與實作綁定模型。
|
|
22
|
+
- **Plugin manifest 版本對齊。** `.claude-plugin` / `.cursor-plugin` / `.codex-plugin` 及 `plugins/dbcli-agent` 的 `plugin.json` 版本更新為 1.39.2(先前漂移在 1.37.1 / 1.31.0,未跟上主版本;`plugin:sync` / `plugin:check` 只同步 skill 內容不同步版本)。
|
|
23
|
+
|
|
24
|
+
### Internal
|
|
25
|
+
|
|
26
|
+
- CI 加入 doc / skill drift guards 並修正 release-gate 說明;新增 `reference.md` 指令覆蓋契約測試;移除失效的 `validate-skill.sh`(testing doc 改指向 `bun test`);稽核冗餘測試改用 collision-proof token sentinel;zsh 不存在時跳過 rc-eval 測試;每檔還原 leaked spies 以修正順序相依的 CI 失敗;prettier 對齊 `q` / audit `logger` 測試。
|
|
27
|
+
|
|
28
|
+
## [1.39.1] - 2026-06-30 - Skill report dashboard routing
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- **Dashboard 請求不再落入通用 query 路由。** 先前 dashboard / report 意圖的請求會 fall through 到一般 query 路徑;現已正確導向 dashboard 專用流程。
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- **Skill 路由補上 DB report / dashboard / HTML UI 意圖。** `assets/SKILL.md` / `assets/SKILL.zh-TW.md` 的 metadata、任務路由表、開發者速查與 HTML dashboard 範例現在明確導向 `queries search|suggest` → `queries show` → `q @<name> --ui` / `--format html`,並保留 raw SQL `export --format html` 的檔案輸出路徑。已透過 `plugin:sync` 同步到所有受管理平台副本。純文件 / skill 變更。
|
|
37
|
+
|
|
38
|
+
## [1.39.0] - 2026-06-24 - Dashboard chart type 解析時邊界驗證
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- **`--ui` dashboard chart type 改為解析時驗證。** Saved query 的 `visual.charts[].type` 現以單一合法集合 `line` / `bar` / `area` / `pie` 驗證;指定未支援的類型(含打錯字)會在解析時拋出 `SavedQueryError`(`PARSE_ERROR`),訊息列出合法清單。先前的行為是把任何未知類型**靜默畫成圓餅圖**。型別宣告中從未被渲染的 `scatter` 一併移除。
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
|
|
46
|
+
- **未知 chart type 不再靜默偽裝成圓餅圖。** dashboard 渲染端對非可渲染類型顯示明確的「Unsupported chart type」佔位,而非 fallthrough 成 `PieChart`。
|
|
47
|
+
|
|
8
48
|
## [1.38.1] - 2026-06-23 - Redis delete 能力對齊 & SKILL.md 任務路由重構
|
|
9
49
|
|
|
10
50
|
### Fixed
|
package/assets/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dbcli
|
|
3
|
-
description: Database CLI for AI agents with permission-based access control. Use to set up new connections, query, inspect schemas, insert/update/delete, export results, and blacklist sensitive columns/tables. Supports MySQL, PostgreSQL, MariaDB, MongoDB, Redis, and Elasticsearch with multiple named connections per project and custom env files. Trigger when configuring a database connection (`.dbcli` / `.env`), choosing between v1 single and v2 multi-connection layouts, picking auth modes (URI, env refs, Cloud ID, API key), running SQL / MongoDB JSON / Redis commands / Elasticsearch DSL, exploring table/collection/key/index structures, switching database environments, protecting sensitive data from AI access, or performing automated recovery and guided remediation after command failures. For exhaustive flags and examples, read the sibling `reference.md`.
|
|
3
|
+
description: Database CLI for AI agents with permission-based access control. Use to set up new connections, query, inspect schemas, insert/update/delete, export results, generate DB reports or interactive HTML dashboards, and blacklist sensitive columns/tables. Supports MySQL, PostgreSQL, MariaDB, MongoDB, Redis, and Elasticsearch with multiple named connections per project and custom env files. Trigger when configuring a database connection (`.dbcli` / `.env`), choosing between v1 single and v2 multi-connection layouts, picking auth modes (URI, env refs, Cloud ID, API key), running SQL / MongoDB JSON / Redis commands / Elasticsearch DSL, generating a report/dashboard/HTML UI from raw SQL or saved snippets, exploring table/collection/key/index structures, switching database environments, protecting sensitive data from AI access, or performing automated recovery and guided remediation after command failures. For exhaustive flags and examples, read the sibling `reference.md`.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# dbcli
|
|
@@ -18,7 +18,16 @@ the CLI package has not been installed globally.
|
|
|
18
18
|
|
|
19
19
|
1. `dbcli blacklist list` — confirm sensitive-data boundaries.
|
|
20
20
|
2. `dbcli schema <object> --format json` — confirm real column/field names. **Never guess.**
|
|
21
|
-
3. All writes: `--dry-run` (SQL/Mongo) → run → `query` read-back to confirm.
|
|
21
|
+
3. All writes: `--dry-run` (SQL/Mongo) → run → `query` read-back to confirm. Redis
|
|
22
|
+
`query` has **no `--dry-run`** (see **Redis**); Elasticsearch is **read-only**.
|
|
23
|
+
|
|
24
|
+
**`update` / `delete` `--where` is equality-only (SQL).** It accepts **only** `col=val` or
|
|
25
|
+
`col1=v1 AND col2=v2`. A comparison / pattern operator (`>`, `>=`, `<`, `!=`, `LIKE`, `IN`)
|
|
26
|
+
is a **parse error**; worse, `OR` is **silently swallowed into the value** — `a=1 OR b=2`
|
|
27
|
+
parses as `a = "1 OR b=2"` and matches the wrong rows (or none). For a range or compound
|
|
28
|
+
condition, first `query` / `export` the target rows' primary keys, then run one
|
|
29
|
+
`update` / `delete --where "id=<pk>"` per key — or escalate to a human. (MongoDB `--where`
|
|
30
|
+
takes a full JSON filter and is exempt.)
|
|
22
31
|
|
|
23
32
|
> `report` and `guide` already embed an `inspect` snapshot — you do **not** need to run
|
|
24
33
|
> `dbcli inspect` first. Run `dbcli inspect --for-agent` manually only when you want the
|
|
@@ -30,6 +39,7 @@ the CLI package has not been installed globally.
|
|
|
30
39
|
| --- | --- |
|
|
31
40
|
| A named workflow fits ("diagnose slow query", "audit permissions") | `skill tasks list` → `skill tasks plan <pack>` — **prefer this; do not invent steps** |
|
|
32
41
|
| A fixed diagnostic goal | `guide <goal>` (`slow-query` / `capacity` / `health` / `index-usage` / `permissions` / `schema-overview`; `guide --list`) |
|
|
42
|
+
| A DB report / dashboard / HTML UI | `blacklist list` → `queries search <keywords>` or `queries suggest <intent>` → `queries show @<name>` → browser: `q @<name> --param k=v --ui`; file: `q @<name> --format html > report.html` or `export "<SQL>" --format html --output report.html` |
|
|
33
43
|
| Setting up a connection | see **Connection setup** |
|
|
34
44
|
| Anything else | run commands manually; consult the **Developer workflows** cheat-sheet |
|
|
35
45
|
|
|
@@ -89,6 +99,7 @@ in **How to use dbcli** still applies.
|
|
|
89
99
|
| Situation | Minimum safe path |
|
|
90
100
|
| --- | --- |
|
|
91
101
|
| DB-backed feature | `blacklist list` → `schema <object>` → `queries suggest <intent>` |
|
|
102
|
+
| DB report / dashboard request | `blacklist list` → `queries search <keywords>` / `queries suggest <intent>` → `queries show @<name>` → `q @<name> --ui` or `--format html` |
|
|
92
103
|
| Application data bug | `audit tail --for-agent --n 10` → `blacklist list` → `schema <object>` → narrow query |
|
|
93
104
|
| ORM or migration work | `schema --format json` → `diff --snapshot <name>` → `migrate add-index`/`add-column` (preview SQL) → `diff --against <snapshot>` |
|
|
94
105
|
| PR database review | Review changed persistence paths, then propose concrete `schema` / `plan` / `dry-run` / `report` / `guide` commands per material claim. |
|
|
@@ -103,6 +114,11 @@ dbcli inspect --for-agent --format json
|
|
|
103
114
|
dbcli blacklist list --format json
|
|
104
115
|
dbcli schema <object> --format json
|
|
105
116
|
dbcli queries suggest <intent> --format json
|
|
117
|
+
dbcli queries search <report keywords> --format json
|
|
118
|
+
dbcli queries show @<name> --format json
|
|
119
|
+
dbcli q @<name> --param k=v --ui
|
|
120
|
+
dbcli q @<name> --param k=v --format html > report.html
|
|
121
|
+
dbcli export "<SQL>" --format html --output report.html
|
|
106
122
|
dbcli audit tail --for-agent --n 10
|
|
107
123
|
dbcli diff --snapshot <name>
|
|
108
124
|
dbcli report --section perf --format json
|
|
@@ -357,12 +373,18 @@ without changing the default. `--recovery` is honoured by `query`, `q`, `insert`
|
|
|
357
373
|
→ `data-admin`. A command not in the whitelist is refused.
|
|
358
374
|
- **No `--dry-run` for Redis `query`** — write safety comes from the permission gate and key
|
|
359
375
|
blacklist (matching reads/writes are rejected). To preview a delete, use `delete <key> --dry-run`.
|
|
360
|
-
- `database` is the logical DB index (default `0`). `dbcli blacklist add 'secrets:*'`
|
|
376
|
+
- `database` is the logical DB index (default `0`). `dbcli blacklist table add 'secrets:*'`
|
|
361
377
|
registers a key glob; an optional `redis.mask` block masks values on read. Size guards
|
|
362
378
|
(SCAN/HGETALL truncation, `--no-limit` to bypass) and masking details: reference.md Redis section.
|
|
363
379
|
|
|
364
380
|
## Elasticsearch
|
|
365
381
|
|
|
382
|
+
**dbcli is read-only against Elasticsearch — `insert` / `update` / `delete` are not supported.**
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
dbcli query '{"query":{"match":{"status":"active"}}}' --collection orders
|
|
386
|
+
```
|
|
387
|
+
|
|
366
388
|
- `query` takes a DSL (JSON body) or Lucene query string; `--collection <index>` is required.
|
|
367
389
|
- **Supported:** `init`, `list` (indices with doc count), `schema [index]` (flattened mapping),
|
|
368
390
|
`query`, `export` (v1.22), `shell` (v1.22), `status`, `use`, `doctor`. **Not supported:**
|
|
@@ -425,14 +447,18 @@ Run with `dbcli q @diag/<topic>` (engine variant auto-picked by the active conne
|
|
|
425
447
|
|
|
426
448
|
```bash
|
|
427
449
|
dbcli query "SELECT day, dau FROM dau_daily" --ui # open in browser
|
|
450
|
+
dbcli q @analytics/revenue --param days=30 --ui # snippet metadata + charts/KPIs
|
|
451
|
+
dbcli q @analytics/revenue --param days=30 --format html > report.html
|
|
428
452
|
dbcli query "SELECT * FROM orders" --format html > out.html # pipe HTML to stdout
|
|
429
453
|
dbcli export "SELECT * FROM orders" --format html --output orders.html
|
|
430
454
|
```
|
|
431
455
|
|
|
432
456
|
`--ui` implies `--format html` and opens the file; `--format html` alone prints to stdout.
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
457
|
+
When a saved snippet exists, prefer `q @<name> --ui` / `q @<name> --format html` because snippet
|
|
458
|
+
metadata can drive titles, KPI cards, and charts. Blacklist redaction is applied **before**
|
|
459
|
+
rendering. To get KPIs and charts instead of a plain table, add a `visual:` block (`title`,
|
|
460
|
+
`kpis[]`, `charts[]`) to the snippet frontmatter — see reference.md for the full `visual:`
|
|
461
|
+
schema. Raw `query` / `export` invocations render a sortable table only.
|
|
436
462
|
|
|
437
463
|
## Common workflows
|
|
438
464
|
|