Experimental Toolset Documentation#
Generated byAICaution: This toolset contains experimental tools that may undergo significant changes or be removed in future updates. Use with caution and ensure you have backups of your data.
Tools#
apply_patch_to_text_file#
Purpose: Applies a patch using the diff format to a specified text file using the patch command.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
String | Yes | The relative path to the file to be patched. |
patch_content |
String | Yes | The content of the patch to apply. |
Success Case Example#
Input:
{
"file_path": "example.txt",
"patch_content": "--- example.txt\n+++ example.txt\n@@ -1 +1 @@\n-old content\n+new content"
}Output:
{
"file_path": "example.txt",
"message": "Patch applied successfully"
}Error Case Examples#
-
Missing File Path:
{ "error": "The required file_path was not specified" } -
Missing Patch Content:
{ "error": "The required patch_content was not specified" } -
Invalid Path:
{ "error": "The specified path 'example.txt' is not allowed." } -
File Does Not Exist:
{ "error": "The specified file 'example.txt' does not exist." } -
Patch Application Failed:
{ "error": "Failure: <patch output>" } -
General Error:
{ "error": "An error occurred while applying the patch: <error message>" }
Notes#
- The tool uses the
patchcommand with the--no-backup-if-mismatchflag. - It ensures the file is within the current directory and is a valid text file.
regex_text_edit_tool#
Purpose: Finds patterns using a regex in a text-based file and replaces them with new text.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
String | Yes | The relative path to the file where you want to perform the regex replacement. |
pattern |
String | Yes | The regex pattern to search for in the file. |
replacement |
String | Yes | The text to replace the pattern with in the file. |
Success Case Example#
Input:
{
"file_path": "example.txt",
"pattern": "old_text",
"replacement": "new_text"
}Output:
{
"file_path": "example.txt",
"new_content": "<updated content of the file>"
}Error Case Examples#
-
Missing File Path:
{ "error": "The required file_path was not specified" } -
Missing Pattern:
{ "error": "The required pattern was not specified" } -
Missing Replacement:
{ "error": "The required replacement was not specified" } -
Invalid Path:
{ "error": "The specified path 'example.txt' is not allowed." } -
File Does Not Exist:
{ "error": "The specified file 'example.txt' does not exist." } -
General Error:
{ "error": "An error occurred while modifying the file: <error message>" }
Notes#
- The tool ensures the file is within the current directory and is a valid text file.
- It uses multiline regex options for pattern matching.