help improved

This commit is contained in:
mrT23
2024-02-19 20:40:24 +02:00
parent c3ff5c46a6
commit 34e89e45bd
3 changed files with 92 additions and 18 deletions

View File

@ -58,7 +58,8 @@ use_bullet_points=true
extra_instructions = "" extra_instructions = ""
enable_pr_type=true enable_pr_type=true
final_update_message = true final_update_message = true
enable_help_text=true enable_help_text=false
enable_help_comment=true
## changes walkthrough section ## changes walkthrough section
enable_semantic_files_types=true enable_semantic_files_types=true
collapsible_file_list='adaptive' # true, false, 'adaptive' collapsible_file_list='adaptive' # true, false, 'adaptive'

View File

@ -11,7 +11,7 @@ from pr_agent.algo.pr_processing import get_pr_diff, retry_with_fallback_models
from pr_agent.algo.token_handler import TokenHandler from pr_agent.algo.token_handler import TokenHandler
from pr_agent.algo.utils import load_yaml, set_custom_labels, get_user_labels, ModelType from pr_agent.algo.utils import load_yaml, set_custom_labels, get_user_labels, ModelType
from pr_agent.config_loader import get_settings from pr_agent.config_loader import get_settings
from pr_agent.git_providers import get_git_provider from pr_agent.git_providers import get_git_provider, GithubProvider
from pr_agent.git_providers.git_provider import get_main_pr_language from pr_agent.git_providers.git_provider import get_main_pr_language
from pr_agent.log import get_logger from pr_agent.log import get_logger
from pr_agent.servers.help import HelpMessage from pr_agent.servers.help import HelpMessage
@ -106,6 +106,12 @@ class PRDescription:
pr_body += "<hr>\n\n<details> <summary><strong>✨ Usage guide:</strong></summary><hr> \n\n" pr_body += "<hr>\n\n<details> <summary><strong>✨ Usage guide:</strong></summary><hr> \n\n"
pr_body += HelpMessage.get_describe_usage_guide() pr_body += HelpMessage.get_describe_usage_guide()
pr_body += "\n</details>\n" pr_body += "\n</details>\n"
elif get_settings().pr_description.enable_help_comment:
if isinstance(self.git_provider, GithubProvider):
pr_body +="\n\n___\n\n✨ **PR-Agent usage guide**:\n\n- [ ] Mark this checkbox :gem:, or comment `/help` on the PR, to get a list of PR-Agent tools and their descriptions. <!-- /help -->"
else:
pr_body +="\n\n___\n\n>Comment `/help` on the PR to to get a list of PR-Agent tools and their descriptions\n\n___\n\n"
# final markdown description # final markdown description
full_markdown_description = f"## Title\n\n{pr_title}\n\n___\n{pr_body}" full_markdown_description = f"## Title\n\n{pr_title}\n\n___\n{pr_body}"

View File

@ -1,5 +1,5 @@
from pr_agent.config_loader import get_settings from pr_agent.config_loader import get_settings
from pr_agent.git_providers import get_git_provider from pr_agent.git_providers import get_git_provider, GithubProvider
from pr_agent.log import get_logger from pr_agent.log import get_logger
@ -14,21 +14,88 @@ class PRHelpMessage:
pr_comment += "🤖 Welcome to the PR Agent, an AI-powered tool for automated pull request analysis, feedback, suggestions and more.""" 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" 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://github.com/Codium-ai/pr-agent/tree/main/docs"
pr_comment += f"<table><tr><th>Tool</th><th align='left'>Description</th></tr>"
pr_comment += f"\n<tr><td align='center'>\n\n<strong>[DESCRIBE]({base_path}/DESCRIBE.md)</strong></td><td>Generates PR description - title, type, summary, code walkthrough and labels</td></tr>" tool_names = []
pr_comment += f"\n<tr><td align='center'>\n\n<strong>[REVIEW]({base_path}/REVIEW.md)</strong></td><td>Adjustable feedback about the PR, possible issues, security concerns, review effort and more</td></tr>" tool_names.append(f"[DESCRIBE]({base_path}/DESCRIBE.md)")
pr_comment += f"\n<tr><td align='center'>\n\n<strong>[IMPROVE]({base_path}/IMPROVE.md)</strong></td><td>Code suggestions for improving the PR.</td></tr>" tool_names.append(f"[REVIEW]({base_path}/REVIEW.md)")
pr_comment += f"\n<tr><td align='center'>\n\n<strong>[ASK]({base_path}/ASK.md)</strong></td><td>Answering free-text questions about the PR.</td></tr>" tool_names.append(f"[IMPROVE]({base_path}/IMPROVE.md)")
pr_comment += f"\n<tr><td align='center'>\n\n<strong>[SIMILAR ISSUE]({base_path}/SIMILAR_ISSUE.md)</strong></td><td>Automatically retrieves and presents similar issues.</td></tr>" tool_names.append(f"[ANALYZE]({base_path}/Analyze.md)")
pr_comment += f"\n<tr><td align='center'>\n\n<strong>[UPDATE CHANGELOG]({base_path}/UPDATE_CHANGELOG.md)</strong></td><td>Automatically updates the changelog.</td></tr>" tool_names.append(f"[UPDATE CHANGELOG]({base_path}/UPDATE_CHANGELOG.md)")
pr_comment += f"\n<tr><td align='center'>\n\n<strong>[ADD DOCUMENTATION]({base_path}/ADD_DOCUMENTATION.md)</strong></td><td>Generates documentation to methods/functions/classes that changed in the PR.</td></tr>" tool_names.append(f"[ADD DOCUMENTATION]({base_path}/ADD_DOCUMENTATION.md)")
pr_comment += f"\n<tr><td align='center'>\n\n<strong>[GENERATE CUSTOM LABELS]({base_path}/GENERATE_CUSTOM_LABELS.md)</strong></td><td>Generates custom labels for the PR, based on specific guidelines defined by the user</td></tr>" tool_names.append(f"[ASK]({base_path}/ASK.md)")
pr_comment += f"\n<tr><td align='center'>\n\n<strong>[ANALYZE]({base_path}/Analyze.md)</strong></td><td>Identifies code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component.</td></tr>" tool_names.append(f"[GENERATE CUSTOM LABELS]({base_path}/GENERATE_CUSTOM_LABELS.md)")
pr_comment += f"\n<tr><td align='center'>\n\n<strong>[TEST]({base_path}/TEST.md)</strong></td><td>Generates unit tests for a selected component, based on the PR code change.</td></tr>" tool_names.append(f"[TEST]({base_path}/TEST.md)")
pr_comment += f"\n<tr><td align='center'>\n\n<strong>[CI FEEDBACK]({base_path}/CI_FEEDBACK.md)</strong></td><td>Generates feedback and analysis for a failed CI job.</td></tr>" tool_names.append(f"[CI FEEDBACK]({base_path}/CI_FEEDBACK.md)")
pr_comment += f"\n<tr><td align='center'>\n\n<strong>[CUSTOM SUGGESTIONS]({base_path}/CUSTOM_SUGGESTIONS.md)</strong></td><td>Generates custom suggestions for improving the PR code, based on specific guidelines defined by the user.</td></tr>" tool_names.append(f"[CUSTOM SUGGESTIONS]({base_path}/CUSTOM_SUGGESTIONS.md)")
pr_comment += "</table>\n\n" tool_names.append(f"[SIMILAR ISSUE]({base_path}/SIMILAR_ISSUE.md)")
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)."""
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("Generates custom labels for the PR, based on specific guidelines defined by the user")
descriptions.append("Generates unit tests for a selected 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.")
commands =[]
commands.append("`/describe`")
commands.append("`/review`")
commands.append("`/improve`")
commands.append("`/analyze`")
commands.append("`/update_changelog`")
commands.append("`/add_docs`")
commands.append("`/ask`")
commands.append("`/generate_labels`")
commands.append("`/test`")
commands.append("`/checks`")
commands.append("`/custom_suggestions`")
commands.append("`/similar_issue`")
checkbox_list = []
checkbox_list.append(" - [ ] Send <!-- /describe -->")
checkbox_list.append(" - [ ] Send <!-- /review -->")
checkbox_list.append(" - [ ] Send <!-- /improve -->")
checkbox_list.append(" - [ ] Send <!-- /analyze -->")
checkbox_list.append(" - [ ] Send <!-- /update_changelog -->")
checkbox_list.append(" - [ ] Send <!-- /add_docs -->")
checkbox_list.append("[*]")
checkbox_list.append("[*]")
checkbox_list.append("[*]")
checkbox_list.append("[*]")
checkbox_list.append("[*]")
checkbox_list.append("[*]")
if isinstance(self.git_provider, GithubProvider):
pr_comment += f"<table><tr align='center'><th align='center'>Tool</th><th align='left'>Description</th><th align='left'>Run this command :gem:</th></tr>"
for i in range(len(tool_names)):
pr_comment += f"\n<tr><td align='center'>\n\n<strong>{tool_names[i]}</strong></td>\n<td>{descriptions[i]}</td>\n<td>\n\n{checkbox_list[i]}\n</td></tr>"
pr_comment += "</table>\n\n"
pr_comment += f"""\n\n(1) Note 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\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 "What is the purpose of this PR?"`. See the relevant documentation for each tool for more details."""
else:
pr_comment += f"<table><tr align='center'><th align='center'>Tool</th><th align='left'>Command</th><th align='left'>Description</th></tr>"
for i in range(len(tool_names)):
pr_comment += f"\n<tr><td align='center'>\n\n<strong>{tool_names[i]}</strong></td><td>{commands[i]}</td><td>{descriptions[i]}</td></tr>"
# pr_comment += f"\n<tr><td align='center'>\n\n<strong>[DESCRIBE]({base_path}/DESCRIBE.md)</strong></td><td>Generates PR description - title, type, summary, code walkthrough and labels</td></tr>"
# pr_comment += f"\n<tr><td align='center'>\n\n<strong>[REVIEW]({base_path}/REVIEW.md)</strong></td><td>Adjustable feedback about the PR, possible issues, security concerns, review effort and more</td></tr>"
# pr_comment += f"\n<tr><td align='center'>\n\n<strong>[IMPROVE]({base_path}/IMPROVE.md)</strong></td><td>Code suggestions for improving the PR.</td></tr>"
# pr_comment += f"\n<tr><td align='center'>\n\n<strong>[ASK]({base_path}/ASK.md)</strong></td><td>Answering free-text questions about the PR.</td></tr>"
# pr_comment += f"\n<tr><td align='center'>\n\n<strong>[SIMILAR ISSUE]({base_path}/SIMILAR_ISSUE.md)</strong></td><td>Automatically retrieves and presents similar issues.</td></tr>"
# pr_comment += f"\n<tr><td align='center'>\n\n<strong>[UPDATE CHANGELOG]({base_path}/UPDATE_CHANGELOG.md)</strong></td><td>Automatically updates the changelog.</td></tr>"
# pr_comment += f"\n<tr><td align='center'>\n\n<strong>[ADD DOCUMENTATION]({base_path}/ADD_DOCUMENTATION.md)</strong></td><td>Generates documentation to methods/functions/classes that changed in the PR.</td></tr>"
# pr_comment += f"\n<tr><td align='center'>\n\n<strong>[GENERATE CUSTOM LABELS]({base_path}/GENERATE_CUSTOM_LABELS.md)</strong></td><td>Generates custom labels for the PR, based on specific guidelines defined by the user</td></tr>"
# pr_comment += f"\n<tr><td align='center'>\n\n<strong>[ANALYZE]({base_path}/Analyze.md)</strong></td><td>Identifies code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component.</td></tr>"
# pr_comment += f"\n<tr><td align='center'>\n\n<strong>[TEST]({base_path}/TEST.md)</strong></td><td>Generates unit tests for a selected component, based on the PR code change.</td></tr>"
# pr_comment += f"\n<tr><td align='center'>\n\n<strong>[CI FEEDBACK]({base_path}/CI_FEEDBACK.md)</strong></td><td>Generates feedback and analysis for a failed CI job.</td></tr>"
# pr_comment += f"\n<tr><td align='center'>\n\n<strong>[CUSTOM SUGGESTIONS]({base_path}/CUSTOM_SUGGESTIONS.md)</strong></td><td>Generates custom suggestions for improving the PR code, based on specific guidelines defined by the user.</td></tr>"
pr_comment += "</table>\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)."""
if get_settings().config.publish_output: if get_settings().config.publish_output:
self.git_provider.publish_comment(pr_comment) self.git_provider.publish_comment(pr_comment)
except Exception as e: except Exception as e: