- MCP
- blame on this site's /mcp
- CLI
- abso blame client/hooks/register.test.ts --json
- JSON
- /christopher/abso-core/blame/client/hooks/register.test.ts?format=json
152 linesFirst import 49% · pinch 28% · box-grants 19% · review 3% · rename 1%Last change pinch in version 293,
152 lines from 8 changes in 8 versions.
2// an agent that isn't editing still gets announcements, within 30 seconds.
4import type { On } from "claude-code";
5import { expect, mock, test } from "claude-code/testing";
pinch293Local 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.Compare6import { HOOK_COMMAND } from "./stamp.ts";
8/** The world beneath the mod: a chat in /w/p, an abso folder when `inFolder`, and a server with `news` waiting. */
pinch293Local 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.Compare9function world(on: On, inFolder: boolean, news: string[][], server = "https://avcs.test") {
11 const clock = mock.clock(on, { now: 1_000_000 });
12 const asked: string[] = [];
13 const auth: string[] = [];
14 const clients: string[] = [];
15 const appended: string[] = [];
16 const written = new Map<string, string>();
17 // The engine hands hooks paths resolved for this machine (C:\w\p on Windows).
18 const norm = (p: string) => p.replace(/\\/g, "/").replace(/^[A-Za-z]:/, "");
19 on("session.start", (_$, e) => ({ cwd: (e as { cwd?: string }).cwd ?? "/w/p" }));
20 on("session.cwd", () => ({ value: "/w/p" }));
review17New folders keep their state in .abso/, and the machine's sign-in, servers and admin token are read from ~/.abso/ first, then ~/.avcs/. A folder made before, with only .avcs/, is untouched: it keeps working, is never half-moved, and no older client or mod loses it. stateDir(root) and homeFile/homeWritePath are in the new client/src/state-dir.ts and replace the old AVCS_DIR constant everywhere. abso login writes only to ~/.abso/ and leaves ~/.avcs/ alone; logout removes both copies. The edit mod and the view mod read either folder. .abso is skipped like .avcs (including its odd spellings), the git exclude names whichever folder is in use, and the messages name .abso. Not changed: avcs.json (the server reads that name, so abso.json needs the server to learn it first), .avcsignore, env var names and wire headers. Tests: 709 run, 708 pass (one is skipped), including new ones for the folder choice, the home-file order and box sign-in; biome ci has no errors.Compare21 on("fs.exists", (_$, e) => ({ value: inFolder && norm(e.path) === "/w/p/.abso/config.json" }));
23 const path = norm(e.path);
review17New folders keep their state in .abso/, and the machine's sign-in, servers and admin token are read from ~/.abso/ first, then ~/.avcs/. A folder made before, with only .avcs/, is untouched: it keeps working, is never half-moved, and no older client or mod loses it. stateDir(root) and homeFile/homeWritePath are in the new client/src/state-dir.ts and replace the old AVCS_DIR constant everywhere. abso login writes only to ~/.abso/ and leaves ~/.avcs/ alone; logout removes both copies. The edit mod and the view mod read either folder. .abso is skipped like .avcs (including its odd spellings), the git exclude names whichever folder is in use, and the messages name .abso. Not changed: avcs.json (the server reads that name, so abso.json needs the server to learn it first), .avcsignore, env var names and wire headers. Tests: 709 run, 708 pass (one is skipped), including new ones for the folder choice, the home-file order and box sign-in; biome ci has no errors.Compare24 if (inFolder && path === "/w/p/.abso/config.json")
pinch293Local 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.Compare25 return { value: JSON.stringify({ server, project: "p", agent: "bob" }) };
27 return { deny: `ENOENT: ${path}` };
28 });
29 on("fs.write", (_$, e) => {
30 written.set(norm(e.path), e.text);
31 return { value: undefined };
32 });
33 on("http.fetch", (_$, e) => {
34 asked.push(e.url);
35 auth.push((e.init?.headers as Record<string, string> | undefined)?.authorization ?? "none");
pinch54The client and the edit mods send and read X-Abso-* headers only (Client, Name, Run-Key, Kind, Admin; Run, Box, Prep from answers). Servers have read X-Abso-* beside the old names for a while and answer under both, so this works with any current server.Compare36 clients.push(String((e.init?.headers as Record<string, string> | undefined)?.["x-abso-client"]));
init0Start the project37 return { value: { status: 200, ok: true, headers: {}, text: JSON.stringify({ news: news.shift() ?? [] }) } };
38 });
pinch56The mods' tests run on current Claude Code: a session.append hook passes the row on with next (the engine stores it and refuses an answer made without next), and the view's test answers fs.exists, which the view calls to find a folder's .abso/. Both mods' tests pass in the plugin test kit again, so their installers no longer refuse.Compare39 // The engine stores the row itself: a session.append hook passes it on and answers what next answered.
40 on("session.append", (_$, e, next) => {
pinch56The mods' tests run on current Claude Code: a session.append hook passes the row on with next (the engine stores it and refuses an answer made without next), and the view's test answers fs.exists, which the view calls to find a folder's .abso/. Both mods' tests pass in the plugin test kit again, so their installers no longer refuse.Compare42 return next(e);
box-grants272abso-hooks mod: ask for news every 5 minutes, not 30 seconds, and not at all in a chat with no tool call for 10 minutes (its next tool call starts it again). Prod abso's object reset under the load of every chat asking every 30 seconds (Agent VCS, 5:10 PM CT). abso announce says so. Tests: node client/test-mods.ts.Compare44 // Tools the chat calls run as asked.
init0Start the project45 on("tool.call", () => ({ result: { isError: false, text: "ok" } }) as never);
46 return { clock, asked, auth, clients, appended, written };
47}
box-grants272abso-hooks mod: ask for news every 5 minutes, not 30 seconds, and not at all in a chat with no tool call for 10 minutes (its next tool call starts it again). Prod abso's object reset under the load of every chat asking every 30 seconds (Agent VCS, 5:10 PM CT). abso announce says so. Tests: node client/test-mods.ts.Compare49test("the news poll asks every 5 minutes in an abso folder, and keeps each item once", async ($, on) => {
init0Start the project50 // The kit has no conversation to append to, so the append itself is checked in a live session (#25);
51 // here: the poll's timing, the call, and the news log the view mod reads.
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 const w = world(on, true, [["Announcement from lead: stop pushing until v12 lands"], []]);
box-grants272abso-hooks mod: ask for news every 5 minutes, not 30 seconds, and not at all in a chat with no tool call for 10 minutes (its next tool call starts it again). Prod abso's object reset under the load of every chat asking every 30 seconds (Agent VCS, 5:10 PM CT). abso announce says so. Tests: node client/test-mods.ts.Compare54 await w.clock.advance(299_000);
56 await w.clock.advance(1_000);
57 expect(w.asked).toEqual(["https://avcs.test/p/p/a/bob/news"]);
58 // avcs.test isn't a server the token goes to (#30): the call goes out without it.
59 expect(w.auth[0]).toBe("none");
60 // Which mod asked: avcs-mod/<version> once installed, avcs-mod/checkout from a checkout (#29).
61 expect(w.clients[0]).toMatch(/^avcs-mod\/(checkout|\d+\.\d+\.\d+(\+[\w.]+)?)$/);
box-grants272abso-hooks mod: ask for news every 5 minutes, not 30 seconds, and not at all in a chat with no tool call for 10 minutes (its next tool call starts it again). Prod abso's object reset under the load of every chat asking every 30 seconds (Agent VCS, 5:10 PM CT). abso announce says so. Tests: node client/test-mods.ts.Compare62 await $.tool.call({ tool: "Bash", command: "ls" } as never);
63 await w.clock.advance(300_000);
review17New folders keep their state in .abso/, and the machine's sign-in, servers and admin token are read from ~/.abso/ first, then ~/.avcs/. A folder made before, with only .avcs/, is untouched: it keeps working, is never half-moved, and no older client or mod loses it. stateDir(root) and homeFile/homeWritePath are in the new client/src/state-dir.ts and replace the old AVCS_DIR constant everywhere. abso login writes only to ~/.abso/ and leaves ~/.avcs/ alone; logout removes both copies. The edit mod and the view mod read either folder. .abso is skipped like .avcs (including its odd spellings), the git exclude names whichever folder is in use, and the messages name .abso. Not changed: avcs.json (the server reads that name, so abso.json needs the server to learn it first), .avcsignore, env var names and wire headers. Tests: 709 run, 708 pass (one is skipped), including new ones for the folder choice, the home-file order and box sign-in; biome ci has no errors.Compare65 const log = w.written.get("/w/p/.abso/news.log") ?? "";
init0Start the project66 expect(log.split("\n").filter((l) => l.includes("Announcement from lead"))).toHaveLength(1);
67});
box-grants270abso 690: while a seat holds its news stream, the abso-hooks mod's 30-second news poll stands down. abso news --stream marks the folder (.abso/news-stream.json) for the Monitor's 30 minutes plus the ticket's minute; --follow renews the mark on open and at each 45-second ping. The poll asks again once the mark runs out. Tests: client/test/news-stream.test.ts, client/hooks/register.test.ts (node client/test-mods.ts).Compare69test("while the seat holds its news stream (abso 690), the poll stands down, and asks again once the mark runs out", async ($, on) => {
70 const w = world(on, true, [[], []]);
box-grants272abso-hooks mod: ask for news every 5 minutes, not 30 seconds, and not at all in a chat with no tool call for 10 minutes (its next tool call starts it again). Prod abso's object reset under the load of every chat asking every 30 seconds (Agent VCS, 5:10 PM CT). abso announce says so. Tests: node client/test-mods.ts.Compare71 w.written.set("/w/p/.abso/news-stream.json", JSON.stringify({ until: 1_000_000 + 400_000 }));
box-grants270abso 690: while a seat holds its news stream, the abso-hooks mod's 30-second news poll stands down. abso news --stream marks the folder (.abso/news-stream.json) for the Monitor's 30 minutes plus the ticket's minute; --follow renews the mark on open and at each 45-second ping. The poll asks again once the mark runs out. Tests: client/test/news-stream.test.ts, client/hooks/register.test.ts (node client/test-mods.ts).Compare72 await $.session.start({ cwd: "/w/p" });
box-grants272abso-hooks mod: ask for news every 5 minutes, not 30 seconds, and not at all in a chat with no tool call for 10 minutes (its next tool call starts it again). Prod abso's object reset under the load of every chat asking every 30 seconds (Agent VCS, 5:10 PM CT). abso announce says so. Tests: node client/test-mods.ts.Compare73 await w.clock.advance(300_000);
box-grants270abso 690: while a seat holds its news stream, the abso-hooks mod's 30-second news poll stands down. abso news --stream marks the folder (.abso/news-stream.json) for the Monitor's 30 minutes plus the ticket's minute; --follow renews the mark on open and at each 45-second ping. The poll asks again once the mark runs out. Tests: client/test/news-stream.test.ts, client/hooks/register.test.ts (node client/test-mods.ts).Compare74 expect(w.asked).toEqual([]);
box-grants272abso-hooks mod: ask for news every 5 minutes, not 30 seconds, and not at all in a chat with no tool call for 10 minutes (its next tool call starts it again). Prod abso's object reset under the load of every chat asking every 30 seconds (Agent VCS, 5:10 PM CT). abso announce says so. Tests: node client/test-mods.ts.Compare75 await $.tool.call({ tool: "Bash", command: "ls" } as never);
76 await w.clock.advance(300_000);
box-grants270abso 690: while a seat holds its news stream, the abso-hooks mod's 30-second news poll stands down. abso news --stream marks the folder (.abso/news-stream.json) for the Monitor's 30 minutes plus the ticket's minute; --follow renews the mark on open and at each 45-second ping. The poll asks again once the mark runs out. Tests: client/test/news-stream.test.ts, client/hooks/register.test.ts (node client/test-mods.ts).Compare77 expect(w.asked).toEqual(["https://avcs.test/p/p/a/bob/news"]);
box-grants272abso-hooks mod: ask for news every 5 minutes, not 30 seconds, and not at all in a chat with no tool call for 10 minutes (its next tool call starts it again). Prod abso's object reset under the load of every chat asking every 30 seconds (Agent VCS, 5:10 PM CT). abso announce says so. Tests: node client/test-mods.ts.Compare78});
80test("a chat with no tool call for 10 minutes stops asking for news; its next tool call starts it again", async ($, on) => {
81 const w = world(on, true, [[], [], []]);
82 await $.session.start({ cwd: "/w/p" });
83 await w.clock.advance(300_000);
84 expect(w.asked).toHaveLength(1);
85 // Idle since the start: at 10 and 15 minutes it doesn't ask.
86 await w.clock.advance(600_000);
87 expect(w.asked).toHaveLength(1);
88 await $.tool.call({ tool: "Read", file_path: "/w/p/a.ts" } as never);
89 await w.clock.advance(300_000);
90 expect(w.asked).toHaveLength(2);
box-grants270abso 690: while a seat holds its news stream, the abso-hooks mod's 30-second news poll stands down. abso news --stream marks the folder (.abso/news-stream.json) for the Monitor's 30 minutes plus the ticket's minute; --follow renews the mark on open and at each 45-second ping. The poll asks again once the mark runs out. Tests: client/test/news-stream.test.ts, client/hooks/register.test.ts (node client/test-mods.ts).Compare91});
94 const w = world(on, false, [["should not arrive"]]);
95 await $.session.start({ cwd: "/w/p" });
96 await w.clock.advance(120_000);
97 expect(w.asked).toEqual([]);
98 expect(w.appended).toEqual([]);
99});
101test("an edit that leaves a NUL byte in a text file is not sent, and the log says where", async ($, on) => {
102 const w = world(on, true, []);
review17New folders keep their state in .abso/, and the machine's sign-in, servers and admin token are read from ~/.abso/ first, then ~/.avcs/. A folder made before, with only .avcs/, is untouched: it keeps working, is never half-moved, and no older client or mod loses it. stateDir(root) and homeFile/homeWritePath are in the new client/src/state-dir.ts and replace the old AVCS_DIR constant everywhere. abso login writes only to ~/.abso/ and leaves ~/.avcs/ alone; logout removes both copies. The edit mod and the view mod read either folder. .abso is skipped like .avcs (including its odd spellings), the git exclude names whichever folder is in use, and the messages name .abso. Not changed: avcs.json (the server reads that name, so abso.json needs the server to learn it first), .avcsignore, env var names and wire headers. Tests: 709 run, 708 pass (one is skipped), including new ones for the folder choice, the home-file order and box sign-in; biome ci has no errors.Compare103 w.written.set("/w/p/.abso/known/fuzz.ts", "one\ntwo\nthree\n");
105 on("fs.stat", () => ({ value: { realPath: "/w/p/fuzz.ts" } }) as never);
106 on("session.id", () => ({ value: "sess" }));
107 await $.session.start({ cwd: "/w/p" });
108 await $.tool.call({
109 tool: "Write",
110 tool_use_id: "t1",
111 file_path: "/w/p/fuzz.ts",
112 content: "one\ntwo\nth\u0000ree\n",
113 } as never);
114 await w.clock.advance(1_000);
review17New folders keep their state in .abso/, and the machine's sign-in, servers and admin token are read from ~/.abso/ first, then ~/.avcs/. A folder made before, with only .avcs/, is untouched: it keeps working, is never half-moved, and no older client or mod loses it. stateDir(root) and homeFile/homeWritePath are in the new client/src/state-dir.ts and replace the old AVCS_DIR constant everywhere. abso login writes only to ~/.abso/ and leaves ~/.avcs/ alone; logout removes both copies. The edit mod and the view mod read either folder. .abso is skipped like .avcs (including its odd spellings), the git exclude names whichever folder is in use, and the messages name .abso. Not changed: avcs.json (the server reads that name, so abso.json needs the server to learn it first), .avcsignore, env var names and wire headers. Tests: 709 run, 708 pass (one is skipped), including new ones for the folder choice, the home-file order and box sign-in; biome ci has no errors.Compare115 expect(w.written.get("/w/p/.abso/hook.log") ?? "").toContain("not sent: a NUL byte at line 3");
pinch293Local 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.Compare117});
119test("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;
130 });
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");
141 return;
142 }
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]);