@motherbase/cli 0.2.6 → 0.2.8

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 (59) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +248 -247
  3. package/bin/.motherbase/config.json +5 -0
  4. package/bin/motherbase.js +10 -10
  5. package/package.json +1 -1
  6. package/src/api.js +39 -16
  7. package/src/commands/_util.js +106 -106
  8. package/src/commands/backups.js +16 -16
  9. package/src/commands/branches.js +113 -113
  10. package/src/commands/completion.js +90 -90
  11. package/src/commands/config.js +47 -47
  12. package/src/commands/cron.js +65 -65
  13. package/src/commands/db.js +103 -103
  14. package/src/commands/domains.js +124 -124
  15. package/src/commands/gen.js +178 -172
  16. package/src/commands/import.js +55 -55
  17. package/src/commands/index.js +85 -85
  18. package/src/commands/inspect.js +178 -178
  19. package/src/commands/keys.js +72 -72
  20. package/src/commands/link.js +35 -35
  21. package/src/commands/local.js +100 -23
  22. package/src/commands/login.js +9 -3
  23. package/src/commands/logout.js +16 -16
  24. package/src/commands/mcp.js +61 -61
  25. package/src/commands/migrate.js +0 -5
  26. package/src/commands/migration.js +1 -1
  27. package/src/commands/network.js +83 -83
  28. package/src/commands/orgs.js +40 -40
  29. package/src/commands/postgres-config.js +113 -113
  30. package/src/commands/projects.js +131 -130
  31. package/src/commands/queues.js +133 -133
  32. package/src/commands/realtime.js +35 -35
  33. package/src/commands/rls.js +176 -176
  34. package/src/commands/secrets.js +66 -66
  35. package/src/commands/signing.js +130 -130
  36. package/src/commands/snippets.js +44 -44
  37. package/src/commands/status.js +42 -42
  38. package/src/commands/storage.js +261 -261
  39. package/src/commands/test.js +9 -9
  40. package/src/commands/unlink.js +15 -15
  41. package/src/commands/vault.js +82 -82
  42. package/src/commands/webhooks.js +62 -62
  43. package/src/commands/whoami.js +20 -20
  44. package/src/commands/wrappers.js +150 -150
  45. package/src/config.js +98 -98
  46. package/src/context.js +106 -106
  47. package/src/edge-templates.js +194 -194
  48. package/src/format.js +92 -92
  49. package/src/inspect/csv.js +22 -22
  50. package/src/inspect/queries.js +562 -562
  51. package/src/mcp/platform-tools.js +233 -233
  52. package/src/mcp/protocol.js +152 -152
  53. package/src/mcp/storage-tools.js +93 -93
  54. package/src/mcp/tools.js +478 -478
  55. package/src/migration/commands.js +2 -2
  56. package/src/migration/files.js +13 -0
  57. package/src/prompt.js +91 -91
  58. package/src/storage/remote.js +62 -62
  59. package/src/ui.js +111 -111
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Motherbase contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Motherbase contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,247 +1,248 @@
1
- # Motherbase CLI
2
-
3
- A Supabase-CLI-like operator CLI for **Motherbase**. It drives both the
4
- **Platform Console** (account + multi-project lifecycle) and a **linked project's
5
- admin API** through the Console proxy, or a single project API directly.
6
-
7
- Zero runtime dependencies. Node ≥ 18 (uses built-in `fetch`, `readline`, `fs`,
8
- `child_process` only).
9
-
10
- ```bash
11
- node bin/motherbase.js --help # auto-generated help
12
- npm link # or: npm i -g @motherbase/cli
13
- motherbase login --url https://console.example.com
14
- motherbase link # pick a project → writes ./.motherbase/config.json
15
- motherbase db tables
16
- motherbase functions deploy --name hello --route hello --file ./hello.js
17
- ```
18
-
19
- ## Connection model
20
-
21
- 1. **Console / account**, `motherbase login [--url <consoleUrl>]` performs a real
22
- Console login (`POST /api/platform/login`) and stores the session token.
23
- 2. **Linked project**, `motherbase link [project]` records which project this
24
- directory targets. All resource commands then route through the Console proxy
25
- (`/api/projects/:id/admin/*`).
26
- 3. **Direct mode (CI / single stack)**. Set `MOTHERBASE_URL` +
27
- `MOTHERBASE_ADMIN_TOKEN` to talk straight to one project's `/api/admin/*`.
28
-
29
- ### Configuration files
30
-
31
- **Global credentials**: `~/.motherbase/config.json` (contains tokens, written `0o600`):
32
-
33
- ```json
34
- {
35
- "consoles": {
36
- "https://console.example.com": { "token": "…", "email": "you@example.com" }
37
- },
38
- "current": "https://console.example.com"
39
- }
40
- ```
41
-
42
- **Project link**: `./.motherbase/config.json` (versionable, non-secret):
43
-
44
- ```json
45
- { "consoleUrl": "https://console.example.com", "projectId": "my-app", "projectName": "my-app" }
46
- ```
47
-
48
- ### Resolution precedence
49
-
50
- `flags > env > config`, per value:
51
-
52
- | Value | Flag | Env | Config |
53
- | ----------- | ----------------- | ------------------------- | ------ |
54
- | console URL | `--url/-u` | `MOTHERBASE_CONSOLE_URL` | link / global `current` |
55
- | token | `--token` | `MOTHERBASE_TOKEN` | global console entry |
56
- | project | `--project/-p` | `MOTHERBASE_PROJECT` | link |
57
- | direct API | (| `MOTHERBASE_URL` + `MOTHERBASE_ADMIN_TOKEN` |) |
58
-
59
- ### Auth headers
60
-
61
- The console session token is sent as `Authorization: Bearer <token>` on every
62
- request. Console requests hit `/api/platform/*`; admin requests hit the proxy at
63
- `/api/projects/:id/admin/*` (which validates the session, then injects its own
64
- `X-Platform-Token` to the project). In direct mode the admin token is the Bearer.
65
-
66
- ## Commands
67
-
68
- Global flags: `-o/--output pretty|json|yaml|env` (`--json` is `-o json`),
69
- `--yes/-y`, `--project/-p/--project-ref <id>`, `--url/-u <consoleUrl>`,
70
- `--token <t>`, `--workdir <dir>`, `--debug` (one stderr line per HTTP request),
71
- `-h/--help`, `-v/--version`.
72
-
73
- Commands follow the Supabase CLI's names. Where Motherbase already had its own
74
- name, both work: `projects api-keys` / `keys list`, `backups list|restore` /
75
- `db backups|restore`, `functions download` / `functions pull`, `db lint` /
76
- `rls lint`, `gen types --lang <l>` / `gen types <l>`.
77
-
78
- - **Connection**: `login`, `logout`, `whoami`, `link`, `unlink`, `status`
79
- - **Orgs & projects (Console)**: `orgs list|create`, `projects list|create|start|stop|restart|update|rebuild|delete|logs|info|limits|api-keys`
80
- - **Branches (Console)**: `branches create <name> [--with-data] [--git-branch <ref>]`, `branches list|get|update|delete|pause|unpause|reset|merge|rebase|switch <name>`
81
- - **Domains (Console)**: `domains create --custom-hostname <host>`, `domains get|reverify|activate|delete`, `vanity-subdomains get|check-availability|activate --desired-subdomain <name>|delete`
82
- - **Database access**: `network-restrictions get|update --db-allow-cidr <cidr> ...`, `ssl-enforcement get|update --enable-db-ssl-enforcement|--disable-db-ssl-enforcement`
83
- - **Local self-host** (docker compose): `init`, `start`, `stop`, `deploy`, `logs`
84
- - **Database**: `db push|pull|diff|reset|dump|seed`, `db tables|sql|backup|restore|backups|lint`, `backups list|restore`, `test db`
85
- - **Database objects**: `db indexes list|create|drop`, `db types list|create|add-value|rename-value|drop`, `db roles list|create|alter|drop`, `db column-privileges list|grant|revoke`, `db publications list|create|alter|drop`
86
- - **Postgres config**: `postgres-config get [--all]`, `postgres-config update --config k=v [--scope database|role|system] [--replace-existing-overrides]`, `postgres-config delete --config k1,k2`
87
- - **Migrations**: `migration new|list|up|down|repair|squash|fetch|diff|get|create|apply|rollback` (`migrations` is an alias)
88
- - **Import**: `import --from-supabase <conn> [--preview] [--no-data] [--no-auth]`
89
- - **RLS**: `rls list|enable|disable`, `rls policy create|delete`
90
- - **Users**: `users list|get|create|update|delete|reset-password|promote|demote|revoke-sessions|audit`
91
- - **Storage**: `storage buckets list|create|delete`, `storage ls|cp|mv|rm [-r]` on `ss:///bucket/key` paths
92
- - **Functions**: `functions list|get|new|deploy|pull|download|serve|delete|invoke|logs`
93
- - **Secrets**: `secrets list|unset`, `secrets set NAME=VALUE ... [--env-file .env]`
94
- - **Realtime**: `realtime config|channels`
95
- - **Webhooks**: `webhooks list|create|delete|test`
96
- - **Cron**: `cron list|create|delete|toggle`
97
- - **Queues**: `queues list|enable|expose|create|drop|send|read|archive|purge`
98
- - **Vault**: `vault list|enable|create|update|reveal|delete`
99
- - **Wrappers**: `wrappers list|enable|create-server|drop-server|credentials|import|create-table|drop-table`
100
- - **Config**: `config list|get|set`
101
- - **Inspect**: `inspect db <query>`, `inspect report`, `inspect logs|stats|performance|index-advisor|requests|advisor|shield`
102
- - **Codegen**: `gen types [--lang typescript|zod] [--schema public] [--local] [--output <file>] [--check]`
103
- - **AI agents**: `mcp [--write]`
104
- - **Keys**: `gen signing-key [--algorithm ES256|RS256|EdDSA] [--append]`, `gen bearer-jwt --sub <user> [--role] [--valid-for 1h]`, `gen keys [-o env]`
105
- - **Shell**: `completion bash|zsh|fish` (e.g. `source <(motherbase completion bash)`)
106
-
107
- Run `motherbase <group> -h` for per-group usage.
108
-
109
- ## Migrations and seeds
110
-
111
- Local files, laid out like a Supabase project's `supabase/` directory:
112
-
113
- ```
114
- motherbase/
115
- migrations/<version>_<name>.sql `migration new <name>` stamps the version (UTC)
116
- seed.sql or db.seed.sql_paths in motherbase/config.json
117
- tests/*.sql pgTAP, for `motherbase test db`
118
- ```
119
-
120
- A migration file may end with a `-- @down` line followed by the SQL that undoes
121
- it; `migration down` needs one. The linked project keeps the history, keyed on
122
- `version`, and the Studio Migrations page shows the same rows (origin `cli`,
123
- `studio` or `git`).
124
-
125
- ```bash
126
- motherbase migration list # LOCAL | REMOTE side by side
127
- motherbase db push --dry-run # then without, add --include-seed for the seeds
128
- motherbase db pull # remote changes -> a new file, recorded as applied
129
- motherbase db diff -f add_index # the same diff, written as a new migration
130
- motherbase migration repair 20260101120000 --status reverted
131
- motherbase db reset --confirm # backup, empty app schemas, replay migrations + seed
132
- motherbase db dump -f schema.sql --schema-only
133
- ```
134
-
135
- Each pushed file runs in its own transaction; a push stops at the first file
136
- that fails, and nothing of that file is recorded. `db diff` replays the local
137
- migrations into a throwaway database on the same server and compares tables,
138
- columns and indexes: review what it writes. With no local migration yet, `db
139
- pull` writes the remote schema itself, from `pg_dump`. `db dump` used to take a
140
- server-side backup; that is `db backup` now.
141
-
142
- ## Type generation
143
-
144
- Generate TypeScript definitions for the live schema, in the shape supabase-js
145
- emits, so `createClient<Database>(url, key)` types every row, rejects unknown
146
- columns and types `.rpc()` calls:
147
-
148
- ```bash
149
- motherbase gen types typescript > database.types.ts
150
- motherbase gen types typescript --schema shop --output src/shop.types.ts
151
- ```
152
-
153
- With no `--output` the file goes to stdout and nothing else does, so the
154
- redirect above produces a compiling file. `--local` skips the Console proxy and
155
- talks to a project API on this machine (`MOTHERBASE_URL`, default
156
- `http://localhost:5001`, with `MOTHERBASE_ADMIN_TOKEN`).
157
-
158
- Gate CI on schema drift with `--check`, which never writes and exits non-zero
159
- when the committed file differs from a fresh generation:
160
-
161
- ```bash
162
- motherbase gen types typescript --check --output database.types.ts
163
- ```
164
-
165
- ## Storage paths
166
-
167
- Objects are addressed as the Supabase CLI does, `ss:///<bucket>/<key>`, and
168
- `-r` applies a command to everything under a prefix:
169
-
170
- ```bash
171
- motherbase storage ls # buckets
172
- motherbase storage ls ss:///media/img # one level; -r for every key
173
- motherbase storage cp ./logo.png ss:///media/img/ # upload (overwrites)
174
- motherbase storage cp -r ./site ss:///web/v2 # upload a directory tree
175
- motherbase storage cp -r ss:///web/v2 ./site-backup # download a prefix
176
- motherbase storage mv -r ss:///web/v2 ss:///web/live # move within a bucket
177
- motherbase storage rm -r ss:///web/old
178
- ```
179
-
180
- Bulk commands send one request per object and stop at the first failure,
181
- saying how many had already gone through. `mv` and in-bucket `cp` work within
182
- one bucket. The older forms still work: `cp ./a.png bucket:` uploads with a
183
- generated key, `cp <fileId> ./a.png` downloads and `rm <fileId>` deletes by id.
184
-
185
- ## Database inspection
186
-
187
- `inspect db` runs the Supabase CLI's diagnostic queries against the linked
188
- project, on its read-only SQL endpoint:
189
-
190
- ```bash
191
- motherbase inspect db outliers # slowest queries by total time
192
- motherbase inspect db table-stats -o json
193
- motherbase inspect report --output-dir reports # one CSV per query in reports/<YYYY-MM-DD>/
194
- ```
195
-
196
- The queries are `bloat`, `blocking`, `calls`, `db-stats`, `index-stats`,
197
- `locks`, `long-running-queries`, `outliers`, `replication-slots`, `role-stats`,
198
- `table-stats`, `traffic-profile` and `vacuum-stats`. The names Supabase has
199
- deprecated (`cache-hit`, `index-usage`, `table-sizes`, `unused-indexes`, …)
200
- still work and run the query that replaced them. `calls` and `outliers` read
201
- `pg_stat_statements`: it is preloaded by the Motherbase Postgres image but has
202
- to be created once per database (Studio > Database > Extensions, or
203
- `motherbase db sql -e "create extension pg_stat_statements"`); `inspect report`
204
- skips those two files until it is.
205
-
206
- ## MCP server
207
-
208
- `motherbase mcp` serves this project to an AI agent over stdio:
209
-
210
- ```json
211
- { "mcpServers": { "motherbase": { "command": "npx", "args": ["@motherbase/cli", "mcp"] } } }
212
- ```
213
-
214
- It exposes what the session can reach. With a linked project (or direct mode):
215
- `list_tables`, `describe_table`, `list_policies`, `simulate_rls`,
216
- `get_advisors`, `get_logs`, `generate_types`, `execute_sql` (read-only),
217
- `get_project_url`, `get_publishable_keys`, `list_extensions`,
218
- `list_migrations`, `list_edge_functions`, `get_edge_function`,
219
- `list_storage_buckets` and `get_storage_config`. With a console login:
220
- `list_organizations`, `get_organization`, `list_projects` and `get_project`.
221
-
222
- Everything that changes something needs `--write`: `apply_migration`,
223
- `execute_sql_write`, `deploy_edge_function`, `create_project`,
224
- `pause_project` and `restore_project`. The names and arguments follow
225
- Supabase's MCP server.
226
-
227
- ## Supabase migration
228
-
229
- Preview a Supabase import without writing to Motherbase:
230
-
231
- ```bash
232
- motherbase import --from-supabase "$SUPABASE_DB_URL" --preview --json
233
- ```
234
-
235
- Run the import:
236
-
237
- ```bash
238
- motherbase import --from-supabase "$SUPABASE_DB_URL" --yes
239
- ```
240
-
241
- The importer moves the portable parts of a Supabase project: `public` schema, table data, RLS policies, and email/password users from `auth.users`. Storage objects are not copied. Use `--no-data` or `--no-auth` for partial imports.
242
-
243
- ## Tests
244
-
245
- ```bash
246
- npm test # node --test, mocked fetch, no network/DB
247
- ```
1
+ # Motherbase CLI
2
+
3
+ A Supabase-CLI-like operator CLI for **Motherbase**. It drives both the
4
+ **Platform Console** (account + multi-project lifecycle) and a **linked project's
5
+ admin API** through the Console proxy, or a single project API directly.
6
+
7
+ Zero runtime dependencies. Node ≥ 18 (uses built-in `fetch`, `readline`, `fs`,
8
+ `child_process` only).
9
+
10
+ ```bash
11
+ node bin/motherbase.js --help # auto-generated help
12
+ npm link # or: npm i -g @motherbase/cli
13
+ motherbase login --url https://console.example.com
14
+ motherbase link # pick a project → writes ./.motherbase/config.json
15
+ motherbase db tables
16
+ motherbase functions deploy --name hello --route hello --file ./hello.js
17
+ ```
18
+
19
+ ## Connection model
20
+
21
+ 1. **Console / account**, `motherbase login [--url <consoleUrl>]` performs a real
22
+ Console login (`POST /api/platform/login`) and stores the session token.
23
+ 2. **Linked project**, `motherbase link [project]` records which project this
24
+ directory targets. All resource commands then route through the Console proxy
25
+ (`/api/projects/:id/admin/*`).
26
+ 3. **Direct mode (CI / single stack)**. Set `MOTHERBASE_URL` +
27
+ `MOTHERBASE_ADMIN_TOKEN` to talk straight to one project's `/api/admin/*`.
28
+
29
+ ### Configuration files
30
+
31
+ **Global credentials**: `~/.motherbase/config.json` (contains tokens, written `0o600`):
32
+
33
+ ```json
34
+ {
35
+ "consoles": {
36
+ "https://console.example.com": { "token": "…", "email": "you@example.com" }
37
+ },
38
+ "current": "https://console.example.com"
39
+ }
40
+ ```
41
+
42
+ **Project link**: `./.motherbase/config.json` (versionable, non-secret):
43
+
44
+ ```json
45
+ { "consoleUrl": "https://console.example.com", "projectId": "my-app", "projectName": "my-app" }
46
+ ```
47
+
48
+ ### Resolution precedence
49
+
50
+ `flags > env > config`, per value:
51
+
52
+ | Value | Flag | Env | Config |
53
+ | ----------- | ----------------- | ------------------------- | ------ |
54
+ | console URL | `--url/-u` | `MOTHERBASE_CONSOLE_URL` | link / global `current` |
55
+ | token | `--token` | `MOTHERBASE_TOKEN` | global console entry |
56
+ | project | `--project/-p` | `MOTHERBASE_PROJECT` | link |
57
+ | direct API | (| `MOTHERBASE_URL` + `MOTHERBASE_ADMIN_TOKEN` |) |
58
+
59
+ ### Auth headers
60
+
61
+ The console session token is sent as `Authorization: Bearer <token>` on every
62
+ request. Console requests hit `/api/platform/*`; admin requests hit the proxy at
63
+ `/api/projects/:id/admin/*` (which validates the session, then injects its own
64
+ `X-Platform-Token` to the project). In direct mode the admin token is the Bearer.
65
+
66
+ ## Commands
67
+
68
+ Global flags: `-o/--output pretty|json|yaml|env` (`--json` is `-o json`),
69
+ `--yes/-y`, `--project/-p/--project-ref <id>`, `--url/-u <consoleUrl>`,
70
+ `--token <t>`, `--workdir <dir>`, `--debug` (one stderr line per HTTP request),
71
+ `-h/--help`, `-v/--version`.
72
+
73
+ Commands follow the Supabase CLI's names. Where Motherbase already had its own
74
+ name, both work: `projects api-keys` / `keys list`, `backups list|restore` /
75
+ `db backups|restore`, `functions download` / `functions pull`, `db lint` /
76
+ `rls lint`, `gen types --lang <l>` / `gen types <l>`.
77
+
78
+ - **Connection**: `login`, `logout`, `whoami`, `link`, `unlink`, `status`
79
+ - **Orgs & projects (Console)**: `orgs list|create`, `projects list|create|start|stop|restart|update|rebuild|delete|logs|info|limits|api-keys`
80
+ - **Branches (Console)**: `branches create <name> [--with-data] [--git-branch <ref>]`, `branches list|get|update|delete|pause|unpause|reset|merge|rebase|switch <name>`
81
+ - **Domains (Console)**: `domains create --custom-hostname <host>`, `domains get|reverify|activate|delete`, `vanity-subdomains get|check-availability|activate --desired-subdomain <name>|delete`
82
+ - **Database access**: `network-restrictions get|update --db-allow-cidr <cidr> ...`, `ssl-enforcement get|update --enable-db-ssl-enforcement|--disable-db-ssl-enforcement`
83
+ - **Local self-host** (docker compose): `init`, `start`, `stop`, `deploy`, `logs`
84
+ - **Database**: `db push|pull|diff|reset|dump|seed`, `db tables|sql|backup|restore|backups|lint`, `backups list|restore`, `test db`
85
+ - **Database objects**: `db indexes list|create|drop`, `db types list|create|add-value|rename-value|drop`, `db roles list|create|alter|drop`, `db column-privileges list|grant|revoke`, `db publications list|create|alter|drop`
86
+ - **Postgres config**: `postgres-config get [--all]`, `postgres-config update --config k=v [--scope database|role|system] [--replace-existing-overrides]`, `postgres-config delete --config k1,k2`
87
+ - **Migrations**: `migration new|list|up|down|repair|squash|fetch|diff|get|create|apply|rollback` (`migrations` is an alias)
88
+ - **Import**: `import --from-supabase <conn> [--preview] [--no-data] [--no-auth]`
89
+ - **RLS**: `rls list|enable|disable`, `rls policy create|delete`
90
+ - **Users**: `users list|get|create|update|delete|reset-password|promote|demote|revoke-sessions|audit`
91
+ - **Storage**: `storage buckets list|create|delete`, `storage ls|cp|mv|rm [-r]` on `ss:///bucket/key` paths
92
+ - **Functions**: `functions list|get|new|deploy|pull|download|serve|delete|invoke|logs`
93
+ - **Secrets**: `secrets list|unset`, `secrets set NAME=VALUE ... [--env-file .env]`
94
+ - **Realtime**: `realtime config|channels`
95
+ - **Webhooks**: `webhooks list|create|delete|test`
96
+ - **Cron**: `cron list|create|delete|toggle`
97
+ - **Queues**: `queues list|enable|expose|create|drop|send|read|archive|purge`
98
+ - **Vault**: `vault list|enable|create|update|reveal|delete`
99
+ - **Wrappers**: `wrappers list|enable|create-server|drop-server|credentials|import|create-table|drop-table`
100
+ - **Config**: `config list|get|set`
101
+ - **Inspect**: `inspect db <query>`, `inspect report`, `inspect logs|stats|performance|index-advisor|requests|advisor|shield`
102
+ - **Codegen**: `gen types [--lang typescript|zod] [--schema public] [--local] [--output <file>] [--check]`
103
+ - **AI agents**: `mcp [--write]`
104
+ - **Keys**: `gen signing-key [--algorithm ES256|RS256|EdDSA] [--append]`, `gen bearer-jwt --sub <user> [--role] [--valid-for 1h]`, `gen keys [-o env]`
105
+ - **Shell**: `completion bash|zsh|fish` (e.g. `source <(motherbase completion bash)`)
106
+
107
+ Run `motherbase <group> -h` for per-group usage.
108
+
109
+ ## Migrations and seeds
110
+
111
+ Local files, laid out like a Supabase project's `supabase/` directory:
112
+
113
+ ```
114
+ motherbase/
115
+ migrations/<version>_<name>.sql `migration new <name>` stamps the version (UTC)
116
+ seed.sql or db.seed.sql_paths in motherbase/config.json
117
+ tests/*.sql pgTAP, for `motherbase test db`
118
+ ```
119
+
120
+ A migration file may end with a `-- @down` line followed by the SQL that undoes
121
+ it; `migration down` needs one. The linked project keeps the history, keyed on
122
+ `version`, and the Studio Migrations page shows the same rows (origin `cli`,
123
+ `studio` or `git`).
124
+
125
+ ```bash
126
+ motherbase migration list # LOCAL | REMOTE side by side
127
+ motherbase db push --dry-run # then without, add --include-seed for the seeds
128
+ motherbase db pull # remote changes -> a new file, recorded as applied
129
+ motherbase db diff -f add_index # the same diff, written as a new migration
130
+ motherbase migration repair 20260101120000 --status reverted
131
+ motherbase db reset --confirm # backup, empty app schemas, replay migrations + seed
132
+ motherbase db dump -f schema.sql --schema-only
133
+ ```
134
+
135
+ Each pushed file runs in its own transaction; a push stops at the first file
136
+ that fails, and nothing of that file is recorded. `db diff` replays the local
137
+ migrations into a throwaway database on the same server and compares tables,
138
+ columns and indexes: review what it writes. With no local migration yet, `db
139
+ pull` writes the remote schema itself, from `pg_dump`. `db dump` used to take a
140
+ server-side backup; that is `db backup` now.
141
+
142
+ ## Type generation
143
+
144
+ Generate TypeScript definitions for the live schema, in the shape supabase-js
145
+ emits, so `createClient<Database>(url, key)` types every row, rejects unknown
146
+ columns and types `.rpc()` calls:
147
+
148
+ ```bash
149
+ motherbase gen types typescript # in a terminal: writes ./database.types.ts
150
+ motherbase gen types typescript > database.types.ts # piped: prints the file
151
+ motherbase gen types typescript --schema shop --output src/shop.types.ts
152
+ ```
153
+
154
+ With no `--output` the file goes to stdout and nothing else does, so the
155
+ redirect above produces a compiling file. `--local` skips the Console proxy and
156
+ talks to a project API on this machine (`MOTHERBASE_URL`, default
157
+ `http://localhost:5001`, with `MOTHERBASE_ADMIN_TOKEN`).
158
+
159
+ Gate CI on schema drift with `--check`, which never writes and exits non-zero
160
+ when the committed file differs from a fresh generation:
161
+
162
+ ```bash
163
+ motherbase gen types typescript --check --output database.types.ts
164
+ ```
165
+
166
+ ## Storage paths
167
+
168
+ Objects are addressed as the Supabase CLI does, `ss:///<bucket>/<key>`, and
169
+ `-r` applies a command to everything under a prefix:
170
+
171
+ ```bash
172
+ motherbase storage ls # buckets
173
+ motherbase storage ls ss:///media/img # one level; -r for every key
174
+ motherbase storage cp ./logo.png ss:///media/img/ # upload (overwrites)
175
+ motherbase storage cp -r ./site ss:///web/v2 # upload a directory tree
176
+ motherbase storage cp -r ss:///web/v2 ./site-backup # download a prefix
177
+ motherbase storage mv -r ss:///web/v2 ss:///web/live # move within a bucket
178
+ motherbase storage rm -r ss:///web/old
179
+ ```
180
+
181
+ Bulk commands send one request per object and stop at the first failure,
182
+ saying how many had already gone through. `mv` and in-bucket `cp` work within
183
+ one bucket. The older forms still work: `cp ./a.png bucket:` uploads with a
184
+ generated key, `cp <fileId> ./a.png` downloads and `rm <fileId>` deletes by id.
185
+
186
+ ## Database inspection
187
+
188
+ `inspect db` runs the Supabase CLI's diagnostic queries against the linked
189
+ project, on its read-only SQL endpoint:
190
+
191
+ ```bash
192
+ motherbase inspect db outliers # slowest queries by total time
193
+ motherbase inspect db table-stats -o json
194
+ motherbase inspect report --output-dir reports # one CSV per query in reports/<YYYY-MM-DD>/
195
+ ```
196
+
197
+ The queries are `bloat`, `blocking`, `calls`, `db-stats`, `index-stats`,
198
+ `locks`, `long-running-queries`, `outliers`, `replication-slots`, `role-stats`,
199
+ `table-stats`, `traffic-profile` and `vacuum-stats`. The names Supabase has
200
+ deprecated (`cache-hit`, `index-usage`, `table-sizes`, `unused-indexes`, …)
201
+ still work and run the query that replaced them. `calls` and `outliers` read
202
+ `pg_stat_statements`: it is preloaded by the Motherbase Postgres image but has
203
+ to be created once per database (Studio > Database > Extensions, or
204
+ `motherbase db sql -e "create extension pg_stat_statements"`); `inspect report`
205
+ skips those two files until it is.
206
+
207
+ ## MCP server
208
+
209
+ `motherbase mcp` serves this project to an AI agent over stdio:
210
+
211
+ ```json
212
+ { "mcpServers": { "motherbase": { "command": "npx", "args": ["@motherbase/cli", "mcp"] } } }
213
+ ```
214
+
215
+ It exposes what the session can reach. With a linked project (or direct mode):
216
+ `list_tables`, `describe_table`, `list_policies`, `simulate_rls`,
217
+ `get_advisors`, `get_logs`, `generate_types`, `execute_sql` (read-only),
218
+ `get_project_url`, `get_publishable_keys`, `list_extensions`,
219
+ `list_migrations`, `list_edge_functions`, `get_edge_function`,
220
+ `list_storage_buckets` and `get_storage_config`. With a console login:
221
+ `list_organizations`, `get_organization`, `list_projects` and `get_project`.
222
+
223
+ Everything that changes something needs `--write`: `apply_migration`,
224
+ `execute_sql_write`, `deploy_edge_function`, `create_project`,
225
+ `pause_project` and `restore_project`. The names and arguments follow
226
+ Supabase's MCP server.
227
+
228
+ ## Supabase migration
229
+
230
+ Preview a Supabase import without writing to Motherbase:
231
+
232
+ ```bash
233
+ motherbase import --from-supabase "$SUPABASE_DB_URL" --preview --json
234
+ ```
235
+
236
+ Run the import:
237
+
238
+ ```bash
239
+ motherbase import --from-supabase "$SUPABASE_DB_URL" --yes
240
+ ```
241
+
242
+ The importer moves the portable parts of a Supabase project: `public` schema, table data, RLS policies, and email/password users from `auth.users`. Storage objects are not copied. Use `--no-data` or `--no-auth` for partial imports.
243
+
244
+ ## Tests
245
+
246
+ ```bash
247
+ npm test # node --test, mocked fetch, no network/DB
248
+ ```
@@ -0,0 +1,5 @@
1
+ {
2
+ "consoleUrl": "https://console.test.fidelix.pro",
3
+ "projectId": "gvask8",
4
+ "projectName": "gvask8"
5
+ }
package/bin/motherbase.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';
3
-
4
- const { main } = require('../src/main');
5
-
6
- main(process.argv.slice(2))
7
- .then(code => { process.exitCode = code || 0; })
8
- .catch(err => {
9
- process.stderr.write((err && err.message ? err.message : String(err)) + '\n');
10
- process.exitCode = 1;
11
- });
2
+ 'use strict';
3
+
4
+ const { main } = require('../src/main');
5
+
6
+ main(process.argv.slice(2))
7
+ .then(code => { process.exitCode = code || 0; })
8
+ .catch(err => {
9
+ process.stderr.write((err && err.message ? err.message : String(err)) + '\n');
10
+ process.exitCode = 1;
11
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motherbase/cli",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Motherbase operator CLI: drives the Platform Console and linked projects.",
5
5
  "type": "commonjs",
6
6
  "bin": {