@delegance/claude-autopilot 5.2.2 → 5.5.2
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/CHANGELOG.md +97 -0
- package/README.md +49 -17
- package/dist/src/adapters/council/claude.js +2 -1
- package/dist/src/adapters/council/openai.js +2 -1
- package/dist/src/adapters/deploy/generic.d.ts +39 -0
- package/dist/src/adapters/deploy/generic.js +98 -0
- package/dist/src/adapters/deploy/index.d.ts +13 -0
- package/dist/src/adapters/deploy/index.js +45 -0
- package/dist/src/adapters/deploy/types.d.ts +157 -0
- package/dist/src/adapters/deploy/types.js +15 -0
- package/dist/src/adapters/deploy/vercel.d.ts +127 -0
- package/dist/src/adapters/deploy/vercel.js +446 -0
- package/dist/src/adapters/review-engine/claude.js +2 -1
- package/dist/src/adapters/review-engine/codex.js +2 -1
- package/dist/src/adapters/review-engine/gemini.js +2 -1
- package/dist/src/adapters/review-engine/openai-compatible.js +2 -1
- package/dist/src/adapters/sdk-loader.d.ts +15 -0
- package/dist/src/adapters/sdk-loader.js +77 -0
- package/dist/src/cli/deploy.d.ts +71 -0
- package/dist/src/cli/deploy.js +514 -0
- package/dist/src/cli/index.js +91 -3
- package/dist/src/cli/preflight.js +76 -1
- package/dist/src/core/config/schema.d.ts +34 -0
- package/dist/src/core/config/schema.js +18 -0
- package/dist/src/core/config/types.d.ts +6 -0
- package/dist/src/core/errors.d.ts +1 -1
- package/dist/src/core/errors.js +1 -0
- package/dist/src/core/migrate/detector-rules.js +6 -0
- package/dist/src/core/migrate/schema-validator.js +7 -0
- package/package.json +8 -5
- package/scripts/autoregress.ts +2 -1
- package/skills/migrate/SKILL.md +193 -47
package/skills/migrate/SKILL.md
CHANGED
|
@@ -1,83 +1,229 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: migrate
|
|
3
|
-
description:
|
|
3
|
+
description: Framework-agnostic database migration orchestrator. Reads .autopilot/stack.md, runs the configured per-env command (Rails, Alembic, Prisma, Drizzle, golang-migrate, dbmate, flyway, supabase-cli, custom), enforces policy gates, and emits a structured result artifact. For Supabase-specific repos with data/deltas/* layout use `migrate-supabase` instead.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# /migrate — Generic database migration orchestrator
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
The thin, framework-agnostic migrate skill. Wraps any migration tool in a uniform contract:
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
1. Validate `.autopilot/stack.md` against the JSON schema
|
|
11
|
+
2. Resolve the configured skill + apply policy (clean git, manual approval, prod-in-CI gate)
|
|
12
|
+
3. Run `migrate.envs.<env>.command` via `spawn(shell: false)` — no shell injection surface
|
|
13
|
+
4. Capture stdout/stderr, parse the result artifact, append an audit-log entry
|
|
14
|
+
5. Return a `ResultArtifact` to the caller (autopilot pipeline or CLI)
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
This skill **does not know what your migration tool is**. It just executes the command you point it at and reports the outcome. Tool-specific behavior (e.g., Supabase's `data/deltas/*.sql` ledger or auto-regenerating `types/supabase.ts`) lives in `migrate-supabase`. Everything else uses this one.
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
## Usage
|
|
15
19
|
|
|
16
|
-
###
|
|
20
|
+
### CLI
|
|
17
21
|
|
|
18
22
|
```bash
|
|
19
|
-
|
|
23
|
+
claude-autopilot migrate # default env: dev
|
|
24
|
+
claude-autopilot migrate --env qa
|
|
25
|
+
claude-autopilot migrate --env prod --yes # required for prod (manual approval)
|
|
26
|
+
claude-autopilot migrate doctor # validate stack.md without running
|
|
20
27
|
```
|
|
21
28
|
|
|
22
|
-
|
|
29
|
+
### Autopilot pipeline
|
|
30
|
+
|
|
31
|
+
The dispatcher invokes the skill automatically when `migrate` is in the pipeline plan. The skill receives the invocation envelope via `AUTOPILOT_ENVELOPE` and writes its result to `AUTOPILOT_RESULT_PATH`.
|
|
32
|
+
|
|
33
|
+
## Configuration
|
|
34
|
+
|
|
35
|
+
Add a `migrate` block to `.autopilot/stack.md`:
|
|
36
|
+
|
|
37
|
+
```yaml
|
|
38
|
+
schema_version: 1
|
|
39
|
+
migrate:
|
|
40
|
+
skill: "migrate@1"
|
|
41
|
+
envs:
|
|
42
|
+
dev:
|
|
43
|
+
command: { exec: "<tool>", args: ["<args>"] }
|
|
44
|
+
env_file: ".env.dev"
|
|
45
|
+
qa:
|
|
46
|
+
command: { exec: "<tool>", args: ["<args>"] }
|
|
47
|
+
prod:
|
|
48
|
+
command: { exec: "<tool>", args: ["<args>"] }
|
|
49
|
+
policy:
|
|
50
|
+
allow_prod_in_ci: false
|
|
51
|
+
require_clean_git: true
|
|
52
|
+
require_manual_approval: true
|
|
53
|
+
require_dry_run_first: false
|
|
54
|
+
```
|
|
23
55
|
|
|
24
|
-
|
|
56
|
+
The `init` flow auto-detects most common toolchains and pre-fills sensible commands. Run `claude-autopilot init` once to bootstrap.
|
|
25
57
|
|
|
26
|
-
|
|
27
|
-
|
|
58
|
+
## Examples by toolchain
|
|
59
|
+
|
|
60
|
+
### Rails (Active Record)
|
|
61
|
+
|
|
62
|
+
```yaml
|
|
63
|
+
migrate:
|
|
64
|
+
skill: "migrate@1"
|
|
65
|
+
envs:
|
|
66
|
+
dev:
|
|
67
|
+
command: { exec: "rails", args: ["db:migrate"] }
|
|
68
|
+
env_file: ".env.development"
|
|
69
|
+
prod:
|
|
70
|
+
command: { exec: "rails", args: ["db:migrate", "RAILS_ENV=production"] }
|
|
28
71
|
```
|
|
29
72
|
|
|
30
|
-
###
|
|
73
|
+
### Alembic (Python)
|
|
74
|
+
|
|
75
|
+
```yaml
|
|
76
|
+
migrate:
|
|
77
|
+
skill: "migrate@1"
|
|
78
|
+
envs:
|
|
79
|
+
dev:
|
|
80
|
+
command: { exec: "alembic", args: ["upgrade", "head"] }
|
|
81
|
+
env_file: ".env.dev"
|
|
82
|
+
prod:
|
|
83
|
+
command: { exec: "alembic", args: ["-x", "env=prod", "upgrade", "head"] }
|
|
84
|
+
```
|
|
31
85
|
|
|
32
|
-
|
|
86
|
+
### Django
|
|
33
87
|
|
|
34
|
-
|
|
88
|
+
```yaml
|
|
89
|
+
migrate:
|
|
90
|
+
skill: "migrate@1"
|
|
91
|
+
envs:
|
|
92
|
+
dev:
|
|
93
|
+
command: { exec: "python", args: ["manage.py", "migrate"] }
|
|
94
|
+
env_file: ".env.dev"
|
|
95
|
+
```
|
|
35
96
|
|
|
36
|
-
|
|
37
|
-
|
|
97
|
+
### golang-migrate
|
|
98
|
+
|
|
99
|
+
```yaml
|
|
100
|
+
migrate:
|
|
101
|
+
skill: "migrate@1"
|
|
102
|
+
envs:
|
|
103
|
+
dev:
|
|
104
|
+
command: { exec: "migrate", args: ["-database", "$DATABASE_URL", "-path", "migrations", "up"] }
|
|
105
|
+
env_file: ".env.dev"
|
|
38
106
|
```
|
|
39
107
|
|
|
40
|
-
###
|
|
108
|
+
### Prisma
|
|
41
109
|
|
|
42
|
-
|
|
110
|
+
```yaml
|
|
111
|
+
migrate:
|
|
112
|
+
skill: "migrate@1"
|
|
113
|
+
envs:
|
|
114
|
+
dev:
|
|
115
|
+
command: { exec: "prisma", args: ["migrate", "dev"] }
|
|
116
|
+
prod:
|
|
117
|
+
command: { exec: "prisma", args: ["migrate", "deploy"] }
|
|
118
|
+
```
|
|
43
119
|
|
|
44
|
-
###
|
|
120
|
+
### Drizzle
|
|
45
121
|
|
|
46
|
-
```
|
|
47
|
-
|
|
122
|
+
```yaml
|
|
123
|
+
migrate:
|
|
124
|
+
skill: "migrate@1"
|
|
125
|
+
envs:
|
|
126
|
+
dev:
|
|
127
|
+
command: { exec: "drizzle-kit", args: ["migrate"] }
|
|
128
|
+
env_file: ".env.dev"
|
|
48
129
|
```
|
|
49
130
|
|
|
50
|
-
###
|
|
131
|
+
### dbmate
|
|
51
132
|
|
|
52
|
-
|
|
133
|
+
```yaml
|
|
134
|
+
migrate:
|
|
135
|
+
skill: "migrate@1"
|
|
136
|
+
envs:
|
|
137
|
+
dev:
|
|
138
|
+
command: { exec: "dbmate", args: ["up"] }
|
|
139
|
+
env_file: ".env.dev"
|
|
140
|
+
```
|
|
53
141
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
142
|
+
### Flyway
|
|
143
|
+
|
|
144
|
+
```yaml
|
|
145
|
+
migrate:
|
|
146
|
+
skill: "migrate@1"
|
|
147
|
+
envs:
|
|
148
|
+
dev:
|
|
149
|
+
command: { exec: "flyway", args: ["migrate"] }
|
|
57
150
|
```
|
|
58
151
|
|
|
59
|
-
|
|
152
|
+
### Supabase CLI
|
|
153
|
+
|
|
154
|
+
```yaml
|
|
155
|
+
migrate:
|
|
156
|
+
skill: "migrate@1"
|
|
157
|
+
envs:
|
|
158
|
+
dev:
|
|
159
|
+
command: { exec: "supabase", args: ["migration", "up"] }
|
|
160
|
+
```
|
|
60
161
|
|
|
61
|
-
|
|
62
|
-
|------|---------|
|
|
63
|
-
| `--env dev\|qa\|prod` | Target environment |
|
|
64
|
-
| `--dry-run` | Validate only, don't execute |
|
|
65
|
-
| `--force` | Allow destructive operations (DROP, TRUNCATE) |
|
|
66
|
-
| `--confirm-prod` | Required for prod execution |
|
|
67
|
-
| `--promote qa\|prod` | Run missing migrations from source env |
|
|
162
|
+
### Custom script
|
|
68
163
|
|
|
69
|
-
|
|
164
|
+
Anything goes — the dispatcher just runs `exec` with `args`:
|
|
70
165
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
166
|
+
```yaml
|
|
167
|
+
migrate:
|
|
168
|
+
skill: "migrate@1"
|
|
169
|
+
envs:
|
|
170
|
+
dev:
|
|
171
|
+
command: { exec: "./scripts/db/migrate.sh", args: ["--env", "dev"] }
|
|
172
|
+
env_file: ".env.dev"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## When to use `migrate-supabase` instead
|
|
176
|
+
|
|
177
|
+
Use `migrate.supabase@1` if your repo has the canonical Delegance/Supabase layout:
|
|
178
|
+
- `data/deltas/<timestamp>_<name>.sql` files as the source of truth
|
|
179
|
+
- `.claude/supabase-envs.json` with per-env `dbUrl`
|
|
180
|
+
- Auto-regeneration of `types/supabase.ts` after each apply
|
|
181
|
+
- Built-in promotion chain (dev → qa → prod with checksum verification)
|
|
182
|
+
|
|
183
|
+
Otherwise, use `migrate@1` with the appropriate command above.
|
|
184
|
+
|
|
185
|
+
## Policy enforcement
|
|
186
|
+
|
|
187
|
+
Every run goes through `policy-enforcer.ts` before the command executes. The default policy:
|
|
188
|
+
|
|
189
|
+
| Setting | Default | Effect |
|
|
190
|
+
|---------|---------|--------|
|
|
191
|
+
| `allow_prod_in_ci` | `false` | Fail if `--env prod` runs in CI without explicit override |
|
|
192
|
+
| `require_clean_git` | `true` | Fail if working tree has uncommitted changes |
|
|
193
|
+
| `require_manual_approval` | `true` | Fail prod runs without `--yes` flag |
|
|
194
|
+
| `require_dry_run_first` | `false` | Force a dry-run before apply (opt-in) |
|
|
195
|
+
|
|
196
|
+
Override per-environment if your workflow needs it. Tighter is better — these defaults catch real foot-guns.
|
|
197
|
+
|
|
198
|
+
## Result artifact
|
|
199
|
+
|
|
200
|
+
When invoked under the autopilot pipeline (`AUTOPILOT_ENVELOPE` set), the skill writes:
|
|
201
|
+
|
|
202
|
+
```json
|
|
203
|
+
{
|
|
204
|
+
"contractVersion": "1.0",
|
|
205
|
+
"skillId": "migrate@1",
|
|
206
|
+
"invocationId": "<uuid>",
|
|
207
|
+
"nonce": "<from envelope>",
|
|
208
|
+
"status": "applied" | "skipped" | "validation-failed" | "needs-human" | "error",
|
|
209
|
+
"reasonCode": "<short string>",
|
|
210
|
+
"appliedMigrations": [],
|
|
211
|
+
"destructiveDetected": false,
|
|
212
|
+
"sideEffectsPerformed": ["no-side-effects"],
|
|
213
|
+
"nextActions": []
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
The generic skill cannot enumerate `appliedMigrations` (that's tool-specific) — it leaves the array empty and reports `status: "applied"` if the command exited 0. Tool-specific result enrichment is the job of skills like `migrate-supabase` that understand the migration ledger format.
|
|
218
|
+
|
|
219
|
+
## Auditing
|
|
220
|
+
|
|
221
|
+
Every dispatch — success, failure, dry-run — writes one entry to `.autopilot/audit.log` (chained via `seq` + `prev_hash`). Inspect with:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
claude-autopilot migrate doctor --audit-tail 10
|
|
225
|
+
```
|
|
79
226
|
|
|
80
|
-
##
|
|
227
|
+
## Stack.md schema
|
|
81
228
|
|
|
82
|
-
|
|
83
|
-
- `postgres` npm package installed
|
|
229
|
+
See `presets/schemas/migrate.schema.json` for the full JSON schema. Validation happens automatically on every dispatch — invalid `.autopilot/stack.md` fails closed before any command runs.
|