cclaw-cli 0.51.30 → 0.55.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +22 -16
  2. package/dist/artifact-linter/brainstorm.d.ts +2 -0
  3. package/dist/artifact-linter/brainstorm.js +245 -0
  4. package/dist/artifact-linter/design.d.ts +2 -0
  5. package/dist/artifact-linter/design.js +323 -0
  6. package/dist/artifact-linter/plan.d.ts +2 -0
  7. package/dist/artifact-linter/plan.js +162 -0
  8. package/dist/artifact-linter/review-army.d.ts +24 -0
  9. package/dist/artifact-linter/review-army.js +365 -0
  10. package/dist/artifact-linter/review.d.ts +2 -0
  11. package/dist/artifact-linter/review.js +65 -0
  12. package/dist/artifact-linter/scope.d.ts +2 -0
  13. package/dist/artifact-linter/scope.js +115 -0
  14. package/dist/artifact-linter/shared.d.ts +246 -0
  15. package/dist/artifact-linter/shared.js +1488 -0
  16. package/dist/artifact-linter/ship.d.ts +2 -0
  17. package/dist/artifact-linter/ship.js +46 -0
  18. package/dist/artifact-linter/spec.d.ts +2 -0
  19. package/dist/artifact-linter/spec.js +108 -0
  20. package/dist/artifact-linter/tdd.d.ts +2 -0
  21. package/dist/artifact-linter/tdd.js +124 -0
  22. package/dist/artifact-linter.d.ts +4 -76
  23. package/dist/artifact-linter.js +56 -2949
  24. package/dist/cli.d.ts +1 -6
  25. package/dist/cli.js +4 -159
  26. package/dist/codex-feature-flag.d.ts +1 -1
  27. package/dist/codex-feature-flag.js +1 -1
  28. package/dist/config.d.ts +3 -2
  29. package/dist/config.js +67 -3
  30. package/dist/constants.d.ts +1 -7
  31. package/dist/constants.js +9 -15
  32. package/dist/content/cancel-command.js +2 -2
  33. package/dist/content/closeout-guidance.js +10 -7
  34. package/dist/content/core-agents.d.ts +18 -0
  35. package/dist/content/core-agents.js +46 -2
  36. package/dist/content/decision-protocol.d.ts +1 -1
  37. package/dist/content/decision-protocol.js +1 -1
  38. package/dist/content/examples.js +6 -6
  39. package/dist/content/harness-doc.js +20 -2
  40. package/dist/content/hook-inline-snippets.d.ts +17 -4
  41. package/dist/content/hook-inline-snippets.js +218 -5
  42. package/dist/content/hook-manifest.d.ts +2 -2
  43. package/dist/content/hook-manifest.js +2 -2
  44. package/dist/content/hooks.d.ts +1 -0
  45. package/dist/content/hooks.js +32 -137
  46. package/dist/content/idea-command.d.ts +8 -0
  47. package/dist/content/{ideate-command.js → idea-command.js} +57 -50
  48. package/dist/content/idea-frames.d.ts +31 -0
  49. package/dist/content/{ideate-frames.js → idea-frames.js} +9 -9
  50. package/dist/content/idea-ranking.d.ts +25 -0
  51. package/dist/content/{ideate-ranking.js → idea-ranking.js} +5 -5
  52. package/dist/content/iron-laws.d.ts +0 -1
  53. package/dist/content/iron-laws.js +31 -16
  54. package/dist/content/learnings.js +1 -1
  55. package/dist/content/meta-skill.js +7 -7
  56. package/dist/content/node-hooks.d.ts +10 -0
  57. package/dist/content/node-hooks.js +43 -9
  58. package/dist/content/opencode-plugin.js +3 -3
  59. package/dist/content/skills.js +19 -7
  60. package/dist/content/stage-schema.js +44 -2
  61. package/dist/content/stages/_lint-metadata/index.js +26 -2
  62. package/dist/content/stages/brainstorm.js +13 -7
  63. package/dist/content/stages/design.js +16 -11
  64. package/dist/content/stages/plan.js +7 -4
  65. package/dist/content/stages/review.js +4 -4
  66. package/dist/content/stages/schema-types.d.ts +1 -1
  67. package/dist/content/stages/scope.js +15 -12
  68. package/dist/content/stages/ship.js +2 -2
  69. package/dist/content/stages/spec.js +9 -3
  70. package/dist/content/stages/tdd.js +14 -4
  71. package/dist/content/start-command.js +11 -10
  72. package/dist/content/status-command.js +3 -3
  73. package/dist/content/subagents.js +60 -6
  74. package/dist/content/templates.d.ts +1 -1
  75. package/dist/content/templates.js +102 -150
  76. package/dist/content/tree-command.js +2 -2
  77. package/dist/content/utility-skills.d.ts +2 -2
  78. package/dist/content/utility-skills.js +2 -2
  79. package/dist/content/view-command.js +4 -2
  80. package/dist/delegation.d.ts +2 -0
  81. package/dist/delegation.js +2 -1
  82. package/dist/early-loop.d.ts +66 -0
  83. package/dist/early-loop.js +275 -0
  84. package/dist/gate-evidence.d.ts +8 -0
  85. package/dist/gate-evidence.js +141 -5
  86. package/dist/harness-adapters.d.ts +2 -2
  87. package/dist/harness-adapters.js +47 -18
  88. package/dist/install.js +153 -29
  89. package/dist/internal/advance-stage/advance.d.ts +50 -0
  90. package/dist/internal/advance-stage/advance.js +480 -0
  91. package/dist/internal/advance-stage/cancel-run.d.ts +8 -0
  92. package/dist/internal/advance-stage/cancel-run.js +19 -0
  93. package/dist/internal/advance-stage/flow-state-coercion.d.ts +3 -0
  94. package/dist/internal/advance-stage/flow-state-coercion.js +81 -0
  95. package/dist/internal/advance-stage/helpers.d.ts +14 -0
  96. package/dist/internal/advance-stage/helpers.js +145 -0
  97. package/dist/internal/advance-stage/hook.d.ts +8 -0
  98. package/dist/internal/advance-stage/hook.js +40 -0
  99. package/dist/internal/advance-stage/parsers.d.ts +54 -0
  100. package/dist/internal/advance-stage/parsers.js +307 -0
  101. package/dist/internal/advance-stage/review-loop.d.ts +7 -0
  102. package/dist/internal/advance-stage/review-loop.js +170 -0
  103. package/dist/internal/advance-stage/rewind.d.ts +14 -0
  104. package/dist/internal/advance-stage/rewind.js +108 -0
  105. package/dist/internal/advance-stage/start-flow.d.ts +11 -0
  106. package/dist/internal/advance-stage/start-flow.js +136 -0
  107. package/dist/internal/advance-stage/verify.d.ts +29 -0
  108. package/dist/internal/advance-stage/verify.js +225 -0
  109. package/dist/internal/advance-stage.js +21 -1470
  110. package/dist/internal/compound-readiness.d.ts +1 -1
  111. package/dist/internal/compound-readiness.js +2 -2
  112. package/dist/internal/early-loop-status.d.ts +7 -0
  113. package/dist/internal/early-loop-status.js +90 -0
  114. package/dist/internal/runtime-integrity.d.ts +7 -0
  115. package/dist/internal/runtime-integrity.js +288 -0
  116. package/dist/internal/tdd-red-evidence.js +1 -1
  117. package/dist/knowledge-store.d.ts +3 -8
  118. package/dist/knowledge-store.js +16 -29
  119. package/dist/managed-resources.js +24 -2
  120. package/dist/policy.js +4 -6
  121. package/dist/run-archive.d.ts +1 -1
  122. package/dist/run-archive.js +12 -12
  123. package/dist/run-persistence.js +111 -11
  124. package/dist/tdd-cycle.d.ts +3 -3
  125. package/dist/tdd-cycle.js +1 -1
  126. package/dist/types.d.ts +18 -10
  127. package/package.json +1 -1
  128. package/dist/content/ideate-command.d.ts +0 -8
  129. package/dist/content/ideate-frames.d.ts +0 -31
  130. package/dist/content/ideate-ranking.d.ts +0 -25
  131. package/dist/content/next-command.d.ts +0 -20
  132. package/dist/content/next-command.js +0 -298
  133. package/dist/content/seed-shelf.d.ts +0 -36
  134. package/dist/content/seed-shelf.js +0 -301
  135. package/dist/content/stage-common-guidance.d.ts +0 -1
  136. package/dist/content/stage-common-guidance.js +0 -106
  137. package/dist/doctor-registry.d.ts +0 -10
  138. package/dist/doctor-registry.js +0 -186
  139. package/dist/doctor.d.ts +0 -17
  140. package/dist/doctor.js +0 -2201
  141. package/dist/internal/hook-manifest.d.ts +0 -16
  142. package/dist/internal/hook-manifest.js +0 -77
@@ -1,4 +1,4 @@
1
- import { REVIEW_LOOP_CHECKLISTS, reviewLoopPolicySummary, reviewLoopSecondOpinionSummary } from "../review-loop.js";
1
+ import { REVIEW_LOOP_CHECKLISTS, reviewLoopPolicySummary } from "../review-loop.js";
2
2
  import { decisionProtocolInstruction } from "../decision-protocol.js";
3
3
  // ---------------------------------------------------------------------------
4
4
  // DESIGN — reference: gstack Eng review
@@ -7,8 +7,8 @@ export const DESIGN = {
7
7
  schemaShape: "v2",
8
8
  stage: "design",
9
9
  complexityTier: "standard",
10
- skillFolder: "engineering-design-lock",
11
- skillName: "engineering-design-lock",
10
+ skillFolder: "design",
11
+ skillName: "design",
12
12
  skillDescription: "Engineering lock stage. Convert the approved scope contract into a buildable architecture with adversarial alternatives, failure/rescue paths, and spec handoff.",
13
13
  philosophy: {
14
14
  hardGate: "Do NOT write implementation code. This stage produces design decisions and architecture documents only. No code changes, no scaffolding, no test files.",
@@ -49,8 +49,9 @@ export const DESIGN = {
49
49
  "Architecture Review — lock boundaries, chosen path, shadow alternative, switch trigger, failure/rescue/degraded behavior, and verification evidence for every high-risk choice; include tier-required diagrams.",
50
50
  "Review core risk areas — existing system fit, data/state flow, critical path, security/trust boundaries, tests, performance budget, observability/debuggability, rollout/rollback, rejected alternatives, and spec handoff.",
51
51
  "**ADR + pre-mortem contract** — capture ADR-style decision rows (context, decision, alternatives, consequences), run a pre-mortem on likely failures, and map each critical flow to a validating test and diagram anchor before lock.",
52
- `Critic pass — run/reconcile adversarial second opinion on architecture, coupling, failure modes, and cheaper alternatives. ${reviewLoopPolicySummary("design")} ${reviewLoopSecondOpinionSummary("design")}`,
53
- "Run optional stale-diagram audit only when configured.",
52
+ "Critic pass — run/reconcile adversarial second opinion on architecture, coupling, failure modes, and cheaper alternatives; record outcomes per the Design Outside Voice Loop policy.",
53
+ "**Run early Ralph loop discipline** — after each producer iteration, append a `Critic Pass` JSONL row to `.cclaw/state/early-loop-log.jsonl`, refresh `.cclaw/state/early-loop.json`, and iterate until open concerns clear or convergence guard escalates.",
54
+ "Run stale-diagram audit as a design freshness gate (default-on; explicit config opt-out allowed).",
54
55
  "Capture leftovers — seed high-upside deferred ideas, list unresolved decisions with defaults, document distribution for new artifact types, and cross-reference deferred items to scope or unresolved decisions."
55
56
  ],
56
57
  interactionProtocol: [
@@ -71,7 +72,7 @@ export const DESIGN = {
71
72
  "Run investigator pass plus scope challenge/search-before-building.",
72
73
  "Walk review sections interactively and lock boundaries, data flow, state transitions, edge cases, and failure modes.",
73
74
  "Cover security, observability, deployment, tests, and performance for Standard+ changes.",
74
- "Run configured stale-diagram audit when enabled.",
75
+ "Run stale-diagram audit (enabled by default unless explicitly disabled).",
75
76
  "Produce required outputs: NOT-in-scope, What-already-exists, tier diagrams, failure table, completion dashboard.",
76
77
  "Plant high-upside deferred ideas when useful and reconcile critic/outside-voice findings.",
77
78
  "Write design lock artifact for downstream spec/plan with design decisions, rejected alternatives, verification evidence, and exact spec handoff."
@@ -79,6 +80,7 @@ export const DESIGN = {
79
80
  requiredGates: [
80
81
  { id: "design_research_complete", description: "Research is complete: compact inline synthesis by default, or a separate research artifact for deep/high-risk work, and findings are mapped to design decisions." },
81
82
  { id: "design_architecture_locked", description: "Architecture boundaries are explicit and approved." },
83
+ { id: "design_diagram_freshness", description: "Stale Diagram Audit is clear, or explicitly skipped for compact trivial-override slices without diagram markers." },
82
84
  { id: "design_data_flow_mapped", description: "Data/state flow includes edge-case paths." },
83
85
  { id: "design_failure_modes_mapped", description: "Failure modes and mitigations are documented." },
84
86
  { id: "design_test_and_perf_defined", description: "Test strategy and performance budget are defined." }
@@ -88,12 +90,13 @@ export const DESIGN = {
88
90
  "Artifact written to `.cclaw/artifacts/03-design-<slug>.md`.",
89
91
  "Failure-mode table exists in Method/Exception/Rescue/UserSees format.",
90
92
  "Tier-required diagram markers are present: architecture (all tiers). Standard/Deep add-ons (shadow/error) and Deep add-ons (state-machine/rollback/deployment-sequence) are included only when risk warrants them.",
91
- "When `.cclaw/config.yaml::optInAudits.staleDiagramAudit` is true, stale diagram audit finding is clear (no blast-radius file newer than diagram markers without explicit update).",
93
+ "Stale diagram audit finding is clear by default (unless `.cclaw/config.yaml::optInAudits.staleDiagramAudit` is explicitly false): no blast-radius file newer than diagram markers without explicit update.",
92
94
  "Security & threat model findings are documented with mitigations.",
93
95
  "Observability and deployment plans are explicit for critical flows.",
94
96
  "Outside-voice findings and dispositions are recorded (accept/reject/defer).",
95
- `Spec review loop summary includes iteration count and quality score trajectory per ${reviewLoopPolicySummary("design")}`,
96
- reviewLoopSecondOpinionSummary("design"),
97
+ "Design outside-voice loop summary includes iteration count and quality-score trajectory with explicit stop reason and unresolved concerns.",
98
+ "Early-loop status is reflected via `Victory Detector` / `Critic Pass` sections and `.cclaw/state/early-loop.json` when concerns remain.",
99
+ "When a second opinion is used, record source, critique frame, and disposition (accept/reject/defer) with rationale.",
97
100
  "Adversarial lock table includes chosen path, shadow alternative, switch trigger, failure/rescue/degraded behavior, and verification evidence, with reference-grade contracts for mirrored patterns when applicable.",
98
101
  "Architecture Decision Record (ADR) section captures context, decision, alternatives, consequences, and reversal trigger for major choices.",
99
102
  "Pre-mortem section lists top failure scenarios, early signals, mitigations, and owner before implementation begins.",
@@ -158,13 +161,12 @@ export const DESIGN = {
158
161
  { section: "Data-Flow Shadow Paths", required: false, validationRule: "Standard/Deep add-on: include `<!-- diagram: data-flow-shadow-paths -->` marker plus a table for high-risk choices: chosen path, shadow alternative, switch trigger, failure/rescue/degraded behavior, and verification evidence." },
159
162
  { section: "Error Flow Diagram", required: false, validationRule: "Standard/Deep add-on: include `<!-- diagram: error-flow -->` marker and failure-detection -> rescue -> user-visible outcome flow." },
160
163
  { section: "Data Flow", required: false, validationRule: "Must include data/state flow, happy path, nil input, empty input, upstream error paths, plus Interaction Edge Case matrix rows for double-click, nav-away-mid-request, 10K-result dataset, background-job abandonment, zombie connection. Each row declares handled yes/no and deferred item when not handled." },
161
- { section: "Stale Diagram Audit", required: false, validationRule: "When `.cclaw/config.yaml::optInAudits.staleDiagramAudit` is true: blast-radius files from Codebase Investigation must not be newer than the current design diagram-marker baseline unless explicitly refreshed." },
164
+ { section: "Stale Diagram Audit", required: false, validationRule: "Default-on audit (unless `.cclaw/config.yaml::optInAudits.staleDiagramAudit` is false): blast-radius files from Codebase Investigation must not be newer than the current design diagram-marker baseline unless explicitly refreshed." },
162
165
  { section: "Failure Mode Table", required: true, validationRule: "Use Method/Exception/Rescue/UserSees columns and treat silent user impact without rescue as critical." },
163
166
  { section: "Pre-mortem", required: false, validationRule: "Recommended: list top failure scenarios, early warning signal, mitigation owner, and containment action before implementation." },
164
167
  { section: "Security & Threat Model", required: true, validationRule: "Must list trust boundaries, abuse/failure scenarios, mitigations, and residual risks." },
165
168
  { section: "Test Strategy", required: false, validationRule: "Must define unit/integration/e2e expectations with coverage targets." },
166
169
  { section: "Test-Diagram Mapping", required: false, validationRule: "Recommended: map each critical flow to at least one validating test ID and one diagram marker/anchor." },
167
- { section: "Test Strategy", required: false, validationRule: "Must define unit/integration/e2e expectations with coverage targets." },
168
170
  { section: "Performance Budget", required: false, validationRule: "For each critical path: metric name, target threshold, and measurement method." },
169
171
  { section: "Observability & Debuggability", required: true, validationRule: "Must define logs/metrics/traces plus alerting/debug path for critical failure modes." },
170
172
  { section: "Deployment & Rollout", required: true, validationRule: "Must define migration/flag strategy, rollout/rollback plan, switch trigger, and post-deploy verification steps." },
@@ -173,8 +175,11 @@ export const DESIGN = {
173
175
  { section: "Rejected Alternatives", required: false, validationRule: "List alternatives considered, why rejected, and what signal would revive them." },
174
176
  { section: "Design Decisions", required: false, validationRule: "Stable design decisions with requirement/locked-decision refs and downstream spec impact." },
175
177
  { section: "Spec Handoff", required: true, validationRule: "Exact requirements, design decisions, risks, test/perf expectations, and unresolved questions that spec must carry forward." },
178
+ { section: "Long-Term Trajectory", required: false, validationRule: "Recommended (1-3 lines, present-only): name what comes after this ships (Phase 2 / Phase 3 / platform promotion) and whether the locked architecture can absorb that path without major rework. Use `None - tactical change only` for compact slices." },
176
179
  { section: "Outside Voice Findings", required: false, validationRule: "Critic pass: list adversarial findings and disposition (accept/reject/defer) with rationale per material finding." },
177
180
  { section: "Design Outside Voice Loop", required: false, validationRule: `Record iteration table with quality score per iteration, stop reason, and unresolved concerns. Enforce ${reviewLoopPolicySummary("design")}` },
181
+ { section: "Victory Detector", required: false, validationRule: "Recommended early-loop checkpoint: cite `.cclaw/state/early-loop.json`, current iteration/maxIterations, open concern count, convergence status, and iterate/ready/escalate decision." },
182
+ { section: "Critic Pass", required: false, validationRule: "Recommended producer/critic log contract: each iteration appends one JSONL row to `.cclaw/state/early-loop-log.jsonl` with runId, stage, iteration, and open concerns." },
178
183
  { section: "NOT in scope", required: false, validationRule: "Work considered and explicitly deferred with one-line rationale." },
179
184
  { section: "Completion Dashboard", required: true, validationRule: "Lists every review section with status (clear / issues-found-resolved / issues-open), critical/open gap counts, decision count, and unresolved items (or 'None')." }
180
185
  ],
@@ -5,8 +5,8 @@ export const PLAN = {
5
5
  schemaShape: "v2",
6
6
  stage: "plan",
7
7
  complexityTier: "standard",
8
- skillFolder: "planning-and-task-breakdown",
9
- skillName: "planning-and-task-breakdown",
8
+ skillFolder: "plan",
9
+ skillName: "plan",
10
10
  skillDescription: "Execution planning stage with strict confirmation gate before implementation.",
11
11
  philosophy: {
12
12
  hardGate: "Do NOT write code or tests. Planning only. This stage produces a task graph and execution order. WAIT_FOR_CONFIRM before any handoff to implementation.",
@@ -69,6 +69,7 @@ export const PLAN = {
69
69
  "Define each task with acceptance mapping, verification command/manual step, and expected evidence/pass condition.",
70
70
  "Trace every locked decision (D-XX) to plan tasks or explicit defer rationale.",
71
71
  "Record validation points, blockers, and execution posture.",
72
+ "For high-risk/multi-batch plans, add a calibrated findings pass and explicit regression iron-rule acknowledgement.",
72
73
  "Write plan artifact and pause at WAIT_FOR_CONFIRM."
73
74
  ],
74
75
  requiredGates: [
@@ -132,9 +133,11 @@ export const PLAN = {
132
133
  { section: "Locked Decision Coverage", required: false, validationRule: "Every locked decision ID (D-XX) from scope is listed with linked task IDs or explicit defer rationale." },
133
134
  { section: "Risk Assessment", required: false, validationRule: "If present: per-task or per-batch risk identification with likelihood, impact, and mitigation strategy." },
134
135
  { section: "Boundary Map", required: false, validationRule: "If present: per-batch or per-task interface contracts listing what each task produces (exports) and consumes (imports) from other tasks." },
136
+ { section: "Implementation Units", required: false, validationRule: "If present: each `### Implementation Unit U-<n>` includes Goal, Files, Approach, Test scenarios, and Verification fields." },
137
+ { section: "Calibrated Findings", required: false, validationRule: "If present: either `None this stage` or one or more lines in `[P1|P2|P3] (confidence: <n>/10) <path>[:<line>] — <description>` format." },
138
+ { section: "Regression Iron Rule", required: false, validationRule: "If present: includes `Iron rule acknowledged: yes`." },
135
139
  { section: "WAIT_FOR_CONFIRM", required: true, validationRule: "Explicit marker present. Status: pending until user approves." },
136
- { section: "No-Placeholder Scan", required: false, validationRule: "Confirmation that a text scan for `TODO`, `TBD`, `FIXME`, `<fill-in>`, `<your-*-here>`, `xxx`, or bare ellipses has zero hits in the task list. A placeholder is a deferred decision masquerading as a plan." },
137
- { section: "No Scope Reduction Language Scan", required: false, validationRule: "Confirmation that scope-reduction phrases (`v1`, `for now`, `later`, `temporary`, `placeholder`) are absent from task rows when locked decisions exist." }
140
+ { section: "Plan Quality Scan", required: false, validationRule: "If present: includes a placeholder scan (`TODO`/`TBD`/`FIXME`/`<fill-in>`/`<your-*-here>`/`xxx`/bare ellipsis) and a scope-reduction language scan (`v1`, `for now`, `later`, `temporary`, `placeholder`) with zero hits in task rows when locked decisions exist." }
138
141
  ]
139
142
  },
140
143
  reviewLens: {
@@ -6,8 +6,8 @@ export const REVIEW = {
6
6
  schemaShape: "v2",
7
7
  stage: "review",
8
8
  complexityTier: "standard",
9
- skillFolder: "two-layer-review",
10
- skillName: "two-layer-review",
9
+ skillFolder: "review",
10
+ skillName: "review",
11
11
  skillDescription: "Two-layer review stage: spec compliance first, then code quality and production readiness. Section-by-section with severity discipline.",
12
12
  philosophy: {
13
13
  hardGate: "Do NOT ship, merge, or release until both review layers complete with an explicit verdict. No exceptions for urgency. Critical blockers MUST be resolved before handoff.",
@@ -47,7 +47,7 @@ export const REVIEW = {
47
47
  "Classify findings — Critical (blocks ship), Important (should fix), Suggestion (optional improvement).",
48
48
  "Victory Detector — before verdict, confirm Layer 1, Layer 2, security sweep, structured findings, trace evidence, and unresolved-critical status are complete; otherwise iterate findings or route back to TDD.",
49
49
  "Produce verdict — APPROVED, APPROVED_WITH_CONCERNS, or BLOCKED.",
50
- "If verdict is BLOCKED, emit remediation route token `ROUTE_BACK_TO_TDD`, include the managed command `cclaw internal rewind tdd \"review_blocked_by_critical <finding-ids>\"`, list the critical finding IDs and required TDD evidence to repair, and satisfy the special transition guard `review_verdict_blocked` instead of `review_criticals_resolved`. After TDD rework, clear the stale marker with `cclaw internal rewind --ack tdd` before `/cc`."
50
+ "If verdict is BLOCKED, emit remediation route token `ROUTE_BACK_TO_TDD`, include the managed command `npx cclaw-cli internal rewind tdd \"review_blocked_by_critical <finding-ids>\"`, list the critical finding IDs and required TDD evidence to repair, and satisfy the special transition guard `review_verdict_blocked` instead of `review_criticals_resolved`. After TDD rework, clear the stale marker with `npx cclaw-cli internal rewind --ack tdd` before `/cc`."
51
51
  ],
52
52
  interactionProtocol: [
53
53
  "Run Layer 1 (spec compliance) completely before starting Layer 2.",
@@ -55,7 +55,7 @@ export const REVIEW = {
55
55
  "Classify every finding as Critical, Important, or Suggestion.",
56
56
  decisionProtocolInstruction("each Critical finding", "present resolution options (A/B/C) with trade-offs, and mark one as (recommended)", "recommend the option that fully closes the finding with no carry-over risk and the smallest blast radius", STRUCTURED_ASK_TOOL_LIST_REVIEW),
57
57
  "Resolve all critical blockers before ship. If verdict is BLOCKED, do not pass `review_criticals_resolved`; pass only the remediation route gate `review_verdict_blocked` when routing back to TDD.",
58
- "When verdict is BLOCKED, do not end with a passive stop: explicitly route remediation to TDD via `ROUTE_BACK_TO_TDD`, point to `cclaw internal rewind tdd` with the blocking IDs, and tell the operator to ack the stale TDD marker only after rework is complete.",
58
+ "When verdict is BLOCKED, do not end with a passive stop: explicitly route remediation to TDD via `ROUTE_BACK_TO_TDD`, point to `npx cclaw-cli internal rewind tdd` with the blocking IDs, and tell the operator to ack the stale TDD marker only after rework is complete.",
59
59
  structuredAskSingleChoiceInstruction("final verdict", "verdict (APPROVED / APPROVED_WITH_CONCERNS / BLOCKED)"),
60
60
  "**STOP.** Do NOT proceed to ship until the user provides an explicit verdict."
61
61
  ],
@@ -20,7 +20,7 @@ export interface ArtifactValidation {
20
20
  tier?: "required" | "recommended";
21
21
  validationRule: string;
22
22
  }
23
- export type StageSubagentName = "researcher" | "architect" | "spec-validator" | "slice-implementer" | "performance-reviewer" | "compatibility-reviewer" | "observability-reviewer" | "release-reviewer" | "planner" | "product-manager" | "critic" | "reviewer" | "security-reviewer" | "test-author" | "doc-updater" | "implementer" | "fixer";
23
+ export type StageSubagentName = "researcher" | "architect" | "spec-validator" | "spec-document-reviewer" | "slice-implementer" | "performance-reviewer" | "compatibility-reviewer" | "observability-reviewer" | "release-reviewer" | "planner" | "product-manager" | "product-strategist" | "critic" | "reviewer" | "security-reviewer" | "test-author" | "doc-updater" | "implementer" | "fixer";
24
24
  export type StageSubagentDispatchClass = "stage-specialist" | "worker" | "review-lens";
25
25
  export type StageSubagentReturnSchema = "planning-return" | "product-return" | "critic-return" | "review-return" | "security-return" | "tdd-return" | "docs-return" | "worker-return" | "fixer-return" | "research-return" | "architecture-return" | "spec-validation-return" | "performance-return" | "compatibility-return" | "observability-return" | "release-return";
26
26
  export interface StageAutoSubagentDispatch {
@@ -1,4 +1,4 @@
1
- import { REVIEW_LOOP_CHECKLISTS, reviewLoopPolicySummary, reviewLoopSecondOpinionSummary } from "../review-loop.js";
1
+ import { REVIEW_LOOP_CHECKLISTS, reviewLoopPolicySummary } from "../review-loop.js";
2
2
  import { decisionProtocolInstruction } from "../decision-protocol.js";
3
3
  // ---------------------------------------------------------------------------
4
4
  // SCOPE — reference: gstack CEO review
@@ -7,8 +7,8 @@ export const SCOPE = {
7
7
  schemaShape: "v2",
8
8
  stage: "scope",
9
9
  complexityTier: "standard",
10
- skillFolder: "scope-shaping",
11
- skillName: "scope-shaping",
10
+ skillFolder: "scope",
11
+ skillName: "scope",
12
12
  skillDescription: "Strategic contract stage. Select HOLD/SELECTIVE/EXPAND/REDUCE mode, lock the slice and boundaries, and hand stable discretion zones to design.",
13
13
  philosophy: {
14
14
  hardGate: "Do NOT begin architecture, design, or code. This stage produces scope decisions only. Do not silently add or remove scope — every change is an explicit user opt-in.",
@@ -53,18 +53,19 @@ export const SCOPE = {
53
53
  "**Decision-driver contract** — list weighted decision drivers (value, risk, reversibility, effort, timeline) and score candidate scope moves so the selected mode and boundaries are evidence-backed, not preference-led.",
54
54
  "**Compare implementation alternatives** — include minimum viable, product-grade, and ideal architecture options with effort (S/M/L/XL), risk (Low/Med/High), pros, cons, and reuses. Recommend one and tie it to mode.",
55
55
  "**Run outside voice before final approval** — for simple/low-risk scope, record one concise adversarial self-check row; for complex/high-risk/configured scope, iterate until threshold. Record the loop summary in `## Scope Outside Voice Loop`, but do not treat it as user approval.",
56
+ "**Run early Ralph loop discipline** — after each producer iteration, append a `Critic Pass` JSONL row to `.cclaw/state/early-loop-log.jsonl`, refresh `.cclaw/state/early-loop.json`, and iterate until open concerns clear or convergence guard escalates.",
56
57
  "**Ask only one decision-changing question** — if the user rejects the contract but is unsure, offer 3-4 concrete scope moves instead of open-ended interrogation.",
57
58
  "**Write the scope contract after approval** — include selected mode, in scope, out of scope, requirements, locked decisions, discretion areas, deferred ideas, accepted/rejected reference ideas, success definition, design handoff, completion dashboard, and explicit approval evidence."
58
59
  ],
59
60
  interactionProtocol: [
60
61
  decisionProtocolInstruction("scope mode selection", "present expand/selective/hold/reduce as labeled options with trade-offs and mark one as (recommended)", "recommend the option that best covers the prime-directive failure modes, four data-flow paths, observability, and deferred handling for the in-scope set with the smallest blast radius. Base your recommendation on default heuristics: greenfield -> expand, enhancement -> selective, bugfix/hotfix/refactor -> hold, broad blast radius -> reduce"),
61
62
  "Do not walk the full checklist by default. Lead with a proposed scope contract, selected depth (`lite`/`standard`/`deep`), and the one decision that matters most; label the mode as recommended, not selected, until the user answers.",
62
- "For simple web-app flows, default to HOLD SCOPE or SELECTIVE EXPANSION, show the exact in/out/deferred contract as a proposal, and STOP for one explicit approval before writing the final scope artifact or completing the stage.",
63
+ "For low-risk concrete asks, keep the proposal compact but still explicit: recommend (do not auto-select) one mode, show exact in/out/deferred boundaries, and STOP for one explicit approval before finalizing the artifact or completing the stage.",
63
64
  "Challenge premise first, take a firm position, and name one concrete condition that would change it.",
64
65
  "Push back on weak framing: vague scope needs a specific user/problem, platform vision needs a narrow wedge, social proof needs behavioral evidence.",
65
66
  "Resolve one structural scope issue at a time. Only non-critical preference/default assumptions may continue; STOP on uncertainty about scope boundary, architecture commitment, security, data loss, public API, migration, auth/pricing, or required user approval.",
66
67
  "If the user says no but cannot name the change, offer concrete moves: keep scope, add one obvious adjacent capability, reduce to wedge, or re-open stack/product direction.",
67
- `Before final approval, record outside-voice findings and a \`## Scope Outside Voice Loop\` table using ${reviewLoopPolicySummary("scope")}`,
68
+ "Before final approval, record outside-voice findings and a `## Scope Outside Voice Loop` table per the Scope Outside Voice Loop policy above.",
68
69
  "**STOP.** Wait for explicit user approval of the scope mode and scope contract before writing final approval language or advancing.",
69
70
  "**STOP BEFORE ADVANCE.** Mandatory delegation `planner` must be completed or explicitly waived for a real blocker. If the active harness cannot isolate a planner, run a role-switch planner pass instead: announce `## cclaw role-switch: scope/planner (mandatory)`, write the planner output/evidence into the scope artifact, and append a completed delegation row with `fulfillmentMode: \"role-switch\"` plus non-empty `evidenceRefs`. Then close with `node .cclaw/hooks/stage-complete.mjs scope --passed=scope_mode_selected,scope_contract_written,scope_user_approved --evidence-json '{\"scope_mode_selected\":\"<user-approved mode + rationale>\",\"scope_contract_written\":\"<artifact path + sections>\",\"scope_user_approved\":\"<explicit user approval quote or summary>\"}'`. `scope_user_approved` must cite the user's approval; review-loop evidence alone is not approval."
70
71
  ],
@@ -88,14 +89,16 @@ export const SCOPE = {
88
89
  "In-scope and out-of-scope lists are explicit.",
89
90
  "Discretion areas are explicit (or marked as `None`).",
90
91
  "Selected mode and rationale are documented using HOLD SCOPE, SELECTIVE EXPANSION, SCOPE EXPANSION, or SCOPE REDUCTION.",
92
+ "When selected mode is SCOPE EXPANSION or SELECTIVE EXPANSION, active-run delegation ledger includes a completed `product-strategist` row with non-empty `evidenceRefs`.",
91
93
  "Scope Contract captures requirements, locked decisions, discretion areas, accepted/rejected/deferred reference ideas from the Reference Pattern Registry, success definition, and design handoff.",
92
94
  "Decision Drivers section records weighted criteria and per-option scores used to choose mode and boundary moves.",
93
95
  "Scope Completeness Score is recorded (0.00-1.00) with the explicit blocker list for any remaining uncertainty.",
94
96
  "Locked Decisions section lists stable LD#hash anchors for non-negotiable boundaries.",
95
97
  "Premise challenge findings documented.",
96
98
  "Outside Voice findings and dispositions are recorded (accept/reject/defer with rationale) before final approval.",
97
- `Scope outside-voice loop summary includes a table with columns Iteration, Quality Score, Findings, plus Stop reason, Target score, and Max iterations. This is outside-voice evidence only; it does not satisfy user approval. ${reviewLoopPolicySummary("scope")}`,
98
- reviewLoopSecondOpinionSummary("scope"),
99
+ "Scope outside-voice loop summary includes a table with columns Iteration, Quality Score, Findings, plus Stop reason, Target score, Max iterations, and unresolved concerns. This is outside-voice evidence only; it does not satisfy user approval.",
100
+ "Early-loop status is reflected via `Victory Detector` / `Critic Pass` sections and `.cclaw/state/early-loop.json` when concerns remain.",
101
+ "When a second opinion is used, record source, critique frame, and disposition (accept/reject/defer) with rationale.",
99
102
  "Deferred items list with one-line rationale for each.",
100
103
  "When an upside deferred idea is parked, a seed file is created under `.cclaw/seeds/` and referenced in the artifact.",
101
104
  "Completion dashboard lists per-section status, critical/open gaps, decision count, and unresolved items (or `None`).",
@@ -103,7 +106,7 @@ export const SCOPE = {
103
106
  ],
104
107
  inputs: ["brainstorm artifact", "timeline constraints", "product priorities"],
105
108
  requiredContext: [
106
- "approved brainstorm direction",
109
+ "approved brainstorm direction with selected option and non-goals",
107
110
  "existing capabilities and reusable components",
108
111
  "delivery deadlines and risk tolerance"
109
112
  ],
@@ -150,7 +153,7 @@ export const SCOPE = {
150
153
  { section: "Landscape Check", required: false, validationRule: "Optional evidence heading for EXPAND/SELECTIVE/deep modes: include reference insight and impact on scope, or omit for compact HOLD SCOPE." },
151
154
  { section: "Taste Calibration", required: false, validationRule: "Optional evidence heading: reference 2-3 strong in-repo modules/files that define the quality bar or justify omission." },
152
155
  { section: "Reference Pattern Registry", required: false, validationRule: "Recommended for SELECTIVE/EXPAND/deep scope: table of pattern/source, accepted/rejected/deferred disposition, invariant to preserve, and boundary impact. Compact HOLD SCOPE may state `Not needed - compact scope`." },
153
- { section: "Reference Pull", required: false, validationRule: "Optional evidence heading: cite ideas pulled from `/Users/zuevrs/Downloads/references` or state no reference pull was needed for compact HOLD SCOPE." },
156
+ { section: "Reference Pull", required: false, validationRule: "Optional evidence heading: cite ideas pulled from `<repo-relative references dir>` or state no reference pull was needed for compact HOLD SCOPE." },
154
157
  { section: "Ambitious Alternatives", required: false, validationRule: "Optional evidence heading for SCOPE EXPANSION/SELECTIVE: list larger alternatives considered and their disposition." },
155
158
  { section: "Ruthless Minimum Slice", required: false, validationRule: "Optional evidence heading for SCOPE REDUCTION or high-risk scope: define the smallest useful wedge and what it proves." },
156
159
  { section: "Requirements", required: false, validationRule: "Table of stable requirement IDs (R1, R2, R3…) one per row with observable outcome, priority, and source. IDs are assigned once and never renumbered across scope/design/spec/plan/review; dropped requirements stay with Priority `DROPPED`." },
@@ -164,10 +167,10 @@ export const SCOPE = {
164
167
  { section: "Error & Rescue Registry", required: false, validationRule: "Each scoped capability has: failure mode, detection method, fallback decision." },
165
168
  { section: "Outside Voice Findings", required: false, validationRule: "Must list external/adversarial findings and disposition (accept/reject/defer) with rationale." },
166
169
  { section: "Scope Outside Voice Loop", required: false, validationRule: `Must record iterations, quality score per iteration, stop reason, and unresolved concerns. Enforce ${reviewLoopPolicySummary("scope")}` },
170
+ { section: "Victory Detector", required: false, validationRule: "Recommended early-loop checkpoint: cite `.cclaw/state/early-loop.json`, current iteration/maxIterations, open concern count, convergence status, and iterate/ready/escalate decision." },
171
+ { section: "Critic Pass", required: false, validationRule: "Recommended producer/critic log contract: each iteration appends one JSONL row to `.cclaw/state/early-loop-log.jsonl` with runId, stage, iteration, and open concerns." },
167
172
  { section: "Completion Dashboard", required: true, validationRule: "Lists per-review-section status, count of critical/open gaps, resolved decisions, and unresolved decisions (or 'None')." },
168
- { section: "Scope Summary", required: true, validationRule: "Compact recap of the locked scope. Must name the selected mode using one canonical token, confidence, explicit drift from brainstorm, unresolved questions, and the track-aware next-stage handoff (`design` for standard, `spec` for medium); the linter checks structure, not English wording." },
169
- { section: "Dream State Mapping", required: false, validationRule: "Deep/optional only: CURRENT STATE, THIS PLAN, 12-MONTH IDEAL, and alignment verdict. Omit for compact scope." },
170
- { section: "Temporal Interrogation", required: false, validationRule: "Deep/optional only: timeline simulation table with decision pressures and lock-now vs defer verdicts. Omit for compact scope." }
173
+ { section: "Scope Summary", required: true, validationRule: "Compact recap of the locked scope. Must name the selected mode using one canonical token, confidence, explicit drift from brainstorm, unresolved questions, and the track-aware next-stage handoff (`design` for standard, `spec` for medium); the linter checks structure, not English wording." }
171
174
  ]
172
175
  },
173
176
  reviewLens: {
@@ -6,8 +6,8 @@ export const SHIP = {
6
6
  schemaShape: "v2",
7
7
  stage: "ship",
8
8
  complexityTier: "standard",
9
- skillFolder: "shipping-and-handoff",
10
- skillName: "shipping-and-handoff",
9
+ skillFolder: "ship",
10
+ skillName: "ship",
11
11
  skillDescription: "Release handoff stage with preflight checks, rollback readiness, and explicit finalization mode for both git and non-git workflows.",
12
12
  philosophy: {
13
13
  hardGate: "Do NOT merge, push, or finalize without a passed preflight check, written rollback plan, and exactly one explicit finalization mode selected. No exceptions for urgency. If no VCS is available, use FINALIZE_NO_VCS explicitly instead of inventing git steps.",
@@ -5,8 +5,8 @@ export const SPEC = {
5
5
  schemaShape: "v2",
6
6
  stage: "spec",
7
7
  complexityTier: "standard",
8
- skillFolder: "specification-authoring",
9
- skillName: "specification-authoring",
8
+ skillFolder: "spec",
9
+ skillName: "spec",
10
10
  skillDescription: "Specification stage. Produce measurable, testable requirements without ambiguity.",
11
11
  philosophy: {
12
12
  hardGate: "Do NOT plan tasks or write implementation code. This stage produces a specification document only. Every requirement must be expressed in observable, testable terms.",
@@ -42,6 +42,7 @@ export const SPEC = {
42
42
  "Document constraints and assumptions — regulatory, system, integration, and performance boundaries. Only non-critical preference/default assumptions may continue; STOP on uncertainty about scope, architecture, security, data loss, public API, migration, auth/pricing, or required user approval.",
43
43
  "Surface assumptions before finalization — list each assumption with source/confidence, validation path, and whether it is accepted, rejected, or still open.",
44
44
  "Build the Acceptance Mapping contract — for each AC, map upstream design decision, observable evidence, verification method, and likely test level. If any column is unclear, rewrite the criterion.",
45
+ "Run Spec Self-Review — explicitly verify placeholder/consistency/scope/ambiguity checks before approval.",
45
46
  "Present acceptance criteria to the user in 3-5-item batches, pausing for explicit ACK between batches (see Interaction Protocol).",
46
47
  "Write spec artifact and request user approval — wait for explicit confirmation before proceeding."
47
48
  ],
@@ -68,6 +69,7 @@ export const SPEC = {
68
69
  { id: "spec_acceptance_measurable", description: "Acceptance criteria are measurable and observable." },
69
70
  { id: "spec_testability_confirmed", description: "Each criterion has a described test method." },
70
71
  { id: "spec_assumptions_surfaced", description: "Assumptions were explicitly reviewed with source/confidence, validation path, and disposition before approval." },
72
+ { id: "spec_self_review_complete", description: "Spec Self-Review covers placeholder, consistency, scope, and ambiguity checks before approval." },
71
73
  { id: "spec_user_approved", description: "User approved the final written spec." }
72
74
  ],
73
75
  requiredEvidence: [
@@ -75,6 +77,7 @@ export const SPEC = {
75
77
  "Each acceptance criterion maps to upstream design decision, observable evidence, verification method, and likely test level.",
76
78
  "Edge cases documented per criterion.",
77
79
  "Assumptions Before Finalization section records source/confidence, validation path, and accepted/rejected/open disposition.",
80
+ "Spec Self-Review section covers placeholder, consistency, scope, and ambiguity checks with any patches noted.",
78
81
  "Approval marker captured in artifact.",
79
82
  "For quick bug-fix specs, reproduction contract records symptom, repro steps, expected RED test, and acceptance criterion."
80
83
  ],
@@ -119,9 +122,12 @@ export const SPEC = {
119
122
  { section: "Constraints and Assumptions", required: false, validationRule: "All implicit assumptions surfaced. Constraints have sources." },
120
123
  { section: "Assumptions Before Finalization", required: true, validationRule: "Each assumption has source/confidence, validation path, and accepted/rejected/open disposition before the Approval section is finalized." },
121
124
  { section: "Acceptance Mapping", required: true, validationRule: "Each criterion maps to upstream design decision, observable evidence, verification method, likely test level (unit/integration/e2e/manual), and command or manual steps when known." },
122
- { section: "Vague to Fixed", required: false, validationRule: "If present: table with original vague wording and rewritten observable/testable version for each ambiguous requirement." },
123
125
  { section: "Non-Functional Requirements", required: false, validationRule: "If present: performance thresholds, security constraints, scalability limits, reliability targets with measurable values." },
124
126
  { section: "Interface Contracts", required: false, validationRule: "If present: for each module boundary list produces (outputs) and consumes (inputs) with data types." },
127
+ { section: "Synthesis Sources", required: false, validationRule: "If present: cite at least one upstream/context source with what it supplied and confidence." },
128
+ { section: "Behavior Contract", required: false, validationRule: "If present: list >=3 behaviors in user-story or Given/When/Then shape (or `- None.` for single-step specs)." },
129
+ { section: "Architecture Modules", required: false, validationRule: "If present: module responsibilities only (no code fences or function/class signatures); keep module count within a single coherent subsystem." },
130
+ { section: "Spec Self-Review", required: true, validationRule: "Must explicitly cover placeholder, consistency, scope, and ambiguity checks plus applied patches/remaining concerns." },
125
131
  { section: "Approval", required: true, validationRule: "Explicit user approval marker present." }
126
132
  ]
127
133
  },
@@ -6,8 +6,8 @@ export const TDD = {
6
6
  schemaShape: "v2",
7
7
  stage: "tdd",
8
8
  complexityTier: "standard",
9
- skillFolder: "test-driven-development",
10
- skillName: "test-driven-development",
9
+ skillFolder: "tdd",
10
+ skillName: "tdd",
11
11
  skillDescription: "Full vertical-slice TDD cycle: discover existing tests and system impact, then RED (failing tests), GREEN (minimal implementation), REFACTOR (cleanup). One source item at a time with strict traceability.",
12
12
  philosophy: {
13
13
  hardGate: "Do NOT merge, ship, or skip review. Follow RED → GREEN → REFACTOR strictly for each plan slice. Do NOT write implementation code before RED tests exist. Do NOT write RED tests before discovering relevant existing tests and impacted contracts. Do NOT skip the REFACTOR step.",
@@ -70,7 +70,7 @@ export const TDD = {
70
70
  "Use incremental RED/GREEN/REFACTOR commits when the repository workflow and working tree make that appropriate; otherwise record the checkpoint boundaries in the artifact.",
71
71
  "Stop if regressions appear and fix before proceeding.",
72
72
  "If a test passes unexpectedly, investigate: does the behavior already exist, or is the test wrong?",
73
- "**Per-Slice Review point (conditional, opt-in).** When `.cclaw/config.yaml::sliceReview.enabled` is true, check every slice against the triggers before declaring it DONE. Triggers: `touchCount >= filesChangedThreshold`, any `touchPaths` match a `touchTriggers` glob, or the plan row declares `highRisk: true`. On a trigger, run two passes on the slice alone — (1) Spec-Compliance: trace RED/GREEN/REFACTOR evidence back to its plan task + spec criterion, noting edge cases the tests skip; (2) Quality: diff-scan for naming, error handling, dead code, simpler alternatives. Record both under `## Per-Slice Review` in `06-tdd.md`, naming the trigger that fired. Dispatch the `reviewer` subagent natively when available (log `fulfillmentMode: \"isolated\"`); otherwise fulfil via in-session role switch (`fulfillmentMode: \"role-switch\"`). Never fabricate an isolated pass from memory. Tracks outside `sliceReview.enforceOnTracks` still emit the section; doctor only escalates missed reviews on enforced tracks."
73
+ "**Per-Slice Review point (conditional, opt-in).** When `.cclaw/config.yaml::sliceReview.enabled` is true, check every slice against the triggers before declaring it DONE. Triggers: `touchCount >= filesChangedThreshold`, any `touchPaths` match a `touchTriggers` glob, or the plan row declares `highRisk: true`. On a trigger, run two passes on the slice alone — (1) Spec-Compliance: trace RED/GREEN/REFACTOR evidence back to its plan task + spec criterion, noting edge cases the tests skip; (2) Quality: diff-scan for naming, error handling, dead code, simpler alternatives. Record both under `## Per-Slice Review` in `06-tdd.md`, naming the trigger that fired. Dispatch the `reviewer` subagent natively when available (log `fulfillmentMode: \"isolated\"`); otherwise fulfil via in-session role switch (`fulfillmentMode: \"role-switch\"`). Never fabricate an isolated pass from memory. Tracks outside `sliceReview.enforceOnTracks` still emit the section; sync only escalates missed reviews on enforced tracks."
74
74
  ],
75
75
  process: [
76
76
  "Select one vertical slice and map it to acceptance criterion(s).",
@@ -93,6 +93,9 @@ export const TDD = {
93
93
  { id: "tdd_green_full_suite", description: "Full relevant suite passes in GREEN state." },
94
94
  { id: "tdd_refactor_completed", description: "Refactor pass completed with behavior preservation verified." },
95
95
  { id: "tdd_verified_before_complete", description: "Fresh verification evidence includes test command, explicit pass/fail status, and a config-aware ref: commit SHA when VCS is present/required or an explicit no-VCS attestation when allowed." },
96
+ { id: "tdd_iron_law_acknowledged", description: "Iron Law acknowledgement is explicit (`Acknowledged: yes`) before implementation proceeds." },
97
+ { id: "tdd_watched_red_observed", description: "Watched-RED Proof records at least one observed failing test with ISO timestamp evidence." },
98
+ { id: "tdd_slice_cycle_complete", description: "Vertical Slice Cycle records RED, GREEN, and REFACTOR phases per active slice." },
96
99
  { id: "tdd_traceable_to_plan", description: "Change traceability to plan slice is explicit." },
97
100
  { id: "tdd_docs_drift_check", description: "When public API/config/CLI surfaces change, docs drift is addressed via a completed doc-updater pass." }
98
101
  ],
@@ -104,6 +107,9 @@ export const TDD = {
104
107
  "Failing command output captured (RED).",
105
108
  "Full test/build output recorded (GREEN).",
106
109
  "Fresh verification evidence recorded with command, PASS/FAIL status, and config-aware commit SHA or no-VCS reason plus content/artifact hash before completion.",
110
+ "Iron Law Acknowledgement section explicitly states `Acknowledged: yes`.",
111
+ "Watched-RED Proof includes at least one populated row with an ISO timestamp.",
112
+ "Vertical Slice Cycle records RED, GREEN, and REFACTOR per active slice.",
107
113
  "Acceptance mapping documented.",
108
114
  "Failure reason analysis recorded.",
109
115
  "Refactor rationale captured.",
@@ -155,10 +161,14 @@ export const TDD = {
155
161
  { section: "GREEN Evidence", required: true, validationRule: "Full suite pass output captured." },
156
162
  { section: "REFACTOR Notes", required: true, validationRule: "What changed, why, behavior preservation confirmed." },
157
163
  { section: "Traceability", required: true, validationRule: "Plan task ID and spec criterion linked." },
164
+ { section: "Iron Law Acknowledgement", required: true, validationRule: "Must include `Acknowledged: yes` and list exceptions (or `None`)." },
165
+ { section: "Watched-RED Proof", required: true, validationRule: "At least one populated row with ISO timestamp proving RED was observed before production edits." },
166
+ { section: "Vertical Slice Cycle", required: true, validationRule: "Per active slice records RED, GREEN, and REFACTOR timestamps (refactor may be deferred only with explicit rationale)." },
158
167
  { section: "Verification Ladder", required: true, validationRule: "Per-slice verification tier (static, command, behavioral, human) with evidence captured for the highest tier reached this turn. Must include command + PASS/FAIL + commit SHA when VCS is present, or explicit no-vcs reason plus content/artifact hash/config override." },
159
168
  { section: "TDD Blocker Taxonomy", required: false, validationRule: "When blocked, classify as NO_SOURCE_CONTEXT, NO_TEST_SURFACE, NO_IMPLEMENTABLE_SLICE, RED_NOT_EXPRESSIBLE, or NO_VCS_MODE; include blockedBecause, missingInputs, recommendedRoute, nextCommand, and resumeCriteria." },
160
169
  { section: "Coverage Targets", required: false, validationRule: "If present: per-module or per-code-type coverage thresholds with current values and measurement commands." },
161
170
  { section: "Test Pyramid Shape", required: false, validationRule: "If present: per-slice count of Small/Medium/Large tests added, to let reviewers verify the suite is not drifting top-heavy." },
171
+ { section: "Mock Preference Order", required: false, validationRule: "When mocks/spies appear in Test Discovery or RED Evidence, prefer Real > Fake > Stub > Mock. Mock-heavy slices should include explicit boundary justification (for example network/fs/time/external trust boundaries)." },
162
172
  { section: "Prove-It Reproduction", required: false, validationRule: "Required for bug-fix slices: original failing reproduction test (RED without fix), passing output with fix (GREEN), and a note confirming the test fails again if the fix is reverted." },
163
173
  { section: "Per-Slice Review", required: false, validationRule: "When `.cclaw/config.yaml::sliceReview.enabled` is true: per triggered slice, a two-part record — Spec-Compliance (slice <-> plan task <-> spec criterion trace plus edge-case notes) and Quality (diff-focused review of naming, error handling, dead code, simpler alternatives). Each entry names the trigger (touchCount, touchPaths glob, or highRisk) and the delegation fulfillmentMode (`isolated` when a reviewer subagent was dispatched natively; `role-switch` when fulfilled in-session). Slices that did not meet any trigger may list `not triggered` instead of a full pass." }
164
174
  ]
@@ -216,7 +226,7 @@ export const TDD = {
216
226
  evaluationPoints: [
217
227
  "When `.cclaw/config.yaml::sliceReview.enabled` is true: does every triggered slice (touchCount >= threshold, touchPaths match, or highRisk=true) carry a Per-Slice Review entry with BOTH a Spec-Compliance pass (plan task <-> spec criterion + edge-case notes) AND a Quality pass (diff-level naming/errors/dead code/simpler alternatives)?",
218
228
  "Is the delegation `fulfillmentMode` recorded (`isolated` for a dispatched reviewer subagent, `role-switch` for an in-session pass) and does it match an entry in `.cclaw/state/delegation-log.json`?",
219
- "On tracks listed in `sliceReview.enforceOnTracks`, are there zero missed triggered slices (doctor also surfaces this as a warning)?"
229
+ "On tracks listed in `sliceReview.enforceOnTracks`, are there zero missed triggered slices (sync also surfaces this as a warning)?"
220
230
  ],
221
231
  stopGate: false
222
232
  },
@@ -20,7 +20,7 @@ export function startCommandContract() {
20
20
 
21
21
  **The unified entry point for the cclaw flow.**
22
22
 
23
- - \`/cc\` (no arguments) → reads existing flow state and resumes/progresses the active flow. If flow state is missing or still a fresh init placeholder, stop and guide the user to run \`/cc <prompt>\` or \`cclaw init\`; do not silently create a brainstorm run.
23
+ - \`/cc\` (no arguments) → reads existing flow state and resumes/progresses the active flow. If flow state is missing or still a fresh init placeholder, stop and guide the user to run \`/cc <prompt>\` or \`npx cclaw-cli init\`; do not silently create a brainstorm run.
24
24
  - \`/cc <prompt>\` (with an idea/description) → saves the prompt as idea context and starts the first stage of the resolved track.
25
25
 
26
26
  This is the **recommended way to start, resume, and continue** working with cclaw.
@@ -93,8 +93,8 @@ ${conversationLanguagePolicyMarkdown()}
93
93
  If this helper fails, STOP and report the exact command/output. Do **not** manually edit \`${flowPath}\`.
94
94
  11. The helper persists \`${flowPath}\`, computes \`skippedStages\`, sets the first stage for the track, resets the gate catalog, and writes \`.cclaw/artifacts/00-idea.md\`.
95
95
  12. Load the **first-stage skill for the chosen track** and its command file:
96
- - quick → \`.cclaw/skills/specification-authoring/SKILL.md\`
97
- - medium/standard → \`.cclaw/skills/brainstorming/SKILL.md\`
96
+ - quick → \`.cclaw/skills/spec/SKILL.md\`
97
+ - medium/standard → \`.cclaw/skills/brainstorm/SKILL.md\`
98
98
  - trivial fast-path → quick track spec skill per Phase 0 decision.
99
99
  13. Execute that stage with the prompt + Phase 1/Phase 2 + seed context as initial input.
100
100
 
@@ -110,21 +110,22 @@ If during any stage the agent discovers evidence that contradicts the initial Ph
110
110
  ### Without prompt (\`/cc\`)
111
111
 
112
112
  1. Read \`${flowPath}\`.
113
- 2. If flow state is missing → guide the user to run \`cclaw init\` and stop.
113
+ 2. If flow state is missing → guide the user to run \`npx cclaw-cli init\` and stop.
114
114
  3. If flow state is only a fresh init placeholder (\`completedStages: []\`, all \`passed\` arrays empty, and no \`00-idea.md\`) → stop and ask for \`/cc <prompt>\` to start a tracked run. Do not create a brainstorm state implicitly.
115
115
  4. Otherwise check current stage gates, resume if incomplete, and advance if complete.
116
116
 
117
- ## Headless mode
117
+ ## Headless mode (CI/automation only)
118
118
 
119
- When called by another skill or subagent in machine mode, emit exactly one
120
- JSON envelope (no prose) and stop:
119
+ Headless envelopes are a machine-mode exception for CI/automation orchestration.
120
+ In normal interactive runs, respond in natural language instead of emitting an envelope.
121
+ When called by another skill or subagent in machine mode, emit exactly one JSON envelope (no prose) and stop:
121
122
 
122
123
  \`\`\`json
123
124
  {"version":"1","kind":"stage-output","stage":"<currentStage>","payload":{"command":"/cc","track":"<track>","action":"start_or_resume"},"emittedAt":"<ISO-8601>"}
124
125
  \`\`\`
125
126
 
126
127
  Validate envelopes with:
127
- \`cclaw internal envelope-validate --stdin\`
128
+ \`npx cclaw-cli internal envelope-validate --stdin\`
128
129
 
129
130
  ## Primary skill
130
131
 
@@ -187,7 +188,7 @@ ${conversationLanguagePolicyMarkdown()}
187
188
  - On conflict, prefer \`standard\` over \`medium\`, and \`medium\` over \`quick\`.
188
189
  - Always state the recommendation as a one-line reason citing matched triggers and a high/medium/low track selection confidence. Clarify that the heuristic is advisory until the managed helper writes state; after that, \`/cc\` follows the selected track. Include override guidance: switch to standard when architecture, schema, migration, security, or unclear scope appears; switch to medium when product framing is needed but architecture is known.
189
190
  8. Run the managed start helper: \`node .cclaw/hooks/start-flow.mjs --track=<quick|medium|standard> --class=<class> --prompt=<prompt> --stack=<stack> --reason=<matched heuristic>\`. The helper writes \`${flowPath}\`, computes \`skippedStages\`, resets the gate catalog, and writes \`${RUNTIME_ROOT}/artifacts/00-idea.md\`. If it fails, STOP and report the exact command/output; do not manually edit flow state.
190
- 9. Load and execute the **first stage skill of the chosen track** (\`brainstorming\` for medium/standard, \`specification-authoring\` for quick) plus its matching command file.
191
+ 9. Load and execute the **first stage skill of the chosen track** (\`brainstorm\` for medium/standard, \`spec\` for quick) plus its matching command file.
191
192
 
192
193
  ### Reclassification on discovery
193
194
 
@@ -198,7 +199,7 @@ If mid-stage evidence contradicts the initial Class/Track decision (the "trivial
198
199
  Progress the tracked flow only when one exists:
199
200
 
200
201
  1. Read \`${flowPath}\`.
201
- 2. If missing, guide the user to run \`cclaw init\` and stop.
202
+ 2. If missing, guide the user to run \`npx cclaw-cli init\` and stop.
202
203
  3. If it is only a fresh init placeholder (\`completedStages: []\`, no passed gates, and no \`${RUNTIME_ROOT}/artifacts/00-idea.md\`), stop and ask for \`/cc <prompt>\` to start a tracked run. Do not silently create a brainstorm run.
203
204
  4. Check gates for \`currentStage\`.
204
205
  5. If incomplete → load current stage skill and execute.
@@ -45,7 +45,7 @@ a read-only command.
45
45
 
46
46
  ## Algorithm
47
47
 
48
- 1. Read \`${flowPath}\`. If missing → report **BLOCKED: flow state absent** and suggest \`cclaw init\`.
48
+ 1. Read \`${flowPath}\`. If missing → report **BLOCKED: flow state absent** and suggest \`npx cclaw-cli init\`.
49
49
  2. Read \`${delegationPath}\`. Missing → treat all mandatory delegations as pending.
50
50
  3. Render **time in stage** as \`(unknown)\` unless visible conversation or
51
51
  artifact handoff context gives a timestamp.
@@ -81,7 +81,7 @@ a read-only command.
81
81
  - If current stage has unmet gates -> \`/cc\` to resume.
82
82
  - If a mandatory delegation is missing evidence -> dispatch the worker/reviewer or waive with rationale; do not advance silently.
83
83
  - If a TDD blocker taxonomy code is present (\`NO_SOURCE_CONTEXT\`, \`NO_TEST_SURFACE\`, \`NO_IMPLEMENTABLE_SLICE\`, \`RED_NOT_EXPRESSIBLE\`, \`NO_VCS_MODE\`) -> name the blocker and the rewind/config route.
84
- - If review is blocked by critical findings -> show \`cclaw internal rewind tdd "review_blocked_by_critical <finding-ids>"\` plus the later \`cclaw internal rewind --ack tdd\`.
84
+ - If review is blocked by critical findings -> show \`npx cclaw-cli internal rewind tdd "review_blocked_by_critical <finding-ids>"\` plus the later \`npx cclaw-cli internal rewind --ack tdd\`.
85
85
  - If closeout substate is non-idle -> \`/cc\` to continue the chain.
86
86
  - If current stage is complete -> \`/cc\` to advance (or report "Flow complete" if terminal).
87
87
 
@@ -98,7 +98,7 @@ a read-only command.
98
98
 
99
99
  ## Anti-patterns
100
100
 
101
- - Rebuilding trace-matrix or running doctor from \`/cc-view status\` — those belong to dedicated tools.
101
+ - Rebuilding trace-matrix or running sync from \`/cc-view status\` — those belong to dedicated tools.
102
102
  - Treating absence of delegation log as "all delegations complete".
103
103
  - Collapsing \`◎ missing-evidence\` into \`✓ completed\` — role-switch gaps must stay
104
104
  visible so the stage cannot advance silently.