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

Compare

+54 −0 in 1 place
new file, 54 lines
1+// Text the engine keeps and prints can't hold characters a reader can't see:
2+// a version message with an escape sequence would run in
3+// every terminal that shows `abso log` or news.
4+
5+import assert from "node:assert/strict";
6+import { test } from "node:test";
7+import { answer } from "../http.ts";
8+import type { ProjectCalls } from "../project-api.ts";
9+import { unseenIn } from "../unseen.ts";
11+const ESC = String.fromCharCode(0x1b);
12+const BEL = String.fromCharCode(0x07);
13+const CSI = String.fromCharCode(0x9b);
14+const RLO = String.fromCharCode(0x202e);
15+const CR = String.fromCharCode(0x0d);
17+test("unseenIn: ESC, C1, BEL and bidi overrides are found; newline, tab and CRLF pass", () => {
18+ assert.equal(unseenIn(`Fix the parser\n\nDetails\twith a tab${CR}\nand CRLF.`), null);
19+ assert.equal(unseenIn(`ok ${ESC}]52;c;aGk=${BEL}`), "a control character at character 4");
20+ assert.equal(unseenIn(`${CSI}31m`), "a control character at character 1");
21+ assert.equal(unseenIn(`a${CR}b`), "a control character at character 2");
22+ assert.match(unseenIn(`abc${RLO}def`)!, /bidirectional embedding or override/);
23+ assert.equal(unseenIn(`emoji 🎉 counts as one character ${ESC}`), "a control character at character 33");
24+ assert.equal(unseenIn(`😀😀😀\nB${CR}X`), "a control character at character 6", "a lone CR after emoji is found");
25+ assert.equal(unseenIn(`😀😀😀${CR}\nB`), null, "CRLF after emoji passes");
26+});
28+test("push, amend, land, starting notes and announcements refuse unseen characters before the engine sees them", () => {
29+ // A stand-in for the engine: it records each call that gets through.
30+ const calls: string[] = [];
31+ const project = new Proxy({} as ProjectCalls, {
32+ get:
33+ (_, name) =>
34+ (...args: unknown[]) => {
35+ if (name === "exists") return true;
36+ calls.push(`${String(name)} ${JSON.stringify(args[1])}`);
37+ return { ok: true };
38+ },
39+ });
40+ const osc8 = `Fix ${ESC}]8;;https://example.invalid${BEL}here${ESC}]8;;${BEL}`;
41+ const refused = answer(project, "publish", "ann", { message: osc8 });
42+ assert.equal(refused.status, 400);
43+ assert.match(JSON.stringify(refused.body), /the message holds a control character at character 5/);
44+ assert.equal(answer(project, "amend", "ann", { message: `Two ${ESC}[2J` }).status, 400);
45+ assert.equal(answer(project, "land", "ann", { message: `Land ${CSI}1m` }).status, 400);
46+ assert.equal(answer(project, "starting", "ann", { text: `on ${RLO}this` }).status, 400);
47+ assert.equal(answer(project, "announce", "ann", { text: `hi ${BEL}` }).status, 400);
48+ assert.deepEqual(calls, [], "none reached the engine");
50+ const windows = `Two${CR}\n${CR}\nWritten on Windows.`;
51+ assert.equal(answer(project, "publish", "ann", { message: windows }).status, 200);
52+ assert.equal(answer(project, "starting", "ann", { text: "on the parser" }).status, 200);
53+ assert.deepEqual(calls, [`publish ${JSON.stringify(windows)}`, 'starting "on the parser"']);
54+});
MCP
compare on this site's /mcp
CLI
abso diff 2 318 worker/project/test/unseen.test.ts --json
JSON
/christopher/abso-core/compare/2..318?file=worker%2Fproject%2Ftest%2Funseen.test.ts&format=json