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

@@ -152,7 +152,7 @@ describe("AgentActivityCluster", () => {
await act(async () => setAppLanguage("zh-CN"));
expect(screen.getByText(`已搜索文件 “${query}”`)).toBeInTheDocument();
expect(screen.getByText(`文件搜索完成 “${query}”`)).toBeInTheDocument();
expect(screen.getByText(`正在读取文件 ${path}`)).toBeInTheDocument();
expect(screen.getByText("正在使用 Blender · --json --background scene.blend")).toBeInTheDocument();
expect(screen.getByText("正在打开 example.com · Browserbase")).toBeInTheDocument();
@@ -161,7 +161,7 @@ describe("AgentActivityCluster", () => {
await act(async () => setAppLanguage("ja"));
expect(screen.getByText(`“${query}” · ファイルを検索しました`)).toBeInTheDocument();
expect(screen.getByText(`“${query}” · ファイル検索完了`)).toBeInTheDocument();
expect(screen.getByText(`${path} · ファイルを読み取り中`)).toBeInTheDocument();
expect(screen.getByText("Blender を使用中 · --json --background scene.blend")).toBeInTheDocument();
expect(screen.getByText("example.com · 開いています · Browserbase")).toBeInTheDocument();
@@ -1523,7 +1523,7 @@ describe("AgentActivityCluster", () => {
/>,
);
expect(screen.getByText("Found files *.tsx")).toBeInTheDocument();
expect(screen.getByText("File search complete *.tsx")).toBeInTheDocument();
expect(screen.getByText("Listed files memory")).toBeInTheDocument();
expect(screen.getByText("Searching files “dream_cursor”")).toBeInTheDocument();
expect(screen.queryByText("Technical details")).not.toBeInTheDocument();
+20 -3
View File
@@ -15,8 +15,25 @@ function describeRun(line: string, status: GenericToolStatus = "done") {
}
describe("generic tool activity semantics", () => {
it.each(["running", "done", "error"] as const)("shows rg arguments during %s", (status) => {
const presentation = describeRun('rg({"args":["-n","hello world","src"]})', status);
expect(presentation.detail).toBe('-n "hello world" src');
expect(presentation.status).toBe(status);
});
it("bounds and redacts rg argument previews", () => {
const presentation = describeRun(`rg(${JSON.stringify({ args: ["sk-proj-abcdefghijklmno", "x".repeat(120)] })})`);
expect(presentation.detail).toContain("<redacted>");
expect(presentation.detail.length).toBeLessThanOrEqual(88);
});
it("shows rg regex characters and empty arguments", () => {
const presentation = describeRun(`rg(${JSON.stringify({ args: [String.raw`resolve\(`, ""] })})`);
expect(presentation.detail).toBe('resolve\\( ""');
});
it.each([
['find_files({"glob":"*.tsx"})', "Found files", "*.tsx"],
['find_files({"glob":"*.tsx"})', "File search complete", "*.tsx"],
['grep({"pattern":"dream_cursor"})', "Searched files", "“dream_cursor”"],
['list_dir({"path":"memory"})', "Listed files", "memory"],
['read_file({"path":"docs/guide.md"})', "Read file", "docs/guide.md"],
@@ -90,8 +107,8 @@ describe("generic tool activity semantics", () => {
{ trace: first, status: "done" },
{ trace: second, status: "done" },
], i18n.t)).toMatchObject({
label: "已搜索文件",
aside: "2 次搜索",
label: "文件搜索完成",
aside: "2 次",
});
});
@@ -29,7 +29,15 @@ describe("localized agent activity contracts", () => {
await setAppLanguage(locale);
const trace = parseGenericToolTrace('read_file({"path":"src/app.tsx"})')!;
const rg = parseGenericToolTrace('rg({"args":["-n","hello world","src"]})')!;
for (const status of ["running", "done", "error"] as const) {
const rgPresentation = describeGenericToolRun([{ trace: rg, status }], i18n.t);
const searchKey = status === "running" ? "searchingFiles" : status === "done" ? "searchedFiles" : "searchFilesFailed";
expect(rgPresentation).toMatchObject({
label: translated[searchKey],
detail: '-n "hello world" src',
status,
});
const generic = describeGenericToolRun([{ trace, status }], i18n.t);
const command = describeTraceLine('exec({"command":"bun run test"})', status, i18n.t);
const browser = describeMcpActivity("browser_press_key", { key: "Enter" }, status, i18n.t);