Skip to content

πŸ€– AI-powered Pull Request analysis bot that provides intelligent code reviews, impact analysis, and documentation updates

License

Notifications You must be signed in to change notification settings

sudo-whodo/pr-genius

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PR Genius πŸ€–

Build Status Version License: MIT Python Version

AI-powered pull request analysis tool that provides comprehensive code reviews, impact analysis, and documentation updates.

Features β€’ Quick Start β€’ Documentation β€’ Contributing

✨ Features

  • πŸ” Analyzes file changes in pull requests
  • πŸ“Š Provides detailed statistics (files changed, lines added/deleted)
  • 🧠 Uses OpenRouter AI models (default: Claude 3.5 Sonnet) to:
    • Analyze code changes and their impact
    • Identify potential risks and concerns
    • Suggest improvements
    • Generate documentation updates
  • πŸ’¬ Posts formatted summaries as PR comments
  • πŸ“š Maintains documentation requirements
  • πŸ” Supports authentication via GitHub token
  • πŸš€ Available as a GitHub Action

πŸš€ Quick Start

  1. Create .github/workflows/pr-analysis.yml in your repository:
name: PR Analysis
on:
  pull_request:
    types: [opened, synchronize]

jobs:
  analyze:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
      contents: read

    steps:
      - name: PR Diff Analysis
        uses: sudo-whodo/pr-genius@v1
        with:
          github_token: ${{ secrets.PAT_TOKEN }}
          openrouter_key: ${{ secrets.OPENROUTER_API_KEY }}
  1. Add required secrets to your repository:

    a. Personal Access Token (PAT):

    • Go to GitHub Settings > Developer settings > Personal access tokens > Tokens (classic)
    • Generate new token with:
      • repo scope (for repository access)
      • pull_requests scope (for commenting on PRs)
    • Add to repository secrets as PAT_TOKEN

    b. OpenRouter API Key:

That's it! PR Genius will now analyze your pull requests automatically.

πŸ“š Documentation

πŸ”§ Configuration

Action Inputs

Input Description Required Default
github_token Personal Access Token (PAT) Yes -
openrouter_key OpenRouter API key Yes -
repository Repository name (owner/repo) No Current repository
pull_request_number PR number to analyze No Current PR number
model OpenRouter model to use No anthropic/claude-3.5-sonnet

These inputs are mapped to environment variables inside the action:

  • Required inputs:
    • GITHUB_TOKEN: From github_token input
    • OPENROUTER_API_KEY: From openrouter_key input
  • Optional inputs:
    • REPOSITORY: From repository input (defaults to current repository)
    • PR_NUMBER: From pull_request_number input (defaults to current PR)
    • MODEL: From model input (defaults to claude-3.5-sonnet)

Required Permissions

The workflow needs these permissions:

permissions:
  pull-requests: write # For posting comments
  contents: read # For accessing repository contents

Additionally, your PAT_TOKEN must have:

  • repo scope for repository access
  • pull_requests scope for commenting on PRs

πŸ“Š Example Output

PR Genius adds a comment to your pull request with:

Click to see example output
## πŸ€– Pull Request Analysis

### πŸ“Š Statistics

- Files changed: 3
- Lines added: 150
- Lines deleted: 50

### 🧠 AI Code Review

Analysis by anthropic/claude-3.5-sonnet:
[Detailed code review with impact assessment, risks, and suggestions]

### πŸ“š Documentation Updates Needed

[Documentation suggestions based on changes]

### πŸ” Notable Changes

- Major changes in src/main.py: +100/-30 lines
- New file: tests/test_feature.py

⚠️ Troubleshooting

  1. Permission Issues (403 Forbidden)

    • Ensure you're using PAT_TOKEN, not GITHUB_TOKEN
    • Verify PAT has required scopes (repo, pull_requests)
    • Check that the token hasn't expired
  2. Missing OpenRouter API Key

    • Ensure you've added the OPENROUTER_API_KEY to your repository secrets
    • Check that the secret name matches exactly
  3. Rate Limits

    • OpenRouter has rate limits based on your plan
    • GitHub API also has rate limits
  4. Token Security

    • Never commit tokens directly in workflow files
    • Always use repository secrets
    • Regularly rotate your PAT for security

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes using conventional commits:
    • feat: add new feature
    • fix: resolve issue
    • docs: update documentation
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please read our Contributing Guidelines for details.

πŸ“‹ Requirements

  • Python 3.8+
  • GitHub Personal Access Token
  • OpenRouter API Key

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

πŸ€– AI-powered Pull Request analysis bot that provides intelligent code reviews, impact analysis, and documentation updates

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •