postgresai 0.14.0-beta.3 → 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 +45 -45
- package/bin/postgres-ai.ts +946 -336
- package/bun.lock +258 -0
- package/bunfig.toml +11 -0
- package/dist/bin/postgres-ai.js +27868 -1771
- 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 +282 -78
- 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 -75
- package/dist/lib/init.d.ts.map +0 -1
- package/dist/lib/init.js +0 -482
- 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 `postgresai` package provides two command aliases
|
|
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`:
|
|
@@ -49,26 +49,26 @@ If you want `npx pgai ...` as a shorthand for `npx postgresai ...`, install the
|
|
|
49
49
|
npx pgai --help
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
##
|
|
52
|
+
## prepare-db (create monitoring user in Postgres)
|
|
53
53
|
|
|
54
|
-
This command creates (or updates) the `postgres_ai_mon` user and grants the permissions described in the root `README.md` (it is idempotent).
|
|
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.
|
|
55
55
|
|
|
56
56
|
Run without installing (positional connection string):
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
npx postgresai
|
|
59
|
+
npx postgresai prepare-db postgresql://admin@host:5432/dbname
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
It also accepts libpq
|
|
62
|
+
It also accepts libpq "conninfo" syntax:
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
|
-
npx postgresai
|
|
65
|
+
npx postgresai prepare-db "dbname=dbname host=host user=admin"
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
And psql-like options:
|
|
69
69
|
|
|
70
70
|
```bash
|
|
71
|
-
npx postgresai
|
|
71
|
+
npx postgresai prepare-db -h host -p 5432 -U admin -d dbname
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
Password input options (in priority order):
|
|
@@ -82,7 +82,7 @@ By default, the generated password is printed **only in interactive (TTY) mode**
|
|
|
82
82
|
Optional permissions (RDS/self-managed extras from the root `README.md`) are enabled by default. To skip them:
|
|
83
83
|
|
|
84
84
|
```bash
|
|
85
|
-
npx postgresai
|
|
85
|
+
npx postgresai prepare-db postgresql://admin@host:5432/dbname --skip-optional-permissions
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
### Print SQL / dry run
|
|
@@ -90,7 +90,7 @@ npx postgresai init postgresql://admin@host:5432/dbname --skip-optional-permissi
|
|
|
90
90
|
To see what SQL would be executed (passwords redacted by default):
|
|
91
91
|
|
|
92
92
|
```bash
|
|
93
|
-
npx postgresai
|
|
93
|
+
npx postgresai prepare-db postgresql://admin@host:5432/dbname --print-sql
|
|
94
94
|
```
|
|
95
95
|
|
|
96
96
|
### Verify and password reset
|
|
@@ -98,13 +98,13 @@ npx postgresai init postgresql://admin@host:5432/dbname --print-sql
|
|
|
98
98
|
Verify that everything is configured as expected (no changes):
|
|
99
99
|
|
|
100
100
|
```bash
|
|
101
|
-
npx postgresai
|
|
101
|
+
npx postgresai prepare-db postgresql://admin@host:5432/dbname --verify
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
Reset monitoring user password only (no other changes):
|
|
105
105
|
|
|
106
106
|
```bash
|
|
107
|
-
npx postgresai
|
|
107
|
+
npx postgresai prepare-db postgresql://admin@host:5432/dbname --reset-password --password 'new_password'
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
## Quick start
|
|
@@ -125,17 +125,17 @@ This will:
|
|
|
125
125
|
|
|
126
126
|
Start monitoring with demo database:
|
|
127
127
|
```bash
|
|
128
|
-
|
|
128
|
+
postgresai mon local-install --demo
|
|
129
129
|
```
|
|
130
130
|
|
|
131
131
|
Start monitoring with your own database:
|
|
132
132
|
```bash
|
|
133
|
-
|
|
133
|
+
postgresai mon local-install --db-url postgresql://user:pass@host:5432/db
|
|
134
134
|
```
|
|
135
135
|
|
|
136
136
|
Complete automated setup with API key and database:
|
|
137
137
|
```bash
|
|
138
|
-
|
|
138
|
+
postgresai mon local-install --api-key your_key --db-url postgresql://user:pass@host:5432/db -y
|
|
139
139
|
```
|
|
140
140
|
|
|
141
141
|
This will:
|
|
@@ -152,22 +152,22 @@ This will:
|
|
|
152
152
|
#### Service lifecycle
|
|
153
153
|
```bash
|
|
154
154
|
# Complete setup with various options
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
|
161
161
|
|
|
162
162
|
# Service management
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
|
168
168
|
```
|
|
169
169
|
|
|
170
|
-
#####
|
|
170
|
+
##### local-install options
|
|
171
171
|
- `--demo` - Demo mode with sample database (testing only, cannot use with --api-key)
|
|
172
172
|
- `--api-key <key>` - Postgres AI API key for automated report uploads
|
|
173
173
|
- `--db-url <url>` - PostgreSQL connection URL to monitor (format: `postgresql://user:pass@host:port/db`)
|
|
@@ -175,21 +175,21 @@ postgres-ai mon health [--wait <sec>] # Check monitoring services health
|
|
|
175
175
|
|
|
176
176
|
#### Monitoring target databases (`mon targets` subgroup)
|
|
177
177
|
```bash
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
|
182
182
|
```
|
|
183
183
|
|
|
184
184
|
#### Configuration and maintenance
|
|
185
185
|
```bash
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
|
193
193
|
```
|
|
194
194
|
|
|
195
195
|
### MCP server (`mcp` group)
|
|
@@ -249,16 +249,16 @@ postgresai issues view <issueId> > issue.json
|
|
|
249
249
|
|
|
250
250
|
#### Grafana management
|
|
251
251
|
```bash
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
postgresai mon generate-grafana-password # Generate new Grafana password
|
|
253
|
+
postgresai mon show-grafana-credentials # Show Grafana credentials
|
|
254
254
|
```
|
|
255
255
|
|
|
256
256
|
### Authentication and API key management
|
|
257
257
|
```bash
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
|
262
262
|
```
|
|
263
263
|
|
|
264
264
|
## Configuration
|