Expand description
Write/Edit/MultiEdit tool — Rust port of @agent-sh/harness-write.
Contract matches agent-knowledge/design/write.md and the TS
package: atomic write via temp file + rename, read-before-edit
ledger enforcement (NOT_READ_THIS_SESSION / STALE_READ), fuzzy
candidates on OLD_STRING_NOT_FOUND, match locations on
OLD_STRING_NOT_UNIQUE, CRLF→LF normalization, sequential
MultiEdit pipeline with rollback on failure.
Structs§
- Apply
Result - Edit
Meta - Edit
Params - Edit
Spec - Error
Result - Fuzzy
Candidate - InMemory
Ledger - Ledger
Entry - Match
Location - Multi
Edit Meta - Multi
Edit Params - Preview
Meta - Preview
Result - Text
Write Result - Write
Meta - Write
Params - Write
Session Config
Enums§
Constants§
- BINARY_
SAMPLE_ BYTES - CONTEXT_
LINES - DEFAULT_
FUZZY_ LENGTH_ TOLERANCE - DEFAULT_
FUZZY_ THRESHOLD - DEFAULT_
FUZZY_ TOP_ K - EDIT_
TOOL_ DESCRIPTION - EDIT_
TOOL_ NAME - MAX_
EDIT_ FILE_ SIZE - MULTIEDIT_
TOOL_ DESCRIPTION - MULTIEDIT_
TOOL_ NAME - Canonical MultiEdit tool name. Matches
fn multi_editand the snake_case convention used by every other multi-word tool name in the workspace (bash_output,bash_kill). - MULTIEDIT_
TOOL_ NAME_ LEGACY Deprecated - Legacy MultiEdit tool name (pre-0.3.0 spelling). Still accepted as an alias anywhere tool names are matched/dispatched, but deprecated.
- WRITE_
TOOL_ DESCRIPTION - WRITE_
TOOL_ NAME
Traits§
- Ledger
- Mirror of the TS
Ledgersurface: keyed by path, most-recent wins.
Functions§
- apply_
edit - Apply a single edit spec to
content. Returns either the new content + counts, or a structured ToolError. - apply_
pipeline - build_
match_ locations - edit
- find_
all_ occurrences - Find all exact occurrences of
needleinhaystack. Returns byte offsets. - find_
fuzzy_ candidates - is_
multi_ edit_ tool_ name - Returns
trueifnamenames the MultiEdit tool — either the canonical"multi_edit"or the deprecated legacy"multiedit"spelling. - levenshtein
- Levenshtein distance O(n*m) time, O(min(n,m)) space.
- multi_
edit - normalize_
line_ endings - Normalize CRLF → LF. Matches the TS normalizer exactly.
- normalize_
multi_ edit_ tool_ name - Resolves
nameto the canonical MultiEdit tool name ("multi_edit"), orNonewhennameis not a MultiEdit spelling. - safe_
parse_ edit_ params - safe_
parse_ multi_ edit_ params - safe_
parse_ write_ params - similarity
- substring_
boundary_ collisions - Boundary-collision check: flag lines where
needlesits adjacent to identifier characters — caller may be stomping on a longer identifier. - unified_
diff - Produce a unified-diff string. Uses the
similarcrate’s grouped hunks. Output shape:--- old\n+++ new\n@@ ... @@\n ...\n- ...\n+ .... - warn_
legacy_ multi_ edit_ tool_ name - Emits a one-time (per process) deprecation warning on stderr telling the
caller to migrate from
"multiedit"to"multi_edit". Subsequent calls are no-ops, so dispatch loops do not spam logs. - write