- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/client/src/without.ts?version=280&format=json
53 linescandidates 100%Last change candidates in version 186, 1 version changed it
You're reading version 280. The newest is 318, and no version since then changed this file.
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.
5import type { VersionRef, WithoutAnswer } from "./api.ts";
6import { type Parsed, str, UsageError } from "./args.ts";
8/** The versions --without names, sorted, or undefined without it. */
9export 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". */
22export 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}
27function 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. */
32export 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). */
40export 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}