* Resolve the on-disk path of the `codegraph` binary so a Mac GUI app * launched from Dock/Finder (with a stripped PATH) can find it. Falls * back to the bare `codegraph` name when: * * - we're not on macOS (Linux GUI apps inherit user PATH; Windows * uses env PATH directly), OR * - the l
()
| 118 | * nvm-managed tools like ours. |
| 119 | */ |
| 120 | function resolveCodegraphCommand(): string { |
| 121 | if (process.platform !== 'darwin') return 'codegraph'; |
| 122 | try { |
| 123 | const resolved = execSync('command -v codegraph || which codegraph', { |
| 124 | encoding: 'utf-8', |
| 125 | stdio: ['ignore', 'pipe', 'ignore'], |
| 126 | shell: '/bin/bash', |
| 127 | windowsHide: true, |
| 128 | }).trim(); |
| 129 | if (resolved && fs.existsSync(resolved)) { |
| 130 | // fnm resolves `codegraph` inside an ephemeral per-shell symlink dir |
| 131 | // (~/.local/state/fnm_multishells/<pid>/bin) that fnm removes when the |
| 132 | // installing shell exits, leaving a dangling command in the GUI app's |
| 133 | // MCP config. Canonicalize the containing directory so the path outlives |
| 134 | // the shell, while preserving the `codegraph` binary name (agents that |
| 135 | // validate the command by basename still match). |
| 136 | try { |
| 137 | return path.join(fs.realpathSync(path.dirname(resolved)), path.basename(resolved)); |
| 138 | } catch { |
| 139 | return resolved; |
| 140 | } |
| 141 | } |
| 142 | } catch { |
| 143 | /* fall through to bare name */ |
| 144 | } |
| 145 | return 'codegraph'; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Build the codegraph MCP-server entry for Antigravity. Distinct from |
no test coverage detected