mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-19 12:00:37 +08:00
Compare commits
7 Commits
ok/base_ur
...
ok/fix_imp
Author | SHA1 | Date | |
---|---|---|---|
2dcee63df5 | |||
cddf183e03 | |||
e80a0ed9c8 | |||
d6d362b51e | |||
4eff0282a1 | |||
8fc07df6ef | |||
84e4b607cc |
3
.github/workflows/pr-agent-review.yaml
vendored
3
.github/workflows/pr-agent-review.yaml
vendored
@ -26,6 +26,7 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
PINECONE.API_KEY: ${{ secrets.PINECONE_API_KEY }}
|
PINECONE.API_KEY: ${{ secrets.PINECONE_API_KEY }}
|
||||||
PINECONE.ENVIRONMENT: ${{ secrets.PINECONE_ENVIRONMENT }}
|
PINECONE.ENVIRONMENT: ${{ secrets.PINECONE_ENVIRONMENT }}
|
||||||
GITHUB_ACTION.AUTO_REVIEW: true
|
GITHUB_ACTION.AUTO_REVIEW: 'true'
|
||||||
|
GITHUB_ACTION.AUTO_IMPROVE: 'true'
|
||||||
|
|
||||||
|
|
||||||
|
@ -410,6 +410,8 @@ BITBUCKET_BEARER_TOKEN: <your token>
|
|||||||
|
|
||||||
You can get a Bitbucket token for your repository by following Repository Settings -> Security -> Access Tokens.
|
You can get a Bitbucket token for your repository by following Repository Settings -> Security -> Access Tokens.
|
||||||
|
|
||||||
|
Note that comments on a PR are not supported in Bitbucket Pipeline.
|
||||||
|
|
||||||
|
|
||||||
### Run using CodiumAI-hosted Bitbucket app
|
### Run using CodiumAI-hosted Bitbucket app
|
||||||
|
|
||||||
|
29
Usage.md
29
Usage.md
@ -32,14 +32,19 @@ The [Tools Guide](./docs/TOOLS_GUIDE.md) provides a detailed description of the
|
|||||||
#### Ignoring files from analysis
|
#### Ignoring files from analysis
|
||||||
In some cases, you may want to exclude specific files or directories from the analysis performed by CodiumAI PR-Agent. This can be useful, for example, when you have files that are generated automatically or files that shouldn't be reviewed, like vendored code.
|
In some cases, you may want to exclude specific files or directories from the analysis performed by CodiumAI PR-Agent. This can be useful, for example, when you have files that are generated automatically or files that shouldn't be reviewed, like vendored code.
|
||||||
|
|
||||||
To ignore files or directories, edit the **[ignore.toml](/pr_agent/settings/ignore.toml)** configuration file. This setting is also exposed the following environment variables:
|
To ignore files or directories, edit the **[ignore.toml](/pr_agent/settings/ignore.toml)** configuration file. This setting also exposes the following environment variables:
|
||||||
|
|
||||||
- `IGNORE.GLOB`
|
- `IGNORE.GLOB`
|
||||||
- `IGNORE.REGEX`
|
- `IGNORE.REGEX`
|
||||||
|
|
||||||
For example, to ignore python files in a PR, set:
|
For example, to ignore python files in a PR with online usage, comment on a PR:
|
||||||
|
`/review --ignore.glob=['*.py']`
|
||||||
|
|
||||||
`ignore.glob = ['*.py']`
|
To ignore python files in all PRs, set in a configuration file:
|
||||||
|
```
|
||||||
|
[ignore]
|
||||||
|
glob = ['*.py']
|
||||||
|
```
|
||||||
|
|
||||||
#### git provider
|
#### git provider
|
||||||
The [git_provider](pr_agent/settings/configuration.toml#L4) field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported:
|
The [git_provider](pr_agent/settings/configuration.toml#L4) field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported:
|
||||||
@ -61,7 +66,7 @@ The [git_provider](pr_agent/settings/configuration.toml#L4) field in the configu
|
|||||||
|
|
||||||
### Working from a local repo (CLI)
|
### Working from a local repo (CLI)
|
||||||
When running from your local repo (CLI), your local configuration file will be used.
|
When running from your local repo (CLI), your local configuration file will be used.
|
||||||
Examples for invoking the different tools via the CLI:
|
Examples of invoking the different tools via the CLI:
|
||||||
|
|
||||||
- **Review**: `python -m pr_agent.cli --pr_url=<pr_url> review`
|
- **Review**: `python -m pr_agent.cli --pr_url=<pr_url> review`
|
||||||
- **Describe**: `python -m pr_agent.cli --pr_url=<pr_url> describe`
|
- **Describe**: `python -m pr_agent.cli --pr_url=<pr_url> describe`
|
||||||
@ -85,7 +90,7 @@ python -m pr_agent.cli --pr_url=<pr_url> /review --pr_reviewer.extra_instructio
|
|||||||
publish_output=true
|
publish_output=true
|
||||||
verbosity_level=2
|
verbosity_level=2
|
||||||
```
|
```
|
||||||
This is useful for debugging or experimenting with the different tools.
|
This is useful for debugging or experimenting with different tools.
|
||||||
|
|
||||||
|
|
||||||
### Online usage
|
### Online usage
|
||||||
@ -102,17 +107,17 @@ Commands for invoking the different tools via comments:
|
|||||||
|
|
||||||
|
|
||||||
To edit a specific configuration value, just add `--config_path=<value>` to any command.
|
To edit a specific configuration value, just add `--config_path=<value>` to any command.
|
||||||
For example if you want to edit the `review` tool configurations, you can run:
|
For example, if you want to edit the `review` tool configurations, you can run:
|
||||||
```
|
```
|
||||||
/review --pr_reviewer.extra_instructions="..." --pr_reviewer.require_score_review=false
|
/review --pr_reviewer.extra_instructions="..." --pr_reviewer.require_score_review=false
|
||||||
```
|
```
|
||||||
Any configuration value in [configuration file](pr_agent/settings/configuration.toml) file can be similarly edited. comment `/config` to see the list of available configurations.
|
Any configuration value in [configuration file](pr_agent/settings/configuration.toml) file can be similarly edited. Comment `/config` to see the list of available configurations.
|
||||||
|
|
||||||
|
|
||||||
### Working with GitHub App
|
### Working with GitHub App
|
||||||
When running PR-Agent from GitHub App, the default [configuration file](pr_agent/settings/configuration.toml) from a pre-built docker will be initially loaded.
|
When running PR-Agent from GitHub App, the default [configuration file](pr_agent/settings/configuration.toml) from a pre-built docker will be initially loaded.
|
||||||
|
|
||||||
By uploading a local `.pr_agent.toml` file, you can edit and customize any configuration parameter.
|
By uploading a local `.pr_agent.toml` file to the root of the repo's main branch, you can edit and customize any configuration parameter.
|
||||||
|
|
||||||
For example, if you set in `.pr_agent.toml`:
|
For example, if you set in `.pr_agent.toml`:
|
||||||
|
|
||||||
@ -121,7 +126,7 @@ For example, if you set in `.pr_agent.toml`:
|
|||||||
num_code_suggestions=1
|
num_code_suggestions=1
|
||||||
```
|
```
|
||||||
|
|
||||||
Than you will overwrite the default number of code suggestions to be 1.
|
Then you will overwrite the default number of code suggestions to 1.
|
||||||
|
|
||||||
#### GitHub app automatic tools
|
#### GitHub app automatic tools
|
||||||
The [github_app](pr_agent/settings/configuration.toml#L76) section defines GitHub app-specific configurations.
|
The [github_app](pr_agent/settings/configuration.toml#L76) section defines GitHub app-specific configurations.
|
||||||
@ -135,7 +140,7 @@ The GitHub app can respond to the following actions on a PR:
|
|||||||
4. `review_requested` - Specifically requesting review (in the PR reviewers list) from the `github-actions[bot]` user
|
4. `review_requested` - Specifically requesting review (in the PR reviewers list) from the `github-actions[bot]` user
|
||||||
|
|
||||||
The configuration parameter `handle_pr_actions` defines the list of actions for which the GitHub app will trigger the PR-Agent.
|
The configuration parameter `handle_pr_actions` defines the list of actions for which the GitHub app will trigger the PR-Agent.
|
||||||
The configuration parameter `pr_commands` defines the list of tools that will be **run automatically** when one of the above action happens (e.g. a new PR is opened):
|
The configuration parameter `pr_commands` defines the list of tools that will be **run automatically** when one of the above actions happens (e.g., a new PR is opened):
|
||||||
```
|
```
|
||||||
[github_app]
|
[github_app]
|
||||||
handle_pr_actions = ['opened', 'reopened', 'ready_for_review', 'review_requested']
|
handle_pr_actions = ['opened', 'reopened', 'ready_for_review', 'review_requested']
|
||||||
@ -175,11 +180,11 @@ push_commands = [
|
|||||||
"/auto_review -i --pr_reviewer.remove_previous_review_comment=true",
|
"/auto_review -i --pr_reviewer.remove_previous_review_comment=true",
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
The means that when new code is pushed to the PR, the PR-Agent will run the `describe` and incremental `auto_review` tools.
|
This means that when new code is pushed to the PR, the PR-Agent will run the `describe` and incremental `auto_review` tools.
|
||||||
For the describe tool, the `add_original_user_description` and `keep_original_user_title` parameters will be set to true.
|
For the describe tool, the `add_original_user_description` and `keep_original_user_title` parameters will be set to true.
|
||||||
For the `auto_review` tool, it will run in incremental mode, and the `remove_previous_review_comment` parameter will be set to true.
|
For the `auto_review` tool, it will run in incremental mode, and the `remove_previous_review_comment` parameter will be set to true.
|
||||||
|
|
||||||
Much like the configurations for `pr_commands`, you can override the default tool paramteres by uploading a local configuration file to the root of your repo.
|
Much like the configurations for `pr_commands`, you can override the default tool parameters by uploading a local configuration file to the root of your repo.
|
||||||
|
|
||||||
#### Editing the prompts
|
#### Editing the prompts
|
||||||
The prompts for the various PR-Agent tools are defined in the `pr_agent/settings` folder.
|
The prompts for the various PR-Agent tools are defined in the `pr_agent/settings` folder.
|
||||||
|
@ -11,7 +11,12 @@ def filter_ignored(files):
|
|||||||
try:
|
try:
|
||||||
# load regex patterns, and translate glob patterns to regex
|
# load regex patterns, and translate glob patterns to regex
|
||||||
patterns = get_settings().ignore.regex
|
patterns = get_settings().ignore.regex
|
||||||
patterns += [fnmatch.translate(glob) for glob in get_settings().ignore.glob]
|
if isinstance(patterns, str):
|
||||||
|
patterns = [patterns]
|
||||||
|
glob_setting = get_settings().ignore.glob
|
||||||
|
if isinstance(glob_setting, str): # --ignore.glob=[.*utils.py], --ignore.glob=.*utils.py
|
||||||
|
glob_setting = glob_setting.strip('[]').split(",")
|
||||||
|
patterns += [fnmatch.translate(glob) for glob in glob_setting]
|
||||||
|
|
||||||
# compile all valid patterns
|
# compile all valid patterns
|
||||||
compiled_patterns = []
|
compiled_patterns = []
|
||||||
|
@ -282,7 +282,7 @@ def _fix_key_value(key: str, value: str):
|
|||||||
try:
|
try:
|
||||||
value = yaml.safe_load(value)
|
value = yaml.safe_load(value)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
get_logger().error(f"Failed to parse YAML for config override {key}={value}", exc_info=e)
|
get_logger().debug(f"Failed to parse YAML for config override {key}={value}", exc_info=e)
|
||||||
return key, value
|
return key, value
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,13 +65,13 @@ async def run_action():
|
|||||||
if action in ["opened", "reopened"]:
|
if action in ["opened", "reopened"]:
|
||||||
pr_url = event_payload.get("pull_request", {}).get("url")
|
pr_url = event_payload.get("pull_request", {}).get("url")
|
||||||
if pr_url:
|
if pr_url:
|
||||||
auto_review = os.environ.get('github_action.auto_review', None)
|
auto_review = get_settings().get('GITHUB_ACTION.AUTO_REVIEW', None)
|
||||||
if auto_review is None or (isinstance(auto_review, str) and auto_review.lower() == 'true'):
|
if auto_review is None or (isinstance(auto_review, str) and auto_review.lower() == 'true'):
|
||||||
await PRReviewer(pr_url).run()
|
await PRReviewer(pr_url).run()
|
||||||
auto_describe = os.environ.get('github_action.auto_describe', None)
|
auto_describe = get_settings().get('GITHUB_ACTION.AUTO_DESCRIBE', None)
|
||||||
if isinstance(auto_describe, str) and auto_describe.lower() == 'true':
|
if isinstance(auto_describe, str) and auto_describe.lower() == 'true':
|
||||||
await PRDescription(pr_url).run()
|
await PRDescription(pr_url).run()
|
||||||
auto_improve = os.environ.get('github_action.auto_improve', None)
|
auto_improve = get_settings().get('GITHUB_ACTION.AUTO_IMPROVE', None)
|
||||||
if isinstance(auto_improve, str) and auto_improve.lower() == 'true':
|
if isinstance(auto_improve, str) and auto_improve.lower() == 'true':
|
||||||
await PRCodeSuggestions(pr_url).run()
|
await PRCodeSuggestions(pr_url).run()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user