woopcode docs
v1.0.0 GitHub

edit_file

Replace text inside an existing file. oldText must match exactly one place in the file, or the edit is refused so the wrong occurrence is never changed. Changes the workspace, so it pauses on a unified diff and waits for you.

Parameters#

Parameter Type Required Description
path string Yes File path
oldText string Yes Exact current text to replace, copied verbatim from read_file output. Include enough surrounding lines to match exactly one place in the file.
newText string Yes Exact replacement text. Inserted literally; no substitution patterns are expanded.
replaceAll boolean No Set to true only to deliberately change every non-overlapping occurrence, such as a rename. Omit it otherwise; omitting means the single unique occurrence.

Example#

edit_file({ path: "…", oldText: "…", newText: "…" })

Approval#

Pauses on a unified diff. Nothing is written until you approve it.

See also#

  • Tools — every tool, and which of them can change your files
  • Approval modes — what gates the tools that change things

Added in woopcode@0.6.0