feat(tools): use installed ripgrep for native file search (#5948)

* feat(tools): expose installed ripgrep through exec

* refactor(tools): launch ripgrep with native argument vectors

* refactor(tools): reuse the fresh exec parameter schema

* fix(tools): select search backend in loader and display rg arguments

* fix(ui): simplify rg previews and localize search completion

* docs: simplify ripgrep configuration note

* docs: keep ripgrep note on one line
This commit is contained in:
chengyongru authored and GitHub committed 2026-09-28 13:44:51 +08:00
1 parent b8893aba56
commit e0b8efa0be
33 files changed
+514 -204

No files matched your search

+14
View File
@@ -3,6 +3,20 @@ import { describe, expect, test } from "bun:test"
import { mergeToolEvent, renderToolEvent } from "./tool-renderers"
describe("tool renderers", () => {
test("shows rg search phases and argument boundaries", () => {
const start = { name: "rg", phase: "start", arguments: { args: ["-n", "hello world", "src"] } }
expect(renderToolEvent(start)).toBe(' › Searching files -n "hello world" src')
expect(renderToolEvent(mergeToolEvent(start, { name: "rg", phase: "end", result: "src/a:1:hello world" })))
.toBe(' ✓ Searched files -n "hello world" src')
expect(renderToolEvent({ name: "rg", phase: "error", error: "invalid regex" }))
.toBe(" × Search failed invalid regex")
})
test("shows rg regex characters and empty arguments", () => {
expect(renderToolEvent({ name: "rg", phase: "end", arguments: { args: [String.raw`resolve\(`, ""] } }))
.toBe(' ✓ Searched files resolve\\( ""')
})
test("retains start arguments when an end frame only carries output", () => {
const event = mergeToolEvent(
{ call_id: "exec-1", phase: "start", name: "exec", arguments: { cmd: "git status" } },
+6
View File
@@ -54,6 +54,7 @@ function toolLabel(
return phase === "end" ? "Delegated" : phase === "error" ? "Delegation failed" : "Delegating"
}
if (name === "web_search") return "Search web"
if (name === "rg") return phase === "end" ? "Searched files" : phase === "error" ? "Search failed" : "Searching files"
if (name === "web_fetch") return "Fetch"
return name
}
@@ -72,6 +73,11 @@ function toolDetail(
}
if (/^(?:spawn|spawn_agent)$/u.test(name)) return compact(args.label ?? args.task, 56)
if (name === "web_search") return compact(args.query ?? args.q)
if (name === "rg" && Array.isArray(args.args)) {
return compact(args.args.map((arg) =>
typeof arg === "string" && arg && !/[\s"']/u.test(arg) ? arg : JSON.stringify(arg),
).join(" "))
}
if (name === "web_fetch") return compact(args.url)
if (/session/u.test(name)) return compact(args.session_key ?? args.chat_id ?? args.query)
if (Object.keys(args).length) return compact(args)