From 950b9582e443e7ccd6709f7ab75f580c03fbcc69 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Tue, 28 Oct 2025 19:07:53 +0000 Subject: [PATCH 1/7] fix: remove search_and_replace tool and all references - Deleted src/core/tools/searchAndReplaceTool.ts - Removed import and case handling from presentAssistantMessage.ts - Removed from toolNames array in packages/types/src/tool.ts - Removed SearchAndReplaceToolUse interface from src/shared/tools.ts - Deleted src/core/prompts/tools/search-and-replace.ts - Removed from tool description map in prompts/tools/index.ts - Removed from prompts rules and responses - Removed from test files - Snapshot files will be regenerated on test run Fixes #8891 --- packages/types/src/tool.ts | 1 - .../presentAssistantMessage.ts | 7 - src/core/prompts/responses.ts | 3 +- src/core/prompts/sections/rules.ts | 5 - src/core/prompts/tools/index.ts | 3 - src/core/prompts/tools/search-and-replace.ts | 39 --- src/core/tools/searchAndReplaceTool.ts | 282 ------------------ src/shared/__tests__/modes.spec.ts | 27 +- src/shared/tools.ts | 16 +- 9 files changed, 4 insertions(+), 379 deletions(-) delete mode 100644 src/core/prompts/tools/search-and-replace.ts delete mode 100644 src/core/tools/searchAndReplaceTool.ts diff --git a/packages/types/src/tool.ts b/packages/types/src/tool.ts index 2c7495e5ebe..8c12a2dc049 100644 --- a/packages/types/src/tool.ts +++ b/packages/types/src/tool.ts @@ -20,7 +20,6 @@ export const toolNames = [ "write_to_file", "apply_diff", "insert_content", - "search_and_replace", "search_files", "list_files", "list_code_definition_names", diff --git a/src/core/assistant-message/presentAssistantMessage.ts b/src/core/assistant-message/presentAssistantMessage.ts index 689675999fd..2249c008d67 100644 --- a/src/core/assistant-message/presentAssistantMessage.ts +++ b/src/core/assistant-message/presentAssistantMessage.ts @@ -15,7 +15,6 @@ import { shouldUseSingleFileRead } from "@roo-code/types" import { writeToFileTool } from "../tools/writeToFileTool" import { applyDiffTool } from "../tools/multiApplyDiffTool" import { insertContentTool } from "../tools/insertContentTool" -import { searchAndReplaceTool } from "../tools/searchAndReplaceTool" import { listCodeDefinitionNamesTool } from "../tools/listCodeDefinitionNamesTool" import { searchFilesTool } from "../tools/searchFilesTool" import { browserActionTool } from "../tools/browserActionTool" @@ -195,8 +194,6 @@ export async function presentAssistantMessage(cline: Task) { }]` case "insert_content": return `[${block.name} for '${block.params.path}']` - case "search_and_replace": - return `[${block.name} for '${block.params.path}']` case "list_files": return `[${block.name} for '${block.params.path}']` case "list_code_definition_names": @@ -463,10 +460,6 @@ export async function presentAssistantMessage(cline: Task) { await checkpointSaveAndMark(cline) await insertContentTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag) break - case "search_and_replace": - await checkpointSaveAndMark(cline) - await searchAndReplaceTool(cline, block, askApproval, handleError, pushToolResult, removeClosingTag) - break case "read_file": // Check if this model should use the simplified single-file read tool const modelId = cline.api.getModel().id diff --git a/src/core/prompts/responses.ts b/src/core/prompts/responses.ts index fd51b18feda..2f3ea87d4c6 100644 --- a/src/core/prompts/responses.ts +++ b/src/core/prompts/responses.ts @@ -56,8 +56,7 @@ Otherwise, if you have not completed the task and do not need additional informa } existingFileApproaches.push( - `${diffStrategyEnabled ? "3" : "2"}. Or use search_and_replace for specific text replacements`, - `${diffStrategyEnabled ? "4" : "3"}. Or use insert_content to add specific content at particular lines`, + `${diffStrategyEnabled ? "3" : "2"}. Or use insert_content to add specific content at particular lines`, ) const existingFileGuidance = diff --git a/src/core/prompts/sections/rules.ts b/src/core/prompts/sections/rules.ts index a5eaf23ce08..e8c7534b18a 100644 --- a/src/core/prompts/sections/rules.ts +++ b/src/core/prompts/sections/rules.ts @@ -16,7 +16,6 @@ function getEditingInstructions(diffStrategy?: DiffStrategy): string { } availableTools.push("insert_content (for adding lines to files)") - availableTools.push("search_and_replace (for finding and replacing individual pieces of text)") // Base editing instruction mentioning all available tools if (availableTools.length > 1) { @@ -28,10 +27,6 @@ function getEditingInstructions(diffStrategy?: DiffStrategy): string { "- The insert_content tool adds lines of text to files at a specific line number, such as adding a new function to a JavaScript file or inserting a new route in a Python file. Use line number 0 to append at the end of the file, or any positive number to insert before that line.", ) - instructions.push( - "- The search_and_replace tool finds and replaces text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text. It can support multiple operations at once.", - ) - if (availableTools.length > 1) { instructions.push( "- You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files.", diff --git a/src/core/prompts/tools/index.ts b/src/core/prompts/tools/index.ts index c212b18a3de..22588d55d12 100644 --- a/src/core/prompts/tools/index.ts +++ b/src/core/prompts/tools/index.ts @@ -14,7 +14,6 @@ import { getWriteToFileDescription } from "./write-to-file" import { getSearchFilesDescription } from "./search-files" import { getListFilesDescription } from "./list-files" import { getInsertContentDescription } from "./insert-content" -import { getSearchAndReplaceDescription } from "./search-and-replace" import { getListCodeDefinitionNamesDescription } from "./list-code-definition-names" import { getBrowserActionDescription } from "./browser-action" import { getAskFollowupQuestionDescription } from "./ask-followup-question" @@ -54,7 +53,6 @@ const toolDescriptionMap: Record string | undefined> switch_mode: () => getSwitchModeDescription(), new_task: (args) => getNewTaskDescription(args), insert_content: (args) => getInsertContentDescription(args), - search_and_replace: (args) => getSearchAndReplaceDescription(args), apply_diff: (args) => args.diffStrategy ? args.diffStrategy.getToolDescription({ cwd: args.cwd, toolOptions: args.toolOptions }) : "", update_todo_list: (args) => getUpdateTodoListDescription(args), @@ -176,7 +174,6 @@ export { getAccessMcpResourceDescription, getSwitchModeDescription, getInsertContentDescription, - getSearchAndReplaceDescription, getCodebaseSearchDescription, getRunSlashCommandDescription, getGenerateImageDescription, diff --git a/src/core/prompts/tools/search-and-replace.ts b/src/core/prompts/tools/search-and-replace.ts deleted file mode 100644 index 357a7058323..00000000000 --- a/src/core/prompts/tools/search-and-replace.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { ToolArgs } from "./types" - -export function getSearchAndReplaceDescription(args: ToolArgs): string { - return `## search_and_replace -Description: Use this tool to find and replace specific text strings or patterns (using regex) within a file. It's suitable for targeted replacements across multiple locations within the file. Supports literal text and regex patterns, case sensitivity options, and optional line ranges. Shows a diff preview before applying changes. - -Required Parameters: -- path: The path of the file to modify (relative to the current workspace directory ${args.cwd.toPosix()}) -- search: The text or pattern to search for -- replace: The text to replace matches with - -Optional Parameters: -- start_line: Starting line number for restricted replacement (1-based) -- end_line: Ending line number for restricted replacement (1-based) -- use_regex: Set to "true" to treat search as a regex pattern (default: false) -- ignore_case: Set to "true" to ignore case when matching (default: false) - -Notes: -- When use_regex is true, the search parameter is treated as a regular expression pattern -- When ignore_case is true, the search is case-insensitive regardless of regex mode - -Examples: - -1. Simple text replacement: - -example.ts -oldText -newText - - -2. Case-insensitive regex pattern: - -example.ts -old\w+ -new$& -true -true -` -} diff --git a/src/core/tools/searchAndReplaceTool.ts b/src/core/tools/searchAndReplaceTool.ts deleted file mode 100644 index b0ee3947e1e..00000000000 --- a/src/core/tools/searchAndReplaceTool.ts +++ /dev/null @@ -1,282 +0,0 @@ -// Core Node.js imports -import path from "path" -import fs from "fs/promises" -import delay from "delay" - -// Internal imports -import { Task } from "../task/Task" -import { AskApproval, HandleError, PushToolResult, RemoveClosingTag, ToolUse } from "../../shared/tools" -import { formatResponse } from "../prompts/responses" -import { ClineSayTool } from "../../shared/ExtensionMessage" -import { getReadablePath } from "../../utils/path" -import { fileExistsAtPath } from "../../utils/fs" -import { RecordSource } from "../context-tracking/FileContextTrackerTypes" -import { DEFAULT_WRITE_DELAY_MS } from "@roo-code/types" -import { EXPERIMENT_IDS, experiments } from "../../shared/experiments" - -/** - * Tool for performing search and replace operations on files - * Supports regex and case-sensitive/insensitive matching - */ - -/** - * Validates required parameters for search and replace operation - */ -async function validateParams( - cline: Task, - relPath: string | undefined, - search: string | undefined, - replace: string | undefined, - pushToolResult: PushToolResult, -): Promise { - if (!relPath) { - cline.consecutiveMistakeCount++ - cline.recordToolError("search_and_replace") - pushToolResult(await cline.sayAndCreateMissingParamError("search_and_replace", "path")) - return false - } - - if (!search) { - cline.consecutiveMistakeCount++ - cline.recordToolError("search_and_replace") - pushToolResult(await cline.sayAndCreateMissingParamError("search_and_replace", "search")) - return false - } - - if (replace === undefined) { - cline.consecutiveMistakeCount++ - cline.recordToolError("search_and_replace") - pushToolResult(await cline.sayAndCreateMissingParamError("search_and_replace", "replace")) - return false - } - - return true -} - -/** - * Performs search and replace operations on a file - * @param cline - Cline instance - * @param block - Tool use parameters - * @param askApproval - Function to request user approval - * @param handleError - Function to handle errors - * @param pushToolResult - Function to push tool results - * @param removeClosingTag - Function to remove closing tags - */ -export async function searchAndReplaceTool( - cline: Task, - block: ToolUse, - askApproval: AskApproval, - handleError: HandleError, - pushToolResult: PushToolResult, - removeClosingTag: RemoveClosingTag, -): Promise { - // Extract and validate parameters - const relPath: string | undefined = block.params.path - const search: string | undefined = block.params.search - const replace: string | undefined = block.params.replace - const useRegex: boolean = block.params.use_regex === "true" - const ignoreCase: boolean = block.params.ignore_case === "true" - const startLine: number | undefined = block.params.start_line ? parseInt(block.params.start_line, 10) : undefined - const endLine: number | undefined = block.params.end_line ? parseInt(block.params.end_line, 10) : undefined - - try { - // Handle partial tool use - if (block.partial) { - const partialMessageProps = { - tool: "searchAndReplace" as const, - path: getReadablePath(cline.cwd, removeClosingTag("path", relPath)), - search: removeClosingTag("search", search), - replace: removeClosingTag("replace", replace), - useRegex: block.params.use_regex === "true", - ignoreCase: block.params.ignore_case === "true", - startLine, - endLine, - } - await cline.ask("tool", JSON.stringify(partialMessageProps), block.partial).catch(() => {}) - return - } - - // Validate required parameters - if (!(await validateParams(cline, relPath, search, replace, pushToolResult))) { - return - } - - // At this point we know relPath, search and replace are defined - const validRelPath = relPath as string - const validSearch = search as string - const validReplace = replace as string - - const sharedMessageProps: ClineSayTool = { - tool: "searchAndReplace", - path: getReadablePath(cline.cwd, validRelPath), - search: validSearch, - replace: validReplace, - useRegex: useRegex, - ignoreCase: ignoreCase, - startLine: startLine, - endLine: endLine, - } - - const accessAllowed = cline.rooIgnoreController?.validateAccess(validRelPath) - - if (!accessAllowed) { - await cline.say("rooignore_error", validRelPath) - pushToolResult(formatResponse.toolError(formatResponse.rooIgnoreError(validRelPath))) - return - } - - // Check if file is write-protected - const isWriteProtected = cline.rooProtectedController?.isWriteProtected(validRelPath) || false - - const absolutePath = path.resolve(cline.cwd, validRelPath) - const fileExists = await fileExistsAtPath(absolutePath) - - if (!fileExists) { - cline.consecutiveMistakeCount++ - cline.recordToolError("search_and_replace") - const formattedError = formatResponse.toolError( - `File does not exist at path: ${absolutePath}\nThe specified file could not be found. Please verify the file path and try again.`, - ) - await cline.say("error", formattedError) - pushToolResult(formattedError) - return - } - - // Reset consecutive mistakes since all validations passed - cline.consecutiveMistakeCount = 0 - - // Read and process file content - let fileContent: string - try { - fileContent = await fs.readFile(absolutePath, "utf-8") - } catch (error) { - cline.consecutiveMistakeCount++ - cline.recordToolError("search_and_replace") - const errorMessage = `Error reading file: ${absolutePath}\nFailed to read the file content: ${ - error instanceof Error ? error.message : String(error) - }\nPlease verify file permissions and try again.` - const formattedError = formatResponse.toolError(errorMessage) - await cline.say("error", formattedError) - pushToolResult(formattedError) - return - } - - // Create search pattern and perform replacement - const flags = ignoreCase ? "gi" : "g" - const searchPattern = useRegex ? new RegExp(validSearch, flags) : new RegExp(escapeRegExp(validSearch), flags) - - let newContent: string - if (startLine !== undefined || endLine !== undefined) { - // Handle line-specific replacement - const lines = fileContent.split("\n") - const start = Math.max((startLine ?? 1) - 1, 0) - const end = Math.min((endLine ?? lines.length) - 1, lines.length - 1) - - // Get content before and after target section - const beforeLines = lines.slice(0, start) - const afterLines = lines.slice(end + 1) - - // Get and modify target section - const targetContent = lines.slice(start, end + 1).join("\n") - const modifiedContent = targetContent.replace(searchPattern, validReplace) - const modifiedLines = modifiedContent.split("\n") - - // Reconstruct full content - newContent = [...beforeLines, ...modifiedLines, ...afterLines].join("\n") - } else { - // Global replacement - newContent = fileContent.replace(searchPattern, validReplace) - } - - // Initialize diff view - cline.diffViewProvider.editType = "modify" - cline.diffViewProvider.originalContent = fileContent - - // Generate and validate diff - const diff = formatResponse.createPrettyPatch(validRelPath, fileContent, newContent) - if (!diff) { - pushToolResult(`No changes needed for '${relPath}'`) - await cline.diffViewProvider.reset() - return - } - - // Check if preventFocusDisruption experiment is enabled - const provider = cline.providerRef.deref() - const state = await provider?.getState() - const diagnosticsEnabled = state?.diagnosticsEnabled ?? true - const writeDelayMs = state?.writeDelayMs ?? DEFAULT_WRITE_DELAY_MS - const isPreventFocusDisruptionEnabled = experiments.isEnabled( - state?.experiments ?? {}, - EXPERIMENT_IDS.PREVENT_FOCUS_DISRUPTION, - ) - - const completeMessage = JSON.stringify({ - ...sharedMessageProps, - diff, - isProtected: isWriteProtected, - } satisfies ClineSayTool) - - // Show diff view if focus disruption prevention is disabled - if (!isPreventFocusDisruptionEnabled) { - await cline.diffViewProvider.open(validRelPath) - await cline.diffViewProvider.update(newContent, true) - cline.diffViewProvider.scrollToFirstDiff() - } - - const didApprove = await askApproval("tool", completeMessage, undefined, isWriteProtected) - - if (!didApprove) { - // Revert changes if diff view was shown - if (!isPreventFocusDisruptionEnabled) { - await cline.diffViewProvider.revertChanges() - } - pushToolResult("Changes were rejected by the user.") - await cline.diffViewProvider.reset() - return - } - - // Save the changes - if (isPreventFocusDisruptionEnabled) { - // Direct file write without diff view or opening the file - await cline.diffViewProvider.saveDirectly(validRelPath, newContent, false, diagnosticsEnabled, writeDelayMs) - } else { - // Call saveChanges to update the DiffViewProvider properties - await cline.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs) - } - - // Track file edit operation - if (relPath) { - await cline.fileContextTracker.trackFileContext(relPath, "roo_edited" as RecordSource) - } - - cline.didEditFile = true - - // Get the formatted response message - const message = await cline.diffViewProvider.pushToolWriteResult( - cline, - cline.cwd, - false, // Always false for search_and_replace - ) - - pushToolResult(message) - - // Record successful tool usage and cleanup - cline.recordToolUsage("search_and_replace") - await cline.diffViewProvider.reset() - - // Process any queued messages after file edit completes - cline.processQueuedMessages() - } catch (error) { - handleError("search and replace", error) - await cline.diffViewProvider.reset() - } -} - -/** - * Escapes special regex characters in a string - * @param input String to escape regex characters in - * @returns Escaped string safe for regex pattern matching - */ -function escapeRegExp(input: string): string { - return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") -} diff --git a/src/shared/__tests__/modes.spec.ts b/src/shared/__tests__/modes.spec.ts index 52e4424d8db..0ec6554fe2f 100644 --- a/src/shared/__tests__/modes.spec.ts +++ b/src/shared/__tests__/modes.spec.ts @@ -246,16 +246,7 @@ describe("isToolAllowedForMode", () => { expect(isToolAllowedForMode("use_mcp_tool", "architect", [])).toBe(true) }) - it("applies restrictions to all edit tools including search_and_replace and insert_content", () => { - // Test search_and_replace with matching file - expect( - isToolAllowedForMode("search_and_replace", "architect", [], undefined, { - path: "test.md", - search: "old text", - replace: "new text", - }), - ).toBe(true) - + it("applies restrictions to insert_content edit tool", () => { // Test insert_content with matching file expect( isToolAllowedForMode("insert_content", "architect", [], undefined, { @@ -265,22 +256,6 @@ describe("isToolAllowedForMode", () => { }), ).toBe(true) - // Test search_and_replace with non-matching file - should throw error - expect(() => - isToolAllowedForMode("search_and_replace", "architect", [], undefined, { - path: "test.py", - search: "old text", - replace: "new text", - }), - ).toThrow(FileRestrictionError) - expect(() => - isToolAllowedForMode("search_and_replace", "architect", [], undefined, { - path: "test.py", - search: "old text", - replace: "new text", - }), - ).toThrow(/Markdown files only/) - // Test insert_content with non-matching file - should throw error expect(() => isToolAllowedForMode("insert_content", "architect", [], undefined, { diff --git a/src/shared/tools.ts b/src/shared/tools.ts index 608b50752e7..61e84027272 100644 --- a/src/shared/tools.ts +++ b/src/shared/tools.ts @@ -55,15 +55,10 @@ export const toolParamNames = [ "follow_up", "task", "size", - "search", - "replace", - "use_regex", - "ignore_case", + "query", "args", "start_line", "end_line", - "query", - "args", "todos", "prompt", "image", @@ -165,12 +160,6 @@ export interface RunSlashCommandToolUse extends ToolUse { params: Partial, "command" | "args">> } -export interface SearchAndReplaceToolUse extends ToolUse { - name: "search_and_replace" - params: Required, "path" | "search" | "replace">> & - Partial, "use_regex" | "ignore_case" | "start_line" | "end_line">> -} - export interface GenerateImageToolUse extends ToolUse { name: "generate_image" params: Partial, "prompt" | "path" | "image">> @@ -199,7 +188,6 @@ export const TOOL_DISPLAY_NAMES: Record = { switch_mode: "switch modes", new_task: "create new task", insert_content: "insert content", - search_and_replace: "search and replace", codebase_search: "codebase search", update_todo_list: "update todo list", run_slash_command: "run slash command", @@ -219,7 +207,7 @@ export const TOOL_GROUPS: Record = { ], }, edit: { - tools: ["apply_diff", "write_to_file", "insert_content", "search_and_replace", "generate_image"], + tools: ["apply_diff", "write_to_file", "insert_content", "generate_image"], }, browser: { tools: ["browser_action"], From 9b993efe10be1e2b4c9635b5b92b9c7e0cc0910c Mon Sep 17 00:00:00 2001 From: Roo Code Date: Tue, 28 Oct 2025 19:08:38 +0000 Subject: [PATCH 2/7] test: update snapshots after removing search_and_replace tool --- .../architect-mode-prompt.snap | 39 +------------------ .../ask-mode-prompt.snap | 3 +- .../mcp-server-creation-disabled.snap | 39 +------------------ .../mcp-server-creation-enabled.snap | 39 +------------------ .../partial-reads-enabled.snap | 39 +------------------ .../consistent-system-prompt.snap | 39 +------------------ .../with-computer-use-support.snap | 39 +------------------ .../with-diff-enabled-false.snap | 39 +------------------ .../system-prompt/with-diff-enabled-true.snap | 39 +------------------ .../with-diff-enabled-undefined.snap | 39 +------------------ .../with-different-viewport-size.snap | 39 +------------------ .../system-prompt/with-mcp-hub-provided.snap | 39 +------------------ .../system-prompt/with-undefined-mcp-hub.snap | 39 +------------------ 13 files changed, 13 insertions(+), 458 deletions(-) diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/architect-mode-prompt.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/architect-mode-prompt.snap index aa928fd50cf..f9fc5027649 100644 --- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/architect-mode-prompt.snap +++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/architect-mode-prompt.snap @@ -226,42 +226,6 @@ Example for appending to the end of file: -## search_and_replace -Description: Use this tool to find and replace specific text strings or patterns (using regex) within a file. It's suitable for targeted replacements across multiple locations within the file. Supports literal text and regex patterns, case sensitivity options, and optional line ranges. Shows a diff preview before applying changes. - -Required Parameters: -- path: The path of the file to modify (relative to the current workspace directory /test/path) -- search: The text or pattern to search for -- replace: The text to replace matches with - -Optional Parameters: -- start_line: Starting line number for restricted replacement (1-based) -- end_line: Ending line number for restricted replacement (1-based) -- use_regex: Set to "true" to treat search as a regex pattern (default: false) -- ignore_case: Set to "true" to ignore case when matching (default: false) - -Notes: -- When use_regex is true, the search parameter is treated as a regular expression pattern -- When ignore_case is true, the search is case-insensitive regardless of regex mode - -Examples: - -1. Simple text replacement: - -example.ts -oldText -newText - - -2. Case-insensitive regex pattern: - -example.ts -oldw+ -new$& -true -true - - ## ask_followup_question Description: Ask the user a question to gather additional information needed to complete the task. Use when you need clarification or more details to proceed effectively. @@ -465,9 +429,8 @@ RULES - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with `cd`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run `npm install` in a project outside of '/test/path', you would need to prepend with a `cd` i.e. pseudocode for this would be `cd (path to project) && (command, in this case npm install)`. - When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes. - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser. -- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files), search_and_replace (for finding and replacing individual pieces of text). +- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files). - The insert_content tool adds lines of text to files at a specific line number, such as adding a new function to a JavaScript file or inserting a new route in a Python file. Use line number 0 to append at the end of the file, or any positive number to insert before that line. -- The search_and_replace tool finds and replaces text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text. It can support multiple operations at once. - You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files. - When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project. - Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode. diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/ask-mode-prompt.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/ask-mode-prompt.snap index 07dc1ff9de1..059f98d73b3 100644 --- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/ask-mode-prompt.snap +++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/ask-mode-prompt.snap @@ -362,9 +362,8 @@ RULES - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with `cd`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run `npm install` in a project outside of '/test/path', you would need to prepend with a `cd` i.e. pseudocode for this would be `cd (path to project) && (command, in this case npm install)`. - When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes. - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser. -- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files), search_and_replace (for finding and replacing individual pieces of text). +- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files). - The insert_content tool adds lines of text to files at a specific line number, such as adding a new function to a JavaScript file or inserting a new route in a Python file. Use line number 0 to append at the end of the file, or any positive number to insert before that line. -- The search_and_replace tool finds and replaces text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text. It can support multiple operations at once. - You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files. - When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project. - Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode. diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-disabled.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-disabled.snap index 300c7a3565e..e45deefb6a4 100644 --- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-disabled.snap +++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-disabled.snap @@ -225,42 +225,6 @@ Example for appending to the end of file: -## search_and_replace -Description: Use this tool to find and replace specific text strings or patterns (using regex) within a file. It's suitable for targeted replacements across multiple locations within the file. Supports literal text and regex patterns, case sensitivity options, and optional line ranges. Shows a diff preview before applying changes. - -Required Parameters: -- path: The path of the file to modify (relative to the current workspace directory /test/path) -- search: The text or pattern to search for -- replace: The text to replace matches with - -Optional Parameters: -- start_line: Starting line number for restricted replacement (1-based) -- end_line: Ending line number for restricted replacement (1-based) -- use_regex: Set to "true" to treat search as a regex pattern (default: false) -- ignore_case: Set to "true" to ignore case when matching (default: false) - -Notes: -- When use_regex is true, the search parameter is treated as a regular expression pattern -- When ignore_case is true, the search is case-insensitive regardless of regex mode - -Examples: - -1. Simple text replacement: - -example.ts -oldText -newText - - -2. Case-insensitive regex pattern: - -example.ts -oldw+ -new$& -true -true - - ## ask_followup_question Description: Ask the user a question to gather additional information needed to complete the task. Use when you need clarification or more details to proceed effectively. @@ -464,9 +428,8 @@ RULES - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with `cd`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run `npm install` in a project outside of '/test/path', you would need to prepend with a `cd` i.e. pseudocode for this would be `cd (path to project) && (command, in this case npm install)`. - When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes. - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser. -- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files), search_and_replace (for finding and replacing individual pieces of text). +- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files). - The insert_content tool adds lines of text to files at a specific line number, such as adding a new function to a JavaScript file or inserting a new route in a Python file. Use line number 0 to append at the end of the file, or any positive number to insert before that line. -- The search_and_replace tool finds and replaces text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text. It can support multiple operations at once. - You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files. - When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project. - Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode. diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap index ec5304a2b2a..a6afbec4065 100644 --- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap +++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap @@ -226,42 +226,6 @@ Example for appending to the end of file: -## search_and_replace -Description: Use this tool to find and replace specific text strings or patterns (using regex) within a file. It's suitable for targeted replacements across multiple locations within the file. Supports literal text and regex patterns, case sensitivity options, and optional line ranges. Shows a diff preview before applying changes. - -Required Parameters: -- path: The path of the file to modify (relative to the current workspace directory /test/path) -- search: The text or pattern to search for -- replace: The text to replace matches with - -Optional Parameters: -- start_line: Starting line number for restricted replacement (1-based) -- end_line: Ending line number for restricted replacement (1-based) -- use_regex: Set to "true" to treat search as a regex pattern (default: false) -- ignore_case: Set to "true" to ignore case when matching (default: false) - -Notes: -- When use_regex is true, the search parameter is treated as a regular expression pattern -- When ignore_case is true, the search is case-insensitive regardless of regex mode - -Examples: - -1. Simple text replacement: - -example.ts -oldText -newText - - -2. Case-insensitive regex pattern: - -example.ts -oldw+ -new$& -true -true - - ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. Parameters: @@ -533,9 +497,8 @@ RULES - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with `cd`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run `npm install` in a project outside of '/test/path', you would need to prepend with a `cd` i.e. pseudocode for this would be `cd (path to project) && (command, in this case npm install)`. - When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes. - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser. -- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files), search_and_replace (for finding and replacing individual pieces of text). +- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files). - The insert_content tool adds lines of text to files at a specific line number, such as adding a new function to a JavaScript file or inserting a new route in a Python file. Use line number 0 to append at the end of the file, or any positive number to insert before that line. -- The search_and_replace tool finds and replaces text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text. It can support multiple operations at once. - You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files. - When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project. - Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode. diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/partial-reads-enabled.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/partial-reads-enabled.snap index bf584f2691c..0956dcde382 100644 --- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/partial-reads-enabled.snap +++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/partial-reads-enabled.snap @@ -231,42 +231,6 @@ Example for appending to the end of file: -## search_and_replace -Description: Use this tool to find and replace specific text strings or patterns (using regex) within a file. It's suitable for targeted replacements across multiple locations within the file. Supports literal text and regex patterns, case sensitivity options, and optional line ranges. Shows a diff preview before applying changes. - -Required Parameters: -- path: The path of the file to modify (relative to the current workspace directory /test/path) -- search: The text or pattern to search for -- replace: The text to replace matches with - -Optional Parameters: -- start_line: Starting line number for restricted replacement (1-based) -- end_line: Ending line number for restricted replacement (1-based) -- use_regex: Set to "true" to treat search as a regex pattern (default: false) -- ignore_case: Set to "true" to ignore case when matching (default: false) - -Notes: -- When use_regex is true, the search parameter is treated as a regular expression pattern -- When ignore_case is true, the search is case-insensitive regardless of regex mode - -Examples: - -1. Simple text replacement: - -example.ts -oldText -newText - - -2. Case-insensitive regex pattern: - -example.ts -oldw+ -new$& -true -true - - ## ask_followup_question Description: Ask the user a question to gather additional information needed to complete the task. Use when you need clarification or more details to proceed effectively. @@ -470,9 +434,8 @@ RULES - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with `cd`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run `npm install` in a project outside of '/test/path', you would need to prepend with a `cd` i.e. pseudocode for this would be `cd (path to project) && (command, in this case npm install)`. - When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes. - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser. -- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files), search_and_replace (for finding and replacing individual pieces of text). +- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files). - The insert_content tool adds lines of text to files at a specific line number, such as adding a new function to a JavaScript file or inserting a new route in a Python file. Use line number 0 to append at the end of the file, or any positive number to insert before that line. -- The search_and_replace tool finds and replaces text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text. It can support multiple operations at once. - You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files. - When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project. - Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode. diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/consistent-system-prompt.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/consistent-system-prompt.snap index aa928fd50cf..f9fc5027649 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/consistent-system-prompt.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/consistent-system-prompt.snap @@ -226,42 +226,6 @@ Example for appending to the end of file: -## search_and_replace -Description: Use this tool to find and replace specific text strings or patterns (using regex) within a file. It's suitable for targeted replacements across multiple locations within the file. Supports literal text and regex patterns, case sensitivity options, and optional line ranges. Shows a diff preview before applying changes. - -Required Parameters: -- path: The path of the file to modify (relative to the current workspace directory /test/path) -- search: The text or pattern to search for -- replace: The text to replace matches with - -Optional Parameters: -- start_line: Starting line number for restricted replacement (1-based) -- end_line: Ending line number for restricted replacement (1-based) -- use_regex: Set to "true" to treat search as a regex pattern (default: false) -- ignore_case: Set to "true" to ignore case when matching (default: false) - -Notes: -- When use_regex is true, the search parameter is treated as a regular expression pattern -- When ignore_case is true, the search is case-insensitive regardless of regex mode - -Examples: - -1. Simple text replacement: - -example.ts -oldText -newText - - -2. Case-insensitive regex pattern: - -example.ts -oldw+ -new$& -true -true - - ## ask_followup_question Description: Ask the user a question to gather additional information needed to complete the task. Use when you need clarification or more details to proceed effectively. @@ -465,9 +429,8 @@ RULES - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with `cd`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run `npm install` in a project outside of '/test/path', you would need to prepend with a `cd` i.e. pseudocode for this would be `cd (path to project) && (command, in this case npm install)`. - When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes. - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser. -- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files), search_and_replace (for finding and replacing individual pieces of text). +- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files). - The insert_content tool adds lines of text to files at a specific line number, such as adding a new function to a JavaScript file or inserting a new route in a Python file. Use line number 0 to append at the end of the file, or any positive number to insert before that line. -- The search_and_replace tool finds and replaces text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text. It can support multiple operations at once. - You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files. - When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project. - Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode. diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-computer-use-support.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-computer-use-support.snap index 641ec16082e..3420d1d1333 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-computer-use-support.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-computer-use-support.snap @@ -226,42 +226,6 @@ Example for appending to the end of file: -## search_and_replace -Description: Use this tool to find and replace specific text strings or patterns (using regex) within a file. It's suitable for targeted replacements across multiple locations within the file. Supports literal text and regex patterns, case sensitivity options, and optional line ranges. Shows a diff preview before applying changes. - -Required Parameters: -- path: The path of the file to modify (relative to the current workspace directory /test/path) -- search: The text or pattern to search for -- replace: The text to replace matches with - -Optional Parameters: -- start_line: Starting line number for restricted replacement (1-based) -- end_line: Ending line number for restricted replacement (1-based) -- use_regex: Set to "true" to treat search as a regex pattern (default: false) -- ignore_case: Set to "true" to ignore case when matching (default: false) - -Notes: -- When use_regex is true, the search parameter is treated as a regular expression pattern -- When ignore_case is true, the search is case-insensitive regardless of regex mode - -Examples: - -1. Simple text replacement: - -example.ts -oldText -newText - - -2. Case-insensitive regex pattern: - -example.ts -oldw+ -new$& -true -true - - ## browser_action Description: Request to interact with a Puppeteer-controlled browser. Every action, except `close`, will be responded to with a screenshot of the browser's current state, along with any new console logs. You may only perform one browser action per message, and wait for the user's response including a screenshot and logs to determine the next action. - The sequence of actions **must always start with** launching the browser at a URL, and **must always end with** closing the browser. If you need to visit a new URL that is not possible to navigate to from the current webpage, you must first close the browser, then launch again at the new URL. @@ -520,9 +484,8 @@ RULES - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with `cd`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run `npm install` in a project outside of '/test/path', you would need to prepend with a `cd` i.e. pseudocode for this would be `cd (path to project) && (command, in this case npm install)`. - When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes. - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser. -- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files), search_and_replace (for finding and replacing individual pieces of text). +- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files). - The insert_content tool adds lines of text to files at a specific line number, such as adding a new function to a JavaScript file or inserting a new route in a Python file. Use line number 0 to append at the end of the file, or any positive number to insert before that line. -- The search_and_replace tool finds and replaces text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text. It can support multiple operations at once. - You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files. - When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project. - Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode. diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-false.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-false.snap index aa928fd50cf..f9fc5027649 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-false.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-false.snap @@ -226,42 +226,6 @@ Example for appending to the end of file: -## search_and_replace -Description: Use this tool to find and replace specific text strings or patterns (using regex) within a file. It's suitable for targeted replacements across multiple locations within the file. Supports literal text and regex patterns, case sensitivity options, and optional line ranges. Shows a diff preview before applying changes. - -Required Parameters: -- path: The path of the file to modify (relative to the current workspace directory /test/path) -- search: The text or pattern to search for -- replace: The text to replace matches with - -Optional Parameters: -- start_line: Starting line number for restricted replacement (1-based) -- end_line: Ending line number for restricted replacement (1-based) -- use_regex: Set to "true" to treat search as a regex pattern (default: false) -- ignore_case: Set to "true" to ignore case when matching (default: false) - -Notes: -- When use_regex is true, the search parameter is treated as a regular expression pattern -- When ignore_case is true, the search is case-insensitive regardless of regex mode - -Examples: - -1. Simple text replacement: - -example.ts -oldText -newText - - -2. Case-insensitive regex pattern: - -example.ts -oldw+ -new$& -true -true - - ## ask_followup_question Description: Ask the user a question to gather additional information needed to complete the task. Use when you need clarification or more details to proceed effectively. @@ -465,9 +429,8 @@ RULES - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with `cd`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run `npm install` in a project outside of '/test/path', you would need to prepend with a `cd` i.e. pseudocode for this would be `cd (path to project) && (command, in this case npm install)`. - When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes. - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser. -- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files), search_and_replace (for finding and replacing individual pieces of text). +- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files). - The insert_content tool adds lines of text to files at a specific line number, such as adding a new function to a JavaScript file or inserting a new route in a Python file. Use line number 0 to append at the end of the file, or any positive number to insert before that line. -- The search_and_replace tool finds and replaces text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text. It can support multiple operations at once. - You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files. - When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project. - Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode. diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-true.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-true.snap index 154e1f08ae8..530598739c6 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-true.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-true.snap @@ -314,42 +314,6 @@ Example for appending to the end of file: -## search_and_replace -Description: Use this tool to find and replace specific text strings or patterns (using regex) within a file. It's suitable for targeted replacements across multiple locations within the file. Supports literal text and regex patterns, case sensitivity options, and optional line ranges. Shows a diff preview before applying changes. - -Required Parameters: -- path: The path of the file to modify (relative to the current workspace directory /test/path) -- search: The text or pattern to search for -- replace: The text to replace matches with - -Optional Parameters: -- start_line: Starting line number for restricted replacement (1-based) -- end_line: Ending line number for restricted replacement (1-based) -- use_regex: Set to "true" to treat search as a regex pattern (default: false) -- ignore_case: Set to "true" to ignore case when matching (default: false) - -Notes: -- When use_regex is true, the search parameter is treated as a regular expression pattern -- When ignore_case is true, the search is case-insensitive regardless of regex mode - -Examples: - -1. Simple text replacement: - -example.ts -oldText -newText - - -2. Case-insensitive regex pattern: - -example.ts -oldw+ -new$& -true -true - - ## ask_followup_question Description: Ask the user a question to gather additional information needed to complete the task. Use when you need clarification or more details to proceed effectively. @@ -553,9 +517,8 @@ RULES - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with `cd`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run `npm install` in a project outside of '/test/path', you would need to prepend with a `cd` i.e. pseudocode for this would be `cd (path to project) && (command, in this case npm install)`. - When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using apply_diff or write_to_file to make informed changes. - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser. -- For editing files, you have access to these tools: apply_diff (for surgical edits - targeted changes to specific lines or functions), write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files), search_and_replace (for finding and replacing individual pieces of text). +- For editing files, you have access to these tools: apply_diff (for surgical edits - targeted changes to specific lines or functions), write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files). - The insert_content tool adds lines of text to files at a specific line number, such as adding a new function to a JavaScript file or inserting a new route in a Python file. Use line number 0 to append at the end of the file, or any positive number to insert before that line. -- The search_and_replace tool finds and replaces text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text. It can support multiple operations at once. - You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files. - When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project. - Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode. diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-undefined.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-undefined.snap index aa928fd50cf..f9fc5027649 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-undefined.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-diff-enabled-undefined.snap @@ -226,42 +226,6 @@ Example for appending to the end of file: -## search_and_replace -Description: Use this tool to find and replace specific text strings or patterns (using regex) within a file. It's suitable for targeted replacements across multiple locations within the file. Supports literal text and regex patterns, case sensitivity options, and optional line ranges. Shows a diff preview before applying changes. - -Required Parameters: -- path: The path of the file to modify (relative to the current workspace directory /test/path) -- search: The text or pattern to search for -- replace: The text to replace matches with - -Optional Parameters: -- start_line: Starting line number for restricted replacement (1-based) -- end_line: Ending line number for restricted replacement (1-based) -- use_regex: Set to "true" to treat search as a regex pattern (default: false) -- ignore_case: Set to "true" to ignore case when matching (default: false) - -Notes: -- When use_regex is true, the search parameter is treated as a regular expression pattern -- When ignore_case is true, the search is case-insensitive regardless of regex mode - -Examples: - -1. Simple text replacement: - -example.ts -oldText -newText - - -2. Case-insensitive regex pattern: - -example.ts -oldw+ -new$& -true -true - - ## ask_followup_question Description: Ask the user a question to gather additional information needed to complete the task. Use when you need clarification or more details to proceed effectively. @@ -465,9 +429,8 @@ RULES - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with `cd`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run `npm install` in a project outside of '/test/path', you would need to prepend with a `cd` i.e. pseudocode for this would be `cd (path to project) && (command, in this case npm install)`. - When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes. - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser. -- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files), search_and_replace (for finding and replacing individual pieces of text). +- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files). - The insert_content tool adds lines of text to files at a specific line number, such as adding a new function to a JavaScript file or inserting a new route in a Python file. Use line number 0 to append at the end of the file, or any positive number to insert before that line. -- The search_and_replace tool finds and replaces text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text. It can support multiple operations at once. - You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files. - When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project. - Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode. diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-different-viewport-size.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-different-viewport-size.snap index aa928fd50cf..f9fc5027649 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-different-viewport-size.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-different-viewport-size.snap @@ -226,42 +226,6 @@ Example for appending to the end of file: -## search_and_replace -Description: Use this tool to find and replace specific text strings or patterns (using regex) within a file. It's suitable for targeted replacements across multiple locations within the file. Supports literal text and regex patterns, case sensitivity options, and optional line ranges. Shows a diff preview before applying changes. - -Required Parameters: -- path: The path of the file to modify (relative to the current workspace directory /test/path) -- search: The text or pattern to search for -- replace: The text to replace matches with - -Optional Parameters: -- start_line: Starting line number for restricted replacement (1-based) -- end_line: Ending line number for restricted replacement (1-based) -- use_regex: Set to "true" to treat search as a regex pattern (default: false) -- ignore_case: Set to "true" to ignore case when matching (default: false) - -Notes: -- When use_regex is true, the search parameter is treated as a regular expression pattern -- When ignore_case is true, the search is case-insensitive regardless of regex mode - -Examples: - -1. Simple text replacement: - -example.ts -oldText -newText - - -2. Case-insensitive regex pattern: - -example.ts -oldw+ -new$& -true -true - - ## ask_followup_question Description: Ask the user a question to gather additional information needed to complete the task. Use when you need clarification or more details to proceed effectively. @@ -465,9 +429,8 @@ RULES - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with `cd`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run `npm install` in a project outside of '/test/path', you would need to prepend with a `cd` i.e. pseudocode for this would be `cd (path to project) && (command, in this case npm install)`. - When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes. - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser. -- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files), search_and_replace (for finding and replacing individual pieces of text). +- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files). - The insert_content tool adds lines of text to files at a specific line number, such as adding a new function to a JavaScript file or inserting a new route in a Python file. Use line number 0 to append at the end of the file, or any positive number to insert before that line. -- The search_and_replace tool finds and replaces text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text. It can support multiple operations at once. - You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files. - When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project. - Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode. diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap index ec5304a2b2a..a6afbec4065 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap @@ -226,42 +226,6 @@ Example for appending to the end of file: -## search_and_replace -Description: Use this tool to find and replace specific text strings or patterns (using regex) within a file. It's suitable for targeted replacements across multiple locations within the file. Supports literal text and regex patterns, case sensitivity options, and optional line ranges. Shows a diff preview before applying changes. - -Required Parameters: -- path: The path of the file to modify (relative to the current workspace directory /test/path) -- search: The text or pattern to search for -- replace: The text to replace matches with - -Optional Parameters: -- start_line: Starting line number for restricted replacement (1-based) -- end_line: Ending line number for restricted replacement (1-based) -- use_regex: Set to "true" to treat search as a regex pattern (default: false) -- ignore_case: Set to "true" to ignore case when matching (default: false) - -Notes: -- When use_regex is true, the search parameter is treated as a regular expression pattern -- When ignore_case is true, the search is case-insensitive regardless of regex mode - -Examples: - -1. Simple text replacement: - -example.ts -oldText -newText - - -2. Case-insensitive regex pattern: - -example.ts -oldw+ -new$& -true -true - - ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. Parameters: @@ -533,9 +497,8 @@ RULES - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with `cd`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run `npm install` in a project outside of '/test/path', you would need to prepend with a `cd` i.e. pseudocode for this would be `cd (path to project) && (command, in this case npm install)`. - When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes. - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser. -- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files), search_and_replace (for finding and replacing individual pieces of text). +- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files). - The insert_content tool adds lines of text to files at a specific line number, such as adding a new function to a JavaScript file or inserting a new route in a Python file. Use line number 0 to append at the end of the file, or any positive number to insert before that line. -- The search_and_replace tool finds and replaces text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text. It can support multiple operations at once. - You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files. - When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project. - Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode. diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-undefined-mcp-hub.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-undefined-mcp-hub.snap index aa928fd50cf..f9fc5027649 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-undefined-mcp-hub.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-undefined-mcp-hub.snap @@ -226,42 +226,6 @@ Example for appending to the end of file: -## search_and_replace -Description: Use this tool to find and replace specific text strings or patterns (using regex) within a file. It's suitable for targeted replacements across multiple locations within the file. Supports literal text and regex patterns, case sensitivity options, and optional line ranges. Shows a diff preview before applying changes. - -Required Parameters: -- path: The path of the file to modify (relative to the current workspace directory /test/path) -- search: The text or pattern to search for -- replace: The text to replace matches with - -Optional Parameters: -- start_line: Starting line number for restricted replacement (1-based) -- end_line: Ending line number for restricted replacement (1-based) -- use_regex: Set to "true" to treat search as a regex pattern (default: false) -- ignore_case: Set to "true" to ignore case when matching (default: false) - -Notes: -- When use_regex is true, the search parameter is treated as a regular expression pattern -- When ignore_case is true, the search is case-insensitive regardless of regex mode - -Examples: - -1. Simple text replacement: - -example.ts -oldText -newText - - -2. Case-insensitive regex pattern: - -example.ts -oldw+ -new$& -true -true - - ## ask_followup_question Description: Ask the user a question to gather additional information needed to complete the task. Use when you need clarification or more details to proceed effectively. @@ -465,9 +429,8 @@ RULES - Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '/test/path', and if so prepend with `cd`'ing into that directory && then executing the command (as one command since you are stuck operating from '/test/path'). For example, if you needed to run `npm install` in a project outside of '/test/path', you would need to prepend with a `cd` i.e. pseudocode for this would be `cd (path to project) && (command, in this case npm install)`. - When using the search_files tool, craft your regex patterns carefully to balance specificity and flexibility. Based on the user's task you may use it to find code patterns, TODO comments, function definitions, or any text-based information across the project. The results include context, so analyze the surrounding code to better understand the matches. Leverage the search_files tool in combination with other tools for more comprehensive analysis. For example, use it to find specific code patterns, then use read_file to examine the full context of interesting matches before using write_to_file to make informed changes. - When creating a new project (such as an app, website, or any software project), organize all new files within a dedicated project directory unless the user specifies otherwise. Use appropriate file paths when writing files, as the write_to_file tool will automatically create any necessary directories. Structure the project logically, adhering to best practices for the specific type of project being created. Unless otherwise specified, new projects should be easily run without additional setup, for example most projects can be built in HTML, CSS, and JavaScript - which you can open in a browser. -- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files), search_and_replace (for finding and replacing individual pieces of text). +- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), insert_content (for adding lines to files). - The insert_content tool adds lines of text to files at a specific line number, such as adding a new function to a JavaScript file or inserting a new route in a Python file. Use line number 0 to append at the end of the file, or any positive number to insert before that line. -- The search_and_replace tool finds and replaces text or regex in files. This tool allows you to search for a specific regex pattern or text and replace it with another value. Be cautious when using this tool to ensure you are replacing the correct text. It can support multiple operations at once. - You should always prefer using other editing tools over write_to_file when making changes to existing files since write_to_file is much slower and cannot handle large files. - When using the write_to_file tool to modify a file, use the tool directly with the desired content. You do not need to display the content before using the tool. ALWAYS provide the COMPLETE file content in your response. This is NON-NEGOTIABLE. Partial updates or placeholders like '// rest of code unchanged' are STRICTLY FORBIDDEN. You MUST include ALL parts of the file, even if they haven't been modified. Failure to do so will result in incomplete or broken code, severely impacting the user's project. - Some modes have restrictions on which files they can edit. If you attempt to edit a restricted file, the operation will be rejected with a FileRestrictionError that will specify which file patterns are allowed for the current mode. From 7d42021fdfeaef018106caa4d9f59323dd528374 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Tue, 28 Oct 2025 19:18:14 +0000 Subject: [PATCH 3/7] fix: remove remaining search_and_replace references from localization and ExtensionMessage --- src/shared/ExtensionMessage.ts | 1 - webview-ui/src/i18n/locales/ca/settings.json | 4 ---- webview-ui/src/i18n/locales/de/settings.json | 4 ---- webview-ui/src/i18n/locales/en/chat.json | 2 -- webview-ui/src/i18n/locales/en/settings.json | 4 ---- webview-ui/src/i18n/locales/es/settings.json | 4 ---- webview-ui/src/i18n/locales/fr/settings.json | 4 ---- webview-ui/src/i18n/locales/hi/settings.json | 4 ---- webview-ui/src/i18n/locales/id/settings.json | 4 ---- webview-ui/src/i18n/locales/it/settings.json | 4 ---- webview-ui/src/i18n/locales/ja/settings.json | 4 ---- webview-ui/src/i18n/locales/ko/settings.json | 4 ---- webview-ui/src/i18n/locales/nl/settings.json | 4 ---- webview-ui/src/i18n/locales/pl/settings.json | 4 ---- webview-ui/src/i18n/locales/pt-BR/settings.json | 4 ---- webview-ui/src/i18n/locales/ru/settings.json | 4 ---- webview-ui/src/i18n/locales/tr/settings.json | 4 ---- webview-ui/src/i18n/locales/vi/settings.json | 4 ---- webview-ui/src/i18n/locales/zh-CN/settings.json | 4 ---- webview-ui/src/i18n/locales/zh-TW/settings.json | 4 ---- 20 files changed, 75 deletions(-) diff --git a/src/shared/ExtensionMessage.ts b/src/shared/ExtensionMessage.ts index 5929e7a950e..ab1386a358b 100644 --- a/src/shared/ExtensionMessage.ts +++ b/src/shared/ExtensionMessage.ts @@ -379,7 +379,6 @@ export interface ClineSayTool { | "switchMode" | "newTask" | "finishTask" - | "searchAndReplace" | "insertContent" | "generateImage" | "imageGenerated" diff --git a/webview-ui/src/i18n/locales/ca/settings.json b/webview-ui/src/i18n/locales/ca/settings.json index c97345f5e46..72335d48c40 100644 --- a/webview-ui/src/i18n/locales/ca/settings.json +++ b/webview-ui/src/i18n/locales/ca/settings.json @@ -713,10 +713,6 @@ "name": "Utilitzar estratègia diff unificada experimental", "description": "Activar l'estratègia diff unificada experimental. Aquesta estratègia podria reduir el nombre de reintents causats per errors del model, però pot causar comportaments inesperats o edicions incorrectes. Activeu-la només si enteneu els riscos i esteu disposats a revisar acuradament tots els canvis." }, - "SEARCH_AND_REPLACE": { - "name": "Utilitzar eina de cerca i reemplaçament experimental", - "description": "Activar l'eina de cerca i reemplaçament experimental, permetent a Roo reemplaçar múltiples instàncies d'un terme de cerca en una sola petició." - }, "INSERT_BLOCK": { "name": "Utilitzar eina d'inserció de contingut experimental", "description": "Activar l'eina d'inserció de contingut experimental, permetent a Roo inserir contingut a números de línia específics sense necessitat de crear un diff." diff --git a/webview-ui/src/i18n/locales/de/settings.json b/webview-ui/src/i18n/locales/de/settings.json index 7588982b368..fb9cd75754e 100644 --- a/webview-ui/src/i18n/locales/de/settings.json +++ b/webview-ui/src/i18n/locales/de/settings.json @@ -713,10 +713,6 @@ "name": "Experimentelle einheitliche Diff-Strategie verwenden", "description": "Aktiviere die experimentelle einheitliche Diff-Strategie. Diese Strategie könnte die Anzahl der durch Modellfehler verursachten Wiederholungsversuche reduzieren, kann aber zu unerwartetem Verhalten oder falschen Bearbeitungen führen. Aktiviere sie nur, wenn du die Risiken verstehst und bereit bist, alle Änderungen sorgfältig zu überprüfen." }, - "SEARCH_AND_REPLACE": { - "name": "Experimentelles Such- und Ersetzungswerkzeug verwenden", - "description": "Aktiviere das experimentelle Such- und Ersetzungswerkzeug, mit dem Roo mehrere Instanzen eines Suchbegriffs in einer Anfrage ersetzen kann." - }, "INSERT_BLOCK": { "name": "Experimentelles Inhalts-Einfügewerkzeug verwenden", "description": "Aktiviere das experimentelle Inhalts-Einfügewerkzeug, mit dem Roo Inhalte an bestimmten Zeilennummern einfügen kann, ohne einen Diff erstellen zu müssen." diff --git a/webview-ui/src/i18n/locales/en/chat.json b/webview-ui/src/i18n/locales/en/chat.json index 6e2cf84f895..a061626a4d2 100644 --- a/webview-ui/src/i18n/locales/en/chat.json +++ b/webview-ui/src/i18n/locales/en/chat.json @@ -192,8 +192,6 @@ "wantsToGenerateImageProtected": "Roo wants to generate an image in a protected location", "didGenerateImage": "Roo generated an image", "wantsToCreate": "Roo wants to create a new file", - "wantsToSearchReplace": "Roo wants to search and replace in this file", - "didSearchReplace": "Roo performed search and replace on this file", "wantsToInsert": "Roo wants to insert content into this file", "wantsToInsertWithLineNumber": "Roo wants to insert content into this file at line {{lineNumber}}", "wantsToInsertAtEnd": "Roo wants to append content to the end of this file" diff --git a/webview-ui/src/i18n/locales/en/settings.json b/webview-ui/src/i18n/locales/en/settings.json index 789452fadcf..8292d24ae74 100644 --- a/webview-ui/src/i18n/locales/en/settings.json +++ b/webview-ui/src/i18n/locales/en/settings.json @@ -718,10 +718,6 @@ "name": "Use experimental unified diff strategy", "description": "Enable the experimental unified diff strategy. This strategy might reduce the number of retries caused by model errors but may cause unexpected behavior or incorrect edits. Only enable if you understand the risks and are willing to carefully review all changes." }, - "SEARCH_AND_REPLACE": { - "name": "Use experimental search and replace tool", - "description": "Enable the experimental search and replace tool, allowing Roo to replace multiple instances of a search term in one request." - }, "INSERT_BLOCK": { "name": "Use experimental insert content tool", "description": "Enable the experimental insert content tool, allowing Roo to insert content at specific line numbers without needing to create a diff." diff --git a/webview-ui/src/i18n/locales/es/settings.json b/webview-ui/src/i18n/locales/es/settings.json index fa5ce550e85..5bc3ff683b6 100644 --- a/webview-ui/src/i18n/locales/es/settings.json +++ b/webview-ui/src/i18n/locales/es/settings.json @@ -713,10 +713,6 @@ "name": "Usar estrategia de diff unificada experimental", "description": "Habilitar la estrategia de diff unificada experimental. Esta estrategia podría reducir el número de reintentos causados por errores del modelo, pero puede causar comportamientos inesperados o ediciones incorrectas. Habilítela solo si comprende los riesgos y está dispuesto a revisar cuidadosamente todos los cambios." }, - "SEARCH_AND_REPLACE": { - "name": "Usar herramienta experimental de búsqueda y reemplazo", - "description": "Habilitar la herramienta experimental de búsqueda y reemplazo, permitiendo a Roo reemplazar múltiples instancias de un término de búsqueda en una sola solicitud." - }, "INSERT_BLOCK": { "name": "Usar herramienta experimental de inserción de contenido", "description": "Habilitar la herramienta experimental de inserción de contenido, permitiendo a Roo insertar contenido en números de línea específicos sin necesidad de crear un diff." diff --git a/webview-ui/src/i18n/locales/fr/settings.json b/webview-ui/src/i18n/locales/fr/settings.json index d1c2ccd40f8..9a5c655d648 100644 --- a/webview-ui/src/i18n/locales/fr/settings.json +++ b/webview-ui/src/i18n/locales/fr/settings.json @@ -713,10 +713,6 @@ "name": "Utiliser la stratégie diff unifiée expérimentale", "description": "Activer la stratégie diff unifiée expérimentale. Cette stratégie pourrait réduire le nombre de tentatives causées par des erreurs de modèle, mais peut provoquer des comportements inattendus ou des modifications incorrectes. Activez-la uniquement si vous comprenez les risques et êtes prêt à examiner attentivement tous les changements." }, - "SEARCH_AND_REPLACE": { - "name": "Utiliser l'outil de recherche et remplacement expérimental", - "description": "Activer l'outil de recherche et remplacement expérimental, permettant à Roo de remplacer plusieurs occurrences d'un terme de recherche en une seule requête." - }, "INSERT_BLOCK": { "name": "Utiliser l'outil d'insertion de contenu expérimental", "description": "Activer l'outil d'insertion de contenu expérimental, permettant à Roo d'insérer du contenu à des numéros de ligne spécifiques sans avoir besoin de créer un diff." diff --git a/webview-ui/src/i18n/locales/hi/settings.json b/webview-ui/src/i18n/locales/hi/settings.json index bcc45d5db75..9e490f82712 100644 --- a/webview-ui/src/i18n/locales/hi/settings.json +++ b/webview-ui/src/i18n/locales/hi/settings.json @@ -714,10 +714,6 @@ "name": "प्रायोगिक एकीकृत diff रणनीति का उपयोग करें", "description": "प्रायोगिक एकीकृत diff रणनीति सक्षम करें। यह रणनीति मॉडल त्रुटियों के कारण पुनः प्रयासों की संख्या को कम कर सकती है, लेकिन अप्रत्याशित व्यवहार या गलत संपादन का कारण बन सकती है। केवल तभी सक्षम करें जब आप जोखिमों को समझते हों और सभी परिवर्तनों की सावधानीपूर्वक समीक्षा करने के लिए तैयार हों।" }, - "SEARCH_AND_REPLACE": { - "name": "प्रायोगिक खोज और प्रतिस्थापन उपकरण का उपयोग करें", - "description": "प्रायोगिक खोज और प्रतिस्थापन उपकरण सक्षम करें, जो Roo को एक अनुरोध में खोज शब्द के कई उदाहरणों को बदलने की अनुमति देता है।" - }, "INSERT_BLOCK": { "name": "प्रायोगिक सामग्री सम्मिलित करने के उपकरण का उपयोग करें", "description": "प्रायोगिक सामग्री सम्मिलित करने के उपकरण को सक्षम करें, जो Roo को diff बनाए बिना विशिष्ट लाइन नंबरों पर सामग्री सम्मिलित करने की अनुमति देता है।" diff --git a/webview-ui/src/i18n/locales/id/settings.json b/webview-ui/src/i18n/locales/id/settings.json index 01298d93ddf..b965166d5db 100644 --- a/webview-ui/src/i18n/locales/id/settings.json +++ b/webview-ui/src/i18n/locales/id/settings.json @@ -739,10 +739,6 @@ "name": "Gunakan strategi unified diff eksperimental", "description": "Aktifkan strategi unified diff eksperimental. Strategi ini mungkin mengurangi jumlah retry yang disebabkan oleh error model tetapi dapat menyebabkan perilaku yang tidak terduga atau edit yang salah. Hanya aktifkan jika kamu memahami risikonya dan bersedia meninjau semua perubahan dengan hati-hati." }, - "SEARCH_AND_REPLACE": { - "name": "Gunakan tool search and replace eksperimental", - "description": "Aktifkan tool search and replace eksperimental, memungkinkan Roo mengganti beberapa instance dari term pencarian dalam satu permintaan." - }, "INSERT_BLOCK": { "name": "Gunakan tool insert content eksperimental", "description": "Aktifkan tool insert content eksperimental, memungkinkan Roo menyisipkan konten pada nomor baris spesifik tanpa perlu membuat diff." diff --git a/webview-ui/src/i18n/locales/it/settings.json b/webview-ui/src/i18n/locales/it/settings.json index 7b3eb560b9c..5523ec3ceab 100644 --- a/webview-ui/src/i18n/locales/it/settings.json +++ b/webview-ui/src/i18n/locales/it/settings.json @@ -714,10 +714,6 @@ "name": "Usa strategia diff unificata sperimentale", "description": "Abilita la strategia diff unificata sperimentale. Questa strategia potrebbe ridurre il numero di tentativi causati da errori del modello, ma può causare comportamenti imprevisti o modifiche errate. Abilitala solo se comprendi i rischi e sei disposto a rivedere attentamente tutte le modifiche." }, - "SEARCH_AND_REPLACE": { - "name": "Usa strumento di ricerca e sostituzione sperimentale", - "description": "Abilita lo strumento di ricerca e sostituzione sperimentale, consentendo a Roo di sostituire più istanze di un termine di ricerca in una singola richiesta." - }, "INSERT_BLOCK": { "name": "Usa strumento di inserimento contenuti sperimentale", "description": "Abilita lo strumento di inserimento contenuti sperimentale, consentendo a Roo di inserire contenuti a numeri di riga specifici senza dover creare un diff." diff --git a/webview-ui/src/i18n/locales/ja/settings.json b/webview-ui/src/i18n/locales/ja/settings.json index 9ad7035b546..74869992c95 100644 --- a/webview-ui/src/i18n/locales/ja/settings.json +++ b/webview-ui/src/i18n/locales/ja/settings.json @@ -714,10 +714,6 @@ "name": "実験的な統合diff戦略を使用する", "description": "実験的な統合diff戦略を有効にします。この戦略はモデルエラーによる再試行の回数を減らす可能性がありますが、予期しない動作や不正確な編集を引き起こす可能性があります。リスクを理解し、すべての変更を注意深く確認する準備がある場合にのみ有効にしてください。" }, - "SEARCH_AND_REPLACE": { - "name": "実験的な検索と置換ツールを使用する", - "description": "実験的な検索と置換ツールを有効にし、Rooが1つのリクエストで検索語の複数のインスタンスを置き換えることを可能にします。" - }, "INSERT_BLOCK": { "name": "実験的なコンテンツ挿入ツールを使用する", "description": "実験的なコンテンツ挿入ツールを有効にし、Rooがdiffを作成せずに特定の行番号にコンテンツを挿入できるようにします。" diff --git a/webview-ui/src/i18n/locales/ko/settings.json b/webview-ui/src/i18n/locales/ko/settings.json index c0b8bce736c..161f79ff56d 100644 --- a/webview-ui/src/i18n/locales/ko/settings.json +++ b/webview-ui/src/i18n/locales/ko/settings.json @@ -714,10 +714,6 @@ "name": "실험적 통합 diff 전략 사용", "description": "실험적 통합 diff 전략을 활성화합니다. 이 전략은 모델 오류로 인한 재시도 횟수를 줄일 수 있지만 예기치 않은 동작이나 잘못된 편집을 일으킬 수 있습니다. 위험을 이해하고 모든 변경 사항을 신중하게 검토할 의향이 있는 경우에만 활성화하십시오." }, - "SEARCH_AND_REPLACE": { - "name": "실험적 검색 및 바꾸기 도구 사용", - "description": "실험적 검색 및 바꾸기 도구를 활성화하여 Roo가 하나의 요청에서 검색어의 여러 인스턴스를 바꿀 수 있게 합니다." - }, "INSERT_BLOCK": { "name": "실험적 콘텐츠 삽입 도구 사용", "description": "실험적 콘텐츠 삽입 도구를 활성화하여 Roo가 diff를 만들 필요 없이 특정 줄 번호에 콘텐츠를 삽입할 수 있게 합니다." diff --git a/webview-ui/src/i18n/locales/nl/settings.json b/webview-ui/src/i18n/locales/nl/settings.json index 539e214e81b..7dd8a6358c2 100644 --- a/webview-ui/src/i18n/locales/nl/settings.json +++ b/webview-ui/src/i18n/locales/nl/settings.json @@ -714,10 +714,6 @@ "name": "Experimentele unified diff-strategie gebruiken", "description": "Schakel de experimentele unified diff-strategie in. Deze strategie kan het aantal herhalingen door model fouten verminderen, maar kan onverwacht gedrag of onjuiste bewerkingen veroorzaken. Alleen inschakelen als je de risico's begrijpt en wijzigingen zorgvuldig wilt controleren." }, - "SEARCH_AND_REPLACE": { - "name": "Experimentele zoek-en-vervang-tool gebruiken", - "description": "Schakel de experimentele zoek-en-vervang-tool in, waarmee Roo meerdere instanties van een zoekterm in één verzoek kan vervangen." - }, "INSERT_BLOCK": { "name": "Experimentele inhoud-invoeg-tool gebruiken", "description": "Schakel de experimentele inhoud-invoeg-tool in, waarmee Roo inhoud op specifieke regelnummers kan invoegen zonder een diff te maken." diff --git a/webview-ui/src/i18n/locales/pl/settings.json b/webview-ui/src/i18n/locales/pl/settings.json index ebc192e2302..7a01b8d077b 100644 --- a/webview-ui/src/i18n/locales/pl/settings.json +++ b/webview-ui/src/i18n/locales/pl/settings.json @@ -714,10 +714,6 @@ "name": "Użyj eksperymentalnej ujednoliconej strategii diff", "description": "Włącz eksperymentalną ujednoliconą strategię diff. Ta strategia może zmniejszyć liczbę ponownych prób spowodowanych błędami modelu, ale może powodować nieoczekiwane zachowanie lub nieprawidłowe edycje. Włącz tylko jeśli rozumiesz ryzyko i jesteś gotów dokładnie przeglądać wszystkie zmiany." }, - "SEARCH_AND_REPLACE": { - "name": "Użyj eksperymentalnego narzędzia do wyszukiwania i zamiany", - "description": "Włącz eksperymentalne narzędzie do wyszukiwania i zamiany, umożliwiając Roo zastąpienie wielu wystąpień wyszukiwanego terminu w jednym żądaniu." - }, "INSERT_BLOCK": { "name": "Użyj eksperymentalnego narzędzia do wstawiania treści", "description": "Włącz eksperymentalne narzędzie do wstawiania treści, umożliwiając Roo wstawianie treści w określonych numerach linii bez konieczności tworzenia diff." diff --git a/webview-ui/src/i18n/locales/pt-BR/settings.json b/webview-ui/src/i18n/locales/pt-BR/settings.json index fb68793e418..4bf5b02a83c 100644 --- a/webview-ui/src/i18n/locales/pt-BR/settings.json +++ b/webview-ui/src/i18n/locales/pt-BR/settings.json @@ -714,10 +714,6 @@ "name": "Usar estratégia diff unificada experimental", "description": "Ativar a estratégia diff unificada experimental. Esta estratégia pode reduzir o número de novas tentativas causadas por erros do modelo, mas pode causar comportamento inesperado ou edições incorretas. Ative apenas se compreender os riscos e estiver disposto a revisar cuidadosamente todas as alterações." }, - "SEARCH_AND_REPLACE": { - "name": "Usar ferramenta de busca e substituição experimental", - "description": "Ativar a ferramenta de busca e substituição experimental, permitindo que o Roo substitua várias instâncias de um termo de busca em uma única solicitação." - }, "INSERT_BLOCK": { "name": "Usar ferramenta de inserção de conteúdo experimental", "description": "Ativar a ferramenta de inserção de conteúdo experimental, permitindo que o Roo insira conteúdo em números de linha específicos sem precisar criar um diff." diff --git a/webview-ui/src/i18n/locales/ru/settings.json b/webview-ui/src/i18n/locales/ru/settings.json index 09fedab8f46..5755d40e27c 100644 --- a/webview-ui/src/i18n/locales/ru/settings.json +++ b/webview-ui/src/i18n/locales/ru/settings.json @@ -714,10 +714,6 @@ "name": "Использовать экспериментальную стратегию унифицированного диффа", "description": "Включает экспериментальную стратегию унифицированного диффа. Может уменьшить количество повторных попыток из-за ошибок модели, но может привести к неожиданному поведению или неверным правкам. Включайте только если готовы внимательно проверять все изменения." }, - "SEARCH_AND_REPLACE": { - "name": "Использовать экспериментальный инструмент поиска и замены", - "description": "Включает экспериментальный инструмент поиска и замены, позволяя Roo заменять несколько вхождений за один запрос." - }, "INSERT_BLOCK": { "name": "Использовать экспериментальный инструмент вставки контента", "description": "Включает экспериментальный инструмент вставки контента, позволяя Roo вставлять контент по номеру строки без создания диффа." diff --git a/webview-ui/src/i18n/locales/tr/settings.json b/webview-ui/src/i18n/locales/tr/settings.json index 2ce4732ff3a..9d05ef38ab4 100644 --- a/webview-ui/src/i18n/locales/tr/settings.json +++ b/webview-ui/src/i18n/locales/tr/settings.json @@ -714,10 +714,6 @@ "name": "Deneysel birleştirilmiş diff stratejisini kullan", "description": "Deneysel birleştirilmiş diff stratejisini etkinleştir. Bu strateji, model hatalarından kaynaklanan yeniden deneme sayısını azaltabilir, ancak beklenmeyen davranışlara veya hatalı düzenlemelere neden olabilir. Yalnızca riskleri anlıyorsanız ve tüm değişiklikleri dikkatlice incelemeye istekliyseniz etkinleştirin." }, - "SEARCH_AND_REPLACE": { - "name": "Deneysel arama ve değiştirme aracını kullan", - "description": "Deneysel arama ve değiştirme aracını etkinleştir, Roo'nun tek bir istekte bir arama teriminin birden fazla örneğini değiştirmesine olanak tanır." - }, "INSERT_BLOCK": { "name": "Deneysel içerik ekleme aracını kullan", "description": "Deneysel içerik ekleme aracını etkinleştir, Roo'nun bir diff oluşturma gereği duymadan belirli satır numaralarına içerik eklemesine olanak tanır." diff --git a/webview-ui/src/i18n/locales/vi/settings.json b/webview-ui/src/i18n/locales/vi/settings.json index e9b15db7d7a..6569ffca640 100644 --- a/webview-ui/src/i18n/locales/vi/settings.json +++ b/webview-ui/src/i18n/locales/vi/settings.json @@ -714,10 +714,6 @@ "name": "Sử dụng chiến lược diff thống nhất thử nghiệm", "description": "Bật chiến lược diff thống nhất thử nghiệm. Chiến lược này có thể giảm số lần thử lại do lỗi mô hình nhưng có thể gây ra hành vi không mong muốn hoặc chỉnh sửa không chính xác. Chỉ bật nếu bạn hiểu rõ các rủi ro và sẵn sàng xem xét cẩn thận tất cả các thay đổi." }, - "SEARCH_AND_REPLACE": { - "name": "Sử dụng công cụ tìm kiếm và thay thế thử nghiệm", - "description": "Bật công cụ tìm kiếm và thay thế thử nghiệm, cho phép Roo thay thế nhiều phiên bản của một thuật ngữ tìm kiếm trong một yêu cầu." - }, "INSERT_BLOCK": { "name": "Sử dụng công cụ chèn nội dung thử nghiệm", "description": "Bật công cụ chèn nội dung thử nghiệm, cho phép Roo chèn nội dung tại số dòng cụ thể mà không cần tạo diff." diff --git a/webview-ui/src/i18n/locales/zh-CN/settings.json b/webview-ui/src/i18n/locales/zh-CN/settings.json index 25a889939f2..c2856faed15 100644 --- a/webview-ui/src/i18n/locales/zh-CN/settings.json +++ b/webview-ui/src/i18n/locales/zh-CN/settings.json @@ -714,10 +714,6 @@ "name": "启用diff更新工具", "description": "可减少因模型错误导致的重复尝试,但可能引发意外操作。启用前请确保理解风险并会仔细检查所有修改。" }, - "SEARCH_AND_REPLACE": { - "name": "启用搜索和替换工具", - "description": "启用实验性搜索和替换工具,允许 Roo 在一个请求中替换搜索词的多个实例。" - }, "INSERT_BLOCK": { "name": "启用插入内容工具", "description": "允许 Roo 在特定行号插入内容,无需处理差异。" diff --git a/webview-ui/src/i18n/locales/zh-TW/settings.json b/webview-ui/src/i18n/locales/zh-TW/settings.json index 26225e2278f..3b4c20c35aa 100644 --- a/webview-ui/src/i18n/locales/zh-TW/settings.json +++ b/webview-ui/src/i18n/locales/zh-TW/settings.json @@ -714,10 +714,6 @@ "name": "使用實驗性統一差異比對策略", "description": "啟用實驗性的統一差異比對策略。此策略可能減少因模型錯誤而導致的重試次數,但也可能導致意外行為或錯誤的編輯。請務必了解風險,並願意仔細檢查所有變更後再啟用。" }, - "SEARCH_AND_REPLACE": { - "name": "使用實驗性搜尋與取代工具", - "description": "啟用實驗性的搜尋與取代工具,允許 Roo 在單一請求中取代多個符合的內容。" - }, "INSERT_BLOCK": { "name": "使用實驗性插入內容工具", "description": "啟用實驗性的插入內容工具,允許 Roo 直接在指定行號插入內容,而無需產生差異比對。" From b1c175189e2b207f63a8a85fb3d45eb78afcc6c4 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Tue, 28 Oct 2025 19:19:30 +0000 Subject: [PATCH 4/7] fix: remove searchAndReplace case from ChatRow.tsx --- webview-ui/src/components/chat/ChatRow.tsx | 33 ---------------------- 1 file changed, 33 deletions(-) diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index ed5257528fe..fd3d480014a 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -437,39 +437,6 @@ export const ChatRowContent = ({ ) - case "searchAndReplace": - return ( - <> -
- {tool.isProtected ? ( - - ) : ( - toolIcon("replace") - )} - - {tool.isProtected && message.type === "ask" - ? t("chat:fileOperations.wantsToEditProtected") - : message.type === "ask" - ? t("chat:fileOperations.wantsToSearchReplace") - : t("chat:fileOperations.didSearchReplace")} - -
-
- -
- - ) case "codebaseSearch": { return (
From 201c1f4d474a809f69c9f7ae6faba1f3ab62cc15 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Tue, 28 Oct 2025 21:28:57 +0000 Subject: [PATCH 5/7] fix(pr-fixer): scrub lingering references to removed search_and_replace tool (UI + rules) --- .roo/rules-issue-fixer/1_Workflow.xml | 1 - .../rules-merge-resolver/2_best_practices.xml | 2 +- .roo/rules-merge-resolver/3_tool_usage.xml | 25 +++---------------- webview-ui/src/components/chat/ChatView.tsx | 11 +++----- 4 files changed, 7 insertions(+), 32 deletions(-) diff --git a/.roo/rules-issue-fixer/1_Workflow.xml b/.roo/rules-issue-fixer/1_Workflow.xml index 8aa595cde74..62a3fd7c269 100644 --- a/.roo/rules-issue-fixer/1_Workflow.xml +++ b/.roo/rules-issue-fixer/1_Workflow.xml @@ -191,7 +191,6 @@ Use appropriate tools: - apply_diff for targeted changes - write_to_file for new files - - search_and_replace for systematic updates After each significant change, run relevant tests: - execute_command to run test suites diff --git a/.roo/rules-merge-resolver/2_best_practices.xml b/.roo/rules-merge-resolver/2_best_practices.xml index 5bf1b393eb2..ea6c7cc6a52 100644 --- a/.roo/rules-merge-resolver/2_best_practices.xml +++ b/.roo/rules-merge-resolver/2_best_practices.xml @@ -33,7 +33,7 @@ Escape Conflict Markers - When using apply_diff or search_and_replace tools, always escape merge + When using apply_diff, always escape merge conflict markers with backslashes to prevent parsing errors. - apply_diff or search_and_replace + apply_diff To resolve conflicts by replacing conflicted sections Precise editing of specific conflict blocks @@ -127,25 +127,6 @@ function mergedImplementation() { ]]> - - - Use for simple conflict resolutions - Enable regex mode for complex patterns - Always escape special characters - - - -src/config.ts -\<<<<<<< HEAD[\s\S]*?\>>>>>>> \w+ -// Resolved configuration -const config = { - // Merged settings from both branches -} -true - - ]]> - @@ -215,7 +196,7 @@ const config = { Conflict markers are incomplete or nested - Use search_and_replace with careful regex patterns + Use apply_diff with precise search blocks; split into multiple targeted edits if needed Manual inspection may be required @@ -232,7 +213,7 @@ const config = { Code contains literal conflict marker strings Extra careful escaping in diffs - Consider using search_and_replace with precise patterns + Prefer apply_diff with precise search blocks diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index b454c97bef9..0683f2ebd03 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -1011,14 +1011,9 @@ const ChatViewComponent: React.ForwardRefRenderFunction Date: Thu, 30 Oct 2025 18:19:19 -0500 Subject: [PATCH 6/7] test: remove obsolete search_and_replace e2e test file --- .../suite/tools/search-and-replace.test.ts | 631 ------------------ 1 file changed, 631 deletions(-) delete mode 100644 apps/vscode-e2e/src/suite/tools/search-and-replace.test.ts diff --git a/apps/vscode-e2e/src/suite/tools/search-and-replace.test.ts b/apps/vscode-e2e/src/suite/tools/search-and-replace.test.ts deleted file mode 100644 index a371253a8e5..00000000000 --- a/apps/vscode-e2e/src/suite/tools/search-and-replace.test.ts +++ /dev/null @@ -1,631 +0,0 @@ -import * as assert from "assert" -import * as fs from "fs/promises" -import * as path from "path" -import * as vscode from "vscode" - -import { RooCodeEventName, type ClineMessage } from "@roo-code/types" - -import { waitFor, sleep } from "../utils" -import { setDefaultSuiteTimeout } from "../test-utils" - -suite.skip("Roo Code search_and_replace Tool", function () { - setDefaultSuiteTimeout(this) - - let workspaceDir: string - - // Pre-created test files that will be used across tests - const testFiles = { - simpleReplace: { - name: `test-simple-replace-${Date.now()}.txt`, - content: "Hello World\nThis is a test file\nWith multiple lines\nHello again", - path: "", - }, - regexReplace: { - name: `test-regex-replace-${Date.now()}.js`, - content: `function oldFunction() { - console.log("old implementation") - return "old result" -} - -function anotherOldFunction() { - console.log("another old implementation") - return "another old result" -}`, - path: "", - }, - caseInsensitive: { - name: `test-case-insensitive-${Date.now()}.txt`, - content: `Hello World -HELLO UNIVERSE -hello everyone -HeLLo ThErE`, - path: "", - }, - multipleMatches: { - name: `test-multiple-matches-${Date.now()}.txt`, - content: `TODO: Fix this bug -This is some content -TODO: Add more tests -Some more content -TODO: Update documentation -Final content`, - path: "", - }, - noMatches: { - name: `test-no-matches-${Date.now()}.txt`, - content: "This file has no matching patterns\nJust regular content\nNothing special here", - path: "", - }, - } - - // Get the actual workspace directory that VSCode is using and create all test files - suiteSetup(async function () { - // Get the workspace folder from VSCode - const workspaceFolders = vscode.workspace.workspaceFolders - if (!workspaceFolders || workspaceFolders.length === 0) { - throw new Error("No workspace folder found") - } - workspaceDir = workspaceFolders[0]!.uri.fsPath - console.log("Using workspace directory:", workspaceDir) - - // Create all test files before any tests run - console.log("Creating test files in workspace...") - for (const [key, file] of Object.entries(testFiles)) { - file.path = path.join(workspaceDir, file.name) - await fs.writeFile(file.path, file.content) - console.log(`Created ${key} test file at:`, file.path) - } - - // Verify all files exist - for (const [key, file] of Object.entries(testFiles)) { - const exists = await fs - .access(file.path) - .then(() => true) - .catch(() => false) - if (!exists) { - throw new Error(`Failed to create ${key} test file at ${file.path}`) - } - } - }) - - // Clean up after all tests - suiteTeardown(async () => { - // Cancel any running tasks before cleanup - try { - await globalThis.api.cancelCurrentTask() - } catch { - // Task might not be running - } - - // Clean up all test files - console.log("Cleaning up test files...") - for (const [key, file] of Object.entries(testFiles)) { - try { - await fs.unlink(file.path) - console.log(`Cleaned up ${key} test file`) - } catch (error) { - console.log(`Failed to clean up ${key} test file:`, error) - } - } - }) - - // Clean up before each test - setup(async () => { - // Cancel any previous task - try { - await globalThis.api.cancelCurrentTask() - } catch { - // Task might not be running - } - - // Small delay to ensure clean state - await sleep(100) - }) - - // Clean up after each test - teardown(async () => { - // Cancel the current task - try { - await globalThis.api.cancelCurrentTask() - } catch { - // Task might not be running - } - - // Small delay to ensure clean state - await sleep(100) - }) - - test("Should perform simple text replacement", async function () { - const api = globalThis.api - const messages: ClineMessage[] = [] - const testFile = testFiles.simpleReplace - const expectedContent = "Hello Universe\nThis is a test file\nWith multiple lines\nHello again" - let taskStarted = false - let taskCompleted = false - let errorOccurred: string | null = null - let searchReplaceExecuted = false - - // Listen for messages - const messageHandler = ({ message }: { message: ClineMessage }) => { - messages.push(message) - - // Log important messages for debugging - if (message.type === "say" && message.say === "error") { - errorOccurred = message.text || "Unknown error" - console.error("Error:", message.text) - } - if (message.type === "ask" && message.ask === "tool") { - console.log("Tool request:", message.text?.substring(0, 200)) - } - if (message.type === "say" && (message.say === "completion_result" || message.say === "text")) { - console.log("AI response:", message.text?.substring(0, 200)) - } - - // Check for tool execution - if (message.type === "say" && message.say === "api_req_started" && message.text) { - console.log("API request started:", message.text.substring(0, 200)) - try { - const requestData = JSON.parse(message.text) - if (requestData.request && requestData.request.includes("search_and_replace")) { - searchReplaceExecuted = true - console.log("search_and_replace tool executed!") - } - } catch (e) { - console.log("Failed to parse api_req_started message:", e) - } - } - } - api.on(RooCodeEventName.Message, messageHandler) - - // Listen for task events - const taskStartedHandler = (id: string) => { - if (id === taskId) { - taskStarted = true - console.log("Task started:", id) - } - } - api.on(RooCodeEventName.TaskStarted, taskStartedHandler) - - const taskCompletedHandler = (id: string) => { - if (id === taskId) { - taskCompleted = true - console.log("Task completed:", id) - } - } - api.on(RooCodeEventName.TaskCompleted, taskCompletedHandler) - - let taskId: string - try { - // Start task with search_and_replace instruction - taskId = await api.startNewTask({ - configuration: { - mode: "code", - autoApprovalEnabled: true, - alwaysAllowWrite: true, - alwaysAllowReadOnly: true, - alwaysAllowReadOnlyOutsideWorkspace: true, - }, - text: `Use search_and_replace on the file ${testFile.name} to replace "Hello World" with "Hello Universe". - -The file is located at: ${testFile.path} - -The file already exists with this content: -${testFile.content} - -Assume the file exists and you can modify it directly.`, - }) - - console.log("Task ID:", taskId) - console.log("Test filename:", testFile.name) - - // Wait for task to start - await waitFor(() => taskStarted, { timeout: 45_000 }) - - // Check for early errors - if (errorOccurred) { - console.error("Early error detected:", errorOccurred) - } - - // Wait for task completion - await waitFor(() => taskCompleted, { timeout: 45_000 }) - - // Give extra time for file system operations - await sleep(2000) - - // Check if the file was modified correctly - const actualContent = await fs.readFile(testFile.path, "utf-8") - console.log("File content after modification:", actualContent) - - // Verify tool was executed - assert.strictEqual(searchReplaceExecuted, true, "search_and_replace tool should have been executed") - - // Verify file content - assert.strictEqual( - actualContent.trim(), - expectedContent.trim(), - "File content should be modified correctly", - ) - - console.log("Test passed! search_and_replace tool executed and file modified successfully") - } finally { - // Clean up - api.off(RooCodeEventName.Message, messageHandler) - api.off(RooCodeEventName.TaskStarted, taskStartedHandler) - api.off(RooCodeEventName.TaskCompleted, taskCompletedHandler) - } - }) - - test("Should perform regex pattern replacement", async function () { - const api = globalThis.api - const messages: ClineMessage[] = [] - const testFile = testFiles.regexReplace - const expectedContent = `function newFunction() { - console.log("new implementation") - return "new result" -} - -function anotherNewFunction() { - console.log("another new implementation") - return "another new result" -}` - let taskStarted = false - let taskCompleted = false - let errorOccurred: string | null = null - let searchReplaceExecuted = false - - // Listen for messages - const messageHandler = ({ message }: { message: ClineMessage }) => { - messages.push(message) - - // Log important messages for debugging - if (message.type === "say" && message.say === "error") { - errorOccurred = message.text || "Unknown error" - console.error("Error:", message.text) - } - if (message.type === "ask" && message.ask === "tool") { - console.log("Tool request:", message.text?.substring(0, 200)) - } - if (message.type === "say" && (message.say === "completion_result" || message.say === "text")) { - console.log("AI response:", message.text?.substring(0, 200)) - } - - // Check for tool execution - if (message.type === "say" && message.say === "api_req_started" && message.text) { - console.log("API request started:", message.text.substring(0, 200)) - try { - const requestData = JSON.parse(message.text) - if (requestData.request && requestData.request.includes("search_and_replace")) { - searchReplaceExecuted = true - console.log("search_and_replace tool executed!") - } - } catch (e) { - console.log("Failed to parse api_req_started message:", e) - } - } - } - api.on(RooCodeEventName.Message, messageHandler) - - // Listen for task events - const taskStartedHandler = (id: string) => { - if (id === taskId) { - taskStarted = true - console.log("Task started:", id) - } - } - api.on(RooCodeEventName.TaskStarted, taskStartedHandler) - - const taskCompletedHandler = (id: string) => { - if (id === taskId) { - taskCompleted = true - console.log("Task completed:", id) - } - } - api.on(RooCodeEventName.TaskCompleted, taskCompletedHandler) - - let taskId: string - try { - // Start task with search_and_replace instruction - simpler and more direct - taskId = await api.startNewTask({ - configuration: { - mode: "code", - autoApprovalEnabled: true, - alwaysAllowWrite: true, - alwaysAllowReadOnly: true, - alwaysAllowReadOnlyOutsideWorkspace: true, - }, - text: `Use search_and_replace on the file ${testFile.name} to: -1. First, replace "old" with "new" (use_regex: false) -2. Then, replace "Old" with "New" (use_regex: false) - -The file is located at: ${testFile.path} - -Assume the file exists and you can modify it directly. - -Use the search_and_replace tool twice - once for each replacement.`, - }) - - console.log("Task ID:", taskId) - console.log("Test filename:", testFile.name) - - // Wait for task to start - await waitFor(() => taskStarted, { timeout: 90_000 }) - - // Check for early errors - if (errorOccurred) { - console.error("Early error detected:", errorOccurred) - } - - // Wait for task completion - await waitFor(() => taskCompleted, { timeout: 90_000 }) - - // Give extra time for file system operations - await sleep(2000) - - // Check if the file was modified correctly - const actualContent = await fs.readFile(testFile.path, "utf-8") - console.log("File content after modification:", actualContent) - - // Verify tool was executed - assert.strictEqual(searchReplaceExecuted, true, "search_and_replace tool should have been executed") - - // Verify file content - assert.strictEqual( - actualContent.trim(), - expectedContent.trim(), - "File content should be modified with regex replacement", - ) - - console.log("Test passed! search_and_replace tool executed with regex successfully") - } finally { - // Clean up - api.off(RooCodeEventName.Message, messageHandler) - api.off(RooCodeEventName.TaskStarted, taskStartedHandler) - api.off(RooCodeEventName.TaskCompleted, taskCompletedHandler) - } - }) - - test("Should replace multiple matches in file", async function () { - const api = globalThis.api - const messages: ClineMessage[] = [] - const testFile = testFiles.multipleMatches - const expectedContent = `DONE: Fix this bug -This is some content -DONE: Add more tests -Some more content -DONE: Update documentation -Final content` - let taskStarted = false - let taskCompleted = false - let errorOccurred: string | null = null - let searchReplaceExecuted = false - - // Listen for messages - const messageHandler = ({ message }: { message: ClineMessage }) => { - messages.push(message) - - // Log important messages for debugging - if (message.type === "say" && message.say === "error") { - errorOccurred = message.text || "Unknown error" - console.error("Error:", message.text) - } - if (message.type === "ask" && message.ask === "tool") { - console.log("Tool request:", message.text?.substring(0, 200)) - } - if (message.type === "say" && (message.say === "completion_result" || message.say === "text")) { - console.log("AI response:", message.text?.substring(0, 200)) - } - - // Check for tool execution - if (message.type === "say" && message.say === "api_req_started" && message.text) { - console.log("API request started:", message.text.substring(0, 200)) - try { - const requestData = JSON.parse(message.text) - if (requestData.request && requestData.request.includes("search_and_replace")) { - searchReplaceExecuted = true - console.log("search_and_replace tool executed!") - } - } catch (e) { - console.log("Failed to parse api_req_started message:", e) - } - } - } - api.on(RooCodeEventName.Message, messageHandler) - - // Listen for task events - const taskStartedHandler = (id: string) => { - if (id === taskId) { - taskStarted = true - console.log("Task started:", id) - } - } - api.on(RooCodeEventName.TaskStarted, taskStartedHandler) - - const taskCompletedHandler = (id: string) => { - if (id === taskId) { - taskCompleted = true - console.log("Task completed:", id) - } - } - api.on(RooCodeEventName.TaskCompleted, taskCompletedHandler) - - let taskId: string - try { - // Start task with search_and_replace instruction for multiple matches - taskId = await api.startNewTask({ - configuration: { - mode: "code", - autoApprovalEnabled: true, - alwaysAllowWrite: true, - alwaysAllowReadOnly: true, - alwaysAllowReadOnlyOutsideWorkspace: true, - }, - text: `Use search_and_replace on the file ${testFile.name} to replace all occurrences of "TODO" with "DONE". - -The file is located at: ${testFile.path} - -The file already exists with this content: -${testFile.content} - -Assume the file exists and you can modify it directly.`, - }) - - console.log("Task ID:", taskId) - console.log("Test filename:", testFile.name) - - // Wait for task to start - await waitFor(() => taskStarted, { timeout: 45_000 }) - - // Check for early errors - if (errorOccurred) { - console.error("Early error detected:", errorOccurred) - } - - // Wait for task completion - await waitFor(() => taskCompleted, { timeout: 45_000 }) - - // Give extra time for file system operations - await sleep(2000) - - // Check if the file was modified correctly - const actualContent = await fs.readFile(testFile.path, "utf-8") - console.log("File content after modification:", actualContent) - - // Verify tool was executed - assert.strictEqual(searchReplaceExecuted, true, "search_and_replace tool should have been executed") - - // Verify file content - assert.strictEqual( - actualContent.trim(), - expectedContent.trim(), - "All TODO occurrences should be replaced with DONE", - ) - - console.log("Test passed! search_and_replace tool executed and replaced multiple matches successfully") - } finally { - // Clean up - api.off(RooCodeEventName.Message, messageHandler) - api.off(RooCodeEventName.TaskStarted, taskStartedHandler) - api.off(RooCodeEventName.TaskCompleted, taskCompletedHandler) - } - }) - - test("Should handle case when no matches are found", async function () { - const api = globalThis.api - const messages: ClineMessage[] = [] - const testFile = testFiles.noMatches - const expectedContent = testFile.content // Should remain unchanged - let taskStarted = false - let taskCompleted = false - let errorOccurred: string | null = null - let searchReplaceExecuted = false - - // Listen for messages - const messageHandler = ({ message }: { message: ClineMessage }) => { - messages.push(message) - - // Log important messages for debugging - if (message.type === "say" && message.say === "error") { - errorOccurred = message.text || "Unknown error" - console.error("Error:", message.text) - } - if (message.type === "ask" && message.ask === "tool") { - console.log("Tool request:", message.text?.substring(0, 200)) - } - if (message.type === "say" && (message.say === "completion_result" || message.say === "text")) { - console.log("AI response:", message.text?.substring(0, 200)) - } - - // Check for tool execution - if (message.type === "say" && message.say === "api_req_started" && message.text) { - console.log("API request started:", message.text.substring(0, 200)) - try { - const requestData = JSON.parse(message.text) - if (requestData.request && requestData.request.includes("search_and_replace")) { - searchReplaceExecuted = true - console.log("search_and_replace tool executed!") - } - } catch (e) { - console.log("Failed to parse api_req_started message:", e) - } - } - } - api.on(RooCodeEventName.Message, messageHandler) - - // Listen for task events - const taskStartedHandler = (id: string) => { - if (id === taskId) { - taskStarted = true - console.log("Task started:", id) - } - } - api.on(RooCodeEventName.TaskStarted, taskStartedHandler) - - const taskCompletedHandler = (id: string) => { - if (id === taskId) { - taskCompleted = true - console.log("Task completed:", id) - } - } - api.on(RooCodeEventName.TaskCompleted, taskCompletedHandler) - - let taskId: string - try { - // Start task with search_and_replace instruction for pattern that won't match - taskId = await api.startNewTask({ - configuration: { - mode: "code", - autoApprovalEnabled: true, - alwaysAllowWrite: true, - alwaysAllowReadOnly: true, - alwaysAllowReadOnlyOutsideWorkspace: true, - }, - text: `Use search_and_replace on the file ${testFile.name} to replace "NONEXISTENT_PATTERN" with "REPLACEMENT". This pattern should not be found in the file. - -The file is located at: ${testFile.path} - -The file already exists with this content: -${testFile.content} - -Assume the file exists and you can modify it directly.`, - }) - - console.log("Task ID:", taskId) - console.log("Test filename:", testFile.name) - - // Wait for task to start - await waitFor(() => taskStarted, { timeout: 45_000 }) - - // Check for early errors - if (errorOccurred) { - console.error("Early error detected:", errorOccurred) - } - - // Wait for task completion - await waitFor(() => taskCompleted, { timeout: 45_000 }) - - // Give extra time for file system operations - await sleep(2000) - - // Check if the file remains unchanged - const actualContent = await fs.readFile(testFile.path, "utf-8") - console.log("File content after search (should be unchanged):", actualContent) - - // Verify tool was executed - assert.strictEqual(searchReplaceExecuted, true, "search_and_replace tool should have been executed") - - // Verify file content remains unchanged - assert.strictEqual( - actualContent.trim(), - expectedContent.trim(), - "File content should remain unchanged when no matches are found", - ) - - console.log("Test passed! search_and_replace tool executed and handled no matches correctly") - } finally { - // Clean up - api.off(RooCodeEventName.Message, messageHandler) - api.off(RooCodeEventName.TaskStarted, taskStartedHandler) - api.off(RooCodeEventName.TaskCompleted, taskCompletedHandler) - } - }) -}) From 2017d378119d1cf1a853337fd06224496a765d7e Mon Sep 17 00:00:00 2001 From: Hannes Rudolph Date: Thu, 30 Oct 2025 20:40:40 -0600 Subject: [PATCH 7/7] chore: remove orphaned search_and_replace fields from ClineSayTool (ExtensionMessage.ts) --- src/shared/ExtensionMessage.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/shared/ExtensionMessage.ts b/src/shared/ExtensionMessage.ts index ab1386a358b..7d2759c9190 100644 --- a/src/shared/ExtensionMessage.ts +++ b/src/shared/ExtensionMessage.ts @@ -393,12 +393,6 @@ export interface ClineSayTool { isOutsideWorkspace?: boolean isProtected?: boolean additionalFileCount?: number // Number of additional files in the same read_file request - search?: string - replace?: string - useRegex?: boolean - ignoreCase?: boolean - startLine?: number - endLine?: number lineNumber?: number query?: string batchFiles?: Array<{