Local projects: the abso mod hands their edits to abso hook. The installer stamps the mod with the command that runs its checkout's abso hook (node, client/abso.ts); in a local project's folder the mod runs it with the edit, as Claude Code's command hook would, and passes its news to the chat. A mod installed before this one still skips local folders, and init says so. Version 293 of shared· pinch· Oct 16 (2026-10-16 03:29 UTC) · Not checked
Version 292 · Files at version 293
6 files, 141 lines added, 14 removed.
--- a/client/hooks/register.test.ts
+++ b/client/hooks/register.test.ts
@@ -3,9 +3,10 @@
4 4 import type { On } from "claude-code"; 5 5 import { expect, mock, test } from "claude-code/testing"; 6 + import { HOOK_COMMAND } from "./stamp.ts"; 7 8 /** The world beneath the mod: a chat in /w/p, an abso folder when `inFolder`, and a server with `news` waiting. */ 8 − function world(on: On, inFolder: boolean, news: string[][]) {
9 + function world(on: On, inFolder: boolean, news: string[][], server = "https://avcs.test") { 9 10 mock.env(on, { AVCS_TOKEN: "test-token" }); 10 11 const clock = mock.clock(on, { now: 1_000_000 }); 11 12 const asked: string[] = []; @@ -21,7 +22,7 @@
21 22 on("fs.read", (_$, e) => { 22 23 const path = norm(e.path); 23 24 if (inFolder && path === "/w/p/.abso/config.json") 24 − return { value: JSON.stringify({ server: "https://avcs.test", project: "p", agent: "bob" }) };
25 + return { value: JSON.stringify({ server, project: "p", agent: "bob" }) }; 25 26 if (written.has(path)) return { value: written.get(path)! }; 26 27 return { deny: `ENOENT: ${path}` }; @@ -114,3 +115,38 @@
114 115 expect(w.written.get("/w/p/.abso/hook.log") ?? "").toContain("not sent: a NUL byte at line 3"); 115 116 expect(w.asked.filter((u) => !u.endsWith("/news"))).toEqual([]); 119 + test("a local project's edit goes to abso hook as Claude Code's command hook would get it, and its news to the chat", async ($, on) => { 120 + const w = world(on, true, [], "local"); 121 + w.written.set("/w/p/notes.md", "hello\n"); 122 + on("fs.stat", () => ({ value: { realPath: "/w/p/notes.md" } }) as never); 123 + on("session.id", () => ({ value: "sess" })); 124 + const ran: { argv: readonly string[]; stdin?: string; env?: Record<string, string> }[] = []; 125 + const context = "abso: Announcement from lead: hold pushes"; 126 + on("process.run", (_$, e) => { 127 + ran.push({ argv: e.argv, stdin: e.init?.stdin, env: e.init?.env }); 128 + const stdout = JSON.stringify({ hookSpecificOutput: { hookEventName: "PostToolUse", additionalContext: context } }); 129 + return { value: { exitCode: 0, stdout, stderr: "" } } as never; 131 + await $.session.start({ cwd: "/w/p" }); 132 + await $.tool.call({ tool: "Write", tool_use_id: "t1", file_path: "/w/p/notes.md", content: "hello\n" } as never); 133 + await w.clock.advance(1_000); 134 + // A local project has no server to call: nothing goes over the network. 135 + expect(w.asked.filter((u) => !u.endsWith("/news"))).toEqual([]); 136 + const log = w.written.get("/w/p/.abso/hook.log") ?? ""; 137 + if (HOOK_COMMAND === undefined) { 138 + // Loaded from a checkout, the mod has no client to hand it to. 139 + expect(ran).toEqual([]); 140 + expect(log).toContain("skipped: a local project"); 143 + expect(ran).toHaveLength(1); 144 + expect(ran[0]!.argv).toEqual(HOOK_COMMAND); 145 + expect(ran[0]!.env).toEqual({ ABSO_HOOK_FORCE: "1" }); 146 + const input = JSON.parse(ran[0]!.stdin ?? "{}") as Record<string, unknown>; 147 + expect(input.session_id).toBe("sess"); 148 + expect(input.tool_name).toBe("Write"); 149 + expect((input.tool_input as Record<string, unknown>).file_path).toBe("/w/p/notes.md"); 150 + expect(log).toContain("handed to abso hook"); 151 + expect(w.appended).toEqual([context]); --- a/client/hooks/register.ts
+++ b/client/hooks/register.ts
@@ -33,7 +33,7 @@
35 35 } from "../src/core.ts"; 36 − import { STAMP } from "./stamp.ts";
36 + import { HOOK_COMMAND, STAMP } from "./stamp.ts"; 38 38 const TOOLS = ["Edit", "MultiEdit", "Write", "NotebookEdit"]; 39 39 /** A known copy holding a NUL byte reads as no known copy (the client treats it as binary). */ @@ -184,19 +184,22 @@
185 185 /** A local project's folder (abso init --local): its config names no server. */ 186 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; 188 190 async function run($: Engine, job: Job): Promise<void> { 189 191 const started = await $.clock.now().catch(() => job.queuedAt); 190 192 let outcome: string; 191 193 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; 193 197 if ((await readOr($, `${await stateOf($, job.root)}/paused`)) !== undefined) { 194 198 outcome = "skipped: recording is paused (abso resume)"; 195 199 } else if (/"reader"\s*:\s*true/.test((await readOr($, `${await stateOf($, job.root)}/config.json`)) ?? "")) { 196 200 outcome = "skipped: this folder is a reader"; 197 201 } 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)); 200 203 } else if (await ignored($, job.root, job.rel)) { 201 204 outcome = "skipped: ignored path"; 202 205 } else if (await isLink($, job.root, job.rel)) { @@ -217,11 +220,11 @@
218 221 `${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}`, 220 − const context = newsContext(news);
223 + const context = handed ?? newsContext(news); 221 224 if (context === undefined) return; 222 225 // For anything that shows news later (the avcs-view mod reads it). 223 226 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"); 226 229 await $.session.append({ 227 230 message: { type: "user", content: [{ type: "text", text: context }] }, @@ -234,6 +237,43 @@
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. 244 + async function handToClient($: Engine, job: Job): Promise<{ outcome: string; context?: string }> { 245 + if (HOOK_COMMAND === undefined || HOOK_COMMAND.length === 0) 248 + "skipped: a local project, and this mod has no abso to hand it to (install-mod.ts adds one); abso record sends it", 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 } : {}), 257 + const ran = await $.process.run(HOOK_COMMAND, { 259 + env: { ABSO_HOOK_FORCE: "1" }, 260 + stdin: JSON.stringify(hookInput), 261 + timeoutMs: LOCAL_HOOK_MS, 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(); 269 + : (JSON.parse(out) as { hookSpecificOutput?: { additionalContext?: unknown } }).hookSpecificOutput 270 + ?.additionalContext; 272 + outcome: "handed to abso hook (a local project; its own line is just above)", 273 + ...(typeof context === "string" ? { context } : {}), 237 277 /** Ask for the news waiting for this agent (announcements, collisions) and hand it to the model. */ 238 278 async function pollNews($: Engine, root: string): Promise<void> { --- a/client/hooks/stamp.ts
+++ b/client/hooks/stamp.ts
@@ -3,3 +3,9 @@
3 3 // this file with the version it installs: plugin.json's, plus the commit 4 4 // (0.1.0+702c616). Loaded straight from a checkout, it stays undefined. 5 5 export const STAMP: string | undefined = undefined; 7 + // The command that runs `abso hook` from the checkout the mod was installed 8 + // from, as [node, client/abso.ts, "hook"]; the installer writes it too. A 9 + // local project's history is in a store on this machine that only the abso 10 + // command opens, so the mod hands those edits to it. 11 + export const HOOK_COMMAND: readonly string[] | undefined = undefined; --- a/client/src/install.ts
+++ b/client/src/install.ts
@@ -94,6 +94,8 @@
94 94 /** For tests: the rename that moves each file into place. */ 95 95 readonly rename?: (from: string, to: string) => void; 96 96 readonly now?: Date; 97 + /** For tests: the command stamped as HOOK_COMMAND, instead of this client's own `abso hook`. */ 98 + readonly hookCommand?: readonly string[]; 99 101 const RECORD = ".avcs-install.json"; @@ -132,6 +134,15 @@
132 134 existsSync(at(skillsFolder(AVCS_MOD.name, env), MANIFEST)) || 133 135 existsSync(at(skillsFolder(OLD_MOD_NAMES[AVCS_MOD.name]!, env), MANIFEST)); 137 + /** Whether the installed abso mod hands a local project's edits to abso hook: it was installed with a HOOK_COMMAND. */ 138 + export function modHandsLocal(env: Readonly<Record<string, string | undefined>> = process.env): boolean { 140 + return /HOOK_COMMAND[^=\n]*=\s*\[/.test(readFileSync(at(skillsFolder(AVCS_MOD.name, env), STAMP_FILE), "utf8")); 136 147 * After the new mod is in, the folder it replaces (skills/avcs, skills/avcs-view) would load beside it, so it 137 148 * is moved, not deleted, to ~/.abso/retired-mods/<name>-<stamp>. Returns where it went, or undefined when there was none. @@ -226,8 +237,11 @@
229 − /** The files to install, stamped with `version`, in install order. */
230 − function filesFor(spec: ModSpec, version: string): Map<string, Buffer> {
240 + /** The command that runs this checkout's `abso hook`: what the mod hands a local project's edits to. */ 241 + export const hookCommand = (): readonly string[] => [process.execPath, join(CLIENT_DIR, "abso.ts"), "hook"]; 243 + /** The files to install, stamped with `version` (and HOOK_COMMAND, where a stamp.ts has it), in install order. */ 244 + function filesFor(spec: ModSpec, version: string, hook: readonly string[] = hookCommand()): Map<string, Buffer> { 231 245 if (!/^[\w.+-]+$/.test(version)) throw new Error(`can't stamp the version ${JSON.stringify(version)}`); 232 246 const out = new Map<string, Buffer>(); 233 247 for (const rel of spec.files) { @@ -239,7 +253,9 @@
239 253 const text = data.toString("utf8"); 240 254 const stamped = text.replace(/(STAMP[^=\n]*=\s*)undefined/, `$1'${version}'`); 241 255 if (stamped === text) throw new Error(`${rel} has no "STAMP ... = undefined" line to stamp`); 242 − data = Buffer.from(stamped);
257 + stamped.replace(/(HOOK_COMMAND[^=\n]*=\s*)undefined/, (_, head: string) => head + JSON.stringify(hook)), 244 260 out.set(rel, data); @@ -386,7 +402,7 @@
386 402 export function installMod(spec: ModSpec, options: InstallOptions): Installed { 387 403 const target = resolve(options.target); 388 404 const version = versionFor(spec, options.commit); 389 − const next = filesFor(spec, version);
405 + const next = filesFor(spec, version, options.hookCommand); 390 406 const existed = existsSync(target); 391 407 mkdirSync(target, { recursive: true }); --- a/client/src/join-commands.ts
+++ b/client/src/join-commands.ts
@@ -32,7 +32,7 @@
32 32 import { elsewhereText } from "./doctor.ts"; 33 33 import { fromEnv } from "./env-names.ts"; 34 34 import { clearKnown, loadIgnore, readFolder, writeKnown } from "./folder.ts"; 35 − import { installerCommand, modInstalled } from "./install.ts";
35 + import { installerCommand, modHandsLocal, modInstalled } from "./install.ts"; 36 36 import { LOCAL, NO_STORE, storeDir } from "./local-store.ts"; 37 37 import { type FullMode, foldModes, writeKnownModes } from "./modes.ts"; 38 38 import { initInOrg, siteOf } from "./orgs.ts"; @@ -538,8 +538,14 @@
540 540 function hookHint(env: Readonly<Record<string, string | undefined>>, local = false): string { 541 − // The mod sends each edit to the folder's server itself, and a local project has none.
542 − if (local) return "abso record sends the edits made here: the abso mod doesn't record local projects yet.";
541 + // A local project has no server: the mod hands its edits to abso hook, when it was installed with one to hand them to. 543 + if (modHandsLocal(env)) 544 + return "Edits made by Claude Code here are recorded by the abso mod on this machine, through abso hook. Anything else: abso record."; 545 + if (modInstalled(env) && !builtCopy()) 546 + return `abso record sends the edits made here: the abso mod on this machine is older than local projects. ${installerCommand("install-mod.ts")} updates it, and new chats load it.`; 547 + return "abso record sends the edits made here, whoever made them."; 543 549 if (modInstalled(env)) 544 550 return "Edits made by Claude Code here are recorded by the abso mod on this machine, signed in as this folder. Anything else: abso record."; 545 551 // A built copy (the npm package) has no installer to point at (abso-core 18). --- a/client/test/install.test.ts
+++ b/client/test/install.test.ts
@@ -26,6 +26,7 @@
26 26 import { clientVersion, headCommit } from "../src/client-version.ts"; @@ -114,6 +115,28 @@
118 + it("stamps the command that runs this client's abso hook, where stamp.ts has a HOOK_COMMAND line", () => { 119 + const spec = source({ 121 + "export const STAMP: string | undefined = undefined\nexport const HOOK_COMMAND: readonly string[] | undefined = undefined\n", 123 + const target = join(temp(), "avcs"); 128 + hookCommand: ["C:\\node.exe", "C:\\abso\\client\\abso.ts", "hook"], 131 + read(target, "hooks/stamp.ts"), 132 + "export const STAMP: string | undefined = '0.1.0+702c616'\n" + 133 + 'export const HOOK_COMMAND: readonly string[] | undefined = ["C:\\\\node.exe","C:\\\\abso\\\\client\\\\abso.ts","hook"]\n', 135 + // By default, this checkout's own: the node running it and client/abso.ts. 136 + assert.deepEqual(hookCommand().slice(0, 1), [process.execPath]); 137 + assert.match(hookCommand()[1]!, /client[\\/]abso\.ts$/); 117 140 it("moves the files in by rename, what the hook imports first and plugin.json last", () => { 118 141 const spec = source(); 119 142 const target = join(temp(), "avcs");