{"version":293,"agent":"pinch","message":"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.","time":1792121340185,"timeIso":"2026-10-16T03:29:00.185Z","changes":14,"change":4591,"files":["client/hooks/register.test.ts","client/hooks/register.ts","client/hooks/stamp.ts","client/src/install.ts","client/src/join-commands.ts","client/test/install.test.ts"],"draft":null,"diff":[{"path":"client/hooks/register.test.ts","added":38,"removed":2,"diff":"--- a/client/hooks/register.test.ts\n+++ b/client/hooks/register.test.ts\n@@ -3,9 +3,10 @@\n \n import type { On } from \"claude-code\";\n import { expect, mock, test } from \"claude-code/testing\";\n+import { HOOK_COMMAND } from \"./stamp.ts\";\n \n /** The world beneath the mod: a chat in /w/p, an abso folder when `inFolder`, and a server with `news` waiting. */\n-function world(on: On, inFolder: boolean, news: string[][]) {\n+function world(on: On, inFolder: boolean, news: string[][], server = \"https://avcs.test\") {\n \tmock.env(on, { AVCS_TOKEN: \"test-token\" });\n \tconst clock = mock.clock(on, { now: 1_000_000 });\n \tconst asked: string[] = [];\n@@ -21,7 +22,7 @@\n \ton(\"fs.read\", (_$, e) => {\n \t\tconst path = norm(e.path);\n \t\tif (inFolder && path === \"/w/p/.abso/config.json\")\n-\t\t\treturn { value: JSON.stringify({ server: \"https://avcs.test\", project: \"p\", agent: \"bob\" }) };\n+\t\t\treturn { value: JSON.stringify({ server, project: \"p\", agent: \"bob\" }) };\n \t\tif (written.has(path)) return { value: written.get(path)! };\n \t\treturn { deny: `ENOENT: ${path}` };\n \t});\n@@ -114,3 +115,38 @@\n \texpect(w.written.get(\"/w/p/.abso/hook.log\") ?? \"\").toContain(\"not sent: a NUL byte at line 3\");\n \texpect(w.asked.filter((u) => !u.endsWith(\"/news\"))).toEqual([]);\n });\n+\n+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) => {\n+\tconst w = world(on, true, [], \"local\");\n+\tw.written.set(\"/w/p/notes.md\", \"hello\\n\");\n+\ton(\"fs.stat\", () => ({ value: { realPath: \"/w/p/notes.md\" } }) as never);\n+\ton(\"session.id\", () => ({ value: \"sess\" }));\n+\tconst ran: { argv: readonly string[]; stdin?: string; env?: Record<string, string> }[] = [];\n+\tconst context = \"abso: Announcement from lead: hold pushes\";\n+\ton(\"process.run\", (_$, e) => {\n+\t\tran.push({ argv: e.argv, stdin: e.init?.stdin, env: e.init?.env });\n+\t\tconst stdout = JSON.stringify({ hookSpecificOutput: { hookEventName: \"PostToolUse\", additionalContext: context } });\n+\t\treturn { value: { exitCode: 0, stdout, stderr: \"\" } } as never;\n+\t});\n+\tawait $.session.start({ cwd: \"/w/p\" });\n+\tawait $.tool.call({ tool: \"Write\", tool_use_id: \"t1\", file_path: \"/w/p/notes.md\", content: \"hello\\n\" } as never);\n+\tawait w.clock.advance(1_000);\n+\t// A local project has no server to call: nothing goes over the network.\n+\texpect(w.asked.filter((u) => !u.endsWith(\"/news\"))).toEqual([]);\n+\tconst log = w.written.get(\"/w/p/.abso/hook.log\") ?? \"\";\n+\tif (HOOK_COMMAND === undefined) {\n+\t\t// Loaded from a checkout, the mod has no client to hand it to.\n+\t\texpect(ran).toEqual([]);\n+\t\texpect(log).toContain(\"skipped: a local project\");\n+\t\treturn;\n+\t}\n+\texpect(ran).toHaveLength(1);\n+\texpect(ran[0]!.argv).toEqual(HOOK_COMMAND);\n+\texpect(ran[0]!.env).toEqual({ ABSO_HOOK_FORCE: \"1\" });\n+\tconst input = JSON.parse(ran[0]!.stdin ?? \"{}\") as Record<string, unknown>;\n+\texpect(input.session_id).toBe(\"sess\");\n+\texpect(input.tool_name).toBe(\"Write\");\n+\texpect((input.tool_input as Record<string, unknown>).file_path).toBe(\"/w/p/notes.md\");\n+\texpect(log).toContain(\"handed to abso hook\");\n+\texpect(w.appended).toEqual([context]);\n+});"},{"path":"client/hooks/register.ts","added":45,"removed":5,"diff":"--- a/client/hooks/register.ts\n+++ b/client/hooks/register.ts\n@@ -33,7 +33,7 @@\n \tuncomposedText,\n \ttype Who,\n } from \"../src/core.ts\";\n-import { STAMP } from \"./stamp.ts\";\n+import { HOOK_COMMAND, STAMP } from \"./stamp.ts\";\n \n const TOOLS = [\"Edit\", \"MultiEdit\", \"Write\", \"NotebookEdit\"];\n /** A known copy holding a NUL byte reads as no known copy (the client treats it as binary). */\n@@ -184,19 +184,22 @@\n \n /** A local project's folder (abso init --local): its config names no server. */\n const LOCAL_FOLDER = /\"server\"\\s*:\\s*\"local\"/;\n+/** How long abso hook may take on a local project's edit: it waits up to two minutes for the store's lock. */\n+const LOCAL_HOOK_MS = 150_000;\n \n async function run($: Engine, job: Job): Promise<void> {\n \tconst started = await $.clock.now().catch(() => job.queuedAt);\n \tlet outcome: string;\n \tlet news: readonly string[] = [];\n+\t/** What abso hook handed back for the agent, on a local project's edit (it keeps the news log itself). */\n+\tlet handed: string | undefined;\n \ttry {\n \t\tif ((await readOr($, `${await stateOf($, job.root)}/paused`)) !== undefined) {\n \t\t\toutcome = \"skipped: recording is paused (abso resume)\";\n \t\t} else if (/\"reader\"\\s*:\\s*true/.test((await readOr($, `${await stateOf($, job.root)}/config.json`)) ?? \"\")) {\n \t\t\toutcome = \"skipped: this folder is a reader\";\n \t\t} else if (LOCAL_FOLDER.test((await readOr($, `${await stateOf($, job.root)}/config.json`)) ?? \"\")) {\n-\t\t\t// A local project's history is in a store on this machine, which only the abso command opens.\n-\t\t\toutcome = \"skipped: a local project; abso record sends its edits\";\n+\t\t\t({ outcome, context: handed } = await handToClient($, job));\n \t\t} else if (await ignored($, job.root, job.rel)) {\n \t\t\toutcome = \"skipped: ignored path\";\n \t\t} else if (await isLink($, job.root, job.rel)) {\n@@ -217,11 +220,11 @@\n \t\tjob.root,\n \t\t`${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}`,\n \t);\n-\tconst context = newsContext(news);\n+\tconst context = handed ?? newsContext(news);\n \tif (context === undefined) return;\n \t// For anything that shows news later (the avcs-view mod reads it).\n \tconst at = new Date(done).toISOString();\n-\tawait log($, job.root, news.map((n) => `${at}\\t${n}`).join(\"\\n\"), \"news.log\");\n+\tif (news.length > 0) await log($, job.root, news.map((n) => `${at}\\t${n}`).join(\"\\n\"), \"news.log\");\n \ttry {\n \t\tawait $.session.append({\n \t\t\tmessage: { type: \"user\", content: [{ type: \"text\", text: context }] },\n@@ -234,6 +237,43 @@\n \t}\n }\n \n+/**\n+ * A local project's history is in a store on this machine that only the abso command opens, so its edits go to\n+ * `abso hook` from the checkout this mod was installed from, as Claude Code's command hook would run it.\n+ */\n+async function handToClient($: Engine, job: Job): Promise<{ outcome: string; context?: string }> {\n+\tif (HOOK_COMMAND === undefined || HOOK_COMMAND.length === 0)\n+\t\treturn {\n+\t\t\toutcome:\n+\t\t\t\t\"skipped: a local project, and this mod has no abso to hand it to (install-mod.ts adds one); abso record sends it\",\n+\t\t};\n+\tconst hookInput = {\n+\t\tsession_id: await $.session.id(),\n+\t\tcwd: slash(await $.session.cwd()),\n+\t\ttool_name: job.tool,\n+\t\ttool_input: job.input,\n+\t\t...(job.agentId ? { agent_id: job.agentId } : {}),\n+\t};\n+\tconst ran = await $.process.run(HOOK_COMMAND, {\n+\t\tcwd: job.root,\n+\t\tenv: { ABSO_HOOK_FORCE: \"1\" },\n+\t\tstdin: JSON.stringify(hookInput),\n+\t\ttimeoutMs: LOCAL_HOOK_MS,\n+\t});\n+\tif (ran.exitCode !== 0) throw new Error(`abso hook exited ${ran.exitCode}: ${ran.stderr.trim().split(\"\\n\").at(-1)}`);\n+\t// It prints Claude Code's JSON when it has news for the agent, and nothing otherwise.\n+\tconst out = ran.stdout.trim();\n+\tconst context =\n+\t\tout === \"\"\n+\t\t\t? undefined\n+\t\t\t: (JSON.parse(out) as { hookSpecificOutput?: { additionalContext?: unknown } }).hookSpecificOutput\n+\t\t\t\t\t?.additionalContext;\n+\treturn {\n+\t\toutcome: \"handed to abso hook (a local project; its own line is just above)\",\n+\t\t...(typeof context === \"string\" ? { context } : {}),\n+\t};\n+}\n+\n /** Ask for the news waiting for this agent (announcements, collisions) and hand it to the model. */\n async function pollNews($: Engine, root: string): Promise<void> {\n \ttry {"},{"path":"client/hooks/stamp.ts","added":6,"removed":0,"diff":"--- a/client/hooks/stamp.ts\n+++ b/client/hooks/stamp.ts\n@@ -3,3 +3,9 @@\n // this file with the version it installs: plugin.json's, plus the commit\n // (0.1.0+702c616). Loaded straight from a checkout, it stays undefined.\n export const STAMP: string | undefined = undefined;\n+\n+// The command that runs `abso hook` from the checkout the mod was installed\n+// from, as [node, client/abso.ts, \"hook\"]; the installer writes it too. A\n+// local project's history is in a store on this machine that only the abso\n+// command opens, so the mod hands those edits to it.\n+export const HOOK_COMMAND: readonly string[] | undefined = undefined;"},{"path":"client/src/install.ts","added":20,"removed":4,"diff":"--- a/client/src/install.ts\n+++ b/client/src/install.ts\n@@ -94,6 +94,8 @@\n \t/** For tests: the rename that moves each file into place. */\n \treadonly rename?: (from: string, to: string) => void;\n \treadonly now?: Date;\n+\t/** For tests: the command stamped as HOOK_COMMAND, instead of this client's own `abso hook`. */\n+\treadonly hookCommand?: readonly string[];\n }\n \n const RECORD = \".avcs-install.json\";\n@@ -132,6 +134,15 @@\n \texistsSync(at(skillsFolder(AVCS_MOD.name, env), MANIFEST)) ||\n \texistsSync(at(skillsFolder(OLD_MOD_NAMES[AVCS_MOD.name]!, env), MANIFEST));\n \n+/** Whether the installed abso mod hands a local project's edits to abso hook: it was installed with a HOOK_COMMAND. */\n+export function modHandsLocal(env: Readonly<Record<string, string | undefined>> = process.env): boolean {\n+\ttry {\n+\t\treturn /HOOK_COMMAND[^=\\n]*=\\s*\\[/.test(readFileSync(at(skillsFolder(AVCS_MOD.name, env), STAMP_FILE), \"utf8\"));\n+\t} catch {\n+\t\treturn false;\n+\t}\n+}\n+\n /**\n  * After the new mod is in, the folder it replaces (skills/avcs, skills/avcs-view) would load beside it, so it\n  * is moved, not deleted, to ~/.abso/retired-mods/<name>-<stamp>. Returns where it went, or undefined when there was none.\n@@ -226,8 +237,11 @@\n \treturn commit;\n }\n \n-/** The files to install, stamped with `version`, in install order. */\n-function filesFor(spec: ModSpec, version: string): Map<string, Buffer> {\n+/** The command that runs this checkout's `abso hook`: what the mod hands a local project's edits to. */\n+export const hookCommand = (): readonly string[] => [process.execPath, join(CLIENT_DIR, \"abso.ts\"), \"hook\"];\n+\n+/** The files to install, stamped with `version` (and HOOK_COMMAND, where a stamp.ts has it), in install order. */\n+function filesFor(spec: ModSpec, version: string, hook: readonly string[] = hookCommand()): Map<string, Buffer> {\n \tif (!/^[\\w.+-]+$/.test(version)) throw new Error(`can't stamp the version ${JSON.stringify(version)}`);\n \tconst out = new Map<string, Buffer>();\n \tfor (const rel of spec.files) {\n@@ -239,7 +253,9 @@\n \t\t\tconst text = data.toString(\"utf8\");\n \t\t\tconst stamped = text.replace(/(STAMP[^=\\n]*=\\s*)undefined/, `$1'${version}'`);\n \t\t\tif (stamped === text) throw new Error(`${rel} has no \"STAMP ... = undefined\" line to stamp`);\n-\t\t\tdata = Buffer.from(stamped);\n+\t\t\tdata = Buffer.from(\n+\t\t\t\tstamped.replace(/(HOOK_COMMAND[^=\\n]*=\\s*)undefined/, (_, head: string) => head + JSON.stringify(hook)),\n+\t\t\t);\n \t\t}\n \t\tout.set(rel, data);\n \t}\n@@ -386,7 +402,7 @@\n export function installMod(spec: ModSpec, options: InstallOptions): Installed {\n \tconst target = resolve(options.target);\n \tconst version = versionFor(spec, options.commit);\n-\tconst next = filesFor(spec, version);\n+\tconst next = filesFor(spec, version, options.hookCommand);\n \tconst existed = existsSync(target);\n \tmkdirSync(target, { recursive: true });\n \ttry {"},{"path":"client/src/join-commands.ts","added":9,"removed":3,"diff":"--- a/client/src/join-commands.ts\n+++ b/client/src/join-commands.ts\n@@ -32,7 +32,7 @@\n import { elsewhereText } from \"./doctor.ts\";\n import { fromEnv } from \"./env-names.ts\";\n import { clearKnown, loadIgnore, readFolder, writeKnown } from \"./folder.ts\";\n-import { installerCommand, modInstalled } from \"./install.ts\";\n+import { installerCommand, modHandsLocal, modInstalled } from \"./install.ts\";\n import { LOCAL, NO_STORE, storeDir } from \"./local-store.ts\";\n import { type FullMode, foldModes, writeKnownModes } from \"./modes.ts\";\n import { initInOrg, siteOf } from \"./orgs.ts\";\n@@ -538,8 +538,14 @@\n }\n \n function hookHint(env: Readonly<Record<string, string | undefined>>, local = false): string {\n-\t// The mod sends each edit to the folder's server itself, and a local project has none.\n-\tif (local) return \"abso record sends the edits made here: the abso mod doesn't record local projects yet.\";\n+\t// A local project has no server: the mod hands its edits to abso hook, when it was installed with one to hand them to.\n+\tif (local) {\n+\t\tif (modHandsLocal(env))\n+\t\t\treturn \"Edits made by Claude Code here are recorded by the abso mod on this machine, through abso hook. Anything else: abso record.\";\n+\t\tif (modInstalled(env) && !builtCopy())\n+\t\t\treturn `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.`;\n+\t\treturn \"abso record sends the edits made here, whoever made them.\";\n+\t}\n \tif (modInstalled(env))\n \t\treturn \"Edits made by Claude Code here are recorded by the abso mod on this machine, signed in as this folder. Anything else: abso record.\";\n \t// A built copy (the npm package) has no installer to point at (abso-core 18)."},{"path":"client/test/install.test.ts","added":23,"removed":0,"diff":"--- a/client/test/install.test.ts\n+++ b/client/test/install.test.ts\n@@ -26,6 +26,7 @@\n import { clientVersion, headCommit } from \"../src/client-version.ts\";\n import {\n \tAVCS_MOD,\n+\thookCommand,\n \tinstallerCommand,\n \tinstallMod,\n \tkeptModCommit,\n@@ -114,6 +115,28 @@\n \t\t);\n \t});\n \n+\tit(\"stamps the command that runs this client's abso hook, where stamp.ts has a HOOK_COMMAND line\", () => {\n+\t\tconst spec = source({\n+\t\t\t\"hooks/stamp.ts\":\n+\t\t\t\t\"export const STAMP: string | undefined = undefined\\nexport const HOOK_COMMAND: readonly string[] | undefined = undefined\\n\",\n+\t\t});\n+\t\tconst target = join(temp(), \"avcs\");\n+\t\tinstallMod(spec, {\n+\t\t\ttarget,\n+\t\t\tcheck: pass,\n+\t\t\tcommit: \"702c616\",\n+\t\t\thookCommand: [\"C:\\\\node.exe\", \"C:\\\\abso\\\\client\\\\abso.ts\", \"hook\"],\n+\t\t});\n+\t\tassert.equal(\n+\t\t\tread(target, \"hooks/stamp.ts\"),\n+\t\t\t\"export const STAMP: string | undefined = '0.1.0+702c616'\\n\" +\n+\t\t\t\t'export const HOOK_COMMAND: readonly string[] | undefined = [\"C:\\\\\\\\node.exe\",\"C:\\\\\\\\abso\\\\\\\\client\\\\\\\\abso.ts\",\"hook\"]\\n',\n+\t\t);\n+\t\t// By default, this checkout's own: the node running it and client/abso.ts.\n+\t\tassert.deepEqual(hookCommand().slice(0, 1), [process.execPath]);\n+\t\tassert.match(hookCommand()[1]!, /client[\\\\/]abso\\.ts$/);\n+\t});\n+\n \tit(\"moves the files in by rename, what the hook imports first and plugin.json last\", () => {\n \t\tconst spec = source();\n \t\tconst target = join(temp(), \"avcs\");"}],"ci":null}