| 1 | ### text_editor |
| 2 | Read, write, or patch Markdown and plain text files. |
| 3 | |
| 4 | Actions in `tool_args.action`: |
| 5 | - `read`: read a file |
| 6 | - `write`: create or overwrite a file |
| 7 | - `patch`: edit an existing file |
| 8 | |
| 9 | Common arguments: |
| 10 | - `path`: absolute file path |
| 11 | - `content`: full file content for `write` |
| 12 | - `open_in_canvas`: set `true` when the user explicitly asks to open a Markdown file in the Canvas or Editor |
| 13 | |
| 14 | Rules: |
| 15 | - Use this tool for `.md` and plain text files. |
| 16 | - Use `write` to create a new Markdown file. |
| 17 | - If the user asks to open the file in the Canvas or Editor, include `"open_in_canvas": true` in the same `write` or `patch` call. |
| 18 | - After a successful write or patch result, do not repeat the same tool call. Use the `response` tool unless a different action is needed. |
| 19 | |
| 20 | Examples: |
| 21 | |
| 22 | `{"tool_name":"text_editor","tool_args":{"action":"write","path":"/a0/usr/workdir/TODO.md","content":"# TODO\n- [ ] First item\n","open_in_canvas":true}}` |
| 23 | |
| 24 | `{"tool_name":"text_editor","tool_args":{"action":"read","path":"/a0/usr/workdir/TODO.md"}}` |
| 25 | |
| 26 | `{"tool_name":"text_editor","tool_args":{"action":"patch","path":"/a0/usr/workdir/TODO.md","old_text":"- [ ] First item","new_text":"- [x] First item"}}` |