@carllee1983/dbcli 1.30.0 → 1.32.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/CHANGELOG.md CHANGED
@@ -5,6 +5,38 @@ 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.32.0] - 2026-06-18 - Agent Task Packs Expansion & Skill Parity Guards
9
+
10
+ ### Added
11
+
12
+ - **4 個新的內建 Agent Task Pack(皆 `plan-only` 唯讀)。** `audit-permissions`(權限等級與 blacklist 覆蓋稽核)、`safe-backfill`(在寫入前做 blacklist + schema + 風險檢查的回填計畫)、`schema-drift-review`(快取/committed schema 與線上 schema 的漂移比對)、`connection-health`(連線可達性 / 設定 / 容量分級三步診斷)。皆走確定存在的唯讀指令;用 `dbcli skill tasks list` 瀏覽完整清單。
13
+ - **平台清單 parity 檢查(`scripts/check-platform-parity.ts`,`bun run platform:check`)。** 以 `SUPPORTED_PLATFORMS` 為單一真實來源,驗證 README、SKILL.md、SKILL.zh-TW.md、reference.md 與 CLI `--install` 選項描述的平台列舉完全一致(缺項或多項皆報錯),並掛進 `release-check.sh`。
14
+ - **語意 parity 守門。** `scripts/check-skill-parity.ts` 在結構比對外,新增 14 個語言不變的安全/命令 token(`query`/`insert`/`update`/`delete`/`export`/`schema`、`blacklist`、`--dry-run`/`--no-limit`/`--recovery`、`LIMIT 1000`、三個權限等級)在 EN 與 zh-TW 皆須對稱出現的檢查。
15
+ - **安裝與 context CLI 測試覆蓋。** 新增 `skill --install` 對 7 個平台寫入 temp HOME/cwd 的 smoke 測試(含 cursor/windsurf 的 root-rule + reference 雙檔結構),以及 `skill context` 的 xml/json/markdown、預設格式、無效格式與 blacklist 不外洩的 CLI 入口測試。
16
+
17
+ ### Fixed
18
+
19
+ - **`codex` / `windsurf` 安裝目標文件漂移。** 兩者已存在於 `SUPPORTED_PLATFORMS`(`--install` 實際可用),卻在 `SKILL.md` / `SKILL.zh-TW.md` 缺漏、`windsurf` 在 README 缺漏。已補齊並重新同步所有 plugin/skill 副本;新的 `platform:check` 會防止再次漂移。
20
+
21
+ ## [1.31.0] - 2026-06-10 - Data Editing Surface & Agent Plugin Packaging
22
+
23
+ ### Added
24
+
25
+ - **`@carllee1983/dbcli/core` 公開匯出 `DataExecutor` 與資料執行型別。** 在 `./core` barrel 開出資料編輯介面(insert/update/delete 執行面),讓外部消費者(如 `dbcli-gui` sidecar)能重用與 CLI 同源的資料寫入能力,不必重寫 adapter 邏輯。CLI 行為不變。
26
+ - **Agent plugin 打包與 marketplace 安裝。** 將 dbcli 打包為 agent plugin(Ponytail 風格 marketplace install),新增 GitHub Copilot CLI plugin 支援與 Cursor plugin 安裝(add-plugin metadata、marketplace 提交路徑),並依各 agent 拆分安裝指令與文件。
27
+ - **開發者工作流 skill 指引(en/zh-TW)。** 在 dbcli skill 新增「Developer workflows」段落,把資料庫影響隱含於開發任務時的最小安全路徑(DB-backed 功能、資料錯誤排查、ORM/migration、PR 審查、慢查詢、回填、環境驗證)寫入 SKILL en/zh-TW 與各平台副本,並以可執行的指令錨點取代不可執行的 migrate 範例。
28
+
29
+ ## [1.30.0] - 2026-06-09 - Connection Writer API
30
+
31
+ ### Added
32
+
33
+ - **`@carllee1983/dbcli/core` 新增連線寫入 API。** 在 `./core` barrel 公開純函式 mutation:`upsertConnection`、`removeConnection`(含預設連線重指派與 last-connection 防護)、`setDefaultConnection`、`migrateV1ToV2`(保留 legacy `.env.local` 密碼)、`writeConnectionSecret` + `envVarNameFor`(per-connection env 命名空間)。讓外部消費者(如 `dbcli-gui` sidecar)能程式化管理 `.dbcli` v2 連線,與 CLI 同源。CLI 行為不變。
34
+
35
+ ### Fixed
36
+
37
+ - **`writeV2Config` 改為 atomic temp+rename 寫入**,避免寫入中斷時破壞設定庫。
38
+ - **`migrateV1ToV2` 對非 SQL 的 v1 連線 fail-loud 拒絕**,防止把不相容連線寫進 v2 設定庫。
39
+
8
40
  ## [1.29.0] - 2026-06-08 - Core Config-Read Entrypoint
9
41
 
10
42
  ### Added
package/README.md CHANGED
@@ -634,6 +634,8 @@ dbcli skill --install gemini # Install to Gemini CLI (being phased out)
634
634
  dbcli skill --install antigravity # Install to Antigravity CLI (Gemini CLI's successor)
635
635
  dbcli skill --install copilot # Install to GitHub Copilot
636
636
  dbcli skill --install cursor # Install to Cursor IDE
637
+ dbcli skill --install codex # Install to Codex skills
638
+ dbcli skill --install windsurf # Install to Windsurf (.windsurfrules)
637
639
  ```
638
640
 
639
641
  **Behavior:**
@@ -657,7 +659,8 @@ dbcli skill --install claude && \
657
659
  dbcli skill --install gemini && \
658
660
  dbcli skill --install antigravity && \
659
661
  dbcli skill --install copilot && \
660
- dbcli skill --install cursor
662
+ dbcli skill --install cursor && \
663
+ dbcli skill --install codex
661
664
  ```
662
665
 
663
666
  ---
@@ -1231,8 +1234,20 @@ dbcli skill --install gemini
1231
1234
  # GitHub Copilot CLI
1232
1235
  dbcli skill --install copilot
1233
1236
 
1237
+ # GitHub Copilot CLI plugin marketplace
1238
+ # copilot plugin marketplace add CarlLee1983/dbcli
1239
+ # copilot plugin install dbcli-agent@dbcli-agent
1240
+
1234
1241
  # Cursor IDE (AI-native editor)
1235
1242
  dbcli skill --install cursor
1243
+
1244
+ # Cursor plugin marketplace
1245
+ # /add-plugin dbcli-agent
1246
+
1247
+ # Codex plugin marketplace
1248
+ # codex plugin marketplace add CarlLee1983/dbcli
1249
+ # Then open /plugins and install dbcli-agent.
1250
+ # Full install guide: plugins/dbcli-agent/INSTALL.md
1236
1251
  ```
1237
1252
 
1238
1253
  After installation, the AI agent will have access to dbcli commands and can use them to query, insert, update, or export data based on your permission level.
@@ -1285,6 +1300,22 @@ After installation, the AI agent will have access to dbcli commands and can use
1285
1300
 
1286
1301
  **Skill location:** `.cursor/rules/dbcli.mdc` (summary + workflows) and `.cursor/skills/dbcli/reference.md` (full command flags and examples) under the **current working directory** when you run `dbcli skill --install cursor`.
1287
1302
 
1303
+ **Cursor plugin install:** in Cursor Agent chat, run `/add-plugin dbcli-agent`, or see `plugins/dbcli-agent/INSTALL.md#cursor` for marketplace and fallback options.
1304
+
1305
+ ---
1306
+
1307
+ #### Codex
1308
+
1309
+ 1. Add the marketplace: `codex plugin marketplace add CarlLee1983/dbcli`.
1310
+ 2. Open `/plugins`, select the dbcli Agent marketplace, and install `dbcli-agent`.
1311
+ 3. For a persistent CLI, install dbcli globally: `bun install -g @carllee1983/dbcli` or `npm install -g @carllee1983/dbcli`.
1312
+ 4. Without a global install, the plugin skill uses `bunx @carllee1983/dbcli <command>` as its fallback.
1313
+ 5. Initialize: `dbcli init` or `bunx @carllee1983/dbcli init`.
1314
+
1315
+ **Plugin skill location:** `skills/dbcli/` (SKILL.md + reference.md).
1316
+
1317
+ **Install guide:** `plugins/dbcli-agent/INSTALL.md`.
1318
+
1288
1319
  ---
1289
1320
 
1290
1321
  ### Example: AI Agent Workflow
package/README.zh-TW.md CHANGED
@@ -532,6 +532,7 @@ dbcli skill --install gemini # 安裝至 Gemini CLI(即將淘汰)
532
532
  dbcli skill --install antigravity # 安裝至 Antigravity CLI(Gemini CLI 後繼者)
533
533
  dbcli skill --install copilot # 安裝至 GitHub Copilot
534
534
  dbcli skill --install cursor # 安裝至 Cursor IDE
535
+ dbcli skill --install codex # 安裝至 Codex skills
535
536
  ```
536
537
 
537
538
  **行為:**
@@ -555,7 +556,8 @@ dbcli skill --install claude && \
555
556
  dbcli skill --install gemini && \
556
557
  dbcli skill --install antigravity && \
557
558
  dbcli skill --install copilot && \
558
- dbcli skill --install cursor
559
+ dbcli skill --install cursor && \
560
+ dbcli skill --install codex
559
561
  ```
560
562
 
561
563
  ---
@@ -1127,8 +1129,20 @@ dbcli skill --install gemini
1127
1129
  # GitHub Copilot CLI
1128
1130
  dbcli skill --install copilot
1129
1131
 
1132
+ # GitHub Copilot CLI plugin marketplace
1133
+ # copilot plugin marketplace add CarlLee1983/dbcli
1134
+ # copilot plugin install dbcli-agent@dbcli-agent
1135
+
1130
1136
  # Cursor IDE
1131
1137
  dbcli skill --install cursor
1138
+
1139
+ # Cursor plugin marketplace
1140
+ # /add-plugin dbcli-agent
1141
+
1142
+ # Codex plugin marketplace
1143
+ # codex plugin marketplace add CarlLee1983/dbcli
1144
+ # 接著開啟 /plugins 並安裝 dbcli-agent。
1145
+ # 完整安裝說明:plugins/dbcli-agent/INSTALL.md
1132
1146
  ```
1133
1147
 
1134
1148
  安裝後,AI 可依你的權限等級使用 dbcli 查詢、插入、更新或匯出資料。
@@ -1181,6 +1195,22 @@ dbcli skill --install cursor
1181
1195
 
1182
1196
  **Skill 路徑:** 在**目前工作目錄**執行 `dbcli skill --install cursor` 時,寫入 **`.cursor/rules/dbcli.mdc`**(摘要與工作流程)及 **`.cursor/skills/dbcli/reference.md`**(完整旗標與範例)。
1183
1197
 
1198
+ **Cursor plugin 安裝:** 在 Cursor Agent chat 執行 `/add-plugin dbcli-agent`,或參考 `plugins/dbcli-agent/INSTALL.md#cursor` 的 marketplace 與 fallback 說明。
1199
+
1200
+ ---
1201
+
1202
+ #### Codex
1203
+
1204
+ 1. 加入 marketplace:`codex plugin marketplace add CarlLee1983/dbcli`。
1205
+ 2. 開啟 `/plugins`,選擇 dbcli Agent marketplace,並安裝 `dbcli-agent`。
1206
+ 3. 若要常駐 CLI,請全域安裝 dbcli:`bun install -g @carllee1983/dbcli` 或 `npm install -g @carllee1983/dbcli`。
1207
+ 4. 若未全域安裝,plugin 內的 skill 會以 `bunx @carllee1983/dbcli <command>` 作為 fallback。
1208
+ 5. 初始化:`dbcli init` 或 `bunx @carllee1983/dbcli init`。
1209
+
1210
+ **Plugin skill 路徑:** `skills/dbcli/`(`SKILL.md` + `reference.md`)。
1211
+
1212
+ **安裝說明:** `plugins/dbcli-agent/INSTALL.md`。
1213
+
1184
1214
  ---
1185
1215
 
1186
1216
  ### 範例:AI 代理工作流程
package/assets/SKILL.md CHANGED
@@ -7,6 +7,11 @@ description: Database CLI for AI agents with permission-based access control. Us
7
7
 
8
8
  Database CLI for AI agents with permission-based access control.
9
9
 
10
+ If the `dbcli` executable is not available in `PATH`, use
11
+ `bunx @carllee1983/dbcli <command>` as the command prefix. This is the expected
12
+ fallback for Codex plugin installs where the skill is installed by the plugin but
13
+ the CLI package has not been installed globally.
14
+
10
15
  ## AI agent workflow (follow in order)
11
16
 
12
17
  0. `dbcli skill context --format xml` — LLM prompt context payload: serializes connection metadata, schema caches, and saved queries into a compressed XML/JSON structure for prompt injection.
@@ -74,11 +79,64 @@ Builtin packs: `diagnose-slow-query` and **(v1.23)** `analyze-table-perf` — a
74
79
  read-only `plan-only` pack taking a required `table` parameter that walks
75
80
  `blacklist list` → `schema <table> --format json` → `guide index-usage`. `dbcli
76
81
  inspect` suggests `analyze-table-perf` automatically for the hottest table in
77
- recent audit activity.
82
+ recent audit activity. Additional read-only packs: `audit-permissions`,
83
+ `safe-backfill`, `schema-drift-review`, `connection-health` — run
84
+ `dbcli skill tasks list` for the full set.
78
85
 
79
86
  Tasks live under `assets/tasks/` (builtin), `.dbcli-shared/tasks/` (shared), and
80
87
  `.dbcli/tasks/` (local override).
81
88
 
89
+ ## Developer workflows
90
+
91
+ Use these workflows when database impact is implicit in a development task. Keep
92
+ the normal dbcli safety rules: prefer `--format json`, run `blacklist list`
93
+ before touching sensitive data, confirm names with `schema`, dry-run writes, and
94
+ use `--recovery` / `recover` after failures.
95
+
96
+ | Situation | Use dbcli for | Minimum safe path |
97
+ | --- | --- | --- |
98
+ | DB-backed feature | Map product/code terms to real objects before editing code. | `inspect --for-agent` -> `blacklist list` -> `schema <object>` -> `queries suggest <intent>` |
99
+ | Application data bug | Separate stored facts from application-code inference. | `inspect --for-agent` -> `audit tail --for-agent --n 10` -> `blacklist list` -> `schema <object>` -> narrow query/snippet |
100
+ | ORM or migration work | Ground model and migration edits in live schema evidence. | `schema --format json` -> `diff --snapshot <name>` -> generate DDL via `migrate add-index`/`add-column` (preview SQL) -> `diff --against <snapshot>` |
101
+ | PR database review | Check query, write, migration, export, fixture, and blacklist risk. | Review changed persistence paths, then propose concrete `schema`, `plan`, `dry-run`, `report`, or `guide` commands for each material claim. |
102
+ | Slow endpoint or query | Prefer read-only diagnostics before index proposals. | `report --section perf` -> task pack `analyze-table-perf` -> `guide missing-index-for "<query>"`; use `proxy analyze` when logs exist. |
103
+ | Safe data backfill | Scope affected rows and preview mutations before execution. | `blacklist list` -> `schema <object>` -> count/scope query -> `update ... --dry-run` -> read-back or snippet `--verify`. |
104
+ | Environment validation | Check config shape and connectivity without leaking secrets. | `status --format json` -> `doctor --format json` -> `inspect --for-agent --no-connect --format json`. |
105
+
106
+ Copy-paste command anchors:
107
+
108
+ ```bash
109
+ dbcli inspect --for-agent --format json
110
+ dbcli blacklist list --format json
111
+ dbcli schema <object> --format json
112
+ dbcli queries suggest <intent> --format json
113
+ dbcli audit tail --for-agent --n 10
114
+ dbcli schema --format json
115
+ dbcli diff --snapshot <name>
116
+ dbcli migrate add-index <table>
117
+ dbcli diff --against <snapshot>
118
+ dbcli report --section perf --format json
119
+ dbcli skill tasks plan analyze-table-perf --param table=<table> --format json
120
+ dbcli guide missing-index-for "<query>" --format json
121
+ dbcli proxy analyze --format json
122
+ dbcli query "<count/scope query>" --format json
123
+ dbcli update <object> --where "<bounded predicate>" --set '<json>' --dry-run --format json
124
+ dbcli status --format json
125
+ dbcli doctor --format json
126
+ dbcli inspect --for-agent --no-connect --format json
127
+ ```
128
+
129
+ Developer workflow guardrails:
130
+
131
+ - Never invent table, collection, key, index, or field names. Confirm them with
132
+ `schema` before writing code that depends on them.
133
+ - Separate database facts from application-code inference. Report which dbcli
134
+ output shaped the code or review conclusion.
135
+ - For writes and backfills, include scope count, dry-run preview, execution
136
+ command, and read-back or snippet verification.
137
+ - Do not create indexes directly from a performance suggestion; turn them into reviewed migrations.
138
+ - Do not print credentials, copied connection strings, or blacklisted values.
139
+
82
140
  Full flags, per-command copy-paste blocks, `migrate` DDL, interactive `shell`, and MongoDB/Redis/ES walkthroughs are in [reference.md](reference.md) (installed next to this file).
83
141
 
84
142
  ## Audit Log usage
@@ -263,7 +321,7 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
263
321
  | `completion` | n/a | bash / zsh / fish scripts. |
264
322
  | `upgrade` | n/a | Self-update from npm; 24h-cached version hints on every command. |
265
323
  | `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). |
266
- | `skill` | n/a | Generate / install AI skill docs (`--install <claude\|gemini\|antigravity\|copilot\|cursor>`); `skill tasks list/show/plan` for Agent Task Packs; `skill context` for LLM prompt context payload. |
324
+ | `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 LLM prompt context payload. |
267
325
  | `migrate` | admin | SQL only. **DDL; dry-run by default** — needs `--execute`. |
268
326
 
269
327
  `--use <name>` on any subcommand targets a v2 connection without changing the default.
@@ -68,8 +68,57 @@ dbcli skill tasks plan <task> --param key=value --format json # 產生計畫
68
68
 
69
69
  計畫輸出是一組附帶說明與風險標籤的 dbcli 指令序列。請逐一執行 — 任務計畫**不會**繞過 blacklist、schema、dry-run 或確認等要求。
70
70
 
71
+ 內建套件:`diagnose-slow-query` 與 **(v1.23)** `analyze-table-perf` — 後者是 read-only 的 `plan-only` 套件,需帶入必填的 `table` 參數,依序執行 `blacklist list` → `schema <table> --format json` → `guide index-usage`。`dbcli inspect` 會針對近期 audit 活動中最熱門的資料表自動建議 `analyze-table-perf`。其他唯讀套件:`audit-permissions`、`safe-backfill`、`schema-drift-review`、`connection-health` — 用 `dbcli skill tasks list` 瀏覽完整清單。
72
+
71
73
  任務檔放在 `assets/tasks/`(內建)、`.dbcli-shared/tasks/`(共享)與 `.dbcli/tasks/`(本地覆寫)。
72
74
 
75
+ ## 開發者工作流
76
+
77
+ 當資料庫影響隱含在開發任務中時使用這些流程。保留一般 dbcli 安全規則:優先使用 `--format json`,碰觸敏感資料前先跑 `blacklist list`,用 `schema` 確認名稱,寫入先 dry-run,失敗後使用 `--recovery` / `recover`。
78
+
79
+ | 情境 | 使用 dbcli 的目的 | 最小安全路徑 |
80
+ | --- | --- | --- |
81
+ | DB-backed 功能 | 編輯程式碼前先把產品/程式語彙對應到真實資料物件。 | `inspect --for-agent` -> `blacklist list` -> `schema <object>` -> `queries suggest <intent>` |
82
+ | 應用程式資料錯誤 | 分離資料庫事實與應用程式推論。 | `inspect --for-agent` -> `audit tail --for-agent --n 10` -> `blacklist list` -> `schema <object>` -> 最小查詢/snippet |
83
+ | ORM 或 migration | 用 live schema 證據支撐 model 與 migration 修改。 | `schema --format json` -> `diff --snapshot <name>` -> 用 `migrate add-index`/`add-column` 產生 DDL(預覽 SQL)-> `diff --against <snapshot>` |
84
+ | PR 資料庫風險審查 | 檢查 query、write、migration、export、fixture 與 blacklist 風險。 | 審查變更的 persistence path,並針對每個重要主張提出具體 `schema`、`plan`、`dry-run`、`report` 或 `guide` 指令。 |
85
+ | 慢 endpoint 或查詢 | 在提出 index 前優先使用 read-only diagnostics。 | `report --section perf` -> task pack `analyze-table-perf` -> `guide missing-index-for "<query>"`;有 proxy log 時使用 `proxy analyze`。 |
86
+ | 安全資料回填 | 先界定受影響資料範圍並預覽 mutation。 | `blacklist list` -> `schema <object>` -> count/scope query -> `update ... --dry-run` -> read-back 或 snippet `--verify`。 |
87
+ | 環境設定驗證 | 不洩漏 secrets 地檢查 config shape 與 connectivity。 | `status --format json` -> `doctor --format json` -> `inspect --for-agent --no-connect --format json`。 |
88
+
89
+ 可直接複製的指令錨點:
90
+
91
+ ```bash
92
+ dbcli inspect --for-agent --format json
93
+ dbcli blacklist list --format json
94
+ dbcli schema <object> --format json
95
+ dbcli queries suggest <intent> --format json
96
+ dbcli audit tail --for-agent --n 10
97
+ dbcli schema --format json
98
+ dbcli diff --snapshot <name>
99
+ dbcli migrate add-index <table>
100
+ dbcli diff --against <snapshot>
101
+ dbcli report --section perf --format json
102
+ dbcli skill tasks plan analyze-table-perf --param table=<table> --format json
103
+ dbcli guide missing-index-for "<query>" --format json
104
+ dbcli proxy analyze --format json
105
+ dbcli query "<count/scope query>" --format json
106
+ dbcli update <object> --where "<bounded predicate>" --set '<json>' --dry-run --format json
107
+ dbcli status --format json
108
+ dbcli doctor --format json
109
+ dbcli inspect --for-agent --no-connect --format json
110
+ ```
111
+
112
+ 開發者工作流守門規則:
113
+
114
+ - 不要猜測 table、collection、key、index 或 field 名稱。先用 `schema` 確認,再編寫依賴這些名稱的程式碼。
115
+ - 分離資料庫事實與應用程式推論。回報是哪個 dbcli 輸出影響了程式修改或 review 結論。
116
+ - 寫入與 backfill 必須包含 scope count、dry-run preview、execution command,以及 read-back 或 snippet verification。
117
+ - 不要直接從 performance suggestion 建 index;應轉成經過 review 的 migration。
118
+ - 不要列印 credentials、複製的連線字串或 blacklisted 值。
119
+
120
+ 完整旗標、每個指令的可貼上範例、`migrate` DDL、互動式 `shell` 與 MongoDB / Redis / ES 教學在 [reference.md](reference.md)(安裝時與本檔放在一起)。
121
+
73
122
  ## Audit Log 使用
74
123
 
75
124
  當需要跨 session 或事後 forensics 重建工具歷史時,請優先使用 audit log,而非從零開始查詢 DB 狀態。
@@ -97,8 +146,6 @@ dbcli audit show --recovery-ref <envelope-id> # 反向找出觸發 envelope 的
97
146
 
98
147
  詳細指令參考:[`reference.md`](./reference.md) §audit(英文)。完整 agent 復原 walkthrough(各錯誤碼 end-to-end 情境、`--next` 多輪逐步、envelope ⇄ audit pivot、risk gate cheat sheet)見 [`reference.md`](./reference.md) §Recovery Cookbook(英文)。
99
148
 
100
- 完整旗標、每個指令的可貼上範例、`migrate` DDL、互動式 `shell` 與 MongoDB / Redis / ES 教學在 [reference.md](reference.md)(安裝時與本檔放在一起)。
101
-
102
149
  ## 快速開始
103
150
 
104
151
  ```bash
@@ -200,6 +247,7 @@ dbcli init --use-env-refs \
200
247
  | `list` | query-only+ | 資料表(SQL)、collections(MongoDB)、keys(Redis)或 indices(Elasticsearch)。 |
201
248
  | `schema` | query-only+ | SQL:單表或全掃描存入 `.dbcli/schemas/`。MongoDB:sampled。ES:flattened mapping。Redis:僅單一 key(type / TTL / size)。支援 `--recovery`。 |
202
249
  | `query` | query-only+ | SQL、Mongo JSON(`--collection`)、Redis 指令、ES DSL / Lucene(`--collection`)。`--format table\|json\|csv\|html`、`--ui` 開啟瀏覽器互動式 dashboard。支援 `--recovery`。 |
250
+ | `explain` | query-only+ | **(v1.23)** 唯讀查詢計畫並附註解。僅 SQL。單一查詢、`@saved-query`、`@file.sql` 或 `--bulk @glob/*`。`--analyze`(EXPLAIN ANALYZE / MariaDB ANALYZE SELECT)、`--format markdown\|json\|table`。 |
203
251
  | `plan` | n/a | 靜態 SQL 風險分析器(`--format text\|json`);不連線即可分類語句。 |
204
252
  | `q` | query-only+ | 以 `@name` 執行已儲存 snippet,搭配 `--param k=v`。支援 `--verify` 以執行斷言。 |
205
253
  | `queries` | n/a | 管理已儲存 snippet:`list` / `show` / `search` / `suggest` / `new` / `edit` / `check` / `delete` / `rename` / `copy` / `import` / `export`。 |
@@ -222,7 +270,7 @@ dbcli init --use-env-refs \
222
270
  | `completion` | n/a | bash / zsh / fish 腳本。 |
223
271
  | `upgrade` | n/a | 從 npm 自我更新;每個指令都帶 24h 快取的版本提示。 |
224
272
  | `shell` | (與 query 同) | 互動式 REPL。支援 SQL 引擎、MongoDB 與 Redis(單行;`.no-limit on/off`)。 |
225
- | `skill` | n/a | 產出 / 安裝 AI skill 文件(`--install <claude\|gemini\|antigravity\|copilot\|cursor>`);`skill tasks list/show/plan` 提供 Agent Task Packs;`skill context` 提供 LLM 提示詞脈絡載荷。 |
273
+ | `skill` | n/a | 產出 / 安裝 AI skill 文件(`--install <claude\|gemini\|antigravity\|copilot\|cursor\|codex\|windsurf>`);`skill tasks list/show/plan` 提供 Agent Task Packs;`skill context` 提供 LLM 提示詞脈絡載荷。 |
226
274
  | `migrate` | admin | 僅 SQL。**DDL;預設 dry-run** — 需 `--execute` 才會真的執行。 |
227
275
 
228
276
  任何子指令上的 `--use <name>` 都會把目標切到對應的 v2 連線,但不改變預設值。
@@ -1238,6 +1238,7 @@ dbcli skill --install gemini # install to ~/.gemini/skills/dbcli
1238
1238
  dbcli skill --install antigravity # install to ~/.gemini/antigravity-cli/skills/dbcli/
1239
1239
  dbcli skill --install copilot # install to .github/skills/dbcli/ (repo-local)
1240
1240
  dbcli skill --install cursor # install to .cursor/skills/dbcli/ (repo-local)
1241
+ dbcli skill --install codex # install to ~/.codex/skills/dbcli/
1241
1242
  ```
1242
1243
 
1243
1244
  **Options:**
@@ -1247,6 +1248,9 @@ dbcli skill --install cursor # install to .cursor/skills/dbcli/
1247
1248
  **Notes:**
1248
1249
  - 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.
1249
1250
  - `claude` / `gemini` / `antigravity` install paths are user-global; `copilot` / `cursor` are repo-local under `.github/` / `.cursor/`.
1251
+ - Cursor can install through `/add-plugin dbcli-agent` when available in Cursor's plugin marketplace; this repo includes `.cursor-plugin/plugin.json`. Instruction-file fallback options remain documented in `plugins/dbcli-agent/INSTALL.md#cursor`.
1252
+ - Codex can consume the repo through the Ponytail-style marketplace layout at `.agents/plugins/marketplace.json` and `.codex-plugin/plugin.json`; plugin installs provide the skill from `skills/dbcli/`, and the skill falls back to `bunx @carllee1983/dbcli` when `dbcli` is not on `PATH`.
1253
+ - Agent plugin installation details live in `plugins/dbcli-agent/INSTALL.md`, including Codex, Claude Code, GitHub Copilot CLI, Antigravity (`agy`), and Cursor targets.
1250
1254
  - `gemini` (Gemini CLI) is retained for now but is being phased out in favour of `antigravity` (Antigravity CLI), Google's successor terminal agent.
1251
1255
  - Re-running `--install` overwrites the existing skill atomically; no prompt.
1252
1256
 
@@ -1272,7 +1276,11 @@ dbcli skill tasks plan diagnose-slow-query --param query="..." --format json
1272
1276
  a read-only (`plan-only`) pack taking a required `table` parameter that walks
1273
1277
  `blacklist list` → `schema <table> --format json` → `guide index-usage --format json`.
1274
1278
  `dbcli inspect` suggests `analyze-table-perf` automatically for the hottest table
1275
- in recent audit activity.
1279
+ in recent audit activity. Additional read-only packs ship for common agent
1280
+ workflows: `audit-permissions` (permission/blacklist audit), `safe-backfill`
1281
+ (plan a write with blacklist+schema+risk checks), `schema-drift-review` (cached
1282
+ vs live schema diff), and `connection-health` (reachability/config/capacity
1283
+ triage). Run `dbcli skill tasks list` for the full set.
1276
1284
 
1277
1285
  ```bash
1278
1286
  dbcli skill tasks plan analyze-table-perf --param table=betting_logs --format json
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: audit-permissions
3
+ description: Audit the active permission tier and blacklist coverage before granting an agent write access.
4
+ tags: [security, permissions, readonly]
5
+ engines: [postgres, mysql]
6
+ params:
7
+ table:
8
+ type: string
9
+ required: false
10
+ description: Optional table to spot-check column-level blacklist coverage (exact name; confirm via `dbcli list`).
11
+ safety:
12
+ mode: plan-only
13
+ requires:
14
+ - blacklist-list
15
+ steps:
16
+ - type: command
17
+ command: status
18
+ reason: Read the current permission tier and connection summary (no credentials).
19
+ risk: readonly
20
+ - type: command
21
+ command: blacklist list
22
+ reason: Enumerate every protected table and column so sensitive data is accounted for.
23
+ risk: readonly
24
+ - type: command
25
+ command: guide permissions --format json
26
+ reason: Get the deterministic next-step plan for reviewing what the current tier allows.
27
+ risk: readonly
28
+ ---
29
+ # Agent Notes
30
+
31
+ Use this task before widening an agent's access (e.g. query-only → read-write) or
32
+ when a user asks "what can this connection touch?". Confirm the permission tier is
33
+ the minimum required and that every sensitive table/column already appears in the
34
+ blacklist. Do not run write operations. If a `table` is supplied, follow up with
35
+ `dbcli schema {{table}} --format json` to verify no sensitive column is exposed.
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: connection-health
3
+ description: Quick read-only health check of the active connection (reachability, config, capacity signals).
4
+ tags: [diagnostics, health, readonly]
5
+ engines: [postgres, mysql]
6
+ params:
7
+ section:
8
+ type: string
9
+ required: false
10
+ default: health
11
+ description: Which report section to pull.
12
+ enum: [health, capacity, perf]
13
+ safety:
14
+ mode: plan-only
15
+ requires:
16
+ - blacklist-list
17
+ steps:
18
+ - type: command
19
+ command: status
20
+ reason: Confirm the connection and permission tier resolve without exposing credentials.
21
+ risk: readonly
22
+ - type: command
23
+ command: doctor
24
+ reason: Run environment, config, connection and schema-cache diagnostics.
25
+ risk: readonly
26
+ - type: command
27
+ command: report --section {{section}} --for-agent
28
+ reason: Pull the diagnostic report section for a structured health snapshot.
29
+ risk: readonly
30
+ ---
31
+ # Agent Notes
32
+
33
+ Use this task as a first-touch triage when a connection "feels" wrong or before a
34
+ larger operation — it answers "can I reach the DB, is the config sane, and are there
35
+ obvious health/capacity red flags?" entirely read-only. If `doctor` reports a stale
36
+ schema cache, refresh it before trusting cached schema. Escalate to
37
+ `dbcli guide capacity` or `dbcli report --section perf` for deeper analysis.
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: safe-backfill
3
+ description: Plan a safe data backfill/UPDATE with blacklist, schema and risk checks before any write.
4
+ tags: [data, write, safety]
5
+ engines: [postgres, mysql]
6
+ params:
7
+ table:
8
+ type: string
9
+ required: true
10
+ description: The table the backfill writes to (exact name; confirm via `dbcli list`).
11
+ query:
12
+ type: string
13
+ required: true
14
+ description: The backfill UPDATE statement to analyze (not executed by this task).
15
+ safety:
16
+ mode: plan-only
17
+ requires:
18
+ - blacklist-list
19
+ - schema-check
20
+ steps:
21
+ - type: command
22
+ command: blacklist list
23
+ reason: Confirm the target table and its columns are not protected before planning a write.
24
+ risk: readonly
25
+ - type: command
26
+ command: schema {{table}} --format json
27
+ reason: Verify the exact column names and types the backfill will touch.
28
+ risk: readonly
29
+ - type: command
30
+ command: plan "{{query}}"
31
+ reason: Analyze the UPDATE's risk and scope without executing it.
32
+ risk: readonly
33
+ ---
34
+ # Agent Notes
35
+
36
+ Use this task when a user wants to backfill or correct existing rows. This task only
37
+ PLANS — it never writes. After reviewing the plan, run the real backfill manually in
38
+ two steps: first `dbcli update ... --dry-run` (or `dbcli query "<sql>" --dry-run`) to
39
+ preview the generated SQL, then re-run with `--execute` only once the dry-run looks
40
+ correct. Prefer a narrow `WHERE` clause and verify the affected row count with a
41
+ read-only `SELECT count(*)` before writing. Requires read-write (or higher) permission
42
+ to actually execute.
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: schema-drift-review
3
+ description: Detect drift between the cached/committed schema and the live database for one table.
4
+ tags: [diagnostics, schema, readonly]
5
+ engines: [postgres, mysql]
6
+ params:
7
+ table:
8
+ type: string
9
+ required: true
10
+ description: The table to compare against its cached schema (exact name; confirm via `dbcli list`).
11
+ safety:
12
+ mode: plan-only
13
+ requires:
14
+ - blacklist-list
15
+ - schema-check
16
+ steps:
17
+ - type: command
18
+ command: blacklist list
19
+ reason: Confirm the table is inspectable and not protected before reading its schema.
20
+ risk: readonly
21
+ - type: command
22
+ command: doctor
23
+ reason: Report the schema-cache age so a stale cache can be ruled out as the cause of drift.
24
+ risk: readonly
25
+ - type: command
26
+ command: schema {{table}} --format json
27
+ reason: Pull the current live schema to diff against the cached/committed definition.
28
+ risk: readonly
29
+ ---
30
+ # Agent Notes
31
+
32
+ Use this task when a migration may have landed out of band, or a query fails on a
33
+ column that "should" exist. Compare the live `schema {{table}}` output against the
34
+ `schema` block committed in the `.dbcli` config (or the cached snapshot). If they
35
+ disagree, the cache is stale or the live DB drifted — surface the specific column
36
+ differences. Do not run write operations or DDL. Refresh the cache before acting on a
37
+ stale snapshot.
package/dist/cli.mjs CHANGED
@@ -81224,7 +81224,7 @@ var {
81224
81224
  // package.json
81225
81225
  var package_default = {
81226
81226
  name: "@carllee1983/dbcli",
81227
- version: "1.30.0",
81227
+ version: "1.32.0",
81228
81228
  description: "Database CLI for AI agents",
81229
81229
  type: "module",
81230
81230
  publishConfig: {
@@ -81268,6 +81268,15 @@ var package_default = {
81268
81268
  files: [
81269
81269
  "dist/",
81270
81270
  "assets/",
81271
+ "plugins/",
81272
+ "skills/",
81273
+ ".codex-plugin/",
81274
+ ".claude-plugin/",
81275
+ ".cursor-plugin/",
81276
+ ".agents/",
81277
+ ".cursor/",
81278
+ ".github/skills/",
81279
+ "gemini-extension.json",
81271
81280
  "README.md",
81272
81281
  "CHANGELOG.md",
81273
81282
  "LICENSE"
@@ -81277,15 +81286,19 @@ var package_default = {
81277
81286
  build: "bun run scripts/build.ts",
81278
81287
  prepublishOnly: "bun run build",
81279
81288
  "release:check": "bash scripts/release-check.sh",
81289
+ "plugin:sync": "bun run scripts/sync-plugin-assets.ts --write",
81290
+ "plugin:check": "bun run scripts/sync-plugin-assets.ts",
81280
81291
  test: "bun test",
81281
81292
  "test:unit": "bun test tests/unit tests/core",
81282
81293
  "test:integration": "bun test tests/integration",
81283
81294
  "test:docker": "docker compose -f docker-compose.test.yml up -d --wait && bun test tests/integration/adapters; docker compose -f docker-compose.test.yml down",
81284
81295
  "docs:check": "bun run scripts/check-user-docs.ts",
81296
+ "skill:check": "bun run scripts/check-skill-parity.ts",
81297
+ "platform:check": "bun run scripts/check-platform-parity.ts",
81285
81298
  typecheck: "tsc --noEmit --pretty false",
81286
81299
  "test:perf": "bun test ./tests/perf/*.bench.ts",
81287
- lint: "eslint src tests --ext .ts --max-warnings=0",
81288
- "lint:fix": "eslint src tests --ext .ts --fix --max-warnings=0",
81300
+ lint: "eslint src tests scripts --ext .ts --max-warnings=0",
81301
+ "lint:fix": "eslint src tests scripts --ext .ts --fix --max-warnings=0",
81289
81302
  format: 'prettier --write "src/**/*.ts" "tests/**/*.ts"'
81290
81303
  },
81291
81304
  dependencies: {
@@ -81306,7 +81319,7 @@ var package_default = {
81306
81319
  },
81307
81320
  devDependencies: {
81308
81321
  "@eslint/js": "^9.39.4",
81309
- "@happy-dom/global-registrator": "^20.9.0",
81322
+ "@happy-dom/global-registrator": "^20.10.6",
81310
81323
  "@inquirer/prompts": "^8.4.3",
81311
81324
  "@testing-library/react": "^16.3.2",
81312
81325
  "@types/bun": "latest",
@@ -81316,7 +81329,7 @@ var package_default = {
81316
81329
  autoprefixer: "^10.5.0",
81317
81330
  "dts-bundle-generator": "^9.5.1",
81318
81331
  eslint: "^10.4.0",
81319
- "happy-dom": "^20.9.0",
81332
+ "happy-dom": "^20.10.6",
81320
81333
  postcss: "^8.5.14",
81321
81334
  prettier: "^3.8.3",
81322
81335
  tailwindcss: "3.4.1",
@@ -89408,7 +89421,7 @@ function parseGoal(value) {
89408
89421
  }
89409
89422
  return normalized;
89410
89423
  }
89411
- var guideCommand = new Command().name("guide").description(t("guide.description")).argument("[goal]", `Guide goal ID; one of [${ALLOWED_GOALS.join(", ")}]`).option("--format <format>", "Output format: json (default) or markdown", "json").option("--brief", "Trim rationale/expects for compact output", false).option("--for-agent", "Shortcut for --format json --brief", false).option("--list", "List available guide goals and exit", false).option("--probe", "Refresh inspect context via live probe (default: cache-first)", false).option("--probe-timeout <ms>", "Inspect probe timeout for cheap version/object check (default 1500)", (v) => parseInt(v, 10), 1500).action(async (goal, options, command) => {
89424
+ var guideCommand = new Command().name("guide").enablePositionalOptions().description(t("guide.description")).argument("[goal]", `Guide goal ID; one of [${ALLOWED_GOALS.join(", ")}]`).option("--format <format>", "Output format: json (default) or markdown", "json").option("--brief", "Trim rationale/expects for compact output", false).option("--for-agent", "Shortcut for --format json --brief", false).option("--list", "List available guide goals and exit", false).option("--probe", "Refresh inspect context via live probe (default: cache-first)", false).option("--probe-timeout <ms>", "Inspect probe timeout for cheap version/object check (default 1500)", (v) => parseInt(v, 10), 1500).action(async (goal, options, command) => {
89412
89425
  let config;
89413
89426
  try {
89414
89427
  const forAgent = options.forAgent === true;