Skip to main content

Crate diffler_core

Crate diffler_core 

Source
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§

classify
Which bucket a changed file belongs to, from its path alone. The rule order is the design: Generated outranks Tests so a generated fixture reads as noise, and Build outranks Config so Cargo.toml reads as a manifest.
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 Vcs trait: 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, a contiguous commit range, or everything since a named revision. 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.json is read once and migrated to reviews/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 the git and repo modules (and test fixtures) may import git2.