From af5059652903f8f66b92773fce87a295bfdee274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haris=20Gu=C5=A1i=C4=87?= Date: Fri, 31 Oct 2025 23:20:22 +0100 Subject: [PATCH] fix: grep failing when pattern started with a dash --- packages/opencode/src/file/ripgrep.ts | 1 + packages/opencode/src/tool/grep.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/file/ripgrep.ts b/packages/opencode/src/file/ripgrep.ts index 6e7f549a..29014d19 100644 --- a/packages/opencode/src/file/ripgrep.ts +++ b/packages/opencode/src/file/ripgrep.ts @@ -367,6 +367,7 @@ export namespace Ripgrep { args.push(`--max-count=${input.limit}`) } + args.push("--") args.push(input.pattern) const command = args.join(" ") diff --git a/packages/opencode/src/tool/grep.ts b/packages/opencode/src/tool/grep.ts index a4d57b3d..5390be21 100644 --- a/packages/opencode/src/tool/grep.ts +++ b/packages/opencode/src/tool/grep.ts @@ -20,7 +20,7 @@ export const GrepTool = Tool.define("grep", { const searchPath = params.path || Instance.directory const rgPath = await Ripgrep.filepath() - const args = ["-nH", "--field-match-separator=|", params.pattern] + const args = ["-nH", "--field-match-separator=|", "--regexp", params.pattern] if (params.include) { args.push("--glob", params.include) }