3510f9c3
feat: prosediff — word-level prose diff over markdown block structure
The Phase 0 de-risk gate. Segments a document into blocks with goldmark (headings, paragraphs, list items, code fences, table rows, block quotes, frontmatter), aligns the two block sequences with Myers over content hashes, and diffs word-by-word inside modified prose blocks and line-by-line inside modified code fences. Whitespace and line wrapping alone produce no diff in prose, and always do in code — that split is the whole point. Moves are detected by verbatim anchor and grown over their neighbours, so a relocated section does not explode into add+remove; a move that also bridges one edited block is recognised, a section rewritten while moving is not, and that limit is pinned by a test rather than papered over. SPIKE.md reports the verdict against twelve real revisions of docs/DESIGN.md: rewrapping the whole 1139-line document produces 1563 changed lines for git and zero changes here; 77% of real prose modifications read as small edits; 13% shred and want a two-column fallback in the web layer, which BlockChange.Similarity already gates. Verdict: the approach works, build the review UI on it.
Eugene Blikh <bigbes@gmail.com> — 2026-07-22 08:29:26 UTC
Commit 3510f9c3484dfb709691780afed3e0662bc889ec —
view raw patch
Parent(s):
db7d6c0f
| File | Status | + | − |
|---|---|---|---|
prosediff/SPIKE.md
|
A | +304 | |
prosediff/align.go
|
A | +397 | |
prosediff/cmd/prosediff/main.go
|
A | +55 | |
prosediff/myers.go
|
A | +234 | |
prosediff/myers_test.go
|
A | +126 | |
prosediff/prosediff.go
|
A | +140 | |
prosediff/prosediff_test.go
|
A | +417 | |
prosediff/render.go
|
A | +216 | |
prosediff/segment.go
|
A | +457 | |
prosediff/segment_test.go
|
A | +150 | |
prosediff/token.go
|
A | +273 | |
prosediff/token_test.go
|
A | +140 |