fix(acp): use POSIX path semantics for ACP wire format paths

ToolCallLocation.path and Diff.path emitted over ACP must be absolute
and POSIX-style per the v1 spec (tool-calls.mdx:304-306). The previous
code used platform-specific `node:path` which on Windows prepends the
drive letter (e.g. "D:\...") to POSIX-style inputs like
"/Users/test/project" — silently corrupting paths emitted to ACP
clients on Windows hosts. CI runs on Linux so the latent issue went
undetected. Switch to `node:path/posix` so the path normalisation is
host-OS independent.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
hongye
2026-06-25 15:29:26 +08:00
parent 751efb827c
commit 106fd5043e
2 changed files with 12 additions and 3 deletions

View File

@@ -172,7 +172,9 @@ export function sanitizeTitle(text: string): string {
// ── Path display helpers ──────────────────────────────────────────
import * as path from 'node:path'
// POSIX semantics so paths are normalised consistently regardless of host OS.
// ACP paths are always POSIX-style (see bridge/paths.ts for the same rationale).
import * as path from 'node:path/posix'
/**
* Convert an absolute file path to a project-relative path for display.
@@ -186,7 +188,7 @@ export function toDisplayPath(filePath: string, cwd?: string): string {
resolvedFile.startsWith(resolvedCwd + path.sep) ||
resolvedFile === resolvedCwd
) {
return path.relative(resolvedCwd, resolvedFile).replaceAll('\\', '/')
return path.relative(resolvedCwd, resolvedFile)
}
return filePath
}