Lines 15–23 at 318 (were 15–20 at 277)
1515// Written with one Windows line ending inside, which arrives as LF. 1616writeFileSync(join(dir, "body.md"), `${BODY.replace("- two\n", "- two\r\n")}\r\n`); 1717writeFileSync(join(dir, "empty.md"), "\n \n"); 18+// A reply as agents write them: prose, a code block and a Windows path, which no shell quoting mangles here. 19+const REPLY = 'Checked it:\n\n```ts\nconst x = "a\\tb";\n```\n\nThe log is in C:\\Users\\me\\repo\\out.txt.'; 20+writeFileSync(join(dir, "reply.md"), `${REPLY}\n`); 1922const ISSUE = { comment: "string", description: "string", title: "string", drop: "boolean" } as const; 2023const parse = (command: string, spec: Record<string, "string" | "boolean">, words: string[], stdin?: string) => Lines 43–56 at 318 (were 40–49 at 277)
43− it("--file gives ask's question, answer's words and announce's text", () => {
46+ it("--file gives ask's question, answer's and reply's words, and announce's text", () => { 4447 assert.deepEqual(parse("ask", { issue: "string" }, ["alice", "--file", "body.md"]).positionals, ["alice", BODY]); 4548 assert.deepEqual(parse("answer", { note: "string" }, ["12", "--file", "body.md"]).positionals, ["12", BODY]); 4649 assert.deepEqual(parse("announce", { to: "string" }, ["--file", "body.md"]).positionals, [BODY]); 50+ const reply = parse("reply", { question: "boolean" }, ["648", "--file", "reply.md", "--question"]); 51+ assert.deepEqual(reply.positionals, ["648", REPLY]); 52+ assert.equal(reply.flags.get("question"), true); 53+ assert.match(bodyFilesHelp("reply", { question: "boolean" })!, /--file <path>/); 4855 () => parse("answer", { note: "string" }, ["12", "words", "--file", "body.md"]), 4956 /--file gives answer's text, so leave the words off the command line/, Lines 3–25 at 318 (were 3–11 at 277)
33import { test } from "node:test"; 44import { CALLER_HEADER, CALLER_MAX, callerHeader, callerPlace, parseCaller } from "../../src/caller.ts"; 55import { Api } from "../src/api.ts"; 6+import { callerFor } from "../src/command-env.ts"; 78const session = "0da5c2b7-ab07-4249-b868-e8f09b6ec7b6"; 10+test("the client sends a hash of the session and only the folder's last part", () => { 11+ const header = callerFor(session, "DESKTOP-1", "C:\\Users\\sam\\repos\\abso\\groups")!; 12+ const caller = parseCaller(header)!; 13+ assert.equal(caller.folder, "groups"); 14+ assert.match(caller.session!, /^[0-9a-f]{16}$/); 15+ assert.notEqual(caller.session, session); 16+ assert.doesNotMatch(Buffer.from(header, "base64url").toString(), /sam|0da5c2b7/); 17+ // The same chat hashes the same way, so the server still tells one chat from another. 18+ assert.equal(parseCaller(callerFor(session, "DESKTOP-1", "/x/groups"))!.session, caller.session); 19+ assert.equal(parseCaller(callerFor(undefined, "box", "/work/über"))!.session, undefined); 20+ assert.equal(callerPlace(caller), "groups on DESKTOP-1"); 923test("a caller goes out and comes back as it was", () => { 1024 const header = callerHeader({ session, machine: "DESKTOP-1", folder: "C:\\Users\\sam\\repos\\abso\\groups" })!; 1125 assert.match(header, /^[A-Za-z0-9_-]+$/); new file, 60 lines
1+// abso ci for a project whose CI is its pipeline file (abso 719): test-byoc on 2026-10-16 had no abso.json, and abso ci 2+// said "nothing to run" while its abso.yml's run 8 was going. The stored run is the project's CI there. 4+import assert from "node:assert/strict"; 5+import { test } from "node:test"; 6+import { builtInHasNothing, runLine, storedRuns } from "../src/ci.ts"; 8+const base = { latest: null, checked: null, running: null, red: null, behind: null } as const; 12+ reason: "nothing to run: no abso.json, and package.json has no test, typecheck or vite", 13+ at: "2026-10-16T16:47:00.000Z", 16+test("the stored runs are read strictly, newest first as the server lists them", () => { 17+ const runs = storedRuns({ 20+ { id: 8, version: 6, state: "running", file: "abso.yml", started: 1 }, 21+ { id: "7", version: 6, state: "failed", file: "abso.yml" }, 22+ { id: 6, version: 5, state: "failed", file: "abso.yml" }, 26+ runs.map((r) => r.id), 29+ assert.deepEqual(storedRuns(null), []); 30+ assert.deepEqual(storedRuns({ runs: "no" }), []); 33+test("a run in a line names its file, its state and where its jobs are", () => { 35+ runLine({ id: 8, version: 6, state: "running", file: "abso.yml" }), 36+ "Pipeline run 8 (abso.yml) is running on version 6. abso pipeline runs 8 shows its jobs.", 39+ runLine({ id: 7, version: 6, state: "failed", file: "abso.yml" }), 40+ "Pipeline run 7 (abso.yml) failed on version 6. abso pipeline runs 7 shows its jobs.", 43+ runLine({ id: 2, version: 1, state: "planned", file: "abso.yml" }), 44+ "Pipeline run 2 (abso.yml) was planned, not run, on version 1. abso pipeline runs 2 shows its jobs.", 48+test("only the built-in check's own nothing to run is set aside, never a red or another skip", () => { 49+ assert.equal(builtInHasNothing({ ...base, skipped: nothing }), true); 50+ assert.equal(builtInHasNothing({ ...base, skipped: { ...nothing, reason: "CI is off" } }), false); 51+ assert.equal(builtInHasNothing({ ...base }), false); 55+ red: { version: 6, agent: null, message: null, lastGood: null }, Lines 211–235 at 318 (were 211–231 at 277)
212212test("plainError words a refusal by whether a credential went, and a server that can't be reached", () => { 213213 const refused = new ApiError("GET /status answered 401: missing or wrong token", 401); 214− assert.equal(plainError(refused, false), "You're not signed in. Run abso login, then abso join <project>.");
215− assert.match(plainError(refused, true)!, /^The server didn't accept this folder's key.*abso doctor checks it/);
214+ assert.equal(plainError(refused, undefined), "You're not signed in. Run abso login, then abso join <project>."); 216+ plainError(refused, "this folder's key")!, 217+ /^The server didn't accept this folder's key.*abso doctor checks it/, 219+ assert.match(plainError(refused, "ABSO_TOKEN")!, /^The server didn't accept ABSO_TOKEN: /); 217− plainError(new ApiError("could not reach https://api.abso.dev: connect ECONNREFUSED"), true),
221+ plainError(new ApiError("could not reach https://api.abso.dev: connect ECONNREFUSED"), "this folder's key"), 218222 "Can't reach https://api.abso.dev: connect ECONNREFUSED. Check your connection; abso doctor checks the rest.", 222226 new ApiError("could not reach http://x: refused. Nothing was pushed. Run the same command again."), 223− true,
227+ "this folder's key", 225229 "Can't reach http://x: refused. Nothing was pushed. Run the same command again.", 227− assert.equal(plainError(new ApiError("GET /log answered 500: boom", 500), true), undefined);
228− assert.equal(plainError(new Error("anything else"), true), undefined);
231+ assert.equal(plainError(new ApiError("GET /log answered 500: boom", 500), "this folder's key"), undefined); 232+ assert.equal(plainError(new Error("anything else"), "this folder's key"), undefined); 231235test("whoami with nothing named shows prod, and names the other servers this box is signed in to", async () => { new file, 60 lines
1+// An init or join that fails against the server leaves the folder as it was, so the same command can run again: 2+// no starting .absoignore or abso.json from init, no .abso/ from join (but a key already here stays). 4+import assert from "node:assert/strict"; 5+import { existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs"; 6+import { tmpdir } from "node:os"; 7+import { join } from "node:path"; 8+import { after, describe, it } from "node:test"; 9+import { main } from "../src/main.ts"; 11+// Nothing listens on port 1, so every call fails to connect. 12+const DOWN = "http://127.0.0.1:1"; 13+const ENV = { ABSO_TOKEN: "test-token-not-secret", ABSO_SERVERS_FILE: "no-servers.json" }; 15+const dirs: string[] = []; 17+ for (const d of dirs) rmSync(d, { recursive: true, force: true, maxRetries: 5 }); 20+function temp(): string { 21+ const d = mkdtempSync(join(tmpdir(), "abso-failed-start-")); 26+async function run(cwd: string, ...argv: string[]): Promise<number> { 27+ return (await main(argv, { cwd, env: ENV, write: () => {} })).exit; 30+describe("a failed start", () => { 31+ it("init takes back the .absoignore and abso.json it wrote", async () => { 33+ writeFileSync(join(dir, "package.json"), `${JSON.stringify({ scripts: { test: "node --test" } })}\n`); 34+ assert.notEqual(await run(dir, "init", "--server", DOWN, "--project", "p", "--agent", "a"), 0); 35+ assert.deepEqual(readdirSync(dir), ["package.json"]); 38+ it("join leaves no .abso folder", async () => { 40+ assert.notEqual(await run(dir, "join", "p", "--server", DOWN, "--agent", "a", "--dir", dir), 0); 41+ assert.equal(existsSync(join(dir, ".abso")), false); 44+ it("join keeps a key that was already here", async () => { 46+ mkdirSync(join(dir, ".abso")); 47+ const key = { server: DOWN, key: "abso_sk_not-a-real-key", id: "k_0123abcd" }; 48+ writeFileSync(join(dir, ".abso", "key"), `${JSON.stringify(key)}\n`); 49+ assert.notEqual(await run(dir, "join", "p", "--server", DOWN, "--agent", "a", "--dir", dir), 0); 50+ assert.deepEqual(readdirSync(join(dir, ".abso")), ["key"]); 53+ it("join with a key it can't read leaves only that key", async () => { 55+ mkdirSync(join(dir, ".abso")); 56+ writeFileSync(join(dir, ".abso", "key"), "{}\n"); 57+ assert.notEqual(await run(dir, "join", "p", "--server", DOWN, "--agent", "a", "--dir", dir), 0); 58+ assert.deepEqual(readdirSync(join(dir, ".abso")), ["key"]); Lines 89–96 at 318 (were 89–94 at 277)
9090 /** The next publish: commit it and answer 500 ('after'), or answer 500 without it ('before'), as a storage reset does. */ 9191 failPublish: "after" | "before" | undefined; 92+ /** How many of the next pulls to carry out and then cut before answering, as an answer that never arrives (abso-core 26). */ 93+ loseSyncAnswers: number; 9294 /** Run the merge queue's rounds now (after queueHold is let go). */ 9395 kickQueue(name: string): Promise<void>; 9496 /** Each run POST's X-Abso-Run-Key, and whether a run started for it. */ Lines 157–163 at 318 (were 155–160 at 277)
155157 boxExtra: undefined, 157159 failPublish: undefined, 158161 kickQueue: async () => {}, 159162 close: async () => {}, Lines 635–645 at 318 (were 632–637 at 277)
632635 ...(typeof body.label === "string" ? { label: body.label } : {}), 633636 ...(body.full === true ? { full: true } : {}), 638+ if (fake.loseSyncAnswers > 0) { 639+ fake.loseSyncAnswers--; 635643 const extra = fake.injectSync; 636644 fake.injectSync = undefined; 637645 if (extra === undefined) return send(res, 200, synced); Lines 26–33 at 318 (were 26–31 at 277)
2626import { clientVersion, headCommit } from "../src/client-version.ts"; Lines 115–142 at 318 (were 113–118 at 277)
118+ it("stamps the command that runs this client's abso hook, where stamp.ts has a HOOK_COMMAND line", () => { 119+ const spec = source({ 121+ "export const STAMP: string | undefined = undefined\nexport const HOOK_COMMAND: readonly string[] | undefined = undefined\n", 123+ const target = join(temp(), "avcs"); 128+ hookCommand: ["C:\\node.exe", "C:\\abso\\client\\abso.ts", "hook"], 131+ read(target, "hooks/stamp.ts"), 132+ "export const STAMP: string | undefined = '0.1.0+702c616'\n" + 133+ 'export const HOOK_COMMAND: readonly string[] | undefined = ["C:\\\\node.exe","C:\\\\abso\\\\client\\\\abso.ts","hook"]\n', 135+ // By default, this checkout's own: the node running it and client/abso.ts. 136+ assert.deepEqual(hookCommand().slice(0, 1), [process.execPath]); 137+ assert.match(hookCommand()[1]!, /client[\\/]abso\.ts$/); 116140 it("moves the files in by rename, what the hook imports first and plugin.json last", () => { 117141 const spec = source(); 118142 const target = join(temp(), "avcs"); Lines 451–460 at 318 (were 427–435 at 277)
427451 assert.equal(client, `abso ${clientVersion()} (${dirname(import.meta.dirname)})`); 430− /^the abso-hooks mod: 0\.1\.0\+aaaaaaa in .*skills[\\/]abso-hooks, installed 2026-10-05 04:30 UTC; this client has 0.2.0(\+[0-9a-f]{7}(\.dirty)?)?: node client\/install-mod\.ts installs it$/,
454+ /^the abso-hooks mod: 0\.1\.0\+aaaaaaa in .*skills[\\/]abso-hooks, installed 2026-10-05 04:30 UTC; this client has 0.2.0(\+[0-9a-f]{7}(\.dirty)?)?: /, 432− assert.equal(view, "the abso-view mod: not installed (node client/install-view.ts)");
456+ assert.ok(mod!.endsWith(`: ${installerCommand("install-mod.ts")} installs it`), mod); 457+ assert.equal(view, `the abso-view mod: not installed (${installerCommand("install-view.ts")})`); 433458 const json = JSON.parse( 434459 (await main(["--version", "--json"], { cwd: config, env: { CLAUDE_CONFIG_DIR: config }, write: () => {} })) Lines 499–505 at 318 (were 474–480 at 277)
474499 const current = (versionReport(env).json.mods as { current: string }[])[0]!.current; 475500 if (/\+[0-9a-f]{7}$/.test(current)) 476501 assert.deepEqual(modsBehindText(env), [ 477− `The avcs mod installed on this machine is 0.1.0+aaaaaaa, and this client has ${current}: node client/install-mod.ts installs it (new chats load it).`,
502+ `The ${AVCS_MOD.name} mod installed on this machine is 0.1.0+aaaaaaa, and this client has ${current}: ${installerCommand("install-mod.ts")} installs it (new chats load it).`, 479504 // A client outside git (an abso folder, a box) can't tell, so it says nothing. 480505 else assert.deepEqual(modsBehindText(env), []); new file, 222 lines
1+// 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. 5+import assert from "node:assert/strict"; 6+import { spawnSync } from "node:child_process"; 7+import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; 8+import { tmpdir } from "node:os"; 9+import { join } from "node:path"; 10+import { after, before, describe, it } from "node:test"; 11+import { fileURLToPath } from "node:url"; 12+import { closeLocalStores, LOCAL_BASE, localFetch } from "../src/local-store.ts"; 13+import { main } from "../src/main.ts"; 14+import { stateDir } from "../src/state-dir.ts"; 16+const dirs: string[] = []; 17+const temp = (label: string) => { 18+ const d = mkdtempSync(join(tmpdir(), `abso-local-${label}-`)); 23+const outside: string[] = []; 24+const realFetch = globalThis.fetch; 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"); 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"); 38+const env = () => ({ ABSO_STORE: store, ABSO_SERVERS_FILE: "no-servers.json", ABSO_HOOK_FORCE: "1" }); 39+async 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 }; 43+const text = (dir: string, rel: string) => readFileSync(join(dir, rel), "utf8"); 45+/** A copy of the client without the open server beside it (a platform that pins only client/) has no local projects to test. */ 46+const noServer = existsSync(fileURLToPath(new URL("../../server/src/router.ts", import.meta.url))) 48+ : "no server/src beside this client, so no local projects"; 50+describe("a local project, with the network off", { skip: noServer }, () => { 54+ store = temp("store"); 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"); 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/); 84+ it("a second folder joins, and pulls what the first pushes", async () => { 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"); 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/); 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/); 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/); 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`)]); 142+ for (const a of answers) assert.equal(a.status, 200, await a.text()); 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"); 148+ 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/); 154+ assert.ok(!existsSync(join(store, "..", "project.sqlite"))); 155+ assert.deepEqual(readdirSync(dir), ["a.txt"], "init left nothing behind"); 159+describe("where a local project's store is", { skip: noServer }, () => { 160+ 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); 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/); 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); 194+describe("local commands as their own processes", { skip: noServer }, () => { 195+ // 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], { 200+ env: { ...process.env, ABSO_STORE: processStore, ABSO_SERVERS_FILE: "no-servers.json" }, 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"]], 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/); new file, 88 lines
1+// A pull whose answer never arrives (abso-core 26): the server has moved the agent's base, so later pulls 2+// send only what changed since then. The folder notes the pull it started and, until one is written, the 3+// next pull asks for every file and writes the ones that differ. Status says so in the meantime. 5+import assert from "node:assert/strict"; 6+import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; 7+import { tmpdir } from "node:os"; 8+import { join } from "node:path"; 9+import { after, before, describe, it } from "node:test"; 10+import { main } from "../src/main.ts"; 11+import { type Fake, startFake } from "./fake-server.ts"; 13+const TOKEN = "test-token-not-secret"; 14+const ENV = { AVCS_TOKEN: TOKEN, AVCS_HOOK_FORCE: "1", AVCS_SERVERS_FILE: "no-servers.json" }; 17+const dirs: string[] = []; 19+ fake = await startFake(0, TOKEN); 23+ for (const d of dirs) rmSync(d, { recursive: true, force: true, maxRetries: 5 }); 26+function temp(): string { 27+ const d = mkdtempSync(join(tmpdir(), "abso-lost-pull-")); 32+async function run(cwd: string, ...argv: string[]): Promise<{ exit: number; out: string }> { 33+ const r = await main(argv, { cwd, env: ENV, write: () => {} }); 34+ return { exit: r.exit, out: r.stdout + r.stderr }; 38+/** alice and bob on one project; alice pushes a change and a new file, and bob's pull of them is lost. */ 39+async function lost(): Promise<{ alice: string; bob: string }> { 40+ const name = `lost${++projects}`; 41+ const alice = temp(); 42+ writeFileSync(join(alice, "a.txt"), "one\n"); 44+ (await run(alice, "init", "--server", fake.url, "--project", name, "--agent", "alice", "--as-is")).exit, 48+ assert.equal((await run(bob, "join", name, "--agent", "bob", "--server", fake.url)).exit, 0); 49+ writeFileSync(join(alice, "a.txt"), "two\n"); 50+ writeFileSync(join(alice, "b.txt"), "new\n"); 51+ const pushed = await run(alice, "push", "-m", "Change a.txt and add b.txt"); 52+ assert.equal(pushed.exit, 0, pushed.out); 53+ fake.loseSyncAnswers = 1; 54+ assert.notEqual((await run(bob, "pull")).exit, 0, "the pull whose answer was lost fails"); 55+ return { alice, bob }; 58+const text = (dir: string, rel: string) => readFileSync(join(dir, rel), "utf8"); 60+describe("a pull whose answer never arrives", () => { 61+ it("leaves the folder as it was, and status says a pull didn't finish", async () => { 62+ const { bob } = await lost(); 63+ assert.equal(text(bob, "a.txt"), "one\n"); 64+ assert.equal(existsSync(join(bob, "b.txt")), false); 65+ const status = await run(bob, "status"); 66+ assert.match(status.out, /A pull here didn't finish/); 69+ it("the next pull asks for every file and writes what the lost one would have", async () => { 70+ const { bob } = await lost(); 71+ const pulled = await run(bob, "pull"); 72+ assert.equal(pulled.exit, 0, pulled.out); 73+ assert.match(pulled.out, /The last pull here didn't finish, so this one asked for every file/); 74+ assert.equal(text(bob, "a.txt"), "two\n"); 75+ assert.equal(text(bob, "b.txt"), "new\n"); 76+ assert.doesNotMatch((await run(bob, "status")).out, /A pull here didn't finish/); 77+ const again = await run(bob, "pull"); 78+ assert.doesNotMatch(again.out, /didn't finish/, "once caught up, pulls are plain again"); 81+ it("keeps work done in the folder meanwhile", async () => { 82+ const { bob } = await lost(); 83+ writeFileSync(join(bob, "a.txt"), "bob's own\n"); 84+ const pulled = await run(bob, "pull"); 85+ assert.equal(text(bob, "a.txt"), "bob's own\n", pulled.out); 86+ assert.equal(text(bob, "b.txt"), "new\n"); Lines 3–9 at 318 (were 3–8 at 277)
33import assert from "node:assert/strict"; 44import { test } from "node:test"; Lines 42–52 at 318 (were 41–46 at 277)
4142 assert.match(text[0]!, /within 45 seconds/); 4243 assert.match(text[0]!, /run abso news --stream again/); 4344 assert.deepEqual(JSON.parse(text[1]!), args); 45+ // The server sends the expiry as an ISO time (staging 1418); the countdown and the stream mark read it the same. 46+ const iso = { ...ticket(1), expiresAt: new Date(NOW + 60_000).toISOString() }; 47+ assert.match(streamText(iso, "abso", "fe", NOW + 15_000), /within 45 seconds/); 48+ assert.equal(streamMarkUntil(iso, NOW), NOW + 60_000 + MONITOR_TIMEOUT_MS); 49+ assert.equal(expiresAtMs({ ...ticket(1), expiresAt: "soon" }, NOW), NOW); 4652test("a refusal close stops --follow; any other close opens again, waiting 1 s doubling to a minute", () => { Lines 134–182 at 318 (were 128–133 at 277)
128134 assert.equal(w.notes.length, 0); 137+test("a frame is a wake: --follow reads the news and prints that once; an empty read prints the frames", async () => { 138+ // The server's frames don't count as heard (abso 690): the read takes them, so each item prints once. 139+ const w = world([{ frames: ["fe told you: hello", "cloud asks: ship it?"], close: { code: 1006 } }]); 140+ const reads: string[][] = [["fe told you: hello", "cloud asks: ship it?"], []]; 142+ w.deps.take = async () => { 144+ return reads.shift() ?? []; 146+ await follow(w.deps); 147+ // Two frames, one read in flight: the second folds into one more read, which finds nothing new; its frame was 148+ // already printed by the first read, so nothing prints twice. 149+ assert.equal(calls, 2); 150+ assert.deepEqual(w.lines, ["fe told you: hello", "cloud asks: ship it?"]); 152+ // A server that counts a frame as heard already (staging 1418): the read is empty, so the frame is what shows. 153+ const old = world([{ frames: ["fe told you: hello"], close: { code: 1006 } }]); 154+ old.deps.take = async () => []; 155+ await follow(old.deps); 156+ assert.deepEqual(old.lines, ["fe told you: hello"]); 158+ // On that server a read can find other news waiting: the frame's own item still shows (Code Review, 291). 159+ const mixed = world([{ frames: ["fe told you: hello"], close: { code: 1006 } }]); 160+ mixed.deps.take = async () => ["cloud: an older item"]; 161+ await follow(mixed.deps); 162+ assert.deepEqual(mixed.lines, ["cloud: an older item", "fe told you: hello"]); 164+ // A catch-up frame names the first few waiting items and how many more: the read shows them all, the frame adds nothing. 165+ const catchUp = world([{ frames: ["fe told you: hello\ncloud: ship it?\nand 1 more"], close: { code: 1006 } }]); 166+ catchUp.deps.take = async () => ["fe told you: hello", "cloud: ship it?", "desk: a third"]; 167+ await follow(catchUp.deps); 168+ assert.deepEqual(catchUp.lines, ["fe told you: hello", "cloud: ship it?", "desk: a third"]); 170+ // A read that fails shows the frames and says why. 171+ const down = world([{ frames: ["fe told you: hello"], close: { code: 1006 } }]); 172+ down.deps.take = async () => { 173+ throw new Error("could not reach the server"); 175+ await follow(down.deps); 176+ assert.deepEqual(down.lines, ["fe told you: hello"]); 177+ assert.match(down.notes[0]!, /couldn't read the news: could not reach the server/); 131180test("--follow keeps an idle socket open with a ping the object answers without waking", async () => { 132181 const w = world([{ frames: [], close: { code: 1006 } }]); 133182 const held: number[] = []; new file, 106 lines
1+// abso login --web: a staging website session handed to a browser as a one-use link, with no secret printed. 3+import assert from "node:assert/strict"; 4+import { mkdtempSync, writeFileSync } from "node:fs"; 5+import { tmpdir } from "node:os"; 6+import { join } from "node:path"; 7+import { test } from "node:test"; 8+import { handoffText, patFromFile, siteFor, webHandoff, webLogin } from "../src/web-session.ts"; 10+const SITE = "https://abso-website-staging.chrisazy.workers.dev"; 11+const STAGING = "https://abso-staging.chrisazy.workers.dev"; 12+const BOX = `abso_bx_${"C".repeat(43)}`; 13+const PAT = `abso_pat_${"A".repeat(40)}`; 14+const NOW = Date.UTC(2026, 9, 16, 9, 0, 0); 16+test("the credential goes only to the staging website beside the folder's staging server (Security condition 6)", () => { 17+ assert.equal(siteFor(STAGING, undefined, "box"), SITE); 18+ assert.equal(siteFor("https://avcs-staging.chrisazy.workers.dev/", undefined, "pat"), SITE); 19+ // A server that isn't staging is refused, prod included, whatever is asked. 21+ () => siteFor("https://api.abso.dev", undefined, "box"), 22+ /for staging.*never sign in to the website on prod/, 24+ assert.throws(() => siteFor("https://api.abso.dev", "http://localhost:8871", "pat"), /for staging/); 25+ // A box's sign-in takes no --site, not even the staging website's own address. 26+ assert.throws(() => siteFor(STAGING, SITE, "box"), /isn't taken with a box's sign-in/); 27+ assert.throws(() => siteFor(STAGING, "http://localhost:8871", "box"), /isn't taken with a box's sign-in/); 28+ // A PAT may name this machine over http, and nothing else. 29+ assert.equal(siteFor(STAGING, "http://localhost:8871/x", "pat"), "http://localhost:8871"); 30+ assert.equal(siteFor(STAGING, "http://127.0.0.1:8871", "pat"), "http://127.0.0.1:8871"); 31+ for (const elsewhere of ["https://anywhere.example", SITE, "https://localhost:8871", "not a url"]) 32+ assert.throws(() => siteFor(STAGING, elsewhere, "pat"), /names this machine only/, elsewhere); 35+test("a refused handoff reads no credential and sends no request", async () => { 36+ const sent: string[] = []; 37+ const fetcher = (async (url: string) => (sent.push(url), Response.json({}))) as unknown as typeof fetch; 39+ const credential = () => (read++, BOX); 40+ for (const asked of [ 41+ { server: "https://api.abso.dev", site: undefined, kind: "box" as const }, 42+ { server: STAGING, site: "https://anywhere.example", kind: "box" as const }, 43+ { server: STAGING, site: SITE, kind: "box" as const }, 44+ { server: "https://api.abso.dev", site: "http://localhost:8871", kind: "pat" as const }, 45+ { server: STAGING, site: "https://anywhere.example", kind: "pat" as const }, 47+ await assert.rejects(webLogin({ ...asked, credential, fetcher }), /Nothing was sent/, JSON.stringify(asked)); 48+ assert.deepEqual(sent, []); 49+ assert.equal(read, 0); 50+ // Allowed, it goes to the staging website only. 51+ await webLogin({ server: STAGING, site: undefined, kind: "pat", credential: () => PAT, fetcher }).catch(() => {}); 52+ assert.deepEqual(sent, [`${SITE}/login/handoff`]); 55+test("the credential goes in Authorization only, and the answer is the one link and who it signs in as", async () => { 56+ const seen: { url: string; authorization: string | null; body: unknown }[] = []; 57+ const fetcher = (async (url: string, init: RequestInit) => { 58+ seen.push({ url, authorization: new Headers(init.headers).get("authorization"), body: init.body ?? null }); 59+ return Response.json({ 60+ url: `${SITE}/login/handoff#${"t".repeat(50)}`, 61+ expiresAt: new Date(NOW + 60_000).toISOString(), 62+ account: "acct_person1", 64+ sessionEnds: "2026-10-16T21:00:00.000Z", 67+ const h = await webHandoff(SITE, BOX, fetcher); 68+ assert.deepEqual(seen, [{ url: `${SITE}/login/handoff`, authorization: `Bearer ${BOX}`, body: null }]); 69+ const text = handoffText(h, SITE, true, NOW); 70+ assert.match(text, /within 60 seconds/); 71+ assert.match(text, /as christopher, until 2026-10-16T21:00:00.000Z, and works once/); 72+ assert.match(text, /only to the projects this box was granted, at most as a writer/); 73+ assert.match(handoffText(h, SITE, false, NOW), /It reaches at most as a writer:/); 74+ assert.match(text, /\/login\/handoff#t{50}$/); 75+ assert.doesNotMatch(text + JSON.stringify(h), /abso_bx_/); 78+test("a refusal says why without the credential; an answer that isn't the site's own link is refused", async () => { 79+ const echo = (async () => 80+ Response.json({ error: `that key was refused: ${BOX}` }, { status: 401 })) as unknown as typeof fetch; 81+ await assert.rejects(webHandoff(SITE, BOX, echo), (err: Error) => { 82+ assert.match(err.message, /refused: that key was refused: \[the credential\]/); 83+ assert.doesNotMatch(err.message, /abso_bx_/); 86+ const off = (async () => Response.json({ error: "not found" }, { status: 404 })) as unknown as typeof fetch; 87+ await assert.rejects(webHandoff(SITE, BOX, off), /doesn't hand out sign-in links/); 88+ const elsewhere = (async () => 90+ url: "https://elsewhere.example/login/handoff#x", 91+ expiresAt: new Date(NOW).toISOString(), 93+ })) as unknown as typeof fetch; 94+ await assert.rejects(webHandoff(SITE, BOX, elsewhere), /isn't a sign-in link/); 97+test("--pat-file reads a PAT from its file, and refuses a file that doesn't hold one", () => { 98+ const dir = mkdtempSync(join(tmpdir(), "abso-web-")); 99+ const good = join(dir, "pat"); 100+ writeFileSync(good, `abso_pat_${"A".repeat(40)}\n`); 101+ assert.equal(patFromFile(good), `abso_pat_${"A".repeat(40)}`); 102+ const bad = join(dir, "not"); 103+ writeFileSync(bad, "hello"); 104+ assert.throws(() => patFromFile(bad), /doesn't hold a PAT/); 105+ assert.throws(() => patFromFile(join(dir, "missing")), /can't read/);