From 443d06df06c1458a724dc976eaa8beaead41fee5 Mon Sep 17 00:00:00 2001 From: Pratul Sanwal Date: Fri, 1 Nov 2024 14:47:47 -0400 Subject: [PATCH 1/7] Add configuration option to control publish of no code suggestions message --- pr_agent/settings/configuration.toml | 1 + pr_agent/tools/pr_code_suggestions.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 6d1f0cee..038010e2 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -7,6 +7,7 @@ fallback_models=["gpt-4o-2024-05-13"] git_provider="github" publish_output=true publish_output_progress=true +publish_output_no_suggestions=true verbosity_level=0 # 0,1,2 use_extra_bad_extensions=false # Configurations diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index 37a89a56..e4218ba8 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -113,12 +113,15 @@ class PRCodeSuggestions: if (data is None or 'code_suggestions' not in data or not data['code_suggestions'] and get_settings().config.publish_output): get_logger().warning('No code suggestions found for the PR.') - pr_body = "## PR Code Suggestions ✨\n\nNo code suggestions found for the PR." - get_logger().debug(f"PR output", artifact=pr_body) - if self.progress_response: - self.git_provider.edit_comment(self.progress_response, body=pr_body) - else: - self.git_provider.publish_comment(pr_body) + + if (get_settings().config.publish_output_no_suggestions): + pr_body = "## PR Code Suggestions ✨\n\nNo code suggestions found for the PR." + get_logger().debug(f"PR output", artifact=pr_body) + if self.progress_response: + self.git_provider.edit_comment(self.progress_response, body=pr_body) + else: + self.git_provider.publish_comment(pr_body) + return if (not self.is_extended and get_settings().pr_code_suggestions.rank_suggestions) or \ From 022e407d841a6d5cb4ac4fc01bef823728b31521 Mon Sep 17 00:00:00 2001 From: "Hussam.lawen" Date: Mon, 4 Nov 2024 15:52:39 +0200 Subject: [PATCH 2/7] add documentation for ticket integrations --- .../core-abilities/fetching_ticket_context.md | 115 ++++++++++++++++++ docs/docs/core-abilities/index.md | 2 +- docs/mkdocs.yml | 1 + 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 docs/docs/core-abilities/fetching_ticket_context.md diff --git a/docs/docs/core-abilities/fetching_ticket_context.md b/docs/docs/core-abilities/fetching_ticket_context.md new file mode 100644 index 00000000..851895bf --- /dev/null +++ b/docs/docs/core-abilities/fetching_ticket_context.md @@ -0,0 +1,115 @@ +# Fetching Ticket Context for PRs +## Overview +Qodo Merge PR Agent streamlines code review workflows by seamlessly connecting with multiple ticket management systems. +This integration enriches the review process by automatically surfacing relevant ticket information and context alongside code changes. + + +## Affected Tools + +Ticket Recognition Requirements: + +1. The PR description should contain a link to the ticket. +2. For Jira tickets, you should follow the instructions in #jira-integration in order to authenticate with Jira. + + +### Describe tool +Qodo Merge PR Agent will recognize the ticket and use the ticket content (title, description, labels) to provide additional context for the code changes. +By understanding the reasoning and intent behind modifications, the LLM can offer more insightful and relevant code analysis. + +### Review tool +Similarly to the `describe` tool, the `review` tool will use the ticket content to provide additional context for the code changes. + +In addition, This feature will evaluate how well a Pull Request (PR) adheres to its original purpose/intent as defined by the associated ticket or issue mentioned in the PR description. +Each ticket will be assigned a label (Compliance/Alignment level), Indicates the degree to which the PR fulfills its original purpose, Options: Fully compliant, Partially compliant or Not compliant. + + +![Ticket Compliance](https://www.qodo.ai/images/pr_agent/ticket_compliance_review.png){width=768} + +By default, the tool will automatically validate if the PR complies with the referenced ticket. +If you want to disable this feedback, add the following line to your configuration file: + +```toml +[pr_reviewer] +require_ticket_analysis_review=false +``` + +## Providers + +### Github Issues Integration + +Qodo Merge PR Agent will automatically recognize Github issues mentioned in the PR description and fetch the issue content. +Examples of valid GitHub issue references: + +- `https://github.com///issues/` +- `#` +- `/#` + +Since Qodo Merge PR Agent is integrated with GitHub, it doesn't require any additional configuration to fetch GitHub issues. + +### Jira Integration 💎 + +We support both Jira Cloud and Jira Server/Data Center. +To integrate with Jira, The PR Description should contain a link to the Jira ticket. + +For Jira integration, include a ticket reference in your PR description using either the complete URL format `https://.atlassian.net/browse/ISSUE-123` or the shortened ticket ID `ISSUE-123`. + +!!! note "Jira Base URL" + If using the shortened format, ensure your configuration file contains the Jira base URL under the [jira] section like this: + + ```toml + [jira] + jira_base_url = "https://.atlassian.net" + ``` + +#### Jira Cloud 💎 +There are two ways to authenticate with Jira Cloud: + +**1) Jira App Authentication** + +The recommended way to authenticate with Jira Cloud is to install the Qodo Merge app in your Jira Cloud instance. This will allow Qodo Merge to access Jira data on your behalf. + +Installation steps: + +1. Click [here](https://auth.atlassian.com/authorize?audience=api.atlassian.com&client_id=8krKmA4gMD8mM8z24aRCgPCSepZNP1xf&scope=read%3Ajira-work%20offline_access&redirect_uri=https%3A%2F%2Fregister.jira.pr-agent.codium.ai&state=qodomerge&response_type=code&prompt=consent) to install the Qodo Merge app in your Jira Cloud instance, click the `accept` button.
+![Jira Cloud App Installation](https://www.qodo.ai/images/pr_agent/jira_app_installation1.png){width=384} + +2. After installing the app, you will be redirected to the Qodo Merge registration page. and you will see a success message.
+![Jira Cloud App success message](https://www.qodo.ai/images/pr_agent/jira_app_success.png){width=384} + +3. Now you can use the Jira integration in Qodo Merge PR Agent. + +**2) Email/Token Authentication** + +You can create an API token from your Atlassian account: + +1. Log in to https://id.atlassian.com/manage-profile/security/api-tokens. + +2. Click Create API token. + +3. From the dialog that appears, enter a name for your new token and click Create. + +4. Click Copy to clipboard. + +![Jira Cloud API Token](https://images.ctfassets.net/zsv3d0ugroxu/1RYvh9lqgeZjjNe5S3Hbfb/155e846a1cb38f30bf17512b6dfd2229/screenshot_NewAPIToken){width=384} + +5. In your [configuration file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/) add the following lines: + +```toml +[jira] +jira_api_token = "YOUR_API_TOKEN" +jira_api_email = "YOUR_EMAIL" +``` + + +#### Jira Server/Data Center 💎 + +Currently we only Personal Access Token (PAT) Authentication method. + +1. Create a [Personal Access Token (PAT)](https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html) in your Jira account +2. In your [configuration file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/) add the following lines: + +```toml +[jira] +jira_base_url = "YOUR_JIRA_BASE_URL" # e.g. https://jira.example.com +jira_api_token = "YOUR_API_TOKEN" +``` \ No newline at end of file diff --git a/docs/docs/core-abilities/index.md b/docs/docs/core-abilities/index.md index c9f288bc..51f01b69 100644 --- a/docs/docs/core-abilities/index.md +++ b/docs/docs/core-abilities/index.md @@ -1,6 +1,6 @@ # Core Abilities Qodo Merge utilizes a variety of core abilities to provide a comprehensive and efficient code review experience. These abilities include: - +- [Fetching ticket context](https://qodo-merge-docs.qodo.ai/core-abilities/fetching_ticket_context/) - [Local and global metadata](https://qodo-merge-docs.qodo.ai/core-abilities/metadata/) - [Dynamic context](https://qodo-merge-docs.qodo.ai/core-abilities/dynamic_context/) - [Self-reflection](https://qodo-merge-docs.qodo.ai/core-abilities/self_reflection/) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index f6957536..b168f621 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -43,6 +43,7 @@ nav: - 💎 Similar Code: 'tools/similar_code.md' - Core Abilities: - 'core-abilities/index.md' + - Fetching ticket context: 'core-abilities/fetching_ticket_context.md' - Local and global metadata: 'core-abilities/metadata.md' - Dynamic context: 'core-abilities/dynamic_context.md' - Self-reflection: 'core-abilities/self_reflection.md' From c1f4964a5539bae2c2e67aee43265e4371d3be13 Mon Sep 17 00:00:00 2001 From: "Hussam.lawen" Date: Mon, 4 Nov 2024 16:19:17 +0200 Subject: [PATCH 3/7] update review --- 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 2fd774f6..5c740023 100644 --- a/docs/docs/tools/review.md +++ b/docs/docs/tools/review.md @@ -140,7 +140,7 @@ num_code_suggestions = ... require_ticket_analysis_review - If set to true, and the PR contains a GitHub ticket number, the tool will add a section that checks if the PR in fact fulfilled the ticket requirements. Default is true. + If set to true, and the PR contains a GitHub or Jira ticket link, the tool will add a section that checks if the PR in fact fulfilled the ticket requirements. Default is true. From 5939d3b17b8eb0e5bc826422c452e3b345de93b5 Mon Sep 17 00:00:00 2001 From: "Hussam.lawen" Date: Mon, 4 Nov 2024 16:32:53 +0200 Subject: [PATCH 4/7] readme --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 9bebb2a6..e96d31b5 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,11 @@ Qode Merge PR-Agent aims to help efficiently review and handle pull requests, by ## News and Updates +### November 4, 2024 + +Qodo Merge PR Agent will now leverage context from Jira or GitHub tickets to enhance the PR Feedback. Read more about this feature +[here](https://qodo-merge-docs.qodo.ai/core-abilities/fetching_ticket_context/) + ### November 3, 2024 Meaningful improvement to the quality of code suggestions by separating the code suggestion generation from [line number detection](https://github.com/Codium-ai/pr-agent/pull/1338) From b2181e4c79cec55592c2ccc5af6a5feecb062135 Mon Sep 17 00:00:00 2001 From: "Hussam.lawen" Date: Mon, 4 Nov 2024 16:35:21 +0200 Subject: [PATCH 5/7] typos --- docs/docs/core-abilities/fetching_ticket_context.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/core-abilities/fetching_ticket_context.md b/docs/docs/core-abilities/fetching_ticket_context.md index 851895bf..7b6bd5e7 100644 --- a/docs/docs/core-abilities/fetching_ticket_context.md +++ b/docs/docs/core-abilities/fetching_ticket_context.md @@ -19,7 +19,7 @@ By understanding the reasoning and intent behind modifications, the LLM can offe ### Review tool Similarly to the `describe` tool, the `review` tool will use the ticket content to provide additional context for the code changes. -In addition, This feature will evaluate how well a Pull Request (PR) adheres to its original purpose/intent as defined by the associated ticket or issue mentioned in the PR description. +In addition, this feature will evaluate how well a Pull Request (PR) adheres to its original purpose/intent as defined by the associated ticket or issue mentioned in the PR description. Each ticket will be assigned a label (Compliance/Alignment level), Indicates the degree to which the PR fulfills its original purpose, Options: Fully compliant, Partially compliant or Not compliant. @@ -103,7 +103,7 @@ jira_api_email = "YOUR_EMAIL" #### Jira Server/Data Center 💎 -Currently we only Personal Access Token (PAT) Authentication method. +Currently, we only support the Personal Access Token (PAT) Authentication method. 1. Create a [Personal Access Token (PAT)](https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html) in your Jira account 2. In your [configuration file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/) add the following lines: From eb44ecb1be93da9808ca3d01e9285a0d3a3eb9b5 Mon Sep 17 00:00:00 2001 From: "Hussam.lawen" Date: Mon, 4 Nov 2024 17:18:18 +0200 Subject: [PATCH 6/7] update docs --- docs/docs/core-abilities/fetching_ticket_context.md | 4 ++-- docs/docs/core-abilities/index.md | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/docs/core-abilities/fetching_ticket_context.md b/docs/docs/core-abilities/fetching_ticket_context.md index 7b6bd5e7..cf8aa8d9 100644 --- a/docs/docs/core-abilities/fetching_ticket_context.md +++ b/docs/docs/core-abilities/fetching_ticket_context.md @@ -9,7 +9,7 @@ This integration enriches the review process by automatically surfacing relevant Ticket Recognition Requirements: 1. The PR description should contain a link to the ticket. -2. For Jira tickets, you should follow the instructions in #jira-integration in order to authenticate with Jira. +2. For Jira tickets, you should follow the instructions in [Jira Integration](https://qodo-merge-docs.qodo.ai/core-abilities/fetching_ticket_context/#jira-integration) in order to authenticate with Jira. ### Describe tool @@ -106,7 +106,7 @@ jira_api_email = "YOUR_EMAIL" Currently, we only support the Personal Access Token (PAT) Authentication method. 1. Create a [Personal Access Token (PAT)](https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html) in your Jira account -2. In your [configuration file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/) add the following lines: +2. In your Configuration file/Environment variables/Secrets file, add the following lines: ```toml [jira] diff --git a/docs/docs/core-abilities/index.md b/docs/docs/core-abilities/index.md index 51f01b69..7059b83e 100644 --- a/docs/docs/core-abilities/index.md +++ b/docs/docs/core-abilities/index.md @@ -1,5 +1,6 @@ # Core Abilities Qodo Merge utilizes a variety of core abilities to provide a comprehensive and efficient code review experience. These abilities include: + - [Fetching ticket context](https://qodo-merge-docs.qodo.ai/core-abilities/fetching_ticket_context/) - [Local and global metadata](https://qodo-merge-docs.qodo.ai/core-abilities/metadata/) - [Dynamic context](https://qodo-merge-docs.qodo.ai/core-abilities/dynamic_context/) From 6e3544f52393e0398a84d5bf8e36b3209ad69040 Mon Sep 17 00:00:00 2001 From: Tal Date: Tue, 5 Nov 2024 11:27:38 +0200 Subject: [PATCH 7/7] Update automations_and_usage.md --- .../docs/usage-guide/automations_and_usage.md | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/docs/docs/usage-guide/automations_and_usage.md b/docs/docs/usage-guide/automations_and_usage.md index 57e1adeb..11354503 100644 --- a/docs/docs/usage-guide/automations_and_usage.md +++ b/docs/docs/usage-guide/automations_and_usage.md @@ -72,13 +72,13 @@ The configuration parameter `pr_commands` defines the list of tools that will be ``` [github_app] pr_commands = [ - "/describe --pr_description.final_update_message=false", - "/review --pr_reviewer.num_code_suggestions=0", - "/improve", + "/describe", + "/review", + "/improve --pr_code_suggestions.suggestions_score_threshold=5", ] ``` This means that when a new PR is opened/reopened or marked as ready for review, Qodo Merge will run the `describe`, `review` and `improve` tools. -For the `review` tool, for example, the `num_code_suggestions` parameter will be set to 0. +For the `improve` tool, for example, the `suggestions_score_threshold` parameter will be set to 5 (suggestions below a score of 5 won't be presented) You can override the default tool parameters by using one the three options for a [configuration file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/): **wiki**, **local**, or **global**. For example, if your local `.pr_agent.toml` file contains: @@ -105,7 +105,7 @@ The configuration parameter `push_commands` defines the list of tools that will handle_push_trigger = true push_commands = [ "/describe", - "/review --pr_reviewer.num_code_suggestions=0 --pr_reviewer.final_update_message=false", + "/review", ] ``` This means that when new code is pushed to the PR, the Qodo Merge will run the `describe` and `review` tools, with the specified parameters. @@ -148,12 +148,12 @@ After setting up a GitLab webhook, to control which commands will run automatica [gitlab] pr_commands = [ "/describe", - "/review --pr_reviewer.num_code_suggestions=0", + "/review", "/improve", ] ``` -the GitLab webhook can also respond to new code that is pushed to an open MR. +The GitLab webhook can also respond to new code that is pushed to an open MR. The configuration toggle `handle_push_trigger` can be used to enable this feature. The configuration parameter `push_commands` defines the list of tools that will be **run automatically** when new code is pushed to the MR. ``` @@ -161,7 +161,7 @@ The configuration parameter `push_commands` defines the list of tools that will handle_push_trigger = true push_commands = [ "/describe", - "/review --pr_reviewer.num_code_suggestions=0 --pr_reviewer.final_update_message=false", + "/review", ] ``` @@ -182,7 +182,7 @@ Each time you invoke a `/review` tool, it will use the extra instructions you se Note that among other limitations, BitBucket provides relatively low rate-limits for applications (up to 1000 requests per hour), and does not provide an API to track the actual rate-limit usage. -If you experience lack of responses from Qodo Merge, you might want to set: `bitbucket_app.avoid_full_files=true` in your configuration file. +If you experience a lack of responses from Qodo Merge, you might want to set: `bitbucket_app.avoid_full_files=true` in your configuration file. This will prevent Qodo Merge from acquiring the full file content, and will only use the diff content. This will reduce the number of requests made to BitBucket, at the cost of small decrease in accuracy, as dynamic context will not be applicable. @@ -194,13 +194,23 @@ Specifically, set the following values: ``` [bitbucket_app] pr_commands = [ - "/review --pr_reviewer.num_code_suggestions=0", + "/review", "/improve --pr_code_suggestions.commitable_code_suggestions=true --pr_code_suggestions.suggestions_score_threshold=7", ] ``` Note that we set specifically for bitbucket, we recommend using: `--pr_code_suggestions.suggestions_score_threshold=7` and that is the default value we set for bitbucket. Since this platform only supports inline code suggestions, we want to limit the number of suggestions, and only present a limited number. +To enable BitBucket app to respond to each **push** to the PR, set (for example): +``` +[bitbucket_app] +handle_push_trigger = true +push_commands = [ + "/describe", + "/review", +] +``` + ## Azure DevOps provider To use Azure DevOps provider use the following settings in configuration.toml: @@ -210,7 +220,7 @@ git_provider="azure" ``` Azure DevOps provider supports [PAT token](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows) or [DefaultAzureCredential](https://learn.microsoft.com/en-us/azure/developer/python/sdk/authentication-overview#authentication-in-server-environments) authentication. -PAT is faster to create, but has build in expiration date, and will use the user identity for API calls. +PAT is faster to create, but has a build in expiration date, and will use the user identity for API calls. Using DefaultAzureCredential you can use managed identity or Service principle, which are more secure and will create separate ADO user identity (via AAD) to the agent. If PAT was chosen, you can assign the value in .secrets.toml.