Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions .roo/rules-merge-resolver/1_workflow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
<tools>
<tool>gh pr checkout [PR_NUMBER] --force</tool>
<tool>git fetch origin main</tool>
<tool>git rebase origin/main</tool>
<tool>GIT_EDITOR=true git rebase origin/main</tool>
</tools>
<details>
Force checkout the PR branch to ensure clean state
Fetch the latest main branch
Attempt to rebase onto main to reveal conflicts
Use GIT_EDITOR=true to ensure non-interactive rebase
</details>
</step>

Expand Down Expand Up @@ -108,8 +109,8 @@
</command>

<command name="rebase_main">
<syntax>git rebase origin/main</syntax>
<purpose>Rebase current branch onto main to reveal conflicts</purpose>
<syntax>GIT_EDITOR=true git rebase origin/main</syntax>
<purpose>Rebase current branch onto main to reveal conflicts (non-interactive)</purpose>
</command>

<command name="get_blame_info">
Expand All @@ -133,6 +134,20 @@
</command>
</git_commands>

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical issue: There's a duplicate </git_commands> closing tag here. The continue_rebase command block starting at line 137 is placed after the first closing tag, creating invalid XML structure. Could we move the continue_rebase command inside the existing git_commands section before line 136?

<command name="continue_rebase">
<syntax>GIT_EDITOR=true git rebase --continue</syntax>
<purpose>Continue rebase after resolving conflicts (non-interactive)</purpose>
</command>
</git_commands>

<environment_variables>
<variable name="GIT_EDITOR">
<value>true</value>
<purpose>Set to 'true' (a no-op command) to prevent interactive prompts during rebase operations</purpose>
<usage>Prefix git rebase commands with GIT_EDITOR=true to ensure non-interactive execution</usage>
</variable>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding GIT_SEQUENCE_EDITOR to the environment variables section for completeness. While GIT_EDITOR=true handles most cases, interactive rebases might also trigger GIT_SEQUENCE_EDITOR. Would it be helpful to document both for comprehensive coverage?

</environment_variables>

<completion_criteria>
<criterion>All merge conflicts have been resolved</criterion>
<criterion>Resolved files have been staged</criterion>
Expand Down
57 changes: 53 additions & 4 deletions .roo/rules-merge-resolver/3_tool_usage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<practice>Chain git commands with && for efficiency</practice>
<practice>Use --format options for structured output</practice>
<practice>Capture command output for parsing</practice>
<practice>Use GIT_EDITOR=true for non-interactive git rebase operations</practice>
<practice>Set environment variables inline to avoid prompts during automation</practice>
</best_practices>

<common_commands>
Expand All @@ -46,7 +48,7 @@

<command>
<purpose>Rebase onto main to reveal conflicts</purpose>
<syntax>git rebase origin/main</syntax>
<syntax>GIT_EDITOR=true git rebase origin/main</syntax>
</command>

<command>
Expand All @@ -71,7 +73,7 @@

<command>
<purpose>Continue rebase after resolution</purpose>
<syntax>git rebase --continue</syntax>
<syntax>GIT_EDITOR=true git rebase --continue</syntax>
</command>
</common_commands>
</tool>
Expand Down Expand Up @@ -152,7 +154,7 @@ const config = {
<step>execute_command - Get PR info with gh CLI</step>
<step>execute_command - Checkout PR with gh pr checkout --force</step>
<step>execute_command - Fetch origin main</step>
<step>execute_command - Rebase onto origin/main</step>
<step>execute_command - Rebase onto origin/main with GIT_EDITOR=true</step>
<step>execute_command - Check for conflicts with git status</step>
</sequence>
</pattern>
Expand All @@ -178,13 +180,22 @@ const config = {
<pattern name="complete_rebase">
<sequence>
<step>execute_command - Check all conflicts resolved</step>
<step>execute_command - Continue rebase with git rebase --continue</step>
<step>execute_command - Continue rebase with GIT_EDITOR=true git rebase --continue</step>
<step>execute_command - Verify clean status</step>
</sequence>
</pattern>
</tool_combination_patterns>

<error_handling>
<scenario name="interactive_prompt_blocking">
<description>Git commands waiting for interactive input</description>
<approach>
Use GIT_EDITOR=true to bypass editor prompts
Set GIT_SEQUENCE_EDITOR=true for sequence editing
Consider --no-edit flag for commit operations
</approach>
</scenario>

<scenario name="no_conflicts_after_rebase">
<description>Rebase completes without conflicts</description>
<approach>
Expand Down Expand Up @@ -225,4 +236,42 @@ const config = {
</approach>
</scenario>
</error_handling>

<non_interactive_operations>
<overview>
Ensuring git operations run without requiring user interaction is critical
for automated conflict resolution. The mode uses environment variables to
bypass interactive prompts.
</overview>

<techniques>
<technique name="GIT_EDITOR">
<description>Set to 'true' (a no-op command) to skip editor prompts</description>
<usage>GIT_EDITOR=true git rebase --continue</usage>
<when>During rebase operations that would normally open an editor</when>
</technique>

<technique name="GIT_SEQUENCE_EDITOR">
<description>Skip interactive rebase todo editing</description>
<usage>GIT_SEQUENCE_EDITOR=true git rebase -i HEAD~3</usage>
<when>When interactive rebase is triggered but no editing needed</when>
</technique>

<technique name="commit_flags">
<description>Use flags to avoid interactive prompts</description>
<examples>
<example>git commit --no-edit (use existing message)</example>
<example>git merge --no-edit (skip merge message editing)</example>
<example>git cherry-pick --no-edit (keep original message)</example>
</examples>
</technique>
</techniques>

<best_practices>
<practice>Always test commands locally first to identify potential prompts</practice>
<practice>Combine environment variables when multiple editors might be invoked</practice>
<practice>Document why non-interactive mode is used in comments</practice>
<practice>Have fallback strategies if automation fails</practice>
</best_practices>
</non_interactive_operations>
</merge_resolver_tool_usage>
7 changes: 4 additions & 3 deletions .roo/rules-merge-resolver/4_complete_example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ From github.com:user/repo

<tool_use><![CDATA[
<execute_command>
<command>git rebase origin/main</command>
<command>GIT_EDITOR=true git rebase origin/main</command>
</execute_command>
]]></tool_use>
<expected_output><![CDATA[
Expand Down Expand Up @@ -251,7 +251,7 @@ abc123 Fix: Add listener cleanup to prevent memory leak

<tool_use><![CDATA[
<execute_command>
<command>git rebase --continue</command>
<command>GIT_EDITOR=true git rebase --continue</command>
</execute_command>
]]></tool_use>
<expected_output><![CDATA[
Expand Down Expand Up @@ -309,7 +309,8 @@ Both the feature refactor and the critical bugfix have been preserved in the res
<takeaway>Use git blame and commit messages to understand the history</takeaway>
<takeaway>Combine non-conflicting improvements when possible</takeaway>
<takeaway>Prioritize bugfixes while accommodating refactors</takeaway>
<takeaway>Complete the rebase process with git rebase --continue</takeaway>
<takeaway>Use GIT_EDITOR=true to ensure non-interactive rebase operations</takeaway>
<takeaway>Complete the rebase process with GIT_EDITOR=true git rebase --continue</takeaway>
<takeaway>Validate that both sets of changes work together</takeaway>
</key_takeaways>
</merge_resolver_example>
Loading