diff options
| author | Mani Sundararajan <[email protected]> | 2025-10-05 15:32:07 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-10-05 14:32:07 -0500 |
| commit | 889c276558f0cf012c3930501a013b2a38c4aecb (patch) | |
| tree | 230ba0c345d074829bf11c81ec9ee1ababf2be57 | |
| parent | 9c6192b00d97e581529dc9cc8e95a0f6d9d1ff00 (diff) | |
| download | opencode-889c276558f0cf012c3930501a013b2a38c4aecb.tar.gz opencode-889c276558f0cf012c3930501a013b2a38c4aecb.zip | |
fix: file references & grep tool for windows (#2980)
| -rw-r--r-- | packages/opencode/src/session/prompt.ts | 8 | ||||
| -rw-r--r-- | packages/opencode/src/tool/grep.ts | 5 |
2 files changed, 7 insertions, 6 deletions
diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts index f0be55330..474843dd9 100644 --- a/packages/opencode/src/session/prompt.ts +++ b/packages/opencode/src/session/prompt.ts @@ -47,7 +47,7 @@ import { NamedError } from "../util/error" import { ulid } from "ulid" import { spawn } from "child_process" import { Command } from "../command" -import { $ } from "bun" +import { $, fileURLToPath } from "bun" import { ConfigMarkdown } from "../config/markdown" export namespace SessionPrompt { @@ -589,7 +589,7 @@ export namespace SessionPrompt { log.info("file", { mime: part.mime }) // have to normalize, symbol search returns absolute paths // Decode the pathname since URL constructor doesn't automatically decode it - const filepath = decodeURIComponent(url.pathname) + const filepath = fileURLToPath(part.url) const stat = await Bun.file(filepath).stat() if (stat.isDirectory()) { @@ -604,14 +604,14 @@ export namespace SessionPrompt { end: url.searchParams.get("end"), } if (range.start != null) { - const filePath = part.url.split("?")[0] + const filePathURI = part.url.split("?")[0] let start = parseInt(range.start) let end = range.end ? parseInt(range.end) : undefined // some LSP servers (eg, gopls) don't give full range in // workspace/symbol searches, so we'll try to find the // symbol in the document to get the full range if (start === end) { - const symbols = await LSP.documentSymbol(filePath) + const symbols = await LSP.documentSymbol(filePathURI) for (const symbol of symbols) { let range: LSP.Range | undefined if ("range" in symbol) { diff --git a/packages/opencode/src/tool/grep.ts b/packages/opencode/src/tool/grep.ts index 215659ced..3faeb6fb4 100644 --- a/packages/opencode/src/tool/grep.ts +++ b/packages/opencode/src/tool/grep.ts @@ -25,6 +25,7 @@ export const GrepTool = Tool.define("grep", { args.push("--glob", params.include) } args.push(searchPath) + args.push("--field-match-separator=|") const proc = Bun.spawn([rgPath, ...args], { stdout: "pipe", @@ -53,11 +54,11 @@ export const GrepTool = Tool.define("grep", { for (const line of lines) { if (!line) continue - const [filePath, lineNumStr, ...lineTextParts] = line.split(":") + const [filePath, lineNumStr, ...lineTextParts] = line.split("|") if (!filePath || !lineNumStr || lineTextParts.length === 0) continue const lineNum = parseInt(lineNumStr, 10) - const lineText = lineTextParts.join(":") + const lineText = lineTextParts.join("|") const file = Bun.file(filePath) const stats = await file.stat().catch(() => null) |
