A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.
TypeScript
fix(daemon): keep the bundled folder once in a Windows PATH
Marcelito4e8562b2bbcd
diff --git a/packages/daemon/src/isolation.ts b/packages/daemon/src/isolation.tsindex 1e87a1f..7bac47d 100644--- a/packages/daemon/src/isolation.ts+++ b/packages/daemon/src/isolation.ts@@ -186,8 +186,14 @@ export function isolatedAgentEnv(}const bin = bundledBinDir(base, options);if (bin) {- const separator = platform === "win32" ? ";" : delimiter;- const rest = (path ?? "").split(separator).filter((part) => part && part !== bin);+ const windows = platform === "win32";+ const separator = windows ? ";" : delimiter;+ // Windows paths ignore case and a trailing separator, so the bundled folder is not kept twice.+ const same = (part: string) =>+ windows+ ? part.replace(/[\\/]+$/, "").toLowerCase() === bin.replace(/[\\/]+$/, "").toLowerCase()+ : part === bin;+ const rest = (path ?? "").split(separator).filter((part) => part && !same(part));env.PATH = [bin, ...rest].join(separator);}// The user's own Gentle Shell setting is not the assistant's.diff --git a/packages/daemon/test/isolation.test.ts b/packages/daemon/test/isolation.test.tsindex 5880d3b..f217809 100644--- a/packages/daemon/test/isolation.test.ts+++ b/packages/daemon/test/isolation.test.ts@@ -94,6 +94,18 @@ describe("isolatedAgentEnv PATH", () => {expect(env.PATH).toBe([bin, "C:\\Windows\\System32", "C:\\Git\\cmd"].join(";"));});+ it("does not add the bundled folder twice on Windows, whatever its case or trailing separator", () => {+ const bin = tempDir();+ writeFileSync(join(bin, "pi.cmd"), "");+ const env = isolatedAgentEnv(+ { Path: `C:\\Windows\\System32;${bin.toUpperCase()}\\;${bin}/`, HOME: tempDir() },+ tempDir(),+ undefined,+ { platform: "win32", sourceBinDirs: [bin] },+ );+ expect(env.PATH).toBe([bin, "C:\\Windows\\System32"].join(";"));+ });+it("does not add the bundled folder twice", () => {const once = isolatedAgentEnv({ PATH: "/bin", HOME: tempDir() }, tempDir());const twice = isolatedAgentEnv({ PATH: once.PATH, HOME: tempDir() }, tempDir());