Skip to content

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

Python

Add graff refresh as the short catalog pull

justrach345a29d41235
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e888bce7..3d18eecd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ current is part of cutting a release.
## v0.0.302.4
- Xiaomi's model list follows `https://api.xiaomimimo.com/v1/models` (same 6h cache and `graff models refresh` as the other live catalogs). Offline fallback and the default are MiMo-V2.6.
+- `graff refresh` is the short form of `graff models refresh`.
- A background command that exits resumes the same session with its exit status and output, instead of waiting for another message (#1154).
- Desktop interface sounds are optional and off until turned on. Cuelume notices ship with the app bundle.
- Desktop task workspaces get their own Git checkouts, with a keep gate so dirty or unique trees are not dropped.
diff --git a/src/cli.zig b/src/cli.zig
index c38735fc..a6e14198 100644
--- a/src/cli.zig
+++ b/src/cli.zig
@@ -323,7 +323,8 @@ pub const usage_text =
\\ graff login zai Z.AI Coding Plan OAuth login
\\ graff key set <provider> <key> store a key (Keychain; POSIX 0600 file; Windows home ACL)
\\ graff key list show which providers have keys
- \\ graff models [refresh] list the live catalog; refresh Codex + models.dev metadata
+ \\ graff refresh pull live catalogs (same as `graff models refresh`)
+ \\ graff models [refresh] list the live catalog; refresh Codex + provider lists + models.dev
\\ graff route <model>… dry-run which provider/billing a model lands on (no API call)
\\ graff mcp add <name> -- <cmd> add a stdio MCP server to .mcp.json
\\ graff mcp add <name> --url <url> add a Streamable HTTP MCP server
diff --git a/src/models_cache.zig b/src/models_cache.zig
index 03d12611..c06d34ed 100644
--- a/src/models_cache.zig
+++ b/src/models_cache.zig
@@ -546,7 +546,7 @@ pub fn list(out: *Io.Writer) !void {
try out.print(" {s:<34}{d:>10} ctx (unpriced)\n", .{ m.name, ctx });
}
}
- try out.writeAll("\nrefresh Codex catalog + models.dev metadata: graff models refresh\n");
+ try out.writeAll("\nrefresh live catalogs: graff refresh\n");
try out.flush();
}
diff --git a/src/startup.zig b/src/startup.zig
index daabc2b0..68e362a4 100644
--- a/src/startup.zig
+++ b/src/startup.zig
@@ -227,10 +227,20 @@ pub fn resolveKeysOrRunAcpPreAuth(io: Io, gpa: Allocator, arena: Allocator, init
return null;
}
+/// `graff models` lists, `graff refresh` is `graff models refresh`, `graff route` dry-runs seating.
+pub const CatalogCommand = enum { none, list, refresh, route };
+
+pub fn catalogCommand(name: []const u8) CatalogCommand {
+ if (std.mem.eql(u8, name, "models")) return .list;
+ if (std.mem.eql(u8, name, "refresh")) return .refresh;
+ if (std.mem.eql(u8, name, "route")) return .route;
+ return .none;
+}
+
/// The early subcommand/flag branches that exit before any credential
/// resolution or Agent construction happens — `--help`/`--version`, `key`,
/// `mcp add`, `login`, `serve`, `update`, `worktree` (list/merge), `sandboxes`,
-/// `cube`, and `--schema`. Moved verbatim out of main() (600-line goal,
+/// `cube`, `refresh`, and `--schema`. Moved verbatim out of main() (600-line goal,
/// #123 follow-up). Returns true when a branch handled the run and main()
/// should return immediately without going any further (credential
/// resolution, Agent construction, the REPL/turn loop, ...).
@@ -397,16 +407,17 @@ pub fn runSubcommand(io: Io, gpa: Allocator, arena: Allocator, init: std.process
return true;
}
- // `graff models [refresh]` / `graff route <model>…`: print the catalog or
- // pull fresh metadata; route dry-runs provider seating on the same caches.
- if (flags.positionals.items.len > 0 and (std.mem.eql(u8, flags.positionals.items[0], "models") or std.mem.eql(u8, flags.positionals.items[0], "route"))) {
+ // `graff models [refresh]` / `graff refresh` / `graff route <model>…`:
+ // print the catalog or pull fresh metadata; route dry-runs seating.
+ const catalog = if (flags.positionals.items.len > 0) catalogCommand(flags.positionals.items[0]) else .none;
+ if (catalog != .none) {
const home = keys_cli.homeEnv(init.environ_map) orelse std.process.fatal("no HOME/USERPROFILE", .{});
const codex_home = oauth.codexHomeDir(arena, home) orelse "";
const codex_auth = oauth.loadCodexAuthFrom(io, arena, codex_home);
- const refreshing = flags.positionals.items.len > 1 and
+ const refreshing = catalog == .refresh or (flags.positionals.items.len > 1 and
(std.mem.eql(u8, flags.positionals.items[1], "refresh") or
std.mem.eql(u8, flags.positionals.items[1], "--refresh") or
- std.mem.eql(u8, flags.positionals.items[1], "update"));
+ std.mem.eql(u8, flags.positionals.items[1], "update")));
models_cache.loadCodexCatalog(
io,
gpa,
@@ -465,7 +476,13 @@ pub fn runSubcommand(io: Io, gpa: Allocator, arena: Allocator, init: std.process
router_keys.router_source = if (router_keys.router_value != null) .stored else .none;
}
router_catalog.loadAll(io, gpa, arena, home, router_keys, refreshing);
- if (std.mem.eql(u8, flags.positionals.items[0], "route")) try @import("route_check.zig").command(io, gpa, arena, init.environ_map, flags.positionals.items[1..]) else try models_cache.command(io, gpa, arena, home, flags.positionals.items[1..]);
+ const refresh_args = [_][]const u8{"refresh"};
+ switch (catalog) {
+ .route => try @import("route_check.zig").command(io, gpa, arena, init.environ_map, flags.positionals.items[1..]),
+ .refresh => try models_cache.command(io, gpa, arena, home, &refresh_args),
+ .list => try models_cache.command(io, gpa, arena, home, flags.positionals.items[1..]),
+ .none => unreachable,
+ }
return true;
}
diff --git a/src/startup_tests.zig b/src/startup_tests.zig
index 13a81136..c9c1eb7e 100644
--- a/src/startup_tests.zig
+++ b/src/startup_tests.zig
@@ -9,6 +9,14 @@ const builtin = @import("builtin");
const resolveKeys = @import("startup.zig").resolveKeys;
+test "graff refresh is the short catalog pull, not a new command" {
+ const startup = @import("startup.zig");
+ try std.testing.expectEqual(startup.CatalogCommand.refresh, startup.catalogCommand("refresh"));
+ try std.testing.expectEqual(startup.CatalogCommand.list, startup.catalogCommand("models"));
+ try std.testing.expectEqual(startup.CatalogCommand.route, startup.catalogCommand("route"));
+ try std.testing.expectEqual(startup.CatalogCommand.none, startup.catalogCommand("update"));
+}
+
test "resolveKeys does not load Kimi/xAI OAuth credentials for an explicit unrelated provider" {
// #274: loadKimiOAuth/loadXaiOAuth refresh in place (a synchronous
// network round-trip) when the stored credential is near expiry. Before