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
@@ -1,782 +1,55 @@
1
- import { conversationLanguagePolicyBullets } from "./language-policy.js";
2
- function yamlScalarString(value) {
3
- // JSON double-quoted strings are valid YAML scalars and escape reliably.
4
- return JSON.stringify(value);
5
- }
6
- function yamlFlowSequence(values) {
7
- return JSON.stringify(values);
8
- }
9
- const WORKER_RETURN_SCHEMA = {
10
- statusField: "status",
11
- allowedStatuses: ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"],
12
- requiredFields: ["status", "filesChanged", "testsRun", "evidenceRefs", "concerns", "needsContext", "blockers"],
13
- evidenceFields: ["testsRun", "evidenceRefs"]
14
- };
15
- const REVIEW_RETURN_SCHEMA = {
16
- statusField: "status",
17
- allowedStatuses: ["PASS", "PASS_WITH_GAPS", "FAIL", "BLOCKED"],
18
- requiredFields: ["status", "findings", "criteria", "evidenceRefs", "blockers"],
19
- evidenceFields: ["findings.location", "criteria.evidence", "evidenceRefs"]
20
- };
21
- const ADVISORY_RETURN_SCHEMA = {
22
- statusField: "status",
23
- allowedStatuses: ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"],
24
- requiredFields: ["status", "summary", "recommendations", "evidenceRefs", "unknowns"],
25
- evidenceFields: ["evidenceRefs", "recommendations"]
26
- };
27
- const CRITIC_ADVISORY_RETURN_SCHEMA = {
28
- ...ADVISORY_RETURN_SCHEMA,
29
- optionalFields: ["predictions", "predictionsValidated", "openQuestions", "realistCheckResults"]
30
- };
31
- const DOC_RETURN_SCHEMA = {
32
- statusField: "status",
33
- allowedStatuses: ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"],
34
- requiredFields: ["status", "filesUpdated", "summary", "evidenceRefs", "openQuestions"],
35
- evidenceFields: ["filesUpdated", "evidenceRefs"]
36
- };
37
- function workerAckContract() {
38
- return `## Worker ACK Contract
39
-
40
- Before doing substantive work, return an ACK object that the parent can record:
41
-
42
- \`\`\`json
43
- {
44
- "status": "ACK",
45
- "spanId": "<parent spanId>",
46
- "dispatchId": "<parent dispatchId or workerRunId>",
47
- "dispatchSurface": "claude-task|cursor-task|opencode-agent|codex-agent|generic-task|role-switch",
48
- "agentDefinitionPath": ".cclaw/agents/<agent>.md or harness generated path",
49
- "ackTs": "<ISO timestamp>"
50
- }
51
- \`\`\`
52
-
53
- Finish with the required return schema plus the same \`spanId\` and \`dispatchId\`. The parent must not claim isolated completion unless ACK/result proof matches the ledger/event span.`;
54
- }
55
- /**
56
- * TDD worker self-record contract. The parent records `scheduled` and
57
- * `launched` rows BEFORE dispatching the Task; the worker records
58
- * `acknowledged` (on entry) and `completed` (on exit).
59
- */
60
- function tddWorkerSelfRecordContract(agentName) {
61
- const isBuilder = agentName === "slice-builder";
62
- const refactorOutcomeFlag = isBuilder
63
- ? " --refactor-outcome=inline|deferred [--refactor-rationale=\"<why>\"]"
64
- : "";
65
- const laneFlags = isBuilder
66
- ? " [--claim-token=<t>] [--lane-id=<lane>] [--lease-until=<iso>]"
67
- : "";
68
- return `## TDD worker delegation self-record contract
69
-
70
- You are a TDD worker dispatched via \`Task\`. The parent already wrote your \`scheduled\` and \`launched\` ledger rows BEFORE invoking you. **Your responsibility is to self-record \`acknowledged\` on entry and \`completed\` on exit** by invoking \`.cclaw/hooks/delegation-record.mjs\` directly. Do NOT skip these — the controller depends on them, the linter validates them, and back-fill via \`--repair\` is reserved for recovery only.
71
-
72
- **On entry — record acknowledgement (BEFORE doing work):**
73
-
74
- \`\`\`bash
75
- ACK_TS="$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ 2>/dev/null || date -u +%Y-%m-%dT%H:%M:%SZ)"
76
- node .cclaw/hooks/delegation-record.mjs \\
77
- --stage=tdd --agent=${agentName} --mode=mandatory \\
78
- --status=acknowledged \\
79
- --span-id=<spanId from controller dispatch> \\
80
- --dispatch-id=<dispatchId from controller dispatch> \\
81
- --dispatch-surface=<surface from controller dispatch> \\
82
- --agent-definition-path=.cclaw/agents/${agentName}.md \\
83
- --ack-ts="$ACK_TS" \\
84
- --json
85
- \`\`\`
86
-
87
- **On exit — record completion (AFTER work + verification):**
88
-
89
- \`\`\`bash
90
- COMPLETED_TS="$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ 2>/dev/null || date -u +%Y-%m-%dT%H:%M:%SZ)"
91
- node .cclaw/hooks/delegation-record.mjs \\
92
- --stage=tdd --agent=${agentName} --mode=mandatory \\
93
- --status=completed \\
94
- --span-id=<same spanId> \\
95
- --completed-ts="$COMPLETED_TS" \\
96
- --evidence-ref="<test-path-or-artifact-ref>"${refactorOutcomeFlag}${laneFlags} \\
97
- --json
98
- \`\`\`
99
-
100
- Reuse the same \`<spanId>\` and \`<dispatchId>\` across both rows. **GREEN evidence freshness** (slice-builder): the FIRST \`--evidence-ref\` MUST (1) reference the same test the matching \`phase=red\` row cited (basename/stem substring; reject \`green_evidence_red_test_mismatch\`), (2) include a recognized passing-runner line such as \`=> N passed; 0 failed\`, \`N passed in 0.42s\`, or \`ok pkg 0.12s\` (reject \`green_evidence_passing_assertion_missing\`), AND (3) be captured AFTER \`ackTs\` of this span — \`completedTs - ackTs\` must be ≥ \`flow-state.json::tddGreenMinElapsedMs\` (default 4000ms; reject \`green_evidence_too_fresh\`). Escape clause for legitimate observational GREEN: pass \`--green-mode=observational\`. \`--ack-ts\` and \`--completed-ts\` must be monotonic on the span (\`startTs ≤ launchedTs ≤ ackTs ≤ completedTs\`); the helper rejects out-of-order writes with \`delegation_timestamp_non_monotonic\`. If the helper rejects with \`dispatch_active_span_collision\` against a stale span, surface the conflicting \`spanId\` to the parent — do NOT silently retry with \`--allow-parallel\`.`;
101
- }
102
- function formatReturnSchema(schema) {
103
- const lines = [
104
- `- Status field: \`${schema.statusField}\``,
105
- `- Allowed statuses: ${schema.allowedStatuses.map((status) => `\`${status}\``).join(", ")}`,
106
- `- Required fields: ${schema.requiredFields.map((field) => `\`${field}\``).join(", ")}`,
107
- `- Evidence fields: ${schema.evidenceFields.map((field) => `\`${field}\``).join(", ")}`
108
- ];
109
- if (schema.optionalFields && schema.optionalFields.length > 0) {
110
- lines.push(`- Optional fields: ${schema.optionalFields.map((field) => `\`${field}\``).join(", ")}`);
111
- }
112
- return lines.join("\n");
113
- }
114
- function formattedAgentsForStages(stages) {
115
- const summary = stageDelegationSummary("standard");
116
- const merged = [];
117
- for (const stage of stages) {
118
- const row = summary.find((item) => item.stage === stage);
119
- if (!row)
120
- continue;
121
- for (const agent of row.primaryAgents) {
122
- if (!merged.includes(agent)) {
123
- merged.push(agent);
124
- }
125
- }
126
- }
127
- return merged.length > 0 ? merged.join(", ") : "none";
128
- }
129
- function activationModeSummary() {
130
- const summary = stageDelegationSummary("standard");
131
- const mandatory = new Set();
132
- const proactive = new Set();
133
- for (const row of summary) {
134
- for (const agent of row.mandatoryAgents) {
135
- mandatory.add(agent);
136
- }
137
- for (const agent of row.proactiveAgents) {
138
- proactive.add(agent);
139
- }
140
- }
141
- return {
142
- mandatory: [...mandatory].join(", "),
143
- proactive: [...proactive].join(", ")
144
- };
145
- }
146
- /**
147
- * Canonical slice-builder worker protocol text (embedded in the agent body and
148
- * echoed in the TDD skill block).
149
- */
150
- export function sliceBuilderProtocol() {
151
- return [
152
- "## slice-builder protocol",
153
- "",
154
- "**slice-builder** is the canonical worker for **one feature-atomic implementation unit/slice** end-to-end: **RED → GREEN → REFACTOR → inline DOC** in **one** delegated span. The unit may contain internal 2-5 minute TDD steps; do not split those into separate agents unless the parent selected `strict-micro`. Multiple slice-builder spans run in parallel only when topology is `parallel-builders` and the wave plan declares disjoint `claimedPaths`.",
155
- "",
156
- "### Invariants",
157
- "- Produce failing RED evidence (or cite the delegated RED artifact) **before** production edits.",
158
- "- Stay inside the slice contract: `claimedPaths`, acceptance mapping, and forbidden-change lists from the parent.",
159
- "- When `tdd.isolationMode=worktree|auto`, run the slice inside the assigned worktree path (never in the shared repo root) so filesystem isolation enforces the claimed-path fence.",
160
- "- When `tdd.commitMode=managed-per-slice`, do **not** hand-edit git state for slice files (no manual `git add/commit` on claimed paths). Let `.cclaw/hooks/slice-commit.mjs` own per-slice commits.",
161
- "- After GREEN, refactor inline **or** record deferred refactor via the same `--refactor-outcome` mechanics the controller specifies.",
162
- "- Own the prose slice summary at `<artifacts-dir>/tdd-slices/S-<id>.md` yourself.",
163
- "",
164
- "### Events",
165
- "- Honor every `delegation-record`/`delegation-record.mjs` row shape the controller requests so artifact linters keep passing.",
166
- "- The umbrella `slice-completed` row ties RED/GREEN/REFACTOR/DOC timestamps to your builder span.",
167
- "",
168
- "### Event → status flag table (7.6.0 — phase-event status validation)",
169
- "",
170
- "Phase-level granularity is only meaningful on terminal outcomes. The dispatch-level ack (no `--phase`) is the controller saying \"I see the dispatch surface back\" — it stays on `--status=acknowledged`. Phase events MUST use `--status=completed` or `--status=failed`. The hook rejects mismatches with `phase_event_requires_completed_or_failed_status` (exit 2) and prints a corrected-command hint.",
171
- "",
172
- "| event | --phase | --status |",
173
- "|---|---|---|",
174
- "| dispatch ack (controller-side) | (none) | `acknowledged` |",
175
- "| RED watched-fail captured | `red` | `completed` |",
176
- "| GREEN test passes | `green` | `completed` (with `--refactor-outcome=inline\\|deferred\\|...`) |",
177
- "| REFACTOR landed | `refactor` | `completed` |",
178
- "| DOC card landed (triggers slice-commit) | `doc` | `completed` |",
179
- "| BLOCKED / unrecoverable | (any phase reached) | `failed` |",
180
- "",
181
- "Common slip: recording every phase event with `--status=acknowledged` (e.g. `--phase=doc --status=acknowledged`). The event row is silently dropped from terminal-phase aggregations, `slice-commit.mjs` never fires (it only triggers on `phase=doc status=completed`), and `wave-status` reports the slice as phantom-open. Recovery requires raw backfill commands. The 7.6.0 hook validator forbids this configuration up front.",
182
- "",
183
- "### Streaming output contract",
184
- "- Emit one JSON line to stdout per completed phase: `{\"event\":\"phase-completed\",\"stage\":\"tdd\",\"sliceId\":\"S-<n>\",\"phase\":\"<red|green|refactor|refactor-deferred|doc>\",\"spanId\":\"<span>\",\"runId\":\"<run>\",\"ts\":\"<iso>\"}`.",
185
- "- For `phase=green` with inline/deferred refactor folding, include `refactorOutcome.mode` in the same JSON line so live controllers can close the slice without waiting for file sync.",
186
- "- If streaming is unavailable in your harness/runtime, keep writing canonical `delegation-record` rows; controller-side live mode will fall back to file-based events.",
187
- "",
188
- "**Role boundary:** do not widen scope, do not self-approve ship-level review, and do not recurse into other agents unless the parent explicitly directs it."
189
- ].join("\n");
190
- }
191
- /**
192
- * Canonical specialist roster materialized under `.cclaw/agents/`.
193
- *
194
- * Declared with `satisfies` so the array retains literal `name` types for
195
- * downstream type-level consumers (e.g. `AgentName`), while still being
196
- * checked against the `AgentDefinition` shape at compile time. Do not add
197
- * an explicit `AgentDefinition[]` annotation here — it would widen `name`
198
- * to `string` and break the compile-time drift guard.
199
- */
200
- export const CCLAW_AGENTS = [
1
+ import { SPECIALIST_PROMPTS } from "./specialist-prompts/index.js";
2
+ export const CORE_AGENTS = [
201
3
  {
202
- name: "researcher",
203
- description: "PROACTIVE when context readiness, repo search, reference patterns, or external docs could change a stage decision. MUST summarize search-before-read evidence before large reads.",
204
- tools: ["Read", "Grep", "Glob", "WebSearch"],
205
- model: "fast",
206
- activation: "proactive",
207
- relatedStages: ["brainstorm", "scope", "design", "plan"],
208
- returnSchema: ADVISORY_RETURN_SCHEMA,
209
- body: [
210
- "You are a **context readiness and research specialist**.",
211
- "",
212
- "When invoked:",
213
- "1. Start with search/query summaries before reading large files.",
214
- "2. Name provider status when known: graph/search/docs/MCP/semantic index freshness.",
215
- "3. Separate observed facts from assumptions and stale or missing context.",
216
- "4. Return concise evidence refs the controller can paste into stage artifacts.",
217
- "",
218
- "**Role boundary:** research and context synthesis only. Do NOT edit files."
219
- ].join("\n")
220
- },
221
- {
222
- name: "planner",
223
- description: "MANDATORY for scope/design/plan and PROACTIVE for high-ambiguity work. MUST BE USED when sequencing, dependency mapping, or risk trade-offs are required before coding.",
224
- tools: ["Read", "Grep", "Glob", "WebSearch"],
225
- model: "deep",
226
- activation: "mandatory",
227
- relatedStages: ["brainstorm", "scope", "design", "spec", "plan"],
228
- returnSchema: ADVISORY_RETURN_SCHEMA,
229
- body: [
230
- "You are an **implementation planning specialist** (staff engineer mindset).",
231
- "",
232
- "When invoked:",
233
- "1. Map upstream decisions, scope boundaries, and explicit drift before planning.",
234
- "2. Break the work into concrete sub-problems with dependencies and existing-module fit.",
235
- "3. Enforce one-question discipline: ask only decision-changing questions, one at a time.",
236
- "4. Produce an ordered execution plan with verification checks and handoff quality notes.",
237
- "5. Highlight risks and unknowns that need user decisions.",
238
- "",
239
- "**Role boundary:** planning only. Do NOT write production code."
240
- ].join("\n")
241
- },
242
- {
243
- name: "product-discovery",
244
- description: "MANDATORY during brainstorm and PROACTIVE during scope when value framing or expansion strategy needs product-level discovery pressure.",
245
- tools: ["Read", "Grep", "Glob", "WebSearch"],
246
- model: "deep",
247
- activation: "mandatory",
248
- relatedStages: ["brainstorm", "scope"],
249
- returnSchema: ADVISORY_RETURN_SCHEMA,
250
- body: [
251
- "You are a **product discovery specialist**.",
252
- "",
253
- "**Mode: discovery** (default)",
254
- "- persona / user and job to be done",
255
- "- pain or trigger",
256
- "- value hypothesis and success metric",
257
- "- evidence or signal strength",
258
- "- why now, do-nothing consequence, and non-goals",
259
- "",
260
- "**Mode: strategist** (trigger when scope mode is SCOPE EXPANSION or SELECTIVE EXPANSION)",
261
- "- 10x vision and ideal outcome versus baseline scope",
262
- "- concrete expansion proposals (not cosmetic variants)",
263
- "- expected upside, reversibility, and trajectory impact",
264
- "- explicit add/defer/skip recommendation per proposal",
265
- "",
266
- "For technical-maintenance work, translate these modes to operator/developer outcomes, failure-mode reduction, verification signal quality, and trajectory impact.",
267
- "",
268
- "**Role boundary:** frame value and trajectory fit. Do NOT choose implementation architecture."
269
- ].join("\n")
270
- },
271
- {
272
- name: "divergent-thinker",
273
- description: "PROACTIVE before planner/critic convergence when brainstorm or scope needs option-space expansion and alternative framings.",
274
- tools: ["Read", "Grep", "Glob", "WebSearch"],
275
- model: "balanced",
276
- activation: "proactive",
277
- relatedStages: ["brainstorm", "scope"],
278
- returnSchema: ADVISORY_RETURN_SCHEMA,
279
- body: [
280
- "You are a **creative divergent-thinker** dispatched BEFORE planner/critic converge on a single path.",
281
- "",
282
- "Your job:",
283
- "1. Generate 3-5 alternative framings of the problem.",
284
- "2. Generate 3-5 alternative approaches per framing where reasonable.",
285
- "3. For each option, include one-line pro/con plus reversibility flag.",
286
- "4. Highlight option-space the user might not have considered.",
287
- "5. Return concise structured output in `recommendations[]` for planner/critic consumption.",
288
- "",
289
- "Role boundary: divergence only.",
290
- "- Do NOT recommend a single approach.",
291
- "- Do NOT validate feasibility (feasibility-reviewer owns that).",
292
- "- Do NOT critique premise validity (critic owns that).",
293
- "",
294
- "You are an explicit amplifier of option-space; convergence happens after you."
295
- ].join("\n")
296
- },
297
- {
298
- name: "critic",
299
- description: "PROACTIVE during brainstorm/scope/design when premises, alternatives, cost, rollback, or hidden assumptions need adversarial pressure.",
300
- tools: ["Read", "Grep", "Glob", "WebSearch"],
301
- model: "balanced",
302
- activation: "proactive",
303
- relatedStages: ["brainstorm", "scope", "design"],
304
- returnSchema: CRITIC_ADVISORY_RETURN_SCHEMA,
305
- body: [
306
- "You are an **adversarial critic** for product and engineering decisions.",
307
- "",
308
- "## Why this matters",
309
- "False approval is expensive: a missed flaw early can cost 10-100x more to unwind after implementation.",
310
- "Anchor every concern in evidence and avoid inventing hypothetical blockers without proof.",
311
- "",
312
- "## Pre-commitment predictions",
313
- "Before deep investigation, list your hypotheses in `predictions[]` (what you expect to find and why).",
314
- "",
315
- "## Multi-perspective angles",
316
- "Pick context-aware angles before analysis:",
317
- "- plan/spec/scope: `executor`, `stakeholder`, `skeptic`",
318
- "- design/code: `security`, `operator`, `new-hire`",
319
- "",
320
- "## Gap analysis",
321
- "Name what is missing (evidence gaps, undefined contracts, absent safeguards), not just what looks wrong.",
322
- "",
323
- "## Self-audit",
324
- "Low-confidence concerns (confidence <=4/10) must move into `openQuestions[]` and should not block stage transition by themselves.",
325
- "",
326
- "## Realist check",
327
- "For each Critical/Major concern, test if it would realistically ship; downgrade or suppress concerns that are not plausible in this context.",
328
- "Record the result in `realistCheckResults[]`.",
329
- "",
330
- "## ADVERSARIAL mode escalation",
331
- "Escalate to ADVERSARIAL mode when reviewers disagree, your confidence is low, or trust/security boundaries are involved.",
332
- "",
333
- "Return validated risks, disproven predictions in `predictionsValidated[]`, and the smallest decision-changing recommendation."
334
- ].join("\n")
335
- },
336
- {
337
- name: "architect",
338
- description: "MANDATORY during design and final ship verification. MUST BE USED to validate architecture boundaries, alternatives, failure modes, rollout, and cross-stage cohesion before release.",
339
- tools: ["Read", "Grep", "Glob", "WebSearch"],
340
- model: "deep",
341
- activation: "mandatory",
342
- relatedStages: ["design", "ship"],
343
- returnSchema: ADVISORY_RETURN_SCHEMA,
344
- body: [
345
- "You are an **architecture validation specialist**.",
346
- "",
347
- "Check architecture boundaries, existing-system fit, critical paths, data/state flow, alternatives, rescue paths, and verification hooks.",
348
- "Return chosen path risks, rejected alternatives, switch triggers, and required evidence before spec handoff.",
349
- "At ship, perform cross-stage verification across scope/design/spec/plan/review/code and flag DRIFT_DETECTED when shipped behavior diverges from locked decisions.",
350
- "",
351
- "**Role boundary:** design validation only. Do NOT write implementation code."
352
- ].join("\n")
353
- },
354
- {
355
- name: "spec-validator",
356
- description: "MANDATORY during standard/deep spec. MUST BE USED to validate measurable acceptance criteria, assumptions, edge cases, and testability mapping.",
357
- tools: ["Read", "Grep", "Glob"],
358
- model: "balanced",
359
- activation: "mandatory",
360
- relatedStages: ["spec"],
361
- returnSchema: REVIEW_RETURN_SCHEMA,
362
- body: [
363
- "You are a **specification validation specialist**.",
364
- "",
365
- "For every acceptance criterion, verify it is observable, measurable, falsifiable, mapped to upstream decisions, and paired with concrete verification evidence.",
366
- "Flag vague language, missing edge cases, hidden assumptions, and RED tests that cannot be expressed.",
367
- "",
368
- "**Role boundary:** validate the spec; do NOT write plan tasks or implementation."
369
- ].join("\n")
370
- },
371
- {
372
- name: "spec-document-reviewer",
373
- description: "PROACTIVE during spec when self-review surfaces issues, subsystem boundaries feel broad, or the artifact needs a final plan-readiness pass.",
374
- tools: ["Read", "Grep", "Glob"],
375
- model: "balanced",
376
- activation: "proactive",
377
- relatedStages: ["spec"],
378
- returnSchema: REVIEW_RETURN_SCHEMA,
379
- body: [
380
- "You are a **spec document reviewer** focused on plan-readiness.",
381
- "",
382
- "Run a concise pass over:",
383
- "- completeness of required spec sections",
384
- "- consistency across acceptance criteria, assumptions, and mapping",
385
- "- clarity / ambiguity / placeholder drift",
386
- "- single-subsystem scope fit and YAGNI pressure",
387
- "",
388
- "Return `PASS`, `PASS_WITH_GAPS`, `FAIL`, or `BLOCKED` with concrete evidence refs and minimal corrective actions.",
389
- "",
390
- "**Role boundary:** review the spec artifact only; do NOT write plan tasks or implementation."
391
- ].join("\n")
392
- },
393
- {
394
- name: "coherence-reviewer",
395
- description: "PROACTIVE during spec/plan/design when internal consistency must be validated across sections, terminology, references, and dependency narratives.",
396
- tools: ["Read", "Grep", "Glob"],
397
- model: "balanced",
398
- activation: "proactive",
399
- relatedStages: ["spec", "plan", "design"],
400
- returnSchema: REVIEW_RETURN_SCHEMA,
401
- body: [
402
- "You are a **document coherence reviewer** focused on consistency, not quality scoring.",
403
- "",
404
- "Check for:",
405
- "- contradictions between sections",
406
- "- terminology drift (same concept named differently)",
407
- "- broken internal references and forward-reference mismatches",
408
- "- dependency/storyline conflicts between architecture, scope, and execution notes",
409
- "",
410
- "Return `PASS`, `PASS_WITH_GAPS`, `FAIL`, or `BLOCKED` with calibrated, evidence-anchored findings.",
411
- "",
412
- "**Role boundary:** consistency checks only. Do NOT rewrite the document or propose architecture alternatives."
413
- ].join("\n")
414
- },
415
- {
416
- name: "scope-guardian-reviewer",
417
- description: "PROACTIVE during scope/plan/design when complexity growth, scope drift, or unnecessary abstraction risk needs a dedicated challenge pass.",
418
- tools: ["Read", "Grep", "Glob"],
419
- model: "balanced",
420
- activation: "proactive",
421
- relatedStages: ["scope", "plan", "design"],
422
- returnSchema: REVIEW_RETURN_SCHEMA,
423
- body: [
424
- "You are a **scope guard reviewer** focused on minimum viable change and complexity discipline.",
425
- "",
426
- "Check for:",
427
- "- whether the document reuses existing solutions before adding abstractions",
428
- "- scope-goal alignment and minimum useful slice",
429
- "- complexity smell tests (generic utilities, framework-ahead-of-need patterns, speculative layers)",
430
- "- dependency ordering that can accidentally widen scope",
431
- "",
432
- "Return `PASS`, `PASS_WITH_GAPS`, `FAIL`, or `BLOCKED` with concrete evidence refs and smallest corrective action.",
433
- "",
434
- "**Role boundary:** challenge over-scope and unnecessary complexity; do NOT replace planner/architect ownership."
435
- ].join("\n")
436
- },
437
- {
438
- name: "feasibility-reviewer",
439
- description: "PROACTIVE during plan/design when resource, runtime, environment, dependency, or rollout assumptions can make the solution non-viable.",
440
- tools: ["Read", "Grep", "Glob"],
441
- model: "balanced",
442
- activation: "proactive",
443
- relatedStages: ["plan", "design"],
444
- returnSchema: REVIEW_RETURN_SCHEMA,
445
- body: [
446
- "You are a **feasibility reviewer** focused on execution realism.",
447
- "",
448
- "Check for:",
449
- "- resource/time assumptions versus current constraints",
450
- "- runtime and environment assumptions (infrastructure, limits, deployment shape)",
451
- "- availability/reliability assumptions for external dependencies",
452
- "- rollout and operational risk under real-world conditions",
453
- "",
454
- "Return `PASS`, `PASS_WITH_GAPS`, `FAIL`, or `BLOCKED` with evidence and explicit risk-to-ship mapping.",
455
- "",
456
- "**Role boundary:** feasibility realism only; do NOT redesign architecture unless feasibility is blocked."
457
- ].join("\n")
458
- },
459
- {
460
- name: "reviewer",
461
- description: "MANDATORY during review. MUST BE USED to run a two-pass audit with explicit inline lens coverage for performance, compatibility, and observability.",
462
- tools: ["Read", "Grep", "Glob"],
463
- model: "balanced",
464
- activation: "mandatory",
465
- relatedStages: ["spec", "review", "ship"],
466
- returnSchema: REVIEW_RETURN_SCHEMA,
467
- body: [
468
- "You are a **combined spec + code reviewer**.",
469
- "",
470
- "Run two explicit passes:",
471
- "",
472
- "1. **Spec pass**",
473
- " - For each acceptance criterion: PASS / PARTIAL / FAIL.",
474
- " - Cite evidence as `file:line`.",
475
- "",
476
- "2. **Code-quality pass**",
477
- " - Correctness: logic, boundaries, state transitions.",
478
- " - Maintainability: naming, structure, complexity, debt risks.",
479
- " - Performance: avoid obvious hot-path regressions.",
480
- " - Architecture fit: layering and contract stability.",
481
- "",
482
- "## Lens Coverage",
483
- "Performance: NO_IMPACT / FOUND_<n>",
484
- "Compatibility: NO_IMPACT / FOUND_<n>",
485
- "Observability: NO_IMPACT / FOUND_<n>",
486
- "Security: routed to security-reviewer (always separate)",
487
- "",
488
- "### Companion lens skills (load on-demand, never all-at-once)",
489
- "- **review-perf-lens** — load when reviewing code touching hot paths, loops over large data, network/disk I/O, render hot paths, or sub-100ms latency budgets.",
490
- "- **review-compat-lens** — load when reviewing code that runs on multiple OS/runtime/browser targets, modifies shared library APIs, or changes serialized payload shapes.",
491
- "- **review-observability-lens** — load when reviewing code that adds/removes logging, metrics, traces, error reporting, or audit/compliance signals.",
492
- "If none of those triggers apply, do NOT load the lens skills — they are deep-dive context, not default reading.",
493
- "",
494
- "For each finding include:",
495
- "- Severity: `Critical` | `Important` | `Suggestion`",
496
- "- Location: `file:line`; if no line is possible, state the no-line reason",
497
- "- Problem and concrete recommendation",
498
- "",
499
- "Also report files inspected, changed-file coverage, diagnostics run, dependency/version audit when relevant, and a no-finding attestation when no issues are found.",
500
- "",
501
- "**Trust model:** never rely on implementer claims; verify by reading code."
502
- ].join("\n")
503
- },
504
- {
505
- name: "security-reviewer",
506
- description: "MANDATORY during review; PROACTIVE during design/ship for trust-boundary changes. Always produce an explicit no-change attestation when no security-relevant surface moved.",
507
- tools: ["Read", "Grep", "Glob"],
508
- model: "balanced",
509
- activation: "mandatory",
510
- relatedStages: ["design", "review", "ship"],
511
- returnSchema: REVIEW_RETURN_SCHEMA,
512
- body: [
513
- "You are a **security vulnerability specialist** focused on exploitability.",
514
- "",
515
- "Check for (non-exhaustive):",
516
- "- validation gaps and injection vectors",
517
- "- authz/authn boundary violations",
518
- "- secret leakage in code/logging",
519
- "- unsafe file/system/network operations",
520
- "- privilege escalation and trust-boundary misuse",
521
- "",
522
- "For each finding include:",
523
- "- severity aligned to ship risk",
524
- "- CWE ID when possible (or UNKNOWN)",
525
- "- short proof-of-concept vector",
526
- "- concrete control-oriented fix",
527
- "- `NO_CHANGE_ATTESTATION` or `NO_SECURITY_IMPACT` with inspected surfaces when no security finding exists"
528
- ].join("\n")
4
+ id: "brainstormer",
5
+ title: "Brainstormer",
6
+ activation: "on-demand",
7
+ modes: ["frame", "scope", "alternatives"],
8
+ description: "Frame what/why and scope. Optional alternatives sweep when the request is ambiguous.",
9
+ prompt: SPECIALIST_PROMPTS.brainstormer
529
10
  },
530
11
  {
531
- name: "integration-overseer",
532
- description: "ON-DEMAND after TDD fan-out to verify cross-slice cohesion contract integrity, integration surfaces, and shared invariants before review handoff.",
533
- tools: ["Read", "Grep", "Glob"],
534
- model: "balanced",
12
+ id: "architect",
13
+ title: "Architect",
535
14
  activation: "on-demand",
536
- relatedStages: ["tdd", "review"],
537
- returnSchema: REVIEW_RETURN_SCHEMA,
538
- body: [
539
- "You are an **integration overseer** for TDD fan-out runs.",
540
- "",
541
- "You are dispatched after parallel `slice-builder` lanes complete.",
542
- "",
543
- "Checks:",
544
- "- every integration test named in `cohesion-contract.md` passes (or has explicit gap rationale)",
545
- "- naming conventions remain consistent across slices",
546
- "- shared invariants stay true after fan-in",
547
- "- boundary types at touchpoints match the contract",
548
- "- integration between slices is executable and regression-safe",
549
- "",
550
- "Return `PASS`, `PASS_WITH_GAPS`, `FAIL`, or `BLOCKED` with evidence refs and explicit integration risks.",
551
- "",
552
- "**Role boundary:** integration and cohesion oversight only; do NOT implement production code."
553
- ].join("\n")
15
+ modes: ["architecture", "feasibility"],
16
+ description: "Architectural decisions plus feasibility against the current codebase.",
17
+ prompt: SPECIALIST_PROMPTS.architect
554
18
  },
555
19
  {
556
- name: "release-reviewer",
557
- description: "MANDATORY during ship. MUST BE USED for release readiness, rollback, finalization mode, evidence freshness, and victory detector checks.",
558
- tools: ["Read", "Grep", "Glob", "Bash"],
559
- model: "balanced",
560
- activation: "mandatory",
561
- relatedStages: ["ship"],
562
- returnSchema: REVIEW_RETURN_SCHEMA,
563
- body: [
564
- "You are a **release readiness reviewer**.",
565
- "",
566
- "Verify preflight evidence, review verdict freshness, rollback trigger and steps, finalization enum, no-VCS handoff when applicable, learnings capture, and handoff completeness.",
567
- "Block ship on stale evidence, unresolved criticals, missing rollback, or ambiguous finalization."
568
- ].join("\n")
20
+ id: "planner",
21
+ title: "Planner",
22
+ activation: "on-demand",
23
+ modes: ["research", "work-breakdown", "topology"],
24
+ description: "Targeted research, work breakdown into AC, execution topology recommendation.",
25
+ prompt: SPECIALIST_PROMPTS.planner
569
26
  },
570
27
  {
571
- name: "doc-updater",
572
- description: "MANDATORY only at ship; PROACTIVE during tdd/review whenever behavior, config, or public API changes. Keep docs and runbooks in lockstep with shipped behavior.",
573
- tools: ["Read", "Write", "Edit", "Grep", "Glob"],
574
- model: "fast",
575
- activation: "mandatory",
576
- relatedStages: ["tdd", "ship"],
577
- returnSchema: DOC_RETURN_SCHEMA,
578
- body: [
579
- "You are a **documentation maintenance specialist**.",
580
- "",
581
- "After code changes, verify and update only stale sections in:",
582
- "- README / setup / usage",
583
- "- API docs and examples",
584
- "- migration, rollout, rollback, and operational notes",
585
- "- public-surface change notes tied to actual changed files",
586
- "",
587
- "Preserve existing tone and structure; avoid rewrites for style alone."
588
- ].join("\n")
28
+ id: "reviewer",
29
+ title: "Reviewer",
30
+ activation: "on-demand",
31
+ modes: ["code", "text-review", "integration", "release", "adversarial"],
32
+ description: "Multi-mode reviewer covering code, plan/spec text, integration, release readiness, and adversarial sweeps.",
33
+ prompt: SPECIALIST_PROMPTS.reviewer
589
34
  },
590
35
  {
591
- name: "slice-builder",
592
- description: "MANDATORY for delegated TDD slices. Owns RED → GREEN → REFACTOR → per-slice DOC for one feature-atomic implementation unit/slice in a single delegated span. Multiple slice-builder spans run in parallel only under `parallel-builders` topology with disjoint `claimedPaths`; `strict-micro` keeps tiny tasks separate.",
593
- tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash"],
594
- model: "balanced",
595
- activation: "mandatory",
596
- relatedStages: ["tdd"],
597
- returnSchema: WORKER_RETURN_SCHEMA,
598
- body: [
599
- "You are **slice-builder**, the canonical vertical-slice TDD worker.",
600
- "",
601
- sliceBuilderProtocol(),
602
- "",
603
- "**Mode hints:**",
604
- "- **TDD-bound (default)** — RED evidence precedes GREEN; preserve behavior across REFACTOR; document outcomes in `tdd-slices/S-<id>.md`.",
605
- "- **Generic** — only when the parent explicitly disables TDD gates for quick-track breadth; bounded scope and verification still apply.",
606
- "",
607
- "**Role boundary:** obey the parent's phase flags (`--phase=red|green|refactor|doc`); never improvise undeclared parallelism."
608
- ].join("\n")
36
+ id: "security-reviewer",
37
+ title: "Security reviewer",
38
+ activation: "on-demand",
39
+ modes: ["threat-model", "sensitive-change"],
40
+ description: "Threat-model + focused review of sensitive changes. Sets security_flag for compound learnings.",
41
+ prompt: SPECIALIST_PROMPTS["security-reviewer"]
609
42
  },
610
43
  {
611
- name: "fixer",
612
- description: "ON-DEMAND fresh worker after review FAIL/PARTIAL evidence. Must fix only the cited criterion within explicit allowed files.",
613
- tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash"],
614
- model: "balanced",
44
+ id: "slice-builder",
45
+ title: "Slice builder",
615
46
  activation: "on-demand",
616
- relatedStages: ["review", "tdd"],
617
- returnSchema: WORKER_RETURN_SCHEMA,
618
- body: [
619
- "You are a **fresh fixer worker** dispatched after a review found a concrete gap.",
620
- "",
621
- "Rules:",
622
- "1. Start from the failing criterion and reviewer evidence, not from implementer claims.",
623
- "2. Stay inside the allowed files and forbidden-change constraints.",
624
- "3. Apply the smallest fix and rerun the relevant verification.",
625
- "4. Return the strict fixer JSON schema before prose.",
626
- "",
627
- "**Role boundary:** fix only the cited gap; do not redesign the slice."
628
- ].join("\n")
47
+ modes: ["build", "fix-only"],
48
+ description: "Implements AC slices and post-review scoped fixes. Always commits per AC via commit-helper.",
49
+ prompt: SPECIALIST_PROMPTS["slice-builder"]
629
50
  }
630
51
  ];
631
- /**
632
- * Agents whose rendered `.cclaw/agents/<name>.md` file gets the TDD worker
633
- * self-record helper template. Controllers dispatch these via `Task` during
634
- * TDD; they own `acknowledged` and `completed` ledger writes.
635
- */
636
- const TDD_WORKER_SELF_RECORD_AGENTS = new Set([
637
- "slice-builder",
638
- "integration-overseer"
639
- ]);
640
- import { stageDelegationSummary } from "./stage-schema.js";
641
- /**
642
- * Render a complete cclaw agent markdown file (YAML frontmatter + body).
643
- */
644
- function defaultTaskDelegationSection(agentName) {
645
- return `
646
-
647
- ## Task Tool Delegation
648
-
649
- Use native Task/subagent delegation only when this agent's role requires isolated context or strict lifecycle evidence. Keep the delegation prompt self-contained and bounded to this agent's role.
650
-
651
- ${agentName === "reviewer"
652
- ? "- For large/high-risk diffs, load optional deep lens skills (`review-perf-lens`, `review-compat-lens`, `review-observability-lens`) before final verdict."
653
- : "_No extra agent-specific delegation template is required._"}
654
- `;
655
- }
656
- export function agentMarkdown(agent) {
657
- const frontmatter = [
658
- "---",
659
- `name: ${agent.name}`,
660
- `description: ${yamlScalarString(agent.description)}`,
661
- `tools: ${yamlFlowSequence(agent.tools)}`,
662
- `model: ${agent.model}`,
663
- "---"
664
- ].join("\n");
665
- const relatedStages = agent.relatedStages.length > 0 ? agent.relatedStages.join(", ") : "(none)";
666
- const taskDelegation = defaultTaskDelegationSection(agent.name);
667
- const tddWorkerSelfRecordSection = TDD_WORKER_SELF_RECORD_AGENTS.has(agent.name)
668
- ? `\n${tddWorkerSelfRecordContract(agent.name)}\n`
669
- : "";
670
- return `${frontmatter}
671
-
672
- # ${agent.name}
673
-
674
- ${agent.body}
675
-
676
- ## Activation
677
-
678
- - Mode: ${agent.activation}
679
- - Related stages: ${relatedStages}
680
-
681
- ${workerAckContract()}
682
- ${tddWorkerSelfRecordSection}
683
- ## Required Return Schema
684
-
685
- STRICT_RETURN_SCHEMA: return a structured object matching this contract before any narrative when delegated. Include \`spanId\`, \`dispatchId\` or \`workerRunId\`, \`dispatchSurface\`, \`agentDefinitionPath\`, and lifecycle timestamps when provided by the parent.
686
-
687
- ${formatReturnSchema(agent.returnSchema)}
688
-
689
- ## Rules
690
-
691
- ## Conversation Language Policy
692
-
693
- ${conversationLanguagePolicyBullets()}
694
- - Cite file:line for every finding
695
- - Do not make changes outside your specialist domain
696
- - Report findings with severity classification
697
- - If uncertain, say "UNKNOWN" - never guess
698
-
699
- ${taskDelegation}
700
- `;
701
- }
702
- /**
703
- * Markdown table mapping cclaw stage entry points to specialist agents.
704
- */
705
- export function agentRoutingTable() {
706
- const brainstormPrimary = formattedAgentsForStages(["brainstorm"]);
707
- const scopeDesignPlanPrimary = formattedAgentsForStages(["scope", "design", "plan"]);
708
- const specPrimary = formattedAgentsForStages(["spec"]);
709
- const tddPrimary = formattedAgentsForStages(["tdd"]);
710
- const reviewPrimary = formattedAgentsForStages(["review"]);
711
- const shipPrimary = formattedAgentsForStages(["ship"]);
712
- return `| Stage Entry | Primary Agent(s) | Supporting guidance |
713
- |---|---|---|
714
- | Brainstorm (start with \`/cc <idea>\`) | ${brainstormPrimary} | Run in-thread research playbooks: \`research/repo-scan.md\`, \`research/learnings-lookup.md\` |
715
- | Scope / Design / Plan (via \`/cc\`) | ${scopeDesignPlanPrimary} | Use \`research/git-history.md\` (scope) and \`research/framework-docs-lookup.md\` + \`research/best-practices-lookup.md\` (design) as needed |
716
- | Spec (via \`/cc\`) | ${specPrimary} | planner (if ambiguity or conflicts remain) |
717
- | TDD (via \`/cc\`) | ${tddPrimary} | doc-updater on public behavior/config changes |
718
- | Review (via \`/cc\`) | ${reviewPrimary} | conditional second reviewer for high blast-radius diffs |
719
- | Ship (via \`/cc\`) | ${shipPrimary} | security-reviewer when release risk is elevated |
720
- `;
721
- }
722
- /**
723
- * Cost tier routing for the specialist agent roster.
724
- */
725
- export function agentCostTierTable() {
726
- return `| Tier | Use for | Example agents |
727
- |---|---|---|
728
- | \`deep\` | one heavy planning/strategy pass per stage | planner, product-discovery |
729
- | \`balanced\` | discovery, criticism, review, TDD, and bounded worker execution | critic, spec-document-reviewer, coherence-reviewer, scope-guardian-reviewer, feasibility-reviewer, reviewer, security-reviewer, slice-builder, fixer |
730
- | \`fast\` | bounded maintenance updates with limited blast radius | doc-updater |
731
- `;
732
- }
733
- export function agentRegistryMatrix() {
734
- const rows = CCLAW_AGENTS.map((agent) => {
735
- const stages = agent.relatedStages.length > 0 ? agent.relatedStages.join(", ") : "none";
736
- return `| ${agent.name} | ${agent.activation} | ${agent.model} | ${stages} | ${agent.returnSchema.allowedStatuses.join(" / ")} |`;
737
- }).join("\n");
738
- return `| Agent | Activation | Model | Related stages | Terminal statuses |
739
- |---|---|---|---|---|
740
- ${rows}`;
741
- }
742
- /**
743
- * AGENTS.md-ready section describing cclaw’s specialist delegation model.
744
- */
745
- export function agentsAgentsMdBlock() {
746
- return `### Agent Specialists
747
-
748
- cclaw defines specialist personas for \`.cclaw/agents/\`: ${CCLAW_AGENTS.map((agent) => agent.name).join(", ")}.
749
- **TDD work** is owned end-to-end by **slice-builder** — one worker per slice, multiple workers in parallel within a wave when \`claimedPaths\` are disjoint.
750
-
751
- ${agentRoutingTable()}
752
-
753
- ### Agent Registry Matrix
754
-
755
- ${agentRegistryMatrix()}
756
-
757
- ### Research Playbooks (in-thread)
758
-
759
- Research work is no longer modeled as standalone personas. Use in-thread playbooks under \`.cclaw/skills/research/\`:
760
-
761
- - \`repo-scan.md\`
762
- - \`learnings-lookup.md\`
763
- - \`framework-docs-lookup.md\`
764
- - \`best-practices-lookup.md\`
765
- - \`git-history.md\`
766
-
767
- ### Activation modes
768
-
769
- ${(() => {
770
- const mode = activationModeSummary();
771
- return `- **Mandatory:** ${mode.mandatory}.
772
- - **Proactive:** ${mode.proactive}.
773
- - **On-demand:** fixer. Research playbooks are in-thread procedures.`;
774
- })()}
775
-
776
- ### Cost-aware routing
777
-
778
- ${agentCostTierTable()}
779
-
780
- **Agent files:** \`.cclaw/agents/{name}.md\` — each contains YAML frontmatter with tools and model tier.
781
- `;
52
+ export function renderAgentMarkdown(agent) {
53
+ const modes = agent.modes.map((mode) => `- ${mode}`).join("\n");
54
+ return `---\nname: ${agent.id}\ntitle: ${agent.title}\nactivation: ${agent.activation}\n---\n\n# ${agent.title}\n\n${agent.description}\n\n## Modes\n\n${modes}\n\n## Prompt\n\n${agent.prompt}\n`;
782
55
  }