@ait-co/devtools 0.1.118 → 0.1.119

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.
@@ -296,34 +296,52 @@ function userFactoryPlugin(absPath) {
296
296
  };
297
297
  }
298
298
  /**
299
- * Returns the absolute path to the test-runner runtime module.
300
- *
301
- * Searches candidates in priority order:
302
- * 1. Co-located `runtime.ts` / `runtime.js` covers the source tree
303
- * (tsx / ts-node) and the `dist/test-runner/` entry.
304
- * 2. `../test-runner/runtime.js` covers the `dist/mcp/cli.js` entry,
305
- * where `import.meta.url` resolves to `dist/mcp/` (a sibling directory
306
- * of `dist/test-runner/`). Without this second candidate the MCP entry
307
- * point would look for `dist/mcp/runtime.js`, which does not exist, and
308
- * every `run_tests` call would fail with an esbuild "Could not resolve"
309
- * error (#678).
310
- *
311
- * Returns the first candidate that exists on disk. Falls back to the
312
- * co-located `runtime.js` path so esbuild produces a clear "file not found"
313
- * error rather than a cryptic failure.
299
+ * Returns the absolute filesystem path to the test-runner runtime module
300
+ * (dist/test-runner/runtime.js — a fully self-contained page-side bundle).
301
+ *
302
+ * Rolldown code-splitting duplicates this bundling logic into shared chunks
303
+ * emitted at ARBITRARY dist depths: the `devtools-test` CLI pulls it from
304
+ * dist/test-runner/bundle.js (dir = dist/test-runner/), while the `devtools-mcp`
305
+ * daemon (dist/mcp/cli.js) pulls it through a ROOT chunk
306
+ * (dist/debug-server-<hash>.js, dir = dist/). A fixed `..`-hop candidate list
307
+ * is therefore wrong from at least one chunk — the live #697 regression.
308
+ *
309
+ * This resolves WITHOUT assuming chunk depth: from `import.meta.url`'s dir it
310
+ * probes the co-located `runtime.js` and the nested `test-runner/runtime.js`,
311
+ * then ascends one directory at a time (bounded) repeating both probes. The
312
+ * nested probe catches dist/test-runner/runtime.js from the dist/ root level no
313
+ * matter which depth the chunk was hoisted to (root, dist/mcp/, or a future
314
+ * relocation). The build always emits dist/test-runner/runtime.js (tsdown entry
315
+ * `'test-runner/runtime'`; guarded by scripts/check-test-runner-dist.sh).
316
+ *
317
+ * An ABSOLUTE path is returned deliberately: esbuild loads it as a literal file
318
+ * read, bypassing Node module resolution entirely, so this works identically in
319
+ * the npx-daemon context (its own dist tree) and the consumer-CLI context
320
+ * (the mini-app's installed @ait-co/devtools dist) — neither needs the package
321
+ * to be node-resolvable from the caller.
314
322
  */
315
323
  function getRuntimePath() {
316
- const dir = path$1.dirname(fileURLToPath(import.meta.url));
317
- const candidates = [
318
- path$1.join(dir, "runtime.ts"),
319
- path$1.join(dir, "runtime.js"),
320
- path$1.join(dir, "..", "test-runner", "runtime.js")
324
+ const startDir = path$1.dirname(fileURLToPath(import.meta.url));
325
+ const RELATIVE_PROBES = [
326
+ ["runtime.js"],
327
+ ["test-runner", "runtime.js"],
328
+ ["runtime.ts"],
329
+ ["test-runner", "runtime.ts"]
321
330
  ];
322
- for (const candidate of candidates) try {
323
- accessSync(candidate);
324
- return candidate;
325
- } catch {}
326
- return path$1.join(dir, "runtime.js");
331
+ let dir = startDir;
332
+ for (let i = 0; i < 12; i++) {
333
+ for (const segs of RELATIVE_PROBES) {
334
+ const candidate = path$1.join(dir, ...segs);
335
+ try {
336
+ accessSync(candidate);
337
+ return candidate;
338
+ } catch {}
339
+ }
340
+ const parent = path$1.dirname(dir);
341
+ if (parent === dir) break;
342
+ dir = parent;
343
+ }
344
+ return path$1.join(startDir, "runtime.js");
327
345
  }
328
346
  /**
329
347
  * Bundles `absPath` into a single IIFE string suitable for `Runtime.evaluate`.
@@ -1888,4 +1906,4 @@ async function bootRelayFamily(options = {}) {
1888
1906
  //#endregion
1889
1907
  export { bootRelayFamily, buildRelayVerifyAuth };
1890
1908
 
1891
- //# sourceMappingURL=debug-server-krAOy6cl.js.map
1909
+ //# sourceMappingURL=debug-server-Buc8yoa7.js.map