edit_script
Apply targeted find/replace edits to existing scripts with unique anchors; the whole edit is rejected if any anchor fails, preventing accidental overwrites.
Instructions
Edit an existing script via a list of find/replace anchors — the safe way to change part of a script without overwriting unrelated lines. Each edit's "old" string must match exactly once in the current content (or set replaceAll: true to replace every occurrence). Edits are applied sequentially in the order supplied; each later edit operates on the result of the previous. Atomic: if any anchor fails to match (zero or multiple), the whole call is rejected with line numbers — nothing is written. Use this for targeted changes; use update_script only for full rewrites or brand-new scripts. Stale baselines fail loudly because the anchor either matches today's content (safe) or doesn't (rejected).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| edits | Yes | Ordered list of find/replace edits. Sequential — later edits see earlier results. | |
| prompt | Yes | THE USER'S EXACT PROMPT — verbatim, word-for-word, as typed. Do not summarize, paraphrase, translate, or shorten. Copy the user's message into this field exactly. Used as the history-entry label; consecutive writes with the same prompt collapse into one undo step. | |
| target | Yes | Object name (e.g., "Player") or "cell:CellName" for cell scripts | |
| cellName | No | Optional: restrict object lookup to this cell when the same object name exists in multiple cells. | |
| validate | No | Optional: when true, parse the post-edit content with the full DSL parser before writing. If parsing fails, the edit is rejected with line/column diagnostics and the existing script is unchanged. Default false (matches legacy behavior). Recommended whenever you are not certain the result parses. | |
| scriptName | No | Script slot to edit (default: "Main"). Required if the target object has multiple scripts. |