From be8ae56abe5bb49357177e577fd801be80f6d477 Mon Sep 17 00:00:00 2001 From: Charles Packer Date: Tue, 3 Feb 2026 16:08:45 -0800 Subject: [PATCH] fix(cli): restore PATH handling on Windows and fix PowerShell quoting (#785) Co-Authored-By: Aaron Matthis Co-Authored-By: Letta --- src/tools/impl/shellEnv.ts | 7 +++++-- src/tools/impl/shellLaunchers.ts | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/tools/impl/shellEnv.ts b/src/tools/impl/shellEnv.ts index ccefa81..76497e1 100644 --- a/src/tools/impl/shellEnv.ts +++ b/src/tools/impl/shellEnv.ts @@ -54,8 +54,11 @@ export function getShellEnv(): NodeJS.ProcessEnv { // Add ripgrep bin directory to PATH if available const rgBinDir = getRipgrepBinDir(); if (rgBinDir) { - const currentPath = env.PATH || ""; - env.PATH = `${rgBinDir}${path.delimiter}${currentPath}`; + // Windows uses "Path" (not "PATH"), and env vars are case-insensitive there. + // Find the actual key to avoid clobbering the user's PATH. + const pathKey = + Object.keys(env).find((k) => k.toUpperCase() === "PATH") || "PATH"; + env[pathKey] = `${rgBinDir}${path.delimiter}${env[pathKey] || ""}`; } // Add Letta context for skill scripts diff --git a/src/tools/impl/shellLaunchers.ts b/src/tools/impl/shellLaunchers.ts index a1ca2fc..d5d1706 100644 --- a/src/tools/impl/shellLaunchers.ts +++ b/src/tools/impl/shellLaunchers.ts @@ -17,6 +17,14 @@ function windowsLaunchers(command: string): string[][] { if (!trimmed) return []; const launchers: string[][] = []; const seen = new Set(); + const powerShellCommand = + trimmed.startsWith("&") || + trimmed.startsWith('"') || + trimmed.startsWith("'") + ? trimmed.startsWith("&") + ? trimmed + : `& ${trimmed}` + : trimmed; // Default to PowerShell on Windows (same as Gemini CLI and Codex CLI) // This ensures better PATH compatibility since many tools are configured @@ -25,9 +33,14 @@ function windowsLaunchers(command: string): string[][] { "powershell.exe", "-NoProfile", "-Command", - trimmed, + powerShellCommand, + ]); + pushUnique(launchers, seen, [ + "pwsh", + "-NoProfile", + "-Command", + powerShellCommand, ]); - pushUnique(launchers, seen, ["pwsh", "-NoProfile", "-Command", trimmed]); // Fall back to cmd.exe if PowerShell fails const envComSpecRaw = process.env.ComSpec || process.env.COMSPEC;