fix: install rg if not found, show error messages if tool errored
This commit is contained in:
parent
48fd27d6bb
commit
4fa0492037
3 changed files with 14 additions and 6 deletions
|
|
@ -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)
|
||||
}`
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}`;
|
||||
|
|
|
|||
|
|
@ -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_file":
|
||||
return content.includes("Successfully created file")
|
||||
? "File created successfully"
|
||||
: "File written successfully";
|
||||
: "File updated successfully";
|
||||
|
||||
case "edit_file":
|
||||
return content.includes("Successfully created file")
|
||||
? "File created successfully"
|
||||
: "File edited successfully";
|
||||
return "File edited successfully";
|
||||
|
||||
case "list_files":
|
||||
return `Listed ${lines} ${lines === 1 ? "item" : "items"}`;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue