Text Editing Toolset Documentation

Generated byAI

This 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_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 find and replace. Must match byte-for-byte. Include enough surrounding lines to make the match unique.
new_str String Yes The new text to insert in place of the old text.
occurrence Integer No Which occurrence of old_str to replace (1-based). Default is 1 (first match). Use -1 to replace all occurrences. New in 0.9.12

Notes

  • Ensures the file is within the current directory and is a text file.
  • Counts changes made to detect if nothing was modified.
  • New in 0.9.12 Returns only the modified lines along with location information (line numbers and context) rather than the entire modified file, plus 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.