plugins/_text_editor/prompts/agent.system.tool.text_editor.md
canonical text and Markdown file read write patch with numbered lines
not code execution rejects binary
terminal (grep find sed) advance search/replace
actions: read write patch
common args: action path
optional UI intent args: open_in_canvas
use this tool for Markdown and plain text files; use office_artifact only for Office packages such as odt ods odp docx xlsx pptx
if the user explicitly asks to open the Markdown file in the canvas/Editor after a write or patch, set open_in_canvas: true; otherwise omit UI flags because already-open Editor sessions refresh automatically
read file with numbered lines args path line_from line_to (inclusive optional) no range -> first {{default_line_count}} lines long lines cropped output may trim by token limit read surrounding context before patching usage:
{
"thoughts": ["I need file context before editing."],
"headline": "Reading file",
"tool_name": "text_editor",
"tool_args": {
"action": "read",
"path": "/path/file.py",
"line_from": 1,
"line_to": 50
}
}
create/overwrite file auto-creates dirs
args path content
for Markdown files, include open_in_canvas: true only when the user explicitly asks to open the canvas/Editor
usage:
{
"thoughts": ["I need to create or replace the file content."],
"headline": "Writing file",
"tool_name": "text_editor",
"tool_args": {
"action": "write",
"path": "/path/file.py",
"content": "import os\nprint('hello')\n"
}
}
edit existing file. prefer exact replace for simple "change X to Y"; use patch_text for context changes; use edits only right after read for tiny line edits
if the user says patch, change without rewriting, or don't rewrite, use action patch instead of write
args path plus exactly one of: old_text+new_text OR patch_text string OR edits [{from to content}]
for Markdown files, include open_in_canvas: true only when the user explicitly asks to open the canvas/Editor
exact replace: old_text must be the exact current text span and must match once; new_text is the replacement
patch_text uses current file content, no prior read required
patch_text update-only forms:
{
"thoughts": ["I can replace one exact current string without rewriting the whole file."],
"headline": "Patching file",
"tool_name": "text_editor",
"tool_args": {
"action": "patch",
"path": "/path/file.py",
"old_text": "status = 'draft'",
"new_text": "status = 'ready'"
}
}