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

Compare

+37 −13 in 5 places
Lines 1–30 at 318 (were 1–25 at 23)
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 .avcs-export.json 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 = ".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"];
2328
2429/** Where an export may go: outside the abso folder, or in a part of it abso leaves out. Empty, or an earlier export. */
2530function checkTarget(root: string, target: string): void {
Lines 34–48 at 318 (were 29–40 at 23)
2934 }
3035 if (inside !== undefined && !ignoredHere(loadIgnore(root), inside, true)) {
3136 throw new UsageError(
32− `${inside} is inside this abso folder, so abso would record the export as your edits. Export outside the folder, or into a folder .avcsignore leaves out`,
37+ `${inside} is inside this abso folder, so abso would record the export as your edits. Export outside the folder, or into a folder .absoignore leaves out`,
3338 );
3439 }
3540 if (!existsSync(target)) return;
3641 if (!statSync(target).isDirectory()) throw new UsageError(`${target} is a file; export to a folder`);
37− if (readdirSync(target).length > 0 && !existsSync(join(target, EXPORT_STAMP))) {
42+ if (
43+ readdirSync(target).length > 0 &&
44+ ![EXPORT_STAMP, ...OLD_EXPORT_STAMPS].some((n) => existsSync(join(target, n)))
45+ ) {
3846 throw new UsageError(
3947 `${target} has files in it; export to an empty folder (an export replaces only a folder an earlier export made)`,
4048 );
Lines 82–92 at 318 (were 74–81 at 23)
7482 const rawVersion = str(args, "version");
7583 if (rawVersion !== undefined && !/^\d+$/.test(rawVersion))
7684 throw new UsageError(`--version is a version number (got ${JSON.stringify(rawVersion)})`);
85+ const leave = withoutArg(args);
7786 const diff = await api.diff();
7887 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}`);
7990 // The listing names the version (the newest by default) and every file it holds; a server from before it answers 404.
8091 const listing = await api
8192 .filesAt(diff.draft, rawVersion === undefined ? undefined : Number(rawVersion))
Lines 106–127 at 318 (were 95–104 at 23)
95106 else
96107 skipped.push({
97108 path: rel,
98− 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",
99110 });
100111 }
101112 }
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");
102125 const entries = await snapshotEntries(api, snap);
103126 // Built before anything is removed, so a failed export leaves an earlier one whole.
104127 const keepGlob = str(args, "keep");
Lines 151–164 at 318 (were 128–140 at 23)
128151 project: config.project,
129152 space: diff.draft ?? "shared",
130153 version,
154+ ...(without !== undefined ? { without: without.without.map((w) => w.version), tree: without.tree } : {}),
131155 files: written,
132156 exportedAt: new Date().toISOString(),
133157 };
134− writeFileSync(join(target, EXPORT_STAMP), `${JSON.stringify(stamp, null, 2)}\n`);
158+ writeFileSync(join(target, EXPORT_STAMP), `${JSON.stringify(stamp)}\n`);
135159 return {
136160 text: [
137− `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.`,
138162 ...(kept.length > 0 ? [`Kept from the earlier export: ${kept.join(", ")}.`] : []),
139163 ...(skipped.length > 0
140164 ? [`Not exported (${skipped.length}):`, ...skipped.map((s) => ` ${s.path}: ${s.why}`)]
MCP
compare on this site's /mcp
CLI
abso diff 23 318 client/src/export.ts --json
JSON
/christopher/abso-core/compare/23..318?file=client%2Fsrc%2Fexport.ts&format=json