githolon 0.102.4 → 0.103.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/compile.ts
4
+ import { spawn, spawnSync } from "node:child_process";
5
+ import { createRequire } from "node:module";
6
+ import { dirname as dirname2, join as join2 } from "node:path";
7
+ import { pathToFileURL } from "node:url";
8
+
9
+ // src/editor.ts
10
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
11
+ import { dirname, join } from "node:path";
12
+ var NOMOS_LAW_EXTENSION_ID = "captain-app.nomos-law";
13
+ function hasEditorRecommendation(cwd) {
14
+ const p = join(cwd, ".vscode", "extensions.json");
15
+ if (!existsSync(p)) return false;
16
+ try {
17
+ const json = JSON.parse(readFileSync(p, "utf8"));
18
+ return Array.isArray(json.recommendations) && json.recommendations.includes(NOMOS_LAW_EXTENSION_ID);
19
+ } catch {
20
+ return true;
21
+ }
22
+ }
23
+ var INIT_EDITOR_HINT = "tip: the Nomos Law VS Code extension gives you these checks as you type \u2014 npx githolon init-editor";
24
+
25
+ // src/compile.ts
26
+ function resolveCompileLauncher(cwd) {
27
+ const resolveDslPkg = (fromDir) => {
28
+ try {
29
+ const req = fromDir === void 0 ? createRequire(import.meta.url) : createRequire(pathToFileURL(join2(fromDir, "noop.js")));
30
+ return req.resolve("@githolon/dsl/package.json");
31
+ } catch {
32
+ return void 0;
33
+ }
34
+ };
35
+ const dslPkg = resolveDslPkg(cwd) ?? resolveDslPkg(void 0);
36
+ return dslPkg === void 0 ? void 0 : join2(dirname2(dslPkg), "compile_package.mjs");
37
+ }
38
+ var NO_DSL_REMEDY = "@githolon/dsl not found \u2014 add it to your project's dependencies";
39
+ function runCompile(args) {
40
+ const launcher = resolveCompileLauncher(process.cwd());
41
+ if (launcher === void 0) {
42
+ process.stderr.write(`error: ${NO_DSL_REMEDY}
43
+ `);
44
+ return 1;
45
+ }
46
+ const r = spawnSync(process.execPath, [launcher, ...args], { stdio: "inherit", cwd: process.cwd() });
47
+ const status = r.status ?? 1;
48
+ if (status === 0 && process.stdout.isTTY) {
49
+ try {
50
+ if (!hasEditorRecommendation(process.cwd())) process.stdout.write(`
51
+ ${INIT_EDITOR_HINT}
52
+ `);
53
+ } catch {
54
+ }
55
+ }
56
+ return status;
57
+ }
58
+
59
+ // src/compile_command.ts
60
+ async function runCompileCommand(args) {
61
+ const skipMountCheck = args.includes("--no-mount-check");
62
+ const preflightOnly = args.includes("--preflight");
63
+ const status = runCompile(args.filter((arg) => arg !== "--no-mount-check"));
64
+ if (status !== 0 || skipMountCheck || preflightOnly) return status;
65
+ try {
66
+ const { assertPublicCompileMountable } = await import("./compile_mountability_entry.js");
67
+ const verdict = await assertPublicCompileMountable(process.cwd());
68
+ if (verdict.skipped !== void 0) process.stderr.write(`note: ${verdict.skipped}
69
+ `);
70
+ else if (!verdict.ok) {
71
+ process.stderr.write(
72
+ `
73
+ \u2717 compile emitted an UNMOUNTABLE package \u2014 ${verdict.error}
74
+ (compile-valid must mean mountable; fix the law or re-run with --no-mount-check to emit anyway)
75
+ `
76
+ );
77
+ return 1;
78
+ } else if (verdict.checked.length > 0) {
79
+ process.stdout.write(
80
+ ` mountable \u2713 ${verdict.checked.join(", ")} mount on the real read router${verdict.cached ? " (content-addressed proof reused)" : ""}
81
+ `
82
+ );
83
+ }
84
+ } catch (error) {
85
+ process.stderr.write(
86
+ `note: mountability gate could not run (${error instanceof Error ? error.message : error}) \u2014 package emitted
87
+ `
88
+ );
89
+ }
90
+ return status;
91
+ }
92
+
93
+ // src/compile_entry.ts
94
+ process.exit(await runCompileCommand(process.argv.slice(2)));