Skip to content

Commit 4550e50

Browse files
committed
Clarify rebase conflict repair prompts
1 parent a6ee02e commit 4550e50

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

‎src/repair/fix-prompt-builder.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ test("fix prompt includes rebase and previous no-diff recovery details", () => {
144144
base_ref: "origin/main",
145145
base_sha: "def456",
146146
detail: "CONFLICT (content): CHANGELOG.md",
147+
unmerged_paths: ["CHANGELOG.md", "src/messages.ts"],
147148
},
148149
maxEditAttempts: 5,
149150
});
@@ -153,7 +154,11 @@ test("fix prompt includes rebase and previous no-diff recovery details", () => {
153154
assert.match(prompt, /Existing repair branch detected/);
154155
assert.match(prompt, /Source head before edit: abc123/);
155156
assert.match(prompt, /Deterministic pre-edit rebase: conflicts onto origin\/main \(def456\)/);
156-
assert.match(prompt, /Resolve the active rebase conflicts/);
157+
assert.match(prompt, /Conflict-first mode:/);
158+
assert.match(prompt, /resolve only the active rebase conflicts before doing any feature repair/);
159+
assert.match(prompt, /git status --short/);
160+
assert.match(prompt, /git rebase --continue/);
161+
assert.match(prompt, /Unmerged conflict paths: CHANGELOG\.md, src\/messages\.ts/);
157162
assert.match(prompt, /Rebase output: CONFLICT \(content\): CHANGELOG\.md/);
158163
assert.match(prompt, /Previous attempt produced no target repo diff/);
159164
assert.match(prompt, /Previous no-diff summary: Analyzed without editing files/);

‎src/repair/fix-prompt-builder.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,23 @@ function renderRebaseResult(rebaseResult: LooseRecord) {
284284
const baseRef = String(rebaseResult.base_ref ?? "origin/main");
285285
const baseSha = String(rebaseResult.base_sha ?? "unknown");
286286
const detail = compactText(String(rebaseResult.detail ?? "").trim(), 800);
287+
const unmergedPaths = Array.isArray(rebaseResult.unmerged_paths)
288+
? rebaseResult.unmerged_paths.map((entry: unknown) => String(entry)).filter(Boolean)
289+
: [];
287290
return [
288291
`Deterministic pre-edit rebase: ${status} onto ${baseRef} (${baseSha}).`,
289292
status === "conflicts"
290-
? "Resolve the active rebase conflicts, continue or finish the rebase, and leave the checkout in a normal non-rebasing state before returning."
293+
? [
294+
"Conflict-first mode:",
295+
"- resolve only the active rebase conflicts before doing any feature repair;",
296+
"- inspect `git status --short` and the conflicted files listed below;",
297+
"- remove all conflict markers and stage the resolved files;",
298+
"- run `git rebase --continue` until the checkout is no longer rebasing;",
299+
"- do not broaden the patch while conflicts remain.",
300+
].join("\n")
301+
: "",
302+
status === "conflicts" && unmergedPaths.length > 0
303+
? `Unmerged conflict paths: ${unmergedPaths.join(", ")}`
291304
: "",
292305
detail ? `Rebase output: ${detail}` : "",
293306
]

0 commit comments

Comments
 (0)