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 271 to 318

Compare

+61 −9 in 7 places
Lines 3–12 at 318 (were 3–11 at 271)
33
44import type { On } from "claude-code";
55import { expect, mock, test } from "claude-code/testing";
6+import { HOOK_COMMAND } from "./stamp.ts";
67
78/** 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") {
910 mock.env(on, { AVCS_TOKEN: "test-token" });
1011 const clock = mock.clock(on, { now: 1_000_000 });
1112 const asked: string[] = [];
Lines 22–28 at 318 (were 21–27 at 271)
2122 on("fs.read", (_$, e) => {
2223 const path = norm(e.path);
2324 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" }) };
2526 if (written.has(path)) return { value: written.get(path)! };
2627 return { deny: `ENOENT: ${path}` };
2728 });
Lines 41–57 at 318 (were 40–54 at 271)
4041 appended.push((e.message.content as { text: string }[])[0]!.text);
4142 return next(e);
4243 });
44+ // Tools the chat calls run as asked.
45+ on("tool.call", () => ({ result: { isError: false, text: "ok" } }) as never);
4346 return { clock, asked, auth, clients, appended, written };
4447}
4548
46−test("the news poll asks every 30 seconds in an abso folder, and keeps each item once", async ($, on) => {
49+test("the news poll asks every 5 minutes in an abso folder, and keeps each item once", async ($, on) => {
4750 // The kit has no conversation to append to, so the append itself is checked in a live session (#25);
4851 // here: the poll's timing, the call, and the news log the view mod reads.
4952 const w = world(on, true, [["Announcement from lead: stop pushing until v12 lands"], []]);
5053 await $.session.start({ cwd: "/w/p" });
51− await w.clock.advance(29_000);
54+ await w.clock.advance(299_000);
5255 expect(w.asked).toEqual([]);
5356 await w.clock.advance(1_000);
5457 expect(w.asked).toEqual(["https://avcs.test/p/p/a/bob/news"]);
Lines 59–66 at 318 (were 56–62 at 271)
5659 expect(w.auth[0]).toBe("none");
5760 // Which mod asked: avcs-mod/<version> once installed, avcs-mod/checkout from a checkout (#29).
5861 expect(w.clients[0]).toMatch(/^avcs-mod\/(checkout|\d+\.\d+\.\d+(\+[\w.]+)?)$/);
59− await w.clock.advance(30_000);
62+ await $.tool.call({ tool: "Bash", command: "ls" } as never);
63+ await w.clock.advance(300_000);
6064 expect(w.asked).toHaveLength(2);
6165 const log = w.written.get("/w/p/.abso/news.log") ?? "";
6266 expect(log.split("\n").filter((l) => l.includes("Announcement from lead"))).toHaveLength(1);
Lines 68–95 at 318 (were 64–77 at 271)
6468
6569test("while the seat holds its news stream (abso 690), the poll stands down, and asks again once the mark runs out", async ($, on) => {
6670 const w = world(on, true, [[], []]);
67− w.written.set("/w/p/.abso/news-stream.json", JSON.stringify({ until: 1_000_000 + 95_000 }));
71+ w.written.set("/w/p/.abso/news-stream.json", JSON.stringify({ until: 1_000_000 + 400_000 }));
6872 await $.session.start({ cwd: "/w/p" });
69− await w.clock.advance(90_000);
73+ await w.clock.advance(300_000);
7074 expect(w.asked).toEqual([]);
71− await w.clock.advance(30_000);
75+ await $.tool.call({ tool: "Bash", command: "ls" } as never);
76+ await w.clock.advance(300_000);
7277 expect(w.asked).toEqual(["https://avcs.test/p/p/a/bob/news"]);
7378});
7479
80+test("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);
91+});
7593test("outside an abso folder it never asks", async ($, on) => {
7694 const w = world(on, false, [["should not arrive"]]);
7795 await $.session.start({ cwd: "/w/p" });
Lines 103–108 at 318 (were 85–91 at 271)
85103 w.written.set("/w/p/.abso/known/fuzz.ts", "one\ntwo\nthree\n");
86104 w.written.set("/w/p/fuzz.ts", "one\ntwo\nth\u0000ree\n");
87105 on("fs.stat", () => ({ value: { realPath: "/w/p/fuzz.ts" } }) as never);
88− on("tool.call", () => ({ result: { isError: false, text: "ok" } }) as never);
89106 on("session.id", () => ({ value: "sess" }));
90107 await $.session.start({ cwd: "/w/p" });
91108 await $.tool.call({
Lines 115–152 at 318 (were 98–100 at 271)
98115 expect(w.written.get("/w/p/.abso/hook.log") ?? "").toContain("not sent: a NUL byte at line 3");
99116 expect(w.asked.filter((u) => !u.endsWith("/news"))).toEqual([]);
100117});
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;
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]);
152+});
MCP
compare on this site's /mcp
CLI
abso diff 271 318 client/hooks/register.test.ts --json
JSON
/christopher/abso-core/compare/271..318?file=client%2Fhooks%2Fregister.test.ts&format=json