@carllee1983/dbcli 1.50.0 → 1.51.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 +1 -0
- package/.cursor/skills/dbcli/reference.md +118 -0
- package/.cursor-plugin/plugin.json +1 -1
- package/.github/skills/dbcli/SKILL.md +1 -0
- package/.github/skills/dbcli/reference.md +118 -0
- package/CHANGELOG.md +9 -0
- package/assets/SKILL.md +1 -0
- package/assets/SKILL.zh-TW.md +1 -0
- package/assets/reference.md +118 -0
- package/dist/cli.mjs +68300 -67106
- package/gemini-extension.json +1 -1
- package/package.json +1 -1
- package/plugins/dbcli-agent/.codex-plugin/plugin.json +1 -1
- package/plugins/dbcli-agent/skills/dbcli/SKILL.md +1 -0
- package/plugins/dbcli-agent/skills/dbcli/reference.md +118 -0
- package/skills/dbcli/SKILL.md +1 -0
- package/skills/dbcli/reference.md +118 -0
package/gemini-extension.json
CHANGED
package/package.json
CHANGED
|
@@ -375,6 +375,7 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
|
|
|
375
375
|
| `upgrade` | n/a | Self-update from npm; 24h-cached version hints on every command. |
|
|
376
376
|
| `shell` | (same as query+) | Interactive REPL. SQL engines, MongoDB, and Redis (single-line; `.no-limit on/off`). **(v1.22)** Elasticsearch opens a Kibana Dev Tools-style REPL (`<METHOD> /<path>` + optional JSON body, blank line submits). |
|
|
377
377
|
| `skill` | n/a | Generate / install AI skill docs (`--install <claude\|gemini\|antigravity\|copilot\|cursor\|codex\|windsurf>`); `skill tasks list/show/plan` for Agent Task Packs; `skill context` for an LLM prompt-context payload (for injecting into another LLM, not needed for normal operation). |
|
|
378
|
+
| `semantic` | n/a | Validate, search, inspect drift, migrate to v2, or print the optional project-root `dbcli.semantic.json`. Give its reviewed context to an external agent, but keep provider credentials, prompts, and agent context outside dbcli. `semantic draft validate --input <file|-> [--format text\|json]` validates only the explicit untrusted `QueryDraft` offline against local semantic/schema/saved-query metadata; it returns safe hashes/references/violation codes, never executes or echoes candidate SQL. Review the original draft, then invoke `explain` or `query` separately if intended. |
|
|
378
379
|
| `migrate` | admin | SQL only. **DDL; dry-run by default** — needs `--execute`. |
|
|
379
380
|
|
|
380
381
|
Use root-level `dbcli --use <name> <command>` for any command; `query`, `schema`, `list`,
|
|
@@ -2190,6 +2190,124 @@ dbcli migrate drop-enum status --execute --force
|
|
|
2190
2190
|
|
|
2191
2191
|
**AI agent note:** Always use dry-run first (no `--execute`) to preview generated SQL. Only add `--execute` after confirming the SQL is correct. For DROP operations, both `--execute` and `--force` are required.
|
|
2192
2192
|
|
|
2193
|
+
### semantic
|
|
2194
|
+
|
|
2195
|
+
Validate or print the optional, version-controlled `dbcli.semantic.json` in the
|
|
2196
|
+
project root. It supplies business names and descriptions to an agent, but is
|
|
2197
|
+
not a query language: these commands are offline, read-only, and never execute
|
|
2198
|
+
SQL or contact an LLM.
|
|
2199
|
+
|
|
2200
|
+
```bash
|
|
2201
|
+
dbcli semantic validate
|
|
2202
|
+
dbcli semantic validate --format json
|
|
2203
|
+
dbcli semantic context
|
|
2204
|
+
dbcli semantic context --format markdown
|
|
2205
|
+
dbcli semantic context --file ./analytics.semantic.json
|
|
2206
|
+
dbcli semantic drift --format json
|
|
2207
|
+
dbcli semantic migrate --to 2 --format json
|
|
2208
|
+
dbcli semantic search purchases --kind model --format json
|
|
2209
|
+
dbcli semantic draft validate --input ./draft.json --format json
|
|
2210
|
+
external-agent | dbcli semantic draft validate --input - --format json
|
|
2211
|
+
```
|
|
2212
|
+
|
|
2213
|
+
The default file has this compact contract:
|
|
2214
|
+
|
|
2215
|
+
```json
|
|
2216
|
+
{
|
|
2217
|
+
"version": 2,
|
|
2218
|
+
"models": [
|
|
2219
|
+
{
|
|
2220
|
+
"name": "orders",
|
|
2221
|
+
"table": "orders",
|
|
2222
|
+
"description": "Completed purchases.",
|
|
2223
|
+
"aliases": ["purchases"],
|
|
2224
|
+
"fields": [
|
|
2225
|
+
{ "column": "created_at", "aliases": ["order date"] },
|
|
2226
|
+
{ "column": "customer_id" }
|
|
2227
|
+
]
|
|
2228
|
+
},
|
|
2229
|
+
{
|
|
2230
|
+
"name": "customers",
|
|
2231
|
+
"table": "customers",
|
|
2232
|
+
"fields": [{ "column": "id" }]
|
|
2233
|
+
}
|
|
2234
|
+
],
|
|
2235
|
+
"relationships": [
|
|
2236
|
+
{
|
|
2237
|
+
"name": "order-customer",
|
|
2238
|
+
"from": { "model": "orders", "field": "customer_id" },
|
|
2239
|
+
"to": { "model": "customers", "field": "id" },
|
|
2240
|
+
"cardinality": "many-to-one",
|
|
2241
|
+
"description": "Each order belongs to one customer."
|
|
2242
|
+
}
|
|
2243
|
+
],
|
|
2244
|
+
"metrics": [
|
|
2245
|
+
{ "name": "daily-revenue", "query": "@analytics/revenue" }
|
|
2246
|
+
]
|
|
2247
|
+
}
|
|
2248
|
+
```
|
|
2249
|
+
|
|
2250
|
+
Version 1 remains supported and is normalized with `relationships: []`.
|
|
2251
|
+
Version 2 relationships must reference a declared model and a declared field on
|
|
2252
|
+
that model; the field must also be visible in cached schema. Their `cardinality`
|
|
2253
|
+
is one of `one-to-one`, `one-to-many`, `many-to-one`, or `many-to-many`.
|
|
2254
|
+
`models[].table` and `models[].fields[].column` must name a visible cached
|
|
2255
|
+
schema object. Blacklisted tables and columns are not visible and are rejected.
|
|
2256
|
+
Each metric `query` must name an available saved query. Validation parses its
|
|
2257
|
+
local file through the normal saved-query safety checks, but never executes or
|
|
2258
|
+
emits SQL. The semantic file cannot contain SQL, connection data, or
|
|
2259
|
+
credentials. `semantic validate` reports a
|
|
2260
|
+
deterministic success summary (`--format text|json`); `semantic context` prints
|
|
2261
|
+
the validated context (`--format json|markdown`). `semantic drift` returns a
|
|
2262
|
+
stable `valid`, `stale`, `invalid`, or `unavailable` report and exits non-zero
|
|
2263
|
+
for every status except `valid`; it never connects to a database. `semantic
|
|
2264
|
+
migrate --to 2` prints a deterministic v2 JSON document to stdout and never
|
|
2265
|
+
writes the input file. An absent default file is allowed for `skill context`
|
|
2266
|
+
and simply omits the semantic section; a stale or invalid present file fails
|
|
2267
|
+
closed rather than being silently ignored.
|
|
2268
|
+
|
|
2269
|
+
`semantic search <terms...>` performs deterministic, case-insensitive matching
|
|
2270
|
+
over canonical names, aliases, descriptions, and governed model paths. Results
|
|
2271
|
+
are ranked by exact canonical name, exact alias, prefix, then description token;
|
|
2272
|
+
kind/name breaks ties. Use `--kind model|field|relationship|metric` and
|
|
2273
|
+
`--limit <1-100>` (default `20`). It returns only canonical references, matched
|
|
2274
|
+
terms, aliases, descriptions, and necessary model paths—never SQL bodies,
|
|
2275
|
+
connection data, or blacklist names. No result is an empty array / text notice
|
|
2276
|
+
with exit 0.
|
|
2277
|
+
|
|
2278
|
+
`semantic draft validate --input <file|-> [--format text|json]` accepts only an
|
|
2279
|
+
explicit untrusted `QueryDraft` JSON document from a file or stdin. First give
|
|
2280
|
+
the external agent reviewed `dbcli semantic context --format json` output; its
|
|
2281
|
+
provider credentials, prompt, and other agent context remain outside dbcli. The
|
|
2282
|
+
agent returns a draft using only the declared models and fields, for example:
|
|
2283
|
+
|
|
2284
|
+
```json
|
|
2285
|
+
{
|
|
2286
|
+
"version": 1,
|
|
2287
|
+
"questionHash": "<sha256-of-the-original-question>",
|
|
2288
|
+
"candidate": { "kind": "sql", "sql": "<reviewed-read-only-sql>" },
|
|
2289
|
+
"semanticReferences": ["model:<model>", "field:<model>.<field>"]
|
|
2290
|
+
}
|
|
2291
|
+
```
|
|
2292
|
+
|
|
2293
|
+
The command validates the contract, read-only single-statement SQL, canonical
|
|
2294
|
+
semantic references, saved-query names, and local filtered schema/blacklist
|
|
2295
|
+
compatibility without connecting to a database, reading query results, storing
|
|
2296
|
+
the draft, or calling a provider. JSON reports contain only status, hashes,
|
|
2297
|
+
canonical references, and safe violation codes; they never echo candidate SQL
|
|
2298
|
+
or protected names. Exit `0` means valid, `1` means rejected, and `2` means
|
|
2299
|
+
required local semantic evidence is unavailable. A valid report is not execution
|
|
2300
|
+
authorization: review the original draft, then separately and explicitly invoke
|
|
2301
|
+
`dbcli explain "<reviewed-read-only-sql>"` or `dbcli query
|
|
2302
|
+
"<reviewed-read-only-sql>"` when appropriate.
|
|
2303
|
+
|
|
2304
|
+
When valid, `dbcli skill context` includes the same bounded data in its JSON,
|
|
2305
|
+
XML, and Markdown output. To run a metric, an agent must still invoke the named
|
|
2306
|
+
saved query through `dbcli q`; all ordinary permissions, blacklist masking,
|
|
2307
|
+
limits, audit, and recovery safeguards remain in force.
|
|
2308
|
+
|
|
2309
|
+
**Permission:** n/a (local files only; no database connection).
|
|
2310
|
+
|
|
2193
2311
|
### skill
|
|
2194
2312
|
|
|
2195
2313
|
Emit `SKILL.md` (and the companion `reference.md`) to stdout, a file, or an
|
package/skills/dbcli/SKILL.md
CHANGED
|
@@ -375,6 +375,7 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
|
|
|
375
375
|
| `upgrade` | n/a | Self-update from npm; 24h-cached version hints on every command. |
|
|
376
376
|
| `shell` | (same as query+) | Interactive REPL. SQL engines, MongoDB, and Redis (single-line; `.no-limit on/off`). **(v1.22)** Elasticsearch opens a Kibana Dev Tools-style REPL (`<METHOD> /<path>` + optional JSON body, blank line submits). |
|
|
377
377
|
| `skill` | n/a | Generate / install AI skill docs (`--install <claude\|gemini\|antigravity\|copilot\|cursor\|codex\|windsurf>`); `skill tasks list/show/plan` for Agent Task Packs; `skill context` for an LLM prompt-context payload (for injecting into another LLM, not needed for normal operation). |
|
|
378
|
+
| `semantic` | n/a | Validate, search, inspect drift, migrate to v2, or print the optional project-root `dbcli.semantic.json`. Give its reviewed context to an external agent, but keep provider credentials, prompts, and agent context outside dbcli. `semantic draft validate --input <file|-> [--format text\|json]` validates only the explicit untrusted `QueryDraft` offline against local semantic/schema/saved-query metadata; it returns safe hashes/references/violation codes, never executes or echoes candidate SQL. Review the original draft, then invoke `explain` or `query` separately if intended. |
|
|
378
379
|
| `migrate` | admin | SQL only. **DDL; dry-run by default** — needs `--execute`. |
|
|
379
380
|
|
|
380
381
|
Use root-level `dbcli --use <name> <command>` for any command; `query`, `schema`, `list`,
|
|
@@ -2190,6 +2190,124 @@ dbcli migrate drop-enum status --execute --force
|
|
|
2190
2190
|
|
|
2191
2191
|
**AI agent note:** Always use dry-run first (no `--execute`) to preview generated SQL. Only add `--execute` after confirming the SQL is correct. For DROP operations, both `--execute` and `--force` are required.
|
|
2192
2192
|
|
|
2193
|
+
### semantic
|
|
2194
|
+
|
|
2195
|
+
Validate or print the optional, version-controlled `dbcli.semantic.json` in the
|
|
2196
|
+
project root. It supplies business names and descriptions to an agent, but is
|
|
2197
|
+
not a query language: these commands are offline, read-only, and never execute
|
|
2198
|
+
SQL or contact an LLM.
|
|
2199
|
+
|
|
2200
|
+
```bash
|
|
2201
|
+
dbcli semantic validate
|
|
2202
|
+
dbcli semantic validate --format json
|
|
2203
|
+
dbcli semantic context
|
|
2204
|
+
dbcli semantic context --format markdown
|
|
2205
|
+
dbcli semantic context --file ./analytics.semantic.json
|
|
2206
|
+
dbcli semantic drift --format json
|
|
2207
|
+
dbcli semantic migrate --to 2 --format json
|
|
2208
|
+
dbcli semantic search purchases --kind model --format json
|
|
2209
|
+
dbcli semantic draft validate --input ./draft.json --format json
|
|
2210
|
+
external-agent | dbcli semantic draft validate --input - --format json
|
|
2211
|
+
```
|
|
2212
|
+
|
|
2213
|
+
The default file has this compact contract:
|
|
2214
|
+
|
|
2215
|
+
```json
|
|
2216
|
+
{
|
|
2217
|
+
"version": 2,
|
|
2218
|
+
"models": [
|
|
2219
|
+
{
|
|
2220
|
+
"name": "orders",
|
|
2221
|
+
"table": "orders",
|
|
2222
|
+
"description": "Completed purchases.",
|
|
2223
|
+
"aliases": ["purchases"],
|
|
2224
|
+
"fields": [
|
|
2225
|
+
{ "column": "created_at", "aliases": ["order date"] },
|
|
2226
|
+
{ "column": "customer_id" }
|
|
2227
|
+
]
|
|
2228
|
+
},
|
|
2229
|
+
{
|
|
2230
|
+
"name": "customers",
|
|
2231
|
+
"table": "customers",
|
|
2232
|
+
"fields": [{ "column": "id" }]
|
|
2233
|
+
}
|
|
2234
|
+
],
|
|
2235
|
+
"relationships": [
|
|
2236
|
+
{
|
|
2237
|
+
"name": "order-customer",
|
|
2238
|
+
"from": { "model": "orders", "field": "customer_id" },
|
|
2239
|
+
"to": { "model": "customers", "field": "id" },
|
|
2240
|
+
"cardinality": "many-to-one",
|
|
2241
|
+
"description": "Each order belongs to one customer."
|
|
2242
|
+
}
|
|
2243
|
+
],
|
|
2244
|
+
"metrics": [
|
|
2245
|
+
{ "name": "daily-revenue", "query": "@analytics/revenue" }
|
|
2246
|
+
]
|
|
2247
|
+
}
|
|
2248
|
+
```
|
|
2249
|
+
|
|
2250
|
+
Version 1 remains supported and is normalized with `relationships: []`.
|
|
2251
|
+
Version 2 relationships must reference a declared model and a declared field on
|
|
2252
|
+
that model; the field must also be visible in cached schema. Their `cardinality`
|
|
2253
|
+
is one of `one-to-one`, `one-to-many`, `many-to-one`, or `many-to-many`.
|
|
2254
|
+
`models[].table` and `models[].fields[].column` must name a visible cached
|
|
2255
|
+
schema object. Blacklisted tables and columns are not visible and are rejected.
|
|
2256
|
+
Each metric `query` must name an available saved query. Validation parses its
|
|
2257
|
+
local file through the normal saved-query safety checks, but never executes or
|
|
2258
|
+
emits SQL. The semantic file cannot contain SQL, connection data, or
|
|
2259
|
+
credentials. `semantic validate` reports a
|
|
2260
|
+
deterministic success summary (`--format text|json`); `semantic context` prints
|
|
2261
|
+
the validated context (`--format json|markdown`). `semantic drift` returns a
|
|
2262
|
+
stable `valid`, `stale`, `invalid`, or `unavailable` report and exits non-zero
|
|
2263
|
+
for every status except `valid`; it never connects to a database. `semantic
|
|
2264
|
+
migrate --to 2` prints a deterministic v2 JSON document to stdout and never
|
|
2265
|
+
writes the input file. An absent default file is allowed for `skill context`
|
|
2266
|
+
and simply omits the semantic section; a stale or invalid present file fails
|
|
2267
|
+
closed rather than being silently ignored.
|
|
2268
|
+
|
|
2269
|
+
`semantic search <terms...>` performs deterministic, case-insensitive matching
|
|
2270
|
+
over canonical names, aliases, descriptions, and governed model paths. Results
|
|
2271
|
+
are ranked by exact canonical name, exact alias, prefix, then description token;
|
|
2272
|
+
kind/name breaks ties. Use `--kind model|field|relationship|metric` and
|
|
2273
|
+
`--limit <1-100>` (default `20`). It returns only canonical references, matched
|
|
2274
|
+
terms, aliases, descriptions, and necessary model paths—never SQL bodies,
|
|
2275
|
+
connection data, or blacklist names. No result is an empty array / text notice
|
|
2276
|
+
with exit 0.
|
|
2277
|
+
|
|
2278
|
+
`semantic draft validate --input <file|-> [--format text|json]` accepts only an
|
|
2279
|
+
explicit untrusted `QueryDraft` JSON document from a file or stdin. First give
|
|
2280
|
+
the external agent reviewed `dbcli semantic context --format json` output; its
|
|
2281
|
+
provider credentials, prompt, and other agent context remain outside dbcli. The
|
|
2282
|
+
agent returns a draft using only the declared models and fields, for example:
|
|
2283
|
+
|
|
2284
|
+
```json
|
|
2285
|
+
{
|
|
2286
|
+
"version": 1,
|
|
2287
|
+
"questionHash": "<sha256-of-the-original-question>",
|
|
2288
|
+
"candidate": { "kind": "sql", "sql": "<reviewed-read-only-sql>" },
|
|
2289
|
+
"semanticReferences": ["model:<model>", "field:<model>.<field>"]
|
|
2290
|
+
}
|
|
2291
|
+
```
|
|
2292
|
+
|
|
2293
|
+
The command validates the contract, read-only single-statement SQL, canonical
|
|
2294
|
+
semantic references, saved-query names, and local filtered schema/blacklist
|
|
2295
|
+
compatibility without connecting to a database, reading query results, storing
|
|
2296
|
+
the draft, or calling a provider. JSON reports contain only status, hashes,
|
|
2297
|
+
canonical references, and safe violation codes; they never echo candidate SQL
|
|
2298
|
+
or protected names. Exit `0` means valid, `1` means rejected, and `2` means
|
|
2299
|
+
required local semantic evidence is unavailable. A valid report is not execution
|
|
2300
|
+
authorization: review the original draft, then separately and explicitly invoke
|
|
2301
|
+
`dbcli explain "<reviewed-read-only-sql>"` or `dbcli query
|
|
2302
|
+
"<reviewed-read-only-sql>"` when appropriate.
|
|
2303
|
+
|
|
2304
|
+
When valid, `dbcli skill context` includes the same bounded data in its JSON,
|
|
2305
|
+
XML, and Markdown output. To run a metric, an agent must still invoke the named
|
|
2306
|
+
saved query through `dbcli q`; all ordinary permissions, blacklist masking,
|
|
2307
|
+
limits, audit, and recovery safeguards remain in force.
|
|
2308
|
+
|
|
2309
|
+
**Permission:** n/a (local files only; no database connection).
|
|
2310
|
+
|
|
2193
2311
|
### skill
|
|
2194
2312
|
|
|
2195
2313
|
Emit `SKILL.md` (and the companion `reference.md`) to stdout, a file, or an
|