@galaxy-stack/blackhole-cli 3.0.2 → 3.0.5

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.
Files changed (50) hide show
  1. package/README.md +96 -5
  2. package/dist/cli.js +24 -0
  3. package/dist/cli.js.map +1 -1
  4. package/dist/harness/command.d.ts +2 -0
  5. package/dist/harness/command.d.ts.map +1 -1
  6. package/dist/harness/command.js +11 -1
  7. package/dist/harness/command.js.map +1 -1
  8. package/dist/harness/ensure.d.ts +56 -0
  9. package/dist/harness/ensure.d.ts.map +1 -0
  10. package/dist/harness/ensure.js +100 -0
  11. package/dist/harness/ensure.js.map +1 -0
  12. package/dist/harness/install-command.d.ts +25 -0
  13. package/dist/harness/install-command.d.ts.map +1 -0
  14. package/dist/harness/install-command.js +224 -0
  15. package/dist/harness/install-command.js.map +1 -0
  16. package/dist/harness/install.d.ts +127 -0
  17. package/dist/harness/install.d.ts.map +1 -0
  18. package/dist/harness/install.js +329 -0
  19. package/dist/harness/install.js.map +1 -0
  20. package/dist/harness/locate.d.ts +77 -3
  21. package/dist/harness/locate.d.ts.map +1 -1
  22. package/dist/harness/locate.js +151 -17
  23. package/dist/harness/locate.js.map +1 -1
  24. package/dist/harness/process.d.ts.map +1 -1
  25. package/dist/harness/process.js +2 -2
  26. package/dist/harness/process.js.map +1 -1
  27. package/dist/harness/zip.d.ts +58 -0
  28. package/dist/harness/zip.d.ts.map +1 -0
  29. package/dist/harness/zip.js +190 -0
  30. package/dist/harness/zip.js.map +1 -0
  31. package/dist/options.d.ts +1 -1
  32. package/dist/options.d.ts.map +1 -1
  33. package/dist/options.js +3 -0
  34. package/dist/options.js.map +1 -1
  35. package/dist/web/command.d.ts.map +1 -1
  36. package/dist/web/command.js +3 -2
  37. package/dist/web/command.js.map +1 -1
  38. package/dist/web/doctor.d.ts.map +1 -1
  39. package/dist/web/doctor.js +9 -7
  40. package/dist/web/doctor.js.map +1 -1
  41. package/dist/web/open-browser.d.ts.map +1 -1
  42. package/dist/web/open-browser.js +2 -1
  43. package/dist/web/open-browser.js.map +1 -1
  44. package/dist/web/web.d.ts +2 -0
  45. package/dist/web/web.d.ts.map +1 -1
  46. package/dist/web/web.js +18 -8
  47. package/dist/web/web.js.map +1 -1
  48. package/package.json +1 -1
  49. package/web/brand/lib/client.js +4 -4
  50. package/web/brand/lib/journey-run.js +13 -1
@@ -0,0 +1,329 @@
1
+ /**
2
+ * `blackhole harness install | status | remove`: put the Galaxy Blackhole harness on a machine
3
+ * that never had a checkout of it.
4
+ *
5
+ * The CLI is published without the harness, so a fresh `npm i -g` has no launcher to boot. This
6
+ * module fetches one — `git clone --depth 1` when git is installed, the GitHub archive otherwise —
7
+ * unpacks it under `~/.galaxy/harness/blackhole-tauri` (or wherever `--dir` says), installs the
8
+ * runtime dependencies the launcher needs, and records where it went so the resolver finds it
9
+ * again. Every step is printed before it runs: a multi-minute download must never look like a hang.
10
+ */
11
+ import { spawn } from "node:child_process";
12
+ import { createWriteStream, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
13
+ import { homedir } from "node:os";
14
+ import { basename, dirname, join, resolve } from "node:path";
15
+ import { Readable } from "node:stream";
16
+ import { pipeline } from "node:stream/promises";
17
+ import { extractZip } from "./zip.js";
18
+ import { defaultHarnessDir, defaultHarnessParent, findBun, findTauriLocation, harnessHome, installRecordPaths, isHarnessCheckout, systemLocateEnvironment, } from "./locate.js";
19
+ import { resolveNodeRuntime, systemNodeLookup } from "./node-runtime.js";
20
+ /** The repository the harness is published from. */
21
+ export const HARNESS_REPO = "https://github.com/galaxy-blackhole/blackhole-harness";
22
+ /** The branch a shallow clone and the archive URL both read. */
23
+ export const HARNESS_BRANCH = "main";
24
+ /** The checkout directory name every install ends with. */
25
+ export const HARNESS_DIR_NAME = "blackhole-harness";
26
+ /**
27
+ * The archive URL for a repository: GitHub serves the branch head as a zip, which needs no git.
28
+ * @param repo - repository URL (an `.git` suffix is dropped).
29
+ * @param branch - branch to download.
30
+ * @returns the `archive/refs/heads/<branch>.zip` URL.
31
+ */
32
+ export function archiveUrl(repo = HARNESS_REPO, branch = HARNESS_BRANCH) {
33
+ return repo.replace(/\.git$/u, "").replace(/\/+$/u, "") + "/archive/refs/heads/" + branch + ".zip";
34
+ }
35
+ /**
36
+ * One failed download, with the next step attached: a 404 means the source, not the network, so
37
+ * the message names the other sources instead of leaving the user with a bare status code.
38
+ * @param url - the URL that failed.
39
+ * @param error - the network or HTTP failure.
40
+ * @returns the error the installer throws.
41
+ */
42
+ function downloadFailure(url, error) {
43
+ const reason = error instanceof Error ? error.message : String(error);
44
+ const notFound = /\b404\b/u.test(reason) ? " (404: repo chưa public, hoặc nhánh chưa có)" : "";
45
+ return new Error("tải harness thất bại" + notFound + ": " + reason +
46
+ "\n nguồn khác: blackhole harness install --from <url .zip | repo git>, hoặc đặt GBH_TAURI_ARCHIVE / GBH_TAURI_REPO.");
47
+ }
48
+ /** Spawn a child with inherited stdio, so a package manager's own progress is visible. */
49
+ function runInherit(command, args, cwd) {
50
+ return new Promise(resolvePromise => {
51
+ const child = spawn(command, [...args], { cwd, stdio: "inherit" });
52
+ child.once("error", () => resolvePromise(1));
53
+ child.once("close", code => resolvePromise(code ?? 1));
54
+ });
55
+ }
56
+ /** Stream one HTTP(S) URL into a file, following redirects (`codeload.github.com` does that). */
57
+ async function downloadToFile(url, dest) {
58
+ const response = await fetch(url, { redirect: "follow" });
59
+ if (!response.ok) {
60
+ throw new Error("HTTP " + String(response.status) + (response.statusText.length > 0 ? " " + response.statusText : "") + " — " + url);
61
+ }
62
+ if (response.body === null)
63
+ throw new Error("máy chủ trả về nội dung rỗng — " + url);
64
+ await pipeline(Readable.fromWeb(response.body), createWriteStream(dest));
65
+ }
66
+ /**
67
+ * Where a `--dir` install lands: the directory holding the checkout, or the checkout itself when
68
+ * the path already ends with `blackhole-tauri`.
69
+ * @param options - the parsed `--dir`, when one was given.
70
+ * @param environment - environment and home facts.
71
+ * @returns the absolute checkout root.
72
+ */
73
+ export function resolveInstallRoot(options, environment) {
74
+ const base = options.dir === undefined ? defaultHarnessParent(environment) : resolve(options.dir);
75
+ return basename(base) === HARNESS_DIR_NAME ? base : join(base, HARNESS_DIR_NAME);
76
+ }
77
+ /**
78
+ * Refuse to delete anything that is not a harness checkout directory.
79
+ * @param target - the directory an install would replace.
80
+ * @throws when the path is a filesystem root, a home directory, or not named blackhole-tauri.
81
+ */
82
+ export function assertReplaceable(target) {
83
+ const absolute = resolve(target);
84
+ const parent = dirname(absolute);
85
+ if (parent === absolute || absolute === resolve(homedir()) || basename(absolute) !== HARNESS_DIR_NAME) {
86
+ throw new Error("từ chối ghi đè " + absolute + ": chỉ thay thư mục " + HARNESS_DIR_NAME + " bên trong thư mục harness");
87
+ }
88
+ }
89
+ /** The `version` a checkout's package.json declares, when it has one. */
90
+ export function readHarnessVersion(root) {
91
+ try {
92
+ const parsed = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
93
+ const version = parsed.version;
94
+ return typeof version === "string" && version.trim().length > 0 ? version.trim() : undefined;
95
+ }
96
+ catch {
97
+ return undefined;
98
+ }
99
+ }
100
+ /**
101
+ * Whether `apps/host/node_modules` is populated.
102
+ * @param root - checkout root.
103
+ * @returns presence and the number of top-level entries.
104
+ */
105
+ export function hostModulesState(root) {
106
+ const dir = join(root, "apps", "host", "node_modules");
107
+ try {
108
+ const entries = readdirSync(dir).filter(name => !name.startsWith("."));
109
+ return { present: entries.length > 0, packages: entries.length };
110
+ }
111
+ catch {
112
+ return { present: false, packages: 0 };
113
+ }
114
+ }
115
+ /**
116
+ * Resolve npm without a shell: on Windows `npm` is a `.cmd` shim, which `spawn` refuses to run
117
+ * directly, so the JS entry beside the shim is started through node instead (the same rule the DSH
118
+ * resolver uses). A shim whose package is gone falls back to `cmd.exe /c`, the last resort.
119
+ */
120
+ function npmInvocation(environment, node) {
121
+ const found = environment.which("npm");
122
+ if (found === undefined)
123
+ return undefined;
124
+ if (/\.(cmd|bat)$/iu.test(found)) {
125
+ const cli = join(dirname(found), "node_modules", "npm", "bin", "npm-cli.js");
126
+ if (environment.exists(cli))
127
+ return { command: node, args: [cli] };
128
+ return { command: environment.env.ComSpec ?? "cmd.exe", args: ["/d", "/s", "/c", found] };
129
+ }
130
+ if (/\.(js|mjs|cjs)$/iu.test(found))
131
+ return { command: node, args: [found] };
132
+ return { command: found, args: [] };
133
+ }
134
+ /**
135
+ * The dependency steps a checkout needs, in order.
136
+ *
137
+ * Bun is the repository's own tool (`bun install`, then `bun install` in `apps/host`, which is not
138
+ * a workspace member). Without Bun the host's pinned `@deepseek-ai/*` runtime is installed with
139
+ * npm instead, which is enough for the host process but not for the CLI's own tooling.
140
+ * @param root - checkout root.
141
+ * @param environment - PATH and filesystem facts.
142
+ * @param node - node binary for npm's JS entry.
143
+ * @returns the steps to run; empty when no package manager is installed.
144
+ */
145
+ export function planDependencies(root, environment, node = process.execPath) {
146
+ const bun = findBun(environment);
147
+ if (bun !== undefined) {
148
+ const host = join(root, "apps", "host");
149
+ const steps = [{ command: bun, args: ["install"], cwd: root, label: "bun install (package + workspace)" }];
150
+ if (environment.exists(join(host, "package.json")))
151
+ steps.push({ command: bun, args: ["install"], cwd: host, label: "bun install (apps/host)" });
152
+ return steps;
153
+ }
154
+ const npm = npmInvocation(environment, node);
155
+ if (npm === undefined)
156
+ return [];
157
+ const host = join(root, "apps", "host");
158
+ if (!environment.exists(join(host, "package.json")))
159
+ return [];
160
+ return [{ command: npm.command, args: [...npm.args, "install", "--omit=dev", "--no-audit", "--no-fund"], cwd: host, label: "npm install --omit=dev (apps/host)" }];
161
+ }
162
+ /** Write the record every later lookup reads, beside the default slot and beside `$GBH_HOME`. */
163
+ function writeInstallRecord(root, environment, via) {
164
+ const version = readHarnessVersion(root);
165
+ const body = JSON.stringify({ root, installedAt: new Date().toISOString(), via, ...(version === undefined ? {} : { version }) }, null, 2) + "\n";
166
+ const written = [];
167
+ for (const path of installRecordPaths(environment)) {
168
+ try {
169
+ mkdirSync(dirname(path), { recursive: true });
170
+ writeFileSync(path, body, "utf8");
171
+ written.push(path);
172
+ }
173
+ catch {
174
+ // A read-only or missing home must not fail a download that already succeeded.
175
+ }
176
+ }
177
+ return written;
178
+ }
179
+ /** Run every dependency step; report which manager answered and whether the host is ready. */
180
+ async function runDependencies(input) {
181
+ if (input.skip)
182
+ return { deps: "skipped", ready: hostModulesState(input.root).present, note: "--no-deps: chưa cài phụ thuộc" };
183
+ if (!input.force && hostModulesState(input.root).present) {
184
+ input.write("phụ thuộc: apps/host/node_modules đã có — bỏ qua (dùng --force để cài lại)");
185
+ return { deps: "skipped", ready: true };
186
+ }
187
+ const steps = planDependencies(input.root, input.environment);
188
+ if (steps.length === 0) {
189
+ return {
190
+ deps: "skipped",
191
+ ready: false,
192
+ note: "không thấy bun hay npm trên PATH — cài Node.js (kèm npm) hoặc bun (https://bun.sh) rồi chạy lại",
193
+ };
194
+ }
195
+ const manager = basename(steps[0].command).toLowerCase().startsWith("bun") ? "bun" : "npm";
196
+ for (const step of steps) {
197
+ input.write("phụ thuộc: " + step.label + " (cwd " + step.cwd + ")");
198
+ const code = await input.run(step.command, step.args, step.cwd);
199
+ if (code !== 0) {
200
+ return { deps: "failed", ready: hostModulesState(input.root).present, note: step.label + " thoát mã " + String(code) };
201
+ }
202
+ }
203
+ return {
204
+ deps: manager,
205
+ ready: hostModulesState(input.root).present,
206
+ ...(manager === "npm"
207
+ ? { note: "đã cài apps/host bằng npm; repo dùng bun cho bước đầy đủ (bun run setup) — cài bun tại https://bun.sh nếu launcher báo thiếu gói" }
208
+ : {}),
209
+ };
210
+ }
211
+ /**
212
+ * Download (or reuse) the harness checkout and install its dependencies.
213
+ * @param options - destination, force, source override, progress sink and injected process facts.
214
+ * @returns the checkout root, how it arrived and whether it is ready to boot.
215
+ * @throws when the download fails, the archive has no launcher, or the destination is unsafe.
216
+ */
217
+ export async function installHarness(options = {}) {
218
+ const environment = options.environment ?? systemLocateEnvironment();
219
+ const write = options.write ?? (line => { process.stdout.write(line + "\n"); });
220
+ const run = options.run ?? runInherit;
221
+ const download = options.download ?? downloadToFile;
222
+ const node = options.node ?? process.execPath;
223
+ const root = resolveInstallRoot(options, environment);
224
+ assertReplaceable(root);
225
+ write("harness: " + root);
226
+ if (isHarnessCheckout(environment, root) && options.force !== true) {
227
+ write("nguồn: đã có sẵn — không tải lại (dùng --force để tải lại)");
228
+ // An explicit --dir on an existing checkout is still worth recording: it is what makes the
229
+ // next `chat` find a tree the user installed by hand.
230
+ for (const record of writeInstallRecord(root, environment, "existing"))
231
+ write("ghi nhớ: " + record);
232
+ const deps = await runDependencies({ root, environment, run, write, force: false, skip: options.noDeps === true });
233
+ return { root, via: "existing", downloaded: false, deps: deps.deps, ready: deps.ready, ...(deps.note === undefined ? {} : { note: deps.note }) };
234
+ }
235
+ const archive = (environment.env.GBH_TAURI_ARCHIVE ?? "").trim();
236
+ const repo = (environment.env.GBH_TAURI_REPO ?? "").trim() || HARNESS_REPO;
237
+ const branch = (environment.env.GBH_TAURI_BRANCH ?? "").trim() || HARNESS_BRANCH;
238
+ const from = (options.from ?? "").trim();
239
+ const zipSource = from.length > 0 ? /\.zip(?:\?.*)?$/iu.test(from) : archive.length > 0;
240
+ const gitSource = from.length > 0 ? (zipSource ? "" : from) : repo;
241
+ const parent = dirname(root);
242
+ mkdirSync(parent, { recursive: true });
243
+ const staging = join(parent, "." + HARNESS_DIR_NAME + "-tai-" + Date.now().toString(36) + "-" + Math.random().toString(36).slice(2, 6));
244
+ let via = "zip";
245
+ try {
246
+ const git = zipSource ? undefined : environment.which("git");
247
+ if (!zipSource && gitSource.length > 0 && git !== undefined) {
248
+ write("nguồn: git clone --depth 1 --branch " + branch + " " + gitSource);
249
+ const code = await run(git, ["clone", "--depth", "1", "--branch", branch, gitSource, staging], parent);
250
+ if (code === 0)
251
+ via = "git";
252
+ else {
253
+ rmSync(staging, { recursive: true, force: true });
254
+ write("git clone lỗi (mã " + String(code) + ") — chuyển sang tải ZIP");
255
+ }
256
+ }
257
+ if (via === "zip") {
258
+ // A --from that names a local repository is only reachable through git; without it the ZIP
259
+ // fallback would build a meaningless archive URL, so say what is missing instead.
260
+ if (!zipSource && from.length > 0 && git === undefined) {
261
+ throw new Error("--from " + from + " cần git để clone, và máy này không có git trên PATH. Cài git, hoặc dùng --from <url .zip>.");
262
+ }
263
+ const url = zipSource ? (from.length > 0 ? from : archive) : archiveUrl(gitSource.length > 0 ? gitSource : HARNESS_REPO, branch);
264
+ write("nguồn: tải ZIP " + url);
265
+ const file = staging + ".zip";
266
+ try {
267
+ await download(url, file);
268
+ }
269
+ catch (error) {
270
+ throw downloadFailure(url, error);
271
+ }
272
+ write("giải nén: " + file);
273
+ const bytes = readFileSync(file);
274
+ const summary = extractZip(bytes, staging, {
275
+ onSkip: (name, reason) => write("bỏ qua: " + name + " (" + reason + ")"),
276
+ });
277
+ rmSync(file, { force: true });
278
+ write("đã giải nén: " + String(summary.files) + " tệp, " + String(summary.dirs) + " thư mục" + (summary.links === 0 ? "" : ", " + String(summary.links) + " symlink"));
279
+ }
280
+ if (!isHarnessCheckout(environment, staging)) {
281
+ throw new Error("gói tải về không có apps/cli/src/main.ts — không phải checkout blackhole-tauri");
282
+ }
283
+ rmSync(root, { recursive: true, force: true });
284
+ renameSync(staging, root);
285
+ }
286
+ catch (error) {
287
+ rmSync(staging, { recursive: true, force: true });
288
+ rmSync(staging + ".zip", { force: true });
289
+ throw error;
290
+ }
291
+ const version = readHarnessVersion(root);
292
+ write("đã tải: " + root + (version === undefined ? "" : " (harness " + version + ")"));
293
+ for (const record of writeInstallRecord(root, environment, via))
294
+ write("ghi nhớ: " + record);
295
+ const deps = await runDependencies({ root, environment, run, write, force: true, skip: options.noDeps === true });
296
+ return { root, via, downloaded: true, deps: deps.deps, ready: deps.ready, ...(deps.note === undefined ? {} : { note: deps.note }) };
297
+ }
298
+ /**
299
+ * Everything `harness status` prints, gathered without side effects.
300
+ * @param environment - locate facts; this machine by default.
301
+ * @returns the checkout (when found), its versions, the runtimes and the host dependency state.
302
+ */
303
+ export function harnessStatusFacts(environment = systemLocateEnvironment()) {
304
+ const location = findTauriLocation(environment);
305
+ let node;
306
+ let nodeError;
307
+ try {
308
+ node = resolveNodeRuntime(systemNodeLookup());
309
+ }
310
+ catch (error) {
311
+ nodeError = error instanceof Error ? error.message : String(error);
312
+ }
313
+ const root = location?.root;
314
+ const hostVersion = root === undefined ? undefined : readHarnessVersion(join(root, "apps", "host"));
315
+ const version = root === undefined ? undefined : readHarnessVersion(root);
316
+ const bun = findBun(environment);
317
+ return Object.freeze({
318
+ ...(location === undefined ? {} : { location }),
319
+ ...(version === undefined ? {} : { version }),
320
+ ...(hostVersion === undefined ? {} : { hostVersion }),
321
+ ...(node === undefined ? {} : { node }),
322
+ ...(nodeError === undefined ? {} : { nodeError }),
323
+ ...(bun === undefined ? {} : { bun }),
324
+ hostModules: root === undefined ? { present: false, packages: 0 } : hostModulesState(root),
325
+ home: harnessHome(environment),
326
+ defaultDir: defaultHarnessDir(environment),
327
+ });
328
+ }
329
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/harness/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;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AC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;QAC7C,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;QACrD,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;QACvC,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC;QACjD,GAAG,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;QACrC,WAAW,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAC1F,IAAI,EAAE,WAAW,CAAC,WAAW,CAAC;QAC9B,UAAU,EAAE,iBAAiB,CAAC,WAAW,CAAC;KAC3C,CAAC,CAAC;AACL,CAAC"}
@@ -1,24 +1,98 @@
1
+ /** The ladder step that produced a checkout. */
2
+ export type HarnessSource = "env" | "home" | "installed" | "sibling" | "dev";
3
+ /** A found checkout and the step that found it. */
4
+ export interface HarnessLocation {
5
+ /** Absolute root of the checkout that owns `apps/cli/src/main.ts`. */
6
+ readonly root: string;
7
+ /** Which rung of the ladder answered. */
8
+ readonly source: HarnessSource;
9
+ /** The rung as the user reads it: `GBH_TAURI_ROOT`, `~/.galaxy/harness/blackhole-harness`, … */
10
+ readonly label: string;
11
+ }
12
+ /** What `blackhole harness install --dir` records beside the default slot. */
13
+ export interface HarnessRecord {
14
+ /** Absolute checkout root that was installed. */
15
+ readonly root: string;
16
+ /** ISO timestamp of the install. */
17
+ readonly installedAt?: string;
18
+ /** How the tree arrived: a git clone or the GitHub archive. */
19
+ readonly via?: string;
20
+ /** `version` read from the checkout's package.json at install time. */
21
+ readonly version?: string;
22
+ }
1
23
  /** The process facts a lookup reads. */
2
24
  export interface LocateEnvironment {
3
25
  readonly env: NodeJS.ProcessEnv;
4
26
  readonly exists: (path: string) => boolean;
5
27
  /** First line of `which <name>` (or `where`), or undefined. */
6
28
  readonly which: (name: string) => string | undefined;
29
+ /** Home directory; `os.homedir()` in production, injected by tests. */
30
+ readonly home?: string;
31
+ /** Reads an install record, or undefined when the file is missing or unreadable. */
32
+ readonly readRecord?: (path: string) => HarnessRecord | undefined;
7
33
  }
8
34
  /** The real filesystem, PATH and environment. */
9
35
  export declare function systemLocateEnvironment(): LocateEnvironment;
36
+ /** The home directory every `~` path is built from. */
37
+ export declare function locateHome(environment: LocateEnvironment): string;
38
+ /**
39
+ * The harness data home: `$GBH_HOME`, else `~/.galaxy/blackhole`.
40
+ * @param environment - environment and home facts.
41
+ * @returns the directory the harness keeps sessions and profiles in.
42
+ */
43
+ export declare function harnessHome(environment: LocateEnvironment): string;
44
+ /** `~/.galaxy/harness`: the directory `blackhole harness install` fills by default. */
45
+ export declare function defaultHarnessParent(environment: LocateEnvironment): string;
46
+ /** `~/.galaxy/harness/blackhole-harness`: where a default install lands. */
47
+ export declare function defaultHarnessDir(environment: LocateEnvironment): string;
48
+ /**
49
+ * Every file `harness install --dir` may have written its record to, de-duplicated.
50
+ * @param environment - environment and home facts.
51
+ * @returns absolute record paths, harness home first.
52
+ */
53
+ export declare function installRecordPaths(environment: LocateEnvironment): string[];
54
+ /**
55
+ * Read one install record.
56
+ * @param path - the `install.json` to read.
57
+ * @returns the record, or undefined when the file is missing, unreadable or not a record.
58
+ */
59
+ export declare function readHarnessRecord(path: string): HarnessRecord | undefined;
10
60
  /**
11
- * Root of the blackhole-tauri checkout that owns `apps/cli/src/main.ts`.
61
+ * Whether a directory is a harness checkout: it owns `apps/cli/src/main.ts`.
62
+ * @param environment - filesystem facts.
63
+ * @param root - candidate checkout root.
64
+ * @returns true when the launcher entry point is there.
65
+ */
66
+ export declare function isHarnessCheckout(environment: LocateEnvironment, root: string): boolean;
67
+ /**
68
+ * Find the harness checkout and say which rung answered:
69
+ * `GBH_TAURI_ROOT` → `$GBH_HOME/harness/blackhole-harness` → `~/.galaxy/harness/blackhole-harness`
70
+ * (each slot also honours the record `install --dir` leaves) → sibling of this package → dev path.
71
+ * @param environment - filesystem, PATH and environment facts.
72
+ * @returns the checkout and its provenance, or undefined when this machine has none.
73
+ */
74
+ export declare function findTauriLocation(environment?: LocateEnvironment): HarnessLocation | undefined;
75
+ /**
76
+ * Root of the blackhole-harness checkout that owns `apps/cli/src/main.ts`.
12
77
  * @param environment - filesystem, PATH and environment facts.
13
78
  * @returns the absolute checkout root, or undefined when this machine has none.
14
79
  */
15
80
  export declare function findTauriRoot(environment?: LocateEnvironment): string | undefined;
81
+ /** The one line every missing-harness failure starts with, exactly as users were promised it. */
82
+ export declare const HARNESS_MISSING_LINE = "Ch\u01B0a c\u00F3 harness blackhole-harness. Ch\u1EA1y: blackhole harness install (ho\u1EB7c \u0111\u1EB7t GBH_TAURI_ROOT t\u1EDBi b\u1EA3n checkout)";
83
+ /**
84
+ * The actionable missing-harness message: the two ways out, with a command each for macOS/Linux
85
+ * and for both Windows shells, so it can be pasted as-is wherever the user is.
86
+ * @param environment - environment facts; defaults to this process.
87
+ * @returns several lines, the promised first one included.
88
+ */
89
+ export declare function harnessMissingMessage(environment?: LocateEnvironment): string;
16
90
  /**
17
91
  * A Bun binary, when this machine has one: an override, PATH, or the default install location.
18
92
  *
19
93
  * Booting the harness no longer needs it (`blackhole web` runs the launcher with Node), but the
20
- * desktop checkout still uses Bun to bundle its client plugins, so the lookup stays available for
21
- * the commands that build rather than boot.
94
+ * desktop checkout still uses Bun to install and to bundle its client plugins, so the lookup stays
95
+ * available for the commands that build or install rather than boot.
22
96
  * @param environment - filesystem, PATH and environment facts.
23
97
  * @returns the executable path, or undefined when Bun is not installed.
24
98
  */
@@ -1 +1 @@
1
- {"version":3,"file":"locate.d.ts","sourceRoot":"","sources":["../../src/harness/locate.ts"],"names":[],"mappings":"AAcA,wCAAwC;AACxC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAC3C,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CACtD;AAED,iDAAiD;AACjD,wBAAgB,uBAAuB,IAAI,iBAAiB,CAgB3D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,WAAW,GAAE,iBAA6C,GAAG,MAAM,GAAG,SAAS,CAU5G;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,WAAW,GAAE,iBAA6C,GAAG,MAAM,GAAG,SAAS,CAOtG;AAED,qEAAqE;AACrE,wBAAgB,MAAM,CAAC,WAAW,GAAE,iBAA6C,GAAG,MAAM,GAAG,SAAS,CAErG"}
1
+ {"version":3,"file":"locate.d.ts","sourceRoot":"","sources":["../../src/harness/locate.ts"],"names":[],"mappings":"AAmBA,gDAAgD;AAChD,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,KAAK,CAAC;AAE7E,mDAAmD;AACnD,MAAM,WAAW,eAAe;IAC9B,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,gGAAgG;IAChG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B,iDAAiD;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,o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