From fd6e81978fe9403dd5be2a5284095c901a9696ea Mon Sep 17 00:00:00 2001 From: mrT23 Date: Tue, 31 Dec 2024 08:32:54 +0200 Subject: [PATCH 1/4] fix: improve PR description and title field descriptions for clarity --- pr_agent/settings/pr_description_prompts.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pr_agent/settings/pr_description_prompts.toml b/pr_agent/settings/pr_description_prompts.toml index fc522c31..315bc7ac 100644 --- a/pr_agent/settings/pr_description_prompts.toml +++ b/pr_agent/settings/pr_description_prompts.toml @@ -52,8 +52,8 @@ class PRDescription(BaseModel): {%- if enable_semantic_files_types %} pr_files: List[FileDescription] = Field(max_items=20, description="a list of all the files that were changed in the PR, and summary of their changes. Each file must be analyzed regardless of change size.") {%- endif %} - description: str = Field(description="an informative and concise description of the PR. Use bullet points. Display first the most significant changes.") - title: str = Field(description="an informative title for the PR, describing its main theme") + description: str = Field(description="a clear and concise description of the PR using bullet points (with sub-bullets if needed). Prioritize the most significant changes first") + title: str = Field(description="a concise and descriptive title that captures the PR's main theme") ===== From 6fbd95e1a9d9f69c830da201a38867e6c55d6d98 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Tue, 31 Dec 2024 08:36:32 +0200 Subject: [PATCH 2/4] fix: emphasize brevity in PR description bullet points --- pr_agent/settings/pr_description_prompts.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/settings/pr_description_prompts.toml b/pr_agent/settings/pr_description_prompts.toml index 315bc7ac..9748cbce 100644 --- a/pr_agent/settings/pr_description_prompts.toml +++ b/pr_agent/settings/pr_description_prompts.toml @@ -52,7 +52,7 @@ class PRDescription(BaseModel): {%- if enable_semantic_files_types %} pr_files: List[FileDescription] = Field(max_items=20, description="a list of all the files that were changed in the PR, and summary of their changes. Each file must be analyzed regardless of change size.") {%- endif %} - description: str = Field(description="a clear and concise description of the PR using bullet points (with sub-bullets if needed). Prioritize the most significant changes first") + description: str = Field(description="a clear and concise description of the PR using short bullet points (with sub-bullets if needed). Prioritize the most significant changes first") title: str = Field(description="a concise and descriptive title that captures the PR's main theme") ===== From 4a1b042152036ad2fd93e9415492eecea8c3bb8b Mon Sep 17 00:00:00 2001 From: mrT23 Date: Tue, 31 Dec 2024 12:00:21 +0200 Subject: [PATCH 3/4] fix: improve bullet point formatting and file path display in PR description --- pr_agent/algo/pr_processing.py | 3 ++- pr_agent/settings/pr_description_prompts.toml | 2 +- pr_agent/tools/pr_description.py | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pr_agent/algo/pr_processing.py b/pr_agent/algo/pr_processing.py index 78c15438..6d5a86d9 100644 --- a/pr_agent/algo/pr_processing.py +++ b/pr_agent/algo/pr_processing.py @@ -205,10 +205,11 @@ def pr_generate_extended_diff(pr_languages: list, if not extended_patch: get_logger().warning(f"Failed to extend patch for file: {file.filename}") continue - full_extended_patch = f"\n\n## {file.filename}\n{extended_patch.rstrip()}\n" if add_line_numbers_to_hunks: full_extended_patch = convert_to_hunks_with_lines_numbers(extended_patch, file) + else: + full_extended_patch = f"\n\n## File: '{file.filename.strip()}'\n{extended_patch.rstrip()}\n" # add AI-summary metadata to the patch if file.ai_file_summary and get_settings().get("config.enable_ai_metadata", False): diff --git a/pr_agent/settings/pr_description_prompts.toml b/pr_agent/settings/pr_description_prompts.toml index 9748cbce..7e93d9da 100644 --- a/pr_agent/settings/pr_description_prompts.toml +++ b/pr_agent/settings/pr_description_prompts.toml @@ -52,7 +52,7 @@ class PRDescription(BaseModel): {%- if enable_semantic_files_types %} pr_files: List[FileDescription] = Field(max_items=20, description="a list of all the files that were changed in the PR, and summary of their changes. Each file must be analyzed regardless of change size.") {%- endif %} - description: str = Field(description="a clear and concise description of the PR using short bullet points (with sub-bullets if needed). Prioritize the most significant changes first") + description: str = Field(description="summarize the PR changes in up to four bullet points, each up to 8 words. Add sub-bullets if needed. Order bullets by importance, with each bullet highlighting a key change group.") title: str = Field(description="a concise and descriptive title that captures the PR's main theme") ===== diff --git a/pr_agent/tools/pr_description.py b/pr_agent/tools/pr_description.py index b610e83b..18df4f10 100644 --- a/pr_agent/tools/pr_description.py +++ b/pr_agent/tools/pr_description.py @@ -556,6 +556,11 @@ class PRDescription: elif 'pr_files' in key.lower() and get_settings().pr_description.enable_semantic_files_types: changes_walkthrough, pr_file_changes = self.process_pr_files_prediction(changes_walkthrough, value) changes_walkthrough = f"{PRDescriptionHeader.CHANGES_WALKTHROUGH.value}\n{changes_walkthrough}" + elif key.lower().strip() == 'description': + if isinstance(value, list): + value = ', '.join(v.rstrip() for v in value) + value = value.replace('\n-', '\n\n-').strip() # makes the bullet points more readable by adding double space + pr_body += f"{value}\n" else: # if the value is a list, join its items by comma if isinstance(value, list): From 6e80f5fcce5a047ca5e32555ab2e359de7c48311 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Tue, 31 Dec 2024 12:31:21 +0200 Subject: [PATCH 4/4] fix: improve file path formatting in patch headers --- tests/unittest/test_extend_patch.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/unittest/test_extend_patch.py b/tests/unittest/test_extend_patch.py index 6689186c..dfe4c502 100644 --- a/tests/unittest/test_extend_patch.py +++ b/tests/unittest/test_extend_patch.py @@ -145,8 +145,8 @@ class TestExtendedPatchMoreLines: # Check that with no extra lines, the patches are the same as the original patches p0 = patches_extended_no_extra_lines[0].strip() p1 = patches_extended_no_extra_lines[1].strip() - assert p0 == '## file1\n' + pr_languages[0]['files'][0].patch.strip() - assert p1 == '## file2\n' + pr_languages[0]['files'][1].patch.strip() + assert p0 == "## File: 'file1'\n" + pr_languages[0]['files'][0].patch.strip() + assert p1 == "## File: 'file2'\n" + pr_languages[0]['files'][1].patch.strip() patches_extended_with_extra_lines, total_tokens, patches_extended_tokens = pr_generate_extended_diff( pr_languages, token_handler, add_line_numbers_to_hunks=False, @@ -154,5 +154,6 @@ class TestExtendedPatchMoreLines: patch_extra_lines_after=1 ) + p0_extended = patches_extended_with_extra_lines[0].strip() - assert p0_extended == '## file1\n\n@@ -3,8 +3,8 @@ \n line0\n line1\n-original content\n+modified content\n line2\n line3\n line4\n line5\n line6' + assert p0_extended == "## File: 'file1'\n\n@@ -3,8 +3,8 @@ \n line0\n line1\n-original content\n+modified content\n line2\n line3\n line4\n line5\n line6"