From 736c8a695306830bdcff445d07ba901960e060d9 Mon Sep 17 00:00:00 2001 From: Almog Lavi Date: Tue, 26 Mar 2024 23:00:57 +0200 Subject: [PATCH 01/44] Refactor markdown image syntax and enhance documentation presentation --- .github/workflows/docs-ci.yaml | 1 + docs/docs/core-abilities/index.md | 2 +- docs/docs/css/custom.css | 9 ++ docs/docs/index.md | 90 ++++--------------- docs/docs/installation/pr_agent_pro.md | 16 ++-- docs/docs/tools/analyze.md | 12 ++- docs/docs/tools/ask.md | 6 +- docs/docs/tools/ci_feedback.md | 9 +- docs/docs/tools/custom_labels.md | 7 +- docs/docs/tools/custom_suggestions.md | 7 +- docs/docs/tools/describe.md | 49 ++-------- docs/docs/tools/documentation.md | 6 +- docs/docs/tools/improve.md | 14 +-- docs/docs/tools/review.md | 36 ++------ docs/docs/tools/similar_code.md | 12 +-- docs/docs/tools/similar_issues.md | 6 +- docs/docs/tools/test.md | 6 +- docs/docs/tools/update_changelog.md | 5 +- .../docs/usage-guide/configuration_options.md | 2 +- docs/docs/usage-guide/mail_notifications.md | 4 +- docs/mkdocs.yml | 2 + 21 files changed, 96 insertions(+), 205 deletions(-) diff --git a/.github/workflows/docs-ci.yaml b/.github/workflows/docs-ci.yaml index 1648fd44..b260039e 100644 --- a/.github/workflows/docs-ci.yaml +++ b/.github/workflows/docs-ci.yaml @@ -29,4 +29,5 @@ jobs: mkdocs-material- - run: pip install mkdocs-material - run: pip install "mkdocs-material[imaging]" + - run: pip install mkdocs-glightbox - run: mkdocs gh-deploy -f docs/mkdocs.yml --force diff --git a/docs/docs/core-abilities/index.md b/docs/docs/core-abilities/index.md index 074d4c09..0a97aaf3 100644 --- a/docs/docs/core-abilities/index.md +++ b/docs/docs/core-abilities/index.md @@ -43,7 +43,7 @@ We use [tiktoken](https://github.com/openai/tiktoken) to tokenize the patches af #### Example - +![Core Abilities](https://codium.ai/images/git_patch_logic.png){width=768} ## YAML Prompting TBD diff --git a/docs/docs/css/custom.css b/docs/docs/css/custom.css index 2f963ccd..e79736b4 100644 --- a/docs/docs/css/custom.css +++ b/docs/docs/css/custom.css @@ -16,3 +16,12 @@ font-size: 20px; margin-left: 0px !important; } + +.md-content img { + border-width: 1px; + border-style: solid; + border-color: black; + outline-width: 3px; + outline-style: solid; + outline-color: darkgray; + } \ No newline at end of file diff --git a/docs/docs/index.md b/docs/docs/index.md index ed02e502..246680df 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -47,83 +47,25 @@ PR-Agent offers extensive pull request functionalities across various git provid ## Example results -
-

/describe

-
-

- -

-
-
+#### [/describe](https://github.com/Codium-ai/pr-agent/pull/530) +
+![/describe](https://www.codium.ai/images/pr_agent/describe_new_short_main.png){width=512} +
-

/review

-
-

- - - -

-
-
+#### [/review](https://github.com/Codium-ai/pr-agent/pull/732#issuecomment-1975099151) +
+![/review](https://www.codium.ai/images/pr_agent/review_new_short_main.png){width=512} +
-

/improve

-
-

- - - -

-
-
- -

/generate_labels

-
-

- -

-
- -[//]: # (

/reflect_and_review:

) - -[//]: # (
) - -[//]: # (

) - -[//]: # () - -[//]: # (

) - -[//]: # (
) - -[//]: # (

/ask:

) - -[//]: # (
) - -[//]: # (

) - -[//]: # () - -[//]: # (

) - -[//]: # (
) - -[//]: # (

/improve:

) - -[//]: # (
) - -[//]: # (

) - -[//]: # () - -[//]: # (

) - -[//]: # (
) -
- - -
-
+#### [/improve](https://github.com/Codium-ai/pr-agent/pull/732#issuecomment-1975099159) +
+![/improve](https://www.codium.ai/images/pr_agent/improve_new_short_main.png){width=512} +
+#### [/generate_labels](https://github.com/Codium-ai/pr-agent/pull/530) +
+![/generate_labels](https://www.codium.ai/images/pr_agent/geneare_custom_labels_main_short.png){width=300} +
## How it works diff --git a/docs/docs/installation/pr_agent_pro.md b/docs/docs/installation/pr_agent_pro.md index cb371df7..bf3f32de 100644 --- a/docs/docs/installation/pr_agent_pro.md +++ b/docs/docs/installation/pr_agent_pro.md @@ -7,9 +7,7 @@ See [here](https://pr-agent-docs.codium.ai/#pr-agent-pro) for more details about Interested parties can subscribe to PR-Agent Pro through the following [link](https://www.codium.ai/pricing/). After subscribing, you are granted the ability to easily install the application across any of your repositories. - - - +![PR Agent Pro](https://codium.ai/images/pr_agent/pr_agent_pro_install.png){width=468} Each user who wants to use PR-Agent pro needs to buy a seat. Initially, CodiumAI offers a two-week trial period at no cost, after which continued access requires each user to secure a personal seat. @@ -27,7 +25,9 @@ Since GitLab platform does not support apps, installing PR-Agent Pro for GitLab Acquire a personal, project or group level access token. Enable the “api” scope in order to allow PR-Agent to read pull requests, comment and respond to requests. - +
+![Step 1](https://www.codium.ai/images/pr_agent/gitlab_pro_pat.png){width=750} +
Store the token in a safe place, you won’t be able to access it again after it was generated. @@ -42,7 +42,9 @@ You should see "Success!" displayed above the Submit button, and a shared secret Install a webhook for your repository or groups, by clicking “webhooks” on the settings menu. Click the “Add new webhook” button. - +
+![Step 3.1](https://www.codium.ai/images/pr_agent/gitlab_pro_add_webhook.png) +
In the webhook definition form, fill in the following fields: URL: https://pro.gitlab.pr-agent.codium.ai/webhook @@ -51,7 +53,9 @@ Secret token: Your CodiumAI key Trigger: Check the ‘comments’ and ‘merge request events’ boxes. Enable SSL verification: Check the box. - +
+![Step 3.2](https://www.codium.ai/images/pr_agent/gitlab_pro_webhooks.png){width=750} +
### Step 4 diff --git a/docs/docs/tools/analyze.md b/docs/docs/tools/analyze.md index 1264be7f..3b7c6d58 100644 --- a/docs/docs/tools/analyze.md +++ b/docs/docs/tools/analyze.md @@ -11,13 +11,11 @@ It can be invoked manually by commenting on any PR: ## Example usage An example [result](https://github.com/Codium-ai/pr-agent/pull/546#issuecomment-1868524805): - - - - - - - +![Analyze 1](https://codium.ai/images/pr_agent/analyze_1.png){width=750} +→ +![Analyze 2](https://codium.ai/images/pr_agent/analyze_2.png){width=750} +→ +![Analyze 3](https://codium.ai/images/pr_agent/analyze_3.png){width=750} **Notes** diff --git a/docs/docs/tools/ask.md b/docs/docs/tools/ask.md index e6e02160..453807fd 100644 --- a/docs/docs/tools/ask.md +++ b/docs/docs/tools/ask.md @@ -7,9 +7,9 @@ It can be invoked manually by commenting on any PR: ``` For example: - +![Ask Comment](https://codium.ai/images/pr_agent/ask_comment.png){width=768} - +![Ask](https://codium.ai/images/pr_agent/ask.png){width=768} ## Ask lines @@ -18,6 +18,6 @@ You can run `/ask` on specific lines of code in the PR from the PR's diff view. - To select multiple lines, click on the '+' sign of the first line and then hold and drag to select the rest of the lines. - write `/ask "..."` in the comment box and press `Add single comment` button. - +![Ask Line](https://codium.ai/images/pr_agent/Ask_line.png){width=768} Note that the tool does not have "memory" of previous questions, and answers each question independently. diff --git a/docs/docs/tools/ci_feedback.md b/docs/docs/tools/ci_feedback.md index 2949f138..998fef56 100644 --- a/docs/docs/tools/ci_feedback.md +++ b/docs/docs/tools/ci_feedback.md @@ -8,13 +8,10 @@ The tool analyzes the failed checks and provides several feedbacks: - Failure summary - Relevant error logs - - - +![Failed Check 1](https://www.codium.ai/images/pr_agent/failed_check1.png){width=768} + → - - - +![Failed Check 2](https://www.codium.ai/images/pr_agent/failed_check2.png){width=768} ___ diff --git a/docs/docs/tools/custom_labels.md b/docs/docs/tools/custom_labels.md index d8dbb1a1..29f1a9e2 100644 --- a/docs/docs/tools/custom_labels.md +++ b/docs/docs/tools/custom_labels.md @@ -9,11 +9,11 @@ For example: If we wish to add detect changes to SQL queries in a given PR, we can add the following custom label along with its description: - +![Custom labels list](https://codium.ai/images/pr_agent/custom_labels_list.png){width=768} When running the `generate_labels` tool on a PR that includes changes in SQL queries, it will automatically suggest the custom label: - +![Custom labels published](https://codium.ai/images/pr_agent/custom_label_published.png){width=768} Note that in addition to the dedicated tool `generate_labels`, the custom labels will also be used by the `describe` tool. @@ -36,7 +36,8 @@ b. Add/edit the custom labels. It should be formatted as follows: * Label name: The name of the custom label. * Description: Start the description of with prefix `pr_agent:`, for example: `pr_agent: Description of when AI should suggest this label`.
The description should be comprehensive and detailed, indicating when to add the desired label. - + +![Add native custom labels](https://codium.ai/images/pr_agent/add_native_custom_labels.png){width=880} c. Now the custom labels will be included in the `generate_labels` tool. diff --git a/docs/docs/tools/custom_suggestions.md b/docs/docs/tools/custom_suggestions.md index 0b19ecef..85720c11 100644 --- a/docs/docs/tools/custom_suggestions.md +++ b/docs/docs/tools/custom_suggestions.md @@ -43,10 +43,9 @@ The instructions above are just an example. We want to emphasize that the prompt Results obtained with the prompt above: - - - - +![Custom suggestions prompt](https://codium.ai/images/pr_agent/custom_suggestions_prompt.png){width=512} +→ +![Custom suggestions results](https://codium.ai/images/pr_agent/custom_suggestions_result.png){width=768} ## Configuration options diff --git a/docs/docs/tools/describe.md b/docs/docs/tools/describe.md index cf7ccdfb..e0de5153 100644 --- a/docs/docs/tools/describe.md +++ b/docs/docs/tools/describe.md @@ -7,17 +7,9 @@ The tool can be triggered automatically every time a new PR is [opened](../usage ``` For example: - - - - - +![Describe comment](https://codium.ai/images/pr_agent/describe_comment.png){width=512} - - - - - +![Describe New](https://codium.ai/images/pr_agent/describe_new.png){width=512} @@ -57,29 +49,17 @@ This feature enables you to copy the `changes walkthrough` table to the "Files c To copy the `changes walkthrough` table to the "Files changed" tab, you can click on the checkbox that appears PR Description status message below the main PR Description: - - - - - +![Add table checkbox](https://codium.ai/images/pr_agent/add_table_checkbox.png){width=512} If you prefer to have the file summaries appear in the "Files changed" tab on every PR, change the `pr_description.inline_file_summary` parameter in the configuration file, possible values are: - `'table'`: File changes walkthrough table will be displayed on the top of the "Files changed" tab, in addition to the "Conversation" tab. - - - - - +![Diffview table](https://codium.ai/images/pr_agent/diffview-table.png){width=512} - `true`: A collapsable file comment with changes title and a changes summary for each file in the PR. - - - - - +![Diffview changes](https://codium.ai/images/pr_agent/diffview_changes.png){width=512} - `false` (`default`): File changes walkthrough will be added only to the "Conversation" tab. @@ -99,11 +79,7 @@ Now add/edit the custom labels. they should be formatted as follows: * Description: Start the description of with prefix `pr_agent:`, for example: `pr_agent: Description of when AI should suggest this label`.
The description should be comprehensive and detailed, indicating when to add the desired label. For example: - - - - - +![Add native custom labels](https://codium.ai/images/pr_agent/add_native_custom_labels.png){width=768} ### Markers template @@ -126,19 +102,12 @@ 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. - - - - - +![Describe markers before](https://codium.ai/images/pr_agent/describe_markers_before.png){width=512} → - - - - - +![Describe markers after](https://codium.ai/images/pr_agent/describe_markers_after.png){width=512} + **Configuration params**: diff --git a/docs/docs/tools/documentation.md b/docs/docs/tools/documentation.md index b3fb0ba4..4318ee45 100644 --- a/docs/docs/tools/documentation.md +++ b/docs/docs/tools/documentation.md @@ -7,11 +7,11 @@ It can be invoked manually by commenting on any PR: ``` For example: - +![Docs command](https://codium.ai/images/pr_agent/docs_command.png){width=768} - +![Docs component](https://codium.ai/images/pr_agent/docs_components.png){width=768} - +![Docs single component](https://codium.ai/images/pr_agent/docs_single_component.png){width=768} ## 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`. diff --git a/docs/docs/tools/improve.md b/docs/docs/tools/improve.md index f5808139..40945775 100644 --- a/docs/docs/tools/improve.md +++ b/docs/docs/tools/improve.md @@ -9,20 +9,12 @@ The tool can be triggered automatically every time a new PR is [opened](../usage The code suggestions can be presented as a single comment (via `pr_code_suggestions.summarize=true`): - - - - - - +![code suggestions as comment](https://codium.ai/images/pr_agent/code_suggestions_as_comment.png){width=512} Or as a separate commitable code comment for each suggestion: - - - - - +![imporove](https://codium.ai/images/pr_agent/improve.png){width=512} + 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. diff --git a/docs/docs/tools/review.md b/docs/docs/tools/review.md index a8bd5a66..32314b5c 100644 --- a/docs/docs/tools/review.md +++ b/docs/docs/tools/review.md @@ -6,17 +6,9 @@ The tool can be triggered automatically every time a new PR is [opened](../usage ``` For example: - - - - - +![review comment](https://codium.ai/images/pr_agent/review_comment.png){width=512} - - - - - +![review](https://codium.ai/images/pr_agent/review_comment.png){width=512} ## Configuration options @@ -70,11 +62,7 @@ For invoking the incremental mode, the following command can be used: ``` Note that the incremental mode is only available for GitHub. - - - - - +![incremental review](https://codium.ai/images/pr_agent/incremental_review_2.png){width=512} ### PR Reflection @@ -84,23 +72,11 @@ By invoking: ``` The tool will first ask the author questions about the PR, and will guide the review based on their answers. - - - - - +![reflection questions](https://codium.ai/images/pr_agent/reflection_questions.png){width=512} - - - - - +![reflection answers](https://codium.ai/images/pr_agent/reflection_answers.png){width=512} - - - - - +![reflection insights](https://codium.ai/images/pr_agent/reflection_insights.png){width=512} ## Usage Tips diff --git a/docs/docs/tools/similar_code.md b/docs/docs/tools/similar_code.md index a35111d7..5f2af5c8 100644 --- a/docs/docs/tools/similar_code.md +++ b/docs/docs/tools/similar_code.md @@ -5,7 +5,8 @@ For example: `Global Search` for a method called `chat_completion`: - +![similar code global](https://codium.ai/images/pr_agent/similar_code_global2.png){width=768} + PR-Agent will examine the code component and will extract the most relevant keywords to search for similar code: @@ -16,11 +17,12 @@ PR-Agent will examine the code component and will extract the most relevant keyw Search result link example: - +![code search result single](https://codium.ai/images/pr_agent/code_search_result_single.png){width=768} + `Organization Search`: - +![similar code org](https://codium.ai/images/pr_agent/similar_code_org.png){width=768} ## How to use @@ -47,11 +49,11 @@ 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. - +![analyze similar](https://codium.ai/images/pr_agent/analyze_similar.png){width=768} 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. - +![similar code global](https://codium.ai/images/pr_agent/similar_code_global.png){width=768} ## Configuration options diff --git a/docs/docs/tools/similar_issues.md b/docs/docs/tools/similar_issues.md index 3d492c0a..239b4e90 100644 --- a/docs/docs/tools/similar_issues.md +++ b/docs/docs/tools/similar_issues.md @@ -6,11 +6,11 @@ It can be invoked manually by commenting on any PR: ``` For example: - +![similar_issue_original_issue](https://codium.ai/images/pr_agent/similar_issue_original_issue.png){width=768} - +![similar_issue_comment](https://codium.ai/images/pr_agent/similar_issue_comment.png){width=768} - +![similar_issue](https://codium.ai/images/pr_agent/similar_issue.png){width=768} Note that to perform retrieval, the `similar_issue` tool indexes all the repo previous issues (once). diff --git a/docs/docs/tools/test.md b/docs/docs/tools/test.md index a45f6faf..6c1901b1 100644 --- a/docs/docs/tools/test.md +++ b/docs/docs/tools/test.md @@ -10,11 +10,11 @@ To get a list of the components that changed in the PR, use the [`analyze`](./an An example [result](https://github.com/Codium-ai/pr-agent/pull/598#issuecomment-1913679429): - +![test1](https://codium.ai/images/pr_agent/test1.png){width=704} - +![test2](https://codium.ai/images/pr_agent/test2.png){width=768} - +![test3](https://codium.ai/images/pr_agent/test3.png){width=768} **Notes** - Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript. diff --git a/docs/docs/tools/update_changelog.md b/docs/docs/tools/update_changelog.md index 4c423a3e..4f4de235 100644 --- a/docs/docs/tools/update_changelog.md +++ b/docs/docs/tools/update_changelog.md @@ -6,10 +6,9 @@ It can be invoked manually by commenting on any PR: ``` For example: - - - +![update_changelog_comment](https://codium.ai/images/pr_agent/update_changelog_comment.png){width=768} +![update_changelog](https://codium.ai/images/pr_agent/update_changelog.png){width=768} ## Configuration options diff --git a/docs/docs/usage-guide/configuration_options.md b/docs/docs/usage-guide/configuration_options.md index 9b15babb..1d56baa2 100644 --- a/docs/docs/usage-guide/configuration_options.md +++ b/docs/docs/usage-guide/configuration_options.md @@ -16,7 +16,7 @@ In terms of precedence, wiki configurations will override local configurations, 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**. - +![wiki_configuration](https://codium.ai/images/pr_agent/wiki_configuration.png){width=512} 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: diff --git a/docs/docs/usage-guide/mail_notifications.md b/docs/docs/usage-guide/mail_notifications.md index 1e5b2e8a..82dc10a0 100644 --- a/docs/docs/usage-guide/mail_notifications.md +++ b/docs/docs/usage-guide/mail_notifications.md @@ -2,8 +2,8 @@ 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: - +![notifications](https://codium.ai/images/pr_agent/notifications.png){width=512} 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 +![filter_mail_notifications](https://codium.ai/images/pr_agent/filter_mail_notifications.png){width=512} diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index c3e10abd..bcf39b36 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -77,6 +77,7 @@ theme: plugins: - social - search + - glightbox extra: generator: false @@ -112,6 +113,7 @@ markdown_extensions: - pymdownx.details - pymdownx.superfences - pymdownx.mark + - md_in_html - attr_list - pymdownx.emoji: emoji_index: !!python/name:material.extensions.emoji.twemoji From 2f823fb4e1091dc24c3c3ebaf77051336d42a45e Mon Sep 17 00:00:00 2001 From: Almog Lavi Date: Tue, 26 Mar 2024 23:06:07 +0200 Subject: [PATCH 02/44] update deprecated plugin --- docs/mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index bcf39b36..b7e6864d 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -117,7 +117,7 @@ markdown_extensions: - attr_list - pymdownx.emoji: emoji_index: !!python/name:material.extensions.emoji.twemoji - emoji_generator: !!python/name:materialx.emoji.to_svg + emoji_generator: !!python/name:material.extensions.emoji.to_svg - toc: title: On this page toc_depth: 3 From c97702982c282bae5138e3b61ca0f0a187e56f0f Mon Sep 17 00:00:00 2001 From: Almog Lavi Date: Tue, 26 Mar 2024 23:09:37 +0200 Subject: [PATCH 03/44] fix image --- docs/docs/tools/review.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/tools/review.md b/docs/docs/tools/review.md index 32314b5c..41ef75ed 100644 --- a/docs/docs/tools/review.md +++ b/docs/docs/tools/review.md @@ -8,7 +8,7 @@ For example: ![review comment](https://codium.ai/images/pr_agent/review_comment.png){width=512} -![review](https://codium.ai/images/pr_agent/review_comment.png){width=512} +![review](https://codium.ai/images/pr_agent/review3.png){width=512} ## Configuration options From d250cb46f4b275a3e9126a95560fc7860b820ffa Mon Sep 17 00:00:00 2001 From: Diogo Simoes Date: Tue, 26 Mar 2024 22:28:19 +0000 Subject: [PATCH 04/44] fix: missing requirements.txt on lambda dockerfile --- docker/Dockerfile.lambda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile.lambda b/docker/Dockerfile.lambda index 59e78a54..058f84d1 100644 --- a/docker/Dockerfile.lambda +++ b/docker/Dockerfile.lambda @@ -4,7 +4,7 @@ RUN yum update -y && \ yum install -y gcc python3-devel && \ yum clean all -ADD pyproject.toml . +ADD pyproject.toml requirements.txt . RUN pip install . && rm pyproject.toml RUN pip install mangum==0.17.0 COPY pr_agent/ ${LAMBDA_TASK_ROOT}/pr_agent/ From 0241fe5c131242a94e36add32b091d83e53f347d Mon Sep 17 00:00:00 2001 From: Diogo Simoes Date: Tue, 26 Mar 2024 23:58:07 +0000 Subject: [PATCH 05/44] fix: missing git binary on lambda dockerfile --- docker/Dockerfile.lambda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile.lambda b/docker/Dockerfile.lambda index 058f84d1..54aa1374 100644 --- a/docker/Dockerfile.lambda +++ b/docker/Dockerfile.lambda @@ -1,7 +1,7 @@ FROM public.ecr.aws/lambda/python:3.10 RUN yum update -y && \ - yum install -y gcc python3-devel && \ + yum install -y gcc python3-devel git && \ yum clean all ADD pyproject.toml requirements.txt . From fa889fbb064d2f36e0bc2fdcae79a4718a3558af Mon Sep 17 00:00:00 2001 From: idubnori Date: Wed, 27 Mar 2024 12:00:24 +0900 Subject: [PATCH 06/44] docs: add pull request event types --- docs/docs/installation/github.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/installation/github.md b/docs/docs/installation/github.md index b405b020..f19590f1 100644 --- a/docs/docs/installation/github.md +++ b/docs/docs/installation/github.md @@ -7,6 +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: jobs: pr_agent_job: @@ -28,6 +29,7 @@ jobs: ```yaml on: pull_request: + types: [opened,reopened,ready_for_review,review_requested] issue_comment: jobs: From 493f73f1ce5e0625026cd0ebbcb0bac098990b62 Mon Sep 17 00:00:00 2001 From: idubnori Date: Wed, 27 Mar 2024 12:03:27 +0900 Subject: [PATCH 07/44] chore: add logging the reason not execute --- pr_agent/servers/github_action_runner.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pr_agent/servers/github_action_runner.py b/pr_agent/servers/github_action_runner.py index d4278156..5382d051 100644 --- a/pr_agent/servers/github_action_runner.py +++ b/pr_agent/servers/github_action_runner.py @@ -101,6 +101,8 @@ async def run_action(): await PRReviewer(pr_url).run() if auto_improve is None or is_true(auto_improve): await PRCodeSuggestions(pr_url).run() + else: + get_logger().info(f"Skipping action: {action}") # Handle issue comment event elif GITHUB_EVENT_NAME == "issue_comment" or GITHUB_EVENT_NAME == "pull_request_review_comment": From 82d9c77489562997126efe10da4741920bb007d0 Mon Sep 17 00:00:00 2001 From: Tal Date: Wed, 27 Mar 2024 12:40:47 +0200 Subject: [PATCH 08/44] Update github.md --- docs/docs/installation/github.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/docs/installation/github.md b/docs/docs/installation/github.md index b405b020..afe15517 100644 --- a/docs/docs/installation/github.md +++ b/docs/docs/installation/github.md @@ -159,6 +159,9 @@ cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets.toml ## Deploy as a Lambda Function +Note that since AWS Lambda env vars cannot have "." in the name, you can replace each "." in an env variable with "__".
+For example: `GITHUB.WEBHOOK_SECRET` --> `GITHUB__WEBHOOK_SECRET` + 1. Follow steps 1-5 from [here](#run-as-a-github-app). 2. Build a docker image that can be used as a lambda function ```shell @@ -246,4 +249,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 -``` \ No newline at end of file +``` From a8bee89ae969d581a6a7b692c3a2712455eac2b5 Mon Sep 17 00:00:00 2001 From: Tal Date: Wed, 27 Mar 2024 13:00:16 +0200 Subject: [PATCH 09/44] Update custom.css --- docs/docs/css/custom.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/css/custom.css b/docs/docs/css/custom.css index e79736b4..8b0879a0 100644 --- a/docs/docs/css/custom.css +++ b/docs/docs/css/custom.css @@ -21,7 +21,7 @@ border-width: 1px; border-style: solid; border-color: black; - outline-width: 3px; + outline-width: 1px; outline-style: solid; outline-color: darkgray; - } \ No newline at end of file + } From 020a29ebb8c3794b0768ef3ab13ce19b69fd00ef Mon Sep 17 00:00:00 2001 From: idubnori Date: Wed, 27 Mar 2024 20:53:46 +0900 Subject: [PATCH 10/44] docs: optimize condition of github actions --- docs/docs/installation/github.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/docs/installation/github.md b/docs/docs/installation/github.md index f19590f1..edaaf24f 100644 --- a/docs/docs/installation/github.md +++ b/docs/docs/installation/github.md @@ -7,10 +7,11 @@ 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] + types: [opened, reopened, ready_for_review] issue_comment: jobs: pr_agent_job: + if: ${{ github.event.sender.type != 'Bot' }} runs-on: ubuntu-latest permissions: issues: write @@ -29,11 +30,12 @@ jobs: ```yaml on: pull_request: - types: [opened,reopened,ready_for_review,review_requested] + types: [opened, reopened, ready_for_review] issue_comment: jobs: pr_agent_job: + if: ${{ github.event.sender.type != 'Bot' }} runs-on: ubuntu-latest permissions: issues: write From 79bdb9a69f3dd732142053fea6065d3504a8848f Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 27 Mar 2024 19:56:27 +0200 Subject: [PATCH 11/44] bugfix: validate output publishing with progress condition in pr_code_suggestions --- pr_agent/tools/pr_code_suggestions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index aa119f2a..926edf00 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -76,7 +76,7 @@ class PRCodeSuggestions: relevant_configs = {'pr_code_suggestions': dict(get_settings().pr_code_suggestions), 'config': dict(get_settings().config)} get_logger().debug("Relevant configs", artifacts=relevant_configs) - if get_settings().config.publish_output: + if get_settings().config.publish_output and get_settings().config.publish_output_progress: if self.git_provider.is_supported("gfm_markdown"): self.progress_response = self.git_provider.publish_comment(self.progress) else: From aae6869964000578ccecc5e4ee9ee5919f06b7c8 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 28 Mar 2024 09:37:29 +0200 Subject: [PATCH 12/44] docs: Update PR-Agent usage guide --- docs/docs/installation/github.md | 24 ++++--------------- .../docs/usage-guide/automations_and_usage.md | 13 +++++----- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/docs/docs/installation/github.md b/docs/docs/installation/github.md index 2e5a2824..4f7be99a 100644 --- a/docs/docs/installation/github.md +++ b/docs/docs/installation/github.md @@ -26,29 +26,14 @@ jobs: OPENAI_KEY: ${{ secrets.OPENAI_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` -** if you want to pin your action to a specific release (v0.7 for example) for stability reasons, use: +** if you want to pin your action to a specific release (v2.0 for example) for stability reasons, use: ```yaml -on: - pull_request: - types: [opened, reopened, ready_for_review] - issue_comment: - -jobs: - pr_agent_job: - if: ${{ github.event.sender.type != 'Bot' }} - runs-on: ubuntu-latest - permissions: - issues: write - pull-requests: write - contents: write - name: Run pr agent on every pull request, respond to user comments +... steps: - name: PR Agent action step id: pragent - uses: Codium-ai/pr-agent@v0.7 - env: - OPENAI_KEY: ${{ secrets.OPENAI_KEY }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: Codium-ai/pr-agent@v2.0 +... ``` 2) Add the following secret to your repository under `Settings > Secrets and variables > Actions > New repository secret > Add secret`: @@ -70,6 +55,7 @@ When you open your next PR, you should see a comment from `github-actions` bot w PR_REVIEWER.REQUIRE_TESTS_REVIEW: "false" # Disable tests review PR_CODE_SUGGESTIONS.NUM_CODE_SUGGESTIONS: 6 # Increase number of code suggestions ``` +See detailed usage instructions in the [USAGE GUIDE](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-action) --- diff --git a/docs/docs/usage-guide/automations_and_usage.md b/docs/docs/usage-guide/automations_and_usage.md index d20516fd..f718e9bd 100644 --- a/docs/docs/usage-guide/automations_and_usage.md +++ b/docs/docs/usage-guide/automations_and_usage.md @@ -59,7 +59,7 @@ The configuration parameter `pr_commands` defines the list of tools that will be [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", + "/review --pr_reviewer.num_code_suggestions=0", "/improve", ] ``` @@ -99,13 +99,13 @@ The configuration parameter `push_commands` defines the list of tools that will 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", + "/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. ## GitHub Action -`GitHub Action` is a different way to trigger PR-Agent tools, and uses a different configuration mechanism than `GitHub App`. +`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 @@ -119,13 +119,14 @@ Specifically, start by setting the following environment variables: `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. +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` [configuration file](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/#global-configuration-file) in the root of your repo -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: +For example, you can set an environment variable: `pr_description.publish_labels=false`, or add a `.pr_agent.toml` file with the following content: ``` [pr_description] -add_original_user_description = false +publish_labels = false ``` +to prevent PR-Agent from publishing labels when running the `describe` tool. ## 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: From 7e84acc63cd1d382212b1ab9d45c36ce9e3f46ec Mon Sep 17 00:00:00 2001 From: mrT23 Date: Fri, 29 Mar 2024 13:34:23 +0300 Subject: [PATCH 13/44] docs: Refine project description and reorganize documentation links in README --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0f107870..0d75489c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@
-Making pull requests less painful with an AI agent +CodiumAI PR-Agent aims to help efficiently review and handle pull requests, by providing AI feedbacks and suggestions [![GitHub license](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/Codium-ai/pr-agent/blob/main/LICENSE) @@ -21,6 +21,14 @@ Making pull requests less painful with an AI agent +### [Documentation](https://pr-agent-docs.codium.ai/) +- See the [Installation Guide](https://pr-agent-docs.codium.ai/installation/) for instructions on installing PR-Agent on different platforms. + +- See the [Usage Guide](https://pr-agent-docs.codium.ai/usage-guide/) for instructions on running PR-Agent tools via different interfaces, such as CLI, PR Comments, or by automatically triggering them when a new PR is opened. + +- See the [Tools Guide](https://pr-agent-docs.codium.ai/tools/) for a detailed description of the different tools, and the available configurations for each tool. + + ## Table of Contents - [News and Updates](#news-and-updates) - [Overview](#overview) @@ -63,14 +71,6 @@ If set to true, the tool will add a section that checks if the PR contains sever ## Overview
-CodiumAI PR-Agent aims to help efficiently review and handle pull requests, by providing AI feedbacks and suggestions - -- 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](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](https://pr-agent-docs.codium.ai/tools/) for a detailed description of the different tools. - Supported commands per platform: | | | GitHub | Gitlab | Bitbucket | Azure DevOps | From c3b3651769c8b42abf82dacf69cca9c988473c28 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 31 Mar 2024 11:43:00 +0300 Subject: [PATCH 14/44] refine help --- pr_agent/tools/pr_help_message.py | 47 ++++++++++++++++++------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/pr_agent/tools/pr_help_message.py b/pr_agent/tools/pr_help_message.py index f7a5ff13..df2698cf 100644 --- a/pr_agent/tools/pr_help_message.py +++ b/pr_agent/tools/pr_help_message.py @@ -27,12 +27,13 @@ class PRHelpMessage: tool_names.append(f"[DESCRIBE]({base_path}/describe/)") tool_names.append(f"[REVIEW]({base_path}/review/)") tool_names.append(f"[IMPROVE]({base_path}/improve/)") - tool_names.append(f"[ANALYZE]({base_path}/analyze/) 💎") tool_names.append(f"[UPDATE CHANGELOG]({base_path}/update_changelog/)") - tool_names.append(f"[ADD DOCUMENTATION]({base_path}/documentation/) 💎") - tool_names.append(f"[ASK]({base_path}/ask/)") - tool_names.append(f"[GENERATE CUSTOM LABELS]({base_path}/custom_labels/)") + tool_names.append(f"[ADD DOCS]({base_path}/documentation/) 💎") tool_names.append(f"[TEST]({base_path}/test/) 💎") + tool_names.append(f"[IMPROVE COMPONENT]({base_path}/improve_component/) 💎") + tool_names.append(f"[ANALYZE]({base_path}/analyze/) 💎") + tool_names.append(f"[ASK]({base_path}/ask/)") + tool_names.append(f"[GENERATE CUSTOM LABELS]({base_path}/custom_labels/) 💎") tool_names.append(f"[CI FEEDBACK]({base_path}/ci_feedback/) 💎") tool_names.append(f"[CUSTOM SUGGESTIONS]({base_path}/custom_suggestions/) 💎") tool_names.append(f"[SIMILAR ISSUE]({base_path}/similar_issues/)") @@ -40,27 +41,29 @@ class PRHelpMessage: descriptions = [] descriptions.append("Generates PR description - title, type, summary, code walkthrough and labels") descriptions.append("Adjustable feedback about the PR, possible issues, security concerns, review effort and more") - descriptions.append("Code suggestions for improving the PR.") - descriptions.append("Identifies code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component.") - descriptions.append("Automatically updates the changelog.") - descriptions.append("Generates documentation to methods/functions/classes that changed in the PR.") - descriptions.append("Answering free-text questions about the PR.") + descriptions.append("Code suggestions for improving the PR") + descriptions.append("Automatically updates the changelog") + descriptions.append("Generates documentation to methods/functions/classes that changed in the PR") + descriptions.append("Generates unit tests for a specific component, based on the PR code change") + descriptions.append("Code suggestions for a specific component that changed in the PR") + descriptions.append("Identifies code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component") + descriptions.append("Answering free-text questions about the PR") descriptions.append("Generates custom labels for the PR, based on specific guidelines defined by the user") - descriptions.append("Generates unit tests for a specific component, based on the PR code change.") - descriptions.append("Generates feedback and analysis for a failed CI job.") - descriptions.append("Generates custom suggestions for improving the PR code, based on specific guidelines defined by the user.") - descriptions.append("Automatically retrieves and presents similar issues.") + descriptions.append("Generates feedback and analysis for a failed CI job") + descriptions.append("Generates custom suggestions for improving the PR code, based only on specific guidelines defined by the user") + descriptions.append("Automatically retrieves and presents similar issues") commands =[] commands.append("`/describe`") commands.append("`/review`") commands.append("`/improve`") - commands.append("`/analyze`") commands.append("`/update_changelog`") commands.append("`/add_docs`") + commands.append("`/test`") + commands.append("`/improve_component`") + commands.append("`/analyze`") commands.append("`/ask`") commands.append("`/generate_labels`") - commands.append("`/test`") commands.append("`/checks`") commands.append("`/custom_suggestions`") commands.append("`/similar_issue`") @@ -69,9 +72,13 @@ class PRHelpMessage: checkbox_list.append(" - [ ] Run ") checkbox_list.append(" - [ ] Run ") checkbox_list.append(" - [ ] Run ") - checkbox_list.append(" - [ ] Run ") checkbox_list.append(" - [ ] Run ") checkbox_list.append(" - [ ] Run ") + checkbox_list.append(" - [ ] Run ") + checkbox_list.append(" - [ ] Run ") + checkbox_list.append(" - [ ] Run ") + checkbox_list.append("[*]") + checkbox_list.append("[*]") checkbox_list.append("[*]") checkbox_list.append("[*]") checkbox_list.append("[*]") @@ -80,16 +87,16 @@ class PRHelpMessage: checkbox_list.append("[*]") if isinstance(self.git_provider, GithubProvider): - pr_comment += f"" + pr_comment += f"
ToolDescriptionInvoke Interactively :gem:
" for i in range(len(tool_names)): - pr_comment += f"\n\n\n" + pr_comment += f"\n\n\n" pr_comment += "
ToolDescriptionTrigger Interactively :gem:
\n\n{tool_names[i]}{descriptions[i]}\n\n{checkbox_list[i]}\n
\n\n{tool_names[i]}{descriptions[i]}\n\n{checkbox_list[i]}\n
\n\n" pr_comment += f"""\n\n(1) Note that each tool be [triggered automatically](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools-for-pr-actions) when a new PR is opened, or called manually by [commenting on a PR](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#online-usage).""" pr_comment += f"""\n\n(2) Tools marked with [*] require additional parameters to be passed. For example, to invoke the `/ask` tool, you need to comment on a PR: `/ask ""`. See the relevant documentation for each tool for more details.""" else: - pr_comment += f"" + pr_comment += f"
ToolCommandDescription
" for i in range(len(tool_names)): - pr_comment += f"\n" + pr_comment += f"\n" pr_comment += "
ToolCommandDescription
\n\n{tool_names[i]}{commands[i]}{descriptions[i]}
\n\n{tool_names[i]}{commands[i]}{descriptions[i]}
\n\n" pr_comment += f"""\n\nNote that each tool be [invoked automatically](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/) when a new PR is opened, or called manually by [commenting on a PR](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#online-usage).""" if get_settings().config.publish_output: From 8bda365636576c518e2e13f2f2107d483c8c5a62 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 31 Mar 2024 12:13:25 +0300 Subject: [PATCH 15/44] docs: Add "Improve Component" tool documentation and update related guides --- docs/docs/tools/improve_component.md | 24 +++++++++++++++++++++++ docs/docs/tools/index.md | 29 ++++++++++++++-------------- docs/docs/tools/test.md | 2 +- docs/mkdocs.yml | 1 + pr_agent/settings/configuration.toml | 5 +++++ 5 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 docs/docs/tools/improve_component.md diff --git a/docs/docs/tools/improve_component.md b/docs/docs/tools/improve_component.md new file mode 100644 index 00000000..d7e0e787 --- /dev/null +++ b/docs/docs/tools/improve_component.md @@ -0,0 +1,24 @@ +## Overview +The `improve_component` tool generates code suggestions for a specific code component that changed in the PR. +it can be invoked manually by commenting on any PR: +``` +/improve_component component_name +``` + +To get a list of the components that changed in the PR and choose the relevant component interactively, use the [`analyze`](./analyze.md) tool. + + +Example result: + +![improve_component1](https://codium.ai/images/pr_agent/improve_component1.png){width=768} + +![improve_component2](https://codium.ai/images/pr_agent/improve_component2.png){width=768} + +**Notes** +- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript. + +## Configuration options +- `num_code_suggestions`: number of code suggestions to provide. Default is 4 +- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on ...". +- `file`: in case there are several components with the same name, you can specify the relevant file. +- `class_name`: in case there are several methods with the same name in the same file, you can specify the relevant class name. \ No newline at end of file diff --git a/docs/docs/tools/index.md b/docs/docs/tools/index.md index bcd9ed9d..b77097b3 100644 --- a/docs/docs/tools/index.md +++ b/docs/docs/tools/index.md @@ -2,19 +2,20 @@ 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 | +| 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 | +| **💎 [Improve Component (`/improve_component component_name`](./improve_component.md))** | Generates code suggestions for a specific code component that changed in the PR | +| **💎 [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/docs/tools/test.md b/docs/docs/tools/test.md index 6c1901b1..4cb46bac 100644 --- a/docs/docs/tools/test.md +++ b/docs/docs/tools/test.md @@ -5,7 +5,7 @@ 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`](./analyze.md) tool. +To get a list of the components that changed in the PR and choose the relevant component interactively, use the [`analyze`](./analyze.md) tool. An example [result](https://github.com/Codium-ai/pr-agent/pull/598#issuecomment-1913679429): diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index b7e6864d..e67712e1 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -27,6 +27,7 @@ nav: - Similar Issues: 'tools/similar_issues.md' - 💎 Analyze: 'tools/analyze.md' - 💎 Test: 'tools/test.md' + - 💎 Improve Component: 'tools/improve_component.md' - 💎 Documentation: 'tools/documentation.md' - 💎 Custom Labels: 'tools/custom_labels.md' - 💎 Custom Suggestions: 'tools/custom_suggestions.md' diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 837c71d3..765c8342 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -110,6 +110,11 @@ file = "" # in case there are several components with the same name class_name = "" # in case there are several methods with the same name in the same file, you can specify the relevant class name enable_help_text=true +[pr_improve_component] # /improve_component # +num_code_suggestions=4 +extra_instructions = "" +file = "" # in case there are several components with the same name, you can specify the relevant file +class_name = "" [checks] # /checks (pro feature) # enable_auto_checks_feedback=true From ce47adf986593bff404ae06b613c5909fadab72f Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 31 Mar 2024 12:15:29 +0300 Subject: [PATCH 16/44] C# --- docs/docs/tools/analyze.md | 2 +- docs/docs/tools/documentation.md | 2 +- docs/docs/tools/improve_component.md | 2 +- docs/docs/tools/test.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/tools/analyze.md b/docs/docs/tools/analyze.md index 3b7c6d58..0255e759 100644 --- a/docs/docs/tools/analyze.md +++ b/docs/docs/tools/analyze.md @@ -19,4 +19,4 @@ An example [result](https://github.com/Codium-ai/pr-agent/pull/546#issuecomment- **Notes** -- Language that are currently supported: Python, Java, C++, JavaScript, TypeScript. \ No newline at end of file +- Language that are currently supported: Python, Java, C++, JavaScript, TypeScript, C#. \ No newline at end of file diff --git a/docs/docs/tools/documentation.md b/docs/docs/tools/documentation.md index 4318ee45..9c56386f 100644 --- a/docs/docs/tools/documentation.md +++ b/docs/docs/tools/documentation.md @@ -19,6 +19,6 @@ For example: **Notes** -- Language that are currently fully supported: Python, Java, C++, JavaScript, TypeScript. +- Language that are currently fully supported: Python, Java, C++, JavaScript, TypeScript, C#. - 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. \ No newline at end of file diff --git a/docs/docs/tools/improve_component.md b/docs/docs/tools/improve_component.md index d7e0e787..321114b4 100644 --- a/docs/docs/tools/improve_component.md +++ b/docs/docs/tools/improve_component.md @@ -15,7 +15,7 @@ Example result: ![improve_component2](https://codium.ai/images/pr_agent/improve_component2.png){width=768} **Notes** -- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript. +- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript, C#. ## Configuration options - `num_code_suggestions`: number of code suggestions to provide. Default is 4 diff --git a/docs/docs/tools/test.md b/docs/docs/tools/test.md index 4cb46bac..52e447ce 100644 --- a/docs/docs/tools/test.md +++ b/docs/docs/tools/test.md @@ -17,7 +17,7 @@ An example [result](https://github.com/Codium-ai/pr-agent/pull/598#issuecomment- ![test3](https://codium.ai/images/pr_agent/test3.png){width=768} **Notes** -- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript. +- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript, C#. ## Configuration options From b86b37e6a2bfd8104c786420e9239568f765190a Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Mon, 1 Apr 2024 09:54:59 +0300 Subject: [PATCH 17/44] analytics --- docs/overrides/main.html | 10 ++++++++++ .../partials/integrations/analytics/custom.html | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 docs/overrides/main.html create mode 100644 docs/overrides/partials/integrations/analytics/custom.html diff --git a/docs/overrides/main.html b/docs/overrides/main.html new file mode 100644 index 00000000..93a67950 --- /dev/null +++ b/docs/overrides/main.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% block scripts %} + {{ super() }} + + + + +{% endblock %} \ No newline at end of file diff --git a/docs/overrides/partials/integrations/analytics/custom.html b/docs/overrides/partials/integrations/analytics/custom.html new file mode 100644 index 00000000..9a0785d2 --- /dev/null +++ b/docs/overrides/partials/integrations/analytics/custom.html @@ -0,0 +1,7 @@ + + + \ No newline at end of file From a53ba4596efffa7beb2cb3776ce81ac29b77aed5 Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Mon, 1 Apr 2024 10:03:36 +0300 Subject: [PATCH 18/44] fix custom analytics --- docs/mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index e67712e1..c045d8e4 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -96,7 +96,7 @@ extra: - icon: fontawesome/brands/instagram link: https://www.instagram.com/codiumai/ analytics: - provider: google + provider: custom property: ${{ secrets.GOOGLE_ANALYTICS_ID }} extra_css: From 3d86430f18f8d769db66413be3b7ce6c28bb960e Mon Sep 17 00:00:00 2001 From: Tal Date: Mon, 1 Apr 2024 18:46:08 +0300 Subject: [PATCH 19/44] Update automations_and_usage.md --- docs/docs/usage-guide/automations_and_usage.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/usage-guide/automations_and_usage.md b/docs/docs/usage-guide/automations_and_usage.md index f718e9bd..f32863eb 100644 --- a/docs/docs/usage-guide/automations_and_usage.md +++ b/docs/docs/usage-guide/automations_and_usage.md @@ -154,11 +154,11 @@ 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: +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] ``` +[bitbucket_app] pr_commands = [ "/review --pr_reviewer.num_code_suggestions=0", "/improve --pr_code_suggestions.summarize=false", @@ -197,4 +197,4 @@ pr_commands = [ "/review --pr_reviewer.num_code_suggestions=0", "/improve", ] -``` \ No newline at end of file +``` From 27cdd419e57b78c37508dcbf3fdee1b9a0bae78f Mon Sep 17 00:00:00 2001 From: Tal Date: Mon, 1 Apr 2024 18:56:36 +0300 Subject: [PATCH 20/44] Update index.md --- docs/docs/index.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/docs/index.md b/docs/docs/index.md index 246680df..3919feae 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -19,20 +19,19 @@ PR-Agent offers extensive pull request functionalities across various git provid | | ⮑ [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"} 💎 | ✅ | ✅ | ✅ | ✅ | +| | ⮑ [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"} 💎 | ✅ | ✅ | ✅ | ✅ | +| | [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"} 💎 | ✅ | ✅ | ✅ | ✅ | +| | [Analyze PR Components](./tools/analyze.md){:target="_blank"} 💎 | ✅ | ✅ | | ✅ | | | | | | | ️ | | USAGE | CLI | ✅ | ✅ | ✅ | ✅ | -| | App / webhook | ✅ | ✅ | | ✅ | -| | Tagging bot | ✅ | | | ✅ | +| | App / webhook | ✅ | ✅ | ✅ | ✅ | | | Actions | ✅ | | | ️ | | | | | | | | CORE | PR compression | ✅ | ✅ | ✅ | ✅ | From 501b0595759c47549ae3fc155ad79b5a29bf4835 Mon Sep 17 00:00:00 2001 From: gregoryboue Date: Tue, 2 Apr 2024 11:01:45 +0200 Subject: [PATCH 21/44] feat: allows ollama usage Fix https://github.com/Codium-ai/pr-agent/issues/657 --- pr_agent/algo/ai_handlers/litellm_ai_handler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pr_agent/algo/ai_handlers/litellm_ai_handler.py b/pr_agent/algo/ai_handlers/litellm_ai_handler.py index ce4d1db0..d07542f6 100644 --- a/pr_agent/algo/ai_handlers/litellm_ai_handler.py +++ b/pr_agent/algo/ai_handlers/litellm_ai_handler.py @@ -61,6 +61,9 @@ class LiteLLMAIHandler(BaseAiHandler): if get_settings().get("HUGGINGFACE.API_BASE", None) and 'huggingface' in get_settings().config.model: litellm.api_base = get_settings().huggingface.api_base self.api_base = get_settings().huggingface.api_base + if get_settings().get("OLLAMA.API_BASE", None) : + litellm.api_base = get_settings().ollama.api_base + self.api_base = get_settings().ollama.api_base if get_settings().get("HUGGINGFACE.REPITITION_PENALTY", None): self.repetition_penalty = float(get_settings().huggingface.repetition_penalty) if get_settings().get("VERTEXAI.VERTEX_PROJECT", None): @@ -150,4 +153,4 @@ class LiteLLMAIHandler(BaseAiHandler): if get_settings().config.verbosity_level >= 2: get_logger().info(f"\nAI response:\n{resp}") - return resp, finish_reason \ No newline at end of file + return resp, finish_reason From 3ebb72e3f12b3fb4404513f49ce1c908e4d1f652 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Tue, 2 Apr 2024 17:52:34 +0300 Subject: [PATCH 22/44] feat: add persistent comment option for PR descriptions --- pr_agent/settings/configuration.toml | 4 +++- pr_agent/tools/pr_description.py | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 765c8342..c5c4a440 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -52,7 +52,6 @@ maximal_review_effort=5 [pr_description] # /describe # publish_labels=true -publish_description_as_comment=false add_original_user_description=true keep_original_user_title=true use_bullet_points=true @@ -61,6 +60,9 @@ enable_pr_type=true final_update_message = true enable_help_text=false enable_help_comment=true +# describe as comment +publish_description_as_comment=false +publish_description_as_comment_persistent=true ## changes walkthrough section enable_semantic_files_types=true collapsible_file_list='adaptive' # true, false, 'adaptive' diff --git a/pr_agent/tools/pr_description.py b/pr_agent/tools/pr_description.py index 7500efa7..8526642f 100644 --- a/pr_agent/tools/pr_description.py +++ b/pr_agent/tools/pr_description.py @@ -132,7 +132,14 @@ class PRDescription: # publish description if get_settings().pr_description.publish_description_as_comment: full_markdown_description = f"## Title\n\n{pr_title}\n\n___\n{pr_body}" - self.git_provider.publish_comment(full_markdown_description) + if get_settings().pr_description.publish_description_as_comment_persistent: + self.git_provider.publish_persistent_comment(full_markdown_description, + initial_header="## Title", + update_header=True, + name="describe", + final_update_message=False, ) + else: + self.git_provider.publish_comment(full_markdown_description) else: self.git_provider.publish_description(pr_title, pr_body) From 9614f619e83d20d9b86a18b95f5fbb634ac4a187 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Tue, 2 Apr 2024 17:54:37 +0300 Subject: [PATCH 23/44] feat: add persistent comment option for PR descriptions --- docs/docs/tools/describe.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/tools/describe.md b/docs/docs/tools/describe.md index e0de5153..bbd03ab7 100644 --- a/docs/docs/tools/describe.md +++ b/docs/docs/tools/describe.md @@ -27,6 +27,8 @@ To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agen - `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 original description. Default is false. + - `publish_description_as_comment_persistent`: if set to true and `publish_description_as_comment` is true, the tool will publish the description as a persistent comment to the PR. Default is true. + - `add_original_user_description`: if set to true, the tool will add the original user description to the generated description. Default is true. - `keep_original_user_title`: if set to true, the tool will keep the original PR title, and won't change it. Default is true. From 9c3673209dd7dd80d652c04dcec6131bdb3d048a Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 3 Apr 2024 08:42:50 +0300 Subject: [PATCH 24/44] TokenEncoder --- pr_agent/algo/token_handler.py | 23 ++++++++++++++++++----- pr_agent/algo/utils.py | 4 ++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/pr_agent/algo/token_handler.py b/pr_agent/algo/token_handler.py index d7eff9d7..9cc3b41f 100644 --- a/pr_agent/algo/token_handler.py +++ b/pr_agent/algo/token_handler.py @@ -1,12 +1,25 @@ from jinja2 import Environment, StrictUndefined from tiktoken import encoding_for_model, get_encoding - from pr_agent.config_loader import get_settings +from threading import Lock -def get_token_encoder(): - return encoding_for_model(get_settings().config.model) if "gpt" in get_settings().config.model else get_encoding( - "cl100k_base") +class TokenEncoder: + _encoder_instance = None + _model = None + _lock = Lock() # Create a lock object + + @classmethod + def get_token_encoder(cls): + model = get_settings().config.model + if cls._encoder_instance is None or model != cls._model: # Check without acquiring the lock for performance + with cls._lock: # Lock acquisition to ensure thread safety + if cls._encoder_instance is None or model != cls._model: + cls._model = model + cls._encoder_instance = encoding_for_model(cls._model) if "gpt" in cls._model else get_encoding( + "cl100k_base") + return cls._encoder_instance + class TokenHandler: """ @@ -31,7 +44,7 @@ class TokenHandler: - system: The system string. - user: The user string. """ - self.encoder = get_token_encoder() + self.encoder = TokenEncoder.get_token_encoder() if pr is not None: self.prompt_tokens = self._get_system_user_tokens(pr, self.encoder, vars, system, user) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index c2b6323c..b017f0aa 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -12,7 +12,7 @@ import yaml from starlette_context import context from pr_agent.algo import MAX_TOKENS -from pr_agent.algo.token_handler import get_token_encoder +from pr_agent.algo.token_handler import TokenEncoder from pr_agent.config_loader import get_settings, global_settings from pr_agent.algo.types import FilePatchInfo from pr_agent.log import get_logger @@ -566,7 +566,7 @@ def clip_tokens(text: str, max_tokens: int, add_three_dots=True) -> str: return text try: - encoder = get_token_encoder() + encoder = TokenEncoder.get_token_encoder() num_input_tokens = len(encoder.encode(text)) if num_input_tokens <= max_tokens: return text From d7b19af117dc71d60154682c1871f00e65ace2e4 Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:53:56 +0300 Subject: [PATCH 25/44] Update README.md --- docs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/README.md b/docs/README.md index 68867ce4..a06f01af 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,3 +13,4 @@ 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. + From 877aeffbb3cfaebe923a86c916f9f0b12c1d8156 Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:59:53 +0300 Subject: [PATCH 26/44] Update describe.md --- docs/docs/tools/describe.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/docs/tools/describe.md b/docs/docs/tools/describe.md index bbd03ab7..1510b2e8 100644 --- a/docs/docs/tools/describe.md +++ b/docs/docs/tools/describe.md @@ -5,6 +5,7 @@ The tool can be triggered automatically every time a new PR is [opened](../usage ``` /describe ``` + For example: ![Describe comment](https://codium.ai/images/pr_agent/describe_comment.png){width=512} @@ -160,4 +161,4 @@ The marker `pr_agent:type` will be replaced with the PR type, `pr_agent:summary` 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. \ No newline at end of file +
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. From bbd302360f475129e8b890ddc3d9bb553a77c56f Mon Sep 17 00:00:00 2001 From: Tal Date: Fri, 5 Apr 2024 17:22:54 +0300 Subject: [PATCH 27/44] Update additional_configurations.md --- .../usage-guide/additional_configurations.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/docs/usage-guide/additional_configurations.md b/docs/docs/usage-guide/additional_configurations.md index 1a756252..e1128817 100644 --- a/docs/docs/usage-guide/additional_configurations.md +++ b/docs/docs/usage-guide/additional_configurations.md @@ -7,10 +7,10 @@ To ignore files or directories, edit the **[ignore.toml](https://github.com/Codi - `IGNORE.GLOB` - `IGNORE.REGEX` -For example, to ignore python files in a PR with online usage, comment on a PR: +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: +To ignore Python files in all PRs, set in a configuration file: ``` [ignore] glob = ['*.py'] @@ -26,13 +26,13 @@ All PR-Agent tools have a parameter called `extra_instructions`, that enables to ## 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. +This mode provides 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: +However, for very large PRs, or in case you want to emphasize quality over speed and cost, there are two 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) +which divides the PR to chunks, and processes 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 @@ -79,6 +79,7 @@ MAX_TOKENS={ [config] # in configuration.toml model = "ollama/llama2" +model_turbo = "ollama/llama2" [ollama] # in .secrets.toml api_base = ... # the base url for your huggingface inference endpoint @@ -101,6 +102,7 @@ MAX_TOKENS={ } [config] # in configuration.toml model = "huggingface/meta-llama/Llama-2-7b-chat-hf" +model_turbo = "huggingface/meta-llama/Llama-2-7b-chat-hf" [huggingface] # in .secrets.toml key = ... # your huggingface api key @@ -114,13 +116,14 @@ To use Llama2 model with Replicate, for example, set: ``` [config] # in configuration.toml model = "replicate/llama-2-70b-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1" +model_turbo = "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. +Also, review the [AiHandler](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/algo/ai_handler.py) file for instructions on how to set keys for other models. ### Vertex AI @@ -129,6 +132,7 @@ To use Google's Vertex AI platform and its associated models (chat-bison/codecha ``` [config] # in configuration.toml model = "vertex_ai/codechat-bison" +model_turbo = "vertex_ai/codechat-bison" fallback_models="vertex_ai/codechat-bison" [vertexai] # in .secrets.toml @@ -183,7 +187,7 @@ AWS session is automatically authenticated from your environment, but you can al ## Patch Extra Lines -By default, around any change in your PR, git patch provides 3 lines of context above and below the change. +By default, around any change in your PR, git patch provides three lines of context above and below the change. ``` @@ -12,5 +12,5 @@ def func1(): code line that already existed in the file... From 4dc160bc1684a6dbfb8df306113bb9b9fc10126a Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 09:08:40 +0300 Subject: [PATCH 28/44] readme --- README.md | 50 ++++++++++++------- docs/docs/index.md | 10 ++-- docs/docs/installation/index.md | 2 +- .../docs/usage-guide/automations_and_usage.md | 4 ++ docs/mkdocs.yml | 2 +- 5 files changed, 44 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 0d75489c..de3f51e5 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,6 @@ CodiumAI PR-Agent aims to help efficiently review and handle pull requests, by p - [Overview](#overview) - [Example results](#example-results) - [Try it now](#try-it-now) -- [Installation](#installation) - [PR-Agent Pro 💎](#pr-agent-pro-) - [How it works](#how-it-works) - [Why use PR-Agent?](#why-use-pr-agent) @@ -235,32 +234,47 @@ Note that when you set your own PR-Agent or use CodiumAI hosted PR-Agent, there --- -## Installation -To use your own version of PR-Agent, you first need to acquire two tokens: +[//]: # (## Installation) -1. An OpenAI key from [here](https://platform.openai.com/), with access to GPT-4. -2. A GitHub personal access token (classic) with the repo scope. +[//]: # (To use your own version of PR-Agent, you first need to acquire two tokens:) -There are several ways to use PR-Agent: +[//]: # () +[//]: # (1. An OpenAI key from [here](https://platform.openai.com/), with access to GPT-4.) -**Locally** -- [Using pip package](https://pr-agent-docs.codium.ai/installation/locally/#using-pip-package) -- [Using Docker image](https://pr-agent-docs.codium.ai/installation/locally/#using-docker-image) -- [Run from source](https://pr-agent-docs.codium.ai/installation/locally/#run-from-source) +[//]: # (2. A GitHub personal access token (classic) with the repo scope.) -**GitHub specific methods** -- [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) +[//]: # () +[//]: # (There are several ways to use PR-Agent:) -**GitLab specific methods** -- [Run a GitLab webhook server](https://pr-agent-docs.codium.ai/installation/gitlab/) +[//]: # () +[//]: # (**Locally**) -**BitBucket specific methods** -- [Run as a Bitbucket Pipeline](https://pr-agent-docs.codium.ai/installation/bitbucket/) +[//]: # (- [Using pip package](https://pr-agent-docs.codium.ai/installation/locally/#using-pip-package)) + +[//]: # (- [Using Docker image](https://pr-agent-docs.codium.ai/installation/locally/#using-docker-image)) + +[//]: # (- [Run from source](https://pr-agent-docs.codium.ai/installation/locally/#run-from-source)) + +[//]: # () +[//]: # (**GitHub specific methods**) + +[//]: # (- [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](https://pr-agent-docs.codium.ai/installation/gitlab/)) + +[//]: # () +[//]: # (**BitBucket specific methods**) + +[//]: # (- [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. +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\GitLab\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. diff --git a/docs/docs/index.md b/docs/docs/index.md index 3919feae..cec35b45 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -45,7 +45,7 @@ PR-Agent offers extensive pull request functionalities across various git provid 💎 marks a feature available only in [PR-Agent Pro](https://www.codium.ai/pricing/){:target="_blank"} -## Example results +## Example Results #### [/describe](https://github.com/Codium-ai/pr-agent/pull/530)
![/describe](https://www.codium.ai/images/pr_agent/describe_new_short_main.png){width=512} @@ -66,7 +66,7 @@ PR-Agent offers extensive pull request functionalities across various git provid ![/generate_labels](https://www.codium.ai/images/pr_agent/geneare_custom_labels_main_short.png){width=300}
-## How it works +## How it Works The following diagram illustrates PR-Agent tools and their flow: @@ -80,7 +80,7 @@ Check out the [PR Compression strategy](core-abilities/index.md) page for more d [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. +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\GitLab\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: @@ -88,13 +88,15 @@ Check out the [PR Compression strategy](core-abilities/index.md) page for more d - [**Custom Code Suggestions**](./tools/custom_suggestions.md/) - [**Tests**](./tools/test.md/) - [**PR documentation**](./tools/documentation.md/) + - [**Improve Component**](https://pr-agent-docs.codium.ai/tools/improve_component/) + - [**Similar code search**](https://pr-agent-docs.codium.ai/tools/similar_code/) - [**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 +## 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 diff --git a/docs/docs/installation/index.md b/docs/docs/installation/index.md index fc71ecbb..f8b64a27 100644 --- a/docs/docs/installation/index.md +++ b/docs/docs/installation/index.md @@ -1,6 +1,6 @@ # Installation -## self-hosted PR-Agent +## Self-hosted PR-Agent 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). diff --git a/docs/docs/usage-guide/automations_and_usage.md b/docs/docs/usage-guide/automations_and_usage.md index f32863eb..3d23c491 100644 --- a/docs/docs/usage-guide/automations_and_usage.md +++ b/docs/docs/usage-guide/automations_and_usage.md @@ -50,6 +50,10 @@ Any configuration value in [configuration file](https://github.com/Codium-ai/pr- ## GitHub App +!!! note "Configurations for PR-Agent Pro" + PR-Agent Pro for GitHub is an App, hosted by CodiumAI. So all the instructions below are relevant also for PR-Agent Pro users. + Same goes for [GitLab webhook](#gitlab-webhook) and [BitBucket App](#bitbucket-app) sections. + ### 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. diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index c045d8e4..a34c1bc0 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -14,7 +14,7 @@ nav: - 'usage-guide/index.md' - Introduction: 'usage-guide/introduction.md' - Configuration Options: 'usage-guide/configuration_options.md' - - Managing email notifications: 'usage-guide/mail_notifications.md' + - Managing Mail Notifications: 'usage-guide/mail_notifications.md' - Usage and Automation: 'usage-guide/automations_and_usage.md' - Additional Configurations: 'usage-guide/additional_configurations.md' - Tools: From d9efc441df3941513793f8d22b559174dbb135af Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 09:28:22 +0300 Subject: [PATCH 29/44] readme --- docs/docs/index.md | 22 ++++++++++++---------- docs/docs/tools/analyze.md | 10 +++------- docs/docs/tools/help.md | 13 +++++++++++++ docs/docs/tools/index.md | 1 + 4 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 docs/docs/tools/help.md diff --git a/docs/docs/index.md b/docs/docs/index.md index cec35b45..198bee22 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -84,16 +84,18 @@ Check out the [PR Compression strategy](core-abilities/index.md) page for more d 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/) - - [**Improve Component**](https://pr-agent-docs.codium.ai/tools/improve_component/) - - [**Similar code search**](https://pr-agent-docs.codium.ai/tools/similar_code/) - - [**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) + - (Tool): [**Analyze PR components**](./tools/analyze.md/) + - (Tool): [**Custom Code Suggestions**](./tools/custom_suggestions.md/) + - (Tool): [**Tests**](./tools/test.md/) + - (Tool): [**PR documentation**](./tools/documentation.md/) + - (Tool): [**Improve Component**](https://pr-agent-docs.codium.ai/tools/improve_component/) + - (Tool): [**Similar code search**](https://pr-agent-docs.codium.ai/tools/similar_code/) + - (Tool): [**CI feedback**](./tools/ci_feedback.md/) + - (Feature): [**Interactive triggering**](./usage-guide/automations_and_usage.md/#interactive-triggering) + - (Feature): [**SOC2 compliance check**](./tools/review.md/#soc2-ticket-compliance) + - (Feature): [**Custom labels**](./tools/describe.md/#handle-custom-labels-from-the-repos-labels-page) + - (Feature): [**Global and wiki configuration**](./usage-guide/configuration_options.md/#wiki-configuration-file) + - (Feature): [**Inline file summary**](https://pr-agent-docs.codium.ai/tools/describe/#inline-file-summary) ## Data Privacy diff --git a/docs/docs/tools/analyze.md b/docs/docs/tools/analyze.md index 0255e759..7af0546e 100644 --- a/docs/docs/tools/analyze.md +++ b/docs/docs/tools/analyze.md @@ -1,7 +1,7 @@ ## Overview -The `analyze` tool combines static code analysis with LLM capabilities to provide a comprehensive analysis of the PR code changes. +The `analyze` tool combines advanced 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. +The tool scans the PR code changes, find the code components (methods, functions, classes) that changed, and enables to interactively generate tests, docs, code suggestions and similar code search for each component. It can be invoked manually by commenting on any PR: ``` @@ -9,13 +9,9 @@ It can be invoked manually by commenting on any PR: ``` ## Example usage -An example [result](https://github.com/Codium-ai/pr-agent/pull/546#issuecomment-1868524805): +An example result: ![Analyze 1](https://codium.ai/images/pr_agent/analyze_1.png){width=750} -→ -![Analyze 2](https://codium.ai/images/pr_agent/analyze_2.png){width=750} -→ -![Analyze 3](https://codium.ai/images/pr_agent/analyze_3.png){width=750} **Notes** diff --git a/docs/docs/tools/help.md b/docs/docs/tools/help.md new file mode 100644 index 00000000..ac66d158 --- /dev/null +++ b/docs/docs/tools/help.md @@ -0,0 +1,13 @@ +## Overview +The `help` tool provides a list of all the available tools and their descriptions. +For PR-Agent Pro users, it also enables to trigger each tool by checking the relevant box. +``` +/help +``` + +## Example usage +An example [result](https://github.com/Codium-ai/pr-agent/pull/546#issuecomment-1868524805): + +![Help 1](https://codium.ai/images/pr_agent/help1.png){width=750} +→ +![Analyze 2](https://codium.ai/images/pr_agent/help2.png){width=750} diff --git a/docs/docs/tools/index.md b/docs/docs/tools/index.md index b77097b3..49c31a8f 100644 --- a/docs/docs/tools/index.md +++ b/docs/docs/tools/index.md @@ -10,6 +10,7 @@ Here is a list of PR-Agent tools, each with a dedicated page that explains how t | **[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 | +| **[Help (`/help`](./help.md))** | Provides a list of all the available tools. Also enables to trigger them interactively (💎) | | **💎 [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 | From 60fd1c67fa4894f7c5e0092f579ec52d1b9e0415 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 09:35:41 +0300 Subject: [PATCH 30/44] readme --- docs/docs/usage-guide/index.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/docs/usage-guide/index.md b/docs/docs/usage-guide/index.md index e784d1b0..ce714c70 100644 --- a/docs/docs/usage-guide/index.md +++ b/docs/docs/usage-guide/index.md @@ -1,8 +1,10 @@ # Usage guide +This page provides a detailed guide on how to use PR-Agent. It includes information on how to adjust PR-Agent configurations, define which tools will run automatically, manage mail notifications, and other advanced configurations. + + - [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) @@ -11,6 +13,7 @@ - [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) +- [Managing Mail Notifications](./mail_notifications.md) - [Additional Configurations Walkthrough](./additional_configurations.md) - [Ignoring files from analysis](./additional_configurations.md#ignoring-files-from-analysis) - [Extra instructions](./additional_configurations.md#extra-instructions) From f3b46956173441320bb29df3921b14acfbdb1ff3 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 10:43:56 +0300 Subject: [PATCH 31/44] readme --- docs/docs/tools/help.md | 4 ++++ docs/docs/usage-guide/mail_notifications.md | 8 ++++++++ docs/mkdocs.yml | 1 + 3 files changed, 13 insertions(+) diff --git a/docs/docs/tools/help.md b/docs/docs/tools/help.md index ac66d158..5cfc1e81 100644 --- a/docs/docs/tools/help.md +++ b/docs/docs/tools/help.md @@ -1,6 +1,8 @@ ## Overview The `help` tool provides a list of all the available tools and their descriptions. For PR-Agent Pro users, it also enables to trigger each tool by checking the relevant box. + +It can be invoked manually by commenting on any PR: ``` /help ``` @@ -9,5 +11,7 @@ For PR-Agent Pro users, it also enables to trigger each tool by checking the rel An example [result](https://github.com/Codium-ai/pr-agent/pull/546#issuecomment-1868524805): ![Help 1](https://codium.ai/images/pr_agent/help1.png){width=750} + → + ![Analyze 2](https://codium.ai/images/pr_agent/help2.png){width=750} diff --git a/docs/docs/usage-guide/mail_notifications.md b/docs/docs/usage-guide/mail_notifications.md index 82dc10a0..4c2ee64e 100644 --- a/docs/docs/usage-guide/mail_notifications.md +++ b/docs/docs/usage-guide/mail_notifications.md @@ -7,3 +7,11 @@ If you are subscribed to notifications for a repo with PR-Agent, we recommend tu 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). ![filter_mail_notifications](https://codium.ai/images/pr_agent/filter_mail_notifications.png){width=512} + + +Another option to reduce the mail overload is disable the help collapsible section in PR-Agent bot comments, by adding the relevant configurations to the `.pr_agent.toml` file. +For example, to disable the help text for the `pr_reviewer` tool, add to the configuration file: +``` +[pr_reviewer] +enable_help_text = false +``` \ No newline at end of file diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index a34c1bc0..717f42bf 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -25,6 +25,7 @@ nav: - Ask: 'tools/ask.md' - Update Changelog: 'tools/update_changelog.md' - Similar Issues: 'tools/similar_issues.md' + - Help: 'tools/help.md' - 💎 Analyze: 'tools/analyze.md' - 💎 Test: 'tools/test.md' - 💎 Improve Component: 'tools/improve_component.md' From 45eefaa4f0068e596cb330fcf1861292be58b206 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 11:04:23 +0300 Subject: [PATCH 32/44] readme --- docs/docs/usage-guide/mail_notifications.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/docs/usage-guide/mail_notifications.md b/docs/docs/usage-guide/mail_notifications.md index 4c2ee64e..1d6f6dcb 100644 --- a/docs/docs/usage-guide/mail_notifications.md +++ b/docs/docs/usage-guide/mail_notifications.md @@ -9,8 +9,9 @@ As an alternative, you can filter in your mail provider the notifications specif ![filter_mail_notifications](https://codium.ai/images/pr_agent/filter_mail_notifications.png){width=512} -Another option to reduce the mail overload is disable the help collapsible section in PR-Agent bot comments, by adding the relevant configurations to the `.pr_agent.toml` file. -For example, to disable the help text for the `pr_reviewer` tool, add to the configuration file: +Another option to reduce the mail overload, yet still receive notifications on PR-Agent tools, is to disable the help collapsible section in PR-Agent bot comments. +This can done by setting `enable_help_text=false` configuration to the relevant tool in the configuration file. +For example, to disable the help text for the `pr_reviewer` tool, set: ``` [pr_reviewer] enable_help_text = false From d6b037a63a9244ab32eeb3da9f5c40aa501d530a Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 11:51:06 +0300 Subject: [PATCH 33/44] readme --- docs/docs/tools/describe.md | 70 ++++++++++++++------------- pr_agent/tools/pr_code_suggestions.py | 41 +++++++++------- 2 files changed, 61 insertions(+), 50 deletions(-) diff --git a/docs/docs/tools/describe.md b/docs/docs/tools/describe.md index 1510b2e8..50d2af0a 100644 --- a/docs/docs/tools/describe.md +++ b/docs/docs/tools/describe.md @@ -69,22 +69,6 @@ If you prefer to have the file summaries appear in the "Files changed" tab on ev **Note**: that this feature is currently available only for GitHub. -### Handle custom labels from the Repo's labels page 💎 - -You can control the custom labels that will be suggested by the `describe` tool, from the repo's labels page: - -* GitHub : go to `https://github.com/{owner}/{repo}/labels` (or click on the "Labels" tab in the issues or PRs page) -* GitLab : go to `https://gitlab.com/{owner}/{repo}/-/labels` (or click on "Manage" -> "Labels" on the left menu) - -Now add/edit the custom labels. they should be formatted as follows: - -* Label name: The name of the custom label. -* Description: Start the description of with prefix `pr_agent:`, for example: `pr_agent: Description of when AI should suggest this label`.
- -The description should be comprehensive and detailed, indicating when to add the desired label. For example: -![Add native custom labels](https://codium.ai/images/pr_agent/add_native_custom_labels.png){width=768} - - ### Markers template To enable markers, set `pr_description.use_description_markers=true`. @@ -117,6 +101,43 @@ The marker `pr_agent:type` will be replaced with the PR type, `pr_agent:summary` - `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. +## 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`]. + +You can define custom labels that are relevant for your repo and use cases. +Custom labels can be defined in a [configuration file](https://pr-agent-docs.codium.ai/tools/custom_labels/#configuration-options), or directly in the repo's [labels page](#handle-custom-labels-from-the-repos-labels-page). + +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 + - `SQL query` - pr_agent:A new SQL query was added in this PR + - `Dockerfile changes` - pr_agent:The PR contains changes in the Dockerfile + - ... + +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. +Each label description should be a **conditional statement**, that indicates if to add the label to the PR or not, according to the PR content. + + +### Handle custom labels from the Repo's labels page 💎 + +You can control the custom labels that will be suggested by the `describe` tool, from the repo's labels page: + +* GitHub : go to `https://github.com/{owner}/{repo}/labels` (or click on the "Labels" tab in the issues or PRs page) +* GitLab : go to `https://gitlab.com/{owner}/{repo}/-/labels` (or click on "Manage" -> "Labels" on the left menu) + +Now add/edit the custom labels. they should be formatted as follows: + +* Label name: The name of the custom label. +* Description: Start the description of with prefix `pr_agent:`, for example: `pr_agent: Description of when AI should suggest this label`.
+ +The description should be comprehensive and detailed, indicating when to add the desired label. For example: +![Add native custom labels](https://codium.ai/images/pr_agent/add_native_custom_labels.png){width=768} + ## Usage Tips @@ -145,20 +166,3 @@ The marker `pr_agent:type` will be replaced with the PR type, `pr_agent:summary` * `walkthrough`: the PR walkthrough. - 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. - -!!! tip "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) 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 - - `SQL query` - pr_agent:A new SQL query was added in this PR - - `Dockerfile changes` - pr_agent:The PR contains changes in the Dockerfile - - ... - - 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. diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index 926edf00..ed14d225 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -196,24 +196,31 @@ class PRCodeSuggestions: suggestion_list = [] one_sentence_summary_list = [] for i, suggestion in enumerate(data['code_suggestions']): - if get_settings().pr_code_suggestions.summarize: - if not suggestion or 'one_sentence_summary' not in suggestion or 'label' not in suggestion or 'relevant_file' not in suggestion: - get_logger().debug(f"Skipping suggestion {i + 1}, because it is invalid: {suggestion}") - continue - - if suggestion['one_sentence_summary'] in one_sentence_summary_list: - get_logger().debug(f"Skipping suggestion {i + 1}, because it is a duplicate: {suggestion}") - continue - - if ('existing_code' in suggestion) and ('improved_code' in suggestion) and ( - suggestion['existing_code'] != suggestion['improved_code']): - suggestion = self._truncate_if_needed(suggestion) + try: if get_settings().pr_code_suggestions.summarize: - one_sentence_summary_list.append(suggestion['one_sentence_summary']) - suggestion_list.append(suggestion) - else: - get_logger().debug( - f"Skipping suggestion {i + 1}, because existing code is equal to improved code {suggestion['existing_code']}") + if not suggestion or 'one_sentence_summary' not in suggestion or 'label' not in suggestion or 'relevant_file' not in suggestion: + get_logger().debug(f"Skipping suggestion {i + 1}, because it is invalid: {suggestion}") + continue + + if suggestion['one_sentence_summary'] in one_sentence_summary_list: + get_logger().debug(f"Skipping suggestion {i + 1}, because it is a duplicate: {suggestion}") + continue + + if 'const' in suggestion['suggestion_content'] and 'instead' in suggestion['suggestion_content'] and 'let' in suggestion['suggestion_content']: + get_logger().debug(f"Skipping suggestion {i + 1}, because it uses 'const instead let': {suggestion}") + continue + + if ('existing_code' in suggestion) and ('improved_code' in suggestion) and ( + suggestion['existing_code'] != suggestion['improved_code']): + suggestion = self._truncate_if_needed(suggestion) + if get_settings().pr_code_suggestions.summarize: + one_sentence_summary_list.append(suggestion['one_sentence_summary']) + suggestion_list.append(suggestion) + else: + get_logger().debug( + f"Skipping suggestion {i + 1}, because existing code is equal to improved code {suggestion['existing_code']}") + except Exception as e: + get_logger().error(f"Error processing suggestion {i + 1}: {suggestion}, error: {e}") data['code_suggestions'] = suggestion_list return data From 68f29a41eff80a109ab971101267b33835ec3e04 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 11:52:42 +0300 Subject: [PATCH 34/44] readme --- docs/docs/usage-guide/mail_notifications.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/usage-guide/mail_notifications.md b/docs/docs/usage-guide/mail_notifications.md index 1d6f6dcb..f25c7eaa 100644 --- a/docs/docs/usage-guide/mail_notifications.md +++ b/docs/docs/usage-guide/mail_notifications.md @@ -10,7 +10,7 @@ As an alternative, you can filter in your mail provider the notifications specif Another option to reduce the mail overload, yet still receive notifications on PR-Agent tools, is to disable the help collapsible section in PR-Agent bot comments. -This can done by setting `enable_help_text=false` configuration to the relevant tool in the configuration file. +This can done by setting `enable_help_text=false` for the relevant tool in the configuration file. For example, to disable the help text for the `pr_reviewer` tool, set: ``` [pr_reviewer] From dc14b876578765c2da32eaf026771df5330e02a8 Mon Sep 17 00:00:00 2001 From: Charles Uneze Date: Sun, 7 Apr 2024 10:06:05 +0100 Subject: [PATCH 35/44] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index de3f51e5..1ac8b7da 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ ___ \ ‣ **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. +‣ **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 From aa2121a48def2f05e2e85e373063259999b1955b Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 16:28:30 +0300 Subject: [PATCH 36/44] readme --- docs/docs/tools/improve.md | 2 +- docs/docs/tools/review.md | 4 ++-- docs/docs/usage-guide/configuration_options.md | 2 +- pr_agent/servers/help.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/docs/tools/improve.md b/docs/docs/tools/improve.md index 40945775..b62fd649 100644 --- a/docs/docs/tools/improve.md +++ b/docs/docs/tools/improve.md @@ -72,7 +72,7 @@ To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agen Examples for extra instructions: ``` [pr_code_suggestions] # /improve # - extra_instructions=""" + extra_instructions="""\ Emphasize the following aspects: - Does the code logic cover relevant edge cases? - Is the code logic clear and easy to understand? diff --git a/docs/docs/tools/review.md b/docs/docs/tools/review.md index 41ef75ed..c5681bb4 100644 --- a/docs/docs/tools/review.md +++ b/docs/docs/tools/review.md @@ -124,8 +124,8 @@ The tool will first ask the author questions about the PR, and will guide the re Examples for extra instructions: ``` - [pr_reviewer] # /review # - extra_instructions=""" + [pr_reviewer] + extra_instructions="""\ In the code feedback section, emphasize the following: - Does the code logic cover relevant edge cases? - Is the code logic clear and easy to understand? diff --git a/docs/docs/usage-guide/configuration_options.md b/docs/docs/usage-guide/configuration_options.md index 1d56baa2..ee908b76 100644 --- a/docs/docs/usage-guide/configuration_options.md +++ b/docs/docs/usage-guide/configuration_options.md @@ -22,7 +22,7 @@ Click [here](https://codium.ai/images/pr_agent/wiki_configuration_pr_agent.mp4) An example content: ``` -[pr_description] # /describe # +[pr_description] keep_original_user_title=false ``` diff --git a/pr_agent/servers/help.py b/pr_agent/servers/help.py index 364088ec..9e85887d 100644 --- a/pr_agent/servers/help.py +++ b/pr_agent/servers/help.py @@ -128,7 +128,7 @@ Be specific, clear, and concise in the instructions. With extra instructions, yo Examples for extra instructions: ``` [pr_description] -extra_instructions=""" +extra_instructions="""\ - The PR title should be in the format: ': ' - The title should be short and concise (up to 10 words) - ... From 2be0e9108e531c2d39bfdd7f05ae76e0e2c0d4c3 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Sun, 7 Apr 2024 17:00:40 +0300 Subject: [PATCH 37/44] readme --- pr_agent/algo/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index b017f0aa..5a1e332d 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -575,7 +575,7 @@ def clip_tokens(text: str, max_tokens: int, add_three_dots=True) -> str: num_output_chars = int(chars_per_token * max_tokens) clipped_text = text[:num_output_chars] if add_three_dots: - clipped_text += "...(truncated)" + clipped_text += " ...(truncated)" return clipped_text except Exception as e: get_logger().warning(f"Failed to clip tokens: {e}") From a5a68c2a733d1b34f343af70c0b99aaaf1ff2022 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Sun, 7 Apr 2024 17:02:37 +0300 Subject: [PATCH 38/44] readme --- tests/unittest/test_clip_tokens.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unittest/test_clip_tokens.py b/tests/unittest/test_clip_tokens.py index cc52ab7e..2405a06b 100644 --- a/tests/unittest/test_clip_tokens.py +++ b/tests/unittest/test_clip_tokens.py @@ -15,5 +15,5 @@ class TestClipTokens: max_tokens = 10 result = clip_tokens(text, max_tokens) - expected_results = 'line1\nline2\nline3\nli...(truncated)' + expected_results = 'line1\nline2\nline3\nli ...(truncated)' assert result == expected_results From 09f76f45effd7cbce4d6b36a98a03f31fb593beb Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Mon, 8 Apr 2024 08:18:33 +0300 Subject: [PATCH 39/44] Update docs readme --- docs/README.md | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/docs/README.md b/docs/README.md index a06f01af..42154c96 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,16 +1 @@ -# 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. - +# [Visit Our Docs Portal](https://pr-agent-docs.codium.ai/) From a543d7ed1adfd888969da697b61143154c746623 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Mon, 8 Apr 2024 09:12:50 +0300 Subject: [PATCH 40/44] readme --- docs/docs/index.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/docs/index.md b/docs/docs/index.md index 198bee22..80b62e11 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -46,25 +46,31 @@ PR-Agent offers extensive pull request functionalities across various git provid ## Example Results +<hr> + #### [/describe](https://github.com/Codium-ai/pr-agent/pull/530) <figure markdown="1"> ![/describe](https://www.codium.ai/images/pr_agent/describe_new_short_main.png){width=512} </figure> +<hr> #### [/review](https://github.com/Codium-ai/pr-agent/pull/732#issuecomment-1975099151) <figure markdown="1"> ![/review](https://www.codium.ai/images/pr_agent/review_new_short_main.png){width=512} </figure> +<hr> #### [/improve](https://github.com/Codium-ai/pr-agent/pull/732#issuecomment-1975099159) <figure markdown="1"> ![/improve](https://www.codium.ai/images/pr_agent/improve_new_short_main.png){width=512} </figure> +<hr> #### [/generate_labels](https://github.com/Codium-ai/pr-agent/pull/530) <figure markdown="1"> ![/generate_labels](https://www.codium.ai/images/pr_agent/geneare_custom_labels_main_short.png){width=300} </figure> +<hr> ## How it Works From 84d8f78d0c6215d3d10acfdd9c25074800ddc639 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Mon, 8 Apr 2024 14:00:41 +0300 Subject: [PATCH 41/44] publish_output --- pr_agent/algo/utils.py | 2 +- pr_agent/tools/pr_reviewer.py | 3 +++ tests/unittest/test_clip_tokens.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 5a1e332d..4c87c038 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -575,7 +575,7 @@ def clip_tokens(text: str, max_tokens: int, add_three_dots=True) -> str: num_output_chars = int(chars_per_token * max_tokens) clipped_text = text[:num_output_chars] if add_three_dots: - clipped_text += " ...(truncated)" + clipped_text += "\n...(truncated)" return clipped_text except Exception as e: get_logger().warning(f"Failed to clip tokens: {e}") diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index 4d1739a5..c257c30a 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -357,6 +357,9 @@ class PRReviewer: return True def set_review_labels(self, data): + if not get_settings().config.publish_output: + return + if (get_settings().pr_reviewer.enable_review_labels_security or get_settings().pr_reviewer.enable_review_labels_effort): try: diff --git a/tests/unittest/test_clip_tokens.py b/tests/unittest/test_clip_tokens.py index 2405a06b..a56ff92f 100644 --- a/tests/unittest/test_clip_tokens.py +++ b/tests/unittest/test_clip_tokens.py @@ -15,5 +15,5 @@ class TestClipTokens: max_tokens = 10 result = clip_tokens(text, max_tokens) - expected_results = 'line1\nline2\nline3\nli ...(truncated)' + expected_results = 'line1\nline2\nline3\nli\n...(truncated)' assert result == expected_results From 8a5b01b4657d5522b6b4d44592f66cf3150f1836 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Mon, 8 Apr 2024 14:49:00 +0300 Subject: [PATCH 42/44] empty calc_pr_statistics --- pr_agent/git_providers/github_provider.py | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/pr_agent/git_providers/github_provider.py b/pr_agent/git_providers/github_provider.py index de54ec3f..574e28cf 100644 --- a/pr_agent/git_providers/github_provider.py +++ b/pr_agent/git_providers/github_provider.py @@ -745,22 +745,4 @@ class GithubProvider(GitProvider): return False def calc_pr_statistics(self, pull_request_data: dict): - try: - out = {} - from datetime import datetime - created_at = pull_request_data['created_at'] - closed_at = pull_request_data['closed_at'] - closed_at_datetime = datetime.strptime(closed_at, "%Y-%m-%dT%H:%M:%SZ") - created_at_datetime = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%SZ") - difference = closed_at_datetime - created_at_datetime - out['hours'] = difference.total_seconds() / 3600 - out['commits'] = pull_request_data['commits'] - out['comments'] = pull_request_data['comments'] - out['review_comments'] = pull_request_data['review_comments'] - out['changed_files'] = pull_request_data['changed_files'] - out['additions'] = pull_request_data['additions'] - out['deletions'] = pull_request_data['deletions'] - except Exception as e: - get_logger().exception(f"Failed to calculate PR statistics, error: {e}") - return {} - return out + return {} From 0257b619ff6507729ea2345a753ec9ac10716efb Mon Sep 17 00:00:00 2001 From: phuongvietnamlab <phuongpv@vietnamlab.vn> Date: Tue, 9 Apr 2024 15:47:54 +0700 Subject: [PATCH 43/44] Failed to review PR: name 'is_valid_file' is not defined --- pr_agent/git_providers/codecommit_provider.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/git_providers/codecommit_provider.py b/pr_agent/git_providers/codecommit_provider.py index f035351d..41de6bb3 100644 --- a/pr_agent/git_providers/codecommit_provider.py +++ b/pr_agent/git_providers/codecommit_provider.py @@ -10,7 +10,7 @@ from ..algo.utils import load_large_diff from .git_provider import GitProvider from ..config_loader import get_settings from ..log import get_logger - +from pr_agent.algo.language_handler import is_valid_file class PullRequestCCMimic: """ From 108b1afa0ee8d853517a10e75ea4aef63f8db2bd Mon Sep 17 00:00:00 2001 From: Yuta Nishi <riyaamemiya@gmail.com> Date: Wed, 10 Apr 2024 14:44:38 +0900 Subject: [PATCH 44/44] add new models --- pr_agent/algo/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pr_agent/algo/__init__.py b/pr_agent/algo/__init__.py index 19968be5..1357db29 100644 --- a/pr_agent/algo/__init__.py +++ b/pr_agent/algo/__init__.py @@ -11,6 +11,8 @@ MAX_TOKENS = { 'gpt-4-1106-preview': 128000, # 128K, but may be limited by config.max_model_tokens 'gpt-4-0125-preview': 128000, # 128K, but may be limited by config.max_model_tokens 'gpt-4-turbo-preview': 128000, # 128K, but may be limited by config.max_model_tokens + 'gpt-4-turbo-2024-04-09': 128000, # 128K, but may be limited by config.max_model_tokens + 'gpt-4-turbo': 128000, # 128K, but may be limited by config.max_model_tokens 'claude-instant-1': 100000, 'claude-2': 100000, 'command-nightly': 4096,