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/key.test.ts --json
JSON
/christopher/abso-core/blame/client/test/key.test.ts?format=json
60 linesFirst import 95% · pinch 5%Last change pinch in version 18,

60 lines from 2 changes in 2 versions.

init0Start the project1import assert from "node:assert/strict";
2import { mkdtempSync, readFileSync, writeFileSync } from "node:fs";
3import { tmpdir } from "node:os";
4import { join } from "node:path";
5import { test } from "node:test";
6import { credentialLabel, installKey, tokenFor, writeConfig } from "../src/config.ts";
7
8function folder() {
9 const root = mkdtempSync(join(tmpdir(), "abso-key-"));
10 writeConfig(root, { server: "https://staging.abso.example", project: "p", agent: "a" });
11 return root;
14const KEY = "abso_sk_abcdefghijklmnopqrstuvwxyz012345";
15const ID = "k_ab12cd34";
17test("a key in the folder is sent instead of AVCS_TOKEN, and only to its server", () => {
18 const root = folder();
19 installKey(root, JSON.stringify({ key: KEY, id: ID }));
20 const env = { AVCS_TOKEN: "shared-token-value" };
21 assert.equal(tokenFor("https://staging.abso.example", env, root), KEY);
22 assert.throws(() => tokenFor("https://abso.example", env, root), /different server/);
23 const label = credentialLabel(root, "https://staging.abso.example", env);
24 assert.deepEqual(label, { kind: "agent key", id: ID });
25 assert.equal(JSON.stringify(label).includes(KEY), false);
26});
28test("with no key, the shared token is unchanged", () => {
29 const root = folder();
30 const env = {
31 AVCS_TOKEN: "shared-token-value",
32 AVCS_TRUSTED_SERVERS: "https://abso.example",
33 AVCS_SERVERS_FILE: "no-servers.json",
34 };
35 assert.equal(tokenFor("https://abso.example", env, root), "shared-token-value");
36 assert.deepEqual(credentialLabel(root, "https://abso.example", env), { kind: "shared token", id: null });
37});
pinch18New folders keep .avcs/ for now; the server keeps both state folders out of a project Version 17 made new folders with .abso/. An edit mod or Cursor hook installed before the rename looks only for .avcs/config.json, so in a .abso/ folder it would stop recording edits, and nothing would say so. Until installs can say which mods know .abso/, a new folder is made with .avcs/ again (NEW_FOLDER_DIR in client/src/state-dir.ts). Reading is unchanged: a folder with .abso/ works exactly as one with .avcs/, and neither is ever half-moved. The user's files still go to ~/.abso/, since an older client that can't find them says so. The server refused only paths under .avcs/, and the test server only .abso/. Both now refuse both, so a folder's state never becomes part of a project, whichever name it has. Tests: new folders get .avcs/; a folder moved to .abso/ records and isn't moved back; the tests that assumed .abso/ for a new folder now use .avcs/.Compare39test("install writes .avcs/key and does not leave the key in the returned value", () => {
init0Start the project40 const root = folder();
41 const installed = installKey(root, JSON.stringify({ key: KEY, id: ID }));
42 assert.deepEqual(installed, { id: ID });
pinch18New folders keep .avcs/ for now; the server keeps both state folders out of a project Version 17 made new folders with .abso/. An edit mod or Cursor hook installed before the rename looks only for .avcs/config.json, so in a .abso/ folder it would stop recording edits, and nothing would say so. Until installs can say which mods know .abso/, a new folder is made with .avcs/ again (NEW_FOLDER_DIR in client/src/state-dir.ts). Reading is unchanged: a folder with .abso/ works exactly as one with .avcs/, and neither is ever half-moved. The user's files still go to ~/.abso/, since an older client that can't find them says so. The server refused only paths under .avcs/, and the test server only .abso/. Both now refuse both, so a folder's state never becomes part of a project, whichever name it has. Tests: new folders get .avcs/; a folder moved to .abso/ records and isn't moved back; the tests that assumed .abso/ for a new folder now use .avcs/.Compare43 const stored = readFileSync(join(root, ".avcs", "key"), "utf8");
init0Start the project44 assert.equal(stored.includes(KEY), true);
45 assert.equal(JSON.stringify(installed).includes(KEY), false);
pinch18New folders keep .avcs/ for now; the server keeps both state folders out of a project Version 17 made new folders with .abso/. An edit mod or Cursor hook installed before the rename looks only for .avcs/config.json, so in a .abso/ folder it would stop recording edits, and nothing would say so. Until installs can say which mods know .abso/, a new folder is made with .avcs/ again (NEW_FOLDER_DIR in client/src/state-dir.ts). Reading is unchanged: a folder with .abso/ works exactly as one with .avcs/, and neither is ever half-moved. The user's files still go to ~/.abso/, since an older client that can't find them says so. The server refused only paths under .avcs/, and the test server only .abso/. Both now refuse both, so a folder's state never becomes part of a project, whichever name it has. Tests: new folders get .avcs/; a folder moved to .abso/ records and isn't moved back; the tests that assumed .abso/ for a new folder now use .avcs/.Compare46 writeFileSync(join(root, ".avcs", "key"), stored);
init0Start the project47});
49test("a key installed with --server before join is the one join's folder sends", () => {
50 const root = mkdtempSync(join(tmpdir(), "abso-key-"));
51 const staging = "https://staging.abso.example";
52 assert.throws(() => installKey(root, JSON.stringify({ key: KEY, id: ID })), /--server/);
53 installKey(root, JSON.stringify({ key: KEY, id: ID }), staging);
54 writeConfig(root, { server: staging, project: "p", agent: "a" });
55 assert.equal(tokenFor(staging, {}, root), KEY);
56 assert.throws(
57 () => installKey(root, JSON.stringify({ key: KEY, id: ID }), "https://abso.example"),
58 /not https:\/\/abso.example/,
59 );
60});