agent-zero/plugins/_text_editor/prompts/agent.system.tool.text_editor.md
Alessandro 4c2bc3d783 Add context-based patch_text support to text_editor
Introduces patch_text editing for the Docker-local text_editor, sharing request validation and freshness-state logic with text_editor_remote while preserving legacy line-number edits. Adds anchored context patching, safer state handling after context edits, updated model guidance, live remote wrapper reuse, and focused regression coverage for chained patches and Python replacement cases.
2026-04-21 18:18:59 +02:00

2 KiB

text_editor

file read write patch with numbered lines not code execution rejects binary terminal (grep find sed) advance search/replace

text_editor:read

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:

{
    ...
    "tool_name": "text_editor:read",
    "tool_args": {
        "path": "/path/file.py",
        "line_from": 1,
        "line_to": 50
    }
}

text_editor:write

create/overwrite file auto-creates dirs args path content usage:

{
    ...
    "tool_name": "text_editor:write",
    "tool_args": {
        "path": "/path/file.py",
        "content": "import os\nprint('hello')\n"
    }
}

text_editor:patch

edit existing file. prefer patch_text; use edits only right after read for tiny line edits args path plus exactly one of: patch_text string OR edits [{from to content}] patch_text uses current file content, no prior read required patch_text update-only forms:

  • insert after anchor: @@ exact existing line then +new lines
  • replace: use @@ line before target then -old +new, or @@ old target line then -same old target line +new
  • do not repeat the same old line as both a space-context line and a -removed line
  • context lines start with space, removals with -, additions with +
  • use enough unique context; add @@ anchor when repeated text exists edits legacy line mode: from/to inclusive, original line numbers from read, no overlaps edits examples: {from:2 to:2 content:"x\n"} replace; {from:2 to:2} delete; {from:2 content:"x\n"} insert before for edits, re-read after insert/delete or line-count-changing replace ensure valid syntax in content (all braces brackets tags closed) usage:
{
    ...
    "tool_name": "text_editor:patch",
    "tool_args": {
        "path": "/path/file.py",
        "patch_text": "*** Begin Patch\n*** Update File: file.py\n@@ def run():\n+    print('ready')\n*** End Patch"
    }
}