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

Compare

+33 −15 in 5 places
Lines 1–30 at 318 (were 1–27 at 27)
11// abso export <dir> [--version N]: one published version of this folder's
22// space, written to a folder of its own, for a build that doesn't move while
3−// shared does (#37, Playtester 1). The folder gets .abso-export.json (.avcs-export.json before the rename) naming
4−// the version, to stamp the build with. Exporting again replaces the folder,
5−// keeping node_modules (and what --keep names) so a build needs no new install.
3+// shared does (#37). The folder gets .abso-export naming the
4+// version, to stamp the build with: JSON on one line, in a file with no
5+// extension, so the exported project's own formatter and linter pass it by.
6+// Exporting again replaces the folder, keeping node_modules (and what --keep
7+// names) so a build needs no new install.
68//
79// The version is rebuilt as `abso run --at` rebuilds it (at.ts), from the
8−// known copies and one compare; the server's listing of that version (#37,
9−// Engine 522be7f) then checks that no file is left out.
10+// known copies and one compare; the server's listing of that version (#37)
11+// then checks that no file is left out.
1012
1113import { chmodSync, existsSync, mkdirSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
1214import { dirname, join, resolve } from "node:path";
1315import type { Where } from "./api.ts";
1416import { type Parsed, str, UsageError } from "./args.ts";
15−import { globTest, snapshotAt, snapshotEntries } from "./at.ts";
16−import { type Env, type Output, open, plural } from "./commands.ts";
17+import { applySide, globTest, snapshotAt, snapshotEntries } from "./at.ts";
18+import { type Env, EXIT, type Output, open, plural } from "./commands.ts";
1719import { ignoredHere } from "./fetch.ts";
1820import { loadIgnore, relativeTo } from "./folder.ts";
1921import { type Refused, unsafePath } from "./safety.ts";
22+import { refusalText, versionsText, withoutArg } from "./without.ts";
2023
2124/** The file an export leaves in its folder: what it holds, and the sign that the folder is one export may replace. */
22−export const EXPORT_STAMP = ".abso-export.json";
23−/** The name before the rename: an export made then still counts as one. */
24−const OLD_EXPORT_STAMP = ".avcs-export.json";
25+export const EXPORT_STAMP = ".abso-export";
26+/** Its earlier names: an export made then still counts as one. A .json name drew the project's formatter. */
27+const OLD_EXPORT_STAMPS = [".abso-export.json", ".avcs-export.json"];
2528
2629/** Where an export may go: outside the abso folder, or in a part of it abso leaves out. Empty, or an earlier export. */
2730function checkTarget(root: string, target: string): void {
Lines 41–47 at 318 (were 38–45 at 27)
3841 if (!statSync(target).isDirectory()) throw new UsageError(`${target} is a file; export to a folder`);
3942 if (
4043 readdirSync(target).length > 0 &&
41− !existsSync(join(target, EXPORT_STAMP)) &&
42− !existsSync(join(target, OLD_EXPORT_STAMP))
44+ ![EXPORT_STAMP, ...OLD_EXPORT_STAMPS].some((n) => existsSync(join(target, n)))
4345 ) {
4446 throw new UsageError(
4547 `${target} has files in it; export to an empty folder (an export replaces only a folder an earlier export made)`,
Lines 82–92 at 318 (were 80–87 at 27)
8082 const rawVersion = str(args, "version");
8183 if (rawVersion !== undefined && !/^\d+$/.test(rawVersion))
8284 throw new UsageError(`--version is a version number (got ${JSON.stringify(rawVersion)})`);
85+ const leave = withoutArg(args);
8386 const diff = await api.diff();
8487 const where: Where = { draft: diff.draft };
88+ if (leave !== undefined && diff.draft !== null)
89+ throw new UsageError(`--without reads shared, and this folder is on draft ${diff.draft}`);
8590 // The listing names the version (the newest by default) and every file it holds; a server from before it answers 404.
8691 const listing = await api
8792 .filesAt(diff.draft, rawVersion === undefined ? undefined : Number(rawVersion))
Lines 106–127 at 318 (were 101–110 at 27)
101106 else
102107 skipped.push({
103108 path: rel,
104− why: "a binary file this folder has no copy of; abso sync --full, then export again",
109+ why: "a binary file this folder has no copy of; abso pull --full, then export again",
105110 });
106111 }
107112 }
113+ // Without some versions: the server says what differs from this version, as it is without them.
114+ const without = leave === undefined ? undefined : await api.without(version, leave);
115+ if (without !== undefined && !without.ok)
116+ return {
117+ exit: EXIT.refused,
118+ text: refusalText(
119+ without,
120+ (vs) => `abso export ${args.positionals[0]} --version ${version} --without ${vs.join(",")}`,
121+ ),
122+ json: { ...without },
123+ };
124+ if (without !== undefined) applySide(snap, without.files, "after");
108125 const entries = await snapshotEntries(api, snap);
109126 // Built before anything is removed, so a failed export leaves an earlier one whole.
110127 const keepGlob = str(args, "keep");
Lines 151–164 at 318 (were 134–146 at 27)
134151 project: config.project,
135152 space: diff.draft ?? "shared",
136153 version,
154+ ...(without !== undefined ? { without: without.without.map((w) => w.version), tree: without.tree } : {}),
137155 files: written,
138156 exportedAt: new Date().toISOString(),
139157 };
140− writeFileSync(join(target, EXPORT_STAMP), `${JSON.stringify(stamp, null, 2)}\n`);
158+ writeFileSync(join(target, EXPORT_STAMP), `${JSON.stringify(stamp)}\n`);
141159 return {
142160 text: [
143− `Exported version ${version} of ${space} to ${target}: ${plural(written, "file")}. ${EXPORT_STAMP} there names the version; abso export to the same folder replaces it.`,
161+ `Exported version ${version} of ${space}${without !== undefined ? ` without ${versionsText(without.without.map((w) => w.version))}` : ""} to ${target}: ${plural(written, "file")}. ${EXPORT_STAMP} there names the version; abso export to the same folder replaces it.`,
144162 ...(kept.length > 0 ? [`Kept from the earlier export: ${kept.join(", ")}.`] : []),
145163 ...(skipped.length > 0
146164 ? [`Not exported (${skipped.length}):`, ...skipped.map((s) => ` ${s.path}: ${s.why}`)]
MCP
compare on this site's /mcp
CLI
abso diff 27 318 client/src/export.ts --json
JSON
/christopher/abso-core/compare/27..318?file=client%2Fsrc%2Fexport.ts&format=json