Add bus-factor analyzer script

Implements scripts/bus-factor.mjs — a standalone Node.js CLI that shells
out to git log --numstat to collect per-file, per-author commit stats,
then computes bus-factor scores (number of contributors with >10%
ownership) for every source file in server/src/, client/src/, and
db/migrations/.

High-risk files (bus-factor=1) are surfaced prominently in the default
report. A --json flag emits machine-readable output for CI. Pure
analysis functions (parseGitLog, computeOwnership, scoreFiles, repoStats)
are unit-tested with Vitest (19 tests, all passing).

No new runtime dependencies — only Node.js built-ins and git are required.
Run via: node scripts/bus-factor.mjs [--json] [--min-commits N] [--top N]

Nightshift-Task: bus-factor
Nightshift-Ref: https://github.com/marcus/nightshift
This commit is contained in:
2026-03-20 03:03:26 -04:00
parent ccd0fb2155
commit 066d50fa89
5 changed files with 1596 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
globals: true,
environment: 'node',
},
});