graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
feat(repl): transcript is the task, not the event bus
Rach Pradhan98958fcbc8c8
diff --git a/TUI/app.zig b/TUI/app.zigindex 946c53aa..556d6c3c 100644--- a/TUI/app.zig+++ b/TUI/app.zig@@ -24,8 +24,12 @@ pub const ToolInfo = struct {/// The engine's tool name, verbatim. Classification (mcp / search) tests/// this, never the whole row.name: []const u8,- /// Argument preview on a call, result preview on an outcome.+ /// Tier 1: One-line decision summary (via interpret).+ summary: []const u8 = "",+ /// Tier 2: High-signal facts (via usefulPreview).detail: []const u8 = "",+ /// Tier 3: The raw output from the engine.+ raw: []const u8 = "",/// false = the call was announced, true = it returned (or was refused).done: bool = false,is_error: bool = false,@@ -290,20 +294,25 @@ pub const Model = struct {pub fn pushTool(self: *Model, info: ToolInfo) !void {const name = try self.alloc.dupe(u8, info.name);errdefer self.alloc.free(name);+ const summary = try sanitized(self.alloc, info.summary);+ errdefer self.alloc.free(summary);const detail = try sanitized(self.alloc, info.detail);errdefer self.alloc.free(detail);- const text = if (detail.len > 0)- try std.fmt.allocPrint(self.alloc, "{s} {s}", .{ name, detail })- else- try self.alloc.dupe(u8, name);+ const raw = try sanitized(self.alloc, info.raw);+ errdefer self.alloc.free(raw);++ const text = try self.alloc.dupe(u8, summary);errdefer self.alloc.free(text);+try self.history.append(.{.kind = .tool,.text = text,.folded = true,.tool = .{.name = name,+ .summary = summary,.detail = detail,+ .raw = raw,.done = info.done,.is_error = info.is_error,.denied = info.denied,@@ -318,7 +327,9 @@ pub const Model = struct {self.alloc.free(e.text);if (e.tool) |t| {self.alloc.free(t.name);+ self.alloc.free(t.summary);self.alloc.free(t.detail);+ self.alloc.free(t.raw);}}diff --git a/TUI/foldhdr.zig b/TUI/foldhdr.zigindex 8dd938fd..f5b83590 100644--- a/TUI/foldhdr.zig+++ b/TUI/foldhdr.zig@@ -55,7 +55,7 @@ fn verbOf(f: Family) Verb {.bash => .{ .present = "Running", .past = "Ran", .noun = "command", .solo_tool = true },.search => .{ .present = "Searching", .past = "Searched", .noun = "pattern" },.web => .{ .present = "Fetching", .past = "Fetched", .noun = "page" },- .task => .{ .present = "Running", .past = "Ran", .noun = "task" },+ .task => .{ .present = "Scouting", .past = "Scouted", .noun = "scout" },.todo => .{ .present = "Updating", .past = "Updated", .noun = "todo" },.mcp => .{ .present = "Calling", .past = "Called", .noun = "MCP tool" },.other => .{ .present = "Calling", .past = "Called", .noun = "tool", .solo_tool = true },@@ -99,7 +99,11 @@ pub fn leafOf(name: []const u8) []const u8 {pub fn displayName(name: []const u8) []const u8 {if (std.mem.eql(u8, name, "read_file")) return "read";if (std.mem.eql(u8, name, "write_file")) return "write";- return leafOf(name);+ if (std.mem.eql(u8, name, "read_tool_result")) return "inspect";+ const leaf = leafOf(name);+ if (std.mem.eql(u8, leaf, "batch")) return "inspect";+ if (std.mem.eql(u8, name, "subagent") or std.mem.eql(u8, name, "workflow")) return "scout";+ return leaf;}/// Which verb family a tool name belongs to. Exact names first — they are what@@ -294,7 +298,7 @@ test "each family gets its own verb and object" {.{ .f = .edit, .n = 3, .want = "Edited 3 files" },.{ .f = .search, .n = 2, .want = "Searched 2 patterns" },.{ .f = .web, .n = 1, .want = "Fetched 1 page" },- .{ .f = .task, .n = 2, .want = "Ran 2 tasks" },+ .{ .f = .task, .n = 2, .want = "Scouted 2 scouts" },.{ .f = .todo, .n = 1, .want = "Updated 1 todo" },.{ .f = .mcp, .n = 2, .want = "Called 2 MCP tools" },.{ .f = .mixed, .n = 3, .want = "Called 3 tools" },diff --git a/TUI/scrollback.zig b/TUI/scrollback.zigindex 0ef0f831..558ada71 100644--- a/TUI/scrollback.zig+++ b/TUI/scrollback.zig@@ -288,13 +288,12 @@ fn toolTitle(a: std.mem.Allocator, named: app.Entry, status: app.Entry) ![]constelse"";const name = displayName(t.name);- // A finished row's detail is its RESULT preview and belongs in the body.const args = if (t.done) "" else t.detail;if (args.len == 0) return if (mark.len == 0) name else std.fmt.allocPrint(a, "{s}{s}", .{ mark, name });return std.fmt.allocPrint(a, "{s}{s} {s}", .{ mark, name, args });}-/// The one-line body under a tool card: the outcome's result preview.+/// The one-line body under a tool card: the outcome's useful detail.fn toolPreview(e: app.Entry) ?[]const u8 {const t = e.tool orelse return null;if (!t.done or t.detail.len == 0) return null;@@ -322,11 +321,9 @@ fn toolCard(a: std.mem.Allocator, th: theme_mod.Theme, call: app.Entry, outcome:const preview = toolPreview(outcome);const head = try std.fmt.allocPrint(a, "{s}{s}{s}{s}{s} {s}", .{ sel, if (selected) th.accent else th.muted, glyphs.tool, theme_mod.reset, th.text, title });if (preview == null) return theme_mod.wrapToWidth(a, head, width);- // A patch-shaped result is banded, not quoted: diff.zig owns its wrap.if (diff_mod.looksLikeUnified(preview.?)) return std.fmt.allocPrint(a, "{s}\n{s}", .{ try theme_mod.wrapToWidth(a, head, width), try diff_mod.renderThemed(a, preview.?, th, width) });const body = try std.fmt.allocPrint(a, "{s}{s}│ {s}{s}", .{ sel, th.muted, preview.?, theme_mod.reset });- const joined = try std.fmt.allocPrint(a, "{s}\n{s}", .{ try theme_mod.wrapToWidth(a, head, width), try theme_mod.wrapToWidth(a, body, width) });- return joined;+ return std.fmt.allocPrint(a, "{s}\n{s}", .{ try theme_mod.wrapToWidth(a, head, width), try theme_mod.wrapToWidth(a, body, width) });}fn thinkingGlyph(now_ms: u64) []const u8 {diff --git a/TUI/turn.zig b/TUI/turn.zigindex 261c9776..bfd20453 100644--- a/TUI/turn.zig+++ b/TUI/turn.zig@@ -212,28 +212,32 @@ pub fn drainEvents(self: *Model) void {fn applyEvent(self: *Model, ev: engine.Event) void {switch (ev) {- .tool_started => |t| self.pushTool(.{ .name = t.name, .detail = t.detail }) catch {},- .tool_finished => |t| self.pushTool(.{- .name = t.name,- .detail = t.detail,- .done = true,- .is_error = t.is_error,- }) catch {},- // A refusal is a finished tool row in the error state: the TUI has a- // surface for that today, and dropping it (as the old sink did) left- // the user watching a call that simply never came back.- .tool_rejected => |t| self.pushTool(.{- .name = t.name,- .detail = t.detail,- .done = true,- .is_error = true,- .denied = true,- }) catch {},+ .tool_started => |t| {+ if (std.mem.startsWith(u8, t.name, "internal_")) return;+ self.pushTool(.{ .name = t.name, .summary = t.detail, .detail = t.detail }) catch {};+ },+ .tool_finished => |t| {+ if (std.mem.startsWith(u8, t.name, "internal_")) return;+ self.pushTool(.{+ .name = t.name,+ .summary = t.detail,+ .detail = t.detail,+ .done = true,+ .is_error = t.is_error,+ }) catch {};+ },+ .tool_rejected => |t| {+ if (std.mem.startsWith(u8, t.name, "internal_")) return;+ self.pushTool(.{+ .name = t.name,+ .summary = t.detail,+ .detail = t.detail,+ .done = true,+ .is_error = true,+ .denied = true,+ }) catch {};+ },.notice => |s| self.push(.system, s) catch {},- // A mid-turn failover changes what the status bar must say. The event's- // copy dies with this drain, so the Model takes ownership of the name- // the global points at.- // The engine's meters, measured against the request it actually sent..status => |st| self.setStatus(st),.model_changed => |s| if (self.alloc.dupe(u8, s)) |owned| {if (self.model_override) |old| self.alloc.free(old);diff --git a/docs/adr/0011-prompt-cache-max-is-visible.md b/docs/adr/0011-prompt-cache-max-is-visible.mdindex 7e364460..ad54b1b4 100644--- a/docs/adr/0011-prompt-cache-max-is-visible.md+++ b/docs/adr/0011-prompt-cache-max-is-visible.md@@ -39,6 +39,10 @@ A `/cache` after a miss names the lever. Revisit defaulting stable-catalogonly if a new live measurement shows load-after-load cache-read returningfrom 0% without discovery or compaction regressions.+Subagents (2026-08-21): non-xAI children share four role-lane prefix keys so+repeated scouts reuse system+tools. xAI children stay per-agent — mixing them+into the root conv-id would break append-only prefix matching (ADR 0009).+Live Grok 4.6 (Responses, SuperGrok OAuth, 2026-08-19): same-processappend-only turn 2 cached 3,712 of turn 1's 3,721 input tokens. `/btw` afterthat turn reused **3,712** tokens (99.8% of the prior prompt). A new processdiff --git a/docs/adr/0021-transcript-is-the-task-not-the-bus.md b/docs/adr/0021-transcript-is-the-task-not-the-bus.mdnew file mode 100644index 00000000..ba2c7fbc--- /dev/null+++ b/docs/adr/0021-transcript-is-the-task-not-the-bus.md@@ -0,0 +1,34 @@+# 0021. The transcript is the task, not the event bus++Status: accepted 2026-08-21++## Context++ADR 0016 and 0020 made tool rows verbs and WORKING chrome, but the line REPL+still printed harness bookkeeping: `⛔ constraint recorded`, `# skill:`,+`[compacting…]`, `[~]` todo dumps, `read_tool_re` paging, and eight-line+subagent cards with `sa-000-…` ids. To the user those are one fact — the+work — not six UI concepts.++## Decision++Every harness event is one of four classes:++| Class | User sees |+| --- | --- |+| Internal bookkeeping | nothing |+| Work in progress | one ephemeral line, or WORKING on change |+| Useful operation | a semantic one-liner |+| New information | model narration |++`note_constraint`, `skill`, `read_tool_result`, and successful compaction are+bookkeeping (`/debug` still prints compaction). `todo_write` reprints a+`WORKING` block only when the checklist changes, and the same block sits+above `›`. Subagents are `↯ scout` / `✓ scout` one-liners; the `sa-` id is+not foreground UI. `batch` is `inspect`. Observe, then conclude, then act.++## Consequences++JSON events and tool results the model reads are unchanged. `/debug` and+`.graff/subagents/<id>.md` remain the escape hatch. A later TUI chrome pass+can bind WORKING to the pager footer the same way.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 5d49e9f7..dfadd37e 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -31,6 +31,7 @@ record only when you need the evidence or the edge cases.| [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. |+| [0021](0021-transcript-is-the-task-not-the-bus.md) | Transcript is the task, not the event bus: bookkeeping is silent, todos are WORKING, subagents are scouts. |## When to write onediff --git a/install.sh b/install.shindex baa6e096..df21c85d 100644--- a/install.sh+++ b/install.sh@@ -56,12 +56,29 @@ need_zig() {printf " ${D}zig${N} $v\n"}+# Apple Silicon SIGKILLs a binary whose signature no longer matches the+# kernel cache for that path. Leave a notarized Developer ID alone (re-signing+# strips the staple). Do NOT Developer-ID-sign a local zig build: unnotarized+# Developer ID + hardened runtime is `SIGKILL (Code Signature Invalid)` once+# --yolo pages in more than --version. Ad-hoc is the correct local signature.+darwin_sign() {+ [ "$(uname -s)" = Darwin ] || return 0+ local bin="$1"+ [ -f "$bin" ] || return 0+ if codesign --verify --strict "$bin" >/dev/null 2>&1 \+ && codesign -dv --verbose=2 "$bin" 2>&1 | grep -q 'Authority=Developer ID Application'; then+ return 0+ fi+ codesign -s - --force --identifier graff "$bin" >/dev/null 2>&1 || true+}+# Drop the binary onto a *fresh inode*: overwriting a running macOS binary in# place gets the replacement SIGKILLed by the kernel's signature cache.place_bin() {mkdir -p "$INSTALL_DIR"rm -f "$INSTALL_DIR/$BIN"install -m 0755 "$1" "$INSTALL_DIR/$BIN"+ darwin_sign "$INSTALL_DIR/$BIN"# Overwrite any *other* graff already on PATH (e.g. an older copy in# ~/.local/bin from the codegraff stack) so the binary we just installed@@ -74,6 +91,7 @@ place_bin() {[ "$d" = "$INSTALL_DIR" ] && continueif [ -f "$d/$BIN" ] && [ -w "$d/$BIN" ]; thenif rm -f "$d/$BIN" && install -m 0755 "$1" "$d/$BIN" 2>/dev/null; then+ darwin_sign "$d/$BIN"printf " ${D}│${N} %-10s ${G}✓${N} (overwrote stale $d/$BIN)\n" "replace"fifi@@ -127,14 +145,6 @@ fetch_release() {fi[ -n "$binpath" ] && [ -f "$binpath" ] || { rm -rf "$tmpd"; return 1; }place_bin "$binpath"- if [ "$(uname -s)" = "Darwin" ]; then- # The release binary is already Developer-ID-signed + notarized — that both- # satisfies Gatekeeper and avoids the Apple-Silicon SIGKILL, so leave it be.- # Only ad-hoc re-sign when it does NOT already verify (older unsigned tarballs- # or a source build); re-signing a notarized binary would strip its Developer ID.- codesign --verify --strict "$INSTALL_DIR/$BIN" >/dev/null 2>&1 \- || codesign -s - --force "$INSTALL_DIR/$BIN" >/dev/null 2>&1 || true- firm -rf "$tmpd"# Fail closed: if the binary didn't actually land, return non-zero so the# caller falls back to a source build instead of falsely reporting success.diff --git a/src/agent_compact.zig b/src/agent_compact.zigindex ef3992cb..9b528bbc 100644--- a/src/agent_compact.zig+++ b/src/agent_compact.zig@@ -116,7 +116,9 @@ pub fn compact(self: *Agent) anyerror!usize {if (!main_mod.json_mode) try self.say("nothing to compact\n", .{});return 0;};- if (!main_mod.json_mode) try self.say("[compacting ~{d} tokens…]\n", .{pending_tokens});+ // ADR 0021: successful compaction is a status-bar fact, not a transcript+ // row. `/debug` still prints the archaeology.+ if (!main_mod.json_mode and @import("repl.zig").g_debug) try self.say("[compacting ~{d} tokens…]\n", .{pending_tokens});// #391: the agent writes its own handoff BEFORE the summarizer rewrites the// history it describes. Gated, budgeted, best-effort: every refusal is a// named skip, so everything below runs unconditionally.@@ -219,7 +221,7 @@ pub fn compact(self: *Agent) anyerror!usize {// Responses wire. Manual /compact on codex lands here too — correctly// labeled, since it IS a client compaction.if (self.provider.kind == .responses) server_compact.noteClientSummary(summary.len);- if (!main_mod.json_mode) try self.say("[history compacted to a {d}-char summary]\n", .{summary.len});+ if (!main_mod.json_mode and @import("repl.zig").g_debug) try self.say("[history compacted to a {d}-char summary]\n", .{summary.len});return summary.len;}diff --git a/src/agent_prompt.zig b/src/agent_prompt.zigindex c0f10c69..219b7843 100644--- a/src/agent_prompt.zig+++ b/src/agent_prompt.zig@@ -87,11 +87,13 @@ fn standing(self: *const Agent) engine_events.StandingWork {if (t.epoch != epoch or t.retired) continue;out.todos_total += 1;const done = std.mem.eql(u8, t.status, "completed");+ const active = std.mem.eql(u8, t.status, "in_progress");if (done) out.todos_done += 1;if (items.items.len < 8) {items.append(self.arena, .{.content = util.utf8Prefix(t.content, 48),.done = done,+ .active = active,}) catch {};}}diff --git a/src/agent_prompt_render.zig b/src/agent_prompt_render.zigindex 811f0659..29c3280a 100644--- a/src/agent_prompt_render.zig+++ b/src/agent_prompt_render.zig@@ -17,8 +17,8 @@ const Io = std.Io;const style = &@import("ansi.zig").style;const terminal = @import("term.zig");const engine_events = @import("engine_events.zig");-const util = @import("util.zig");const PromptStatus = engine_events.PromptStatus;+const working = @import("agent_working.zig");pub fn reasoningLabel(effort: anytype) []const u8 {return switch (effort) {@@ -78,41 +78,21 @@ pub fn promptLine(w: *Io.Writer, st: PromptStatus) void {line(w, st, terminal.termCols()) catch return;}-fn workingActive(sw: engine_events.StandingWork) bool {- return sw.goal.len > 0 or sw.todos_total > 0;-}--/// 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 w.print("{s}WORKING", .{style.dim});- if (sw.goal_status.len > 0) try w.print(" ({s})", .{sw.goal_status});- if (sw.goal.len > 0) {- 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(" {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 });- }+fn cwdName(cwd: []const u8) []const u8 {+ var end = cwd.len;+ while (end > 1 and cwd[end - 1] == '/') end -= 1;+ const t = cwd[0..end];+ if (t.len == 0) return cwd;+ if (std.mem.lastIndexOfScalar(u8, t, '/')) |idx| {+ const rest = t[idx + 1 ..];+ return if (rest.len == 0) t else rest;}+ return t;}fn line(w: *Io.Writer, st: PromptStatus, cols: usize) !void {+ working.writeFromStanding(w, st.standing);try w.writeByte('\n');- try workingBlock(w, st.standing, cols);var cbuf: [24]u8 = undefined;const cost: []const u8 = switch (st.cost) {@@ -144,13 +124,15 @@ fn line(w: *Io.Writer, st: PromptStatus, cols: usize) !void {"";// Dim meter above a bare `›`. Operational badges (Fast/Plan/Strict)- // stay; cwd and the old bracket frame do not — they competed with input.- // #209: drop from the right so a narrow pane never splits a label.+ // stay. Cwd is a high-priority one-liner (`~/folder`) so the Codegraff+ // box does not have to restate the ask. #209: drop from the right.const avail = cols -| 1;var used: usize = st.model.len;+ const folder = cwdName(st.cwd);const show_fast = st.fast and fitsSegment(&used, avail, 3 + "Fast".len);const show_effort = st.effort != null andfitsSegment(&used, avail, 3 + reasoningLabel(st.effort.?).len);+ const show_cwd = folder.len > 0 and fitsSegment(&used, avail, 3 + 2 + folder.len);const show_fallback = st.fallback andfitsSegment(&used, avail, 3 + "Fallback".len);const show_plan = st.plan and fitsSegment(&used, avail, 3 + "Plan".len);@@ -167,6 +149,7 @@ fn line(w: *Io.Writer, st: PromptStatus, cols: usize) !void {try w.print("{s}{s}", .{ style.dim, st.model });if (show_fast) try w.print(" · Fast", .{});if (show_effort) try w.print(" · {s}", .{reasoningLabel(st.effort.?)});+ if (show_cwd) try w.print(" · ~/{s}", .{folder});if (show_fallback) try w.print(" · Fallback", .{});if (show_plan) try w.print(" · Plan", .{});if (show_strict) try w.print(" · Strict", .{});@@ -279,14 +262,14 @@ test "batch 3: every status-line segment renders exactly as it did inline" {.ultracode = true,};try std.testing.expectEqualStrings(- "\ngpt-5.6 · Fast · High · Fallback · Plan · Strict · Ultracode · ctx 6% · cache 16% · $0.50\n› ",+ "\ngpt-5.6 · Fast · High · ~/graff · Fallback · Plan · Strict · Ultracode · ctx 6% · cache 16% · $0.50\n› ",renderPlain(&aw, full),);// The bare line: no usage yet, meter off, no optional badge.aw.clearRetainingCapacity();try std.testing.expectEqualStrings(- "\nlmstudio\n› ",+ "\nlmstudio · ~/w\n› ",renderPlain(&aw, .{.model = "lmstudio",.provider_id = "lmstudio",@@ -300,7 +283,7 @@ test "batch 3: every status-line segment renders exactly as it did inline" {// unpriced model admits it rather than printing a fabricated 0.0000.aw.clearRetainingCapacity();try std.testing.expectEqualStrings(- "\nm · sub\n› ",+ "\nm · ~/w · sub\n› ",renderPlain(&aw, .{.model = "m",.provider_id = "p",@@ -312,7 +295,7 @@ test "batch 3: every status-line segment renders exactly as it did inline" {);aw.clearRetainingCapacity();try std.testing.expectEqualStrings(- "\nm · $?\n› ",+ "\nm · ~/w · $?\n› ",renderPlain(&aw, .{.model = "m",.provider_id = "p",@@ -345,8 +328,8 @@ test "batch 3: a shrinking pane sheds segments in the #209 priority order" {.cost = .unpriced,};const cases = [_]struct { cols: usize, want: []const u8 }{- .{ .cols = 80, .want = "\ngpt-5.6 · High · ctx 6% · cache 16% · $?\n› " },- .{ .cols = 28, .want = "\ngpt-5.6 · High · ctx 6%\n› " },+ .{ .cols = 80, .want = "\ngpt-5.6 · High · ~/graff · ctx 6% · cache 16% · $?\n› " },+ .{ .cols = 28, .want = "\ngpt-5.6 · High · ~/graff\n› " },.{ .cols = 18, .want = "\ngpt-5.6 · High\n› " },};for (cases) |c| {@@ -397,7 +380,7 @@ test "a measured turn prints last-turn cache hit next to ctx" {try std.testing.expect(std.mem.indexOf(u8, out, "cache 16%") != null);}-test "WORKING block sits above a bare prompt and is skipped when empty" {+test "standing work draws a WORKING block above the prompt" {const saved = style.*;style.* = .{};defer style.* = saved;@@ -411,7 +394,7 @@ test "WORKING block sits above a bare prompt and is skipped when empty" {.privacy = .local,};try std.testing.expectEqualStrings(- "\nm\n› ",+ "\nm · ~/w\n› ",renderPlain(&aw, bare),);@@ -438,9 +421,14 @@ test "WORKING block sits above a bare prompt and is skipped when empty" {};try line(&aw.writer, full, 80);try std.testing.expectEqualStrings(- "\nWORKING (paused) ship the repl standing line 1/2\n" ++- "├─ ✓ inspect current prompt\n└─ ○ update implementation\n" ++- "m · image · login-fix\n› ",+ "WORKING ship the repl standing line 1/2\n" +++ "├ ✓ inspect current prompt\n" +++ "└ ○ update implementation\n" +++ "\nm · ~/w · image · login-fix\n› ",aw.writer.buffered(),);}++test {+ _ = working;+}diff --git a/src/agent_request_body.zig b/src/agent_request_body.zigindex 4f567fb5..8a7beea4 100644--- a/src/agent_request_body.zig+++ b/src/agent_request_body.zig@@ -169,12 +169,11 @@ pub fn buildBody(self: *Agent, tools: ?[]const u8, force_tool: bool, stream: boo}try s.endObject();}- // Sticky cache partition from the first request. Durable per- // project so a new session still hits the warm system+tools- // prefix; children suffix so they do not evict the root.+ // Sticky cache partition. xAI stays per-agent; everyone else uses+ // a prefix lane so repeated subagent roles reuse system+tools.var ckbuf: [96]u8 = undefined;try s.objectField("prompt_cache_key");- try s.write(http_headers.promptCacheKey(self.io, self.label, self, &ckbuf));+ try s.write(http_headers.requestCacheKey(self.io, self.label, self, self.provider.id, &ckbuf));// reasoning_effort (codegraff/deepseek/zai) + Z.AI thinking + Vercel reasoning.effort.try @import("zai_wire.zig").writeChatExtras(&s, self.provider.id, self.sendReasoningEffort(), @tagName(self.reasoning));// --output-schema: structured outputs (xAI docs' response_format).@@ -584,6 +583,14 @@ test "openai-wire bodies send a sticky prompt_cache_key; children isolate" {const ce = std.mem.indexOfScalarPos(u8, cb, cs + needle.len, '"') orelse return error.MissingPromptCacheKey;const child_key = cb[cs + needle.len .. ce];try std.testing.expect(!std.mem.eql(u8, root_key, child_key));+ try std.testing.expect(std.mem.indexOf(u8, child_key, "-child-") != null);+ // Same role, different Agent: one prefix lane (prompt-cache max).+ var twin = child;+ const tb = try twin.buildBody(null, false, true, true);+ defer std.testing.allocator.free(tb);+ const ts = std.mem.indexOf(u8, tb, needle) orelse return error.MissingPromptCacheKey;+ const te = std.mem.indexOfScalarPos(u8, tb, ts + needle.len, '"') orelse return error.MissingPromptCacheKey;+ try std.testing.expectEqualStrings(child_key, tb[ts + needle.len .. te]);var oai = root;oai.provider = .{ .id = "openai", .kind = .responses, .auth = .bearer, .url = "", .api_key = "k", .model = "gpt-5.6", .context = 1_050_000 };diff --git a/src/agent_request_body_responses.zig b/src/agent_request_body_responses.zigindex 849185d8..43f6ee3c 100644--- a/src/agent_request_body_responses.zig+++ b/src/agent_request_body_responses.zig@@ -24,10 +24,7 @@ pub fn write(self: *Agent, s: *std.json.Stringify, tools: ?[]const u8, force_too// prefix lanes so repeated workflow roles can reuse the stable prompt.var ckbuf: [96]u8 = undefined;try s.objectField("prompt_cache_key");- if (std.mem.eql(u8, self.provider.id, "xai"))- try s.write(http_headers.promptCacheKey(self.io, self.label, self, &ckbuf))- else- try s.write(http_headers.promptPrefixCacheKey(self.io, self.label, &ckbuf));+ try s.write(http_headers.requestCacheKey(self.io, self.label, self, self.provider.id, &ckbuf));const explicit_cache = supportsExplicitPromptCache(self);if (explicit_cache) {try s.objectField("prompt_cache_options");diff --git a/src/agent_server_compact.zig b/src/agent_server_compact.zigindex 11d48a6e..bb9287ed 100644--- a/src/agent_server_compact.zig+++ b/src/agent_server_compact.zig@@ -297,7 +297,7 @@ pub fn manualCompact(self: *Agent) anyerror!usize {return 0;}const pending_tokens = self.effectiveContextTokens();- if (!main_mod.json_mode) try self.say("[compacting ~{d} tokens with OpenAI…]\n", .{pending_tokens});+ if (!main_mod.json_mode and @import("repl.zig").g_debug) try self.say("[compacting ~{d} tokens with OpenAI…]\n", .{pending_tokens});const result = switch (route) {.standalone => compactStandalone(self),.in_stream => compactInStream(self),@@ -435,7 +435,7 @@ pub fn explicitCompact(self: *Agent) bool {defer self.gpa.free(body);var cp = self.provider;cp.url = compact_url;- if (!main_mod.json_mode) self.say("[compacting server-side: {d} item(s)…]\n", .{self.messages.items.len}) catch {};+ if (!main_mod.json_mode and @import("repl.zig").g_debug) self.say("[compacting server-side: {d} item(s)…]\n", .{self.messages.items.len}) catch {};var conv_buf: [96]u8 = undefined;const conv = @import("http_headers.zig").promptCacheKey(self.io, self.label, self, &conv_buf);const resp = http.postWatched(self.gpa, self.io, self.client, cp, body, conv) catch |err| {diff --git a/src/agent_tool_label.zig b/src/agent_tool_label.zigindex 8c734197..0b377aab 100644--- a/src/agent_tool_label.zig+++ b/src/agent_tool_label.zig@@ -128,7 +128,34 @@ fn copy(dst: []u8, src: []const u8) usize {return n;}-/// Short verb the human reads. Never "bash".+fn mcpLeaf(name: []const u8) []const u8 {+ if (std.mem.lastIndexOf(u8, name, "__")) |u| {+ if (u + 2 < name.len) return name[u + 2 ..];+ }+ if (std.mem.startsWith(u8, name, "mcp_")) return name["mcp_".len..];+ return name;+}++/// ADR 0021 bookkeeping: the model still gets the result; no frontend should+/// print it. Subagents are NOT this — they have a one-line card in the line+/// REPL and a scout row in the TUI.+pub fn skipTranscript(name: []const u8) bool {+ const leaf = mcpLeaf(name);+ if (std.mem.eql(u8, name, "skill") or std.mem.eql(u8, leaf, "skill")) return true;+ if (std.mem.eql(u8, name, "read_tool_result")) return true;+ if (std.mem.eql(u8, name, "note_constraint")) return true;+ if (std.mem.eql(u8, name, "load_tool_schemas")) return true;+ return false;+}++/// Line-REPL only: the scout card already said this.+pub fn skipLineRepl(name: []const u8) bool {+ if (skipTranscript(name)) return true;+ return std.mem.eql(u8, name, "subagent") or std.mem.eql(u8, name, "workflow") or+ std.mem.eql(u8, name, "agent_output");+}++/// Short verb the human reads. Never "bash". Never a truncated harness name.pub fn verb(name: []const u8, input: std.json.Value, buf: []u8) []const u8 {if (std.mem.eql(u8, name, "bash")) {const cmd = stringField(input, "command") orelse return "run";@@ -153,16 +180,12 @@ pub fn verb(name: []const u8, input: std.json.Value, buf: []u8) []const u8 {}return "search";}- if (std.mem.eql(u8, name, "subagent")) return "agent";+ if (std.mem.eql(u8, name, "subagent") or std.mem.eql(u8, name, "workflow")) return "scout";if (std.mem.eql(u8, name, "imagegen")) return "image";+ if (std.mem.eql(u8, name, "read_tool_result")) return "inspect";+ const leaf = mcpLeaf(name);+ if (std.mem.eql(u8, leaf, "batch")) return "inspect";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];@@ -402,6 +425,14 @@ test "verb never says bash" {try std.testing.expectEqualStrings("test", verb("bash", input, &buf));try std.testing.expectEqualStrings("edit", verb("edit_file", .null, &buf));try std.testing.expectEqualStrings("read", verb("read_file", .null, &buf));+ try std.testing.expectEqualStrings("inspect", verb("read_tool_result", .null, &buf));+ try std.testing.expectEqualStrings("inspect", verb("mcp__codedbpro__batch", .null, &buf));+ try std.testing.expectEqualStrings("scout", verb("subagent", .null, &buf));+ try std.testing.expect(skipTranscript("skill"));+ try std.testing.expect(skipTranscript("read_tool_result"));+ try std.testing.expect(!skipTranscript("subagent"));+ try std.testing.expect(skipLineRepl("subagent"));+ try std.testing.expect(!skipTranscript("read_file"));}test "compactBash keeps the count and drops the boilerplate" {diff --git a/src/agent_tool_render.zig b/src/agent_tool_render.zigindex 8439bb13..156e634b 100644--- a/src/agent_tool_render.zig+++ b/src/agent_tool_render.zig@@ -132,6 +132,7 @@ pub fn liveOutput(a: *Agent, text: []const u8) void {pub fn toolResultLine(a: *Agent, r: ToolOutcome) void {const w = a.out orelse return;if (r.meta) return;+ if (label.skipLineRepl(r.name)) return;const all = std.mem.trim(u8, r.text, " \t\r\n");if (r.is_error) {if (label.infraFamily(r.name, all)) |fam| {@@ -308,6 +309,13 @@ test "the result line marks success, failure and cancellation and previews one ltoolResultLine(&a, .{ .name = "todo_write", .text = "todos", .is_error = false, .meta = true });try std.testing.expectEqualStrings("", aw.writer.buffered());+ // ADR 0021: skill load and spilled-result paging are not conversational.+ aw.clearRetainingCapacity();+ toolResultLine(&a, .{ .name = "skill", .text = "# skill: deploy (plugin)\n", .is_error = false });+ try std.testing.expectEqualStrings("", aw.writer.buffered());+ toolResultLine(&a, .{ .name = "read_tool_result", .text = "hit 1 at byte 17378:\n", .is_error = false });+ try std.testing.expectEqualStrings("", aw.writer.buffered());+// Over the cap: exactly 100 bytes of the first line, then the ellipsis —// the literal the pre-#422 inline path spelled out, not result_preview_bytes.aw.clearRetainingCapacity();diff --git a/src/agent_working.zig b/src/agent_working.zignew file mode 100644index 00000000..c3af6bb6--- /dev/null+++ b/src/agent_working.zig@@ -0,0 +1,120 @@+//! Standing WORK block: the user's mental model of the task, not the+//! harness's todo_write dump. Printed when the checklist changes and again+//! as chrome above `›` (ADR 0021). Raw `[x]/[~]/[ ]` lines stay in the+//! tool result the model sees; they are not conversational.++const std = @import("std");+const Io = std.Io;++const engine_events = @import("engine_events.zig");+const util = @import("util.zig");++pub const Item = struct {+ content: []const u8,+ done: bool = false,+ active: bool = false,+};++const title_clip: usize = 40;+const item_clip: usize = 48;+const max_items: usize = 8;++fn clip(s: []const u8, n: usize) []const u8 {+ return util.utf8Prefix(std.mem.trim(u8, s, " \t\r"), n);+}++/// `WORKING {title} done/total` plus a `├`/`└` checklist. Empty input is+/// a no-op so a sink can call this on every prompt without a gate.+pub fn write(w: *Io.Writer, title: []const u8, items: []const Item) void {+ if (items.len == 0 and title.len == 0) return;+ const shown = if (title.len > 0) clip(title, title_clip) else "work";+ var done: usize = 0;+ for (items) |it| {+ if (it.done) done += 1;+ }+ w.print("WORKING {s}", .{shown}) catch return;+ if (items.len > 0) w.print(" {d}/{d}", .{ done, items.len }) catch return;+ w.writeByte('\n') catch return;+ const n = @min(items.len, max_items);+ for (items[0..n], 0..) |it, i| {+ const branch: []const u8 = if (i + 1 == n) "└ " else "├ ";+ const mark: []const u8 = if (it.done) "✓" else if (it.active) "◌" else "○";+ w.print("{s}{s} {s}\n", .{ branch, mark, clip(it.content, item_clip) }) catch return;+ }+}++pub fn writeFromStanding(w: *Io.Writer, st: engine_events.StandingWork) void {+ var buf: [max_items]Item = undefined;+ const n = @min(st.todos.len, buf.len);+ for (st.todos[0..n], 0..) |t, i| {+ buf[i] = .{ .content = t.content, .done = t.done, .active = t.active };+ }+ write(w, st.goal, buf[0..n]);+}++/// Parse the model's todo_write dump (`[x]` / `[~]` / `[ ]` lines) into the+/// same block. Unknown lines are ignored so a stray sentence cannot appear.+pub fn writeFromTodoText(w: *Io.Writer, title: []const u8, text: []const u8) void {+ var buf: [max_items]Item = undefined;+ var n: usize = 0;+ var it = std.mem.splitScalar(u8, text, '\n');+ while (it.next()) |raw| {+ if (n >= buf.len) break;+ const line = std.mem.trim(u8, raw, " \t\r");+ if (line.len < 4) continue;+ const mark = line[0..3];+ const rest = std.mem.trim(u8, line[3..], " \t");+ if (std.mem.eql(u8, mark, "[x]") or std.mem.eql(u8, mark, "[X]")) {+ buf[n] = .{ .content = rest, .done = true };+ n += 1;+ } else if (std.mem.eql(u8, mark, "[~]")) {+ buf[n] = .{ .content = rest, .active = true };+ n += 1;+ } else if (std.mem.eql(u8, mark, "[ ]")) {+ buf[n] = .{ .content = rest };+ n += 1;+ }+ }+ if (n == 0) return;+ write(w, title, buf[0..n]);+}++test "empty standing work draws nothing" {+ var aw: Io.Writer.Allocating = .init(std.testing.allocator);+ defer aw.deinit();+ write(&aw.writer, "", &.{});+ try std.testing.expectEqualStrings("", aw.writer.buffered());+}++test "a checklist is WORKING plus a tree, not [~] dump lines" {+ var aw: Io.Writer.Allocating = .init(std.testing.allocator);+ defer aw.deinit();+ writeFromTodoText(&aw.writer, "full Meld test deployment", "[x] inspect\n[~] configure Cloudflare\n[ ] build + validate\n[ ] deploy + verify\n[ ] commit + push\n");+ try std.testing.expectEqualStrings(+ "WORKING full Meld test deployment 1/5\n" +++ "├ ✓ inspect\n" +++ "├ ◌ configure Cloudflare\n" +++ "├ ○ build + validate\n" +++ "├ ○ deploy + verify\n" +++ "└ ○ commit + push\n",+ aw.writer.buffered(),+ );+}++test "writeFromStanding uses the goal title and active/done marks" {+ var aw: Io.Writer.Allocating = .init(std.testing.allocator);+ defer aw.deinit();+ const items = [_]engine_events.StandingTodo{+ .{ .content = "inspect", .done = true },+ .{ .content = "configure", .active = true },+ .{ .content = "deploy" },+ };+ writeFromStanding(&aw.writer, .{ .goal = "ship it", .todos = &items, .todos_done = 1, .todos_total = 3 });+ try std.testing.expectEqualStrings(+ "WORKING ship it 1/3\n" +++ "├ ✓ inspect\n" +++ "├ ◌ configure\n" +++ "└ ○ deploy\n",+ aw.writer.buffered(),+ );+}diff --git a/src/cards.zig b/src/cards.zigindex 0803a4d6..dd4a0a3f 100644--- a/src/cards.zig+++ b/src/cards.zig@@ -1,10 +1,6 @@-//! Subagent cards (#51): the parallel-subagent launch/done cards (sprite +-//! stable id + label + one-line activity), the box-drawing helpers, whitespace-//! collapse, and the per-subagent inspect-report writer (.graff/subagents/-//! <id>.md). Split out of main.zig (600-line goal). Imports ansi (palette) +-//! term (termCols); back-imports main for utf8Prefix and the live-//! use_color/json_mode toggles. main aliases the 5 renderers back and-//! mod-qualifies g_subagent_seq.+//! Subagent cards (#51): launch/done one-liners (`↯ scout` / `✓ scout`) and+//! the inspect-report writer (`.graff/subagents/<id>.md`). The sa- id is not+//! foreground UI (ADR 0021). Split out of main.zig (600-line goal).const std = @import("std");const Io = std.Io;@@ -13,12 +9,7 @@ const Allocator = std.mem.Allocator;const ansi = @import("ansi.zig");const style = &ansi.style;-const term = @import("term.zig");-const termCols = term.termCols;-const root = @import("main.zig");-const util = @import("util.zig");-const utf8Prefix = util.utf8Prefix;// #tui-tick: cards go through the line-boundary gate, not straight to stderr.const tick_gate = @import("tick_gate.zig");@@ -69,94 +60,57 @@ pub fn subagentId(buf: []u8, ordinal: u32, label: []const u8, prompt: []const u8return std.fmt.bufPrint(buf, "sa-{d:0>3}-{s}", .{ ordinal, hex }) catch buf[0..0];}-/// Render the launch card for a subagent to stderr as one block. `kind` is-/// "subagent" or "workflow_task"; `activity` is the one-line task preview.+/// One-line launch: `↯ scout {label}`. The sa- id and the boxed prompt are+/// not foreground UI (ADR 0021); `/debug` still names the id.pub fn subagentLaunchCard(arena: Allocator, id: []const u8, sprite: []const u8, label: []const u8, kind: []const u8, activity: []const u8) void {- if (root.json_mode) return; // SDK consumers get structured events, not TUI cards- const cols = termCols();- // Inner width: clamp to the terminal, but keep cards readable and never- // wider than a comfortable card. -2 leaves room for the box borders.- const inner: usize = @min(@max(cols, 24) - 2, 58);- const tag = if (std.mem.eql(u8, kind, "workflow_task")) "workflow" else "subagent";+ _ = sprite;+ _ = kind;+ _ = activity;+ if (root.json_mode) return;var aw: Io.Writer.Allocating = .init(arena);const w = &aw.writer;- // Header line carries the sprite (kept outside the box so emoji width can't- // skew the borders) plus the agent label and its stable id.- const sep = if (root.use_color) "·" else "-";- w.print(" {s} {s}{s}{s} {s}{s} {s} [{s}]{s}\n", .{- sprite, style.bold, label, style.reset, style.dim, sep, tag, id, style.reset,- }) catch return;- boxRule(w, inner, .top);- boxLine(w, inner, if (root.use_color) "▸ " else "> ", activity);- boxRule(w, inner, .bottom);+ const shown = collapseWs(label);+ if (@import("repl.zig").g_debug) {+ w.print(" {s}↯ scout{s} {s}{s}{s} [{s}]\n", .{ style.dim, style.reset, style.bold, shown, style.reset, id }) catch return;+ } else {+ w.print(" {s}↯ scout{s} {s}{s}{s}\n", .{ style.dim, style.reset, style.bold, shown, style.reset }) catch return;+ }tick_gate.workerLine(aw.writer.buffered());}-/// Render the completion card: status, elapsed, tools, and the inspect: path.-pub fn subagentDoneCard(arena: Allocator, id: []const u8, sprite: []const u8, label: []const u8, ok: bool, run_ms: i64, tools: []const u8, detail_path: ?[]const u8) void {+/// One-line settle: `✓ scout {label}` (or ✗). Cache hit rides when the+/// worker reported usage (ADR 0018 for scouts). Elapsed/tools/inspect path+/// stay in `.graff/subagents/<id>.md`.+pub fn subagentDoneCard(+ arena: Allocator,+ id: []const u8,+ sprite: []const u8,+ label: []const u8,+ ok: bool,+ run_ms: i64,+ tools: []const u8,+ detail_path: ?[]const u8,+ cache_read: u64,+ context_tokens: u64,+) void {+ _ = sprite;+ _ = run_ms;+ _ = tools;+ _ = detail_path;if (root.json_mode) return;- const cols = termCols();- const inner: usize = @min(@max(cols, 24) - 2, 58);- const mark = if (ok) (if (root.use_color) "✓ done" else "done") else (if (root.use_color) "✗ failed" else "failed");- const mark_style = if (ok) style.green else style.red;var aw: Io.Writer.Allocating = .init(arena);const w = &aw.writer;- const sep = if (root.use_color) "·" else "-";- w.print(" {s} {s}{s}{s} {s}{s}{s} {s}{s} {d}ms [{s}]{s}\n", .{- sprite, style.bold, label, style.reset,- mark_style, mark, style.reset, style.dim,- sep, run_ms, id, style.reset,- }) catch return;- boxRule(w, inner, .top);- const tool_line = if (tools.len > 0)- std.fmt.allocPrint(arena, "tools: {s}", .{tools}) catch "tools: (n/a)"- else- "tools: (none)";- const bullet = if (root.use_color) "· " else "- ";- boxLine(w, inner, bullet, tool_line);- if (detail_path) |p|- boxLine(w, inner, bullet, std.fmt.allocPrint(arena, "inspect: {s}", .{p}) catch p);- boxRule(w, inner, .bottom);- tick_gate.workerLine(aw.writer.buffered());-}--const BoxEdge = enum { top, bottom };--/// One horizontal box rule of `inner` light box-drawing dashes. ASCII '+---+'-/// when color (and thus likely Unicode-friendly rendering) is off.-fn boxRule(w: *Io.Writer, inner: usize, edge: BoxEdge) void {- const corners = if (root.use_color)- (if (edge == .top) [2][]const u8{ "╭", "╮" } else [2][]const u8{ "╰", "╯" })- else- [2][]const u8{ "+", "+" };- const dash = if (root.use_color) "─" else "-";- w.print(" {s}{s}", .{ style.dim, corners[0] }) catch return;- var i: usize = 0;- while (i < inner) : (i += 1) w.writeAll(dash) catch return;- w.print("{s}{s}\n", .{ corners[1], style.reset }) catch return;-}--/// One box content row: "│ <prefix><text…> │", text clamped (UTF-8 safe) to the-/// inner width so the right border lands in the same column every row. The-/// closing border is omitted when the text was truncated (a trailing ellipsis-/// reads cleaner than a misaligned border under variable-width glyphs).-fn boxLine(w: *Io.Writer, inner: usize, prefix: []const u8, text: []const u8) void {- const bar = if (root.use_color) "│" else "|";- // One column of padding inside each border.- const budget = if (inner >= 2) inner - 2 else 0;- const flat = collapseWs(text);- const want = if (prefix.len + flat.len <= budget) flat else utf8Prefix(flat, if (budget > prefix.len + 1) budget - prefix.len - 1 else 0);- const truncated = want.len != flat.len;- w.print(" {s}{s}{s} {s}{s}", .{ style.dim, bar, style.reset, prefix, want }) catch return;- if (truncated) w.writeAll(if (root.use_color) "…" else "~") catch return;- // Pad to the right border using the byte length as an approximation; the- // border is decorative, so a few off columns under wide glyphs are benign.- const used = prefix.len + want.len + (if (truncated) @as(usize, 1) else 0);- if (used < budget) {- var i: usize = used;- while (i < budget) : (i += 1) w.writeByte(' ') catch return;+ const shown = collapseWs(label);+ const mark: []const u8 = if (ok) "✓" else "✗";+ const mc: []const u8 = if (ok) style.green else style.red;+ w.print(" {s}{s} scout{s} {s}", .{ mc, mark, style.reset, shown }) catch return;+ if (context_tokens > 0) {+ const pct = @min((cache_read *| 100) / context_tokens, 100);+ w.print(" {s}cache {d}%{s}", .{ style.dim, pct, style.reset }) catch return;}- w.print(" {s}{s}{s}\n", .{ style.dim, bar, style.reset }) catch return;+ if (@import("repl.zig").g_debug) w.print(" [{s}]", .{id}) catch return;+ w.writeAll("\n") catch return;+ tick_gate.workerLine(aw.writer.buffered());}/// Collapse every run of whitespace (spaces, newlines, tabs) to a single spacediff --git a/src/engine_events.zig b/src/engine_events.zigindex 030add65..6c86c47b 100644--- a/src/engine_events.zig+++ b/src/engine_events.zig@@ -208,6 +208,8 @@ pub const ContextMeter = struct {pub const StandingTodo = struct {content: []const u8 = "",done: bool = false,+ /// `todo_write` in_progress — the ◌ mark in the WORKING tree.+ active: bool = false,};/// Standing work the line REPL may draw above the model prompt. Emptydiff --git a/src/engine_sink.zig b/src/engine_sink.zigindex 81e467ef..a73da4d3 100644--- a/src/engine_sink.zig+++ b/src/engine_sink.zig@@ -45,6 +45,7 @@ const render = @import("agent_stream_render.zig");const tool_render = @import("agent_tool_render.zig"); // slice 1c: the tool cluster's terminal halfconst session_render = @import("session_render.zig"); // slice 2: the lifecycle cluster's terminal halfconst prompt_render = @import("agent_prompt_render.zig"); // batch 3: the status line's terminal half+const working = @import("agent_working.zig");const tick_gate = @import("tick_gate.zig"); // #tui-tick: child ticks wait for a foreground line boundary/// An event plus its position, as delivered to a sink.@@ -303,7 +304,16 @@ fn tuiEmit(ctx: *anyopaque, ev: Stamped) void {.parallel_batch_finished => |b| tool_render.parallelBatchFinished(a, b),.completion_deferred => tool_render.completionDeferred(a),.goal_completed => tool_render.goalCompleted(a),- .completion_text, .todo_list_updated => |t| tool_render.toolTextLine(a, t.text),+ .completion_text => |t| tool_render.toolTextLine(a, t.text),+ .todo_list_updated => |t| {+ const w = a.out orelse return;+ const title = if (a.goal) |g|+ (if (g.status != .complete and g.objective.len > 0) g.objective else "work")+ else+ "work";+ working.writeFromTodoText(w, title, t.text);+ w.flush() catch {};+ },// The lifecycle cluster (slice 2). An Agent-backed TUI sink reaches// these only when one is injected (tests, a future frontend): the// engine's own lifecycle emitters use writerSink, whose terminaldiff --git a/src/http_headers.zig b/src/http_headers.zigindex a1fe5a05..2fc1c133 100644--- a/src/http_headers.zig+++ b/src/http_headers.zig@@ -58,6 +58,15 @@ pub fn promptPrefixCacheKey(io: Io, label: []const u8, buf: []u8) []const u8 {return std.fmt.bufPrint(buf, "{s}-child-{d}", .{ base, lane }) catch base;}+/// Partition for one request. xAI conversation affinity is per-agent (append-only+/// conv-id). Everyone else uses a prefix lane so repeated subagent roles hit+/// the warm system+tools cache instead of writing a unique suffix (ADR 0011).+pub fn requestCacheKey(io: Io, label: []const u8, agent: *const anyopaque, provider_id: []const u8, buf: []u8) []const u8 {+ if (std.mem.eql(u8, provider_id, "xai"))+ return promptCacheKey(io, label, agent, buf);+ return promptPrefixCacheKey(io, label, buf);+}+var project_id_buf: [36]u8 = undefined;var project_id_len: usize = 0;var project_id_lock: std.atomic.Value(bool) = .init(false);@@ -326,6 +335,17 @@ test "project and prefix cache keys preserve conversation and sharing boundariestry std.testing.expectEqualStrings(prefix1, prefix2);try std.testing.expect(std.mem.startsWith(u8, prefix1, a));try std.testing.expect(!std.mem.eql(u8, prefix1, a));++ // Chat-wire OpenAI scouts share a role lane; xAI scouts stay isolated.+ var oai1: [96]u8 = undefined;+ var oai2: [96]u8 = undefined;+ try std.testing.expectEqualStrings(+ requestCacheKey(std.testing.io, "implement", agent, "openai", &oai1),+ requestCacheKey(std.testing.io, "implement", sibling, "openai", &oai2),+ );+ var x1: [96]u8 = undefined;+ var x2: [96]u8 = undefined;+ try std.testing.expect(!std.mem.eql(u8, requestCacheKey(std.testing.io, "implement", agent, "xai", &x1), requestCacheKey(std.testing.io, "implement", sibling, "xai", &x2)));}test "x-grok-conv-id with no explicit conv still uses the project root id" {diff --git a/src/peer_channel.zig b/src/peer_channel.zigindex 34304806..9b41c828 100644--- a/src/peer_channel.zig+++ b/src/peer_channel.zig@@ -206,7 +206,20 @@ pub fn deliverInbound(root: *Agent) void {lines.append(root.arena, line) catch {};}}- renderPeerBlock(sink, root.io, any_visible, markers.items, lines.items[window.start..]);+ // Foreground chrome: one tally. Full peer lines stay in /debug and in the+ // parked inbox the model reads. Unrelated coordination must not steal+ // the first screenful of a turn.+ if (repl.g_debug) {+ renderPeerBlock(sink, root.io, any_visible, markers.items, lines.items[window.start..]);+ } else if (any_visible) {+ const n = lines.items.len;+ const summary = if (n == 0)+ ""+ else+ (std.fmt.allocPrint(root.arena, "↯ {d} peer update{s}", .{ n, if (n == 1) "" else "s" }) catch "↯ peer updates");+ if (summary.len > 0)+ renderPeerBlock(sink, root.io, true, &.{}, &.{summary});+ }if (peer_inbox.parkHeard(local_msgs, device_msgs) == 0) return;// History gets the wake only (ADR 0004). Bodies wait in the ring.var obj: std.json.ObjectMap = .empty;diff --git a/src/playbook_glue.zig b/src/playbook_glue.zigindex bda9062b..ee9c2db5 100644--- a/src/playbook_glue.zig+++ b/src/playbook_glue.zig@@ -67,7 +67,8 @@ pub fn noteConstraint(agent: *Agent, input: std.json.Value) ExecResult {};@import("prompt_cache_hud.zig").noteBust(.playbook);refreshRoot(agent, agent.arena);- agent.say(" {s}⛔ constraint recorded ({s}){s} {s}\n", .{ style.yellow, r.id, style.reset, text }) catch {};+ // ADR 0021: the user just said this. Echoing "constraint recorded" is+ // machine state, not progress. The tool result still tells the model.return .{ .text = std.fmt.allocPrint(agent.arena, "constraint recorded as {s}. It is now in {s} and rides every subagent, workflow and pipeline brief from here on, in this session and in later ones — you do not need to restate it.", .{ r.id, playbook.path }) catch "constraint recorded", .is_error = false };}diff --git a/src/prompt_cache_hud.zig b/src/prompt_cache_hud.zigindex 4f0dcdd6..a6214c13 100644--- a/src/prompt_cache_hud.zig+++ b/src/prompt_cache_hud.zig@@ -219,6 +219,7 @@ pub fn render(w: *Io.Writer) !void {\\ Z.AI implicit prefix (cached_tokens); thinking.clear_thinking=false\\ Vercel gateway implicit cache (cached_tokens); coding-agent /v1\\ /btw parent tools + system + cache key; note is the user message+ \\ subagents prefix lanes (OpenAI/chat); xAI conv stays isolated\\);}@@ -307,6 +308,7 @@ test "render stays content-free and names remaining levers" {try std.testing.expect(contains(text, "/goal"));try std.testing.expect(contains(text, "x-grok-conv-id"));try std.testing.expect(contains(text, "append-only"));+ try std.testing.expect(contains(text, "subagents"));try std.testing.expect(!contains(text, "SECRET-PROMPT"));try std.testing.expect(!contains(text, "/Users/me"));try std.testing.expect(!contains(text, "bash"));diff --git a/src/prompt_snapshot_tests.zig b/src/prompt_snapshot_tests.zigindex b439b270..904780b9 100644--- a/src/prompt_snapshot_tests.zig+++ b/src/prompt_snapshot_tests.zig@@ -35,6 +35,9 @@ const golden_full_prompt =\\a tool, a parameter, or a wrapper API around one, and never assume a\\capability that is not listed for you — when the thing you want is absent,\\say so and finish the task with what is here.+ \\Inspect before you commit to an architecture: say what you found, then+ \\what you will do, then do it. Do not announce a solution and hunt for+ \\confirmation of it.\\read_file before editing; prefer\\edit_file for changes to existing files and write_file only for new\\files or full rewrites. For a read-only exact-key lookup in one known file,diff --git a/src/prompt_text.zig b/src/prompt_text.zigindex 92d363e7..ec36c3b3 100644--- a/src/prompt_text.zig+++ b/src/prompt_text.zig@@ -24,6 +24,9 @@ pub const intro_note =\\a tool, a parameter, or a wrapper API around one, and never assume a\\capability that is not listed for you — when the thing you want is absent,\\say so and finish the task with what is here.+ \\Inspect before you commit to an architecture: say what you found, then+ \\what you will do, then do it. Do not announce a solution and hunt for+ \\confirmation of it.;/// Gate: `caps.local_tools`. #330 `--no-local-tools` hard-removes bash,diff --git a/src/router_catalog.zig b/src/router_catalog.zigindex 570f16e7..d3649602 100644--- a/src/router_catalog.zig+++ b/src/router_catalog.zig@@ -1,17 +1,9 @@//! Model discovery for Codegraff, Anthropic, xAI, and the optional workspace router.//!-//! The workspace router is declared by `.graff/.config.router`; its catalog-//! cache stays beside that config. xAI is always-live (never TTL-short-circuits).-//! Startup fans live GETs out concurrently (with Kimi) so REPL boot pays-//! max(latency), not the sum. Catalog failures never prevent startup.-//! Anthropic's `/v1/models` (catalog kind `.anthropic`) rides the same-//! machinery so new Claude releases appear without a rebuild. It differs in-//! auth (x-api-key + anthropic-version, like Messages) and in pagination:-//! the Models API pages with after_id/has_more/last_id rather than the-//! page/next_page scheme, so fetch follows has_more until the list is-//! complete. Discovery replaces the provider's slice, keeping graff's list-//! 1:1 with the official one; the baked pricing.zig rows remain purely the-//! no-key/offline fallback.+//! Workspace router cache: `.graff/.config.router`. xAI prefers a live GET but+//! boot activates any disk cache, waits at most 500ms to recache, else+//! refreshes in the background. `/models` is the blocking freshness moment.+//! Catalog failures never prevent startup. Baked pricing.zig rows are offline fallback.const std = @import("std");const Io = std.Io;@@ -33,13 +25,45 @@ const cache_ttl_ms: i64 = 6 * 60 * 60 * 1000;var attempted: [provider.provider_specs.len]bool = @splat(false);var additional_attempted = false;-/// Providers whose live `/models` list must win over a disk cache every load.-/// xAI ships new Grok ids often enough that a 6h snapshot is actively wrong;-/// always hit api.x.ai and only fall back to cache/baked when offline.+/// xAI boot uses any disk cache; live GET is budgeted, else background. `/models` still blocks.+pub const live_budget_ms: i64 = 500;pub fn alwaysLive(spec: provider.ProviderSpec) bool {return std.mem.eql(u8, spec.id, "xai");}+var bg_refresh: Io.Future(void) = undefined;+var bg_refresh_live = false;+var bg_done: Io.Event = .unset;++fn refreshCacheTask(io: Io, gpa: Allocator, home: []u8, spec: provider.ProviderSpec, key: []u8, source: provider.Keys.CredentialSource) void {+ defer gpa.free(home);+ defer gpa.free(key);+ defer bg_done.set(io);+ var arena_state = std.heap.ArenaAllocator.init(gpa);+ defer arena_state.deinit();+ const snapshot = fetch(io, gpa, arena_state.allocator(), spec, key, source) orelse return;+ writeCache(io, arena_state.allocator(), home, spec, snapshot.models);+}++fn startBackgroundRefresh(io: Io, gpa: Allocator, home: []const u8, spec: provider.ProviderSpec, key: []const u8, source: provider.Keys.CredentialSource) void {+ if (bg_refresh_live) return;+ const home_d = gpa.dupe(u8, home) catch return;+ const key_d = gpa.dupe(u8, key) catch {+ gpa.free(home_d);+ return;+ };+ bg_done.reset();+ const args = .{ io, gpa, home_d, spec, key_d, source };+ bg_refresh = io.concurrent(refreshCacheTask, args) catch io.async(refreshCacheTask, args);+ bg_refresh_live = true;+}++fn joinBackground(io: Io) void {+ if (!bg_refresh_live) return;+ bg_refresh.await(io);+ bg_refresh_live = false;+}+pub const Snapshot = struct {models: []const pricing.ModelInfo,fetched_at_ms: i64 = 0,@@ -326,18 +350,14 @@ pub fn activate(arena: Allocator, spec: provider.ProviderSpec, discovered: []confn loadSpec(io: Io, gpa: Allocator, arena: Allocator, home: []const u8, spec: provider.ProviderSpec, key: []const u8, source: provider.Keys.CredentialSource, force_refresh: bool) bool {if (!dynamic(spec) or key.len == 0) return false;const cached = cachedSnapshot(io, arena, home, spec);- // alwaysLive providers (xAI) never short-circuit on a fresh disk cache —- // every load tries the network so new Grok ids appear without waiting for- // TTL or `graff models refresh`. Cache remains offline fallback only.- const skip_cache = force_refresh or alwaysLive(spec);- if (!skip_cache) if (cached) |snapshot| {+ // xAI may use a stale cache at boot; only `force_refresh` (`/models`) skips it.+ if (!force_refresh) if (cached) |snapshot| {const age = util.unixMs(io) - snapshot.fetched_at_ms;- if (age >= 0 and age <= cache_ttl_ms and activate(arena, spec, snapshot.models)) return true;+ const usable = alwaysLive(spec) or (age >= 0 and age <= cache_ttl_ms);+ if (usable and activate(arena, spec, snapshot.models)) return true;};if (fetch(io, gpa, arena, spec, key, source)) |snapshot| {if (activate(arena, spec, snapshot.models)) {- // Still write for offline/`--schema` fallback, but never treat it as- // authoritative for alwaysLive providers on the next load.if (home.len != 0 or isAdditional(spec)) writeCache(io, arena, home, spec, snapshot.models);return true;}@@ -421,8 +441,8 @@ fn finishFetch(io: Io, arena: Allocator, home: []const u8, outcome: FetchOutcome}fn cacheFresh(io: Io, arena: Allocator, home: []const u8, spec: provider.ProviderSpec) bool {- if (alwaysLive(spec)) return false;const snapshot = cachedSnapshot(io, arena, home, spec) orelse return false;+ if (alwaysLive(spec)) return activate(arena, spec, snapshot.models);const age = util.unixMs(io) - snapshot.fetched_at_ms;return age >= 0 and age <= cache_ttl_ms and activate(arena, spec, snapshot.models);}@@ -452,9 +472,10 @@ fn spawnKimi(io: Io, gpa: Allocator, arena: Allocator, home: []const u8, keys: preturn io.concurrent(kimiFetchTask, args) catch io.async(kimiFetchTask, args);}-/// Startup catalog load. Fresh disk caches activate inline; every live GET-/// (xAI, stale Anthropic/Codegraff, Kimi, …) runs concurrently so boot pays-/// the slowest host, not the sum. Table mutation stays on this thread.+/// Startup catalog load. Fresh disk caches activate inline; live GETs run+/// concurrently so boot pays the slowest host, not the sum. xAI activates any+/// cache immediately, waits `live_budget_ms` only when there is none, and+/// otherwise refreshes the cache file in the background.pub fn ensureForStartup(io: Io, gpa: Allocator, arena: Allocator, home: []const u8, keys: provider.Keys, model_flag: ?[]const u8, saved: ?serde.SavedModel) void {var kimi_task = spawnKimi(io, gpa, arena, home, keys, model_flag, saved);defer if (kimi_task) |*fut| {@@ -470,8 +491,18 @@ pub fn ensureForStartup(io: Io, gpa: Allocator, arena: Allocator, home: []constconst key = keys.get(spec.id) orelse continue;if (key.len == 0) continue;attempted[index] = true;- if (cacheFresh(io, arena, home, spec)) continue;- futures[index] = spawnFetch(io, gpa, home, spec, key, keys.source(spec.id));+ const source = keys.source(spec.id);+ if (cacheFresh(io, arena, home, spec)) {+ if (alwaysLive(spec)) startBackgroundRefresh(io, gpa, home, spec, key, source);+ continue;+ }+ if (alwaysLive(spec)) {+ startBackgroundRefresh(io, gpa, home, spec, key, source);+ bg_done.waitTimeout(io, .{ .duration = .{ .raw = .fromMilliseconds(live_budget_ms), .clock = .awake } }) catch {};+ if (cachedSnapshot(io, arena, home, spec)) |snapshot| _ = activate(arena, spec, snapshot.models);+ continue;+ }+ futures[index] = spawnFetch(io, gpa, home, spec, key, source);}if (provider.additional_router) |spec| {if (catalog_selection.startupMayUse(keys, spec.id, model_flag, saved) and !additional_attempted) {@@ -495,6 +526,7 @@ pub fn ensureForStartup(io: Io, gpa: Allocator, arena: Allocator, home: []const/// remains the offline fallback, and each live list is re-cached for the/// next boot. Returns how many providers were pinged.pub fn refreshForListing(io: Io, gpa: Allocator, arena: Allocator, home: []const u8, keys: provider.Keys) usize {+ joinBackground(io);pricing_db.ensure(io, gpa, arena, home, true); // the same freshness moment covers the price sheet, network and allvar futures: [provider.provider_specs.len + 1]?Io.Future(FetchOutcome) = @splat(null);var pinged: usize = 0;diff --git a/src/router_catalog_tests.zig b/src/router_catalog_tests.zigindex 789ad771..fed29eb2 100644--- a/src/router_catalog_tests.zig+++ b/src/router_catalog_tests.zig@@ -176,6 +176,7 @@ test "alwaysLive is xAI-only so other OpenAI routers keep the disk TTL" {try std.testing.expect(!alwaysLive(provider.specFor("codegraff").?));try std.testing.expect(!alwaysLive(provider.specFor("anthropic").?));try std.testing.expect(!alwaysLive(provider.specFor("fireworks").?));+ try std.testing.expectEqual(@as(i64, 500), rc.live_budget_ms);}test "xAI /v1/models rows inherit baked context windows" {@@ -299,6 +300,9 @@ test "startup catalog loads fan out concurrently with Kimi" {try std.testing.expect(std.mem.indexOf(u8, src, "io.concurrent(fetchSpecTask") != null);try std.testing.expect(std.mem.indexOf(u8, src, "io.concurrent(kimiFetchTask") != null);try std.testing.expect(std.mem.indexOf(u8, src, "fn spawnKimi") != null);+ try std.testing.expect(std.mem.indexOf(u8, src, "startBackgroundRefresh") != null);+ try std.testing.expect(std.mem.indexOf(u8, src, "live_budget_ms") != null);+ try std.testing.expect(std.mem.indexOf(u8, src, "if (alwaysLive(spec)) return false") == null);}// ── provider.zig routing tests parked here under its 600-line ceiling ──────diff --git a/src/subagent_run.zig b/src/subagent_run.zigindex 7daa82eb..d2239c77 100644--- a/src/subagent_run.zig+++ b/src/subagent_run.zig@@ -427,7 +427,7 @@ pub fn runSub(ctx: ToolCtx, kind: []const u8, label: []const u8, prompt: []const// the #381 constraint block too. Reading a report against the raw prompt// is how "the subagent ignored my instruction" becomes unfalsifiable.const detail = cards.writeSubagentDetail(ctx.io, arena, sub_id, label, kind, task_prompt, report_body, !empty, run_ms, used_tools);- cards.subagentDoneCard(arena, sub_id, sprite, label, !empty, run_ms, used_tools, detail);+ cards.subagentDoneCard(arena, sub_id, sprite, label, !empty, run_ms, used_tools, detail, usage.cache_read_tokens, usage.context_tokens);var extra: []const u8 = isolation_note;var extra_owned = false;diff --git a/src/test_hooks.zig b/src/test_hooks.zigindex 889443c8..ca38ef6c 100644--- a/src/test_hooks.zig+++ b/src/test_hooks.zig@@ -197,6 +197,7 @@ const engine_sink = @import("engine_sink.zig");// surface moved into, plus the policy leaf approvals.zig split its pure half// out to. Production reaches all three through calls or aliases only.const agent_prompt_render = @import("agent_prompt_render.zig");+const agent_working = @import("agent_working.zig");const skill_docs_render = @import("skill_docs_render.zig");const harness_policy = @import("harness_policy.zig");@@ -292,6 +293,7 @@ test {_ = engine_events;_ = engine_sink;_ = agent_prompt_render;+ _ = agent_working;_ = skill_docs_render;_ = harness_policy;_ = verify_fingerprint;diff --git a/src/title.zig b/src/title.zigindex 18733f8d..2bc6b0e3 100644--- a/src/title.zig+++ b/src/title.zig@@ -11,9 +11,6 @@ const Io = std.Io;const Value = std.json.Value;const Allocator = std.mem.Allocator;-const ansi = @import("ansi.zig");-const style = &ansi.style;-const main_mod = @import("main.zig");const agent_mod = @import("agent.zig");const provider_mod = @import("provider.zig");@@ -76,15 +73,12 @@ pub fn setTerminalTitle(w: *Io.Writer, title: []const u8, folder: []const u8) vo}pub fn printSessionHeader(w: *Io.Writer, title: []const u8, folder: []const u8) !void {+ _ = w;+ _ = title;+ _ = folder;+ // The › status line owns model · effort · ~/folder. Restating the ask+ // in a Codegraff box was vertical tax: the prompt is already on screen.if (main_mod.json_mode) return;- try w.print("\n{s}╭─ Codegraff{s}\n{s}│ Working on:{s} {s}\n{s}│ Folder:{s} {s}\n{s}╰────────────────────────────{s}\n", .{- style.dim, style.reset,- style.dim, style.reset,- title, style.dim,- style.reset, folder,- style.dim, style.reset,- });- try w.flush();}/// Extracts the reasoning/thinking text from one streamed SSE delta object for@@ -267,7 +261,7 @@ test "titleFromPrompt: truncates long prompts at a word boundary, UTF-8 intact (try std.testing.expectEqualStrings("héllo wörld", titleFromPrompt("héllo wörld"));}-test "printSessionHeader renders the working-on title and folder (#83)" {+test "printSessionHeader is silent; the ask is not restated (#83)" {const saved = main_mod.json_mode;main_mod.json_mode = false;defer main_mod.json_mode = saved;@@ -276,9 +270,9 @@ test "printSessionHeader renders the working-on title and folder (#83)" {defer aw.deinit();try printSessionHeader(&aw.writer, "Fix the bug", "/tmp/proj");const s = aw.writer.buffered();- try std.testing.expect(std.mem.indexOf(u8, s, "Codegraff") != null);- try std.testing.expect(std.mem.indexOf(u8, s, "Fix the bug") != null);- try std.testing.expect(std.mem.indexOf(u8, s, "/tmp/proj") != null);+ try std.testing.expectEqual(@as(usize, 0), s.len);+ try std.testing.expect(std.mem.indexOf(u8, s, "Working on:") == null);+ try std.testing.expect(std.mem.indexOf(u8, s, "Fix the bug") == null);// JSON mode emits nothing (the header would corrupt the event stream).main_mod.json_mode = true;diff --git a/src/tui_sink.zig b/src/tui_sink.zigindex 7358bc0a..0586ff12 100644--- a/src/tui_sink.zig+++ b/src/tui_sink.zig@@ -26,6 +26,8 @@ const EngineEvent = engine_events.EngineEvent;const engine_sink = @import("engine_sink.zig");const repl = @import("repl.zig");const tui = @import("tui");+const label = @import("agent_tool_label.zig");+const working = @import("agent_working.zig");/// Result previews are one line, capped — the same budget hostedEmit used, so/// a row's body stays a body and a 20 KB tool result never reaches the queue.@@ -100,18 +102,28 @@ fn emit(ctx: *anyopaque, ev: engine_sink.Stamped) void {// never the prose stream (that mixing is what #551 took apart)..tool_output_delta => |d| if (tui.rawStream()) |raw| raw.appendBytes(d.text),// A meta tool owns this text's layout, so it arrives whole.- .completion_text, .todo_list_updated => |t| {+ .completion_text => |t| {b.stream.appendBytes(t.text);b.stream.appendBytes("\n");},+ .todo_list_updated => |t| {+ var aw: std.Io.Writer.Allocating = .init(std.heap.page_allocator);+ defer aw.deinit();+ working.writeFromTodoText(&aw.writer, "work", t.text);+ b.stream.appendBytes(aw.writer.buffered());+ },// ── structure: typed rows ────────────────────────────────────────- .tool_call_announced => |t| b.queue.push(.{ .tool_started = .{- .name = t.name,- .detail = capLine(engine_sink.compactArg(t.input), arg_cap),- } }),+ .tool_call_announced => |t| {+ if (label.skipTranscript(t.name)) return;+ b.queue.push(.{ .tool_started = .{+ .name = t.name,+ .detail = capLine(engine_sink.compactArg(t.input), arg_cap),+ } });+ },.tool_result => |r| {if (tui.rawStream()) |raw| raw.len.store(0, .release);+ if (label.skipTranscript(r.name)) return;b.queue.push(.{ .tool_finished = .{.name = r.name,.detail = capLine(r.text, preview_cap),diff --git a/uxlog.md b/uxlog.mdindex efc67d9d..a95f8016 100644--- a/uxlog.md+++ b/uxlog.md@@ -6,6 +6,23 @@ UX = how it behaves. Add an entry whenever a change alters what the usersees or how an interaction flows — small entries are fine; the point isthat "why does it work this way?" always has an answer here.+## 2026-08-21++### Transcript is the task, not the event bus (UI)+The line REPL was still printing harness vocabulary: `⛔ constraint recorded`,+`# skill:`, `[compacting…]`, `[~]` todo dumps, truncated `read_tool_re` rows,+and eight-line subagent cards with `sa-000-…` ids. Those are now classified+(ADR 0021). Bookkeeping is silent (compaction only under `/debug`). Todos+reprint as a `WORKING` tree on change and sit above `›`. Subagents are one+line (`↯ scout` / `✓ scout`). `batch` / `read_tool_result` are `inspect` or+hidden. The root prompt tells the model to observe, then conclude, then act.++### Scout cache (UX)+Repeated subagents on OpenAI/chat now share a prompt-cache prefix lane, so the+second "implement" scout can hit instead of writing a unique suffix. xAI scouts+stay isolated (append-only conv-id). The settle line shows `cache N%` when the+worker reported usage.+## 2026-06-22### TUI `/ultracode` opens an on/off picker (UX)