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
MCP
code on this site's /mcp
CLI
none: the JSON below is the answer
JSON
/christopher/abso-core/files/server/src/issues/seats.ts?format=json
49 linestrials 100%Last change trials in version 151, 1 version changed it
1// Asks go to seats: an ask to a name that isn't an agent in the project would
2// wait on nobody, so it's refused, with the closest seat named. Seats are only
3// ever this project's own.
4
5/** A name as people write it: lower case, letters and digits only ("abso - Cloud Infra Lead" → "absocloudinfralead"). */
6function plain(name: string): string {
7 return name.toLowerCase().replace(/[^a-z0-9]/g, "");
8}
9
10/** Edits from a to b: insertions, deletions and substitutions. */
11function distance(a: string, b: string): number {
12 let row = Array.from({ length: b.length + 1 }, (_, i) => i);
13 for (let i = 1; i <= a.length; i++) {
14 const next = [i];
15 for (let j = 1; j <= b.length; j++)
16 next[j] = Math.min(row[j]! + 1, next[j - 1]! + 1, row[j - 1]! + (a[i - 1] === b[j - 1] ? 0 : 1));
17 row = next;
18 }
19 return row[b.length]!;
22/**
23 * The seat a name most likely meant, or null. The same name written another way wins; then the longest seat
24 * the name holds ("abso - Cloud Infra Lead" holds cloud), or that holds the name; then a near spelling.
25 */
26export function closestSeat(name: string, seats: readonly string[]): string | null {
27 const n = plain(name);
28 if (n === "") return null;
29 const same = seats.find((s) => plain(s) === n);
30 if (same) return same;
31 const held = seats
32 .filter((s) => plain(s).length >= 3 && (n.includes(plain(s)) || plain(s).includes(n)))
33 .sort((a, b) => plain(b).length - plain(a).length);
34 if (held[0]) return held[0];
35 let best: string | null = null;
36 let least = Math.max(2, Math.floor(n.length / 3)) + 1;
37 for (const s of seats) {
38 const d = distance(n, plain(s));
39 if (d < least) [best, least] = [s, d];
40 }
41 return best;
44/** Why an ask to `of` is refused, or null when `of` is a seat. */
45export function seatRefusal(of: string, project: string, seats: readonly string[]): string | null {
46 if (seats.includes(of)) return null;
47 const near = closestSeat(of, seats);
48 return `${JSON.stringify(of)} isn't an agent in ${project}, so nobody would hear the ask${near ? `; did you mean ${near}?` : "."} abso status lists the agents.`;