From 3f760cab21e9411e7cf9b84c1baf6ffd13e7cb8a Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 30 Jul 2025 22:35:32 -0700 Subject: [PATCH] revert vitest change, fix tool permissions --- package.json | 2 +- src/permissions/toolNameMapping.ts | 83 +++++++++++++++-------------- src/tools/searchAndReplace/index.ts | 4 +- 3 files changed, 46 insertions(+), 43 deletions(-) diff --git a/package.json b/package.json index e4d8dbaa3..8f8cd64db 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/permissions/toolNameMapping.ts b/src/permissions/toolNameMapping.ts index 97f711130..b15f354e6 100644 --- a/src/permissions/toolNameMapping.ts +++ b/src/permissions/toolNameMapping.ts @@ -3,36 +3,39 @@ */ const TOOL_NAME_MAPPINGS: Record = { // 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 = { - "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; -} \ No newline at end of file +} diff --git a/src/tools/searchAndReplace/index.ts b/src/tools/searchAndReplace/index.ts index 1ff1f1c4e..9d38908e5 100644 --- a/src/tools/searchAndReplace/index.ts +++ b/src/tools/searchAndReplace/index.ts @@ -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}`,