{"file":"client/src/fetch.ts","version":318,"total":92,"from":1,"to":92,"lines":[{"n":1,"text":"// abso fetch <glob...> and abso run --fetch <glob>: bring files the box made","atom":"a0","author":"init","version":0},{"n":2,"text":"// back into the folder (#37). Only paths abso ignores are written,","atom":"a347","author":"infra-split","version":37},{"n":3,"text":"// so a fetched file never becomes an edit; the rest are named and left alone.","atom":"a0","author":"init","version":0},{"n":4,"text":"// Every path is screened as a sync's are (safety.ts): the box runs whatever","atom":"a0","author":"init","version":0},{"n":5,"text":"// the folder held, so its files are not trusted any more than the server's.","atom":"a0","author":"init","version":0},{"n":6,"text":"","atom":"a0","author":"init","version":0},{"n":7,"text":"import { chmodSync, mkdirSync } from \"node:fs\";","atom":"a0","author":"init","version":0},{"n":8,"text":"import { dirname } from \"node:path\";","atom":"a0","author":"init","version":0},{"n":9,"text":"import type { Api } from \"./api.ts\";","atom":"a0","author":"init","version":0},{"n":10,"text":"import { UsageError } from \"./args.ts\";","atom":"a0","author":"init","version":0},{"n":11,"text":"import { isLocalOnly } from \"./core.ts\";","atom":"a0","author":"init","version":0},{"n":12,"text":"import { absolute, loadIgnore, writeFileAtomic } from \"./folder.ts\";","atom":"a0","author":"init","version":0},{"n":13,"text":"import { type Refused, throughLink, unsafePath } from \"./safety.ts\";","atom":"a0","author":"init","version":0},{"n":14,"text":"import { untarGz } from \"./tar.ts\";","atom":"a0","author":"init","version":0},{"n":15,"text":"","atom":"a0","author":"init","version":0},{"n":16,"text":"export interface Fetched {","atom":"a0","author":"init","version":0},{"n":17,"text":"\treadonly written: string[];","atom":"a0","author":"init","version":0},{"n":18,"text":"\t/** Matched in the box but not written, and why. */","atom":"a0","author":"init","version":0},{"n":19,"text":"\treadonly skipped: Refused[];","atom":"a0","author":"init","version":0},{"n":20,"text":"\t/** Globs that matched nothing (or the box had stopped). */","atom":"a0","author":"init","version":0},{"n":21,"text":"\treadonly empty: string[];","atom":"a0","author":"init","version":0},{"n":22,"text":"}","atom":"a0","author":"init","version":0},{"n":23,"text":"","atom":"a0","author":"init","version":0},{"n":24,"text":"/** Whether abso leaves `rel` out: itself, or a folder on its way (git's rule: nothing under an ignored folder counts). */","atom":"a0","author":"init","version":0},{"n":25,"text":"export function ignoredHere(ignore: ReturnType<typeof loadIgnore>, rel: string, isDir = false): boolean {","atom":"a0","author":"init","version":0},{"n":26,"text":"\tconst parts = rel.split(\"/\");","atom":"a0","author":"init","version":0},{"n":27,"text":"\tfor (let i = 1; i < parts.length; i++) if (ignore(parts.slice(0, i).join(\"/\"), true)) return true;","atom":"a0","author":"init","version":0},{"n":28,"text":"\treturn ignore(rel, isDir);","atom":"a0","author":"init","version":0},{"n":29,"text":"}","atom":"a0","author":"init","version":0},{"n":30,"text":"","atom":"a0","author":"init","version":0},{"n":31,"text":"export async function fetchFromBox(root: string, api: Api, globs: readonly string[]): Promise<Fetched> {","atom":"a0","author":"init","version":0},{"n":32,"text":"\tif (globs.length === 0) throw new UsageError('name what to fetch: abso fetch <glob...>, like abso fetch \"out/*.png\"');","atom":"a0","author":"init","version":0},{"n":33,"text":"\tconst ignore = loadIgnore(root);","atom":"a0","author":"init","version":0},{"n":34,"text":"\tconst written: string[] = [];","atom":"a0","author":"init","version":0},{"n":35,"text":"\tconst skipped: Refused[] = [];","atom":"a0","author":"init","version":0},{"n":36,"text":"\tconst empty: string[] = [];","atom":"a0","author":"init","version":0},{"n":37,"text":"\tconst seen = new Set<string>();","atom":"a0","author":"init","version":0},{"n":38,"text":"\tfor (const glob of globs) {","atom":"a0","author":"init","version":0},{"n":39,"text":"\t\tconst gz = await api.boxFiles(glob);","atom":"a0","author":"init","version":0},{"n":40,"text":"\t\tif (gz === null) {","atom":"a0","author":"init","version":0},{"n":41,"text":"\t\t\tempty.push(glob);","atom":"a0","author":"init","version":0},{"n":42,"text":"\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":43,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":44,"text":"\t\tfor (const e of untarGz(gz)) {","atom":"a0","author":"init","version":0},{"n":45,"text":"\t\t\tif (seen.has(e.path)) continue;","atom":"a0","author":"init","version":0},{"n":46,"text":"\t\t\tseen.add(e.path);","atom":"a0","author":"init","version":0},{"n":47,"text":"\t\t\tconst why =","atom":"a0","author":"init","version":0},{"n":48,"text":"\t\t\t\tunsafePath(e.path) ??","atom":"a0","author":"init","version":0},{"n":49,"text":"\t\t\t\t(isLocalOnly(e.path) ? \"it is under .git, .claude, .abso or node_modules, which stay local\" : undefined) ??","atom":"a102","author":"review","version":17},{"n":50,"text":"\t\t\t\t(throughLink(root, e.path) ? \"a folder on its way is a link\" : undefined) ??","atom":"a0","author":"init","version":0},{"n":51,"text":"\t\t\t\t(e.link !== undefined ? \"it is a link; fetch makes none\" : undefined) ??","atom":"a0","author":"init","version":0},{"n":52,"text":"\t\t\t\t(!ignoredHere(ignore, e.path)","atom":"a0","author":"init","version":0},{"n":53,"text":"\t\t\t\t\t? \"abso records it, so writing it would make an edit; add it to .absoignore to fetch it\"","atom":"a205","author":"review","version":27},{"n":54,"text":"\t\t\t\t\t: undefined);","atom":"a0","author":"init","version":0},{"n":55,"text":"\t\t\tif (why !== undefined) {","atom":"a0","author":"init","version":0},{"n":56,"text":"\t\t\t\tskipped.push({ path: e.path, why });","atom":"a0","author":"init","version":0},{"n":57,"text":"\t\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":58,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":59,"text":"\t\t\tconst path = absolute(root, e.path);","atom":"a0","author":"init","version":0},{"n":60,"text":"\t\t\tmkdirSync(dirname(path), { recursive: true });","atom":"a0","author":"init","version":0},{"n":61,"text":"\t\t\twriteFileAtomic(path, e.data);","atom":"a0","author":"init","version":0},{"n":62,"text":"\t\t\tif (e.mode !== undefined && (e.mode & 0o111) !== 0) {","atom":"a0","author":"init","version":0},{"n":63,"text":"\t\t\t\ttry {","atom":"a0","author":"init","version":0},{"n":64,"text":"\t\t\t\t\tchmodSync(path, 0o755);","atom":"a0","author":"init","version":0},{"n":65,"text":"\t\t\t\t} catch {","atom":"a0","author":"init","version":0},{"n":66,"text":"\t\t\t\t\t// The bit is a convenience here.","atom":"a0","author":"init","version":0},{"n":67,"text":"\t\t\t\t}","atom":"a0","author":"init","version":0},{"n":68,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":69,"text":"\t\t\twritten.push(e.path);","atom":"a0","author":"init","version":0},{"n":70,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":71,"text":"\t}","atom":"a0","author":"init","version":0},{"n":72,"text":"\treturn { written: written.sort(), skipped: skipped.sort((a, b) => a.path.localeCompare(b.path)), empty };","atom":"a0","author":"init","version":0},{"n":73,"text":"}","atom":"a0","author":"init","version":0},{"n":74,"text":"","atom":"a0","author":"init","version":0},{"n":75,"text":"/** What a fetch says: what it wrote, what it left alone and why, and globs that found nothing. */","atom":"a0","author":"init","version":0},{"n":76,"text":"export function fetchedText(f: Fetched): string[] {","atom":"a0","author":"init","version":0},{"n":77,"text":"\tconst shown = (list: readonly string[]) =>","atom":"a0","author":"init","version":0},{"n":78,"text":"\t\tlist.length <= 8 ? list.join(\", \") : `${list.slice(0, 8).join(\", \")}, and ${list.length - 8} more`;","atom":"a0","author":"init","version":0},{"n":79,"text":"\treturn [","atom":"a0","author":"init","version":0},{"n":80,"text":"\t\t...(f.written.length > 0","atom":"a0","author":"init","version":0},{"n":81,"text":"\t\t\t? [","atom":"a0","author":"init","version":0},{"n":82,"text":"\t\t\t\t\t`Fetched ${f.written.length === 1 ? \"1 file\" : `${f.written.length} files`} from the box: ${shown(f.written)}.`,","atom":"a0","author":"init","version":0},{"n":83,"text":"\t\t\t\t]","atom":"a0","author":"init","version":0},{"n":84,"text":"\t\t\t: []),","atom":"a0","author":"init","version":0},{"n":85,"text":"\t\t...(f.skipped.length > 0","atom":"a0","author":"init","version":0},{"n":86,"text":"\t\t\t? [`Not fetched (${f.skipped.length}):`, ...f.skipped.map((s) => `  ${s.path}: ${s.why}`)]","atom":"a0","author":"init","version":0},{"n":87,"text":"\t\t\t: []),","atom":"a0","author":"init","version":0},{"n":88,"text":"\t\t...f.empty.map(","atom":"a0","author":"init","version":0},{"n":89,"text":"\t\t\t(g) => `Nothing in the box matches ${g} (or the box has stopped: it keeps /w only until it idles out).`,","atom":"a0","author":"init","version":0},{"n":90,"text":"\t\t),","atom":"a0","author":"init","version":0},{"n":91,"text":"\t];","atom":"a0","author":"init","version":0},{"n":92,"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":"a102","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":"a205","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":"a347","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"}}]}