Skip to content

Navigation Menu

Sign in
Sign up

Repository files navigation

AI-Powered PR Reviewer

A GitHub App that uses a multi-agent architecture to review Pull Requests with cross-file reasoning and codebase memory.

🌟 What Makes This Different

Unlike other AI reviewers that only see the diff, this bot understands your entire codebase:

  • Indexes your repo on installation
  • Finds related code across files you didn't change
  • Learns patterns from your codebase
  • Self-hosted = your code never leaves your infrastructure

Features

  • 🚫 Block Bad PRs: High-risk PRs get a failing status check (can't merge!)
  • πŸ”§ Auto-Fix Suggestions: AI generates code fixes for issues found
  • 🌐 Multi-Language: Python, JavaScript/TypeScript, Java, C/C++, Go, Rust
  • 🧠 RAG Context: Indexes your codebase for smarter reviews
  • πŸ“Š Map-Reduce: Handles large PRs by summarizing files individually
  • 🌳 Tree-sitter: Parses code structure (functions, classes, imports)
  • πŸ”— Cross-File Impact: Identifies files affected by your changes
  • πŸ”‘ Multi-Key Manager: Rotates Gemini API keys with rate-limit handling
  • ⚠️ Risk Scoring: Assigns risk based on size, tests, and impact

Setup

  1. Install Dependencies:

    pip install -r requirements.txt
  2. Configure Environment: Copy .env.example to .env and fill in:

    • APP_ID: Your GitHub App ID
    • PRIVATE_KEY_PATH: Path to your GitHub App private key
    • WEBHOOK_SECRET: Your webhook secret
    • GEMINI_API_KEYS: Comma-separated list of Gemini API keys
  3. Run the Server:

    uvicorn app.main:app --reload

How It Works

On GitHub App Installation

  1. Receives installation webhook
  2. Indexes entire repository in background
  3. Stores embeddings in local vector store

On Pull Request

  1. Status: Pending β†’ Shows "AI review in progress"
  2. Diff Analysis β†’ Fetch changed files
  3. Tree-sitter β†’ Parse code structure (7 languages)
  4. Map β†’ Summarize each file
  5. RAG β†’ Find related code in codebase
  6. Risk β†’ Calculate risk score (0-100)
  7. Reduce β†’ Generate final review
  8. Auto-Fix β†’ Generate code suggestions if issues found
  9. Status: Pass/Fail β†’ Block merge if risk β‰₯ 70

Architecture

app/
β”œβ”€β”€ main.py # FastAPI + webhooks
β”œβ”€β”€ core/
β”‚ β”œβ”€β”€ config.py # Settings
β”‚ β”œβ”€β”€ security.py # GitHub App JWT auth
β”‚ β”œβ”€β”€ llm.py # Gemini client
β”‚ β”œβ”€β”€ key_manager.py # Multi-key rotation
β”‚ β”œβ”€β”€ embeddings.py # Gemini embeddings
β”‚ β”œβ”€β”€ vector_store.py # ChromaDB wrapper
β”‚ β”œβ”€β”€ indexer.py # Codebase indexer
β”‚ └── code_parser.py # Tree-sitter parser
└── agents/
 β”œβ”€β”€ master.py # Orchestrator
 β”œβ”€β”€ diff.py # PR diff analysis
 β”œβ”€β”€ dependency.py # Cross-file dependencies
 β”œβ”€β”€ file_summary.py # File summarizer (MAP)
 β”œβ”€β”€ context.py # RAG context retrieval
 β”œβ”€β”€ test.py # Test impact
 β”œβ”€β”€ risk.py # Risk scoring
 └── writer.py # Review composer (REDUCE)

API Endpoints

Endpoint Description
POST /webhook GitHub webhook handler
GET / Health check
GET /stats/{owner}/{repo} Index statistics

Configuration

Variable Description
APP_ID GitHub App ID
PRIVATE_KEY_PATH Path to private key file
WEBHOOK_SECRET Webhook signature secret
GEMINI_API_KEYS Comma-separated API keys

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /