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 292 to 293

Compare

+45 −5 in 4 places
Lines 33–39 at 293 (were 33–39 at 292)
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 184–205 at 293 (were 184–202 at 292)
184184
185185/** A local project's folder (abso init --local): its config names no server. */
186186const 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;
187189
188190async function run($: Engine, job: Job): Promise<void> {
189191 const started = await $.clock.now().catch(() => job.queuedAt);
190192 let outcome: string;
191193 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;
192196 try {
193197 if ((await readOr($, `${await stateOf($, job.root)}/paused`)) !== undefined) {
194198 outcome = "skipped: recording is paused (abso resume)";
195199 } else if (/"reader"\s*:\s*true/.test((await readOr($, `${await stateOf($, job.root)}/config.json`)) ?? "")) {
196200 outcome = "skipped: this folder is a reader";
197201 } else if (LOCAL_FOLDER.test((await readOr($, `${await stateOf($, job.root)}/config.json`)) ?? "")) {
198− // A local project's history is in a store on this machine, which only the abso command opens.
199− outcome = "skipped: a local project; abso record sends its edits";
202+ ({ outcome, context: handed } = await handToClient($, job));
200203 } else if (await ignored($, job.root, job.rel)) {
201204 outcome = "skipped: ignored path";
202205 } else if (await isLink($, job.root, job.rel)) {
Lines 220–230 at 293 (were 217–227 at 292)
217220 job.root,
218221 `${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}`,
219222 );
220− const context = newsContext(news);
223+ const context = handed ?? newsContext(news);
221224 if (context === undefined) return;
222225 // For anything that shows news later (the avcs-view mod reads it).
223226 const at = new Date(done).toISOString();
224− 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");
225228 try {
226229 await $.session.append({
227230 message: { type: "user", content: [{ type: "text", text: context }] },
Lines 237–279 at 293 (were 234–239 at 292)
234237 }
235238}
236239
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+}
237277/** Ask for the news waiting for this agent (announcements, collisions) and hand it to the model. */
238278async function pollNews($: Engine, root: string): Promise<void> {
239279 try {
MCP
compare on this site's /mcp
CLI
abso diff 292 293 client/hooks/register.ts --json
JSON
/christopher/abso-core/compare/292..293?file=client%2Fhooks%2Fregister.ts&format=json