vibecode-anything 0.3.0 → 0.4.0

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.
Files changed (160) hide show
  1. package/README.md +239 -67
  2. package/dist/cli.js +2140 -73
  3. package/dist/core/adapters.d.ts +26 -3
  4. package/dist/core/adapters.js +411 -25
  5. package/dist/core/agent-adapter.d.ts +67 -0
  6. package/dist/core/agent-adapter.js +312 -0
  7. package/dist/core/anti-cheat.d.ts +6 -0
  8. package/dist/core/anti-cheat.js +372 -0
  9. package/dist/core/badge.d.ts +18 -0
  10. package/dist/core/badge.js +360 -0
  11. package/dist/core/cache.d.ts +47 -0
  12. package/dist/core/cache.js +403 -0
  13. package/dist/core/ci-export.d.ts +35 -0
  14. package/dist/core/ci-export.js +796 -0
  15. package/dist/core/ci-formats.d.ts +21 -0
  16. package/dist/core/ci-formats.js +388 -0
  17. package/dist/core/client-codegen.d.ts +36 -0
  18. package/dist/core/client-codegen.js +2538 -0
  19. package/dist/core/compose.d.ts +71 -0
  20. package/dist/core/compose.js +1088 -0
  21. package/dist/core/docs-export.d.ts +37 -0
  22. package/dist/core/docs-export.js +2706 -0
  23. package/dist/core/doctor.d.ts +21 -1
  24. package/dist/core/doctor.js +234 -21
  25. package/dist/core/exec.d.ts +26 -2
  26. package/dist/core/exec.js +235 -8
  27. package/dist/core/fixtures.d.ts +153 -0
  28. package/dist/core/fixtures.js +2245 -0
  29. package/dist/core/format.d.ts +77 -0
  30. package/dist/core/format.js +632 -0
  31. package/dist/core/fs-snapshot.d.ts +37 -0
  32. package/dist/core/fs-snapshot.js +216 -0
  33. package/dist/core/graphql-export.d.ts +34 -0
  34. package/dist/core/graphql-export.js +2482 -0
  35. package/dist/core/har-export.d.ts +29 -0
  36. package/dist/core/har-export.js +988 -0
  37. package/dist/core/html-report.d.ts +27 -0
  38. package/dist/core/html-report.js +1535 -0
  39. package/dist/core/http-export.d.ts +31 -0
  40. package/dist/core/http-export.js +726 -0
  41. package/dist/core/impact.d.ts +80 -0
  42. package/dist/core/impact.js +1412 -0
  43. package/dist/core/lint.d.ts +38 -0
  44. package/dist/core/lint.js +1111 -0
  45. package/dist/core/load-export.d.ts +37 -0
  46. package/dist/core/load-export.js +1813 -0
  47. package/dist/core/mcp-export.d.ts +35 -0
  48. package/dist/core/mcp-export.js +1736 -0
  49. package/dist/core/mock-server.d.ts +47 -0
  50. package/dist/core/mock-server.js +1722 -0
  51. package/dist/core/openapi-export.d.ts +44 -0
  52. package/dist/core/openapi-export.js +1074 -0
  53. package/dist/core/parity.d.ts +6 -1
  54. package/dist/core/parity.js +36 -1
  55. package/dist/core/playwright-exporter.d.ts +23 -0
  56. package/dist/core/playwright-exporter.js +1343 -0
  57. package/dist/core/png.js +45 -9
  58. package/dist/core/regression.d.ts +54 -0
  59. package/dist/core/regression.js +529 -0
  60. package/dist/core/responsive.d.ts +86 -0
  61. package/dist/core/responsive.js +606 -0
  62. package/dist/core/run.d.ts +74 -0
  63. package/dist/core/run.js +696 -0
  64. package/dist/core/scheduler.d.ts +24 -0
  65. package/dist/core/scheduler.js +162 -0
  66. package/dist/core/schema-export.d.ts +29 -0
  67. package/dist/core/schema-export.js +2215 -0
  68. package/dist/core/schema.d.ts +3 -2
  69. package/dist/core/schema.js +460 -17
  70. package/dist/core/security.d.ts +233 -0
  71. package/dist/core/security.js +1839 -0
  72. package/dist/core/server-export.d.ts +38 -0
  73. package/dist/core/server-export.js +3198 -0
  74. package/dist/core/spec-writer.d.ts +9 -0
  75. package/dist/core/spec-writer.js +1202 -0
  76. package/dist/core/store.d.ts +11 -2
  77. package/dist/core/store.js +128 -8
  78. package/dist/core/target-map.d.ts +34 -0
  79. package/dist/core/target-map.js +262 -0
  80. package/dist/core/test-exporter.d.ts +25 -0
  81. package/dist/core/test-exporter.js +1918 -0
  82. package/dist/core/types.d.ts +182 -14
  83. package/dist/core/visual-semantic.d.ts +67 -0
  84. package/dist/core/visual-semantic.js +673 -0
  85. package/dist/core/visual.js +65 -16
  86. package/dist/core/watch.d.ts +28 -3
  87. package/dist/core/watch.js +222 -12
  88. package/dist/core/yaml.d.ts +5 -0
  89. package/dist/core/yaml.js +1009 -0
  90. package/dist/diagnostics/diagnose.d.ts +53 -0
  91. package/dist/diagnostics/diagnose.js +1083 -0
  92. package/dist/diagnostics/flake.d.ts +71 -0
  93. package/dist/diagnostics/flake.js +608 -0
  94. package/dist/diagnostics/mutation-audit.d.ts +69 -0
  95. package/dist/diagnostics/mutation-audit.js +769 -0
  96. package/dist/diagnostics/spatial.d.ts +42 -0
  97. package/dist/diagnostics/spatial.js +346 -0
  98. package/dist/diagnostics/trends.d.ts +122 -0
  99. package/dist/diagnostics/trends.js +1190 -0
  100. package/dist/discovery/discover.d.ts +111 -0
  101. package/dist/discovery/discover.js +2017 -0
  102. package/dist/discovery/lock.d.ts +116 -0
  103. package/dist/discovery/lock.js +1505 -0
  104. package/dist/discovery/routes.d.ts +36 -0
  105. package/dist/discovery/routes.js +1494 -0
  106. package/dist/discovery/test-importer.d.ts +92 -0
  107. package/dist/discovery/test-importer.js +4952 -0
  108. package/dist/index.d.ts +123 -0
  109. package/dist/index.js +99 -0
  110. package/dist/ingestors/api-collections.d.ts +28 -0
  111. package/dist/ingestors/api-collections.js +2335 -0
  112. package/dist/ingestors/api-repo.d.ts +2 -1
  113. package/dist/ingestors/api-repo.js +483 -85
  114. package/dist/ingestors/asyncapi.d.ts +26 -0
  115. package/dist/ingestors/asyncapi.js +2105 -0
  116. package/dist/ingestors/bridges.d.ts +2 -0
  117. package/dist/ingestors/bridges.js +702 -0
  118. package/dist/ingestors/cli.d.ts +2 -1
  119. package/dist/ingestors/cli.js +234 -46
  120. package/dist/ingestors/curl.d.ts +14 -0
  121. package/dist/ingestors/curl.js +1024 -0
  122. package/dist/ingestors/graphql.d.ts +56 -0
  123. package/dist/ingestors/graphql.js +1852 -0
  124. package/dist/ingestors/http-file.d.ts +20 -0
  125. package/dist/ingestors/http-file.js +923 -0
  126. package/dist/ingestors/index.js +486 -6
  127. package/dist/ingestors/openrpc.d.ts +29 -0
  128. package/dist/ingestors/openrpc.js +1807 -0
  129. package/dist/ingestors/proto.d.ts +47 -0
  130. package/dist/ingestors/proto.js +2690 -0
  131. package/dist/ingestors/trace.d.ts +10 -0
  132. package/dist/ingestors/trace.js +599 -0
  133. package/dist/ingestors/video.d.ts +4 -1
  134. package/dist/ingestors/video.js +86 -36
  135. package/dist/ingestors/web.d.ts +16 -1
  136. package/dist/ingestors/web.js +474 -32
  137. package/dist/mcp/server.js +3532 -67
  138. package/dist/oracles/api-repo.js +102 -30
  139. package/dist/oracles/cli.js +65 -17
  140. package/dist/oracles/http-workflow.d.ts +68 -0
  141. package/dist/oracles/http-workflow.js +828 -0
  142. package/dist/oracles/image.js +178 -28
  143. package/dist/oracles/index.d.ts +3 -1
  144. package/dist/oracles/index.js +243 -14
  145. package/dist/oracles/perf-budget.d.ts +90 -0
  146. package/dist/oracles/perf-budget.js +1329 -0
  147. package/dist/oracles/stream.d.ts +94 -0
  148. package/dist/oracles/stream.js +1268 -0
  149. package/dist/oracles/ui-states.d.ts +49 -0
  150. package/dist/oracles/ui-states.js +894 -0
  151. package/dist/oracles/video.d.ts +1 -1
  152. package/dist/oracles/video.js +232 -16
  153. package/dist/oracles/web.js +464 -73
  154. package/dist/plugins/builtins.d.ts +12 -0
  155. package/dist/plugins/builtins.js +1052 -0
  156. package/dist/plugins/registry.d.ts +86 -0
  157. package/dist/plugins/registry.js +554 -0
  158. package/dist/setup/index.js +145 -33
  159. package/package.json +56 -47
  160. package/skills/vibecode-anything/SKILL.md +75 -52
@@ -1,6 +1,8 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { VibecodeError, errorMessage } from "../core/errors.js";
4
+ import { parseYaml } from "../core/yaml.js";
5
+ import { mergeHeaders, redactHeaders } from "./trace.js";
4
6
  function isObject(v) {
5
7
  return v !== null && typeof v === "object" && !Array.isArray(v);
6
8
  }
@@ -217,6 +219,9 @@ function resolveSchema(schema, doc, stack = [], memo = new Map()) {
217
219
  else if (k === "additionalProperties" && isObject(v)) {
218
220
  out[k] = resolveSchema(v, doc, stack, memo);
219
221
  }
222
+ else if (k === "not" && isObject(v)) {
223
+ out[k] = resolveSchema(v, doc, stack, memo);
224
+ }
220
225
  else if ((k === "anyOf" || k === "oneOf") && Array.isArray(v)) {
221
226
  out[k] = v.map((x) => resolveSchema(x, doc, stack, memo));
222
227
  }
@@ -445,32 +450,210 @@ function pickBaseUrlFromSpec(doc, options) {
445
450
  function isOpenApiDoc(doc) {
446
451
  return isObject(doc) && Boolean(doc.openapi || doc.swagger) && isObject(doc.paths);
447
452
  }
448
- function scanExportsFromText(text) {
449
- const exports = [];
450
- const push = (name, kind) => {
451
- if (name && !exports.some((e) => e.name === name))
452
- exports.push({ name, kind });
453
+ const EXPORT_CONDITION_PRIORITY = ["import", "default", "node", "require", "module", "main"];
454
+ const FALLBACK_ENTRY_CANDIDATES = [
455
+ "src/index.ts",
456
+ "src/index.mts",
457
+ "src/index.mjs",
458
+ "src/index.js",
459
+ "index.ts",
460
+ "index.mjs",
461
+ "index.js"
462
+ ];
463
+ const MODULE_RESOLVE_EXTENSIONS = [".ts", ".mts", ".cts", ".tsx", ".mjs", ".js", ".cjs"];
464
+ const MAX_EXTRA_SUBPATH_INVARIANTS = 5;
465
+ const DEFAULT_SCAN_MAX_DEPTH = 4;
466
+ function isDeclarationFile(filePath) {
467
+ return /\.d\.[cm]?ts$/i.test(filePath);
468
+ }
469
+ function isIgnoredExportTarget(filePath) {
470
+ const trimmed = filePath.trim();
471
+ return !trimmed || trimmed.includes("*") || isDeclarationFile(trimmed) || /\.json$/i.test(trimmed);
472
+ }
473
+ function isExistingFile(absPath) {
474
+ try {
475
+ return fs.existsSync(absPath) && fs.statSync(absPath).isFile();
476
+ }
477
+ catch {
478
+ return false;
479
+ }
480
+ }
481
+ function canonicalizePath(absPath) {
482
+ let resolved;
483
+ try {
484
+ resolved = typeof fs.realpathSync.native === "function" ? fs.realpathSync.native(absPath) : fs.realpathSync(absPath);
485
+ }
486
+ catch {
487
+ resolved = path.resolve(absPath);
488
+ }
489
+ return process.platform === "win32" ? resolved.toLowerCase() : resolved;
490
+ }
491
+ function detectModuleLanguage(filePath) {
492
+ return /\.(?:[cm]?ts|tsx)$/i.test(filePath) ? "ts" : "js";
493
+ }
494
+ function slugifySubpath(subpath) {
495
+ const cleaned = subpath
496
+ .replace(/^\.+\//, "")
497
+ .toLowerCase()
498
+ .replace(/[^a-z0-9]+/g, "-")
499
+ .replace(/^-+|-+$/g, "");
500
+ return cleaned || "subpath";
501
+ }
502
+ function collectExportConditionCandidates(value, depth = 0) {
503
+ if (depth > 8 || value === null || value === undefined)
504
+ return [];
505
+ if (typeof value === "string") {
506
+ return isIgnoredExportTarget(value) ? [] : [value];
507
+ }
508
+ const out = [];
509
+ const add = (items) => {
510
+ for (const item of items) {
511
+ if (!out.includes(item))
512
+ out.push(item);
513
+ }
453
514
  };
454
- // export function foo / export async function foo
455
- for (const m of text.matchAll(/\bexport\s+(?:async\s+)?function\s+([A-Za-z_$][A-Za-z0-9_$]*)/g))
456
- push(m[1], "function");
457
- // export class Foo
458
- for (const m of text.matchAll(/\bexport\s+class\s+([A-Za-z_$][A-Za-z0-9_$]*)/g))
459
- push(m[1], "class");
515
+ if (Array.isArray(value)) {
516
+ for (const item of value)
517
+ add(collectExportConditionCandidates(item, depth + 1));
518
+ return out;
519
+ }
520
+ if (isObject(value)) {
521
+ for (const cond of EXPORT_CONDITION_PRIORITY) {
522
+ if (Object.prototype.hasOwnProperty.call(value, cond)) {
523
+ add(collectExportConditionCandidates(value[cond], depth + 1));
524
+ }
525
+ }
526
+ for (const [key, val] of Object.entries(value)) {
527
+ if (key === "types" || EXPORT_CONDITION_PRIORITY.includes(key))
528
+ continue;
529
+ add(collectExportConditionCandidates(val, depth + 1));
530
+ }
531
+ }
532
+ return out;
533
+ }
534
+ function resolveRepoEntryCandidate(repoDir, relCandidate) {
535
+ if (isIgnoredExportTarget(relCandidate))
536
+ return null;
537
+ const norm = relCandidate.trim().replace(/^\.\//, "").replace(/\\/g, "/");
538
+ if (!norm || isIgnoredExportTarget(norm))
539
+ return null;
540
+ const absPath = path.resolve(repoDir, norm);
541
+ if (!isExistingFile(absPath))
542
+ return null;
543
+ return { file: norm, absPath };
544
+ }
545
+ function resolveRelativeModulePath(fromFileAbs, specifier) {
546
+ if (!(specifier.startsWith("./") || specifier.startsWith("../") || specifier === "." || specifier === "..")) {
547
+ return null;
548
+ }
549
+ const base = path.resolve(path.dirname(fromFileAbs), specifier);
550
+ if (!isDeclarationFile(base) && isExistingFile(base))
551
+ return base;
552
+ const lower = base.toLowerCase();
553
+ const extOrder = lower.endsWith(".mjs")
554
+ ? [".mts", ".ts", ".mjs", ".js", ".cts", ".cjs", ".tsx"]
555
+ : lower.endsWith(".cjs")
556
+ ? [".cts", ".ts", ".cjs", ".js", ".mts", ".mjs", ".tsx"]
557
+ : MODULE_RESOLVE_EXTENSIONS;
558
+ const stem = base.replace(/\.(?:[cm]?js|jsx)$/i, "");
559
+ if (stem !== base) {
560
+ for (const ext of extOrder) {
561
+ const candidate = `${stem}${ext}`;
562
+ if (!isDeclarationFile(candidate) && isExistingFile(candidate))
563
+ return candidate;
564
+ }
565
+ }
566
+ for (const ext of extOrder) {
567
+ const candidate = `${base}${ext}`;
568
+ if (!isDeclarationFile(candidate) && isExistingFile(candidate))
569
+ return candidate;
570
+ }
571
+ for (const ext of extOrder) {
572
+ const indexCandidate = path.join(base, `index${ext}`);
573
+ if (!isDeclarationFile(indexCandidate) && isExistingFile(indexCandidate))
574
+ return indexCandidate;
575
+ }
576
+ if (stem !== base) {
577
+ for (const ext of extOrder) {
578
+ const indexCandidate = path.join(stem, `index${ext}`);
579
+ if (!isDeclarationFile(indexCandidate) && isExistingFile(indexCandidate))
580
+ return indexCandidate;
581
+ }
582
+ }
583
+ return null;
584
+ }
585
+ function parseNamedExportSpecifiers(specListRaw) {
586
+ const cleaned = specListRaw.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/\/\/[^\r\n]*/g, " ");
587
+ const out = [];
588
+ for (const rawPart of cleaned.split(",")) {
589
+ const trimmed = rawPart.trim();
590
+ if (!trimmed)
591
+ continue;
592
+ // Skip TypeScript inline type specifiers: `export { type Foo, type Bar as Baz }`
593
+ if (/^type\s+(?!as(?:\s|$))(?:[A-Za-z_$]|['"])/.test(trimmed))
594
+ continue;
595
+ const asMatch = trimmed.match(/^([A-Za-z_$][A-Za-z0-9_$]*)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)$/);
596
+ if (asMatch) {
597
+ out.push({ localName: asMatch[1], exportedName: asMatch[2] });
598
+ }
599
+ else if (/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(trimmed)) {
600
+ out.push({ localName: trimmed, exportedName: trimmed });
601
+ }
602
+ }
603
+ return out;
604
+ }
605
+ function parseExportsFromText(text) {
606
+ const direct = [];
607
+ const starReExports = [];
608
+ const namedReExports = [];
609
+ const pushDirect = (name, kind) => {
610
+ if (!name)
611
+ return;
612
+ const existing = direct.find((e) => e.name === name);
613
+ if (!existing)
614
+ direct.push({ name, kind });
615
+ else if (existing.kind === "unknown" && kind !== "unknown")
616
+ existing.kind = kind;
617
+ };
618
+ // export [async] function [*] foo
619
+ for (const m of text.matchAll(/(?:^|[;}\r\n]|\*\/)[ \t]*export[ \t]+(?:async[ \t]+)?function(?:\s*\*\s*|\s+)([A-Za-z_$][A-Za-z0-9_$]*)/g)) {
620
+ pushDirect(m[1], "function");
621
+ }
622
+ // export [abstract] class Foo
623
+ for (const m of text.matchAll(/(?:^|[;}\r\n]|\*\/)[ \t]*export[ \t]+(?:abstract[ \t]+)?class[ \t]+([A-Za-z_$][A-Za-z0-9_$]*)/g)) {
624
+ pushDirect(m[1], "class");
625
+ }
460
626
  // export const/let/var foo
461
- for (const m of text.matchAll(/\bexport\s+(?:const|let|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)/g))
462
- push(m[1], "const");
463
- // export { a, b as c }
464
- for (const m of text.matchAll(/\bexport\s*\{([^}]+)\}\s*(?:from\s*['"][^'"]+['"])?/g)) {
465
- for (const part of m[1].split(",")) {
466
- const name = part.trim().split(/\s+as\s+/i).pop()?.trim();
467
- if (name && /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name))
468
- push(name, "unknown");
627
+ for (const m of text.matchAll(/(?:^|[;}\r\n]|\*\/)[ \t]*export[ \t]+(?:const|let|var)[ \t]+([A-Za-z_$][A-Za-z0-9_$]*)/g)) {
628
+ pushDirect(m[1], "const");
629
+ }
630
+ // export * as ns from "./sub.js" (excludes `export type * as ...`)
631
+ for (const m of text.matchAll(/(?:^|[;}\r\n]|\*\/)[ \t]*export[ \t]+\*[ \t]+as[ \t]+([A-Za-z_$][A-Za-z0-9_$]*)[ \t]+from[ \t]*(['"])([^'"]+)\2/g)) {
632
+ pushDirect(m[1], "unknown");
633
+ }
634
+ // export * from "./sub.js" (excludes `export type * from ...` and `export * as ...`)
635
+ for (const m of text.matchAll(/(?:^|[;}\r\n]|\*\/)[ \t]*export[ \t]+\*[ \t]+from[ \t]*(['"])([^'"]+)\1/g)) {
636
+ if (m[2] && !starReExports.includes(m[2]))
637
+ starReExports.push(m[2]);
638
+ }
639
+ // export { a, b as c } [from "./sub.js"] (excludes `export type { ... }`)
640
+ for (const m of text.matchAll(/(?:^|[;}\r\n]|\*\/)[ \t]*export[ \t\r\n]*\{([^}]+)\}(?:[ \t\r\n]*from[ \t\r\n]*(['"])([^'"]+)\2)?/g)) {
641
+ const specifiers = parseNamedExportSpecifiers(m[1]);
642
+ if (specifiers.length === 0)
643
+ continue;
644
+ if (m[3]) {
645
+ namedReExports.push({ specifier: m[3], specifiers });
646
+ }
647
+ else {
648
+ for (const spec of specifiers) {
649
+ pushDirect(spec.exportedName, spec.exportedName === "default" ? "default" : "unknown");
650
+ }
469
651
  }
470
652
  }
471
- // export default
472
- if (/\bexport\s+default\b/.test(text))
473
- push("default", "default");
653
+ // export default (excludes `export default interface`)
654
+ if (/(?:^|[;}\r\n]|\*\/)[ \t]*export[ \t]+default(?!\s+interface\b)\b/.test(text)) {
655
+ pushDirect("default", "default");
656
+ }
474
657
  // CJS module.exports = { a, b }
475
658
  const modObj = text.match(/\bmodule\.exports\s*=\s*\{([\s\S]*?)\}/m);
476
659
  if (modObj) {
@@ -478,13 +661,119 @@ function scanExportsFromText(text) {
478
661
  const kv = part.trim().split(":")[0].trim();
479
662
  const name = kv.split(/\s+/)[0];
480
663
  if (name && /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name))
481
- push(name, "unknown");
664
+ pushDirect(name, "unknown");
482
665
  }
483
666
  }
484
667
  for (const m of text.matchAll(/\bexports\.([A-Za-z_$][A-Za-z0-9_$]*)\s*=/g))
485
- push(m[1], "unknown");
668
+ pushDirect(m[1], "unknown");
669
+ return { direct, starReExports, namedReExports };
670
+ }
671
+ function scanExportsFromText(text) {
672
+ const parsed = parseExportsFromText(text);
673
+ const exports = [];
674
+ const push = (name, kind) => {
675
+ const existing = exports.find((e) => e.name === name);
676
+ if (!existing)
677
+ exports.push({ name, kind });
678
+ else if (existing.kind === "unknown" && kind !== "unknown")
679
+ existing.kind = kind;
680
+ };
681
+ for (const entry of parsed.direct)
682
+ push(entry.name, entry.kind);
683
+ for (const re of parsed.namedReExports) {
684
+ for (const spec of re.specifiers) {
685
+ push(spec.exportedName, spec.exportedName === "default" ? "default" : "unknown");
686
+ }
687
+ }
486
688
  return exports;
487
689
  }
690
+ function scanExportsFromFileInternal(absPath, depth, maxDepth, visitedStack, memo) {
691
+ if (depth > maxDepth)
692
+ return { entries: [], truncatedByCycle: false };
693
+ const canonical = canonicalizePath(absPath);
694
+ if (visitedStack.has(canonical))
695
+ return { entries: [], truncatedByCycle: true };
696
+ if (!isExistingFile(absPath) || isDeclarationFile(absPath))
697
+ return { entries: [], truncatedByCycle: false };
698
+ const memoKey = `${canonical}::${maxDepth - depth}`;
699
+ const cached = memo.get(memoKey);
700
+ if (cached)
701
+ return { entries: cached, truncatedByCycle: false };
702
+ const text = fs.readFileSync(absPath, "utf8");
703
+ const parsed = parseExportsFromText(text);
704
+ const entries = [];
705
+ const byName = new Map();
706
+ const push = (entry) => {
707
+ const existing = byName.get(entry.name);
708
+ if (!existing) {
709
+ const copy = { name: entry.name, kind: entry.kind };
710
+ byName.set(copy.name, copy);
711
+ entries.push(copy);
712
+ }
713
+ else if (existing.kind === "unknown" && entry.kind !== "unknown") {
714
+ existing.kind = entry.kind;
715
+ }
716
+ };
717
+ for (const entry of parsed.direct)
718
+ push(entry);
719
+ let truncatedByCycle = false;
720
+ visitedStack.add(canonical);
721
+ try {
722
+ // Named re-exports: `export { a, b as c, default as Foo } from "./sub.js"`
723
+ for (const re of parsed.namedReExports) {
724
+ let targetExports = null;
725
+ if (depth < maxDepth) {
726
+ const targetAbs = resolveRelativeModulePath(absPath, re.specifier);
727
+ if (targetAbs) {
728
+ const sub = scanExportsFromFileInternal(targetAbs, depth + 1, maxDepth, visitedStack, memo);
729
+ if (sub.truncatedByCycle)
730
+ truncatedByCycle = true;
731
+ targetExports = sub.entries;
732
+ }
733
+ }
734
+ for (const spec of re.specifiers) {
735
+ const found = targetExports?.find((e) => e.name === spec.localName);
736
+ let kind;
737
+ if (spec.exportedName === "default") {
738
+ kind = "default";
739
+ }
740
+ else if (found && found.kind !== "default") {
741
+ kind = found.kind;
742
+ }
743
+ else {
744
+ kind = "unknown";
745
+ }
746
+ push({ name: spec.exportedName, kind });
747
+ }
748
+ }
749
+ // Star re-exports: `export * from "./sub.js"` (excludes `default` per ESM spec)
750
+ if (depth < maxDepth) {
751
+ for (const specifier of parsed.starReExports) {
752
+ const targetAbs = resolveRelativeModulePath(absPath, specifier);
753
+ if (!targetAbs)
754
+ continue;
755
+ const sub = scanExportsFromFileInternal(targetAbs, depth + 1, maxDepth, visitedStack, memo);
756
+ if (sub.truncatedByCycle)
757
+ truncatedByCycle = true;
758
+ for (const entry of sub.entries) {
759
+ if (entry.name === "default")
760
+ continue;
761
+ push(entry);
762
+ }
763
+ }
764
+ }
765
+ }
766
+ finally {
767
+ visitedStack.delete(canonical);
768
+ }
769
+ if (!truncatedByCycle) {
770
+ memo.set(memoKey, entries);
771
+ }
772
+ return { entries, truncatedByCycle };
773
+ }
774
+ function scanExportsFromFile(absPath, maxDepth = DEFAULT_SCAN_MAX_DEPTH) {
775
+ return scanExportsFromFileInternal(absPath, 0, maxDepth, new Set(), new Map()).entries;
776
+ }
488
777
  export async function ingestRepo(options = {}, _deps = {}) {
489
778
  const source = options.source;
490
779
  if (!source || typeof source !== "string") {
@@ -507,79 +796,167 @@ export async function ingestRepo(options = {}, _deps = {}) {
507
796
  warnings.push({ code: "PARSE_WARNING", message: "Could not parse package.json" });
508
797
  }
509
798
  }
510
- const entryCandidates = [];
511
- if (pkg?.exports) {
512
- if (typeof pkg.exports === "string")
513
- entryCandidates.push(pkg.exports);
799
+ // 1. Collect prioritized primary (".") runtime candidates and extra subpath candidate lists
800
+ const primaryCandidates = [];
801
+ const subpathCandidates = [];
802
+ const pushPrimary = (candidates) => {
803
+ for (const c of candidates) {
804
+ if (!primaryCandidates.includes(c))
805
+ primaryCandidates.push(c);
806
+ }
807
+ };
808
+ if (pkg?.exports !== undefined && pkg?.exports !== null) {
809
+ if (typeof pkg.exports === "string") {
810
+ pushPrimary(collectExportConditionCandidates(pkg.exports));
811
+ }
514
812
  else if (isObject(pkg.exports)) {
515
- for (const v of Object.values(pkg.exports)) {
516
- if (typeof v === "string")
517
- entryCandidates.push(v);
518
- else if (isObject(v))
519
- for (const vv of Object.values(v))
520
- if (typeof vv === "string")
521
- entryCandidates.push(vv);
813
+ const exportEntries = Object.entries(pkg.exports);
814
+ const isSubpathMap = exportEntries.some(([k]) => k.startsWith("."));
815
+ if (isSubpathMap) {
816
+ if (Object.prototype.hasOwnProperty.call(pkg.exports, ".")) {
817
+ pushPrimary(collectExportConditionCandidates(pkg.exports["."]));
818
+ }
819
+ for (const [subpath, value] of exportEntries) {
820
+ if (subpath === "." || !subpath.startsWith(".") || subpath.includes("*") || /\.json$/i.test(subpath)) {
821
+ continue;
822
+ }
823
+ const cands = collectExportConditionCandidates(value);
824
+ if (cands.length > 0)
825
+ subpathCandidates.push({ subpath, candidates: cands });
826
+ }
827
+ }
828
+ else {
829
+ pushPrimary(collectExportConditionCandidates(pkg.exports));
522
830
  }
523
831
  }
524
832
  }
525
833
  if (typeof pkg?.module === "string")
526
- entryCandidates.push(pkg.module);
834
+ pushPrimary(collectExportConditionCandidates(pkg.module));
527
835
  if (typeof pkg?.main === "string")
528
- entryCandidates.push(pkg.main);
529
- for (const c of ["src/index.mjs", "src/index.js", "index.mjs", "index.js"])
530
- entryCandidates.push(c);
531
- const seen = new Set();
532
- const filesPresent = [];
533
- const exports = [];
534
- for (const rel of entryCandidates) {
535
- const norm = rel.replace(/^\.\//, "");
536
- if (seen.has(norm))
537
- continue;
538
- seen.add(norm);
539
- const abs = path.join(repoDir, norm);
540
- if (!fs.existsSync(abs) || !fs.statSync(abs).isFile())
836
+ pushPrimary(collectExportConditionCandidates(pkg.main));
837
+ for (const fallback of FALLBACK_ENTRY_CANDIDATES)
838
+ pushPrimary([fallback]);
839
+ // 2. Resolve existing runtime files on disk (primary + additional subpaths)
840
+ const seenFiles = new Set();
841
+ let primaryEntry = null;
842
+ for (const cand of primaryCandidates) {
843
+ const resolved = resolveRepoEntryCandidate(repoDir, cand);
844
+ if (!resolved)
541
845
  continue;
542
- filesPresent.push(norm.replace(/\\/g, "/"));
543
- try {
544
- const text = fs.readFileSync(abs, "utf8");
545
- for (const e of scanExportsFromText(text)) {
546
- if (!exports.some((x) => x.name === e.name))
547
- exports.push(e);
846
+ primaryEntry = { subpath: ".", ...resolved };
847
+ seenFiles.add(resolved.file);
848
+ break;
849
+ }
850
+ const extraEntries = [];
851
+ for (const sub of subpathCandidates) {
852
+ for (const cand of sub.candidates) {
853
+ const resolved = resolveRepoEntryCandidate(repoDir, cand);
854
+ if (!resolved)
855
+ continue;
856
+ if (seenFiles.has(resolved.file))
857
+ break;
858
+ seenFiles.add(resolved.file);
859
+ if (!primaryEntry) {
860
+ primaryEntry = { subpath: sub.subpath, ...resolved };
861
+ }
862
+ else {
863
+ extraEntries.push({ subpath: sub.subpath, ...resolved });
548
864
  }
865
+ break;
866
+ }
867
+ }
868
+ const filesPresent = [];
869
+ if (primaryEntry)
870
+ filesPresent.push(primaryEntry.file);
871
+ for (const extra of extraEntries)
872
+ filesPresent.push(extra.file);
873
+ // 3. Scan ONLY primaryEntry for `inv-repo-exports` (no cross-entrypoint symbol contamination)
874
+ let primaryExports = [];
875
+ if (primaryEntry) {
876
+ try {
877
+ primaryExports = scanExportsFromFile(primaryEntry.absPath);
549
878
  }
550
879
  catch (err) {
551
- warnings.push({ code: "READ_WARNING", message: `Failed to scan ${norm}: ${errorMessage(err)}` });
880
+ warnings.push({ code: "READ_WARNING", message: `Failed to scan ${primaryEntry.file}: ${errorMessage(err)}` });
881
+ }
882
+ }
883
+ const invariants = [
884
+ {
885
+ id: "inv-repo-exports",
886
+ domain: "repo",
887
+ type: "repo_exports",
888
+ severity: "hard",
889
+ description: "Public entrypoint preserves exported symbol contract",
890
+ tags: ["repo", "exports"],
891
+ sourceId: "src-1",
892
+ input: {
893
+ modulePath: primaryEntry ? primaryEntry.file : "src/index.mjs",
894
+ language: primaryEntry ? detectModuleLanguage(primaryEntry.file) : "js"
895
+ },
896
+ expected: {
897
+ filesPresent: filesPresent.length
898
+ ? filesPresent
899
+ : ["package.json"].filter((f) => fs.existsSync(path.join(repoDir, f))),
900
+ exports: primaryExports
901
+ },
902
+ tolerance: {}
552
903
  }
553
- if (exports.length >= 50)
904
+ ];
905
+ // 4. Emit separate `repo_exports` invariants for up to 5 extra subpath entrypoints that export symbols
906
+ const usedIds = new Set(["inv-repo-exports"]);
907
+ let extraEmitted = 0;
908
+ for (const extra of extraEntries) {
909
+ if (extraEmitted >= MAX_EXTRA_SUBPATH_INVARIANTS)
554
910
  break;
911
+ let extraExports = [];
912
+ try {
913
+ extraExports = scanExportsFromFile(extra.absPath);
914
+ }
915
+ catch (err) {
916
+ warnings.push({ code: "READ_WARNING", message: `Failed to scan ${extra.file}: ${errorMessage(err)}` });
917
+ continue;
918
+ }
919
+ if (extraExports.length === 0)
920
+ continue;
921
+ const slug = slugifySubpath(extra.subpath);
922
+ let invId = `inv-repo-exports-${slug}`;
923
+ let suffix = 2;
924
+ while (usedIds.has(invId)) {
925
+ invId = `inv-repo-exports-${slug}-${suffix++}`;
926
+ }
927
+ usedIds.add(invId);
928
+ invariants.push({
929
+ id: invId,
930
+ domain: "repo",
931
+ type: "repo_exports",
932
+ severity: "hard",
933
+ description: `Subpath entrypoint ${extra.subpath} preserves exported symbol contract`,
934
+ tags: ["repo", "exports", slug],
935
+ sourceId: "src-1",
936
+ input: {
937
+ modulePath: extra.file,
938
+ language: detectModuleLanguage(extra.file)
939
+ },
940
+ expected: {
941
+ filesPresent: [extra.file],
942
+ exports: extraExports
943
+ },
944
+ tolerance: {}
945
+ });
946
+ extraEmitted++;
555
947
  }
556
- if (exports.length === 0) {
948
+ if (primaryExports.length === 0 && extraEmitted === 0) {
557
949
  warnings.push({ code: "ADAPTER_DEGRADED", message: "No exports detected; emitting filesPresent-only invariant." });
558
950
  }
559
- const invariant = {
560
- id: "inv-repo-exports",
561
- domain: "repo",
562
- type: "repo_exports",
563
- severity: "hard",
564
- description: "Public entrypoint preserves exported symbol contract",
565
- tags: ["repo", "exports"],
566
- sourceId: "src-1",
567
- input: { modulePath: filesPresent[0] || "src/index.mjs", language: "js" },
568
- expected: {
569
- filesPresent: filesPresent.length ? filesPresent : ["package.json"].filter((f) => fs.existsSync(path.join(repoDir, f))),
570
- exports
571
- },
572
- tolerance: {}
573
- };
574
951
  return {
575
952
  domain: "repo",
576
953
  sources: [{ id: "src-1", kind: "repo", ref: source, meta: { repoDir } }],
577
954
  artifacts: { root: ".vibecode/artifacts", files: {} },
578
- invariants: [invariant],
955
+ invariants,
579
956
  warnings
580
957
  };
581
958
  }
582
- export { scanExportsFromText };
959
+ export { scanExportsFromText, scanExportsFromFile };
583
960
  export async function ingestApi(options = {}, deps = {}) {
584
961
  const source = options.source;
585
962
  if (!source || typeof source !== "string") {
@@ -603,9 +980,13 @@ export async function ingestApi(options = {}, deps = {}) {
603
980
  const isUrl = /^https?:\/\//i.test(source);
604
981
  if (!isUrl) {
605
982
  const abs = path.resolve(options.cwd || process.cwd(), source);
606
- if (fs.existsSync(abs) && abs.toLowerCase().endsWith(".json")) {
983
+ const lowerAbs = abs.toLowerCase();
984
+ const isJsonSpec = lowerAbs.endsWith(".json");
985
+ const isYamlSpec = lowerAbs.endsWith(".yaml") || lowerAbs.endsWith(".yml");
986
+ if (fs.existsSync(abs) && (isJsonSpec || isYamlSpec)) {
607
987
  try {
608
- const doc = JSON.parse(fs.readFileSync(abs, "utf8"));
988
+ const rawText = fs.readFileSync(abs, "utf8");
989
+ const doc = isYamlSpec ? parseYaml(rawText) : JSON.parse(rawText);
609
990
  if (isOpenApiDoc(doc)) {
610
991
  specDoc = doc;
611
992
  baseUrl = pickBaseUrlFromSpec(doc, options);
@@ -623,15 +1004,32 @@ export async function ingestApi(options = {}, deps = {}) {
623
1004
  if (!specDoc && typeof options.baseUrl === "string" && options.baseUrl)
624
1005
  baseUrl = options.baseUrl;
625
1006
  if (endpoints.length === 0) {
626
- endpoints = [
627
- { method: "GET", path: "/health", headers: {}, body: null },
628
- { method: "GET", path: "/", headers: {}, body: null }
629
- ];
1007
+ if (isUrl && !specDoc && !(typeof options.baseUrl === "string" && options.baseUrl)) {
1008
+ try {
1009
+ const parsed = new URL(source);
1010
+ if ((parsed.pathname && parsed.pathname !== "/") || parsed.search) {
1011
+ baseUrl = parsed.origin;
1012
+ const queryObj = parsed.search ? Object.fromEntries(parsed.searchParams.entries()) : undefined;
1013
+ endpoints = [{ method: "GET", path: parsed.pathname || "/", query: queryObj, headers: {}, body: null }];
1014
+ }
1015
+ }
1016
+ catch {
1017
+ // fall through to default probes
1018
+ }
1019
+ }
1020
+ if (endpoints.length === 0) {
1021
+ endpoints = [
1022
+ { method: "GET", path: "/health", headers: {}, body: null },
1023
+ { method: "GET", path: "/", headers: {}, body: null }
1024
+ ];
1025
+ }
630
1026
  }
1027
+ const globalHeaders = isObject(options.headers) ? options.headers : undefined;
631
1028
  const usedIds = new Set();
632
1029
  const invariants = [];
633
1030
  for (const ep of endpoints.slice(0, 25)) {
634
1031
  const method = String(ep.method || "GET").toUpperCase();
1032
+ const probeHeaders = mergeHeaders(ep.headers, globalHeaders);
635
1033
  const url = buildApiUrl(baseUrl, ep.path, ep.query);
636
1034
  let observed = null;
637
1035
  let probeFailed = null;
@@ -640,7 +1038,7 @@ export async function ingestApi(options = {}, deps = {}) {
640
1038
  try {
641
1039
  observed = await (deps.fetchJson || fetchJson)(url, {
642
1040
  method,
643
- headers: ep.headers || {},
1041
+ headers: probeHeaders,
644
1042
  body: ep.body ?? null,
645
1043
  timeoutMs: ep.timeoutMs || 10000
646
1044
  });
@@ -677,7 +1075,7 @@ export async function ingestApi(options = {}, deps = {}) {
677
1075
  if (specMode && ep.fromSpec && ep.jsonSchema)
678
1076
  expected.jsonSchema = ep.jsonSchema;
679
1077
  if (specMode && ep.fromSpec && ep.expectedContentType) {
680
- expected.headers = { ...(isObject(expected.headers) ? expected.headers : {}), "content-type": ep.expectedContentType };
1078
+ expected.headers = redactHeaders({ ...(isObject(expected.headers) ? expected.headers : {}), "content-type": ep.expectedContentType }, "strip");
681
1079
  }
682
1080
  }
683
1081
  else {
@@ -687,7 +1085,7 @@ export async function ingestApi(options = {}, deps = {}) {
687
1085
  if (ep.jsonPaths)
688
1086
  expected.jsonPaths = ep.jsonPaths;
689
1087
  if (ep.expectedContentType)
690
- expected.headers = { "content-type": ep.expectedContentType };
1088
+ expected.headers = redactHeaders({ "content-type": ep.expectedContentType }, "strip");
691
1089
  }
692
1090
  const baseId = ep.id || `inv-api-${method.toLowerCase()}-${slugify(ep.path)}`;
693
1091
  const id = uniqueId(baseId, usedIds);
@@ -703,7 +1101,7 @@ export async function ingestApi(options = {}, deps = {}) {
703
1101
  input: {
704
1102
  method,
705
1103
  path: ep.path,
706
- headers: isObject(ep.headers) ? ep.headers : {},
1104
+ headers: redactHeaders(probeHeaders, "strip"),
707
1105
  ...(ep.query ? { query: ep.query } : {}),
708
1106
  body: ep.body ?? null,
709
1107
  timeoutMs: ep.timeoutMs || 10000