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.
- package/README.md +210 -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 +90 -508
- 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/install.d.ts +27 -15
- package/dist/install.js +230 -1342
- 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,550 @@
|
|
|
1
|
+
const PLAN_TEMPLATE = `---
|
|
2
|
+
slug: SLUG-PLACEHOLDER
|
|
3
|
+
stage: plan
|
|
4
|
+
status: active
|
|
5
|
+
ac:
|
|
6
|
+
- id: AC-1
|
|
7
|
+
text: "Replace with the first observable outcome (something a user or test can verify)."
|
|
8
|
+
status: pending
|
|
9
|
+
parallelSafe: true
|
|
10
|
+
touchSurface: []
|
|
11
|
+
- id: AC-2
|
|
12
|
+
text: "Replace with the second observable outcome, or delete this entry if one AC is enough."
|
|
13
|
+
status: pending
|
|
14
|
+
parallelSafe: true
|
|
15
|
+
touchSurface: []
|
|
16
|
+
last_specialist: null
|
|
17
|
+
refines: null
|
|
18
|
+
shipped_at: null
|
|
19
|
+
ship_commit: null
|
|
20
|
+
review_iterations: 0
|
|
21
|
+
security_flag: false
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# SLUG-PLACEHOLDER
|
|
25
|
+
|
|
26
|
+
> One short paragraph: what we are doing and why. If the goal does not fit in 4 lines, the request is probably too large — split it.
|
|
27
|
+
|
|
28
|
+
## Frame
|
|
29
|
+
|
|
30
|
+
_(Brainstormer-authored when invoked. 2-5 sentences: what is broken or missing today, who feels it, what success looks like a user or test can verify, what is explicitly out of scope. Cite real evidence — \`file:path:line\`, ticket id, conversation excerpt — when you have it. If the orchestrator runs inline without brainstormer, leave a one-line summary here.)_
|
|
31
|
+
|
|
32
|
+
## Approaches
|
|
33
|
+
|
|
34
|
+
_(Optional. Brainstormer fills this in \`guided\` or \`deep\` posture. Drop dead options before showing the table; do not pad to 3 rows for symmetry.)_
|
|
35
|
+
|
|
36
|
+
| Role | Approach | Trade-off | Reuse / reference |
|
|
37
|
+
| --- | --- | --- | --- |
|
|
38
|
+
| baseline | _approach_ | _trade-off_ | _reference_ |
|
|
39
|
+
| challenger | _approach_ | _trade-off_ | _reference_ |
|
|
40
|
+
|
|
41
|
+
## Selected Direction
|
|
42
|
+
|
|
43
|
+
_(One paragraph when Approaches exists; cites the picked row and why.)_
|
|
44
|
+
|
|
45
|
+
## Not Doing
|
|
46
|
+
|
|
47
|
+
_(3-5 bullets the brainstorm explicitly is NOT committing to. Protects scope from silent enlargement.)_
|
|
48
|
+
|
|
49
|
+
- _explicit non-commitment_
|
|
50
|
+
- _explicit non-commitment_
|
|
51
|
+
|
|
52
|
+
## Architecture
|
|
53
|
+
|
|
54
|
+
_(Architect, when invoked. Link to \`flows/SLUG-PLACEHOLDER/decisions.md\`. Keep this section short — full rationale lives in decisions.md.)_
|
|
55
|
+
|
|
56
|
+
## Plan
|
|
57
|
+
|
|
58
|
+
_(Planner authors this. AC-aligned, not horizontal-layer. Each unit ships an end-to-end vertical slice for one AC.)_
|
|
59
|
+
|
|
60
|
+
- **Phase 1 — Foundation (AC-1).**
|
|
61
|
+
- Concrete change with file:path:line reference.
|
|
62
|
+
- **Phase 2 — Wiring (AC-2, AC-3).**
|
|
63
|
+
- Concrete change with file:path:line reference.
|
|
64
|
+
|
|
65
|
+
## Acceptance Criteria
|
|
66
|
+
|
|
67
|
+
| id | text | status | parallelSafe | touchSurface | commit |
|
|
68
|
+
| --- | --- | --- | --- | --- | --- |
|
|
69
|
+
| AC-1 | _Replace with the first observable outcome._ | pending | true | _list of repo paths_ | — |
|
|
70
|
+
| AC-2 | _Replace or delete._ | pending | true | _list of repo paths_ | — |
|
|
71
|
+
|
|
72
|
+
The AC block is the source of truth. Every commit produced by \`commit-helper.mjs\` references exactly one AC id. \`parallelSafe: false\` opts the AC out of parallel-build dispatch; \`touchSurface\` is the list of repo-relative paths the AC is allowed to modify. Each AC must point at a real \`file:line\` or destination path.
|
|
73
|
+
|
|
74
|
+
## Edge cases
|
|
75
|
+
|
|
76
|
+
_(Planner-authored. One bullet per AC naming the non-happy-path the slice-builder's RED test must encode.)_
|
|
77
|
+
|
|
78
|
+
- **AC-1** — _empty input / boundary / error response_.
|
|
79
|
+
- **AC-2** — _hover under 100ms / missing fixture / etc_.
|
|
80
|
+
|
|
81
|
+
## Topology
|
|
82
|
+
|
|
83
|
+
_(Planner topology mode. Default: \`inline\`. \`parallel-build\` is opt-in; see lib/skills/parallel-build.md for rules.)_
|
|
84
|
+
|
|
85
|
+
- topology: inline
|
|
86
|
+
- slices: _none_
|
|
87
|
+
|
|
88
|
+
## Traceability block
|
|
89
|
+
|
|
90
|
+
- AC-1 → commit pending
|
|
91
|
+
- AC-2 → commit pending
|
|
92
|
+
|
|
93
|
+
This block is rebuilt by \`commit-helper.mjs\` after every AC commit. Do not edit by hand once a commit is recorded.
|
|
94
|
+
`;
|
|
95
|
+
const BUILD_TEMPLATE = `---
|
|
96
|
+
slug: SLUG-PLACEHOLDER
|
|
97
|
+
stage: build
|
|
98
|
+
status: active
|
|
99
|
+
build_iterations: 0
|
|
100
|
+
last_commit: null
|
|
101
|
+
tdd_cycle: enforced
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
# Build log — SLUG-PLACEHOLDER
|
|
105
|
+
|
|
106
|
+
This is the TDD implementation journal. Every AC goes through RED → GREEN → REFACTOR; every phase is a separate commit recorded by \`commit-helper.mjs --phase=…\`.
|
|
107
|
+
|
|
108
|
+
> **Iron Law:** NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST. The RED failure is the spec.
|
|
109
|
+
|
|
110
|
+
## Plan summary
|
|
111
|
+
|
|
112
|
+
_(One paragraph mirroring \`plans/SLUG-PLACEHOLDER.md\` Plan section.)_
|
|
113
|
+
|
|
114
|
+
## TDD cycle log
|
|
115
|
+
|
|
116
|
+
For every AC, append one row with **all six columns filled** before the AC is considered done.
|
|
117
|
+
|
|
118
|
+
| AC | Discovery | RED proof | GREEN evidence | REFACTOR notes | commits |
|
|
119
|
+
| --- | --- | --- | --- | --- | --- |
|
|
120
|
+
| AC-1 | _file:path:line refs from discovery_ | _failing test name + 1-3 line failure excerpt_ | _full-suite command + PASS summary_ | _shape change or "skipped: reason"_ | _red SHA, green SHA, refactor SHA (or "skipped")_ |
|
|
121
|
+
|
|
122
|
+
## Watched-RED proofs
|
|
123
|
+
|
|
124
|
+
\`\`\`text
|
|
125
|
+
_(Per AC: command run, test name, 1-3 line failure excerpt that proves RED failed for the right reason.)_
|
|
126
|
+
_AC-1: npm test src/lib/permissions.ts -- -t "renders email"_
|
|
127
|
+
_ AssertionError: expected 'anna@example.com' got undefined_
|
|
128
|
+
\`\`\`
|
|
129
|
+
|
|
130
|
+
## GREEN suite evidence
|
|
131
|
+
|
|
132
|
+
\`\`\`text
|
|
133
|
+
_(Per AC: command run, PASS/FAIL summary of the FULL relevant suite — not the single test.)_
|
|
134
|
+
_AC-1: npm test src/lib/__ 47 passed, 0 failed (in 1.8s)_
|
|
135
|
+
\`\`\`
|
|
136
|
+
|
|
137
|
+
## REFACTOR notes
|
|
138
|
+
|
|
139
|
+
_(Per AC: one-line shape change applied, or explicit "skipped: <reason>". Silence is not acceptable; the gate forces the question.)_
|
|
140
|
+
|
|
141
|
+
- AC-1: extracted \`hasViewEmail\` helper from inline check.
|
|
142
|
+
|
|
143
|
+
## Fix iterations (after a review block)
|
|
144
|
+
|
|
145
|
+
_(Append one fix-iteration block per review iteration that returned \`block\`. Same TDD cycle applies; same AC id is reused; finding F-N is cited in the message.)_
|
|
146
|
+
|
|
147
|
+
### Fix iteration 1 — review block 1
|
|
148
|
+
|
|
149
|
+
| F-N | AC | phase | commit | files | note |
|
|
150
|
+
| --- | --- | --- | --- | --- | --- |
|
|
151
|
+
| F-2 | AC-1 | red | _SHA_ | _tests/...:line_ | _what the new RED encodes_ |
|
|
152
|
+
| F-2 | AC-1 | green | _SHA_ | _src/...:line_ | _minimal fix_ |
|
|
153
|
+
| F-2 | AC-1 | refactor (skipped) | — | — | _reason_ |
|
|
154
|
+
|
|
155
|
+
## Hooks invoked
|
|
156
|
+
|
|
157
|
+
- \`commit-helper.mjs --ac=AC-1 --phase=red --message="red(AC-1): …"\` → _SHA_
|
|
158
|
+
- \`commit-helper.mjs --ac=AC-1 --phase=green --message="green(AC-1): …"\` → _SHA_
|
|
159
|
+
- \`commit-helper.mjs --ac=AC-1 --phase=refactor --message="refactor(AC-1): …"\` → _SHA_ or _skipped_
|
|
160
|
+
|
|
161
|
+
## Notes
|
|
162
|
+
|
|
163
|
+
_(Surprises, deviations from the plan, tests added, refactors that came up, paths considered and discarded, etc.)_
|
|
164
|
+
`;
|
|
165
|
+
const REVIEW_TEMPLATE = `---
|
|
166
|
+
slug: SLUG-PLACEHOLDER
|
|
167
|
+
stage: review
|
|
168
|
+
status: active
|
|
169
|
+
review_iterations: 0
|
|
170
|
+
modes_run:
|
|
171
|
+
- code
|
|
172
|
+
findings_block: []
|
|
173
|
+
ledger_open: 0
|
|
174
|
+
ledger_closed: 0
|
|
175
|
+
zero_block_streak: 0
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
# Review — SLUG-PLACEHOLDER
|
|
179
|
+
|
|
180
|
+
This is the review log. \`reviewer\` (and \`security-reviewer\`, when relevant) append findings here. The loop is producer ↔ critic: iteration N proposes findings, \`slice-builder\` (mode=fix-only) closes them, iteration N+1 re-checks. The loop ends when the convergence detector fires (see review-loop skill).
|
|
181
|
+
|
|
182
|
+
## Run summary
|
|
183
|
+
|
|
184
|
+
| iteration | mode | reviewer | result | new_block | closed_block |
|
|
185
|
+
| --- | --- | --- | --- | --- | --- |
|
|
186
|
+
| 1 | code | reviewer | _pending_ | _N_ | _N_ |
|
|
187
|
+
|
|
188
|
+
Hard cap: 5 iterations. After the 5th, stop and surface what remains in the ledger.
|
|
189
|
+
|
|
190
|
+
## Concern Ledger (append-only)
|
|
191
|
+
|
|
192
|
+
Stable global ids per slug. Rows are never edited or deleted, only appended. Closing a row requires a citation to the fix evidence (commit SHA, test name, or new file:line).
|
|
193
|
+
|
|
194
|
+
| ID | Opened in | Mode | Severity | Status | Closed in | Citation |
|
|
195
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
196
|
+
| F-1 | 1 | code | _block / warn_ | _open / closed_ | _N or –_ | \`path:line\` or commit SHA |
|
|
197
|
+
|
|
198
|
+
Severity rules:
|
|
199
|
+
|
|
200
|
+
- \`block\` — must close before ship.
|
|
201
|
+
- \`warn\` — may ship; carries to \`ships/<slug>.md\` and \`learnings/<slug>.md\`.
|
|
202
|
+
|
|
203
|
+
## Iteration logs
|
|
204
|
+
|
|
205
|
+
\`\`\`markdown
|
|
206
|
+
## Iteration N — <mode> — <ISO timestamp>
|
|
207
|
+
|
|
208
|
+
Ledger reread:
|
|
209
|
+
- F-K: <closed | open | superseded by F-L> — <citation>
|
|
210
|
+
|
|
211
|
+
New findings:
|
|
212
|
+
- F-M <severity> — \`<path:line>\` — <description> → <proposed fix>
|
|
213
|
+
|
|
214
|
+
Five Failure Modes:
|
|
215
|
+
- Hallucinated actions: no / yes (cite)
|
|
216
|
+
- Scope creep: no / yes (cite)
|
|
217
|
+
- Cascading errors: no / yes (cite)
|
|
218
|
+
- Context loss: no / yes (cite)
|
|
219
|
+
- Tool misuse: no / yes (cite)
|
|
220
|
+
|
|
221
|
+
Decision: <block | warn | clear | cap-reached>
|
|
222
|
+
\`\`\`
|
|
223
|
+
|
|
224
|
+
## Convergence detector
|
|
225
|
+
|
|
226
|
+
The loop ends when ANY signal fires:
|
|
227
|
+
|
|
228
|
+
1. All ledger rows closed → \`clear\`.
|
|
229
|
+
2. Two consecutive iterations with zero new \`block\` findings AND every open row is \`warn\` → \`clear\` (warn carry-over).
|
|
230
|
+
3. Hard cap reached with at least one open \`block\` row → \`cap-reached\`.
|
|
231
|
+
|
|
232
|
+
Tie-breaker: if iteration 5 closes the last block row, return \`clear\` (signal #1) regardless of cap.
|
|
233
|
+
|
|
234
|
+
## Decision values
|
|
235
|
+
|
|
236
|
+
- **block** — at least one open block row. slice-builder (fix-only) addresses them; re-review next iteration.
|
|
237
|
+
- **warn** — convergence signal #2 fired. Open warns carry over. Ship may proceed.
|
|
238
|
+
- **clear** — signal #1 (all closed) or signal #2 (warn-only convergence). Ready for ship.
|
|
239
|
+
- **cap-reached** — signal #3. Stop; orchestrator surfaces remaining open rows to the user; user picks \`/cc-cancel\` or \`accept warns and ship\` (only valid if every open row is severity=warn).
|
|
240
|
+
`;
|
|
241
|
+
const SHIP_TEMPLATE = `---
|
|
242
|
+
slug: SLUG-PLACEHOLDER
|
|
243
|
+
stage: ship
|
|
244
|
+
status: active
|
|
245
|
+
ship_commit: null
|
|
246
|
+
push_approved: false
|
|
247
|
+
pr_url: null
|
|
248
|
+
finalization_mode: null
|
|
249
|
+
preflight_passed: false
|
|
250
|
+
rollback_recorded: false
|
|
251
|
+
repo_mode: git
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
# Ship notes — SLUG-PLACEHOLDER
|
|
255
|
+
|
|
256
|
+
This artifact is written just before \`runCompoundAndShip()\` archives the run. It must contain enough information for downstream operators to understand what shipped without opening every other artifact.
|
|
257
|
+
|
|
258
|
+
> **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.
|
|
259
|
+
|
|
260
|
+
## Summary
|
|
261
|
+
|
|
262
|
+
_(2-4 lines: what changed, who needs to know.)_
|
|
263
|
+
|
|
264
|
+
## Preflight checks (mandatory; fresh output in this artifact)
|
|
265
|
+
|
|
266
|
+
Every check below must produce fresh output in this section. Pasting "tests passed yesterday" does not count.
|
|
267
|
+
|
|
268
|
+
| Check | Command | Result | Notes |
|
|
269
|
+
| --- | --- | --- | --- |
|
|
270
|
+
| tests | _e.g._ \`npm test\` | _pass / fail_ | _file paths or test names_ |
|
|
271
|
+
| build | _e.g._ \`npm run build\` | _pass / fail_ | _output stderr lines_ |
|
|
272
|
+
| linter | _e.g._ \`npm run lint\` | _pass / fail_ | _file paths_ |
|
|
273
|
+
| type-check | _e.g._ \`npm run typecheck\` or \`tsc --noEmit\` | _pass / fail_ | _error count_ |
|
|
274
|
+
| clean tree | \`git status --porcelain\` | _empty / non-empty_ | _file paths_ |
|
|
275
|
+
|
|
276
|
+
Set \`preflight_passed: true\` in the frontmatter only when every row is pass/empty.
|
|
277
|
+
|
|
278
|
+
## Repository mode detection
|
|
279
|
+
|
|
280
|
+
Run \`test -d .git && echo git || echo no-vcs\`. Result: _git / no-vcs_.
|
|
281
|
+
|
|
282
|
+
If no-vcs, the only valid finalization mode is \`FINALIZE_NO_VCS\`; document the manual handoff target and rollback owner in the relevant sections.
|
|
283
|
+
|
|
284
|
+
## Merge-base detection (git mode only)
|
|
285
|
+
|
|
286
|
+
Run \`git merge-base HEAD <base-branch>\`. If the base has diverged significantly, flag for rebase-first BEFORE proceeding to finalization.
|
|
287
|
+
|
|
288
|
+
\`\`\`bash
|
|
289
|
+
$ git merge-base HEAD main
|
|
290
|
+
<sha>
|
|
291
|
+
|
|
292
|
+
$ git rev-list --count <sha>..main
|
|
293
|
+
N commits behind main
|
|
294
|
+
\`\`\`
|
|
295
|
+
|
|
296
|
+
If \`N > 0\` and any of those commits touch this slug's \`touchSurface\`, rebase first. Re-run preflight after the rebase; do not trust the prior preflight result.
|
|
297
|
+
|
|
298
|
+
## AC ↔ commit map
|
|
299
|
+
|
|
300
|
+
| AC | text (one line) | red SHA | green SHA | refactor SHA | description |
|
|
301
|
+
| --- | --- | --- | --- | --- | --- |
|
|
302
|
+
| AC-1 | _AC text_ | _sha_ | _sha_ | _sha or skipped_ | _short description_ |
|
|
303
|
+
|
|
304
|
+
This table mirrors \`flows/SLUG-PLACEHOLDER/plan.md > Acceptance Criteria\` with the final SHAs from \`flow-state.ac[].phases\`. The orchestrator refuses to run \`runCompoundAndShip()\` if any AC still shows \`status: pending\`.
|
|
305
|
+
|
|
306
|
+
## Rollback plan (mandatory)
|
|
307
|
+
|
|
308
|
+
The rollback plan has three explicit fields; missing any one blocks ship:
|
|
309
|
+
|
|
310
|
+
- **Trigger conditions (what tells you it is broken):** _e.g._ error rate on /api/list > 1% over 5 min; latency p95 > 800ms over 10 min; user-visible 5xx in dashboard.
|
|
311
|
+
- **Rollback steps (exact commands or git operations):** _e.g._ \`git revert <ship_commit>; git push origin main\`. For non-git: \`scp release/<slug>-prev.tar.gz <host>:/srv/app && systemctl restart app\`.
|
|
312
|
+
- **Verification (how to confirm rollback worked):** _e.g._ /healthz returns 200; error rate back to baseline within 5 min; smoke test \`curl /api/list | jq '.items | length'\` returns N.
|
|
313
|
+
|
|
314
|
+
Set \`rollback_recorded: true\` in the frontmatter only when all three fields are filled with concrete content.
|
|
315
|
+
|
|
316
|
+
## Monitoring checklist
|
|
317
|
+
|
|
318
|
+
- Error rate on _/path_: baseline _N_/min, alert above _M_/min for _T_ min.
|
|
319
|
+
- Latency p95 on _/path_: baseline _Nms_, alert above _Mms_ for _T_ min.
|
|
320
|
+
- Business metric: _e.g._ search_quality_score (rolling 1h average should not drop > 5%).
|
|
321
|
+
- If no monitoring exists for the affected surface, flag in Risks section below.
|
|
322
|
+
|
|
323
|
+
## Push / PR
|
|
324
|
+
|
|
325
|
+
- push: _pending — orchestrator must explicitly ask the user before running \`git push\`._
|
|
326
|
+
- PR: _pending — only created if the user explicitly says "open a PR"._
|
|
327
|
+
|
|
328
|
+
When push is approved, record the upstream branch + PR URL above.
|
|
329
|
+
|
|
330
|
+
## Finalization mode (exactly ONE)
|
|
331
|
+
|
|
332
|
+
Pick exactly one. Setting \`finalization_mode\` to anything other than these five values is rejected:
|
|
333
|
+
|
|
334
|
+
- **FINALIZE_MERGE_LOCAL** — merge into the base branch locally; no PR.
|
|
335
|
+
- **FINALIZE_OPEN_PR** — push and open a PR with this artifact's Summary + AC↔commit map as the body.
|
|
336
|
+
- **FINALIZE_KEEP_BRANCH** — push the branch but leave the merge to a downstream operator.
|
|
337
|
+
- **FINALIZE_DISCARD_BRANCH** — delete the branch entirely (requires typed confirmation in the orchestrator turn).
|
|
338
|
+
- **FINALIZE_NO_VCS** — no VCS available; record manual handoff target and rollback owner.
|
|
339
|
+
|
|
340
|
+
Selected: _<one mode>_
|
|
341
|
+
Rationale: _<one sentence>_
|
|
342
|
+
|
|
343
|
+
## Breaking changes / migration
|
|
344
|
+
|
|
345
|
+
_(If none, write "none". If any, link to migration notes — typically docs/migration-… or a release-notes file.)_
|
|
346
|
+
|
|
347
|
+
## Release notes (one paragraph)
|
|
348
|
+
|
|
349
|
+
_(Suitable for CHANGELOG.md. Avoid TODOs and references that won't make sense to readers without internal context.)_
|
|
350
|
+
|
|
351
|
+
## Risks carried over
|
|
352
|
+
|
|
353
|
+
_(List any \`warn\`-severity ledger rows from \`flows/SLUG-PLACEHOLDER/review.md\` and any \`open\` assumptions from the plan. Each line says: id, source, why we are shipping anyway.)_
|
|
354
|
+
|
|
355
|
+
- _e.g._ F-2 (warn) — \`tests/integration/list.test.ts:31\` — no negative test for empty page; tracked in \`flows/SLUG-PLACEHOLDER/learnings.md\`.
|
|
356
|
+
|
|
357
|
+
## Victory Detector
|
|
358
|
+
|
|
359
|
+
Ship is allowed only when ALL of these are true:
|
|
360
|
+
|
|
361
|
+
- valid review verdict (\`clear\` or \`warn\` with convergence signal #2)
|
|
362
|
+
- preflight_passed=true with fresh output
|
|
363
|
+
- rollback_recorded=true with all three fields filled
|
|
364
|
+
- finalization_mode set to exactly one enum value
|
|
365
|
+
- repo_mode matches the chosen finalization (\`no-vcs\` repo cannot pick \`FINALIZE_MERGE_LOCAL\`)
|
|
366
|
+
|
|
367
|
+
If any field is stale or missing, keep \`status: blocked\` and iterate.
|
|
368
|
+
`;
|
|
369
|
+
const DECISIONS_TEMPLATE = `---
|
|
370
|
+
slug: SLUG-PLACEHOLDER
|
|
371
|
+
stage: plan
|
|
372
|
+
status: active
|
|
373
|
+
decision_count: 0
|
|
374
|
+
architecture_tier: null
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
# Decisions — SLUG-PLACEHOLDER
|
|
378
|
+
|
|
379
|
+
\`architect\` (and any reviewer in \`text-review\` mode) records decisions here. Each decision is independently citable.
|
|
380
|
+
|
|
381
|
+
## Architecture tier
|
|
382
|
+
|
|
383
|
+
_(Architect picks one tier per slug, recorded once at the top of this file. Tier sets the depth bar for the whole D-N set.)_
|
|
384
|
+
|
|
385
|
+
- **minimum-viable** — solve only the immediate failure mode; ignore future-proofing. Use for hot-fixes, small enhancements, doc-only.
|
|
386
|
+
- **product-grade** — production-ready quality bar; includes failure modes, monitoring hooks, rollback plan. Default for most slugs.
|
|
387
|
+
- **ideal** — invest in long-term shape (clean abstractions, full failure-mode coverage, perf budgets, security review). Use only when explicitly requested or when the change is foundational.
|
|
388
|
+
|
|
389
|
+
Selected tier: _<minimum-viable | product-grade | ideal>_
|
|
390
|
+
Rationale: _<one sentence>_
|
|
391
|
+
|
|
392
|
+
## Trivial-Change Escape Hatch
|
|
393
|
+
|
|
394
|
+
_(If the change is ≤3 files, no new interfaces, no cross-module data flow, write a one-paragraph mini-decision here and skip the full D-N machinery. Otherwise write \`Not applicable.\`.)_
|
|
395
|
+
|
|
396
|
+
## Blast-radius Diff
|
|
397
|
+
|
|
398
|
+
_(Only the paths this slug touches, not the whole repo. Cite \`git diff\` against the slug's baseline SHA. Skip for trivial changes.)_
|
|
399
|
+
|
|
400
|
+
\`\`\`text
|
|
401
|
+
$ git diff <baseline-sha>..HEAD --stat
|
|
402
|
+
src/api/list.ts | 12 +
|
|
403
|
+
tests/unit/list.test.ts | 6 +
|
|
404
|
+
\`\`\`
|
|
405
|
+
|
|
406
|
+
## D-1 — _decision title_
|
|
407
|
+
|
|
408
|
+
- **Context:** _what makes this a real decision instead of a default._
|
|
409
|
+
- **Considered options:**
|
|
410
|
+
- Option A — _summary_
|
|
411
|
+
- Option B — _summary_
|
|
412
|
+
- Option C — _summary_
|
|
413
|
+
- **Selected:** Option _X_
|
|
414
|
+
- **Rationale:** _why X beats A / B / C right now._
|
|
415
|
+
- **Rejected because:** _short reason per rejected option._
|
|
416
|
+
- **Consequences:** _what becomes easier; what becomes harder; what we will revisit._
|
|
417
|
+
- **Refs:** _file:path:line, AC-N, related external link._
|
|
418
|
+
|
|
419
|
+
### Failure Mode Table
|
|
420
|
+
|
|
421
|
+
_(Only when this decision touches a user-visible failure path — rendering, request/response, persisted data, payment/auth, third-party calls. If the decision is purely internal, replace this section with the single line \`Failure Mode Table: not applicable — no user-visible failure path\`. When present, \`UserSees\` is mandatory in every row; silent failure paths must show "UserSees=nothing — recorded in <metric>".)_
|
|
422
|
+
|
|
423
|
+
| # | Method | Exception | Rescue | UserSees |
|
|
424
|
+
| --- | --- | --- | --- | --- |
|
|
425
|
+
| 1 | \`scoring.bm25\` | doc length missing in index | fallback to plain TF | warning toast: "Search ranking degraded" |
|
|
426
|
+
|
|
427
|
+
### Pre-mortem
|
|
428
|
+
|
|
429
|
+
_(Imagine this decision shipped and failed. What did it look like in the failure scenario? Three bullets max. Mandatory at product-grade and ideal tiers; minimum-viable may skip.)_
|
|
430
|
+
|
|
431
|
+
- _Failure scenario 1_
|
|
432
|
+
- _Failure scenario 2_
|
|
433
|
+
- _Failure scenario 3_
|
|
434
|
+
`;
|
|
435
|
+
const LEARNINGS_TEMPLATE = `---
|
|
436
|
+
slug: SLUG-PLACEHOLDER
|
|
437
|
+
stage: ship
|
|
438
|
+
status: active
|
|
439
|
+
captured_by: orchestrator
|
|
440
|
+
quality_gate: passed
|
|
441
|
+
signals:
|
|
442
|
+
hasArchitectDecision: false
|
|
443
|
+
reviewIterations: 0
|
|
444
|
+
securityFlag: false
|
|
445
|
+
userRequestedCapture: false
|
|
446
|
+
---
|
|
447
|
+
|
|
448
|
+
# Learnings — SLUG-PLACEHOLDER
|
|
449
|
+
|
|
450
|
+
The compound phase writes this only when at least one quality signal is present. If you are reading this in an active run, the orchestrator decided this run is worth remembering.
|
|
451
|
+
|
|
452
|
+
## What we believed at the start
|
|
453
|
+
|
|
454
|
+
_(What was the going-in assumption when \`/cc\` was invoked?)_
|
|
455
|
+
|
|
456
|
+
## What turned out to be true
|
|
457
|
+
|
|
458
|
+
_(Confirmed beliefs.)_
|
|
459
|
+
|
|
460
|
+
## What turned out to be wrong
|
|
461
|
+
|
|
462
|
+
_(Discoveries that contradicted the assumption.)_
|
|
463
|
+
|
|
464
|
+
## Decisions worth remembering
|
|
465
|
+
|
|
466
|
+
- D-N (link to decisions.md)
|
|
467
|
+
|
|
468
|
+
## Patterns we should keep
|
|
469
|
+
|
|
470
|
+
_(Reusable patterns we saw work.)_
|
|
471
|
+
|
|
472
|
+
## Anti-patterns we should avoid
|
|
473
|
+
|
|
474
|
+
_(Reusable patterns we saw fail.)_
|
|
475
|
+
|
|
476
|
+
## Follow-ups
|
|
477
|
+
|
|
478
|
+
- _(Items intentionally deferred. Each one becomes a separate \`/cc <task>\` later.)_
|
|
479
|
+
`;
|
|
480
|
+
const MANIFEST_TEMPLATE = `---
|
|
481
|
+
slug: SLUG-PLACEHOLDER
|
|
482
|
+
stage: shipped
|
|
483
|
+
status: shipped
|
|
484
|
+
ship_commit: SHIP-COMMIT-PLACEHOLDER
|
|
485
|
+
shipped_at: SHIPPED-AT-PLACEHOLDER
|
|
486
|
+
artifacts:
|
|
487
|
+
- plan.md
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
# SLUG-PLACEHOLDER — shipped manifest
|
|
491
|
+
|
|
492
|
+
This file is the entry point for any future agent that wants to understand what shipped under this slug.
|
|
493
|
+
|
|
494
|
+
## Acceptance Criteria
|
|
495
|
+
|
|
496
|
+
- AC-1: _description_ (commit \`SHIP-COMMIT-PLACEHOLDER\`)
|
|
497
|
+
|
|
498
|
+
## Artifacts
|
|
499
|
+
|
|
500
|
+
- plan.md — original plan
|
|
501
|
+
- build.md — implementation log
|
|
502
|
+
- review.md — review findings
|
|
503
|
+
- ship.md — release notes
|
|
504
|
+
- decisions.md — architectural decisions (if architect was invoked)
|
|
505
|
+
- learnings.md — lessons captured by compound (if quality gate passed)
|
|
506
|
+
|
|
507
|
+
## Refines
|
|
508
|
+
|
|
509
|
+
_(If this run refined a previous slug, link to its shipped manifest here.)_
|
|
510
|
+
|
|
511
|
+
## Knowledge index
|
|
512
|
+
|
|
513
|
+
This slug is referenced from \`.cclaw/knowledge.jsonl\` whenever the compound quality gate captured a learning.
|
|
514
|
+
`;
|
|
515
|
+
const IDEAS_TEMPLATE = `# .cclaw/ideas.md
|
|
516
|
+
|
|
517
|
+
This file is a free-form idea backlog. Entries are appended by \`/cc-idea\` and never auto-promoted to plans. To act on an idea, invoke \`/cc <task>\` describing it.
|
|
518
|
+
|
|
519
|
+
Each entry begins with an ISO timestamp, then a single-line summary, then the body.
|
|
520
|
+
`;
|
|
521
|
+
export const ARTIFACT_TEMPLATES = [
|
|
522
|
+
{ id: "plan", fileName: "plan.md", description: "Plan template with frontmatter, AC table, and traceability block.", body: PLAN_TEMPLATE },
|
|
523
|
+
{ id: "build", fileName: "build.md", description: "Build log template with commit table and hook invocation log.", body: BUILD_TEMPLATE },
|
|
524
|
+
{ id: "review", fileName: "review.md", description: "Review template with iteration table, findings table, and Five Failure Modes pass.", body: REVIEW_TEMPLATE },
|
|
525
|
+
{ id: "ship", fileName: "ship.md", description: "Ship notes template with AC↔commit map, push/PR section, release notes paragraph.", body: SHIP_TEMPLATE },
|
|
526
|
+
{ id: "decisions", fileName: "decisions.md", description: "Architect-style decision record template (D-N entries).", body: DECISIONS_TEMPLATE },
|
|
527
|
+
{ id: "learnings", fileName: "learnings.md", description: "Compound learning capture template with belief/outcome/follow-up sections.", body: LEARNINGS_TEMPLATE },
|
|
528
|
+
{ id: "manifest", fileName: "manifest.md", description: "Shipped manifest template; lists AC, artifacts, refines link.", body: MANIFEST_TEMPLATE },
|
|
529
|
+
{ id: "ideas", fileName: "ideas.md", description: "Append-only idea backlog seed.", body: IDEAS_TEMPLATE }
|
|
530
|
+
];
|
|
531
|
+
export function templateBody(id, replacements = {}) {
|
|
532
|
+
const template = ARTIFACT_TEMPLATES.find((entry) => entry.id === id);
|
|
533
|
+
if (!template)
|
|
534
|
+
throw new Error(`Unknown artifact template: ${id}`);
|
|
535
|
+
let body = template.body;
|
|
536
|
+
for (const [key, value] of Object.entries(replacements)) {
|
|
537
|
+
body = body.split(key).join(value);
|
|
538
|
+
}
|
|
539
|
+
return body;
|
|
540
|
+
}
|
|
541
|
+
export function planTemplateForSlug(slug) {
|
|
542
|
+
return templateBody("plan", { "SLUG-PLACEHOLDER": slug });
|
|
543
|
+
}
|
|
544
|
+
export function manifestTemplate(slug, shipCommit, shippedAt) {
|
|
545
|
+
return templateBody("manifest", {
|
|
546
|
+
"SLUG-PLACEHOLDER": slug,
|
|
547
|
+
"SHIP-COMMIT-PLACEHOLDER": shipCommit,
|
|
548
|
+
"SHIPPED-AT-PLACEHOLDER": shippedAt
|
|
549
|
+
});
|
|
550
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
export declare function
|
|
1
|
+
export declare const CANCEL_COMMAND_BODY = "# /cc-cancel \u2014 cancel the active cclaw run\n\nStop the current flow without finishing it. Artifacts are preserved.\n\n## Behaviour\n\n1. Read `.cclaw/state/flow-state.json`.\n2. If `currentSlug` is null \u2192 tell the user there is nothing to cancel and stop.\n3. Otherwise, perform the cancel runtime:\n - For every active stage (`plan`, `build`, `review`, `ship`, `decisions`, `learnings`), move `<slug>.md` into `.cclaw/flows/cancelled/<slug>/` as `<stage>.md`.\n - Write `.cclaw/flows/cancelled/<slug>/manifest.md` recording the cancel time, the user's reason (if provided), and the artifacts that were moved.\n - Update each moved artifact's frontmatter so `status: cancelled` and `stage: cancelled` (best-effort \u2014 invalid frontmatter is preserved as-is).\n - Reset `flow-state.json` to fresh: `currentSlug=null, currentStage=null, ac=[], reviewIterations=0, securityFlag=false`.\n - Leave the working tree alone. Do not auto-commit, do not stash, do not revert.\n4. Confirm the cancellation in one line and list the destination directory.\n\n## Recovery\n\nThe artifacts under `.cclaw/flows/cancelled/<slug>/` are read-only references for future runs. To resume the work:\n\n1. Invoke `/cc <task>` describing the same goal.\n2. Existing-plan detection will surface the cancelled match.\n3. Choose **resume from cancelled** to move the artifacts from `.cclaw/flows/cancelled/<slug>/` back into `.cclaw/flows/<slug>/`, reset `status: active`, and continue.\n\n## Hard rules\n\n- `/cc-cancel` never deletes artifacts. The orchestrator must refuse explicit deletion requests.\n- `/cc-cancel` never pushes to git or rewrites history.\n- `/cc-cancel` is idempotent: invoking it without an active slug prints \"no active run\" and stops.\n";
|
|
2
|
+
export declare function renderCancelCommand(): string;
|
|
@@ -1,25 +1,33 @@
|
|
|
1
|
-
export
|
|
2
|
-
return `# /cc-cancel command contract
|
|
1
|
+
export const CANCEL_COMMAND_BODY = `# /cc-cancel — cancel the active cclaw run
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
Stop the current flow without finishing it. Artifacts are preserved.
|
|
5
4
|
|
|
6
|
-
##
|
|
5
|
+
## Behaviour
|
|
7
6
|
|
|
8
|
-
1.
|
|
9
|
-
2.
|
|
10
|
-
3.
|
|
7
|
+
1. Read \`.cclaw/state/flow-state.json\`.
|
|
8
|
+
2. If \`currentSlug\` is null → tell the user there is nothing to cancel and stop.
|
|
9
|
+
3. Otherwise, perform the cancel runtime:
|
|
10
|
+
- For every active stage (\`plan\`, \`build\`, \`review\`, \`ship\`, \`decisions\`, \`learnings\`), move \`<slug>.md\` into \`.cclaw/flows/cancelled/<slug>/\` as \`<stage>.md\`.
|
|
11
|
+
- Write \`.cclaw/flows/cancelled/<slug>/manifest.md\` recording the cancel time, the user's reason (if provided), and the artifacts that were moved.
|
|
12
|
+
- Update each moved artifact's frontmatter so \`status: cancelled\` and \`stage: cancelled\` (best-effort — invalid frontmatter is preserved as-is).
|
|
13
|
+
- Reset \`flow-state.json\` to fresh: \`currentSlug=null, currentStage=null, ac=[], reviewIterations=0, securityFlag=false\`.
|
|
14
|
+
- Leave the working tree alone. Do not auto-commit, do not stash, do not revert.
|
|
15
|
+
4. Confirm the cancellation in one line and list the destination directory.
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
---
|
|
17
|
+
## Recovery
|
|
18
|
+
|
|
19
|
+
The artifacts under \`.cclaw/flows/cancelled/<slug>/\` are read-only references for future runs. To resume the work:
|
|
20
|
+
|
|
21
|
+
1. Invoke \`/cc <task>\` describing the same goal.
|
|
22
|
+
2. Existing-plan detection will surface the cancelled match.
|
|
23
|
+
3. Choose **resume from cancelled** to move the artifacts from \`.cclaw/flows/cancelled/<slug>/\` back into \`.cclaw/flows/<slug>/\`, reset \`status: active\`, and continue.
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
## Hard rules
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
- \`/cc-cancel\` never deletes artifacts. The orchestrator must refuse explicit deletion requests.
|
|
28
|
+
- \`/cc-cancel\` never pushes to git or rewrites history.
|
|
29
|
+
- \`/cc-cancel\` is idempotent: invoking it without an active slug prints "no active run" and stops.
|
|
24
30
|
`;
|
|
31
|
+
export function renderCancelCommand() {
|
|
32
|
+
return CANCEL_COMMAND_BODY;
|
|
25
33
|
}
|