graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix(repl): restore missing command_catalog.zig (fixes build/CI)
justracha7125e087c5f
diff --git a/src/command_catalog.zig b/src/command_catalog.zignew file mode 100644index 00000000..ef3e8b51--- /dev/null+++ b/src/command_catalog.zig@@ -0,0 +1,82 @@+//! The single source of truth for the REPL slash-command catalog, shared by+//! its three consumers so they never drift (600-line goal, issue #123):+//! - the bare "/" fuzzy menu (pickers.command_menu -> mainloop)+//! - the /help dump (commands_misc.handleRest)+//! - tab completion (main.repl_commands -> input_util)+//! Each entry's `name` is the runnable command — the bare "/" menu passes it+//! straight to handleCommand, so it must be the plain "/foo" form, never a+//! usage string. `usage` is the fuller "/foo <arg>" form shown only in the+//! /help dump (it falls back to `name` when empty). `desc` is the one-liner.++const std = @import("std");++/// One catalog entry. `name`/`desc` are the same two fields the generic+/// listPicker items carry (pickers.PickItem = this type), so both are always+/// set there; `usage` is catalog-only and defaults to the bare name.+pub const Item = struct {+ name: []const u8,+ desc: []const u8 = "",+ usage: []const u8 = "",+};++/// The canonical command list, in menu / help display order.+pub const commands = [_]Item{+ .{ .name = "/model", .usage = "/model <name>", .desc = "switch model/provider, fuzzy match (e.g. \"sonnet\", \"opus\")" },+ .{ .name = "/models", .usage = "/models [health]", .desc = "list known models, context windows, compaction points; health shows live state" },+ .{ .name = "/clear", .desc = "wipe the conversation and start fresh" },+ .{ .name = "/new", .desc = "start a fresh autosaved session" },+ .{ .name = "/rename", .usage = "/rename <title>", .desc = "set the current session title" },+ .{ .name = "/goal", .usage = "/goal [text]", .desc = "set/show a standing objective (tracked as a checklist); /goal clear clears" },+ .{ .name = "/loop", .usage = "/loop <prompt>", .desc = "run an autonomous plan->act->verify pass" },+ .{ .name = "/plan", .desc = "toggle plan mode: read-only explore + propose; writes/edits denied" },+ .{ .name = "/ultracode", .desc = "toggle persistent workflow mode; bare opens an on/off picker, or /ultracode on|off" },+ .{ .name = "/fallback", .usage = "/fallback [allow|remove|off]", .desc = "opt-in cross-provider fallback for this workspace (same-provider rollout stays on)" },+ .{ .name = "/key", .usage = "/key [provider secret]", .desc = "show API-key status; /key <provider> <secret> adds one live (+ Keychain)" },+ .{ .name = "/login", .usage = "/login [codegraff|codex|kimi]", .desc = "OAuth sign-in (no key to paste); bare opens a picker (codex alias: oai)" },+ .{ .name = "/keepcontext", .desc = "toggle keeping the conversation when /model switches wire format (default on)" },+ .{ .name = "/effort", .desc = "reasoning depth: low|medium|high|... (codex, deepseek, codegraff; persists)" },+ .{ .name = "/reasoning", .desc = "alias for /effort" },+ .{ .name = "/fast", .desc = "codex only: priority service tier for lower latency (toggle, persists)" },+ .{ .name = "/thinking", .desc = "stream reasoning live vs spinner only (toggle, persists)" },+ .{ .name = "/title", .desc = "name the tab from your first prompt (AI session title; toggle, persists)" },+ .{ .name = "/strict", .desc = "toggle \"every message is a tool\" mode" },+ .{ .name = "/yolo", .desc = "toggle bash auto-approval (skip permission prompts)" },+ .{ .name = "/trace", .desc = "toggle the JSONL event trace (harness.trace.jsonl)" },+ .{ .name = "/trajectory", .desc = "show this session's agent tree — turns + spawned subagents" },+ .{ .name = "/agents", .desc = "list agent types — builtin personas + .harness/agents/*.md" },+ .{ .name = "/skills", .usage = "/skills [remove <name>]", .desc = "list available skills; /skills remove <name> disables one" },+ .{ .name = "/hooks", .desc = "list lifecycle hooks and the built-in codedb guard" },+ .{ .name = "/compact", .desc = "summarize history into a fresh context" },+ .{ .name = "/rewind", .usage = "/rewind [n]", .desc = "list past prompts; /rewind <n> drops prompt n+after & reverts its file edits" },+ .{ .name = "/image", .usage = "/image <path>", .desc = "attach an image to your next message (vision models only)" },+ .{ .name = "/paste", .desc = "attach the clipboard image — macOS; also Ctrl-V (⌘V can't be captured)" },+ .{ .name = "/bash", .usage = "/bash <command>", .desc = "run a shell command directly" },+ .{ .name = "/save", .usage = "/save [name]", .desc = "write the conversation to <name>.session.json (default: current)" },+ .{ .name = "/resume", .usage = "/resume [name]", .desc = "restore a saved conversation (no arg → interactive picker)" },+ .{ .name = "/sessions", .desc = "list saved sessions in the cwd" },+ .{ .name = "/todo", .desc = "show the current task list" },+ .{ .name = "/jobs", .desc = "list background jobs" },+ .{ .name = "/cost", .desc = "session token usage and cost" },+ .{ .name = "/animation", .desc = "pick the thinking animation; persists to settings" },+ .{ .name = "/theme", .usage = "/theme [name]", .desc = "pick a color theme; /theme off resets to your terminal default; persists" },+ .{ .name = "/fleet", .usage = "/fleet [on|off]", .desc = "federated DGM contribution (propose/submit/elite_pull)" },+ .{ .name = "/mcp", .usage = "/mcp [add …]", .desc = "list MCP servers/tools; /mcp add <name> <cmd> [args...] connects one live" },+ .{ .name = "/help", .desc = "list every command" },+};++/// Bare command names for tab completion (re-exported as main.repl_commands),+/// derived from `commands` so completion never drifts from the menu.+pub const names = blk: {+ var arr: [commands.len][]const u8 = undefined;+ for (&arr, commands) |*slot, command| slot.* = command.name;+ break :blk arr;+};++test "catalog is well-formed and names track commands" {+ try std.testing.expectEqual(commands.len, names.len);+ for (commands, names) |command, name| {+ try std.testing.expect(command.name.len > 1 and command.name[0] == '/');+ try std.testing.expect(command.desc.len > 0);+ try std.testing.expectEqualStrings(command.name, name);+ }+}