@vibgrate/cli 2026.721.2 → 2026.721.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.
@@ -1,5 +1,5 @@
1
- import { hashString, langById, shortId, canonicalize, grammarSetVersion, hashBytes, langForExtension, setGrammarsOverride, parseSource } from './chunk-JWBS5GS6.js';
2
- import { writeTextFile, pathExists, readJsonFile, loadConfig, computeUpgradeImpact, getChangelogSignals, gitHistoryAvailable, buildVersionTimelines, findPackageTimeline, severityRank, projectTypeToVulnEcosystem, VERSION } from './chunk-NHLSAZ6N.js';
1
+ import { hashString, langById, shortId, canonicalize, grammarSetVersion, hashBytes, langForExtension, setGrammarsOverride, parseSource } from './chunk-IKJBELUV.js';
2
+ import { writeTextFile, pathExists, readJsonFile, loadConfig, computeUpgradeImpact, getChangelogSignals, gitHistoryAvailable, buildVersionTimelines, findPackageTimeline, severityRank, projectTypeToVulnEcosystem, VERSION } from './chunk-JLRF5TFA.js';
3
3
  import * as fs17 from 'fs';
4
4
  import { spawnSync, execFileSync } from 'child_process';
5
5
  import * as path17 from 'path';
@@ -1646,6 +1646,38 @@ function resolve4(parses, resolver) {
1646
1646
  push(defsByFile, p.rel, ref);
1647
1647
  }
1648
1648
  }
1649
+ const filesByNamespace = /* @__PURE__ */ new Map();
1650
+ for (const p of parses) for (const ns of p.namespaces ?? []) addToSet(filesByNamespace, ns, p.rel);
1651
+ const relsByLang = /* @__PURE__ */ new Map();
1652
+ for (const p of parses) push(relsByLang, p.lang, p.rel);
1653
+ const nsReachableByRel = /* @__PURE__ */ new Map();
1654
+ const moduleReachableByRel = /* @__PURE__ */ new Map();
1655
+ for (const p of parses) {
1656
+ if (MODULE_SCOPED_LANGS.has(p.lang)) {
1657
+ const mod2 = /* @__PURE__ */ new Set();
1658
+ for (const rel2 of relsByLang.get(p.lang) ?? []) if (rel2 !== p.rel) mod2.add(rel2);
1659
+ moduleReachableByRel.set(p.rel, mod2);
1660
+ }
1661
+ const reach = /* @__PURE__ */ new Set();
1662
+ const namespaces = new Set(p.namespaces ?? []);
1663
+ for (const imp of p.imports) {
1664
+ namespaces.add(imp.source);
1665
+ if (IMPORT_NAMES_A_TYPE.has(p.lang)) {
1666
+ const sep10 = Math.max(imp.source.lastIndexOf("."), imp.source.lastIndexOf("\\"));
1667
+ if (sep10 > 0) namespaces.add(imp.source.slice(0, sep10));
1668
+ }
1669
+ }
1670
+ for (const ns of namespaces) for (const rel2 of filesByNamespace.get(ns) ?? []) if (rel2 !== p.rel) reach.add(rel2);
1671
+ nsReachableByRel.set(p.rel, reach);
1672
+ }
1673
+ const superTypesByType = /* @__PURE__ */ new Map();
1674
+ for (const p of parses) {
1675
+ const localDefs = defsByFile.get(p.rel) ?? [];
1676
+ for (const h of p.heritage) {
1677
+ const encl = enclosingDefRef(localDefs, h.byte);
1678
+ if (encl && (encl.kind === "class" || encl.kind === "interface")) addToSet(superTypesByType, encl.name, h.superName);
1679
+ }
1680
+ }
1649
1681
  const edges = new EdgeSet();
1650
1682
  const unresolved2 = /* @__PURE__ */ new Map();
1651
1683
  const stats = {
@@ -1689,9 +1721,11 @@ function resolve4(parses, resolver) {
1689
1721
  const localDefs = defsByFile.get(p.rel) ?? [];
1690
1722
  const imported = importedFilesByRel.get(p.rel) ?? /* @__PURE__ */ new Set();
1691
1723
  const testCaller = isTestFile(p.rel);
1724
+ const nsReach = nsReachableByRel.get(p.rel) ?? /* @__PURE__ */ new Set();
1725
+ const modReach = moduleReachableByRel.get(p.rel) ?? /* @__PURE__ */ new Set();
1692
1726
  for (const call of p.calls) {
1693
1727
  const srcId = enclosingDefId(localDefs, call.byte) ?? fileId;
1694
- const resolved = resolveCall(call, p.rel, p.lang, imported, defsByName, srcId, testCaller);
1728
+ const resolved = resolveCall(call, p.rel, p.lang, imported, defsByName, srcId, testCaller, nsReach, superTypesByType, modReach);
1695
1729
  if (resolved) {
1696
1730
  edges.add("call", srcId, resolved.id, "heuristic", resolved.confidence);
1697
1731
  stats.callsResolved++;
@@ -1706,9 +1740,11 @@ function resolve4(parses, resolver) {
1706
1740
  const localDefs = defsByFile.get(p.rel) ?? [];
1707
1741
  const imported = importedFilesByRel.get(p.rel) ?? /* @__PURE__ */ new Set();
1708
1742
  const testCaller = isTestFile(p.rel);
1743
+ const nsReach = nsReachableByRel.get(p.rel) ?? /* @__PURE__ */ new Set();
1744
+ const modReach = moduleReachableByRel.get(p.rel) ?? /* @__PURE__ */ new Set();
1709
1745
  for (const ref of p.typeRefs) {
1710
1746
  const srcId = enclosingDefId(localDefs, ref.byte) ?? fileId;
1711
- const target = resolveType(ref.name, p.rel, p.lang, imported, defsByName, testCaller);
1747
+ const target = resolveType(ref.name, p.rel, p.lang, imported, defsByName, testCaller, nsReach, modReach);
1712
1748
  if (target) edges.add("references", srcId, target.id, "heuristic", 0.7);
1713
1749
  }
1714
1750
  }
@@ -1719,7 +1755,9 @@ function resolve4(parses, resolver) {
1719
1755
  for (const h of p.heritage) {
1720
1756
  const srcId = enclosingDefId(localDefs, h.byte);
1721
1757
  if (!srcId) continue;
1722
- const target = resolveType(h.superName, p.rel, p.lang, imported, defsByName, testCaller);
1758
+ const nsReach = nsReachableByRel.get(p.rel) ?? /* @__PURE__ */ new Set();
1759
+ const modReach = moduleReachableByRel.get(p.rel) ?? /* @__PURE__ */ new Set();
1760
+ const target = resolveType(h.superName, p.rel, p.lang, imported, defsByName, testCaller, nsReach, modReach);
1723
1761
  if (target) edges.add(h.kind, srcId, target.id, "heuristic", 0.85);
1724
1762
  else bumpUnresolved(unresolved2, srcId, h.superName, h.kind, p.rel);
1725
1763
  }
@@ -1770,21 +1808,52 @@ function parentQualifiedName(qn) {
1770
1808
  const idx = qn.lastIndexOf(".");
1771
1809
  return idx > 0 ? qn.slice(0, idx) : null;
1772
1810
  }
1773
- function enclosingDefId(defs, byte) {
1811
+ function enclosingDefRef(defs, byte) {
1774
1812
  let best;
1775
1813
  for (const d of defs) {
1776
1814
  if (d.startByte <= byte && d.endByte >= byte) {
1777
1815
  if (!best || d.endByte - d.startByte < best.endByte - best.startByte) best = d;
1778
1816
  }
1779
1817
  }
1780
- return best?.id;
1818
+ return best;
1819
+ }
1820
+ function enclosingDefId(defs, byte) {
1821
+ return enclosingDefRef(defs, byte)?.id;
1822
+ }
1823
+ function addToSet(map, key, value) {
1824
+ const s = map.get(key);
1825
+ if (s) s.add(value);
1826
+ else map.set(key, /* @__PURE__ */ new Set([value]));
1827
+ }
1828
+ function parentTypeName(qualifiedName) {
1829
+ const i = qualifiedName.lastIndexOf(".");
1830
+ return i > 0 ? qualifiedName.slice(0, i) : null;
1831
+ }
1832
+ function disambiguateInterfaceImpl(pool, superTypesByType) {
1833
+ const withParent = pool.map((c) => ({ c, parent: parentTypeName(c.qualifiedName) })).filter((x) => x.parent !== null);
1834
+ if (withParent.length < 2) return null;
1835
+ const parents = new Set(withParent.map((x) => x.parent));
1836
+ const impls = withParent.filter(
1837
+ (x) => [...parents].some((other) => other !== x.parent && superTypesByType.get(x.parent)?.has(other))
1838
+ );
1839
+ if (impls.length === 0) return null;
1840
+ const interfaceParents = /* @__PURE__ */ new Set();
1841
+ for (const impl of impls) for (const s of superTypesByType.get(impl.parent) ?? []) interfaceParents.add(s);
1842
+ const interfaces = withParent.filter((x) => interfaceParents.has(x.parent));
1843
+ const uniqueImplIds = new Set(impls.map((x) => x.c.id));
1844
+ if (uniqueImplIds.size === 1) return impls[0].c;
1845
+ const uniqueIfaceIds = new Set(interfaces.map((x) => x.c.id));
1846
+ if (uniqueIfaceIds.size === 1) return interfaces[0].c;
1847
+ return null;
1781
1848
  }
1782
1849
  var PACKAGE_SCOPED_LANGS = /* @__PURE__ */ new Set(["go", "java", "cs", "kotlin", "scala", "swift"]);
1850
+ var IMPORT_NAMES_A_TYPE = /* @__PURE__ */ new Set(["java", "kotlin", "scala", "php"]);
1851
+ var MODULE_SCOPED_LANGS = /* @__PURE__ */ new Set(["swift"]);
1783
1852
  function dirOf(rel2) {
1784
1853
  const i = rel2.lastIndexOf("/");
1785
1854
  return i >= 0 ? rel2.slice(0, i) : "";
1786
1855
  }
1787
- function resolveCall(call, fromRel, fromLang, importedRels, defsByName, enclosingId, fromIsTestFile = false) {
1856
+ function resolveCall(call, fromRel, fromLang, importedRels, defsByName, enclosingId, fromIsTestFile = false, nsReachableRels = /* @__PURE__ */ new Set(), superTypesByType = /* @__PURE__ */ new Map(), moduleReachableRels = /* @__PURE__ */ new Set()) {
1788
1857
  const candidates = defsByName.get(call.callee);
1789
1858
  if (!candidates || candidates.length === 0) return null;
1790
1859
  const callable = candidates.filter((c) => c.kind === "function" || c.kind === "method");
@@ -1796,21 +1865,24 @@ function resolveCall(call, fromRel, fromLang, importedRels, defsByName, enclosin
1796
1865
  const pick = [...sameFile].sort((a, b) => a.id.localeCompare(b.id))[0];
1797
1866
  return { id: pick.id, confidence: 0.4 };
1798
1867
  }
1799
- const imported = pool.filter((c) => importedRels.has(c.rel));
1800
- if (imported.length === 1) return { id: imported[0].id, confidence: 0.75 };
1801
- if (imported.length > 1) return null;
1802
- if (PACKAGE_SCOPED_LANGS.has(fromLang)) {
1803
- const dir = dirOf(fromRel);
1804
- let samePkg = pool.filter((c) => c.lang === fromLang && dirOf(c.rel) === dir);
1805
- if (call.qualified && enclosingId) samePkg = samePkg.filter((c) => c.id !== enclosingId);
1806
- if (samePkg.length === 1) return { id: samePkg[0].id, confidence: 0.7 };
1868
+ const dir = dirOf(fromRel);
1869
+ const notSelf = (c) => !(call.qualified && enclosingId && c.id === enclosingId);
1870
+ const strict = pool.filter(
1871
+ (c) => notSelf(c) && (importedRels.has(c.rel) || PACKAGE_SCOPED_LANGS.has(fromLang) && c.lang === fromLang && dirOf(c.rel) === dir || nsReachableRels.has(c.rel))
1872
+ );
1873
+ if (strict.length === 1) return { id: strict[0].id, confidence: 0.75 };
1874
+ const broad = pool.filter((c) => notSelf(c) && (moduleReachableRels.has(c.rel) || strict.includes(c)));
1875
+ if (broad.length > 1) {
1876
+ const dedup = disambiguateInterfaceImpl(broad, superTypesByType);
1877
+ if (dedup) return { id: dedup.id, confidence: 0.6 };
1807
1878
  }
1879
+ if (strict.length > 1) return null;
1808
1880
  if (fromLang === "swift" && fromIsTestFile && pool.length === 1) {
1809
1881
  return { id: pool[0].id, confidence: 0.5 };
1810
1882
  }
1811
1883
  return null;
1812
1884
  }
1813
- function resolveType(name, fromRel, fromLang, importedRels, defsByName, fromIsTestFile = false) {
1885
+ function resolveType(name, fromRel, fromLang, importedRels, defsByName, fromIsTestFile = false, nsReachableRels = /* @__PURE__ */ new Set(), moduleReachableRels = /* @__PURE__ */ new Set()) {
1814
1886
  const candidates = (defsByName.get(name) ?? []).filter(
1815
1887
  (c) => c.kind === "class" || c.kind === "interface"
1816
1888
  );
@@ -1825,6 +1897,10 @@ function resolveType(name, fromRel, fromLang, importedRels, defsByName, fromIsTe
1825
1897
  const samePkg = candidates.filter((c) => c.lang === fromLang && dirOf(c.rel) === dir);
1826
1898
  if (samePkg.length === 1) return { id: samePkg[0].id };
1827
1899
  }
1900
+ if (nsReachableRels.size || moduleReachableRels.size) {
1901
+ const reach = candidates.filter((c) => nsReachableRels.has(c.rel) || moduleReachableRels.has(c.rel));
1902
+ if (reach.length === 1) return { id: reach[0].id };
1903
+ }
1828
1904
  if (fromLang === "swift" && fromIsTestFile && candidates.length === 1) {
1829
1905
  return { id: candidates[0].id };
1830
1906
  }
@@ -1881,6 +1957,9 @@ function tsResolveEdges(root, tsFiles, nodes) {
1881
1957
  const edges = /* @__PURE__ */ new Map();
1882
1958
  const covered = /* @__PURE__ */ new Set();
1883
1959
  const stats = empty.stats;
1960
+ const interfaceCalls = [];
1961
+ const byId = /* @__PURE__ */ new Map();
1962
+ for (const list of nodesByFile.values()) for (const n of list) byId.set(n.id, n);
1884
1963
  for (const file of tsFiles) {
1885
1964
  const sf = program.getSourceFile(file.abs);
1886
1965
  if (!sf) continue;
@@ -1898,6 +1977,9 @@ function tsResolveEdges(root, tsFiles, nodes) {
1898
1977
  if (src && src.id !== target.id) {
1899
1978
  add2(edges, callKind(target), src.id, target.id);
1900
1979
  stats.resolved++;
1980
+ if (target.kind === "interface" && ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {
1981
+ interfaceCalls.push({ srcId: src.id, interfaceId: target.id, method: node.expression.name.text });
1982
+ }
1901
1983
  }
1902
1984
  }
1903
1985
  } else if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
@@ -1931,6 +2013,27 @@ function tsResolveEdges(root, tsFiles, nodes) {
1931
2013
  };
1932
2014
  visit(sf);
1933
2015
  }
2016
+ const implsByInterface = /* @__PURE__ */ new Map();
2017
+ for (const e of edges.values()) {
2018
+ if (e.kind !== "implements" && e.kind !== "extends") continue;
2019
+ if (byId.get(e.dst)?.kind !== "interface") continue;
2020
+ const list = implsByInterface.get(e.dst);
2021
+ if (list) list.push(e.src);
2022
+ else implsByInterface.set(e.dst, [e.src]);
2023
+ }
2024
+ for (const { srcId, interfaceId, method } of interfaceCalls) {
2025
+ const impls = implsByInterface.get(interfaceId);
2026
+ if (!impls || impls.length !== 1) continue;
2027
+ const impl = byId.get(impls[0]);
2028
+ if (!impl) continue;
2029
+ const target = (nodesByFile.get(impl.file) ?? []).find(
2030
+ (n) => (n.kind === "method" || n.kind === "function") && n.qualifiedName === `${impl.qualifiedName}.${method}`
2031
+ );
2032
+ if (target && target.id !== srcId) {
2033
+ add2(edges, "call", srcId, target.id);
2034
+ stats.resolved++;
2035
+ }
2036
+ }
1934
2037
  return { edges: [...edges.values()], coveredFiles: covered, stats };
1935
2038
  }
1936
2039
  function callKind(target) {
@@ -2046,7 +2149,7 @@ function enclosing3(nodes, line) {
2046
2149
  function normalize2(p) {
2047
2150
  return path17.resolve(p).split(path17.sep).join("/");
2048
2151
  }
2049
- var CACHE_VERSION = "vg-parse-cache/2";
2152
+ var CACHE_VERSION = "vg-parse-cache/3";
2050
2153
  function cacheDir(root) {
2051
2154
  return path17.join(root, ".vibgrate", "cache");
2052
2155
  }
@@ -7828,5 +7931,5 @@ function spdx(ctx) {
7828
7931
  }
7829
7932
 
7830
7933
  export { ASSISTANTS, CLI_TOOL_ALIASES, CliError, ECOSYSTEMS, ExitCode, FREE_PACK, GraphIndex, GraphSource, NPX_INVOCATION, ResourceLimitError, SAVINGS_TOOLS, SCHEMA_VERSION, SKIP_DIRS, SKIP_FILES, SMALL_REPO_FILES, TOOLS, UsageError, addLibrary, analyze, applyCoverage, applyStaticTestLinkage, assessDocQuality, assistantById, availableRegionIds, buildFacts, buildGraph, buildModuleResolver, cacheDir, catalogPath, clearModelCache, clearSavings, clearStoredCredentials, cosine, countPending, countTokens, coveringTests, createServer, createWorkspaceDsn, credentialsPath, dashHostForIngestHost, decodeScipIndex, defaultGraphPath, detectAssistants, detectRunner, detectServeLaunch, discover, discoverModels, driftCount, driftFor, dsnCommand, embeddingsCached, enrichOnline, ensureGitignored, epistemicBreakdown, exportGraph, fetchHostedDocsCached, findGitRoot, findNodes, formatForExt, getNodeEmbeddings, gitignoreEntryForCredentials, groundGraph, hasDrift, homeCredentialsPath, hostedBase, identifierParts, impactOf, indexFor, ingestHostForRegionId, installAssistant, inventory, isModelReady, isTestFile, libDir, libId, loadCatalog, loadCoverage, loadEmbedder, loadGraph, loadSnapshot, localApiSurface, localPackageDocs, modelCacheInfo, nodeById, nodeEmbedText, parseDsn, parseGraph, parseJsonc, probeFreshness, projectCredentialsPath, publishPrivateLibrary, pushCommand, queryGraph, queryGraphSemantic, readDoc, readSavings, readScanArtifact, readStoredCredentials, readUsage, recordCliCall, recordSaving, refreshIfStale, refreshInstalledInstructions, relativeResolver, renderHtml, renderReport, resolveCliInvocation, resolveDsn, resolveEmbedModel, resolveIngestHost, resolveLib, resolveLimits, resolveOne, resolveVersion, sanitizeClient, saveCatalog, savingsLedgerPath, savingsRecorded, scipEdges, selectForBudget, serializeGraph, serveStdio, shortestPath, stableStringify, symbolsFromApi, testsToRun, unavailableMessage, uninstallAssistant, uploadScanArtifact, usageError, verifyDeterminism, vibgrateDir, writeArtifacts, writeNavigationConfig, writeSnapshot, writeStoredCredentials };
7831
- //# sourceMappingURL=chunk-3DPZQS2Q.js.map
7832
- //# sourceMappingURL=chunk-3DPZQS2Q.js.map
7934
+ //# sourceMappingURL=chunk-ELUFCQDR.js.map
7935
+ //# sourceMappingURL=chunk-ELUFCQDR.js.map