@butterbase/cli 0.8.0 → 0.9.0

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 (36) hide show
  1. package/README.md +434 -407
  2. package/dist/bin/butterbase.js +9 -1
  3. package/dist/bin/butterbase.js.map +1 -1
  4. package/dist/src/commands/init.d.ts +6 -0
  5. package/dist/src/commands/init.d.ts.map +1 -1
  6. package/dist/src/commands/init.js +32 -1
  7. package/dist/src/commands/init.js.map +1 -1
  8. package/dist/src/commands/office.d.ts +28 -0
  9. package/dist/src/commands/office.d.ts.map +1 -0
  10. package/dist/src/commands/office.js +321 -0
  11. package/dist/src/commands/office.js.map +1 -0
  12. package/dist/src/commands/plugin.d.ts.map +1 -1
  13. package/dist/src/commands/plugin.js +2 -1
  14. package/dist/src/commands/plugin.js.map +1 -1
  15. package/dist/src/lib/api-client.d.ts +3 -0
  16. package/dist/src/lib/api-client.d.ts.map +1 -1
  17. package/dist/src/lib/api-client.js.map +1 -1
  18. package/dist/src/lib/office-client.d.ts +5 -0
  19. package/dist/src/lib/office-client.d.ts.map +1 -0
  20. package/dist/src/lib/office-client.js +25 -0
  21. package/dist/src/lib/office-client.js.map +1 -0
  22. package/dist/tsconfig.tsbuildinfo +1 -1
  23. package/package.json +3 -2
  24. package/templates/react-vite/.env.example +2 -2
  25. package/templates/react-vite/.mcp.json +10 -10
  26. package/templates/react-vite/README.md +38 -38
  27. package/templates/react-vite/index.html +13 -13
  28. package/templates/react-vite/package.json +24 -25
  29. package/templates/react-vite/src/App.css +33 -33
  30. package/templates/react-vite/src/App.tsx +83 -77
  31. package/templates/react-vite/src/index.css +8 -8
  32. package/templates/react-vite/src/lib.ts +6 -6
  33. package/templates/react-vite/src/main.tsx +10 -10
  34. package/templates/react-vite/src/vite-env.d.ts +1 -0
  35. package/templates/react-vite/tsconfig.json +21 -21
  36. package/templates/react-vite/vite.config.ts +6 -6
package/README.md CHANGED
@@ -1,407 +1,434 @@
1
- # @butterbase/cli
2
-
3
- Command-line tool for Butterbase project scaffolding and backend management.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install -g @butterbase/cli
9
- ```
10
-
11
- ## Quick Start
12
-
13
- ```bash
14
- # Login with your API key
15
- butterbase login
16
-
17
- # Create a new app
18
- butterbase apps create my-app
19
-
20
- # Set as current app
21
- butterbase apps use app_abc123
22
-
23
- # Get current schema
24
- butterbase schema get --output schema.json
25
-
26
- # Apply schema changes
27
- butterbase schema apply schema.json
28
-
29
- # Deploy a function
30
- butterbase functions deploy ./functions/hello.ts
31
-
32
- # Upload a file
33
- butterbase storage upload ./image.png
34
- ```
35
-
36
- ## Commands
37
-
38
- ### Authentication
39
-
40
- ```bash
41
- # Login
42
- butterbase login
43
-
44
- # Logout
45
- butterbase logout
46
- ```
47
-
48
- ### Configuration
49
-
50
- ```bash
51
- # Show current config
52
- butterbase config get
53
-
54
- # Set endpoint
55
- butterbase config set endpoint https://api.butterbase.ai
56
-
57
- # Set API key
58
- butterbase config set apiKey bb_key_...
59
- ```
60
-
61
- Configuration is stored in `~/.butterbase/config.json`.
62
-
63
- ### Apps
64
-
65
- ```bash
66
- # List all apps
67
- butterbase apps list
68
-
69
- # Create new app
70
- butterbase apps create my-app
71
-
72
- # Set current app (used by other commands)
73
- butterbase apps use app_abc123
74
-
75
- # Delete app
76
- butterbase apps delete app_abc123
77
- ```
78
-
79
- ### Schema
80
-
81
- ```bash
82
- # Get current schema
83
- butterbase schema get
84
-
85
- # Save schema to file
86
- butterbase schema get --output schema.json
87
-
88
- # Preview schema changes (dry-run)
89
- butterbase schema apply schema.json --dry-run
90
-
91
- # Apply schema changes
92
- butterbase schema apply schema.json
93
-
94
- # Apply with custom migration name
95
- butterbase schema apply schema.json --name "add_users_table"
96
-
97
- # Use specific app
98
- butterbase schema get --app app_abc123
99
- ```
100
-
101
- ### Functions
102
-
103
- ```bash
104
- # List deployed functions
105
- butterbase functions list
106
-
107
- # Deploy function
108
- butterbase functions deploy ./functions/hello.ts
109
-
110
- # Deploy with custom name
111
- butterbase functions deploy ./functions/hello.ts --name my-function
112
-
113
- # Deploy with description
114
- butterbase functions deploy ./functions/hello.ts --description "Hello world function"
115
-
116
- # Deploy cron function
117
- butterbase functions deploy ./functions/cleanup.ts --trigger cron
118
-
119
- # View function logs
120
- butterbase functions logs my-function
121
-
122
- # View error logs only
123
- butterbase functions logs my-function --level error
124
-
125
- # Limit number of logs
126
- butterbase functions logs my-function --limit 50
127
- ```
128
-
129
- ### Storage
130
-
131
- ```bash
132
- # List storage objects
133
- butterbase storage list
134
-
135
- # Upload file
136
- butterbase storage upload ./image.png
137
-
138
- # Delete object
139
- butterbase storage delete obj_abc123
140
- ```
141
-
142
- ### AI
143
-
144
- ```bash
145
- butterbase ai chat "Summarize this" --model openai/gpt-4o-mini
146
- butterbase ai chat "Explain RAG" --system "You're a concise teacher." --temperature 0.2
147
- butterbase ai embed "hello world" "another doc"
148
- butterbase ai models
149
- butterbase ai config get
150
- butterbase ai config set --default-model openai/gpt-4o-mini --max-tokens-per-request 4000
151
- butterbase ai config set --byok-key sk-or-... # rotate BYOK key; "" to clear
152
- butterbase ai usage --start-date 2026-05-01 --end-date 2026-05-31
153
- ```
154
-
155
- ### OAuth (admin)
156
-
157
- ```bash
158
- butterbase oauth configure google \
159
- --client-id ... --client-secret ... \
160
- --redirect-uri https://app.example/cb \
161
- --scope openid --scope email
162
- butterbase oauth list
163
- butterbase oauth get google
164
- butterbase oauth update google --enabled false
165
- butterbase oauth delete google
166
- ```
167
-
168
- ### Audit logs
169
-
170
- ```bash
171
- butterbase audit query --category auth --event-type login --limit 50
172
- butterbase audit query --from 2026-05-01 --to 2026-05-31 --action create --resource-type user
173
- butterbase audit query --actor-id user_123 --json
174
- ```
175
-
176
- ### App config (server-side)
177
-
178
- ```bash
179
- butterbase apps config get
180
- butterbase apps config cors --allowed-origin https://app.example --allow-credentials true
181
- butterbase apps config jwt --access-token-ttl 15m --refresh-token-ttl-days 30
182
- butterbase apps config storage --public-read true --max-file-size-mb 25 --allowed-content-type image/png --allowed-content-type image/jpeg
183
- butterbase apps config access-mode authenticated
184
- butterbase apps config secure --table posts --table comments --user-column author_id --access-mode authenticated
185
- ```
186
-
187
- ### Regions + multi-region moves
188
-
189
- ```bash
190
- butterbase regions list
191
- butterbase apps move app_abc us-west-2 --follow
192
- butterbase apps migrations active # current app
193
- butterbase apps migrations status app_abc m_xyz
194
- butterbase apps migrations abort app_abc m_xyz # before cutover
195
- butterbase apps migrations reverse app_abc m_xyz # after cutover
196
- butterbase apps replicas list
197
- butterbase apps replicas teardown m_xyz
198
- ```
199
-
200
- ### App-level billing (Stripe Connect)
201
-
202
- ```bash
203
- butterbase app-billing plans list
204
- butterbase app-billing plans create --name pro --price-cents 1999 --interval month
205
- butterbase app-billing plans update plan_abc --price-cents 2499
206
- butterbase app-billing products list
207
- butterbase app-billing products create --name "Lifetime access" --price-cents 9900
208
- butterbase app-billing subscribe plan_abc
209
- butterbase app-billing subscription
210
- butterbase app-billing cancel
211
- butterbase app-billing purchase prod_xyz
212
- butterbase app-billing orders list
213
- butterbase app-billing orders get order_abc
214
- ```
215
-
216
- ### Scoped API keys + integrations
217
-
218
- ```bash
219
- butterbase keys generate ci-key --scope schema:read --scope functions:invoke
220
- butterbase integrations configure github --scope repo --scope read:user
221
- butterbase integrations connect github --redirect-url https://app.example/cb --scope repo
222
- ```
223
-
224
- ### Functions deploy (full options)
225
-
226
- ```bash
227
- butterbase functions deploy fn.ts \
228
- --name my-fn \
229
- --trigger cron --trigger-config '{"schedule":"*/5 * * * *"}' \
230
- --env API_KEY=sk_... --env DEBUG=true \
231
- --timeout-ms 9000 --memory-mb 256
232
- ```
233
-
234
- ### RLS
235
-
236
- ```bash
237
- butterbase rls create --table posts --policy-name posts_own \
238
- --command SELECT --using "author_id = auth.uid()" \
239
- --role user --restrictive
240
- butterbase rls delete posts # delete all policies on table
241
- butterbase rls delete posts --policy posts_own
242
- ```
243
-
244
- ## Global Options
245
-
246
- Most commands support the `--app` flag to specify an app ID:
247
-
248
- ```bash
249
- butterbase schema get --app app_abc123
250
- butterbase functions list --app app_abc123
251
- butterbase storage list --app app_abc123
252
- ```
253
-
254
- If `--app` is not provided, the CLI uses the current app set with `butterbase apps use`.
255
-
256
- ## Configuration
257
-
258
- The CLI stores configuration in two places:
259
-
260
- 1. **Global config**: `~/.butterbase/config.json`
261
- - API key
262
- - Default endpoint
263
- - Current app
264
-
265
- 2. **Project config**: `.butterbase/config.json` (in project directory)
266
- - App ID
267
- - Endpoint override
268
-
269
- Project config takes precedence over global config.
270
-
271
- ## Environment Variables
272
-
273
- You can also configure the CLI using environment variables:
274
-
275
- - `BUTTERBASE_API_KEY` - API key
276
- - `BUTTERBASE_ENDPOINT` - API endpoint URL
277
-
278
- ## Examples
279
-
280
- ### Complete Workflow
281
-
282
- ```bash
283
- # 1. Login
284
- butterbase login
285
-
286
- # 2. Create app
287
- butterbase apps create my-grocery-app
288
-
289
- # 3. Set as current
290
- butterbase apps use app_abc123
291
-
292
- # 4. Create schema file
293
- cat > schema.json <<EOF
294
- {
295
- "tables": {
296
- "grocery_items": {
297
- "columns": {
298
- "id": { "type": "uuid", "primaryKey": true, "default": "gen_random_uuid()" },
299
- "name": { "type": "text" },
300
- "quantity": { "type": "integer", "default": "1" },
301
- "purchased": { "type": "boolean", "default": "false" },
302
- "user_id": { "type": "uuid" },
303
- "created_at": { "type": "timestamptz", "default": "now()" }
304
- }
305
- }
306
- }
307
- }
308
- EOF
309
-
310
- # 5. Apply schema
311
- butterbase schema apply schema.json
312
-
313
- # 6. Deploy function
314
- butterbase functions deploy ./functions/add-item.ts
315
-
316
- # 7. Upload image
317
- butterbase storage upload ./logo.png
318
- ```
319
-
320
- ### Working with Multiple Apps
321
-
322
- ```bash
323
- # Create production app
324
- butterbase apps create my-app-prod
325
- # Returns: app_prod123
326
-
327
- # Create staging app
328
- butterbase apps create my-app-staging
329
- # Returns: app_staging456
330
-
331
- # Deploy to production
332
- butterbase functions deploy ./functions/api.ts --app app_prod123
333
-
334
- # Deploy to staging
335
- butterbase functions deploy ./functions/api.ts --app app_staging456
336
-
337
- # Switch between apps
338
- butterbase apps use app_prod123
339
- butterbase apps use app_staging456
340
- ```
341
-
342
- ## Development
343
-
344
- ```bash
345
- # Install dependencies
346
- npm install
347
-
348
- # Build
349
- npm run build
350
-
351
- # Test locally
352
- node dist/bin/butterbase.js --help
353
- ```
354
-
355
- ### Integrations
356
-
357
- ```bash
358
- # List available integrations (curated)
359
- butterbase integrations list --app app_abc123
360
-
361
- # Search the full catalog
362
- butterbase integrations list --search salesforce --app app_abc123
363
-
364
- # Show configured integrations
365
- butterbase integrations config --app app_abc123
366
-
367
- # Enable a toolkit
368
- butterbase integrations configure gmail --app app_abc123
369
-
370
- # Disable a toolkit
371
- butterbase integrations disable gmail --app app_abc123
372
-
373
- # Generate OAuth URL for an end-user
374
- butterbase integrations connect gmail --redirect-url https://yourapp.com/settings --app app_abc123
375
-
376
- # List connected accounts
377
- butterbase integrations connections --app app_abc123
378
-
379
- # Disconnect an account
380
- butterbase integrations disconnect <connection-id> --app app_abc123
381
-
382
- # List tools for a toolkit
383
- butterbase integrations tools gmail --app app_abc123
384
-
385
- # Execute a tool
386
- butterbase integrations execute GMAIL_SEND_EMAIL --data '{"to":"x@y.com","subject":"Hi","body":"Hello"}' --app app_abc123
387
- ```
388
-
389
- ## Error output
390
-
391
- The CLI throws typed `ButterbaseError`s from `@butterbase/sdk`. The top-level
392
- handler renders the class name, message, and the structured fields the backend
393
- returned (`code`, `status`, `remediation`). Example for an unauthenticated call:
394
-
395
- ```
396
- AuthError: Invalid API key
397
- code: AUTH_INVALID_API_KEY
398
- status: 401
399
- remediation: Rotate the key with `butterbase keys generate` and update ~/.butterbase/config.json.
400
- ```
401
-
402
- The error codes come from `@butterbase/shared`'s `ErrorCodes` namespace — see
403
- the SDK README for the full list.
404
-
405
- ## License
406
-
407
- MIT
1
+ # @butterbase/cli
2
+
3
+ Command-line tool for Butterbase project scaffolding and backend management.
4
+
5
+ ## Office commands
6
+
7
+ ```sh
8
+ butterbase office status --org <uuid> --json
9
+ butterbase office ask "What needs follow-up?" --org <uuid> --stream
10
+ butterbase office decisions approve <id> --source substrate --org <uuid> --open --wait
11
+ butterbase office memory record-learning --file learning.json --org <uuid> --json
12
+ ```
13
+
14
+ Every Office command requires `--org` and supports `--json`, with no selected app. Credentials come from the existing platform login/config, or `BUTTERBASE_API_KEY`; `BUTTERBASE_CONTROL_API_URL` can override the configured endpoint. `butterbase office --help` lists the 22 commands and nested groups.
15
+
16
+ Protected commands print a confirmation receipt and URL. `--open` explicitly launches a browser; a missing browser still leaves the URL usable. `--wait` observes only; use `--wait-timeout <ms>` to bound waiting. `status --confirmation <id>` inspects the saved outcome. Use `--idempotency-key` to retry the same intended write, and `--source office|substrate` for decision references.
17
+
18
+ Ask `--stream --conversation <id> --turn <id> --after-sequence <n>` observes an existing turn without another question. SIGINT stops observation, not server work. JSON mode prints one `{data,error}` object to stdout; diagnostics go to stderr. `--json --stream` includes collected public events in that final object.
19
+
20
+ Exit **0**: accepted/read, including pending confirmation. Exit **1**: request/terminal failure, rejected/expired/unknown receipt, timeout or interruption. Exit **2**: usage/input error. Inspect receipts and exact turn IDs after a disconnect before requesting new work. See [all commands, payloads and access rules](https://docs.butterbase.ai/core-concepts/office-clients/).
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install -g @butterbase/cli
26
+ ```
27
+
28
+ ## Quick Start
29
+
30
+ ```bash
31
+ # Login with your API key
32
+ butterbase login
33
+
34
+ # Create a new app
35
+ butterbase apps create my-app
36
+
37
+ # Set as current app
38
+ butterbase apps use app_abc123
39
+
40
+ # Get current schema
41
+ butterbase schema get --output schema.json
42
+
43
+ # Apply schema changes
44
+ butterbase schema apply schema.json
45
+
46
+ # Deploy a function
47
+ butterbase functions deploy ./functions/hello.ts
48
+
49
+ # Upload a file
50
+ butterbase storage upload ./image.png
51
+ ```
52
+
53
+ ## Commands
54
+
55
+ ### Authentication
56
+
57
+ ```bash
58
+ # Login
59
+ butterbase login
60
+
61
+ # Logout
62
+ butterbase logout
63
+ ```
64
+
65
+ ### Configuration
66
+
67
+ ```bash
68
+ # Show current config
69
+ butterbase config get
70
+
71
+ # Set endpoint
72
+ butterbase config set endpoint https://api.butterbase.ai
73
+
74
+ # Set API key
75
+ butterbase config set apiKey bb_sk_...
76
+ ```
77
+
78
+ Configuration is stored in `~/.butterbase/config.json`.
79
+
80
+ ### Apps
81
+
82
+ ```bash
83
+ # List all apps
84
+ butterbase apps list
85
+
86
+ # Create new app
87
+ butterbase apps create my-app
88
+
89
+ # Set current app (used by other commands)
90
+ butterbase apps use app_abc123
91
+
92
+ # Delete app
93
+ butterbase apps delete app_abc123
94
+ ```
95
+
96
+ ### Schema
97
+
98
+ ```bash
99
+ # Get current schema
100
+ butterbase schema get
101
+
102
+ # Save schema to file
103
+ butterbase schema get --output schema.json
104
+
105
+ # Preview schema changes (dry-run)
106
+ butterbase schema apply schema.json --dry-run
107
+
108
+ # Apply schema changes
109
+ butterbase schema apply schema.json
110
+
111
+ # Apply with custom migration name
112
+ butterbase schema apply schema.json --name "add_users_table"
113
+
114
+ # Use specific app
115
+ butterbase schema get --app app_abc123
116
+ ```
117
+
118
+ ### Functions
119
+
120
+ ```bash
121
+ # List deployed functions
122
+ butterbase functions list
123
+
124
+ # Deploy function
125
+ butterbase functions deploy ./functions/hello.ts
126
+
127
+ # Deploy with custom name
128
+ butterbase functions deploy ./functions/hello.ts --name my-function
129
+
130
+ # Deploy with description
131
+ butterbase functions deploy ./functions/hello.ts --description "Hello world function"
132
+
133
+ # Deploy cron function
134
+ butterbase functions deploy ./functions/cleanup.ts --trigger cron
135
+
136
+ # View function logs
137
+ butterbase functions logs my-function
138
+
139
+ # View error logs only
140
+ butterbase functions logs my-function --level error
141
+
142
+ # Limit number of logs
143
+ butterbase functions logs my-function --limit 50
144
+ ```
145
+
146
+ ### Storage
147
+
148
+ ```bash
149
+ # List storage objects
150
+ butterbase storage list
151
+
152
+ # Upload file
153
+ butterbase storage upload ./image.png
154
+
155
+ # Delete object
156
+ butterbase storage delete obj_abc123
157
+ ```
158
+
159
+ ### AI
160
+
161
+ ```bash
162
+ butterbase ai chat "Summarize this" --model openai/gpt-4o-mini
163
+ butterbase ai chat "Explain RAG" --system "You're a concise teacher." --temperature 0.2
164
+ butterbase ai embed "hello world" "another doc"
165
+ butterbase ai models
166
+ butterbase ai config get
167
+ butterbase ai config set --default-model openai/gpt-4o-mini --max-tokens-per-request 4000
168
+ butterbase ai config set --byok-key sk-or-... # rotate BYOK key; "" to clear
169
+ butterbase ai usage --start-date 2026-05-01 --end-date 2026-05-31
170
+ ```
171
+
172
+ ### OAuth (admin)
173
+
174
+ ```bash
175
+ butterbase oauth configure google \
176
+ --client-id ... --client-secret ... \
177
+ --redirect-uri https://app.example/cb \
178
+ --scope openid --scope email
179
+ butterbase oauth list
180
+ butterbase oauth get google
181
+ butterbase oauth update google --enabled false
182
+ butterbase oauth delete google
183
+ ```
184
+
185
+ ### Audit logs
186
+
187
+ ```bash
188
+ butterbase audit query --category auth --event-type login --limit 50
189
+ butterbase audit query --from 2026-05-01 --to 2026-05-31 --action create --resource-type user
190
+ butterbase audit query --actor-id user_123 --json
191
+ ```
192
+
193
+ ### App config (server-side)
194
+
195
+ ```bash
196
+ butterbase apps config get
197
+ butterbase apps config cors --allowed-origin https://app.example --allow-credentials true
198
+ butterbase apps config jwt --access-token-ttl 15m --refresh-token-ttl-days 30
199
+ butterbase apps config storage --public-read true --max-file-size-mb 25 --allowed-content-type image/png --allowed-content-type image/jpeg
200
+ butterbase apps config access-mode authenticated
201
+ butterbase apps config secure --table posts --table comments --user-column author_id --access-mode authenticated
202
+ ```
203
+
204
+ ### Regions + multi-region moves
205
+
206
+ ```bash
207
+ butterbase regions list
208
+ butterbase apps move app_abc us-west-2 --follow
209
+ butterbase apps migrations active # current app
210
+ butterbase apps migrations status app_abc m_xyz
211
+ butterbase apps migrations abort app_abc m_xyz # before cutover
212
+ butterbase apps migrations reverse app_abc m_xyz # after cutover
213
+ butterbase apps replicas list
214
+ butterbase apps replicas teardown m_xyz
215
+ ```
216
+
217
+ ### App-level billing (Stripe Connect)
218
+
219
+ ```bash
220
+ butterbase app-billing plans list
221
+ butterbase app-billing plans create --name pro --price-cents 1999 --interval month
222
+ butterbase app-billing plans update plan_abc --price-cents 2499
223
+ butterbase app-billing products list
224
+ butterbase app-billing products create --name "Lifetime access" --price-cents 9900
225
+ butterbase app-billing subscribe plan_abc
226
+ butterbase app-billing subscription
227
+ butterbase app-billing cancel
228
+ butterbase app-billing purchase prod_xyz
229
+ butterbase app-billing orders list
230
+ butterbase app-billing orders get order_abc
231
+ ```
232
+
233
+ ### Scoped API keys + integrations
234
+
235
+ ```bash
236
+ butterbase keys generate ci-key --scope app --app app_abc123 --extra-scope ai:gateway # --scope: account (default) | app
237
+ butterbase keys list
238
+ butterbase keys revoke <key-id>
239
+ butterbase integrations configure github --scope repo --scope read:user
240
+ butterbase integrations connect github --redirect-url https://app.example/cb --scope repo
241
+ ```
242
+
243
+ ### Functions deploy (full options)
244
+
245
+ ```bash
246
+ butterbase functions deploy fn.ts \
247
+ --name my-fn \
248
+ --trigger cron --trigger-config '{"schedule":"*/5 * * * *"}' \
249
+ --env API_KEY=sk_... --env DEBUG=true \
250
+ --timeout-ms 9000 --memory-mb 256
251
+ ```
252
+
253
+ ### RLS
254
+
255
+ ```bash
256
+ butterbase rls create --table posts --policy-name posts_own \
257
+ --command SELECT --using "author_id = auth.uid()" \
258
+ --role user --restrictive
259
+ butterbase rls delete posts # delete all policies on table
260
+ butterbase rls delete posts --policy posts_own
261
+ ```
262
+
263
+ ### More commands
264
+
265
+ Other top-level commands (run `butterbase <command> --help` for flags):
266
+
267
+ - `init [template]`, `clone`, `templates`, `visibility <mode>`, `status`, `open`
268
+ - `deploy [directory]` (frontend; `--from-source` builds remotely), `deploy:edge-ssr`, `domains`, `env`
269
+ - `data query|insert`, `realtime enable|config|disable`, `kv`, `rag`, `do` (Durable Objects)
270
+ - `agents list|get|create|update|delete`, `substrate`, `people`, `partners`, `preview`, `repo`
271
+ - `billing` (platform billing), `mcp install`, `plugin setup`
272
+ - `apps pause|resume`, `functions get|delete|invoke|env|metrics`, `rls list|enable`, `ai meetings`
273
+
274
+ ## Global Options
275
+
276
+ Most commands support the `--app` flag to specify an app ID:
277
+
278
+ ```bash
279
+ butterbase schema get --app app_abc123
280
+ butterbase functions list --app app_abc123
281
+ butterbase storage list --app app_abc123
282
+ ```
283
+
284
+ If `--app` is not provided, the CLI uses the current app set with `butterbase apps use`.
285
+
286
+ ## Configuration
287
+
288
+ The CLI stores configuration in two places:
289
+
290
+ 1. **Global config**: `~/.butterbase/config.json`
291
+ - API key
292
+ - Default endpoint
293
+ - Current app
294
+
295
+ 2. **Project config**: `.butterbase/config.json` (in project directory)
296
+ - App ID
297
+ - Endpoint override
298
+
299
+ Project config takes precedence over global config.
300
+
301
+ ## Environment Variables
302
+
303
+ The CLI reads its API key and endpoint from the config files above, not from environment variables. `BUTTERBASE_API_KEY` is only referenced by the MCP client config that `butterbase plugin setup` / `butterbase mcp install` write (`Authorization: Bearer ${BUTTERBASE_API_KEY}`), and `butterbase integrations configure|rotate` fall back to `<TOOLKIT>_CLIENT_ID` / `<TOOLKIT>_CLIENT_SECRET`.
304
+
305
+ ## Examples
306
+
307
+ ### Complete Workflow
308
+
309
+ ```bash
310
+ # 1. Login
311
+ butterbase login
312
+
313
+ # 2. Create app
314
+ butterbase apps create my-grocery-app
315
+
316
+ # 3. Set as current
317
+ butterbase apps use app_abc123
318
+
319
+ # 4. Create schema file
320
+ cat > schema.json <<EOF
321
+ {
322
+ "tables": {
323
+ "grocery_items": {
324
+ "columns": {
325
+ "id": { "type": "uuid", "primaryKey": true, "default": "gen_random_uuid()" },
326
+ "name": { "type": "text" },
327
+ "quantity": { "type": "integer", "default": "1" },
328
+ "purchased": { "type": "boolean", "default": "false" },
329
+ "user_id": { "type": "uuid" },
330
+ "created_at": { "type": "timestamptz", "default": "now()" }
331
+ }
332
+ }
333
+ }
334
+ }
335
+ EOF
336
+
337
+ # 5. Apply schema
338
+ butterbase schema apply schema.json
339
+
340
+ # 6. Deploy function
341
+ butterbase functions deploy ./functions/add-item.ts
342
+
343
+ # 7. Upload image
344
+ butterbase storage upload ./logo.png
345
+ ```
346
+
347
+ ### Working with Multiple Apps
348
+
349
+ ```bash
350
+ # Create production app
351
+ butterbase apps create my-app-prod
352
+ # Returns: app_prod123
353
+
354
+ # Create staging app
355
+ butterbase apps create my-app-staging
356
+ # Returns: app_staging456
357
+
358
+ # Deploy to production
359
+ butterbase functions deploy ./functions/api.ts --app app_prod123
360
+
361
+ # Deploy to staging
362
+ butterbase functions deploy ./functions/api.ts --app app_staging456
363
+
364
+ # Switch between apps
365
+ butterbase apps use app_prod123
366
+ butterbase apps use app_staging456
367
+ ```
368
+
369
+ ## Development
370
+
371
+ ```bash
372
+ # Install dependencies
373
+ npm install
374
+
375
+ # Build
376
+ npm run build
377
+
378
+ # Test locally
379
+ node dist/bin/butterbase.js --help
380
+ ```
381
+
382
+ ### Integrations
383
+
384
+ ```bash
385
+ # List available integrations (curated)
386
+ butterbase integrations list --app app_abc123
387
+
388
+ # Search the full catalog
389
+ butterbase integrations list --search salesforce --app app_abc123
390
+
391
+ # Show configured integrations
392
+ butterbase integrations config --app app_abc123
393
+
394
+ # Enable a toolkit
395
+ butterbase integrations configure gmail --app app_abc123
396
+
397
+ # Disable a toolkit
398
+ butterbase integrations disable gmail --app app_abc123
399
+
400
+ # Generate OAuth URL for an end-user
401
+ butterbase integrations connect gmail --redirect-url https://yourapp.com/settings --app app_abc123
402
+
403
+ # List connected accounts
404
+ butterbase integrations connections --app app_abc123
405
+
406
+ # Disconnect an account
407
+ butterbase integrations disconnect <connection-id> --app app_abc123
408
+
409
+ # List tools for a toolkit
410
+ butterbase integrations tools gmail --app app_abc123
411
+
412
+ # Execute a tool
413
+ butterbase integrations execute GMAIL_SEND_EMAIL --data '{"to":"x@y.com","subject":"Hi","body":"Hello"}' --app app_abc123
414
+ ```
415
+
416
+ ## Error output
417
+
418
+ The CLI throws typed `ButterbaseError`s from `@butterbase/sdk`. The top-level
419
+ handler renders the class name, message, and the structured fields the backend
420
+ returned (`code`, `status`, `remediation`). Example for an unauthenticated call:
421
+
422
+ ```
423
+ AuthError: Invalid API key
424
+ code: AUTH_INVALID_API_KEY
425
+ status: 401
426
+ remediation: Rotate the key with `butterbase keys generate` and update ~/.butterbase/config.json.
427
+ ```
428
+
429
+ The error codes come from `@butterbase/shared`'s `ErrorCodes` namespace — see
430
+ the SDK README for the full list.
431
+
432
+ ## License
433
+
434
+ Apache-2.0