Skip to content

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

Python

feat: /ultracode slash command for persistent ultracode mode (issue #62)

Rach Pradhan460a4009d0aa
diff --git a/gui/src-tauri/src/runtime/simple.rs b/gui/src-tauri/src/runtime/simple.rs
index 99060592..76475553 100644
--- a/gui/src-tauri/src/runtime/simple.rs
+++ b/gui/src-tauri/src/runtime/simple.rs
@@ -42,6 +42,8 @@ struct ConversationState {
/// (harness semantics). Surfaced to the GUI's task-progress dock.
todos: Vec<SessionTodoDto>,
goal: Option<String>,
+ /// Persistent ultracode (multi-agent workflow) mode, scoped to this chat.
+ ultracode_enabled: bool,
updated_at: i64,
}
@@ -445,6 +447,7 @@ impl RuntimeManager {
bash_command(),
command("compact", "Compact current conversation.", true),
command("workspace-status", "Show git status.", true),
+ command("ultracode", "Toggle persistent ultracode (multi-agent workflow) mode.", true),
])
}
@@ -484,6 +487,7 @@ impl RuntimeManager {
queued_prompts: VecDeque::new(),
active_agent_id,
plan_mode,
+ ultracode_enabled: false,
todos: Vec::new(),
goal: None,
updated_at: now_millis(),
@@ -1017,7 +1021,7 @@ impl RuntimeManager {
continue;
};
match event.get("type").and_then(serde_json::Value::as_str) {
- Some("model" | "compact" | "mode" | "agent" | "effort" | "fast") => break event,
+ Some("model" | "compact" | "mode" | "agent" | "effort" | "fast" | "ultracode") => break event,
Some("error") => {
let message = event
.get("message")
@@ -1057,6 +1061,7 @@ impl RuntimeManager {
messages: conversation.messages.clone(),
active_agent_id: conversation.active_agent_id.clone(),
plan_mode: conversation.plan_mode,
+ ultracode_enabled: conversation.ultracode_enabled,
goal: conversation.goal.clone(),
updated_at: conversation.updated_at,
})
@@ -1095,7 +1100,7 @@ impl RuntimeManager {
let model_arg = self.selected_model_arg().await;
let mut sessions = self.sessions.lock().await;
if !sessions.contains_key(conversation_id) {
- let (active_agent_id, plan_mode, effort, fast) = {
+ let (active_agent_id, plan_mode, effort, fast, ultracode) = {
let state = self.state.lock().await;
let conversation = state.conversations.get(conversation_id);
(
@@ -1107,6 +1112,7 @@ impl RuntimeManager {
.unwrap_or(false),
state.selected_effort.clone(),
state.fast_enabled,
+ conversation.map(|c| c.ultracode_enabled).unwrap_or(false),
)
};
let session = spawn_graff_session(workspace_path, model_arg.as_deref())?;
@@ -1140,6 +1146,13 @@ impl RuntimeManager {
)
.await?;
}
+ if ultracode {
+ self.send_control(
+ conversation_id,
+ serde_json::json!({ "type": "set_ultracode", "on": true }),
+ )
+ .await?;
+ }
sessions = self.sessions.lock().await;
}
let session = sessions
@@ -1202,6 +1215,39 @@ impl RuntimeManager {
result_kind: CommandResultKindDto::Agents,
payload: Some(CommandPayloadDto::Agents(self.agents_payload().await)),
}),
+ "ultracode" => {
+ let conversation_id = conversation_id.context("Missing conversation")?;
+ let now_on = {
+ let mut state = self.state.lock().await;
+ let conversation = state
+ .conversations
+ .get_mut(&conversation_id)
+ .context("Conversation not found")?;
+ conversation.ultracode_enabled = !conversation.ultracode_enabled;
+ conversation.ultracode_enabled
+ };
+ self.persist_conversations().await;
+ if self.session_exists(&conversation_id).await {
+ self.send_control(
+ &conversation_id,
+ serde_json::json!({ "type": "set_ultracode", "on": now_on }),
+ )
+ .await?;
+ }
+ let body = if now_on {
+ "Ultracode mode enabled for this chat."
+ } else {
+ "Ultracode mode disabled for this chat."
+ };
+ Ok(CommandRunResultDto {
+ title: "/ultracode".into(),
+ body: Some(body.into()),
+ snapshot: None,
+ saved_path: None,
+ result_kind: CommandResultKindDto::Text,
+ payload: None,
+ })
+ }
"goal" => {
let _workspace = workspace_path.context("Missing workspace")?;
let conversation_id = conversation_id.context("Missing conversation")?;
@@ -1679,6 +1725,7 @@ impl RuntimeManager {
queued_prompts: VecDeque::new(),
active_agent_id: None,
plan_mode: false,
+ ultracode_enabled: false,
todos: Vec::new(),
goal: None,
updated_at: now_millis(),
@@ -2267,6 +2314,8 @@ struct PersistedConversation {
#[serde(default)]
plan_mode: bool,
#[serde(default)]
+ ultracode_enabled: bool,
+ #[serde(default)]
goal: Option<String>,
#[serde(default)]
updated_at: i64,
@@ -2354,6 +2403,7 @@ fn load_persisted_conversations() -> HashMap<String, ConversationState> {
queued_prompts: VecDeque::new(),
active_agent_id: conversation.active_agent_id,
plan_mode: conversation.plan_mode,
+ ultracode_enabled: conversation.ultracode_enabled,
todos: Vec::new(),
goal: conversation.goal,
updated_at: conversation.updated_at,
@@ -2469,7 +2519,7 @@ fn command(name: &str, usage: &str, requires_workspace: bool) -> CommandDescript
is_agent_switch: false,
execution_kind: CommandExecutionKindDto::Runnable,
requires_workspace,
- requires_conversation: matches!(name, "compact" | "goal" | "loop"),
+ requires_conversation: matches!(name, "compact" | "goal" | "loop" | "ultracode"),
argument_hint: None,
result_kind: CommandResultKindDto::Text,
}
@@ -3956,6 +4006,7 @@ mod tests {
queued_prompts: VecDeque::new(),
active_agent_id: None,
plan_mode: false,
+ ultracode_enabled: false,
todos: Vec::new(),
goal: None,
updated_at: 10,
@@ -4226,6 +4277,7 @@ mod tests {
queued_prompts: VecDeque::new(),
active_agent_id: None,
plan_mode: false,
+ ultracode_enabled: false,
todos: Vec::new(),
goal: None,
updated_at: 10,
@@ -4243,6 +4295,7 @@ mod tests {
queued_prompts: VecDeque::new(),
active_agent_id: None,
plan_mode: false,
+ ultracode_enabled: false,
todos: Vec::new(),
goal: None,
updated_at: 20,
diff --git a/src/main.zig b/src/main.zig
index 1369bf07..b4f0cce6 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -79,7 +79,7 @@ var unattended = false; // -p one-shot: no human to prompt; unapproved tool call
const schema_protocol_json =
\\{
\\ "transport": "newline-delimited JSON over stdin/stdout (--json)",
- \\ "request": "one JSON object per line: {\"type\":\"user\",\"text\":\"...\"} sends a user turn; {\"type\":\"answer\",\"text\":\"...\",\"cancelled\":false,\"call_id\":\"optional\"} answers an active ask_user event; {\"type\":\"set_system_prompt\",\"text\":\"...\",\"append\":false} replaces (or with append=true extends) the system prompt between turns and acks with a system_prompt event; {\"type\":\"set_model\",\"model\":\"gpt-5.5\",\"provider\":\"codex\"}, {\"type\":\"compact\"}, {\"type\":\"set_mode\",\"mode\":\"plan|normal\"}, and {\"type\":\"set_agent\",\"id\":\"reviewer\"}, {\"type\":\"set_effort\",\"level\":\"low|medium|high\"}, and {\"type\":\"set_fast\",\"on\":true} are live control requests acked by model/compact/mode/agent/effort/fast events. For compatibility, set_model also accepts legacy {\"name\":\"provider model|model\"}. NOTE: the system prompt heads the KV-cached prefix, so any mutation invalidates the cache for the whole conversation (per Manus context-engineering lessons) — set it at spawn when possible and mutate only at task boundaries",
+ \\ "request": "one JSON object per line: {\"type\":\"user\",\"text\":\"...\"} sends a user turn; {\"type\":\"answer\",\"text\":\"...\",\"cancelled\":false,\"call_id\":\"optional\"} answers an active ask_user event; {\"type\":\"set_system_prompt\",\"text\":\"...\",\"append\":false} replaces (or with append=true extends) the system prompt between turns and acks with a system_prompt event; {\"type\":\"set_model\",\"model\":\"gpt-5.5\",\"provider\":\"codex\"}, {\"type\":\"compact\"}, {\"type\":\"set_mode\",\"mode\":\"plan|normal\"}, and {\"type\":\"set_agent\",\"id\":\"reviewer\"}, {\"type\":\"set_effort\",\"level\":\"low|medium|high\"}, and {\"type\":\"set_fast\",\"on\":true} are live control requests acked by model/compact/mode/agent/effort/fast/ultracode events. For compatibility, set_model also accepts legacy {\"name\":\"provider model|model\"}. NOTE: the system prompt heads the KV-cached prefix, so any mutation invalidates the cache for the whole conversation (per Manus context-engineering lessons) — set it at spawn when possible and mutate only at task boundaries",
\\ "score_request": "{\"type\":\"score\",\"prompt_sha\":\"<16 hex>\",\"score\":0.7,\"notes\":\"...\",\"parent_sha\":\"<16 hex, optional>\"} appends an evaluation record for an agent/prompt variant to harness.trajectory.jsonl (the append-only DGM-style archive; prompt_sha = first 8 bytes of SHA-256 of the system prompt, hex; parent_sha records which prompt this variant was mutated from — the lineage edge DGM parent selection counts children with) and acks with a score event",
\\ "events": [
\\ {"type": "text", "text": "assistant text delta"},
@@ -2224,7 +2224,7 @@ fn loadOrCreateId(io: Io, gpa: Allocator, home: []const u8, fname: []const u8) [
/// Reasoning depth for codex/responses (OpenAI Responses `reasoning.effort`).
const ReasoningEffort = enum { low, medium, high };
-const repl_commands = [_][]const u8{ "/model", "/models", "/clear", "/bash", "/plan", "/key", "/keepcontext", "/effort", "/fast", "/reasoning", "/strict", "/yolo", "/trace", "/trajectory", "/agents", "/skills", "/hooks", "/compact", "/rewind", "/image", "/paste", "/save", "/resume", "/sessions", "/todo", "/jobs", "/cost", "/animation", "/mcp", "/help" };
+const repl_commands = [_][]const u8{ "/model", "/models", "/clear", "/bash", "/plan", "/key", "/keepcontext", "/effort", "/fast", "/ultracode", "/reasoning", "/strict", "/yolo", "/trace", "/trajectory", "/agents", "/skills", "/hooks", "/compact", "/rewind", "/image", "/paste", "/save", "/resume", "/sessions", "/todo", "/jobs", "/cost", "/animation", "/mcp", "/help" };
/// Lifecycle hooks (codex/Claude-style), loaded once at startup from
/// .harness/settings.json's "hooks" object. Three events:
@@ -4955,6 +4955,12 @@ pub fn main(init: std.process.Init) !void {
root.emit(.{ .type = "fast", .ok = true, .on = on, .applies = root.provider.kind == .responses });
continue;
}
+ if (std.mem.eql(u8, rtype, "set_ultracode")) {
+ const on = if (parsed.object.get("on")) |v| (if (v == .bool) v.bool else false) else false;
+ root.ultracode_mode = on;
+ root.emit(.{ .type = "ultracode", .ok = true, .on = on });
+ continue;
+ }
if (std.mem.eql(u8, rtype, "score")) {
const sha = if (parsed.object.get("prompt_sha")) |v| (if (v == .string) v.string else "") else "";
const sc: f64 = if (parsed.object.get("score")) |v| switch (v) {
@@ -5046,7 +5052,7 @@ pub fn main(init: std.process.Init) !void {
stageGuiImageAttachment(&root, msg);
// "ultracode" codeword: opt this turn into multi-agent workflow mode.
- if (std.ascii.indexOfIgnoreCase(msg, "ultracode") != null) {
+ if (std.ascii.indexOfIgnoreCase(msg, "ultracode") != null or root.ultracode_mode) {
if (!json_mode) {
if (interactive) {
ultracodeShine(out, io);
@@ -5659,6 +5665,7 @@ const command_menu = [_]PickItem{
.{ .name = "/effort", .desc = "thinking depth: low|medium|high (codex, deepseek, codegraff)" },
.{ .name = "/reasoning", .desc = "alias for /effort" },
.{ .name = "/fast", .desc = "codex priority service tier — lower latency (gpt-5.5)" },
+ .{ .name = "/ultracode", .desc = "toggle persistent ultracode (multi-agent workflow) mode" },
.{ .name = "/image", .desc = "attach an image to the next message" },
.{ .name = "/paste", .desc = "attach the clipboard image" },
.{ .name = "/trace", .desc = "toggle the JSONL event trace" },
@@ -6156,6 +6163,12 @@ fn handleCommand(root: *Agent, keys: *Keys, arena: Allocator, line: []const u8,
try out.flush();
return;
}
+ if (std.mem.eql(u8, line, "/ultracode") or std.mem.eql(u8, line, "/ultracode on") or std.mem.eql(u8, line, "/ultracode off")) {
+ root.ultracode_mode = if (std.mem.eql(u8, line, "/ultracode on")) true else if (std.mem.eql(u8, line, "/ultracode off")) false else !root.ultracode_mode;
+ try out.print("ultracode mode: {s}\n", .{if (root.ultracode_mode) "on" else "off"});
+ try out.flush();
+ return;
+ }
if (std.mem.startsWith(u8, line, "/effort") or std.mem.startsWith(u8, line, "/reasoning")) {
const prefix: []const u8 = if (std.mem.startsWith(u8, line, "/effort")) "/effort" else "/reasoning";
const arg = std.mem.trim(u8, line[prefix.len..], " \t");
@@ -7921,6 +7934,7 @@ const Agent = struct {
keep_context: bool = true, // carry the conversation across wire-format model switches (/keepcontext)
reasoning: ReasoningEffort = .medium, // reasoning/thinking depth — codex, deepseek, codegraff (/effort, /reasoning)
fast: bool = false, // codex "fast" mode → priority service_tier (/fast)
+ ultracode_mode: bool = false, // persistent ultracode (multi-agent workflow) mode (/ultracode)
sys_strict: []const u8 = main_system_prompt_strict,
tools_anthropic: []const u8 = tools_anthropic_sub,
tools_openai: []const u8 = tools_openai_sub,