powerbase-cli 0.1.0__tar.gz

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.
Files changed (37) hide show
  1. powerbase_cli-0.1.0/PKG-INFO +318 -0
  2. powerbase_cli-0.1.0/README.md +310 -0
  3. powerbase_cli-0.1.0/pyproject.toml +24 -0
  4. powerbase_cli-0.1.0/setup.cfg +4 -0
  5. powerbase_cli-0.1.0/src/powerbase_cli/__init__.py +5 -0
  6. powerbase_cli-0.1.0/src/powerbase_cli/__main__.py +5 -0
  7. powerbase_cli-0.1.0/src/powerbase_cli/api.py +348 -0
  8. powerbase_cli-0.1.0/src/powerbase_cli/certs/powerbase-test-ca.pem +21 -0
  9. powerbase_cli-0.1.0/src/powerbase_cli/cli.py +7 -0
  10. powerbase_cli-0.1.0/src/powerbase_cli/commands/__init__.py +3 -0
  11. powerbase_cli-0.1.0/src/powerbase_cli/commands/agent.py +192 -0
  12. powerbase_cli-0.1.0/src/powerbase_cli/commands/auth.py +169 -0
  13. powerbase_cli-0.1.0/src/powerbase_cli/commands/branch.py +86 -0
  14. powerbase_cli-0.1.0/src/powerbase_cli/commands/config_cmd.py +73 -0
  15. powerbase_cli-0.1.0/src/powerbase_cli/commands/context.py +84 -0
  16. powerbase_cli-0.1.0/src/powerbase_cli/commands/database.py +129 -0
  17. powerbase_cli-0.1.0/src/powerbase_cli/commands/instance.py +81 -0
  18. powerbase_cli-0.1.0/src/powerbase_cli/commands/org.py +18 -0
  19. powerbase_cli-0.1.0/src/powerbase_cli/commands/parser.py +114 -0
  20. powerbase_cli-0.1.0/src/powerbase_cli/commands/publish.py +44 -0
  21. powerbase_cli-0.1.0/src/powerbase_cli/commands/sandbox.py +90 -0
  22. powerbase_cli-0.1.0/src/powerbase_cli/commands/shared.py +152 -0
  23. powerbase_cli-0.1.0/src/powerbase_cli/commands/sql.py +32 -0
  24. powerbase_cli-0.1.0/src/powerbase_cli/config.py +239 -0
  25. powerbase_cli-0.1.0/src/powerbase_cli/session.py +141 -0
  26. powerbase_cli-0.1.0/src/powerbase_cli/transport.py +130 -0
  27. powerbase_cli-0.1.0/src/powerbase_cli.egg-info/PKG-INFO +318 -0
  28. powerbase_cli-0.1.0/src/powerbase_cli.egg-info/SOURCES.txt +35 -0
  29. powerbase_cli-0.1.0/src/powerbase_cli.egg-info/dependency_links.txt +1 -0
  30. powerbase_cli-0.1.0/src/powerbase_cli.egg-info/entry_points.txt +2 -0
  31. powerbase_cli-0.1.0/src/powerbase_cli.egg-info/top_level.txt +1 -0
  32. powerbase_cli-0.1.0/tests/test_api.py +62 -0
  33. powerbase_cli-0.1.0/tests/test_cli_commands.py +168 -0
  34. powerbase_cli-0.1.0/tests/test_cli_help.py +111 -0
  35. powerbase_cli-0.1.0/tests/test_config.py +94 -0
  36. powerbase_cli-0.1.0/tests/test_session.py +182 -0
  37. powerbase_cli-0.1.0/tests/test_transport.py +183 -0
@@ -0,0 +1,318 @@
1
+ Metadata-Version: 2.4
2
+ Name: powerbase-cli
3
+ Version: 0.1.0
4
+ Summary: CLI for operating Powerbase console workflows
5
+ Author: Powerbase
6
+ Requires-Python: >=3.11
7
+ Description-Content-Type: text/markdown
8
+
9
+ # powerbase-cli
10
+
11
+ Python CLI for automating Powerbase console operations, with a command shape designed for Openclaw and other LLM agents.
12
+
13
+ ## What It Covers
14
+
15
+ `powerbase-cli` mirrors the main console workflows with a user-mode auth model:
16
+
17
+ - browser login bridge for CLI use
18
+ - local session persistence and refresh
19
+ - config and context management
20
+ - organizations, databases, instances, branches
21
+ - SQL execution
22
+ - publish diff and publish run
23
+ - sandbox file operations
24
+ - sandbox agent provider config, chat, and login workflows
25
+
26
+ The CLI is optimized for agent use:
27
+
28
+ - stable command groups
29
+ - `--help` explains parameter source and format
30
+ - `--json` is available for machine-readable output
31
+ - context can be saved so later commands need fewer flags
32
+
33
+ Database model:
34
+
35
+ - default path: `powerbase instance create` uses the managed Powerbase database flow
36
+ - advanced path: `powerbase database create --dsn ...` registers an existing external database connection for later use with `--database-id`
37
+ - `powerbase database create` does not provision a new physical database
38
+
39
+ ## Install And Run
40
+
41
+ Install from PyPI:
42
+
43
+ ```bash
44
+ python -m pip install powerbase-cli
45
+ powerbase --help
46
+ ```
47
+
48
+ From the repository root during development:
49
+
50
+ ```bash
51
+ pip install -e .
52
+ ```
53
+
54
+ Or run directly during development:
55
+
56
+ ```bash
57
+ PYTHONPATH=src python3 -m powerbase_cli --help
58
+ ```
59
+
60
+ ## Configuration Model
61
+
62
+ Values are resolved in this order:
63
+
64
+ 1. command flags
65
+ 2. environment variables
66
+ 3. `~/.config/powerbase/`
67
+ 4. built-in defaults
68
+
69
+ Default local files:
70
+
71
+ ```text
72
+ ~/.config/powerbase/
73
+ config.toml
74
+ auth.json
75
+ context.json
76
+ ```
77
+
78
+ Most users do not need environment variables.
79
+
80
+ Optional advanced overrides:
81
+ - `POWERBASE_ACCESS_TOKEN` and `POWERBASE_REFRESH_TOKEN` for non-browser or pre-issued login flows
82
+ - `POWERBASE_INSTANCE_ID`, `POWERBASE_ORG_ID`, and `POWERBASE_BRANCH` to prefill local context
83
+ - `POWERBASE_CONFIG_DIR` to isolate local state, for example in tests or E2E runs
84
+ - `POWERBASE_OUTPUT` to default to `json`
85
+
86
+ ## Authentication
87
+
88
+ ### Browser Login
89
+
90
+ The preferred flow is:
91
+
92
+ ```bash
93
+ powerbase auth login
94
+ ```
95
+
96
+ The CLI now includes a built-in `base_url` and `anon_key` default for this deployment. The test package also bundles this environment's self-signed CA certificate, so most users can start with browser login directly and only use flags or environment variables when overriding that default.
97
+
98
+ The bundled CA is a test-only convenience for the current self-signed deployment. After the console moves to a publicly trusted TLS certificate, remove the bundled CA fallback and package resource, then keep only the built-in `base_url` and `anon_key` defaults.
99
+
100
+ This will:
101
+
102
+ 1. request a CLI login session from Powerbase
103
+ 2. print a browser URL
104
+ 3. poll until browser approval or until `--timeout` elapses (default **300** seconds, five minutes)
105
+ 4. save the resulting session to `~/.config/powerbase/auth.json`
106
+
107
+ Use `--timeout 0` to wait without a time limit. Use a larger value if users need more than five minutes to complete login.
108
+ If an agent or wrapper script is coordinating the workflow, it is still helpful
109
+ to tell the user: after browser approval, return to the current session so the
110
+ remaining steps can continue.
111
+
112
+ ### Manual Token Import
113
+
114
+ Use this when browser login is not available in the current agent environment:
115
+
116
+ ```bash
117
+ powerbase auth token-set \
118
+ --access-token ACCESS_TOKEN \
119
+ --refresh-token REFRESH_TOKEN \
120
+ --expires-at 1760000000
121
+ ```
122
+
123
+ Use `--base-url` or `--anon-key` here only when you intentionally want to override the built-in deployment defaults.
124
+
125
+ ### Check Auth State
126
+
127
+ ```bash
128
+ powerbase auth status --json
129
+ ```
130
+
131
+ ### Refresh A Saved Session
132
+
133
+ ```bash
134
+ powerbase auth refresh --json
135
+ ```
136
+
137
+ ## Context Workflow
138
+
139
+ For repeated agent workflows, save the current org, instance, and branch:
140
+
141
+ ```bash
142
+ powerbase context use-org ORG_ID
143
+ powerbase context use-instance INSTANCE_ID
144
+ powerbase context use-branch main
145
+ powerbase context show --json
146
+ ```
147
+
148
+ After that, many commands can omit `--instance-id`.
149
+
150
+ ## Common Workflows
151
+
152
+ ### Discover Resources
153
+
154
+ ```bash
155
+ powerbase org list --json
156
+ powerbase database list --json
157
+ powerbase instance list --json
158
+ powerbase branch list --instance-id INSTANCE_ID --json
159
+ ```
160
+
161
+ ### Create An Instance With The Managed Database Flow
162
+
163
+ This is the default and recommended path:
164
+
165
+ ```bash
166
+ powerbase org list --json
167
+ powerbase instance create --name todo-app --org-id ORG_ID --json
168
+ ```
169
+
170
+ `instance create` returns when provisioning starts, not necessarily when every
171
+ dependent resource is immediately readable. If `instance get`, `branch list`, or
172
+ sandbox commands briefly say the instance is missing or partial, retry after a
173
+ short wait.
174
+
175
+ ### Register And Reuse An External Database Connection
176
+
177
+ Use this only when you intentionally want the advanced bring-your-own-database flow:
178
+
179
+ ```bash
180
+ powerbase database create --name todo-db --dsn "mysql://user:pass@host:3306/db" --db-type mysql --json
181
+ powerbase instance create --name todo-app --database-id DATABASE_ID --org-id ORG_ID --json
182
+ ```
183
+
184
+ Notes for the advanced path:
185
+
186
+ - `powerbase database create` registers a DSN in Powerbase; it does not create a physical database server
187
+ - DSN credentials are sensitive and are stored by the platform
188
+ - branch and preview workflows may require SeekDB-compatible database behavior, not just generic MySQL wire compatibility
189
+ - deleting a Powerbase database record does not delete the external database itself
190
+
191
+ ### Switch To An Instance And Branch
192
+
193
+ ```bash
194
+ powerbase context use-instance INSTANCE_ID
195
+ powerbase branch switch feature/demo --instance-id INSTANCE_ID --json
196
+ powerbase context use-branch feature/demo
197
+ ```
198
+
199
+ When you create a branch with a name like `feature/demo`, later delete or SQL
200
+ commands should prefer the normalized slug returned by the API, such as
201
+ `feature-demo`, instead of assuming the original input string is still valid.
202
+
203
+ ### Run SQL
204
+
205
+ Inline SQL:
206
+
207
+ ```bash
208
+ powerbase sql run --instance-id INSTANCE_ID --branch main --sql "SELECT 1" --json
209
+ ```
210
+
211
+ From a file:
212
+
213
+ ```bash
214
+ powerbase sql run --instance-id INSTANCE_ID --sql-file ./query.sql --json
215
+ ```
216
+
217
+ ### Publish
218
+
219
+ ```bash
220
+ powerbase publish diff --instance-id INSTANCE_ID --json
221
+ powerbase publish run --instance-id INSTANCE_ID --json
222
+ ```
223
+
224
+ ### Sandbox Files
225
+
226
+ ```bash
227
+ powerbase sandbox files tree --instance-id INSTANCE_ID --root / --json
228
+ powerbase sandbox files read --instance-id INSTANCE_ID /src/app.tsx --json
229
+ powerbase sandbox files upload --instance-id INSTANCE_ID ./local.txt --target-path /tmp --json
230
+ ```
231
+
232
+ ### Sandbox Agent Providers
233
+
234
+ ```bash
235
+ powerbase agent providers --instance-id INSTANCE_ID --json
236
+ powerbase agent status --instance-id INSTANCE_ID --provider cursor --json
237
+ powerbase agent login-url --instance-id INSTANCE_ID --provider cursor --json
238
+ ```
239
+
240
+ ### Sandbox Agent Chat And Config
241
+
242
+ Send one prompt to the sandbox agent and stream events as JSONL:
243
+
244
+ ```bash
245
+ powerbase branch switch feature/demo --instance-id INSTANCE_ID --json
246
+
247
+ powerbase agent chat \
248
+ --instance-id INSTANCE_ID \
249
+ --provider cursor \
250
+ --message "Build a todo app with create, complete, and delete actions." \
251
+ --stream-jsonl
252
+ ```
253
+
254
+ `agent chat` follows the sandbox's current branch for the automatic preview build. Use
255
+ `powerbase branch switch ...` first when you want the generated preview to land on a
256
+ feature branch. `powerbase context use-branch ...` only changes the local default value;
257
+ it does not switch the remote sandbox by itself.
258
+
259
+ Read and update opencode provider config:
260
+
261
+ ```bash
262
+ powerbase agent opencode-config get --instance-id INSTANCE_ID --json
263
+ powerbase agent opencode-config set --instance-id INSTANCE_ID --provider anthropic --api-key API_KEY --json
264
+ powerbase agent opencode-config delete --instance-id INSTANCE_ID --provider anthropic --json
265
+ ```
266
+
267
+ Replace the sandbox `opencode.json` file:
268
+
269
+ ```bash
270
+ powerbase agent opencode-json set --instance-id INSTANCE_ID --file ./opencode.json --json
271
+ ```
272
+
273
+ ## Openclaw Usage Notes
274
+
275
+ When Openclaw or another LLM agent uses `powerbase`:
276
+
277
+ - prefer `--json` on all commands
278
+ - run discovery commands before write operations
279
+ - set context for long multi-step tasks
280
+ - use `auth status` before workflows that assume login
281
+ - use `auth token-set` if browser login is not practical in the current environment
282
+ - remember that `--json` overrides a saved `config output text` setting for that command
283
+
284
+ Recommended agent sequence:
285
+
286
+ 1. `powerbase auth status --json`
287
+ 2. If unauthenticated, run `powerbase auth login` or `powerbase auth token-set`
288
+ 3. `powerbase context show --json`
289
+ 4. If no instance is selected, run `powerbase instance list --json`
290
+ 5. If no suitable instance exists, prefer `powerbase instance create --name ... --org-id ... --json`
291
+ 6. Use `powerbase database ...` only for the advanced bring-your-own-database path
292
+ 7. Set context with `powerbase context use-instance ...`
293
+ 8. If you want the sandbox agent preview on a non-main branch, run `powerbase branch switch ...`
294
+ 9. Continue with `branch`, `sql`, `publish`, `sandbox files`, or `agent` commands
295
+
296
+ ## Testing
297
+
298
+ Run the full CLI test suite:
299
+
300
+ ```bash
301
+ PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src python3 -m unittest discover -s tests -v
302
+ ```
303
+
304
+ Compile the modules:
305
+
306
+ ```bash
307
+ PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src python3 -m py_compile src/powerbase_cli/*.py
308
+ ```
309
+
310
+ ## Project Skill
311
+
312
+ A project skill for Cursor/Openclaw-style agent usage lives in:
313
+
314
+ `./.cursor/skills/powerbase-cli-openclaw/SKILL.md`
315
+
316
+ Design and auth review notes live in:
317
+
318
+ `./docs/console-cli-plan.md`
@@ -0,0 +1,310 @@
1
+ # powerbase-cli
2
+
3
+ Python CLI for automating Powerbase console operations, with a command shape designed for Openclaw and other LLM agents.
4
+
5
+ ## What It Covers
6
+
7
+ `powerbase-cli` mirrors the main console workflows with a user-mode auth model:
8
+
9
+ - browser login bridge for CLI use
10
+ - local session persistence and refresh
11
+ - config and context management
12
+ - organizations, databases, instances, branches
13
+ - SQL execution
14
+ - publish diff and publish run
15
+ - sandbox file operations
16
+ - sandbox agent provider config, chat, and login workflows
17
+
18
+ The CLI is optimized for agent use:
19
+
20
+ - stable command groups
21
+ - `--help` explains parameter source and format
22
+ - `--json` is available for machine-readable output
23
+ - context can be saved so later commands need fewer flags
24
+
25
+ Database model:
26
+
27
+ - default path: `powerbase instance create` uses the managed Powerbase database flow
28
+ - advanced path: `powerbase database create --dsn ...` registers an existing external database connection for later use with `--database-id`
29
+ - `powerbase database create` does not provision a new physical database
30
+
31
+ ## Install And Run
32
+
33
+ Install from PyPI:
34
+
35
+ ```bash
36
+ python -m pip install powerbase-cli
37
+ powerbase --help
38
+ ```
39
+
40
+ From the repository root during development:
41
+
42
+ ```bash
43
+ pip install -e .
44
+ ```
45
+
46
+ Or run directly during development:
47
+
48
+ ```bash
49
+ PYTHONPATH=src python3 -m powerbase_cli --help
50
+ ```
51
+
52
+ ## Configuration Model
53
+
54
+ Values are resolved in this order:
55
+
56
+ 1. command flags
57
+ 2. environment variables
58
+ 3. `~/.config/powerbase/`
59
+ 4. built-in defaults
60
+
61
+ Default local files:
62
+
63
+ ```text
64
+ ~/.config/powerbase/
65
+ config.toml
66
+ auth.json
67
+ context.json
68
+ ```
69
+
70
+ Most users do not need environment variables.
71
+
72
+ Optional advanced overrides:
73
+ - `POWERBASE_ACCESS_TOKEN` and `POWERBASE_REFRESH_TOKEN` for non-browser or pre-issued login flows
74
+ - `POWERBASE_INSTANCE_ID`, `POWERBASE_ORG_ID`, and `POWERBASE_BRANCH` to prefill local context
75
+ - `POWERBASE_CONFIG_DIR` to isolate local state, for example in tests or E2E runs
76
+ - `POWERBASE_OUTPUT` to default to `json`
77
+
78
+ ## Authentication
79
+
80
+ ### Browser Login
81
+
82
+ The preferred flow is:
83
+
84
+ ```bash
85
+ powerbase auth login
86
+ ```
87
+
88
+ The CLI now includes a built-in `base_url` and `anon_key` default for this deployment. The test package also bundles this environment's self-signed CA certificate, so most users can start with browser login directly and only use flags or environment variables when overriding that default.
89
+
90
+ The bundled CA is a test-only convenience for the current self-signed deployment. After the console moves to a publicly trusted TLS certificate, remove the bundled CA fallback and package resource, then keep only the built-in `base_url` and `anon_key` defaults.
91
+
92
+ This will:
93
+
94
+ 1. request a CLI login session from Powerbase
95
+ 2. print a browser URL
96
+ 3. poll until browser approval or until `--timeout` elapses (default **300** seconds, five minutes)
97
+ 4. save the resulting session to `~/.config/powerbase/auth.json`
98
+
99
+ Use `--timeout 0` to wait without a time limit. Use a larger value if users need more than five minutes to complete login.
100
+ If an agent or wrapper script is coordinating the workflow, it is still helpful
101
+ to tell the user: after browser approval, return to the current session so the
102
+ remaining steps can continue.
103
+
104
+ ### Manual Token Import
105
+
106
+ Use this when browser login is not available in the current agent environment:
107
+
108
+ ```bash
109
+ powerbase auth token-set \
110
+ --access-token ACCESS_TOKEN \
111
+ --refresh-token REFRESH_TOKEN \
112
+ --expires-at 1760000000
113
+ ```
114
+
115
+ Use `--base-url` or `--anon-key` here only when you intentionally want to override the built-in deployment defaults.
116
+
117
+ ### Check Auth State
118
+
119
+ ```bash
120
+ powerbase auth status --json
121
+ ```
122
+
123
+ ### Refresh A Saved Session
124
+
125
+ ```bash
126
+ powerbase auth refresh --json
127
+ ```
128
+
129
+ ## Context Workflow
130
+
131
+ For repeated agent workflows, save the current org, instance, and branch:
132
+
133
+ ```bash
134
+ powerbase context use-org ORG_ID
135
+ powerbase context use-instance INSTANCE_ID
136
+ powerbase context use-branch main
137
+ powerbase context show --json
138
+ ```
139
+
140
+ After that, many commands can omit `--instance-id`.
141
+
142
+ ## Common Workflows
143
+
144
+ ### Discover Resources
145
+
146
+ ```bash
147
+ powerbase org list --json
148
+ powerbase database list --json
149
+ powerbase instance list --json
150
+ powerbase branch list --instance-id INSTANCE_ID --json
151
+ ```
152
+
153
+ ### Create An Instance With The Managed Database Flow
154
+
155
+ This is the default and recommended path:
156
+
157
+ ```bash
158
+ powerbase org list --json
159
+ powerbase instance create --name todo-app --org-id ORG_ID --json
160
+ ```
161
+
162
+ `instance create` returns when provisioning starts, not necessarily when every
163
+ dependent resource is immediately readable. If `instance get`, `branch list`, or
164
+ sandbox commands briefly say the instance is missing or partial, retry after a
165
+ short wait.
166
+
167
+ ### Register And Reuse An External Database Connection
168
+
169
+ Use this only when you intentionally want the advanced bring-your-own-database flow:
170
+
171
+ ```bash
172
+ powerbase database create --name todo-db --dsn "mysql://user:pass@host:3306/db" --db-type mysql --json
173
+ powerbase instance create --name todo-app --database-id DATABASE_ID --org-id ORG_ID --json
174
+ ```
175
+
176
+ Notes for the advanced path:
177
+
178
+ - `powerbase database create` registers a DSN in Powerbase; it does not create a physical database server
179
+ - DSN credentials are sensitive and are stored by the platform
180
+ - branch and preview workflows may require SeekDB-compatible database behavior, not just generic MySQL wire compatibility
181
+ - deleting a Powerbase database record does not delete the external database itself
182
+
183
+ ### Switch To An Instance And Branch
184
+
185
+ ```bash
186
+ powerbase context use-instance INSTANCE_ID
187
+ powerbase branch switch feature/demo --instance-id INSTANCE_ID --json
188
+ powerbase context use-branch feature/demo
189
+ ```
190
+
191
+ When you create a branch with a name like `feature/demo`, later delete or SQL
192
+ commands should prefer the normalized slug returned by the API, such as
193
+ `feature-demo`, instead of assuming the original input string is still valid.
194
+
195
+ ### Run SQL
196
+
197
+ Inline SQL:
198
+
199
+ ```bash
200
+ powerbase sql run --instance-id INSTANCE_ID --branch main --sql "SELECT 1" --json
201
+ ```
202
+
203
+ From a file:
204
+
205
+ ```bash
206
+ powerbase sql run --instance-id INSTANCE_ID --sql-file ./query.sql --json
207
+ ```
208
+
209
+ ### Publish
210
+
211
+ ```bash
212
+ powerbase publish diff --instance-id INSTANCE_ID --json
213
+ powerbase publish run --instance-id INSTANCE_ID --json
214
+ ```
215
+
216
+ ### Sandbox Files
217
+
218
+ ```bash
219
+ powerbase sandbox files tree --instance-id INSTANCE_ID --root / --json
220
+ powerbase sandbox files read --instance-id INSTANCE_ID /src/app.tsx --json
221
+ powerbase sandbox files upload --instance-id INSTANCE_ID ./local.txt --target-path /tmp --json
222
+ ```
223
+
224
+ ### Sandbox Agent Providers
225
+
226
+ ```bash
227
+ powerbase agent providers --instance-id INSTANCE_ID --json
228
+ powerbase agent status --instance-id INSTANCE_ID --provider cursor --json
229
+ powerbase agent login-url --instance-id INSTANCE_ID --provider cursor --json
230
+ ```
231
+
232
+ ### Sandbox Agent Chat And Config
233
+
234
+ Send one prompt to the sandbox agent and stream events as JSONL:
235
+
236
+ ```bash
237
+ powerbase branch switch feature/demo --instance-id INSTANCE_ID --json
238
+
239
+ powerbase agent chat \
240
+ --instance-id INSTANCE_ID \
241
+ --provider cursor \
242
+ --message "Build a todo app with create, complete, and delete actions." \
243
+ --stream-jsonl
244
+ ```
245
+
246
+ `agent chat` follows the sandbox's current branch for the automatic preview build. Use
247
+ `powerbase branch switch ...` first when you want the generated preview to land on a
248
+ feature branch. `powerbase context use-branch ...` only changes the local default value;
249
+ it does not switch the remote sandbox by itself.
250
+
251
+ Read and update opencode provider config:
252
+
253
+ ```bash
254
+ powerbase agent opencode-config get --instance-id INSTANCE_ID --json
255
+ powerbase agent opencode-config set --instance-id INSTANCE_ID --provider anthropic --api-key API_KEY --json
256
+ powerbase agent opencode-config delete --instance-id INSTANCE_ID --provider anthropic --json
257
+ ```
258
+
259
+ Replace the sandbox `opencode.json` file:
260
+
261
+ ```bash
262
+ powerbase agent opencode-json set --instance-id INSTANCE_ID --file ./opencode.json --json
263
+ ```
264
+
265
+ ## Openclaw Usage Notes
266
+
267
+ When Openclaw or another LLM agent uses `powerbase`:
268
+
269
+ - prefer `--json` on all commands
270
+ - run discovery commands before write operations
271
+ - set context for long multi-step tasks
272
+ - use `auth status` before workflows that assume login
273
+ - use `auth token-set` if browser login is not practical in the current environment
274
+ - remember that `--json` overrides a saved `config output text` setting for that command
275
+
276
+ Recommended agent sequence:
277
+
278
+ 1. `powerbase auth status --json`
279
+ 2. If unauthenticated, run `powerbase auth login` or `powerbase auth token-set`
280
+ 3. `powerbase context show --json`
281
+ 4. If no instance is selected, run `powerbase instance list --json`
282
+ 5. If no suitable instance exists, prefer `powerbase instance create --name ... --org-id ... --json`
283
+ 6. Use `powerbase database ...` only for the advanced bring-your-own-database path
284
+ 7. Set context with `powerbase context use-instance ...`
285
+ 8. If you want the sandbox agent preview on a non-main branch, run `powerbase branch switch ...`
286
+ 9. Continue with `branch`, `sql`, `publish`, `sandbox files`, or `agent` commands
287
+
288
+ ## Testing
289
+
290
+ Run the full CLI test suite:
291
+
292
+ ```bash
293
+ PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src python3 -m unittest discover -s tests -v
294
+ ```
295
+
296
+ Compile the modules:
297
+
298
+ ```bash
299
+ PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src python3 -m py_compile src/powerbase_cli/*.py
300
+ ```
301
+
302
+ ## Project Skill
303
+
304
+ A project skill for Cursor/Openclaw-style agent usage lives in:
305
+
306
+ `./.cursor/skills/powerbase-cli-openclaw/SKILL.md`
307
+
308
+ Design and auth review notes live in:
309
+
310
+ `./docs/console-cli-plan.md`
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "powerbase-cli"
7
+ version = "0.1.0"
8
+ description = "CLI for operating Powerbase console workflows"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ authors = [{ name = "Powerbase" }]
12
+ dependencies = []
13
+
14
+ [project.scripts]
15
+ powerbase = "powerbase_cli.cli:main"
16
+
17
+ [tool.setuptools]
18
+ package-dir = { "" = "src" }
19
+
20
+ [tool.setuptools.package-data]
21
+ powerbase_cli = ["certs/*.pem"]
22
+
23
+ [tool.setuptools.packages.find]
24
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ """Powerbase CLI package."""
2
+
3
+ __all__ = ["__version__"]
4
+
5
+ __version__ = "0.1.0"
@@ -0,0 +1,5 @@
1
+ from .cli import main
2
+
3
+
4
+ if __name__ == "__main__":
5
+ raise SystemExit(main())