Skip to content

Commit 62459e8

Browse files
daniel-lxscte
authored andcommitted
feat: add PR Fixer mode for resolving pull request issues (#4961)
* feat: add PR Fixer mode for resolving pull request issues - Add new PR Fixer mode to help address feedback and resolve issues in existing PRs - Include workflow instructions for analyzing PR comments, failing tests, and merge conflicts - Add best practices and common patterns for PR resolution - Include tool usage guidelines and examples - Add custom instructions for handling merge conflict markers in diffs * refactor: remove duplicate custom instructions
1 parent a397fd5 commit 62459e8

File tree

6 files changed

+313
-1
lines changed

6 files changed

+313
-1
lines changed

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

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<workflow_instructions>
2+
<mode_overview>
3+
This mode is designed to help resolve issues in existing pull requests. It analyzes PR feedback from GitHub, checks for failing tests and merge conflicts, gathers context, and guides the user toward a solution.
4+
</mode_overview>
5+
6+
<initialization_steps>
7+
<step number="1">
8+
<action>Understand the user's request</action>
9+
<details>
10+
Parse the user's input to identify the pull request URL or number. Extract the repository owner and name.
11+
</details>
12+
</step>
13+
<step number="2">
14+
<action>Gather PR context</action>
15+
<tools>
16+
<tool>use_mcp_tool (github): get_pull_request, get_pull_request_comments</tool>
17+
<tool>gh cli: Check workflow status and logs for failing tests.</tool>
18+
<tool>gh cli: Check for merge conflicts.</tool>
19+
</tools>
20+
</step>
21+
</initialization_steps>
22+
23+
<main_workflow>
24+
<phase name="analysis">
25+
<description>Analyze the gathered information to identify the core problems.</description>
26+
<steps>
27+
<step>Summarize review comments and requested changes.</step>
28+
<step>Identify the root cause of failing tests by analyzing logs.</step>
29+
<step>Determine if merge conflicts exist.</step>
30+
</steps>
31+
</phase>
32+
33+
<phase name="synthesis">
34+
<description>Synthesize the findings and present them to the user.</description>
35+
<steps>
36+
<step>Present a summary of the issues found (reviews, failing tests, conflicts).</step>
37+
<step>Use ask_followup_question to ask the user how they want to proceed with fixing the issues.</step>
38+
</steps>
39+
</phase>
40+
41+
<phase name="implementation">
42+
<description>Execute the user's chosen course of action.</description>
43+
<steps>
44+
<step>Check out the PR branch locally using 'gh pr checkout'.</step>
45+
<step>Apply code changes based on review feedback.</step>
46+
<step>Fix failing tests.</step>
47+
<step>Resolve conflicts by rebasing the PR branch and force-pushing.</step>
48+
</steps>
49+
</phase>
50+
</main_workflow>
51+
52+
<completion_criteria>
53+
<criterion>All actionable review comments have been addressed.</criterion>
54+
<criterion>All tests are passing.</criterion>
55+
<criterion>The PR is free of merge conflicts.</criterion>
56+
</completion_criteria>
57+
</workflow_instructions>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<best_practices>
2+
<general_principles>
3+
<principle priority="high">
4+
<name>Context is Key</name>
5+
<description>Always gather full context before attempting a fix. This includes reading all relevant PR comments, checking CI/CD logs, and understanding the surrounding code.</description>
6+
<rationale>Without full context, fixes may be incomplete or introduce new issues.</rationale>
7+
</principle>
8+
<principle priority="medium">
9+
<name>Incremental Fixes</name>
10+
<description>Address issues one at a time (e.g., fix tests first, then address comments). This makes the process more manageable and easier to validate.</description>
11+
<rationale>Tackling all issues at once can be complex and error-prone.</rationale>
12+
</principle>
13+
</general_principles>
14+
15+
<code_conventions>
16+
<convention category="merge_conflicts">
17+
<rule>How to correctly escape conflict markers when using apply_diff.</rule>
18+
<template>
19+
When removing merge conflict markers from files, you must **escape** them in your `SEARCH` section by prepending a backslash (`\`) at the beginning of the line. This prevents the system from mistaking them for actual diff syntax.
20+
21+
**Correct Format Example:**
22+
23+
```
24+
<<<<<<< SEARCH
25+
content before
26+
\<<<<<<< HEAD <-- Note the backslash here
27+
content after
28+
=======
29+
replacement content
30+
>>>>>>> REPLACE
31+
```
32+
33+
Without escaping, the system confuses your content with real diff markers.
34+
35+
You may include multiple diff blocks in a single request, but if any of the following markers appear within your `SEARCH` or `REPLACE` content, they must be escaped:
36+
37+
```
38+
\<<<<<<< SEARCH
39+
\=======
40+
\>>>>>>> REPLACE
41+
```
42+
43+
Only these three need to be escaped when used in content.
44+
</template>
45+
</convention>
46+
</code_conventions>
47+
48+
<quality_checklist>
49+
<category name="before_completion">
50+
<item>Have all review comments been addressed?</item>
51+
<item>Are all CI/CD checks passing?</item>
52+
<item>Is the PR free of merge conflicts?</item>
53+
<item>Have the changes been tested locally?</item>
54+
</category>
55+
</quality_checklist>
56+
</best_practices>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<common_patterns>
2+
<pattern name="checking_pr_status">
3+
<usage>A set of commands to quickly assess the state of a Pull Request.</usage>
4+
<template>
5+
<command tool="gh">
6+
gh pr status --json number,title,state,conflict,reviewDecision,headRefName,headRepositoryOwner
7+
</command>
8+
<command tool="gh">
9+
gh pr checks
10+
</command>
11+
<command tool="gh">
12+
gh pr view --comments
13+
</command>
14+
</template>
15+
</pattern>
16+
<pattern name="analyzing_failing_tests">
17+
<usage>Commands to investigate why a specific test is failing.</usage>
18+
<template>
19+
<command tool="gh">
20+
gh run list --workflow=<workflow_id> --branch=<branch_name> --json databaseId,name,status,conclusion
21+
</command>
22+
<command tool="gh">
23+
gh run view --log-failed <run_id>
24+
</command>
25+
</template>
26+
</pattern>
27+
<pattern name="resolving_conflicts_rebase">
28+
<usage>A sequence of commands to resolve merge conflicts locally using rebase.</usage>
29+
<template>
30+
<command tool="git">git checkout main</command>
31+
<command tool="git">git pull origin main</command>
32+
<command tool="git">git checkout <pr_branch></command>
33+
<command tool="git">git rebase main</command>
34+
<comment>After resolving conflicts manually, continue the rebase.</comment>
35+
<command tool="git">git rebase --continue</command>
36+
<comment>Force push with lease is preferred for safety.</comment>
37+
<command tool="git">git push --force-with-lease</command>
38+
<comment>If force-with-lease fails, a regular force push can be used.</comment>
39+
<command tool="git">git push --force</command>
40+
</template>
41+
</pattern>
42+
<pattern name="checking_out_pr">
43+
<usage>Command to check out a pull request branch locally.</usage>
44+
<template>
45+
<command tool="gh">gh pr checkout <pr_number_or_url></command>
46+
</template>
47+
</pattern>
48+
</common_patterns>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<tool_usage_guide>
2+
<tool_priorities>
3+
<priority level="1">
4+
<tool>use_mcp_tool (server: github)</tool>
5+
<when>Use at the start to get all review comments and PR metadata.</when>
6+
<why>Provides the core context of what needs to be fixed from a human perspective.</why>
7+
</priority>
8+
<priority level="2">
9+
<tool>gh pr checks</tool>
10+
<when>After getting comments, to check the technical status.</when>
11+
<why>Quickly identifies if there are failing automated checks that need investigation.</why>
12+
</priority>
13+
</tool_priorities>
14+
15+
<tool_specific_guidance>
16+
<tool name="use_mcp_tool (github: get_pull_request)">
17+
<best_practices>
18+
<practice>Always fetch details to get the branch name, owner, repo slug, and mergeable state.</practice>
19+
</best_practices>
20+
</tool>
21+
22+
<tool name="use_mcp_tool (github: get_pull_request_comments)">
23+
<best_practices>
24+
<practice>Parse all comments to create a checklist of required changes.</practice>
25+
<practice>Ignore comments that are not actionable or have been resolved.</practice>
26+
</best_practices>
27+
</tool>
28+
29+
<tool name="gh run view --log-failed">
30+
<best_practices>
31+
<practice>Use this command to get the exact error messages from failing tests.</practice>
32+
<practice>Search the log for keywords like 'error', 'failed', or 'exception' to quickly find the root cause.</practice>
33+
</best_practices>
34+
</tool>
35+
36+
<tool name="ask_followup_question">
37+
<best_practices>
38+
<practice>After analyzing all the problems (reviews, tests, conflicts), present a summary to the user.</practice>
39+
<practice>Provide clear, actionable next steps as suggestions.</practice>
40+
<practice>Example suggestions: "Address review comments first.", "Tackle the failing tests.", "Resolve merge conflicts."</practice>
41+
</best_practices>
42+
</tool>
43+
</tool_specific_guidance>
44+
</tool_usage_guide>

.roo/rules-pr-fixer/5_examples.xml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<complete_examples>
2+
<example name="fix_failing_tests_and_address_comments">
3+
<scenario>
4+
A pull request has a failing CI check and a review comment asking for a change.
5+
</scenario>
6+
7+
<user_request>
8+
Fix PR #4365 in RooCodeInc/Roo-Code.
9+
</user_request>
10+
11+
<workflow>
12+
<step number="1">
13+
<description>Get PR details and review comments.</description>
14+
<tool_use>
15+
<use_mcp_tool>
16+
<server_name>github</server_name>
17+
<tool_name>get_pull_request</tool_name>
18+
<arguments>
19+
{
20+
"owner": "RooCodeInc",
21+
"repo": "Roo-Code",
22+
"pullNumber": 4365
23+
}
24+
</arguments>
25+
</use_mcp_tool>
26+
<use_mcp_tool>
27+
<server_name>github</server_name>
28+
<tool_name>get_pull_request_comments</tool_name>
29+
<arguments>
30+
{
31+
"owner": "RooCodeInc",
32+
"repo": "Roo-Code",
33+
"pullNumber": 4365
34+
}
35+
</arguments>
36+
</use_mcp_tool>
37+
</tool_use>
38+
<expected_outcome>Get the branch name, list of review comments, and check for mergeability.</expected_outcome>
39+
</step>
40+
41+
<step number="2">
42+
<description>Check CI status.</description>
43+
<tool_use>
44+
<execute_command>
45+
<command>gh pr checks 4365</command>
46+
</execute_command>
47+
</tool_use>
48+
<analysis>Identify which check is failing.</analysis>
49+
</step>
50+
51+
<step number="3">
52+
<description>Get logs for the failing check.</description>
53+
<tool_use>
54+
<execute_command>
55+
<command>gh run view <run_id> --log-failed</command>
56+
</execute_command>
57+
</tool_use>
58+
<analysis>Find the specific error message causing the test to fail.</analysis>
59+
</step>
60+
61+
<step number="4">
62+
<description>Check out the pull request branch.</description>
63+
<tool_use>
64+
<execute_command>
65+
<command>gh pr checkout 4365</command>
66+
</execute_command>
67+
</tool_use>
68+
<analysis>The PR branch is now ready for local edits.</analysis>
69+
</step>
70+
71+
<step number="5">
72+
<description>Summarize findings and ask the user for the next action.</description>
73+
<tool_use>
74+
<ask_followup_question>
75+
<question>I've checked out the branch. I've found a failing test related to 'XYZ' and a review comment asking to rename a variable. How should we proceed?</question>
76+
<follow_up>
77+
<suggest>First, apply the change requested in the review comment.</suggest>
78+
<suggest>Let's start by fixing the failing test.</suggest>
79+
<suggest>Show me the code for the failing test and the file with the requested change.</suggest>
80+
</follow_up>
81+
</ask_followup_question>
82+
</tool_use>
83+
</step>
84+
</workflow>
85+
86+
<key_takeaways>
87+
<takeaway>Always gather all information before proposing a solution.</takeaway>
88+
<takeaway>Use a combination of the GitHub MCP server and the `gh` CLI to get a complete picture of the PR's status.</takeaway>
89+
</key_takeaways>
90+
</example>
91+
</complete_examples>

.roomodes

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,20 @@ customModes:
241241
description: Temporary documentation extraction files only
242242
- command
243243
- mcp
244-
244+
- slug: pr-fixer
245+
name: 🛠️ PR Fixer
246+
roleDefinition: "You are Roo, a pull request resolution specialist. Your focus
247+
is on addressing feedback and resolving issues within existing pull
248+
requests. Your expertise includes: - Analyzing PR review comments to
249+
understand required changes. - Checking CI/CD workflow statuses to
250+
identify failing tests. - Fetching and analyzing test logs to diagnose
251+
failures. - Identifying and resolving merge conflicts. - Guiding the user
252+
through the resolution process."
253+
whenToUse: Use this mode to fix pull requests. It can analyze PR feedback from
254+
GitHub, check for failing tests, and help resolve merge conflicts before
255+
applying the necessary code changes.
256+
groups:
257+
- read
258+
- edit
259+
- command
260+
- mcp

0 commit comments

Comments
 (0)