@galaxy-blackhole/blackhole-harness 0.1.1 → 0.1.3

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.
@@ -33,7 +33,8 @@ import { fileURLToPath } from "node:url";
33
33
  var cacheKernel;
34
34
  var DEFAULT_PORT = 5439;
35
35
  var LOOPBACK_HOST = "127.0.0.1";
36
- var MIN_NODE_MAJOR = 26;
36
+ var MIN_NODE_MAJOR = 22;
37
+ var MIN_NODE_MINOR = 6;
37
38
  var DEFAULT_PROFILE = "blackhole";
38
39
  var ORACLE_PORT = 4001;
39
40
  function galaxyRoot() {
@@ -345,6 +346,7 @@ import { dirname as dirname2, join as join3 } from "node:path";
345
346
  function linkSelfPackages() {
346
347
  const modules = join3(repoRoot(), "node_modules");
347
348
  let added = 0;
349
+ const failed = [];
348
350
  for (const tang of ["host", "client", "tools"]) {
349
351
  const root = join3(repoRoot(), "packages", tang);
350
352
  let names;
@@ -369,15 +371,18 @@ function linkSelfPackages() {
369
371
  continue;
370
372
  try {
371
373
  mkdirSync(dirname2(link), { recursive: true });
372
- symlinkSync(dir, link, "dir");
374
+ symlinkSync(dir, link, process.platform === "win32" ? "junction" : "dir");
373
375
  added += 1;
374
- } catch {
375
- continue;
376
+ } catch (error) {
377
+ failed.push(specifier + " → " + dir + " (" + (error instanceof Error ? error.message : String(error)) + ")");
376
378
  }
377
379
  }
378
380
  }
379
381
  if (added > 0)
380
382
  console.log("[bh] tu link " + String(added) + " goi GBH vao node_modules cua goi (ban npm)");
383
+ if (failed.length > 0) {
384
+ console.error("[bh] KHÔNG tao duoc " + String(failed.length) + " lien ket goi GBH" + (process.platform === "win32" ? " (Windows: bat Developer Mode hoac chay bang quyen Administrator)" : "") + "; 3 cai dau: " + failed.slice(0, 3).join(" · "));
385
+ }
381
386
  return added;
382
387
  }
383
388
 
@@ -2061,9 +2066,13 @@ function resolveNodeRuntime() {
2061
2066
  rejected.push({ bin: candidate.bin, reason: "did not answer --version (known silent failure)" });
2062
2067
  continue;
2063
2068
  }
2064
- const major = Number(version.slice(1).split(".")[0]);
2065
- if (major < MIN_NODE_MAJOR) {
2066
- rejected.push({ bin: candidate.bin, version, reason: `below the required v${MIN_NODE_MAJOR}` });
2069
+ const [major = 0, minor = 0] = version.slice(1).split(".").map((part) => Number(part));
2070
+ if (major < MIN_NODE_MAJOR || major === MIN_NODE_MAJOR && minor < MIN_NODE_MINOR) {
2071
+ rejected.push({
2072
+ bin: candidate.bin,
2073
+ version,
2074
+ reason: `below the required v${MIN_NODE_MAJOR}.${MIN_NODE_MINOR}`
2075
+ });
2067
2076
  continue;
2068
2077
  }
2069
2078
  cached = { bin: candidate.bin, version, major, source: candidate.source };
@@ -2149,6 +2158,7 @@ function spawnHost(options) {
2149
2158
  });
2150
2159
  let settled = false;
2151
2160
  let buffer = "";
2161
+ let errBuffer = "";
2152
2162
  const relayTo = (sink) => {
2153
2163
  let pending = "";
2154
2164
  return (chunk) => {
@@ -2184,6 +2194,7 @@ function spawnHost(options) {
2184
2194
  child.stderr?.setEncoding("utf8");
2185
2195
  child.stderr?.on("data", (chunk) => {
2186
2196
  relayErr(chunk);
2197
+ errBuffer = `${errBuffer}${chunk}`.slice(-4096);
2187
2198
  });
2188
2199
  child.once("error", (error) => {
2189
2200
  if (settled)
@@ -2195,7 +2206,11 @@ function spawnHost(options) {
2195
2206
  if (settled)
2196
2207
  return;
2197
2208
  settled = true;
2198
- reject(new Error(`harness exited before printing a URL (code ${String(code)}, signal ${String(signal)})`));
2209
+ const tail = (errBuffer.trim() === "" ? buffer : errBuffer).trim().split(/\r?\n/u).slice(-8).join(`
2210
+ `);
2211
+ reject(new Error(`harness exited before printing a URL (code ${String(code)}, signal ${String(signal)})` + (tail === "" ? "" : `
2212
+ --- 8 dòng cuối của harness ---
2213
+ ${tail}`)));
2199
2214
  });
2200
2215
  });
2201
2216
  return { child, ready, launch };
@@ -205,6 +205,8 @@ export function spawnHost(options: HostOptions): HostProcess {
205
205
  });
206
206
  let settled = false;
207
207
  let buffer = "";
208
+ /** Đuôi stderr của harness con, để báo lỗi thật thay vì chỉ "thoát trước khi in URL". */
209
+ let errBuffer = "";
208
210
  /**
209
211
  * Relay one child stream to one of ours, a complete line at a time, so every line can be
210
212
  * relabelled and a partial line never splits a UTF-8 sequence mid-write.
@@ -248,6 +250,7 @@ export function spawnHost(options: HostOptions): HostProcess {
248
250
  child.stderr?.setEncoding("utf8");
249
251
  child.stderr?.on("data", (chunk: string) => {
250
252
  relayErr(chunk);
253
+ errBuffer = `${errBuffer}${chunk}`.slice(-4096);
251
254
  });
252
255
  child.once("error", (error) => {
253
256
  if (settled) return;
@@ -257,7 +260,15 @@ export function spawnHost(options: HostOptions): HostProcess {
257
260
  child.once("exit", (code, signal) => {
258
261
  if (settled) return;
259
262
  settled = true;
260
- reject(new Error(`harness exited before printing a URL (code ${String(code)}, signal ${String(signal)})`));
263
+ // 13/11/2026 (Lead): kèm 8 dòng cuối của luồng con. Trên Windows người dùng chỉ thấy câu "exited before
264
+ // printing a URL" còn nguyên nhân thật (ERR_MODULE_NOT_FOUND) nằm trong log — không tự đi tìm.
265
+ const tail = (errBuffer.trim() === "" ? buffer : errBuffer).trim().split(/\r?\n/u).slice(-8).join("\n");
266
+ reject(
267
+ new Error(
268
+ `harness exited before printing a URL (code ${String(code)}, signal ${String(signal)})` +
269
+ (tail === "" ? "" : `\n--- 8 dòng cuối của harness ---\n${tail}`),
270
+ ),
271
+ );
261
272
  });
262
273
  });
263
274
  return { child, ready, launch };
@@ -27,7 +27,13 @@ export const DEFAULT_PORT = 5439;
27
27
  export const LOOPBACK_HOST = "127.0.0.1";
28
28
 
29
29
  /** Lowest Node major this app boots the harness with; v24 exits silently on this machine. */
30
- export const MIN_NODE_MAJOR = 26;
30
+ export const MIN_NODE_MAJOR = 22;
31
+
32
+ /**
33
+ * Nhỏ nhất của dòng {@link MIN_NODE_MAJOR}: 22.6 là bản đầu có `--experimental-strip-types`.
34
+ * @remarks Launcher chạy thẳng `.ts` nên Node 22.0–22.5 không dùng được dù đúng major.
35
+ */
36
+ export const MIN_NODE_MINOR = 6;
31
37
 
32
38
  /** Profile the app boots. */
33
39
  export const DEFAULT_PROFILE = "blackhole";
@@ -10,7 +10,7 @@ import { spawnSync } from "node:child_process";
10
10
  import { existsSync, readdirSync, readFileSync } from "node:fs";
11
11
  import { homedir } from "node:os";
12
12
  import { join } from "node:path";
13
- import { MIN_NODE_MAJOR, dshBinPath, dshManifestPath } from "./paths.ts";
13
+ import { MIN_NODE_MAJOR, MIN_NODE_MINOR, dshBinPath, dshManifestPath } from "./paths.ts";
14
14
 
15
15
  /** A Node binary this app is willing to boot the harness with. */
16
16
  export interface NodeRuntime {
@@ -123,9 +123,13 @@ export function resolveNodeRuntime(): NodeRuntime {
123
123
  rejected.push({ bin: candidate.bin, reason: "did not answer --version (known silent failure)" });
124
124
  continue;
125
125
  }
126
- const major = Number(version.slice(1).split(".")[0]);
127
- if (major < MIN_NODE_MAJOR) {
128
- rejected.push({ bin: candidate.bin, version, reason: `below the required v${MIN_NODE_MAJOR}` });
126
+ const [major = 0, minor = 0] = version.slice(1).split(".").map(part => Number(part));
127
+ if (major < MIN_NODE_MAJOR || (major === MIN_NODE_MAJOR && minor < MIN_NODE_MINOR)) {
128
+ rejected.push({
129
+ bin: candidate.bin,
130
+ version,
131
+ reason: `below the required v${MIN_NODE_MAJOR}.${MIN_NODE_MINOR}`,
132
+ });
129
133
  continue;
130
134
  }
131
135
  cached = { bin: candidate.bin, version, major, source: candidate.source };
@@ -26,6 +26,8 @@ import { repoRoot } from "./paths.ts";
26
26
  export function linkSelfPackages(): number {
27
27
  const modules = join(repoRoot(), "node_modules");
28
28
  let added = 0;
29
+ /** Những gói không tạo được liên kết, kèm lý do — in ra thay vì nuốt lỗi. */
30
+ const failed: string[] = [];
29
31
  for (const tang of ["host", "client", "tools"]) {
30
32
  const root = join(repoRoot(), "packages", tang);
31
33
  let names: string[];
@@ -48,13 +50,27 @@ export function linkSelfPackages(): number {
48
50
  if (daCo === true) continue;
49
51
  try {
50
52
  mkdirSync(dirname(link), { recursive: true });
51
- symlinkSync(dir, link, "dir");
53
+ // 13/11/2026 (Lead): Windows KHÔNG cho tạo symlink thư mục nếu không bật Developer Mode / không elevated
54
+ // (EPERM), mà `catch { continue }` cũ nuốt lỗi ⇒ bản cài npm thiếu link ⇒ import chéo
55
+ // @galaxy-blackhole/* nổ ERR_MODULE_NOT_FOUND, harness chết không in URL. Junction thì không cần quyền.
56
+ symlinkSync(dir, link, process.platform === "win32" ? "junction" : "dir");
52
57
  added += 1;
53
- } catch {
54
- continue;
58
+ } catch (error) {
59
+ failed.push(specifier + " → " + dir + " (" + (error instanceof Error ? error.message : String(error)) + ")");
55
60
  }
56
61
  }
57
62
  }
58
63
  if (added > 0) console.log("[bh] tu link " + String(added) + " goi GBH vao node_modules cua goi (ban npm)");
64
+ if (failed.length > 0) {
65
+ // Không im lặng: thiếu link ⇒ import chéo chết, mà triệu chứng lại xuất hiện ở chỗ khác (harness không in URL).
66
+ console.error(
67
+ "[bh] KHÔNG tao duoc " +
68
+ String(failed.length) +
69
+ " lien ket goi GBH" +
70
+ (process.platform === "win32" ? " (Windows: bat Developer Mode hoac chay bang quyen Administrator)" : "") +
71
+ "; 3 cai dau: " +
72
+ failed.slice(0, 3).join(" · "),
73
+ );
74
+ }
59
75
  return added;
60
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galaxy-blackhole/blackhole-harness",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Galaxy Blackhole harness — boot the DSH host with the blackhole profile (lean npm build)",
package/prepare.mjs CHANGED
@@ -29,7 +29,24 @@ const REPO = dirname(STAGING);
29
29
  const KEEP = new Set(["prepare.mjs", "README.md"]);
30
30
  /** Ten goi va version publish. */
31
31
  const NAME = "@galaxy-blackhole/blackhole-harness";
32
- const VERSION = "0.1.0";
32
+ // 12/11/2026 (Lead): version doc tu env de `GBH_HARNESS_VERSION=0.1.2 bun run pack:harness` khong
33
+ // bi ghi de ve 0.1.0 (npm khong cho publish lai cung version, nen pack sai version la mat 1 luot).
34
+ // 12/11/2026 (Lead bổ sung): giữ version ĐANG CÓ trong npm-package/package.json khi không đặt env —
35
+ // nếu luôn mặc định 0.1.0 thì mỗi lượt `publish:harness` lại đụng "cannot publish over 0.1.0".
36
+ const VERSION = (process.env.GBH_HARNESS_VERSION ?? docVersion() ?? "0.1.0").trim();
37
+
38
+ /**
39
+ * Version đang nằm trong staging package.json, nếu có.
40
+ * @returns version đã publish gần nhất theo staging, hoặc undefined khi chưa có tệp.
41
+ */
42
+ function docVersion() {
43
+ try {
44
+ const doc = JSON.parse(readFileSync(join(STAGING, "package.json"), "utf8"));
45
+ return typeof doc.version === "string" ? doc.version.trim() : undefined;
46
+ } catch {
47
+ return undefined;
48
+ }
49
+ }
33
50
 
34
51
  /** Bo dem dung luong/so tep theo tung nhom, de in bao cao cuoi. */
35
52
  const stats = new Map();
@@ -1,26 +0,0 @@
1
- {
2
- "name": "@galaxy-blackhole/gbh-libreoffice-kit-darwin-x64",
3
- "version": "0.2.1-alpha.4",
4
- "private": true,
5
- "description": "Bo nhi phan LibreOffice cho darwin-x64 (khong phai ma).",
6
- "license": "MPL-2.0",
7
- "type": "module",
8
- "exports": {
9
- "./prebuilds.json": "./prebuilds.json",
10
- "./package.json": "./package.json"
11
- },
12
- "os": [
13
- "darwin"
14
- ],
15
- "cpu": [
16
- "x64"
17
- ],
18
- "gbh": {
19
- "provenance": {
20
- "stock": "@deepseek-ai/libreoffice-kit-darwin-x64",
21
- "version": "0.1.5",
22
- "sha": "865bed0ca46779eb5d56b8da2938c6e54197432dde8f25fc3c778d6e84a8294c"
23
- },
24
- "draft": "Ban sao 1:1 tu goi goc - chua co dong nao trong bang doi chieu (khong khai gbh.row)."
25
- }
26
- }