@carrieros/cli 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +89 -15
  2. package/dist/commands/chat.js +6 -6
  3. package/dist/commands/context.js +40 -0
  4. package/dist/commands/doctor.js +34 -14
  5. package/dist/commands/logout.js +2 -0
  6. package/dist/commands/permissions.js +78 -0
  7. package/dist/commands/scope.js +9 -6
  8. package/dist/commands/sessions.js +5 -0
  9. package/dist/commands/settings.js +83 -10
  10. package/dist/commands/update.js +177 -51
  11. package/dist/commands/usage.js +10 -8
  12. package/dist/commands/version.js +1 -3
  13. package/dist/commands/whoami.js +12 -9
  14. package/dist/ide/editor-context.js +115 -12
  15. package/dist/ide/ide-session.js +288 -18
  16. package/dist/ide/tool-host.js +6 -6
  17. package/dist/main.js +10 -1
  18. package/dist/services/api.js +183 -15
  19. package/dist/services/auth-origin.js +20 -0
  20. package/dist/services/auto-update.js +221 -0
  21. package/dist/services/chat-stream.js +26 -3
  22. package/dist/services/checkpoints.js +176 -14
  23. package/dist/services/client-tools.js +123 -27
  24. package/dist/services/code-intel.js +243 -0
  25. package/dist/services/code-symbols.js +94 -0
  26. package/dist/services/coding-workflow.js +554 -0
  27. package/dist/services/command-coordinator.js +85 -12
  28. package/dist/services/command-policy.js +34 -4
  29. package/dist/services/config.js +96 -11
  30. package/dist/services/container-runner.js +254 -0
  31. package/dist/services/container-supervisor.js +38 -0
  32. package/dist/services/context.js +98 -25
  33. package/dist/services/device-auth.js +33 -6
  34. package/dist/services/execution-platform.js +30 -0
  35. package/dist/services/file-resolver.js +1 -1
  36. package/dist/services/folder-key.js +22 -0
  37. package/dist/services/git-tools.js +181 -0
  38. package/dist/services/helper-bin.js +56 -35
  39. package/dist/services/instruction-resolver.js +54 -0
  40. package/dist/services/job-helper.js +31 -10
  41. package/dist/services/local-files.js +148 -26
  42. package/dist/services/local-tools.js +540 -35
  43. package/dist/services/login-flow.js +44 -13
  44. package/dist/services/meta.js +27 -0
  45. package/dist/services/mutation-coordinator.js +186 -20
  46. package/dist/services/mutation-groups.js +309 -0
  47. package/dist/services/mutation-recovery.js +159 -0
  48. package/dist/services/mutations.js +264 -78
  49. package/dist/services/packaged-update.js +403 -0
  50. package/dist/services/packaged.js +15 -0
  51. package/dist/services/permission-mode.js +78 -0
  52. package/dist/services/process-runner.js +7 -1
  53. package/dist/services/project-context.js +4 -4
  54. package/dist/services/result-reconciliation.js +49 -0
  55. package/dist/services/secure-store.js +21 -1
  56. package/dist/services/session-resolver.js +7 -0
  57. package/dist/services/supported-runtime.js +59 -0
  58. package/dist/services/task-context.js +212 -0
  59. package/dist/services/task-snapshot.js +38 -0
  60. package/dist/services/tool-result-outbox.js +195 -0
  61. package/dist/services/update.js +457 -13
  62. package/dist/services/workspace-registry.js +4 -3
  63. package/dist/services/workspace.js +8 -1
  64. package/dist/shell/shell-chat.js +320 -34
  65. package/dist/shell/shell-commands.js +47 -5
  66. package/dist/shell/shell-prompt.js +21 -11
  67. package/dist/shell/shell-renderer.js +1 -1
  68. package/dist/shell/shell.js +107 -20
  69. package/dist/shell/task-context-view.js +40 -0
  70. package/dist/ui/agent-cards.js +111 -0
  71. package/dist/ui/agent-presentation.js +131 -0
  72. package/dist/ui/approval.js +46 -16
  73. package/dist/ui/banner.js +31 -87
  74. package/dist/ui/change-review.js +293 -46
  75. package/dist/ui/chat-renderer.js +6 -6
  76. package/dist/ui/colors.js +9 -9
  77. package/dist/ui/command-details.js +11 -0
  78. package/dist/ui/command-palette.js +27 -10
  79. package/dist/ui/command-registry.js +11 -4
  80. package/dist/ui/command-review.js +77 -28
  81. package/dist/ui/composer-layout.js +26 -20
  82. package/dist/ui/conversation.js +77 -25
  83. package/dist/ui/live.js +1 -1
  84. package/dist/ui/screen.js +19 -11
  85. package/dist/ui/select.js +6 -0
  86. package/dist/ui/task-context-card.js +99 -0
  87. package/dist/ui/trust.js +7 -12
  88. package/dist/ui/ui.js +23 -0
  89. package/package.json +9 -5
@@ -1,7 +1,10 @@
1
+ import path from "node:path";
2
+ import { executionContract } from "../services/execution-platform.js";
1
3
  import { displayCommand } from "../services/command-policy.js";
2
4
  import { c } from "./colors.js";
3
5
  import { MARGIN, contentWidth } from "./composer-layout.js";
4
6
  import { clip, stripControl, wrapText } from "./conversation.js";
7
+ import { approvalCard, cardHeader } from "./agent-cards.js";
5
8
  /**
6
9
  * What a person sees before and after a local command.
7
10
  *
@@ -29,30 +32,29 @@ const INDENT = MARGIN + " ";
29
32
  const inner = () => Math.max(24, contentWidth() - 4);
30
33
  /** ` Label value` with continuation lines aligned under the value. */
31
34
  function field(label, value, paint = c.dim) {
32
- const pad = 8;
35
+ const pad = Math.max(12, label.length + 2);
33
36
  const head = label.padEnd(pad);
34
37
  return wrapText(safeText(value), inner() - pad).map((l, i) => INDENT + c.dim(i === 0 ? head : " ".repeat(pad)) + paint(l));
35
38
  }
36
- export function renderCommandReview(d, reason, repository) {
39
+ export function renderCommandReview(d, reason, repository, execution = executionContract(), activeRoot, operationId) {
37
40
  const tier = d.tier === "R2" ? c.warn(TIER_TEXT[d.tier]) : d.tier === "R1" ? c.value(TIER_TEXT[d.tier]) : c.dim(TIER_TEXT[d.tier]);
38
- const lines = [
39
- "",
40
- MARGIN + c.warn("◆") + " " + c.title("Carrier OS wants to run:"),
41
- ""
42
- ];
43
- // A command can now be aimed at a repository that is not the active one, so
44
- // WHICH repository is part of what is being approved. It sits above the
45
- // command, before the absolute working directory that confirms it, and reads
46
- // the same as the file-change card.
47
- if (repository) {
48
- lines.push(INDENT + c.dim("Repository ") + c.value(clip(safeText(repository), Math.max(12, inner() - 14))), "");
49
- }
41
+ const lines = [...cardHeader("COMMAND REVIEW", c.title)];
50
42
  for (const l of wrapText(safeText(displayCommand(d.program, d.args)), inner()))
51
- lines.push(INDENT + c.accent(l));
52
- for (const l of wrapText(safeText(d.cwdAbsolute), inner()))
53
- lines.push(INDENT + c.file(l));
54
- lines.push(INDENT + tier + c.dim(" · network: " + NETWORK_TEXT[d.network]));
43
+ lines.push(MARGIN + c.accent(l));
55
44
  lines.push("");
45
+ // A command can be aimed at a repository that is not the active one, so
46
+ // WHICH repository is part of what is being approved.
47
+ if (repository)
48
+ lines.push(...field("Repository", repository, c.value));
49
+ const relative = activeRoot ? path.relative(activeRoot, d.cwdAbsolute) : undefined;
50
+ const cwd = relative !== undefined && relative !== ".." && !relative.startsWith(".." + path.sep) && !path.isAbsolute(relative) ? relative || "." : d.cwdAbsolute;
51
+ lines.push(...field("Directory", cwd, c.file));
52
+ const network = execution.backend === "docker-engine-v1" ? "Disabled" : execution.backend === "windows-job" ? "Not restricted by executor" : "Unavailable";
53
+ lines.push(...field("Runtime", execution.backend ? `${execution.backend} · ${execution.backend === "docker-engine-v1" ? "isolated Linux runtime" : "native Windows"}` : "unavailable", c.value));
54
+ lines.push(...field("Network", network, execution.backend === "docker-engine-v1" ? c.ok : c.warn));
55
+ if (execution.backend === "windows-job")
56
+ lines.push(...field("Expected", NETWORK_TEXT[d.network]));
57
+ lines.push(INDENT + c.dim("Risk".padEnd(12)) + tier);
56
58
  if (d.script) {
57
59
  lines.push(...field("Script", d.script.text, c.value));
58
60
  if (d.script.pre)
@@ -61,18 +63,19 @@ export function renderCommandReview(d, reason, repository) {
61
63
  lines.push(...field("post", d.script.post, c.value));
62
64
  }
63
65
  if (reason)
64
- lines.push(...field("Why", reason));
66
+ lines.push(...field("Reason", reason));
65
67
  for (const note of d.notes) {
66
68
  if (/^Read-only|^Runs project code/.test(note))
67
69
  continue; // already said by the tier
68
70
  lines.push(INDENT + c.dim("· " + clip(note, inner() - 2)));
69
71
  }
70
- lines.push("");
72
+ lines.push(...approvalCard("command", "This command needs its own approval; approving file changes never approves a command.", operationId ? [operationId] : []), "");
71
73
  return lines;
72
74
  }
73
75
  /**
74
- * A one-line result: what ran, how it ended, how long it took — plus test
75
- * counts when the output plainly states them.
76
+ * The result: a status heading, the command, then counts and timing — the
77
+ * exit code is the truth about success; counts are read from the output only
78
+ * when a runner states them plainly.
76
79
  */
77
80
  export function renderCommandSummary(d, r, errorCode, message) {
78
81
  const what = d ? displayCommand(d.program, d.args) : "command";
@@ -82,19 +85,65 @@ export function renderCommandSummary(d, r, errorCode, message) {
82
85
  return [MARGIN + icon + " " + c.dim(clip(`${what} — ${safeText(message ?? errorCode ?? "not run")}`, inner()))];
83
86
  }
84
87
  const secs = `${(r.duration_ms / 1000).toFixed(1)}s`;
88
+ const counts = summariseOutput(r.output);
85
89
  const extra = [
86
- summariseOutput(r.output),
90
+ counts,
91
+ secs,
87
92
  r.truncated ? "output truncated" : "",
88
93
  r.redaction_count ? `${r.redaction_count} secret${r.redaction_count === 1 ? "" : "s"} redacted` : ""
89
94
  ].filter(Boolean);
90
- const tail = c.dim([secs, ...extra].join(" · "));
95
+ // "Running tests…", the command, each test the runner named, the counts one
96
+ // per line, then the status the exit code decides.
97
+ const report = parseTestReport(r.output);
98
+ const isTest = report.tests.length > 0 || !!counts;
99
+ const shown = report.tests.slice(0, 12);
100
+ const out = [
101
+ "",
102
+ MARGIN + c.title(isTest ? "Running tests…" : "Running command…"),
103
+ MARGIN + " " + c.dim("> ") + c.accent(clip(what, inner() - 2)),
104
+ ...shown.map((t) => MARGIN + " " + (t.passed ? c.ok("✓ ") : c.err("✗ ")) + (t.passed ? c.dim : c.value)(clip(t.name, inner() - 2))),
105
+ ...(report.tests.length > shown.length ? [MARGIN + " " + c.dim(`+${report.tests.length - shown.length} more`)] : []),
106
+ ...(counts ? counts.split(" · ").map((n) => MARGIN + " " + (/^0 failed$/.test(n) || /passed/.test(n) ? c.value(n) : c.err(n))) : [])
107
+ ];
108
+ const timing = MARGIN + " " + c.dim(extra.filter((e) => e !== counts).join(" · "));
91
109
  if (r.timed_out)
92
- return [MARGIN + c.err("✕") + " " + c.value(what) + c.dim(" timed out — process tree stopped · ") + tail];
110
+ return [...out, MARGIN + c.err("✕ TIMED OUT") + c.dim(" · process tree stopped"), timing];
93
111
  if (r.cancelled)
94
- return [MARGIN + c.warn("✗") + " " + c.value(what) + c.dim(" cancelled — process tree stopped · ") + tail];
112
+ return [...out, MARGIN + c.warn("⊘ CANCELLED") + c.dim(" · process tree stopped"), timing];
95
113
  if (r.exit_code === 0)
96
- return [MARGIN + c.ok("✓") + " " + c.value(what) + c.dim(" · ") + tail];
97
- return [MARGIN + c.err("✕") + " " + c.value(what) + c.dim(` exited ${r.exit_code} · `) + tail];
114
+ return [...out, MARGIN + c.ok("✓ PASSED"), timing];
115
+ return [...out, MARGIN + c.err("✕ FAILED") + c.dim(` · exit ${r.exit_code}`), timing];
116
+ }
117
+ export function parseTestReport(output) {
118
+ const text = safeText(output).replace(/\r\n/g, "\n");
119
+ const tests = [];
120
+ const seen = new Set();
121
+ const add = (name, passed) => {
122
+ const clean = name.replace(/\s+\([\d.]+\s*m?s\)\s*$/, "").replace(/\s+#\s.*$/, "").trim();
123
+ const key = `${passed}:${clean}`;
124
+ if (!clean || seen.has(key))
125
+ return;
126
+ seen.add(key);
127
+ tests.push({ name: clean, passed });
128
+ };
129
+ // Results end where a runner starts its failure recap; reading past it would
130
+ // list a failing test twice.
131
+ const body = text.split(/\n[✖✕]\s+failing tests:|\nFailures:|\n\s*\d+ failing\b/)[0];
132
+ for (const line of body.split("\n")) {
133
+ let m;
134
+ if ((m = /^\s{0,4}(✔|✓|✖|✕|×)\s+(.+)$/.exec(line)))
135
+ add(m[2], m[1] === "✔" || m[1] === "✓");
136
+ else if ((m = /^(not ok|ok)\s+\d+\s+-\s+(.+)$/.exec(line)))
137
+ add(m[2], m[1] === "ok");
138
+ }
139
+ const value = (re) => {
140
+ const m = re.exec(text);
141
+ return m ? m[1].trim().replace(/,$/, "").slice(0, 120) : undefined;
142
+ };
143
+ const failed = tests.find((t) => !t.passed);
144
+ const expected = value(/^\s*expected:\s*(.+)$/m) ?? value(/^\s*Expected[^:]*:\s*(.+)$/m);
145
+ const received = value(/^\s*actual:\s*(.+)$/m) ?? value(/^\s*Received[^:]*:\s*(.+)$/m);
146
+ return { tests, ...(failed || expected || received ? { failure: { name: failed?.name, expected, received } } : {}) };
98
147
  }
99
148
  /**
100
149
  * Test counts, when a runner states them plainly. Presentation only: the exit
@@ -1,3 +1,4 @@
1
+ import stringWidth from "string-width";
1
2
  /**
2
3
  * Composer layout. The composer + its divider lines span the FULL terminal
3
4
  * width (Claude-style), inset by a small margin with a one-column right gutter
@@ -19,7 +20,7 @@ function columns() {
19
20
  /** Full content width for the composer + dividers: terminal minus the left
20
21
  * margin and a one-column right gutter. */
21
22
  export function contentWidth() {
22
- return Math.max(24, columns() - MARGIN.length - 1);
23
+ return Math.max(8, columns() - MARGIN.length - 1);
23
24
  }
24
25
  /** Width to wrap running text to — full content width, capped for readability. */
25
26
  export function textWidth() {
@@ -28,10 +29,9 @@ export function textWidth() {
28
29
  // SGR colour runs plus OSC strings. An OSC payload (a hyperlink URL, a window
29
30
  // title) occupies no columns, so a matcher that only knows SGR over-counts any
30
31
  // line carrying one.
31
- const ANSI = /\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b\[[0-9;]*m/g;
32
32
  /** Visible column count of a styled string — escape sequences don't count. */
33
33
  export function visibleWidth(s) {
34
- return s.replace(ANSI, "").length;
34
+ return stringWidth(s);
35
35
  }
36
36
  /**
37
37
  * Clamp a styled line to `width` visible columns, keeping its colour codes.
@@ -46,23 +46,29 @@ export function visibleWidth(s) {
46
46
  export function clampAnsi(s, width = contentWidth()) {
47
47
  if (visibleWidth(s) <= width)
48
48
  return s;
49
- const max = Math.max(1, width - 1); // room for the ellipsis
50
- let out = "";
51
- let vis = 0;
52
- let i = 0;
53
- while (i < s.length && vis < max) {
54
- if (s[i] === "\x1b") {
55
- // Copy the escape verbatim; it costs no columns.
56
- const m = /^\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|^\x1b\[[0-9;]*m/.exec(s.slice(i));
57
- if (m) {
58
- out += m[0];
59
- i += m[0].length;
60
- continue;
61
- }
49
+ const first = wrapAnsi(s, Math.max(1, width - 1))[0];
50
+ return `${first}…${s.includes("\x1b[") ? "\x1b[0m" : ""}`;
51
+ }
52
+ /** Reflow transcript content without discarding reviewed bytes on resize. */
53
+ export function wrapAnsi(text, width) {
54
+ const limit = Math.max(1, width);
55
+ const tokens = text.split(/(\x1b\[[0-9;]*m)/g).flatMap(part => part.startsWith("\x1b[") ? [part] : [...new Intl.Segmenter().segment(part)].map(s => s.segment));
56
+ const lines = [];
57
+ let row = "", count = 0, style = "";
58
+ for (const token of tokens) {
59
+ if (token.startsWith("\x1b[")) {
60
+ row += token;
61
+ style = token === "\x1b[0m" ? "" : style + token;
62
+ continue;
63
+ }
64
+ if (count + visibleWidth(token) > limit && count > 0) {
65
+ lines.push(row + (style ? "\x1b[0m" : ""));
66
+ row = style;
67
+ count = 0;
62
68
  }
63
- out += s[i];
64
- vis++;
65
- i++;
69
+ row += token;
70
+ count += visibleWidth(token);
66
71
  }
67
- return `${out}…\x1b[0m`;
72
+ lines.push(row);
73
+ return lines;
68
74
  }
@@ -33,6 +33,8 @@ export function clipCommand(text, width) {
33
33
  const plain = stripControl(text);
34
34
  if (visibleWidth(plain) <= width)
35
35
  return plain;
36
+ if (width < 22)
37
+ return clip(plain, width);
36
38
  const keepEnd = Math.max(8, Math.floor((width - 3) * 0.35));
37
39
  const keepStart = Math.max(8, width - 3 - keepEnd);
38
40
  return [...plain].slice(0, keepStart).join("") + " … " + [...plain].slice(-keepEnd).join("");
@@ -42,7 +44,7 @@ export function clipCommand(text, width) {
42
44
  * for anything a person needs in full: a command, a path, a reason.
43
45
  */
44
46
  export function wrapText(text, width) {
45
- const w = Math.max(16, width);
47
+ const w = Math.max(1, width);
46
48
  const out = [];
47
49
  for (const paragraph of text.split("\n")) {
48
50
  let cur = "";
@@ -84,6 +86,8 @@ export function isNoiseLine(line) {
84
86
  const t = line.trim();
85
87
  if (!t)
86
88
  return true;
89
+ if (/\b(error|warn|warning|failed|failure)\b/i.test(t))
90
+ return false;
87
91
  return (/^\(node:\d+\)\s+ExperimentalWarning/.test(t) ||
88
92
  /^\(Use `node --trace-warnings/.test(t) ||
89
93
  // Winston / pino style structured logs: "info:", "debug:", "http:", plus a
@@ -161,32 +165,36 @@ export function createRenderer(live) {
161
165
  let command = null;
162
166
  let preview = "";
163
167
  let paused = false;
164
- const width = () => Math.max(32, contentWidth() - 4);
168
+ let frame = 0;
169
+ const width = () => Math.max(8, contentWidth() - 4);
165
170
  const dot = () => c.accentLight("•");
166
171
  const paint = () => {
167
172
  if (paused)
168
173
  return;
169
174
  const lines = [];
175
+ const activity = () => c.accentLight(["·", "•", "◦", "•"][frame++ % 4]) + " ";
170
176
  if (command) {
171
- lines.push(MARGIN + " " + c.value(clip(command.label, width() - 12)) + c.dim(elapsedLabel(command.since)));
177
+ lines.push(MARGIN + " " + activity() + c.value(clip(command.label, width() - 14)) + c.dim(elapsedLabel(command.since)));
172
178
  lines.push(MARGIN + " " + c.dim("└ $ " + clipCommand(command.command, width() - 8)));
173
179
  for (const l of command.tail.view(width() - 6))
174
180
  lines.push(MARGIN + " " + c.dim(l));
175
181
  }
176
- else if (step) {
177
- lines.push(MARGIN + " " + c.value(clip(step.label, width() - 12)) + c.dim(elapsedLabel(step.started)));
182
+ else if (step && step.running.length) {
183
+ lines.push(MARGIN + " " + activity() + c.value(clip(step.label, width() - 14)) + c.dim(elapsedLabel(step.started)));
178
184
  if (step.running.length > 1) {
179
- for (const [i, label] of step.running.entries()) {
185
+ for (const [i, label] of step.running.slice(0, 3).entries()) {
180
186
  const branch = i === step.running.length - 1 ? "└ " : "├ ";
181
187
  lines.push(MARGIN + " " + c.dim(branch + clip(label, width() - 6)));
182
188
  }
189
+ if (step.running.length > 3)
190
+ lines.push(MARGIN + " " + c.dim(`+${step.running.length - 3} more`));
183
191
  }
184
192
  }
185
193
  else if (preview) {
186
194
  lines.push(MARGIN + dot() + " " + c.dim(clip(preview, width())));
187
195
  }
188
196
  else if (statusLabel) {
189
- lines.push(MARGIN + " " + c.dim(clip(statusLabel, width())) + c.dim(elapsedLabel(statusSince)));
197
+ lines.push(MARGIN + " " + activity() + c.dim(clip(statusLabel, width() - 2)) + c.dim(elapsedLabel(statusSince)));
190
198
  }
191
199
  live.setStatus(lines);
192
200
  };
@@ -196,7 +204,7 @@ export function createRenderer(live) {
196
204
  return {
197
205
  user(text) {
198
206
  const lines = wrapText(text.trim(), contentWidth() - 3);
199
- live.commit(["", ...lines.map((l, i) => MARGIN + (i === 0 ? c.brandFixed("›") : " ") + " " + c.title(l)), ""]);
207
+ live.commit(["", ...lines.map((l, i) => MARGIN + (i === 0 ? c.brand("›") : " ") + " " + c.title(l)), ""]);
200
208
  },
201
209
  assistant(text) {
202
210
  const md = renderMarkdown(text.trim());
@@ -227,19 +235,30 @@ export function createRenderer(live) {
227
235
  },
228
236
  toolStart(label, kind) {
229
237
  if (!step)
230
- step = { label, started: Date.now(), running: [], counts: blankCounts() };
231
- step.counts[kind] += 1;
238
+ step = { label, started: Date.now(), running: [], kinds: [], counts: blankCounts(), targets: { read: [], search: [], list: [] } };
232
239
  step.running.push(label);
240
+ step.kinds.push(kind);
233
241
  // One tool at a time reads better as itself than as a group.
234
- step.label = step.running.length === 1 ? label : groupLabel(step.counts);
242
+ step.label = step.running.length === 1 ? label : "Inspecting repository";
235
243
  paint();
236
244
  },
237
245
  toolEnd(label, kind, summary, ok = true) {
238
246
  if (!step)
239
247
  return;
240
248
  const i = step.running.indexOf(label);
241
- if (i !== -1)
249
+ if (i !== -1) {
242
250
  step.running.splice(i, 1);
251
+ const originalKind = step.kinds.splice(i, 1)[0];
252
+ const k = kind ?? originalKind;
253
+ if (ok)
254
+ step.counts[k] += 1;
255
+ // Name what was looked at, so investigation is visible without a line per read.
256
+ if (ok && (k === "read" || k === "search" || k === "list")) {
257
+ const target = stepTarget(label);
258
+ if (target && !step.targets[k].includes(target))
259
+ step.targets[k].push(target);
260
+ }
261
+ }
243
262
  if (step.running.length === 1)
244
263
  step.label = step.running[0];
245
264
  // A failed tool says so, concisely, right where it happened.
@@ -258,12 +277,14 @@ export function createRenderer(live) {
258
277
  return;
259
278
  // Inspections already left their own ✓ lines; the aggregate is the reads
260
279
  // and searches that were kept quiet during the step.
261
- const summary = summariseStep({ ...step.counts, inspect: 0 });
280
+ const summary = summariseStep({ ...step.counts, inspect: 0, command: 0, change: 0, other: 0 });
262
281
  const took = elapsedLabel(step.started);
263
282
  const hadInspect = step.counts.inspect > 0;
283
+ const targets = step.targets;
284
+ const counts = step.counts;
264
285
  step = null;
265
286
  if (summary)
266
- live.commit([MARGIN + " " + c.ok("✓ ") + c.dim(summary + took), ""]);
287
+ live.commit([...investigationBlock(counts, targets, took, width()), ""]);
267
288
  else if (hadInspect)
268
289
  live.commit([""]); // spacer after the ✓ inspection lines
269
290
  paint();
@@ -306,19 +327,36 @@ export function createRenderer(live) {
306
327
  }
307
328
  };
308
329
  }
330
+ /**
331
+ * The grouped record of what a step read, searched and listed: one heading and
332
+ * a row per kind, each naming its targets (paths and queries only — never model
333
+ * text). Rows are clipped to the terminal; the full list is the tool record.
334
+ */
335
+ function investigationBlock(counts, targets, took, width) {
336
+ const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
337
+ const named = (list) => (list.length ? " · " + list.slice(0, 4).join(", ") + (list.length > 4 ? `, +${list.length - 4} more` : "") : "");
338
+ // Phases in the order an investigation runs, each present only when a tool
339
+ // of that kind actually ran — never inferred from model text.
340
+ const rows = [
341
+ [counts.list + counts.inspect > 0, "Inspecting repository structure", named(targets.list)],
342
+ [counts.search > 0, "Searching for related code", named(targets.search)],
343
+ [counts.read > 0, `Reading relevant files (${plural(counts.read, "file", "files")})`, named(targets.read)]
344
+ ];
345
+ return [
346
+ MARGIN + c.title("Agent investigation") + c.dim(took),
347
+ ...rows.filter(([ran]) => ran).map(([, text, list]) => MARGIN + " " + c.ok("✓ ") + c.value(clip(text, width - 4)) + c.dim(clip(list, Math.max(0, width - 6 - visibleWidth(text)))))
348
+ ];
349
+ }
350
+ /** "Reading src/a.ts" → "src/a.ts"; a label with no target names nothing. */
351
+ function stepTarget(label) {
352
+ const m = stripControl(label).match(/^(?:Reading|Searching|Finding files|Finding file|Finding definition|Finding usages|Outlining|Inspecting repository|Listing)\s+(.+)$/);
353
+ const target = m ? m[1].trim().slice(0, 80) : "";
354
+ // Generic activity words name nothing the user could look at.
355
+ return /^(project files|the project|repository|files)$/i.test(target) ? "" : target;
356
+ }
309
357
  function blankCounts() {
310
358
  return { read: 0, list: 0, search: 0, inspect: 0, command: 0, change: 0, other: 0 };
311
359
  }
312
- /** What to call a step that is doing several things at once. */
313
- function groupLabel(counts) {
314
- if (counts.command > 1)
315
- return "Running commands";
316
- if (counts.change > 1)
317
- return "Preparing changes";
318
- if (counts.search && !counts.read)
319
- return "Searching the project";
320
- return "Inspecting the project";
321
- }
322
360
  /**
323
361
  * The compact result line for one completed tool, or undefined when the step's
324
362
  * aggregate should speak for it instead.
@@ -368,7 +406,13 @@ export function toolSummary(name, ok, detail) {
368
406
  return "git_diff · no changes";
369
407
  return `git_diff · ${n(r.files_changed)} ${n(r.files_changed) === 1 ? "file" : "files"} · +${n(r.additions)} −${n(r.deletions)}`;
370
408
  }
371
- // read_file / list_files / search_files are aggregated by the step summary.
409
+ if (name === "git_log")
410
+ return `git_log · ${arr(r.commits)} ${arr(r.commits) === 1 ? "commit" : "commits"}${r.path ? ` · ${r.path}` : ""}`;
411
+ if (name === "git_blame")
412
+ return `git_blame · ${r.path ?? ""} lines ${n(r.start_line)}–${n(r.end_line)}`;
413
+ if (name === "git_show")
414
+ return `git_show · ${r.short ?? ""} ${typeof r.subject === "string" ? r.subject.slice(0, 60) : ""}`.trimEnd();
415
+ // read_file / list_files / find_files / search_files are aggregated by the step summary.
372
416
  return undefined;
373
417
  }
374
418
  /** The kind of activity a tool name represents, for the step summary. */
@@ -378,11 +422,19 @@ export function toolKind(name) {
378
422
  return "read";
379
423
  case "list_files":
380
424
  return "list";
425
+ case "find_files":
381
426
  case "search_files":
427
+ case "find_symbol":
428
+ case "find_references":
382
429
  return "search";
430
+ case "code_outline":
431
+ return "read";
383
432
  case "resolve_local_file":
384
433
  case "git_status":
385
434
  case "git_diff":
435
+ case "git_log":
436
+ case "git_blame":
437
+ case "git_show":
386
438
  return "inspect";
387
439
  case "run_command":
388
440
  return "command";
package/dist/ui/live.js CHANGED
@@ -28,7 +28,7 @@ export function startLiveComposer(footer = "") {
28
28
  stop: () => screenTransient([])
29
29
  };
30
30
  }
31
- if (!stdout.isTTY)
31
+ if (!stdout.isTTY || process.env.TERM === "dumb")
32
32
  return passthrough;
33
33
  let status = [];
34
34
  let shown = []; // the transient region currently on screen (status + bar)
package/dist/ui/screen.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { clampAnsi, wrapAnsi } from "./composer-layout.js";
1
2
  /**
2
3
  * Persistent bottom-composer TUI engine (Claude Code–style).
3
4
  *
@@ -43,6 +44,7 @@ const MAX_SCROLLBACK = 5000;
43
44
  let active = false;
44
45
  let committed = []; // permanent transcript lines
45
46
  let transient = []; // in-progress tail (spinner / streaming), below `committed`
47
+ let task = []; // existing task review projection, pinned while active
46
48
  let palette = []; // slash-palette overlay (empty when closed)
47
49
  let bar = []; // the fixed composer core (CORE_H lines)
48
50
  let caretBarIndex = 1; // which composer row the caret sits on (1 = prompt line)
@@ -65,10 +67,11 @@ function metrics() {
65
67
  const core = bar.length || CORE_H;
66
68
  const tb = Math.max(1, h - core); // transcript occupies rows 1..tb
67
69
  const pH = Math.min(palette.length, Math.max(0, tb - 1)); // overlay never covers the whole region
68
- const contentH = Math.max(0, tb - pH); // transcript rows above the palette overlay
69
- const all = transient.length ? committed.concat(transient) : committed;
70
+ const taskH = Math.min(task.length, Math.max(0, Math.floor((tb - pH) / 2)));
71
+ const contentH = Math.max(0, tb - pH - taskH); // transcript rows above the palette overlay
72
+ const all = (transient.length ? committed.concat(transient) : committed).flatMap(line => wrapAnsi(line, Math.max(1, (out.columns ?? 80) - 1)));
70
73
  const maxOffset = Math.max(0, all.length - contentH);
71
- return { h, core, tb, pH, contentH, all, maxOffset };
74
+ return { h, core, tb, pH, taskH, contentH, all, maxOffset };
72
75
  }
73
76
  /** Clamp the scroll offset into range and recompute the pinned flag. */
74
77
  function clampScroll() {
@@ -94,7 +97,7 @@ function onContentGrew(added) {
94
97
  }
95
98
  /** Build the full desired screen: [transcript window][palette][composer core]. */
96
99
  function compose() {
97
- const { h, tb, pH, contentH, all, maxOffset } = metrics();
100
+ const { h, tb, pH, taskH, contentH, all, maxOffset } = metrics();
98
101
  if (scrollOffset > maxOffset)
99
102
  scrollOffset = maxOffset; // stay valid across resizes
100
103
  // The visible window into `all`. offset 0 = last `contentH` lines (the tail);
@@ -103,17 +106,19 @@ function compose() {
103
106
  const start = Math.max(0, end - contentH);
104
107
  const win = all.slice(start, end);
105
108
  const desired = new Array(h).fill("");
109
+ for (let i = 0; i < taskH; i++)
110
+ desired[i] = task[i] ?? "";
106
111
  for (let i = 0; i < contentH; i++)
107
- desired[i] = win[i] ?? "";
112
+ desired[taskH + i] = win[i] ?? "";
108
113
  // A subtle "more below" hint on the last transcript row when scrolled up.
109
114
  if (scrollOffset > 0 && contentH > 0) {
110
- desired[contentH - 1] = `${ESC}2m ↓ ${scrollOffset} more line${scrollOffset === 1 ? "" : "s"} - End to jump to latest${ESC}0m`;
115
+ desired[taskH + contentH - 1] = `${ESC}2m ↓ ${scrollOffset} more line${scrollOffset === 1 ? "" : "s"} - End to jump to latest${ESC}0m`;
111
116
  }
112
117
  for (let i = 0; i < pH; i++)
113
- desired[contentH + i] = palette[i] ?? "";
118
+ desired[taskH + contentH + i] = palette[i] ?? "";
114
119
  for (let i = 0; i < (bar.length || CORE_H); i++)
115
120
  desired[tb + i] = bar[i] ?? "";
116
- return desired;
121
+ return desired.map(line => clampAnsi(line, Math.max(1, (out.columns ?? 80) - 1)));
117
122
  }
118
123
  /** Diff the desired screen against what's on-screen; rewrite only changed rows. */
119
124
  function flush() {
@@ -132,15 +137,16 @@ function flush() {
132
137
  const caretRow = rows() - core + 1 + caretBarIndex;
133
138
  // The composer is a permanent region, so its caret shows whenever the composer
134
139
  // is active — independent of where the transcript is scrolled.
135
- s += showCaret ? `${ESC}${caretRow};${caretCol}H${SHOW}` : HIDE;
140
+ s += showCaret ? `${ESC}${caretRow};${Math.min(caretCol, out.columns ?? 80)}H${SHOW}` : HIDE;
136
141
  write(s);
137
142
  }
138
143
  /** Enter TUI mode: alt-screen, alt-scroll (wheel→arrows), clear, hide caret. */
139
144
  export function startScreen() {
140
- if (!out.isTTY)
145
+ if (!out.isTTY || process.env.TERM === "dumb")
141
146
  return;
142
147
  active = true;
143
148
  committed = [];
149
+ task = [];
144
150
  transient = [];
145
151
  palette = [];
146
152
  bar = [];
@@ -279,7 +285,7 @@ export function suspendScreen() {
279
285
  }
280
286
  /** Resume TUI mode after suspendScreen(), repainting the preserved transcript. */
281
287
  export function resumeScreen() {
282
- if (!out.isTTY)
288
+ if (!out.isTTY || process.env.TERM === "dumb")
283
289
  return;
284
290
  active = true;
285
291
  shown = [];
@@ -287,3 +293,5 @@ export function resumeScreen() {
287
293
  flush();
288
294
  out.on("resize", screenResize);
289
295
  }
296
+ /** Pin task evidence without changing transcript, approval or keyboard ownership. */
297
+ export function screenTask(lines) { task = lines.slice(0, 24); clampScroll(); flush(); }
package/dist/ui/select.js CHANGED
@@ -154,6 +154,10 @@ export function pickFromList(opts) {
154
154
  stdin.removeAllListeners("keypress");
155
155
  readline.emitKeypressEvents(stdin);
156
156
  const prevRaw = stdin.isRaw ?? false;
157
+ // A one-shot command (e.g. the trust prompt before `cos files`) must not
158
+ // leave stdin flowing behind it, or the finished command never exits.
159
+ // (isPaused() is false for a stream never resumed, so test flowing state.)
160
+ const wasPaused = stdin.readableFlowing !== true;
157
161
  if (stdin.isTTY)
158
162
  stdin.setRawMode(true);
159
163
  stdin.resume();
@@ -175,6 +179,8 @@ export function pickFromList(opts) {
175
179
  readline.clearScreenDown(stdout);
176
180
  stdin.removeListener("keypress", onKey);
177
181
  stdin.setRawMode(prevRaw);
182
+ if (wasPaused)
183
+ stdin.pause();
178
184
  if (suspended)
179
185
  resumeScreen(); // repaint the pinned composer + transcript
180
186
  resolve(val);