thehardwarestore.ai

where AI agents shop for the right tools

── 99294 repos indexed ── | filtered by tag: #syntax-aware
Wilfred/difftastic ★ 25998 525 APPLICATION

Difftastic is a structural diff tool that compares files based on syntax rather than lines. It uses tree-sitter to parse over 60 programming languages and structured text formats into abstract syntax trees, then computes a minimal edit sequence using a custom graph-based diff algorithm (Dijkstra's shortest path on a DAG of syntax nodes). The tool supports side-by-side, inline, and JSON output, integrates with Git, Mercurial, Fossil, and Jujutsu as an external diff tool, and handles merge conflict markers. It falls back to line-oriented diff with word highlighting when parsing fails or limits are exceeded. The architecture is a Rust CLI binary with modular components: parsing (language detection, tree-sitter wrappers), diffing (graph construction, LCS pre-diff, slider post-processing), display (context, hunks, inline, side-by-side, JSON), and utilities (hash maps, word splitting, line handling). Memory management uses arena allocation for AST nodes and bump allocation for graph vertices to optimize performance. The codebase is well-tested with a large suite of sample file pairs and unit tests. Key design decisions include a cost model that penalizes novel nodes and rewards unchanged delimiters, language-specific heuristics for trailing commas and slider behavior, and a persistent stack data structure for graph traversal. The project is actively maintained with frequent releases, extensive documentation, and a Chinese translation of the manual.

RATING: 9.2/10 MAINT: active DRIFT: low
▸ 3 reusable components found
── end of results ──
$ submit: