@fusengine/harness 0.1.52 → 0.1.54

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/bin.mjs CHANGED
@@ -4,11 +4,10 @@ import { t as detectHarness } from "../harness-Cb9xR8dC.mjs";
4
4
  import { t as claudeHome } from "../home-state-D0RLWP8J.mjs";
5
5
  import { n as stagedContent, r as stagedFiles, t as checkStaged } from "../run-DZvP_9xB.mjs";
6
6
  import { n as writeInitFile, t as initFor } from "../run-Do2JltgU.mjs";
7
- import { Nt as todayUtc, t as handleHook } from "../handle-QfgfNSh6.mjs";
8
- import { delimiter, dirname, join } from "node:path";
7
+ import { F as runDoctor, I as runningVersion, L as versionBanner, Lt as todayUtc, t as handleHook } from "../handle-CVvp1yuc.mjs";
8
+ import { delimiter, join } from "node:path";
9
9
  import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
10
10
  import { homedir } from "node:os";
11
- import { fileURLToPath } from "node:url";
12
11
  //#region src/changelog/fetch.ts
13
12
  /**
14
13
  * Changelog scanner — ports the changelog-watcher plugin's `fetch-changelog`
@@ -354,90 +353,6 @@ function discoverRefs(home, cwd, marketplaces) {
354
353
  return [...bySkill.values()].join(delimiter);
355
354
  }
356
355
  //#endregion
357
- //#region src/cli/doctor.ts
358
- /**
359
- * `harness doctor` — diagnose which `@fusengine/harness` is actually running.
360
- *
361
- * A confirmed, still-open bun bug (oven-sh/bun #5791; scoped-pkg behaviour
362
- * reinforced by #32019/#32150) makes `bunx <pkg>` (unpinned) prefer a stale
363
- * GLOBAL install over npm-latest, so a consumer can silently run an old harness
364
- * after a publish. This command surfaces the truth: the resolved version +
365
- * package path of the code executing right now, the runtime binary, and the
366
- * latest version published on npm. It queries the registry over HTTP (not
367
- * `npm view`, whose exit code is 0 even on an empty result — npm/cli#6408) and
368
- * never throws: an offline environment yields `latest: null`, never a crash.
369
- */
370
- const PKG = "@fusengine/harness";
371
- /** Walk up from `startDir` for the `@fusengine/harness` `package.json`. */
372
- function findPackage(startDir) {
373
- let dir = startDir;
374
- for (let depth = 0; depth < 6; depth++) {
375
- try {
376
- const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
377
- if (pkg.name === PKG) return {
378
- version: pkg.version ?? "unknown",
379
- path: dir
380
- };
381
- } catch {}
382
- const parent = dirname(dir);
383
- if (parent === dir) break;
384
- dir = parent;
385
- }
386
- return null;
387
- }
388
- /** Resolve the running version + package path (no network), from a module URL. */
389
- function runningVersion(moduleUrl) {
390
- const found = findPackage(dirname(fileURLToPath(moduleUrl)));
391
- return {
392
- version: found?.version ?? "unknown",
393
- path: found?.path ?? "unknown"
394
- };
395
- }
396
- /** One-line `pkg vX.Y.Z` banner (stderr, only on explicit `--version`/`doctor` commands — never on `hook`, to avoid spamming automated invocations). */
397
- function versionBanner(moduleUrl) {
398
- return `${PKG} v${runningVersion(moduleUrl).version}`;
399
- }
400
- /** Latest published version via the npm registry HTTP API. `null` on any failure. */
401
- async function npmLatest() {
402
- try {
403
- const res = await fetch(`https://registry.npmjs.org/${PKG}/latest`, { signal: AbortSignal.timeout(8e3) });
404
- if (!res.ok) return null;
405
- return (await res.json()).version ?? null;
406
- } catch {
407
- return null;
408
- }
409
- }
410
- /** Build the full diagnostic report for the module at `moduleUrl`. */
411
- async function buildDoctorReport(moduleUrl) {
412
- const { version, path } = runningVersion(moduleUrl);
413
- const latest = await npmLatest();
414
- return {
415
- running: version,
416
- packagePath: path,
417
- runtime: process.execPath,
418
- latest,
419
- stale: latest !== null && latest !== version
420
- };
421
- }
422
- /** Render a {@link DoctorReport} as human-readable stdout text. */
423
- function formatDoctor(r) {
424
- const lines = [
425
- `${PKG} doctor`,
426
- ` running: ${r.running}`,
427
- ` package: ${r.packagePath}`,
428
- ` runtime: ${r.runtime}`,
429
- ` npm latest: ${r.latest ?? "(unavailable — offline or unreachable)"}`
430
- ];
431
- if (r.stale) lines.push(` ! stale — npm serves ${r.latest}. Pin "@fusengine/harness@${r.latest}" in hooks.json (see README).`);
432
- else if (r.latest !== null) lines.push(` ok — running the latest published version.`);
433
- return lines.join("\n");
434
- }
435
- /** Run `harness doctor`: print the diagnostic to stdout. Always resolves 0 (pure info). */
436
- async function runDoctor(moduleUrl) {
437
- process.stdout.write(formatDoctor(await buildDoctorReport(moduleUrl)) + "\n");
438
- return 0;
439
- }
440
- //#endregion
441
356
  //#region src/cli/bin.ts
442
357
  /**
443
358
  * harness — CLI for @fusengine/harness.