Operations
operations
Pydantic models for batch file operations.
Defines the three operation types from the axm-edit spec:
- ReplaceOp — modify lines in an existing file
- CreateOp — create a new file
- DeleteOp — delete an existing file
Operation = Annotated[ReplaceOp | CreateOp | DeleteOp, Field(discriminator='op')]
module-attribute
Discriminated union of all operation types.
BatchResult
Bases: BaseModel
Result of a batch edit operation.
Attributes:
| Name | Type | Description |
|---|---|---|
success |
bool
|
Whether all operations were applied. |
checkpoint |
str | None
|
Git stash SHA for rollback, if available. |
applied |
int
|
Total number of individual edits applied. |
summary |
dict[str, int]
|
Counts of modified, created, and deleted files. |
error |
str | None
|
Human-readable error message on failure. |
details |
list[ValidationError]
|
Detailed validation errors on failure. |
Source code in packages/axm-edit/src/axm_edit/models/operations.py
CreateOp
Bases: BaseModel
Create a new file.
Fails if the file already exists unless overwrite is True.
Source code in packages/axm-edit/src/axm_edit/models/operations.py
DeleteOp
Bases: BaseModel
Delete an existing file.
Fails if the file does not exist.
Source code in packages/axm-edit/src/axm_edit/models/operations.py
Edit
Bases: BaseModel
A single line-level edit within a replace operation.
Attributes:
| Name | Type | Description |
|---|---|---|
line |
int | None
|
Optional 1-indexed line hint in the original file.
If provided, used as a starting point for searching |
old |
str
|
Expected content to find and replace (validation anchor).
May contain |
new |
str
|
Replacement content. |
Source code in packages/axm-edit/src/axm_edit/models/operations.py
ReplaceOp
Bases: BaseModel
Modify lines in an existing file.
All line numbers reference the file as originally read, before any edits are applied. The engine sorts edits bottom-to-top to avoid line-shift problems.
Source code in packages/axm-edit/src/axm_edit/models/operations.py
ValidationError
Bases: BaseModel
A single validation failure.
Source code in packages/axm-edit/src/axm_edit/models/operations.py
| Python | |
|---|---|