Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Align ¶ added in v1.19.0
func Align[T comparable](a, b []T) []int
Align matches a against b along a longest common subsequence: for each element of a it returns the index of the element of b it is paired with, or -1 when it is not part of the subsequence. Pairs are strictly increasing in both a and b. It runs Myers' O((N+M)D) algorithm in linear space — splitting each problem at the middle of its shortest edit path (the bisection diff-match-patch uses) — so long inputs with many differences need no frontier history and no budget.
func Unified ¶
Unified produces a standard unified diff (3 context lines) of two file bodies for the agent harness’s edit/write tools. The output round-trips through Parse so the existing renderDiffBlock pipeline renders agent edits exactly like any other diff block. Returns "" when the bodies are identical. No ---/+++ file header is emitted: toolDiffMsg carries the path separately and Parse drops pre-@@ lines anyway.
Types ¶
type Hunk ¶
Hunk represents a unified diff hunk.
func Parse ¶
Parse turns a unified diff string into a slice of Hunks. Lines whose first character is neither space, +, -, nor \ are kept verbatim (no prefix re-writing) so renderDiffBlock’s existing prefix-based styling applies. Lines before the first `@@` (file headers like "--- a/f") are dropped — we already know the path from the FileUpdateChange record.