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

Compare

+79 −22 in 9 places
Lines 13–19 at 318 (were 13–19 at 97)
1313import { join } from "node:path";
1414import { after, before, describe, it } from "node:test";
1515import { readConfig, readMachineServers } from "../src/config.ts";
16−import { issuesServerFor, tokenGoesTo } from "../src/core.ts";
16+import { issuesServerFor, tokenGoesTo, tokenGoesToIssues } from "../src/core.ts";
1717import { issuePage, searchLines } from "../src/issues.ts";
1818import type { IssuePage } from "../src/issues-wire.ts";
1919import { main } from "../src/main.ts";
Lines 35–41 at 318 (were 35–41 at 97)
3535const threaded = {
3636 id: 7,
3737 issue: 3,
38− title: "Sync is slow",
38+ title: "Pull is slow",
3939 by: "desk",
4040 of: "fay",
4141 kind: "question",
Lines 78–84 at 318 (were 78–84 at 97)
7878 dryRun: true,
7979 plan: {
8080 from: { project: body.from, issue: body.issue },
81− title: "Sync is slow",
81+ title: "Pull is slow",
8282 edited: ["description"],
8383 labels: ["client"],
8484 closed: { how: "done" },
Lines 131–139 at 318 (were 131–136 at 97)
131131 });
132132 send(500, { error: "a stand-in" });
133133 });
134+ // As fake-server.ts: never close an idle kept-alive connection, or under load the client can reuse one as it closes
135+ // and fail with ECONNRESET (abso 410).
136+ issues.keepAliveTimeout = 0;
134137 await new Promise<void>((ok) => issues.listen(0, "127.0.0.1", ok));
135138 issuesUrl = `http://127.0.0.1:${(issues.address() as AddressInfo).port}`;
136139});
Lines 176–217 at 318 (were 173–188 at 97)
173176 assert.equal(r.exit, 1, r.out);
174177 assert.match(r.out, /sends your token only to its own servers and this machine/);
175178 assert.equal(seen.length, before);
176− // A server with no Issues Worker beside it, and none named.
177− const { AVCS_ISSUES_SERVER: _, ...without } = ENV();
178− const none = await avcs(dave, ["waiting"], without);
179− assert.notEqual(none.exit, 0);
180− assert.match(
181− none.out,
182− /has no Issues Worker beside it that abso knows; ~\/\.abso\/servers\.json or ABSO_ISSUES_SERVER names one/,
183− );
184179 });
185180
181+ it("with no Issues Worker named, uses the server's own /issues, as the open server keeps them", () => {
182+ assert.equal(issuesServerFor("https://abso.example"), "https://abso.example/issues");
183+ assert.equal(issuesServerFor("https://Abso.Example/"), "https://abso.example/issues");
184+ assert.equal(issuesServerFor("http://localhost:8787"), "http://localhost:8787/issues");
185+ assert.equal(issuesServerFor("not a server"), undefined);
186+ // abso's hosted server keeps its own Issues Worker, and servers.json still comes first.
187+ assert.equal(issuesServerFor("https://api.abso.dev"), "https://issues.abso.dev");
188+ const machine = {
189+ trusted: [],
190+ issues: { "https://staging.abso.example": "https://issues-staging.abso.example" },
191+ };
192+ assert.equal(issuesServerFor("https://staging.abso.example", machine), "https://issues-staging.abso.example");
193+ // The token goes to <server>/issues exactly where it goes to <server>.
194+ assert.ok(tokenGoesToIssues("https://api.abso.dev/issues"));
195+ assert.ok(tokenGoesToIssues("http://localhost:8787/issues"));
196+ assert.ok(tokenGoesToIssues("https://mine.example/issues", "https://mine.example"));
197+ assert.equal(tokenGoesToIssues("https://evil.example/issues"), false);
198+ assert.equal(tokenGoesToIssues("https://api.abso.dev@evil.example/issues"), false);
199+ assert.equal(tokenGoesToIssues("https://api.abso.dev/issues?x=1"), false);
200+ assert.equal(tokenGoesToIssues("http://mine.example/issues", "http://mine.example"), false, "plain http only here");
201+ // The server itself still takes no path.
202+ assert.equal(tokenGoesTo("https://api.abso.dev/issues"), false);
203+ });
205+ it("calls <issues server>/p/<project>/... when the Issues Worker is at a path", async () => {
206+ const fay = await folder("fay");
207+ const before = seen.length;
208+ const env = { ...ENV(), AVCS_ISSUES_SERVER: `${issuesUrl}/issues` };
209+ const r = await main(["ask", "7"], { cwd: fay, env, write: () => {} });
210+ assert.equal(r.exit, 0, r.stdout + r.stderr);
211+ const { project } = readConfig(fay);
212+ assert.deepEqual(seen.slice(before), [`GET /issues/p/${project}/ask/7`]);
213+ });
186215 it("finds a server's Issues Worker in this machine's servers.json, and may send it the token", async () => {
187216 const dir = mkdtempSync(join(tmpdir(), "abso-servers-"));
188217 dirs.push(dir);
Lines 224–230 at 318 (were 195–201 at 97)
195224 assert.ok(seen.length > before, "the call went to the Issues Worker servers.json names");
196225 const machine = readMachineServers({ AVCS_SERVERS_FILE: file });
197226 assert.equal(issuesServerFor(fake.url, machine), issuesUrl);
198− assert.equal(issuesServerFor("https://abso.example", machine), undefined);
227+ assert.equal(issuesServerFor("https://abso.example", machine), "https://abso.example/issues");
199228 // abso's own server and its Issues Worker are built in.
200229 assert.ok(tokenGoesTo("https://api.abso.dev"));
201230 assert.ok(tokenGoesTo("https://issues.abso.dev"));
Lines 272–315 at 318 (were 243–258 at 97)
243272 });
244273
245274 it("shows a search hit as the issue, then where it matched, without the match markers", () => {
246− const issue = { id: 12, title: "Sync is slow", status: "open" as const, updated: 0, labels: [] };
275+ const unknownAuthorship = {
276+ kind: "unknown" as const,
277+ actor: null,
278+ provenance: "unknown" as const,
279+ authorField: null,
280+ };
281+ const issue = {
282+ id: 12,
283+ title: "Pull is slow",
284+ status: "open" as const,
285+ updated: 0,
286+ labels: [],
287+ authorship: { title: unknownAuthorship },
288+ };
247289 assert.deepEqual(
248− searchLines({ issue, where: "comment", comment: 40, snippet: "the \u0001network\u0002 drops mid-sync" }),
249− [' 12 open "Sync is slow"', ' in comment 40: "the network drops mid-sync"'],
290+ searchLines({
291+ issue,
292+ where: "comment",
293+ comment: 40,
294+ snippet: "the \u0001network\u0002 drops mid-sync",
295+ matchedAuthorship: unknownAuthorship,
296+ }),
297+ [' 12 open "Pull is slow"', ' in comment 40: "the network drops mid-sync"'],
250298 );
251− assert.deepEqual(searchLines({ issue, where: "description", snippet: "Pages load late.", meaning: true }), [
252− ' 12 open "Sync is slow"',
253− ' by meaning: "Pages load late."',
254− ]);
255− assert.deepEqual(searchLines({ issue, where: "title", snippet: "Sync is slow" })[1], " in the title");
299+ assert.deepEqual(
300+ searchLines({
301+ issue,
302+ where: "description",
303+ snippet: "Pages load late.",
304+ meaning: true,
305+ matchedAuthorship: unknownAuthorship,
306+ }),
307+ [' 12 open "Pull is slow"', ' by meaning: "Pages load late."'],
308+ );
309+ assert.deepEqual(
310+ searchLines({ issue, where: "title", snippet: "Pull is slow", matchedAuthorship: unknownAuthorship })[1],
311+ " in the title",
312+ );
256313 });
257314
258315 it("withdraw is one POST to the asker's own withdraw/<ask> route", async () => {
Lines 370–376 at 318 (were 313–319 at 97)
313370 assert.match(seen.slice(before).join("\n"), /^GET \/p\/issues\d+\/ask\/7$/m);
314371 assert.match(
315372 r.stdout,
316− /^ {2}ask 7: desk, .* asks fay a question on issue 3 \("Sync is slow"\) \(2 replies; waiting on desk\): "Which way\?"$/m,
373+ /^ {2}ask 7: desk, .* asks fay a question on issue 3 \("Pull is slow"\) \(2 replies; waiting on desk\): "Which way\?"$/m,
317374 );
318375 const ack = r.stdout.indexOf(' fay, Jan 1 1970 00:00 UTC: "ok, let me check"');
319376 const back = r.stdout.indexOf(' fay, Jan 1 1970 00:00 UTC, a question: "staging or live?\\nlive is 906"');
Lines 471–477 at 318 (were 414–420 at 97)
414471 r.out.trimEnd(),
415472 [
416473 `A dry run: nothing was written. Copying ${from} issue 12 into core would make:`,
417− ` "Sync is slow", done (description edited when copied)`,
474+ ` "Pull is slow", done (description edited when copied)`,
418475 " 2 comments (1 edited), 1 answered ask, labelled client",
419476 " not copied: comments 4; asks 2 (open asks, and what --clean left out)",
420477 "Run it again without --dry-run to copy it.",
MCP
compare on this site's /mcp
CLI
abso diff 97 318 client/test/issues.test.ts --json
JSON
/christopher/abso-core/compare/97..318?file=client%2Ftest%2Fissues.test.ts&format=json