@carllee1983/dbcli 1.51.1 → 1.52.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 +26 -2
- package/.cursor/skills/dbcli/reference.md +170 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/.github/skills/dbcli/SKILL.md +26 -2
- package/.github/skills/dbcli/reference.md +170 -1
- package/CHANGELOG.md +23 -0
- package/README.md +1 -0
- package/README.zh-TW.md +1 -0
- package/assets/SKILL.md +26 -2
- package/assets/SKILL.zh-TW.md +17 -0
- package/assets/reference.md +170 -1
- package/assets/tasks/design-review.md +42 -0
- package/dist/cli.mjs +12173 -715
- package/dist/core.d.ts +8 -0
- package/gemini-extension.json +1 -1
- package/package.json +4 -1
- package/plugins/dbcli-agent/.codex-plugin/plugin.json +1 -1
- package/plugins/dbcli-agent/skills/dbcli/SKILL.md +26 -2
- package/plugins/dbcli-agent/skills/dbcli/reference.md +170 -1
- package/skills/dbcli/SKILL.md +26 -2
- package/skills/dbcli/reference.md +170 -1
package/.cursor/rules/dbcli.mdc
CHANGED
|
@@ -82,6 +82,30 @@ warnings) go to stderr so stdout stays parseable — when piping JSON into a par
|
|
|
82
82
|
use `2>/dev/null` or leave stderr alone. **Never `2>&1`**: it merges those lines back
|
|
83
83
|
into stdout and the parse fails.
|
|
84
84
|
|
|
85
|
+
**Intent confirmation:** Treat `auto`, `confirm`, and `guided` as conversational
|
|
86
|
+
preferences for the current request, not as dbcli flags or persistent configuration.
|
|
87
|
+
Do not ask the user a meta-question about whether they want questions.
|
|
88
|
+
|
|
89
|
+
- `auto` (default): autonomously use governed semantic context and schema discovery.
|
|
90
|
+
If unresolved ambiguity would materially change the result, ask one compact batch of
|
|
91
|
+
questions before querying; otherwise state the assumptions and proceed.
|
|
92
|
+
- `confirm`: first state the proposed interpretation and wait for the user's approval
|
|
93
|
+
before issuing the task's data query.
|
|
94
|
+
- `guided`: resolve the request through short, focused questions, carrying confirmed
|
|
95
|
+
answers forward rather than asking again.
|
|
96
|
+
|
|
97
|
+
For business requests, material ambiguity includes the requested result shape or grain,
|
|
98
|
+
metric definition, time boundary and timezone, inclusion/exclusion rules (such as order
|
|
99
|
+
status or refunds), grouping, or selected connection. Example: for “yesterday's sales,”
|
|
100
|
+
do not guess whether the user needs a total or detail, which timezone defines yesterday,
|
|
101
|
+
or whether cancelled and refunded orders count. Summarize the candidate interpretation
|
|
102
|
+
and ask only the unresolved, result-changing questions.
|
|
103
|
+
|
|
104
|
+
When the user explicitly says to decide without further questions, proceed in `auto`
|
|
105
|
+
mode and disclose the material assumptions. This never bypasses blacklist, schema,
|
|
106
|
+
permission, dry-run, production-selection, or write-confirmation gates; an agent must
|
|
107
|
+
still stop where those gates require human confirmation.
|
|
108
|
+
|
|
85
109
|
**Business-language discovery:** When a user uses a business alias, metric, recurring
|
|
86
110
|
term, or relationship/join intent instead of a physical table or field name, first run
|
|
87
111
|
`dbcli skill context --format json`. If it includes `semantic`, treat that reviewed
|
|
@@ -357,11 +381,11 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
|
|
|
357
381
|
| `use` | n/a | Show/switch default named connection (v2 only). |
|
|
358
382
|
| `list` | query-only+ | Tables (SQL), collections (MongoDB), keys (Redis), or indices (Elasticsearch). |
|
|
359
383
|
| `schema` | query-only+ | SQL: per-table or full scan into `.dbcli/schemas/`. MongoDB: sampled. ES: flattened mapping. Redis: per-key only (type/TTL/size). Supports `--recovery`. |
|
|
360
|
-
| `query` | query-only+ | SQL, Mongo JSON (`--collection`), Redis command, or ES DSL/Lucene (`--collection`). `--format table\|json\|csv\|html`, `--ui` to open the interactive dashboard in a browser. `--fields` (projection), `--truncate` (cell width), `-f/--query-file` (read query from file or stdin), `--use a,b` (read-only fan-out). Supports `--recovery`. See **Query workflow flags**. |
|
|
384
|
+
| `query` | query-only+ | SQL, Mongo JSON (`--collection`), Redis command, or ES DSL/Lucene (`--collection`). `--format table\|json\|csv\|html`, `--ui` to open the interactive dashboard in a browser. `--fields` (projection), `--truncate` (cell width), `-f/--query-file` (read query from file or stdin), `--use a,b` (read-only fan-out). Supports `--recovery`. `--slow-ms <n>` sets the passive slow-query hint threshold (default 1000, `0` off): at or above it, table output gains a `Performance hint` footer and JSON gains `metadata.performanceAdvisory`; it runs no extra diagnostics and is suppressed under `--recovery`. Distinct from the `proxy` flag of the same name. See **Query workflow flags**. |
|
|
361
385
|
| `explain` | query-only+ | **(v1.23)** Read-only query plan with annotations. SQL only. Single query, `@saved-query`, `@file.sql`, or `--bulk @glob/*`. `--analyze` (EXPLAIN ANALYZE / MariaDB ANALYZE SELECT), `--format markdown\|json\|table`. |
|
|
362
386
|
| `lint` | n/a | Static SQL anti-pattern advisor (no DB connection). 9 rules incl. schema-aware implicit-cast / NOT IN-nullable checks via the layered `.dbcli/schemas/` cache; global `--use <conn>` selects a named cache. Findings carry rewrite drafts + guarded `explain` verify commands (`--analyze` only for proven read-only SQL) — report-only, never executes. `--format text\|json\|markdown`, `--min-severity`, `--no-schema`, `--bulk`. Supports `--recovery`. |
|
|
363
387
|
| `plan` | n/a | Static SQL risk analyzer (`--format text\|json`); classifies a statement without connecting to the database. |
|
|
364
|
-
| `q` | query-only+ | Run a saved snippet by `@name` with `--param k=v`. Supports `--verify` to run assertions. |
|
|
388
|
+
| `q` | query-only+ | Run a saved snippet by `@name` with `--param k=v`. Supports `--verify` to run assertions and `--slow-ms <n>` (same passive slow-query hint as `query`). |
|
|
365
389
|
| `queries` | n/a | Manage saved snippets: `list` / `show` / `search` / `suggest` / `new` / `edit` / `check` / `delete` / `rename` / `copy` / `import` / `export`. |
|
|
366
390
|
| `insert` / `update` | read-write+ | SQL or MongoDB only. JSON `--data` / `--set`; `--where` required on `update`; `--dry-run` first. Redis writes go through `query`. Supports `--recovery`. |
|
|
367
391
|
| `delete` | data-admin+ | SQL or MongoDB; Redis has a basic implementation (see Redis section). `--where` required; `--dry-run` first. Supports `--recovery`. |
|
|
@@ -220,9 +220,44 @@ dbcli query "SELECT day, dau FROM dau_daily" --ui # open in brows
|
|
|
220
220
|
dbcli query "SELECT * FROM orders" --format html > orders.html # pipe to stdout
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
-
**Options:** `--format <table|json|csv|html>`, `--ui` (open the dashboard in the system browser; implies `--format html`), `--limit <number>`, `--no-limit`, `--collection <name>` (MongoDB / Elasticsearch), `--index <name>` (Elasticsearch alias for `--collection`), `--fields <list>`, `--truncate <number>` / `--no-truncate`, `-f, --query-file <path>`, `--use <name[,name]>`, `--recovery`
|
|
223
|
+
**Options:** `--format <table|json|csv|html>`, `--ui` (open the dashboard in the system browser; implies `--format html`), `--limit <number>`, `--no-limit`, `--collection <name>` (MongoDB / Elasticsearch), `--index <name>` (Elasticsearch alias for `--collection`), `--fields <list>`, `--truncate <number>` / `--no-truncate`, `-f, --query-file <path>`, `--use <name[,name]>`, `--slow-ms <number>`, `--recovery`
|
|
224
224
|
**Permission:** query-only+ (Redis: per-command; Elasticsearch: per HTTP method/path)
|
|
225
225
|
|
|
226
|
+
#### Passive slow-query hint (`--slow-ms`)
|
|
227
|
+
|
|
228
|
+
`query` and `q` read the execution time they already measured for a finished
|
|
229
|
+
query and, at or above the threshold, add a hint. Default `1000`; `--slow-ms 0`
|
|
230
|
+
disables it for that invocation. This is **not** the `proxy` / `proxy analyze`
|
|
231
|
+
flag of the same name — that one flags events in the proxy log; this one only
|
|
232
|
+
annotates a single command's own result.
|
|
233
|
+
|
|
234
|
+
The hint performs no extra work: it never runs `EXPLAIN`, reads a schema, or
|
|
235
|
+
issues a second request. It is suppressed entirely under `--recovery`, so the
|
|
236
|
+
recovery envelope keeps its exact machine contract.
|
|
237
|
+
|
|
238
|
+
- `--format table` appends `Performance hint: <recommendation>` to the footer.
|
|
239
|
+
- `--format json` adds `metadata.performanceAdvisory`:
|
|
240
|
+
|
|
241
|
+
```json
|
|
242
|
+
{
|
|
243
|
+
"metadata": {
|
|
244
|
+
"statement": "SELECT",
|
|
245
|
+
"performanceAdvisory": {
|
|
246
|
+
"code": "SLOW_QUERY",
|
|
247
|
+
"executionTimeMs": 1250,
|
|
248
|
+
"thresholdMs": 1000,
|
|
249
|
+
"recommendation": "Review safely with: dbcli guide slow-query --format markdown. This hint runs no additional database diagnostics."
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
The recommendation is engine-aware: PostgreSQL, MySQL, MariaDB, and Redis are
|
|
256
|
+
pointed at `dbcli guide slow-query`, because that goal resolves to real
|
|
257
|
+
diagnostic snippets for them. MongoDB and Elasticsearch ship no snippet for its
|
|
258
|
+
intents, so their hint states the timing and says so instead of naming a command
|
|
259
|
+
that would come back empty. `csv` and `html` output are unchanged.
|
|
260
|
+
|
|
226
261
|
Below `admin`, SQL holding more than one statement is rejected, because only the
|
|
227
262
|
first statement would decide the permission check while a driver on the simple
|
|
228
263
|
query protocol executes them all. Semicolons inside string literals, backtick
|
|
@@ -529,6 +564,7 @@ dbcli q @analytics/revenue --param days=30 --format html > report.html
|
|
|
529
564
|
- `--no-limit` — skip the `SELECT * FROM (…) AS _dbcli_guard LIMIT 1000` wrap
|
|
530
565
|
- `--dry-run` — print the bound SQL + values without executing
|
|
531
566
|
- `--use <name>` — pick a v2 named connection
|
|
567
|
+
- `--slow-ms <number>` — passive slow-query hint threshold (default `1000`; `0` disables). Same contract as `query` — see "Passive slow-query hint" there
|
|
532
568
|
- `--recovery` — emit a `RecoveryEnvelope` on failure (see `recover`)
|
|
533
569
|
- `--verify` — run the snippet's verification assertions after execution (only if the snippet defines them)
|
|
534
570
|
|
|
@@ -1077,6 +1113,139 @@ Both parameters are required. Keep each expansion as one quoted shell argument;
|
|
|
1077
1113
|
never use `eval`, and consider `--execute` only after the plan and captured DDL
|
|
1078
1114
|
have been reviewed.
|
|
1079
1115
|
|
|
1116
|
+
### design
|
|
1117
|
+
|
|
1118
|
+
Author, validate, render, and review a version-controlled SQL database design
|
|
1119
|
+
kept beside the code as `dbcli.design.json`. Every subcommand is offline: none
|
|
1120
|
+
opens a database connection, executes DDL, or calls an LLM. `design init` is the
|
|
1121
|
+
only writer, and it writes only to the explicit `--output` path.
|
|
1122
|
+
|
|
1123
|
+
```text
|
|
1124
|
+
dbcli design init --output <path> [--dialect <dialect>]
|
|
1125
|
+
dbcli design validate [--file <path>] [--format <format>]
|
|
1126
|
+
dbcli design render [--file <path>] [--format <format>]
|
|
1127
|
+
dbcli design diff (--against-cache | --against-orm <paths>) [options]
|
|
1128
|
+
dbcli design propose (--against-cache | --against-orm <paths>) [options]
|
|
1129
|
+
```
|
|
1130
|
+
|
|
1131
|
+
```bash
|
|
1132
|
+
# Writes only to this explicit, missing path; edit the starter before validating.
|
|
1133
|
+
dbcli design init --output ./dbcli.design.json --dialect postgresql
|
|
1134
|
+
|
|
1135
|
+
dbcli design validate --format json
|
|
1136
|
+
dbcli design render --format mermaid
|
|
1137
|
+
dbcli design diff --against-cache --format markdown
|
|
1138
|
+
dbcli design diff --against-orm ./prisma/schema.prisma --format markdown
|
|
1139
|
+
dbcli design propose --against-orm ./prisma/schema.prisma --format markdown
|
|
1140
|
+
```
|
|
1141
|
+
|
|
1142
|
+
| Option | Applies to | Default | Meaning |
|
|
1143
|
+
|---|---|---|---|
|
|
1144
|
+
| `--output <path>` | `init` | required | Destination for the new artifact; refuses to overwrite an existing file. |
|
|
1145
|
+
| `--dialect <postgresql\|mysql\|mariadb>` | `init` | `postgresql` | Target SQL dialect recorded in the artifact. |
|
|
1146
|
+
| `--file <path>` | all but `init` | `dbcli.design.json` | Design artifact to read. |
|
|
1147
|
+
| `--format <format>` | all but `init` | see below | `validate`/`propose`: `json`, `markdown`. `render`: `json`, `markdown`, `mermaid` (default `markdown`). `diff`: `json` (default), `table`, `markdown`. |
|
|
1148
|
+
| `--against-cache` | `diff`, `propose` | off | Compare with the local schema cache; requires a configured PostgreSQL/MySQL/MariaDB connection whose system matches the artifact dialect, and a non-empty cache (run `dbcli schema` first). |
|
|
1149
|
+
| `--against-orm <paths>` | `diff`, `propose` | none | Compare with local ORM definition(s); repeatable or comma-separated, DDL paths support globs. Needs no config and no connection. |
|
|
1150
|
+
| `--orm-format <format>` | `diff`, `propose` | auto-detect | Force `prisma`, `ddl`, `json`, `drizzle`, `typeorm`, or `sequelize`. |
|
|
1151
|
+
| `--ignore <globs>` | `diff`, `propose` | none | Comma-separated table globs excluded from drift. |
|
|
1152
|
+
|
|
1153
|
+
`diff` and `propose` require **exactly one** comparison target; passing both or
|
|
1154
|
+
neither is an error.
|
|
1155
|
+
|
|
1156
|
+
#### Artifact shape
|
|
1157
|
+
|
|
1158
|
+
```json
|
|
1159
|
+
{
|
|
1160
|
+
"version": 1,
|
|
1161
|
+
"dialect": "postgresql",
|
|
1162
|
+
"models": [
|
|
1163
|
+
{
|
|
1164
|
+
"name": "orders",
|
|
1165
|
+
"table": "orders",
|
|
1166
|
+
"description": "Completed purchases.",
|
|
1167
|
+
"fields": [
|
|
1168
|
+
{ "name": "id", "type": "bigint", "nullable": false, "primaryKey": true, "unique": true },
|
|
1169
|
+
{ "name": "customer_id", "type": "bigint", "nullable": false, "primaryKey": false, "unique": false }
|
|
1170
|
+
],
|
|
1171
|
+
"indexes": [{ "name": "orders_customer_idx", "columns": ["customer_id"], "unique": false }]
|
|
1172
|
+
}
|
|
1173
|
+
],
|
|
1174
|
+
"relationships": [
|
|
1175
|
+
{
|
|
1176
|
+
"name": "orders_customer",
|
|
1177
|
+
"from": { "model": "orders", "field": "customer_id" },
|
|
1178
|
+
"to": { "model": "customers", "field": "id" },
|
|
1179
|
+
"cardinality": "many-to-one"
|
|
1180
|
+
}
|
|
1181
|
+
],
|
|
1182
|
+
"accessPatterns": [{ "model": "orders", "filters": ["customer_id"], "sort": ["created_at"] }],
|
|
1183
|
+
"decisions": [{ "name": "single-currency", "rationale": "Amounts are stored in minor units, USD only." }]
|
|
1184
|
+
}
|
|
1185
|
+
```
|
|
1186
|
+
|
|
1187
|
+
It holds no SQL, credentials, rows, or provider configuration. `design init`
|
|
1188
|
+
emits this envelope with empty `models`, `relationships`, `accessPatterns`, and
|
|
1189
|
+
`decisions`.
|
|
1190
|
+
|
|
1191
|
+
#### Review findings
|
|
1192
|
+
|
|
1193
|
+
`validate` is fail-closed: any `error` finding exits `1`, and `render`, `diff`,
|
|
1194
|
+
and `propose` refuse to do their work while errors remain.
|
|
1195
|
+
|
|
1196
|
+
| Severity | Codes |
|
|
1197
|
+
|---|---|
|
|
1198
|
+
| `error` | `NO_MODELS`, `DUPLICATE_MODEL`, `DUPLICATE_TABLE`, `DUPLICATE_FIELD`, `PRIMARY_KEY_COUNT`, `NULLABLE_PRIMARY_KEY`, `UNKNOWN_INDEX_FIELD`, `DUPLICATE_RELATIONSHIP`, `REVERSE_RELATIONSHIP`, `UNKNOWN_RELATIONSHIP_MODEL`, `UNKNOWN_RELATIONSHIP_FIELD`, `RELATIONSHIP_TYPE_MISMATCH`, `MANY_TO_MANY_REQUIRES_BRIDGE`, `ONE_TO_ONE_REQUIRES_UNIQUE_FK`, `UNKNOWN_ACCESS_MODEL`, `UNKNOWN_ACCESS_FIELD` |
|
|
1199
|
+
| `warn` | `DUPLICATE_INDEX`, `REDUNDANT_PRIMARY_KEY_INDEX`, `PREFIX_REDUNDANT_INDEX`, `ACCESS_PATTERN_INDEX` |
|
|
1200
|
+
|
|
1201
|
+
`REVERSE_RELATIONSHIP` fires when the same endpoints are declared again in the
|
|
1202
|
+
opposite direction; `PREFIX_REDUNDANT_INDEX` fires when a non-unique index is a
|
|
1203
|
+
leading-column prefix of a longer index. `v1` requires exactly one primary-key
|
|
1204
|
+
field per model and an explicit bridge model for `many-to-many`.
|
|
1205
|
+
|
|
1206
|
+
#### `design propose` (review-only)
|
|
1207
|
+
|
|
1208
|
+
`propose` turns drift into a plan a human reviews; it never applies a write. Each
|
|
1209
|
+
entry carries a `safety` of `dry-run` (an existing `migrate` command can represent
|
|
1210
|
+
the change losslessly) or `migration-review` (everything else), plus `preflight`,
|
|
1211
|
+
`rollback`, and `verification` steps:
|
|
1212
|
+
|
|
1213
|
+
```json
|
|
1214
|
+
{
|
|
1215
|
+
"table": "orders",
|
|
1216
|
+
"object": "total_cents",
|
|
1217
|
+
"safety": "migration-review",
|
|
1218
|
+
"commands": ["..."],
|
|
1219
|
+
"preflight": [
|
|
1220
|
+
"dbcli blacklist list",
|
|
1221
|
+
"Confirm the exact affected table with: dbcli schema <exact-table> --format json"
|
|
1222
|
+
],
|
|
1223
|
+
"rollback": "Capture the current schema and generated DDL before any approved write; define the inverse migration before execution.",
|
|
1224
|
+
"verification": [
|
|
1225
|
+
"After an approved write, run: dbcli schema <exact-table> --format json",
|
|
1226
|
+
"Re-run this same design diff command and review the remaining drift."
|
|
1227
|
+
]
|
|
1228
|
+
}
|
|
1229
|
+
```
|
|
1230
|
+
|
|
1231
|
+
**Workflows:**
|
|
1232
|
+
|
|
1233
|
+
- **New project** — `design init` → edit the artifact → `design validate` →
|
|
1234
|
+
`design render`. If application models already exist, use the offline
|
|
1235
|
+
`design diff --against-orm <path>` to reconcile the artifact and the ORM before
|
|
1236
|
+
any database exists.
|
|
1237
|
+
- **Existing database** — `blacklist list` → refresh the cache with
|
|
1238
|
+
`schema --format json` → `design diff --against-cache` →
|
|
1239
|
+
`design propose --against-cache`. Review the plan, perform any approved
|
|
1240
|
+
migration separately, then refresh the schema and rerun the same diff.
|
|
1241
|
+
|
|
1242
|
+
**Exit codes:** `0` when no errors, `1` when the artifact has review errors, an
|
|
1243
|
+
invalid target selection, an unreadable file, or reported drift errors.
|
|
1244
|
+
|
|
1245
|
+
An external coding agent may draft the artifact, but a human should review it
|
|
1246
|
+
before it is relied upon. Do not create or rewrite `dbcli.design.json` without an
|
|
1247
|
+
explicit human request.
|
|
1248
|
+
|
|
1080
1249
|
### snapshot
|
|
1081
1250
|
|
|
1082
1251
|
Capture a **result fingerprint** of a query (not schema): `rowCount` plus per-column
|
|
@@ -82,6 +82,30 @@ warnings) go to stderr so stdout stays parseable — when piping JSON into a par
|
|
|
82
82
|
use `2>/dev/null` or leave stderr alone. **Never `2>&1`**: it merges those lines back
|
|
83
83
|
into stdout and the parse fails.
|
|
84
84
|
|
|
85
|
+
**Intent confirmation:** Treat `auto`, `confirm`, and `guided` as conversational
|
|
86
|
+
preferences for the current request, not as dbcli flags or persistent configuration.
|
|
87
|
+
Do not ask the user a meta-question about whether they want questions.
|
|
88
|
+
|
|
89
|
+
- `auto` (default): autonomously use governed semantic context and schema discovery.
|
|
90
|
+
If unresolved ambiguity would materially change the result, ask one compact batch of
|
|
91
|
+
questions before querying; otherwise state the assumptions and proceed.
|
|
92
|
+
- `confirm`: first state the proposed interpretation and wait for the user's approval
|
|
93
|
+
before issuing the task's data query.
|
|
94
|
+
- `guided`: resolve the request through short, focused questions, carrying confirmed
|
|
95
|
+
answers forward rather than asking again.
|
|
96
|
+
|
|
97
|
+
For business requests, material ambiguity includes the requested result shape or grain,
|
|
98
|
+
metric definition, time boundary and timezone, inclusion/exclusion rules (such as order
|
|
99
|
+
status or refunds), grouping, or selected connection. Example: for “yesterday's sales,”
|
|
100
|
+
do not guess whether the user needs a total or detail, which timezone defines yesterday,
|
|
101
|
+
or whether cancelled and refunded orders count. Summarize the candidate interpretation
|
|
102
|
+
and ask only the unresolved, result-changing questions.
|
|
103
|
+
|
|
104
|
+
When the user explicitly says to decide without further questions, proceed in `auto`
|
|
105
|
+
mode and disclose the material assumptions. This never bypasses blacklist, schema,
|
|
106
|
+
permission, dry-run, production-selection, or write-confirmation gates; an agent must
|
|
107
|
+
still stop where those gates require human confirmation.
|
|
108
|
+
|
|
85
109
|
**Business-language discovery:** When a user uses a business alias, metric, recurring
|
|
86
110
|
term, or relationship/join intent instead of a physical table or field name, first run
|
|
87
111
|
`dbcli skill context --format json`. If it includes `semantic`, treat that reviewed
|
|
@@ -357,11 +381,11 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
|
|
|
357
381
|
| `use` | n/a | Show/switch default named connection (v2 only). |
|
|
358
382
|
| `list` | query-only+ | Tables (SQL), collections (MongoDB), keys (Redis), or indices (Elasticsearch). |
|
|
359
383
|
| `schema` | query-only+ | SQL: per-table or full scan into `.dbcli/schemas/`. MongoDB: sampled. ES: flattened mapping. Redis: per-key only (type/TTL/size). Supports `--recovery`. |
|
|
360
|
-
| `query` | query-only+ | SQL, Mongo JSON (`--collection`), Redis command, or ES DSL/Lucene (`--collection`). `--format table\|json\|csv\|html`, `--ui` to open the interactive dashboard in a browser. `--fields` (projection), `--truncate` (cell width), `-f/--query-file` (read query from file or stdin), `--use a,b` (read-only fan-out). Supports `--recovery`. See **Query workflow flags**. |
|
|
384
|
+
| `query` | query-only+ | SQL, Mongo JSON (`--collection`), Redis command, or ES DSL/Lucene (`--collection`). `--format table\|json\|csv\|html`, `--ui` to open the interactive dashboard in a browser. `--fields` (projection), `--truncate` (cell width), `-f/--query-file` (read query from file or stdin), `--use a,b` (read-only fan-out). Supports `--recovery`. `--slow-ms <n>` sets the passive slow-query hint threshold (default 1000, `0` off): at or above it, table output gains a `Performance hint` footer and JSON gains `metadata.performanceAdvisory`; it runs no extra diagnostics and is suppressed under `--recovery`. Distinct from the `proxy` flag of the same name. See **Query workflow flags**. |
|
|
361
385
|
| `explain` | query-only+ | **(v1.23)** Read-only query plan with annotations. SQL only. Single query, `@saved-query`, `@file.sql`, or `--bulk @glob/*`. `--analyze` (EXPLAIN ANALYZE / MariaDB ANALYZE SELECT), `--format markdown\|json\|table`. |
|
|
362
386
|
| `lint` | n/a | Static SQL anti-pattern advisor (no DB connection). 9 rules incl. schema-aware implicit-cast / NOT IN-nullable checks via the layered `.dbcli/schemas/` cache; global `--use <conn>` selects a named cache. Findings carry rewrite drafts + guarded `explain` verify commands (`--analyze` only for proven read-only SQL) — report-only, never executes. `--format text\|json\|markdown`, `--min-severity`, `--no-schema`, `--bulk`. Supports `--recovery`. |
|
|
363
387
|
| `plan` | n/a | Static SQL risk analyzer (`--format text\|json`); classifies a statement without connecting to the database. |
|
|
364
|
-
| `q` | query-only+ | Run a saved snippet by `@name` with `--param k=v`. Supports `--verify` to run assertions. |
|
|
388
|
+
| `q` | query-only+ | Run a saved snippet by `@name` with `--param k=v`. Supports `--verify` to run assertions and `--slow-ms <n>` (same passive slow-query hint as `query`). |
|
|
365
389
|
| `queries` | n/a | Manage saved snippets: `list` / `show` / `search` / `suggest` / `new` / `edit` / `check` / `delete` / `rename` / `copy` / `import` / `export`. |
|
|
366
390
|
| `insert` / `update` | read-write+ | SQL or MongoDB only. JSON `--data` / `--set`; `--where` required on `update`; `--dry-run` first. Redis writes go through `query`. Supports `--recovery`. |
|
|
367
391
|
| `delete` | data-admin+ | SQL or MongoDB; Redis has a basic implementation (see Redis section). `--where` required; `--dry-run` first. Supports `--recovery`. |
|
|
@@ -220,9 +220,44 @@ dbcli query "SELECT day, dau FROM dau_daily" --ui # open in brows
|
|
|
220
220
|
dbcli query "SELECT * FROM orders" --format html > orders.html # pipe to stdout
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
-
**Options:** `--format <table|json|csv|html>`, `--ui` (open the dashboard in the system browser; implies `--format html`), `--limit <number>`, `--no-limit`, `--collection <name>` (MongoDB / Elasticsearch), `--index <name>` (Elasticsearch alias for `--collection`), `--fields <list>`, `--truncate <number>` / `--no-truncate`, `-f, --query-file <path>`, `--use <name[,name]>`, `--recovery`
|
|
223
|
+
**Options:** `--format <table|json|csv|html>`, `--ui` (open the dashboard in the system browser; implies `--format html`), `--limit <number>`, `--no-limit`, `--collection <name>` (MongoDB / Elasticsearch), `--index <name>` (Elasticsearch alias for `--collection`), `--fields <list>`, `--truncate <number>` / `--no-truncate`, `-f, --query-file <path>`, `--use <name[,name]>`, `--slow-ms <number>`, `--recovery`
|
|
224
224
|
**Permission:** query-only+ (Redis: per-command; Elasticsearch: per HTTP method/path)
|
|
225
225
|
|
|
226
|
+
#### Passive slow-query hint (`--slow-ms`)
|
|
227
|
+
|
|
228
|
+
`query` and `q` read the execution time they already measured for a finished
|
|
229
|
+
query and, at or above the threshold, add a hint. Default `1000`; `--slow-ms 0`
|
|
230
|
+
disables it for that invocation. This is **not** the `proxy` / `proxy analyze`
|
|
231
|
+
flag of the same name — that one flags events in the proxy log; this one only
|
|
232
|
+
annotates a single command's own result.
|
|
233
|
+
|
|
234
|
+
The hint performs no extra work: it never runs `EXPLAIN`, reads a schema, or
|
|
235
|
+
issues a second request. It is suppressed entirely under `--recovery`, so the
|
|
236
|
+
recovery envelope keeps its exact machine contract.
|
|
237
|
+
|
|
238
|
+
- `--format table` appends `Performance hint: <recommendation>` to the footer.
|
|
239
|
+
- `--format json` adds `metadata.performanceAdvisory`:
|
|
240
|
+
|
|
241
|
+
```json
|
|
242
|
+
{
|
|
243
|
+
"metadata": {
|
|
244
|
+
"statement": "SELECT",
|
|
245
|
+
"performanceAdvisory": {
|
|
246
|
+
"code": "SLOW_QUERY",
|
|
247
|
+
"executionTimeMs": 1250,
|
|
248
|
+
"thresholdMs": 1000,
|
|
249
|
+
"recommendation": "Review safely with: dbcli guide slow-query --format markdown. This hint runs no additional database diagnostics."
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
The recommendation is engine-aware: PostgreSQL, MySQL, MariaDB, and Redis are
|
|
256
|
+
pointed at `dbcli guide slow-query`, because that goal resolves to real
|
|
257
|
+
diagnostic snippets for them. MongoDB and Elasticsearch ship no snippet for its
|
|
258
|
+
intents, so their hint states the timing and says so instead of naming a command
|
|
259
|
+
that would come back empty. `csv` and `html` output are unchanged.
|
|
260
|
+
|
|
226
261
|
Below `admin`, SQL holding more than one statement is rejected, because only the
|
|
227
262
|
first statement would decide the permission check while a driver on the simple
|
|
228
263
|
query protocol executes them all. Semicolons inside string literals, backtick
|
|
@@ -529,6 +564,7 @@ dbcli q @analytics/revenue --param days=30 --format html > report.html
|
|
|
529
564
|
- `--no-limit` — skip the `SELECT * FROM (…) AS _dbcli_guard LIMIT 1000` wrap
|
|
530
565
|
- `--dry-run` — print the bound SQL + values without executing
|
|
531
566
|
- `--use <name>` — pick a v2 named connection
|
|
567
|
+
- `--slow-ms <number>` — passive slow-query hint threshold (default `1000`; `0` disables). Same contract as `query` — see "Passive slow-query hint" there
|
|
532
568
|
- `--recovery` — emit a `RecoveryEnvelope` on failure (see `recover`)
|
|
533
569
|
- `--verify` — run the snippet's verification assertions after execution (only if the snippet defines them)
|
|
534
570
|
|
|
@@ -1077,6 +1113,139 @@ Both parameters are required. Keep each expansion as one quoted shell argument;
|
|
|
1077
1113
|
never use `eval`, and consider `--execute` only after the plan and captured DDL
|
|
1078
1114
|
have been reviewed.
|
|
1079
1115
|
|
|
1116
|
+
### design
|
|
1117
|
+
|
|
1118
|
+
Author, validate, render, and review a version-controlled SQL database design
|
|
1119
|
+
kept beside the code as `dbcli.design.json`. Every subcommand is offline: none
|
|
1120
|
+
opens a database connection, executes DDL, or calls an LLM. `design init` is the
|
|
1121
|
+
only writer, and it writes only to the explicit `--output` path.
|
|
1122
|
+
|
|
1123
|
+
```text
|
|
1124
|
+
dbcli design init --output <path> [--dialect <dialect>]
|
|
1125
|
+
dbcli design validate [--file <path>] [--format <format>]
|
|
1126
|
+
dbcli design render [--file <path>] [--format <format>]
|
|
1127
|
+
dbcli design diff (--against-cache | --against-orm <paths>) [options]
|
|
1128
|
+
dbcli design propose (--against-cache | --against-orm <paths>) [options]
|
|
1129
|
+
```
|
|
1130
|
+
|
|
1131
|
+
```bash
|
|
1132
|
+
# Writes only to this explicit, missing path; edit the starter before validating.
|
|
1133
|
+
dbcli design init --output ./dbcli.design.json --dialect postgresql
|
|
1134
|
+
|
|
1135
|
+
dbcli design validate --format json
|
|
1136
|
+
dbcli design render --format mermaid
|
|
1137
|
+
dbcli design diff --against-cache --format markdown
|
|
1138
|
+
dbcli design diff --against-orm ./prisma/schema.prisma --format markdown
|
|
1139
|
+
dbcli design propose --against-orm ./prisma/schema.prisma --format markdown
|
|
1140
|
+
```
|
|
1141
|
+
|
|
1142
|
+
| Option | Applies to | Default | Meaning |
|
|
1143
|
+
|---|---|---|---|
|
|
1144
|
+
| `--output <path>` | `init` | required | Destination for the new artifact; refuses to overwrite an existing file. |
|
|
1145
|
+
| `--dialect <postgresql\|mysql\|mariadb>` | `init` | `postgresql` | Target SQL dialect recorded in the artifact. |
|
|
1146
|
+
| `--file <path>` | all but `init` | `dbcli.design.json` | Design artifact to read. |
|
|
1147
|
+
| `--format <format>` | all but `init` | see below | `validate`/`propose`: `json`, `markdown`. `render`: `json`, `markdown`, `mermaid` (default `markdown`). `diff`: `json` (default), `table`, `markdown`. |
|
|
1148
|
+
| `--against-cache` | `diff`, `propose` | off | Compare with the local schema cache; requires a configured PostgreSQL/MySQL/MariaDB connection whose system matches the artifact dialect, and a non-empty cache (run `dbcli schema` first). |
|
|
1149
|
+
| `--against-orm <paths>` | `diff`, `propose` | none | Compare with local ORM definition(s); repeatable or comma-separated, DDL paths support globs. Needs no config and no connection. |
|
|
1150
|
+
| `--orm-format <format>` | `diff`, `propose` | auto-detect | Force `prisma`, `ddl`, `json`, `drizzle`, `typeorm`, or `sequelize`. |
|
|
1151
|
+
| `--ignore <globs>` | `diff`, `propose` | none | Comma-separated table globs excluded from drift. |
|
|
1152
|
+
|
|
1153
|
+
`diff` and `propose` require **exactly one** comparison target; passing both or
|
|
1154
|
+
neither is an error.
|
|
1155
|
+
|
|
1156
|
+
#### Artifact shape
|
|
1157
|
+
|
|
1158
|
+
```json
|
|
1159
|
+
{
|
|
1160
|
+
"version": 1,
|
|
1161
|
+
"dialect": "postgresql",
|
|
1162
|
+
"models": [
|
|
1163
|
+
{
|
|
1164
|
+
"name": "orders",
|
|
1165
|
+
"table": "orders",
|
|
1166
|
+
"description": "Completed purchases.",
|
|
1167
|
+
"fields": [
|
|
1168
|
+
{ "name": "id", "type": "bigint", "nullable": false, "primaryKey": true, "unique": true },
|
|
1169
|
+
{ "name": "customer_id", "type": "bigint", "nullable": false, "primaryKey": false, "unique": false }
|
|
1170
|
+
],
|
|
1171
|
+
"indexes": [{ "name": "orders_customer_idx", "columns": ["customer_id"], "unique": false }]
|
|
1172
|
+
}
|
|
1173
|
+
],
|
|
1174
|
+
"relationships": [
|
|
1175
|
+
{
|
|
1176
|
+
"name": "orders_customer",
|
|
1177
|
+
"from": { "model": "orders", "field": "customer_id" },
|
|
1178
|
+
"to": { "model": "customers", "field": "id" },
|
|
1179
|
+
"cardinality": "many-to-one"
|
|
1180
|
+
}
|
|
1181
|
+
],
|
|
1182
|
+
"accessPatterns": [{ "model": "orders", "filters": ["customer_id"], "sort": ["created_at"] }],
|
|
1183
|
+
"decisions": [{ "name": "single-currency", "rationale": "Amounts are stored in minor units, USD only." }]
|
|
1184
|
+
}
|
|
1185
|
+
```
|
|
1186
|
+
|
|
1187
|
+
It holds no SQL, credentials, rows, or provider configuration. `design init`
|
|
1188
|
+
emits this envelope with empty `models`, `relationships`, `accessPatterns`, and
|
|
1189
|
+
`decisions`.
|
|
1190
|
+
|
|
1191
|
+
#### Review findings
|
|
1192
|
+
|
|
1193
|
+
`validate` is fail-closed: any `error` finding exits `1`, and `render`, `diff`,
|
|
1194
|
+
and `propose` refuse to do their work while errors remain.
|
|
1195
|
+
|
|
1196
|
+
| Severity | Codes |
|
|
1197
|
+
|---|---|
|
|
1198
|
+
| `error` | `NO_MODELS`, `DUPLICATE_MODEL`, `DUPLICATE_TABLE`, `DUPLICATE_FIELD`, `PRIMARY_KEY_COUNT`, `NULLABLE_PRIMARY_KEY`, `UNKNOWN_INDEX_FIELD`, `DUPLICATE_RELATIONSHIP`, `REVERSE_RELATIONSHIP`, `UNKNOWN_RELATIONSHIP_MODEL`, `UNKNOWN_RELATIONSHIP_FIELD`, `RELATIONSHIP_TYPE_MISMATCH`, `MANY_TO_MANY_REQUIRES_BRIDGE`, `ONE_TO_ONE_REQUIRES_UNIQUE_FK`, `UNKNOWN_ACCESS_MODEL`, `UNKNOWN_ACCESS_FIELD` |
|
|
1199
|
+
| `warn` | `DUPLICATE_INDEX`, `REDUNDANT_PRIMARY_KEY_INDEX`, `PREFIX_REDUNDANT_INDEX`, `ACCESS_PATTERN_INDEX` |
|
|
1200
|
+
|
|
1201
|
+
`REVERSE_RELATIONSHIP` fires when the same endpoints are declared again in the
|
|
1202
|
+
opposite direction; `PREFIX_REDUNDANT_INDEX` fires when a non-unique index is a
|
|
1203
|
+
leading-column prefix of a longer index. `v1` requires exactly one primary-key
|
|
1204
|
+
field per model and an explicit bridge model for `many-to-many`.
|
|
1205
|
+
|
|
1206
|
+
#### `design propose` (review-only)
|
|
1207
|
+
|
|
1208
|
+
`propose` turns drift into a plan a human reviews; it never applies a write. Each
|
|
1209
|
+
entry carries a `safety` of `dry-run` (an existing `migrate` command can represent
|
|
1210
|
+
the change losslessly) or `migration-review` (everything else), plus `preflight`,
|
|
1211
|
+
`rollback`, and `verification` steps:
|
|
1212
|
+
|
|
1213
|
+
```json
|
|
1214
|
+
{
|
|
1215
|
+
"table": "orders",
|
|
1216
|
+
"object": "total_cents",
|
|
1217
|
+
"safety": "migration-review",
|
|
1218
|
+
"commands": ["..."],
|
|
1219
|
+
"preflight": [
|
|
1220
|
+
"dbcli blacklist list",
|
|
1221
|
+
"Confirm the exact affected table with: dbcli schema <exact-table> --format json"
|
|
1222
|
+
],
|
|
1223
|
+
"rollback": "Capture the current schema and generated DDL before any approved write; define the inverse migration before execution.",
|
|
1224
|
+
"verification": [
|
|
1225
|
+
"After an approved write, run: dbcli schema <exact-table> --format json",
|
|
1226
|
+
"Re-run this same design diff command and review the remaining drift."
|
|
1227
|
+
]
|
|
1228
|
+
}
|
|
1229
|
+
```
|
|
1230
|
+
|
|
1231
|
+
**Workflows:**
|
|
1232
|
+
|
|
1233
|
+
- **New project** — `design init` → edit the artifact → `design validate` →
|
|
1234
|
+
`design render`. If application models already exist, use the offline
|
|
1235
|
+
`design diff --against-orm <path>` to reconcile the artifact and the ORM before
|
|
1236
|
+
any database exists.
|
|
1237
|
+
- **Existing database** — `blacklist list` → refresh the cache with
|
|
1238
|
+
`schema --format json` → `design diff --against-cache` →
|
|
1239
|
+
`design propose --against-cache`. Review the plan, perform any approved
|
|
1240
|
+
migration separately, then refresh the schema and rerun the same diff.
|
|
1241
|
+
|
|
1242
|
+
**Exit codes:** `0` when no errors, `1` when the artifact has review errors, an
|
|
1243
|
+
invalid target selection, an unreadable file, or reported drift errors.
|
|
1244
|
+
|
|
1245
|
+
An external coding agent may draft the artifact, but a human should review it
|
|
1246
|
+
before it is relied upon. Do not create or rewrite `dbcli.design.json` without an
|
|
1247
|
+
explicit human request.
|
|
1248
|
+
|
|
1080
1249
|
### snapshot
|
|
1081
1250
|
|
|
1082
1251
|
Capture a **result fingerprint** of a query (not schema): `rowCount` plus per-column
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,29 @@ 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.52.0] - 2026-08-07 - Offline database design assistant and slow-query hints
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Offline database design assistant.** `dbcli design init|validate|render|diff|propose` authors and reviews a version-controlled `dbcli.design.json` beside the code. Every subcommand is offline: none opens a connection, executes DDL, or calls a provider, and `design init` is the only writer — to the explicit `--output` path, refusing to overwrite. `validate` is fail-closed, so `render`, `diff`, and `propose` refuse to work while `error` findings remain; `render` emits `json`, `markdown`, or `mermaid`.
|
|
13
|
+
- **Design drift comparison and review-only proposals.** `design diff` and `design propose` compare the artifact against the local schema cache (`--against-cache`) or local ORM definitions (`--against-orm`, supporting Prisma, DDL, Drizzle, TypeORM, Sequelize, and JSON), with `--orm-format` and `--ignore` for control. `propose` turns drift into a plan a human reviews and never applies a write: each entry carries a `dry-run` or `migration-review` safety level plus `preflight`, `rollback`, and `verification` steps.
|
|
14
|
+
- **Two further design review rules.** `REVERSE_RELATIONSHIP` (error) fires when the same endpoints are declared again in the opposite direction, and `PREFIX_REDUNDANT_INDEX` (warn) fires when a non-unique index is a leading-column prefix of a longer index.
|
|
15
|
+
- **Passive slow-query hint on `query` and `q`.** At or above `--slow-ms` (default 1000, `0` disables), a finished query gains a Performance hint footer and `metadata.performanceAdvisory`. It reuses the execution time already measured — no `EXPLAIN`, no schema read, no second request. The recommendation is engine-aware: PostgreSQL, MySQL, MariaDB, and Redis are pointed at `guide slow-query`; MongoDB and Elasticsearch state the timing instead. `--recovery` suppresses the hint so that envelope keeps its contract.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- **Skill reference documents the new surface.** `skills/dbcli/reference.md` gains the `design` section (subcommands, artifact shape, finding codes and severities, the review-only `propose` contract, and workflows) plus the `--slow-ms` flag and the `metadata.performanceAdvisory` shape, disambiguated from the proxy flag of the same name.
|
|
20
|
+
|
|
21
|
+
### Tests
|
|
22
|
+
|
|
23
|
+
- Gherkin CLI workflow coverage for workspace inspection, blacklist review, and the verification prune dry run.
|
|
24
|
+
|
|
25
|
+
## [1.51.2] - 2026-08-07 - Intent confirmation for business requests
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- **Per-request agent intent confirmation.** Installed dbcli skills now support `auto` (default), `confirm`, and `guided` conversational preferences for business-language database requests. Agents ask only result-changing questions, carry confirmed answers forward, and disclose material assumptions when explicitly asked to decide without further questions. These preferences are not persistent CLI configuration and never bypass schema, blacklist, permission, dry-run, production-selection, or write-confirmation gates.
|
|
30
|
+
|
|
8
31
|
## [1.51.1] - 2026-08-07 - Proactive semantic context discovery
|
|
9
32
|
|
|
10
33
|
### Changed
|
package/README.md
CHANGED
|
@@ -1679,6 +1679,7 @@ bun test # full test suite (Bun test runner)
|
|
|
1679
1679
|
bun run typecheck # TypeScript compile-time validation
|
|
1680
1680
|
bun run test:unit # unit + core tests only
|
|
1681
1681
|
bun run test:integration # integration tests
|
|
1682
|
+
bun run test:gherkin # Gherkin feature tests at the CLI boundary
|
|
1682
1683
|
bun run test:docker # integration tests with docker-compose.test.yml (MySQL + PostgreSQL)
|
|
1683
1684
|
bun run build # bundle CLI to dist/ (used before publish)
|
|
1684
1685
|
```
|
package/README.zh-TW.md
CHANGED
|
@@ -1558,6 +1558,7 @@ import {
|
|
|
1558
1558
|
bun test # 完整測試(Bun test runner)
|
|
1559
1559
|
bun run test:unit # 僅單元與 core 測試
|
|
1560
1560
|
bun run test:integration # 整合測試
|
|
1561
|
+
bun run test:gherkin # CLI 邊界的 Gherkin feature 測試
|
|
1561
1562
|
bun run test:docker # 搭配 docker-compose.test.yml(MySQL + PostgreSQL)
|
|
1562
1563
|
bun run build # 建置 CLI 至 dist/(發布前使用)
|
|
1563
1564
|
```
|
package/assets/SKILL.md
CHANGED
|
@@ -82,6 +82,30 @@ warnings) go to stderr so stdout stays parseable — when piping JSON into a par
|
|
|
82
82
|
use `2>/dev/null` or leave stderr alone. **Never `2>&1`**: it merges those lines back
|
|
83
83
|
into stdout and the parse fails.
|
|
84
84
|
|
|
85
|
+
**Intent confirmation:** Treat `auto`, `confirm`, and `guided` as conversational
|
|
86
|
+
preferences for the current request, not as dbcli flags or persistent configuration.
|
|
87
|
+
Do not ask the user a meta-question about whether they want questions.
|
|
88
|
+
|
|
89
|
+
- `auto` (default): autonomously use governed semantic context and schema discovery.
|
|
90
|
+
If unresolved ambiguity would materially change the result, ask one compact batch of
|
|
91
|
+
questions before querying; otherwise state the assumptions and proceed.
|
|
92
|
+
- `confirm`: first state the proposed interpretation and wait for the user's approval
|
|
93
|
+
before issuing the task's data query.
|
|
94
|
+
- `guided`: resolve the request through short, focused questions, carrying confirmed
|
|
95
|
+
answers forward rather than asking again.
|
|
96
|
+
|
|
97
|
+
For business requests, material ambiguity includes the requested result shape or grain,
|
|
98
|
+
metric definition, time boundary and timezone, inclusion/exclusion rules (such as order
|
|
99
|
+
status or refunds), grouping, or selected connection. Example: for “yesterday's sales,”
|
|
100
|
+
do not guess whether the user needs a total or detail, which timezone defines yesterday,
|
|
101
|
+
or whether cancelled and refunded orders count. Summarize the candidate interpretation
|
|
102
|
+
and ask only the unresolved, result-changing questions.
|
|
103
|
+
|
|
104
|
+
When the user explicitly says to decide without further questions, proceed in `auto`
|
|
105
|
+
mode and disclose the material assumptions. This never bypasses blacklist, schema,
|
|
106
|
+
permission, dry-run, production-selection, or write-confirmation gates; an agent must
|
|
107
|
+
still stop where those gates require human confirmation.
|
|
108
|
+
|
|
85
109
|
**Business-language discovery:** When a user uses a business alias, metric, recurring
|
|
86
110
|
term, or relationship/join intent instead of a physical table or field name, first run
|
|
87
111
|
`dbcli skill context --format json`. If it includes `semantic`, treat that reviewed
|
|
@@ -357,11 +381,11 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
|
|
|
357
381
|
| `use` | n/a | Show/switch default named connection (v2 only). |
|
|
358
382
|
| `list` | query-only+ | Tables (SQL), collections (MongoDB), keys (Redis), or indices (Elasticsearch). |
|
|
359
383
|
| `schema` | query-only+ | SQL: per-table or full scan into `.dbcli/schemas/`. MongoDB: sampled. ES: flattened mapping. Redis: per-key only (type/TTL/size). Supports `--recovery`. |
|
|
360
|
-
| `query` | query-only+ | SQL, Mongo JSON (`--collection`), Redis command, or ES DSL/Lucene (`--collection`). `--format table\|json\|csv\|html`, `--ui` to open the interactive dashboard in a browser. `--fields` (projection), `--truncate` (cell width), `-f/--query-file` (read query from file or stdin), `--use a,b` (read-only fan-out). Supports `--recovery`. See **Query workflow flags**. |
|
|
384
|
+
| `query` | query-only+ | SQL, Mongo JSON (`--collection`), Redis command, or ES DSL/Lucene (`--collection`). `--format table\|json\|csv\|html`, `--ui` to open the interactive dashboard in a browser. `--fields` (projection), `--truncate` (cell width), `-f/--query-file` (read query from file or stdin), `--use a,b` (read-only fan-out). Supports `--recovery`. `--slow-ms <n>` sets the passive slow-query hint threshold (default 1000, `0` off): at or above it, table output gains a `Performance hint` footer and JSON gains `metadata.performanceAdvisory`; it runs no extra diagnostics and is suppressed under `--recovery`. Distinct from the `proxy` flag of the same name. See **Query workflow flags**. |
|
|
361
385
|
| `explain` | query-only+ | **(v1.23)** Read-only query plan with annotations. SQL only. Single query, `@saved-query`, `@file.sql`, or `--bulk @glob/*`. `--analyze` (EXPLAIN ANALYZE / MariaDB ANALYZE SELECT), `--format markdown\|json\|table`. |
|
|
362
386
|
| `lint` | n/a | Static SQL anti-pattern advisor (no DB connection). 9 rules incl. schema-aware implicit-cast / NOT IN-nullable checks via the layered `.dbcli/schemas/` cache; global `--use <conn>` selects a named cache. Findings carry rewrite drafts + guarded `explain` verify commands (`--analyze` only for proven read-only SQL) — report-only, never executes. `--format text\|json\|markdown`, `--min-severity`, `--no-schema`, `--bulk`. Supports `--recovery`. |
|
|
363
387
|
| `plan` | n/a | Static SQL risk analyzer (`--format text\|json`); classifies a statement without connecting to the database. |
|
|
364
|
-
| `q` | query-only+ | Run a saved snippet by `@name` with `--param k=v`. Supports `--verify` to run assertions. |
|
|
388
|
+
| `q` | query-only+ | Run a saved snippet by `@name` with `--param k=v`. Supports `--verify` to run assertions and `--slow-ms <n>` (same passive slow-query hint as `query`). |
|
|
365
389
|
| `queries` | n/a | Manage saved snippets: `list` / `show` / `search` / `suggest` / `new` / `edit` / `check` / `delete` / `rename` / `copy` / `import` / `export`. |
|
|
366
390
|
| `insert` / `update` | read-write+ | SQL or MongoDB only. JSON `--data` / `--set`; `--where` required on `update`; `--dry-run` first. Redis writes go through `query`. Supports `--recovery`. |
|
|
367
391
|
| `delete` | data-admin+ | SQL or MongoDB; Redis has a basic implementation (see Redis section). `--where` required; `--dry-run` first. Supports `--recovery`. |
|
package/assets/SKILL.zh-TW.md
CHANGED
|
@@ -64,6 +64,23 @@ legacy 單檔 `.dbcli`。若要防護同一 OS 使用者的惡意 process,host
|
|
|
64
64
|
stdout 保持可解析——把 JSON 導進 parser 時請用 `2>/dev/null` 或不要動 stderr。
|
|
65
65
|
**絕對不要用 `2>&1`**:那會把那些訊息併回 stdout,解析必定失敗。
|
|
66
66
|
|
|
67
|
+
**意圖確認:**將 `auto`、`confirm` 與 `guided` 視為**當次請求**的對話偏好,而不是 dbcli
|
|
68
|
+
旗標或持久化設定。不要先用後設問題詢問使用者「要不要讓我提問」。
|
|
69
|
+
|
|
70
|
+
- `auto`(預設):自主使用受治理的 semantic context 與 schema 探索。若尚未解決的歧義會
|
|
71
|
+
實質改變結果,先用一小批精簡問題確認;否則說明假設後繼續。
|
|
72
|
+
- `confirm`:先說明預計採用的解讀,等待使用者核准後,才發出該任務的資料查詢。
|
|
73
|
+
- `guided`:以短而聚焦的問題逐步釐清請求;已確認的答案必須延續使用,不可重複詢問。
|
|
74
|
+
|
|
75
|
+
對業務請求而言,會實質改變結果的歧義包括所需結果的形狀或粒度、指標定義、時間邊界與
|
|
76
|
+
時區、納入/排除規則(例如訂單狀態或退款)、分組方式與選用連線。例如「昨天的銷售資料」
|
|
77
|
+
不能猜測使用者要總額或明細、哪個時區定義昨天,或取消與退款訂單是否計入。先摘要候選解讀,
|
|
78
|
+
只詢問尚未解決且會改變結果的問題。
|
|
79
|
+
|
|
80
|
+
當使用者明確要求自行判斷、不要再問時,以 `auto` 模式繼續並說明重要假設。這絕不繞過
|
|
81
|
+
blacklist、schema、permission、dry-run、production 選取或寫入確認閘門;只要閘門要求人類
|
|
82
|
+
確認,agent 仍必須停止。
|
|
83
|
+
|
|
67
84
|
**業務語言探索:** 當使用者以業務別名、metric、反覆出現的術語或 relationship/join 意圖,
|
|
68
85
|
而非實體 table 或 field 名稱提出需求時,先執行 `dbcli skill context --format json`。若輸出含有
|
|
69
86
|
`semantic`,將該已檢閱的區塊視為受治理詞彙;需查找特定術語時,用
|