postgresai 0.16.0-dev.1 → 0.16.0-dev.10
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 +84 -1
- package/bin/postgres-ai.ts +789 -6
- package/bun.lock +4 -4
- package/dist/bin/postgres-ai.js +2621 -279
- package/dist/sql/06.helpers.sql +0 -122
- package/dist/sql/sql/06.helpers.sql +0 -122
- package/lib/dblab.ts +449 -0
- package/lib/init.ts +0 -8
- package/lib/joe.ts +761 -0
- package/lib/mcp-server.ts +625 -0
- package/lib/supabase.ts +0 -18
- package/lib/util.ts +125 -18
- package/package.json +1 -1
- package/sql/06.helpers.sql +0 -122
- package/test/dblab.cli.test.ts +373 -0
- package/test/dblab.test.ts +488 -0
- package/test/e2e/pgai-e2e-smoke.sh +192 -0
- package/test/init.integration.test.ts +9 -79
- package/test/joe.cli.test.ts +469 -0
- package/test/joe.test.ts +858 -0
- package/test/monitoring.test.ts +54 -3
- package/test/util.test.ts +111 -1
package/README.md
CHANGED
|
@@ -229,10 +229,67 @@ postgresai mon check # System readiness check
|
|
|
229
229
|
postgresai mon shell <service> # Open shell to monitoring service
|
|
230
230
|
```
|
|
231
231
|
|
|
232
|
+
### Joe API v2 (`joe` group)
|
|
233
|
+
|
|
234
|
+
Run database-optimization commands on the project's ephemeral DBLab clone via the
|
|
235
|
+
platform Joe API v2. Every verb takes `--project <id|alias>` (a numeric project id,
|
|
236
|
+
or the project's alias/name/label); use `pgai projects` to discover them.
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
pgai projects # org-level discovery: which projects have Joe ready
|
|
240
|
+
|
|
241
|
+
pgai joe plan "select * from users where email = $1" --project 12 # EXPLAIN, plan-only (never executes)
|
|
242
|
+
pgai joe explain "select ..." --project main-db # EXPLAIN ANALYZE (executes on the clone)
|
|
243
|
+
pgai joe exec "create index on users (email)" --project 12 # arbitrary DDL/DML on the clone
|
|
244
|
+
pgai joe hypo "create index on users (name)" --query "select ..." --project 12 # HypoPG what-if + re-plan
|
|
245
|
+
pgai joe activity --project 12 # pg_stat_activity snapshot (query text redacted)
|
|
246
|
+
pgai joe describe users --project 12 [--variant "\d+"] # \d-family metadata
|
|
247
|
+
pgai joe terminate <pid> --project 12 # pg_terminate_backend on the clone
|
|
248
|
+
pgai joe reset --project 12 # reset the session's clone
|
|
249
|
+
pgai joe status <commandId> # command status (metadata only)
|
|
250
|
+
pgai joe result <commandId> # fetch/resume a command result
|
|
251
|
+
pgai joe history <terms> # search prior analyses (M1b — not yet available)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Shared options: `--session <id>` / `--new-session` (session/clone threading — the
|
|
255
|
+
session returned by a command is auto-reused per project), `--budget <seconds>`
|
|
256
|
+
(one-shot poll budget, default 25; on expiry the command exits 0 and prints a
|
|
257
|
+
resume handle: `pgai joe result <commandId>`), `--debug`, `--json`.
|
|
258
|
+
|
|
259
|
+
Exit codes: 0 on success or budget expiry (resume handle); 1 on a server-side
|
|
260
|
+
`error` or `timed_out`, a refused submit (e.g. missing scope, `ai_enabled=false`),
|
|
261
|
+
or invalid arguments.
|
|
262
|
+
|
|
263
|
+
### DBLab companion (`dblab` group)
|
|
264
|
+
|
|
265
|
+
Manage the project's DBLab thin clones, branches, and snapshots — proxies the same
|
|
266
|
+
Platform DBLab API the Console uses. Read/create verbs require the `joe:plan` token
|
|
267
|
+
scope; destructive verbs (clone reset/destroy, branch delete, snapshot destroy)
|
|
268
|
+
require `joe:admin` (enforced server-side).
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
pgai dblab clone create --project 12 --id my-clone --db-user u --db-password p \
|
|
272
|
+
[--branch <branch>] [--snapshot <id>] [--protected]
|
|
273
|
+
pgai dblab clone list --project 12
|
|
274
|
+
pgai dblab clone status <cloneId> --project 12
|
|
275
|
+
pgai dblab clone reset <cloneId> --project 12 [--snapshot <id> | --latest]
|
|
276
|
+
pgai dblab clone destroy <cloneId> --project 12
|
|
277
|
+
|
|
278
|
+
pgai dblab branch list --project 12
|
|
279
|
+
pgai dblab branch create <name> --project 12 [--snapshot <id>] [--base-branch <branch>]
|
|
280
|
+
pgai dblab branch delete <name> --project 12
|
|
281
|
+
pgai dblab branch log <name> --project 12
|
|
282
|
+
|
|
283
|
+
pgai dblab snapshot list --project 12 [--branch <branch>] [--dataset <dataset>]
|
|
284
|
+
pgai dblab snapshot create --project 12 --clone <cloneId> [--message <msg>]
|
|
285
|
+
pgai dblab snapshot destroy <snapshotId> --project 12 [--force]
|
|
286
|
+
```
|
|
287
|
+
|
|
232
288
|
### MCP server (`mcp` group)
|
|
233
289
|
|
|
234
290
|
```bash
|
|
235
291
|
postgresai mcp start # Start MCP stdio server exposing tools
|
|
292
|
+
postgresai mcp install [client] # Install the MCP config for cursor/claude-code/windsurf/codex
|
|
236
293
|
```
|
|
237
294
|
|
|
238
295
|
Cursor configuration example (Settings → MCP):
|
|
@@ -251,7 +308,9 @@ Cursor configuration example (Settings → MCP):
|
|
|
251
308
|
}
|
|
252
309
|
```
|
|
253
310
|
|
|
254
|
-
Tools exposed:
|
|
311
|
+
Tools exposed (36 total — MCP tool names are FLAT; only the human CLI tree is grouped):
|
|
312
|
+
|
|
313
|
+
Issues & files:
|
|
255
314
|
- `list_issues`: returns the same JSON as `postgresai issues list`.
|
|
256
315
|
- `view_issue`: view a single issue with its comments (args: `{ issue_id, debug? }`).
|
|
257
316
|
- `create_issue`: create a new issue (args: `{ title, description?, org_id, attachments?, debug? }`).
|
|
@@ -261,6 +320,30 @@ Tools exposed:
|
|
|
261
320
|
- `upload_file`: upload a local file and return the storage URL plus a ready-to-paste markdown link (args: `{ path, debug? }`).
|
|
262
321
|
- `download_file`: download a file from storage (args: `{ url, output_path?, debug? }`).
|
|
263
322
|
|
|
323
|
+
Action items:
|
|
324
|
+
- `view_action_item`, `list_action_items`, `create_action_item`, `update_action_item`: manage an issue's action items.
|
|
325
|
+
|
|
326
|
+
Checkup reports:
|
|
327
|
+
- `list_reports`, `list_report_files`, `get_report_data`: browse checkup reports and fetch their json/md content.
|
|
328
|
+
|
|
329
|
+
Joe API v2 (mirror `pgai joe <verb>`; every command tool takes `{ project_id, session_id?, new_session?, timeout_ms?, debug? }`
|
|
330
|
+
plus its own arguments — `timeout_ms` is the one-shot poll budget; on expiry the tool returns `budget_expired: true`
|
|
331
|
+
and a `resume` handle instead of blocking):
|
|
332
|
+
- `plan_query`: EXPLAIN, plan-only — never executes (args: `{ sql, ... }`). Requires `joe:plan`.
|
|
333
|
+
- `explain_query`: EXPLAIN ANALYZE — executes on the ephemeral DBLab clone (args: `{ sql, ... }`). Requires `joe:exec`.
|
|
334
|
+
- `exec_sql`: arbitrary DDL/DML on the clone — can return real table rows into the agent's context (args: `{ sql, ... }`). Requires `joe:exec`.
|
|
335
|
+
- `hypo_index`: HypoPG hypothetical index + re-plan (args: `{ sql, query, ... }`). Requires `joe:plan`.
|
|
336
|
+
- `activity`: pg_stat_activity snapshot, query text redacted. Requires `joe:plan`.
|
|
337
|
+
- `terminate_backend`: pg_terminate_backend on the clone (args: `{ pid, ... }`). Requires `joe:admin`.
|
|
338
|
+
- `reset_clone`: reset the session's thin clone. Requires `joe:admin`.
|
|
339
|
+
- `describe`: \d-family metadata introspection (args: `{ object, variant?, ... }`). Requires `joe:plan`.
|
|
340
|
+
- `list_projects`: org-level discovery (mirrors `pgai projects`) — which projects are Joe-ready.
|
|
341
|
+
|
|
342
|
+
DBLab companion (mirror `pgai dblab <group> <verb>`; every tool takes `{ project, org_id?, debug? }` plus its own arguments):
|
|
343
|
+
- `clone_create`, `clone_list`, `clone_status`, `clone_reset`, `clone_destroy`
|
|
344
|
+
- `branch_list`, `branch_create`, `branch_delete`, `branch_log`
|
|
345
|
+
- `snapshot_list`, `snapshot_create`, `snapshot_destroy`
|
|
346
|
+
|
|
264
347
|
#### `attachments` parameter (issue/comment tools)
|
|
265
348
|
|
|
266
349
|
`create_issue`, `update_issue`, `post_issue_comment`, and `update_issue_comment` accept an
|