|
|
@@ -201,6 +201,42 @@ Example: Requesting to append to a log file
|
|
|
</content>
|
|
|
</append_to_file>
|
|
|
|
|
|
+## search_and_replace
|
|
|
+Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. 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:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldText</search>
|
|
|
+<replace>newText</replace>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
+2. Case-insensitive regex pattern:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldw+</search>
|
|
|
+<replace>new$&</replace>
|
|
|
+<use_regex>true</use_regex>
|
|
|
+<ignore_case>true</ignore_case>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
## execute_command
|
|
|
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Prefer relative commands and paths that avoid location sensitivity for terminal consistency, e.g: \`touch ./testdata/example.file\`, \`dir ./examples/model1/data/yaml\`, or \`go test ./cmd/front --config ./cmd/front/config.yml\`. If directed by the user, you may open a terminal in a different directory by using the \`cwd\` parameter.
|
|
|
Parameters:
|
|
|
@@ -361,8 +397,9 @@ 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), append_to_file (for appending content to the end of files).
|
|
|
+- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), append_to_file (for appending content to the end of files), search_and_replace (for finding and replacing individual pieces of text).
|
|
|
- The append_to_file tool adds content to the end of files, such as appending new log entries or adding new data records. This tool will always add the content at the end of the file.
|
|
|
+- 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.
|
|
|
@@ -659,53 +696,39 @@ Example: Insert a new function and its import statement
|
|
|
</insert_content>
|
|
|
|
|
|
## search_and_replace
|
|
|
-Description: Request to perform search and replace operations on a file. Each operation can specify a search pattern (string or regex) and replacement text, with optional line range restrictions and regex flags. Shows a diff preview before applying changes.
|
|
|
-Parameters:
|
|
|
-- path: (required) The path of the file to modify (relative to the current workspace directory /test/path)
|
|
|
-- operations: (required) A JSON array of search/replace operations. Each operation is an object with:
|
|
|
- * search: (required) The text or pattern to search for
|
|
|
- * replace: (required) The text to replace matches with. If multiple lines need to be replaced, use "
|
|
|
-" for newlines
|
|
|
- * start_line: (optional) Starting line number for restricted replacement
|
|
|
- * end_line: (optional) Ending line number for restricted replacement
|
|
|
- * use_regex: (optional) Whether to treat search as a regex pattern
|
|
|
- * ignore_case: (optional) Whether to ignore case when matching
|
|
|
- * regex_flags: (optional) Additional regex flags when use_regex is true
|
|
|
-Usage:
|
|
|
-<search_and_replace>
|
|
|
-<path>File path here</path>
|
|
|
-<operations>[
|
|
|
- {
|
|
|
- "search": "text to find",
|
|
|
- "replace": "replacement text",
|
|
|
- "start_line": 1,
|
|
|
- "end_line": 10
|
|
|
- }
|
|
|
-]</operations>
|
|
|
-</search_and_replace>
|
|
|
-Example: Replace "foo" with "bar" in lines 1-10 of example.ts
|
|
|
+Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. 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:
|
|
|
<search_and_replace>
|
|
|
<path>example.ts</path>
|
|
|
-<operations>[
|
|
|
- {
|
|
|
- "search": "foo",
|
|
|
- "replace": "bar",
|
|
|
- "start_line": 1,
|
|
|
- "end_line": 10
|
|
|
- }
|
|
|
-]</operations>
|
|
|
+<search>oldText</search>
|
|
|
+<replace>newText</replace>
|
|
|
</search_and_replace>
|
|
|
-Example: Replace all occurrences of "old" with "new" using regex
|
|
|
+
|
|
|
+2. Case-insensitive regex pattern:
|
|
|
<search_and_replace>
|
|
|
<path>example.ts</path>
|
|
|
-<operations>[
|
|
|
- {
|
|
|
- "search": "old\\w+",
|
|
|
- "replace": "new$&",
|
|
|
- "use_regex": true,
|
|
|
- "ignore_case": true
|
|
|
- }
|
|
|
-]</operations>
|
|
|
+<search>oldw+</search>
|
|
|
+<replace>new$&</replace>
|
|
|
+<use_regex>true</use_regex>
|
|
|
+<ignore_case>true</ignore_case>
|
|
|
</search_and_replace>
|
|
|
|
|
|
## execute_command
|
|
|
@@ -1133,53 +1156,39 @@ Example: Requesting to append to a log file
|
|
|
</append_to_file>
|
|
|
|
|
|
## search_and_replace
|
|
|
-Description: Request to perform search and replace operations on a file. Each operation can specify a search pattern (string or regex) and replacement text, with optional line range restrictions and regex flags. Shows a diff preview before applying changes.
|
|
|
-Parameters:
|
|
|
-- path: (required) The path of the file to modify (relative to the current workspace directory /test/path)
|
|
|
-- operations: (required) A JSON array of search/replace operations. Each operation is an object with:
|
|
|
- * search: (required) The text or pattern to search for
|
|
|
- * replace: (required) The text to replace matches with. If multiple lines need to be replaced, use "
|
|
|
-" for newlines
|
|
|
- * start_line: (optional) Starting line number for restricted replacement
|
|
|
- * end_line: (optional) Ending line number for restricted replacement
|
|
|
- * use_regex: (optional) Whether to treat search as a regex pattern
|
|
|
- * ignore_case: (optional) Whether to ignore case when matching
|
|
|
- * regex_flags: (optional) Additional regex flags when use_regex is true
|
|
|
-Usage:
|
|
|
-<search_and_replace>
|
|
|
-<path>File path here</path>
|
|
|
-<operations>[
|
|
|
- {
|
|
|
- "search": "text to find",
|
|
|
- "replace": "replacement text",
|
|
|
- "start_line": 1,
|
|
|
- "end_line": 10
|
|
|
- }
|
|
|
-]</operations>
|
|
|
-</search_and_replace>
|
|
|
-Example: Replace "foo" with "bar" in lines 1-10 of example.ts
|
|
|
+Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. 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:
|
|
|
<search_and_replace>
|
|
|
<path>example.ts</path>
|
|
|
-<operations>[
|
|
|
- {
|
|
|
- "search": "foo",
|
|
|
- "replace": "bar",
|
|
|
- "start_line": 1,
|
|
|
- "end_line": 10
|
|
|
- }
|
|
|
-]</operations>
|
|
|
+<search>oldText</search>
|
|
|
+<replace>newText</replace>
|
|
|
</search_and_replace>
|
|
|
-Example: Replace all occurrences of "old" with "new" using regex
|
|
|
+
|
|
|
+2. Case-insensitive regex pattern:
|
|
|
<search_and_replace>
|
|
|
<path>example.ts</path>
|
|
|
-<operations>[
|
|
|
- {
|
|
|
- "search": "old\\w+",
|
|
|
- "replace": "new$&",
|
|
|
- "use_regex": true,
|
|
|
- "ignore_case": true
|
|
|
- }
|
|
|
-]</operations>
|
|
|
+<search>oldw+</search>
|
|
|
+<replace>new$&</replace>
|
|
|
+<use_regex>true</use_regex>
|
|
|
+<ignore_case>true</ignore_case>
|
|
|
</search_and_replace>
|
|
|
|
|
|
## execute_command
|
|
|
@@ -1605,6 +1614,42 @@ Example: Requesting to append to a log file
|
|
|
</content>
|
|
|
</append_to_file>
|
|
|
|
|
|
+## search_and_replace
|
|
|
+Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. 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:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldText</search>
|
|
|
+<replace>newText</replace>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
+2. Case-insensitive regex pattern:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldw+</search>
|
|
|
+<replace>new$&</replace>
|
|
|
+<use_regex>true</use_regex>
|
|
|
+<ignore_case>true</ignore_case>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
## execute_command
|
|
|
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Prefer relative commands and paths that avoid location sensitivity for terminal consistency, e.g: \`touch ./testdata/example.file\`, \`dir ./examples/model1/data/yaml\`, or \`go test ./cmd/front --config ./cmd/front/config.yml\`. If directed by the user, you may open a terminal in a different directory by using the \`cwd\` parameter.
|
|
|
Parameters:
|
|
|
@@ -1765,8 +1810,9 @@ 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), append_to_file (for appending content to the end of files).
|
|
|
+- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), append_to_file (for appending content to the end of files), search_and_replace (for finding and replacing individual pieces of text).
|
|
|
- The append_to_file tool adds content to the end of files, such as appending new log entries or adding new data records. This tool will always add the content at the end of the file.
|
|
|
+- 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.
|
|
|
@@ -2027,6 +2073,42 @@ Example: Requesting to append to a log file
|
|
|
</content>
|
|
|
</append_to_file>
|
|
|
|
|
|
+## search_and_replace
|
|
|
+Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. 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:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldText</search>
|
|
|
+<replace>newText</replace>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
+2. Case-insensitive regex pattern:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldw+</search>
|
|
|
+<replace>new$&</replace>
|
|
|
+<use_regex>true</use_regex>
|
|
|
+<ignore_case>true</ignore_case>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
## execute_command
|
|
|
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Prefer relative commands and paths that avoid location sensitivity for terminal consistency, e.g: \`touch ./testdata/example.file\`, \`dir ./examples/model1/data/yaml\`, or \`go test ./cmd/front --config ./cmd/front/config.yml\`. If directed by the user, you may open a terminal in a different directory by using the \`cwd\` parameter.
|
|
|
Parameters:
|
|
|
@@ -2187,8 +2269,9 @@ 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), append_to_file (for appending content to the end of files).
|
|
|
+- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), append_to_file (for appending content to the end of files), search_and_replace (for finding and replacing individual pieces of text).
|
|
|
- The append_to_file tool adds content to the end of files, such as appending new log entries or adding new data records. This tool will always add the content at the end of the file.
|
|
|
+- 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.
|
|
|
@@ -2449,6 +2532,42 @@ Example: Requesting to append to a log file
|
|
|
</content>
|
|
|
</append_to_file>
|
|
|
|
|
|
+## search_and_replace
|
|
|
+Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. 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:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldText</search>
|
|
|
+<replace>newText</replace>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
+2. Case-insensitive regex pattern:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldw+</search>
|
|
|
+<replace>new$&</replace>
|
|
|
+<use_regex>true</use_regex>
|
|
|
+<ignore_case>true</ignore_case>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
## execute_command
|
|
|
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Prefer relative commands and paths that avoid location sensitivity for terminal consistency, e.g: \`touch ./testdata/example.file\`, \`dir ./examples/model1/data/yaml\`, or \`go test ./cmd/front --config ./cmd/front/config.yml\`. If directed by the user, you may open a terminal in a different directory by using the \`cwd\` parameter.
|
|
|
Parameters:
|
|
|
@@ -2609,8 +2728,9 @@ 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), append_to_file (for appending content to the end of files).
|
|
|
+- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), append_to_file (for appending content to the end of files), search_and_replace (for finding and replacing individual pieces of text).
|
|
|
- The append_to_file tool adds content to the end of files, such as appending new log entries or adding new data records. This tool will always add the content at the end of the file.
|
|
|
+- 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.
|
|
|
@@ -2871,6 +2991,42 @@ Example: Requesting to append to a log file
|
|
|
</content>
|
|
|
</append_to_file>
|
|
|
|
|
|
+## search_and_replace
|
|
|
+Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. 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:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldText</search>
|
|
|
+<replace>newText</replace>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
+2. Case-insensitive regex pattern:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldw+</search>
|
|
|
+<replace>new$&</replace>
|
|
|
+<use_regex>true</use_regex>
|
|
|
+<ignore_case>true</ignore_case>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
## 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.
|
|
|
@@ -3086,8 +3242,9 @@ 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), append_to_file (for appending content to the end of files).
|
|
|
+- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), append_to_file (for appending content to the end of files), search_and_replace (for finding and replacing individual pieces of text).
|
|
|
- The append_to_file tool adds content to the end of files, such as appending new log entries or adding new data records. This tool will always add the content at the end of the file.
|
|
|
+- 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.
|
|
|
@@ -3349,6 +3506,42 @@ Example: Requesting to append to a log file
|
|
|
</content>
|
|
|
</append_to_file>
|
|
|
|
|
|
+## search_and_replace
|
|
|
+Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. 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:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldText</search>
|
|
|
+<replace>newText</replace>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
+2. Case-insensitive regex pattern:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldw+</search>
|
|
|
+<replace>new$&</replace>
|
|
|
+<use_regex>true</use_regex>
|
|
|
+<ignore_case>true</ignore_case>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
## execute_command
|
|
|
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Prefer relative commands and paths that avoid location sensitivity for terminal consistency, e.g: \`touch ./testdata/example.file\`, \`dir ./examples/model1/data/yaml\`, or \`go test ./cmd/front --config ./cmd/front/config.yml\`. If directed by the user, you may open a terminal in a different directory by using the \`cwd\` parameter.
|
|
|
Parameters:
|
|
|
@@ -3577,8 +3770,9 @@ 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), append_to_file (for appending content to the end of files).
|
|
|
+- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), append_to_file (for appending content to the end of files), search_and_replace (for finding and replacing individual pieces of text).
|
|
|
- The append_to_file tool adds content to the end of files, such as appending new log entries or adding new data records. This tool will always add the content at the end of the file.
|
|
|
+- 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.
|
|
|
@@ -3839,6 +4033,42 @@ Example: Requesting to append to a log file
|
|
|
</content>
|
|
|
</append_to_file>
|
|
|
|
|
|
+## search_and_replace
|
|
|
+Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. 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:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldText</search>
|
|
|
+<replace>newText</replace>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
+2. Case-insensitive regex pattern:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldw+</search>
|
|
|
+<replace>new$&</replace>
|
|
|
+<use_regex>true</use_regex>
|
|
|
+<ignore_case>true</ignore_case>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
## 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.
|
|
|
@@ -4054,8 +4284,9 @@ 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), append_to_file (for appending content to the end of files).
|
|
|
+- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), append_to_file (for appending content to the end of files), search_and_replace (for finding and replacing individual pieces of text).
|
|
|
- The append_to_file tool adds content to the end of files, such as appending new log entries or adding new data records. This tool will always add the content at the end of the file.
|
|
|
+- 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.
|
|
|
@@ -4407,6 +4638,42 @@ Example: Requesting to append to a log file
|
|
|
</content>
|
|
|
</append_to_file>
|
|
|
|
|
|
+## search_and_replace
|
|
|
+Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. 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:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldText</search>
|
|
|
+<replace>newText</replace>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
+2. Case-insensitive regex pattern:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldw+</search>
|
|
|
+<replace>new$&</replace>
|
|
|
+<use_regex>true</use_regex>
|
|
|
+<ignore_case>true</ignore_case>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
## execute_command
|
|
|
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Prefer relative commands and paths that avoid location sensitivity for terminal consistency, e.g: \`touch ./testdata/example.file\`, \`dir ./examples/model1/data/yaml\`, or \`go test ./cmd/front --config ./cmd/front/config.yml\`. If directed by the user, you may open a terminal in a different directory by using the \`cwd\` parameter.
|
|
|
Parameters:
|
|
|
@@ -4567,8 +4834,9 @@ 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 replacing lines in existing files), write_to_file (for creating new files or complete file rewrites), append_to_file (for appending content to the end of files).
|
|
|
+- For editing files, you have access to these tools: apply_diff (for replacing lines in existing files), write_to_file (for creating new files or complete file rewrites), append_to_file (for appending content to the end of files), search_and_replace (for finding and replacing individual pieces of text).
|
|
|
- The append_to_file tool adds content to the end of files, such as appending new log entries or adding new data records. This tool will always add the content at the end of the file.
|
|
|
+- 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.
|
|
|
@@ -4829,6 +5097,42 @@ Example: Requesting to append to a log file
|
|
|
</content>
|
|
|
</append_to_file>
|
|
|
|
|
|
+## search_and_replace
|
|
|
+Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. 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:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldText</search>
|
|
|
+<replace>newText</replace>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
+2. Case-insensitive regex pattern:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldw+</search>
|
|
|
+<replace>new$&</replace>
|
|
|
+<use_regex>true</use_regex>
|
|
|
+<ignore_case>true</ignore_case>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
## execute_command
|
|
|
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Prefer relative commands and paths that avoid location sensitivity for terminal consistency, e.g: \`touch ./testdata/example.file\`, \`dir ./examples/model1/data/yaml\`, or \`go test ./cmd/front --config ./cmd/front/config.yml\`. If directed by the user, you may open a terminal in a different directory by using the \`cwd\` parameter.
|
|
|
Parameters:
|
|
|
@@ -4989,8 +5293,9 @@ 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), append_to_file (for appending content to the end of files).
|
|
|
+- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), append_to_file (for appending content to the end of files), search_and_replace (for finding and replacing individual pieces of text).
|
|
|
- The append_to_file tool adds content to the end of files, such as appending new log entries or adding new data records. This tool will always add the content at the end of the file.
|
|
|
+- 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.
|
|
|
@@ -5293,6 +5598,42 @@ Example: Requesting to append to a log file
|
|
|
</content>
|
|
|
</append_to_file>
|
|
|
|
|
|
+## search_and_replace
|
|
|
+Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. 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:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldText</search>
|
|
|
+<replace>newText</replace>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
+2. Case-insensitive regex pattern:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldw+</search>
|
|
|
+<replace>new$&</replace>
|
|
|
+<use_regex>true</use_regex>
|
|
|
+<ignore_case>true</ignore_case>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
## execute_command
|
|
|
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Prefer relative commands and paths that avoid location sensitivity for terminal consistency, e.g: \`touch ./testdata/example.file\`, \`dir ./examples/model1/data/yaml\`, or \`go test ./cmd/front --config ./cmd/front/config.yml\`. If directed by the user, you may open a terminal in a different directory by using the \`cwd\` parameter.
|
|
|
Parameters:
|
|
|
@@ -5515,8 +5856,9 @@ 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), append_to_file (for appending content to the end of files).
|
|
|
+- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), append_to_file (for appending content to the end of files), search_and_replace (for finding and replacing individual pieces of text).
|
|
|
- The append_to_file tool adds content to the end of files, such as appending new log entries or adding new data records. This tool will always add the content at the end of the file.
|
|
|
+- 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.
|
|
|
@@ -5792,6 +6134,42 @@ Example: Requesting to append to a log file
|
|
|
</content>
|
|
|
</append_to_file>
|
|
|
|
|
|
+## search_and_replace
|
|
|
+Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. 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:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldText</search>
|
|
|
+<replace>newText</replace>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
+2. Case-insensitive regex pattern:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldw+</search>
|
|
|
+<replace>new$&</replace>
|
|
|
+<use_regex>true</use_regex>
|
|
|
+<ignore_case>true</ignore_case>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
## ask_followup_question
|
|
|
Description: Ask the user a question to gather additional information needed to complete the task. This tool should be used when you encounter ambiguities, need clarification, or require more details to proceed effectively. It allows for interactive problem-solving by enabling direct communication with the user. Use this tool judiciously to maintain a balance between gathering necessary information and avoiding excessive back-and-forth.
|
|
|
Parameters:
|
|
|
@@ -5930,8 +6308,9 @@ 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), append_to_file (for appending content to the end of files).
|
|
|
+- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), append_to_file (for appending content to the end of files), search_and_replace (for finding and replacing individual pieces of text).
|
|
|
- The append_to_file tool adds content to the end of files, such as appending new log entries or adding new data records. This tool will always add the content at the end of the file.
|
|
|
+- 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.
|
|
|
@@ -6284,8 +6663,9 @@ 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), append_to_file (for appending content to the end of files).
|
|
|
+- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), append_to_file (for appending content to the end of files), search_and_replace (for finding and replacing individual pieces of text).
|
|
|
- The append_to_file tool adds content to the end of files, such as appending new log entries or adding new data records. This tool will always add the content at the end of the file.
|
|
|
+- 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.
|
|
|
@@ -6579,6 +6959,42 @@ Example: Requesting to append to a log file
|
|
|
</content>
|
|
|
</append_to_file>
|
|
|
|
|
|
+## search_and_replace
|
|
|
+Description: Request to perform a search and replace operation on a file. Supports both literal text and regex patterns. 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:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldText</search>
|
|
|
+<replace>newText</replace>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
+2. Case-insensitive regex pattern:
|
|
|
+<search_and_replace>
|
|
|
+<path>example.ts</path>
|
|
|
+<search>oldw+</search>
|
|
|
+<replace>new$&</replace>
|
|
|
+<use_regex>true</use_regex>
|
|
|
+<ignore_case>true</ignore_case>
|
|
|
+</search_and_replace>
|
|
|
+
|
|
|
## execute_command
|
|
|
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Prefer relative commands and paths that avoid location sensitivity for terminal consistency, e.g: \`touch ./testdata/example.file\`, \`dir ./examples/model1/data/yaml\`, or \`go test ./cmd/front --config ./cmd/front/config.yml\`. If directed by the user, you may open a terminal in a different directory by using the \`cwd\` parameter.
|
|
|
Parameters:
|
|
|
@@ -6807,8 +7223,9 @@ 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), append_to_file (for appending content to the end of files).
|
|
|
+- For editing files, you have access to these tools: write_to_file (for creating new files or complete file rewrites), append_to_file (for appending content to the end of files), search_and_replace (for finding and replacing individual pieces of text).
|
|
|
- The append_to_file tool adds content to the end of files, such as appending new log entries or adding new data records. This tool will always add the content at the end of the file.
|
|
|
+- 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.
|