Repository navigation
Description
Follow-up of #1520 (PR #1587); from the independent code review. This is the synchronous consolidation; the async move is #506 and stays there.
Problem
Four modules carry their own function git( wrapper over spawnSync("git", …): src/lib/skills-commit-state.ts:36 (returns null on failure), src/lib/worktree-isolation.ts:102 (takes the command as one string), src/lib/merge-check/combined-branch-test.ts:70 and src/lib/workflow/review-residue.post.ts:28 (both throw, with different error text; the last one picks a 64 MB maxBuffer, the others the default). grep -lE '^function git\(' <the four files> | wc -l → 4 today. Each copy drifts on its own: a change to how a failed git read is reported, or to the buffer a large diff needs, lands in one and not the others. src/lib/workflow/git-diff-utils.ts already hosts the shared git reads (resolveDiffBase, getCommitHash, getGitDiffStats) and is where one helper belongs.
Acceptance Criteria
- AC-1: One exported helper in
git-diff-utils.ts(for examplerunGit(cwd, args, { maxBuffer? }), throwing with one error shape) replaces the four local wrappers; each former site calls it and keeps its own failure policy at the call site (catch and returnnullwhere it did). Evidence:grep -lE '^function git\(' src/lib/skills-commit-state.ts src/lib/worktree-isolation.ts src/lib/merge-check/combined-branch-test.ts src/lib/workflow/review-residue.post.ts | wc -l | tr -d ' '→0(today4) - AC-2: The helper has its own test for the two outcomes (stdout on success; a thrown error that names the args and stderr on failure). Evidence:
npx vitest run src/lib/workflow/git-diff-utils.test.ts -t "runGit"→≥ 2 passed, 0 failed(new cases) - AC-3: The four callers' tests still pass. Evidence:
npx vitest run src/lib/skills-commit-state.integration.test.ts src/lib/worktree-isolation.test.ts src/lib/merge-check/combined-branch-test.test.ts src/lib/workflow/review-residue.post.test.ts→0 failed - AC-4: No function grows past the refactor(workflow): split run, ensureWorktree, executePhaseWithRetry and executePhase to ≤ 200 counted lines; max-lines-per-function ratchet for src/lib/workflow #1508 ratchet and no metric rises. Evidence:
npm run lint && npm run lint:health→ exit 0,no metric rose above the baseline
May touch
src/lib/workflow/git-diff-utils.ts and its test, the four listed files, CHANGELOG.
Non-Goals
- Making any of these async (arch: async I/O modernization — unblock true parallel execution #506).
- Touching
GitHubProvideror anyghcall (refactor(platform): every gh call goes through PlatformProvider; FakeGitHubProvider replays captured gh output so no test fakes gh through child_process #1506). - No edits under
plugin/,.claude/skills/,templates/skills/(plugin freeze).
Activity
docs(#1523): HANDOFF.md for graph-2026-10-review-surface — W0 and #1520…