cclaw-cli 0.48.35 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/README.md +54 -82
  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 -495
  6. package/dist/constants.d.ts +2 -13
  7. package/dist/constants.js +1 -46
  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 +51 -9
  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 +2 -0
  23. package/dist/content/ideate-command.d.ts +2 -0
  24. package/dist/content/ideate-command.js +31 -25
  25. package/dist/content/iron-laws.d.ts +5 -5
  26. package/dist/content/iron-laws.js +5 -5
  27. package/dist/content/learnings.d.ts +3 -4
  28. package/dist/content/learnings.js +24 -50
  29. package/dist/content/meta-skill.js +31 -24
  30. package/dist/content/next-command.js +38 -38
  31. package/dist/content/node-hooks.js +17 -343
  32. package/dist/content/opencode-plugin.js +2 -100
  33. package/dist/content/research-playbooks.js +14 -14
  34. package/dist/content/review-loop.d.ts +2 -0
  35. package/dist/content/review-loop.js +8 -0
  36. package/dist/content/session-hooks.js +14 -46
  37. package/dist/content/skills.d.ts +0 -5
  38. package/dist/content/skills.js +53 -128
  39. package/dist/content/stage-common-guidance.d.ts +0 -1
  40. package/dist/content/stage-common-guidance.js +15 -14
  41. package/dist/content/stage-schema.d.ts +26 -1
  42. package/dist/content/stage-schema.js +121 -40
  43. package/dist/content/stages/_lint-metadata/index.js +9 -15
  44. package/dist/content/stages/brainstorm.js +22 -43
  45. package/dist/content/stages/design.js +37 -57
  46. package/dist/content/stages/plan.js +22 -13
  47. package/dist/content/stages/review.js +24 -27
  48. package/dist/content/stages/scope.js +34 -46
  49. package/dist/content/stages/ship.js +7 -4
  50. package/dist/content/stages/spec.js +20 -9
  51. package/dist/content/stages/tdd.js +64 -44
  52. package/dist/content/start-command.js +10 -12
  53. package/dist/content/status-command.d.ts +2 -7
  54. package/dist/content/status-command.js +19 -146
  55. package/dist/content/subagents.d.ts +0 -5
  56. package/dist/content/subagents.js +47 -28
  57. package/dist/content/templates.d.ts +1 -1
  58. package/dist/content/templates.js +126 -135
  59. package/dist/content/track-render-context.d.ts +17 -0
  60. package/dist/content/track-render-context.js +44 -0
  61. package/dist/content/tree-command.d.ts +1 -2
  62. package/dist/content/tree-command.js +4 -87
  63. package/dist/content/utility-skills.d.ts +2 -29
  64. package/dist/content/utility-skills.js +2 -1533
  65. package/dist/content/view-command.js +29 -11
  66. package/dist/delegation.d.ts +1 -1
  67. package/dist/delegation.js +5 -15
  68. package/dist/doctor-registry.js +20 -21
  69. package/dist/doctor.js +88 -408
  70. package/dist/flow-state.d.ts +3 -0
  71. package/dist/flow-state.js +2 -0
  72. package/dist/harness-adapters.d.ts +1 -1
  73. package/dist/harness-adapters.js +48 -57
  74. package/dist/install.js +128 -520
  75. package/dist/internal/advance-stage.js +3 -9
  76. package/dist/internal/compound-readiness.d.ts +1 -1
  77. package/dist/internal/compound-readiness.js +1 -1
  78. package/dist/internal/tdd-loop-status.d.ts +1 -1
  79. package/dist/internal/tdd-loop-status.js +1 -1
  80. package/dist/knowledge-store.d.ts +16 -10
  81. package/dist/knowledge-store.js +51 -15
  82. package/dist/policy.js +16 -109
  83. package/dist/run-archive.d.ts +4 -6
  84. package/dist/run-archive.js +15 -20
  85. package/dist/run-persistence.d.ts +2 -2
  86. package/dist/run-persistence.js +3 -9
  87. package/package.json +1 -2
  88. package/dist/content/archive-command.d.ts +0 -2
  89. package/dist/content/archive-command.js +0 -124
  90. package/dist/content/compound-command.d.ts +0 -5
  91. package/dist/content/compound-command.js +0 -193
  92. package/dist/content/contexts.d.ts +0 -9
  93. package/dist/content/contexts.js +0 -65
  94. package/dist/content/contracts.d.ts +0 -2
  95. package/dist/content/contracts.js +0 -51
  96. package/dist/content/doctor-references.d.ts +0 -2
  97. package/dist/content/doctor-references.js +0 -150
  98. package/dist/content/eval-scaffold.d.ts +0 -15
  99. package/dist/content/eval-scaffold.js +0 -370
  100. package/dist/content/feature-command.d.ts +0 -2
  101. package/dist/content/feature-command.js +0 -123
  102. package/dist/content/flow-map.d.ts +0 -23
  103. package/dist/content/flow-map.js +0 -134
  104. package/dist/content/harness-doc.d.ts +0 -2
  105. package/dist/content/harness-doc.js +0 -202
  106. package/dist/content/harness-playbooks.d.ts +0 -24
  107. package/dist/content/harness-playbooks.js +0 -393
  108. package/dist/content/harness-tool-refs.d.ts +0 -20
  109. package/dist/content/harness-tool-refs.js +0 -268
  110. package/dist/content/ops-command.d.ts +0 -2
  111. package/dist/content/ops-command.js +0 -71
  112. package/dist/content/protocols.d.ts +0 -7
  113. package/dist/content/protocols.js +0 -215
  114. package/dist/content/retro-command.d.ts +0 -2
  115. package/dist/content/retro-command.js +0 -165
  116. package/dist/content/rewind-command.d.ts +0 -2
  117. package/dist/content/rewind-command.js +0 -106
  118. package/dist/content/tdd-log-command.d.ts +0 -2
  119. package/dist/content/tdd-log-command.js +0 -85
  120. package/dist/eval/agents/single-shot.d.ts +0 -27
  121. package/dist/eval/agents/single-shot.js +0 -79
  122. package/dist/eval/agents/with-tools.d.ts +0 -44
  123. package/dist/eval/agents/with-tools.js +0 -261
  124. package/dist/eval/agents/workflow.d.ts +0 -31
  125. package/dist/eval/agents/workflow.js +0 -155
  126. package/dist/eval/baseline.d.ts +0 -38
  127. package/dist/eval/baseline.js +0 -282
  128. package/dist/eval/config-loader.d.ts +0 -14
  129. package/dist/eval/config-loader.js +0 -395
  130. package/dist/eval/corpus.d.ts +0 -30
  131. package/dist/eval/corpus.js +0 -330
  132. package/dist/eval/cost-guard.d.ts +0 -102
  133. package/dist/eval/cost-guard.js +0 -190
  134. package/dist/eval/diff.d.ts +0 -64
  135. package/dist/eval/diff.js +0 -323
  136. package/dist/eval/llm-client.d.ts +0 -176
  137. package/dist/eval/llm-client.js +0 -267
  138. package/dist/eval/mode.d.ts +0 -28
  139. package/dist/eval/mode.js +0 -61
  140. package/dist/eval/progress.d.ts +0 -83
  141. package/dist/eval/progress.js +0 -59
  142. package/dist/eval/report.d.ts +0 -11
  143. package/dist/eval/report.js +0 -181
  144. package/dist/eval/rubric-loader.d.ts +0 -20
  145. package/dist/eval/rubric-loader.js +0 -143
  146. package/dist/eval/runner.d.ts +0 -81
  147. package/dist/eval/runner.js +0 -746
  148. package/dist/eval/runs.d.ts +0 -41
  149. package/dist/eval/runs.js +0 -114
  150. package/dist/eval/sandbox.d.ts +0 -38
  151. package/dist/eval/sandbox.js +0 -137
  152. package/dist/eval/tools/glob.d.ts +0 -2
  153. package/dist/eval/tools/glob.js +0 -163
  154. package/dist/eval/tools/grep.d.ts +0 -2
  155. package/dist/eval/tools/grep.js +0 -152
  156. package/dist/eval/tools/index.d.ts +0 -7
  157. package/dist/eval/tools/index.js +0 -35
  158. package/dist/eval/tools/read.d.ts +0 -2
  159. package/dist/eval/tools/read.js +0 -122
  160. package/dist/eval/tools/types.d.ts +0 -49
  161. package/dist/eval/tools/types.js +0 -41
  162. package/dist/eval/tools/write.d.ts +0 -2
  163. package/dist/eval/tools/write.js +0 -92
  164. package/dist/eval/types.d.ts +0 -561
  165. package/dist/eval/types.js +0 -47
  166. package/dist/eval/verifiers/judge.d.ts +0 -40
  167. package/dist/eval/verifiers/judge.js +0 -256
  168. package/dist/eval/verifiers/rules.d.ts +0 -24
  169. package/dist/eval/verifiers/rules.js +0 -218
  170. package/dist/eval/verifiers/structural.d.ts +0 -14
  171. package/dist/eval/verifiers/structural.js +0 -171
  172. package/dist/eval/verifiers/traceability.d.ts +0 -23
  173. package/dist/eval/verifiers/traceability.js +0 -84
  174. package/dist/eval/verifiers/workflow-consistency.d.ts +0 -21
  175. package/dist/eval/verifiers/workflow-consistency.js +0 -225
  176. package/dist/eval/workflow-corpus.d.ts +0 -7
  177. package/dist/eval/workflow-corpus.js +0 -207
  178. package/dist/feature-system.d.ts +0 -42
  179. package/dist/feature-system.js +0 -432
  180. package/dist/internal/knowledge-digest.d.ts +0 -7
  181. package/dist/internal/knowledge-digest.js +0 -93
@@ -1,268 +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
- export const HARNESS_TOOL_REFS_DIR = "references/harness-tools";
18
- const CLAUDE_TOOLS_MD = `---
19
- harness: claude
20
- name: Claude Code tool map
21
- description: "Canonical mapping of cclaw capability names → Claude Code tool names. Cited by stage skills; do not duplicate in per-stage text."
22
- ---
23
-
24
- # Claude Code — Tool Map
25
-
26
- Use this file as the single source of truth for which Claude Code tool to call when a cclaw skill references a generic capability.
27
-
28
- ## Core capabilities
29
-
30
- | cclaw capability | Claude Code tool | Notes |
31
- |---|---|---|
32
- | Ask user a structured question | \`AskUserQuestion\` | Max 4 options; lettered labels ≤12 chars. Fall back to plain-text lettered list on schema error. |
33
- | Dispatch a subagent (read-only or write) | \`Task\` with \`subagent_type\` | \`explore\` = read-only; \`generalPurpose\` = read-write. Background via \`run_in_background: true\`. |
34
- | Read file | \`Read\` | Prefer this over \`cat\` / \`head\` / \`tail\`. |
35
- | Edit file | \`StrReplace\` (exact match) or \`Write\` (overwrite) | Always \`Read\` before editing; avoid \`sed\`/\`awk\` unless asked. |
36
- | Create file | \`Write\` | Reject if the task can be solved by editing an existing file. |
37
- | Search file contents | \`Grep\` (ripgrep-backed) | Use \`output_mode: files_with_matches\` for file lists. |
38
- | Find files by name / glob | \`Glob\` | Pattern matches mtime-sorted. |
39
- | Shell command | \`Shell\` | Background long-running jobs with \`block_until_ms: 0\`; poll with \`Await\`. |
40
- | Fetch URL | \`WebFetch\` | Returns markdown. No auth, no binaries. |
41
- | Web search | \`WebSearch\` | Use for docs, real-time info, version lookups. |
42
- | Semantic code search | \`SemanticSearch\` | One directory per call; whole-repo via \`[]\`. |
43
- | Todo tracking | \`TodoWrite\` | Use \`merge: true\` to update; keep one task \`in_progress\`. |
44
- | Ask tool (multi-question) | \`AskQuestion\` (Cursor-only, unavailable in Claude) | NOT available in Claude — use \`AskUserQuestion\` instead. |
45
- | MCP tool call | \`CallMcpTool\` | Always read the tool's schema descriptor first. |
46
-
47
- ## Decision-protocol mapping
48
-
49
- When a stage skill says "ask the user a structured question", in Claude Code that means:
50
-
51
- \`\`\`
52
- AskUserQuestion({
53
- questions: [{
54
- id: "...",
55
- prompt: "One-sentence decision, plain English",
56
- options: [
57
- { id: "a", label: "Short label" }, // ≤12 chars
58
- { id: "b", label: "Alt label" },
59
- { id: "c", label: "Recommended" }
60
- ]
61
- }]
62
- })
63
- \`\`\`
64
-
65
- One question per call. Never batch.
66
-
67
- ## Escalation / fall-back
68
-
69
- If a tool returns a schema error twice in a row (see the meta-skill's Error / Retry Budget), switch to plain-text equivalents:
70
-
71
- - \`AskUserQuestion\` → write a numbered list in the response, wait for reply.
72
- - \`Task\` (dispatch) → inline the work in the current turn.
73
- - \`WebFetch\` → ask the user for the URL's content.
74
- `;
75
- const CURSOR_TOOLS_MD = `---
76
- harness: cursor
77
- name: Cursor tool map
78
- description: "Canonical mapping of cclaw capability names → Cursor agent tool names. Cited by stage skills; do not duplicate in per-stage text."
79
- ---
80
-
81
- # Cursor — Tool Map
82
-
83
- Use this file as the single source of truth for which Cursor agent tool to call when a cclaw skill references a generic capability.
84
-
85
- ## Core capabilities
86
-
87
- | cclaw capability | Cursor tool | Notes |
88
- |---|---|---|
89
- | Ask user a structured question | \`AskQuestion\` | \`questions\` is an array; each question has \`id\`, \`prompt\`, \`options\`, optional \`allow_multiple\`. |
90
- | Dispatch a subagent | \`Task\` with \`subagent_type\` | Available types: \`generalPurpose\`, \`explore\` (readonly), \`shell\`, \`browser-use\`, \`best-of-n-runner\`. |
91
- | Read file | \`Read\` | Line-numbered output; avoid \`cat\` / \`head\` / \`tail\`. |
92
- | Edit file | \`StrReplace\` | Unique \`old_string\` required; use \`replace_all: true\` for bulk renames. |
93
- | Create file | \`Write\` | Prefer editing existing files. |
94
- | Search file contents | \`Grep\` (ripgrep-backed) | Output modes: \`content\`, \`files_with_matches\`, \`count\`. |
95
- | Find files by name / glob | \`Glob\` | Auto-prepends \`**/\` when pattern does not start with it. |
96
- | Shell command | \`Shell\` | Long-running jobs go to background via \`block_until_ms: 0\`; poll with \`Await\`. |
97
- | Fetch URL | \`WebFetch\` | Markdown output. |
98
- | Web search | \`WebSearch\` | Use for real-time info, framework docs, news. |
99
- | Semantic code search | \`SemanticSearch\` | Prefer for exploratory "how does X work?" queries. |
100
- | Todo tracking | \`TodoWrite\` | Supports \`merge: true\` for partial updates. |
101
- | Generate image | \`GenerateImage\` | Only on explicit user request. |
102
- | Ask structured questions (Claude-style) | \`AskUserQuestion\` | NOT available in Cursor — use \`AskQuestion\`. |
103
- | MCP tool call | \`CallMcpTool\` | Cursor exposes MCP tools via this wrapper; read the descriptor first. |
104
- | Jupyter notebook edit | \`EditNotebook\` | Use for \`.ipynb\` only; cell-granular edits. |
105
- | Mode switching | \`SwitchMode\` | Propose plan/agent mode changes when task character shifts. |
106
-
107
- ## Decision-protocol mapping
108
-
109
- In Cursor, structured asks look like:
110
-
111
- \`\`\`
112
- AskQuestion({
113
- questions: [{
114
- id: "...",
115
- prompt: "One-sentence decision",
116
- options: [
117
- { id: "a", label: "Option A" },
118
- { id: "b", label: "Option B" }
119
- ]
120
- }]
121
- })
122
- \`\`\`
123
-
124
- ## Escalation / fall-back
125
-
126
- On repeated tool errors, fall back to plain-text equivalents just like Claude — see the meta-skill's Error / Retry Budget.
127
- `;
128
- const OPENCODE_TOOLS_MD = `---
129
- harness: opencode
130
- name: OpenCode tool map
131
- description: "Canonical mapping of cclaw capability names → OpenCode primitives. Cited by stage skills; do not duplicate in per-stage text."
132
- ---
133
-
134
- # OpenCode — Tool Map
135
-
136
- OpenCode exposes a leaner tool surface than Claude Code / Cursor, but it DOES have a native structured-ask primitive (\`question\`) — you just have to opt into it. When a cclaw skill describes a capability that OpenCode lacks entirely, fall back to the plain-text equivalent listed below.
137
-
138
- ## Core capabilities
139
-
140
- | cclaw capability | OpenCode primitive | Notes |
141
- |---|---|---|
142
- | Ask user a structured question | \`question\` tool | Each call has a header, question text, and a list of options; users can pick an option or type a custom answer. Supports multiple questions with navigation. **Gated:** \`opencode.json\` must set \`permission.question: "allow"\`; ACP clients additionally need the \`OPENCODE_ENABLE_QUESTION_TOOL=1\` env var. If the tool is denied or unavailable, fall back to a plain-text lettered list (\`A) ... B) ... C) (recommended) ...\`). |
143
- | Dispatch a subagent | **Not available as a tool.** | Inline the work in the current turn, or split across multiple turns with the user driving. |
144
- | Read file | file-read primitive | Same role as \`Read\`. |
145
- | Edit file | file-edit primitive | Same role as \`StrReplace\`; confirm diff before writing. |
146
- | Create file | file-write primitive | Prefer editing existing files. |
147
- | Search file contents | \`rg\` via shell | Cite \`rg\` output verbatim as evidence when a skill requires a grep result. |
148
- | Find files by name / glob | \`fd\` or \`find\` via shell | Capture the command + output. |
149
- | Shell command | shell primitive | Long-running jobs require explicit background + polling — check the OpenCode docs for \`&\` semantics. |
150
- | Fetch URL | \`curl\` via shell | No markdown conversion; extract manually. |
151
- | Web search | **Not available.** | Ask the user to paste docs or provide a URL, then fetch via shell. |
152
- | Todo tracking | **Not available as a tool.** | Maintain a \`### TODO\` block inline in your response; keep one item in progress. |
153
- | MCP tool call | Depends on runtime config. | If MCP is enabled, use the documented invocation; otherwise treat as unavailable. |
154
-
155
- ## Decision-protocol mapping
156
-
157
- When the \`question\` tool is enabled, issue one call per decision:
158
-
159
- \`\`\`
160
- question({
161
- header: "<stage> decision",
162
- question: "<one-sentence decision>",
163
- options: [
164
- "A) <label> — <trade-off>",
165
- "B) <label> — <trade-off>",
166
- "C) <label> — <trade-off> (recommended, because <reason>)"
167
- ]
168
- })
169
- \`\`\`
170
-
171
- If the tool is denied or the host doesn't expose it, fall back to plain text using the same skeleton:
172
-
173
- \`\`\`
174
- Decision: <one sentence>.
175
-
176
- A) <label> — <trade-off>
177
- B) <label> — <trade-off>
178
- C) <label> — <trade-off> (recommended, because <one-line reason>)
179
-
180
- Please reply with the letter.
181
- \`\`\`
182
-
183
- ## Escalation / fall-back
184
-
185
- OpenCode has the structured-ask primitive (\`question\`) but no isolated subagent dispatch, so delegation falls back to the role-switch playbook. Flow gates and artifacts are identical; only the delivery channel changes.
186
- `;
187
- const CODEX_TOOLS_MD = `---
188
- harness: codex
189
- name: Codex tool map
190
- description: "Canonical mapping of cclaw capability names → Codex CLI primitives. Cited by stage skills; do not duplicate in per-stage text."
191
- ---
192
-
193
- # Codex — Tool Map
194
-
195
- Codex (OpenAI Codex CLI) exposes file I/O, shell, skills, and lifecycle hooks (≥ v0.114, gated by the \`codex_hooks\` feature flag). It does NOT have isolated subagent dispatch, but it DOES expose a native structured-ask tool (\`request_user_input\`) on builds with the Plan / Collaboration mode templates. Fall back to plain text only when that tool is denied or hidden.
196
-
197
- ## Core capabilities
198
-
199
- | cclaw capability | Codex primitive | Notes |
200
- |---|---|---|
201
- | Ask user a structured question | \`request_user_input\` tool | Accepts 1-3 short questions and returns the user's answers in the same order. Experimental; used by Codex's built-in Plan / Collaboration mode (see \`codex-rs/collaboration-mode-templates/templates/plan.md\`). Offer only meaningful options — filler choices are explicitly discouraged. Free-form answer strings are returned; keep the lettered options inline in the question text. Fall back to a plain-text lettered list if the tool is hidden or errors. |
202
- | Dispatch a subagent | **Not available as a tool.** | Codex has no named or generic subagent dispatch. cclaw closes the mandatory-delegation gate with the role-switch playbook (\`.cclaw/references/harnesses/codex-playbook.md\`). |
203
- | Read file | \`read\` / \`open\` primitive | Same role as \`Read\`. |
204
- | Edit file | \`edit\` / \`patch\` primitive | Same role as \`StrReplace\`. |
205
- | Create file | \`write\` primitive | Prefer editing existing files. |
206
- | Search file contents | \`rg\` via shell | Capture command + output verbatim. |
207
- | Find files by name / glob | \`fd\` / \`find\` / \`ls\` via shell | Capture command + output. |
208
- | Shell command | shell primitive | Codex CLI may restrict some binaries by default — check the effective permissions. |
209
- | Fetch URL | \`curl\` via shell | Extract markdown manually. |
210
- | Web search | **Not available.** | Ask user for docs / URL. |
211
- | Todo tracking | \`update_plan\` tool (Codex-native checklist) | \`update_plan\` is Codex's built-in progress / checklist surface and is **separate** from Plan / Collaboration mode — do not conflate them. cclaw also keeps an inline \`### TODO\` block in-turn as an audit mirror. |
212
- | MCP tool call | Depends on runtime config. | If MCP is wired, cite the descriptor; otherwise treat as unavailable. |
213
-
214
- ## Decision-protocol mapping
215
-
216
- When \`request_user_input\` is available, issue a single call with 1-3 questions:
217
-
218
- \`\`\`
219
- request_user_input({
220
- questions: [
221
- "<stage> — <one-sentence decision>. Reply A/B/C. A) <label> — <trade-off>. B) <label> — <trade-off>. C) <label> — <trade-off> (recommended, <reason>)."
222
- ]
223
- })
224
- \`\`\`
225
-
226
- Answers come back as free-form strings, not option IDs — keep the lettered options inline so the user's reply maps cleanly to the artifact decision log. When the tool is hidden (older build, non-collaboration mode), fall back to plain text with the same skeleton:
227
-
228
- \`\`\`
229
- Decision: <one sentence>.
230
-
231
- A) <label> — <trade-off>
232
- B) <label> — <trade-off> (recommended, because <reason>)
233
- C) <label> — <trade-off>
234
-
235
- Please reply with the letter.
236
- \`\`\`
237
-
238
- ## Escalation / fall-back
239
-
240
- \`request_user_input\` is the only structured-ask primitive Codex ships; dispatch still requires the role-switch playbook. Treat missing tools as "plain-text required", not "skip the step". The gate still has to pass; only the channel changes.
241
- `;
242
- const HARNESS_TOOL_REFS = {
243
- claude: CLAUDE_TOOLS_MD,
244
- cursor: CURSOR_TOOLS_MD,
245
- opencode: OPENCODE_TOOLS_MD,
246
- codex: CODEX_TOOLS_MD
247
- };
248
- export function harnessToolRefMarkdown(harness) {
249
- return HARNESS_TOOL_REFS[harness];
250
- }
251
- export const HARNESS_TOOL_REFS_INDEX_MD = `---
252
- name: Harness tool maps
253
- description: "Index file. One reference per supported harness — cite the per-harness file instead of hardcoding tool names in stage skills."
254
- ---
255
-
256
- # Harness Tool Maps
257
-
258
- cclaw 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.
259
-
260
- | Harness | File | Notes |
261
- |---|---|---|
262
- | Claude Code | \`.cclaw/${HARNESS_TOOL_REFS_DIR}/claude.md\` | Richest tool surface (AskUserQuestion, Task, WebFetch, WebSearch, MCP, …). |
263
- | Cursor | \`.cclaw/${HARNESS_TOOL_REFS_DIR}/cursor.md\` | Near-parity with Claude; uses \`AskQuestion\` instead of \`AskUserQuestion\`. |
264
- | OpenCode | \`.cclaw/${HARNESS_TOOL_REFS_DIR}/opencode.md\` | Native \`question\` tool (permission-gated) for structured asks; no isolated subagent dispatch. |
265
- | Codex | \`.cclaw/${HARNESS_TOOL_REFS_DIR}/codex.md\` | Native \`request_user_input\` tool (experimental, Plan / Collaboration mode) for structured asks; no subagent dispatch. |
266
-
267
- When a new harness is added or an existing one renames a tool, update the corresponding file (and this index) — do NOT scatter tool names across skill text.
268
- `;
@@ -1,2 +0,0 @@
1
- export declare function opsCommandContract(): string;
2
- export declare function opsCommandSkillMarkdown(): string;
@@ -1,71 +0,0 @@
1
- import { RUNTIME_ROOT } from "../constants.js";
2
- const OPS_SKILL_FOLDER = "flow-ops";
3
- const OPS_SKILL_NAME = "flow-ops";
4
- export function opsCommandContract() {
5
- return `# /cc-ops
6
-
7
- ## Purpose
8
-
9
- Unified operational command surface for non-stage flow actions.
10
-
11
- Subcommands:
12
- - \`feature\` -> \`/cc-ops feature\`
13
- - \`tdd-log\` -> \`/cc-ops tdd-log\`
14
- - \`retro\` -> \`/cc-ops retro\`
15
- - \`compound\` -> \`/cc-ops compound\`
16
- - \`archive\` -> \`/cc-ops archive\`
17
- - \`rewind\` -> \`/cc-ops rewind\`
18
-
19
- ## HARD-GATE
20
-
21
- - \`/cc-ops\` is a routing wrapper; execute only one target subcommand per call.
22
- - Preserve target command safety contracts (retro gate, archive gate, rewind atomicity, etc.).
23
-
24
- ## Routing
25
-
26
- 1. Parse required subcommand token.
27
- 2. Dispatch:
28
- - \`feature\` -> \`${RUNTIME_ROOT}/commands/feature.md\`
29
- - \`tdd-log\` -> \`${RUNTIME_ROOT}/commands/tdd-log.md\`
30
- - \`retro\` -> \`${RUNTIME_ROOT}/commands/retro.md\`
31
- - \`compound\` -> \`${RUNTIME_ROOT}/commands/compound.md\`
32
- - \`archive\` -> \`${RUNTIME_ROOT}/commands/archive.md\`
33
- - \`rewind\` -> \`${RUNTIME_ROOT}/commands/rewind.md\`
34
- 3. Unknown subcommand -> print supported values and stop.
35
-
36
- ## Headless mode
37
-
38
- For skill-to-skill dispatch, emit exactly one JSON envelope:
39
-
40
- \`\`\`json
41
- {"version":"1","kind":"stage-output","stage":"ship","payload":{"command":"/cc-ops","subcommand":"archive","status":"completed"},"emittedAt":"<ISO-8601>"}
42
- \`\`\`
43
-
44
- Validate envelopes with:
45
- \`cclaw internal envelope-validate --stdin\`
46
-
47
- ## Primary skill
48
-
49
- **${RUNTIME_ROOT}/skills/${OPS_SKILL_FOLDER}/SKILL.md**
50
- `;
51
- }
52
- export function opsCommandSkillMarkdown() {
53
- return `---
54
- name: ${OPS_SKILL_NAME}
55
- description: "Unified operational router for feature/tdd-log/retro/compound/archive/rewind commands."
56
- ---
57
-
58
- # /cc-ops
59
-
60
- ## HARD-GATE
61
-
62
- This wrapper only dispatches. It must not apply state mutations itself.
63
-
64
- ## Protocol
65
-
66
- 1. Require a subcommand (\`feature|tdd-log|retro|compound|archive|rewind\`).
67
- 2. Route to the matching command contract + skill pair.
68
- 3. Preserve pass-through args after the subcommand (e.g. \`/cc-ops rewind design\`).
69
- 4. Echo which subcommand was dispatched for auditability.
70
- `;
71
- }
@@ -1,7 +0,0 @@
1
- export declare const PROTOCOLS_REL_DIR = ".cclaw/references/protocols";
2
- export declare const DECISION_PROTOCOL_REL_PATH = ".cclaw/references/protocols/decision.md";
3
- export declare const COMPLETION_PROTOCOL_REL_PATH = ".cclaw/references/protocols/completion.md";
4
- export declare const ETHOS_PROTOCOL_REL_PATH = ".cclaw/references/protocols/ethos.md";
5
- export declare function decisionProtocolMarkdown(): string;
6
- export declare function completionProtocolMarkdown(): string;
7
- export declare function ethosProtocolMarkdown(): string;
@@ -1,215 +0,0 @@
1
- import { RUNTIME_ROOT } from "../constants.js";
2
- export const PROTOCOLS_REL_DIR = `${RUNTIME_ROOT}/references/protocols`;
3
- export const DECISION_PROTOCOL_REL_PATH = `${PROTOCOLS_REL_DIR}/decision.md`;
4
- export const COMPLETION_PROTOCOL_REL_PATH = `${PROTOCOLS_REL_DIR}/completion.md`;
5
- export const ETHOS_PROTOCOL_REL_PATH = `${PROTOCOLS_REL_DIR}/ethos.md`;
6
- export function decisionProtocolMarkdown() {
7
- return `# Decision Protocol
8
-
9
- Shared format for decisions that require user confirmation.
10
-
11
- ## Core sequence
12
-
13
- 1. State the decision in one sentence.
14
- 2. Provide 2-4 labeled options (A, B, C...).
15
- 3. Mark one option as **recommended** with a short rationale.
16
- 4. Use the harness's structured-ask tool when available:
17
- - Claude: \`AskUserQuestion\` (up to ~4 options × multi-question).
18
- - Cursor: \`AskQuestion\` (≥2 options, multi-question, optional \`allow_multiple\`).
19
- - OpenCode: \`question\` tool (options + "type custom" fallback).
20
- Requires \`permission.question: "allow"\` in \`opencode.json\`; ACP
21
- clients additionally need \`OPENCODE_ENABLE_QUESTION_TOOL=1\`.
22
- - Codex: \`request_user_input\` (1-3 short questions; experimental,
23
- surfaced in Plan / Collaboration mode).
24
- - Fallback (any harness where the native tool is hidden, denied, or
25
- returns a schema error): a numbered / lettered plain-text list
26
- keeping the same Re-ground / Simplify / RECOMMENDATION / Options
27
- skeleton described below.
28
- 5. Wait for user choice before proceeding.
29
-
30
- ## Decision skeleton
31
-
32
- Every Decision Protocol call — regardless of harness — follows this
33
- four-part skeleton. Do not skip a part; if a part is trivially empty,
34
- say so explicitly (e.g. "Re-ground: same branch, same task as prior
35
- turn").
36
-
37
- 1. **Re-ground (1-2 sentences).** State the project, the active
38
- feature slug, the active stage (from \`flow-state.json\`), and the
39
- decision's plain-English context. Pull these values from the source
40
- of truth, not from conversation memory.
41
- 2. **Simplify (2-4 sentences).** Explain the choice in plain English a
42
- smart 16-year-old could follow. No internal jargon, no raw function
43
- names, no implementation trivia. Say what each option DOES and
44
- what changes for the user.
45
- 3. **Recommend.** One line of the form
46
- \`RECOMMENDATION: Choose [Letter] because [one-line reason]\`.
47
- Always prefer the more complete option unless an explicit constraint
48
- says otherwise (see Completeness calibration below). Never present
49
- options as equivalent when they are not.
50
- 4. **Options.** Lettered options \`A) ... B) ... C) ...\`. Each option
51
- includes one-line \`Completeness: X/10\` plus, when effort differs
52
- noticeably, a \`(human: ~Xh / agent: ~Ym)\` estimate.
53
-
54
- ## Completeness calibration
55
-
56
- Use the same 1-10 scale for every option so comparisons stay honest:
57
-
58
- - **10** = complete implementation: all stated edges handled,
59
- traceable to spec, no known deferred work.
60
- - **7** = covers the happy path; one or two non-critical edges
61
- deferred with an explicit follow-up.
62
- - **5** = partial; either drops edge cases silently or hands off
63
- required work to a future run.
64
- - **3** = shortcut; skips spec criteria, violates an Iron Law, or
65
- defers significant work without tracking.
66
- - **1** = acknowledged placeholder (\`TBD\`, \`TODO\`, "static for now").
67
-
68
- Calibration rules:
69
-
70
- - Mark any option at \`Completeness: ≤5\` and require the user to
71
- acknowledge the gap before picking it.
72
- - If two options are both \`≥8\`, recommend the higher one.
73
- - "Static for now" / "we will add later" phrasing always scores \`≤3\`
74
- and must be surfaced in Simplify, not buried in an option label.
75
-
76
- ## Ask format
77
-
78
- - One question per call.
79
- - Option labels are short and unambiguous; the full reasoning lives in
80
- Simplify + per-option Completeness.
81
- - If tool schema fails once, fall back to plain text immediately but
82
- keep the skeleton (Re-ground / Simplify / RECOMMENDATION / lettered
83
- Options with Completeness scores).
84
- - Log the chosen letter into the stage artifact's decision log with
85
- the Completeness score; do not rely on chat history.
86
-
87
- ## Retry and escalation
88
-
89
- - Same tool fails twice -> stop using that tool in this interaction.
90
- - Three tool failures in one stage -> pause and surface blocker to user.
91
- - Same technical approach fails three times -> escalate with evidence and ask for direction.
92
- `;
93
- }
94
- export function completionProtocolMarkdown() {
95
- return `# Stage Completion Protocol
96
-
97
- Shared closeout sequence applied by every stage skill.
98
-
99
- ## Required order
100
-
101
- 1. Verify mandatory delegations are completed or explicitly waived.
102
- 2. Persist stage artifact under \`.cclaw/artifacts/\`.
103
- 3. Use the canonical helper:
104
- - \`node .cclaw/hooks/stage-complete.mjs <stage>\`
105
- - helper responsibilities: validate mandatory delegations, validate
106
- current-stage gate evidence/artifact lint, update
107
- \`stageGateCatalog\` + \`guardEvidence\`, and advance \`currentStage\`.
108
- 4. Run \`npx cclaw doctor\` and resolve failures.
109
- 5. **Capture through-flow learnings** — see the policy below. Knowledge
110
- accrues continuously across stages, not just at retro.
111
- 6. Notify user with stage completion and next action (\`/cc-next\`).
112
- 7. Stop; do not auto-run the next stage unless user asks.
113
-
114
- ## Through-flow knowledge capture
115
-
116
- Knowledge is recorded **throughout the run**, not saved up for retro.
117
- Each stage contributes a different kind of insight:
118
-
119
- | Stage | Typical \`type\` | What to capture |
120
- |-------------|-----------------|-------------------------------------------------------|
121
- | brainstorm | \`lesson\` | rejected framings and why (only when non-obvious) |
122
- | scope | \`rule\` | explicit out-of-scope boundaries worth remembering |
123
- | design | \`pattern\` | architectural trade-offs and their rationale |
124
- | spec | \`rule\` | non-negotiable acceptance criteria shape |
125
- | plan | \`pattern\` | effective decomposition / risk-ordering heuristics |
126
- | tdd | \`pattern\` | red→green→refactor cycle lessons, test-design notes |
127
- | review | \`lesson\` | recurring defects / blockers caught in this codebase |
128
- | ship | \`lesson\` | rollback triggers, preflight gotchas |
129
- | retro | \`compound\` | process accelerators for the **next** run |
130
-
131
- Rules:
132
-
133
- - Append 1–3 strict-schema JSONL lines to \`.cclaw/knowledge.jsonl\` per
134
- stage when that stage produced non-obvious decisions, patterns, or
135
- lessons. Obvious restatements of the checklist do not count.
136
- - Use \`type=rule|pattern|lesson\` during stages; reserve \`type=compound\`
137
- for the retro step so the retro vs. through-flow signal stays
138
- distinguishable.
139
- - Set \`origin_stage\` to the stage that emitted the entry and
140
- \`origin_feature\` to the active feature slug.
141
-
142
- ## Automatic learning capture policy
143
-
144
- - \`standard\` / \`medium\` tracks: required for \`design\`, \`tdd\`, and \`review\`;
145
- recommended for other stages.
146
- - \`quick\` track: recommended only (avoid overhead for tiny fixes).
147
- - "No learning captured" is acceptable only when explicitly justified (e.g. pure
148
- mechanical change, no new trade-offs). Record the justification in the
149
- stage artifact, not in knowledge.jsonl.
150
-
151
- ## Resume protocol
152
-
153
- On resume, if artifact exists but not all gates are passed:
154
-
155
- 1. Reconcile already-proven gates from artifact evidence.
156
- 2. Confirm unresolved gates with the user one at a time.
157
- 3. Update \`guardEvidence\` for each confirmed gate.
158
- `;
159
- }
160
- export function ethosProtocolMarkdown() {
161
- return `# Engineering Ethos
162
-
163
- Shared operating principles across all stages.
164
-
165
- ## 1) Boil the Lake
166
-
167
- When the "complete version" costs only slightly more than a shortcut, prefer the
168
- complete version. Do not leave obvious quality gaps for hypothetical follow-ups.
169
-
170
- ## 2) Search Before Building
171
-
172
- Before adding new code/templates/rules:
173
-
174
- 1. Search existing artifacts/docs.
175
- 2. Search existing knowledge entries.
176
- 3. Search codebase for reusable implementations.
177
- 4. Prefer built-in/library primitives over custom helpers.
178
-
179
- ## 3) User Sovereignty
180
-
181
- AI recommends. User decides. If your recommendation changes the user's stated
182
- direction, ask first and wait for explicit approval.
183
-
184
- ## 4) Iron-Law Discipline
185
-
186
- Every stage has a non-negotiable Iron Law. If a proposed action violates it,
187
- stop and escalate via Decision Protocol instead of rationalizing exceptions.
188
-
189
- ## 5) Complete Before Ship
190
-
191
- No release shortcuts:
192
- - review verdict must be explicit,
193
- - preflight evidence must be fresh,
194
- - rollback must be written before finalization.
195
-
196
- ## 6) Compound, Don't Repeat
197
-
198
- Knowledge is recorded **throughout** the run, not saved for the retro.
199
- When a reusable lesson appears in design, plan, tdd, or review, append one
200
- strict-schema JSONL entry to \`.cclaw/knowledge.jsonl\` using
201
- \`type=rule|pattern|lesson\`. Reserve \`type=compound\` for post-ship retro.
202
- Repeated lessons (frequency ≥ 3) are lifted into stable
203
- rules/protocols/skills during the automatic compound pass so the same
204
- class of mistake gets harder to repeat.
205
-
206
- ## Turn Announce Discipline
207
-
208
- Keep orchestration visible without maintaining a dedicated preamble runtime log.
209
-
210
- - Start substantial turns with a 1-2 sentence announce: current stage, intent, next action.
211
- - Skip announce for trivial single-command actions.
212
- - Never repeat boilerplate announces when the intent did not change.
213
- - If plan or risk changes materially, post a fresh announce before executing.
214
- `;
215
- }
@@ -1,2 +0,0 @@
1
- export declare function retroCommandContract(): string;
2
- export declare function retroCommandSkillMarkdown(): string;