Enabling\\disabling automation \n\n"
output += """\
-- When you first install the app, the [default mode](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) for the describe tool is:
+- When you first install the app, the [default mode](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-app-automatic-tools-when-a-new-pr-is-opened) for the describe tool is:
```
pr_commands = ["/describe --pr_description.add_original_user_description=true"
"--pr_description.keep_original_user_title=true", ...]
@@ -186,7 +186,7 @@ Note that when markers are enabled, if the original PR description does not cont
output += """\
The default labels of the `describe` tool are quite generic: [`Bug fix`, `Tests`, `Enhancement`, `Documentation`, `Other`].
-If you specify [custom labels](https://github.com/Codium-ai/pr-agent/blob/main/docs/DESCRIBE.md#handle-custom-labels-from-the-repos-labels-page-gem) in the repo's labels page or via configuration file, you can get tailored labels for your use cases.
+If you specify [custom labels](https://pr-agent-docs.codium.ai/tools/describe/#handle-custom-labels-from-the-repos-labels-page) in the repo's labels page or via configuration file, 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
@@ -240,7 +240,7 @@ Use triple quotes to write multi-line instructions. Use bullet points to make th
output += ""
- output += f"\n\nSee the [describe usage](https://github.com/Codium-ai/pr-agent/blob/main/docs/DESCRIBE.md) page for a comprehensive guide on using this tool.\n\n"
+ output += f"\n\nSee the [describe usage](https://pr-agent-docs.codium.ai/tools/describe/) page for a comprehensive guide on using this tool.\n\n"
return output
@@ -265,7 +265,7 @@ Note that the tool does not have "memory" of previous questions, and answers eac
output += ""
- output += f"\n\nSee the [ask usage](https://github.com/Codium-ai/pr-agent/blob/main/docs/ASK.md) page for a comprehensive guide on using this tool.\n\n"
+ output += f"\n\nSee the [ask usage](https://pr-agent-docs.codium.ai/tools/ask/) page for a comprehensive guide on using this tool.\n\n"
return output
@@ -274,7 +274,7 @@ Note that the tool does not have "memory" of previous questions, and answers eac
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 tool can be triggered [automatically](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) every time a new PR is opened, or can be invoked manually by commenting on a PR.\n"
+ 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#L69) related to the improve tool (`pr_code_suggestions` section), use the following template:
@@ -282,7 +282,7 @@ When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/
/improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
```
-With a [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#working-with-github-app), use the following template:
+With a [configuration file](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/), use the following template:
```
[pr_code_suggestions]
@@ -296,7 +296,7 @@ some_config2=...
# automation
output += " Enabling\\disabling automation \n\n"
output += """\
-When you first install the app, the [default mode](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) for the improve tool is:
+When you first install the app, the [default mode](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-app-automatic-tools-when-a-new-pr-is-opened) for the improve tool is:
```
pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...]
@@ -335,7 +335,7 @@ Use triple quotes to write multi-line instructions. Use bullet points to make th
output += """\
- While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically.
- Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base.
-- Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the [custom suggestions :gem:](https://github.com/Codium-ai/pr-agent/blob/main/docs/CUSTOM_SUGGESTIONS.md) tool
+- Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the [custom suggestions :gem:](https://pr-agent-docs.codium.ai/tools/custom_suggestions/) tool
- With large PRs, best quality will be obtained by using 'improve --extended' mode.
@@ -349,6 +349,6 @@ Use triple quotes to write multi-line instructions. Use bullet points to make th
output += ""
- output += f"\n\nSee the [improve usage](https://github.com/Codium-ai/pr-agent/blob/main/docs/IMPROVE.md) page for a more comprehensive guide on using this tool.\n\n"
+ output += f"\n\nSee the [improve usage](https://pr-agent-docs.codium.ai/tools/improve/) page for a more comprehensive guide on using this tool.\n\n"
return output
\ No newline at end of file
diff --git a/pr_agent/tools/pr_add_docs.py b/pr_agent/tools/pr_add_docs.py
index d13a829d..a671dd3b 100644
--- a/pr_agent/tools/pr_add_docs.py
+++ b/pr_agent/tools/pr_add_docs.py
@@ -26,6 +26,8 @@ class PRAddDocs:
)
self.ai_handler = ai_handler()
+ self.ai_handler.main_pr_language = self.main_language
+
self.patches_diff = None
self.prediction = None
self.cli_mode = cli_mode
diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py
index 51dbe130..33628123 100644
--- a/pr_agent/tools/pr_code_suggestions.py
+++ b/pr_agent/tools/pr_code_suggestions.py
@@ -46,6 +46,7 @@ class PRCodeSuggestions:
num_code_suggestions = get_settings().pr_code_suggestions.num_code_suggestions
self.ai_handler = ai_handler()
+ self.ai_handler.main_pr_language = self.main_language
self.patches_diff = None
self.prediction = None
self.cli_mode = cli_mode
@@ -393,11 +394,7 @@ class PRCodeSuggestions:
for label, suggestions in suggestions_labels.items():
num_suggestions=len(suggestions)
- # pr_body += f"""{label} | """
pr_body += f""" {label.capitalize()} | \n"""
- # pr_body += f""""""
- # pr_body += f"""{len(suggestions)} suggestions"""
- # pr_body += f""""""
for i, suggestion in enumerate(suggestions):
relevant_file = suggestion['relevant_file'].strip()
@@ -444,11 +441,11 @@ class PRCodeSuggestions:
{example_code}
"""
pr_body += f""
-
pr_body += f""
+
# pr_body += ""
- pr_body += """"""
+ # pr_body += """"""
pr_body += """ """
return pr_body
except Exception as e:
diff --git a/pr_agent/tools/pr_description.py b/pr_agent/tools/pr_description.py
index 33674d00..7500efa7 100644
--- a/pr_agent/tools/pr_description.py
+++ b/pr_agent/tools/pr_description.py
@@ -41,6 +41,7 @@ class PRDescription:
# Initialize the AI handler
self.ai_handler = ai_handler()
+ self.ai_handler.main_pr_language = self.main_pr_language
# Initialize the variables dictionary
@@ -118,11 +119,15 @@ class PRDescription:
if get_settings().config.publish_output:
# publish labels
if get_settings().pr_description.publish_labels and self.git_provider.is_supported("get_labels"):
- original_labels = self.git_provider.get_pr_labels()
+ original_labels = self.git_provider.get_pr_labels(update=True)
get_logger().debug(f"original labels", artifact=original_labels)
user_labels = get_user_labels(original_labels)
- get_logger().debug(f"published labels:\n{pr_labels + user_labels}")
- self.git_provider.publish_labels(pr_labels + user_labels)
+ new_labels = pr_labels + user_labels
+ get_logger().debug(f"published labels", artifact=new_labels)
+ if sorted(new_labels) != sorted(original_labels):
+ self.git_provider.publish_labels(new_labels)
+ else:
+ get_logger().debug(f"Labels are the same, not updating")
# publish description
if get_settings().pr_description.publish_description_as_comment:
diff --git a/pr_agent/tools/pr_generate_labels.py b/pr_agent/tools/pr_generate_labels.py
index 1d91d5e0..4111f7c2 100644
--- a/pr_agent/tools/pr_generate_labels.py
+++ b/pr_agent/tools/pr_generate_labels.py
@@ -35,7 +35,8 @@ class PRGenerateLabels:
# Initialize the AI handler
self.ai_handler = ai_handler()
-
+ self.ai_handler.main_pr_language = self.main_pr_language
+
# Initialize the variables dictionary
self.vars = {
"title": self.git_provider.pr.title,
diff --git a/pr_agent/tools/pr_help_message.py b/pr_agent/tools/pr_help_message.py
index 357a9112..f7a5ff13 100644
--- a/pr_agent/tools/pr_help_message.py
+++ b/pr_agent/tools/pr_help_message.py
@@ -21,21 +21,21 @@ class PRHelpMessage:
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://github.com/Codium-ai/pr-agent/tree/main/docs"
+ base_path = "https://pr-agent-docs.codium.ai/tools"
tool_names = []
- tool_names.append(f"[DESCRIBE]({base_path}/DESCRIBE.md)")
- tool_names.append(f"[REVIEW]({base_path}/REVIEW.md)")
- tool_names.append(f"[IMPROVE]({base_path}/IMPROVE.md)")
- tool_names.append(f"[ANALYZE]({base_path}/Analyze.md) 💎")
- tool_names.append(f"[UPDATE CHANGELOG]({base_path}/UPDATE_CHANGELOG.md)")
- tool_names.append(f"[ADD DOCUMENTATION]({base_path}/ADD_DOCUMENTATION.md) 💎")
- tool_names.append(f"[ASK]({base_path}/ASK.md)")
- tool_names.append(f"[GENERATE CUSTOM LABELS]({base_path}/GENERATE_CUSTOM_LABELS.md)")
- tool_names.append(f"[TEST]({base_path}/TEST.md) 💎")
- tool_names.append(f"[CI FEEDBACK]({base_path}/CI_FEEDBACK.md) 💎")
- tool_names.append(f"[CUSTOM SUGGESTIONS]({base_path}/CUSTOM_SUGGESTIONS.md) 💎")
- tool_names.append(f"[SIMILAR ISSUE]({base_path}/SIMILAR_ISSUE.md)")
+ 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"[TEST]({base_path}/test/) 💎")
+ 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/)")
descriptions = []
descriptions.append("Generates PR description - title, type, summary, code walkthrough and labels")
@@ -91,7 +91,7 @@ class PRHelpMessage:
for i in range(len(tool_names)):
pr_comment += f"\n\n\n{tool_names[i]} | {commands[i]} | {descriptions[i]} | "
pr_comment += "\n\n"
- pr_comment += f"""\n\nNote that each tool be [invoked 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\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:
self.git_provider.publish_comment(pr_comment)
except Exception as e:
diff --git a/pr_agent/tools/pr_information_from_user.py b/pr_agent/tools/pr_information_from_user.py
index 1523d737..03537181 100644
--- a/pr_agent/tools/pr_information_from_user.py
+++ b/pr_agent/tools/pr_information_from_user.py
@@ -21,6 +21,8 @@ class PRInformationFromUser:
self.git_provider.get_languages(), self.git_provider.get_files()
)
self.ai_handler = ai_handler()
+ self.ai_handler.main_pr_language = self.main_pr_language
+
self.vars = {
"title": self.git_provider.pr.title,
"branch": self.git_provider.get_pr_branch(),
diff --git a/pr_agent/tools/pr_line_questions.py b/pr_agent/tools/pr_line_questions.py
index e6386fd1..e26e06d5 100644
--- a/pr_agent/tools/pr_line_questions.py
+++ b/pr_agent/tools/pr_line_questions.py
@@ -22,8 +22,11 @@ class PR_LineQuestions:
def __init__(self, pr_url: str, args=None, ai_handler: partial[BaseAiHandler,] = LiteLLMAIHandler):
self.question_str = self.parse_args(args)
self.git_provider = get_git_provider()(pr_url)
-
+ self.main_pr_language = get_main_pr_language(
+ self.git_provider.get_languages(), self.git_provider.get_files()
+ )
self.ai_handler = ai_handler()
+ self.ai_handler.main_pr_language = self.main_pr_language
self.vars = {
"title": self.git_provider.pr.title,
diff --git a/pr_agent/tools/pr_questions.py b/pr_agent/tools/pr_questions.py
index 7d789e2b..3849029d 100644
--- a/pr_agent/tools/pr_questions.py
+++ b/pr_agent/tools/pr_questions.py
@@ -22,6 +22,8 @@ class PRQuestions:
self.git_provider.get_languages(), self.git_provider.get_files()
)
self.ai_handler = ai_handler()
+ self.ai_handler.main_pr_language = self.main_pr_language
+
self.question_str = question_str
self.vars = {
"title": self.git_provider.pr.title,
diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py
index 04a13a61..19d1bb94 100644
--- a/pr_agent/tools/pr_reviewer.py
+++ b/pr_agent/tools/pr_reviewer.py
@@ -46,6 +46,8 @@ class PRReviewer:
if self.is_answer and not self.git_provider.is_supported("get_issue_comments"):
raise Exception(f"Answer mode is not supported for {get_settings().config.git_provider} for now")
self.ai_handler = ai_handler()
+ self.ai_handler.main_pr_language = self.main_language
+
self.patches_diff = None
self.prediction = None
@@ -108,6 +110,17 @@ class PRReviewer:
relevant_configs = {'pr_reviewer': dict(get_settings().pr_reviewer),
'config': dict(get_settings().config)}
get_logger().debug("Relevant configs", artifacts=relevant_configs)
+
+ if self.incremental.is_incremental and hasattr(self.git_provider, "unreviewed_files_set") and not self.git_provider.unreviewed_files_set:
+ get_logger().info(f"Incremental review is enabled for {self.pr_url} but there are no new files")
+ previous_review_url = ""
+ if hasattr(self.git_provider, "previous_review"):
+ previous_review_url = self.git_provider.previous_review.html_url
+ if get_settings().config.publish_output:
+ self.git_provider.publish_comment(f"Incremental Review Skipped\n"
+ f"No files were changed since the [previous PR Review]({previous_review_url})")
+ return None
+
if get_settings().config.publish_output:
self.git_provider.publish_comment("Preparing review...", is_temporary=True)
@@ -208,21 +221,15 @@ class PRReviewer:
pass
+ incremental_review_markdown_text = None
# Add incremental review section
if self.incremental.is_incremental:
last_commit_url = f"{self.git_provider.get_pr_url()}/commits/" \
f"{self.git_provider.incremental.first_new_commit_sha}"
- last_commit_msg = self.incremental.commits_range[0].commit.message if self.incremental.commits_range else ""
incremental_review_markdown_text = f"Starting from commit {last_commit_url}"
- if last_commit_msg:
- replacement = last_commit_msg.splitlines(keepends=False)[0].replace('_', r'\_')
- incremental_review_markdown_text += f" \n_({replacement})_"
- data = OrderedDict(data)
- data.update({'Incremental PR Review': {
- "⏮️ Review for commits since previous PR-Agent review": incremental_review_markdown_text}})
- data.move_to_end('Incremental PR Review', last=False)
- markdown_text = convert_to_markdown(data, self.git_provider.is_supported("gfm_markdown"))
+ markdown_text = convert_to_markdown(data, self.git_provider.is_supported("gfm_markdown"),
+ incremental_review_markdown_text)
# Add help text if gfm_markdown is supported
if self.git_provider.is_supported("gfm_markdown") and get_settings().pr_reviewer.enable_help_text:
@@ -320,6 +327,10 @@ class PRReviewer:
if self.is_auto and not self.incremental.first_new_commit_sha:
get_logger().info(f"Incremental review is enabled for {self.pr_url} but there are no new commits")
return False
+
+ if not hasattr(self.git_provider, "get_incremental_commits"):
+ get_logger().info(f"Incremental review is not supported for {get_settings().config.git_provider}")
+ return False
# checking if there are enough commits to start the review
num_new_commits = len(self.incremental.commits_range)
num_commits_threshold = get_settings().pr_reviewer.minimal_commits_for_incremental_review
@@ -361,17 +372,20 @@ class PRReviewer:
if security_concerns_bool:
review_labels.append('Possible security concern')
- current_labels = self.git_provider.get_pr_labels()
+ current_labels = self.git_provider.get_pr_labels(update=True)
+ get_logger().debug(f"Current labels:\n{current_labels}")
if current_labels:
current_labels_filtered = [label for label in current_labels if
not label.lower().startswith('review effort [1-5]:') and not label.lower().startswith(
'possible security concern')]
else:
current_labels_filtered = []
- if current_labels or review_labels:
- get_logger().debug(f"Current labels:\n{current_labels}")
+ new_labels = review_labels + current_labels_filtered
+ if (current_labels or review_labels) and sorted(new_labels) != sorted(current_labels):
get_logger().info(f"Setting review labels:\n{review_labels + current_labels_filtered}")
- self.git_provider.publish_labels(review_labels + current_labels_filtered)
+ self.git_provider.publish_labels(new_labels)
+ else:
+ get_logger().info(f"Review labels are already set:\n{review_labels + current_labels_filtered}")
except Exception as e:
get_logger().error(f"Failed to set review labels, error: {e}")
diff --git a/pr_agent/tools/pr_update_changelog.py b/pr_agent/tools/pr_update_changelog.py
index 4e168d5d..399e0599 100644
--- a/pr_agent/tools/pr_update_changelog.py
+++ b/pr_agent/tools/pr_update_changelog.py
@@ -26,7 +26,10 @@ class PRUpdateChangelog:
)
self.commit_changelog = get_settings().pr_update_changelog.push_changelog_changes
self._get_changlog_file() # self.changelog_file_str
+
self.ai_handler = ai_handler()
+ self.ai_handler.main_pr_language = self.main_language
+
self.patches_diff = None
self.prediction = None
self.cli_mode = cli_mode
| | |