fix: fix misc windows issues (#323)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2025-12-19 14:01:03 -08:00
committed by GitHub
parent 66c4842375
commit e5281fb06d
12 changed files with 371 additions and 11 deletions

View File

@@ -155,7 +155,8 @@ export async function apply_patch(
try {
const buf = await fs.readFile(abs, "utf8");
return buf;
// Normalize line endings to LF for consistent matching (Windows uses CRLF)
return buf.replace(/\r\n/g, "\n");
} catch (error) {
const err = error as NodeJS.ErrnoException;
if (err.code === "ENOENT") {

View File

@@ -29,7 +29,9 @@ export async function edit(args: EditArgs): Promise<EditResult> {
"No changes to make: old_string and new_string are exactly the same.",
);
try {
const content = await fs.readFile(resolvedPath, "utf-8");
const rawContent = await fs.readFile(resolvedPath, "utf-8");
// Normalize line endings to LF for consistent matching (Windows uses CRLF)
const content = rawContent.replace(/\r\n/g, "\n");
const occurrences = content.split(old_string).length - 1;
if (occurrences === 0)
throw new Error(

View File

@@ -42,7 +42,9 @@ export async function multi_edit(
);
}
try {
let content = await fs.readFile(resolvedPath, "utf-8");
const rawContent = await fs.readFile(resolvedPath, "utf-8");
// Normalize line endings to LF for consistent matching (Windows uses CRLF)
let content = rawContent.replace(/\r\n/g, "\n");
const appliedEdits: string[] = [];
for (let i = 0; i < edits.length; i++) {
const edit = edits[i];

View File

@@ -17,12 +17,10 @@ function windowsLaunchers(command: string): string[][] {
if (!trimmed) return [];
const launchers: string[][] = [];
const seen = new Set<string>();
const envComSpecRaw = process.env.ComSpec || process.env.COMSPEC;
const envComSpec = envComSpecRaw?.trim();
if (envComSpec) {
pushUnique(launchers, seen, [envComSpec, "/d", "/s", "/c", trimmed]);
}
pushUnique(launchers, seen, ["cmd.exe", "/d", "/s", "/c", trimmed]);
// Default to PowerShell on Windows (same as Gemini CLI and Codex CLI)
// This ensures better PATH compatibility since many tools are configured
// in PowerShell profiles rather than system-wide cmd.exe PATH
pushUnique(launchers, seen, [
"powershell.exe",
"-NoProfile",
@@ -30,6 +28,15 @@ function windowsLaunchers(command: string): string[][] {
trimmed,
]);
pushUnique(launchers, seen, ["pwsh", "-NoProfile", "-Command", trimmed]);
// Fall back to cmd.exe if PowerShell fails
const envComSpecRaw = process.env.ComSpec || process.env.COMSPEC;
const envComSpec = envComSpecRaw?.trim();
if (envComSpec) {
pushUnique(launchers, seen, [envComSpec, "/d", "/s", "/c", trimmed]);
}
pushUnique(launchers, seen, ["cmd.exe", "/d", "/s", "/c", trimmed]);
return launchers;
}