Browse Source

PR-Reviewer improvements (#5406)

* feat: add Issue Fixer Orchestrator mode

* feat: enhance PR Reviewer mode as orchestrator with critical review capabilities

- Transform PR Reviewer into an orchestrator mode that delegates analysis tasks
- Add comprehensive rule files for workflow, guidelines, and patterns
- Implement file-based context management system in .roo/temp/pr-*/
- Add GitHub MCP tool integration with CLI fallback strategy
- Include critical review guidelines for pattern consistency and redundancy detection
- Update file permissions to support temporary context files
Murilo Pires 8 months ago
parent
commit
7c4fc55fc5

+ 203 - 0
.roo/rules-pr-reviewer/1_orchestrator_workflow.xml

@@ -0,0 +1,203 @@
+<orchestrator_workflow>
+  <overview>
+    This workflow orchestrates a comprehensive pull request review process by delegating
+    specialized analysis tasks to appropriate modes while maintaining context through
+    structured report files. The orchestrator ensures critical review coverage while
+    avoiding redundant feedback.
+  </overview>
+
+  <initialization>
+    <step number="1">
+      <name>Parse PR Information and Initialize Context</name>
+      <description>
+        Extract PR information from user input (URL or PR number).
+        Create context directory and tracking files.
+        If called by another mode (Issue Fixer, PR Fixer), set calledByMode field.
+      </description>
+      <actions>
+        - Parse PR URL or number from user input
+        - Create directory: .roo/temp/pr-[PR_NUMBER]/
+        - Initialize review-context.json with PR metadata
+        - Check if called by another mode and record it
+      </actions>
+    </step>
+  </initialization>
+
+  <github_operations>
+    <step number="2">
+      <name>Fetch PR Details and Context</name>
+      <description>
+        Try using GitHub MCP tools first. If unavailable or failing, fall back to GitHub CLI.
+      </description>
+      <mcp_approach>
+        Use get_pull_request tool to fetch PR details
+      </mcp_approach>
+      <cli_fallback>
+        gh pr view [PR_NUMBER] --repo [owner]/[repo] --json number,title,author,state,body,url,headRefName,baseRefName,files,additions,deletions,changedFiles
+      </cli_fallback>
+    </step>
+
+    <step number="3">
+      <name>Fetch Linked Issue</name>
+      <description>
+        If PR references an issue, fetch its details for context.
+      </description>
+      <mcp_approach>
+        Use get_issue tool if issue is referenced
+      </mcp_approach>
+      <cli_fallback>
+        gh issue view [issue_number] --repo [owner]/[repo] --json number,title,body,author,state
+      </cli_fallback>
+    </step>
+
+    <step number="4">
+      <name>Fetch Existing Comments and Reviews</name>
+      <description>
+        CRITICAL: Get all existing feedback to avoid redundancy.
+      </description>
+      <mcp_approach>
+        Use get_pull_request_comments and get_pull_request_reviews
+      </mcp_approach>
+      <cli_fallback>
+        gh pr review [PR_NUMBER] --repo [owner]/[repo] --json comments,reviews
+      </cli_fallback>
+      <save_to>.roo/temp/pr-[PR_NUMBER]/existing-feedback.json</save_to>
+    </step>
+
+    <step number="5">
+      <name>Check Out PR Locally</name>
+      <command>gh pr checkout [PR_NUMBER] --repo [owner]/[repo]</command>
+      <purpose>Enable local code analysis and pattern comparison</purpose>
+    </step>
+  </github_operations>
+
+  <delegated_analysis>
+    <step number="6">
+      <name>Delegate Pattern Analysis</name>
+      <description>
+        Create a subtask to analyze code patterns and organization.
+      </description>
+      <delegation>
+        <mode>code</mode>
+        <focus_areas>
+          - Identifying similar existing features/components
+          - Checking if implementations follow established patterns
+          - Finding potential code redundancy
+          - Verifying test organization
+          - Checking file/directory structure consistency
+        </focus_areas>
+        <output>.roo/temp/pr-[PR_NUMBER]/pattern-analysis.md</output>
+      </delegation>
+    </step>
+
+    <step number="7">
+      <name>Delegate Architecture Review</name>
+      <description>
+        Create a subtask for architectural analysis.
+      </description>
+      <delegation>
+        <mode>architect</mode>
+        <focus_areas>
+          - Module boundary violations
+          - Dependency management issues
+          - Separation of concerns
+          - Potential circular dependencies
+          - Overall architectural consistency
+        </focus_areas>
+        <output>.roo/temp/pr-[PR_NUMBER]/architecture-review.md</output>
+      </delegation>
+    </step>
+
+    <step number="8">
+      <name>Delegate Test Coverage Analysis</name>
+      <description>
+        If test files are modified or added, delegate test analysis.
+      </description>
+      <delegation>
+        <mode>test</mode>
+        <focus_areas>
+          - Test organization and location
+          - Test coverage adequacy
+          - Test naming conventions
+          - Mock usage patterns
+          - Edge case coverage
+        </focus_areas>
+        <output>.roo/temp/pr-[PR_NUMBER]/test-analysis.md</output>
+      </delegation>
+    </step>
+  </delegated_analysis>
+
+  <synthesis>
+    <step number="9">
+      <name>Synthesize Findings</name>
+      <description>
+        Collect all delegated analysis results and create comprehensive review.
+      </description>
+      <actions>
+        - Read all analysis files from .roo/temp/pr-[PR_NUMBER]/
+        - Identify critical issues vs suggestions
+        - Check against existing comments to avoid redundancy
+        - Prioritize findings by impact
+      </actions>
+    </step>
+
+    <step number="10">
+      <name>Create Final Review Report</name>
+      <description>
+        Generate comprehensive review report with all findings.
+      </description>
+      <output>.roo/temp/pr-[PR_NUMBER]/final-review.md</output>
+      <sections>
+        - Executive Summary
+        - Critical Issues (must fix)
+        - Pattern Inconsistencies
+        - Redundancy Findings
+        - Architecture Concerns
+        - Test Coverage Issues
+        - Minor Suggestions
+      </sections>
+    </step>
+  </synthesis>
+
+  <completion>
+    <step number="11">
+      <name>Present Review to User</name>
+      <description>
+        Show the review findings and ask for action.
+      </description>
+      <decision_points>
+        <if_called_by_mode>
+          Only present the analysis report, do not comment on PR
+        </if_called_by_mode>
+        <if_direct_review>
+          Ask user if they want to post the review as a comment
+        </if_direct_review>
+      </decision_points>
+    </step>
+
+    <step number="12">
+      <name>Post Review Comment (if approved)</name>
+      <description>
+        If user approves and not called by another mode, post review.
+      </description>
+      <mcp_approach>
+        Use add_issue_comment or create PR review
+      </mcp_approach>
+      <cli_fallback>
+        gh pr comment [PR_NUMBER] --repo [owner]/[repo] --body-file .roo/temp/pr-[PR_NUMBER]/final-review.md
+      </cli_fallback>
+    </step>
+  </completion>
+
+  <error_handling>
+    <github_api_failures>
+      Always fall back to GitHub CLI commands
+    </github_api_failures>
+    <delegation_failures>
+      Continue with available analysis and note limitations
+    </delegation_failures>
+    <context_preservation>
+      Always save intermediate results to temp files
+    </context_preservation>
+  </error_handling>
+</orchestrator_workflow>

+ 0 - 281
.roo/rules-pr-reviewer/1_workflow.xml

@@ -1,281 +0,0 @@
-<workflow>
-  <step number="1">
-    <name>Fetch Pull Request Information</name>
-    <instructions>
-      By default, use the GitHub MCP server to fetch and 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:
-      
-      <use_mcp_tool>
-      <server_name>github</server_name>
-      <tool_name>get_pull_request</tool_name>
-      <arguments>
-      {
-        "owner": "[owner]",
-        "repo": "[repo]",
-        "pullNumber": [number]
-      }
-      </arguments>
-      </use_mcp_tool>
-    </instructions>
-  </step>
-
-  <step number="2">
-    <name>Fetch Associated Issue (If Any)</name>
-    <instructions>
-      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:
-
-      <use_mcp_tool>
-      <server_name>github</server_name>
-      <tool_name>get_issue</tool_name>
-      <arguments>
-      {
-        "owner": "[owner]",
-        "repo": "[repo]",
-        "issue_number": [issue_number]
-      }
-      </arguments>
-      </use_mcp_tool>
-
-      The issue description and comments can provide valuable context for the review.
-    </instructions>
-  </step>
-
-  <step number="3">
-    <name>Fetch Pull Request Diff</name>
-    <instructions>
-      Get the pull request diff to understand the changes:
-      
-      <use_mcp_tool>
-      <server_name>github</server_name>
-      <tool_name>get_pull_request_diff</tool_name>
-      <arguments>
-      {
-        "owner": "[owner]",
-        "repo": "[repo]",
-        "pullNumber": [number]
-      }
-      </arguments>
-      </use_mcp_tool>
-    </instructions>
-  </step>
-
-  <step number="4">
-    <name>Fetch Existing PR Comments and Reviews</name>
-    <instructions>
-      IMPORTANT: Before reviewing any code, first get all existing comments and reviews to understand what feedback has already been provided:
-      
-      <use_mcp_tool>
-      <server_name>github</server_name>
-      <tool_name>get_pull_request_comments</tool_name>
-      <arguments>
-      {
-        "owner": "[owner]",
-        "repo": "[repo]",
-        "pullNumber": [number]
-      }
-      </arguments>
-      </use_mcp_tool>
-      
-      Also fetch existing reviews:
-      <use_mcp_tool>
-      <server_name>github</server_name>
-      <tool_name>get_pull_request_reviews</tool_name>
-      <arguments>
-      {
-        "owner": "[owner]",
-        "repo": "[repo]",
-        "pullNumber": [number]
-      }
-      </arguments>
-      </use_mcp_tool>
-      
-      Create a mental or written list of:
-      - All issues/suggestions that have been raised
-      - The specific files and line numbers mentioned
-      - Whether comments appear to be resolved or still pending
-      
-      This information will guide your review to avoid duplicate feedback.
-    </instructions>
-  </step>
-
-  <step number="5">
-    <name>Check Out Pull Request Locally</name>
-    <instructions>
-      Use the GitHub CLI to check out the pull request locally:
-      
-      <execute_command>
-      <command>gh pr checkout [PR_NUMBER]</command>
-      </execute_command>
-      
-      This allows you to:
-      - Navigate the actual code structure
-      - Understand how changes interact with existing code
-      - Get better context for your review
-    </instructions>
-  </step>
-
-  <step number="6">
-    <name>Verify Existing Comments Against Current Code</name>
-    <instructions>
-      Now that you have the code checked out locally and know what comments exist:
-      
-      1. For each existing comment/review point:
-         - Navigate to the specific file and line mentioned
-         - Check if the issue has been addressed in the current code
-         - Mark it as "resolved" or "still pending" in your notes
-      
-      2. Use read_file or codebase_search to examine the specific areas mentioned in comments:
-         - If a comment says "missing error handling on line 45", check if error handling now exists
-         - If a review mentioned "this function needs tests", check if tests have been added
-         - If feedback was about code structure, verify if refactoring has occurred
-      
-      3. Keep track of:
-         - Comments that have been addressed (DO NOT repeat these)
-         - Comments that are still valid (you may reinforce these if critical)
-         - 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.
-    </instructions>
-  </step>
-
-  <step number="7">
-    <name>Perform Comprehensive Review</name>
-    <instructions>
-      Review the pull request thoroughly:
-      - Verify that the changes are directly related to the linked issue and do not include unrelated modifications.
-      - Focus primarily on the changes made in the PR.
-      - Prioritize code quality, code smell, structural consistency, and for UI-related changes, ensure proper internationalization (i18n) is applied.
-      - Watch for signs of technical debt (e.g., overly complex logic, lack of abstraction, tight coupling, missing tests, TODOs).
-      - For large PRs, alert the user and recommend breaking it up if appropriate.
-      - NEVER run tests or execute code in PR Reviewer mode. The repository likely has automated testing. Your role is limited to:
-        - Code review and analysis
-        - Leaving review comments
-        - Checking code quality and structure
-        - Reviewing test coverage and quality (without execution)
-      
-      Document your findings:
-      - Code quality issues
-      - Structural improvements
-      - Missing tests or documentation
-      - Potential bugs or edge cases
-      - Performance concerns
-      - Security considerations
-    </instructions>
-  </step>
-
-  <step number="8">
-    <name>Prepare Review Comments</name>
-    <instructions>
-      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
-      - Only comment on NEW issues or UNRESOLVED existing issues
-      - Never repeat feedback that has been addressed in the current code
-      
-      Your suggestions should:
-      - Use a **friendly, curious tone** — prefer asking: "Is this intentional?" or "Could we approach this differently to improve X?"
-      - Avoid assumptions or judgments; ask questions instead of declaring problems.
-      - Skip ALL praise and positive comments. Focus exclusively on issues that need attention.
-      - Use Markdown sparingly — only for code blocks or when absolutely necessary for clarity. Avoid markdown headings (###, ##, etc.) entirely.
-      - Avoid including internal evaluation terminology (e.g., scores or internal tags) in public comments.
-      
-      When linking to specific lines or files, use full GitHub URLs relative to the repository, e.g.
-      `https://github.com/RooCodeInc/Roo-Code/blob/main/src/api/providers/human-relay.ts#L50`.
-      
-      Group your comments by:
-      - Critical issues (must fix)
-      - Important suggestions (should consider)
-      - Minor improvements (nice to have)
-      
-      Include a note about which existing comments you verified as resolved (for user awareness).
-    </instructions>
-  </step>
-
-  <step number="9">
-    <name>Preview Review with User</name>
-    <instructions>
-      Always show the user a preview of your review suggestions and comments before taking any action.
-      Summarize your findings clearly for the user before submitting comments.
-      
-      <ask_followup_question>
-      <question>I've completed my review of PR #[number]. Here's what I found:
-
-      [If applicable: Existing comments that have been resolved:
-      - Comment about X on file Y - now addressed
-      - Suggestion about Z - implemented]
-
-      [Summary of NEW findings organized by priority]
-
-      Would you like me to:
-      1. Create a comprehensive review with all comments
-      2. Modify any of the suggestions
-      3. Skip the review submission</question>
-      <follow_up>
-      <suggest>Create a comprehensive review</suggest>
-      <suggest>Let me modify the suggestions first</suggest>
-      <suggest>Skip submission - just wanted the analysis</suggest>
-      </follow_up>
-      </ask_followup_question>
-    </instructions>
-  </step>
-
-  <step number="10">
-    <name>Submit Review</name>
-    <instructions>
-      Based on user preference, submit the review as a comprehensive review:
-      
-      1. First create a pending review:
-      <use_mcp_tool>
-      <server_name>github</server_name>
-      <tool_name>create_pending_pull_request_review</tool_name>
-      <arguments>
-      {
-        "owner": "[owner]",
-        "repo": "[repo]",
-        "pullNumber": [number]
-      }
-      </arguments>
-      </use_mcp_tool>
-      
-      2. Add comments to the pending review using:
-      <use_mcp_tool>
-      <server_name>github</server_name>
-      <tool_name>add_pull_request_review_comment_to_pending_review</tool_name>
-      <arguments>
-      {
-        "owner": "[owner]",
-        "repo": "[repo]",
-        "pullNumber": [number],
-        "path": "[file path]",
-        "line": [line number],
-        "body": "[comment text]",
-        "subjectType": "LINE"
-      }
-      </arguments>
-      </use_mcp_tool>
-      
-      3. Submit the review:
-      <use_mcp_tool>
-      <server_name>github</server_name>
-      <tool_name>submit_pending_pull_request_review</tool_name>
-      <arguments>
-      {
-        "owner": "[owner]",
-        "repo": "[repo]",
-        "pullNumber": [number],
-        "event": "COMMENT",
-        "body": "[overall review summary]"
-      }
-      </arguments>
-      </use_mcp_tool>
-    </instructions>
-  </step>
-</workflow>

+ 0 - 27
.roo/rules-pr-reviewer/2_best_practices.xml

@@ -1,27 +0,0 @@
-<best_practices>
-  - ALWAYS fetch existing comments and reviews BEFORE reviewing any code (Step 4)
-  - 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)
-  - 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
-  - Always fetch and review the entire PR diff before commenting
-  - Check for and review any associated issue for context
-  - Focus on the changes made, not unrelated code
-  - Ensure all changes are directly related to the linked issue
-  - Use a friendly, curious tone in all comments
-  - Ask questions rather than making assumptions - there may be intentions behind the code choices
-  - Provide actionable feedback with specific suggestions
-  - Focus exclusively on issues and improvements - skip all praise or positive comments
-  - Use minimal markdown - avoid headings (###, ##) and excessive formatting
-  - Only use markdown for code blocks or when absolutely necessary for clarity
-  - Consider the PR's scope - suggest breaking up large PRs
-  - Verify proper i18n implementation for UI changes
-  - Check for test coverage without executing tests
-  - Look for signs of technical debt and code smells
-  - Ensure consistency with existing code patterns
-  - Link to specific lines using full GitHub URLs
-  - Group feedback by priority (critical, important, minor)
-  - Always preview comments with the user before submitting
-</best_practices>

+ 208 - 0
.roo/rules-pr-reviewer/2_critical_review_guidelines.xml

@@ -0,0 +1,208 @@
+<critical_review_guidelines>
+  <overview>
+    These guidelines ensure PR reviews are appropriately critical while remaining
+    constructive. The goal is to maintain high code quality and consistency
+    across the codebase by identifying issues that might be overlooked in a
+    less thorough review.
+  </overview>
+
+  <being_appropriately_critical>
+    <principle name="evidence_based_criticism">
+      <description>Always support criticism with evidence from the codebase</description>
+      <example>
+        Instead of: "This doesn't follow our patterns"
+        Say: "This implementation differs from the pattern used in src/api/handlers/*.ts 
+        where we consistently use the factory pattern for endpoint creation"
+      </example>
+    </principle>
+
+    <principle name="compare_with_existing_code">
+      <description>Reference similar existing implementations</description>
+      <approach>
+        1. Find 2-3 examples of similar features
+        2. Identify the common patterns they follow
+        3. Explain how the PR deviates from these patterns
+        4. Suggest alignment with existing approaches
+      </approach>
+    </principle>
+
+    <principle name="question_design_decisions">
+      <description>Challenge architectural choices when appropriate</description>
+      <examples>
+        - "Why was this implemented as a separate module instead of extending the existing X module?"
+        - "This introduces a new pattern for Y. Have we considered using the established pattern from Z?"
+        - "This creates a circular dependency with module A. Could we restructure to maintain cleaner boundaries?"
+      </examples>
+    </principle>
+  </being_appropriately_critical>
+
+  <pattern_analysis_checklist>
+    <category name="api_endpoints">
+      <check>Do new endpoints follow the same structure as existing ones?</check>
+      <check>Are error responses consistent with other endpoints?</check>
+      <check>Is authentication/authorization handled the same way?</check>
+      <check>Are request validations following established patterns?</check>
+    </category>
+
+    <category name="react_components">
+      <check>Do components follow the same file structure (types, helpers, component)?</check>
+      <check>Are props interfaces defined consistently?</check>
+      <check>Is state management approach consistent with similar components?</check>
+      <check>Are hooks used in the same patterns as elsewhere?</check>
+    </category>
+
+    <category name="test_files">
+      <check>Are test files in the correct directory structure?</check>
+      <check>Do test descriptions follow the same format?</check>
+      <check>Are mocking strategies consistent with other tests?</check>
+      <check>Is test data generation following established patterns?</check>
+    </category>
+
+    <category name="utility_functions">
+      <check>Could this utility already exist elsewhere?</check>
+      <check>Should this be added to an existing utility module?</check>
+      <check>Does the naming convention match other utilities?</check>
+      <check>Are similar transformations already implemented?</check>
+    </category>
+  </pattern_analysis_checklist>
+
+  <redundancy_detection>
+    <search_strategies>
+      <strategy name="functionality_search">
+        <description>Search for similar functionality by behavior</description>
+        <example>
+          If PR adds a "formatDate" function, search for:
+          - "date format"
+          - "format.*date"
+          - "dateFormat"
+          - Existing date manipulation utilities
+        </example>
+      </strategy>
+
+      <strategy name="pattern_search">
+        <description>Search for similar code patterns</description>
+        <example>
+          If PR adds error handling, search for:
+          - try/catch patterns in similar contexts
+          - Error boundary implementations
+          - Existing error utilities
+        </example>
+      </strategy>
+
+      <strategy name="import_analysis">
+        <description>Check what similar files import</description>
+        <approach>
+          Look at imports in files with similar purposes
+          to discover existing utilities that could be reused
+        </approach>
+      </strategy>
+    </search_strategies>
+
+    <common_redundancies>
+      <type name="utility_duplication">
+        <description>Reimplementing existing utilities</description>
+        <examples>
+          - String manipulation functions
+          - Array transformations  
+          - Date formatting
+          - API response transformations
+        </examples>
+      </type>
+
+      <type name="component_duplication">
+        <description>Creating similar components</description>
+        <examples>
+          - Modal variations that could use a base modal
+          - Form inputs that could extend existing inputs
+          - List components with slight variations
+        </examples>
+      </type>
+
+      <type name="logic_duplication">
+        <description>Repeating business logic</description>
+        <examples>
+          - Validation rules implemented multiple times
+          - Permission checks duplicated across files
+          - Data transformation logic repeated
+        </examples>
+      </type>
+    </common_redundancies>
+  </redundancy_detection>
+
+  <constructive_criticism_templates>
+    <template name="pattern_deviation">
+      <format>
+        "I notice this [feature] implements [pattern X], but our existing
+        [similar features] consistently use [pattern Y]. For example:
+        - [Link to example 1]
+        - [Link to example 2]
+        
+        Consider aligning with the established pattern to maintain consistency.
+        If there's a specific reason for the deviation, it would be helpful
+        to document it."
+      </format>
+    </template>
+
+    <template name="redundancy_found">
+      <format>
+        "This functionality appears to overlap with existing code in
+        [file/module]. Specifically, [existing function/component] already
+        handles [similar use case].
+        
+        Could we either:
+        1. Reuse the existing implementation
+        2. Extend it to cover this use case
+        3. Extract a shared utility if both are needed"
+      </format>
+    </template>
+
+    <template name="organization_improvement">
+      <format>
+        "For better code organization, this [file/component/test] would
+        fit better in [suggested location] alongside [similar items].
+        This follows our pattern where [explanation of pattern]."
+      </format>
+    </template>
+
+    <template name="test_organization">
+      <format>
+        "I see the tests are in [current location], but our other
+        [type] tests are organized in [correct location]. Moving them
+        would make them easier to find and maintain consistency with
+        tests like [example test files]."
+      </format>
+    </template>
+  </constructive_criticism_templates>
+
+  <severity_guidelines>
+    <level name="must_fix">
+      <description>Issues that should block PR approval</description>
+      <examples>
+        - Security vulnerabilities
+        - Breaking changes without migration path
+        - Significant pattern violations that would confuse future developers
+        - Major redundancy that adds maintenance burden
+      </examples>
+    </level>
+
+    <level name="should_fix">
+      <description>Important issues that need addressing</description>
+      <examples>
+        - Test files in wrong location
+        - Inconsistent error handling
+        - Missing critical test cases
+        - Code organization that violates module boundaries
+      </examples>
+    </level>
+
+    <level name="consider_fixing">
+      <description>Improvements that would benefit the codebase</description>
+      <examples>
+        - Minor pattern inconsistencies
+        - Opportunities for code reuse
+        - Additional test coverage
+        - Documentation improvements
+      </examples>
+    </level>
+  </severity_guidelines>
+</critical_review_guidelines>

+ 0 - 24
.roo/rules-pr-reviewer/3_common_mistakes_to_avoid.xml

@@ -1,24 +0,0 @@
-<common_mistakes_to_avoid>
-  - 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
-  - Repeating feedback that has already been addressed in the current code
-  - Ignoring existing PR comments or failing to verify if they have already been resolved
-  - Running tests or executing code during review
-  - Making judgmental or harsh comments
-  - Providing feedback on code outside the PR's scope
-  - Overlooking unrelated changes not tied to the main issue
-  - Including ANY praise or positive comments - focus only on issues
-  - Using markdown headings (###, ##, #) in review comments
-  - Using excessive markdown formatting when plain text would suffice
-  - Submitting comments without user preview/approval
-  - Forgetting to check for an associated issue for additional context
-  - Missing critical security or performance issues
-  - Not checking for proper i18n in UI changes
-  - Failing to suggest breaking up large PRs
-  - Using internal evaluation terminology in public comments
-  - Not providing actionable suggestions for improvements
-  - Reviewing only the diff without local context
-  - Making assumptions instead of asking clarifying questions about potential intentions
-  - Forgetting to link to specific lines with full GitHub URLs
-</common_mistakes_to_avoid>

+ 238 - 0
.roo/rules-pr-reviewer/3_delegation_patterns.xml

@@ -0,0 +1,238 @@
+<delegation_patterns>
+  <overview>
+    Patterns for effectively delegating analysis tasks to specialized modes
+    while maintaining context and ensuring comprehensive review coverage.
+  </overview>
+
+  <delegation_strategies>
+    <strategy name="pattern_analysis_delegation">
+      <when_to_delegate>
+        When PR contains new features or significant code changes
+      </when_to_delegate>
+      <delegate_to>code</delegate_to>
+      <task_template>
+        Analyze the following changed files for pattern consistency:
+        [List of changed files]
+        
+        Please focus on:
+        1. Finding similar existing implementations in the codebase
+        2. Identifying established patterns for this type of feature
+        3. Checking if the new code follows these patterns
+        4. Looking for potential code redundancy
+        5. Verifying proper file organization
+        
+        Use codebase_search and search_files to find similar code.
+        Document all findings with specific examples and file references.
+        
+        Save your analysis to: .roo/temp/pr-[PR_NUMBER]/pattern-analysis.md
+        
+        Format the output as:
+        ## Pattern Analysis for PR #[PR_NUMBER]
+        ### Similar Existing Implementations
+        ### Established Patterns
+        ### Pattern Deviations
+        ### Redundancy Findings
+        ### Organization Issues
+      </task_template>
+    </strategy>
+
+    <strategy name="architecture_review_delegation">
+      <when_to_delegate>
+        When PR modifies core modules, adds new modules, or changes dependencies
+      </when_to_delegate>
+      <delegate_to>architect</delegate_to>
+      <task_template>
+        Review the architectural implications of PR #[PR_NUMBER]:
+        
+        Changed files:
+        [List of changed files]
+        
+        PR Description:
+        [PR description]
+        
+        Please analyze:
+        1. Module boundary adherence
+        2. Dependency management (new dependencies, circular dependencies)
+        3. Separation of concerns
+        4. Impact on system architecture
+        5. Consistency with architectural patterns
+        
+        Save your findings to: .roo/temp/pr-[PR_NUMBER]/architecture-review.md
+        
+        Format as:
+        ## Architecture Review for PR #[PR_NUMBER]
+        ### Module Boundaries
+        ### Dependency Analysis
+        ### Architectural Concerns
+        ### Recommendations
+      </task_template>
+    </strategy>
+
+    <strategy name="test_analysis_delegation">
+      <when_to_delegate>
+        When PR adds or modifies test files
+      </when_to_delegate>
+      <delegate_to>test</delegate_to>
+      <task_template>
+        Analyze test changes in PR #[PR_NUMBER]:
+        
+        Test files changed:
+        [List of test files]
+        
+        Please review:
+        1. Test file organization and location
+        2. Test naming conventions
+        3. Coverage of edge cases
+        4. Mock usage patterns
+        5. Consistency with existing test patterns
+        
+        Compare with similar existing tests in the codebase.
+        
+        Save analysis to: .roo/temp/pr-[PR_NUMBER]/test-analysis.md
+        
+        Format as:
+        ## Test Analysis for PR #[PR_NUMBER]
+        ### Test Organization
+        ### Coverage Assessment
+        ### Pattern Consistency
+        ### Recommendations
+      </task_template>
+    </strategy>
+
+    <strategy name="ui_review_delegation">
+      <when_to_delegate>
+        When PR modifies UI components or adds new ones
+      </when_to_delegate>
+      <delegate_to>design-engineer</delegate_to>
+      <task_template>
+        Review UI changes in PR #[PR_NUMBER]:
+        
+        UI files changed:
+        [List of UI files]
+        
+        Please analyze:
+        1. Component structure consistency
+        2. Styling approach (Tailwind usage)
+        3. Accessibility considerations
+        4. i18n implementation
+        5. Component reusability
+        
+        Save findings to: .roo/temp/pr-[PR_NUMBER]/ui-review.md
+      </task_template>
+    </strategy>
+  </delegation_strategies>
+
+  <context_preservation>
+    <principle name="use_temp_files">
+      <description>Always save delegation results to temp files</description>
+      <pattern>.roo/temp/pr-[PR_NUMBER]/[analysis-type].md</pattern>
+    </principle>
+
+    <principle name="structured_output">
+      <description>Request structured markdown output from delegates</description>
+      <benefits>
+        - Easy to parse and combine
+        - Consistent formatting
+        - Clear section headers
+      </benefits>
+    </principle>
+
+    <principle name="pass_context_forward">
+      <description>Include relevant context in delegation requests</description>
+      <include>
+        - PR number and description
+        - List of changed files
+        - Specific areas of concern
+        - Output file location
+      </include>
+    </principle>
+  </context_preservation>
+
+  <coordination_patterns>
+    <pattern name="sequential_delegation">
+      <description>Delegate tasks one at a time, using results to inform next delegation</description>
+      <example>
+        1. Pattern analysis first
+        2. If patterns violated, delegate architecture review
+        3. If tests affected, delegate test analysis
+      </example>
+    </pattern>
+
+    <pattern name="parallel_delegation">
+      <description>Delegate multiple independent analyses simultaneously</description>
+      <example>
+        - Pattern analysis (code mode)
+        - Test analysis (test mode)
+        - UI review (design-engineer mode)
+      </example>
+    </pattern>
+
+    <pattern name="conditional_delegation">
+      <description>Only delegate based on file types changed</description>
+      <conditions>
+        - If *.test.ts changed -> delegate to test mode
+        - If src/components/* changed -> delegate to design-engineer
+        - If package.json changed -> delegate to architect
+      </conditions>
+    </pattern>
+  </coordination_patterns>
+
+  <result_synthesis>
+    <step name="collect_results">
+      <action>Read all analysis files from temp directory</action>
+      <files>
+        - pattern-analysis.md
+        - architecture-review.md
+        - test-analysis.md
+        - ui-review.md
+      </files>
+    </step>
+
+    <step name="identify_themes">
+      <action>Find common issues across analyses</action>
+      <themes>
+        - Pattern violations mentioned multiple times
+        - Redundancy identified by different modes
+        - Organizational issues
+      </themes>
+    </step>
+
+    <step name="prioritize_findings">
+      <action>Categorize by severity</action>
+      <categories>
+        - Critical (blocks PR)
+        - Important (should fix)
+        - Suggestions (nice to have)
+      </categories>
+    </step>
+
+    <step name="create_unified_report">
+      <action>Combine all findings into final review</action>
+      <format>
+        ## PR Review Summary
+        ### Critical Issues
+        ### Pattern Inconsistencies
+        ### Architecture Concerns
+        ### Test Coverage
+        ### Suggestions
+      </format>
+    </step>
+  </result_synthesis>
+
+  <fallback_strategies>
+    <scenario name="delegation_fails">
+      <action>Continue with available analyses</action>
+      <note>Document which analyses couldn't be completed</note>
+    </scenario>
+
+    <scenario name="mode_unavailable">
+      <action>Perform basic analysis in orchestrator mode</action>
+      <limitations>Note limitations in final report</limitations>
+    </scenario>
+
+    <scenario name="timeout">
+      <action>Use completed analyses</action>
+      <timeout>Set reasonable time limits for delegations</timeout>
+    </scenario>
+  </fallback_strategies>
+</delegation_patterns>

+ 226 - 0
.roo/rules-pr-reviewer/4_github_operations.xml

@@ -0,0 +1,226 @@
+<github_operations>
+  <overview>
+    Guidelines for handling GitHub operations with fallback strategies
+    when MCP tools are unavailable or failing.
+  </overview>
+
+  <mcp_vs_cli>
+    <principle>
+      Always try MCP tools first, fall back to GitHub CLI if they fail
+    </principle>
+    <benefits_of_mcp>
+      - Structured data responses
+      - Better error handling
+      - Integrated with the system
+    </benefits_of_mcp>
+    <benefits_of_cli>
+      - More reliable when MCP is down
+      - Direct GitHub API access
+      - Can handle complex queries
+    </benefits_of_cli>
+  </mcp_vs_cli>
+
+  <operation_patterns>
+    <operation name="fetch_pr_details">
+      <mcp_approach>
+        <tool>get_pull_request</tool>
+        <example><![CDATA[
+<use_mcp_tool>
+<server_name>github</server_name>
+<tool_name>get_pull_request</tool_name>
+<arguments>
+{
+  "owner": "RooCodeInc",
+  "repo": "Roo-Code",
+  "pullNumber": 123
+}
+</arguments>
+</use_mcp_tool>
+        ]]></example>
+      </mcp_approach>
+      <cli_fallback>
+        <command>gh pr view [PR_NUMBER] --repo [owner]/[repo] --json number,title,author,state,body,url,headRefName,baseRefName,files,additions,deletions,changedFiles</command>
+        <parse_json>true</parse_json>
+      </cli_fallback>
+    </operation>
+
+    <operation name="fetch_pr_diff">
+      <mcp_approach>
+        <tool>get_pull_request_diff</tool>
+        <example><![CDATA[
+<use_mcp_tool>
+<server_name>github</server_name>
+<tool_name>get_pull_request_diff</tool_name>
+<arguments>
+{
+  "owner": "RooCodeInc",
+  "repo": "Roo-Code",
+  "pullNumber": 123
+}
+</arguments>
+</use_mcp_tool>
+        ]]></example>
+      </mcp_approach>
+      <cli_fallback>
+        <command>gh pr diff [PR_NUMBER] --repo [owner]/[repo]</command>
+        <save_to>.roo/temp/pr-[PR_NUMBER]/pr.diff</save_to>
+      </cli_fallback>
+    </operation>
+
+    <operation name="fetch_pr_files">
+      <mcp_approach>
+        <tool>get_pull_request_files</tool>
+      </mcp_approach>
+      <cli_fallback>
+        <command>gh pr view [PR_NUMBER] --repo [owner]/[repo] --json files --jq '.files[].path'</command>
+        <description>Lists all files changed in the PR</description>
+      </cli_fallback>
+    </operation>
+
+    <operation name="fetch_comments">
+      <mcp_approach>
+        <tool>get_pull_request_comments</tool>
+      </mcp_approach>
+      <cli_fallback>
+        <command>gh pr view [PR_NUMBER] --repo [owner]/[repo] --json comments --jq '.comments'</command>
+      </cli_fallback>
+    </operation>
+
+    <operation name="fetch_reviews">
+      <mcp_approach>
+        <tool>get_pull_request_reviews</tool>
+      </mcp_approach>
+      <cli_fallback>
+        <command>gh pr view [PR_NUMBER] --repo [owner]/[repo] --json reviews --jq '.reviews'</command>
+      </cli_fallback>
+    </operation>
+
+    <operation name="checkout_pr">
+      <cli_only>
+        <command>gh pr checkout [PR_NUMBER] --repo [owner]/[repo]</command>
+        <note>No MCP equivalent - always use CLI</note>
+      </cli_only>
+    </operation>
+
+    <operation name="post_comment">
+      <mcp_approach>
+        <tool>add_issue_comment</tool>
+        <note>PRs use same comment system as issues</note>
+      </mcp_approach>
+      <cli_fallback>
+        <command>gh pr comment [PR_NUMBER] --repo [owner]/[repo] --body-file [file_path]</command>
+        <alternative>gh pr comment [PR_NUMBER] --repo [owner]/[repo] --body "[comment_text]"</alternative>
+      </cli_fallback>
+    </operation>
+
+    <operation name="create_review">
+      <mcp_approach>
+        <sequence>
+          1. create_pending_pull_request_review
+          2. add_pull_request_review_comment_to_pending_review (multiple times)
+          3. submit_pending_pull_request_review
+        </sequence>
+      </mcp_approach>
+      <cli_fallback>
+        <command>gh pr review [PR_NUMBER] --repo [owner]/[repo] --comment --body-file [review_file]</command>
+      </cli_fallback>
+    </operation>
+  </operation_patterns>
+
+  <error_handling>
+    <scenario name="mcp_server_unavailable">
+      <detection>
+        Error message contains "MCP server" or "github server not found"
+      </detection>
+      <action>
+        Immediately switch to CLI commands for all operations
+      </action>
+    </scenario>
+
+    <scenario name="api_rate_limit">
+      <detection>
+        Error contains "rate limit" or status code 403
+      </detection>
+      <action>
+        1. Wait briefly (30 seconds)
+        2. Retry with CLI using --limit flag
+        3. Reduce number of API calls
+      </action>
+    </scenario>
+
+    <scenario name="authentication_failure">
+      <detection>
+        Error contains "authentication" or status code 401
+      </detection>
+      <action>
+        1. Inform user about auth issue
+        2. Suggest checking gh auth status
+        3. Continue with available data
+      </action>
+    </scenario>
+
+    <scenario name="pr_not_found">
+      <detection>
+        Error contains "not found" or status code 404
+      </detection>
+      <action>
+        1. Verify PR number and repository
+        2. Ask user to confirm details
+        3. Check if PR is from a fork
+      </action>
+    </scenario>
+  </error_handling>
+
+  <data_handling>
+    <principle name="save_everything">
+      <description>Always save API responses to temp files</description>
+      <reason>Preserve data in case of failures</reason>
+    </principle>
+
+    <principle name="parse_json_safely">
+      <description>Use jq or built-in JSON parsing</description>
+      <example>
+        gh pr view --json files --jq '.files[].path'
+      </example>
+    </principle>
+
+    <principle name="handle_large_prs">
+      <description>For PRs with many files, process in batches</description>
+      <threshold>More than 50 files</threshold>
+    </principle>
+  </data_handling>
+
+  <cli_command_reference>
+    <command_group name="pr_info">
+      <command>gh pr view [number] --json [fields]</command>
+      <fields>
+        number, title, author, state, body, url, 
+        headRefName, baseRefName, files, additions, 
+        deletions, changedFiles, comments, reviews
+      </fields>
+    </command_group>
+
+    <command_group name="pr_interaction">
+      <command>gh pr checkout [number]</command>
+      <command>gh pr diff [number]</command>
+      <command>gh pr comment [number] --body "[text]"</command>
+      <command>gh pr review [number] --comment --body "[text]"</command>
+    </command_group>
+
+    <command_group name="issue_info">
+      <command>gh issue view [number] --json [fields]</command>
+      <fields>
+        number, title, body, author, state, 
+        labels, assignees, milestone
+      </fields>
+    </command_group>
+  </cli_command_reference>
+
+  <best_practices>
+    <practice>Always specify --repo to avoid ambiguity</practice>
+    <practice>Use --json for structured data</practice>
+    <practice>Save command outputs to temp files</practice>
+    <practice>Check gh auth status before operations</practice>
+    <practice>Handle both personal repos and org repos</practice>
+  </best_practices>
+</github_operations>

+ 356 - 0
.roo/rules-pr-reviewer/5_context_management.xml

@@ -0,0 +1,356 @@
+<context_management>
+  <overview>
+    Strategies for maintaining review context across delegated tasks and
+    ensuring no information is lost during the orchestration process.
+  </overview>
+
+  <context_files>
+    <file name="review-context.json">
+      <purpose>Central tracking file for the entire review process</purpose>
+      <location>.roo/temp/pr-[PR_NUMBER]/review-context.json</location>
+      <structure>
+        {
+          "prNumber": "string",
+          "repository": "string", 
+          "reviewStartTime": "ISO timestamp",
+          "calledByMode": "string or null",
+          "prMetadata": {
+            "title": "string",
+            "author": "string",
+            "state": "string",
+            "baseRefName": "string",
+            "headRefName": "string",
+            "additions": "number",
+            "deletions": "number",
+            "changedFiles": "number"
+          },
+          "linkedIssue": {
+            "number": "number",
+            "title": "string",
+            "body": "string"
+          },
+          "existingComments": [],
+          "existingReviews": [],
+          "filesChanged": [],
+          "delegatedTasks": [
+            {
+              "mode": "string",
+              "status": "pending|completed|failed",
+              "outputFile": "string",
+              "startTime": "ISO timestamp",
+              "endTime": "ISO timestamp"
+            }
+          ],
+          "findings": {
+            "critical": [],
+            "patterns": [],
+            "redundancy": [],
+            "architecture": [],
+            "tests": []
+          },
+          "reviewStatus": "initialized|analyzing|synthesizing|completed"
+        }
+      </structure>
+    </file>
+
+    <file name="pr-metadata.json">
+      <purpose>Raw PR data from GitHub</purpose>
+      <location>.roo/temp/pr-[PR_NUMBER]/pr-metadata.json</location>
+    </file>
+
+    <file name="existing-feedback.json">
+      <purpose>All existing comments and reviews</purpose>
+      <location>.roo/temp/pr-[PR_NUMBER]/existing-feedback.json</location>
+    </file>
+
+    <file name="pattern-analysis.md">
+      <purpose>Output from code mode delegation</purpose>
+      <location>.roo/temp/pr-[PR_NUMBER]/pattern-analysis.md</location>
+    </file>
+
+    <file name="architecture-review.md">
+      <purpose>Output from architect mode delegation</purpose>
+      <location>.roo/temp/pr-[PR_NUMBER]/architecture-review.md</location>
+    </file>
+
+    <file name="test-analysis.md">
+      <purpose>Output from test mode delegation</purpose>
+      <location>.roo/temp/pr-[PR_NUMBER]/test-analysis.md</location>
+    </file>
+
+    <file name="final-review.md">
+      <purpose>Synthesized review ready for posting</purpose>
+      <location>.roo/temp/pr-[PR_NUMBER]/final-review.md</location>
+    </file>
+  </context_files>
+
+  <update_patterns>
+    <pattern name="after_github_fetch">
+      <action>Update review-context.json with PR metadata</action>
+      <example><![CDATA[
+<read_file>
+<path>.roo/temp/pr-123/review-context.json</path>
+</read_file>
+
+<!-- Parse and update the JSON -->
+
+<write_to_file>
+<path>.roo/temp/pr-123/review-context.json</path>
+<content>
+{
+  ...existing,
+  "prMetadata": {
+    "title": "Fix user authentication",
+    "author": "developer123",
+    ...
+  },
+  "filesChanged": ["src/auth.ts", "tests/auth.test.ts"],
+  "reviewStatus": "analyzing"
+}
+</content>
+</write_to_file>
+      ]]></example>
+    </pattern>
+
+    <pattern name="after_delegation">
+      <action>Update delegatedTasks array with task status</action>
+      <fields>
+        - mode: Which mode was delegated to
+        - status: pending -> completed/failed
+        - outputFile: Where results were saved
+        - timestamps: Start and end times
+      </fields>
+    </pattern>
+
+    <pattern name="after_synthesis">
+      <action>Update findings object with categorized issues</action>
+      <categories>
+        - critical: Must-fix issues
+        - patterns: Pattern inconsistencies
+        - redundancy: Duplicate code findings
+        - architecture: Architectural concerns
+        - tests: Test-related issues
+      </categories>
+    </pattern>
+  </update_patterns>
+
+  <context_preservation_strategies>
+    <strategy name="atomic_updates">
+      <description>Always read-modify-write for JSON updates</description>
+      <steps>
+        1. Read current context file
+        2. Parse JSON
+        3. Update specific fields
+        4. Write entire updated JSON
+      </steps>
+    </strategy>
+
+    <strategy name="backup_critical_data">
+      <description>Save copies of important data</description>
+      <files>
+        - PR diff before analysis
+        - Existing comments before review
+        - Each delegation output
+      </files>
+    </strategy>
+
+    <strategy name="status_tracking">
+      <description>Track review progress through status field</description>
+      <states>
+        - initialized: Just started
+        - analyzing: Delegating tasks
+        - synthesizing: Combining results
+        - completed: Ready for user
+      </states>
+    </strategy>
+  </context_preservation_strategies>
+
+  <recovery_procedures>
+    <scenario name="partial_failure">
+      <description>Some delegations failed</description>
+      <action>
+        1. Mark failed tasks in context
+        2. Continue with available data
+        3. Note limitations in final review
+      </action>
+    </scenario>
+
+    <scenario name="context_corruption">
+      <description>JSON file becomes invalid</description>
+      <action>
+        1. Try to recover from backups
+        2. Reconstruct from individual files
+        3. Start fresh if necessary
+      </action>
+    </scenario>
+
+    <scenario name="interrupted_review">
+      <description>Review process interrupted</description>
+      <action>
+        1. Check reviewStatus field
+        2. Resume from last completed step
+        3. Re-run failed delegations
+      </action>
+    </scenario>
+  </recovery_procedures>
+
+  <best_practices>
+    <practice name="always_update_status">
+      Keep reviewStatus current to enable recovery
+    </practice>
+    
+    <practice name="timestamp_everything">
+      Add timestamps to all operations for debugging
+    </practice>
+    
+    <practice name="validate_json">
+      Ensure JSON is valid before writing
+    </practice>
+    
+    <practice name="use_descriptive_filenames">
+      Make it clear what each file contains
+    </practice>
+    
+    <practice name="clean_up_old_reviews">
+      Suggest cleaning .roo/temp/ periodically
+    </practice>
+  </best_practices>
+
+  <example_workflow>
+    <step number="1">
+      <action>Initialize context</action>
+      <code><![CDATA[
+<execute_command>
+<command>New-Item -ItemType Directory -Force -Path ".roo/temp/pr-123"</command>
+</execute_command>
+
+<write_to_file>
+<path>.roo/temp/pr-123/review-context.json</path>
+<content>
+{
+  "prNumber": "123",
+  "repository": "RooCodeInc/Roo-Code",
+  "reviewStartTime": "2025-01-04T18:00:00Z",
+  "calledByMode": null,
+  "prMetadata": {},
+  "linkedIssue": {},
+  "existingComments": [],
+  "existingReviews": [],
+  "filesChanged": [],
+  "delegatedTasks": [],
+  "findings": {
+    "critical": [],
+    "patterns": [],
+    "redundancy": [],
+    "architecture": [],
+    "tests": []
+  },
+  "reviewStatus": "initialized"
+}
+</content>
+</write_to_file>
+      ]]></code>
+    </step>
+
+    <step number="2">
+      <action>Update after GitHub fetch</action>
+      <code><![CDATA[
+<read_file>
+<path>.roo/temp/pr-123/review-context.json</path>
+</read_file>
+
+<!-- Update with PR data -->
+
+<write_to_file>
+<path>.roo/temp/pr-123/review-context.json</path>
+<content>
+{
+  ...existing,
+  "prMetadata": {
+    "title": "Fix user authentication",
+    "author": "developer123",
+    "state": "open",
+    "baseRefName": "main",
+    "headRefName": "fix-auth",
+    "additions": 150,
+    "deletions": 50,
+    "changedFiles": 3
+  },
+  "filesChanged": ["src/auth.ts", "tests/auth.test.ts", "docs/auth.md"],
+  "reviewStatus": "analyzing"
+}
+</content>
+</write_to_file>
+      ]]></code>
+    </step>
+
+    <step number="3">
+      <action>Track delegation</action>
+      <code><![CDATA[
+<!-- Before delegation -->
+<read_file>
+<path>.roo/temp/pr-123/review-context.json</path>
+</read_file>
+
+<!-- Update to add pending task -->
+<write_to_file>
+<path>.roo/temp/pr-123/review-context.json</path>
+<content>
+{
+  ...existing,
+  "delegatedTasks": [
+    ...existing,
+    {
+      "mode": "code",
+      "status": "pending",
+      "outputFile": "pattern-analysis.md",
+      "startTime": "2025-01-04T18:05:00Z",
+      "endTime": null
+    }
+  ]
+}
+</content>
+</write_to_file>
+
+<!-- After delegation completes -->
+<!-- Update task status to completed -->
+      ]]></code>
+    </step>
+
+    <step number="4">
+      <action>Synthesize results</action>
+      <code><![CDATA[
+<!-- Read all analysis files -->
+<read_file>
+<path>.roo/temp/pr-123/pattern-analysis.md</path>
+</read_file>
+
+<read_file>
+<path>.roo/temp/pr-123/architecture-review.md</path>
+</read_file>
+
+<read_file>
+<path>.roo/temp/pr-123/test-analysis.md</path>
+</read_file>
+
+<!-- Update findings and status -->
+<write_to_file>
+<path>.roo/temp/pr-123/review-context.json</path>
+<content>
+{
+  ...existing,
+  "findings": {
+    "critical": ["Missing error handling in auth.ts"],
+    "patterns": ["Inconsistent naming convention"],
+    "redundancy": ["Duplicate validation logic"],
+    "architecture": [],
+    "tests": ["Missing test for edge case"]
+  },
+  "reviewStatus": "completed"
+}
+</content>
+</write_to_file>
+      ]]></code>
+    </step>
+  </example_workflow>
+</context_management>

+ 19 - 5
.roomodes

@@ -139,14 +139,28 @@ customModes:
   - slug: pr-reviewer
     name: 🔍 PR Reviewer
     roleDefinition: |-
-      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
-      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.
-    whenToUse: Use this mode to review pull requests on the Roo-Code GitHub repository or any other repository if specified by the user.
+      You are Roo, a critical pull request review orchestrator specializing in code quality, architectural consistency, and codebase organization. Your expertise includes:
+      - Orchestrating comprehensive PR reviews by delegating specialized analysis tasks
+      - Analyzing pull request diffs with a critical eye for code organization and patterns
+      - Evaluating whether changes follow established codebase patterns and conventions
+      - Identifying redundant or duplicate code that already exists elsewhere
+      - Ensuring tests are properly organized with other similar tests
+      - Verifying that new features follow patterns established by similar existing features
+      - Detecting code smells, technical debt, and architectural inconsistencies
+      - Delegating deep codebase analysis to specialized modes when needed
+      - Maintaining context through structured report files in .roo/temp/pr-[number]/
+      - Ensuring proper internationalization (i18n) for UI changes
+      - Providing direct, constructive feedback that improves code quality
+      - Being appropriately critical to maintain high code standards
+      - Using GitHub CLI when MCP tools are unavailable
+      
+      You work primarily with the RooCodeInc/Roo-Code repository, creating context reports to track findings and delegating complex pattern analysis to specialized modes while maintaining overall review coordination. When called by other modes (Issue Fixer, PR Fixer), you focus only on analysis without commenting on the PR.
+    whenToUse: Use this mode to critically review pull requests, focusing on code organization, pattern consistency, and identifying redundancy or architectural issues. This mode orchestrates complex analysis tasks while maintaining review context.
     groups:
       - read
       - - edit
-        - fileRegex: \.md$
-          description: Markdown files only
+        - fileRegex: (\.md$|\.roo/temp/pr-.*\.(json|md|txt)$)
+          description: Markdown files and PR review context files
       - mcp
       - command
     source: project