forked from qodo-ai/pr-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/polling base #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
research-developer
wants to merge
7
commits into
main
Choose a base branch
from
feature/polling-base
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4741f0e
feat(polling): Add local polling infrastructure for GitHub and Railway
research-developer dc8d688
docs: Update README for local daemon fork
research-developer 3adebdd
feat(webhooks): Add universal webhook router with multi-platform dete…
research-developer e0f7bc6
Update pr_agent/polling/dispatcher.py
research-developer 4e43b1f
Update pr_agent/cli/main.py
research-developer 29144df
fix: Address PR review comments
research-developer 428cfe9
feat: Implement Railway and Cloudflare pollers
research-developer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,208 @@ | ||
| > [!NOTE] | ||
| > PR Agent is an open-source project originally created by Qodo, the company behind next-generation AI code review. This repository represents the legacy version of the project and is provided as-is for the community to explore, learn from, and build upon. The project now has its first external maintainer, Naor (([@naorpeled](https://github.com/naorpeled))), and is currently in the process of being donated to an open-source foundation. | ||
| # PR-Agent Local Daemon | ||
|
|
||
| ## 🚀 About | ||
| PR Agent was the first AI assistant for pull requests, built by Qodo, and contributed to the open-source community. | ||
| It represents the first generation of intelligent code review - the project that started Qodo’s journey toward fully AI-driven development, Code Review. | ||
| If you enjoy this project, you’ll love the next-level PR Agent - Qodo free tier version, which is faster, smarter, and built for today’s workflows. | ||
| A local polling-based PR agent that monitors GitHub notifications and Railway deployments, running as a background service on your machine. | ||
|
|
||
| 🚀 Qodo includes a free user trial, 250 tokens, bonus tokens for active contributors, and 50% more advanced features than this open-source version. | ||
| > **Fork Note**: This is a fork of [Qodo's PR-Agent](https://github.com/qodo-ai/pr-agent) adapted for local daemon operation with polling instead of webhooks. | ||
|
|
||
| If you have an open-source project, you can get the Qodo paid version for free for your project, powered by Google Gemini 2.5 Pro – [https://www.qodo.ai/solutions/open-source/](https://www.qodo.ai/solutions/open-source/) | ||
| ## Features | ||
|
|
||
| --- | ||
| - **GitHub Notification Polling** - Responds to @mentions on PRs with AI-powered reviews, descriptions, and suggestions | ||
| - **Railway Deployment Monitoring** - Tracks deployment status and can analyze failures | ||
| - **Local Daemon** - Runs as a background service, no webhook infrastructure needed | ||
| - **Multi-Repo Support** - Monitor multiple repositories from a single daemon | ||
| - **Simple CLI** - Easy setup and management | ||
|
|
||
| ## ✨ Advanced Features in Qodo | ||
| ## Quick Start | ||
|
|
||
| ### 🧭 PR → Ticket Automation | ||
| Seamlessly links pull requests to your project tracking system for end-to-end visibility. | ||
| ```bash | ||
| # Install | ||
| pip install -e . | ||
|
|
||
| ### ✅ Auto Best Practices | ||
| Learns your team’s standards and automatically enforces them during code reviews. | ||
| # Initialize a repository | ||
| cd ~/projects/myapp | ||
| pr-agent-daemon init | ||
|
|
||
| ### 🧪 Code Validation | ||
| Performs advanced static and semantic analysis to catch issues before merge. | ||
| # Configure credentials (or set environment variables) | ||
| pr-agent-daemon config set github_token ghp_xxx | ||
| pr-agent-daemon config set anthropic_api_key sk-ant-xxx | ||
|
|
||
| ### 💬 PR Chat Interface | ||
| Lets you converse with your PR to explain, summarize, or suggest improvements instantly. | ||
| # Start the daemon | ||
| pr-agent-daemon start | ||
|
|
||
| ### 🔍 Impact Evaluation | ||
| Analyzes the business and technical effect of each change before approval. | ||
| # Check status | ||
| pr-agent-daemon status | ||
| ``` | ||
|
|
||
| --- | ||
| ## CLI Commands | ||
|
|
||
| ## ❤️ Community | ||
| This open-source release remains here as a community contribution from Qodo — the origin of modern AI-powered code collaboration. | ||
| We’re proud to share it and inspire developers worldwide. | ||
| The daemon uses `pr-agent-daemon` command (separate from the original `pr-agent` CLI): | ||
|
|
||
| | Command | Description | | ||
| |---------|-------------| | ||
| | `pr-agent-daemon init` | Add current repo to config | | ||
| | `pr-agent-daemon start` | Start polling daemon | | ||
| | `pr-agent-daemon stop` | Stop daemon | | ||
| | `pr-agent-daemon status` | Show daemon status and tracked repos | | ||
| | `pr-agent-daemon config` | View/edit configuration | | ||
| | `pr-agent-daemon remove` | Remove repo from config | | ||
|
|
||
| The original `pr-agent` command remains available for direct PR reviews: | ||
| ```bash | ||
| pr-agent --pr_url=<URL> review | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| Configuration is stored at `~/.pr-agent/config.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "version": "1.0", | ||
| "credentials": { | ||
| "github_token": "ghp_xxx", | ||
| "anthropic_api_key": "sk-ant-xxx", | ||
| "railway_token": "railway_xxx" | ||
| }, | ||
| "settings": { | ||
| "poll_interval_github": 30, | ||
| "poll_interval_railway": 60, | ||
| "model": "claude-sonnet-4-20250514", | ||
| "log_level": "INFO", | ||
| "github_username": "my-bot" | ||
| }, | ||
| "repos": [ | ||
| { | ||
| "path": "/Users/you/projects/myapp", | ||
| "github_repo": "owner/myapp", | ||
| "railway_project_id": "abc123", | ||
| "auto_review": true, | ||
| "auto_describe": false | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ### Environment Variables | ||
|
|
||
| Credentials can also be set via environment variables (takes precedence over config file): | ||
|
|
||
| - `GITHUB_TOKEN` - GitHub personal access token | ||
| - `ANTHROPIC_API_KEY` - Anthropic API key | ||
| - `RAILWAY_TOKEN` - Railway API token | ||
|
|
||
| ## Architecture | ||
|
|
||
| ``` | ||
| ┌─────────────────────────────────────────────────────────┐ | ||
| │ pr-agent-daemon CLI │ | ||
| ├─────────────────────────────────────────────────────────┤ | ||
| │ init - Add repo to config │ | ||
| │ start - Start polling daemon │ | ||
| │ stop - Stop daemon │ | ||
| │ status - Show status │ | ||
| └─────────────────────────────────────────────────────────┘ | ||
| │ | ||
| ▼ | ||
| ┌─────────────────────────────────────────────────────────┐ | ||
| │ ~/.pr-agent/ │ | ||
| │ config.json - Repos, credentials, settings │ | ||
| │ daemon.pid - PID file │ | ||
| │ logs/ - Log files │ | ||
| └─────────────────────────────────────────────────────────┘ | ||
| │ | ||
| ▼ | ||
| ┌─────────────────────────────────────────────────────────┐ | ||
| │ Polling Daemon │ | ||
| ├─────────────────────────────────────────────────────────┤ | ||
| │ GitHubPoller - Poll notifications for @mentions │ | ||
| │ RailwayPoller - Poll deployment status changes │ | ||
| │ EventDispatcher - Route events to handlers │ | ||
| │ PRAgent - Generate AI responses │ | ||
| └─────────────────────────────────────────────────────────┘ | ||
| ``` | ||
|
|
||
| ## Usage Examples | ||
|
|
||
| ### Respond to PR Mentions | ||
|
|
||
| When someone mentions your bot on a PR: | ||
|
|
||
| ``` | ||
| @my-bot /review | ||
| ``` | ||
|
|
||
| The daemon will: | ||
| 1. Detect the notification via polling | ||
| 2. Parse the command (`/review`) | ||
| 3. Run PR-Agent's review tool | ||
| 4. Post the response as a comment | ||
|
|
||
| ### Available Commands | ||
|
|
||
| When mentioned on a PR, the bot responds to: | ||
|
|
||
| | Command | Description | | ||
| |---------|-------------| | ||
| | `/review` | Comprehensive code review | | ||
| | `/describe` | Generate PR description | | ||
| | `/improve` | Suggest code improvements | | ||
| | `/ask <question>` | Answer questions about the PR | | ||
| | `/update_changelog` | Update changelog | | ||
| | `/add_docs` | Generate documentation | | ||
|
|
||
| ### Railway Integration | ||
|
|
||
| Link a Railway project to get deployment notifications: | ||
|
|
||
| ```bash | ||
| pr-agent-daemon init --railway-project abc123 | ||
| ``` | ||
|
|
||
| The daemon will monitor deployments and can: | ||
| - Alert on failed deployments | ||
| - Analyze crash logs | ||
| - Correlate deployments with recent PRs | ||
|
|
||
| ## Development | ||
|
|
||
| ### Project Structure | ||
|
|
||
| ``` | ||
| pr_agent/ | ||
| ├── daemon/ # Daemon CLI commands | ||
| │ ├── config.py # Config management | ||
| │ └── main.py # Typer CLI | ||
| ├── polling/ # Polling infrastructure | ||
| │ ├── base.py # Abstract BasePoller | ||
| │ ├── events.py # Event models | ||
| │ ├── github.py # GitHub notification poller | ||
| │ ├── railway.py # Railway deployment poller | ||
| │ └── dispatcher.py # Event routing | ||
| ├── cli.py # Original PR-Agent CLI | ||
| └── ... # Original PR-Agent tools | ||
| ``` | ||
|
|
||
| ### Running in Development | ||
|
|
||
| ```bash | ||
| # Run in foreground with debug output | ||
| pr-agent-daemon start --foreground | ||
|
|
||
| # Or run directly | ||
| python -m pr_agent.daemon.main start -f | ||
| ``` | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Python 3.12+ | ||
| - GitHub personal access token with `notifications` and `repo` scopes | ||
| - Anthropic API key (or OpenAI API key) | ||
| - Railway API token (optional, for deployment monitoring) | ||
|
|
||
| ## License | ||
|
|
||
| Apache 2.0 - See [LICENSE](LICENSE) | ||
|
|
||
| ## Acknowledgments | ||
|
|
||
| Based on [Qodo PR-Agent](https://github.com/qodo-ai/pr-agent), the original AI-powered PR assistant. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| """ | ||
| PR-Agent Daemon for local polling-based PR reviews. | ||
|
|
||
| Commands: | ||
| pr-agent-daemon init - Add current repo to config | ||
| pr-agent-daemon start - Start polling daemon | ||
| pr-agent-daemon stop - Stop daemon | ||
| pr-agent-daemon status - Show daemon status | ||
| pr-agent-daemon config - View/edit config | ||
| """ | ||
|
|
||
| from pr_agent.daemon.config import Config, load_config, save_config | ||
| from pr_agent.daemon.main import main as run | ||
|
|
||
| __all__ = ["Config", "load_config", "save_config", "run"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README states "Python 3.12+" as a requirement, but the codebase uses deprecated
datetime.utcnow()which triggers deprecation warnings in Python 3.12+. While this won't break functionality, it's inconsistent with the stated Python version requirement. Consider either updating the code to use the non-deprecated API or adjusting the minimum version requirement.