Versions 5 to 318
Lines 1–18 at 318 (were 1–14 at 5)
4−// The token is never in the folder: it comes from the AVCS_TOKEN environment
5−// variable, or else from ~/.avcs/token, outside every repo.
67
9−import { dirname, join, resolve } from "node:path";
1112import { type MachineServers, machineServers, TOKEN_SERVERS, tokenGoesTo, trustedList } from "./core.ts";
1216
Lines 23–48 at 318 (were 19–37 at 5)
2024 /** A reader folder (abso join --reader, #37): it reads everything and records nothing; the server refuses its records too. */
27+ * A visitor folder (abso join <project> --reader with no sign-in, for a public project): it reads through the
28+ * routes anyone can read and sends no credential. It has no agent; its config holds server, project and this.
31+ /** A local project's store (abso init --local --store), when it isn't the machine's own: ABSO_STORE or the OS data folder. */
2334
37+ /** For a local project (server "local"): the store folder its history is in, or undefined when there's none to use. */
2740
28−export const AVCS_DIR = ".avcs";
29−
31− return join(root, AVCS_DIR, "config.json");
3344
34−/** The nearest folder at or above `start` that has .avcs/config.json, or undefined. */
45+/** The nearest folder at or above `start` that has .abso/config.json (or .avcs/config.json, from before the rename), or undefined. */
Lines 53–98 at 318 (were 42–63 at 5)
4455
45−export function readConfig(root: string, env: Readonly<Record<string, string | undefined>> = process.env): Config {
64+ if (typeof raw[key] !== "string" || raw[key] === "") throw new Error(`${configPath(root)} has no "${key}"`);
66+ // No token and no key, whatever the environment or the folder holds: a visitor sends no credential.
4870 if (typeof raw[key] !== "string" || raw[key] === "") throw new Error(`${configPath(root)} has no "${key}"`);
50− const token = tokenFor(raw.server!, env, root);
6086
87+/** Whether the folder is a visitor's: it reads signed out and sends no credential. Read straight from its config. */
90+ return (JSON.parse(readFileSync(configPath(root), "utf8")) as { visitor?: unknown }).visitor === true;
95+
6196/** Whether the folder is a reader (#37): records nothing. Read straight from its config, for the paths that only need this. */
Lines 111–126 at 318 (were 76–88 at 5)
79−): { kind: "agent key" | "shared token" | "none"; id: string | null } {
85− return { kind: readToken(env) ? "shared token" : "none", id: null };
87125
Lines 130–136 at 318 (were 92–98 at 5)
93131
95− return join(root, AVCS_DIR, "key");
97135
Lines 164–170 at 318 (were 126–132 at 5)
129− if (!server) throw new UsageError("this folder has no .avcs/config.json yet: give --server <url>");
167+ if (!server) throw new UsageError("this folder has no .abso/config.json yet: give --server <url>");
Lines 178–184 at 318 (were 140–146 at 5)
143− mkdirSync(join(root, AVCS_DIR), { recursive: true });
144182 writeFileSync(keyPath(root), `${JSON.stringify({ server, key: parsed.key, id: parsed.id })}\n`, { mode: 0o600 });
Lines 192–237 at 318 (were 154–182 at 5)
199+ // A folder with a key signs in with that key and nothing else, even when the server refuses it.
202+ `this folder's key file (${keyPath(root)}) can't be read, so abso sends nothing; abso key install puts a key back`,
162206 throw new UsageError("this folder's key was issued for a different server, so abso will not send it");
166− const token = readToken(env);
167− const trusted = trustedServers(env);
168− if (token === undefined || tokenGoesTo(server, trusted)) return token;
216+
170− `this folder's server is ${server}, and abso sends your token only to ${[...TOKEN_SERVERS, "this machine"].join(", ")}, and the servers ~/.avcs/servers.json or AVCS_TRUSTED_SERVERS name. ` +
171− `If ${server} is yours, name it in ~/.avcs/servers.json or AVCS_TRUSTED_SERVERS (comma-separated); if you didn't set it, someone else wrote .avcs/config.json.`,
225+ `this folder's server is ${server}, and abso sends your token only to ${[...TOKEN_SERVERS, "this machine"].join(", ")}, and the servers ~/.abso/servers.json or ABSO_TRUSTED_SERVERS name. ` +
226+ `If ${server} is yours, name it in ~/.abso/servers.json or ABSO_TRUSTED_SERVERS (comma-separated); if you didn't set it, someone else wrote .abso/config.json.`,
174229
176−/** This machine's servers (core.ts machineServers), from ~/.avcs/servers.json, read once. AVCS_SERVERS_FILE names another file (tests). */
231+/** This machine's servers (core.ts machineServers), from ~/.abso/servers.json (or the older ~/.avcs/servers.json), read once. ABSO_SERVERS_FILE names another file (tests). */
177232export function readMachineServers(env: Readonly<Record<string, string | undefined>> = process.env): MachineServers {
178− if (env.AVCS_SERVERS_FILE !== undefined) return machineServers(readOr(env.AVCS_SERVERS_FILE));
179− machine ??= machineServers(readOr(join(homedir(), AVCS_DIR, "servers.json")));
233+ if (fromEnv(env, "SERVERS_FILE") !== undefined) return machineServers(readOr(fromEnv(env, "SERVERS_FILE") as string));
Lines 242–312 at 318 (were 187–224 at 5)
189244
190−/** The servers the token may go to beyond abso's own: AVCS_TRUSTED_SERVERS, then this machine's servers.json. */
245+/** The servers the token may go to beyond abso's own: ABSO_TRUSTED_SERVERS, then this machine's servers.json. */
191246export function trustedServers(env: Readonly<Record<string, string | undefined>> = process.env): string {
192− return trustedList(env.AVCS_TRUSTED_SERVERS, readMachineServers(env));
194249
195−/** AVCS_TOKEN if set, else ~/.avcs/token, else none. */
251+ * A pipeline run's key, from the file ABSO_KEY_FILE names (the runner writes it, mode 600, holding the bare key).
252+ * Read each time and kept in memory only; nothing abso writes or prints holds it, errors included.
254+export function runKey(env: Readonly<Record<string, string | undefined>> = process.env): string | undefined {
268+
269+/** This machine's token file (~/.abso/token, else ~/.avcs/token), or none. Read only for a command given --token-file. */
273+
196275export function readToken(env: Readonly<Record<string, string | undefined>> = process.env): string | undefined {
197− if (env.AVCS_TOKEN) return env.AVCS_TOKEN.trim();
199− return readFileSync(join(homedir(), AVCS_DIR, "token"), "utf8").trim() || undefined;
204284
206− mkdirSync(join(root, AVCS_DIR), { recursive: true });
207− const { server, project, agent, follow, reader } = settings;
208− writeFileSync(
209− configPath(root),
210− `${JSON.stringify({ server, project, agent, ...(follow ? { follow } : {}), ...(reader ? { reader: true } : {}) }, null, 2)}\n`,
211− );
214301
215−/** If the folder is a git repo, keep .avcs/ out of it (in .git/info/exclude, so .gitignore isn't changed). */
302+/** If the folder is a git repo, keep its state folder (.abso/, or .avcs/ in an older folder) out of it (in .git/info/exclude, so .gitignore isn't changed). */
221− if (text.split(/\r?\n/).some((line) => line.trim() === ".avcs/" || line.trim() === "/.avcs/")) return;
309+ if (text.split(/\r?\n/).some((line) => line.trim() === name || line.trim() === `/${name}`)) return;
223− writeFileSync(exclude, `${text}${text === "" || text.endsWith("\n") ? "" : "\n"}/.avcs/\n`);
- MCP
- compare on this site's /mcp
- CLI
- abso diff 5 318 client/src/config.ts --json
- JSON
- /christopher/abso-core/compare/5..318?file=client%2Fsrc%2Fconfig.ts&format=json