Text Editing Toolset Documentation#
Generated byAIThis toolset provides tools for reading, creating, and modifying text-based files within the current directory.
read_text_file#
Purpose: Reads the content of a specified text-based file in the current directory. Supports plain text, code files, markdown, and other text-based formats.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
String | Yes | The relative path to the text file to read. |
Success Case Example#
Input:
{
"file_path": "example.txt"
}Output:
{
"file_path": "example.txt",
"content": "This is the content of example.txt"
}Error Case Examples#
-
Missing File Path:
{ "error": "The required file_path was not specified" } -
Invalid Path:
{ "error": "Access to the specified path 'example.txt' is not allowed." } -
File Does Not Exist:
{ "error": "The specified file 'example.txt' does not exist." } -
Not a Text File:
{ "error": "The specified file 'example.png' is not a text-based file." } -
Read Error:
{ "error": "An error occurred while reading the file: Permission denied" }
Notes#
- Ensures the file is within the current directory and is not a binary file.
- Supports plain text, code files, markdown, and other text-based formats.
create_text_file#
Purpose: Creates a text file at the specified path with the given content. Ensures the file is created within the current directory and does not overwrite existing files.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
String | Yes | The relative path where the text file will be created. |
content |
String | Yes | The content to write into the text file. |
Success Case Example#
Input:
{
"file_path": "new_file.txt",
"content": "This is the content of new_file.txt"
}Output:
{
"message": "File 'new_file.txt' created successfully."
}Error Case Examples#
-
Missing File Path:
{ "error": "The required file_path was not specified" } -
Missing Content:
{ "error": "The required content was not specified" } -
Invalid Path:
{ "error": "Access to the specified path 'new_file.txt' is not allowed." } -
File Already Exists:
{ "error": "The file 'new_file.txt' already exists." } -
Write Error:
{ "error": "An error occurred while creating the file: Permission denied" }
Notes#
- Ensures the file is created within the current directory.
- Does not overwrite existing files.
replace_text_in_text_file#
Purpose: Searches for the specified text in a text-based file and replaces it with alternative text. Ensures the file is within the current directory and is a text file.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
String | Yes | The relative path to the file where you want to perform the replacement. |
search |
String | Yes | The text to search for in the file. |
replace_with |
String | Yes | The text to use to replace the text we searched for in the file. |
Success Case Example#
Input:
{
"file_path": "example.txt",
"search": "old text",
"replace_with": "new text"
}Output:
{
"file_path": "example.txt",
"new_content": "This is the updated content with new text"
}Error Case Examples#
-
Missing File Path:
{ "error": "The required file_path was not specified" } -
Missing Search Text:
{ "error": "The required search_text was not specified" } -
Missing Replacement Text:
{ "error": "The required replacement_text 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." } -
Search Text Not Found:
{ "error": "An error occurred while modifying the file: Unable to find search text in the file" } -
Write Error:
{ "error": "An error occurred while modifying the file: Permission denied" }
Notes#
- Ensures the file is within the current directory and is a text file.
- Counts changes made to detect if nothing was modified.