@carllee1983/dbcli 1.44.0 → 1.45.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 +30 -3
- package/.cursor/skills/dbcli/reference.md +100 -2
- package/.cursor-plugin/plugin.json +1 -1
- package/.github/skills/dbcli/SKILL.md +30 -3
- package/.github/skills/dbcli/reference.md +100 -2
- package/CHANGELOG.md +26 -0
- package/README.md +13 -0
- package/README.zh-TW.md +13 -0
- package/assets/SKILL.md +30 -3
- package/assets/SKILL.zh-TW.md +26 -3
- package/assets/reference.md +100 -2
- package/dist/agent-core.d.ts +7 -1
- package/dist/agent-core.mjs +29 -8
- package/dist/cli.mjs +2045 -11756
- package/dist/core.d.ts +48 -3
- package/dist/core.mjs +348 -89
- package/gemini-extension.json +1 -1
- package/package.json +2 -1
- package/plugins/dbcli-agent/.codex-plugin/plugin.json +1 -1
- package/plugins/dbcli-agent/skills/dbcli/SKILL.md +30 -3
- package/plugins/dbcli-agent/skills/dbcli/reference.md +100 -2
- package/skills/dbcli/SKILL.md +30 -3
- package/skills/dbcli/reference.md +100 -2
- package/.cursor/skills/dbcli/SKILL.md +0 -106
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: dbcli
|
|
3
|
-
description: Database CLI for AI agents with permission-based access control. Use to query, inspect schemas, insert/update/delete data, export results, and manage sensitive data blacklists. Supports MySQL, PostgreSQL, MariaDB, and MongoDB with multiple named connections per project and custom env files. For exhaustive flags and examples, read reference.md next to this skill. Trigger when working with databases, running SQL or MongoDB JSON queries, exploring table/collection structures, switching between database environments, or protecting sensitive columns/tables from AI access.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# dbcli
|
|
7
|
-
|
|
8
|
-
Database CLI for AI agents with permission-based access control.
|
|
9
|
-
|
|
10
|
-
## Quick start
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
dbcli init # Initialize .dbcli config (parses .env automatically)
|
|
14
|
-
dbcli schema # Scan all tables and save to .dbcli
|
|
15
|
-
dbcli query "SELECT * FROM users" # Execute SQL
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
**Full flags, per-command copy-paste blocks, `migrate` DDL, interactive `shell`, and MongoDB walkthroughs** live in [reference.md](reference.md) (sibling file in the npm `assets/` folder, or installed next to this skill for Claude / Gemini / Copilot; for Cursor, also under `.cursor/skills/dbcli/reference.md` after `dbcli skill --install cursor`).
|
|
19
|
-
|
|
20
|
-
## Command overview
|
|
21
|
-
|
|
22
|
-
| Command | Min permission | Summary |
|
|
23
|
-
|---------|-----------------|---------|
|
|
24
|
-
| `init` | n/a (setup) | Create `.dbcli` (v1 single or v2 multi-connection with `--conn-name` / `--env-file`). **Usually run by the human** — do not re-run to strip `{"$env"}` references. |
|
|
25
|
-
| `use` | n/a | Show/switch default named connection (v2 only). |
|
|
26
|
-
| `list` | query-only+ | Tables (SQL) or collections (MongoDB). |
|
|
27
|
-
| `schema` | query-only+ | Per-table or full scan into `.dbcli/schemas/`; use `--use` for the right connection cache. |
|
|
28
|
-
| `query` | query-only+ | SQL, or Mongo JSON filter / pipeline with `--collection`. |
|
|
29
|
-
| `insert` / `update` | read-write+ | JSON `--data` / `--set`, `--where` (update), `--dry-run` first. |
|
|
30
|
-
| `delete` | data-admin+ | `--where` required, `--dry-run` first. |
|
|
31
|
-
| `export` | query-only+ | Query to CSV/JSON file or stdout. |
|
|
32
|
-
| `blacklist` | n/a | `list` / `table` / `column` subcommands block sensitive data from query results. |
|
|
33
|
-
| `check` | query-only+ | Table health: nulls, duplicates, orphans, etc. |
|
|
34
|
-
| `diff` | query-only+ | Save/compare schema snapshots. |
|
|
35
|
-
| `status` | query-only+ | Safe JSON/text summary (no credentials). |
|
|
36
|
-
| `doctor` | n/a | Environment, config, connection, SRV/diagnostics (Mongo), schema cache age. |
|
|
37
|
-
| `completion` | n/a | bash / zsh / fish scripts. |
|
|
38
|
-
| `upgrade` | n/a | Self-update from npm; all commands can hint on new version (24h cache). |
|
|
39
|
-
| `shell` | (same as `query`+) | Interactive REPL. |
|
|
40
|
-
| `migrate` | admin | **DDL; dry-run by default** — needs `--execute`, DROP also needs `--force`. |
|
|
41
|
-
|
|
42
|
-
`--use <name>` on any subcommand targets a v2 connection without changing the default.
|
|
43
|
-
|
|
44
|
-
## Multi-connection and schema (v2)
|
|
45
|
-
|
|
46
|
-
- Named connections get isolated schema dirs: `.dbcli/schemas/<connection>/`. Run `dbcli schema --use <name>` before `schema <table>` for that environment.
|
|
47
|
-
- `schema --refresh` / `--reset` manage cache; see [reference.md](reference.md) for options.
|
|
48
|
-
|
|
49
|
-
## MongoDB (at a glance)
|
|
50
|
-
|
|
51
|
-
- JSON `find` object or `aggregate` array; **`--collection` required**; no SQL. Supported: `init`, `list`, `query`, `status`, `use`, `shell`, `doctor`, `upgrade`, `completion`. **Unsupported:** `schema`, `insert`, `update`, `delete`, `export`, `diff`, `migrate`, `check`.
|
|
52
|
-
- See [reference.md](reference.md) (MongoDB section) for query syntax and examples.
|
|
53
|
-
|
|
54
|
-
## Permission levels
|
|
55
|
-
|
|
56
|
-
| Level | Allowed |
|
|
57
|
-
|-------|---------|
|
|
58
|
-
| query-only | SELECT, list, schema, export |
|
|
59
|
-
| read-write | + INSERT, UPDATE |
|
|
60
|
-
| data-admin | + DELETE (DML, no DDL) |
|
|
61
|
-
| admin | + DDL via `migrate` and destructive ops |
|
|
62
|
-
|
|
63
|
-
## Global options
|
|
64
|
-
|
|
65
|
-
| Flag | Description |
|
|
66
|
-
|------|-------------|
|
|
67
|
-
| `--config` | Custom `.dbcli` path (default: `.dbcli`) |
|
|
68
|
-
| `--use` | Named connection (v2) |
|
|
69
|
-
| `-v` / `-vv` / `-q` | Verbose or quiet |
|
|
70
|
-
| `--no-color` | No ANSI (see also `NO_COLOR`) |
|
|
71
|
-
|
|
72
|
-
## AI agent workflow
|
|
73
|
-
|
|
74
|
-
**Before any database work:**
|
|
75
|
-
|
|
76
|
-
1. `dbcli status` — permissions and system (no secrets).
|
|
77
|
-
2. `dbcli blacklist list` — sensitive data boundaries.
|
|
78
|
-
3. `dbcli schema <table> --format json` — real column names.
|
|
79
|
-
4. Then `query` / DML / `export` within permission.
|
|
80
|
-
|
|
81
|
-
**Never guess column names** — use schema output.
|
|
82
|
-
|
|
83
|
-
## Workflows (short)
|
|
84
|
-
|
|
85
|
-
- **Debug odd state:** `schema` → `check` → `query` with a tight `WHERE` → follow FKs from schema JSON; confirm related rows. Prefer evidence over theory.
|
|
86
|
-
- **After INSERT/UPDATE:** `--dry-run` → run → `query` read-back; explain mismatches via triggers, defaults, or blacklist.
|
|
87
|
-
- **Migrations:** `diff --snapshot` → run migration → `diff --against` → `check` on affected tables. **Migrate:** use [reference.md](reference.md) for dry-run, `--execute`, and `--force` on DROP.
|
|
88
|
-
- **Health / growth:** `check --all` (large tables skipped unless `--include-large`); use schema `sizeCategory` before ad-hoc queries.
|
|
89
|
-
- **Codegen from live DB:** `dbcli schema --format json` to drive ORM; `check` before trusting data. Compare ORM result with `dbcli query` once.
|
|
90
|
-
- **Logic / integration truth:** `query` before → run app or API → `query` after; for multi-table updates, re-check all touched tables. Unit tests with mocks are not a substitute.
|
|
91
|
-
- **Natural language (“update order to shipped”):** infer `query` vs DML, map terms to columns via `schema` (and enums/values in data), respect blacklist and `sizeCategory`, **`--dry-run` on all writes** before commit.
|
|
92
|
-
|
|
93
|
-
## Notes
|
|
94
|
-
|
|
95
|
-
- Prefer `--format json` for agents.
|
|
96
|
-
- Query-only: auto-`LIMIT 1000` unless `--no-limit` (e.g. `information_schema` or statements that break with `LIMIT`).
|
|
97
|
-
- Blacklisted tables/columns are redacted in query results.
|
|
98
|
-
- `doctor` (Mongo SRV): reports SRV resolution vs DoH fallback when relevant.
|
|
99
|
-
|
|
100
|
-
## Data volume protection
|
|
101
|
-
|
|
102
|
-
`schema` includes `estimatedRowCount` and `sizeCategory` (small / medium / large / huge). See [reference.md](reference.md) for row-count bands and `huge`-table query rules. For large or huge tables, add `WHERE` or `LIMIT`.
|
|
103
|
-
|
|
104
|
-
## Full command reference
|
|
105
|
-
|
|
106
|
-
See [reference.md](reference.md) for all options, the `migrate` column spec, `shell` meta-commands, and one-block examples for every subcommand.
|