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/src/project-file.ts --json
JSON
/christopher/abso-core/blame/client/src/project-file.ts?format=json
121 linesFirst import 82% · review 16% · rename 2% · infra-split 1%Last change rename in version 100,

121 lines from 4 changes in 4 versions.

init0Start the project1// avcs.json: what the project runs to check and build a version (#39). It is
2// recorded and published like any file, so each version carries its own; the
3// server's job for each new shared version reads it, and publish --check with
4// no command runs its check.
5
6import { existsSync, readFileSync, writeFileSync } from "node:fs";
7import { join } from "node:path";
8
review28Client: abso.json is the project file (avcs.json still read; a new project gets abso.json unless it has either); new folders get .abso when no installed mod is older than 0.2.0; both mods are 0.2.0 (abso 253, 224)Compare9/** The project file's name: abso.json, or avcs.json from before the rename. A new one is written as abso.json. */
10export const PROJECT_FILE = "abso.json";
11export const OLD_PROJECT_FILE = "avcs.json";
init0Start the project12
review28Client: abso.json is the project file (avcs.json still read; a new project gets abso.json unless it has either); new folders get .abso when no installed mod is older than 0.2.0; both mods are 0.2.0 (abso 253, 224)Compare13/** The name the folder's project file has: abso.json when it is there, else avcs.json when that is, else the new name. */
14export function projectFileName(root: string): string {
15 if (existsSync(join(root, PROJECT_FILE))) return PROJECT_FILE;
16 return existsSync(join(root, OLD_PROJECT_FILE)) ? OLD_PROJECT_FILE : PROJECT_FILE;
init0Start the project19/** Each key optional; an empty string counts as missing. */
20export interface ProjectFile {
21 readonly setup: string;
22 readonly check: string;
23 readonly build: string;
24 readonly out: string;
25 /** The merge queue (#39): publishes to shared land only once the project's check passes on them. */
26 readonly queue?: boolean;
29const KEYS = ["setup", "check", "build", "out"] as const;
review28Client: abso.json is the project file (avcs.json still read; a new project gets abso.json unless it has either); new folders get .abso when no installed mod is older than 0.2.0; both mods are 0.2.0 (abso 253, 224)Compare31/** The folder's abso.json (or avcs.json), or why it can't be read; null when there is none. */
init0Start the project32export function readProjectFile(root: string): { file: ProjectFile } | { error: string } | null {
review28Client: abso.json is the project file (avcs.json still read; a new project gets abso.json unless it has either); new folders get .abso when no installed mod is older than 0.2.0; both mods are 0.2.0 (abso 253, 224)Compare33 const name = projectFileName(root);
34 const path = join(root, name);
init0Start the project35 if (!existsSync(path)) return null;
36 let raw: unknown;
37 try {
38 raw = JSON.parse(readFileSync(path, "utf8"));
39 } catch (e) {
review28Client: abso.json is the project file (avcs.json still read; a new project gets abso.json unless it has either); new folders get .abso when no installed mod is older than 0.2.0; both mods are 0.2.0 (abso 253, 224)Compare40 return { error: `${name} isn't valid JSON (${(e as Error).message})` };
init0Start the project41 }
42 if (typeof raw !== "object" || raw === null || Array.isArray(raw))
review28Client: abso.json is the project file (avcs.json still read; a new project gets abso.json unless it has either); new folders get .abso when no installed mod is older than 0.2.0; both mods are 0.2.0 (abso 253, 224)Compare43 return { error: `${name} should hold an object, like {"check": "npm test"}` };
init0Start the project44 const o = raw as Record<string, unknown>;
45 for (const k of KEYS) {
review28Client: abso.json is the project file (avcs.json still read; a new project gets abso.json unless it has either); new folders get .abso when no installed mod is older than 0.2.0; both mods are 0.2.0 (abso 253, 224)Compare46 if (o[k] !== undefined && typeof o[k] !== "string") return { error: `"${k}" in ${name} should be a string` };
init0Start the project47 }
48 const get = (k: (typeof KEYS)[number]) => ((o[k] as string | undefined) ?? "").trim();
49 return {
50 file: {
51 setup: get("setup"),
52 check: get("check"),
53 build: get("build"),
54 out: get("out"),
55 ...(o.queue === true ? { queue: true } : {}),
56 },
57 };
60/** npm's placeholder test script, which always fails. */
61const NO_TEST = /no test specified/;
review28Client: abso.json is the project file (avcs.json still read; a new project gets abso.json unless it has either); new folders get .abso when no installed mod is older than 0.2.0; both mods are 0.2.0 (abso 253, 224)Compare63/** A starting abso.json, guessed from package.json; empty where nothing can be guessed. */
init0Start the project64export function guessProjectFile(root: string): ProjectFile {
65 let pkg: {
66 scripts?: Record<string, unknown>;
67 dependencies?: Record<string, unknown>;
68 devDependencies?: Record<string, unknown>;
69 } = {};
70 const hasPkg = existsSync(join(root, "package.json"));
71 if (hasPkg) {
72 try {
73 pkg = JSON.parse(readFileSync(join(root, "package.json"), "utf8")) ?? {};
74 } catch {
75 pkg = {};
76 }
77 }
78 const scripts = typeof pkg.scripts === "object" && pkg.scripts !== null ? pkg.scripts : {};
79 const has = (s: string) => typeof scripts[s] === "string" && !(s === "test" && NO_TEST.test(scripts[s] as string));
80 const check = has("check")
81 ? "npm run check"
82 : [has("typecheck") ? "npm run typecheck" : "", has("test") ? "npm test" : ""].filter((c) => c !== "").join(" && ");
83 const vite = "vite" in (pkg.devDependencies ?? {}) || "vite" in (pkg.dependencies ?? {});
84 const build = vite ? "npx --no-install vite build --base ./ --outDir dist" : has("build") ? "npm run build" : "";
85 const out = vite ? "dist" : "";
86 const setup = existsSync(join(root, "package-lock.json")) ? "npm ci" : hasPkg ? "npm install" : "";
87 return { setup, check, build, out };
90/**
review28Client: abso.json is the project file (avcs.json still read; a new project gets abso.json unless it has either); new folders get .abso when no installed mod is older than 0.2.0; both mods are 0.2.0 (abso 253, 224)Compare91 * Writes a guessed abso.json (unless it has abso.json or avcs.json) when the folder has none and package.json gives
infra-split37Comments and test names give each reason in plain words, without naming who raised it Notes like "(#37, Builder 5)" or "(AVCS - Security)" become "(#37)" or go, and a private commit hash after a name goes with it. Issue numbers and references such as git's CVE-2019-1353 stay. Only comments and test names change; no behavior changes.Compare92 * a check or a build to guess (#39: a project with nothing to
init0Start the project93 * check shouldn't start boxes; CI skips a version with nothing to run).
94 * Answers what it wrote; 'exists' or 'nothing' when it wrote none.
95 */
96export function writeStartingProjectFile(root: string): ProjectFile | "exists" | "nothing" {
review28Client: abso.json is the project file (avcs.json still read; a new project gets abso.json unless it has either); new folders get .abso when no installed mod is older than 0.2.0; both mods are 0.2.0 (abso 253, 224)Compare97 if (existsSync(join(root, PROJECT_FILE)) || existsSync(join(root, OLD_PROJECT_FILE))) return "exists";
init0Start the project98 const guess = guessProjectFile(root);
99 if (guess.check === "" && guess.build === "") return "nothing";
100 writeFileSync(join(root, PROJECT_FILE), `${JSON.stringify(guess, null, 2)}\n`);
101 return guess;
review28Client: abso.json is the project file (avcs.json still read; a new project gets abso.json unless it has either); new folders get .abso when no installed mod is older than 0.2.0; both mods are 0.2.0 (abso 253, 224)Compare104/** What init says about abso.json. */
init0Start the project105export function startingProjectFileText(wrote: ProjectFile | "exists" | "nothing"): string[] {
106 if (wrote === "exists") return [];
107 if (wrote === "nothing") {
108 return [
rename100abso publish is now abso push, abso sync is now abso pull (abso 427) Commands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; "shared" stays the noun ("Pushed version N"). No aliases, no notices. A queued push that was "pulled" is now "turned back", so pull means one thing. push -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch. Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare109 `No ${PROJECT_FILE} written: package.json gives no check or build to guess, so CI has nothing to run on each new version. To give it a check, push an ${PROJECT_FILE} like {"check": "npm test"} (abso ci --help says what it runs).`,
init0Start the project110 ];
111 }
112 const set = KEYS.filter((k) => wrote[k] !== "").map((k) => `${k} "${wrote[k]}"`);
113 const empty = KEYS.filter((k) => wrote[k] === "");
114 return [
115 [
116 `Wrote ${PROJECT_FILE}: CI will run on every new version of shared (${set.join(", ")}).`,
117 empty.length > 0 ? ` Fill in ${empty.join(", ")} when the project has them.` : "",
rename100abso publish is now abso push, abso sync is now abso pull (abso 427) Commands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; "shared" stays the noun ("Pushed version N"). No aliases, no notices. A queued push that was "pulled" is now "turned back", so pull means one thing. push -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch. Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare118 " abso push --check with no command runs its build and check.",
init0Start the project119 ].join(""),
120 ];