@delegance/claude-autopilot 5.5.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 (119) hide show
  1. package/CHANGELOG.md +935 -6
  2. package/README.md +55 -0
  3. package/dist/src/adapters/council/openai.js +12 -6
  4. package/dist/src/adapters/deploy/_http.d.ts +43 -0
  5. package/dist/src/adapters/deploy/_http.js +99 -0
  6. package/dist/src/adapters/deploy/fly.d.ts +206 -0
  7. package/dist/src/adapters/deploy/fly.js +696 -0
  8. package/dist/src/adapters/deploy/index.d.ts +2 -0
  9. package/dist/src/adapters/deploy/index.js +33 -0
  10. package/dist/src/adapters/deploy/render.d.ts +181 -0
  11. package/dist/src/adapters/deploy/render.js +550 -0
  12. package/dist/src/adapters/deploy/types.d.ts +67 -3
  13. package/dist/src/adapters/deploy/vercel.d.ts +17 -1
  14. package/dist/src/adapters/deploy/vercel.js +29 -49
  15. package/dist/src/adapters/pricing.d.ts +36 -0
  16. package/dist/src/adapters/pricing.js +40 -0
  17. package/dist/src/adapters/review-engine/codex.js +10 -7
  18. package/dist/src/cli/autopilot.d.ts +71 -0
  19. package/dist/src/cli/autopilot.js +735 -0
  20. package/dist/src/cli/brainstorm.d.ts +23 -0
  21. package/dist/src/cli/brainstorm.js +131 -0
  22. package/dist/src/cli/costs.d.ts +15 -1
  23. package/dist/src/cli/costs.js +99 -10
  24. package/dist/src/cli/deploy.d.ts +3 -3
  25. package/dist/src/cli/deploy.js +34 -9
  26. package/dist/src/cli/fix.d.ts +18 -0
  27. package/dist/src/cli/fix.js +105 -11
  28. package/dist/src/cli/help-text.d.ts +52 -0
  29. package/dist/src/cli/help-text.js +400 -0
  30. package/dist/src/cli/implement.d.ts +91 -0
  31. package/dist/src/cli/implement.js +196 -0
  32. package/dist/src/cli/index.js +719 -245
  33. package/dist/src/cli/json-envelope.d.ts +187 -0
  34. package/dist/src/cli/json-envelope.js +270 -0
  35. package/dist/src/cli/json-mode.d.ts +33 -0
  36. package/dist/src/cli/json-mode.js +201 -0
  37. package/dist/src/cli/migrate.d.ts +111 -0
  38. package/dist/src/cli/migrate.js +305 -0
  39. package/dist/src/cli/plan.d.ts +81 -0
  40. package/dist/src/cli/plan.js +149 -0
  41. package/dist/src/cli/pr.d.ts +106 -0
  42. package/dist/src/cli/pr.js +191 -19
  43. package/dist/src/cli/preflight.js +26 -0
  44. package/dist/src/cli/review.d.ts +27 -0
  45. package/dist/src/cli/review.js +126 -0
  46. package/dist/src/cli/runs-watch-renderer.d.ts +45 -0
  47. package/dist/src/cli/runs-watch-renderer.js +275 -0
  48. package/dist/src/cli/runs-watch.d.ts +41 -0
  49. package/dist/src/cli/runs-watch.js +395 -0
  50. package/dist/src/cli/runs.d.ts +122 -0
  51. package/dist/src/cli/runs.js +902 -0
  52. package/dist/src/cli/scan.d.ts +93 -0
  53. package/dist/src/cli/scan.js +166 -40
  54. package/dist/src/cli/spec.d.ts +66 -0
  55. package/dist/src/cli/spec.js +132 -0
  56. package/dist/src/cli/validate.d.ts +29 -0
  57. package/dist/src/cli/validate.js +131 -0
  58. package/dist/src/core/config/schema.d.ts +9 -0
  59. package/dist/src/core/config/schema.js +7 -0
  60. package/dist/src/core/config/types.d.ts +11 -0
  61. package/dist/src/core/council/runner.d.ts +10 -1
  62. package/dist/src/core/council/runner.js +25 -3
  63. package/dist/src/core/council/types.d.ts +7 -0
  64. package/dist/src/core/errors.d.ts +1 -1
  65. package/dist/src/core/errors.js +11 -0
  66. package/dist/src/core/logging/redaction.d.ts +13 -0
  67. package/dist/src/core/logging/redaction.js +20 -0
  68. package/dist/src/core/migrate/schema-validator.js +15 -1
  69. package/dist/src/core/phases/static-rules.d.ts +5 -1
  70. package/dist/src/core/phases/static-rules.js +2 -5
  71. package/dist/src/core/run-state/budget.d.ts +88 -0
  72. package/dist/src/core/run-state/budget.js +141 -0
  73. package/dist/src/core/run-state/cli-internal.d.ts +21 -0
  74. package/dist/src/core/run-state/cli-internal.js +174 -0
  75. package/dist/src/core/run-state/events.d.ts +59 -0
  76. package/dist/src/core/run-state/events.js +504 -0
  77. package/dist/src/core/run-state/lock.d.ts +61 -0
  78. package/dist/src/core/run-state/lock.js +206 -0
  79. package/dist/src/core/run-state/phase-context.d.ts +60 -0
  80. package/dist/src/core/run-state/phase-context.js +108 -0
  81. package/dist/src/core/run-state/phase-registry.d.ts +137 -0
  82. package/dist/src/core/run-state/phase-registry.js +162 -0
  83. package/dist/src/core/run-state/phase-runner.d.ts +80 -0
  84. package/dist/src/core/run-state/phase-runner.js +447 -0
  85. package/dist/src/core/run-state/provider-readback.d.ts +130 -0
  86. package/dist/src/core/run-state/provider-readback.js +426 -0
  87. package/dist/src/core/run-state/replay-decision.d.ts +69 -0
  88. package/dist/src/core/run-state/replay-decision.js +144 -0
  89. package/dist/src/core/run-state/resolve-engine.d.ts +100 -0
  90. package/dist/src/core/run-state/resolve-engine.js +190 -0
  91. package/dist/src/core/run-state/resume-preflight.d.ts +66 -0
  92. package/dist/src/core/run-state/resume-preflight.js +116 -0
  93. package/dist/src/core/run-state/run-phase-with-lifecycle.d.ts +73 -0
  94. package/dist/src/core/run-state/run-phase-with-lifecycle.js +186 -0
  95. package/dist/src/core/run-state/runs.d.ts +57 -0
  96. package/dist/src/core/run-state/runs.js +288 -0
  97. package/dist/src/core/run-state/snapshot.d.ts +14 -0
  98. package/dist/src/core/run-state/snapshot.js +114 -0
  99. package/dist/src/core/run-state/state.d.ts +40 -0
  100. package/dist/src/core/run-state/state.js +164 -0
  101. package/dist/src/core/run-state/types.d.ts +278 -0
  102. package/dist/src/core/run-state/types.js +13 -0
  103. package/dist/src/core/run-state/ulid.d.ts +11 -0
  104. package/dist/src/core/run-state/ulid.js +95 -0
  105. package/dist/src/core/schema-alignment/extractor/index.d.ts +1 -1
  106. package/dist/src/core/schema-alignment/extractor/index.js +2 -2
  107. package/dist/src/core/schema-alignment/extractor/prisma.d.ts +13 -1
  108. package/dist/src/core/schema-alignment/extractor/prisma.js +65 -10
  109. package/dist/src/core/schema-alignment/git-history.d.ts +19 -0
  110. package/dist/src/core/schema-alignment/git-history.js +53 -0
  111. package/dist/src/core/static-rules/rules/brand-tokens.js +2 -2
  112. package/dist/src/core/static-rules/rules/schema-alignment.js +14 -4
  113. package/package.json +2 -1
  114. package/scripts/autoregress.ts +1 -1
  115. package/skills/claude-autopilot.md +1 -1
  116. package/skills/make-interfaces-feel-better/SKILL.md +104 -0
  117. package/skills/simplify-ui/SKILL.md +103 -0
  118. package/skills/ui/SKILL.md +117 -0
  119. package/skills/ui-ux-pro-max/SKILL.md +90 -0
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Two-level help grouping for the claude-autopilot CLI.
3
+ *
4
+ * The CLI ships ~25 subcommands. A flat list crowds the welcome screen and
5
+ * makes it hard for new users to find the verb they need. This module owns
6
+ * the canonical grouping (Pipeline / Review / Deploy / Migrate / Diagnostics
7
+ * / Advanced), the per-verb summaries, and the per-verb Options blocks.
8
+ *
9
+ * The dispatcher in index.ts imports these helpers — keeping the data here
10
+ * means the help text can be rendered into a string for tests without firing
11
+ * the side-effecting top-level switch statement in index.ts.
12
+ *
13
+ * Group assignments are asserted by tests/cli/help-text.test.ts so newly
14
+ * added verbs are forced into the structure rather than silently dropped.
15
+ *
16
+ * Groups are ordered roughly by user journey:
17
+ * Pipeline — brainstorm → spec → plan → implement → PR
18
+ * Review — operates on findings / runs the LLM-backed code review
19
+ * Deploy — platform-specific deploy verbs
20
+ * Migrate — database migration dispatch
21
+ * Diagnostics — sanity checks, second-opinion, test scaffolding
22
+ * Advanced — long-running daemons / niche / experimental verbs
23
+ */
24
+ export type HelpVerb = {
25
+ verb: string;
26
+ summary: string;
27
+ };
28
+ export type HelpGroup = {
29
+ name: string;
30
+ tagline: string;
31
+ verbs: HelpVerb[];
32
+ };
33
+ export declare const HELP_GROUPS: HelpGroup[];
34
+ /**
35
+ * Per-verb Options blocks. Keyed by the verb that owns the block. Some verbs
36
+ * have no documented flags (e.g. `costs`, `lsp`, `report`) and are absent here;
37
+ * `claude-autopilot help <verb>` will show just the row in that case.
38
+ */
39
+ export declare const HELP_OPTIONS: Record<string, string>;
40
+ /**
41
+ * Global flags advertised in --help. These work across most verbs (per-verb
42
+ * support varies; v6.0.1 wires them into `scan` first, additional verbs land
43
+ * in subsequent v6.0.x point releases per docs/v6/wrapping-pipeline-phases.md).
44
+ */
45
+ export declare const GLOBAL_FLAGS_BLOCK = "Global flags:\n --json Emit a structured JSON envelope on stdout (most verbs)\n --engine Run under the v6 Run State Engine (writes .guardrail-cache/runs/<ulid>/)\n --no-engine Force the legacy stateless code path (overrides config / env)\n Precedence: CLI > env (CLAUDE_AUTOPILOT_ENGINE) > config (engine.enabled) > built-in default\n v6.0.1: wired for `scan`. v6.0.2: wired for `fix` and `costs`. v6.0.3: wired for `brainstorm` and `spec`. v6.0.4: wired for `plan` and `review`. v6.0.5: wired for `validate`. v6.0.7: wired for `implement`. v6.0.8: wired for `migrate`. v6.0.9: wired for `pr`. ALL 10 phases now wrapped \u2014 v6.0.x feature-complete.";
46
+ /** Build the full two-level help text. Returned as a string so tests can assert against it without spawning. */
47
+ export declare function buildHelpText(): string;
48
+ /** Build help text for a single verb. Returns null if the verb is unknown. */
49
+ export declare function buildCommandHelpText(verb: string): string | null;
50
+ /** Set of verbs that have a row in HELP_GROUPS — used by `help <verb>` lookup and by tests. */
51
+ export declare const HELP_VERBS: readonly string[];
52
+ //# sourceMappingURL=help-text.d.ts.map
@@ -0,0 +1,400 @@
1
+ /**
2
+ * Two-level help grouping for the claude-autopilot CLI.
3
+ *
4
+ * The CLI ships ~25 subcommands. A flat list crowds the welcome screen and
5
+ * makes it hard for new users to find the verb they need. This module owns
6
+ * the canonical grouping (Pipeline / Review / Deploy / Migrate / Diagnostics
7
+ * / Advanced), the per-verb summaries, and the per-verb Options blocks.
8
+ *
9
+ * The dispatcher in index.ts imports these helpers — keeping the data here
10
+ * means the help text can be rendered into a string for tests without firing
11
+ * the side-effecting top-level switch statement in index.ts.
12
+ *
13
+ * Group assignments are asserted by tests/cli/help-text.test.ts so newly
14
+ * added verbs are forced into the structure rather than silently dropped.
15
+ *
16
+ * Groups are ordered roughly by user journey:
17
+ * Pipeline — brainstorm → spec → plan → implement → PR
18
+ * Review — operates on findings / runs the LLM-backed code review
19
+ * Deploy — platform-specific deploy verbs
20
+ * Migrate — database migration dispatch
21
+ * Diagnostics — sanity checks, second-opinion, test scaffolding
22
+ * Advanced — long-running daemons / niche / experimental verbs
23
+ */
24
+ export const HELP_GROUPS = [
25
+ {
26
+ name: 'Pipeline',
27
+ tagline: 'spec → plan → implement → PR loop',
28
+ verbs: [
29
+ { verb: 'init', summary: 'Scaffold guardrail.config.yaml + auto-detect migrate stack (writes .autopilot/stack.md)' },
30
+ { verb: 'setup', summary: 'Auto-detect stack, write config, install pre-push hook' },
31
+ { verb: 'autopilot', summary: 'Multi-phase orchestrator — run scan → spec → plan → implement under one runId (v6.2.0)' },
32
+ { verb: 'brainstorm', summary: 'Pipeline entry point (Claude Code skill — see /brainstorm)' },
33
+ { verb: 'spec', summary: 'Spec-writing pointer (Claude Code skill — see /brainstorm)' },
34
+ { verb: 'plan', summary: 'Pipeline plan phase (engine-wrap shell — see superpowers:writing-plans skill)' },
35
+ { verb: 'implement', summary: 'Pipeline implement phase (engine-wrap shell — see claude-autopilot skill)' },
36
+ { verb: 'review', summary: 'Pipeline review phase (engine-wrap shell — see /review, /review-2pass)' },
37
+ { verb: 'validate', summary: 'Pipeline validate phase (engine-wrap shell — see /validate skill)' },
38
+ { verb: 'pr', summary: 'Review a specific PR by number (auto-detects if on PR branch)' },
39
+ { verb: 'pr-desc', summary: 'Generate a PR title / summary / test plan from the current diff' },
40
+ ],
41
+ },
42
+ {
43
+ name: 'Review',
44
+ tagline: 'findings + scan + autofix',
45
+ verbs: [
46
+ { verb: 'run', summary: 'Review git-changed files (default)' },
47
+ { verb: 'scan', summary: 'Review any path — no git required' },
48
+ { verb: 'ci', summary: 'Opinionated CI entrypoint (post comments + SARIF)' },
49
+ { verb: 'fix', summary: 'Auto-fix cached findings using the configured LLM' },
50
+ { verb: 'baseline', summary: 'Manage the committed findings baseline (create|update|show|delete)' },
51
+ { verb: 'triage', summary: 'Mark individual findings as accepted/dismissed' },
52
+ { verb: 'explain', summary: 'Deep-dive explanation + remediation for a specific finding' },
53
+ { verb: 'report', summary: 'Render cached findings as a markdown report' },
54
+ { verb: 'costs', summary: 'Show per-run cost summary' },
55
+ ],
56
+ },
57
+ {
58
+ name: 'Deploy',
59
+ tagline: 'platform-specific deploy',
60
+ verbs: [
61
+ { verb: 'deploy', summary: 'Deploy via configured adapter (vercel | fly | render | generic) — also: rollback, status' },
62
+ ],
63
+ },
64
+ {
65
+ name: 'Migrate',
66
+ tagline: 'database migration dispatch',
67
+ verbs: [
68
+ { verb: 'migrate', summary: 'Run database migrations via the stack-aware dispatcher' },
69
+ { verb: 'migrate-doctor', summary: 'Validate .autopilot/stack.md and skill manifests (alias: migrate doctor)' },
70
+ { verb: 'migrate-v4', summary: 'Codemod for v4 → v5 repo migration (not a pipeline phase)' },
71
+ ],
72
+ },
73
+ {
74
+ name: 'Diagnostics',
75
+ tagline: 'sanity checks + second-opinion + test scaffolding',
76
+ verbs: [
77
+ { verb: 'doctor', summary: 'Check prerequisites (alias: preflight)' },
78
+ { verb: 'preflight', summary: 'Check prerequisites (alias: doctor)' },
79
+ { verb: 'council', summary: 'Multi-model review — dispatch the diff to N models and synthesize consensus' },
80
+ { verb: 'test-gen', summary: 'Detect uncovered exports and generate test cases using the LLM' },
81
+ ],
82
+ },
83
+ {
84
+ name: 'Engine',
85
+ tagline: 'v6 run state engine — list, inspect, GC, resume',
86
+ verbs: [
87
+ { verb: 'runs', summary: 'Inspect run state: runs list | show <id> | watch <id> | resume <id> | gc | delete <id> | doctor' },
88
+ ],
89
+ },
90
+ {
91
+ name: 'Advanced',
92
+ tagline: 'server / experimental — hidden from welcome screen',
93
+ verbs: [
94
+ { verb: 'worker', summary: 'Persistent review daemon for multi-terminal parallel usage (start|stop|status)' },
95
+ { verb: 'mcp', summary: 'MCP server for Claude / ChatGPT integration' },
96
+ { verb: 'hook', summary: 'Install / remove the pre-push git hook' },
97
+ { verb: 'watch', summary: 'Watch for file changes and re-run on each save' },
98
+ { verb: 'autoregress', summary: 'Snapshot regression tests (run|diff|update|generate)' },
99
+ { verb: 'lsp', summary: 'Language server — publishes findings as LSP diagnostics (stdin/stdout)' },
100
+ { verb: 'ignore', summary: 'Interactively add findings to .guardrail-ignore' },
101
+ ],
102
+ },
103
+ ];
104
+ /**
105
+ * Per-verb Options blocks. Keyed by the verb that owns the block. Some verbs
106
+ * have no documented flags (e.g. `costs`, `lsp`, `report`) and are absent here;
107
+ * `claude-autopilot help <verb>` will show just the row in that case.
108
+ */
109
+ export const HELP_OPTIONS = {
110
+ run: `Options (run):
111
+ --base <ref> Git base ref for diff (default: HEAD~1)
112
+ --config <path> Path to config file (default: ./guardrail.config.yaml)
113
+ --files <a,b,c> Explicit comma-separated file list (skips git detection)
114
+ --dry-run Show what would run without executing
115
+ --diff Send git diff hunks instead of full files (~70% fewer tokens)
116
+ --delta Only report findings new since last run (suppress pre-existing)
117
+ --inline-comments Post per-line review comments on the PR diff
118
+ --post-comments Post/update a summary comment on the open PR
119
+ --format <text|sarif> Output format (default: text)
120
+ --output <path> Output file path (required with --format sarif)`,
121
+ scan: `Options (scan):
122
+ <path> [path...] Files or directories to scan (or --all for entire codebase)
123
+ --all Scan entire codebase
124
+ --ask <question> Targeted question to inject into the LLM review prompt
125
+ --focus <type> security | logic | performance (default: all)
126
+ --dry-run List files that would be scanned without running
127
+ --config <path> Path to config file
128
+ --engine Run under the v6 Run State Engine (writes .guardrail-cache/runs/<ulid>/)
129
+ --no-engine Force the legacy stateless code path (overrides config / env)`,
130
+ pr: `Options (pr):
131
+ <number> PR number to review (optional if on a PR branch)
132
+ --no-post-comments Skip posting/updating PR summary comment
133
+ --no-inline-comments Skip posting per-line inline annotations
134
+ --config <path> Path to config file
135
+ --engine Run under the v6 Run State Engine (writes .guardrail-cache/runs/<ulid>/)
136
+ --no-engine Force the legacy stateless code path (overrides config / env)
137
+
138
+ Note: pr is side-effecting — it posts/updates a PR comment and inline
139
+ review comments via the gh CLI. Engine-on records a github-pr
140
+ externalRef; future replays gate on the spec's "side-effect
141
+ readback" rule (--force-replay required if a prior phase.success
142
+ exists for the same run).`,
143
+ fix: `Options (fix):
144
+ --severity <critical|warning|all> Which findings to fix (default: critical)
145
+ --dry-run Preview fixes without writing files
146
+ --config <path> Path to config file
147
+ --engine Run under the v6 Run State Engine (writes .guardrail-cache/runs/<ulid>/)
148
+ --no-engine Force the legacy stateless code path (overrides config / env)`,
149
+ costs: `Options (costs):
150
+ --config <path> Path to config file
151
+ --engine Run under the v6 Run State Engine (writes .guardrail-cache/runs/<ulid>/)
152
+ --no-engine Force the legacy stateless code path (overrides config / env)`,
153
+ brainstorm: `Options (brainstorm):
154
+ --config <path> Path to config file
155
+ --engine Run under the v6 Run State Engine (writes .guardrail-cache/runs/<ulid>/)
156
+ --no-engine Force the legacy stateless code path (overrides config / env)
157
+ --json Emit a structured JSON envelope on stdout
158
+
159
+ Note: brainstorm is primarily a Claude Code skill (/brainstorm). The CLI
160
+ verb is an advisory pointer; engine-on still produces a run-state
161
+ snapshot (state.json + events.ndjson) for pipeline introspection.`,
162
+ spec: `Options (spec):
163
+ --config <path> Path to config file
164
+ --engine Run under the v6 Run State Engine (writes .guardrail-cache/runs/<ulid>/)
165
+ --no-engine Force the legacy stateless code path (overrides config / env)
166
+ --json Emit a structured JSON envelope on stdout
167
+
168
+ Note: spec is primarily a Claude Code skill (entered via /brainstorm). The
169
+ CLI verb is an advisory pointer; engine-on still produces a run-state
170
+ snapshot (state.json + events.ndjson) for pipeline introspection.`,
171
+ plan: `Options (plan):
172
+ --spec <path> Spec file the planner should read (optional)
173
+ --output <path> Where to write the plan markdown (default: .guardrail-cache/plans/<ts>-plan.md)
174
+ --config <path> Path to config file
175
+ --engine Run under the v6 Run State Engine (writes .guardrail-cache/runs/<ulid>/)
176
+ --no-engine Force the legacy stateless code path (overrides config / env)`,
177
+ review: `Options (review):
178
+ --context <text> Optional context note injected into the review log
179
+ --output <path> Where to write the review log (default: .guardrail-cache/reviews/<ts>-review.md)
180
+ --config <path> Path to config file
181
+ --engine Run under the v6 Run State Engine (writes .guardrail-cache/runs/<ulid>/)
182
+ --no-engine Force the legacy stateless code path (overrides config / env)`,
183
+ validate: `Options (validate):
184
+ --context <text> Optional context note injected into the validate log
185
+ --output <path> Where to write the validate log (default: .guardrail-cache/validate/<ts>-validate.md)
186
+ --config <path> Path to config file
187
+ --engine Run under the v6 Run State Engine (writes .guardrail-cache/runs/<ulid>/)
188
+ --no-engine Force the legacy stateless code path (overrides config / env)
189
+
190
+ Note: validate is primarily a Claude Code skill (/validate). The CLI verb
191
+ is an engine-wrap shell; engine-on still produces a run-state
192
+ snapshot (state.json + events.ndjson) for pipeline introspection.
193
+ SARIF emission lives in \`claude-autopilot run --format sarif\`.`,
194
+ autopilot: `Options (autopilot):
195
+ --mode <full> Pipeline mode (v6.2.0 ships 'full' only — scan → spec → plan → implement)
196
+ --phases <a,b,c> Explicit phase list (comma-separated; overrides --mode)
197
+ --budget <usd> Run-scope budget cap (USD). Cross-phase — actualSoFar accumulates across phases.
198
+ --engine Run under the v6 Run State Engine (REQUIRED — engine-off is rejected)
199
+ --no-engine REJECTED — orchestrator requires engine-on (rejected at pre-flight, exit 1)
200
+
201
+ Behavior: drives N pipeline phases under ONE runId so a \`runs watch <id>\`
202
+ window covers the whole pipeline. Sequential — no parallel
203
+ execution. Non-interactive — pause budget decisions hard-fail.
204
+ Exit codes: 0 success, 78 budget_exceeded, 2 engine error
205
+ (lock_held / corrupted_state / partial_write), 1 everything else.
206
+ Resume a failed pipeline via \`claude-autopilot run resume <id>\`.
207
+
208
+ v6.2.0 ships scan / spec / plan / implement only. \`migrate\` and \`pr\`
209
+ land in v6.2.1 once their per-phase idempotency contracts (preflight
210
+ readback + externalRef recorded BEFORE side-effect) are wired. The
211
+ --mode=fix and --mode=review modes land in v6.2.1+; --json envelope
212
+ lands in v6.2.2.
213
+
214
+ Examples:
215
+ claude-autopilot autopilot
216
+ claude-autopilot autopilot --budget 25
217
+ claude-autopilot autopilot --phases=scan,spec,plan`,
218
+ implement: `Options (implement):
219
+ --context <text> Optional context note injected into the implement log
220
+ --plan <path> Plan file the implement phase consumed (e.g. docs/plans/<slug>.md)
221
+ --output <path> Where to write the implement log (default: .guardrail-cache/implement/<ts>-implement.md)
222
+ --config <path> Path to config file
223
+ --engine Run under the v6 Run State Engine (writes .guardrail-cache/runs/<ulid>/)
224
+ --no-engine Force the legacy stateless code path (overrides config / env)
225
+
226
+ Note: implement is primarily a Claude Code skill (claude-autopilot — reads
227
+ plan, dispatches subagents per plan phase via subagent-driven-development,
228
+ writes code, runs tests, commits, optionally pushes via commit-push-pr).
229
+ The CLI verb is an engine-wrap shell; engine-on still produces a
230
+ run-state snapshot (state.json + events.ndjson) for pipeline
231
+ introspection. The v6.0.7 wrap declares idempotent: true,
232
+ hasSideEffects: false because the CLI verb writes a local log stub
233
+ only — no git push, no PR creation. If a future PR inlines the
234
+ implement loop into the CLI verb, the declarations flip to match
235
+ the spec table (idempotent: false, hasSideEffects: true,
236
+ externalRefs: git-remote-push). See src/cli/implement.ts deviation
237
+ note for the full rationale.`,
238
+ watch: `Options (watch):
239
+ --config <path> Path to config file (default: ./guardrail.config.yaml)
240
+ --debounce <ms> Debounce delay in ms (default: 300)`,
241
+ autoregress: `Options (autoregress):
242
+ --all Run/diff all snapshots
243
+ --since <ref> Git ref for changed-files detection
244
+ --snapshot <slug> Target a single snapshot
245
+ --files <a,b,c> Explicit file list for generate (skips git detection)`,
246
+ migrate: `Options (migrate):
247
+ --env <name> Target environment from .autopilot/stack.md (default: dev)
248
+ --dry-run Run skill in dry-run mode (no side effects)
249
+ --yes Required to apply prod migrations in CI
250
+ --config <path> Path to config file (default: ./guardrail.config.yaml)
251
+ --engine Run under the v6 Run State Engine (writes .guardrail-cache/runs/<ulid>/)
252
+ --no-engine Force the legacy stateless code path (overrides config / env)
253
+
254
+ Note: migrate is a side-effecting phase — re-running with --engine after a
255
+ prior phase.success requires --force-replay (Phase 6+) because the
256
+ engine cannot read back \`migration_state\` yet. Each applied
257
+ migration emits a \`migration-version\` externalRef under the run
258
+ for the resume gate.`,
259
+ 'migrate-doctor': `Options (migrate doctor / migrate-doctor):
260
+ --fix Apply auto-fixable mutations (legacy stack.md, skills/migrate/, schema_version)`,
261
+ runs: `Sub-verbs (runs):
262
+ runs list List runs newest-first
263
+ runs show <id> Show a run's state + last events
264
+ runs watch <id> Tail events.ndjson with a live cost meter
265
+ runs gc Delete completed runs older than N days
266
+ runs delete <id> Delete a single run (terminal-status only)
267
+ runs doctor Replay events vs. state.json; report drift
268
+ run resume <id> Lookup-only: identify the next phase + decision
269
+
270
+ Options (runs list):
271
+ --status <s> Filter: pending | running | paused | completed | failed | aborted
272
+ --json Emit a structured JSON envelope on stdout
273
+
274
+ Options (runs show):
275
+ <id> ULID of the run to inspect
276
+ --events Tail events.ndjson after the state summary
277
+ --events-tail <n> How many tail events to show (default 20)
278
+ --json Emit a structured JSON envelope on stdout
279
+
280
+ Options (runs watch):
281
+ <id> ULID of the run to watch
282
+ --since <seq> Replay forward from a specific event seq (resume after disconnect)
283
+ --no-follow Render the current state once and exit (snapshot mode)
284
+ --json Emit raw NDJSON to stdout (one event per line) — ANSI suppressed
285
+ --no-color Force ANSI off even on a TTY
286
+
287
+ Behavior: tails events.ndjson via fs.watchFile (1s poll) and pretty-renders
288
+ each new event with a running cost/budget meter. Exits when the
289
+ run terminates (run.complete / run.failed / run.aborted) or on
290
+ Ctrl-C. Exit codes: 0 success, 1 invalid input or stream error,
291
+ 2 not_found.
292
+
293
+ Options (runs gc):
294
+ --older-than-days <n> Cutoff in days (default 30)
295
+ --dry-run Preview deletions without touching disk
296
+ --yes Skip the confirmation prompt
297
+ --json Emit a structured JSON envelope on stdout
298
+
299
+ Options (runs delete):
300
+ <id> ULID of the run to delete
301
+ --force Override the terminal-status guard (dangerous)
302
+ --json Emit a structured JSON envelope on stdout
303
+
304
+ Options (runs doctor):
305
+ <id> Limit the check to a single run id (optional)
306
+ --fix Rewrite state.json from events.ndjson where drift is found
307
+ --json Emit a structured JSON envelope on stdout
308
+
309
+ Options (run resume):
310
+ <id> ULID of the run to look up
311
+ --from-phase <name> Resume target phase by name (must exist on the run)
312
+ --json Emit a structured JSON envelope on stdout
313
+
314
+ NOTE: \`run resume\` in v6 Phase 3 is LOOKUP-ONLY. It identifies which phase
315
+ would resume from and the decision rationale (retry, skip-idempotent,
316
+ needs-human, already-complete) without actually executing the phase.
317
+ Real execution wires in v6 Phase 6+.`,
318
+ deploy: `Options (deploy):
319
+ --adapter <vercel|fly|render|generic> Override deploy.adapter from config
320
+ --config <path> Path to config file
321
+ --ref <ref> Git ref (branch / tag) to deploy
322
+ --sha <commit> Specific commit SHA to deploy
323
+ --watch Stream build logs to stderr in real time (vercel: SSE; fly: WebSocket; render: REST polling)
324
+ --to <deploy-id> Target deploy ID for 'deploy rollback'
325
+ --pr <n> Post upserting deploy summary comment on the PR
326
+
327
+ Subcommands (deploy):
328
+ deploy Deploy via configured adapter
329
+ deploy rollback Roll back to previous prod deploy
330
+ deploy rollback --to <id> Roll back to a specific deploy
331
+ deploy status Show current prod + last 5 builds`,
332
+ };
333
+ /** Pad the verb column so summaries align across groups. */
334
+ function padVerb(verb) {
335
+ const WIDTH = 16;
336
+ return verb.length >= WIDTH ? verb + ' ' : verb + ' '.repeat(WIDTH - verb.length);
337
+ }
338
+ /**
339
+ * Global flags advertised in --help. These work across most verbs (per-verb
340
+ * support varies; v6.0.1 wires them into `scan` first, additional verbs land
341
+ * in subsequent v6.0.x point releases per docs/v6/wrapping-pipeline-phases.md).
342
+ */
343
+ export const GLOBAL_FLAGS_BLOCK = `Global flags:
344
+ --json Emit a structured JSON envelope on stdout (most verbs)
345
+ --engine Run under the v6 Run State Engine (writes .guardrail-cache/runs/<ulid>/)
346
+ --no-engine Force the legacy stateless code path (overrides config / env)
347
+ Precedence: CLI > env (CLAUDE_AUTOPILOT_ENGINE) > config (engine.enabled) > built-in default
348
+ v6.0.1: wired for \`scan\`. v6.0.2: wired for \`fix\` and \`costs\`. v6.0.3: wired for \`brainstorm\` and \`spec\`. v6.0.4: wired for \`plan\` and \`review\`. v6.0.5: wired for \`validate\`. v6.0.7: wired for \`implement\`. v6.0.8: wired for \`migrate\`. v6.0.9: wired for \`pr\`. ALL 10 phases now wrapped — v6.0.x feature-complete.`;
349
+ /** Build the full two-level help text. Returned as a string so tests can assert against it without spawning. */
350
+ export function buildHelpText() {
351
+ const lines = [];
352
+ lines.push('');
353
+ lines.push('Usage: claude-autopilot <command> [options] (legacy alias: guardrail)');
354
+ lines.push('');
355
+ for (const group of HELP_GROUPS) {
356
+ lines.push(`\x1b[1m${group.name}:\x1b[0m \x1b[2m# ${group.tagline}\x1b[0m`);
357
+ for (const v of group.verbs) {
358
+ lines.push(` ${padVerb(v.verb)}${v.summary}`);
359
+ }
360
+ lines.push('');
361
+ }
362
+ lines.push(GLOBAL_FLAGS_BLOCK);
363
+ lines.push('');
364
+ for (const group of HELP_GROUPS) {
365
+ for (const v of group.verbs) {
366
+ const block = HELP_OPTIONS[v.verb];
367
+ if (block) {
368
+ lines.push(block);
369
+ lines.push('');
370
+ }
371
+ }
372
+ }
373
+ lines.push('Run \x1b[36mclaude-autopilot help <command>\x1b[0m for command-specific options.');
374
+ return lines.join('\n') + '\n';
375
+ }
376
+ /** Build help text for a single verb. Returns null if the verb is unknown. */
377
+ export function buildCommandHelpText(verb) {
378
+ for (const group of HELP_GROUPS) {
379
+ const match = group.verbs.find(v => v.verb === verb);
380
+ if (match) {
381
+ const lines = [];
382
+ lines.push('');
383
+ lines.push(`Usage: claude-autopilot ${verb} [options]`);
384
+ lines.push('');
385
+ lines.push(` ${padVerb(match.verb)}${match.summary}`);
386
+ lines.push(` \x1b[2m(group: ${group.name} — ${group.tagline})\x1b[0m`);
387
+ lines.push('');
388
+ const block = HELP_OPTIONS[verb];
389
+ if (block) {
390
+ lines.push(block);
391
+ lines.push('');
392
+ }
393
+ return lines.join('\n');
394
+ }
395
+ }
396
+ return null;
397
+ }
398
+ /** Set of verbs that have a row in HELP_GROUPS — used by `help <verb>` lookup and by tests. */
399
+ export const HELP_VERBS = HELP_GROUPS.flatMap(g => g.verbs.map(v => v.verb));
400
+ //# sourceMappingURL=help-text.js.map
@@ -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