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

Compare

+61 −0 in 1 place
new file, 61 lines
1+// Builds client/bin/abso.mjs: the whole client, client/abso.ts and everything it imports (yaml included),
2+// as one plain-JS file for Node 20 or later. Node 20 can't run the .ts files themselves (it has no type
3+// stripping), so this file is how a checkout runs on it:
4+//
5+// npm ci && npm run build
6+// node client/bin/abso.mjs help
7+//
8+// The file isn't committed (.gitignore leaves client/bin/ out); build it again after pulling. It sits one
9+// folder under client/, so the client's own folder (client-version.ts) is still client/. scripts/pack-npm.mjs
10+// puts the same build in the npm package.
11+//
12+// Plain JS on purpose: it runs before anything is built.
13+import { mkdirSync, writeFileSync } from "node:fs";
14+import { createRequire } from "node:module";
15+import { dirname, join, resolve } from "node:path";
16+import { fileURLToPath } from "node:url";
18+const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
19+const OUT = "client/bin/abso.mjs";
21+/** The bundle's text, built in memory. `banner` adds lines at its top (the npm package stamps its version). */
22+export function buildClient(banner = []) {
23+ const esbuild = createRequire(import.meta.url)("esbuild");
24+ const result = esbuild.buildSync({
25+ absWorkingDir: root,
26+ entryPoints: ["client/abso.ts"],
27+ bundle: true,
28+ platform: "node",
29+ format: "esm",
30+ target: "node20",
31+ write: false,
32+ outfile: OUT,
33+ logLevel: "warning",
34+ // Local projects run the open server's code in the client (client/src/local-store.ts); its Durable Object
35+ // base class comes from the Workers runtime, so the bundle gets the client's stand-in.
36+ alias: { "cloudflare:workers": "./client/src/durable-object-stand-in.ts" },
37+ // A bundled CommonJS package (yaml) calls require("process") lazily, which an ES module bundle
38+ // can't do without a real require.
39+ banner: {
40+ js: [
41+ "// Built from client/abso.ts by scripts/build-client.mjs (npm run build). Don't edit it by hand.",
42+ 'import { createRequire as __absoCreateRequire } from "node:module";',
43+ "const require = __absoCreateRequire(import.meta.url);",
44+ ...banner,
45+ ].join("\n"),
46+ },
47+ });
48+ // esbuild leaves control characters in string literals as they are (yaml's lexer has \x02, \x18 and \x1f).
49+ // Escaped, the file is plain text that every tool shows and stores as it is.
50+ return result.outputFiles[0].text.replace(
51+ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g,
52+ (c) => `\\x${c.charCodeAt(0).toString(16).padStart(2, "0")}`,
53+ );
54+}
56+if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
57+ const path = join(root, OUT);
58+ mkdirSync(dirname(path), { recursive: true });
59+ writeFileSync(path, buildClient());
60+ process.stdout.write(`Built ${OUT}: node ${OUT} help\n`);
61+}
MCP
compare on this site's /mcp
CLI
abso diff 110 318 scripts/build-client.mjs --json
JSON
/christopher/abso-core/compare/110..318?file=scripts%2Fbuild-client.mjs&format=json