Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 191 to 192

Compare

+35 −0 in 1 place
new file, 35 lines
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.
4+
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+}
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 191 192 scripts/autosettle/rules.ts --json
JSON
/christopher/abso-core/compare/191..192?file=scripts%2Fautosettle%2Frules.ts&format=json