{"file":"client/src/commands.ts","version":318,"total":728,"from":1,"to":728,"lines":[{"n":1,"text":"// The abso commands other than `hook`: init, join, record, publish, sync, run","atom":"a0","author":"init","version":0},{"n":2,"text":"// and status. Each returns what to print and the exit code, so tests can call","atom":"a0","author":"init","version":0},{"n":3,"text":"// them directly.","atom":"a0","author":"init","version":0},{"n":4,"text":"","atom":"a0","author":"init","version":0},{"n":5,"text":"import { existsSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";","atom":"a0","author":"init","version":0},{"n":6,"text":"import { join } from \"node:path\";","atom":"a0","author":"init","version":0},{"n":7,"text":"// The engine's own key, so both sides match spellings the same way (#49). Not in core.ts: the edit mod installs core.ts alone.","atom":"a0","author":"init","version":0},{"n":8,"text":"import {","atom":"a0","author":"init","version":0},{"n":9,"text":"\ttype Api,","atom":"a0","author":"init","version":0},{"n":10,"text":"\tApiError,","atom":"a2755","author":"pinch","version":280},{"n":11,"text":"\ttype Collision,","atom":"a0","author":"init","version":0},{"n":12,"text":"\ttype FileChange,","atom":"a0","author":"init","version":0},{"n":13,"text":"\ttype MergedLine,","atom":"a0","author":"init","version":0},{"n":14,"text":"\ttype News,","atom":"a0","author":"init","version":0},{"n":15,"text":"\tnewsLines,","atom":"a0","author":"init","version":0},{"n":16,"text":"\ttype SyncAnswer,","atom":"a0","author":"init","version":0},{"n":17,"text":"} from \"./api.ts\";","atom":"a0","author":"init","version":0},{"n":18,"text":"import { bool, type Parsed, str, UsageError } from \"./args.ts\";","atom":"a0","author":"init","version":0},{"n":19,"text":"import { blobOf, keptWholeAs, MAX_BLOB_BYTES, readKnownBlobs, writeKnownBlobs } from \"./blobs.ts\";","atom":"a0","author":"init","version":0},{"n":20,"text":"import { type Env, EXIT, heard, type Output, open } from \"./command-env.ts\";","atom":"a0","author":"init","version":0},{"n":21,"text":"import { findRoot, isReader } from \"./config.ts\";","atom":"a99","author":"review","version":17},{"n":22,"text":"import { spellingText, uncomposedText } from \"./core.ts\";","atom":"a0","author":"init","version":0},{"n":23,"text":"import { pairRenames } from \"./diff.ts\";","atom":"a0","author":"init","version":0},{"n":24,"text":"import type { BlobToSend, TurnedBinary } from \"./folder.ts\";","atom":"a0","author":"init","version":0},{"n":25,"text":"import {","atom":"a0","author":"init","version":0},{"n":26,"text":"\tabsolute,","atom":"a0","author":"init","version":0},{"n":27,"text":"\tforgetKnown,","atom":"a0","author":"init","version":0},{"n":28,"text":"\tisLocalOnly,","atom":"a0","author":"init","version":0},{"n":29,"text":"\tisPaused,","atom":"a0","author":"init","version":0},{"n":30,"text":"\ttype LeftOut,","atom":"a0","author":"init","version":0},{"n":31,"text":"\tlistKnown,","atom":"a0","author":"init","version":0},{"n":32,"text":"\tnewFileEndings,","atom":"a0","author":"init","version":0},{"n":33,"text":"\tnormalize,","atom":"a0","author":"init","version":0},{"n":34,"text":"\tpausedPath,","atom":"a0","author":"init","version":0},{"n":35,"text":"\treadKnown,","atom":"a0","author":"init","version":0},{"n":36,"text":"\tremoveFile,","atom":"a0","author":"init","version":0},{"n":37,"text":"\tunrecorded,","atom":"a0","author":"init","version":0},{"n":38,"text":"\twithEndingsOf,","atom":"a0","author":"init","version":0},{"n":39,"text":"\twriteFileAtomic,","atom":"a0","author":"init","version":0},{"n":40,"text":"\twriteKnown,","atom":"a0","author":"init","version":0},{"n":41,"text":"} from \"./folder.ts\";","atom":"a0","author":"init","version":0},{"n":42,"text":"import { withFolderLock } from \"./lock.ts\";","atom":"a0","author":"init","version":0},{"n":43,"text":"import type { OnDisk } from \"./modes.ts\";","atom":"a0","author":"init","version":0},{"n":44,"text":"import { applyMode, type FullMode, foldModes, onDisk, PLAIN, readKnownModes, writeKnownModes } from \"./modes.ts\";","atom":"a0","author":"init","version":0},{"n":45,"text":"import { batchRecordItems, sendRecordBatches } from \"./record-batches.ts\";","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":46,"text":"import { type Refused, screenAnswer, unsafePath } from \"./safety.ts\";","atom":"a0","author":"init","version":0},{"n":47,"text":"","atom":"a0","author":"init","version":0},{"n":48,"text":"export {","atom":"a0","author":"init","version":0},{"n":49,"text":"\tknownPrep,","atom":"a0","author":"init","version":0},{"n":50,"text":"\tparallelScript,","atom":"a0","author":"init","version":0},{"n":51,"text":"\ttype RunStamp,","atom":"a0","author":"init","version":0},{"n":52,"text":"\trunBisect,","atom":"a0","author":"init","version":0},{"n":53,"text":"\trunCommand,","atom":"a0","author":"init","version":0},{"n":54,"text":"\trunLogs,","atom":"a0","author":"init","version":0},{"n":55,"text":"\trunPrep,","atom":"a0","author":"init","version":0},{"n":56,"text":"\trunRun,","atom":"a0","author":"init","version":0},{"n":57,"text":"\tshellWord,","atom":"a0","author":"init","version":0},{"n":58,"text":"\tundoGitBashPaths,","atom":"a0","author":"init","version":0},{"n":59,"text":"\twithEntries,","atom":"a0","author":"init","version":0},{"n":60,"text":"} from \"./box-commands.ts\";","atom":"a0","author":"init","version":0},{"n":61,"text":"export { collisionsHeading, collisionText, mergedLinesText } from \"./collision-text.ts\";","atom":"a0","author":"init","version":0},{"n":62,"text":"export { type Env, EXIT, newsText, type Output, open, plural, takeNews } from \"./command-env.ts\";","atom":"a0","author":"init","version":0},{"n":63,"text":"export { runInit, runJoin } from \"./join-commands.ts\";","atom":"a0","author":"init","version":0},{"n":64,"text":"export { runPublish, runSync, sameVersionHint } from \"./publish-commands.ts\";","atom":"a0","author":"init","version":0},{"n":65,"text":"export { imageTokens, runFetch, runServe, runShot } from \"./serve-commands.ts\";","atom":"a0","author":"init","version":0},{"n":66,"text":"export {","atom":"a0","author":"init","version":0},{"n":67,"text":"\tcrlfOnly,","atom":"a0","author":"init","version":0},{"n":68,"text":"\tmissingHere,","atom":"a0","author":"init","version":0},{"n":69,"text":"\tmissingText,","atom":"a0","author":"init","version":0},{"n":70,"text":"\topenCollisionsText,","atom":"a0","author":"init","version":0},{"n":71,"text":"\trunFixEol,","atom":"a0","author":"init","version":0},{"n":72,"text":"\trunMv,","atom":"a0","author":"init","version":0},{"n":73,"text":"\trunReader,","atom":"a0","author":"init","version":0},{"n":74,"text":"\trunSettle,","atom":"a0","author":"init","version":0},{"n":75,"text":"\trunStatus,","atom":"a0","author":"init","version":0},{"n":76,"text":"\tstaleModText,","atom":"a0","author":"init","version":0},{"n":77,"text":"} from \"./status-commands.ts\";","atom":"a0","author":"init","version":0},{"n":78,"text":"","atom":"a0","author":"init","version":0},{"n":79,"text":"import { gitMarkerLine } from \"./settle.ts\";","atom":"a52","author":"review","version":12},{"n":80,"text":"import { stateDir } from \"./state-dir.ts\";","atom":"a99","author":"review","version":17},{"n":81,"text":"","atom":"a52","author":"review","version":12},{"n":82,"text":"// --- record ---","atom":"a0","author":"init","version":0},{"n":83,"text":"","atom":"a0","author":"init","version":0},{"n":84,"text":"interface Recorded {","atom":"a0","author":"init","version":0},{"n":85,"text":"\treadonly sent: number;","atom":"a0","author":"init","version":0},{"n":86,"text":"\t/** The paths sent. */","atom":"a0","author":"init","version":0},{"n":87,"text":"\treadonly paths: readonly string[];","atom":"a0","author":"init","version":0},{"n":88,"text":"\t/** Those of them sent as deleted (gone from the folder). */","atom":"a0","author":"init","version":0},{"n":89,"text":"\treadonly deleted: readonly string[];","atom":"a0","author":"init","version":0},{"n":90,"text":"\t/** Those of them new to avcs: no copy recorded before (#37: a file a script made is easy to miss). */","atom":"a346","author":"infra-split","version":37},{"n":91,"text":"\treadonly added?: readonly string[];","atom":"a0","author":"init","version":0},{"n":92,"text":"\t/** Nothing was sent because the folder is paused (abso pause). */","atom":"a0","author":"init","version":0},{"n":93,"text":"\treadonly paused?: boolean;","atom":"a0","author":"init","version":0},{"n":94,"text":"\treadonly changed: readonly string[] | number | undefined;","atom":"a0","author":"init","version":0},{"n":95,"text":"\treadonly news: News;","atom":"a0","author":"init","version":0},{"n":96,"text":"\treadonly leftOut: readonly LeftOut[];","atom":"a0","author":"init","version":0},{"n":97,"text":"\treadonly turnedBinary: readonly TurnedBinary[];","atom":"a0","author":"init","version":0},{"n":98,"text":"\t/** Text files sent that hold what looks like a git conflict (a merge git left unfinished, or markers typed by hand). */","atom":"a52","author":"review","version":12},{"n":99,"text":"\treadonly gitMarkers?: readonly { path: string; line: number }[];","atom":"a52","author":"review","version":12},{"n":100,"text":"\t/** Sent files whose path is long enough to fail on Windows, here or in another agent's folder. */","atom":"a52","author":"review","version":12},{"n":101,"text":"\treadonly longPaths?: readonly { path: string; length: number }[];","atom":"a52","author":"review","version":12},{"n":102,"text":"}","atom":"a0","author":"init","version":0},{"n":103,"text":"","atom":"a0","author":"init","version":0},{"n":104,"text":"/** The warning for text files that turned binary: what, where, and what to do. Empty when there are none. */","atom":"a0","author":"init","version":0},{"n":105,"text":"export function turnedBinaryText(list: readonly TurnedBinary[]): string[] {","atom":"a0","author":"init","version":0},{"n":106,"text":"\treturn list.map(","atom":"a0","author":"init","version":0},{"n":107,"text":"\t\t(t) =>","atom":"a0","author":"init","version":0},{"n":108,"text":"\t\t\t`NOT SENT: ${t.path} was text and now has ${t.why} at line ${t.line} (byte ${t.offset}). The server keeps its last text, so the other agents still have the old file. Fix the file; or, if it is meant to be binary now, pass --binary ${t.path}.`,","atom":"a0","author":"init","version":0},{"n":109,"text":"\t);","atom":"a0","author":"init","version":0},{"n":110,"text":"}","atom":"a0","author":"init","version":0},{"n":111,"text":"","atom":"a0","author":"init","version":0},{"n":112,"text":"/** The paths given with --binary (comma-separated, relative to the folder). */","atom":"a0","author":"init","version":0},{"n":113,"text":"export function meantBinary(args: Parsed): Set<string> {","atom":"a0","author":"init","version":0},{"n":114,"text":"\treturn new Set(","atom":"a0","author":"init","version":0},{"n":115,"text":"\t\t(str(args, \"binary\") ?? \"\")","atom":"a0","author":"init","version":0},{"n":116,"text":"\t\t\t.split(\",\")","atom":"a0","author":"init","version":0},{"n":117,"text":"\t\t\t.map((p) => p.trim().replace(/\\\\/g, \"/\").replace(/^\\.\\//, \"\"))","atom":"a0","author":"init","version":0},{"n":118,"text":"\t\t\t.filter((p) => p !== \"\"),","atom":"a0","author":"init","version":0},{"n":119,"text":"\t);","atom":"a0","author":"init","version":0},{"n":120,"text":"}","atom":"a0","author":"init","version":0},{"n":121,"text":"","atom":"a0","author":"init","version":0},{"n":122,"text":"/** One line naming the files left out, or none. */","atom":"a0","author":"init","version":0},{"n":123,"text":"export function leftOutText(leftOut: readonly LeftOut[]): string[] {","atom":"a0","author":"init","version":0},{"n":124,"text":"\tif (leftOut.length === 0) return [];","atom":"a0","author":"init","version":0},{"n":125,"text":"\tconst why = (f: LeftOut) => `${f.path}${f.kept ? \" (the server keeps its last version)\" : \"\"}`;","atom":"a0","author":"init","version":0},{"n":126,"text":"\treturn [","atom":"a0","author":"init","version":0},{"n":127,"text":"\t\t`Left out, over the server's ${MAX_BLOB_BYTES / 1024 / 1024} MB limit for one file: ${leftOut.map(why).join(\", \")}.`,","atom":"a0","author":"init","version":0},{"n":128,"text":"\t];","atom":"a0","author":"init","version":0},{"n":129,"text":"}","atom":"a0","author":"init","version":0},{"n":130,"text":"","atom":"a0","author":"init","version":0},{"n":131,"text":"/**","atom":"a50","author":"review","version":11},{"n":132,"text":" * A command that left files out for size did not do everything it was asked: say so in the exit code too, so","atom":"a50","author":"review","version":11},{"n":133,"text":" * a script, CI or an agent cannot read \"ok\" while a file is missing. Other exits (refused, queued) stay as they are.","atom":"a50","author":"review","version":11},{"n":134,"text":" */","atom":"a50","author":"review","version":11},{"n":135,"text":"export function withLeftOut(out: Output, leftOut: readonly LeftOut[]): Output {","atom":"a50","author":"review","version":11},{"n":136,"text":"\tif (leftOut.length === 0) return out;","atom":"a50","author":"review","version":11},{"n":137,"text":"\tconst text = out.text.includes(\"Left out,\") ? out.text : [out.text, ...leftOutText(leftOut)].join(\"\\n\");","atom":"a50","author":"review","version":11},{"n":138,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":139,"text":"\t\t...out,","atom":"a50","author":"review","version":11},{"n":140,"text":"\t\ttext: `${text}\\nExit ${EXIT.error}: ${leftOut.length} file${leftOut.length === 1 ? \" was\" : \"s were\"} not sent.`,","atom":"a50","author":"review","version":11},{"n":141,"text":"\t\tjson: { ...out.json, leftOut },","atom":"a50","author":"review","version":11},{"n":142,"text":"\t\texit: out.exit === undefined || out.exit === EXIT.ok ? EXIT.error : out.exit,","atom":"a50","author":"review","version":11},{"n":143,"text":"\t};","atom":"a50","author":"review","version":11},{"n":144,"text":"}","atom":"a50","author":"review","version":11},{"n":145,"text":"","atom":"a50","author":"review","version":11},{"n":146,"text":"/** Upload binary files' bytes before the record or init that names them, each hash once. */","atom":"a0","author":"init","version":0},{"n":147,"text":"export async function uploadBlobs(api: Api, blobs: ReadonlyMap<string, BlobToSend>): Promise<void> {","atom":"a0","author":"init","version":0},{"n":148,"text":"\tconst seen = new Set<string>();","atom":"a0","author":"init","version":0},{"n":149,"text":"\tfor (const b of blobs.values()) {","atom":"a0","author":"init","version":0},{"n":150,"text":"\t\tif (seen.has(b.sha)) continue;","atom":"a0","author":"init","version":0},{"n":151,"text":"\t\tseen.add(b.sha);","atom":"a0","author":"init","version":0},{"n":152,"text":"\t\tawait api.putBlob(b.sha, b.bytes);","atom":"a0","author":"init","version":0},{"n":153,"text":"\t}","atom":"a0","author":"init","version":0},{"n":154,"text":"}","atom":"a0","author":"init","version":0},{"n":155,"text":"","atom":"a0","author":"init","version":0},{"n":156,"text":"/**","atom":"a0","author":"init","version":0},{"n":157,"text":" * Whether the file at `rel` is as the server last gave it (or gone), so a sync","atom":"a0","author":"init","version":0},{"n":158,"text":" * may replace it: text compared with the known copy, a binary file by hash.","atom":"a0","author":"init","version":0},{"n":159,"text":" */","atom":"a0","author":"init","version":0},{"n":160,"text":"function untouchedOnDisk(","atom":"a0","author":"init","version":0},{"n":161,"text":"\troot: string,","atom":"a0","author":"init","version":0},{"n":162,"text":"\trel: string,","atom":"a0","author":"init","version":0},{"n":163,"text":"\tnow: OnDisk | undefined,","atom":"a0","author":"init","version":0},{"n":164,"text":"\tknownBlobs: ReadonlyMap<string, string>,","atom":"a0","author":"init","version":0},{"n":165,"text":"): boolean {","atom":"a0","author":"init","version":0},{"n":166,"text":"\tif (now === undefined) return true;","atom":"a0","author":"init","version":0},{"n":167,"text":"\tif (now.text !== undefined) {","atom":"a0","author":"init","version":0},{"n":168,"text":"\t\tconst known = readKnown(root, rel);","atom":"a0","author":"init","version":0},{"n":169,"text":"\t\t// A file the server keeps whole (#46) is known by its hash.","atom":"a0","author":"init","version":0},{"n":170,"text":"\t\treturn known !== undefined ? normalize(now.text) === known : keptWholeAs(normalize(now.text), knownBlobs.get(rel));","atom":"a0","author":"init","version":0},{"n":171,"text":"\t}","atom":"a0","author":"init","version":0},{"n":172,"text":"\tconst blob = knownBlobs.get(rel);","atom":"a0","author":"init","version":0},{"n":173,"text":"\tconst b = blobOf(absolute(root, rel));","atom":"a0","author":"init","version":0},{"n":174,"text":"\treturn blob !== undefined && b !== undefined && \"sha\" in b && b.sha === blob;","atom":"a0","author":"init","version":0},{"n":175,"text":"}","atom":"a0","author":"init","version":0},{"n":176,"text":"","atom":"a0","author":"init","version":0},{"n":177,"text":"/** Send what differs from the known copy. Used by record, publish and sync. */","atom":"a0","author":"init","version":0},{"n":178,"text":"/** Record the folder, holding its lock (#51): known copies, modes and blobs are rewritten. */","atom":"a0","author":"init","version":0},{"n":179,"text":"export async function recordFolder(","atom":"a0","author":"init","version":0},{"n":180,"text":"\troot: string,","atom":"a0","author":"init","version":0},{"n":181,"text":"\tapi: Api,","atom":"a0","author":"init","version":0},{"n":182,"text":"\tall = false,","atom":"a0","author":"init","version":0},{"n":183,"text":"\tbinary: ReadonlySet<string> = new Set(),","atom":"a0","author":"init","version":0},{"n":184,"text":"): Promise<Recorded> {","atom":"a0","author":"init","version":0},{"n":185,"text":"\treturn withFolderLock(root, \"record\", () => recordFolderLocked(root, api, all, binary));","atom":"a0","author":"init","version":0},{"n":186,"text":"}","atom":"a0","author":"init","version":0},{"n":187,"text":"","atom":"a0","author":"init","version":0},{"n":188,"text":"async function recordFolderLocked(","atom":"a0","author":"init","version":0},{"n":189,"text":"\troot: string,","atom":"a0","author":"init","version":0},{"n":190,"text":"\tapi: Api,","atom":"a0","author":"init","version":0},{"n":191,"text":"\tall: boolean,","atom":"a0","author":"init","version":0},{"n":192,"text":"\tbinary: ReadonlySet<string>,","atom":"a0","author":"init","version":0},{"n":193,"text":"): Promise<Recorded> {","atom":"a0","author":"init","version":0},{"n":194,"text":"\tif (isPaused(root))","atom":"a0","author":"init","version":0},{"n":195,"text":"\t\treturn {","atom":"a0","author":"init","version":0},{"n":196,"text":"\t\t\tsent: 0,","atom":"a0","author":"init","version":0},{"n":197,"text":"\t\t\tpaths: [],","atom":"a0","author":"init","version":0},{"n":198,"text":"\t\t\tdeleted: [],","atom":"a0","author":"init","version":0},{"n":199,"text":"\t\t\tpaused: true,","atom":"a0","author":"init","version":0},{"n":200,"text":"\t\t\tchanged: [],","atom":"a0","author":"init","version":0},{"n":201,"text":"\t\t\tnews: undefined,","atom":"a0","author":"init","version":0},{"n":202,"text":"\t\t\tleftOut: [],","atom":"a0","author":"init","version":0},{"n":203,"text":"\t\t\tturnedBinary: [],","atom":"a0","author":"init","version":0},{"n":204,"text":"\t\t};","atom":"a0","author":"init","version":0},{"n":205,"text":"\t// A reader records nothing (#37); the server would refuse it anyway.","atom":"a0","author":"init","version":0},{"n":206,"text":"\tif (isReader(root))","atom":"a0","author":"init","version":0},{"n":207,"text":"\t\treturn { sent: 0, paths: [], deleted: [], changed: [], news: undefined, leftOut: [], turnedBinary: [] };","atom":"a0","author":"init","version":0},{"n":208,"text":"\tconst { files, blobs, modes, leftOut, turnedBinary } = unrecorded(root, all, binary);","atom":"a0","author":"init","version":0},{"n":209,"text":"\tconst paths = [...new Set([...files.keys(), ...blobs.keys(), ...Object.keys(modes)])].sort();","atom":"a0","author":"init","version":0},{"n":210,"text":"\tconst knownBefore = new Set([...listKnown(root), ...readKnownBlobs(root).keys()]);","atom":"a0","author":"init","version":0},{"n":211,"text":"\tconst added = paths.filter((p) => files.get(p) !== null && !knownBefore.has(p));","atom":"a0","author":"init","version":0},{"n":212,"text":"\tconst sent = paths.length;","atom":"a0","author":"init","version":0},{"n":213,"text":"\tconst deleted = [...files]","atom":"a0","author":"init","version":0},{"n":214,"text":"\t\t.filter(([, text]) => text === null)","atom":"a0","author":"init","version":0},{"n":215,"text":"\t\t.map(([rel]) => rel)","atom":"a0","author":"init","version":0},{"n":216,"text":"\t\t.sort();","atom":"a0","author":"init","version":0},{"n":217,"text":"\tif (sent === 0) return { sent: 0, paths, deleted, changed: [], news: undefined, leftOut, turnedBinary };","atom":"a0","author":"init","version":0},{"n":218,"text":"\tconst items = paths.map((path) => ({","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":219,"text":"\t\tpath,","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":220,"text":"\t\t...(files.has(path) ? { text: files.get(path) } : {}),","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":221,"text":"\t\t...(modes[path] !== undefined ? { mode: modes[path] } : {}),","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":222,"text":"\t\t...(blobs.has(path) ? { blob: blobs.get(path)?.sha } : {}),","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":223,"text":"\t}));","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":224,"text":"\tconst batches = batchRecordItems(items);","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":225,"text":"\tlet batchBlobs = new Map<string, BlobToSend>();","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":226,"text":"\tconst uploaded = new Set<string>();","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":227,"text":"\tconst answers = await sendRecordBatches(","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":228,"text":"\t\tapi,","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":229,"text":"\t\tbatches,","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":230,"text":"\t\tasync (batch) => {","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":231,"text":"\t\t\tbatchBlobs = new Map(","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":232,"text":"\t\t\t\tbatch.paths.flatMap((path) => {","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":233,"text":"\t\t\t\t\tconst blob = blobs.get(path);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":234,"text":"\t\t\t\t\treturn blob === undefined ? [] : [[path, blob] as const];","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":235,"text":"\t\t\t\t}),","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":236,"text":"\t\t\t);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":237,"text":"\t\t\tfor (const [path, blob] of batchBlobs) {","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":238,"text":"\t\t\t\tif (uploaded.has(blob.sha)) continue;","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":239,"text":"\t\t\t\tawait uploadBlobs(api, new Map([[path, blob]]));","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":240,"text":"\t\t\t\tuploaded.add(blob.sha);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":241,"text":"\t\t\t}","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":242,"text":"\t\t},","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":243,"text":"\t\tasync (batch, answer) => {","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":244,"text":"\t\t\tconst batchFiles = new Map(Object.entries(batch.files));","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":245,"text":"\t\t\t// Commit known state only after this batch is confirmed; earlier successful batches stay committed on later failure.","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":246,"text":"\t\t\tfor (const [rel, text] of batchFiles) if (text === null) forgetKnown(root, rel);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":247,"text":"\t\t\tfor (const [rel, text] of batchFiles) if (text !== null) writeKnown(root, rel, text);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":248,"text":"\t\t\tconst knownBlobs = readKnownBlobs(root);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":249,"text":"\t\t\tif (Object.keys(batch.blobs).length > 0 || batch.paths.some((rel) => knownBlobs.has(rel))) {","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":250,"text":"\t\t\t\tfor (const rel of new Set([...Object.keys(batch.files), ...Object.keys(batch.blobs)])) knownBlobs.delete(rel);","atom":"a961","author":"codex-prose-authorship-1","version":108},{"n":251,"text":"\t\t\t\tfor (const [rel, sha] of Object.entries(batch.blobs)) {","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":252,"text":"\t\t\t\t\tforgetKnown(root, rel);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":253,"text":"\t\t\t\t\tknownBlobs.set(rel, sha);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":254,"text":"\t\t\t\t}","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":255,"text":"\t\t\t\twriteKnownBlobs(root, knownBlobs);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":256,"text":"\t\t\t}","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":257,"text":"\t\t\tconst gone = Object.entries(batch.files)","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":258,"text":"\t\t\t\t.filter(([, text]) => text === null)","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":259,"text":"\t\t\t\t.map(([rel]) => rel);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":260,"text":"\t\t\tconst knownModes = readKnownModes(root);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":261,"text":"\t\t\tif (Object.keys(batch.modes).length > 0 || gone.some((rel) => knownModes.has(rel))) {","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":262,"text":"\t\t\t\tfoldModes(knownModes, batch.modes, gone);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":263,"text":"\t\t\t\twriteKnownModes(root, knownModes);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":264,"text":"\t\t\t}","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":265,"text":"\t\t\theard(root, [","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":266,"text":"\t\t\t\t...newsLines(answer.news),","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":267,"text":"\t\t\t\t...(answer.spelling ?? []).map(spellingText),","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":268,"text":"\t\t\t\t...(answer.uncomposed ?? []).map(uncomposedText),","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":269,"text":"\t\t\t]);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":270,"text":"\t\t},","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":271,"text":"\t);","atom":"a958","author":"codex-prose-authorship-1","version":108},{"n":272,"text":"\tconst changed = answers.flatMap((answer) => (Array.isArray(answer.changed) ? answer.changed : []));","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":273,"text":"\tconst changedCount = answers.some((answer) => typeof answer.changed === \"number\")","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":274,"text":"\t\t? answers.reduce(","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":275,"text":"\t\t\t\t(sum, answer) =>","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":276,"text":"\t\t\t\t\tsum +","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":277,"text":"\t\t\t\t\t(typeof answer.changed === \"number\"","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":278,"text":"\t\t\t\t\t\t? answer.changed","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":279,"text":"\t\t\t\t\t\t: Array.isArray(answer.changed)","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":280,"text":"\t\t\t\t\t\t\t? answer.changed.length","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":281,"text":"\t\t\t\t\t\t\t: 0),","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":282,"text":"\t\t\t\t0,","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":283,"text":"\t\t\t)","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":284,"text":"\t\t: changed;","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":285,"text":"\tconst news = answers.flatMap((answer) => newsLines(answer.news));","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":286,"text":"\tconst spelling = answers.flatMap((answer) => answer.spelling ?? []);","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":287,"text":"\tconst uncomposed = answers.flatMap((answer) => answer.uncomposed ?? []);","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":288,"text":"\tconst answer = { changed: changedCount, news, spelling, uncomposed };","atom":"a955","author":"codex-prose-authorship-1","version":108},{"n":289,"text":"\tconst longPaths = longPathsOf(","atom":"a52","author":"review","version":12},{"n":290,"text":"\t\troot,","atom":"a52","author":"review","version":12},{"n":291,"text":"\t\t[...files].filter(([, text]) => text !== null).map(([path]) => path),","atom":"a52","author":"review","version":12},{"n":292,"text":"\t);","atom":"a52","author":"review","version":12},{"n":293,"text":"\tconst gitMarkers = [...files]","atom":"a52","author":"review","version":12},{"n":294,"text":"\t\t.flatMap(([path, text]) => {","atom":"a52","author":"review","version":12},{"n":295,"text":"\t\t\tconst line = text === null ? undefined : gitMarkerLine(text);","atom":"a52","author":"review","version":12},{"n":296,"text":"\t\t\treturn line === undefined ? [] : [{ path, line }];","atom":"a52","author":"review","version":12},{"n":297,"text":"\t\t})","atom":"a52","author":"review","version":12},{"n":298,"text":"\t\t.sort((a, b) => (a.path < b.path ? -1 : 1));","atom":"a52","author":"review","version":12},{"n":299,"text":"\treturn {","atom":"a52","author":"review","version":12},{"n":300,"text":"\t\tsent,","atom":"a52","author":"review","version":12},{"n":301,"text":"\t\tpaths,","atom":"a52","author":"review","version":12},{"n":302,"text":"\t\tdeleted,","atom":"a52","author":"review","version":12},{"n":303,"text":"\t\tadded,","atom":"a52","author":"review","version":12},{"n":304,"text":"\t\tchanged: answer.changed,","atom":"a52","author":"review","version":12},{"n":305,"text":"\t\tnews: answer.news,","atom":"a52","author":"review","version":12},{"n":306,"text":"\t\tleftOut,","atom":"a52","author":"review","version":12},{"n":307,"text":"\t\tturnedBinary,","atom":"a52","author":"review","version":12},{"n":308,"text":"\t\tgitMarkers,","atom":"a52","author":"review","version":12},{"n":309,"text":"\t\tlongPaths,","atom":"a52","author":"review","version":12},{"n":310,"text":"\t};","atom":"a52","author":"review","version":12},{"n":311,"text":"}","atom":"a52","author":"review","version":12},{"n":312,"text":"","atom":"a52","author":"review","version":12},{"n":313,"text":"/** A note per file that holds what looks like a git conflict: abso records it as it is, as text, and does not call it a collision. */","atom":"a52","author":"review","version":12},{"n":314,"text":"export function gitMarkerText(list: readonly { path: string; line: number }[] | undefined): string[] {","atom":"a52","author":"review","version":12},{"n":315,"text":"\treturn (list ?? []).map(","atom":"a52","author":"review","version":12},{"n":316,"text":"\t\t(m) =>","atom":"a52","author":"review","version":12},{"n":317,"text":"\t\t\t`Note: ${m.path} has lines that look like a git conflict (from line ${m.line}). abso records them as ordinary text and will push them as they are. If a merge was left unfinished, fix the file first.`,","atom":"a839","author":"rename","version":100},{"n":318,"text":"\t);","atom":"a52","author":"review","version":12},{"n":319,"text":"}","atom":"a52","author":"review","version":12},{"n":320,"text":"","atom":"a52","author":"review","version":12},{"n":321,"text":"/** Windows stops at 260 characters for a whole path, and another agent's folder may sit deeper than this one. */","atom":"a52","author":"review","version":12},{"n":322,"text":"const LONG_FULL_PATH = 240;","atom":"a52","author":"review","version":12},{"n":323,"text":"const LONG_RELATIVE_PATH = 160;","atom":"a52","author":"review","version":12},{"n":324,"text":"","atom":"a52","author":"review","version":12},{"n":325,"text":"/** The sent files whose path will likely fail to write on Windows: the whole path is near its limit here, or the part inside the folder is already long. */","atom":"a52","author":"review","version":12},{"n":326,"text":"export function longPathsOf(root: string, paths: Iterable<string>): { path: string; length: number }[] {","atom":"a52","author":"review","version":12},{"n":327,"text":"\treturn [...paths]","atom":"a52","author":"review","version":12},{"n":328,"text":"\t\t.map((path) => ({ path, length: absolute(root, path).length }))","atom":"a52","author":"review","version":12},{"n":329,"text":"\t\t.filter((p) => p.length >= LONG_FULL_PATH || p.path.length >= LONG_RELATIVE_PATH)","atom":"a52","author":"review","version":12},{"n":330,"text":"\t\t.sort((a, b) => (a.path < b.path ? -1 : 1));","atom":"a52","author":"review","version":12},{"n":331,"text":"}","atom":"a52","author":"review","version":12},{"n":332,"text":"","atom":"a52","author":"review","version":12},{"n":333,"text":"/** A note per long path: abso keeps it, but a Windows agent may not be able to write the file. */","atom":"a52","author":"review","version":12},{"n":334,"text":"export function longPathText(list: readonly { path: string; length: number }[] | undefined): string[] {","atom":"a52","author":"review","version":12},{"n":335,"text":"\treturn (list ?? []).map(","atom":"a52","author":"review","version":12},{"n":336,"text":"\t\t(p) =>","atom":"a52","author":"review","version":12},{"n":337,"text":"\t\t\t`Note: ${p.path} is ${p.path.length} characters inside the folder (${p.length} with this folder's location). Windows stops at 260 for a whole path, so an agent on Windows may be unable to write it. A shorter path avoids that.`,","atom":"a52","author":"review","version":12},{"n":338,"text":"\t);","atom":"a52","author":"review","version":12},{"n":339,"text":"}","atom":"a0","author":"init","version":0},{"n":340,"text":"","atom":"a0","author":"init","version":0},{"n":341,"text":"/** \"Recorded 3 files first: a, b, c.\" (names cut short past 8), or a word that the folder is paused. Empty when nothing was sent. */","atom":"a0","author":"init","version":0},{"n":342,"text":"export function recordedFirst(r: Recorded): string[] {","atom":"a0","author":"init","version":0},{"n":343,"text":"\tif (r.paused) return [\"Recording is paused (abso resume): your folder's changes were not sent first.\"];","atom":"a0","author":"init","version":0},{"n":344,"text":"\tif (r.sent === 0) return [];","atom":"a0","author":"init","version":0},{"n":345,"text":"\treturn [`Recorded first: ${recordedList(r)}.`, ...gitMarkerText(r.gitMarkers), ...longPathText(r.longPaths)];","atom":"a52","author":"review","version":12},{"n":346,"text":"}","atom":"a0","author":"init","version":0},{"n":347,"text":"","atom":"a0","author":"init","version":0},{"n":348,"text":"/** \"2 changed (a, b), 3 deleted (x, y, z)\": deletions said as such (#37: deleted files were read as edits). */","atom":"a346","author":"infra-split","version":37},{"n":349,"text":"function recordedList(r: Recorded): string {","atom":"a0","author":"init","version":0},{"n":350,"text":"\tconst names = (list: readonly string[]) =>","atom":"a0","author":"init","version":0},{"n":351,"text":"\t\tlist.length <= LISTED ? list.join(\", \") : `${list.slice(0, LISTED).join(\", \")}, and ${list.length - LISTED} more`;","atom":"a0","author":"init","version":0},{"n":352,"text":"\tconst gone = new Set(r.deleted);","atom":"a0","author":"init","version":0},{"n":353,"text":"\tconst fresh = new Set(r.added ?? []);","atom":"a0","author":"init","version":0},{"n":354,"text":"\tconst changed = r.paths.filter((p) => !gone.has(p) && !fresh.has(p));","atom":"a0","author":"init","version":0},{"n":355,"text":"\t// New files are named in full: they are the ones a script made and nobody remembers (#37).","atom":"a346","author":"infra-split","version":37},{"n":356,"text":"\treturn [","atom":"a0","author":"init","version":0},{"n":357,"text":"\t\t...(fresh.size > 0 ? [`${fresh.size} new (${[...fresh].join(\", \")})`] : []),","atom":"a0","author":"init","version":0},{"n":358,"text":"\t\t...(changed.length > 0 ? [`${changed.length} changed (${names(changed)})`] : []),","atom":"a0","author":"init","version":0},{"n":359,"text":"\t\t...(r.deleted.length > 0 ? [`${r.deleted.length} deleted (${names(r.deleted)})`] : []),","atom":"a0","author":"init","version":0},{"n":360,"text":"\t].join(\", \");","atom":"a0","author":"init","version":0},{"n":361,"text":"}","atom":"a0","author":"init","version":0},{"n":362,"text":"","atom":"a0","author":"init","version":0},{"n":363,"text":"export const READER_REFUSES =","atom":"a0","author":"init","version":0},{"n":364,"text":"\t\"this folder is a reader: it records and pushes nothing (abso reader off makes it a writer again)\";","atom":"a839","author":"rename","version":100},{"n":365,"text":"","atom":"a0","author":"init","version":0},{"n":366,"text":"/** abso pause: send nothing from the folder (no hook, no record) until abso resume. */","atom":"a0","author":"init","version":0},{"n":367,"text":"export async function runPause(_args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":368,"text":"\tconst { root } = open(env);","atom":"a0","author":"init","version":0},{"n":369,"text":"\tconst was = isPaused(root);","atom":"a0","author":"init","version":0},{"n":370,"text":"\twriteFileSync(pausedPath(root), `${new Date().toISOString()}\\n`);","atom":"a0","author":"init","version":0},{"n":371,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":372,"text":"\t\ttext: `${was ? \"Recording was already paused.\" : \"Recording is paused.\"} The edit hook sends nothing, abso record refuses, and other commands skip recording first. abso run still sends the folder as it is to the box. abso resume ends it.`,","atom":"a0","author":"init","version":0},{"n":373,"text":"\t\tjson: { paused: true },","atom":"a0","author":"init","version":0},{"n":374,"text":"\t};","atom":"a0","author":"init","version":0},{"n":375,"text":"}","atom":"a0","author":"init","version":0},{"n":376,"text":"","atom":"a0","author":"init","version":0},{"n":377,"text":"export async function runResume(_args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":378,"text":"\tconst { root } = open(env);","atom":"a0","author":"init","version":0},{"n":379,"text":"\tconst was = isPaused(root);","atom":"a0","author":"init","version":0},{"n":380,"text":"\trmSync(pausedPath(root), { force: true });","atom":"a0","author":"init","version":0},{"n":381,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":382,"text":"\t\ttext: was","atom":"a0","author":"init","version":0},{"n":383,"text":"\t\t\t? \"Recording again. Changes made while paused go at the next abso record (or push, pull, ...); abso status lists them.\"","atom":"a839","author":"rename","version":100},{"n":384,"text":"\t\t\t: \"Recording was not paused.\",","atom":"a0","author":"init","version":0},{"n":385,"text":"\t\tjson: { paused: false },","atom":"a0","author":"init","version":0},{"n":386,"text":"\t};","atom":"a0","author":"init","version":0},{"n":387,"text":"}","atom":"a0","author":"init","version":0},{"n":388,"text":"","atom":"a0","author":"init","version":0},{"n":389,"text":"export async function runRecord(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":390,"text":"\tif (isReader(findRoot(env.cwd) ?? env.cwd)) throw new UsageError(READER_REFUSES);","atom":"a0","author":"init","version":0},{"n":391,"text":"\tconst { root, api } = open(env);","atom":"a0","author":"init","version":0},{"n":392,"text":"\tif (isPaused(root))","atom":"a0","author":"init","version":0},{"n":393,"text":"\t\treturn {","atom":"a0","author":"init","version":0},{"n":394,"text":"\t\t\texit: EXIT.refused,","atom":"a0","author":"init","version":0},{"n":395,"text":"\t\t\ttext: \"Not recorded: recording is paused. abso resume, then abso record.\",","atom":"a0","author":"init","version":0},{"n":396,"text":"\t\t\tjson: { paused: true },","atom":"a0","author":"init","version":0},{"n":397,"text":"\t\t};","atom":"a0","author":"init","version":0},{"n":398,"text":"\tconst r = await recordFolder(root, api, bool(args, \"all\"), meantBinary(args));","atom":"a0","author":"init","version":0},{"n":399,"text":"\tconst changed = Array.isArray(r.changed) ? r.changed.length : r.changed;","atom":"a0","author":"init","version":0},{"n":400,"text":"\tconst text =","atom":"a0","author":"init","version":0},{"n":401,"text":"\t\tr.sent === 0","atom":"a0","author":"init","version":0},{"n":402,"text":"\t\t\t? \"Nothing to record: the folder matches what the server has.\"","atom":"a0","author":"init","version":0},{"n":403,"text":"\t\t\t: `Recorded ${recordedList(r)}${changed === undefined ? \"\" : `; ${changed} changed on the server`}.`;","atom":"a0","author":"init","version":0},{"n":404,"text":"\treturn withLeftOut(","atom":"a50","author":"review","version":11},{"n":405,"text":"\t\t{","atom":"a50","author":"review","version":11},{"n":406,"text":"\t\t\ttext: [","atom":"a52","author":"review","version":12},{"n":407,"text":"\t\t\t\t...turnedBinaryText(r.turnedBinary),","atom":"a52","author":"review","version":12},{"n":408,"text":"\t\t\t\ttext,","atom":"a52","author":"review","version":12},{"n":409,"text":"\t\t\t\t...gitMarkerText(r.gitMarkers),","atom":"a52","author":"review","version":12},{"n":410,"text":"\t\t\t\t...longPathText(r.longPaths),","atom":"a52","author":"review","version":12},{"n":411,"text":"\t\t\t\t...leftOutText(r.leftOut),","atom":"a52","author":"review","version":12},{"n":412,"text":"\t\t\t].join(\"\\n\"),","atom":"a52","author":"review","version":12},{"n":413,"text":"\t\t\tjson: {","atom":"a50","author":"review","version":11},{"n":414,"text":"\t\t\t\tsent: r.sent,","atom":"a50","author":"review","version":11},{"n":415,"text":"\t\t\t\tchanged: r.changed ?? null,","atom":"a50","author":"review","version":11},{"n":416,"text":"\t\t\t\tnews: newsLines(r.news),","atom":"a50","author":"review","version":11},{"n":417,"text":"\t\t\t\tleftOut: r.leftOut,","atom":"a50","author":"review","version":11},{"n":418,"text":"\t\t\t\tturnedBinary: r.turnedBinary,","atom":"a50","author":"review","version":11},{"n":419,"text":"\t\t\t\tgitMarkers: r.gitMarkers ?? [],","atom":"a52","author":"review","version":12},{"n":420,"text":"\t\t\t\tlongPaths: r.longPaths ?? [],","atom":"a52","author":"review","version":12},{"n":421,"text":"\t\t\t},","atom":"a50","author":"review","version":11},{"n":422,"text":"\t\t},","atom":"a0","author":"init","version":0},{"n":423,"text":"\t\tr.leftOut,","atom":"a50","author":"review","version":11},{"n":424,"text":"\t);","atom":"a50","author":"review","version":11},{"n":425,"text":"}","atom":"a0","author":"init","version":0},{"n":426,"text":"","atom":"a0","author":"init","version":0},{"n":427,"text":"// --- writing answers into the folder ---","atom":"a0","author":"init","version":0},{"n":428,"text":"","atom":"a0","author":"init","version":0},{"n":429,"text":"/**","atom":"a0","author":"init","version":0},{"n":430,"text":" * Bring the folder to shared and set the agent's base. Writes only files that","atom":"a0","author":"init","version":0},{"n":431,"text":" * still match the known copy (or are new), so unrecorded work is never","atom":"a0","author":"init","version":0},{"n":432,"text":" * overwritten.","atom":"a0","author":"init","version":0},{"n":433,"text":" */","atom":"a0","author":"init","version":0},{"n":434,"text":"export async function syncFolder(root: string, api: Api, full = false): Promise<Applied> {","atom":"a0","author":"init","version":0},{"n":435,"text":"\tconst applied = await applyAnswer(root, api, await pullAnswer(root, api, full));","atom":"a2754","author":"pinch","version":280},{"n":436,"text":"\tpullWritten(root);","atom":"a2754","author":"pinch","version":280},{"n":437,"text":"\treturn applied;","atom":"a2754","author":"pinch","version":280},{"n":438,"text":"}","atom":"a2754","author":"pinch","version":280},{"n":439,"text":"","atom":"a2754","author":"pinch","version":280},{"n":440,"text":"const PULLING_FILE = \"pulling.json\";","atom":"a2754","author":"pinch","version":280},{"n":441,"text":"","atom":"a2754","author":"pinch","version":280},{"n":442,"text":"/**","atom":"a2754","author":"pinch","version":280},{"n":443,"text":" * Whether a pull here asked the server and never wrote its answer (abso-core 26): it timed out, or stopped","atom":"a2754","author":"pinch","version":280},{"n":444,"text":" * partway. The server moved the agent's base when it answered, and later pulls send only what changed since","atom":"a2754","author":"pinch","version":280},{"n":445,"text":" * that base, so the files it would have written stay behind until a pull asks for every file.","atom":"a2754","author":"pinch","version":280},{"n":446,"text":" */","atom":"a2754","author":"pinch","version":280},{"n":447,"text":"export function pullUnfinished(root: string): boolean {","atom":"a2754","author":"pinch","version":280},{"n":448,"text":"\treturn existsSync(join(stateDir(root), PULLING_FILE));","atom":"a2754","author":"pinch","version":280},{"n":449,"text":"}","atom":"a2754","author":"pinch","version":280},{"n":450,"text":"","atom":"a2754","author":"pinch","version":280},{"n":451,"text":"/**","atom":"a2754","author":"pinch","version":280},{"n":452,"text":" * Ask the server for a pull, noting first that one is under way, so a pull whose answer never gets written","atom":"a2754","author":"pinch","version":280},{"n":453,"text":" * leaves the note behind. With that note, or `full`, it asks for every file in the agent's view, which the","atom":"a2754","author":"pinch","version":280},{"n":454,"text":" * folder's own checks then write only where the folder differs. pullWritten takes the note away.","atom":"a2754","author":"pinch","version":280},{"n":455,"text":" */","atom":"a2754","author":"pinch","version":280},{"n":456,"text":"export async function pullAnswer(root: string, api: Api, full = false): Promise<SyncAnswer> {","atom":"a2754","author":"pinch","version":280},{"n":457,"text":"\tconst unfinished = pullUnfinished(root);","atom":"a2754","author":"pinch","version":280},{"n":458,"text":"\twriteFileAtomic(join(stateDir(root), PULLING_FILE), `${JSON.stringify({ at: new Date().toISOString() })}\\n`);","atom":"a2754","author":"pinch","version":280},{"n":459,"text":"\tif (!full && !unfinished) return api.sync();","atom":"a2754","author":"pinch","version":280},{"n":460,"text":"\ttry {","atom":"a2754","author":"pinch","version":280},{"n":461,"text":"\t\treturn await api.sync({ full: true });","atom":"a2754","author":"pinch","version":280},{"n":462,"text":"\t} catch (err) {","atom":"a2754","author":"pinch","version":280},{"n":463,"text":"\t\t// A server from before full pulls (501): the plain pull is still better than none.","atom":"a2754","author":"pinch","version":280},{"n":464,"text":"\t\tif (unfinished && !full && err instanceof ApiError && err.status === 501) return api.sync();","atom":"a2754","author":"pinch","version":280},{"n":465,"text":"\t\tthrow err;","atom":"a2754","author":"pinch","version":280},{"n":466,"text":"\t}","atom":"a2754","author":"pinch","version":280},{"n":467,"text":"}","atom":"a2754","author":"pinch","version":280},{"n":468,"text":"","atom":"a2754","author":"pinch","version":280},{"n":469,"text":"/** The pull's answer is written into the folder: take away pullAnswer's note. */","atom":"a2754","author":"pinch","version":280},{"n":470,"text":"export function pullWritten(root: string): void {","atom":"a2754","author":"pinch","version":280},{"n":471,"text":"\trmSync(join(stateDir(root), PULLING_FILE), { force: true });","atom":"a2754","author":"pinch","version":280},{"n":472,"text":"}","atom":"a2754","author":"pinch","version":280},{"n":473,"text":"","atom":"a2754","author":"pinch","version":280},{"n":474,"text":"/** Status's line, and pull's when it caught up. */","atom":"a2754","author":"pinch","version":280},{"n":475,"text":"export function pullUnfinishedText(root: string): string[] {","atom":"a2754","author":"pinch","version":280},{"n":476,"text":"\treturn pullUnfinished(root)","atom":"a2754","author":"pinch","version":280},{"n":477,"text":"\t\t? [","atom":"a2754","author":"pinch","version":280},{"n":478,"text":"\t\t\t\t\"A pull here didn't finish (its answer never arrived or wasn't written), so files may be behind this folder's base. abso pull fetches every file and writes the ones that differ.\",","atom":"a2754","author":"pinch","version":280},{"n":479,"text":"\t\t\t]","atom":"a2754","author":"pinch","version":280},{"n":480,"text":"\t\t: [];","atom":"a2754","author":"pinch","version":280},{"n":481,"text":"}","atom":"a0","author":"init","version":0},{"n":482,"text":"","atom":"a0","author":"init","version":0},{"n":483,"text":"/** What writing a sync or switch answer into the folder did. */","atom":"a0","author":"init","version":0},{"n":484,"text":"export interface Applied {","atom":"a0","author":"init","version":0},{"n":485,"text":"\treadonly version: number;","atom":"a0","author":"init","version":0},{"n":486,"text":"\treadonly written: string[];","atom":"a0","author":"init","version":0},{"n":487,"text":"\treadonly deleted: string[];","atom":"a0","author":"init","version":0},{"n":488,"text":"\treadonly kept: string[];","atom":"a0","author":"init","version":0},{"n":489,"text":"\treadonly dropped: string[];","atom":"a0","author":"init","version":0},{"n":490,"text":"\treadonly collisions: readonly Collision[];","atom":"a0","author":"init","version":0},{"n":491,"text":"\t/** Text files the answer deleted and wrote again under a new path, paired as git pairs renames. Each is in `written` and `deleted` too. */","atom":"a0","author":"init","version":0},{"n":492,"text":"\treadonly renamed: readonly { readonly from: string; readonly to: string }[];","atom":"a0","author":"init","version":0},{"n":493,"text":"\t/** Paths in the answer that were not touched: outside the folder, into .git/.claude/.avcs, a device, or through a link (safety.ts). */","atom":"a0","author":"init","version":0},{"n":494,"text":"\treadonly refused: readonly Refused[];","atom":"a0","author":"init","version":0},{"n":495,"text":"\t/** Lines both sides changed that the server merged item by item. */","atom":"a0","author":"init","version":0},{"n":496,"text":"\treadonly merged: readonly MergedLine[];","atom":"a0","author":"init","version":0},{"n":497,"text":"\t/** Files a sync couldn't write here, this one or an earlier one, still stale (#51): path -> when and why. */","atom":"a0","author":"init","version":0},{"n":498,"text":"\treadonly unwritten: Readonly<Record<string, Unwritten>>;","atom":"a0","author":"init","version":0},{"n":499,"text":"}","atom":"a0","author":"init","version":0},{"n":500,"text":"","atom":"a0","author":"init","version":0},{"n":501,"text":"/** How many names a summary line shows before \"and N more\". */","atom":"a0","author":"init","version":0},{"n":502,"text":"export const LISTED = 8;","atom":"a0","author":"init","version":0},{"n":503,"text":"/** How far back an empty publish looks for this agent's last publish. */","atom":"a0","author":"init","version":0},{"n":504,"text":"export const FOLDER_LOG_LIMIT = 200;","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":" * The files a sync or switch changed. A line per kind, with the names cut","atom":"a0","author":"init","version":0},{"n":508,"text":" * short past LISTED (a big sync used to print a line per file); --verbose","atom":"a0","author":"init","version":0},{"n":509,"text":" * gives a line per file.","atom":"a0","author":"init","version":0},{"n":510,"text":" */","atom":"a0","author":"init","version":0},{"n":511,"text":"export function changedFilesText(","atom":"a0","author":"init","version":0},{"n":512,"text":"\tcommand: string,","atom":"a0","author":"init","version":0},{"n":513,"text":"\twritten: readonly string[],","atom":"a0","author":"init","version":0},{"n":514,"text":"\tdeleted: readonly string[],","atom":"a0","author":"init","version":0},{"n":515,"text":"\trenamed: readonly { readonly from: string; readonly to: string }[],","atom":"a0","author":"init","version":0},{"n":516,"text":"\tverbose: boolean,","atom":"a0","author":"init","version":0},{"n":517,"text":"): string[] {","atom":"a0","author":"init","version":0},{"n":518,"text":"\tconst moves = renamed.map((r) => `${r.from} -> ${r.to}`);","atom":"a0","author":"init","version":0},{"n":519,"text":"\tif (verbose)","atom":"a0","author":"init","version":0},{"n":520,"text":"\t\treturn [","atom":"a0","author":"init","version":0},{"n":521,"text":"\t\t\t...written.map((f) => `  updated ${f}`),","atom":"a0","author":"init","version":0},{"n":522,"text":"\t\t\t...deleted.map((f) => `  deleted ${f}`),","atom":"a0","author":"init","version":0},{"n":523,"text":"\t\t\t...moves.map((m) => `  renamed ${m}`),","atom":"a0","author":"init","version":0},{"n":524,"text":"\t\t];","atom":"a0","author":"init","version":0},{"n":525,"text":"\tconst some = (names: readonly string[]) =>","atom":"a0","author":"init","version":0},{"n":526,"text":"\t\tnames.length <= LISTED","atom":"a0","author":"init","version":0},{"n":527,"text":"\t\t\t? names.join(\", \")","atom":"a0","author":"init","version":0},{"n":528,"text":"\t\t\t: `${names.slice(0, LISTED).join(\", \")}, and ${names.length - LISTED} more`;","atom":"a0","author":"init","version":0},{"n":529,"text":"\treturn [","atom":"a0","author":"init","version":0},{"n":530,"text":"\t\t...(written.length > 0 ? [`  updated: ${some(written)}`] : []),","atom":"a0","author":"init","version":0},{"n":531,"text":"\t\t...(deleted.length > 0 ? [`  deleted: ${some(deleted)}`] : []),","atom":"a0","author":"init","version":0},{"n":532,"text":"\t\t...(moves.length > 0 ? [`  renamed: ${some(moves)}`] : []),","atom":"a0","author":"init","version":0},{"n":533,"text":"\t\t...([written, deleted, moves].some((l) => l.length > LISTED)","atom":"a0","author":"init","version":0},{"n":534,"text":"\t\t\t? [`  (abso ${command} --verbose lists every file)`]","atom":"a0","author":"init","version":0},{"n":535,"text":"\t\t\t: []),","atom":"a0","author":"init","version":0},{"n":536,"text":"\t];","atom":"a0","author":"init","version":0},{"n":537,"text":"}","atom":"a0","author":"init","version":0},{"n":538,"text":"","atom":"a0","author":"init","version":0},{"n":539,"text":"/** A file a sync couldn't write (#51): the server takes the folder to have `version`'s text, so no later sync sends it again. */","atom":"a0","author":"init","version":0},{"n":540,"text":"export interface Unwritten {","atom":"a0","author":"init","version":0},{"n":541,"text":"\treadonly version: number;","atom":"a0","author":"init","version":0},{"n":542,"text":"\treadonly why: string;","atom":"a0","author":"init","version":0},{"n":543,"text":"}","atom":"a0","author":"init","version":0},{"n":544,"text":"","atom":"a0","author":"init","version":0},{"n":545,"text":"const UNWRITTEN_FILE = \"unwritten.json\";","atom":"a0","author":"init","version":0},{"n":546,"text":"","atom":"a0","author":"init","version":0},{"n":547,"text":"/** Files earlier syncs couldn't write here, kept in .avcs/unwritten.json until a write of them works. */","atom":"a0","author":"init","version":0},{"n":548,"text":"export function readUnwritten(root: string): Record<string, Unwritten> {","atom":"a0","author":"init","version":0},{"n":549,"text":"\ttry {","atom":"a0","author":"init","version":0},{"n":550,"text":"\t\treturn JSON.parse(readFileSync(join(stateDir(root), UNWRITTEN_FILE), \"utf8\")) as Record<string, Unwritten>;","atom":"a99","author":"review","version":17},{"n":551,"text":"\t} catch {","atom":"a0","author":"init","version":0},{"n":552,"text":"\t\treturn {};","atom":"a0","author":"init","version":0},{"n":553,"text":"\t}","atom":"a0","author":"init","version":0},{"n":554,"text":"}","atom":"a0","author":"init","version":0},{"n":555,"text":"","atom":"a0","author":"init","version":0},{"n":556,"text":"/** Status's line for them, and sync's for ones an earlier sync named. */","atom":"a0","author":"init","version":0},{"n":557,"text":"export function unwrittenText(","atom":"a0","author":"init","version":0},{"n":558,"text":"\tunwritten: Readonly<Record<string, Unwritten>>,","atom":"a0","author":"init","version":0},{"n":559,"text":"\tskip: ReadonlySet<string> = new Set(),","atom":"a0","author":"init","version":0},{"n":560,"text":"): string[] {","atom":"a0","author":"init","version":0},{"n":561,"text":"\tconst paths = Object.keys(unwritten)","atom":"a0","author":"init","version":0},{"n":562,"text":"\t\t.filter((p) => !skip.has(p))","atom":"a0","author":"init","version":0},{"n":563,"text":"\t\t.sort();","atom":"a0","author":"init","version":0},{"n":564,"text":"\tif (paths.length === 0) return [];","atom":"a0","author":"init","version":0},{"n":565,"text":"\tconst list = paths.map((p) => `${p} (version ${unwritten[p]!.version}: ${unwritten[p]!.why})`).join(\", \");","atom":"a0","author":"init","version":0},{"n":566,"text":"\treturn [","atom":"a0","author":"init","version":0},{"n":567,"text":"\t\t`Stale here: a pull couldn't write ${paths.length === 1 ? \"this file\" : \"these files\"}, and no later pull sends ${paths.length === 1 ? \"it\" : \"them\"} again. Close whatever holds ${paths.length === 1 ? \"it\" : \"them\"}, then abso pull --full: ${list}`,","atom":"a839","author":"rename","version":100},{"n":568,"text":"\t];","atom":"a0","author":"init","version":0},{"n":569,"text":"}","atom":"a0","author":"init","version":0},{"n":570,"text":"","atom":"a0","author":"init","version":0},{"n":571,"text":"/** Write the files a sync or switch answer lists into the folder (the same rules as sync). */","atom":"a0","author":"init","version":0},{"n":572,"text":"/** Write a sync's answer into the folder, holding its lock (#51). */","atom":"a0","author":"init","version":0},{"n":573,"text":"export async function applyAnswer(root: string, api: Api, unscreened: SyncAnswer): Promise<Applied> {","atom":"a0","author":"init","version":0},{"n":574,"text":"\treturn withFolderLock(root, \"pull\", () => applyAnswerLocked(root, api, unscreened));","atom":"a839","author":"rename","version":100},{"n":575,"text":"}","atom":"a0","author":"init","version":0},{"n":576,"text":"","atom":"a0","author":"init","version":0},{"n":577,"text":"async function applyAnswerLocked(root: string, api: Api, unscreened: SyncAnswer): Promise<Applied> {","atom":"a0","author":"init","version":0},{"n":578,"text":"\t// Other agents' paths: nothing outside this folder, in .git/.claude/.avcs, or through a link.","atom":"a0","author":"init","version":0},{"n":579,"text":"\tconst { answer, refused } = screenAnswer(root, unscreened);","atom":"a0","author":"init","version":0},{"n":580,"text":"\t// A write the disk refuses anyway is named and skipped, so the rest of the sync still lands with its","atom":"a0","author":"init","version":0},{"n":581,"text":"\t// known copies and modes, rather than stopping partway (git checks every path first).","atom":"a312","author":"infra-split","version":37},{"n":582,"text":"\tconst failed = new Set<string>();","atom":"a0","author":"init","version":0},{"n":583,"text":"\t// Remembered until a write works (#51): the server won't send these files again.","atom":"a0","author":"init","version":0},{"n":584,"text":"\tconst unwritten = readUnwritten(root);","atom":"a0","author":"init","version":0},{"n":585,"text":"\tconst unwrittenBefore = JSON.stringify(unwritten);","atom":"a0","author":"init","version":0},{"n":586,"text":"\tconst tryWrite = (rel: string, write: () => void): boolean => {","atom":"a0","author":"init","version":0},{"n":587,"text":"\t\ttry {","atom":"a0","author":"init","version":0},{"n":588,"text":"\t\t\twrite();","atom":"a0","author":"init","version":0},{"n":589,"text":"\t\t\tdelete unwritten[rel];","atom":"a0","author":"init","version":0},{"n":590,"text":"\t\t\treturn true;","atom":"a0","author":"init","version":0},{"n":591,"text":"\t\t} catch (e) {","atom":"a0","author":"init","version":0},{"n":592,"text":"\t\t\tfailed.add(rel);","atom":"a0","author":"init","version":0},{"n":593,"text":"\t\t\tconst code = (e as NodeJS.ErrnoException).code ?? (e as Error).message;","atom":"a0","author":"init","version":0},{"n":594,"text":"\t\t\trefused.push({ path: rel, why: `writing it here failed (${code})` });","atom":"a0","author":"init","version":0},{"n":595,"text":"\t\t\tunwritten[rel] = { version: answer.version, why: code };","atom":"a0","author":"init","version":0},{"n":596,"text":"\t\t\treturn false;","atom":"a0","author":"init","version":0},{"n":597,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":598,"text":"\t};","atom":"a0","author":"init","version":0},{"n":599,"text":"\tconst written: string[] = [];","atom":"a0","author":"init","version":0},{"n":600,"text":"\tconst deleted: string[] = [];","atom":"a0","author":"init","version":0},{"n":601,"text":"\tconst kept: string[] = [];","atom":"a0","author":"init","version":0},{"n":602,"text":"\t// Text that left one path and arrived at a new one, to tell renames from a delete and an add.","atom":"a0","author":"init","version":0},{"n":603,"text":"\tconst gone: FileChange[] = [];","atom":"a0","author":"init","version":0},{"n":604,"text":"\tconst arrived: FileChange[] = [];","atom":"a0","author":"init","version":0},{"n":605,"text":"\t// Local-only files (.claude/, ...) the server still holds: never written here,","atom":"a0","author":"init","version":0},{"n":606,"text":"\t// and sent back as deleted so they leave this agent's view and draft.","atom":"a0","author":"init","version":0},{"n":607,"text":"\tconst dropped = new Set<string>();","atom":"a0","author":"init","version":0},{"n":608,"text":"\tconst knownModes = readKnownModes(root);","atom":"a0","author":"init","version":0},{"n":609,"text":"\tconst knownBlobs = readKnownBlobs(root);","atom":"a0","author":"init","version":0},{"n":610,"text":"\tconst blobsBefore = JSON.stringify([...knownBlobs]);","atom":"a0","author":"init","version":0},{"n":611,"text":"\tfor (const c of answer.collisions ?? [])","atom":"a0","author":"init","version":0},{"n":612,"text":"\t\tif (isLocalOnly(c.file) && unsafePath(c.file) === undefined) dropped.add(c.file);","atom":"a0","author":"init","version":0},{"n":613,"text":"\t// Deletions first: on a case-insensitive disk a rename from a.ts to A.ts is one file, and","atom":"a0","author":"init","version":0},{"n":614,"text":"\t// writing A.ts before deleting a.ts would delete the new file.","atom":"a0","author":"init","version":0},{"n":615,"text":"\tconst entries = Object.entries(answer.files).sort(([, a], [, b]) => Number(a !== null) - Number(b !== null));","atom":"a0","author":"init","version":0},{"n":616,"text":"\t// Files new to the folder get the line endings git would give them, asked once for all of them.","atom":"a0","author":"init","version":0},{"n":617,"text":"\tconst fresh = newFileEndings(","atom":"a0","author":"init","version":0},{"n":618,"text":"\t\troot,","atom":"a0","author":"init","version":0},{"n":619,"text":"\t\tentries","atom":"a0","author":"init","version":0},{"n":620,"text":"\t\t\t.filter(([rel, text]) => text !== null && !isLocalOnly(rel) && !existsSync(absolute(root, rel)))","atom":"a0","author":"init","version":0},{"n":621,"text":"\t\t\t.map(([rel]) => rel),","atom":"a0","author":"init","version":0},{"n":622,"text":"\t);","atom":"a0","author":"init","version":0},{"n":623,"text":"\tfor (const [rel, text] of entries) {","atom":"a0","author":"init","version":0},{"n":624,"text":"\t\tif (isLocalOnly(rel)) {","atom":"a0","author":"init","version":0},{"n":625,"text":"\t\t\tif (text !== null) dropped.add(rel);","atom":"a0","author":"init","version":0},{"n":626,"text":"\t\t\tforgetKnown(root, rel);","atom":"a0","author":"init","version":0},{"n":627,"text":"\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":628,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":629,"text":"\t\tconst path = absolute(root, rel);","atom":"a0","author":"init","version":0},{"n":630,"text":"\t\t// Judged by its mode: a link is \"\" and is never followed.","atom":"a0","author":"init","version":0},{"n":631,"text":"\t\tconst now = onDisk(path, knownModes.get(rel) ?? PLAIN);","atom":"a0","author":"init","version":0},{"n":632,"text":"\t\tconst raw = now?.text;","atom":"a0","author":"init","version":0},{"n":633,"text":"\t\tconst disk = raw === undefined ? undefined : normalize(raw);","atom":"a0","author":"init","version":0},{"n":634,"text":"\t\tconst untouched = untouchedOnDisk(root, rel, now, knownBlobs);","atom":"a0","author":"init","version":0},{"n":635,"text":"\t\tif (text === null) {","atom":"a0","author":"init","version":0},{"n":636,"text":"\t\t\tif (!untouched) {","atom":"a0","author":"init","version":0},{"n":637,"text":"\t\t\t\tkept.push(rel);","atom":"a0","author":"init","version":0},{"n":638,"text":"\t\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":639,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":640,"text":"\t\t\tconst was = readKnown(root, rel);","atom":"a0","author":"init","version":0},{"n":641,"text":"\t\t\tif (was !== undefined) gone.push({ path: rel, before: was, after: null });","atom":"a0","author":"init","version":0},{"n":642,"text":"\t\t\tremoveFile(path);","atom":"a0","author":"init","version":0},{"n":643,"text":"\t\t\tforgetKnown(root, rel);","atom":"a0","author":"init","version":0},{"n":644,"text":"\t\t\tknownModes.delete(rel);","atom":"a0","author":"init","version":0},{"n":645,"text":"\t\t\tknownBlobs.delete(rel);","atom":"a0","author":"init","version":0},{"n":646,"text":"\t\t\tdelete unwritten[rel];","atom":"a0","author":"init","version":0},{"n":647,"text":"\t\t\tdeleted.push(rel);","atom":"a0","author":"init","version":0},{"n":648,"text":"\t\t} else {","atom":"a0","author":"init","version":0},{"n":649,"text":"\t\t\tif (disk === text) {","atom":"a0","author":"init","version":0},{"n":650,"text":"\t\t\t\twriteKnown(root, rel, text);","atom":"a0","author":"init","version":0},{"n":651,"text":"\t\t\t\tknownBlobs.delete(rel);","atom":"a0","author":"init","version":0},{"n":652,"text":"\t\t\t\tdelete unwritten[rel];","atom":"a0","author":"init","version":0},{"n":653,"text":"\t\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":654,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":655,"text":"\t\t\tif (!untouched) {","atom":"a0","author":"init","version":0},{"n":656,"text":"\t\t\t\tkept.push(rel);","atom":"a0","author":"init","version":0},{"n":657,"text":"\t\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":658,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":659,"text":"\t\t\tif (!tryWrite(rel, () => writeFileAtomic(path, withEndingsOf(text, raw, fresh.get(rel))))) continue;","atom":"a0","author":"init","version":0},{"n":660,"text":"\t\t\tif (now === undefined) arrived.push({ path: rel, before: null, after: text });","atom":"a0","author":"init","version":0},{"n":661,"text":"\t\t\twriteKnown(root, rel, text);","atom":"a0","author":"init","version":0},{"n":662,"text":"\t\t\tknownBlobs.delete(rel);","atom":"a0","author":"init","version":0},{"n":663,"text":"\t\t\twritten.push(rel);","atom":"a0","author":"init","version":0},{"n":664,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":665,"text":"\t}","atom":"a0","author":"init","version":0},{"n":666,"text":"\t// Binary files: fetch the bytes the answer names, with the same care for unrecorded work.","atom":"a0","author":"init","version":0},{"n":667,"text":"\tfor (const [rel, sha] of Object.entries(answer.blobs ?? {})) {","atom":"a0","author":"init","version":0},{"n":668,"text":"\t\tif (sha === null || isLocalOnly(rel)) continue;","atom":"a0","author":"init","version":0},{"n":669,"text":"\t\tconst path = absolute(root, rel);","atom":"a0","author":"init","version":0},{"n":670,"text":"\t\tconst now = onDisk(path, knownModes.get(rel) ?? PLAIN);","atom":"a0","author":"init","version":0},{"n":671,"text":"\t\tconst b = now === undefined ? undefined : blobOf(path);","atom":"a0","author":"init","version":0},{"n":672,"text":"\t\t// Already this file: the same bytes, or (a file kept whole, #46) the same text with any line endings.","atom":"a0","author":"init","version":0},{"n":673,"text":"\t\tif (","atom":"a0","author":"init","version":0},{"n":674,"text":"\t\t\t(b !== undefined && \"sha\" in b && b.sha === sha) ||","atom":"a0","author":"init","version":0},{"n":675,"text":"\t\t\t(now?.text !== undefined && keptWholeAs(normalize(now.text), sha))","atom":"a0","author":"init","version":0},{"n":676,"text":"\t\t) {","atom":"a0","author":"init","version":0},{"n":677,"text":"\t\t\tforgetKnown(root, rel);","atom":"a0","author":"init","version":0},{"n":678,"text":"\t\t\tknownBlobs.set(rel, sha);","atom":"a0","author":"init","version":0},{"n":679,"text":"\t\t\tdelete unwritten[rel];","atom":"a0","author":"init","version":0},{"n":680,"text":"\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":681,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":682,"text":"\t\tif (!untouchedOnDisk(root, rel, now, knownBlobs)) {","atom":"a0","author":"init","version":0},{"n":683,"text":"\t\t\tkept.push(rel);","atom":"a0","author":"init","version":0},{"n":684,"text":"\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":685,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":686,"text":"\t\tconst bytes = await api.getBlob(sha);","atom":"a0","author":"init","version":0},{"n":687,"text":"\t\tif (!tryWrite(rel, () => writeFileAtomic(path, bytes))) continue;","atom":"a0","author":"init","version":0},{"n":688,"text":"\t\tforgetKnown(root, rel);","atom":"a0","author":"init","version":0},{"n":689,"text":"\t\tknownBlobs.set(rel, sha);","atom":"a0","author":"init","version":0},{"n":690,"text":"\t\twritten.push(rel);","atom":"a0","author":"init","version":0},{"n":691,"text":"\t}","atom":"a0","author":"init","version":0},{"n":692,"text":"\tif (JSON.stringify([...knownBlobs]) !== blobsBefore) writeKnownBlobs(root, knownBlobs);","atom":"a0","author":"init","version":0},{"n":693,"text":"\t// Modes after text: a link replaces the \"\" just written, and the bit goes on the file as written.","atom":"a0","author":"init","version":0},{"n":694,"text":"\tfor (const [rel, m] of Object.entries(answer.modes ?? {})) {","atom":"a0","author":"init","version":0},{"n":695,"text":"\t\tif (isLocalOnly(rel) || kept.includes(rel) || answer.files[rel] === null || failed.has(rel)) continue;","atom":"a0","author":"init","version":0},{"n":696,"text":"\t\tconst was = knownModes.get(rel) ?? PLAIN;","atom":"a0","author":"init","version":0},{"n":697,"text":"\t\tconst mode: FullMode = { exec: m.exec ?? was.exec, link: m.link === undefined ? was.link : m.link };","atom":"a0","author":"init","version":0},{"n":698,"text":"\t\tif (!tryWrite(rel, () => applyMode(absolute(root, rel), mode))) continue;","atom":"a0","author":"init","version":0},{"n":699,"text":"\t\tknownModes.set(rel, mode);","atom":"a0","author":"init","version":0},{"n":700,"text":"\t\tif (!written.includes(rel)) written.push(rel);","atom":"a0","author":"init","version":0},{"n":701,"text":"\t}","atom":"a0","author":"init","version":0},{"n":702,"text":"\twriteKnownModes(root, knownModes);","atom":"a0","author":"init","version":0},{"n":703,"text":"\tif (dropped.size > 0) {","atom":"a0","author":"init","version":0},{"n":704,"text":"\t\theard(root, (await api.record(Object.fromEntries([...dropped].map((rel) => [rel, null])))).news);","atom":"a0","author":"init","version":0},{"n":705,"text":"\t\tfor (const rel of dropped) forgetKnown(root, rel);","atom":"a0","author":"init","version":0},{"n":706,"text":"\t}","atom":"a0","author":"init","version":0},{"n":707,"text":"\tconst collisions = (answer.collisions ?? []).filter((c) => !isLocalOnly(c.file));","atom":"a0","author":"init","version":0},{"n":708,"text":"\tconst renamed =","atom":"a0","author":"init","version":0},{"n":709,"text":"\t\tgone.length > 0 && arrived.length > 0","atom":"a0","author":"init","version":0},{"n":710,"text":"\t\t\t? pairRenames([...gone, ...arrived])","atom":"a0","author":"init","version":0},{"n":711,"text":"\t\t\t\t\t.filter((f) => f.from !== undefined)","atom":"a0","author":"init","version":0},{"n":712,"text":"\t\t\t\t\t.map((f) => ({ from: f.from!, to: f.path }))","atom":"a0","author":"init","version":0},{"n":713,"text":"\t\t\t: [];","atom":"a0","author":"init","version":0},{"n":714,"text":"\tif (JSON.stringify(unwritten) !== unwrittenBefore)","atom":"a0","author":"init","version":0},{"n":715,"text":"\t\twriteFileAtomic(join(stateDir(root), UNWRITTEN_FILE), `${JSON.stringify(unwritten, null, 1)}\\n`);","atom":"a99","author":"review","version":17},{"n":716,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":717,"text":"\t\tversion: answer.version,","atom":"a0","author":"init","version":0},{"n":718,"text":"\t\twritten,","atom":"a0","author":"init","version":0},{"n":719,"text":"\t\tdeleted,","atom":"a0","author":"init","version":0},{"n":720,"text":"\t\tkept,","atom":"a0","author":"init","version":0},{"n":721,"text":"\t\tdropped: [...dropped].sort(),","atom":"a0","author":"init","version":0},{"n":722,"text":"\t\tcollisions,","atom":"a0","author":"init","version":0},{"n":723,"text":"\t\trenamed,","atom":"a0","author":"init","version":0},{"n":724,"text":"\t\trefused,","atom":"a0","author":"init","version":0},{"n":725,"text":"\t\tmerged: answer.merged ?? [],","atom":"a0","author":"init","version":0},{"n":726,"text":"\t\tunwritten,","atom":"a0","author":"init","version":0},{"n":727,"text":"\t};","atom":"a0","author":"init","version":0},{"n":728,"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":"a50","author":"review","message":"","time":1791513140032,"timeIso":"2026-10-09T02:32:20.032Z","publish":{"draft":null,"version":11,"agent":"review","message":"Exit 1 when a file is left out for size: record and publish say so and still send the rest. Measured on abso 156: both exited 0 with a 21 MB file missing, so a script or CI read success. withLeftOut in commands.ts, used by record and publish; the existing blobs test now expects exit 1 and the left-out line and JSON (client suite: 170 pass). init is unchanged (its exit stays 0).","time":1791513140032,"timeIso":"2026-10-09T02:32:20.032Z"}},{"atom":"a52","author":"review","message":"","time":1791514003159,"timeIso":"2026-10-09T02:46:43.159Z","publish":{"draft":null,"version":12,"agent":"review","message":"record and publish note two things git users know the hard way, without blocking. (1) A file that holds what looks like a git conflict (a '<<<<<<< ' line, a '=======' line, then a '>>>>>>> ' line, other than abso's own blocks) gets: 'Note: <file> has lines that look like a git conflict (from line N)...'. (2) A sent path of 160+ characters inside the folder, or 240+ with the folder's location, gets a note that Windows stops at 260. Both are one line per file, only when the file is sent, and the JSON carries gitMarkers and longPaths. gitMarkerLine is in settle.ts, longPathsOf in commands.ts. Tests: three new ones; the whole suite passes (702) and biome ci is clean.","time":1791514010730,"timeIso":"2026-10-09T02:46:50.730Z"}},{"atom":"a99","author":"review","message":"","time":1791522261912,"timeIso":"2026-10-09T05:04:21.912Z","publish":{"draft":null,"version":17,"agent":"review","message":"New folders keep their state in .abso/, and the machine's sign-in, servers and admin token are read from ~/.abso/ first, then ~/.avcs/. A folder made before, with only .avcs/, is untouched: it keeps working, is never half-moved, and no older client or mod loses it. stateDir(root) and homeFile/homeWritePath are in the new client/src/state-dir.ts and replace the old AVCS_DIR constant everywhere. abso login writes only to ~/.abso/ and leaves ~/.avcs/ alone; logout removes both copies. The edit mod and the view mod read either folder. .abso is skipped like .avcs (including its odd spellings), the git exclude names whichever folder is in use, and the messages name .abso. Not changed: avcs.json (the server reads that name, so abso.json needs the server to learn it first), .avcsignore, env var names and wire headers. Tests: 709 run, 708 pass (one is skipped), including new ones for the folder choice, the home-file order and box sign-in; biome ci has no errors.","time":1791522270512,"timeIso":"2026-10-09T05:04:30.512Z"}},{"atom":"a312","author":"infra-split","message":"","time":1791546813593,"timeIso":"2026-10-09T11:53:33.593Z","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":"a346","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":"a839","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":"a955","author":"codex-prose-authorship-1","message":"","time":1791787492161,"timeIso":"2026-10-12T06:44:52.161Z","publish":{"draft":null,"version":108,"agent":"codex-prose-authorship-1","message":"Implement bounded sequential client recording for #606","time":1791788591360,"timeIso":"2026-10-12T07:03:11.360Z"}},{"atom":"a958","author":"codex-prose-authorship-1","message":"","time":1791787560319,"timeIso":"2026-10-12T06:46:00.319Z","publish":{"draft":null,"version":108,"agent":"codex-prose-authorship-1","message":"Implement bounded sequential client recording for #606","time":1791788591360,"timeIso":"2026-10-12T07:03:11.360Z"}},{"atom":"a961","author":"codex-prose-authorship-1","message":"","time":1791787653396,"timeIso":"2026-10-12T06:47:33.396Z","publish":{"draft":null,"version":108,"agent":"codex-prose-authorship-1","message":"Implement bounded sequential client recording for #606","time":1791788591360,"timeIso":"2026-10-12T07:03:11.360Z"}},{"atom":"a2754","author":"pinch","message":"","time":1792113574328,"timeIso":"2026-10-16T01:19:34.328Z","publish":{"draft":null,"version":280,"agent":"pinch","message":"A pull whose answer never arrives no longer leaves the folder behind\n\nThe server moves the agent's base when it answers a pull, and later pulls send only what changed since that base. When the answer was lost (a timeout on a slow server), the files it carried were never written, and every later pull, status, restore and export agreed the folder was current.\n\nNow the client notes a pull in .abso/pulling.json before asking, and takes the note away once the answer is written. While the note is there, abso status says a pull didn't finish, and the next pull asks for every file in the view (as pull --full does) and writes the ones that differ, keeping work done in the folder meanwhile, as every pull does. follow, draft switching and draft-pull pull the same way. A server without full pulls gets a plain pull.\n\nTests: client/test/lost-pull.test.ts (a fake server that carries out a pull and drops its answer), plus held-push, join-signed-out and record-batches: 19 pass. tsc and Biome clean.","time":1792113718029,"timeIso":"2026-10-16T01:21:58.029Z"}},{"atom":"a2755","author":"pinch","message":"","time":1792113575069,"timeIso":"2026-10-16T01:19:35.069Z","publish":{"draft":null,"version":280,"agent":"pinch","message":"A pull whose answer never arrives no longer leaves the folder behind\n\nThe server moves the agent's base when it answers a pull, and later pulls send only what changed since that base. When the answer was lost (a timeout on a slow server), the files it carried were never written, and every later pull, status, restore and export agreed the folder was current.\n\nNow the client notes a pull in .abso/pulling.json before asking, and takes the note away once the answer is written. While the note is there, abso status says a pull didn't finish, and the next pull asks for every file in the view (as pull --full does) and writes the ones that differ, keeping work done in the folder meanwhile, as every pull does. follow, draft switching and draft-pull pull the same way. A server without full pulls gets a plain pull.\n\nTests: client/test/lost-pull.test.ts (a fake server that carries out a pull and drops its answer), plus held-push, join-signed-out and record-batches: 19 pass. tsc and Biome clean.","time":1792113718029,"timeIso":"2026-10-16T01:21:58.029Z"}}]}