Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/services/acp/bridge/paths.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
// Pure path-normalisation helper used by toolInfo / toolResults / forwarding.
import { isAbsolute, resolve } from 'node:path'
//
// POSIX semantics are used so that emitted paths are platform-independent:
// ACP v1 spec (tool-calls.mdx:304-306) requires ToolCallLocation.path /
// Diff.path to be absolute, and the wire format is POSIX-style regardless of
// the host OS. Using the platform-specific `node:path` here would prepend the
// Windows drive letter (e.g. "D:\...") to POSIX-style inputs like
// "/Users/test/project" — silently corrupting paths emitted to ACP clients.
import { isAbsolute, resolve } from 'node:path/posix'

/**
* Normalises an emitted file path against the session cwd so that
Expand Down
6 changes: 4 additions & 2 deletions src/services/acp/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
Expand Down