fix(opencode): make ACP resource text sourcing cross-platform (#33534)

This commit is contained in:
Aiden Cline
2026-06-23 12:55:34 -05:00
committed by GitHub
parent 2ba18b84a5
commit 5152150bfe
2 changed files with 40 additions and 11 deletions
+8 -1
View File
@@ -80,10 +80,17 @@ export function contentBlockToParts(block: ContentBlock): PromptPart[] {
const parsed = new URL(block.resource.uri)
if (parsed.protocol === "file:") {
const line = parsed.hash.match(/^#L(\d+)/)?.[1]
let filepath: string
try {
filepath = fileURLToPath(parsed)
} catch {
filepath = decodeURIComponent(parsed.pathname)
}
if (path.sep === "\\") filepath = filepath.replace(/\\/g, "/")
return [
{
type: "text",
text: `[${fileURLToPath(parsed)}${line ? `:${line}` : ""}]\n${block.resource.text}`,
text: `[${filepath}${line ? `:${line}` : ""}]\n${block.resource.text}`,
},
]
}