@indiekitai/pg-dash 0.5.2 → 0.7.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # pg-dash
4
4
 
5
- **The AI-native PostgreSQL health checker.** One command to audit your database, 23 MCP tools for AI-assisted optimization, CI integration for automated checks.
5
+ **The AI-native PostgreSQL health checker.** One command to audit your database, 25 MCP tools for AI-assisted optimization, CI integration for automated checks.
6
6
 
7
7
  📖 **[Read the full writeup on Dev.to](https://dev.to/fan_yang_670d82db29664c9e/i-built-a-free-postgresql-health-checker-with-23-mcp-tools-and-ci-integration-2abc)**
8
8
 
@@ -55,7 +55,7 @@ The Dashboard is there when you need it. But the real power is in the CLI, MCP,
55
55
  | pganalyze | $149+/mo | SaaS signup | ❌ | ❌ |
56
56
  | Grafana+Prometheus | Free | 3 services | ❌ | ❌ |
57
57
  | pgAdmin | Free | Complex UI | ❌ | ❌ |
58
- | **pg-dash** | **Free** | **One command** | **23 MCP tools** | **`--ci --diff`** |
58
+ | **pg-dash** | **Free** | **One command** | **25 MCP tools** | **`--ci --diff`** |
59
59
 
60
60
  ## Features
61
61
 
@@ -147,6 +147,23 @@ Real-time lock wait monitor — refreshes every 3 seconds. Shows:
147
147
  - Long-running queries (configurable threshold via `--long-query-threshold`)
148
148
  - Table and lock type for each wait
149
149
 
150
+ ### 📊 query-stats (PG 18+)
151
+
152
+ ```bash
153
+ # Export query statistics from production
154
+ pg-dash query-stats export postgres://prod-server/db --file prod-stats.json
155
+
156
+ # Import to development environment
157
+ pg-dash query-stats import prod-stats.json postgres://localhost/db
158
+ ```
159
+
160
+ Export/import PostgreSQL query statistics (requires PG 18+). Enables "production query plans without production data" workflow:
161
+ 1. Export stats from production: `pg-dash query-stats export prod`
162
+ 2. Import to dev: `pg-dash query-stats import prod-stats.json dev`
163
+ 3. Run `EXPLAIN` locally — now uses production statistics for accurate query plans
164
+
165
+ The exported JSON is typically <1MB regardless of database size.
166
+
150
167
  ### 🛡️ Migration Safety Check
151
168
  - Analyze a migration SQL file for risks before running it
152
169
  - Detects: `CREATE INDEX` without `CONCURRENTLY` (lock risk), `ADD COLUMN NOT NULL` without `DEFAULT`, `ALTER COLUMN TYPE` (full table rewrite), `DROP COLUMN` (app breakage risk), `ADD CONSTRAINT` without `NOT VALID` (full table scan), `CREATE INDEX CONCURRENTLY` inside a transaction (runtime failure), `DROP TABLE`, `TRUNCATE`, `DELETE`/`UPDATE` without `WHERE`
@@ -246,6 +263,8 @@ Options:
246
263
  --discord-webhook <url> Discord webhook URL for alert notifications
247
264
  --ci Output GitHub Actions annotations (check, check-migration, diff-env)
248
265
  --diff Compare with last snapshot (check command)
266
+ --ai-suggest Use AI to generate fix suggestions (requires LLM config)
267
+ --ai-explain Use AI to explain schema diff business impact (requires LLM config)
249
268
  --snapshot-path <path> Path to snapshot file for --diff
250
269
  --health Include health comparison (diff-env)
251
270
  -v, --version Show version
@@ -263,7 +282,7 @@ pg-dash-mcp postgres://user:pass@host/db
263
282
  PG_DASH_CONNECTION_STRING=postgres://... pg-dash-mcp
264
283
  ```
265
284
 
266
- ### Available Tools (23)
285
+ ### Available Tools (25)
267
286
 
268
287
  | Tool | Description |
269
288
  |------|-------------|
@@ -290,6 +309,9 @@ PG_DASH_CONNECTION_STRING=postgres://... pg-dash-mcp
290
309
  | `pg_dash_autovacuum` | Check autovacuum health — which tables are stale or never vacuumed |
291
310
  | `pg_dash_locks` | Show active lock waits and long-running blocking queries |
292
311
  | `pg_dash_config_check` | Audit PostgreSQL configuration and get tuning recommendations |
312
+ | `fetch_db_context` | Comprehensive DB context for AI agents: all table structures, columns, types, PKs/FKs, indexes, business intent inference, and health summary (single call for full context) |
313
+ | `pg_dash_query_natural` | Query database using natural language — LLM converts your question to SQL and returns results. Example: "show me slow queries last hour", "find missing indexes", "what's the health score", "list all tables with their sizes" |
314
+ | `ci_health_summary` | Generate a CI-friendly health summary with AI-powered prioritization. Input: health check result (from pg_dash_health). Output: one-sentence summary + prioritized issue list. Perfect for GitHub Actions/GitLab CI integration. |
293
315
 
294
316
  ## MCP Setup
295
317
 
package/README.zh-CN.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # pg-dash
4
4
 
5
- **AI 原生的 PostgreSQL 健康检查工具。** 一条命令审计数据库,23 个 MCP 工具让 AI 帮你优化,CI 集成自动检查。
5
+ **AI 原生的 PostgreSQL 健康检查工具。** 一条命令审计数据库,25 个 MCP 工具让 AI 帮你优化,CI 集成自动检查。
6
6
 
7
7
  📖 **[在 Dev.to 阅读完整介绍](https://dev.to/fan_yang_670d82db29664c9e/i-built-a-free-postgresql-health-checker-with-23-mcp-tools-and-ci-integration-2abc)**
8
8
 
@@ -55,7 +55,7 @@ Dashboard 需要时可以用。但真正的核心能力在 CLI、MCP 和 CI。
55
55
  | pganalyze | $149+/月 | SaaS 注册 | ❌ | ❌ |
56
56
  | Grafana+Prometheus | 免费 | 配置 3 个服务 | ❌ | ❌ |
57
57
  | pgAdmin | 免费 | 界面复杂 | ❌ | ❌ |
58
- | **pg-dash** | **免费** | **一条命令** | **23 个 MCP 工具** | **`--ci --diff`** |
58
+ | **pg-dash** | **免费** | **一条命令** | **25 个 MCP 工具** | **`--ci --diff`** |
59
59
 
60
60
  ## 功能
61
61
 
@@ -183,6 +183,8 @@ pg-dash explain "<query>" <connection> 终端里 EXPLAIN ANALYZE 查
183
183
  pg-dash watch-locks <connection> 实时锁和长查询监控
184
184
  pg-dash diff-env --source <url> --target <url> 对比两个环境
185
185
  pg-dash schema-diff <connection-string> 显示 Schema 变更
186
+ pg-dash query-stats export <connection> 导出查询统计(PG 18+)
187
+ pg-dash query-stats import <file> <connection> 导入查询统计(PG 18+)
186
188
 
187
189
  Options:
188
190
  -p, --port <port> 面板端口(默认:3480)
@@ -202,6 +204,8 @@ Options:
202
204
  --discord-webhook <url> Discord webhook URL,用于告警通知
203
205
  --ci 输出 GitHub Actions 注解(check、check-migration、diff-env)
204
206
  --diff 与上次快照对比(check 命令)
207
+ --ai-suggest 使用 AI 生成修复建议(需要配置 LLM)
208
+ --ai-explain 使用 AI 解释 Schema 差异的业务影响(需要配置 LLM)
205
209
  --snapshot-path <path> --diff 使用的快照文件路径
206
210
  --health 包含健康对比(diff-env)
207
211
  -v, --version 显示版本
@@ -219,7 +223,7 @@ pg-dash-mcp postgres://user:pass@host/db
219
223
  PG_DASH_CONNECTION_STRING=postgres://... pg-dash-mcp
220
224
  ```
221
225
 
222
- ### 可用工具(23 个)
226
+ ### 可用工具(25 个)
223
227
 
224
228
  | 工具 | 描述 |
225
229
  |------|------|
@@ -246,6 +250,9 @@ PG_DASH_CONNECTION_STRING=postgres://... pg-dash-mcp
246
250
  | `pg_dash_autovacuum` | Autovacuum 健康状态——哪些表长期未 vacuum |
247
251
  | `pg_dash_locks` | 显示活跃锁等待链和长时间阻塞的查询 |
248
252
  | `pg_dash_config_check` | 审计 PostgreSQL 配置,给出调优建议 |
253
+ | `fetch_db_context` | AI Agent 用的完整数据库上下文:所有表结构、列类型、主键外键、索引、业务意图推断、健康摘要(一次调用获取全部信息) |
254
+ | `pg_dash_query_natural` | 自然语言查询数据库——LLM 将你的问题转换为 SQL 并返回结果。示例:"显示最近一小时的慢查询"、"查找缺失的索引"、"健康评分是多少"、"列出所有表及其大小" |
255
+ | `ci_health_summary` | 生成 CI 友好的健康摘要(AI 辅助优先级排序)。输入:健康检查结果。输出:一句自然语言总结 + 优先级排序的问题列表。非常适合集成到 GitHub Actions/GitLab CI。 |
249
256
 
250
257
  ## MCP 配置
251
258