{"file":"client/src/changes.ts","version":318,"total":657,"from":1,"to":657,"lines":[{"n":1,"text":"// abso diff, log, show and restore: the everyday commands of #27.","atom":"a0","author":"init","version":0},{"n":2,"text":"//","atom":"a0","author":"init","version":0},{"n":3,"text":"// diff and restore work on this agent's unpublished changes. log, show and","atom":"a0","author":"init","version":0},{"n":4,"text":"// diff between versions read the published versions of the space this folder","atom":"a0","author":"init","version":0},{"n":5,"text":"// is in (shared or a named draft) unless --draft names another.","atom":"a0","author":"init","version":0},{"n":6,"text":"","atom":"a0","author":"init","version":0},{"n":7,"text":"import { existsSync, statSync } from \"node:fs\";","atom":"a0","author":"init","version":0},{"n":8,"text":"import { relative, resolve } from \"node:path\";","atom":"a0","author":"init","version":0},{"n":9,"text":"import type { Api, FileChange, LogAnswer, LogEntry, Where } from \"./api.ts\";","atom":"a0","author":"init","version":0},{"n":10,"text":"import { bool, type Parsed, str, UsageError } from \"./args.ts\";","atom":"a0","author":"init","version":0},{"n":11,"text":"import { globTest } from \"./at.ts\";","atom":"a0","author":"init","version":0},{"n":12,"text":"import { readKnownBlobs, writeKnownBlobs } from \"./blobs.ts\";","atom":"a0","author":"init","version":0},{"n":13,"text":"import { ciMarkText } from \"./ci.ts\";","atom":"a0","author":"init","version":0},{"n":14,"text":"import { type Env, EXIT, missingHere, type Output, open, plural, recordedFirst, recordFolder } from \"./commands.ts\";","atom":"a0","author":"init","version":0},{"n":15,"text":"import { editScript, linesOf, normalize, withEndingsOf } from \"./core.ts\";","atom":"a0","author":"init","version":0},{"n":16,"text":"import { lineCounts, pairRenames, unifiedDiff } from \"./diff.ts\";","atom":"a0","author":"init","version":0},{"n":17,"text":"import {","atom":"a0","author":"init","version":0},{"n":18,"text":"\tabsolute,","atom":"a0","author":"init","version":0},{"n":19,"text":"\tforgetKnown,","atom":"a0","author":"init","version":0},{"n":20,"text":"\tnewFileEndings,","atom":"a0","author":"init","version":0},{"n":21,"text":"\treadText,","atom":"a0","author":"init","version":0},{"n":22,"text":"\tremoveFile,","atom":"a0","author":"init","version":0},{"n":23,"text":"\tunrecorded,","atom":"a0","author":"init","version":0},{"n":24,"text":"\twriteFileAtomic,","atom":"a0","author":"init","version":0},{"n":25,"text":"\twriteKnown,","atom":"a0","author":"init","version":0},{"n":26,"text":"} from \"./folder.ts\";","atom":"a0","author":"init","version":0},{"n":27,"text":"import { fileArg, when } from \"./history.ts\";","atom":"a0","author":"init","version":0},{"n":28,"text":"import { byWhom } from \"./history-answers.ts\";","atom":"a56","author":"engine","version":13},{"n":29,"text":"import { applyMode, PLAIN, readKnownModes, writeKnownModes } from \"./modes.ts\";","atom":"a0","author":"init","version":0},{"n":30,"text":"import { refusedText, screenAnswer } from \"./safety.ts\";","atom":"a0","author":"init","version":0},{"n":31,"text":"import { refusalText, withoutArg, withoutHeading } from \"./without.ts\";","atom":"a2092","author":"candidates","version":186},{"n":32,"text":"","atom":"a0","author":"init","version":0},{"n":33,"text":"/** The space to read: --draft (where \"shared\" means shared), else the one this agent is in (shared, in a folder with no agent). */","atom":"a765","author":"pinch","version":86},{"n":34,"text":"function space(args: Parsed, agent: string): Where {","atom":"a0","author":"init","version":0},{"n":35,"text":"\tconst named = str(args, \"draft\");","atom":"a0","author":"init","version":0},{"n":36,"text":"\tif (named === undefined) return agent === \"\" ? { draft: null } : { agent };","atom":"a765","author":"pinch","version":86},{"n":37,"text":"\treturn { draft: named === \"shared\" ? null : named };","atom":"a0","author":"init","version":0},{"n":38,"text":"}","atom":"a0","author":"init","version":0},{"n":39,"text":"","atom":"a0","author":"init","version":0},{"n":40,"text":"function spaceName(draft: string | null): string {","atom":"a0","author":"init","version":0},{"n":41,"text":"\treturn draft === null ? \"shared\" : `draft ${draft}`;","atom":"a0","author":"init","version":0},{"n":42,"text":"}","atom":"a0","author":"init","version":0},{"n":43,"text":"","atom":"a0","author":"init","version":0},{"n":44,"text":"/** How to name a space in a sentence when only the request says which it is. */","atom":"a0","author":"init","version":0},{"n":45,"text":"function whereName(where: Where): string {","atom":"a0","author":"init","version":0},{"n":46,"text":"\treturn \"agent\" in where ? \"your space\" : spaceName(where.draft);","atom":"a0","author":"init","version":0},{"n":47,"text":"}","atom":"a0","author":"init","version":0},{"n":48,"text":"","atom":"a0","author":"init","version":0},{"n":49,"text":"function version(raw: string, what = \"a version\"): number {","atom":"a0","author":"init","version":0},{"n":50,"text":"\tconst n = Number(raw);","atom":"a0","author":"init","version":0},{"n":51,"text":"\tif (!/^\\d+$/.test(raw) || !Number.isSafeInteger(n))","atom":"a0","author":"init","version":0},{"n":52,"text":"\t\tthrow new UsageError(`${what} is a version number (got ${JSON.stringify(raw)})`);","atom":"a0","author":"init","version":0},{"n":53,"text":"\treturn n;","atom":"a0","author":"init","version":0},{"n":54,"text":"}","atom":"a0","author":"init","version":0},{"n":55,"text":"","atom":"a0","author":"init","version":0},{"n":56,"text":"/**","atom":"a0","author":"init","version":0},{"n":57,"text":" * abso files [glob...] [--draft <name>] [--version N]: the files a view holds","atom":"a0","author":"init","version":0},{"n":58,"text":" * (#37). Without flags, this agent's view, what the folder should hold, with","atom":"a0","author":"init","version":0},{"n":59,"text":" * any the folder lacks marked; with --draft or --version, that space at that","atom":"a0","author":"init","version":0},{"n":60,"text":" * version as published.","atom":"a0","author":"init","version":0},{"n":61,"text":" */","atom":"a0","author":"init","version":0},{"n":62,"text":"export async function runFiles(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":63,"text":"\tconst { root, config, api } = open(env);","atom":"a0","author":"init","version":0},{"n":64,"text":"\tconst rawVersion = str(args, \"version\");","atom":"a0","author":"init","version":0},{"n":65,"text":"\tconst at = rawVersion === undefined ? undefined : version(rawVersion, \"--version\");","atom":"a0","author":"init","version":0},{"n":66,"text":"\tconst where = space(args, config.agent);","atom":"a0","author":"init","version":0},{"n":67,"text":"\tconst mine = \"agent\" in where && at === undefined;","atom":"a0","author":"init","version":0},{"n":68,"text":"\t// --version alone reads the space this agent is in, which only its view names.","atom":"a0","author":"init","version":0},{"n":69,"text":"\tconst answer = mine","atom":"a0","author":"init","version":0},{"n":70,"text":"\t\t? await api.viewFiles()","atom":"a0","author":"init","version":0},{"n":71,"text":"\t\t: await api.filesAt(\"agent\" in where ? (await api.viewFiles()).draft : where.draft, at);","atom":"a0","author":"init","version":0},{"n":72,"text":"\tconst match = args.positionals.length === 0 ? () => true : globTest(args.positionals.join(\",\"));","atom":"a0","author":"init","version":0},{"n":73,"text":"\tconst files = answer.files.filter((f) => match(f));","atom":"a0","author":"init","version":0},{"n":74,"text":"\tconst pending = mine ? unrecorded(root) : undefined;","atom":"a0","author":"init","version":0},{"n":75,"text":"\tconst missing = new Set(","atom":"a0","author":"init","version":0},{"n":76,"text":"\t\tpending","atom":"a0","author":"init","version":0},{"n":77,"text":"\t\t\t? missingHere(","atom":"a0","author":"init","version":0},{"n":78,"text":"\t\t\t\t\troot,","atom":"a0","author":"init","version":0},{"n":79,"text":"\t\t\t\t\tfiles,","atom":"a0","author":"init","version":0},{"n":80,"text":"\t\t\t\t\tnew Set([...pending.files.keys(), ...pending.blobs.keys(), ...Object.keys(pending.modes)]),","atom":"a0","author":"init","version":0},{"n":81,"text":"\t\t\t\t)","atom":"a0","author":"init","version":0},{"n":82,"text":"\t\t\t: [],","atom":"a0","author":"init","version":0},{"n":83,"text":"\t);","atom":"a0","author":"init","version":0},{"n":84,"text":"\tconst what =","atom":"a0","author":"init","version":0},{"n":85,"text":"\t\targs.positionals.length === 0","atom":"a0","author":"init","version":0},{"n":86,"text":"\t\t\t? plural(files.length, \"file\")","atom":"a0","author":"init","version":0},{"n":87,"text":"\t\t\t: `${plural(files.length, \"file\")} matching ${args.positionals.join(\", \")}`;","atom":"a0","author":"init","version":0},{"n":88,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":89,"text":"\t\ttext: [","atom":"a0","author":"init","version":0},{"n":90,"text":"\t\t\tmine","atom":"a0","author":"init","version":0},{"n":91,"text":"\t\t\t\t? `Your view holds ${what}: ${spaceName(answer.draft)} at version ${answer.version}, with your unpushed changes.${missing.size > 0 ? ` ${missing.size} of them ${missing.size === 1 ? \"is\" : \"are\"} missing from this folder (abso pull --full writes them).` : \"\"}`","atom":"a837","author":"rename","version":100},{"n":92,"text":"\t\t\t\t: `${spaceName(answer.draft)} at version ${answer.version} holds ${what}.`,","atom":"a0","author":"init","version":0},{"n":93,"text":"\t\t\t...files.map((f) => (missing.has(f) ? `${f}  (missing from this folder)` : f)),","atom":"a0","author":"init","version":0},{"n":94,"text":"\t\t].join(\"\\n\"),","atom":"a0","author":"init","version":0},{"n":95,"text":"\t\tjson: { version: answer.version, draft: answer.draft, files, ...(mine ? { missing: [...missing] } : {}) },","atom":"a0","author":"init","version":0},{"n":96,"text":"\t};","atom":"a0","author":"init","version":0},{"n":97,"text":"}","atom":"a0","author":"init","version":0},{"n":98,"text":"","atom":"a0","author":"init","version":0},{"n":99,"text":"/** The diffs, and a JSON form that carries each file's diff text and line counts. */","atom":"a0","author":"init","version":0},{"n":100,"text":"function diffs(files: readonly FileChange[]): { text: string[]; json: unknown[] } {","atom":"a0","author":"init","version":0},{"n":101,"text":"\tconst text: string[] = [];","atom":"a0","author":"init","version":0},{"n":102,"text":"\tconst json: unknown[] = [];","atom":"a0","author":"init","version":0},{"n":103,"text":"\tfor (const f of files) {","atom":"a0","author":"init","version":0},{"n":104,"text":"\t\tconst diff = unifiedDiff(f);","atom":"a0","author":"init","version":0},{"n":105,"text":"\t\ttext.push(diff);","atom":"a0","author":"init","version":0},{"n":106,"text":"\t\tjson.push({ ...f, ...lineCounts(f), diff });","atom":"a0","author":"init","version":0},{"n":107,"text":"\t}","atom":"a0","author":"init","version":0},{"n":108,"text":"\treturn { text, json };","atom":"a0","author":"init","version":0},{"n":109,"text":"}","atom":"a0","author":"init","version":0},{"n":110,"text":"","atom":"a0","author":"init","version":0},{"n":111,"text":"function totals(files: readonly FileChange[]): string {","atom":"a0","author":"init","version":0},{"n":112,"text":"\tlet added = 0;","atom":"a0","author":"init","version":0},{"n":113,"text":"\tlet removed = 0;","atom":"a0","author":"init","version":0},{"n":114,"text":"\tfor (const f of files) {","atom":"a0","author":"init","version":0},{"n":115,"text":"\t\tconst c = lineCounts(f);","atom":"a0","author":"init","version":0},{"n":116,"text":"\t\tadded += c.added;","atom":"a0","author":"init","version":0},{"n":117,"text":"\t\tremoved += c.removed;","atom":"a0","author":"init","version":0},{"n":118,"text":"\t}","atom":"a0","author":"init","version":0},{"n":119,"text":"\tconst renamed = files.filter((f) => f.from !== undefined).length;","atom":"a0","author":"init","version":0},{"n":120,"text":"\treturn `${plural(files.length, \"file\")}${renamed > 0 ? ` (${renamed} renamed)` : \"\"}, ${plural(added, \"line\")} added, ${removed} removed`;","atom":"a0","author":"init","version":0},{"n":121,"text":"}","atom":"a0","author":"init","version":0},{"n":122,"text":"","atom":"a0","author":"init","version":0},{"n":123,"text":"/** Whether a change is to `p` (a file or a folder): a renamed file counts under its old path and its new one. */","atom":"a0","author":"init","version":0},{"n":124,"text":"function touches(f: FileChange, p: string): boolean {","atom":"a0","author":"init","version":0},{"n":125,"text":"\treturn under(f.path, p) || (f.from !== undefined && under(f.from, p));","atom":"a0","author":"init","version":0},{"n":126,"text":"}","atom":"a0","author":"init","version":0},{"n":127,"text":"","atom":"a0","author":"init","version":0},{"n":128,"text":"export async function runDiff(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":129,"text":"\tconst { root, config, api } = open(env);","atom":"a0","author":"init","version":0},{"n":130,"text":"\tconst words = args.positionals;","atom":"a0","author":"init","version":0},{"n":131,"text":"\tconst between = words.length >= 2 && /^\\d+$/.test(words[0]!) && /^\\d+$/.test(words[1]!);","atom":"a0","author":"init","version":0},{"n":132,"text":"\tconst only = (between ? words.slice(2) : words).map((w) => pathArg(root, env.cwd, w));","atom":"a0","author":"init","version":0},{"n":133,"text":"\t// Renames are paired over every file first, so a path picks the whole rename.","atom":"a0","author":"init","version":0},{"n":134,"text":"\tconst pick = (files: readonly FileChange[]) => {","atom":"a0","author":"init","version":0},{"n":135,"text":"\t\tconst all = pairRenames(files);","atom":"a0","author":"init","version":0},{"n":136,"text":"\t\treturn only.length === 0 ? all : all.filter((f) => only.some((p) => touches(f, p)));","atom":"a0","author":"init","version":0},{"n":137,"text":"\t};","atom":"a0","author":"init","version":0},{"n":138,"text":"\t// Each path that matched nothing gets a line of its own, saying whether it is even there.","atom":"a0","author":"init","version":0},{"n":139,"text":"\tconst unmatched = (files: readonly FileChange[]) => only.filter((p) => !files.some((f) => touches(f, p)));","atom":"a0","author":"init","version":0},{"n":140,"text":"\tconst notes = (files: readonly FileChange[]) =>","atom":"a0","author":"init","version":0},{"n":141,"text":"\t\tunmatched(files)","atom":"a0","author":"init","version":0},{"n":142,"text":"\t\t\t.filter((p) => only.length > 1 || !existsHere(root, p))","atom":"a0","author":"init","version":0},{"n":143,"text":"\t\t\t.map((p) => nothingAt(root, p));","atom":"a0","author":"init","version":0},{"n":144,"text":"","atom":"a0","author":"init","version":0},{"n":145,"text":"\t// --agent: someone else's draft, to review it. What they've recorded, not their folder; nothing here is recorded.","atom":"a471","author":"pinch","version":52},{"n":146,"text":"\tconst other = str(args, \"agent\");","atom":"a471","author":"pinch","version":52},{"n":147,"text":"\tif (other !== undefined) {","atom":"a471","author":"pinch","version":52},{"n":148,"text":"\t\tif (between || str(args, \"draft\") !== undefined)","atom":"a471","author":"pinch","version":52},{"n":149,"text":"\t\t\tthrow new UsageError(\"--agent shows that agent's unpushed changes: abso diff [file...] --agent <name>\");","atom":"a837","author":"rename","version":100},{"n":150,"text":"\t\tconst answer = await api.diffOf(other);","atom":"a471","author":"pinch","version":52},{"n":151,"text":"\t\tconst files = pick(answer.files);","atom":"a471","author":"pinch","version":52},{"n":152,"text":"\t\tconst d = diffs(files);","atom":"a471","author":"pinch","version":52},{"n":153,"text":"\t\tconst where = `${spaceName(answer.draft)}${answer.base === null ? \"\" : ` (on version ${answer.base})`}`;","atom":"a471","author":"pinch","version":52},{"n":154,"text":"\t\tconst head =","atom":"a471","author":"pinch","version":52},{"n":155,"text":"\t\t\tfiles.length === 0","atom":"a471","author":"pinch","version":52},{"n":156,"text":"\t\t\t\t? `${other} has no recorded, unpushed changes${inPaths(only, \"to\")} in ${where}.`","atom":"a837","author":"rename","version":100},{"n":157,"text":"\t\t\t\t: `${other}'s recorded, unpushed changes${inPaths(only, \"to\")} in ${where}: ${totals(files)}.`;","atom":"a837","author":"rename","version":100},{"n":158,"text":"\t\treturn {","atom":"a471","author":"pinch","version":52},{"n":159,"text":"\t\t\ttext: [head, ...d.text].join(\"\\n\"),","atom":"a471","author":"pinch","version":52},{"n":160,"text":"\t\t\tjson: { agent: other, draft: answer.draft, base: answer.base, files: d.json, unmatched: unmatched(files) },","atom":"a471","author":"pinch","version":52},{"n":161,"text":"\t\t};","atom":"a471","author":"pinch","version":52},{"n":162,"text":"\t}","atom":"a471","author":"pinch","version":52},{"n":163,"text":"","atom":"a471","author":"pinch","version":52},{"n":164,"text":"\tif (between) {","atom":"a0","author":"init","version":0},{"n":165,"text":"\t\tconst from = version(words[0]!);","atom":"a0","author":"init","version":0},{"n":166,"text":"\t\tconst to = version(words[1]!);","atom":"a0","author":"init","version":0},{"n":167,"text":"\t\tconst where = space(args, config.agent);","atom":"a0","author":"init","version":0},{"n":168,"text":"\t\tconst answer = await api.compare(from, to, where);","atom":"a0","author":"init","version":0},{"n":169,"text":"\t\tconst files = pick(answer.files);","atom":"a0","author":"init","version":0},{"n":170,"text":"\t\tconst d = diffs(files);","atom":"a0","author":"init","version":0},{"n":171,"text":"\t\tconst head =","atom":"a0","author":"init","version":0},{"n":172,"text":"\t\t\tfiles.length === 0","atom":"a0","author":"init","version":0},{"n":173,"text":"\t\t\t\t? `No differences between versions ${from} and ${to} of ${whereName(where)}${inPaths(only)}.`","atom":"a0","author":"init","version":0},{"n":174,"text":"\t\t\t\t: `From version ${from} to ${to} of ${whereName(where)}${inPaths(only)}: ${totals(files)}.`;","atom":"a0","author":"init","version":0},{"n":175,"text":"\t\treturn {","atom":"a0","author":"init","version":0},{"n":176,"text":"\t\t\ttext: [head, ...notes(files), ...d.text].join(\"\\n\"),","atom":"a0","author":"init","version":0},{"n":177,"text":"\t\t\tjson: { ...where, from, to, files: d.json, unmatched: unmatched(files) },","atom":"a0","author":"init","version":0},{"n":178,"text":"\t\t};","atom":"a0","author":"init","version":0},{"n":179,"text":"\t}","atom":"a0","author":"init","version":0},{"n":180,"text":"","atom":"a0","author":"init","version":0},{"n":181,"text":"\tif (str(args, \"draft\") !== undefined)","atom":"a0","author":"init","version":0},{"n":182,"text":"\t\tthrow new UsageError(","atom":"a0","author":"init","version":0},{"n":183,"text":"\t\t\t\"--draft goes with two versions (abso diff <from> <to>); abso diff alone shows your own unpushed changes\",","atom":"a837","author":"rename","version":100},{"n":184,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":185,"text":"\t// Folder-only edits count as unpublished changes too.","atom":"a0","author":"init","version":0},{"n":186,"text":"\tconst recorded = await recordFolder(root, api);","atom":"a0","author":"init","version":0},{"n":187,"text":"\tconst answer = await api.diff();","atom":"a0","author":"init","version":0},{"n":188,"text":"\tconst files = pick(answer.files);","atom":"a0","author":"init","version":0},{"n":189,"text":"\tconst d = diffs(files);","atom":"a0","author":"init","version":0},{"n":190,"text":"\tconst where = `${spaceName(answer.draft)}${answer.base === null ? \"\" : ` (on version ${answer.base})`}`;","atom":"a0","author":"init","version":0},{"n":191,"text":"\tconst head =","atom":"a0","author":"init","version":0},{"n":192,"text":"\t\tfiles.length === 0","atom":"a0","author":"init","version":0},{"n":193,"text":"\t\t\t? `No unpushed changes${inPaths(only, \"to\")} in ${where}.`","atom":"a837","author":"rename","version":100},{"n":194,"text":"\t\t\t: `Your unpushed changes${inPaths(only, \"to\")} in ${where}: ${totals(files)}.`;","atom":"a837","author":"rename","version":100},{"n":195,"text":"\tconst pre = recordedFirst(recorded);","atom":"a0","author":"init","version":0},{"n":196,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":197,"text":"\t\ttext: [...pre, head, ...notes(files), ...d.text].join(\"\\n\"),","atom":"a0","author":"init","version":0},{"n":198,"text":"\t\tjson: {","atom":"a0","author":"init","version":0},{"n":199,"text":"\t\t\tdraft: answer.draft,","atom":"a0","author":"init","version":0},{"n":200,"text":"\t\t\tbase: answer.base,","atom":"a0","author":"init","version":0},{"n":201,"text":"\t\t\tfiles: d.json,","atom":"a0","author":"init","version":0},{"n":202,"text":"\t\t\trecorded: recorded.sent,","atom":"a0","author":"init","version":0},{"n":203,"text":"\t\t\tunmatched: unmatched(files),","atom":"a0","author":"init","version":0},{"n":204,"text":"\t\t},","atom":"a0","author":"init","version":0},{"n":205,"text":"\t};","atom":"a0","author":"init","version":0},{"n":206,"text":"}","atom":"a0","author":"init","version":0},{"n":207,"text":"","atom":"a0","author":"init","version":0},{"n":208,"text":"const LOG_FILES = 8;","atom":"a0","author":"init","version":0},{"n":209,"text":"/** How far back `abso log <folder>` looks, since the client filters it. */","atom":"a0","author":"init","version":0},{"n":210,"text":"const FOLDER_LOG = 1000;","atom":"a0","author":"init","version":0},{"n":211,"text":"","atom":"a0","author":"init","version":0},{"n":212,"text":"/** A path as typed, folder-relative: \"\" for the whole folder. A folder stands for every file under it. */","atom":"a0","author":"init","version":0},{"n":213,"text":"function pathArg(root: string, cwd: string, typed: string): string {","atom":"a0","author":"init","version":0},{"n":214,"text":"\tif (relative(root, resolve(cwd, typed)) === \"\") return \"\";","atom":"a0","author":"init","version":0},{"n":215,"text":"\treturn fileArg(root, cwd, typed);","atom":"a0","author":"init","version":0},{"n":216,"text":"}","atom":"a0","author":"init","version":0},{"n":217,"text":"","atom":"a0","author":"init","version":0},{"n":218,"text":"/** Whether `path` is `p`, or under the folder `p` (\"\" is everything). */","atom":"a0","author":"init","version":0},{"n":219,"text":"function under(path: string, p: string): boolean {","atom":"a0","author":"init","version":0},{"n":220,"text":"\treturn p === \"\" || path === p || path.startsWith(`${p}/`);","atom":"a0","author":"init","version":0},{"n":221,"text":"}","atom":"a0","author":"init","version":0},{"n":222,"text":"","atom":"a0","author":"init","version":0},{"n":223,"text":"function isFolder(root: string, p: string): boolean {","atom":"a0","author":"init","version":0},{"n":224,"text":"\ttry {","atom":"a0","author":"init","version":0},{"n":225,"text":"\t\treturn statSync(absolute(root, p)).isDirectory();","atom":"a0","author":"init","version":0},{"n":226,"text":"\t} catch {","atom":"a0","author":"init","version":0},{"n":227,"text":"\t\treturn false;","atom":"a0","author":"init","version":0},{"n":228,"text":"\t}","atom":"a0","author":"init","version":0},{"n":229,"text":"}","atom":"a0","author":"init","version":0},{"n":230,"text":"","atom":"a0","author":"init","version":0},{"n":231,"text":"function existsHere(root: string, p: string): boolean {","atom":"a0","author":"init","version":0},{"n":232,"text":"\treturn p === \"\" || existsSync(absolute(root, p));","atom":"a0","author":"init","version":0},{"n":233,"text":"}","atom":"a0","author":"init","version":0},{"n":234,"text":"","atom":"a0","author":"init","version":0},{"n":235,"text":"/** The line for a path that matched no changed file. */","atom":"a0","author":"init","version":0},{"n":236,"text":"function nothingAt(root: string, p: string): string {","atom":"a0","author":"init","version":0},{"n":237,"text":"\tif (!existsHere(root, p))","atom":"a0","author":"init","version":0},{"n":238,"text":"\t\treturn `  ${p}: no such file or folder here now (paths are relative to where you run abso).`;","atom":"a77","author":"review","version":16},{"n":239,"text":"\treturn `  ${p === \"\" ? \"the whole folder\" : `${p}${isFolder(root, p) ? \"/\" : \"\"}`}: no changes there.`;","atom":"a0","author":"init","version":0},{"n":240,"text":"}","atom":"a0","author":"init","version":0},{"n":241,"text":"","atom":"a0","author":"init","version":0},{"n":242,"text":"/** \" in a.ts, harness\" (or \" to ...\") for the paths a command was limited to. */","atom":"a0","author":"init","version":0},{"n":243,"text":"function inPaths(only: readonly string[], word = \"in\"): string {","atom":"a0","author":"init","version":0},{"n":244,"text":"\treturn only.length === 0 ? \"\" : ` ${word} ${only.map((p) => (p === \"\" ? \"the whole folder\" : p)).join(\", \")}`;","atom":"a0","author":"init","version":0},{"n":245,"text":"}","atom":"a0","author":"init","version":0},{"n":246,"text":"","atom":"a0","author":"init","version":0},{"n":247,"text":"/** How many renames `abso log <file>` follows back. */","atom":"a0","author":"init","version":0},{"n":248,"text":"const FOLLOW_RENAMES = 20;","atom":"a0","author":"init","version":0},{"n":249,"text":"","atom":"a0","author":"init","version":0},{"n":250,"text":"type FollowedEntry = LogEntry & { readonly renamedFrom?: string };","atom":"a0","author":"init","version":0},{"n":251,"text":"","atom":"a0","author":"init","version":0},{"n":252,"text":"/**","atom":"a0","author":"init","version":0},{"n":253,"text":" * A file's log that goes on past a rename, like `git log --follow`: where the","atom":"a0","author":"init","version":0},{"n":254,"text":" * oldest version found is the one that renamed the file into being, the","atom":"a0","author":"init","version":0},{"n":255,"text":" * versions before it come from the old path's log.","atom":"a0","author":"init","version":0},{"n":256,"text":" */","atom":"a0","author":"init","version":0},{"n":257,"text":"async function followRenames(","atom":"a0","author":"init","version":0},{"n":258,"text":"\tapi: Api,","atom":"a0","author":"init","version":0},{"n":259,"text":"\twhere: Where,","atom":"a0","author":"init","version":0},{"n":260,"text":"\tpath: string,","atom":"a0","author":"init","version":0},{"n":261,"text":"\tfirst: LogAnswer,","atom":"a0","author":"init","version":0},{"n":262,"text":"\tlimit: number | undefined,","atom":"a0","author":"init","version":0},{"n":263,"text":"): Promise<FollowedEntry[]> {","atom":"a0","author":"init","version":0},{"n":264,"text":"\tconst versions: FollowedEntry[] = [...first.versions];","atom":"a0","author":"init","version":0},{"n":265,"text":"\tlet current = path;","atom":"a0","author":"init","version":0},{"n":266,"text":"\tfor (let hops = 0; hops < FOLLOW_RENAMES; hops++) {","atom":"a0","author":"init","version":0},{"n":267,"text":"\t\tif (limit !== undefined && versions.length >= limit) break;","atom":"a0","author":"init","version":0},{"n":268,"text":"\t\tconst oldest = versions[versions.length - 1];","atom":"a0","author":"init","version":0},{"n":269,"text":"\t\tif (oldest === undefined || oldest.version === 0) break;","atom":"a0","author":"init","version":0},{"n":270,"text":"\t\tconst renamed = pairRenames((await api.show(oldest.version, where)).diff).find(","atom":"a0","author":"init","version":0},{"n":271,"text":"\t\t\t(f) => f.path === current && f.from !== undefined,","atom":"a0","author":"init","version":0},{"n":272,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":273,"text":"\t\tif (renamed === undefined) break;","atom":"a0","author":"init","version":0},{"n":274,"text":"\t\tversions[versions.length - 1] = { ...oldest, renamedFrom: renamed.from! };","atom":"a0","author":"init","version":0},{"n":275,"text":"\t\tconst earlier = (await api.log(where, FOLDER_LOG, renamed.from)).versions.filter((v) => v.version < oldest.version);","atom":"a0","author":"init","version":0},{"n":276,"text":"\t\tversions.push(...earlier.slice(0, limit === undefined ? 50 : limit - versions.length));","atom":"a0","author":"init","version":0},{"n":277,"text":"\t\tcurrent = renamed.from!;","atom":"a0","author":"init","version":0},{"n":278,"text":"\t}","atom":"a0","author":"init","version":0},{"n":279,"text":"\treturn versions;","atom":"a0","author":"init","version":0},{"n":280,"text":"}","atom":"a0","author":"init","version":0},{"n":281,"text":"","atom":"a0","author":"init","version":0},{"n":282,"text":"/** What else a version says: its labels, what it dropped or what dropped it, and its first message when amended. */","atom":"a0","author":"init","version":0},{"n":283,"text":"function notes(v: FollowedEntry): string[] {","atom":"a0","author":"init","version":0},{"n":284,"text":"\tconst out: string[] = [];","atom":"a0","author":"init","version":0},{"n":285,"text":"\tif (v.renamedFrom !== undefined)","atom":"a0","author":"init","version":0},{"n":286,"text":"\t\tout.push(`  renamed from ${v.renamedFrom}; the versions below are its history under that name`);","atom":"a0","author":"init","version":0},{"n":287,"text":"\tif (v.labels && v.labels.length > 0) out.push(`  labels: ${v.labels.join(\", \")}`);","atom":"a0","author":"init","version":0},{"n":288,"text":"\tif (v.drops && v.drops.length > 0)","atom":"a0","author":"init","version":0},{"n":289,"text":"\t\tout.push(`  drops ${v.drops.length === 1 ? \"version\" : \"versions\"} ${v.drops.join(\", \")}`);","atom":"a0","author":"init","version":0},{"n":290,"text":"\tif (v.droppedIn !== undefined) out.push(`  dropped in version ${v.droppedIn}: shared no longer has these changes`);","atom":"a0","author":"init","version":0},{"n":291,"text":"\tif (v.originalMessage !== undefined) out.push(`  amended; first pushed as: ${v.originalMessage}`);","atom":"a837","author":"rename","version":100},{"n":292,"text":"\treturn out;","atom":"a0","author":"init","version":0},{"n":293,"text":"}","atom":"a0","author":"init","version":0},{"n":294,"text":"","atom":"a0","author":"init","version":0},{"n":295,"text":"/**","atom":"a0","author":"init","version":0},{"n":296,"text":" * --since: a version number (the versions after it), a span back from now","atom":"a0","author":"init","version":0},{"n":297,"text":" * (30m, 2h, 1d), or a date and time Date.parse reads (2026-10-05T17:00).","atom":"a0","author":"init","version":0},{"n":298,"text":" */","atom":"a0","author":"init","version":0},{"n":299,"text":"export function sinceTest(raw: string, now: number): (v: LogEntry) => boolean {","atom":"a0","author":"init","version":0},{"n":300,"text":"\tif (/^\\d+$/.test(raw)) {","atom":"a0","author":"init","version":0},{"n":301,"text":"\t\tconst n = Number(raw);","atom":"a0","author":"init","version":0},{"n":302,"text":"\t\treturn (v) => v.version > n;","atom":"a0","author":"init","version":0},{"n":303,"text":"\t}","atom":"a0","author":"init","version":0},{"n":304,"text":"\tconst span = /^(\\d+)\\s*(m|min|h|d)$/.exec(raw);","atom":"a0","author":"init","version":0},{"n":305,"text":"\t// A bare clock time (20:00) is today's, local; yesterday's when today's hasn't come yet (#37, Reporter).","atom":"a0","author":"init","version":0},{"n":306,"text":"\tconst clock = /^(\\d{1,2}):(\\d{2})$/.exec(raw);","atom":"a0","author":"init","version":0},{"n":307,"text":"\tconst today = (h: number, m: number) => {","atom":"a0","author":"init","version":0},{"n":308,"text":"\t\tconst d = new Date(now);","atom":"a0","author":"init","version":0},{"n":309,"text":"\t\td.setHours(h, m, 0, 0);","atom":"a0","author":"init","version":0},{"n":310,"text":"\t\treturn d.getTime() > now ? d.getTime() - 86_400_000 : d.getTime();","atom":"a0","author":"init","version":0},{"n":311,"text":"\t};","atom":"a0","author":"init","version":0},{"n":312,"text":"\tconst at = span","atom":"a0","author":"init","version":0},{"n":313,"text":"\t\t? now -","atom":"a0","author":"init","version":0},{"n":314,"text":"\t\t\tNumber(span[1]) * { m: 60_000, min: 60_000, h: 3_600_000, d: 86_400_000 }[span[2] as \"m\" | \"min\" | \"h\" | \"d\"]","atom":"a0","author":"init","version":0},{"n":315,"text":"\t\t: clock && Number(clock[1]) < 24 && Number(clock[2]) < 60","atom":"a0","author":"init","version":0},{"n":316,"text":"\t\t\t? today(Number(clock[1]), Number(clock[2]))","atom":"a0","author":"init","version":0},{"n":317,"text":"\t\t\t: Date.parse(raw);","atom":"a0","author":"init","version":0},{"n":318,"text":"\tif (Number.isNaN(at))","atom":"a0","author":"init","version":0},{"n":319,"text":"\t\tthrow new UsageError(","atom":"a0","author":"init","version":0},{"n":320,"text":"\t\t\t`--since takes a version (400), a span back from now (30m, 2h, 1d), a clock time today (20:00), or a date and time (2026-10-05T17:00); got ${JSON.stringify(raw)}`,","atom":"a0","author":"init","version":0},{"n":321,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":322,"text":"\treturn (v) => v.time >= at;","atom":"a0","author":"init","version":0},{"n":323,"text":"}","atom":"a0","author":"init","version":0},{"n":324,"text":"","atom":"a0","author":"init","version":0},{"n":325,"text":"export async function runLog(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":326,"text":"\tif (args.positionals.length > 1)","atom":"a0","author":"init","version":0},{"n":327,"text":"\t\tthrow new UsageError(\"log takes at most one file: abso log [file] [-n <count>] [--draft <name>]\");","atom":"a0","author":"init","version":0},{"n":328,"text":"\tconst { root, config, api } = open(env);","atom":"a0","author":"init","version":0},{"n":329,"text":"\tconst typed = args.positionals[0];","atom":"a0","author":"init","version":0},{"n":330,"text":"\tconst path = typed === undefined ? undefined : pathArg(root, env.cwd, typed);","atom":"a0","author":"init","version":0},{"n":331,"text":"\tconst rawLimit = str(args, \"limit\");","atom":"a0","author":"init","version":0},{"n":332,"text":"\tconst limit = rawLimit === undefined ? undefined : version(rawLimit, \"-n\");","atom":"a0","author":"init","version":0},{"n":333,"text":"\tif (limit === 0) throw new UsageError(\"-n is how many versions to show; give 1 or more\");","atom":"a0","author":"init","version":0},{"n":334,"text":"\tconst rawBefore = str(args, \"before\");","atom":"a190","author":"pinch","version":26},{"n":335,"text":"\tconst before = rawBefore === undefined ? undefined : version(rawBefore, \"--before\");","atom":"a190","author":"pinch","version":26},{"n":336,"text":"\t// The server filters by one file; a folder (or the whole folder) is filtered here, from a longer log.","atom":"a0","author":"init","version":0},{"n":337,"text":"\tconst folder = path !== undefined && (path === \"\" || /[/]$/.test(typed!) || isFolder(root, path));","atom":"a0","author":"init","version":0},{"n":338,"text":"\t// --since, --by and --count (#37, Reporter's progress reports) filter here, from a longer log.","atom":"a0","author":"init","version":0},{"n":339,"text":"\tconst since = str(args, \"since\");","atom":"a0","author":"init","version":0},{"n":340,"text":"\tconst by = str(args, \"by\");","atom":"a0","author":"init","version":0},{"n":341,"text":"\tconst count = bool(args, \"count\");","atom":"a0","author":"init","version":0},{"n":342,"text":"\tconst filtering = since !== undefined || by !== undefined || count;","atom":"a0","author":"init","version":0},{"n":343,"text":"\tconst keep = since === undefined ? () => true : sinceTest(since, Date.now());","atom":"a0","author":"init","version":0},{"n":344,"text":"\tconst agents =","atom":"a0","author":"init","version":0},{"n":345,"text":"\t\tby === undefined","atom":"a0","author":"init","version":0},{"n":346,"text":"\t\t\t? undefined","atom":"a0","author":"init","version":0},{"n":347,"text":"\t\t\t: new Set(","atom":"a0","author":"init","version":0},{"n":348,"text":"\t\t\t\t\tby","atom":"a0","author":"init","version":0},{"n":349,"text":"\t\t\t\t\t\t.split(\",\")","atom":"a0","author":"init","version":0},{"n":350,"text":"\t\t\t\t\t\t.map((a) => a.trim())","atom":"a0","author":"init","version":0},{"n":351,"text":"\t\t\t\t\t\t.filter((a) => a !== \"\"),","atom":"a0","author":"init","version":0},{"n":352,"text":"\t\t\t\t);","atom":"a0","author":"init","version":0},{"n":353,"text":"\tconst raw = await api.log(","atom":"a0","author":"init","version":0},{"n":354,"text":"\t\tspace(args, config.agent),","atom":"a0","author":"init","version":0},{"n":355,"text":"\t\tfolder || filtering ? FOLDER_LOG : limit,","atom":"a0","author":"init","version":0},{"n":356,"text":"\t\tfolder ? undefined : path,","atom":"a0","author":"init","version":0},{"n":357,"text":"\t\tbefore,","atom":"a190","author":"pinch","version":26},{"n":358,"text":"\t);","atom":"a0","author":"init","version":0},{"n":359,"text":"\tconst found = folder","atom":"a0","author":"init","version":0},{"n":360,"text":"\t\t? {","atom":"a0","author":"init","version":0},{"n":361,"text":"\t\t\t\t...raw,","atom":"a0","author":"init","version":0},{"n":362,"text":"\t\t\t\tversions: raw.versions","atom":"a0","author":"init","version":0},{"n":363,"text":"\t\t\t\t\t.filter((v) => v.files.some((f) => under(f, path!)))","atom":"a0","author":"init","version":0},{"n":364,"text":"\t\t\t\t\t.slice(0, filtering ? FOLDER_LOG : (limit ?? 50)),","atom":"a0","author":"init","version":0},{"n":365,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":366,"text":"\t\t: path !== undefined","atom":"a0","author":"init","version":0},{"n":367,"text":"\t\t\t? {","atom":"a0","author":"init","version":0},{"n":368,"text":"\t\t\t\t\t...raw,","atom":"a0","author":"init","version":0},{"n":369,"text":"\t\t\t\t\tversions: await followRenames(api, space(args, config.agent), path, raw, filtering ? FOLDER_LOG : limit),","atom":"a0","author":"init","version":0},{"n":370,"text":"\t\t\t\t}","atom":"a0","author":"init","version":0},{"n":371,"text":"\t\t\t: raw;","atom":"a0","author":"init","version":0},{"n":372,"text":"\tconst answer = filtering","atom":"a0","author":"init","version":0},{"n":373,"text":"\t\t? {","atom":"a0","author":"init","version":0},{"n":374,"text":"\t\t\t\t...found,","atom":"a0","author":"init","version":0},{"n":375,"text":"\t\t\t\tversions: found.versions","atom":"a0","author":"init","version":0},{"n":376,"text":"\t\t\t\t\t.filter((v) => keep(v) && (agents === undefined || agents.has(v.agent)))","atom":"a0","author":"init","version":0},{"n":377,"text":"\t\t\t\t\t.slice(0, limit ?? FOLDER_LOG),","atom":"a0","author":"init","version":0},{"n":378,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":379,"text":"\t\t: found;","atom":"a0","author":"init","version":0},{"n":380,"text":"\tif (count) {","atom":"a0","author":"init","version":0},{"n":381,"text":"\t\t// Versions and files per agent, most first.","atom":"a0","author":"init","version":0},{"n":382,"text":"\t\tconst per = new Map<string, { versions: number; files: Set<string> }>();","atom":"a0","author":"init","version":0},{"n":383,"text":"\t\tfor (const v of answer.versions) {","atom":"a0","author":"init","version":0},{"n":384,"text":"\t\t\tconst a = per.get(v.agent) ?? { versions: 0, files: new Set<string>() };","atom":"a0","author":"init","version":0},{"n":385,"text":"\t\t\ta.versions++;","atom":"a0","author":"init","version":0},{"n":386,"text":"\t\t\tfor (const f of v.files) a.files.add(f);","atom":"a0","author":"init","version":0},{"n":387,"text":"\t\t\tper.set(v.agent, a);","atom":"a0","author":"init","version":0},{"n":388,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":389,"text":"\t\tconst rows = [...per].sort(([a, x], [b, y]) => y.versions - x.versions || a.localeCompare(b));","atom":"a0","author":"init","version":0},{"n":390,"text":"\t\tconst scope = [","atom":"a0","author":"init","version":0},{"n":391,"text":"\t\t\tsince === undefined ? \"\" : /^\\d+$/.test(since) ? ` since version ${since}` : ` since ${since}`,","atom":"a0","author":"init","version":0},{"n":392,"text":"\t\t\tagents === undefined ? \"\" : ` by ${[...agents].join(\", \")}`,","atom":"a0","author":"init","version":0},{"n":393,"text":"\t\t].join(\"\");","atom":"a0","author":"init","version":0},{"n":394,"text":"\t\treturn {","atom":"a0","author":"init","version":0},{"n":395,"text":"\t\t\ttext: [","atom":"a0","author":"init","version":0},{"n":396,"text":"\t\t\t\t`${spaceName(answer.draft)} is at version ${answer.version}. ${plural(answer.versions.length, \"version\")}${scope}${answer.versions.length > 0 ? \", per agent:\" : \".\"}`,","atom":"a0","author":"init","version":0},{"n":397,"text":"\t\t\t\t...rows.map(([agent, a]) => `  ${agent}: ${plural(a.versions, \"version\")}, ${plural(a.files.size, \"file\")}`),","atom":"a0","author":"init","version":0},{"n":398,"text":"\t\t\t].join(\"\\n\"),","atom":"a0","author":"init","version":0},{"n":399,"text":"\t\t\tjson: {","atom":"a0","author":"init","version":0},{"n":400,"text":"\t\t\t\tdraft: answer.draft,","atom":"a0","author":"init","version":0},{"n":401,"text":"\t\t\t\tversion: answer.version,","atom":"a0","author":"init","version":0},{"n":402,"text":"\t\t\t\tversions: answer.versions.length,","atom":"a0","author":"init","version":0},{"n":403,"text":"\t\t\t\tagents: Object.fromEntries(rows.map(([agent, a]) => [agent, { versions: a.versions, files: a.files.size }])),","atom":"a0","author":"init","version":0},{"n":404,"text":"\t\t\t},","atom":"a0","author":"init","version":0},{"n":405,"text":"\t\t};","atom":"a0","author":"init","version":0},{"n":406,"text":"\t}","atom":"a0","author":"init","version":0},{"n":407,"text":"\tconst named = path === undefined ? \"\" : path === \"\" ? \"the whole folder\" : folder ? `${path}/` : path;","atom":"a0","author":"init","version":0},{"n":408,"text":"\tconst lines = [","atom":"a0","author":"init","version":0},{"n":409,"text":"\t\t`${spaceName(answer.draft)} is at version ${answer.version}.${path === undefined ? \"\" : answer.versions.length === 0 ? ` No version changed ${named}.` : ` The versions that changed ${named}, newest first:`}`,","atom":"a0","author":"init","version":0},{"n":410,"text":"\t\t...(path !== undefined && answer.versions.length === 0 && !existsHere(root, path) ? [nothingAt(root, path)] : []),","atom":"a0","author":"init","version":0},{"n":411,"text":"\t\t...answer.versions.flatMap((v) => [","atom":"a0","author":"init","version":0},{"n":412,"text":"\t\t\t`version ${v.version} by ${byWhom(v)}, ${when(v.time)}${answer.draft === null ? ciMarkText(v.ci) : \"\"}: ${v.message}`,","atom":"a56","author":"engine","version":13},{"n":413,"text":"\t\t\t`  ${plural(v.files.length, \"file\")}: ${v.files.slice(0, LOG_FILES).join(\", \")}${v.files.length > LOG_FILES ? `, and ${v.files.length - LOG_FILES} more` : \"\"}`,","atom":"a0","author":"init","version":0},{"n":414,"text":"\t\t\t...notes(v),","atom":"a0","author":"init","version":0},{"n":415,"text":"\t\t]),","atom":"a0","author":"init","version":0},{"n":416,"text":"\t];","atom":"a0","author":"init","version":0},{"n":417,"text":"\tconst oldest = answer.versions[answer.versions.length - 1];","atom":"a0","author":"init","version":0},{"n":418,"text":"\tif (!filtering && !folder && raw.next !== undefined && oldest !== undefined)","atom":"a190","author":"pinch","version":26},{"n":419,"text":"\t\tlines.push(`Older versions: abso log${typed === undefined ? \"\" : ` ${typed}`} --before ${oldest.version}`);","atom":"a190","author":"pinch","version":26},{"n":420,"text":"\tif (filtering && answer.versions.length === 0) lines.push(\"No version matches.\");","atom":"a0","author":"init","version":0},{"n":421,"text":"\t// A filter or a folder reads the newest FOLDER_LOG versions; say so when older ones were left unread.","atom":"a190","author":"pinch","version":26},{"n":422,"text":"\tif ((filtering || folder) && raw.next !== undefined)","atom":"a190","author":"pinch","version":26},{"n":423,"text":"\t\tlines.push(","atom":"a190","author":"pinch","version":26},{"n":424,"text":"\t\t\t`Only the newest ${FOLDER_LOG} versions${before === undefined ? \"\" : ` below ${before}`} were read; --before ${raw.next} reads older ones.`,","atom":"a190","author":"pinch","version":26},{"n":425,"text":"\t\t);","atom":"a190","author":"pinch","version":26},{"n":426,"text":"\treturn { text: lines.join(\"\\n\"), json: { ...answer } };","atom":"a0","author":"init","version":0},{"n":427,"text":"}","atom":"a0","author":"init","version":0},{"n":428,"text":"","atom":"a0","author":"init","version":0},{"n":429,"text":"/** abso show <version>[:<file>] --without <versions>: what differs with them left out, or that file then. */","atom":"a2097","author":"candidates","version":186},{"n":430,"text":"async function showWithout(","atom":"a2097","author":"candidates","version":186},{"n":431,"text":"\tapi: Api,","atom":"a2097","author":"candidates","version":186},{"n":432,"text":"\troot: string,","atom":"a2097","author":"candidates","version":186},{"n":433,"text":"\tcwd: string,","atom":"a2097","author":"candidates","version":186},{"n":434,"text":"\tword: string,","atom":"a2097","author":"candidates","version":186},{"n":435,"text":"\twhere: Where,","atom":"a2097","author":"candidates","version":186},{"n":436,"text":"\tleave: readonly number[],","atom":"a2097","author":"candidates","version":186},{"n":437,"text":"): Promise<Output> {","atom":"a2097","author":"candidates","version":186},{"n":438,"text":"\tif (\"draft\" in where && where.draft !== null) throw new UsageError(\"--without reads shared, not a named draft\");","atom":"a2101","author":"candidates","version":186},{"n":439,"text":"\tconst colon = word.indexOf(\":\");","atom":"a2097","author":"candidates","version":186},{"n":440,"text":"\tconst v = version(colon >= 0 ? word.slice(0, colon) : word);","atom":"a2097","author":"candidates","version":186},{"n":441,"text":"\tconst path = colon >= 0 ? fileArg(root, cwd, word.slice(colon + 1)) : undefined;","atom":"a2097","author":"candidates","version":186},{"n":442,"text":"\tconst answer = await api.without(v, leave);","atom":"a2097","author":"candidates","version":186},{"n":443,"text":"\tif (!answer.ok)","atom":"a2097","author":"candidates","version":186},{"n":444,"text":"\t\treturn {","atom":"a2097","author":"candidates","version":186},{"n":445,"text":"\t\t\texit: EXIT.refused,","atom":"a2097","author":"candidates","version":186},{"n":446,"text":"\t\t\ttext: refusalText(answer, (vs) => `abso show ${word} --without ${vs.join(\",\")}`),","atom":"a2097","author":"candidates","version":186},{"n":447,"text":"\t\t\tjson: { ...answer },","atom":"a2097","author":"candidates","version":186},{"n":448,"text":"\t\t};","atom":"a2097","author":"candidates","version":186},{"n":449,"text":"\tif (path !== undefined) {","atom":"a2097","author":"candidates","version":186},{"n":450,"text":"\t\tconst file = answer.files.find((f) => f.path === path);","atom":"a2097","author":"candidates","version":186},{"n":451,"text":"\t\tif (file === undefined) {","atom":"a2097","author":"candidates","version":186},{"n":452,"text":"\t\t\tconst same = await api.fileAt(path, v, { draft: null });","atom":"a2101","author":"candidates","version":186},{"n":453,"text":"\t\t\tif (same.text !== null) return { text: same.text, json: { ...same, without: answer.without } };","atom":"a2097","author":"candidates","version":186},{"n":454,"text":"\t\t} else if (file.after !== null) return { text: file.after, json: { ...file, without: answer.without } };","atom":"a2097","author":"candidates","version":186},{"n":455,"text":"\t\treturn {","atom":"a2097","author":"candidates","version":186},{"n":456,"text":"\t\t\texit: EXIT.error,","atom":"a2097","author":"candidates","version":186},{"n":457,"text":"\t\t\ttext: `${path} isn't in version ${v} of shared without them.`,","atom":"a2097","author":"candidates","version":186},{"n":458,"text":"\t\t\tjson: { path, version: v, without: answer.without },","atom":"a2097","author":"candidates","version":186},{"n":459,"text":"\t\t};","atom":"a2097","author":"candidates","version":186},{"n":460,"text":"\t}","atom":"a2097","author":"candidates","version":186},{"n":461,"text":"\tconst changed = pairRenames(answer.files);","atom":"a2097","author":"candidates","version":186},{"n":462,"text":"\tconst d = diffs(changed);","atom":"a2097","author":"candidates","version":186},{"n":463,"text":"\tconst lines = [","atom":"a2097","author":"candidates","version":186},{"n":464,"text":"\t\t...withoutHeading(answer),","atom":"a2097","author":"candidates","version":186},{"n":465,"text":"\t\tchanged.length === 0 ? `No file differs from version ${v}.` : `Compared with version ${v}: ${totals(changed)}.`,","atom":"a2097","author":"candidates","version":186},{"n":466,"text":"\t\t`The files hash to ${answer.tree}; the same ask gives the same hash. Shared doesn't change.`,","atom":"a2097","author":"candidates","version":186},{"n":467,"text":"\t\t...d.text,","atom":"a2097","author":"candidates","version":186},{"n":468,"text":"\t];","atom":"a2097","author":"candidates","version":186},{"n":469,"text":"\treturn { text: lines.join(\"\\n\"), json: { ...answer, files: d.json } };","atom":"a2097","author":"candidates","version":186},{"n":470,"text":"}","atom":"a2097","author":"candidates","version":186},{"n":471,"text":"","atom":"a2097","author":"candidates","version":186},{"n":472,"text":"export async function runShow(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":473,"text":"\tif (args.positionals.length !== 1)","atom":"a0","author":"init","version":0},{"n":474,"text":"\t\tthrow new UsageError(\"show takes one version: abso show <version> or abso show <version>:<file>\");","atom":"a0","author":"init","version":0},{"n":475,"text":"\tconst { root, config, api } = open(env);","atom":"a0","author":"init","version":0},{"n":476,"text":"\tconst word = args.positionals[0]!;","atom":"a0","author":"init","version":0},{"n":477,"text":"\tconst colon = word.indexOf(\":\");","atom":"a0","author":"init","version":0},{"n":478,"text":"\tconst where = space(args, config.agent);","atom":"a0","author":"init","version":0},{"n":479,"text":"\tconst leave = withoutArg(args);","atom":"a2092","author":"candidates","version":186},{"n":480,"text":"\tif (leave !== undefined) return showWithout(api, root, env.cwd, word, where, leave);","atom":"a2096","author":"candidates","version":186},{"n":481,"text":"","atom":"a0","author":"init","version":0},{"n":482,"text":"\tif (colon >= 0) {","atom":"a0","author":"init","version":0},{"n":483,"text":"\t\tconst v = version(word.slice(0, colon));","atom":"a0","author":"init","version":0},{"n":484,"text":"\t\tconst path = fileArg(root, env.cwd, word.slice(colon + 1));","atom":"a0","author":"init","version":0},{"n":485,"text":"\t\tconst answer = await api.fileAt(path, v, where);","atom":"a0","author":"init","version":0},{"n":486,"text":"\t\tif (answer.text === null)","atom":"a0","author":"init","version":0},{"n":487,"text":"\t\t\treturn {","atom":"a0","author":"init","version":0},{"n":488,"text":"\t\t\t\texit: EXIT.error,","atom":"a0","author":"init","version":0},{"n":489,"text":"\t\t\t\ttext: `${path} did not exist at version ${v} of ${whereName(where)}.`,","atom":"a0","author":"init","version":0},{"n":490,"text":"\t\t\t\tjson: { ...answer, ...where },","atom":"a0","author":"init","version":0},{"n":491,"text":"\t\t\t};","atom":"a0","author":"init","version":0},{"n":492,"text":"\t\treturn { text: answer.text, json: { ...answer, ...where } };","atom":"a0","author":"init","version":0},{"n":493,"text":"\t}","atom":"a0","author":"init","version":0},{"n":494,"text":"","atom":"a0","author":"init","version":0},{"n":495,"text":"\tconst answer = await api.show(version(word), where);","atom":"a0","author":"init","version":0},{"n":496,"text":"\tconst changed = pairRenames(answer.diff);","atom":"a0","author":"init","version":0},{"n":497,"text":"\tconst d = diffs(changed);","atom":"a0","author":"init","version":0},{"n":498,"text":"\tconst lines = [","atom":"a0","author":"init","version":0},{"n":499,"text":"\t\t`version ${answer.version} of ${spaceName(answer.draft)} by ${byWhom(answer)}, ${when(answer.time)}: ${answer.message}`,","atom":"a56","author":"engine","version":13},{"n":500,"text":"\t\t...notes(answer),","atom":"a0","author":"init","version":0},{"n":501,"text":"\t\tchanged.length === 0 ? \"It changed no files.\" : `${totals(changed)}.`,","atom":"a0","author":"init","version":0},{"n":502,"text":"\t\t...d.text,","atom":"a0","author":"init","version":0},{"n":503,"text":"\t];","atom":"a0","author":"init","version":0},{"n":504,"text":"\treturn { text: lines.join(\"\\n\"), json: { ...answer, diff: d.json } };","atom":"a0","author":"init","version":0},{"n":505,"text":"}","atom":"a0","author":"init","version":0},{"n":506,"text":"","atom":"a0","author":"init","version":0},{"n":507,"text":"/**","atom":"a0","author":"init","version":0},{"n":508,"text":" * A file's text with the draft's hunks that touch lines `from`-`to` (of the","atom":"a0","author":"init","version":0},{"n":509,"text":" * file as it is now, as abso diff numbers them) put back as they were at the","atom":"a0","author":"init","version":0},{"n":510,"text":" * base; the other hunks stay (#37: drop my copy of a teammate's","atom":"a344","author":"infra-split","version":37},{"n":511,"text":" * half and keep the rest). A hunk that only deleted lines touches the line","atom":"a0","author":"init","version":0},{"n":512,"text":" * where they were.","atom":"a0","author":"init","version":0},{"n":513,"text":" */","atom":"a0","author":"init","version":0},{"n":514,"text":"export function restoreLines(before: string, after: string, from: number, to: number): { text: string; hunks: number } {","atom":"a0","author":"init","version":0},{"n":515,"text":"\tconst ops = editScript(linesOf(before), linesOf(after));","atom":"a0","author":"init","version":0},{"n":516,"text":"\tconst out: string[] = [];","atom":"a0","author":"init","version":0},{"n":517,"text":"\tlet hunks = 0;","atom":"a0","author":"init","version":0},{"n":518,"text":"\tlet line = 1; // the next line of the file as it is now","atom":"a0","author":"init","version":0},{"n":519,"text":"\tfor (let i = 0; i < ops.length; ) {","atom":"a0","author":"init","version":0},{"n":520,"text":"\t\tif (ops[i]!.kind === \" \") {","atom":"a0","author":"init","version":0},{"n":521,"text":"\t\t\tout.push(ops[i]!.line);","atom":"a0","author":"init","version":0},{"n":522,"text":"\t\t\tline++;","atom":"a0","author":"init","version":0},{"n":523,"text":"\t\t\ti++;","atom":"a0","author":"init","version":0},{"n":524,"text":"\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":525,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":526,"text":"\t\t// One hunk: the run of - and + ops.","atom":"a0","author":"init","version":0},{"n":527,"text":"\t\tlet j = i;","atom":"a0","author":"init","version":0},{"n":528,"text":"\t\twhile (j < ops.length && ops[j]!.kind !== \" \") j++;","atom":"a0","author":"init","version":0},{"n":529,"text":"\t\tconst run = ops.slice(i, j);","atom":"a0","author":"init","version":0},{"n":530,"text":"\t\tconst added = run.filter((o) => o.kind === \"+\").length;","atom":"a0","author":"init","version":0},{"n":531,"text":"\t\tconst first = line;","atom":"a0","author":"init","version":0},{"n":532,"text":"\t\tconst last = added > 0 ? line + added - 1 : line;","atom":"a0","author":"init","version":0},{"n":533,"text":"\t\tconst touched = added > 0 ? first <= to && last >= from : first >= from && first <= to + 1;","atom":"a0","author":"init","version":0},{"n":534,"text":"\t\tif (touched) {","atom":"a0","author":"init","version":0},{"n":535,"text":"\t\t\tout.push(...run.filter((o) => o.kind === \"-\").map((o) => o.line));","atom":"a0","author":"init","version":0},{"n":536,"text":"\t\t\thunks++;","atom":"a0","author":"init","version":0},{"n":537,"text":"\t\t} else {","atom":"a0","author":"init","version":0},{"n":538,"text":"\t\t\tout.push(...run.filter((o) => o.kind === \"+\").map((o) => o.line));","atom":"a0","author":"init","version":0},{"n":539,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":540,"text":"\t\tline += added;","atom":"a0","author":"init","version":0},{"n":541,"text":"\t\ti = j;","atom":"a0","author":"init","version":0},{"n":542,"text":"\t}","atom":"a0","author":"init","version":0},{"n":543,"text":"\treturn { text: out.length === 0 ? \"\" : `${out.join(\"\\n\")}\\n`, hunks };","atom":"a0","author":"init","version":0},{"n":544,"text":"}","atom":"a0","author":"init","version":0},{"n":545,"text":"","atom":"a0","author":"init","version":0},{"n":546,"text":"/** file:12 or file:12-30, as typed; not a Windows drive letter (C:...). */","atom":"a0","author":"init","version":0},{"n":547,"text":"const LINES = /^(.+?):(\\d+)(?:-(\\d+))?$/;","atom":"a0","author":"init","version":0},{"n":548,"text":"","atom":"a0","author":"init","version":0},{"n":549,"text":"export async function runRestore(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":550,"text":"\tconst all = bool(args, \"all\");","atom":"a0","author":"init","version":0},{"n":551,"text":"\tif (all === args.positionals.length > 0)","atom":"a0","author":"init","version":0},{"n":552,"text":"\t\tthrow new UsageError(","atom":"a0","author":"init","version":0},{"n":553,"text":"\t\t\t\"restore takes files, or --all: abso restore <file...> | abso restore <file>:<lines> | abso restore --all\",","atom":"a0","author":"init","version":0},{"n":554,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":555,"text":"\tconst { root, api } = open(env);","atom":"a0","author":"init","version":0},{"n":556,"text":"\tconst ranged = args.positionals","atom":"a0","author":"init","version":0},{"n":557,"text":"\t\t.map((w) => LINES.exec(w))","atom":"a0","author":"init","version":0},{"n":558,"text":"\t\t.filter((m): m is RegExpExecArray => m !== null && !/^[A-Za-z]$/.test(m[1]!))","atom":"a0","author":"init","version":0},{"n":559,"text":"\t\t.map((m) => ({ file: fileArg(root, env.cwd, m[1]!), from: Number(m[2]), to: Number(m[3] ?? m[2]), typed: m[0] }));","atom":"a0","author":"init","version":0},{"n":560,"text":"\tconst asked = args.positionals","atom":"a0","author":"init","version":0},{"n":561,"text":"\t\t.filter((w) => !ranged.some((r) => r.typed === w))","atom":"a0","author":"init","version":0},{"n":562,"text":"\t\t.map((w) => fileArg(root, env.cwd, w));","atom":"a0","author":"init","version":0},{"n":563,"text":"\t// Folder-only edits go to the server first, so they are discarded with the rest.","atom":"a0","author":"init","version":0},{"n":564,"text":"\tawait recordFolder(root, api);","atom":"a0","author":"init","version":0},{"n":565,"text":"\tif (ranged.length > 0) {","atom":"a0","author":"init","version":0},{"n":566,"text":"\t\t// Some lines of a file: put those hunks back here, then record the file (#37).","atom":"a344","author":"infra-split","version":37},{"n":567,"text":"\t\tconst diff = await api.diff();","atom":"a0","author":"init","version":0},{"n":568,"text":"\t\tconst lines: string[] = [];","atom":"a0","author":"init","version":0},{"n":569,"text":"\t\tfor (const r of ranged) {","atom":"a0","author":"init","version":0},{"n":570,"text":"\t\t\tif (r.to < r.from) throw new UsageError(`${r.typed}: the range runs backwards`);","atom":"a0","author":"init","version":0},{"n":571,"text":"\t\t\tconst change = diff.files.find((f) => f.path === r.file);","atom":"a0","author":"init","version":0},{"n":572,"text":"\t\t\tif (change === undefined || change.before === null || change.after === null || change.blob !== undefined) {","atom":"a0","author":"init","version":0},{"n":573,"text":"\t\t\t\tthrow new UsageError(","atom":"a0","author":"init","version":0},{"n":574,"text":"\t\t\t\t\t`${r.file} has no line changes in your draft to restore (abso diff ${r.file} shows what it has)`,","atom":"a0","author":"init","version":0},{"n":575,"text":"\t\t\t\t);","atom":"a0","author":"init","version":0},{"n":576,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":577,"text":"\t\t\tconst back = restoreLines(change.before, change.after, r.from, r.to);","atom":"a0","author":"init","version":0},{"n":578,"text":"\t\t\tif (back.hunks === 0)","atom":"a0","author":"init","version":0},{"n":579,"text":"\t\t\t\tthrow new UsageError(","atom":"a0","author":"init","version":0},{"n":580,"text":"\t\t\t\t\t`none of your changes to ${r.file} touch lines ${r.from}-${r.to} (abso diff ${r.file} shows where they are)`,","atom":"a0","author":"init","version":0},{"n":581,"text":"\t\t\t\t);","atom":"a0","author":"init","version":0},{"n":582,"text":"\t\t\tconst path = absolute(root, r.file);","atom":"a0","author":"init","version":0},{"n":583,"text":"\t\t\twriteFileAtomic(path, withEndingsOf(back.text, readText(path), undefined));","atom":"a0","author":"init","version":0},{"n":584,"text":"\t\t\tlines.push(","atom":"a0","author":"init","version":0},{"n":585,"text":"\t\t\t\t`Restored ${plural(back.hunks, \"hunk\")} of ${r.file} at ${r.from === r.to ? `line ${r.from}` : `lines ${r.from}-${r.to}`} to how ${diff.base === null ? \"shared\" : `version ${diff.base}`} has ${back.hunks === 1 ? \"it\" : \"them\"}; your other changes to it stay.`,","atom":"a0","author":"init","version":0},{"n":586,"text":"\t\t\t);","atom":"a0","author":"init","version":0},{"n":587,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":588,"text":"\t\tawait recordFolder(root, api);","atom":"a0","author":"init","version":0},{"n":589,"text":"\t\tif (asked.length === 0)","atom":"a0","author":"init","version":0},{"n":590,"text":"\t\t\treturn {","atom":"a0","author":"init","version":0},{"n":591,"text":"\t\t\t\ttext: lines.join(\"\\n\"),","atom":"a0","author":"init","version":0},{"n":592,"text":"\t\t\t\tjson: { restoredLines: ranged.map((r) => ({ file: r.file, from: r.from, to: r.to })) },","atom":"a0","author":"init","version":0},{"n":593,"text":"\t\t\t};","atom":"a0","author":"init","version":0},{"n":594,"text":"\t}","atom":"a0","author":"init","version":0},{"n":595,"text":"\t// The server's own paths, screened as a sync's are (safety.ts).","atom":"a0","author":"init","version":0},{"n":596,"text":"\tconst { answer, refused } = screenAnswer(root, await api.restore(all ? null : asked));","atom":"a0","author":"init","version":0},{"n":597,"text":"\tconst restored: string[] = [];","atom":"a0","author":"init","version":0},{"n":598,"text":"\tconst deleted: string[] = [];","atom":"a0","author":"init","version":0},{"n":599,"text":"\tconst fresh = newFileEndings(","atom":"a0","author":"init","version":0},{"n":600,"text":"\t\troot,","atom":"a0","author":"init","version":0},{"n":601,"text":"\t\tObject.entries(answer.files)","atom":"a0","author":"init","version":0},{"n":602,"text":"\t\t\t.filter(([rel, text]) => text !== null && !existsSync(absolute(root, rel)))","atom":"a0","author":"init","version":0},{"n":603,"text":"\t\t\t.map(([rel]) => rel),","atom":"a0","author":"init","version":0},{"n":604,"text":"\t);","atom":"a0","author":"init","version":0},{"n":605,"text":"\tfor (const [rel, text] of Object.entries(answer.files).sort(","atom":"a0","author":"init","version":0},{"n":606,"text":"\t\t([, a], [, b]) => Number(a !== null) - Number(b !== null),","atom":"a0","author":"init","version":0},{"n":607,"text":"\t)) {","atom":"a0","author":"init","version":0},{"n":608,"text":"\t\tconst path = absolute(root, rel);","atom":"a0","author":"init","version":0},{"n":609,"text":"\t\tif (text === null) {","atom":"a0","author":"init","version":0},{"n":610,"text":"\t\t\tremoveFile(path);","atom":"a0","author":"init","version":0},{"n":611,"text":"\t\t\tforgetKnown(root, rel);","atom":"a0","author":"init","version":0},{"n":612,"text":"\t\t\tdeleted.push(rel);","atom":"a0","author":"init","version":0},{"n":613,"text":"\t\t} else {","atom":"a0","author":"init","version":0},{"n":614,"text":"\t\t\tconst raw = readText(path);","atom":"a0","author":"init","version":0},{"n":615,"text":"\t\t\twriteFileAtomic(path, withEndingsOf(text, raw, fresh.get(rel)));","atom":"a0","author":"init","version":0},{"n":616,"text":"\t\t\twriteKnown(root, rel, normalize(text));","atom":"a0","author":"init","version":0},{"n":617,"text":"\t\t\trestored.push(rel);","atom":"a0","author":"init","version":0},{"n":618,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":619,"text":"\t}","atom":"a0","author":"init","version":0},{"n":620,"text":"\tconst knownModes = readKnownModes(root);","atom":"a0","author":"init","version":0},{"n":621,"text":"\tfor (const rel of deleted) knownModes.delete(rel);","atom":"a0","author":"init","version":0},{"n":622,"text":"\tfor (const [rel, m] of Object.entries(answer.modes ?? {})) {","atom":"a0","author":"init","version":0},{"n":623,"text":"\t\tif (answer.files[rel] === null) continue;","atom":"a0","author":"init","version":0},{"n":624,"text":"\t\tconst was = knownModes.get(rel) ?? PLAIN;","atom":"a0","author":"init","version":0},{"n":625,"text":"\t\tconst mode = { exec: m.exec ?? was.exec, link: m.link === undefined ? was.link : m.link };","atom":"a0","author":"init","version":0},{"n":626,"text":"\t\tapplyMode(absolute(root, rel), mode);","atom":"a0","author":"init","version":0},{"n":627,"text":"\t\tknownModes.set(rel, mode);","atom":"a0","author":"init","version":0},{"n":628,"text":"\t\tif (!restored.includes(rel)) restored.push(rel);","atom":"a0","author":"init","version":0},{"n":629,"text":"\t}","atom":"a0","author":"init","version":0},{"n":630,"text":"\twriteKnownModes(root, knownModes);","atom":"a0","author":"init","version":0},{"n":631,"text":"\t// Binary files go back to the bytes the server has.","atom":"a0","author":"init","version":0},{"n":632,"text":"\tconst knownBlobs = readKnownBlobs(root);","atom":"a0","author":"init","version":0},{"n":633,"text":"\tfor (const rel of [...deleted, ...Object.keys(answer.files)]) knownBlobs.delete(rel);","atom":"a0","author":"init","version":0},{"n":634,"text":"\tfor (const [rel, sha] of Object.entries(answer.blobs ?? {})) {","atom":"a0","author":"init","version":0},{"n":635,"text":"\t\tif (sha === null) continue;","atom":"a0","author":"init","version":0},{"n":636,"text":"\t\twriteFileAtomic(absolute(root, rel), await api.getBlob(sha));","atom":"a0","author":"init","version":0},{"n":637,"text":"\t\tforgetKnown(root, rel);","atom":"a0","author":"init","version":0},{"n":638,"text":"\t\tknownBlobs.set(rel, sha);","atom":"a0","author":"init","version":0},{"n":639,"text":"\t\tif (!restored.includes(rel)) restored.push(rel);","atom":"a0","author":"init","version":0},{"n":640,"text":"\t}","atom":"a0","author":"init","version":0},{"n":641,"text":"\twriteKnownBlobs(root, knownBlobs);","atom":"a0","author":"init","version":0},{"n":642,"text":"\tconst untouched = asked.filter(","atom":"a0","author":"init","version":0},{"n":643,"text":"\t\t(rel) => !(rel in answer.files) && !(rel in (answer.modes ?? {})) && !(rel in (answer.blobs ?? {})),","atom":"a0","author":"init","version":0},{"n":644,"text":"\t);","atom":"a0","author":"init","version":0},{"n":645,"text":"\tconst lines = [","atom":"a0","author":"init","version":0},{"n":646,"text":"\t\trestored.length + deleted.length === 0","atom":"a0","author":"init","version":0},{"n":647,"text":"\t\t\t? \"Nothing to restore: no unpushed changes there.\"","atom":"a837","author":"rename","version":100},{"n":648,"text":"\t\t\t: `Discarded your unpushed changes to ${plural(restored.length + deleted.length, \"file\")}:`,","atom":"a837","author":"rename","version":100},{"n":649,"text":"\t\t...restored.map((f) => `  restored ${f}`),","atom":"a0","author":"init","version":0},{"n":650,"text":"\t\t...deleted.map((f) => `  deleted ${f} (it is new in your draft)`),","atom":"a0","author":"init","version":0},{"n":651,"text":"\t\t...(untouched.length > 0 && restored.length + deleted.length > 0","atom":"a0","author":"init","version":0},{"n":652,"text":"\t\t\t? [`No unpushed changes to: ${untouched.join(\", \")}`]","atom":"a837","author":"rename","version":100},{"n":653,"text":"\t\t\t: []),","atom":"a0","author":"init","version":0},{"n":654,"text":"\t\t...refusedText(refused),","atom":"a0","author":"init","version":0},{"n":655,"text":"\t];","atom":"a0","author":"init","version":0},{"n":656,"text":"\treturn { text: lines.join(\"\\n\"), json: { restored, deleted, untouched, dropped: answer.dropped, refused } };","atom":"a0","author":"init","version":0},{"n":657,"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":"a56","author":"engine","message":"","time":1791514683415,"timeIso":"2026-10-09T02:58:03.415Z","publish":{"draft":null,"version":13,"agent":"engine","message":"The client names an imported version's original author (abso issue 23). The hosted Worker's admin route for imported history lays an author beside agent on every publish of a shared version (version 647 in abso). abso log, show, blame's Publishes, why and where now say who first wrote a version when there's an author, and the agent who published it otherwise (byWhom in history-answers.ts), the way git names a commit's author beside its committer. Code that matches agents (publish's checks, settle, news) keeps using agent. No change for projects without imported history. Tests: client/test/imported-history.test.ts; check passes (703).","time":1791514684603,"timeIso":"2026-10-09T02:58:04.603Z"}},{"atom":"a77","author":"review","message":"","time":1791520995119,"timeIso":"2026-10-09T04:43:15.119Z","publish":{"draft":null,"version":16,"agent":"review","message":"The client says abso, not avcs, in everything a person reads: the hints after an issue view and abso issue new, the help for issue, issues, ask, answer and waiting, the 'abso:' prefix on notices from run, publish --check, the queue and serve, the 'News from abso' header, the MCP server's name and the claude mcp add example, and the view mod's status line. Only printed words changed: file and folder names (avcs.json, .avcs/, ~/.avcs/token), environment variables and wire headers are as they were, and the tests were updated to the new words (704 pass, biome ci clean).","time":1791521002669,"timeIso":"2026-10-09T04:43:22.669Z"}},{"atom":"a190","author":"pinch","message":"","time":1791532995488,"timeIso":"2026-10-09T08:03:15.488Z","publish":{"draft":null,"version":26,"agent":"pinch","message":"Publish and log fixes, and a flaky test removed.\n\n- A publish or a land now waits up to 150 s for the server's answer, not 30 s. The server may work on one request for up to 2 minutes, so a slow merge was reported as failed and then landed.\n- abso log reads any length of history. The server sends at most 200 versions a page, and the client now follows its pages: -n 2000 gives 2000, and --since or a folder reads up to 1000. abso log --before <version> starts below that version. The end of the list names the --before for the next older ones, and a filtered read says when it stopped short.\n- The test 'sends one run, and takes each command as one quoted word' is removed: it failed on Windows about half the time. The stand-in server the client tests use no longer closes idle kept-alive connections, which other tests also tripped on under load (ECONNRESET).\n\nCheck: 722 pass, 0 fail.","time":1791533012122,"timeIso":"2026-10-09T08:03:32.122Z"}},{"atom":"a344","author":"infra-split","message":"","time":1791546892033,"timeIso":"2026-10-09T11:54:52.033Z","publish":{"draft":null,"version":37,"agent":"infra-split","message":"Comments and test names give each reason in plain words, without naming who raised it\n\nNotes like \"(#37, Builder 5)\" or \"(AVCS - Security)\" become \"(#37)\" or go, and a private commit hash after a name goes with it. Issue numbers and references such as git's CVE-2019-1353 stay. Only comments and test names change; no behavior changes.","time":1791547035956,"timeIso":"2026-10-09T11:57:15.956Z"}},{"atom":"a471","author":"pinch","message":"","time":1791581020988,"timeIso":"2026-10-09T21:23:40.988Z","publish":{"draft":null,"version":52,"agent":"pinch","message":"abso diff --agent <name>: review another agent's unpublished changes\n\nReviewing a teammate's work before it's published had no command: abso diff showed only your own draft, and abso status names files but not lines. Reviewers read the other agent's folder on disk, which only works on a shared machine and shows their disk, not what they recorded.\n\nabso diff --agent alice now prints alice's recorded, unpublished changes line by line, the way abso diff prints yours: \"alice's recorded, unpublished changes in shared (on version 12): 2 files, 5 lines added, 1 removed.\" Paths narrow it as usual. It reads what the server holds, the same route the website's drafts use, so it records nothing and changes nothing. An agent with no changes says so; a name the project doesn't know is refused by the server. --agent doesn't go with two versions or --draft.\n\nThe test server answers GET /p/:project/diff?agent= as the Worker does. Tested in client.test.ts.","time":1791581673467,"timeIso":"2026-10-09T21:34:33.467Z"}},{"atom":"a765","author":"pinch","message":"","time":1791616755509,"timeIso":"2026-10-10T07:19:15.509Z","publish":{"draft":null,"version":86,"agent":"pinch","message":"Read a public project signed out: abso join <project> --reader with no sign-in makes a folder that reads it. The folder holds only its settings (server, project, visitor), sends no sign-in whatever the environment or the box holds, follows no redirect, and runs status, log, show, files, blame, why, where, issues, issue and search; every other command is refused before any call, from an allow-list a new command has to join. join answers a private project and a missing one alike, by the status answer's code alone. Tests in client/test/visitor.test.ts.","time":1791616980022,"timeIso":"2026-10-10T07:23:00.022Z"}},{"atom":"a837","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":"a2092","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"}},{"atom":"a2096","author":"candidates","message":"","time":1792003683890,"timeIso":"2026-10-14T18:48:03.890Z","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"}},{"atom":"a2097","author":"candidates","message":"","time":1792003684158,"timeIso":"2026-10-14T18:48:04.158Z","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"}},{"atom":"a2101","author":"candidates","message":"","time":1792003808372,"timeIso":"2026-10-14T18:50:08.372Z","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"}}]}