mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 20:30:41 +08:00
Merge pull request #10 from Codium-ai/readme-updates
add giff, icon and demo section
This commit is contained in:
144
README.md
144
README.md
@ -1,51 +1,59 @@
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
|
<img src="./pics/Icon-7.png" alt="pr-agent_icon" width="100"/>
|
||||||
|
|
||||||
# pr-agent
|
# pr-agent
|
||||||
|
|
||||||
[](https://github.com/Codium-ai/pr-agent/blob/main/LICENSE)
|
[](https://github.com/Codium-ai/pr-agent/blob/main/LICENSE)
|
||||||
[](https://discord.com/channels/1057273017547378788/1126104260430528613)
|
[](https://discord.com/channels/1057273017547378788/1126104260430528613)
|
||||||
|
|
||||||
CodiumAI `PR-Agent` is an open-source tool that helps developers review PRs faster and more efficiently.
|
CodiumAI `pr-agent` is an open-source tool is powered by GPT-4 aming to help developers review PRs faster and more efficiently. It automatically analyzes the PR, and provides feedback and suggestions, and can answer questions.
|
||||||
It automatically analyzes the PR, and provides feedback and suggestions, and can answer questions.
|
|
||||||
It is powered by GPT-4, and is based on the [CodiumAI](https://github.com/Codium-ai/) platform.
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
- [Quickstart](#Quickstart)
|
||||||
|
- [Configuration](#Configuration)
|
||||||
|
- [Usage and Tools](#usage-and-tools)
|
||||||
|
- [Roadmap](#roadmap)
|
||||||
|
- [Similar projects](#similar-projects)
|
||||||
|
|
||||||
|
## Live demo
|
||||||
|
|
||||||
* [Quickstart](#Quickstart)
|
Experience GPT-4 powered PR review on your public Github repository with our hosted pr-agent. To try it, mention @CodiumAI-Agent in a PR comment! The agent will generate the review response ([see details in the Usage section](https://github.com/Codium-ai/pr-agent#usage-and-tools)).
|
||||||
* [Configuration](#Configuration)
|
|
||||||
* [Usage and Tools](#usage-and-tools)
|
|
||||||
* [Roadmap](#roadmap)
|
|
||||||
* [Similar projects](#similar-projects)
|
|
||||||
|
|
||||||
|

|
||||||
## Quickstart
|
|
||||||
|
|
||||||
To get started with PR-Agent quickly, you first need to acquire two tokens:
|
|
||||||
1. An OpenAI key from [here](https://platform.openai.com/), with access to GPT-4.
|
|
||||||
2. A GitHub personal access token (classic) with the repo scope.
|
|
||||||
|
|
||||||
There are several ways to use PR-Agent. Let's start with the simplest one:
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Method 1: Use Docker image (no installation required)
|
## Quickstart
|
||||||
|
|
||||||
To request a review for a PR, or ask a question about a PR, you can run the appropriate
|
To get started with pr-agent quickly, you first need to acquire two tokens:
|
||||||
Python scripts from the scripts folder. Here's how:
|
|
||||||
|
1. An OpenAI key from [here](https://platform.openai.com/), with access to GPT-4.
|
||||||
|
2. A GitHub personal access token (classic) with the repo scope.
|
||||||
|
|
||||||
|
There are several ways to use pr-agent. Let's start with the simplest one:
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### Method 1: Use Docker image (no installation required)
|
||||||
|
|
||||||
|
To request a review for a PR, or ask a question about a PR, you can run directly from the Docker image. Here's how:
|
||||||
|
|
||||||
1. To request a review for a PR, run the following command:
|
1. To request a review for a PR, run the following command:
|
||||||
|
|
||||||
```
|
```
|
||||||
docker run --rm -it -e OPENAI.KEY=<your key> -e GITHUB.USER_TOKEN=<your token> codiumai/pr-agent --pr_url <pr url>
|
docker run --rm -it -e OPENAI.KEY=<your key> -e GITHUB.USER_TOKEN=<your token> codiumai/pr-agent --pr_url <pr url>
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
2. To ask a question about a PR, run the following command:
|
2. To ask a question about a PR, run the following command:
|
||||||
|
|
||||||
```
|
```
|
||||||
docker run --rm -it -e OPENAI.KEY=<your key> -e GITHUB.USER_TOKEN=<your token> codiumai/pr-agent --pr_url <pr url> --question "<your question>"
|
docker run --rm -it -e OPENAI.KEY=<your key> -e GITHUB.USER_TOKEN=<your token> codiumai/pr-agent --pr_url <pr url> --question "<your question>"
|
||||||
```
|
```
|
||||||
|
|
||||||
Possible questions you can ask include:
|
Possible questions you can ask include:
|
||||||
|
|
||||||
- What is the main theme of this PR?
|
- What is the main theme of this PR?
|
||||||
- Is the PR ready for merge?
|
- Is the PR ready for merge?
|
||||||
- What are the main changes in this PR?
|
- What are the main changes in this PR?
|
||||||
@ -54,25 +62,29 @@ Possible questions you can ask include:
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Method 2: Run from source
|
#### Method 2: Run from source
|
||||||
|
|
||||||
1. Clone this repository:
|
1. Clone this repository:
|
||||||
|
|
||||||
```
|
```
|
||||||
git clone https://github.com/Codium-ai/pr-agent.git
|
git clone https://github.com/Codium-ai/pr-agent.git
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Install the requirements in your favorite virtual environment:
|
2. Install the requirements in your favorite virtual environment:
|
||||||
|
|
||||||
```
|
```
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Copy the secrets template file and fill in your OpenAI key and your GitHub user token:
|
3. Copy the secrets template file and fill in your OpenAI key and your GitHub user token:
|
||||||
|
|
||||||
```
|
```
|
||||||
cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets
|
cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets
|
||||||
# Edit .secrets file
|
# Edit .secrets file
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Run the appropriate Python scripts from the scripts folder:
|
4. Run the appropriate Python scripts from the scripts folder:
|
||||||
|
|
||||||
```
|
```
|
||||||
python pr_agent/cli.py --pr_url <pr url>
|
python pr_agent/cli.py --pr_url <pr url>
|
||||||
python pr_agent/cli.py --pr_url <pr url> --question "<your question>"
|
python pr_agent/cli.py --pr_url <pr url> --question "<your question>"
|
||||||
@ -80,19 +92,21 @@ python pr_agent/cli.py --pr_url <pr url> --question "<your question>"
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Method 3: Method 3: Run as a polling server; request reviews by tagging your Github user on a PR
|
#### Method 3: Method 3: Run as a polling server; request reviews by tagging your Github user on a PR
|
||||||
|
|
||||||
Follow steps 1-3 of method 2.
|
Follow steps 1-3 of method 2.
|
||||||
Run the following command to start the server:
|
Run the following command to start the server:
|
||||||
|
|
||||||
```
|
```
|
||||||
python pr_agent/servers/github_polling.py
|
python pr_agent/servers/github_polling.py
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Method 4: Run as a Github App, allowing you to automate the review process on your private or public repositories.
|
#### Method 4: Run as a Github App, allowing you to automate the review process on your private or public repositories.
|
||||||
|
|
||||||
1. Create a GitHub App from the [Github Developer Portal](https://docs.github.com/en/developers/apps/creating-a-github-app).
|
1. Create a GitHub App from the [Github Developer Portal](https://docs.github.com/en/developers/apps/creating-a-github-app).
|
||||||
|
|
||||||
- Set the following permissions:
|
- Set the following permissions:
|
||||||
- Pull requests: Read & write
|
- Pull requests: Read & write
|
||||||
- Issue comment: Read & write
|
- Issue comment: Read & write
|
||||||
@ -102,15 +116,18 @@ python pr_agent/servers/github_polling.py
|
|||||||
- Pull request
|
- Pull request
|
||||||
|
|
||||||
2. Generate a random secret for your app, and save it for later. For example, you can use:
|
2. Generate a random secret for your app, and save it for later. For example, you can use:
|
||||||
|
|
||||||
```
|
```
|
||||||
WEBHOOK_SECRET=$(python -c "import secrets; print(secrets.token_hex(10))")
|
WEBHOOK_SECRET=$(python -c "import secrets; print(secrets.token_hex(10))")
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Acquire the following pieces of information from your app's settings page:
|
3. Acquire the following pieces of information from your app's settings page:
|
||||||
|
|
||||||
- App private key (click "Generate a private key", and save the file)
|
- App private key (click "Generate a private key", and save the file)
|
||||||
- App ID
|
- App ID
|
||||||
|
|
||||||
4. Clone this repository:
|
4. Clone this repository:
|
||||||
|
|
||||||
```
|
```
|
||||||
git clone https://github.com/Codium-ai/pr-agent.git
|
git clone https://github.com/Codium-ai/pr-agent.git
|
||||||
```
|
```
|
||||||
@ -121,21 +138,24 @@ git clone https://github.com/Codium-ai/pr-agent.git
|
|||||||
- Copy your app's private key to the private_key field.
|
- Copy your app's private key to the private_key field.
|
||||||
- Copy your app's ID to the app_id field.
|
- Copy your app's ID to the app_id field.
|
||||||
- Copy your app's webhook secret to the webhook_secret field.
|
- Copy your app's webhook secret to the webhook_secret field.
|
||||||
|
|
||||||
```
|
```
|
||||||
cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets
|
cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets
|
||||||
# Edit .secrets file
|
# Edit .secrets file
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Build a Docker image for the app and optionally push it to a Docker repository. We'll use Dockerhub as an example:
|
6. Build a Docker image for the app and optionally push it to a Docker repository. We'll use Dockerhub as an example:
|
||||||
|
|
||||||
```
|
```
|
||||||
docker build . -t codiumai/pr-agent:github_app --target github_app -f docker/Dockerfile
|
docker build . -t codiumai/pr-agent:github_app --target github_app -f docker/Dockerfile
|
||||||
docker push codiumai/pr-agent:github_app # Push to your Docker repository
|
docker push codiumai/pr-agent:github_app # Push to your Docker repository
|
||||||
```
|
```
|
||||||
|
|
||||||
7. Host the app using a server, serverless function, or container environment. Alternatively, for development and
|
7. Host the app using a server, serverless function, or container environment. Alternatively, for development and
|
||||||
debugging, you may use tools like smee.io to forward webhooks to your local machine.
|
debugging, you may use tools like smee.io to forward webhooks to your local machine.
|
||||||
|
|
||||||
8. Go back to your app's settings, set the following:
|
8. Go back to your app's settings, set the following:
|
||||||
|
|
||||||
- Webhook URL: The URL of your app's server, or the URL of the smee.io channel.
|
- Webhook URL: The URL of your app's server, or the URL of the smee.io channel.
|
||||||
- Webhook secret: The secret you generated earlier.
|
- Webhook secret: The secret you generated earlier.
|
||||||
|
|
||||||
@ -144,11 +164,14 @@ docker push codiumai/pr-agent:github_app # Push to your Docker repository
|
|||||||
---
|
---
|
||||||
|
|
||||||
## Usage and Tools
|
## Usage and Tools
|
||||||
CodiumAI PR-Agent provides two types of interactions ("tools"): `"PR Reviewer"` and `"PR Q&A"`.
|
|
||||||
|
CodiumAI pr-agent provides two types of interactions ("tools"): `"PR Reviewer"` and `"PR Q&A"`.
|
||||||
|
|
||||||
- The "PR Reviewer" tool automatically analyzes PRs, and provides different types of feedbacks.
|
- The "PR Reviewer" tool automatically analyzes PRs, and provides different types of feedbacks.
|
||||||
- The "PR Q&A" tool answers free-text questions about the PR.
|
- The "PR Q&A" tool answers free-text questions about the PR.
|
||||||
|
|
||||||
### PR Reviewer
|
### PR Reviewer
|
||||||
|
|
||||||
Here is a quick overview of the different sub-tools of PR Reviewer:
|
Here is a quick overview of the different sub-tools of PR Reviewer:
|
||||||
|
|
||||||
- PR Analysis
|
- PR Analysis
|
||||||
@ -162,10 +185,10 @@ Here is a quick overview of the different sub-tools of PR Reviewer:
|
|||||||
- General PR suggestions
|
- General PR suggestions
|
||||||
- Code suggestions
|
- Code suggestions
|
||||||
|
|
||||||
|
|
||||||
This is how a typical output of the PR Reviewer looks like:
|
This is how a typical output of the PR Reviewer looks like:
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
#### PR Analysis
|
#### PR Analysis
|
||||||
|
|
||||||
- 🎯 **Main theme:** Adding language extension handler and token handler
|
- 🎯 **Main theme:** Adding language extension handler and token handler
|
||||||
@ -181,26 +204,26 @@ This is how a typical output of the PR Reviewer looks like:
|
|||||||
|
|
||||||
- 🤖 **Code suggestions:**
|
- 🤖 **Code suggestions:**
|
||||||
|
|
||||||
|
|
||||||
- **relevant file:** pr_agent/algo/language_handler.py
|
- **relevant file:** pr_agent/algo/language_handler.py
|
||||||
|
|
||||||
**suggestion content:** Consider using a set instead of a list for 'bad_extensions' as checking membership in a set is faster than in a list. [medium]
|
**suggestion content:** Consider using a set instead of a list for 'bad_extensions' as checking membership in a set is faster than in a list. [medium]
|
||||||
|
|
||||||
|
|
||||||
- **relevant file:** pr_agent/algo/language_handler.py
|
- **relevant file:** pr_agent/algo/language_handler.py
|
||||||
|
|
||||||
**suggestion content:** In the 'filter_bad_extensions' function, you are splitting the filename on '.' and taking the last element to get the extension. This might not work as expected if the filename contains multiple '.' characters. Consider using 'os.path.splitext' to get the file extension more reliably. [important]
|
**suggestion content:** In the 'filter_bad_extensions' function, you are splitting the filename on '.' and taking the last element to get the extension. This might not work as expected if the filename contains multiple '.' characters. Consider using 'os.path.splitext' to get the file extension more reliably. [important]
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
### PR Q&A
|
### PR Q&A
|
||||||
|
|
||||||
This tool answers free-text questions about the PR. This is how a typical output of the PR Q&A looks like:
|
This tool answers free-text questions about the PR. This is how a typical output of the PR Q&A looks like:
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Question**: summarize for me the PR in 4 bullet points
|
**Question**: summarize for me the PR in 4 bullet points
|
||||||
|
|
||||||
**Answer**:
|
**Answer**:
|
||||||
|
|
||||||
- The PR introduces a new feature to sort files by their main languages. It uses a mapping of programming languages to their file extensions to achieve this.
|
- The PR introduces a new feature to sort files by their main languages. It uses a mapping of programming languages to their file extensions to achieve this.
|
||||||
- It also introduces a filter to exclude files with certain extensions, deemed as 'bad extensions', from the sorting process.
|
- It also introduces a filter to exclude files with certain extensions, deemed as 'bad extensions', from the sorting process.
|
||||||
- The PR modifies the `get_pr_diff` function in `pr_processing.py` to use the new sorting function. It also refactors the code to move the PR pruning logic into a separate function.
|
- The PR modifies the `get_pr_diff` function in `pr_processing.py` to use the new sorting function. It also refactors the code to move the PR pruning logic into a separate function.
|
||||||
@ -209,53 +232,64 @@ This tool answers free-text questions about the PR. This is how a typical output
|
|||||||
---
|
---
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
The different tools and sub-tools used by CodiumAI PR-Agent are easily configurable via the configuration file: `/settings/configuration.toml`.
|
|
||||||
|
The different tools and sub-tools used by CodiumAI pr-agent are easily configurable via the configuration file: `/settings/configuration.toml`.
|
||||||
|
|
||||||
#### Enabling/disabling sub-tools:
|
#### Enabling/disabling sub-tools:
|
||||||
You can enable/disable the different PR Reviewer sub-sections with the following flags:
|
|
||||||
|
You can enable/disable the different PR Reviewer sub-sections with the following flags:
|
||||||
|
|
||||||
```
|
```
|
||||||
require_minimal_and_focused_review=true
|
require_minimal_and_focused_review=true
|
||||||
require_tests_review=true
|
require_tests_review=true
|
||||||
require_security_review=true
|
require_security_review=true
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Code Suggestions configuration:
|
#### Code Suggestions configuration:
|
||||||
|
|
||||||
There are also configuration options to control different aspects of the `code suggestions` feature.
|
There are also configuration options to control different aspects of the `code suggestions` feature.
|
||||||
The number of suggestions provided can be controlled by adjusting the following parameter:
|
The number of suggestions provided can be controlled by adjusting the following parameter:
|
||||||
|
|
||||||
```
|
```
|
||||||
num_code_suggestions=4
|
num_code_suggestions=4
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also enable more verbose and informative mode of code suggestions:
|
You can also enable more verbose and informative mode of code suggestions:
|
||||||
|
|
||||||
```
|
```
|
||||||
extended_code_suggestions=false
|
extended_code_suggestions=false
|
||||||
```
|
```
|
||||||
|
|
||||||
This is a comparison of the regular and extended code suggestions modes:
|
This is a comparison of the regular and extended code suggestions modes:
|
||||||
|
|
||||||
---
|
---
|
||||||
Example for regular suggestion:
|
|
||||||
|
|
||||||
- **relevant file:** sql.py
|
- **relevant file:** sql.py
|
||||||
- **suggestion content:** Remove hardcoded sensitive information like username and password. Use environment variables or a secure method to store these values. [important]
|
- **suggestion content:** Remove hardcoded sensitive information like username and password. Use environment variables or a secure method to store these values. [important]
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Example for extended suggestion:
|
Example for extended suggestion:
|
||||||
|
|
||||||
- **relevant file:** sql.py
|
- **relevant file:** sql.py
|
||||||
- **suggestion content:** Remove hardcoded sensitive information (username and password) [important]
|
- **suggestion content:** Remove hardcoded sensitive information (username and password) [important]
|
||||||
- **why:** Hardcoding sensitive information is a security risk. It's better to use environment variables or a secure way to store these values.
|
- **why:** Hardcoding sensitive information is a security risk. It's better to use environment variables or a secure way to store these values.
|
||||||
- **code example:**
|
- **code example:**
|
||||||
- **before code:**
|
- **before code:**
|
||||||
```
|
```
|
||||||
user = "root",
|
user = "root",
|
||||||
password = "Mysql@123",
|
password = "Mysql@123",
|
||||||
```
|
```
|
||||||
- **after code:**
|
- **after code:**
|
||||||
```
|
```
|
||||||
user = os.getenv('DB_USER'),
|
user = os.getenv('DB_USER'),
|
||||||
password = os.getenv('DB_PASSWORD'),
|
password = os.getenv('DB_PASSWORD'),
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
## Roadmap
|
## Roadmap
|
||||||
|
|
||||||
- [ ] Support open-source models, as a replacement for openai models. Note that a minimal requirement for each open-source model is to have 8k+ context, and good support for generating json as an output
|
- [ ] Support open-source models, as a replacement for openai models. Note that a minimal requirement for each open-source model is to have 8k+ context, and good support for generating json as an output
|
||||||
- [ ] Support other Git providers, such as Gitlab and Bitbucket.
|
- [ ] Support other Git providers, such as Gitlab and Bitbucket.
|
||||||
- [ ] Develop additional logics for handling large PRs, and compressing git patches
|
- [ ] Develop additional logics for handling large PRs, and compressing git patches
|
||||||
@ -270,7 +304,9 @@ Example for extended suggestion:
|
|||||||
- [ ] ...
|
- [ ] ...
|
||||||
|
|
||||||
## Similar Projects
|
## Similar Projects
|
||||||
|
|
||||||
- [CodiumAI - Meaningful tests for busy devs](https://github.com/Codium-ai/codiumai-vscode-release)
|
- [CodiumAI - Meaningful tests for busy devs](https://github.com/Codium-ai/codiumai-vscode-release)
|
||||||
- [Aider - GPT powered coding in your terminal](https://github.com/paul-gauthier/aider)
|
- [Aider - GPT powered coding in your terminal](https://github.com/paul-gauthier/aider)
|
||||||
- [GPT-Engineer](https://github.com/AntonOsika/gpt-engineer)
|
- [GPT-Engineer](https://github.com/AntonOsika/gpt-engineer)
|
||||||
- [CodeReview BOT](https://github.com/anc95/ChatGPT-CodeReview)
|
- [CodeReview BOT](https://github.com/anc95/ChatGPT-CodeReview)
|
||||||
|
- [AI-Maintainer](https://github.com/merwanehamadi/AI-Maintainer)
|
||||||
|
BIN
pics/.DS_Store
vendored
Normal file
BIN
pics/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
pics/Icon-7.png
Normal file
BIN
pics/Icon-7.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 100 KiB |
BIN
pics/pr-agent-review-process1.gif
Normal file
BIN
pics/pr-agent-review-process1.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
Reference in New Issue
Block a user