diff --git a/.github/workflows/docs-ci.yaml b/.github/workflows/docs-ci.yaml new file mode 100644 index 00000000..1648fd44 --- /dev/null +++ b/.github/workflows/docs-ci.yaml @@ -0,0 +1,32 @@ +name: docs-ci +on: + push: + branches: + - main + - add-docs-portal + paths: + - docs/** +permissions: + contents: write +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Configure Git Credentials + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV + - uses: actions/cache@v4 + with: + key: mkdocs-material-${{ env.cache_id }} + path: .cache + restore-keys: | + mkdocs-material- + - run: pip install mkdocs-material + - run: pip install "mkdocs-material[imaging]" + - run: mkdocs gh-deploy -f docs/mkdocs.yml --force diff --git a/.gitignore b/.gitignore index c5c939de..47683742 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,5 @@ __pycache__ dist/ *.egg-info/ build/ -review.md .DS_Store +docs/.cache/ diff --git a/README.md b/README.md index 74c4a774..a09b341f 100644 --- a/README.md +++ b/README.md @@ -32,100 +32,101 @@ Making pull requests less painful with an AI agent ## News and Updates +### Jan 10, 2024 +- A new [knowledge-base website](https://pr-agent-docs.codium.ai/) for PR-Agent is now available. It includes detailed information about the different tools, usage guides and more, in an accessible and organized format. + +### Jan 8, 2024 + +- A new tool, [Find Similar Code](https://pr-agent-docs.codium.ai/tools/similar_code/) 💎 is now available. +
This tool retrieves the most similar code components from inside the organization's codebase, or from open-source code: + + + +(click on the image to see an instructional video) + ### Feb 29, 2024 -- You can now use the repo's [wiki page](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#configuration-options) to set configurations for PR-Agent 💎 +- You can now use the repo's [wiki page](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/) to set configurations for PR-Agent 💎 -### Feb 21, 2024 -- Added a new command, `/help`, to easily provide a list of available tools and their descriptions, and run them interactively. - - - - - - - -### Feb 18, 2024 -- Introducing the `CI Feedback` tool 💎. The tool automatically triggers when a PR has a failed check. It analyzes the failed check, and provides summarized logs and analysis. Note that this feature requires read access to GitHub 'checks' and 'actions'. See [here](./docs/CI_FEEDBACK.md) for more details. -- New ability - you can run `/ask` on specific lines of code in the PR from the PR's diff view. See [here](./docs/ASK.md#ask-lines) for more details. -- Introducing support for [Azure DevOps Webhooks](./Usage.md#azure-devops-webhook), as well as bug fixes and improved support for several ADO commands. - - ## Overview
CodiumAI PR-Agent is an open-source tool to help efficiently review and handle pull requests. -- See the [Installation Guide](./INSTALL.md) for instructions on installing and running the tool on different git platforms. +- See the [Installation Guide](https://pr-agent-docs.codium.ai/installation/) for instructions on installing and running the tool on different git platforms. -- See the [Usage Guide](./Usage.md) for instructions on running the PR-Agent commands via different interfaces, including _CLI_, _online usage_, or by _automatically triggering_ them when a new PR is opened. +- See the [Usage Guide](https://pr-agent-docs.codium.ai/usage-guide/) for instructions on running the PR-Agent commands via different interfaces, including _CLI_, _online usage_, or by _automatically triggering_ them when a new PR is opened. -- See the [Tools Guide](./docs/TOOLS_GUIDE.md) for a detailed description of the different tools (tools are run via the commands). +- See the [Tools Guide](https://pr-agent-docs.codium.ai/tools/) for a detailed description of the different tools (tools are run via the commands). Supported commands per platform: -| | | GitHub | Gitlab | Bitbucket | Azure DevOps | -|-------|-----------------------------------------------------------------------------------------------------------------------------------------|:--------------------:|:--------------------:|:--------------------:|:--------------------:| -| TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | ⮑ Incremental | :white_check_mark: | | | | -| | ⮑ [SOC2 Compliance](https://github.com/Codium-ai/pr-agent/blob/main/docs/REVIEW.md#soc2-ticket-compliance-) 💎 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Describe | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | ⮑ [Inline File Summary](https://github.com/Codium-ai/pr-agent/blob/main/docs/DESCRIBE.md#inline-file-summary-) 💎 | :white_check_mark: | | | | -| | Improve | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | ⮑ Extended | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Ask | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | ⮑ [Ask on code lines](./docs/ASK.md#ask-lines) | :white_check_mark: | :white_check_mark: | | | -| | [Custom Suggestions](https://github.com/Codium-ai/pr-agent/blob/main/docs/CUSTOM_SUGGESTIONS.md) 💎 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | [Test](https://github.com/Codium-ai/pr-agent/blob/main/docs/TEST.md) 💎 | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | Reflect and Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Update CHANGELOG.md | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Find Similar Issue | :white_check_mark: | | | | -| | [Add PR Documentation](https://github.com/Codium-ai/pr-agent/blob/main/docs/ADD_DOCUMENTATION.md) 💎 | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | [Custom Labels](https://github.com/Codium-ai/pr-agent/blob/main/docs/DESCRIBE.md#handle-custom-labels-from-the-repos-labels-page-gem) 💎 | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | [Analyze](https://github.com/Codium-ai/pr-agent/blob/main/docs/Analyze.md) 💎 | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | [CI Feedback](https://github.com/Codium-ai/pr-agent/blob/main/docs/CI_FEEDBACK.md) 💎 | :white_check_mark: | | | | -| | | | | | | -| USAGE | CLI | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | App / webhook | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Tagging bot | :white_check_mark: | | | | -| | Actions | :white_check_mark: | | :white_check_mark: | | -| | | | | | | -| CORE | PR compression | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Repo language prioritization | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Adaptive and token-aware file patch fitting | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | [Static code analysis](https://github.com/Codium-ai/pr-agent/blob/main/docs/Analyze.md) 💎 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | [Global and wiki configurations](./Usage.md#configuration) 💎 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | [PR Actions](https://www.codium.ai/images/pr_agent/pr-actions.mp4) 💎 | :white_check_mark: | | | | +| | | GitHub | Gitlab | Bitbucket | Azure DevOps | +|-------|-------------------------------------------------------------------------------------------------------------------|:--------------------:|:--------------------:|:--------------------:|:--------------------:| +| TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | ⮑ Incremental | :white_check_mark: | | | | +| | ⮑ [SOC2 Compliance](https://pr-agent-docs.codium.ai/tools/review/#soc2-ticket-compliance) 💎 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Describe | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | ⮑ [Inline File Summary](https://pr-agent-docs.codium.ai/tools/describe#inline-file-summary) 💎 | :white_check_mark: | | | | +| | Improve | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | ⮑ Extended | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Ask | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | ⮑ [Ask on code lines](https://pr-agent-docs.codium.ai/tools/ask#ask-lines) | :white_check_mark: | :white_check_mark: | | | +| | [Custom Suggestions](https://pr-agent-docs.codium.ai/tools/custom_suggestions/) 💎 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | [Test](https://pr-agent-docs.codium.ai/tools/test/) 💎 | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| | Reflect and Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Update CHANGELOG.md | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Find Similar Issue | :white_check_mark: | | | | +| | [Add PR Documentation](https://pr-agent-docs.codium.ai/tools/documentation/) 💎 | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| | [Custom Labels](https://pr-agent-docs.codium.ai/tools/custom_labels/) 💎 | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| | [Analyze](https://pr-agent-docs.codium.ai/tools/analyze/) 💎 | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| | [CI Feedback](https://pr-agent-docs.codium.ai/tools/ci_feedback/) 💎 | :white_check_mark: | | | | +| | [Similar Code](https://pr-agent-docs.codium.ai/tools/similar_code/) 💎 | :white_check_mark: | | | | +| | | | | | | +| USAGE | CLI | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | App / webhook | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Tagging bot | :white_check_mark: | | | | +| | Actions | :white_check_mark: | | :white_check_mark: | | +| | | | | | | +| CORE | PR compression | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Repo language prioritization | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Adaptive and token-aware file patch fitting | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | [Static code analysis](https://pr-agent-docs.codium.ai/core-abilities/#static-code-analysis) 💎 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | [Global and wiki configurations](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/) 💎 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | [PR interactive actions](https://www.codium.ai/images/pr_agent/pr-actions.mp4) 💎 | :white_check_mark: | | | | - 💎 means this feature is available only in [PR-Agent Pro](https://www.codium.ai/pricing/) -- Support for additional git providers is described in [here](./docs/Full_environments.md) + +[//]: # (- Support for additional git providers is described in [here](./docs/Full_environments.md)) ___ -‣ **Auto Description ([`/describe`](./docs/DESCRIBE.md))**: Automatically generating PR description - title, type, summary, code walkthrough and labels. +‣ **Auto Description ([`/describe`](https://pr-agent-docs.codium.ai/tools/describe/))**: Automatically generating PR description - title, type, summary, code walkthrough and labels. \ -‣ **Auto Review ([`/review`](./docs/REVIEW.md))**: Adjustable feedback about the PR, possible issues, security concerns, review effort and more. +‣ **Auto Review ([`/review`](https://pr-agent-docs.codium.ai/tools/review/))**: Adjustable feedback about the PR, possible issues, security concerns, review effort and more. \ -‣ **Question Answering ([`/ask ...`](./docs/ASK.md))**: Answering free-text questions about the PR. +‣ **Code Suggestions ([`/improve`](https://pr-agent-docs.codium.ai/tools/improve/))**: Code suggestions for improving the PR. \ -‣ **Code Suggestions ([`/improve`](./docs/IMPROVE.md))**: Code suggestions for improving the PR. +‣ **Question Answering ([`/ask ...`](https://pr-agent-docs.codium.ai/tools/ask/))**: Answering free-text questions about the PR. \ -‣ **Update Changelog ([`/update_changelog`](./docs/UPDATE_CHANGELOG.md))**: Automatically updating the CHANGELOG.md file with the PR changes. +‣ **Update Changelog ([`/update_changelog`](https://pr-agent-docs.codium.ai/tools/update_changelog/))**: Automatically updating the CHANGELOG.md file with the PR changes. \ -‣ **Find Similar Issue ([`/similar_issue`](./docs/SIMILAR_ISSUE.md))**: Automatically retrieves and presents similar issues. +‣ **Find Similar Issue ([`/similar_issue`](https://pr-agent-docs.codium.ai/tools/similar_issues/))**: Automatically retrieves and presents similar issues. \ -‣ **Add Documentation 💎 ([`/add_docs`](./docs/ADD_DOCUMENTATION.md))**: Generates documentation to methods/functions/classes that changed in the PR. +‣ **Add Documentation 💎 ([`/add_docs`](https://pr-agent-docs.codium.ai/tools/documentation/))**: Generates documentation to methods/functions/classes that changed in the PR. \ -‣ **Generate Custom Labels 💎 ([`/generate_labels`](./docs/GENERATE_CUSTOM_LABELS.md))**: Generates custom labels for the PR, based on specific guidelines defined by the user. +‣ **Generate Custom Labels 💎 ([`/generate_labels`](https://pr-agent-docs.codium.ai/tools/custom_labels/))**: Generates custom labels for the PR, based on specific guidelines defined by the user. \ -‣ **Analyze 💎 ([`/analyze`](./docs/Analyze.md))**: Identify code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component. +‣ **Analyze 💎 ([`/analyze`](https://pr-agent-docs.codium.ai/tools/analyze/))**: Identify code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component. \ -‣ **Custom Suggestions 💎 ([`/custom_suggestions`](./docs/CUSTOM_SUGGESTIONS.md))**: Automatically generates custom suggestions for improving the PR code, based on specific guidelines defined by the user. +‣ **Custom Suggestions 💎 ([`/custom_suggestions`](https://pr-agent-docs.codium.ai/tools/custom_suggestions/))**: Automatically generates custom suggestions for improving the PR code, based on specific guidelines defined by the user. \ -‣ **Generate Tests 💎 ([`/test component_name`](./docs/TEST.md))**: Automatically generates unit tests for a selected component, based on the PR code changes. +‣ **Generate Tests 💎 ([`/test component_name`](https://pr-agent-docs.codium.ai/tools/test/))**: Generates unit tests for a selected component, based on the PR code changes. \ -‣ **CI Feedback 💎 ([`/checks ci_job`](./docs/CI_FEEDBACK.md))**: Automatically generates feedback and analysis for a failed CI job. +‣ **CI Feedback 💎 ([`/checks ci_job`](https://pr-agent-docs.codium.ai/tools/ci_feedback/))**: Automatically generates feedback and analysis for a failed CI job. +\ +‣ **Similar Code 💎 ([`/find_similar_component`](https://pr-agent-docs.codium.ai/tools/similar_code//))**: Retrieves the most similar code components from inside the organization's codebase, or from open-source code. ___ ## Example results @@ -219,7 +220,7 @@ and the agent will respond with a review of your PR ![Review generation process](https://www.codium.ai/images/demo-2.gif) -To set up your own PR-Agent, see the [Installation](#installation) section below. +To set up your own PR-Agent, see the [Installation](https://pr-agent-docs.codium.ai/installation/) section below. Note that when you set your own PR-Agent or use CodiumAI hosted PR-Agent, there is no need to mention `@CodiumAI-Agent ...`. Instead, directly start with the command, e.g., `/ask ...`. --- @@ -233,32 +234,26 @@ To use your own version of PR-Agent, you first need to acquire two tokens: There are several ways to use PR-Agent: **Locally** -- [Use Docker image (no installation required)](./INSTALL.md#use-docker-image-no-installation-required) -- [Run from source](./INSTALL.md#run-from-source) +- [Use Docker image (no installation required)](https://pr-agent-docs.codium.ai/installation/locally/#use-docker-image-no-installation-required) +- [Run from source](https://pr-agent-docs.codium.ai/installation/locally/#run-from-source) **GitHub specific methods** -- [Run as a GitHub Action](./INSTALL.md#run-as-a-github-action) -- [Run as a GitHub App](./INSTALL.md#run-as-a-github-app) +- [Run as a GitHub Action](https://pr-agent-docs.codium.ai/installation/github/#run-as-a-github-action) +- [Run as a GitHub App](https://pr-agent-docs.codium.ai/installation/github/#run-as-a-github-app) **GitLab specific methods** -- [Run a GitLab webhook server](./INSTALL.md#run-a-gitlab-webhook-server) +- [Run a GitLab webhook server](https://pr-agent-docs.codium.ai/installation/gitlab/) **BitBucket specific methods** -- [Run as a Bitbucket Pipeline](./INSTALL.md#run-as-a-bitbucket-pipeline) +- [Run as a Bitbucket Pipeline](https://pr-agent-docs.codium.ai/installation/bitbucket/) ## PR-Agent Pro 💎 [PR-Agent Pro](https://www.codium.ai/pricing/) is a hosted version of PR-Agent, provided by CodiumAI. It is available for a monthly fee, and provides the following benefits: 1. **Fully managed** - We take care of everything for you - hosting, models, regular updates, and more. Installation is as simple as signing up and adding the PR-Agent app to your GitHub\BitBucket repo. 2. **Improved privacy** - No data will be stored or used to train models. PR-Agent Pro will employ zero data retention, and will use an OpenAI account with zero data retention. 3. **Improved support** - PR-Agent Pro users will receive priority support, and will be able to request new features and capabilities. -4. **Extra features** -In addition to the benefits listed above, PR-Agent Pro will emphasize more customization, and the usage of static code analysis, in addition to LLM logic, to improve results. It has the following additional tools and features: - - [**Analyze PR components**](https://github.com/Codium-ai/pr-agent/blob/main/docs/Analyze.md) - - [**Custom Code Suggestions**](https://github.com/Codium-ai/pr-agent/blob/main/docs/CUSTOM_SUGGESTIONS.md) - - [**Tests**](https://github.com/Codium-ai/pr-agent/blob/main/docs/TEST.md) - - [**PR documentation**](https://github.com/Codium-ai/pr-agent/blob/main/docs/ADD_DOCUMENTATION.md) - - [**SOC2 compliance check**](https://github.com/Codium-ai/pr-agent/blob/main/docs/REVIEW.md#soc2-ticket-compliance-) - - [**Custom labels**](https://github.com/Codium-ai/pr-agent/blob/main/docs/DESCRIBE.md#handle-custom-labels-from-the-repos-labels-page-gem) - - [**Global configuration**](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#global-configuration-file-) +4. **Extra features** -In addition to the benefits listed above, PR-Agent Pro will emphasize more customization, and the usage of static code analysis, in addition to LLM logic, to improve results. +See [here](https://pr-agent-docs.codium.ai/#pr-agent-pro) for a list of features available in PR-Agent Pro. @@ -268,7 +263,7 @@ The following diagram illustrates PR-Agent tools and their flow: ![PR-Agent Tools](https://codium.ai/images/pr_agent/diagram-v0.9.png) -Check out the [PR Compression strategy](./PR_COMPRESSION.md) page for more details on how we convert a code diff to a manageable LLM prompt +Check out the [PR Compression strategy](https://pr-agent-docs.codium.ai/core-abilities/#pr-compression-strategy) page for more details on how we convert a code diff to a manageable LLM prompt ## Why use PR-Agent? @@ -277,7 +272,7 @@ A reasonable question that can be asked is: `"Why use PR-Agent? What makes it st Here are some advantages of PR-Agent: - We emphasize **real-life practical usage**. Each tool (review, improve, ask, ...) has a single GPT-4 call, no more. We feel that this is critical for realistic team usage - obtaining an answer quickly (~30 seconds) and affordably. -- Our [PR Compression strategy](./PR_COMPRESSION.md) is a core ability that enables to effectively tackle both short and long PRs. +- Our [PR Compression strategy](https://pr-agent-docs.codium.ai/core-abilities/#pr-compression-strategy) is a core ability that enables to effectively tackle both short and long PRs. - Our JSON prompting strategy enables to have **modular, customizable tools**. For example, the '/review' tool categories can be controlled via the [configuration](pr_agent/settings/configuration.toml) file. Adding additional categories is easy and accessible. - We support **multiple git providers** (GitHub, Gitlab, Bitbucket), **multiple ways** to use the tool (CLI, GitHub Action, GitHub App, Docker, ...), and **multiple models** (GPT-4, GPT-3.5, Anthropic, Cohere, Llama2). diff --git a/Usage.md b/Usage.md deleted file mode 100644 index f0dbb3a9..00000000 --- a/Usage.md +++ /dev/null @@ -1,538 +0,0 @@ -## Usage Guide - -### Table of Contents -- [Introduction](#introduction) -- [Configuration Options](#configuration-options) -- [Managing Mail Notifications](#managing-mail-notifications) -- [Usage and Automation](#usage-and-automation) - - [Local Repo (CLI)](#working-from-a-local-repo-cli) - - [Online Usage](#online-usage) - - [GitHub App](#working-with-github-app) - - [GitHub Action](#working-with-github-action) - - [GitLab Webhook](#working-with-gitlab-webhook) - - [BitBucket App](#working-with-bitbucket-self-hosted-app) - - [Azure DevOps Provider](#azure-devops-provider) -- [Additional Configurations Walkthrough](#appendix---additional-configurations-walkthrough) - - [Ignoring files from analysis](#ignoring-files-from-analysis) - - [Extra instructions](#extra-instructions) - - [Working with large PRs](#working-with-large-prs) - - [Changing a model](#changing-a-model) - - [Patch Extra Lines](#patch-extra-lines) - - [Editing the prompts](#editing-the-prompts) - -## Introduction - -After [installation](/INSTALL.md), there are three basic ways to invoke CodiumAI PR-Agent: -1. Locally running a CLI command -2. Online usage - by [commenting](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695021901) on a PR -3. Enabling PR-Agent tools to run automatically when a new PR is opened - - -Specifically, CLI commands can be issued by invoking a pre-built [docker image](/INSTALL.md#running-from-source), or by invoking a [locally cloned repo](INSTALL.md#method-2-run-from-source). -For online usage, you will need to setup either a [GitHub App](INSTALL.md#method-5-run-as-a-github-app), or a [GitHub Action](INSTALL.md#method-3-run-as-a-github-action). -GitHub App and GitHub Action also enable to run PR-Agent specific tool automatically when a new PR is opened. - - -### 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: -` -"github", "gitlab", "bitbucket", "azure", "codecommit", "local", "gerrit" -` - -## Configuration Options - -The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](pr_agent/settings/configuration.toml)**. - -In addition to general configuration options, each tool has its own configurations. For example, the `review` tool will use parameters from the [pr_reviewer](/pr_agent/settings/configuration.toml#L16) section in the configuration file. -See the [Tools Guide](./docs/TOOLS_GUIDE.md) for a detailed description of the different tools and their configurations. - -There are three ways to set persistent configurations: -1. Wiki configuration page 💎 -2. Local configuration file -3. Global configuration file 💎 - -In terms of precedence, wiki configurations will override local configurations, and local configurations will override global configurations. - -### Wiki configuration file 💎 - -Specifically for GitHub, with PR-Agent-Pro you can set configurations by creating a page called `.pr_agent.toml` in the [wiki](https://github.com/Codium-ai/pr-agent/wiki/pr_agent.toml) of the repo. -The advantage of this method is that it allows to set configurations without needing to commit new content to the repo - just edit the wiki page and **save**. - - - -Click [here](https://codium.ai/images/pr_agent/wiki_configuration_pr_agent.mp4) to see a short instructional video. We recommend surrounding the configuration content with triple-quotes, to allow better presentation when displayed in the wiki as markdown. -An example content: - -\`\`\`
-[pr_description] # /describe #
-keep_original_user_title=false
-\`\`\` - -PR-Agent will know to remove the triple-quotes when reading the configuration content. - -### Local configuration file - -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. Note that you need to upload `.pr_agent.toml` prior to creating a PR, in order for the configuration to take effect. - -For example, if you set in `.pr_agent.toml`: - -``` -[pr_reviewer] -extra_instructions="""\ -- instruction a -- instruction b -... -""" -``` - -Then you can give a list of extra instructions to the `review` tool. - - -### Global configuration file 💎 - -If you create a repo called `pr-agent-settings` in your **organization**, it's configuration file `.pr_agent.toml` will be used as a global configuration file for any other repo that belongs to the same organization. -Parameters from a local `.pr_agent.toml` file, in a specific repo, will override the global configuration parameters. - -For example, in the GitHub organization `Codium-ai`: -- The repo [`https://github.com/Codium-ai/pr-agent-settings`](https://github.com/Codium-ai/pr-agent-settings/blob/main/.pr_agent.toml) contains a `.pr_agent.toml` file that serves as a global configuration file for all the repos in the GitHub organization `Codium-ai`. -- The repo [`https://github.com/Codium-ai/pr-agent`](https://github.com/Codium-ai/pr-agent/blob/main/.pr_agent.toml) inherits the global configuration file from `pr-agent-settings`. - - -## Managing mail notifications -Unfortunately, it is not possible in GitHub to disable mail notifications from a specific user. -If you are subscribed to notifications for a repo with PR-Agent, we recommend turning off notifications for PR comments, to avoid lengthy emails: - - - -As an alternative, you can filter in your mail provider the notifications specifically from the PR-Agent bot: -https://www.quora.com/How-can-you-filter-emails-for-specific-people-in-Gmail#:~:text=On%20the%20Filters%20and%20Blocked,the%20body%20of%20the%20email - - - -## Usage and Automation - -### Working from a local repo (CLI) -When running from your local repo (CLI), your local configuration file will be used. -Examples of invoking the different tools via the CLI: - -- **Review**: `python -m pr_agent.cli --pr_url= review` -- **Describe**: `python -m pr_agent.cli --pr_url= describe` -- **Improve**: `python -m pr_agent.cli --pr_url= improve` -- **Ask**: `python -m pr_agent.cli --pr_url= ask "Write me a poem about this PR"` -- **Reflect**: `python -m pr_agent.cli --pr_url= reflect` -- **Update Changelog**: `python -m pr_agent.cli --pr_url= update_changelog` - -`` is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). - -**Notes:** - -(1) in addition to editing your local configuration file, you can also change any configuration value by adding it to the command line: -``` -python -m pr_agent.cli --pr_url= /review --pr_reviewer.extra_instructions="focus on the file: ..." -``` - -(2) You can print results locally, without publishing them, by setting in `configuration.toml`: -``` -[config] -publish_output=false -verbosity_level=2 -``` -This is useful for debugging or experimenting with different tools. - - -### Online usage - -Online usage means invoking PR-Agent tools by [comments](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695021901) on a PR. -Commands for invoking the different tools via comments: - -- **Review**: `/review` -- **Describe**: `/describe` -- **Improve**: `/improve` -- **Ask**: `/ask "..."` -- **Reflect**: `/reflect` -- **Update Changelog**: `/update_changelog` - - -To edit a specific configuration value, just add `--config_path=` to any command. -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 -``` -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 - -#### GitHub app automatic tools when a new PR is opened - -The [github_app](pr_agent/settings/configuration.toml#L108) section defines GitHub app specific configurations. - -The configuration parameter `pr_commands` defines the list of tools that will be **run automatically** when a new PR is opened. -``` -[github_app] -pr_commands = [ - "/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true", - "/review --pr_reviewer.num_code_suggestions=0", - "/improve", -] -``` -This means that when a new PR is opened/reopened or marked as ready for review, PR-Agent will run the `describe`, `review` and `improve` tools. -For the `describe` tool, for example, the `add_original_user_description` and `keep_original_user_title` parameters will be set to true. - -You can override the default tool parameters by using one the three options for a [configuration file](#configuration-options): **wiki**, **local**, or **global**. -For example, if your local `.pr_agent.toml` file contains: -``` -[pr_description] -add_original_user_description = false -keep_original_user_title = false -``` -When a new PR is opened, PR-Agent will run the `describe` tool with the above parameters. - -To cancel the automatic run of all the tools, set: -``` -[github_app] -handle_pr_actions = [] -``` - -You can also disable automatic runs for PRs with specific titles, by setting the `ignore_pr_titles` parameter with the relevant regex. For example: -``` -[github_app] -ignore_pr_title = ["^[Auto]", ".*ignore.*"] -``` -will ignore PRs with titles that start with "Auto" or contain the word "ignore". - -#### GitHub app automatic tools for push actions (commits to an open PR) - -In addition to running automatic tools when a PR is opened, the GitHub app can also respond to new code that is pushed to an open PR. - -The configuration toggle `handle_push_trigger` can be used to enable this feature. -The configuration parameter `push_commands` defines the list of tools that will be **run automatically** when new code is pushed to the PR. -``` -[github_app] -handle_push_trigger = true -push_commands = [ - "/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true --pr_description.final_update_message=false", - "/review --pr_reviewer.num_code_suggestions=0 --pr_reviewer.final_update_message=false", -] -``` -This means that when new code is pushed to the PR, the PR-Agent will run the `describe` and `review` tools, with the specified parameters. - -### Working with GitHub Action -`GitHub Action` is a different way to trigger PR-Agent tools, and uses a different configuration mechanism than `GitHub App`. -You can configure settings for `GitHub Action` by adding environment variables under the env section in `.github/workflows/pr_agent.yml` file. -Specifically, start by setting the following environment variables: -```yaml - env: - OPENAI_KEY: ${{ secrets.OPENAI_KEY }} # Make sure to add your OpenAI key to your repo secrets - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Make sure to add your GitHub token to your repo secrets - github_action_config.auto_review: "true" # enable\disable auto review - github_action_config.auto_describe: "true" # enable\disable auto describe - github_action_config.auto_improve: "true" # enable\disable auto improve -``` -`github_action_config.auto_review`, `github_action_config.auto_describe` and `github_action_config.auto_improve` are used to enable/disable automatic tools that run when a new PR is opened. -If not set, the default configuration is for all three tools to run automatically when a new PR is opened. - -Note that you can give additional config parameters by adding environment variables to `.github/workflows/pr_agent.yml`, or by using a `.pr_agent.toml` file in the root of your repo, similar to the GitHub App usage. - -For example, you can set an environment variable: `pr_description.add_original_user_description=false`, or add a `.pr_agent.toml` file with the following content: -``` -[pr_description] -add_original_user_description = false -``` - -### Working with GitLab Webhook -After setting up a GitLab webhook, to control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file, similar to the GitHub App: -``` -[gitlab] -pr_commands = [ - "/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true", - "/review --pr_reviewer.num_code_suggestions=0", - "/improve", -] -``` - -### Working with BitBucket Self-Hosted App -Similar to GitHub app, when running PR-Agent from BitBucket 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 to the root of the repo's main branch, you can edit and customize any configuration parameter. Note that you need to upload `.pr_agent.toml` prior to creating a PR, in order for the configuration to take effect. - -For example, if your local `.pr_agent.toml` file contains: -``` -[pr_reviewer] -inline_code_comments = true -``` - -Each time you invoke a `/review` tool, it will use inline code comments. - -#### BitBucket Self-Hosted App automatic tools -to control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file: -``` -[bitbucket_app] -pr_commands = [ - "/review --pr_reviewer.num_code_suggestions=0", - "/improve --pr_code_suggestions.summarize=false", -] -``` - -Note that due to limitations of the bitbucket platform, not all tools or sub-options, are supported. See [here](./README.md#Overview) for an overview of the supported tools for bitbucket. - -### Azure DevOps provider - -To use Azure DevOps provider use the following settings in configuration.toml: -``` -[config] -git_provider="azure" -use_repo_settings_file=false -``` - -Azure DevOps provider supports [PAT token](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows) or [DefaultAzureCredential](https://learn.microsoft.com/en-us/azure/developer/python/sdk/authentication-overview#authentication-in-server-environments) authentication. -PAT is faster to create, but has build in experation date, and will use the user identity for API calls. -Using DefaultAzureCredential you can use managed identity or Service principle, which are more secure and will create seperate ADO user identity (via AAD) to the agent. - -If PAT was choosen, you can assign the value in .secrets.toml. -If DefaultAzureCredential was choosen, you can assigned the additional env vars like AZURE_CLIENT_SECRET directly, -or use managed identity/az cli (for local develpment) without any additional configuration. -in any case, 'org' value must be assigned in .secrets.toml: -``` -[azure_devops] -org = "https://dev.azure.com/YOUR_ORGANIZATION/" -# pat = "YOUR_PAT_TOKEN" needed only if using PAT for authentication -``` - -##### Azure DevOps Webhook -To trigger from an Azure webhook, you need to manually [add a webhook](https://learn.microsoft.com/en-us/azure/devops/service-hooks/services/webhooks?view=azure-devops). -Use the "Pull request created" type to trigger a review, or "Pull request commented on" to trigger any supported comment with / comment on the relevant PR. Note that for the "Pull request commented on" trigger, only API v2.0 is supported. - -To control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file, similar to the GitHub App: -``` -[azure_devops_server] -pr_commands = [ - "/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true", - "/review --pr_reviewer.num_code_suggestions=0", - "/improve", -] -``` - -For webhook security, create a sporadic username/password pair and configure the webhook username and password on both the server and Azure DevOps webhook. These will be sent as basic Auth data by the webhook with each request: -``` -[azure_devops_server] -webhook_username = "" -webhook_password = "" -``` -> :warning: **Ensure that the webhook endpoint is only accessible over HTTPS** to mitigate the risk of credential interception when using basic authentication. - - -## Appendix - additional configurations walkthrough - - -#### 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. - -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.REGEX` - -For example, to ignore python files in a PR with online usage, comment on a PR: -`/review --ignore.glob=['*.py']` - -To ignore python files in all PRs, set in a configuration file: -``` -[ignore] -glob = ['*.py'] -``` - -#### Extra instructions -All PR-Agent tools have a parameter called `extra_instructions`, that enables to add free-text extra instructions. Example usage: -``` -/update_changelog --pr_update_changelog.extra_instructions="Make sure to update also the version ..." -``` - -#### Working with large PRs - -The default mode of CodiumAI is to have a single call per tool, using GPT-4, which has a token limit of 8000 tokens. -This mode provide a very good speed-quality-cost tradeoff, and can handle most PRs successfully. -When the PR is above the token limit, it employs a [PR Compression strategy](./PR_COMPRESSION.md). - -However, for very large PRs, or in case you want to emphasize quality over speed and cost, there are 2 possible solutions: -1) [Use a model](#changing-a-model) with larger context, like GPT-32K, or claude-100K. This solution will be applicable for all the tools. -2) For the `/improve` tool, there is an ['extended' mode](./docs/IMPROVE.md) (`/improve --extended`), -which divides the PR to chunks, and process each chunk separately. With this mode, regardless of the model, no compression will be done (but for large PRs, multiple model calls may occur) - - -#### Changing a model - -See [here](pr_agent/algo/__init__.py) for the list of available models. -To use a different model than the default (GPT-4), you need to edit [configuration file](pr_agent/settings/configuration.toml#L2). -For models and environments not from OPENAI, you might need to provide additional keys and other parameters. See below for instructions. - -##### Azure -To use Azure, set in your `.secrets.toml` (working from CLI), or in the GitHub `Settings > Secrets and variables` (working from GitHub App or GitHub Action): -``` -[openai] -key = "" # your azure api key -api_type = "azure" -api_version = '2023-05-15' # Check Azure documentation for the current API version -api_base = "" # The base URL for your Azure OpenAI resource. e.g. "https://.openai.azure.com" -deployment_id = "" # The deployment name you chose when you deployed the engine -``` - -and set in your configuration file: -``` -[config] -model="" # the OpenAI model you've deployed on Azure (e.g. gpt-3.5-turbo) -``` - -##### Huggingface - -**Local** -You can run Huggingface models locally through either [VLLM](https://docs.litellm.ai/docs/providers/vllm) or [Ollama](https://docs.litellm.ai/docs/providers/ollama) - -E.g. to use a new Huggingface model locally via Ollama, set: -``` -[__init__.py] -MAX_TOKENS = { - "model-name-on-ollama": -} -e.g. -MAX_TOKENS={ - ..., - "ollama/llama2": 4096 -} - - -[config] # in configuration.toml -model = "ollama/llama2" - -[ollama] # in .secrets.toml -api_base = ... # the base url for your huggingface inference endpoint -# e.g. if running Ollama locally, you may use: -api_base = "http://localhost:11434/" -``` - -**Inference Endpoints** - -To use a new model with Huggingface Inference Endpoints, for example, set: -``` -[__init__.py] -MAX_TOKENS = { - "model-name-on-huggingface": -} -e.g. -MAX_TOKENS={ - ..., - "meta-llama/Llama-2-7b-chat-hf": 4096 -} -[config] # in configuration.toml -model = "huggingface/meta-llama/Llama-2-7b-chat-hf" - -[huggingface] # in .secrets.toml -key = ... # your huggingface api key -api_base = ... # the base url for your huggingface inference endpoint -``` -(you can obtain a Llama2 key from [here](https://replicate.com/replicate/llama-2-70b-chat/api)) - -##### Replicate - -To use Llama2 model with Replicate, for example, set: -``` -[config] # in configuration.toml -model = "replicate/llama-2-70b-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1" -[replicate] # in .secrets.toml -key = ... -``` -(you can obtain a Llama2 key from [here](https://replicate.com/replicate/llama-2-70b-chat/api)) - - -Also review the [AiHandler](pr_agent/algo/ai_handler.py) file for instruction how to set keys for other models. - -##### Vertex AI - -To use Google's Vertex AI platform and its associated models (chat-bison/codechat-bison) set: - -``` -[config] # in configuration.toml -model = "vertex_ai/codechat-bison" -fallback_models="vertex_ai/codechat-bison" - -[vertexai] # in .secrets.toml -vertex_project = "my-google-cloud-project" -vertex_location = "" -``` - -Your [application default credentials](https://cloud.google.com/docs/authentication/application-default-credentials) will be used for authentication so there is no need to set explicit credentials in most environments. - -If you do want to set explicit credentials then you can use the `GOOGLE_APPLICATION_CREDENTIALS` environment variable set to a path to a json credentials file. - -##### Anthropic -To use Anthropic models, set the relevant models in the configuration section of the configuration file: -``` -[config] -model="anthropic/claude-3-opus-20240229" -model_turbo="anthropic/claude-3-opus-20240229" -fallback_models=["anthropic/claude-3-opus-20240229"] -``` - -And also set the api key in the .secrets.toml file: -``` -[anthropic] -KEY = "..." -``` -##### Amazon Bedrock - -To use Amazon Bedrock and its foundational models, add the below configuration: - -``` -[config] # in configuration.toml -model = "anthropic.claude-v2" -fallback_models="anthropic.claude-instant-v1" - -[aws] # in .secrets.toml -bedrock_region = "us-east-1" -``` - -Note that you have to add access to foundational models before using them. Please refer to [this document](https://docs.aws.amazon.com/bedrock/latest/userguide/setting-up.html) for more details. - -AWS session is automatically authenticated from your environment, but you can also explicitly set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. - - -#### Patch Extra Lines -By default, around any change in your PR, git patch provides 3 lines of context above and below the change. -``` -@@ -12,5 +12,5 @@ def func1(): - code line that already existed in the file... - code line that already existed in the file... - code line that already existed in the file.... --code line that was removed in the PR -+new code line added in the PR - code line that already existed in the file... - code line that already existed in the file... - code line that already existed in the file... -``` - -For the `review`, `describe`, `ask` and `add_docs` tools, if the token budget allows, PR-Agent tries to increase the number of lines of context, via the parameter: -``` -[config] -patch_extra_lines=3 -``` - -Increasing this number provides more context to the model, but will also increase the token budget. -If the PR is too large (see [PR Compression strategy](./PR_COMPRESSION.md)), PR-Agent automatically sets this number to 0, using the original git patch. - - -#### Editing the prompts -The prompts for the various PR-Agent tools are defined in the `pr_agent/settings` folder. -In practice, the prompts are loaded and stored as a standard setting object. -Hence, editing them is similar to editing any other configuration value - just place the relevant key in `.pr_agent.toml`file, and override the default value. - -For example, if you want to edit the prompts of the [describe](./pr_agent/settings/pr_description_prompts.toml) tool, you can add the following to your `.pr_agent.toml` file: -``` -[pr_description_prompt] -system=""" -... -""" -user=""" -... -""" -``` -Note that the new prompt will need to generate an output compatible with the relevant [post-process function](./pr_agent/tools/pr_description.py#L137). diff --git a/docs/Full_environments.md b/docs/Full_environments.md deleted file mode 100644 index 3584b006..00000000 --- a/docs/Full_environments.md +++ /dev/null @@ -1,27 +0,0 @@ -## Overview -`PR-Agent` offers extensive pull request functionalities across various git providers: -| | | GitHub | Gitlab | Bitbucket | CodeCommit | Azure DevOps | Gerrit | -|-------|---------------------------------------------|:------:|:------:|:---------:|:----------:|:----------:|:----------:| -| TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | ⮑ Incremental | :white_check_mark: | | | | | | -| | Ask | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Auto-Description | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Improve Code | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | ⮑ Extended | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | Reflect and Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | :white_check_mark: | -| | Update CHANGELOG.md | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | -| | Find similar issue | :white_check_mark: | | | | | | -| | Add Documentation | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | Generate Custom Labels 💎 | :white_check_mark: | :white_check_mark: | | | | | -| | | | | | | | -| USAGE | CLI | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | App / webhook | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | -| | Tagging bot | :white_check_mark: | | | | | -| | Actions | :white_check_mark: | | | | | -| | Web server | | | | | | :white_check_mark: | -| | | | | | | | -| CORE | PR compression | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Repo language prioritization | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Adaptive and token-aware
file patch fitting | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Incremental PR Review | :white_check_mark: | | | | | | diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..68867ce4 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,15 @@ +# To install: +pip install mkdocs +pip install mkdocs-material +pip install mkdocs-material-extensions +pip install "mkdocs-material[imaging]" + +# docs +To run localy: `mkdocs serve` + +To expand and customize the theme: [Material MKDocs](https://squidfunk.github.io/mkdocs-material/) + +The deployment is managed on the gh-pages branches. +After each merge to main the deplloyment will be taken care of by GH action automatically and the new version will be available at: [Docs](https://codium-ai.github.io/docs/) + +Github action is located in `.github/workflows/ci.yml` file. diff --git a/docs/TOOLS_GUIDE.md b/docs/TOOLS_GUIDE.md deleted file mode 100644 index a993e0ef..00000000 --- a/docs/TOOLS_GUIDE.md +++ /dev/null @@ -1,15 +0,0 @@ -## Tools Guide -- [DESCRIBE](./DESCRIBE.md) -- [REVIEW](./REVIEW.md) -- [IMPROVE](./IMPROVE.md) -- [ASK](./ASK.md) -- [SIMILAR_ISSUE](./SIMILAR_ISSUE.md) -- [UPDATE CHANGELOG](./UPDATE_CHANGELOG.md) -- [CUSTOM SUGGESTIONS](./CUSTOM_SUGGESTIONS.md) 💎 -- [ADD DOCUMENTATION](./ADD_DOCUMENTATION.md) 💎 -- [GENERATE CUSTOM LABELS](./GENERATE_CUSTOM_LABELS.md) 💎 -- [Analyze](./Analyze.md) 💎 -- [Test](./TEST.md) 💎 -- [CI Feedback](./CI_FEEDBACK.md) 💎 - -See the **[installation guide](/INSTALL.md)** for instructions on setting up PR-Agent. diff --git a/docs/docs/CNAME b/docs/docs/CNAME new file mode 100644 index 00000000..1cbf9740 --- /dev/null +++ b/docs/docs/CNAME @@ -0,0 +1 @@ +pr-agent-docs.codium.ai diff --git a/docs/docs/assets/favicon.ico b/docs/docs/assets/favicon.ico new file mode 100644 index 00000000..fece6b1e Binary files /dev/null and b/docs/docs/assets/favicon.ico differ diff --git a/docs/docs/assets/logo.png b/docs/docs/assets/logo.png new file mode 100644 index 00000000..4c9fec1d Binary files /dev/null and b/docs/docs/assets/logo.png differ diff --git a/PR_COMPRESSION.md b/docs/docs/core-abilities/index.md similarity index 81% rename from PR_COMPRESSION.md rename to docs/docs/core-abilities/index.md index 101874c0..074d4c09 100644 --- a/PR_COMPRESSION.md +++ b/docs/docs/core-abilities/index.md @@ -1,42 +1,52 @@ -# PR Compression Strategy +## PR Compression Strategy There are two scenarios: + 1. The PR is small enough to fit in a single prompt (including system and user prompt) 2. The PR is too large to fit in a single prompt (including system and user prompt) For both scenarios, we first use the following strategy -#### Repo language prioritization strategy +#### Repo language prioritization strategy We prioritize the languages of the repo based on the following criteria: + 1. Exclude binary files and non code files (e.g. images, pdfs, etc) 2. Given the main languages used in the repo -2. We sort the PR files by the most common languages in the repo (in descending order): +3. We sort the PR files by the most common languages in the repo (in descending order): * ```[[file.py, file2.py],[file3.js, file4.jsx],[readme.md]]``` -## Small PR +### Small PR In this case, we can fit the entire PR in a single prompt: 1. Exclude binary files and non code files (e.g. images, pdfs, etc) 2. We Expand the surrounding context of each patch to 3 lines above and below the patch -## Large PR -### Motivation +### Large PR + +#### Motivation Pull Requests can be very long and contain a lot of information with varying degree of relevance to the pr-agent. We want to be able to pack as much information as possible in a single LMM prompt, while keeping the information relevant to the pr-agent. - - #### Compression strategy We prioritize additions over deletions: - Combine all deleted files into a single list (`deleted files`) - File patches are a list of hunks, remove all hunks of type deletion-only from the hunks in the file patch + #### Adaptive and token-aware file patch fitting We use [tiktoken](https://github.com/openai/tiktoken) to tokenize the patches after the modifications described above, and we use the following strategy to fit the patches into the prompt: -1. Within each language we sort the files by the number of tokens in the file (in descending order): - * ```[[file2.py, file.py],[file4.jsx, file3.js],[readme.md]]``` -2. Iterate through the patches in the order described above -2. Add the patches to the prompt until the prompt reaches a certain buffer from the max token length -3. If there are still patches left, add the remaining patches as a list called `other modified files` to the prompt until the prompt reaches the max token length (hard stop), skip the rest of the patches. -4. If we haven't reached the max token length, add the `deleted files` to the prompt until the prompt reaches the max token length (hard stop), skip the rest of the patches. -### Example +1. Within each language we sort the files by the number of tokens in the file (in descending order): + - ```[[file2.py, file.py],[file4.jsx, file3.js],[readme.md]]``` +2. Iterate through the patches in the order described above +3. Add the patches to the prompt until the prompt reaches a certain buffer from the max token length +4. If there are still patches left, add the remaining patches as a list called `other modified files` to the prompt until the prompt reaches the max token length (hard stop), skip the rest of the patches. +5. If we haven't reached the max token length, add the `deleted files` to the prompt until the prompt reaches the max token length (hard stop), skip the rest of the patches. + +#### Example + + +## YAML Prompting +TBD + +## Static Code Analysis 💎 +TBD diff --git a/docs/docs/css/custom.css b/docs/docs/css/custom.css new file mode 100644 index 00000000..0e9b26fe --- /dev/null +++ b/docs/docs/css/custom.css @@ -0,0 +1,98 @@ + + +:root { + --md-primary-fg-color: #765bfa; + --md-accent-fg-color: #AEA1F1; + } +.md-nav__title, .md-nav__link { + font-size: 16px; /* Adjust the font size as needed */ +} + +.md-tabs__link { + font-size: 16px; /* Adjust the font size as needed */ +} + +.md-header__title { + font-size: 20px; /* Adjust the font size as needed */ +} + +/* +@media (prefers-color-scheme: light) { + body { + --md-primary-fg-color: #00ffee !important; + --md-primary-bg-color: #ff0000 !important; + } + + body, .md-main, .md-content { + background-color: #4312f5 !important; + } +} + +@media (prefers-color-scheme: dark) { + body { + --md-primary-fg-color: #171518 !important; + --md-primary-bg-color: #171518 !important; + } + + body, .md-main, .md-content { + background-color: #171518 !important; + } + + .md-header__title { + color: #ffffff !important; + } + + .md-tabs .md-tabs__link { + color: #ffffff !important; + } + + .md-tabs .md-tabs__link:hover, + .md-tabs .md-tabs__link:focus { + color: #ffffff !important; + } + + .md-header__button { + color: #ffffff !important; + } + + .md-header__button svg { + fill: currentColor !important; + } + + .md-header__button:hover, + .md-header__button:focus { + color: #ffffff !important; + } + + .md-header__button:hover svg, + .md-header__button:focus svg { + fill: currentColor !important; + } + + .md-search__icon svg { + fill: #ffffff !important; + } + + .md-search__input { + color: #ffffff !important; + } + + .md-nav__item--active > .md-nav__link--active, + .md-nav__link--active { + color: #AEA1F1 !important; + } + + .md-nav--secondary .md-nav__title { + background: #171518; + box-shadow: 0 0 0.4rem 0.4rem #171518; + } + + .md-nav--lifted>.md-nav__list>.md-nav__item--active>.md-nav__link { + background: #171518; + box-shadow: 0 0 0.4rem 0.4rem #171518; + } + + .md-content a { + color: #AEA1F1 !important; + } +} */ \ No newline at end of file diff --git a/docs/docs/index.md b/docs/docs/index.md new file mode 100644 index 00000000..f604fd25 --- /dev/null +++ b/docs/docs/index.md @@ -0,0 +1,162 @@ +# Overview + +CodiumAI PR-Agent is an open-source tool to help efficiently review and handle pull requests. + +- See the [Installation Guide](./installation/index.md) for instructions on installing and running the tool on different git platforms. + +- See the [Usage Guide](./usage-guide/index.md) for instructions on running the PR-Agent commands via different interfaces, including _CLI_, _online usage_, or by _automatically triggering_ them when a new PR is opened. + +- See the [Tools Guide](./tools/index.md) for a detailed description of the different tools (tools are run via the commands). + + +## PR-Agent Features +PR-Agent offers extensive pull request functionalities across various git providers. + +| | | GitHub | Gitlab | Bitbucket | Azure DevOps | +|-------|---------------------------------------------------------------------------------------------------------------------|:------:|:------:|:---------:|:------------:| +| TOOLS | Review | ✔️ | ✔️ | ✔️ | ✔️ | +| | ⮑ Incremental | ✔️ | | | | +| | ⮑ [SOC2 Compliance](https://pr-agent-docs.codium.ai/tools/review/#soc2-ticket-compliance){:target="_blank"} 💎 | ✔️ | ✔️ | ✔️ | ✔️ | +| | Ask | ✔️ | ✔️ | ✔️ | ✔️ | +| | Describe | ✔️ | ✔️ | ✔️ | ✔️ | +| | ⮑ [Inline file summary](https://pr-agent-docs.codium.ai/tools/describe/#inline-file-summary){:target="_blank"} 💎 | ✔️ | ✔️ | ✔️ | ✔️ | +| | Improve | ✔️ | ✔️ | ✔️ | ✔️ | +| | ⮑ Extended | ✔️ | ✔️ | ✔️ | ✔️ | +| | [Custom Suggestions](./tools/custom_suggestions.md){:target="_blank"} 💎 | ✔️ | ✔️ | ✔️ | ✔️ | +| | Reflect and Review | ✔️ | ✔️ | ✔️ | ✔️ | +| | Update CHANGELOG.md | ✔️ | ✔️ | ✔️ | ️ | +| | Find Similar Issue | ✔️ | | | ️ | +| | [Add PR Documentation](./tools/documentation.md){:target="_blank"} 💎 | ✔️ | ✔️ | ✔️ | ✔️ | +| | [Generate Custom Labels](./tools/describe.md#handle-custom-labels-from-the-repos-labels-page-💎){:target="_blank"} 💎 | ✔️ | ✔️ | | ✔️ | +| | [Analyze PR Components](./tools/analyze.md){:target="_blank"} 💎 | ✔️ | ✔️ | ✔️ | ✔️ | +| | | | | | ️ | +| USAGE | CLI | ✔️ | ✔️ | ✔️ | ✔️ | +| | App / webhook | ✔️ | ✔️ | | ✔️ | +| | Tagging bot | ✔️ | | | ✔️ | +| | Actions | ✔️ | | | ️ | +| | | | | | +| CORE | PR compression | ✔️ | ✔️ | ✔️ | ✔️ | +| | Repo language prioritization | ✔️ | ✔️ | ✔️ | ✔️ | +| | Adaptive and token-aware file patch fitting | ✔️ | ✔️ | ✔️ | ✔️ | +| | Multiple models support | ✔️ | ✔️ | ✔️ | ✔️ | +| | Incremental PR review | ✔️ | | | | +| | [Static code analysis](./tools/analyze.md/){:target="_blank"} 💎 | ✔️ | ✔️ | ✔️ | ✔️ | +| | [Multiple configuration options](./usage-guide/configuration_options.md){:target="_blank"} 💎 | ✔️ | ✔️ | ✔️ | ✔️ | + +💎 marks a feature available only in [PR-Agent Pro](https://www.codium.ai/pricing/){:target="_blank"} + + +## Example results +
+

/describe

+
+

+ +

+
+
+ +

/review

+
+

+ + + +

+
+
+ +

/improve

+
+

+ + + +

+
+
+ +

/generate_labels

+
+

+ +

+
+ +[//]: # (

/reflect_and_review:

) + +[//]: # (
) + +[//]: # (

) + +[//]: # () + +[//]: # (

) + +[//]: # (
) + +[//]: # (

/ask:

) + +[//]: # (
) + +[//]: # (

) + +[//]: # () + +[//]: # (

) + +[//]: # (
) + +[//]: # (

/improve:

) + +[//]: # (
) + +[//]: # (

) + +[//]: # () + +[//]: # (

) + +[//]: # (
) +
+ + +
+
+ + +## How it works + +The following diagram illustrates PR-Agent tools and their flow: + +![PR-Agent Tools](https://codium.ai/images/pr_agent/diagram-v0.9.png) + +Check out the [PR Compression strategy](core-abilities/index.md) page for more details on how we convert a code diff to a manageable LLM prompt + + + +## PR-Agent Pro 💎 + +[PR-Agent Pro](https://www.codium.ai/pricing/) is a hosted version of PR-Agent, provided by CodiumAI. It is available for a monthly fee, and provides the following benefits: + +1. **Fully managed** - We take care of everything for you - hosting, models, regular updates, and more. Installation is as simple as signing up and adding the PR-Agent app to your GitHub\BitBucket repo. +2. **Improved privacy** - No data will be stored or used to train models. PR-Agent Pro will employ zero data retention, and will use an OpenAI account with zero data retention. +3. **Improved support** - PR-Agent Pro users will receive priority support, and will be able to request new features and capabilities. +4. **Extra features** -In addition to the benefits listed above, PR-Agent Pro will emphasize more customization, and the usage of static code analysis, in addition to LLM logic, to improve results. It has the following additional tools and features: + - [**Analyze PR components**](./tools/analyze.md/) + - [**Custom Code Suggestions**](./tools/custom_suggestions.md/) + - [**Tests**](./tools/test.md/) + - [**PR documentation**](./tools/documentation.md/) + - [**CI feedback**](./tools/ci_feedback.md/) + - [**SOC2 compliance check**](./tools/review.md/#soc2-ticket-compliance) + - [**Custom labels**](./tools/describe.md/#handle-custom-labels-from-the-repos-labels-page) + - [**Global and wiki configuration**](./usage-guide/configuration_options.md/#wiki-configuration-file) + + +## Data privacy + +If you host PR-Agent with your OpenAI API key, it is between you and OpenAI. You can read their API data privacy policy here: +https://openai.com/enterprise-privacy + +When using PR-Agent Pro 💎, hosted by CodiumAI, we will not store any of your data, nor will we use it for training. +You will also benefit from an OpenAI account with zero data retention. diff --git a/docs/docs/installation/azure.md b/docs/docs/installation/azure.md new file mode 100644 index 00000000..8c111581 --- /dev/null +++ b/docs/docs/installation/azure.md @@ -0,0 +1,36 @@ +## Azure DevOps provider + +To use Azure DevOps provider use the following settings in configuration.toml: +``` +[config] +git_provider="azure" +use_repo_settings_file=false +``` + +Azure DevOps provider supports [PAT token](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows) or [DefaultAzureCredential](https://learn.microsoft.com/en-us/azure/developer/python/sdk/authentication-overview#authentication-in-server-environments) authentication. +PAT is faster to create, but has build in experation date, and will use the user identity for API calls. +Using DefaultAzureCredential you can use managed identity or Service principle, which are more secure and will create seperate ADO user identity (via AAD) to the agent. + +If PAT was choosen, you can assign the value in .secrets.toml. +If DefaultAzureCredential was choosen, you can assigned the additional env vars like AZURE_CLIENT_SECRET directly, +or use managed identity/az cli (for local develpment) without any additional configuration. +in any case, 'org' value must be assigned in .secrets.toml: +``` +[azure_devops] +org = "https://dev.azure.com/YOUR_ORGANIZATION/" +# pat = "YOUR_PAT_TOKEN" needed only if using PAT for authentication +``` + +### Azure DevOps Webhook + +To trigger from an Azure webhook, you need to manually [add a webhook](https://learn.microsoft.com/en-us/azure/devops/service-hooks/services/webhooks?view=azure-devops). +Use the "Pull request created" type to trigger a review, or "Pull request commented on" to trigger any supported comment with / comment on the relevant PR. Note that for the "Pull request commented on" trigger, only API v2.0 is supported. + + +For webhook security, create a sporadic username/password pair and configure the webhook username and password on both the server and Azure DevOps webhook. These will be sent as basic Auth data by the webhook with each request: +``` +[azure_devops_server] +webhook_username = "" +webhook_password = "" +``` +> :warning: **Ensure that the webhook endpoint is only accessible over HTTPS** to mitigate the risk of credential interception when using basic authentication. diff --git a/docs/docs/installation/bitbucket.md b/docs/docs/installation/bitbucket.md new file mode 100644 index 00000000..d3c93ad9 --- /dev/null +++ b/docs/docs/installation/bitbucket.md @@ -0,0 +1,70 @@ +## Run as a Bitbucket Pipeline + + +You can use the Bitbucket Pipeline system to run PR-Agent on every pull request open or update. + +1. Add the following file in your repository bitbucket_pipelines.yml + +```yaml +pipelines: + pull-requests: + '**': + - step: + name: PR Agent Review + image: python:3.10 + services: + - docker + script: + - docker run -e CONFIG.GIT_PROVIDER=bitbucket -e OPENAI.KEY=$OPENAI_API_KEY -e BITBUCKET.BEARER_TOKEN=$BITBUCKET_BEARER_TOKEN codiumai/pr-agent:latest --pr_url=https://bitbucket.org/$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG/pull-requests/$BITBUCKET_PR_ID review +``` + +2. Add the following secure variables to your repository under Repository settings > Pipelines > Repository variables. +OPENAI_API_KEY: `` +BITBUCKET_BEARER_TOKEN: `` + +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 + +Please contact [support@codium.ai](mailto:support@codium.ai) or visit [CodiumAI pricing page](https://www.codium.ai/pricing/) if you're interested in a hosted BitBucket app solution that provides full functionality including PR reviews and comment handling. It's based on the [bitbucket_app.py](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/git_providers/bitbucket_provider.py) implementation. + + +## Bitbucket Server and Data Center + +Login into your on-prem instance of Bitbucket with your service account username and password. +Navigate to `Manage account`, `HTTP Access tokens`, `Create Token`. +Generate the token and add it to .secret.toml under `bitbucket_server` section + +```toml +[bitbucket_server] +bearer_token = "" +``` + +### Run it as CLI + +Modify `configuration.toml`: + +```toml +git_provider="bitbucket_server" +``` + +and pass the Pull request URL: +```shell +python cli.py --pr_url https://git.onpreminstanceofbitbucket.com/projects/PROJECT/repos/REPO/pull-requests/1 review +``` + +### Run it as service + +To run pr-agent as webhook, build the docker image: +``` +docker build . -t codiumai/pr-agent:bitbucket_server_webhook --target bitbucket_server_webhook -f docker/Dockerfile +docker push codiumai/pr-agent:bitbucket_server_webhook # Push to your Docker repository +``` + +Navigate to `Projects` or `Repositories`, `Settings`, `Webhooks`, `Create Webhook`. +Fill the name and URL, Authentication None select the Pull Request Opened checkbox to receive that event as webhook. + +The URL should end with `/webhook`, for example: https://domain.com/webhook diff --git a/INSTALL.md b/docs/docs/installation/github.md similarity index 51% rename from INSTALL.md rename to docs/docs/installation/github.md index cc51aa4a..f4d08447 100644 --- a/INSTALL.md +++ b/docs/docs/installation/github.md @@ -1,120 +1,4 @@ - -## Installation - -To get started with PR-Agent quickly, you first need to acquire two tokens: - -1. An OpenAI key from [here](https://platform.openai.com/api-keys), with access to GPT-4. -2. A GitHub\GitLab\BitBucket personal access token (classic), with the repo scope. [GitHub from [here](https://github.com/settings/tokens)] - -There are several ways to use PR-Agent: - -**Locally** -- [Using Docker image (no installation required)](INSTALL.md#use-docker-image-no-installation-required) -- [Run from source](INSTALL.md#run-from-source) - -**GitHub specific methods** -- [Run as a GitHub Action](INSTALL.md#run-as-a-github-action) -- [Run as a GitHub App](INSTALL.md#run-as-a-github-app) -- [Deploy as a Lambda Function](INSTALL.md#deploy-as-a-lambda-function) -- [AWS CodeCommit](INSTALL.md#aws-codecommit-setup) - -**GitLab specific methods** -- [Run a GitLab webhook server](INSTALL.md#run-a-gitlab-webhook-server) - -**BitBucket specific methods** -- [Run as a Bitbucket Pipeline](INSTALL.md#run-as-a-bitbucket-pipeline) -- [Run on a hosted app](INSTALL.md#run-on-a-hosted-bitbucket-app) -- [Bitbucket server and data center](INSTALL.md#bitbucket-server-and-data-center) ---- - -### Use Docker image (no installation required) - -A list of the relevant tools can be found in the [tools guide](./docs/TOOLS_GUIDE.md). - -To invoke a tool (for example `review`), you can run directly from the Docker image. Here's how: - -- For GitHub: -``` -docker run --rm -it -e OPENAI.KEY= -e GITHUB.USER_TOKEN= codiumai/pr-agent:latest --pr_url review -``` - -- For GitLab: -``` -docker run --rm -it -e OPENAI.KEY= -e CONFIG.GIT_PROVIDER=gitlab -e GITLAB.PERSONAL_ACCESS_TOKEN= codiumai/pr-agent:latest --pr_url review -``` - -Note: If you have a dedicated GitLab instance, you need to specify the custom url as variable: -``` -docker run --rm -it -e OPENAI.KEY= -e CONFIG.GIT_PROVIDER=gitlab -e GITLAB.PERSONAL_ACCESS_TOKEN= -e GITLAB.URL= codiumai/pr-agent:latest --pr_url review -``` - -- For BitBucket: -``` -docker run --rm -it -e CONFIG.GIT_PROVIDER=bitbucket -e OPENAI.KEY=$OPENAI_API_KEY -e BITBUCKET.BEARER_TOKEN=$BITBUCKET_BEARER_TOKEN codiumai/pr-agent:latest --pr_url= review -``` - -For other git providers, update CONFIG.GIT_PROVIDER accordingly, and check the `pr_agent/settings/.secrets_template.toml` file for the environment variables expected names and values. - ---- - - -If you want to ensure you're running a specific version of the Docker image, consider using the image's digest: -```bash -docker run --rm -it -e OPENAI.KEY= -e GITHUB.USER_TOKEN= codiumai/pr-agent@sha256:71b5ee15df59c745d352d84752d01561ba64b6d51327f97d46152f0c58a5f678 --pr_url review -``` - -Or you can run a [specific released versions](./RELEASE_NOTES.md) of pr-agent, for example: -``` -codiumai/pr-agent@v0.9 -``` - ---- - -### Run from source - -1. Clone this repository: - -``` -git clone https://github.com/Codium-ai/pr-agent.git -``` - -2. Navigate to the `/pr-agent` folder and install the requirements in your favorite virtual environment: - -``` -pip install -e . -``` - -*Note: If you get an error related to Rust in the dependency installation then make sure Rust is installed and in your `PATH`, instructions: https://rustup.rs* - -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.toml -chmod 600 pr_agent/settings/.secrets.toml -# Edit .secrets.toml file -``` - -4. Run the cli.py script: - -``` -python3 -m pr_agent.cli --pr_url review -python3 -m pr_agent.cli --pr_url ask -python3 -m pr_agent.cli --pr_url describe -python3 -m pr_agent.cli --pr_url improve -python3 -m pr_agent.cli --pr_url add_docs -python3 -m pr_agent.cli --pr_url generate_labels -python3 -m pr_agent.cli --issue_url similar_issue -... -``` - -[Optional] Add the pr_agent folder to your PYTHONPATH -``` -export PYTHONPATH=$PYTHONPATH: -``` - ---- - -### Run as a GitHub Action +## Run as a GitHub Action You can use our pre-built Github Action Docker image to run PR-Agent as a Github Action. @@ -123,16 +7,7 @@ You can use our pre-built Github Action Docker image to run PR-Agent as a Github ```yaml on: pull_request: - types: - - opened - - reopened - - ready_for_review - - review_requested - issue_comment: - types: - - created - - edited jobs: pr_agent_job: runs-on: ubuntu-latest @@ -153,16 +28,7 @@ jobs: ```yaml on: pull_request: - types: - - opened - - reopened - - ready_for_review - - review_requested - issue_comment: - types: - - created - - edited jobs: pr_agent_job: @@ -192,7 +58,7 @@ The GITHUB_TOKEN secret is automatically created by GitHub. 3. Merge this change to your main branch. When you open your next PR, you should see a comment from `github-actions` bot with a review of your PR, and instructions on how to use the rest of the tools. -4. You may configure PR-Agent by adding environment variables under the env section corresponding to any configurable property in the [configuration](pr_agent/settings/configuration.toml) file. Some examples: +4. You may configure PR-Agent by adding environment variables under the env section corresponding to any configurable property in the [configuration](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml) file. Some examples: ```yaml env: # ... previous environment values @@ -202,8 +68,20 @@ When you open your next PR, you should see a comment from `github-actions` bot w ``` --- +## Run as a polling server +Request reviews by tagging your GitHub user on a PR -### Run as a GitHub App +Follow [steps 1-3](#run-as-a-github-action) of the GitHub Action setup. + +Run the following command to start the server: + +``` +python pr_agent/servers/github_polling.py +``` + +--- + +## 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). @@ -244,7 +122,7 @@ 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 ID to the app_id field. - Copy your app's webhook secret to the webhook_secret field. - - Set deployment_type to 'app' in [configuration.toml](./pr_agent/settings/configuration.toml) + - Set deployment_type to 'app' in [configuration.toml](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml) > The .secrets.toml file is not copied to the Docker image by default, and is only used for local development. > If you want to use the .secrets.toml file in your Docker image, you can add remove it from the .dockerignore file. @@ -284,12 +162,12 @@ docker push codiumai/pr-agent:github_app # Push to your Docker repository 9. Install the app by navigating to the "Install App" tab and selecting your desired repositories. -> **Note:** When running PR-Agent from GitHub App, the default configuration file (configuration.toml) will be loaded.
-> However, you can override the default tool parameters by uploading a local configuration file `.pr_agent.toml`
-> For more information please check out the [USAGE GUIDE](./Usage.md#working-with-github-app) +> **Note:** When running PR-Agent from GitHub App, the default configuration file (configuration.toml) will be loaded. +> However, you can override the default tool parameters by uploading a local configuration file `.pr_agent.toml` +> For more information please check out the [USAGE GUIDE](../usage-guide/automations_and_usage.md#github-app) --- -### Deploy as a Lambda Function +## Deploy as a Lambda Function 1. Follow steps 1-5 of [Method 5](#run-as-a-github-app). 2. Build a docker image that can be used as a lambda function @@ -309,7 +187,7 @@ docker push codiumai/pr-agent:github_app # Push to your Docker repository --- -### AWS CodeCommit Setup +## AWS CodeCommit Setup Not all features have been added to CodeCommit yet. As of right now, CodeCommit has been implemented to run the pr-agent CLI on the command line, using AWS credentials stored in environment variables. (More features will be added in the future.) The following is a set of instructions to have pr-agent do a review of your CodeCommit pull request from the command line: @@ -324,7 +202,10 @@ Not all features have been added to CodeCommit yet. As of right now, CodeCommit * Option B: Set `PYTHONPATH` and run the CLI in one command, for example: * `PYTHONPATH="/PATH/TO/PROJECTS/pr-agent python pr_agent/cli.py [--ARGS]` -##### AWS CodeCommit IAM Role Example +--- + + +#### AWS CodeCommit IAM Role Example Example IAM permissions to that user to allow access to CodeCommit: @@ -356,7 +237,7 @@ Example IAM permissions to that user to allow access to CodeCommit: } ``` -##### AWS CodeCommit Access Key and Secret +#### AWS CodeCommit Access Key and Secret Example setting the Access Key and Secret using environment variables @@ -366,7 +247,7 @@ export AWS_SECRET_ACCESS_KEY="XXXXXXXXXXXXXXXX" export AWS_DEFAULT_REGION="us-east-1" ``` -##### AWS CodeCommit CLI Example +#### AWS CodeCommit CLI Example After you set up AWS CodeCommit using the instructions above, here is an example CLI run that tells pr-agent to **review** a given pull request. (Replace your specific PYTHONPATH and PR URL in the example) @@ -375,98 +256,4 @@ After you set up AWS CodeCommit using the instructions above, here is an example PYTHONPATH="/PATH/TO/PROJECTS/pr-agent" python pr_agent/cli.py \ --pr_url https://us-east-1.console.aws.amazon.com/codesuite/codecommit/repositories/MY_REPO_NAME/pull-requests/321 \ review -``` - ---- - -### Run a GitLab webhook server - -1. From the GitLab workspace or group, create an access token. Enable the "api" scope only. -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))") -``` -3. Follow the instructions to build the Docker image, setup a secrets file and deploy on your own server from [Method 5](#run-as-a-github-app) steps 4-7. Be sure to set the target to `gitlab_webhook` instead of `github_app` when building the Docker image. -4. In the secrets file, fill in the following: - - Your OpenAI key. - - In the [gitlab] section, fill in personal_access_token and shared_secret. The access token can be a personal access token, or a group or project access token. - - Set deployment_type to 'gitlab' in [configuration.toml](./pr_agent/settings/configuration.toml) -5. Create a webhook in GitLab. Set the URL to the URL of your app's server with the path `/webhook` (e.g. `http://pr-agent.example.com:3000/webhook`). Set the secret token to the generated secret from step 2. -In the "Trigger" section, check the ‘comments’ and ‘merge request events’ boxes. -6. Test your installation by opening a merge request or commenting on a merge request using one of CodiumAI's commands. - - - -### Run as a Bitbucket Pipeline - - -You can use the Bitbucket Pipeline system to run PR-Agent on every pull request open or update. - -1. Add the following file in your repository bitbucket_pipelines.yml - -```yaml -pipelines: - pull-requests: - '**': - - step: - name: PR Agent Review - image: python:3.10 - services: - - docker - script: - - docker run -e CONFIG.GIT_PROVIDER=bitbucket -e OPENAI.KEY=$OPENAI_API_KEY -e BITBUCKET.BEARER_TOKEN=$BITBUCKET_BEARER_TOKEN codiumai/pr-agent:latest --pr_url=https://bitbucket.org/$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG/pull-requests/$BITBUCKET_PR_ID review -``` - -2. Add the following secure variables to your repository under Repository settings > Pipelines > Repository variables. -OPENAI_API_KEY: -BITBUCKET_BEARER_TOKEN: - -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 - -Please contact or visit [CodiumAI pricing page](https://www.codium.ai/pricing/) if you're interested in a hosted BitBucket app solution that provides full functionality including PR reviews and comment handling. It's based on the [bitbucket_app.py](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/git_providers/bitbucket_provider.py) implementation. - - -### Bitbucket Server and Data Center - -Login into your on-prem instance of Bitbucket with your service account username and password. -Navigate to `Manage account`, `HTTP Access tokens`, `Create Token`. -Generate the token and add it to .secret.toml under `bitbucket_server` section - -```toml -[bitbucket_server] -bearer_token = "" -``` - -#### Run it as CLI - -Modify `configuration.toml`: - -```toml -git_provider="bitbucket_server" -``` - -and pass the Pull request URL: -```shell -python cli.py --pr_url https://git.onpreminstanceofbitbucket.com/projects/PROJECT/repos/REPO/pull-requests/1 review -``` - -#### Run it as service - -To run pr-agent as webhook, build the docker image: -``` -docker build . -t codiumai/pr-agent:bitbucket_server_webhook --target bitbucket_server_webhook -f docker/Dockerfile -docker push codiumai/pr-agent:bitbucket_server_webhook # Push to your Docker repository -``` - -Navigate to `Projects` or `Repositories`, `Settings`, `Webhooks`, `Create Webhook`. -Fill the name and URL, Authentication None select the Pull Request Opened checkbox to receive that event as webhook. - -The URL should end with `/webhook`, for example: https://domain.com/webhook - -======= +``` \ No newline at end of file diff --git a/docs/docs/installation/gitlab.md b/docs/docs/installation/gitlab.md new file mode 100644 index 00000000..e768e850 --- /dev/null +++ b/docs/docs/installation/gitlab.md @@ -0,0 +1,16 @@ +## Run a GitLab webhook server + +1. From the GitLab workspace or group, create an access token. Enable the "api" scope only. +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))") +``` +3. Follow the instructions to build the Docker image, setup a secrets file and deploy on your own server from [Method 5](#run-as-a-github-app) steps 4-7. +4. In the secrets file, fill in the following: + - Your OpenAI key. + - In the [gitlab] section, fill in personal_access_token and shared_secret. The access token can be a personal access token, or a group or project access token. + - Set deployment_type to 'gitlab' in [configuration.toml](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml) +5. Create a webhook in GitLab. Set the URL to the URL of your app's server. Set the secret token to the generated secret from step 2. +In the "Trigger" section, check the ‘comments’ and ‘merge request events’ boxes. +6. Test your installation by opening a merge request or commenting or a merge request using one of CodiumAI's commands. \ No newline at end of file diff --git a/docs/docs/installation/index.md b/docs/docs/installation/index.md new file mode 100644 index 00000000..18b7b056 --- /dev/null +++ b/docs/docs/installation/index.md @@ -0,0 +1,19 @@ +# Installation + +If you choose to host you own PR-Agent, you first need to acquire two tokens: + +1. An OpenAI key from [here](https://platform.openai.com/api-keys), with access to GPT-4 (or a key for [other models](../usage-guide/additional_configurations.md/#changing-a-model), if you prefer). +2. A GitHub\GitLab\BitBucket personal access token (classic), with the repo scope. [GitHub from [here](https://github.com/settings/tokens)] + +There are several ways to use self-hosted PR-Agent: + +- [Locally](./locally.md) +- [GitHub](./github.md) +- [GitLab](./gitlab.md) +- [BitBucket](./bitbucket.md) +- [Azure DevOps](./azure.md) + +___ +Note that [PR-Agent Pro 💎](https://app.codium.ai/), an app for GitHub\GitLab\BitBucket hosted by CodiumAI, is also available. +
+With PR-Agent Pro Installation is as simple as signing up and adding the PR-Agent app to your relevant repo. \ No newline at end of file diff --git a/docs/docs/installation/locally.md b/docs/docs/installation/locally.md new file mode 100644 index 00000000..32ba77ae --- /dev/null +++ b/docs/docs/installation/locally.md @@ -0,0 +1,84 @@ +## Use Docker image (no installation required) + +A list of the relevant tools can be found in the [tools guide](../tools/ask.md). + +To invoke a tool (for example `review`), you can run directly from the Docker image. Here's how: + +- For GitHub: +``` +docker run --rm -it -e OPENAI.KEY= -e GITHUB.USER_TOKEN= codiumai/pr-agent:latest --pr_url review +``` + +- For GitLab: +``` +docker run --rm -it -e OPENAI.KEY= -e CONFIG.GIT_PROVIDER=gitlab -e GITLAB.PERSONAL_ACCESS_TOKEN= codiumai/pr-agent:latest --pr_url review +``` + +Note: If you have a dedicated GitLab instance, you need to specify the custom url as variable: +``` +docker run --rm -it -e OPENAI.KEY= -e CONFIG.GIT_PROVIDER=gitlab -e GITLAB.PERSONAL_ACCESS_TOKEN= -e GITLAB.URL= codiumai/pr-agent:latest --pr_url review +``` + +- For BitBucket: +``` +docker run --rm -it -e CONFIG.GIT_PROVIDER=bitbucket -e OPENAI.KEY=$OPENAI_API_KEY -e BITBUCKET.BEARER_TOKEN=$BITBUCKET_BEARER_TOKEN codiumai/pr-agent:latest --pr_url= review +``` + +For other git providers, update CONFIG.GIT_PROVIDER accordingly, and check the `pr_agent/settings/.secrets_template.toml` file for the environment variables expected names and values. + +--- + + +If you want to ensure you're running a specific version of the Docker image, consider using the image's digest: +```bash +docker run --rm -it -e OPENAI.KEY= -e GITHUB.USER_TOKEN= codiumai/pr-agent@sha256:71b5ee15df59c745d352d84752d01561ba64b6d51327f97d46152f0c58a5f678 --pr_url review +``` + +Or you can run a [specific released versions](https://github.com/Codium-ai/pr-agent/blob/main/RELEASE_NOTES.md) of pr-agent, for example: +``` +codiumai/pr-agent@v0.9 +``` + +--- + +## Run from source + +1. Clone this repository: + +``` +git clone https://github.com/Codium-ai/pr-agent.git +``` + +2. Navigate to the `/pr-agent` folder and install the requirements in your favorite virtual environment: + +``` +pip install -e . +``` + +*Note: If you get an error related to Rust in the dependency installation then make sure Rust is installed and in your `PATH`, instructions: https://rustup.rs* + +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.toml +chmod 600 pr_agent/settings/.secrets.toml +# Edit .secrets.toml file +``` + +4. Run the cli.py script: + +``` +python3 -m pr_agent.cli --pr_url review +python3 -m pr_agent.cli --pr_url ask +python3 -m pr_agent.cli --pr_url describe +python3 -m pr_agent.cli --pr_url improve +python3 -m pr_agent.cli --pr_url add_docs +python3 -m pr_agent.cli --pr_url generate_labels +python3 -m pr_agent.cli --issue_url similar_issue +... +``` + +[Optional] Add the pr_agent folder to your PYTHONPATH +``` +export PYTHONPATH=$PYTHONPATH: +``` \ No newline at end of file diff --git a/docs/Analyze.md b/docs/docs/tools/analyze.md similarity index 92% rename from docs/Analyze.md rename to docs/docs/tools/analyze.md index 45dcae8d..1264be7f 100644 --- a/docs/Analyze.md +++ b/docs/docs/tools/analyze.md @@ -1,4 +1,4 @@ -# Analyze Tool 💎 +## Overview The `analyze` tool combines static code analysis with LLM capabilities to provide a comprehensive analysis of the PR code changes. The tool scans the PR code changes, find the code components (methods, functions, classes) that changed, and summarizes the changes in each component. @@ -8,14 +8,17 @@ It can be invoked manually by commenting on any PR: /analyze ``` +## Example usage An example [result](https://github.com/Codium-ai/pr-agent/pull/546#issuecomment-1868524805): -___ + -___ + -Notes + +**Notes** + - Language that are currently supported: Python, Java, C++, JavaScript, TypeScript. \ No newline at end of file diff --git a/docs/ASK.md b/docs/docs/tools/ask.md similarity index 93% rename from docs/ASK.md rename to docs/docs/tools/ask.md index d87938a1..e6e02160 100644 --- a/docs/ASK.md +++ b/docs/docs/tools/ask.md @@ -1,4 +1,4 @@ -# ASK Tool +## Overview The `ask` tool answers questions about the PR, based on the PR code changes. Make sure to be specific and clear in your questions. It can be invoked manually by commenting on any PR: @@ -6,13 +6,13 @@ It can be invoked manually by commenting on any PR: /ask "..." ``` For example: -___ + -___ + -___ ## Ask lines + You can run `/ask` on specific lines of code in the PR from the PR's diff view. The tool will answer questions based on the code changes in the selected lines. - Click on the '+' sign next to the line number to select the line. - To select multiple lines, click on the '+' sign of the first line and then hold and drag to select the rest of the lines. @@ -20,5 +20,4 @@ You can run `/ask` on specific lines of code in the PR from the PR's diff view. - -Note that the tool does not have "memory" of previous questions, and answers each question independently. \ No newline at end of file +Note that the tool does not have "memory" of previous questions, and answers each question independently. diff --git a/docs/CI_FEEDBACK.md b/docs/docs/tools/ci_feedback.md similarity index 97% rename from docs/CI_FEEDBACK.md rename to docs/docs/tools/ci_feedback.md index ee92a64f..2949f138 100644 --- a/docs/CI_FEEDBACK.md +++ b/docs/docs/tools/ci_feedback.md @@ -1,7 +1,8 @@ -# CI Feedback Tool +## Overview The CI feedback tool (`/checks)` automatically triggers when a PR has a failed check. The tool analyzes the failed checks and provides several feedbacks: + - Failed stage - Failed test name - Failure summary @@ -10,7 +11,6 @@ The tool analyzes the failed checks and provides several feedbacks: - → @@ -24,7 +24,7 @@ In addition to being automatically triggered, the tool can also be invoked manua ``` where `{repo_name}` is the name of the repository, `{run_number}` is the run number of the failed check, and `{job_number}` is the job number of the failed check. -### Configuration options +## Configuration options - `enable_auto_checks_feedback` - if set to true, the tool will automatically provide feedback when a check is failed. Default is true. - `excluded_checks_list` - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list. - `persistent_comment` - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true. diff --git a/docs/GENERATE_CUSTOM_LABELS.md b/docs/docs/tools/custom_labels.md similarity index 86% rename from docs/GENERATE_CUSTOM_LABELS.md rename to docs/docs/tools/custom_labels.md index 61837ff1..d8dbb1a1 100644 --- a/docs/GENERATE_CUSTOM_LABELS.md +++ b/docs/docs/tools/custom_labels.md @@ -1,4 +1,4 @@ -# Generate Custom Labels 💎 +## Overview The `generate_labels` tool scans the PR code changes, and given a list of labels and their descriptions, it automatically suggests labels that match the PR code changes. It can be invoked manually by commenting on any PR: @@ -12,6 +12,7 @@ If we wish to add detect changes to SQL queries in a given PR, we can add the fo When running the `generate_labels` tool on a PR that includes changes in SQL queries, it will automatically suggest the custom label: + Note that in addition to the dedicated tool `generate_labels`, the custom labels will also be used by the `describe` tool. @@ -20,13 +21,14 @@ Note that in addition to the dedicated tool `generate_labels`, the custom labels There are 3 ways to enable custom labels: #### 1. CLI (local configuration file) -When working from CLI, you need to apply the [configuration changes](#configuration-changes) to the [custom_labels file](./../pr_agent/settings/custom_labels.toml): +When working from CLI, you need to apply the [configuration changes](#configuration-options) to the [custom_labels file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/custom_labels.toml): #### 2. Repo configuration file -To enable custom labels, you need to apply the [configuration changes](#configuration-changes) to the local `.pr_agent.toml` file in you repository. +To enable custom labels, you need to apply the [configuration changes](#configuration-options) to the local `.pr_agent.toml` file in you repository. -#### 3. Handle custom labels from the Repo's labels page +#### 3. Handle custom labels from the Repo's labels page 💎 > This feature is available only in PR-Agent Pro + * GitHub : `https://github.com/{owner}/{repo}/labels`, or click on the "Labels" tab in the issues or PRs page. * GitLab : `https://gitlab.com/{owner}/{repo}/-/labels`, or click on "Manage" -> "Labels" on the left menu. @@ -38,9 +40,9 @@ The description should be comprehensive and detailed, indicating when to add the c. Now the custom labels will be included in the `generate_labels` tool. -*This feature is supported in GitHub and GitLab. +> This feature is supported in GitHub and GitLab. -#### Configuration changes +## Configuration options - Change `enable_custom_labels` to True: This will turn off the default labels and enable the custom labels provided in the custom_labels.toml file. - Add the custom labels. It should be formatted as follows: @@ -53,5 +55,4 @@ description = "Description of when AI should suggest this label" [custom_labels."Custom Label 2"] description = "Description of when AI should suggest this label 2" -``` - +``` \ No newline at end of file diff --git a/docs/CUSTOM_SUGGESTIONS.md b/docs/docs/tools/custom_suggestions.md similarity index 78% rename from docs/CUSTOM_SUGGESTIONS.md rename to docs/docs/tools/custom_suggestions.md index 1be9dfb4..0b19ecef 100644 --- a/docs/CUSTOM_SUGGESTIONS.md +++ b/docs/docs/tools/custom_suggestions.md @@ -1,16 +1,8 @@ -# Custom Suggestions Tool 💎 - -## Table of Contents -- [Overview](#overview) -- [Example usage](#example-usage) -- [Configuration options](#configuration-options) - - ## Overview The `custom_suggestions` tool scans the PR code changes, and automatically generates custom suggestions for improving the PR code. It shares similarities with the `improve` tool, but with one main difference: the `custom_suggestions` tool will only propose suggestions that follow specific guidelines defined by the prompt in: `pr_custom_suggestions.prompt` configuration. -The tool can be triggered [automatically](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) every time a new PR is opened, or can be invoked manually by commenting on a PR. +The tool can be triggered [automatically](../usage-guide/automations_and_usage.md#github-app-automatic-tools-when-a-new-pr-is-opened) every time a new PR is opened, or can be invoked manually by commenting on a PR. When commenting, use the following template: @@ -18,7 +10,7 @@ When commenting, use the following template: /custom_suggestions --pr_custom_suggestions.prompt="The suggestions should focus only on the following:\n-...\n-...\n-..." ``` -With a [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#working-with-github-app), use the following template: +With a [configuration file](../usage-guide/automations_and_usage.md#github-app), use the following template: ``` [pr_custom_suggestions] @@ -50,11 +42,11 @@ The suggestions should focus only on the following: The instructions above are just an example. We want to emphasize that the prompt should be specific and clear, and be tailored to the needs of your project. Results obtained with the prompt above: -___ + -___ + -___ + ## Configuration options @@ -62,4 +54,4 @@ ___ `num_code_suggestions`: number of code suggestions provided by the 'custom_suggestions' tool. Default is 4. -`enable_help_text`: if set to true, the tool will display a help text in the comment. Default is true. +`enable_help_text`: if set to true, the tool will display a help text in the comment. Default is true. \ No newline at end of file diff --git a/docs/DESCRIBE.md b/docs/docs/tools/describe.md similarity index 85% rename from docs/DESCRIBE.md rename to docs/docs/tools/describe.md index 2490180e..bb676f86 100644 --- a/docs/DESCRIBE.md +++ b/docs/docs/tools/describe.md @@ -1,35 +1,26 @@ -# Describe Tool -## Table of Contents -- [Overview](#overview) - - [Configuration options](#configuration-options) - - [Inline file summary 💎](#inline-file-summary-) - - [Handle custom labels from the Repo's labels page :gem:](#handle-custom-labels-from-the-repos-labels-page-gem) - - [Markers template](#markers-template) -- [Usage Tips](#usage-tips) - - [Automation](#automation) - - [Custom labels](#custom-labels) - ## Overview The `describe` tool scans the PR code changes, and generates a description for the PR - title, type, summary, walkthrough and labels. -The tool can be triggered automatically every time a new PR is [opened](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools), or it can be invoked manually by commenting on any PR: +The tool can be triggered automatically every time a new PR is [opened](../usage-guide/automations_and_usage.md#github-app-automatic-tools-when-a-new-pr-is-opened), or it can be invoked manually by commenting on any PR: ``` /describe ``` For example: -___ + -___ + -___ + + -### Configuration options -To edit [configurations](./../pr_agent/settings/configuration.toml#L46) related to the describe tool (`pr_description` section), use the following template: +## Configuration options +To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L46) related to the describe tool (`pr_description` section), use the following template: ``` /describe --pr_description.some_config1=... --pr_description.some_config2=... ``` -**Possible configurations:** +### Possible configurations: + - `publish_labels`: if set to true, the tool will publish the labels to the PR. Default is true. - `publish_description_as_comment`: if set to true, the tool will publish the description as a comment to the PR. If false, it will overwrite the origianl description. Default is false. @@ -40,7 +31,7 @@ To edit [configurations](./../pr_agent/settings/configuration.toml#L46) related - `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...". -- To enable `custom labels`, apply the configuration changes described [here](./GENERATE_CUSTOM_LABELS.md#configuration-changes) +- To enable `custom labels`, apply the configuration changes described [here](./custom_labels.md#configuration-options) - `enable_pr_type`: if set to false, it will not show the `PR type` as a text value in the description content. Default is true. @@ -68,10 +59,10 @@ If you prefer to have the file summaries appear in the "Files changed" tab on ev - `false` (`default`): File changes walkthrough will be added only to the "Conversation" tab. -Note that this feature is currently available only for GitHub. +**Note** that this feature is currently available only for GitHub. -### Handle custom labels from the Repo's labels page :gem: +### Handle custom labels from the Repo's labels page 💎 > This feature is available only in PR-Agent Pro You can control the custom labels that will be suggested by the `describe` tool, from the repo's labels page: @@ -88,6 +79,7 @@ The description should be comprehensive and detailed, indicating when to add the ### Markers template + To enable markers, set `pr_description.use_description_markers=true`. Markers enable to easily integrate user's content and auto-generated content, with a template-like mechanism. @@ -107,22 +99,19 @@ pr_agent:walkthrough The marker `pr_agent:type` will be replaced with the PR type, `pr_agent:summary` will be replaced with the PR summary, and `pr_agent:walkthrough` will be replaced with the PR walkthrough. - -==> - +→ -**Configuration params:** +### Configuration params: - `use_description_markers`: if set to true, the tool will use markers template. It replaces every marker of the form `pr_agent:marker_name` with the relevant content. Default is false. - `include_generated_by_header`: if set to true, the tool will add a dedicated header: 'Generated by PR Agent at ...' to any automatic content. Default is true. ## Usage Tips -1) [Automation](#automation) -2) [Custom labels](#custom-labels) + ### Automation -- When you first install the app, the [default mode](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) for the describe tool is: +- When you first install the app, the [default mode](../usage-guide/automations_and_usage.md#github-app) for the describe tool is: ``` pr_commands = ["/describe --pr_description.add_original_user_description=true" "--pr_description.keep_original_user_title=true", ...] @@ -148,9 +137,10 @@ the tool will replace every marker of the form `pr_agent:marker_name` in the PR Note that when markers are enabled, if the original PR description does not contain any markers, the tool will not alter the description at all. ### Custom labels + The default labels of the describe tool are quite generic, since they are meant to be used in any repo: [`Bug fix`, `Tests`, `Enhancement`, `Documentation`, `Other`]. -If you specify [custom labels](#handle-custom-labels-from-the-repos-labels-page-gem) in the repo's labels page, you can get tailored labels for your use cases. +If you specify [custom labels](#handle-custom-labels-from-the-repos-labels-page) in the repo's labels page, you can get tailored labels for your use cases. Examples for custom labels: - `Main topic:performance` - pr_agent:The main topic of this PR is performance - `New endpoint` - pr_agent:A new endpoint was added in this PR @@ -160,4 +150,4 @@ Examples for custom labels: The list above is eclectic, and aims to give an idea of different possibilities. Define custom labels that are relevant for your repo and use cases. Note that Labels are not mutually exclusive, so you can add multiple label categories. -
Make sure to provide proper title, and a detailed and well-phrased description for each label, so the tool will know when to suggest it. +
Make sure to provide proper title, and a detailed and well-phrased description for each label, so the tool will know when to suggest it. \ No newline at end of file diff --git a/docs/ADD_DOCUMENTATION.md b/docs/docs/tools/documentation.md similarity index 91% rename from docs/ADD_DOCUMENTATION.md rename to docs/docs/tools/documentation.md index 69049ca2..b3fb0ba4 100644 --- a/docs/ADD_DOCUMENTATION.md +++ b/docs/docs/tools/documentation.md @@ -1,4 +1,4 @@ -# Add Documentation Tool 💎 +## Overview The `add_docs` tool scans the PR code changes, and automatically suggests documentation for any code components that changed in the PR (functions, classes, etc.). It can be invoked manually by commenting on any PR: @@ -8,17 +8,17 @@ It can be invoked manually by commenting on any PR: For example: -___ + -___ + -### Configuration options +## Configuration options - `docs_style`: The exact style of the documentation (for python docstring). you can choose between: `google`, `numpy`, `sphinx`, `restructuredtext`, `plain`. Default is `sphinx`. - `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...". -Notes +**Notes** + - Language that are currently fully supported: Python, Java, C++, JavaScript, TypeScript. - For languages that are not fully supported, the tool will suggest documentation only for new components in the PR. -- A previous version of the tool, that offered support only for new components, was deprecated. - +- A previous version of the tool, that offered support only for new components, was deprecated. \ No newline at end of file diff --git a/docs/IMPROVE.md b/docs/docs/tools/improve.md similarity index 74% rename from docs/IMPROVE.md rename to docs/docs/tools/improve.md index 315f4ba0..b4f16d17 100644 --- a/docs/IMPROVE.md +++ b/docs/docs/tools/improve.md @@ -1,16 +1,6 @@ -# Improve Tool - -## Table of Contents -- [Overview](#overview) - - [Configuration options](#configuration-options) -- [Usage Tips](#usage-tips) - - [Extra instructions](#extra-instructions) - - [PR footprint - regular vs summarize mode](#pr-footprint---regular-vs-summarize-mode) - - [A note on code suggestions quality](#a-note-on-code-suggestions-quality) - ## Overview The `improve` tool scans the PR code changes, and automatically generates suggestions for improving the PR code. -The tool can be triggered automatically every time a new PR is [opened](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools), or it can be invoked manually by commenting on any PR: +The tool can be triggered automatically every time a new PR is [opened](../usage-guide/automations_and_usage.md#github-app-automatic-tools-when-a-new-pr-is-opened), or it can be invoked manually by commenting on any PR: ``` /improve ``` @@ -18,15 +8,14 @@ The tool can be triggered automatically every time a new PR is [opened](https:// ### Summarized vs committable code suggestions The code suggestions can be presented as a single comment (via `pr_code_suggestions.summarize=true`): -___ + -___ + Or as a separate commitable code comment for each suggestion: -___ + ---- Note that a single comment has a significantly smaller PR footprint. We recommend this mode for most cases. Also note that collapsible are not supported in _Bitbucket_. Hence, the suggestions are presented there as code comments. @@ -49,18 +38,21 @@ Hence, the total number of suggestions is proportional to the number of chunks, ### Configuration options -To edit [configurations](./../pr_agent/settings/configuration.toml#L66) related to the improve tool (`pr_code_suggestions` section), use the following template: +To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L66) related to the improve tool (`pr_code_suggestions` section), use the following template: ``` /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=... ``` -#### General options +### General options + - `num_code_suggestions`: number of code suggestions provided by the 'improve' tool. Default is 4. - `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...". - `rank_suggestions`: if set to true, the tool will rank the suggestions, based on importance. Default is false. - `summarize`: if set to true, the tool will display the suggestions in a single comment. Default is false. - `enable_help_text`: if set to true, the tool will display a help text in the comment. Default is true. -#### params for '/improve --extended' mode + +### params for '/improve --extended' mode + - `auto_extended_mode`: enable extended mode automatically (no need for the `--extended` option). Default is true. - `num_code_suggestions_per_chunk`: number of code suggestions provided by the 'improve' tool, per chunk. Default is 8. - `rank_extended_suggestions`: if set to true, the tool will rank the suggestions, based on importance. Default is true. @@ -71,6 +63,7 @@ To edit [configurations](./../pr_agent/settings/configuration.toml#L66) related ## Usage Tips ### Extra instructions + Extra instructions are very important for the `imrpove` tool, since they enable you to guide the model to suggestions that are more relevant to the specific needs of the project. Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on. @@ -91,7 +84,6 @@ Use triple quotes to write multi-line instructions. Use bullet points to make th ### A note on code suggestions quality - While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically. -- Suggestions are not meant to be [simplistic](./../pr_agent/settings/pr_code_suggestions_prompts.toml#L34). Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base. +- Suggestions are not meant to be [simplistic](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/pr_code_suggestions_prompts.toml#L34). Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base. - Recommended to use the `exra_instructions` field to guide the model to suggestions that are more relevant to the specific needs of the project. -- Consider also trying the [Custom Suggestions Tool](https://github.com/Codium-ai/pr-agent/blob/main/docs/CUSTOM_SUGGESTIONS.md) 💎, that will **only** propose suggestions that follow specific guidelines defined by user. - +- Consider also trying the [Custom Suggestions Tool](./custom_suggestions.md) 💎, that will **only** propose suggestions that follow specific guidelines defined by user. \ No newline at end of file diff --git a/docs/docs/tools/index.md b/docs/docs/tools/index.md new file mode 100644 index 00000000..bcd9ed9d --- /dev/null +++ b/docs/docs/tools/index.md @@ -0,0 +1,20 @@ +# Tools + +Here is a list of PR-Agent tools, each with a dedicated page that explains how to use it: + +| Tool | Description | +|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------| +| **[PR Description (`/describe`](./describe.md))** | Automatically generating PR description - title, type, summary, code walkthrough and labels | +| **[PR Review (`/review`](./review.md))** | Adjustable feedback about the PR, possible issues, security concerns, review effort and more | +| **[Code Suggestions (`/improve`](./improve.md))** | Code suggestions for improving the PR | +| **[Question Answering (`/ask ...`](./ask.md))** | Answering free-text questions about the PR, or on specific code lines | +| **[Update Changelog (`/update_changelog`](./update_changelog.md))** | Automatically updating the CHANGELOG.md file with the PR changes | +| **[Find Similar Issue (`/similar_issue`](./similar_issues.md))** | Automatically retrieves and presents similar issues | +| **💎 [Add Documentation (`/add_docs`](./documentation.md))** | Generates documentation to methods/functions/classes that changed in the PR | +| **💎 [Generate Custom Labels (`/generate_labels`](./custom_labels.md))** | Generates custom labels for the PR, based on specific guidelines defined by the user | +| **💎 [Analyze (`/analyze`](./analyze.md))** | Identify code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component | +| **💎 [Custom Suggestions (`/custom_suggestions`](./custom_suggestions.md))** | Automatically generates custom suggestions for improving the PR code, based on specific guidelines defined by the user | +| **💎 [Generate Tests (`/test component_name`](./test.md))** | Automatically generates unit tests for a selected component, based on the PR code changes | +| **💎 [CI Feedback (`/checks ci_job`](./ci_feedback.md))** | Automatically generates feedback and analysis for a failed CI job | + +Note that the tools marked with 💎 are available only for PR-Agent Pro users. \ No newline at end of file diff --git a/docs/REVIEW.md b/docs/docs/tools/review.md similarity index 85% rename from docs/REVIEW.md rename to docs/docs/tools/review.md index 98afb085..c0190587 100644 --- a/docs/REVIEW.md +++ b/docs/docs/tools/review.md @@ -1,34 +1,19 @@ -# Review Tool - -## Table of Contents -- [Overview](#overview) - - [Configuration options](#configuration-options) - - [Incremental Mode](#incremental-mode) - - [PR Reflection](#pr-reflection) -- [Usage Tips](#usage-tips) - - [General guidelines](#general-guidelines) - - [Code suggestions](#code-suggestions) - - [Automation](#automation) - - [Auto-labels](#auto-labels) - - [Extra instructions](#extra-instructions) - - [Auto-approval](#auto-approval-1) - ## Overview The `review` tool scans the PR code changes, and automatically generates a PR review. -The tool can be triggered automatically every time a new PR is [opened](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools), or can be invoked manually by commenting on any PR: +The tool can be triggered automatically every time a new PR is [opened](../usage-guide/automations_and_usage.md#github-app-automatic-tools-when-a-new-pr-is-opened), or can be invoked manually by commenting on any PR: ``` /review ``` For example: -___ + -___ + -___ -### Configuration options -To edit [configurations](./../pr_agent/settings/configuration.toml#L19) related to the review tool (`pr_reviewer` section), use the following template: +## Configuration options + +To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L19) related to the review tool (`pr_reviewer` section), use the following template: ``` /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=... ``` @@ -36,26 +21,30 @@ To edit [configurations](./../pr_agent/settings/configuration.toml#L19) related #### General options - `num_code_suggestions`: number of code suggestions provided by the 'review' tool. For manual comments, default is 4. For [PR-Agent app](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L142) auto tools, default is 0, meaning no code suggestions will be provided by the review tool, unless you manually edit `pr_commands`. - `inline_code_comments`: if set to true, the tool will publish the code suggestions as comments on the code diff. Default is false. -- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...". -- `final_update_message`: if set to true, it will add a comment message after finishing calling `/review`. Default is true. - `persistent_comment`: if set to true, the review comment will be persistent, meaning that every new review request will edit the previous one. Default is true. +- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...". #### Enable\\disable features - `require_score_review`: if set to true, the tool will add a section that scores the PR. Default is false. - `require_tests_review`: if set to true, the tool will add a section that checks if the PR contains tests. Default is true. - `require_estimate_effort_to_review`: if set to true, the tool will add a section that estimates the effort needed to review the PR. Default is true. + #### SOC2 ticket compliance 💎 +> This feature is available only in PR-Agent Pro + This sub-tool checks if the PR description properly contains a ticket to a project management system (e.g., Jira, Asana, Trello, etc.), as required by SOC2 compliance. If not, it will add a label to the PR: "Missing SOC2 ticket". - `require_soc2_ticket`: If set to true, the SOC2 ticket checker sub-tool will be enabled. Default is false. - `soc2_ticket_prompt`: The prompt for the SOC2 ticket review. Default is: `Does the PR description include a link to ticket in a project management system (e.g., Jira, Asana, Trello, etc.) ?`. Edit this field if your compliance requirements are different. + #### Adding PR labels - `enable_review_labels_security`: if set to true, the tool will publish a 'possible security issue' label if it detects a security issue. Default is true. - `enable_review_labels_effort`: if set to true, the tool will publish a 'Review effort [1-5]: x' label. Default is true. + #### Auto-approval - `enable_auto_approval`: if set to true, the tool will approve the PR when invoked with the 'auto_approve' command. Default is false. This flag can be changed only from configuration file. - `maximal_review_effort`: maximal effort level for auto-approval. If the PR's estimated review effort is above this threshold, the auto-approval will not run. Default is 5. -### Incremental Mode +#### Incremental Mode Incremental review only considers changes since the last PR-Agent review. This can be useful when working on the PR in an iterative manner, and you want to focus on the changes since the last review instead of reviewing the entire PR again. For invoking the incremental mode, the following command can be used: ``` @@ -65,7 +54,7 @@ Note that the incremental mode is only available for GitHub. -Under the section 'pr_reviewer', the [configuration file](./../pr_agent/settings/configuration.toml#L19) contains options to customize the 'review -i' tool. +Under the section 'pr_reviewer', the [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L19) contains options to customize the 'review -i' tool. These configurations can be used to control the rate at which the incremental review tool will create new review comments when invoked automatically, to prevent making too much noise in the PR. - `minimal_commits_for_incremental_review`: Minimal number of commits since the last review that are required to create incremental review. If there are less than the specified number of commits since the last review, the tool will not perform any action. @@ -79,7 +68,8 @@ When `require_all_thresholds_for_incremental_review=true` the incremental review but when `require_all_thresholds_for_incremental_review=false` the incremental review __will__ run, because one condition is enough (we have 3 commits which is more than the configured 2). Default is false - the tool will run as long as at least once conditions is met. -### PR Reflection +#### PR Reflection + By invoking: ``` /reflect_and_review @@ -87,22 +77,17 @@ By invoking: The tool will first ask the author questions about the PR, and will guide the review based on their answers. -___ + -___ + -___ + ## Usage Tips -1) [General guidelines](#general-guidelines) -2) [Code suggestions](#code-suggestions) -3) [Automation](#automation) -4) [Auto-labels](#auto-labels) -5) [Extra instructions](#extra-instructions) -6) [Auto-approval](#auto-approval) ### General guidelines + The `review` tool provides a collection of possible feedbacks about a PR. It is recommended to review the [Configuration options](#configuration-options) section, and choose the relevant options for your use case. @@ -112,13 +97,14 @@ Some of the features that are disabled by default are quite useful, and should b On the other hand, if you find one of the enabled features to be irrelevant for your use case, disable it. No default configuration can fit all use cases. ### Code suggestions + If you set `num_code_suggestions`>0 , the `review` tool will also provide code suggestions. -Notice If you are interested **only** in the code suggestions, it is recommended to use the [`improve`](./IMPROVE.md) feature instead, since it is a dedicated only to code suggestions, and usually gives better results. +Notice If you are interested **only** in the code suggestions, it is recommended to use the [`improve`](./improve.md) feature instead, since it is a dedicated only to code suggestions, and usually gives better results. Use the `review` tool if you want to get more comprehensive feedback, which includes code suggestions as well. ### Automation -- When you first install the app, the [default mode](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) for the `review` tool is: +- When you first install the app, the [default mode](../usage-guide/automations_and_usage.md#github-app-automatic-tools-when-a-new-pr-is-opened) for the `review` tool is: ``` pr_commands = ["/review", ...] ``` @@ -126,13 +112,16 @@ Meaning the `review` tool will run automatically on every PR, with the default c Edit this field to enable/disable the tool, or to change the used configurations. ### Auto-labels + The `review` tool can auto-generate two specific types of labels for a PR: + - a `possible security issue` label that detects a possible [security issue](https://github.com/Codium-ai/pr-agent/blob/tr/user_description/pr_agent/settings/pr_reviewer_prompts.toml#L136) (`enable_review_labels_security` flag) - a `Review effort [1-5]: x` label, where x is the estimated effort to review the PR (`enable_review_labels_effort` flag) Both modes are useful, and we recommended to enable them. ### Extra instructions + Extra instructions are important. The `review` tool can be configured with extra instructions, which can be used to guide the model to a feedback tailored to the needs of your project. @@ -153,6 +142,7 @@ Use triple quotes to write multi-line instructions. Use bullet points to make th ### Auto-approval + PR-Agent can approve a PR when a specific comment is invoked. To ensure safety, the auto-approval feature is disabled by default. To enable auto-approval, you need to actively set in a pre-defined configuration file the following: @@ -174,4 +164,4 @@ You can also enable auto-approval only if the PR meets certain requirements, suc ``` [pr_reviewer] maximal_review_effort = 5 -``` +``` \ No newline at end of file diff --git a/docs/docs/tools/similar_code.md b/docs/docs/tools/similar_code.md new file mode 100644 index 00000000..a35111d7 --- /dev/null +++ b/docs/docs/tools/similar_code.md @@ -0,0 +1,61 @@ +## Overview +The similar code tool retrieves the most similar code components from inside the organization's codebase, or from open-source code. + +For example: + +`Global Search` for a method called `chat_completion`: + + + +PR-Agent will examine the code component and will extract the most relevant keywords to search for similar code: + +- `extracted keywords`: the keywords that were extracted from the code by PR-Agent. the link will open a search page with the extracted keywords, to allow the user to modify the search if needed. +- `search context`: the context in which the search will be performed, organization's codebase or open-source code (Global). +- `similar code`: the most similar code components found. the link will open the code component in the relevant file. +- `relevant repositories`: the open-source repositories in which that are relevant to the searched code component and it's keywords. + +Search result link example: + + + +`Organization Search`: + + + + +## How to use +### Manually +To invoke the `similar code` tool manually, comment on the PR: +``` +/find_similar_component COMPONENT_NAME +``` +Where `COMPONENT_NAME` should be the name of a code component in the PR (class, method, function). + +If there is a name ambiguity, there are two configurations that will help the tool to find the correct component: + +- `--pr_find_similar_component.file`: in case there are several components with the same name, you can specify the relevant file. +- `--pr_find_similar_component.class_name`: in case there are several methods with the same name in the same file, you can specify the relevant class name. + +example: +``` +/find_similar_component COMPONENT_NAME --pr_find_similar_component.file=FILE_NAME +``` + +### Automatically (via Analyze table) +It can be invoked automatically from the analyze table, can be accessed by: +``` +/analyze +``` +Choose the components you want to find similar code for, and click on the `similar` checkbox. + + +If you are looking to search for similar code in the organization's codebase, you can click on the `Organization` checkbox, and it will invoke a new search command just for the organization's codebase. + + + + +## Configuration options + +- `search_from_org`: if set to true, the tool will search for similar code in the organization's codebase. Default is false. +- `number_of_keywords`: number of keywords to use for the search. Default is 5. +- `number_of_results`: the maximum number of results to present. Default is 5. diff --git a/docs/SIMILAR_ISSUE.md b/docs/docs/tools/similar_issues.md similarity index 93% rename from docs/SIMILAR_ISSUE.md rename to docs/docs/tools/similar_issues.md index 2fcd393b..3d492c0a 100644 --- a/docs/SIMILAR_ISSUE.md +++ b/docs/docs/tools/similar_issues.md @@ -1,4 +1,4 @@ -# Similar Issue Tool +## Overview The similar issue tool retrieves the most similar issues to the current issue. It can be invoked manually by commenting on any PR: ``` @@ -7,7 +7,9 @@ It can be invoked manually by commenting on any PR: For example: + + Note that to perform retrieval, the `similar_issue` tool indexes all the repo previous issues (once). @@ -29,11 +31,11 @@ environment = "..." These parameters can be obtained by registering to [Pinecone](https://app.pinecone.io/?sessionType=signup/). -### How to use: +## How to use: - To invoke the 'similar issue' tool from **CLI**, run: `python3 cli.py --issue_url=... similar_issue` - To invoke the 'similar' issue tool via online usage, [comment](https://github.com/Codium-ai/pr-agent/issues/178#issuecomment-1716934893) on a PR: `/similar_issue` -- You can also enable the 'similar issue' tool to run automatically when a new issue is opened, by adding it to the [pr_commands list in the github_app section](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L66) +- You can also enable the 'similar issue' tool to run automatically when a new issue is opened, by adding it to the [pr_commands list in the github_app section](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L66) \ No newline at end of file diff --git a/docs/TEST.md b/docs/docs/tools/test.md similarity index 85% rename from docs/TEST.md rename to docs/docs/tools/test.md index 4f88c359..a45f6faf 100644 --- a/docs/TEST.md +++ b/docs/docs/tools/test.md @@ -1,26 +1,26 @@ -# Test Tool 💎 +## Overview By combining LLM abilities with static code analysis, the `test` tool generate tests for a selected component, based on the PR code changes. It can be invoked manually by commenting on any PR: ``` /test component_name ``` where 'component_name' is the name of a specific component in the PR. -To get a list of the components that changed in the PR, use the [`analyze`](https://github.com/Codium-ai/pr-agent/blob/main/docs/Analyze.md) tool. +To get a list of the components that changed in the PR, use the [`analyze`](./analyze.md) tool. An example [result](https://github.com/Codium-ai/pr-agent/pull/598#issuecomment-1913679429): -___ + -___ + -Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript. +**Notes** +- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript. - -### Configuration options +## Configuration options - `num_tests`: number of tests to generate. Default is 3. - `testing_framework`: the testing framework to use. If not set, for Python it will use `pytest`, for Java it will use `JUnit`, for C++ it will use `Catch2`, and for JavaScript and TypeScript it will use `jest`. - `avoid_mocks`: if set to true, the tool will try to avoid using mocks in the generated tests. Note that even if this option is set to true, the tool might still use mocks if it cannot generate a test without them. Default is true. diff --git a/docs/UPDATE_CHANGELOG.md b/docs/docs/tools/update_changelog.md similarity index 77% rename from docs/UPDATE_CHANGELOG.md rename to docs/docs/tools/update_changelog.md index dee448f2..4c423a3e 100644 --- a/docs/UPDATE_CHANGELOG.md +++ b/docs/docs/tools/update_changelog.md @@ -1,5 +1,4 @@ -# Update Changelog Tool - +## Overview The `update_changelog` tool automatically updates the CHANGELOG.md file with the PR changes. It can be invoked manually by commenting on any PR: ``` @@ -8,12 +7,13 @@ It can be invoked manually by commenting on any PR: For example: + -### Configuration options +## Configuration options -Under the section 'pr_update_changelog', the [configuration file](./../pr_agent/settings/configuration.toml#L50) contains options to customize the 'update changelog' tool: +Under the section 'pr_update_changelog', the [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L50) contains options to customize the 'update changelog' tool: - `push_changelog_changes`: whether to push the changes to CHANGELOG.md, or just print them. Default is false (print only). - `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ... \ No newline at end of file diff --git a/docs/docs/usage-guide/additional_configurations.md b/docs/docs/usage-guide/additional_configurations.md new file mode 100644 index 00000000..4a6224bd --- /dev/null +++ b/docs/docs/usage-guide/additional_configurations.md @@ -0,0 +1,218 @@ +## 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. + +To ignore files or directories, edit the **[ignore.toml](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/ignore.toml)** configuration file. This setting also exposes the following environment variables: + + - `IGNORE.GLOB` + - `IGNORE.REGEX` + +For example, to ignore python files in a PR with online usage, comment on a PR: +`/review --ignore.glob=['*.py']` + +To ignore python files in all PRs, set in a configuration file: +``` +[ignore] +glob = ['*.py'] +``` + +## Extra instructions + +All PR-Agent tools have a parameter called `extra_instructions`, that enables to add free-text extra instructions. Example usage: +``` +/update_changelog --pr_update_changelog.extra_instructions="Make sure to update also the version ..." +``` + +## Working with large PRs + +The default mode of CodiumAI is to have a single call per tool, using GPT-4, which has a token limit of 8000 tokens. +This mode provide a very good speed-quality-cost tradeoff, and can handle most PRs successfully. +When the PR is above the token limit, it employs a [PR Compression strategy](../core-abilities/index.md). + +However, for very large PRs, or in case you want to emphasize quality over speed and cost, there are 2 possible solutions: +1) [Use a model](https://codium-ai.github.io/Docs-PR-Agent/usage-guide/#changing-a-model) with larger context, like GPT-32K, or claude-100K. This solution will be applicable for all the tools. +2) For the `/improve` tool, there is an ['extended' mode](https://codium-ai.github.io/Docs-PR-Agent/tools/#improve) (`/improve --extended`), +which divides the PR to chunks, and process each chunk separately. With this mode, regardless of the model, no compression will be done (but for large PRs, multiple model calls may occur) + + +## Changing a model + +See [here](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/algo/__init__.py) for the list of available models. +To use a different model than the default (GPT-4), you need to edit [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L2). +For models and environments not from OPENAI, you might need to provide additional keys and other parameters. See below for instructions. + +### Azure + +To use Azure, set in your `.secrets.toml` (working from CLI), or in the GitHub `Settings > Secrets and variables` (working from GitHub App or GitHub Action): +``` +[openai] +key = "" # your azure api key +api_type = "azure" +api_version = '2023-05-15' # Check Azure documentation for the current API version +api_base = "" # The base URL for your Azure OpenAI resource. e.g. "https://.openai.azure.com" +deployment_id = "" # The deployment name you chose when you deployed the engine +``` + +and set in your configuration file: +``` +[config] +model="" # the OpenAI model you've deployed on Azure (e.g. gpt-3.5-turbo) +``` + +### Huggingface + +**Local** +You can run Huggingface models locally through either [VLLM](https://docs.litellm.ai/docs/providers/vllm) or [Ollama](https://docs.litellm.ai/docs/providers/ollama) + +E.g. to use a new Huggingface model locally via Ollama, set: +``` +[__init__.py] +MAX_TOKENS = { + "model-name-on-ollama": +} +e.g. +MAX_TOKENS={ + ..., + "ollama/llama2": 4096 +} + + +[config] # in configuration.toml +model = "ollama/llama2" + +[ollama] # in .secrets.toml +api_base = ... # the base url for your huggingface inference endpoint +# e.g. if running Ollama locally, you may use: +api_base = "http://localhost:11434/" +``` + +### Inference Endpoints + +To use a new model with Huggingface Inference Endpoints, for example, set: +``` +[__init__.py] +MAX_TOKENS = { + "model-name-on-huggingface": +} +e.g. +MAX_TOKENS={ + ..., + "meta-llama/Llama-2-7b-chat-hf": 4096 +} +[config] # in configuration.toml +model = "huggingface/meta-llama/Llama-2-7b-chat-hf" + +[huggingface] # in .secrets.toml +key = ... # your huggingface api key +api_base = ... # the base url for your huggingface inference endpoint +``` +(you can obtain a Llama2 key from [here](https://replicate.com/replicate/llama-2-70b-chat/api)) + +### Replicate + +To use Llama2 model with Replicate, for example, set: +``` +[config] # in configuration.toml +model = "replicate/llama-2-70b-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1" +[replicate] # in .secrets.toml +key = ... +``` +(you can obtain a Llama2 key from [here](https://replicate.com/replicate/llama-2-70b-chat/api)) + + +Also review the [AiHandler](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/algo/ai_handler.py) file for instruction how to set keys for other models. + +### Vertex AI + +To use Google's Vertex AI platform and its associated models (chat-bison/codechat-bison) set: + +``` +[config] # in configuration.toml +model = "vertex_ai/codechat-bison" +fallback_models="vertex_ai/codechat-bison" + +[vertexai] # in .secrets.toml +vertex_project = "my-google-cloud-project" +vertex_location = "" +``` + +Your [application default credentials](https://cloud.google.com/docs/authentication/application-default-credentials) will be used for authentication so there is no need to set explicit credentials in most environments. + +If you do want to set explicit credentials then you can use the `GOOGLE_APPLICATION_CREDENTIALS` environment variable set to a path to a json credentials file. + +### Anthropic + +To use Anthropic models, set the relevant models in the configuration section of the configuration file: +``` +[config] +model="anthropic/claude-3-opus-20240229" +model_turbo="anthropic/claude-3-opus-20240229" +fallback_models=["anthropic/claude-3-opus-20240229"] +``` + +And also set the api key in the .secrets.toml file: +``` +[anthropic] +KEY = "..." +``` + +### Amazon Bedrock + +To use Amazon Bedrock and its foundational models, add the below configuration: + +``` +[config] # in configuration.toml +model = "anthropic.claude-v2" +fallback_models="anthropic.claude-instant-v1" + +[aws] # in .secrets.toml +bedrock_region = "us-east-1" +``` + +Note that you have to add access to foundational models before using them. Please refer to [this document](https://docs.aws.amazon.com/bedrock/latest/userguide/setting-up.html) for more details. + +AWS session is automatically authenticated from your environment, but you can also explicitly set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. + + +## Patch Extra Lines + +By default, around any change in your PR, git patch provides 3 lines of context above and below the change. +``` +@@ -12,5 +12,5 @@ def func1(): + code line that already existed in the file... + code line that already existed in the file... + code line that already existed in the file.... +-code line that was removed in the PR ++new code line added in the PR + code line that already existed in the file... + code line that already existed in the file... + code line that already existed in the file... +``` + +For the `review`, `describe`, `ask` and `add_docs` tools, if the token budget allows, PR-Agent tries to increase the number of lines of context, via the parameter: +``` +[config] +patch_extra_lines=3 +``` + +Increasing this number provides more context to the model, but will also increase the token budget. +If the PR is too large (see [PR Compression strategy](https://github.com/Codium-ai/pr-agent/blob/main/PR_COMPRESSION.md)), PR-Agent automatically sets this number to 0, using the original git patch. + + +## Editing the prompts + +The prompts for the various PR-Agent tools are defined in the `pr_agent/settings` folder. +In practice, the prompts are loaded and stored as a standard setting object. +Hence, editing them is similar to editing any other configuration value - just place the relevant key in `.pr_agent.toml`file, and override the default value. + +For example, if you want to edit the prompts of the [describe](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/pr_description_prompts.toml) tool, you can add the following to your `.pr_agent.toml` file: +``` +[pr_description_prompt] +system=""" +... +""" +user=""" +... +""" +``` +Note that the new prompt will need to generate an output compatible with the relevant [post-process function](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/tools/pr_description.py#L137). diff --git a/docs/docs/usage-guide/automations_and_usage.md b/docs/docs/usage-guide/automations_and_usage.md new file mode 100644 index 00000000..81f182b5 --- /dev/null +++ b/docs/docs/usage-guide/automations_and_usage.md @@ -0,0 +1,200 @@ +## Local repo (CLI) +When running from your local repo (CLI), your local configuration file will be used. +Examples of invoking the different tools via the CLI: + +- **Review**: `python -m pr_agent.cli --pr_url= review` +- **Describe**: `python -m pr_agent.cli --pr_url= describe` +- **Improve**: `python -m pr_agent.cli --pr_url= improve` +- **Ask**: `python -m pr_agent.cli --pr_url= ask "Write me a poem about this PR"` +- **Reflect**: `python -m pr_agent.cli --pr_url= reflect` +- **Update Changelog**: `python -m pr_agent.cli --pr_url= update_changelog` + +`` is the url of the relevant PR (for example: [#50](https://github.com/Codium-ai/pr-agent/pull/50)). + +**Notes:** + +(1) in addition to editing your local configuration file, you can also change any configuration value by adding it to the command line: +``` +python -m pr_agent.cli --pr_url= /review --pr_reviewer.extra_instructions="focus on the file: ..." +``` + +(2) You can print results locally, without publishing them, by setting in `configuration.toml`: +``` +[config] +publish_output=false +verbosity_level=2 +``` +This is useful for debugging or experimenting with different tools. + + +### Online usage + +Online usage means invoking PR-Agent tools by [comments](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695021901) on a PR. +Commands for invoking the different tools via comments: + +- **Review**: `/review` +- **Describe**: `/describe` +- **Improve**: `/improve` +- **Ask**: `/ask "..."` +- **Reflect**: `/reflect` +- **Update Changelog**: `/update_changelog` + + +To edit a specific configuration value, just add `--config_path=` to any command. +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 +``` +Any configuration value in [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml) file can be similarly edited. Comment `/config` to see the list of available configurations. + + +## GitHub App + +### GitHub app automatic tools when a new PR is opened + +The [github_app](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L108) section defines GitHub app specific configurations. + +The configuration parameter `pr_commands` defines the list of tools that will be **run automatically** when a new PR is opened. +``` +[github_app] +pr_commands = [ + "/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true --pr_description.final_update_message=false", + "/review --pr_reviewer.num_code_suggestions=0 --pr_reviewer.final_update_message=false", + "/improve", +] +``` +This means that when a new PR is opened/reopened or marked as ready for review, PR-Agent will run the `describe`, `review` and `improve` tools. +For the `describe` tool, for example, the `add_original_user_description` and `keep_original_user_title` parameters will be set to true. + +You can override the default tool parameters by using one the three options for a [configuration file](https://codium-ai.github.io/Docs-PR-Agent/usage-guide/#configuration-options): **wiki**, **local**, or **global**. +For example, if your local `.pr_agent.toml` file contains: +``` +[pr_description] +add_original_user_description = false +keep_original_user_title = false +``` +When a new PR is opened, PR-Agent will run the `describe` tool with the above parameters. + +To cancel the automatic run of all the tools, set: +``` +[github_app] +handle_pr_actions = [] +``` + +You can also disable automatic runs for PRs with specific titles, by setting the `ignore_pr_titles` parameter with the relevant regex. For example: +``` +[github_app] +ignore_pr_title = ["^[Auto]", ".*ignore.*"] +``` +will ignore PRs with titles that start with "Auto" or contain the word "ignore". + +### GitHub app automatic tools for push actions (commits to an open PR) + +In addition to running automatic tools when a PR is opened, the GitHub app can also respond to new code that is pushed to an open PR. + +The configuration toggle `handle_push_trigger` can be used to enable this feature. +The configuration parameter `push_commands` defines the list of tools that will be **run automatically** when new code is pushed to the PR. +``` +[github_app] +handle_push_trigger = true +push_commands = [ + "/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true", + "/review --pr_reviewer.num_code_suggestions=0", +] +``` +This means that when new code is pushed to the PR, the PR-Agent will run the `describe` and `review` tools, with the specified parameters. + +## GitHub Action +`GitHub Action` is a different way to trigger PR-Agent tools, and uses a different configuration mechanism than `GitHub App`. +You can configure settings for `GitHub Action` by adding environment variables under the env section in `.github/workflows/pr_agent.yml` file. +Specifically, start by setting the following environment variables: +```yaml + env: + OPENAI_KEY: ${{ secrets.OPENAI_KEY }} # Make sure to add your OpenAI key to your repo secrets + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Make sure to add your GitHub token to your repo secrets + github_action_config.auto_review: "true" # enable\disable auto review + github_action_config.auto_describe: "true" # enable\disable auto describe + github_action_config.auto_improve: "true" # enable\disable auto improve +``` +`github_action_config.auto_review`, `github_action_config.auto_describe` and `github_action_config.auto_improve` are used to enable/disable automatic tools that run when a new PR is opened. +If not set, the default configuration is for all three tools to run automatically when a new PR is opened. + +Note that you can give additional config parameters by adding environment variables to `.github/workflows/pr_agent.yml`, or by using a `.pr_agent.toml` file in the root of your repo, similar to the GitHub App usage. + +For example, you can set an environment variable: `pr_description.add_original_user_description=false`, or add a `.pr_agent.toml` file with the following content: +``` +[pr_description] +add_original_user_description = false +``` + +## GitLab Webhook +After setting up a GitLab webhook, to control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file, similar to the GitHub App: +``` +[gitlab] +pr_commands = [ + "/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true", + "/review --pr_reviewer.num_code_suggestions=0", + "/improve", +] +``` + +## BitBucket App +Similar to GitHub app, when running PR-Agent from BitBucket App, the default [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml) from a pre-built docker will be initially loaded. + +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. Note that you need to upload `.pr_agent.toml` prior to creating a PR, in order for the configuration to take effect. + +For example, if your local `.pr_agent.toml` file contains: +``` +[pr_reviewer] +inline_code_comments = true +``` + +Each time you invoke a `/review` tool, it will use inline code comments. + +### BitBucket Self-Hosted App automatic tools + +to control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file: +Specifically, set the following values: + +[bitbucket_app] +``` +pr_commands = [ + "/review --pr_reviewer.num_code_suggestions=0", + "/improve --pr_code_suggestions.summarize=false", +] +``` + +## Azure DevOps provider + +To use Azure DevOps provider use the following settings in configuration.toml: +``` +[config] +git_provider="azure" +use_repo_settings_file=false +``` + +Azure DevOps provider supports [PAT token](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows) or [DefaultAzureCredential](https://learn.microsoft.com/en-us/azure/developer/python/sdk/authentication-overview#authentication-in-server-environments) authentication. +PAT is faster to create, but has build in experation date, and will use the user identity for API calls. +Using DefaultAzureCredential you can use managed identity or Service principle, which are more secure and will create seperate ADO user identity (via AAD) to the agent. + +If PAT was choosen, you can assign the value in .secrets.toml. +If DefaultAzureCredential was choosen, you can assigned the additional env vars like AZURE_CLIENT_SECRET directly, +or use managed identity/az cli (for local develpment) without any additional configuration. +in any case, 'org' value must be assigned in .secrets.toml: +``` +[azure_devops] +org = "https://dev.azure.com/YOUR_ORGANIZATION/" +# pat = "YOUR_PAT_TOKEN" needed only if using PAT for authentication +``` + +### Azure DevOps Webhook + +To control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file, similar to the GitHub App: +``` +[azure_devops_server] +pr_commands = [ + "/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true", + "/review --pr_reviewer.num_code_suggestions=0", + "/improve", +] +``` \ No newline at end of file diff --git a/docs/docs/usage-guide/configuration_options.md b/docs/docs/usage-guide/configuration_options.md new file mode 100644 index 00000000..9b15babb --- /dev/null +++ b/docs/docs/usage-guide/configuration_options.md @@ -0,0 +1,56 @@ +The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml)**. + +In addition to general configuration options, each tool has its own configurations. For example, the `review` tool will use parameters from the [pr_reviewer](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L16) section in the configuration file. +See the [Tools Guide](https://codium-ai.github.io/Docs-PR-Agent/tools/) for a detailed description of the different tools and their configurations. + +There are three ways to set persistent configurations: + +1. Wiki configuration page 💎 +2. Local configuration file +3. Global configuration file 💎 + +In terms of precedence, wiki configurations will override local configurations, and local configurations will override global configurations. + +## Wiki configuration file 💎 + +Specifically for GitHub, with PR-Agent-Pro you can set configurations by creating a page called `.pr_agent.toml` in the [wiki](https://github.com/Codium-ai/pr-agent/wiki/pr_agent.toml) of the repo. +The advantage of this method is that it allows to set configurations without needing to commit new content to the repo - just edit the wiki page and **save**. + + + +Click [here](https://codium.ai/images/pr_agent/wiki_configuration_pr_agent.mp4) to see a short instructional video. We recommend surrounding the configuration content with triple-quotes, to allow better presentation when displayed in the wiki as markdown. +An example content: + +``` +[pr_description] # /describe # +keep_original_user_title=false +``` + +PR-Agent will know to remove the triple-quotes when reading the configuration content. + +## Local configuration file + +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. Note that you need to upload `.pr_agent.toml` prior to creating a PR, in order for the configuration to take effect. + +For example, if you set in `.pr_agent.toml`: + +``` +[pr_reviewer] +extra_instructions="""\ +- instruction a +- instruction b +... +""" +``` + +Then you can give a list of extra instructions to the `review` tool. + + +## Global configuration file 💎 + +If you create a repo called `pr-agent-settings` in your **organization**, it's configuration file `.pr_agent.toml` will be used as a global configuration file for any other repo that belongs to the same organization. +Parameters from a local `.pr_agent.toml` file, in a specific repo, will override the global configuration parameters. + +For example, in the GitHub organization `Codium-ai`: +- The repo [`https://github.com/Codium-ai/pr-agent-settings`](https://github.com/Codium-ai/pr-agent-settings/blob/main/.pr_agent.toml) contains a `.pr_agent.toml` file that serves as a global configuration file for all the repos in the GitHub organization `Codium-ai`. +- The repo [`https://github.com/Codium-ai/pr-agent`](https://github.com/Codium-ai/pr-agent/blob/main/.pr_agent.toml) inherits the global configuration file from `pr-agent-settings`. \ No newline at end of file diff --git a/docs/docs/usage-guide/index.md b/docs/docs/usage-guide/index.md new file mode 100644 index 00000000..e784d1b0 --- /dev/null +++ b/docs/docs/usage-guide/index.md @@ -0,0 +1,20 @@ +# Usage guide + +- [Introduction](./introduction.md) +- [Configuration Options](./configuration_options.md) +- [Managing Mail Notifications](./mail_notifications.md) +- [Usage and Automation](./automations_and_usage.md) + - [Local Repo (CLI)](./automations_and_usage.md#local-repo-cli) + - [Online Usage](./automations_and_usage.md#online-usage) + - [GitHub App](./automations_and_usage.md#github-app) + - [GitHub Action](./automations_and_usage.md#github-action) + - [GitLab Webhook](./automations_and_usage.md#gitlab-webhook) + - [BitBucket App](./automations_and_usage.md#bitbucket-app) + - [Azure DevOps Provider](./automations_and_usage.md#azure-devops-provider) +- [Additional Configurations Walkthrough](./additional_configurations.md) + - [Ignoring files from analysis](./additional_configurations.md#ignoring-files-from-analysis) + - [Extra instructions](./additional_configurations.md#extra-instructions) + - [Working with large PRs](./additional_configurations.md#working-with-large-prs) + - [Changing a model](./additional_configurations.md#changing-a-model) + - [Patch Extra Lines](./additional_configurations.md#patch-extra-lines) + - [Editing the prompts](./additional_configurations.md#editing-the-prompts) \ No newline at end of file diff --git a/docs/docs/usage-guide/introduction.md b/docs/docs/usage-guide/introduction.md new file mode 100644 index 00000000..c851edbe --- /dev/null +++ b/docs/docs/usage-guide/introduction.md @@ -0,0 +1,18 @@ + +After [installation](https://codium-ai.github.io/Docs-PR-Agent/installation/), there are three basic ways to invoke CodiumAI PR-Agent: + +1. Locally running a CLI command +2. Online usage - by [commenting](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695021901) on a PR +3. Enabling PR-Agent tools to run automatically when a new PR is opened + + +Specifically, CLI commands can be issued by invoking a pre-built [docker image](https://codium-ai.github.io/Docs-PR-Agent/installation/#run-from-source), or by invoking a [locally cloned repo](https://codium-ai.github.io/Docs-PR-Agent/installation/#locally). +For online usage, you will need to setup either a [GitHub App](https://codium-ai.github.io/Docs-PR-Agent/installation/#run-as-a-github-app), or a [GitHub Action](https://codium-ai.github.io/Docs-PR-Agent/installation/#run-as-a-github-action). +GitHub App and GitHub Action also enable to run PR-Agent specific tool automatically when a new PR is opened. + + +**git provider**: The [git_provider](https://github.com/Codium-ai/pr-agent/blob/main/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: +` +"github", "gitlab", "bitbucket", "azure", "codecommit", "local", "gerrit" +` + diff --git a/docs/docs/usage-guide/mail_notifications.md b/docs/docs/usage-guide/mail_notifications.md new file mode 100644 index 00000000..1e5b2e8a --- /dev/null +++ b/docs/docs/usage-guide/mail_notifications.md @@ -0,0 +1,9 @@ + +Unfortunately, it is not possible in GitHub to disable mail notifications from a specific user. +If you are subscribed to notifications for a repo with PR-Agent, we recommend turning off notifications for PR comments, to avoid lengthy emails: + + + +As an alternative, you can filter in your mail provider the notifications specifically from the PR-Agent bot, [see how](https://www.quora.com/How-can-you-filter-emails-for-specific-people-in-Gmail#:~:text=On%20the%20Filters%20and%20Blocked,the%20body%20of%20the%20email). + + \ No newline at end of file diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml new file mode 100644 index 00000000..b71bf125 --- /dev/null +++ b/docs/mkdocs.yml @@ -0,0 +1,121 @@ +site_name: PR-Agent + +nav: + - Overview: 'index.md' + - Installation: + - 'installation/index.md' + - Locally: 'installation/locally.md' + - GitHub: 'installation/github.md' + - GitLab: 'installation/gitlab.md' + - BitBucket: 'installation/bitbucket.md' + - Azure DevOps: 'installation/azure.md' + - Usage Guide: + - 'usage-guide/index.md' + - Introduction: 'usage-guide/introduction.md' + - Configuration Options: 'usage-guide/configuration_options.md' + - Managing email notifications: 'usage-guide/mail_notifications.md' + - Usage and Automation: 'usage-guide/automations_and_usage.md' + - Additional Configurations: 'usage-guide/additional_configurations.md' + - Tools: + - 'tools/index.md' + - Describe: 'tools/describe.md' + - Review: 'tools/review.md' + - Improve: 'tools/improve.md' + - Ask: 'tools/ask.md' + - Update Changelog: 'tools/update_changelog.md' + - Similar Issues: 'tools/similar_issues.md' + - 💎 Analyze: 'tools/analyze.md' + - 💎 Test: 'tools/test.md' + - 💎 Documentation: 'tools/documentation.md' + - 💎 Custom Labels: 'tools/custom_labels.md' + - 💎 Custom Suggestions: 'tools/custom_suggestions.md' + - 💎 CI Feedback: 'tools/ci_feedback.md' + - 💎 Similar Code: 'tools/similar_code.md' + - Core Abilities: 'core-abilities/index.md' + +theme: + logo: assets/logo.png + favicon: assets/favicon.ico + name: material + features: + - navigation.tabs + - navigation.expand + - navigation.path + - navigation.top + - navigation.tracking + - navigation.indexes + - search.suggest + - search.highlight + - content.tabs.link + - content.code.annotation + - content.code.copy + - toc.integrate + language: en + custom_dir: overrides + + palette: + - media: "(prefers-color-scheme)" + toggle: + icon: material/brightness-auto + name: Switch to light mode + - media: "(prefers-color-scheme: light)" + scheme: default + toggle: + icon: material/toggle-switch-off-outline + name: Switch to dark mode + primary: custom + accent: custom + - media: "(prefers-color-scheme: dark)" + scheme: slate + toggle: + icon: material/toggle-switch + name: Switch to light mode + primary: custom + accent: custom + +plugins: + - social + - search + +extra: + generator: false + social: + - icon: fontawesome/brands/github + link: https://github.com/Codium-ai + - icon: fontawesome/brands/discord + link: https://discord.com/invite/SgSxuQ65GF + - icon: fontawesome/brands/youtube + link: https://www.youtube.com/@Codium-AI + - icon: fontawesome/brands/linkedin + link: https://www.linkedin.com/company/codiumai + - icon: fontawesome/brands/twitter + link: https://twitter.com/CodiumAI + - icon: fontawesome/brands/instagram + link: https://www.instagram.com/codiumai/ + +extra_css: + - css/custom.css + +markdown_extensions: + - pymdownx.highlight: + anchor_linenums: true + - pymdownx.inlinehilite + - pymdownx.snippets + - admonition + - pymdownx.arithmatex: + generic: true + - footnotes + - pymdownx.details + - pymdownx.superfences + - pymdownx.mark + - attr_list + - pymdownx.emoji: + emoji_index: !!python/name:material.extensions.emoji.twemoji + emoji_generator: !!python/name:materialx.emoji.to_svg + - toc: + title: On this page + toc_depth: 3 + permalink: true + +copyright: | + © 2024 CodiumAI diff --git a/docs/overrides/partials/footer.html b/docs/overrides/partials/footer.html new file mode 100644 index 00000000..96ba7e86 --- /dev/null +++ b/docs/overrides/partials/footer.html @@ -0,0 +1,100 @@ + + + + + +Footer Customization + + + + + + + + diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index 6d1eb5b9..04a13a61 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -176,7 +176,9 @@ class PRReviewer: Prepare the PR review by processing the AI prediction and generating a markdown-formatted text that summarizes the feedback. """ - data = load_yaml(self.prediction.strip()) + data = load_yaml(self.prediction.strip(), + keys_fix_yaml=["estimated_effort_to_review_[1-5]:", "security_concerns:", "possible_issues:", + "relevant_file:", "relevant_line:", "suggestion:"]) if 'code_feedback' in data: code_feedback = data['code_feedback'] @@ -247,7 +249,7 @@ class PRReviewer: keys_fix_yaml=["estimated_effort_to_review_[1-5]:", "security_concerns:", "possible_issues:", "relevant_file:", "relevant_line:", "suggestion:"]) comments: List[str] = [] - for suggestion in data.get('PR Feedback', {}).get('Code feedback', []): + for suggestion in data.get('code_feedback', []): relevant_file = suggestion.get('relevant_file', '').strip() relevant_line_in_file = suggestion.get('relevant_line', '').strip() content = suggestion.get('suggestion', '')