@gitkraken/conflict-tools 0.2.4-beta.1 → 0.2.4-beta.3
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/CHANGELOG.md +2 -0
- package/dist/git/port-dispatch.d.ts +2 -1
- package/dist/git/port-dispatch.js +2 -1
- package/dist/index.d.ts +2 -2
- package/dist/ports/git.d.ts +5 -0
- package/dist/reference-integrity/detect.js +3 -1
- package/dist/reference-integrity/snapshot.d.ts +8 -3
- package/dist/reference-integrity/snapshot.js +1 -1
- package/dist/resolver/summarize-operation.d.ts +2 -1
- package/dist/resolver/summarize-operation.js +1 -1
- package/dist/types/findings.d.ts +8 -1
- package/dist/types/resolution.d.ts +4 -0
- package/dist/types/summary.d.ts +24 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
12
|
- Reference-integrity detection. `resolveConflicts` now attaches a `StepResult.detection` report listing broken references (symbols that resolved in a pre-merge parent but no longer resolve in the merged result, with provenance), duplicate definitions, and syntax errors in the resolved files. Detection is opt-in via a new `ParserPort` (`ResolverDeps.parser`) that supplies parsing/symbol resolution per surface (tree-sitter, language server); when it is absent, unavailable, or a file's language is unsupported, the report says so rather than implying a clean result. Report-only in this release — no automatic fixing.
|
|
13
|
+
- Auto-merged scope for reference-integrity detection: the detector discovers the merge's incoming/auto-merged set itself (new optional `changedFiles` git-port op; `git diff --name-only base..theirs`, base from `refs.base` or `mergeBase`) and includes it in scope, so dangling references in cleanly-merged files are caught. Scope is capped and reported via `DetectionReport.scope`; an optional `ResolutionContext.touchedFiles` overrides discovery. Adds a `dropped-side` finding when a whole-side take (take-ours/take-theirs/fallback) discards a substantial diff from the other side.
|
|
14
|
+
- Operation-level assessment: `buildOperationDigest`/`summarizeOperation` now fold `StepResult.detection` into the rollup. A file with an error-severity finding (broken-reference, dropped-side, syntax-error, duplicate-definition) is added to `needsReview` (`reason: 'finding'`) regardless of confidence — even a file with no resolution of its own; `OperationDigest.detectionComplete` reports whether every detection check ran (so empty findings on a skipped check are not read as clean); and a derived `OperationDigest.verdict` (`'clean' | 'needs-review' | 'blocked'`) gives consumers an honest gate signal. `ReviewItem` gains `reason` and optional `findingCategories`, and its `confidence` is now optional.
|
|
13
15
|
|
|
14
16
|
## [0.2.3] - 2026-07-06
|
|
15
17
|
|
|
@@ -8,6 +8,7 @@ declare function mergeBase(git: ConflictGitPort, a: string, b: string, opts?: Op
|
|
|
8
8
|
declare function blame(git: ConflictGitPort, path: string, opts?: BlameOptions): Promise<string>;
|
|
9
9
|
declare function grep(git: ConflictGitPort, pattern: string, opts?: GrepOptions): Promise<string>;
|
|
10
10
|
declare function diff(git: ConflictGitPort, from: string, to: string, opts?: ConflictDiffOptions): Promise<string>;
|
|
11
|
+
declare function changedFiles(git: ConflictGitPort, from: string, to: string, opts?: OpOptions): Promise<string[]>;
|
|
11
12
|
declare function log(git: ConflictGitPort, opts?: LogOptions): Promise<string>;
|
|
12
13
|
declare function show(git: ConflictGitPort, sha: string, opts?: ShowOptions): Promise<string>;
|
|
13
14
|
declare function writeFile(git: ConflictGitPort, path: string, content: string, opts?: OpOptions): Promise<void>;
|
|
@@ -15,4 +16,4 @@ declare function stageFiles(git: ConflictGitPort, paths: string[], opts?: OpOpti
|
|
|
15
16
|
declare function checkoutFile(git: ConflictGitPort, path: string, side: 'ours' | 'theirs', opts?: OpOptions): Promise<void>;
|
|
16
17
|
declare function removeFile(git: ConflictGitPort, path: string, opts?: OpOptions): Promise<void>;
|
|
17
18
|
//#endregion
|
|
18
|
-
export { blame, checkoutFile, diff, grep, log, mergeBase, readFile, removeFile, show, showFile, stageFiles, unmergedEntries, writeFile };
|
|
19
|
+
export { blame, changedFiles, checkoutFile, diff, grep, log, mergeBase, readFile, removeFile, show, showFile, stageFiles, unmergedEntries, writeFile };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import{ConflictGitPortMissingOpError as e}from"../ports/git.js";import{sliceLines as t,truncateLines as n,truncateMatches as r}from"./truncation.js";const i={DD:`both-deleted`,AU:`added-by-us`,UD:`deleted-by-them`,UA:`added-by-them`,DU:`deleted-by-us`,AA:`both-added`,UU:`both-modified`};function a(e){return i[e]??e}function o(e){return`Search capped at ${e} matches. There may be more — narrow with a more specific pattern or path.`}function s(t,n){throw new e(t,n)}function c(e,t){return e!=null&&t!=null?`startLine=${e}, endLine=${t}`:e==null?`endLine=${t}`:`startLine=${e}`}async function l(e,t,n){return e.readFile?e.readFile(t,n):s(`readFile`)}async function u(e,r,i,a){let o;if(e.showFile)o=await e.showFile(r,i,a);else if(e.exec){let n=t(await e.exec([`show`,`${r}:${i}`],{signal:a?.signal}),a?.startLine,a?.endLine);if(!n.ok)return n.reason===`invalid-range`?`[Invalid range: ${c(n.startLine,n.endLine)} (startLine must be <= endLine).]`:`[Range out of bounds: file has ${n.total} lines, requested ${c(n.startLine,n.endLine)}.]`;o=n.content}else return s(`showFile`);return n(o,1e3,`Output capped at 1000 lines. Use startLine/endLine to read other regions of the file.`)}async function d(e,t){if(e.unmergedEntries)return e.unmergedEntries(t);if(e.exec){let n=await e.exec([`status`,`--porcelain=v2`],{signal:t?.signal}),r=[];for(let e of n.split(`
|
|
2
|
-
`)){if(!e.startsWith(`u `))continue;let t=e.split(` `),n=t[1]??``,i=t.slice(10).join(` `);r.push({path:i,reason:a(n)})}return r}return s(`unmergedEntries`)}async function f(e,t,n,r){return e.mergeBase?e.mergeBase(t,n,r):e.exec?(await e.exec([`merge-base`,`--`,t,n],{signal:r?.signal})).trim():s(`mergeBase`)}async function p(e,t,r){let i=r?.startLine,a=r?.endLine,o=Number.isFinite(i),l=Number.isFinite(a);if(o&&l&&i>a)return`[Invalid range: ${c(i,a)} (startLine must be <= endLine).]`;let u;if(e.blame)u=await e.blame(t,r);else if(e.exec){let n=[`blame`,`--porcelain`],s=o?Math.max(1,i):void 0,c=l?Math.max(1,a):void 0;s!=null&&c!=null?n.push(`-L`,`${s},${c}`):s==null?c!=null&&n.push(`-L`,`1,${c}`):n.push(`-L`,`${s},`),r?.ref&&n.push(r.ref),n.push(`--`,t),u=await e.exec(n,{signal:r?.signal})}else return s(`blame`);return n(u,1e3,`Output capped at 1000 lines. Use startLine/endLine to inspect other regions.`)}async function m(e,t,n){let i=n?.maxResults,a=i!=null&&Number.isFinite(i)?Math.min(Math.max(1,i),100):100,c;if(e.grep)c=await e.grep(t,n);else if(e.exec){let r=[`grep`,`-n`,`--`,t];n?.ref&&r.push(n.ref),c=await e.exec(r,{signal:n?.signal})}else return s(`grep`);return r(c,a,o(a))}async function h(e,t,n,r){if(e.diff)return e.diff(t,n,r);if(e.exec){let i=[`diff`,t,n];return r?.path&&i.push(`--`,r.path),e.exec(i,{signal:r?.signal})}return s(`diff`)}async function g(e,t
|
|
2
|
+
`)){if(!e.startsWith(`u `))continue;let t=e.split(` `),n=t[1]??``,i=t.slice(10).join(` `);r.push({path:i,reason:a(n)})}return r}return s(`unmergedEntries`)}async function f(e,t,n,r){return e.mergeBase?e.mergeBase(t,n,r):e.exec?(await e.exec([`merge-base`,`--`,t,n],{signal:r?.signal})).trim():s(`mergeBase`)}async function p(e,t,r){let i=r?.startLine,a=r?.endLine,o=Number.isFinite(i),l=Number.isFinite(a);if(o&&l&&i>a)return`[Invalid range: ${c(i,a)} (startLine must be <= endLine).]`;let u;if(e.blame)u=await e.blame(t,r);else if(e.exec){let n=[`blame`,`--porcelain`],s=o?Math.max(1,i):void 0,c=l?Math.max(1,a):void 0;s!=null&&c!=null?n.push(`-L`,`${s},${c}`):s==null?c!=null&&n.push(`-L`,`1,${c}`):n.push(`-L`,`${s},`),r?.ref&&n.push(r.ref),n.push(`--`,t),u=await e.exec(n,{signal:r?.signal})}else return s(`blame`);return n(u,1e3,`Output capped at 1000 lines. Use startLine/endLine to inspect other regions.`)}async function m(e,t,n){let i=n?.maxResults,a=i!=null&&Number.isFinite(i)?Math.min(Math.max(1,i),100):100,c;if(e.grep)c=await e.grep(t,n);else if(e.exec){let r=[`grep`,`-n`,`--`,t];n?.ref&&r.push(n.ref),c=await e.exec(r,{signal:n?.signal})}else return s(`grep`);return r(c,a,o(a))}async function h(e,t,n,r){if(e.diff)return e.diff(t,n,r);if(e.exec){let i=[`diff`,t,n];return r?.path&&i.push(`--`,r.path),e.exec(i,{signal:r?.signal})}return s(`diff`)}async function g(e,t,n,r){return e.changedFiles?e.changedFiles(t,n,r):e.exec?(await e.exec([`diff`,`--name-only`,t,n],{signal:r?.signal})).split(`
|
|
3
|
+
`).map(e=>e.trim()).filter(e=>e.length>0):s(`changedFiles`)}async function _(e,t){let r=t?.maxCount,i=r!=null&&Number.isFinite(r)?Math.min(Math.max(1,r),100):100,a;if(e.log)a=await e.log({...t,maxCount:i});else if(e.exec){let n=[`log`,`--oneline`,`-n`,String(i)];t?.ref&&n.push(t.ref),t?.path&&n.push(`--`,t.path),a=await e.exec(n,{signal:t?.signal})}else return s(`log`);return n(a,100,`Output capped at 100 commits. Use path to scope to a file or refine the ref range.`)}async function v(e,t,r){let i;if(e.show)i=await e.show(t,r);else if(e.exec){let n=[`show`,t];r?.path&&n.push(`--`,r.path),i=await e.exec(n,{signal:r?.signal})}else return s(`show`);return n(i,500,`Output capped at 500 lines. Use show_file_at_ref with startLine/endLine to read specific regions.`)}async function y(e,t,n,r){return e.writeFile?e.writeFile(t,n,r):s(`writeFile`)}async function b(e,t,n){if(e.stageFiles)return e.stageFiles(t,n);if(e.exec){await e.exec([`add`,`--`,...t],{signal:n?.signal});return}return s(`stageFiles`)}async function x(e,t,n,r){if(e.checkoutFile)return e.checkoutFile(t,n,r);if(e.exec){await e.exec([`checkout`,`--${n}`,`--`,t],{signal:r?.signal});return}return s(`checkoutFile`)}async function S(e,t,n){if(e.removeFile)return e.removeFile(t,n);if(e.exec){await e.exec([`rm`,`--`,t],{signal:n?.signal});return}return s(`removeFile`)}export{p as blame,g as changedFiles,x as checkoutFile,h as diff,m as grep,_ as log,f as mergeBase,l as readFile,S as removeFile,v as show,u as showFile,b as stageFiles,d as unmergedEntries,y as writeFile};
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,6 @@ import { ConflictProgressEvent } from "./types/events.js";
|
|
|
20
20
|
import { resolveConflict } from "./resolver/resolve-conflict.js";
|
|
21
21
|
import { FileRule, StepConfig, StepResult } from "./types/step.js";
|
|
22
22
|
import { resolveConflicts } from "./resolver/resolve-conflicts.js";
|
|
23
|
-
import { OperationDigest, OperationSummary, ReviewItem } from "./types/summary.js";
|
|
23
|
+
import { OperationDigest, OperationSummary, OperationVerdict, ReviewItem } from "./types/summary.js";
|
|
24
24
|
import { SummarizeOperationOptions, buildOperationDigest, summarizeOperation } from "./resolver/summarize-operation.js";
|
|
25
|
-
export { AIError, type AIErrorCode, type BlameOptions, type CheckStatus, type Conflict, type ConflictDiffOptions, ConflictError, type ConflictErrorCode, type ConflictGitOps, type ConflictGitPort, ConflictGitPortMissingOpError, type ConflictMarker, type ConflictMarkerUserInput, type ConflictModelMessage, type ConflictModelParams, type ConflictModelPort, type ConflictModelResult, type ConflictProgressEvent, type ConflictType, type DetectDeps, type DetectionReport, type DiffStats, type FileRule, type Finding, type FindingCategory, type FindingTier, type GrepOptions, type IntraFileEditOp, type Issue, type LogOptions, type OpOptions, type OperationDigest, type OperationSummary, type ParsedFile, type ParserPort, type Resolution, type ResolutionContext, type ResolutionMetrics, type ResolutionRawSignals, type ResolutionRefs, type ResolutionStrategy, type ResolutionVerifier, type ResolvedChunk, type ResolverConfig, type ReviewItem, type ShowFileOptions, type ShowOptions, type SourceOverlay, type StepConfig, type StepResult, type SummarizeOperationOptions, type SymbolDefinition, type SymbolReference, type SyntaxIssue, type ThreeWayDiff, type ToolCall, type ToolDefinition, type ToolResult, type UnmergedEntry, type UnmergedReason, type VerificationResult, applyResolutions, buildOperationDigest, checkoutFile, createResolution, defaultVerifier, detect, extractConflict, removeFile, resolveConflict, resolveConflicts, show, summarizeOperation, takeOurs, takeTheirs };
|
|
25
|
+
export { AIError, type AIErrorCode, type BlameOptions, type CheckStatus, type Conflict, type ConflictDiffOptions, ConflictError, type ConflictErrorCode, type ConflictGitOps, type ConflictGitPort, ConflictGitPortMissingOpError, type ConflictMarker, type ConflictMarkerUserInput, type ConflictModelMessage, type ConflictModelParams, type ConflictModelPort, type ConflictModelResult, type ConflictProgressEvent, type ConflictType, type DetectDeps, type DetectionReport, type DiffStats, type FileRule, type Finding, type FindingCategory, type FindingTier, type GrepOptions, type IntraFileEditOp, type Issue, type LogOptions, type OpOptions, type OperationDigest, type OperationSummary, type OperationVerdict, type ParsedFile, type ParserPort, type Resolution, type ResolutionContext, type ResolutionMetrics, type ResolutionRawSignals, type ResolutionRefs, type ResolutionStrategy, type ResolutionVerifier, type ResolvedChunk, type ResolverConfig, type ReviewItem, type ShowFileOptions, type ShowOptions, type SourceOverlay, type StepConfig, type StepResult, type SummarizeOperationOptions, type SymbolDefinition, type SymbolReference, type SyntaxIssue, type ThreeWayDiff, type ToolCall, type ToolDefinition, type ToolResult, type UnmergedEntry, type UnmergedReason, type VerificationResult, applyResolutions, buildOperationDigest, checkoutFile, createResolution, defaultVerifier, detect, extractConflict, removeFile, resolveConflict, resolveConflicts, show, summarizeOperation, takeOurs, takeTheirs };
|
package/dist/ports/git.d.ts
CHANGED
|
@@ -45,6 +45,11 @@ interface ConflictGitOps {
|
|
|
45
45
|
showFile?: (ref: string, path: string, opts?: ShowFileOptions) => Promise<string>;
|
|
46
46
|
unmergedEntries?: (opts?: OpOptions) => Promise<UnmergedEntry[]>;
|
|
47
47
|
mergeBase?: (a: string, b: string, opts?: OpOptions) => Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the paths changed between two refs (name-only). Used to discover the merge's
|
|
50
|
+
* incoming/auto-merged set for reference-integrity detection.
|
|
51
|
+
*/
|
|
52
|
+
changedFiles?: (from: string, to: string, opts?: OpOptions) => Promise<string[]>;
|
|
48
53
|
/**
|
|
49
54
|
* Returns line-by-line authorship for `path`. When `opts.startLine`/`endLine` are provided,
|
|
50
55
|
* implementations should restrict to that 1-indexed inclusive range. The library does not
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import{buildSnapshots as e}from"./snapshot.js";async function t(t,r,o){let
|
|
1
|
+
import{buildSnapshots as e}from"./snapshot.js";async function t(t,r,o){let c=o.parser;if(!c)return{findings:[],checks:{referenceIntegrity:`skipped-no-parser`,structural:`skipped-no-parser`}};try{let l=r.refs?await e(t,r,o):null;if(l){let[e,r,o]=await Promise.all([c.analyze(l.ours),c.analyze(l.theirs),c.analyze(l.result)]);return{findings:[...n(e,r,o),...i(o),...a(t,l)],checks:{referenceIntegrity:s([e,r,o])?`partial-unsupported-language`:`ran`,structural:s([o])?`partial-unsupported-language`:`ran`},scope:{analyzed:l.analyzed,truncated:l.truncated}}}let u=new Map(t.map(e=>[e.filePath,e.content])),d=await c.analyze(u);return{findings:i(d),checks:{referenceIntegrity:`skipped-no-refs`,structural:s([d])?`partial-unsupported-language`:`ran`}}}catch{return{findings:[],checks:{referenceIntegrity:`errored`,structural:`errored`}}}}function n(e,t,n){let i=new Map;r(e,`ours`,i),r(t,`theirs`,i);let a=[];for(let[e,t]of n)for(let n of t.references){if(n.resolved)continue;let t=i.get(c(e,n.name));t&&a.push({category:`broken-reference`,severity:`error`,tier:`project`,location:{file:e,line:n.line,symbol:n.name},provenance:t,message:`Reference "${n.name}" resolved before the merge (on ${t.side}) but no longer resolves.`})}return a}function r(e,t,n){for(let[r,i]of e)for(let e of i.references){if(!e.resolved)continue;let i=c(r,e.name);n.has(i)||n.set(i,{side:t,line:e.line})}}function i(e){let t=[];for(let[n,r]of e){let e=new Map;for(let i of r.definitions){let r=e.get(i.name);r==null?e.set(i.name,i.line):t.push({category:`duplicate-definition`,severity:`error`,tier:`file`,location:{file:n,line:i.line,symbol:i.name},message:`Duplicate definition of "${i.name}" (also defined at line ${r}).`})}for(let e of r.syntaxErrors)t.push({category:`syntax-error`,severity:`error`,tier:`file`,location:{file:n,line:e.line},message:e.message})}return t}function a(e,t){let n=[];for(let r of e){let e=r.strategy===`take-ours`?`theirs`:r.strategy===`take-theirs`?`ours`:null;if(!e)continue;let i=(e===`ours`?t.ours:t.theirs).get(r.filePath);if(i==null)continue;let a=o(i,r.content);a<20||n.push({category:`dropped-side`,severity:`error`,tier:`file`,location:{file:r.filePath,line:1},message:`Resolution took "${r.strategy}" wholesale, discarding ~${a} line(s) of the ${e} side.`})}return n}function o(e,t){let n=new Set(t.split(`
|
|
2
|
+
`)),r=0;for(let t of e.split(`
|
|
3
|
+
`))t.trim()!==``&&!n.has(t)&&r++;return r}function s(e){return e.some(e=>{for(let t of e.values())if(t.language===`unsupported`)return!0;return!1})}function c(e,t){return JSON.stringify([e,t])}export{t as detect};
|
|
@@ -7,6 +7,10 @@ interface DetectionSnapshots {
|
|
|
7
7
|
ours: SourceOverlay;
|
|
8
8
|
theirs: SourceOverlay;
|
|
9
9
|
result: SourceOverlay;
|
|
10
|
+
/** Number of files actually included in the snapshots (after the cap). */
|
|
11
|
+
analyzed: number;
|
|
12
|
+
/** Whether the scope exceeded the cap and was truncated. */
|
|
13
|
+
truncated: boolean;
|
|
10
14
|
}
|
|
11
15
|
interface SnapshotDeps {
|
|
12
16
|
git: ConflictGitPort;
|
|
@@ -15,9 +19,10 @@ interface SnapshotDeps {
|
|
|
15
19
|
/**
|
|
16
20
|
* Builds the file-content overlays the detector compares: both pre-merge parents (read from git
|
|
17
21
|
* objects — no working tree needed) and the resolved result (in-memory resolutions overlaid on the
|
|
18
|
-
* surrounding files). Scope is the resolved files plus
|
|
19
|
-
*
|
|
20
|
-
*
|
|
22
|
+
* surrounding files). Scope is the resolved files plus the merge's incoming/auto-merged set, which
|
|
23
|
+
* the detector discovers itself via the git port (`changedFiles(base, theirs)`), unless the consumer
|
|
24
|
+
* supplies `context.touchedFiles` as an override. Returns `null` when `context.refs` is absent — the
|
|
25
|
+
* before/after comparison is impossible without the parent refs.
|
|
21
26
|
*/
|
|
22
27
|
declare function buildSnapshots(resolutions: Resolution[], context: ResolutionContext, deps: SnapshotDeps): Promise<DetectionSnapshots | null>;
|
|
23
28
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{changedFiles as e,mergeBase as t,readFile as n,showFile as r}from"../git/port-dispatch.js";async function i(e,t,n){let r=t.refs;if(!r)return null;let i=n.signal?{signal:n.signal}:void 0,c=new Map(e.map(e=>[e.filePath,e.content])),l=t.touchedFiles??await a(n.git,r,i),u=[],d=new Set;for(let e of[...c.keys(),...l,...t.fileNeighbors??[]])d.has(e)||(d.add(e),u.push(e));let f=u.length>400,p=f?u.slice(0,400):u,m=new Map,h=new Map,g=new Map;for(let e of p){let t=await o(n.git,r.ours,e,i);t!=null&&m.set(e,t);let a=await o(n.git,r.theirs,e,i);a!=null&&h.set(e,a);let l=c.get(e);if(l!=null)g.set(e,l);else{let t=await s(n.git,e,i);t!=null&&g.set(e,t)}}return{ours:m,theirs:h,result:g,analyzed:p.length,truncated:f}}async function a(n,r,i){try{return await e(n,r.base??await t(n,r.ours,r.theirs,i),r.theirs,i)}catch{return[]}}async function o(e,t,n,i){try{return await r(e,t,n,i)}catch{return null}}async function s(e,t,r){try{return await n(e,t,r)}catch{return null}}export{i as buildSnapshots};
|
|
@@ -16,7 +16,8 @@ interface SummarizeOperationOptions {
|
|
|
16
16
|
reviewThreshold?: number;
|
|
17
17
|
temperature?: number;
|
|
18
18
|
}
|
|
19
|
-
/** Pure, model-free rollup of a {@link StepResult}
|
|
19
|
+
/** Pure, model-free rollup of a {@link StepResult}, folding in `detection` so a file with an error
|
|
20
|
+
* finding — or a detection check that did not run — can never read as clean. */
|
|
20
21
|
declare function buildOperationDigest(result: StepResult, reviewThreshold?: number): OperationDigest;
|
|
21
22
|
/**
|
|
22
23
|
* Summarize a resolve operation for a reviewer. Always returns a deterministic `digest`; when
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildSummaryPrompt as e}from"./prompt.js";const t=.8;function n(e,n=t){let
|
|
1
|
+
import{buildSummaryPrompt as e}from"./prompt.js";const t=.8;function n(e,n=t){let a={ai:0,"take-ours":0,"take-theirs":0,deleted:0,skipped:0},o=0,s=null,c=new Map;for(let t of e.resolutions)a[t.strategy]++,o+=t.chunks?.length??0,s=s===null?t.confidence:Math.min(s,t.confidence),t.confidence<n&&c.set(t.filePath,{filePath:t.filePath,confidence:t.confidence,reason:`low-confidence`});let l=e.detection,u=l?.findings??[],d=new Map;for(let e of u){if(e.severity!==`error`)continue;let t=d.get(e.location.file)??new Set;t.add(e.category),d.set(e.location.file,t)}for(let[e,t]of d){let n=c.get(e);c.set(e,{filePath:e,...n?.confidence==null?{}:{confidence:n.confidence},reason:`finding`,findingCategories:[...t].sort()})}let f=[...c.values()].sort(r),p=l!=null&&l.checks.referenceIntegrity===`ran`&&l.checks.structural===`ran`,m=i({hasErrorFinding:d.size>0,hasWarningFinding:u.some(e=>e.severity===`warning`),needsReview:f.length>0,detectionComplete:p,hasErrors:e.errors.length>0});return{files:e.resolutions.length,conflicts:o,byStrategy:a,minConfidence:s,needsReview:f,skipped:e.skipped?.length??0,errors:e.errors.length,detectionComplete:p,findingCount:u.length,verdict:m}}function r(e,t){return e.reason===t.reason?(e.confidence??1)-(t.confidence??1):e.reason===`finding`?-1:1}function i(e){return e.hasErrorFinding?`blocked`:e.needsReview||!e.detectionComplete||e.hasErrors||e.hasWarningFinding?`needs-review`:`clean`}async function a(r,i={}){let a=n(r,i.reviewThreshold??t);if(!i.model)return{digest:a};let{system:o,userMessage:s}=e(r,a),c=await i.model.generate({system:o,messages:[{role:`user`,content:s}],temperature:i.temperature??0,signal:i.signal}),l=c.text?.trim();return{digest:a,...l?{prose:l}:{},...c.usage?{usage:c.usage}:{}}}export{n as buildOperationDigest,a as summarizeOperation};
|
package/dist/types/findings.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/types/findings.d.ts
|
|
2
|
-
type FindingCategory = 'broken-reference' | 'duplicate-definition' | 'syntax-error';
|
|
2
|
+
type FindingCategory = 'broken-reference' | 'duplicate-definition' | 'syntax-error' | 'dropped-side';
|
|
3
3
|
type FindingTier = 'file' | 'project';
|
|
4
4
|
interface Finding {
|
|
5
5
|
category: FindingCategory;
|
|
@@ -27,6 +27,13 @@ interface DetectionReport {
|
|
|
27
27
|
referenceIntegrity: CheckStatus;
|
|
28
28
|
structural: CheckStatus;
|
|
29
29
|
};
|
|
30
|
+
/** How many files were analyzed and whether the scope was capped — an honest coverage signal so
|
|
31
|
+
* empty findings on a truncated scope are not read as "clean". Present only when the reference
|
|
32
|
+
* check ran (refs available). */
|
|
33
|
+
scope?: {
|
|
34
|
+
analyzed: number;
|
|
35
|
+
truncated: boolean;
|
|
36
|
+
};
|
|
30
37
|
}
|
|
31
38
|
//#endregion
|
|
32
39
|
export { CheckStatus, DetectionReport, Finding, FindingCategory, FindingTier };
|
|
@@ -69,6 +69,10 @@ interface ResolutionContext {
|
|
|
69
69
|
prDescription?: string;
|
|
70
70
|
previousResolutions?: Resolution[];
|
|
71
71
|
fileNeighbors?: string[];
|
|
72
|
+
/** Files the merge/sync touched beyond the conflict set (chiefly auto-merged incoming changes).
|
|
73
|
+
* Usually left unset — the reference-integrity detector discovers this set itself from `refs`.
|
|
74
|
+
* When provided, it overrides auto-discovery and defines the incoming detection scope. */
|
|
75
|
+
touchedFiles?: string[];
|
|
72
76
|
refs?: ResolutionRefs;
|
|
73
77
|
threeWayDiff?: ThreeWayDiff;
|
|
74
78
|
/** Free-text guidance from the user that applies to the whole file ("prefer logging across the
|
package/dist/types/summary.d.ts
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { ResolutionStrategy } from "./resolution.js";
|
|
2
|
+
import { FindingCategory } from "./findings.js";
|
|
2
3
|
import { AiTokenUsage } from "@gitkraken/shared-tools";
|
|
3
4
|
|
|
4
5
|
//#region src/types/summary.d.ts
|
|
5
|
-
/** A
|
|
6
|
+
/** A file flagged for human review. `reason` distinguishes a low file-confidence flag from a
|
|
7
|
+
* detection finding; `confidence` is absent for files flagged purely by a finding (e.g. an
|
|
8
|
+
* auto-merged file with no resolution of its own). */
|
|
6
9
|
interface ReviewItem {
|
|
7
10
|
filePath: string;
|
|
8
|
-
confidence
|
|
11
|
+
confidence?: number;
|
|
12
|
+
reason: 'low-confidence' | 'finding';
|
|
13
|
+
/** Categories of the error-severity findings on this file; present when `reason` is `'finding'`. */
|
|
14
|
+
findingCategories?: FindingCategory[];
|
|
9
15
|
}
|
|
16
|
+
/** Suggested honest verdict for the operation. `blocked` when any error-severity finding exists;
|
|
17
|
+
* `needs-review` when confidence is low, detection did not fully run, resolution errored, or a
|
|
18
|
+
* warning finding exists; `clean` only when none of those apply. Advisory — the consumer owns its
|
|
19
|
+
* own gate, but this must not read as clean when the build is known-broken. */
|
|
20
|
+
type OperationVerdict = 'clean' | 'needs-review' | 'blocked';
|
|
10
21
|
/** Deterministic, model-free rollup of a resolve operation. */
|
|
11
22
|
interface OperationDigest {
|
|
12
23
|
/** Files that produced a resolution. */
|
|
@@ -17,12 +28,21 @@ interface OperationDigest {
|
|
|
17
28
|
byStrategy: Record<ResolutionStrategy, number>;
|
|
18
29
|
/** Lowest file confidence across all resolutions; null when there are none. */
|
|
19
30
|
minConfidence: number | null;
|
|
20
|
-
/**
|
|
31
|
+
/** Files needing review — low-confidence resolutions and files with error findings, findings
|
|
32
|
+
* first, then lowest confidence first. */
|
|
21
33
|
needsReview: ReviewItem[];
|
|
22
34
|
/** Files skipped by rule or because they had no markers. */
|
|
23
35
|
skipped: number;
|
|
24
36
|
/** Files that errored during resolution. */
|
|
25
37
|
errors: number;
|
|
38
|
+
/** Whether reference-integrity detection ran to completion (every check `ran`). `false` when no
|
|
39
|
+
* detection was attached or any check was skipped/errored — so empty findings must NOT be read
|
|
40
|
+
* as "clean". */
|
|
41
|
+
detectionComplete: boolean;
|
|
42
|
+
/** Total detection findings across the operation. */
|
|
43
|
+
findingCount: number;
|
|
44
|
+
/** Suggested honest verdict; see {@link OperationVerdict}. */
|
|
45
|
+
verdict: OperationVerdict;
|
|
26
46
|
}
|
|
27
47
|
/** Result of summarizing an operation: always a digest, plus a narrative when a model was provided. */
|
|
28
48
|
interface OperationSummary {
|
|
@@ -33,4 +53,4 @@ interface OperationSummary {
|
|
|
33
53
|
usage?: AiTokenUsage;
|
|
34
54
|
}
|
|
35
55
|
//#endregion
|
|
36
|
-
export { OperationDigest, OperationSummary, ReviewItem };
|
|
56
|
+
export { OperationDigest, OperationSummary, OperationVerdict, ReviewItem };
|