graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
feat(lean): drop dead -p catalog tools and leftover essays
Cursor Agent2dac0075cdf2
diff --git a/src/no_local_tools.zig b/src/no_local_tools.zigindex f7445e89..012d5430 100644--- a/src/no_local_tools.zig+++ b/src/no_local_tools.zig@@ -76,22 +76,17 @@ pub fn blocks(name: []const u8) bool {/// hallucinated call fails like any bad tool name.pub var lean: bool = false;-/// The lean keep-list. `subagent` stays despite being the priciest schema-/// (5.1k bytes): unattended non-yolo still needs a sanctioned delegation-/// path (`prompts.unattended_note` — that note is the approval-denied-/// fact, not this catalog), and yolo/`-p` still needs fan-out for-/// independent work. Dropping it would strand the first case. The compact-/// desc must not claim root is always approval-denied: evals and `-p`-/// run `--yolo`, so that claim was a token/call tax (ADR 0024).-/// `load_tool_schemas` stays because lean folds MCP behind that meta tool-/// (mcp_schema_gate.deferAllRuntime) instead of skipping it.+/// The lean keep-list. `subagent` stays in the list (unattended !yolo+/// still delegates; catalogSkips folds it off the wire until loaded).+/// `load_tool_schemas` stays so a connected MCP server can unfold; it+/// is hidden on lean when nothing is deferred (schema.zig). Overflow+/// paging (`read_tool_result`) is interactive — drop it from -p.pub const lean_tools = [_][]const u8{"bash","read_file","edit_file","write_file","codedb",- "read_tool_result","subagent","attempt_completion","load_tool_schemas",@@ -235,10 +230,10 @@ test "lean: the filter keeps exactly the seven one-shot tools, and allocates nottry std.testing.expectEqualStrings("read_file", kept[1].name);try std.testing.expectEqualStrings("subagent", kept[2].name);try std.testing.expectEqualStrings("attempt_completion", kept[3].name);- // The keep-list is exactly the nine documented tools — subagent stays- // (unattended-non-yolo delegation + independent fan-out), load_tool_schemas- // stays (lean folds MCP behind it), everything orchestration/meta goes.- try std.testing.expectEqual(@as(usize, 9), lean_tools.len);+ // Keep-list is eight names: subagent stays (unattended !yolo), load_tool_schemas+ // stays (MCP unfold). Overflow pager is gone. Render may hide both.+ try std.testing.expectEqual(@as(usize, 8), lean_tools.len);+ try std.testing.expect(!leanKeeps("read_tool_result"));for (lean_tools) |tool| try std.testing.expect(leanKeeps(tool));try std.testing.expect(!leanKeeps("workflow"));try std.testing.expect(!leanKeeps("todo_write"));@@ -388,4 +383,22 @@ test "lean prompt diet: no fan-out / trace / issue-filing; short local-tools nottry std.testing.expect(std.mem.indexOf(u8, out, "not covered by /rewind") == null);try std.testing.expect(std.mem.indexOf(u8, out, "list_dir") != null);try std.testing.expect(std.mem.indexOf(u8, out, "SPEC.md") != null);+ try std.testing.expect(std.mem.indexOf(u8, out, "discard work") == null);+ try std.testing.expect(std.mem.indexOf(u8, out, "Fix root causes") == null);+ try std.testing.expect(std.mem.indexOf(u8, out, "Co-Authored-By") == null);+}++test "lean catalog drops overflow pager and empty load_tool_schemas" {+ const schema = @import("schema.zig");+ const saved = lean;+ defer lean = saved;+ lean = true;+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const arena = arena_state.allocator();+ const specs = try schema.effectiveRootSpecs(arena);+ const json = try schema.renderRootTools(arena, .openai, specs, &.{});+ try std.testing.expect(std.mem.indexOf(u8, json, "read_tool_result") == null);+ try std.testing.expect(std.mem.indexOf(u8, json, "load_tool_schemas") == null);+ try std.testing.expect(std.mem.indexOf(u8, json, "\"rlm\"") != null);}diff --git a/src/prompt_text.zig b/src/prompt_text.zigindex ec81e07c..293fdfb2 100644--- a/src/prompt_text.zig+++ b/src/prompt_text.zig@@ -267,11 +267,39 @@ pub const lean_local_tools_note =\\span, smallest edit, do not verify after success.;-/// --lean composition: drop harness-debug / narration; swap the long-/// local-tools essay. `null` means skip the segment entirely.+pub const lean_intro_note =+ \\You are a coding agent. Use only the tools in this session's catalog —+ \\never invent a tool or a wrapper. Inspect, then do the work.+;++pub const lean_work_note =+ \\+ \\Assume the user wants the work done. Verify with the project's own+ \\tests in its OWN environment. Use named files and tests directly.+ \\Do not add unrequested tests. Never repeat a tool call with identical+ \\parameters. When a named SPEC.md is in the task, satisfy every clause+ \\— a green public test is not the whole spec. Empty input includes+ \\whitespace-only: yield nothing, do not raise. A required record+ \\delimiter applies to records that exist; a payload with no records+ \\is empty, not malformed.+;++pub const lean_closing_note =+ \\+ \\Write the final message as a short teammate update. Cite path:line.+ \\Be direct and concise.+;++/// --lean composition: drop harness-debug / narration / git-safety; swap+/// the long intro/work/closing essays. `null` means skip the segment.pub fn leanSegment(name: []const u8, original: []const u8, is_lean: bool) ?[]const u8 {if (!is_lean) return original;- if (std.mem.eql(u8, name, "trace") or std.mem.eql(u8, name, "harness_issue") or std.mem.eql(u8, name, "headsup")) return null;+ if (std.mem.eql(u8, name, "trace") or std.mem.eql(u8, name, "harness_issue") or+ std.mem.eql(u8, name, "headsup") or std.mem.eql(u8, name, "git_safety") or+ std.mem.eql(u8, name, "root_cause")) return null;+ if (std.mem.eql(u8, name, "intro")) return lean_intro_note;if (std.mem.eql(u8, name, "local_tools")) return lean_local_tools_note;+ if (std.mem.eql(u8, name, "work")) return lean_work_note;+ if (std.mem.eql(u8, name, "closing")) return lean_closing_note;return original;}diff --git a/src/prompts.zig b/src/prompts.zigindex 2bd5ed48..0ffae75e 100644--- a/src/prompts.zig+++ b/src/prompts.zig@@ -143,7 +143,7 @@ pub fn detectCaps() Caps {.subagents = toolAdvertised("subagent") and !no_local_tools.lean, // lean: no fan-out essay.todos = toolAdvertised("todo_write") and !no_local_tools.lean,.constraints = toolAdvertised("note_constraint") and !no_local_tools.lean,- .git_repo = g_git_repo,+ .git_repo = g_git_repo and !no_local_tools.lean, // -p: no commit/PR essay};}diff --git a/src/rlm.zig b/src/rlm.zigindex 4f203098..4ea249f1 100644--- a/src/rlm.zig+++ b/src/rlm.zig@@ -22,6 +22,9 @@ const rlm_spec = @import("rlm_spec.zig");pub const tool_name = "rlm";pub const tool_desc = "Programmatic tool calling (RLM + sPTC). Script whose functions ARE this session's tools. Independent literal read_file/codedb/bash/webfetch/sleep_ms/llm_query/subagent calls start as the script streams. Binds persist across rlm calls. subagent(\"task\") is sidecar-only (keep the critical-path next step local; sync in v1; run_in_background=true returns an id). print() is the answer. Example: a = read_file(\"src/main.zig\"); b = codedb(\"status\"); print(a, b). No imports, no control flow. Prefer one rlm over N tool calls.";+/// --lean catalog desc: same contract, no REPL essay. maybeAppend is after+/// compactLeanSpecs, so this is the one-shot wire text.+pub const lean_tool_desc = "Script of this session's tools. Literal read_file/codedb/bash/llm_query start as it streams. Binds persist. print(...) is the answer. Prefer one rlm over N tool calls.";pub const tool_schema =\\{"type": "object", "properties": {"code": {"type": "string", "description": "Python-like script: name = read_file(\"path\") / codedb(\"command\") / bash(\"cmd\") / sleep_ms(ms) / llm_query(\"prompt\") / subagent(\"task\"); print(...) is the result. Assignments persist across rlm calls. Semicolons or newlines separate statements."}}, "required": ["code"]};@@ -67,7 +70,7 @@ pub fn maybeAppend(comptime Spec: type, arena: Allocator, specs: []const Spec) !for (specs) |s| if (std.mem.eql(u8, s.name, tool_name)) return specs;const buf = try arena.alloc(Spec, specs.len + 1);@memcpy(buf[0..specs.len], specs);- buf[specs.len] = .{ .name = tool_name, .desc = tool_desc, .schema = tool_schema };+ buf[specs.len] = .{ .name = tool_name, .desc = if (no_local_tools.lean) lean_tool_desc else tool_desc, .schema = tool_schema };return buf;}diff --git a/src/schema.zig b/src/schema.zigindex 8a520161..963c16fb 100644--- a/src/schema.zig+++ b/src/schema.zig@@ -298,7 +298,7 @@ pub fn renderRootTools(var s: std.json.Stringify = .{ .writer = &aw.writer };try s.beginArray();for (specs) |t| {- if (mcp_schema_gate.hiddenSpec(t.name, mcp_tools) and !native_fold.anyFolded()) continue; // #416: load_tool_schemas hides only with nothing deferred OR folded+ if (mcp_schema_gate.hiddenSpec(t.name, mcp_tools) and (!native_fold.anyFolded() or no_local_tools.lean)) continue; // lean: no empty load_tool_schemasif (native_fold.catalogSkips(t.name)) continue; // zero-stub like the MCP half: folded natives ride the meta tool's listing (#476)if (std.mem.eql(u8, t.name, mcp_schema_gate.tool_name))try writeToolEntry(&s, kind, t.name, try mcp_schema_gate.descWithListing(out, mcp_tools), .{ .raw = t.schema })diff --git a/src/startup.zig b/src/startup.zigindex da98cabe..211a0dcd 100644--- a/src/startup.zig+++ b/src/startup.zig@@ -126,7 +126,8 @@ pub fn buildSystemPrompt(if (@import("repo_map.zig").segment(io, arena)) |map| sys_normal = try std.fmt.allocPrint(arena, "{s}{s}", .{ sys_normal, map });}if (unattended) sys_normal = try std.fmt.allocPrint(arena, "{s}{s}", .{ sys_normal, prompts.unattended_note });- if (@import("rlm_spec.zig").available)+ // Lean already puts rlm on the catalog; the system_note is duplicate prefix.+ if (@import("rlm_spec.zig").available and !@import("no_local_tools.zig").lean)sys_normal = try std.fmt.allocPrint(arena, "{s}{s}", .{ sys_normal, @import("rlm_spec.zig").system_note });// Codex-style skills: one capability line per installed optional// companion (skills_registry) — metadata in context, --help on demand.