file_edit
Edit files at line level to delete, insert, replace, or append content with automatic backup before operations.
Instructions
文件行级编辑:在指定位置删除、插入、替换或追加内容。操作前自动备份原文件。
示例:删除第 3-5 行 { "operation": "delete_lines", "path": "test.js", "start_line": 3, "end_line": 5 } 示例:插入内容到第 2 行后 { "operation": "insert_lines", "path": "test.js", "start_line": 2, "content": "new line" }
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| operation | Yes | 编辑操作:delete_lines(删除行)、insert_lines(插入行)、replace_lines(替换行)、append_lines(追加行) | |
| path | Yes | 文件或目录的绝对路径,或相对于 working_directory 的相对路径 | |
| start_line | No | 起始行号(从1开始) | |
| end_line | No | 结束行号(从1开始) | |
| content | No | 要写入或追加的文件内容 | |
| output_format | No | 输出格式:text(纯文本)、json(结构化JSON)、both(两者兼有) |