@open-cr-agent/core 0.22.0 → 0.23.0
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/mend/conflict.d.ts
CHANGED
|
@@ -27,9 +27,16 @@ export declare function buildConflictCheckPrompt(path: string, segments: readonl
|
|
|
27
27
|
user: string;
|
|
28
28
|
};
|
|
29
29
|
export declare function conflictVerdict(text: string): "resolves" | "does_not_resolve" | "unsure" | undefined;
|
|
30
|
+
export interface ResolvedRegion {
|
|
31
|
+
line: number;
|
|
32
|
+
ours: string[];
|
|
33
|
+
theirs: string[];
|
|
34
|
+
lines: string[];
|
|
35
|
+
}
|
|
30
36
|
export type ConflictAnswer = {
|
|
31
37
|
file: string;
|
|
32
38
|
resolutions: string[][];
|
|
39
|
+
regions: ResolvedRegion[];
|
|
33
40
|
} | {
|
|
34
41
|
refused: "declined" | "invalid";
|
|
35
42
|
};
|
package/dist/mend/conflict.js
CHANGED
|
@@ -174,6 +174,7 @@ export function resolveConflicts(segments, text) {
|
|
|
174
174
|
return { refused: "invalid" };
|
|
175
175
|
const out = [];
|
|
176
176
|
const resolutions = [];
|
|
177
|
+
const answered = [];
|
|
177
178
|
let index = 0;
|
|
178
179
|
for (const segment of segments) {
|
|
179
180
|
if (!("region" in segment)) {
|
|
@@ -189,10 +190,12 @@ export function resolveConflicts(segments, text) {
|
|
|
189
190
|
if (lines.some((line) => MARKER.test(line) || line.includes("\r"))) {
|
|
190
191
|
return { refused: "invalid" };
|
|
191
192
|
}
|
|
193
|
+
const { ours, theirs } = segment.region;
|
|
194
|
+
answered.push({ line: out.length + 1, ours, theirs, lines });
|
|
192
195
|
out.push(...lines);
|
|
193
196
|
resolutions.push(lines);
|
|
194
197
|
}
|
|
195
|
-
return { file: out.join("\n"), resolutions };
|
|
198
|
+
return { file: out.join("\n"), resolutions, regions: answered };
|
|
196
199
|
}
|
|
197
200
|
function jsonOf(text) {
|
|
198
201
|
try {
|
package/dist/mend/round.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CallFailure } from "../errors.js";
|
|
2
|
+
import type { ResolvedRegion } from "./conflict.js";
|
|
2
3
|
import type { ItemOutcome, ItemReason, MEND_OUTCOMES } from "./outcomes.js";
|
|
3
4
|
import type { Hunk } from "./patch.js";
|
|
4
5
|
import { type MendState, type RoundStop } from "./state.js";
|
|
@@ -11,6 +12,7 @@ export interface MendItemResult {
|
|
|
11
12
|
cause?: CallFailure;
|
|
12
13
|
edits?: readonly Hunk[];
|
|
13
14
|
resolved?: string;
|
|
15
|
+
regions?: readonly ResolvedRegion[];
|
|
14
16
|
}
|
|
15
17
|
export interface MendRound {
|
|
16
18
|
headSha: string;
|
|
@@ -3,6 +3,7 @@ import type { AgentCallSettings } from "../agent/settings.js";
|
|
|
3
3
|
import type { SpendLimit } from "../agent/spend-limit.js";
|
|
4
4
|
import type { ReviewContext, SyntaxChecker } from "../contracts.js";
|
|
5
5
|
import { type CallFailure } from "../errors.js";
|
|
6
|
+
import { type ResolvedRegion } from "../mend/conflict.js";
|
|
6
7
|
import type { MendScope } from "../mend/gate.js";
|
|
7
8
|
import type { ItemOutcome, ItemReason } from "../mend/outcomes.js";
|
|
8
9
|
import { type MendState } from "../mend/state.js";
|
|
@@ -20,6 +21,7 @@ export interface ConflictRound {
|
|
|
20
21
|
path: string;
|
|
21
22
|
content: string;
|
|
22
23
|
executable: boolean;
|
|
24
|
+
regions: ResolvedRegion[];
|
|
23
25
|
}[];
|
|
24
26
|
}
|
|
25
27
|
interface ConflictDeps {
|
|
@@ -65,7 +65,7 @@ export async function conflictRound(conflicts, before, deps) {
|
|
|
65
65
|
items: open.map(({ id, file }) => ({ id, conflict: file.path, outcome: "fixed" })),
|
|
66
66
|
resolved: open.map(({ file }, i) => ({
|
|
67
67
|
path: file.path,
|
|
68
|
-
|
|
68
|
+
...answers[i],
|
|
69
69
|
executable: file.executable,
|
|
70
70
|
})),
|
|
71
71
|
};
|
|
@@ -106,7 +106,7 @@ async function resolveFile(file, segments, deps) {
|
|
|
106
106
|
return { outcome: "deferred", reason: "no_room" };
|
|
107
107
|
const verdict = conflictVerdict(await call("verifier", buildConflictCheckPrompt(file.path, segments, answer.resolutions)));
|
|
108
108
|
if (verdict === "resolves")
|
|
109
|
-
return { content: answer.file };
|
|
109
|
+
return { content: answer.file, regions: answer.regions };
|
|
110
110
|
return rejected(verdict === "does_not_resolve" ? "unresolved" : verdict === "unsure" ? "unsure" : "unchecked");
|
|
111
111
|
}
|
|
112
112
|
catch (error) {
|
|
@@ -62,12 +62,16 @@ export async function mergeRound(options, conflicts, round) {
|
|
|
62
62
|
if (!resolved)
|
|
63
63
|
return ended("nothing", answered.items);
|
|
64
64
|
if (options.level === "propose") {
|
|
65
|
-
const
|
|
66
|
-
return ended("proposed", answered.items.map((item) =>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
const files = new Map(resolved.map((file) => [file.path, file]));
|
|
66
|
+
return ended("proposed", answered.items.map((item) => {
|
|
67
|
+
const file = files.get(item.conflict);
|
|
68
|
+
return {
|
|
69
|
+
...item,
|
|
70
|
+
outcome: "proposed",
|
|
71
|
+
resolved: file?.content,
|
|
72
|
+
regions: file?.regions ?? [],
|
|
73
|
+
};
|
|
74
|
+
}));
|
|
71
75
|
}
|
|
72
76
|
if (!vcs.commit)
|
|
73
77
|
return ended("not_writable", deferred(answered.items, "not_writable"));
|
|
@@ -75,7 +79,12 @@ export async function mergeRound(options, conflicts, round) {
|
|
|
75
79
|
parent: headSha,
|
|
76
80
|
mergeParent: conflicts.mergeParent,
|
|
77
81
|
message: mergeMessage(conflicts.mergeParent, resolved),
|
|
78
|
-
files: resolved.map((
|
|
82
|
+
files: resolved.map(({ path, content, executable }) => ({
|
|
83
|
+
path,
|
|
84
|
+
content,
|
|
85
|
+
executable,
|
|
86
|
+
created: false,
|
|
87
|
+
})),
|
|
79
88
|
});
|
|
80
89
|
if (!result.committed)
|
|
81
90
|
return ended(result.outcome, deferred(answered.items, result.outcome));
|