Make graft init --dry-run honor --no-global, --no-mcp and --no-hooks - #333
Make graft init --dry-run honor --no-global, --no-mcp and --no-hooks#333L4XB wants to merge 1 commit into
graft init --dry-run honor --no-global, --no-mcp and --no-hooks#333Conversation
The dry-run plan was built without the suppression flags, so `graft init --dry-run --no-global --no-mcp --no-hooks` printed the same planned writes as a plain dry-run, including the ~/.codex config and hooks that the real writer skips. That made --dry-run unusable as a preflight for those flags although its help text promises to print every file init would touch. planInit() now applies the same predicates runHostsInit() uses: --no-mcp drops the MCP registrations, --no-hooks the Codex and Cursor hooks, --no-global everything outside the repo (the ~/.claude copy, global MCP configs, Codex hooks, Antigravity skill; Cursor's repo-local hooks stay). The CLI passes the flags through for the parent and every workspace child. The "skipped out-of-repo writes" notice still fires by checking the unsuppressed plan. Refs trailhq#329 (the retraction / wiring-stamp / graph-build side effects are still not part of the plan)
🌱 graft blast radiusNothing outside this diff depends on it. 2 areas changed; no indexed dependents at depth 2. Who knows this code — 3 people across 2 areas
Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no Test signal per changed area — 1 ✓ · 1 ✗Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.
2 test suites also reference this code4 symbols, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.
Open the interactive graph → — click an area to see its dependent symbols at file:line. |
Refs #329 — this covers the first half of that report (the suppression flags); the second half (retraction, wiring stamp and graph-build side effects in the plan) is not addressed here.
Problem
src/cli.tsbuilt the dry-run plan withplanInit(repo, { home }), sograft init --dry-run --no-global --no-mcp --no-hooksprinted exactly the same planned writes as a plain--dry-run, including~/.codex/config.toml, the Codex hook shim/hooks.jsonandopencode.json, all of whichrunHostsInit()skips for those flags. The help text says--dry-runprints every file init would touch, so the plan was wrong as a preflight for the flags.Change
planInit()takesmcp,hooksandglobaland applies the same predicates asrunHostsInit():--no-mcp: no MCP registrations for the non-Claude hosts;--no-hooks: no Codex hooks and no Cursor hooks;--no-global: nothing outside the repo — the~/.claudecopy, the global MCP configs (Codex, Antigravity), the Codex hooks and the Antigravity skill are dropped; Cursor's hooks are repo-local and stay, as in the writer.planInitfor the parent repo and for every workspace child.· skipped out-of-repo writes (--no-global)notice still fires: it now asks the unsuppressed plan whether there was anything out-of-repo to skip (the existingCLI: --no-global writes AGENTS.md but leaves ~/.codex alonetest covers that).Tests
test/hosts-plan.test.ts: new case checking each flag against the plan (default plan lists the~/.codexwrites and Cursor hooks;--no-mcpdrops MCP configs;--no-hooksdrops Codex and Cursor hooks;--no-globalleaves noscope: 'global'write and nothing under~while keeping Cursor's repo-local hooks; all three together leave theagentshost with onlyAGENTS.md). Fails onmain, passes with the change.node --import tsx --test test/hosts-plan.test.ts test/hosts-init.test.ts test/claude-init.test.ts test/claude-init-workspace.test.ts: 54 pass.tsc --noEmitclean.