Skip to content

Commit ea631ee

Browse files
feat: add translation orchestration to PR Fixer mode (#5280)
Co-authored-by: Daniel Riccio <[email protected]>
1 parent e09d27c commit ea631ee

File tree

5 files changed

+276
-25
lines changed

5 files changed

+276
-25
lines changed

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,24 @@
4141
<phase name="implementation">
4242
<description>Execute the user's chosen course of action.</description>
4343
<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>
44+
<step>Check out the PR branch locally using 'gh pr checkout --force'.</step>
45+
<step>Determine if the PR is from a fork by checking 'gh pr view --json isCrossRepository'.</step>
46+
<step>Apply code changes based on review feedback using file editing tools.</step>
47+
<step>Fix failing tests by modifying test files or source code as needed.</step>
48+
<step>For conflict resolution: Use GIT_EDITOR=true for non-interactive rebases, then resolve conflicts via file editing.</step>
49+
<step>If changes affect user-facing content (i18n files, UI components, announcements), delegate translation updates using the new_task tool with translate mode.</step>
50+
<step>Commit changes using git commands.</step>
51+
<step>Push changes to the correct remote (origin for same-repo PRs, fork remote for cross-repo PRs) using 'git push --force-with-lease'.</step>
4852
</steps>
4953
</phase>
5054

5155
<phase name="validation">
5256
<description>Verify that the pushed changes resolve the issues.</description>
5357
<steps>
54-
<step>Use 'gh pr checks --watch' to monitor the CI/CD pipeline and ensure all workflows execute successfully.</step>
58+
<step>Use 'gh pr checks --watch' to monitor check status in real-time until all checks complete.</step>
59+
<step>If needed, check specific workflow runs with 'gh run list --pr' for detailed CI/CD pipeline status.</step>
60+
<step>Verify that all translation updates (if any) have been completed and committed.</step>
61+
<step>Confirm PR is ready for review by checking mergeable state with 'gh pr view --json'.</step>
5562
</steps>
5663
</phase>
5764
</main_workflow>
@@ -60,5 +67,6 @@
6067
<criterion>All actionable review comments have been addressed.</criterion>
6168
<criterion>All tests are passing.</criterion>
6269
<criterion>The PR is free of merge conflicts.</criterion>
70+
<criterion>All required translations have been completed and committed (if changes affect user-facing content).</criterion>
6371
</completion_criteria>
6472
</workflow_instructions>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
<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>
1111
<rationale>Tackling all issues at once can be complex and error-prone.</rationale>
1212
</principle>
13+
<principle priority="high">
14+
<name>Handle Fork Remotes Correctly</name>
15+
<description>Always check if a PR comes from a fork (cross-repository) before pushing changes. Use 'gh pr view --json isCrossRepository' to determine the correct remote.</description>
16+
<rationale>Pushing to the wrong remote (e.g., origin instead of fork) will fail for cross-repository PRs.</rationale>
17+
<example>
18+
<scenario>PR from a fork</scenario>
19+
<good>Check isCrossRepository, add fork remote if needed, push to fork</good>
20+
<bad>Always push to origin without checking PR source</bad>
21+
</example>
22+
</principle>
1323
</general_principles>
1424

1525
<code_conventions>

.roo/rules-pr-fixer/3_common_patterns.xml

Lines changed: 72 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,87 @@
2424
</command>
2525
</template>
2626
</pattern>
27-
<pattern name="resolving_conflicts_rebase">
28-
<usage>A sequence of commands to resolve merge conflicts locally using rebase.</usage>
27+
<pattern name="detecting_conflicts">
28+
<usage>Commands to detect merge conflicts.</usage>
29+
<template>
30+
<comment>Fetch latest main branch</comment>
31+
<command tool="git">git fetch origin main</command>
32+
<comment>Check if rebase would create conflicts</comment>
33+
<command tool="git">git rebase --dry-run origin/main</command>
34+
</template>
35+
</pattern>
36+
37+
<pattern name="non_interactive_rebase">
38+
<usage>Rebase operations using GIT_EDITOR to prevent interactive prompts.</usage>
2939
<template>
30-
<command tool="git">git checkout main</command>
31-
<command tool="git">git pull origin main</command>
3240
<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>
41+
<command tool="git">GIT_EDITOR=true git rebase main</command>
42+
<comment>If conflicts occur, resolve them manually then use 'git rebase --continue'</comment>
43+
<command tool="git">git push --force-with-lease <remote> <pr_branch></command>
44+
</template>
45+
</pattern>
46+
47+
<pattern name="conflict_status_check">
48+
<usage>Check current conflict status without interactive input.</usage>
49+
<template>
50+
<command tool="git">git status --porcelain</command>
51+
<command tool="git">git diff --name-only --diff-filter=U</command>
52+
<comment>List files with unresolved conflicts</comment>
53+
<command tool="git">git ls-files --unmerged</command>
4054
</template>
4155
</pattern>
4256
<pattern name="checking_out_pr">
43-
<usage>Command to check out a pull request branch locally.</usage>
57+
<usage>Check out a pull request branch locally.</usage>
58+
<template>
59+
<command tool="gh">gh pr checkout <pr_number_or_url> --force</command>
60+
<comment>Alternative if gh checkout fails:</comment>
61+
<command tool="git">git fetch origin pull/<pr_number>/head:<branch_name> && git checkout <branch_name></command>
62+
</template>
63+
</pattern>
64+
65+
<pattern name="determine_push_remote">
66+
<usage>Determine the correct remote to push to (handles forks).</usage>
67+
<template>
68+
<comment>Get PR metadata to check if it's from a fork</comment>
69+
<command tool="gh">gh pr view <pr_number> --json headRepositoryOwner,headRefName,isCrossRepository</command>
70+
<comment>If isCrossRepository is true, it's from a fork</comment>
71+
<command tool="git">git remote -v</command>
72+
<comment>Check if fork remote exists, otherwise add it</comment>
73+
<command tool="git">git remote add fork https://github.com/<fork_owner>/<repo_name>.git</command>
74+
<comment>Use appropriate remote based on PR source</comment>
75+
</template>
76+
</pattern>
77+
78+
<pattern name="real_time_monitoring">
79+
<usage>Monitor PR checks in real-time as they run.</usage>
80+
<template>
81+
<command tool="gh">gh pr checks <pr_number> --watch</command>
82+
<comment>Continuously monitor check status with automatic updates</comment>
83+
<alternative>For one-time status check: gh pr checks <pr_number> --json state,conclusion,name,detailsUrl</alternative>
84+
<command tool="gh">gh run list --pr <pr_number> --json databaseId,status,conclusion</command>
85+
</template>
86+
</pattern>
87+
88+
<pattern name="safe_push_operations">
89+
<usage>Push operations that handle both origin and fork remotes correctly.</usage>
4490
<template>
45-
<command tool="gh">gh pr checkout <pr_number_or_url></command>
91+
<comment>First determine the correct remote (origin or fork)</comment>
92+
<command tool="gh">gh pr view <pr_number> --json headRepositoryOwner,headRefName,isCrossRepository</command>
93+
<comment>If isCrossRepository is false, push to origin</comment>
94+
<command tool="git">git push --force-with-lease origin <branch_name></command>
95+
<comment>If isCrossRepository is true, push to fork remote</comment>
96+
<command tool="git">git push --force-with-lease fork <branch_name></command>
97+
<comment>If force-with-lease fails, fetch and retry</comment>
98+
<command tool="git">git fetch <remote> <branch_name></command>
99+
<command tool="git">git push --force <remote> <branch_name></command>
46100
</template>
47101
</pattern>
48-
<pattern name="watching_pr_checks">
49-
<usage>After pushing changes, use this command to monitor the CI/CD pipeline in real-time.</usage>
102+
103+
<pattern name="automated_commit_operations">
104+
<usage>Commit operations that work in automated environments.</usage>
50105
<template>
51-
<command tool="gh">gh pr checks --watch</command>
106+
<command tool="git">git add .</command>
107+
<command tool="git">git commit -m "<commit_message>"</command>
52108
</template>
53109
</pattern>
54110
</common_patterns>

.roo/rules-pr-fixer/4_tool_usage.xml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
<why>Quickly identifies if there are failing automated checks that need investigation.</why>
1212
</priority>
1313
<priority level="3">
14+
<tool>new_task (mode: translate)</tool>
15+
<when>When changes affect user-facing content, i18n files, or UI components that require translation.</when>
16+
<why>Ensures translation consistency across all supported languages when PR fixes involve user-facing changes.</why>
17+
</priority>
18+
<priority level="4">
1419
<tool>gh pr checks --watch</tool>
1520
<when>After pushing a fix, to confirm that the changes have resolved the CI/CD failures.</when>
1621
<why>Provides real-time feedback on whether the fix was successful.</why>
@@ -35,6 +40,41 @@
3540
<best_practices>
3641
<practice>Use this command to get the exact error messages from failing tests.</practice>
3742
<practice>Search the log for keywords like 'error', 'failed', or 'exception' to quickly find the root cause.</practice>
43+
<practice>Always specify run ID explicitly to avoid interactive selection prompts.</practice>
44+
</best_practices>
45+
</tool>
46+
47+
<tool name="gh pr checkout">
48+
<best_practices>
49+
<practice>Use --force flag: 'gh pr checkout <pr_number> --force'</practice>
50+
<practice>If gh checkout fails, use: git fetch origin pull/<pr_number>/head:<branch_name></practice>
51+
</best_practices>
52+
</tool>
53+
54+
<tool name="git operations">
55+
<best_practices>
56+
<practice>Use --force-with-lease for safer force pushing.</practice>
57+
<practice>Use GIT_EDITOR=true to prevent interactive prompts during rebases.</practice>
58+
<practice>Always determine the correct remote before pushing (origin vs fork).</practice>
59+
</best_practices>
60+
<remote_handling>
61+
<step>Check if PR is from a fork: 'gh pr view <pr_number> --json isCrossRepository'</step>
62+
<step>If isCrossRepository is true, add fork remote if needed</step>
63+
<step>Push to appropriate remote: 'git push --force-with-lease <remote> <branch>'</step>
64+
</remote_handling>
65+
<conflict_resolution>
66+
<step>Use 'GIT_EDITOR=true git rebase main' to start rebase</step>
67+
<step>If conflicts occur, edit files to resolve them</step>
68+
<step>Use 'git add .' and 'git rebase --continue' to proceed</step>
69+
</conflict_resolution>
70+
</tool>
71+
72+
<tool name="gh pr checks">
73+
<best_practices>
74+
<practice>Use --watch flag to monitor checks in real-time: 'gh pr checks <pr_number> --watch'</practice>
75+
<practice>For one-time status checks, use --json flag: 'gh pr checks <pr_number> --json state,conclusion,name'</practice>
76+
<practice>The --watch flag automatically updates the display as check statuses change.</practice>
77+
<practice>Use 'gh run list --pr <pr_number>' to get detailed workflow status if needed.</practice>
3878
</best_practices>
3979
</tool>
4080

@@ -45,5 +85,34 @@
4585
<practice>Example suggestions: "Address review comments first.", "Tackle the failing tests.", "Resolve merge conflicts."</practice>
4686
</best_practices>
4787
</tool>
88+
89+
<tool name="new_task (mode: translate)">
90+
<best_practices>
91+
<practice>Use when PR fixes involve changes to user-facing strings, i18n files, or UI components.</practice>
92+
<practice>Provide specific details about what content needs translation in the message.</practice>
93+
<practice>Include file paths and descriptions of the changes made.</practice>
94+
<practice>List all affected languages that need updates.</practice>
95+
<practice>Wait for translation completion before proceeding to validation phase.</practice>
96+
</best_practices>
97+
<when_to_use>
98+
<trigger>Changes to webview-ui/src/i18n/locales/en/*.json files</trigger>
99+
<trigger>Changes to src/i18n/locales/en/*.json files</trigger>
100+
<trigger>Modifications to UI components with user-facing text</trigger>
101+
<trigger>Updates to announcement files or documentation requiring localization</trigger>
102+
<trigger>Addition of new error messages or user notifications</trigger>
103+
</when_to_use>
104+
<example_usage><![CDATA[
105+
<new_task>
106+
<mode>translate</mode>
107+
<message>Translation updates needed for PR #1234 fixes. Please translate the following changes:
108+
109+
Files modified:
110+
- webview-ui/src/i18n/locales/en/common.json: Added new error message "connection_failed"
111+
- webview-ui/src/components/settings/ApiSettings.tsx: Updated button text from "Save" to "Save Configuration"
112+
113+
Please ensure all supported languages (ca, de, es, fr, hi, id, it, ja, ko, nl, pl, pt-BR, ru, tr, vi, zh-CN, zh-TW) are updated with appropriate translations for these changes.</message>
114+
</new_task>
115+
]]></example_usage>
116+
</tool>
48117
</tool_specific_guidance>
49118
</tool_usage_guide>

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

Lines changed: 112 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<description>Check out the pull request branch.</description>
6363
<tool_use>
6464
<execute_command>
65-
<command>gh pr checkout 4365</command>
65+
<command>gh pr checkout 4365 --force</command>
6666
</execute_command>
6767
</tool_use>
6868
<analysis>The PR branch is now ready for local edits.</analysis>
@@ -82,13 +82,13 @@
8282
</tool_use>
8383
</step>
8484
<step number="6">
85-
<description>After pushing the changes, watch the PR checks to confirm the fix.</description>
85+
<description>After pushing the changes, monitor PR checks in real-time.</description>
8686
<tool_use>
8787
<execute_command>
88-
<command>gh pr checks --watch</command>
88+
<command>gh pr checks 4365 --watch</command>
8989
</execute_command>
9090
</tool_use>
91-
<analysis>Confirm that all checks are passing after the fix.</analysis>
91+
<analysis>Monitor checks continuously until all complete. The --watch flag provides real-time updates as check statuses change.</analysis>
9292
</step>
9393
</workflow>
9494

@@ -97,4 +97,112 @@
9797
<takeaway>Use a combination of the GitHub MCP server and the `gh` CLI to get a complete picture of the PR's status.</takeaway>
9898
</key_takeaways>
9999
</example>
100+
101+
<example name="fix_pr_with_translation_requirements">
102+
<scenario>
103+
A pull request has review comments requesting UI text changes that require translation updates across all supported languages.
104+
</scenario>
105+
106+
<user_request>
107+
Fix PR #1234 in RooCodeInc/Roo-Code - the reviewer asked to change button text and there are some failing tests.
108+
</user_request>
109+
110+
<workflow>
111+
<step number="1">
112+
<description>Get PR details and analyze changes.</description>
113+
<tool_use>
114+
<use_mcp_tool>
115+
<server_name>github</server_name>
116+
<tool_name>get_pull_request</tool_name>
117+
<arguments>
118+
{
119+
"owner": "RooCodeInc",
120+
"repo": "Roo-Code",
121+
"pullNumber": 1234
122+
}
123+
</arguments>
124+
</use_mcp_tool>
125+
</tool_use>
126+
<expected_outcome>Identify the files changed and review feedback requiring UI text modifications.</expected_outcome>
127+
</step>
128+
129+
<step number="2">
130+
<description>Check out PR and apply the requested changes.</description>
131+
<tool_use>
132+
<execute_command>
133+
<command>gh pr checkout 1234 --force</command>
134+
</execute_command>
135+
</tool_use>
136+
<analysis>Make the requested button text changes in the UI components.</analysis>
137+
</step>
138+
139+
<step number="3">
140+
<description>Identify translation requirements and delegate to translate mode.</description>
141+
<tool_use>
142+
<new_task>
143+
<mode>translate</mode>
144+
<message>Translation updates needed for PR #1234 fixes. The following changes were made based on review feedback:
145+
146+
Files modified:
147+
- webview-ui/src/components/settings/ApiSettings.tsx: Changed button text from "Save" to "Save Configuration"
148+
- webview-ui/src/i18n/locales/en/common.json: Updated key "save_button" to "save_config_button"
149+
150+
Please update all supported languages (ca, de, es, fr, hi, id, it, ja, ko, nl, pl, pt-BR, ru, tr, vi, zh-CN, zh-TW) with appropriate translations for:
151+
- New key "save_config_button" with translation equivalent to "Save Configuration"
152+
- Any other text changes that affect user-facing content
153+
154+
Ensure consistency across all language files and maintain the same context and tone as existing translations.</message>
155+
</new_task>
156+
</tool_use>
157+
<expected_outcome>Translation subtask created and all language files updated.</expected_outcome>
158+
</step>
159+
160+
<step number="4">
161+
<description>Commit all changes including translations with automated git configuration.</description>
162+
<tool_use>
163+
<execute_command>
164+
<command>git add . && git commit -m "fix: update button text and translations as requested in review"</command>
165+
</execute_command>
166+
</tool_use>
167+
<analysis>All code changes and translation updates are now committed.</analysis>
168+
</step>
169+
170+
<step number="5">
171+
<description>Check if PR is from a fork and push to correct remote.</description>
172+
<tool_use>
173+
<execute_command>
174+
<command>gh pr view 1234 --json isCrossRepository,headRepositoryOwner,headRefName</command>
175+
</execute_command>
176+
</tool_use>
177+
<analysis>Determine if this is a cross-repository PR to know which remote to push to.</analysis>
178+
</step>
179+
180+
<step number="6">
181+
<description>Push changes to the appropriate remote.</description>
182+
<tool_use>
183+
<execute_command>
184+
<command>git push --force-with-lease origin <branch_name></command>
185+
</execute_command>
186+
</tool_use>
187+
<analysis>Push changes safely to update the pull request. Use 'fork' remote instead if PR is from a fork.</analysis>
188+
</step>
189+
190+
<step number="7">
191+
<description>Monitor CI status in real-time.</description>
192+
<tool_use>
193+
<execute_command>
194+
<command>gh pr checks 1234 --watch</command>
195+
</execute_command>
196+
</tool_use>
197+
<analysis>Watch CI checks continuously until all tests pass. The --watch flag provides automatic updates as check statuses change.</analysis>
198+
</step>
199+
</workflow>
200+
201+
<key_takeaways>
202+
<takeaway>Always check if PR fixes involve user-facing content that requires translation.</takeaway>
203+
<takeaway>Use new_task with translate mode to ensure consistent translation updates.</takeaway>
204+
<takeaway>Include detailed context about what changed and why in translation requests.</takeaway>
205+
<takeaway>Verify translation completeness before considering the PR fix complete.</takeaway>
206+
</key_takeaways>
207+
</example>
100208
</complete_examples>

0 commit comments

Comments
 (0)