ソースを参照

fix: grep failing when pattern started with a dash

Haris Gušić 10 ヶ月 前
コミット
af50596529

+ 1 - 0
packages/opencode/src/file/ripgrep.ts

@@ -367,6 +367,7 @@ export namespace Ripgrep {
       args.push(`--max-count=${input.limit}`)
       args.push(`--max-count=${input.limit}`)
     }
     }
 
 
+    args.push("--")
     args.push(input.pattern)
     args.push(input.pattern)
 
 
     const command = args.join(" ")
     const command = args.join(" ")

+ 1 - 1
packages/opencode/src/tool/grep.ts

@@ -20,7 +20,7 @@ export const GrepTool = Tool.define("grep", {
     const searchPath = params.path || Instance.directory
     const searchPath = params.path || Instance.directory
 
 
     const rgPath = await Ripgrep.filepath()
     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) {
     if (params.include) {
       args.push("--glob", params.include)
       args.push("--glob", params.include)
     }
     }