@0perator/operator 0.1.352 → 0.1.354

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 (92) hide show
  1. package/dist/acp/agent.js +4 -2
  2. package/dist/acp/tool-map.js +5 -4
  3. package/dist/autonomy/delegate.js +55 -2
  4. package/dist/autonomy/headless.js +4 -1
  5. package/dist/autonomy/session-factory.js +1 -0
  6. package/dist/background/index.js +86 -10
  7. package/dist/background/notices.js +16 -4
  8. package/dist/cli.js +1072 -178
  9. package/dist/config/home.js +6 -0
  10. package/dist/config/memory-sections.js +92 -0
  11. package/dist/config/persona.js +144 -26
  12. package/dist/config/settings.js +15 -4
  13. package/dist/consolidation/scheduler.js +9 -2
  14. package/dist/consolidation/sleep.js +39 -278
  15. package/dist/engine/agent.js +547 -92
  16. package/dist/engine/anthropic-chat.js +13 -2
  17. package/dist/engine/aurora.js +135 -30
  18. package/dist/engine/batch-scheduler.js +27 -3
  19. package/dist/engine/compaction.js +12 -5
  20. package/dist/engine/continuation.js +51 -22
  21. package/dist/engine/contract.js +1 -1
  22. package/dist/engine/decision-points.js +7 -1
  23. package/dist/engine/front-door.js +59 -0
  24. package/dist/engine/grandmaster.js +13 -1
  25. package/dist/engine/loop-guard.js +694 -0
  26. package/dist/engine/net-error.js +2 -1
  27. package/dist/engine/owner-act.js +52 -0
  28. package/dist/engine/selfheal.js +48 -0
  29. package/dist/engine/verify-gate.js +52 -0
  30. package/dist/flywheel/processor.js +3 -1
  31. package/dist/flywheel/srft.js +8 -4
  32. package/dist/hooks/index.js +12 -8
  33. package/dist/mcp/index.js +9 -4
  34. package/dist/permissions/index.js +32 -11
  35. package/dist/permissions/modes.js +42 -0
  36. package/dist/permissions/plan-review.js +100 -0
  37. package/dist/permissions/policy.js +16 -5
  38. package/dist/permissions/signature.js +8 -3
  39. package/dist/remote/safe-commands.js +1 -1
  40. package/dist/router/read-rates.js +152 -0
  41. package/dist/selfimprove/backfill.js +174 -0
  42. package/dist/selfimprove/index.js +146 -57
  43. package/dist/selfimprove/lessons.js +429 -0
  44. package/dist/selfimprove/sync.js +58 -0
  45. package/dist/session.js +375 -31
  46. package/dist/skills/finder.js +219 -0
  47. package/dist/tools/deferred.js +28 -18
  48. package/dist/tools/executor.js +7 -3
  49. package/dist/tools/registry.js +34 -4
  50. package/dist/ui/ActivitySpinner.js +21 -12
  51. package/dist/ui/App.js +107 -30
  52. package/dist/ui/ApprovalPrompt.js +5 -3
  53. package/dist/ui/ArtifactPicker.js +3 -3
  54. package/dist/ui/BgPanel.js +105 -5
  55. package/dist/ui/Composer.js +85 -9
  56. package/dist/ui/PlanPane.js +72 -8
  57. package/dist/ui/QuestionPrompt.js +6 -4
  58. package/dist/ui/SecretPrompt.js +8 -3
  59. package/dist/ui/SessionPicker.js +2 -2
  60. package/dist/ui/SkillFinder.js +153 -0
  61. package/dist/ui/StatusRule.js +5 -2
  62. package/dist/ui/SummaryCard.js +3 -1
  63. package/dist/ui/ThinkingSpinner.js +11 -2
  64. package/dist/ui/ToolBatch.js +11 -2
  65. package/dist/ui/ToolStep.js +36 -13
  66. package/dist/ui/Transcript.js +13 -2
  67. package/dist/ui/actNow.js +61 -0
  68. package/dist/ui/batchLine.js +165 -0
  69. package/dist/ui/conversations.js +154 -0
  70. package/dist/ui/decodeHealth.js +77 -0
  71. package/dist/ui/expand.js +17 -0
  72. package/dist/ui/fit.js +40 -0
  73. package/dist/ui/fitTail.js +14 -0
  74. package/dist/ui/fold.js +149 -0
  75. package/dist/ui/format.js +46 -2
  76. package/dist/ui/liveTools.js +163 -13
  77. package/dist/ui/modelPicker.js +78 -6
  78. package/dist/ui/nextStep.js +103 -0
  79. package/dist/ui/pending.js +57 -0
  80. package/dist/ui/phase.js +105 -0
  81. package/dist/ui/planExit.js +0 -5
  82. package/dist/ui/progressbar.js +4 -26
  83. package/dist/ui/readForecast.js +44 -0
  84. package/dist/ui/readProgress.js +119 -0
  85. package/dist/ui/reportLine.js +62 -0
  86. package/dist/ui/slashCommands.js +1 -1
  87. package/dist/ui/theme.js +1 -0
  88. package/dist/ui/turnFlow.js +72 -0
  89. package/dist/ui/turnLedger.js +121 -0
  90. package/dist/ui/turnScope.js +11 -0
  91. package/dist/util/slash.js +18 -0
  92. package/package.json +1 -1
@@ -1,7 +1,10 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  import { theme } from "./theme.js";
4
- import { bar } from "./chart.js";
4
+ import { termCols } from "./term.js";
5
+ import { cellWidth, truncateToWidth } from "./StatusRule.js";
6
+ import { fitSegments, seg } from "./fit.js";
7
+ import { fmtElapsed } from "./format.js";
5
8
  const GLYPH = { pending: "☐", in_progress: "◐", done: "☑", cancelled: "⊘" };
6
9
  const COLOR = { pending: theme.muted, in_progress: theme.running, done: theme.success, cancelled: theme.muted };
7
10
  const finished = (t) => t.status === "done" || t.status === "cancelled";
@@ -31,18 +34,79 @@ export function visiblePlan(tasks, max = PLAN_MAX_ROWS) {
31
34
  const shown = tasks.filter((t) => pick.has(t));
32
35
  return { shown, hidden: tasks.length - shown.length };
33
36
  }
34
- export function PlanPane({ tasks, title = "plan" }) {
37
+ /** A step's measured time: the time it was worked (registry.ts taskUpdate's activeMs, plus the stretch in progress up to
38
+ * `now`); a stretch it sat demoted to pending while another step ran does not count (review F6). Pending or never
39
+ * started → nothing. A task without work stamps (an older store) falls back to its span. */
40
+ export function stepMs(t, now) {
41
+ if (t.startedAt === undefined || t.status === "pending")
42
+ return undefined;
43
+ if (t.activeMs !== undefined || t.activeSince !== undefined) {
44
+ const open = t.status === "in_progress" && t.activeSince !== undefined ? now - t.activeSince : 0;
45
+ return Math.max(0, (t.activeMs ?? 0) + open);
46
+ }
47
+ if (finished(t))
48
+ return t.endedAt !== undefined ? Math.max(0, t.endedAt - t.startedAt) : undefined;
49
+ return Math.max(0, now - t.startedAt);
50
+ }
51
+ /** Narrow thresholds: the duration column leaves below 70 cols; below 50 the pane is one line. */
52
+ export const PLAN_DURATION_MIN_COLS = 70;
53
+ export const PLAN_ONE_LINE_COLS = 50;
54
+ const DUR_W = 7; // "21m 5s" plus a cell
55
+ const LEAD = 4; // paddingLeft + glyph (counted wide, as cellWidth does) + space
56
+ /** One row (pure): the step text clipped to fit, and its measured time right-aligned so the row ends at cols−1. */
57
+ export function planRow(t, cols, now) {
58
+ const avail = cols - 1 - LEAD;
59
+ const withDur = cols >= PLAN_DURATION_MIN_COLS;
60
+ const ms = withDur ? stepMs(t, now) : undefined;
61
+ const dur = ms !== undefined ? fmtElapsed(ms) : "";
62
+ const text = truncateToWidth(t.text, withDur ? avail - DUR_W - 1 : avail);
63
+ return { text, pad: dur ? " ".repeat(Math.max(1, avail - cellWidth(text) - cellWidth(dur))) : "", dur };
64
+ }
65
+ /** The pane as one line under PLAN_ONE_LINE_COLS: "plan 2/7 · ◐ Wire the fallback…". */
66
+ export function planOneLine(tasks, cols) {
67
+ const done = tasks.filter((t) => t.status === "done").length;
68
+ const cur = tasks.find((t) => t.status === "in_progress") ?? tasks.find((t) => t.status === "pending");
69
+ return fitSegments([seg(`plan ${done}/${tasks.length}`), ...(cur ? [seg(`${GLYPH[cur.status]} ${cur.text}`)] : [])], cols, { lead: " " });
70
+ }
71
+ /** The spinner verb while a step is being worked: "Step 3/7 · Wire the fallback into buildRouter". */
72
+ export function planVerb(tasks) {
73
+ const i = tasks.findIndex((t) => t.status === "in_progress");
74
+ return i < 0 ? undefined : `Step ${i + 1}/${tasks.length} · ${tasks[i].text}`;
75
+ }
76
+ /** The one Static line when the last open step lands: counts, the wall time from the first start to the last end, and
77
+ * the longest step — every number a timestamp the task store recorded. */
78
+ export function planReceipt(tasks, cols) {
79
+ const done = tasks.filter((t) => t.status === "done").length;
80
+ const cancelled = tasks.filter((t) => t.status === "cancelled").length;
81
+ const starts = tasks.map((t) => t.startedAt).filter((x) => x !== undefined);
82
+ const ends = tasks.map((t) => t.endedAt).filter((x) => x !== undefined);
83
+ const wall = starts.length && ends.length ? Math.max(...ends) - Math.min(...starts) : undefined;
84
+ let longest;
85
+ for (const t of tasks)
86
+ if ((stepMs(t, 0) ?? -1) > (longest ? stepMs(longest, 0) ?? -1 : -1))
87
+ longest = t;
88
+ const counts = cancelled ? `${done}/${tasks.length} done, ${cancelled} cancelled,` : `${done}/${tasks.length} steps`;
89
+ return fitSegments([
90
+ seg(wall !== undefined ? [`plan complete · ${counts} in ${fmtElapsed(wall)}`, `plan complete · ${counts.replace(/,$/, "")}`] : `plan complete · ${counts.replace(/,$/, "")}`, 2, true),
91
+ ...(longest && stepMs(longest, 0) !== undefined ? [seg(`longest: ${longest.text} (${fmtElapsed(stepMs(longest, 0))})`, 3)] : []),
92
+ ], cols, { lead: "☑ " });
93
+ }
94
+ export function PlanPane({ tasks, title = "plan", now = Date.now() }) {
35
95
  if (!tasks.length)
36
96
  return null;
37
97
  // A fully-completed plan clears itself — once every step is done it has no live value and shouldn't keep
38
- // occupying the frame. The per-step ✓ already showed as each landed; the finished list drops away.
98
+ // occupying the frame. The per-step ✓ already showed as each landed; cli.tsx settles one receipt line instead.
39
99
  if (tasks.every(finished))
40
100
  return null;
101
+ const cols = termCols();
102
+ if (cols < PLAN_ONE_LINE_COLS)
103
+ return _jsx(Text, { dimColor: true, children: planOneLine(tasks, cols) });
41
104
  // Borderless: this pane renders in Ink's DYNAMIC region; a box border there orphans its rows into
42
105
  // scrollback whenever the Static transcript grows during a long turn (the v0.1.92 line-flood). The
43
106
  // dim header labels the group without a border.
44
- return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsxs(Text, { dimColor: true, children: [`${title} · ${planProgress(tasks)} `, _jsx(Text, { color: theme.success, children: bar(tasks.filter((t) => t.status === "done").length, tasks.length, 8) })] }), (() => {
45
- const { shown, hidden } = visiblePlan(tasks);
46
- return (_jsxs(_Fragment, { children: [shown.map((t) => (_jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: COLOR[t.status], children: [GLYPH[t.status], " "] }), _jsx(Text, { dimColor: finished(t), strikethrough: finished(t), children: t.text })] }, t.id))), hidden > 0 ? _jsx(Text, { dimColor: true, children: ` +${hidden} more` }) : null] }));
47
- })()] }));
107
+ const { shown, hidden } = visiblePlan(tasks);
108
+ return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsx(Text, { dimColor: true, children: `${title} · ${planProgress(tasks)}` }), shown.map((t) => {
109
+ const { text, pad, dur } = planRow(t, cols, now);
110
+ return (_jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: COLOR[t.status], children: [GLYPH[t.status], " "] }), _jsx(Text, { dimColor: finished(t), strikethrough: finished(t), children: text }), dur ? _jsxs(Text, { dimColor: true, children: [pad, dur] }) : null] }, t.id));
111
+ }), hidden > 0 ? _jsx(Text, { dimColor: true, children: ` +${hidden} more` }) : null] }));
48
112
  }
@@ -84,7 +84,9 @@ export function questionKey(st, input, key, options, multiSelect = false) {
84
84
  return { state: { mode: "type", buffer: "", highlight: options.length, selected: st.selected } }; // open the free-text line
85
85
  return {};
86
86
  }
87
- export function QuestionPrompt({ pending }) {
87
+ /** `suspended`: another surface owns the keyboard (an overlay open over it, App.tsx) — drawn, with `waiting` saying how to
88
+ * reach it, and never answered by that surface's keys. */
89
+ export function QuestionPrompt({ pending, suspended = false, waiting }) {
88
90
  const multi = !!pending?.multiSelect;
89
91
  const [st, setSt] = useState({ mode: "choose", buffer: "", highlight: 0, selected: multi ? [] : undefined });
90
92
  const qRef = useRef(null);
@@ -104,7 +106,7 @@ export function QuestionPrompt({ pending }) {
104
106
  pending.resolve(a.resolve, a.index);
105
107
  else if (a.state)
106
108
  setSt(a.state);
107
- }, { isActive: !!pending });
109
+ }, { isActive: !!pending && !suspended });
108
110
  // Click-to-select (hooks run every render → compute before the early return). The question can WRAP, so
109
111
  // its height is measured rather than assumed; options + the chat escape are the clickable rows (1 line
110
112
  // each). A click moves the highlight — Enter still commits — so a mis-anchored click is visibly correctable.
@@ -119,12 +121,12 @@ export function QuestionPrompt({ pending }) {
119
121
  const headerLines = 1 /* marginTop */ + 1 /* top border */ + qLines;
120
122
  useClickList({
121
123
  id: "question-list",
122
- active: !!pending && st.mode === "choose",
124
+ active: !!pending && !suspended && st.mode === "choose",
123
125
  headerLines, rowHeight: 1, windowStart: 0, visibleCount: optCount,
124
126
  onPick: (idx) => setSt((s) => ({ ...s, mode: "choose", highlight: idx })),
125
127
  });
126
128
  if (!pending)
127
129
  return null;
128
130
  const chatIndex = pending.options.length; // 0-based highlight index for the chat escape
129
- return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsx(Box, { ref: qRef, children: _jsxs(Text, { color: "cyan", bold: true, children: ["? ", _jsx(Text, { color: "white", children: pending.question })] }) }), pending.options.map((o, i) => (_jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === i ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsx(Text, { color: "cyan", children: multi ? (st.selected?.includes(i) ? "[x]" : "[ ]") : `[${i + 1}]` }), " ", _jsx(Text, { bold: st.mode === "choose" && st.highlight === i, children: o })] }, i))), _jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === chatIndex ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsxs(Text, { color: "cyan", children: ["[", chatIndex + 1, "]"] }), " ", _jsx(Text, { color: "magenta", bold: st.mode === "choose" && st.highlight === chatIndex, children: CHAT_LABEL })] }), st.mode === "type" ? (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "› " }), st.buffer, _jsx(Text, { color: "cyan", children: "\u258C" })] }), _jsx(Text, { dimColor: true, children: " type your reply · Enter to send · Esc for the menu" })] })) : multi ? (_jsxs(Text, { dimColor: true, children: [" ↑/↓ to move · Space (or 1-", chatIndex, ") to toggle · Enter to confirm · ", chatIndex + 1, " to type your own · Esc to close"] })) : (_jsxs(Text, { dimColor: true, children: [" ↑/↓ to move · Enter to pick · or press 1-", chatIndex + 1, " to jump · Esc to close"] }))] }));
131
+ return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsx(Box, { ref: qRef, children: _jsxs(Text, { color: "cyan", bold: true, children: ["? ", _jsx(Text, { color: "white", children: pending.question })] }) }), pending.options.map((o, i) => (_jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === i ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsx(Text, { color: "cyan", children: multi ? (st.selected?.includes(i) ? "[x]" : "[ ]") : `[${i + 1}]` }), " ", _jsx(Text, { bold: st.mode === "choose" && st.highlight === i, children: o })] }, i))), _jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === chatIndex ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsxs(Text, { color: "cyan", children: ["[", chatIndex + 1, "]"] }), " ", _jsx(Text, { color: "magenta", bold: st.mode === "choose" && st.highlight === chatIndex, children: CHAT_LABEL })] }), suspended ? (_jsx(Text, { dimColor: true, children: " waiting · " + (waiting ?? "another prompt has the keyboard") })) : st.mode === "type" ? (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "› " }), st.buffer, _jsx(Text, { color: "cyan", children: "\u258C" })] }), _jsx(Text, { dimColor: true, children: " type your reply · Enter to send · Esc for the menu" })] })) : multi ? (_jsxs(Text, { dimColor: true, children: [" ↑/↓ to move · Space (or 1-", chatIndex, ") to toggle · Enter to confirm · ", chatIndex + 1, " to type your own · Esc to close"] })) : (_jsxs(Text, { dimColor: true, children: [" ↑/↓ to move · Enter to pick · or press 1-", chatIndex + 1, " to jump · Esc to close"] }))] }));
130
132
  }
@@ -15,9 +15,14 @@ const TERMINAL_REPORT = /\x1b?\[<\d+;\d+;\d+[Mm]|\x1b?\[\d+;\d+R/g;
15
15
  const NOT_KEY = /[\s\x00-\x1f\x7f]/g;
16
16
  // Mask cells drawn at most: a 100+ character key stays on one line of an 80-column box; the count says the rest.
17
17
  export const MASK_MAX = 32;
18
+ /** One input chunk without what the terminal wrapped around it or sent of its own (paste markers, mouse and cursor
19
+ * reports) — the text the owner typed or pasted. */
20
+ export function typedText(input) {
21
+ return input.replace(PASTE_MARKER, "").replace(TERMINAL_REPORT, "");
22
+ }
18
23
  /** The characters of one input chunk that belong to the key. */
19
24
  export function secretChars(input) {
20
- return input.replace(PASTE_MARKER, "").replace(TERMINAL_REPORT, "").replace(NOT_KEY, "");
25
+ return typedText(input).replace(NOT_KEY, "");
21
26
  }
22
27
  /** Pure keystroke reducer (no React, no I/O), like questionKey: the next value, the value to store (Enter), or a cancel
23
28
  * (Esc / ctrl+c). ctrl+u clears; Enter on an empty value does nothing. */
@@ -39,7 +44,7 @@ export function secretKey(value, input, key) {
39
44
  export function maskFor(length) {
40
45
  return "•".repeat(Math.min(length, MASK_MAX));
41
46
  }
42
- export function SecretPrompt({ pending }) {
47
+ export function SecretPrompt({ pending, suspended = false }) {
43
48
  // A ref, not state: a paste can land as several chunks (with Enter right behind them) before React re-renders, and
44
49
  // each must extend what the last one typed. `size` is all the render ever sees.
45
50
  const valueRef = useRef("");
@@ -70,7 +75,7 @@ export function SecretPrompt({ pending }) {
70
75
  valueRef.current = a.value;
71
76
  setSize(a.value.length);
72
77
  }
73
- }, { isActive: !!pending });
78
+ }, { isActive: !!pending && !suspended });
74
79
  if (!pending)
75
80
  return null;
76
81
  return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: ["? ", _jsx(Text, { color: "white", children: pending.title })] }), _jsxs(Text, { children: [" ", _jsx(Text, { color: "magenta", children: "› " }), maskFor(size), _jsx(Text, { color: "cyan", children: "\u258C" }), size ? _jsx(Text, { dimColor: true, children: ` ${size} characters` }) : null] }), _jsx(Text, { dimColor: true, children: " Enter to store · Esc to cancel · ctrl+u to clear — the key is never shown or logged" })] }));
@@ -49,7 +49,7 @@ function windowFor(n, hi) {
49
49
  const start = Math.max(0, Math.min(hi - Math.floor(VISIBLE / 2), n - VISIBLE));
50
50
  return { start, end: start + VISIBLE };
51
51
  }
52
- export function SessionPicker({ pending }) {
52
+ export function SessionPicker({ pending, suspended = false }) {
53
53
  const [st, setSt] = useState({ scope: "all", query: "", highlight: 0 });
54
54
  const wasOpen = useRef(false);
55
55
  useEffect(() => {
@@ -74,7 +74,7 @@ export function SessionPicker({ pending }) {
74
74
  }
75
75
  else if (a.intent)
76
76
  pending.onIntent(a.intent);
77
- }, { isActive: !!pending });
77
+ }, { isActive: !!pending && !suspended });
78
78
  if (!pending)
79
79
  return null;
80
80
  const { loading, error, note } = pending;
@@ -0,0 +1,153 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // ctrl+g — the skills and tools finder (TUI A3.3, James's change): search as you type across your profile, the Operator
3
+ // catalogue, Operator's tools and the AXE skills hub (65K+ skills), preview the highlighted one, use it (activate a
4
+ // skill, or ask for a tool), run it with your words as the task, or create a new skill. Same shape as SessionPicker: a
5
+ // pure keystroke reducer (tested without a TTY) + useInput gated while open, a bordered box above the composer, one
6
+ // fixed height for as long as it is open.
7
+ import { useEffect, useRef, useState } from "react";
8
+ import { Box, Text, useInput } from "ink";
9
+ import { skillSlug } from "../skills/finder.js";
10
+ import { fitSegments, seg } from "./fit.js";
11
+ import { fitWithTail } from "./fitTail.js";
12
+ import { termCols } from "./term.js";
13
+ import { typedText } from "./SecretPrompt.js";
14
+ export const FINDER_ROWS = 7;
15
+ const PREVIEW_ROWS = 4;
16
+ /** A typed or pasted chunk as one-line field text: the paste markers and terminal reports out (review F9), line breaks
17
+ * and other control characters as spaces. */
18
+ const fieldText = (input) => typedText(input).replace(/[\x00-\x1f\x7f]+/g, " ");
19
+ /** Pure keystroke reducer: the next state and/or an intent. Any query change searches again. `busy`: a ⏎ is loading —
20
+ * Esc cancels it before anything else (review F8). */
21
+ export function finderKey(st, raw, key, items, busy = false) {
22
+ if (busy && key.escape)
23
+ return { intent: { kind: "cancel" } };
24
+ const input = key.ctrl || key.meta ? raw : fieldText(raw);
25
+ const n = items.length;
26
+ const hi = Math.min(Math.max(st.highlight, 0), Math.max(0, n - 1));
27
+ const item = items[hi];
28
+ if (st.mode === "name" || st.mode === "desc") {
29
+ const field = st.mode === "name" ? "name" : "desc";
30
+ if (key.escape)
31
+ return { state: { ...st, mode: st.mode === "desc" ? "name" : "search" } };
32
+ if (key.return) {
33
+ if (st.mode === "name")
34
+ return st.name.trim() ? { state: { ...st, mode: "desc" } } : {};
35
+ return { state: { ...st, mode: "search" }, intent: { kind: "create", name: st.name, description: st.desc, draft: true } };
36
+ }
37
+ if (key.tab && st.mode === "desc")
38
+ return { state: { ...st, mode: "search" }, intent: { kind: "create", name: st.name, description: st.desc, draft: false } };
39
+ if (key.backspace || key.delete)
40
+ return { state: { ...st, [field]: st[field].slice(0, -1) } };
41
+ if (input && !key.ctrl && !key.meta)
42
+ return { state: { ...st, [field]: st[field] + input } };
43
+ return {};
44
+ }
45
+ if (key.escape) {
46
+ if (st.query) {
47
+ const next = { ...st, query: "", highlight: 0, expanded: false };
48
+ return { state: next, intent: { kind: "query", query: "" } };
49
+ }
50
+ return { intent: { kind: "close" } };
51
+ }
52
+ if (key.upArrow)
53
+ return { state: { ...st, highlight: n ? (hi <= 0 ? n - 1 : hi - 1) : 0, expanded: false } };
54
+ if (key.downArrow)
55
+ return { state: { ...st, highlight: n ? (hi >= n - 1 ? 0 : hi + 1) : 0, expanded: false } };
56
+ if (key.rightArrow)
57
+ return item ? { state: { ...st, expanded: true }, intent: { kind: "preview", item } } : {};
58
+ if (key.leftArrow)
59
+ return { state: { ...st, expanded: false } };
60
+ if (key.return)
61
+ return item ? { intent: { kind: "use", item, query: st.query } } : {};
62
+ if (key.ctrl && input === "r")
63
+ return item ? { intent: { kind: "run", item, query: st.query } } : {};
64
+ if (key.ctrl && input === "n")
65
+ return { state: { ...st, mode: "name", name: skillSlug(st.query || "new-skill"), desc: st.query } };
66
+ if (key.backspace || key.delete) {
67
+ if (!st.query)
68
+ return {};
69
+ const query = st.query.slice(0, -1);
70
+ return { state: { ...st, query, highlight: 0, expanded: false }, intent: { kind: "query", query } };
71
+ }
72
+ if (input && !key.ctrl && !key.meta) {
73
+ const query = st.query + input;
74
+ return { state: { ...st, query, highlight: 0, expanded: false }, intent: { kind: "query", query } };
75
+ }
76
+ return {};
77
+ }
78
+ const SOURCE_TAG = { profile: "profile", catalogue: "catalogue", tool: "tool", hub: "hub" };
79
+ /** One result row, fitted to `width`: name, where it is from, then as much of the description as fits. */
80
+ export function finderRow(it, selected, width) {
81
+ const tag = [SOURCE_TAG[it.source], it.origin && it.origin !== "profile" ? it.origin : "", it.verified ? "✓" : ""].filter(Boolean).join(" · ");
82
+ return fitWithTail([seg(selected ? "❯ " : " "), seg(it.name), seg(` [${tag}]`, 2)], it.description ? ` — ${it.description}` : "", width + 1, { sep: "", tailMin: 0 });
83
+ }
84
+ /** The preview block: the highlighted item's description (wrapped), or its full text after →, in PREVIEW_ROWS lines. */
85
+ export function previewLines(it, p, expanded, width) {
86
+ if (!it)
87
+ return Array.from({ length: PREVIEW_ROWS }, () => "");
88
+ let body;
89
+ if (expanded && p && p.source === it.source && p.id === it.id) {
90
+ if (p.loading)
91
+ body = ["loading the full text…"];
92
+ else if (p.error)
93
+ body = [p.error];
94
+ else
95
+ body = (p.text ?? "").replace(/^---\n[\s\S]*?\n---\n?/, "").split("\n").map((l) => l.trimEnd()).filter((l) => l.trim()).slice(0, PREVIEW_ROWS);
96
+ }
97
+ else {
98
+ const words = (it.description || "(no description)").split(/\s+/);
99
+ body = [];
100
+ let line = "";
101
+ for (const w of words) {
102
+ if ((line ? `${line} ${w}` : w).length > width - 2) {
103
+ body.push(line);
104
+ line = w;
105
+ if (body.length === PREVIEW_ROWS)
106
+ break;
107
+ }
108
+ else
109
+ line = line ? `${line} ${w}` : w;
110
+ }
111
+ if (line && body.length < PREVIEW_ROWS)
112
+ body.push(line);
113
+ }
114
+ const out = body.slice(0, PREVIEW_ROWS).map((l) => fitSegments([seg(l)], width + 1, { lead: " " }));
115
+ while (out.length < PREVIEW_ROWS)
116
+ out.push("");
117
+ return out;
118
+ }
119
+ export function SkillFinder({ pending }) {
120
+ const [st, setSt] = useState({ mode: "search", query: "", highlight: 0, name: "", desc: "", expanded: false });
121
+ const wasOpen = useRef(false);
122
+ useEffect(() => {
123
+ const open = !!pending;
124
+ if (open && !wasOpen.current)
125
+ setSt({ mode: "search", query: pending.initialQuery ?? "", highlight: 0, name: "", desc: "", expanded: false });
126
+ wasOpen.current = open;
127
+ }, [pending]);
128
+ const items = pending?.items ?? [];
129
+ const n = items.length;
130
+ const hi = Math.min(Math.max(st.highlight, 0), Math.max(0, n - 1));
131
+ useInput((input, key) => {
132
+ if (!pending)
133
+ return;
134
+ const a = finderKey(st, input, key, items, !!pending.loading);
135
+ if (a.state)
136
+ setSt(a.state);
137
+ if (a.intent)
138
+ pending.onIntent(a.intent);
139
+ }, { isActive: !!pending });
140
+ if (!pending)
141
+ return null;
142
+ const width = Math.max(30, termCols() - 4); // inside the border and padding
143
+ const start = n <= FINDER_ROWS ? 0 : Math.max(0, Math.min(hi - Math.floor(FINDER_ROWS / 2), n - FINDER_ROWS));
144
+ const shown = items.slice(start, start + FINDER_ROWS);
145
+ const pad = FINDER_ROWS - shown.length;
146
+ const creating = st.mode !== "search";
147
+ return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsx(Text, { color: "cyan", bold: true, children: fitSegments([seg("◆ Skills & tools"), seg(pending.sizes ? ` ${pending.sizes}` : "", 1)], width + 1, { sep: "" }) }), creating ? (_jsxs(_Fragment, { children: [_jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "new skill› " }), st.mode === "name" ? _jsxs(_Fragment, { children: [st.name, _jsx(Text, { color: "cyan", children: "\u258C" })] }) : st.name] }), _jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: " what for› " }), st.mode === "desc" ? _jsxs(_Fragment, { children: [st.desc, _jsx(Text, { color: "cyan", children: "\u258C" })] }) : _jsx(Text, { dimColor: true, children: st.desc || "(Enter to write what it is for)" })] })] })) : (_jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "search› " }), st.query, _jsx(Text, { color: "cyan", children: "\u258C" })] })), shown.map((it, i) => {
148
+ const sel = start + i === hi && !creating;
149
+ return _jsx(Text, { bold: sel, color: sel ? "cyan" : undefined, dimColor: !sel && it.source === "tool", children: finderRow(it, sel, width) }, `${it.source}:${it.id}`);
150
+ }), Array.from({ length: pad }, (_, i) => _jsx(Text, { children: i === 0 && n === 0 ? (st.query ? ` nothing matches "${st.query}" yet` : " type to search") : " " }, `pad${i}`)), _jsx(Text, { dimColor: true, children: fitSegments([seg(pending.status ? ` ${pending.status}` : " "), seg(n > FINDER_ROWS ? ` · ${hi + 1}/${n}` : "")], width + 1, { sep: "" }) }), previewLines(creating ? undefined : items[hi], pending.preview, st.expanded, width).map((l, i) => _jsx(Text, { dimColor: !st.expanded, children: l || " " }, `pv${i}`)), pending.note ? _jsx(Text, { color: "green", children: fitSegments([seg(pending.note)], width + 1, { lead: " " }) }) : _jsx(Text, { children: " " }), _jsx(Text, { dimColor: true, children: fitSegments([seg(creating
151
+ ? (st.mode === "name" ? "name it · Enter next · Esc back" : "what it is for · Enter: I draft it with the model · Tab: save the skeleton now · Esc back")
152
+ : "type to search · ↑/↓ move · → preview · ⏎ use · ctrl+r run with your words · ctrl+n new skill · esc close")], width + 1, { lead: " " }) })] }));
153
+ }
@@ -45,6 +45,10 @@ export function truncateToWidth(s, max) {
45
45
  // which keeps the leading fill ≥ 1 and the whole line at cols-1, so the rule never becomes the line that
46
46
  // wraps (the creep bug) no matter how many badges are lit or how narrow the window.
47
47
  const ROUTE_LABELS = { "operator-1m": "aurora" };
48
+ /** The model as the owner reads it everywhere ("cortana"; the default operator-1m reads "aurora"). */
49
+ export function routeLabel(route) {
50
+ return ROUTE_LABELS[route] ?? route;
51
+ }
48
52
  export function statusRight(p, cols) {
49
53
  const who = p.user ? `◆ ${p.user} · ` : "";
50
54
  const seat = p.tier && p.tier !== "admin" ? `⛨ ${p.tier} · ` : ""; // a narrowed seat shows; owner's admin doesn't
@@ -55,9 +59,8 @@ export function statusRight(p, cols) {
55
59
  // Show the active model (cortana, claude-opus, moa, custom …) and the window it runs on, never the leg that answered
56
60
  // ("cortana@192.168.1.103:8112" read as noise; /endpoints lists the legs). The default model reads as "aurora", not
57
61
  // its id operator-1m (owner, 11/03: "just aurora 300k"), and the window is the one served, not a pin above it.
58
- const routeLabel = ROUTE_LABELS[p.route] ?? p.route;
59
62
  const window = p.ctxWindow ? ` ${p.ctxWindow}` : "";
60
- let info = `${think}${plan}${seat}${who}${routeLabel}${window} ${ring(p.ctxPct)} ${Math.round(p.ctxPct)}% · ${tok}v${p.version}${p.build ? ` ·${p.build}` : ""}`;
63
+ let info = `${think}${plan}${seat}${who}${routeLabel(p.route)}${window} ${ring(p.ctxPct)} ${Math.round(p.ctxPct)}% · ${tok}v${p.version}${p.build ? ` ·${p.build}` : ""}`;
61
64
  let right = `✷ OPERATOR · ${info} ─`;
62
65
  const maxRight = cols - 3; // leaves fill ≥ 1 and total = cols-1
63
66
  if (cellWidth(right) > maxRight) {
@@ -1,6 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  import { theme } from "./theme.js";
4
+ import { termCols } from "./term.js";
5
+ import { ledgerLines, repetitionLine } from "./turnLedger.js";
4
6
  const fmtDur = (ms) => (ms < 1000 ? `${Math.round(ms)}ms` : ms < 60_000 ? `${(ms / 1000).toFixed(1)}s` : `${Math.floor(ms / 60_000)}m ${Math.round((ms % 60_000) / 1000)}s`);
5
7
  const fmtTok = (n) => (n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`);
6
8
  /** The metrics line (pure) — kept separate so the exact layout is unit-testable without a render. */
@@ -14,5 +16,5 @@ export function summaryLine(s) {
14
16
  return parts.join(" · ");
15
17
  }
16
18
  export function SummaryCard({ summary }) {
17
- return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: theme.accent, children: "\u2726 " }), _jsx(Text, { bold: true, children: "turn complete" }), _jsx(Text, { dimColor: true, children: ` ${summaryLine(summary)}` })] }), summary.unverified ? (_jsx(Text, { color: theme.warn, children: "\u26A0 changed files \u00B7 not verified (no passing check ran)" })) : null] }));
19
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: theme.accent, children: "\u2726 " }), _jsx(Text, { bold: true, children: "turn complete" }), _jsx(Text, { dimColor: true, children: ` ${summaryLine(summary)}` })] }), summary.time ? ledgerLines(summary.time, summary.time, termCols() - 5).map((l, i) => (_jsxs(Text, { dimColor: true, children: [" ", _jsx(Text, { color: i === 0 ? theme.info : undefined, children: l.slice(0, 4) }), l.slice(4)] }, `t${i}`))) : null, summary.lastRound ? _jsx(Text, { dimColor: true, children: " " + repetitionLine(summary.lastRound.chars, summary.lastRound.ms, termCols() - 6) }) : null, summary.unverified ? (_jsx(Text, { color: theme.warn, children: "\u26A0 changed files \u00B7 not verified (no passing check ran)" })) : null] }));
18
20
  }
@@ -7,6 +7,8 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
7
7
  import { useEffect, useState } from "react";
8
8
  import { Box, Text } from "ink";
9
9
  import { ShimmerText, PEARL } from "./shimmer.js";
10
+ import { termCols } from "./term.js";
11
+ import { cellWidth, truncateToWidth } from "./StatusRule.js";
10
12
  const DEFAULT_VERBS = [
11
13
  "Thinking", "Reasoning", "Noodling", "Synthesizing", "Percolating", "Untangling", "Weighing",
12
14
  ];
@@ -41,6 +43,13 @@ export function expandStar(frames = FRAMES) {
41
43
  return out;
42
44
  }
43
45
  const SEQUENCE = expandStar();
46
+ const GLYPH_CELLS = 3; // the widest star frame counted wide, plus its space — constant, so a tick never reflows the row
47
+ /** The verb with its ellipsis, clipped to the width left after the star and the metrics: a long plan step
48
+ * ("Step 3/7 · Wire the fallback into buildRouter") never wraps the row (TUI plan #5). Pure. */
49
+ export function spinnerLabel(label, cols, metrics) {
50
+ const room = cols - 1 - GLYPH_CELLS - (metrics ? 2 + cellWidth(metrics) : 0);
51
+ return cellWidth(`${label}…`) <= room ? `${label}…` : truncateToWidth(label, room);
52
+ }
44
53
  export function ThinkingSpinner({ active, verb, verbs = DEFAULT_VERBS, verbIntervalMs = 2000, tickMs = 150, // 150ms (~7fps): the star still reads as animated, but each tick re-renders the whole inline frame — the dominant streaming-phase driver, kept slow to reduce flashing
45
54
  metrics, }) {
46
55
  const [tick, setTick] = useState(0);
@@ -61,8 +70,8 @@ metrics, }) {
61
70
  return null;
62
71
  const [tone, glyph] = SEQUENCE[tick];
63
72
  const style = TONE_STYLE[tone];
64
- const label = verb ?? verbs[verbIdx % verbs.length];
73
+ const label = spinnerLabel(verb ?? verbs[verbIdx % verbs.length], termCols(), metrics);
65
74
  // Star keeps its amber tone animation; the VERB now carries a pearl (slate→white) shimmer sweep driven by the
66
75
  // same tick — the continuous light replaces the old tone-flash as the "alive" cue.
67
- return (_jsxs(Box, { children: [_jsxs(Text, { color: style.color, bold: style.bold, dimColor: style.dim, children: [glyph, " "] }), _jsx(ShimmerText, { text: `${label}…`, frame: tick, palette: PEARL }), metrics ? _jsx(Text, { dimColor: true, children: " " + metrics }) : null] }));
76
+ return (_jsxs(Box, { children: [_jsxs(Text, { color: style.color, bold: style.bold, dimColor: style.dim, children: [glyph, " "] }), _jsx(ShimmerText, { text: label, frame: tick, palette: PEARL }), metrics ? _jsx(Text, { dimColor: true, children: " " + metrics }) : null] }));
68
77
  }
@@ -2,11 +2,20 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  import { theme } from "./theme.js";
4
4
  import { ToolStep } from "./ToolStep.js";
5
+ import { termCols } from "./term.js";
6
+ import { batchChips } from "./batchLine.js";
7
+ import { KIND_HUE, toolKind } from "./toolicons.js";
5
8
  const fmtDur = (ms) => ms < 1000 ? `${Math.round(ms)}ms` : ms < 60_000 ? `${(ms / 1000).toFixed(1)}s` : `${Math.floor(ms / 60_000)}m ${Math.round((ms % 60_000) / 1000)}s`;
6
9
  /** The batch header (pure) — kept separate so the exact wording/layout is unit-testable without a render. */
7
10
  export function batchHeader(count, durationMs) {
8
11
  return `${count} tools in parallel · ${fmtDur(durationMs)}`;
9
12
  }
10
- export function ToolBatch({ steps, durationMs }) {
11
- return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: theme.accent, children: "\u21C9 " }), _jsx(Text, { bold: true, children: `${steps.length} tools in parallel` }), _jsx(Text, { dimColor: true, children: ` ${fmtDur(durationMs)}` })] }), steps.map((step) => _jsx(ToolStep, { step: step }, step.id))] }));
13
+ const TONE = { done: theme.success, error: theme.error, blocked: theme.blocked, cancelled: theme.muted };
14
+ export function ToolBatch({ steps, durationMs, expanded }) {
15
+ if (expanded) {
16
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: theme.accent, children: "\u21C9 " }), _jsx(Text, { bold: true, children: `${steps.length} tools in parallel` }), _jsx(Text, { dimColor: true, children: ` ${fmtDur(durationMs)}` })] }), steps.map((step) => _jsx(ToolStep, { step: step }, step.id))] }));
17
+ }
18
+ const { head, chips, folded, hint } = batchChips(steps, durationMs, termCols());
19
+ const broken = steps.filter((s) => s.status === "error");
20
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: theme.accent, children: head.slice(0, 2) }), _jsx(Text, { dimColor: true, children: head.slice(2) }), chips.map((c, i) => (_jsxs(Text, { children: [" ", _jsx(Text, { color: TONE[c.tone], children: c.glyph }), " ", _jsx(Text, { color: KIND_HUE[toolKind(c.name)], children: c.label })] }, i))), folded ? _jsx(Text, { dimColor: true, children: ` ${folded}` }) : null, hint ? _jsx(Text, { color: theme.info, children: ` ${hint}` }) : null] }), broken.map((s) => _jsx(Box, { paddingLeft: 2, children: _jsx(ToolStep, { step: s }) }, s.id))] }));
12
21
  }
@@ -1,14 +1,16 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  import { formatDuration } from "./format.js";
4
4
  import { fileLink } from "./osc.js";
5
5
  import { theme } from "./theme.js";
6
6
  import { computeEditDiff } from "./editdiff.js";
7
7
  import { useTick } from "./tick.js";
8
- import { rowBackgroundHint } from "./liveTools.js";
8
+ import { rowBackgroundHint, BULK_ARGS } from "./liveTools.js";
9
9
  import { glyphFor, toolKind, KIND_HUE } from "./toolicons.js";
10
- import { renderBar, mediaEtaMs, mediaProgressFraction } from "./progressbar.js";
10
+ import { renderSweepBar } from "./progressbar.js";
11
11
  import { ShimmerText, huePalette } from "./shimmer.js";
12
+ import { foldLine } from "./fold.js";
13
+ import { termCols } from "./term.js";
12
14
  const PATH_KEYS = new Set(["path", "file", "filename"]);
13
15
  // Icon is now per ACTION (see toolicons.ts: read ▤ · write ✎ · search ◎ · shell ❯ · web ◍ · git ❖ · skill ◆ ·
14
16
  // agent ✺), animated while running; COLOR still carries the status (muted → amber → green → red).
@@ -17,10 +19,10 @@ const COLOR = { selected: theme.muted, running: theme.running, done: theme.succe
17
19
  // (never truncated), so you can always read the exact file name / path a tool wrote or read. Order matters:
18
20
  // path-like keys first.
19
21
  const KEY_ARGS = ["path", "file", "filename", "command", "cmd", "pattern", "url", "query", "workspace", "cwd", "name"];
20
- // Bulky payloads — never dumped (they'd bury the path and blow up the line); shown as a size instead.
21
- const BULK_ARGS = ["content", "text", "body", "data", "new_string", "old_string", "diff", "message"];
22
22
  const SHELL_TOOLS = new Set(["bash", "shell_exec", "shell_background"]);
23
- export function argsPreview(args) {
23
+ /** `link: false` gives the plain text (a live row clips it, and clipping an OSC-8 escape cuts it); `sizes` are a
24
+ * draft's bulk arguments by their running length, shown where the finished call shows its own. */
25
+ export function argsPreview(args, opts = {}) {
24
26
  if (!args)
25
27
  return "";
26
28
  const parts = [];
@@ -33,7 +35,7 @@ export function argsPreview(args) {
33
35
  for (const k of KEY_ARGS) {
34
36
  const v = args[k];
35
37
  if (v != null && (typeof v === "string" || typeof v === "number")) {
36
- const shown = PATH_KEYS.has(k) && typeof v === "string" ? fileLink(v) : String(v); // clickable path (OSC 8)
38
+ const shown = PATH_KEYS.has(k) && typeof v === "string" && opts.link !== false ? fileLink(v) : String(v); // clickable path (OSC 8)
37
39
  parts.push(`${k}: ${shown}`);
38
40
  seen.add(k);
39
41
  }
@@ -44,6 +46,10 @@ export function argsPreview(args) {
44
46
  parts.push(`${k}: ${args[k].length} chars`);
45
47
  seen.add(k);
46
48
  }
49
+ else if (opts.sizes?.[k] !== undefined) {
50
+ parts.push(`${k}: ${opts.sizes[k]} chars`);
51
+ seen.add(k);
52
+ }
47
53
  }
48
54
  // 3) any remaining scalar args, each individually trimmed (never at the cost of the path above).
49
55
  for (const [k, v] of Object.entries(args)) {
@@ -77,6 +83,16 @@ export function shellCommandHint(step) {
77
83
  return trimmed.length > 120 ? trimmed.slice(0, 117) + "..." : trimmed;
78
84
  }
79
85
  export function ToolStep({ step }) {
86
+ if (step.repeat)
87
+ return _jsx(FoldRow, { step: step });
88
+ return _jsx(CallRow, { step: step });
89
+ }
90
+ // A settled fold (ui/fold.ts): N more identical rounds as one counting line, ↻ in muted amber, the rest dim.
91
+ function FoldRow({ step }) {
92
+ const line = foldLine(step, termCols());
93
+ return _jsxs(Text, { children: [_jsx(Text, { color: theme.blocked, children: line.slice(0, 1) }), _jsx(Text, { dimColor: true, children: line.slice(1) })] });
94
+ }
95
+ function CallRow({ step }) {
80
96
  // ONE shared animation clock (tick.ts) drives both the per-action icon animation AND the live elapsed timer,
81
97
  // so a running row needs no setInterval of its own — this replaces N per-row 250ms timers with a single
82
98
  // ~8fps shared tick (richer motion, fewer timers). Settled rows don't subscribe, so they never re-render.
@@ -91,14 +107,21 @@ export function ToolStep({ step }) {
91
107
  // Enterprise "what changed at a glance": only on a SETTLED edit (not mid-run, not errored — the write
92
108
  // may never have landed), and only when the tool's own args are actually diffable.
93
109
  const editDiff = step.status === "done" ? computeEditDiff(step.name, step.args) : undefined;
94
- // Media-gen rows (image_generate/video_generate): the flux/video brokers report no percentage, so we
95
- // fake a determinate feel from elapsed-vs-ETA (progressbar.ts), capped at 95% until the real result
96
- // lands. Only RUNNING media rows get the bar — everything else renders exactly as before.
110
+ // Media-gen rows (image_generate/video_generate): the flux/video brokers report no percentage, so a running row
111
+ // shows a sweep beside its real elapsed clock. It used to draw elapsed ÷ a guessed ETA as a percentage — a number
112
+ // nobody measured. Only RUNNING media rows get the sweep; everything else renders exactly as before.
97
113
  const isRunningMedia = toolKind(step.name) === "media" && step.status === "running";
98
- const mediaFraction = isRunningMedia && elapsed != null ? mediaProgressFraction(elapsed, mediaEtaMs(step.name, step.args)) : undefined;
114
+ // A call that never ran reads as exactly that — ⊘ with the reason inline, no timer, no preview (TUI plan #3): a refused
115
+ // or cancelled call used to paint as a green success with the refusal text as its "output".
116
+ if (step.outcome) {
117
+ const t = stepTitle(step);
118
+ return (_jsxs(Text, { children: [_jsx(Text, { color: step.outcome === "blocked" ? theme.blocked : theme.muted, bold: true, children: "\u2298" }), " ", _jsx(Text, { color: KIND_HUE[toolKind(step.name)], children: t.head }), t.head === "$" ? " " : "", t.body, _jsx(Text, { color: step.outcome === "blocked" ? theme.blocked : undefined, dimColor: step.outcome === "cancelled", children: step.outcome === "blocked" ? ` · blocked${step.summary ? `: ${step.summary}` : ""} · did not run` : " · cancelled · did not run" })] }));
119
+ }
99
120
  return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: step.status === "running" ? KIND_HUE[toolKind(step.name)] : COLOR[step.status], bold: true, children: glyphFor(step.name, step.status, frame) }), " ", (() => {
100
121
  const t = stepTitle(step);
101
- const head = step.status === "running" ? _jsx(ShimmerText, { text: t.head, frame: frame, palette: huePalette(KIND_HUE[toolKind(step.name)]) }) : t.head;
122
+ // The tool's name (or "$") always takes its kind's color — the same everywhere a tool row appears (TUI plan #12):
123
+ // shimmering while it runs, solid once settled; the glyph before it carries the outcome.
124
+ const head = step.status === "running" ? _jsx(ShimmerText, { text: t.head, frame: frame, palette: huePalette(KIND_HUE[toolKind(step.name)]) }) : _jsx(Text, { color: KIND_HUE[toolKind(step.name)], children: t.head });
102
125
  return _jsxs(_Fragment, { children: [head, t.head === "$" ? " " : "", t.body, t.note ? _jsx(Text, { dimColor: true, children: ` · ${t.note}` }) : null] });
103
- })(), mediaFraction != null ? (_jsxs(Text, { children: [" ", _jsx(Text, { color: theme.mediaProgress, children: renderBar(mediaFraction) }), " ", Math.round(mediaFraction * 100), "%"] })) : null, elapsed != null ? _jsxs(Text, { dimColor: true, children: [" ", formatDuration(elapsed)] }) : null, editDiff ? (_jsxs(Text, { children: [" ", _jsxs(Text, { color: theme.success, children: ["+", editDiff.added] }), " ", _jsxs(Text, { color: theme.error, children: ["-", editDiff.removed] })] })) : null] }), rowBackgroundHint(step, now) ? _jsxs(Text, { dimColor: true, children: [" ", rowBackgroundHint(step, now)] }) : null, step.summary ? step.summary.split("\n").map((l, i) => (_jsxs(Text, { dimColor: true, children: [" ", l] }, `sm${i}`))) : null, editDiff?.preview?.map((l, i) => (_jsxs(Text, { color: l.kind === "add" ? theme.success : theme.error, children: [" ", l.kind === "add" ? "+ " : "- ", l.text] }, i)))] }));
126
+ })(), isRunningMedia ? _jsxs(Text, { children: [" ", _jsx(Text, { color: theme.mediaProgress, children: renderSweepBar(frame) })] }) : null, elapsed != null ? _jsxs(Text, { dimColor: true, children: [" ", formatDuration(elapsed)] }) : null, step.exitCode !== undefined ? _jsx(Text, { color: theme.error, children: ` · exit ${step.exitCode}` }) : null, editDiff ? (_jsxs(Text, { children: [" ", _jsxs(Text, { color: theme.success, children: ["+", editDiff.added] }), " ", _jsxs(Text, { color: theme.error, children: ["-", editDiff.removed] })] })) : null] }), rowBackgroundHint(step, now) ? _jsxs(Text, { dimColor: true, children: [" ", rowBackgroundHint(step, now)] }) : null, step.summary ? step.summary.split("\n").map((l, i) => (_jsxs(Text, { dimColor: true, children: [" ", l] }, `sm${i}`))) : null, editDiff?.preview?.map((l, i) => (_jsxs(Text, { color: l.kind === "add" ? theme.success : theme.error, children: [" ", l.kind === "add" ? "+ " : "- ", l.text] }, i)))] }));
104
127
  }
@@ -12,6 +12,8 @@ import { StatsCard } from "./StatsCard.js";
12
12
  import { ToolBatch } from "./ToolBatch.js";
13
13
  import { SB_MARK, SB_IN, SB_OUT } from "./brand.js";
14
14
  import { termCols, termRows } from "./term.js";
15
+ import { reportLine } from "./reportLine.js";
16
+ import { theme } from "./theme.js";
15
17
  // In fullscreen we can't use <Static> (it targets the scrollback the alt-screen buffer hides), so render
16
18
  // the last N entries as a plain column the parent region clips to the visible height. N is generous — the
17
19
  // parent's overflow:hidden + justifyContent:flex-end shows only what fits, bottom-anchored.
@@ -104,19 +106,28 @@ function clampReasoning(s) {
104
106
  return { text: s, hidden: 0 };
105
107
  return { text: lines.slice(-REASONING_TAIL_LINES).join("\n"), hidden: lines.length - REASONING_TAIL_LINES };
106
108
  }
109
+ // A finished sub-agent's one line: the glyph in its outcome color, the name bright, the rest dim, the expand hint cyan.
110
+ function ReportRow({ agent }) {
111
+ const { tone, line, hint } = reportLine(agent, termCols());
112
+ const body = line.slice(2, hint ? line.length - hint.length : undefined);
113
+ const name = body.split(" · ")[0];
114
+ return (_jsxs(Text, { children: [_jsx(Text, { color: tone === "done" ? theme.success : tone === "stopped" ? theme.blocked : theme.error, children: line.slice(0, 2) }), _jsx(Text, { bold: true, children: name }), _jsx(Text, { dimColor: true, children: body.slice(name.length) }), hint ? _jsx(Text, { color: theme.info, children: hint }) : null] }));
115
+ }
107
116
  function renderEntry(entry, live = false) {
108
117
  if (entry.kind === "summary")
109
118
  return _jsx(SummaryCard, { summary: entry.summary });
119
+ if (entry.kind === "report")
120
+ return _jsx(ReportRow, { agent: entry.agent });
110
121
  if (entry.kind === "stats")
111
122
  return _jsx(StatsCard, { stats: entry.stats });
112
123
  if (entry.kind === "bus")
113
124
  return _jsx(BusCard, { entry: entry });
114
125
  if (entry.kind === "toolBatch")
115
- return _jsx(ToolBatch, { steps: entry.steps, durationMs: entry.durationMs });
126
+ return _jsx(ToolBatch, { steps: entry.steps, durationMs: entry.durationMs, expanded: entry.expanded });
116
127
  if (entry.kind === "message") {
117
128
  const { message } = entry;
118
129
  if (message.role === "user") {
119
- return _jsxs(Text, { children: ["❯ ", message.content] });
130
+ return _jsxs(Text, { children: ["❯ ", message.content, message.tag ? _jsx(Text, { dimColor: true, children: ` ${message.tag}` }) : null] });
120
131
  }
121
132
  if (message.role === "system") {
122
133
  return _jsx(Text, { dimColor: true, children: message.content }); // slash-command output / status notes