* Best-effort check that the `copilot` binary is reachable on PATH. * A plain fs scan (no shell-out) — cheap enough to run inside * `detectAll()` for the multiselect prompt.
()
| 81 | * `detectAll()` for the multiselect prompt. |
| 82 | */ |
| 83 | function copilotOnPath(): boolean { |
| 84 | const pathVar = process.env.PATH || ''; |
| 85 | const exts = process.platform === 'win32' |
| 86 | ? ['.exe', '.cmd', '.bat', '.ps1'] |
| 87 | : ['']; |
| 88 | for (const dir of pathVar.split(path.delimiter)) { |
| 89 | if (!dir) continue; |
| 90 | for (const ext of exts) { |
| 91 | try { |
| 92 | if (fs.existsSync(path.join(dir, 'copilot' + ext))) return true; |
| 93 | } catch { /* ignore unreadable PATH entries */ } |
| 94 | } |
| 95 | } |
| 96 | return false; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * The shared stdio entry, every tool allowed, and `deferTools: 'never'`: Copilot CLI's tool |