Skip to main content

harness_write/
lib.rs

1//! Write/Edit/MultiEdit tool — Rust port of `@agent-sh/harness-write`.
2//!
3//! Contract matches `agent-knowledge/design/write.md` and the TS
4//! package: atomic write via temp file + rename, read-before-edit
5//! ledger enforcement (NOT_READ_THIS_SESSION / STALE_READ), fuzzy
6//! candidates on OLD_STRING_NOT_FOUND, match locations on
7//! OLD_STRING_NOT_UNIQUE, CRLF→LF normalization, sequential
8//! MultiEdit pipeline with rollback on failure.
9
10mod constants;
11mod diff;
12mod engine;
13mod fence;
14mod format;
15mod ledger;
16mod levenshtein;
17mod matching;
18mod normalize;
19mod run;
20mod schema;
21mod types;
22
23pub use constants::*;
24pub use diff::unified_diff;
25pub use engine::{apply_edit, apply_pipeline, ApplyResult, PipelineResult};
26pub use ledger::{InMemoryLedger, Ledger, LedgerEntry};
27pub use levenshtein::{levenshtein, similarity};
28pub use matching::{
29    build_match_locations, find_all_occurrences, find_fuzzy_candidates,
30    substring_boundary_collisions,
31};
32pub use normalize::normalize_line_endings;
33pub use run::{edit, multi_edit, write};
34pub use schema::{
35    safe_parse_edit_params, safe_parse_multi_edit_params, safe_parse_write_params,
36    EDIT_TOOL_DESCRIPTION, EDIT_TOOL_NAME, EditParams, EditSpec, MULTIEDIT_TOOL_DESCRIPTION,
37    MULTIEDIT_TOOL_NAME, MultiEditParams, WRITE_TOOL_DESCRIPTION, WRITE_TOOL_NAME, WriteParams,
38    WriteParseError,
39};
40pub use types::{
41    EditMeta, EditResult, ErrorResult, FuzzyCandidate, MatchLocation, MultiEditMeta,
42    MultiEditResult, PreviewMeta, PreviewResult, TextWriteResult, WriteMeta, WriteResult,
43    WriteSessionConfig,
44};