@galaxy-blackhole/blackhole-harness 0.1.2 → 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.
@@ -346,6 +346,7 @@ import { dirname as dirname2, join as join3 } from "node:path";
346
346
  function linkSelfPackages() {
347
347
  const modules = join3(repoRoot(), "node_modules");
348
348
  let added = 0;
349
+ const failed = [];
349
350
  for (const tang of ["host", "client", "tools"]) {
350
351
  const root = join3(repoRoot(), "packages", tang);
351
352
  let names;
@@ -370,15 +371,18 @@ function linkSelfPackages() {
370
371
  continue;
371
372
  try {
372
373
  mkdirSync(dirname2(link), { recursive: true });
373
- symlinkSync(dir, link, "dir");
374
+ symlinkSync(dir, link, process.platform === "win32" ? "junction" : "dir");
374
375
  added += 1;
375
- } catch {
376
- continue;
376
+ } catch (error) {
377
+ failed.push(specifier + " → " + dir + " (" + (error instanceof Error ? error.message : String(error)) + ")");
377
378
  }
378
379
  }
379
380
  }
380
381
  if (added > 0)
381
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
+ }
382
386
  return added;
383
387
  }
384
388
 
@@ -2154,6 +2158,7 @@ function spawnHost(options) {
2154
2158
  });
2155
2159
  let settled = false;
2156
2160
  let buffer = "";
2161
+ let errBuffer = "";
2157
2162
  const relayTo = (sink) => {
2158
2163
  let pending = "";
2159
2164
  return (chunk) => {
@@ -2189,6 +2194,7 @@ function spawnHost(options) {
2189
2194
  child.stderr?.setEncoding("utf8");
2190
2195
  child.stderr?.on("data", (chunk) => {
2191
2196
  relayErr(chunk);
2197
+ errBuffer = `${errBuffer}${chunk}`.slice(-4096);
2192
2198
  });
2193
2199
  child.once("error", (error) => {
2194
2200
  if (settled)
@@ -2200,7 +2206,11 @@ function spawnHost(options) {
2200
2206
  if (settled)
2201
2207
  return;
2202
2208
  settled = true;
2203
- 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}`)));
2204
2214
  });
2205
2215
  });
2206
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 };
@@ -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.2",
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)",