Versions 194 to 195
Lines 3–18 at 195 (were 3–15 at 194)
6−// Each settled collision gives: the file before theirs (their version - 1, the
7−// best guess at what both started from), theirs, and the settle's result.
8−// The held agent's own lines are only recoverable from the result when it kept
9−// yours or both; otherwise "yours" is null and score.ts skips the case.
1011
12−import { writeFileSync } from "node:fs";
1316
Lines 38–51 at 195 (were 35–49 at 194)
38−const review = JSON.parse(abso("review", "--since", since, "--json")) as {
39− changes: {
40− agent?: string;
41− author?: string;
42− message?: string;
43− settled: Settled[];
44− versions?: { version: number; message: string }[];
45− }[];
46−};
4850for (const c of review.changes) for (const v of c.versions ?? []) messages.set(v.version, v.message);
Lines 60–174 at 195 (were 58–116 at 194)
6062
61−/** The span where `a` and `b` differ, by common prefix and suffix. */
62−function hunk(a: string[], b: string[]): { start: number; aEnd: number; bEnd: number } {
63− let start = 0;
64− while (start < a.length && start < b.length && a[start] === b[start]) start++;
65− let tail = 0;
66− while (tail < a.length - start && tail < b.length - start && a[a.length - 1 - tail] === b[b.length - 1 - tail])
67− tail++;
68− return { start, aEnd: a.length - tail, bEnd: b.length - tail };
64+ /** 0-based start and length on each side; a length of 0 is an insertion before (or deletion at) start. */
7070
71−/** The lines of `r` between the context above and below a hunk of `t`, found by a few anchor lines. */
72−function regionIn(r: string[], t: string[], start: number, end: number): string[] | null {
73− const above = t.slice(Math.max(0, start - 3), start);
74− const below = t.slice(end, end + 3);
75− const find = (needle: string[], from: number) => {
76− if (needle.length === 0) return -1;
77− for (let i = from; i + needle.length <= r.length; i++) if (needle.every((l, j) => r[i + j] === l)) return i;
78− return -2;
79− };
80− const a = find(above, 0);
81− const from = above.length === 0 ? 0 : a < 0 ? -1 : a + above.length;
82− if (from < 0) return null;
83− const b = find(below, from);
84− const to = below.length === 0 ? r.length : b < 0 ? -1 : b;
85− return to < 0 ? null : r.slice(from, to);
78+ text = execFileSync("git", ["diff", "--no-index", "-U0", "--no-color", join(dir, "a"), join(dir, "b")], {
87100
106+
108+ * The collisions a settle went through in one file: each of their hunks (before to theirs) that the
114+ const touches = (h: Hunk, g: Hunk) => g.aStart <= h.bStart + h.bLen && h.bStart <= g.aStart + g.aLen;
131+ context: { before: theirs.slice(Math.max(0, tStart - 15), tStart), after: theirs.slice(tEnd, tEnd + 15) },
136+
89−for (const c of review.changes) {
91− const before = fileAt(s.theirs.version - 1, s.file);
92− const theirs = fileAt(s.theirs.version, s.file);
93− const result = fileAt(s.version, s.file);
152+ // Marker blocks the settler changed, in file order; a block where it kept theirs left no trace to find.
95− let base: string[] | null = null;
96− let theirsLines: string[] | null = null;
97− let region: string[] | null = null;
98− let context = { before: [] as string[], after: [] as string[] };
99− if (before && theirs && result) {
100− const h = hunk(before, theirs);
101− base = before.slice(h.start, h.aEnd);
102− theirsLines = theirs.slice(h.start, h.bEnd);
103− context = { before: theirs.slice(Math.max(0, h.start - 15), h.start), after: theirs.slice(h.bEnd, h.bEnd + 15) };
104− region = regionIn(result, theirs, h.start, h.bEnd);
105− if (region === null) notes.push("couldn't find the region in the settled file");
106− if (theirsLines.length > 80) notes.push(`their change spans ${theirsLines.length} lines`);
107− } else notes.push("a version of the file couldn't be read");
160+ else if (!r) notes.push(`found ${found.length} changed regions for ${changed.length} settled blocks`);
162+ notes.push(`found ${found.length} changed regions for ${changed.length} settled blocks: the pairing may be off`);
109− if (region && s.kept === "yours") yours = region;
110− else if (region && theirsLines && s.kept === "both") yours = region.slice(0, region.length - theirsLines.length);
111− else notes.push(`yours isn't recoverable from the result when the agent kept ${s.kept}`);
167+ if (tail.join("\n") === r.theirs.join("\n")) yours = r.result.slice(0, r.result.length - r.theirs.length);
169+ } else if (r) notes.push(`yours isn't recoverable from the result when the agent kept ${s.kept}`);
113− id: `${s.version}-${s.file}`,
Lines 178–193 at 195 (were 120–135 at 194)
122180 theirs: { agent: s.theirs.agent, version: s.theirs.version, message: messageOf(s.theirs.version) },
123− base,
125− theirsLines,
126− context,
127− result: region,
131− });
132− }
- MCP
- compare on this site's /mcp
- CLI
- abso diff 194 195 scripts/autosettle/extract.ts --json
- JSON
- /christopher/abso-core/compare/194..195?file=scripts%2Fautosettle%2Fextract.ts&format=json