@gitkraken/conflict-tools 0.2.2-beta.1 → 0.2.2-beta.2

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/dist/index.d.ts CHANGED
@@ -17,4 +17,6 @@ import { ConflictProgressEvent } from "./types/events.js";
17
17
  import { resolveConflict } from "./resolver/resolve-conflict.js";
18
18
  import { FileRule, StepConfig, StepResult } from "./types/step.js";
19
19
  import { resolveConflicts } from "./resolver/resolve-conflicts.js";
20
- export { AIError, type AIErrorCode, type BlameOptions, 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 DiffStats, type FileRule, type GrepOptions, type IntraFileEditOp, type Issue, type LogOptions, type OpOptions, type Resolution, type ResolutionContext, type ResolutionMetrics, type ResolutionRawSignals, type ResolutionRefs, type ResolutionStrategy, type ResolutionVerifier, type ResolvedChunk, type ResolverConfig, type ShowFileOptions, type ShowOptions, type StepConfig, type StepResult, type ThreeWayDiff, type ToolCall, type ToolDefinition, type ToolResult, type UnmergedEntry, type UnmergedReason, type VerificationResult, applyResolutions, checkoutFile, createResolution, defaultVerifier, extractConflict, removeFile, resolveConflict, resolveConflicts, show, takeOurs, takeTheirs };
20
+ import { OperationDigest, OperationSummary, ReviewItem } from "./types/summary.js";
21
+ import { SummarizeOperationOptions, buildOperationDigest, summarizeOperation } from "./resolver/summarize-operation.js";
22
+ export { AIError, type AIErrorCode, type BlameOptions, 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 DiffStats, type FileRule, type GrepOptions, type IntraFileEditOp, type Issue, type LogOptions, type OpOptions, type OperationDigest, type OperationSummary, 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 StepConfig, type StepResult, type SummarizeOperationOptions, type ThreeWayDiff, type ToolCall, type ToolDefinition, type ToolResult, type UnmergedEntry, type UnmergedReason, type VerificationResult, applyResolutions, buildOperationDigest, checkoutFile, createResolution, defaultVerifier, extractConflict, removeFile, resolveConflict, resolveConflicts, show, summarizeOperation, takeOurs, takeTheirs };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{AIError as e}from"./errors/ai.js";import{ConflictError as t}from"./errors/conflict.js";import{ConflictGitPortMissingOpError as n}from"./ports/git.js";import{checkoutFile as r,removeFile as i,show as a}from"./git/port-dispatch.js";import{extractConflict as o}from"./extraction/extract.js";import{defaultVerifier as s}from"./ports/verify.js";import{createResolution as c}from"./resolution/create-resolution.js";import{takeOurs as l,takeTheirs as u}from"./resolution/take-strategy.js";import{applyResolutions as d}from"./resolver/apply-resolutions.js";import{resolveConflict as f}from"./resolver/resolve-conflict.js";import{resolveConflicts as p}from"./resolver/resolve-conflicts.js";export{e as AIError,t as ConflictError,n as ConflictGitPortMissingOpError,d as applyResolutions,r as checkoutFile,c as createResolution,s as defaultVerifier,o as extractConflict,i as removeFile,f as resolveConflict,p as resolveConflicts,a as show,l as takeOurs,u as takeTheirs};
1
+ import{AIError as e}from"./errors/ai.js";import{ConflictError as t}from"./errors/conflict.js";import{ConflictGitPortMissingOpError as n}from"./ports/git.js";import{checkoutFile as r,removeFile as i,show as a}from"./git/port-dispatch.js";import{extractConflict as o}from"./extraction/extract.js";import{defaultVerifier as s}from"./ports/verify.js";import{createResolution as c}from"./resolution/create-resolution.js";import{takeOurs as l,takeTheirs as u}from"./resolution/take-strategy.js";import{applyResolutions as d}from"./resolver/apply-resolutions.js";import{resolveConflict as f}from"./resolver/resolve-conflict.js";import{resolveConflicts as p}from"./resolver/resolve-conflicts.js";import{buildOperationDigest as m,summarizeOperation as h}from"./resolver/summarize-operation.js";export{e as AIError,t as ConflictError,n as ConflictGitPortMissingOpError,d as applyResolutions,m as buildOperationDigest,r as checkoutFile,c as createResolution,s as defaultVerifier,o as extractConflict,i as removeFile,f as resolveConflict,p as resolveConflicts,a as show,h as summarizeOperation,l as takeOurs,u as takeTheirs};
@@ -0,0 +1,23 @@
1
+ import { ConflictModelPort } from "../ports/model.js";
2
+ import { StepResult } from "../types/step.js";
3
+ import { OperationDigest, OperationSummary } from "../types/summary.js";
4
+
5
+ //#region src/resolver/summarize-operation.d.ts
6
+ interface SummarizeOperationOptions {
7
+ /** When provided, a single generation call produces the `prose` narrative. Omit for digest only. */
8
+ model?: ConflictModelPort;
9
+ signal?: AbortSignal;
10
+ /** File confidence below this lands a file in `needsReview`. Default 0.8. */
11
+ reviewThreshold?: number;
12
+ temperature?: number;
13
+ }
14
+ /** Pure, model-free rollup of a {@link StepResult}. */
15
+ declare function buildOperationDigest(result: StepResult, reviewThreshold?: number): OperationDigest;
16
+ /**
17
+ * Summarize a resolve operation for a reviewer. Always returns a deterministic `digest`; when
18
+ * `opts.model` is set, one generation call adds a prose narrative fed by the per-chunk reasons
19
+ * captured during resolution — never reverse-engineered from the resolved content.
20
+ */
21
+ declare function summarizeOperation(result: StepResult, opts?: SummarizeOperationOptions): Promise<OperationSummary>;
22
+ //#endregion
23
+ export { SummarizeOperationOptions, buildOperationDigest, summarizeOperation };
@@ -0,0 +1,4 @@
1
+ const e=.8,t=[`ai`,`take-ours`,`take-theirs`,`deleted`,`skipped`];function n(n,r=e){let i=Object.fromEntries(t.map(e=>[e,0])),a=0,o=null,s=[];for(let e of n.resolutions)i[e.strategy]++,a+=e.chunks?.length??0,o=o===null?e.confidence:Math.min(o,e.confidence),e.confidence<r&&s.push({filePath:e.filePath,confidence:e.confidence});return s.sort((e,t)=>e.confidence-t.confidence),{files:n.resolutions.length,conflicts:a,byStrategy:i,minConfidence:o,needsReview:s,skipped:n.skipped?.length??0,errors:n.errors.length}}async function r(t,r={}){let a=n(t,r.reviewThreshold??e);if(!r.model)return{digest:a};let{system:o,userMessage:s}=i(t,a),c=await r.model.generate({system:o,messages:[{role:`user`,content:s}],temperature:r.temperature??0,signal:r.signal}),l=c.text?.trim();return{digest:a,...l?{prose:l}:{},...c.usage?{usage:c.usage}:{}}}function i(e,t){let n=[];if(n.push(`Files resolved: ${t.files}. Conflicts: ${t.conflicts}. Skipped: ${t.skipped}. Errors: ${t.errors}.`),e.resolutions.length>0){n.push(``,`Resolutions:`);for(let t of e.resolutions){n.push(`- ${t.filePath} [${t.strategy}, ${a(t.confidence)}]: ${t.description}`);for(let e of t.chunks??[]){if(!e.reason)continue;let t=a(e.confidence);n.push(` - marker ${e.markerIndex} (${e.strategy}, ${t}): ${e.reason}`)}}}if(e.skipped&&e.skipped.length>0){n.push(``,`Skipped:`);for(let t of e.skipped)n.push(`- ${t.filePath}: ${t.reason}`)}if(e.errors.length>0){n.push(``,`Errors:`);for(let t of e.errors)n.push(`- ${t.filePath}: ${t.error.message}`)}return{system:`You are summarizing an automated git conflict-resolution pass for a human reviewer who is about to accept or reject it.
2
+
3
+ Write 2-4 sentences of plain prose. Lead with what happened across the operation, then call out which files deserve a closer look and why — the lower-confidence ones, the skips, and any errors. Be concrete: name files and the reason for any doubt. Use only the information given; do not invent specifics. No bullet points, headings, or markdown — sentences only.`,userMessage:n.join(`
4
+ `)}}function a(e){return e===void 0?`—`:`${Math.round(e*100)}%`}export{n as buildOperationDigest,r as summarizeOperation};
@@ -0,0 +1,36 @@
1
+ import { ResolutionStrategy } from "./resolution.js";
2
+ import { AiTokenUsage } from "@gitkraken/shared-tools";
3
+
4
+ //#region src/types/summary.d.ts
5
+ /** A resolved file flagged for human review because its file confidence is below the threshold. */
6
+ interface ReviewItem {
7
+ filePath: string;
8
+ confidence: number;
9
+ }
10
+ /** Deterministic, model-free rollup of a resolve operation. */
11
+ interface OperationDigest {
12
+ /** Files that produced a resolution. */
13
+ files: number;
14
+ /** Total resolved conflict markers across all files. */
15
+ conflicts: number;
16
+ /** Resolution count per strategy. */
17
+ byStrategy: Record<ResolutionStrategy, number>;
18
+ /** Lowest file confidence across all resolutions; null when there are none. */
19
+ minConfidence: number | null;
20
+ /** Resolutions below the review threshold, lowest confidence first. */
21
+ needsReview: ReviewItem[];
22
+ /** Files skipped by rule or because they had no markers. */
23
+ skipped: number;
24
+ /** Files that errored during resolution. */
25
+ errors: number;
26
+ }
27
+ /** Result of summarizing an operation: always a digest, plus a narrative when a model was provided. */
28
+ interface OperationSummary {
29
+ digest: OperationDigest;
30
+ /** Human-readable narrative; present only when a model produced one. */
31
+ prose?: string;
32
+ /** Token usage of the prose synthesis call; present only when prose was generated. */
33
+ usage?: AiTokenUsage;
34
+ }
35
+ //#endregion
36
+ export { OperationDigest, OperationSummary, ReviewItem };
@@ -0,0 +1 @@
1
+ export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitkraken/conflict-tools",
3
- "version": "0.2.2-beta.1",
3
+ "version": "0.2.2-beta.2",
4
4
  "description": "AI-powered git conflict resolution.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Axosoft, LLC dba GitKraken",