cclaw-cli 7.7.1 → 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 -768
  24. package/dist/content/decision-protocol.d.ts +1 -12
  25. package/dist/content/decision-protocol.js +27 -20
  26. package/dist/content/examples.d.ts +8 -42
  27. package/dist/content/examples.js +293 -425
  28. package/dist/content/idea-command.d.ts +2 -0
  29. package/dist/content/idea-command.js +38 -0
  30. package/dist/content/iron-laws.d.ts +4 -138
  31. package/dist/content/iron-laws.js +18 -197
  32. package/dist/content/meta-skill.d.ts +1 -3
  33. package/dist/content/meta-skill.js +57 -134
  34. package/dist/content/node-hooks.d.ts +12 -8
  35. package/dist/content/node-hooks.js +188 -838
  36. package/dist/content/recovery.d.ts +8 -0
  37. package/dist/content/recovery.js +179 -0
  38. package/dist/content/reference-patterns.d.ts +4 -13
  39. package/dist/content/reference-patterns.js +260 -389
  40. package/dist/content/research-playbooks.d.ts +8 -8
  41. package/dist/content/research-playbooks.js +108 -121
  42. package/dist/content/review-loop.d.ts +6 -192
  43. package/dist/content/review-loop.js +29 -731
  44. package/dist/content/skills.d.ts +8 -38
  45. package/dist/content/skills.js +681 -732
  46. package/dist/content/specialist-prompts/architect.d.ts +1 -0
  47. package/dist/content/specialist-prompts/architect.js +225 -0
  48. package/dist/content/specialist-prompts/brainstormer.d.ts +1 -0
  49. package/dist/content/specialist-prompts/brainstormer.js +168 -0
  50. package/dist/content/specialist-prompts/index.d.ts +2 -0
  51. package/dist/content/specialist-prompts/index.js +14 -0
  52. package/dist/content/specialist-prompts/planner.d.ts +1 -0
  53. package/dist/content/specialist-prompts/planner.js +182 -0
  54. package/dist/content/specialist-prompts/reviewer.d.ts +1 -0
  55. package/dist/content/specialist-prompts/reviewer.js +193 -0
  56. package/dist/content/specialist-prompts/security-reviewer.d.ts +1 -0
  57. package/dist/content/specialist-prompts/security-reviewer.js +133 -0
  58. package/dist/content/specialist-prompts/slice-builder.d.ts +1 -0
  59. package/dist/content/specialist-prompts/slice-builder.js +232 -0
  60. package/dist/content/stage-playbooks.d.ts +8 -0
  61. package/dist/content/stage-playbooks.js +404 -0
  62. package/dist/content/start-command.d.ts +2 -12
  63. package/dist/content/start-command.js +221 -207
  64. package/dist/flow-state.d.ts +21 -178
  65. package/dist/flow-state.js +67 -170
  66. package/dist/fs-utils.d.ts +6 -26
  67. package/dist/fs-utils.js +29 -162
  68. package/dist/gitignore.d.ts +2 -1
  69. package/dist/gitignore.js +51 -34
  70. package/dist/harness-detect.d.ts +10 -0
  71. package/dist/harness-detect.js +29 -0
  72. package/dist/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 -44
  193. package/dist/execution-topology.js +0 -95
  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 -74
  258. package/dist/internal/wave-status.js +0 -506
  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,471 +1,339 @@
1
- export const BEHAVIOR_ANCHORS = [
2
- {
3
- stage: "brainstorm",
4
- section: "Problem Decision Record",
5
- bad: "Frame the problem broadly and quietly add a second outcome (\"and while we're at it, refresh the dashboard\") that no Q&A row sanctioned.",
6
- good: "Name one affected user, one current failure mode, and one observable outcome; record any extra outcome as a separate row in `## Not Doing`.",
7
- ruleHint: "Scope creep starts in framing keep the Problem Decision Record single-target."
8
- },
9
- {
10
- stage: "scope",
11
- section: "Scope Contract",
12
- bad: "Invent a contract from a hunch: \"I'll let the user choose 3 templates\" with no Q&A row, no user feedback citation, no upstream decision.",
13
- good: "Cite the Q&A row or upstream decision (`brainstorm > Selected Direction`) that produced each in/out boundary; refuse to lock without that citation.",
14
- ruleHint: "Every scope contract row must trace to a recorded user signal or carried-forward decision."
15
- },
16
- {
17
- stage: "design",
18
- section: "Codebase Investigation",
19
- bad: "Open with \"Use a queue + worker pool\" before reading any file; the architecture choice precedes the trace and the diagram has no concrete node.",
20
- good: "List 1-3 blast-radius files in `Codebase Investigation` with current responsibility and reuse candidate first; only then propose architecture in `ADR`.",
21
- ruleHint: "Trace before lock — no architecture decision lands without a codebase citation."
22
- },
23
- {
24
- stage: "spec",
25
- section: "Acceptance Criteria",
26
- bad: "AC: \"System should be fast and reliable\"no measurable predicate, no verification approach, no design-decision ref.",
27
- good: "AC: \"GET /feed returns ≤ 50 items in < 200 ms p95; verified via integration test `tests/feed.spec.ts` against scope `R-2`.\"",
28
- ruleHint: "Every AC carries an observable predicate plus the exact evidence command or path that proves it."
29
- },
30
- {
31
- stage: "plan",
32
- section: "Execution Posture",
33
- bad: "Posture: \"parallel-safe\" with three units that all edit the same `src/api/router.ts`; no shared interface contract, no boundary map.",
34
- good: "Posture: \"parallel-safe\" only when each Implementation Unit owns disjoint files and the shared types live in one cited interface contract entry.",
35
- ruleHint: "Parallelization needs disjoint units AND a single shared interface contract — claim otherwise and the next batch deadlocks."
36
- },
37
- {
38
- stage: "tdd",
39
- section: "RED Evidence",
40
- bad: "Controller edits production code or per-slice prose directly, skips ledger rows, then hand-edits auto-render tables. Slice workers never ran; lint blocks on missing span history.",
41
- good: "`Task(\"slice-builder --slice S-1 --paths …\")` when major ≥7; otherwise the historical trio must still log `phase=red|green|doc` rows. Controller records before dispatch; linter mirrors history into auto-render blocks.",
42
- ruleHint: "Wave-status first, record-before-dispatch, one delegated worker owns RED→GREEN→REFACTOR→slice doc; controller stays out of production edits."
43
- },
44
- {
45
- stage: "review",
46
- section: "Layer 2 Findings",
47
- bad: "Slip in a rename of `userSvc` → `userService` and a folder reorg under \"Layer 2: cleanup\"; no acceptance criterion or finding ID demanded the change.",
48
- good: "Findings name observed defects with `file:line`; refactors land as a separate slice with their own RED/GREEN, not bundled into the review pass.",
49
- ruleHint: "Review surfaces findings; it does not refactor. Drive-by edits go back through TDD."
50
- },
51
- {
52
- stage: "ship",
53
- section: "Preflight Results",
54
- bad: "Preflight: \"Looks good, tests passed last night\"; no fresh command output, no commit SHA, no exit code.",
55
- good: "Preflight: paste the command, the exit code, and the commit SHA from this turn; if the suite was not re-run after the last edit, mark BLOCKED.",
56
- ruleHint: "Victory-by-confidence is not a preflight. Re-run, capture, cite SHA — or stay BLOCKED."
57
- }
58
- ];
59
- const BEHAVIOR_ANCHOR_BY_STAGE = new Map(BEHAVIOR_ANCHORS.map((entry) => [entry.stage, entry]));
60
- export function behaviorAnchorFor(stage) {
61
- return BEHAVIOR_ANCHOR_BY_STAGE.get(stage) ?? null;
62
- }
63
- /**
64
- * Render the one-line "Behavior anchor (bad → good)" pointer used at the top
65
- * of each artifact template (01..08). Templates carry the anchor inline so
66
- * agents see it before they start filling sections; the prose itself lives
67
- * only in `BEHAVIOR_ANCHORS` to avoid duplication.
68
- */
69
- export function renderBehaviorAnchorTemplateLine(stage) {
70
- const anchor = behaviorAnchorFor(stage);
71
- if (!anchor)
72
- return "";
73
- return `> Behavior anchor (bad -> good) — ${anchor.section}: bad: ${anchor.bad} good: ${anchor.good}`;
74
- }
75
- const STAGE_EXAMPLES = {
76
- brainstorm: `## Context
77
-
78
- - Project state: release checks exist but CI/local behavior drifts.
79
- - Existing anchors: \`scripts/pre-publish.sh\`, \`src/release/\`, incident notes.
80
-
81
- ## Q&A Log
82
-
83
- | Turn | Question | User answer (1-line) | Decision impact |
1
+ const PLAN_SMALL = `---
2
+ slug: approval-pill
3
+ stage: plan
4
+ status: active
5
+ ac:
6
+ - id: AC-1
7
+ text: "Approval status pill renders pending/approved/rejected on the dashboard tile."
8
+ status: pending
9
+ - id: AC-2
10
+ text: "Pill shows a tooltip with approver name and request age when status != pending."
11
+ status: pending
12
+ last_specialist: planner
13
+ refines: null
14
+ shipped_at: null
15
+ ship_commit: null
16
+ review_iterations: 0
17
+ security_flag: false
18
+ ---
19
+
20
+ # approval-pill
21
+
22
+ Add a status pill on the dashboard's request card so users can spot the approval lifecycle at a glance instead of opening the request modal.
23
+
24
+ ## Context
25
+
26
+ The dashboard currently lists pending and approved requests in two flat tables. Customer support has been pasting the request id into the modal to read the approver that workflow is slow. We can keep the existing tables but add a single 56×24 pill that encodes the same information visually.
27
+
28
+ ## Frame
29
+
30
+ - Already true: \`Request\` model has \`status\`, \`approverId\`, \`requestedAt\`. \`User\` model has \`displayName\`.
31
+ - Not sure: whether designers want the pill to animate on status change. We default to no animation.
32
+ - Out of scope: the modal itself; approver workflows; mobile layout.
33
+
34
+ ## Scope
35
+
36
+ - **In scope:** \`src/components/dashboard/RequestCard.tsx\`, \`src/components/dashboard/StatusPill.tsx\` (new), \`src/components/dashboard/StatusPill.test.tsx\` (new), \`src/styles/tokens.css\` (3 colour tokens).
37
+ - **Out of scope:** \`src/components/dashboard/RequestModal.tsx\`, mobile breakpoints, dark mode.
38
+
39
+ ## Plan
40
+
41
+ - Phase 1 Foundation
42
+ - Add \`StatusPill\` component with three variants (\`pending\`, \`approved\`, \`rejected\`) \`src/components/dashboard/StatusPill.tsx\`.
43
+ - Add the three colour tokens — \`src/styles/tokens.css:42\`.
44
+ - Phase 2 — Wiring
45
+ - Render \`StatusPill\` inside \`RequestCard\` — \`src/components/dashboard/RequestCard.tsx:88\`.
46
+ - Surface the tooltip with approver name + relative time — \`src/components/dashboard/RequestCard.tsx:90\`.
47
+
48
+ ## Acceptance Criteria
49
+
50
+ | id | text | status | commit |
84
51
  | --- | --- | --- | --- |
85
- | 1 | Block invalid releases or only warn? | Block. | Validation is a hard gate. |
86
- | 2 | Shared module or script-only patch? | Shared module. | Reuse in CI/local. |
87
- | 3 | (stop-signal) | "достаточно, давай драфт" | stop-and-draft |
52
+ | AC-1 | Approval status pill renders pending/approved/rejected on the dashboard tile. | pending | |
53
+ | AC-2 | Pill shows a tooltip with approver name and request age when status != pending. | pending | |
54
+
55
+ ## Topology
56
+
57
+ - topology: inline
58
+ - parallel slices: none
59
+
60
+ ## Traceability block
61
+
62
+ - AC-1 → commit pending
63
+ - AC-2 → commit pending
64
+ `;
65
+ const PLAN_PARALLEL_BUILD = `---
66
+ slug: search-overhaul
67
+ stage: plan
68
+ status: active
69
+ ac:
70
+ - id: AC-1
71
+ text: "Search index includes ticket comments alongside titles."
72
+ status: pending
73
+ - id: AC-2
74
+ text: "Search ranking uses BM25 instead of plain TF."
75
+ status: pending
76
+ - id: AC-3
77
+ text: "Search UI surfaces a \\"comments matched\\" badge."
78
+ status: pending
79
+ - id: AC-4
80
+ text: "Search API returns matched-comments fixture in integration tests."
81
+ status: pending
82
+ last_specialist: planner
83
+ refines: null
84
+ shipped_at: null
85
+ ship_commit: null
86
+ review_iterations: 0
87
+ security_flag: false
88
+ ---
89
+
90
+ # search-overhaul
91
+
92
+ ## Topology
93
+
94
+ - topology: parallel-build
95
+ - parallel slices:
96
+ - AC-1, AC-2 → slice-builder #1 (backend) — owners: \`src/server/search/*\`, \`src/server/db/migrations/2026-05-07-bm25.sql\`
97
+ - AC-3 → slice-builder #2 (frontend) — owner: \`src/client/search/Hits.tsx\`
98
+ - AC-4 → slice-builder #3 (integration tests) — owner: \`tests/integration/search.spec.ts\`
99
+ - integration reviewer: \`reviewer #integration\` after the wave finishes.
100
+
101
+ (File set per slice is disjoint; AC-3 does not depend on AC-1/AC-2 because the badge is purely presentational and can use a feature flag for the first review pass.)
102
+
103
+ ## Plan
104
+
105
+ (See per-slice owner files; do not merge them into one log. The integration reviewer reconstructs the picture from \`builds/search-overhaul.md\` after the wave.)
106
+
107
+ ## Acceptance Criteria
108
+
109
+ | id | text | status | commit |
110
+ | --- | --- | --- | --- |
111
+ | AC-1 | Search index includes ticket comments alongside titles. | pending | — |
112
+ | AC-2 | Search ranking uses BM25 instead of plain TF. | pending | — |
113
+ | AC-3 | Search UI surfaces a "comments matched" badge. | pending | — |
114
+ | AC-4 | Search API returns matched-comments fixture in integration tests. | pending | — |
115
+
116
+ ## Traceability block
88
117
 
89
- ## Problem Decision Record
118
+ - AC-1 commit pending
119
+ - AC-2 → commit pending
120
+ - AC-3 → commit pending
121
+ - AC-4 → commit pending
122
+ `;
123
+ const BUILD_LOG = `---
124
+ slug: approval-pill
125
+ stage: build
126
+ status: active
127
+ build_iterations: 2
128
+ last_commit: 9e2c3a4
129
+ ---
90
130
 
91
- - Depth: standard
92
- - Frame type: \`technical-maintenance\`
93
- - Affected user / role / operator: release operator
94
- - Current state / failure mode / opportunity: inconsistent validation paths
95
- - Desired outcome (observable): one deterministic preflight in CI and local flows
96
- - Evidence / signal: repeated metadata drift incidents
97
- - Why now: recurring operational cost on every release
98
- - Do-nothing consequence: continued publish risk
99
- - Non-goals: no release framework rewrite
131
+ # Build log — approval-pill
100
132
 
101
- ## Clarifying Questions
133
+ ## Plan summary
102
134
 
103
- | # | Question | Answer | Decision impact |
135
+ Two AC: pill component + tooltip with approver name. Inline topology, single slice-builder.
136
+
137
+ ## Commits
138
+
139
+ | AC | commit | files | note |
104
140
  | --- | --- | --- | --- |
105
- | 1 | Block invalid releases or only warn? | Block. | Validation is a hard gate. |
106
- | 2 | Shared module or script-only patch? | Shared module. | Reuse in CI/local. |
141
+ | AC-1 | a1b2c3d | \`src/components/dashboard/StatusPill.tsx:1-58\`, \`src/components/dashboard/StatusPill.test.tsx:1-44\`, \`src/styles/tokens.css:42-44\` | Three variants, snapshot test for each. |
142
+ | AC-2 | 9e2c3a4 | \`src/components/dashboard/RequestCard.tsx:88-104\`, \`src/components/dashboard/RequestCard.test.tsx:51-72\` | Wires \`StatusPill\` + tooltip. Uses existing \`<Tooltip>\` from \`src/components/Tooltip.tsx\`. |
143
+
144
+ ## Open work
107
145
 
108
- ## Approach Tier
146
+ _(none both AC are committed.)_
109
147
 
110
- - Tier: standard
111
- - Why this tier: cross-cutting release path change, bounded subsystem
148
+ ## Hooks invoked
112
149
 
113
- ## Approaches
150
+ - \`commit-helper.mjs --ac=AC-1 --message="Add StatusPill component with three variants"\` → \`a1b2c3d\`
151
+ - \`commit-helper.mjs --ac=AC-2 --message="Wire StatusPill + tooltip into RequestCard"\` → \`9e2c3a4\`
152
+
153
+ ## Notes
114
154
 
115
- | Approach | Role | Upside | Architecture | Trade-offs | Recommendation |
155
+ - \`<Tooltip>\` component already supports a \`delay\` prop; reused the 250 ms token from \`src/styles/tokens.css\` instead of hardcoding.
156
+ - Snapshot tests use \`@testing-library/react\` v15 \`render\` API; same as adjacent tests, no test-config changes needed.
157
+ `;
158
+ const REVIEW_LOG = `---
159
+ slug: approval-pill
160
+ stage: review
161
+ status: active
162
+ review_iterations: 2
163
+ modes_run:
164
+ - code
165
+ - text-review
166
+ findings_block:
167
+ - F-1
168
+ - F-2
169
+ ---
170
+
171
+ # Review — approval-pill
172
+
173
+ ## Run summary
174
+
175
+ | iteration | mode | reviewer | result |
176
+ | --- | --- | --- | --- |
177
+ | 1 | code | reviewer | block |
178
+ | 2 | code | reviewer | clear |
179
+
180
+ ## Findings
181
+
182
+ | id | severity | AC | location | finding | fix |
116
183
  | --- | --- | --- | --- | --- | --- |
117
- | Shared validator module | baseline | high | Typed checks reused by CI/local | Medium effort | **Recommended** |
118
- | Script hardening only | challenger | high | Keep shell checks | Fast but drift risk remains | Fallback |
184
+ | F-1 | block | AC-1 | \`src/components/dashboard/StatusPill.tsx:23\` | The \`rejected\` variant uses the same red token as warning banners; designers want a separate "muted red" token. | Add \`--color-status-rejected\` to \`src/styles/tokens.css\` and reference it. |
185
+ | F-2 | warn | AC-2 | \`src/components/dashboard/RequestCard.tsx:97\` | Tooltip text uses absolute timestamps; product asked for relative ("2 hours ago"). | Replace with \`formatRelativeTime\` from \`src/lib/time.ts\`. |
119
186
 
120
- ## Approach Reaction
187
+ ## Five Failure Modes pass
121
188
 
122
- - Closest option: shared validator module
123
- - Concerns: keep v1 delivery tight; avoid framework creep
124
- - What changed after reaction: kept module path and added incremental rollout guardrails
189
+ Iteration 1:
125
190
 
126
- ## Challenger Alternative Enforcement
191
+ - Hallucinated actions: no.
192
+ - Scope creep: no.
193
+ - Cascading errors: no.
194
+ - Context loss: no — all decisions on display name still hold.
195
+ - Tool misuse: no.
127
196
 
128
- - Challenger alternative: script hardening only.
129
- - Disposition: rejected for this cycle.
130
- - Enforcement note: preserve the challenger as a bounded fallback, but do not mix both paths in v1 implementation.
197
+ Iteration 2: same answers, all "no".
131
198
 
132
- ## Selected Direction
199
+ ## Decision
133
200
 
134
- - Selected approach: shared validator module
135
- - Approval: approved
136
- - Rationale: best balance of consistency and delivery speed
137
- - Scope handoff: carry hard-block policy + module boundary into scope
138
- `,
139
- scope: `## Scope contract
201
+ - Iteration 1: **block** slice-builder mode=fix-only on F-1 and F-2.
202
+ - Iteration 2: **clear** — both findings resolved; ready for ship.
203
+ `;
204
+ const SHIP_NOTES = `---
205
+ slug: approval-pill
206
+ stage: ship
207
+ status: active
208
+ ship_commit: 9e2c3a4
209
+ push_approved: true
210
+ pr_url: https://github.com/example/web/pull/2317
211
+ ---
140
212
 
141
- Mode selected: SELECTIVE EXPANSION
213
+ # Ship notes — approval-pill
142
214
 
143
- ## In scope / out of scope / deferred
215
+ ## Summary
144
216
 
145
- | Category | Items |
146
- | --- | --- |
147
- | In scope | durable in-app feed, SSE path, degraded-state UX |
148
- | Out of scope | email/SMS/push channels, marketing flows |
149
- | Deferred | WebSocket migration, rich-media payloads |
217
+ Adds a colour-coded approval status pill to dashboard request cards plus a tooltip exposing the approver's display name and the request age. No backend or schema changes.
150
218
 
151
- ## Reference Pattern Registry
219
+ ## AC commit map
152
220
 
153
- | Pattern | Disposition | Rationale |
221
+ | AC | commit | description |
154
222
  | --- | --- | --- |
155
- | Snapshot + stream handoff | accept | Proven consistency model |
156
- | Queue-backed fan-out rewrite | defer | High cost for current demand |
223
+ | AC-1 | \`a1b2c3d\` | StatusPill component with three variants (pending / approved / rejected). |
224
+ | AC-2 | \`9e2c3a4\` | RequestCard wires StatusPill and tooltip. |
157
225
 
158
- ## Requirements
226
+ ## Push / PR
159
227
 
160
- | R# | Requirement | Why |
161
- | --- | --- | --- |
162
- | R-1 | Feed is queryable for recent window | Baseline usability |
163
- | R-2 | Live updates are timely and recoverable | Reliability |
164
- | R-3 | Degraded state is explicit to users | No silent failure |
228
+ - push: approved by user on 2026-04-18T14:21Z.
229
+ - PR: https://github.com/example/web/pull/2317.
165
230
 
166
- ## Boundary Stress-Tests
231
+ ## Breaking changes / migration
167
232
 
168
- - Stream disconnect while user is active -> banner + fallback path required.
169
- - Snapshot/stream cursor mismatch -> deterministic recovery required.
170
- `,
171
- design: `## Blast Radius
233
+ None. Public component API unchanged.
172
234
 
173
- | File | Change type | Reason |
174
- | --- | --- | --- |
175
- | \`src/services/notifications.ts\` | modify | persistence-aware publish path |
176
- | \`src/api/routes/notifications.ts\` | modify | snapshot + stream endpoints |
177
- | \`src/ui/feed.tsx\` | modify | degraded banner + reconnect states |
178
- | \`tests/integration/notifications.test.ts\` | add/update | consistency + auth coverage |
235
+ ## Release notes
179
236
 
180
- ## Architecture Diagram
237
+ > Dashboard request cards now display a colour-coded approval status pill with a tooltip showing the approver and the request age. No configuration changes required.
238
+ `;
239
+ const DECISION_RECORD = `---
240
+ slug: approval-pill-tooltips
241
+ stage: plan
242
+ status: active
243
+ decision_count: 1
244
+ ---
181
245
 
182
- \`\`\`mermaid
183
- flowchart LR
184
- API --> Service --> Outbox --> Projector --> Feed
185
- Service --> Stream
186
- \`\`\`
246
+ # Decisions — approval-pill-tooltips
187
247
 
188
- ## Failure Modes
248
+ ## D-1 — Permission check is read-from-cached-claim, not re-checked on render
189
249
 
190
- | Failure | Detection | Mitigation |
191
- | --- | --- | --- |
192
- | Stream drops | heartbeat timeout | fallback polling + reconnect |
193
- | Cursor gap | consistency check | replay snapshot delta |
194
- | Auth mismatch | auth guard log | terminate stream + refresh |
250
+ - **Context:** the tooltip needs to gate email visibility on the \`view-email\` permission. We can either (A) re-check the permission on every render via a synchronous IAM call, (B) read from the already-cached user claim with a 60 s TTL, or (C) push permission into a render-time React context.
251
+ - **Considered options:**
252
+ - Option A re-check on render. Pros: always fresh. Cons: adds 8 ms p99 to dashboard render budget; couples the dashboard to IAM uptime.
253
+ - Option B cached claim, 60 s TTL. Pros: zero extra latency on render; same path used by \`view-billing\`. Cons: stale for up to 60 s after permission revoke.
254
+ - Option C render-time React context. Pros: makes permission explicit at the call site. Cons: another context provider; redundant with the cached claim path.
255
+ - **Selected:** Option B.
256
+ - **Rationale:** consistent with \`view-billing\` (\`src/lib/permissions.ts:14\`); 60 s TTL is acceptable per the threat model since permission changes already pin a fresh login on next nav; render budget is non-negotiable for the dashboard.
257
+ - **Rejected because:** A — render budget impact unacceptable; C — redundant.
258
+ - **Consequences:** any future permission gate on the dashboard is expected to follow the same pattern. \`view-billing\` and \`view-email\` should be tested together to keep the path single-purpose.
259
+ - **Refs:** \`src/lib/permissions.ts:14\`, AC-1, AC-3, threat model entry from security-reviewer iteration 1.
260
+ `;
261
+ const LEARNING_RECORD = `---
262
+ slug: approval-pill-tooltips
263
+ stage: ship
264
+ status: active
265
+ captured_by: orchestrator
266
+ quality_gate: passed
267
+ signals:
268
+ hasArchitectDecision: true
269
+ reviewIterations: 2
270
+ securityFlag: true
271
+ userRequestedCapture: false
272
+ ---
195
273
 
196
- ## Test Strategy
274
+ # Learnings — approval-pill-tooltips
197
275
 
198
- - Unit: merge logic, retry budget, projection idempotency.
199
- - Integration: snapshot+stream consistency and auth boundaries.
200
- - E2E: degraded banner and recovery UX.
201
- `,
202
- spec: `## Acceptance Criteria
276
+ ## What we believed at the start
203
277
 
204
- | AC ID | Criterion | Requirement ref | Verification approach |
205
- | --- | --- | --- | --- |
206
- | AC-1 | Feed returns recent window reliably | R-1 | integration test |
207
- | AC-2 | Live updates visible within agreed latency | R-2 | perf + integration |
208
- | AC-3 | Disconnect shows degraded state promptly | R-3 | e2e scenario |
278
+ The simple thing is to call IAM on render whenever the dashboard wants to know whether to show email. That assumption was the original brainstormer frame.
209
279
 
210
- ## Notes
280
+ ## What turned out to be true
211
281
 
212
- - Criteria are observable, measurable, and falsifiable.
213
- - Every AC maps to at least one task and one test path in plan/tdd.
214
- `,
215
- plan: `## Dependency Graph
282
+ - \`useCurrentUser\` already caches permission claims. We did not need a new mechanism.
283
+ - Designers' "muted red" complaint from the original \`approval-pill\` slug was still relevant for new pill variants; we should add it to the design tokens skill.
216
284
 
217
- - D1 schema + persistence
218
- - D2 API snapshot/stream
219
- - D3 UI degraded-state handling
220
- - D4 tests + observability
285
+ ## What turned out to be wrong
221
286
 
222
- ## Tasks
287
+ - The render budget is much tighter than expected — 8 ms is not free in this code path. The architect's feasibility check caught this.
223
288
 
224
- | Task ID | Description | Effort | Minutes |
225
- | --- | --- | --- | --- |
226
- | T-1 | schema + migration | M | 90 |
227
- | T-2 | snapshot/stream API updates | M | 90 |
228
- | T-3 | UI degraded-state path | M | 70 |
229
- | T-4 | consistency + auth tests | M | 85 |
289
+ ## Decisions worth remembering
230
290
 
231
- ## Acceptance Mapping
291
+ - D-1 (cached claim with 60 s TTL).
232
292
 
233
- | AC ID | Task IDs |
234
- | --- | --- |
235
- | AC-1 | T-1, T-2, T-4 |
236
- | AC-2 | T-2, T-4 |
237
- | AC-3 | T-3, T-4 |
293
+ ## Patterns we should keep
294
+
295
+ - Permission gates at render should reuse \`useCurrentUser\` claim caching unless the threat model says otherwise.
296
+ - Refinement slugs that touch sensitive data should set \`security_flag: true\` even when the diff feels small.
297
+
298
+ ## Anti-patterns we should avoid
299
+
300
+ - Re-checking permissions on render in a tight UI path without measuring the budget first.
301
+
302
+ ## Follow-ups
238
303
 
239
- ## WAIT_FOR_CONFIRM
304
+ - Document the 60 s TTL contract on \`useCurrentUser\` in \`src/lib/auth.ts\` (one-line JSDoc).
305
+ - Consider an \`assertPermission\` helper for non-render paths so the rules are obvious.
306
+ `;
307
+ const COMMIT_HELPER_SESSION = `\`\`\`bash
308
+ $ git status --short
309
+ M src/components/dashboard/StatusPill.tsx
310
+ M src/components/dashboard/StatusPill.test.tsx
311
+ M src/styles/tokens.css
312
+
313
+ $ git add src/components/dashboard/StatusPill.tsx \\
314
+ src/components/dashboard/StatusPill.test.tsx \\
315
+ src/styles/tokens.css
316
+
317
+ $ node .cclaw/hooks/commit-helper.mjs --ac=AC-1 \\
318
+ --message="Add StatusPill component with three variants"
319
+
320
+ [commit-helper] AC-1 committed as a1b2c3d
321
+ \`\`\``;
322
+ export const EXAMPLES = [
323
+ { id: "plan-small", fileName: "plan-small.md", title: "Plan — small slug", description: "Two AC, inline topology, no specialists invoked.", body: PLAN_SMALL },
324
+ { id: "plan-parallel-build", fileName: "plan-parallel-build.md", title: "Plan — parallel-build topology", description: "Four AC across three slice owners + integration reviewer.", body: PLAN_PARALLEL_BUILD },
325
+ { id: "build-log", fileName: "build-log.md", title: "Build log — two AC committed", description: "Commit table with file:line refs and hook invocations.", body: BUILD_LOG },
326
+ { id: "review-log", fileName: "review-log.md", title: "Review — two iterations to clear", description: "Iteration table, findings, Five Failure Modes pass.", body: REVIEW_LOG },
327
+ { id: "ship-notes", fileName: "ship-notes.md", title: "Ship notes — approved push + PR", description: "Summary, AC↔commit map, push/PR, release notes.", body: SHIP_NOTES },
328
+ { id: "decision-permission-cache", fileName: "decision-permission-cache.md", title: "Decision — cached permission claim (D-1)", description: "Considered options, selection, rationale, consequences, refs.", body: DECISION_RECORD },
329
+ { id: "learning-record", fileName: "learning-record.md", title: "Learnings — gated capture", description: "Belief / outcomes / patterns / antipatterns / follow-ups.", body: LEARNING_RECORD },
330
+ { id: "commit-helper-session", fileName: "commit-helper-session.md", title: "Commit-helper session", description: "Shell transcript for one AC commit via the hook.", body: `# commit-helper.mjs session\n\n${COMMIT_HELPER_SESSION}\n` }
331
+ ];
332
+ export const EXAMPLES_INDEX = `# .cclaw/lib/examples/
240
333
 
241
- Plan is ready to execute after user confirmation.
242
- `,
243
- tdd: `## RED
334
+ Worked artifacts the orchestrator and specialists can study before producing their own. Each file is a real-looking plan / build / review / ship / decision / learning artifact, plus a few orchestrator-prompt transcripts.
244
335
 
245
- | Slice | Failing test evidence |
336
+ | file | what it shows |
246
337
  | --- | --- |
247
- | S-1 feed window | expected 30d window, got 7d |
248
- | S-2 degraded banner | banner absent after forced disconnect |
249
-
250
- ## Acceptance & Failure Map
251
-
252
- | Slice | Source ID | AC ID | Expected behavior | RED-link |
253
- | --- | --- | --- | --- | --- |
254
- | S-1 | SRC-1 | AC-1 | feed window honors 30d cap | spanId:tdd-feed-window-red |
255
- | S-2 | SRC-2 | AC-3 | degraded banner appears on disconnect | spanId:tdd-banner-red (auto-derived from delegation-events.jsonl) |
256
-
257
- ## GREEN
258
-
259
- - Targeted tests pass.
260
- - Full suite re-run after fixes.
261
-
262
- ## REFACTOR
263
-
264
- - Reduced reconnect state duplication.
265
- - Revalidated behavior with regression tests.
266
- `,
267
- review: `## Layer 1 — Spec Compliance
268
-
269
- | ID | Severity | Finding | Evidence | Status |
270
- | --- | --- | --- | --- | --- |
271
- | R-1 | low | AC mapping remains intact | trace table + tests | closed |
272
-
273
- ## Layer 2 — Code Quality
274
-
275
- | ID | Severity | Finding | Evidence | Status |
276
- | --- | --- | --- | --- | --- |
277
- | R-2 | high | auth guard gap in stream query path | curl repro + failing test | open |
278
-
279
- ## Victory Detector
280
-
281
- Victory Detector: pass | fail
282
-
283
- - Current verdict: fail (R-2 open)
284
- `,
285
- ship: `## Release Checklist
286
-
287
- - version/changelog prepared
288
- - test/build/preflight passed
289
- - review blockers resolved or explicitly accepted
290
-
291
- ## Victory Detector
292
-
293
- Victory Detector: pass | fail
294
-
295
- - Current verdict: pass
296
-
297
- ## Rollback Plan
298
-
299
- - Trigger: error-rate or latency threshold breach
300
- - Steps: revert + redeploy prior artifact
301
- - Verification: key metrics return to baseline
302
- `
303
- };
304
- const GOOD_BAD_EXAMPLES = {
305
- brainstorm: [{
306
- label: "Problem framing",
307
- good: "Names affected role, current failure mode, measurable target, and non-goals.",
308
- bad: "Need to improve this area somehow.",
309
- lesson: "Concrete framing prevents scope drift in downstream stages."
310
- }],
311
- scope: [{
312
- label: "Boundary clarity",
313
- good: "Clear in-scope/out-of-scope/deferred lists with concrete capabilities.",
314
- bad: "Add improvements where useful.",
315
- lesson: "Scope without hard boundaries becomes hidden commitment."
316
- }],
317
- design: [{
318
- label: "Failure handling",
319
- good: "Each failure row includes trigger, detection, and mitigation.",
320
- bad: "Could fail, handle later.",
321
- lesson: "Actionable design risk must be testable and operationally visible."
322
- }],
323
- spec: [{
324
- label: "AC quality",
325
- good: "AC includes measurable signal and explicit verification approach.",
326
- bad: "System should work reliably.",
327
- lesson: "Observable/falsifiable language is required for meaningful verification."
328
- }],
329
- plan: [{
330
- label: "Task granularity",
331
- good: "Tasks have bounded outputs, effort, and AC links.",
332
- bad: "Implement feature end-to-end.",
333
- lesson: "Execution speed depends on concrete, reviewable task slices."
334
- }],
335
- tdd: [{
336
- label: "RED evidence",
337
- good: "Includes failing output tied to one behavior slice.",
338
- bad: "Tests failed at first.",
339
- lesson: "Without concrete RED evidence, behavior intent is not auditable."
340
- }],
341
- review: [{
342
- label: "Finding quality",
343
- good: "Severity + falsifiable claim + evidence + status.",
344
- bad: "LGTM with a few comments.",
345
- lesson: "Review findings are decisions, not vibes."
346
- }],
347
- ship: [{
348
- label: "Rollback contract",
349
- good: "Named trigger, exact rollback steps, and verification condition.",
350
- bad: "Revert if something goes wrong.",
351
- lesson: "Rollback must be executable under incident pressure."
352
- }]
353
- };
354
- export function stageGoodBadExamples(stage) {
355
- const samples = GOOD_BAD_EXAMPLES[stage];
356
- if (!samples || samples.length === 0)
357
- return "";
358
- const blocks = [
359
- "## Good vs Bad (at-a-glance)",
360
- "",
361
- "Contrasting samples to calibrate quality for this stage.",
362
- ""
363
- ];
364
- samples.forEach((sample, index) => {
365
- blocks.push(`### ${index + 1}. ${sample.label}`);
366
- blocks.push("");
367
- blocks.push("**Good**");
368
- blocks.push("");
369
- blocks.push("> " + sample.good);
370
- blocks.push("");
371
- blocks.push("**Bad**");
372
- blocks.push("");
373
- blocks.push("> " + sample.bad);
374
- blocks.push("");
375
- blocks.push("**Why it matters:** " + sample.lesson);
376
- blocks.push("");
377
- });
378
- return blocks.join("\n");
379
- }
380
- /**
381
- * Returns the full example artifact body for tests and internal quality checks.
382
- * Generated user projects keep only short inline shape cues.
383
- */
384
- export function stageFullArtifactExampleMarkdown(stage) {
385
- const examples = STAGE_EXAMPLES[stage];
386
- if (!examples)
387
- return null;
388
- return [
389
- `---`,
390
- `stage: ${stage}`,
391
- `name: ${stage}-stage-examples`,
392
- `description: "Full sample artifact for the ${stage} stage."`,
393
- `---`,
394
- "",
395
- `# ${stage} stage — full artifact sample`,
396
- "",
397
- `The sample uses H2 headings that mirror the artifact a cclaw session must produce, so the markdown is wrapped in a fence to avoid collapsing into the outline.`,
398
- "",
399
- "```markdown",
400
- examples,
401
- "```",
402
- ""
403
- ].join("\n");
404
- }
405
- /**
406
- * Returns short inline shape cues rendered directly inside the stage skill.
407
- */
408
- export function stageExamples(stage) {
409
- const examples = STAGE_EXAMPLES[stage];
410
- if (!examples)
411
- return "";
412
- return [
413
- "## Examples",
414
- "",
415
- "Shape cues to follow; do not paste these headings verbatim unless they match the work:",
416
- ...exampleSummaryBullets(stage),
417
- ""
418
- ].join("\n");
419
- }
420
- function exampleSummaryBullets(stage) {
421
- const headings = STAGE_EXAMPLE_SECTION_HEADINGS[stage] ?? [];
422
- if (headings.length === 0)
423
- return ["- Full artifact structure."];
424
- return headings.map((heading) => `- ${heading}`);
425
- }
426
- const STAGE_EXAMPLE_SECTION_HEADINGS = {
427
- brainstorm: [
428
- "Problem Decision Record (free-form Frame type label + universal framing fields)",
429
- "Approaches with explicit trade-offs",
430
- "Approach Reaction and Selected Direction"
431
- ],
432
- scope: [
433
- "In-scope / out-of-scope / deferred lists with concrete capabilities",
434
- "Reference Pattern Registry with clear dispositions",
435
- "Requirements table with stable R# IDs"
436
- ],
437
- design: [
438
- "Blast-radius file list",
439
- "Mandatory architecture diagram (Mermaid)",
440
- "Failure-mode table with detection + mitigation"
441
- ],
442
- spec: [
443
- "Acceptance-criteria table (observable, measurable, falsifiable)",
444
- "Requirement-ref column tying each AC back to an R# from scope",
445
- "Verification-approach column"
446
- ],
447
- plan: [
448
- "Dependency graph",
449
- "Task list with effort + minutes estimate per task",
450
- "Acceptance mapping (every AC -> task IDs)",
451
- "WAIT_FOR_CONFIRM marker"
452
- ],
453
- tdd: [
454
- "RED evidence per vertical slice",
455
- "Acceptance mapping per slice",
456
- "GREEN evidence",
457
- "REFACTOR notes with behavior-preservation confirmation"
458
- ],
459
- review: [
460
- "Spec-compliance findings (Layer 1)",
461
- "Code-quality findings (Layer 2)",
462
- "Severity, evidence, and status per finding",
463
- "Victory Detector-backed go / no-go verdict"
464
- ],
465
- ship: [
466
- "Release checklist",
467
- "Victory Detector: pass | fail",
468
- "Rollback plan with trigger, steps, verification",
469
- "Runbook and sign-off"
470
- ]
471
- };
338
+ ${EXAMPLES.map((e) => `| \`${e.fileName}\` | ${e.description} |`).join("\n")}
339
+ `;