postgresai 0.11.0-alpha.8 → 0.12.0-alpha.13

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 CHANGED
@@ -4,10 +4,22 @@ Command-line interface for PostgresAI monitoring and database management.
4
4
 
5
5
  ## Installation
6
6
 
7
+ ### From npm
8
+
7
9
  ```bash
8
10
  npm install -g postgresai@alpha
9
11
  ```
10
12
 
13
+ ### From Homebrew (macOS)
14
+
15
+ ```bash
16
+ # Add the PostgresAI tap
17
+ brew tap postgres-ai/tap https://gitlab.com/postgres-ai/homebrew-tap.git
18
+
19
+ # Install postgresai
20
+ brew install postgresai
21
+ ```
22
+
11
23
  ## Usage
12
24
 
13
25
  The CLI provides three command aliases:
@@ -19,9 +31,23 @@ pgai --help # short alias
19
31
 
20
32
  ## Quick start
21
33
 
34
+ ### Authentication
35
+
36
+ Authenticate via browser to obtain API key:
37
+ ```bash
38
+ pgai auth
39
+ ```
40
+
41
+ This will:
42
+ - Open your browser for authentication
43
+ - Prompt you to select an organization
44
+ - Automatically save your API key to `~/.config/postgresai/config.json`
45
+
46
+ ### Start monitoring
47
+
22
48
  Start monitoring with demo database:
23
49
  ```bash
24
- postgres-ai quickstart --demo
50
+ postgres-ai mon quickstart --demo
25
51
  ```
26
52
 
27
53
  This will:
@@ -31,40 +57,144 @@ This will:
31
57
 
32
58
  ## Commands
33
59
 
34
- ### Monitoring services
60
+ ### Monitoring services management (`mon` group)
61
+
62
+ #### Service lifecycle
35
63
  ```bash
36
- postgres-ai start # Start all services
37
- postgres-ai stop # Stop all services
38
- postgres-ai restart # Restart all services
39
- postgres-ai status # Show service status
40
- postgres-ai logs [service] # Show logs
64
+ postgres-ai mon quickstart [--demo] # Complete setup (generate config, start services)
65
+ postgres-ai mon start # Start monitoring services
66
+ postgres-ai mon stop # Stop monitoring services
67
+ postgres-ai mon restart [service] # Restart all or specific monitoring service
68
+ postgres-ai mon status # Show monitoring services status
69
+ postgres-ai mon health [--wait <sec>] # Check monitoring services health
41
70
  ```
42
71
 
43
- ### Instance management
72
+ #### Monitoring target databases (`mon targets` subgroup)
44
73
  ```bash
45
- postgres-ai list-instances # List configured instances
46
- postgres-ai add-instance <conn-string> <name> # Add new instance
47
- postgres-ai remove-instance <name> # Remove instance
48
- postgres-ai update-config # Regenerate config files
74
+ postgres-ai mon targets list # List databases to monitor
75
+ postgres-ai mon targets add <conn-string> <name> # Add database to monitor
76
+ postgres-ai mon targets remove <name> # Remove monitoring target
77
+ postgres-ai mon targets test <name> # Test target connectivity
49
78
  ```
50
79
 
51
- ### Configuration
80
+ #### Configuration and maintenance
52
81
  ```bash
53
- postgres-ai config # Show current configuration
54
- postgres-ai check # Verify prerequisites
82
+ postgres-ai mon config # Show monitoring configuration
83
+ postgres-ai mon update-config # Apply configuration changes
84
+ postgres-ai mon update # Update monitoring stack
85
+ postgres-ai mon reset [service] # Reset service data
86
+ postgres-ai mon clean # Cleanup artifacts
87
+ postgres-ai mon check # System readiness check
88
+ postgres-ai mon shell <service> # Open shell to monitoring service
55
89
  ```
56
90
 
57
- ### API key management
91
+ ### MCP server (`mcp` group)
92
+
58
93
  ```bash
59
- postgres-ai add-key <key> # Store API key
94
+ pgai mcp start # Start MCP stdio server exposing list_issues tool
95
+ ```
96
+
97
+ Cursor configuration example (Settings → MCP):
98
+
99
+ ```json
100
+ {
101
+ "mcpServers": {
102
+ "PostgresAI": {
103
+ "command": "pgai",
104
+ "args": ["mcp", "start"],
105
+ "env": {
106
+ "PGAI_API_BASE_URL": "https://postgres.ai/api/general/"
107
+ }
108
+ }
109
+ }
110
+ }
111
+ ```
112
+
113
+ Tools exposed:
114
+ - list_issues: returns the same JSON as `pgai issues list`.
115
+
116
+ #### Grafana management
117
+ ```bash
118
+ postgres-ai mon generate-grafana-password # Generate new Grafana password
119
+ postgres-ai mon show-grafana-credentials # Show Grafana credentials
120
+ ```
121
+
122
+ ### Authentication and API key management
123
+ ```bash
124
+ postgres-ai auth # Authenticate via browser (recommended)
125
+ postgres-ai add-key <key> # Manually store API key
60
126
  postgres-ai show-key # Show stored key (masked)
61
127
  postgres-ai remove-key # Remove stored key
62
128
  ```
63
129
 
64
- ## Environment variables
130
+ ## Configuration
131
+
132
+ The CLI stores configuration in `~/.config/postgresai/config.json` including:
133
+ - API key
134
+ - Base URL
135
+ - Organization ID
136
+
137
+ ### Configuration priority
138
+
139
+ API key resolution order:
140
+ 1. Command line option (`--api-key`)
141
+ 2. Environment variable (`PGAI_API_KEY`)
142
+ 3. User config file (`~/.config/postgresai/config.json`)
143
+ 4. Legacy project config (`.pgwatch-config`)
144
+
145
+ Base URL resolution order:
146
+ - API base URL (`apiBaseUrl`):
147
+ 1. Command line option (`--api-base-url`)
148
+ 2. Environment variable (`PGAI_API_BASE_URL`)
149
+ 3. User config file `baseUrl` (`~/.config/postgresai/config.json`)
150
+ 4. Default: `https://postgres.ai/api/general/`
151
+ - UI base URL (`uiBaseUrl`):
152
+ 1. Command line option (`--ui-base-url`)
153
+ 2. Environment variable (`PGAI_UI_BASE_URL`)
154
+ 3. Default: `https://console.postgres.ai`
155
+
156
+ Normalization:
157
+ - A single trailing `/` is removed to ensure consistent path joining.
158
+
159
+ ### Environment variables
65
160
 
66
161
  - `PGAI_API_KEY` - API key for PostgresAI services
67
- - `PGAI_BASE_URL` - API endpoint (default: `https://postgres.ai/api/general/`)
162
+ - `PGAI_API_BASE_URL` - API endpoint for backend RPC (default: `https://postgres.ai/api/general/`)
163
+ - `PGAI_UI_BASE_URL` - UI endpoint for browser routes (default: `https://console.postgres.ai`)
164
+
165
+ ### CLI options
166
+
167
+ - `--api-base-url <url>` - overrides `PGAI_API_BASE_URL`
168
+ - `--ui-base-url <url>` - overrides `PGAI_UI_BASE_URL`
169
+
170
+ ### Examples
171
+
172
+ Linux/macOS (bash/zsh):
173
+
174
+ ```bash
175
+ export PGAI_API_BASE_URL=https://v2.postgres.ai/api/general/
176
+ export PGAI_UI_BASE_URL=https://console.postgres.ai
177
+ pgai auth --debug
178
+ ```
179
+
180
+ Windows PowerShell:
181
+
182
+ ```powershell
183
+ $env:PGAI_API_BASE_URL = "https://v2.postgres.ai/api/general/"
184
+ $env:PGAI_UI_BASE_URL = "https://console.postgres.ai"
185
+ pgai auth --debug
186
+ ```
187
+
188
+ Via CLI options (overrides env):
189
+
190
+ ```bash
191
+ pgai auth --debug \
192
+ --api-base-url https://v2.postgres.ai/api/general/ \
193
+ --ui-base-url https://console.postgres.ai
194
+ ```
195
+
196
+ Notes:
197
+ - If `PGAI_UI_BASE_URL` is not set, the default is `https://console.postgres.ai`.
68
198
 
69
199
  ## Requirements
70
200