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 196 to 318

Compare

+18 −72 in 3 places
Lines 7–17 at 318 (were 7–13 at 196)
77// is never printed or written anywhere.
88
99import { execFileSync } from "node:child_process";
10+import { confidenceOf, SIGNS, systemOneBody } from "../../worker/project/autosettle.ts";
1011
12+// The questions are the tool's own (worker/project/autosettle.ts), so Jev and Clef are asked alike.
13+export { systemOneBody };
1115export const ENDPOINT = "https://api.typesafe.ai/v1/systemone";
1216
1317/** abso's settle choices, plus a hand edit by an agent. */
Lines 71–101 at 318 (were 67–155 at 196)
6771 }
6872}
6973
70−const text = (lines: readonly string[]): string => (lines.length === 0 ? "(no lines)" : lines.join("\n"));
71−
72−function stateOf(h: Hold): Record<string, unknown> {
73− return {
74− file: h.file,
75− lines_above: text(h.before),
76− before_either_change: text(h.base),
77− yours: text(h.yours),
78− theirs: text(h.theirs),
79− lines_below: text(h.after),
80− your_push: { agent: h.yourAgent ?? "you", message: h.yourMessage ?? "(no message)" },
81− their_push: { agent: h.theirAgent ?? "the other agent", message: h.theirMessage ?? "(no message)" },
82− ...(h.issue ? { issue: h.issue } : {}),
83− };
84−}
85−
86−const INSTRUCTIONS =
87− "Two agents changed the same lines of `file`. Both started from `before_either_change`. " +
88− "`yours` is what the held agent wrote, for the reason in `your_push`; `theirs` was pushed first, for the reason in `their_push`. " +
89− "The region sits between `lines_above` and `lines_below`. " +
90− "Which result is correct code that does what both pushes meant?";
91−
92−const CRITERIA: Record<Pick, string> = {
93− yours: "Keep `yours` only: `yours` already does what `theirs` meant, or `theirs` is wrong or out of date.",
94− theirs: "Keep `theirs` only: `theirs` already does what `yours` meant, or `yours` is wrong or out of date.",
95− both: "Keep both unchanged, `yours` then `theirs`: they add separate things that work side by side, and nothing is duplicated or contradicts.",
96− agent:
97− "Neither side alone and not both unchanged: the sides change the same thing in different ways (such as two different values for one setting), or keeping both would duplicate or contradict, so a correct result needs a hand edit.",
98−};
99−
100−function choice(order: readonly Pick[]) {
101− return {
102− type: "choice",
103− instructions: INSTRUCTIONS,
104− criteria: Object.fromEntries(order.map((p) => [p, CRITERIA[p]])),
105− };
106−}
107−
108−const SIGNS: Record<string, string> = {
109− same_setting_different_values:
110− "Do `yours` and `theirs` set the same setting, constant or value to two different values?",
111− theirs_covers_yours: "Does `theirs` already do everything `yours` was changed to do?",
112− yours_covers_theirs: "Does `yours` already do everything `theirs` was changed to do?",
113− both_unchanged_compiles:
114− "If `yours` were placed directly above `theirs`, unchanged, would the file still be correct code with nothing defined twice?",
115−};
116−
117−function confidenceOf(p: Record<Pick, number>): number {
118− const max = Math.max(...PICKS.map((k) => p[k]));
119− const even = 1 / PICKS.length;
120− return Math.max(0, (max - even) / (1 - even));
121−}
122−
12374function top(p: Record<Pick, number>): Pick {
12475 return PICKS.reduce((a, b) => (p[b] > p[a] ? b : a));
12576}
12677
127−/** Ask Jev once, with the choice in two option orders (Jev's docs warn order can sway a Choice) and the side questions. */
78+export interface SystemOneAnswer {
79+ model: string;
80+ answers: Record<string, { type: string; probabilities?: Record<string, number>; noul?: number; choice?: string }>;
81+ usage?: { input_tokens?: number };
82+}
84+/** Ask Jev once. */
12885export async function ask(h: Hold, opts: { model?: string; key?: string } = {}): Promise<Verdict> {
129− const forward = PICKS;
130− const backward = [...PICKS].reverse();
131− const body = {
132− model: opts.model ?? "jev-latest",
133− state: stateOf(h),
134− questions: {
135− settle: choice(forward),
136− settle_reversed: choice(backward),
137− ...Object.fromEntries(Object.entries(SIGNS).map(([id, q]) => [id, { type: "noul", instructions: q }])),
138− },
139− };
14086 const started = performance.now();
14187 const res = await fetch(ENDPOINT, {
14288 method: "POST",
14389 headers: { authorization: `Bearer ${opts.key ?? apiKey()}`, "content-type": "application/json" },
144− body: JSON.stringify(body),
90+ body: JSON.stringify(systemOneBody(h, opts.model ?? "jev-latest")),
14591 });
14692 const ms = performance.now() - started;
14793 if (!res.ok) throw new Error(`Jev answered ${res.status}: ${(await res.text()).slice(0, 500)}`);
148− const out = (await res.json()) as {
149− model: string;
150− answers: Record<string, { type: string; probabilities?: Record<string, number>; noul?: number; choice?: string }>;
151− usage: { input_tokens: number };
152− };
94+ return verdictOf((await res.json()) as SystemOneAnswer, ms);
95+}
97+/** A System One answer to systemOneBody's questions, as a Verdict. */
98+export function verdictOf(out: SystemOneAnswer, ms: number): Verdict {
15399 const orders = ["settle", "settle_reversed"].map((id) => {
154100 const probabilities = Object.fromEntries(PICKS.map((k) => [k, out.answers[id]!.probabilities![k] ?? 0])) as Record<
155101 Pick,
Lines 114–120 at 318 (were 168–174 at 196)
168114 signs: Object.fromEntries(Object.keys(SIGNS).map((id) => [id, out.answers[id]?.noul ?? Number.NaN])),
169115 model: out.model,
170116 ms,
171− inputTokens: out.usage.input_tokens,
117+ inputTokens: out.usage?.input_tokens ?? 0,
172118 };
173119}
174120
MCP
compare on this site's /mcp
CLI
abso diff 196 318 scripts/autosettle/jev.ts --json
JSON
/christopher/abso-core/compare/196..318?file=scripts%2Fautosettle%2Fjev.ts&format=json