Text Editing Toolset Documentation#
Generated byAIThis toolset provides tools for reading, creating, and modifying text-based files within the current directory.
read_text_file#
Read the contents of a text file within the current directory. Read the entire file or a specific range of lines.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
String | Yes | The relative path to the text file to read. |
include_line_numbers |
Boolean | No | If true, prepends 1-indexed line numbers like cat -n. Defaults to false. |
line_range |
Array | Yes | An array of two integers specifying the start and end line numbers to view. Line numbers are 1-indexed, and -1 for the end line means read to the end of the file. |
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.
str_insert_in_text_file#
Insert text at a specific location in a text file within the current directory.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
String | Yes | The relative path to the text file to modify. |
insert_line |
Integer | Yes | The line number after which to insert the text (0 for beginning of file, -1 to append at the end) |
insert_text |
String | Yes | The text to insert |
Notes#
- Ensures the file is within the current directory and is a text file.
- Returns the modified contents of the file.
str_replace_in_text_file#
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. |
old_str |
String | Yes | The text to replace (must match exactly, including whitespace and indentation |
new_str |
String | Yes | The new text to insert in place of the old text. |
multiple |
Boolean | No | If true, tries to replaces multiple occurrences of the old string. Default is false, replacing only the first occurence. |
Notes#
- Ensures the file is within the current directory and is a text file.
- Counts changes made to detect if nothing was modified.
- Returns the modified contents of the file and the number of replacements
write_text_file#
Write a text file with the given content, ensuring path to file is within current directory. Create entire path to the file if needed. DOES NOT overwrite existing file unless requested.
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. |
overwrite |
Boolean | No | Set to true to overwrite existing file; default is false. |
Notes#
- Ensures the file is created within the current directory.
- Does not overwrite existing files unless asked to do so.