Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
blame on this site's /mcp
CLI
abso blame client/test/failed-start.test.ts --json
JSON
/christopher/abso-core/blame/client/test/failed-start.test.ts?format=json
60 linespinch 100%Last change pinch in version 281,

60 lines from 2 changes in 1 version.

pinch281Client fixes from the judge dry run: help with today's names, a mod installer hint that runs, a failed init or join takes back what it wrote, a refused 401 names the credential that went, and reply --file - help: abso.json, ABSO_ADMIN_TOKEN, ABSO_ADMIN_SERVERS, ABSO_BOX and .abso/shots/ in place of the old names, and the missing full stop. abso shot saves under .abso/shots/ as help says. - --version, init, join and status name the mod installer by its full path, and on a Node that can't run .ts files say it needs Node 22.18 or later. A built copy, which has no installer, says abso record sends the edits. - A failed init removes the .absoignore and abso.json it wrote. A failed join removes its .abso/ folder; a key already there, or one made for this join, stays. - A 401 names what was sent (this folder's key, ABSO_TOKEN, a pipeline run's key, the token file) instead of always a folder key. - reply takes --file <path> or --file - (stdin), like ask and answer. - The mod-behind tests no longer depend on which mods the machine has. Tests: install, body-files, failed-start (new), doctor, help, lost-pull pass; tsc clean.Compare1// 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).
3
4import assert from "node:assert/strict";
5import { existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";
6import { tmpdir } from "node:os";
7import { join } from "node:path";
8import { after, describe, it } from "node:test";
9import { main } from "../src/main.ts";
11// Nothing listens on port 1, so every call fails to connect.
12const DOWN = "http://127.0.0.1:1";
13const ENV = { ABSO_TOKEN: "test-token-not-secret", ABSO_SERVERS_FILE: "no-servers.json" };
15const dirs: string[] = [];
16after(() => {
17 for (const d of dirs) rmSync(d, { recursive: true, force: true, maxRetries: 5 });
18});
20function temp(): string {
21 const d = mkdtempSync(join(tmpdir(), "abso-failed-start-"));
22 dirs.push(d);
23 return d;
26async function run(cwd: string, ...argv: string[]): Promise<number> {
27 return (await main(argv, { cwd, env: ENV, write: () => {} })).exit;
30describe("a failed start", () => {
31 it("init takes back the .absoignore and abso.json it wrote", async () => {
32 const dir = temp();
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"]);
36 });
38 it("join leaves no .abso folder", async () => {
39 const dir = temp();
40 assert.notEqual(await run(dir, "join", "p", "--server", DOWN, "--agent", "a", "--dir", dir), 0);
41 assert.equal(existsSync(join(dir, ".abso")), false);
42 });
44 it("join keeps a key that was already here", async () => {
45 const dir = temp();
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"]);
51 });
53 it("join with a key it can't read leaves only that key", async () => {
54 const dir = temp();
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"]);
59 });
60});