Dependency-ordered layers
Builds an import graph over the changed files with ts-morph and splits the diff so nothing depends on a later layer. Handles relative imports, tsconfig paths and package.json imports aliases.
DiffCarve takes the pull request your coding agent just opened and splits it into layers ordered by what imports what, each with a reviewability score.
Coding agents write a whole feature in one go. DiffCarve decides where to cut, from the code itself.
Builds an import graph over the changed files with ts-morph and splits the diff so nothing depends on a later layer. Handles relative imports, tsconfig paths and package.json imports aliases.
0 to 100 per layer, pass at 50, with the lines, files, complexity delta and reverse dependencies behind it, so you know which layers to skim.
per layer--dry-run prints the proposed stack as the markdown a PR comment would carry.
Silent under 400 changed lines by default, otherwise posts or updates one comment. Needs only GITHUB_TOKEN, never blocks or approves, and your source never leaves the runner.
From the README. Node 22.18 or newer. Run it from the branch the PR targets: it diffs the branch against its merge base with HEAD.
npm install
npm run build
node dist/cli.js analyze my-feature-branch
node dist/cli.js analyze my-feature-branch --dry-run
npm test && npm run lint
As a GitHub Action, add uses: ai-automation-tools/diff-carve@main to a workflow on pull_request (opened, synchronize) with fetch-depth: 0; the optional threshold input sets the changed-line count before it comments. The full workflow is in the README.
On ten real oversized PRs the layers came out sensible on 6 (results), signed off as enough to keep building. No config file yet; diffcarve.yml, stacked PR chains, a merge gate and Python come later.