Editfile
editFileEdits existing local text files with sed expressions while creating numbered backups and returning unified diffs. Restricts changes to the configured directory and removes the backup if sed fails.
Instructions
Edits an existing local text file using a sed expression/program.
Args: file: Local path of the file to edit, limited to the configured current directory and its descendants. script: The authoritative sed editing expression/program. args: Optional safe sed arguments. Options that enable in-place editing, supply another expression or program file, select other files, or execute commands are not allowed.
Before editing, the tool creates the next available numbered backup (.bk1, .bk2,
.bk3, and so on), and never overwrites an existing backup. The source file is
replaced only after sandboxed sed completes successfully. On success, the response
contains a diff -u unified diff from the backup/original version to the edited
file. If sed fails while the original is unchanged, the newly created backup is
removed. When --editdelbk or config editdelbk is enabled, a successful edit's
backup is deleted only after the unified diff response has been composed.
Example: file="src/example.py", script="s/old_name/new_name/g". The resulting
backup might be src/example.py.bk1.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | ||
| file | Yes | ||
| script | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |