cclaw-cli 0.51.24 → 0.51.26

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 (45) hide show
  1. package/README.md +135 -414
  2. package/dist/artifact-linter.js +10 -6
  3. package/dist/config.d.ts +1 -1
  4. package/dist/config.js +28 -3
  5. package/dist/content/core-agents.d.ts +110 -0
  6. package/dist/content/core-agents.js +255 -3
  7. package/dist/content/examples.js +8 -5
  8. package/dist/content/harness-doc.d.ts +1 -0
  9. package/dist/content/harness-doc.js +3 -0
  10. package/dist/content/hooks.d.ts +1 -0
  11. package/dist/content/hooks.js +189 -0
  12. package/dist/content/next-command.js +10 -6
  13. package/dist/content/reference-patterns.d.ts +18 -0
  14. package/dist/content/reference-patterns.js +391 -0
  15. package/dist/content/skills.js +42 -36
  16. package/dist/content/stage-common-guidance.js +19 -3
  17. package/dist/content/stage-schema.d.ts +12 -0
  18. package/dist/content/stage-schema.js +184 -28
  19. package/dist/content/stages/_lint-metadata/index.js +3 -2
  20. package/dist/content/stages/brainstorm.js +7 -3
  21. package/dist/content/stages/design.js +12 -3
  22. package/dist/content/stages/review.js +7 -5
  23. package/dist/content/stages/schema-types.d.ts +9 -2
  24. package/dist/content/stages/scope.js +8 -2
  25. package/dist/content/stages/ship.js +3 -2
  26. package/dist/content/stages/tdd.js +18 -13
  27. package/dist/content/start-command.js +3 -2
  28. package/dist/content/status-command.js +17 -6
  29. package/dist/content/subagents.js +286 -40
  30. package/dist/content/templates.js +64 -3
  31. package/dist/content/tree-command.js +7 -1
  32. package/dist/delegation.d.ts +34 -1
  33. package/dist/delegation.js +168 -8
  34. package/dist/doctor-registry.js +9 -0
  35. package/dist/doctor.js +121 -6
  36. package/dist/gate-evidence.js +25 -2
  37. package/dist/harness-adapters.d.ts +6 -0
  38. package/dist/harness-adapters.js +28 -4
  39. package/dist/install.js +5 -10
  40. package/dist/internal/advance-stage.js +179 -26
  41. package/dist/run-persistence.js +21 -3
  42. package/dist/tdd-verification-evidence.d.ts +17 -0
  43. package/dist/tdd-verification-evidence.js +43 -0
  44. package/dist/types.d.ts +10 -0
  45. package/package.json +1 -1
@@ -6,14 +6,25 @@ import { conversationLanguagePolicyMarkdown } from "./language-policy.js";
6
6
  * execute orchestration logic at install time beyond string assembly.
7
7
  */
8
8
  const SUBAGENT_AGENT_NAMES = [
9
+ "researcher",
10
+ "architect",
11
+ "spec-validator",
12
+ "slice-implementer",
13
+ "performance-reviewer",
14
+ "compatibility-reviewer",
15
+ "observability-reviewer",
16
+ "release-reviewer",
9
17
  "planner",
10
18
  "product-manager",
11
19
  "critic",
12
20
  "reviewer",
13
21
  "security-reviewer",
14
22
  "test-author",
15
- "doc-updater"
23
+ "doc-updater",
24
+ "implementer",
25
+ "fixer"
16
26
  ];
27
+ const MARKDOWN_CODE_FENCE = "```";
17
28
  function formatAgentList(agents) {
18
29
  return agents.length > 0 ? agents.join(", ") : "none";
19
30
  }
@@ -28,7 +39,7 @@ ${rows}`;
28
39
  }
29
40
  function stageSummary(stage) {
30
41
  return stageDelegationSummary("standard").find((row) => row.stage === stage)
31
- ?? { stage, mandatoryAgents: [], proactiveAgents: [], primaryAgents: [], stackAwareRoutes: [] };
42
+ ?? { stage, mandatoryAgents: [], proactiveAgents: [], primaryAgents: [], dispatchRules: [], stackAwareRoutes: [] };
32
43
  }
33
44
  export function subagentDrivenDevSkill() {
34
45
  return `---
@@ -40,11 +51,11 @@ description: "Orchestrate implementation via isolated subagents — one fresh ag
40
51
 
41
52
  ## Overview
42
53
 
43
- Use a **controller implementer reviewer** loop when building multi-step software work.
54
+ Use a **controller -> coder -> overseer** loop when building multi-step software work.
44
55
 
45
56
  - **Controller (parent agent):** owns the plan, gating, sequencing, and dispatch decisions; never mixes deep implementation context with review evidence.
46
- - **Implementer (subagent):** receives a **single self-contained task** and edits code within that scope; exits with a structured status contract.
47
- - **Reviewer (subagent):** validates outputs against the specification **by reading code**, then hands findings back to the controller for the next dispatch.
57
+ - **Coder / slice-implementer (subagent):** receives a **single self-contained task** and edits code only within that scope; exits with a structured status contract.
58
+ - **Overseer / reviewer (subagent):** validates outputs against the specification **by reading code** and never edits during the overseer pass.
48
59
 
49
60
  This pattern is intentionally **Superpowers-style**: cheap parallelism where it doesn’t corrupt state, strict serialization where it would.
50
61
 
@@ -164,6 +175,10 @@ Borrow the good part of Team/Ruflo-style orchestration without adding a swarm ru
164
175
  - **Checkpoint before synthesis.** Each agent returns status, files inspected/changed, evidence, and blockers before the parent acts.
165
176
  - **Consensus is for hard calls only.** Use two reviewers when severity or architecture is disputed; otherwise one evidence-backed reviewer is enough.
166
177
 
178
+ ## Parallelization Decision Gate
179
+
180
+ Before parallel dispatch, answer yes to all gates: tasks are independent, write sets do not overlap, outputs can be reconciled by evidence, and failure in one lane will not invalidate hidden assumptions in another. If any answer is no, serialize. Coder/overseer work is contract-first: the coder implements only the pasted contract, the overseer reads code and verifies acceptance evidence before the controller marks work complete.
181
+
167
182
  ## When to Use
168
183
 
169
184
  - Mid/large plans with multiple discrete tasks, dependencies, or risky overlap.
@@ -198,9 +213,43 @@ Borrow the good part of Team/Ruflo-style orchestration without adding a swarm ru
198
213
  | NEEDS_CONTEXT | Missing authoritative information only the parent/user can supply | Parent gathers context, then re-dispatch implementer with augmented prompt |
199
214
  | BLOCKED | Hard stop (permissions, tool failure, conflicting requirements, unsafe state) | Parent escalates to user; do not stack speculative guesses |
200
215
 
216
+ ## Strict Worker Return Schemas
217
+
218
+ Every delegated worker must return one terminal status and the listed evidence fields. Prefer JSON fenced as \`json\`; prose may follow only after the object.
219
+
220
+ ### Implementer / fixer return
221
+
222
+ ${MARKDOWN_CODE_FENCE}json
223
+ {
224
+ "status": "DONE|DONE_WITH_CONCERNS|NEEDS_CONTEXT|BLOCKED",
225
+ "filesChanged": ["path"],
226
+ "testsRun": [{ "command": "string", "result": "PASS|FAIL|NOT_RUN", "evidence": "short excerpt or reason" }],
227
+ "evidenceRefs": [".cclaw/artifacts/<file>#anchor"],
228
+ "concerns": ["string"],
229
+ "needsContext": ["string"],
230
+ "blockers": ["string"]
231
+ }
232
+ ${MARKDOWN_CODE_FENCE}
233
+
234
+ ### Reviewer return
235
+
236
+ ${MARKDOWN_CODE_FENCE}json
237
+ {
238
+ "status": "PASS|PASS_WITH_GAPS|FAIL|BLOCKED",
239
+ "findings": [{ "severity": "Critical|Important|Suggestion", "location": "file:line", "problem": "string", "recommendation": "string" }],
240
+ "criteria": [{ "id": "string", "verdict": "PASS|PARTIAL|FAIL", "evidence": "file:line" }],
241
+ "evidenceRefs": [".cclaw/artifacts/<file>#anchor"],
242
+ "blockers": ["string"]
243
+ }
244
+ ${MARKDOWN_CODE_FENCE}
245
+
246
+ ### Lifecycle evidence
247
+
248
+ Before dispatch, create or reserve a delegation span (\`status: "scheduled"\`, \`spanId\`, \`startTs\`, optional \`taskId\`). On return, append a terminal row for the same \`spanId\` with \`endTs\`, \`status\`, \`fulfillmentMode\`, and non-empty \`evidenceRefs\` whenever the worker was generic-dispatch or role-switch. A scheduled span without a terminal row in the current run is stale and must be resolved before claiming the stage is complete.
249
+
201
250
  ## Implementer Prompt Template (paste into Task tool)
202
251
 
203
- \`\`\`
252
+ ${MARKDOWN_CODE_FENCE}
204
253
  You are implementing a single task from a development plan.
205
254
 
206
255
  TASK: {paste full task text here}
@@ -209,15 +258,15 @@ CONSTRAINTS: {paste from spec — what NOT to do}
209
258
 
210
259
  After implementation:
211
260
  0. Write user-facing narrative in the parent/user language; keep status tokens unchanged.
212
- 1. Run the full test suite
213
- 2. Report your status: DONE / DONE_WITH_CONCERNS / NEEDS_CONTEXT / BLOCKED
214
- 3. If DONE_WITH_CONCERNS, list each concern
215
- 4. If NEEDS_CONTEXT, specify exactly what you need
216
- \`\`\`
261
+ 1. Run the relevant test suite or explain why it was not run.
262
+ 2. Return the strict implementer/fixer JSON schema first.
263
+ 3. If DONE_WITH_CONCERNS, list each concern in \`concerns\`.
264
+ 4. If NEEDS_CONTEXT, specify exactly what you need in \`needsContext\`.
265
+ ${MARKDOWN_CODE_FENCE}
217
266
 
218
267
  ## Spec-Reviewer Prompt Template (paste into Task tool)
219
268
 
220
- \`\`\`
269
+ ${MARKDOWN_CODE_FENCE}
221
270
  Review the implementation against the specification.
222
271
 
223
272
  SPEC CRITERIA: {paste acceptance criteria}
@@ -225,7 +274,7 @@ FILES CHANGED: {list files}
225
274
 
226
275
  For each criterion: PASS / FAIL / PARTIAL with evidence (file:line).
227
276
  Do NOT trust the implementer's self-report — read the actual code.
228
- \`\`\`
277
+ ${MARKDOWN_CODE_FENCE}
229
278
 
230
279
  ## Anti-patterns
231
280
 
@@ -273,7 +322,7 @@ Do NOT trust the implementer's self-report — read the actual code.
273
322
 
274
323
  ## Code-Quality Reviewer Prompt Template (paste into Task tool)
275
324
 
276
- \`\`\`
325
+ ${MARKDOWN_CODE_FENCE}
277
326
  You are a code-quality reviewer (subagent) after a single SDD task.
278
327
 
279
328
  SCOPE: {files touched by this task}
@@ -288,11 +337,11 @@ Review for maintainability and ship hygiene across:
288
337
  Output:
289
338
  - FINDINGS: severity, file:line, issue, recommendation
290
339
  - VERDICT: APPROVE | APPROVE_WITH_NITS | REWORK_REQUIRED
291
- \`\`\`
340
+ ${MARKDOWN_CODE_FENCE}
292
341
 
293
342
  ## Fixer Subagent Prompt Template (after spec review FAIL)
294
343
 
295
- \`\`\`
344
+ ${MARKDOWN_CODE_FENCE}
296
345
  You are a fixer subagent. You are NOT the original implementer.
297
346
 
298
347
  FAILING CRITERION (verbatim): {paste failed criterion}
@@ -305,11 +354,11 @@ Process:
305
354
  2) Implement the smallest fix that satisfies the criterion.
306
355
  3) Run the full test suite.
307
356
  4) Report STATUS: DONE / DONE_WITH_CONCERNS / NEEDS_CONTEXT / BLOCKED with evidence excerpts.
308
- \`\`\`
357
+ ${MARKDOWN_CODE_FENCE}
309
358
 
310
359
  ## Final Code Reviewer Prompt Template (post-queue sweep)
311
360
 
312
- \`\`\`
361
+ ${MARKDOWN_CODE_FENCE}
313
362
  You are the final code-quality reviewer after ALL SDD tasks completed.
314
363
 
315
364
  ENTIRE CHANGESET: {summary + primary entrypoints}
@@ -323,7 +372,7 @@ Deliver:
323
372
  - TOP_FINDINGS (merge blockers first)
324
373
  - CONSISTENCY_PASS/FAIL with rationale
325
374
  - SHIP_RECOMMENDATION: SHIP | SHIP_WITH_FOLLOWUPS | NO_SHIP
326
- \`\`\`
375
+ ${MARKDOWN_CODE_FENCE}
327
376
 
328
377
  ## Glossary
329
378
 
@@ -400,7 +449,7 @@ Implementation that touches shared source trees must remain **sequential** unles
400
449
 
401
450
  Write a structured reconciliation artifact at \`.cclaw/artifacts/07-review-army.json\` using this schema:
402
451
 
403
- \`\`\`json
452
+ ${MARKDOWN_CODE_FENCE}json
404
453
  {
405
454
  "version": 1,
406
455
  "generatedAt": "ISO timestamp",
@@ -424,7 +473,7 @@ Write a structured reconciliation artifact at \`.cclaw/artifacts/07-review-army.
424
473
  "shipBlockers": []
425
474
  }
426
475
  }
427
- \`\`\`
476
+ ${MARKDOWN_CODE_FENCE}
428
477
 
429
478
  Contract rules:
430
479
  - \`id\` and \`fingerprint\` must be stable between reruns if the finding is unchanged.
@@ -506,7 +555,7 @@ Contract rules:
506
555
 
507
556
  ## Parallel Review Task Template (paste into Task tool)
508
557
 
509
- \`\`\`
558
+ ${MARKDOWN_CODE_FENCE}
510
559
  You are an independent review/investigation subagent.
511
560
 
512
561
  LENS: {security|data|perf|api|ux|observability — pick one}
@@ -518,7 +567,7 @@ Rules:
518
567
  - Do not edit files unless explicitly authorized in this prompt.
519
568
  - Cite evidence as file:line for every finding.
520
569
  - If uncertain, emit CONFIDENCE <= 4 and label as hypothesis.
521
- \`\`\`
570
+ ${MARKDOWN_CODE_FENCE}
522
571
 
523
572
  ## Worked Example (narrative)
524
573
 
@@ -529,6 +578,137 @@ A large refactor touches **auth middleware** and **repository queries**. The con
529
578
  - Parallel agents produce **evidence and prioritized tasks**.
530
579
  - SDD **implements** those tasks **one at a time** with sequential implementers.
531
580
  - Never parallelize **writers** on the same codebase; parallelize **readers/analysts** with disjoint scopes.
581
+ `;
582
+ }
583
+ function researcherEnhancedBody() {
584
+ return `
585
+
586
+ ## Task Tool Delegation
587
+
588
+ Use this payload when a stage needs context-readiness or search-before-read evidence:
589
+
590
+ ${MARKDOWN_CODE_FENCE}
591
+ You are a researcher subagent.
592
+
593
+ QUESTION: {one falsifiable research question}
594
+ SCOPE: {repo paths, docs, references, providers to inspect}
595
+ CONTEXT READINESS: {graph/search/provider status if known}
596
+
597
+ Required output:
598
+ - SEARCH_SUMMARY: queries/patterns/providers tried before large reads
599
+ - FACTS: evidence-backed findings with refs
600
+ - STALE_OR_MISSING_CONTEXT: gaps and recommended recovery
601
+ - DECISION_IMPACT: what stage decision this changes
602
+ ${MARKDOWN_CODE_FENCE}
603
+
604
+ `;
605
+ }
606
+ function architectEnhancedBody() {
607
+ return `
608
+
609
+ ## Task Tool Delegation
610
+
611
+ ${MARKDOWN_CODE_FENCE}
612
+ You are an architect subagent.
613
+
614
+ DESIGN_DECISION: {architecture decision to validate}
615
+ SCOPE_CONTRACT: {approved boundaries}
616
+ BLAST_RADIUS: {paths/modules/interfaces}
617
+
618
+ Required output:
619
+ - BOUNDARIES: chosen ownership and interface contracts
620
+ - ALTERNATIVES: rejected alternatives and revival signals
621
+ - FAILURE_MODES: method/exception/rescue/user-visible impact
622
+ - SPEC_HANDOFF: requirements and verification evidence downstream spec must carry
623
+ ${MARKDOWN_CODE_FENCE}
624
+
625
+ `;
626
+ }
627
+ function specValidatorEnhancedBody() {
628
+ return `
629
+
630
+ ## Task Tool Delegation
631
+
632
+ ${MARKDOWN_CODE_FENCE}
633
+ You are a spec-validator subagent.
634
+
635
+ ACCEPTANCE_CRITERIA: {criteria to validate}
636
+ UPSTREAM_DECISIONS: {design/scope refs}
637
+
638
+ Required output:
639
+ - CRITERIA_AUDIT: PASS/PARTIAL/FAIL per AC with reason
640
+ - EDGE_CASE_GAPS: boundary/error cases missing
641
+ - ASSUMPTION_GAPS: assumptions requiring approval or rewrite
642
+ - TESTABILITY_MAP: concrete test level and command/manual evidence per AC
643
+ ${MARKDOWN_CODE_FENCE}
644
+
645
+ `;
646
+ }
647
+ function sliceImplementerEnhancedBody() {
648
+ return `
649
+
650
+ ## Task Tool Delegation
651
+
652
+ ${MARKDOWN_CODE_FENCE}
653
+ You are a slice-implementer subagent.
654
+
655
+ SLICE: {single vertical slice}
656
+ RED_EVIDENCE: {failing test and expected failure}
657
+ ALLOWED_FILES: {explicit file boundaries}
658
+ FORBIDDEN_CHANGES: {scope/compatibility limits}
659
+ VERIFICATION: {commands expected}
660
+
661
+ Rules:
662
+ - Implement only the minimal GREEN change for the existing RED evidence.
663
+ - Keep REFACTOR behavior-preserving.
664
+ - Return the strict worker JSON schema first.
665
+ ${MARKDOWN_CODE_FENCE}
666
+
667
+ `;
668
+ }
669
+ function performanceReviewerEnhancedBody() {
670
+ return `${codeReviewerEnhancedBody()}
671
+
672
+ ## Performance Lens
673
+
674
+ Focus on hot paths, IO/network calls, repeated work, caching, data volume, rendering, and algorithmic complexity. Include measurement evidence or a concrete measurement plan for every non-trivial finding.
675
+ `;
676
+ }
677
+ function compatibilityReviewerEnhancedBody() {
678
+ return `${codeReviewerEnhancedBody()}
679
+
680
+ ## Compatibility Lens
681
+
682
+ Focus on public APIs, CLI/config shape, persisted data, migrations, generated clients, dependency/runtime versions, and backwards-compatibility obligations. Distinguish shipped behavior from in-branch churn.
683
+ `;
684
+ }
685
+ function observabilityReviewerEnhancedBody() {
686
+ return `${codeReviewerEnhancedBody()}
687
+
688
+ ## Observability Lens
689
+
690
+ Focus on logs, metrics, traces, alerts, debug paths, rollout visibility, and support handoff. Block only when missing visibility affects diagnosis, rollback, or user/data safety.
691
+ `;
692
+ }
693
+ function releaseReviewerEnhancedBody() {
694
+ return `
695
+
696
+ ## Task Tool Delegation
697
+
698
+ ${MARKDOWN_CODE_FENCE}
699
+ You are a release-reviewer subagent.
700
+
701
+ SHIP_ARTIFACT: {ship/preflight evidence}
702
+ REVIEW_VERDICT: {review status and blockers}
703
+ FINALIZATION_MODE: {selected enum}
704
+
705
+ Required output:
706
+ - PREFLIGHT: commands and PASS/FAIL evidence freshness
707
+ - VICTORY_DETECTOR: feature coverage, evaluator evidence, clean state, learnings, handoff
708
+ - ROLLBACK: trigger, steps, owner, and no-VCS handoff if applicable
709
+ - SHIP_VERDICT: SHIP | SHIP_WITH_CONCERNS | BLOCKED
710
+ ${MARKDOWN_CODE_FENCE}
711
+
532
712
  `;
533
713
  }
534
714
  function plannerEnhancedBody() {
@@ -540,7 +720,7 @@ When a planning problem is too broad for one message, delegate **planning subtas
540
720
 
541
721
  Paste the template below verbatim and fill \`{placeholders}\` in the parent before dispatching.
542
722
 
543
- \`\`\`
723
+ ${MARKDOWN_CODE_FENCE}
544
724
  You are a planning subagent for a larger Cclaw / engineering workflow.
545
725
 
546
726
  PLANNING GOAL: {one sentence outcome — e.g., sequencing, risk register, dependency graph}
@@ -553,7 +733,7 @@ Rules:
553
733
  - Every task must include acceptance criteria copy-paste ready for SDD implementers.
554
734
  - Flag UNKNOWN explicitly instead of guessing.
555
735
  - Close with: OPEN_QUESTIONS: ... and NEXT_TASK_TEXT: ... (verbatim extractable queue item)
556
- \`\`\`
736
+ ${MARKDOWN_CODE_FENCE}
557
737
 
558
738
  `;
559
739
  }
@@ -564,7 +744,7 @@ function specReviewerEnhancedBody() {
564
744
 
565
745
  For review audits, use the Task tool with the following **reviewer** payload (fill placeholders in the parent session).
566
746
 
567
- \`\`\`
747
+ ${MARKDOWN_CODE_FENCE}
568
748
  You are a specification compliance reviewer (subagent).
569
749
 
570
750
  SPEC CRITERIA (verbatim): {acceptance criteria / invariants / non-goals}
@@ -575,7 +755,7 @@ Instructions:
575
755
  - For EACH criterion emit PASS / PARTIAL / FAIL with evidence as file:line.
576
756
  - Read the code; ignore implementer claims unless backed by code citations.
577
757
  - Close with SPEC_VERDICT: PASS | PASS_WITH_GAPS | FAIL plus GAPS/FAIL list.
578
- \`\`\`
758
+ ${MARKDOWN_CODE_FENCE}
579
759
 
580
760
  `;
581
761
  }
@@ -586,7 +766,7 @@ function codeReviewerEnhancedBody() {
586
766
 
587
767
  Launch deep **code-quality** reviews using this five-axis template in the Task tool body:
588
768
 
589
- \`\`\`
769
+ ${MARKDOWN_CODE_FENCE}
590
770
  You are a code-quality reviewer (subagent). Review along ALL axes:
591
771
 
592
772
  1) Correctness — logic, data flow, error handling, boundary conditions
@@ -601,7 +781,7 @@ BASELINE CONTEXT: {tests, deployment constraints, compatibility promises}
601
781
  Output format (mandatory):
602
782
  - FINDING: [Critical|Important|Suggestion] file:line — problem — recommendation
603
783
  - Close with RISK_SUMMARY and SHIP_BLOCKERS (explicit list, possibly empty).
604
- \`\`\`
784
+ ${MARKDOWN_CODE_FENCE}
605
785
 
606
786
  `;
607
787
  }
@@ -612,7 +792,7 @@ function productManagerEnhancedBody() {
612
792
 
613
793
  Use this payload when product discovery needs an isolated lens:
614
794
 
615
- \`\`\`
795
+ ${MARKDOWN_CODE_FENCE}
616
796
  You are a product-manager subagent.
617
797
 
618
798
  DISCOVERY GOAL: {problem/value decision to clarify}
@@ -626,7 +806,7 @@ Required output:
626
806
  - WHY_NOW_AND_DO_NOTHING: why now plus consequence of no action
627
807
  - NON_GOALS: explicit exclusions
628
808
  - SCOPE_HANDOFF: one recommendation for hold/selective/expand/reduce
629
- \`\`\`
809
+ ${MARKDOWN_CODE_FENCE}
630
810
 
631
811
  `;
632
812
  }
@@ -637,7 +817,7 @@ function criticEnhancedBody() {
637
817
 
638
818
  Use this payload when a premise, scope mode, or engineering path needs adversarial pressure:
639
819
 
640
- \`\`\`
820
+ ${MARKDOWN_CODE_FENCE}
641
821
  You are a critic subagent.
642
822
 
643
823
  DECISION_UNDER_REVIEW: {direction/scope/design choice}
@@ -651,7 +831,7 @@ Required output:
651
831
  - SWITCH_TRIGGER: signal that should change the decision
652
832
  - FAILURE_RESCUE: likely failure and rescue/degraded behavior
653
833
  - VERIFICATION_EVIDENCE: evidence needed before locking
654
- \`\`\`
834
+ ${MARKDOWN_CODE_FENCE}
655
835
 
656
836
  `;
657
837
  }
@@ -665,7 +845,7 @@ function securityReviewerEnhancedBody() {
665
845
 
666
846
  Use a dedicated Task tool invocation for CWE-focused review with reproducible narratives:
667
847
 
668
- \`\`\`
848
+ ${MARKDOWN_CODE_FENCE}
669
849
  You are a security reviewer (subagent). Perform a CWE-oriented review of the scoped change.
670
850
 
671
851
  SCOPE: {files/commits/services touched}
@@ -677,7 +857,7 @@ Requirements:
677
857
  - Include a short proof-of-concept attack vector (conceptual, no weaponization).
678
858
  - Recommend concrete controls (validation, sandboxing, authz checks, safer APIs).
679
859
  - Close with SECURITY_VERDICT: SHIP | SHIP_WITH_HOTFIXES | NO_SHIP and cite top 3 drivers.
680
- \`\`\`
860
+ ${MARKDOWN_CODE_FENCE}
681
861
 
682
862
  `;
683
863
  }
@@ -691,7 +871,7 @@ This agent runs in two explicit stage modes to respect cclaw hard-gates:
691
871
  - \`TEST_RED_ONLY\` (only failing tests + evidence; no production edits)
692
872
  - \`BUILD_GREEN_REFACTOR\` (implementation + full-suite green + refactor notes)
693
873
 
694
- \`\`\`
874
+ ${MARKDOWN_CODE_FENCE}
695
875
  You are a TDD implementer subagent.
696
876
 
697
877
  STAGE_MODE: {TEST_RED_ONLY | BUILD_GREEN_REFACTOR}
@@ -708,6 +888,52 @@ Process (mandatory):
708
888
  - GREEN — minimal production code to satisfy existing RED tests, rerun full suite.
709
889
  - REFACTOR — only after full suite is green; preserve behavior.
710
890
  - Report: FILES_EDITED, GREEN_COMMAND_RUN, REFACTOR_NOTES, STATUS: DONE|BLOCKED.
891
+ ${MARKDOWN_CODE_FENCE}
892
+
893
+ `;
894
+ }
895
+ function implementerEnhancedBody() {
896
+ return `
897
+
898
+ ## Task Tool Delegation
899
+
900
+ You are the default sequential implementation worker for one scoped task. Do not expand scope silently.
901
+
902
+ \`\`\`
903
+ You are an implementer subagent.
904
+
905
+ TASK: {single task with acceptance criteria pasted in full}
906
+ ALLOWED FILES / MODULES: {explicit boundaries}
907
+ FORBIDDEN CHANGES: {out-of-scope behavior, compatibility constraints}
908
+ VERIFICATION: {commands expected, or explain if unavailable}
909
+
910
+ Rules:
911
+ - Implement the smallest code change that satisfies the task.
912
+ - Do not spawn subagents.
913
+ - Return the strict implementer JSON schema first.
914
+ \`\`\`
915
+
916
+ `;
917
+ }
918
+ function fixerEnhancedBody() {
919
+ return `
920
+
921
+ ## Task Tool Delegation
922
+
923
+ Fixers are fresh workers dispatched only after a reviewer identifies a concrete failing criterion.
924
+
925
+ \`\`\`
926
+ You are a fixer subagent. You are NOT the original implementer.
927
+
928
+ FAILING CRITERION: {verbatim criterion}
929
+ REVIEW EVIDENCE: {file:line citations and short quotes}
930
+ ALLOWED FILES: {explicit list}
931
+ FORBIDDEN CHANGES: {scope and compatibility constraints}
932
+
933
+ Rules:
934
+ - Reproduce or reason from the cited failure before editing.
935
+ - Apply the smallest fix that closes the cited gap.
936
+ - Return the strict fixer JSON schema first.
711
937
  \`\`\`
712
938
 
713
939
  `;
@@ -719,7 +945,7 @@ function docUpdaterEnhancedBody() {
719
945
 
720
946
  For documentation parallelism, still avoid conflicting writes — partition by artifact:
721
947
 
722
- \`\`\`
948
+ ${MARKDOWN_CODE_FENCE}
723
949
  You are a documentation updater subagent.
724
950
 
725
951
  DOCS SCOPE: {README|API ref|runbook|changelog section}
@@ -729,7 +955,7 @@ Tasks:
729
955
  - Diff mental model vs reality; update only stale sections.
730
956
  - Preserve tone/structure; no doc rewrite for its own sake.
731
957
  - List FILES_UPDATED + SUMMARY + OPEN_DOC_QUESTIONS (if user input needed).
732
- \`\`\`
958
+ ${MARKDOWN_CODE_FENCE}
733
959
 
734
960
  `;
735
961
  }
@@ -739,6 +965,22 @@ Tasks:
739
965
  */
740
966
  export function enhancedAgentBody(agentName) {
741
967
  switch (agentName) {
968
+ case "researcher":
969
+ return researcherEnhancedBody();
970
+ case "architect":
971
+ return architectEnhancedBody();
972
+ case "spec-validator":
973
+ return specValidatorEnhancedBody();
974
+ case "slice-implementer":
975
+ return sliceImplementerEnhancedBody();
976
+ case "performance-reviewer":
977
+ return performanceReviewerEnhancedBody();
978
+ case "compatibility-reviewer":
979
+ return compatibilityReviewerEnhancedBody();
980
+ case "observability-reviewer":
981
+ return observabilityReviewerEnhancedBody();
982
+ case "release-reviewer":
983
+ return releaseReviewerEnhancedBody();
742
984
  case "planner":
743
985
  return plannerEnhancedBody();
744
986
  case "product-manager":
@@ -753,6 +995,10 @@ export function enhancedAgentBody(agentName) {
753
995
  return testAuthorEnhancedBody();
754
996
  case "doc-updater":
755
997
  return docUpdaterEnhancedBody();
998
+ case "implementer":
999
+ return implementerEnhancedBody();
1000
+ case "fixer":
1001
+ return fixerEnhancedBody();
756
1002
  default:
757
1003
  return `
758
1004
 
@@ -771,9 +1017,9 @@ Two patterns (skills under \`.cclaw/skills/\`):
771
1017
  - **SDD** (subagent-driven-development): sequential implementer→reviewer loops. Paste self-contained task text; never point subagents at plan files.
772
1018
  - **Parallel Agents** (dispatching-parallel-agents): parallel review/analysis lenses. Never parallelize implementers on same codebase.
773
1019
 
774
- Status contract: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED.
1020
+ Status contract: ACK first, then DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED. Worker returns must use the strict JSON schemas in \`subagent-driven-development\` and include matching spanId+dispatchId proof.
775
1021
 
776
- - Controller sequentially dispatches **implementer → reviewer** loops per task.
1022
+ - Controller sequentially dispatches **implementer → reviewer** loops per task and records lifecycle events in \`.cclaw/state/delegation-events.jsonl\`.
777
1023
  - HARD-GATE: paste **self-contained task text**; never point subagents at plan files to “discover” scope.
778
1024
  - **Review fixers** are **fresh agents** after failed review passes — avoids parent-context pollution.
779
1025
  - **Machine-only flow checks auto-dispatch** by stage (design/plan/tdd/review/ship) without asking the user to trigger each specialist manually.