Expand description
Core review engine for diffler: diff computation, sessions, comments, viewed marks.
This crate holds all logic with no terminal dependency, so it can be tested headless and reused by the TUI, the MCP server, and future frontends.
Modules§
- diff
- Intra-line diff: byte ranges of changed regions between a paired old/new line, used for word-level emphasis on top of line diffs.
- feedback
- Markdown export of review feedback: comments with diff context, ready to paste into any agent prompt.
- git
- git2 backend for the
Vcstrait: the only module that may touch git2 (test fixtures aside). - highlight
- Whole-file syntax highlighting via tree-sitter, sliced into per-line styled ranges. Highlighting whole files (not hunks) keeps multi-line constructs like strings correct across hunk boundaries. Unknown languages and parse failures degrade to plain (empty) ranges so rendering never breaks.
- model
- Diff model: what changed, organized as files -> hunks -> lines.
- pairing
- Pair deleted/added line runs inside a hunk and attach intra-line emphasis. Within a run, lines pair by best total similarity (delta’s homologous-line model): an unbalanced run pairs each line with its true counterpart, and lines with no counterpart stay unpaired and render plain — emphasis only ever contrasts a line against its homolog.
- repo
- Repository discovery.
- review
- Facade tying the VCS backend, session, and store together: the one entry point the TUI and MCP layers consume.
- session
- Review session: comments and per-file viewed marks, reconciled against
fresh diff models. Persistence lives in
store. - source
- What a review is of: the working tree, a single commit, or a contiguous commit range. A source has a deterministic, filesystem-safe persistence key and a human-facing label, so review state can be tracked per source and the agent can be told exactly what the human reviewed.
- store
- Session persistence: one file per review source under
.diffler/reviews/, atomically written, self-gitignored. The legacy single-session file.diffler/session.jsonis read once and migrated toreviews/working.json. - syntax
- Tree-sitter foundation shared by highlighting, scope context, and the
structural diff. Grammars are statically linked (no runtime loading, since
musl-static binaries cannot
dlopen); a parse failure or unknown language degrades silently to plain behavior so the UI is never blocked. - vcs
- Backend-agnostic VCS interface. Everything above this trait consumes
dyn Vcs; only thegitandrepomodules (and test fixtures) may import git2.