{"file":"client/src/export.ts","version":318,"total":169,"from":1,"to":169,"lines":[{"n":1,"text":"// abso export <dir> [--version N]: one published version of this folder's","atom":"a0","author":"init","version":0},{"n":2,"text":"// space, written to a folder of its own, for a build that doesn't move while","atom":"a0","author":"init","version":0},{"n":3,"text":"// shared does (#37). The folder gets .abso-export naming the","atom":"a386","author":"infra-split","version":39},{"n":4,"text":"// version, to stamp the build with: JSON on one line, in a file with no","atom":"a250","author":"pinch","version":29},{"n":5,"text":"// extension, so the exported project's own formatter and linter pass it by.","atom":"a250","author":"pinch","version":29},{"n":6,"text":"// Exporting again replaces the folder, keeping node_modules (and what --keep","atom":"a250","author":"pinch","version":29},{"n":7,"text":"// names) so a build needs no new install.","atom":"a250","author":"pinch","version":29},{"n":8,"text":"//","atom":"a0","author":"init","version":0},{"n":9,"text":"// The version is rebuilt as `abso run --at` rebuilds it (at.ts), from the","atom":"a0","author":"init","version":0},{"n":10,"text":"// known copies and one compare; the server's listing of that version (#37)","atom":"a386","author":"infra-split","version":39},{"n":11,"text":"// then checks that no file is left out.","atom":"a386","author":"infra-split","version":39},{"n":12,"text":"","atom":"a0","author":"init","version":0},{"n":13,"text":"import { chmodSync, existsSync, mkdirSync, readdirSync, rmSync, statSync, writeFileSync } from \"node:fs\";","atom":"a0","author":"init","version":0},{"n":14,"text":"import { dirname, join, resolve } from \"node:path\";","atom":"a0","author":"init","version":0},{"n":15,"text":"import type { Where } from \"./api.ts\";","atom":"a0","author":"init","version":0},{"n":16,"text":"import { type Parsed, str, UsageError } from \"./args.ts\";","atom":"a0","author":"init","version":0},{"n":17,"text":"import { applySide, globTest, snapshotAt, snapshotEntries } from \"./at.ts\";","atom":"a2093","author":"candidates","version":186},{"n":18,"text":"import { type Env, EXIT, type Output, open, plural } from \"./commands.ts\";","atom":"a2093","author":"candidates","version":186},{"n":19,"text":"import { ignoredHere } from \"./fetch.ts\";","atom":"a0","author":"init","version":0},{"n":20,"text":"import { loadIgnore, relativeTo } from \"./folder.ts\";","atom":"a0","author":"init","version":0},{"n":21,"text":"import { type Refused, unsafePath } from \"./safety.ts\";","atom":"a0","author":"init","version":0},{"n":22,"text":"import { refusalText, versionsText, withoutArg } from \"./without.ts\";","atom":"a2093","author":"candidates","version":186},{"n":23,"text":"","atom":"a0","author":"init","version":0},{"n":24,"text":"/** The file an export leaves in its folder: what it holds, and the sign that the folder is one export may replace. */","atom":"a0","author":"init","version":0},{"n":25,"text":"export const EXPORT_STAMP = \".abso-export\";","atom":"a250","author":"pinch","version":29},{"n":26,"text":"/** Its earlier names: an export made then still counts as one. A .json name drew the project's formatter. */","atom":"a250","author":"pinch","version":29},{"n":27,"text":"const OLD_EXPORT_STAMPS = [\".abso-export.json\", \".avcs-export.json\"];","atom":"a250","author":"pinch","version":29},{"n":28,"text":"","atom":"a0","author":"init","version":0},{"n":29,"text":"/** Where an export may go: outside the abso folder, or in a part of it abso leaves out. Empty, or an earlier export. */","atom":"a0","author":"init","version":0},{"n":30,"text":"function checkTarget(root: string, target: string): void {","atom":"a0","author":"init","version":0},{"n":31,"text":"\tconst inside = relativeTo(root, target);","atom":"a0","author":"init","version":0},{"n":32,"text":"\tif (inside === undefined && (target === root || relativeTo(target, root) !== undefined)) {","atom":"a0","author":"init","version":0},{"n":33,"text":"\t\tthrow new UsageError(`${target} holds this abso folder; export to a folder of its own`);","atom":"a0","author":"init","version":0},{"n":34,"text":"\t}","atom":"a0","author":"init","version":0},{"n":35,"text":"\tif (inside !== undefined && !ignoredHere(loadIgnore(root), inside, true)) {","atom":"a0","author":"init","version":0},{"n":36,"text":"\t\tthrow new UsageError(","atom":"a0","author":"init","version":0},{"n":37,"text":"\t\t\t`${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`,","atom":"a204","author":"review","version":27},{"n":38,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":39,"text":"\t}","atom":"a0","author":"init","version":0},{"n":40,"text":"\tif (!existsSync(target)) return;","atom":"a0","author":"init","version":0},{"n":41,"text":"\tif (!statSync(target).isDirectory()) throw new UsageError(`${target} is a file; export to a folder`);","atom":"a0","author":"init","version":0},{"n":42,"text":"\tif (","atom":"a204","author":"review","version":27},{"n":43,"text":"\t\treaddirSync(target).length > 0 &&","atom":"a204","author":"review","version":27},{"n":44,"text":"\t\t![EXPORT_STAMP, ...OLD_EXPORT_STAMPS].some((n) => existsSync(join(target, n)))","atom":"a250","author":"pinch","version":29},{"n":45,"text":"\t) {","atom":"a204","author":"review","version":27},{"n":46,"text":"\t\tthrow new UsageError(","atom":"a0","author":"init","version":0},{"n":47,"text":"\t\t\t`${target} has files in it; export to an empty folder (an export replaces only a folder an earlier export made)`,","atom":"a0","author":"init","version":0},{"n":48,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":49,"text":"\t}","atom":"a0","author":"init","version":0},{"n":50,"text":"}","atom":"a0","author":"init","version":0},{"n":51,"text":"","atom":"a0","author":"init","version":0},{"n":52,"text":"/**","atom":"a0","author":"init","version":0},{"n":53,"text":" * Empties an earlier export for the next, except what `keep` names: node_modules","atom":"a0","author":"init","version":0},{"n":54,"text":" * always (abso never exports it, and an install takes a while), and --keep's","atom":"a0","author":"init","version":0},{"n":55,"text":" * globs. Returns the kept paths, the top-most of each.","atom":"a0","author":"init","version":0},{"n":56,"text":" */","atom":"a0","author":"init","version":0},{"n":57,"text":"function clearExport(dir: string, keep: (rel: string) => boolean, rel = \"\"): string[] {","atom":"a0","author":"init","version":0},{"n":58,"text":"\tconst kept: string[] = [];","atom":"a0","author":"init","version":0},{"n":59,"text":"\tfor (const e of readdirSync(join(dir, ...rel.split(\"/\").filter(Boolean)), { withFileTypes: true })) {","atom":"a0","author":"init","version":0},{"n":60,"text":"\t\tconst path = rel === \"\" ? e.name : `${rel}/${e.name}`;","atom":"a0","author":"init","version":0},{"n":61,"text":"\t\tconst full = join(dir, ...path.split(\"/\"));","atom":"a0","author":"init","version":0},{"n":62,"text":"\t\tif (e.name === \"node_modules\" || keep(path)) {","atom":"a0","author":"init","version":0},{"n":63,"text":"\t\t\tkept.push(path);","atom":"a0","author":"init","version":0},{"n":64,"text":"\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":65,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":66,"text":"\t\tif (e.isDirectory() && !e.isSymbolicLink()) {","atom":"a0","author":"init","version":0},{"n":67,"text":"\t\t\tconst inner = clearExport(dir, keep, path);","atom":"a0","author":"init","version":0},{"n":68,"text":"\t\t\tkept.push(...inner);","atom":"a0","author":"init","version":0},{"n":69,"text":"\t\t\tif (inner.length > 0) continue;","atom":"a0","author":"init","version":0},{"n":70,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":71,"text":"\t\trmSync(full, { recursive: true, force: true });","atom":"a0","author":"init","version":0},{"n":72,"text":"\t}","atom":"a0","author":"init","version":0},{"n":73,"text":"\treturn kept;","atom":"a0","author":"init","version":0},{"n":74,"text":"}","atom":"a0","author":"init","version":0},{"n":75,"text":"","atom":"a0","author":"init","version":0},{"n":76,"text":"export async function runExport(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":77,"text":"\tif (args.positionals.length !== 1)","atom":"a0","author":"init","version":0},{"n":78,"text":"\t\tthrow new UsageError(\"export takes the folder to write: abso export <dir> [--version <N>]\");","atom":"a0","author":"init","version":0},{"n":79,"text":"\tconst { root, config, api } = open(env);","atom":"a0","author":"init","version":0},{"n":80,"text":"\tconst target = resolve(env.cwd, args.positionals[0]!);","atom":"a0","author":"init","version":0},{"n":81,"text":"\tcheckTarget(root, target);","atom":"a0","author":"init","version":0},{"n":82,"text":"\tconst rawVersion = str(args, \"version\");","atom":"a0","author":"init","version":0},{"n":83,"text":"\tif (rawVersion !== undefined && !/^\\d+$/.test(rawVersion))","atom":"a0","author":"init","version":0},{"n":84,"text":"\t\tthrow new UsageError(`--version is a version number (got ${JSON.stringify(rawVersion)})`);","atom":"a0","author":"init","version":0},{"n":85,"text":"\tconst leave = withoutArg(args);","atom":"a2093","author":"candidates","version":186},{"n":86,"text":"\tconst diff = await api.diff();","atom":"a0","author":"init","version":0},{"n":87,"text":"\tconst where: Where = { draft: diff.draft };","atom":"a0","author":"init","version":0},{"n":88,"text":"\tif (leave !== undefined && diff.draft !== null)","atom":"a2093","author":"candidates","version":186},{"n":89,"text":"\t\tthrow new UsageError(`--without reads shared, and this folder is on draft ${diff.draft}`);","atom":"a2093","author":"candidates","version":186},{"n":90,"text":"\t// The listing names the version (the newest by default) and every file it holds; a server from before it answers 404.","atom":"a0","author":"init","version":0},{"n":91,"text":"\tconst listing = await api","atom":"a0","author":"init","version":0},{"n":92,"text":"\t\t.filesAt(diff.draft, rawVersion === undefined ? undefined : Number(rawVersion))","atom":"a0","author":"init","version":0},{"n":93,"text":"\t\t.catch(() => undefined);","atom":"a0","author":"init","version":0},{"n":94,"text":"\tconst version =","atom":"a0","author":"init","version":0},{"n":95,"text":"\t\trawVersion !== undefined ? Number(rawVersion) : (listing?.version ?? (await api.log(where, 1)).version);","atom":"a0","author":"init","version":0},{"n":96,"text":"\tconst snap = await snapshotAt(root, api, version);","atom":"a0","author":"init","version":0},{"n":97,"text":"\tconst skipped: Refused[] = [];","atom":"a0","author":"init","version":0},{"n":98,"text":"\tif (listing !== undefined) {","atom":"a0","author":"init","version":0},{"n":99,"text":"\t\tconst holds = new Set(listing.files);","atom":"a0","author":"init","version":0},{"n":100,"text":"\t\tfor (const rel of [...snap.files.keys()]) if (!holds.has(rel)) snap.files.delete(rel);","atom":"a0","author":"init","version":0},{"n":101,"text":"\t\t// Files the known copies lack (a folder that missed some, #37): asked for one by one.","atom":"a0","author":"init","version":0},{"n":102,"text":"\t\tfor (const rel of listing.files) {","atom":"a0","author":"init","version":0},{"n":103,"text":"\t\t\tif (snap.files.has(rel)) continue;","atom":"a0","author":"init","version":0},{"n":104,"text":"\t\t\tconst file = await api.fileAt(rel, version, where);","atom":"a0","author":"init","version":0},{"n":105,"text":"\t\t\tif (file.text !== null) snap.files.set(rel, { text: file.text });","atom":"a0","author":"init","version":0},{"n":106,"text":"\t\t\telse","atom":"a0","author":"init","version":0},{"n":107,"text":"\t\t\t\tskipped.push({","atom":"a0","author":"init","version":0},{"n":108,"text":"\t\t\t\t\tpath: rel,","atom":"a0","author":"init","version":0},{"n":109,"text":"\t\t\t\t\twhy: \"a binary file this folder has no copy of; abso pull --full, then export again\",","atom":"a841","author":"rename","version":100},{"n":110,"text":"\t\t\t\t});","atom":"a0","author":"init","version":0},{"n":111,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":112,"text":"\t}","atom":"a0","author":"init","version":0},{"n":113,"text":"\t// Without some versions: the server says what differs from this version, as it is without them.","atom":"a2093","author":"candidates","version":186},{"n":114,"text":"\tconst without = leave === undefined ? undefined : await api.without(version, leave);","atom":"a2093","author":"candidates","version":186},{"n":115,"text":"\tif (without !== undefined && !without.ok)","atom":"a2093","author":"candidates","version":186},{"n":116,"text":"\t\treturn {","atom":"a2093","author":"candidates","version":186},{"n":117,"text":"\t\t\texit: EXIT.refused,","atom":"a2093","author":"candidates","version":186},{"n":118,"text":"\t\t\ttext: refusalText(","atom":"a2093","author":"candidates","version":186},{"n":119,"text":"\t\t\t\twithout,","atom":"a2093","author":"candidates","version":186},{"n":120,"text":"\t\t\t\t(vs) => `abso export ${args.positionals[0]} --version ${version} --without ${vs.join(\",\")}`,","atom":"a2093","author":"candidates","version":186},{"n":121,"text":"\t\t\t),","atom":"a2093","author":"candidates","version":186},{"n":122,"text":"\t\t\tjson: { ...without },","atom":"a2093","author":"candidates","version":186},{"n":123,"text":"\t\t};","atom":"a2093","author":"candidates","version":186},{"n":124,"text":"\tif (without !== undefined) applySide(snap, without.files, \"after\");","atom":"a2093","author":"candidates","version":186},{"n":125,"text":"\tconst entries = await snapshotEntries(api, snap);","atom":"a0","author":"init","version":0},{"n":126,"text":"\t// Built before anything is removed, so a failed export leaves an earlier one whole.","atom":"a0","author":"init","version":0},{"n":127,"text":"\tconst keepGlob = str(args, \"keep\");","atom":"a0","author":"init","version":0},{"n":128,"text":"\tconst kept = existsSync(target) ? clearExport(target, keepGlob === undefined ? () => false : globTest(keepGlob)) : [];","atom":"a0","author":"init","version":0},{"n":129,"text":"\tmkdirSync(target, { recursive: true });","atom":"a0","author":"init","version":0},{"n":130,"text":"\tlet written = 0;","atom":"a0","author":"init","version":0},{"n":131,"text":"\tfor (const e of entries) {","atom":"a0","author":"init","version":0},{"n":132,"text":"\t\tconst why = unsafePath(e.path) ?? (e.link !== undefined ? \"it is a link; export makes none\" : undefined);","atom":"a0","author":"init","version":0},{"n":133,"text":"\t\tif (why !== undefined) {","atom":"a0","author":"init","version":0},{"n":134,"text":"\t\t\tskipped.push({ path: e.path, why });","atom":"a0","author":"init","version":0},{"n":135,"text":"\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":136,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":137,"text":"\t\tconst path = join(target, ...e.path.split(\"/\"));","atom":"a0","author":"init","version":0},{"n":138,"text":"\t\tmkdirSync(dirname(path), { recursive: true });","atom":"a0","author":"init","version":0},{"n":139,"text":"\t\twriteFileSync(path, e.data);","atom":"a0","author":"init","version":0},{"n":140,"text":"\t\tif (e.mode !== undefined) {","atom":"a0","author":"init","version":0},{"n":141,"text":"\t\t\ttry {","atom":"a0","author":"init","version":0},{"n":142,"text":"\t\t\t\tchmodSync(path, e.mode);","atom":"a0","author":"init","version":0},{"n":143,"text":"\t\t\t} catch {","atom":"a0","author":"init","version":0},{"n":144,"text":"\t\t\t\t// The bit is a convenience here.","atom":"a0","author":"init","version":0},{"n":145,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":146,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":147,"text":"\t\twritten++;","atom":"a0","author":"init","version":0},{"n":148,"text":"\t}","atom":"a0","author":"init","version":0},{"n":149,"text":"\tconst space = diff.draft === null ? \"shared\" : `draft ${diff.draft}`;","atom":"a0","author":"init","version":0},{"n":150,"text":"\tconst stamp = {","atom":"a0","author":"init","version":0},{"n":151,"text":"\t\tproject: config.project,","atom":"a0","author":"init","version":0},{"n":152,"text":"\t\tspace: diff.draft ?? \"shared\",","atom":"a0","author":"init","version":0},{"n":153,"text":"\t\tversion,","atom":"a0","author":"init","version":0},{"n":154,"text":"\t\t...(without !== undefined ? { without: without.without.map((w) => w.version), tree: without.tree } : {}),","atom":"a2093","author":"candidates","version":186},{"n":155,"text":"\t\tfiles: written,","atom":"a0","author":"init","version":0},{"n":156,"text":"\t\texportedAt: new Date().toISOString(),","atom":"a0","author":"init","version":0},{"n":157,"text":"\t};","atom":"a0","author":"init","version":0},{"n":158,"text":"\twriteFileSync(join(target, EXPORT_STAMP), `${JSON.stringify(stamp)}\\n`);","atom":"a251","author":"pinch","version":29},{"n":159,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":160,"text":"\t\ttext: [","atom":"a0","author":"init","version":0},{"n":161,"text":"\t\t\t`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.`,","atom":"a2093","author":"candidates","version":186},{"n":162,"text":"\t\t\t...(kept.length > 0 ? [`Kept from the earlier export: ${kept.join(\", \")}.`] : []),","atom":"a0","author":"init","version":0},{"n":163,"text":"\t\t\t...(skipped.length > 0","atom":"a0","author":"init","version":0},{"n":164,"text":"\t\t\t\t? [`Not exported (${skipped.length}):`, ...skipped.map((s) => `  ${s.path}: ${s.why}`)]","atom":"a0","author":"init","version":0},{"n":165,"text":"\t\t\t\t: []),","atom":"a0","author":"init","version":0},{"n":166,"text":"\t\t].join(\"\\n\"),","atom":"a0","author":"init","version":0},{"n":167,"text":"\t\tjson: { ...stamp, dir: target, kept, skipped },","atom":"a0","author":"init","version":0},{"n":168,"text":"\t};","atom":"a0","author":"init","version":0},{"n":169,"text":"}","atom":"a0","author":"init","version":0}],"atoms":[{"atom":"a0","author":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z","publish":{"draft":null,"version":0,"agent":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z"}},{"atom":"a204","author":"review","message":"","time":1791533506483,"timeIso":"2026-10-09T08:11:46.483Z","publish":{"draft":null,"version":27,"agent":"review","message":"Client: ABSO_ environment names (AVCS_ still read), .absoignore (.avcsignore still read), .abso-export.json, shot files; READMEs say abso (abso 224)","time":1791533840174,"timeIso":"2026-10-09T08:17:20.174Z"}},{"atom":"a250","author":"pinch","message":"","time":1791539664482,"timeIso":"2026-10-09T09:54:24.482Z","publish":{"draft":null,"version":29,"agent":"pinch","message":"Client: abso issue N --save-attachments <dir> saves each attachment on an issue and its comments once (an SVG's own file beside its drawing), outside the abso folder unless the place is ignored; MCP confines the folder like attach. abso export now stamps its folder with .abso-export, one line of JSON in a file with no extension, so the exported project's own formatter and linter pass it by; a folder stamped .abso-export.json or .avcs-export.json still counts as an export.","time":1791540340754,"timeIso":"2026-10-09T10:05:40.754Z"}},{"atom":"a251","author":"pinch","message":"","time":1791539666315,"timeIso":"2026-10-09T09:54:26.315Z","publish":{"draft":null,"version":29,"agent":"pinch","message":"Client: abso issue N --save-attachments <dir> saves each attachment on an issue and its comments once (an SVG's own file beside its drawing), outside the abso folder unless the place is ignored; MCP confines the folder like attach. abso export now stamps its folder with .abso-export, one line of JSON in a file with no extension, so the exported project's own formatter and linter pass it by; a folder stamped .abso-export.json or .avcs-export.json still counts as an export.","time":1791540340754,"timeIso":"2026-10-09T10:05:40.754Z"}},{"atom":"a386","author":"infra-split","message":"","time":1791548567277,"timeIso":"2026-10-09T12:22:47.277Z","publish":{"draft":null,"version":39,"agent":"infra-split","message":"More comments and test names give their reason without naming who raised it\n\nThe same cleanup as version 37, for notes it missed because they were wrapped or worded differently: \"(#37, Playtester 1)\" becomes \"(#37)\", \"(#39, agreed with Engine)\" becomes \"(#39)\", and a commit hash after a name goes with the name. Issue numbers stay. No behavior changes.","time":1791548569542,"timeIso":"2026-10-09T12:22:49.542Z"}},{"atom":"a841","author":"rename","message":"","time":1791659799126,"timeIso":"2026-10-10T19:16:39.126Z","publish":{"draft":null,"version":100,"agent":"rename","message":"abso publish is now abso push, abso sync is now abso pull (abso 427)\n\nCommands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; \"shared\" stays the noun (\"Pushed version N\"). No aliases, no notices. A queued push that was \"pulled\" is now \"turned back\", so pull means one thing.\n\npush -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch.\n\nKept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.","time":1791659833853,"timeIso":"2026-10-10T19:17:13.853Z"}},{"atom":"a2093","author":"candidates","message":"","time":1792003615465,"timeIso":"2026-10-14T18:46:55.465Z","publish":{"draft":null,"version":186,"agent":"candidates","message":"Read a version of shared without some earlier versions: abso show <N> --without A,B shows what differs and abso export <dir> --version N --without A,B writes the files. The server's GET without?version=&versions= checks the set left exactly as asked: when a version it keeps builds on one left out, it refuses with that chain, the files and the wider set that works, and never widens it. Atoms keep their ids and authors; shared and its log don't change; the same ask gives the same tree hash.","time":1792004002371,"timeIso":"2026-10-14T18:53:22.371Z"}}]}