scip-query 0.2.1 → 0.3.2

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 (131) hide show
  1. package/dist/chunk-26DOJ63W.js +161 -0
  2. package/dist/{chunk-PMJKOXOT.js → chunk-4JCSOF2O.js} +2 -2
  3. package/dist/{chunk-AKMBBKWV.js → chunk-5OMVSV6E.js} +12 -4
  4. package/dist/{chunk-R56FJU3E.js → chunk-7KIMF5PV.js} +2 -2
  5. package/dist/chunk-AXQKUYKF.js +1442 -0
  6. package/dist/chunk-C7H5WBTJ.js +46 -0
  7. package/dist/{chunk-AMNISGYR.js → chunk-CHDJXYBG.js} +2 -27
  8. package/dist/{chunk-GPJVPT3U.js → chunk-CPVAQJEC.js} +12 -4
  9. package/dist/{chunk-75RQSBTK.js → chunk-DH7G3DDV.js} +2 -2
  10. package/dist/{chunk-LTJC5ZQL.js → chunk-EOROMIFO.js} +13 -5
  11. package/dist/{chunk-BFLULBEU.js → chunk-EPWLXXBL.js} +2 -2
  12. package/dist/{chunk-MVH45PYK.js → chunk-FYYOWQXK.js} +12 -12
  13. package/dist/chunk-GEXE2T6I.js +87 -0
  14. package/dist/{chunk-IXPHLF6K.js → chunk-GJDHTTR2.js} +10 -3
  15. package/dist/chunk-GSH2FPKV.js +87 -0
  16. package/dist/{chunk-4ACRRQC4.js → chunk-HJZUSUPU.js} +2 -2
  17. package/dist/{chunk-M3NPW3FC.js → chunk-HLKAFWWJ.js} +81 -2
  18. package/dist/{chunk-CU62ZDHI.js → chunk-HLUS2HEB.js} +2 -2
  19. package/dist/{chunk-RFMT7UAZ.js → chunk-J3JSOSUO.js} +8 -5
  20. package/dist/{chunk-HDSRORNV.js → chunk-KKCHYLVI.js} +17 -11
  21. package/dist/{chunk-Y3M323OX.js → chunk-LFJQVJYJ.js} +2 -2
  22. package/dist/{chunk-6WVR5K46.js → chunk-LQJUPXQY.js} +3 -3
  23. package/dist/{chunk-ITZ3DDOG.js → chunk-MPGIHELS.js} +18 -3
  24. package/dist/{chunk-N4C3H7LH.js → chunk-NFS5W3PP.js} +2 -2
  25. package/dist/{chunk-Y4JFVQ7C.js → chunk-O7Q7FDUJ.js} +21 -13
  26. package/dist/{chunk-H6WCPKCX.js → chunk-OIDHN6GD.js} +2 -2
  27. package/dist/{chunk-4BQFSNFI.js → chunk-P3E6L7KW.js} +2 -2
  28. package/dist/{chunk-ORINICIZ.js → chunk-P4WO3BBW.js} +2 -2
  29. package/dist/{chunk-M4QGEKKD.js → chunk-SMDCNPMK.js} +8 -3
  30. package/dist/{chunk-6QSHLFSL.js → chunk-UGQKAVCD.js} +2 -2
  31. package/dist/{chunk-HMYJJ3HY.js → chunk-UQEQ6AHX.js} +3 -3
  32. package/dist/{chunk-WVK7AASK.js → chunk-VIYSWZCO.js} +2 -2
  33. package/dist/chunk-VJJKSGIX.js +121 -0
  34. package/dist/{chunk-N5KEREIA.js → chunk-VT4JBH6L.js} +19 -7
  35. package/dist/{chunk-R2I3M5B4.js → chunk-WGAD3GNR.js} +2 -2
  36. package/dist/{chunk-IJKLB2JW.js → chunk-YDBXNPYU.js} +2 -2
  37. package/dist/{chunk-VO4QI3LS.js → chunk-YY4QGUQ5.js} +2 -2
  38. package/dist/{chunk-3566TKJ5.js → chunk-ZEUCXQBN.js} +2 -2
  39. package/dist/cli.js +2314 -1352
  40. package/dist/{db-BHYam4BK.d.ts → db-ShvwGDKf.d.ts} +6 -1
  41. package/dist/index.d.ts +2 -2
  42. package/dist/index.js +38 -38
  43. package/dist/queries/affected.d.ts +1 -1
  44. package/dist/queries/affected.js +2 -2
  45. package/dist/queries/bottlenecks.d.ts +1 -1
  46. package/dist/queries/by-kind.d.ts +1 -1
  47. package/dist/queries/by-kind.js +1 -1
  48. package/dist/queries/call-graph.d.ts +1 -1
  49. package/dist/queries/call-graph.js +2 -2
  50. package/dist/queries/change-surface.d.ts +1 -1
  51. package/dist/queries/change-surface.js +2 -1
  52. package/dist/queries/code.d.ts +1 -1
  53. package/dist/queries/code.js +2 -2
  54. package/dist/queries/complexity-hotspots.d.ts +1 -1
  55. package/dist/queries/complexity-hotspots.js +2 -2
  56. package/dist/queries/complexity.d.ts +1 -1
  57. package/dist/queries/complexity.js +2 -2
  58. package/dist/queries/convergence.d.ts +1 -1
  59. package/dist/queries/convergence.js +2 -2
  60. package/dist/queries/coupling.d.ts +1 -1
  61. package/dist/queries/coupling.js +3 -1
  62. package/dist/queries/cycles.d.ts +1 -1
  63. package/dist/queries/cycles.js +2 -2
  64. package/dist/queries/dataflow.d.ts +1 -1
  65. package/dist/queries/dataflow.js +2 -2
  66. package/dist/queries/dead.d.ts +1 -1
  67. package/dist/queries/dead.js +3 -3
  68. package/dist/queries/deep-chains.d.ts +1 -1
  69. package/dist/queries/deep-chains.js +2 -2
  70. package/dist/queries/deps.d.ts +1 -1
  71. package/dist/queries/deps.js +3 -1
  72. package/dist/queries/diff-impact.d.ts +1 -1
  73. package/dist/queries/doc-coverage.d.ts +1 -1
  74. package/dist/queries/drift.d.ts +1 -1
  75. package/dist/queries/drift.js +2 -2
  76. package/dist/queries/extract-candidates.d.ts +1 -1
  77. package/dist/queries/extract-candidates.js +2 -2
  78. package/dist/queries/fan.d.ts +1 -1
  79. package/dist/queries/fan.js +2 -1
  80. package/dist/queries/files.d.ts +1 -1
  81. package/dist/queries/health.d.ts +1 -1
  82. package/dist/queries/health.js +13 -13
  83. package/dist/queries/hierarchy.d.ts +1 -1
  84. package/dist/queries/hierarchy.js +2 -2
  85. package/dist/queries/hotspots.d.ts +1 -1
  86. package/dist/queries/imports.d.ts +1 -1
  87. package/dist/queries/imports.js +2 -2
  88. package/dist/queries/index.d.ts +1 -1
  89. package/dist/queries/index.js +38 -38
  90. package/dist/queries/isolated.d.ts +1 -1
  91. package/dist/queries/isolated.js +3 -3
  92. package/dist/queries/members.d.ts +1 -1
  93. package/dist/queries/members.js +2 -2
  94. package/dist/queries/methods.d.ts +1 -1
  95. package/dist/queries/outline.d.ts +1 -1
  96. package/dist/queries/outline.js +2 -1
  97. package/dist/queries/passthrough-candidates.d.ts +1 -1
  98. package/dist/queries/passthrough-candidates.js +2 -2
  99. package/dist/queries/redundant-reexports.d.ts +1 -1
  100. package/dist/queries/redundant-reexports.js +3 -3
  101. package/dist/queries/refs.d.ts +1 -1
  102. package/dist/queries/refs.js +3 -1
  103. package/dist/queries/similar-chains.d.ts +1 -1
  104. package/dist/queries/similar-chains.js +2 -2
  105. package/dist/queries/similar-files.d.ts +1 -1
  106. package/dist/queries/similar-files.js +2 -2
  107. package/dist/queries/similar-signatures.d.ts +1 -1
  108. package/dist/queries/similar.d.ts +1 -1
  109. package/dist/queries/similar.js +2 -2
  110. package/dist/queries/slice.d.ts +2 -2
  111. package/dist/queries/slice.js +2 -2
  112. package/dist/queries/stale-abstractions.d.ts +1 -1
  113. package/dist/queries/stale-abstractions.js +2 -2
  114. package/dist/queries/stats.d.ts +1 -1
  115. package/dist/queries/surface.d.ts +1 -1
  116. package/dist/queries/surface.js +2 -1
  117. package/dist/queries/symbols.d.ts +1 -1
  118. package/dist/queries/symbols.js +2 -1
  119. package/dist/queries/system.d.ts +1 -1
  120. package/dist/queries/system.js +2 -1
  121. package/dist/queries/trace.d.ts +1 -1
  122. package/dist/queries/trace.js +2 -2
  123. package/dist/queries/wrapper-candidates.d.ts +1 -1
  124. package/dist/queries/wrapper-candidates.js +2 -2
  125. package/package.json +1 -1
  126. package/dist/chunk-34JPTNRN.js +0 -601
  127. package/dist/chunk-7JFZSOJ7.js +0 -103
  128. package/dist/chunk-DY4AFG2W.js +0 -48
  129. package/dist/chunk-LLMPAG56.js +0 -221
  130. package/dist/chunk-NVIIM34O.js +0 -65
  131. package/dist/chunk-YAFWL3RA.js +0 -55
@@ -0,0 +1,46 @@
1
+ import {
2
+ findFirstSymbolMatch,
3
+ getCalleeRowsForSymbol,
4
+ getCallerRowsForSymbol
5
+ } from "./chunk-AXQKUYKF.js";
6
+ import {
7
+ shortenSymbol
8
+ } from "./chunk-QIXNAB5K.js";
9
+
10
+ // src/queries/call-graph.ts
11
+ function callGraph(db, symbolPattern) {
12
+ const target = findFirstSymbolMatch(db, symbolPattern);
13
+ if (!target) return null;
14
+ const callerRows = getCallerRowsForSymbol(db, target, { limit: 50 });
15
+ const calleeRows = uniqueRows(getCalleeRowsForSymbol(db, target, { limit: 50 }));
16
+ return {
17
+ symbol: target.symbol,
18
+ shortName: shortenSymbol(target.symbol),
19
+ callers: callerRows.map((r) => ({
20
+ symbol: r.symbol,
21
+ shortName: shortenSymbol(r.symbol),
22
+ file: r.file
23
+ })),
24
+ callees: calleeRows.map((r) => ({
25
+ symbol: r.symbol,
26
+ shortName: shortenSymbol(r.symbol),
27
+ file: r.file
28
+ }))
29
+ };
30
+ }
31
+ function uniqueRows(rows) {
32
+ const seen = /* @__PURE__ */ new Set();
33
+ const unique = [];
34
+ for (const row of rows) {
35
+ const key = `${row.symbol}|${row.file}`;
36
+ if (seen.has(key)) continue;
37
+ seen.add(key);
38
+ unique.push(row);
39
+ }
40
+ return unique;
41
+ }
42
+
43
+ export {
44
+ callGraph
45
+ };
46
+ //# sourceMappingURL=chunk-C7H5WBTJ.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  findFirstSymbolMatch,
3
3
  getCalleeRowsForSymbol
4
- } from "./chunk-LLMPAG56.js";
4
+ } from "./chunk-AXQKUYKF.js";
5
5
  import {
6
6
  shortenSymbol
7
7
  } from "./chunk-QIXNAB5K.js";
@@ -19,21 +19,6 @@ function slice(db, symbolPattern, opts = {}) {
19
19
  }
20
20
  function backwardSlice(db, match) {
21
21
  const callees = getCalleeRowsForSymbol(db, match);
22
- const localPredecessors = db.all(
23
- `SELECT DISTINCT gs.symbol, d.relative_path AS file
24
- FROM defn_enclosing_ranges der
25
- JOIN global_symbols gs ON der.symbol_id = gs.id
26
- JOIN documents d ON der.document_id = d.id
27
- WHERE der.document_id = ?
28
- AND der.end_line < ?
29
- AND gs.id != ?
30
- ${db.symbolNoiseFor("gs")}
31
- ORDER BY der.start_line DESC
32
- LIMIT 15`,
33
- match.documentId,
34
- match.startLine,
35
- match.symbolId
36
- );
37
22
  const seen = /* @__PURE__ */ new Set();
38
23
  const connected = [];
39
24
  for (const c of callees) {
@@ -46,16 +31,6 @@ function backwardSlice(db, match) {
46
31
  relationship: "referenced within definition (callee)"
47
32
  });
48
33
  }
49
- for (const p of localPredecessors) {
50
- if (seen.has(p.symbol) || db.isIgnored(p.file)) continue;
51
- seen.add(p.symbol);
52
- connected.push({
53
- symbol: p.symbol,
54
- shortName: shortenSymbol(p.symbol),
55
- file: p.file,
56
- relationship: "defined before target in same file (local predecessor)"
57
- });
58
- }
59
34
  return {
60
35
  symbol: match.symbol,
61
36
  shortName: shortenSymbol(match.symbol),
@@ -122,4 +97,4 @@ function forwardSlice(db, match) {
122
97
  export {
123
98
  slice
124
99
  };
125
- //# sourceMappingURL=chunk-AMNISGYR.js.map
100
+ //# sourceMappingURL=chunk-CHDJXYBG.js.map
@@ -1,12 +1,20 @@
1
1
  import {
2
2
  cleanSignature
3
3
  } from "./chunk-4TYLS5XX.js";
4
+ import {
5
+ resolveIndexedPaths
6
+ } from "./chunk-AXQKUYKF.js";
4
7
  import {
5
8
  shortenSymbol
6
9
  } from "./chunk-QIXNAB5K.js";
7
10
 
8
11
  // src/queries/symbols.ts
9
12
  function symbols(db, filePattern) {
13
+ const resolvedPaths = resolveIndexedPaths(db, filePattern);
14
+ if (resolvedPaths.length === 0) {
15
+ return [];
16
+ }
17
+ const placeholders = resolvedPaths.map(() => "?").join(", ");
10
18
  const rows = db.all(
11
19
  `SELECT
12
20
  der.start_line,
@@ -17,11 +25,11 @@ function symbols(db, filePattern) {
17
25
  FROM defn_enclosing_ranges der
18
26
  JOIN global_symbols gs ON der.symbol_id = gs.id
19
27
  JOIN documents d ON der.document_id = d.id
20
- WHERE d.relative_path LIKE ?
28
+ WHERE d.relative_path IN (${placeholders})
21
29
  AND ${db.localSymbolPredicate}
22
30
  ${db.symbolNoise}
23
- ORDER BY der.start_line`,
24
- `%${filePattern}%`
31
+ ORDER BY d.relative_path, der.start_line`,
32
+ ...resolvedPaths
25
33
  );
26
34
  return rows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({
27
35
  startLine: r.start_line,
@@ -35,4 +43,4 @@ function symbols(db, filePattern) {
35
43
  export {
36
44
  symbols
37
45
  };
38
- //# sourceMappingURL=chunk-GPJVPT3U.js.map
46
+ //# sourceMappingURL=chunk-CPVAQJEC.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildFileDepGraph
3
- } from "./chunk-LLMPAG56.js";
3
+ } from "./chunk-AXQKUYKF.js";
4
4
 
5
5
  // src/queries/deep-chains.ts
6
6
  function deepChains(db, opts = {}) {
@@ -41,4 +41,4 @@ function deepChains(db, opts = {}) {
41
41
  export {
42
42
  deepChains
43
43
  };
44
- //# sourceMappingURL=chunk-75RQSBTK.js.map
44
+ //# sourceMappingURL=chunk-DH7G3DDV.js.map
@@ -1,9 +1,17 @@
1
+ import {
2
+ resolveIndexedPaths
3
+ } from "./chunk-AXQKUYKF.js";
1
4
  import {
2
5
  shortenSymbol
3
6
  } from "./chunk-QIXNAB5K.js";
4
7
 
5
8
  // src/queries/surface.ts
6
9
  function surface(db, modulePattern) {
10
+ const matchedPaths = resolveIndexedPaths(db, modulePattern);
11
+ if (matchedPaths.length === 0) {
12
+ return [];
13
+ }
14
+ const placeholders = matchedPaths.map(() => "?").join(", ");
7
15
  const rows = db.all(
8
16
  `SELECT DISTINCT d1.relative_path, gs.symbol
9
17
  FROM mentions m
@@ -12,13 +20,13 @@ function surface(db, modulePattern) {
12
20
  JOIN global_symbols gs ON m.symbol_id = gs.id
13
21
  JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
14
22
  JOIN documents d2 ON der.document_id = d2.id
15
- WHERE d2.relative_path LIKE ?
16
- AND d1.relative_path NOT LIKE ?
23
+ WHERE d2.relative_path IN (${placeholders})
24
+ AND d1.relative_path NOT IN (${placeholders})
17
25
  AND ${db.localSymbolPredicate}
18
26
  AND m.role != 1
19
27
  ORDER BY d1.relative_path`,
20
- `%${modulePattern}%`,
21
- `%${modulePattern}%`
28
+ ...matchedPaths,
29
+ ...matchedPaths
22
30
  );
23
31
  return rows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({
24
32
  consumer: r.relative_path,
@@ -30,4 +38,4 @@ function surface(db, modulePattern) {
30
38
  export {
31
39
  surface
32
40
  };
33
- //# sourceMappingURL=chunk-LTJC5ZQL.js.map
41
+ //# sourceMappingURL=chunk-EOROMIFO.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getCalleeRowsForSymbol
3
- } from "./chunk-LLMPAG56.js";
3
+ } from "./chunk-AXQKUYKF.js";
4
4
  import {
5
5
  shortenSymbol
6
6
  } from "./chunk-QIXNAB5K.js";
@@ -111,4 +111,4 @@ function extractCandidates(db, opts = {}) {
111
111
  export {
112
112
  extractCandidates
113
113
  };
114
- //# sourceMappingURL=chunk-BFLULBEU.js.map
114
+ //# sourceMappingURL=chunk-EPWLXXBL.js.map
@@ -1,39 +1,39 @@
1
1
  import {
2
2
  staleAbstractions
3
- } from "./chunk-ORINICIZ.js";
3
+ } from "./chunk-P4WO3BBW.js";
4
4
  import {
5
5
  stats
6
6
  } from "./chunk-74RFWB5T.js";
7
7
  import {
8
8
  wrapperCandidates
9
- } from "./chunk-PMJKOXOT.js";
9
+ } from "./chunk-4JCSOF2O.js";
10
10
  import {
11
11
  passthroughCandidates
12
- } from "./chunk-3566TKJ5.js";
12
+ } from "./chunk-ZEUCXQBN.js";
13
13
  import {
14
14
  similarAll
15
- } from "./chunk-H6WCPKCX.js";
15
+ } from "./chunk-OIDHN6GD.js";
16
16
  import {
17
17
  isolated
18
- } from "./chunk-HMYJJ3HY.js";
18
+ } from "./chunk-UQEQ6AHX.js";
19
19
  import {
20
20
  drift
21
- } from "./chunk-R56FJU3E.js";
21
+ } from "./chunk-7KIMF5PV.js";
22
22
  import {
23
23
  extractCandidates
24
- } from "./chunk-BFLULBEU.js";
24
+ } from "./chunk-EPWLXXBL.js";
25
25
  import {
26
26
  complexityHotspots
27
- } from "./chunk-WVK7AASK.js";
27
+ } from "./chunk-VIYSWZCO.js";
28
28
  import {
29
29
  cycles
30
- } from "./chunk-Y3M323OX.js";
30
+ } from "./chunk-LFJQVJYJ.js";
31
31
  import {
32
32
  dead
33
- } from "./chunk-6WVR5K46.js";
33
+ } from "./chunk-LQJUPXQY.js";
34
34
  import {
35
35
  isEntrySurface
36
- } from "./chunk-VO4QI3LS.js";
36
+ } from "./chunk-YY4QGUQ5.js";
37
37
 
38
38
  // src/queries/health.ts
39
39
  function health(db, opts = {}) {
@@ -235,4 +235,4 @@ function health(db, opts = {}) {
235
235
  export {
236
236
  health
237
237
  };
238
- //# sourceMappingURL=chunk-MVH45PYK.js.map
238
+ //# sourceMappingURL=chunk-FYYOWQXK.js.map
@@ -0,0 +1,87 @@
1
+ import {
2
+ cleanSignature
3
+ } from "./chunk-4TYLS5XX.js";
4
+ import {
5
+ findFirstSymbolMatch,
6
+ getSourceReferenceSites
7
+ } from "./chunk-AXQKUYKF.js";
8
+ import {
9
+ isFunctionLikeSymbol,
10
+ shortenSymbol
11
+ } from "./chunk-QIXNAB5K.js";
12
+
13
+ // src/queries/trace.ts
14
+ function trace(db, symbolPattern) {
15
+ const match = findFirstSymbolMatch(db, symbolPattern);
16
+ if (!match) {
17
+ return { definitions: [], referencedBy: [] };
18
+ }
19
+ const defRows = db.all(
20
+ `SELECT d.relative_path, der.start_line, der.end_line,
21
+ gs.display_name,
22
+ REPLACE(SUBSTR(gs.documentation, INSTR(gs.documentation, '|') + 1), char(10), ' ') AS sig
23
+ FROM global_symbols gs
24
+ JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
25
+ JOIN documents d ON der.document_id = d.id
26
+ WHERE gs.id = ?
27
+ ORDER BY d.relative_path, der.start_line
28
+ LIMIT 10`,
29
+ match.symbolId
30
+ );
31
+ const definitions = defRows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({
32
+ relativePath: r.relative_path,
33
+ startLine: r.start_line,
34
+ endLine: r.end_line,
35
+ signature: buildTraceSignature(r.sig, r.display_name, match.symbol)
36
+ }));
37
+ const sourceSites = getSourceReferenceSites(db, match);
38
+ const referencedBy = sourceSites.length > 0 ? sourceSites.filter((site) => !db.isIgnored(site.file)).map((site) => ({
39
+ relativePath: site.file,
40
+ line: site.line,
41
+ enclosingSymbol: site.enclosingSymbol,
42
+ enclosingShort: site.enclosingSymbol ? shortenSymbol(site.enclosingSymbol) : "(top-level)"
43
+ })) : db.all(
44
+ `SELECT DISTINCT d.relative_path, c.start_line AS line,
45
+ (SELECT enc_gs.symbol
46
+ FROM defn_enclosing_ranges enc_der
47
+ JOIN global_symbols enc_gs ON enc_der.symbol_id = enc_gs.id
48
+ WHERE enc_der.document_id = d.id
49
+ AND enc_der.start_line <= c.start_line
50
+ AND enc_der.end_line >= c.end_line
51
+ ORDER BY (enc_der.end_line - enc_der.start_line) ASC
52
+ LIMIT 1
53
+ ) AS enclosing_symbol
54
+ FROM mentions m
55
+ JOIN chunks c ON m.chunk_id = c.id
56
+ JOIN documents d ON c.document_id = d.id
57
+ WHERE m.symbol_id = ?
58
+ AND m.role != 1
59
+ ORDER BY d.relative_path, c.start_line`,
60
+ match.symbolId
61
+ ).filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({
62
+ relativePath: r.relative_path,
63
+ line: r.line,
64
+ enclosingSymbol: r.enclosing_symbol,
65
+ enclosingShort: r.enclosing_symbol ? shortenSymbol(r.enclosing_symbol) : "(top-level)"
66
+ }));
67
+ return { definitions, referencedBy };
68
+ }
69
+ function buildTraceSignature(signature, displayName, rawSymbol) {
70
+ const cleaned = cleanSignature(signature);
71
+ if (cleaned && !looksBogusSignature(cleaned)) {
72
+ return cleaned;
73
+ }
74
+ const fallback = (displayName ?? "").trim();
75
+ if (fallback) {
76
+ return isFunctionLikeSymbol(rawSymbol) && !fallback.endsWith("()") ? `${fallback}()` : fallback;
77
+ }
78
+ return shortenSymbol(rawSymbol);
79
+ }
80
+ function looksBogusSignature(signature) {
81
+ return signature.startsWith("undefined") || signature.includes("|") || signature.includes("```");
82
+ }
83
+
84
+ export {
85
+ trace
86
+ };
87
+ //# sourceMappingURL=chunk-GEXE2T6I.js.map
@@ -1,3 +1,6 @@
1
+ import {
2
+ resolveIndexedFile
3
+ } from "./chunk-AXQKUYKF.js";
1
4
  import {
2
5
  shortenSymbol
3
6
  } from "./chunk-QIXNAB5K.js";
@@ -21,6 +24,10 @@ function fanIn(db, symbolPattern) {
21
24
  }));
22
25
  }
23
26
  function fanOut(db, filePattern) {
27
+ const resolvedFile = resolveIndexedFile(db, filePattern);
28
+ if (!resolvedFile) {
29
+ return [];
30
+ }
24
31
  const rows = db.all(
25
32
  `SELECT d.relative_path, COUNT(DISTINCT gs.id) AS symbol_count
26
33
  FROM mentions m
@@ -29,12 +36,12 @@ function fanOut(db, filePattern) {
29
36
  JOIN global_symbols gs ON m.symbol_id = gs.id
30
37
  JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
31
38
  JOIN documents def_d ON der.document_id = def_d.id
32
- WHERE d.relative_path LIKE ?
39
+ WHERE d.relative_path = ?
33
40
  AND m.role != 1
34
41
  AND def_d.id != d.id
35
42
  GROUP BY d.id
36
43
  ORDER BY symbol_count DESC`,
37
- `%${filePattern}%`
44
+ resolvedFile
38
45
  );
39
46
  return rows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({
40
47
  name: r.relative_path,
@@ -99,4 +106,4 @@ export {
99
106
  topFanIn,
100
107
  topFanOut
101
108
  };
102
- //# sourceMappingURL=chunk-IXPHLF6K.js.map
109
+ //# sourceMappingURL=chunk-GJDHTTR2.js.map
@@ -0,0 +1,87 @@
1
+ import {
2
+ findFirstSymbolMatch,
3
+ getCalleeRowsForSymbol,
4
+ getSourceReferenceSites
5
+ } from "./chunk-AXQKUYKF.js";
6
+ import {
7
+ shortenSymbol
8
+ } from "./chunk-QIXNAB5K.js";
9
+
10
+ // src/queries/dataflow.ts
11
+ function dataflow(db, symbolPattern) {
12
+ const match = findFirstSymbolMatch(db, symbolPattern);
13
+ if (!match) return null;
14
+ const defSites = [{
15
+ file: match.relativePath,
16
+ line: match.startLine
17
+ }];
18
+ const sourceUsageSites = getSourceReferenceSites(db, match);
19
+ const usageSites = sourceUsageSites.length > 0 ? sourceUsageSites.map((site) => ({
20
+ file: site.file,
21
+ line: site.line,
22
+ enclosing_symbol: site.enclosingSymbol
23
+ })) : db.all(
24
+ `SELECT d.relative_path AS file, c.start_line AS line,
25
+ (SELECT enc_gs.symbol
26
+ FROM defn_enclosing_ranges enc_der
27
+ JOIN global_symbols enc_gs ON enc_der.symbol_id = enc_gs.id
28
+ WHERE enc_der.document_id = d.id
29
+ AND enc_der.start_line <= c.start_line
30
+ AND enc_der.end_line >= c.end_line
31
+ ORDER BY (enc_der.end_line - enc_der.start_line) ASC
32
+ LIMIT 1
33
+ ) AS enclosing_symbol
34
+ FROM mentions m
35
+ JOIN chunks c ON m.chunk_id = c.id
36
+ JOIN documents d ON c.document_id = d.id
37
+ WHERE m.symbol_id = ? AND m.role != 1
38
+ ${db.pathExclusionsFor("d")}
39
+ ORDER BY d.relative_path, c.start_line`,
40
+ match.symbolId
41
+ );
42
+ const normalizedUsageSites = usageSites.filter((site) => !db.isIgnored(site.file)).map((site) => ({
43
+ file: site.file,
44
+ line: site.line,
45
+ enclosingSymbol: site.enclosing_symbol ?? "(top-level)",
46
+ enclosingShort: site.enclosing_symbol ? shortenSymbol(site.enclosing_symbol) : "(top-level)"
47
+ }));
48
+ const producers = uniqueSymbolRows(getCalleeRowsForSymbol(db, match, { limit: 30 }).map((row) => ({
49
+ symbol: row.symbol,
50
+ file: row.file
51
+ })));
52
+ const consumers = uniqueSymbolRows(
53
+ normalizedUsageSites.map((site) => ({
54
+ symbol: site.enclosingSymbol === "(top-level)" ? site.file : site.enclosingSymbol,
55
+ file: site.file
56
+ }))
57
+ );
58
+ return {
59
+ symbol: match.symbol,
60
+ shortName: shortenSymbol(match.symbol),
61
+ relativePath: match.relativePath,
62
+ definitionSites: defSites.filter((s) => !db.isIgnored(s.file)),
63
+ usageSites: normalizedUsageSites,
64
+ producers: producers.filter((p) => !db.isIgnored(p.file)).map((p) => ({ symbol: p.symbol, shortName: shortenSymbol(p.symbol), file: p.file })),
65
+ consumers: consumers.filter((c) => !db.isIgnored(c.file)).map((c) => ({
66
+ symbol: c.symbol,
67
+ shortName: c.symbol === c.file ? "(top-level)" : shortenSymbol(c.symbol),
68
+ file: c.file
69
+ }))
70
+ };
71
+ }
72
+ function uniqueSymbolRows(rows) {
73
+ const seen = /* @__PURE__ */ new Set();
74
+ const unique = [];
75
+ for (const row of rows) {
76
+ const key = `${row.symbol}|${row.file}`;
77
+ if (seen.has(key)) continue;
78
+ seen.add(key);
79
+ unique.push(row);
80
+ }
81
+ return unique;
82
+ }
83
+
84
+ export {
85
+ dataflow
86
+ };
87
+ //# sourceMappingURL=chunk-GSH2FPKV.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  findFirstSymbolMatch,
3
3
  getCalleeRowsForSymbol
4
- } from "./chunk-LLMPAG56.js";
4
+ } from "./chunk-AXQKUYKF.js";
5
5
  import {
6
6
  shortenSymbol
7
7
  } from "./chunk-QIXNAB5K.js";
@@ -73,4 +73,4 @@ function convergence(db, symbolPatternA, symbolPatternB) {
73
73
  export {
74
74
  convergence
75
75
  };
76
- //# sourceMappingURL=chunk-4ACRRQC4.js.map
76
+ //# sourceMappingURL=chunk-HJZUSUPU.js.map
@@ -1,4 +1,6 @@
1
1
  import {
2
+ leafSuffix,
3
+ parseSymbol,
2
4
  shortenSymbol
3
5
  } from "./chunk-QIXNAB5K.js";
4
6
 
@@ -118,7 +120,7 @@ function byKind(db, kindQuery, opts = {}) {
118
120
  `SELECT COUNT(*) AS c FROM global_symbols WHERE kind IS NOT NULL`
119
121
  );
120
122
  if (!hasKinds || hasKinds.c === 0) {
121
- return [];
123
+ return inferByKind(db, kindNum, scope, limit);
122
124
  }
123
125
  const rows = db.all(
124
126
  `SELECT gs.symbol, gs.kind, d.relative_path, der.start_line, der.end_line
@@ -158,15 +160,92 @@ function kindCounts(db, opts = {}) {
158
160
  GROUP BY gs.kind
159
161
  ORDER BY cnt DESC`
160
162
  );
163
+ if (rows.length === 0) {
164
+ return inferKindCounts(db, opts.scope);
165
+ }
161
166
  return rows.map((r) => ({
162
167
  kind: r.kind,
163
168
  kindName: KIND_NAMES[r.kind] ?? "Unknown",
164
169
  count: r.cnt
165
170
  }));
166
171
  }
172
+ function inferByKind(db, kindNum, scope, limit = 100) {
173
+ const scopeFilter = scope ? `AND d.relative_path LIKE '%${scope}%'` : "";
174
+ const rows = db.all(
175
+ `SELECT gs.symbol, d.relative_path, der.start_line, der.end_line, gs.documentation, gs.enclosing_symbol
176
+ FROM global_symbols gs
177
+ JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
178
+ JOIN documents d ON der.document_id = d.id
179
+ WHERE 1 = 1
180
+ ${db.pathExclusionsFor("d")}
181
+ ${scopeFilter}
182
+ ORDER BY d.relative_path, der.start_line`
183
+ );
184
+ return rows.filter((row) => !db.isIgnored(row.relative_path)).map((row) => ({
185
+ row,
186
+ inferredKind: inferKindNumber(row.symbol, row.documentation, row.enclosing_symbol)
187
+ })).filter((entry) => entry.inferredKind === kindNum).slice(0, limit).map(({ row, inferredKind }) => ({
188
+ symbol: row.symbol,
189
+ shortName: shortenSymbol(row.symbol),
190
+ kind: inferredKind,
191
+ kindName: KIND_NAMES[inferredKind] ?? "Unknown",
192
+ relativePath: row.relative_path,
193
+ startLine: row.start_line,
194
+ endLine: row.end_line
195
+ }));
196
+ }
197
+ function inferKindCounts(db, scope) {
198
+ const scopeFilter = scope ? `AND d.relative_path LIKE '%${scope}%'` : "";
199
+ const rows = db.all(
200
+ `SELECT gs.symbol, gs.documentation, gs.enclosing_symbol, d.relative_path
201
+ FROM global_symbols gs
202
+ JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
203
+ JOIN documents d ON der.document_id = d.id
204
+ WHERE 1 = 1
205
+ ${db.pathExclusionsFor("d")}
206
+ ${scopeFilter}`
207
+ );
208
+ const counts = /* @__PURE__ */ new Map();
209
+ for (const row of rows) {
210
+ if (db.isIgnored(row.relative_path)) continue;
211
+ const inferred = inferKindNumber(row.symbol, row.documentation, row.enclosing_symbol);
212
+ if (inferred === null || inferred === 0) continue;
213
+ counts.set(inferred, (counts.get(inferred) ?? 0) + 1);
214
+ }
215
+ return [...counts.entries()].sort((a, b) => b[1] - a[1] || a[0] - b[0]).map(([kind, count]) => ({
216
+ kind,
217
+ kindName: KIND_NAMES[kind] ?? "Unknown",
218
+ count
219
+ }));
220
+ }
221
+ function inferKindNumber(symbol, documentation, enclosingSymbol) {
222
+ const parsed = parseSymbol(symbol);
223
+ if ("kind" in parsed) {
224
+ return null;
225
+ }
226
+ const descriptors = parsed.descriptors;
227
+ const last = descriptors[descriptors.length - 1] ?? null;
228
+ const parent = descriptors[descriptors.length - 2] ?? null;
229
+ const suffix = leafSuffix(symbol);
230
+ if (suffix === "type") return 9;
231
+ if (suffix === "method") {
232
+ return parent?.suffix === "type" ? 33 : 23;
233
+ }
234
+ if (suffix === "namespace") return 39;
235
+ if (suffix !== "term") return null;
236
+ const signature = (documentation ?? "").toLowerCase();
237
+ if (signature.includes("async def ") || signature.includes("def ")) {
238
+ return 23;
239
+ }
240
+ const enclosingSuffix = enclosingSymbol ? leafSuffix(enclosingSymbol) : parent?.suffix ?? null;
241
+ if (enclosingSuffix === "type") {
242
+ return 21;
243
+ }
244
+ return 83;
245
+ }
167
246
 
168
247
  export {
169
248
  byKind,
170
249
  kindCounts
171
250
  };
172
- //# sourceMappingURL=chunk-M3NPW3FC.js.map
251
+ //# sourceMappingURL=chunk-HLKAFWWJ.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildFileDepGraph
3
- } from "./chunk-LLMPAG56.js";
3
+ } from "./chunk-AXQKUYKF.js";
4
4
 
5
5
  // src/queries/similar-files.ts
6
6
  function similarFiles(db, opts = {}) {
@@ -89,4 +89,4 @@ function compareProfiles(a, b, minSimilarity) {
89
89
  export {
90
90
  similarFiles
91
91
  };
92
- //# sourceMappingURL=chunk-CU62ZDHI.js.map
92
+ //# sourceMappingURL=chunk-HLUS2HEB.js.map
@@ -1,6 +1,7 @@
1
1
  import {
2
- findFirstSymbolMatch
3
- } from "./chunk-LLMPAG56.js";
2
+ findFirstSymbolMatch,
3
+ resolveIndexedFile
4
+ } from "./chunk-AXQKUYKF.js";
4
5
  import {
5
6
  shortenSymbol
6
7
  } from "./chunk-QIXNAB5K.js";
@@ -43,9 +44,11 @@ function code(db, symbolPattern, opts = {}) {
43
44
  };
44
45
  }
45
46
  function readFileRange(db, filePath, startLine, endLine, context) {
47
+ const resolvedPath = resolveIndexedFile(db, filePath);
48
+ if (!resolvedPath) return null;
46
49
  const doc = db.get(
47
- `SELECT relative_path, language FROM documents WHERE relative_path LIKE ?`,
48
- `%${filePath}%`
50
+ `SELECT relative_path, language FROM documents WHERE relative_path = ?`,
51
+ resolvedPath
49
52
  );
50
53
  if (!doc) return null;
51
54
  const fullPath = join(db.config.projectRoot, doc.relative_path);
@@ -73,4 +76,4 @@ function readFileRange(db, filePath, startLine, endLine, context) {
73
76
  export {
74
77
  code
75
78
  };
76
- //# sourceMappingURL=chunk-RFMT7UAZ.js.map
79
+ //# sourceMappingURL=chunk-J3JSOSUO.js.map