cclaw-cli 7.7.0 → 8.1.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.
Files changed (282) hide show
  1. package/README.md +210 -134
  2. package/dist/artifact-frontmatter.d.ts +51 -0
  3. package/dist/artifact-frontmatter.js +131 -0
  4. package/dist/artifact-paths.d.ts +7 -27
  5. package/dist/artifact-paths.js +20 -249
  6. package/dist/cancel.d.ts +16 -0
  7. package/dist/cancel.js +66 -0
  8. package/dist/cli.d.ts +2 -27
  9. package/dist/cli.js +90 -508
  10. package/dist/compound.d.ts +26 -0
  11. package/dist/compound.js +96 -0
  12. package/dist/config.d.ts +14 -51
  13. package/dist/config.js +23 -359
  14. package/dist/constants.d.ts +11 -18
  15. package/dist/constants.js +19 -106
  16. package/dist/content/antipatterns.d.ts +1 -0
  17. package/dist/content/antipatterns.js +109 -0
  18. package/dist/content/artifact-templates.d.ts +10 -0
  19. package/dist/content/artifact-templates.js +550 -0
  20. package/dist/content/cancel-command.d.ts +2 -2
  21. package/dist/content/cancel-command.js +25 -17
  22. package/dist/content/core-agents.d.ts +9 -233
  23. package/dist/content/core-agents.js +39 -766
  24. package/dist/content/decision-protocol.d.ts +1 -12
  25. package/dist/content/decision-protocol.js +27 -20
  26. package/dist/content/examples.d.ts +8 -42
  27. package/dist/content/examples.js +293 -425
  28. package/dist/content/idea-command.d.ts +2 -0
  29. package/dist/content/idea-command.js +38 -0
  30. package/dist/content/iron-laws.d.ts +4 -138
  31. package/dist/content/iron-laws.js +18 -197
  32. package/dist/content/meta-skill.d.ts +1 -3
  33. package/dist/content/meta-skill.js +57 -132
  34. package/dist/content/node-hooks.d.ts +12 -8
  35. package/dist/content/node-hooks.js +188 -838
  36. package/dist/content/recovery.d.ts +8 -0
  37. package/dist/content/recovery.js +179 -0
  38. package/dist/content/reference-patterns.d.ts +4 -13
  39. package/dist/content/reference-patterns.js +260 -389
  40. package/dist/content/research-playbooks.d.ts +8 -8
  41. package/dist/content/research-playbooks.js +108 -121
  42. package/dist/content/review-loop.d.ts +6 -192
  43. package/dist/content/review-loop.js +29 -731
  44. package/dist/content/skills.d.ts +8 -38
  45. package/dist/content/skills.js +681 -732
  46. package/dist/content/specialist-prompts/architect.d.ts +1 -0
  47. package/dist/content/specialist-prompts/architect.js +225 -0
  48. package/dist/content/specialist-prompts/brainstormer.d.ts +1 -0
  49. package/dist/content/specialist-prompts/brainstormer.js +168 -0
  50. package/dist/content/specialist-prompts/index.d.ts +2 -0
  51. package/dist/content/specialist-prompts/index.js +14 -0
  52. package/dist/content/specialist-prompts/planner.d.ts +1 -0
  53. package/dist/content/specialist-prompts/planner.js +182 -0
  54. package/dist/content/specialist-prompts/reviewer.d.ts +1 -0
  55. package/dist/content/specialist-prompts/reviewer.js +193 -0
  56. package/dist/content/specialist-prompts/security-reviewer.d.ts +1 -0
  57. package/dist/content/specialist-prompts/security-reviewer.js +133 -0
  58. package/dist/content/specialist-prompts/slice-builder.d.ts +1 -0
  59. package/dist/content/specialist-prompts/slice-builder.js +232 -0
  60. package/dist/content/stage-playbooks.d.ts +8 -0
  61. package/dist/content/stage-playbooks.js +404 -0
  62. package/dist/content/start-command.d.ts +2 -12
  63. package/dist/content/start-command.js +221 -207
  64. package/dist/flow-state.d.ts +21 -178
  65. package/dist/flow-state.js +67 -170
  66. package/dist/fs-utils.d.ts +6 -26
  67. package/dist/fs-utils.js +29 -162
  68. package/dist/gitignore.d.ts +2 -1
  69. package/dist/gitignore.js +51 -34
  70. package/dist/harness-detect.d.ts +10 -0
  71. package/dist/harness-detect.js +29 -0
  72. package/dist/install.d.ts +27 -15
  73. package/dist/install.js +230 -1342
  74. package/dist/knowledge-store.d.ts +19 -163
  75. package/dist/knowledge-store.js +56 -590
  76. package/dist/logger.d.ts +8 -3
  77. package/dist/logger.js +13 -4
  78. package/dist/orchestrator-routing.d.ts +29 -0
  79. package/dist/orchestrator-routing.js +156 -0
  80. package/dist/run-persistence.d.ts +7 -118
  81. package/dist/run-persistence.js +29 -845
  82. package/dist/runtime/run-hook.entry.d.ts +1 -3
  83. package/dist/runtime/run-hook.entry.js +19 -4
  84. package/dist/runtime/run-hook.mjs +13 -1024
  85. package/dist/types.d.ts +25 -261
  86. package/dist/types.js +8 -36
  87. package/package.json +6 -3
  88. package/dist/artifact-linter/brainstorm.d.ts +0 -2
  89. package/dist/artifact-linter/brainstorm.js +0 -353
  90. package/dist/artifact-linter/design.d.ts +0 -18
  91. package/dist/artifact-linter/design.js +0 -444
  92. package/dist/artifact-linter/findings-dedup.d.ts +0 -56
  93. package/dist/artifact-linter/findings-dedup.js +0 -232
  94. package/dist/artifact-linter/plan.d.ts +0 -2
  95. package/dist/artifact-linter/plan.js +0 -826
  96. package/dist/artifact-linter/review-army.d.ts +0 -49
  97. package/dist/artifact-linter/review-army.js +0 -520
  98. package/dist/artifact-linter/review.d.ts +0 -2
  99. package/dist/artifact-linter/review.js +0 -113
  100. package/dist/artifact-linter/scope.d.ts +0 -2
  101. package/dist/artifact-linter/scope.js +0 -158
  102. package/dist/artifact-linter/shared.d.ts +0 -637
  103. package/dist/artifact-linter/shared.js +0 -2163
  104. package/dist/artifact-linter/ship.d.ts +0 -2
  105. package/dist/artifact-linter/ship.js +0 -250
  106. package/dist/artifact-linter/spec.d.ts +0 -2
  107. package/dist/artifact-linter/spec.js +0 -176
  108. package/dist/artifact-linter/tdd.d.ts +0 -118
  109. package/dist/artifact-linter/tdd.js +0 -1404
  110. package/dist/artifact-linter.d.ts +0 -15
  111. package/dist/artifact-linter.js +0 -517
  112. package/dist/codex-feature-flag.d.ts +0 -58
  113. package/dist/codex-feature-flag.js +0 -193
  114. package/dist/content/closeout-guidance.d.ts +0 -14
  115. package/dist/content/closeout-guidance.js +0 -44
  116. package/dist/content/diff-command.d.ts +0 -1
  117. package/dist/content/diff-command.js +0 -43
  118. package/dist/content/harness-doc.d.ts +0 -1
  119. package/dist/content/harness-doc.js +0 -65
  120. package/dist/content/hook-events.d.ts +0 -9
  121. package/dist/content/hook-events.js +0 -23
  122. package/dist/content/hook-manifest.d.ts +0 -81
  123. package/dist/content/hook-manifest.js +0 -156
  124. package/dist/content/hooks.d.ts +0 -11
  125. package/dist/content/hooks.js +0 -1972
  126. package/dist/content/idea.d.ts +0 -60
  127. package/dist/content/idea.js +0 -416
  128. package/dist/content/language-policy.d.ts +0 -2
  129. package/dist/content/language-policy.js +0 -13
  130. package/dist/content/learnings.d.ts +0 -6
  131. package/dist/content/learnings.js +0 -141
  132. package/dist/content/observe.d.ts +0 -19
  133. package/dist/content/observe.js +0 -86
  134. package/dist/content/opencode-plugin.d.ts +0 -1
  135. package/dist/content/opencode-plugin.js +0 -635
  136. package/dist/content/review-prompts.d.ts +0 -1
  137. package/dist/content/review-prompts.js +0 -104
  138. package/dist/content/runtime-shared-snippets.d.ts +0 -8
  139. package/dist/content/runtime-shared-snippets.js +0 -80
  140. package/dist/content/session-hooks.d.ts +0 -7
  141. package/dist/content/session-hooks.js +0 -107
  142. package/dist/content/skills-elicitation.d.ts +0 -1
  143. package/dist/content/skills-elicitation.js +0 -167
  144. package/dist/content/stage-command.d.ts +0 -2
  145. package/dist/content/stage-command.js +0 -17
  146. package/dist/content/stage-schema.d.ts +0 -117
  147. package/dist/content/stage-schema.js +0 -955
  148. package/dist/content/stages/_lint-metadata/index.d.ts +0 -2
  149. package/dist/content/stages/_lint-metadata/index.js +0 -97
  150. package/dist/content/stages/brainstorm.d.ts +0 -2
  151. package/dist/content/stages/brainstorm.js +0 -184
  152. package/dist/content/stages/design.d.ts +0 -2
  153. package/dist/content/stages/design.js +0 -288
  154. package/dist/content/stages/index.d.ts +0 -8
  155. package/dist/content/stages/index.js +0 -11
  156. package/dist/content/stages/plan.d.ts +0 -2
  157. package/dist/content/stages/plan.js +0 -191
  158. package/dist/content/stages/review.d.ts +0 -2
  159. package/dist/content/stages/review.js +0 -240
  160. package/dist/content/stages/schema-types.d.ts +0 -203
  161. package/dist/content/stages/schema-types.js +0 -1
  162. package/dist/content/stages/scope.d.ts +0 -2
  163. package/dist/content/stages/scope.js +0 -254
  164. package/dist/content/stages/ship.d.ts +0 -2
  165. package/dist/content/stages/ship.js +0 -159
  166. package/dist/content/stages/spec.d.ts +0 -2
  167. package/dist/content/stages/spec.js +0 -170
  168. package/dist/content/stages/tdd.d.ts +0 -4
  169. package/dist/content/stages/tdd.js +0 -273
  170. package/dist/content/state-contracts.d.ts +0 -1
  171. package/dist/content/state-contracts.js +0 -63
  172. package/dist/content/status-command.d.ts +0 -4
  173. package/dist/content/status-command.js +0 -109
  174. package/dist/content/subagent-context-skills.d.ts +0 -4
  175. package/dist/content/subagent-context-skills.js +0 -279
  176. package/dist/content/subagents.d.ts +0 -3
  177. package/dist/content/subagents.js +0 -997
  178. package/dist/content/templates.d.ts +0 -26
  179. package/dist/content/templates.js +0 -1692
  180. package/dist/content/track-render-context.d.ts +0 -18
  181. package/dist/content/track-render-context.js +0 -53
  182. package/dist/content/tree-command.d.ts +0 -1
  183. package/dist/content/tree-command.js +0 -64
  184. package/dist/content/utility-skills.d.ts +0 -30
  185. package/dist/content/utility-skills.js +0 -160
  186. package/dist/content/view-command.d.ts +0 -2
  187. package/dist/content/view-command.js +0 -92
  188. package/dist/delegation.d.ts +0 -649
  189. package/dist/delegation.js +0 -1539
  190. package/dist/early-loop.d.ts +0 -70
  191. package/dist/early-loop.js +0 -302
  192. package/dist/execution-topology.d.ts +0 -36
  193. package/dist/execution-topology.js +0 -73
  194. package/dist/gate-evidence.d.ts +0 -85
  195. package/dist/gate-evidence.js +0 -631
  196. package/dist/harness-adapters.d.ts +0 -151
  197. package/dist/harness-adapters.js +0 -756
  198. package/dist/harness-selection.d.ts +0 -31
  199. package/dist/harness-selection.js +0 -214
  200. package/dist/hook-schema.d.ts +0 -6
  201. package/dist/hook-schema.js +0 -114
  202. package/dist/hook-schemas/claude-hooks.v1.json +0 -10
  203. package/dist/hook-schemas/codex-hooks.v1.json +0 -10
  204. package/dist/hook-schemas/cursor-hooks.v1.json +0 -13
  205. package/dist/init-detect.d.ts +0 -2
  206. package/dist/init-detect.js +0 -50
  207. package/dist/internal/advance-stage/advance.d.ts +0 -89
  208. package/dist/internal/advance-stage/advance.js +0 -655
  209. package/dist/internal/advance-stage/cancel-run.d.ts +0 -8
  210. package/dist/internal/advance-stage/cancel-run.js +0 -19
  211. package/dist/internal/advance-stage/flow-state-coercion.d.ts +0 -3
  212. package/dist/internal/advance-stage/flow-state-coercion.js +0 -81
  213. package/dist/internal/advance-stage/helpers.d.ts +0 -14
  214. package/dist/internal/advance-stage/helpers.js +0 -145
  215. package/dist/internal/advance-stage/hook.d.ts +0 -8
  216. package/dist/internal/advance-stage/hook.js +0 -40
  217. package/dist/internal/advance-stage/parsers.d.ts +0 -72
  218. package/dist/internal/advance-stage/parsers.js +0 -357
  219. package/dist/internal/advance-stage/proactive-delegation-trace.d.ts +0 -24
  220. package/dist/internal/advance-stage/proactive-delegation-trace.js +0 -56
  221. package/dist/internal/advance-stage/review-loop.d.ts +0 -16
  222. package/dist/internal/advance-stage/review-loop.js +0 -199
  223. package/dist/internal/advance-stage/rewind.d.ts +0 -14
  224. package/dist/internal/advance-stage/rewind.js +0 -108
  225. package/dist/internal/advance-stage/start-flow.d.ts +0 -13
  226. package/dist/internal/advance-stage/start-flow.js +0 -241
  227. package/dist/internal/advance-stage/verify.d.ts +0 -21
  228. package/dist/internal/advance-stage/verify.js +0 -185
  229. package/dist/internal/advance-stage.d.ts +0 -7
  230. package/dist/internal/advance-stage.js +0 -138
  231. package/dist/internal/cohesion-contract-stub.d.ts +0 -24
  232. package/dist/internal/cohesion-contract-stub.js +0 -148
  233. package/dist/internal/compound-readiness.d.ts +0 -23
  234. package/dist/internal/compound-readiness.js +0 -102
  235. package/dist/internal/detect-public-api-changes.d.ts +0 -5
  236. package/dist/internal/detect-public-api-changes.js +0 -45
  237. package/dist/internal/detect-supply-chain-changes.d.ts +0 -6
  238. package/dist/internal/detect-supply-chain-changes.js +0 -138
  239. package/dist/internal/early-loop-status.d.ts +0 -7
  240. package/dist/internal/early-loop-status.js +0 -93
  241. package/dist/internal/envelope-validate.d.ts +0 -7
  242. package/dist/internal/envelope-validate.js +0 -66
  243. package/dist/internal/flow-state-repair.d.ts +0 -20
  244. package/dist/internal/flow-state-repair.js +0 -104
  245. package/dist/internal/plan-split-waves.d.ts +0 -190
  246. package/dist/internal/plan-split-waves.js +0 -764
  247. package/dist/internal/runtime-integrity.d.ts +0 -7
  248. package/dist/internal/runtime-integrity.js +0 -268
  249. package/dist/internal/slice-commit.d.ts +0 -7
  250. package/dist/internal/slice-commit.js +0 -619
  251. package/dist/internal/tdd-loop-status.d.ts +0 -14
  252. package/dist/internal/tdd-loop-status.js +0 -68
  253. package/dist/internal/tdd-red-evidence.d.ts +0 -7
  254. package/dist/internal/tdd-red-evidence.js +0 -153
  255. package/dist/internal/waiver-grant.d.ts +0 -62
  256. package/dist/internal/waiver-grant.js +0 -294
  257. package/dist/internal/wave-status.d.ts +0 -63
  258. package/dist/internal/wave-status.js +0 -450
  259. package/dist/managed-resources.d.ts +0 -53
  260. package/dist/managed-resources.js +0 -313
  261. package/dist/policy.d.ts +0 -10
  262. package/dist/policy.js +0 -167
  263. package/dist/retro-gate.d.ts +0 -9
  264. package/dist/retro-gate.js +0 -47
  265. package/dist/run-archive.d.ts +0 -61
  266. package/dist/run-archive.js +0 -391
  267. package/dist/runs.d.ts +0 -2
  268. package/dist/runs.js +0 -2
  269. package/dist/stack-detection.d.ts +0 -116
  270. package/dist/stack-detection.js +0 -489
  271. package/dist/streaming/event-stream.d.ts +0 -31
  272. package/dist/streaming/event-stream.js +0 -114
  273. package/dist/tdd-cycle.d.ts +0 -107
  274. package/dist/tdd-cycle.js +0 -289
  275. package/dist/tdd-verification-evidence.d.ts +0 -17
  276. package/dist/tdd-verification-evidence.js +0 -122
  277. package/dist/track-heuristics.d.ts +0 -27
  278. package/dist/track-heuristics.js +0 -154
  279. package/dist/util/slice-id.d.ts +0 -58
  280. package/dist/util/slice-id.js +0 -89
  281. package/dist/worktree-manager.d.ts +0 -20
  282. package/dist/worktree-manager.js +0 -108
@@ -0,0 +1,8 @@
1
+ export interface RecoveryPlaybook {
2
+ id: string;
3
+ fileName: string;
4
+ title: string;
5
+ body: string;
6
+ }
7
+ export declare const RECOVERY_PLAYBOOKS: RecoveryPlaybook[];
8
+ export declare const RECOVERY_INDEX: string;
@@ -0,0 +1,179 @@
1
+ const AC_TRACEABILITY_BREAK = `# Recovery — AC traceability broken
2
+
3
+ The orchestrator detects a broken AC ↔ commit chain when:
4
+
5
+ - \`flow-state.json\` has an AC with \`status: pending\` but \`builds/<slug>.md\` already has a row for that AC;
6
+ - the commit-helper hook was bypassed (a plain \`git commit\` produced a SHA that flow-state does not know about);
7
+ - a force-push rewrote SHAs that flow-state had recorded.
8
+
9
+ ## Symptoms
10
+
11
+ - \`runCompoundAndShip()\` refuses to run with: \`Cannot ship <slug>: AC traceability gate failed. Pending AC: ...\`
12
+ - a review iteration finds an AC labelled \`pending\` with a commit cited in \`builds/<slug>.md\`.
13
+
14
+ ## Recovery steps
15
+
16
+ 1. Identify the affected AC ids and the actual commit SHAs from \`git log\`.
17
+ 2. Open \`.cclaw/state/flow-state.json\` and locate the matching AC entry.
18
+ 3. Set \`commit\` to the verified SHA and \`status\` to \`committed\`.
19
+ 4. Re-render the traceability block in \`plans/<slug>.md\`: every AC gets a single line \`AC-N → commit <short-sha>\`.
20
+ 5. Re-run review-stage for the affected AC. The reviewer must see the correct chain before ship proceeds.
21
+
22
+ ## What not to do
23
+
24
+ - Do not delete \`.cclaw/state/flow-state.json\` to "start fresh". The active artifacts still reference the slug; deleting state desynchronizes everything.
25
+ - Do not edit historical commits to "fix" the message. The ship gate trusts SHAs, not messages.
26
+ - Do not amend the commit produced by commit-helper. Amending changes the SHA and breaks the chain again.
27
+ `;
28
+ const REVIEW_CAP_REACHED = `# Recovery — review hard cap reached
29
+
30
+ The reviewer reached iteration 5 with outstanding block-level findings.
31
+
32
+ ## Symptoms
33
+
34
+ - \`reviews/<slug>.md\` has 5 iteration blocks; the last one carries \`status: cap-reached\`.
35
+ - The orchestrator surfaces remaining findings and recommends \`/cc-cancel\` or splitting.
36
+
37
+ ## Recovery steps
38
+
39
+ Pick one of:
40
+
41
+ ### Option A — \`/cc-cancel\` and re-plan
42
+
43
+ 1. \`/cc-cancel reason="cap reached on <slug>"\`.
44
+ 2. Read the cap-reached block to identify the still-broken AC.
45
+ 3. \`/cc <task>\` with a tighter scope. Often the cap was reached because the slug bundled two changes; split them.
46
+ 4. The cancelled artifacts under \`.cclaw/flows/cancelled/<slug>/\` can be referenced from the new plan via the Refs section.
47
+
48
+ ### Option B — fold remaining findings into a fresh slug
49
+
50
+ 1. Manually move \`.cclaw/flows/<slug>/plan.md\` and friends out of the active directory (e.g. into \`.cclaw/flows/cancelled/\` for archive).
51
+ 2. Reset flow-state.
52
+ 3. \`/cc <new task>\` for the leftovers.
53
+
54
+ ### Option C — escalate to a human review
55
+
56
+ If the cap is genuinely a tooling failure (e.g. the reviewer kept hallucinating the same finding), capture the iteration logs as a decision record and ask a human to break the loop.
57
+
58
+ ## What not to do
59
+
60
+ - Do not raise the iteration cap. The cap exists because past iteration 5 the marginal value of another iteration is near zero.
61
+ - Do not silently force \`clear\` to ship. The block findings are real; ignoring them puts garbage into shipped/.
62
+ - Do not fork the slug into ten micro-slugs. Two or three is healthy; ten is fragmentation.
63
+ `;
64
+ const PARALLEL_BUILD_CONFLICT = `# Recovery — parallel-build slice conflict
65
+
66
+ Two slice-builders touch the same file or write conflicting changes during a \`parallel-build\` wave.
67
+
68
+ ## Symptoms
69
+
70
+ - Slice-builder #2 reports a path conflict with slice-builder #1 mid-wave.
71
+ - The integration reviewer finds two commits both editing the same file.
72
+ - Build log shows two AC committing to the same file.
73
+
74
+ ## Recovery steps
75
+
76
+ 1. Pause the wave. Stop dispatching new slice-builders.
77
+ 2. Read \`builds/<slug>.md\` to understand which AC each commit closes.
78
+ 3. Decide ownership:
79
+ - if the file legitimately needs both changes, integration reviewer reconciles them and creates a single fix-only commit referencing both AC;
80
+ - if one slice should not have touched the file, slice-builder mode=\`fix-only\` reverts the offending hunk and re-implements the AC inside its declared file set.
81
+ 4. Re-run the integration reviewer.
82
+
83
+ ## Pre-flight prevention
84
+
85
+ - Planner topology=\`parallel-build\` must verify disjoint file sets before recommending the topology.
86
+ - The orchestrator must surface the file-set partition to the user before dispatching slices.
87
+ - Slice-builders never read each other's working trees mid-wave.
88
+
89
+ ## What not to do
90
+
91
+ - Do not "merge" the conflicting commits with \`git rebase\` or \`git merge\` inside \`/cc\`. The AC chain breaks.
92
+ - Do not have one slice-builder re-do another slice-builder's AC. Hand it back to the original slice-builder via fix-only.
93
+ - Do not silently rewrite the topology to inline mid-wave. Cancel the wave, re-plan, restart.
94
+ `;
95
+ const FRONTMATTER_CORRUPTION = `# Recovery — frontmatter corruption
96
+
97
+ A YAML parser error appears when the orchestrator tries to read \`plans/<slug>.md\` or another active artifact.
98
+
99
+ ## Symptoms
100
+
101
+ - Existing-plan detection silently skips a plan it should have matched.
102
+ - The frontmatter parser throws \`FrontmatterError: Invalid YAML frontmatter: ...\`.
103
+ - The orchestrator surfaces "Artifact is missing the required YAML frontmatter block (---)".
104
+
105
+ ## Recovery steps
106
+
107
+ 1. Open the artifact in your editor.
108
+ 2. Compare against the canonical template in \`.cclaw/lib/templates/<stage>.md\`.
109
+ 3. Fix the YAML — the most common errors are:
110
+ - missing closing \`---\`;
111
+ - tabs inside the YAML block (use spaces);
112
+ - unquoted strings containing \`:\` (quote them);
113
+ - invalid date / timestamp values.
114
+ 4. Re-run the operation that surfaced the error.
115
+
116
+ ## Defensive workflow
117
+
118
+ - Every edit to an artifact frontmatter should go through \`syncFrontmatter()\` rather than hand-editing whenever possible. The function reads, patches, re-renders, and re-writes atomically.
119
+ - AC entries in frontmatter are arrays of objects; do not collapse them to one-line strings.
120
+ - Treat the AC body table and the frontmatter \`ac\` array as the same data; \`mergeAcceptanceCriteria()\` keeps them aligned.
121
+
122
+ ## What not to do
123
+
124
+ - Do not delete the frontmatter and rewrite from scratch when only one field is wrong; you lose history (review_iterations, last_specialist).
125
+ - Do not ignore the parser error and assume the orchestrator will "figure it out". Existing-plan detection silently drops corrupt artifacts.
126
+ `;
127
+ const SCHEMA_MISMATCH = `# Recovery — flow-state schemaVersion mismatch
128
+
129
+ \`/cc\` refuses to run because \`.cclaw/state/flow-state.json\` carries \`schemaVersion: 1\` (cclaw 7.x) instead of \`schemaVersion: 2\`.
130
+
131
+ ## Symptoms
132
+
133
+ - \`/cc\` prints: "This project's flow-state.json is from cclaw 7.x. cclaw v8 cannot resume it."
134
+ - \`commit-helper.mjs\` refuses to record commits with \`schemaVersion mismatch\`.
135
+
136
+ ## Recovery options
137
+
138
+ The orchestrator surfaces three options. Pick one explicitly:
139
+
140
+ ### (a) Finish or abandon the run with cclaw 7.x
141
+
142
+ If you have an in-flight 7.x run and want to ship it, do that first. After ship, the active state is reset and the project can install cclaw v8 cleanly.
143
+
144
+ ### (b) Delete \`.cclaw/state/flow-state.json\` and start fresh
145
+
146
+ For projects that are not mid-run, this is the right answer. The artifacts under \`.cclaw/flows/<slug>/\` are not deleted; only the state file is.
147
+
148
+ \`\`\`bash
149
+ rm .cclaw/state/flow-state.json
150
+ npx cclaw-cli sync
151
+ \`\`\`
152
+
153
+ \`cclaw sync\` writes a fresh \`flow-state.json\` with \`schemaVersion: 2\`.
154
+
155
+ ### (c) Leave it alone
156
+
157
+ If you want to continue using cclaw 7.x for now, do not run any v8 \`/cc\` commands. Pin the toolkit version in your project to \`7.7.1\`.
158
+
159
+ ## What not to do
160
+
161
+ - Do not edit the \`schemaVersion\` field by hand. Version 2 has different fields than version 1; mismatched fields fail validation downstream.
162
+ - Do not delete the artifacts under \`.cclaw/flows/<slug>/\` — they survive the version transition; only the state file does not.
163
+ - Do not run \`cclaw-cli upgrade\` while a 7.x run is mid-flight. Finish the run first.
164
+ `;
165
+ export const RECOVERY_PLAYBOOKS = [
166
+ { id: "ac-traceability-break", fileName: "ac-traceability-break.md", title: "Recovery — AC traceability broken", body: AC_TRACEABILITY_BREAK },
167
+ { id: "review-cap-reached", fileName: "review-cap-reached.md", title: "Recovery — review hard cap reached", body: REVIEW_CAP_REACHED },
168
+ { id: "parallel-build-conflict", fileName: "parallel-build-conflict.md", title: "Recovery — parallel-build slice conflict", body: PARALLEL_BUILD_CONFLICT },
169
+ { id: "frontmatter-corruption", fileName: "frontmatter-corruption.md", title: "Recovery — frontmatter corruption", body: FRONTMATTER_CORRUPTION },
170
+ { id: "schema-mismatch", fileName: "schema-mismatch.md", title: "Recovery — flow-state schemaVersion mismatch", body: SCHEMA_MISMATCH }
171
+ ];
172
+ export const RECOVERY_INDEX = `# .cclaw/lib/recovery/
173
+
174
+ Recovery playbooks for the most common failure modes. The orchestrator opens these when an automated check fails or when a specialist asks for guidance.
175
+
176
+ | playbook | symptom |
177
+ | --- | --- |
178
+ ${RECOVERY_PLAYBOOKS.map((p) => `| [\`${p.fileName}\`](./${p.fileName}) | ${p.title.replace(/^Recovery — /u, "")} |`).join("\n")}
179
+ `;
@@ -1,18 +1,9 @@
1
- import type { FlowStage } from "../types.js";
2
- export interface ReferencePatternContract {
3
- stage: FlowStage;
4
- guidance: string[];
5
- artifactSections: string[];
6
- }
7
1
  export interface ReferencePattern {
8
2
  id: string;
3
+ fileName: string;
9
4
  title: string;
10
- intent: string;
11
- useWhen: string;
12
- policyNeedles: string[];
13
- contracts: ReferencePatternContract[];
5
+ triggers: string[];
6
+ body: string;
14
7
  }
15
8
  export declare const REFERENCE_PATTERNS: ReferencePattern[];
16
- export declare function referencePatternsForStage(stage: FlowStage): ReferencePattern[];
17
- export declare function referencePatternContractsForStage(stage: FlowStage): ReferencePatternContract[];
18
- export declare function referencePatternPolicyNeedles(stage: FlowStage): string[];
9
+ export declare const REFERENCE_PATTERNS_INDEX: string;