cclaw-cli 0.40.0 → 0.41.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 CHANGED
@@ -359,8 +359,8 @@ closes every real gap with a documented fallback — not a silent waiver.
359
359
  |---|---|---|---|---|---|
360
360
  | Claude Code | full (named subagents) | `native` | full | `AskUserQuestion` | [`claude-playbook.md`](./src/content/harness-playbooks.ts) |
361
361
  | Cursor | generic Task dispatcher | `generic-dispatch` | full | `AskQuestion` | `cursor-playbook.md` |
362
- | OpenCode | plugin / in-session | `role-switch` | plugin | plain-text | `opencode-playbook.md` |
363
- | OpenAI Codex | in-session only | `role-switch` (evidenceRefs required) | limited (Bash-only `PreToolUse`/`PostToolUse`; requires `codex_hooks` feature flag) | plain-text | `codex-playbook.md` |
362
+ | OpenCode | plugin / in-session | `role-switch` | plugin | `question` (permission-gated; `permission.question: "allow"`) | `opencode-playbook.md` |
363
+ | OpenAI Codex | in-session only | `role-switch` (evidenceRefs required) | limited (Bash-only `PreToolUse`/`PostToolUse`; requires `codex_hooks` feature flag) | `request_user_input` (experimental; Plan / Collaboration mode) | `codex-playbook.md` |
364
364
 
365
365
  What the fallbacks mean:
366
366
 
@@ -39,8 +39,10 @@ the user can approve individual lifts, accept-all, or skip.
39
39
  "Drift check" section in the skill): confirm the lift target file is
40
40
  current, spot-check the repo for contradictions, demote stale clusters
41
41
  into a new superseding entry instead of a lift.
42
- 6. Otherwise, present **one** structured ask (AskUserQuestion / AskQuestion /
43
- plain text) summarising all candidates at once:
42
+ 6. Otherwise, present **one** structured ask via the harness's native ask
43
+ tool (\`AskUserQuestion\` / \`AskQuestion\` / \`question\` /
44
+ \`request_user_input\`; plain-text lettered list as fallback) summarising
45
+ all candidates at once:
44
46
  - \`apply-all\` (default) — apply every listed lift,
45
47
  - \`apply-selected\` — prompt per-candidate,
46
48
  - \`skip\` — record a skip reason and advance without changes.
@@ -134,7 +134,7 @@ Cursor dispatch is real isolation.
134
134
  const OPENCODE_PLAYBOOK = `---
135
135
  harness: opencode
136
136
  fallback: role-switch
137
- description: "OpenCode has plugin-based dispatch hooks but no isolated subagent worker primitive. cclaw uses an in-session role-switch with a delegation-log entry + evidenceRefs."
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
138
  ---
139
139
 
140
140
  # OpenCode — Parity Playbook
@@ -145,6 +145,22 @@ delegation gate by role-switching inside the same session: the agent
145
145
  announces the role, performs the work against the contract, and records
146
146
  evidence.
147
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
+
148
164
  ## Role-switch protocol
149
165
 
150
166
  1. Announce the role explicitly in a single message:
@@ -225,6 +241,23 @@ Codex CLI has a different shape from Claude/Cursor:
225
241
  layout is replaced by \`.agents/skills/cc*/\` and the old folders are
226
242
  auto-removed on sync. Do not restore either by hand.
227
243
 
244
+ ## Structured ask: native \`request_user_input\` tool
245
+
246
+ Codex exposes \`request_user_input\` — an experimental tool that accepts
247
+ 1-3 short questions and returns the user's answers in the same order.
248
+ It is the primitive the built-in Plan / Collaboration mode templates use
249
+ (see \`codex-rs/collaboration-mode-templates/templates/plan.md\`), and
250
+ agents running inside Codex can call it directly. Answers come back as
251
+ free-form strings, not option IDs — keep lettered options inline in the
252
+ question text so the user's reply maps cleanly to the artifact
253
+ decision log.
254
+
255
+ cclaw stage skills invoke \`request_user_input\` for every Decision
256
+ Protocol call when the tool is available, and fall back to the shared
257
+ plain-text lettered list when Codex returns a schema error or when the
258
+ current host hides the tool (older builds, non-collaboration mode). Full
259
+ mapping: \`.cclaw/references/harness-tools/codex.md\`.
260
+
228
261
  ## Fallback: role-switch
229
262
 
230
263
  Codex has no subagent dispatch — neither named nor generic. Mandatory
@@ -17,4 +17,4 @@
17
17
  import type { HarnessId } from "../types.js";
18
18
  export declare const HARNESS_TOOL_REFS_DIR = "references/harness-tools";
19
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` | No native ask-user / dispatch; more plain-text fallbacks. |\n| Codex | `.cclaw/references/harness-tools/codex.md` | No native ask-user / dispatch; shell + file I/O only by default. |\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";
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";
@@ -133,13 +133,13 @@ description: "Canonical mapping of cclaw capability names → OpenCode primitive
133
133
 
134
134
  # OpenCode — Tool Map
135
135
 
136
- OpenCode exposes a leaner tool surface than Claude Code / Cursor. When a cclaw skill describes a capability that OpenCode lacks, fall back to the plain-text equivalent listed below.
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
137
 
138
138
  ## Core capabilities
139
139
 
140
140
  | cclaw capability | OpenCode primitive | Notes |
141
141
  |---|---|---|
142
- | Ask user a structured question | **Not available as a tool.** | Emit a plain-text numbered list: \`A) ... B) ... C) (recommended) ...\`. Wait for the user's letter. |
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
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
144
  | Read file | file-read primitive | Same role as \`Read\`. |
145
145
  | Edit file | file-edit primitive | Same role as \`StrReplace\`; confirm diff before writing. |
@@ -154,6 +154,22 @@ OpenCode exposes a leaner tool surface than Claude Code / Cursor. When a cclaw s
154
154
 
155
155
  ## Decision-protocol mapping
156
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
+
157
173
  \`\`\`
158
174
  Decision: <one sentence>.
159
175
 
@@ -166,7 +182,7 @@ Please reply with the letter.
166
182
 
167
183
  ## Escalation / fall-back
168
184
 
169
- Because OpenCode lacks native ask-user and dispatch tools, more of cclaw's protocols degrade to plain text. This is expected the flow gates and artifacts are identical; only the delivery channel changes.
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.
170
186
  `;
171
187
  const CODEX_TOOLS_MD = `---
172
188
  harness: codex
@@ -176,14 +192,14 @@ description: "Canonical mapping of cclaw capability names → Codex CLI primitiv
176
192
 
177
193
  # Codex — Tool Map
178
194
 
179
- Codex (OpenAI Codex CLI) exposes roughly the same core surface as OpenCode: file I/O, shell, no native ask-user, no dispatch. Fall back to plain text for anything else.
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.
180
196
 
181
197
  ## Core capabilities
182
198
 
183
199
  | cclaw capability | Codex primitive | Notes |
184
200
  |---|---|---|
185
- | Ask user a structured question | **Not available as a tool.** | Emit a plain-text lettered list; wait for the user's reply. |
186
- | Dispatch a subagent | **Not available as a tool.** | Inline the work; split turns if needed. |
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\`). |
187
203
  | Read file | \`read\` / \`open\` primitive | Same role as \`Read\`. |
188
204
  | Edit file | \`edit\` / \`patch\` primitive | Same role as \`StrReplace\`. |
189
205
  | Create file | \`write\` primitive | Prefer editing existing files. |
@@ -192,11 +208,23 @@ Codex (OpenAI Codex CLI) exposes roughly the same core surface as OpenCode: file
192
208
  | Shell command | shell primitive | Codex CLI may restrict some binaries by default — check the effective permissions. |
193
209
  | Fetch URL | \`curl\` via shell | Extract markdown manually. |
194
210
  | Web search | **Not available.** | Ask user for docs / URL. |
195
- | Todo tracking | **Not available as a tool.** | Keep an inline \`### TODO\` section; update it as you progress. |
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. |
196
212
  | MCP tool call | Depends on runtime config. | If MCP is wired, cite the descriptor; otherwise treat as unavailable. |
197
213
 
198
214
  ## Decision-protocol mapping
199
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
+
200
228
  \`\`\`
201
229
  Decision: <one sentence>.
202
230
 
@@ -209,7 +237,7 @@ Please reply with the letter.
209
237
 
210
238
  ## Escalation / fall-back
211
239
 
212
- Treat missing tools as "plain-text required", not "skip the step". The gate still has to pass; only the channel changes.
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.
213
241
  `;
214
242
  const HARNESS_TOOL_REFS = {
215
243
  claude: CLAUDE_TOOLS_MD,
@@ -233,8 +261,8 @@ cclaw supports four harnesses; each exposes different primitive names for the sa
233
261
  |---|---|---|
234
262
  | Claude Code | \`.cclaw/${HARNESS_TOOL_REFS_DIR}/claude.md\` | Richest tool surface (AskUserQuestion, Task, WebFetch, WebSearch, MCP, …). |
235
263
  | Cursor | \`.cclaw/${HARNESS_TOOL_REFS_DIR}/cursor.md\` | Near-parity with Claude; uses \`AskQuestion\` instead of \`AskUserQuestion\`. |
236
- | OpenCode | \`.cclaw/${HARNESS_TOOL_REFS_DIR}/opencode.md\` | No native ask-user / dispatch; more plain-text fallbacks. |
237
- | Codex | \`.cclaw/${HARNESS_TOOL_REFS_DIR}/codex.md\` | No native ask-user / dispatch; shell + file I/O only by default. |
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. |
238
266
 
239
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.
240
268
  `;
@@ -13,10 +13,18 @@ Shared format for decisions that require user confirmation.
13
13
  1. State the decision in one sentence.
14
14
  2. Provide 2-4 labeled options (A, B, C...).
15
15
  3. Mark one option as **recommended** with a short rationale.
16
- 4. Use harness question tools when available:
17
- - Claude: \`AskUserQuestion\`
18
- - Cursor: \`AskQuestion\`
19
- - OpenCode/Codex: plain text options
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.
20
28
  5. Wait for user choice before proceeding.
21
29
 
22
30
  ## Decision skeleton
@@ -48,8 +48,11 @@ in the structured ask; there is no \`--skip\` flag.
48
48
  - scan \`${knowledgePath()}\` for entries recorded during this run,
49
49
  - structure the draft as: Outcomes / Slowed / Accelerated / Repeatable rule.
50
50
  4. Update \`closeout.retroDraftedAt = <ISO>\` in flow-state.
51
- 5. Present **one** structured ask (AskUserQuestion on Claude, AskQuestion on
52
- Cursor, plain-text options elsewhere):
51
+ 5. Present **one** structured ask using the harness's native tool
52
+ (\`AskUserQuestion\` on Claude, \`AskQuestion\` on Cursor, \`question\` on
53
+ OpenCode when \`permission.question: "allow"\` is set,
54
+ \`request_user_input\` on Codex in Plan / Collaboration mode; fall back
55
+ to a plain-text lettered list when the tool is hidden or errors):
53
56
  - \`accept\` (default) — keep the draft as-is,
54
57
  - \`edit\` — user edits \`${retroArtifactPath()}\` in-place, then re-runs \`/cc-next\`,
55
58
  - \`skip\` — record \`retroSkipped: true\` + one-line reason, no compound entry required.
@@ -106,8 +109,9 @@ Do not silently skip. Do not finalize without updating \`flow-state.json\`.
106
109
  - **Accelerated** — patterns/decisions that worked and are worth keeping.
107
110
  - **Repeatable rule** — one candidate rule/pattern for next run.
108
111
  Record \`closeout.retroDraftedAt\`.
109
- 3. Ask the user **one** structured question via the harness question tool
110
- (AskUserQuestion / AskQuestion / plain text fallback):
112
+ 3. Ask the user **one** structured question via the harness's native
113
+ ask tool (\`AskUserQuestion\` / \`AskQuestion\` / \`question\` /
114
+ \`request_user_input\`; plain-text lettered list as fallback):
111
115
 
112
116
  > Retro draft ready at \`${retroArtifactPath()}\`. How do you want to
113
117
  > proceed? (default: accept)
@@ -37,7 +37,7 @@ export const DESIGN = {
37
37
  interactionProtocol: [
38
38
  "Review architecture decisions section-by-section.",
39
39
  "For EACH issue found in a review section, present it ONE AT A TIME. Do NOT batch multiple issues.",
40
- "For each issue: use the Decision Protocol — describe concretely with file/line references, present labeled options (A/B/C) with trade-offs, effort estimate (S/M/L/XL), risk level (Low/Med/High), and mark one as (recommended). Do NOT use a numeric Completeness rubric; recommend the option that best covers architecture, data-flow, failure-modes, test, and perf review concerns for the issue with the lowest risk. If AskQuestion/AskUserQuestion is available, send exactly ONE question per call, validate fields against runtime schema, and on schema error immediately fall back to plain-text question instead of retrying guessed payloads.",
40
+ "For each issue: use the Decision Protocol — describe concretely with file/line references, present labeled options (A/B/C) with trade-offs, effort estimate (S/M/L/XL), risk level (Low/Med/High), and mark one as (recommended). Do NOT use a numeric Completeness rubric; recommend the option that best covers architecture, data-flow, failure-modes, test, and perf review concerns for the issue with the lowest risk. If the harness's native structured-ask tool is available (`AskUserQuestion` / `AskQuestion` / `question` / `request_user_input`), send exactly ONE question per call, validate fields against the runtime schema, and on schema error immediately fall back to a plain-text lettered list instead of retrying guessed payloads.",
41
41
  "Only proceed to the next review section after ALL issues in the current section are resolved.",
42
42
  "If a section has no issues, say 'No issues found' and move on.",
43
43
  "Do not skip failure-mode mapping.",
@@ -39,9 +39,9 @@ export const REVIEW = {
39
39
  "Run Layer 1 (spec compliance) completely before starting Layer 2.",
40
40
  "In each review section, present findings ONE AT A TIME. Do NOT batch.",
41
41
  "Classify every finding as Critical, Important, or Suggestion.",
42
- "For each Critical finding: use the Decision Protocol — present resolution options (A/B/C) with trade-offs, and mark one as (recommended). Do NOT use a numeric Completeness rubric; recommend the option that fully closes the finding with no carry-over risk and the smallest blast radius. If AskQuestion/AskUserQuestion is available, send exactly ONE question per call, validate fields against runtime schema, and on schema error immediately fall back to plain-text question instead of retrying guessed payloads.",
42
+ "For each Critical finding: use the Decision Protocol — present resolution options (A/B/C) with trade-offs, and mark one as (recommended). Do NOT use a numeric Completeness rubric; recommend the option that fully closes the finding with no carry-over risk and the smallest blast radius. If the harness's native structured-ask tool is available (`AskUserQuestion` on Claude, `AskQuestion` on Cursor, `question` on OpenCode with `permission.question: \"allow\"`, `request_user_input` on Codex in Plan/Collaboration mode), send exactly ONE question per call, validate fields against the runtime schema, and on schema error immediately fall back to a plain-text lettered list instead of retrying guessed payloads.",
43
43
  "Resolve all critical blockers before ship.",
44
- "For final verdict: use AskQuestion/AskUserQuestion only if runtime schema is confirmed; otherwise collect verdict with a plain-text single-choice prompt (APPROVED / APPROVED_WITH_CONCERNS / BLOCKED).",
44
+ "For final verdict: use the native structured-ask tool (`AskUserQuestion` / `AskQuestion` / `question` / `request_user_input`) only if runtime schema is confirmed; otherwise collect verdict with a plain-text single-choice prompt (APPROVED / APPROVED_WITH_CONCERNS / BLOCKED).",
45
45
  "**STOP.** Do NOT proceed to ship until the user provides an explicit verdict."
46
46
  ],
47
47
  process: [
@@ -32,7 +32,7 @@ export const SCOPE = {
32
32
  "**Error and Rescue Registry** — For each capability: what breaks, how detected, what fallback."
33
33
  ],
34
34
  interactionProtocol: [
35
- "For scope mode selection: use the Decision Protocol — present expand/selective/hold/reduce as labeled options with trade-offs and mark one as (recommended). Do NOT use a numeric Completeness rubric; recommend the option that best covers the prime-directive failure modes, four data-flow paths, observability, and deferred handling for the in-scope set with the smallest blast radius. Base your recommendation on default heuristics: greenfield -> expand, enhancement -> selective, bugfix/hotfix/refactor -> hold, broad blast radius -> reduce. If AskQuestion/AskUserQuestion is available, send exactly ONE question per call, validate fields against runtime schema, and on schema error immediately fall back to plain-text question instead of retrying guessed payloads.",
35
+ "For scope mode selection: use the Decision Protocol — present expand/selective/hold/reduce as labeled options with trade-offs and mark one as (recommended). Do NOT use a numeric Completeness rubric; recommend the option that best covers the prime-directive failure modes, four data-flow paths, observability, and deferred handling for the in-scope set with the smallest blast radius. Base your recommendation on default heuristics: greenfield -> expand, enhancement -> selective, bugfix/hotfix/refactor -> hold, broad blast radius -> reduce. If the harness's native structured-ask tool is available (`AskUserQuestion` / `AskQuestion` / `question` / `request_user_input`), send exactly ONE question per call, validate fields against the runtime schema, and on schema error immediately fall back to a plain-text lettered list instead of retrying guessed payloads.",
36
36
  "Walk through the scope checklist interactively. Each checklist item that surfaces a decision should be presented to the user as a question, not as a monologue. Do not dump all items at once.",
37
37
  "Challenge premise and verify the problem framing before anything else.",
38
38
  "Take a position on every scope decision. Avoid hedging phrases like 'this could work' or 'there are many ways'; state your recommendation and one concrete condition that would change it.",
@@ -35,7 +35,7 @@ export const SHIP = {
35
35
  interactionProtocol: [
36
36
  "Run preflight checks before any release action.",
37
37
  "Document release notes and rollback plan explicitly.",
38
- "For finalization mode: use the Decision Protocol — present modes as labeled options (A/B/C/D) with consequences, and mark one as (recommended). Do NOT use a numeric Completeness rubric; recommend the mode that best addresses release blast-radius, rollback readiness, observability, and stakeholder communication — ties go to the most reversible option. If AskQuestion/AskUserQuestion is available, send exactly ONE question per call, validate fields against runtime schema, and on schema error immediately fall back to plain-text question instead of retrying guessed payloads.",
38
+ "For finalization mode: use the Decision Protocol — present modes as labeled options (A/B/C/D) with consequences, and mark one as (recommended). Do NOT use a numeric Completeness rubric; recommend the mode that best addresses release blast-radius, rollback readiness, observability, and stakeholder communication — ties go to the most reversible option. If the harness's native structured-ask tool is available (`AskUserQuestion` / `AskQuestion` / `question` / `request_user_input`), send exactly ONE question per call, validate fields against the runtime schema, and on schema error immediately fall back to a plain-text lettered list instead of retrying guessed payloads.",
39
39
  "Do not proceed if critical blockers remain from review.",
40
40
  "**STOP.** Present finalization options and wait for user selection before executing any finalization action."
41
41
  ],
@@ -76,7 +76,7 @@ This is the **recommended way to start** working with cclaw. Use \`/cc-next\` fo
76
76
  7. Present the recommendation as a single decision with explicit options:
77
77
  > \`Recommended track: <quick|medium|standard>\` because \`<one-line reason citing matched triggers>\`.
78
78
  > Override? (A) keep \`<recommended>\` (B) switch track (C) cancel.
79
- If \`AskQuestion\`/\`AskUserQuestion\` is available, send exactly ONE question; on schema error, fall back to plain text.
79
+ If the harness's native ask tool is available (\`AskUserQuestion\` / \`AskQuestion\` / \`question\` / \`request_user_input\`), send exactly ONE question; on schema error, fall back to a plain-text lettered list.
80
80
  8. Persist the chosen track to \`${flowPath}\` (\`track\` field). Compute \`skippedStages\` from the track and write that too. Use the **first stage of the chosen track** as \`currentStage\` (quick → \`spec\`, medium/standard → \`brainstorm\`, trivial fast-path → \`design\` or \`spec\` per Phase 0).
81
81
  9. Write the prompt to \`.cclaw/artifacts/00-idea.md\` with the following header lines: \`Class:\` (from Phase 0), \`Track:\` (chosen track + matched heuristic), \`Stack:\` (from Phase 2 detection, or \`unknown\`), and a \`Discovered context\` section if Phase 1 found origin docs.
82
82
  10. Load the **first-stage skill for the chosen track** and its command file:
@@ -47,8 +47,8 @@ Human input remains mandatory only at explicit approval gates (plan approval, us
47
47
  |---|---|---|---|---|
48
48
  | Claude | \`native\` | Task (named subagent_type) | AskUserQuestion | \`.cclaw/references/harnesses/claude-playbook.md\` |
49
49
  | Cursor | \`generic-dispatch\` | Task (generic subagent_type: explore/generalPurpose/…) | AskQuestion | \`.cclaw/references/harnesses/cursor-playbook.md\` |
50
- | OpenCode | \`role-switch\` | plugin dispatch _or_ in-session role-switch | plain-text options | \`.cclaw/references/harnesses/opencode-playbook.md\` |
51
- | Codex | \`role-switch\` | in-session role-switch (mandatory evidenceRefs) | plain-text options | \`.cclaw/references/harnesses/codex-playbook.md\` |
50
+ | OpenCode | \`role-switch\` | plugin dispatch _or_ in-session role-switch | \`question\` (permission-gated; \`permission.question: "allow"\`) | \`.cclaw/references/harnesses/opencode-playbook.md\` |
51
+ | Codex | \`role-switch\` | in-session role-switch (mandatory evidenceRefs) | \`request_user_input\` (experimental; Plan / Collaboration mode) | \`.cclaw/references/harnesses/codex-playbook.md\` |
52
52
 
53
53
  **Dispatch rules driven by \`subagentFallback\`:**
54
54
 
@@ -58,7 +58,23 @@ export interface HarnessAdapter {
58
58
  */
59
59
  nativeSubagentDispatch: "full" | "generic" | "partial" | "none";
60
60
  hookSurface: "full" | "plugin" | "limited" | "none";
61
- structuredAsk: "AskUserQuestion" | "AskQuestion" | "plain-text";
61
+ /**
62
+ * Structured-ask primitive exposed by the harness.
63
+ *
64
+ * - `AskUserQuestion` — Claude Code native tool (≤5 options × multi-question).
65
+ * - `AskQuestion` — Cursor native tool (≥2 options, multi-question, `allow_multiple`).
66
+ * - `question` — OpenCode native tool (header + options + "type custom"
67
+ * fallback); **gated**: requires `permission.question: "allow"` in
68
+ * `opencode.json`, and for ACP clients additionally needs
69
+ * `OPENCODE_ENABLE_QUESTION_TOOL=1`.
70
+ * - `request_user_input` — Codex CLI tool (1-3 short questions); experimental
71
+ * and primarily surfaced inside Plan / Collaboration mode templates
72
+ * (`codex-rs/collaboration-mode-templates`). Available to agents running
73
+ * inside Codex but may be hidden on very old builds.
74
+ * - `plain-text` — fallback only; used when no native primitive is
75
+ * available (no shipping harness uses this in v0.41.0).
76
+ */
77
+ structuredAsk: "AskUserQuestion" | "AskQuestion" | "question" | "request_user_input" | "plain-text";
62
78
  /**
63
79
  * Declared fallback pattern used when the harness cannot satisfy a
64
80
  * mandatory delegation natively. Drives `checkMandatoryDelegations`
@@ -104,7 +104,15 @@ export const HARNESS_ADAPTERS = {
104
104
  capabilities: {
105
105
  nativeSubagentDispatch: "partial",
106
106
  hookSurface: "plugin",
107
- structuredAsk: "plain-text",
107
+ // OpenCode exposes a native `question` tool (header + options +
108
+ // custom-answer fallback, multi-question navigation). It is
109
+ // permission-gated — `opencode.json` must set
110
+ // `permission.question: "allow"` and ACP clients must export
111
+ // `OPENCODE_ENABLE_QUESTION_TOOL=1`. cclaw surfaces the tool name
112
+ // in the Decision Protocol and in the OpenCode playbook; skills
113
+ // fall back to the shared plain-text lettered list when the tool
114
+ // is denied or unavailable.
115
+ structuredAsk: "question",
108
116
  subagentFallback: "role-switch"
109
117
  }
110
118
  },
@@ -125,7 +133,15 @@ export const HARNESS_ADAPTERS = {
125
133
  capabilities: {
126
134
  nativeSubagentDispatch: "none",
127
135
  hookSurface: "limited",
128
- structuredAsk: "plain-text",
136
+ // Codex CLI exposes `request_user_input` — an experimental tool
137
+ // that asks 1-3 short questions and returns the user's answers.
138
+ // It is the primitive the built-in Plan / Collaboration mode
139
+ // templates use (see `codex-rs/collaboration-mode-templates`).
140
+ // Agents running inside Codex can call it directly; cclaw wires
141
+ // it into the Decision Protocol and the Codex playbook. The
142
+ // shared plain-text lettered list is the documented fallback
143
+ // when the tool is unavailable.
144
+ structuredAsk: "request_user_input",
129
145
  subagentFallback: "role-switch"
130
146
  }
131
147
  }
package/dist/install.js CHANGED
@@ -984,8 +984,24 @@ async function writeHarnessGapsState(projectRoot, harnesses) {
984
984
  remediation.push(`subagent dispatch → record explicit harness_limitation waiver; no parity path available`);
985
985
  break;
986
986
  }
987
- if (capabilities.structuredAsk === "plain-text") {
988
- remediation.push("structured ask fall back to a numbered plain-text list; first option is default");
987
+ // Per-harness structuredAsk remediation: record either the fallback
988
+ // requirement (plain-text) or the gating / experimental status of the
989
+ // native primitive so `cclaw doctor` and harness-gaps.json stay
990
+ // honest about *why* a primitive might silently not fire.
991
+ switch (capabilities.structuredAsk) {
992
+ case "plain-text":
993
+ remediation.push("structured ask → fall back to a numbered plain-text list; first option is default");
994
+ break;
995
+ case "question":
996
+ remediation.push(`structured ask → OpenCode \`question\` tool; enable with \`permission.question: "allow"\` in \`opencode.json\` (ACP clients additionally need \`OPENCODE_ENABLE_QUESTION_TOOL=1\`). Fallback: shared plain-text lettered list.`);
997
+ break;
998
+ case "request_user_input":
999
+ remediation.push("structured ask → Codex `request_user_input` tool (experimental; surfaced in Plan / Collaboration mode). Fallback: shared plain-text lettered list when the tool is hidden.");
1000
+ break;
1001
+ case "AskUserQuestion":
1002
+ case "AskQuestion":
1003
+ // Native first-class ask — no remediation required.
1004
+ break;
989
1005
  }
990
1006
  for (const event of missingHookEvents) {
991
1007
  remediation.push(`hook event ${event} → schedule the corresponding script manually or accept reduced observability`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cclaw-cli",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "description": "Installer-first flow toolkit for coding agents",
5
5
  "type": "module",
6
6
  "bin": {