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

Compare

+53 −0 in 1 place
new file, 53 lines
1+// --without <version,...> on abso show and abso export: a version of shared with some earlier versions left out.
2+// The server reads it; shared doesn't change. When a version kept builds on one left out, it is refused with
3+// that chain and the wider set that works, which is never taken without being asked.
4+
5+import type { VersionRef, WithoutAnswer } from "./api.ts";
6+import { type Parsed, str, UsageError } from "./args.ts";
7+
8+/** The versions --without names, sorted, or undefined without it. */
9+export function withoutArg(args: Parsed): number[] | undefined {
10+ const raw = str(args, "without");
11+ if (raw === undefined) return undefined;
12+ const words = raw
13+ .split(",")
14+ .map((w) => w.trim())
15+ .filter((w) => w !== "");
16+ if (words.length === 0 || words.some((w) => !/^\d+$/.test(w)))
17+ throw new UsageError(`--without takes version numbers, like --without 37,38 (got ${JSON.stringify(raw)})`);
18+ return [...new Set(words.map(Number))].toSorted((a, b) => a - b);
19+}
21+/** "version 37", "versions 37 and 38", "versions 37, 38 and 40". */
22+export function versionsText(versions: readonly number[]): string {
23+ if (versions.length === 1) return `version ${versions[0]}`;
24+ return `versions ${versions.slice(0, -1).join(", ")} and ${versions[versions.length - 1]}`;
25+}
27+function ref(v: VersionRef): string {
28+ return ` version ${v.version} by ${v.agent}: ${v.message}`;
29+}
31+/** The heading of an answer: the version and what it leaves out, one line each. */
32+export function withoutHeading(answer: WithoutAnswer): string[] {
33+ return [
34+ `Version ${answer.version} of shared without ${versionsText(answer.without.map((w) => w.version))}:`,
35+ ...answer.without.map(ref),
36+ ];
37+}
39+/** A refusal: which kept versions build on what is left out, and the ask that would work (`retry` writes it). */
40+export function refusalText(
41+ answer: Extract<WithoutAnswer, { ok: false }>,
42+ retry: (versions: readonly number[]) => string,
43+): string {
44+ const asked = answer.without.map((w) => w.version);
45+ return [
46+ `Version ${answer.version} of shared can't leave out ${versionsText(asked)}: versions it keeps build on ${asked.length === 1 ? "it" : "them"}.`,
47+ ...answer.dependents.flatMap((d) => [
48+ ref(d),
49+ ` builds on ${d.needs.map((n) => `version ${n.version} (${n.files.join(", ") || "no file of its own"})`).join(", ")}`,
50+ ]),
51+ `Leaving those out too works: ${retry(answer.suggestion)}`,
52+ ].join("\n");
53+}
MCP
compare on this site's /mcp
CLI
abso diff 55 318 client/src/without.ts --json
JSON
/christopher/abso-core/compare/55..318?file=client%2Fsrc%2Fwithout.ts&format=json