Expand description
Pure edit matching and diff helpers for the edit tool.
Ports .references/pi/packages/coding-agent/src/core/tools/edit-diff.ts.
Matching runs against the original LF-normalized file; multi-edits apply in
reverse offset order. Fuzzy matches preserve untouched original line bytes.
Structs§
- Applied
Edits Result - Result of applying edits to LF-normalized content.
- Diff
String Result - Display-oriented diff result.
- Edit
- One exact-text replacement.
Enums§
- Line
Ending - Line ending detected from file content (first occurrence wins).
Functions§
- apply_
edits_ to_ normalized_ content - Apply one or more exact-text replacements to LF-normalized content.
- detect_
line_ ending - Detect line ending from the first newline occurrence.
- generate_
diff_ string - Generate a display-oriented numbered diff with context collapse.
- generate_
unified_ patch - Generate a standard contextual unified patch.
- normalize_
for_ fuzzy_ match - Normalize text for fuzzy matching (NFKC, trimEnd, quotes, dashes, spaces).
- normalize_
to_ lf - Normalize
\r\nand bare\rto\n. - restore_
line_ endings - Restore LF content to the original line ending style.
- strip_
bom - Strip a leading UTF-8 BOM, returning
(bom, text_without_bom).