cclaw-cli 7.7.1 → 8.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +211 -134
- package/dist/artifact-frontmatter.d.ts +51 -0
- package/dist/artifact-frontmatter.js +131 -0
- package/dist/artifact-paths.d.ts +7 -27
- package/dist/artifact-paths.js +20 -249
- package/dist/cancel.d.ts +16 -0
- package/dist/cancel.js +66 -0
- package/dist/cli.d.ts +2 -27
- package/dist/cli.js +107 -511
- package/dist/compound.d.ts +26 -0
- package/dist/compound.js +96 -0
- package/dist/config.d.ts +14 -51
- package/dist/config.js +23 -359
- package/dist/constants.d.ts +11 -18
- package/dist/constants.js +19 -106
- package/dist/content/antipatterns.d.ts +1 -0
- package/dist/content/antipatterns.js +109 -0
- package/dist/content/artifact-templates.d.ts +10 -0
- package/dist/content/artifact-templates.js +550 -0
- package/dist/content/cancel-command.d.ts +2 -2
- package/dist/content/cancel-command.js +25 -17
- package/dist/content/core-agents.d.ts +9 -233
- package/dist/content/core-agents.js +39 -768
- package/dist/content/decision-protocol.d.ts +1 -12
- package/dist/content/decision-protocol.js +27 -20
- package/dist/content/examples.d.ts +8 -42
- package/dist/content/examples.js +293 -425
- package/dist/content/idea-command.d.ts +2 -0
- package/dist/content/idea-command.js +38 -0
- package/dist/content/iron-laws.d.ts +4 -138
- package/dist/content/iron-laws.js +18 -197
- package/dist/content/meta-skill.d.ts +1 -3
- package/dist/content/meta-skill.js +57 -134
- package/dist/content/node-hooks.d.ts +12 -8
- package/dist/content/node-hooks.js +188 -838
- package/dist/content/recovery.d.ts +8 -0
- package/dist/content/recovery.js +179 -0
- package/dist/content/reference-patterns.d.ts +4 -13
- package/dist/content/reference-patterns.js +260 -389
- package/dist/content/research-playbooks.d.ts +8 -8
- package/dist/content/research-playbooks.js +108 -121
- package/dist/content/review-loop.d.ts +6 -192
- package/dist/content/review-loop.js +29 -731
- package/dist/content/skills.d.ts +8 -38
- package/dist/content/skills.js +681 -732
- package/dist/content/specialist-prompts/architect.d.ts +1 -0
- package/dist/content/specialist-prompts/architect.js +225 -0
- package/dist/content/specialist-prompts/brainstormer.d.ts +1 -0
- package/dist/content/specialist-prompts/brainstormer.js +168 -0
- package/dist/content/specialist-prompts/index.d.ts +2 -0
- package/dist/content/specialist-prompts/index.js +14 -0
- package/dist/content/specialist-prompts/planner.d.ts +1 -0
- package/dist/content/specialist-prompts/planner.js +182 -0
- package/dist/content/specialist-prompts/reviewer.d.ts +1 -0
- package/dist/content/specialist-prompts/reviewer.js +193 -0
- package/dist/content/specialist-prompts/security-reviewer.d.ts +1 -0
- package/dist/content/specialist-prompts/security-reviewer.js +133 -0
- package/dist/content/specialist-prompts/slice-builder.d.ts +1 -0
- package/dist/content/specialist-prompts/slice-builder.js +232 -0
- package/dist/content/stage-playbooks.d.ts +8 -0
- package/dist/content/stage-playbooks.js +404 -0
- package/dist/content/start-command.d.ts +2 -12
- package/dist/content/start-command.js +221 -207
- package/dist/flow-state.d.ts +21 -178
- package/dist/flow-state.js +67 -170
- package/dist/fs-utils.d.ts +6 -26
- package/dist/fs-utils.js +29 -162
- package/dist/gitignore.d.ts +2 -1
- package/dist/gitignore.js +51 -34
- package/dist/harness-detect.d.ts +10 -0
- package/dist/harness-detect.js +29 -0
- package/dist/harness-prompt.d.ts +26 -0
- package/dist/harness-prompt.js +142 -0
- package/dist/install.d.ts +35 -15
- package/dist/install.js +238 -1347
- package/dist/knowledge-store.d.ts +19 -163
- package/dist/knowledge-store.js +56 -590
- package/dist/logger.d.ts +8 -3
- package/dist/logger.js +13 -4
- package/dist/orchestrator-routing.d.ts +29 -0
- package/dist/orchestrator-routing.js +156 -0
- package/dist/run-persistence.d.ts +7 -118
- package/dist/run-persistence.js +29 -845
- package/dist/runtime/run-hook.entry.d.ts +1 -3
- package/dist/runtime/run-hook.entry.js +19 -4
- package/dist/runtime/run-hook.mjs +13 -1024
- package/dist/types.d.ts +25 -261
- package/dist/types.js +8 -36
- package/package.json +6 -3
- package/dist/artifact-linter/brainstorm.d.ts +0 -2
- package/dist/artifact-linter/brainstorm.js +0 -353
- package/dist/artifact-linter/design.d.ts +0 -18
- package/dist/artifact-linter/design.js +0 -444
- package/dist/artifact-linter/findings-dedup.d.ts +0 -56
- package/dist/artifact-linter/findings-dedup.js +0 -232
- package/dist/artifact-linter/plan.d.ts +0 -2
- package/dist/artifact-linter/plan.js +0 -826
- package/dist/artifact-linter/review-army.d.ts +0 -49
- package/dist/artifact-linter/review-army.js +0 -520
- package/dist/artifact-linter/review.d.ts +0 -2
- package/dist/artifact-linter/review.js +0 -113
- package/dist/artifact-linter/scope.d.ts +0 -2
- package/dist/artifact-linter/scope.js +0 -158
- package/dist/artifact-linter/shared.d.ts +0 -637
- package/dist/artifact-linter/shared.js +0 -2163
- package/dist/artifact-linter/ship.d.ts +0 -2
- package/dist/artifact-linter/ship.js +0 -250
- package/dist/artifact-linter/spec.d.ts +0 -2
- package/dist/artifact-linter/spec.js +0 -176
- package/dist/artifact-linter/tdd.d.ts +0 -118
- package/dist/artifact-linter/tdd.js +0 -1404
- package/dist/artifact-linter.d.ts +0 -15
- package/dist/artifact-linter.js +0 -517
- package/dist/codex-feature-flag.d.ts +0 -58
- package/dist/codex-feature-flag.js +0 -193
- package/dist/content/closeout-guidance.d.ts +0 -14
- package/dist/content/closeout-guidance.js +0 -44
- package/dist/content/diff-command.d.ts +0 -1
- package/dist/content/diff-command.js +0 -43
- package/dist/content/harness-doc.d.ts +0 -1
- package/dist/content/harness-doc.js +0 -65
- package/dist/content/hook-events.d.ts +0 -9
- package/dist/content/hook-events.js +0 -23
- package/dist/content/hook-manifest.d.ts +0 -81
- package/dist/content/hook-manifest.js +0 -156
- package/dist/content/hooks.d.ts +0 -11
- package/dist/content/hooks.js +0 -1972
- package/dist/content/idea.d.ts +0 -60
- package/dist/content/idea.js +0 -416
- package/dist/content/language-policy.d.ts +0 -2
- package/dist/content/language-policy.js +0 -13
- package/dist/content/learnings.d.ts +0 -6
- package/dist/content/learnings.js +0 -141
- package/dist/content/observe.d.ts +0 -19
- package/dist/content/observe.js +0 -86
- package/dist/content/opencode-plugin.d.ts +0 -1
- package/dist/content/opencode-plugin.js +0 -635
- package/dist/content/review-prompts.d.ts +0 -1
- package/dist/content/review-prompts.js +0 -104
- package/dist/content/runtime-shared-snippets.d.ts +0 -8
- package/dist/content/runtime-shared-snippets.js +0 -80
- package/dist/content/session-hooks.d.ts +0 -7
- package/dist/content/session-hooks.js +0 -107
- package/dist/content/skills-elicitation.d.ts +0 -1
- package/dist/content/skills-elicitation.js +0 -167
- package/dist/content/stage-command.d.ts +0 -2
- package/dist/content/stage-command.js +0 -17
- package/dist/content/stage-schema.d.ts +0 -117
- package/dist/content/stage-schema.js +0 -955
- package/dist/content/stages/_lint-metadata/index.d.ts +0 -2
- package/dist/content/stages/_lint-metadata/index.js +0 -97
- package/dist/content/stages/brainstorm.d.ts +0 -2
- package/dist/content/stages/brainstorm.js +0 -184
- package/dist/content/stages/design.d.ts +0 -2
- package/dist/content/stages/design.js +0 -288
- package/dist/content/stages/index.d.ts +0 -8
- package/dist/content/stages/index.js +0 -11
- package/dist/content/stages/plan.d.ts +0 -2
- package/dist/content/stages/plan.js +0 -191
- package/dist/content/stages/review.d.ts +0 -2
- package/dist/content/stages/review.js +0 -240
- package/dist/content/stages/schema-types.d.ts +0 -203
- package/dist/content/stages/schema-types.js +0 -1
- package/dist/content/stages/scope.d.ts +0 -2
- package/dist/content/stages/scope.js +0 -254
- package/dist/content/stages/ship.d.ts +0 -2
- package/dist/content/stages/ship.js +0 -159
- package/dist/content/stages/spec.d.ts +0 -2
- package/dist/content/stages/spec.js +0 -170
- package/dist/content/stages/tdd.d.ts +0 -4
- package/dist/content/stages/tdd.js +0 -273
- package/dist/content/state-contracts.d.ts +0 -1
- package/dist/content/state-contracts.js +0 -63
- package/dist/content/status-command.d.ts +0 -4
- package/dist/content/status-command.js +0 -109
- package/dist/content/subagent-context-skills.d.ts +0 -4
- package/dist/content/subagent-context-skills.js +0 -279
- package/dist/content/subagents.d.ts +0 -3
- package/dist/content/subagents.js +0 -997
- package/dist/content/templates.d.ts +0 -26
- package/dist/content/templates.js +0 -1692
- package/dist/content/track-render-context.d.ts +0 -18
- package/dist/content/track-render-context.js +0 -53
- package/dist/content/tree-command.d.ts +0 -1
- package/dist/content/tree-command.js +0 -64
- package/dist/content/utility-skills.d.ts +0 -30
- package/dist/content/utility-skills.js +0 -160
- package/dist/content/view-command.d.ts +0 -2
- package/dist/content/view-command.js +0 -92
- package/dist/delegation.d.ts +0 -649
- package/dist/delegation.js +0 -1539
- package/dist/early-loop.d.ts +0 -70
- package/dist/early-loop.js +0 -302
- package/dist/execution-topology.d.ts +0 -44
- package/dist/execution-topology.js +0 -95
- package/dist/gate-evidence.d.ts +0 -85
- package/dist/gate-evidence.js +0 -631
- package/dist/harness-adapters.d.ts +0 -151
- package/dist/harness-adapters.js +0 -756
- package/dist/harness-selection.d.ts +0 -31
- package/dist/harness-selection.js +0 -214
- package/dist/hook-schema.d.ts +0 -6
- package/dist/hook-schema.js +0 -114
- package/dist/hook-schemas/claude-hooks.v1.json +0 -10
- package/dist/hook-schemas/codex-hooks.v1.json +0 -10
- package/dist/hook-schemas/cursor-hooks.v1.json +0 -13
- package/dist/init-detect.d.ts +0 -2
- package/dist/init-detect.js +0 -50
- package/dist/internal/advance-stage/advance.d.ts +0 -89
- package/dist/internal/advance-stage/advance.js +0 -655
- package/dist/internal/advance-stage/cancel-run.d.ts +0 -8
- package/dist/internal/advance-stage/cancel-run.js +0 -19
- package/dist/internal/advance-stage/flow-state-coercion.d.ts +0 -3
- package/dist/internal/advance-stage/flow-state-coercion.js +0 -81
- package/dist/internal/advance-stage/helpers.d.ts +0 -14
- package/dist/internal/advance-stage/helpers.js +0 -145
- package/dist/internal/advance-stage/hook.d.ts +0 -8
- package/dist/internal/advance-stage/hook.js +0 -40
- package/dist/internal/advance-stage/parsers.d.ts +0 -72
- package/dist/internal/advance-stage/parsers.js +0 -357
- package/dist/internal/advance-stage/proactive-delegation-trace.d.ts +0 -24
- package/dist/internal/advance-stage/proactive-delegation-trace.js +0 -56
- package/dist/internal/advance-stage/review-loop.d.ts +0 -16
- package/dist/internal/advance-stage/review-loop.js +0 -199
- package/dist/internal/advance-stage/rewind.d.ts +0 -14
- package/dist/internal/advance-stage/rewind.js +0 -108
- package/dist/internal/advance-stage/start-flow.d.ts +0 -13
- package/dist/internal/advance-stage/start-flow.js +0 -241
- package/dist/internal/advance-stage/verify.d.ts +0 -21
- package/dist/internal/advance-stage/verify.js +0 -185
- package/dist/internal/advance-stage.d.ts +0 -7
- package/dist/internal/advance-stage.js +0 -138
- package/dist/internal/cohesion-contract-stub.d.ts +0 -24
- package/dist/internal/cohesion-contract-stub.js +0 -148
- package/dist/internal/compound-readiness.d.ts +0 -23
- package/dist/internal/compound-readiness.js +0 -102
- package/dist/internal/detect-public-api-changes.d.ts +0 -5
- package/dist/internal/detect-public-api-changes.js +0 -45
- package/dist/internal/detect-supply-chain-changes.d.ts +0 -6
- package/dist/internal/detect-supply-chain-changes.js +0 -138
- package/dist/internal/early-loop-status.d.ts +0 -7
- package/dist/internal/early-loop-status.js +0 -93
- package/dist/internal/envelope-validate.d.ts +0 -7
- package/dist/internal/envelope-validate.js +0 -66
- package/dist/internal/flow-state-repair.d.ts +0 -20
- package/dist/internal/flow-state-repair.js +0 -104
- package/dist/internal/plan-split-waves.d.ts +0 -190
- package/dist/internal/plan-split-waves.js +0 -764
- package/dist/internal/runtime-integrity.d.ts +0 -7
- package/dist/internal/runtime-integrity.js +0 -268
- package/dist/internal/slice-commit.d.ts +0 -7
- package/dist/internal/slice-commit.js +0 -619
- package/dist/internal/tdd-loop-status.d.ts +0 -14
- package/dist/internal/tdd-loop-status.js +0 -68
- package/dist/internal/tdd-red-evidence.d.ts +0 -7
- package/dist/internal/tdd-red-evidence.js +0 -153
- package/dist/internal/waiver-grant.d.ts +0 -62
- package/dist/internal/waiver-grant.js +0 -294
- package/dist/internal/wave-status.d.ts +0 -74
- package/dist/internal/wave-status.js +0 -506
- package/dist/managed-resources.d.ts +0 -53
- package/dist/managed-resources.js +0 -313
- package/dist/policy.d.ts +0 -10
- package/dist/policy.js +0 -167
- package/dist/retro-gate.d.ts +0 -9
- package/dist/retro-gate.js +0 -47
- package/dist/run-archive.d.ts +0 -61
- package/dist/run-archive.js +0 -391
- package/dist/runs.d.ts +0 -2
- package/dist/runs.js +0 -2
- package/dist/stack-detection.d.ts +0 -116
- package/dist/stack-detection.js +0 -489
- package/dist/streaming/event-stream.d.ts +0 -31
- package/dist/streaming/event-stream.js +0 -114
- package/dist/tdd-cycle.d.ts +0 -107
- package/dist/tdd-cycle.js +0 -289
- package/dist/tdd-verification-evidence.d.ts +0 -17
- package/dist/tdd-verification-evidence.js +0 -122
- package/dist/track-heuristics.d.ts +0 -27
- package/dist/track-heuristics.js +0 -154
- package/dist/util/slice-id.d.ts +0 -58
- package/dist/util/slice-id.js +0 -89
- package/dist/worktree-manager.d.ts +0 -20
- package/dist/worktree-manager.js +0 -108
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
export const SLICE_BUILDER_PROMPT = `# slice-builder
|
|
2
|
+
|
|
3
|
+
You are the cclaw slice-builder. You are the **only specialist that writes code**, and **build is a TDD cycle**: every AC goes through RED → GREEN → REFACTOR. There is no other build mode.
|
|
4
|
+
|
|
5
|
+
## Iron Law
|
|
6
|
+
|
|
7
|
+
> NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST. THE RED FAILURE IS THE SPEC.
|
|
8
|
+
|
|
9
|
+
You may not commit production code that is not preceded by a recorded RED test on the same AC. \`commit-helper.mjs\` enforces this with the \`--phase\` flag (\`red\` / \`green\` / \`refactor\`); commits without a phase are rejected.
|
|
10
|
+
|
|
11
|
+
## Modes
|
|
12
|
+
|
|
13
|
+
- \`build\` — implement AC slices for the active plan, one AC at a time, RED → GREEN → REFACTOR per AC.
|
|
14
|
+
- \`fix-only\` — apply post-review fixes bounded to file:line refs cited in the latest \`reviews/<slug>.md\` block. The TDD cycle still applies (see Fix-only flow).
|
|
15
|
+
|
|
16
|
+
## Inputs
|
|
17
|
+
|
|
18
|
+
- \`plans/<slug>.md\` — the AC contract (you do not author AC; you implement them).
|
|
19
|
+
- \`decisions/<slug>.md\` if architect ran.
|
|
20
|
+
- \`builds/<slug>.md\` from prior iterations and \`reviews/<slug>.md\` (for fix-only mode).
|
|
21
|
+
- \`.cclaw/lib/runbooks/build.md\` — your stage runbook (TDD cycle reference).
|
|
22
|
+
- \`.cclaw/lib/skills/ac-traceability.md\`, \`.cclaw/lib/skills/tdd-cycle.md\`, \`.cclaw/lib/skills/commit-message-quality.md\`, \`.cclaw/lib/skills/anti-slop.md\`.
|
|
23
|
+
|
|
24
|
+
## Output
|
|
25
|
+
|
|
26
|
+
For each AC, you produce:
|
|
27
|
+
|
|
28
|
+
1. A real diff in the working tree, split into RED / GREEN / REFACTOR commits via \`commit-helper.mjs --phase=…\`.
|
|
29
|
+
2. A six-column row in \`builds/<slug>.md\` (AC, Discovery, RED proof, GREEN evidence, REFACTOR notes, commits).
|
|
30
|
+
3. A \`tdd-slices/S-<id>.md\` per-slice card (when the plan declares more than one slice; for single-slice slugs, omit) with watched-RED proof + GREEN suite evidence + REFACTOR diff summary.
|
|
31
|
+
|
|
32
|
+
## Hard rules
|
|
33
|
+
|
|
34
|
+
1. **One AC per cycle**, three commits (RED + GREEN + REFACTOR or RED + GREEN + REFACTOR-skipped).
|
|
35
|
+
2. **No production edits in the RED commit.** Stage and commit test files only.
|
|
36
|
+
3. **Run the full relevant suite** before the GREEN commit. A passing single test with the rest of the suite broken is not GREEN; it is a regression.
|
|
37
|
+
4. **REFACTOR is mandatory**. Either commit a refactor or commit \`--phase=refactor --skipped\` with a one-line reason in the message and the row.
|
|
38
|
+
5. **Smallest correct change** at every phase. Smallest diff, smallest scope (only declared files), smallest cognitive load (no new abstraction unless the plan asked).
|
|
39
|
+
6. **commit-helper, never \`git commit\` directly.** Bypass breaks the traceability gate; \`commit-helper.mjs\` rejects commits with a missing or unknown \`--phase\`.
|
|
40
|
+
7. **No \`git add -A\`.** Stage AC-related files explicitly.
|
|
41
|
+
8. **Stop and surface** when the smallest-correct change requires touching files outside the plan or rewriting an AC. Do not silently expand scope or revise the plan.
|
|
42
|
+
9. **Test files follow project convention.** Mirror the production module: tests for \`src/lib/permissions.ts\` go in \`tests/unit/permissions.test.ts\` (or whatever the project's pattern is — \`*.spec.ts\`, \`__tests__/*.ts\`, \`*_test.go\`, \`test_*.py\`). **Never name a test file after an AC id.** \`AC-1.test.ts\`, \`tests/AC-2.test.ts\`, \`spec/ac3.spec.ts\` are wrong. AC ids belong inside the test, not in the filename:
|
|
43
|
+
- test name (\`it('AC-1: tooltip shows email when permission set', ...)\`),
|
|
44
|
+
- commit message (\`red(AC-1): tooltip shows email\`),
|
|
45
|
+
- build log row.
|
|
46
|
+
The filename is for humans, the AC id is for the traceability machine. They live in different layers.
|
|
47
|
+
10. **No redundant verification.** Do not re-run the same build / test / lint command twice in a row without a code or input change. If a tool failed once, the second identical run will fail too — fix the cause or surface a finding. See \`.cclaw/lib/skills/anti-slop.md\` for the full rule.
|
|
48
|
+
11. **No environment shims, no fake fixes.** Do not add \`process.env.NODE_ENV === "test"\` branches, \`@ts-ignore\` / \`eslint-disable\` to silence real failures, \`.skip\`-ed tests "until later", or hardcoded fixture-fallbacks inside production code. Either fix the root cause or surface the failure as a finding (severity: \`block\`) and stop. Reviewer flags shims as \`block\` — they always cost a round-trip.
|
|
49
|
+
|
|
50
|
+
## RED phase — discovery + failing test
|
|
51
|
+
|
|
52
|
+
Before writing the RED test:
|
|
53
|
+
|
|
54
|
+
- Find the closest existing test file for the affected module.
|
|
55
|
+
- Identify the runnable command for that file (\`npm test path\`, \`pytest path\`, \`go test ./pkg/...\`).
|
|
56
|
+
- Identify callbacks, state transitions, public exports, schemas, and contracts the AC's verification touches.
|
|
57
|
+
- Cite each finding as \`file:path:line\` in the **Discovery** column of the AC row.
|
|
58
|
+
|
|
59
|
+
Write the test. The test must encode the AC verification line (the one written by planner). The test must fail for the **right reason** — the assertion that encodes the AC, not a syntax / import / fixture error.
|
|
60
|
+
|
|
61
|
+
Capture the runner output that proves the failure (command + 1-3 line excerpt of the failure message). This is the **watched-RED proof**.
|
|
62
|
+
|
|
63
|
+
Stage test files only:
|
|
64
|
+
|
|
65
|
+
\`\`\`bash
|
|
66
|
+
git add tests/path/to/new-or-updated.test.ts
|
|
67
|
+
|
|
68
|
+
node .cclaw/hooks/commit-helper.mjs --ac=AC-N --phase=red \\
|
|
69
|
+
--message="red(AC-N): assert <observable behaviour>"
|
|
70
|
+
\`\`\`
|
|
71
|
+
|
|
72
|
+
\`commit-helper\` records the RED SHA in flow-state under \`ac[AC-N].red\`.
|
|
73
|
+
|
|
74
|
+
## GREEN phase — minimal production change
|
|
75
|
+
|
|
76
|
+
Goal: smallest possible production diff that turns RED into PASS, without touching files outside the plan.
|
|
77
|
+
|
|
78
|
+
After implementing, run the **full relevant suite** (not the single test). Capture the command + PASS/FAIL summary. The captured output is the **GREEN evidence**.
|
|
79
|
+
|
|
80
|
+
If the full suite is not green, the AC is **not done**. Either fix the regression (continue editing) or revert the partial GREEN edit and surface the conflict back to planner / architect — do **not** commit a half-green state.
|
|
81
|
+
|
|
82
|
+
Stage production files only (or production + test fixtures if the plan declares them):
|
|
83
|
+
|
|
84
|
+
\`\`\`bash
|
|
85
|
+
git add src/path/to/implementation.ts
|
|
86
|
+
|
|
87
|
+
node .cclaw/hooks/commit-helper.mjs --ac=AC-N --phase=green \\
|
|
88
|
+
--message="green(AC-N): minimal impl that satisfies RED"
|
|
89
|
+
\`\`\`
|
|
90
|
+
|
|
91
|
+
\`commit-helper\` records the GREEN SHA under \`ac[AC-N].green\` and verifies that \`ac[AC-N].red\` exists. If RED is missing, the GREEN commit is **rejected**.
|
|
92
|
+
|
|
93
|
+
## REFACTOR phase — mandatory pass
|
|
94
|
+
|
|
95
|
+
REFACTOR is not optional. Even when the GREEN diff feels minimal, you must consider:
|
|
96
|
+
|
|
97
|
+
- Renames that improve clarity.
|
|
98
|
+
- Extractions that reduce duplication.
|
|
99
|
+
- Type narrowing that shrinks the interface.
|
|
100
|
+
- Inlining of one-shot variables / functions.
|
|
101
|
+
- Removal of dead code introduced during GREEN.
|
|
102
|
+
|
|
103
|
+
If a refactor is warranted, apply it. Run the same full suite again; it must pass with **identical expected output** (no behaviour change).
|
|
104
|
+
|
|
105
|
+
If no refactor is warranted, you must say so **explicitly**. Silence fails the gate.
|
|
106
|
+
|
|
107
|
+
Both paths use commit-helper:
|
|
108
|
+
|
|
109
|
+
\`\`\`bash
|
|
110
|
+
# Path A — refactor applied:
|
|
111
|
+
git add src/path/to/refactored.ts
|
|
112
|
+
node .cclaw/hooks/commit-helper.mjs --ac=AC-N --phase=refactor \\
|
|
113
|
+
--message="refactor(AC-N): <one-line shape change>"
|
|
114
|
+
|
|
115
|
+
# Path B — refactor explicitly skipped:
|
|
116
|
+
node .cclaw/hooks/commit-helper.mjs --ac=AC-N --phase=refactor --skipped \\
|
|
117
|
+
--message="refactor(AC-N) skipped: 12-line addition, idiomatic"
|
|
118
|
+
\`\`\`
|
|
119
|
+
|
|
120
|
+
\`commit-helper\` records the REFACTOR SHA (or "skipped" sentinel) under \`ac[AC-N].refactor\`. Until \`ac[AC-N]\` has all three phases recorded, the AC's overall status stays \`pending\`.
|
|
121
|
+
|
|
122
|
+
## Build log shape — \`builds/<slug>.md\`
|
|
123
|
+
|
|
124
|
+
After all three phases for AC-N:
|
|
125
|
+
|
|
126
|
+
\`\`\`markdown
|
|
127
|
+
| AC-N | Discovery | RED proof | GREEN evidence | REFACTOR notes | commits |
|
|
128
|
+
| --- | --- | --- | --- | --- | --- |
|
|
129
|
+
| AC-1 | tests/unit/permissions.test.ts:1, fixtures/users.json:14 | "renders email when permission set" — AssertionError: expected "anna@…" got undefined | npm test src/lib/permissions.ts → 47 passed, 0 failed | extracted hasViewEmail helper from inline check | red a1b2c3d, green 4e5f6a7, refactor 9e2c3a4 |
|
|
130
|
+
\`\`\`
|
|
131
|
+
|
|
132
|
+
A row missing any column is a build-stage finding for the reviewer.
|
|
133
|
+
|
|
134
|
+
## Worked example — full cycle for one AC
|
|
135
|
+
|
|
136
|
+
\`\`\`bash
|
|
137
|
+
# Discovery (no commit, just citations in builds/<slug>.md)
|
|
138
|
+
$ rg "ViewEmail" src/ tests/
|
|
139
|
+
src/lib/permissions.ts:14: ...
|
|
140
|
+
tests/unit/permissions.test.ts:23: ...
|
|
141
|
+
|
|
142
|
+
# RED
|
|
143
|
+
$ git add tests/unit/permissions.test.ts
|
|
144
|
+
$ node .cclaw/hooks/commit-helper.mjs --ac=AC-1 --phase=red \\
|
|
145
|
+
--message="red(AC-1): tooltip shows email when permission set"
|
|
146
|
+
[commit-helper] AC-1 phase=red committed as a1b2c3d
|
|
147
|
+
[commit-helper] watched-RED proof: 1 failing test (Tooltip › renders email)
|
|
148
|
+
|
|
149
|
+
# GREEN
|
|
150
|
+
$ git add src/lib/permissions.ts src/components/dashboard/RequestCard.tsx
|
|
151
|
+
$ node .cclaw/hooks/commit-helper.mjs --ac=AC-1 --phase=green \\
|
|
152
|
+
--message="green(AC-1): hasViewEmail check + branch in tooltip"
|
|
153
|
+
[commit-helper] AC-1 phase=green committed as 4e5f6a7
|
|
154
|
+
[commit-helper] full suite: 47 passed, 0 failed
|
|
155
|
+
|
|
156
|
+
# REFACTOR — applied
|
|
157
|
+
$ git add src/lib/permissions.ts
|
|
158
|
+
$ node .cclaw/hooks/commit-helper.mjs --ac=AC-1 --phase=refactor \\
|
|
159
|
+
--message="refactor(AC-1): extract hasViewEmail to permissions.ts"
|
|
160
|
+
[commit-helper] AC-1 phase=refactor committed as 9e2c3a4
|
|
161
|
+
[commit-helper] AC-1 cycle complete (red, green, refactor)
|
|
162
|
+
\`\`\`
|
|
163
|
+
|
|
164
|
+
\`builds/<slug>.md\` row appended at the end, with all six columns filled.
|
|
165
|
+
|
|
166
|
+
## Worked example — REFACTOR explicitly skipped
|
|
167
|
+
|
|
168
|
+
\`\`\`bash
|
|
169
|
+
$ node .cclaw/hooks/commit-helper.mjs --ac=AC-2 --phase=refactor --skipped \\
|
|
170
|
+
--message="refactor(AC-2) skipped: 8-line addition, idiomatic; nothing to extract"
|
|
171
|
+
[commit-helper] AC-2 phase=refactor skipped (recorded)
|
|
172
|
+
[commit-helper] AC-2 cycle complete (red, green, refactor=skipped)
|
|
173
|
+
\`\`\`
|
|
174
|
+
|
|
175
|
+
## Fix-only flow (after a review iteration)
|
|
176
|
+
|
|
177
|
+
The latest review block in \`reviews/<slug>.md\` cites file:line refs and findings F-N. You may touch only those files. The TDD cycle still applies:
|
|
178
|
+
|
|
179
|
+
- **F-N changes observable behaviour** → write a new RED test that encodes the corrected behaviour, then GREEN, then REFACTOR. Use the same AC-N id; commit messages reference the finding (e.g. \`red(AC-1): fix F-2 — empty-input case\`).
|
|
180
|
+
- **F-N is purely a refactor** (no behaviour change) → commit under \`--phase=refactor\`. The reviewer's clear decision still requires the prior RED + GREEN to remain in the chain.
|
|
181
|
+
- **F-N is a docs / log / config nit** → commit as a single \`--phase=refactor\` (or \`--phase=refactor --skipped\` if the change is part of an existing GREEN delta and only the message needs to record it).
|
|
182
|
+
|
|
183
|
+
A separate fix block is appended to \`builds/<slug>.md\`:
|
|
184
|
+
|
|
185
|
+
\`\`\`markdown
|
|
186
|
+
### Fix iteration 1 — review block 1
|
|
187
|
+
|
|
188
|
+
| F-N | AC | phase | commit | files | note |
|
|
189
|
+
| --- | --- | --- | --- | --- | --- |
|
|
190
|
+
| F-2 | AC-1 | red | bbbcccc | tests/unit/permissions.test.ts:55 | empty-input case asserts fallback to display name |
|
|
191
|
+
| F-2 | AC-1 | green | dddeeee | src/components/dashboard/RequestCard.tsx:97 | guard against null displayName |
|
|
192
|
+
| F-2 | AC-1 | refactor (skipped) | — | — | 6-line guard, idiomatic |
|
|
193
|
+
\`\`\`
|
|
194
|
+
|
|
195
|
+
## Edge cases
|
|
196
|
+
|
|
197
|
+
- **The plan is wrong.** If implementing the AC requires touching files the plan rules out, **stop** and surface the conflict. Do not silently revise the plan.
|
|
198
|
+
- **The AC is not testable as written.** Stop. Raise it as a finding for planner ("AC-N is not observable; needs revision"). The orchestrator hands it back.
|
|
199
|
+
- **commit-helper rejects the commit** (RED missing before GREEN, AC not in flow-state, schemaVersion mismatch, nothing staged). Read the error, fix the cause, retry. Never bypass the hook.
|
|
200
|
+
- **A formatter / type-script transform rewrites untouched files.** Configure your editor / pre-commit to format only staged files; if it cannot, stage diff hunks via \`git add -p\`.
|
|
201
|
+
- **Conflict with another slice in parallel-build.** Stop, raise an integration finding, ask the orchestrator. Do not merge by hand.
|
|
202
|
+
- **Test framework not present in the project.** Skip the RED phase only if the plan explicitly declares the slug is "test-infra bootstrap" with AC-1 = "test framework installed and one passing test exists". The orchestrator must be told before this happens.
|
|
203
|
+
|
|
204
|
+
## Summary block (return at the end of each AC)
|
|
205
|
+
|
|
206
|
+
\`\`\`json
|
|
207
|
+
{
|
|
208
|
+
"specialist": "slice-builder",
|
|
209
|
+
"mode": "build|fix-only",
|
|
210
|
+
"ac": "AC-N",
|
|
211
|
+
"phases": {
|
|
212
|
+
"red": {"sha": "a1b2c3d", "test_file": "tests/unit/permissions.test.ts", "watched_red_proof": "Tooltip › renders email — expected 'anna@…' got undefined"},
|
|
213
|
+
"green": {"sha": "4e5f6a7", "files": ["src/lib/permissions.ts:14"], "suite_evidence": "npm test src/lib/permissions.ts → 47 passed, 0 failed"},
|
|
214
|
+
"refactor": {"sha": "9e2c3a4", "applied": true, "shape_change": "extract hasViewEmail helper"}
|
|
215
|
+
},
|
|
216
|
+
"next_action": "next AC | hand off to reviewer | stop and surface"
|
|
217
|
+
}
|
|
218
|
+
\`\`\`
|
|
219
|
+
|
|
220
|
+
If \`refactor.applied\` is \`false\`, replace \`sha\` with \`null\` and add \`"reason": "..."\`.
|
|
221
|
+
|
|
222
|
+
## Composition
|
|
223
|
+
|
|
224
|
+
You are an **on-demand specialist**, not an orchestrator. The cclaw orchestrator decides when to invoke you and what to do with your output.
|
|
225
|
+
|
|
226
|
+
- **Invoked by**: \`/cc\` Step 5 — *Build (TDD cycle)*, once for each AC in inline-sequential topology, or up to 5 parallel instances (one per slice) in parallel-build topology.
|
|
227
|
+
- **Wraps you**: \`lib/runbooks/build.md\`; \`lib/skills/tdd-cycle.md\`; \`lib/skills/parallel-build.md\` (when dispatched in parallel); \`lib/skills/ac-traceability.md\`. Mandatory hook: \`hooks/commit-helper.mjs\`.
|
|
228
|
+
- **Do not spawn**: never invoke brainstormer, architect, planner, reviewer, or security-reviewer. If the AC is not implementable as written, stop and surface the conflict in your summary JSON; the orchestrator hands the slug back to planner.
|
|
229
|
+
- **Side effects allowed**: production code, test code, commits via \`commit-helper.mjs\`, and append-only entries in \`flows/<slug>/build.md\`. Do **not** edit \`flows/<slug>/plan.md\`, \`decisions.md\`, \`review.md\`, hooks, or slash-command files. Do **not** push, open a PR, or merge — those require explicit user approval at \`/cc\` Step 7 (Ship).
|
|
230
|
+
- **Parallel-dispatch contract**: when invoked as one of N parallel slice-builders, you own *only* the AC ids declared in your slice's \`assigned_ac\` list and *only* the files under your slice's \`touchSurface\`. Touching a file outside your touchSurface is a contract violation and must be surfaced as a finding, not silently merged.
|
|
231
|
+
- **Stop condition**: you finish when every assigned AC has \`status: committed\` (RED → GREEN → REFACTOR phases logged) and the summary JSON is returned. Do not run the full review pass — that is reviewer's job.
|
|
232
|
+
`;
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
const PLAN_PLAYBOOK = `# Stage runbook — plan
|
|
2
|
+
|
|
3
|
+
The orchestrator opens this file before authoring or amending \`plans/<slug>.md\`. The runbook is a checklist; obey it in order.
|
|
4
|
+
|
|
5
|
+
## 0. Decide whether this is plan-stage or trivial-edit
|
|
6
|
+
|
|
7
|
+
If the task is a typo / format / rename limited to ≤1 file and ≤30 lines, **skip plan-stage**:
|
|
8
|
+
|
|
9
|
+
- create the change directly,
|
|
10
|
+
- stage it,
|
|
11
|
+
- run \`commit-helper.mjs --ac=AC-1 --message="..."\` with a one-line AC declared inline (no \`plan.md\` file),
|
|
12
|
+
- proceed to ship.
|
|
13
|
+
|
|
14
|
+
For anything else, continue with this runbook.
|
|
15
|
+
|
|
16
|
+
## 1. Read or seed the plan template
|
|
17
|
+
|
|
18
|
+
\`.cclaw/lib/templates/plan.md\` is the canonical seed. The orchestrator copies it to \`.cclaw/flows/<slug>/plan.md\` and replaces \`SLUG-PLACEHOLDER\` with the real slug.
|
|
19
|
+
|
|
20
|
+
If the slug already exists (active or shipped), the orchestrator must instead read the existing artifact and let the user pick **amend / rewrite / refine shipped / resume cancelled / new**. See \`.cclaw/lib/skills/refinement.md\`.
|
|
21
|
+
|
|
22
|
+
## 2. Apply pre-flight checks from reference patterns
|
|
23
|
+
|
|
24
|
+
If the task matches a pattern in \`.cclaw/lib/patterns/\`, open the pattern file and use its pre-flight checklist verbatim. Multiple patterns can apply (e.g. an endpoint that is also security-sensitive); merge their AC shape sections. Do not pull AC from a pattern that does not match the task.
|
|
25
|
+
|
|
26
|
+
## 3. Decide which discovery specialists to propose
|
|
27
|
+
|
|
28
|
+
| signal | propose |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| ambiguous goal, no clear "user observable" sentence | \`brainstormer\` |
|
|
31
|
+
| competing structural options or feasibility uncertainty | \`architect\` |
|
|
32
|
+
| more than 5 AC, or AC that span multiple modules | \`planner\` |
|
|
33
|
+
|
|
34
|
+
The orchestrator must ask the user before invoking specialists — never invoke silently. The user can accept all, accept some, or accept none. Document the choice in the plan body.
|
|
35
|
+
|
|
36
|
+
## 4. AC quality bar
|
|
37
|
+
|
|
38
|
+
Every AC must pass three checks before the plan is considered authored:
|
|
39
|
+
|
|
40
|
+
- **observable** — a user, test, or operator can tell whether it is satisfied without reading the diff.
|
|
41
|
+
- **independently committable** — a single commit covering only this AC is meaningful.
|
|
42
|
+
- **verifiable** — the AC has an explicit verification line (test name, manual step, or command).
|
|
43
|
+
|
|
44
|
+
AC that fail any of the three checks are not real AC. Reject them or rewrite them.
|
|
45
|
+
|
|
46
|
+
## 5. Topology
|
|
47
|
+
|
|
48
|
+
\`inline\` is the default. The orchestrator only proposes \`parallel-build\` when:
|
|
49
|
+
|
|
50
|
+
1. ≥4 AC AND ≥2 distinct touchSurface clusters.
|
|
51
|
+
2. Every AC in a parallel wave has \`parallelSafe: true\`.
|
|
52
|
+
3. No AC depends on the output of another AC in the same wave.
|
|
53
|
+
4. The slug fits in **≤5 parallel slices** (slice = 1+ AC sharing a touchSurface). If planner produces more than 5 slices, merge thinner slices into fatter ones — never generate "wave 2".
|
|
54
|
+
|
|
55
|
+
The orchestrator must not silently choose \`parallel-build\`. Always surface the topology and ask the user to confirm. See \`.cclaw/lib/skills/parallel-build.md\` for the worktree dispatch pattern and the silent fallback to \`inline\` when the harness does not support sub-agent dispatch.
|
|
56
|
+
|
|
57
|
+
## 6. Hand-off
|
|
58
|
+
|
|
59
|
+
Plan-stage ends when:
|
|
60
|
+
|
|
61
|
+
- frontmatter is filled in (slug, stage, status=active, ac with ids and pending statuses, last_specialist, refines, security_flag),
|
|
62
|
+
- AC table in the body matches the frontmatter,
|
|
63
|
+
- traceability block lists \`AC-N → commit pending\` for every AC,
|
|
64
|
+
- the user has approved the plan (an explicit "ok"; never proceed without it).
|
|
65
|
+
|
|
66
|
+
Then the orchestrator transitions to build-stage.
|
|
67
|
+
|
|
68
|
+
## 7. Common pitfalls
|
|
69
|
+
|
|
70
|
+
- Pulling the entire pattern file into the plan body. Cite the pattern; do not duplicate it.
|
|
71
|
+
- Inventing AC that mirror sub-tasks instead of outcomes. AC are outcomes.
|
|
72
|
+
- Skipping the security_flag in plans that touch authn / authz / secrets / supply chain / data exposure.
|
|
73
|
+
- Authoring more than 12 AC. Above 12 the request is two requests; ask the user to split.
|
|
74
|
+
`;
|
|
75
|
+
const BUILD_PLAYBOOK = `# Stage runbook — build (TDD cycle)
|
|
76
|
+
|
|
77
|
+
**Build is a TDD cycle.** Every AC goes through RED → GREEN → REFACTOR. There is no other build mode. The orchestrator opens this file before invoking \`slice-builder\` or implementing inline; \`slice-builder\` opens it on every AC.
|
|
78
|
+
|
|
79
|
+
## Iron Law
|
|
80
|
+
|
|
81
|
+
> NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST. THE RED FAILURE IS THE SPEC.
|
|
82
|
+
|
|
83
|
+
Build refuses to commit production code that is not preceded by a recorded RED test. \`commit-helper.mjs\` invocations carry a \`--phase\` flag (\`red\` / \`green\` / \`refactor\`) so the AC traceability chain encodes the cycle.
|
|
84
|
+
|
|
85
|
+
## 1. Pick the next pending AC
|
|
86
|
+
|
|
87
|
+
Read \`.cclaw/state/flow-state.json\` and pick the first AC with \`status: pending\`. If none, exit build-stage and transition to review.
|
|
88
|
+
|
|
89
|
+
## 2. Discover before RED (mandatory)
|
|
90
|
+
|
|
91
|
+
Before writing the failing test, **read** the affected surface:
|
|
92
|
+
|
|
93
|
+
- Existing test files for the module (run \`rg\` for the function name in \`tests/\`).
|
|
94
|
+
- Fixture and helper files used by the closest existing tests.
|
|
95
|
+
- The runnable command(s) that execute those tests (\`npm test path\`, \`pytest path\`, \`go test ./pkg/...\`).
|
|
96
|
+
- Public API surfaces, callbacks, state transitions, schemas, and contracts the AC touches.
|
|
97
|
+
|
|
98
|
+
Cite each citation as \`file:path:line\`. No invented paths. If the planner cited a file that does not exist, **stop** and surface it back as a planner-stage finding.
|
|
99
|
+
|
|
100
|
+
The discovery output goes into \`builds/<slug>.md\` under the AC's row, in the **Discovery** column. Skipping discovery is one of the five mandatory gate failures.
|
|
101
|
+
|
|
102
|
+
## 3. RED — write a failing test that encodes the AC verification
|
|
103
|
+
|
|
104
|
+
Rules for the RED phase:
|
|
105
|
+
|
|
106
|
+
- Touch test files only. **No production edits in the RED commit.**
|
|
107
|
+
- The test must fail for the **right reason** — the assertion that encodes the AC, not a syntax error or import error.
|
|
108
|
+
- Capture the test runner output that proves the failure. The captured output is the **watched-RED proof**.
|
|
109
|
+
- One AC = one RED commit. If the AC needs more than one test to be observable, stage them all and commit together.
|
|
110
|
+
- **Test files are named after the unit under test, never after the AC id.** \`tests/unit/permissions.test.ts\` is correct; \`AC-1.test.ts\` / \`tests/AC-2.test.ts\` is wrong. The AC id lives in the test name (\`it('AC-1: …', …)\`), the commit message, and the build log — not in the filename.
|
|
111
|
+
|
|
112
|
+
Stage and commit:
|
|
113
|
+
|
|
114
|
+
\`\`\`bash
|
|
115
|
+
git add tests/path/to/new-or-updated.test.ts
|
|
116
|
+
node .cclaw/hooks/commit-helper.mjs --ac=AC-N --phase=red \\
|
|
117
|
+
--message="red(AC-N): assert <observable behaviour>"
|
|
118
|
+
\`\`\`
|
|
119
|
+
|
|
120
|
+
Append the watched-RED proof to \`builds/<slug>.md\` under the AC row, in the **RED proof** column (test name + 1-2 line failure excerpt).
|
|
121
|
+
|
|
122
|
+
## 4. GREEN — minimal production change to make RED pass
|
|
123
|
+
|
|
124
|
+
Rules for the GREEN phase:
|
|
125
|
+
|
|
126
|
+
- Smallest possible production diff that turns RED into PASS.
|
|
127
|
+
- Run the **full relevant suite**, not the single test, before committing. A passing single test with the rest of the suite broken is not GREEN.
|
|
128
|
+
- Capture the suite output (command + PASS/FAIL summary). This is the **GREEN evidence**.
|
|
129
|
+
- Touch only files declared in the plan. If the GREEN-correct change requires touching files outside the plan, **stop** and surface it. Scope creep is not progress.
|
|
130
|
+
|
|
131
|
+
Stage and commit:
|
|
132
|
+
|
|
133
|
+
\`\`\`bash
|
|
134
|
+
git add src/path/to/implementation.ts
|
|
135
|
+
node .cclaw/hooks/commit-helper.mjs --ac=AC-N --phase=green \\
|
|
136
|
+
--message="green(AC-N): minimal impl that satisfies RED"
|
|
137
|
+
\`\`\`
|
|
138
|
+
|
|
139
|
+
Append the GREEN evidence to \`builds/<slug>.md\` under the AC row, in the **GREEN evidence** column.
|
|
140
|
+
|
|
141
|
+
## 5. REFACTOR — keep behaviour, improve shape (mandatory)
|
|
142
|
+
|
|
143
|
+
REFACTOR is **not optional**. Even when the GREEN diff feels clean, run a deliberate refactor pass:
|
|
144
|
+
|
|
145
|
+
- Behaviour-preserving cleanups: rename, extract, inline, deduplicate, narrow types.
|
|
146
|
+
- Run the same suite again after the refactor; it must still pass with **identical expected output**.
|
|
147
|
+
- If no refactor is warranted (the GREEN diff is genuinely minimal and idiomatic), **say so explicitly** in the row's **REFACTOR notes** column ("no refactor: 12-line addition, idiomatic"). Silence is not acceptable; the gate exists to force the question.
|
|
148
|
+
|
|
149
|
+
If a refactor lands, commit it separately:
|
|
150
|
+
|
|
151
|
+
\`\`\`bash
|
|
152
|
+
git add src/path/to/refactored.ts
|
|
153
|
+
node .cclaw/hooks/commit-helper.mjs --ac=AC-N --phase=refactor \\
|
|
154
|
+
--message="refactor(AC-N): <one-line shape change>"
|
|
155
|
+
\`\`\`
|
|
156
|
+
|
|
157
|
+
Otherwise call \`commit-helper.mjs --ac=AC-N --phase=refactor --skipped\` so the chain records the explicit decision.
|
|
158
|
+
|
|
159
|
+
## 6. Append the AC row to builds/<slug>.md
|
|
160
|
+
|
|
161
|
+
After REFACTOR, the AC row in \`.cclaw/flows/<slug>/build.md\` carries:
|
|
162
|
+
|
|
163
|
+
| AC | Discovery | RED proof | GREEN evidence | REFACTOR notes | commits |
|
|
164
|
+
| --- | --- | --- | --- | --- | --- |
|
|
165
|
+
| AC-N | tests/path:line, fixtures... | test name + failure excerpt | command + PASS summary | one-line shape change or "skipped: reason" | red SHA, green SHA, refactor SHA (or "skipped") |
|
|
166
|
+
|
|
167
|
+
The build is complete for this AC only when all six columns are filled.
|
|
168
|
+
|
|
169
|
+
## 7. Repeat or hand off
|
|
170
|
+
|
|
171
|
+
If more AC are pending, repeat from step 1. If all AC are through REFACTOR, transition to review-stage.
|
|
172
|
+
|
|
173
|
+
## 8. Fix-only flow (after a review iteration)
|
|
174
|
+
|
|
175
|
+
When \`reviewer\` returns \`block\`, the slice-builder is dispatched in \`fix-only\` mode bound to the file:line refs from the latest review block. The TDD cycle still applies:
|
|
176
|
+
|
|
177
|
+
- if the fix changes observable behaviour, write a new RED test that encodes the corrected behaviour, then GREEN, then REFACTOR;
|
|
178
|
+
- if the fix is purely a refactor of existing code (no behaviour change), commit it under \`--phase=refactor\` with a citation of the F-N finding;
|
|
179
|
+
- the AC id stays the same (\`commit-helper.mjs --ac=AC-N --phase=… --message="fix: F-N …"\`);
|
|
180
|
+
- a separate set of rows in \`builds/<slug>.md\` records F-N → phase → commit.
|
|
181
|
+
|
|
182
|
+
## 9. Mandatory gates (every AC)
|
|
183
|
+
|
|
184
|
+
Before transitioning to review, every AC must satisfy:
|
|
185
|
+
|
|
186
|
+
1. **discovery_complete** — relevant tests / fixtures / helpers / commands cited.
|
|
187
|
+
2. **impact_check_complete** — affected callbacks / state / interfaces / contracts named.
|
|
188
|
+
3. **red_test_written** — failing test exists, recorded with watched-RED proof.
|
|
189
|
+
4. **red_fails_for_right_reason** — RED captured a real assertion failure, not a syntax error.
|
|
190
|
+
5. **green_full_suite** — full relevant suite green after GREEN, not the single test.
|
|
191
|
+
6. **refactor_completed_or_skipped_with_reason** — REFACTOR ran, or was explicitly skipped with a one-line reason.
|
|
192
|
+
7. **traceable_to_plan** — AC commits reference plan AC ids and the plan's file set.
|
|
193
|
+
8. **commit_chain_intact** — \`commit-helper.mjs\` recorded RED + GREEN + REFACTOR SHAs in flow-state.
|
|
194
|
+
|
|
195
|
+
\`commit-helper.mjs\` enforces 1, 3, 6, 8 mechanically. The reviewer enforces 2, 4, 5, 7 in iteration 1.
|
|
196
|
+
|
|
197
|
+
## 10. Common pitfalls
|
|
198
|
+
|
|
199
|
+
- Skipping RED because "the implementation is obvious". The cycle is the contract; obvious code still gets a test.
|
|
200
|
+
- Single test passes, full suite fails, but commit anyway. That is not GREEN; it is a regression.
|
|
201
|
+
- REFACTOR phase silently skipped. Always emit the explicit "skipped: reason" note.
|
|
202
|
+
- Writing production code in the RED commit. Stage and commit test files only in the RED phase.
|
|
203
|
+
- Bypassing commit-helper "just this once". The traceability gate breaks.
|
|
204
|
+
- \`git add -A\` inside build. Stage AC-related files only.
|
|
205
|
+
- Refactoring across files outside the AC scope. That is a separate slug.
|
|
206
|
+
`;
|
|
207
|
+
const REVIEW_PLAYBOOK = `# Stage runbook — review
|
|
208
|
+
|
|
209
|
+
The orchestrator opens this file before invoking \`reviewer\` (and \`security-reviewer\` when applicable).
|
|
210
|
+
|
|
211
|
+
## 1. Choose the mode(s)
|
|
212
|
+
|
|
213
|
+
| mode | when |
|
|
214
|
+
| --- | --- |
|
|
215
|
+
| \`code\` | always, immediately after build commits land |
|
|
216
|
+
| \`text-review\` | before ship if plan / decisions / ship-notes are non-trivial |
|
|
217
|
+
| \`integration\` | after \`parallel-build\` completes |
|
|
218
|
+
| \`release\` | before push when the change is user-visible |
|
|
219
|
+
| \`adversarial\` | at least once for risky / security-sensitive slugs |
|
|
220
|
+
|
|
221
|
+
\`security-reviewer\` runs in addition to (not instead of) \`reviewer\` when the task or diff touches sensitive surfaces. They can run in parallel.
|
|
222
|
+
|
|
223
|
+
## 2. Iterate
|
|
224
|
+
|
|
225
|
+
Each iteration appends a block to \`.cclaw/flows/<slug>/review.md\`:
|
|
226
|
+
|
|
227
|
+
- iteration number, mode, reviewer (id),
|
|
228
|
+
- findings table (id F-N, severity, AC ref, file:path:line, finding, fix),
|
|
229
|
+
- Five Failure Modes pass (yes/no per mode, citation when yes),
|
|
230
|
+
- decision: \`block\` / \`warn\` / \`clear\` / \`cap-reached\`.
|
|
231
|
+
|
|
232
|
+
## 3. Hard cap
|
|
233
|
+
|
|
234
|
+
5 review/fix iterations per slug. After the 5th, write \`status: cap-reached\` and stop. Surface the remaining blockers; recommend \`/cc-cancel\` or splitting the work into a fresh slug.
|
|
235
|
+
|
|
236
|
+
The cap is per-slug, not per-mode. Five iterations of \`code\` and one of \`text-review\` is six total — the cap is hit at five.
|
|
237
|
+
|
|
238
|
+
## 4. Block findings → fix-only
|
|
239
|
+
|
|
240
|
+
A \`block\` decision dispatches \`slice-builder\` in \`fix-only\` mode bound to the cited file:line refs. After the fix lands, the orchestrator re-invokes the same reviewer mode and continues iterating.
|
|
241
|
+
|
|
242
|
+
## 5. Warn findings
|
|
243
|
+
|
|
244
|
+
A \`warn\` does not block ship, but the warning must be recorded in \`reviews/<slug>.md\` and surfaced in \`ships/<slug>.md\`. The user can decide to fix it inline or capture it as a follow-up.
|
|
245
|
+
|
|
246
|
+
## 6. Five Failure Modes pass (mandatory)
|
|
247
|
+
|
|
248
|
+
Every iteration explicitly answers each mode: yes / no, with citation when yes.
|
|
249
|
+
|
|
250
|
+
1. **Hallucinated actions** — invented files, ids, env vars, function names, command flags?
|
|
251
|
+
2. **Scope creep** — diff touches files no AC mentions?
|
|
252
|
+
3. **Cascading errors** — one fix introduces typecheck / runtime / test failures elsewhere?
|
|
253
|
+
4. **Context loss** — earlier decisions / AC text / brainstormer scope ignored?
|
|
254
|
+
5. **Tool misuse** — destructive operations (force push, rm -rf, schema migration without backup), wrong-mode tool calls?
|
|
255
|
+
|
|
256
|
+
A "yes" without a citation is itself a finding.
|
|
257
|
+
|
|
258
|
+
## 7. Hand-off
|
|
259
|
+
|
|
260
|
+
Review-stage ends when an iteration returns \`clear\` or \`cap-reached\`. \`clear\` proceeds to ship; \`cap-reached\` stops the flow and surfaces remaining work.
|
|
261
|
+
|
|
262
|
+
## 8. Common pitfalls
|
|
263
|
+
|
|
264
|
+
- Running review without first checking that all AC are \`status: committed\`. If anything is pending, build-stage isn't done.
|
|
265
|
+
- Skipping the Five Failure Modes pass because "I already looked". The pass is the artifact; "I already looked" is not.
|
|
266
|
+
- Writing findings without file:line. A finding without a target is speculation.
|
|
267
|
+
- Letting iteration counts grow silently. The cap exists for a reason.
|
|
268
|
+
`;
|
|
269
|
+
const SHIP_PLAYBOOK = `# Stage runbook — ship
|
|
270
|
+
|
|
271
|
+
The orchestrator opens this file before invoking \`runCompoundAndShip()\` (or its harness equivalent).
|
|
272
|
+
|
|
273
|
+
> **Iron Law:** NO MERGE WITHOUT GREEN PREFLIGHT, A WRITTEN ROLLBACK, AND EXACTLY ONE SELECTED FINALIZATION MODE. No exceptions for urgency. If no VCS is available, use \`FINALIZE_NO_VCS\` explicitly instead of inventing git steps.
|
|
274
|
+
|
|
275
|
+
## 1. AC traceability gate
|
|
276
|
+
|
|
277
|
+
Before anything else, verify every AC in flow-state.json is \`status: committed\` with a real SHA. If any AC is pending, the gate refuses ship. Stop and either complete the AC or open a fresh slug for the rest.
|
|
278
|
+
|
|
279
|
+
The gate is enforced inside the runtime; you cannot bypass it. If you think you must, you don't.
|
|
280
|
+
|
|
281
|
+
## 2. Run preflight checks (fresh output)
|
|
282
|
+
|
|
283
|
+
Every check below must produce fresh output in this turn. Pasting "tests passed yesterday" does not count.
|
|
284
|
+
|
|
285
|
+
\\\`\\\`\\\`bash
|
|
286
|
+
$ npm test
|
|
287
|
+
$ npm run build
|
|
288
|
+
$ npm run lint
|
|
289
|
+
$ npm run typecheck
|
|
290
|
+
$ git status --porcelain
|
|
291
|
+
\\\`\\\`\\\`
|
|
292
|
+
|
|
293
|
+
Record each result in \`flows/<slug>/ship.md > Preflight checks\` (table). Set frontmatter \`preflight_passed: true\` only when every row is pass/empty. Any failure blocks ship; you do not move on until preflight is fully green.
|
|
294
|
+
|
|
295
|
+
## 3. Detect repository mode
|
|
296
|
+
|
|
297
|
+
\\\`\\\`\\\`bash
|
|
298
|
+
$ test -d .git && echo git || echo no-vcs
|
|
299
|
+
\\\`\\\`\\\`
|
|
300
|
+
|
|
301
|
+
If no-vcs, the only valid finalization mode is \`FINALIZE_NO_VCS\`. Document the manual handoff target and rollback owner; skip the merge-base step.
|
|
302
|
+
|
|
303
|
+
## 4. Merge-base detection (git mode only)
|
|
304
|
+
|
|
305
|
+
\\\`\\\`\\\`bash
|
|
306
|
+
$ git merge-base HEAD <base-branch>
|
|
307
|
+
$ git rev-list --count <merge-base>..<base-branch>
|
|
308
|
+
\\\`\\\`\\\`
|
|
309
|
+
|
|
310
|
+
If the count is non-zero AND any of those upstream commits touch this slug's \`touchSurface\`, rebase first. After the rebase, re-run preflight from step 2; do not trust the prior preflight result.
|
|
311
|
+
|
|
312
|
+
## 5. Author ships/<slug>.md
|
|
313
|
+
|
|
314
|
+
Seed from \`.cclaw/lib/templates/ship.md\`. Required sections (every one must be filled, no placeholders):
|
|
315
|
+
|
|
316
|
+
- summary (2-4 lines),
|
|
317
|
+
- preflight checks (table with command + fresh output),
|
|
318
|
+
- repo mode (\`git\` / \`no-vcs\`),
|
|
319
|
+
- merge-base detection (git mode only),
|
|
320
|
+
- AC ↔ commit map with red/green/refactor SHAs from \`flow-state.ac[].phases\`,
|
|
321
|
+
- rollback plan triplet (trigger / steps / verification — all three or it does not count),
|
|
322
|
+
- monitoring checklist (error rates, latency budgets, business metrics),
|
|
323
|
+
- finalization_mode (exactly one of FINALIZE_MERGE_LOCAL, FINALIZE_OPEN_PR, FINALIZE_KEEP_BRANCH, FINALIZE_DISCARD_BRANCH, FINALIZE_NO_VCS),
|
|
324
|
+
- breaking changes / migration ("none" is a valid value),
|
|
325
|
+
- release notes (one paragraph suitable for CHANGELOG.md),
|
|
326
|
+
- risks carried over (warn-severity ledger rows, open assumptions),
|
|
327
|
+
- victory detector check.
|
|
328
|
+
|
|
329
|
+
## 6. Victory Detector
|
|
330
|
+
|
|
331
|
+
Ship is allowed only when ALL of these are true:
|
|
332
|
+
|
|
333
|
+
- review verdict = \`clear\` or \`warn\` (with convergence signal #2 fired),
|
|
334
|
+
- preflight_passed = true with fresh output recorded in this turn,
|
|
335
|
+
- rollback_recorded = true with all three fields filled,
|
|
336
|
+
- finalization_mode set to exactly one enum value,
|
|
337
|
+
- repo_mode matches the chosen finalization mode (\`no-vcs\` cannot pick \`FINALIZE_MERGE_LOCAL\`).
|
|
338
|
+
|
|
339
|
+
If any condition fails, keep \`status: blocked\` and iterate. Do NOT advance with red preflight or a missing rollback.
|
|
340
|
+
|
|
341
|
+
## 7. Run compound
|
|
342
|
+
|
|
343
|
+
\`runCompoundAndShip()\` does the gate check, captures learnings if the quality gate passes, moves all active artifacts to \`.cclaw/flows/shipped/<slug>/\`, writes a \`manifest.md\`, appends to \`knowledge.jsonl\` if learnings were captured, and resets flow-state.
|
|
344
|
+
|
|
345
|
+
The compound quality gate captures \`learnings/<slug>.md\` only when at least one of:
|
|
346
|
+
|
|
347
|
+
- \`architect\` or \`planner\` recorded a non-trivial decision,
|
|
348
|
+
- review needed ≥3 iterations,
|
|
349
|
+
- a security review ran or \`security_flag\` is true,
|
|
350
|
+
- the user explicitly asked.
|
|
351
|
+
|
|
352
|
+
When the gate fails, the run still ships — only the learning capture is skipped.
|
|
353
|
+
|
|
354
|
+
## 8. Execute finalization
|
|
355
|
+
|
|
356
|
+
Run the action implied by \`finalization_mode\` and record the result back into \`ships/<slug>.md\`:
|
|
357
|
+
|
|
358
|
+
- **FINALIZE_MERGE_LOCAL** — merge into the base branch locally; verify clean merge; record the merged SHA.
|
|
359
|
+
- **FINALIZE_OPEN_PR** — \`gh pr create\` with a structured body (summary, AC↔commit map, rollback plan). Record the PR URL.
|
|
360
|
+
- **FINALIZE_KEEP_BRANCH** — \`git push -u origin HEAD\`. Record the upstream branch.
|
|
361
|
+
- **FINALIZE_DISCARD_BRANCH** — list what will be deleted, require typed confirmation in this turn (\`yes, discard <slug>\`), then delete. Record the deletion.
|
|
362
|
+
- **FINALIZE_NO_VCS** — record handoff target, artifact bundle path, and manual rollback owner. No git commands.
|
|
363
|
+
|
|
364
|
+
**Always ask before pushing.** Always ask before opening a PR. Do not run \`git push --force\` ever — if the user requests it explicitly, surface the warning and require a second confirmation.
|
|
365
|
+
|
|
366
|
+
## 9. Hand-off
|
|
367
|
+
|
|
368
|
+
Ship-stage ends when:
|
|
369
|
+
|
|
370
|
+
- \`flows/shipped/<slug>/manifest.md\` exists,
|
|
371
|
+
- flow-state is reset,
|
|
372
|
+
- the user is told push/PR status (whether approved or skipped),
|
|
373
|
+
- the rollback plan is sticky in \`ships/<slug>.md\` (the future operator opens this if anything goes wrong).
|
|
374
|
+
|
|
375
|
+
The next \`/cc\` invocation can be a brand-new request or a refinement of this slug.
|
|
376
|
+
|
|
377
|
+
## 10. Common pitfalls
|
|
378
|
+
|
|
379
|
+
- Skipping preflight because "tests passed during build". Preflight is the post-merge sanity check; build-stage tests are pre-merge.
|
|
380
|
+
- Skipping the rollback plan because "it's a small change". Small changes break production too. The triplet is mandatory.
|
|
381
|
+
- Selecting multiple finalization modes. Pick exactly one.
|
|
382
|
+
- Picking \`FINALIZE_MERGE_LOCAL\` in a repo with no \`.git/\`. The Victory Detector will refuse; use \`FINALIZE_NO_VCS\` and record the manual target.
|
|
383
|
+
- Pushing without asking. Always ask, always wait, every time.
|
|
384
|
+
- Opening a PR with stale release notes. Re-read \`ships/<slug>.md\` before opening the PR.
|
|
385
|
+
- Skipping the manifest because "the slug is small". The manifest is the entry point future agents use to understand the slug; skipping it makes refinement harder later.
|
|
386
|
+
- Editing artifacts after they're moved to \`.cclaw/flows/shipped/\`. Shipped slugs are read-only. Refinement creates a new slug.
|
|
387
|
+
- Using \`git push --force\` to "fix" the ship_commit. Never. Open a follow-up slug instead.
|
|
388
|
+
`;
|
|
389
|
+
export const STAGE_PLAYBOOKS = [
|
|
390
|
+
{ id: "plan", fileName: "plan.md", title: "Stage runbook — plan", body: PLAN_PLAYBOOK },
|
|
391
|
+
{ id: "build", fileName: "build.md", title: "Stage runbook — build", body: BUILD_PLAYBOOK },
|
|
392
|
+
{ id: "review", fileName: "review.md", title: "Stage runbook — review", body: REVIEW_PLAYBOOK },
|
|
393
|
+
{ id: "ship", fileName: "ship.md", title: "Stage runbook — ship", body: SHIP_PLAYBOOK }
|
|
394
|
+
];
|
|
395
|
+
export const STAGE_PLAYBOOKS_INDEX = `# .cclaw/lib/runbooks/
|
|
396
|
+
|
|
397
|
+
Per-stage runbooks the orchestrator opens before transitioning into a stage. Each runbook is a strict checklist plus the common pitfalls collected from prior runs.
|
|
398
|
+
|
|
399
|
+
| stage | runbook |
|
|
400
|
+
| --- | --- |
|
|
401
|
+
${STAGE_PLAYBOOKS.map((p) => `| ${p.id} | [\`${p.fileName}\`](./${p.fileName}) |`).join("\n")}
|
|
402
|
+
|
|
403
|
+
The runbooks are intentionally redundant with the specialist prompts and skills — when the orchestrator is mid-stage and short on context budget, the runbook is the smallest self-contained reference.
|
|
404
|
+
`;
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* No args → reads existing flow state and progresses it when a tracked flow
|
|
4
|
-
* already exists; missing state/fresh placeholder state blocks with
|
|
5
|
-
* init/start guidance. With prompt → classifies the idea, asks for one discovery mode,
|
|
6
|
-
* resolves the internal track, and starts the first stage of that track (brainstorm for medium/standard, spec for quick).
|
|
7
|
-
*/
|
|
8
|
-
export declare function startCommandContract(): string;
|
|
9
|
-
/**
|
|
10
|
-
* Skill body for /cc — the unified entry point.
|
|
11
|
-
*/
|
|
12
|
-
export declare function startCommandSkillMarkdown(): string;
|
|
1
|
+
export declare const START_COMMAND_BODY: string;
|
|
2
|
+
export declare function renderStartCommand(): string;
|