Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

feat(repl): drop edit boilerplate and add a WORKING playhead

Cursor Agentf24e4e402450
diff --git a/docs/adr/0012-line-repl-is-a-working-block.md b/docs/adr/0012-line-repl-is-a-working-block.md
index 07962832..c6971705 100644
--- a/docs/adr/0012-line-repl-is-a-working-block.md
+++ b/docs/adr/0012-line-repl-is-a-working-block.md
@@ -16,7 +16,8 @@ should be the eye's rest.
## Decision
- Standing goal and its checklist render as a `WORKING` block above the prompt,
- not as badges on the input line.
+ not as badges on the input line. A progress bar sits under `N of M` so the
+ checklist is state, not more narration.
- The prompt is a bare `›`. Model, ctx, cost, `/resume N`, and a staged image
sit on one dim line above it.
- Parallel tool batches are a `├─` / `└─` tree. Sequential calls are flat.
diff --git a/src/agent_prompt_render.zig b/src/agent_prompt_render.zig
index dcec74a3..9f98a254 100644
--- a/src/agent_prompt_render.zig
+++ b/src/agent_prompt_render.zig
@@ -90,6 +90,28 @@ fn writeRule(w: *Io.Writer, cols: usize) !void {
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).
fn workingBlock(w: *Io.Writer, sw: engine_events.StandingWork, cols: usize) !void {
@@ -104,6 +126,7 @@ fn workingBlock(w: *Io.Writer, sw: engine_events.StandingWork, cols: usize) !voi
}
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 });
@@ -409,8 +432,10 @@ test "WORKING block sits above a bare prompt and is skipped when empty" {
};
try line(&aw.writer, full, 32);
const rule = "────────────────────────────────";
+ const bar = "━━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━"; // 15 filled + playhead + 14 rest at 30 cells
try std.testing.expectEqualStrings(
- "\n" ++ rule ++ "\nWORKING (paused)\nship the repl standing line\n1 of 2\n✓ inspect current prompt\n○ update implementation\n" ++
+ "\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› ",
aw.writer.buffered(),
);
diff --git a/src/agent_tool_label.zig b/src/agent_tool_label.zig
index 737bc8d5..8e7cea36 100644
--- a/src/agent_tool_label.zig
+++ b/src/agent_tool_label.zig
@@ -206,6 +206,18 @@ pub fn compactBash(line: []const u8, buf: []u8) []const u8 {
return line;
}
+/// 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, detail: []const u8, shown: []const u8) []const u8 {
+ if (shown.len == 0) return shown;
+ if (std.mem.eql(u8, name, "edit_file")) {
+ if (std.mem.indexOf(u8, shown, "edit span") != null) return "";
+ if (std.mem.indexOf(u8, detail, " · +") != null) return "";
+ }
+ if (detail.len > 0 and std.mem.eql(u8, shown, detail)) return "";
+ return shown;
+}
+
test "verb never says bash" {
var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
defer arena_state.deinit();
@@ -221,3 +233,9 @@ test "compactBash keeps the count and drops the boilerplate" {
try std.testing.expectEqualStrings("1475 passed", compactBash("All 1475 tests passed", &buf));
try std.testing.expectEqualStrings("ok", compactBash("ok", &buf));
}
+
+test "usefulPreview drops edit-span boilerplate once +N/-N is known" {
+ try std.testing.expectEqualStrings("", usefulPreview("edit_file", "src/a.zig · +3/-2", "applied 1 edit span(s) to src/a.zig (each verified)"));
+ try std.testing.expectEqualStrings("4 matches", usefulPreview("mcp_search", "standing line", "4 matches"));
+ try std.testing.expectEqualStrings("", usefulPreview("webfetch", "https://ex", "https://ex"));
+}
diff --git a/src/agent_tool_render.zig b/src/agent_tool_render.zig
index 43e606a2..cb0e2736 100644
--- a/src/agent_tool_render.zig
+++ b/src/agent_tool_render.zig
@@ -150,12 +150,13 @@ pub fn toolResultLine(a: *Agent, r: ToolOutcome) void {
const remembered = label.take(r.name);
const verb = if (remembered) |mem| mem.verb else r.name;
const detail = if (remembered) |mem| mem.detail else "";
+ const shown_final = label.usefulPreview(r.name, detail, shown);
const prefix = treePrefix();
w.print("{s}{s}{s}{s} {s}", .{ prefix, mc, mark, style.reset, verb }) catch return;
if (detail.len > 0) w.print(" {s}", .{detail}) catch return;
w.print("{s}{s}{s}", .{ style.dim, timing, style.reset }) catch return;
if (badge.len > 0) w.print(" {s}", .{badge}) catch return;
- if (shown.len > 0) w.print(" {s}{s}{s}{s}", .{ style.dim, shown, if (truncated) "…" else "", style.reset }) catch return;
+ if (shown_final.len > 0) w.print(" {s}{s}{s}{s}", .{ style.dim, shown_final, if (truncated) "…" else "", style.reset }) catch return;
w.writeAll("\n") catch return;
w.flush() catch return;
}
@@ -420,7 +421,7 @@ test "edit_file one-liner includes a +N/-N delta" {
label.resetPending();
toolUseLine(&a, .{ .name = "edit_file", .input = one });
toolResultLine(&a, .{ .name = "edit_file", .text = "applied 1 edit span(s) to src/a.zig (each verified)", .is_error = false });
- try std.testing.expectEqualStrings(" ✓ edit src/a.zig · +3/-2 applied 1 edit span(s) to src/a.zig (each verified)\n", aw.writer.buffered());
+ try std.testing.expectEqualStrings(" ✓ edit src/a.zig · +3/-2\n", aw.writer.buffered());
}
test "bash result prefers the last line of a multi-line run" {