@ait-co/devtools 0.1.112 → 0.1.113

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.
@@ -1 +1 @@
1
- {"version":3,"file":"bundle-KFs4t-wc.d.ts","names":[],"sources":["../src/test-runner/bundle.ts"],"mappings":";;AAqEA;;;;;AAmBA;;;;;AA2LA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA9MiB,aAAA;;;;;;;EAOf,cAAA;;;;;EAKA,UAAA;AAAA;;;;;UAOe,YAAA;EACf,IAAA;EACA,QAAA;AAAA;;;;;;;;;;;;;;;iBAyLoB,cAAA,CAAe,OAAA,UAAiB,IAAA,GAAO,aAAA,GAAgB,OAAA,CAAQ,YAAA"}
1
+ {"version":3,"file":"bundle-KFs4t-wc.d.ts","names":[],"sources":["../src/test-runner/bundle.ts"],"mappings":";;AAqEA;;;;;AAmBA;;;;;AAuPA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA1QiB,aAAA;;;;;;;EAOf,cAAA;;;;;EAKA,UAAA;AAAA;;;;;UAOe,YAAA;EACf,IAAA;EACA,QAAA;AAAA;;;;;;;;;;;;;;;iBAqPoB,cAAA,CAAe,OAAA,UAAiB,IAAA,GAAO,aAAA,GAAgB,OAAA,CAAQ,YAAA"}
package/dist/mcp/cli.js CHANGED
@@ -351,8 +351,19 @@ module.exports = __proxy;
351
351
  * installed describe/it/test/expect as globals.
352
352
  *
353
353
  * Algorithm:
354
- * - Lines matching import declarations or re-export statements are kept at
355
- * module top-level (the only valid ESM position for static `import`).
354
+ * - Import declarations and re-export statements are kept at module top-level
355
+ * (the only valid ESM position for static `import`). A statement that spans
356
+ * multiple lines — e.g. a named import with one member per line:
357
+ * import {
358
+ * appLogin,
359
+ * getAnonymousKey,
360
+ * } from '@apps-in-toss/web-framework';
361
+ * is tracked as a single block: every line from the opening `import {` /
362
+ * `export {` through the closing `from '…'` (or side-effect `'…'`) line is
363
+ * kept together at top-level. This prevents the member lines and the
364
+ * closing `} from '…'` line from leaking into the factory body, which would
365
+ * leave an unterminated `import {` at module scope (the #678 env3 failure:
366
+ * esbuild threw `Expected "as" but found "{"` on multi-line SDK imports).
356
367
  * - All other lines (describe/it/test calls, local declarations, etc.) are
357
368
  * moved into the body of the exported async factory function.
358
369
  *
@@ -376,12 +387,25 @@ function userFactoryPlugin(absPath) {
376
387
  const topLevelLines = [];
377
388
  const bodyLines = [];
378
389
  const EXPORT_DECLARATION_RE = /^(export\s+)(default\s+|async\s+function\s+|function\s+|class\s+|const\s+|let\s+|var\s+)/;
390
+ const isImportStart = (trimmed) => trimmed.startsWith("import ") || trimmed.startsWith("import{") || trimmed.startsWith("import'") || trimmed.startsWith("import\"");
391
+ const endsStatement = (trimmed) => /['"]\s*;?\s*$/.test(trimmed.replace(/\/\/.*$/, "").trimEnd());
392
+ let inImportBlock = false;
379
393
  for (const line of lines) {
380
394
  const trimmed = line.trimStart();
381
395
  const indent = line.slice(0, line.length - trimmed.length);
382
- if (trimmed.startsWith("import ") || trimmed.startsWith("import{") || trimmed.startsWith("import'") || trimmed.startsWith("import\"")) topLevelLines.push(line);
383
- else if (trimmed.startsWith("export ")) if (trimmed.match(EXPORT_DECLARATION_RE)) bodyLines.push(indent + trimmed.slice(7));
384
- else topLevelLines.push(line);
396
+ if (inImportBlock) {
397
+ topLevelLines.push(line);
398
+ if (endsStatement(trimmed)) inImportBlock = false;
399
+ continue;
400
+ }
401
+ if (isImportStart(trimmed)) {
402
+ topLevelLines.push(line);
403
+ if (!endsStatement(trimmed)) inImportBlock = true;
404
+ } else if (trimmed.startsWith("export ")) if (trimmed.match(EXPORT_DECLARATION_RE)) bodyLines.push(indent + trimmed.slice(7));
405
+ else {
406
+ topLevelLines.push(line);
407
+ if (/\bfrom\b/.test(trimmed) ? !endsStatement(trimmed) : trimmed.endsWith("{")) inImportBlock = true;
408
+ }
385
409
  else bodyLines.push(line);
386
410
  }
387
411
  return {
@@ -401,21 +425,33 @@ function userFactoryPlugin(absPath) {
401
425
  };
402
426
  }
403
427
  /**
404
- * Returns the absolute path to the co-located runtime module.
428
+ * Returns the absolute path to the test-runner runtime module.
405
429
  *
406
- * In the source tree (running via tsx / ts-node) the file is `runtime.ts`.
407
- * After `tsdown` compiles to `dist/test-runner/`, it becomes `runtime.js`.
408
- * We try both extensions to support both environments.
430
+ * Searches candidates in priority order:
431
+ * 1. Co-located `runtime.ts` / `runtime.js` — covers the source tree
432
+ * (tsx / ts-node) and the `dist/test-runner/` entry.
433
+ * 2. `../test-runner/runtime.js` — covers the `dist/mcp/cli.js` entry,
434
+ * where `import.meta.url` resolves to `dist/mcp/` (a sibling directory
435
+ * of `dist/test-runner/`). Without this second candidate the MCP entry
436
+ * point would look for `dist/mcp/runtime.js`, which does not exist, and
437
+ * every `run_tests` call would fail with an esbuild "Could not resolve"
438
+ * error (#678).
439
+ *
440
+ * Returns the first candidate that exists on disk. Falls back to the
441
+ * co-located `runtime.js` path so esbuild produces a clear "file not found"
442
+ * error rather than a cryptic failure.
409
443
  */
410
444
  function getRuntimePath() {
411
445
  const dir = path.dirname(fileURLToPath(import.meta.url));
412
- for (const ext of [".ts", ".js"]) {
413
- const candidate = path.join(dir, `runtime${ext}`);
414
- try {
415
- accessSync(candidate);
416
- return candidate;
417
- } catch {}
418
- }
446
+ const candidates = [
447
+ path.join(dir, "runtime.ts"),
448
+ path.join(dir, "runtime.js"),
449
+ path.join(dir, "..", "test-runner", "runtime.js")
450
+ ];
451
+ for (const candidate of candidates) try {
452
+ accessSync(candidate);
453
+ return candidate;
454
+ } catch {}
419
455
  return path.join(dir, "runtime.js");
420
456
  }
421
457
  /**
@@ -5375,7 +5411,7 @@ async function readMcpSdkVersion() {
5375
5411
  * some test environments that skip the build step).
5376
5412
  */
5377
5413
  function readDevtoolsVersion() {
5378
- return "0.1.112";
5414
+ return "0.1.113";
5379
5415
  }
5380
5416
  /**
5381
5417
  * Derives the next recommended action from a completed diagnostics snapshot.
@@ -6295,7 +6331,7 @@ function createDebugServer(deps) {
6295
6331
  }
6296
6332
  const server = new Server({
6297
6333
  name: "ait-debug",
6298
- version: "0.1.112"
6334
+ version: "0.1.113"
6299
6335
  }, { capabilities: { tools: { listChanged: true } } });
6300
6336
  server.setRequestHandler(ListToolsRequestSchema, () => {
6301
6337
  const conn = router.active;
@@ -8195,7 +8231,7 @@ function createDevServer(deps = {}) {
8195
8231
  const aitSource = deps.aitSource ?? new HttpAitSource({ stateEndpoint });
8196
8232
  const server = new Server({
8197
8233
  name: "ait-devtools",
8198
- version: "0.1.112"
8234
+ version: "0.1.113"
8199
8235
  }, { capabilities: { tools: {} } });
8200
8236
  server.setRequestHandler(ListToolsRequestSchema, () => ({ tools: DEV_TOOL_DEFINITIONS.map((tool) => ({ ...tool })) }));
8201
8237
  server.setRequestHandler(CallToolRequestSchema, async (request) => {