@sdkurjnk/blackshell 0.5.0 → 0.6.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.
- package/dist/cli.js +34 -26
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// BlackShell Launcher (TS).
|
|
3
|
-
// index and message rendering (docs/Architecture.md §5 hybrid).
|
|
4
|
-
// exposes per-unit primitives (check, enshell); the Launcher composes them
|
|
5
|
-
// `enshell` seals every staged unit by calling the engine's enshell per unit.
|
|
2
|
+
// BlackShell Launcher (TS).
|
|
3
|
+
// Owns the CLI: parsing, the command set, the staging index and message rendering (docs/Architecture.md §5 hybrid).
|
|
4
|
+
// The C++ engine exposes per-unit primitives (check, enshell); the Launcher composes them
|
|
5
|
+
// e.g. `enshell` seals every staged unit by calling the engine's enshell per unit.
|
|
6
6
|
import { spawnSync } from "node:child_process";
|
|
7
7
|
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
9
|
import { createRequire } from "node:module";
|
|
10
|
-
import { dirname, join, extname } from "node:path";
|
|
10
|
+
import { dirname, join, extname, basename } from "node:path";
|
|
11
11
|
const here = (p) => fileURLToPath(new URL(p, import.meta.url));
|
|
12
12
|
const pkg = JSON.parse(readFileSync(here("../package.json"), "utf8"));
|
|
13
13
|
const USAGE = `blackshell <command> [options]
|
|
@@ -57,10 +57,10 @@ export function showLevels(levels) {
|
|
|
57
57
|
}
|
|
58
58
|
return levels.join(",");
|
|
59
59
|
}
|
|
60
|
-
// Resolve the engine binary.
|
|
61
|
-
// optional dependency @sdkurjnk/blackshell-<platform>-<arch>
|
|
62
|
-
// installs only the host's);
|
|
63
|
-
// fallback when no platform package is installed.
|
|
60
|
+
// Resolve the engine binary.
|
|
61
|
+
// The published package pulls the matching engine as an optional dependency @sdkurjnk/blackshell-<platform>-<arch>
|
|
62
|
+
// (os/cpu-gated, so npm installs only the host's);
|
|
63
|
+
// resolve its binary. A local dev build in build/ is the fallback when no platform package is installed.
|
|
64
64
|
function enginePath() {
|
|
65
65
|
const exe = process.platform === "win32" ? "blackshell-engine.exe" : "blackshell-engine";
|
|
66
66
|
const pkg = `@sdkurjnk/blackshell-${process.platform}-${process.arch}`;
|
|
@@ -83,44 +83,45 @@ function engine(args) {
|
|
|
83
83
|
const token = (res.stdout ?? "").trim().split("\n").pop() ?? "";
|
|
84
84
|
return { token, status: res.status ?? 1 };
|
|
85
85
|
}
|
|
86
|
-
// engine
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
// engine code -> rendered message. The engine emits a bare token;
|
|
87
|
+
// we fill the source and object paths from the staged unit (ctx),
|
|
88
|
+
// so the engine never has to echo them. The engine never renders.
|
|
89
|
+
export function render(token, ctx) {
|
|
90
|
+
switch (token) {
|
|
90
91
|
case "gate.ok": {
|
|
91
|
-
return { line: `pass: ${
|
|
92
|
+
return { line: `pass: ${ctx.src} is eligible`, err: false };
|
|
92
93
|
}
|
|
93
94
|
case "gate.reject": {
|
|
94
|
-
return { line: `reject: ${
|
|
95
|
+
return { line: `reject: ${ctx.src} — ineligible`, err: true };
|
|
95
96
|
}
|
|
96
97
|
case "sealed": {
|
|
97
|
-
return { line: `sealed: ${
|
|
98
|
+
return { line: `sealed: ${ctx.src} -> ${ctx.obj}`, err: false };
|
|
98
99
|
}
|
|
99
100
|
case "frontend.failed": {
|
|
100
|
-
return { line: `error: clang (frontend) failed on ${
|
|
101
|
+
return { line: `error: clang (frontend) failed on ${ctx.src}`, err: true };
|
|
101
102
|
}
|
|
102
103
|
case "backend.failed": {
|
|
103
|
-
return { line: `error: llc (backend) failed on ${
|
|
104
|
+
return { line: `error: llc (backend) failed on ${ctx.src}`, err: true };
|
|
104
105
|
}
|
|
105
106
|
case "verify.broken": {
|
|
106
|
-
return { line: `error: noising broke equivalence on ${
|
|
107
|
+
return { line: `error: noising broke equivalence on ${ctx.src}`, err: true };
|
|
107
108
|
}
|
|
108
109
|
case "arg.one_positional": {
|
|
109
110
|
return { line: `error: expected exactly one <source> argument`, err: true };
|
|
110
111
|
}
|
|
111
112
|
case "cmd.unknown": {
|
|
112
|
-
return { line: `error: unknown command
|
|
113
|
+
return { line: `error: unknown command`, err: true };
|
|
113
114
|
}
|
|
114
115
|
default: {
|
|
115
116
|
return { line: token, err: true };
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
|
-
function emit(token) {
|
|
120
|
+
function emit(token, ctx) {
|
|
120
121
|
if (!token) {
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
|
-
const { line, err } = render(token);
|
|
124
|
+
const { line, err } = render(token, ctx);
|
|
124
125
|
if (err) {
|
|
125
126
|
console.error(line);
|
|
126
127
|
}
|
|
@@ -161,6 +162,13 @@ export function enshellArgs(u) {
|
|
|
161
162
|
}
|
|
162
163
|
return args;
|
|
163
164
|
}
|
|
165
|
+
// The object path the engine writes for a unit, mirroring the engine's default(<stem>.o):
|
|
166
|
+
// the --name stem if set, else the source's basename stem.
|
|
167
|
+
// Used to render the sealed line, since the engine no longer echoes the path.
|
|
168
|
+
export function objOf(u) {
|
|
169
|
+
const stem = u.name ?? basename(u.path, extname(u.path));
|
|
170
|
+
return `${stem}.o`;
|
|
171
|
+
}
|
|
164
172
|
// --- commands ---
|
|
165
173
|
function cmdCheck(rest) {
|
|
166
174
|
const stray = strayOption(rest);
|
|
@@ -182,7 +190,7 @@ function cmdCheck(rest) {
|
|
|
182
190
|
return 1;
|
|
183
191
|
}
|
|
184
192
|
const { token, status } = engine(["check", src]);
|
|
185
|
-
emit(token);
|
|
193
|
+
emit(token, { src });
|
|
186
194
|
return status;
|
|
187
195
|
}
|
|
188
196
|
function cmdAdd(rest) {
|
|
@@ -216,8 +224,8 @@ function cmdAdd(rest) {
|
|
|
216
224
|
console.error("error: --name requires a value");
|
|
217
225
|
return 1;
|
|
218
226
|
}
|
|
219
|
-
// --name is a bare object stem, not a path:
|
|
220
|
-
// can't escape the working dir (we hand it to the engine as the object path).
|
|
227
|
+
// --name is a bare object stem, not a path:
|
|
228
|
+
// reject separators so the output can't escape the working dir (we hand it to the engine as the object path).
|
|
221
229
|
if (nameOpt.value !== undefined && /[/\\]/.test(nameOpt.value)) {
|
|
222
230
|
console.error("error: --name must be a bare filename (no path separators)");
|
|
223
231
|
return 1;
|
|
@@ -280,7 +288,7 @@ function cmdEnshell() {
|
|
|
280
288
|
let code = 0;
|
|
281
289
|
for (const u of units) {
|
|
282
290
|
const { token, status } = engine(enshellArgs(u));
|
|
283
|
-
emit(token);
|
|
291
|
+
emit(token, { src: u.path, obj: objOf(u) });
|
|
284
292
|
if (status !== 0) {
|
|
285
293
|
code = status;
|
|
286
294
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdkurjnk/blackshell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Build-stage protection tool that seals critical code regions at the compiler IR level, communicating with the outside only by value.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"typescript": "^7.0.2"
|
|
46
46
|
},
|
|
47
47
|
"optionalDependencies": {
|
|
48
|
-
"@sdkurjnk/blackshell-darwin-arm64": "0.
|
|
49
|
-
"@sdkurjnk/blackshell-darwin-x64": "0.
|
|
50
|
-
"@sdkurjnk/blackshell-linux-arm64": "0.
|
|
51
|
-
"@sdkurjnk/blackshell-linux-x64": "0.
|
|
52
|
-
"@sdkurjnk/blackshell-win32-x64": "0.
|
|
48
|
+
"@sdkurjnk/blackshell-darwin-arm64": "0.6.0",
|
|
49
|
+
"@sdkurjnk/blackshell-darwin-x64": "0.6.0",
|
|
50
|
+
"@sdkurjnk/blackshell-linux-arm64": "0.6.0",
|
|
51
|
+
"@sdkurjnk/blackshell-linux-x64": "0.6.0",
|
|
52
|
+
"@sdkurjnk/blackshell-win32-x64": "0.6.0"
|
|
53
53
|
}
|
|
54
54
|
}
|