Edit a project file (find & replace)
dreamagent_edit_fileWRITE ACTION — make SMALL targeted changes to an EXISTING file in a DreamAgent project via exact search/replace. PREFERRED over dreamagent_write_file for editing existing files: you send only the changed fragments (never the whole file) — cheaper, immune to payload size/safety blocks in the calling client, and cannot corrupt unchanged code. Use dreamagent_write_file only to CREATE files or for full rewrites.
Read the file first (dreamagent_read_file) and copy each 'find' text EXACTLY as it appears — whitespace and indentation must match. All edits are validated BEFORE anything is saved; if any 'find' fails to match, the file is left untouched and the error tells you which edit and why.
CONFIRM BEFORE CALLING — show the user the target file and each planned find→replace change, then call only with confirm=true.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| edits | Yes | list of edit objects: {"find": "<exact existing text>", "replace": "<new text>", "all": false} # optional: replace every occurrence | |
| confirm | No | must be true to execute. | |
| file_path | Yes | project-relative path of the EXISTING file to edit. | |
| project_id | Yes | project containing the file. | |
| auto_commit | No | commit+push and record version history after saving (default true; pass false to batch several edit_file calls and finish with one dreamagent_commit_push). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |