()
| 12 | export const PI_PACKAGE_SOURCE = "npm:@cortexkit/pi-magic-context"; |
| 13 | |
| 14 | export function detectPiBinary(): PiBinaryInfo | null { |
| 15 | // Node-only PATH walker, not which/where: shelling out fails in |
| 16 | // Alpine/slim/Nix/bunx sandboxes that lack those binaries (same reason the |
| 17 | // OpenCode detector switched to findOnPath). findOnPath handles platform |
| 18 | // extensions (.cmd/.exe) and X_OK checks internally. |
| 19 | const fromPath = findOnPath("pi"); |
| 20 | if (fromPath) return { path: fromPath, source: "path" }; |
| 21 | |
| 22 | const homeCandidate = |
| 23 | process.platform === "win32" |
| 24 | ? join(homedir(), ".pi", "bin", "pi.cmd") |
| 25 | : join(homedir(), ".pi", "bin", "pi"); |
| 26 | if (existsSync(homeCandidate)) return { path: homeCandidate, source: "home" }; |
| 27 | |
| 28 | return null; |
| 29 | } |
| 30 | |
| 31 | export function getPiVersion(piPath: string): string | null { |
| 32 | // Pi >= 0.71.x writes `--version` output to stderr, not stdout. Use |
no test coverage detected