(loc: Location, opts: InstallOptions)
| 94 | } |
| 95 | |
| 96 | install(loc: Location, opts: InstallOptions): WriteResult { |
| 97 | const files: WriteResult['files'] = []; |
| 98 | |
| 99 | // 1. MCP server entry |
| 100 | files.push(writeMcpEntry(loc)); |
| 101 | |
| 102 | // 1b. Migrate away any stale ./.claude.json left by a pre-#207 |
| 103 | // local install, so the project isn't left with two competing |
| 104 | // (one dead) MCP configs. |
| 105 | if (loc === 'local') { |
| 106 | const migrated = cleanupLegacyLocalMcp(); |
| 107 | if (migrated) files.push(migrated); |
| 108 | } |
| 109 | |
| 110 | // 2. Permissions (only when autoAllow) |
| 111 | if (opts.autoAllow) { |
| 112 | files.push(writePermissionsEntry(loc)); |
| 113 | } |
| 114 | |
| 115 | // 2b. Strip stale auto-sync hooks left by a pre-0.8 install. Those |
| 116 | // versions wrote `codegraph mark-dirty` / `sync-if-dirty` hooks to |
| 117 | // settings.json; both subcommands are gone from the CLI, so the |
| 118 | // Stop hook now fails every turn with "unknown command |
| 119 | // 'sync-if-dirty'". Cleaning up on install makes an upgrade |
| 120 | // self-healing. Only surfaced when something was actually removed. |
| 121 | const hookCleanup = cleanupLegacyHooks(loc); |
| 122 | if (hookCleanup.action === 'removed') files.push(hookCleanup); |
| 123 | |
| 124 | // 2c. Front-load prompt hook (Claude UserPromptSubmit). Opt-in via the |
| 125 | // installer prompt (default-yes): `promptHook === true` writes it; |
| 126 | // `=== false` strips any a prior install wrote so opting out round-trips |
| 127 | // (and an upgrade re-run honors the new choice); `undefined` leaves it |
| 128 | // untouched for callers that don't manage it. |
| 129 | if (opts.promptHook === true) { |
| 130 | files.push(writePromptHookEntry(loc)); |
| 131 | } else if (opts.promptHook === false) { |
| 132 | const removed = removePromptHookEntry(loc); |
| 133 | if (removed.action === 'removed') files.push(removed); |
| 134 | } |
| 135 | |
| 136 | // 3. CLAUDE.md instructions — the short marker-fenced CodeGraph |
| 137 | // block (#704). The MCP initialize instructions reach only the main |
| 138 | // agent; CLAUDE.md is what Task-tool subagents (and non-MCP |
| 139 | // harnesses) actually see, so the block carries the codegraph |
| 140 | // pointers there. Upsert self-heals a stale pre-#529 long block. |
| 141 | files.push(upsertInstructionsEntry(instructionsPath(loc))); |
| 142 | |
| 143 | return { files }; |
| 144 | } |
| 145 | |
| 146 | uninstall(loc: Location): WriteResult { |
| 147 | const files: WriteResult['files'] = []; |
nothing calls this directly
no test coverage detected