{"file":"client/src/local-store.ts","version":318,"total":407,"from":1,"to":407,"lines":[{"n":1,"text":"// Local projects (abso init --local): the open server's own router and project object (server/src) run in this","atom":"a2797","author":"pinch","version":287},{"n":2,"text":"// process, over Node's SQLite, so a project needs no server, account or network. Each project is one SQLite file in a","atom":"a2797","author":"pinch","version":287},{"n":3,"text":"// store folder. Every call runs in one SQLite write transaction, which is the store's lock: another process's call","atom":"a2797","author":"pinch","version":287},{"n":4,"text":"// waits for it, and a process that dies mid-call leaves nothing half-written.","atom":"a2797","author":"pinch","version":287},{"n":5,"text":"","atom":"a2797","author":"pinch","version":287},{"n":6,"text":"import { existsSync, mkdirSync } from \"node:fs\";","atom":"a2824","author":"pinch","version":287},{"n":7,"text":"import { homedir } from \"node:os\";","atom":"a2797","author":"pinch","version":287},{"n":8,"text":"import { join, resolve } from \"node:path\";","atom":"a2797","author":"pinch","version":287},{"n":9,"text":"import { deserialize, serialize } from \"node:v8\";","atom":"a2797","author":"pinch","version":287},{"n":10,"text":"import { UsageError } from \"./args.ts\";","atom":"a2824","author":"pinch","version":287},{"n":11,"text":"import { fromEnv } from \"./env-names.ts\";","atom":"a2797","author":"pinch","version":287},{"n":12,"text":"","atom":"a2797","author":"pinch","version":287},{"n":13,"text":"/** The server a local folder's config names. */","atom":"a2797","author":"pinch","version":287},{"n":14,"text":"export const LOCAL = \"local\";","atom":"a2797","author":"pinch","version":287},{"n":15,"text":"/** The address the client's calls use for a local project; they never leave this process. */","atom":"a2797","author":"pinch","version":287},{"n":16,"text":"export const LOCAL_BASE = \"http://local.abso.invalid\";","atom":"a2797","author":"pinch","version":287},{"n":17,"text":"/** The shared token the in-process server is given, and that its calls carry. Not a secret: nothing listens. */","atom":"a2797","author":"pinch","version":287},{"n":18,"text":"const LOCAL_TOKEN = \"local-store\";","atom":"a2797","author":"pinch","version":287},{"n":19,"text":"","atom":"a2797","author":"pinch","version":287},{"n":20,"text":"export const isLocal = (server: string | undefined): boolean => server === LOCAL;","atom":"a2797","author":"pinch","version":287},{"n":21,"text":"","atom":"a2797","author":"pinch","version":287},{"n":22,"text":"type EnvMap = Readonly<Record<string, string | undefined>>;","atom":"a2797","author":"pinch","version":287},{"n":23,"text":"","atom":"a2797","author":"pinch","version":287},{"n":24,"text":"/**","atom":"a2797","author":"pinch","version":287},{"n":25,"text":" * Where local projects live: the folder's own store (--store, kept in its config), else ABSO_STORE, else the OS's","atom":"a2797","author":"pinch","version":287},{"n":26,"text":" * per-user data folder. Undefined when there is none to use (no data folder and nothing named), so nothing assumes a","atom":"a2797","author":"pinch","version":287},{"n":27,"text":" * writable home folder.","atom":"a2797","author":"pinch","version":287},{"n":28,"text":" */","atom":"a2797","author":"pinch","version":287},{"n":29,"text":"export function storeDir(env: EnvMap, configured?: string, cwd = process.cwd()): string | undefined {","atom":"a2797","author":"pinch","version":287},{"n":30,"text":"\tif (configured) return resolve(cwd, configured);","atom":"a2797","author":"pinch","version":287},{"n":31,"text":"\tconst named = fromEnv(env, \"STORE\");","atom":"a2797","author":"pinch","version":287},{"n":32,"text":"\tif (named) return resolve(cwd, named);","atom":"a2797","author":"pinch","version":287},{"n":33,"text":"\tconst data =","atom":"a2797","author":"pinch","version":287},{"n":34,"text":"\t\tprocess.platform === \"win32\"","atom":"a2797","author":"pinch","version":287},{"n":35,"text":"\t\t\t? env.LOCALAPPDATA","atom":"a2797","author":"pinch","version":287},{"n":36,"text":"\t\t\t: process.platform === \"darwin\"","atom":"a2797","author":"pinch","version":287},{"n":37,"text":"\t\t\t\t? env.HOME && join(env.HOME, \"Library\", \"Application Support\")","atom":"a2797","author":"pinch","version":287},{"n":38,"text":"\t\t\t\t: env.XDG_DATA_HOME || (env.HOME ? join(env.HOME, \".local\", \"share\") : undefined);","atom":"a2797","author":"pinch","version":287},{"n":39,"text":"\tif (data) return join(data, \"abso\", \"store\");","atom":"a2797","author":"pinch","version":287},{"n":40,"text":"\ttry {","atom":"a2797","author":"pinch","version":287},{"n":41,"text":"\t\tconst home = homedir();","atom":"a2797","author":"pinch","version":287},{"n":42,"text":"\t\treturn home ? join(home, \".local\", \"share\", \"abso\", \"store\") : undefined;","atom":"a2797","author":"pinch","version":287},{"n":43,"text":"\t} catch {","atom":"a2797","author":"pinch","version":287},{"n":44,"text":"\t\treturn undefined;","atom":"a2797","author":"pinch","version":287},{"n":45,"text":"\t}","atom":"a2797","author":"pinch","version":287},{"n":46,"text":"}","atom":"a2797","author":"pinch","version":287},{"n":47,"text":"","atom":"a2797","author":"pinch","version":287},{"n":48,"text":"export const NO_STORE =","atom":"a2797","author":"pinch","version":287},{"n":49,"text":"\t\"there's no folder for local projects here: set ABSO_STORE to one, or give abso init --local a --store <folder>\";","atom":"a2797","author":"pinch","version":287},{"n":50,"text":"","atom":"a2797","author":"pinch","version":287},{"n":51,"text":"// --- The Workers runtime's parts the server uses, over node:sqlite -----------------------------------------------","atom":"a2797","author":"pinch","version":287},{"n":52,"text":"","atom":"a2797","author":"pinch","version":287},{"n":53,"text":"interface Db {","atom":"a2797","author":"pinch","version":287},{"n":54,"text":"\texec(sql: string): void;","atom":"a2797","author":"pinch","version":287},{"n":55,"text":"\tprepare(sql: string): {","atom":"a2797","author":"pinch","version":287},{"n":56,"text":"\t\tall(...args: unknown[]): unknown[];","atom":"a2797","author":"pinch","version":287},{"n":57,"text":"\t\trun(...args: unknown[]): unknown;","atom":"a2797","author":"pinch","version":287},{"n":58,"text":"\t\tget(...args: unknown[]): unknown;","atom":"a2797","author":"pinch","version":287},{"n":59,"text":"\t\tcolumns(): unknown[];","atom":"a2797","author":"pinch","version":287},{"n":60,"text":"\t};","atom":"a2797","author":"pinch","version":287},{"n":61,"text":"\tclose(): void;","atom":"a2797","author":"pinch","version":287},{"n":62,"text":"}","atom":"a2797","author":"pinch","version":287},{"n":63,"text":"","atom":"a2797","author":"pinch","version":287},{"n":64,"text":"/** A Durable Object's storage: SQL, synchronous transactions, the key-value calls and the alarm, on one database. */","atom":"a2797","author":"pinch","version":287},{"n":65,"text":"function storageOver(db: Db) {","atom":"a2797","author":"pinch","version":287},{"n":66,"text":"\tdb.exec(","atom":"a2797","author":"pinch","version":287},{"n":67,"text":"\t\t\"CREATE TABLE IF NOT EXISTS _local_kv (key TEXT PRIMARY KEY, value BLOB NOT NULL); CREATE TABLE IF NOT EXISTS _local_alarm (id INTEGER PRIMARY KEY CHECK (id = 0), at INTEGER)\",","atom":"a2797","author":"pinch","version":287},{"n":68,"text":"\t);","atom":"a2797","author":"pinch","version":287},{"n":69,"text":"\tconst statements = new Map<string, ReturnType<Db[\"prepare\"]>>();","atom":"a2797","author":"pinch","version":287},{"n":70,"text":"\tconst prepared = (query: string) => {","atom":"a2797","author":"pinch","version":287},{"n":71,"text":"\t\tlet s = statements.get(query);","atom":"a2797","author":"pinch","version":287},{"n":72,"text":"\t\tif (!s) {","atom":"a2797","author":"pinch","version":287},{"n":73,"text":"\t\t\ts = db.prepare(query);","atom":"a2797","author":"pinch","version":287},{"n":74,"text":"\t\t\tstatements.set(query, s);","atom":"a2797","author":"pinch","version":287},{"n":75,"text":"\t\t}","atom":"a2797","author":"pinch","version":287},{"n":76,"text":"\t\treturn s;","atom":"a2797","author":"pinch","version":287},{"n":77,"text":"\t};","atom":"a2797","author":"pinch","version":287},{"n":78,"text":"\t// Workers takes and gives BLOB columns as ArrayBuffers; node:sqlite as Uint8Arrays.","atom":"a2797","author":"pinch","version":287},{"n":79,"text":"\tconst bind = (v: unknown) => (v instanceof ArrayBuffer ? new Uint8Array(v) : v);","atom":"a2797","author":"pinch","version":287},{"n":80,"text":"\tconst out = (v: unknown) => (v instanceof Uint8Array ? v.buffer.slice(v.byteOffset, v.byteOffset + v.byteLength) : v);","atom":"a2824","author":"pinch","version":287},{"n":81,"text":"\tlet depth = 0;","atom":"a2797","author":"pinch","version":287},{"n":82,"text":"\tconst kvGet = (key: string) => {","atom":"a2797","author":"pinch","version":287},{"n":83,"text":"\t\tconst row = prepared(\"SELECT value FROM _local_kv WHERE key = ?\").get(key) as { value: Uint8Array } | undefined;","atom":"a2797","author":"pinch","version":287},{"n":84,"text":"\t\treturn row ? deserialize(row.value) : undefined;","atom":"a2797","author":"pinch","version":287},{"n":85,"text":"\t};","atom":"a2797","author":"pinch","version":287},{"n":86,"text":"\tconst kvPut = (key: string, value: unknown) =>","atom":"a2797","author":"pinch","version":287},{"n":87,"text":"\t\tprepared(","atom":"a2824","author":"pinch","version":287},{"n":88,"text":"\t\t\t\"INSERT INTO _local_kv (key, value) VALUES (?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value\",","atom":"a2824","author":"pinch","version":287},{"n":89,"text":"\t\t).run(key, serialize(value));","atom":"a2824","author":"pinch","version":287},{"n":90,"text":"\tconst kvDelete = (key: string) =>","atom":"a2797","author":"pinch","version":287},{"n":91,"text":"\t\t(prepared(\"DELETE FROM _local_kv WHERE key = ?\").run(key) as { changes: number | bigint }).changes > 0;","atom":"a2797","author":"pinch","version":287},{"n":92,"text":"\tconst storage = {","atom":"a2797","author":"pinch","version":287},{"n":93,"text":"\t\tsql: {","atom":"a2797","author":"pinch","version":287},{"n":94,"text":"\t\t\texec(query: string, ...bindings: unknown[]) {","atom":"a2797","author":"pinch","version":287},{"n":95,"text":"\t\t\t\tconst statement = prepared(query);","atom":"a2797","author":"pinch","version":287},{"n":96,"text":"\t\t\t\tconst args = bindings.map(bind);","atom":"a2797","author":"pinch","version":287},{"n":97,"text":"\t\t\t\tconst rows = statement.columns().length > 0 ? statement.all(...args) : (statement.run(...args), []);","atom":"a2797","author":"pinch","version":287},{"n":98,"text":"\t\t\t\treturn {","atom":"a2797","author":"pinch","version":287},{"n":99,"text":"\t\t\t\t\ttoArray: () =>","atom":"a2797","author":"pinch","version":287},{"n":100,"text":"\t\t\t\t\t\t(rows as Record<string, unknown>[]).map((r) =>","atom":"a2797","author":"pinch","version":287},{"n":101,"text":"\t\t\t\t\t\t\tObject.fromEntries(Object.entries(r).map(([k, v]) => [k, out(v)])),","atom":"a2797","author":"pinch","version":287},{"n":102,"text":"\t\t\t\t\t\t),","atom":"a2797","author":"pinch","version":287},{"n":103,"text":"\t\t\t\t};","atom":"a2797","author":"pinch","version":287},{"n":104,"text":"\t\t\t},","atom":"a2797","author":"pinch","version":287},{"n":105,"text":"\t\t},","atom":"a2797","author":"pinch","version":287},{"n":106,"text":"\t\ttransactionSync<T>(fn: () => T): T {","atom":"a2797","author":"pinch","version":287},{"n":107,"text":"\t\t\tconst name = `local_t${depth++}`;","atom":"a2797","author":"pinch","version":287},{"n":108,"text":"\t\t\tdb.exec(`SAVEPOINT ${name}`);","atom":"a2797","author":"pinch","version":287},{"n":109,"text":"\t\t\ttry {","atom":"a2797","author":"pinch","version":287},{"n":110,"text":"\t\t\t\tconst value = fn();","atom":"a2797","author":"pinch","version":287},{"n":111,"text":"\t\t\t\tdb.exec(`RELEASE ${name}`);","atom":"a2797","author":"pinch","version":287},{"n":112,"text":"\t\t\t\treturn value;","atom":"a2797","author":"pinch","version":287},{"n":113,"text":"\t\t\t} catch (e) {","atom":"a2797","author":"pinch","version":287},{"n":114,"text":"\t\t\t\tdb.exec(`ROLLBACK TO ${name}; RELEASE ${name}`);","atom":"a2797","author":"pinch","version":287},{"n":115,"text":"\t\t\t\tthrow e;","atom":"a2797","author":"pinch","version":287},{"n":116,"text":"\t\t\t} finally {","atom":"a2797","author":"pinch","version":287},{"n":117,"text":"\t\t\t\tdepth--;","atom":"a2797","author":"pinch","version":287},{"n":118,"text":"\t\t\t}","atom":"a2797","author":"pinch","version":287},{"n":119,"text":"\t\t},","atom":"a2797","author":"pinch","version":287},{"n":120,"text":"\t\tasync transaction<T>(fn: (txn: unknown) => Promise<T>): Promise<T> {","atom":"a2797","author":"pinch","version":287},{"n":121,"text":"\t\t\treturn fn(storage);","atom":"a2797","author":"pinch","version":287},{"n":122,"text":"\t\t},","atom":"a2797","author":"pinch","version":287},{"n":123,"text":"\t\tasync get(key: string | string[]) {","atom":"a2797","author":"pinch","version":287},{"n":124,"text":"\t\t\tif (typeof key === \"string\") return kvGet(key);","atom":"a2797","author":"pinch","version":287},{"n":125,"text":"\t\t\treturn new Map(key.flatMap((k) => (kvGet(k) === undefined ? [] : [[k, kvGet(k)] as const])));","atom":"a2797","author":"pinch","version":287},{"n":126,"text":"\t\t},","atom":"a2797","author":"pinch","version":287},{"n":127,"text":"\t\tasync put(key: string | Record<string, unknown>, value?: unknown) {","atom":"a2797","author":"pinch","version":287},{"n":128,"text":"\t\t\tif (typeof key === \"string\") kvPut(key, value);","atom":"a2797","author":"pinch","version":287},{"n":129,"text":"\t\t\telse for (const [k, v] of Object.entries(key)) kvPut(k, v);","atom":"a2797","author":"pinch","version":287},{"n":130,"text":"\t\t},","atom":"a2797","author":"pinch","version":287},{"n":131,"text":"\t\tasync delete(key: string | string[]) {","atom":"a2797","author":"pinch","version":287},{"n":132,"text":"\t\t\tif (typeof key === \"string\") return kvDelete(key);","atom":"a2797","author":"pinch","version":287},{"n":133,"text":"\t\t\treturn key.filter(kvDelete).length;","atom":"a2797","author":"pinch","version":287},{"n":134,"text":"\t\t},","atom":"a2797","author":"pinch","version":287},{"n":135,"text":"\t\tasync list(options: { prefix?: string } = {}) {","atom":"a2797","author":"pinch","version":287},{"n":136,"text":"\t\t\tconst rows = prepared(\"SELECT key, value FROM _local_kv WHERE key >= ? ORDER BY key\").all(","atom":"a2797","author":"pinch","version":287},{"n":137,"text":"\t\t\t\toptions.prefix ?? \"\",","atom":"a2797","author":"pinch","version":287},{"n":138,"text":"\t\t\t) as { key: string; value: Uint8Array }[];","atom":"a2797","author":"pinch","version":287},{"n":139,"text":"\t\t\treturn new Map(","atom":"a2797","author":"pinch","version":287},{"n":140,"text":"\t\t\t\trows.filter((r) => r.key.startsWith(options.prefix ?? \"\")).map((r) => [r.key, deserialize(r.value)]),","atom":"a2797","author":"pinch","version":287},{"n":141,"text":"\t\t\t);","atom":"a2797","author":"pinch","version":287},{"n":142,"text":"\t\t},","atom":"a2797","author":"pinch","version":287},{"n":143,"text":"\t\t// The alarm is kept, but nothing in a local project needs it: it pushes out to Artifacts, which is off here.","atom":"a2797","author":"pinch","version":287},{"n":144,"text":"\t\tasync getAlarm() {","atom":"a2797","author":"pinch","version":287},{"n":145,"text":"\t\t\tconst row = prepared(\"SELECT at FROM _local_alarm WHERE id = 0\").get() as { at: number | null } | undefined;","atom":"a2797","author":"pinch","version":287},{"n":146,"text":"\t\t\treturn row?.at ?? null;","atom":"a2797","author":"pinch","version":287},{"n":147,"text":"\t\t},","atom":"a2797","author":"pinch","version":287},{"n":148,"text":"\t\tasync setAlarm(at: number | Date) {","atom":"a2797","author":"pinch","version":287},{"n":149,"text":"\t\t\tprepared(\"INSERT INTO _local_alarm (id, at) VALUES (0, ?) ON CONFLICT (id) DO UPDATE SET at = excluded.at\").run(","atom":"a2797","author":"pinch","version":287},{"n":150,"text":"\t\t\t\tNumber(at),","atom":"a2797","author":"pinch","version":287},{"n":151,"text":"\t\t\t);","atom":"a2797","author":"pinch","version":287},{"n":152,"text":"\t\t},","atom":"a2797","author":"pinch","version":287},{"n":153,"text":"\t\tasync deleteAlarm() {","atom":"a2797","author":"pinch","version":287},{"n":154,"text":"\t\t\tprepared(\"DELETE FROM _local_alarm WHERE id = 0\").run();","atom":"a2797","author":"pinch","version":287},{"n":155,"text":"\t\t},","atom":"a2797","author":"pinch","version":287},{"n":156,"text":"\t};","atom":"a2797","author":"pinch","version":287},{"n":157,"text":"\treturn storage;","atom":"a2797","author":"pinch","version":287},{"n":158,"text":"}","atom":"a2797","author":"pinch","version":287},{"n":159,"text":"","atom":"a2797","author":"pinch","version":287},{"n":160,"text":"/** Workers' crypto.DigestStream, which the blob store hashes uploads with. */","atom":"a2797","author":"pinch","version":287},{"n":161,"text":"async function installDigestStream(): Promise<void> {","atom":"a2797","author":"pinch","version":287},{"n":162,"text":"\t// Through a cast: abso's worker compiles this file too (tool.lock.json), and its types have no globalThis.crypto.","atom":"a2895","author":"capacity","version":297},{"n":163,"text":"\tconst c = (globalThis as unknown as { crypto: { DigestStream?: unknown } }).crypto;","atom":"a2895","author":"capacity","version":297},{"n":164,"text":"\tif (c.DigestStream) return;","atom":"a2797","author":"pinch","version":287},{"n":165,"text":"\tconst { createHash } = await import(\"node:crypto\");","atom":"a2797","author":"pinch","version":287},{"n":166,"text":"\tclass DigestStream extends WritableStream<Uint8Array> {","atom":"a2797","author":"pinch","version":287},{"n":167,"text":"\t\treadonly digest: Promise<ArrayBuffer>;","atom":"a2797","author":"pinch","version":287},{"n":168,"text":"\t\tconstructor(algorithm: string) {","atom":"a2797","author":"pinch","version":287},{"n":169,"text":"\t\t\tconst hash = createHash(algorithm.replace(\"-\", \"\").toLowerCase());","atom":"a2797","author":"pinch","version":287},{"n":170,"text":"\t\t\tlet done!: (b: ArrayBuffer) => void;","atom":"a2797","author":"pinch","version":287},{"n":171,"text":"\t\t\tconst digest = new Promise<ArrayBuffer>((ok) => {","atom":"a2797","author":"pinch","version":287},{"n":172,"text":"\t\t\t\tdone = ok;","atom":"a2797","author":"pinch","version":287},{"n":173,"text":"\t\t\t});","atom":"a2797","author":"pinch","version":287},{"n":174,"text":"\t\t\tsuper({","atom":"a2797","author":"pinch","version":287},{"n":175,"text":"\t\t\t\twrite: (chunk) => void hash.update(chunk),","atom":"a2797","author":"pinch","version":287},{"n":176,"text":"\t\t\t\tclose: () => {","atom":"a2797","author":"pinch","version":287},{"n":177,"text":"\t\t\t\t\tconst b = hash.digest();","atom":"a2797","author":"pinch","version":287},{"n":178,"text":"\t\t\t\t\tdone(b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength) as ArrayBuffer);","atom":"a2797","author":"pinch","version":287},{"n":179,"text":"\t\t\t\t},","atom":"a2797","author":"pinch","version":287},{"n":180,"text":"\t\t\t});","atom":"a2797","author":"pinch","version":287},{"n":181,"text":"\t\t\tthis.digest = digest;","atom":"a2797","author":"pinch","version":287},{"n":182,"text":"\t\t}","atom":"a2797","author":"pinch","version":287},{"n":183,"text":"\t}","atom":"a2797","author":"pinch","version":287},{"n":184,"text":"\tc.DigestStream = DigestStream;","atom":"a2797","author":"pinch","version":287},{"n":185,"text":"}","atom":"a2797","author":"pinch","version":287},{"n":186,"text":"","atom":"a2797","author":"pinch","version":287},{"n":187,"text":"// --- Loading the server's code ------------------------------------------------------------------------------------","atom":"a2797","author":"pinch","version":287},{"n":188,"text":"","atom":"a2797","author":"pinch","version":287},{"n":189,"text":"type Server = {","atom":"a2797","author":"pinch","version":287},{"n":190,"text":"\tDatabaseSync: new (path: string) => Db;","atom":"a2797","author":"pinch","version":287},{"n":191,"text":"\thandle: (request: Request, env: unknown, ctx: unknown, issues: unknown) => Promise<Response>;","atom":"a2797","author":"pinch","version":287},{"n":192,"text":"\tProjectObject: new (ctx: unknown, env: unknown) => object;","atom":"a2797","author":"pinch","version":287},{"n":193,"text":"\tIssueProject: new (ctx: unknown, env: unknown) => object;","atom":"a2873","author":"pinch","version":294},{"n":194,"text":"\tissuesFetch: (request: Request, env: unknown, ctx: unknown, route: unknown) => Promise<Response>;","atom":"a2873","author":"pinch","version":294},{"n":195,"text":"};","atom":"a2797","author":"pinch","version":287},{"n":196,"text":"let server: Promise<Server> | undefined;","atom":"a2797","author":"pinch","version":287},{"n":197,"text":"","atom":"a2797","author":"pinch","version":287},{"n":198,"text":"/** Node's SQLite says it's experimental on every start; that line would land in every local command's output. */","atom":"a2797","author":"pinch","version":287},{"n":199,"text":"function quietSqliteWarning(): void {","atom":"a2797","author":"pinch","version":287},{"n":200,"text":"\tconst emit = process.emitWarning;","atom":"a2797","author":"pinch","version":287},{"n":201,"text":"\tif ((emit as { quiet?: boolean }).quiet) return;","atom":"a2797","author":"pinch","version":287},{"n":202,"text":"\tconst quiet = ((warning: string | Error, ...rest: unknown[]) => {","atom":"a2797","author":"pinch","version":287},{"n":203,"text":"\t\tconst text = typeof warning === \"string\" ? warning : warning.message;","atom":"a2797","author":"pinch","version":287},{"n":204,"text":"\t\tif (text.startsWith(\"SQLite is an experimental feature\")) return;","atom":"a2797","author":"pinch","version":287},{"n":205,"text":"\t\treturn (emit as (...a: unknown[]) => void).call(process, warning, ...rest);","atom":"a2797","author":"pinch","version":287},{"n":206,"text":"\t}) as typeof process.emitWarning;","atom":"a2797","author":"pinch","version":287},{"n":207,"text":"\t(quiet as unknown as { quiet: boolean }).quiet = true;","atom":"a2797","author":"pinch","version":287},{"n":208,"text":"\tprocess.emitWarning = quiet;","atom":"a2797","author":"pinch","version":287},{"n":209,"text":"}","atom":"a2797","author":"pinch","version":287},{"n":210,"text":"","atom":"a2797","author":"pinch","version":287},{"n":211,"text":"export const NODE_TOO_OLD = `local projects need Node 22.13 or later, for its built-in SQLite; this is Node ${process.versions.node}`;","atom":"a2797","author":"pinch","version":287},{"n":212,"text":"","atom":"a2797","author":"pinch","version":287},{"n":213,"text":"function loadServer(): Promise<Server> {","atom":"a2797","author":"pinch","version":287},{"n":214,"text":"\tserver ??= (async () => {","atom":"a2797","author":"pinch","version":287},{"n":215,"text":"\t\tquietSqliteWarning();","atom":"a2797","author":"pinch","version":287},{"n":216,"text":"\t\tlet sqlite: { DatabaseSync: Server[\"DatabaseSync\"] };","atom":"a2797","author":"pinch","version":287},{"n":217,"text":"\t\ttry {","atom":"a2797","author":"pinch","version":287},{"n":218,"text":"\t\t\tsqlite = (await import(\"node:sqlite\")) as unknown as typeof sqlite;","atom":"a2797","author":"pinch","version":287},{"n":219,"text":"\t\t} catch {","atom":"a2797","author":"pinch","version":287},{"n":220,"text":"\t\t\tthrow new LocalError(NODE_TOO_OLD);","atom":"a2797","author":"pinch","version":287},{"n":221,"text":"\t\t}","atom":"a2797","author":"pinch","version":287},{"n":222,"text":"\t\tawait installDigestStream();","atom":"a2797","author":"pinch","version":287},{"n":223,"text":"\t\t// Run as .ts files, the server's `import { DurableObject } from \"cloudflare:workers\"` needs a stand-in. A built","atom":"a2797","author":"pinch","version":287},{"n":224,"text":"\t\t// copy has it already: the build points the import at the same file (scripts/build-client.mjs).","atom":"a2824","author":"pinch","version":287},{"n":225,"text":"\t\tconst standIn = new URL(\"./durable-object-stand-in.ts\", import.meta.url).href;","atom":"a2824","author":"pinch","version":287},{"n":226,"text":"\t\tconst mod = (await import(\"node:module\")) as unknown as {","atom":"a2797","author":"pinch","version":287},{"n":227,"text":"\t\t\tregisterHooks?: (hooks: unknown) => unknown;","atom":"a2837","author":"pinch","version":289},{"n":228,"text":"\t\t};","atom":"a2797","author":"pinch","version":287},{"n":229,"text":"\t\t// The hook stays for the rest of the process: deregistering it crashes Node 24 at exit when the compile cache","atom":"a2837","author":"pinch","version":289},{"n":230,"text":"\t\t// is on (client/avcs.ts turns it on). It answers only cloudflare:workers.","atom":"a2837","author":"pinch","version":289},{"n":231,"text":"\t\tmod.registerHooks?.({","atom":"a2837","author":"pinch","version":289},{"n":232,"text":"\t\t\tresolve(specifier: string, context: unknown, next: (s: string, c: unknown) => unknown) {","atom":"a2797","author":"pinch","version":287},{"n":233,"text":"\t\t\t\tif (specifier === \"cloudflare:workers\") return { url: standIn, shortCircuit: true };","atom":"a2824","author":"pinch","version":287},{"n":234,"text":"\t\t\t\treturn next(specifier, context);","atom":"a2797","author":"pinch","version":287},{"n":235,"text":"\t\t\t},","atom":"a2797","author":"pinch","version":287},{"n":236,"text":"\t\t});","atom":"a2797","author":"pinch","version":287},{"n":237,"text":"\t\tlet loaded: typeof import(\"./local-server.mjs\");","atom":"a2837","author":"pinch","version":289},{"n":238,"text":"\t\ttry {","atom":"a2797","author":"pinch","version":287},{"n":239,"text":"\t\t\tloaded = await import(\"./local-server.mjs\");","atom":"a2837","author":"pinch","version":289},{"n":240,"text":"\t\t} catch (e) {","atom":"a2837","author":"pinch","version":289},{"n":241,"text":"\t\t\t// Nothing is reached for here: a part of the client is missing (its packages not installed, say).","atom":"a2837","author":"pinch","version":289},{"n":242,"text":"\t\t\tthrow new LocalError(","atom":"a2837","author":"pinch","version":289},{"n":243,"text":"\t\t\t\t`local projects couldn't load the server's code: ${e instanceof Error ? e.message : String(e)}`,","atom":"a2837","author":"pinch","version":289},{"n":244,"text":"\t\t\t);","atom":"a2837","author":"pinch","version":289},{"n":245,"text":"\t\t}","atom":"a2797","author":"pinch","version":287},{"n":246,"text":"\t\treturn {","atom":"a2874","author":"pinch","version":294},{"n":247,"text":"\t\t\tDatabaseSync: sqlite.DatabaseSync,","atom":"a2874","author":"pinch","version":294},{"n":248,"text":"\t\t\thandle: loaded.handle,","atom":"a2874","author":"pinch","version":294},{"n":249,"text":"\t\t\tProjectObject: loaded.ProjectObject,","atom":"a2874","author":"pinch","version":294},{"n":250,"text":"\t\t\tIssueProject: loaded.IssueProject,","atom":"a2874","author":"pinch","version":294},{"n":251,"text":"\t\t\tissuesFetch: loaded.issuesFetch,","atom":"a2874","author":"pinch","version":294},{"n":252,"text":"\t\t};","atom":"a2874","author":"pinch","version":294},{"n":253,"text":"\t})();","atom":"a2797","author":"pinch","version":287},{"n":254,"text":"\treturn server;","atom":"a2797","author":"pinch","version":287},{"n":255,"text":"}","atom":"a2797","author":"pinch","version":287},{"n":256,"text":"","atom":"a2797","author":"pinch","version":287},{"n":257,"text":"/** What stops a local project from opening at all: said plainly, like a usage error. */","atom":"a2824","author":"pinch","version":287},{"n":258,"text":"export class LocalError extends UsageError {}","atom":"a2824","author":"pinch","version":287},{"n":259,"text":"","atom":"a2797","author":"pinch","version":287},{"n":260,"text":"// --- One store, as a fetch -----------------------------------------------------------------------------------------","atom":"a2797","author":"pinch","version":287},{"n":261,"text":"","atom":"a2797","author":"pinch","version":287},{"n":262,"text":"interface Open {","atom":"a2797","author":"pinch","version":287},{"n":263,"text":"\tdb: Db;","atom":"a2797","author":"pinch","version":287},{"n":264,"text":"\tstorage: ReturnType<typeof storageOver>;","atom":"a2797","author":"pinch","version":287},{"n":265,"text":"\tobject: object | undefined;","atom":"a2797","author":"pinch","version":287},{"n":266,"text":"\t/** PRAGMA data_version when this process last used the project: it changes when another process writes. */","atom":"a2797","author":"pinch","version":287},{"n":267,"text":"\tseen: number | undefined;","atom":"a2797","author":"pinch","version":287},{"n":268,"text":"\t/** The project's issues, asks and news: issues.sqlite beside it, opened when a call first reaches them. */","atom":"a2875","author":"pinch","version":294},{"n":269,"text":"\tissues?: { db: Db; storage: ReturnType<typeof storageOver> };","atom":"a2875","author":"pinch","version":294},{"n":270,"text":"\t/** The issues object for the call under way: made again for each call, as another process may have written. */","atom":"a2875","author":"pinch","version":294},{"n":271,"text":"\tissueObject?: object;","atom":"a2875","author":"pinch","version":294},{"n":272,"text":"}","atom":"a2797","author":"pinch","version":287},{"n":273,"text":"","atom":"a2824","author":"pinch","version":287},{"n":274,"text":"/** Every store file this process has open: closed when its command ends (closeLocalStores). */","atom":"a2824","author":"pinch","version":287},{"n":275,"text":"const opened = new Set<Db>();","atom":"a2824","author":"pinch","version":287},{"n":276,"text":"","atom":"a2797","author":"pinch","version":287},{"n":277,"text":"/** Closes every local project this process opened. Its next call opens them again. */","atom":"a2824","author":"pinch","version":287},{"n":278,"text":"export function closeLocalStores(): void {","atom":"a2824","author":"pinch","version":287},{"n":279,"text":"\tfor (const db of opened) {","atom":"a2824","author":"pinch","version":287},{"n":280,"text":"\t\ttry {","atom":"a2824","author":"pinch","version":287},{"n":281,"text":"\t\t\tdb.close();","atom":"a2824","author":"pinch","version":287},{"n":282,"text":"\t\t} catch {}","atom":"a2824","author":"pinch","version":287},{"n":283,"text":"\t}","atom":"a2824","author":"pinch","version":287},{"n":284,"text":"\topened.clear();","atom":"a2824","author":"pinch","version":287},{"n":285,"text":"}","atom":"a2824","author":"pinch","version":287},{"n":286,"text":"","atom":"a2824","author":"pinch","version":287},{"n":287,"text":"/** A project's calls, and its issues, asks and news, which the open server keeps at /issues/p/<project>/. */","atom":"a2876","author":"pinch","version":294},{"n":288,"text":"const PROJECT_PATH = /^(?:\\/issues)?\\/p\\/([^/]+)\\//;","atom":"a2876","author":"pinch","version":294},{"n":289,"text":"/** A project's name is also its folder in the store, so it never starts with a dot (\".\" and \"..\" would leave it). */","atom":"a2913","author":"pinch","version":300},{"n":290,"text":"const NAME = /^[A-Za-z0-9_-][A-Za-z0-9._-]{0,99}$/;","atom":"a2913","author":"pinch","version":300},{"n":291,"text":"const json = (status: number, body: unknown) => Response.json(body, { status });","atom":"a2797","author":"pinch","version":287},{"n":292,"text":"","atom":"a2797","author":"pinch","version":287},{"n":293,"text":"/**","atom":"a2797","author":"pinch","version":287},{"n":294,"text":" * The fetch a local folder's calls go through: each call is answered by the open server's router, in this process,","atom":"a2797","author":"pinch","version":287},{"n":295,"text":" * against the project's SQLite file in `dir`. Only init makes a project's file.","atom":"a2797","author":"pinch","version":287},{"n":296,"text":" */","atom":"a2797","author":"pinch","version":287},{"n":297,"text":"export function localFetch(dir: string): (input: string, init?: RequestInit) => Promise<Response> {","atom":"a2797","author":"pinch","version":287},{"n":298,"text":"\tconst open = new Map<string, Open>();","atom":"a2797","author":"pinch","version":287},{"n":299,"text":"\tlet opening: Server | undefined;","atom":"a2797","author":"pinch","version":287},{"n":300,"text":"\tconst openProject = (name: string, create: boolean): Open | undefined => {","atom":"a2797","author":"pinch","version":287},{"n":301,"text":"\t\tconst existing = open.get(name);","atom":"a2797","author":"pinch","version":287},{"n":302,"text":"\t\tif (existing && opened.has(existing.db)) return existing;","atom":"a2824","author":"pinch","version":287},{"n":303,"text":"\t\tconst folder = join(dir, name);","atom":"a2797","author":"pinch","version":287},{"n":304,"text":"\t\tconst file = join(folder, \"project.sqlite\");","atom":"a2797","author":"pinch","version":287},{"n":305,"text":"\t\tif (create) mkdirSync(folder, { recursive: true });","atom":"a2797","author":"pinch","version":287},{"n":306,"text":"\t\telse if (!existsSync(file)) return undefined;","atom":"a2798","author":"pinch","version":287},{"n":307,"text":"\t\tconst db = new opening!.DatabaseSync(file);","atom":"a2798","author":"pinch","version":287},{"n":308,"text":"\t\topened.add(db);","atom":"a2824","author":"pinch","version":287},{"n":309,"text":"\t\tdb.exec(\"PRAGMA journal_mode = WAL; PRAGMA busy_timeout = 120000; PRAGMA synchronous = NORMAL\");","atom":"a2797","author":"pinch","version":287},{"n":310,"text":"\t\tconst project = { db, storage: storageOver(db), object: undefined, seen: undefined };","atom":"a2797","author":"pinch","version":287},{"n":311,"text":"\t\topen.set(name, project);","atom":"a2797","author":"pinch","version":287},{"n":312,"text":"\t\treturn project;","atom":"a2797","author":"pinch","version":287},{"n":313,"text":"\t};","atom":"a2797","author":"pinch","version":287},{"n":314,"text":"\tconst env = (name: string) => ({","atom":"a2797","author":"pinch","version":287},{"n":315,"text":"\t\tABSO_TOKEN: LOCAL_TOKEN,","atom":"a2797","author":"pinch","version":287},{"n":316,"text":"\t\tABSO_ARTIFACTS: \"off\",","atom":"a2797","author":"pinch","version":287},{"n":317,"text":"\t\tABSO_DISK_FIRST: \"off\",","atom":"a2797","author":"pinch","version":287},{"n":318,"text":"\t\tPROJECT: {","atom":"a2797","author":"pinch","version":287},{"n":319,"text":"\t\t\tidFromName: (n: string) => n,","atom":"a2797","author":"pinch","version":287},{"n":320,"text":"\t\t\tget: (n: string) => {","atom":"a2797","author":"pinch","version":287},{"n":321,"text":"\t\t\t\tconst p = open.get(n);","atom":"a2797","author":"pinch","version":287},{"n":322,"text":"\t\t\t\tif (!p || n !== name) throw new LocalError(`no local project ${n}`);","atom":"a2797","author":"pinch","version":287},{"n":323,"text":"\t\t\t\tp.object ??= new opening!.ProjectObject(","atom":"a2797","author":"pinch","version":287},{"n":324,"text":"\t\t\t\t\t{ id: { toString: () => n, name: n }, storage: p.storage, waitUntil: () => {} },","atom":"a2797","author":"pinch","version":287},{"n":325,"text":"\t\t\t\t\tenv(name),","atom":"a2797","author":"pinch","version":287},{"n":326,"text":"\t\t\t\t);","atom":"a2797","author":"pinch","version":287},{"n":327,"text":"\t\t\t\treturn p.object;","atom":"a2797","author":"pinch","version":287},{"n":328,"text":"\t\t\t},","atom":"a2797","author":"pinch","version":287},{"n":329,"text":"\t\t},","atom":"a2797","author":"pinch","version":287},{"n":330,"text":"\t\tISSUES_DO: {","atom":"a2877","author":"pinch","version":294},{"n":331,"text":"\t\t\tidFromName: (n: string) => n,","atom":"a2877","author":"pinch","version":294},{"n":332,"text":"\t\t\tget: (n: string) => {","atom":"a2877","author":"pinch","version":294},{"n":333,"text":"\t\t\t\tconst p = open.get(n);","atom":"a2877","author":"pinch","version":294},{"n":334,"text":"\t\t\t\tif (!p || n !== name) throw new LocalError(`no local project ${n}`);","atom":"a2877","author":"pinch","version":294},{"n":335,"text":"\t\t\t\tif (p.issues === undefined || !opened.has(p.issues.db)) {","atom":"a2877","author":"pinch","version":294},{"n":336,"text":"\t\t\t\t\tconst db = new opening!.DatabaseSync(join(dir, name, \"issues.sqlite\"));","atom":"a2877","author":"pinch","version":294},{"n":337,"text":"\t\t\t\t\topened.add(db);","atom":"a2877","author":"pinch","version":294},{"n":338,"text":"\t\t\t\t\tdb.exec(\"PRAGMA journal_mode = WAL; PRAGMA busy_timeout = 120000; PRAGMA synchronous = NORMAL\");","atom":"a2877","author":"pinch","version":294},{"n":339,"text":"\t\t\t\t\tp.issues = { db, storage: storageOver(db) };","atom":"a2877","author":"pinch","version":294},{"n":340,"text":"\t\t\t\t}","atom":"a2877","author":"pinch","version":294},{"n":341,"text":"\t\t\t\t// Its writes need no lock of their own: every call holds the project file's (see below).","atom":"a2877","author":"pinch","version":294},{"n":342,"text":"\t\t\t\tp.issueObject ??= new opening!.IssueProject(","atom":"a2884","author":"pinch","version":294},{"n":343,"text":"\t\t\t\t\t{ id: { toString: () => n, name: n }, storage: p.issues.storage },","atom":"a2884","author":"pinch","version":294},{"n":344,"text":"\t\t\t\t\tenv(name),","atom":"a2884","author":"pinch","version":294},{"n":345,"text":"\t\t\t\t);","atom":"a2884","author":"pinch","version":294},{"n":346,"text":"\t\t\t\treturn p.issueObject;","atom":"a2877","author":"pinch","version":294},{"n":347,"text":"\t\t\t},","atom":"a2877","author":"pinch","version":294},{"n":348,"text":"\t\t},","atom":"a2877","author":"pinch","version":294},{"n":349,"text":"\t});","atom":"a2797","author":"pinch","version":287},{"n":350,"text":"\t// One call at a time, as a Durable Object takes them: a call holds its project's write transaction across awaits,","atom":"a2914","author":"pinch","version":300},{"n":351,"text":"\t// and the connection can't start a second (two calls at once come from Promise.all in ci and waiting --mine).","atom":"a2914","author":"pinch","version":300},{"n":352,"text":"\tlet last: Promise<unknown> = Promise.resolve();","atom":"a2914","author":"pinch","version":300},{"n":353,"text":"\treturn (input, init) => {","atom":"a2914","author":"pinch","version":300},{"n":354,"text":"\t\tconst next = last.then(","atom":"a2914","author":"pinch","version":300},{"n":355,"text":"\t\t\t() => call(input, init),","atom":"a2914","author":"pinch","version":300},{"n":356,"text":"\t\t\t() => call(input, init),","atom":"a2914","author":"pinch","version":300},{"n":357,"text":"\t\t);","atom":"a2914","author":"pinch","version":300},{"n":358,"text":"\t\tlast = next.catch(() => {});","atom":"a2914","author":"pinch","version":300},{"n":359,"text":"\t\treturn next;","atom":"a2914","author":"pinch","version":300},{"n":360,"text":"\t};","atom":"a2914","author":"pinch","version":300},{"n":361,"text":"","atom":"a2914","author":"pinch","version":300},{"n":362,"text":"\tasync function call(input: string, init: RequestInit = {}): Promise<Response> {","atom":"a2914","author":"pinch","version":300},{"n":363,"text":"\t\tconst s = await loadServer();","atom":"a2797","author":"pinch","version":287},{"n":364,"text":"\t\topening = s;","atom":"a2797","author":"pinch","version":287},{"n":365,"text":"\t\tconst url = new URL(input);","atom":"a2797","author":"pinch","version":287},{"n":366,"text":"\t\tconst match = PROJECT_PATH.exec(url.pathname);","atom":"a2797","author":"pinch","version":287},{"n":367,"text":"\t\tif (!match) return json(404, { error: \"a local store answers only project calls\" });","atom":"a2797","author":"pinch","version":287},{"n":368,"text":"\t\tconst name = decodeURIComponent(match[1]!);","atom":"a2797","author":"pinch","version":287},{"n":369,"text":"\t\tif (!NAME.test(name)) return json(400, { error: \"project names use letters, digits, '.', '_' and '-'\" });","atom":"a2797","author":"pinch","version":287},{"n":370,"text":"\t\tconst p = openProject(name, url.pathname === `/p/${match[1]}/init`);","atom":"a2797","author":"pinch","version":287},{"n":371,"text":"\t\tif (!p) return json(404, { error: `no local project ${name} in ${dir}` });","atom":"a2797","author":"pinch","version":287},{"n":372,"text":"\t\tconst headers = new Headers(init.headers);","atom":"a2797","author":"pinch","version":287},{"n":373,"text":"\t\theaders.set(\"authorization\", `Bearer ${LOCAL_TOKEN}`);","atom":"a2797","author":"pinch","version":287},{"n":374,"text":"\t\tconst request = new Request(url, { ...init, headers });","atom":"a2797","author":"pinch","version":287},{"n":375,"text":"\t\tconst waits: Promise<unknown>[] = [];","atom":"a2797","author":"pinch","version":287},{"n":376,"text":"\t\t// Every call, issues ones too, holds the project file's lock, so local writers of the project and of its","atom":"a2878","author":"pinch","version":294},{"n":377,"text":"\t\t// issues take one lock in one order.","atom":"a2878","author":"pinch","version":294},{"n":378,"text":"\t\tp.db.exec(\"BEGIN IMMEDIATE\");","atom":"a2797","author":"pinch","version":287},{"n":379,"text":"\t\tp.issueObject = undefined;","atom":"a2878","author":"pinch","version":294},{"n":380,"text":"\t\ttry {","atom":"a2797","author":"pinch","version":287},{"n":381,"text":"\t\t\tconst version = (p.db.prepare(\"PRAGMA data_version\").get() as { data_version: number }).data_version;","atom":"a2797","author":"pinch","version":287},{"n":382,"text":"\t\t\tif (p.seen !== undefined && version !== p.seen) p.object = undefined;","atom":"a2797","author":"pinch","version":287},{"n":383,"text":"\t\t\tconst response = await s.handle(","atom":"a2824","author":"pinch","version":287},{"n":384,"text":"\t\t\t\trequest,","atom":"a2824","author":"pinch","version":287},{"n":385,"text":"\t\t\t\tenv(name),","atom":"a2824","author":"pinch","version":287},{"n":386,"text":"\t\t\t\t{ waitUntil: (w: Promise<unknown>) => waits.push(w) },","atom":"a2824","author":"pinch","version":287},{"n":387,"text":"\t\t\t\ts.issuesFetch,","atom":"a2878","author":"pinch","version":294},{"n":388,"text":"\t\t\t);","atom":"a2824","author":"pinch","version":287},{"n":389,"text":"\t\t\tawait Promise.allSettled(waits);","atom":"a2797","author":"pinch","version":287},{"n":390,"text":"\t\t\t// The answer is read whole before the write is kept, so a body that fails to arrive keeps nothing either.","atom":"a2797","author":"pinch","version":287},{"n":391,"text":"\t\t\tconst body = await response.arrayBuffer();","atom":"a2797","author":"pinch","version":287},{"n":392,"text":"\t\t\tp.db.exec(\"COMMIT\");","atom":"a2797","author":"pinch","version":287},{"n":393,"text":"\t\t\tp.seen = (p.db.prepare(\"PRAGMA data_version\").get() as { data_version: number }).data_version;","atom":"a2797","author":"pinch","version":287},{"n":394,"text":"\t\t\treturn new Response(body, { status: response.status, headers: response.headers });","atom":"a2797","author":"pinch","version":287},{"n":395,"text":"\t\t} catch (e) {","atom":"a2797","author":"pinch","version":287},{"n":396,"text":"\t\t\ttry {","atom":"a2797","author":"pinch","version":287},{"n":397,"text":"\t\t\t\tp.db.exec(\"ROLLBACK\");","atom":"a2797","author":"pinch","version":287},{"n":398,"text":"\t\t\t} catch {}","atom":"a2797","author":"pinch","version":287},{"n":399,"text":"\t\t\t// What the object held in memory may be from the rolled-back call.","atom":"a2797","author":"pinch","version":287},{"n":400,"text":"\t\t\tp.object = undefined;","atom":"a2797","author":"pinch","version":287},{"n":401,"text":"\t\t\tp.seen = undefined;","atom":"a2797","author":"pinch","version":287},{"n":402,"text":"\t\t\tif (e instanceof LocalError) throw e;","atom":"a2824","author":"pinch","version":287},{"n":403,"text":"\t\t\t// Where the Workers runtime answers a throw with a 500, so does this.","atom":"a2824","author":"pinch","version":287},{"n":404,"text":"\t\t\treturn json(500, { error: e instanceof Error ? e.message : String(e) });","atom":"a2824","author":"pinch","version":287},{"n":405,"text":"\t\t}","atom":"a2797","author":"pinch","version":287},{"n":406,"text":"\t}","atom":"a2919","author":"pinch","version":300},{"n":407,"text":"}","atom":"a2797","author":"pinch","version":287}],"atoms":[{"atom":"a2797","author":"pinch","message":"","time":1792119086066,"timeIso":"2026-10-16T02:51:26.066Z","publish":{"draft":null,"version":287,"agent":"pinch","message":"Local projects: abso init --local keeps a project's history on this machine, with no server, sign-in or network\n\nA local folder's calls never leave the process. The client runs the open server's own router and project object (server/src) in-process, over Node's built-in SQLite. It's the same engine with the same answers, so what the commands print matches a server.\n\n- abso init --local [--project <name>] [--agent <name>] [--store <folder>] makes the project, and abso join <project> --local adds a folder. After that, record, push, pull, log, blame and the held collisions work as usual. The folder's config says \"server\": \"local\".\n- Where the store lives: --store (kept in the folder's config; a store inside the folder is left out of its files through .absoignore), else ABSO_STORE, else this user's data folder: %LOCALAPPDATA%\\abso\\store, ~/Library/Application Support/abso/store, or $XDG_DATA_HOME/abso/store. Nothing needs a writable home folder when ABSO_STORE or --store is set.\n- Each project is <store>/<project>/project.sqlite. Every call runs in one SQLite write transaction, which is the store's lock: other processes wait for it, and a process that dies mid-call keeps nothing half-written. A process reloads the project only when SQLite's data_version shows another process wrote.\n- No credential goes with a local folder's calls. The edit mod leaves local folders alone, so abso record sends their edits. Issues, asks and news aren't in local projects yet.\n- Needs Node 22.13 or later (node:sqlite); its experimental warning is kept out of the output. Run as .ts, a module hook supplies the Durable Object base class (client/src/durable-object-stand-in.ts); the build aliases cloudflare:workers to the same file. client/src/local-server.mjs, with its .d.mts, keeps the client's typecheck out of server/src, which has its own.\n- Each command closes the store files it opened.\n\nTests: local (8, with fetch replaced by one that throws: init, record, push, join, pull, log, blame, a held collision, --store inside the folder, refusals), plus failed-start, install, caller, doctor, lost-pull, help, body-files: 60 pass; tsc clean. The bundle built with the alias runs init, push and log locally.","time":1792119778236,"timeIso":"2026-10-16T03:02:58.236Z"}},{"atom":"a2798","author":"pinch","message":"","time":1792119111079,"timeIso":"2026-10-16T02:51:51.079Z","publish":{"draft":null,"version":287,"agent":"pinch","message":"Local projects: abso init --local keeps a project's history on this machine, with no server, sign-in or network\n\nA local folder's calls never leave the process. The client runs the open server's own router and project object (server/src) in-process, over Node's built-in SQLite. It's the same engine with the same answers, so what the commands print matches a server.\n\n- abso init --local [--project <name>] [--agent <name>] [--store <folder>] makes the project, and abso join <project> --local adds a folder. After that, record, push, pull, log, blame and the held collisions work as usual. The folder's config says \"server\": \"local\".\n- Where the store lives: --store (kept in the folder's config; a store inside the folder is left out of its files through .absoignore), else ABSO_STORE, else this user's data folder: %LOCALAPPDATA%\\abso\\store, ~/Library/Application Support/abso/store, or $XDG_DATA_HOME/abso/store. Nothing needs a writable home folder when ABSO_STORE or --store is set.\n- Each project is <store>/<project>/project.sqlite. Every call runs in one SQLite write transaction, which is the store's lock: other processes wait for it, and a process that dies mid-call keeps nothing half-written. A process reloads the project only when SQLite's data_version shows another process wrote.\n- No credential goes with a local folder's calls. The edit mod leaves local folders alone, so abso record sends their edits. Issues, asks and news aren't in local projects yet.\n- Needs Node 22.13 or later (node:sqlite); its experimental warning is kept out of the output. Run as .ts, a module hook supplies the Durable Object base class (client/src/durable-object-stand-in.ts); the build aliases cloudflare:workers to the same file. client/src/local-server.mjs, with its .d.mts, keeps the client's typecheck out of server/src, which has its own.\n- Each command closes the store files it opened.\n\nTests: local (8, with fetch replaced by one that throws: init, record, push, join, pull, log, blame, a held collision, --store inside the folder, refusals), plus failed-start, install, caller, doctor, lost-pull, help, body-files: 60 pass; tsc clean. The bundle built with the alias runs init, push and log locally.","time":1792119778236,"timeIso":"2026-10-16T03:02:58.236Z"}},{"atom":"a2824","author":"pinch","message":"","time":1792119773277,"timeIso":"2026-10-16T03:02:53.277Z","publish":{"draft":null,"version":287,"agent":"pinch","message":"Local projects: abso init --local keeps a project's history on this machine, with no server, sign-in or network\n\nA local folder's calls never leave the process. The client runs the open server's own router and project object (server/src) in-process, over Node's built-in SQLite. It's the same engine with the same answers, so what the commands print matches a server.\n\n- abso init --local [--project <name>] [--agent <name>] [--store <folder>] makes the project, and abso join <project> --local adds a folder. After that, record, push, pull, log, blame and the held collisions work as usual. The folder's config says \"server\": \"local\".\n- Where the store lives: --store (kept in the folder's config; a store inside the folder is left out of its files through .absoignore), else ABSO_STORE, else this user's data folder: %LOCALAPPDATA%\\abso\\store, ~/Library/Application Support/abso/store, or $XDG_DATA_HOME/abso/store. Nothing needs a writable home folder when ABSO_STORE or --store is set.\n- Each project is <store>/<project>/project.sqlite. Every call runs in one SQLite write transaction, which is the store's lock: other processes wait for it, and a process that dies mid-call keeps nothing half-written. A process reloads the project only when SQLite's data_version shows another process wrote.\n- No credential goes with a local folder's calls. The edit mod leaves local folders alone, so abso record sends their edits. Issues, asks and news aren't in local projects yet.\n- Needs Node 22.13 or later (node:sqlite); its experimental warning is kept out of the output. Run as .ts, a module hook supplies the Durable Object base class (client/src/durable-object-stand-in.ts); the build aliases cloudflare:workers to the same file. client/src/local-server.mjs, with its .d.mts, keeps the client's typecheck out of server/src, which has its own.\n- Each command closes the store files it opened.\n\nTests: local (8, with fetch replaced by one that throws: init, record, push, join, pull, log, blame, a held collision, --store inside the folder, refusals), plus failed-start, install, caller, doctor, lost-pull, help, body-files: 60 pass; tsc clean. The bundle built with the alias runs init, push and log locally.","time":1792119778236,"timeIso":"2026-10-16T03:02:58.236Z"}},{"atom":"a2837","author":"pinch","message":"","time":1792120394349,"timeIso":"2026-10-16T03:13:14.349Z","publish":{"draft":null,"version":289,"agent":"pinch","message":"Local projects run as their own processes again: no compile cache for a local command, and plain words when the server's code can't load\n\nAt 287, every local command run as `node client/abso.ts` could crash with a segmentation fault (exit 139, at random, init and join included). The cause is Node's compile cache, which client/avcs.ts turns on, together with the module hook that gives the open server's code its cloudflare:workers stand-in. avcs.ts now leaves the cache off for a --local command and in a folder whose config names the server \"local\". The hook also stays registered rather than being removed after the import.\n\n- If the server's code can't load (a package missing, say), it's said as \"local projects couldn't load the server's code: ...\" rather than \"Can't reach local ... check your connection\".\n- In a local folder, status says \"It's a local project, in <store>/<project>.\" instead of \"Signed in with none.\", and skips the npm newer-client check, which reaches for the network.\n- worker/project/news.ts is Biome-formatted (only formatting), so the check gets past Biome again.\n- scripts/local-measure.ts times status, log, blame, pull and push as separate processes on a small and a large local history, with peak memory and the store's size. scripts/local-writers.ts pushes from 1, 4 and 16 writers at once to measure the store lock.\n\nTests: client/test/local.test.ts (9, one running init, push, status and log as child processes with the cache as it is); tsc and Biome clean. Three rounds of init, push and status as processes exit 0.","time":1792120394633,"timeIso":"2026-10-16T03:13:14.633Z"}},{"atom":"a2873","author":"pinch","message":"","time":1792121435284,"timeIso":"2026-10-16T03:30:35.284Z","publish":{"draft":null,"version":294,"agent":"pinch","message":"Local projects: issues, asks and news. The open server's issues code runs in the client's process as the project's does, over issues.sqlite beside project.sqlite in the store; every call, issues ones too, holds the project file's lock, so local writers take one lock in one order. abso issue, issues, ask, answer, waiting, news and start --issue work with the network off. Attachments and news --stream don't yet.","time":1792121598859,"timeIso":"2026-10-16T03:33:18.859Z"}},{"atom":"a2874","author":"pinch","message":"","time":1792121435697,"timeIso":"2026-10-16T03:30:35.697Z","publish":{"draft":null,"version":294,"agent":"pinch","message":"Local projects: issues, asks and news. The open server's issues code runs in the client's process as the project's does, over issues.sqlite beside project.sqlite in the store; every call, issues ones too, holds the project file's lock, so local writers take one lock in one order. abso issue, issues, ask, answer, waiting, news and start --issue work with the network off. Attachments and news --stream don't yet.","time":1792121598859,"timeIso":"2026-10-16T03:33:18.859Z"}},{"atom":"a2875","author":"pinch","message":"","time":1792121436010,"timeIso":"2026-10-16T03:30:36.010Z","publish":{"draft":null,"version":294,"agent":"pinch","message":"Local projects: issues, asks and news. The open server's issues code runs in the client's process as the project's does, over issues.sqlite beside project.sqlite in the store; every call, issues ones too, holds the project file's lock, so local writers take one lock in one order. abso issue, issues, ask, answer, waiting, news and start --issue work with the network off. Attachments and news --stream don't yet.","time":1792121598859,"timeIso":"2026-10-16T03:33:18.859Z"}},{"atom":"a2876","author":"pinch","message":"","time":1792121436197,"timeIso":"2026-10-16T03:30:36.197Z","publish":{"draft":null,"version":294,"agent":"pinch","message":"Local projects: issues, asks and news. The open server's issues code runs in the client's process as the project's does, over issues.sqlite beside project.sqlite in the store; every call, issues ones too, holds the project file's lock, so local writers take one lock in one order. abso issue, issues, ask, answer, waiting, news and start --issue work with the network off. Attachments and news --stream don't yet.","time":1792121598859,"timeIso":"2026-10-16T03:33:18.859Z"}},{"atom":"a2877","author":"pinch","message":"","time":1792121445655,"timeIso":"2026-10-16T03:30:45.655Z","publish":{"draft":null,"version":294,"agent":"pinch","message":"Local projects: issues, asks and news. The open server's issues code runs in the client's process as the project's does, over issues.sqlite beside project.sqlite in the store; every call, issues ones too, holds the project file's lock, so local writers take one lock in one order. abso issue, issues, ask, answer, waiting, news and start --issue work with the network off. Attachments and news --stream don't yet.","time":1792121598859,"timeIso":"2026-10-16T03:33:18.859Z"}},{"atom":"a2878","author":"pinch","message":"","time":1792121445824,"timeIso":"2026-10-16T03:30:45.824Z","publish":{"draft":null,"version":294,"agent":"pinch","message":"Local projects: issues, asks and news. The open server's issues code runs in the client's process as the project's does, over issues.sqlite beside project.sqlite in the store; every call, issues ones too, holds the project file's lock, so local writers take one lock in one order. abso issue, issues, ask, answer, waiting, news and start --issue work with the network off. Attachments and news --stream don't yet.","time":1792121598859,"timeIso":"2026-10-16T03:33:18.859Z"}},{"atom":"a2884","author":"pinch","message":"","time":1792121598473,"timeIso":"2026-10-16T03:33:18.473Z","publish":{"draft":null,"version":294,"agent":"pinch","message":"Local projects: issues, asks and news. The open server's issues code runs in the client's process as the project's does, over issues.sqlite beside project.sqlite in the store; every call, issues ones too, holds the project file's lock, so local writers take one lock in one order. abso issue, issues, ask, answer, waiting, news and start --issue work with the network off. Attachments and news --stream don't yet.","time":1792121598859,"timeIso":"2026-10-16T03:33:18.859Z"}},{"atom":"a2895","author":"capacity","message":"","time":1792126873957,"timeIso":"2026-10-16T05:01:13.957Z","publish":{"draft":null,"version":297,"agent":"capacity","message":"local-store's DigestStream check through a cast, so abso's worker typecheck passes on the pin (abso Capacity, 2026-10-16)\n\n- abso's worker compiles client/src/local-store.ts too (tool.lock.json), and its types have no globalThis.crypto: pinning core 288 onward failed its tsc with TS2339 at installDigestStream. The same object, read through a cast.\n- abso shared has been red since its 284 pin on caller.test.ts, which core 290 fixed; this lets that pin go up to here.\n\nChecks: core tsc clean; client/test/local.test.ts 10 of 10 pass; abso's worker tsc clean with this file in place.","time":1792126913197,"timeIso":"2026-10-16T05:01:53.197Z"}},{"atom":"a2913","author":"pinch","message":"","time":1792140552018,"timeIso":"2026-10-16T08:49:12.018Z","publish":{"draft":null,"version":300,"agent":"pinch","message":"Local projects take one call at a time, and a project's name can't start with a dot. A call holds its project's write transaction across awaits, so a second call started meanwhile (Promise.all in abso ci and waiting --mine) failed to begin its own; localFetch now runs calls in turn, as a Durable Object takes them. A name of . or .. put the project's file outside the store; names now start with a letter, digit, _ or -. Found in review.","time":1792140617142,"timeIso":"2026-10-16T08:50:17.142Z"}},{"atom":"a2914","author":"pinch","message":"","time":1792140552180,"timeIso":"2026-10-16T08:49:12.180Z","publish":{"draft":null,"version":300,"agent":"pinch","message":"Local projects take one call at a time, and a project's name can't start with a dot. A call holds its project's write transaction across awaits, so a second call started meanwhile (Promise.all in abso ci and waiting --mine) failed to begin its own; localFetch now runs calls in turn, as a Durable Object takes them. A name of . or .. put the project's file outside the store; names now start with a letter, digit, _ or -. Found in review.","time":1792140617142,"timeIso":"2026-10-16T08:50:17.142Z"}},{"atom":"a2919","author":"pinch","message":"","time":1792140616983,"timeIso":"2026-10-16T08:50:16.983Z","publish":{"draft":null,"version":300,"agent":"pinch","message":"Local projects take one call at a time, and a project's name can't start with a dot. A call holds its project's write transaction across awaits, so a second call started meanwhile (Promise.all in abso ci and waiting --mine) failed to begin its own; localFetch now runs calls in turn, as a Durable Object takes them. A name of . or .. put the project's file outside the store; names now start with a letter, digit, _ or -. Found in review.","time":1792140617142,"timeIso":"2026-10-16T08:50:17.142Z"}}]}