@carllee1983/dbcli 0.4.0-beta → 0.5.0-beta

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,31 @@ 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
+ ## [0.5.0-beta] - 2026-03-27
9
+
10
+ ### UX & Developer Experience — Colors, Logging, Diagnostics, and Tooling
11
+
12
+ ### Added
13
+
14
+ - **Color system** (`picocolors`): Semantic color helpers (`success`/`error`/`warn`/`info`/`dim`/`bold`) with automatic `NO_COLOR` support
15
+ - **SQL syntax highlighting**: Keywords (blue bold), strings (green), numbers (yellow) — applied in verbose mode and dry-run preview
16
+ - **Leveled logger**: Four levels — quiet (`-q`), normal (default), verbose (`-v`), debug (`-vv`) — all output to stderr to keep stdout clean for structured data
17
+ - **`--no-color` global flag**: Disable colored output; also respects `NO_COLOR` environment variable (<https://no-color.org/>)
18
+ - **`-v, --verbose` global flag**: Increase verbosity (`-v` = verbose, `-vv` = debug)
19
+ - **`-q, --quiet` global flag**: Suppress non-essential output
20
+ - **`dbcli doctor` command**: Full self-diagnostic — checks Bun version, dbcli version (npm registry), config validity, permission level, blacklist completeness (detects unprotected sensitive columns like `password`/`token`/`secret`), database connectivity, schema cache freshness, and large table warnings (> 1M rows). Supports `--format json` for AI agents. Exits with code 1 on errors.
21
+ - **`dbcli completion` command**: Shell auto-completion script generation for bash, zsh, and fish. `--install` flag auto-writes to the shell rc file using idempotent marker blocks.
22
+ - **`dbcli upgrade` command**: Self-update from npm registry. `--check` flag for check-only mode.
23
+ - **Background version check**: Every command silently checks the npm registry (at most once per 24 hours, cached in `.dbcli/version-check.json`). Shows a one-line hint to stderr after the command completes if a newer version is available. Suppressed by `--quiet`.
24
+ - **Table formatter colorization**: Table headers now display in bold
25
+ - **62 new tests**: colors (7), sql-highlight (6), logger (10), doctor (12), completion (8), upgrade/version-check (19)
26
+
27
+ ### Dependencies
28
+
29
+ - Added `picocolors` (~0.4 KB) as production dependency
30
+
31
+ ---
32
+
8
33
  ## [0.2.0-beta] - 2026-03-26
9
34
 
10
35
  ### Data Access Control — Blacklist System
package/README.md CHANGED
@@ -49,6 +49,10 @@ npx @carllee1983/dbcli query "SELECT * FROM users"
49
49
  #### Update
50
50
 
51
51
  ```bash
52
+ # Self-update (recommended)
53
+ dbcli upgrade
54
+
55
+ # Or via npm
52
56
  npm update -g @carllee1983/dbcli
53
57
  ```
54
58
 
@@ -438,6 +442,68 @@ DBCLI_OVERRIDE_BLACKLIST=true dbcli query "SELECT * FROM secrets_vault"
438
442
 
439
443
  ---
440
444
 
445
+ #### `dbcli doctor`
446
+
447
+ Run diagnostic checks on environment, configuration, connection, and data.
448
+
449
+ ```bash
450
+ dbcli doctor # Colored text output
451
+ dbcli doctor --format json # JSON output for AI agents
452
+ ```
453
+
454
+ **Checks:**
455
+ - **Environment:** Bun version compatibility, dbcli version (compares with npm registry)
456
+ - **Configuration:** Config file exists/valid, permission level, blacklist completeness
457
+ - **Connection & Data:** Database connectivity, schema cache freshness (> 7 days warning), large table warnings (> 1M rows)
458
+
459
+ **Options:** `--format <text|json>`
460
+ **Exit code:** 0 = all pass or warnings only, 1 = errors found
461
+
462
+ ---
463
+
464
+ #### `dbcli completion [shell]`
465
+
466
+ Generate shell completion scripts for tab auto-complete.
467
+
468
+ ```bash
469
+ dbcli completion bash # Output bash completion to stdout
470
+ dbcli completion zsh # Output zsh completion to stdout
471
+ dbcli completion fish # Output fish completion to stdout
472
+ dbcli completion --install # Auto-detect shell and install to rc file
473
+ dbcli completion --install zsh # Install for specific shell
474
+ ```
475
+
476
+ **Supported shells:** bash, zsh, fish
477
+
478
+ ---
479
+
480
+ #### `dbcli upgrade`
481
+
482
+ Check for updates and self-upgrade dbcli.
483
+
484
+ ```bash
485
+ dbcli upgrade # Check and upgrade if newer version available
486
+ dbcli upgrade --check # Only check, do not upgrade
487
+ ```
488
+
489
+ **Options:** `--check` — check only, don't install
490
+ **Background check:** dbcli silently checks npm registry once per 24 hours. If a newer version is found, a hint is shown after command output.
491
+
492
+ ---
493
+
494
+ ## Global Options
495
+
496
+ All commands support these global options:
497
+
498
+ | Flag | Description |
499
+ |------|-------------|
500
+ | `--config <path>` | Path to .dbcli config file (default: `.dbcli`) |
501
+ | `-v, --verbose` | Increase verbosity (`-v` verbose, `-vv` debug) |
502
+ | `-q, --quiet` | Suppress non-essential output |
503
+ | `--no-color` | Disable colored output (respects `NO_COLOR` env var) |
504
+
505
+ ---
506
+
441
507
  ## Permission Model
442
508
 
443
509
  dbcli implements a coarse-grained permission system with three levels. Permission level is set during `dbcli init` and stored in `.dbcli` config file. The blacklist system works alongside permissions to provide fine-grained protection for sensitive tables and columns (see [Data Access Control](#data-access-control)).
package/README.zh-TW.md CHANGED
@@ -29,11 +29,11 @@ npm install --save-dev @carllee1983/dbcli
29
29
  ### 更新
30
30
 
31
31
  ```bash
32
- # Bun
33
- bun update @carllee1983/dbcli
32
+ # 自動更新(推薦)
33
+ dbcli upgrade
34
34
 
35
- # npm
36
- npm update --save-dev @carllee1983/dbcli
35
+ # 或手動更新
36
+ bun update @carllee1983/dbcli
37
37
  ```
38
38
 
39
39
  ### 初始化
@@ -142,6 +142,12 @@ dbcli init
142
142
  - 支援跨平台 AI 代理使用(Claude Code、Gemini、Copilot CLI、Cursor、IDE)
143
143
  - 技能動態反映 dbcli 功能
144
144
 
145
+ ### 診斷與維護
146
+
147
+ - `dbcli doctor` — 執行環境、設定、連線與資料的全面診斷
148
+ - `dbcli upgrade` — 檢查更新並自動升級 dbcli
149
+ - `dbcli completion [shell]` — 產生 shell 自動補全腳本(bash、zsh、fish)
150
+
145
151
  ## 權限模型
146
152
 
147
153
  dbcli 使用三層粗粒度權限模型,並搭配黑名單系統提供敏感表和欄位的細粒度保護(見[資料存取控制](#資料存取控制)):
@@ -358,6 +364,62 @@ dbcli blacklist column remove users.ssn
358
364
  DBCLI_OVERRIDE_BLACKLIST=true dbcli query "SELECT * FROM secrets_vault"
359
365
  ```
360
366
 
367
+ #### `dbcli doctor`
368
+
369
+ 執行環境、設定、連線與資料的全面診斷。
370
+
371
+ ```bash
372
+ dbcli doctor # 彩色文字輸出
373
+ dbcli doctor --format json # JSON 輸出供 AI agent 使用
374
+ ```
375
+
376
+ **檢查項目:**
377
+ - **環境:** Bun 版本相容性、dbcli 版本(與 npm registry 比對)
378
+ - **設定:** 設定檔存在/合法、權限等級、blacklist 完整性
379
+ - **連線與資料:** 資料庫連線測試、schema cache 新鮮度(> 7 天警告)、大表警告(> 1M 列)
380
+
381
+ **選項:** `--format <text|json>`
382
+
383
+ ---
384
+
385
+ #### `dbcli completion [shell]`
386
+
387
+ 產生 shell 自動補全腳本。
388
+
389
+ ```bash
390
+ dbcli completion bash # 輸出 bash 補全腳本
391
+ dbcli completion zsh # 輸出 zsh 補全腳本
392
+ dbcli completion fish # 輸出 fish 補全腳本
393
+ dbcli completion --install # 自動偵測 shell 並安裝
394
+ dbcli completion --install zsh # 指定 shell 安裝
395
+ ```
396
+
397
+ **支援 shell:** bash、zsh、fish
398
+
399
+ ---
400
+
401
+ #### `dbcli upgrade`
402
+
403
+ 檢查更新並自動升級 dbcli。
404
+
405
+ ```bash
406
+ dbcli upgrade # 檢查並升級
407
+ dbcli upgrade --check # 僅檢查,不升級
408
+ ```
409
+
410
+ **背景檢查:** 每個指令靜默檢查 npm registry(每 24 小時一次),有新版時在指令完成後顯示提示。
411
+
412
+ ## 全域選項
413
+
414
+ 以下選項適用於所有指令:
415
+
416
+ | 選項 | 說明 |
417
+ |------|------|
418
+ | `--config <path>` | 指定 .dbcli 設定檔路徑(預設:`.dbcli`) |
419
+ | `-v, --verbose` | 增加輸出詳細度(`-v` 詳細、`-vv` 除錯) |
420
+ | `-q, --quiet` | 靜音模式,抑制非必要輸出 |
421
+ | `--no-color` | 關閉彩色輸出(支援 `NO_COLOR` 環境變數) |
422
+
361
423
  ## 環境配置
362
424
 
363
425
  ### .dbcli 配置檔案
package/assets/SKILL.md CHANGED
@@ -176,6 +176,50 @@ dbcli status --format text # Human-readable text output
176
176
  **Output:** `permission`, `system`, `blacklist` summary, `version`
177
177
  **Permission:** query-only+
178
178
 
179
+ ### doctor
180
+
181
+ Run diagnostic checks on environment, configuration, connection, and data.
182
+
183
+ ```bash
184
+ dbcli doctor # Colored text output
185
+ dbcli doctor --format json # JSON output for AI agents
186
+ ```
187
+
188
+ **Checks:**
189
+ - Environment: Bun version, dbcli version (compares with npm registry)
190
+ - Configuration: config file exists/valid, permission level, blacklist completeness (detects unprotected sensitive columns)
191
+ - Connection & Data: database connectivity, schema cache freshness (warns if > 7 days), large table warnings (> 1M rows)
192
+
193
+ **Exit code:** 0 if all pass or warnings only, 1 if any error
194
+ **Options:** `--format <text|json>`
195
+
196
+ ### completion
197
+
198
+ Generate shell completion scripts for tab auto-complete.
199
+
200
+ ```bash
201
+ dbcli completion bash # Output bash completion script
202
+ dbcli completion zsh # Output zsh completion script
203
+ dbcli completion fish # Output fish completion script
204
+ dbcli completion --install # Auto-detect shell and install
205
+ dbcli completion --install zsh # Install for specific shell
206
+ ```
207
+
208
+ **Supported shells:** bash, zsh, fish
209
+
210
+ ### upgrade
211
+
212
+ Check for updates and self-upgrade dbcli to the latest version from npm.
213
+
214
+ ```bash
215
+ dbcli upgrade # Check and upgrade if newer version available
216
+ dbcli upgrade --check # Only check, do not upgrade
217
+ ```
218
+
219
+ **Options:** `--check`
220
+
221
+ **Background check:** Every command silently checks the npm registry for a newer version (at most once per 24 hours, cached in `.dbcli/version-check.json`). If a newer version is found, a one-line hint is printed to stderr after the command completes. Pass `-q` / `--quiet` to suppress the hint.
222
+
179
223
  ## Permission Levels
180
224
 
181
225
  | Level | Allowed Operations |
@@ -189,7 +233,12 @@ Set via `dbcli init --permission <level>` or in `.dbcli` config.
189
233
 
190
234
  ## Global Options
191
235
 
192
- All commands support `--config <path>` to specify a custom config file (default: `.dbcli`).
236
+ | Flag | Description |
237
+ |------|-------------|
238
+ | `--config <path>` | Path to .dbcli config file (default: `.dbcli`) |
239
+ | `-v, --verbose` | Increase verbosity (`-v` verbose, `-vv` debug) |
240
+ | `-q, --quiet` | Suppress non-essential output |
241
+ | `--no-color` | Disable colored output (also respects `NO_COLOR` env var) |
193
242
 
194
243
  ## AI Agent Workflow
195
244