graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Add pwd command and show workspace folder
yxlyxba861dfdd79f
diff --git a/gui/src-tauri/src/runtime/simple.rs b/gui/src-tauri/src/runtime/simple.rsindex 3ab58c6e..df532dda 100644--- a/gui/src-tauri/src/runtime/simple.rs+++ b/gui/src-tauri/src/runtime/simple.rs@@ -403,6 +403,7 @@ impl RuntimeManager {Ok(vec![command("help", "Show available commands.", false),command("agent", "Show active agent.", false),+ command("pwd", "Show current workspace path.", true),command("compact", "Compact current conversation.", true),command("workspace-status", "Show git status.", true),])@@ -1067,6 +1068,20 @@ impl RuntimeManager {result_kind: CommandResultKindDto::Snapshot,payload: None,}),+ "pwd" => {+ let workspace = self+ .resolve_workspace(workspace_path)+ .await+ .context("Missing workspace")?;+ Ok(CommandRunResultDto {+ title: "/pwd".into(),+ body: Some(workspace),+ snapshot: None,+ saved_path: None,+ result_kind: CommandResultKindDto::Text,+ payload: None,+ })+ }"workspace-status" => {let workspace = workspace_path.unwrap_or_default();Ok(CommandRunResultDto {@@ -1086,7 +1101,7 @@ impl RuntimeManager {_ => Ok(CommandRunResultDto {title: format!("/{name}"),body: Some(format!(- "Available MVP commands: /help, /agent, /compact, /workspace-status. Args: {}",+ "Available MVP commands: /help, /agent, /pwd, /compact, /workspace-status. Args: {}",args.join(" "))),snapshot: None,@@ -2674,7 +2689,11 @@ fn codegraff_binary() -> String {}}}- for abs in ["/opt/homebrew/bin/graff", "/usr/local/bin/graff", "/usr/bin/graff"] {+ for abs in [+ "/opt/homebrew/bin/graff",+ "/usr/local/bin/graff",+ "/usr/bin/graff",+ ] {if Path::new(abs).is_file() {return abs.to_string();}diff --git a/gui/src/services/desktop/client.ts b/gui/src/services/desktop/client.tsindex d2850dc7..aed238ad 100644--- a/gui/src/services/desktop/client.ts+++ b/gui/src/services/desktop/client.ts@@ -70,6 +70,7 @@ const qaCommandRows: Array<[]> = [["help", "Show available slash commands.", null, "text"],["agent", "Show active agent and available agents.", null, "agents"],+ ["pwd", "Show current workspace path.", null, "text"],["sage", "Switch to Sage.", null, "agents"],["reasoning-effort", "Update reasoning effort.", "<low|medium|high>", "text"],["workspace-info", "Show indexed workspace metadata.", null, "workspaceInfo"],@@ -99,7 +100,7 @@ const qaCommands: CommandDescriptor[] = qaCommandRows.map(: "builtin",name,requiresConversation: false,- requiresWorkspace: name.startsWith("workspace-"),+ requiresWorkspace: name === "pwd" || name.startsWith("workspace-"),resultKind,usage,value: name === "sage" ? "sage" : null,@@ -227,9 +228,11 @@ function qaCommandResult(input: {switch (input.name) {case "help":- return { body: "| Command | What it does | UI expectation |\n|---|---|---|\n| `/help` | Lists commands | Inline table |\n| `/agent` | Shows current agent | Inline cards |\n| `/workspace-info` | Shows metadata | Inline markdown/table |\n| `/workflow <goal>` | Builds a workflow draft | Review modal |", payload: null, resultKind: "text", savedPath: null, snapshot: null, title: "/help" };+ return { body: "| Command | What it does | UI expectation |\n|---|---|---|\n| `/help` | Lists commands | Inline table |\n| `/agent` | Shows current agent | Inline cards |\n| `/pwd` | Shows current workspace folder | Inline text |\n| `/workspace-info` | Shows metadata | Inline markdown/table |\n| `/workflow <goal>` | Builds a workflow draft | Review modal |", payload: null, resultKind: "text", savedPath: null, snapshot: null, title: "/help" };case "agent":return { body: "Current agent status.", payload: { kind: "agents", ...qaAgentsPayload() }, resultKind: "agents", savedPath: null, snapshot: null, title };+ case "pwd":+ return { body: input.workspacePath ?? QA_WORKSPACE_PATH, payload: null, resultKind: "text", savedPath: null, snapshot: null, title: "/pwd" };case "sage":qaActiveAgentId = "sage";return { body: "Switched active agent to Sage.", payload: { kind: "agents", ...qaAgentsPayload() }, resultKind: "agents", savedPath: null, snapshot: null, title };diff --git a/src/main.zig b/src/main.zigindex 73578f9f..b6a803e2 100644--- a/src/main.zig+++ b/src/main.zig@@ -2269,6 +2269,8 @@ fn mcpServerConnected(tools: []const mcp.Tool, server: []const u8) bool {/// PATH captured at startup for skill detection (PATH won't change mid-run).var g_path_env: []const u8 = "";+/// Human-facing current workspace folder shown in the REPL prompt and /pwd.+var g_cwd_display: []const u8 = ".";fn binOnPath(io: Io, name: []const u8) bool {var it = std.mem.splitScalar(u8, g_path_env, ':');@@ -3986,9 +3988,14 @@ pub fn main(init: std.process.Init) !void {style = Style.ansi;use_color = true;}+ var cwd_buf: [4096]u8 = undefined;+ g_cwd_display = if (Io.Dir.cwd().realPath(io, &cwd_buf)) |n|+ try arena.dupe(u8, cwd_buf[0..n])+ else |_|+ try arena.dupe(u8, init.environ_map.get("PWD") orelse ".");if (!json_mode and oneshot_prompt == null) {- try out.print("{s}simple-harness{s} · / for commands · @ picks a file · esc interrupts · ↑/↓ history · tab completes · ctrl-d quits · trace → {s}\n", .{ style.bold, style.reset, trace_path });+ try out.print("{s}codegraff{s} · folder: {s}{s}{s} · / for commands · @ picks a file · esc interrupts · ↑/↓ history · tab completes · ctrl-d quits · trace → {s}\n", .{ style.bold, style.reset, style.cyan, g_cwd_display, style.reset, trace_path });try out.flush();if (codex_account) |acct| {try out.print("logged into Codex (ChatGPT account {s}…) — /model gpt-5.5\n", .{acct[0..@min(acct.len, 8)]});@@ -5027,6 +5034,7 @@ const command_menu = [_]PickItem{.{ .name = "/model", .desc = "switch model/provider (picker)" },.{ .name = "/models", .desc = "list known models, context windows" },.{ .name = "/clear", .desc = "wipe the conversation, start fresh" },+ .{ .name = "/pwd", .desc = "show the current workspace folder" },.{ .name = "/compact", .desc = "summarize history into a fresh context" },.{ .name = "/plan", .desc = "toggle plan mode (read-only, propose first)" },.{ .name = "/resume", .desc = "restore a saved session (picker)" },@@ -5086,6 +5094,11 @@ fn handleCommand(root: *Agent, keys: *Keys, arena: Allocator, line: []const u8,try out.flush();return;}+ if (std.mem.eql(u8, line, "/pwd")) {+ try out.print("{s}\n", .{g_cwd_display});+ try out.flush();+ return;+ }if (std.mem.eql(u8, line, "/agents")) {try out.print("{s}agent types{s} — MAP-Elites niches: builtins + {s}/*.md (file shadows builtin); spawn via subagent agent:\"<name>\"\n", .{ style.bold, style.reset, agents_dir });for (g_agent_types) |t| {@@ -7273,15 +7286,16 @@ const Agent = struct {const threshold = self.provider.compactAt();// % of the compaction budget already used — glanceable headroom.const pct = if (threshold > 0) self.last_context_tokens * 100 / threshold else 0;- try w.print("\n{s}[{s}{s}{s}{s}{s} · {d}/{d}k tok ({d}%){s}{s}]{s} {s}›{s} ", .{- style.dim, style.reset, style.cyan, self.provider.model, flag, style.dim,- self.last_context_tokens, threshold / 1000, pct, cached, cost, style.reset,- style.bold, style.reset,+ try w.print("\n{s}[{s}{s}{s}{s}{s} · {s}{s}{s} · {d}/{d}k tok ({d}%){s}{s}]{s} {s}›{s} ", .{+ style.dim, style.reset, style.cyan, self.provider.model, flag, style.dim,+ style.reset, g_cwd_display, style.dim, self.last_context_tokens, threshold / 1000, pct,+ cached, cost, style.reset, style.bold, style.reset,});} else {- try w.print("\n{s}[{s}{s}{s}{s}{s}{s}]{s} {s}›{s} ", .{- style.dim, style.reset, style.cyan, self.provider.model, flag, style.dim, cost,- style.reset, style.bold, style.reset,+ try w.print("\n{s}[{s}{s}{s}{s}{s} · {s}{s}{s}{s}]{s} {s}›{s} ", .{+ style.dim, style.reset, style.cyan, self.provider.model, flag, style.dim,+ style.reset, g_cwd_display, style.dim, cost, style.reset, style.bold,+ style.reset,});}try w.flush();