{"file":"client/src/at.ts","version":318,"total":110,"from":1,"to":110,"lines":[{"n":1,"text":"// abso run --at <version> [--files <glob>]: run a past version of the","atom":"a0","author":"init","version":0},{"n":2,"text":"// folder's space, or old copies of a few files, in the box, without touching","atom":"a0","author":"init","version":0},{"n":3,"text":"// a file in the folder (Backtracker's bisect, #25). Swapping files in by hand","atom":"a0","author":"init","version":0},{"n":4,"text":"// let the edit hook record the old copies.","atom":"a0","author":"init","version":0},{"n":5,"text":"//","atom":"a0","author":"init","version":0},{"n":6,"text":"// The version is rebuilt from what the client already knows, in two calls:","atom":"a0","author":"init","version":0},{"n":7,"text":"// the known copies are this agent's view (its base plus its recorded draft);","atom":"a0","author":"init","version":0},{"n":8,"text":"// its diff gives each drafted file as it was at the base; and compare(N, base)","atom":"a0","author":"init","version":0},{"n":9,"text":"// gives each file that differs between version N and the base, as it was at N.","atom":"a0","author":"init","version":0},{"n":10,"text":"","atom":"a0","author":"init","version":0},{"n":11,"text":"import type { Api, FileChange, Where } from \"./api.ts\";","atom":"a0","author":"init","version":0},{"n":12,"text":"import { UsageError } from \"./args.ts\";","atom":"a0","author":"init","version":0},{"n":13,"text":"import { readKnownBlobs } from \"./blobs.ts\";","atom":"a0","author":"init","version":0},{"n":14,"text":"import { isLocalOnly } from \"./core.ts\";","atom":"a0","author":"init","version":0},{"n":15,"text":"import { listKnown, readKnown } from \"./folder.ts\";","atom":"a0","author":"init","version":0},{"n":16,"text":"import { type FullMode, PLAIN, readKnownModes } from \"./modes.ts\";","atom":"a0","author":"init","version":0},{"n":17,"text":"import type { TarEntry } from \"./tar.ts\";","atom":"a0","author":"init","version":0},{"n":18,"text":"","atom":"a0","author":"init","version":0},{"n":19,"text":"/** One file of a version: its text, or its bytes by hash; and its mode. */","atom":"a0","author":"init","version":0},{"n":20,"text":"type Held = { readonly text: string } | { readonly blob: string };","atom":"a0","author":"init","version":0},{"n":21,"text":"","atom":"a0","author":"init","version":0},{"n":22,"text":"export interface Snapshot {","atom":"a0","author":"init","version":0},{"n":23,"text":"\treadonly version: number;","atom":"a0","author":"init","version":0},{"n":24,"text":"\treadonly files: Map<string, Held>;","atom":"a0","author":"init","version":0},{"n":25,"text":"\treadonly modes: Map<string, FullMode>;","atom":"a0","author":"init","version":0},{"n":26,"text":"}","atom":"a0","author":"init","version":0},{"n":27,"text":"","atom":"a0","author":"init","version":0},{"n":28,"text":"/** Each file as it is on one side of a change (`before` unless said), applied to the snapshot. */","atom":"a2091","author":"candidates","version":186},{"n":29,"text":"export function applySide(s: Snapshot, changes: readonly FileChange[], side: \"before\" | \"after\" = \"before\"): void {","atom":"a2091","author":"candidates","version":186},{"n":30,"text":"\tfor (const f of changes) {","atom":"a0","author":"init","version":0},{"n":31,"text":"\t\tif (isLocalOnly(f.path)) continue;","atom":"a0","author":"init","version":0},{"n":32,"text":"\t\tconst blob = f.blob?.[side] ?? null;","atom":"a2091","author":"candidates","version":186},{"n":33,"text":"\t\tconst text = f[side];","atom":"a2091","author":"candidates","version":186},{"n":34,"text":"\t\tif (blob !== null) s.files.set(f.path, { blob });","atom":"a0","author":"init","version":0},{"n":35,"text":"\t\telse if (text !== null) s.files.set(f.path, { text });","atom":"a2091","author":"candidates","version":186},{"n":36,"text":"\t\telse {","atom":"a0","author":"init","version":0},{"n":37,"text":"\t\t\ts.files.delete(f.path);","atom":"a0","author":"init","version":0},{"n":38,"text":"\t\t\ts.modes.delete(f.path);","atom":"a0","author":"init","version":0},{"n":39,"text":"\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":40,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":41,"text":"\t\tif (f.mode) s.modes.set(f.path, { exec: f.mode[side].exec === true, link: f.mode[side].link ?? null });","atom":"a2091","author":"candidates","version":186},{"n":42,"text":"\t}","atom":"a0","author":"init","version":0},{"n":43,"text":"}","atom":"a0","author":"init","version":0},{"n":44,"text":"","atom":"a0","author":"init","version":0},{"n":45,"text":"/** The folder's space as it was at `version`: every file, and its mode. */","atom":"a0","author":"init","version":0},{"n":46,"text":"export async function snapshotAt(root: string, api: Api, version: number): Promise<Snapshot> {","atom":"a0","author":"init","version":0},{"n":47,"text":"\tconst diff = await api.diff();","atom":"a0","author":"init","version":0},{"n":48,"text":"\tif (diff.base === null) throw new UsageError(\"this folder has no version yet: run abso pull first\");","atom":"a836","author":"rename","version":100},{"n":49,"text":"\tconst where: Where = { draft: diff.draft };","atom":"a0","author":"init","version":0},{"n":50,"text":"\t// This agent's view, from its known copies.","atom":"a0","author":"init","version":0},{"n":51,"text":"\tconst s: Snapshot = { version, files: new Map(), modes: new Map() };","atom":"a0","author":"init","version":0},{"n":52,"text":"\tfor (const rel of listKnown(root)) {","atom":"a0","author":"init","version":0},{"n":53,"text":"\t\tif (isLocalOnly(rel)) continue;","atom":"a0","author":"init","version":0},{"n":54,"text":"\t\tconst text = readKnown(root, rel);","atom":"a0","author":"init","version":0},{"n":55,"text":"\t\tif (text !== undefined) s.files.set(rel, { text });","atom":"a0","author":"init","version":0},{"n":56,"text":"\t}","atom":"a0","author":"init","version":0},{"n":57,"text":"\tfor (const [rel, sha] of readKnownBlobs(root)) s.files.set(rel, { blob: sha });","atom":"a0","author":"init","version":0},{"n":58,"text":"\tfor (const [rel, mode] of readKnownModes(root)) if (s.files.has(rel)) s.modes.set(rel, mode);","atom":"a0","author":"init","version":0},{"n":59,"text":"\t// Its base: the draft's changes taken back out.","atom":"a0","author":"init","version":0},{"n":60,"text":"\tapplySide(s, diff.files);","atom":"a2091","author":"candidates","version":186},{"n":61,"text":"\t// Version N: what differs from the base, as it was at N.","atom":"a0","author":"init","version":0},{"n":62,"text":"\tif (version !== diff.base) applySide(s, (await api.compare(version, diff.base, where)).files);","atom":"a2091","author":"candidates","version":186},{"n":63,"text":"\treturn s;","atom":"a0","author":"init","version":0},{"n":64,"text":"}","atom":"a0","author":"init","version":0},{"n":65,"text":"","atom":"a0","author":"init","version":0},{"n":66,"text":"/** A glob (or several, comma-separated) as a test on folder-relative paths. `**` crosses folders, `*` and `?` don't; a plain path matches itself and what is under it. */","atom":"a0","author":"init","version":0},{"n":67,"text":"export function globTest(globs: string): (rel: string) => boolean {","atom":"a0","author":"init","version":0},{"n":68,"text":"\tconst tests = globs","atom":"a0","author":"init","version":0},{"n":69,"text":"\t\t.split(\",\")","atom":"a0","author":"init","version":0},{"n":70,"text":"\t\t.map((g) => g.trim().replace(/\\\\/g, \"/\").replace(/^\\.\\//, \"\").replace(/\\/+$/, \"\"))","atom":"a0","author":"init","version":0},{"n":71,"text":"\t\t.filter((g) => g !== \"\")","atom":"a0","author":"init","version":0},{"n":72,"text":"\t\t.map((g) => {","atom":"a0","author":"init","version":0},{"n":73,"text":"\t\t\tif (!/[*?[]/.test(g)) return (rel: string) => rel === g || rel.startsWith(`${g}/`);","atom":"a0","author":"init","version":0},{"n":74,"text":"\t\t\tlet re = \"\";","atom":"a0","author":"init","version":0},{"n":75,"text":"\t\t\tfor (let i = 0; i < g.length; i++) {","atom":"a0","author":"init","version":0},{"n":76,"text":"\t\t\t\tconst c = g[i]!;","atom":"a0","author":"init","version":0},{"n":77,"text":"\t\t\t\tif (c === \"*\" && g[i + 1] === \"*\") {","atom":"a0","author":"init","version":0},{"n":78,"text":"\t\t\t\t\tre += g[i + 2] === \"/\" ? \"(?:.*/)?\" : \".*\";","atom":"a0","author":"init","version":0},{"n":79,"text":"\t\t\t\t\ti += g[i + 2] === \"/\" ? 2 : 1;","atom":"a0","author":"init","version":0},{"n":80,"text":"\t\t\t\t} else if (c === \"*\") re += \"[^/]*\";","atom":"a0","author":"init","version":0},{"n":81,"text":"\t\t\t\telse if (c === \"?\") re += \"[^/]\";","atom":"a0","author":"init","version":0},{"n":82,"text":"\t\t\t\telse re += c.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\");","atom":"a0","author":"init","version":0},{"n":83,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":84,"text":"\t\t\tconst r = new RegExp(`^${re}$`);","atom":"a0","author":"init","version":0},{"n":85,"text":"\t\t\treturn (rel: string) => r.test(rel);","atom":"a0","author":"init","version":0},{"n":86,"text":"\t\t});","atom":"a0","author":"init","version":0},{"n":87,"text":"\tif (tests.length === 0) throw new UsageError('--files needs a path or a glob, like --files \"src/*.ts\"');","atom":"a0","author":"init","version":0},{"n":88,"text":"\treturn (rel) => tests.some((t) => t(rel));","atom":"a0","author":"init","version":0},{"n":89,"text":"}","atom":"a0","author":"init","version":0},{"n":90,"text":"","atom":"a0","author":"init","version":0},{"n":91,"text":"/** The tar entries for a snapshot's files (all of them, or those `pick` takes), fetching blob bytes. */","atom":"a0","author":"init","version":0},{"n":92,"text":"export async function snapshotEntries(","atom":"a0","author":"init","version":0},{"n":93,"text":"\tapi: Api,","atom":"a0","author":"init","version":0},{"n":94,"text":"\ts: Snapshot,","atom":"a0","author":"init","version":0},{"n":95,"text":"\tpick: (rel: string) => boolean = () => true,","atom":"a0","author":"init","version":0},{"n":96,"text":"): Promise<TarEntry[]> {","atom":"a0","author":"init","version":0},{"n":97,"text":"\tconst out: TarEntry[] = [];","atom":"a0","author":"init","version":0},{"n":98,"text":"\tfor (const [rel, held] of [...s.files].sort(([a], [b]) => a.localeCompare(b))) {","atom":"a0","author":"init","version":0},{"n":99,"text":"\t\tif (!pick(rel)) continue;","atom":"a0","author":"init","version":0},{"n":100,"text":"\t\tconst mode = s.modes.get(rel) ?? PLAIN;","atom":"a0","author":"init","version":0},{"n":101,"text":"\t\tif (mode.link !== null) {","atom":"a0","author":"init","version":0},{"n":102,"text":"\t\t\tout.push({ path: rel, data: new Uint8Array(0), link: mode.link });","atom":"a0","author":"init","version":0},{"n":103,"text":"\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":104,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":105,"text":"\t\tconst data = \"blob\" in held ? await api.getBlob(held.blob) : new TextEncoder().encode(held.text);","atom":"a0","author":"init","version":0},{"n":106,"text":"\t\tconst script = data[0] === 0x23 && data[1] === 0x21;","atom":"a0","author":"init","version":0},{"n":107,"text":"\t\tout.push({ path: rel, data, ...(mode.exec || script ? { mode: 0o755 } : {}) });","atom":"a0","author":"init","version":0},{"n":108,"text":"\t}","atom":"a0","author":"init","version":0},{"n":109,"text":"\treturn out;","atom":"a0","author":"init","version":0},{"n":110,"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":"a836","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":"a2091","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"}}]}