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/versions.ts --json
JSON
/christopher/abso-core/blame/client/src/versions.ts?format=json
180 linesFirst import 89% · pinch 8% · rename 3%Last change pinch in version 280,

180 lines from 3 changes in 3 versions.

init0Start the project1// abso drop, pluck, amend, label, labels and follow: changing which published
2// versions shared holds, naming versions, and following a named one (#10, #27).
3
4import type { VersionRef } from "./api.ts";
5import { bool, type Parsed, str, UsageError } from "./args.ts";
pinch280A pull whose answer never arrives no longer leaves the folder behind The server moves the agent's base when it answers a pull, and later pulls send only what changed since that base. When the answer was lost (a timeout on a slow server), the files it carried were never written, and every later pull, status, restore and export agreed the folder was current. Now the client notes a pull in .abso/pulling.json before asking, and takes the note away once the answer is written. While the note is there, abso status says a pull didn't finish, and the next pull asks for every file in the view (as pull --full does) and writes the ones that differ, keeping work done in the folder meanwhile, as every pull does. follow, draft switching and draft-pull pull the same way. A server without full pulls gets a plain pull. Tests: client/test/lost-pull.test.ts (a fake server that carries out a pull and drops its answer), plus held-push, join-signed-out and record-batches: 19 pass. tsc and Biome clean.Compare6import {
7 applyAnswer,
8 collisionText,
9 type Env,
10 EXIT,
11 type Output,
12 open,
13 plural,
14 pullAnswer,
15 pullWritten,
16 recordFolder,
17} from "./commands.ts";
init0Start the project18import { writeConfig } from "./config.ts";
19import { refusedText } from "./safety.ts";
21function versionList(words: readonly string[], what: string): number[] {
22 if (words.length === 0) throw new UsageError(`name the ${what} by number`);
23 return words.map((w) => {
24 if (!/^\d+$/.test(w)) throw new UsageError(`${what} are version numbers (got ${JSON.stringify(w)})`);
25 return Number(w);
26 });
29function ref(v: VersionRef): string {
30 return ` version ${v.version} by ${v.agent}: ${v.message}`;
33function labelName(raw: string | undefined): string {
34 if (!raw || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(raw))
35 throw new UsageError(
36 `label names are letters, digits, dot, dash and underscore (got ${JSON.stringify(raw ?? "")})`,
37 );
38 return raw;
41export async function runDrop(args: Parsed, env: Env): Promise<Output> {
42 const versions = versionList(args.positionals, "versions to drop");
43 const message = str(args, "message");
44 if (!message) throw new UsageError('say why with -m "<message>"');
45 const { api } = open(env);
46 const answer = await api.drop(versions, message, bool(args, "with-dependents"));
47 if (answer.ok) {
48 return {
49 text: [
50 `Dropped from shared, as version ${answer.version}:`,
51 ...answer.dropped.map(ref),
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.Compare52 "Other agents hear it as news; their next pull takes it out of their folders. History keeps it: abso log shows the drop.",
init0Start the project53 ].join("\n"),
54 json: { ...answer },
55 };
56 }
57 const lines = ["Not dropped."];
58 if (answer.dependents && answer.dependents.length > 0) {
59 lines.push(
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.Compare60 `Later pushed versions build on ${versions.length === 1 ? "it" : "them"}:`,
init0Start the project61 ...answer.dependents.map(ref),
62 "Pass --with-dependents to drop those too.",
63 );
64 }
65 if (answer.blocked && answer.blocked.length > 0) {
66 lines.push(
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.Compare67 "Unpushed work builds on it, and a drop never touches unpushed work:",
init0Start the project68 ...answer.blocked.map(
69 (b) => ` ${b.agent !== undefined ? `agent ${b.agent}` : `draft ${b.draft}`}: ${b.files.join(", ")}`,
70 ),
71 );
72 }
73 return { exit: EXIT.refused, text: lines.join("\n"), json: { ...answer } };
76export async function runPluck(args: Parsed, env: Env): Promise<Output> {
77 const [draft, ...rest] = args.positionals;
78 if (draft === undefined)
79 throw new UsageError('pluck takes a draft and its versions: abso pluck <draft> <version...> -m "why"');
80 const versions = versionList(rest, `versions of draft ${draft} to pluck`);
81 const message = str(args, "message");
82 if (!message) throw new UsageError('say why with -m "<message>"');
83 const { api } = open(env);
84 const answer = await api.pluck(draft, versions, message, bool(args, "with-dependencies"));
85 if (answer.ok) {
86 return {
87 text: `Plucked ${plural(versions.length, "version")} of draft ${draft} into shared as version ${answer.version} (${plural(answer.changes, "change")}). The draft stays as it is; landing it later brings in only the rest.`,
88 json: { ...answer },
89 };
90 }
91 const lines = ["Not plucked."];
92 if (answer.needs && answer.needs.length > 0)
93 lines.push(
94 "They build on these versions of the draft:",
95 ...answer.needs.map(ref),
96 "Pass --with-dependencies to take those too.",
97 );
98 if (answer.collisions && answer.collisions.length > 0)
99 lines.push(
100 `${plural(answer.collisions.length, "collision")} with work in shared:`,
101 ...answer.collisions.map(collisionText),
102 );
103 return { exit: EXIT.refused, text: lines.join("\n"), json: { ...answer } };
106export async function runAmend(args: Parsed, env: Env): Promise<Output> {
107 const message = str(args, "message");
108 if (!message) throw new UsageError('give the new message with -m "<message>"');
109 const { api } = open(env);
110 const a = await api.amend(message);
111 const where = a.draft === null ? "shared" : `draft ${a.draft}`;
112 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.Compare113 text: `Version ${a.version} of ${where} now says: ${a.message}\n(It said: ${a.was}.) Only the message changed; to change what it did, push again or abso drop it.`,
init0Start the project114 json: { ...a },
115 };
118export async function runLabel(args: Parsed, env: Env): Promise<Output> {
119 if (args.positionals.length !== 1)
120 throw new UsageError("label takes one name: abso label <name> [--version <n>] [--remove]");
121 const name = labelName(args.positionals[0]);
122 const raw = str(args, "version");
123 if (raw !== undefined && !/^\d+$/.test(raw))
124 throw new UsageError(`--version is a version number (got ${JSON.stringify(raw)})`);
125 const remove = bool(args, "remove");
126 const { api } = open(env);
127 const a = await api.label(name, raw === undefined ? undefined : Number(raw), remove);
128 const now =
129 a.versions.length === 0 ? "no version now" : `${plural(a.versions.length, "version")}: ${a.versions.join(", ")}`;
130 return {
131 text: `${remove ? "Took" : "Put"} label ${a.name} ${remove ? "off" : "on"} version ${a.version}. It marks ${now}.`,
132 json: { ...a },
133 };
136export async function runLabels(_args: Parsed, env: Env): Promise<Output> {
137 const { config, api } = open(env);
138 const { labels } = await api.labels();
139 const names = Object.keys(labels).sort();
140 const lines =
141 names.length === 0
142 ? ["No labels yet. abso label <name> puts one on shared's newest version."]
143 : names.map((n) => ` ${n}: ${labels[n]!.join(", ")}${config.follow === n ? " (this folder follows it)" : ""}`);
144 return { text: lines.join("\n"), json: { labels, follow: config.follow ?? null } };
147export async function runFollow(args: Parsed, env: Env): Promise<Output> {
148 const none = bool(args, "none");
149 if (none === (args.positionals.length === 1) || args.positionals.length > 1)
150 throw new UsageError("follow takes one label, or --none: abso follow <label> | abso follow --none");
151 const follow = none ? undefined : labelName(args.positionals[0]);
152 const { root, config } = open(env);
153 const { token: _token, follow: _old, ...settings } = config;
154 writeConfig(root, { ...settings, ...(follow ? { follow } : {}) });
155 // Sync now (recording first, as sync does), so the folder is where it now says it is.
156 const { api } = open(env);
157 await recordFolder(root, api);
pinch280A pull whose answer never arrives no longer leaves the folder behind The server moves the agent's base when it answers a pull, and later pulls send only what changed since that base. When the answer was lost (a timeout on a slow server), the files it carried were never written, and every later pull, status, restore and export agreed the folder was current. Now the client notes a pull in .abso/pulling.json before asking, and takes the note away once the answer is written. While the note is there, abso status says a pull didn't finish, and the next pull asks for every file in the view (as pull --full does) and writes the ones that differ, keeping work done in the folder meanwhile, as every pull does. follow, draft switching and draft-pull pull the same way. A server without full pulls gets a plain pull. Tests: client/test/lost-pull.test.ts (a fake server that carries out a pull and drops its answer), plus held-push, join-signed-out and record-batches: 19 pass. tsc and Biome clean.Compare158 const s = await applyAnswer(root, api, await pullAnswer(root, api));
159 pullWritten(root);
init0Start the project160 const changes = s.written.length + s.deleted.length;
161 const head = follow
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.Compare162 ? `This folder now follows label ${follow}: every pull takes it to the newest version with that label. It is on version ${s.version}.`
163 : `This folder follows no label now: pulls take it to shared's newest version, ${s.version}.`;
init0Start the project164 return {
165 text: [
166 head,
167 changes === 0 ? "No files changed." : `${plural(s.written.length, "file")} updated, ${s.deleted.length} deleted.`,
168 ...refusedText(s.refused),
169 ...(s.kept.length > 0 ? [`Left alone because they have unrecorded changes: ${s.kept.join(", ")}`] : []),
170 ].join("\n"),
171 json: {
172 follow: follow ?? null,
173 version: s.version,
174 written: s.written,
175 deleted: s.deleted,
176 kept: s.kept,
177 refused: s.refused,
178 },
179 };