graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
feat(repl): transcript shows decisions, not raw tool output
justrachf478838a270b
diff --git a/docs/adr/0020-transcript-shows-decisions.md b/docs/adr/0020-transcript-shows-decisions.mdnew file mode 100644index 00000000..155649c1--- /dev/null+++ b/docs/adr/0020-transcript-shows-decisions.md@@ -0,0 +1,29 @@+# 0020. The transcript shows decisions, not raw tool output++Status: accepted 2026-08-21++## Context++ADR 0016 made the line REPL a WORKING block plus a bare `›`, and tool rows a+tree of verbs. Live bash chunks (0.0.268) and command-as-detail then dumped+branch lists, CI runs, and repeated `McpClosed` rows into that transcript. A+question like "is 0.0.269 passing tests?" became ten near-identical failed CI+lines. The user-relevant fact was "CI is red."++## Decision++- Never print data merely because a tool returned it. Print it only if the+ user would notice its absence.+- A tool row is one interpreted line (`✓ git 3 commits`). The command is not+ conversational. `/debug` (and the TUI fold) keeps the raw bytes inspectable.+- Repeated infrastructure failures of the same family collapse to one+ `! codedb unavailable`. The batch `↯ N failed` tally stays off when every+ failure was that family.+- WORKING is compact: `WORKING {goal} {done}/{total}` and a `├─`/`└─`+ checklist. No rules, no progress bar.++## Consequences++JSON `bash_output_chunk` events are unchanged. The hosted TUI sink still+streams into the fold. Expanding a one-liner from the line REPL is not a+feature yet; `/debug` is the escape hatch. ADR 0016's progress bar is retired.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex e884973c..5d49e9f7 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -30,6 +30,7 @@ record only when you need the evidence or the edge cases.| [0017](0017-model-election-ranks-signed-in-plans-first.md) | `/model` and `/models` on both frontends rank signed-in plan seats above credits and metered keys (`src/models_rank.zig`). || [0018](0018-standing-chrome-shows-last-turn-cache-hit.md) | Last-turn cache hit % rides with `ctx` on the line-REPL meter and the TUI footer; `/cache` stays the posture HUD. || [0019](0019-codedb-one-shot-over-hop-chains.md) | Advertise only `context` / `around` / `callpath` / `list_dir` / `status`; hop verbs stay callable, not on the menu. |+| [0020](0020-transcript-shows-decisions.md) | Transcript shows decisions: one interpreted tool line, collapsed infra failures, compact WORKING; raw output is `/debug` / TUI-fold. |## When to write onediff --git a/src/agent_prompt_render.zig b/src/agent_prompt_render.zigindex a4ed5092..811f0659 100644--- a/src/agent_prompt_render.zig+++ b/src/agent_prompt_render.zig@@ -82,60 +82,32 @@ fn workingActive(sw: engine_events.StandingWork) bool {return sw.goal.len > 0 or sw.todos_total > 0;}-fn writeRule(w: *Io.Writer, cols: usize) !void {- const n = @min(if (cols > 2) cols else 2, 64);- try w.writeAll(style.dim);- var i: usize = 0;- while (i < n) : (i += 1) try w.writeAll("─");- try w.print("{s}\n", .{style.reset});-}--/// Variation 4's playhead under the git-status count: filled work is accent,-/// the rest recedes, so the checklist is state rather than more narration.-fn writeProgress(w: *Io.Writer, done: u32, total: u32, cols: usize) !void {- if (total == 0) return;- const width: usize = @min(if (cols > 4) cols - 2 else 20, 40);- const filled: usize = @min(width, (@as(usize, done) * width) / @as(usize, total));- try w.writeAll(style.accent);- var i: usize = 0;- while (i < width) : (i += 1) {- if (i < filled) {- try w.writeAll("━");- } else if (i == filled and done < total) {- try w.writeAll("╺");- try w.writeAll(style.dim);- } else {- if (i == filled) try w.writeAll(style.dim);- try w.writeAll("━");- }- }- try w.print("{s}\n", .{style.reset});-}--/// Git-style WORKING block: the goal and checklist live here, not in the-/// agent narration and not mixed into the `›` prompt (variations 4+5).+/// Compact WORKING block: goal + N/M on one line, checklist as a tree.+/// No rules, no progress bar — those competed with the tool rows (ADR 0020).fn workingBlock(w: *Io.Writer, sw: engine_events.StandingWork, cols: usize) !void {if (!workingActive(sw)) return;- try writeRule(w, cols);try w.print("{s}WORKING", .{style.dim});if (sw.goal_status.len > 0) try w.print(" ({s})", .{sw.goal_status});- try w.print("{s}\n", .{style.reset});if (sw.goal.len > 0) {- const clip = util.utf8Prefix(sw.goal, if (cols > 8) cols - 2 else 40);- try w.print("{s}{s}{s}\n", .{ style.accent, clip, style.reset });+ var used: usize = "WORKING".len;+ if (sw.goal_status.len > 0) used += 3 + sw.goal_status.len;+ used += 2;+ if (sw.todos_total > 0) used += 7; // " 99/99"+ const room = if (cols > used) cols - used else 12;+ const clip = util.utf8Prefix(sw.goal, room);+ try w.print(" {s}{s}{s}", .{ style.accent, clip, style.dim });}- if (sw.todos_total > 0) {- try w.print("{s}{d} of {d}{s}\n", .{ style.dim, sw.todos_done, sw.todos_total, style.reset });- try writeProgress(w, sw.todos_done, sw.todos_total, cols);- for (sw.todos) |t| {- if (t.done) {- try w.print("{s}✓{s} {s}\n", .{ style.green, style.reset, t.content });- } else {- try w.print("{s}○{s} {s}\n", .{ style.dim, style.reset, t.content });- }+ if (sw.todos_total > 0) try w.print(" {d}/{d}", .{ sw.todos_done, sw.todos_total });+ try w.print("{s}\n", .{style.reset});+ for (sw.todos, 0..) |t, i| {+ const branch: []const u8 = if (i + 1 == sw.todos.len) "└─" else "├─";+ const clip = util.utf8Prefix(t.content, if (cols > 6) cols - 6 else 20);+ if (t.done) {+ try w.print("{s} {s}✓{s} {s}\n", .{ branch, style.green, style.reset, clip });+ } else {+ try w.print("{s} {s}○{s} {s}\n", .{ branch, style.dim, style.reset, clip });}}- try writeRule(w, cols);}fn line(w: *Io.Writer, st: PromptStatus, cols: usize) !void {@@ -464,13 +436,11 @@ test "WORKING block sits above a bare prompt and is skipped when empty" {.image = true,},};- try line(&aw.writer, full, 32);- const rule = "────────────────────────────────";- const bar = "━━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━"; // 15 filled + playhead + 14 rest at 30 cells+ try line(&aw.writer, full, 80);try std.testing.expectEqualStrings(- "\n" ++ rule ++ "\nWORKING (paused)\nship the repl standing line\n1 of 2\n" ++ bar ++- "\n✓ inspect current prompt\n○ update implementation\n" ++- rule ++ "\nm · image · login-fix\n› ",+ "\nWORKING (paused) ship the repl standing line 1/2\n" +++ "├─ ✓ inspect current prompt\n└─ ○ update implementation\n" +++ "m · image · login-fix\n› ",aw.writer.buffered(),);}diff --git a/src/agent_tool_label.zig b/src/agent_tool_label.zigindex e4de4005..8c734197 100644--- a/src/agent_tool_label.zig+++ b/src/agent_tool_label.zig@@ -36,8 +36,18 @@ pub fn newlineCount(s: []const u8) usize {return n;}+fn displayPath(path: []const u8) []const u8 {+ if (path.len == 0) return path;+ if (std.fs.path.isAbsolute(path)) {+ const base = std.fs.path.basename(path);+ return if (base.len > 0) base else path;+ }+ return path;+}+fn namedDetailField(name: []const u8, input: std.json.Value) ?[]const u8 {- if (std.mem.eql(u8, name, "bash") or std.mem.eql(u8, name, "codedb")) return "command";+ // bash's command is not conversational — the ✓ line interprets the result.+ if (std.mem.eql(u8, name, "codedb")) return "command";if (std.mem.eql(u8, name, "read_file") orstd.mem.eql(u8, name, "write_file") orstd.mem.eql(u8, name, "edit_file")) return "path";@@ -63,7 +73,10 @@ fn fallbackDetail(input: std.json.Value) []const u8 {for (fallback_fields) |field| {const raw = stringField(input, field) orelse continue;const shown = firstLine(raw);- if (shown.len > 0) return shown;+ if (shown.len == 0) continue;+ if (std.mem.eql(u8, field, "path") or std.mem.eql(u8, field, "file") or std.mem.eql(u8, field, "uri"))+ return displayPath(shown);+ return shown;}return "";}@@ -95,13 +108,16 @@ pub fn editDelta(input: std.json.Value, path: []const u8, buf: []u8) []const u8}pub fn detail(t: ToolInvocation, buf: []u8) []const u8 {+ if (std.mem.eql(u8, t.name, "bash")) return "";if (std.mem.eql(u8, t.name, "edit_file")) {const path = stringField(t.input, "path") orelse return "";- return editDelta(t.input, firstLine(path), buf);+ return editDelta(t.input, displayPath(firstLine(path)), buf);}if (namedDetailField(t.name, t.input)) |field| {const raw = stringField(t.input, field) orelse return "";- return firstLine(raw);+ const shown = firstLine(raw);+ if (std.mem.eql(u8, field, "path") or std.mem.eql(u8, field, "file")) return displayPath(shown);+ return shown;}return fallbackDetail(t.input);}@@ -139,9 +155,16 @@ pub fn verb(name: []const u8, input: std.json.Value, buf: []u8) []const u8 {}if (std.mem.eql(u8, name, "subagent")) return "agent";if (std.mem.eql(u8, name, "imagegen")) return "image";- if (std.mem.startsWith(u8, name, "mcp_")) {- const rest = name["mcp_".len..];- const n = copy(buf, if (rest.len > 12) rest[0..12] else rest);+ if (std.mem.startsWith(u8, name, "mcp")) {+ const leaf = blk: {+ if (std.mem.lastIndexOf(u8, name, "__")) |u| {+ if (u + 2 < name.len) break :blk name[u + 2 ..];+ }+ if (std.mem.startsWith(u8, name, "mcp_")) break :blk name["mcp_".len..];+ break :blk name;+ };+ if (std.mem.endsWith(u8, leaf, "search")) return "search";+ const n = copy(buf, if (leaf.len > 12) leaf[0..12] else leaf);return buf[0..n];}const n = copy(buf, if (name.len > 12) name[0..12] else name);@@ -206,6 +229,158 @@ pub fn compactBash(line: []const u8, buf: []u8) []const u8 {return line;}+pub fn lastNonEmptyLine(text: []const u8) []const u8 {+ const rest = std.mem.trim(u8, text, " \t\r\n");+ if (std.mem.lastIndexOfScalar(u8, rest, '\n')) |nl|+ return std.mem.trim(u8, rest[nl + 1 ..], " \t\r");+ return rest;+}++fn hexPrefix(s: []const u8) usize {+ var i: usize = 0;+ while (i < s.len and i < 40) : (i += 1) {+ const c = s[i];+ const hex = (c >= '0' and c <= '9') or (c >= 'a' and c <= 'f') or (c >= 'A' and c <= 'F');+ if (!hex) break;+ }+ return i;+}++fn gitCommitCount(text: []const u8) ?usize {+ var n: usize = 0;+ var it = std.mem.splitScalar(u8, text, '\n');+ while (it.next()) |raw| {+ const s = std.mem.trim(u8, raw, " \t\r");+ const h = hexPrefix(s);+ if (h >= 7 and (h == s.len or s[h] == ' ')) n += 1;+ }+ return if (n >= 3) n else null;+}++fn looksLikeRefs(text: []const u8) bool {+ var n: usize = 0;+ var it = std.mem.splitScalar(u8, text, '\n');+ while (it.next()) |raw| {+ const s = std.mem.trim(u8, raw, " \t\r*");+ if (std.mem.startsWith(u8, s, "refs/") or+ std.mem.startsWith(u8, s, "remotes/") or+ std.mem.startsWith(u8, s, "origin/") or+ std.mem.startsWith(u8, s, "release/") or+ std.mem.eql(u8, s, "main")) n += 1;+ }+ return n >= 3;+}++fn isSummaryLine(s: []const u8) bool {+ if (s.len == 0 or s.len > 80) return false;+ if (std.mem.indexOf(u8, s, "passed") != null) return true;+ if (std.mem.indexOf(u8, s, "failed") != null) return true;+ if (std.mem.startsWith(u8, s, "ok") or std.mem.startsWith(u8, s, "OK")) return true;+ if (std.mem.startsWith(u8, s, "error") or std.mem.startsWith(u8, s, "Error")) return true;+ if (std.mem.startsWith(u8, s, "All ")) return true;+ for (s) |c| {+ if (c < '0' or c > '9') return false;+ }+ return true;+}++/// Scan a JSON object for `"key":` then a string, bool, or integer. Not a parser.+fn jsonQuoted(s: []const u8, key: []const u8) ?[]const u8 {+ var pat: [48]u8 = undefined;+ const p = std.fmt.bufPrint(&pat, "\"{s}\":", .{key}) catch return null;+ const at = std.mem.indexOf(u8, s, p) orelse return null;+ var j = at + p.len;+ while (j < s.len and (s[j] == ' ' or s[j] == '\t')) j += 1;+ if (j >= s.len) return null;+ if (s[j] == '"') {+ j += 1;+ const start = j;+ while (j < s.len) : (j += 1) {+ if (s[j] == '\\') {+ j += 1;+ continue;+ }+ if (s[j] == '"') return s[start..j];+ }+ return null;+ }+ if (std.mem.startsWith(u8, s[j..], "true")) return "true";+ if (std.mem.startsWith(u8, s[j..], "false")) return "false";+ const start = j;+ while (j < s.len and s[j] >= '0' and s[j] <= '9') j += 1;+ if (j > start) return s[start..j];+ return null;+}++fn escapedNewlineCount(json_string: []const u8) usize {+ var n: usize = 1;+ var i: usize = 0;+ while (i + 1 < json_string.len) : (i += 1) {+ if (json_string[i] == '\\' and json_string[i + 1] == 'n') n += 1;+ }+ return n;+}++/// JSON tool results (CodeDB Pro, MCP) become a decision, never the envelope.+fn interpretJson(s: []const u8, buf: []u8) []const u8 {+ if (jsonQuoted(s, "ok")) |ok| {+ if (std.mem.eql(u8, ok, "false")) {+ if (jsonQuoted(s, "error")) |err| {+ return if (err.len > result_preview_bytes) err[0..result_preview_bytes] else err;+ }+ return "failed";+ }+ }+ if (jsonQuoted(s, "matches")) |m|+ return std.fmt.bufPrint(buf, "{s} matches", .{m}) catch m;+ if (jsonQuoted(s, "mode")) |mode| {+ const lines = if (jsonQuoted(s, "content")) |c| escapedNewlineCount(c) else 0;+ if (lines > 1)+ return std.fmt.bufPrint(buf, "{s} · {d} lines", .{ mode, lines }) catch mode;+ return mode;+ }+ return "";+}++/// One-line decision the transcript shows. Raw output stays off this line.+pub fn interpret(name: []const u8, all: []const u8, buf: []u8) []const u8 {+ if (all.len == 0) return "";+ const trimmed = std.mem.trimStart(u8, all, " \t\r\n");+ if (trimmed.len > 0 and trimmed[0] == '{') return interpretJson(trimmed, buf);+ const lines = newlineCount(all);+ if (std.mem.eql(u8, name, "read_file") and lines > 1) {+ return std.fmt.bufPrint(buf, "{d} lines", .{lines}) catch all;+ }+ const bashy = std.mem.eql(u8, name, "bash") or std.mem.eql(u8, name, "codedb");+ if (bashy and lines > 1) {+ if (gitCommitCount(all)) |n|+ return std.fmt.bufPrint(buf, "{d} commits", .{n}) catch lastNonEmptyLine(all);+ if (looksLikeRefs(all) and lines >= 4)+ return std.fmt.bufPrint(buf, "{d} branches", .{lines}) catch lastNonEmptyLine(all);+ const last = lastNonEmptyLine(all);+ const compacted = compactBash(last, buf);+ if (!std.mem.eql(u8, compacted, last)) return compacted;+ if (isSummaryLine(last)) {+ return if (last.len > result_preview_bytes) last[0..result_preview_bytes] else last;+ }+ if (lines >= 4)+ return std.fmt.bufPrint(buf, "{d} lines", .{lines}) catch last;+ return if (last.len > result_preview_bytes) last[0..result_preview_bytes] else last;+ }+ if (bashy) return compactBash(firstLine(all), buf);+ const raw = firstLine(all);+ return if (raw.len > result_preview_bytes) raw[0..result_preview_bytes] else raw;+}++/// Transport death, not a tool bug. The transcript names the family once.+pub fn infraFamily(name: []const u8, text: []const u8) ?[]const u8 {+ const closed = std.mem.indexOf(u8, text, "McpClosed") != null or+ std.mem.indexOf(u8, text, "McpHandshakeTimeout") != null;+ if (!closed) return null;+ if (std.mem.indexOf(u8, name, "codedb") != null) return "codedb";+ return "mcp";+}+/// Drop a result preview that only restates the verb/detail (the edit/// harness saying "applied N edit span(s)…" when `+12/-4` is already there).pub fn usefulPreview(name: []const u8, known: []const u8, shown: []const u8) []const u8 {@@ -215,6 +390,7 @@ pub fn usefulPreview(name: []const u8, known: []const u8, shown: []const u8) []cif (std.mem.indexOf(u8, known, " · +") != null) return "";}if (known.len > 0 and std.mem.eql(u8, shown, known)) return "";+ if (shown.len > 0 and shown[0] == '{') return "";return shown;}@@ -239,3 +415,64 @@ test "usefulPreview drops edit-span boilerplate once +N/-N is known" {try std.testing.expectEqualStrings("4 matches", usefulPreview("mcp_search", "standing line", "4 matches"));try std.testing.expectEqualStrings("", usefulPreview("webfetch", "https://ex", "https://ex"));}++test "interpret turns git log and branch dumps into counts" {+ var buf: [32]u8 = undefined;+ const log =+ \\d022479 feat(ui): cache+ \\8f75b5b fix(tui): chips+ \\4ba84b3 feat(models): seats+ \\+ ;+ try std.testing.expectEqualStrings("3 commits", interpret("bash", log, &buf));+ const refs =+ \\* release/v0.0.269+ \\ main+ \\ remotes/origin/main+ \\ remotes/origin/release/v0.0.269+ \\+ ;+ try std.testing.expectEqualStrings("4 branches", interpret("bash", refs, &buf));+ try std.testing.expectEqualStrings("29", interpret("bash", "29\n", &buf));+}++test "bash detail is empty so the command never becomes the transcript" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ var buf: [16]u8 = undefined;+ const input = try std.json.parseFromSliceLeaky(std.json.Value, arena_state.allocator(), "{\"command\":\"git log --oneline v0.0.267..HEAD | wc -l\"}", .{});+ try std.testing.expectEqualStrings("", detail(.{ .name = "bash", .input = input }, &buf));+ try std.testing.expectEqualStrings("git", verb("bash", input, &buf));+}++test "mcp verb is the leaf, not _codedbpro_" {+ var buf: [16]u8 = undefined;+ try std.testing.expectEqualStrings("read", verb("mcp__codedbpro__read", .null, &buf));+ try std.testing.expectEqualStrings("search", verb("mcp__codedbpro__faster_search", .null, &buf));+ try std.testing.expectEqualStrings("search", verb("mcp_search", .null, &buf));+}++test "infraFamily collapses McpClosed to a family name" {+ try std.testing.expectEqualStrings("codedb", infraFamily("mcp__codedbpro__read", "McpClosed") orelse "");+ try std.testing.expectEqualStrings("mcp", infraFamily("mcp__github__get", "McpHandshakeTimeout") orelse "");+ try std.testing.expect(infraFamily("bash", "boom") == null);+}++test "interpretJson never leaks a CodeDB envelope" {+ var buf: [48]u8 = undefined;+ const section =+ \\{"ok":true,"file":"/Users/rachpradhan/codedb/docs/architecture.md","mode":"section","content":"a\nb\nc"}+ ;+ try std.testing.expectEqualStrings("section · 3 lines", interpret("mcp__codedbpro__read", section, &buf));+ try std.testing.expectEqualStrings("5 matches", interpret("mcp__codedbpro__faster_search", "{\"ok\":true,\"matches\":5}", &buf));+ try std.testing.expectEqualStrings("outline", interpret("mcp__codedbpro__read", "{\"ok\":true,\"mode\":\"outline\"}", &buf));+ try std.testing.expectEqualStrings("", interpret("mcp__codedbpro__read", "{\"ok\":true,\"file\":\"x.md\"}", &buf));+}++test "mcp file detail is the basename, not the absolute path" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ var buf: [16]u8 = undefined;+ const input = try std.json.parseFromSliceLeaky(std.json.Value, arena_state.allocator(), "{\"file\":\"/Users/rachpradhan/codedb/docs/architecture.md\",\"mode\":\"section\"}", .{});+ try std.testing.expectEqualStrings("architecture.md", detail(.{ .name = "mcp__codedbpro__read", .input = input }, &buf));+}diff --git a/src/agent_tool_render.zig b/src/agent_tool_render.zigindex cb0e2736..8439bb13 100644--- a/src/agent_tool_render.zig+++ b/src/agent_tool_render.zig@@ -91,13 +91,6 @@ fn handleBadge(text: []const u8) ?HandleBadge {return null;}-fn lastNonEmptyLine(text: []const u8) []const u8 {- const rest = std.mem.trim(u8, text, " \t\r\n");- if (std.mem.lastIndexOfScalar(u8, rest, '\n')) |nl|- return std.mem.trim(u8, rest[nl + 1 ..], " \t\r");- return rest;-}-const Preview = struct { text: []const u8, clipped: bool };/// First useful line — or a short summary. Handle markers stay off the line;@@ -106,17 +99,29 @@ fn resultPreview(name: []const u8, all: []const u8, buf: []u8) Preview {if (handleBadge(all) != null) return .{ .text = "", .clipped = false };if (std.mem.startsWith(u8, all, handle_marker) or std.mem.startsWith(u8, all, truncated_marker))return .{ .text = "", .clipped = false };- const lines = label.newlineCount(all);- if (std.mem.eql(u8, name, "read_file") and lines > 1) {- const text = std.fmt.bufPrint(buf, "{d} lines", .{lines}) catch all;- return .{ .text = text, .clipped = false };- }- var raw = if (std.mem.eql(u8, name, "bash") and lines > 1) lastNonEmptyLine(all) else label.firstLine(all);- if (std.mem.eql(u8, name, "bash")) raw = label.compactBash(raw, buf);+ const raw = label.interpret(name, all, buf);if (raw.len > label.result_preview_bytes) return .{ .text = raw[0..label.result_preview_bytes], .clipped = true };return .{ .text = raw, .clipped = false };}+/// Same family of transport death already named this turn. The transcript+/// says it once; later rows are inspectable in /debug, not conversational.+var infra_fam: []const u8 = "";+var infra_count: usize = 0;++pub fn resetInfra() void {+ infra_fam = "";+ infra_count = 0;+}++/// Live bash bytes belong in /debug (and the TUI fold), not the line REPL.+pub fn liveOutput(a: *Agent, text: []const u8) void {+ if (!repl.g_debug) return;+ const w = a.out orelse return;+ w.writeAll(text) catch return;+ w.flush() catch return;+}+/// Compact result feedback for one finished tool call: a green ✓ / red ✗ //// yellow ⊘ and a one-line preview of what it returned. A result that spilled/// to a #440 handle (or was truncated without one) also badges the spill size —@@ -128,7 +133,18 @@ pub fn toolResultLine(a: *Agent, r: ToolOutcome) void {const w = a.out orelse return;if (r.meta) return;const all = std.mem.trim(u8, r.text, " \t\r\n");- var pbuf: [32]u8 = undefined;+ if (r.is_error) {+ if (label.infraFamily(r.name, all)) |fam| {+ _ = treePrefix();+ infra_count += 1;+ if (infra_fam.len > 0 and std.mem.eql(u8, infra_fam, fam)) return;+ infra_fam = fam;+ w.print(" {s}! {s} unavailable{s}\n", .{ style.yellow, fam, style.reset }) catch return;+ w.flush() catch return;+ return;+ }+ }+ var pbuf: [48]u8 = undefined;const preview = resultPreview(r.name, all, &pbuf);const shown = preview.text;const truncated = preview.clipped;@@ -187,6 +203,12 @@ pub fn parallelBatchStarted(a: *Agent, count: usize) void {pub fn parallelBatchFinished(a: *Agent, o: BatchOutcome) void {batch_left = 0;+ const infra_only = infra_count > 0 and o.failed == infra_count;+ if (infra_only) {+ resetInfra();+ return;+ }+ resetInfra();if (o.failed == 0 and o.cancelled == 0) return;var buf: [notice_buf_bytes]u8 = undefined;const line = if (o.cancelled == 0)@@ -219,6 +241,7 @@ pub fn toolTextLine(a: *Agent, text: []const u8) void {fn testAgent(w: *Io.Writer) Agent {batch_left = 0;label.resetPending();+ resetInfra();return .{.gpa = std.testing.allocator,.arena = std.testing.allocator,@@ -439,3 +462,62 @@ test "bash result prefers the last line of a multi-line run" {});try std.testing.expectEqualStrings(" ✓ bash 1475 passed\n", aw.writer.buffered());}++test "bash git log is a count, never the command" {+ const saved = ansi.style;+ ansi.style = .{};+ defer ansi.style = saved;+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ var aw: Io.Writer.Allocating = .init(std.testing.allocator);+ defer aw.deinit();+ var a = testAgent(&aw.writer);+ const input = try std.json.parseFromSliceLeaky(std.json.Value, arena_state.allocator(), "{\"command\":\"git log --oneline v0.0.267..HEAD\"}", .{});+ toolUseLine(&a, .{ .name = "bash", .input = input });+ toolResultLine(&a, .{+ .name = "bash",+ .text = "d022479 feat(ui): cache\n8f75b5b fix(tui): chips\n4ba84b3 feat(models): seats\n",+ .is_error = false,+ });+ try std.testing.expectEqualStrings(" ✓ git 3 commits\n", aw.writer.buffered());+}++test "repeated McpClosed collapses to one notice and skips the batch tally" {+ const saved = ansi.style;+ ansi.style = .{};+ defer ansi.style = saved;+ const saved_json = main_mod.json_mode;+ main_mod.json_mode = false;+ defer main_mod.json_mode = saved_json;+ var aw: Io.Writer.Allocating = .init(std.testing.allocator);+ defer aw.deinit();+ var a = testAgent(&aw.writer);++ parallelBatchStarted(&a, 3);+ toolResultLine(&a, .{ .name = "mcp__codedbpro__read", .text = "McpClosed", .is_error = true });+ toolResultLine(&a, .{ .name = "mcp__codedbpro__read", .text = "McpClosed", .is_error = true });+ toolResultLine(&a, .{ .name = "mcp__codedbpro__faster_search", .text = "McpClosed", .is_error = true });+ try std.testing.expectEqualStrings(" ! codedb unavailable\n", aw.writer.buffered());+ aw.clearRetainingCapacity();+ parallelBatchFinished(&a, .{ .done = 0, .failed = 3, .cancelled = 0 });+ try std.testing.expectEqualStrings("", aw.writer.buffered());+}++test "codedb JSON read is basename plus mode, not the envelope" {+ const saved = ansi.style;+ ansi.style = .{};+ defer ansi.style = saved;+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ var aw: Io.Writer.Allocating = .init(std.testing.allocator);+ defer aw.deinit();+ var a = testAgent(&aw.writer);+ const input = try std.json.parseFromSliceLeaky(std.json.Value, arena_state.allocator(), "{\"file\":\"/Users/rachpradhan/codedb/docs/architecture.md\",\"mode\":\"section\"}", .{});+ toolUseLine(&a, .{ .name = "mcp__codedbpro__read", .input = input });+ toolResultLine(&a, .{+ .name = "mcp__codedbpro__read",+ .text = "{\"ok\":true,\"file\":\"/Users/rachpradhan/codedb/docs/architecture.md\",\"mode\":\"section\",\"content\":\"a\\nb\\nc\"}",+ .is_error = false,+ });+ try std.testing.expectEqualStrings(" ✓ read architecture.md section · 3 lines\n", aw.writer.buffered());+}diff --git a/src/cli.zig b/src/cli.zigindex 710de141..9c420321 100644--- a/src/cli.zig+++ b/src/cli.zig@@ -25,6 +25,7 @@ pub const changelog_text =\\ • Vercel AI Gateway (AI_GATEWAY_API_KEY → alibaba/qwen3.8-27b); coding-agent /v1\\ • Z.AI defaults to GLM-5.3 (1M); thinking.enabled + implicit prefix cache\\ • GLM Coding Plan: ZAI_CODING=1 / GRAFF_ZAI_URL; not image/video+ \\ • Line REPL tool rows are decisions; live bash is /debug-only\\\\0.0.268\\ • Cerebras Inference (CEREBRAS_API_KEY → gpt-oss-120b); not the WSE CSL SDKdiff --git a/src/engine_sink.zig b/src/engine_sink.zigindex 7ed10802..81e467ef 100644--- a/src/engine_sink.zig+++ b/src/engine_sink.zig@@ -245,10 +245,8 @@ fn tuiEmit(ctx: *anyopaque, ev: Stamped) void {}},// grok-build RawTerminal/Append: live bash bytes, not markdown.- .tool_output_delta => |d| if (a.out) |w| {- w.writeAll(d.text) catch return;- w.flush() catch return;- },+ // Line REPL keeps them off the transcript unless /debug (ADR 0020).+ .tool_output_delta => |d| tool_render.liveOutput(a, d.text),.job_completed => |j| {var buf: [80]u8 = undefined;const msg = if (j.killed)@@ -323,7 +321,10 @@ fn tuiEmit(ctx: *anyopaque, ev: Stamped) void {// The status line before a human turn (#429). Its drawing — palette,// badge frame, and the #209 width budget that decides which segments// survive a narrow pane — lives in agent_prompt_render.- .prompt_ready => |st| if (a.out) |w| prompt_render.promptLine(w, st),+ .prompt_ready => |st| {+ tool_render.resetInfra();+ if (a.out) |w| prompt_render.promptLine(w, st);+ },}}diff --git a/src/exec_bash_stream.zig b/src/exec_bash_stream.zigindex ba1fbfd5..b4f25dfa 100644--- a/src/exec_bash_stream.zig+++ b/src/exec_bash_stream.zig@@ -55,6 +55,9 @@ fn emitOne(ctx: ?*anyopaque, which: u8, chunk: []const u8) void {w.flush() catch {};return;}+ // Line REPL: live bytes are inspectable via /debug, not conversational.+ // The hosted TUI sink (above) still streams into the fold.+ if (!@import("repl.zig").g_debug) return;w.writeAll(chunk) catch return;w.flush() catch {};}