graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
feat(evals): stress-test in-place plugins and workspace switch
Cursor Agent9baf83e347cd
diff --git a/README.md b/README.mdindex aa85c764..6a799b70 100644--- a/README.md+++ b/README.md@@ -399,6 +399,7 @@ usage:graff key list show which providers have keysgraff mcp add <name> -- <cmd> add an MCP server to .mcp.jsongraff mcp list configured MCP servers+ graff plugins list Cursor/Claude/Grok/Codex plugin trees (in place)graff learn <command> local prompt-policy learning and rollbackgraff --schema print the machine-readable interface (SDK codegen)@@ -579,8 +580,8 @@ project), give it `name` and `description` frontmatter, and write theinstructions in the body. Skills already written for Claude Code, Cursor,Grok, or Codex work as they are: `.claude/skills/`, `~/.cursor/skills-cursor/`,`~/.grok/skills/`, plugin `skills/` trees, and `~/.agents/skills/` are read-in place (not copied). `/plugins` lists the plugin trees. `GRAFF_NO_PLUGINS=1`-skips them.+in place (not copied). `/plugins` and `graff plugins` list the plugin trees.+`GRAFF_NO_PLUGINS=1` skips them.Only the name and description enter the system prompt, so a large skill librarycosts one line each. The model calls the `skill` tool to pull a body in when it@@ -598,8 +599,8 @@ Graff speaks both MCP transports directly: local stdio servers and remoteStreamable HTTP servers. Servers already configured for Claude, Cursor, orGrok are read in place (plugin `mcp.json` / `.mcp.json`, `~/.claude.json`,`~/.cursor/mcp.json`, `.cursor/mcp.json`) and fill names graff does not-already define; they still need `/mcp trust` or `--yolo`. `/plugins` shows-which plugin trees contributed. Smolify (`https://app.smol.ly/mcp`) is available as a+already define; they still need `/mcp trust` or `--yolo`. `/plugins` and+`graff plugins` show which plugin trees contributed. Smolify (`https://app.smol.ly/mcp`) is available as acore documentation service; it needs no Node bridge or project configuration.Its public-read schemas are bundled locally, so startup makes no Smolifyrequest. The anonymous transport initializes only after an approved tool call,diff --git a/docs/adr/0007-plugins-are-read-in-place.md b/docs/adr/0007-plugins-are-read-in-place.mdindex 40f026e8..fe48085f 100644--- a/docs/adr/0007-plugins-are-read-in-place.md+++ b/docs/adr/0007-plugins-are-read-in-place.md@@ -34,8 +34,8 @@ config.(`~/.claude.json`, `~/.cursor/mcp.json`, `.cursor/mcp.json`, …) fill**missing** server names only. graff's `~/.codegraff/mcp.json` and`.mcp.json` still win. Consent is unchanged (`/mcp trust` / `--yolo`).-- `GRAFF_NO_PLUGINS=1` disables the scan. `/plugins` lists origin. Do not- vendor grok-build. Do not auto-run plugin hooks.+- `GRAFF_NO_PLUGINS=1` disables the scan. `/plugins` and `graff plugins`+ list origin. Do not vendor grok-build. Do not auto-run plugin hooks.## Consequencesdiff --git a/evals/harness_behavior.jsonl b/evals/harness_behavior.jsonlindex 5879bd06..97a4d343 100644--- a/evals/harness_behavior.jsonl+++ b/evals/harness_behavior.jsonl@@ -51,3 +51,6 @@{"id": "peer-message-list-names-live-peer", "why": "#563: action=list is ListAgents. With a live peer the tool result must name that they are live, not error, and not require text.", "live_peer": true, "args": [], "prompt": "who else is here", "script": [{"tool": "peer_message", "arguments": {"action": "list"}}, {"text": "saw them"}], "assert": [{"event": {"type": "tool_call", "name": "peer_message"}}, {"request_contains": {"index": 1, "text": "live"}}]}{"id": "peer-message-inbox-empty-when-quiet", "why": "#563: action=inbox is the mailbox. With nothing parked it must say so in the tool result — never invent a body, never require text.", "args": [], "prompt": "check the peer inbox", "script": [{"tool": "peer_message", "arguments": {"action": "inbox"}}, {"text": "nothing waiting"}], "assert": [{"event": {"type": "tool_call", "name": "peer_message"}}, {"request_contains": {"index": 1, "text": "inbox empty"}}]}{"id": "readonly-exact-key-prefers-one-search", "why": "Named-file guidance forced a whole-file read before an exact-key search, adding avoidable context and a provider round trip. A read-only keyed lookup should call read_file once with contains set to the exact key, answer from the numbered match, and never read the entire file.", "args": [], "workspace_seed": {"catalog.py": "SKU0001 = {'price': 100, 'stock': 1}\nSKU0002 = {'price': 200, 'stock': 2}\nSKU0420 = {'price': 31415, 'stock': 27}\nSKU0900 = {'price': 900, 'stock': 9}\n"}, "prompt": "Read catalog.py without editing it. Find SKU0420. Reply with exactly one line in the format SKU0420|price=<price>|stock=<stock> and nothing else.", "script": [{"tool": "read_file", "arguments": {"path": "catalog.py", "contains": "SKU0420"}}, {"text": "SKU0420|price=31415|stock=27"}], "assert": [{"request_contains": {"index": 0, "text": "contains set to the exact key"}}, {"event": {"type": "tool_call", "name": "read_file"}}, {"events_at_most": {"match": {"type": "tool_call"}, "count": 1}}, {"final_text_contains": "SKU0420|price=31415|stock=27"}]}+{"id": "plugin-skill-on-demand", "why": "ADR 0007: a Cursor cache plugin skill must appear in the catalog as (plugin) without its body, and skill name= loads the body. The regression is copying/adopting (body always in the prompt) or never walking plugins/cache/.", "args": [], "workspace_seed": {".cursor/plugins/cache/cursor-public/evalfix/2a8044425c7bddf429c3bdedf3ab61e791d34d65/.cursor-plugin/plugin.json": "{\"name\":\"eval-gmail\"}\n", ".cursor/plugins/cache/cursor-public/evalfix/2a8044425c7bddf429c3bdedf3ab61e791d34d65/skills/plugin-secret/SKILL.md": "---\nname: plugin-secret\ndescription: load before using the plugin secret handshake\n---\n\n# Plugin Secret\n\nPLUGIN_SKILL_BODY_TOKEN_9f3a\n", ".cursor/skills-cursor/env-setup/SKILL.md": "---\nname: env-setup\ndescription: personal skills-cursor playbook that survives GRAFF_NO_PLUGINS\n---\n\n# Env Setup\n\nPERSONAL_SKILL_BODY_TOKEN_c2e1\n"}, "prompt": "list available skills, then load plugin-secret", "script": [{"tool": "load_tool_schemas", "arguments": {"tools": ["skill"]}}, {"tool": "skill", "arguments": {}}, {"tool": "skill", "arguments": {"name": "plugin-secret"}}, {"text": "loaded the plugin secret playbook"}], "assert": [{"request_contains": {"index": 0, "text": "plugin-secret (plugin)"}}, {"request_contains": {"index": 0, "text": "env-setup (personal)"}}, {"request_lacks": {"index": 0, "text": "PLUGIN_SKILL_BODY_TOKEN_9f3a"}}, {"request_lacks": {"index": 0, "text": "PERSONAL_SKILL_BODY_TOKEN_c2e1"}}, {"event": {"type": "tool_call", "name": "skill"}}, {"request_contains": {"index": -1, "text": "PLUGIN_SKILL_BODY_TOKEN_9f3a"}}, {"final_text_contains": "loaded the plugin secret playbook"}]}+{"id": "plugin-off-keeps-personal-skills", "why": "GRAFF_NO_PLUGINS must drop plugin-tree skills while ~/.cursor/skills-cursor stays personal. The regression is treating skills-cursor as a plugin (it vanishes) or ignoring the opt-out (plugin-secret still loads).", "args": [], "env": {"GRAFF_NO_PLUGINS": "1"}, "workspace_seed": {".cursor/plugins/cache/cursor-public/evalfix/2a8044425c7bddf429c3bdedf3ab61e791d34d65/.cursor-plugin/plugin.json": "{\"name\":\"eval-gmail\"}\n", ".cursor/plugins/cache/cursor-public/evalfix/2a8044425c7bddf429c3bdedf3ab61e791d34d65/skills/plugin-secret/SKILL.md": "---\nname: plugin-secret\ndescription: load before using the plugin secret handshake\n---\n\n# Plugin Secret\n\nPLUGIN_SKILL_BODY_TOKEN_9f3a\n", ".cursor/skills-cursor/env-setup/SKILL.md": "---\nname: env-setup\ndescription: personal skills-cursor playbook that survives GRAFF_NO_PLUGINS\n---\n\n# Env Setup\n\nPERSONAL_SKILL_BODY_TOKEN_c2e1\n"}, "prompt": "try to load plugin-secret", "script": [{"tool": "skill", "arguments": {"name": "plugin-secret"}}, {"text": "plugin skill is gone; personal env-setup remains"}], "assert": [{"request_contains": {"index": 0, "text": "env-setup (personal)"}}, {"request_lacks": {"index": 0, "text": "plugin-secret"}}, {"request_lacks": {"index": 0, "text": "PLUGIN_SKILL_BODY_TOKEN_9f3a"}}, {"event": {"type": "tool_call", "name": "skill"}}, {"request_contains": {"index": -1, "text": "no skill named 'plugin-secret'"}}, {"final_text_contains": "plugin skill is gone"}]}+{"id": "workspace-list-use", "why": "ADR 0006: workspace is a folded tool that must list real git worktrees and chdir the session. A skill cannot move file-tool cwd; bash-cd is not enough. Guards load_tool_schemas unfold + use by folder name.", "args": [], "env": {"GRAFF_NO_CODEDB_GUARD": "1"}, "prompt": "create a feature worktree, list workspaces, switch into it", "script": [{"tool": "bash", "arguments": {"command": "git init && git config user.email eval@invalid && git config user.name Eval && echo x > README && git add README && git commit -m init && git worktree add wt-feature -b feature && echo seeded-worktree"}}, {"tool": "load_tool_schemas", "arguments": {"tools": ["workspace"]}}, {"tool": "workspace", "arguments": {"action": "list"}}, {"tool": "workspace", "arguments": {"action": "use", "path": "wt-feature"}}, {"tool": "bash", "arguments": {"command": "basename \"$(pwd)\""}}, {"text": "switched into wt-feature"}], "assert": [{"event": {"type": "tool_call", "name": "load_tool_schemas"}}, {"event": {"type": "tool_call", "name": "workspace"}}, {"request_contains": {"index": -1, "text": "wt-feature"}}, {"request_contains": {"index": -1, "text": "now at"}}, {"final_text_contains": "switched into wt-feature"}]}diff --git a/evals/long_horizon/README.md b/evals/long_horizon/README.mdindex 5702b248..6012759a 100644--- a/evals/long_horizon/README.md+++ b/evals/long_horizon/README.md@@ -168,3 +168,18 @@ mount the generator/grader outside it. The local runner relies on harness pathconfinement and is designed for evaluation convenience, not hostile-codeisolation. Pin the generator and grader commit/hash in every trajectory so anoptimizer cannot silently change its own reward function.++## Related evals (harness surfaces, not coding kernels)++`ledger-batch-v1` does not cover plugin discovery, skill disclosure, or+worktree switch. Those are cheap, offline, and live next to this family:++| Surface | How |+|---|---|+| In-place plugins + MCP merge | `python3 evals/plugins_oob/run.py --self-test` |+| Plugin skill on-demand / opt-out | `python3 scripts/eval-tier2.py --only plugin-skill-on-demand` |+| Mid-session worktree switch | `python3 scripts/eval-tier2.py --only workspace-list-use` |++A second generator family should still be a distinct systems behavior+(scheduler, migrations, protocol adapter) — not a larger ledger, and not a+re-test of the inspect path above.diff --git a/evals/plugins_oob/README.md b/evals/plugins_oob/README.mdnew file mode 100644index 00000000..456d1e41--- /dev/null+++ b/evals/plugins_oob/README.md@@ -0,0 +1,28 @@+# Plugin out-of-box inspect eval++Unit tests in `src/plugins.zig` call `discover` / `mergeMcp` directly. They+cannot tell you whether `graff mcp list` and `graff plugins` see the same+trees a session would, honor `GRAFF_NO_PLUGINS`, or keep graff's own+`~/.codegraff/mcp.json` ahead of a colliding plugin name.++This environment builds a fake `$HOME` with a Cursor cache plugin (manifest+name, not the content-hash folder), a Claude plugin, a personal+`~/.cursor/mcp.json`, and a graff global that overrides a shared server+name. The verifier is the real binary. No provider calls.++```sh+zig build+python3 evals/plugins_oob/run.py --self-test+python3 evals/plugins_oob/test_eval.py+```++What it guards:++- Plugin MCP names appear on `graff mcp list`.+- A graff global wins a shared name (plugin command must not leak).+- `GRAFF_NO_PLUGINS=1` hides plugin and foreign-harness names only.+- `graff plugins` prints the manifest name, not the Cursor cache hash.+- The same opt-out prints `GRAFF_NO_PLUGINS` on `graff plugins`.++MCP fixtures use `command: /bin/false` so a mistaken connect cannot hang on+a remote URL. `--yolo` is not passed; list/inspect never start servers.diff --git a/evals/plugins_oob/run.py b/evals/plugins_oob/run.pynew file mode 100644index 00000000..158f0977--- /dev/null+++ b/evals/plugins_oob/run.py@@ -0,0 +1,199 @@+#!/usr/bin/env python3+"""Drive graff mcp list / graff plugins against a fake HOME (ADR 0007)."""++from __future__ import annotations++import argparse+import json+import os+from pathlib import Path+import subprocess+import sys+import tempfile++ROOT = Path(__file__).resolve().parent+REPO = ROOT.parents[1]+CURSOR_HASH = "2a8044425c7bddf429c3bdedf3ab61e791d34d65"++PLUGIN_ONLY = ("eval-gmail", "eval-claude", "from-cursor")+GRAFF_ONLY = ("from-graff",)+SHARED = "shared"+++def default_graff() -> str:+ return str(REPO / "zig-out" / "bin" / "graff")+++def seed_home(home: Path) -> None:+ plug = home / ".cursor/plugins/cache/cursor-public/evalfix" / CURSOR_HASH+ (plug / ".cursor-plugin").mkdir(parents=True)+ (plug / "skills/plugin-secret").mkdir(parents=True)+ (plug / ".cursor-plugin/plugin.json").write_text(+ '{"name":"eval-gmail","mcpServers":"./mcp.json"}\n', encoding="utf-8"+ )+ (plug / "mcp.json").write_text(+ json.dumps(+ {+ "mcpServers": {+ "eval-gmail": {"command": "/bin/false"},+ SHARED: {"command": "/bin/false", "args": ["plugin-loses"]},+ }+ }+ )+ + "\n",+ encoding="utf-8",+ )+ (plug / "skills/plugin-secret/SKILL.md").write_text(+ "---\nname: plugin-secret\ndescription: fixture playbook\n---\n\nbody\n",+ encoding="utf-8",+ )++ claude = home / ".claude/plugins/demo"+ (claude / ".claude-plugin").mkdir(parents=True)+ (claude / ".claude-plugin/plugin.json").write_text(+ '{"name":"eval-claude"}\n', encoding="utf-8"+ )+ (claude / ".mcp.json").write_text(+ json.dumps({"mcpServers": {"eval-claude": {"command": "/bin/false"}}}) + "\n",+ encoding="utf-8",+ )++ (home / ".cursor").mkdir(parents=True, exist_ok=True)+ (home / ".cursor/mcp.json").write_text(+ json.dumps({"mcpServers": {"from-cursor": {"command": "/bin/false"}}}) + "\n",+ encoding="utf-8",+ )++ (home / ".codegraff").mkdir(parents=True, exist_ok=True)+ (home / ".codegraff/mcp.json").write_text(+ json.dumps(+ {+ "mcpServers": {+ SHARED: {"command": "/bin/true", "args": ["graff-wins"]},+ "from-graff": {"command": "/bin/true"},+ }+ }+ )+ + "\n",+ encoding="utf-8",+ )+++def graff_env(home: Path, extra: dict[str, str] | None = None) -> dict[str, str]:+ env = {+ key: value+ for key, value in os.environ.items()+ if not key.endswith("_API_KEY") and key != "GRAFF_MCP_CONFIG"+ }+ env.update(+ {+ "HOME": str(home),+ "GRAFF_NO_TELEMETRY": "1",+ "GRAFF_NO_SMOLIFY": "1",+ "NO_COLOR": "1",+ }+ )+ if extra:+ env.update(extra)+ return env+++def run_graff(+ graff: str, args: list[str], home: Path, cwd: Path, extra: dict[str, str] | None = None+) -> subprocess.CompletedProcess[str]:+ return subprocess.run(+ [graff, *args],+ cwd=cwd,+ env=graff_env(home, extra),+ text=True,+ capture_output=True,+ timeout=20,+ )+++def expect_ok(done: subprocess.CompletedProcess[str], label: str) -> str:+ if done.returncode != 0:+ raise SystemExit(+ f"{label} exited {done.returncode}\nstdout:\n{done.stdout}\nstderr:\n{done.stderr}"+ )+ return done.stdout+++def assert_mcp_merged(text: str) -> None:+ for name in PLUGIN_ONLY + GRAFF_ONLY + (SHARED,):+ if f"{name}:" not in text:+ raise SystemExit(f"mcp list missing {name!r}:\n{text}")+ if "plugin-loses" in text:+ raise SystemExit(f"plugin command leaked onto shared:\n{text}")+ if "graff-wins" not in text:+ raise SystemExit(f"graff global lost the shared name:\n{text}")+++def assert_mcp_opt_out(text: str) -> None:+ for name in PLUGIN_ONLY:+ if f"{name}:" in text:+ raise SystemExit(f"GRAFF_NO_PLUGINS still listed {name!r}:\n{text}")+ for name in GRAFF_ONLY + (SHARED,):+ if f"{name}:" not in text:+ raise SystemExit(f"opt-out hid graff's own {name!r}:\n{text}")+ if "plugin-loses" in text:+ raise SystemExit(f"opt-out still leaked the plugin command:\n{text}")+++def assert_plugins_named(text: str) -> None:+ if "eval-gmail" not in text:+ raise SystemExit(f"graff plugins missed the Cursor manifest name:\n{text}")+ if CURSOR_HASH in text.split("eval-gmail", 1)[0]:+ raise SystemExit(f"listing used the cache hash as the name:\n{text}")+ if "eval-claude" not in text:+ raise SystemExit(f"graff plugins missed the Claude plugin:\n{text}")+ if "[cursor/user]" not in text or "[claude/user]" not in text:+ raise SystemExit(f"origin tags missing:\n{text}")+++def self_test(graff: str) -> None:+ if not Path(graff).exists():+ raise SystemExit(f"{graff} does not exist — run `zig build` first")+ with tempfile.TemporaryDirectory(prefix="graff-plugins-oob-") as raw:+ base = Path(raw)+ home = base / "home"+ cwd = base / "cwd"+ cwd.mkdir()+ seed_home(home)++ merged = expect_ok(run_graff(graff, ["mcp", "list"], home, cwd), "graff mcp list")+ assert_mcp_merged(merged)++ opted = expect_ok(+ run_graff(graff, ["mcp", "list"], home, cwd, {"GRAFF_NO_PLUGINS": "1"}),+ "graff mcp list (GRAFF_NO_PLUGINS)",+ )+ assert_mcp_opt_out(opted)++ listed = expect_ok(run_graff(graff, ["plugins"], home, cwd), "graff plugins")+ assert_plugins_named(listed)++ disabled = expect_ok(+ run_graff(graff, ["plugins"], home, cwd, {"GRAFF_NO_PLUGINS": "1"}),+ "graff plugins (GRAFF_NO_PLUGINS)",+ )+ if "GRAFF_NO_PLUGINS" not in disabled:+ raise SystemExit(f"opt-out plugins listing was not explicit:\n{disabled}")+ if "eval-gmail" in disabled:+ raise SystemExit(f"opt-out plugins listing still named a plugin:\n{disabled}")++ print("self-test ok: mcp list merges, graff wins shared names, GRAFF_NO_PLUGINS hides plugin/foreign only")+++def main() -> None:+ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument("--graff", default=default_graff())+ parser.add_argument("--self-test", action="store_true")+ args = parser.parse_args()+ if not args.self_test:+ parser.error("this eval is inspect-only; pass --self-test")+ self_test(args.graff)+++if __name__ == "__main__":+ main()diff --git a/evals/plugins_oob/test_eval.py b/evals/plugins_oob/test_eval.pynew file mode 100644index 00000000..d3160473--- /dev/null+++ b/evals/plugins_oob/test_eval.py@@ -0,0 +1,73 @@+#!/usr/bin/env python3+"""Unittest wrapper so the plugin inspect eval is a normal `python3 -m unittest`."""++from __future__ import annotations++import os+import tempfile+import unittest+from pathlib import Path++from run import (+ CURSOR_HASH,+ assert_mcp_merged,+ assert_mcp_opt_out,+ assert_plugins_named,+ default_graff,+ seed_home,+ self_test,+)+++class PluginOobTests(unittest.TestCase):+ @classmethod+ def setUpClass(cls) -> None:+ cls.graff = os.environ.get("GRAFF", default_graff())+ if not Path(cls.graff).exists():+ raise unittest.SkipTest(f"{cls.graff} missing — run `zig build`")++ def test_self_test_passes(self) -> None:+ self_test(self.graff)++ def test_seeded_home_is_enough_without_the_binary(self) -> None:+ with tempfile.TemporaryDirectory() as raw:+ home = Path(raw)+ seed_home(home)+ self.assertTrue(+ (home / ".cursor/plugins/cache/cursor-public/evalfix" / CURSOR_HASH / ".cursor-plugin/plugin.json").is_file()+ )+ self.assertIn("eval-gmail", (home / ".cursor/plugins/cache/cursor-public/evalfix" / CURSOR_HASH / ".cursor-plugin/plugin.json").read_text())+ self.assertIn("graff-wins", (home / ".codegraff/mcp.json").read_text())++ def test_assertions_reject_the_wrong_listing(self) -> None:+ good = (+ "5 MCP server(s):\n"+ " eval-gmail: /bin/false\n"+ " eval-claude: /bin/false\n"+ " from-cursor: /bin/false\n"+ " from-graff: /bin/true (global)\n"+ " shared: /bin/true graff-wins (global)\n"+ )+ assert_mcp_merged(good)+ with self.assertRaises(SystemExit):+ assert_mcp_merged(good.replace("graff-wins", "plugin-loses"))+ opted = (+ "2 MCP server(s):\n"+ " from-graff: /bin/true (global)\n"+ " shared: /bin/true graff-wins (global)\n"+ )+ assert_mcp_opt_out(opted)+ with self.assertRaises(SystemExit):+ assert_mcp_opt_out(good)+ plugins = (+ "2 plugin(s) (in-place, not copied):\n"+ f" eval-gmail [cursor/user] skills mcp /home/{CURSOR_HASH}\n"+ " eval-claude [claude/user] mcp /home/demo\n"+ )+ assert_plugins_named(plugins)+ with self.assertRaises(SystemExit):+ assert_plugins_named(f"{CURSOR_HASH} [cursor/user] mcp\n")+++if __name__ == "__main__":+ unittest.main()diff --git a/src/cli.zig b/src/cli.zigindex b6cf189d..8d7f31e0 100644--- a/src/cli.zig+++ b/src/cli.zig@@ -158,6 +158,7 @@ pub const usage_text =\\ graff mcp add <name> --url <url> add a Streamable HTTP MCP server\\ graff mcp login <name> OAuth login for a remote MCP server\\ graff mcp list configured MCP servers+ \\ graff plugins list Cursor/Claude/Grok/Codex plugin trees (in place)\\ graff learn [help] local mutate/evaluate/promote/rollback engine\\ graff worktree list list the per-tab worktrees created by -w\\ graff worktree merge <name> squash-land worktree-<name> onto the current branch + clean updiff --git a/src/plugins.zig b/src/plugins.zigindex 736e223e..1bfef185 100644--- a/src/plugins.zig+++ b/src/plugins.zig@@ -280,6 +280,13 @@ pub fn slashCommand(io: Io, arena: Allocator, home: []const u8, line: []const u8return true;}+/// `graff plugins` — same listing as `/plugins`, without starting a session.+pub fn command(io: Io, arena: Allocator, home: []const u8) !void {+ var obuf: [4096]u8 = undefined;+ var out = Io.File.stdout().writer(io, &obuf);+ _ = try slashCommand(io, arena, home, "/plugins", &out.interface);+}+const testing = std.testing;fn tmpBase(io: Io, tmp: *testing.TmpDir, arena: Allocator) ![]const u8 {@@ -402,6 +409,37 @@ test "slashCommand: /plugins lists origin and refuses unrelated lines" {try testing.expect(std.mem.indexOf(u8, aw.writer.buffered(), "plugin") != null);}+test "applyEnv: GRAFF_NO_PLUGINS disables discover and /plugins" {+ const saved = disabled;+ defer disabled = saved;+ disabled = false;+ const Env = struct {+ pub fn get(_: @This(), key: []const u8) ?[]const u8 {+ return if (std.mem.eql(u8, key, "GRAFF_NO_PLUGINS")) "1" else null;+ }+ };+ applyEnv(Env{});+ try testing.expect(disabled);++ var tmp = testing.tmpDir(.{});+ defer tmp.cleanup();+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);+ defer arena_state.deinit();+ const arena = arena_state.allocator();+ const io = testing.io;+ const base = try tmpBase(io, &tmp, arena);+ const home = join(arena, base, "home");+ const plug = join(arena, home, ".claude/plugins/hidden");+ try Io.Dir.cwd().createDirPath(io, join(arena, plug, ".claude-plugin"));+ try Io.Dir.cwd().writeFile(io, .{ .sub_path = join(arena, plug, ".claude-plugin/plugin.json"), .data = "{\"name\":\"hidden\"}" });+ try testing.expectEqual(@as(usize, 0), discover(io, arena, home, tmp.dir).len);++ var aw: Io.Writer.Allocating = .init(testing.allocator);+ defer aw.deinit();+ try testing.expect(try slashCommand(io, arena, home, "/plugins", &aw.writer));+ try testing.expect(std.mem.indexOf(u8, aw.writer.buffered(), "GRAFF_NO_PLUGINS") != null);+}+test "discover: Cursor cache uses .cursor-plugin + mcp.json; name from manifest" {var tmp = testing.tmpDir(.{});defer tmp.cleanup();diff --git a/src/startup.zig b/src/startup.zigindex f0a0fda5..cefcac56 100644--- a/src/startup.zig+++ b/src/startup.zig@@ -46,6 +46,7 @@ const learn_bootstrap = @import("learn_bootstrap.zig");const learn_auto = @import("learn_auto.zig");const imagegen = @import("imagegen.zig"); // #352: codex-skill detection + the personal-tier skill mirror+const plugins = @import("plugins.zig");const startup_keys = @import("startup_keys.zig");pub const ResolvedKeys = startup_keys.ResolvedKeys;pub const storedKeyMayAffectSelection = startup_keys.storedKeyMayAffectSelection;@@ -218,10 +219,20 @@ pub fn runSubcommand(io: Io, gpa: Allocator, arena: Allocator, init: std.process// override); add still writes workspace-only. OAuth login validates HOME itself.if (flags.positionals.items.len > 0 and std.mem.eql(u8, flags.positionals.items[0], "mcp")) {const home = keys_cli.homeEnv(init.environ_map) orelse "";+ // CLI never reaches session_settings.applyEnvKnobs; honor the same+ // GRAFF_NO_PLUGINS gate the REPL / --json session uses.+ plugins.applyEnv(init.environ_map);try mcp_cli.mcpCommand(io, gpa, arena, home, init.environ_map, flags.positionals.items[1..]);return true;}+ if (flags.positionals.items.len > 0 and std.mem.eql(u8, flags.positionals.items[0], "plugins")) {+ const home = keys_cli.homeEnv(init.environ_map) orelse "";+ plugins.applyEnv(init.environ_map);+ try plugins.command(io, arena, home);+ return true;+ }+// `graff learn ...`: local immutable policy learning. It runs before key// resolution and normal session construction; configured child tools get// only their explicitly allowlisted environment.