cclaw-cli 0.49.0 → 0.51.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.
Files changed (183) hide show
  1. package/README.md +57 -84
  2. package/dist/artifact-linter.d.ts +4 -0
  3. package/dist/artifact-linter.js +24 -3
  4. package/dist/cli.d.ts +1 -19
  5. package/dist/cli.js +49 -491
  6. package/dist/constants.d.ts +2 -13
  7. package/dist/constants.js +1 -43
  8. package/dist/content/closeout-guidance.d.ts +14 -0
  9. package/dist/content/closeout-guidance.js +42 -0
  10. package/dist/content/core-agents.js +55 -17
  11. package/dist/content/decision-protocol.d.ts +12 -0
  12. package/dist/content/decision-protocol.js +20 -0
  13. package/dist/content/diff-command.d.ts +1 -2
  14. package/dist/content/diff-command.js +8 -94
  15. package/dist/content/examples.d.ts +4 -10
  16. package/dist/content/examples.js +10 -20
  17. package/dist/content/hook-events.js +2 -2
  18. package/dist/content/hook-inline-snippets.d.ts +5 -2
  19. package/dist/content/hook-inline-snippets.js +33 -1
  20. package/dist/content/hook-manifest.d.ts +3 -4
  21. package/dist/content/hook-manifest.js +11 -12
  22. package/dist/content/hooks.js +44 -21
  23. package/dist/content/ideate-command.d.ts +2 -0
  24. package/dist/content/ideate-command.js +34 -25
  25. package/dist/content/iron-laws.d.ts +5 -5
  26. package/dist/content/iron-laws.js +5 -5
  27. package/dist/content/language-policy.d.ts +2 -0
  28. package/dist/content/language-policy.js +13 -0
  29. package/dist/content/learnings.d.ts +3 -4
  30. package/dist/content/learnings.js +26 -50
  31. package/dist/content/meta-skill.js +33 -22
  32. package/dist/content/next-command.js +41 -38
  33. package/dist/content/node-hooks.js +17 -345
  34. package/dist/content/opencode-plugin.js +5 -103
  35. package/dist/content/research-playbooks.js +14 -14
  36. package/dist/content/review-loop.d.ts +2 -0
  37. package/dist/content/review-loop.js +8 -0
  38. package/dist/content/session-hooks.js +15 -47
  39. package/dist/content/skills.d.ts +0 -5
  40. package/dist/content/skills.js +55 -128
  41. package/dist/content/stage-common-guidance.d.ts +0 -1
  42. package/dist/content/stage-common-guidance.js +17 -14
  43. package/dist/content/stage-schema.d.ts +26 -1
  44. package/dist/content/stage-schema.js +121 -40
  45. package/dist/content/stages/_lint-metadata/index.js +9 -15
  46. package/dist/content/stages/brainstorm.js +22 -43
  47. package/dist/content/stages/design.js +37 -57
  48. package/dist/content/stages/plan.js +22 -13
  49. package/dist/content/stages/review.js +24 -27
  50. package/dist/content/stages/scope.js +34 -46
  51. package/dist/content/stages/ship.js +7 -4
  52. package/dist/content/stages/spec.js +20 -9
  53. package/dist/content/stages/tdd.js +64 -44
  54. package/dist/content/start-command.js +13 -12
  55. package/dist/content/status-command.d.ts +2 -7
  56. package/dist/content/status-command.js +19 -146
  57. package/dist/content/subagents.d.ts +0 -5
  58. package/dist/content/subagents.js +51 -28
  59. package/dist/content/templates.d.ts +1 -1
  60. package/dist/content/templates.js +126 -135
  61. package/dist/content/track-render-context.d.ts +17 -0
  62. package/dist/content/track-render-context.js +44 -0
  63. package/dist/content/tree-command.d.ts +1 -2
  64. package/dist/content/tree-command.js +4 -87
  65. package/dist/content/utility-skills.d.ts +2 -29
  66. package/dist/content/utility-skills.js +2 -1534
  67. package/dist/content/view-command.js +31 -11
  68. package/dist/delegation.d.ts +1 -1
  69. package/dist/delegation.js +5 -15
  70. package/dist/doctor-registry.js +20 -21
  71. package/dist/doctor.js +88 -344
  72. package/dist/flow-state.d.ts +3 -0
  73. package/dist/flow-state.js +2 -0
  74. package/dist/harness-adapters.d.ts +1 -1
  75. package/dist/harness-adapters.js +51 -58
  76. package/dist/install.js +128 -358
  77. package/dist/internal/advance-stage.js +3 -9
  78. package/dist/internal/compound-readiness.d.ts +1 -1
  79. package/dist/internal/compound-readiness.js +1 -1
  80. package/dist/internal/tdd-loop-status.d.ts +1 -1
  81. package/dist/internal/tdd-loop-status.js +1 -1
  82. package/dist/knowledge-store.d.ts +16 -10
  83. package/dist/knowledge-store.js +51 -15
  84. package/dist/policy.js +16 -105
  85. package/dist/run-archive.d.ts +4 -6
  86. package/dist/run-archive.js +15 -20
  87. package/dist/run-persistence.d.ts +2 -2
  88. package/dist/run-persistence.js +3 -9
  89. package/package.json +1 -2
  90. package/dist/content/archive-command.d.ts +0 -2
  91. package/dist/content/archive-command.js +0 -124
  92. package/dist/content/compound-command.d.ts +0 -5
  93. package/dist/content/compound-command.js +0 -193
  94. package/dist/content/contexts.d.ts +0 -18
  95. package/dist/content/contexts.js +0 -24
  96. package/dist/content/contracts.d.ts +0 -2
  97. package/dist/content/contracts.js +0 -51
  98. package/dist/content/doctor-references.d.ts +0 -2
  99. package/dist/content/doctor-references.js +0 -150
  100. package/dist/content/eval-scaffold.d.ts +0 -15
  101. package/dist/content/eval-scaffold.js +0 -370
  102. package/dist/content/feature-command.d.ts +0 -2
  103. package/dist/content/feature-command.js +0 -123
  104. package/dist/content/flow-map.d.ts +0 -23
  105. package/dist/content/flow-map.js +0 -134
  106. package/dist/content/harness-doc.d.ts +0 -2
  107. package/dist/content/harness-doc.js +0 -202
  108. package/dist/content/harness-playbooks.d.ts +0 -24
  109. package/dist/content/harness-playbooks.js +0 -393
  110. package/dist/content/harness-tool-refs.d.ts +0 -20
  111. package/dist/content/harness-tool-refs.js +0 -268
  112. package/dist/content/ops-command.d.ts +0 -2
  113. package/dist/content/ops-command.js +0 -71
  114. package/dist/content/protocols.d.ts +0 -7
  115. package/dist/content/protocols.js +0 -215
  116. package/dist/content/retro-command.d.ts +0 -2
  117. package/dist/content/retro-command.js +0 -165
  118. package/dist/content/rewind-command.d.ts +0 -2
  119. package/dist/content/rewind-command.js +0 -106
  120. package/dist/content/tdd-log-command.d.ts +0 -2
  121. package/dist/content/tdd-log-command.js +0 -85
  122. package/dist/eval/agents/single-shot.d.ts +0 -27
  123. package/dist/eval/agents/single-shot.js +0 -79
  124. package/dist/eval/agents/with-tools.d.ts +0 -44
  125. package/dist/eval/agents/with-tools.js +0 -261
  126. package/dist/eval/agents/workflow.d.ts +0 -31
  127. package/dist/eval/agents/workflow.js +0 -155
  128. package/dist/eval/baseline.d.ts +0 -38
  129. package/dist/eval/baseline.js +0 -282
  130. package/dist/eval/config-loader.d.ts +0 -14
  131. package/dist/eval/config-loader.js +0 -395
  132. package/dist/eval/corpus.d.ts +0 -30
  133. package/dist/eval/corpus.js +0 -330
  134. package/dist/eval/cost-guard.d.ts +0 -102
  135. package/dist/eval/cost-guard.js +0 -190
  136. package/dist/eval/diff.d.ts +0 -64
  137. package/dist/eval/diff.js +0 -323
  138. package/dist/eval/llm-client.d.ts +0 -176
  139. package/dist/eval/llm-client.js +0 -267
  140. package/dist/eval/mode.d.ts +0 -28
  141. package/dist/eval/mode.js +0 -61
  142. package/dist/eval/progress.d.ts +0 -83
  143. package/dist/eval/progress.js +0 -59
  144. package/dist/eval/report.d.ts +0 -11
  145. package/dist/eval/report.js +0 -181
  146. package/dist/eval/rubric-loader.d.ts +0 -20
  147. package/dist/eval/rubric-loader.js +0 -143
  148. package/dist/eval/runner.d.ts +0 -81
  149. package/dist/eval/runner.js +0 -746
  150. package/dist/eval/runs.d.ts +0 -41
  151. package/dist/eval/runs.js +0 -114
  152. package/dist/eval/sandbox.d.ts +0 -38
  153. package/dist/eval/sandbox.js +0 -137
  154. package/dist/eval/tools/glob.d.ts +0 -2
  155. package/dist/eval/tools/glob.js +0 -163
  156. package/dist/eval/tools/grep.d.ts +0 -2
  157. package/dist/eval/tools/grep.js +0 -152
  158. package/dist/eval/tools/index.d.ts +0 -7
  159. package/dist/eval/tools/index.js +0 -35
  160. package/dist/eval/tools/read.d.ts +0 -2
  161. package/dist/eval/tools/read.js +0 -122
  162. package/dist/eval/tools/types.d.ts +0 -49
  163. package/dist/eval/tools/types.js +0 -41
  164. package/dist/eval/tools/write.d.ts +0 -2
  165. package/dist/eval/tools/write.js +0 -92
  166. package/dist/eval/types.d.ts +0 -561
  167. package/dist/eval/types.js +0 -47
  168. package/dist/eval/verifiers/judge.d.ts +0 -40
  169. package/dist/eval/verifiers/judge.js +0 -256
  170. package/dist/eval/verifiers/rules.d.ts +0 -24
  171. package/dist/eval/verifiers/rules.js +0 -218
  172. package/dist/eval/verifiers/structural.d.ts +0 -14
  173. package/dist/eval/verifiers/structural.js +0 -171
  174. package/dist/eval/verifiers/traceability.d.ts +0 -23
  175. package/dist/eval/verifiers/traceability.js +0 -84
  176. package/dist/eval/verifiers/workflow-consistency.d.ts +0 -21
  177. package/dist/eval/verifiers/workflow-consistency.js +0 -225
  178. package/dist/eval/workflow-corpus.d.ts +0 -7
  179. package/dist/eval/workflow-corpus.js +0 -207
  180. package/dist/feature-system.d.ts +0 -42
  181. package/dist/feature-system.js +0 -432
  182. package/dist/internal/knowledge-digest.d.ts +0 -7
  183. package/dist/internal/knowledge-digest.js +0 -93
@@ -1,202 +0,0 @@
1
- import { HARNESS_ADAPTERS, harnessTier } from "../harness-adapters.js";
2
- import { STAGE_TO_SKILL_FOLDER } from "../constants.js";
3
- import { HOOK_EVENTS_BY_HARNESS, HOOK_SEMANTIC_EVENTS } from "./hook-events.js";
4
- import { HARNESS_PLAYBOOKS_DIR, harnessPlaybookFileName } from "./harness-playbooks.js";
5
- import { HARNESS_TOOL_REFS_DIR } from "./harness-tool-refs.js";
6
- function harnessTitle(harness) {
7
- switch (harness) {
8
- case "claude":
9
- return "Claude Code";
10
- case "cursor":
11
- return "Cursor";
12
- case "opencode":
13
- return "OpenCode";
14
- case "codex":
15
- return "OpenAI Codex";
16
- }
17
- }
18
- function tierDescription(tier) {
19
- if (tier === "tier1")
20
- return "full native automation";
21
- if (tier === "tier2")
22
- return "partial automation with waivers";
23
- return "compatibility shim";
24
- }
25
- export function harnessIntegrationDocMarkdown() {
26
- const harnesses = Object.keys(HARNESS_ADAPTERS);
27
- const stageSkillRows = Object.entries(STAGE_TO_SKILL_FOLDER)
28
- .map(([stage, skillFolder]) => `| \`${stage}\` | \`${skillFolder}\` |`)
29
- .join("\n");
30
- const hookCasingRows = [
31
- "| Claude Code | `claude` | PascalCase (`SessionStart`, `PreToolUse`) |",
32
- "| Cursor | `cursor` | camelCase (`sessionStart`, `preToolUse`) |",
33
- "| OpenCode | `opencode` | camelCase (`sessionStart`, `preToolUse`) |",
34
- "| OpenAI Codex | `codex` | PascalCase (`SessionStart`, `PreToolUse`) |"
35
- ].join("\n");
36
- const capabilityRows = harnesses
37
- .map((harness) => {
38
- const adapter = HARNESS_ADAPTERS[harness];
39
- const tier = harnessTier(harness);
40
- const caps = adapter.capabilities;
41
- const playbook = `\`${HARNESS_PLAYBOOKS_DIR}/${harnessPlaybookFileName(harness)}\``;
42
- return `| ${harnessTitle(harness)} | \`${harness}\` | \`${tier}\` (${tierDescription(tier)}) | ${caps.nativeSubagentDispatch} | ${caps.subagentFallback} | ${caps.hookSurface} | ${caps.structuredAsk} | ${playbook} |`;
43
- })
44
- .join("\n");
45
- const hookRows = HOOK_SEMANTIC_EVENTS.map((eventName) => {
46
- const columns = harnesses
47
- .map((harness) => {
48
- const mapping = HOOK_EVENTS_BY_HARNESS[harness][eventName];
49
- return mapping ?? "missing";
50
- })
51
- .join(" | ");
52
- return `| \`${eventName}\` | ${columns} |`;
53
- }).join("\n");
54
- return `# Harness Integration Matrix
55
-
56
- Generated from \`src/harness-adapters.ts\` capabilities and hook event mappings.
57
-
58
- ## Capability tiers
59
-
60
- | Harness | ID | Tier | Native dispatch | Fallback | Hook surface | Structured ask | Playbook |
61
- |---|---|---|---|---|---|---|---|
62
- ${capabilityRows}
63
-
64
- Fallback legend:
65
-
66
- - \`native\` — first-class named subagent dispatch (Claude).
67
- - \`generic-dispatch\` — generic Task dispatcher mapped to cclaw roles (Cursor).
68
- - \`role-switch\` — in-session role announce + delegation-log entry with evidenceRefs (OpenCode, Codex).
69
- - \`waiver\` — no parity path; reserved for harnesses that cannot role-switch (none shipped).
70
-
71
- ## Parallel research dispatch semantics
72
-
73
- Design-stage research fleet uses the same parity model:
74
-
75
- - **Claude / Cursor**: dispatch all four research lenses in one turn
76
- (stack, features, architecture, pitfalls) and synthesize into
77
- \`.cclaw/artifacts/02a-research.md\`.
78
- - **OpenCode / Codex**: execute the same four lenses via sequential
79
- role-switch, each with explicit announce -> execute -> evidence trail.
80
- This preserves auditability when native parallel dispatch is unavailable.
81
-
82
- ## Semantic hook event coverage
83
-
84
- | Event | Claude | Cursor | OpenCode | Codex |
85
- |---|---|---|---|---|
86
- ${hookRows}
87
-
88
- ## Hook event casing
89
-
90
- Hook keys are intentionally harness-native and must not be normalized:
91
-
92
- | Harness | ID | Event key casing |
93
- |---|---|---|
94
- ${hookCasingRows}
95
-
96
- Use the exact event names from each harness schema. Treating all hooks as one
97
- shared casing silently breaks generated wiring.
98
-
99
- ## Interpretation
100
-
101
- - \`tier1\`: full native delegation + structured asks + full hook surface.
102
- - \`tier2\`: usable flow with capability gaps; mandatory delegation can require waivers.
103
- - Codex-specific ceiling: \`PreToolUse\` can only intercept \`Bash\`. Direct
104
- \`Write\`/\`Edit\` to \`.cclaw/state/flow-state.json\` cannot be hard-blocked
105
- at hook level, so the canonical path is
106
- \`node .cclaw/hooks/stage-complete.mjs <stage>\` plus the non-blocking
107
- \`UserPromptSubmit\` state nudge.
108
-
109
- ## Shared command contract
110
-
111
- All harnesses receive the same utility commands:
112
-
113
- - \`/cc\` - flow entry and resume
114
- - \`/cc-next\` - stage progression
115
- - \`/cc-ideate\` - ideate mode for ranked repo-improvement backlog
116
- - \`/cc-view\` - read-only router for status/tree/diff
117
- - \`/cc-ops\` - operations router for feature/tdd-log/retro/compound/archive/rewind
118
-
119
- Read-only subcommands:
120
- - \`/cc-view status\` - visual flow snapshot
121
- - \`/cc-view tree\` - deep flow tree (stages, artifacts, stale markers)
122
- - \`/cc-view diff\` - before/after flow-state diff map
123
-
124
- Operations subcommands:
125
- - \`/cc-ops feature ...\` - git-worktree feature isolation and routing
126
- - \`/cc-ops tdd-log ...\` - explicit RED/GREEN/REFACTOR evidence log
127
- - \`/cc-ops retro\` - mandatory retrospective gate before archive
128
- - \`/cc-ops compound\` - lift repeated learnings into durable rules/skills
129
- - \`/cc-ops archive\` - archive active run from harness flow
130
- - \`/cc-ops rewind ...\` - rewind flow and invalidate downstream stages
131
- - \`/cc-ops rewind --ack ...\` - clear stale stage markers after redo
132
-
133
- Stage order remains canonical:
134
- \`brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship\`
135
-
136
- ## Stage -> skill folder mapping
137
-
138
- | Stage | Skill folder |
139
- |---|---|
140
- ${stageSkillRows}
141
-
142
- This map is generated from \`src/constants.ts::STAGE_TO_SKILL_FOLDER\` so
143
- skill-path naming stays explicit and stable even when stage ids differ from
144
- folder names.
145
-
146
- ## Install surfaces
147
-
148
- Always generated:
149
-
150
- - \`.cclaw/commands/*.md\`
151
- - \`.cclaw/skills/*/SKILL.md\`
152
- - \`.cclaw/references/**\`
153
- - \`.cclaw/state/*.json|*.jsonl\`
154
- - \`AGENTS.md\` managed block
155
-
156
- Harness-specific additions:
157
-
158
- - \`claude\`: \`.claude/commands/cc*.md\`, \`.claude/hooks/hooks.json\`
159
- - \`cursor\`: \`.cursor/commands/cc*.md\`, \`.cursor/hooks.json\`, \`.cursor/rules/cclaw-workflow.mdc\`
160
- - \`opencode\`: \`.opencode/commands/cc*.md\`, \`.opencode/plugins/cclaw-plugin.mjs\`, opencode plugin registration
161
- - \`codex\`: \`.agents/skills/cc/SKILL.md\`, \`.agents/skills/cc-next/SKILL.md\`, \`.agents/skills/cc-ideate/SKILL.md\`, \`.agents/skills/cc-view/SKILL.md\`, \`.agents/skills/cc-ops/SKILL.md\`, \`.codex/hooks.json\` (Codex CLI reads \`.agents/skills/\` for custom skills and consumes \`.codex/hooks.json\` on v0.114+ when \`[features] codex_hooks = true\` is set in \`~/.codex/config.toml\`. \`.codex/commands/\` and the legacy \`.agents/skills/cclaw-cc*/\` layout from v0.39.x are auto-cleaned on sync.)
162
-
163
- ## Runtime observability
164
-
165
- - \`.cclaw/state/harness-gaps.json\` captures per-harness capability gaps for the active config.
166
- - \`cclaw doctor\` validates shim, hook, and lifecycle surfaces against this capability model.
167
- `;
168
- }
169
- export function harnessDocsOverviewMarkdown() {
170
- const harnesses = Object.keys(HARNESS_ADAPTERS);
171
- const rows = harnesses
172
- .map((harness) => {
173
- const tier = harnessTier(harness);
174
- const toolMap = `\`.cclaw/${HARNESS_TOOL_REFS_DIR}/${harness}.md\``;
175
- const playbook = `\`.cclaw/${HARNESS_PLAYBOOKS_DIR}/${harnessPlaybookFileName(harness)}\``;
176
- return `| ${harnessTitle(harness)} | \`${harness}\` | \`${tier}\` | ${toolMap} | ${playbook} |`;
177
- })
178
- .join("\n");
179
- return `# Harness Docs Overview
180
-
181
- Single entrypoint for harness-specific references generated by cclaw sync.
182
-
183
- ## Core references
184
-
185
- - Integration matrix: \`.cclaw/references/harnesses.md\`
186
- - Tool-map index: \`.cclaw/references/${HARNESS_TOOL_REFS_DIR}/README.md\`
187
- - Playbook index: \`.cclaw/references/${HARNESS_PLAYBOOKS_DIR}/README.md\`
188
-
189
- ## Per-harness quick links
190
-
191
- | Harness | ID | Tier | Tool map | Playbook |
192
- |---|---|---|---|---|
193
- ${rows}
194
-
195
- ## How to use this pack
196
-
197
- 1. Start with \`harnesses.md\` to understand capability/tier differences.
198
- 2. Open the harness-specific tool map before writing stage logic that depends on tool names.
199
- 3. Open the harness-specific playbook before asserting delegation parity behavior.
200
- 4. If docs disagree, treat \`harnesses.md\` + harness adapter capabilities as source of truth and regenerate.
201
- `;
202
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * Per-harness parity playbooks.
3
- *
4
- * cclaw's subagent contracts (planner / reviewer / security-reviewer /
5
- * test-author / doc-updater) assume Claude-style isolated workers. On
6
- * harnesses without that primitive, the agent has to fulfil the role via a
7
- * documented fallback (generic Task dispatch, role-switch in-session, …).
8
- *
9
- * Each playbook is:
10
- * 1. short (≤ ~150 lines markdown),
11
- * 2. executable — reproducible by an agent without reading the whole repo,
12
- * 3. evidence-first — always records a delegation-log entry with
13
- * `fulfillmentMode` and `evidenceRefs` so `cclaw doctor` can tell the
14
- * role was actually performed.
15
- *
16
- * Playbooks are materialised at
17
- * `.cclaw/references/harnesses/<harness>-playbook.md` by install/sync/upgrade.
18
- */
19
- import type { HarnessId } from "../types.js";
20
- export declare const HARNESS_PLAYBOOKS_DIR = "references/harnesses";
21
- export declare function harnessPlaybookRelativePath(harness: HarnessId): string;
22
- export declare function harnessPlaybookFileName(harness: HarnessId): string;
23
- export declare function harnessPlaybookMarkdown(harness: HarnessId): string;
24
- export declare function harnessPlaybooksIndexMarkdown(): string;
@@ -1,393 +0,0 @@
1
- /**
2
- * Per-harness parity playbooks.
3
- *
4
- * cclaw's subagent contracts (planner / reviewer / security-reviewer /
5
- * test-author / doc-updater) assume Claude-style isolated workers. On
6
- * harnesses without that primitive, the agent has to fulfil the role via a
7
- * documented fallback (generic Task dispatch, role-switch in-session, …).
8
- *
9
- * Each playbook is:
10
- * 1. short (≤ ~150 lines markdown),
11
- * 2. executable — reproducible by an agent without reading the whole repo,
12
- * 3. evidence-first — always records a delegation-log entry with
13
- * `fulfillmentMode` and `evidenceRefs` so `cclaw doctor` can tell the
14
- * role was actually performed.
15
- *
16
- * Playbooks are materialised at
17
- * `.cclaw/references/harnesses/<harness>-playbook.md` by install/sync/upgrade.
18
- */
19
- import { HARNESS_ADAPTERS } from "../harness-adapters.js";
20
- export const HARNESS_PLAYBOOKS_DIR = "references/harnesses";
21
- export function harnessPlaybookRelativePath(harness) {
22
- return `${HARNESS_PLAYBOOKS_DIR}/${harness}-playbook.md`;
23
- }
24
- export function harnessPlaybookFileName(harness) {
25
- return `${harness}-playbook.md`;
26
- }
27
- const CLAUDE_PLAYBOOK = `---
28
- harness: claude
29
- fallback: native
30
- description: "Claude Code has real isolated subagent workers with user-defined named types. No fallback required — this playbook is reference-only."
31
- ---
32
-
33
- # Claude Code — Parity Playbook
34
-
35
- **Status: native.** Claude Code supports isolated subagent workers via the
36
- \`Task\` tool with user-defined \`subagent_type\` (\`planner\`, \`reviewer\`,
37
- \`security-reviewer\`, \`test-author\`, \`doc-updater\`). Each dispatch runs in
38
- its own context and produces a return message visible only to the parent
39
- agent.
40
-
41
- This playbook exists so the harness matrix has one reference shape; Claude
42
- itself has no parity gap to close.
43
-
44
- ## Dispatch pattern
45
-
46
- 1. Pick the \`subagent_type\` matching the cclaw agent (e.g. \`reviewer\`).
47
- 2. Provide a specific, self-contained \`prompt\` — the subagent cannot see
48
- prior assistant turns.
49
- 3. Record a delegation entry before dispatch:
50
-
51
- \`\`\`json
52
- {
53
- "stage": "review",
54
- "agent": "reviewer",
55
- "mode": "mandatory",
56
- "status": "scheduled",
57
- "fulfillmentMode": "isolated",
58
- "spanId": "dspan-..."
59
- }
60
- \`\`\`
61
-
62
- 4. After the subagent returns, update the entry to \`status: "completed"\`
63
- and attach \`evidenceRefs\` pointing at the artifact section that
64
- captures the subagent's output.
65
-
66
- ## Verification
67
-
68
- \`cclaw doctor\` will pass the \`delegation:mandatory:current_stage\` check
69
- when each mandatory agent has a \`completed\` row for the active run.
70
- `;
71
- const CURSOR_PLAYBOOK = `---
72
- harness: cursor
73
- fallback: generic-dispatch
74
- description: "Cursor has a generic Task dispatcher with subagent_type (generalPurpose, explore, shell, …) but no user-defined named subagents. cclaw maps planner/reviewer/test-author/… onto generic dispatch with a structured role prompt."
75
- ---
76
-
77
- # Cursor — Parity Playbook
78
-
79
- **Fallback: generic-dispatch.** Cursor's \`Task\` tool supports
80
- \`subagent_type\` from a fixed vocabulary (\`generalPurpose\`, \`explore\`,
81
- \`shell\`, \`browser-use\`, …). Real isolation, but no user-defined agent
82
- names. cclaw closes the gap by mapping each named cclaw agent onto the
83
- generic dispatcher with a strict role prompt.
84
-
85
- ## Named-agent → Cursor subagent_type map
86
-
87
- | cclaw agent | Cursor \`subagent_type\` | Readonly? | Rationale |
88
- |----------------------|-------------------------|-----------|-----------|
89
- | \`planner\` | \`explore\` | yes | Pure research, no writes. |
90
- | \`reviewer\` | \`explore\` | yes | Reads diff + context, emits findings. |
91
- | \`security-reviewer\`| \`explore\` | yes | Reads code, produces report; no fixes. |
92
- | \`test-author\` | \`generalPurpose\` | no | Writes tests, runs them, iterates. |
93
- | \`doc-updater\` | \`generalPurpose\` | no | Edits docs, re-runs build. |
94
-
95
- ## Dispatch pattern
96
-
97
- 1. Pick the mapped \`subagent_type\` from the table above.
98
- 2. Build the \`prompt\` from the cclaw agent role brief in
99
- \`.cclaw/agents/<agent>.md\`, prefaced with a single line naming the
100
- cclaw role (\`You are the cclaw <agent>. Follow the role brief below.\`).
101
- 3. Set \`readonly: true\` when the table says yes — Cursor enforces it.
102
- 4. Before dispatch, append a delegation row:
103
-
104
- \`\`\`json
105
- {
106
- "stage": "tdd",
107
- "agent": "test-author",
108
- "mode": "mandatory",
109
- "status": "scheduled",
110
- "fulfillmentMode": "generic-dispatch",
111
- "spanId": "dspan-..."
112
- }
113
- \`\`\`
114
-
115
- 5. After dispatch returns, transition the row to \`completed\` with
116
- \`evidenceRefs\` citing the artifact anchor where the result landed.
117
-
118
- ## Why not upgrade Cursor to a full tier-1?
119
-
120
- Cursor has dispatch + hooks + \`AskQuestion\`. The missing piece is
121
- **user-defined named subagents**. Semantically this is the difference
122
- between Claude's \`test-author\` (a distinct runtime worker registered by
123
- cclaw) and Cursor's \`generalPurpose\` worker that cclaw *asks* to act as a
124
- test-author. Good enough for parity; different enough to keep the labels
125
- honest.
126
-
127
- ## Verification
128
-
129
- \`cclaw doctor\` passes when the delegation row exists with
130
- \`fulfillmentMode: "generic-dispatch"\` (or \`completed\` rows for the
131
- mandatory agents in general). No evidenceRef requirement applies here —
132
- Cursor dispatch is real isolation.
133
- `;
134
- const OPENCODE_PLAYBOOK = `---
135
- harness: opencode
136
- fallback: role-switch
137
- description: "OpenCode has plugin-based dispatch hooks and a native structured-ask tool (question) but no isolated subagent worker primitive. cclaw uses an in-session role-switch with a delegation-log entry + evidenceRefs, and emits Decision Protocol calls through the question tool when it is permitted."
138
- ---
139
-
140
- # OpenCode — Parity Playbook
141
-
142
- **Fallback: role-switch.** OpenCode exposes tool/session event hooks via a
143
- plugin but does not provide an isolated subagent worker. cclaw closes the
144
- delegation gate by role-switching inside the same session: the agent
145
- announces the role, performs the work against the role brief, and records
146
- evidence.
147
-
148
- **Structured ask: native \`question\` tool.** OpenCode ships a first-class
149
- \`question\` primitive (header + question text + options, plus a
150
- "type custom" fallback; supports multi-question navigation). It is
151
- permission-gated:
152
-
153
- - \`opencode.json\` must grant \`permission.question: "allow"\` (or be
154
- covered by a \`"*": "allow"\` default).
155
- - ACP clients additionally need \`OPENCODE_ENABLE_QUESTION_TOOL=1\` set
156
- on the \`opencode acp\` process.
157
-
158
- When the tool is permitted, every Decision Protocol call maps to a single
159
- \`question\` invocation. When it is denied or the host doesn't expose it,
160
- fall back to the shared plain-text lettered list — same skeleton, same
161
- artifact decision log. Full mapping:
162
- \`.cclaw/references/harness-tools/opencode.md\`.
163
-
164
- ## Role-switch protocol
165
-
166
- 1. Announce the role explicitly in a single message:
167
-
168
- > Acting as cclaw **<agent>** per \`.cclaw/agents/<agent>.md\`. No other
169
- > role may be assumed until the delegation row is closed.
170
-
171
- 2. Execute the role's brief. Do NOT interleave other roles' work.
172
- 3. Write the result into the stage artifact (e.g. TDD work lands in
173
- \`.cclaw/artifacts/06-tdd.md\`).
174
- 4. Append a delegation row:
175
-
176
- \`\`\`json
177
- {
178
- "stage": "tdd",
179
- "agent": "test-author",
180
- "mode": "mandatory",
181
- "status": "completed",
182
- "fulfillmentMode": "role-switch",
183
- "evidenceRefs": [
184
- ".cclaw/artifacts/06-tdd.md#red-run",
185
- ".cclaw/artifacts/06-tdd.md#green-run"
186
- ],
187
- "spanId": "dspan-..."
188
- }
189
- \`\`\`
190
-
191
- 5. \`evidenceRefs\` **must** point at concrete artifact anchors — not
192
- placeholder text. \`cclaw doctor\` will report \`missingEvidence\` if
193
- the array is empty under a role-switch fallback.
194
-
195
- ## Exception: OpenCode plugin dispatch
196
-
197
- If the project configures a plugin-based dispatch path (e.g. a tool that
198
- spawns a worker process), set \`fulfillmentMode: "generic-dispatch"\`
199
- instead of \`role-switch\` and omit the role-announce step. evidenceRefs
200
- remain optional but recommended.
201
-
202
- ## Verification
203
-
204
- \`cclaw doctor\` passes when every mandatory agent for the active stage
205
- has either a \`completed\` row with evidenceRefs (role-switch) or a
206
- \`completed\` row under plugin dispatch.
207
- `;
208
- const CODEX_PLAYBOOK = `---
209
- harness: codex
210
- fallback: role-switch
211
- description: "OpenAI Codex exposes lifecycle hooks (v0.114+, gated by the codex_hooks feature flag) but no subagent dispatch and no custom slash commands. cclaw ships entry points as skills under .agents/skills/cc*/ and wires .codex/hooks.json; mandatory delegations fall back to role-switch with evidenceRefs."
212
- ---
213
-
214
- # OpenAI Codex — Parity Playbook
215
-
216
- Codex CLI has a different shape from Claude/Cursor:
217
-
218
- - **Entry points are skills.** \`/cc\`, \`/cc-next\`, \`/cc-ideate\`,
219
- \`/cc-view\`, \`/cc-ops\` are generated as skills at
220
- \`.agents/skills/cc/SKILL.md\` (and \`cc-next/\`, \`cc-view/\`,
221
- \`cc-ideate/\`, \`cc-ops/\`). They activate via Codex's native
222
- \`/use <skillName>\` command or automatically when the user's prompt
223
- mentions any of the \`/cc\`-style tokens (skill descriptions include
224
- them verbatim). Codex CLI removed custom prompts in v0.89 (Jan 2026);
225
- there is no way to register a true custom slash command.
226
- - **Lifecycle hooks.** Codex CLI ≥ v0.114 (Mar 2026) exposes lifecycle
227
- hooks at \`.codex/hooks.json\`, gated behind the experimental
228
- \`[features] codex_hooks = true\` flag in \`~/.codex/config.toml\`.
229
- cclaw writes \`.codex/hooks.json\` on sync; if the flag is off, the
230
- file is simply inert and \`cclaw doctor\` emits a warning. \`cclaw init\`
231
- offers to patch the flag with explicit user consent.
232
- - **Tool interception is Bash-only.** Codex's \`PreToolUse\` and
233
- \`PostToolUse\` events only fire for the \`Bash\` tool. \`Write\`,
234
- \`Edit\`, \`WebSearch\`, and MCP tool calls are **not** gated by hooks.
235
- cclaw partially compensates by wiring \`UserPromptSubmit\` to both
236
- \`prompt-guard\` and a non-blocking
237
- \`cclaw internal verify-current-state --quiet\` nudge that emits
238
- unmet-delegation / missing-evidence warnings before the turn executes.
239
- This is still a nudge, not a hard block: workflow-guard (TDD red-first,
240
- artifact presence) only fires on Bash turns. See the hook coverage matrix below.
241
- - **Legacy paths.** \`.codex/commands/*\` was never consumed by Codex and
242
- is removed on every \`cclaw sync\`. The v0.39.x \`.agents/skills/cclaw-cc*/\`
243
- layout is replaced by \`.agents/skills/cc*/\` and the old folders are
244
- auto-removed on sync. Do not restore either by hand.
245
-
246
- ## Structured ask: native \`request_user_input\` tool
247
-
248
- Codex exposes \`request_user_input\` — an experimental tool that accepts
249
- 1-3 short questions and returns the user's answers in the same order.
250
- It is the primitive the built-in Plan / Collaboration mode templates use
251
- (see \`codex-rs/collaboration-mode-templates/templates/plan.md\`), and
252
- agents running inside Codex can call it directly. Answers come back as
253
- free-form strings, not option IDs — keep lettered options inline in the
254
- question text so the user's reply maps cleanly to the artifact
255
- decision log.
256
-
257
- cclaw stage skills invoke \`request_user_input\` for every Decision
258
- Protocol call when the tool is available, and fall back to the shared
259
- plain-text lettered list when Codex returns a schema error or when the
260
- current host hides the tool (older builds, non-collaboration mode). Full
261
- mapping: \`.cclaw/references/harness-tools/codex.md\`.
262
-
263
- ## Fallback: role-switch
264
-
265
- Codex has no subagent dispatch — neither named nor generic. Mandatory
266
- delegations must be role-switched in-session. Silent auto-waiver was
267
- disabled in v0.33 and remains off.
268
-
269
- 1. **Explicit announce.** Before performing the role, emit a single
270
- message naming the role and citing \`.cclaw/agents/<agent>.md\`.
271
- 2. **No role interleaving.** Close one delegation before opening
272
- another; never mix, for example, reviewer and test-author work in
273
- the same turn.
274
- 3. **EvidenceRefs are mandatory.** A \`completed\` row without
275
- \`evidenceRefs\` is treated as \`missingEvidence\` by \`cclaw doctor\`
276
- and blocks the stage gate.
277
-
278
- ## Stage-specific role maps
279
-
280
- | Stage | Mandatory roles | Artifact to cite in evidenceRefs |
281
- |------------|----------------------------------|--------------------------------------|
282
- | scope | \`planner\` | \`.cclaw/artifacts/02-scope.md\` |
283
- | design | \`planner\` | \`.cclaw/artifacts/03-design.md\` |
284
- | plan | \`planner\` | \`.cclaw/artifacts/05-plan.md\` |
285
- | tdd | \`test-author\` | \`.cclaw/artifacts/06-tdd.md\` |
286
- | review | \`reviewer\`, \`security-reviewer\` | \`.cclaw/artifacts/07-review.md\` |
287
- | ship | \`doc-updater\` | \`.cclaw/artifacts/08-ship.md\` |
288
-
289
- ## Invocation cheatsheet
290
-
291
- - \`/use cc\` — open the \`/cc\` skill and pick a track.
292
- - \`/use cc-next\` — advance the flow one stage.
293
- - \`/use cc-ops\` — compound / archive / rewind.
294
- - \`node .cclaw/hooks/stage-complete.mjs <stage>\` — canonical stage closeout helper;
295
- validates delegations + gate evidence before mutating \`flow-state.json\`.
296
- - Typing \`/cc …\` or \`/cc-next …\` in plain text also works: Codex
297
- matches the skill descriptions (which spell out these tokens) and
298
- auto-loads the right skill body.
299
- - Use Codex's built-in \`/skill\` UI to enable or disable
300
- cclaw skills per session.
301
-
302
- ## Feature flag — how to enable hooks
303
-
304
- Codex CLI ignores \`.codex/hooks.json\` unless \`codex_hooks = true\`
305
- appears under \`[features]\` in \`~/.codex/config.toml\`:
306
-
307
- \`\`\`toml
308
- [features]
309
- codex_hooks = true
310
- \`\`\`
311
-
312
- \`cclaw init --codex\` prompts to write this automatically (one-line
313
- diff, preserving the rest of \`config.toml\` untouched). Decline the
314
- prompt to leave the file alone; the skill-level \`/use cc\` entry points
315
- continue to work regardless.
316
-
317
- ## Hook coverage matrix
318
-
319
- | Hook intent | Codex mapping | Coverage |
320
- |-------------|---------------|----------|
321
- | SessionStart rehydration | \`SessionStart\` matcher \`startup|resume\` → \`session-start\` | Full. |
322
- | PreToolUse prompt-guard | \`PreToolUse\` matcher \`Bash\` + \`UserPromptSubmit\` → \`prompt-guard\` | Bash tool calls are gated inline; \`UserPromptSubmit\` catches prompts before any tool fires, so non-Bash writes (\`Write\`/\`Edit\`) are still prompt-guarded at the turn boundary. |
323
- | UserPromptSubmit state nudge | \`UserPromptSubmit\` → \`cclaw internal verify-current-state --quiet\` | Non-blocking warning only. Prints unmet mandatory delegation / gate-evidence counts before the turn; cannot block non-Bash \`Write\`/\`Edit\`. |
324
- | PreToolUse workflow-guard | \`PreToolUse\` matcher \`Bash\` → \`workflow-guard\` | Bash-only. For \`Write\`/\`Edit\` calls the agent performs the TDD-order / artifact check in-turn (see the stage skill). |
325
- | PostToolUse context-monitor | \`PostToolUse\` matcher \`Bash\` → \`context-monitor\` | Bash-only. Other tool calls get context-monitored at end-of-turn via \`.cclaw/references/protocols/ethos.md\`. |
326
- | Stop checkpoint | \`Stop\` → \`stop-checkpoint\` | Full. |
327
- | PreCompact digest | Not supported — Codex has no \`PreCompact\` event. | Covered by \`/cc-ops retro\` and the user running \`/cc-view status\` before Codex's \`/compact\` command. |
328
-
329
- ## Verification
330
-
331
- \`cclaw doctor\` on a codex-enabled install checks:
332
-
333
- - \`shim:codex:cc:present\` and \`frontmatter\` (plus the four utility
334
- skills \`cc-next\`, \`cc-view\`, \`cc-ops\`, \`cc-ideate\`).
335
- - \`hook:schema:codex\` validates \`.codex/hooks.json\` shape.
336
- - \`hook:wiring:codex\` verifies the generated hooks reference every
337
- runtime script cclaw needs (session-start, prompt-guard, workflow-guard,
338
- context-monitor, stop-checkpoint).
339
- - \`warning:codex:feature_flag\` is emitted as a warning (not an error)
340
- when \`~/.codex/config.toml\` is missing the \`codex_hooks\` feature
341
- flag — hooks silently do nothing in that state.
342
- - \`warning:codex:legacy_commands_dir\` and
343
- \`warning:codex:legacy_cclaw_cc_skills\` catch leftovers from older
344
- cclaw versions.
345
- - Every mandatory agent for the active stage has a \`completed\` row
346
- with \`fulfillmentMode: "role-switch"\` and at least one \`evidenceRef\`.
347
- `;
348
- const PLAYBOOK_BY_HARNESS = {
349
- claude: CLAUDE_PLAYBOOK,
350
- cursor: CURSOR_PLAYBOOK,
351
- opencode: OPENCODE_PLAYBOOK,
352
- codex: CODEX_PLAYBOOK
353
- };
354
- export function harnessPlaybookMarkdown(harness) {
355
- const body = PLAYBOOK_BY_HARNESS[harness];
356
- if (!body) {
357
- throw new Error(`No playbook defined for harness "${harness}".`);
358
- }
359
- return body;
360
- }
361
- export function harnessPlaybooksIndexMarkdown() {
362
- const rows = Object.keys(HARNESS_ADAPTERS)
363
- .map((h) => {
364
- const fallback = HARNESS_ADAPTERS[h].capabilities.subagentFallback;
365
- return `| \`${h}\` | ${fallback} | [\`${harnessPlaybookFileName(h)}\`](./${harnessPlaybookFileName(h)}) |`;
366
- })
367
- .join("\n");
368
- return `# Harness parity playbooks
369
-
370
- Each playbook describes the concrete pattern cclaw expects when the
371
- harness does not natively satisfy a mandatory delegation contract.
372
-
373
- | Harness | Fallback | Playbook |
374
- |---|---|---|
375
- ${rows}
376
-
377
- ## How cclaw uses these files
378
-
379
- - \`cclaw doctor\` verifies that every installed harness has its playbook
380
- present under \`.cclaw/references/harnesses/\`.
381
- - Stage skills (TDD, review, ship) cite the active harness's playbook
382
- instead of inlining the fallback pattern.
383
- - The \`delegation:mandatory:current_stage\` check expects
384
- \`fulfillmentMode\` to match the harness's declared \`subagentFallback\`
385
- (\`isolated\`, \`generic-dispatch\`, or \`role-switch\`).
386
-
387
- ## When to edit
388
-
389
- Playbooks are generated by \`cclaw upgrade\`. Local edits are overwritten.
390
- To customise the parity pattern for a specific repository, override the
391
- skill that cites the playbook, not the playbook itself.
392
- `;
393
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Per-harness tool-mapping reference files.
3
- *
4
- * Addresses A.1#4: the four supported harnesses (claude, cursor, opencode, codex)
5
- * expose different primitive names for the same capabilities (ask-user,
6
- * delegate/Task, web fetch, file edit, code execution, ...). cclaw's stage skills
7
- * need to pick the right name at runtime without bloating every stage with per-harness
8
- * if/else ladders.
9
- *
10
- * Each file below is short (one table per capability), authoritative, and materialised
11
- * at `.cclaw/references/harness-tools/<harness>.md`. Stage skills and the meta-skill
12
- * cite the folder instead of duplicating the mappings inline.
13
- *
14
- * When a new harness is added (or an existing one renames a tool), update the
15
- * corresponding entry here — do NOT scatter tool names across skill text.
16
- */
17
- import type { HarnessId } from "../types.js";
18
- export declare const HARNESS_TOOL_REFS_DIR = "references/harness-tools";
19
- export declare function harnessToolRefMarkdown(harness: HarnessId): string;
20
- export declare const HARNESS_TOOL_REFS_INDEX_MD = "---\nname: Harness tool maps\ndescription: \"Index file. One reference per supported harness \u2014 cite the per-harness file instead of hardcoding tool names in stage skills.\"\n---\n\n# Harness Tool Maps\n\ncclaw supports four harnesses; each exposes different primitive names for the same capabilities. Stage skills and utility skills cite the file matching the currently active harness and fall back to plain-text equivalents for capabilities that the harness lacks.\n\n| Harness | File | Notes |\n|---|---|---|\n| Claude Code | `.cclaw/references/harness-tools/claude.md` | Richest tool surface (AskUserQuestion, Task, WebFetch, WebSearch, MCP, \u2026). |\n| Cursor | `.cclaw/references/harness-tools/cursor.md` | Near-parity with Claude; uses `AskQuestion` instead of `AskUserQuestion`. |\n| OpenCode | `.cclaw/references/harness-tools/opencode.md` | Native `question` tool (permission-gated) for structured asks; no isolated subagent dispatch. |\n| Codex | `.cclaw/references/harness-tools/codex.md` | Native `request_user_input` tool (experimental, Plan / Collaboration mode) for structured asks; no subagent dispatch. |\n\nWhen a new harness is added or an existing one renames a tool, update the corresponding file (and this index) \u2014 do NOT scatter tool names across skill text.\n";