xonecas.io
79113
Ma

mini-coding-agent / commit d966d92

cleanup: remove excessive comments and deduplication

xonecas2026-10-28 d966d926cd17c8c0c297ac1c6aed878b670081dd parent 52b3907

34 files changed

This diff is too big to show in full. The first 1000 lines are below, and every file is listed with its counts.

build.zig+0−2
@@ -3,7 +3,6 @@ const zon = @import("build.zig.zon");
33
44 pub fn build(b: *std.Build) void {
55 const target = b.standardTargetOptions(.{});
6- // A plain `zig build` ships the smallest binary; pass -Doptimize=debug to develop.
76 const optimize = b.option(std.builtin.OptimizeMode, "optimize", "Optimization mode") orelse .small;
87
98 const exe = b.addExecutable(.{
@@ -19,7 +18,6 @@ pub fn build(b: *std.Build) void {
1918 const options = b.addOptions();
2019 options.addOption([]const u8, "version", zon.version);
2120 exe.root_module.addOptions("build_options", options);
22- // `platform.zig` reads the passwd entry through `std.c`, which needs libc.
2321 exe.root_module.link_libc = true;
2422
2523 const run_cmd = b.addRunArtifact(exe);
src/agent.zig+0−4
@@ -90,7 +90,6 @@ fn onToolPhase(ctx: *anyopaque, phase: tools.ToolPhase) void {
9090 fn onApiEvent(ctx: *anyopaque, event: api.Event) void {
9191 const stream_ctx: *StreamCtx = @ptrCast(@alignCast(ctx));
9292 const listener = stream_ctx.listener;
93- // A retry is not output: it leaves the turn where it was, waiting.
9493 if (std.meta.activeTag(event) == .retry) {
9594 const r = event.retry;
9695 listener.emit(.{ .retry = .{
@@ -224,9 +223,6 @@ pub fn runTurn(opts: Options, messages: *std.ArrayList(message_mod.Message), int
224223 return;
225224 };
226225
227- // A failed request is a rolled-back transaction: the error never enters
228- // the context or the log, so resending the turn repeats the same
229- // request instead of appending an apology to it.
230226 if (assistant.stop_reason == .err) {
231227 listener.emit(.{ .err = assistant.error_message orelse "provider error" });
232228 return;
src/api.zig+10−15
@@ -265,29 +265,27 @@ pub fn appendCalls(msg: *message_mod.AssistantMessage, sink: Sink, a: std.mem.Al
265265 for (calls) |call| {
266266 if (call.name.len == 0) continue;
267267 any = true;
268+ const arguments = argumentsOrObject(call.args.items);
268269 try msg.content.append(a, .{ .tool_call = .{
269270 .id = call.id,
270271 .name = call.name,
271- .arguments = argumentsOrObject(call.args.items),
272+ .arguments = arguments,
272273 .thought_signature = call.thought_signature,
273274 } });
274275 sink.emit(.{ .tool_call = .{
275276 .id = call.id,
276277 .name = call.name,
277- .arguments = argumentsOrObject(call.args.items),
278+ .arguments = arguments,
278279 } });
279280 }
280281 return any;
281282 }
282283
283-/// The reasoning effort to send, or null when reasoning is off for this turn.
284284 pub fn effortOn(req: Request) ?[]const u8 {
285285 if (req.effort.len == 0 or std.mem.eql(u8, req.effort, "off")) return null;
286286 return req.effort;
287287 }
288288
289-/// The wire stop reasons that carry a meaning of their own; anything else is a
290-/// plain stop, which the caller falls back to.
291289 const stop_reasons = [_]struct { wire: []const u8, reason: message_mod.StopReason, message: ?[]const u8 = null }{
292290 .{ .wire = "length", .reason = .length },
293291 .{ .wire = "max_tokens", .reason = .length },
@@ -300,8 +298,6 @@ const stop_reasons = [_]struct { wire: []const u8, reason: message_mod.StopReaso
300298 .{ .wire = "sensitive", .reason = .err, .message = "Provider stop_reason: sensitive" },
301299 };
302300
303-/// Applies a provider's own stop reason. Returns false when the table has no
304-/// entry for it, so the caller can fall back to its own default.
305301 pub fn stopReason(msg: *message_mod.AssistantMessage, raw: ?[]const u8) bool {
306302 const wire = raw orelse return false;
307303 for (stop_reasons) |entry| {
@@ -329,17 +325,16 @@ pub fn appendParts(msg: *message_mod.AssistantMessage, a: std.mem.Allocator, thi
329325 if (text.len > 0) try msg.content.append(a, .{ .text = text });
330326 }
331327
328+fn cost(tokens: u64, rate: f64) f64 {
329+ return @as(f64, @floatFromInt(tokens)) * rate / 1_000_000.0;
330+}
331+
332332 pub fn finishUsage(msg: *message_mod.AssistantMessage, model: *const models.Model, usage: message_mod.Usage) void {
333333 var u = usage;
334334 if (u.total_tokens == 0) u.total_tokens = u.input + u.output + u.cache_read + u.cache_write;
335- const per = struct {
336- fn cost(tokens: u64, rate: f64) f64 {
337- return @as(f64, @floatFromInt(tokens)) * rate / 1_000_000.0;
338- }
339- };
340- u.cost_input = per.cost(u.input, model.cost_input);
341- u.cost_output = per.cost(u.output, model.cost_output);
342- u.cost_cache_read = per.cost(u.cache_read, model.cost_cache_read);
335+ u.cost_input = cost(u.input, model.cost_input);
336+ u.cost_output = cost(u.output, model.cost_output);
337+ u.cost_cache_read = cost(u.cache_read, model.cost_cache_read);
343338 u.cost_total = u.cost_input + u.cost_output + u.cost_cache_read;
344339 msg.usage = u;
345340 }
src/api/openai_completions.zig+0−3
@@ -87,9 +87,6 @@ fn imageParts(a: std.mem.Allocator, run: []const message_mod.Message) ![]const P
8787
8888 fn buildMessages(a: std.mem.Allocator, req: api.Request) ![]const Message {
8989 var out: std.ArrayList(Message) = .empty;
90- // Some upstreams reject a thinking-mode request whose assistant messages omit
91- // reasoning_content, even when the turn produced none, so the field is always
92- // sent (empty) while reasoning is on.
9390 const reasoning_on = api.effortOn(req) != null;
9491 if (req.system_prompt.len > 0) {
9592 try out.append(a, .{ .system = .{ .content = req.system_prompt } });
src/config.zig+8−9
@@ -4,7 +4,6 @@ const filesystem = @import("filesystem.zig");
44
55 pub const ToolName = enum { edit, read, bash };
66
7-/// How mini draws the user's attention when a turn needs them.
87 pub const Notifications = enum { off, osc9, bell, both };
98
109 pub const Api = enum {
@@ -56,7 +55,6 @@ pub const Colorscheme = struct {
5655 heading6: ?[]const u8 = null,
5756 };
5857
59-/// A `#rrggbb` override. The TUI only ever sees the parsed value.
6058 pub fn parseHex(text: []const u8) ?u24 {
6159 const body = if (text.len > 0 and text[0] == '#') text[1..] else text;
6260 if (body.len != 6) return null;
@@ -114,7 +112,6 @@ const File = struct {
114112 colorscheme: ?Colorscheme = null,
115113 };
116114
117-/// An empty environment variable is treated as unset, per the XDG spec.
118115 fn xdg(key: []const u8) ?[]const u8 {
119116 const value = platform.getEnv(key) orelse return null;
120117 return if (value.len == 0) null else value;
@@ -137,16 +134,18 @@ fn stateDir(a: std.mem.Allocator) []const u8 {
137134 };
138135 }
139136
140-pub fn historyPath(a: std.mem.Allocator) []const u8 {
137+fn stateFile(a: std.mem.Allocator, name: []const u8) []const u8 {
141138 const state = stateDir(a);
142- if (state.len == 0) return "history";
143- return filesystem.join(a, &.{ state, "mini-coding-agent/history" }) catch "history";
139+ if (state.len == 0) return name;
140+ return filesystem.join(a, &.{ state, "mini-coding-agent", name }) catch name;
141+}
142+
143+pub fn historyPath(a: std.mem.Allocator) []const u8 {
144+ return stateFile(a, "history");
144145 }
145146
146147 fn sessionsDir(a: std.mem.Allocator) []const u8 {
147- const state = stateDir(a);
148- if (state.len == 0) return "sessions";
149- return filesystem.join(a, &.{ state, "mini-coding-agent/sessions" }) catch "sessions";
148+ return stateFile(a, "sessions");
150149 }
151150 pub fn load(a: std.mem.Allocator, override: ?[]const u8, no_config: bool) !Config {
152151 var cfg = try defaults(a);
src/filesystem.zig+0−2
@@ -15,8 +15,6 @@ pub fn readFileAlloc(a: std.mem.Allocator, path: []const u8, max: usize) ![]u8 {
1515 return std.Io.Dir.cwd().readFileAlloc(platform.io, path, a, .limited(max));
1616 }
1717
18-/// Reads at most `max` bytes from the start of `path`; a larger file is
19-/// clipped instead of failing.
2018 pub fn readFilePrefix(a: std.mem.Allocator, path: []const u8, max: usize) ![]u8 {
2119 const file = try std.Io.Dir.cwd().openFile(platform.io, path, .{});
2220 defer file.close(platform.io);
src/gitignore.zig+0−16
@@ -1,24 +1,17 @@
11 const std = @import("std");
22
3-/// A single compiled gitignore pattern.
43 const Pattern = struct {
5- /// Pattern text with leading `!`, leading `/` and trailing `/` stripped.
64 text: []const u8,
7- /// Re-include rather than ignore.
85 negated: bool,
9- /// Match directories only (trailing `/`).
106 dir_only: bool,
11- /// Match the full path relative to the source dir, not the basename.
127 anchored: bool,
138 };
149
15-/// One `.gitignore` file's rules and the directory they were read from.
1610 const Source = struct {
1711 base: []const u8,
1812 patterns: []const Pattern,
1913 };
2014
21-/// Compile a single line. Returns null for blanks and comments.
2215 fn compilePattern(a: std.mem.Allocator, raw: []const u8) ?Pattern {
2316 var line = raw;
2417 if (line.len > 0 and line[line.len - 1] == '\r') line = line[0 .. line.len - 1];
@@ -104,7 +97,6 @@ fn matchChar(pat: []const u8, p: *usize, c: u8) bool {
10497 }
10598 }
10699
107-/// Glob match within one path segment (`*` and `?` never cross `/`).
108100 fn segmentMatch(pat: []const u8, s: []const u8) bool {
109101 var p: usize = 0;
110102 var i: usize = 0;
@@ -127,7 +119,6 @@ fn segmentMatch(pat: []const u8, s: []const u8) bool {
127119 return p == pat.len;
128120 }
129121
130-/// End index (exclusive) of the pattern segment starting at `start`.
131122 fn segmentEnd(pat: []const u8, start: usize) usize {
132123 var i = start;
133124 while (i < pat.len) : (i += 1) {
@@ -140,7 +131,6 @@ fn segmentEnd(pat: []const u8, start: usize) usize {
140131 return pat.len;
141132 }
142133
143-/// Match a full relative path against a pattern; `**` spans path separators.
144134 fn pathMatchFrom(pat: []const u8, pi: usize, path: []const u8) bool {
145135 if (pi >= pat.len) return path.len == 0;
146136 const pend = segmentEnd(pat, pi);
@@ -168,7 +158,6 @@ fn patternMatches(pat: Pattern, rel: []const u8, is_dir: bool) bool {
168158 return segmentMatch(pat.text, std.fs.path.basename(rel));
169159 }
170160
171-/// Strip an ancestor `base` prefix from `rel`; null when not under `base`.
172161 fn stripBase(rel: []const u8, base: []const u8) ?[]const u8 {
173162 if (base.len == 0) return rel;
174163 if (rel.len > base.len and rel[base.len] == '/' and std.mem.startsWith(u8, rel, base))
@@ -176,7 +165,6 @@ fn stripBase(rel: []const u8, base: []const u8) ?[]const u8 {
176165 return null;
177166 }
178167
179-/// Ordered set of gitignore rules, shallow sources first.
180168 pub const Matcher = struct {
181169 a: std.mem.Allocator,
182170 sources: std.ArrayList(Source) = .empty,
@@ -194,7 +182,6 @@ pub const Matcher = struct {
194182 try self.sources.append(self.a, .{ .base = base, .patterns = pats });
195183 }
196184
197- /// Add the rules from one `.gitignore` file located in `base`.
198185 pub fn pushFile(self: *Matcher, base: []const u8, content: []const u8) !void {
199186 var pats: std.ArrayList(Pattern) = .empty;
200187 var it = std.mem.tokenizeScalar(u8, content, '\n');
@@ -204,7 +191,6 @@ pub const Matcher = struct {
204191 try self.appendSource(base, try pats.toOwnedSlice(self.a));
205192 }
206193
207- /// Add caller-supplied patterns (e.g. config dirs) as a source at `base`.
208194 pub fn pushPatterns(self: *Matcher, base: []const u8, lines: []const []const u8) !void {
209195 var pats: std.ArrayList(Pattern) = .empty;
210196 for (lines) |line| {
@@ -213,8 +199,6 @@ pub const Matcher = struct {
213199 try self.appendSource(base, try pats.toOwnedSlice(self.a));
214200 }
215201
216- /// Decide whether `rel` (relative to the search root) is ignored.
217- /// null means no rule matched.
218202 pub fn check(self: *const Matcher, rel: []const u8, is_dir: bool) ?bool {
219203 var decision: ?bool = null;
220204 for (self.sources.items) |src| {
src/http.zig+0−24
@@ -5,8 +5,6 @@ const build_options = @import("build_options");
55
66 const user_agent = "mini-coding-agent/" ++ build_options.version;
77
8-/// OpenRouter only creates an app page from a `HTTP-Referer`; the title and
9-/// user agent alone leave usage unattributed.
108 const openrouter_headers = [_]std.http.Header{
119 .{ .name = "HTTP-Referer", .value = "https://xonecas.io/mini-coding-agent/" },
1210 .{ .name = "X-OpenRouter-Title", .value = "mini-coding-agent" },
@@ -38,9 +36,6 @@ const HttpError = error{
3836 Aborted,
3937 } || std.mem.Allocator.Error;
4038
41-/// How a request fails over: the retries after the first attempt, the first
42-/// backoff step (each retry doubles it), and how long a stream may stay silent
43-/// before the connection is treated as dead.
4439 pub const Retry = struct {
4540 attempts: usize = 3,
4641 base_ms: u64 = 1000,
@@ -49,8 +44,6 @@ pub const Retry = struct {
4944
5045 const max_backoff_ms: u64 = 30_000;
5146
52-/// Told about every retry before it happens, so both front ends can say why the
53-/// request is being repeated.
5447 pub const RetryNotice = struct {
5548 ctx: *anyopaque,
5649 on_retry: *const fn (ctx: *anyopaque, attempt: usize, total: usize, delay_ms: u64, reason: []const u8) void,
@@ -60,9 +53,6 @@ pub const RetryNotice = struct {
6053 }
6154 };
6255
63-/// Blocking socket reads cannot observe the cancel token or the idle window, so
64-/// a watcher thread shuts the connection down when either is spent, unblocking
65-/// the read that cannot see them.
6656 const Watch = struct {
6757 cancel: *const std.atomic.Value(bool),
6858 connection: *std.http.Client.Connection,
@@ -91,8 +81,6 @@ const Watch = struct {
9181 }
9282 };
9383
94-/// One request and its response, with the buffers the response reader borrows.
95-/// The parts point at each other, so an exchange is always opened in place.
9684 const Exchange = struct {
9785 a: std.mem.Allocator,
9886 client: std.http.Client,
@@ -105,7 +93,6 @@ const Exchange = struct {
10593 decompress_buf: [std.compress.flate.max_window_len]u8 = undefined,
10694 reader: *std.Io.Reader = undefined,
10795
108- /// Connects and sends, leaving the response to `receive`.
10996 fn open(self: *Exchange, a: std.mem.Allocator, method: std.http.Method, url: []const u8, headers: []const Header, body: ?[]const u8) HttpError!void {
11097 self.a = a;
11198 self.hdrs = .empty;
@@ -151,8 +138,6 @@ const Exchange = struct {
151138 }
152139 };
153140
154-/// What one attempt achieved: the status it saw, whether the sink already
155-/// received events (a partial stream cannot be repeated), and how it ended.
156141 const Attempt = struct {
157142 status: u16 = 0,
158143 sent: bool = false,
@@ -268,10 +253,6 @@ fn postOnce(
268253 var have_data = false;
269254 var buf: [4096]u8 = undefined;
270255
271- // Lines are assembled here instead of with `takeDelimiter`: some providers
272- // stream whole documents in one event, and a line that does not fit the
273- // reader's buffer sends the delimiter search down a failure path that
274- // desynchronizes chunked transfer decoding.
275256 while (true) {
276257 if (cancel.load(.acquire)) {
277258 out.err = error.Aborted;
@@ -307,8 +288,6 @@ fn postOnce(
307288 return out;
308289 };
309290 }
310- // The watcher shuts a dead stream down, which can end the read cleanly; the
311- // flag is what tells a finished stream from a silent one.
312291 if (watch.idle.load(.acquire)) {
313292 out.err = error.IdleTimeout;
314293 return out;
@@ -354,7 +333,6 @@ fn describe(e: HttpError, status: u16, buf: []u8) []const u8 {
354333 };
355334 }
356335
357-/// Waits out the backoff in small steps, so a cancel lands promptly.
358336 fn pause(cancel: *const std.atomic.Value(bool), delay_ms: u64) HttpError!void {
359337 var left = delay_ms;
360338 while (left > 0) {
@@ -366,8 +344,6 @@ fn pause(cancel: *const std.atomic.Value(bool), delay_ms: u64) HttpError!void {
366344 if (cancel.load(.acquire)) return error.Aborted;
367345 }
368346
369-/// Applies one SSE line to the pending event payload, returning whether the
370-/// payload is complete and should be dispatched.
371347 fn feedLine(
372348 a: std.mem.Allocator,
373349 raw: []const u8,
src/json.zig+0−1
@@ -10,7 +10,6 @@ pub const Raw = struct {
1010 }
1111 };
1212
13-/// A non-empty string field, or null when the key is missing or holds another type.
1413 pub fn stringField(obj: std.json.ObjectMap, key: []const u8) ?[]const u8 {
1514 const value = obj.get(key) orelse return null;
1615 return if (value == .string and value.string.len > 0) value.string else null;
src/models.zig+37−52
@@ -24,9 +24,6 @@ pub const Model = struct {
2424 thinking: Thinking = .budget,
2525 };
2626
27-/// A built-in provider is one whose models.dev entry the agent knows how to
28-/// request: name, environment keys, API root and models all come from the
29-/// document.
3027 const Builtin = struct {
3128 id: []const u8,
3229 session_header: ?[]const u8 = null,
@@ -97,6 +94,15 @@ fn custom(cfg: *const config.Config, id: []const u8) ?*const config.CustomProvid
9794 return null;
9895 }
9996
97+fn customModel(cfg: *const config.Config, provider_id: []const u8, model_id: []const u8) ?*const config.CustomModel {
98+ if (builtin(provider_id) != null) return null;
99+ const p = custom(cfg, provider_id) orelse return null;
100+ for (p.models) |*m| {
101+ if (std.mem.eql(u8, m.id, model_id)) return m;
102+ }
103+ return null;
104+}
105+
100106 fn firstEnv(keys: []const []const u8) ?[]const u8 {
101107 for (keys) |key| {
102108 if (platform.getEnv(key)) |value| {
@@ -145,27 +151,26 @@ pub fn resolveNamed(a: std.mem.Allocator, cfg: *const config.Config, provider_id
145151 }
146152
147153 if (custom(cfg, provider_id)) |p| {
148- for (p.models) |m| {
149- if (!std.mem.eql(u8, m.id, model_id)) continue;
150- return Model{
151- .id = m.id,
152- .api = @tagName(m.api),
153- .provider = provider_id,
154- .base_url = m.baseUrl,
155- .api_key = firstEnv(p.envKeys),
156- .effort = clampEffort(m.reasoning, m.effort, cfg.thinking_effort),
157- .supports_images = m.images,
158- .context_window = m.context,
159- .max_tokens = m.maxOutput,
160- .cost_input = m.cost[0],
161- .cost_output = m.cost[1],
162- .cost_cache_read = m.cost[2],
163- .session_header = null,
164- .headers = headerPairs(a, p.headers),
165- };
166- }
167- err.* = unknownModel(a, model_id, provider_id);
168- return null;
154+ const m = customModel(cfg, provider_id, model_id) orelse {
155+ err.* = unknownModel(a, model_id, provider_id);
156+ return null;
157+ };
158+ return Model{
159+ .id = m.id,
160+ .api = @tagName(m.api),
161+ .provider = provider_id,
162+ .base_url = m.baseUrl,
163+ .api_key = firstEnv(p.envKeys),
164+ .effort = clampEffort(m.reasoning, m.effort, cfg.thinking_effort),
165+ .supports_images = m.images,
166+ .context_window = m.context,
167+ .max_tokens = m.maxOutput,
168+ .cost_input = m.cost[0],
169+ .cost_output = m.cost[1],
170+ .cost_cache_read = m.cost[2],
171+ .session_header = null,
172+ .headers = headerPairs(a, p.headers),
173+ };
169174 }
170175
171176 err.* = unknownProvider(a, provider_id);
@@ -182,7 +187,6 @@ fn headerPairs(a: std.mem.Allocator, headers: ?std.json.ArrayHashMap([]const u8)
182187
183188 const ProviderEntry = struct { id: []const u8, name: []const u8, ready: bool };
184189
185-/// A built-in provider is usable when its first environment key is present.
186190 fn usable(p: modelsdev.Provider) bool {
187191 return firstEnv(p.env) != null;
188192 }
@@ -191,7 +195,6 @@ pub fn providers(a: std.mem.Allocator, cfg: *const config.Config) []ProviderEntr
191195 var out: std.ArrayList(ProviderEntry) = .empty;
192196 var db: ?modelsdev.Db = modelsdev.Db.open(a) catch null;
193197 for (builtins) |b| {
194- // Name, environment keys and every model fact come from the document.
195198 const p = (if (db) |*d| d.provider(b.id) else null) orelse continue;
196199 out.append(a, .{
197200 .id = b.id,
@@ -207,9 +210,6 @@ pub fn providers(a: std.mem.Allocator, cfg: *const config.Config) []ProviderEntr
207210
208211 pub const Entry = struct { id: []const u8, name: []const u8 };
209212
210-/// The models a provider offers. Built-ins are asked over the wire
211-/// (authenticated, so the provider decides what is enabled); a model with no
212-/// models.dev metadata is skipped. Custom providers list what they declare.
213213 pub fn listing(
214214 a: std.mem.Allocator,
215215 cfg: *const config.Config,
@@ -239,7 +239,6 @@ pub fn listing(
239239 return items;
240240 }
241241
242-/// The model list shape of an OpenAI-compatible gateway: `data[].id`.
243242 const Listed = struct {
244243 data: ?[]const Item = null,
245244
@@ -260,34 +259,20 @@ fn customListing(a: std.mem.Allocator, p: *const config.CustomProvider) ![]Entry
260259 return items;
261260 }
262261
262+fn levels(reasoning: bool, effort: []const []const u8) []const []const u8 {
263+ if (!reasoning) return &.{"off"};
264+ return if (effort.len == 0) &ladder else effort;
265+}
266+
263267 pub fn supportedLevels(a: std.mem.Allocator, cfg: *const config.Config, provider_id: []const u8, model_id: []const u8) []const []const u8 {
264- if (builtin(provider_id) == null) {
265- if (custom(cfg, provider_id)) |p| {
266- for (p.models) |m| {
267- if (!std.mem.eql(u8, m.id, model_id)) continue;
268- if (!m.reasoning) return &.{"off"};
269- if (m.effort.len == 0) return &ladder;
270- return m.effort;
271- }
272- }
273- return &ladder;
274- }
268+ if (customModel(cfg, provider_id, model_id)) |m| return levels(m.reasoning, m.effort);
275269 var db = modelsdev.Db.open(a) catch return &ladder;
276270 const info = db.info(provider_id, model_id) orelse return &ladder;
277- if (!info.reasoning) return &.{"off"};
278- if (info.effort.len == 0) return &ladder;
279- return info.effort;
271+ return levels(info.reasoning, info.effort);
280272 }
281273
282274 pub fn clampNamed(a: std.mem.Allocator, cfg: *const config.Config, provider_id: []const u8, model_id: []const u8, desired: []const u8) []const u8 {
283- if (builtin(provider_id) == null) {
284- if (custom(cfg, provider_id)) |p| {
285- for (p.models) |m| {
286- if (std.mem.eql(u8, m.id, model_id)) return clampEffort(m.reasoning, m.effort, desired);
287- }
288- }
289- return desired;
290- }
275+ if (customModel(cfg, provider_id, model_id)) |m| return clampEffort(m.reasoning, m.effort, desired);
291276 var db = modelsdev.Db.open(a) catch return desired;
292277 const info = db.info(provider_id, model_id) orelse return desired;
293278 return clampEffort(info.reasoning, info.effort, desired);
src/models_dev.zig+0−15
@@ -1,9 +1,5 @@
1-// models.dev metadata, embedded at build time. Refresh with
2-// `python3 tools/gen_models_dev.py`.
3-
41 const std = @import("std");
52
6-/// The raw models.dev document, filtered to the providers this agent talks to.
73 pub const raw = @embedFile("models_dev.json");
84
95 pub const Info = struct {
@@ -61,12 +57,8 @@ pub const Provider = struct {
6157
6258 const File = std.json.ArrayHashMap(Provider);
6359
64-/// Wire directories a gateway inserts between its API root and the version
65-/// when it fronts several wires (`/openai/v1`, `/anthropic/v1`).
6660 const wire_dirs = [_][]const u8{ "openai", "anthropic", "google" };
6761
68-/// A parsed models.dev document. The provider listing and each model's wire,
69-/// base URL and metadata all come from here.
7062 pub const Db = struct {
7163 a: std.mem.Allocator,
7264 file: File,
@@ -75,15 +67,10 @@ pub const Db = struct {
7567 return .{ .a = a, .file = try std.json.parseFromSliceLeaky(File, a, raw, .{ .ignore_unknown_fields = true }) };
7668 }
7769
78- /// The provider's record: its name, environment keys and metadata all live
79- /// in the document, never in the agent.
8070 pub fn provider(self: Db, provider_id: []const u8) ?Provider {
8171 return self.file.map.get(provider_id);
8272 }
8373
84- /// The provider's API root, where its model list lives. A provider's `api`
85- /// is the base URL of its default wire; when it carries a wire directory
86- /// the list sits one level up (`.../openai/v1` -> `.../v1`).
8774 pub fn baseUrl(self: Db, provider_id: []const u8) ?[]const u8 {
8875 const p = self.file.map.get(provider_id) orelse return null;
8976 const api = std.mem.trimEnd(u8, p.api, "/");
@@ -122,8 +109,6 @@ fn isWireDir(seg: []const u8) bool {
122109 return false;
123110 }
124111
125-/// A model's wire package overrides its provider's; a model override that only
126-/// names an `api` keeps the provider's wire.
127112 fn modelNpm(m: Model, p: Provider) []const u8 {
128113 if (m.provider) |pkg| {
129114 if (pkg.npm.len > 0) return pkg.npm;
src/platform.zig+0−5
@@ -1,8 +1,5 @@
11 const std = @import("std");
22
3-/// The default `std.Io.Threaded` grows its worker pool to one less than the CPU
4-/// count. That pool is only exercised by the net stack, which races DNS answers
5-/// and connections through `Io.async`; a handful of workers covers the agent.
63 const max_io_threads = 4;
74
85 pub var io: std.Io = undefined;
@@ -37,8 +34,6 @@ pub fn home() ?[]const u8 {
3734 return std.mem.sliceTo(dir, 0);
3835 }
3936
40-/// Reset `sig` to its default disposition and re-raise it, so the process dies
41-/// with the signal instead of masking it behind a normal exit code.
4237 pub fn reRaise(sig: std.posix.SIG) noreturn {
4338 const act = std.posix.Sigaction{
4439 .handler = .{ .handler = std.posix.SIG.DFL },
src/session.zig+31−42
@@ -30,9 +30,7 @@ const Block = union(enum) {
3030
3131 pub fn jsonStringify(self: Block, jws: anytype) !void {
3232 switch (self) {
33- .text => |v| try jws.write(v),
34- .thinking => |v| try jws.write(v),
35- .tool_call => |v| try jws.write(v),
33+ inline else => |v| try jws.write(v),
3634 }
3735 }
3836 };
@@ -51,8 +49,7 @@ const Part = union(enum) {
5149
5250 pub fn jsonStringify(self: Part, jws: anytype) !void {
5351 switch (self) {
54- .text => |v| try jws.write(v),
55- .image => |v| try jws.write(v),
52+ inline else => |v| try jws.write(v),
5653 }
5754 }
5855 };
@@ -111,9 +108,7 @@ const MessageRecord = union(enum) {
111108
112109 pub fn jsonStringify(self: MessageRecord, jws: anytype) !void {
113110 switch (self) {
114- .user => |v| try jws.write(v),
115- .tool_result => |v| try jws.write(v),
116- .assistant => |v| try jws.write(v),
111+ inline else => |v| try jws.write(v),
117112 }
118113 }
119114 };
@@ -167,8 +162,6 @@ pub const Session = struct {
167162 disabled: bool = false,
168163 closed: bool = false,
169164
170- /// `id` names the provider's session header until a log is opened; a recording
171- /// session then takes the name of its directory.
172165 pub fn init(a: std.mem.Allocator, sessions_dir: []const u8, cwd: []const u8) Session {
173166 var id: [6]u8 = undefined;
174167 shortId(&id);
@@ -176,35 +169,38 @@ pub const Session = struct {
176169 }
177170
178171 pub fn appendMessage(self: *Session, scratch: std.mem.Allocator, message: message_mod.Message) !void {
179- if (self.closed or self.disabled) return;
180- try self.ensure(if (message == .user) text.slugify(self.a, message.user.content) else "session");
181-
182- var arena = std.heap.ArenaAllocator.init(scratch);
183- defer arena.deinit();
184- const a = arena.allocator();
185- const line = try stringify(a, MessageLine{
186- .at = time.isoAlloc(a),
187- .message = try messageRecord(a, message),
188- });
189- try self.commitLine(scratch, line);
172+ try self.append(scratch, .{ .message = message });
190173 }
191174
192175 pub fn appendRequest(self: *Session, scratch: std.mem.Allocator, req: Request) !void {
193- if (self.closed or self.disabled) return;
194- try self.ensure("session");
176+ try self.append(scratch, .{ .request = req });
177+ }
178+
179+ const Record = union(enum) { message: message_mod.Message, request: Request };
195180
181+ fn append(self: *Session, scratch: std.mem.Allocator, record: Record) !void {
182+ if (self.closed or self.disabled) return;
183+ const title = switch (record) {
184+ .message => |m| if (m == .user) text.slugify(self.a, m.user.content) else "session",
185+ .request => "session",
186+ };
187+ try self.ensure(title);
196188 var arena = std.heap.ArenaAllocator.init(scratch);
197189 defer arena.deinit();
198190 const a = arena.allocator();
199- const line = try stringify(a, RequestLine{
200- .at = time.isoAlloc(a),
201- .provider = req.provider,
202- .model = req.model,
203- .api = req.api,
204- .thinkingEffort = req.thinking_effort,
205- .systemPrompt = req.system_prompt,
206- .tools = .{ .bytes = if (req.tools_json.len > 0) req.tools_json else "[]" },
207- });
191+ const at = time.isoAlloc(a);
192+ const line = switch (record) {
193+ .message => |m| try stringify(a, MessageLine{ .at = at, .message = try messageRecord(a, m) }),
194+ .request => |r| try stringify(a, RequestLine{
195+ .at = at,
196+ .provider = r.provider,
197+ .model = r.model,
198+ .api = r.api,
199+ .thinkingEffort = r.thinking_effort,
200+ .systemPrompt = r.system_prompt,
201+ .tools = .{ .bytes = if (r.tools_json.len > 0) r.tools_json else "[]" },
202+ }),
203+ };
208204 try self.commitLine(scratch, line);
209205 }
210206
@@ -228,8 +224,6 @@ pub const Session = struct {
228224 }
229225 }
230226
231- /// Reopens the session matching `id` for appending and replays its messages into
232- /// `messages`. Strings land in `self.a`, so the caller may release its own arena.
233227 pub fn reopen(self: *Session, id: []const u8, messages: *std.ArrayList(message_mod.Message)) !void {
234228 var arena = std.heap.ArenaAllocator.init(self.a);
235229 defer arena.deinit();
@@ -254,7 +248,6 @@ pub const Session = struct {
254248 self.file = file;
255249 }
256250
257- /// An exact session name, or the single one it prefixes.
258251 fn matching(self: *Session, scratch: std.mem.Allocator, id: []const u8) ![]const u8 {
259252 const names = filesystem.listDir(scratch, self.sessions_dir) catch return error.NoSuchSession;
260253 for (names) |name| if (std.mem.eql(u8, name, id)) return name;
@@ -404,11 +397,9 @@ fn object(obj: std.json.ObjectMap, key: []const u8) ?std.json.ObjectMap {
404397
405398 fn stopReason(name: ?[]const u8) StopReason {
406399 const wire = name orelse return .stop;
407- if (std.mem.eql(u8, wire, "pending")) return .pending;
408- if (std.mem.eql(u8, wire, "length")) return .length;
409- if (std.mem.eql(u8, wire, "toolUse")) return .tool_use;
410- if (std.mem.eql(u8, wire, "error")) return .err;
411- if (std.mem.eql(u8, wire, "aborted")) return .aborted;
400+ for (std.meta.tags(StopReason)) |reason| {
401+ if (std.mem.eql(u8, reason.wire(), wire)) return reason;
402+ }
412403 return .stop;
413404 }
414405
@@ -488,8 +479,6 @@ fn parseAssistant(a: std.mem.Allocator, record: std.json.ObjectMap) ?*message_mo
488479 return message;
489480 }
490481
491-/// One JSONL record, if it carries a conversation message. Everything else in the
492-/// log (the header, requests) is history of the run, not context for the model.
493482 fn parseMessage(a: std.mem.Allocator, scratch: std.mem.Allocator, line: []const u8) ?message_mod.Message {
494483 if (std.mem.trim(u8, line, " \t\r").len == 0) return null;
495484 const root = std.json.parseFromSliceLeaky(std.json.Value, scratch, line, .{}) catch return null;
src/text.zig+4−3
@@ -11,6 +11,10 @@ pub fn countLines(content: []const u8) usize {
1111 return std.mem.count(u8, content, "\n") + @intFromBool(content[content.len - 1] != '\n');
1212 }
1313
14+pub fn plural(a: std.mem.Allocator, n: usize, one: []const u8, many: []const u8) []const u8 {
15+ return std.fmt.allocPrint(a, "{d} {s}", .{ n, if (n == 1) one else many }) catch many;
16+}
17+
1418 pub fn join(a: std.mem.Allocator, parts: []const []const u8, sep: []const u8) ![]const u8 {
1519 var out: std.ArrayList(u8) = .empty;
1620 for (parts, 0..) |part, i| {
@@ -45,8 +49,6 @@ fn utf8SeqLen(p: []const u8) ?usize {
4549
4650 pub const Cp = struct { cp: u21, len: usize };
4751
48-/// The code point at `i` and its byte length. An invalid or truncated byte counts
49-/// as a one-byte code point, so callers always make progress.
5052 pub fn decodeAt(bytes: []const u8, i: usize) ?Cp {
5153 if (i >= bytes.len) return null;
5254 const b = bytes[i];
@@ -55,7 +57,6 @@ pub fn decodeAt(bytes: []const u8, i: usize) ?Cp {
5557 return .{ .cp = std.unicode.utf8Decode(bytes[i .. i + n]) catch b, .len = n };
5658 }
5759
58-/// Code points in `bytes`, counting each invalid byte as one.
5960 pub fn cpLen(bytes: []const u8) usize {
6061 var i: usize = 0;
6162 var n: usize = 0;
src/tools.zig+0−3
@@ -48,7 +48,6 @@ pub const Result = struct {
4848 images: []const message_mod.ImageContent = &.{},
4949 diffs: []const FileDiff = &.{},
5050 body: ?[]const u8 = null,
51- /// Text the model sees instead of `text`; the TUI still renders `text`.
5251 model_text: ?[]const u8 = null,
5352 };
5453
@@ -59,8 +58,6 @@ pub fn fail(a: std.mem.Allocator, fallback: []const u8, comptime fmt: []const u8
5958 };
6059 }
6160
62-/// Failure to touch `path`; the common filesystem errors get a plain sentence
63-/// instead of a bare error name.
6461 pub fn ioFail(a: std.mem.Allocator, what: []const u8, path: []const u8, e: anyerror) Result {
6562 const message = switch (e) {
6663 error.FileNotFound => std.fmt.allocPrint(a, "{s} failed: {s} does not exist", .{ what, path }),
src/tools/bash.zig+2−4
@@ -76,7 +76,6 @@ fn killGroup(pid: i32) void {
7676 std.posix.kill(-pid, .KILL) catch {};
7777 }
7878
79-/// What the TUI shows instead of the output. The status words match the exit line the model sees.
8079 fn bodyLine(a: std.mem.Allocator, code: ?u8, timed_out: bool, timeout_s: u64, output: []const u8) ?[]const u8 {
8180 const label = if (code) |c|
8281 std.fmt.allocPrint(a, "exit {d}", .{c}) catch return null
@@ -87,10 +86,9 @@ fn bodyLine(a: std.mem.Allocator, code: ?u8, timed_out: bool, timeout_s: u64, ou
8786 const lines = text.countLines(output);
8887 if (lines == 0) return label;
8988 const truncated = std.mem.indexOf(u8, output, truncated_marker) != null;
90- return std.fmt.allocPrint(a, "{s} · {d} line{s}{s}", .{
89+ return std.fmt.allocPrint(a, "{s} · {s}{s}", .{
9190 label,
92- lines,
93- if (lines == 1) "" else "s",
91+ text.plural(a, lines, "line", "lines"),
9492 if (truncated) ", truncated" else "",
9593 }) catch null;
9694 }
src/tools/read.zig+1−2
@@ -56,7 +56,6 @@ fn fail(a: std.mem.Allocator, comptime fmt: []const u8, args: anytype) tools.Res
5656 return tools.fail(a, "read failed", fmt, args);
5757 }
5858
59-/// A non-error result the model reads as information, not as a failure.
6059 fn warn(a: std.mem.Allocator, comptime fmt: []const u8, args: anytype) tools.Result {
6160 return .{ .text = std.fmt.allocPrint(a, fmt, args) catch "read", .is_error = false };
6261 }
@@ -100,7 +99,7 @@ fn bodyLine(a: std.mem.Allocator, args: Args, lines: usize, truncated: bool) ?[]
10099 window = true;
101100 }
102101 if (window) w.writeAll(" · ") catch return null;
103- if (lines == 1) w.writeAll("1 line") catch return null else w.print("{d} lines", .{lines}) catch return null;
102+ w.writeAll(text.plural(a, lines, "line", "lines")) catch return null;
104103 if (truncated) w.writeAll(", truncated") catch return null;
105104 return out.written();
106105 }
src/tui/diff_view.zig+0−1
@@ -37,7 +37,6 @@ pub fn diffLines(a: std.mem.Allocator, lines: []const []const u8, max_diff_lines
3737 if (std.mem.startsWith(u8, line, "diff ")) in_hunk = false;
3838 const kind = highlight.diffKind(line, in_hunk);
3939 if (kind == .hunk) in_hunk = true;
40- // File content is untrusted: its own escapes never reach the terminal.
4140 const text = render.stripAnsi(a, line);
4241 switch (kind) {
4342 .hunk => out.append(a, .{ .text = text, .style = diffHunk() }) catch {},
src/tui/editor.zig+0−1
@@ -283,7 +283,6 @@ pub const Editor = struct {
283283 self.col = anchor;
284284 }
285285
286- /// Replace the code points in `[from, to)` of `line` with `text`.
287286 fn replaceCols(self: *Editor, line: *Line, from: usize, to: usize, text: []const u8) void {
288287 const start = byteOf(line.items, from);
289288 const end = byteOf(line.items, to);
src/tui/format.zig+0−18
@@ -1,8 +1,6 @@
11 const std = @import("std");
22 const render = @import("render.zig");
33
4-/// The text-level half of the renderer: canonical markers, whitespace, and tables.
5-/// Styling runs afterwards, in highlight.zig, over the bytes produced here.
64 pub const Normalizer = struct {
75 ordered_indent: ?usize = null,
86 ordered_next: usize = 1,
@@ -12,9 +10,6 @@ pub const Normalizer = struct {
1210 self.ordered_next = 1;
1311 }
1412
15- /// Canonical form of one markdown line: even indentation, one space after every
16- /// marker, `-` bullets, sequential ordered runs, `> ` quotes, `---` rules, no
17- /// trailing whitespace. Fence bodies never reach this.
1813 pub fn line(self: *Normalizer, a: std.mem.Allocator, raw: []const u8) []const u8 {
1914 const text = std.mem.trimEnd(u8, raw, " \t\r");
2015 const ind = indentOf(text);
@@ -88,8 +83,6 @@ fn trimmed(out: *std.ArrayList(u8)) []const u8 {
8883
8984 const Indent = struct { end: usize, cols: usize };
9085
91-/// Leading whitespace, with tabs worth two columns and the depth rounded down to even
92-/// so nested levels line up.
9386 fn indentOf(text: []const u8) Indent {
9487 var end: usize = 0;
9588 var cols: usize = 0;
@@ -98,7 +91,6 @@ fn indentOf(text: []const u8) Indent {
9891 return .{ .end = end, .cols = cols & ~@as(usize, 1) };
9992 }
10093
101-/// The fence marker run (``` or ~~~) that opens `line`, if any.
10294 pub fn fenceRun(line: []const u8) ?[]const u8 {
10395 var i: usize = 0;
10496 while (i < line.len and i < 3 and line[i] == ' ') i += 1;
@@ -110,8 +102,6 @@ pub fn fenceRun(line: []const u8) ?[]const u8 {
110102 return if (n >= 3) line[i .. i + n] else null;
111103 }
112104
113-/// Whether `line` closes a fence opened with `opener`: the same byte, at least as
114-/// long a run, and nothing but whitespace after it.
115105 pub fn fenceClose(line: []const u8, opener: []const u8) bool {
116106 var i: usize = 0;
117107 while (i < line.len and i < 3 and line[i] == ' ') i += 1;
@@ -145,7 +135,6 @@ pub fn heading(rest: []const u8) ?Heading {
145135 if (n == 0 or n > 6) return null;
146136 if (n < rest.len and rest[n] != ' ' and rest[n] != '\t') return null;
147137 var text = std.mem.trimStart(u8, rest[n..], " \t");
148- // A closing run of `#`s is decoration; only one that follows a space counts.
149138 var end = text.len;
150139 while (end > 0 and text[end - 1] == '#') end -= 1;
151140 if (end < text.len and (end == 0 or text[end - 1] == ' ' or text[end - 1] == '\t'))
@@ -158,7 +147,6 @@ const Marker = union(enum) {
158147 ordered: struct { num: usize, at: usize },
159148 };
160149
161-/// Byte offset just past the list marker, or null when the line has none.
162150 fn marker(rest: []const u8) ?Marker {
163151 if (rest.len == 0) return null;
164152 const c = rest[0];
@@ -204,7 +192,6 @@ fn splitCells(a: std.mem.Allocator, line: []const u8) []const []const u8 {
204192 return cells.items;
205193 }
206194
207-/// Index of the `]` closing the `[` at `open`, skipping escaped bytes.
208195 pub fn closeBracket(text: []const u8, open: usize) ?usize {
209196 var i = open + 1;
210197 while (i < text.len) : (i += 1) {
@@ -217,7 +204,6 @@ pub fn closeBracket(text: []const u8, open: usize) ?usize {
217204 return null;
218205 }
219206
220-/// Index of the `)` closing the `(` at `open`, so destinations may hold parentheses.
221207 pub fn linkEnd(text: []const u8, open: usize) ?usize {
222208 var depth: usize = 0;
223209 var i = open;
@@ -237,7 +223,6 @@ pub fn linkEnd(text: []const u8, open: usize) ?usize {
237223 return null;
238224 }
239225
240-/// Delimiter row (`|---|:--:|`) as per-column alignments, or null when the line is not one.
241226 fn delimiterRow(a: std.mem.Allocator, line: []const u8) ?[]const Align {
242227 if (std.mem.indexOfScalar(u8, line, '-') == null) return null;
243228 const cells = splitCells(a, line);
@@ -259,7 +244,6 @@ fn delimiterRow(a: std.mem.Allocator, line: []const u8) ?[]const Align {
259244 fn tableCandidate(line: []const u8) bool {
260245 const trimmed_line = std.mem.trim(u8, line, " \t\r");
261246 if (trimmed_line.len == 0) return false;
262- // Tables nested in quotes or lists keep their marker; reflowing them would drop it.
263247 if (trimmed_line[0] == '>' or trimmed_line[0] == '-' or trimmed_line[0] == '*' or trimmed_line[0] == '+') return false;
264248 return std.mem.indexOfScalar(u8, trimmed_line, '|') != null;
265249 }
@@ -295,7 +279,6 @@ fn emitRow(a: std.mem.Allocator, block: *std.ArrayList(u8), indent: []const u8,
295279 }
296280 }
297281
298-/// Leading whitespace, kept so a table nested in a list stays in its item.
299282 fn leadingText(line: []const u8) []const u8 {
300283 var i: usize = 0;
301284 while (i < line.len and (line[i] == ' ' or line[i] == '\t')) i += 1;
@@ -358,7 +341,6 @@ pub fn formatTables(a: std.mem.Allocator, text: []const u8) []const u8 {
358341 out.append(a, '\n') catch {};
359342 i += 1;
360343 }
361- // A single trailing split always leaves one empty entry; drop its newline.
362344 if (out.items.len > 0 and text.len > 0 and text[text.len - 1] != '\n' and out.items[out.items.len - 1] == '\n')
363345 out.items.len -= 1;
364346 return out.items;
src/tui/highlight.zig+0−14
@@ -83,9 +83,7 @@ fn runLength(line: []const u8, at: usize, c: u8) usize {
8383 return n;
8484 }
8585
86-/// Just past the code span opened at `i`, or null when its backticks never close.
8786 fn codeSpanEnd(line: []const u8, at: usize, limit: usize) ?usize {
88- // Backslashes are literal inside a code span, so only the run length closes it.
8987 const n = runLength(line, at, '`');
9088 var i = at + n;
9189 while (i < limit) : (i += 1) {
@@ -94,8 +92,6 @@ fn codeSpanEnd(line: []const u8, at: usize, limit: usize) ?usize {
9492 return null;
9593 }
9694
97-/// Closing run for `marker` repeated `count` times, ignoring empty or space-padded content
98-/// and anything escaped or inside a code span.
9995 fn closeRun(line: []const u8, open_at: usize, marker: u8, count: usize, limit: usize) ?usize {
10096 var i = open_at + count;
10197 while (i + count <= limit) : (i += 1) {
@@ -111,7 +107,6 @@ fn closeRun(line: []const u8, open_at: usize, marker: u8, count: usize, limit: u
111107 if (line[i - 1] == ' ' or line[i - 1] == '\t') continue;
112108 const run = runLength(line, i, marker);
113109 if (run < count) continue;
114- // `_` only closes where a word ends, so `foo_bar_baz` stays literal.
115110 if (marker == '_' and i + run < limit and isAlnum(line[i + run])) continue;
116111 return i;
117112 }
@@ -131,7 +126,6 @@ fn addSpan(a: std.mem.Allocator, spans: *std.ArrayList(Span), base: u32, start:
131126 spans.append(a, .{ .start = base + @as(u32, @intCast(start)), .end = base + @as(u32, @intCast(end)), .style = style }) catch {};
132127 }
133128
134-/// Inline markup inside one prose line. `limit` is the byte index the scan stops at.
135129 fn scanInline(a: std.mem.Allocator, line: []const u8, base: u32, start: usize, limit: usize, spans: *std.ArrayList(Span)) void {
136130 var i = start;
137131 while (i < limit) {
@@ -154,7 +148,6 @@ fn scanInline(a: std.mem.Allocator, line: []const u8, base: u32, start: usize, l
154148 const n = runLength(line, i, c);
155149 const count: usize = @min(n, 3);
156150 const content = i + count;
157- // An opener needs content and, for `_`, must not sit inside a word.
158151 if (content >= limit or line[content] == ' ' or line[content] == '\t' or
159152 (c == '_' and i > start and isAlnum(line[i - 1])))
160153 {
@@ -194,7 +187,6 @@ fn leadingSpaces(line: []const u8) usize {
194187 return i;
195188 }
196189
197-/// Byte offset just past a list or quote marker, or null when the line has none.
198190 fn blockMarker(line: []const u8) ?usize {
199191 var at: usize = 0;
200192 while (at < line.len and (line[at] == ' ' or line[at] == '\t')) at += 1;
@@ -222,7 +214,6 @@ fn markdownLine(a: std.mem.Allocator, line: []const u8, base: u32, spans: *std.A
222214 addSpan(a, spans, base, start, start + after, muted());
223215 start += after;
224216 }
225- // Headings and rules keep their style when quoted or listed.
226217 const rest = line[start..];
227218 if (format.heading(rest[leadingSpaces(rest)..])) |h| {
228219 addSpan(a, spans, base, start, limit, styles.roles.heading(h.level));
@@ -246,10 +237,7 @@ pub fn highlightMarkdown(a: std.mem.Allocator, text: []const u8) []const u8 {
246237 return paint(a, text, spans.items, .{});
247238 }
248239
249-/// Fenced code is styled as one muted block: token-level coloring needs a grammar, and a
Cut short: this commit's diff is over 1000 lines.
src/tui/history.zig+0−1
Cut short: this commit's diff is over 1000 lines.
src/tui/image.zig+0−13
Cut short: this commit's diff is over 1000 lines.
src/tui/picker.zig+0−4
Cut short: this commit's diff is over 1000 lines.
src/tui/render.zig+0−5
Cut short: this commit's diff is over 1000 lines.
src/tui/screen.zig+0−5
Cut short: this commit's diff is over 1000 lines.
src/tui/status.zig+0−19
Cut short: this commit's diff is over 1000 lines.
src/tui/stream.zig+0−1
Cut short: this commit's diff is over 1000 lines.
src/tui/styles.zig+0−9
Cut short: this commit's diff is over 1000 lines.
src/tui/term.zig+0−3
Cut short: this commit's diff is over 1000 lines.
src/tui/tool_view.zig+0−2
Cut short: this commit's diff is over 1000 lines.
src/tui/tui.zig+3−6
Cut short: this commit's diff is over 1000 lines.
src/tui/usage.zig+11−16
Cut short: this commit's diff is over 1000 lines.
src/tui/width_tables.zig+0−3
Cut short: this commit's diff is over 1000 lines.