xonecas.io
79113
Ma

mini-coding-agent / commit 319801e

feat: readme, config changes and /new.

xonecas2026-10-04 319801e81aa9b65883ce22c24fa38609e5d409cd parent 08a291b

11 files changed

AGENTS.md+7−6
@@ -1,4 +1,4 @@
1-# mini-z-agent (`mza` for short)
1+# mini-coding-agent (`mini` for short)
22
33 A fast, transparent, config-first terminal coding agent for one user at a time.
44 A careful Zig port of mini-coder.
@@ -68,8 +68,9 @@ Hard constraints. Do not cross these without explicit direction:
6868 - **No loop limits.** No max turns, tool calls, token budgets, or agent-imposed
6969 timeouts. The user's ability to interrupt is the limit.
7070 - **Config-first.** Every user-facing behavior that can vary comes from config
71- with a sane default. Global config only — no project-local config, no
72- config-override flags — and never duplicate a provider's catalog or env vars.
71+ with a sane default. Global config only — no project-local config; a
72+ `-c`/`--config` file overrides the global one for a run — and never duplicate
73+ a provider's catalog or env vars.
7374 - **Minimal context.** The model sees the configured system prompt plus
7475 explicitly opted-in resource files — never reminders, hidden blocks, or
7576 harness meta-text.
@@ -121,7 +122,7 @@ largest fragility. Do not reintroduce it.
121122 Verify against the real provider. Do not stand up mock servers, fixture
122123 endpoints, or replay files; they stall and prove nothing. Use the
123124 `OPENCODE_API_KEY` environment variable and a scratch `XDG_CONFIG_HOME` with a
124-`mini-coder/config.json` that declares the provider under test.
125+`mini-coding-agent/config.json` that declares the provider under test.
125126
126127 OpenCode Zen serves all four wire protocols. Base URLs and the working models:
127128
@@ -146,12 +147,12 @@ window over remote control on a private socket, one window per run: it launches
146147 the app in a scratch cwd, waits for the banner, types the prompt, and
147148 screenshots the window at 15fps until the capture window ends or the app exits.
148149
149- tools/stress.sh -C <scratch cwd> -o /tmp/mz-runs/<name> -d 300 -p '<prompt>'
150+ tools/stress.sh -C <scratch cwd> -o /tmp/mini-runs/<name> -d 300 -p '<prompt>'
150151
151152 Frames land in `frame-NNNNN.png`. At the end of a run the pane is written with
152153 its truecolor SGR to `final.txt` (scrollback) and `final-screen.txt` (live
153154 screen). The last line reports frames, wall time, and achieved fps; an
154-`ended early: MZA-EXIT <n>` line means the app died, and `final.txt` holds the
155+`ended early: MINI-EXIT <n>` line means the app died, and `final.txt` holds the
155156 dump. Read the pane text and the frames, not pixels.
156157
157158 ## Working agreement
ISSUES.md+18−0
@@ -0,0 +1,18 @@
1+# Issues from QA/Live use
2+
3+- Pause doesn't work, agent keeps working through the pause, with the UI saying "paused - ...".
4+- Audit statusline states, I never see "waiting for provider". Seems that we don't have that much granularity
5+- `authFile` in config is a fragment of mini-coder's functionality that we don't have, why was it ported without thinking?
6+- Agents use markdown tables in their replies, and usually with terrible whitespace, can we format them for readability?
7+- thinking effort selection doesn't trigger on model selection like it does in mini-coder. since we clamp thinking to the model's
8+ options, this is required, it's why mini-coder does it.
9+
10+# Improvements
11+
12+- Pending/Running bash tool calls: Currently the user only sees the status line "running bash...". The user only sees the arguments
13+ once the tool call completes. We need to add a new section to the live area when there are tool calls waiting for tool results,
14+ that display the arguments. This enables the user to see that a bad bash command was sent and can stop it, right now it's a guess
15+ when something is taking too long.
16+- Read tool bodies aren't useful. Instead we should show a single line body, with the read tool call arguments and the count of lines read.
17+ Users can already see the full path in the tool header. If it's an image we show the path twice, thats is not needed, let's just show the
18+ image metadata in the single line body to match the new behaviour suggested here.
README.md+124−0
@@ -0,0 +1,124 @@
1+# mini
2+
3+A fast, transparent, config-first terminal coding agent.
4+
5+## Build
6+
7+Requires Zig 0.16.0.
8+
9+ zig build
10+
11+The binary lands at `zig-out/bin/mini`.
12+
13+## Run
14+
15+ mini # interactive TUI
16+ mini -p '<prompt>' # one turn, print the reply, exit
17+ mini -c <file> # overlay a config file for this run
18+
19+Arguments:
20+
21+| Flag | Meaning |
22+|---|---|
23+| `-p`, `--print` | run one prompt non-interactively and print the assistant text |
24+| `-c`, `--config` | read a config file after the global one; its keys win |
25+
26+`-p` requires a model in the config. Without one it exits 1 and prints where
27+the config lives. Interactive mode requires a TTY.
28+
29+## TUI commands
30+
31+| Command | Meaning |
32+|---|---|
33+| `/help` | list commands and keybindings |
34+| `/new` | start a new session |
35+| `/provider` | choose the provider and model |
36+| `/model` | choose a model for the current provider |
37+| `/thinking` | set the thinking level |
38+
39+`/provider`, `/model`, and `/thinking` write the change back to the config file.
40+
41+## Keybindings
42+
43+| Key | Meaning |
44+|---|---|
45+| `Enter` | submit |
46+| `Shift+Enter` | newline (`Ctrl+J` also works) |
47+| `Esc` | pause the turn at the next step boundary |
48+| `Ctrl+C` | cancel the turn |
49+| `Ctrl+D` | exit on an empty draft |
50+| `Tab` | complete command or path |
51+
52+## Configure
53+
54+The config is one JSON object. It is read from
55+`$XDG_CONFIG_HOME/mini-coding-agent/config.json`, else
56+`$HOME/.config/mini-coding-agent/config.json`. A missing file means every
57+default. There is no project-local config. `-c` reads a second file over it.
58+
59+A full example:
60+
61+```json
62+{
63+ "provider": "opencode",
64+ "model": "deepseek-v4.1-flash",
65+ "thinkingEffort": "medium",
66+ "systemPrompt": "Be terse.",
67+ "sessionsDir": "/home/me/.local/state/mini-coding-agent/sessions",
68+ "discoverAgentFiles": true,
69+ "skillsDirs": ["/home/me/.agents/skills"],
70+ "tools": ["edit", "read", "bash"],
71+ "customProviders": [
72+ {
73+ "id": "local",
74+ "name": "Local",
75+ "baseUrl": "http://127.0.0.1:11434/v1",
76+ "api": "openai-completions",
77+ "models": ["qwen3-coder"],
78+ "envKeys": ["LOCAL_API_KEY"],
79+ "headers": { "x-tenant": "mini" }
80+ }
81+ ]
82+}
83+```
84+
85+Keys:
86+
87+| Key | Default | Meaning |
88+|---|---|---|
89+| `provider` | unset | provider id; built-ins are `opencode` and `opencode-go`, or a `customProviders` id |
90+| `model` | unset | model id |
91+| `thinkingEffort` | unset | one of `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`; unset sends no reasoning parameter and clamps to what the model accepts |
92+| `systemPrompt` | `""` | prepended to the system prompt |
93+| `sessionsDir` | `$XDG_STATE_HOME/mini-coding-agent/sessions`, else `$HOME/.local/state/mini-coding-agent/sessions`, else `sessions` | where JSONL session logs go |
94+| `discoverAgentFiles` | `true` | load `AGENTS.md`/`CLAUDE.md` from `$HOME/.agents` and the cwd |
95+| `skillsDirs` | `[]` | directories holding `<name>/SKILL.md` skills |
96+| `tools` | `["edit", "read", "bash"]` | which tools the model sees |
97+| `customProviders` | `[]` | in-tree provider definitions |
98+
99+Unknown keys are rejected. `provider` and `model` must both be set to make a
100+request; a custom provider must list the model in its `models`.
101+
102+A `customProvider` field:
103+
104+| Field | Required | Meaning |
105+|---|---|---|
106+| `id` | yes | the id `provider` selects |
107+| `name` | no | display name; falls back to `id` |
108+| `baseUrl` | yes | request base URL |
109+| `api` | yes | one of `openai-completions`, `openai-responses`, `anthropic-messages`, `google-generative-ai` |
110+| `models` | yes | non-empty list of model ids |
111+| `envKeys` | no | environment variables searched, in order, for the API key |
112+| `headers` | no | extra request headers |
113+
114+## Environment
115+
116+The built-in providers read `OPENCODE_API_KEY`. Custom providers read the first
117+present variable in their `envKeys`. A provider without a key is listed but
118+fails at request time.
119+
120+## Sessions
121+
122+Each session is a JSONL directory under `sessionsDir`. Every message and every
123+model request is appended and fsynced. The log is write-only; a write failure
124+stops the turn.
build.zig+2−2
@@ -5,7 +5,7 @@ pub fn build(b: *std.Build) void {
55 const optimize = b.standardOptimizeOption(.{});
66
77 const exe = b.addExecutable(.{
8- .name = "mza",
8+ .name = "mini",
99 .root_module = b.createModule(.{
1010 .root_source_file = b.path("src/main.zig"),
1111 .target = target,
@@ -36,7 +36,7 @@ pub fn build(b: *std.Build) void {
3636 const run_cmd = b.addRunArtifact(exe);
3737 run_cmd.step.dependOn(b.getInstallStep());
3838 if (b.args) |args| run_cmd.addArgs(args);
39- const run_step = b.step("run", "Run mza");
39+ const run_step = b.step("run", "Run mini");
4040 run_step.dependOn(&run_cmd.step);
4141 }
4242
build.zig.zon+2−2
@@ -1,7 +1,7 @@
11 .{
2- .name = .mza,
2+ .name = .mini_coding_agent,
33 .version = "0.1.0",
4- .fingerprint = 0x502b41d3b0515574,
4+ .fingerprint = 0xcd9f17f042740125,
55 .minimum_zig_version = "0.16.0",
66 .dependencies = .{
77 .tree_sitter = .{
src/config.zig+54−25
@@ -1,6 +1,7 @@
1-//! Global config: `$XDG_CONFIG_HOME/mini-coder/config.json` (or the equivalent
1+//! Config: `$XDG_CONFIG_HOME/mini-coding-agent/config.json` (or the equivalent
22 //! under `$HOME`). Every user-facing behavior that can vary comes from here,
3-//! with a sane default. There is no project-local config.
3+//! with a sane default. There is no project-local config. A `-c`/`--config`
4+//! file is read after the global one and overrides its keys.
45
56 const std = @import("std");
67 const platform = @import("platform.zig");
@@ -27,36 +28,50 @@ pub const CustomProvider = struct {
2728 };
2829
2930 pub const Config = struct {
31+ /// The file `save` writes back to: the global config, or the override when
32+ /// one was given on the command line.
33+ path: []const u8,
3034 sessions_dir: []const u8,
31- auth_file: []const u8,
3235 system_prompt: []const u8,
3336 discover_agent_files: bool,
3437 skills_dirs: []const []const u8,
3538 tools: []const ToolName,
3639 provider: ?[]const u8,
3740 model: ?[]const u8,
38- thinking_effort: []const u8,
41+ /// Null when unset: no reasoning parameter is sent, so the provider picks.
42+ thinking_effort: ?[]const u8,
3943 custom_providers: []const CustomProvider,
4044 };
4145
4246 const valid_efforts = [_][]const u8{ "off", "minimal", "low", "medium", "high", "xhigh", "max" };
4347 const valid_apis = [_][]const u8{ "openai-completions", "openai-responses", "anthropic-messages", "google-generative-ai" };
4448 const known_keys = [_][]const u8{
45- "sessionsDir", "authFile", "systemPrompt", "discoverAgentFiles",
46- "skillsDirs", "tools", "provider", "model",
47- "thinkingEffort", "customProviders",
49+ "sessionsDir", "systemPrompt", "discoverAgentFiles",
50+ "skillsDirs", "tools", "provider",
51+ "model", "thinkingEffort", "customProviders",
4852 };
4953
5054 fn configDir(a: std.mem.Allocator) []const u8 {
5155 const base = platform.getEnv("XDG_CONFIG_HOME") orelse
5256 util.join(a, &.{ platform.home() orelse "", ".config" }) catch "";
53- return util.join(a, &.{ base, "mini-coder" }) catch "mini-coder";
57+ return util.join(a, &.{ base, "mini-coding-agent" }) catch "mini-coding-agent";
5458 }
5559
5660 pub fn configPath(a: std.mem.Allocator) []const u8 {
5761 return util.join(a, &.{ configDir(a), "config.json" }) catch "config.json";
5862 }
5963
64+/// `$XDG_STATE_HOME/mini-coding-agent/sessions`, else
65+/// `$HOME/.local/state/mini-coding-agent/sessions`, else the relative
66+/// `sessions`. Paths are not mini-coder's cwd-relative default.
67+fn sessionsDir(a: std.mem.Allocator) []const u8 {
68+ const state = platform.getEnv("XDG_STATE_HOME") orelse blk: {
69+ const home = platform.home() orelse return "sessions";
70+ break :blk util.join(a, &.{ home, ".local/state" }) catch return "sessions";
71+ };
72+ return util.join(a, &.{ state, "mini-coding-agent/sessions" }) catch "sessions";
73+}
74+
6075 fn fail(a: std.mem.Allocator, path: []const u8, comptime fmt: []const u8, args: anytype) error{InvalidConfig} {
6176 const detail = std.fmt.allocPrint(a, fmt, args) catch "invalid";
6277 platform.printErr("config {s}: {s}\n", .{ path, detail });
@@ -127,8 +142,10 @@ fn parseCustomProviders(a: std.mem.Allocator, obj: std.json.ObjectMap, path: []c
127142 const p = item.object;
128143 const id = (try strField(a, p, "id", path)) orelse
129144 return fail(a, path, "\"customProviders[{d}].id\" is required", .{i});
145+ if (id.len == 0) return fail(a, path, "\"customProviders[{d}].id\" must not be empty", .{i});
130146 const base_url = (try strField(a, p, "baseUrl", path)) orelse
131147 return fail(a, path, "\"customProviders[{d}].baseUrl\" is required", .{i});
148+ if (base_url.len == 0) return fail(a, path, "\"customProviders[{d}].baseUrl\" must not be empty", .{i});
132149 const api = (try strField(a, p, "api", path)) orelse
133150 return fail(a, path, "\"customProviders[{d}].api\" is required", .{i});
134151 var api_ok = false;
@@ -154,13 +171,29 @@ fn parseCustomProviders(a: std.mem.Allocator, obj: std.json.ObjectMap, path: []c
154171 return out.toOwnedSlice(a) catch error.OutOfMemory;
155172 }
156173
157-/// Loads the global config. A missing file yields every default. Any other
158-/// read, parse, or validation failure is reported on stderr and returned.
159-/// The result is allocated from `a` and lives for the process.
160-pub fn load(a: std.mem.Allocator) !Config {
161- const path = configPath(a);
174+/// Loads the config. The global file is always read; when `override` is given
175+/// it is read after and its keys win. A missing global file means every
176+/// default, but a missing override is an error. Any read, parse, or validation
177+/// failure is reported on stderr and returned. The result is allocated from
178+/// `a` and lives for the process.
179+pub fn load(a: std.mem.Allocator, override: ?[]const u8) !Config {
180+ var cfg = try defaults(a);
181+ try readInto(a, configPath(a), false, &cfg);
182+
183+ if (override) |path| {
184+ cfg.path = path;
185+ try readInto(a, path, true, &cfg);
186+ }
187+ return cfg;
188+}
189+
190+fn readInto(a: std.mem.Allocator, path: []const u8, required: bool, cfg: *Config) !void {
162191 const text = util.readFileAlloc(a, path, 1 << 20) catch |e| switch (e) {
163- error.FileNotFound => return defaults(a),
192+ error.FileNotFound => {
193+ if (!required) return;
194+ platform.printErr("config {s}: no such file\n", .{path});
195+ return error.InvalidConfig;
196+ },
164197 else => {
165198 platform.printErr("config {s}: {s}\n", .{ path, @errorName(e) });
166199 return error.InvalidConfig;
@@ -182,9 +215,7 @@ pub fn load(a: std.mem.Allocator) !Config {
182215 if (!known) return fail(a, path, "unknown key \"{s}\"", .{entry.key_ptr.*});
183216 }
184217
185- var cfg = try defaults(a);
186218 if (try strField(a, obj, "sessionsDir", path)) |v| cfg.sessions_dir = v;
187- if (try strField(a, obj, "authFile", path)) |v| cfg.auth_file = v;
188219 if (try strField(a, obj, "systemPrompt", path)) |v| cfg.system_prompt = v;
189220 if (try strField(a, obj, "provider", path)) |v| cfg.provider = v;
190221 if (try strField(a, obj, "model", path)) |v| cfg.model = v;
@@ -200,7 +231,6 @@ pub fn load(a: std.mem.Allocator) !Config {
200231 if (!ok) return fail(a, path, "unknown thinkingEffort \"{s}\"", .{v});
201232 cfg.thinking_effort = v;
202233 }
203- return cfg;
204234 }
205235
206236 /// The subset of config a TUI command persists. `null` leaves a key alone.
@@ -211,14 +241,14 @@ pub const Update = struct {
211241 };
212242
213243 /// Merges `update` into the on-disk config, preserving every other key. The
214-/// merge is textual: the existing file is parsed, the changed keys replaced,
215-/// and the whole object written back to `config.json`.
216-pub fn save(a: std.mem.Allocator, update: Update) !void {
244+/// merge is textual: the file at `cfg.path` is parsed, the changed keys
245+/// replaced, and the whole object written back.
246+pub fn save(a: std.mem.Allocator, cfg: *const Config, update: Update) !void {
217247 var arena = std.heap.ArenaAllocator.init(a);
218248 defer arena.deinit();
219249 const tmp = arena.allocator();
220250
221- const path = configPath(a);
251+ const path = cfg.path;
222252 var root: std.json.Value = .{ .object = std.json.ObjectMap.empty };
223253 if (util.readFileAlloc(tmp, path, 1 << 20)) |text| {
224254 const parsed = std.json.parseFromSliceLeaky(std.json.Value, tmp, text, .{}) catch
@@ -242,17 +272,16 @@ pub fn save(a: std.mem.Allocator, update: Update) !void {
242272 }
243273
244274 fn defaults(a: std.mem.Allocator) !Config {
245- const cwd = try std.process.currentPathAlloc(platform.io, a);
246275 return .{
247- .sessions_dir = try util.join(a, &.{ cwd, "sessions" }),
248- .auth_file = try util.join(a, &.{ configDir(a), "auth.json" }),
276+ .path = configPath(a),
277+ .sessions_dir = sessionsDir(a),
249278 .system_prompt = "",
250279 .discover_agent_files = true,
251280 .skills_dirs = &.{},
252281 .tools = &.{ .edit, .read, .bash },
253282 .provider = null,
254283 .model = null,
255- .thinking_effort = "medium",
284+ .thinking_effort = null,
256285 .custom_providers = &.{},
257286 };
258287 }
src/main.zig+17−9
@@ -1,4 +1,4 @@
1-//! mza: a fast, transparent, config-first terminal coding agent.
1+//! mini: a fast, transparent, config-first terminal coding agent.
22
33 const std = @import("std");
44 const platform = @import("platform.zig");
@@ -18,25 +18,29 @@ fn onSignal(_: std.posix.SIG) callconv(.c) void {
1818 cancel.store(true, .release);
1919 }
2020
21-const ParsedArgs = struct { print: ?[]const u8 = null };
21+const ParsedArgs = struct { print: ?[]const u8 = null, config: ?[]const u8 = null };
2222
2323 fn parseArgs(a: std.mem.Allocator) !ParsedArgs {
2424 var it = std.process.Args.Iterator.init(platform.args);
2525 _ = it.next();
2626 var result = ParsedArgs{};
2727 while (it.next()) |arg| {
28- var value: ?[]const u8 = null;
2928 if (std.mem.startsWith(u8, arg, "--print=")) {
30- value = arg["--print=".len..];
29+ result.print = try a.dupe(u8, arg["--print=".len..]);
3130 } else if (std.mem.startsWith(u8, arg, "-p=")) {
32- value = arg["-p=".len..];
31+ result.print = try a.dupe(u8, arg["-p=".len..]);
3332 } else if (std.mem.eql(u8, arg, "-p") or std.mem.eql(u8, arg, "--print")) {
34- value = it.next() orelse return error.MissingPrompt;
33+ const value = it.next() orelse return error.MissingPrompt;
34+ result.print = try a.dupe(u8, value);
35+ } else if (std.mem.startsWith(u8, arg, "--config=")) {
36+ result.config = try a.dupe(u8, arg["--config=".len..]);
37+ } else if (std.mem.eql(u8, arg, "-c") or std.mem.eql(u8, arg, "--config")) {
38+ const value = it.next() orelse return error.MissingConfig;
39+ result.config = try a.dupe(u8, value);
3540 } else {
3641 platform.printErr("unknown argument: {s}\n", .{arg});
3742 return error.UnknownArg;
3843 }
39- result.print = try a.dupe(u8, value.?);
4044 }
4145 return result;
4246 }
@@ -124,11 +128,15 @@ fn run() !u8 {
124128 const a = platform.gpa;
125129
126130 const args = parseArgs(a) catch |e| {
127- if (e == error.MissingPrompt) platform.printErr("a prompt is required\n", .{});
131+ switch (e) {
132+ error.MissingPrompt => platform.printErr("a prompt is required\n", .{}),
133+ error.MissingConfig => platform.printErr("a config path is required\n", .{}),
134+ else => {},
135+ }
128136 return 1;
129137 };
130138
131- const cfg = config.load(a) catch return 1;
139+ const cfg = config.load(a, args.config) catch return 1;
132140
133141 var resolve_err: ?[]const u8 = null;
134142 const model = models.resolve(a, &cfg, &resolve_err);
src/models.zig+13−10
@@ -47,22 +47,25 @@ fn normalizeEffort(value: []const u8) []const u8 {
4747 }
4848
4949 /// Clamps a desired effort to what the model accepts, preferring the next
50-/// higher level, then the next lower. A non-reasoning model runs "off".
51-fn clampEffort(info: *const catalog.ModelInfo, desired: []const u8) []const u8 {
50+/// higher level, then the next lower. An unset desire means no reasoning
51+/// parameter is sent, so the provider decides. A non-reasoning model runs
52+/// "off".
53+fn clampEffort(info: *const catalog.ModelInfo, desired: ?[]const u8) []const u8 {
54+ const want = desired orelse return "";
5255 if (!info.reasoning) return "off";
53- if (info.effort.len == 0) return desired;
56+ if (info.effort.len == 0) return want;
5457 for (info.effort) |accepted| {
55- if (std.mem.eql(u8, normalizeEffort(accepted), desired)) return normalizeEffort(accepted);
58+ if (std.mem.eql(u8, normalizeEffort(accepted), want)) return normalizeEffort(accepted);
5659 }
57- const want = rank(desired);
58- if (want < 0) return normalizeEffort(info.effort[0]);
59- var r: i32 = want;
60+ const r0 = rank(want);
61+ if (r0 < 0) return normalizeEffort(info.effort[0]);
62+ var r: i32 = r0;
6063 while (r <= 6) : (r += 1) {
6164 for (info.effort) |accepted| {
6265 if (rank(normalizeEffort(accepted)) == r) return normalizeEffort(accepted);
6366 }
6467 }
65- r = want - 1;
68+ r = r0 - 1;
6669 while (r >= 0) : (r -= 1) {
6770 for (info.effort) |accepted| {
6871 if (rank(normalizeEffort(accepted)) == r) return normalizeEffort(accepted);
@@ -101,7 +104,7 @@ pub fn resolveNamed(a: std.mem.Allocator, cfg: *const config.Config, provider_id
101104 .provider = provider_id,
102105 .base_url = b.base_url,
103106 .api_key = firstEnv(b.env_keys),
104- .effort = if (info) |i| clampEffort(i, cfg.thinking_effort) else cfg.thinking_effort,
107+ .effort = if (info) |i| clampEffort(i, cfg.thinking_effort) else cfg.thinking_effort orelse "",
105108 .supports_images = if (info) |i| i.images else true,
106109 .context_window = if (info) |i| i.context else 0,
107110 .max_tokens = if (info) |i| i.max_output else 0,
@@ -129,7 +132,7 @@ pub fn resolveNamed(a: std.mem.Allocator, cfg: *const config.Config, provider_id
129132 .provider = provider_id,
130133 .base_url = p.base_url,
131134 .api_key = firstEnv(p.env_keys),
132- .effort = cfg.thinking_effort,
135+ .effort = cfg.thinking_effort orelse "",
133136 // Custom providers are uncatalogued; assume image input. A model
134137 // that rejects images surfaces the provider error as-is.
135138 .supports_images = true,
src/tui/tui.zig+27−6
@@ -7,6 +7,7 @@ const std = @import("std");
77 const platform = @import("../platform.zig");
88 const util = @import("../util.zig");
99 const config = @import("../config.zig");
10+const session_mod = @import("../session.zig");
1011 const types = @import("../types.zig");
1112 const agent = @import("../agent.zig");
1213 const models_mod = @import("../models.zig");
@@ -461,9 +462,12 @@ const Tui = struct {
461462 self.separator = true;
462463 const model = self.opts.model;
463464 self.push(if (model) |m|
464- std.fmt.allocPrint(self.s, "mini-z-agent · {s}/{s} · {s}", .{ m.provider, m.id, m.effort }) catch "mini-z-agent"
465+ if (m.effort.len == 0)
466+ std.fmt.allocPrint(self.s, "mini · {s}/{s}", .{ m.provider, m.id }) catch "mini"
467+ else
468+ std.fmt.allocPrint(self.s, "mini · {s}/{s} · {s}", .{ m.provider, m.id, m.effort }) catch "mini"
465469 else
466- "mini-z-agent · no model configured");
470+ "mini · no model configured");
467471 self.separator = true;
468472 }
469473
@@ -748,6 +752,7 @@ const Tui = struct {
748752 if (std.mem.eql(u8, found.name, "help")) {
749753 const commands = [_][2][]const u8{
750754 .{ "/help", "list commands and keybindings" },
755+ .{ "/new", "start a new session" },
751756 .{ "/provider", "choose the provider and model" },
752757 .{ "/model", "choose a model for the current provider" },
753758 .{ "/thinking", "set the thinking level" },
@@ -772,6 +777,12 @@ const Tui = struct {
772777 self.separator = true;
773778 return;
774779 }
780+ if (std.mem.eql(u8, found.name, "new")) {
781+ self.newSession();
782+ self.push("new session");
783+ self.separator = true;
784+ return;
785+ }
775786 if (std.mem.eql(u8, found.name, "provider")) {
776787 self.startProviderSelect();
777788 return;
@@ -800,6 +811,16 @@ const Tui = struct {
800811 }
801812 }
802813
814+ /// Starts a fresh session: the current log is closed, a new one is opened
815+ /// in the same directory, and the transcript is dropped.
816+ fn newSession(self: *Tui) void {
817+ self.opts.session.close();
818+ const cwd = std.process.currentPathAlloc(platform.io, self.a) catch ".";
819+ self.opts.session.* = session_mod.Session.init(self.a, self.cfg.sessions_dir, cwd);
820+ self.messages.clearRetainingCapacity();
821+ self.dirty = true;
822+ }
823+
803824 fn startProviderSelect(self: *Tui) void {
804825 const entries = models_mod.providers(self.a, self.cfg);
805826 var ids: std.ArrayList([]const u8) = .empty;
@@ -887,7 +908,7 @@ const Tui = struct {
887908 };
888909 ptr.* = m;
889910 self.select(ptr);
890- config.save(self.a, .{ .provider = provider_id, .model = model_id }) catch {};
911+ config.save(self.a, self.cfg, .{ .provider = provider_id, .model = model_id }) catch {};
891912 self.command_active = false;
892913 return;
893914 }
@@ -908,7 +929,7 @@ const Tui = struct {
908929 updated.* = m.*;
909930 updated.effort = clamped;
910931 self.opts.model = updated;
911- config.save(self.a, .{ .thinking_effort = level }) catch {};
932+ config.save(self.a, self.cfg, .{ .thinking_effort = level }) catch {};
912933 self.pushBanner();
913934 self.command_active = false;
914935 return;
@@ -996,7 +1017,7 @@ fn findCommand(text: []const u8) ?Command {
9961017 var i: usize = 1;
9971018 while (i < text.len and text[i] != ' ' and text[i] != '\t' and text[i] != '\n') i += 1;
9981019 const name = text[1..i];
999- const known = [_][]const u8{ "help", "provider", "model", "thinking" };
1020+ const known = [_][]const u8{ "help", "new", "provider", "model", "thinking" };
10001021 for (known) |k| {
10011022 if (std.mem.eql(u8, k, name)) return .{ .name = k };
10021023 }
@@ -1009,7 +1030,7 @@ fn completeCommand(draft: []const u8) ?[]const u8 {
10091030 if (c == ' ' or c == '\t' or c == '\n') return null;
10101031 }
10111032 const typed = draft[1..];
1012- const names = [_][]const u8{ "help", "provider", "model", "thinking" };
1033+ const names = [_][]const u8{ "help", "new", "provider", "model", "thinking" };
10131034 var matches: std.ArrayList([]const u8) = .empty;
10141035 for (names) |n| {
10151036 if (std.mem.startsWith(u8, n, typed)) matches.append(platform.gpa, n) catch {};
tools/gen_catalog.py+1−1
@@ -16,7 +16,7 @@ PROVIDERS = ["opencode", "opencode-go"]
1616
1717 def fetch(src):
1818 if src.startswith(("http://", "https://")):
19- req = urllib.request.Request(src, headers={"User-Agent": "mza-catalog/1"})
19+ req = urllib.request.Request(src, headers={"User-Agent": "mini-catalog/1"})
2020 with urllib.request.urlopen(req) as r:
2121 return json.load(r)
2222 with open(src) as f:
tools/stress.sh+16−16
@@ -6,7 +6,7 @@
66 # <outdir>/frame-NNNNN.png, the final pane text in <outdir>/final.txt.
77 #
88 # tools/stress.sh [-d seconds] [-r fps] [-o outdir] [-C cwd]
9-# [-b mza] [-n name] [-p prompt]
9+# [-b mini] [-n name] [-p prompt]
1010
1111 set -euo pipefail
1212
@@ -14,7 +14,7 @@ fps=15
1414 seconds=300
1515 name="stress-$$"
1616 here=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
17-bin=$here/../zig-out/bin/mza
17+bin=$here/../zig-out/bin/mini
1818 cwd=$PWD
1919 out=
2020 prompt="Research this repo then create /tmp/my-review.html"
@@ -24,9 +24,9 @@ usage() {
2424 usage: stress.sh [options]
2525 -d seconds how long to capture (default 300)
2626 -r fps capture rate (default 15)
27- -o outdir where frames go (default /tmp/mz-stress-<stamp>)
28- -C cwd working directory mza runs in (default $PWD)
29- -b path mza binary (default ../zig-out/bin/mza)
27+ -o outdir where frames go (default /tmp/mini-stress-<stamp>)
28+ -C cwd working directory mini runs in (default $PWD)
29+ -b path mini binary (default ../zig-out/bin/mini)
3030 -n name kitty session name (default stress-$$)
3131 -p prompt what to type (default: review this repo into /tmp/my-review.html)
3232 EOF
@@ -56,10 +56,10 @@ if [[ ! -x $bin ]]; then
5656 fi
5757 bin=$(readlink -f -- "$bin")
5858 cwd=$(cd -- "$cwd" && pwd)
59-out=${out:-/tmp/mz-stress-$(date +%Y%m%d-%H%M%S)}
59+out=${out:-/tmp/mini-stress-$(date +%Y%m%d-%H%M%S)}
6060 mkdir -p -- "$out"
6161 out=$(readlink -f -- "$out")
62-socket=/tmp/mz-$name.sock
62+socket=/tmp/mini-$name.sock
6363
6464 now_us() {
6565 local t=${EPOCHREALTIME/,/.}
@@ -79,15 +79,15 @@ cleanup() {
7979 trap cleanup EXIT
8080 trap 'exit 1' INT TERM
8181
82-# The shell stays alive after mza exits so the window holds the crash for
82+# The shell stays alive after mini exits so the window holds the crash for
8383 # inspection, and so the exit status can be read back off the pane.
84-printf -v launch 'cd %q; %q; printf "\nMZA-EXIT %%d\n" $?; exec sleep 86400' "$cwd" "$bin"
84+printf -v launch 'cd %q; %q; printf "\nMINI-EXIT %%d\n" $?; exec sleep 86400' "$cwd" "$bin"
8585
8686 rm -f -- "$socket"
8787 kitty --detach --listen-on "unix:$socket" \
8888 -o allow_remote_control=yes -o remember_window_size=no \
8989 -o initial_window_width=100c -o initial_window_height=30c \
90- --title "mz-$name" \
90+ --title "mini-$name" \
9191 bash --norc --noprofile -c "$launch"
9292
9393 for _ in $(seq 100); do
@@ -102,11 +102,11 @@ fi
102102
103103 # The banner lands in scrollback, not the live region, so wait on all of it.
104104 for _ in $(seq 300); do
105- pane all | grep -q 'mini-z-agent' && break
105+ pane all | grep -q 'mini ·' && break
106106 sleep 0.1
107107 done
108-if ! pane all | grep -q 'mini-z-agent'; then
109- echo "stress: mza did not start; pane says:" >&2
108+if ! pane all | grep -q 'mini ·'; then
109+ echo "stress: mini did not start; pane says:" >&2
110110 pane all >&2
111111 exit 1
112112 fi
@@ -133,8 +133,8 @@ while :; do
133133 now=$(now_us)
134134 if (( now - checked >= 1000000 )); then
135135 checked=$now
136- if pane screen | grep -q 'MZA-EXIT'; then
137- end_reason=$(pane screen | grep -o 'MZA-EXIT -\?[0-9]*' | tail -n1)
136+ if pane screen | grep -q 'MINI-EXIT'; then
137+ end_reason=$(pane screen | grep -o 'MINI-EXIT -\?[0-9]*' | tail -n1)
138138 break
139139 fi
140140 fi
@@ -152,5 +152,5 @@ pane screen > "$out/final-screen.txt" || true
152152 echo "stress: $frames frames in $(( elapsed / 1000000 ))s (target ${fps}fps, got $(awk "BEGIN { printf \"%.1f\", $frames * 1000000 / $elapsed }")fps)"
153153 if [[ -n $end_reason ]]; then
154154 echo "stress: ended early: $end_reason"
155- [[ $end_reason == 'MZA-EXIT 0' ]] || exit 1
155+ [[ $end_reason == 'MINI-EXIT 0' ]] || exit 1
156156 fi