@orkestrel/probe 0.0.15 → 0.0.17

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.
@@ -61,11 +61,11 @@ function normalizePath(path) {
61
61
  * ```
62
62
  */
63
63
  function readFaultCode(error) {
64
- if (typeof error !== "object" || error === null) return void 0;
64
+ if (!(0, _orkestrel_contract.isObject)(error)) return void 0;
65
65
  const fault = error;
66
66
  const reading = (0, _orkestrel_contract.attempt)(() => "code" in fault ? fault.code : void 0);
67
67
  if (!reading.success) return void 0;
68
- return typeof reading.value === "string" ? reading.value : void 0;
68
+ return (0, _orkestrel_contract.isString)(reading.value) ? reading.value : void 0;
69
69
  }
70
70
  /**
71
71
  * Reports whether one path resolves outside the root it is read against.
@@ -152,7 +152,7 @@ function resolveWorkspaceFile(workspace, target, mutate = false) {
152
152
  });
153
153
  }
154
154
  } catch (error) {
155
- if (error instanceof _src_core.ProbeError) throw error;
155
+ if ((0, _src_core.isProbeError)(error)) throw error;
156
156
  const code = readFaultCode(error);
157
157
  const claimant = code === "ENAMETOOLONG" || code === "ERR_INVALID_ARG_VALUE";
158
158
  throw new _src_core.ProbeError(`The workspace path cannot be inspected: ${target}`, {
@@ -196,7 +196,7 @@ function resolveWorkspaceFile(workspace, target, mutate = false) {
196
196
  *
197
197
  * @example
198
198
  * ```ts
199
- * const file = resolveWorkspaceFile('/srv/checkout', 'tmp/probe/arm-type.ts', true)
199
+ * const file = resolveWorkspaceFile('/srv/checkout', 'tmp/probes/arm-type.ts', true)
200
200
  * writeFileSync(file, 'export type Signal = string\n', { encoding: 'utf8', flag: 'wx' })
201
201
  * overwriteFile(file, 'export type Signal = number\n')
202
202
  * readFileSync(file, 'utf8') // 'export type Signal = number\n'
@@ -239,11 +239,11 @@ function overwriteFile(file, text) {
239
239
  * @example
240
240
  * ```ts
241
241
  * try {
242
- * writeFileSync('tmp/probe/greeting\0.test.ts', '')
242
+ * writeFileSync('tmp/probes/greeting\0.test.ts', '')
243
243
  * } catch (error) {
244
- * isRefusedName('tmp/probe/greeting\0.test.ts', error) // true
244
+ * isRefusedName('tmp/probes/greeting\0.test.ts', error) // true
245
245
  * }
246
- * isRefusedName('tmp/probe/greeting.test.ts', new Error('the runtime stage was destroyed')) // false
246
+ * isRefusedName('tmp/probes/greeting.test.ts', new Error('the runtime stage was destroyed')) // false
247
247
  * ```
248
248
  */
249
249
  function isRefusedName(file, error) {
@@ -460,7 +460,7 @@ function readWorkspaceManifest(workspace, name) {
460
460
  try {
461
461
  path = resolveWorkspaceModule(workspace, `${name}/package.json`);
462
462
  } catch (error) {
463
- if (!(error instanceof _src_core.ProbeError)) throw error;
463
+ if (!(0, _src_core.isProbeError)(error)) throw error;
464
464
  throw new _src_core.ProbeError(`${name} does not publish a readable manifest`, {
465
465
  origin: "workspace",
466
466
  code: error.code,
@@ -537,14 +537,14 @@ function resolveWorkspaceBinary(workspace, name, command = name) {
537
537
  code: "missing",
538
538
  context: { name }
539
539
  });
540
- if (typeof bin === "string") return (0, node_path.resolve)(manifest.path, "..", bin);
540
+ if ((0, _orkestrel_contract.isString)(bin)) return (0, node_path.resolve)(manifest.path, "..", bin);
541
541
  if (!(0, _orkestrel_contract.isRecord)(bin) || !(command in bin)) throw new _src_core.ProbeError(`${name} does not publish the ${command} binary`, {
542
542
  origin: "workspace",
543
543
  code: "missing",
544
544
  context: { name }
545
545
  });
546
546
  const entry = bin[command];
547
- if (typeof entry !== "string") throw new _src_core.ProbeError(`${name} publishes an invalid ${command} binary`, {
547
+ if (!(0, _orkestrel_contract.isString)(entry)) throw new _src_core.ProbeError(`${name} publishes an invalid ${command} binary`, {
548
548
  origin: "workspace",
549
549
  code: "malformed",
550
550
  context: {
@@ -590,14 +590,14 @@ function inferTypeProject(path) {
590
590
  *
591
591
  * @example
592
592
  * ```ts
593
- * inferTestProject('tmp/probe/greeting.test.ts') // 'probe'
593
+ * inferTestProject('tmp/probes/greeting.test.ts') // 'probe'
594
594
  * inferTestProject('tests/src/server/helpers.test.ts') // 'src:server'
595
595
  * inferTestProject('tests/config.test.ts') // undefined
596
596
  * ```
597
597
  */
598
598
  function inferTestProject(path) {
599
599
  const [root, axis, environment] = normalizePath(path).split("/");
600
- if (root === "tmp" && axis === "probe") return "probe";
600
+ if (root === "tmp" && axis === "probes") return "probe";
601
601
  if (root !== "tests" || axis === void 0 || environment === void 0) return void 0;
602
602
  if (axis !== "src" && axis !== "app") return void 0;
603
603
  return `${axis}:${environment}`;
@@ -634,9 +634,9 @@ function inferDocumentLanguage(path) {
634
634
  * ```ts
635
635
  * relativeWorkspaceFile(
636
636
  * '/srv/checkout',
637
- * buildRevisionPath('/srv/checkout', 'tmp/probe/greeting.test.ts', '4821-9f0c'),
637
+ * buildRevisionPath('/srv/checkout', 'tmp/probes/greeting.test.ts', '4821-9f0c'),
638
638
  * )
639
- * // 'tmp/probe/greeting.test.probe-4821-9f0c.ts'
639
+ * // 'tmp/probes/greeting.test.probe-4821-9f0c.ts'
640
640
  * ```
641
641
  */
642
642
  function buildRevisionPath(workspace, path, revision) {
@@ -711,7 +711,7 @@ function matchesWorkspaceModule(path) {
711
711
  * ```
712
712
  */
713
713
  function matchesLiveProcess(id) {
714
- if (!Number.isSafeInteger(id) || id <= 0) return true;
714
+ if (!(0, _orkestrel_contract.isNumber)(id) || !Number.isSafeInteger(id) || id <= 0) return true;
715
715
  try {
716
716
  process.kill(id, 0);
717
717
  return true;
@@ -775,8 +775,8 @@ function collectWorkspaceFiles(workspace) {
775
775
  * ```
776
776
  */
777
777
  function describeUnknown(value) {
778
- if (value instanceof Error) return value.message;
779
- if (typeof value === "object" && value !== null && "message" in value && typeof value.message === "string") return value.message;
778
+ if ((0, _orkestrel_contract.isError)(value)) return value.message;
779
+ if ((0, _orkestrel_contract.isObject)(value) && "message" in value && (0, _orkestrel_contract.isString)(value.message)) return value.message;
780
780
  return String(value);
781
781
  }
782
782
  /**
@@ -796,7 +796,7 @@ async function guardStage(stage, operation) {
796
796
  try {
797
797
  return await operation;
798
798
  } catch (error) {
799
- if (error instanceof _src_core.ProbeError) throw error;
799
+ if ((0, _src_core.isProbeError)(error)) throw error;
800
800
  throw new _src_core.ProbeError(`The ${stage} stage could not serve (${describeUnknown(error)})`, {
801
801
  origin: "instrument",
802
802
  code: "malformed",
@@ -826,7 +826,7 @@ async function guardStage(stage, operation) {
826
826
  *
827
827
  * @example
828
828
  * ```ts
829
- * const test = { path: 'tmp/probe/greeting.test.ts', text: '' }
829
+ * const test = { path: 'tmp/probes/greeting.test.ts', text: '' }
830
830
  * findRefusedPaths({
831
831
  * project: 'tsconfig.json',
832
832
  * case: { files: [{ path: '../../etc/hosts', text: '' }], test },
@@ -873,7 +873,7 @@ function findRefusedPaths(value) {
873
873
  */
874
874
  function normalizeValue(workspace, value) {
875
875
  const root = (0, node_path.resolve)(workspace);
876
- if (typeof value === "string") {
876
+ if ((0, _orkestrel_contract.isString)(value)) {
877
877
  if (!(0, node_path.isAbsolute)(value)) return value;
878
878
  const path = (0, node_path.relative)(root, (0, node_path.resolve)(value));
879
879
  if (path === "") return ".";
@@ -983,14 +983,14 @@ function releaseListeners(emitter, capture) {
983
983
  * ```
984
984
  */
985
985
  function parseProjectConfig(text) {
986
- const parsed = (0, _orkestrel_contract.attempt)(() => JSON.parse(text));
987
- if (!parsed.success || !(0, _orkestrel_contract.isRecord)(parsed.value)) return void 0;
988
- const files = parsed.value.files;
989
- const include = parsed.value.include;
986
+ const parsed = (0, _orkestrel_contract.parseJSON)(text);
987
+ if (!(0, _orkestrel_contract.isRecord)(parsed)) return void 0;
988
+ const files = parsed.files;
989
+ const include = parsed.include;
990
990
  return {
991
- compilerOptions: parsed.value.compilerOptions,
992
- ...(0, _orkestrel_contract.isArray)(files) && files.every((entry) => typeof entry === "string") ? { files } : {},
993
- ...(0, _orkestrel_contract.isArray)(include) && include.every((entry) => typeof entry === "string") ? { include } : {}
991
+ compilerOptions: parsed.compilerOptions,
992
+ ...(0, _orkestrel_contract.isArray)(files) && files.every(_orkestrel_contract.isString) ? { files } : {},
993
+ ...(0, _orkestrel_contract.isArray)(include) && include.every(_orkestrel_contract.isString) ? { include } : {}
994
994
  };
995
995
  }
996
996
  /**
@@ -1104,9 +1104,9 @@ var Overlay = class {
1104
1104
  };
1105
1105
  //#endregion
1106
1106
  //#region package.json
1107
- var version = "0.0.15";
1107
+ var version = "0.0.17";
1108
1108
  var peerDependencies = {
1109
- "oxlint": "^1.82.0",
1109
+ "oxlint": "^1.86.0",
1110
1110
  "typescript": "^6.0.3",
1111
1111
  "vitest": "^4.1.11"
1112
1112
  };
@@ -1279,7 +1279,7 @@ var LintStage = class {
1279
1279
  if (this.#closing !== void 0) return (0, _src_core.createDestroyedError)("lint stage");
1280
1280
  const ending = this.#ending;
1281
1281
  if (ending !== void 0) return this.#fault(`The Oxlint language server exited with ${ending}`, error, path);
1282
- if (error instanceof Error) return error;
1282
+ if ((0, _orkestrel_contract.isError)(error)) return error;
1283
1283
  return this.#fault(describeUnknown(error), error, path);
1284
1284
  }
1285
1285
  #fault(message, cause, path) {
@@ -1450,7 +1450,7 @@ var RuntimeStage = class {
1450
1450
  for (const draft of subject.files) overlay.set(resolveWorkspaceFile(this.#workspace, draft.path), draft.text);
1451
1451
  this.#revalidate(vitest);
1452
1452
  const specification = this.#specification(subject.test);
1453
- if (typeof specification !== "string") return {
1453
+ if (!(0, _orkestrel_contract.isString)(specification)) return {
1454
1454
  stage: this.stage,
1455
1455
  elapsed: Math.round(performance.now() - started),
1456
1456
  issues: [specification]
@@ -1467,7 +1467,7 @@ var RuntimeStage = class {
1467
1467
  const result = await vitest.runTestSpecifications([task], false);
1468
1468
  issues = [...this.#issues(result, file, subject.test.path), ...this.#misses(project, file)];
1469
1469
  } catch (error) {
1470
- if (error instanceof _src_core.ProbeError) throw error;
1470
+ if ((0, _src_core.isProbeError)(error)) throw error;
1471
1471
  throw new _src_core.ProbeError(`The runtime stage could not run the generated specification (${describeUnknown(error)})`, {
1472
1472
  origin: "instrument",
1473
1473
  code: "malformed",
@@ -1488,7 +1488,7 @@ var RuntimeStage = class {
1488
1488
  if ((0, node_fs.existsSync)(contained)) (0, node_fs.unlinkSync)(contained);
1489
1489
  } catch (error) {
1490
1490
  cleanup = [...cleanup, {
1491
- origin: error instanceof _src_core.ProbeError && error.origin === "workspace" ? "workspace" : "instrument",
1491
+ origin: (0, _src_core.isProbeError)(error) && error.origin === "workspace" ? "workspace" : "instrument",
1492
1492
  path: relativeWorkspaceFile(this.#workspace, file),
1493
1493
  message: `The runtime stage could not delete the generated specification (${describeUnknown(error)})`
1494
1494
  }];
@@ -1567,7 +1567,7 @@ var RuntimeStage = class {
1567
1567
  test.projects = test.projects.map((project) => this.#augment(project));
1568
1568
  }
1569
1569
  #augment(project) {
1570
- if (typeof project === "string") return project;
1570
+ if ((0, _orkestrel_contract.isString)(project)) return project;
1571
1571
  if (typeof project === "function") return this.#wrap(project);
1572
1572
  return Promise.resolve(project).then(this.#instrument.bind(this));
1573
1573
  }
@@ -1635,7 +1635,7 @@ var RuntimeStage = class {
1635
1635
  return file;
1636
1636
  });
1637
1637
  if (outcome.success) return outcome.value;
1638
- if (outcome.error instanceof _src_core.ProbeError && outcome.error.origin === "claimant") throw new _src_core.ProbeError(outcome.error.message, {
1638
+ if ((0, _src_core.isProbeError)(outcome.error) && outcome.error.origin === "claimant") throw new _src_core.ProbeError(outcome.error.message, {
1639
1639
  origin: outcome.error.origin,
1640
1640
  code: outcome.error.code,
1641
1641
  context: {
@@ -1654,7 +1654,7 @@ var RuntimeStage = class {
1654
1654
  cause: outcome.error
1655
1655
  });
1656
1656
  return {
1657
- origin: outcome.error instanceof _src_core.ProbeError && outcome.error.origin === "workspace" || creating ? "workspace" : "instrument",
1657
+ origin: (0, _src_core.isProbeError)(outcome.error) && outcome.error.origin === "workspace" || creating ? "workspace" : "instrument",
1658
1658
  path: test.path,
1659
1659
  message: `The runtime stage could not write the generated specification (${describeUnknown(outcome.error)})`
1660
1660
  };
@@ -1914,29 +1914,29 @@ var RuntimeStage = class {
1914
1914
  }
1915
1915
  #issue(error, specification, original) {
1916
1916
  const message = relativeWorkspaceMessage(this.#workspace, describeUnknown(error)).replaceAll((0, node_path.basename)(specification), (0, node_path.basename)(original));
1917
- if (typeof error !== "object" || error === null || !("stacks" in error)) return {
1917
+ if (!(0, _orkestrel_contract.isObject)(error) || !("stacks" in error)) return {
1918
1918
  origin: "claimant",
1919
1919
  path: original,
1920
1920
  message
1921
1921
  };
1922
1922
  const stacks = error.stacks;
1923
- if (!Array.isArray(stacks)) return {
1923
+ if (!(0, _orkestrel_contract.isArray)(stacks)) return {
1924
1924
  origin: "claimant",
1925
1925
  path: original,
1926
1926
  message
1927
1927
  };
1928
1928
  for (const stack of stacks) {
1929
- if (typeof stack !== "object" || stack === null) continue;
1930
- if (!("file" in stack) || typeof stack.file !== "string") continue;
1929
+ if (!(0, _orkestrel_contract.isObject)(stack)) continue;
1930
+ if (!("file" in stack) || !(0, _orkestrel_contract.isString)(stack.file)) continue;
1931
1931
  const declared = stack.file.startsWith("file:") ? (0, node_url.fileURLToPath)(stack.file) : (0, node_path.isAbsolute)(stack.file) ? stack.file : (0, node_path.resolve)(this.#workspace, stack.file);
1932
1932
  const reported = this.#real(declared);
1933
1933
  const path = reported === specification ? original : relativeWorkspaceFile(this.#real(this.#workspace), reported);
1934
- if (!("line" in stack) || typeof stack.line !== "number") return {
1934
+ if (!("line" in stack) || !(0, _orkestrel_contract.isNumber)(stack.line)) return {
1935
1935
  origin: "claimant",
1936
1936
  path,
1937
1937
  message
1938
1938
  };
1939
- const character = "column" in stack && typeof stack.column === "number" ? stack.column - 1 : 0;
1939
+ const character = "column" in stack && (0, _orkestrel_contract.isNumber)(stack.column) ? stack.column - 1 : 0;
1940
1940
  const position = {
1941
1941
  line: stack.line - 1,
1942
1942
  character
@@ -2462,7 +2462,7 @@ var TypeStage = class {
2462
2462
  * },
2463
2463
  * ],
2464
2464
  * test: {
2465
- * path: 'tmp/probe/greeting.test.ts',
2465
+ * path: 'tmp/probes/greeting.test.ts',
2466
2466
  * text: "import { expect, test } from 'vitest'\nimport { createGreeting } from '../../src/core/factories.js'\ntest('greets', () => expect(createGreeting()).toBe('hi'))\n",
2467
2467
  * },
2468
2468
  * },
@@ -2474,7 +2474,7 @@ var TypeStage = class {
2474
2474
  * },
2475
2475
  * ],
2476
2476
  * test: {
2477
- * path: 'tmp/probe/greeting.test.ts',
2477
+ * path: 'tmp/probes/greeting.test.ts',
2478
2478
  * text: "import { expect, test } from 'vitest'\nimport { createGreeting } from '../../src/core/factories.js'\ntest('greets', () => expect(createGreeting()).toBe('hi'))\n",
2479
2479
  * },
2480
2480
  * stage: 'type',
@@ -2484,8 +2484,8 @@ var TypeStage = class {
2484
2484
  *
2485
2485
  * const probe = new Probe({ workspace: process.cwd() })
2486
2486
  * const verdict = await probe.prove(claim)
2487
- * verdict.digest // 'fcb88a2dee987b8673c1fc7107979470'
2488
- * verdict.receipt // 'probe:fcb88a2dee987b8673c1fc7107979470:type:typescript@6.0.3:oxlint@1.83.0:vitest@4.1.11:configs/src/tsconfig.core.json@434f59254d58cf2683d453a26bd0d837'
2487
+ * verdict.digest // 'bdf03e5dfd6bd413ead671c7a2940fcf'
2488
+ * verdict.receipt // 'probe:bdf03e5dfd6bd413ead671c7a2940fcf:type:typescript@6.0.3:oxlint@1.86.0:vitest@4.1.11:configs/src/tsconfig.core.json@434f59254d58cf2683d453a26bd0d837'
2489
2489
  * await probe.destroy()
2490
2490
  * ```
2491
2491
  */
@@ -2582,7 +2582,7 @@ var Probe = class {
2582
2582
  this.#emitter.emit("prove", verdict);
2583
2583
  return verdict;
2584
2584
  } catch (error) {
2585
- if (!(error instanceof _src_core.ProbeError) || !this.#surfaced.has(error)) this.#emitter.emit("error", error);
2585
+ if (!(0, _src_core.isProbeError)(error) || !this.#surfaced.has(error)) this.#emitter.emit("error", error);
2586
2586
  throw error;
2587
2587
  }
2588
2588
  }
@@ -2627,17 +2627,17 @@ var Probe = class {
2627
2627
  this.#emitter.emit("arm", this.#toolchain);
2628
2628
  }
2629
2629
  #surface(error) {
2630
- if (error instanceof _src_core.ProbeError) this.#surfaced.add(error);
2630
+ if ((0, _src_core.isProbeError)(error)) this.#surfaced.add(error);
2631
2631
  this.#emitter.emit("error", error);
2632
2632
  }
2633
2633
  #workbench() {
2634
- const path = "tmp/probe";
2634
+ const path = "tmp/probes";
2635
2635
  const directory = resolveWorkspaceFile(this.#workspace, path);
2636
2636
  const created = !(0, node_fs.existsSync)(directory);
2637
2637
  try {
2638
2638
  (0, node_fs.mkdirSync)(resolveWorkspaceFile(this.#workspace, path, true), { recursive: true });
2639
2639
  } catch (error) {
2640
- const code = error instanceof _src_core.ProbeError && error.origin === "workspace" ? error.code : "malformed";
2640
+ const code = (0, _src_core.isProbeError)(error) && error.origin === "workspace" ? error.code : "malformed";
2641
2641
  throw new _src_core.ProbeError(`The probe could not create the boot workbench (${describeUnknown(error)})`, {
2642
2642
  origin: "workspace",
2643
2643
  code,
@@ -2649,16 +2649,16 @@ var Probe = class {
2649
2649
  }
2650
2650
  async #boot(created) {
2651
2651
  const revision = `${process.pid}-${(0, node_crypto.randomUUID)()}`;
2652
- const typeDependency = buildRevisionPath(this.#workspace, "tmp/probe/arm-type.ts", revision);
2653
- const runtimeDependency = buildRevisionPath(this.#workspace, "tmp/probe/arm-runtime.ts", revision);
2652
+ const typeDependency = buildRevisionPath(this.#workspace, "tmp/probes/arm-type.ts", revision);
2653
+ const runtimeDependency = buildRevisionPath(this.#workspace, "tmp/probes/arm-runtime.ts", revision);
2654
2654
  const typeModule = (0, node_path.basename)(typeDependency, ".ts");
2655
2655
  const runtimeModule = (0, node_path.basename)(runtimeDependency, ".ts");
2656
2656
  const typeTest = {
2657
- path: `tmp/probe/${typeModule}.test.ts`,
2657
+ path: `tmp/probes/${typeModule}.test.ts`,
2658
2658
  text: `import type { Signal } from './${typeModule}.js'\nimport { expect, test } from 'vitest'\nconst SIGNAL: Signal = 'before'\ntest('revalidates a mutated type', () => {\n\texpect(SIGNAL).toBe('before')\n})\n`
2659
2659
  };
2660
2660
  const runtimeTest = {
2661
- path: `tmp/probe/${runtimeModule}.test.ts`,
2661
+ path: `tmp/probes/${runtimeModule}.test.ts`,
2662
2662
  text: `import { SIGNAL } from './${runtimeModule}.js'\nimport { expect, test } from 'vitest'\ntest('revalidates a mutated value', () => {\n\texpect(SIGNAL).toBe('before')\n})\n`
2663
2663
  };
2664
2664
  const typeClaim = {
@@ -2733,7 +2733,7 @@ var Probe = class {
2733
2733
  (0, node_fs.rmSync)(resolveWorkspaceFile(this.#workspace, (0, node_path.relative)(this.#workspace, typeDependency), true), { force: true });
2734
2734
  (0, node_fs.rmSync)(resolveWorkspaceFile(this.#workspace, (0, node_path.relative)(this.#workspace, runtimeDependency), true), { force: true });
2735
2735
  if (created) try {
2736
- (0, node_fs.rmdirSync)(resolveWorkspaceFile(this.#workspace, "tmp/probe", true));
2736
+ (0, node_fs.rmdirSync)(resolveWorkspaceFile(this.#workspace, "tmp/probes", true));
2737
2737
  } catch {}
2738
2738
  }
2739
2739
  }
@@ -2873,12 +2873,12 @@ var Probe = class {
2873
2873
  try {
2874
2874
  await this.#bound(() => stage.destroy(), `The ${stage.stage} stage teardown exceeded ${this.#deadline} ms`, stage, stage.progress);
2875
2875
  } catch (error) {
2876
- if (!(error instanceof _src_core.ProbeError) || !this.#deadlines.has(error)) throw error;
2876
+ if (!(0, _src_core.isProbeError)(error) || !this.#deadlines.has(error)) throw error;
2877
2877
  }
2878
2878
  }
2879
2879
  #version(name) {
2880
2880
  const version = readWorkspaceManifest(this.#workspace, name).contents.version;
2881
- if (typeof version !== "string") throw new _src_core.ProbeError(`${name} publishes no readable version`, {
2881
+ if (!(0, _orkestrel_contract.isString)(version)) throw new _src_core.ProbeError(`${name} publishes no readable version`, {
2882
2882
  origin: "workspace",
2883
2883
  code: "malformed",
2884
2884
  context: { name }