@supacloud/cli 0.10.0 → 0.12.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.
- package/README.md +115 -3
- package/dist/index.js +6784 -14197
- package/package.json +4 -3
- package/skills/supacloud-cli/SKILL.md +83 -0
- package/skills/supacloud-cli/agents/openai.yaml +4 -0
- package/skills/supacloud-cli/references/command-map.md +50 -0
- package/skills/supacloud-cli/references/database-workflow.md +112 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supacloud/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Project-scoped CLI for SupaCloud users",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
|
-
"README.md"
|
|
12
|
+
"README.md",
|
|
13
|
+
"skills"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
15
16
|
"dev": "bun run --watch src/index.ts",
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
"directory": "packages/cli"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"
|
|
34
|
+
"@sinclair/typebox": "^0.34.52"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@types/bun": "^1.3.14",
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: supacloud-cli
|
|
3
|
+
description: Use when operating, implementing, diagnosing, deploying, or documenting a SupaCloud project through supacloud-cli, especially database schema, functions/RPC, triggers, RLS, indexes, grants, extensions, migrations, backups, auth, storage, Edge Functions, frontend, queues, task events, diagnostics, or gateway work. Also use when an AI might otherwise call SQL, psql, a database API, or the Management API directly.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SupaCloud CLI
|
|
7
|
+
|
|
8
|
+
Use `supacloud-cli` as the project-level control surface and keep durable changes reproducible from version-controlled files. Use `supacloud-admin` only for server/platform operations.
|
|
9
|
+
|
|
10
|
+
## Non-negotiable rules
|
|
11
|
+
|
|
12
|
+
1. Inspect repository state and project context before any action:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
git status --short --branch
|
|
16
|
+
supacloud-cli status
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
A missing remote project context does not block local `migration_new`, `db_diff`, or `db_reset`; it blocks remote inspection/apply until context is supplied.
|
|
20
|
+
|
|
21
|
+
2. Never place secrets, service-role keys, database URLs, passwords, or tokens in commands that will be logged, source files, migration files, or chat output.
|
|
22
|
+
3. Treat schema, functions/RPC, triggers, RLS policies, indexes, grants, extensions, and seed/reference-data changes as migrations. Do not apply them through `database query`, `psql`, a dashboard SQL editor, or a raw Management API call.
|
|
23
|
+
4. Use `database query` only for read-only inspection unless the user explicitly authorizes a documented break-glass operation. Break-glass work still requires a backup, rollback SQL, and a follow-up migration in the same task.
|
|
24
|
+
5. Run a remote migration dry-run before apply. Production apply requires explicit user approval in the current task.
|
|
25
|
+
6. Do not edit `supabase_migrations.schema_migrations` through ordinary SQL. Migration history is an application ledger, not a schema backup or source of truth. For a proven-equivalent historical baseline, use the controlled `database baseline_migrations` action with dry-run and explicit approval.
|
|
26
|
+
7. Service-role credentials authenticate the SupaCloud Management API. Never reinterpret them as PostgreSQL passwords or forward them to the official Supabase CLI.
|
|
27
|
+
|
|
28
|
+
## Workflow
|
|
29
|
+
|
|
30
|
+
1. Classify the request using [references/command-map.md](references/command-map.md).
|
|
31
|
+
2. For database work, load [references/database-workflow.md](references/database-workflow.md) and choose either new-change or historical-drift reconciliation.
|
|
32
|
+
3. Prefer the smallest read-only inspection that proves current state.
|
|
33
|
+
4. Create or update version-controlled artifacts before remote writes.
|
|
34
|
+
5. Verify locally, inspect the diff, and run the narrowest relevant tests.
|
|
35
|
+
6. Preview remote changes with `--dry_run`.
|
|
36
|
+
7. Apply only within the user-authorized environment and scope.
|
|
37
|
+
8. Read back migration history and affected resources; report exact evidence and any remaining drift.
|
|
38
|
+
|
|
39
|
+
## Database default
|
|
40
|
+
|
|
41
|
+
For a new database change:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
supacloud-cli supabase migration_new --name add_accounts
|
|
45
|
+
# Edit the generated SQL migration.
|
|
46
|
+
supacloud-cli supabase db_reset --no_seed
|
|
47
|
+
supacloud-cli supabase push --ref <project-ref> --dir supabase/migrations --dry_run
|
|
48
|
+
# Apply only after explicit approval.
|
|
49
|
+
supacloud-cli supabase push --ref <project-ref> --dir supabase/migrations
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Use `db_diff` as an authoring aid, not as permission to bypass review:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
supacloud-cli supabase db_diff --schema public --name reconcile_public_schema
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
For a database that was previously changed directly, stop further direct writes and follow the reconciliation workflow in [references/database-workflow.md](references/database-workflow.md). Do not push guessed historical migrations against a live database. After schema equivalence is proven, preview and record the baseline through:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
supacloud-cli database baseline_migrations \
|
|
62
|
+
--ref <project-ref> \
|
|
63
|
+
--dir supabase/migrations \
|
|
64
|
+
--dry_run
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## CLI boundaries
|
|
68
|
+
|
|
69
|
+
- `supacloud-cli`: project status, database, migrations, auth, storage, Edge Functions, frontend, queues, task events, diagnostics, and project gateway configuration.
|
|
70
|
+
- `supacloud-admin`: installation, upgrades, SSH diagnostics, platform-wide project lifecycle, tenant runtime, and server operations.
|
|
71
|
+
- Official `supabase` CLI: invoked only through the allowlisted `supacloud-cli supabase` adapter for supported local authoring or explicit-DSN inspection commands.
|
|
72
|
+
- Direct HTTP/SQL: read-only diagnosis or an explicitly approved break-glass path; never the default implementation path.
|
|
73
|
+
|
|
74
|
+
## Completion evidence
|
|
75
|
+
|
|
76
|
+
Before declaring success, provide:
|
|
77
|
+
|
|
78
|
+
- migration filenames and reviewed diff;
|
|
79
|
+
- local reset/test/typecheck evidence appropriate to the project;
|
|
80
|
+
- remote dry-run evidence;
|
|
81
|
+
- explicit approval reference for production apply;
|
|
82
|
+
- applied migration/read-back evidence;
|
|
83
|
+
- backup and rollback references for destructive or reconciliation work.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# SupaCloud CLI command map
|
|
2
|
+
|
|
3
|
+
Load this reference when selecting a command surface or when a user asks an AI to “just change the database.”
|
|
4
|
+
|
|
5
|
+
## Decision table
|
|
6
|
+
|
|
7
|
+
| Intent | Use | Guardrail |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| Inspect current project binding | `supacloud-cli status` | Read-only; run first |
|
|
10
|
+
| Inspect project health/logs/tasks | `project`, `queue`, `task_events`, `diagnostics` | Prefer bounded reads |
|
|
11
|
+
| Read database rows or metadata | `database query` and database inspection actions | `SELECT`/read-only by default |
|
|
12
|
+
| Create schema/function/RPC/trigger/RLS/index/grant/extension | `supabase migration_new`, then edit SQL | Never direct remote DDL |
|
|
13
|
+
| Generate migration from local schema changes | `supabase db_diff` | Review generated SQL before use |
|
|
14
|
+
| Rebuild local database | `supabase db_reset` | Local only; preserve required seed behavior |
|
|
15
|
+
| Inspect or back up a remote database | `supabase db_pull`, `migration_list`, `db_dump`, `gen_types` | Requires explicit PostgreSQL DSN; redact it |
|
|
16
|
+
| Preview/apply migrations remotely | `supabase push` | Always dry-run first; production needs explicit approval |
|
|
17
|
+
| Mark proven-equivalent historical migrations as applied | `database baseline_migrations` | Dry-run, schema-equivalence proof, backup, explicit approval |
|
|
18
|
+
| Manage Auth/Storage/Edge Functions/frontend/secrets | Corresponding project module | Keep deployable config/code in version control |
|
|
19
|
+
| Configure project gateway routes | `gateway` | Requires an admin-capable project token; inspect before write |
|
|
20
|
+
| Install/upgrade/debug SupaCloud servers | `supacloud-admin` | Platform boundary; not a project CLI action |
|
|
21
|
+
|
|
22
|
+
If `status` reports missing project context, local migration authoring may still
|
|
23
|
+
continue. Do not attempt remote inspection, baseline, push, or resource changes
|
|
24
|
+
until a project-scoped context is resolved.
|
|
25
|
+
|
|
26
|
+
## Command groups
|
|
27
|
+
|
|
28
|
+
- `status`: resolved context, Management API connectivity, authentication, and project reachability.
|
|
29
|
+
- `project`: project metadata, health, logs, API keys/settings, background tasks, retry/cancel, DLQ, and background settings.
|
|
30
|
+
- `database`: read/query, schema inspection, extensions, indexes, RLS, stats, migration push, controlled historical baseline, and SQL-file execution.
|
|
31
|
+
- `supabase`: allowlisted official CLI adapter for migration authoring, local reset/diff, explicit-DSN inspection/backup/type generation, and SupaCloud-controlled migration push.
|
|
32
|
+
- `auth`: provider and authentication configuration.
|
|
33
|
+
- `storage`: buckets and object-management workflows.
|
|
34
|
+
- `edge_functions`: deploy and configure Edge Functions.
|
|
35
|
+
- `frontend`: list, build/deploy, domain, and deployment workflows.
|
|
36
|
+
- `secrets`: project secret management; never print values after write.
|
|
37
|
+
- `queue`, `task_events`, `diagnostics`: asynchronous workload operations and bounded diagnostics.
|
|
38
|
+
- `gateway`: project route/config/rebuild operations.
|
|
39
|
+
- `ai`: inspect or install this packaged Skill.
|
|
40
|
+
|
|
41
|
+
## Safe inspection pattern
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
supacloud-cli status
|
|
45
|
+
supacloud-cli project get
|
|
46
|
+
supacloud-cli project health
|
|
47
|
+
supacloud-cli supabase migration_list --db_url "$SUPACLOUD_DB_URL"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Do not paste the DSN value into chat or commit it to shell scripts. Prefer an environment variable supplied outside the repository.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Database migration and drift workflow
|
|
2
|
+
|
|
3
|
+
Migration files are the durable source of truth. `supabase_migrations.schema_migrations` records what the controlled migration path applied; it does not discover console/`psql` changes and does not reconstruct the current schema.
|
|
4
|
+
|
|
5
|
+
## New changes
|
|
6
|
+
|
|
7
|
+
1. Inspect the repository, existing migrations, migration history, and relevant schema.
|
|
8
|
+
2. Create a migration:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
supacloud-cli supabase migration_new --name <intent>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
3. Put tables, views, functions/RPC, triggers, RLS, indexes, grants, extensions, and required reference data in the generated SQL file.
|
|
15
|
+
4. Make migrations deterministic and reviewable:
|
|
16
|
+
- qualify schemas;
|
|
17
|
+
- avoid environment-specific IDs, domains, and secrets;
|
|
18
|
+
- use transactions when the operation supports them;
|
|
19
|
+
- document destructive statements and rollback strategy;
|
|
20
|
+
- avoid modifying an already-applied migration.
|
|
21
|
+
5. Rebuild locally and run application tests:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
supacloud-cli supabase db_reset --no_seed
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
6. Preview remote application:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
supacloud-cli supabase push --ref <project-ref> --dir supabase/migrations --dry_run
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
7. After explicit environment approval, apply and read back migration history.
|
|
34
|
+
|
|
35
|
+
## Previously changed remote database
|
|
36
|
+
|
|
37
|
+
Do not fabricate old migration files and immediately push them. Reconcile deliberately:
|
|
38
|
+
|
|
39
|
+
1. Freeze direct SQL/dashboard writes for the reconciliation window.
|
|
40
|
+
2. Inventory three states separately:
|
|
41
|
+
- version-controlled migration files;
|
|
42
|
+
- remote migration-history rows;
|
|
43
|
+
- actual remote schema/functions/policies/grants.
|
|
44
|
+
3. Create a schema-only backup before changing tracking or schema:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
supacloud-cli supabase db_dump \
|
|
48
|
+
--db_url "$SUPACLOUD_DB_URL" \
|
|
49
|
+
--file backups/pre-reconcile-schema.sql
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
4. In an isolated branch/worktree, pull the actual remote schema:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
supacloud-cli supabase db_pull \
|
|
56
|
+
--db_url "$SUPACLOUD_DB_URL" \
|
|
57
|
+
--declarative \
|
|
58
|
+
--name remote_baseline
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
5. Review the generated artifacts. Remove ownership, secret, environment-specific, and extension noise that should not be portable.
|
|
62
|
+
6. Choose one strategy:
|
|
63
|
+
- Empty/new migration repository: establish a reviewed baseline representing the current remote schema.
|
|
64
|
+
- Existing migration repository: keep applied migrations immutable and add one reconciliation migration for the verified delta.
|
|
65
|
+
7. Prove the chosen migration set can recreate the desired schema from a clean local database. Compare the recreated schema with the captured remote schema.
|
|
66
|
+
8. Only after equivalence is proven, preview the controlled baseline action:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
supacloud-cli database baseline_migrations \
|
|
70
|
+
--ref <project-ref> \
|
|
71
|
+
--dir supabase/migrations \
|
|
72
|
+
--dry_run
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
9. Review every file listed under `Would mark as applied`. Obtain explicit approval, then rerun without `--dry_run`. This action records the selected local migration files through the SupaCloud migration-mode API; it does not execute their DDL.
|
|
76
|
+
10. Never insert/update/delete `supabase_migrations.schema_migrations` via `database query`. If the controlled baseline action cannot represent the verified state, stop and request operator assistance.
|
|
77
|
+
11. Run `supabase push --dry_run`; it should report no unintended pending historical migration. Read back migration history and affected objects.
|
|
78
|
+
|
|
79
|
+
## Functions, triggers, RLS, and grants
|
|
80
|
+
|
|
81
|
+
These are schema objects even when business logic lives inside them. Keep them in migrations:
|
|
82
|
+
|
|
83
|
+
- `CREATE OR REPLACE FUNCTION ...`
|
|
84
|
+
- trigger creation/removal;
|
|
85
|
+
- `ALTER TABLE ... ENABLE ROW LEVEL SECURITY`;
|
|
86
|
+
- `CREATE POLICY` / `ALTER POLICY` / `DROP POLICY`;
|
|
87
|
+
- role grants and default privileges;
|
|
88
|
+
- extension enablement and version changes.
|
|
89
|
+
|
|
90
|
+
For function replacement, verify signature, volatility, security definer/invoker behavior, `search_path`, ownership, grants, and callers. A function body diff without its security attributes is incomplete.
|
|
91
|
+
|
|
92
|
+
## Backups and rollback
|
|
93
|
+
|
|
94
|
+
- Schema backup: `supabase db_dump` with the default schema mode.
|
|
95
|
+
- Data backup: use an approved data-backup path; do not assume schema dump includes application data.
|
|
96
|
+
- Restore testing: prove the backup can be parsed/restored in an isolated database before relying on it.
|
|
97
|
+
- Destructive migrations: prefer expand-contract rollout, record affected rows, and provide reversal or forward-fix SQL.
|
|
98
|
+
- Migration history is not a backup. Keep backups outside the migration directory and exclude credentials from filenames/content.
|
|
99
|
+
|
|
100
|
+
## Break-glass
|
|
101
|
+
|
|
102
|
+
A direct remote write is acceptable only when waiting for the normal migration pipeline would cause greater harm and the user explicitly authorizes it. Before execution:
|
|
103
|
+
|
|
104
|
+
1. record incident scope and exact target;
|
|
105
|
+
2. take a relevant backup;
|
|
106
|
+
3. prepare bounded SQL plus rollback SQL;
|
|
107
|
+
4. show the SQL without secrets;
|
|
108
|
+
5. receive explicit approval;
|
|
109
|
+
6. execute once and read back;
|
|
110
|
+
7. create the equivalent migration immediately so repository truth matches production.
|
|
111
|
+
|
|
112
|
+
If any item is missing, stop instead of improvising a direct write.
|