Skip to content

Commit 10327e0

Browse files
Merge pull request #1285 from Ericcc-Ma/fix/acp-posix-paths
fix(acp): use POSIX path semantics for ACP wire format paths
2 parents 751efb8 + 106fd50 commit 10327e0

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/services/acp/bridge/paths.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
// Pure path-normalisation helper used by toolInfo / toolResults / forwarding.
2-
import { isAbsolute, resolve } from 'node:path'
2+
//
3+
// POSIX semantics are used so that emitted paths are platform-independent:
4+
// ACP v1 spec (tool-calls.mdx:304-306) requires ToolCallLocation.path /
5+
// Diff.path to be absolute, and the wire format is POSIX-style regardless of
6+
// the host OS. Using the platform-specific `node:path` here would prepend the
7+
// Windows drive letter (e.g. "D:\...") to POSIX-style inputs like
8+
// "/Users/test/project" — silently corrupting paths emitted to ACP clients.
9+
import { isAbsolute, resolve } from 'node:path/posix'
310

411
/**
512
* Normalises an emitted file path against the session cwd so that

src/services/acp/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ export function sanitizeTitle(text: string): string {
172172

173173
// ── Path display helpers ──────────────────────────────────────────
174174

175-
import * as path from 'node:path'
175+
// POSIX semantics so paths are normalised consistently regardless of host OS.
176+
// ACP paths are always POSIX-style (see bridge/paths.ts for the same rationale).
177+
import * as path from 'node:path/posix'
176178

177179
/**
178180
* Convert an absolute file path to a project-relative path for display.
@@ -186,7 +188,7 @@ export function toDisplayPath(filePath: string, cwd?: string): string {
186188
resolvedFile.startsWith(resolvedCwd + path.sep) ||
187189
resolvedFile === resolvedCwd
188190
) {
189-
return path.relative(resolvedCwd, resolvedFile).replaceAll('\\', '/')
191+
return path.relative(resolvedCwd, resolvedFile)
190192
}
191193
return filePath
192194
}

0 commit comments

Comments
 (0)