Skip to content

phoenix-assistant/pr-accelerator

Repository files navigation

pr-accelerator

Cut PR review time from 48h to 4h. Smart reviewer assignment, semantic diff summaries, and load balancing for GitHub repositories.

CI npm License: MIT


Why?

PRs sit idle because:

  • Wrong reviewer assigned — the person has no context on the changed files
  • Overloaded reviewers — some engineers have 10 PRs queued, others have 0
  • No summary — reviewers spend 20 minutes just understanding what changed

pr-accelerator solves all three with one CLI.


Install

npm install -g @phoenixaihub/pr-accelerator
# or use npx (no install needed in CI)
npx @phoenixaihub/pr-accelerator analyze 42

Requirements:

  • Node.js 18+
  • gh CLI installed and authenticated (gh auth login)
  • Run inside a git repository

Commands

pr-accelerator analyze <pr-number>

Full PR analysis: complexity score, semantic diff summary, and reviewer recommendations.

$ pr-accelerator analyze 142

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 PR #142: feat: add OAuth2 provider support
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Author: alice
  Files:  14  |  +342 -87

▸ Review Complexity
  Level:    COMPLEX (score: 68/100)
  Est. time: ~175 minutes
  Factors:
    Lines changed              ████████████         +17.1
    Files touched              ████████             +14.0
    High-risk areas            ███████████          +12.0
    Directory spread           ████                 +7.5
    New files                  ████                 +6.0
    Deleted files              ██                   +3.0

▸ Semantic Diff Summary

  🔐 Auth & Permissions
     +189 -42 across 5 file(s)
     src/auth/oauth.ts
     src/auth/providers/google.ts
     src/auth/providers/github.ts
     src/auth/session.ts
     src/middleware/auth.ts

  🧪 Test Updates
     +98 -20 across 4 file(s)
     src/auth/oauth.test.ts
     ...

  ⚙️ Configuration
     +55 -25 across 3 file(s)

▸ Reviewer Recommendations

  🥇 Bob Chen
     Score:     142.3
     Open PRs:  1
     Est. wait: ~4.2h
     Expertise: src/auth/session.ts, src/middleware/auth.ts

  🥈 Sarah Kim
     Score:     98.7
     Open PRs:  3
     Est. wait: ~8.1h
     Expertise: src/auth/oauth.ts

▸ AI-Style Summary
  Core changes in: Auth & Permissions, API / Endpoints. Tests updated (4 files). Configuration changed

pr-accelerator reviewers [--file <path>]

Show expertise rankings across the codebase, or for a specific file.

# Overall rankings
pr-accelerator reviewers

# Expertise for a specific file
pr-accelerator reviewers --file src/auth/login.ts

Output:

▸ Overall Codebase Expertise Rankings

  🥇 Alice Smith              score:   287.45  commits: 142
      Top areas: src/auth, src/api, src/core
  🥈 Bob Chen                 score:   198.20  commits: 98
  🥉 Sarah Kim                score:   156.80  commits: 77

Expertise scoring algorithm:

  • TF-IDF on git log: contributors to rare files score higher than contributors to common files
  • Exponential decay: recent commits weighted more (90-day half-life by default)
  • Lines touched: more code touched = higher signal
  • Formula: score = Σ(files) recency × log(1 + lines) × IDF(file)

pr-accelerator load

Show current reviewer queue and recommend the least-loaded expert.

pr-accelerator load

Output:

▸ Current Queue

  Alice Smith               5 open     avg: 4.0h  est. wait: ~24.0h
  Bob Chen                  1 open     avg: 4.0h  est. wait: ~8.0h
  Sarah Kim                 0 open     avg: 4.0h  est. wait: ~4.0h

▸ Recommendation
  Assign to: Sarah Kim
  Expected wait: ~4.0h
  Current queue: 0 PRs

Uses an M/M/c queue model for wait time estimation.


pr-accelerator summarize <pr-number>

Generate a semantic diff summary (terminal, markdown, or PR comment).

# Terminal output
pr-accelerator summarize 42

# Post as PR comment
pr-accelerator summarize 42 --comment

# Output markdown
pr-accelerator summarize 42 --markdown

When posted as a comment (--comment), it produces:

## 🤖 PR Summary — *feat: add OAuth2 provider support*

> Generated by pr-accelerator

### 🔐 Auth & Permissions
**+189 -42** across 5 file(s)
- `src/auth/oauth.ts`
- ...

### ⚠️ Potential Breaking Changes
- Possible removed export in src/auth/session.ts

pr-accelerator setup

Initialize .pr-accelerator.yml for your repo.

pr-accelerator setup

Creates .pr-accelerator.yml:

# pr-accelerator configuration

# Minimum number of reviewers required before merging
minReviewers: 2

# Automatically assign reviewers when CI runs pr-accelerator ci auto-assign
autoAssign: false

# Paths to ignore when computing expertise scores
ignorePaths:
  - "*.lock"
  - "dist/**"
  - "node_modules/**"
  - ".github/**"

# Expertise decay: contributions older than this many days are weighted less
expertiseDecayDays: 90

# Maximum number of reviewer suggestions to show
maxReviewersToSuggest: 3

# Use load balancing (M/M/c model) when suggesting reviewers
loadBalancing: true

pr-accelerator ci — GitHub Actions Integration

Auto-assign reviewers

pr-accelerator ci auto-assign

Post semantic summary as PR comment

pr-accelerator ci summarize

GitHub Actions Setup

Add to .github/workflows/pr-accelerator.yml:

name: PR Accelerator

on:
  pull_request:
    types: [opened, synchronize, reopened]

permissions:
  contents: read
  pull-requests: write

jobs:
  pr-analysis:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0  # needed for git history

      - uses: actions/setup-node@v4
        with:
          node-version: 20

      - name: Post semantic summary
        run: npx @phoenixaihub/pr-accelerator ci summarize
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}

      - name: Auto-assign reviewers
        run: npx @phoenixaihub/pr-accelerator ci auto-assign
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}

Note: fetch-depth: 0 is required so pr-accelerator can analyze git history for expertise scoring.


Algorithms

Expertise Scoring (TF-IDF)

For each file in the PR, we find all historical contributors and weight them:

score(contributor, file) = TF × IDF

TF = Σ(commits) recency_weight × log(1 + lines_changed)
IDF = log(total_commits / (1 + contributors_to_file))
recency_weight = exp(-ln(2) / decay_days × age_days)

Contributors with deep expertise in rarely-touched files score highest.

Load Balancing (M/M/c Queue)

We model the review process as a queue:

  • λ = PR arrival rate
  • μ = reviewer service rate (from historical review times)
  • Expected wait = queue_length / μ + 1/μ

We assign to the reviewer minimizing expected wait × expertise penalty.

Semantic Grouping

Files are clustered by:

  1. Pattern matching — test/spec, config, auth, api, ui, docs, deps, ci patterns
  2. Directory proximity — files in the same directory/module grouped together
  3. Purpose labels — human-readable labels generated from cluster type + top directory

Config File Schema

Field Type Default Description
minReviewers number 2 Minimum reviewers to assign
autoAssign boolean false Auto-assign in CI mode
ignorePaths string[] ["*.lock", "dist/**"] Glob patterns to ignore
expertiseDecayDays number 90 Half-life for recency weighting
maxReviewersToSuggest number 3 Max suggestions shown
loadBalancing boolean true Use M/M/c load balancing

Development

git clone https://github.com/phoenix-assistant/pr-accelerator
cd pr-accelerator
npm install
npm run build
npm test

Contributing

See CONTRIBUTING.md.


License

MIT © Phoenix AI Hub

About

Cut PR review time from 48h to 4h. Smart reviewer assignment, semantic diffs, load balancing.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors