postgresai 0.11.0-alpha.1 → 0.11.0-alpha.11

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
@@ -1,31 +1,168 @@
1
- ## CLI developer quickstart
1
+ # PostgresAI CLI
2
+
3
+ Command-line interface for PostgresAI monitoring and database management.
4
+
5
+ ## Installation
6
+
7
+ ### From npm
2
8
 
3
- ### run without install
4
9
  ```bash
5
- npm --prefix cli install --no-audit --no-fund
6
- node ./cli/bin/postgres-ai.js --help
10
+ npm install -g postgresai@alpha
7
11
  ```
8
12
 
9
- ### use aliases locally (no ./)
13
+ ### From Homebrew (macOS)
14
+
10
15
  ```bash
11
- # install from repo into global prefix
12
- npm install -g ./cli
16
+ # Add the PostgresAI tap
17
+ brew tap postgres-ai/tap https://gitlab.com/postgres-ai/homebrew-tap.git
13
18
 
14
- # ensure global npm bin is in PATH (zsh)
15
- echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.zshrc
16
- exec zsh -l
19
+ # Install postgresai
20
+ brew install postgresai
21
+ ```
22
+
23
+ ## Usage
17
24
 
18
- # aliases
25
+ The CLI provides three command aliases:
26
+ ```bash
19
27
  postgres-ai --help
20
- pgai --help
28
+ postgresai --help
29
+ pgai --help # short alias
30
+ ```
31
+
32
+ ## Quick start
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
+
48
+ Start monitoring with demo database:
49
+ ```bash
50
+ postgres-ai mon quickstart --demo
51
+ ```
52
+
53
+ This will:
54
+ - Generate secure Grafana password
55
+ - Start all monitoring services
56
+ - Open Grafana at http://localhost:3000
57
+
58
+ ## Commands
59
+
60
+ ### Monitoring services management (`mon` group)
61
+
62
+ #### Service lifecycle
63
+ ```bash
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
21
70
  ```
22
71
 
23
- ### one‑off run (no install)
72
+ #### Monitoring target databases (`mon targets` subgroup)
24
73
  ```bash
25
- npx -y -p file:cli postgres-ai --help
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
26
78
  ```
27
79
 
28
- ### env vars for integration tests
29
- - `PGAI_API_KEY`
30
- - `PGAI_BASE_URL` (default `https://v2.postgres.ai/api/general/`)
80
+ #### Configuration and maintenance
81
+ ```bash
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
89
+ ```
90
+
91
+ #### Grafana management
92
+ ```bash
93
+ postgres-ai mon generate-grafana-password # Generate new Grafana password
94
+ postgres-ai mon show-grafana-credentials # Show Grafana credentials
95
+ ```
96
+
97
+ ### Authentication and API key management
98
+ ```bash
99
+ postgres-ai auth # Authenticate via browser (recommended)
100
+ postgres-ai add-key <key> # Manually store API key
101
+ postgres-ai show-key # Show stored key (masked)
102
+ postgres-ai remove-key # Remove stored key
103
+ ```
104
+
105
+ ## Configuration
106
+
107
+ The CLI stores configuration in `~/.config/postgresai/config.json` including:
108
+ - API key
109
+ - Base URL
110
+ - Organization ID
111
+
112
+ ### Configuration priority
113
+
114
+ API key resolution order:
115
+ 1. Command line option (`--api-key`)
116
+ 2. Environment variable (`PGAI_API_KEY`)
117
+ 3. User config file (`~/.config/postgresai/config.json`)
118
+ 4. Legacy project config (`.pgwatch-config`)
119
+
120
+ ### Environment variables
121
+
122
+ - `PGAI_API_KEY` - API key for PostgresAI services
123
+ - `PGAI_API_BASE_URL` - API endpoint for backend RPC (default: `https://postgres.ai/api/general/`)
124
+ - `PGAI_UI_BASE_URL` - UI endpoint for browser routes (default: `https://console.postgres.ai`)
125
+
126
+ ### CLI options
127
+
128
+ - `--api-base-url <url>` - overrides `PGAI_API_BASE_URL`
129
+ - `--ui-base-url <url>` - overrides `PGAI_UI_BASE_URL`
130
+
131
+ ### Examples
132
+
133
+ Linux/macOS (bash/zsh):
134
+
135
+ ```bash
136
+ export PGAI_API_BASE_URL=https://v2.postgres.ai/api/general/
137
+ export PGAI_UI_BASE_URL=https://console.postgres.ai
138
+ pgai auth --debug
139
+ ```
140
+
141
+ Windows PowerShell:
142
+
143
+ ```powershell
144
+ $env:PGAI_API_BASE_URL = "https://v2.postgres.ai/api/general/"
145
+ $env:PGAI_UI_BASE_URL = "https://console.postgres.ai"
146
+ pgai auth --debug
147
+ ```
148
+
149
+ Via CLI options (overrides env):
150
+
151
+ ```bash
152
+ pgai auth --debug \
153
+ --api-base-url https://v2.postgres.ai/api/general/ \
154
+ --ui-base-url https://console.postgres.ai
155
+ ```
156
+
157
+ Notes:
158
+ - If `PGAI_UI_BASE_URL` is not set, the default is `https://console.postgres.ai`.
159
+
160
+ ## Requirements
161
+
162
+ - Node.js 18 or higher
163
+ - Docker and Docker Compose
164
+
165
+ ## Learn more
31
166
 
167
+ - Documentation: https://postgres.ai/docs
168
+ - Issues: https://gitlab.com/postgres-ai/postgres_ai/-/issues