Versions 192 to 318
Lines 1–3 at 318 (were 1–35 at 192)
1−// Checks in code around the model's pick (#19). What code can decide, code
2−// decides; what the model picks is turned down when it would plainly break
3−// the file. Both run before anything is settled automatically.
1+// Checks in code around the model's pick (#19): the tool's own (worker/project/autosettle.ts), so the scripts score what the servers run.
42
5−import type { Hold, Pick } from "./jev.ts";
6−
7−const solid = (lines: readonly string[]) => lines.map((l) => l.trim()).filter((l) => /[A-Za-z0-9]/.test(l));
8−
9−/** A pick code can make without the model, with why; undefined when it takes judgment. */
10−export function ruled(h: Hold): { pick: Pick; reason: string } | undefined {
11− const yours = solid(h.yours);
12− const theirs = solid(h.theirs);
13− if (yours.join("\n") === theirs.join("\n")) return { pick: "theirs", reason: "both sides wrote the same lines" };
14− if (yours.length > 0 && yours.every((l) => theirs.includes(l)))
15− return { pick: "theirs", reason: "every line of yours is already in theirs" };
16− if (theirs.length > 0 && theirs.every((l) => yours.includes(l)))
17− return { pick: "yours", reason: "every line of theirs is already in yours" };
18− return undefined;
19−}
20−
21−/** Why a model's pick can't be applied as it is, or undefined when it can. */
22−export function refused(h: Hold, pick: Pick): string | undefined {
23− if (pick !== "both") return undefined;
24− const theirs = new Set(solid(h.theirs));
25− const twice = solid(h.yours).filter((l) => theirs.has(l));
26− if (twice.length > 0)
27− return `keeping both would repeat ${twice.length === 1 ? "a line" : `${twice.length} lines`}: ${twice[0]}`;
28− // The same key or name set on both sides: `timeoutMs:`, `limit =`.
29− const key = (l: string) => /^([A-Za-z_$"'][\w$"'-]*)\s*[:=]/.exec(l)?.[1];
30− const theirKeys = new Set(solid(h.theirs).map(key).filter(Boolean));
31− const clash = solid(h.yours)
32− .map(key)
33− .find((k) => k && theirKeys.has(k));
34− return clash ? `keeping both would set ${clash} twice` : undefined;
35−}
- MCP
- compare on this site's /mcp
- CLI
- abso diff 192 318 scripts/autosettle/rules.ts --json
- JSON
- /christopher/abso-core/compare/192..318?file=scripts%2Fautosettle%2Frules.ts&format=json