Engine
engine
Batch file editing engine.
Implements the validate-then-apply strategy from the axm-edit spec:
- Read all affected files once (snapshot)
- Validate every operation against the snapshot
- Resolve line positions (fuzzy search for
oldcontent) - Sort replace edits bottom-to-top to avoid line-shift
- Apply all operations atomically (or fail with 0 files touched)
ResolvedEdit
dataclass
An edit whose line position has been resolved against the file.
Source code in packages/axm-edit/src/axm_edit/core/engine.py
batch_apply(root, operations)
Validate and apply a batch of file operations atomically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
Project root directory (all paths are relative to this). |
required |
operations
|
Sequence[Operation]
|
List of replace, create, and delete operations. |
required |
Returns:
| Type | Description |
|---|---|
BatchResult
|
BatchResult with success status, checkpoint SHA, and summary. |