Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
fb37dab
refactor: derive D004, F001, G001 reports from A003 settings data
claude Dec 24, 2025
358ea9d
fix: extract PG version from A003 settings data (server_version_num)
claude Dec 24, 2025
1b07560
feat: add express checkup CLI command
claude Dec 25, 2025
53091db
test: add unit tests for express checkup command
claude Dec 25, 2025
5b4d5c1
feat: add A004 (Cluster info) and A007 (Altered settings) to express …
claude Dec 25, 2025
e0c869f
feat: add TTY spinner and output directory options to checkup command
bogdan-ts Dec 25, 2025
5522e94
feat: Add default project config and `set-default-project` CLI command
bogdan-ts Dec 25, 2025
44e6b2c
feat: Add checkup upload functionality to CLI
bogdan-ts Dec 25, 2025
8c53bda
feat: Include build_ts and version in reports
bogdan-ts Dec 25, 2025
46238ee
chore: Add initial checkup reports
bogdan-ts Dec 25, 2025
8991a3c
feat(cli): improve checkup UX and uploads
bogdan-ts Dec 25, 2025
0b0e969
fix(cli): simplify upload summary output
bogdan-ts Dec 25, 2025
13ae212
fix issue generating
bogdan-ts Dec 25, 2025
03495a7
refactor(cli): make JSON output default for checkup command
NikolayS Dec 25, 2025
15b88ce
feat(checkup): upload default and auto project
bogdan-ts Dec 26, 2025
50bf0da
fix(auth): reset org/project on key change
bogdan-ts Dec 26, 2025
332a4a1
fix(checkup): make --json disable upload
bogdan-ts Dec 26, 2025
6aa2f6c
feat(cli): add express reporting for H001, H002, H003 index checks
NikolayS Dec 26, 2025
eaf9428
fix: add missing crypto import and resolve rebase conflicts
NikolayS Dec 26, 2025
92075f6
feat(cli): add H004 redundant indexes express report
NikolayS Dec 26, 2025
872fda7
chore(cli): remove test report data
NikolayS Dec 26, 2025
5def3f2
feat(reporter): add H003 non-indexed foreign keys schema
NikolayS Dec 26, 2025
8eb8e44
chore: remove unused tools directory
NikolayS Dec 26, 2025
2c1ed98
refactor(cli): migrate tests to TypeScript, remove H003
NikolayS Dec 26, 2025
507b61b
fix(cli): align H001, H002, H004 reports with JSON schemas
NikolayS Dec 26, 2025
8d9983f
test(cli): add JSON schema validation tests for H001, H002, H004
NikolayS Dec 26, 2025
f6fc8cd
refactor(reporter): remove unused markdown generation code
NikolayS Dec 26, 2025
5e9ea92
docs(reporter): clarify scope - JSON Observations only
NikolayS Dec 26, 2025
4f017d0
style(cli): use lowercase SQL keywords per style guide
NikolayS Dec 26, 2025
dfcac40
refactor(cli): remove deprecated epoch parameter from API calls
NikolayS Dec 26, 2025
d94a82b
refactor(cli): load H001/H002/H004 SQL from metrics.yml
NikolayS Dec 26, 2025
5986640
refactor(cli): load all express report SQL from metrics.yml
NikolayS Dec 26, 2025
4731849
refactor(cli): remove METRICS_SQL export completely
NikolayS Dec 26, 2025
7b6d745
docs(cli): document architectural decisions for express checkup
NikolayS Dec 26, 2025
a95f2ac
fix(tests): add missing report codes to expected_report_codes
NikolayS Dec 26, 2025
a153c78
style(cli): use IEC binary units (KiB, MiB, GiB) in formatBytes
NikolayS Dec 26, 2025
afef7e5
fix(test): increase timeout for integration tests
NikolayS Dec 26, 2025
dfff0ef
feat(checkup): add D004, F001, G001 express reports
NikolayS Dec 26, 2025
179700f
fix(checkup): embed SQL queries directly in CLI
NikolayS Dec 26, 2025
ce70873
fix(cli): restore js-yaml dependency
NikolayS Dec 26, 2025
87d95b0
fix(cli): commit bun.lock with js-yaml
NikolayS Dec 26, 2025
817670c
feat(H004): add covering_indexes array with definitions
NikolayS Dec 26, 2025
70179a3
feat: add generation_mode field to all report JSONs
NikolayS Dec 26, 2025
232bb4b
fix(auth): preserve defaultProject on re-authentication
NikolayS Dec 26, 2025
a6491dd
refactor(H004): rename covering_indexes to main_indexes
NikolayS Dec 26, 2025
5c6bd27
refactor(H004): rename main_indexes to redundant_to
NikolayS Dec 26, 2025
0d97d6d
feat(H004): add index sizes to redundant_to array
NikolayS Dec 26, 2025
12f7406
fix: address code review blockers
NikolayS Dec 26, 2025
1bbae7e
fix: address high-priority code review feedback
NikolayS Dec 26, 2025
b24bf00
refactor(cli): embed metrics.yml at build time, remove express_* dupl…
NikolayS Dec 26, 2025
2e22cde
refactor(metrics): add setting_normalized and unit_normalized to sett…
NikolayS Dec 26, 2025
39af571
fix(cli): log errors instead of silent swallowing in report generators
NikolayS Dec 27, 2025
28db9ba
fix(cli): log warning when redundant_to_json parsing fails in H004
NikolayS Dec 27, 2025
596c790
feat(cli): add retry logic with exponential backoff for uploads
NikolayS Dec 27, 2025
799f80b
refactor(cli): remove postgres-ai binary, keep postgresai and pgai
NikolayS Dec 27, 2025
4cc0441
feat(cli): add postgres-ai wrapper package for npm discoverability
NikolayS Dec 27, 2025
1c1cdb7
fix(cli): correct G003 typo to G001 in memory error log message
NikolayS Dec 27, 2025
c349c92
refactor(cli): replace magic numbers with named time constants
NikolayS Dec 27, 2025
209816b
refactor(cli): use AbortController for HTTP timeout handling
NikolayS Dec 27, 2025
413a890
fix(cli): add logging/documentation to empty catch blocks
NikolayS Dec 27, 2025
2554a8f
fix(cli): replace non-null assertion with optional chaining in spinner
NikolayS Dec 27, 2025
e8cfd8b
fix(cli): address low priority code quality issues
NikolayS Dec 27, 2025
8ef5bb8
refactor(cli): consolidate redundant tests
NikolayS Dec 27, 2025
004085a
refactor(cli): consolidate test files to reduce duplication
NikolayS Dec 27, 2025
bc6f5cb
Merge origin/main into claude/express-checkup-cli-DBMWi
NikolayS Dec 27, 2025
6c0275b
test(cli): add integration tests for express mode schema compatibility
NikolayS Dec 27, 2025
d7cc23e
fix(reporter): add generation_mode to K008 schema and fix test
NikolayS Dec 27, 2025
6b4ad84
fix(cli): align MetricDefinition.sqls type to Record<number, string>
NikolayS Dec 27, 2025
0293155
fix(cli): clear spinner interval before setting stopped flag
NikolayS Dec 27, 2025
c55b1e2
fix(cli): add type guard for redundant_to_json parsing
NikolayS Dec 27, 2025
6be75e2
fix(cli): make database name configurable in mock client
NikolayS Dec 27, 2025
8661b18
fix(cli): use console.warn for unexpected errors in resolveBuildTs
NikolayS Dec 27, 2025
6a9d0e3
fix(cli): prevent resource leaks in HTTP timeout handling
NikolayS Dec 27, 2025
0c26cd0
docs(cli): document error handling strategy in checkup module
NikolayS Dec 27, 2025
e21bab1
fix(cli): replace magic numbers with named constants in time formatting
NikolayS Dec 27, 2025
8cf3f18
refactor(cli): remove duplicate createMockClient, use shared test-utils
NikolayS Dec 27, 2025
cc9993f
fix(ci): use 'bun run test' to generate metrics-embedded.ts before tests
NikolayS Dec 27, 2025
d5badde
refactor(cli): address code review feedback
NikolayS Dec 27, 2025
a43e629
fix(cli): move spinner cleanup to finally block
NikolayS Dec 27, 2025
8695941
refactor(cli): use JSON.stringify for SQL escaping in embed-metrics
NikolayS Dec 27, 2025
632daa4
fix(cli): clear HTTP timeout when response starts
NikolayS Dec 27, 2025
86d1c74
feat(cli): include parse error in H004 redundant index output
NikolayS Dec 27, 2025
d8ccdb0
feat(cli): include postmaster startup error in H002 output
NikolayS Dec 27, 2025
4aa46ad
feat(cli): capture postmaster startup errors in H002 output
NikolayS Dec 27, 2025
29a87a2
refactor(cli): use toBool helper for consistent boolean conversion
NikolayS Dec 27, 2025
739ce0a
test(cli): add timeout/retry tests and CI skip warnings
NikolayS Dec 27, 2025
d1d5960
docs(cli): improve JSDoc and clarify API key usage
NikolayS Dec 27, 2025
ee0c3ac
refactor(cli): unify report generators with helper functions
NikolayS Dec 27, 2025
a70f68a
fix(cli): set stopped flag before clearInterval in spinner
NikolayS Dec 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ cli/**/*.js.map
cli/**/*.d.ts
cli/**/*.d.ts.map
!cli/jest.config.js
!cli/packages/postgres-ai/bin/postgres-ai.js

# Generated at build time from metrics.yml
cli/lib/metrics-embedded.ts

# Generated config files (these are created by the sources-generator)
config/pgwatch-postgres/sources.yml
Expand Down
3 changes: 2 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ cli:node:tests:
- su - pgtest -c "curl -fsSL https://bun.sh/install | bash"
- su - pgtest -c "cd \"$CI_PROJECT_DIR/cli\" && export PATH=\"\$HOME/.bun/bin:\$PATH\" && bun install"
script:
- su - pgtest -c "cd \"$CI_PROJECT_DIR/cli\" && export PATH=\"\$HOME/.bun/bin:\$PATH\" && bun test"
# Use 'bun run test' (not 'bun test') to invoke the npm script which generates metrics-embedded.ts first
- su - pgtest -c "cd \"$CI_PROJECT_DIR/cli\" && export PATH=\"\$HOME/.bun/bin:\$PATH\" && bun run test"
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'

Expand Down
69 changes: 34 additions & 35 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ brew install postgresai

## Usage

The `postgresai` package provides three command aliases (prefer `postgresai`):
The `postgresai` package provides two command aliases:
```bash
postgres-ai --help
postgresai --help
pgai --help
postgresai --help # Canonical, discoverable
pgai --help # Short and convenient
```

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

Start monitoring with demo database:
```bash
postgres-ai mon local-install --demo
postgresai mon local-install --demo
```

Start monitoring with your own database:
```bash
postgres-ai mon local-install --db-url postgresql://user:pass@host:5432/db
postgresai mon local-install --db-url postgresql://user:pass@host:5432/db
```

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

This will:
Expand All @@ -153,19 +152,19 @@ This will:
#### Service lifecycle
```bash
# Complete setup with various options
postgres-ai mon local-install # Interactive setup for production
postgres-ai mon local-install --demo # Demo mode with sample database
postgres-ai mon local-install --api-key <key> # Setup with API key
postgres-ai mon local-install --db-url <url> # Setup with database URL
postgres-ai mon local-install --api-key <key> --db-url <url> # Complete automated setup
postgres-ai mon local-install -y # Auto-accept all defaults
postgresai mon local-install # Interactive setup for production
postgresai mon local-install --demo # Demo mode with sample database
postgresai mon local-install --api-key <key> # Setup with API key
postgresai mon local-install --db-url <url> # Setup with database URL
postgresai mon local-install --api-key <key> --db-url <url> # Complete automated setup
postgresai mon local-install -y # Auto-accept all defaults

# Service management
postgres-ai mon start # Start monitoring services
postgres-ai mon stop # Stop monitoring services
postgres-ai mon restart [service] # Restart all or specific monitoring service
postgres-ai mon status # Show monitoring services status
postgres-ai mon health [--wait <sec>] # Check monitoring services health
postgresai mon start # Start monitoring services
postgresai mon stop # Stop monitoring services
postgresai mon restart [service] # Restart all or specific monitoring service
postgresai mon status # Show monitoring services status
postgresai mon health [--wait <sec>] # Check monitoring services health
```

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

#### Monitoring target databases (`mon targets` subgroup)
```bash
postgres-ai mon targets list # List databases to monitor
postgres-ai mon targets add <conn-string> <name> # Add database to monitor
postgres-ai mon targets remove <name> # Remove monitoring target
postgres-ai mon targets test <name> # Test target connectivity
postgresai mon targets list # List databases to monitor
postgresai mon targets add <conn-string> <name> # Add database to monitor
postgresai mon targets remove <name> # Remove monitoring target
postgresai mon targets test <name> # Test target connectivity
```

#### Configuration and maintenance
```bash
postgres-ai mon config # Show monitoring configuration
postgres-ai mon update-config # Apply configuration changes
postgres-ai mon update # Update monitoring stack
postgres-ai mon reset [service] # Reset service data
postgres-ai mon clean # Cleanup artifacts
postgres-ai mon check # System readiness check
postgres-ai mon shell <service> # Open shell to monitoring service
postgresai mon config # Show monitoring configuration
postgresai mon update-config # Apply configuration changes
postgresai mon update # Update monitoring stack
postgresai mon reset [service] # Reset service data
postgresai mon clean # Cleanup artifacts
postgresai mon check # System readiness check
postgresai mon shell <service> # Open shell to monitoring service
```

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

#### Grafana management
```bash
postgres-ai mon generate-grafana-password # Generate new Grafana password
postgres-ai mon show-grafana-credentials # Show Grafana credentials
postgresai mon generate-grafana-password # Generate new Grafana password
postgresai mon show-grafana-credentials # Show Grafana credentials
```

### Authentication and API key management
```bash
postgres-ai auth # Authenticate via browser (OAuth)
postgres-ai auth --set-key <key> # Store API key directly
postgres-ai show-key # Show stored key (masked)
postgres-ai remove-key # Remove stored key
postgresai auth # Authenticate via browser (OAuth)
postgresai auth --set-key <key> # Store API key directly
postgresai show-key # Show stored key (masked)
postgresai remove-key # Remove stored key
```

## Configuration
Expand Down
Loading