feat(mcp): expose the conflict resolver's hunk API over MCP

get_merge_conflicts and resolve_conflict_hunk let an MCP caller resolve a
leaveConflictsInTree merge hunk-by-hunk (ours/theirs/base/literal text)
instead of grep-parsing diff3 markers itself. Reuses the existing
TaskMergeService/ConflictMarkerParser machinery (adds MergeSegment.StartLine
and a non-staging TaskMergeService.WriteConflictFileAsync) rather than a
second parser. A partially resolved file is written without git add so
continue_merge keeps refusing while any hunk still has markers.
This commit is contained in:
mika kuns
2026-08-10 13:49:07 +02:00
parent 6a2a19cc9e
commit 5653daca6e
6 changed files with 335 additions and 6 deletions
+11
View File
@@ -25,4 +25,15 @@ internal static class McpToolDocs
/// <summary>Mutations that refuse to touch a task while its agent is running.</summary>
public const string NotWhileRunning = " Refused while the task is Running — cancel it first.";
/// <summary>
/// Explains this project's diff3 conflict-marker layout so a caller grepping only for
/// "&lt;&lt;&lt;&lt;&lt;&lt;&lt;/=======/&gt;&gt;&gt;&gt;&gt;&gt;&gt;" doesn't mistake the "|||||||" base section for one of the two sides.
/// No leading space (unlike the other consts here) since it also doubles as a DTO field default value.
/// </summary>
public const string Diff3Note =
"Conflicts are parsed in git's diff3 style: each hunk has an 'ours' side (the target branch) and a " +
"'theirs' side (the branch being merged in), plus an optional 'base' — the common-ancestor text for that " +
"hunk, shown between a third '|||||||' marker and the '=======' separator. base is null when git recorded " +
"none for that hunk.";
}