postgresai 0.14.0-beta.2 → 0.14.0-beta.4
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 +53 -45
- package/bin/postgres-ai.ts +953 -353
- package/bun.lock +258 -0
- package/bunfig.toml +11 -0
- package/dist/bin/postgres-ai.js +27868 -1781
- package/lib/auth-server.ts +124 -106
- package/lib/checkup-api.ts +386 -0
- package/lib/checkup.ts +1327 -0
- package/lib/config.ts +3 -0
- package/lib/init.ts +283 -158
- package/lib/issues.ts +86 -195
- package/lib/mcp-server.ts +6 -17
- package/lib/metrics-embedded.ts +79 -0
- package/lib/metrics-loader.ts +127 -0
- package/lib/util.ts +61 -0
- package/package.json +18 -10
- package/packages/postgres-ai/README.md +26 -0
- package/packages/postgres-ai/bin/postgres-ai.js +27 -0
- package/packages/postgres-ai/package.json +27 -0
- package/scripts/embed-metrics.ts +154 -0
- package/sql/02.permissions.sql +9 -5
- package/sql/05.helpers.sql +415 -0
- package/test/checkup.integration.test.ts +273 -0
- package/test/checkup.test.ts +890 -0
- package/test/init.integration.test.ts +399 -0
- package/test/init.test.ts +345 -0
- package/test/schema-validation.test.ts +81 -0
- package/test/test-utils.ts +122 -0
- package/tsconfig.json +12 -20
- package/dist/bin/postgres-ai.d.ts +0 -3
- package/dist/bin/postgres-ai.d.ts.map +0 -1
- package/dist/bin/postgres-ai.js.map +0 -1
- package/dist/lib/auth-server.d.ts +0 -31
- package/dist/lib/auth-server.d.ts.map +0 -1
- package/dist/lib/auth-server.js +0 -263
- package/dist/lib/auth-server.js.map +0 -1
- package/dist/lib/config.d.ts +0 -45
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/config.js +0 -181
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/init.d.ts +0 -77
- package/dist/lib/init.d.ts.map +0 -1
- package/dist/lib/init.js +0 -550
- package/dist/lib/init.js.map +0 -1
- package/dist/lib/issues.d.ts +0 -75
- package/dist/lib/issues.d.ts.map +0 -1
- package/dist/lib/issues.js +0 -336
- package/dist/lib/issues.js.map +0 -1
- package/dist/lib/mcp-server.d.ts +0 -9
- package/dist/lib/mcp-server.d.ts.map +0 -1
- package/dist/lib/mcp-server.js +0 -168
- package/dist/lib/mcp-server.js.map +0 -1
- package/dist/lib/pkce.d.ts +0 -32
- package/dist/lib/pkce.d.ts.map +0 -1
- package/dist/lib/pkce.js +0 -101
- package/dist/lib/pkce.js.map +0 -1
- package/dist/lib/util.d.ts +0 -27
- package/dist/lib/util.d.ts.map +0 -1
- package/dist/lib/util.js +0 -46
- package/dist/lib/util.js.map +0 -1
- package/dist/package.json +0 -46
- package/test/init.integration.test.cjs +0 -382
- package/test/init.test.cjs +0 -323
package/README.md
CHANGED
|
@@ -29,10 +29,10 @@ brew install postgresai
|
|
|
29
29
|
|
|
30
30
|
## Usage
|
|
31
31
|
|
|
32
|
-
The
|
|
32
|
+
The `postgresai` package provides two command aliases:
|
|
33
33
|
```bash
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
postgresai --help # Canonical, discoverable
|
|
35
|
+
pgai --help # Short and convenient
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
You can also run it without installing via `npx`:
|
|
@@ -41,26 +41,34 @@ You can also run it without installing via `npx`:
|
|
|
41
41
|
npx postgresai --help
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
### Optional shorthand: `pgai`
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
If you want `npx pgai ...` as a shorthand for `npx postgresai ...`, install the separate `pgai` wrapper package:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx pgai --help
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## prepare-db (create monitoring user in Postgres)
|
|
53
|
+
|
|
54
|
+
This command creates (or updates) the `postgres_ai_mon` user, creates the required view(s), and grants the permissions described in the root `README.md` (it is idempotent). Where supported, it also enables observability extensions described there.
|
|
47
55
|
|
|
48
56
|
Run without installing (positional connection string):
|
|
49
57
|
|
|
50
58
|
```bash
|
|
51
|
-
npx postgresai
|
|
59
|
+
npx postgresai prepare-db postgresql://admin@host:5432/dbname
|
|
52
60
|
```
|
|
53
61
|
|
|
54
|
-
It also accepts libpq
|
|
62
|
+
It also accepts libpq "conninfo" syntax:
|
|
55
63
|
|
|
56
64
|
```bash
|
|
57
|
-
npx postgresai
|
|
65
|
+
npx postgresai prepare-db "dbname=dbname host=host user=admin"
|
|
58
66
|
```
|
|
59
67
|
|
|
60
68
|
And psql-like options:
|
|
61
69
|
|
|
62
70
|
```bash
|
|
63
|
-
npx postgresai
|
|
71
|
+
npx postgresai prepare-db -h host -p 5432 -U admin -d dbname
|
|
64
72
|
```
|
|
65
73
|
|
|
66
74
|
Password input options (in priority order):
|
|
@@ -74,7 +82,7 @@ By default, the generated password is printed **only in interactive (TTY) mode**
|
|
|
74
82
|
Optional permissions (RDS/self-managed extras from the root `README.md`) are enabled by default. To skip them:
|
|
75
83
|
|
|
76
84
|
```bash
|
|
77
|
-
npx postgresai
|
|
85
|
+
npx postgresai prepare-db postgresql://admin@host:5432/dbname --skip-optional-permissions
|
|
78
86
|
```
|
|
79
87
|
|
|
80
88
|
### Print SQL / dry run
|
|
@@ -82,7 +90,7 @@ npx postgresai init postgresql://admin@host:5432/dbname --skip-optional-permissi
|
|
|
82
90
|
To see what SQL would be executed (passwords redacted by default):
|
|
83
91
|
|
|
84
92
|
```bash
|
|
85
|
-
npx postgresai
|
|
93
|
+
npx postgresai prepare-db postgresql://admin@host:5432/dbname --print-sql
|
|
86
94
|
```
|
|
87
95
|
|
|
88
96
|
### Verify and password reset
|
|
@@ -90,13 +98,13 @@ npx postgresai init postgresql://admin@host:5432/dbname --print-sql
|
|
|
90
98
|
Verify that everything is configured as expected (no changes):
|
|
91
99
|
|
|
92
100
|
```bash
|
|
93
|
-
npx postgresai
|
|
101
|
+
npx postgresai prepare-db postgresql://admin@host:5432/dbname --verify
|
|
94
102
|
```
|
|
95
103
|
|
|
96
104
|
Reset monitoring user password only (no other changes):
|
|
97
105
|
|
|
98
106
|
```bash
|
|
99
|
-
npx postgresai
|
|
107
|
+
npx postgresai prepare-db postgresql://admin@host:5432/dbname --reset-password --password 'new_password'
|
|
100
108
|
```
|
|
101
109
|
|
|
102
110
|
## Quick start
|
|
@@ -117,17 +125,17 @@ This will:
|
|
|
117
125
|
|
|
118
126
|
Start monitoring with demo database:
|
|
119
127
|
```bash
|
|
120
|
-
|
|
128
|
+
postgresai mon local-install --demo
|
|
121
129
|
```
|
|
122
130
|
|
|
123
131
|
Start monitoring with your own database:
|
|
124
132
|
```bash
|
|
125
|
-
|
|
133
|
+
postgresai mon local-install --db-url postgresql://user:pass@host:5432/db
|
|
126
134
|
```
|
|
127
135
|
|
|
128
136
|
Complete automated setup with API key and database:
|
|
129
137
|
```bash
|
|
130
|
-
|
|
138
|
+
postgresai mon local-install --api-key your_key --db-url postgresql://user:pass@host:5432/db -y
|
|
131
139
|
```
|
|
132
140
|
|
|
133
141
|
This will:
|
|
@@ -144,22 +152,22 @@ This will:
|
|
|
144
152
|
#### Service lifecycle
|
|
145
153
|
```bash
|
|
146
154
|
# Complete setup with various options
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
155
|
+
postgresai mon local-install # Interactive setup for production
|
|
156
|
+
postgresai mon local-install --demo # Demo mode with sample database
|
|
157
|
+
postgresai mon local-install --api-key <key> # Setup with API key
|
|
158
|
+
postgresai mon local-install --db-url <url> # Setup with database URL
|
|
159
|
+
postgresai mon local-install --api-key <key> --db-url <url> # Complete automated setup
|
|
160
|
+
postgresai mon local-install -y # Auto-accept all defaults
|
|
153
161
|
|
|
154
162
|
# Service management
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
163
|
+
postgresai mon start # Start monitoring services
|
|
164
|
+
postgresai mon stop # Stop monitoring services
|
|
165
|
+
postgresai mon restart [service] # Restart all or specific monitoring service
|
|
166
|
+
postgresai mon status # Show monitoring services status
|
|
167
|
+
postgresai mon health [--wait <sec>] # Check monitoring services health
|
|
160
168
|
```
|
|
161
169
|
|
|
162
|
-
#####
|
|
170
|
+
##### local-install options
|
|
163
171
|
- `--demo` - Demo mode with sample database (testing only, cannot use with --api-key)
|
|
164
172
|
- `--api-key <key>` - Postgres AI API key for automated report uploads
|
|
165
173
|
- `--db-url <url>` - PostgreSQL connection URL to monitor (format: `postgresql://user:pass@host:port/db`)
|
|
@@ -167,21 +175,21 @@ postgres-ai mon health [--wait <sec>] # Check monitoring services health
|
|
|
167
175
|
|
|
168
176
|
#### Monitoring target databases (`mon targets` subgroup)
|
|
169
177
|
```bash
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
178
|
+
postgresai mon targets list # List databases to monitor
|
|
179
|
+
postgresai mon targets add <conn-string> <name> # Add database to monitor
|
|
180
|
+
postgresai mon targets remove <name> # Remove monitoring target
|
|
181
|
+
postgresai mon targets test <name> # Test target connectivity
|
|
174
182
|
```
|
|
175
183
|
|
|
176
184
|
#### Configuration and maintenance
|
|
177
185
|
```bash
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
186
|
+
postgresai mon config # Show monitoring configuration
|
|
187
|
+
postgresai mon update-config # Apply configuration changes
|
|
188
|
+
postgresai mon update # Update monitoring stack
|
|
189
|
+
postgresai mon reset [service] # Reset service data
|
|
190
|
+
postgresai mon clean # Cleanup artifacts
|
|
191
|
+
postgresai mon check # System readiness check
|
|
192
|
+
postgresai mon shell <service> # Open shell to monitoring service
|
|
185
193
|
```
|
|
186
194
|
|
|
187
195
|
### MCP server (`mcp` group)
|
|
@@ -241,16 +249,16 @@ postgresai issues view <issueId> > issue.json
|
|
|
241
249
|
|
|
242
250
|
#### Grafana management
|
|
243
251
|
```bash
|
|
244
|
-
|
|
245
|
-
|
|
252
|
+
postgresai mon generate-grafana-password # Generate new Grafana password
|
|
253
|
+
postgresai mon show-grafana-credentials # Show Grafana credentials
|
|
246
254
|
```
|
|
247
255
|
|
|
248
256
|
### Authentication and API key management
|
|
249
257
|
```bash
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
258
|
+
postgresai auth # Authenticate via browser (OAuth)
|
|
259
|
+
postgresai auth --set-key <key> # Store API key directly
|
|
260
|
+
postgresai show-key # Show stored key (masked)
|
|
261
|
+
postgresai remove-key # Remove stored key
|
|
254
262
|
```
|
|
255
263
|
|
|
256
264
|
## Configuration
|