Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help improved #677

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pr_agent/settings/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ use_bullet_points=true
extra_instructions = ""
enable_pr_type=true
final_update_message = true
enable_help_text=true
enable_help_text=false
enable_help_comment=true
## changes walkthrough section
enable_semantic_files_types=true
collapsible_file_list='adaptive' # true, false, 'adaptive'
Expand Down
8 changes: 7 additions & 1 deletion pr_agent/tools/pr_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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.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.log import get_logger
from pr_agent.servers.help import HelpMessage
Expand Down Expand Up @@ -106,6 +106,12 @@ async def run(self):
pr_body += "<hr>\n\n<details> <summary><strong>✨ Usage guide:</strong></summary><hr> \n\n"
pr_body += HelpMessage.get_describe_usage_guide()
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`, to get a list of all 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 all PR-Agent tools and their descriptions\n\n___\n\n"


# final markdown description
full_markdown_description = f"## Title\n\n{pr_title}\n\n___\n{pr_body}"
Expand Down
99 changes: 83 additions & 16 deletions pr_agent/tools/pr_help_message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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


Expand All @@ -14,21 +14,88 @@ async def run(self):
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"
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>"
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)."""

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)")

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:
self.git_provider.publish_comment(pr_comment)
except Exception as e:
Expand Down
Loading