@carllee1983/dbcli 1.10.0 → 1.11.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 +32 -0
- package/assets/SKILL.md +8 -0
- package/assets/snippets/diag/blocking-queries.postgres.sql +17 -0
- package/assets/snippets/diag/cache-hit.mysql.sql +1 -0
- package/assets/snippets/diag/cache-hit.postgres.sql +1 -0
- package/assets/snippets/diag/client-list.redis.sql +8 -0
- package/assets/snippets/diag/cluster-info.redis.sql +8 -0
- package/assets/snippets/diag/connections.mysql.sql +1 -0
- package/assets/snippets/diag/connections.postgres.sql +1 -0
- package/assets/snippets/diag/db-size.mysql.sql +1 -0
- package/assets/snippets/diag/db-size.postgres.sql +1 -0
- package/assets/snippets/diag/es-cluster-health.elasticsearch.sql +1 -0
- package/assets/snippets/diag/hot-threads.elasticsearch.sql +9 -0
- package/assets/snippets/diag/index-stats.elasticsearch.sql +16 -0
- package/assets/snippets/diag/index-usage.mysql.sql +1 -0
- package/assets/snippets/diag/index-usage.postgres.sql +1 -0
- package/assets/snippets/diag/locks.mysql.sql +1 -0
- package/assets/snippets/diag/locks.postgres.sql +1 -0
- package/assets/snippets/diag/long-running.mysql.sql +1 -0
- package/assets/snippets/diag/long-running.postgres.sql +1 -0
- package/assets/snippets/diag/memory-usage.redis.sql +8 -0
- package/assets/snippets/diag/missing-indexes.mysql.sql +1 -0
- package/assets/snippets/diag/missing-indexes.postgres.sql +1 -0
- package/assets/snippets/diag/pending-tasks.elasticsearch.sql +9 -0
- package/assets/snippets/diag/redis-key-stats.redis.sql +1 -0
- package/assets/snippets/diag/slowlog.redis.sql +12 -0
- package/assets/snippets/diag/table-sizes.mysql.sql +1 -0
- package/assets/snippets/diag/table-sizes.postgres.sql +1 -0
- package/assets/snippets/diag/unassigned-shards.elasticsearch.sql +9 -0
- package/dist/cli.mjs +854 -303
- package/package.json +14 -16
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.11.0] - 2026-05-08
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `dbcli queries search <keywords>` — fuzzy keyword search across saved queries.
|
|
13
|
+
- `dbcli queries suggest <intent>` — intent-prefix suggestion.
|
|
14
|
+
- Optional `intent` frontmatter field on snippets.
|
|
15
|
+
- 9 new diagnostic snippets: ES x4 (hot-threads, index-stats, unassigned-shards, pending-tasks); Redis x4 (slowlog, client-list, memory-usage, cluster-info); SQL x1 (blocking-queries.postgres).
|
|
16
|
+
- "When you don't know which query to run" section in SKILL.md.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- All 18 existing built-in diagnostic snippets backfilled with `intent`.
|
|
21
|
+
- `foldVariants` extracted from `src/commands/queries.ts` to `src/core/saved-queries/fold.ts`.
|
|
22
|
+
- Redis read-only allowlist gained `CLIENT`, `INFO`, `CLUSTER`, `SLOWLOG` for diagnostic snippets.
|
|
23
|
+
|
|
24
|
+
## [1.10.1] - 2026-05-08
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **Packaged `dist/cli.mjs` 找不到 assets**:1.10.0 bundle 在 `task-paths.ts` / `snippet-paths.ts` 用 `import.meta.dir + ../../../` 解析 builtin 目錄,bundle 後三層往上會跳出 package root,npm 全域安裝的使用者執行 `dbcli queries list` / `dbcli skill tasks list` 讀不到資源。抽出 `src/utils/package-root.ts` 以 `package.json` 走訪定位 root,dev 與 bundle 都正確;`skill.ts` 內既有的 `findPackageRoot` 也收斂到同一處。
|
|
29
|
+
- **`dbcli q` 略過 blacklist 檢查(安全)**:`q.ts` 把空字串當作 `tableName` 傳給 `BlacklistValidator.filterColumns`,column-level redaction 永遠不命中;同時也沒呼叫 `checkTableBlacklist`,使用者可以透過 saved snippet 直接 SELECT 黑名單表/欄位繞開保護。改為從 `prepared.rewrittenSql` 抽出主表(SQL)或 `prepared.execHints.index`(ES),執行前先 `checkTableBlacklist('SELECT', target)`,並把真正的 `tableName` 餵給 `filterColumns`;Redis 維持原樣。
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
- **dist/ 整合 smoke 測試**:`tests/integration/dist-smoke.test.ts` 從 OS tmpdir 執行 `dist/cli.mjs`,覆蓋 `--version`、`skill --output`、`queries list`、`skill tasks list`,守住 packaged assets path 不再回退。
|
|
34
|
+
- **`q` blacklist 迴歸測試**:`tests/unit/commands/q-blacklist.test.ts` 覆蓋黑名單表阻擋、欄位 redact、未受影響 snippet 三種情境。
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- **Lint release-blocking**:`bun run lint` / `lint:fix` 加上 `--max-warnings=0`;同時清掉 45 個 `@typescript-eslint/no-explicit-any` warnings(以正型替代為主,`elasticsearch-adapter.ts` 因刻意不引入 `@elastic/elasticsearch` SDK 而以檔案層 `eslint-disable` 標註理由)。任何新 warning 從此會擋住 release。
|
|
39
|
+
|
|
8
40
|
## [1.10.0] - 2026-05-08
|
|
9
41
|
|
|
10
42
|
### Added
|
package/assets/SKILL.md
CHANGED
|
@@ -224,6 +224,14 @@ Run reusable parameterised SELECT snippets stored in your repo.
|
|
|
224
224
|
| 2. Inspect | `dbcli queries show @<name>` |
|
|
225
225
|
| 3. Run | `dbcli q @<name> --param k=v` |
|
|
226
226
|
|
|
227
|
+
### When you don't know which query to run
|
|
228
|
+
|
|
229
|
+
1. `dbcli queries search <keywords>` — natural keywords, fuzzy ranked
|
|
230
|
+
2. `dbcli queries suggest <intent>` — browse a category
|
|
231
|
+
Common intents: perf.slow-query, perf.cache-hit, capacity.size,
|
|
232
|
+
safety.connections, monitor.cluster-health
|
|
233
|
+
3. Once you find one: `dbcli q @<name>` (blacklist always enforced)
|
|
234
|
+
|
|
227
235
|
Snippets resolve from three layers, **local > shared > builtin** (local wins):
|
|
228
236
|
- `builtin` — bundled with dbcli (e.g. `@diag/*`); read-only at runtime
|
|
229
237
|
- `.dbcli-shared/queries/` — committed, team-shared
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
-- ---
|
|
2
|
+
-- name: blocking-queries.postgres
|
|
3
|
+
-- description: Top queries blocking others, with blocker/blocked PIDs
|
|
4
|
+
-- engine: postgres
|
|
5
|
+
-- intent: safety.locks
|
|
6
|
+
-- tags: [diag, postgres, safety]
|
|
7
|
+
-- ---
|
|
8
|
+
SELECT blocked.pid AS blocked_pid,
|
|
9
|
+
blocked.usename AS blocked_user,
|
|
10
|
+
blocking.pid AS blocking_pid,
|
|
11
|
+
blocking.usename AS blocking_user,
|
|
12
|
+
blocked.query AS blocked_query,
|
|
13
|
+
blocking.query AS blocking_query
|
|
14
|
+
FROM pg_stat_activity blocked
|
|
15
|
+
JOIN pg_stat_activity blocking
|
|
16
|
+
ON blocking.pid = ANY(pg_blocking_pids(blocked.pid))
|
|
17
|
+
WHERE blocked.wait_event_type IS NOT NULL;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- ---
|
|
2
|
+
-- name: hot-threads.elasticsearch
|
|
3
|
+
-- description: ES nodes hot threads — surface CPU bottlenecks
|
|
4
|
+
-- engine: elasticsearch
|
|
5
|
+
-- index: '_nodes/hot_threads'
|
|
6
|
+
-- intent: monitor.cluster-health
|
|
7
|
+
-- tags: [diag, elasticsearch, perf]
|
|
8
|
+
-- ---
|
|
9
|
+
{ "size": 0 }
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
-- ---
|
|
2
|
+
-- name: index-stats.elasticsearch
|
|
3
|
+
-- description: doc count + store size per index (top by store size)
|
|
4
|
+
-- engine: elasticsearch
|
|
5
|
+
-- index: '*'
|
|
6
|
+
-- intent: capacity.size
|
|
7
|
+
-- tags: [diag, elasticsearch, capacity]
|
|
8
|
+
-- ---
|
|
9
|
+
{
|
|
10
|
+
"size": 0,
|
|
11
|
+
"aggs": {
|
|
12
|
+
"by_index": {
|
|
13
|
+
"terms": { "field": "_index", "size": 50, "order": { "_count": "desc" } }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- ---
|
|
2
|
+
-- name: pending-tasks.elasticsearch
|
|
3
|
+
-- description: Cluster pending tasks queue depth and ages
|
|
4
|
+
-- engine: elasticsearch
|
|
5
|
+
-- index: '_cluster/pending_tasks'
|
|
6
|
+
-- intent: monitor.cluster-health
|
|
7
|
+
-- tags: [diag, elasticsearch]
|
|
8
|
+
-- ---
|
|
9
|
+
{ "size": 0 }
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- ---
|
|
2
|
+
-- name: unassigned-shards.elasticsearch
|
|
3
|
+
-- description: Shards stuck in UNASSIGNED state
|
|
4
|
+
-- engine: elasticsearch
|
|
5
|
+
-- index: '_cluster/allocation/explain'
|
|
6
|
+
-- intent: monitor.cluster-health
|
|
7
|
+
-- tags: [diag, elasticsearch, safety]
|
|
8
|
+
-- ---
|
|
9
|
+
{ "size": 0 }
|