strands-darwin 0.0.45 → 0.0.47

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 (50) hide show
  1. package/README.md +4 -2
  2. package/README.zh-CN.md +4 -2
  3. package/dist/src/agent/permission.js +19 -2
  4. package/dist/src/agent/permission.js.map +1 -1
  5. package/dist/src/agent/runtime.d.ts +35 -1
  6. package/dist/src/agent/runtime.js +52 -3
  7. package/dist/src/agent/runtime.js.map +1 -1
  8. package/dist/src/cli-completion.d.ts +13 -0
  9. package/dist/src/cli-completion.js +161 -0
  10. package/dist/src/cli-completion.js.map +1 -0
  11. package/dist/src/cli-usage.d.ts +1 -1
  12. package/dist/src/cli-usage.js +1 -0
  13. package/dist/src/cli-usage.js.map +1 -1
  14. package/dist/src/cli.js +5 -1
  15. package/dist/src/cli.js.map +1 -1
  16. package/dist/src/commands/custom-commands.d.ts +7 -0
  17. package/dist/src/commands/custom-commands.js +20 -0
  18. package/dist/src/commands/custom-commands.js.map +1 -1
  19. package/dist/src/dev-repl.js +4 -1
  20. package/dist/src/dev-repl.js.map +1 -1
  21. package/dist/src/headless-protocol.d.ts +1 -1
  22. package/dist/src/headless-protocol.js +5 -0
  23. package/dist/src/headless-protocol.js.map +1 -1
  24. package/dist/src/headless-runner.js +5 -0
  25. package/dist/src/headless-runner.js.map +1 -1
  26. package/dist/src/headless.js +5 -0
  27. package/dist/src/headless.js.map +1 -1
  28. package/dist/src/mcp/prompts.d.ts +179 -0
  29. package/dist/src/mcp/prompts.js +349 -0
  30. package/dist/src/mcp/prompts.js.map +1 -0
  31. package/dist/src/mcp/registry.d.ts +8 -1
  32. package/dist/src/mcp/registry.js +3 -1
  33. package/dist/src/mcp/registry.js.map +1 -1
  34. package/dist/src/tui/App.js +187 -12
  35. package/dist/src/tui/App.js.map +1 -1
  36. package/dist/src/tui/InputBox.d.ts +7 -1
  37. package/dist/src/tui/InputBox.js +5 -3
  38. package/dist/src/tui/InputBox.js.map +1 -1
  39. package/dist/src/tui/external-editor.d.ts +143 -0
  40. package/dist/src/tui/external-editor.js +482 -0
  41. package/dist/src/tui/external-editor.js.map +1 -0
  42. package/dist/src/tui/help-format.js +2 -2
  43. package/dist/src/tui/help-format.js.map +1 -1
  44. package/dist/src/tui/mcp-format.d.ts +2 -0
  45. package/dist/src/tui/mcp-format.js +23 -1
  46. package/dist/src/tui/mcp-format.js.map +1 -1
  47. package/dist/src/tui/prompt-editor.d.ts +6 -0
  48. package/dist/src/tui/prompt-editor.js +10 -0
  49. package/dist/src/tui/prompt-editor.js.map +1 -1
  50. package/package.json +1 -1
@@ -14,9 +14,10 @@ import { peerNotice, peerPrompt } from '../collaboration/protocol.js';
14
14
  * unfinished answer; while idle the first press only arms. A second press within a
15
15
  * short window exits, busy or idle. Ctrl+D always exits.
16
16
  */
17
+ import { open as openFile } from 'node:fs/promises';
17
18
  import os from 'node:os';
18
19
  import path from 'node:path';
19
- import { Box, Text, useApp, useBoxMetrics, useInput, usePaste, useStdout, useWindowSize } from 'ink';
20
+ import { Box, Text, useApp, useBoxMetrics, useInput, usePaste, useStdin, useStdout, useWindowSize } from 'ink';
20
21
  import React, { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from 'react';
21
22
  import { AGENTS_FILENAME } from '../agent/instructions.js';
22
23
  import { APPROVAL_MODES, describeApprovalMode, isApprovalMode, } from '../agent/permission.js';
@@ -39,6 +40,8 @@ import { BUILTIN_COMMAND_NAMES } from '../commands/custom-commands.js';
39
40
  import { WORKFLOW_COMMAND_USAGE, parseWorkflowCommand } from '../commands/workflow-command.js';
40
41
  import { parseReviewCommand, REVIEW_COMMIT_USAGE } from '../commands/review-command.js';
41
42
  import { MCP_CONFIG_FILENAME, mcpConfigCandidates } from '../mcp/registry.js';
43
+ import { mcpPromptLoadedNotice, mcpPromptOmittedAnything } from '../mcp/prompts.js';
44
+ import { searchPreview } from './search-preview.js';
42
45
  import { DARWIN_DIRNAME } from '../paths.js';
43
46
  import { readBackgroundTail, readBackgroundTails } from '../tools/background-tail.js';
44
47
  import { formatShellEnvNotice } from '../tools/shell-env.js';
@@ -57,7 +60,7 @@ import { PermissionRulePreview, ruleReviewClaim, ruleReviewLayout } from './perm
57
60
  import { welcomeLayout } from './WelcomeHeader.js';
58
61
  import { ActiveToolCalls } from './ToolCallPanel.js';
59
62
  import { QueuedMessages } from './QueuedMessages.js';
60
- import { backspaceAtCursor, deleteAtCursor, deleteWordAfter, deleteWordBefore, insertAtCursor, killToRowEdge, layoutEditor, moveHorizontal, moveToDraftEdge, moveToRowEdge, moveVertical, moveWordHorizontal, popUndo, pushUndo, updateLastCut, LAST_CUT_OVERFLOW_NOTICE, } from './prompt-editor.js';
63
+ import { backspaceAtCursor, deleteAtCursor, deleteWordAfter, deleteWordBefore, insertAtCursor, killToRowEdge, layoutEditor, moveHorizontal, moveToDraftEdge, moveToRowEdge, moveVertical, moveWordHorizontal, normalizeDraftText, popUndo, pushUndo, updateLastCut, LAST_CUT_OVERFLOW_NOTICE, } from './prompt-editor.js';
61
64
  import { NO_WORKSPACE_PATHS, applyPathCompletion, scanWorkspacePaths, workspacePathsNote, } from './path-completion.js';
62
65
  import { promptCompletionState, visiblePromptCompletions, } from './prompt-completion.js';
63
66
  import { openPromptRecall, promptRecallIndicator, stepPromptRecall, } from './prompt-recall.js';
@@ -71,6 +74,8 @@ import { GOAL_CONDITION_MAX_CODE_POINTS, parseGoalCommand } from '../commands/go
71
74
  import { boundedReason } from '../agent/goal-check.js';
72
75
  import { GOAL_SET_NOTICE, composeGoalEvidence, goalAction, goalAfterCheck, goalAfterTurn, goalBeforeTurn, goalContinuationPrompt, goalContinued, goalLiveSuffix, goalStatusText, newGoal, } from './goal.js';
73
76
  import { composeShellReport, parseShellCommand, projectShellOutput, runShellCommand, } from './shell-command.js';
77
+ import { EXTERNAL_EDITOR_UNSET_NOTICE, canQuiesceTerminalInput, editorLabel, externalEditorRefusal, quiesceTerminalInput, resolveEditorCommand, runExternalEditor, } from './external-editor.js';
78
+ import { scrubShellEnv, withDarwinMarker } from '../tools/shell-env.js';
74
79
  import { formatTaskCompletion, formatTasksReport, runningTasksHeader } from './task-format.js';
75
80
  import { TASK_WAKE_TAIL_LINES, formatTaskNotification, formatTaskWakeUndelivered, taskNotificationFields, } from './task-wake.js';
76
81
  import { formatDispatchCancellation, formatDispatchCompletion, formatDispatchesReport, } from './subagent-format.js';
@@ -106,8 +111,6 @@ const PATH_SCAN_TTL_MS = 5000;
106
111
  * guessing low costs the scrollback.
107
112
  */
108
113
  const ASSUMED_HEADER_ROWS = 14;
109
- /** C0 controls except LF and tab, plus DEL: never treated as draft text. */
110
- const NON_TEXT_CONTROLS = /[\u0000-\u0008\u000b-\u001f\u007f]/g;
111
114
  /**
112
115
  * Erase the screen, the scrollback and home the cursor — Ink's own `clearTerminal`,
113
116
  * spelled out here because `ansi-escapes` is Ink's dependency and not darwin's.
@@ -118,12 +121,9 @@ const NON_TEXT_CONTROLS = /[\u0000-\u0008\u000b-\u001f\u007f]/g;
118
121
  * different thing from one per text delta.
119
122
  */
120
123
  const CLEAR_TERMINAL = '\u001B[2J\u001B[3J\u001B[H';
121
- /** Canonicalizes terminal line endings and drops controls without losing layout. */
122
- function normalizeDraftText(value) {
123
- return value.replace(/\r+\n/g, '\n').replace(/\r/g, '\n').replace(NON_TEXT_CONTROLS, '');
124
- }
125
124
  export function App({ runtime: initialRuntime, permissions, initialHistory = [], startNewSession, startRewind, }) {
126
- const { exit: inkExit, waitUntilRenderFlush } = useApp();
125
+ const { exit: inkExit, waitUntilRenderFlush, suspendTerminal } = useApp();
126
+ const { stdin } = useStdin();
127
127
  const { columns, rows } = useWindowSize();
128
128
  const { write: writeToTerminal } = useStdout();
129
129
  // The live session. A prop at startup, state afterwards: `/clear` replaces the
@@ -155,7 +155,16 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
155
155
  ...BUILTIN_COMMAND_NAMES,
156
156
  ...runtime.info.commandNames,
157
157
  ...runtime.info.skillNames,
158
+ // SER-114: lowest precedence, after every existing entry. Names were already
159
+ // claimed against everything above, so none of these dedupes anything away.
160
+ ...runtime.info.mcpPromptCommands.map((command) => command.name),
158
161
  ])], [runtime]);
162
+ // Completion-row descriptions for MCP prompt commands: the server's bounded
163
+ // description plus the argument hint; InputBox escapes controls when drawing.
164
+ const commandDescriptions = useMemo(() => new Map(runtime.info.mcpPromptCommands.map((command) => [
165
+ command.name,
166
+ [command.argumentHint, command.description ?? `MCP prompt`].filter((part) => part !== '').join(' · '),
167
+ ])), [runtime]);
159
168
  // Escape suppresses one computed query generation, not the draft. Mirrors are
160
169
  // required for the same reason as the editor/selection mirrors: a second batched
161
170
  // key must see the first Escape before React commits its render.
@@ -330,6 +339,16 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
330
339
  const clipboardReadGeneration = useRef(0);
331
340
  /** Image currently owned by one model-bound invocation, blocking reassociation. */
332
341
  const imageTurnInFlight = useRef(false);
342
+ /**
343
+ * Ctrl+G external editing (SER-113). `editorActive` is the repeated-chord fence;
344
+ * the run handle is what unmount reaps. While the terminal is released the shared
345
+ * `draining` latch is held too, so queue, peer and goal drains wait, and the Static
346
+ * history is frozen at its released length: Ink discards renders while suspended,
347
+ * so a notice committed then would advance `<Static>` past an item never printed.
348
+ */
349
+ const editorActive = useRef(false);
350
+ const editorRun = useRef(undefined);
351
+ const [heldHistory, setHeldHistory] = useState(undefined);
333
352
  /**
334
353
  * Terminal-only acknowledgement for the answer-close handoff. Dispatching a
335
354
  * reducer action proves only that React accepted it; the layout effect below
@@ -714,6 +733,9 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
714
733
  // A `!` command must not outlive the TUI that ran it: on unmount (Ctrl+D, /exit,
715
734
  // a second Ctrl+C) the group gets the same TERM→KILL reaping a cancel gives it.
716
735
  useEffect(() => () => shellRun.current?.kill(), []);
736
+ // Same for an external editor (SER-113): darwin shutdown TERM→KILLs it and removes
737
+ // its private storage synchronously, since the exit path may not await settlement.
738
+ useEffect(() => () => editorRun.current?.kill(), []);
717
739
  // Terminal window/tab title (SER-073): `darwin · <project> · <state>`, one OSC 2
718
740
  // sequence straight to the real stdout — the seam the bell uses, never Ink's
719
741
  // frame path — and only when the composed title changes, so this is a
@@ -1936,6 +1958,15 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
1936
1958
  // Skills and project commands send their expanded prompt instead of the
1937
1959
  // literal command. Unknown slash input falls through as ordinary input.
1938
1960
  let toSend = text;
1961
+ // SER-114: an MCP prompt is the one expansion that waits on a server. Hold the
1962
+ // session busy meanwhile — submissions queue, Ctrl+C reaches `runtime.cancel()`,
1963
+ // which aborts the `prompts/get` — exactly like the goal check's busy state.
1964
+ const fetchingMcpPrompt = runtime.isMcpPromptCommand(text);
1965
+ if (fetchingMcpPrompt) {
1966
+ turnAborted.current = false;
1967
+ turnStartedAt.current = Date.now();
1968
+ setStatus('streaming');
1969
+ }
1939
1970
  try {
1940
1971
  const expanded = await runtime.expandSlashCommand(text);
1941
1972
  if (expanded !== null) {
@@ -1951,12 +1982,19 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
1951
1982
  ? expanded.message.startsWith('Review commit ')
1952
1983
  ? 'reviewing commit with /review'
1953
1984
  : 'reviewing current changes with /review'
1954
- : `loaded command "/${expanded.command.name}"`,
1985
+ : expanded.kind === 'mcp-prompt'
1986
+ ? mcpPromptLoadedNotice(expanded)
1987
+ : `loaded command "/${expanded.command.name}"`,
1988
+ ...(expanded.kind === 'mcp-prompt' && mcpPromptOmittedAnything(expanded.omitted) ? { severity: 'warn' } : {}),
1955
1989
  });
1956
1990
  toSend = expanded.message;
1957
1991
  }
1958
1992
  }
1959
1993
  catch (error) {
1994
+ if (fetchingMcpPrompt) {
1995
+ turnStartedAt.current = undefined;
1996
+ setStatus('idle');
1997
+ }
1960
1998
  dispatch({
1961
1999
  type: 'notice',
1962
2000
  text: `could not expand ${text}: ${error instanceof Error ? error.message : String(error)}; prompt not sent — restored to the editor`,
@@ -2446,6 +2484,134 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
2446
2484
  if (opened.text !== undefined)
2447
2485
  applyRecalled(opened.text);
2448
2486
  }, [applyRecalled, history, setRecall]);
2487
+ /**
2488
+ * Ctrl+G (SER-113): edit the exact unsent draft in the user's VISUAL/EDITOR. Eligible
2489
+ * only at idle with nothing about to claim the session; the editor gets the terminal
2490
+ * through Ink's `suspendTerminal`, darwin's own tty reads are paused for its lifetime
2491
+ * (see `quiesceTerminalInput`), and drains hold behind the shared `draining` latch.
2492
+ * A valid changed result replaces the draft, cursor at the end, and stays unsent.
2493
+ * Everything else — refusal, launch failure, nonzero/signal exit, invalid output or
2494
+ * no change — leaves the draft, cursor and image exactly as they were.
2495
+ */
2496
+ const openExternalEditor = useCallback(() => {
2497
+ if (historySearchRef.current !== undefined || rewindSearchRef.current !== undefined)
2498
+ return;
2499
+ const goalOwed = goalAction(goalRef.current, {
2500
+ idle: true, permissionPending: false, clearing: false, draining: false, queued: 0, peerPending: 0,
2501
+ }) !== 'none';
2502
+ const refusal = externalEditorRefusal({
2503
+ editorActive: editorActive.current,
2504
+ idle: status === 'idle' && pendingPermission === undefined,
2505
+ queued: queuedRef.current.length,
2506
+ draining: draining.current,
2507
+ clearing: clearing.current,
2508
+ goalOwed,
2509
+ peerPending: runtime.collaboration?.pending ?? 0,
2510
+ liveDelegations: runtime.listBackgroundDelegations().length,
2511
+ });
2512
+ if (refusal === 'ignore')
2513
+ return;
2514
+ if (refusal !== undefined) {
2515
+ dispatch({ type: 'notice', text: refusal, severity: 'warn' });
2516
+ return;
2517
+ }
2518
+ const command = resolveEditorCommand(process.env);
2519
+ if (command.kind === 'unset') {
2520
+ dispatch({ type: 'notice', text: EXTERNAL_EDITOR_UNSET_NOTICE, severity: 'warn' });
2521
+ return;
2522
+ }
2523
+ if (command.kind === 'refused') {
2524
+ dispatch({ type: 'notice', text: `${command.source} not used: it ${command.reason} — draft unchanged`, severity: 'warn' });
2525
+ return;
2526
+ }
2527
+ if (!stdin.isTTY || !canQuiesceTerminalInput(stdin)) {
2528
+ dispatch({ type: 'notice', text: 'Ctrl+G needs an interactive terminal darwin can hand over safely — draft unchanged', severity: 'warn' });
2529
+ return;
2530
+ }
2531
+ const original = editorRef.current;
2532
+ const label = editorLabel(command.argv);
2533
+ // The same sanitized map the model's `bash` gets, plus `DARWIN=1` (SER-082/094).
2534
+ const env = withDarwinMarker(scrubShellEnv(process.env, runtime.info.shellEnv.passthrough).env);
2535
+ const cwd = runtime.info.projectRoot;
2536
+ editorActive.current = true;
2537
+ draining.current = true;
2538
+ // A clipboard read still pending must not attach while (or after) the draft is away.
2539
+ clipboardReadGeneration.current += 1;
2540
+ setHeldHistory(historyRef.current);
2541
+ void (async () => {
2542
+ let outcome;
2543
+ let failure;
2544
+ let restartInput = () => { };
2545
+ try {
2546
+ // Let Ink finish the input batch that carried Ctrl+G and commit the held history.
2547
+ await waitUntilRenderFlush();
2548
+ // A fresh description of the controlling terminal: whatever the editor does to
2549
+ // its file status flags (O_NONBLOCK) cannot leak into darwin's own stdin.
2550
+ const terminal = await openFile('/dev/tty', 'r+').catch(() => undefined);
2551
+ try {
2552
+ await suspendTerminal(async () => {
2553
+ restartInput = await quiesceTerminalInput(stdin);
2554
+ const run = runExternalEditor(original.text, {
2555
+ argv: command.argv,
2556
+ cwd,
2557
+ env,
2558
+ normalize: normalizeDraftText,
2559
+ projectRoot: cwd,
2560
+ ...(terminal === undefined ? {} : { terminalFd: terminal.fd }),
2561
+ });
2562
+ editorRun.current = run;
2563
+ outcome = await run.done;
2564
+ });
2565
+ }
2566
+ finally {
2567
+ editorRun.current = undefined;
2568
+ await terminal?.close().catch(() => undefined);
2569
+ }
2570
+ }
2571
+ catch (error) {
2572
+ failure = error instanceof Error ? error.message : String(error);
2573
+ }
2574
+ finally {
2575
+ // Shutdown leaves darwin's terminal reads stopped on purpose.
2576
+ if (presentationMounted.current)
2577
+ restartInput();
2578
+ setHeldHistory(undefined);
2579
+ editorActive.current = false;
2580
+ draining.current = false;
2581
+ setDrainCycle((cycle) => cycle + 1);
2582
+ }
2583
+ if (!presentationMounted.current)
2584
+ return;
2585
+ if (outcome === undefined) {
2586
+ dispatch({ type: 'notice', text: `external editor failed: ${failure ?? 'no result'} — draft unchanged`, severity: 'warn' });
2587
+ }
2588
+ else if (outcome.kind === 'changed') {
2589
+ if (editorRef.current !== original) {
2590
+ dispatch({ type: 'notice', text: 'the draft changed while the editor was open; editor result discarded', severity: 'warn' });
2591
+ }
2592
+ else {
2593
+ // A different draft: undo/cut/recall/completion state belonged to the old one.
2594
+ undoStack.current = [];
2595
+ lastCut.current = '';
2596
+ preferredColumn.current = undefined;
2597
+ setRecall(undefined);
2598
+ setDismissedCompletion(undefined);
2599
+ setSelectedCompletion(0);
2600
+ setEditor({ text: outcome.text, cursor: moveToDraftEdge(outcome.text, 'end') });
2601
+ dispatch({ type: 'notice', text: `draft replaced from ${label} — not sent; Enter sends it` });
2602
+ }
2603
+ }
2604
+ else if (outcome.kind === 'unchanged') {
2605
+ dispatch({ type: 'notice', text: `${label} closed without changes — draft unchanged` });
2606
+ }
2607
+ else {
2608
+ dispatch({ type: 'notice', text: `external editor: ${outcome.reason} — draft unchanged`, severity: 'warn' });
2609
+ }
2610
+ if (outcome?.cleanupProblem !== undefined) {
2611
+ dispatch({ type: 'notice', text: `external editor storage: ${outcome.cleanupProblem}`, severity: 'warn' });
2612
+ }
2613
+ })();
2614
+ }, [dispatch, pendingPermission, runtime, setDismissedCompletion, setEditor, setRecall, setSelectedCompletion, status, stdin, suspendTerminal, waitUntilRenderFlush]);
2449
2615
  const handleInterrupt = useCallback(() => {
2450
2616
  const now = Date.now();
2451
2617
  const previous = interruptedAt.current;
@@ -2625,6 +2791,13 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
2625
2791
  }
2626
2792
  return;
2627
2793
  }
2794
+ // External editor (SER-113): composer ownership like Ctrl+S/Ctrl+O, below the
2795
+ // permission, compaction and search owners. Eligibility and the repeated-chord
2796
+ // fence live in `openExternalEditor`.
2797
+ if (key.ctrl && typed === 'g') {
2798
+ openExternalEditor();
2799
+ return;
2800
+ }
2628
2801
  // Escape belongs to the highest transient prompt UI currently shown. A menu
2629
2802
  // wins over recall just as it wins the arrow keys; neither branch touches the
2630
2803
  // editor, submits, dispatches, or changes the queue/runtime. The dismissed query
@@ -2912,7 +3085,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
2912
3085
  setSelectedCompletion(0);
2913
3086
  endRecall();
2914
3087
  });
2915
- return (_jsxs(Box, { flexDirection: "column", children: [_jsx(MessageList, { history: state.history, ...(state.staticEpoch === 0 ? { welcome: initialWelcome } : {}), liveText: state.liveText, liveCodeOpen: fenceOpenAfter(state.committedAnswer), columns: columns, maxLiveRows: grants.live, staticEpoch: state.staticEpoch }), _jsx(Box, { ref: headerRef, flexDirection: "column", children: _jsx(Header, { runtime: runtime, status: effectiveStatus, frame: frame, tangent: tangent, goal: goal, runningTaskCount: runningTaskCount, draftStashed: statusHint === undefined && draftStash !== undefined }) }), _jsxs(Box, { ref: chromeRef, flexDirection: "column", children: [state.thinking && effectiveStatus === 'streaming' && (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: `thinking…${busyElapsedMs === undefined ? '' : busySuffix(busyElapsedMs, undefined, busyRetryWait)}` })), _jsx(ActiveToolCalls, { tools: state.activeTools, frame: frame, toolDetailsExpanded: state.toolDetailsExpanded, columns: columns, maxRows: grants.tools }), _jsx(PlanChecklist, { plan: state.livePlan, maxRows: grants.plan }), _jsx(QueuedMessages, { entries: queued, maxRows: grants.queued }), activeRuleReview !== undefined ? _jsx(PermissionRulePreview, { review: activeRuleReview }) : pendingPermission !== undefined ? (_jsx(PermissionPrompt, { request: pendingPermission, waiting: permissions.waiting, columns: columns, maxRows: grants.prompt })) : (_jsx(InputBox, { layout: layout, completions: completions, completionKind: completionKind, completionNote: completionNote, selectedCompletion: selectedCompletion, editable: effectiveStatus !== 'compacting', offset: { top: chrome.top, left: chrome.left }, maxRows: grants.prompt, hint: streamingHint, attachment: attachedImage === undefined ? undefined : clipboardImageFact(attachedImage), recallIndicator: recallIndicator, historySearch: historySearchProjection, rewindSearch: rewindSearchProjection }))] })] }));
3088
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(MessageList, { history: heldHistory ?? state.history, ...(state.staticEpoch === 0 ? { welcome: initialWelcome } : {}), liveText: state.liveText, liveCodeOpen: fenceOpenAfter(state.committedAnswer), columns: columns, maxLiveRows: grants.live, staticEpoch: state.staticEpoch }), _jsx(Box, { ref: headerRef, flexDirection: "column", children: _jsx(Header, { runtime: runtime, status: effectiveStatus, frame: frame, tangent: tangent, goal: goal, runningTaskCount: runningTaskCount, draftStashed: statusHint === undefined && draftStash !== undefined }) }), _jsxs(Box, { ref: chromeRef, flexDirection: "column", children: [state.thinking && effectiveStatus === 'streaming' && (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: `thinking…${busyElapsedMs === undefined ? '' : busySuffix(busyElapsedMs, undefined, busyRetryWait)}` })), _jsx(ActiveToolCalls, { tools: state.activeTools, frame: frame, toolDetailsExpanded: state.toolDetailsExpanded, columns: columns, maxRows: grants.tools }), _jsx(PlanChecklist, { plan: state.livePlan, maxRows: grants.plan }), _jsx(QueuedMessages, { entries: queued, maxRows: grants.queued }), activeRuleReview !== undefined ? _jsx(PermissionRulePreview, { review: activeRuleReview }) : pendingPermission !== undefined ? (_jsx(PermissionPrompt, { request: pendingPermission, waiting: permissions.waiting, columns: columns, maxRows: grants.prompt })) : (_jsx(InputBox, { layout: layout, completions: completions, completionKind: completionKind, completionNote: completionNote, commandDescriptions: commandDescriptions, selectedCompletion: selectedCompletion, editable: effectiveStatus !== 'compacting', offset: { top: chrome.top, left: chrome.left }, maxRows: grants.prompt, hint: streamingHint, attachment: attachedImage === undefined ? undefined : clipboardImageFact(attachedImage), recallIndicator: recallIndicator, historySearch: historySearchProjection, rewindSearch: rewindSearchProjection }))] })] }));
2916
3089
  }
2917
3090
  /** The hint row under the draft, or nothing when the session is idle. */
2918
3091
  function hintForStatus(status, busyReadout, queuedCount = 0, queuedWakeCount = 0, goalSuffix = '') {
@@ -2973,9 +3146,11 @@ export function Header({ runtime, status = 'idle', frame = 0, tangent, goal, run
2973
3146
  const tangentSuffix = tangentHeaderSuffix(tangent) + goalLiveSuffix(goal);
2974
3147
  const activity = runningTasksHeader(runningTaskCount, columns - `◆ DARWIN · ${stateLabel}${tangentSuffix}`.length, frame);
2975
3148
  return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: visualColor.identity, bold: true, children: [visualMarker.identity, " DARWIN"] }), _jsxs(Text, { dimColor: true, children: [' · ', status === 'streaming' ? _jsx(WorkingStatus, { frame: frame }) : headerStatus(status), tangentSuffix] }), _jsx(Text, { color: visualColor.active, children: activity.label }), _jsx(Text, { dimColor: true, children: activity.hint })] }), _jsxs(Text, { dimColor: true, children: [runtime.config.provider, "/", runtime.config.model, " \u00B7 session ", info.sessionId, info.resumed ? ' (resumed)' : '', formatPromptCache(runtime.promptCache), formatThinking(runtime.thinking)] }), mode === 'yolo' ? (_jsxs(Text, { color: visualColor.warning, children: ["mode: ", describeMode(mode, runtime.allowRuleCount, runtime.denyRuleCount)] })) : mode === 'plan' ? (_jsxs(Text, { color: visualColor.warning, children: ["mode: ", describeMode(mode, runtime.allowRuleCount, runtime.denyRuleCount)] })) : (_jsxs(Text, { dimColor: true, children: ["mode: ", describeMode(mode, runtime.allowRuleCount, runtime.denyRuleCount)] })), instructions !== undefined &&
2976
- (instructions.truncated ? (_jsx(Text, { color: visualColor.warning, children: formatInstructionsLoadedRow(instructions) })) : (_jsx(Text, { dimColor: true, children: formatInstructionsLoadedRow(instructions) }))), info.projectInstructionsProblem !== undefined && (_jsx(Text, { color: visualColor.warning, children: formatInstructionsProblemRow(info.projectInstructionsProblemFile ?? AGENTS_FILENAME, info.projectInstructionsProblem) })), info.systemPromptSource === 'config' && (_jsxs(Text, { dimColor: true, children: ["system prompt: overridden by ", DARWIN_DIRNAME, "/", CONFIG_FILENAME] })), info.systemPromptSource === 'file' && (_jsxs(Text, { dimColor: true, children: ["system prompt: ", DARWIN_DIRNAME, "/", SYSTEM_PROMPT_FILENAME] })), info.systemPromptProblem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["system prompt: using the default \u2014 ", info.systemPromptProblem] })), info.workingContextProblem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["working context: no directory listing \u2014 ", info.workingContextProblem] })), info.promptCache.problem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["prompt cache: off \u2014 ", info.promptCache.problem] })), runtime.thinking.problem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["thinking: ", runtime.thinking.problem] })), hasCapabilities(info) && (_jsxs(Text, { dimColor: true, children: ["loaded: ", formatCapabilities(info), " \u00B7 type / for commands"] })), info.mcpIgnoredConfigPath !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["mcp: using ", DARWIN_DIRNAME, "/", MCP_CONFIG_FILENAME, " \u2014 ", info.mcpIgnoredConfigPath, " ignored"] })), info.hookShadowNotices.map((notice) => (_jsxs(Text, { color: visualColor.warning, wrap: "truncate-end", children: ["hooks: ", notice.layer, " ", notice.directory, " shadows ", notice.shadowed.join(', ')] }, notice.directory))), info.skillProblems.map((problem) => (_jsxs(Text, { color: visualColor.warning, children: ["skill skipped: ", problem.directory, " \u2014 ", problem.reason] }, problem.directory))), info.commandProblems.map((problem) => (_jsxs(Text, { color: visualColor.warning, children: ["command skipped: ", problem.file, " \u2014 ", problem.reason] }, problem.file))), info.agentProblems.map((problem) => (_jsxs(Text, { color: visualColor.warning, children: ["agent skipped: ", problem.file, " \u2014 ", problem.reason] }, problem.file))), _jsx(Text, { dimColor: true, children: stashHint('/ for actions · @ for paths · ctrl+c cancels · /exit quits', draftStashed, columns) })] }));
3149
+ (instructions.truncated ? (_jsx(Text, { color: visualColor.warning, children: formatInstructionsLoadedRow(instructions) })) : (_jsx(Text, { dimColor: true, children: formatInstructionsLoadedRow(instructions) }))), info.projectInstructionsProblem !== undefined && (_jsx(Text, { color: visualColor.warning, children: formatInstructionsProblemRow(info.projectInstructionsProblemFile ?? AGENTS_FILENAME, info.projectInstructionsProblem) })), info.systemPromptSource === 'config' && (_jsxs(Text, { dimColor: true, children: ["system prompt: overridden by ", DARWIN_DIRNAME, "/", CONFIG_FILENAME] })), info.systemPromptSource === 'file' && (_jsxs(Text, { dimColor: true, children: ["system prompt: ", DARWIN_DIRNAME, "/", SYSTEM_PROMPT_FILENAME] })), info.systemPromptProblem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["system prompt: using the default \u2014 ", info.systemPromptProblem] })), info.workingContextProblem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["working context: no directory listing \u2014 ", info.workingContextProblem] })), info.promptCache.problem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["prompt cache: off \u2014 ", info.promptCache.problem] })), runtime.thinking.problem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["thinking: ", runtime.thinking.problem] })), hasCapabilities(info) && (_jsxs(Text, { dimColor: true, children: ["loaded: ", formatCapabilities(info), " \u00B7 type / for commands"] })), info.mcpIgnoredConfigPath !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["mcp: using ", DARWIN_DIRNAME, "/", MCP_CONFIG_FILENAME, " \u2014 ", info.mcpIgnoredConfigPath, " ignored"] })), info.hookShadowNotices.map((notice) => (_jsxs(Text, { color: visualColor.warning, wrap: "truncate-end", children: ["hooks: ", notice.layer, " ", notice.directory, " shadows ", notice.shadowed.join(', ')] }, notice.directory))), info.skillProblems.map((problem) => (_jsxs(Text, { color: visualColor.warning, children: ["skill skipped: ", problem.directory, " \u2014 ", problem.reason] }, problem.directory))), info.commandProblems.map((problem) => (_jsxs(Text, { color: visualColor.warning, children: ["command skipped: ", problem.file, " \u2014 ", problem.reason] }, problem.file))), info.mcpPromptProblems.slice(0, MAX_MCP_PROMPT_PROBLEM_ROWS).map((problem, index) => (_jsx(Text, { color: visualColor.warning, wrap: "truncate-end", children: searchPreview(problem) }, `mcp-prompt-${index}`))), info.mcpPromptProblems.length > MAX_MCP_PROMPT_PROBLEM_ROWS && (_jsxs(Text, { color: visualColor.warning, wrap: "truncate-end", children: ["\u2026 ", info.mcpPromptProblems.length - MAX_MCP_PROMPT_PROBLEM_ROWS, " more MCP prompt problems \u2014 /mcp shows per-server counts"] })), info.agentProblems.map((problem) => (_jsxs(Text, { color: visualColor.warning, children: ["agent skipped: ", problem.file, " \u2014 ", problem.reason] }, problem.file))), _jsx(Text, { dimColor: true, children: stashHint('/ for actions · @ for paths · ctrl+c cancels · /exit quits', draftStashed, columns) })] }));
2977
3150
  }
2978
3151
  const WORKING_LABEL = 'working';
3152
+ /** Startup header rows for MCP prompt problems before one `… N more` row (SER-114). */
3153
+ const MAX_MCP_PROMPT_PROBLEM_ROWS = 3;
2979
3154
  /** Highlights one letter in place, preserving the header's exact width and row count. */
2980
3155
  export function workingStatusIndex(frame) {
2981
3156
  return frame % WORKING_LABEL.length;