@delegance/claude-autopilot 5.2.2 → 6.2.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.
Files changed (130) hide show
  1. package/CHANGELOG.md +1027 -1
  2. package/README.md +104 -17
  3. package/dist/src/adapters/council/claude.js +2 -1
  4. package/dist/src/adapters/council/openai.js +14 -7
  5. package/dist/src/adapters/deploy/_http.d.ts +43 -0
  6. package/dist/src/adapters/deploy/_http.js +99 -0
  7. package/dist/src/adapters/deploy/fly.d.ts +206 -0
  8. package/dist/src/adapters/deploy/fly.js +696 -0
  9. package/dist/src/adapters/deploy/generic.d.ts +39 -0
  10. package/dist/src/adapters/deploy/generic.js +98 -0
  11. package/dist/src/adapters/deploy/index.d.ts +15 -0
  12. package/dist/src/adapters/deploy/index.js +78 -0
  13. package/dist/src/adapters/deploy/render.d.ts +181 -0
  14. package/dist/src/adapters/deploy/render.js +550 -0
  15. package/dist/src/adapters/deploy/types.d.ts +221 -0
  16. package/dist/src/adapters/deploy/types.js +15 -0
  17. package/dist/src/adapters/deploy/vercel.d.ts +143 -0
  18. package/dist/src/adapters/deploy/vercel.js +426 -0
  19. package/dist/src/adapters/pricing.d.ts +36 -0
  20. package/dist/src/adapters/pricing.js +40 -0
  21. package/dist/src/adapters/review-engine/claude.js +2 -1
  22. package/dist/src/adapters/review-engine/codex.js +12 -8
  23. package/dist/src/adapters/review-engine/gemini.js +2 -1
  24. package/dist/src/adapters/review-engine/openai-compatible.js +2 -1
  25. package/dist/src/adapters/sdk-loader.d.ts +15 -0
  26. package/dist/src/adapters/sdk-loader.js +77 -0
  27. package/dist/src/cli/autopilot.d.ts +71 -0
  28. package/dist/src/cli/autopilot.js +735 -0
  29. package/dist/src/cli/brainstorm.d.ts +23 -0
  30. package/dist/src/cli/brainstorm.js +131 -0
  31. package/dist/src/cli/costs.d.ts +15 -1
  32. package/dist/src/cli/costs.js +99 -10
  33. package/dist/src/cli/deploy.d.ts +71 -0
  34. package/dist/src/cli/deploy.js +539 -0
  35. package/dist/src/cli/fix.d.ts +18 -0
  36. package/dist/src/cli/fix.js +105 -11
  37. package/dist/src/cli/help-text.d.ts +52 -0
  38. package/dist/src/cli/help-text.js +400 -0
  39. package/dist/src/cli/implement.d.ts +91 -0
  40. package/dist/src/cli/implement.js +196 -0
  41. package/dist/src/cli/index.js +784 -222
  42. package/dist/src/cli/json-envelope.d.ts +187 -0
  43. package/dist/src/cli/json-envelope.js +270 -0
  44. package/dist/src/cli/json-mode.d.ts +33 -0
  45. package/dist/src/cli/json-mode.js +201 -0
  46. package/dist/src/cli/migrate.d.ts +111 -0
  47. package/dist/src/cli/migrate.js +305 -0
  48. package/dist/src/cli/plan.d.ts +81 -0
  49. package/dist/src/cli/plan.js +149 -0
  50. package/dist/src/cli/pr.d.ts +106 -0
  51. package/dist/src/cli/pr.js +191 -19
  52. package/dist/src/cli/preflight.js +102 -1
  53. package/dist/src/cli/review.d.ts +27 -0
  54. package/dist/src/cli/review.js +126 -0
  55. package/dist/src/cli/runs-watch-renderer.d.ts +45 -0
  56. package/dist/src/cli/runs-watch-renderer.js +275 -0
  57. package/dist/src/cli/runs-watch.d.ts +41 -0
  58. package/dist/src/cli/runs-watch.js +395 -0
  59. package/dist/src/cli/runs.d.ts +122 -0
  60. package/dist/src/cli/runs.js +902 -0
  61. package/dist/src/cli/scan.d.ts +93 -0
  62. package/dist/src/cli/scan.js +166 -40
  63. package/dist/src/cli/spec.d.ts +66 -0
  64. package/dist/src/cli/spec.js +132 -0
  65. package/dist/src/cli/validate.d.ts +29 -0
  66. package/dist/src/cli/validate.js +131 -0
  67. package/dist/src/core/config/schema.d.ts +43 -0
  68. package/dist/src/core/config/schema.js +25 -0
  69. package/dist/src/core/config/types.d.ts +17 -0
  70. package/dist/src/core/council/runner.d.ts +10 -1
  71. package/dist/src/core/council/runner.js +25 -3
  72. package/dist/src/core/council/types.d.ts +7 -0
  73. package/dist/src/core/errors.d.ts +1 -1
  74. package/dist/src/core/errors.js +12 -0
  75. package/dist/src/core/logging/redaction.d.ts +13 -0
  76. package/dist/src/core/logging/redaction.js +20 -0
  77. package/dist/src/core/migrate/detector-rules.js +6 -0
  78. package/dist/src/core/migrate/schema-validator.js +22 -1
  79. package/dist/src/core/phases/static-rules.d.ts +5 -1
  80. package/dist/src/core/phases/static-rules.js +2 -5
  81. package/dist/src/core/run-state/budget.d.ts +88 -0
  82. package/dist/src/core/run-state/budget.js +141 -0
  83. package/dist/src/core/run-state/cli-internal.d.ts +21 -0
  84. package/dist/src/core/run-state/cli-internal.js +174 -0
  85. package/dist/src/core/run-state/events.d.ts +59 -0
  86. package/dist/src/core/run-state/events.js +504 -0
  87. package/dist/src/core/run-state/lock.d.ts +61 -0
  88. package/dist/src/core/run-state/lock.js +206 -0
  89. package/dist/src/core/run-state/phase-context.d.ts +60 -0
  90. package/dist/src/core/run-state/phase-context.js +108 -0
  91. package/dist/src/core/run-state/phase-registry.d.ts +137 -0
  92. package/dist/src/core/run-state/phase-registry.js +162 -0
  93. package/dist/src/core/run-state/phase-runner.d.ts +80 -0
  94. package/dist/src/core/run-state/phase-runner.js +447 -0
  95. package/dist/src/core/run-state/provider-readback.d.ts +130 -0
  96. package/dist/src/core/run-state/provider-readback.js +426 -0
  97. package/dist/src/core/run-state/replay-decision.d.ts +69 -0
  98. package/dist/src/core/run-state/replay-decision.js +144 -0
  99. package/dist/src/core/run-state/resolve-engine.d.ts +100 -0
  100. package/dist/src/core/run-state/resolve-engine.js +190 -0
  101. package/dist/src/core/run-state/resume-preflight.d.ts +66 -0
  102. package/dist/src/core/run-state/resume-preflight.js +116 -0
  103. package/dist/src/core/run-state/run-phase-with-lifecycle.d.ts +73 -0
  104. package/dist/src/core/run-state/run-phase-with-lifecycle.js +186 -0
  105. package/dist/src/core/run-state/runs.d.ts +57 -0
  106. package/dist/src/core/run-state/runs.js +288 -0
  107. package/dist/src/core/run-state/snapshot.d.ts +14 -0
  108. package/dist/src/core/run-state/snapshot.js +114 -0
  109. package/dist/src/core/run-state/state.d.ts +40 -0
  110. package/dist/src/core/run-state/state.js +164 -0
  111. package/dist/src/core/run-state/types.d.ts +278 -0
  112. package/dist/src/core/run-state/types.js +13 -0
  113. package/dist/src/core/run-state/ulid.d.ts +11 -0
  114. package/dist/src/core/run-state/ulid.js +95 -0
  115. package/dist/src/core/schema-alignment/extractor/index.d.ts +1 -1
  116. package/dist/src/core/schema-alignment/extractor/index.js +2 -2
  117. package/dist/src/core/schema-alignment/extractor/prisma.d.ts +13 -1
  118. package/dist/src/core/schema-alignment/extractor/prisma.js +65 -10
  119. package/dist/src/core/schema-alignment/git-history.d.ts +19 -0
  120. package/dist/src/core/schema-alignment/git-history.js +53 -0
  121. package/dist/src/core/static-rules/rules/brand-tokens.js +2 -2
  122. package/dist/src/core/static-rules/rules/schema-alignment.js +14 -4
  123. package/package.json +9 -5
  124. package/scripts/autoregress.ts +3 -2
  125. package/skills/claude-autopilot.md +1 -1
  126. package/skills/make-interfaces-feel-better/SKILL.md +104 -0
  127. package/skills/migrate/SKILL.md +193 -47
  128. package/skills/simplify-ui/SKILL.md +103 -0
  129. package/skills/ui/SKILL.md +117 -0
  130. package/skills/ui-ux-pro-max/SKILL.md +90 -0
@@ -0,0 +1,91 @@
1
+ import type { GuardrailConfig } from '../core/config/types.ts';
2
+ import { type RunPhase } from '../core/run-state/phase-runner.ts';
3
+ export interface ImplementCommandOptions {
4
+ cwd?: string;
5
+ configPath?: string;
6
+ /**
7
+ * Optional context note injected into the implement log. The actual
8
+ * implementation work (reading the plan, dispatching subagents, writing
9
+ * code, running tests, committing, optionally pushing) is owned by the
10
+ * Claude Code `claude-autopilot` skill and its delegates
11
+ * (`subagent-driven-development`, `commit-push-pr`,
12
+ * `using-git-worktrees`); this CLI verb is the engine-wrap shell so v6
13
+ * pipeline runs can checkpoint an `implement` phase entry alongside
14
+ * `plan` / `migrate` / `validate` / `pr` / `review`.
15
+ */
16
+ context?: string;
17
+ /**
18
+ * Optional reference to the plan file the implement phase consumed
19
+ * (e.g. `docs/plans/2026-05-05-foo.md`). Echoed into the log stub so
20
+ * `runs show <id>` can surface it. The CLI verb does not read the plan
21
+ * — it just records the path for downstream introspection.
22
+ */
23
+ plan?: string;
24
+ /**
25
+ * Where to write the implement log file. Defaults to
26
+ * `.guardrail-cache/implement/<timestamp>-implement.md` so it lands inside
27
+ * the cache that's already gitignored. The path is recorded on
28
+ * ImplementOutput so the engine path can persist it as `result` for
29
+ * replay.
30
+ */
31
+ outputPath?: string;
32
+ /**
33
+ * v6.0.7 — engine knob inputs. Same shape and precedence as scan / costs /
34
+ * fix / plan / review / validate (CLI > env > config > built-in default
35
+ * off in v6.0.x).
36
+ */
37
+ cliEngine?: boolean;
38
+ envEngine?: string;
39
+ }
40
+ /**
41
+ * Phase input — captured as a struct so the engine path's phase body matches
42
+ * the engine-off path call signature.
43
+ *
44
+ * Exported so the v6.2.0 orchestrator's phase registry can carry the typed
45
+ * I/O shape on its `PhaseRegistration<ImplementInput, ImplementOutput>` slot.
46
+ */
47
+ export interface ImplementInput {
48
+ cwd: string;
49
+ context: string | null;
50
+ plan: string | null;
51
+ outputPath: string;
52
+ }
53
+ /**
54
+ * Phase output — JSON-serializable summary suitable for persistence as
55
+ * `result` on phases/implement.json. A future skip-already-applied (Phase 6)
56
+ * could restore this without re-invoking the implement loop by reading the
57
+ * persisted log path.
58
+ */
59
+ export interface ImplementOutput {
60
+ /** Absolute path to the written implement log file. */
61
+ implementLogPath: string;
62
+ /** Echoed for the render layer / future skip-already-applied. */
63
+ context: string | null;
64
+ /** Plan file path the implement phase was pointed at, if any. */
65
+ plan: string | null;
66
+ }
67
+ /** v6.2.0 — see scan.ts for the kind='early-exit' rationale. Implement has
68
+ * no early-exit branches today; the discriminant is included for shape
69
+ * parity with the other builders. */
70
+ export interface BuildImplementPhaseEarlyExit {
71
+ kind: 'early-exit';
72
+ exitCode: number;
73
+ }
74
+ export interface BuildImplementPhaseResult {
75
+ kind: 'phase';
76
+ phase: RunPhase<ImplementInput, ImplementOutput>;
77
+ input: ImplementInput;
78
+ config: GuardrailConfig;
79
+ renderResult: (output: ImplementOutput) => number;
80
+ }
81
+ /**
82
+ * v6.2.0 — extract the `RunPhase<ImplementInput, ImplementOutput>`
83
+ * construction out of `runImplement(options)` so the new top-level
84
+ * `autopilot` orchestrator can drive `runPhase` itself with a shared
85
+ * `phaseIdx` against the same run dir.
86
+ *
87
+ * Parity asserted by `tests/cli/implement-builder-parity.test.ts`.
88
+ */
89
+ export declare function buildImplementPhase(options: ImplementCommandOptions): Promise<BuildImplementPhaseResult | BuildImplementPhaseEarlyExit>;
90
+ export declare function runImplement(options?: ImplementCommandOptions): Promise<number>;
91
+ //# sourceMappingURL=implement.d.ts.map
@@ -0,0 +1,196 @@
1
+ // src/cli/implement.ts
2
+ //
3
+ // v6.0.7 — wrap the `implement` pipeline phase through `runPhaseWithLifecycle`.
4
+ //
5
+ // `implement` is the implementation phase of the autopilot pipeline (brainstorm
6
+ // → spec → plan → implement → migrate → validate → pr → review). The actual
7
+ // implementation work — reading the plan, dispatching subagents one per plan
8
+ // phase via the `subagent-driven-development` skill, writing code, running
9
+ // tests, committing, optionally pushing — lives in Claude Code skills, not in
10
+ // this CLI verb. The CLI verb that ships in this binary is an engine-wrap
11
+ // shell: it writes a checkpointable phase log stub so v6 pipeline runs can
12
+ // record an `implement` phase entry alongside the rest. Mirrors the
13
+ // validate / review / plan dispatcher shape.
14
+ //
15
+ // Idempotency / side effects (deviation note vs. spec table):
16
+ //
17
+ // The v6 spec table at `docs/specs/v6-run-state-engine.md` (line 159) lists
18
+ // `implement` with `idempotent: partial, hasSideEffects: yes,
19
+ // externalRefs: git-remote-push`. That declaration assumes the verb itself
20
+ // writes commits and pushes them to a remote. The v6.0.7 wrap declares
21
+ // `idempotent: true, hasSideEffects: false` because the v6.0.7 CLI verb does
22
+ // **not** write code, run tests, commit, or push to a remote. All of that
23
+ // work lives in the Claude Code `claude-autopilot` skill (and its delegates:
24
+ // `subagent-driven-development`, `commit-push-pr`, `using-git-worktrees`).
25
+ // The CLI verb is the engine-wrap shell — its only side effect is writing
26
+ // the local `.guardrail-cache/implement/<ts>-implement.md` log stub, which
27
+ // the engine treats as overwrite-style (same precedent as
28
+ // `.guardrail-cache/validate/`, `.guardrail-cache/plans/`,
29
+ // `.guardrail-cache/reviews/`).
30
+ //
31
+ // If a future PR inlines the implement loop into the CLI verb (writes code,
32
+ // runs tests, commits, pushes), the declarations will flip to
33
+ // `idempotent: false, hasSideEffects: true` and the wrap will need to call
34
+ // `ctx.emitExternalRef({ kind: 'git-remote-push', id: '<commit-sha>',
35
+ // observedAt: ... })` after each successful push. The helper signature does
36
+ // not need to grow for that — `phase.run` already receives `ctx`, and the
37
+ // underlying `runPhase()` records externalRefs unchanged.
38
+ import * as path from 'node:path';
39
+ import * as fs from 'node:fs';
40
+ import { loadConfig } from "../core/config/loader.js";
41
+ import { runPhaseWithLifecycle } from "../core/run-state/run-phase-with-lifecycle.js";
42
+ const C = {
43
+ reset: '\x1b[0m', bold: '\x1b[1m', dim: '\x1b[2m',
44
+ green: '\x1b[32m', yellow: '\x1b[33m', cyan: '\x1b[36m', red: '\x1b[31m',
45
+ };
46
+ const fmt = (c, t) => `${C[c]}${t}${C.reset}`;
47
+ /**
48
+ * v6.2.0 — extract the `RunPhase<ImplementInput, ImplementOutput>`
49
+ * construction out of `runImplement(options)` so the new top-level
50
+ * `autopilot` orchestrator can drive `runPhase` itself with a shared
51
+ * `phaseIdx` against the same run dir.
52
+ *
53
+ * Parity asserted by `tests/cli/implement-builder-parity.test.ts`.
54
+ */
55
+ export async function buildImplementPhase(options) {
56
+ const cwd = options.cwd ?? process.cwd();
57
+ const configPath = options.configPath ?? path.join(cwd, 'guardrail.config.yaml');
58
+ let config = { configVersion: 1 };
59
+ if (fs.existsSync(configPath)) {
60
+ const loaded = await loadConfig(configPath);
61
+ if (loaded)
62
+ config = loaded;
63
+ }
64
+ // INTENTIONAL DEVIATION FROM THE SPEC TABLE (documented at top of file):
65
+ // the v6 spec (`docs/specs/v6-run-state-engine.md`, line 159) lists
66
+ // `implement` with `idempotent: partial, hasSideEffects: yes,
67
+ // externalRefs: git-remote-push`. The v6.0.7 wrap declares
68
+ // `idempotent: true, hasSideEffects: false` because the v6.0.7 CLI verb
69
+ // is an engine-wrap shell — the actual code-writing / commit / push loop
70
+ // lives in the Claude Code `claude-autopilot` skill, not in this CLI verb.
71
+ // Local file write only — no git push, no PR creation, no provider-side
72
+ // mutation. If a future PR inlines the implement loop into the CLI verb,
73
+ // both declarations flip and a `ctx.emitExternalRef({ kind:
74
+ // 'git-remote-push', id: '<commit-sha>' })` call lands after each push.
75
+ const context = options.context ?? null;
76
+ const plan = options.plan ?? null;
77
+ const outputPath = options.outputPath
78
+ ? path.resolve(cwd, options.outputPath)
79
+ : path.join(cwd, '.guardrail-cache', 'implement', `${new Date().toISOString().replace(/[:.]/g, '-')}-implement.md`);
80
+ const implementInput = { cwd, context, plan, outputPath };
81
+ // The wrapped phase body — writes an implement log stub to disk. The
82
+ // actual implement loop (read plan → dispatch subagents → write code →
83
+ // run tests → commit → optional push) is produced by the Claude Code
84
+ // `claude-autopilot` skill and its delegates. Engine-off callers invoke
85
+ // this directly via `executeImplementPhase()`; engine-on callers route
86
+ // through `runPhase()`.
87
+ const phase = {
88
+ name: 'implement',
89
+ // Re-running the implement verb against the same context + plan writes
90
+ // the same log file. Engine treats local file writes as overwrite-style
91
+ // — same precedent as scan's findings-cache and validate's validate-log.
92
+ // Once the implement loop inlines into the CLI verb, this flips to
93
+ // `false` per the spec table and the wrap will rely on the
94
+ // `git-remote-push` externalRef readback for resume safety.
95
+ idempotent: true,
96
+ // Local file write only in v6.0.7 — no PR comment posting, no git push,
97
+ // no provider-side mutation. See the long deviation note above where
98
+ // `context`/`plan`/`outputPath` are computed for the externalRefs
99
+ // rationale.
100
+ hasSideEffects: false,
101
+ run: async (input) => executeImplementPhase(input),
102
+ };
103
+ return {
104
+ kind: 'phase',
105
+ phase,
106
+ input: implementInput,
107
+ config,
108
+ renderResult: (output) => renderImplementOutput(output, implementInput),
109
+ };
110
+ }
111
+ export async function runImplement(options = {}) {
112
+ const built = await buildImplementPhase(options);
113
+ if (built.kind === 'early-exit')
114
+ return built.exitCode;
115
+ const { phase, input, config, renderResult } = built;
116
+ // v6.0.6+ — lifecycle wiring lives in `runPhaseWithLifecycle`. The helper
117
+ // owns the engine-on/engine-off branch and the failure banner; the caller
118
+ // just supplies the phase, the input, and the engine-off escape hatch.
119
+ let output;
120
+ try {
121
+ const result = await runPhaseWithLifecycle({
122
+ cwd: input.cwd,
123
+ phase,
124
+ input,
125
+ config,
126
+ cliEngine: options.cliEngine,
127
+ envEngine: options.envEngine,
128
+ runEngineOff: () => executeImplementPhase(input),
129
+ });
130
+ output = result.output;
131
+ }
132
+ catch {
133
+ // Helper already printed the failure banner + emitted run.complete
134
+ // failed + refreshed state.json + released the lock. Surface the
135
+ // legacy non-zero exit so existing CI / scripts are unaffected.
136
+ return 1;
137
+ }
138
+ return renderResult(output);
139
+ }
140
+ // ---------------------------------------------------------------------------
141
+ // Phase body — write an implement log stub. Pure: no console output, no exit
142
+ // codes. Returns a JSON-serializable ImplementOutput so the engine can persist
143
+ // it as `result` on the phase snapshot. The actual implement loop is produced
144
+ // by the Claude Code `claude-autopilot` skill; this CLI verb's job is to
145
+ // provide a checkpointable phase shell.
146
+ // ---------------------------------------------------------------------------
147
+ async function executeImplementPhase(input) {
148
+ const { context, plan, outputPath } = input;
149
+ fs.mkdirSync(path.dirname(outputPath), { recursive: true });
150
+ const lines = [
151
+ '# Implement',
152
+ '',
153
+ `Generated: ${new Date().toISOString()}`,
154
+ '',
155
+ context ? `Context: ${context}` : 'Context: (none provided)',
156
+ plan ? `Plan: ${plan}` : 'Plan: (none provided)',
157
+ '',
158
+ '<!--',
159
+ 'This is the v6 engine-wrap stub for the `implement` phase. The actual',
160
+ 'implement loop (read plan → dispatch subagents one per plan phase via',
161
+ 'the `subagent-driven-development` skill → write code → run tests →',
162
+ 'commit on the branch → optionally push via `commit-push-pr`) is',
163
+ 'produced by the Claude Code `claude-autopilot` skill. The CLI verb',
164
+ 'exists to provide a checkpointable phase shell so',
165
+ '`claude-autopilot runs show <id>` reflects an `implement` phase entry',
166
+ 'when the pipeline includes one.',
167
+ '-->',
168
+ '',
169
+ ];
170
+ fs.writeFileSync(outputPath, lines.join('\n'), 'utf8');
171
+ return {
172
+ implementLogPath: outputPath,
173
+ context,
174
+ plan,
175
+ };
176
+ }
177
+ // ---------------------------------------------------------------------------
178
+ // Render — translate ImplementOutput back to a stdout summary + exit code.
179
+ // Lives outside the wrapped phase because it's pure presentation.
180
+ // ---------------------------------------------------------------------------
181
+ function renderImplementOutput(output, input) {
182
+ const { implementLogPath, context, plan } = output;
183
+ const { cwd } = input;
184
+ console.log('');
185
+ console.log(fmt('bold', '[implement]') + ' ' + fmt('dim', context ? `context: ${context}` : 'no context provided'));
186
+ if (plan)
187
+ console.log(fmt('dim', ` plan: ${plan}`));
188
+ console.log(fmt('dim', ` → ${path.relative(cwd, implementLogPath)}`));
189
+ console.log('');
190
+ console.log(fmt('cyan', 'Note:') + fmt('dim', ' the implement loop lives in Claude Code (`claude-autopilot` skill —'));
191
+ console.log(fmt('dim', ' reads plan, dispatches subagents per plan phase, writes code, runs'));
192
+ console.log(fmt('dim', ' tests, commits, optionally pushes via `commit-push-pr`).'));
193
+ console.log('');
194
+ return 0;
195
+ }
196
+ //# sourceMappingURL=implement.js.map