{"modulePath":"github.com/Agent-Field/codeaf","version":"v0.8.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package diffengine\n\nPackage diffengine ports src/pr\\_af/diff\\_engine.py — the deterministic (non-LLM) diff parser and clustering engine that feeds the anatomy phase.\n\nIt is a byte-for-byte behavioral port of the Python module. Where the Python implementation has quirks (see notes below) they are reproduced exactly rather than \"fixed\", because downstream golden comparisons and cluster/finding ordering depend on identical output:\n\n  - parse\\_unified\\_diff never emits a \"renamed\" status. Git rename headers (\\`rename from\\`/\\`rename to\\`, \\`similarity index\\`) are not special-cased; a rename surfaces as status \"modified\" with the path taken from the \\`+++ b/\\` line (or \"\" for a pure content-free rename that has no \\`+++ b/\\`).\n  - A deleted file (\\`+++ /dev/null\\`) never sets a path, so its Path is \"\".\n  - Binary files (no \\`---\\`/\\`+++\\` lines) yield a FileChange with Path \"\" and no hunks.\n  - Line splitting matches Python's str.splitlines() (not strings.Split on \"\\\\n\"): all Unicode line boundaries split, and a trailing line break does NOT produce a final empty element. This keeps hunk \\`content\\` byte-exact.\n\n## Functions\n\n```go\nfunc ClusterChanges(files []schemas.FileChange) []schemas.ChangeCluster\n```\nClusterChanges ports cluster\\_changes: group files by their directory (the path up to the last \"/\"; \"root\" when there is no \"/\"), then emit one cluster per directory in sorted-directory order with deterministic ids \"cluster\\_0\", \"cluster\\_1\", ... The primary language is the most frequent language in the group.\n\nDivergence note: Python computes primary\\_language via \\`max(set(langs), key=langs.count)\\`, whose tie-break depends on set iteration order and is therefore non-deterministic across Python processes (str hash randomization). This port instead breaks ties deterministically by first-appearance order within the group. For a unique mode (the overwhelming common case, including single-language groups) both agree exactly.\n\n```go\nfunc ComputeDiffStats(files []schemas.FileChange) schemas.DiffStats\n```\nComputeDiffStats ports compute\\_diff\\_stats: aggregate statistics over the parsed files. The test-to-code ratio divides the test-file count by max(code\\_files, 1) so it never divides by zero.\n\n```go\nfunc ParseUnifiedDiff(diffText string) []schemas.FileChange\n```\nParseUnifiedDiff parses unified diff text into structured FileChange objects. It is a direct port of Python parse\\_unified\\_diff, preserving branch order and the accumulation quirks documented on the package.\n\n","path":"github.com/Agent-Field/codeaf/internal/praf/diffengine","name":"diffengine","synopsis":"Package diffengine ports src/pr_af/diff_engine.py — the deterministic (non-LLM) diff parser and clustering engine that feeds the anatomy phase.","isRedistributable":true}
