shellpuppet 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +210 -33
  2. package/dist/cli/desktopShortcut.d.ts +22 -0
  3. package/dist/cli/desktopShortcut.js +157 -0
  4. package/dist/cli/desktopShortcut.js.map +1 -0
  5. package/dist/cli/index.js +268 -59
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/client/http.d.ts +74 -3
  8. package/dist/client/http.js +560 -37
  9. package/dist/client/http.js.map +1 -1
  10. package/dist/core/dialogs.d.ts +20 -12
  11. package/dist/core/dialogs.js +31 -19
  12. package/dist/core/dialogs.js.map +1 -1
  13. package/dist/core/manager.d.ts +35 -5
  14. package/dist/core/manager.js +121 -8
  15. package/dist/core/manager.js.map +1 -1
  16. package/dist/core/nativePty.d.ts +9 -5
  17. package/dist/core/nativePty.js +11 -6
  18. package/dist/core/nativePty.js.map +1 -1
  19. package/dist/core/promptDetector.d.ts +37 -3
  20. package/dist/core/promptDetector.js +303 -12
  21. package/dist/core/promptDetector.js.map +1 -1
  22. package/dist/core/reasoning.d.ts +19 -6
  23. package/dist/core/reasoning.js +223 -30
  24. package/dist/core/reasoning.js.map +1 -1
  25. package/dist/core/regexBudget.d.ts +20 -0
  26. package/dist/core/regexBudget.js +25 -1
  27. package/dist/core/regexBudget.js.map +1 -1
  28. package/dist/core/renderer.d.ts +16 -1
  29. package/dist/core/renderer.js +97 -6
  30. package/dist/core/renderer.js.map +1 -1
  31. package/dist/core/selection.d.ts +6 -0
  32. package/dist/core/selection.js +48 -0
  33. package/dist/core/selection.js.map +1 -0
  34. package/dist/core/session.d.ts +267 -13
  35. package/dist/core/session.js +585 -101
  36. package/dist/core/session.js.map +1 -1
  37. package/dist/core/types.d.ts +53 -18
  38. package/dist/core/types.js +30 -6
  39. package/dist/core/types.js.map +1 -1
  40. package/dist/core/waiter.d.ts +12 -4
  41. package/dist/core/waiter.js +63 -70
  42. package/dist/core/waiter.js.map +1 -1
  43. package/dist/core/windowsConsoleHost.d.ts +147 -0
  44. package/dist/core/windowsConsoleHost.js +588 -0
  45. package/dist/core/windowsConsoleHost.js.map +1 -0
  46. package/dist/core/windowsPtyStart.d.ts +100 -29
  47. package/dist/core/windowsPtyStart.js +143 -36
  48. package/dist/core/windowsPtyStart.js.map +1 -1
  49. package/dist/daemon/auth.d.ts +72 -2
  50. package/dist/daemon/auth.js +128 -3
  51. package/dist/daemon/auth.js.map +1 -1
  52. package/dist/daemon/config.d.ts +44 -1
  53. package/dist/daemon/config.js +276 -9
  54. package/dist/daemon/config.js.map +1 -1
  55. package/dist/daemon/folderPicker.d.ts +27 -0
  56. package/dist/daemon/folderPicker.js +115 -0
  57. package/dist/daemon/folderPicker.js.map +1 -0
  58. package/dist/daemon/index.js +20 -19
  59. package/dist/daemon/index.js.map +1 -1
  60. package/dist/daemon/launchProfiles.d.ts +155 -0
  61. package/dist/daemon/launchProfiles.js +554 -0
  62. package/dist/daemon/launchProfiles.js.map +1 -0
  63. package/dist/daemon/liveness.d.ts +1 -1
  64. package/dist/daemon/liveness.js +2 -2
  65. package/dist/daemon/liveness.js.map +1 -1
  66. package/dist/daemon/paths.d.ts +4 -0
  67. package/dist/daemon/paths.js.map +1 -1
  68. package/dist/daemon/restartHold.d.ts +16 -0
  69. package/dist/daemon/restartHold.js +126 -0
  70. package/dist/daemon/restartHold.js.map +1 -0
  71. package/dist/daemon/screenshot.d.ts +58 -1
  72. package/dist/daemon/screenshot.js +172 -26
  73. package/dist/daemon/screenshot.js.map +1 -1
  74. package/dist/daemon/server.d.ts +220 -10
  75. package/dist/daemon/server.js +1975 -205
  76. package/dist/daemon/server.js.map +1 -1
  77. package/dist/daemon/sessionFeed.d.ts +48 -0
  78. package/dist/daemon/sessionFeed.js +101 -0
  79. package/dist/daemon/sessionFeed.js.map +1 -0
  80. package/dist/daemon/viewerLauncher.d.ts +100 -9
  81. package/dist/daemon/viewerLauncher.js +349 -67
  82. package/dist/daemon/viewerLauncher.js.map +1 -1
  83. package/dist/mcp/config.d.ts +7 -14
  84. package/dist/mcp/config.js +10 -21
  85. package/dist/mcp/config.js.map +1 -1
  86. package/dist/mcp/index.js +20 -11
  87. package/dist/mcp/index.js.map +1 -1
  88. package/dist/mcp/tools.d.ts +14 -7
  89. package/dist/mcp/tools.js +161 -60
  90. package/dist/mcp/tools.js.map +1 -1
  91. package/dist/viewer/dashboard-folders.js +20 -0
  92. package/dist/viewer/dashboard-layout.js +52 -0
  93. package/dist/viewer/dashboard.css +67 -0
  94. package/dist/viewer/dashboard.html +44 -0
  95. package/dist/viewer/dashboard.js +1523 -0
  96. package/dist/viewer/icon.ico +0 -0
  97. package/dist/viewer/index.html +12 -7
  98. package/dist/viewer/pane.js +736 -0
  99. package/dist/viewer/viewer.css +18 -7
  100. package/dist/viewer/viewer.js +47 -624
  101. package/package.json +13 -13
@@ -3,11 +3,15 @@
3
3
  * terminal.
4
4
  *
5
5
  * npm 12 runs a dependency's install scripts only when the person installing
6
- * allows them. node-pty has prebuilt binaries for Windows and macOS but not for
7
- * Linux, where its install script builds one; without that script there is no
8
- * native module to load. On macOS the prebuilt `spawn-helper` ships without its
9
- * execute bit (microsoft/node-pty#850). npm 12 would block an install script
10
- * that restored it, and every spawn would then fail with "posix_spawnp failed".
6
+ * allows them. node-pty ships prebuilt binaries for Windows and macOS and,
7
+ * since 1.2.0-beta, for mainstream Linux; its install script builds one only
8
+ * where no prebuilt matches (another architecture, or musl in place of
9
+ * glibc). Its loader searches `build/Release`, `build/Debug` and then
10
+ * `prebuilds/<platform>-<arch>`, so an install whose script never ran still
11
+ * loads a prebuilt binary that is there. On macOS the prebuilt `spawn-helper`
12
+ * ships without its execute bit (microsoft/node-pty#850). npm 12 would block
13
+ * an install script that restored it, and every spawn would then fail with
14
+ * "posix_spawnp failed".
11
15
  *
12
16
  * So node-pty is loaded on the first start rather than when the daemon starts,
13
17
  * and the helper's execute bit is checked there. Either failure reaches the
@@ -76,7 +80,8 @@ export function explainLoadFailure(error) {
76
80
  return ("node-pty's native module is missing, or was built for another version of Node.js, " +
77
81
  'so ShellPuppet cannot open a terminal. ' +
78
82
  "npm 12 runs a dependency's install script only when you allow it; reinstall with " +
79
- `${REINSTALL} (on Linux that builds node-pty, which needs Python 3, make and a C++ compiler). (${detail})`);
83
+ `${REINSTALL} (on a machine node-pty ships no prebuilt binary for, that builds it, ` +
84
+ `which needs Python 3, make and a C++ compiler). (${detail})`);
80
85
  }
81
86
  return `node-pty could not be loaded, so ShellPuppet cannot open a terminal: ${detail}`;
82
87
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nativePty.js","sourceRoot":"","sources":["../../src/core/nativePty.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAIlC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,qDAAqD,CAAC;AAE/E,oFAAoF;AACpF,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAClD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAAsB,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,CAAY;IACtF,IAAI,MAA2B,CAAC;IAChC,OAAO,GAAG,EAAE;QACV,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,IAAI,CAAC;gBACH,MAAM,GAAG,IAAI,EAAE,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM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,CAAC;gBACD,MAAM,IAAI,yBAAyB,CACjC,mFAAmF,IAAI,KAAK;oBAC1F,kDAAkD,UAAU,CAAC,MAAM,CAAC,GAAG;oBACvE,mDAAmD,CACtD,CAAC;YACJ,CAAC;YACD,OAAO;QACT,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -28,27 +28,61 @@
28
28
  * whose `❯` and aligned lines look like a pointer chooser under a question
29
29
  * from an earlier message.
30
30
  *
31
- * A dialog drawn with its choices as one row of buttons (OpenCode, MiMo Code)
32
- * fits none of these shapes and is recognised by its signature instead
33
- * (`dialogs.ts`), which config can extend.
31
+ * A permission dialog drawn with its choices as one row of buttons
32
+ * (OpenCode, MiMo Code) is recognised by its signature (`dialogs.ts`),
33
+ * which config can extend. Their numbered question menu is recognised by
34
+ * its fixed controls and custom-answer choice here.
34
35
  */
36
+ import type { StyledLine } from './renderer.js';
37
+ /** A plain Muse heading can precede the moment its keys become active. */
38
+ export declare const MUSE_MENU_SETTLE_MS = 1500;
35
39
  export interface DetectedPrompt {
36
40
  /** Best-effort headline for the prompt (e.g. "Permission Required"). */
37
41
  question: string;
38
42
  /** The visible options, in screen order, markers stripped. */
39
43
  options: string[];
44
+ /** Index into `options` when cell styling uniquely selects one row. */
45
+ selectedOption?: number;
46
+ /** Raw screen row for each option, when options occupy separate rows. */
47
+ optionRows?: number[];
40
48
  /**
41
49
  * Stable identity for the prompt as currently drawn: the same prompt
42
50
  * redrawn (cursor blink, spinner elsewhere) keeps its signature, so a
43
51
  * stall timer can accumulate across scans without resetting.
44
52
  */
45
53
  signature: string;
54
+ /**
55
+ * The first and last raw line of the screen the prompt's own drawing
56
+ * occupies: its question when one is found, its options, and what is
57
+ * drawn between them. For Grok's older radio box, whose command is plain
58
+ * bar text above the options, the span also takes that command when a
59
+ * bare bar closes it off from the lines above. A reader that puts parts
60
+ * of a screen aside (`reasoning.ts` hides reasoning) leaves these lines
61
+ * alone: a filter must never hide a question. A wait result does not
62
+ * carry this.
63
+ */
64
+ rows: [number, number];
65
+ /**
66
+ * Why the screen was called live. `question` means the only signal was a
67
+ * question-shaped line with nothing drawn below the options. The reasoning
68
+ * filter leaves such a span unclaimed when every row of it sits inside a
69
+ * reasoning block that began above the question. A wait result does not
70
+ * carry this.
71
+ */
72
+ basis: 'marker' | 'footer' | 'question' | 'frame';
46
73
  }
47
74
  /**
48
75
  * Decide whether the screen is showing a prompt that waits on a human.
49
76
  * Returns null when the screen looks busy or shows no prompt shape.
50
77
  */
78
+ export declare const SELECTED_OPTION_MARKER = "\u27E6SP:selected\u27E7 ";
51
79
  export declare function detectPrompt(screen: string): DetectedPrompt | null;
80
+ /** Tracks the visible menu block, independently of activity above it. */
81
+ export declare class MusePromptSettler {
82
+ private menu;
83
+ private since;
84
+ detect(screen: string, now?: number, styled?: readonly StyledLine[]): DetectedPrompt | null;
85
+ }
52
86
  /**
53
87
  * Whether the prompt on screen is the one the caller has ALREADY ANSWERED.
54
88
  * A supervision loop is wait-for-prompt → answer → wait, and the second wait
@@ -28,11 +28,14 @@
28
28
  * whose `❯` and aligned lines look like a pointer chooser under a question
29
29
  * from an earlier message.
30
30
  *
31
- * A dialog drawn with its choices as one row of buttons (OpenCode, MiMo Code)
32
- * fits none of these shapes and is recognised by its signature instead
33
- * (`dialogs.ts`), which config can extend.
31
+ * A permission dialog drawn with its choices as one row of buttons
32
+ * (OpenCode, MiMo Code) is recognised by its signature (`dialogs.ts`),
33
+ * which config can extend. Their numbered question menu is recognised by
34
+ * its fixed controls and custom-answer choice here.
34
35
  */
35
36
  import { dialogPrompt } from './dialogs.js';
37
+ /** A plain Muse heading can precede the moment its keys become active. */
38
+ export const MUSE_MENU_SETTLE_MS = 1_500;
36
39
  /**
37
40
  * A numbered option row, in either of the two shapes real CLIs draw. Dot
38
41
  * form: `❯ 1. Allow once` / `› 1. Yes, proceed (y)` / `>1. Sign in
@@ -151,6 +154,31 @@ const TAIL_WINDOW = 20;
151
154
  * misattribute ordinary transcript text.
152
155
  */
153
156
  const QUESTION_SEARCH_BUDGET = 8;
157
+ /**
158
+ * Grok's permission question row: two spaces, the bar, two spaces, `>`,
159
+ * then a space. With or without a question mark, that row is the question
160
+ * the box is asking. The composer is `│ >` with one space and does not match.
161
+ */
162
+ const GROK_BOX_QUESTION = /^ {2}│ {2}> /;
163
+ /** Bar text in that same box: two spaces, the bar, two spaces, a word. */
164
+ const GROK_BAR_TEXT = /^ {2}│ {2}\S/;
165
+ /** The bare bar row that closes a command off from the reasoning above it. */
166
+ const GROK_BARE_BAR = /^ {2}│\s*$/;
167
+ /**
168
+ * A line that starts Grok's reasoning. The command walk does not see the
169
+ * signature. The thinking header is itself bar text, so the walk would
170
+ * otherwise take it; the spinner is not bar text, and a run below it is
171
+ * still closed off by it.
172
+ */
173
+ const GROK_REASONING_START = /^ {2}│ {2}♦ Thinking|^ {3}[|/\\-] \S/;
174
+ /** A `$` on a command row, or a `:` continuation of one. */
175
+ const GROK_COMMAND_MARK = /\$|^ {2}│ {2}:/;
176
+ /** The fixed controls at the foot of OpenCode and MiMo Code's question menu. */
177
+ const QUESTION_MENU_FOOTER = /^ *┃ {2}↑↓ select {2}enter submit {2}esc dismiss\s*$/u;
178
+ const QUESTION_MENU_OPTION = /^ *┃ {2}([1-4])\. (\S.*)$/u;
179
+ const QUESTION_MENU_DESCRIPTION = /^ *┃ {5}\S/u;
180
+ const QUESTION_MENU_TEXT = /^ *┃ {2}(\S.*)$/u;
181
+ const QUESTION_MENU_BAR = /^ *┃\s*$/u;
154
182
  function contentLines(raw) {
155
183
  return raw
156
184
  .map((text, index) => ({ text: text.trimEnd(), index }))
@@ -176,12 +204,28 @@ function isYesNo(text) {
176
204
  * Decide whether the screen is showing a prompt that waits on a human.
177
205
  * Returns null when the screen looks busy or shows no prompt shape.
178
206
  */
207
+ export const SELECTED_OPTION_MARKER = '⟦SP:selected⟧ ';
179
208
  export function detectPrompt(screen) {
209
+ const original = screen.split('\n');
210
+ const plain = original.map((line) => line.replace(/^⟦SP:selected⟧ /, ''));
211
+ const prompt = detectPlainPrompt(plain.join('\n'));
212
+ if (prompt?.optionRows === undefined)
213
+ return prompt;
214
+ const selected = prompt.optionRows.flatMap((row, index) => original[row]?.startsWith(SELECTED_OPTION_MARKER) ? [index] : []);
215
+ return selected.length === 1 ? { ...prompt, selectedOption: selected[0] } : prompt;
216
+ }
217
+ function detectPlainPrompt(screen) {
180
218
  const raw = screen.split('\n');
181
219
  const lines = contentLines(raw);
182
220
  if (lines.length === 0)
183
221
  return null;
184
222
  const tail = lines.slice(-TAIL_WINDOW);
223
+ const muse = musePrompt(raw, tail);
224
+ if (muse !== null)
225
+ return muse;
226
+ const questionMenu = openCodeQuestionMenu(raw, lines);
227
+ if (questionMenu !== null)
228
+ return questionMenu;
185
229
  // A dialog a program draws on its own screen, recognised by its signature
186
230
  // (`dialogs.ts`): the most specific test there is, so it goes first.
187
231
  const dialog = dialogPrompt(raw);
@@ -204,7 +248,7 @@ export function detectPrompt(screen) {
204
248
  for (const block of blocks) {
205
249
  if (block === null)
206
250
  continue;
207
- const prompt = livePrompt(block, tail);
251
+ const prompt = livePrompt(block, tail, raw);
208
252
  if (prompt !== null)
209
253
  return prompt;
210
254
  }
@@ -212,16 +256,183 @@ export function detectPrompt(screen) {
212
256
  const last = lines[lines.length - 1];
213
257
  if (isYesNo(last.text) && !BUSY_LINE.test(last.text)) {
214
258
  const question = normalise(last.text);
215
- return { question, options: [], signature: question };
259
+ return { question, options: [], signature: question, rows: [last.index, last.index], basis: 'frame' };
216
260
  }
217
261
  // A bare press-enter wait (the Codex onboarding screens): the last content
218
262
  // line asks for enter and nothing below it can contradict that.
219
263
  if (PRESS_ENTER.test(last.text)) {
220
264
  const question = normalise(last.text);
221
- return { question, options: [], signature: question };
265
+ return { question, options: [], signature: question, rows: [last.index, last.index], basis: 'frame' };
222
266
  }
223
267
  return null;
224
268
  }
269
+ function museQuestion(text) {
270
+ return /^Would .+ like to run the following command\?$/.test(text) || text === 'Do you trust this workspace?';
271
+ }
272
+ /** Muse's approval and trust menus use ⟩ with numbered rows and no composer. */
273
+ function musePrompt(raw, tail) {
274
+ const selected = [...tail].reverse().find((line) => /^⟩ [1-3](?:\. | {2})/.test(line.text));
275
+ if (selected === undefined)
276
+ return null;
277
+ const marker = /^⟩ ([1-3])(\. | {2})/.exec(selected.text);
278
+ if (marker === null)
279
+ return null;
280
+ const selectedOption = Number(marker[1]) - 1;
281
+ const approval = marker[2] === '. ';
282
+ const first = selected.index - selectedOption;
283
+ // Muse omits the workspace-wide choice for script blocks and some commands.
284
+ // The second row identifies that form even when the heading stays plain.
285
+ const twoOptionApproval = approval && /^(?:⟩ | {2})2\. Abort the entire command\s*\(esc\)/.test(raw[first + 1] ?? '');
286
+ const count = approval && !twoOptionApproval ? 3 : 2;
287
+ if (selectedOption >= count)
288
+ return null;
289
+ const options = [];
290
+ const optionRows = [];
291
+ for (let offset = 0; offset < count; offset++) {
292
+ const row = first + offset;
293
+ const text = (raw[row] ?? '').trimEnd();
294
+ const prefix = `${offset === selectedOption ? '⟩ ' : ' '}${String(offset + 1)}${approval ? '. ' : ' '}`;
295
+ if (!text.startsWith(prefix) || text.slice(prefix.length).trim() === '')
296
+ return null;
297
+ options.push(normalise(text.replace(/^⟩ /, '')));
298
+ optionRows.push(row);
299
+ }
300
+ // Walk the visible menu itself: a long wrapped command can put the heading
301
+ // beyond the tail and more than ten rows above the first choice. The first
302
+ // transcript or composer boundary prevents borrowing an answered question.
303
+ let question;
304
+ for (let index = first - 1; index >= 0 && first - index <= 60; index--) {
305
+ const text = (raw[index] ?? '').trimEnd();
306
+ if (museQuestion(text)) {
307
+ question = { text, index };
308
+ break;
309
+ }
310
+ if (/^\s*(?:[◆◇◈]|❯(?:\s|$)|[─━═]{2,})/u.test(text))
311
+ break;
312
+ }
313
+ if (question === undefined)
314
+ return null;
315
+ if (approval !== question.text.startsWith('Would '))
316
+ return null;
317
+ // A quoted menu inside an answer has no new Muse input border before it.
318
+ const before = raw.slice(0, question.index);
319
+ let border = -1;
320
+ for (let index = before.length - 1; index >= 0; index--) {
321
+ if (/^\s*── .*Voice input/.test(before[index])) {
322
+ border = index;
323
+ break;
324
+ }
325
+ }
326
+ if (before.slice(border + 1).some((line) => /^\s*◆/.test(line)))
327
+ return null;
328
+ const stage = approval ? raw.slice(question.index, first).find((line) => /^ {2}Stage \d+\/\d+$/.test(line.trimEnd())) : undefined;
329
+ // Only this menu's hint and footer, blank rows and Muse's status footer
330
+ // belong below its options. Other output means the menu is historical.
331
+ if (raw.slice(optionRows[optionRows.length - 1] + 1).some((line) => {
332
+ const text = line.trimEnd();
333
+ return text.trim() !== '' && !/^Change approval defaults in \/permissions$/.test(text) &&
334
+ (approval || !/^Use Up\/Down or 1\/2, then Enter\. Esc quits\.$/.test(text)) &&
335
+ !/^\s*[─━═]{2,}$/.test(text) &&
336
+ !/^ {2}\S[^·]* · [^·]+ · [^·]+ · Launch overrides$/u.test(text);
337
+ }))
338
+ return null;
339
+ return {
340
+ question: question.text,
341
+ options,
342
+ selectedOption,
343
+ optionRows,
344
+ signature: [question.text, stage ?? '', ...options].join(' | '),
345
+ rows: [question.index, optionRows[optionRows.length - 1]],
346
+ basis: 'marker',
347
+ };
348
+ }
349
+ /** Tracks the visible menu block, independently of activity above it. */
350
+ export class MusePromptSettler {
351
+ menu = null;
352
+ since = 0;
353
+ detect(screen, now = Date.now(), styled) {
354
+ const prompt = detectPrompt(screen);
355
+ if (prompt === null) {
356
+ this.menu = null;
357
+ return null;
358
+ }
359
+ if (!prompt.question.startsWith('Would ') || !prompt.signature.includes('Stage ') ||
360
+ prompt.optionRows === undefined) {
361
+ this.menu = null;
362
+ return prompt;
363
+ }
364
+ const atRow = styled?.[prompt.rows[0]];
365
+ const heading = atRow?.text === prompt.question ? atRow :
366
+ [...(styled ?? [])].reverse().find((line) => line.text === prompt.question);
367
+ const bold = heading !== undefined && heading.spans.some((span) => span.bold && span.to - span.from >= prompt.question.length / 2);
368
+ if (bold) {
369
+ this.menu = null;
370
+ return prompt;
371
+ }
372
+ // The heading to the last option row: a status footer below may tick.
373
+ const block = screen.split('\n').slice(prompt.rows[0], prompt.rows[1] + 1).join('\n');
374
+ if (block !== this.menu) {
375
+ this.menu = block;
376
+ this.since = now;
377
+ }
378
+ return now - this.since >= MUSE_MENU_SETTLE_MS ? prompt : null;
379
+ }
380
+ }
381
+ /** A live left-ruled question menu with its fixed footer and custom-answer choice. */
382
+ function openCodeQuestionMenu(raw, lines) {
383
+ const footer = [...lines].reverse().find((line) => QUESTION_MENU_FOOTER.test(line.text));
384
+ if (footer === undefined)
385
+ return null;
386
+ const after = lines.filter((line) => line.index > footer.index);
387
+ // The programme may draw a status line below the menu, but another input
388
+ // box or a resumed transcript means this menu is no longer waiting.
389
+ if (after.length > 2 || after.some((line) => BUSY_LINE.test(line.text) || /[╭╰│❯›]/u.test(line.text)))
390
+ return null;
391
+ let cursor = footer.index - 1;
392
+ while (QUESTION_MENU_BAR.test(raw[cursor] ?? ''))
393
+ cursor--;
394
+ const options = [];
395
+ for (let count = 0; count < 4 && cursor >= 0; count++) {
396
+ while (QUESTION_MENU_DESCRIPTION.test(raw[cursor] ?? ''))
397
+ cursor--;
398
+ const row = QUESTION_MENU_OPTION.exec(raw[cursor] ?? '');
399
+ if (row === null)
400
+ break;
401
+ options.unshift(row[2]);
402
+ cursor--;
403
+ }
404
+ // The walk above collects option rows from the bottom. Their numbers must
405
+ // be consecutive, with the final row offering the custom answer.
406
+ if (options.length < 2 || options.length > 4 || options.at(-1) !== 'Type your own answer')
407
+ return null;
408
+ const firstOption = cursor + 1;
409
+ const numbered = raw.slice(firstOption, footer.index).map((line) => QUESTION_MENU_OPTION.exec(line)?.[1]);
410
+ if (numbered.filter((value) => value !== undefined).join(',') !== options.map((_, i) => String(i + 1)).join(','))
411
+ return null;
412
+ if (!QUESTION_MENU_BAR.test(raw[cursor] ?? ''))
413
+ return null;
414
+ while (QUESTION_MENU_BAR.test(raw[cursor] ?? ''))
415
+ cursor--;
416
+ const question = [];
417
+ while (cursor >= 0 && question.length < 8) {
418
+ const row = QUESTION_MENU_TEXT.exec(raw[cursor] ?? '');
419
+ if (row === null || QUESTION_MENU_OPTION.test(raw[cursor] ?? ''))
420
+ break;
421
+ question.unshift(row[1]);
422
+ cursor--;
423
+ }
424
+ if (question.length === 0)
425
+ return null;
426
+ const first = cursor + 1;
427
+ return {
428
+ question: normalise(question.join(' ')),
429
+ options,
430
+ optionRows: raw.slice(firstOption, footer.index).map((line, index) => QUESTION_MENU_OPTION.test(line) ? firstOption + index : -1).filter((index) => index >= 0),
431
+ signature: normalise(raw.slice(first, footer.index + 1).join(' ')),
432
+ rows: [first, footer.index],
433
+ basis: 'footer',
434
+ };
435
+ }
225
436
  /**
226
437
  * A clack step waiting on its answer: a `◆` or `▲` headline, choice rows in
227
438
  * the gutter under it and the `└` that closes the step. The headline alone
@@ -270,6 +481,7 @@ function clackPrompt(tail, raw) {
270
481
  // message of its own is asked by the message logged just above it.
271
482
  const message = headline[1] === undefined ? loggedAbove(raw, top - 1) : [headline[1]];
272
483
  const options = [];
484
+ const optionRows = [];
273
485
  let radios = 0;
274
486
  let selected = 0;
275
487
  for (let index = top; index <= lastRow.index; index++) {
@@ -287,6 +499,7 @@ function clackPrompt(tail, raw) {
287
499
  if (glyph === '●')
288
500
  selected++;
289
501
  options.push(normalise(choice.slice(2)));
502
+ optionRows.push(index);
290
503
  }
291
504
  }
292
505
  // A select has exactly one option selected, and so has a confirm.
@@ -299,7 +512,11 @@ function clackPrompt(tail, raw) {
299
512
  return {
300
513
  question,
301
514
  options,
515
+ optionRows,
302
516
  signature: [question, ...options.map(withoutHint)].join(' | '),
517
+ // From the headline to the bar end, a validation message under it included.
518
+ rows: [top - 1, after - 1],
519
+ basis: 'frame',
303
520
  };
304
521
  }
305
522
  /**
@@ -472,11 +689,45 @@ function pointerBlock(tail, raw) {
472
689
  return null;
473
690
  return { rows: all.map((line) => ({ line, option: stripMarkers(line.text) })), kind: 'pointer' };
474
691
  }
692
+ /**
693
+ * Where an older Grok box's command starts. The command is plain bar text
694
+ * above the radios. The walk may cross the one bare bar between that text
695
+ * and the radios. It stops at the next bare bar, or at a line that starts
696
+ * Grok's reasoning (`♦ Thinking`, or the spinner). The run is taken only
697
+ * when a line in it is command evidence: the box's `│ > ` question row,
698
+ * a `$`, or a `:` continuation. Otherwise the run is the same shape as
699
+ * reasoning, and the radios stay the start.
700
+ */
701
+ function commandAboveRadios(raw, firstOption) {
702
+ const text = (index) => (raw[index] ?? '').trimEnd();
703
+ if (!/^ {2}│ {2}\d+ \([○•●]\) /.test(text(firstOption)))
704
+ return firstOption;
705
+ const above = firstOption - 1;
706
+ // The one bare bar between the command and the radios may be crossed.
707
+ // Text sitting directly on the radios is the command itself.
708
+ const gap = GROK_BARE_BAR.test(text(above));
709
+ let cursor = gap ? above - 1 : above;
710
+ let start = firstOption;
711
+ let sawText = false;
712
+ let sawEvidence = false;
713
+ while (cursor >= 0 && GROK_BAR_TEXT.test(text(cursor)) && !GROK_REASONING_START.test(text(cursor))) {
714
+ sawText = true;
715
+ if (GROK_BOX_QUESTION.test(text(cursor)) || GROK_COMMAND_MARK.test(text(cursor)))
716
+ sawEvidence = true;
717
+ start = cursor;
718
+ cursor--;
719
+ }
720
+ if (!sawText || !sawEvidence)
721
+ return firstOption;
722
+ if (GROK_BARE_BAR.test(text(cursor)) || GROK_REASONING_START.test(text(cursor)))
723
+ return start;
724
+ return firstOption;
725
+ }
475
726
  /**
476
727
  * Whether a block is a prompt the program is WAITING on, and if so the
477
728
  * prompt as the consumer should see it.
478
729
  */
479
- function livePrompt(block, tail) {
730
+ function livePrompt(block, tail, raw) {
480
731
  const { rows, kind } = block;
481
732
  const blockStart = rows[0].line.index;
482
733
  const blockEnd = rows[rows.length - 1].line.index;
@@ -488,13 +739,27 @@ function livePrompt(block, tail) {
488
739
  return null;
489
740
  const hasMarker = tail.some((line) => line.index >= blockStart && line.index <= blockEnd && MARKER_LINE.test(line.text));
490
741
  const hasPressEnter = below.some((line) => PRESS_ENTER.test(line.text));
491
- const question = findQuestion(tail, blockStart);
492
742
  const nothingBelow = below.every((line) => RULE_LINE.test(line.text));
743
+ // A question mark above the bare bar that closes an older Grok command is
744
+ // reasoning. The command below that bar is claimed on its own, further down.
745
+ const commandStart = commandAboveRadios(raw, blockStart);
746
+ let question = findQuestion(tail, blockStart);
747
+ if (question !== null && commandStart < blockStart && question.index < commandStart)
748
+ question = null;
493
749
  let live;
750
+ let basis;
494
751
  if (kind === 'key-hint') {
495
752
  // The key hints are the block's own markers; the question above must
496
753
  // frame it.
497
754
  live = question !== null;
755
+ basis = 'frame';
756
+ }
757
+ else if (kind === 'letter') {
758
+ // Distinct letter keys are the block. The weak signal the filter
759
+ // declines is a numbered list with nothing below it, which is also how
760
+ // reasoning draws a list. A letter menu is not that.
761
+ live = hasMarker || hasPressEnter || (question !== null && nothingBelow);
762
+ basis = 'frame';
498
763
  }
499
764
  else if (kind === 'pointer') {
500
765
  // The pointer is the block's own marker, so it proves nothing by itself:
@@ -506,14 +771,24 @@ function livePrompt(block, tail) {
506
771
  // earlier one. What follows the choices cannot decide: inquirer draws a
507
772
  // description of the focused choice and a key-help line there.
508
773
  live = hasPressEnter || (question !== null && drawnTogether(tail, question.index, blockStart));
774
+ basis = hasPressEnter ? 'footer' : 'marker';
509
775
  }
510
- else {
776
+ else if (hasMarker) {
511
777
  // A focused-option marker or a press-enter footer is the strongest
512
778
  // signal a selector is live. Without either, a question-shaped headline
513
779
  // counts only when the block ENDS the screen: a program blocked on a
514
780
  // choice draws nothing after its options, while an agent that has
515
781
  // finished a turn draws its composer under the numbered list it printed.
516
- live = hasMarker || hasPressEnter || (question !== null && nothingBelow);
782
+ live = true;
783
+ basis = 'marker';
784
+ }
785
+ else if (hasPressEnter) {
786
+ live = true;
787
+ basis = 'footer';
788
+ }
789
+ else {
790
+ live = question !== null && nothingBelow;
791
+ basis = 'question';
517
792
  }
518
793
  if (!live)
519
794
  return null;
@@ -525,10 +800,21 @@ function livePrompt(block, tail) {
525
800
  // evade the threshold forever. Normalise filled radios to hollow in the
526
801
  // signature only; `options` keeps the live state for the consumer.
527
802
  const stable = (text) => text.replace(/\([•●]\)/g, '(○)');
803
+ // From the question, when one is found, down to the last option row:
804
+ // what a program draws between the two belongs to the question too.
805
+ // With no question, an older Grok box still owns the command text a bare
806
+ // bar, or a reasoning start, closes off above its radios, when that text
807
+ // carries command evidence.
808
+ let start = question?.index ?? blockStart;
809
+ if (question === null)
810
+ start = Math.min(start, commandStart);
528
811
  return {
529
812
  question: headline,
530
813
  options,
814
+ optionRows: rows.map((row) => row.line.index),
531
815
  signature: [headline, ...options].map(stable).join(' | '),
816
+ rows: [start, blockEnd],
817
+ basis,
532
818
  };
533
819
  }
534
820
  /**
@@ -584,8 +870,13 @@ function findQuestion(tail, blockStart) {
584
870
  if (RULE_LINE.test(line.text))
585
871
  continue;
586
872
  inspected++;
587
- const cleaned = normalise(line.text);
588
- if (/\?/.test(cleaned) ||
873
+ // Only Grok's exact box prefix is chrome. A question may itself begin
874
+ // with `>` or a box character, so leave everything after that prefix.
875
+ const cleaned = normalise(GROK_BOX_QUESTION.test(line.text)
876
+ ? line.text.replace(GROK_BOX_QUESTION, '')
877
+ : line.text);
878
+ if (GROK_BOX_QUESTION.test(line.text) ||
879
+ /\?/.test(cleaned) ||
589
880
  /permission required/i.test(cleaned) ||
590
881
  /^allow\b/i.test(cleaned) ||
591
882
  /do you trust/i.test(cleaned) ||