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 188 to 189

Compare

+81 −0 in 1 place
new file, 81 lines
1+// Ask Jev how to settle each marker block in one file (#19), the way abso pull
2+// leaves a held push's file. Prints Jev's pick and its probabilities; changes nothing.
3+//
4+// node scripts/autosettle/settle-one.ts <file> [--message "<your held push's message>"] [--issue "..."] [--name <path in the project>] [--json]
5+//
6+// Needs JEV_API_KEY in the environment.
7+
8+import { readFileSync } from "node:fs";
9+import { findBlocks } from "../../client/src/settle.ts";
10+import { ask, dollars, type Hold, PICKS } from "./jev.ts";
12+const CONTEXT = 15;
13+const CLOSE = /^>>>>>>> theirs: (.*?), version (\d+) "(.*)"$/;
15+/** Each marker block in a file's text as a Hold. */
16+export function holdsIn(
17+ text: string,
18+ file: string,
19+ extra: { yourMessage?: string; yourAgent?: string; issue?: string } = {},
20+): Hold[] {
21+ const lines = text.split(/\r?\n/);
22+ return findBlocks(lines).map((b) => {
23+ const close = CLOSE.exec(lines[b.end]!);
24+ return {
25+ file,
26+ base: b.base,
27+ yours: b.yours,
28+ theirs: b.theirs,
29+ before: lines.slice(Math.max(0, b.start - CONTEXT), b.start),
30+ after: lines.slice(b.end + 1, b.end + 1 + CONTEXT),
31+ ...(close ? { theirAgent: close[1], theirMessage: close[3] } : {}),
32+ ...extra,
33+ };
34+ });
35+}
37+function flag(args: string[], name: string): string | undefined {
38+ const i = args.indexOf(name);
39+ return i === -1 ? undefined : args[i + 1];
40+}
42+async function main(): Promise<void> {
43+ const args = process.argv.slice(2);
44+ const path = args[0];
45+ if (!path || path.startsWith("--")) {
46+ console.error(
47+ 'usage: node scripts/autosettle/settle-one.ts <file> [--message "..."] [--issue "..."] [--name <path>] [--json]',
48+ );
49+ process.exit(2);
50+ }
51+ const holds = holdsIn(readFileSync(path, "utf8"), flag(args, "--name") ?? path, {
52+ ...(flag(args, "--message") ? { yourMessage: flag(args, "--message") } : {}),
53+ ...(flag(args, "--issue") ? { issue: flag(args, "--issue") } : {}),
54+ });
55+ if (holds.length === 0) {
56+ console.error(`${path} has no marker blocks.`);
57+ process.exit(1);
58+ }
59+ const results = [];
60+ for (const [i, h] of holds.entries()) {
61+ const v = await ask(h);
62+ results.push({ block: i + 1, ...v });
63+ if (args.includes("--json")) continue;
64+ const pct = (x: number) => `${(x * 100).toFixed(0)}%`;
65+ console.log(`Block ${i + 1} of ${holds.length} in ${h.file}: ${v.pick}, confidence ${v.confidence.toFixed(2)}`);
66+ console.log(` probabilities: ${PICKS.map((k) => `${k} ${pct(v.probabilities[k])}`).join(", ")}`);
67+ console.log(
68+ ` each order: ${v.orders.map((o) => `${o.pick} ${o.confidence.toFixed(2)}`).join(" / ")}; side questions: ${Object.entries(
69+ v.signs,
70+ )
71+ .map(([k, p]) => `${k} ${pct(p)}`)
72+ .join(", ")}`,
73+ );
74+ console.log(
75+ ` ${v.model}, ${v.ms.toFixed(0)} ms, ${v.inputTokens} input tokens ($${dollars(v.inputTokens).toFixed(6)})`,
76+ );
77+ }
78+ if (args.includes("--json")) console.log(JSON.stringify(results, null, "\t"));
79+}
81+if (process.argv[1]?.endsWith("settle-one.ts")) await main();
MCP
compare on this site's /mcp
CLI
abso diff 188 189 scripts/autosettle/settle-one.ts --json
JSON
/christopher/abso-core/compare/188..189?file=scripts%2Fautosettle%2Fsettle-one.ts&format=json