Merge pull request #145 from continuedev/dallin/install-rg

fix: Search tool: install rg if not found, show error messages if tool errors
This commit is contained in:
Dallin Romney 2025-08-04 08:30:17 -07:00 • committed by GitHub
commit 46ea3e64d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 6 deletions

View file

@ -179,7 +179,7 @@ Each string in the diffs array can contain multiple SEARCH/REPLACE blocks, and a
return `Successfully edited ${args.filepath}`;
} catch (error) {
throw new Error(
`Failed to edit ${args.filepath}:\n ${
`Error: failed to edit ${args.filepath}:\n ${
error instanceof Error ? error.message : String(error)
}`
);

View file

@ -96,7 +96,11 @@ export const searchCodeTool: Tool = {
args.file_pattern ? ` in files matching "${args.file_pattern}"` : ""
}.`;
}
if (error instanceof Error) {
if (error.message.includes("command not found")) {
return `Error: ripgrep is not installed. Inform the user and run /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" to install it`;
}
}
return `Error executing ripgrep: ${
error instanceof Error ? error.message : String(error)
}`;

View file

@ -109,6 +109,12 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
return "Cancelled by user";
}
// Check if it was an error
if (content.startsWith("Error")) {
const lines = content.split("\n");
return `Error: ${lines[0]}${lines.length > 1 ? "..." : ""}`;
}
// Convert absolute paths to relative paths from workspace root
const formatPath = (filePath: string) => {
if (path.isAbsolute(filePath)) {
@ -133,12 +139,10 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
case "Write":
return content.includes("Successfully created file")
? "File created successfully"
: "File written successfully";
: "File updated successfully";
case "Edit":
return content.includes("Successfully created file")
? "File created successfully"
: "File edited successfully";
return "File edited successfully";
case "List":
return `Listed ${lines} ${lines === 1 ? "item" : "items"}`;