Skip to content

Commit cc0a7d3

Browse files
daniel-lxsutarn
authored andcommitted
Update PR reviewer rules and mode configuration (RooCodeInc#6391)
1 parent a8a2ab7 commit cc0a7d3

File tree

4 files changed

+86
-28
lines changed

4 files changed

+86
-28
lines changed

.roo/rules-pr-reviewer/1_workflow.xml

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
Use the GitHub CLI to fetch the PR details:
3434

3535
<execute_command>
36-
<command>gh pr view [PR_NUMBER] --repo [owner]/[repo] --json number,title,body,author,state,url,headRefName,baseRefName,mergeable,isDraft,createdAt,updatedAt</command>
36+
<command>gh pr view [PR_NUMBER] --repo [owner]/[repo] --json number,title,body,author,state,url,headRefName,baseRefName,headRefOid,mergeable,isDraft,createdAt,updatedAt</command>
3737
</execute_command>
3838

3939
Parse the JSON output to understand the PR's current state and metadata.
40+
IMPORTANT: Save the headRefOid value as it will be needed for submitting the review via the API.
4041

4142
<update_todo_list>
4243
<todos>
@@ -124,7 +125,7 @@
124125

125126
Also fetch review details:
126127
<execute_command>
127-
<command>gh pr reviews [PR_NUMBER] --repo [owner]/[repo]</command>
128+
<command>gh api repos/[owner]/[repo]/pulls/[PR_NUMBER]/reviews</command>
128129
</execute_command>
129130

130131
Create a mental or written list of:
@@ -372,24 +373,65 @@
372373
<step number="11">
373374
<name>Submit Review</name>
374375
<instructions>
375-
Based on user preference, submit the review using GitHub CLI:
376+
Based on user preference, submit the review using the GitHub API to support inline comments:
376377

377-
Note: The GitHub CLI has limited support for creating reviews with inline comments.
378-
For comprehensive reviews with line-specific comments, we'll need to:
378+
1. Construct the review payload with inline comments. For each comment, you need:
379+
- The file path (relative to repository root)
380+
- The line number where the comment should appear
381+
- The comment body text
382+
- The side ("RIGHT" for new code, "LEFT" for old code)
379383

380-
1. Create individual comments on specific lines (if needed):
384+
2. Submit the review using the GitHub API with heredoc syntax:
381385
<execute_command>
382-
<command>gh pr comment [PR_NUMBER] --repo [owner]/[repo] --body "[comment text]"</command>
386+
<command>gh api -X POST repos/[owner]/[repo]/pulls/[PR_NUMBER]/reviews --input - <<EOF
387+
{
388+
"commit_id": "[headRefOid from Step 2]",
389+
"body": "Thank you for your contribution! I've reviewed the changes and [found issues that need attention / have some suggestions for improvement].",
390+
"event": "[COMMENT|REQUEST_CHANGES|APPROVE]",
391+
"comments": [
392+
{
393+
"path": "[file/path/to/code.ts]",
394+
"body": "[Your comment text here - use friendly, curious tone]",
395+
"line": [line_number],
396+
"side": "RIGHT"
397+
}
398+
]
399+
}
400+
EOF</command>
383401
</execute_command>
384402

385-
2. Or create a general review comment summarizing all findings:
403+
The review will be created with all inline comments attached to specific lines of code.
404+
405+
Note on event types:
406+
- "COMMENT": Submit general feedback without approval/rejection
407+
- "REQUEST_CHANGES": Request changes be made before merging
408+
- "APPROVE": Approve the PR for merging
409+
410+
Example for a review requesting changes:
386411
<execute_command>
387-
<command>gh pr review [PR_NUMBER] --repo [owner]/[repo] --comment --body "[review summary with all findings]"</command>
412+
<command>gh api -X POST repos/RooCodeInc/Roo-Code/pulls/6378/reviews --input - <<EOF
413+
{
414+
"commit_id": "abc123def4567890...",
415+
"body": "Thank you for your contribution! I've reviewed the changes and found that the critical issues from the previous review are still pending. I've left some suggestions inline to help improve the implementation.",
416+
"event": "REQUEST_CHANGES",
417+
"comments": [
418+
{
419+
"path": "packages/cloud/src/CloudService.ts",
420+
"body": "Missing error handling here...",
421+
"line": 19,
422+
"side": "RIGHT"
423+
},
424+
{
425+
"path": "packages/cloud/src/CloudService.ts",
426+
"body": "Is this intentional? The timeout seems quite high (30s). Could we consider reducing it or making it configurable?",
427+
"line": 45,
428+
"side": "RIGHT"
429+
}
430+
]
431+
}
432+
EOF</command>
388433
</execute_command>
389434

390-
Note: For line-specific comments, you may need to use the GitHub web interface or API directly,
391-
as the gh CLI has limited support for inline review comments.
392-
393435
<update_todo_list>
394436
<todos>
395437
[x] Fetch pull request information

.roo/rules-pr-reviewer/2_best_practices.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<best_practices>
22
- ALWAYS create a todo list at the start to track the review workflow (Step 1)
33
- Use GitHub CLI (`gh`) commands instead of MCP tools for all GitHub operations
4+
- ALWAYS fetch the PR's headRefOid in Step 2 - this is required for API review submission
45
- ALWAYS fetch existing comments and reviews BEFORE reviewing any code (Step 5)
56
- Create a list of all existing feedback before starting your review
67
- Check out the PR locally using `gh pr checkout` for better context understanding
@@ -27,9 +28,13 @@
2728
- Present findings in a numbered list format for clarity
2829
- Group feedback by priority (critical, important, minor)
2930
- Always preview comments with the user before submitting
31+
- Use the GitHub API for submitting reviews to support inline comments
32+
- Construct proper JSON payloads with commit_id, body, event, and comments array
33+
- Each inline comment needs: path, body, line number, and side (RIGHT for new code)
34+
- Choose appropriate review event: COMMENT, REQUEST_CHANGES, or APPROVE
35+
- Use heredoc syntax (--input - <<EOF) to pass JSON directly
3036
- Offer the option to create individual tasks for each suggestion
3137
- When creating tasks, choose the appropriate mode for each type of work
3238
- Include specific context and file references in each task
3339
- Update the todo list after each major step to track progress
34-
- Note: GitHub CLI has limited support for inline review comments
3540
</best_practices>

.roo/rules-pr-reviewer/3_common_mistakes_to_avoid.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<common_mistakes_to_avoid>
22
- Not creating a todo list at the start to track the review workflow
33
- Using MCP tools instead of GitHub CLI commands for GitHub operations
4+
- Forgetting to fetch headRefOid in Step 2 - this is REQUIRED for API review submission
45
- Starting to review code WITHOUT first fetching existing comments and reviews
56
- Failing to create a list of existing feedback before reviewing
67
- Not systematically checking each existing comment against the current code
@@ -28,6 +29,15 @@
2829
- Creating tasks without specific context or file references
2930
- Choosing inappropriate modes when creating tasks for suggestions
3031
- Not updating the todo list after completing each step
31-
- Forgetting that GitHub CLI has limited support for inline review comments
3232
- Not including --repo flag when using gh commands for non-default repositories
33+
- Using wrong commit_id in review payload (must use headRefOid from PR info)
34+
- Forgetting to specify "side": "RIGHT" for comments on new code
35+
- Using incorrect line numbers that don't match the actual diff
36+
- Not escaping special characters in JSON payload properly
37+
- Using wrong event type (e.g., REQUEST_CHANGES when only commenting)
38+
- Not constructing proper file paths relative to repository root
39+
- Submitting empty comments array when inline comments are needed
40+
- Forgetting to use <<EOF syntax properly in the command
41+
- Not properly escaping special characters in heredoc JSON content
42+
- Missing the EOF delimiter at the end of the heredoc
3343
</common_mistakes_to_avoid>

.roomodes

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,21 @@ customModes:
205205
- command
206206
- mcp
207207
source: project
208+
- slug: pr-reviewer
209+
name: 🔍 PR Reviewer
210+
roleDefinition: |-
211+
You are Roo, a pull request reviewer specializing in code quality, structure, and translation consistency. Your expertise includes: - Analyzing pull request diffs and understanding code changes in context - Evaluating code quality, identifying code smells and technical debt - Ensuring structural consistency across the codebase - Verifying proper internationalization (i18n) for UI changes - Providing constructive feedback with a friendly, curious tone - Reviewing test coverage and quality without executing tests - Identifying opportunities for code improvements and refactoring
212+
You work primarily with the RooCodeInc/Roo-Code repository, using GitHub MCP tools to fetch and review pull requests. You check out PRs locally for better context understanding and focus on providing actionable, constructive feedback that helps improve code quality.
213+
whenToUse: Use this mode to review pull requests on the Roo-Code GitHub repository or any other repository if specified by the user.
214+
description: Review PRs for code quality, structure, and i18n compliance.
215+
groups:
216+
- read
217+
- - edit
218+
- fileRegex: \.md$
219+
description: Markdown files only
220+
- mcp
221+
- command
222+
source: project
208223
- slug: mode-writer
209224
name: ✍️ Mode Writer
210225
roleDefinition: |-
@@ -236,17 +251,3 @@ customModes:
236251
- command
237252
- mcp
238253
source: project
239-
- slug: pr-reviewer
240-
name: 🔍 PR Reviewer
241-
roleDefinition: |-
242-
You are Roo, a pull request reviewer specializing in code quality, structure, and translation consistency. Your expertise includes: - Analyzing pull request diffs and understanding code changes in context - Evaluating code quality, identifying code smells and technical debt - Ensuring structural consistency across the codebase - Verifying proper internationalization (i18n) for UI changes - Providing constructive feedback with a friendly, curious tone - Reviewing test coverage and quality without executing tests - Identifying opportunities for code improvements and refactoring
243-
You work primarily with the RooCodeInc/Roo-Code repository, using GitHub MCP tools to fetch and review pull requests. You check out PRs locally for better context understanding and focus on providing actionable, constructive feedback that helps improve code quality.
244-
whenToUse: Use this mode to review pull requests on the Roo-Code GitHub repository or any other repository if specified by the user.
245-
groups:
246-
- read
247-
- - edit
248-
- fileRegex: \.md$
249-
description: Markdown files only
250-
- mcp
251-
- command
252-
source: project

0 commit comments

Comments
 (0)