@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.
@@ -685,11 +685,11 @@ var Overlay = class {
685
685
  };
686
686
  //#endregion
687
687
  //#region package.json
688
- var version = "0.0.2";
688
+ var version = "0.0.3";
689
689
  var peerDependencies = {
690
- "oxlint": "^1.77.0",
691
- "typescript": "^6.0.0",
692
- "vitest": "^4.1.0"
690
+ "oxlint": "^1.79.0",
691
+ "typescript": "^6.0.3",
692
+ "vitest": "^4.1.11"
693
693
  };
694
694
  //#endregion
695
695
  //#region src/server/stages/LintStage.ts
@@ -1798,25 +1798,53 @@ var TypeStage = class {
1798
1798
  });
1799
1799
  this.#options.set(path, parsed.options);
1800
1800
  this.#files.set(path, parsed.fileNames);
1801
- const service = typescript.createLanguageService({
1802
- getCompilationSettings: () => this.#options.get(path) ?? {},
1803
- getScriptFileNames: () => [...this.#files.get(path) ?? [], ...this.#overlay.paths],
1804
- getScriptVersion: (file) => this.#version(file),
1805
- getScriptSnapshot: (file) => this.#snapshot(typescript, file),
1806
- getCurrentDirectory: () => this.#workspace,
1807
- getDefaultLibFileName: (options) => typescript.getDefaultLibFilePath(options),
1808
- fileExists: (file) => this.#overlay.text(file) !== void 0 || typescript.sys.fileExists(file),
1809
- readFile: (file) => this.#overlay.text(file) ?? typescript.sys.readFile(file),
1801
+ const host = {
1802
+ getCompilationSettings: this.#compilationSettings.bind(this, path),
1803
+ getScriptFileNames: this.#scriptFiles.bind(this, path),
1804
+ getScriptVersion: this.#version.bind(this),
1805
+ getScriptSnapshot: this.#snapshot.bind(this, typescript),
1806
+ getCurrentDirectory: this.#directory.bind(this),
1807
+ getDefaultLibFileName: this.#defaultLibrary.bind(this, typescript),
1808
+ fileExists: this.#fileExists.bind(this, typescript),
1809
+ readFile: this.#readFile.bind(this, typescript),
1810
1810
  readDirectory: typescript.sys.readDirectory,
1811
- directoryExists: (directory) => typescript.sys.directoryExists(directory) || this.#overlay.covers(directory),
1811
+ directoryExists: this.#directoryExists.bind(this, typescript),
1812
1812
  getDirectories: typescript.sys.getDirectories,
1813
- useCaseSensitiveFileNames: () => typescript.sys.useCaseSensitiveFileNames,
1814
- getNewLine: () => typescript.sys.newLine
1815
- });
1813
+ useCaseSensitiveFileNames: this.#caseSensitive.bind(this, typescript),
1814
+ getNewLine: this.#newline.bind(this, typescript)
1815
+ };
1816
+ const service = typescript.createLanguageService(host);
1816
1817
  this.#services.set(path, service);
1817
1818
  if (!this.#resident.has(path)) this.#recycle(path);
1818
1819
  return service;
1819
1820
  }
1821
+ #compilationSettings(path) {
1822
+ return this.#options.get(path) ?? {};
1823
+ }
1824
+ #scriptFiles(path) {
1825
+ return [...this.#files.get(path) ?? [], ...this.#overlay.paths];
1826
+ }
1827
+ #directory() {
1828
+ return this.#workspace;
1829
+ }
1830
+ #defaultLibrary(typescript, options) {
1831
+ return typescript.getDefaultLibFilePath(options);
1832
+ }
1833
+ #fileExists(typescript, file) {
1834
+ return this.#overlay.text(file) !== void 0 || typescript.sys.fileExists(file);
1835
+ }
1836
+ #readFile(typescript, file) {
1837
+ return this.#overlay.text(file) ?? typescript.sys.readFile(file);
1838
+ }
1839
+ #directoryExists(typescript, directory) {
1840
+ return typescript.sys.directoryExists(directory) || this.#overlay.covers(directory);
1841
+ }
1842
+ #caseSensitive(typescript) {
1843
+ return typescript.sys.useCaseSensitiveFileNames;
1844
+ }
1845
+ #newline(typescript) {
1846
+ return typescript.sys.newLine;
1847
+ }
1820
1848
  #translate(typescript, message, path) {
1821
1849
  return normalizePath(typescript.flattenDiagnosticMessageText(message, "\n")).replaceAll(normalizePath(path), relativeWorkspaceFile(this.#workspace, path));
1822
1850
  }
@@ -1946,17 +1974,17 @@ var Probe = class {
1946
1974
  this.#typeQueue = createQueue({
1947
1975
  concurrency: 1,
1948
1976
  retries: 0,
1949
- handler: (inspection) => this.#inspectStage(this.#type, this.#type.progress, this.#type.inspect(inspection.subject, inspection.claim.project), inspection.claim)
1977
+ handler: this.#inspectType.bind(this)
1950
1978
  });
1951
1979
  this.#lintQueue = createQueue({
1952
1980
  concurrency: 1,
1953
1981
  retries: 0,
1954
- handler: (inspection) => this.#inspectStage(this.#lint, this.#lint.progress, this.#lint.inspect(inspection.subject), inspection.claim)
1982
+ handler: this.#inspectLint.bind(this)
1955
1983
  });
1956
1984
  this.#runtimeQueue = createQueue({
1957
1985
  concurrency: 1,
1958
1986
  retries: 0,
1959
- handler: (inspection) => this.#inspectStage(this.#runtime, this.#runtime.progress, this.#runtime.inspect(inspection.subject), inspection.claim)
1987
+ handler: this.#inspectRuntime.bind(this)
1960
1988
  });
1961
1989
  this.#arming = this.#arm();
1962
1990
  this.#arming.catch(() => {});
@@ -2156,6 +2184,15 @@ var Probe = class {
2156
2184
  for (const pending of admitted) pending.catch(() => {});
2157
2185
  return Promise.all(admitted);
2158
2186
  }
2187
+ #inspectType(inspection) {
2188
+ return this.#inspectStage(this.#type, this.#type.progress, this.#type.inspect(inspection.subject, inspection.claim.project), inspection.claim);
2189
+ }
2190
+ #inspectLint(inspection) {
2191
+ return this.#inspectStage(this.#lint, this.#lint.progress, this.#lint.inspect(inspection.subject), inspection.claim);
2192
+ }
2193
+ #inspectRuntime(inspection) {
2194
+ return this.#inspectStage(this.#runtime, this.#runtime.progress, this.#runtime.inspect(inspection.subject), inspection.claim);
2195
+ }
2159
2196
  async #inspectStage(stage, progress, operation, claim) {
2160
2197
  const timeout = createTimeout({ ms: this.#deadline });
2161
2198
  timeout.start();
@@ -2342,17 +2379,7 @@ var ProbeServer = class {
2342
2379
  name: "prove",
2343
2380
  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.",
2344
2381
  parameters,
2345
- execute: async (input) => {
2346
- if (!isClaim(input)) {
2347
- const refused = findRefusedPaths(input);
2348
- throw new 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`, {
2349
- origin: "claimant",
2350
- code: "refused",
2351
- context: { value: input }
2352
- });
2353
- }
2354
- return this.#probe.prove(input);
2355
- }
2382
+ execute: this.#prove.bind(this)
2356
2383
  }));
2357
2384
  return createMCPServer({
2358
2385
  identity: {
@@ -2360,23 +2387,35 @@ var ProbeServer = class {
2360
2387
  version
2361
2388
  },
2362
2389
  tools,
2363
- execution: async ({ call }) => {
2364
- const result = await tools.execute(call);
2365
- if (!result.success) return result;
2366
- if (!isVerdict(result.value)) throw new ProbeError("The prove tool returned an invalid verdict", {
2367
- origin: "instrument",
2368
- code: "malformed",
2369
- context: { value: result.value }
2370
- });
2371
- return {
2372
- resultType: "complete",
2373
- content: [{
2374
- type: "text",
2375
- text: formatVerdict(result.value)
2376
- }]
2377
- };
2378
- }
2390
+ execution: this.#execute.bind(this)
2391
+ });
2392
+ }
2393
+ async #prove(input) {
2394
+ if (!isClaim(input)) {
2395
+ const refused = findRefusedPaths(input);
2396
+ throw new 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`, {
2397
+ origin: "claimant",
2398
+ code: "refused",
2399
+ context: { value: input }
2400
+ });
2401
+ }
2402
+ return this.#probe.prove(input);
2403
+ }
2404
+ async #execute(context) {
2405
+ const result = await context.tools.execute(context.call);
2406
+ if (!result.success) return result;
2407
+ if (!isVerdict(result.value)) throw new ProbeError("The prove tool returned an invalid verdict", {
2408
+ origin: "instrument",
2409
+ code: "malformed",
2410
+ context: { value: result.value }
2379
2411
  });
2412
+ return {
2413
+ resultType: "complete",
2414
+ content: [{
2415
+ type: "text",
2416
+ text: formatVerdict(result.value)
2417
+ }]
2418
+ };
2380
2419
  }
2381
2420
  };
2382
2421
  //#endregion