From cff4afdb0239bd439a988361385be58cc3aef8da Mon Sep 17 00:00:00 2001 From: Daniel Riccio Date: Mon, 28 Jul 2025 19:39:08 -0500 Subject: [PATCH] feat: Update PR reviewer mode to use todo lists and GitHub CLI - Add todo list initialization and tracking throughout the review workflow - Replace all MCP GitHub server calls with gh CLI commands - Fix duplicate step numbering issue - Update best practices and common mistakes documentation - Add notes about GitHub CLI limitations for inline comments --- .roo/rules-pr-reviewer/1_workflow.xml | 349 ++++++++++++------ .roo/rules-pr-reviewer/2_best_practices.xml | 10 +- .../3_common_mistakes_to_avoid.xml | 5 + 3 files changed, 241 insertions(+), 123 deletions(-) diff --git a/.roo/rules-pr-reviewer/1_workflow.xml b/.roo/rules-pr-reviewer/1_workflow.xml index b430a854e6e..0594e191bee 100644 --- a/.roo/rules-pr-reviewer/1_workflow.xml +++ b/.roo/rules-pr-reviewer/1_workflow.xml @@ -1,100 +1,133 @@ + Initialize Review Process + + Create a todo list to track the PR review workflow: + + + + [ ] Fetch pull request information + [ ] Fetch associated issue (if any) + [ ] Fetch pull request diff + [ ] Fetch existing PR comments and reviews + [ ] Check out pull request locally + [ ] Verify existing comments against current code + [ ] Perform comprehensive review + [ ] Prepare review comments + [ ] Preview review with user + [ ] Submit review or create tasks + + + + This helps track progress through the review process and ensures all steps are completed. + + + + Fetch Pull Request Information - By default, use the GitHub MCP server to fetch and review pull requests from the - https://github.com/RooCodeInc/Roo-Code repository. + By default, review pull requests from the https://github.com/RooCodeInc/Roo-Code repository. If the user provides a PR number or URL, extract the necessary information: - Repository owner and name - Pull request number - Use the GitHub MCP tool to fetch the PR details: - - - github - get_pull_request - - { - "owner": "[owner]", - "repo": "[repo]", - "pullNumber": [number] - } - - + Use the GitHub CLI to fetch the PR details: + + + gh pr view [PR_NUMBER] --repo [owner]/[repo] --json number,title,body,author,state,url,headRefName,baseRefName,mergeable,isDraft,createdAt,updatedAt + + + Parse the JSON output to understand the PR's current state and metadata. + + + + [x] Fetch pull request information + [ ] Fetch associated issue (if any) + [ ] Fetch pull request diff + [ ] Fetch existing PR comments and reviews + [ ] Check out pull request locally + [ ] Verify existing comments against current code + [ ] Perform comprehensive review + [ ] Prepare review comments + [ ] Preview review with user + [ ] Submit review or create tasks + + - + Fetch Associated Issue (If Any) Check the pull request body for a reference to a GitHub issue (e.g., "Fixes #123", "Closes #456"). - If an issue is referenced, use the GitHub MCP tool to fetch its details: + If an issue is referenced, use the GitHub CLI to fetch its details: - - github - get_issue - - { - "owner": "[owner]", - "repo": "[repo]", - "issue_number": [issue_number] - } - - + + gh issue view [issue_number] --repo [owner]/[repo] --json number,title,body,author,state,url,createdAt,updatedAt,comments + The issue description and comments can provide valuable context for the review. + + + + [x] Fetch pull request information + [x] Fetch associated issue (if any) + [ ] Fetch pull request diff + [ ] Fetch existing PR comments and reviews + [ ] Check out pull request locally + [ ] Verify existing comments against current code + [ ] Perform comprehensive review + [ ] Prepare review comments + [ ] Preview review with user + [ ] Submit review or create tasks + + - + Fetch Pull Request Diff Get the pull request diff to understand the changes: - - github - get_pull_request_diff - - { - "owner": "[owner]", - "repo": "[repo]", - "pullNumber": [number] - } - - + + gh pr diff [PR_NUMBER] --repo [owner]/[repo] + + + This will show the complete diff of all changes in the PR. + + + + [x] Fetch pull request information + [x] Fetch associated issue (if any) + [x] Fetch pull request diff + [ ] Fetch existing PR comments and reviews + [ ] Check out pull request locally + [ ] Verify existing comments against current code + [ ] Perform comprehensive review + [ ] Prepare review comments + [ ] Preview review with user + [ ] Submit review or create tasks + + - + Fetch Existing PR Comments and Reviews IMPORTANT: Before reviewing any code, first get all existing comments and reviews to understand what feedback has already been provided: - - github - get_pull_request_comments - - { - "owner": "[owner]", - "repo": "[repo]", - "pullNumber": [number] - } - - - - Also fetch existing reviews: - - github - get_pull_request_reviews - - { - "owner": "[owner]", - "repo": "[repo]", - "pullNumber": [number] - } - - + Fetch all review comments: + + gh pr view [PR_NUMBER] --repo [owner]/[repo] --comments + + + Also fetch review details: + + gh pr reviews [PR_NUMBER] --repo [owner]/[repo] + Create a mental or written list of: - All issues/suggestions that have been raised @@ -102,26 +135,56 @@ - Whether comments appear to be resolved or still pending This information will guide your review to avoid duplicate feedback. + + + + [x] Fetch pull request information + [x] Fetch associated issue (if any) + [x] Fetch pull request diff + [x] Fetch existing PR comments and reviews + [ ] Check out pull request locally + [ ] Verify existing comments against current code + [ ] Perform comprehensive review + [ ] Prepare review comments + [ ] Preview review with user + [ ] Submit review or create tasks + + - + Check Out Pull Request Locally Use the GitHub CLI to check out the pull request locally: - gh pr checkout [PR_NUMBER] + gh pr checkout [PR_NUMBER] --repo [owner]/[repo] This allows you to: - Navigate the actual code structure - Understand how changes interact with existing code - Get better context for your review + + + + [x] Fetch pull request information + [x] Fetch associated issue (if any) + [x] Fetch pull request diff + [x] Fetch existing PR comments and reviews + [x] Check out pull request locally + [ ] Verify existing comments against current code + [ ] Perform comprehensive review + [ ] Prepare review comments + [ ] Preview review with user + [ ] Submit review or create tasks + + - + Verify Existing Comments Against Current Code Now that you have the code checked out locally and know what comments exist: @@ -142,10 +205,25 @@ - New issues not previously mentioned (these are your main focus) This verification step is CRITICAL to avoid redundant feedback and ensures your review adds value. + + + + [x] Fetch pull request information + [x] Fetch associated issue (if any) + [x] Fetch pull request diff + [x] Fetch existing PR comments and reviews + [x] Check out pull request locally + [x] Verify existing comments against current code + [ ] Perform comprehensive review + [ ] Prepare review comments + [ ] Preview review with user + [ ] Submit review or create tasks + + - + Perform Comprehensive Review Review the pull request thoroughly: @@ -169,16 +247,31 @@ 6. Security considerations 7. Internationalization (i18n) issues 8. Technical debt indicators + + + + [x] Fetch pull request information + [x] Fetch associated issue (if any) + [x] Fetch pull request diff + [x] Fetch existing PR comments and reviews + [x] Check out pull request locally + [x] Verify existing comments against current code + [x] Perform comprehensive review + [ ] Prepare review comments + [ ] Preview review with user + [ ] Submit review or create tasks + + - + Prepare Review Comments Format your review comments following these guidelines: CRITICAL: Before adding any comment, verify it's not already addressed: - - Cross-reference with your notes from Step 6 + - Cross-reference with your notes from Step 7 - Only comment on NEW issues or UNRESOLVED existing issues - Never repeat feedback that has been addressed in the current code @@ -207,10 +300,25 @@ 6. [Improvement suggestion] Include a note about which existing comments you verified as resolved (for user awareness). + + + + [x] Fetch pull request information + [x] Fetch associated issue (if any) + [x] Fetch pull request diff + [x] Fetch existing PR comments and reviews + [x] Check out pull request locally + [x] Verify existing comments against current code + [x] Perform comprehensive review + [x] Prepare review comments + [ ] Preview review with user + [ ] Submit review or create tasks + + - + Preview Review with User Always show the user a preview of your review suggestions and comments before taking any action. @@ -245,62 +353,63 @@ Skip submission - just wanted the analysis + + + + [x] Fetch pull request information + [x] Fetch associated issue (if any) + [x] Fetch pull request diff + [x] Fetch existing PR comments and reviews + [x] Check out pull request locally + [x] Verify existing comments against current code + [x] Perform comprehensive review + [x] Prepare review comments + [x] Preview review with user + [ ] Submit review or create tasks + + - + Submit Review - Based on user preference, submit the review as a comprehensive review: - - 1. First create a pending review: - - github - create_pending_pull_request_review - - { - "owner": "[owner]", - "repo": "[repo]", - "pullNumber": [number] - } - - - - 2. Add comments to the pending review using: - - github - add_pull_request_review_comment_to_pending_review - - { - "owner": "[owner]", - "repo": "[repo]", - "pullNumber": [number], - "path": "[file path]", - "line": [line number], - "body": "[comment text]", - "subjectType": "LINE" - } - - - - 3. Submit the review: - - github - submit_pending_pull_request_review - - { - "owner": "[owner]", - "repo": "[repo]", - "pullNumber": [number], - "event": "COMMENT", - "body": "[overall review summary]" - } - - + Based on user preference, submit the review using GitHub CLI: + + Note: The GitHub CLI has limited support for creating reviews with inline comments. + For comprehensive reviews with line-specific comments, we'll need to: + + 1. Create individual comments on specific lines (if needed): + + gh pr comment [PR_NUMBER] --repo [owner]/[repo] --body "[comment text]" + + + 2. Or create a general review comment summarizing all findings: + + gh pr review [PR_NUMBER] --repo [owner]/[repo] --comment --body "[review summary with all findings]" + + + Note: For line-specific comments, you may need to use the GitHub web interface or API directly, + as the gh CLI has limited support for inline review comments. + + + + [x] Fetch pull request information + [x] Fetch associated issue (if any) + [x] Fetch pull request diff + [x] Fetch existing PR comments and reviews + [x] Check out pull request locally + [x] Verify existing comments against current code + [x] Perform comprehensive review + [x] Prepare review comments + [x] Preview review with user + [x] Submit review or create tasks + + - + Create Tasks for Suggestions (Optional) If the user chooses to create individual tasks for each suggestion, use the new_task tool to create separate tasks: diff --git a/.roo/rules-pr-reviewer/2_best_practices.xml b/.roo/rules-pr-reviewer/2_best_practices.xml index e2ebb6cf20f..d4aa27736ca 100644 --- a/.roo/rules-pr-reviewer/2_best_practices.xml +++ b/.roo/rules-pr-reviewer/2_best_practices.xml @@ -1,8 +1,10 @@ - - ALWAYS fetch existing comments and reviews BEFORE reviewing any code (Step 4) + - ALWAYS create a todo list at the start to track the review workflow (Step 1) + - Use GitHub CLI (`gh`) commands instead of MCP tools for all GitHub operations + - ALWAYS fetch existing comments and reviews BEFORE reviewing any code (Step 5) - Create a list of all existing feedback before starting your review - - Check out the PR locally for better context understanding - - Systematically verify each existing comment against the current code (Step 6) + - Check out the PR locally using `gh pr checkout` for better context understanding + - Systematically verify each existing comment against the current code (Step 7) - Track which comments are resolved vs still pending - Only provide feedback on NEW issues or UNRESOLVED existing issues - Never duplicate feedback that has already been addressed @@ -28,4 +30,6 @@ - Offer the option to create individual tasks for each suggestion - When creating tasks, choose the appropriate mode for each type of work - Include specific context and file references in each task + - Update the todo list after each major step to track progress + - Note: GitHub CLI has limited support for inline review comments \ No newline at end of file diff --git a/.roo/rules-pr-reviewer/3_common_mistakes_to_avoid.xml b/.roo/rules-pr-reviewer/3_common_mistakes_to_avoid.xml index 0dcbb51b43c..2b97f50845e 100644 --- a/.roo/rules-pr-reviewer/3_common_mistakes_to_avoid.xml +++ b/.roo/rules-pr-reviewer/3_common_mistakes_to_avoid.xml @@ -1,4 +1,6 @@ + - Not creating a todo list at the start to track the review workflow + - Using MCP tools instead of GitHub CLI commands for GitHub operations - Starting to review code WITHOUT first fetching existing comments and reviews - Failing to create a list of existing feedback before reviewing - Not systematically checking each existing comment against the current code @@ -25,4 +27,7 @@ - Failing to offer the task creation option for addressing suggestions - Creating tasks without specific context or file references - Choosing inappropriate modes when creating tasks for suggestions + - Not updating the todo list after completing each step + - Forgetting that GitHub CLI has limited support for inline review comments + - Not including --repo flag when using gh commands for non-default repositories \ No newline at end of file