@0perator/operator 0.1.344 → 0.1.346

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.
@@ -5,41 +5,36 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
5
5
  // tofu (same font-safety rule as the star).
6
6
  // • StepSpinner — a tool batch is executing (braille run-spinner, cyan)
7
7
  // • OrbitSpinner — a background sub-agent is working (rotating arc, violet)
8
- import { useEffect, useRef, useState } from "react";
8
+ import { useEffect, useRef } from "react";
9
9
  import { Text } from "ink";
10
10
  import { theme } from "./theme.js";
11
11
  import { useTick } from "./tick.js";
12
12
  import { renderBar } from "./progressbar.js";
13
- function useFrame(frames, active, tickMs) {
14
- const [i, setI] = useState(0);
15
- useEffect(() => {
16
- if (!active)
17
- return;
18
- const id = setInterval(() => setI((n) => (n + 1) % frames.length), tickMs);
19
- return () => clearInterval(id);
20
- }, [active, frames, tickMs]);
21
- return frames[i];
13
+ // Every glyph advances off the ONE shared clock (tick.ts): a timer per spinner meant one full-frame redraw per
14
+ // working sub-agent per tick — the panel flashed harder with each agent added (10/31).
15
+ function useFrame(frames, active) {
16
+ return frames[useTick(active) % frames.length];
22
17
  }
23
18
  const BRAILLE = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]; // classic run-spinner
24
19
  const ORBIT = ["◜", "◠", "◝", "◞", "◡", "◟"]; // a dot orbiting a ring — "something running elsewhere"
25
20
  const SETTLE = ["◐", "◓", "◑", "◒"]; // a filling/turning disc — "adjusting, working it out" (NOT an error)
26
21
  /** Tools are executing this turn. Distinct from the star: a cyan braille run-spinner + the tool name(s). */
27
- export function StepSpinner({ active, label, tickMs = 125 }) {
28
- const glyph = useFrame(BRAILLE, active, tickMs);
22
+ export function StepSpinner({ active, label }) {
23
+ const glyph = useFrame(BRAILLE, active);
29
24
  if (!active)
30
25
  return null;
31
26
  return (_jsxs(Text, { color: theme.info, children: [glyph, " ", label ? `${label}…` : "running…"] }));
32
27
  }
33
28
  /** A background sub-agent is working. Distinct again: a violet rotating arc + the agent label. */
34
- export function OrbitSpinner({ active, label, tickMs = 120 }) {
35
- const glyph = useFrame(ORBIT, active, tickMs);
29
+ export function OrbitSpinner({ active, label }) {
30
+ const glyph = useFrame(ORBIT, active);
36
31
  if (!active)
37
32
  return null;
38
33
  return (_jsxs(Text, { color: theme.accent, children: [glyph, " ", label ?? "sub-agent working", "\u2026"] }));
39
34
  }
40
35
  /** Just the animated orbit glyph (violet), for embedding in the bg-agents list beside a working agent. */
41
- export function OrbitGlyph({ tickMs = 120 }) {
42
- return _jsx(Text, { color: theme.accent, children: useFrame(ORBIT, true, tickMs) });
36
+ export function OrbitGlyph() {
37
+ return _jsx(Text, { color: theme.accent, children: useFrame(ORBIT, true) });
43
38
  }
44
39
  /** Self-heal in progress (context compaction / reconnect). Shown INSTEAD of a raw "http 400" so a recovery
45
40
  * reads as the agent working it out, not an error — a PINK turning disc + a calm label + a PINK bar that
@@ -1,4 +1,4 @@
1
- import { jsxs as _jsxs, jsx as _jsx } 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 { OrbitGlyph } from "./ActivitySpinner.js";
4
4
  import { theme } from "./theme.js";
@@ -20,9 +20,7 @@ function metrics(a) {
20
20
  parts.push(`${(ms / 1000).toFixed(ms < 10000 ? 1 : 0)}s`);
21
21
  return parts.join(" · ");
22
22
  }
23
- // Grandmaster sub-agent line (SPEC/grandmaster-subagents.md §6a): model/lane chip +
24
- // verified badge + malformed warning. Terminals have no hover, so the verify failure
25
- // reason is shown inline (capped) instead of as a tooltip; success collapses to a bare ✓.
23
+ // Cap a string to n chars with an ellipsis (lines in the dynamic frame must never wrap).
26
24
  const cap = (s, n = 60) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);
27
25
  // Humanize a tool name into the verb an owner reads at a glance ("editing cli.py", not "file_edit cli.py").
28
26
  // Falls back to the raw name (underscores→spaces) for anything not in the table, so a new/MCP tool never
@@ -54,27 +52,40 @@ export function roundActivity(a) {
54
52
  export function missionLine(a) {
55
53
  return a.progress?.trim() || roundActivity(a);
56
54
  }
57
- function GrandmasterLine({ a }) {
58
- const hasModel = a.model != null || a.lane != null;
59
- const hasVerify = a.verified != null;
60
- if (!hasModel && !hasVerify && !a.malformed)
61
- return null;
62
- return (_jsxs(Box, { paddingLeft: 2, children: [hasModel && _jsxs(Text, { dimColor: true, children: [a.model ?? "?", a.lane != null ? ` · ${a.lane}` : ""] }), hasVerify && (_jsxs(Text, { color: a.verified ? theme.success : theme.error, children: [hasModel ? " " : "", a.verified ? "✓ verified" : `✗ unverified${a.verifyDetail ? `: ${cap(a.verifyDetail)}` : ""}`] })), a.malformed ? _jsxs(Text, { color: theme.warn, children: [(hasModel || hasVerify) ? " " : "", "\u26A0 malformed"] }) : null] }));
55
+ /** The ledger line (pure, testable): role title · model · what it has done — "wrote 2 (a.md, b.md) · read 14 · ran 3". */
56
+ export function ledgerLine(a) {
57
+ const done = [
58
+ a.written?.length ? `wrote ${a.written.length} (${a.written.slice(-2).map((p) => p.split("/").pop()).join(", ")})` : "",
59
+ a.reads ? `read ${a.reads}` : "",
60
+ a.commands ? `ran ${a.commands}` : "",
61
+ ].filter(Boolean).join(" · ");
62
+ const verify = a.verified == null ? "" : a.verified ? "✓ verified" : `✗ unverified${a.verifyDetail ? `: ${cap(a.verifyDetail, 30)}` : ""}`;
63
+ return [a.title ?? "assistant", a.model, done || (a.status === "working" ? "nothing written yet" : ""), verify, a.malformed ? "⚠ malformed" : ""]
64
+ .filter(Boolean).join(" · ");
63
65
  }
64
- // Live activity for a WORKING child (SPEC §7 observability): the tools it is running (in-flight
65
- // marked with …) and the tail of its current reasoning — so the owner sees thoughts / steps / reads
66
- // instead of a bare round counter. Both lines are dim and capped so a narrow terminal never wraps.
67
- function ActivityLines({ a }) {
68
- if (a.status !== "working")
69
- return null;
66
+ /** The third row (pure, testable): a stuck agent shows WHY and the exact commands to re-steer or stop it; a working one
67
+ * its current steps or thought; a finished one where its result went. Always exactly one line. */
68
+ export function detailLine(a) {
69
+ if (a.status === "working" && a.stuck)
70
+ return { text: `⚠ stuck: ${a.stuck} — /agents ${a.id} msg <steer> · /agents ${a.id} stop`, tone: "stuck" };
71
+ if (a.status === "idle")
72
+ return { text: "result posted — scroll up or /agents to review", tone: "dim" };
73
+ if (a.status === "stopped")
74
+ return { text: "errored — check transcript for details", tone: "dim" };
75
+ if (a.status === "queued")
76
+ return { text: "waiting for a free slot", tone: "dim" };
70
77
  const steps = a.steps ?? [];
71
- const stepLine = steps
72
- .slice(-3)
73
- .map((s) => s.name + (s.arg ? `(${s.arg})` : "") + (s.running ? " …" : ""))
74
- .join(" · ");
75
- if (!stepLine && !a.thought && !a.lastOutput)
76
- return null;
77
- return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [stepLine ? _jsxs(Text, { dimColor: true, children: ["\u21B3 ", cap(stepLine, 72)] }) : null, a.lastOutput ? _jsxs(Text, { dimColor: true, children: ["⤷ ", cap(a.lastOutput, 72)] }) : null, a.thought ? _jsxs(Text, { dimColor: true, children: ["⋮ ", cap(a.thought, 72)] }) : null] }));
78
+ const stepLine = steps.slice(-3).map((s) => s.name + (s.arg ? `(${s.arg})` : "") + (s.running ? " …" : "")).join(" · ");
79
+ const head = stepLine ? `↳ ${stepLine}` : a.thought ? `⋮ ${a.thought.replace(/^…/, "").trim()}` : "";
80
+ const tail = a.lastOutput ? `⤷ ${a.lastOutput}` : "";
81
+ return { text: [head, tail].filter(Boolean).join(" ") || "starting…", tone: "dim" };
82
+ }
83
+ // One agent = exactly THREE rows, whatever its state: name line, ledger line, detail line. A fixed height keeps Ink's
84
+ // in-place redraw anchored — rows that appeared and vanished as thoughts/outputs came and went changed the frame height
85
+ // every tick, and Ink repainted the whole frame (the flashing, 10/31).
86
+ function AgentRows({ a }) {
87
+ const d = detailLine(a);
88
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Box, { flexGrow: 1, flexShrink: 1, children: _jsxs(Text, { wrap: "truncate-end", children: [a.status === "working" ? _jsx(OrbitGlyph, {}) : _jsx(Text, { color: COLOR[a.status], children: GLYPH[a.status] }), " ", _jsx(Text, { bold: true, children: a.name ?? a.label }), a.name ? _jsx(Text, { dimColor: true, children: ` · ${cap(a.label, 40)}` }) : null, a.round != null ? ` · round ${a.round}` : "", a.status === "working" && missionLine(a) ? _jsxs(Text, { color: theme.accent, children: [" \u00B7 ", cap(missionLine(a), 36)] }) : null] }) }), _jsx(Box, { flexShrink: 0, marginLeft: 1, children: _jsx(Text, { dimColor: true, children: (() => { const m = metrics(a); const ds = DISPLAY_STATUS[a.status]; return m ? `${m} · ${ds}` : ds; })() }) })] }), _jsx(Box, { paddingLeft: 2, children: _jsx(Text, { dimColor: true, wrap: "truncate-end", children: ledgerLine(a) }) }), _jsx(Box, { paddingLeft: 2, children: d.tone === "stuck" ? _jsx(Text, { color: theme.error, wrap: "truncate-end", children: d.text }) : _jsx(Text, { dimColor: true, wrap: "truncate-end", children: cap(d.text, 110) }) })] }));
78
89
  }
79
90
  // Cap how many agent rows the DYNAMIC panel renders. Each agent is ~3 lines; a full fan-out (6–8 agents)
80
91
  // makes the non-Static frame tall AND it re-renders on every sub-agent token — so when it sits near the
@@ -125,5 +136,5 @@ export function BgPanel({ agents, jobs = [], title = "sub-agents" }) {
125
136
  // frame SHORT — BG_MAX_VISIBLE caps rows, activity lines are capped — so the box stays a few rows tall.
126
137
  // If stray border rows ever reappear on a very long turn, drop `borderStyle`/`borderColor` for the
127
138
  // borderless column (the label line alone still heads it).
128
- return (_jsxs(Box, { flexDirection: "column", marginTop: 1, borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsx(Text, { dimColor: true, children: label }), shown.map((a) => (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { justifyContent: "space-between", children: [_jsxs(Text, { children: [a.status === "working" ? _jsx(OrbitGlyph, {}) : _jsx(Text, { color: COLOR[a.status], children: GLYPH[a.status] }), " ", a.label, a.round != null ? ` · round ${a.round}` : "", a.status === "working" && missionLine(a) ? _jsxs(Text, { color: theme.accent, children: [" \u00B7 ", cap(missionLine(a), 36)] }) : null] }), _jsx(Text, { dimColor: true, children: (() => { const m = metrics(a); const ds = DISPLAY_STATUS[a.status]; return m ? `${m} · ${ds}` : ds; })() })] }), _jsx(ActivityLines, { a: a }), _jsx(GrandmasterLine, { a: a }), a.status === "idle" && _jsx(Box, { paddingLeft: 2, children: _jsx(Text, { dimColor: true, children: "result posted \u2014 scroll up or /agents to review" }) }), a.status === "stopped" && _jsx(Box, { paddingLeft: 2, children: _jsx(Text, { dimColor: true, children: "errored \u2014 check transcript for details" }) })] }, a.id))), hidden > 0 ? _jsx(Text, { dimColor: true, children: ` +${hidden} more running` }) : null, _jsx(ShellJobs, { jobs: jobs })] }));
139
+ return (_jsxs(Box, { flexDirection: "column", marginTop: 1, borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsx(Text, { dimColor: true, children: label }), shown.map((a) => _jsx(AgentRows, { a: a }, a.id)), hidden > 0 ? _jsx(Text, { dimColor: true, children: ` +${hidden} more running` }) : null, _jsx(ShellJobs, { jobs: jobs })] }));
129
140
  }
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, 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 { theme } from "./theme.js";
4
4
  import { bar } from "./chart.js";
@@ -10,6 +10,27 @@ export function planProgress(tasks) {
10
10
  const done = tasks.filter((t) => t.status === "done").length;
11
11
  return `${done}/${tasks.length} done`;
12
12
  }
13
+ /** Rows the pane may take in the DYNAMIC frame. Uncapped, a 16-item plan plus the sub-agent box made the live frame
14
+ * taller than the terminal, and Ink then clears and redraws the whole screen on every tick — the flashing (10/31). */
15
+ export const PLAN_MAX_ROWS = 6;
16
+ /** The rows to show (pure, testable): in-progress first, then the next pending, then the most recent finished — in plan
17
+ * order — capped at `max`, plus how many were left out. */
18
+ export function visiblePlan(tasks, max = PLAN_MAX_ROWS) {
19
+ if (tasks.length <= max)
20
+ return { shown: tasks, hidden: 0 };
21
+ const pick = new Set();
22
+ for (const t of tasks)
23
+ if (t.status === "in_progress" && pick.size < max)
24
+ pick.add(t);
25
+ for (const t of tasks)
26
+ if (t.status === "pending" && pick.size < max)
27
+ pick.add(t);
28
+ for (const t of [...tasks].reverse())
29
+ if (finished(t) && pick.size < max)
30
+ pick.add(t);
31
+ const shown = tasks.filter((t) => pick.has(t));
32
+ return { shown, hidden: tasks.length - shown.length };
33
+ }
13
34
  export function PlanPane({ tasks, title = "plan" }) {
14
35
  if (!tasks.length)
15
36
  return null;
@@ -20,5 +41,8 @@ export function PlanPane({ tasks, title = "plan" }) {
20
41
  // Borderless: this pane renders in Ink's DYNAMIC region; a box border there orphans its rows into
21
42
  // scrollback whenever the Static transcript grows during a long turn (the v0.1.92 line-flood). The
22
43
  // dim header labels the group without a border.
23
- 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) })] }), tasks.map((t) => (_jsxs(Text, { children: [_jsxs(Text, { color: COLOR[t.status], children: [GLYPH[t.status], " "] }), _jsx(Text, { dimColor: finished(t), strikethrough: finished(t), children: t.text })] }, t.id)))] }));
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
+ })()] }));
24
48
  }
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } 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";
@@ -56,6 +56,16 @@ export function argsPreview(args) {
56
56
  }
57
57
  return parts.join(", ");
58
58
  }
59
+ /** The call's title. A shell call reads as the command itself — "$ ls -la /path" — like a terminal prompt (owner, 10/31:
60
+ * "bash needs to just show $"); every other tool reads name(args). `note` is the shell call's description, shown dim. */
61
+ export function stepTitle(step) {
62
+ if (SHELL_TOOLS.has(step.name) && typeof step.args?.command === "string") {
63
+ const cmd = step.args.command.replace(/\s+/g, " ").trim();
64
+ const desc = typeof step.args.description === "string" && step.args.description.trim() ? step.args.description.trim() : undefined;
65
+ return { head: "$", body: cmd.length > 160 ? cmd.slice(0, 157) + "..." : cmd, note: desc };
66
+ }
67
+ return { head: step.name, body: `(${argsPreview(step.args)})` };
68
+ }
59
69
  /** For shell tools with a description, the command is shown dim beneath the description line. */
60
70
  export function shellCommandHint(step) {
61
71
  if (!SHELL_TOOLS.has(step.name) || !step.args?.description)
@@ -86,5 +96,9 @@ export function ToolStep({ step }) {
86
96
  // lands. Only RUNNING media rows get the bar — everything else renders exactly as before.
87
97
  const isRunningMedia = toolKind(step.name) === "media" && step.status === "running";
88
98
  const mediaFraction = isRunningMedia && elapsed != null ? mediaProgressFraction(elapsed, mediaEtaMs(step.name, step.args)) : undefined;
89
- 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) }), " ", step.status === "running" ? _jsx(ShimmerText, { text: step.name, frame: frame, palette: huePalette(KIND_HUE[toolKind(step.name)]) }) : step.name, "(", argsPreview(step.args), ")", 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] }), shellCommandHint(step) ? _jsxs(Text, { dimColor: true, children: [" ", shellCommandHint(step)] }) : 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)))] }));
99
+ 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
+ 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;
102
+ 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)))] }));
90
104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.344",
3
+ "version": "0.1.346",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "operator": "dist/cli.js",