summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHaris Gušić <[email protected]>2025-10-31 23:20:22 +0100
committerGitHub <[email protected]>2025-10-31 17:20:22 -0500
commitaf5059652903f8f66b92773fce87a295bfdee274 (patch)
treed77d81f07e30a0abf4e7092bdbcd4c0737333a3d
parent3823d8d50ef5b0fd0d9a4d7ce034b79a4c508b17 (diff)
downloadopencode-af5059652903f8f66b92773fce87a295bfdee274.tar.gz
opencode-af5059652903f8f66b92773fce87a295bfdee274.zip
fix: grep failing when pattern started with a dash
-rw-r--r--packages/opencode/src/file/ripgrep.ts1
-rw-r--r--packages/opencode/src/tool/grep.ts2
2 files changed, 2 insertions, 1 deletions
diff --git a/packages/opencode/src/file/ripgrep.ts b/packages/opencode/src/file/ripgrep.ts
index 6e7f549a7..29014d199 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 a4d57b3d6..5390be21a 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)
}