Skip to main content

Crate oxicode_hashline

Crate oxicode_hashline 

Source
Expand description

oxicode-hashline — line-anchored patch format for AI-assisted code editing.

Pure-function library: no filesystem, no agent runtime, no schema library. The host (oxicode-agent) injects a patcher::HashlineFs implementation.

Ported from omp’s packages/hashline/ (TypeScript). Same algorithms, same test contracts, Rust idioms.

Re-exports§

pub use apply::apply_edits;
pub use format::compute_file_hash;
pub use normalize::normalize_to_lf;
pub use normalize::strip_bom;
pub use parser::Patch;
pub use parser::PatchSection;
pub use parser::split_patch_input;
pub use patcher::HashlineFs;
pub use patcher::Patcher;
pub use snapshots::InMemorySnapshotStore;
pub use snapshots::Snapshot;
pub use snapshots::SnapshotStore;
pub use types::Anchor;
pub use types::Cursor;
pub use types::Edit;

Modules§

apply
Apply a parsed list of Edits to a text body and return the post-edit text plus diagnostic warnings.
diff_preview
Re-number a line-level diff between two file versions into a compact current-file preview.
format
Hashline format primitives: sigils, separators, and display helpers. Single source of truth for the parser, tokenizer, prompt, and grammar.
grammar
Grammar tokens and keywords. Mirrors omp’s grammar.lark but as Rust constants/enums — no parser generator needed (the parser is hand-written).
messages
Centralized error/warning text for the hashline parser, applier, and patcher.
mismatch
Error type raised when a section’s snapshot tag does not match the live file content and recovery is unavailable / has failed.
normalize
Minimal text-shape normalization: line-ending detection / round-trip and BOM stripping. The patcher uses these to canonicalize text to LF before applying edits and to restore the original shape on write-back.
parser
Token-driven state machine that turns a stream of Tokens into a flat list of Edits, plus the top-level envelope splitter that carves an authored patch into PatchSections.
patcher
Filesystem-backed patch orchestrator.
recovery
Snapshot-tag drift recovery.
snapshots
Per-session snapshot store used by recovery and the patcher to bind hashline section tags to the exact file content that minted them.
tokenizer
Stateful, line-oriented classifier for hashline diff text.
types
Pure data types shared across the hashline parser, applier, and patcher. No filesystem, agent runtime, or schema library references — keep it pure.