{"file":"client/src/folder.ts","version":318,"total":481,"from":1,"to":481,"lines":[{"n":1,"text":"// The agent's folder: which files count, reading them as text, and the","atom":"a0","author":"init","version":0},{"n":2,"text":"// known copy.","atom":"a0","author":"init","version":0},{"n":3,"text":"//","atom":"a0","author":"init","version":0},{"n":4,"text":"// The known copy (.avcs/known/<path>) is each file as the server's view of","atom":"a0","author":"init","version":0},{"n":5,"text":"// this agent has it, as far as the client knows. `record` sends the files","atom":"a0","author":"init","version":0},{"n":6,"text":"// that differ from it, the hook checks an edit against it before sending the","atom":"a0","author":"init","version":0},{"n":7,"text":"// edit, and `sync` only overwrites files that still match it.","atom":"a0","author":"init","version":0},{"n":8,"text":"//","atom":"a0","author":"init","version":0},{"n":9,"text":"// Skipped everywhere: .git, .avcs, .claude and node_modules, plus what git's","atom":"a0","author":"init","version":0},{"n":10,"text":"// ignore rules leave out: every .gitignore and .absoignore in the folder,","atom":"a206","author":"review","version":27},{"n":11,"text":"// .git/info/exclude and git's global excludes file (core.ts has the rules).","atom":"a0","author":"init","version":0},{"n":12,"text":"","atom":"a0","author":"init","version":0},{"n":13,"text":"import { execFileSync } from \"node:child_process\";","atom":"a0","author":"init","version":0},{"n":14,"text":"import {","atom":"a0","author":"init","version":0},{"n":15,"text":"\tappendFileSync,","atom":"a0","author":"init","version":0},{"n":16,"text":"\texistsSync,","atom":"a0","author":"init","version":0},{"n":17,"text":"\tmkdirSync,","atom":"a0","author":"init","version":0},{"n":18,"text":"\treaddirSync,","atom":"a0","author":"init","version":0},{"n":19,"text":"\treadFileSync,","atom":"a0","author":"init","version":0},{"n":20,"text":"\trenameSync,","atom":"a0","author":"init","version":0},{"n":21,"text":"\trmSync,","atom":"a0","author":"init","version":0},{"n":22,"text":"\tstatSync,","atom":"a0","author":"init","version":0},{"n":23,"text":"\tunlinkSync,","atom":"a0","author":"init","version":0},{"n":24,"text":"\twriteFileSync,","atom":"a0","author":"init","version":0},{"n":25,"text":"} from \"node:fs\";","atom":"a0","author":"init","version":0},{"n":26,"text":"import { homedir } from \"node:os\";","atom":"a0","author":"init","version":0},{"n":27,"text":"import { dirname, join, relative, sep } from \"node:path\";","atom":"a0","author":"init","version":0},{"n":28,"text":"import { blobOf, keptWholeAs, readKnownBlobs } from \"./blobs.ts\";","atom":"a0","author":"init","version":0},{"n":29,"text":"import type { CleanFiles } from \"./clean-files.ts\";","atom":"a441","author":"speed","version":44},{"n":30,"text":"import { type GitHome, gitIgnoreSetup, type Ignore, isLocalOnly, makeIgnore, normalize, readAllSync } from \"./core.ts\";","atom":"a0","author":"init","version":0},{"n":31,"text":"import { FILE_MODE, type Mode, modeChange, onDisk, PLAIN, readKnownModes } from \"./modes.ts\";","atom":"a441","author":"speed","version":44},{"n":32,"text":"import { stateDir } from \"./state-dir.ts\";","atom":"a103","author":"review","version":17},{"n":33,"text":"","atom":"a0","author":"init","version":0},{"n":34,"text":"export { type Ignore, isLocalOnly, normalize, withEndingsOf } from \"./core.ts\";","atom":"a0","author":"init","version":0},{"n":35,"text":"/** Files bigger than this are not sent as text. */","atom":"a0","author":"init","version":0},{"n":36,"text":"export const MAX_TEXT_BYTES = 2 * 1024 * 1024;","atom":"a0","author":"init","version":0},{"n":37,"text":"","atom":"a0","author":"init","version":0},{"n":38,"text":"const KNOWN = \"known\";","atom":"a0","author":"init","version":0},{"n":39,"text":"","atom":"a0","author":"init","version":0},{"n":40,"text":"export function toPosix(path: string): string {","atom":"a0","author":"init","version":0},{"n":41,"text":"\treturn sep === \"/\" ? path : path.split(sep).join(\"/\");","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":"export function absolute(root: string, rel: string): string {","atom":"a0","author":"init","version":0},{"n":45,"text":"\treturn join(root, ...insideParts(rel));","atom":"a0","author":"init","version":0},{"n":46,"text":"}","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":" * A folder-relative path's parts, refusing any that would leave the folder","atom":"a0","author":"init","version":0},{"n":50,"text":" * (.., an absolute path, a drive). Answers from the server are screened","atom":"a0","author":"init","version":0},{"n":51,"text":" * before this (safety.ts); this is the last line, so a path that slipped","atom":"a0","author":"init","version":0},{"n":52,"text":" * through throws instead of being written.","atom":"a0","author":"init","version":0},{"n":53,"text":" */","atom":"a0","author":"init","version":0},{"n":54,"text":"function insideParts(rel: string): string[] {","atom":"a0","author":"init","version":0},{"n":55,"text":"\tconst parts = rel.split(\"/\");","atom":"a0","author":"init","version":0},{"n":56,"text":"\tconst bad =","atom":"a0","author":"init","version":0},{"n":57,"text":"\t\trel === \"\" ||","atom":"a0","author":"init","version":0},{"n":58,"text":"\t\trel.startsWith(\"/\") ||","atom":"a0","author":"init","version":0},{"n":59,"text":"\t\t/^[A-Za-z]:/.test(rel) ||","atom":"a0","author":"init","version":0},{"n":60,"text":"\t\tparts.some((p) => p === \"..\" || p === \".\" || p === \"\" || (sep === \"\\\\\" && p.includes(\"\\\\\")));","atom":"a0","author":"init","version":0},{"n":61,"text":"\tif (bad) throw new Error(`refusing a path that would leave the folder: ${JSON.stringify(rel)}`);","atom":"a0","author":"init","version":0},{"n":62,"text":"\treturn parts;","atom":"a0","author":"init","version":0},{"n":63,"text":"}","atom":"a0","author":"init","version":0},{"n":64,"text":"","atom":"a0","author":"init","version":0},{"n":65,"text":"/** The folder-relative path of an absolute path, or undefined when it is outside the folder. */","atom":"a0","author":"init","version":0},{"n":66,"text":"export function relativeTo(root: string, path: string): string | undefined {","atom":"a0","author":"init","version":0},{"n":67,"text":"\tconst rel = relative(root, path);","atom":"a0","author":"init","version":0},{"n":68,"text":"\tif (rel === \"\" || rel.startsWith(\"..\") || /^[a-zA-Z]:/.test(rel) || rel.startsWith(sep)) return undefined;","atom":"a0","author":"init","version":0},{"n":69,"text":"\treturn toPosix(rel);","atom":"a0","author":"init","version":0},{"n":70,"text":"}","atom":"a0","author":"init","version":0},{"n":71,"text":"","atom":"a0","author":"init","version":0},{"n":72,"text":"// --- ignore rules ---","atom":"a0","author":"init","version":0},{"n":73,"text":"","atom":"a0","author":"init","version":0},{"n":74,"text":"/** Where git looks for its global files, from the environment. */","atom":"a0","author":"init","version":0},{"n":75,"text":"export function gitHome(env: Readonly<Record<string, string | undefined>> = process.env): GitHome {","atom":"a0","author":"init","version":0},{"n":76,"text":"\treturn { home: env.HOME || homedir(), ...(env.XDG_CONFIG_HOME ? { xdgConfigHome: env.XDG_CONFIG_HOME } : {}) };","atom":"a0","author":"init","version":0},{"n":77,"text":"}","atom":"a0","author":"init","version":0},{"n":78,"text":"","atom":"a0","author":"init","version":0},{"n":79,"text":"function readOrUndefined(path: string): string | undefined {","atom":"a0","author":"init","version":0},{"n":80,"text":"\ttry {","atom":"a0","author":"init","version":0},{"n":81,"text":"\t\treturn readFileSync(path, \"utf8\");","atom":"a0","author":"init","version":0},{"n":82,"text":"\t} catch {","atom":"a0","author":"init","version":0},{"n":83,"text":"\t\treturn undefined;","atom":"a0","author":"init","version":0},{"n":84,"text":"\t}","atom":"a0","author":"init","version":0},{"n":85,"text":"}","atom":"a0","author":"init","version":0},{"n":86,"text":"","atom":"a0","author":"init","version":0},{"n":87,"text":"/** The folder's ignore rules. Ignore files are read when a question first reaches their folder. */","atom":"a0","author":"init","version":0},{"n":88,"text":"export function loadIgnore(root: string, where: GitHome = gitHome()): Ignore {","atom":"a0","author":"init","version":0},{"n":89,"text":"\tconst git = readAllSync(gitIgnoreSetup(root, where), readOrUndefined);","atom":"a0","author":"init","version":0},{"n":90,"text":"\treturn makeIgnore((rel) => readOrUndefined(absolute(root, rel)), git);","atom":"a0","author":"init","version":0},{"n":91,"text":"}","atom":"a0","author":"init","version":0},{"n":92,"text":"","atom":"a0","author":"init","version":0},{"n":93,"text":"// --- walking and reading ---","atom":"a0","author":"init","version":0},{"n":94,"text":"","atom":"a0","author":"init","version":0},{"n":95,"text":"/** Every file in the folder that the ignore rules keep, as sorted folder-relative paths. */","atom":"a0","author":"init","version":0},{"n":96,"text":"export function walk(root: string, ignore: Ignore = loadIgnore(root)): string[] {","atom":"a0","author":"init","version":0},{"n":97,"text":"\tconst out: string[] = [];","atom":"a0","author":"init","version":0},{"n":98,"text":"\tconst visit = (dir: string, prefix: string): void => {","atom":"a0","author":"init","version":0},{"n":99,"text":"\t\tfor (const entry of readdirSync(dir, { withFileTypes: true })) {","atom":"a0","author":"init","version":0},{"n":100,"text":"\t\t\tconst rel = prefix === \"\" ? entry.name : `${prefix}/${entry.name}`;","atom":"a0","author":"init","version":0},{"n":101,"text":"\t\t\tif (entry.isDirectory()) {","atom":"a0","author":"init","version":0},{"n":102,"text":"\t\t\t\tif (!ignore(rel, true)) visit(join(dir, entry.name), rel);","atom":"a0","author":"init","version":0},{"n":103,"text":"\t\t\t} else if (entry.isFile() || entry.isSymbolicLink()) {","atom":"a0","author":"init","version":0},{"n":104,"text":"\t\t\t\t// A link is a file of its own (its target is its mode); it is never followed.","atom":"a0","author":"init","version":0},{"n":105,"text":"\t\t\t\tif (!ignore(rel, false)) out.push(rel);","atom":"a0","author":"init","version":0},{"n":106,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":107,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":108,"text":"\t};","atom":"a0","author":"init","version":0},{"n":109,"text":"\tvisit(root, \"\");","atom":"a0","author":"init","version":0},{"n":110,"text":"\treturn out.sort();","atom":"a0","author":"init","version":0},{"n":111,"text":"}","atom":"a0","author":"init","version":0},{"n":112,"text":"","atom":"a0","author":"init","version":0},{"n":113,"text":"const DECODER = new TextDecoder(\"utf-8\", { fatal: true, ignoreBOM: true });","atom":"a0","author":"init","version":0},{"n":114,"text":"","atom":"a0","author":"init","version":0},{"n":115,"text":"/** The bytes as text, or undefined when they are binary (a NUL byte or invalid UTF-8) or too big. */","atom":"a0","author":"init","version":0},{"n":116,"text":"export function asText(bytes: Uint8Array): string | undefined {","atom":"a0","author":"init","version":0},{"n":117,"text":"\tif (bytes.length > MAX_TEXT_BYTES || bytes.includes(0)) return undefined;","atom":"a0","author":"init","version":0},{"n":118,"text":"\ttry {","atom":"a0","author":"init","version":0},{"n":119,"text":"\t\treturn DECODER.decode(bytes);","atom":"a0","author":"init","version":0},{"n":120,"text":"\t} catch {","atom":"a0","author":"init","version":0},{"n":121,"text":"\t\treturn undefined;","atom":"a0","author":"init","version":0},{"n":122,"text":"\t}","atom":"a0","author":"init","version":0},{"n":123,"text":"}","atom":"a0","author":"init","version":0},{"n":124,"text":"","atom":"a0","author":"init","version":0},{"n":125,"text":"/** A file's text, undefined when missing or not text. */","atom":"a0","author":"init","version":0},{"n":126,"text":"export function readText(path: string): string | undefined {","atom":"a0","author":"init","version":0},{"n":127,"text":"\ttry {","atom":"a0","author":"init","version":0},{"n":128,"text":"\t\treturn asText(readFileSync(path));","atom":"a0","author":"init","version":0},{"n":129,"text":"\t} catch {","atom":"a0","author":"init","version":0},{"n":130,"text":"\t\treturn undefined;","atom":"a0","author":"init","version":0},{"n":131,"text":"\t}","atom":"a0","author":"init","version":0},{"n":132,"text":"}","atom":"a0","author":"init","version":0},{"n":133,"text":"","atom":"a0","author":"init","version":0},{"n":134,"text":"/**","atom":"a0","author":"init","version":0},{"n":135,"text":" * A file the client doesn't send: over the server's limit for one file","atom":"a0","author":"init","version":0},{"n":136,"text":" * (MAX_BLOB_BYTES). `kept` is set when the server still has the file's last","atom":"a0","author":"init","version":0},{"n":137,"text":" * version, which stays.","atom":"a0","author":"init","version":0},{"n":138,"text":" */","atom":"a0","author":"init","version":0},{"n":139,"text":"export interface LeftOut {","atom":"a0","author":"init","version":0},{"n":140,"text":"\treadonly path: string;","atom":"a0","author":"init","version":0},{"n":141,"text":"\treadonly reason: \"too big\";","atom":"a0","author":"init","version":0},{"n":142,"text":"\treadonly kept?: boolean;","atom":"a0","author":"init","version":0},{"n":143,"text":"}","atom":"a0","author":"init","version":0},{"n":144,"text":"","atom":"a0","author":"init","version":0},{"n":145,"text":"/**","atom":"a0","author":"init","version":0},{"n":146,"text":" * A file the server has as text that now reads as binary: almost always an","atom":"a0","author":"init","version":0},{"n":147,"text":" * accident (a stray NUL byte), so it is not sent until it is fixed or","atom":"a0","author":"init","version":0},{"n":148,"text":" * `--binary` says it is meant. `offset` and `line` say where the first bad","atom":"a0","author":"init","version":0},{"n":149,"text":" * byte is.","atom":"a0","author":"init","version":0},{"n":150,"text":" */","atom":"a0","author":"init","version":0},{"n":151,"text":"export interface TurnedBinary {","atom":"a0","author":"init","version":0},{"n":152,"text":"\treadonly path: string;","atom":"a0","author":"init","version":0},{"n":153,"text":"\treadonly why: \"a NUL byte\" | \"bytes that are not UTF-8\";","atom":"a0","author":"init","version":0},{"n":154,"text":"\treadonly offset: number;","atom":"a0","author":"init","version":0},{"n":155,"text":"\treadonly line: number;","atom":"a0","author":"init","version":0},{"n":156,"text":"}","atom":"a0","author":"init","version":0},{"n":157,"text":"","atom":"a0","author":"init","version":0},{"n":158,"text":"/** Where a would-be text file first stops being text. */","atom":"a0","author":"init","version":0},{"n":159,"text":"export function firstBadByte(bytes: Uint8Array): { why: TurnedBinary[\"why\"]; offset: number; line: number } {","atom":"a0","author":"init","version":0},{"n":160,"text":"\tlet offset = bytes.indexOf(0);","atom":"a0","author":"init","version":0},{"n":161,"text":"\tlet why: TurnedBinary[\"why\"] = \"a NUL byte\";","atom":"a0","author":"init","version":0},{"n":162,"text":"\t// Before any NUL, look for the first byte that breaks UTF-8.","atom":"a0","author":"init","version":0},{"n":163,"text":"\tconst end = offset < 0 ? bytes.length : offset;","atom":"a0","author":"init","version":0},{"n":164,"text":"\tfor (let i = 0; i < end; ) {","atom":"a0","author":"init","version":0},{"n":165,"text":"\t\tconst b = bytes[i]!;","atom":"a0","author":"init","version":0},{"n":166,"text":"\t\tconst need = b < 0x80 ? 0 : b >= 0xc2 && b < 0xe0 ? 1 : b >= 0xe0 && b < 0xf0 ? 2 : b >= 0xf0 && b < 0xf5 ? 3 : -1;","atom":"a0","author":"init","version":0},{"n":167,"text":"\t\tlet ok = need >= 0 && i + need < bytes.length;","atom":"a0","author":"init","version":0},{"n":168,"text":"\t\tfor (let k = 1; ok && k <= need; k++) ok = (bytes[i + k]! & 0xc0) === 0x80;","atom":"a0","author":"init","version":0},{"n":169,"text":"\t\tif (!ok) {","atom":"a0","author":"init","version":0},{"n":170,"text":"\t\t\toffset = i;","atom":"a0","author":"init","version":0},{"n":171,"text":"\t\t\twhy = \"bytes that are not UTF-8\";","atom":"a0","author":"init","version":0},{"n":172,"text":"\t\t\tbreak;","atom":"a0","author":"init","version":0},{"n":173,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":174,"text":"\t\ti += need + 1;","atom":"a0","author":"init","version":0},{"n":175,"text":"\t}","atom":"a0","author":"init","version":0},{"n":176,"text":"\tif (offset < 0) offset = 0;","atom":"a0","author":"init","version":0},{"n":177,"text":"\tlet line = 1;","atom":"a0","author":"init","version":0},{"n":178,"text":"\tfor (let i = 0; i < offset; i++) if (bytes[i] === 0x0a) line++;","atom":"a0","author":"init","version":0},{"n":179,"text":"\treturn { why, offset, line };","atom":"a0","author":"init","version":0},{"n":180,"text":"}","atom":"a0","author":"init","version":0},{"n":181,"text":"","atom":"a0","author":"init","version":0},{"n":182,"text":"/** A binary file (or text too big to diff) to send as a blob: its hash and bytes. */","atom":"a0","author":"init","version":0},{"n":183,"text":"export interface BlobToSend {","atom":"a0","author":"init","version":0},{"n":184,"text":"\treadonly sha: string;","atom":"a0","author":"init","version":0},{"n":185,"text":"\treadonly bytes: Uint8Array;","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":"/**","atom":"a0","author":"init","version":0},{"n":189,"text":" * Every file in the folder, in the server's form: text files (empty ones too)","atom":"a0","author":"init","version":0},{"n":190,"text":" * as text, binary files and text over MAX_TEXT_BYTES as blobs, the modes that","atom":"a0","author":"init","version":0},{"n":191,"text":" * aren't plain, and the files over the server's limit, left out.","atom":"a0","author":"init","version":0},{"n":192,"text":" */","atom":"a0","author":"init","version":0},{"n":193,"text":"export function readFolder(","atom":"a0","author":"init","version":0},{"n":194,"text":"\troot: string,","atom":"a0","author":"init","version":0},{"n":195,"text":"\tignore: Ignore = loadIgnore(root),","atom":"a0","author":"init","version":0},{"n":196,"text":"): { files: Map<string, string>; blobs: Map<string, BlobToSend>; modes: Record<string, Mode>; leftOut: LeftOut[] } {","atom":"a0","author":"init","version":0},{"n":197,"text":"\tconst files = new Map<string, string>();","atom":"a0","author":"init","version":0},{"n":198,"text":"\tconst blobs = new Map<string, BlobToSend>();","atom":"a0","author":"init","version":0},{"n":199,"text":"\tconst modes: Record<string, Mode> = {};","atom":"a0","author":"init","version":0},{"n":200,"text":"\tconst leftOut: LeftOut[] = [];","atom":"a0","author":"init","version":0},{"n":201,"text":"\tfor (const rel of walk(root, ignore)) {","atom":"a0","author":"init","version":0},{"n":202,"text":"\t\tconst d = onDisk(absolute(root, rel));","atom":"a0","author":"init","version":0},{"n":203,"text":"\t\tif (d === undefined) continue;","atom":"a0","author":"init","version":0},{"n":204,"text":"\t\tif (d.text === undefined) {","atom":"a0","author":"init","version":0},{"n":205,"text":"\t\t\tconst b = blobOf(absolute(root, rel));","atom":"a0","author":"init","version":0},{"n":206,"text":"\t\t\tif (b === undefined) continue;","atom":"a0","author":"init","version":0},{"n":207,"text":"\t\t\tif (\"tooBig\" in b) {","atom":"a0","author":"init","version":0},{"n":208,"text":"\t\t\t\tleftOut.push({ path: rel, reason: \"too big\" });","atom":"a0","author":"init","version":0},{"n":209,"text":"\t\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":210,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":211,"text":"\t\t\tblobs.set(rel, { sha: b.sha, bytes: b.bytes });","atom":"a0","author":"init","version":0},{"n":212,"text":"\t\t} else {","atom":"a0","author":"init","version":0},{"n":213,"text":"\t\t\tfiles.set(rel, normalize(d.text));","atom":"a0","author":"init","version":0},{"n":214,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":215,"text":"\t\tconst change = modeChange(PLAIN, d);","atom":"a0","author":"init","version":0},{"n":216,"text":"\t\tif (change) modes[rel] = change;","atom":"a0","author":"init","version":0},{"n":217,"text":"\t}","atom":"a0","author":"init","version":0},{"n":218,"text":"\treturn { files, blobs, modes, leftOut };","atom":"a0","author":"init","version":0},{"n":219,"text":"}","atom":"a0","author":"init","version":0},{"n":220,"text":"","atom":"a0","author":"init","version":0},{"n":221,"text":"/** Waits between rename tries, about a second in all: Windows refuses a rename while an editor, a scanner or an indexer holds the file. */","atom":"a0","author":"init","version":0},{"n":222,"text":"const RENAME_WAITS_MS = [10, 30, 100, 250, 600];","atom":"a0","author":"init","version":0},{"n":223,"text":"/** The errors a held file gives on Windows; anything else fails at once. */","atom":"a0","author":"init","version":0},{"n":224,"text":"const HELD = new Set([\"EPERM\", \"EACCES\", \"EBUSY\"]);","atom":"a0","author":"init","version":0},{"n":225,"text":"","atom":"a0","author":"init","version":0},{"n":226,"text":"/**","atom":"a0","author":"init","version":0},{"n":227,"text":" * Write a file by way of a temporary file and a rename, so a reader sees the","atom":"a0","author":"init","version":0},{"n":228,"text":" * old file or the new one, never half (#51, as git writes its index). A held","atom":"a0","author":"init","version":0},{"n":229,"text":" * file is tried again for about a second; then it throws, rather than write","atom":"a0","author":"init","version":0},{"n":230,"text":" * in place, where a crash would leave half a file.","atom":"a0","author":"init","version":0},{"n":231,"text":" */","atom":"a0","author":"init","version":0},{"n":232,"text":"export function writeFileAtomic(","atom":"a0","author":"init","version":0},{"n":233,"text":"\tpath: string,","atom":"a0","author":"init","version":0},{"n":234,"text":"\ttext: string | Uint8Array,","atom":"a0","author":"init","version":0},{"n":235,"text":"\trename: (from: string, to: string) => void = renameSync,","atom":"a0","author":"init","version":0},{"n":236,"text":"): void {","atom":"a0","author":"init","version":0},{"n":237,"text":"\tmkdirSync(dirname(path), { recursive: true });","atom":"a0","author":"init","version":0},{"n":238,"text":"\tconst tmp = `${path}.${process.pid}.tmp`;","atom":"a0","author":"init","version":0},{"n":239,"text":"\twriteFileSync(tmp, text);","atom":"a0","author":"init","version":0},{"n":240,"text":"\tfor (let attempt = 0; ; attempt++) {","atom":"a0","author":"init","version":0},{"n":241,"text":"\t\ttry {","atom":"a0","author":"init","version":0},{"n":242,"text":"\t\t\trename(tmp, path);","atom":"a0","author":"init","version":0},{"n":243,"text":"\t\t\treturn;","atom":"a0","author":"init","version":0},{"n":244,"text":"\t\t} catch (err) {","atom":"a0","author":"init","version":0},{"n":245,"text":"\t\t\tconst code = (err as NodeJS.ErrnoException).code ?? \"\";","atom":"a0","author":"init","version":0},{"n":246,"text":"\t\t\tconst wait = RENAME_WAITS_MS[attempt];","atom":"a0","author":"init","version":0},{"n":247,"text":"\t\t\tif (!HELD.has(code) || wait === undefined) {","atom":"a0","author":"init","version":0},{"n":248,"text":"\t\t\t\trmSync(tmp, { force: true });","atom":"a0","author":"init","version":0},{"n":249,"text":"\t\t\t\tthrow Object.assign(","atom":"a0","author":"init","version":0},{"n":250,"text":"\t\t\t\t\tnew Error(","atom":"a0","author":"init","version":0},{"n":251,"text":"\t\t\t\t\t\t`couldn't replace ${path} (${code || (err as Error).message}${HELD.has(code) ? \", still held by another program after a second\" : \"\"})`,","atom":"a0","author":"init","version":0},{"n":252,"text":"\t\t\t\t\t),","atom":"a0","author":"init","version":0},{"n":253,"text":"\t\t\t\t\t{ code },","atom":"a0","author":"init","version":0},{"n":254,"text":"\t\t\t\t);","atom":"a0","author":"init","version":0},{"n":255,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":256,"text":"\t\t\t// A short synchronous wait: callers write file by file, in order.","atom":"a0","author":"init","version":0},{"n":257,"text":"\t\t\tAtomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, wait);","atom":"a0","author":"init","version":0},{"n":258,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":259,"text":"\t}","atom":"a0","author":"init","version":0},{"n":260,"text":"}","atom":"a0","author":"init","version":0},{"n":261,"text":"","atom":"a0","author":"init","version":0},{"n":262,"text":"export function removeFile(path: string): void {","atom":"a0","author":"init","version":0},{"n":263,"text":"\ttry {","atom":"a0","author":"init","version":0},{"n":264,"text":"\t\tunlinkSync(path);","atom":"a0","author":"init","version":0},{"n":265,"text":"\t} catch (err) {","atom":"a0","author":"init","version":0},{"n":266,"text":"\t\tif ((err as NodeJS.ErrnoException).code !== \"ENOENT\") throw err;","atom":"a0","author":"init","version":0},{"n":267,"text":"\t}","atom":"a0","author":"init","version":0},{"n":268,"text":"}","atom":"a0","author":"init","version":0},{"n":269,"text":"","atom":"a0","author":"init","version":0},{"n":270,"text":"// --- pausing ---","atom":"a0","author":"init","version":0},{"n":271,"text":"","atom":"a0","author":"init","version":0},{"n":272,"text":"/** .avcs/paused: while it exists, nothing from the folder is sent (abso pause, abso resume). */","atom":"a0","author":"init","version":0},{"n":273,"text":"export function pausedPath(root: string): string {","atom":"a0","author":"init","version":0},{"n":274,"text":"\treturn join(stateDir(root), \"paused\");","atom":"a103","author":"review","version":17},{"n":275,"text":"}","atom":"a0","author":"init","version":0},{"n":276,"text":"","atom":"a0","author":"init","version":0},{"n":277,"text":"export function isPaused(root: string): boolean {","atom":"a0","author":"init","version":0},{"n":278,"text":"\treturn existsSync(pausedPath(root));","atom":"a0","author":"init","version":0},{"n":279,"text":"}","atom":"a0","author":"init","version":0},{"n":280,"text":"","atom":"a0","author":"init","version":0},{"n":281,"text":"// --- the known copy ---","atom":"a0","author":"init","version":0},{"n":282,"text":"","atom":"a0","author":"init","version":0},{"n":283,"text":"/** `state` is the folder's stateDir, for a caller that looks up many files: finding it checks the disk each time. */","atom":"a441","author":"speed","version":44},{"n":284,"text":"export function knownPath(root: string, rel: string, state: string = stateDir(root)): string {","atom":"a441","author":"speed","version":44},{"n":285,"text":"\treturn join(state, KNOWN, ...insideParts(rel));","atom":"a441","author":"speed","version":44},{"n":286,"text":"}","atom":"a0","author":"init","version":0},{"n":287,"text":"","atom":"a0","author":"init","version":0},{"n":288,"text":"export function readKnown(root: string, rel: string, state?: string): string | undefined {","atom":"a441","author":"speed","version":44},{"n":289,"text":"\treturn readText(knownPath(root, rel, state));","atom":"a441","author":"speed","version":44},{"n":290,"text":"}","atom":"a0","author":"init","version":0},{"n":291,"text":"","atom":"a0","author":"init","version":0},{"n":292,"text":"export function writeKnown(root: string, rel: string, text: string): void {","atom":"a0","author":"init","version":0},{"n":293,"text":"\twriteFileAtomic(knownPath(root, rel), 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":"/** Forget a file, so the next `record` sends it whole. */","atom":"a0","author":"init","version":0},{"n":297,"text":"export function forgetKnown(root: string, rel: string): void {","atom":"a0","author":"init","version":0},{"n":298,"text":"\tremoveFile(knownPath(root, rel));","atom":"a0","author":"init","version":0},{"n":299,"text":"}","atom":"a0","author":"init","version":0},{"n":300,"text":"","atom":"a0","author":"init","version":0},{"n":301,"text":"/** Every path in the known copy. */","atom":"a0","author":"init","version":0},{"n":302,"text":"export function listKnown(root: string): string[] {","atom":"a0","author":"init","version":0},{"n":303,"text":"\tconst base = join(stateDir(root), KNOWN);","atom":"a103","author":"review","version":17},{"n":304,"text":"\tif (!existsSync(base)) return [];","atom":"a0","author":"init","version":0},{"n":305,"text":"\tconst out: string[] = [];","atom":"a0","author":"init","version":0},{"n":306,"text":"\tconst visit = (dir: string, prefix: string): void => {","atom":"a0","author":"init","version":0},{"n":307,"text":"\t\tfor (const entry of readdirSync(dir, { withFileTypes: true })) {","atom":"a0","author":"init","version":0},{"n":308,"text":"\t\t\tconst rel = prefix === \"\" ? entry.name : `${prefix}/${entry.name}`;","atom":"a0","author":"init","version":0},{"n":309,"text":"\t\t\tif (entry.isDirectory()) visit(join(dir, entry.name), rel);","atom":"a0","author":"init","version":0},{"n":310,"text":"\t\t\telse if (entry.isFile() && !entry.name.endsWith(\".tmp\")) out.push(rel);","atom":"a0","author":"init","version":0},{"n":311,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":312,"text":"\t};","atom":"a0","author":"init","version":0},{"n":313,"text":"\tvisit(base, \"\");","atom":"a0","author":"init","version":0},{"n":314,"text":"\treturn out.sort();","atom":"a0","author":"init","version":0},{"n":315,"text":"}","atom":"a0","author":"init","version":0},{"n":316,"text":"","atom":"a0","author":"init","version":0},{"n":317,"text":"export function clearKnown(root: string): void {","atom":"a0","author":"init","version":0},{"n":318,"text":"\trmSync(join(stateDir(root), KNOWN), { recursive: true, force: true });","atom":"a103","author":"review","version":17},{"n":319,"text":"}","atom":"a0","author":"init","version":0},{"n":320,"text":"","atom":"a0","author":"init","version":0},{"n":321,"text":"/**","atom":"a0","author":"init","version":0},{"n":322,"text":" * What `record` would send: files that differ from the known copy (in the","atom":"a0","author":"init","version":0},{"n":323,"text":" * server's form), known files that are gone (null), and the modes that differ","atom":"a0","author":"init","version":0},{"n":324,"text":" * from the known modes. An empty file is a file like any other (\"\"); a link's","atom":"a0","author":"init","version":0},{"n":325,"text":" * text is \"\".","atom":"a0","author":"init","version":0},{"n":326,"text":" *","atom":"a441","author":"speed","version":44},{"n":327,"text":" * `clean` lets status skip reading the files it found unchanged last time","atom":"a441","author":"speed","version":44},{"n":328,"text":" * (clean-files.ts). record never passes it, so it always reads every file.","atom":"a441","author":"speed","version":44},{"n":329,"text":" */","atom":"a0","author":"init","version":0},{"n":330,"text":"export function unrecorded(","atom":"a0","author":"init","version":0},{"n":331,"text":"\troot: string,","atom":"a0","author":"init","version":0},{"n":332,"text":"\tall = false,","atom":"a0","author":"init","version":0},{"n":333,"text":"\tmeantBinary: ReadonlySet<string> = new Set(),","atom":"a0","author":"init","version":0},{"n":334,"text":"\tclean?: CleanFiles,","atom":"a441","author":"speed","version":44},{"n":335,"text":"): {","atom":"a0","author":"init","version":0},{"n":336,"text":"\tfiles: Map<string, string | null>;","atom":"a0","author":"init","version":0},{"n":337,"text":"\tblobs: Map<string, BlobToSend>;","atom":"a0","author":"init","version":0},{"n":338,"text":"\tmodes: Record<string, Mode>;","atom":"a0","author":"init","version":0},{"n":339,"text":"\tleftOut: LeftOut[];","atom":"a0","author":"init","version":0},{"n":340,"text":"\tturnedBinary: TurnedBinary[];","atom":"a0","author":"init","version":0},{"n":341,"text":"} {","atom":"a0","author":"init","version":0},{"n":342,"text":"\tconst ignore = loadIgnore(root);","atom":"a0","author":"init","version":0},{"n":343,"text":"\tconst out = new Map<string, string | null>();","atom":"a0","author":"init","version":0},{"n":344,"text":"\tconst blobs = new Map<string, BlobToSend>();","atom":"a0","author":"init","version":0},{"n":345,"text":"\tconst modes: Record<string, Mode> = {};","atom":"a0","author":"init","version":0},{"n":346,"text":"\tconst present = new Set<string>();","atom":"a0","author":"init","version":0},{"n":347,"text":"\tconst leftOut: LeftOut[] = [];","atom":"a0","author":"init","version":0},{"n":348,"text":"\tconst turnedBinary: TurnedBinary[] = [];","atom":"a0","author":"init","version":0},{"n":349,"text":"\t// Exact names: on a case-insensitive disk, known/a.ts would also answer for A.ts, hiding a rename that changes only case.","atom":"a0","author":"init","version":0},{"n":350,"text":"\tconst knownPaths = new Set(listKnown(root));","atom":"a0","author":"init","version":0},{"n":351,"text":"\tconst state = stateDir(root);","atom":"a441","author":"speed","version":44},{"n":352,"text":"\tconst knownBlobs = readKnownBlobs(root);","atom":"a0","author":"init","version":0},{"n":353,"text":"\tconst knownModes = readKnownModes(root);","atom":"a0","author":"init","version":0},{"n":354,"text":"\tconst trusted = all ? undefined : clean;","atom":"a441","author":"speed","version":44},{"n":355,"text":"\tfor (const rel of walk(root, ignore)) {","atom":"a0","author":"init","version":0},{"n":356,"text":"\t\tconst was = knownModes.get(rel) ?? PLAIN;","atom":"a0","author":"init","version":0},{"n":357,"text":"\t\t// Taken before the file is read, so an edit during the read changes the key.","atom":"a441","author":"speed","version":44},{"n":358,"text":"\t\tconst key =","atom":"a441","author":"speed","version":44},{"n":359,"text":"\t\t\ttrusted && knownPaths.has(rel) && was.link === null","atom":"a441","author":"speed","version":44},{"n":360,"text":"\t\t\t\t? trusted.key(absolute(root, rel), knownPath(root, rel, state))","atom":"a441","author":"speed","version":44},{"n":361,"text":"\t\t\t\t: undefined;","atom":"a441","author":"speed","version":44},{"n":362,"text":"\t\tif (key && trusted!.check(rel, key)) {","atom":"a441","author":"speed","version":44},{"n":363,"text":"\t\t\tpresent.add(rel);","atom":"a441","author":"speed","version":44},{"n":364,"text":"\t\t\tconst change = modeChange(was, { exec: FILE_MODE ? (key.mode & 0o111) !== 0 : was.exec, link: null });","atom":"a441","author":"speed","version":44},{"n":365,"text":"\t\t\tif (change) modes[rel] = change;","atom":"a441","author":"speed","version":44},{"n":366,"text":"\t\t\tcontinue;","atom":"a441","author":"speed","version":44},{"n":367,"text":"\t\t}","atom":"a441","author":"speed","version":44},{"n":368,"text":"\t\tconst d = onDisk(absolute(root, rel), was);","atom":"a0","author":"init","version":0},{"n":369,"text":"\t\tif (d === undefined) continue;","atom":"a0","author":"init","version":0},{"n":370,"text":"\t\tif (d.text === undefined) {","atom":"a0","author":"init","version":0},{"n":371,"text":"\t\t\tconst b = blobOf(absolute(root, rel));","atom":"a0","author":"init","version":0},{"n":372,"text":"\t\t\tif (b === undefined) continue;","atom":"a0","author":"init","version":0},{"n":373,"text":"\t\t\tif (\"tooBig\" in b) {","atom":"a0","author":"init","version":0},{"n":374,"text":"\t\t\t\t// Over the server's limit: what the server has stays, nothing is deleted.","atom":"a0","author":"init","version":0},{"n":375,"text":"\t\t\t\tconst kept = knownPaths.has(rel) || knownBlobs.has(rel);","atom":"a0","author":"init","version":0},{"n":376,"text":"\t\t\t\tif (kept) present.add(rel);","atom":"a0","author":"init","version":0},{"n":377,"text":"\t\t\t\tleftOut.push({ path: rel, reason: \"too big\", ...(kept ? { kept } : {}) });","atom":"a0","author":"init","version":0},{"n":378,"text":"\t\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":379,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":380,"text":"\t\t\tpresent.add(rel);","atom":"a0","author":"init","version":0},{"n":381,"text":"\t\t\tif (knownPaths.has(rel) && b.size <= MAX_TEXT_BYTES && !meantBinary.has(rel)) {","atom":"a0","author":"init","version":0},{"n":382,"text":"\t\t\t\t// Was text, now binary: hold it back (the server keeps its text) and say where.","atom":"a0","author":"init","version":0},{"n":383,"text":"\t\t\t\tturnedBinary.push({ path: rel, ...firstBadByte(b.bytes) });","atom":"a0","author":"init","version":0},{"n":384,"text":"\t\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":385,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":386,"text":"\t\t\tif (all || knownBlobs.get(rel) !== b.sha) blobs.set(rel, { sha: b.sha, bytes: b.bytes });","atom":"a0","author":"init","version":0},{"n":387,"text":"\t\t} else {","atom":"a0","author":"init","version":0},{"n":388,"text":"\t\t\tconst text = normalize(d.text);","atom":"a0","author":"init","version":0},{"n":389,"text":"\t\t\tconst known = knownPaths.has(rel) ? readKnown(root, rel, state) : undefined;","atom":"a441","author":"speed","version":44},{"n":390,"text":"\t\t\tpresent.add(rel);","atom":"a0","author":"init","version":0},{"n":391,"text":"\t\t\t// A file the server keeps whole has no known copy, only its hash (#46).","atom":"a0","author":"init","version":0},{"n":392,"text":"\t\t\tif (all || (known !== text && !(known === undefined && keptWholeAs(text, knownBlobs.get(rel)))))","atom":"a0","author":"init","version":0},{"n":393,"text":"\t\t\t\tout.set(rel, text);","atom":"a0","author":"init","version":0},{"n":394,"text":"\t\t\tif (key && d.link === null && known === text) trusted!.mark(rel, key, d.text.includes(\"\\r\"));","atom":"a441","author":"speed","version":44},{"n":395,"text":"\t\t\telse trusted?.drop(rel);","atom":"a441","author":"speed","version":44},{"n":396,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":397,"text":"\t\t// --all sends every file's whole mode, as it sends every file's text.","atom":"a0","author":"init","version":0},{"n":398,"text":"\t\tconst change = all ? { exec: d.exec, link: d.link } : modeChange(was, d);","atom":"a0","author":"init","version":0},{"n":399,"text":"\t\tif (change) modes[rel] = change;","atom":"a0","author":"init","version":0},{"n":400,"text":"\t}","atom":"a0","author":"init","version":0},{"n":401,"text":"\tfor (const rel of new Set([...knownPaths, ...knownBlobs.keys()])) {","atom":"a0","author":"init","version":0},{"n":402,"text":"\t\t// A local-only file the server still has (recorded before the client skipped","atom":"a0","author":"init","version":0},{"n":403,"text":"\t\t// it) is sent once as deleted, so it leaves the draft; the file on disk stays.","atom":"a0","author":"init","version":0},{"n":404,"text":"\t\tif (isLocalOnly(rel) || (!present.has(rel) && !ignore(rel, false))) out.set(rel, null);","atom":"a0","author":"init","version":0},{"n":405,"text":"\t}","atom":"a0","author":"init","version":0},{"n":406,"text":"\treturn { files: out, blobs, modes, leftOut, turnedBinary };","atom":"a0","author":"init","version":0},{"n":407,"text":"}","atom":"a0","author":"init","version":0},{"n":408,"text":"","atom":"a0","author":"init","version":0},{"n":409,"text":"/** Keep the news the agent was given in .avcs/news.log, one dated line each, for anything that shows it later. */","atom":"a0","author":"init","version":0},{"n":410,"text":"export function logNews(root: string, news: readonly string[]): void {","atom":"a0","author":"init","version":0},{"n":411,"text":"\tif (news.length === 0) return;","atom":"a0","author":"init","version":0},{"n":412,"text":"\tconst at = new Date().toISOString();","atom":"a0","author":"init","version":0},{"n":413,"text":"\ttry {","atom":"a0","author":"init","version":0},{"n":414,"text":"\t\tappendFileSync(join(stateDir(root), \"news.log\"), news.map((n) => `${at}\\t${n}\\n`).join(\"\"));","atom":"a103","author":"review","version":17},{"n":415,"text":"\t} catch {","atom":"a0","author":"init","version":0},{"n":416,"text":"\t\t// Best effort.","atom":"a0","author":"init","version":0},{"n":417,"text":"\t}","atom":"a0","author":"init","version":0},{"n":418,"text":"}","atom":"a0","author":"init","version":0},{"n":419,"text":"","atom":"a0","author":"init","version":0},{"n":420,"text":"export function isFile(path: string): boolean {","atom":"a0","author":"init","version":0},{"n":421,"text":"\ttry {","atom":"a0","author":"init","version":0},{"n":422,"text":"\t\treturn statSync(path).isFile();","atom":"a0","author":"init","version":0},{"n":423,"text":"\t} catch {","atom":"a0","author":"init","version":0},{"n":424,"text":"\t\treturn false;","atom":"a0","author":"init","version":0},{"n":425,"text":"\t}","atom":"a0","author":"init","version":0},{"n":426,"text":"}","atom":"a0","author":"init","version":0},{"n":427,"text":"","atom":"a0","author":"init","version":0},{"n":428,"text":"// --- line endings for new files ---","atom":"a0","author":"init","version":0},{"n":429,"text":"","atom":"a0","author":"init","version":0},{"n":430,"text":"/**","atom":"a0","author":"init","version":0},{"n":431,"text":" * The line endings git would give each of these files if it wrote them new","atom":"a0","author":"init","version":0},{"n":432,"text":" * into the folder: from .gitattributes (text, eol) and git's config","atom":"a0","author":"init","version":0},{"n":433,"text":" * (core.autocrlf, core.eol), asked of git itself so its rules hold exactly.","atom":"a0","author":"init","version":0},{"n":434,"text":" * LF outside a git repository, or when git can't be run. A file already on","atom":"a0","author":"init","version":0},{"n":435,"text":" * disk keeps its own endings instead (withEndingsOf).","atom":"a0","author":"init","version":0},{"n":436,"text":" */","atom":"a0","author":"init","version":0},{"n":437,"text":"export function newFileEndings(root: string, rels: readonly string[]): Map<string, \"crlf\" | \"lf\"> {","atom":"a0","author":"init","version":0},{"n":438,"text":"\tconst out = new Map<string, \"crlf\" | \"lf\">(rels.map((r) => [r, \"lf\"]));","atom":"a0","author":"init","version":0},{"n":439,"text":"\tif (rels.length === 0 || !existsSync(join(root, \".git\"))) return out;","atom":"a0","author":"init","version":0},{"n":440,"text":"\tconst git = (args: string[], input?: string): string | undefined => {","atom":"a0","author":"init","version":0},{"n":441,"text":"\t\ttry {","atom":"a0","author":"init","version":0},{"n":442,"text":"\t\t\treturn execFileSync(\"git\", [\"-C\", root, ...args], {","atom":"a0","author":"init","version":0},{"n":443,"text":"\t\t\t\tinput,","atom":"a0","author":"init","version":0},{"n":444,"text":"\t\t\t\tstdio: [\"pipe\", \"pipe\", \"ignore\"],","atom":"a0","author":"init","version":0},{"n":445,"text":"\t\t\t\tmaxBuffer: 64 << 20,","atom":"a0","author":"init","version":0},{"n":446,"text":"\t\t\t}).toString();","atom":"a0","author":"init","version":0},{"n":447,"text":"\t\t} catch {","atom":"a0","author":"init","version":0},{"n":448,"text":"\t\t\treturn undefined;","atom":"a0","author":"init","version":0},{"n":449,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":450,"text":"\t};","atom":"a0","author":"init","version":0},{"n":451,"text":"\tconst config = new Map<string, string>();","atom":"a0","author":"init","version":0},{"n":452,"text":"\tfor (const line of (git([\"config\", \"--get-regexp\", \"^core.(autocrlf|eol)$\"]) ?? \"\").split(\"\\n\")) {","atom":"a0","author":"init","version":0},{"n":453,"text":"\t\tconst [k, v] = line.trim().split(/\\s+/);","atom":"a0","author":"init","version":0},{"n":454,"text":"\t\tif (k && v) config.set(k.toLowerCase(), v.toLowerCase());","atom":"a0","author":"init","version":0},{"n":455,"text":"\t}","atom":"a0","author":"init","version":0},{"n":456,"text":"\tconst autocrlf = config.get(\"core.autocrlf\");","atom":"a0","author":"init","version":0},{"n":457,"text":"\tconst coreEol = config.get(\"core.eol\") ?? \"native\";","atom":"a0","author":"init","version":0},{"n":458,"text":"\tconst attrs = git([\"check-attr\", \"--stdin\", \"-z\", \"text\", \"eol\"], `${rels.join(\"\\0\")}\\0`);","atom":"a690","author":"pinch","version":78},{"n":459,"text":"\tif (attrs === undefined) return out;","atom":"a0","author":"init","version":0},{"n":460,"text":"\tconst f = attrs.split(\"\\0\");","atom":"a0","author":"init","version":0},{"n":461,"text":"\tconst seen = new Map<string, { text?: string; eol?: string }>();","atom":"a0","author":"init","version":0},{"n":462,"text":"\tfor (let i = 0; i + 2 < f.length; i += 3) {","atom":"a0","author":"init","version":0},{"n":463,"text":"\t\tconst a = seen.get(f[i]!) ?? {};","atom":"a0","author":"init","version":0},{"n":464,"text":"\t\tif (f[i + 1] === \"text\") a.text = f[i + 2];","atom":"a0","author":"init","version":0},{"n":465,"text":"\t\telse a.eol = f[i + 2];","atom":"a0","author":"init","version":0},{"n":466,"text":"\t\tseen.set(f[i]!, a);","atom":"a0","author":"init","version":0},{"n":467,"text":"\t}","atom":"a0","author":"init","version":0},{"n":468,"text":"\tfor (const rel of rels) {","atom":"a0","author":"init","version":0},{"n":469,"text":"\t\tconst { text = \"unspecified\", eol = \"unspecified\" } = seen.get(rel) ?? {};","atom":"a0","author":"init","version":0},{"n":470,"text":"\t\t// As git's checkout does: -text (or binary) is left alone; eol= decides; then core.autocrlf; then core.eol for text files.","atom":"a0","author":"init","version":0},{"n":471,"text":"\t\tlet crlf = false;","atom":"a0","author":"init","version":0},{"n":472,"text":"\t\tif (text === \"unset\") crlf = false;","atom":"a0","author":"init","version":0},{"n":473,"text":"\t\telse if (eol === \"crlf\" || eol === \"lf\") crlf = eol === \"crlf\";","atom":"a0","author":"init","version":0},{"n":474,"text":"\t\telse if (autocrlf === \"true\") crlf = true;","atom":"a0","author":"init","version":0},{"n":475,"text":"\t\telse if (autocrlf === \"input\") crlf = false;","atom":"a0","author":"init","version":0},{"n":476,"text":"\t\telse if (text === \"set\" || text === \"auto\")","atom":"a0","author":"init","version":0},{"n":477,"text":"\t\t\tcrlf = coreEol === \"crlf\" || (coreEol === \"native\" && process.platform === \"win32\");","atom":"a0","author":"init","version":0},{"n":478,"text":"\t\tout.set(rel, crlf ? \"crlf\" : \"lf\");","atom":"a0","author":"init","version":0},{"n":479,"text":"\t}","atom":"a0","author":"init","version":0},{"n":480,"text":"\treturn out;","atom":"a0","author":"init","version":0},{"n":481,"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":"a103","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":"a206","author":"review","message":"","time":1791533506483,"timeIso":"2026-10-09T08:11:46.483Z","publish":{"draft":null,"version":27,"agent":"review","message":"Client: ABSO_ environment names (AVCS_ still read), .absoignore (.avcsignore still read), .abso-export.json, shot files; READMEs say abso (abso 224)","time":1791533840174,"timeIso":"2026-10-09T08:17:20.174Z"}},{"atom":"a441","author":"speed","message":"","time":1791558026769,"timeIso":"2026-10-09T15:00:26.769Z","publish":{"draft":null,"version":44,"agent":"speed","message":"status: skip reading files found unchanged before. A record in the folder's state dir (clean.json) keeps, per file, the size, time and inode of the file and its known copy, taken before reading; only status's unrecorded and line-ending checks use it, record always reads every file. Files changed too recently to trust are read; an unknown format or client version reads everything. The state dir is found once per walk. The mod-commit test no longer depends on how long it takes.","time":1791558026769,"timeIso":"2026-10-09T15:00:26.769Z"}},{"atom":"a690","author":"pinch","message":"","time":1791611690170,"timeIso":"2026-10-10T05:54:50.170Z","publish":{"draft":null,"version":78,"agent":"pinch","message":"Biome is silent: about 90 hints cleared. String joins as templates, dotted keys, unused imports, variables and a private method removed, optional chains (one kept boolean with === true), the preset field instead of the deprecated recommended. Two rules off where they don't fit: noExplicitAny in the hook modules, whose engine types come from the host, and noTemplateCurlyInString in tests, which hold source text as data.","time":1791612106058,"timeIso":"2026-10-10T06:01:46.058Z"}}]}