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:
1 parent
b8893aba56
commit
e0b8efa0be
33 files changed
+514
-204
No files matched your search
@@ -8,6 +8,7 @@ export type ToolFamily = "content-search" | "file-search" | "list" | "read" | "m
|
||||
interface ToolField {
|
||||
key:
|
||||
| "query"
|
||||
| "args"
|
||||
| "pattern"
|
||||
| "glob"
|
||||
| "path"
|
||||
@@ -88,6 +89,14 @@ export function parseGenericToolTrace(line: string): GenericToolTrace | null {
|
||||
if (!call || isExcludedTool(call.name)) return null;
|
||||
const family = toolFamily(call.name);
|
||||
const fields = safeFields(call.args);
|
||||
if (call.name === "rg" && call.args && typeof call.args === "object") {
|
||||
const argv = (call.args as Record<string, unknown>).args;
|
||||
if (Array.isArray(argv) && argv.every((arg) => typeof arg === "string")) {
|
||||
fields.push({ key: "args", value: argv.map((arg) =>
|
||||
arg && !/[\s"']/u.test(arg) ? arg : JSON.stringify(arg),
|
||||
).join(" ") });
|
||||
}
|
||||
}
|
||||
const collectedSource = fields.some((field) => isCollectedSourcePath(field.value));
|
||||
return {
|
||||
name: call.name,
|
||||
@@ -283,6 +292,7 @@ function activityLabel(
|
||||
function activityDetail(items: GenericToolRunItem[], family: ToolFamily, name: string): string {
|
||||
if (items.length !== 1) return "";
|
||||
const trace = items[0].trace;
|
||||
if (name === "rg") return safeText(fieldValue(trace, "args"));
|
||||
if (family === "content-search") {
|
||||
return quote(fieldValue(trace, "query") || fieldValue(trace, "pattern"));
|
||||
}
|
||||
|
||||
@@ -1867,8 +1867,8 @@
|
||||
"searchedFiles": "Searched files",
|
||||
"searchFilesFailed": "Could not search files",
|
||||
"findingFiles": "Finding files",
|
||||
"foundFiles": "Found files",
|
||||
"findFilesFailed": "Could not find files",
|
||||
"foundFiles": "File search complete",
|
||||
"findFilesFailed": "Could not search for files",
|
||||
"listingFiles": "Listing files",
|
||||
"listedFiles": "Listed files",
|
||||
"listFilesFailed": "Could not list files",
|
||||
|
||||
@@ -1696,8 +1696,8 @@
|
||||
"searchedFiles": "Búsqueda en archivos completada",
|
||||
"searchFilesFailed": "No se pudo buscar en los archivos",
|
||||
"findingFiles": "Buscando archivos",
|
||||
"foundFiles": "Archivos encontrados",
|
||||
"findFilesFailed": "No se pudieron encontrar archivos",
|
||||
"foundFiles": "Búsqueda de archivos completada",
|
||||
"findFilesFailed": "No se pudieron buscar archivos",
|
||||
"listingFiles": "Listando archivos",
|
||||
"listedFiles": "Archivos listados",
|
||||
"listFilesFailed": "No se pudieron listar los archivos",
|
||||
|
||||
@@ -1695,8 +1695,8 @@
|
||||
"searchedFiles": "Recherche terminée dans les fichiers",
|
||||
"searchFilesFailed": "Impossible de rechercher dans les fichiers",
|
||||
"findingFiles": "Recherche de fichiers",
|
||||
"foundFiles": "Fichiers trouvés",
|
||||
"findFilesFailed": "Impossible de trouver les fichiers",
|
||||
"foundFiles": "Recherche de fichiers terminée",
|
||||
"findFilesFailed": "Impossible de rechercher des fichiers",
|
||||
"listingFiles": "Liste des fichiers",
|
||||
"listedFiles": "Fichiers listés",
|
||||
"listFilesFailed": "Impossible de lister les fichiers",
|
||||
|
||||
@@ -1695,8 +1695,8 @@
|
||||
"searchedFiles": "Pencarian file selesai",
|
||||
"searchFilesFailed": "Tidak dapat mencari di file",
|
||||
"findingFiles": "Mencari file",
|
||||
"foundFiles": "File ditemukan",
|
||||
"findFilesFailed": "Tidak dapat menemukan file",
|
||||
"foundFiles": "Pencarian file selesai",
|
||||
"findFilesFailed": "Pencarian file gagal",
|
||||
"listingFiles": "Membuat daftar file",
|
||||
"listedFiles": "File terdaftar",
|
||||
"listFilesFailed": "Tidak dapat membuat daftar file",
|
||||
|
||||
@@ -1692,11 +1692,11 @@
|
||||
"reviewedSources": "ソースを確認しました",
|
||||
"reviewSourcesFailed": "ソースを確認できませんでした",
|
||||
"searchingFiles": "ファイルを検索中",
|
||||
"searchedFiles": "ファイルを検索しました",
|
||||
"searchedFiles": "ファイル検索完了",
|
||||
"searchFilesFailed": "ファイルを検索できませんでした",
|
||||
"findingFiles": "ファイルを探索中",
|
||||
"foundFiles": "ファイルを見つけました",
|
||||
"findFilesFailed": "ファイルを見つけられませんでした",
|
||||
"findingFiles": "ファイルを検索中",
|
||||
"foundFiles": "ファイル検索完了",
|
||||
"findFilesFailed": "ファイルの検索に失敗しました",
|
||||
"listingFiles": "ファイルを一覧表示中",
|
||||
"listedFiles": "ファイルを一覧表示しました",
|
||||
"listFilesFailed": "ファイルを一覧表示できませんでした",
|
||||
|
||||
@@ -1695,8 +1695,8 @@
|
||||
"searchedFiles": "파일 검색 완료",
|
||||
"searchFilesFailed": "파일을 검색하지 못함",
|
||||
"findingFiles": "파일 찾는 중",
|
||||
"foundFiles": "파일 찾음",
|
||||
"findFilesFailed": "파일을 찾지 못함",
|
||||
"foundFiles": "파일 검색 완료",
|
||||
"findFilesFailed": "파일 검색 실패",
|
||||
"listingFiles": "파일 목록 작성 중",
|
||||
"listedFiles": "파일 목록 작성 완료",
|
||||
"listFilesFailed": "파일 목록을 작성하지 못함",
|
||||
|
||||
@@ -1681,8 +1681,8 @@
|
||||
"searchedFiles": "Pesquisa nos arquivos concluída",
|
||||
"searchFilesFailed": "Não foi possível pesquisar nos arquivos",
|
||||
"findingFiles": "Procurando arquivos",
|
||||
"foundFiles": "Arquivos encontrados",
|
||||
"findFilesFailed": "Não foi possível encontrar arquivos",
|
||||
"foundFiles": "Busca de arquivos concluída",
|
||||
"findFilesFailed": "Não foi possível buscar arquivos",
|
||||
"listingFiles": "Listando arquivos",
|
||||
"listedFiles": "Arquivos listados",
|
||||
"listFilesFailed": "Não foi possível listar os arquivos",
|
||||
|
||||
@@ -1692,11 +1692,11 @@
|
||||
"reviewedSources": "Đã xem lại nguồn",
|
||||
"reviewSourcesFailed": "Không thể xem lại nguồn",
|
||||
"searchingFiles": "Đang tìm trong tệp",
|
||||
"searchedFiles": "Đã tìm trong tệp",
|
||||
"searchedFiles": "Đã hoàn tất tìm kiếm trong tệp",
|
||||
"searchFilesFailed": "Không thể tìm trong tệp",
|
||||
"findingFiles": "Đang tìm tệp",
|
||||
"foundFiles": "Đã tìm thấy tệp",
|
||||
"findFilesFailed": "Không thể tìm thấy tệp",
|
||||
"foundFiles": "Đã hoàn tất tìm kiếm tệp",
|
||||
"findFilesFailed": "Không thể tìm kiếm tệp",
|
||||
"listingFiles": "Đang liệt kê tệp",
|
||||
"listedFiles": "Đã liệt kê tệp",
|
||||
"listFilesFailed": "Không thể liệt kê tệp",
|
||||
|
||||
@@ -1859,27 +1859,27 @@
|
||||
"activityWorkingFor": "处理中 {{duration}}",
|
||||
"activityWorked": "已处理",
|
||||
"agentActivity": {
|
||||
"reviewingSources": "正在检查来源",
|
||||
"reviewedSources": "已检查来源",
|
||||
"reviewSourcesFailed": "无法检查来源",
|
||||
"reviewingSources": "正在查阅资料",
|
||||
"reviewedSources": "资料查阅完成",
|
||||
"reviewSourcesFailed": "资料查阅失败",
|
||||
"searchingFiles": "正在搜索文件",
|
||||
"searchedFiles": "已搜索文件",
|
||||
"searchFilesFailed": "无法搜索文件",
|
||||
"searchedFiles": "文件搜索完成",
|
||||
"searchFilesFailed": "文件搜索失败",
|
||||
"findingFiles": "正在查找文件",
|
||||
"foundFiles": "已找到文件",
|
||||
"findFilesFailed": "无法查找文件",
|
||||
"foundFiles": "文件查找完成",
|
||||
"findFilesFailed": "文件查找失败",
|
||||
"listingFiles": "正在列出文件",
|
||||
"listedFiles": "已列出文件",
|
||||
"listFilesFailed": "无法列出文件",
|
||||
"readingSource": "正在读取来源",
|
||||
"readSource": "已读取来源",
|
||||
"readSourceFailed": "无法读取来源",
|
||||
"readingSource": "正在读取资料",
|
||||
"readSource": "资料读取完成",
|
||||
"readSourceFailed": "资料读取失败",
|
||||
"readingFile": "正在读取文件",
|
||||
"readFile": "已读取文件",
|
||||
"readFileFailed": "无法读取文件",
|
||||
"searchingMemory": "正在搜索记忆",
|
||||
"searchedMemory": "已搜索记忆",
|
||||
"searchMemoryFailed": "无法搜索记忆",
|
||||
"searchedMemory": "记忆搜索完成",
|
||||
"searchMemoryFailed": "记忆搜索失败",
|
||||
"generatingImage": "正在生成图片",
|
||||
"generatedImage": "已生成图片",
|
||||
"generateImageFailed": "无法生成图片",
|
||||
@@ -1924,12 +1924,12 @@
|
||||
"completeToolFailed": "无法完成 {{name}}",
|
||||
"files_one": "{{count}} 个文件",
|
||||
"files_other": "{{count}} 个文件",
|
||||
"searches_one": "{{count}} 次搜索",
|
||||
"searches_other": "{{count}} 次搜索",
|
||||
"searches_one": "{{count}} 次",
|
||||
"searches_other": "{{count}} 次",
|
||||
"actions_one": "{{count}} 个操作",
|
||||
"actions_other": "{{count}} 个操作",
|
||||
"searching": "正在搜索 {{target}}",
|
||||
"searched": "已搜索 {{target}}",
|
||||
"searched": "{{target}} 搜索完成",
|
||||
"searchFailed": "无法搜索 {{target}}",
|
||||
"web": "网页",
|
||||
"reading": "正在读取",
|
||||
@@ -1980,7 +1980,7 @@
|
||||
"waitedForPage": "已等待页面",
|
||||
"pageNotReady": "页面未就绪",
|
||||
"searchingPlain": "正在搜索",
|
||||
"searchedPlain": "已搜索",
|
||||
"searchedPlain": "搜索完成",
|
||||
"searchFailedPlain": "无法搜索",
|
||||
"toolFailed": "{{name}} 失败",
|
||||
"toolCompleted": "{{name}} 已完成",
|
||||
|
||||
@@ -1687,27 +1687,27 @@
|
||||
"activityWorked": "已處理",
|
||||
"activityWorkedFor": "已處理 {{duration}}",
|
||||
"agentActivity": {
|
||||
"reviewingSources": "正在檢查來源",
|
||||
"reviewedSources": "已檢查來源",
|
||||
"reviewSourcesFailed": "無法檢查來源",
|
||||
"reviewingSources": "正在查閱資料",
|
||||
"reviewedSources": "資料查閱完成",
|
||||
"reviewSourcesFailed": "資料查閱失敗",
|
||||
"searchingFiles": "正在搜尋檔案",
|
||||
"searchedFiles": "已搜尋檔案",
|
||||
"searchFilesFailed": "無法搜尋檔案",
|
||||
"searchedFiles": "檔案搜尋完成",
|
||||
"searchFilesFailed": "檔案搜尋失敗",
|
||||
"findingFiles": "正在尋找檔案",
|
||||
"foundFiles": "已找到檔案",
|
||||
"findFilesFailed": "無法尋找檔案",
|
||||
"foundFiles": "檔案搜尋完成",
|
||||
"findFilesFailed": "檔案搜尋失敗",
|
||||
"listingFiles": "正在列出檔案",
|
||||
"listedFiles": "已列出檔案",
|
||||
"listFilesFailed": "無法列出檔案",
|
||||
"readingSource": "正在讀取來源",
|
||||
"readSource": "已讀取來源",
|
||||
"readSourceFailed": "無法讀取來源",
|
||||
"readingSource": "正在讀取資料",
|
||||
"readSource": "資料讀取完成",
|
||||
"readSourceFailed": "資料讀取失敗",
|
||||
"readingFile": "正在讀取檔案",
|
||||
"readFile": "已讀取檔案",
|
||||
"readFileFailed": "無法讀取檔案",
|
||||
"searchingMemory": "正在搜尋記憶",
|
||||
"searchedMemory": "已搜尋記憶",
|
||||
"searchMemoryFailed": "無法搜尋記憶",
|
||||
"searchedMemory": "記憶搜尋完成",
|
||||
"searchMemoryFailed": "記憶搜尋失敗",
|
||||
"generatingImage": "正在產生圖片",
|
||||
"generatedImage": "已產生圖片",
|
||||
"generateImageFailed": "無法產生圖片",
|
||||
@@ -1752,12 +1752,12 @@
|
||||
"completeToolFailed": "無法完成 {{name}}",
|
||||
"files_one": "{{count}} 個檔案",
|
||||
"files_other": "{{count}} 個檔案",
|
||||
"searches_one": "{{count}} 次搜尋",
|
||||
"searches_other": "{{count}} 次搜尋",
|
||||
"searches_one": "{{count}} 次",
|
||||
"searches_other": "{{count}} 次",
|
||||
"actions_one": "{{count}} 個操作",
|
||||
"actions_other": "{{count}} 個操作",
|
||||
"searching": "正在搜尋 {{target}}",
|
||||
"searched": "已搜尋 {{target}}",
|
||||
"searched": "{{target}} 搜尋完成",
|
||||
"searchFailed": "無法搜尋 {{target}}",
|
||||
"web": "網頁",
|
||||
"reading": "正在讀取",
|
||||
@@ -1808,7 +1808,7 @@
|
||||
"waitedForPage": "已等待頁面",
|
||||
"pageNotReady": "頁面尚未就緒",
|
||||
"searchingPlain": "正在搜尋",
|
||||
"searchedPlain": "已搜尋",
|
||||
"searchedPlain": "搜尋完成",
|
||||
"searchFailedPlain": "無法搜尋",
|
||||
"toolFailed": "{{name}} 失敗",
|
||||
"toolCompleted": "{{name}} 已完成",
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user