cclaw-cli 7.7.1 → 8.1.1

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 (284) hide show
  1. package/README.md +211 -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 +107 -511
  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 -768
  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 -134
  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/harness-prompt.d.ts +26 -0
  73. package/dist/harness-prompt.js +142 -0
  74. package/dist/install.d.ts +35 -15
  75. package/dist/install.js +238 -1347
  76. package/dist/knowledge-store.d.ts +19 -163
  77. package/dist/knowledge-store.js +56 -590
  78. package/dist/logger.d.ts +8 -3
  79. package/dist/logger.js +13 -4
  80. package/dist/orchestrator-routing.d.ts +29 -0
  81. package/dist/orchestrator-routing.js +156 -0
  82. package/dist/run-persistence.d.ts +7 -118
  83. package/dist/run-persistence.js +29 -845
  84. package/dist/runtime/run-hook.entry.d.ts +1 -3
  85. package/dist/runtime/run-hook.entry.js +19 -4
  86. package/dist/runtime/run-hook.mjs +13 -1024
  87. package/dist/types.d.ts +25 -261
  88. package/dist/types.js +8 -36
  89. package/package.json +6 -3
  90. package/dist/artifact-linter/brainstorm.d.ts +0 -2
  91. package/dist/artifact-linter/brainstorm.js +0 -353
  92. package/dist/artifact-linter/design.d.ts +0 -18
  93. package/dist/artifact-linter/design.js +0 -444
  94. package/dist/artifact-linter/findings-dedup.d.ts +0 -56
  95. package/dist/artifact-linter/findings-dedup.js +0 -232
  96. package/dist/artifact-linter/plan.d.ts +0 -2
  97. package/dist/artifact-linter/plan.js +0 -826
  98. package/dist/artifact-linter/review-army.d.ts +0 -49
  99. package/dist/artifact-linter/review-army.js +0 -520
  100. package/dist/artifact-linter/review.d.ts +0 -2
  101. package/dist/artifact-linter/review.js +0 -113
  102. package/dist/artifact-linter/scope.d.ts +0 -2
  103. package/dist/artifact-linter/scope.js +0 -158
  104. package/dist/artifact-linter/shared.d.ts +0 -637
  105. package/dist/artifact-linter/shared.js +0 -2163
  106. package/dist/artifact-linter/ship.d.ts +0 -2
  107. package/dist/artifact-linter/ship.js +0 -250
  108. package/dist/artifact-linter/spec.d.ts +0 -2
  109. package/dist/artifact-linter/spec.js +0 -176
  110. package/dist/artifact-linter/tdd.d.ts +0 -118
  111. package/dist/artifact-linter/tdd.js +0 -1404
  112. package/dist/artifact-linter.d.ts +0 -15
  113. package/dist/artifact-linter.js +0 -517
  114. package/dist/codex-feature-flag.d.ts +0 -58
  115. package/dist/codex-feature-flag.js +0 -193
  116. package/dist/content/closeout-guidance.d.ts +0 -14
  117. package/dist/content/closeout-guidance.js +0 -44
  118. package/dist/content/diff-command.d.ts +0 -1
  119. package/dist/content/diff-command.js +0 -43
  120. package/dist/content/harness-doc.d.ts +0 -1
  121. package/dist/content/harness-doc.js +0 -65
  122. package/dist/content/hook-events.d.ts +0 -9
  123. package/dist/content/hook-events.js +0 -23
  124. package/dist/content/hook-manifest.d.ts +0 -81
  125. package/dist/content/hook-manifest.js +0 -156
  126. package/dist/content/hooks.d.ts +0 -11
  127. package/dist/content/hooks.js +0 -1972
  128. package/dist/content/idea.d.ts +0 -60
  129. package/dist/content/idea.js +0 -416
  130. package/dist/content/language-policy.d.ts +0 -2
  131. package/dist/content/language-policy.js +0 -13
  132. package/dist/content/learnings.d.ts +0 -6
  133. package/dist/content/learnings.js +0 -141
  134. package/dist/content/observe.d.ts +0 -19
  135. package/dist/content/observe.js +0 -86
  136. package/dist/content/opencode-plugin.d.ts +0 -1
  137. package/dist/content/opencode-plugin.js +0 -635
  138. package/dist/content/review-prompts.d.ts +0 -1
  139. package/dist/content/review-prompts.js +0 -104
  140. package/dist/content/runtime-shared-snippets.d.ts +0 -8
  141. package/dist/content/runtime-shared-snippets.js +0 -80
  142. package/dist/content/session-hooks.d.ts +0 -7
  143. package/dist/content/session-hooks.js +0 -107
  144. package/dist/content/skills-elicitation.d.ts +0 -1
  145. package/dist/content/skills-elicitation.js +0 -167
  146. package/dist/content/stage-command.d.ts +0 -2
  147. package/dist/content/stage-command.js +0 -17
  148. package/dist/content/stage-schema.d.ts +0 -117
  149. package/dist/content/stage-schema.js +0 -955
  150. package/dist/content/stages/_lint-metadata/index.d.ts +0 -2
  151. package/dist/content/stages/_lint-metadata/index.js +0 -97
  152. package/dist/content/stages/brainstorm.d.ts +0 -2
  153. package/dist/content/stages/brainstorm.js +0 -184
  154. package/dist/content/stages/design.d.ts +0 -2
  155. package/dist/content/stages/design.js +0 -288
  156. package/dist/content/stages/index.d.ts +0 -8
  157. package/dist/content/stages/index.js +0 -11
  158. package/dist/content/stages/plan.d.ts +0 -2
  159. package/dist/content/stages/plan.js +0 -191
  160. package/dist/content/stages/review.d.ts +0 -2
  161. package/dist/content/stages/review.js +0 -240
  162. package/dist/content/stages/schema-types.d.ts +0 -203
  163. package/dist/content/stages/schema-types.js +0 -1
  164. package/dist/content/stages/scope.d.ts +0 -2
  165. package/dist/content/stages/scope.js +0 -254
  166. package/dist/content/stages/ship.d.ts +0 -2
  167. package/dist/content/stages/ship.js +0 -159
  168. package/dist/content/stages/spec.d.ts +0 -2
  169. package/dist/content/stages/spec.js +0 -170
  170. package/dist/content/stages/tdd.d.ts +0 -4
  171. package/dist/content/stages/tdd.js +0 -273
  172. package/dist/content/state-contracts.d.ts +0 -1
  173. package/dist/content/state-contracts.js +0 -63
  174. package/dist/content/status-command.d.ts +0 -4
  175. package/dist/content/status-command.js +0 -109
  176. package/dist/content/subagent-context-skills.d.ts +0 -4
  177. package/dist/content/subagent-context-skills.js +0 -279
  178. package/dist/content/subagents.d.ts +0 -3
  179. package/dist/content/subagents.js +0 -997
  180. package/dist/content/templates.d.ts +0 -26
  181. package/dist/content/templates.js +0 -1692
  182. package/dist/content/track-render-context.d.ts +0 -18
  183. package/dist/content/track-render-context.js +0 -53
  184. package/dist/content/tree-command.d.ts +0 -1
  185. package/dist/content/tree-command.js +0 -64
  186. package/dist/content/utility-skills.d.ts +0 -30
  187. package/dist/content/utility-skills.js +0 -160
  188. package/dist/content/view-command.d.ts +0 -2
  189. package/dist/content/view-command.js +0 -92
  190. package/dist/delegation.d.ts +0 -649
  191. package/dist/delegation.js +0 -1539
  192. package/dist/early-loop.d.ts +0 -70
  193. package/dist/early-loop.js +0 -302
  194. package/dist/execution-topology.d.ts +0 -44
  195. package/dist/execution-topology.js +0 -95
  196. package/dist/gate-evidence.d.ts +0 -85
  197. package/dist/gate-evidence.js +0 -631
  198. package/dist/harness-adapters.d.ts +0 -151
  199. package/dist/harness-adapters.js +0 -756
  200. package/dist/harness-selection.d.ts +0 -31
  201. package/dist/harness-selection.js +0 -214
  202. package/dist/hook-schema.d.ts +0 -6
  203. package/dist/hook-schema.js +0 -114
  204. package/dist/hook-schemas/claude-hooks.v1.json +0 -10
  205. package/dist/hook-schemas/codex-hooks.v1.json +0 -10
  206. package/dist/hook-schemas/cursor-hooks.v1.json +0 -13
  207. package/dist/init-detect.d.ts +0 -2
  208. package/dist/init-detect.js +0 -50
  209. package/dist/internal/advance-stage/advance.d.ts +0 -89
  210. package/dist/internal/advance-stage/advance.js +0 -655
  211. package/dist/internal/advance-stage/cancel-run.d.ts +0 -8
  212. package/dist/internal/advance-stage/cancel-run.js +0 -19
  213. package/dist/internal/advance-stage/flow-state-coercion.d.ts +0 -3
  214. package/dist/internal/advance-stage/flow-state-coercion.js +0 -81
  215. package/dist/internal/advance-stage/helpers.d.ts +0 -14
  216. package/dist/internal/advance-stage/helpers.js +0 -145
  217. package/dist/internal/advance-stage/hook.d.ts +0 -8
  218. package/dist/internal/advance-stage/hook.js +0 -40
  219. package/dist/internal/advance-stage/parsers.d.ts +0 -72
  220. package/dist/internal/advance-stage/parsers.js +0 -357
  221. package/dist/internal/advance-stage/proactive-delegation-trace.d.ts +0 -24
  222. package/dist/internal/advance-stage/proactive-delegation-trace.js +0 -56
  223. package/dist/internal/advance-stage/review-loop.d.ts +0 -16
  224. package/dist/internal/advance-stage/review-loop.js +0 -199
  225. package/dist/internal/advance-stage/rewind.d.ts +0 -14
  226. package/dist/internal/advance-stage/rewind.js +0 -108
  227. package/dist/internal/advance-stage/start-flow.d.ts +0 -13
  228. package/dist/internal/advance-stage/start-flow.js +0 -241
  229. package/dist/internal/advance-stage/verify.d.ts +0 -21
  230. package/dist/internal/advance-stage/verify.js +0 -185
  231. package/dist/internal/advance-stage.d.ts +0 -7
  232. package/dist/internal/advance-stage.js +0 -138
  233. package/dist/internal/cohesion-contract-stub.d.ts +0 -24
  234. package/dist/internal/cohesion-contract-stub.js +0 -148
  235. package/dist/internal/compound-readiness.d.ts +0 -23
  236. package/dist/internal/compound-readiness.js +0 -102
  237. package/dist/internal/detect-public-api-changes.d.ts +0 -5
  238. package/dist/internal/detect-public-api-changes.js +0 -45
  239. package/dist/internal/detect-supply-chain-changes.d.ts +0 -6
  240. package/dist/internal/detect-supply-chain-changes.js +0 -138
  241. package/dist/internal/early-loop-status.d.ts +0 -7
  242. package/dist/internal/early-loop-status.js +0 -93
  243. package/dist/internal/envelope-validate.d.ts +0 -7
  244. package/dist/internal/envelope-validate.js +0 -66
  245. package/dist/internal/flow-state-repair.d.ts +0 -20
  246. package/dist/internal/flow-state-repair.js +0 -104
  247. package/dist/internal/plan-split-waves.d.ts +0 -190
  248. package/dist/internal/plan-split-waves.js +0 -764
  249. package/dist/internal/runtime-integrity.d.ts +0 -7
  250. package/dist/internal/runtime-integrity.js +0 -268
  251. package/dist/internal/slice-commit.d.ts +0 -7
  252. package/dist/internal/slice-commit.js +0 -619
  253. package/dist/internal/tdd-loop-status.d.ts +0 -14
  254. package/dist/internal/tdd-loop-status.js +0 -68
  255. package/dist/internal/tdd-red-evidence.d.ts +0 -7
  256. package/dist/internal/tdd-red-evidence.js +0 -153
  257. package/dist/internal/waiver-grant.d.ts +0 -62
  258. package/dist/internal/waiver-grant.js +0 -294
  259. package/dist/internal/wave-status.d.ts +0 -74
  260. package/dist/internal/wave-status.js +0 -506
  261. package/dist/managed-resources.d.ts +0 -53
  262. package/dist/managed-resources.js +0 -313
  263. package/dist/policy.d.ts +0 -10
  264. package/dist/policy.js +0 -167
  265. package/dist/retro-gate.d.ts +0 -9
  266. package/dist/retro-gate.js +0 -47
  267. package/dist/run-archive.d.ts +0 -61
  268. package/dist/run-archive.js +0 -391
  269. package/dist/runs.d.ts +0 -2
  270. package/dist/runs.js +0 -2
  271. package/dist/stack-detection.d.ts +0 -116
  272. package/dist/stack-detection.js +0 -489
  273. package/dist/streaming/event-stream.d.ts +0 -31
  274. package/dist/streaming/event-stream.js +0 -114
  275. package/dist/tdd-cycle.d.ts +0 -107
  276. package/dist/tdd-cycle.js +0 -289
  277. package/dist/tdd-verification-evidence.d.ts +0 -17
  278. package/dist/tdd-verification-evidence.js +0 -122
  279. package/dist/track-heuristics.d.ts +0 -27
  280. package/dist/track-heuristics.js +0 -154
  281. package/dist/util/slice-id.d.ts +0 -58
  282. package/dist/util/slice-id.js +0 -89
  283. package/dist/worktree-manager.d.ts +0 -20
  284. package/dist/worktree-manager.js +0 -108
@@ -1,8 +1,8 @@
1
- /**
2
- * In-thread research playbooks.
3
- *
4
- * These files intentionally have no YAML frontmatter and are not standalone
5
- * delegated personas. The primary agent loads and executes them directly.
6
- */
7
- export declare const RESEARCH_PLAYBOOKS: Record<string, string>;
8
- export declare const RESEARCH_PLAYBOOK_FILES: string[];
1
+ export interface ResearchPlaybook {
2
+ id: string;
3
+ fileName: string;
4
+ title: string;
5
+ body: string;
6
+ }
7
+ export declare const RESEARCH_PLAYBOOKS: ResearchPlaybook[];
8
+ export declare const RESEARCH_PLAYBOOKS_INDEX: string;
@@ -1,171 +1,158 @@
1
- /**
2
- * In-thread research playbooks.
3
- *
4
- * These files intentionally have no YAML frontmatter and are not standalone
5
- * delegated personas. The primary agent loads and executes them directly.
6
- */
7
- export const RESEARCH_PLAYBOOKS = {
8
- "repo-scan.md": `# Repo Scan Playbook
1
+ const READING_CODEBASE = `# Research — reading the codebase
9
2
 
10
- ## Purpose
3
+ Planner mode \`research\` exists because writing a plan against a codebase you have not read produces speculation. This playbook scopes "read enough" without becoming a stall. It covers three reading targets: implementation files, existing tests, and integration boundaries.
11
4
 
12
- Build a grounded map of existing modules and reuse candidates before design lock.
5
+ ## 1. What you must read
13
6
 
14
- ## Steps
7
+ | signal | read |
8
+ | --- | --- |
9
+ | AC mentions a file | the file (or the relevant function within it) |
10
+ | AC mentions a test | the test file |
11
+ | AC implies a public API change | the export site + at least one consumer |
12
+ | AC implies a schema change | the migration directory + the ORM model |
13
+ | AC implies a config change | the config file + every place it is read |
14
+ | AC implies a CI change | the workflow file + the policy doc, if any |
15
15
 
16
- 1. Identify 3-8 task keywords (feature nouns + action verbs).
17
- 2. Search for likely modules with \`rg\` and \`Glob\` patterns.
18
- 3. List existing implementations or close analogs with file citations.
19
- 4. Flag duplication risk and obvious extension points.
16
+ ## 2. What you may skim
20
17
 
21
- ## Output Contract
18
+ | signal | skim |
19
+ | --- | --- |
20
+ | README mentions the area | the relevant README section |
21
+ | Prior shipped slug for the same area exists | \`.cclaw/flows/shipped/<slug>/manifest.md\` |
22
+ | Prior decisions in the area | \`.cclaw/flows/shipped/<slug>/decisions.md\` |
22
23
 
23
- - Relevant modules: \`path - purpose\`
24
- - Reuse candidates: \`file:line - why reusable\`
25
- - Gaps: capabilities not currently present
24
+ ## 3. What you may ignore
26
25
 
27
- ## Guardrails
26
+ - The whole codebase. You are not writing a survey paper.
27
+ - Files outside the AC's declared file set.
28
+ - Library source unless the AC depends on a private library detail.
28
29
 
29
- - Read-only procedure.
30
- - Never invent paths or ownership.
31
- - If scope is too broad, return bounded partial coverage explicitly.
32
- `,
33
- "learnings-lookup.md": `# Learnings Lookup Playbook
30
+ ## 4. Reading existing tests effectively
34
31
 
35
- ## Purpose
32
+ When the task is to add or modify behaviour, the existing test suite is the fastest way to understand the contract.
36
33
 
37
- Reuse prior project knowledge before choosing a direction.
34
+ **Where to look first:**
38
35
 
39
- ## Steps
36
+ 1. The test file with the same name as the module (\`src/foo.ts\` → \`tests/unit/foo.test.ts\` or \`src/foo.test.ts\`). Read the highest-fidelity tests there: integration > unit, behavioural > snapshot.
37
+ 2. The most recent test file in the same directory. It usually reflects the current style, fixture conventions, and mocking choices.
38
+ 3. The shared fixtures (\`tests/helpers/\` or equivalent). They carry the project's idea of "a normal record"; reuse instead of inventing.
40
39
 
41
- 1. Use the session-injected knowledge digest first.
42
- 2. Read \`.cclaw/knowledge.jsonl\` only if the digest is missing or too thin.
43
- 3. Match by stage/domain keywords from the current task.
44
- 4. Rank matches by confidence and recency.
45
- 5. Return the top entries verbatim.
40
+ **What to extract:**
46
41
 
47
- ## Output Contract
42
+ - The contract the module advertises. Tests are the contract.
43
+ - The runner conventions (\`describe\` / \`it\` / \`test\`, async style, mock library).
44
+ - The "doesn't crash on edge X" tests — these often map directly to AC verification lines.
48
45
 
49
- - Matched rules
50
- - Matched patterns
51
- - Matched lessons
52
- - Matched compounds
53
- - Explicit no-match note when empty
46
+ **What to ignore:**
54
47
 
55
- ## Guardrails
48
+ - Snapshot tests for unrelated parts of the file.
49
+ - Coverage gaps in adjacent modules.
50
+ - Tests skipped with \`.skip\` / \`xit\` / \`@pytest.mark.skip\` — usually intentional or stale.
56
51
 
57
- - Append-only store: do not rewrite history entries.
58
- - Prefer exact quote over paraphrase.
59
- `,
60
- "framework-docs-lookup.md": `# Framework Docs Lookup Playbook
52
+ Findings flow back to the plan as either AC verification lines that reference an existing test ("AC-2 verified by \`tests/unit/foo.test.ts: handles empty input\`") or a new AC ("AC-3: pin the empty-input case in a test").
61
53
 
62
- ## Purpose
54
+ ## 5. Reading integration boundaries
63
55
 
64
- Anchor design decisions to version-accurate framework/library docs.
56
+ When the task crosses a module boundary or depends on a library upgrade, read both sides.
65
57
 
66
- ## Steps
58
+ **Internal boundaries:**
67
59
 
68
- 1. Resolve the actual dependency version from lockfiles/manifests.
69
- 2. Fetch official docs for that version (context7 when available).
70
- 3. Extract APIs used by the task and any migration or deprecation notes.
60
+ - The exported surface (\`index.ts\` / \`__init__.py\` / \`mod.rs\`) and the consumers.
61
+ - Any DI registration or factory wiring.
62
+ - The integration test that covers the boundary, if it exists.
71
63
 
72
- ## Output Contract
64
+ If no integration test exists, "add one" is often a valid AC.
73
65
 
74
- - Library + version
75
- - APIs/signatures touched
76
- - Relevant breaking changes or gotchas
77
- - Source links/references
66
+ **External boundaries (third-party libraries):**
78
67
 
79
- ## Guardrails
68
+ - The library's documented API for the version pinned in the project (not the latest version).
69
+ - Any compatibility shims the project added (look for files with \`compat\` / \`shim\` / \`adapter\` in the name).
70
+ - The version constraint in \`package.json\` / \`pyproject.toml\` / \`Cargo.toml\` / equivalent.
80
71
 
81
- - No speculative APIs.
82
- - If docs conflict or are unclear, mark UNKNOWN and escalate.
83
- `,
84
- "best-practices-lookup.md": `# Best Practices Lookup Playbook
72
+ If the project uses a feature the pinned version does not have, escalate back to architect.
85
73
 
86
- ## Purpose
74
+ A boundary inventory then enters the Plan phases (e.g. "Phase 1 — extend boundary at \`src/server/api/index.ts\` to expose the new route"). If the boundary is across a trust boundary (network, IPC, eval), set \`security_flag: true\` in plan frontmatter.
87
75
 
88
- Summarize citable domain practices for a narrow design decision.
76
+ ## 6. Where the output lands
89
77
 
90
- ## Steps
78
+ Research mode does not produce its own artifact. It feeds two sections of \`flows/<slug>/plan.md\`:
91
79
 
92
- 1. Narrow the domain to one concrete sub-problem.
93
- 2. Gather 3-5 authoritative sources.
94
- 3. Produce short practice and anti-pattern lists tied to sources.
80
+ - the **Context** paragraph, citing what you read;
81
+ - the **Plan** phases, with file:line references.
95
82
 
96
- ## Output Contract
83
+ ## 7. Stop conditions
97
84
 
98
- - Recommended practices (\`practice - rationale - source\`)
99
- - Common traps (\`trap - why it fails - source\`)
100
- - Decision hooks (1-3 questions to resolve before proceeding)
85
+ Stop reading when you can answer:
101
86
 
102
- ## Guardrails
87
+ 1. Where will the change land? (file:line)
88
+ 2. Who calls / depends on the changed code?
89
+ 3. What is the verification (test, command, manual step)?
90
+ 4. What is the smallest commit that satisfies AC-1?
103
91
 
104
- - Cite authoritative sources (official docs/standards).
105
- - State uncertainty explicitly when consensus is weak.
106
- `,
107
- "research-fleet.md": `# Parallel Research Fleet Playbook
92
+ If you can answer all four, stop reading and start authoring AC.
93
+ `;
94
+ const HOW_TO_TIME_BOX = `# Research — time-boxing
108
95
 
109
- ## Purpose
96
+ Research can dominate a slug if you let it. Time-box.
110
97
 
111
- Run a tiered investigation before design lock so architecture choices are grounded
112
- in current ecosystem data, not intuition.
98
+ ## Default budget
113
99
 
114
- ## Dispatch Lenses (tiered)
100
+ - 5-10 minutes of reading per AC.
101
+ - 15-30 minutes total for medium tasks.
102
+ - Up to 60 minutes for large/risky tasks; if you exceed 60 minutes, the task is too large and should be split.
115
103
 
116
- Choose the smallest tier that matches the change; use parallel threads only when the
117
- harness supports it and the lenses are independent:
104
+ ## Signals that you are over-reading
118
105
 
119
- - **Lightweight:** pitfalls-researcher only known failure modes, CVEs, and operational traps.
120
- - **Standard:** architecture-researcher + pitfalls-researcher.
121
- - **Deep:** stack-researcher + features-researcher + architecture-researcher + pitfalls-researcher.
106
+ - You re-read the same file twice without finding new information.
107
+ - You start reading "interesting" code outside the AC scope.
108
+ - You start drafting unrelated refactors mentally.
122
109
 
123
- ## Output Contract
110
+ When any of these triggers, stop reading. Author the plan with what you have. The reviewer will catch holes; you do not need to be exhaustive at plan-stage.
124
111
 
125
- Write findings to \`.cclaw/artifacts/02a-research.md\` with these sections:
112
+ ## Signals that you are under-reading
126
113
 
127
- - \`## Stack Analysis\`
128
- - \`## Features & Patterns\`
129
- - \`## Architecture Options\`
130
- - \`## Pitfalls & Risks\`
131
- - \`## Synthesis\`
114
+ - You cannot cite a single \`file:path:line\` reference.
115
+ - You cannot name the verification step for an AC.
116
+ - You are speculating about library behaviour rather than reading the call site.
132
117
 
133
- Each section that was run must contain concrete notes and at least one evidence reference
134
- (source URL, file path, or command output anchor). Sections skipped by tier should say \`Not run for this tier\`.
118
+ In all three cases, read more before authoring.
119
+ `;
120
+ const HOW_TO_USE_PRIOR_SLUGS = `# Research — using prior shipped slugs
135
121
 
136
- ## Guardrails
122
+ Refinement is the cheapest path to a high-quality plan. Use it.
137
123
 
138
- - Investigate first; no production code edits in this playbook.
139
- - Keep lenses independent during fan-out; merge only in synthesis.
140
- - If any lens is incomplete, record it explicitly in \`## Synthesis\` as a blocker.
141
- `,
142
- "git-history.md": `# Git History Playbook
124
+ ## When to look at prior slugs
143
125
 
144
- ## Purpose
126
+ - Existing-plan detection found a match (slug or body overlap).
127
+ - The user said "remember when we did X" / "like the previous one" / "fix the thing we shipped last week".
128
+ - The task touches an area that has been shipped within the past month.
145
129
 
146
- Detect churn, regressions, and ownership signals before locking scope/design.
130
+ ## What to extract from a prior shipped slug
147
131
 
148
- ## Steps
132
+ | from | extract |
133
+ | --- | --- |
134
+ | \`shipped/<slug>/manifest.md\` | AC ↔ commit map; ship_commit |
135
+ | \`shipped/<slug>/plan.md\` | Context, Frame, Out-of-scope items (still useful) |
136
+ | \`shipped/<slug>/decisions.md\` | architectural decisions and their consequences |
137
+ | \`shipped/<slug>/learnings.md\` | what we got wrong; what to keep doing |
138
+ | \`shipped/<slug>/review.md\` | findings from the last review (some may still apply) |
149
139
 
150
- 1. For impacted paths, inspect recent history and themes:
151
- - \`git log --follow -n 20 -- <path>\`
152
- 2. Check ownership hotspots:
153
- - \`git blame <path>\`
154
- - \`git log --since="<window>" --format="%an" -- <path>\`
155
- 3. Search for regression signals:
156
- - \`git log --since="<window>" --grep="revert|regression" -- <path>\`
140
+ ## What not to do
157
141
 
158
- ## Output Contract
142
+ - Do not copy AC verbatim into the new plan. AC restart at AC-1 in a refinement.
143
+ - Do not assume the architecture is unchanged. Re-validate; the refinement may invalidate prior assumptions.
144
+ - Do not treat the prior \`learnings.md\` as ground truth. It captures what we learned at the time; new evidence may overrule it.
145
+ `;
146
+ export const RESEARCH_PLAYBOOKS = [
147
+ { id: "reading-codebase", fileName: "reading-codebase.md", title: "Research — reading the codebase", body: READING_CODEBASE },
148
+ { id: "time-boxing", fileName: "time-boxing.md", title: "Research — time-boxing", body: HOW_TO_TIME_BOX },
149
+ { id: "prior-slugs", fileName: "prior-slugs.md", title: "Research — using prior shipped slugs", body: HOW_TO_USE_PRIOR_SLUGS }
150
+ ];
151
+ export const RESEARCH_PLAYBOOKS_INDEX = `# .cclaw/lib/research/
159
152
 
160
- - Recent themes
161
- - Revert/regression signals (with SHAs)
162
- - Ownership hints
163
- - Collision risks with ongoing refactors
153
+ Research playbooks loaded by \`planner\` mode=\`research\`. Each playbook is a small, focused checklist; they compose with each other.
164
154
 
165
- ## Guardrails
166
-
167
- - Read-only git usage.
168
- - If there is no history, say so explicitly.
169
- `
170
- };
171
- export const RESEARCH_PLAYBOOK_FILES = Object.keys(RESEARCH_PLAYBOOKS).sort();
155
+ | playbook | when |
156
+ | --- | --- |
157
+ ${RESEARCH_PLAYBOOKS.map((p) => `| [\`${p.fileName}\`](./${p.fileName}) | ${p.title.replace(/^Research — /u, "")} |`).join("\n")}
158
+ `;
@@ -1,194 +1,8 @@
1
- import type { FlowStage } from "../types.js";
2
- import type { SkillEnvelope } from "./stage-schema.js";
3
- export declare const REVIEW_LOOP_STAGES: readonly ["scope", "design"];
4
- export type ReviewLoopStage = (typeof REVIEW_LOOP_STAGES)[number];
5
- export declare const REVIEW_LOOP_DEFAULT_MAX_ITERATIONS = 3;
6
- export declare const REVIEW_LOOP_DEFAULT_TARGET_SCORE = 0.8;
7
- export type ReviewFindingSeverity = "critical" | "important" | "suggestion";
8
- export type ReviewLoopStopReason = "quality_threshold_met" | "max_iterations_reached" | "user_opt_out";
9
- export interface ReviewLoopDimension {
1
+ export interface FailureMode {
10
2
  id: string;
11
- label: string;
12
- weight: number;
13
- guidance: string;
3
+ name: string;
4
+ description: string;
14
5
  }
15
- export interface ReviewLoopDimensionScore {
16
- dimensionId: string;
17
- score: number;
18
- weight?: number;
19
- rationale?: string;
20
- }
21
- export interface ReviewFinding {
22
- id: string;
23
- dimensionId: string;
24
- severity: ReviewFindingSeverity;
25
- summary: string;
26
- evidence?: string;
27
- recommendation?: string;
28
- }
29
- export interface ReviewLoopBudget {
30
- maxIterations?: number;
31
- targetScore?: number;
32
- }
33
- export interface ReviewLoopIterationSummary {
34
- iteration: number;
35
- qualityScore: number;
36
- findingsCount: number;
37
- }
38
- export interface ReviewLoopInput {
39
- artifactPath: string;
40
- stage: ReviewLoopStage;
41
- checklist?: readonly ReviewLoopDimension[];
42
- priorIterations?: ReadonlyArray<ReviewLoopIterationSummary>;
43
- budget?: ReviewLoopBudget;
44
- }
45
- export interface ReviewLoopDispatchRequest {
46
- stage: ReviewLoopStage;
47
- artifactPath: string;
48
- checklist: readonly ReviewLoopDimension[];
49
- priorIterations: ReadonlyArray<ReviewLoopIterationSummary>;
50
- iteration: number;
51
- budget: Required<ReviewLoopBudget>;
52
- }
53
- export interface ReviewLoopIterationResult {
54
- qualityScore: number;
55
- findings: ReviewFinding[];
56
- iteration: number;
57
- shouldContinue: boolean;
58
- dimensionScores: ReviewLoopDimensionScore[];
59
- }
60
- export interface ReviewLoopEnvelope {
61
- type: "review-loop";
62
- version: "1";
63
- stage: ReviewLoopStage;
64
- artifactPath: string;
65
- targetScore: number;
66
- maxIterations: number;
67
- stopReason: ReviewLoopStopReason;
68
- iterations: ReviewLoopIterationSummary[];
69
- }
70
- export interface ReviewLoopRunResult {
71
- iterations: ReviewLoopIterationResult[];
72
- qualityScore: number;
73
- stopReason: ReviewLoopStopReason;
74
- envelope: ReviewLoopEnvelope;
75
- }
76
- export type ReviewLoopDispatcher = (request: ReviewLoopDispatchRequest) => Promise<unknown>;
77
- export interface ReviewLoopDispatchAdapterRequest {
78
- request: ReviewLoopDispatchRequest;
79
- prompt: string;
80
- responseSchema: string;
81
- }
82
- export type ReviewLoopDispatchAdapter = (payload: ReviewLoopDispatchAdapterRequest) => Promise<unknown>;
83
- export interface ReviewLoopSecondOpinionPolicy {
84
- enabled?: boolean;
85
- scoreDeltaThreshold?: number;
86
- modelLabel?: string;
87
- }
88
- export interface ReviewLoopSecondOpinionMeta {
89
- enabled: boolean;
90
- modelLabel?: string;
91
- primaryScore: number;
92
- secondOpinionScore: number;
93
- scoreDelta: number;
94
- threshold: number;
95
- }
96
- export type ReviewLoopApplyFindings = (iteration: ReviewLoopIterationResult) => Promise<void> | void;
97
- export interface RunReviewLoopOptions {
98
- dispatcher: ReviewLoopDispatcher;
99
- applyFindings: ReviewLoopApplyFindings;
100
- shouldOptOut?: () => boolean;
101
- emitEnvelope?: (envelope: ReviewLoopEnvelope) => void;
102
- }
103
- export declare function reviewLoopPolicySummary(stage: ReviewLoopStage): string;
104
- export declare function reviewLoopSecondOpinionSummary(stage: ReviewLoopStage): string;
105
- export declare const REVIEW_LOOP_CHECKLISTS: {
106
- readonly scope: readonly [{
107
- readonly id: "premise_fit";
108
- readonly label: "Premise fit";
109
- readonly weight: 1;
110
- readonly guidance: "Does the scope contract solve the actual user/problem framing without drifting into adjacent asks?";
111
- }, {
112
- readonly id: "alternatives_coverage";
113
- readonly label: "Alternatives coverage";
114
- readonly weight: 1;
115
- readonly guidance: "Are meaningful alternatives compared with explicit trade-offs and one clear recommendation?";
116
- }, {
117
- readonly id: "error_rescue_registry";
118
- readonly label: "Error and rescue coverage";
119
- readonly weight: 1;
120
- readonly guidance: "Does each scoped capability define failure mode, detection signal, and fallback/rescue behavior?";
121
- }, {
122
- readonly id: "scope_creep_risk";
123
- readonly label: "Scope-creep risk";
124
- readonly weight: 1;
125
- readonly guidance: "Are in/out boundaries explicit and protected against silent expansion/reduction language?";
126
- }, {
127
- readonly id: "completion_status_fidelity";
128
- readonly label: "Completion status fidelity";
129
- readonly weight: 1;
130
- readonly guidance: "Does the completion dashboard honestly report unresolved risks, decision count, and stop reason?";
131
- }];
132
- readonly design: readonly [{
133
- readonly id: "architecture_fit";
134
- readonly label: "Architecture fit";
135
- readonly weight: 1;
136
- readonly guidance: "Do architecture boundaries and diagrams align with scope and real blast-radius code?";
137
- }, {
138
- readonly id: "failure_mode_coverage";
139
- readonly label: "Failure-mode coverage";
140
- readonly weight: 1;
141
- readonly guidance: "Does the failure-mode table capture method/exception/rescue/user-visible impact for critical paths?";
142
- }, {
143
- readonly id: "test_coverage_realism";
144
- readonly label: "Test coverage realism";
145
- readonly weight: 1;
146
- readonly guidance: "Is the proposed test split realistic (unit/integration/e2e) with explicit gap handling?";
147
- }, {
148
- readonly id: "performance_budget";
149
- readonly label: "Performance budget";
150
- readonly weight: 1;
151
- readonly guidance: "Are critical metrics, thresholds, and measurement methods concrete and enforceable?";
152
- }, {
153
- readonly id: "observability_adequacy";
154
- readonly label: "Observability adequacy";
155
- readonly weight: 1;
156
- readonly guidance: "Can on-call trace a failure from user symptom to root cause via logs/metrics/traces/alerts?";
157
- }];
158
- };
159
- export declare function buildOutsideVoiceReviewPrompt(request: ReviewLoopDispatchRequest): string;
160
- export declare function createOutsideVoiceDispatcher(adapter: ReviewLoopDispatchAdapter): ReviewLoopDispatcher;
161
- export declare function parseReviewLoopDispatcherResult(raw: unknown, checklist: readonly ReviewLoopDimension[]): {
162
- findings: ReviewFinding[];
163
- dimensionScores: ReviewLoopDimensionScore[];
164
- };
165
- export declare function mergeSecondOpinionResults(primaryRaw: unknown, secondOpinionRaw: unknown, checklist: readonly ReviewLoopDimension[], policy?: ReviewLoopSecondOpinionPolicy): {
166
- findings: ReviewFinding[];
167
- dimensionScores: ReviewLoopDimensionScore[];
168
- secondOpinion: ReviewLoopSecondOpinionMeta;
169
- };
170
- export declare function createSecondOpinionDispatcher(args: {
171
- primary: ReviewLoopDispatcher;
172
- secondOpinion?: ReviewLoopDispatcher;
173
- policy?: ReviewLoopSecondOpinionPolicy;
174
- }): ReviewLoopDispatcher;
175
- export declare function aggregateQualityScore(scores: readonly ReviewLoopDimensionScore[], checklist: readonly ReviewLoopDimension[]): number;
176
- export declare function runReviewLoopIteration(input: ReviewLoopInput & {
177
- iteration: number;
178
- }, dispatcher: ReviewLoopDispatcher): Promise<ReviewLoopIterationResult>;
179
- export declare function buildReviewLoopEnvelope(args: {
180
- stage: ReviewLoopStage;
181
- artifactPath: string;
182
- targetScore: number;
183
- maxIterations: number;
184
- stopReason: ReviewLoopStopReason;
185
- iterations: ReadonlyArray<ReviewLoopIterationSummary>;
186
- }): ReviewLoopEnvelope;
187
- export declare function renderReviewLoopHeader(envelope: ReviewLoopEnvelope): string;
188
- export declare function upsertReviewLoopHeader(markdown: string, envelope: ReviewLoopEnvelope): string;
189
- export declare function renderReviewLoopSummarySection(envelope: ReviewLoopEnvelope): string;
190
- export declare function upsertReviewLoopSummary(markdown: string, envelope: ReviewLoopEnvelope): string;
191
- export declare function extractReviewLoopEnvelopeFromArtifact(markdown: string, stage: ReviewLoopStage, artifactPath: string): ReviewLoopEnvelope | null;
192
- export declare function toSkillEnvelope(envelope: ReviewLoopEnvelope, emittedAt?: string, agent?: string): SkillEnvelope;
193
- export declare function runReviewLoop(input: ReviewLoopInput, options: RunReviewLoopOptions): Promise<ReviewLoopRunResult>;
194
- export declare function isReviewLoopStage(stage: FlowStage): stage is ReviewLoopStage;
6
+ export declare const FIVE_FAILURE_MODES: FailureMode[];
7
+ export declare const REVIEW_ITERATION_HARD_CAP = 5;
8
+ export declare function failureModesChecklist(): string;