revert vitest change, fix tool permissions

This commit is contained in:
Dallin Romney 2025-07-30 22:35:32 -07:00
parent e991e7923b
commit 3f760cab21
3 changed files with 46 additions and 43 deletions

View file

@ -9,7 +9,7 @@
"cn": "dist/index.js"
},
"scripts": {
"test": "npm run lint && npm run jest && npm run vitest",
"test": "npm run lint && npm run jest",
"jest": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
"vitest": "vitest run",
"vitest:watch": "vitest watch",

View file

@ -3,36 +3,39 @@
*/
const TOOL_NAME_MAPPINGS: Record<string, string> = {
// Display name mappings
"Read": "read_file",
"Write": "write_file",
"List": "list_files",
"Search": "search_code",
"Bash": "run_terminal_command",
"Terminal": "run_terminal_command",
"Fetch": "fetch",
"Exit": "exit",
"Diff": "view_diff",
Read: "read_file",
Write: "write_file",
List: "list_files",
Search: "search_code",
Bash: "run_terminal_command",
Terminal: "run_terminal_command",
Fetch: "fetch",
Exit: "exit",
Diff: "view_diff",
Edit: "edit_file",
// Common variations (case insensitive)
"read": "read_file",
"write": "write_file",
"list": "list_files",
"search": "search_code",
"bash": "run_terminal_command",
"terminal": "run_terminal_command",
"cmd": "run_terminal_command",
"command": "run_terminal_command",
"fetch": "fetch",
"exit": "exit",
"diff": "view_diff",
read: "read_file",
write: "write_file",
list: "list_files",
search: "search_code",
bash: "run_terminal_command",
terminal: "run_terminal_command",
cmd: "run_terminal_command",
command: "run_terminal_command",
fetch: "fetch",
exit: "exit",
diff: "view_diff",
edit: "edit_file",
// Actual tool names (passthrough)
"read_file": "read_file",
"write_file": "write_file",
"list_files": "list_files",
"search_code": "search_code",
"run_terminal_command": "run_terminal_command",
"view_diff": "view_diff",
read_file: "read_file",
write_file: "write_file",
list_files: "list_files",
search_code: "search_code",
run_terminal_command: "run_terminal_command",
view_diff: "view_diff",
edit_file: "edit_file",
};
/**
@ -43,7 +46,7 @@ export function normalizeToolName(input: string): string {
if (TOOL_NAME_MAPPINGS[input]) {
return TOOL_NAME_MAPPINGS[input];
}
// Try case insensitive match
const lowerInput = input.toLowerCase();
for (const [key, value] of Object.entries(TOOL_NAME_MAPPINGS)) {
@ -51,7 +54,7 @@ export function normalizeToolName(input: string): string {
return value;
}
}
// If no mapping found, return as-is (might be an MCP tool or future tool)
return input;
}
@ -63,15 +66,15 @@ export function normalizeToolName(input: string): string {
export function getDisplayName(normalizedName: string): string {
// Create a reverse mapping from normalized names to display names
const reverseMapping: Record<string, string> = {
"read_file": "Read",
"write_file": "Write",
"list_files": "List",
"search_code": "Search",
"run_terminal_command": "Bash",
"fetch": "Fetch",
"exit": "Exit",
"view_diff": "Diff",
read_file: "Read",
write_file: "Write",
list_files: "List",
search_code: "Search",
run_terminal_command: "Bash",
fetch: "Fetch",
exit: "Exit",
view_diff: "Diff",
};
return reverseMapping[normalizedName] || normalizedName;
}
}

View file

@ -24,8 +24,8 @@ export const NO_PARALLEL_TOOL_CALLING_INSRUCTION =
* Our starting point is heavily inspired by Cline's `replace_in_file` tool: https://github.com/cline/cline/blob/2709ccefcddc616e89a70962f017bcbbca1f17bf/src/core/prompts/system.ts#L87-L121
*/
export const searchAndReplaceInFileTool: Tool = {
name: "search_and_replace_in_file",
displayName: "Search and Replace",
name: "edit_file",
displayName: "Edit",
readonly: false,
isBuiltIn: true,
description: `Request to replace sections of content in an existing file using multiple SEARCH/REPLACE blocks that define exact changes to specific parts of the file. This tool should be used when you need to make targeted changes to specific parts of a file. ${NO_PARALLEL_TOOL_CALLING_INSRUCTION}`,