Aiden Cline 3 месяцев назад
Родитель
Сommit
2a4c035486
1 измененных файлов с 13 добавлено и 9 удалено
  1. 13 9
      packages/opencode/src/file/ripgrep.ts

+ 13 - 9
packages/opencode/src/file/ripgrep.ts

@@ -5,8 +5,6 @@ import fs from "fs/promises"
 import z from "zod"
 import { NamedError } from "@opencode-ai/util/error"
 import { lazy } from "../util/lazy"
-import { $ } from "bun"
-
 import { ZipReader, BlobReader, BlobWriter } from "@zip.js/zip.js"
 import { Log } from "@/util/log"
 
@@ -368,11 +366,11 @@ export namespace Ripgrep {
   }
 
   export async function search(input: { cwd: string; pattern: string; glob?: string[]; limit?: number }) {
-    const args = [`${await filepath()}`, "--json", "--hidden", "--glob='!.git/*'"]
+    const args = [await filepath(), "--json", "--hidden", "--glob=!.git/*"]
 
     if (input.glob) {
       for (const g of input.glob) {
-        args.push(`--glob='${g}'`)
+        args.push(`--glob=${g}`)
       }
     }
 
@@ -383,15 +381,21 @@ export namespace Ripgrep {
     args.push("--")
     args.push(input.pattern)
 
-    const command = args.join(" ")
-    const result = await $`${{ raw: command }}`.cwd(input.cwd).quiet().nothrow()
-    if (result.exitCode !== 0) {
+    const proc = Bun.spawn(args, {
+      cwd: input.cwd,
+      stdout: "pipe",
+      stderr: "ignore",
+    })
+
+    const output = await Bun.readableStreamToText(proc.stdout)
+    await proc.exited
+
+    if (proc.exitCode !== 0) {
       return []
     }
 
     // Handle both Unix (\n) and Windows (\r\n) line endings
-    const lines = result.text().trim().split(/\r?\n/).filter(Boolean)
-    // Parse JSON lines from ripgrep output
+    const lines = output.trim().split(/\r?\n/).filter(Boolean)
 
     return lines
       .map((line) => JSON.parse(line))