MCPcopy Create free account
hub / github.com/cortexkit/magic-context / detectPiBinary

Function detectPiBinary

packages/cli/src/lib/pi-helpers.ts:14–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12export const PI_PACKAGE_SOURCE = "npm:@cortexkit/pi-magic-context";
13
14export 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
31export function getPiVersion(piPath: string): string | null {
32 // Pi >= 0.71.x writes `--version` output to stderr, not stdout. Use

Callers 3

collectDiagnosticsFunction · 0.90
isInstalledMethod · 0.90

Calls 1

findOnPathFunction · 0.90

Tested by

no test coverage detected