@orkestrel/probe 0.0.2 → 0.0.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.
@@ -686,11 +686,11 @@ var Overlay = class {
686
686
  };
687
687
  //#endregion
688
688
  //#region package.json
689
- var version = "0.0.2";
689
+ var version = "0.0.3";
690
690
  var peerDependencies = {
691
- "oxlint": "^1.77.0",
692
- "typescript": "^6.0.0",
693
- "vitest": "^4.1.0"
691
+ "oxlint": "^1.79.0",
692
+ "typescript": "^6.0.3",
693
+ "vitest": "^4.1.11"
694
694
  };
695
695
  //#endregion
696
696
  //#region src/server/stages/LintStage.ts
@@ -1799,25 +1799,53 @@ var TypeStage = class {
1799
1799
  });
1800
1800
  this.#options.set(path, parsed.options);
1801
1801
  this.#files.set(path, parsed.fileNames);
1802
- const service = typescript.createLanguageService({
1803
- getCompilationSettings: () => this.#options.get(path) ?? {},
1804
- getScriptFileNames: () => [...this.#files.get(path) ?? [], ...this.#overlay.paths],
1805
- getScriptVersion: (file) => this.#version(file),
1806
- getScriptSnapshot: (file) => this.#snapshot(typescript, file),
1807
- getCurrentDirectory: () => this.#workspace,
1808
- getDefaultLibFileName: (options) => typescript.getDefaultLibFilePath(options),
1809
- fileExists: (file) => this.#overlay.text(file) !== void 0 || typescript.sys.fileExists(file),
1810
- readFile: (file) => this.#overlay.text(file) ?? typescript.sys.readFile(file),
1802
+ const host = {
1803
+ getCompilationSettings: this.#compilationSettings.bind(this, path),
1804
+ getScriptFileNames: this.#scriptFiles.bind(this, path),
1805
+ getScriptVersion: this.#version.bind(this),
1806
+ getScriptSnapshot: this.#snapshot.bind(this, typescript),
1807
+ getCurrentDirectory: this.#directory.bind(this),
1808
+ getDefaultLibFileName: this.#defaultLibrary.bind(this, typescript),
1809
+ fileExists: this.#fileExists.bind(this, typescript),
1810
+ readFile: this.#readFile.bind(this, typescript),
1811
1811
  readDirectory: typescript.sys.readDirectory,
1812
- directoryExists: (directory) => typescript.sys.directoryExists(directory) || this.#overlay.covers(directory),
1812
+ directoryExists: this.#directoryExists.bind(this, typescript),
1813
1813
  getDirectories: typescript.sys.getDirectories,
1814
- useCaseSensitiveFileNames: () => typescript.sys.useCaseSensitiveFileNames,
1815
- getNewLine: () => typescript.sys.newLine
1816
- });
1814
+ useCaseSensitiveFileNames: this.#caseSensitive.bind(this, typescript),
1815
+ getNewLine: this.#newline.bind(this, typescript)
1816
+ };
1817
+ const service = typescript.createLanguageService(host);
1817
1818
  this.#services.set(path, service);
1818
1819
  if (!this.#resident.has(path)) this.#recycle(path);
1819
1820
  return service;
1820
1821
  }
1822
+ #compilationSettings(path) {
1823
+ return this.#options.get(path) ?? {};
1824
+ }
1825
+ #scriptFiles(path) {
1826
+ return [...this.#files.get(path) ?? [], ...this.#overlay.paths];
1827
+ }
1828
+ #directory() {
1829
+ return this.#workspace;
1830
+ }
1831
+ #defaultLibrary(typescript, options) {
1832
+ return typescript.getDefaultLibFilePath(options);
1833
+ }
1834
+ #fileExists(typescript, file) {
1835
+ return this.#overlay.text(file) !== void 0 || typescript.sys.fileExists(file);
1836
+ }
1837
+ #readFile(typescript, file) {
1838
+ return this.#overlay.text(file) ?? typescript.sys.readFile(file);
1839
+ }
1840
+ #directoryExists(typescript, directory) {
1841
+ return typescript.sys.directoryExists(directory) || this.#overlay.covers(directory);
1842
+ }
1843
+ #caseSensitive(typescript) {
1844
+ return typescript.sys.useCaseSensitiveFileNames;
1845
+ }
1846
+ #newline(typescript) {
1847
+ return typescript.sys.newLine;
1848
+ }
1821
1849
  #translate(typescript, message, path) {
1822
1850
  return normalizePath(typescript.flattenDiagnosticMessageText(message, "\n")).replaceAll(normalizePath(path), relativeWorkspaceFile(this.#workspace, path));
1823
1851
  }
@@ -1947,17 +1975,17 @@ var Probe = class {
1947
1975
  this.#typeQueue = (0, _orkestrel_queue.createQueue)({
1948
1976
  concurrency: 1,
1949
1977
  retries: 0,
1950
- handler: (inspection) => this.#inspectStage(this.#type, this.#type.progress, this.#type.inspect(inspection.subject, inspection.claim.project), inspection.claim)
1978
+ handler: this.#inspectType.bind(this)
1951
1979
  });
1952
1980
  this.#lintQueue = (0, _orkestrel_queue.createQueue)({
1953
1981
  concurrency: 1,
1954
1982
  retries: 0,
1955
- handler: (inspection) => this.#inspectStage(this.#lint, this.#lint.progress, this.#lint.inspect(inspection.subject), inspection.claim)
1983
+ handler: this.#inspectLint.bind(this)
1956
1984
  });
1957
1985
  this.#runtimeQueue = (0, _orkestrel_queue.createQueue)({
1958
1986
  concurrency: 1,
1959
1987
  retries: 0,
1960
- handler: (inspection) => this.#inspectStage(this.#runtime, this.#runtime.progress, this.#runtime.inspect(inspection.subject), inspection.claim)
1988
+ handler: this.#inspectRuntime.bind(this)
1961
1989
  });
1962
1990
  this.#arming = this.#arm();
1963
1991
  this.#arming.catch(() => {});
@@ -2157,6 +2185,15 @@ var Probe = class {
2157
2185
  for (const pending of admitted) pending.catch(() => {});
2158
2186
  return Promise.all(admitted);
2159
2187
  }
2188
+ #inspectType(inspection) {
2189
+ return this.#inspectStage(this.#type, this.#type.progress, this.#type.inspect(inspection.subject, inspection.claim.project), inspection.claim);
2190
+ }
2191
+ #inspectLint(inspection) {
2192
+ return this.#inspectStage(this.#lint, this.#lint.progress, this.#lint.inspect(inspection.subject), inspection.claim);
2193
+ }
2194
+ #inspectRuntime(inspection) {
2195
+ return this.#inspectStage(this.#runtime, this.#runtime.progress, this.#runtime.inspect(inspection.subject), inspection.claim);
2196
+ }
2160
2197
  async #inspectStage(stage, progress, operation, claim) {
2161
2198
  const timeout = (0, _orkestrel_timeout.createTimeout)({ ms: this.#deadline });
2162
2199
  timeout.start();
@@ -2343,17 +2380,7 @@ var ProbeServer = class {
2343
2380
  name: "prove",
2344
2381
  description: "Answers whether a TypeScript edit compiles, lints, and passes its test in this workspace — call it before relying on such a claim, instead of reasoning or writing a throwaway probe. Supply the edit you believe is correct and an edit that must break with the stage it breaks at; the closing line is a receipt only when the case ran clean and the control broke exactly at its declared stage, and no receipt otherwise. For a performance claim, measure before proving: write a guarded bench block — if (import.meta.env.MODE === 'benchmark') — beside the probe test, run the workspace bench script, and record only magnitudes; a settled ratio then proves here as an ordinary runtime claim.",
2345
2382
  parameters,
2346
- execute: async (input) => {
2347
- if (!(0, _src_core.isClaim)(input)) {
2348
- const refused = findRefusedPaths(input);
2349
- throw new _src_core.ProbeError(refused.length === 0 ? "The prove tool requires a claim matching the advertised schema" : `The prove tool refuses ${refused.join(", ")}: a draft path must stay inside the workspace, which the advertised schema does not constrain`, {
2350
- origin: "claimant",
2351
- code: "refused",
2352
- context: { value: input }
2353
- });
2354
- }
2355
- return this.#probe.prove(input);
2356
- }
2383
+ execute: this.#prove.bind(this)
2357
2384
  }));
2358
2385
  return (0, _orkestrel_mcp.createMCPServer)({
2359
2386
  identity: {
@@ -2361,23 +2388,35 @@ var ProbeServer = class {
2361
2388
  version
2362
2389
  },
2363
2390
  tools,
2364
- execution: async ({ call }) => {
2365
- const result = await tools.execute(call);
2366
- if (!result.success) return result;
2367
- if (!(0, _src_core.isVerdict)(result.value)) throw new _src_core.ProbeError("The prove tool returned an invalid verdict", {
2368
- origin: "instrument",
2369
- code: "malformed",
2370
- context: { value: result.value }
2371
- });
2372
- return {
2373
- resultType: "complete",
2374
- content: [{
2375
- type: "text",
2376
- text: (0, _src_core.formatVerdict)(result.value)
2377
- }]
2378
- };
2379
- }
2391
+ execution: this.#execute.bind(this)
2392
+ });
2393
+ }
2394
+ async #prove(input) {
2395
+ if (!(0, _src_core.isClaim)(input)) {
2396
+ const refused = findRefusedPaths(input);
2397
+ throw new _src_core.ProbeError(refused.length === 0 ? "The prove tool requires a claim matching the advertised schema" : `The prove tool refuses ${refused.join(", ")}: a draft path must stay inside the workspace, which the advertised schema does not constrain`, {
2398
+ origin: "claimant",
2399
+ code: "refused",
2400
+ context: { value: input }
2401
+ });
2402
+ }
2403
+ return this.#probe.prove(input);
2404
+ }
2405
+ async #execute(context) {
2406
+ const result = await context.tools.execute(context.call);
2407
+ if (!result.success) return result;
2408
+ if (!(0, _src_core.isVerdict)(result.value)) throw new _src_core.ProbeError("The prove tool returned an invalid verdict", {
2409
+ origin: "instrument",
2410
+ code: "malformed",
2411
+ context: { value: result.value }
2380
2412
  });
2413
+ return {
2414
+ resultType: "complete",
2415
+ content: [{
2416
+ type: "text",
2417
+ text: (0, _src_core.formatVerdict)(result.value)
2418
+ }]
2419
+ };
2381
2420
  }
2382
2421
  };
2383
2422
  //#endregion