Batch edit
batch_edit
BatchEditTool — atomic batch file editing for AI agents.
Registered as batch_edit via the axm.tools entry point.
BatchEditTool
Atomic batch file editing for AI agents.
Replaces, rewrites, creates, and deletes files in a single atomic
operation.
Registered as batch_edit via axm.tools entry point.
Source code in packages/axm-edit/src/axm_edit/tools/batch_edit.py
| Python | |
|---|---|
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 | |
name
property
Tool name used for MCP registration.
execute(*, path='.', operations=None, lint=True, lint_diff=True, lint_diff_max_ratio=0.5, **kwargs)
Execute a batch of file operations atomically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Project root directory. |
'.'
|
operations
|
list[dict[str, object]] | None
|
List of operation dicts with |
None
|
lint
|
bool
|
Run ruff --fix on changed Python files after apply. |
True
|
lint_diff
|
bool
|
Surface per-file diffs of post-lint mutations. |
True
|
lint_diff_max_ratio
|
float
|
Fallback threshold (diff / file size). |
0.5
|
Returns:
| Type | Description |
|---|---|
ToolResult
|
ToolResult with applied counts, the |
ToolResult
|
payload (a JSON string, not a SHA) to pass back to |
ToolResult
|
|
ToolResult
|
warnings and blocking verdict). A blocking preflight refuses the |
ToolResult
|
batch before any checkpoint or write, so the payload then |
ToolResult
|
carries no checkpoint at all. |
Source code in packages/axm-edit/src/axm_edit/tools/batch_edit.py
render_text(result, parsed, data)
Render a compact, git-style LLM-facing view of a batch result.
The header carries the global status — ✓ on success, or on failure
✗ with a label naming what happened to the tree (see
:func:_failure_label), so a partial write is impossible to miss —
followed by the modified/created/deleted/edits counts. Each
operated-on file is then listed with its op sigil and edit count, every
validation error is surfaced verbatim, and the full lint summary
(fixes, remaining errors, warnings, diffs) is appended.
One key is deliberately absent: data["checkpoint"] carries the
base64 snapshot of every touched file before the batch, measured in
tens of thousands of tokens on a real batch. It stays in data for
batch_rollback and never reaches this view. Everything else in
data is rendered; only its JSON structure is dropped.