postgresai 0.14.0-dev.53 → 0.14.0-dev.55
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 +65 -38
- package/bin/postgres-ai.ts +461 -12
- package/bun.lock +3 -1
- package/bunfig.toml +19 -0
- package/dist/bin/postgres-ai.js +2208 -224
- package/lib/auth-server.ts +52 -5
- package/lib/checkup-api.ts +386 -0
- package/lib/checkup.ts +1327 -0
- package/lib/config.ts +3 -0
- package/lib/issues.ts +5 -41
- package/lib/metrics-embedded.ts +79 -0
- package/lib/metrics-loader.ts +127 -0
- package/lib/util.ts +61 -0
- package/package.json +14 -6
- 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/test/auth.test.ts +258 -0
- package/test/checkup.integration.test.ts +273 -0
- package/test/checkup.test.ts +890 -0
- package/test/init.integration.test.ts +36 -33
- package/test/schema-validation.test.ts +81 -0
- package/test/test-utils.ts +122 -0
- package/dist/sql/01.role.sql +0 -16
- package/dist/sql/02.permissions.sql +0 -37
- package/dist/sql/03.optional_rds.sql +0 -6
- package/dist/sql/04.optional_self_managed.sql +0 -8
- package/dist/sql/05.helpers.sql +0 -415
package/README.md
CHANGED
|
@@ -29,11 +29,10 @@ brew install postgresai
|
|
|
29
29
|
|
|
30
30
|
## Usage
|
|
31
31
|
|
|
32
|
-
The `postgresai` package provides
|
|
32
|
+
The `postgresai` package provides two command aliases:
|
|
33
33
|
```bash
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
pgai --help
|
|
34
|
+
postgresai --help # Canonical, discoverable
|
|
35
|
+
pgai --help # Short and convenient
|
|
37
36
|
```
|
|
38
37
|
|
|
39
38
|
You can also run it without installing via `npx`:
|
|
@@ -126,17 +125,17 @@ This will:
|
|
|
126
125
|
|
|
127
126
|
Start monitoring with demo database:
|
|
128
127
|
```bash
|
|
129
|
-
|
|
128
|
+
postgresai mon local-install --demo
|
|
130
129
|
```
|
|
131
130
|
|
|
132
131
|
Start monitoring with your own database:
|
|
133
132
|
```bash
|
|
134
|
-
|
|
133
|
+
postgresai mon local-install --db-url postgresql://user:pass@host:5432/db
|
|
135
134
|
```
|
|
136
135
|
|
|
137
136
|
Complete automated setup with API key and database:
|
|
138
137
|
```bash
|
|
139
|
-
|
|
138
|
+
postgresai mon local-install --api-key your_key --db-url postgresql://user:pass@host:5432/db -y
|
|
140
139
|
```
|
|
141
140
|
|
|
142
141
|
This will:
|
|
@@ -153,19 +152,19 @@ This will:
|
|
|
153
152
|
#### Service lifecycle
|
|
154
153
|
```bash
|
|
155
154
|
# Complete setup with various options
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
|
162
161
|
|
|
163
162
|
# Service management
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
|
169
168
|
```
|
|
170
169
|
|
|
171
170
|
##### local-install options
|
|
@@ -176,21 +175,21 @@ postgres-ai mon health [--wait <sec>] # Check monitoring services health
|
|
|
176
175
|
|
|
177
176
|
#### Monitoring target databases (`mon targets` subgroup)
|
|
178
177
|
```bash
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
|
183
182
|
```
|
|
184
183
|
|
|
185
184
|
#### Configuration and maintenance
|
|
186
185
|
```bash
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
|
194
193
|
```
|
|
195
194
|
|
|
196
195
|
### MCP server (`mcp` group)
|
|
@@ -250,16 +249,16 @@ postgresai issues view <issueId> > issue.json
|
|
|
250
249
|
|
|
251
250
|
#### Grafana management
|
|
252
251
|
```bash
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
postgresai mon generate-grafana-password # Generate new Grafana password
|
|
253
|
+
postgresai mon show-grafana-credentials # Show Grafana credentials
|
|
255
254
|
```
|
|
256
255
|
|
|
257
256
|
### Authentication and API key management
|
|
258
257
|
```bash
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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
|
|
263
262
|
```
|
|
264
263
|
|
|
265
264
|
## Configuration
|
|
@@ -304,17 +303,24 @@ Normalization:
|
|
|
304
303
|
|
|
305
304
|
### Examples
|
|
306
305
|
|
|
307
|
-
|
|
306
|
+
For production (uses default URLs):
|
|
308
307
|
|
|
309
308
|
```bash
|
|
309
|
+
# Production auth - uses console.postgres.ai by default
|
|
310
|
+
postgresai auth --debug
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
For staging/development environments:
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
# Linux/macOS (bash/zsh)
|
|
310
317
|
export PGAI_API_BASE_URL=https://v2.postgres.ai/api/general/
|
|
311
318
|
export PGAI_UI_BASE_URL=https://console-dev.postgres.ai
|
|
312
319
|
postgresai auth --debug
|
|
313
320
|
```
|
|
314
321
|
|
|
315
|
-
Windows PowerShell:
|
|
316
|
-
|
|
317
322
|
```powershell
|
|
323
|
+
# Windows PowerShell
|
|
318
324
|
$env:PGAI_API_BASE_URL = "https://v2.postgres.ai/api/general/"
|
|
319
325
|
$env:PGAI_UI_BASE_URL = "https://console-dev.postgres.ai"
|
|
320
326
|
postgresai auth --debug
|
|
@@ -331,6 +337,27 @@ postgresai auth --debug \
|
|
|
331
337
|
Notes:
|
|
332
338
|
- If `PGAI_UI_BASE_URL` is not set, the default is `https://console.postgres.ai`.
|
|
333
339
|
|
|
340
|
+
## Development
|
|
341
|
+
|
|
342
|
+
### Testing
|
|
343
|
+
|
|
344
|
+
The CLI uses [Bun](https://bun.sh/) as the test runner with built-in coverage reporting.
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
# Run tests with coverage (default)
|
|
348
|
+
bun run test
|
|
349
|
+
|
|
350
|
+
# Run tests without coverage (faster iteration during development)
|
|
351
|
+
bun run test:fast
|
|
352
|
+
|
|
353
|
+
# Run tests with coverage and show report location
|
|
354
|
+
bun run test:coverage
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
Coverage configuration is in `bunfig.toml`. Reports are generated in `coverage/` directory:
|
|
358
|
+
- `coverage/lcov-report/index.html` - HTML coverage report
|
|
359
|
+
- `coverage/lcov.info` - LCOV format for CI integration
|
|
360
|
+
|
|
334
361
|
## Requirements
|
|
335
362
|
|
|
336
363
|
- Node.js 18 or higher
|