Skip to content

Commit 7a94386

Browse files
committed
feat(cli): add express checkup command with direct PostgreSQL health checks + fix H004 and A003
1 parent 9f47244 commit 7a94386

47 files changed

Lines changed: 4491 additions & 84 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ cli/**/*.js.map
5858
cli/**/*.d.ts
5959
cli/**/*.d.ts.map
6060
!cli/jest.config.js
61+
!cli/packages/postgres-ai/bin/postgres-ai.js
62+
63+
# Generated at build time from metrics.yml
64+
cli/lib/metrics-embedded.ts
6165

6266
# Generated config files (these are created by the sources-generator)
6367
config/pgwatch-postgres/sources.yml

.gitlab-ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ cli:node:tests:
217217
- su - pgtest -c "curl -fsSL https://bun.sh/install | bash"
218218
- su - pgtest -c "cd \"$CI_PROJECT_DIR/cli\" && export PATH=\"\$HOME/.bun/bin:\$PATH\" && bun install"
219219
script:
220-
- su - pgtest -c "cd \"$CI_PROJECT_DIR/cli\" && export PATH=\"\$HOME/.bun/bin:\$PATH\" && bun test"
220+
# Use 'bun run test' (not 'bun test') to invoke the npm script which generates metrics-embedded.ts first
221+
- su - pgtest -c "cd \"$CI_PROJECT_DIR/cli\" && export PATH=\"\$HOME/.bun/bin:\$PATH\" && bun run test"
221222
rules:
222223
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
223224

cli/README.md

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ brew install postgresai
2929

3030
## Usage
3131

32-
The `postgresai` package provides three command aliases (prefer `postgresai`):
32+
The `postgresai` package provides two command aliases:
3333
```bash
34-
postgres-ai --help
35-
postgresai --help
36-
pgai --help
34+
postgresai --help # Canonical, discoverable
35+
pgai --help # Short and convenient
3736
```
3837

3938
You can also run it without installing via `npx`:
@@ -126,17 +125,17 @@ This will:
126125

127126
Start monitoring with demo database:
128127
```bash
129-
postgres-ai mon local-install --demo
128+
postgresai mon local-install --demo
130129
```
131130

132131
Start monitoring with your own database:
133132
```bash
134-
postgres-ai mon local-install --db-url postgresql://user:pass@host:5432/db
133+
postgresai mon local-install --db-url postgresql://user:pass@host:5432/db
135134
```
136135

137136
Complete automated setup with API key and database:
138137
```bash
139-
postgres-ai mon local-install --api-key your_key --db-url postgresql://user:pass@host:5432/db -y
138+
postgresai mon local-install --api-key your_key --db-url postgresql://user:pass@host:5432/db -y
140139
```
141140

142141
This will:
@@ -153,19 +152,19 @@ This will:
153152
#### Service lifecycle
154153
```bash
155154
# Complete setup with various options
156-
postgres-ai mon local-install # Interactive setup for production
157-
postgres-ai mon local-install --demo # Demo mode with sample database
158-
postgres-ai mon local-install --api-key <key> # Setup with API key
159-
postgres-ai mon local-install --db-url <url> # Setup with database URL
160-
postgres-ai mon local-install --api-key <key> --db-url <url> # Complete automated setup
161-
postgres-ai mon local-install -y # Auto-accept all defaults
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
162161

163162
# Service management
164-
postgres-ai mon start # Start monitoring services
165-
postgres-ai mon stop # Stop monitoring services
166-
postgres-ai mon restart [service] # Restart all or specific monitoring service
167-
postgres-ai mon status # Show monitoring services status
168-
postgres-ai mon health [--wait <sec>] # Check monitoring services health
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
169168
```
170169

171170
##### local-install options
@@ -176,21 +175,21 @@ postgres-ai mon health [--wait <sec>] # Check monitoring services health
176175

177176
#### Monitoring target databases (`mon targets` subgroup)
178177
```bash
179-
postgres-ai mon targets list # List databases to monitor
180-
postgres-ai mon targets add <conn-string> <name> # Add database to monitor
181-
postgres-ai mon targets remove <name> # Remove monitoring target
182-
postgres-ai mon targets test <name> # Test target connectivity
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
183182
```
184183

185184
#### Configuration and maintenance
186185
```bash
187-
postgres-ai mon config # Show monitoring configuration
188-
postgres-ai mon update-config # Apply configuration changes
189-
postgres-ai mon update # Update monitoring stack
190-
postgres-ai mon reset [service] # Reset service data
191-
postgres-ai mon clean # Cleanup artifacts
192-
postgres-ai mon check # System readiness check
193-
postgres-ai mon shell <service> # Open shell to monitoring service
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
194193
```
195194

196195
### MCP server (`mcp` group)
@@ -250,16 +249,16 @@ postgresai issues view <issueId> > issue.json
250249

251250
#### Grafana management
252251
```bash
253-
postgres-ai mon generate-grafana-password # Generate new Grafana password
254-
postgres-ai mon show-grafana-credentials # Show Grafana credentials
252+
postgresai mon generate-grafana-password # Generate new Grafana password
253+
postgresai mon show-grafana-credentials # Show Grafana credentials
255254
```
256255

257256
### Authentication and API key management
258257
```bash
259-
postgres-ai auth # Authenticate via browser (OAuth)
260-
postgres-ai auth --set-key <key> # Store API key directly
261-
postgres-ai show-key # Show stored key (masked)
262-
postgres-ai remove-key # Remove stored key
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
263262
```
264263

265264
## Configuration

0 commit comments

Comments
 (0)