{# ============================================================================ #}
{# Template: conflict_resolution.txt                                            #}
{# Version: 1.1                                                                  #}
{# ============================================================================ #}
{#                                                                             #}
{# PURPOSE:                                                                    #}
{#   Prompt for resolving merge conflicts during rebase operations.             #}
{#   Agent receives conflicted files and must resolve them by editing files.     #}
{#                                                                             #}
{# WHEN USED:                                                                  #}
{#   During rebase operations when merge conflicts occur.                       #}
{#                                                                             #}
{# TRIGGER:                                                                    #}
{#   Git operation: rebase encounters conflicts.                                #}
{#                                                                             #}
{# VARIABLES:                                                                  #}
{#   CONTEXT   - Formatted section with PROMPT.md and PLAN.md content           #}
{#   CONFLICTS - Formatted section showing conflicted files                     #}
{#                                                                             #}
{# OUTPUT:                                                                     #}
{#   Primary: Edit files on disk to remove conflict markers                     #}
{#   Optional: JSON object with "resolved_files" mapping paths to content       #}
{#                                                                             #}
{# NOTES:                                                                      #}
{#   - Agent MUST NOT know we're in a rebase (security requirement)             #}
{#   - Prompt frames conflicts as "merge conflicts" not rebase conflicts         #}
{#   - File edits are validated for conflict marker removal                     #}
{# ============================================================================ #}

# MERGE CONFLICT RESOLUTION

There are merge conflicts that need to be resolved. Below are the files with conflicts, showing both versions of the conflicting changes.

{{CONTEXT}}

## Conflict Resolution Instructions

PRIMARY GOAL: Resolve all merge conflicts by editing the files on disk.

For each conflicted file below:
1. Review both versions of the changes (the 'ours' and 'theirs' sections)
2. Intelligently merge the changes, considering:
   - The task context above
   - The implementation plan if available
   - The intent of both versions
   - Code correctness and consistency
3. **EDIT THE FILE ON DISK** using the Edit tool to resolve the conflicts
   - Remove ALL conflict markers (<<<<<<<, =======, >>>>>>>)
   - Keep the merged content that best combines both versions

**CRITICAL**: You MUST use the Edit tool to modify each conflicted file on disk. This is the primary way conflicts are resolved. The files will be validated to ensure all conflict markers are removed.

OPTIONAL: After editing files, you may optionally provide JSON output confirming what was resolved. This is not required - successful file edits are sufficient.

## Conflicted Files

{{CONFLICTS}}

## Optional JSON Output Format

If you choose to provide JSON output (optional), use this format to confirm your resolutions:

```json
{
  "resolved_files": {
    "path/to/file1": "<complete resolved file content>",
    "path/to/file2": "<complete resolved file content>"
  }
}
```

Each resolved file should contain the COMPLETE file content, not just the changed sections. The content must be free of conflict markers.

**Note**: If you cannot resolve a particular conflict, you may mark it for manual resolution by omitting it from the resolved_files object. However, you should attempt to resolve all conflicts whenever possible.
