From 1e636f0f77016a6671917ed77b75c1268351fadf Mon Sep 17 00:00:00 2001 From: Zach Bruggeman Date: Thu, 23 Jul 2026 13:14:35 -0700 Subject: [PATCH] fix(opencode): preserve grep symlink paths --- packages/opencode/src/tool/grep.ts | 5 ++++- packages/opencode/test/tool/grep.test.ts | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/tool/grep.ts b/packages/opencode/src/tool/grep.ts index e44b8e89fe29..6ea67124a6f9 100644 --- a/packages/opencode/src/tool/grep.ts +++ b/packages/opencode/src/tool/grep.ts @@ -69,7 +69,10 @@ export const GrepTool = Tool.define( if (result.length === 0) return empty const rows = result.map((item) => ({ - path: path.resolve(cwd, item.entry.path), + path: path.resolve( + requestedInfo?.type === "Directory" ? requested : path.dirname(requested), + item.entry.path, + ), line: item.line, text: item.text, })) diff --git a/packages/opencode/test/tool/grep.test.ts b/packages/opencode/test/tool/grep.test.ts index 81b74aa8baf0..13858f9f92ab 100644 --- a/packages/opencode/test/tool/grep.test.ts +++ b/packages/opencode/test/tool/grep.test.ts @@ -215,6 +215,8 @@ describe("tool.grep", () => { ) expect(result.metadata.matches).toBe(1) + expect(result.output).toContain(path.join(alias, "test.txt")) + expect(result.output).not.toContain(path.join(real, "test.txt")) expect(requests.find((req) => req.permission === "external_directory")).toBeUndefined() }), )