graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Line REPL boxes GFM tables at stream end
justrach003e048b4cb4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ef7a3a19..cf69b53c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,7 @@ current is part of cutting a release.## Unreleased+- Line REPL boxes GFM pipe tables (including `|---|` separators and pipe-less `a | b` rows) when the stream ends.- `#1088`: claims own one artifact. Conflicts ping Accord; acquire/release/handoff also replicate as replaceable Accord progress (file ledger stays canonical). Staging is not a lock.- `#1084`: gpt-6-astra `/effort medium` sends medium (no longer remapped to low).- Empty Enter-Enter while a turn is running interrupts (or steers the next queued prompt). It no longer required a queue to arm.diff --git a/src/agent.zig b/src/agent.zigindex 569b3e61..33d74e4f 100644--- a/src/agent.zig+++ b/src/agent.zig@@ -582,6 +582,7 @@ pub const Agent = struct {pub const atomEnd = @import("agent_table.zig").atomEnd;pub const wrapCell = @import("agent_table.zig").wrapCell;pub const isTableSeparator = @import("agent_table.zig").isTableSeparator;+ pub const isTableRowLine = @import("agent_table.zig").isTableRowLine;};test {diff --git a/src/agent_render.zig b/src/agent_render.zigindex 130f1bda..7bf79740 100644--- a/src/agent_render.zig+++ b/src/agent_render.zig@@ -25,6 +25,7 @@ const tick_gate = @import("tick_gate.zig"); // #tui-tick: subagent ticks land at// isTableSeparator lives in agent_table.zig; reached through the Agent// struct's member alias.const isTableSeparator = Agent.isTableSeparator;+const isTableRowLine = Agent.isTableRowLine;/// Incremental streaming markdown: every delta byte either prints/// immediately or is held only as long as classification demands. Each@@ -135,7 +136,7 @@ pub fn mdTryClassify(self: *Agent, w: *Io.Writer) void {// A buffered table ends at the first line that isn't another row —// render it before this line emits anything.- if (self.md_table.items.len > 0 and body[0] != '|') self.flushTable(w);+ if (self.md_table.items.len > 0 and !isTableRowLine(body)) self.flushTable(w);if (self.md_fence) {// Inside a fence the only special line is the ``` closer.const bt = countPrefix(body, '`');@@ -228,7 +229,9 @@ pub fn mdTryClassify(self: *Agent, w: *Io.Writer) void {}self.mdStartProse(w);},- else => self.mdStartProse(w),+ else => if (isTableRowLine(body)) {+ self.md_kind = .hold;+ } else self.mdStartProse(w),}}@@ -395,7 +398,7 @@ pub fn mdFinishLine(self: *Agent, w: *Io.Writer) bool {const line = self.md_buf.items;var lead: usize = 0;while (lead < line.len and line[lead] == ' ') lead += 1;- if (!self.md_fence and lead < line.len and line[lead] == '|') {+ if (!self.md_fence and lead < line.len and isTableRowLine(line[lead..])) {// Table row: buffer it — columns can only align once the// whole table is known.if (self.gpa.dupe(u8, line[lead..])) |dup| {diff --git a/src/agent_table.zig b/src/agent_table.zigindex 4e89c67f..fb37038b 100644--- a/src/agent_table.zig+++ b/src/agent_table.zig@@ -195,6 +195,17 @@ pub fn wrapCell(gpa: Allocator, cell: []const u8, width: usize, out: *std.ArrayLif (out.items.len == 0) out.append(gpa, "") catch {};}+/// GFM table row: leading `|` or a ` | ` cell join (pipe-less header).+pub fn isTableRowLine(body: []const u8) bool {+ if (body.len == 0) return false;+ if (body[0] == '|') return true;+ var i: usize = 1;+ while (i + 1 < body.len) : (i += 1) {+ if (body[i] == '|' and body[i - 1] == ' ' and body[i + 1] == ' ') return true;+ }+ return false;+}+/// True if a `|`-delimited row contains only separator chars (-, :, space).pub fn isTableSeparator(body: []const u8) bool {var any_dash = false;@@ -244,3 +255,11 @@ test "isTableSeparator: only |, -, :, space and at least one dash" {try std.testing.expect(!isTableSeparator("| | |")); // no dashtry std.testing.expect(!isTableSeparator("")); // empty}++test "isTableRowLine: leading pipe or GFM cell join" {+ try std.testing.expect(isTableRowLine("| PR | What |"));+ try std.testing.expect(isTableRowLine("|---|---|"));+ try std.testing.expect(isTableRowLine("PR | What"));+ try std.testing.expect(!isTableRowLine("just prose"));+ try std.testing.expect(!isTableRowLine(""));+}diff --git a/src/main_test.zig b/src/main_test.zigindex d77a773e..b0096259 100644--- a/src/main_test.zig+++ b/src/main_test.zig@@ -90,6 +90,12 @@ test "incremental markdown streaming renders like renderMdLine" {try std.testing.expectEqualStrings("x │ y\n", aw.writer.buffered());aw.clearRetainingCapacity();+ a.streamMarkdown("| PR | What |\n|---|---|\n| 1093 | keyboard |\n");+ a.flushStreamTail();+ try std.testing.expect(std.mem.indexOf(u8, aw.writer.buffered(), "│") != null);+ try std.testing.expect(std.mem.indexOf(u8, aw.writer.buffered(), "| PR |") == null);+ aw.clearRetainingCapacity();+// Stream tail: a partial prose line flushes whatever is pending.a.streamMarkdown("tail without newline");a.flushStreamTail();