@ossl-dev/differens-core
This package contains the tree matching engine. It takes two node trees and produces a typed edit script. The algorithm follows the GumTree lineage: top-down isomorphic matching finds anchors, bottom-up container matching pairs the rest, and leaf recovery fills the gaps. The result is a typed edit script with a minimal Move set. The package has zero dependencies. Tier adapters in@ossl-dev/differens-tiers parse source into Node trees and call diffTrees.
Install:
Exports
diffTrees
{ changes: EditAction[], nodeCount: number, fallback?: "lines" }. When either tree exceeds maxNodes, fallback is "lines" and the change list is empty. Line-diff instead in that case.
MatchOptions
Node
Both hashes are 53-bit-safe folds of two 32-bit FNV-1a streams, so subtree equality is an integer compare.
EditAction
context: NodeContext[] is the containment chain, nearest ancestor first. Each entry is { kind, label? }. It lets narration say “removed parse from class Config”, and gives AI tooling the full chain without re-parsing.
RenameDetail: { kind: "Renamed", from, to }.
ValueChangeDetail: { kind: "ValueChanged", from?, to? }.