modx_edit_element_lines
Edit MODX chunks, snippets, templates, and plugins by line, sending only changed ranges. Use expect anchors and atomic multi-edit calls to avoid resending whole elements.
Instructions
Edit a chunk/snippet/template/plugin BY LINE, sending only the changed lines (no need to resend the whole element). Each edit replaces the inclusive range [start_line..end_line] with replacement. Conventions: delete = replacement ""; insert before a line = set end_line to start_line-1. Strongly recommended: pass expect (the current text of those lines) as a safety anchor — it is verified, and relocated to its unique match if the line numbers drifted; any mismatch aborts the WHOLE call (atomic, nothing is written). MULTI-EDIT RULES: all line numbers refer to the file exactly as you last saw it in modx_view_element (the original) — do NOT adjust them for the effect of your other edits; the server applies edits together (bottom-up) so earlier inserts/deletes never shift later ones. Ranges must not overlap. So to change several spots in one big file, send them all in ONE call with original line numbers. Read first with modx_view_element to get line numbers.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"type": "<type>",
"edits": "<edits>"
},
"name": "modx_edit_element_lines"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | ||
| name | No | ||
| type | Yes | ||
| edits | Yes | List of line edits applied atomically. |