diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index dc36b36b..fccae61f 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -8,6 +8,7 @@ ### Fixed +- Fixed Windows pnpm global install detection to recognize `\\.pnpm\\` store paths, so update notices now suggest `pnpm install -g @mariozechner/pi-coding-agent` instead of falling back to npm ([#3378](https://github.com/badlogic/pi-mono/issues/3378)) - Fixed missing `@sinclair/typebox` runtime dependency in `@mariozechner/pi-coding-agent`, so strict pnpm installs no longer fail with `ERR_MODULE_NOT_FOUND` when starting `pi` ([#3434](https://github.com/badlogic/pi-mono/issues/3434)) - Fixed xterm uppercase typing in the interactive editor by decoding printable `modifyOtherKeys` input and normalizing shifted letter matching, so `Shift+letter` no longer disappears in `pi` ([#3436](https://github.com/badlogic/pi-mono/issues/3436)) - Fixed `/compact` to reuse the session thinking level for compaction summaries instead of forcing `high`, avoiding invalid reasoning-effort errors on `github-copilot/claude-opus-4.7` sessions configured for `medium` thinking ([#3438](https://github.com/badlogic/pi-mono/issues/3438)) diff --git a/packages/coding-agent/src/config.ts b/packages/coding-agent/src/config.ts index cc663d76..eeb510b0 100644 --- a/packages/coding-agent/src/config.ts +++ b/packages/coding-agent/src/config.ts @@ -31,18 +31,18 @@ export function detectInstallMethod(): InstallMethod { return "bun-binary"; } - const resolvedPath = `${__dirname}\0${process.execPath || ""}`.toLowerCase(); + const resolvedPath = `${__dirname}\0${process.execPath || ""}`.toLowerCase().replace(/\\/g, "/"); - if (resolvedPath.includes("/pnpm/") || resolvedPath.includes("/.pnpm/") || resolvedPath.includes("\\pnpm\\")) { + if (resolvedPath.includes("/pnpm/") || resolvedPath.includes("/.pnpm/")) { return "pnpm"; } - if (resolvedPath.includes("/yarn/") || resolvedPath.includes("/.yarn/") || resolvedPath.includes("\\yarn\\")) { + if (resolvedPath.includes("/yarn/") || resolvedPath.includes("/.yarn/")) { return "yarn"; } if (isBunRuntime) { return "bun"; } - if (resolvedPath.includes("/npm/") || resolvedPath.includes("/node_modules/") || resolvedPath.includes("\\npm\\")) { + if (resolvedPath.includes("/npm/") || resolvedPath.includes("/node_modules/")) { return "npm"; } diff --git a/packages/coding-agent/test/config.test.ts b/packages/coding-agent/test/config.test.ts new file mode 100644 index 00000000..bfa04dfc --- /dev/null +++ b/packages/coding-agent/test/config.test.ts @@ -0,0 +1,30 @@ +import { afterEach, describe, expect, test } from "vitest"; +import { detectInstallMethod, getUpdateInstruction } from "../src/config.js"; + +const execPathDescriptor = Object.getOwnPropertyDescriptor(process, "execPath"); + +function setExecPath(value: string): void { + Object.defineProperty(process, "execPath", { + value, + configurable: true, + }); +} + +afterEach(() => { + if (execPathDescriptor) { + Object.defineProperty(process, "execPath", execPathDescriptor); + } +}); + +describe("detectInstallMethod", () => { + test("detects pnpm from Windows .pnpm install paths", () => { + setExecPath( + "C:\\Users\\Admin\\Documents\\pnpm-repository\\global\\5\\.pnpm\\@mariozechner+pi-coding-agent@0.67.68\\node_modules\\@mariozechner\\pi-coding-agent\\dist\\cli.js", + ); + + expect(detectInstallMethod()).toBe("pnpm"); + expect(getUpdateInstruction("@mariozechner/pi-coding-agent")).toBe( + "Run: pnpm install -g @mariozechner/pi-coding-agent", + ); + }); +});