mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-25 09:35:52 +00:00
Merge pull request #1285 from Ericcc-Ma/fix/acp-posix-paths
fix(acp): use POSIX path semantics for ACP wire format paths
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
// Pure path-normalisation helper used by toolInfo / toolResults / forwarding.
|
// 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
|
* Normalises an emitted file path against the session cwd so that
|
||||||
|
|||||||
@@ -172,7 +172,9 @@ export function sanitizeTitle(text: string): string {
|
|||||||
|
|
||||||
// ── Path display helpers ──────────────────────────────────────────
|
// ── 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.
|
* 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.startsWith(resolvedCwd + path.sep) ||
|
||||||
resolvedFile === resolvedCwd
|
resolvedFile === resolvedCwd
|
||||||
) {
|
) {
|
||||||
return path.relative(resolvedCwd, resolvedFile).replaceAll('\\', '/')
|
return path.relative(resolvedCwd, resolvedFile)
|
||||||
}
|
}
|
||||||
return filePath
|
return filePath
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user