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

Versions 275 to 318

Compare

+50 −3 in 5 places
Lines 33–39 at 318 (were 33–39 at 275)
3333 uncomposedText,
3434 type Who,
3535} from "../src/core.ts";
36−import { STAMP } from "./stamp.ts";
36+import { HOOK_COMMAND, STAMP } from "./stamp.ts";
3737
3838const TOOLS = ["Edit", "MultiEdit", "Write", "NotebookEdit"];
3939/** A known copy holding a NUL byte reads as no known copy (the client treats it as binary). */
Lines 182–205 at 318 (were 182–196 at 275)
182182 for (let job = jobs.shift(); job !== undefined; job = jobs.shift()) await run($, job);
183183}
184184
185+/** A local project's folder (abso init --local): its config names no server. */
186+const LOCAL_FOLDER = /"server"\s*:\s*"local"/;
187+/** How long abso hook may take on a local project's edit: it waits up to two minutes for the store's lock. */
188+const LOCAL_HOOK_MS = 150_000;
185190async function run($: Engine, job: Job): Promise<void> {
186191 const started = await $.clock.now().catch(() => job.queuedAt);
187192 let outcome: string;
188193 let news: readonly string[] = [];
194+ /** What abso hook handed back for the agent, on a local project's edit (it keeps the news log itself). */
195+ let handed: string | undefined;
189196 try {
190197 if ((await readOr($, `${await stateOf($, job.root)}/paused`)) !== undefined) {
191198 outcome = "skipped: recording is paused (abso resume)";
192199 } else if (/"reader"\s*:\s*true/.test((await readOr($, `${await stateOf($, job.root)}/config.json`)) ?? "")) {
193200 outcome = "skipped: this folder is a reader";
201+ } else if (LOCAL_FOLDER.test((await readOr($, `${await stateOf($, job.root)}/config.json`)) ?? "")) {
202+ ({ outcome, context: handed } = await handToClient($, job));
194203 } else if (await ignored($, job.root, job.rel)) {
195204 outcome = "skipped: ignored path";
196205 } else if (await isLink($, job.root, job.rel)) {
Lines 220–230 at 318 (were 211–221 at 275)
211220 job.root,
212221 `${new Date(job.queuedAt).toISOString()}\t${job.tool}\t${job.rel}\t${outcome}\t${done - started}ms sending, ${started - job.queuedAt}ms queued (in process, async)\t${CLIENT}`,
213222 );
214− const context = newsContext(news);
223+ const context = handed ?? newsContext(news);
215224 if (context === undefined) return;
216225 // For anything that shows news later (the avcs-view mod reads it).
217226 const at = new Date(done).toISOString();
218− await log($, job.root, news.map((n) => `${at}\t${n}`).join("\n"), "news.log");
227+ if (news.length > 0) await log($, job.root, news.map((n) => `${at}\t${n}`).join("\n"), "news.log");
219228 try {
220229 await $.session.append({
221230 message: { type: "user", content: [{ type: "text", text: context }] },
Lines 237–279 at 318 (were 228–233 at 275)
228237 }
229238}
230239
240+/**
241+ * A local project's history is in a store on this machine that only the abso command opens, so its edits go to
242+ * `abso hook` from the checkout this mod was installed from, as Claude Code's command hook would run it.
243+ */
244+async function handToClient($: Engine, job: Job): Promise<{ outcome: string; context?: string }> {
245+ if (HOOK_COMMAND === undefined || HOOK_COMMAND.length === 0)
246+ return {
247+ outcome:
248+ "skipped: a local project, and this mod has no abso to hand it to (install-mod.ts adds one); abso record sends it",
249+ };
250+ const hookInput = {
251+ session_id: await $.session.id(),
252+ cwd: slash(await $.session.cwd()),
253+ tool_name: job.tool,
254+ tool_input: job.input,
255+ ...(job.agentId ? { agent_id: job.agentId } : {}),
256+ };
257+ const ran = await $.process.run(HOOK_COMMAND, {
258+ cwd: job.root,
259+ env: { ABSO_HOOK_FORCE: "1" },
260+ stdin: JSON.stringify(hookInput),
261+ timeoutMs: LOCAL_HOOK_MS,
262+ });
263+ if (ran.exitCode !== 0) throw new Error(`abso hook exited ${ran.exitCode}: ${ran.stderr.trim().split("\n").at(-1)}`);
264+ // It prints Claude Code's JSON when it has news for the agent, and nothing otherwise.
265+ const out = ran.stdout.trim();
266+ const context =
267+ out === ""
268+ ? undefined
269+ : (JSON.parse(out) as { hookSpecificOutput?: { additionalContext?: unknown } }).hookSpecificOutput
270+ ?.additionalContext;
271+ return {
272+ outcome: "handed to abso hook (a local project; its own line is just above)",
273+ ...(typeof context === "string" ? { context } : {}),
274+ };
275+}
231277/** Ask for the news waiting for this agent (announcements, collisions) and hand it to the model. */
232278async function pollNews($: Engine, root: string): Promise<void> {
233279 try {
Lines 288–294 at 318 (were 242–247 at 275)
242288 project: string;
243289 agent: string;
244290 };
291+ if (config.server === "local") return;
245292 const bearer = await token($, config.server);
246293 const r = await $.http.fetch(
247294 `${config.server.replace(/\/+$/, "")}/p/${encodeURIComponent(config.project)}/a/${encodeURIComponent(config.agent)}/news`,
MCP
compare on this site's /mcp
CLI
abso diff 275 318 client/hooks/register.ts --json
JSON
/christopher/abso-core/compare/275..318?file=client%2Fhooks%2Fregister.ts&format=json