File bytes
file_bytes
Byte-exact inspection of a file already present on disk.
Strictly read-only: the file is opened once in binary mode (rb) and nothing
is ever written, created or renamed. Detection and verdict are delegated in
full to :func:axm_edit.core.byte_report.build_report; this module only
performs the I/O, maps the core report onto
:class:axm_edit.models.file_bytes.FileBytesReport and shapes the
ToolResult.
Lesson L4: what matters is the bytes actually present on disk after a write routed through MCP, never a value Python has already decoded.
FileBytesTool
Bases: AXMTool
Report what a file really contains, byte for byte, without writing.
Orchestration and shaping layer only: every rule lives in
:mod:axm_edit.core.byte_report. No code path opens the file for
writing, so calling this tool can never change the target.
Source code in packages/axm-edit/src/axm_edit/tools/file_bytes.py
name
property
Tool name used for MCP registration.
execute(*, path=None, expected=None, expect_escaped=False, encoding=_SUPPORTED_ENCODING, **kwargs)
Inspect the bytes of one file, without ever touching the disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | None
|
Absolute path to the file to inspect. |
None
|
expected
|
str | None
|
Content the caller believes it wrote, when known. |
None
|
expect_escaped
|
bool
|
Whether escape sequences are expected verbatim on disk rather than the literal characters they denote. |
False
|
encoding
|
str
|
Decoding used to read the report; only |
_SUPPORTED_ENCODING
|
kwargs
|
object
|
Ignored extra arguments (MCP forward-compatibility). |
{}
|
Returns:
| Type | Description |
|---|---|
ToolResult
|
|
ToolResult
|
|
ToolResult
|
diagnostic and not an execution failure; ``ToolResult( |
ToolResult
|
success=False, error=...)`` when the file could not be read. |
ToolResult
|
Never raises. |
Source code in packages/axm-edit/src/axm_edit/tools/file_bytes.py
render_text(report)
Render a byte report as the compact text consumed by the CLI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report
|
Mapping[str, object]
|
A serialised :class: |
required |
Returns:
| Type | Description |
|---|---|
str
|
A header carrying the verdict and the sha256, followed by every |
str
|
integer counter the report holds (size and bounded totals), plus the |
str
|
remediation hint when the core produced one. |