From 34ad5f2aa29bea735c60d94f06d4dd179a509217 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 5 May 2024 13:33:54 +0300 Subject: [PATCH 1/3] toolbar emojis in pr-agent feedbacks --- pr_agent/algo/utils.py | 8 ++++---- pr_agent/git_providers/git_provider.py | 6 +++--- pr_agent/servers/help.py | 2 +- pr_agent/settings/configuration.toml | 8 ++++---- pr_agent/tools/pr_code_suggestions.py | 10 +++++----- pr_agent/tools/pr_description.py | 10 +++++++--- pr_agent/tools/pr_questions.py | 6 +++--- pr_agent/tools/pr_reviewer.py | 4 ++-- pr_agent/tools/pr_update_changelog.py | 4 ++-- tests/unittest/test_convert_to_markdown.py | 2 +- 10 files changed, 32 insertions(+), 28 deletions(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index a3fd82bdf..b877106dc 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -68,11 +68,11 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool = True, increment output_data (dict): A dictionary containing data to be converted to markdown format. Returns: str: The markdown formatted text generated from the input dictionary. - """ + """ emojis = { "Can be split": "๐Ÿ”€", - "Possible issues": "๐Ÿ”", + "Possible issues": "โšก", "Score": "๐Ÿ…", "Relevant tests": "๐Ÿงช", "Focused PR": "โœจ", @@ -83,9 +83,9 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool = True, increment } markdown_text = "" if not incremental_review: - markdown_text += f"## PR Review\n\n" + markdown_text += f"## PR Review ๐Ÿ”\n\n" else: - markdown_text += f"## Incremental PR Review\n\n" + markdown_text += f"## Incremental PR Review ๐Ÿ” \n\n" markdown_text += f"โฎ๏ธ Review for commits since previous PR-Agent review {incremental_review}.\n\n" if gfm_supported: markdown_text += "\n\n" diff --git a/pr_agent/git_providers/git_provider.py b/pr_agent/git_providers/git_provider.py index a7d772b7e..0ff5caf1e 100644 --- a/pr_agent/git_providers/git_provider.py +++ b/pr_agent/git_providers/git_provider.py @@ -71,7 +71,7 @@ def get_user_description(self) -> str: # if the existing description was generated by the pr-agent, but it doesn't contain a user description, # return nothing (empty string) because it means there is no user description - user_description_header = "## **user description**" + user_description_header = "### **user description**" if user_description_header not in description_lowercase: get_logger().info(f"Existing description was generated by the pr-agent, but it doesn't contain a user description") return "" @@ -102,8 +102,8 @@ def get_user_description(self) -> str: return original_user_description def _possible_headers(self): - return ("## **user description**", "## **pr type**", "## **pr description**", "## **pr labels**", "## **type**", "## **description**", - "## **labels**", "### ๐Ÿค– generated by pr agent") + return ("### **user description**", "### **pr type**", "### **pr description**", "### **pr labels**", "### **type**", "### **description**", + "### **labels**", "### ๐Ÿค– generated by pr agent") def _is_generated_by_pr_agent(self, description_lowercase: str) -> bool: possible_headers = self._possible_headers() diff --git a/pr_agent/servers/help.py b/pr_agent/servers/help.py index 07ade44c6..5578fb0f5 100644 --- a/pr_agent/servers/help.py +++ b/pr_agent/servers/help.py @@ -179,7 +179,7 @@ def get_ask_usage_guide(): @staticmethod def get_improve_usage_guide(): output = "**Overview:**\n" - output += "The `improve` tool scans the PR code changes, and automatically generates suggestions for improving the PR code. " + output += "The code suggestions tool, named `improve`, scans the PR code changes, and automatically generates code suggestions for improving the PR." output += "The tool can be triggered [automatically](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-app-automatic-tools-when-a-new-pr-is-opened) every time a new PR is opened, or can be invoked manually by commenting on a PR.\n" output += """\ - When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L78) related to the improve tool (`pr_code_suggestions` section), use the following template: diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 22ed6ccc0..b2c65a3d0 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -44,7 +44,7 @@ enable_review_labels_effort=true require_all_thresholds_for_incremental_review=false minimal_commits_for_incremental_review=0 minimal_minutes_for_incremental_review=0 -enable_help_text=true # Determines whether to include help text in the PR review. Enabled by default. +enable_help_text=false # Determines whether to include help text in the PR review. Enabled by default. # auto approval enable_auto_approval=false maximal_review_effort=5 @@ -74,7 +74,7 @@ include_generated_by_header=true #custom_labels = ['Bug fix', 'Tests', 'Bug fix with tests', 'Enhancement', 'Documentation', 'Other'] [pr_questions] # /ask # -enable_help_text=true +enable_help_text=false [pr_code_suggestions] # /improve # @@ -83,7 +83,7 @@ num_code_suggestions=4 commitable_code_suggestions = false extra_instructions = "" rank_suggestions = false -enable_help_text=true +enable_help_text=false persistent_comment=false # params for '/improve --extended' mode auto_extended_mode=true @@ -110,7 +110,7 @@ num_tests=3 # number of tests to generate. max 5. avoid_mocks=true # if true, the generated tests will prefer to use real objects instead of mocks 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 -enable_help_text=true +enable_help_text=false [pr_improve_component] # /improve_component # num_code_suggestions=4 diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index 813ccbfaf..ff4eb96fa 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -90,7 +90,7 @@ async def run(self): if (not data) or (not 'code_suggestions' in data) or (not data['code_suggestions']): get_logger().error('No code suggestions found for PR.') - pr_body = "## PR Code Suggestions\n\nNo code suggestions found for PR." + pr_body = "## PR Code Suggestions โœจ\n\nNo code suggestions found for 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) @@ -113,14 +113,14 @@ async def run(self): # add usage guide if get_settings().pr_code_suggestions.enable_help_text: - pr_body += "
\n\n
โœจ Improve tool usage guide:
\n\n" + pr_body += "
\n\n
๐Ÿ’ก Tool usage guide:
\n\n" pr_body += HelpMessage.get_improve_usage_guide() pr_body += "\n
\n" if get_settings().pr_code_suggestions.persistent_comment: final_update_message = False self.git_provider.publish_persistent_comment(pr_body, - initial_header="## PR Code Suggestions", + initial_header="## PR Code Suggestions โœจ", update_header=True, name="suggestions", final_update_message=final_update_message, ) @@ -382,7 +382,7 @@ async def rank_suggestions(self, data: List) -> List: def generate_summarized_suggestions(self, data: Dict) -> str: try: - pr_body = "## PR Code Suggestions\n\n" + pr_body = "## PR Code Suggestions โœจ\n\n" if len(data.get('code_suggestions', [])) == 0: pr_body += "No suggestions found to improve this PR." @@ -394,7 +394,7 @@ def generate_summarized_suggestions(self, data: Dict) -> str: for ext in extensions: extension_to_language[ext] = language - pr_body = "## PR Code Suggestions\n\n" + pr_body = "## PR Code Suggestions โœจ\n\n" pr_body += "
" header = f"Suggestions" diff --git a/pr_agent/tools/pr_description.py b/pr_agent/tools/pr_description.py index fa662464e..661d9dd83 100644 --- a/pr_agent/tools/pr_description.py +++ b/pr_agent/tools/pr_description.py @@ -113,7 +113,7 @@ async def run(self): pr_body += HelpMessage.get_describe_usage_guide() pr_body += "\n\n" elif get_settings().pr_description.enable_help_comment: - pr_body += "\n\n___\n\n> โœจ **PR-Agent usage**:" + pr_body += "\n\n___\n\n> ๐Ÿ’ก **PR-Agent usage**:" pr_body += "\n>Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions\n\n" if get_settings().config.publish_output: @@ -317,7 +317,11 @@ def _prepare_pr_answer(self) -> Tuple[str, str, str, List[dict]]: value = self.file_label_dict else: key_publish = key.rstrip(':').replace("_", " ").capitalize() - pr_body += f"## **{key_publish}**\n" + if key_publish== "Type": + key_publish = "PR Type" + # elif key_publish == "Description": + # key_publish = "PR Description" + pr_body += f"### **{key_publish}**\n" if 'walkthrough' in key.lower(): if self.git_provider.is_supported("gfm_markdown"): pr_body += "
files:\n\n" @@ -329,7 +333,7 @@ def _prepare_pr_answer(self) -> Tuple[str, str, str, List[dict]]: pr_body += "
\n" elif 'pr_files' in key.lower(): changes_walkthrough, pr_file_changes = self.process_pr_files_prediction(changes_walkthrough, value) - changes_walkthrough = f"## **Changes walkthrough**\n{changes_walkthrough}" + changes_walkthrough = f"### **Changes walkthrough** ๐Ÿ“\n{changes_walkthrough}" else: # if the value is a list, join its items by comma if isinstance(value, list): diff --git a/pr_agent/tools/pr_questions.py b/pr_agent/tools/pr_questions.py index d78d08803..78db1452b 100644 --- a/pr_agent/tools/pr_questions.py +++ b/pr_agent/tools/pr_questions.py @@ -68,7 +68,7 @@ async def run(self): get_logger().debug(f"PR output", artifact=pr_comment) if self.git_provider.is_supported("gfm_markdown") and get_settings().pr_questions.enable_help_text: - pr_comment += "
\n\n
โœจ Ask tool usage guide:
\n\n" + pr_comment += "
\n\n
๐Ÿ’ก Tool usage guide:
\n\n" pr_comment += HelpMessage.get_ask_usage_guide() pr_comment += "\n
\n" @@ -116,6 +116,6 @@ async def _get_prediction(self, model: str): return response def _prepare_pr_answer(self) -> str: - answer_str = f"Question: {self.question_str}\n\n" - answer_str += f"Answer:\n{self.prediction.strip()}\n\n" + answer_str = f"### **Ask**โ“\n{self.question_str}\n\n" + answer_str += f"### **Answer:**\n{self.prediction.strip()}\n\n" return answer_str diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index 33149cad1..46036816b 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -137,7 +137,7 @@ async def run(self) -> None: if get_settings().pr_reviewer.persistent_comment and not self.incremental.is_incremental: final_update_message = get_settings().pr_reviewer.final_update_message self.git_provider.publish_persistent_comment(pr_review, - initial_header="## PR Review", + initial_header="## PR Review ๐Ÿ”", update_header=True, final_update_message=final_update_message, ) else: @@ -234,7 +234,7 @@ def _prepare_pr_review(self) -> str: # Add help text if gfm_markdown is supported if self.git_provider.is_supported("gfm_markdown") and get_settings().pr_reviewer.enable_help_text: - markdown_text += "
\n\n
โœจ Review tool usage guide:
\n\n" + markdown_text += "
\n\n
๐Ÿ’ก Tool usage guide:
\n\n" markdown_text += HelpMessage.get_review_usage_guide() markdown_text += "\n
\n" diff --git a/pr_agent/tools/pr_update_changelog.py b/pr_agent/tools/pr_update_changelog.py index 399e05990..1475d9f21 100644 --- a/pr_agent/tools/pr_update_changelog.py +++ b/pr_agent/tools/pr_update_changelog.py @@ -81,7 +81,7 @@ async def run(self): if self.commit_changelog: self._push_changelog_update(new_file_content, answer) else: - self.git_provider.publish_comment(f"**Changelog updates:**\n\n{answer}") + self.git_provider.publish_comment(f"**Changelog updates:** ๐Ÿ”„\n\n{answer}") async def _prepare_prediction(self, model: str): self.patches_diff = get_pr_diff(self.git_provider, self.token_handler, model) @@ -141,7 +141,7 @@ def _push_changelog_update(self, new_file_content, answer): self.git_provider.pr.create_review(commit=last_commit_id, comments=[d]) except Exception: # we can't create a review for some reason, let's just publish a comment - self.git_provider.publish_comment(f"**Changelog updates:**\n\n{answer}") + self.git_provider.publish_comment(f"**Changelog updates: ๐Ÿ”„**\n\n{answer}") def _get_default_changelog(self): example_changelog = \ diff --git a/tests/unittest/test_convert_to_markdown.py b/tests/unittest/test_convert_to_markdown.py index 9b071a747..ad8f49735 100644 --- a/tests/unittest/test_convert_to_markdown.py +++ b/tests/unittest/test_convert_to_markdown.py @@ -52,7 +52,7 @@ def test_simple_dictionary_input(self): 'suggestion': "Consider raising an exception or logging a warning when 'pr_url' attribute is not found. This can help in debugging issues related to the absence of 'pr_url' in instances where it's expected. [important]\n", 'relevant_line': '[return ""](https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199)'}]} - expected_output = '## PR Review\n\n
\n\n\n\n\n\n
โฑ๏ธ Estimated effort to review [1-5]\n\n1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n\n\n
๐Ÿงช Relevant tests\n\nNo\n\n\n
๐Ÿ” Possible issues\n\nNo\n\n
๐Ÿ”’ Security concerns\n\nNo\n\n
\n\n\n
Code feedback:\n\n
relevant filepr_agent/git_providers/git_provider.py\n
suggestion      \n\n\n\nConsider raising an exception or logging a warning when \'pr_url\' attribute is not found. This can help in debugging issues related to the absence of \'pr_url\' in instances where it\'s expected. [important]\n\n\n
relevant linereturn ""

\n\n
' + expected_output = '## PR Review ๐Ÿ”\n\n\n\n\n\n\n\n
โฑ๏ธ Estimated effort to review [1-5]\n\n1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n\n\n
๐Ÿงช Relevant tests\n\nNo\n\n\n
๐Ÿ” Possible issues\n\nNo\n\n
๐Ÿ”’ Security concerns\n\nNo\n\n
\n\n\n
Code feedback:\n\n
relevant filepr_agent/git_providers/git_provider.py\n
suggestion      \n\n\n\nConsider raising an exception or logging a warning when \'pr_url\' attribute is not found. This can help in debugging issues related to the absence of \'pr_url\' in instances where it\'s expected. [important]\n\n\n
relevant linereturn ""

\n\n
' assert convert_to_markdown(input_data).strip() == expected_output.strip() From e4157d2efc676e4fe388a7b840496caec2dc66fb Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 5 May 2024 13:36:34 +0300 Subject: [PATCH 2/3] toolbar emojis in pr-agent feedbacks --- tests/unittest/test_convert_to_markdown.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unittest/test_convert_to_markdown.py b/tests/unittest/test_convert_to_markdown.py index ad8f49735..676d0eea8 100644 --- a/tests/unittest/test_convert_to_markdown.py +++ b/tests/unittest/test_convert_to_markdown.py @@ -52,7 +52,7 @@ def test_simple_dictionary_input(self): 'suggestion': "Consider raising an exception or logging a warning when 'pr_url' attribute is not found. This can help in debugging issues related to the absence of 'pr_url' in instances where it's expected. [important]\n", 'relevant_line': '[return ""](https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199)'}]} - expected_output = '## PR Review ๐Ÿ”\n\n\n\n\n\n\n\n
โฑ๏ธ Estimated effort to review [1-5]\n\n1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n\n\n
๐Ÿงช Relevant tests\n\nNo\n\n\n
๐Ÿ” Possible issues\n\nNo\n\n
๐Ÿ”’ Security concerns\n\nNo\n\n
\n\n\n
Code feedback:\n\n
relevant filepr_agent/git_providers/git_provider.py\n
suggestion      \n\n\n\nConsider raising an exception or logging a warning when \'pr_url\' attribute is not found. This can help in debugging issues related to the absence of \'pr_url\' in instances where it\'s expected. [important]\n\n\n
relevant linereturn ""

\n\n
' + expected_output = '## PR Review ๐Ÿ”\n\n\n\n\n\n\n\n
โฑ๏ธ Estimated effort to review [1-5]\n\n1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n\n\n
๐Ÿงช Relevant tests\n\nNo\n\n\n
โšก Possible issues\n\nNo\n\n
๐Ÿ”’ Security concerns\n\nNo\n\n
\n\n\n
Code feedback:\n\n
relevant filepr_agent/git_providers/git_provider.py\n
suggestion      \n\n\n\nConsider raising an exception or logging a warning when \'pr_url\' attribute is not found. This can help in debugging issues related to the absence of \'pr_url\' in instances where it\'s expected. [important]\n\n\n
relevant linereturn ""

\n\n
' assert convert_to_markdown(input_data).strip() == expected_output.strip() From 097637d7c08ce670c06d718ead66d7bf1cec09fb Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 5 May 2024 13:48:45 +0300 Subject: [PATCH 3/3] toolbar emojis in pr-agent feedbacks --- pr_agent/tools/pr_help_message.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pr_agent/tools/pr_help_message.py b/pr_agent/tools/pr_help_message.py index df2698cfb..9f76434da 100644 --- a/pr_agent/tools/pr_help_message.py +++ b/pr_agent/tools/pr_help_message.py @@ -18,8 +18,8 @@ async def run(self): relevant_configs = {'pr_help': dict(get_settings().pr_help), 'config': dict(get_settings().config)} get_logger().debug("Relevant configs", artifacts=relevant_configs) - pr_comment = "## PR Agent Walkthrough\n\n" - pr_comment += "๐Ÿค– Welcome to the PR Agent, an AI-powered tool for automated pull request analysis, feedback, suggestions and more.""" + pr_comment = "## PR Agent Walkthrough ๐Ÿค–\n\n" + pr_comment += "Welcome to the PR Agent, an AI-powered tool for automated pull request analysis, feedback, suggestions and more.""" pr_comment += "\n\nHere is a list of tools you can use to interact with the PR Agent:\n" base_path = "https://pr-agent-docs.codium.ai/tools"