@@ -50,11 +50,32 @@ async function cleanup() {
5050 } catch { }
5151}
5252
53- async function fix ( pr : PR , files : string [ ] ) {
53+ async function fix ( pr : PR , files : string [ ] , prs : PR [ ] , applied : number [ ] , idx : number ) {
5454 console . log ( ` Trying to auto-resolve ${ files . length } conflict(s) with opencode...` )
55+
56+ const done =
57+ prs
58+ . filter ( ( x ) => applied . includes ( x . number ) )
59+ . map ( ( x ) => `- #${ x . number } : ${ x . title } ` )
60+ . join ( "\n" ) || "(none yet)"
61+
62+ const next =
63+ prs
64+ . slice ( idx + 1 )
65+ . map ( ( x ) => `- #${ x . number } : ${ x . title } ` )
66+ . join ( "\n" ) || "(none)"
67+
5568 const prompt = [
5669 `Resolve the current git merge conflicts while merging PR #${ pr . number } into the beta branch.` ,
70+ `PR #${ pr . number } : ${ pr . title } ` ,
5771 `Only touch these files: ${ files . join ( ", " ) } .` ,
72+ `Merged PRs on HEAD:\n${ done } ` ,
73+ `Pending PRs after this one (context only):\n${ next } ` ,
74+ "IMPORTANT: The conflict resolution must be consistent with already-merged PRs." ,
75+ "Pending PRs are context only; do not introduce their changes unless they are already present on HEAD." ,
76+ "Prefer already-merged PRs over the base branch when resolving stacked conflicts." ,
77+ "If a PR already deleted a file/directory, do not re-add it, instead apply changes in the new semantic location." ,
78+ "If a PR already changed an import, keep that change." ,
5879 "Keep the merge in progress, do not abort the merge, and do not create a commit." ,
5980 "When done, leave the working tree with no unmerged files." ,
6081 ] . join ( "\n" )
@@ -99,7 +120,7 @@ async function main() {
99120 const applied : number [ ] = [ ]
100121 const failed : FailedPR [ ] = [ ]
101122
102- for ( const pr of prs ) {
123+ for ( const [ idx , pr ] of prs . entries ( ) ) {
103124 console . log ( `\nProcessing PR #${ pr . number } : ${ pr . title } ` )
104125
105126 console . log ( " Fetching PR head..." )
@@ -119,7 +140,7 @@ async function main() {
119140 const files = await conflicts ( )
120141 if ( files . length > 0 ) {
121142 console . log ( " Failed to merge (conflicts)" )
122- if ( ! ( await fix ( pr , files ) ) ) {
143+ if ( ! ( await fix ( pr , files , prs , applied , idx ) ) ) {
123144 await cleanup ( )
124145 failed . push ( { number : pr . number , title : pr . title , reason : "Merge conflicts" } )
125146 await commentOnPR ( pr . number , "Merge conflicts with dev branch" )
0 commit comments