postgresai 0.12.0-beta.6 → 0.14.0-dev.7
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 +91 -2
- package/bin/postgres-ai.ts +552 -37
- package/dist/bin/postgres-ai.js +503 -26
- package/dist/bin/postgres-ai.js.map +1 -1
- package/dist/lib/init.d.ts +61 -0
- package/dist/lib/init.d.ts.map +1 -0
- package/dist/lib/init.js +359 -0
- package/dist/lib/init.js.map +1 -0
- package/dist/lib/issues.d.ts +69 -1
- package/dist/lib/issues.d.ts.map +1 -1
- package/dist/lib/issues.js +232 -1
- package/dist/lib/issues.js.map +1 -1
- package/dist/lib/mcp-server.d.ts.map +1 -1
- package/dist/lib/mcp-server.js +69 -15
- package/dist/lib/mcp-server.js.map +1 -1
- package/dist/package.json +3 -2
- package/lib/init.ts +404 -0
- package/lib/issues.ts +325 -3
- package/lib/mcp-server.ts +75 -17
- package/package.json +3 -2
- package/test/init.integration.test.cjs +269 -0
- package/test/init.test.cjs +69 -0
package/README.md
CHANGED
|
@@ -34,6 +34,39 @@ postgresai --help
|
|
|
34
34
|
pgai --help # short alias
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
## init (create monitoring user in Postgres)
|
|
38
|
+
|
|
39
|
+
This command creates (or updates) the `postgres_ai_mon` user and grants the permissions described in the root `README.md` (it is idempotent).
|
|
40
|
+
|
|
41
|
+
Run without installing (positional connection string):
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx postgresai init postgresql://admin@host:5432/dbname
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
It also accepts libpq “conninfo” syntax:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx postgresai init "dbname=dbname host=host user=admin"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
And psql-like options:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npx postgresai init -h host -p 5432 -U admin -d dbname
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Password input options (in priority order):
|
|
60
|
+
- `--password <password>`
|
|
61
|
+
- `PGAI_MON_PASSWORD` environment variable
|
|
62
|
+
- interactive prompt (TTY only)
|
|
63
|
+
|
|
64
|
+
Optional permissions (RDS/self-managed extras from the root `README.md`) are enabled by default. To skip them:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npx postgresai init postgresql://admin@host:5432/dbname --skip-optional-permissions
|
|
68
|
+
```
|
|
69
|
+
|
|
37
70
|
## Quick start
|
|
38
71
|
|
|
39
72
|
### Authentication
|
|
@@ -55,7 +88,19 @@ Start monitoring with demo database:
|
|
|
55
88
|
postgres-ai mon quickstart --demo
|
|
56
89
|
```
|
|
57
90
|
|
|
91
|
+
Start monitoring with your own database:
|
|
92
|
+
```bash
|
|
93
|
+
postgres-ai mon quickstart --db-url postgresql://user:pass@host:5432/db
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Complete automated setup with API key and database:
|
|
97
|
+
```bash
|
|
98
|
+
postgres-ai mon quickstart --api-key your_key --db-url postgresql://user:pass@host:5432/db -y
|
|
99
|
+
```
|
|
100
|
+
|
|
58
101
|
This will:
|
|
102
|
+
- Configure API key for automated report uploads (if provided)
|
|
103
|
+
- Add PostgreSQL instance to monitor (if provided)
|
|
59
104
|
- Generate secure Grafana password
|
|
60
105
|
- Start all monitoring services
|
|
61
106
|
- Open Grafana at http://localhost:3000
|
|
@@ -66,7 +111,15 @@ This will:
|
|
|
66
111
|
|
|
67
112
|
#### Service lifecycle
|
|
68
113
|
```bash
|
|
69
|
-
|
|
114
|
+
# Complete setup with various options
|
|
115
|
+
postgres-ai mon quickstart # Interactive setup for production
|
|
116
|
+
postgres-ai mon quickstart --demo # Demo mode with sample database
|
|
117
|
+
postgres-ai mon quickstart --api-key <key> # Setup with API key
|
|
118
|
+
postgres-ai mon quickstart --db-url <url> # Setup with database URL
|
|
119
|
+
postgres-ai mon quickstart --api-key <key> --db-url <url> # Complete automated setup
|
|
120
|
+
postgres-ai mon quickstart -y # Auto-accept all defaults
|
|
121
|
+
|
|
122
|
+
# Service management
|
|
70
123
|
postgres-ai mon start # Start monitoring services
|
|
71
124
|
postgres-ai mon stop # Stop monitoring services
|
|
72
125
|
postgres-ai mon restart [service] # Restart all or specific monitoring service
|
|
@@ -74,6 +127,12 @@ postgres-ai mon status # Show monitoring services status
|
|
|
74
127
|
postgres-ai mon health [--wait <sec>] # Check monitoring services health
|
|
75
128
|
```
|
|
76
129
|
|
|
130
|
+
##### Quickstart options
|
|
131
|
+
- `--demo` - Demo mode with sample database (testing only, cannot use with --api-key)
|
|
132
|
+
- `--api-key <key>` - Postgres AI API key for automated report uploads
|
|
133
|
+
- `--db-url <url>` - PostgreSQL connection URL to monitor (format: `postgresql://user:pass@host:port/db`)
|
|
134
|
+
- `-y, --yes` - Accept all defaults and skip interactive prompts
|
|
135
|
+
|
|
77
136
|
#### Monitoring target databases (`mon targets` subgroup)
|
|
78
137
|
```bash
|
|
79
138
|
postgres-ai mon targets list # List databases to monitor
|
|
@@ -96,7 +155,7 @@ postgres-ai mon shell <service> # Open shell to monitoring servic
|
|
|
96
155
|
### MCP server (`mcp` group)
|
|
97
156
|
|
|
98
157
|
```bash
|
|
99
|
-
pgai mcp start # Start MCP stdio server exposing
|
|
158
|
+
pgai mcp start # Start MCP stdio server exposing tools
|
|
100
159
|
```
|
|
101
160
|
|
|
102
161
|
Cursor configuration example (Settings → MCP):
|
|
@@ -117,6 +176,36 @@ Cursor configuration example (Settings → MCP):
|
|
|
117
176
|
|
|
118
177
|
Tools exposed:
|
|
119
178
|
- list_issues: returns the same JSON as `pgai issues list`.
|
|
179
|
+
- view_issue: view a single issue with its comments (args: { issue_id, debug? })
|
|
180
|
+
- post_issue_comment: post a comment (args: { issue_id, content, parent_comment_id?, debug? })
|
|
181
|
+
|
|
182
|
+
### Issues management (`issues` group)
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
pgai issues list # List issues (shows: id, title, status, created_at)
|
|
186
|
+
pgai issues view <issueId> # View issue details and comments
|
|
187
|
+
pgai issues post_comment <issueId> <content> # Post a comment to an issue
|
|
188
|
+
# Options:
|
|
189
|
+
# --parent <uuid> Parent comment ID (for replies)
|
|
190
|
+
# --debug Enable debug output
|
|
191
|
+
# --json Output raw JSON (overrides default YAML)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
#### Output format for issues commands
|
|
195
|
+
|
|
196
|
+
By default, issues commands print human-friendly YAML when writing to a terminal. For scripting, you can:
|
|
197
|
+
|
|
198
|
+
- Use `--json` to force JSON output:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
pgai issues list --json | jq '.[] | {id, title}'
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
- Rely on auto-detection: when stdout is not a TTY (e.g., piped or redirected), output is JSON automatically:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
pgai issues view <issueId> > issue.json
|
|
208
|
+
```
|
|
120
209
|
|
|
121
210
|
#### Grafana management
|
|
122
211
|
```bash
|