- MCP
- blame on this site's /mcp
- CLI
- abso blame client/test/local.test.ts --json
- JSON
- /christopher/abso-core/blame/client/test/local.test.ts?format=json
222 linespinch 100%Last change pinch in version 305,
222 lines from 10 changes in 6 versions.
pinch287Local projects: abso init --local keeps a project's history on this machine, with no server, sign-in or network
A 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.
- 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".
- 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.
- 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.
- 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.
- 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.
- Each command closes the store files it opened.
Tests: 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.Compare1// Local projects (abso init --local): a project whose history is in a store on this machine, answered by the open
2// server's own code in the client's process. Every test here runs with fetch replaced by one that throws, so any
3// call that would leave the machine fails the test.
5import assert from "node:assert/strict";
pinch289Local 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
At 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.
- 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".
- 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.
- worker/project/news.ts is Biome-formatted (only formatting), so the check gets past Biome again.
- 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.
Tests: 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.Compare6import { spawnSync } from "node:child_process";
pinch305abso init checks the project's name before any call, as join does. A name like .. went out as part of the request's path, where it collapsed, so a local init answered about project calls instead of naming the rule. The test now checks the message for .. and .hidden, and that init leaves the folder as it was.Compare7import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
pinch287Local projects: abso init --local keeps a project's history on this machine, with no server, sign-in or network
A 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.
- 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".
- 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.
- 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.
- 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.
- 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.
- Each command closes the store files it opened.
Tests: 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.Compare8import { tmpdir } from "node:os";
9import { join } from "node:path";
10import { after, before, describe, it } from "node:test";
pinch289Local 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
At 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.
- 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".
- 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.
- worker/project/news.ts is Biome-formatted (only formatting), so the check gets past Biome again.
- 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.
Tests: 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.Compare11import { fileURLToPath } from "node:url";
pinch300Local 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.Compare12import { closeLocalStores, LOCAL_BASE, localFetch } from "../src/local-store.ts";
pinch287Local projects: abso init --local keeps a project's history on this machine, with no server, sign-in or network
A 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.
- 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".
- 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.
- 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.
- 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.
- 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.
- Each command closes the store files it opened.
Tests: 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.Compare13import { main } from "../src/main.ts";
14import { stateDir } from "../src/state-dir.ts";
16const dirs: string[] = [];
17const temp = (label: string) => {
18 const d = mkdtempSync(join(tmpdir(), `abso-local-${label}-`));
19 dirs.push(d);
20 return d;
21};
23const outside: string[] = [];
24const realFetch = globalThis.fetch;
25before(() => {
26 globalThis.fetch = (async (input: unknown) => {
27 outside.push(String(input instanceof Request ? input.url : input));
28 throw new TypeError("network is off in this test");
29 }) as typeof fetch;
30});
31after(() => {
32 globalThis.fetch = realFetch;
33 for (const d of dirs) rmSync(d, { recursive: true, force: true, maxRetries: 5 });
34 assert.deepEqual(outside, [], "nothing reached for the network");
35});
37let store: string;
38const env = () => ({ ABSO_STORE: store, ABSO_SERVERS_FILE: "no-servers.json", ABSO_HOOK_FORCE: "1" });
39async function run(cwd: string, ...argv: string[]): Promise<{ exit: number; out: string; err: string }> {
40 const r = await main(argv, { cwd, env: env(), write: () => {} });
41 return { exit: r.exit, out: r.stdout, err: r.stderr };
42}
43const text = (dir: string, rel: string) => readFileSync(join(dir, rel), "utf8");
pinch298client/test/local.test.ts skips its suites, saying why, where no server/src sits beside the client. Local projects run the open server's code, and a platform that pins only client/ (abso's pin of 297) has none, so its root test failed on them. Here they all run as before.Compare45/** A copy of the client without the open server beside it (a platform that pins only client/) has no local projects to test. */
46const noServer = existsSync(fileURLToPath(new URL("../../server/src/router.ts", import.meta.url)))
47 ? false
48 : "no server/src beside this client, so no local projects";
50describe("a local project, with the network off", { skip: noServer }, () => {
pinch287Local projects: abso init --local keeps a project's history on this machine, with no server, sign-in or network
A 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.
- 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".
- 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.
- 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.
- 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.
- 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.
- Each command closes the store files it opened.
Tests: 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.Compare51 let alice: string;
52 let bob: string;
53 before(() => {
54 store = temp("store");
55 });
57 it("init --local makes the project in the store, with no sign-in", async () => {
58 alice = temp("alice");
59 writeFileSync(join(alice, "a.txt"), "one\ntwo\nthree\n");
60 const r = await run(alice, "init", "--local", "--project", "demo", "--agent", "alice");
61 assert.equal(r.exit, 0, r.out + r.err);
62 assert.match(r.out, /Created project demo at version 0 from 2 text files/, "a.txt and the starting .absoignore");
63 assert.doesNotMatch(r.out, /CI has nothing to run/);
64 assert.match(r.out, /It's a local project: its history is in .*demo, on this machine/);
65 assert.doesNotMatch(r.out + r.err, /Signing in/);
66 assert.ok(existsSync(join(store, "demo", "project.sqlite")));
67 const config = JSON.parse(readFileSync(join(stateDir(alice), "config.json"), "utf8"));
68 assert.equal(config.server, "local");
69 assert.equal(config.store, undefined, "the store came from ABSO_STORE, so the folder doesn't name it");
70 });
72 it("record and push make version 1, and log says so", async () => {
73 writeFileSync(join(alice, "a.txt"), "one\nTWO\nthree\n");
74 writeFileSync(join(alice, "b.txt"), "new\n");
75 assert.equal((await run(alice, "record")).exit, 0);
76 const pushed = await run(alice, "push", "-m", "Change two, add b");
77 assert.equal(pushed.exit, 0, pushed.out + pushed.err);
78 assert.match(pushed.out, /Pushed version 1/);
79 const log = await run(alice, "log");
80 assert.equal(log.exit, 0, log.err);
81 assert.match(log.out, /Change two, add b/);
82 });
84 it("a second folder joins, and pulls what the first pushes", async () => {
85 bob = temp("bob");
86 const joined = await run(bob, "join", "demo", "--local", "--agent", "bob", "--dir", bob);
87 assert.equal(joined.exit, 0, joined.out + joined.err);
88 assert.equal(text(bob, "a.txt"), "one\nTWO\nthree\n");
89 assert.equal(text(bob, "b.txt"), "new\n");
90 writeFileSync(join(alice, "b.txt"), "new\nmore\n");
91 assert.equal((await run(alice, "push", "-m", "More in b")).exit, 0);
92 const pulled = await run(bob, "pull");
93 assert.equal(pulled.exit, 0, pulled.out + pulled.err);
94 assert.equal(text(bob, "b.txt"), "new\nmore\n");
95 });
97 it("blame names who wrote each line", async () => {
98 const r = await run(bob, "blame", "a.txt");
99 assert.equal(r.exit, 0, r.err);
100 assert.match(r.out, /alice/);
101 assert.match(r.out, /TWO/);
102 });
104 it("a push that collides with work pushed since is held", async () => {
105 assert.equal((await run(bob, "pull")).exit, 0);
106 writeFileSync(join(alice, "a.txt"), "one\nalice's\nthree\n");
107 assert.equal((await run(alice, "push", "-m", "Alice's two")).exit, 0);
108 writeFileSync(join(bob, "a.txt"), "one\nbob's\nthree\n");
109 const held = await run(bob, "push", "-m", "Bob's two");
110 assert.notEqual(held.exit, 0);
111 assert.match(held.out + held.err, /collision/);
112 });
pinch294Local 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.Compare113
114 it("issues, asks and news work too, kept in issues.sqlite beside the project", async () => {
115 const opened = await run(alice, "issue", "new", "Fix the parser", "--agent", "bob");
116 assert.equal(opened.exit, 0, opened.out + opened.err);
117 assert.ok(existsSync(join(store, "demo", "issues.sqlite")));
118 const listed = await run(bob, "issues");
119 assert.equal(listed.exit, 0, listed.err);
120 assert.match(listed.out, /Fix the parser/);
121 const started = await run(bob, "start", "Parser fix", "--issue", "1");
122 assert.equal(started.exit, 0, started.out + started.err);
123 const asked = await run(alice, "ask", "bob", "Which grammar?", "--issue", "1");
124 assert.equal(asked.exit, 0, asked.out + asked.err);
125 const waiting = await run(bob, "waiting", "--mine");
126 assert.equal(waiting.exit, 0, waiting.err);
127 assert.match(waiting.out, /Which grammar\?/);
128 const answered = await run(bob, "answer", "1", "The new one");
129 assert.equal(answered.exit, 0, answered.out + answered.err);
130 const news = await run(alice, "news");
131 assert.equal(news.exit, 0, news.err);
132 assert.match(news.out, /The new one/);
133 const issue = await run(alice, "issue", "1");
134 assert.match(issue.out, /In progress|bob/);
135 });
pinch300Local 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.Compare136
137 it("two calls at once on one project are both answered, one after the other", async () => {
138 // As abso ci and waiting --mine make them, with Promise.all.
139 const local = localFetch(store);
140 const answers = await Promise.all([local(`${LOCAL_BASE}/p/demo/queue`), local(`${LOCAL_BASE}/p/demo/queue`)]);
141 closeLocalStores();
142 for (const a of answers) assert.equal(a.status, 200, await a.text());
143 });
145 it("a project's name can't start with a dot, so its folder stays inside the store", async () => {
146 const dir = temp("dots");
147 writeFileSync(join(dir, "a.txt"), "x\n");
pinch305abso init checks the project's name before any call, as join does. A name like .. went out as part of the request's path, where it collapsed, so a local init answered about project calls instead of naming the rule. The test now checks the message for .. and .hidden, and that init leaves the folder as it was.Compare148 for (const name of ["..", ".hidden"]) {
149 const r = await run(dir, "init", "--local", "--project", name, "--agent", "a");
150 assert.equal(r.exit, 1, r.out + r.err);
151 // The name rule says why, before any call is made (a ".." would collapse the call's path).
152 assert.match(r.err, /project names are letters, digits, dot, dash and underscore/);
153 }
pinch300Local 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.Compare154 assert.ok(!existsSync(join(store, "..", "project.sqlite")));
pinch305abso init checks the project's name before any call, as join does. A name like .. went out as part of the request's path, where it collapsed, so a local init answered about project calls instead of naming the rule. The test now checks the message for .. and .hidden, and that init leaves the folder as it was.Compare155 assert.deepEqual(readdirSync(dir), ["a.txt"], "init left nothing behind");
pinch300Local 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.Compare156 });
pinch287Local projects: abso init --local keeps a project's history on this machine, with no server, sign-in or network
A 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.
- 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".
- 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.
- 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.
- 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.
- 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.
- Each command closes the store files it opened.
Tests: 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.Compare157});
pinch298client/test/local.test.ts skips its suites, saying why, where no server/src sits beside the client. Local projects run the open server's code, and a platform that pins only client/ (abso's pin of 297) has none, so its root test failed on them. Here they all run as before.Compare159describe("where a local project's store is", { skip: noServer }, () => {
pinch287Local projects: abso init --local keeps a project's history on this machine, with no server, sign-in or network
A 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.
- 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".
- 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.
- 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.
- 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.
- 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.
- Each command closes the store files it opened.
Tests: 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.Compare160 it("--store inside the folder is kept in its settings and left out of its files", async () => {
161 store = temp("unused");
162 const dir = temp("venv");
163 writeFileSync(join(dir, "a.txt"), "x\n");
164 const r = await run(dir, "init", "--local", "--project", "beside", "--agent", "a", "--store", ".abso-store");
165 assert.equal(r.exit, 0, r.out + r.err);
166 assert.ok(existsSync(join(dir, ".abso-store", "beside", "project.sqlite")));
167 assert.equal(JSON.parse(readFileSync(join(stateDir(dir), "config.json"), "utf8")).store, join(dir, ".abso-store"));
168 assert.match(text(dir, ".absoignore"), /^\/\.abso-store\/$/m);
169 assert.match(r.out, /from 2 text files/, "a.txt and .absoignore, not the store");
170 // Every later command finds the store from the folder's settings, whatever ABSO_STORE says.
171 writeFileSync(join(dir, "a.txt"), "y\n");
172 assert.equal((await run(dir, "push", "-m", "y")).exit, 0);
173 });
175 it("--local refuses --server, and --store needs --local", async () => {
176 const dir = temp("refuse");
177 mkdirSync(join(dir, "x"));
178 const both = await run(dir, "init", "--local", "--server", "https://abso.test", "--project", "p");
179 assert.match(both.out + both.err, /--local or --server, not both/);
180 const alone = await run(dir, "init", "--store", "s", "--project", "p");
181 assert.match(alone.out + alone.err, /--store goes with --local/);
182 });
184 it("joining a project the store doesn't have leaves nothing behind", async () => {
185 store = temp("empty");
186 const dir = temp("nojoin");
187 const r = await run(dir, "join", "nothing", "--local", "--agent", "a", "--dir", dir);
188 assert.notEqual(r.exit, 0);
189 assert.match(r.out + r.err, /no local project nothing/);
190 assert.equal(existsSync(join(dir, ".abso")) || existsSync(join(dir, ".avcs")), false);
pinch289Local 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
At 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.
- 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".
- 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.
- worker/project/news.ts is Biome-formatted (only formatting), so the check gets past Biome again.
- 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.
Tests: 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.Compare191 });
192});
pinch298client/test/local.test.ts skips its suites, saying why, where no server/src sits beside the client. Local projects run the open server's code, and a platform that pins only client/ (abso's pin of 297) has none, so its root test failed on them. Here they all run as before.Compare194describe("local commands as their own processes", { skip: noServer }, () => {
pinch289Local 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
At 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.
- 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".
- 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.
- worker/project/news.ts is Biome-formatted (only formatting), so the check gets past Biome again.
- 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.
Tests: 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.Compare195 // The way people and agents run them: client/abso.ts, a process per command, Node's compile cache as it is.
196 const entry = fileURLToPath(new URL("../abso.ts", import.meta.url));
197 const cli = (cwd: string, processStore: string, ...argv: string[]) =>
198 spawnSync(process.execPath, [entry, ...argv], {
199 cwd,
200 env: { ...process.env, ABSO_STORE: processStore, ABSO_SERVERS_FILE: "no-servers.json" },
201 encoding: "utf8",
202 });
204 it("init, push, status and log each exit cleanly", () => {
205 const processStore = temp("process-store");
206 const dir = temp("process");
207 writeFileSync(join(dir, "a.txt"), "one\n");
208 const steps: [string, string[]][] = [
209 ["init", ["init", "--local", "--project", "proc", "--agent", "p"]],
210 ["push", ["push", "-m", "Two"]],
211 ["status", ["status"]],
212 ["log", ["log"]],
213 ];
214 for (const [name, argv] of steps) {
215 if (name === "push") writeFileSync(join(dir, "a.txt"), "one\ntwo\n");
216 const r = cli(dir, processStore, ...argv);
217 assert.equal(r.status, 0, `${name}: exit ${r.status} ${r.signal ?? ""}\n${r.stdout}${r.stderr}`);
218 if (name === "status") assert.match(r.stdout, /It's a local project, in /);
219 if (name === "log") assert.match(r.stdout, /Two/);
220 }
pinch287Local projects: abso init --local keeps a project's history on this machine, with no server, sign-in or network
A 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.
- 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".
- 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.
- 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.
- 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.
- 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.
- Each command closes the store files it opened.
Tests: 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.Compare221 });
222});