Edit file
edit_fileEdit files using exact text replacement or line-range edits. Ensures atomic updates with revision validation and dry-run previews.
Instructions
Edit a file. Two mutually exclusive edit shapes: {oldText,newText} literal replacement, or line edits (1-based). {startLine,endLine,newText} replaces the inclusive range; newText "" deletes, no trailing newline. Omitting endLine INSERTS before startLine instead of replacing, and startLine = lines+1 appends at EOF. Line edits require rev and are applied bottom-up in one atomic pass, so numbers from a single grep/read stay valid; a stale rev is rejected, never applied. Returns the new rev. dryRun shows the diff. In a zone with policy overwrite="rev" every edit needs rev, including {oldText}; in overwrite="never" zones editing is refused outright. To replace a whole file use write_file. Document formats are read-only.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rev | No | From grep_files, read_text_file offset, or get_file_info | |
| path | Yes | ||
| edits | Yes | ||
| dryRun | No |