@gitkraken/conflict-tools 0.7.1-beta.10 → 0.7.1-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/resolution/edit-apply.js +4 -5
- package/dist/resolver/prompt.js +2 -5
- package/dist/resolver/refine-pass.d.ts +0 -1
- package/dist/resolver/refine-pass.js +1 -1
- package/dist/resolver/refine-tools.d.ts +0 -1
- package/dist/resolver/refine-tools.js +4 -4
- package/dist/resolver/resolve-conflict.js +1 -1
- package/dist/types/hints.d.ts +0 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -260,7 +260,6 @@ A `merged` chunk is also checked for brackets: the `{}`, `()` and `[]` balance (
|
|
|
260
260
|
- `insert` — inserts `content` after the line matched by `anchor` at `startLine`.
|
|
261
261
|
- `replace` — replaces lines `startLine`–`endLine` (matched by `anchor`) with `content`.
|
|
262
262
|
- `delete` — removes lines `startLine`–`endLine` matched by `anchor`. No `content`.
|
|
263
|
-
- `verify` — confirms lines at `startLine` (optionally through `endLine`) match `anchor` without modifying content.
|
|
264
263
|
|
|
265
264
|
### `resolveConflicts(deps, context?) + applyResolutions(resolutions, deps)` — batch
|
|
266
265
|
|
|
@@ -609,7 +608,7 @@ score(resolution, goldenFile);
|
|
|
609
608
|
| `refine:final-text` | Refine model emitted its final description (`text`) |
|
|
610
609
|
| `refine:completed` | Refine finished successfully (`appliedCount`) |
|
|
611
610
|
| `refine:failed` | Refine threw before completing (`reason`) |
|
|
612
|
-
| `refine:bailed` | Refine bailed early after consecutive apply errors, keeping edits that landed (`reason`) |
|
|
611
|
+
| `refine:bailed` | Refine bailed early after consecutive apply errors, or ran out of steps or model budget, keeping edits that landed (`reason` says which) |
|
|
613
612
|
| `refine:discarded` | A refine/fix edit batch was rejected — it reintroduced conflict markers, or (in the fix phase) it introduced an error the file did not have (`reason` says which) |
|
|
614
613
|
| `refine:lost-addition` | A side's added lines are missing from the resolution (`side`, `startLine`, `endLine`, `lines`, `phase`: `before-refine` or `after-refine`) |
|
|
615
614
|
| `refine:bracket-imbalance` | A merged chunk's bracket balance matches neither side nor the base (`markerIndex`, `pair`, `merged`, `ours`, `theirs`) |
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
function e(e,t){let n=e.split(`
|
|
2
|
-
`);if(t.kind===`insert`){if(t.startLine<1||t.startLine>n.length)return{valid:!1,reason:`out-of-bounds`};let e=n[t.startLine-1]??``;return e===t.anchor?{valid:!0}:{valid:!1,reason:`anchor-mismatch`,expected:t.anchor,actual:e}}
|
|
3
|
-
`);return
|
|
4
|
-
`);
|
|
5
|
-
`),u=[];for(let e of c){let t=r[e];if(t){if(t.kind===`verify`){i.set(e,{opIndex:e,status:`verified`});continue}t.kind===`insert`?l.splice(t.startLine,0,...t.content.split(`
|
|
2
|
+
`);if(t.kind===`insert`){if(t.startLine<1||t.startLine>n.length)return{valid:!1,reason:`out-of-bounds`};let e=n[t.startLine-1]??``;return e===t.anchor?{valid:!0}:{valid:!1,reason:`anchor-mismatch`,expected:t.anchor,actual:e}}let r=t.endLine;if(t.startLine<1||t.startLine>r||r>n.length)return{valid:!1,reason:`out-of-bounds`};let i=n.slice(t.startLine-1,r).join(`
|
|
3
|
+
`);return i===t.anchor?{valid:!0}:{valid:!1,reason:`anchor-mismatch`,expected:t.anchor,actual:i}}function t(e,t){if(e.kind===`insert`&&t.kind===`insert`)return!1;let n=e.startLine,r=e.kind===`insert`?e.startLine:e.endLine,i=t.startLine;return n<=(t.kind===`insert`?t.startLine:t.endLine)&&i<=r}function n(n,r){let i=new Map,a=r.map(t=>e(n,t));for(let e=0;e<r.length;e++){let t=a[e];t&&!t.valid&&(t.reason===`anchor-mismatch`?i.set(e,{opIndex:e,status:`skipped`,reason:`anchor-mismatch`,expected:t.expected,actual:t.actual}):i.set(e,{opIndex:e,status:`skipped`,reason:t.reason}))}let o=[];for(let e=0;e<r.length;e++)i.has(e)||o.push(e);let s=new Set;for(let e=0;e<o.length;e++)for(let n=e+1;n<o.length;n++){let i=o[e],a=o[n],c=i===void 0?void 0:r[i],l=a===void 0?void 0:r[a];i!==void 0&&a!==void 0&&c&&l&&t(c,l)&&(s.add(i),s.add(a))}for(let e of s)i.set(e,{opIndex:e,status:`skipped`,reason:`overlap`});let c=o.filter(e=>!s.has(e));c.sort((e,t)=>(r[t]?.startLine??0)-(r[e]?.startLine??0));let l=n.split(`
|
|
4
|
+
`),u=[];for(let e of c){let t=r[e];t&&(t.kind===`insert`?l.splice(t.startLine,0,...t.content.split(`
|
|
6
5
|
`)):t.kind===`replace`?l.splice(t.startLine-1,t.endLine-t.startLine+1,...t.content.split(`
|
|
7
|
-
`)):l.splice(t.startLine-1,t.endLine-t.startLine+1),u.push(t),i.set(e,{opIndex:e,status:`applied`})}
|
|
6
|
+
`)):l.splice(t.startLine-1,t.endLine-t.startLine+1),u.push(t),i.set(e,{opIndex:e,status:`applied`}))}let d=[];for(let e=0;e<r.length;e++){let t=i.get(e);t&&d.push(t)}return{content:l.join(`
|
|
8
7
|
`),edits:u,results:d}}export{n as applyEditOps};
|
package/dist/resolver/prompt.js
CHANGED
|
@@ -125,11 +125,10 @@ When the user message says "Delete-modify conflict", one side deleted the file w
|
|
|
125
125
|
|
|
126
126
|
## Optional Refinement Phase (Phase 2)
|
|
127
127
|
|
|
128
|
-
After you respond, an optional Phase 2 may run on the resolved file. Phase 2 can apply targeted line-level edits using an \`edit_file_lines\` tool with
|
|
128
|
+
After you respond, an optional Phase 2 may run on the resolved file. Phase 2 can apply targeted line-level edits using an \`edit_file_lines\` tool with three operation kinds:
|
|
129
129
|
- \`insert\`: add new lines after a specified line
|
|
130
130
|
- \`replace\`: rewrite a line range
|
|
131
131
|
- \`delete\`: remove a line range
|
|
132
|
-
- \`verify\`: confirm specific lines are present without modifying them
|
|
133
132
|
|
|
134
133
|
Phase 2 is driven by the \`followUpInstructions\` you provide. This means you should:
|
|
135
134
|
- Prefer a clean base (file-level "ours"/"theirs" or simple per-chunk resolution) + specific followUpInstructions over large "merged" chunks that attempt to inline everything.
|
|
@@ -166,7 +165,6 @@ The \`edit_file_lines\` tool accepts an \`ops\` array of structured operations.
|
|
|
166
165
|
- \`insert\`: inserts \`content\` after \`startLine\`. Anchor must equal the text of line \`startLine\`. No \`endLine\`.
|
|
167
166
|
- \`replace\`: replaces lines \`startLine\`–\`endLine\` (inclusive) with \`content\`. Anchor must equal the joined text of those lines.
|
|
168
167
|
- \`delete\`: deletes lines \`startLine\`–\`endLine\` (inclusive). Anchor must equal the joined text of those lines.
|
|
169
|
-
- \`verify\`: asserts that lines \`startLine\`–\`endLine\` (or just \`startLine\`) match the anchor WITHOUT modifying them. Use to confirm critical content is present. No \`content\` field needed.
|
|
170
168
|
|
|
171
169
|
All ops in a single call are validated atomically server-side. If any anchor mismatches or range is out-of-bounds, no changes are applied and the error is returned.
|
|
172
170
|
|
|
@@ -176,8 +174,7 @@ Example call:
|
|
|
176
174
|
"ops": [
|
|
177
175
|
{ "kind": "insert", "startLine": 3, "anchor": "import { Foo } from './foo';", "content": "import { Bar } from './bar';" },
|
|
178
176
|
{ "kind": "replace", "startLine": 10, "endLine": 12, "anchor": " old line A\\n old line B\\n old line C", "content": " new merged line" },
|
|
179
|
-
{ "kind": "delete", "startLine": 20, "endLine": 21, "anchor": " duplicate line\\n duplicate line 2" }
|
|
180
|
-
{ "kind": "verify", "startLine": 15, "anchor": " const result = await fetchData();" }
|
|
177
|
+
{ "kind": "delete", "startLine": 20, "endLine": 21, "anchor": " duplicate line\\n duplicate line 2" }
|
|
181
178
|
]
|
|
182
179
|
}
|
|
183
180
|
\`\`\`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sumUsages as e}from"../resolution/metrics.js";import{buildRefinePrompt as t}from"./prompt.js";import{generateWithTimeout as n}from"./model-timeout.js";import{createRefineTools as r}from"./refine-tools.js";async function i(i,a,o,s){let c=s.refineMaxSteps??5,{system:l,userMessage:u}=t(i,a,o,s.relatedDefinitions,s.fileGuidance),{definitions:d,execute:f}=r(),p=[{role:`user`,content:u}],m=i,h=[],g=0,_=
|
|
1
|
+
import{sumUsages as e}from"../resolution/metrics.js";import{buildRefinePrompt as t}from"./prompt.js";import{generateWithTimeout as n}from"./model-timeout.js";import{createRefineTools as r}from"./refine-tools.js";async function i(i,a,o,s){let c=s.refineMaxSteps??5,{system:l,userMessage:u}=t(i,a,o,s.relatedDefinitions,s.fileGuidance),{definitions:d,execute:f}=r(),p=[{role:`user`,content:u}],m=i,h=[],g=0,_=[],v=t=>({edits:h,content:m,description:t,usage:e(_)});for(let e=0;e<c;e++){if(s.budget?.exhausted())return s.onProgress?.({type:`refine:bailed`,filePath:s.filePath,reason:`Stopped: model budget exhausted.`}),v(``);let t=e+1,r=await n(s.model,{system:l,messages:[...p],tools:d,temperature:s.temperature??0,signal:s.signal},s.modelCallTimeoutMs);if(r.usage&&_.push(r.usage),r.toolCalls&&r.toolCalls.length>0){p.push({role:`assistant`,content:r.text,toolCalls:r.toolCalls});for(let e of r.toolCalls){let n=e.args.ops,r=Array.isArray(n)?n:[];s.onProgress?.({type:`refine:tool-call`,filePath:s.filePath,stepNumber:t,ops:r});let{content:i,edits:a,feedback:o,isError:c}=f(e,m);if(c?g++:(m=i,h.push(...a),g=0),s.onProgress?.({type:`refine:tool-result`,filePath:s.filePath,stepNumber:t,appliedCount:a.length,isError:c,feedback:o}),p.push({role:`tool`,toolCallId:e.id,toolName:e.name,content:o}),g>=3)return s.onProgress?.({type:`refine:bailed`,filePath:s.filePath,reason:`Stopped after ${g} consecutive apply errors.`}),v(``)}continue}let i=(r.text??``).trim();return s.onProgress?.({type:`refine:final-text`,filePath:s.filePath,text:i}),v(i)}return s.onProgress?.({type:`refine:bailed`,filePath:s.filePath,reason:`Stopped after ${c} step(s) without a final reply.`}),v(``)}export{i as runRefinePass};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{truncateChars as e}from"../git/truncation.js";import{applyEditOps as t}from"../resolution/edit-apply.js";const n=new Set([`insert`,`replace`,`delete
|
|
2
|
-
`);return{content:n,edits:[],
|
|
1
|
+
import{truncateChars as e}from"../git/truncation.js";import{applyEditOps as t}from"../resolution/edit-apply.js";const n=new Set([`insert`,`replace`,`delete`]);function r(e){if(typeof e!=`object`||!e)return{ok:!1,error:`"args" must be an object.`};let t=e;if(!Array.isArray(t.ops))return{ok:!1,error:`"ops" must be an array.`};if(t.ops.length===0)return{ok:!1,error:`"ops" must contain at least one item.`};let r=[];for(let e=0;e<t.ops.length;e++){let i=t.ops[e];if(typeof i!=`object`||!i)return{ok:!1,error:`op[${e}] must be an object.`};let a=i;if(!n.has(a.kind))return{ok:!1,error:`op[${e}].kind must be 'insert', 'replace', or 'delete' (got ${JSON.stringify(a.kind)}). If no edit is needed, reply with text instead of calling the tool.`};if(!Number.isInteger(a.startLine))return{ok:!1,error:`op[${e}].startLine must be an integer (got ${JSON.stringify(a.startLine)}).`};if(typeof a.anchor!=`string`)return{ok:!1,error:`op[${e}].anchor must be a string (got ${JSON.stringify(a.anchor)}).`};if(a.endLine!==void 0&&!Number.isInteger(a.endLine))return{ok:!1,error:`op[${e}].endLine must be an integer when provided (got ${JSON.stringify(a.endLine)}).`};if(a.content!==void 0&&typeof a.content!=`string`)return{ok:!1,error:`op[${e}].content must be a string when provided (got ${JSON.stringify(a.content)}).`};if(a.kind===`insert`){if(a.endLine!==void 0)return{ok:!1,error:`op[${e}].endLine must not be provided for 'insert' operations.`};if(a.content===void 0)return{ok:!1,error:`op[${e}].content is required for 'insert' operations.`};r.push({kind:`insert`,startLine:a.startLine,anchor:a.anchor,content:a.content})}else if(a.kind===`replace`){if(a.endLine===void 0)return{ok:!1,error:`op[${e}].endLine is required for 'replace' operations.`};if(a.content===void 0)return{ok:!1,error:`op[${e}].content is required for 'replace' operations.`};r.push({kind:`replace`,startLine:a.startLine,endLine:a.endLine,anchor:a.anchor,content:a.content})}else if(a.kind===`delete`){if(a.endLine===void 0)return{ok:!1,error:`op[${e}].endLine is required for 'delete' operations.`};if(a.content!==void 0)return{ok:!1,error:`op[${e}].content must not be provided for 'delete' operations.`};r.push({kind:`delete`,startLine:a.startLine,endLine:a.endLine,anchor:a.anchor})}}return{ok:!0,ops:r}}function i(){let n=[{name:`edit_file_lines`,description:`Apply structured edit operations to the resolved file. Each op targets a specific line range validated by an anchor. All ops in a single call are validated atomically — if any fail, no changes are applied.`,parameters:{type:`object`,required:[`ops`],properties:{ops:{type:`array`,minItems:1,description:`Edit operations, applied together. Each item is an object with "kind" (one of insert, replace, delete), "startLine", "anchor", and, depending on kind, "endLine" and "content". insert: startLine, anchor, content (no endLine). replace: startLine, endLine, anchor, content. delete: startLine, endLine, anchor (no content).`,items:{type:`object`,required:[`kind`,`startLine`,`anchor`],properties:{kind:{type:`string`,enum:[`insert`,`replace`,`delete`],description:`Operation: "insert" adds content after startLine (needs content, no endLine); "replace" rewrites startLine-endLine with content (needs endLine and content); "delete" removes startLine-endLine (needs endLine, no content).`},startLine:{type:`integer`,description:`1-based first line the operation targets.`},endLine:{type:`integer`,description:`1-based last line, inclusive. Required for replace and delete, not allowed for insert.`},anchor:{type:`string`,description:`Exact current text of the targeted lines (startLine only for insert), joined with newlines.`},content:{type:`string`,description:`New text. Required for insert and replace, not allowed for delete.`}}}}}}}];function i(e,n){let i=r(e.args);if(!i.ok)return{content:n,edits:[],feedback:i.error,isError:!0};let a=i.ops,{content:o,edits:s,results:c}=t(n,a),l=c.filter(e=>e.status===`skipped`);if(l.length>0){let e=n.split(`
|
|
2
|
+
`);return{content:n,edits:[],feedback:`Failed to apply ops:\n${l.map(t=>{if(t.status!==`skipped`)return``;let n=a[t.opIndex],r=n&&n.kind!==`insert`?n.endLine:void 0,i=n?.kind===`insert`||r===void 0?String(n?.startLine??`?`):`${n.startLine}-${r}`,o=` op[${t.opIndex}] (${n?.kind??`unknown`} startLine=${i}): ${t.reason}`;if(t.reason===`anchor-mismatch`&&n){let i=n.startLine,a=r??n.startLine,s=e.slice(i-1,a).map((e,t)=>` ${i+t}: ${e}`).join(`
|
|
3
3
|
`);return[o,` Your anchor:`,t.expected.split(`
|
|
4
4
|
`).map(e=>` | ${e}`).join(`
|
|
5
5
|
`),` Actual lines ${i}-${a} in current content:`,s].join(`
|
|
6
6
|
`)}return t.reason===`out-of-bounds`&&n?`${o}\n Content has ${e.length} lines; you targeted startLine=${n.startLine}${r===void 0?``:`, endLine=${r}`}.`:o}).join(`
|
|
7
|
-
`)}\n\nHint: anchor must EXACTLY match the content (including whitespace and indentation) at the specified line range. Re-read the resolved content and copy the lines verbatim.`,isError:!0}}let u=
|
|
8
|
-
`).length;return{content:o,edits:s,
|
|
7
|
+
`)}\n\nHint: anchor must EXACTLY match the content (including whitespace and indentation) at the specified line range. Re-read the resolved content and copy the lines verbatim.`,isError:!0}}let u=o.split(`
|
|
8
|
+
`).length;return{content:o,edits:s,feedback:`Applied ${s.length} op(s). New content length: ${u} lines.`,isError:!1}}function a(t,n){let r=i(t,n);return{...r,feedback:e(r.feedback,`Retry with fewer operations and smaller targeted line ranges/anchors.`).content}}return{definitions:n,execute:a}}export{i as createRefineTools};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ConflictGitPortMissingOpError as e}from"../ports/git.js";import{log as t,mergeBase as n}from"../git/port-dispatch.js";import{toFileFinding as r}from"../validation/findings.js";import{resolveChunkContent as i}from"../resolution/chunk-apply.js";import{createResolution as a}from"../resolution/create-resolution.js";import{mergeUsages as o}from"../resolution/metrics.js";import{checkResidualMarkers as s}from"../validation/markers.js";import{bracketImbalances as c,bracketInstruction as l,fileBracketFinding as u}from"./bracket-balance.js";import{matchFileGuidance as d}from"./file-guidance.js";import{runResolverLoop as f}from"./loop.js";import{lostAdditionFinding as p,lostAdditions as m,refineInstructions as h}from"./lost-additions.js";import{runRefinePass as g}from"./refine-pass.js";import{buildThreeWayDiff as _}from"./three-way-diff.js";const v={refineNoAction:.6,refineApplied:.9,errorsRemain:.5};async function y(e,t,n,y=[e.filePath]){let x={...t,fileGuidance:d(t.fileGuidance,y)},S=x;if(x.refs){let t=x.operation!==void 0&&x.upstreamCommits===void 0,r=x.threeWayDiff??await _(e.filePath,x.refs,{git:n.git,signal:n.signal}),i=t?await b(e.filePath,x.refs,x.operation===`merge`?x.refs.theirs:x.refs.ours,n):x.upstreamCommits;S={...x,threeWayDiff:r,...i===void 0?{}:{upstreamCommits:i}}}let{chunks:C,strategy:w,confidence:T,description:E,metrics:D,followUpInstructions:O}=await f(e,S,{model:n.model,git:n.git,config:n.config,onProgress:n.onProgress,signal:n.signal}),k=a(e,C,{confidence:T,description:E,metrics:D,...w?{fileStrategy:w}:{},...S.threeWayDiff?{threeWayDiff:S.threeWayDiff}:{}}),A=(t,r)=>{let i=S.threeWayDiff;if(e.type!==`text`||!i)return[];let a=[...m(i.oursDiff,`ours`,r),...m(i.theirsDiff,`theirs`,r)];for(let r of a)n.onProgress?.({type:`refine:lost-addition`,filePath:e.filePath,side:r.side,startLine:r.startLine,endLine:r.endLine,lines:r.lines.length,phase:t});return a},j=e.type===`text`?c(C,e):[];for(let t of j)n.onProgress?.({type:`refine:bracket-imbalance`,filePath:e.filePath,...t});let M=h(O,A(`before-refine`,k.content),j.map(e=>l(e,S.operation)));if(e.type===`text`&&M.length>0){n.onProgress?.({type:`refine:started`,filePath:e.filePath});let t=0;try{let r=await g(k.content,k.description,M,{model:n.model,signal:n.signal,temperature:n.config?.temperature,refineMaxSteps:n.config?.refineMaxSteps,modelCallTimeoutMs:n.config?.modelCallTimeoutMs,fileGuidance:S.fileGuidance,onProgress:n.onProgress,filePath:e.filePath});if(r.edits.length>0){let i=s(e.filePath,r.content);if(i.valid)k={...k,content:r.content,edits:r.edits,strategy:`ai`},t=r.edits.length;else{let t=(i.issues??[]).map(e=>e.message).join(` `);n.onProgress?.({type:`refine:discarded`,filePath:e.filePath,reason:`Edits introduced conflict markers: ${t}`})}}if(t>0){k={...k,confidence:Math.min(k.confidence,v.refineApplied)};let t=[];for(let n=0;n<e.markers.length;n++){let a=e.markers[n];if(!a||a.userResolution==null)continue;let o=i({markerIndex:n,...a.userResolution},a);o!==``&&(r.content.includes(o)||t.push(n))}t.length>0&&(n.onProgress?.({type:`refine:touched-user-region`,filePath:e.filePath,markerIndexes:t}),k={...k,note:`Refine modified user-resolved region(s): marker ${t.join(`, `)}.`})}else
|
|
1
|
+
import{ConflictGitPortMissingOpError as e}from"../ports/git.js";import{log as t,mergeBase as n}from"../git/port-dispatch.js";import{toFileFinding as r}from"../validation/findings.js";import{resolveChunkContent as i}from"../resolution/chunk-apply.js";import{createResolution as a}from"../resolution/create-resolution.js";import{mergeUsages as o}from"../resolution/metrics.js";import{checkResidualMarkers as s}from"../validation/markers.js";import{bracketImbalances as c,bracketInstruction as l,fileBracketFinding as u}from"./bracket-balance.js";import{matchFileGuidance as d}from"./file-guidance.js";import{runResolverLoop as f}from"./loop.js";import{lostAdditionFinding as p,lostAdditions as m,refineInstructions as h}from"./lost-additions.js";import{runRefinePass as g}from"./refine-pass.js";import{buildThreeWayDiff as _}from"./three-way-diff.js";const v={refineNoAction:.6,refineApplied:.9,errorsRemain:.5};async function y(e,t,n,y=[e.filePath]){let x={...t,fileGuidance:d(t.fileGuidance,y)},S=x;if(x.refs){let t=x.operation!==void 0&&x.upstreamCommits===void 0,r=x.threeWayDiff??await _(e.filePath,x.refs,{git:n.git,signal:n.signal}),i=t?await b(e.filePath,x.refs,x.operation===`merge`?x.refs.theirs:x.refs.ours,n):x.upstreamCommits;S={...x,threeWayDiff:r,...i===void 0?{}:{upstreamCommits:i}}}let{chunks:C,strategy:w,confidence:T,description:E,metrics:D,followUpInstructions:O}=await f(e,S,{model:n.model,git:n.git,config:n.config,onProgress:n.onProgress,signal:n.signal}),k=a(e,C,{confidence:T,description:E,metrics:D,...w?{fileStrategy:w}:{},...S.threeWayDiff?{threeWayDiff:S.threeWayDiff}:{}}),A=(t,r)=>{let i=S.threeWayDiff;if(e.type!==`text`||!i)return[];let a=[...m(i.oursDiff,`ours`,r),...m(i.theirsDiff,`theirs`,r)];for(let r of a)n.onProgress?.({type:`refine:lost-addition`,filePath:e.filePath,side:r.side,startLine:r.startLine,endLine:r.endLine,lines:r.lines.length,phase:t});return a},j=e.type===`text`?c(C,e):[];for(let t of j)n.onProgress?.({type:`refine:bracket-imbalance`,filePath:e.filePath,...t});let M=h(O,A(`before-refine`,k.content),j.map(e=>l(e,S.operation)));if(e.type===`text`&&M.length>0){n.onProgress?.({type:`refine:started`,filePath:e.filePath});let t=0;try{let r=await g(k.content,k.description,M,{model:n.model,signal:n.signal,temperature:n.config?.temperature,refineMaxSteps:n.config?.refineMaxSteps,modelCallTimeoutMs:n.config?.modelCallTimeoutMs,fileGuidance:S.fileGuidance,onProgress:n.onProgress,filePath:e.filePath});if(r.edits.length>0){let i=s(e.filePath,r.content);if(i.valid)k={...k,content:r.content,edits:r.edits,strategy:`ai`},t=r.edits.length;else{let t=(i.issues??[]).map(e=>e.message).join(` `);n.onProgress?.({type:`refine:discarded`,filePath:e.filePath,reason:`Edits introduced conflict markers: ${t}`})}}if(t>0){k={...k,confidence:Math.min(k.confidence,v.refineApplied)};let t=[];for(let n=0;n<e.markers.length;n++){let a=e.markers[n];if(!a||a.userResolution==null)continue;let o=i({markerIndex:n,...a.userResolution},a);o!==``&&(r.content.includes(o)||t.push(n))}t.length>0&&(n.onProgress?.({type:`refine:touched-user-region`,filePath:e.filePath,markerIndexes:t}),k={...k,note:`Refine modified user-resolved region(s): marker ${t.join(`, `)}.`})}else k={...k,confidence:Math.min(k.confidence,v.refineNoAction)};if(r.usage){let e=o(k.metrics??{inputTokens:0,outputTokens:0},r.usage);k={...k,metrics:{...k.metrics,...e}}}n.onProgress?.({type:`refine:completed`,filePath:e.filePath,appliedCount:t})}catch(t){if(n.signal?.aborted)throw t;let r=t instanceof Error?t.message:String(t);n.onProgress?.({type:`refine:failed`,filePath:e.filePath,reason:r}),k={...k,confidence:Math.min(k.confidence,v.refineNoAction)}}}else n.onProgress?.({type:`refine:skipped`,filePath:e.filePath,reason:`no-follow-ups`});let N=A(`after-refine`,k.content);N.length>0&&(k={...k,findings:[...k.findings??[],...N.map(t=>p(t,e.filePath))]});let P=e.type===`text`?u(e,k.content,S.operation,j):void 0;if(P&&(k={...k,findings:[...k.findings??[],P]}),n.validator&&e.type===`text`)try{let t=await n.validator.validate(new Map([[e.filePath,k.content]]),n.signal);t.length>0&&(k={...k,findings:[...k.findings??[],...t.map(r)]})}catch(t){if(n.signal?.aborted)throw t;let r=t instanceof Error?t.message:String(t);n.onProgress?.({type:`validation:failed`,filePath:e.filePath,reason:r})}return n.onProgress?.({type:`resolver:completed`,filePath:e.filePath,stepCount:D.stepCount??0}),k}async function b(r,i,a,o){try{let e=i.base??await n(o.git,i.ours,i.theirs,{signal:o.signal});return await t(o.git,{ref:`${e}..${a}`,path:r,signal:o.signal})}catch(t){if(o.signal?.aborted||!(t instanceof e))throw t;return}}export{v as CONFIDENCE_CAPS,y as resolveConflict};
|
package/dist/types/hints.d.ts
CHANGED
|
@@ -15,18 +15,10 @@ type IntraFileEditOp = {
|
|
|
15
15
|
startLine: number;
|
|
16
16
|
endLine: number;
|
|
17
17
|
anchor: string;
|
|
18
|
-
} | {
|
|
19
|
-
kind: 'verify';
|
|
20
|
-
startLine: number;
|
|
21
|
-
endLine?: number;
|
|
22
|
-
anchor: string;
|
|
23
18
|
};
|
|
24
19
|
type EditOpApplyResult = {
|
|
25
20
|
opIndex: number;
|
|
26
21
|
status: 'applied';
|
|
27
|
-
} | {
|
|
28
|
-
opIndex: number;
|
|
29
|
-
status: 'verified';
|
|
30
22
|
} | {
|
|
31
23
|
opIndex: number;
|
|
32
24
|
status: 'skipped';
|