The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
feat: implement generic permission prompt parser and add support for multiple agent engines
0xken1558edef583720
diff --git a/cli/src/engines/README.md b/cli/src/engines/README.mdindex f8f232c75..82908cecb 100644--- a/cli/src/engines/README.md+++ b/cli/src/engines/README.md@@ -280,6 +280,57 @@ than broken — which is the right failure mode, and why they are last.|---|---|| `engines/<name>/runtimeProfile.ts` + `lib/runtimeProfile.ts` | The model and effort pickers. Some agents expose neither: Amp has no model list at all, only four agent *modes*, so the mode is reported as the model and the effort axis stays `auto`. Note the engine name also lives inside `PROFILE_RE` — miss it there and the picker vanishes with no error || `engines/<name>/askQuestion.ts` + `lib/askQuestion.ts` + `lib/__fixtures__/question-<name>.txt` | Your agent's questions as answerable cards on the device and the web, instead of text in the tool feed. It need not be a question *tool*: Amp has none, and the only thing it blocks a person on is its approval prompt — whose rows are unnumbered, so they are walked with `Down` and committed with `Enter` rather than by pressing a digit |+| `lib/__fixtures__/permission-<name>.txt` | The same card for your agent's **permission prompt**, which matters more than the question does — see below |++### Permission prompts++Harness does not launch your agent and supplies it no permission flags, so an approval prompt is the+pane's ordinary state, not an edge case. Left unparsed it is invisible: the turn sits at `Processing`+until someone walks to the computer. So an approval is modelled as a question whose options are the+approval choices, and it rides the same `commander_question` / `question_response` round trip — no new+frame, and the firmware's existing question screen renders it unchanged.++Most engines need **no parser**. `parsePermissionPane` in `lib/askQuestion.ts` reads any dialog that ends+in numbered rows under a line of key hints, identifying it by the rows rather than the prose: an approval+always offers a way to say yes and a way to say no. Claude, Command Code, codex, hermes and muse are all+read that way, and opencode's prompt is the horizontal one kilo inherited from it. Write a parser only+when your agent's rows are shaped differently — devin's carry no dot after the number, grok's sit in `(●)`+markers, cursor's are unnumbered and print their own key — and put it beside the question parser in+`engines/<name>/askQuestion.ts`. If your agent already+has a question parser, remember the permission prompt is usually a DIFFERENT dialog: muse needs+`parseMuseQuestionPane(capture) ?? parseQuestionPane(capture)` because only the first of those two+recognises its questions and only the second recognises its approvals.++Two rules that came out of measuring nine of these:++- **Never drop the row that declines.** A device user given three ways to approve and none to refuse+ cannot answer the prompt at all.+- **Drop rows that open a text editor** (`Edit command`, `Describe change to command`) — the device+ cannot type into them. This is not cosmetic: the firmware shows `OPT_MAX` = 6 options and truncates+ the rest silently, so on devin's seven-row prompt the row that falls off the end is `No`.++And do not conclude "this agent never asks" from one probe. Muse was filed that way after a single+sandboxed file write it simply *denied*; its approval is on by default and appears the moment the call is+one the sandbox allows but policy gates — network egress, in the end. Check the agent's own flags first:+something like `--yolo`, `--approval-mode` or `--dangerously-skip-permissions` existing at all is proof+there is a prompt to skip. Only pi has none — no such flag, no permission key in its settings, and+`curl`, a file write and a plain `rm` all run unprompted.++**Do not wire up the startup trust dialog.** Six engines open with some form of "do you trust this+directory?" (pi, devin, muse, cursor, codex, commandcode). It is not this feature: harness does not launch+the engine, so the person already answered it at their own keyboard, and the watcher only polls a pane+once the session is registered — which is later. Surfacing it would be dead code.++To capture the fixture: start your agent in tmux under its own config, ask it to run+`curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin`, and while the prompt is up run+`tmux capture-pane -p -e -t <pane> -S -80 > src/lib/__fixtures__/permission-<name>.txt`. Keep `-e`: the+existing fixtures carry their SGR codes because that is what `captureTmuxPane` returns. Then press the+digit and watch what happens. There are three mechanisms in the tree already, so check which one you+have: a digit that selects **and** submits (claude, commandcode, codex, muse, hermes, devin, grok), an+unnumbered list walked with arrows (amp, kilo, opencode), or unnumbered rows that each print their own+key (cursor — `(y)`, `(tab)`, `(shift+tab)`, `(esc or n)`, carried in `number` so `rowKeys` presses it).+And probe more than one kind of action before deciding your agent has only one prompt: claude gates the+command *and* the edit, cursor gates only the command.| `lib/summarize.ts` | The end-of-turn recap. Note the pooling rule: agents that take their recap prompt as argv rather than stdin cannot be pre-warmed, so they opt out of the worker pool. Pick the cheapest setting your agent has for it — this is the one call Harness makes on its own, on every turn || `lib/goalCommand.ts` | `/goal` and `/loop` support || `cli.ts` | Wire the normalizer into the watcher — the last connection that makes it live |diff --git a/cli/src/engines/amp/askQuestion.ts b/cli/src/engines/amp/askQuestion.tsindex 504448800..b36af8621 100644--- a/cli/src/engines/amp/askQuestion.ts+++ b/cli/src/engines/amp/askQuestion.ts@@ -110,6 +110,7 @@ export function parseAmpQuestionPane(capture: string): PaneView {number: String(index),label,checked: false,+ walk: 'down' as const,}))// What is being approved. The tool is the line ending in `:` above the JSON; the argument preview isdiff --git a/cli/src/engines/cursor/askQuestion.ts b/cli/src/engines/cursor/askQuestion.tsnew file mode 100644index 000000000..c435da899--- /dev/null+++ b/cli/src/engines/cursor/askQuestion.ts@@ -0,0 +1,123 @@+/**+ * Cursor's permission prompt — the only dialog cursor ever blocks a person on.+ *+ * It ships no ask-the-user tool at all (asked to use one, cursor answers that no MCP server provides it),+ * so unlike every other engine this file has no question parser to sit beside. Captured live from+ * cursor-agent 2026.08.11 (`__fixtures__/permission-cursor.txt`):+ *+ * ────────────────────────────────────────────────+ * $ curl -s https://example.com in . ← the command, and the directory it runs in+ *+ * Run this command?+ * Not in allowlist: curl ← why it is asking+ * → Run (once) (y)+ * Add Shell(curl) to allowlist? (tab)+ * Run Everything (shift+tab)+ * Skip & tell the agent what to do instead (esc or n)+ *+ * What makes cursor its own parser is the third selection mechanism in this codebase. Claude numbers its+ * rows and a digit submits; amp and kilo number nothing and are walked with arrows; cursor numbers+ * nothing either but **every row states its own key in a trailing parenthesis**. So the key is read off+ * the row and carried in `number`, which is exactly what `rowKeys` presses — no walk, no digit, no engine+ * branch in the driver.+ *+ * Two details worth stating, because both are choices rather than transcriptions:+ *+ * - `(esc or n)` becomes **`n`**, never `Escape`. Esc is also the pane's own cancel and on a busy+ * cursor pane it does more than decline the prompt; the letter only ever answers this dialog.+ * - `Run Everything` is KEPT, even though it disables approvals for the rest of the session. It is+ * cursor's own wording for the same escape hatch claude spells "don't ask again" and amp spells+ * "Allow All for Every Session", and hiding one engine's version of a row the others all offer would+ * be a silent behaviour difference, not a safety feature. Tapping it stays the person's decision.+ *+ * There is no footer under the rows — the pane simply ends at the last option, the way Command Code's+ * dialog does — so the frame's opening rule is the anchor at both ends.+ *+ * One fixture covers cursor because cursor has exactly one gate. Probed on a live pane: editing a file in+ * the workspace, and even writing one OUTSIDE it (`/private/tmp/…`), both run unprompted once the+ * workspace is trusted. Only a shell command absent from the allowlist stops for a person — so unlike+ * claude, there is no second `Edit file` shape waiting to be missed.+ */++import type { PaneView, QuestionRow } from '../../lib/askQuestion.js'++/** The row's own key hint, always the LAST parenthesis on the line. `[^()]` keeps `Shell(curl)` out. */+const ROW_RE = /^\s*(?:[→▶>›]\s*)?(\S.*?)\s*\(([^()]{1,14})\)\s*$/+/** The line that opens the frame. Cursor draws no box, just a rule. */+const RULE_RE = /^\s*[─━═]{6,}\s*$/+/** `Run this command?` — cursor states what it is asking before it lists the rows. */+const PROMPT_RE = /^\s*(run|apply|allow|execute|edit|delete|write)\b.*\?\s*$/i+/** Measured on this dialog: `Run (once)` approves, `Skip & tell the agent …` declines. */+const APPROVE_RE = /^(run|allow|add|yes|approve|accept|proceed|continue)\b/i+const REJECT_RE = /^(skip|no|reject|deny|decline|cancel|stop)\b/i++function stripAnsi(value: string): string {+ return value.replace(/\[[0-9;:]*[A-Za-z]/g, '')+}++/**+ * The tmux key name for one of cursor's hints, or null when the row cannot be answered by keystroke.+ *+ * Measured hints: `y`, `tab`, `shift+tab`, `esc or n`.+ */+export function cursorRowKey(hint: string): string | null {+ const h = hint.trim().toLowerCase()+ if (/^shift\s*\+\s*tab$/.test(h)) return 'BTab'+ if (/^tab$/.test(h)) return 'Tab'+ if (/^enter$/.test(h)) return 'Enter'+ // "esc or n" offers two keys for one row; take the letter, never Escape (see the docblock).+ const letter = /(?:^|\bor\s+)([a-z0-9])$/.exec(h)+ return letter ? letter[1] : null+}++export function parseCursorPermissionPane(capture: string): PaneView {+ const lines = stripAnsi(capture).replace(/ /g, ' ').split('\n')++ // The rows are the last contiguous run of key-hinted lines on the pane. Nothing follows them: cursor+ // paints no footer, so walking up from the bottom-most row is the only anchor available.+ let end = -1+ for (let i = lines.length - 1; i >= 0; i--) {+ if (ROW_RE.test(lines[i])) { end = i; break }+ }+ if (end < 0) return null++ const rows: QuestionRow[] = []+ let start = end + 1+ for (let i = end; i >= 0 && end - i < 10; i--) {+ const match = ROW_RE.exec(lines[i])+ if (!match) break+ const key = cursorRowKey(match[2])+ // A row whose hint is not a single keystroke cannot be answered from a device; drop it rather than+ // offer a choice that would do nothing.+ if (key) rows.unshift({ number: key, label: match[1].trim(), checked: false })+ start = i+ }+ if (rows.length < 2) return null+ if (!rows.some((row) => APPROVE_RE.test(row.label)) || !rows.some((row) => REJECT_RE.test(row.label))) return null++ // Above the rows: the prompt, then the frame's rule with the command just under it.+ let prompt = -1+ for (let i = start - 1; i >= 0 && start - i <= 6; i--) {+ if (PROMPT_RE.test(lines[i])) { prompt = i; break }+ }+ if (prompt < 0) return null++ let command = ''+ for (let i = prompt - 1; i >= 0 && prompt - i <= 8; i--) {+ if (!RULE_RE.test(lines[i])) continue+ for (let j = i + 1; j < prompt; j++) {+ const line = lines[j].trim().replace(/^\$\s*/, '').replace(/\s+/g, ' ')+ // `… in .` just means the workspace root; a real subdirectory is worth keeping.+ if (line) { command = line.replace(/\s+in\s+\.$/, ''); break }+ }+ break+ }++ return {+ kind: 'question',+ question: command ? `Approve ${command}` : lines[prompt].trim(),+ rows,+ multi: false,+ typeRow: null,+ }+}diff --git a/cli/src/engines/devin/askQuestion.ts b/cli/src/engines/devin/askQuestion.tsindex 7e57b590a..eec33e6c6 100644--- a/cli/src/engines/devin/askQuestion.ts+++ b/cli/src/engines/devin/askQuestion.ts@@ -84,3 +84,71 @@ export function parseDevinQuestionPane(capture: string): PaneView {if (/\(multi-select\)/i.test(question)) multi = truereturn { kind: 'question', question: question.replace(/\s*\(multi-select\)\s*$/i, '').trim(), rows, multi, typeRow: null }}++/**+ * Devin's PERMISSION prompt, which reuses the row syntax above and nothing else — no titled rule opens+ * it and its footer drops the word `navigate`, so neither anchor of the parser above can see it.+ * Captured live (`__fixtures__/permission-devin.txt`):+ *+ * ⏺ Running command+ * └ $ curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin+ *+ * ❭ 1 Yes (Approve once)+ * · 2 Yes, allow `curl` commands+ * · 3 Yes, always allow `curl` commands in `work-devin`+ * · 4 Yes, always allow `curl` commands in all projects+ * · 5 Edit command+ * · 6 Describe change to command+ * · 7 No+ * ↑↓ select · ↵ confirm · esc cancel+ *+ * Two measured properties shape this:+ *+ * - **Seven rows, and the device shows six.** `OPT_MAX` is 6 in the firmware, so a verbatim list would+ * silently drop the LAST row — which is `No`, the only way to decline. Keeping just the rows that+ * approve or reject brings it to five and puts `No` back on screen. The two dropped rows are+ * `Edit command` and `Describe change to command`, which open a text editor the device cannot type+ * into, so they were never answerable from there anyway.+ * - **A digit selects AND submits**, despite a footer advertising only arrows — verified by pressing+ * `7` on a live prompt and watching devin report `Tool execution was rejected by the user`. So these+ * rows carry no `walk` and are keyed exactly like the ask dialog's.+ *+ * Anchored on `↵ confirm`, which the ask dialog spells `↵ select` — the one word that separates the two+ * footers, and the reason this is a sibling function rather than another branch inside the parser above.+ */+const PERMISSION_FOOTER_RE = /↵\s*confirm/i+/** The command under `⏺ Running command`, minus devin's box-drawing and shell decoration. */+const COMMAND_RE = /^\s*[└├│]?\s*\$\s*(\S.*?)\s*$/+const APPROVE_RE = /^(yes|allow|approve|accept|proceed|run|continue)\b/i+const REJECT_RE = /^(no|reject|deny|decline|cancel|don'?t|stop)\b/i++export function parseDevinPermissionPane(capture: string): PaneView {+ const lines = stripAnsi(capture).replace(/ /g, ' ').split('\n')+ const footer = lines.findLastIndex((line) => PERMISSION_FOOTER_RE.test(line))+ if (footer < 0) return null++ // The rows sit directly above the footer, back to the one numbered 1.+ const rows: QuestionRow[] = []+ let start = -1+ for (let i = footer - 1; i >= 0 && footer - i <= 20; i--) {+ const match = ROW_RE.exec(lines[i])+ if (!match) continue+ const [, , number, label] = match+ if (!number) continue+ rows.unshift({ number, label: label.replace(/\s{2,}/g, ' ').trim(), checked: false })+ if (number === '1') { start = i; break }+ }+ if (start < 0 || rows.length < 2) return null++ const answerable = rows.filter((row) => APPROVE_RE.test(row.label) || REJECT_RE.test(row.label))+ if (!answerable.length || !answerable.some((row) => REJECT_RE.test(row.label))) return null++ // What is being approved: the `$ …` line above the rows. Best-effort, like every other engine's — the+ // row list is what the answer actually depends on.+ let command = ''+ for (let i = start - 1; i >= 0 && start - i <= 8; i--) {+ const match = COMMAND_RE.exec(lines[i])+ if (match) { command = match[1]; break }+ }+ return { kind: 'question', question: command ? `Approve ${command}` : 'Approval required', rows: answerable, multi: false, typeRow: null }+}diff --git a/cli/src/engines/grok/askQuestion.ts b/cli/src/engines/grok/askQuestion.tsindex f55750b5f..57986b994 100644--- a/cli/src/engines/grok/askQuestion.ts+++ b/cli/src/engines/grok/askQuestion.ts@@ -16,10 +16,27 @@ function stripAnsi(value: string): string {** Descriptions share the row with labels, separated by 2+ spaces. The `z` row opens free text and must* not be offered as an option. Digits select and submit directly (verified by pressing `2`).+ *+ * Grok's PERMISSION prompt reuses this exact row syntax and only reworded the footer, so it needs a+ * second footer alternative rather than a second parser (`__fixtures__/permission-grok.txt`):+ *+ * \u2503 Fetch Bitcoin price from CoinGecko+ * \u2503 curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin+ * \u2503+ * \u2503 1 (\u25cf) Yes, and don't ask again for anything (always-approve mode)+ * \u2503 2 (\u25cb) Yes, proceed+ * \u2503 3 (\u25cb) No, reject (type to add feedback)+ *+ * 1/3:select \u2502 Tab:next option \u2502 Ctrl+o:always-approve \u2502 Ctrl+c:cancel \u2502 Esc:scrollback+ *+ * `1/3:select` is the range of digits the dialog accepts, and pressing one both selects AND submits here+ * too \u2014 verified by pressing `2` on a live prompt and watching the command run. The question line the+ * parser lands on is the COMMAND rather than grok's own one-line summary above it, which is the more+ * useful of the two on a device screen.*/export function parseGrokQuestionPane(capture: string): PaneView {const lines = stripAnsi(capture).replace(/\u00a0/g, ' ').split('\n')- const footer = lines.findLastIndex((line) => /enter\s*:\s*submit/i.test(line))+ const footer = lines.findLastIndex((line) => /enter\s*:\s*submit|\d+\/\d+\s*:\s*select/i.test(line))if (footer < 0) return nullconst rows: QuestionRow[] = []diff --git a/cli/src/engines/kilo/askQuestion.ts b/cli/src/engines/kilo/askQuestion.tsindex cd9869f03..dbef166be 100644--- a/cli/src/engines/kilo/askQuestion.ts+++ b/cli/src/engines/kilo/askQuestion.ts@@ -106,10 +106,14 @@ export function parseKiloQuestionPane(capture: string): PaneView {}if (labels.length < 2) return null+ // `walk` travels with the row because this same dialog is opencode's — kilo is its fork — and opencode+ // numbers its OTHER dialog. Without it, an opencode permission row would be answered with a digit that+ // the horizontal list does not respond to.const rows: QuestionRow[] = labels.map((label, index) => ({number: String(index),label,checked: false,+ walk: 'right' as const,}))// What is being permitted: the first content line under the title, minus the `←` bullet kilo draws ondiff --git a/cli/src/lib/__fixtures__/permission-claude-edit.txt b/cli/src/lib/__fixtures__/permission-claude-edit.txtnew file mode 100644index 000000000..9a04a9a54--- /dev/null+++ b/cli/src/lib/__fixtures__/permission-claude-edit.txt@@ -0,0 +1,51 @@+++[38;5;174m╭───[39m [38;5;174mClaude Code[39m [38;5;246mv2.1.232[39m [38;5;174m─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮+│[39m [2m[38;5;174m│[0m [1m[38;5;174mTips for getting started[0m [38;5;174m│+│[39m [1mWelcome back zon![0m [2m[38;5;174m│[0m Run /init to create a CLAUDE.md file with instructions for Claude [38;5;174m│+│[39m [2m[38;5;174m│[0m [38;5;174m───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────[39m [38;5;174m│+│[39m [38;5;174m ▐[48;5;16m▛███▜[49m▌[39m [2m[38;5;174m│[0m [1m[38;5;174mWhat's new[0m [38;5;174m│+│[39m [38;5;174m▝▜[48;5;16m█████[49m▛▘[39m [2m[38;5;174m│[0m Subagent forking is now on by default: a `subagent_type: "fork"` subagent inherits the full conversation and prompt cache, and non-teammate ag… [38;5;174m│+│[39m [38;5;174m ▘▘ ▝▝ [39m [2m[38;5;174m│[0m Type `@` in the prompt to mention another Claude session by name; Claude then uses `SendMessage` to reach that session directly [38;5;174m│+│[39m [38;5;246mSonnet 5 with xhigh effort · Claude Max · [39m [2m[38;5;174m│[0m `SendMessage` now delivers to a bare name that exactly matches one live session, instead of asking to confirm with a ref first [38;5;174m│+│[39m [38;5;[email protected]'s Organization[39m [2m[38;5;174m│[0m [3m[38;5;246m/release-notes for more[0m [38;5;174m│+│[39m [38;5;246m/…/scratchpad/permcap/work[39m [2m[38;5;174m│[0m [38;5;174m│+╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯+++[38;5;239m[48;5;237m❯ [38;5;231mRun this exact command with Bash, nothing else: curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin[39m++[49m [38;5;246mRan [1m1[0m[38;5;246m shell command [39m++[38;5;246m✻[39m [38;5;246mChurned for 1m 16s[39m++[38;5;239m[48;5;237m❯ [38;5;231mUse the Edit tool to change the word hello to world in README.md. Nothing else.[39m++[49m [38;5;246mRead [1m1[0m[38;5;246m file [39m++[38;5;246m⏺[39m [1mUpdate[0m(]8;id=ffutpc;file:///private/tmp/claude-502/-Users-example-work/00000000-0000-0000-0000-000000000000/scratchpad/permcap/work/README.md\README.md]8;;\)++[38;5;153m────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────+[39m [1m[38;5;153mEdit file[0m+ [38;5;246mREADME.md[39m+[38;5;239m╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌+[38;5;167m[48;5;52m 1 -[38;5;231mhello+[38;5;77m[48;5;22m 1 +[38;5;231mworld+[38;5;239m[49m╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌+[39m Do you want to make this edit to [1mREADME.md[0m?+ [38;5;153m❯[39m [38;5;246m1. [38;5;153mYes[39m+ [38;5;246m2. [39mYes, allow all edits during this session [1m(shift+tab)[0m+ [38;5;246m3. [39mNo++ [38;5;246mEsc to cancel · Tab to amend[39m+++++++++++diff --git a/cli/src/lib/__fixtures__/permission-claude.txt b/cli/src/lib/__fixtures__/permission-claude.txtnew file mode 100644index 000000000..21bc3e353--- /dev/null+++ b/cli/src/lib/__fixtures__/permission-claude.txt@@ -0,0 +1,51 @@+++[38;5;174m╭───[39m [38;5;174mClaude Code[39m [38;5;246mv2.1.232[39m [38;5;174m─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮+│[39m [2m[38;5;174m│[0m [1m[38;5;174mTips for getting started[0m [38;5;174m│+│[39m [1mWelcome back zon![0m [2m[38;5;174m│[0m Run /init to create a CLAUDE.md file with instructions for Claude [38;5;174m│+│[39m [2m[38;5;174m│[0m [38;5;174m───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────[39m [38;5;174m│+│[39m [38;5;174m ▐[48;5;16m▛███▜[49m▌[39m [2m[38;5;174m│[0m [1m[38;5;174mWhat's new[0m [38;5;174m│+│[39m [38;5;174m▝▜[48;5;16m█████[49m▛▘[39m [2m[38;5;174m│[0m Subagent forking is now on by default: a `subagent_type: "fork"` subagent inherits the full conversation and prompt cache, and non-teammate ag… [38;5;174m│+│[39m [38;5;174m ▘▘ ▝▝ [39m [2m[38;5;174m│[0m Type `@` in the prompt to mention another Claude session by name; Claude then uses `SendMessage` to reach that session directly [38;5;174m│+│[39m [38;5;246mSonnet 5 with xhigh effort · Claude Max · [39m [2m[38;5;174m│[0m `SendMessage` now delivers to a bare name that exactly matches one live session, instead of asking to confirm with a ref first [38;5;174m│+│[39m [38;5;[email protected]'s Organization[39m [2m[38;5;174m│[0m [3m[38;5;246m/release-notes for more[0m [38;5;174m│+│[39m [38;5;246m/…/scratchpad/permcap/work[39m [2m[38;5;174m│[0m [38;5;174m│+╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯+++[38;5;239m[48;5;237m❯ [38;5;231mRun this exact command with Bash, nothing else: curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin[39m++[38;5;246m[49m⏺[39m Fetching Bitcoin price from CoinGecko API+[38;5;246m ⎿ $ curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin[39m++[38;5;153m────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────+[39m [1m[38;5;153mBash command[0m++ curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin+ [38;5;246mFetch Bitcoin price from CoinGecko API[39m++ This command requires approval++ Do you want to proceed?+ [38;5;153m❯[39m [38;5;246m1. [38;5;153mYes[39m+ [38;5;246m2. [39mYes, and don’t ask again for: curl *+ [38;5;246m3. [39mNo++ [38;5;246mEsc to cancel · Tab to amend · ctrl+e to explain[39m+++++++++++++++++diff --git a/cli/src/lib/__fixtures__/permission-codex.txt b/cli/src/lib/__fixtures__/permission-codex.txtnew file mode 100644index 000000000..d8e36a10f--- /dev/null+++ b/cli/src/lib/__fixtures__/permission-codex.txt@@ -0,0 +1,74 @@+codex+example@mac work-codex % codex+> [1mYou are in [0m/private/tmp/claude-502/-Users-example-work/00000000-0000-0000-0000-000000000000/scratchpad/permcap/work-codex++ Do you trust the contents of this directory? Working with untrusted contents comes with higher risk of prompt injection. Trusting the directory allows project-local config, hooks, and exec policies+ to load.++[38;5;6m› 1. Yes, continue[39m+ 2. No, quit++ [2mPress enter to continue[0m++[2m╭─────────────────────────────────────────────────────────╮[0m+[2m│ >_ [0;1mOpenAI Codex[0;2m (v0.147.0) │[0m+[2m│ │[0m+[2m│ model: [3mloading[0;2m [0m[38;5;6m/model[2m[39m to change │[0m+[2m│ directory: [0m/private/tmp/claude-502/…/permcap/work-codex[2m │[0m+[2m╰─────────────────────────────────────────────────────────╯[0m+++[1m›[0m [2mExplain this codebase[0m++ [38;2;246;226;183mgpt-5.6-sol default[2m[39m · [0m[38;2;171;223;167m/private/tmp/claude-502/-Users-example-work/00000000-0000-0000-0000-000000000000/scratchpad/permcap/work-codex[39m++[2m╭─────────────────────────────────────────────────────────╮[0m+[2m│ >_ [0;1mOpenAI Codex[0;2m (v0.147.0) │[0m+[2m│ │[0m+[2m│ model: [0mgpt-5.6-sol high[2m [0m[38;5;6m/model[2m[39m to change │[0m+[2m│ directory: [0m/private/tmp/claude-502/…/permcap/work-codex[2m │[0m+[2m╰─────────────────────────────────────────────────────────╯[0m++ [1mTip:[0m [3mNew[0m Use [1m/fast[0m to enable our fastest inference with increased plan usage.+++[1;2m› [0mRun this exact command in the shell, nothing else: curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin+++[1m[38;5;1m•[0m [1mRan[0m [38;2;137;180;250mcurl[38;2;147;153;178m -[38;2;235;160;172ms[38;2;205;214;244m https://api.coingecko.com/api/v3/simple/price[38;2;148;226;213m?[38;2;205;214;244mids=bitcoin[39m+[2m └ zsh:1: no matches found: https://api.coingecko.com/api/v3/simple/price?ids=bitcoin[0m++[2m────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────++• [0mzsh:1: no matches found: ]8;;https://api.coingecko.com/api/v3/simple/price?ids=bitcoin\https://api.coingecko.com/api/v3/simple/price?ids=bitcoin]8;;\++[2m────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────+++[1m› [0mCreate the file /private/etc/harness-probe.txt containing the word hi. Use the shell.+++[2m• [0mI’ll create that exact file via the shell; writing under [38;5;6m/private/etc[39m requires your approval.++[1m[38;2;202;202;202m•[0m [1mRunning[0m [38;2;137;180;250mprintf[38;2;205;214;244m [38;2;166;227;161m'hi\n'[38;2;205;214;244m [38;2;148;226;213m>[38;2;205;214;244m /private/etc/harness-probe.txt[39m+++ [1mWould you like to run the following command?[0m++ Environment: [1mlocal[0m++ Reason: [3mAllow creating /private/etc/harness-probe.txt containing the word hi?[0m++ $ [38;2;137;180;250mprintf[38;2;205;214;244m [38;2;166;227;161m'hi\n'[38;2;205;214;244m [38;2;148;226;213m>[38;2;205;214;244m /private/etc/harness-probe.txt++[1m[38;5;6m› 1. Yes, proceed (y)[0m+ 2. Yes, and don't ask again for commands that start with `printf 'hi\n' > /private/etc/harness-probe.txt` ([2mp[0m)+ 3. No, and tell Codex what to do differently ([2mesc[0m)++ [2mPress enter to confirm or esc to cancel++++++diff --git a/cli/src/lib/__fixtures__/permission-commandcode.txt b/cli/src/lib/__fixtures__/permission-commandcode.txtnew file mode 100644index 000000000..664451702--- /dev/null+++ b/cli/src/lib/__fixtures__/permission-commandcode.txt@@ -0,0 +1,50 @@+commandcode+example@mac work-commandcode % commandcode++[38;2;43;39;88m[48;2;43;39;88m [39m[49m+[38;2;43;39;88m[48;2;43;39;88m [38;2;177;186;249m███████[38;2;43;39;88m [38;2;177;186;249m███████[38;2;43;39;88m [38;2;177;186;249m███████████[38;2;43;39;88m [38;2;177;186;249m███████████[38;2;43;39;88m [38;2;177;186;249m███████[38;2;43;39;88m [38;2;177;186;249m████████[38;2;43;39;88m [38;2;177;186;249m████[38;2;43;39;88m [39m[49m+[38;2;43;39;88m[48;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m██[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███████[38;2;43;39;88m [39m[49m+[38;2;43;39;88m[48;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m██[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███████[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [39m[49m+[38;2;43;39;88m[48;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m██[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███████[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [39m[49m+[38;2;43;39;88m[48;2;43;39;88m [38;2;177;186;249m███████[38;2;43;39;88m [38;2;177;186;249m███████[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███[38;2;43;39;88m [38;2;177;186;249m███████[38;2;43;39;88m [39m[49m+[38;2;43;39;88m[48;2;43;39;88m [39m[49m++[38;2;138;148;168m# [1m[39mCommand Code[0m[38;2;138;148;168m v1.24.0[39m+[38;2;138;148;168m# models: deepseek-v4-flash-(latest) · taste-1[39m+[38;2;138;148;168m# /private/tmp/claude-502/-Users-example-work/00000000-0000-0000-0000-000000000000/scratchpad/permcap/work-commandcode[39m++[38;2;138;148;168m◼ Ran 1 session start hook[39m++[1m[38;2;165;153;233m[48;2;45;43;85m❯[0m[48;2;45;43;85m [38;2;229;229;229mRun this exact command in the shell, nothing else: curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin[39m [49m++[38;2;228;204;255m✻ Thought for 1 second [38;2;53;61;80m[[38;2;138;148;168mctrl+o to expand[38;2;53;61;80m][39m+++[38;2;76;85;106m────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────++[1m[38;2;228;204;255mExecute Shell Command[0m+[38;2;138;148;168mCommand Code needs to execute [38;2;228;204;255mcurl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin[38;2;138;148;168m.[39m++[3m[38;2;138;148;168mPress [1m[38;2;53;61;80m[[38;2;138;148;168mctrl+e[38;2;53;61;80m][0;3m[38;2;138;148;168m to explain this command[0m++[38;2;228;204;255m❯ 1. Yes[39m+[38;2;138;148;168m [38;2;229;229;229m 2. Yes, don't ask again for this exact command in this project[39m+[38;2;138;148;168m [38;2;229;229;229m 3. No, tell Command Code what to do differently[39m++[3m[38;2;138;148;168m↑/↓ navigate · enter select · ctrl+e explain · Run [38;2;229;229;229mcmd --yolo[38;2;138;148;168m to bypass all permissions (]8;;https://commandcode.ai/docs/permissions#permission-modes\Docs ↗]8;;\)[0m++++++++++++++++diff --git a/cli/src/lib/__fixtures__/permission-cursor.txt b/cli/src/lib/__fixtures__/permission-cursor.txtnew file mode 100644index 000000000..ae298cfa7--- /dev/null+++ b/cli/src/lib/__fixtures__/permission-cursor.txt@@ -0,0 +1,50 @@+cursor-agent+example@mac work-cursorcap % cursor-agent++ [33m╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮[39m+ [33m│[39m [33m│[39m+ [33m│[39m [1m[33m⚠ [39mWorkspace Trust Required[0m [33m│[39m+ [33m│[39m [33m│[39m+ [33m│[39m Cursor Agent can execute code and access files in this directory. [33m│[39m+ [33m│[39m [33m│[39m+ [33m│[39m Do you trust the contents of this directory? [33m│[39m+ [33m│[39m [33m│[39m+ [33m│[39m [1m[36m/private/tmp/claude-502/-Users-example-work/00000000-0000-0000-0000-000000000000/scratchpad/permcap/work-cursorcap[0m [33m│[39m+ [33m│[39m [33m│[39m+ [33m│[39m [33m│[39m+ [33m│[39m [2m [a] Trust this workspace[0m [33m│[39m+ [33m│[39m [2m [q] Quit[0m [33m│[39m+ [33m│[39m [33m│[39m+ [33m│[39m [34m⏳ Trusting workspace...[39m [33m│[39m+ [33m│[39m [33m│[39m+ [33m╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯[39m+++ Cursor Agent+ [2mv2026.08.11-e8db854[0m+ [2mTip: Use /plan to plan execution and reach the right outcome faster.[0m++ [48;2;36;36;40m [49m+ [48;2;36;36;40m Run this exact command in the shell, nothing else: curl -s https://example.com [49m+ [48;2;36;36;40m [49m++ $ curl -s https://example.com [2mWaiting for approval...[0m++[38;2;167;139;250m────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────+[39m $ curl -s https://example.com [2min .[0m++ [1m[38;2;167;139;250mRun this command?[0m+ [2mNot in allowlist: curl[0m+ [38;2;167;139;250m→ [1mRun (once)[0m[38;2;167;139;250m (y)[39m+ Add Shell(curl) to allowlist? (tab)+ Run Everything (shift+tab)+ Skip & tell the agent what to do instead (esc or n)+++++++++diff --git a/cli/src/lib/__fixtures__/permission-devin.txt b/cli/src/lib/__fixtures__/permission-devin.txtnew file mode 100644index 000000000..2db7ef763--- /dev/null+++ b/cli/src/lib/__fixtures__/permission-devin.txt@@ -0,0 +1,50 @@+devin+example@mac work-devin % devin+[36m◆[39m Trust /private/tmp/claude-502/-Users-example-work/00000000-0000-0000-0000-000000000000/scratchpad/permcap/work-devin? [2mYes, trust /private/tmp/claude-502/-+Users-example-go-src-github-com-autonomous-ai-autonomous-code/00000000-0000-0000-0000-000000000000/scratchpad/permcap/work-devin[0m+⠀⣴⣾⣶⡄⠀⠀⠀⠀+⠀⠛⠿⠟⠻⣶⣾⣶⡄ Devin CLI+⠀⣤⣶⣦⣴⠿⢿⠿⠃ [38;2;124;124;124mv3000.4.16[39m+⠀⠻⢿⠿⠃⠀⠀⠀⠀+ [38;2;68;68;68m┌────────────────────────────────────────────────────────────────────────┐[39m+ [38;2;68;68;68m│[39m [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m [1m[38;2;217;70;239mWelcome to Devin CLI![0m [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m We have a few tips to help you get the most out of this tool: [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m [38;2;124;124;124m1. [39mDevin can set itself up (e.g. Skills and MCPs). Just ask! [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m [38;2;124;124;124m2. [39mConfused by all the [38;2;220;220;170m[48;2;0;43;54m/model[39m[49ms? Here are [4m[38;2;94;196;255m]8;;https://cli.devin.ai/docs/models#model-selection-tips\our tips to pick[0m[38;2;124;124;124m]8;;\ [39m [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m [38;2;124;124;124m(https://cli.devin.ai/docs/models#model-selection-tips)[39m. [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m [38;2;124;124;124m3. [39mIf you want to see what Devin is up to, Control + O and the [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m down arrow key can be useful. [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m You won't see this message again but you can talk to us at [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m [4m[38;2;94;196;255m]8;;https://x.com/cognition\x.com/cognition[0m[38;2;124;124;124m]8;;\ (https://x.com/cognition)[39m. [38;2;68;68;68m│[39m+ [38;2;68;68;68m│[39m [38;2;68;68;68m│[39m+ [38;2;68;68;68m└────────────────────────────────────────────────────────────────────────┘[39m++[38;2;124;124;124mFree plan, use /upgrade to access better models · 100% remaining (resets in 29m)[39m++[38;2;255;255;255m[48;2;43;42;0m❭[39m [38;2;255;255;255mRun this exact command in the shell, nothing else: curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin[39m++[38;2;74;222;128m[49m⏺ [39mRunning command+ [38;2;68;68;68m└[39m $ [38;2;220;220;170mcurl[39m [38;2;79;193;255m-s[39m https://api.coingecko.com/api/v3/simple/price?ids=bitcoin++[1m[38;2;94;196;255m[48;2;31;31;31m❭[0m[48;2;31;31;31m [38;2;124;124;124m1[39m [1m[38;2;94;196;255mYes[0m[48;2;31;31;31m [38;2;124;124;124m(Approve once)[39m+[38;2;124;124;124m[49m·[39m [38;2;124;124;124m2[39m Yes, allow `curl` commands+[38;2;124;124;124m·[39m [38;2;124;124;124m3[39m Yes, always allow `curl` commands in `work-devin`+[38;2;124;124;124m·[39m [38;2;124;124;124m4[39m Yes, always allow `curl` commands in all projects+[38;2;124;124;124m·[39m [38;2;124;124;124m5[39m Edit command+[38;2;124;124;124m·[39m [38;2;124;124;124m6[39m Describe change to command+[38;2;124;124;124m·[39m [38;2;124;124;124m7[39m No+[38;2;124;124;124m↑↓[39m [38;2;124;124;124mselect[39m [38;2;124;124;124m·[39m [38;2;124;124;124m↵[39m [38;2;124;124;124mconfirm[39m [38;2;124;124;124m·[39m [38;2;124;124;124mesc[39m [38;2;124;124;124mcancel[39m++++++++diff --git a/cli/src/lib/__fixtures__/permission-grok.txt b/cli/src/lib/__fixtures__/permission-grok.txtnew file mode 100644index 000000000..bd013a2bc--- /dev/null+++ b/cli/src/lib/__fixtures__/permission-grok.txt@@ -0,0 +1,50 @@+[48;2;20;20;20m+ [38;2;88;88;88m/private/tmp/claude-502/-Users-example-work/00000000-0000-0000-0000-000000000000/scratchpad/permcap/work-grok[39m [38;2;224;175;104m]8;;https://grok.com/supergrok?referrer=grok-build\[Click here to Upgrade][39m]8;;\ [38;2;223;223;223m15K / 500K[39m++ [48;2;36;36;36m [48;2;20;20;20m+ [48;2;36;36;36m [38;2;200;200;200m❯ [38;2;225;225;225mRun this exact command in the shell, nothing else: curl -s ]8;;https://api.coingecko.com/api/v3/simple/price?ids=bitcoin\https://api.coingecko.com/api/v3/simple/price?ids=bitcoin[39m]8;;\ [38;2;108;108;108m 2:31 PM[39m [48;2;20;20;20m+ [48;2;36;36;36m [48;2;20;20;20m++ [38;2;108;108;108m◆ [1muser_prompt_submit[0m[38;2;108;108;108m[48;2;20;20;20m [hooks: [2m[38;2;158;206;106m2[0m[38;2;108;108;108m[48;2;20;20;20m][39m+ [38;2;108;108;108m◆ [1mThought[0m[38;2;108;108;108m[48;2;20;20;20m for 0.1s[39m++ [38;2;200;200;200mI'll run that exact curl command now.[39m [38;2;108;108;108m 2:31 PM[39m++ [38;2;187;154;247m┃[39m [38;2;187;154;247m◆ [1m[38;2;108;108;108mRun [0m[38;2;108;108;108m[48;2;20;20;20mFetch Bitcoin price from CoinGecko[39m+++++++++++++++++++++++ [38;2;137;137;137m◆ [38;2;200;200;200mFetch Bitcoin price from CoinGecko…[38;2;108;108;108m 1m33s[39m [38;2;108;108;108m1m36s ⇣15.2k [↓][stop][39m++ [38;2;224;175;104m]8;;https://grok.com/supergrok?referrer=grok-build\[Click here to Upgrade][39m]8;;\++ [38;2;200;200;200m[48;2;36;36;36m┃[39m [48;2;20;20;20m+ [38;2;200;200;200m[48;2;36;36;36m┃[39m [1m[38;2;225;225;225mFetch Bitcoin price from CoinGecko[0m[48;2;36;36;36m [48;2;20;20;20m+ [38;2;200;200;200m[48;2;36;36;36m┃[39m [38;2;122;162;247mcurl[38;2;137;221;255m -[38;2;224;175;104ms[38;2;122;162;247m https://api.coingecko.com/api/v3/simple/price[38;2;137;221;255m?[38;2;122;162;247mids=bitcoin[39m [48;2;20;20;20m+ [38;2;200;200;200m[48;2;36;36;36m┃[39m [48;2;20;20;20m+ [38;2;200;200;200m[48;2;36;36;36m┃[39m [38;2;200;200;200m[48;2;54;54;54m1 [1m[38;2;225;225;225m(●) Yes, and don't ask again for anything (always-approve mode)[0m[48;2;54;54;54m [48;2;36;36;36m [48;2;20;20;20m+ [38;2;200;200;200m[48;2;36;36;36m┃[39m [38;2;200;200;200m2 [38;2;108;108;108m(○) [38;2;225;225;225mYes, proceed[39m [48;2;20;20;20m+ [38;2;200;200;200m[48;2;36;36;36m┃[39m [38;2;200;200;200m3 [38;2;108;108;108m(○) No, reject (type to add feedback)[39m [48;2;20;20;20m+ [38;2;200;200;200m[48;2;36;36;36m┃[39m [48;2;20;20;20m++ [1m[38;2;200;200;200m1[0m[38;2;108;108;108m[48;2;20;20;20m/[1m[38;2;200;200;200m3[0m[38;2;108;108;108m[48;2;20;20;20m:select[2m │ [0;1m[38;2;200;200;200m[48;2;20;20;20mTab[0m[38;2;108;108;108m[48;2;20;20;20m:next option[2m │ [0;1m[38;2;200;200;200m[48;2;20;20;20mCtrl+o[0m[38;2;108;108;108m[48;2;20;20;20m:always-approve[2m │ [0;1m[38;2;200;200;200m[48;2;20;20;20mCtrl+c[0m[38;2;108;108;108m[48;2;20;20;20m:cancel[2m │ [0;1m[38;2;200;200;200m[48;2;20;20;20mEsc[0m[38;2;108;108;108m[48;2;20;20;20m:scrollback [39m+diff --git a/cli/src/lib/__fixtures__/permission-hermes.txt b/cli/src/lib/__fixtures__/permission-hermes.txtnew file mode 100644index 000000000..40f899cdd--- /dev/null+++ b/cli/src/lib/__fixtures__/permission-hermes.txt@@ -0,0 +1,74 @@+hermes+example@mac work-hermes % hermes++[1m[38;2;255;215;0m██╗ ██╗███████╗██████╗ ███╗ ███╗███████╗███████╗ █████╗ ██████╗ ███████╗███╗ ██╗████████╗[0m+[1m[38;2;255;215;0m██║ ██║██╔════╝██╔══██╗████╗ ████║██╔════╝██╔════╝ ██╔══██╗██╔════╝ ██╔════╝████╗ ██║╚══██╔══╝[0m+[38;2;255;191;0m███████║█████╗ ██████╔╝██╔████╔██║█████╗ ███████╗█████╗███████║██║ ███╗█████╗ ██╔██╗ ██║ ██║[39m+[38;2;255;191;0m██╔══██║██╔══╝ ██╔══██╗██║╚██╔╝██║██╔══╝ ╚════██║╚════╝██╔══██║██║ ██║██╔══╝ ██║╚██╗██║ ██║[39m+[38;2;205;127;50m██║ ██║███████╗██║ ██║██║ ╚═╝ ██║███████╗███████║ ██║ ██║╚██████╔╝███████╗██║ ╚████║ ██║[39m+[38;2;205;127;50m╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝[39m++[38;2;205;127;50m╭──────────────────────────────────────────────────────────────────────── [1m[38;2;255;215;0mHermes Agent v0.19.0 (2026.7.20) · upstream d71033a4[0m[38;2;205;127;50m ────────────────────────────────────────────────────────────────────────╮+│[39m [1m[38;2;255;191;0mAvailable Tools[0m [38;2;205;127;50m│+│[39m [38;2;205;127;50m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⡀⠀⣀⣀⠀⢀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀[39m [2m[38;2;184;134;11mbrowser:[0m [38;2;255;248;220mbrowser_back[39m, [38;2;255;248;220mbrowser_click[39m, [2m...[0m [38;2;205;127;50m│+│[39m [38;2;205;127;50m⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣿⣿⣇⠸⣿⣿⠇⣸⣿⣿⣷⣦⣄⡀⠀⠀⠀⠀⠀⠀[39m [2m[38;2;184;134;11mclarify:[0m [38;2;255;248;220mclarify[39m [38;2;205;127;50m│+│[39m [38;2;255;191;0m⠀⢀⣠⣴⣶⠿⠋⣩⡿⣿⡿⠻⣿⡇⢠⡄⢸⣿⠟⢿⣿⢿⣍⠙⠿⣶⣦⣄⡀⠀[39m [2m[38;2;184;134;11mcode_execution:[0m [38;2;255;248;220mexecute_code[39m [38;2;205;127;50m│+│[39m [38;2;255;191;0m⠀⠀⠉⠉⠁⠶⠟⠋⠀⠉⠀⢀⣈⣁⡈⢁⣈⣁⡀⠀⠉⠀⠙⠻⠶⠈⠉⠉⠀⠀[39m [2m[38;2;184;134;11mcomputer_use:[0m [33mcomputer_use[39m [38;2;205;127;50m│+│[39m [38;2;255;215;0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⡿⠛⢁⡈⠛⢿⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀[39m [2m[38;2;184;134;11mcronjob:[0m [38;2;255;248;220mcronjob[39m [38;2;205;127;50m│+│[39m [38;2;255;215;0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠿⣿⣦⣤⣈⠁⢠⣴⣿⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀[39m [2m[38;2;184;134;11mdelegation:[0m [38;2;255;248;220mdelegate_task[39m [38;2;205;127;50m│+│[39m [38;2;255;191;0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠻⢿⣿⣦⡉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀[39m [2m[38;2;184;134;11mfile:[0m [38;2;255;248;220mpatch[39m, [38;2;255;248;220mread_file[39m, [38;2;255;248;220msearch_files[39m, [38;2;255;248;220mwrite_file[39m [38;2;205;127;50m│+│[39m [38;2;255;191;0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢷⣦⣈⠛⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀[39m [2m[38;2;184;134;11mimage_gen:[0m [33mimage_generate[39m [38;2;205;127;50m│+│[39m [38;2;205;127;50m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣴⠦⠈⠙⠿⣦⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀[39m [2m[38;2;184;134;11m(and 9 more toolsets...)[0m [38;2;205;127;50m│+│[39m [38;2;205;127;50m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⣤⡈⠁⢤⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀[39m [38;2;205;127;50m│+│[39m [38;2;184;134;11m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠷⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀[39m [1m[38;2;255;191;0mAvailable Skills[0m [38;2;205;127;50m│+│[39m [38;2;184;134;11m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⠑⢶⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀[39m [2m[38;2;184;134;11mapple:[0m [38;2;255;248;220mapple-notes, apple-reminders, findmy, imessage[39m [38;2;205;127;50m│+│[39m [38;2;184;134;11m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠁⢰⡆⠈⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀[39m [2m[38;2;184;134;11mautonomous-ai-agents:[0m [38;2;255;248;220mclaude-code, codex, computer-use, hermes-agent, opencode[39m [38;2;205;127;50m│+│[39m [38;2;184;134;11m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠳⠈⣡⠞⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀[39m [2m[38;2;184;134;11mcreative:[0m [38;2;255;248;220marchitecture-diagram, ascii-art, ascii-video, baoyu-infographic, claude-design, [39m [38;2;205;127;50m│+│[39m [38;2;184;134;11m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀[39m [38;2;255;248;220mcomfyui, +10 more[39m [38;2;205;127;50m│+│[39m [2m[38;2;184;134;11memail:[0m [38;2;255;248;220mhimalaya[39m [38;2;205;127;50m│+│[39m [38;2;255;191;0mauto[39m [2m[38;2;184;134;11m·[0m [2m[38;2;184;134;11mNous Research[0m [2m[38;2;184;134;11mgeneral:[0m [38;2;255;248;220mgrid-chart, grid-host, grid-research, grid-serve, grid-web, vietnamese-fx-rates[39m [38;2;205;127;50m│+│[39m [2m[38;2;184;134;11m/private/tmp/claude-502/-Users-example-work/763aa3…[0m [2m[38;2;184;134;11mgithub:[0m [38;2;255;248;220mcodebase-inspection, github-auth, github-code-review, github-issues, github-pr-workflow, [39m [38;2;205;127;50m│+│[39m [2m[38;2;139;134;130mSession: 20260814_143002_ca7d86[0m [38;2;255;248;220m+1 more[39m [38;2;205;127;50m│+│[39m [2m[38;2;184;134;11mmedia:[0m [38;2;255;248;220mgif-search, songsee, youtube-content[39m [38;2;205;127;50m│+│[39m [2m[38;2;184;134;11mmlops:[0m [38;2;255;248;220mevaluating-llms-harness, huggingface-hub, llama-cpp, serving-llms-vllm, weights-and-biases[39m [38;2;205;127;50m│+│[39m [2m[38;2;184;134;11mnote-taking:[0m [38;2;255;248;220mobsidian[39m [38;2;205;127;50m│+│[39m [2m[38;2;184;134;11mproductivity:[0m [38;2;255;248;220mairtable, docx, google-workspace, maps, nano-pdf, notion, ocr-and-documents, pdf, [39m [38;2;205;127;50m│+│[39m [38;2;255;248;220m+3 more[39m [38;2;205;127;50m│+│[39m [2m[38;2;184;134;11mresearch:[0m [38;2;255;248;220marxiv, blogwatcher, llm-wiki, polymarket, research-paper-writing[39m [38;2;205;127;50m│+│[39m [2m[38;2;184;134;11msmart-home:[0m [38;2;255;248;220mopenhue[39m [38;2;205;127;50m│+│[39m [2m[38;2;184;134;11msocial-media:[0m [38;2;255;248;220mxurl[39m [38;2;205;127;50m│+│[39m [2m[38;2;184;134;11msoftware-development:[0m [38;2;255;248;220mdogfood, hermes-agent-skill-authoring, node-inspect-debugger, plan, +6 more[39m [38;2;205;127;50m│+│[39m [38;2;205;127;50m│+│[39m [2m[38;2;184;134;11m28 tools · 75 skills · /help for commands[0m [38;2;205;127;50m│+│[39m [1m[33m⚠ 1 commit behind[0;2m[33m — run [1mhermes update[0;2m[33m to update[0m [38;2;205;127;50m│+╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯++[38;2;255;248;220mWelcome to Hermes Agent! Type your message or /help for commands.[39m+[2m[38;2;184;134;11m✦ Tip: The terminal tool supports [1m6[0;2m[38;2;184;134;11m backends: local, Docker, SSH, Modal, Daytona, and Singularity.[0m+++[38;5;214m────────────────────────────────────────[39m+[1m[38;5;214m●[0m [1mRun this exact command in the shell, nothing else: curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin[0m+[2;3mInitializing agent...[0m++[38;5;214m────────────────────────────────────────[39m+[38;5;173m╭──────────────────────────────────────────────────────────────────╮[39m+[38;5;173m│ [1m[38;5;214m⚠️ Dangerous Command [0m[38;5;173m │[39m+[38;5;173m│ │[39m+[38;5;173m│ [3m[38;5;136mcurl -s [0m[38;5;173m │[39m+[38;5;173m│ [3m[38;5;136mhttps://api.coingecko.com/api/v3/simple/price?ids=bitcoin [0m[38;5;173m │[39m+[38;5;173m│ │[39m+[38;5;173m│ [1m[38;5;220m❯ 1. Allow once [0m[38;5;173m │[39m+[38;5;173m│ [38;5;136m 2. Allow for this session [38;5;173m │[39m+[38;5;173m│ [38;5;136m 3. Deny [38;5;173m │[39m+[38;5;173m│ │[39m+[38;5;173m│ [1m[38;5;230mSecurity scan — [MEDIUM] Python package from non-PyPI source: [0m[38;5;173m │[39m+[38;5;173m│ [1m[38;5;230mPackage URL points to 'api.coingecko.com' instead of PyPI [0m[38;5;173m │[39m+[38;5;173m╰──────────────────────────────────────────────────────────────────╯[39m++[3m[38;5;136m 💻 curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin (01m30s · ↓ 82 tok)[0m+[3m[38;5;136m ↑/↓ to select, Enter to confirm[0m[38;5;173m (212s)[39m+[38;5;250m[48;5;234m ⚕ [1m[38;5;220mauto[0m[38;5;101m[48;5;234m │ 18.5K/256K │ [1m[38;5;108m[█░░░░░░░░░][0m[38;5;101m[48;5;234m [1m[38;5;108m7%[0m[38;5;101m[48;5;234m │ 3m │ ⏱ 1m 37s[38;5;250m [39m[49m+[38;5;173m────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────+[3m[38;5;136m⚠ ❯ [0m+[38;5;173m────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────diff --git a/cli/src/lib/__fixtures__/permission-muse.txt b/cli/src/lib/__fixtures__/permission-muse.txtnew file mode 100644index 000000000..44b1f54cf--- /dev/null+++ b/cli/src/lib/__fixtures__/permission-muse.txt@@ -0,0 +1,50 @@+muse --approval-mode untrusted+example@mac work-muse2 % muse --approval-mode untrusted+[38;2;103;108;116m [39m+[38;2;103;108;116m [1m[38;2;204;211;219mMuse Code[0m[38;2;204;211;219m 0.1.0[39m++[38;2;103;108;116m [38;2;138;144;152mModel set to [38;2;138;190;183mmuse-spark-1.2-contributor[39m+[38;2;103;108;116m ⎿ [38;2;138;144;152mDiscounted tokens: your content may be used for product improvement.[39m++[38;2;90;160;255m[48;2;38;56;84m⟩ [38;2;204;211;219mRun this exact command in the shell, nothing else: curl -s https://example.com[39m+[49m+[38;2;255;225;74m◆ [1m[38;2;204;211;219mBackgrounded[0m[38;2;204;211;219m [38;2;90;160;255m· Run curl to example.com[38;2;103;108;116m · 13s[2m · ctrl+o[0m++[38;2;103;108;116m [38;2;138;144;152m(↓ to view terminals)[39m++[1m[38;2;204;211;219m◆ [0m[38;2;204;211;219mCommand executed. Output will be returned when available.[39m++[38;2;103;108;116m◇ Call[38;2;118;123;131mi[38;2;154;160;168mn[38;2;189;196;204mg[38;2;204;211;219m [38;2;189;196;204mt[38;2;154;160;168mo[38;2;118;123;131mo[38;2;103;108;116mls (21s · esc to interrupt)[39m++[2m[38;2;103;108;116m── [0m[38;2;138;144;152mVoice input (⌥ + v to start)[2m[38;2;103;108;116m ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────+[0;1m[38;2;204;211;219mWould you like to allow this network access?[0m++[38;2;103;108;116m [38;2;138;144;152mnetwork: example.com:443 https[39m+[38;2;103;108;116m requested by:[39m+[38;2;90;160;255m $ [38;2;129;162;190mcurl[38;2;125;126;127m -[38;2;137;161;181ms[38;2;129;162;190m https://example.com[39m++[1m[38;2;90;160;255m› [0m[38;2;103;108;116m1. [1m[38;2;204;211;219mYes, proceed[0m[38;2;138;144;152m (y)[39m+[38;2;103;108;116m 2. [38;2;166;227;161mYes, don't ask again this session[38;2;103;108;116m (p) [38;2;138;144;152mexample.com:443 (https)[39m+[38;2;103;108;116m 3. [38;2;243;139;168mNo, and tell Muse Code what to do differently[38;2;103;108;116m (esc)[39m+[38;2;103;108;116m Press enter to confirm or esc to cancel[39m+[2m[38;2;103;108;116m────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────+[0;1m[38;2;90;160;255mmain[0m[38;2;103;108;116m · ↓ to select[39m+[38;2;103;108;116m└ [38;2;138;144;152m⠼ curl -s https://example.com running 13s+[38;2;103;108;116m [38;2;90;160;255mmuse-spark-1.2-contributor[38;2;138;144;152m · [38;2;90;160;255mmedium[38;2;138;144;152m · /private/tmp/claude-502/-Users-example-work/00000000-0000-0000-0000-000000000000/scratchpad/permcap/work-muse2[39m+++++++++++++++++diff --git a/cli/src/lib/__fixtures__/permission-opencode.txt b/cli/src/lib/__fixtures__/permission-opencode.txtnew file mode 100644index 000000000..777507d15--- /dev/null+++ b/cli/src/lib/__fixtures__/permission-opencode.txt@@ -0,0 +1,50 @@+[38;2;255;255;255m[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;92;156;245m┃[38;2;255;255;255m[48;2;20;20;20m [48;2;10;10;10m [48;2;20;20;20m [1m[38;2;238;238;238mFetch Bitcoin price from CoinGecko[0m[38;2;255;255;255m[48;2;20;20;20m+[48;2;10;10;10m [38;2;92;156;245m┃[38;2;255;255;255m[48;2;20;20;20m [38;2;238;238;238mRun this exact command in the shell, nothing else: curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;92;156;245m┃[38;2;255;255;255m[48;2;20;20;20m [48;2;10;10;10m [48;2;20;20;20m [1m[38;2;238;238;238mContext[0m[38;2;255;255;255m[48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m [38;2;128;128;128m8,776 tokens[38;2;255;255;255m+[48;2;10;10;10m [38;2;245;167;66m+ Thought: 117ms[38;2;255;255;255m [48;2;20;20;20m [38;2;128;128;128m2% used[38;2;255;255;255m+[48;2;10;10;10m [48;2;20;20;20m [38;2;128;128;128m$0.00 spent[38;2;255;255;255m+[48;2;10;10;10m [38;2;10;10;10m[48;2;20;20;20m┃[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;10;10;10m[48;2;20;20;20m┃[38;2;255;255;255m [38;2;238;238;238m$ curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m [1m[38;2;238;238;238mLSP[0m[38;2;255;255;255m[48;2;20;20;20m+[48;2;10;10;10m [38;2;10;10;10m[48;2;20;20;20m┃[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m [38;2;128;128;128mLSPs are disabled[38;2;255;255;255m+[48;2;10;10;10m [38;2;10;10;10m[48;2;20;20;20m┃[38;2;255;255;255m [38;2;238;238;238mzsh:1: no matches found: https://api.coingecko.com/api/v3/simple/price?ids=bitcoin[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;10;10;10m[48;2;20;20;20m┃[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;245;167;66m+ Thought: 100ms[38;2;255;255;255m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;238;238;238mThe command failed: zsh interpreted the [38;2;127;216;143m?[38;2;238;238;238m in the URL as a glob pattern. Wrap the URL in quotes or escape it:[38;2;255;255;255m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;238;238;238mcurl -s "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin"[38;2;255;255;255m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;92;156;245m▣ [38;2;255;255;255m [38;2;238;238;238mBuild[38;2;128;128;128m · MiniMax M3 (vibe) · 4.2s[38;2;255;255;255m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;92;156;245m┃[38;2;255;255;255m[48;2;20;20;20m [48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;92;156;245m┃[38;2;255;255;255m[48;2;20;20;20m [38;2;238;238;238mRead the file /private/etc/hosts and show me its first line.[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;92;156;245m┃[38;2;255;255;255m[48;2;20;20;20m [48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;245;167;66m+ Thought: 569ms[38;2;255;255;255m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;245;167;66m⠹[38;2;255;255;255m [38;2;245;167;66mRead /private/etc/hosts [limit=1][38;2;255;255;255m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;92;156;245m▣ [38;2;255;255;255m [38;2;238;238;238mBuild[38;2;128;128;128m · MiniMax M3 (vibe)[38;2;255;255;255m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;245;167;66m[48;2;20;20;20m┃[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;245;167;66m[48;2;20;20;20m┃[38;2;255;255;255m [38;2;245;167;66m△[38;2;255;255;255m [38;2;238;238;238mPermission required[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;245;167;66m[48;2;20;20;20m┃[38;2;255;255;255m [38;2;128;128;128m←[38;2;255;255;255m [38;2;238;238;238mAccess external directory /private/etc[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;245;167;66m[48;2;20;20;20m┃[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;245;167;66m[48;2;20;20;20m┃[38;2;255;255;255m [38;2;128;128;128mPatterns[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m [38;2;128;128;128m/private/tmp/claude-502/-Users-[38;2;255;255;255m+[48;2;10;10;10m [38;2;245;167;66m[48;2;20;20;20m┃[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m [38;2;128;128;128mexample-go-src-github-com-autonomous-[38;2;255;255;255m+[48;2;10;10;10m [38;2;245;167;66m[48;2;20;20;20m┃[38;2;255;255;255m [38;2;238;238;238m- /private/etc/*[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m [38;2;128;128;128mai-autonomous-code/00000000-0000-0000-[38;2;255;255;255m+[48;2;10;10;10m [38;2;245;167;66m[48;2;20;20;20m┃[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m [38;2;128;128;128maff2-411a82689b17/scratchpad/permcap/[38;2;255;255;255m+[48;2;10;10;10m [38;2;245;167;66m[48;2;20;20;20m┃[38;2;255;255;255m[48;2;30;30;30m [48;2;10;10;10m [48;2;20;20;20m [38;2;238;238;238mwork-opencode[38;2;255;255;255m+[48;2;10;10;10m [38;2;245;167;66m[48;2;20;20;20m┃[38;2;255;255;255m[48;2;30;30;30m [48;2;245;167;66m [38;2;10;10;10mAllow once[38;2;255;255;255m [48;2;30;30;30m [38;2;128;128;128mAllow always[38;2;255;255;255m [38;2;128;128;128mReject[38;2;255;255;255m [38;2;238;238;238mctrl+f [38;2;128;128;128mfullscreen[38;2;255;255;255m [38;2;238;238;238m⇆ [38;2;128;128;128mselect[38;2;255;255;255m [38;2;238;238;238menter [38;2;128;128;128mconfirm[38;2;255;255;255m [48;2;10;10;10m [48;2;20;20;20m+[48;2;10;10;10m [38;2;245;167;66m[48;2;20;20;20m┃[38;2;255;255;255m[48;2;30;30;30m [48;2;10;10;10m [48;2;20;20;20m [38;2;127;216;143m•[38;2;128;128;128m [1mOpen[38;2;238;238;238mCode[0m[38;2;128;128;128m[48;2;20;20;20m 1.18.18[38;2;255;255;255m+[48;2;10;10;10m [48;2;20;20;20mdiff --git a/cli/src/lib/askQuestion.spec.ts b/cli/src/lib/askQuestion.spec.tsindex a0699bfac..c2ee3b515 100644--- a/cli/src/lib/askQuestion.spec.ts+++ b/cli/src/lib/askQuestion.spec.ts@@ -160,12 +160,12 @@ interface Machine {controller: AskQuestionController}-function machine(captures: string[]): Machine {+function machine(captures: string[], engine?: string): Machine {const keys: string[] = []const texts: string[] = []let i = 0const controller = new AskQuestionController({- getSession: () => ({ sessionId: 's1', tmuxPane: '%1' } as RegisteredSession),+ getSession: () => ({ sessionId: 's1', tmuxPane: '%1', ...(engine ? { engine } : {}) } as RegisteredSession),capture: async () => captures[Math.min(i++, captures.length - 1)],sendText: async (_pane, text) => { texts.push(text); return true },sendKey: async (_pane, key) => { keys.push(key); return true },@@ -405,3 +405,215 @@ describe('the Command Code review screen', () => {expect(view?.kind).not.toBe('question')})})++/**+ * Permission prompts — the reason this whole bridge matters on a remote machine.+ *+ * The CLI attaches to an agent the USER started, under the user's own config and with no permission flag+ * of ours, so a blocking approval is the pane's normal state rather than an edge case. Every fixture below+ * is a real `tmux capture-pane -e` of a live prompt, triggered by asking the engine to run a curl (or, for+ * opencode, to read outside its workspace) — never hand-written, per `engines/README.md`'s one rule.+ *+ * Four engines needed nothing: codex and hermes already fall out of the shared parser (their footers are+ * its anchor), opencode's is kilo's horizontal prompt, and amp/kilo shipped theirs earlier. Muse and pi+ * are absent because they have no such prompt at all — both sandbox the shell and refuse outright rather+ * than ask (measured: muse answers "the shell is sandboxed to the workspace", pi reports the denial and+ * offers alternatives). Cursor is absent because its free-request limit blocked a capture, and a parser+ * written without one would be exactly the silent failure the one rule exists to prevent.+ */+const permission = (name: string): string =>+ readFileSync(join(__dirname, '__fixtures__', `permission-${name}.txt`), 'utf8')++describe('permission prompts, per engine', () => {+ const cases: Array<{ engine: string; fixture: string; question: string; rows: string[] }> = [+ {+ engine: 'claude', fixture: 'claude',+ question: 'Approve Bash command: curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin',+ // Note the TYPOGRAPHIC apostrophe: Claude writes "don’t", not "don't".+ rows: ['Yes', 'Yes, and don’t ask again for: curl *', 'No'],+ },+ {+ engine: 'claude', fixture: 'claude-edit',+ question: 'Approve Edit file: README.md',+ rows: ['Yes', 'Yes, allow all edits during this session (shift+tab)', 'No'],+ },+ {+ engine: 'commandcode', fixture: 'commandcode',+ question: 'Approve Execute Shell Command: Command Code needs to execute curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin.',+ rows: ['Yes', "Yes, don't ask again for this exact command in this project", 'No, tell Command Code what to do differently'],+ },+ {+ engine: 'codex', fixture: 'codex',+ question: "$ printf 'hi\\n' > /private/etc/harness-probe.txt",+ rows: [+ 'Yes, proceed (y)',+ "Yes, and don't ask again for commands that start with `printf 'hi\\n' > /private/etc/harness-probe.txt` (p)",+ 'No, and tell Codex what to do differently (esc)',+ ],+ },+ {+ engine: 'devin', fixture: 'devin',+ question: 'Approve curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin',+ rows: ['Yes (Approve once)', 'Yes, allow `curl` commands', 'Yes, always allow `curl` commands in `work-devin`', 'Yes, always allow `curl` commands in all projects', 'No'],+ },+ {+ engine: 'grok', fixture: 'grok',+ question: 'curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin',+ rows: ["Yes, and don't ask again for anything (always-approve mode)", 'Yes, proceed', 'No, reject (type to add feedback)'],+ },+ {+ // Muse gates the NETWORK, not the command: its prompt names the host, and it only appears at all+ // because `--approval-mode` defaults to `on-request`. A first sweep that only tried a sandboxed+ // file write concluded muse never asks — it does.+ engine: 'muse', fixture: 'muse',+ question: '$ curl -s https://example.com',+ rows: ['Yes, proceed (y)', "Yes, don't ask again this session (p) example.com:443 (https)", 'No, and tell Muse Code what to do differently (esc)'],+ },+ {+ engine: 'hermes', fixture: 'hermes',+ question: 'https://api.coingecko.com/api/v3/simple/price?ids=bitcoin',+ rows: ['Allow once', 'Allow for this session', 'Deny'],+ },+ {+ // Cursor is the third selection mechanism: it numbers nothing and walks nothing — each row states+ // its own key, so `number` carries `y` / `Tab` / `BTab` / `n` instead of a digit or an index.+ engine: 'cursor', fixture: 'cursor',+ question: 'Approve curl -s https://example.com',+ rows: ['Run (once)', 'Add Shell(curl) to allowlist?', 'Run Everything', 'Skip & tell the agent what to do instead'],+ },+ {+ engine: 'opencode', fixture: 'opencode',+ question: 'Access external directory /private/etc',+ rows: ['Allow once', 'Allow always', 'Reject'],+ },+ ]++ for (const c of cases) {+ describe(`${c.engine} (${c.fixture})`, () => {+ const view = (): QuestionView => asQuestion(parseEngineQuestionPane(c.engine as never, permission(c.fixture)))++ it('reads the prompt and every option off the pane', () => {+ expect(view().question).toBe(c.question)+ expect(view().rows.map((row) => row.label)).toEqual(c.rows)+ })++ it('keeps a way to say no', () => {+ // Amp's rule, and the reason its "Reject with feedback" row survives: a device user offered three+ // ways to approve and none to decline cannot answer the prompt at all. The word varies more than+ // it looks — cursor says "Skip", hermes says "Deny" — which is why the shared REJECT_RE lists all+ // of them rather than assuming "no".+ expect(view().rows.some((row) => /^(no|reject|deny|skip|cancel)\b/i.test(row.label))).toBe(true)+ })++ it('is single-select with nothing to type into', () => {+ // The device answers a question by TAPPING (ui_screens.c) and an approval has no free-text row,+ // so a typeRow here would offer a choice the device can never make.+ expect(view().multi).toBe(false)+ expect(view().typeRow).toBeNull()+ })++ it('fits the device screen', () => {+ // Firmware caps: Q_MAX 4 questions, OPT_MAX 6 options. Overflow is dropped SILENTLY, and the row+ // that would fall off the end is the last one — which on devin is "No".+ expect(view().rows.length).toBeLessThanOrEqual(6)+ })+ })+ }+})++describe('permission prompts vs the ask dialog', () => {+ // Both anchors can be on one capture, because a pane keeps its scrollback. Whichever sits LOWER is the+ // live dialog; getting this backwards shows the user a prompt they already answered, or answers the+ // wrong dialog with the digit meant for the other.+ it('takes the permission prompt when it is below an answered question', () => {+ const view = asQuestion(parseQuestionPane(fixture('single') + permission('claude')))+ expect(view.rows.map((r) => r.label)).toEqual(['Yes', 'Yes, and don’t ask again for: curl *', 'No'])+ })++ it('takes the question when IT is the lower of the two', () => {+ const view = asQuestion(parseQuestionPane(permission('claude') + fixture('single')))+ expect(view.question).toBe('Which drink would you like?')+ expect(view.rows.map((r) => r.label)).toEqual(['Tea', 'Coffee'])+ })++ it('does not read an ordinary numbered list as an approval', () => {+ // The rows are what identify a permission prompt — a list that offers no way to decline is prose.+ const prose = [+ 'Here is the plan:',+ ' 1. Yes we should refactor the parser',+ ' 2. Then update the fixtures',+ '',+ 'Esc to cancel',+ ].join('\n')+ expect(parseQuestionPane(prose)).toBeNull()+ })++ it('does not read a numbered block with no key hints under it as an approval', () => {+ const orphan = [' 1. Yes', ' 2. No', '', '', '', '', '', ''].join('\n')+ expect(parseQuestionPane(orphan)).toBeNull()+ })+})++describe('answering a permission prompt from the device', () => {+ it('presses the digit that declines, on an engine whose rows are numbered', () => {+ // Verified on a live claude pane: one digit selects AND submits, so no Enter follows it.+ const h = machine([permission('claude'), CLOSED])+ const answers = { 'Approve Bash command: curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin': 'No' }+ return h.controller.answer({ requestId: 'r1', sessionId: 's1', answers }).then((ok) => {+ expect(ok).toBe(true)+ expect(h.keys).toEqual(['3'])+ })+ })++ it('presses devin\'s real row number, not its position in the shortened list', () => {+ // Devin's "No" is row 7 of 7; two unanswerable editor rows are dropped from what the device shows, so+ // the label→digit mapping must survive that filter.+ const h = machine([permission('devin'), CLOSED], 'devin')+ return h.controller.answer({ requestId: 'r1', sessionId: 's1', answers: { 'Approve curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin': 'No' } }).then((ok) => {+ expect(ok).toBe(true)+ expect(h.keys).toEqual(['7'])+ })+ })++ it('walks to the row on opencode, whose permission prompt numbers nothing', () => {+ // opencode draws BOTH a numbered ask dialog and kilo's horizontal prompt, so the direction travels on+ // the ROW. Keying "2" here would select nothing at all.+ const h = machine([permission('opencode'), CLOSED], 'opencode')+ return h.controller.answer({ requestId: 'r1', sessionId: 's1', answers: { 'Access external directory /private/etc': 'Reject' } }).then((ok) => {+ expect(ok).toBe(true)+ expect(h.keys).toEqual(['Right', 'Right', 'Enter'])+ })+ })++ it('matches an option the device truncated to its 80-byte buffer', () => {+ const h = machine([permission('codex'), CLOSED], 'codex')+ const truncated = "Yes, and don't ask again for commands that start with `printf 'hi\\n' > /priva"+ return h.controller.answer({ requestId: 'r1', sessionId: 's1', answers: { "$ printf 'hi\\n' > /private/etc/harness-probe.txt": truncated } }).then((ok) => {+ expect(ok).toBe(true)+ expect(h.keys).toEqual(['2'])+ })+ })+})++describe('QuestionWatcher on a permission prompt', () => {+ it('announces it exactly like a question, so the firmware renders it unchanged', async () => {+ const seen: Array<{ requestId: string; questions: Array<{ key: string; q: string; options: string[]; multi: boolean }> }> = []+ const w = new QuestionWatcher({+ getSession: () => ({ sessionId: 's1', tmuxPane: '%1', engine: 'claude' } as RegisteredSession),+ capture: async () => permission('claude'),+ hasDevice: () => true,+ onQuestion: (_s, requestId, questions) => { seen.push({ requestId, questions }) },+ })+ const tick = (): Promise<void> => (w as unknown as { tick: (s: string) => Promise<void> }).tick('s1')+ await tick()+ expect(seen).toHaveLength(1)+ expect(seen[0].questions[0]).toMatchObject({+ q: 'Approve Bash command: curl -s https://api.coingecko.com/api/v3/simple/price?ids=bitcoin',+ options: ['Yes', 'Yes, and don’t ask again for: curl *', 'No'],+ multi: false,+ })+ // Same prompt still on screen ⇒ announced once, not every 1.5s tick.+ await tick()+ expect(seen).toHaveLength(1)+ })+})diff --git a/cli/src/lib/askQuestion.ts b/cli/src/lib/askQuestion.tsindex cc6d67a02..f939654f3 100644--- a/cli/src/lib/askQuestion.ts+++ b/cli/src/lib/askQuestion.ts@@ -26,7 +26,8 @@ import type { AgentEngine } from '../engines/types.js'import { parseMuseQuestionPane } from '../engines/muse/askQuestion.js'import { ampSelectionKeys, parseAmpQuestionPane } from '../engines/amp/askQuestion.js'import { kiloSelectionKeys, parseKiloQuestionPane } from '../engines/kilo/askQuestion.js'-import { parseDevinQuestionPane } from '../engines/devin/askQuestion.js'+import { parseCursorPermissionPane } from '../engines/cursor/askQuestion.js'+import { parseDevinPermissionPane, parseDevinQuestionPane } from '../engines/devin/askQuestion.js'import { parseGrokQuestionPane } from '../engines/grok/askQuestion.js'/** Device-facing question shape — byte-for-byte the hosted runtime’s `commanderQuestions()` output. */@@ -43,6 +44,15 @@ export interface QuestionRow {/** Option text with any `[ ]` checkbox prefix removed. */label: stringchecked: boolean+ /**+ * Set only when the dialog does NOT number its rows: the row is then reached by walking to it and+ * pressing Enter, and `number` carries its INDEX rather than a key.+ *+ * The direction is a property of the DIALOG, not of the engine. OpenCode draws BOTH a numbered ask+ * dialog and — for permissions — the horizontal prompt kilo inherited from it, so keying by engine+ * would send digits into a dialog that numbers nothing and select nothing at all.+ */+ walk?: 'right' | 'down'}export interface QuestionView {@@ -117,10 +127,18 @@ export function shapeQuestions(questions: unknown): ShapedQuestion[] {* its own parser rather than more branches in here.*/export function parseEngineQuestionPane(engine: AgentEngine, capture: string): PaneView {- if (engine === 'devin') return parseDevinQuestionPane(capture)+ // Devin's two dialogs are told apart by one word in the footer (`↵ select` vs `↵ confirm`), so they can+ // never both match. Only one can be on screen anyway: answering either replaces it with a summary line.+ if (engine === 'devin') return parseDevinQuestionPane(capture) ?? parseDevinPermissionPane(capture)+ // Cursor has no ask-the-user tool, so its permission prompt is the ONLY dialog it ever draws — and it+ // numbers nothing, stating each row's key in the row instead.+ if (engine === 'cursor') return parseCursorPermissionPane(capture)// Muse pairs each option with a description on the same line and floats a live Preview box above the- // rows — both confuse the shared parser, so it reads its own.- if (engine === 'muse') return parseMuseQuestionPane(capture)+ // rows — both confuse the shared parser, so it reads its own. Its PERMISSION prompt is a different+ // dialog entirely (`Would you like to allow this network access?` over `1. Yes, proceed (y)` rows under+ // a `Press enter to confirm` footer, `__fixtures__/permission-muse.txt`) and that one the shared parser+ // reads exactly, so it falls through rather than getting a parser of its own.+ if (engine === 'muse') return parseMuseQuestionPane(capture) ?? parseQuestionPane(capture)// Amp's is a permission prompt with unnumbered rows — nothing the shared parser can anchor on.if (engine === 'amp') return parseAmpQuestionPane(capture)// Kilo's is the same kind of prompt but laid out HORIZONTALLY, sharing its line with the key hints —@@ -130,6 +148,13 @@ export function parseEngineQuestionPane(engine: AgentEngine, capture: string): P// Hermes and OpenCode paint Claude's dialog inside a box; peel the border and the shared parser fits.if (engine === 'hermes') return parseQuestionPane(unframe(capture))if (engine === 'opencode') {+ // OpenCode's PERMISSION prompt is the horizontal one kilo inherited from it — same `△ Permission+ // required` title, same `⇆ select · enter confirm` footer, same unnumbered rows. Measured: the live+ // capture in `permission-opencode.txt` parses through kilo's parser unchanged, so it is shared rather+ // than copied. Tried FIRST because that dialog numbers nothing: the shared parser would still match+ // its `enter confirm` footer and then walk up into whatever numbered rows the scrollback holds.+ const permission = parseKiloQuestionPane(capture)+ if (permission) return permissionconst plain = unframe(capture)return opencodeReview(plain) ?? parseQuestionPane(plain)}@@ -252,6 +277,149 @@ function parseDownward(lines: string[], tabBar: number): PaneView {}}+// \u2500\u2500 permission prompts \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500++/**+ * A permission prompt is a QUESTION whose options are the approval choices \u2014 the shape amp and kilo+ * already ship (`engines/amp/askQuestion.ts`, `engines/kilo/askQuestion.ts`). It matters far more on a+ * remote machine than a question does: the CLI attaches to an agent the USER started, under the user's+ * own config and with no permission flag of ours (`engines/README.md`), so a blocking approval is the+ * normal state of a pane, not an edge case. Unparsed, the turn simply sits at `Processing` until someone+ * walks to the computer.+ *+ * Claude and Command Code draw it as a framed block ending in numbered rows, and it carries NONE of the+ * three anchors `parseQuestionPane` knows. Captured live (`__fixtures__/permission-claude.txt`):+ *+ * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500+ * Bash command \u2190 the header: what kind of approval this is+ *+ * curl -s https://api.coingecko.com/\u2026 \u2190 the argument, then a one-line description+ * Fetch Bitcoin price from CoinGecko API+ *+ * This command requires approval+ *+ * Do you want to proceed?+ * \u276f 1. Yes+ * 2. Yes, and don\u2019t ask again for: curl *+ * 3. No+ *+ * Esc to cancel \u00b7 Tab to amend \u00b7 ctrl+e to explain+ *+ * Command Code differs only in wording (`permission-commandcode.txt`): header `Execute Shell Command`,+ * a sentence for the body, footer `\u2191/\u2193 navigate \u00b7 enter select \u00b7 ctrl+e explain`. Same frame, same rows \u2014+ * which is why one parser covers both instead of two near-copies that would drift apart.+ *+ * **The prose is not the anchor.** Every engine words it differently and Claude alone writes at least+ * three ("Do you want to proceed?", "Do you want to make this edit to README.md?", "Do you want to create+ * \u2026?"). The ROWS are: an approval always offers a way to say yes and a way to say no. That pair is the+ * signal, guarded by the dialog's own key hints so an ordinary numbered list in assistant output can never+ * be read as a prompt.+ */++/** The first row of an approval, measured across claude, commandcode, codex, devin, grok, amp and kilo. */+const APPROVE_RE = /^(yes|allow|approve|accept|proceed|run|continue)\b/i+/** \u2026and the row that declines it. Never dropped \u2014 see the rule amp's parser states: a device user given+ * three ways to say yes and none to say no cannot answer the prompt at all. */+// `skip` is here because cursor's decline row is "Skip & tell the agent what to do instead" — an engine+// whose only way to refuse says neither "no" nor "reject" would otherwise fail the yes/no guard and its+// whole prompt would go unread.+const REJECT_RE = /^(no|reject|deny|decline|cancel|skip|don'?t|stop)\b/i+/** The key hints a permission dialog prints under its rows: claude `Esc to cancel \u00b7 Tab to amend`,+ * Command Code `\u2191/\u2193 navigate \u00b7 enter select \u00b7 ctrl+e explain`. Proximity to the rows is what makes this+ * a guard and not a search \u2014 it must sit within a few lines UNDER them. */+const PERMISSION_FOOTER_RE = /\besc\b|enter\s+select|ctrl\+e/i+/** The solid rule that opens the frame. Deliberately NOT the dashed one (`\u254c`) that brackets an edit diff,+ * which sits BELOW the header and would cost the title. */+const FRAME_RULE_RE = /^\s*[\u2500\u2501\u2550]{6,}\s*$/+/** Any rule, solid or dashed \u2014 used to skip them while reading the frame's contents. */+const ANY_RULE_RE = /^\s*[\u2500\u2501\u2550\u254c\u2504\u2508-]{6,}\s*$/+/** The dialog's own question line, and Command Code's `Press [ctrl+e] \u2026` hint: both sit between the+ * header and the rows, and neither says what is being approved. */+const PERMISSION_PROSE_RE = /^((do|would) you\b|press \[)/i++/** Keep a synthesised title inside the device's `text[200]` buffer, with the tail marked as cut. */+function clipTitle(value: string): string {+ return value.length <= 160 ? value : `${value.slice(0, 159)}\u2026`+}++/**+ * What is being approved, as one line: `Approve <header>: <argument>`, the form amp's parser already+ * produces so the two read alike on the device.+ *+ * The frame's opening rule is the only reliable top \u2014 the prose under it varies per engine AND per tool.+ * Below the rule sit the header (`Bash command`, `Edit file`, `Execute Shell Command`) and then the+ * argument: the command, the file, or the sentence naming it.+ */+function permissionTitle(lines: string[], start: number): string {+ let top = -1+ for (let i = start - 1; i >= 0 && start - i <= 25; i--) {+ if (FRAME_RULE_RE.test(lines[i])) { top = i; break }+ }+ // No frame above the rows (codex draws none): the nearest text is the dialog's own question, which+ // names the command outright. Better than inventing a header that is not on screen.+ if (top < 0) {+ for (let i = start - 1; i >= 0 && start - i <= 4; i--) {+ const line = lines[i].trim()+ if (line) return clipTitle(line)+ }+ return 'Approval required'+ }+ let header = ''+ let arg = ''+ for (let i = top + 1; i < start; i++) {+ const line = lines[i].trim()+ if (!line || ANY_RULE_RE.test(line)) continue+ if (!header) { header = line; continue }+ if (PERMISSION_PROSE_RE.test(line)) continue+ arg = line+ break+ }+ if (!header) return 'Approval required'+ return clipTitle(arg ? `Approve ${header}: ${arg}` : `Approve ${header}`)+}++/**+ * The permission prompt on screen, with the index of its first row so the caller can rank it against the+ * other anchors.+ *+ * Only the LOWEST numbered block on the pane is considered, and it is rejected outright if it is not an+ * approval. Digging further up would find an answered prompt in the scrollback and re-announce it \u2014 the+ * live dialog is always the bottom-most thing on screen, so there is nothing below it to miss.+ */+export function parsePermissionPane(lines: string[]): { view: QuestionView; index: number } | null {+ let end = -1+ for (let i = lines.length - 1; i >= 0; i--) {+ if (parseRow(lines[i])) { end = i; break }+ }+ if (end < 0) return null++ // Walk up through CONTIGUOUS rows to the one numbered 1. Contiguity is the point: a permission dialog+ // never interleaves prose with its options, while assistant output that happens to be numbered does.+ const rows: QuestionRow[] = []+ let start = -1+ for (let i = end; i >= 0 && end - i < 12; i--) {+ const row = parseRow(lines[i])+ if (!row) break+ rows.unshift(row)+ if (row.number === '1') { start = i; break }+ }+ if (start < 0 || rows.length < 2) return null+ if (!APPROVE_RE.test(rows[0].label) || !rows.some((row) => REJECT_RE.test(row.label))) return null++ let hinted = false+ for (let i = end + 1; i < lines.length && i - end <= 4; i++) {+ if (PERMISSION_FOOTER_RE.test(lines[i])) { hinted = true; break }+ }+ if (!hinted) return null++ // Single-select, and no free-text row: every option here is a choice to be TAPPED. Verified on live+ // panes for claude, codex, devin and grok \u2014 one digit selects and submits, exactly as `rowKeys` assumes.+ return {+ view: { kind: 'question', question: permissionTitle(lines, start), rows, multi: false, typeRow: null },+ index: start,+ }+}+export function parseQuestionPane(capture: string): PaneView {const lines = stripAnsi(capture).replace(/\u00a0/g, ' ').split('\n')// Each CLI words its own footer, and OpenCode rewords it PER SCREEN — `enter submit` on a single@@ -261,6 +429,19 @@ export function parseQuestionPane(capture: string): PaneView {// The review screen paints no footer and puts its rows BELOW the prompt, so it needs its own anchor.// Whichever anchor is LOWER on screen is the live one (the other is scrollback from an earlier step).const review = lines.findLastIndex((l) => /Ready to submit your answers/i.test(l))+ // Command Code's review screen has neither Claude's "Ready to submit your answers" line nor a footer:+ // it is a "Submit"/"Cancel" pair under a summary that is itself numbered. Anchor on that PAIR — the two+ // rows adjacent, in that order — because the summary lines above are numbered too and reading them as+ // options is how the device answered everything and then sat there, never submitting.+ const submit = findSubmitPair(lines)+ // A permission prompt is a FOURTH anchor and gets ranked exactly like the other three: whichever sits+ // lowest on screen is the live dialog. That ordering is what keeps the two apart in both directions —+ // codex and hermes draw an approval whose footer the question anchor also matches, and there the footer+ // is BELOW the rows, so the question path (which reads a better title off the same block) still wins.+ const permission = parsePermissionPane(lines)+ if (permission && permission.index > footer && permission.index > review && permission.index > (submit?.index ?? -1)) {+ return permission.view+ }if (review > footer) {for (let i = review + 1; i < lines.length && i - review <= 10; i++) {const row = parseRow(lines[i])@@ -268,11 +449,6 @@ export function parseQuestionPane(capture: string): PaneView {}return null}- // Command Code's review screen has neither Claude's "Ready to submit your answers" line nor a footer:- // it is a "Submit"/"Cancel" pair under a summary that is itself numbered. Anchor on that PAIR — the two- // rows adjacent, in that order — because the summary lines above are numbered too and reading them as- // options is how the device answered everything and then sat there, never submitting.- const submit = findSubmitPair(lines)if (submit && submit.index > footer) return { kind: 'review', submitRow: submit.row }// Command Code paints the SAME dialog with no footer at all — the pane simply ends at the last option.// Its tab bar is the only thing above the rows that is unmistakably part of the dialog, so anchor on@@ -332,6 +508,10 @@ function rowKeys(engine: AgentEngine, row: QuestionRow): string[] {if (engine === 'amp') return ampSelectionKeys(row)// Kilo's rows sit side by side, so its walk is horizontal — see engines/kilo/askQuestion.ts.if (engine === 'kilo') return kiloSelectionKeys(row)+ // Same dialog, different engine: opencode numbers its ask dialog but not its permission prompt, so the+ // ROW says how it is reached and a per-engine rule would break one of the two.+ if (row.walk === 'right') return kiloSelectionKeys(row)+ if (row.walk === 'down') return ampSelectionKeys(row)return [row.number]}@@ -513,9 +693,13 @@ export interface QuestionWatcherDeps {}const POLL_MS = 1500-// Amp is here for its PERMISSION prompt, not a question tool — it has none. That prompt is drawn only in-// the pane and recorded nowhere, so polling the pane is the only way it is ever seen.-const QUESTION_ENGINES = new Set<AgentEngine>(['claude', 'commandcode', 'devin', 'hermes', 'opencode', 'muse', 'amp', 'kilo', 'grok'])+// Amp and codex are here for their PERMISSION prompt, not a question tool — neither has one. That prompt+// is drawn only in the pane and recorded nowhere, so polling the pane is the only way it is ever seen.+// Codex needs no parser of its own: it draws numbered rows under a `Press enter to confirm or esc to+// cancel` footer, which is the shared parser's anchor exactly (`__fixtures__/permission-codex.txt`), and+// the question it lands on is the command itself. Membership in this set is what starts the poll, so an+// engine belongs here only once something can actually read its pane.+const QUESTION_ENGINES = new Set<AgentEngine>(['claude', 'commandcode', 'codex', 'cursor', 'devin', 'hermes', 'opencode', 'muse', 'amp', 'kilo', 'grok'])/** Does this engine ever paint a question dialog? Callers use it to decide whether to watch its pane. */export function pollsQuestions(engine: AgentEngine): boolean {