File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments