scip-query 0.5.0 → 0.6.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 (199) hide show
  1. package/dist/chunk-2DSS2NGF.js +10 -0
  2. package/dist/chunk-2RLP74AO.js +2 -0
  3. package/dist/chunk-4QJ7LVW5.js +2 -0
  4. package/dist/chunk-4TYGGOLO.js +5 -0
  5. package/dist/chunk-5IADAU5B.js +7 -0
  6. package/dist/chunk-7754WFFV.js +18 -0
  7. package/dist/chunk-7VOF4ZG6.js +2 -0
  8. package/dist/chunk-7Z4COVMC.js +2 -0
  9. package/dist/chunk-AJ5PWKD4.js +2 -0
  10. package/dist/chunk-BDBRZPX3.js +7 -0
  11. package/dist/chunk-BE6EQIWY.js +2 -0
  12. package/dist/chunk-BQ3INTYT.js +8 -0
  13. package/dist/chunk-D7KLLMPB.js +2 -0
  14. package/dist/chunk-D7YBWSON.js +29 -0
  15. package/dist/chunk-DE5ZBHMK.js +39 -0
  16. package/dist/chunk-DHYIJHXZ.js +33 -0
  17. package/dist/chunk-EEF3YEHW.js +2 -0
  18. package/dist/chunk-F2LLHRRZ.js +2 -0
  19. package/dist/chunk-FCC3XJTI.js +2 -0
  20. package/dist/chunk-GNXRLK5G.js +2 -0
  21. package/dist/chunk-GXVB36TG.js +62 -0
  22. package/dist/chunk-HMKJTAZD.js +2 -0
  23. package/dist/chunk-IBGBI3VU.js +2 -0
  24. package/dist/chunk-IYFZS4PV.js +84 -0
  25. package/dist/chunk-JH3A7HTU.js +2 -0
  26. package/dist/chunk-JS2RNIC7.js +2 -0
  27. package/dist/chunk-K5FQFCSN.js +41 -0
  28. package/dist/chunk-K6GBKEQE.js +6 -0
  29. package/dist/chunk-KO7YJRWP.js +12 -0
  30. package/dist/chunk-KYT47WU2.js +4 -0
  31. package/dist/chunk-LORWXBOO.js +2 -0
  32. package/dist/chunk-LX4H4LLG.js +89 -0
  33. package/dist/chunk-N3Z2SJCR.js +2 -0
  34. package/dist/chunk-NTDA4A2D.js +25 -0
  35. package/dist/chunk-NXMYYHDO.js +24 -0
  36. package/dist/chunk-PZ6ESKRH.js +7 -0
  37. package/dist/chunk-QXE6EDY2.js +6 -0
  38. package/dist/chunk-RJ7SPBJ5.js +5 -0
  39. package/dist/chunk-RWE6FHG3.js +3 -0
  40. package/dist/chunk-SDX6MDBL.js +2 -0
  41. package/dist/chunk-SG35Y7J2.js +2 -0
  42. package/dist/chunk-STOGKRJH.js +4 -0
  43. package/dist/chunk-TINPMWJK.js +2 -0
  44. package/dist/chunk-UJB62HV3.js +2 -0
  45. package/dist/chunk-VEUMRDHW.js +2 -0
  46. package/dist/chunk-WCDXJGYT.js +65 -0
  47. package/dist/chunk-WTSTDJZ7.js +6 -0
  48. package/dist/chunk-XAZTIDST.js +2 -0
  49. package/dist/chunk-XVDASCN7.js +35 -0
  50. package/dist/chunk-Y7H6D2EV.js +2 -0
  51. package/dist/chunk-Y7LOQSWY.js +2 -0
  52. package/dist/chunk-YIPCV7M7.js +70 -0
  53. package/dist/chunk-ZSRXMNMK.js +5 -0
  54. package/dist/chunk-ZXKURFVB.js +56 -0
  55. package/dist/cli.js +509 -8758
  56. package/dist/{db-6F9R9e_t.d.ts → db-BSTtBG_H.d.ts} +146 -1
  57. package/dist/index.d.ts +11 -2
  58. package/dist/index.js +13 -1616
  59. package/dist/postinstall.js +4 -100
  60. package/dist/queries/affected.d.ts +1 -1
  61. package/dist/queries/affected.js +1 -8
  62. package/dist/queries/bottlenecks.d.ts +1 -1
  63. package/dist/queries/bottlenecks.js +1 -8
  64. package/dist/queries/by-kind.d.ts +1 -4
  65. package/dist/queries/by-kind.js +1 -10
  66. package/dist/queries/call-graph.d.ts +1 -1
  67. package/dist/queries/call-graph.js +1 -8
  68. package/dist/queries/change-surface.d.ts +1 -1
  69. package/dist/queries/change-surface.js +1 -8
  70. package/dist/queries/code.d.ts +1 -1
  71. package/dist/queries/code.js +1 -8
  72. package/dist/queries/complexity-hotspots.d.ts +5 -10
  73. package/dist/queries/complexity-hotspots.js +1 -8
  74. package/dist/queries/complexity.d.ts +1 -1
  75. package/dist/queries/complexity.js +1 -8
  76. package/dist/queries/convergence.d.ts +1 -1
  77. package/dist/queries/convergence.js +1 -8
  78. package/dist/queries/coupling.d.ts +1 -1
  79. package/dist/queries/coupling.js +1 -10
  80. package/dist/queries/cycles.d.ts +1 -1
  81. package/dist/queries/cycles.js +1 -8
  82. package/dist/queries/dataflow.d.ts +1 -1
  83. package/dist/queries/dataflow.js +1 -8
  84. package/dist/queries/dead.d.ts +1 -1
  85. package/dist/queries/dead.js +1 -9
  86. package/dist/queries/deep-chains.d.ts +9 -1
  87. package/dist/queries/deep-chains.js +1 -8
  88. package/dist/queries/deps.d.ts +1 -1
  89. package/dist/queries/deps.js +1 -10
  90. package/dist/queries/diff-impact.d.ts +1 -1
  91. package/dist/queries/diff-impact.js +1 -7
  92. package/dist/queries/drift.d.ts +1 -1
  93. package/dist/queries/drift.js +1 -8
  94. package/dist/queries/extract-candidates.d.ts +1 -1
  95. package/dist/queries/extract-candidates.js +1 -8
  96. package/dist/queries/fan.d.ts +1 -1
  97. package/dist/queries/fan.js +1 -14
  98. package/dist/queries/files.d.ts +1 -1
  99. package/dist/queries/files.js +1 -6
  100. package/dist/queries/health.d.ts +1 -1
  101. package/dist/queries/health.js +1 -20
  102. package/dist/queries/hierarchy.d.ts +1 -1
  103. package/dist/queries/hierarchy.js +1 -8
  104. package/dist/queries/hotspots.d.ts +1 -1
  105. package/dist/queries/hotspots.js +1 -8
  106. package/dist/queries/imports.d.ts +1 -1
  107. package/dist/queries/imports.js +1 -12
  108. package/dist/queries/index.d.ts +1 -1
  109. package/dist/queries/index.js +1 -197
  110. package/dist/queries/isolated.d.ts +1 -1
  111. package/dist/queries/isolated.js +1 -9
  112. package/dist/queries/members.d.ts +1 -1
  113. package/dist/queries/members.js +1 -8
  114. package/dist/queries/methods.d.ts +1 -1
  115. package/dist/queries/methods.js +1 -8
  116. package/dist/queries/outline.d.ts +1 -1
  117. package/dist/queries/outline.js +1 -8
  118. package/dist/queries/passthrough-candidates.d.ts +1 -1
  119. package/dist/queries/passthrough-candidates.js +1 -8
  120. package/dist/queries/redundant-reexports.d.ts +1 -1
  121. package/dist/queries/redundant-reexports.js +1 -9
  122. package/dist/queries/refs.d.ts +1 -1
  123. package/dist/queries/refs.js +1 -8
  124. package/dist/queries/similar-chains.d.ts +1 -1
  125. package/dist/queries/similar-chains.js +1 -8
  126. package/dist/queries/similar-files.d.ts +1 -1
  127. package/dist/queries/similar-files.js +1 -8
  128. package/dist/queries/similar-signatures.d.ts +1 -1
  129. package/dist/queries/similar-signatures.js +1 -8
  130. package/dist/queries/similar.d.ts +1 -1
  131. package/dist/queries/similar.js +1 -10
  132. package/dist/queries/slice.d.ts +1 -1
  133. package/dist/queries/slice.js +1 -8
  134. package/dist/queries/stale-abstractions.d.ts +15 -5
  135. package/dist/queries/stale-abstractions.js +1 -8
  136. package/dist/queries/stats.d.ts +1 -1
  137. package/dist/queries/stats.js +1 -6
  138. package/dist/queries/surface.d.ts +1 -1
  139. package/dist/queries/surface.js +1 -8
  140. package/dist/queries/symbols.d.ts +1 -1
  141. package/dist/queries/symbols.js +1 -9
  142. package/dist/queries/system.d.ts +1 -1
  143. package/dist/queries/system.js +1 -9
  144. package/dist/queries/trace.d.ts +1 -1
  145. package/dist/queries/trace.js +1 -9
  146. package/dist/queries/wrapper-candidates.d.ts +1 -1
  147. package/dist/queries/wrapper-candidates.js +1 -8
  148. package/dist/reindex-worker.js +7 -672
  149. package/package.json +20 -2
  150. package/dist/chunk-2MQ5DPY6.js +0 -61
  151. package/dist/chunk-2QTYIOJ5.js +0 -165
  152. package/dist/chunk-3VI4YXCL.js +0 -172
  153. package/dist/chunk-3VV2G6U7.js +0 -34
  154. package/dist/chunk-44PFXVXG.js +0 -76
  155. package/dist/chunk-6SLFQR36.js +0 -64
  156. package/dist/chunk-74RFWB5T.js +0 -24
  157. package/dist/chunk-7DBPRGMS.js +0 -221
  158. package/dist/chunk-DTB724R3.js +0 -110
  159. package/dist/chunk-FLOYI6I4.js +0 -185
  160. package/dist/chunk-FO2CBB7U.js +0 -23
  161. package/dist/chunk-GJT3MO2T.js +0 -17
  162. package/dist/chunk-HAP4LJKX.js +0 -66
  163. package/dist/chunk-JCOJQ4I6.js +0 -93
  164. package/dist/chunk-JGQMOS4V.js +0 -59
  165. package/dist/chunk-JMD4WJ2Q.js +0 -213
  166. package/dist/chunk-JSQPZOPO.js +0 -64
  167. package/dist/chunk-JSXGC2EH.js +0 -151
  168. package/dist/chunk-JZN3DRCT.js +0 -59
  169. package/dist/chunk-KMWYB3CX.js +0 -71
  170. package/dist/chunk-MRM755FU.js +0 -37
  171. package/dist/chunk-N2XO3Z5F.js +0 -69
  172. package/dist/chunk-OLW5UL36.js +0 -76
  173. package/dist/chunk-OMCRXXDX.js +0 -2600
  174. package/dist/chunk-OWJOHUZE.js +0 -44
  175. package/dist/chunk-P3VCDYMJ.js +0 -269
  176. package/dist/chunk-PEDH3D4G.js +0 -53
  177. package/dist/chunk-POAN4SCR.js +0 -46
  178. package/dist/chunk-PTMGEBU3.js +0 -101
  179. package/dist/chunk-PU44HK7P.js +0 -87
  180. package/dist/chunk-QJI7EECA.js +0 -327
  181. package/dist/chunk-R5HICGMB.js +0 -110
  182. package/dist/chunk-RJ2D6YWQ.js +0 -49
  183. package/dist/chunk-RZ5GYPBP.js +0 -79
  184. package/dist/chunk-SRLQNO6O.js +0 -101
  185. package/dist/chunk-UGS7HJI4.js +0 -84
  186. package/dist/chunk-VKUUXOE7.js +0 -105
  187. package/dist/chunk-VPUJSJCI.js +0 -84
  188. package/dist/chunk-VRWVV3EP.js +0 -72
  189. package/dist/chunk-WJWQEU4A.js +0 -162
  190. package/dist/chunk-WJZHDUSB.js +0 -40
  191. package/dist/chunk-WWOCQ5W4.js +0 -34
  192. package/dist/chunk-X3Q2OVRL.js +0 -77
  193. package/dist/chunk-Y3P7QKKN.js +0 -27
  194. package/dist/chunk-Y6FAHY4N.js +0 -81
  195. package/dist/chunk-YMSJCSRG.js +0 -213
  196. package/dist/chunk-ZDL3U4W2.js +0 -124
  197. package/dist/chunk-ZXNX5JRE.js +0 -216
  198. package/dist/queries/clean-signature.d.ts +0 -17
  199. package/dist/queries/clean-signature.js +0 -9
@@ -1,84 +0,0 @@
1
- import {
2
- buildFileDepGraph
3
- } from "./chunk-OMCRXXDX.js";
4
-
5
- // src/entry-surfaces.ts
6
- var liveBarrelCache = /* @__PURE__ */ new WeakMap();
7
- function normalizePath(path) {
8
- return path.replace(/\\/g, "/");
9
- }
10
- function isBarrelFile(path) {
11
- const normalized = normalizePath(path);
12
- return normalized === "index.ts" || normalized === "index.js" || normalized.endsWith("/index.ts") || normalized.endsWith("/index.js") || normalized.endsWith("/mod.rs") || normalized.endsWith("/__init__.py");
13
- }
14
- function isWorkerEntrySurface(path) {
15
- const normalized = normalizePath(path);
16
- return /(^|\/)[^/]*worker\.(ts|js|mjs|cjs|rs|py|go)$/.test(normalized);
17
- }
18
- function isStructuralEntrySurface(path) {
19
- const normalized = normalizePath(path);
20
- const segments = normalized.split("/");
21
- const basename = segments[segments.length - 1] ?? normalized;
22
- if (basename === "cli.ts" || basename === "cli.js" || basename === "postinstall.ts" || basename === "postinstall.js" || basename === "main.ts" || basename === "main.js" || basename === "main.rs" || basename === "main.go" || basename === "main.py") {
23
- return true;
24
- }
25
- if (basename === "index.ts" || basename === "index.js") {
26
- return segments.length <= 2;
27
- }
28
- return normalized.endsWith("/mod.rs") || normalized.endsWith("/__init__.py");
29
- }
30
- function getIndexedPaths(db) {
31
- return db.all(
32
- `SELECT d.relative_path
33
- FROM documents d
34
- WHERE 1 = 1
35
- ${db.pathExclusionsFor("d")}
36
- ORDER BY d.relative_path`
37
- ).map((row) => row.relative_path).filter((path) => !db.isIgnored(path));
38
- }
39
- function getLiveBarrelPaths(db) {
40
- const cached = liveBarrelCache.get(db);
41
- if (cached) {
42
- return cached;
43
- }
44
- const graph = buildFileDepGraph(db);
45
- const queue = getIndexedPaths(db).filter(
46
- (path) => isStructuralEntrySurface(path) || isWorkerEntrySurface(path)
47
- );
48
- const visited = /* @__PURE__ */ new Set();
49
- const liveBarrels = /* @__PURE__ */ new Set();
50
- while (queue.length > 0) {
51
- const current = queue.shift();
52
- if (visited.has(current)) {
53
- continue;
54
- }
55
- visited.add(current);
56
- if (isBarrelFile(current)) {
57
- liveBarrels.add(current);
58
- }
59
- for (const dep of graph.get(current) ?? []) {
60
- if (!visited.has(dep)) {
61
- queue.push(dep);
62
- }
63
- }
64
- }
65
- liveBarrelCache.set(db, liveBarrels);
66
- return liveBarrels;
67
- }
68
- function isLiveBarrel(db, path) {
69
- return getLiveBarrelPaths(db).has(normalizePath(path));
70
- }
71
- function isEntrySurface(db, path) {
72
- return isStructuralEntrySurface(path) || isWorkerEntrySurface(path) || isLiveBarrel(db, path);
73
- }
74
- function getInactiveBarrelPaths(db) {
75
- const liveBarrels = getLiveBarrelPaths(db);
76
- return getIndexedPaths(db).filter((path) => isBarrelFile(path)).filter((path) => !liveBarrels.has(path));
77
- }
78
-
79
- export {
80
- isLiveBarrel,
81
- isEntrySurface,
82
- getInactiveBarrelPaths
83
- };
84
- //# sourceMappingURL=chunk-UGS7HJI4.js.map
@@ -1,105 +0,0 @@
1
- import {
2
- buildFileDepGraph,
3
- getCallerRowsForSymbol,
4
- getDefinitionsForFile,
5
- getScopedDefinitions
6
- } from "./chunk-OMCRXXDX.js";
7
- import {
8
- isFunctionLikeSymbol,
9
- shortenSymbol
10
- } from "./chunk-YMSJCSRG.js";
11
-
12
- // src/queries/wrapper-candidates.ts
13
- import { basename, extname } from "path";
14
- function wrapperCandidates(db, opts) {
15
- const { scope, maxLoc = 15, limit = 30 } = opts ?? {};
16
- const reverseFanIn = buildReverseFileFanIn(buildFileDepGraph(db, scope));
17
- const symbols = getScopedDefinitions(db, scope).filter((definition) => definitionLoc(definition) <= maxLoc && definitionLoc(definition) >= 2);
18
- const results = [];
19
- for (const symbol of symbols) {
20
- if (db.isIgnored(symbol.relativePath) || !isFunctionLikeSymbol(symbol.symbol)) continue;
21
- const symbolStem = basename(symbol.relativePath, extname(symbol.relativePath));
22
- const callerRows = dedupeRows(
23
- getCallerRowsForSymbol(db, symbol, { limit: 200 }).filter((row) => row.file !== symbol.relativePath)
24
- ).filter((row) => basename(row.file, extname(row.file)) !== symbolStem);
25
- if (callerRows.length !== 1) continue;
26
- const caller = callerRows[0];
27
- const callerDefinition = getDefinitionsForFile(db, caller.file).find((definition) => definition.symbol === caller.symbol);
28
- const useDefinitionFanIn = callerDefinition?.isFunctionLike ?? false;
29
- let callerFanIn;
30
- if (useDefinitionFanIn && callerDefinition) {
31
- callerFanIn = new Set(
32
- getCallerRowsForSymbol(db, callerDefinition, { limit: 500 }).filter((row) => row.file !== callerDefinition.relativePath).map((row) => row.file)
33
- ).size;
34
- } else {
35
- callerFanIn = fallbackCallerFanIn(db, reverseFanIn, caller.file);
36
- }
37
- if (callerFanIn <= 3) continue;
38
- results.push({
39
- symbol: symbol.symbol,
40
- shortName: shortenSymbol(symbol.symbol),
41
- file: symbol.relativePath,
42
- startLine: symbol.startLine,
43
- endLine: symbol.endLine,
44
- loc: definitionLoc(symbol),
45
- singleCaller: caller.symbol,
46
- singleCallerShort: useDefinitionFanIn ? shortenSymbol(caller.symbol) : basename(caller.file),
47
- callerFanIn
48
- });
49
- }
50
- results.sort((left, right) => right.callerFanIn - left.callerFanIn || right.loc - left.loc);
51
- return results.slice(0, limit);
52
- }
53
- function definitionLoc(definition) {
54
- return definition.endLine - definition.startLine + 1;
55
- }
56
- function dedupeRows(rows) {
57
- const seen = /* @__PURE__ */ new Set();
58
- const unique = [];
59
- for (const row of rows) {
60
- const key = `${row.symbol}|${row.file}`;
61
- if (seen.has(key)) continue;
62
- seen.add(key);
63
- unique.push(row);
64
- }
65
- return unique;
66
- }
67
- function buildReverseFileFanIn(graph) {
68
- const reverse = /* @__PURE__ */ new Map();
69
- for (const [fromFile, deps] of graph) {
70
- if (!reverse.has(fromFile)) {
71
- reverse.set(fromFile, reverse.get(fromFile) ?? 0);
72
- }
73
- for (const dep of deps) {
74
- reverse.set(dep, (reverse.get(dep) ?? 0) + 1);
75
- }
76
- }
77
- return reverse;
78
- }
79
- function fallbackCallerFanIn(db, reverseFanIn, callerFile) {
80
- const functionLikeFanIn = getDefinitionsForFile(db, callerFile).filter((definition) => definition.isFunctionLike).map((definition) => new Set(
81
- getCallerRowsForSymbol(db, definition, { limit: 500 }).filter((row) => row.file !== definition.relativePath).map((row) => row.file)
82
- ).size).sort((left, right) => right - left)[0] ?? 0;
83
- if (functionLikeFanIn > 0) {
84
- return functionLikeFanIn;
85
- }
86
- const direct = reverseFanIn.get(callerFile) ?? 0;
87
- if (direct > 0) {
88
- return direct;
89
- }
90
- const stem = basename(callerFile, extname(callerFile));
91
- let best = 0;
92
- for (const [file, fanIn] of reverseFanIn) {
93
- if (file === callerFile) continue;
94
- if (basename(file, extname(file)) !== stem) continue;
95
- if (fanIn > best) {
96
- best = fanIn;
97
- }
98
- }
99
- return best;
100
- }
101
-
102
- export {
103
- wrapperCandidates
104
- };
105
- //# sourceMappingURL=chunk-VKUUXOE7.js.map
@@ -1,84 +0,0 @@
1
- import {
2
- resolveIndexedFile
3
- } from "./chunk-OMCRXXDX.js";
4
-
5
- // src/queries/coupling.ts
6
- function coupling(db, file1, file2) {
7
- const resolvedFile1 = resolveIndexedFile(db, file1) ?? file1;
8
- const resolvedFile2 = resolveIndexedFile(db, file2) ?? file2;
9
- const row = db.get(
10
- `SELECT COUNT(DISTINCT gs.id) AS shared
11
- FROM global_symbols gs
12
- WHERE (
13
- -- Defined in file1, referenced in file2
14
- EXISTS (
15
- SELECT 1 FROM defn_enclosing_ranges der
16
- JOIN documents d ON der.document_id = d.id
17
- WHERE der.symbol_id = gs.id AND d.relative_path = ?
18
- )
19
- AND EXISTS (
20
- SELECT 1 FROM mentions m
21
- JOIN chunks c ON m.chunk_id = c.id
22
- JOIN documents d ON c.document_id = d.id
23
- WHERE m.symbol_id = gs.id AND m.role != 1 AND d.relative_path = ?
24
- )
25
- ) OR (
26
- -- Defined in file2, referenced in file1
27
- EXISTS (
28
- SELECT 1 FROM defn_enclosing_ranges der
29
- JOIN documents d ON der.document_id = d.id
30
- WHERE der.symbol_id = gs.id AND d.relative_path = ?
31
- )
32
- AND EXISTS (
33
- SELECT 1 FROM mentions m
34
- JOIN chunks c ON m.chunk_id = c.id
35
- JOIN documents d ON c.document_id = d.id
36
- WHERE m.symbol_id = gs.id AND m.role != 1 AND d.relative_path = ?
37
- )
38
- )`,
39
- resolvedFile1,
40
- resolvedFile2,
41
- resolvedFile2,
42
- resolvedFile1
43
- );
44
- return {
45
- file1: resolvedFile1,
46
- file2: resolvedFile2,
47
- sharedSymbols: row?.shared ?? 0
48
- };
49
- }
50
- function topCoupling(db, opts = {}) {
51
- const { limit = 20, scope } = opts;
52
- const scopeFilter = scope ? `AND d1.relative_path LIKE '%${scope}%' AND d2.relative_path LIKE '%${scope}%'` : "";
53
- const rows = db.all(
54
- `SELECT
55
- def_d.relative_path AS file1,
56
- ref_d.relative_path AS file2,
57
- COUNT(DISTINCT gs.id) AS shared
58
- FROM mentions m
59
- JOIN chunks c ON m.chunk_id = c.id
60
- JOIN documents ref_d ON c.document_id = ref_d.id
61
- JOIN global_symbols gs ON m.symbol_id = gs.id
62
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
63
- JOIN documents def_d ON der.document_id = def_d.id
64
- WHERE m.role != 1
65
- AND def_d.id != ref_d.id
66
- ${db.pathExclusionsFor("def_d", "ref_d")}
67
- ${scopeFilter}
68
- GROUP BY def_d.id, ref_d.id
69
- ORDER BY shared DESC
70
- LIMIT ?`,
71
- limit
72
- );
73
- return rows.filter((r) => !db.isIgnored(r.file1) && !db.isIgnored(r.file2)).map((r) => ({
74
- file1: r.file1,
75
- file2: r.file2,
76
- sharedSymbols: r.shared
77
- }));
78
- }
79
-
80
- export {
81
- coupling,
82
- topCoupling
83
- };
84
- //# sourceMappingURL=chunk-VPUJSJCI.js.map
@@ -1,72 +0,0 @@
1
- import {
2
- getDefinitionsForFile,
3
- resolveIndexedPaths
4
- } from "./chunk-OMCRXXDX.js";
5
- import {
6
- isCallableSymbol,
7
- shortenSymbol
8
- } from "./chunk-YMSJCSRG.js";
9
-
10
- // src/queries/surface.ts
11
- function surface(db, modulePattern) {
12
- const matchedPaths = resolveIndexedPaths(db, modulePattern);
13
- if (matchedPaths.length === 0) {
14
- return [];
15
- }
16
- const placeholders = matchedPaths.map(() => "?").join(", ");
17
- const rows = db.all(
18
- `SELECT DISTINCT d1.relative_path, gs.symbol
19
- FROM mentions m
20
- JOIN chunks c ON m.chunk_id = c.id
21
- JOIN documents d1 ON c.document_id = d1.id
22
- JOIN global_symbols gs ON m.symbol_id = gs.id
23
- WHERE d1.relative_path NOT IN (${placeholders})
24
- AND (
25
- EXISTS (
26
- SELECT 1
27
- FROM defn_enclosing_ranges der
28
- JOIN documents d2 ON der.document_id = d2.id
29
- WHERE der.symbol_id = gs.id
30
- AND d2.relative_path IN (${placeholders})
31
- )
32
- OR EXISTS (
33
- SELECT 1
34
- FROM mentions def_m
35
- JOIN chunks def_c ON def_m.chunk_id = def_c.id
36
- JOIN documents d2 ON def_c.document_id = d2.id
37
- WHERE def_m.symbol_id = gs.id
38
- AND def_m.role = 1
39
- AND d2.relative_path IN (${placeholders})
40
- )
41
- )
42
- AND m.role != 1
43
- AND ${db.localSymbolPredicate}
44
- ${db.pathExclusionsFor("d1")}
45
- ORDER BY d1.relative_path`,
46
- ...matchedPaths,
47
- ...matchedPaths,
48
- ...matchedPaths
49
- );
50
- const exposedDefinitions = matchedPaths.flatMap(
51
- (relativePath) => getDefinitionsForFile(db, relativePath).filter((definition) => isCallableSymbol(definition.symbol)).map((definition) => ({
52
- relative_path: relativePath,
53
- symbol: definition.symbol
54
- }))
55
- );
56
- const seen = /* @__PURE__ */ new Set();
57
- return [...rows, ...exposedDefinitions].filter((r) => !db.isIgnored(r.relative_path)).filter((r) => {
58
- const key = `${r.relative_path}|${r.symbol}`;
59
- if (seen.has(key)) return false;
60
- seen.add(key);
61
- return true;
62
- }).map((r) => ({
63
- consumer: r.relative_path,
64
- symbol: r.symbol,
65
- shortName: shortenSymbol(r.symbol)
66
- }));
67
- }
68
-
69
- export {
70
- surface
71
- };
72
- //# sourceMappingURL=chunk-VRWVV3EP.js.map
@@ -1,162 +0,0 @@
1
- import {
2
- getAllDefinitions,
3
- getSourceText
4
- } from "./chunk-OMCRXXDX.js";
5
- import {
6
- shortenSymbol
7
- } from "./chunk-YMSJCSRG.js";
8
-
9
- // src/queries/similar-signatures.ts
10
- function similarSignatures(db, opts = {}) {
11
- const { scope, minLoc = 1, limit } = opts;
12
- const sigGroups = /* @__PURE__ */ new Map();
13
- for (const definition of getAllDefinitions(db, { scope })) {
14
- if (!definition.isFunctionLike || db.isIgnored(definition.relativePath)) continue;
15
- const loc = definition.endLine - definition.startLine + 1;
16
- if (loc < minLoc) continue;
17
- const normalized = resolveNormalizedSignature(db, definition);
18
- if (!normalized) continue;
19
- const entry = {
20
- symbol: definition.symbol,
21
- shortName: shortenSymbol(definition.symbol),
22
- file: definition.relativePath,
23
- startLine: definition.startLine,
24
- endLine: definition.endLine,
25
- loc
26
- };
27
- const existing = sigGroups.get(normalized);
28
- if (existing) {
29
- existing.push(entry);
30
- } else {
31
- sigGroups.set(normalized, [entry]);
32
- }
33
- }
34
- const results = [];
35
- for (const [signature, functions] of sigGroups) {
36
- if (functions.length < 2) continue;
37
- results.push({ signature, functions });
38
- }
39
- results.sort((a, b) => {
40
- const sizeDiff = b.functions.length - a.functions.length;
41
- if (sizeDiff !== 0) return sizeDiff;
42
- const locA = a.functions.reduce((sum, f) => sum + f.loc, 0);
43
- const locB = b.functions.reduce((sum, f) => sum + f.loc, 0);
44
- return locB - locA;
45
- });
46
- return limit ? results.slice(0, limit) : results;
47
- }
48
- function resolveNormalizedSignature(db, definition) {
49
- const documented = extractDocumentedSignature(definition.documentation);
50
- const normalizedDocumented = documented ? normalizeSignature(documented) : null;
51
- if (normalizedDocumented) {
52
- return normalizedDocumented;
53
- }
54
- return normalizeSourceSignature(
55
- extractDeclarationHead(db, definition.relativePath, definition.startLine, definition.endLine, definition.leaf),
56
- definition.leaf
57
- );
58
- }
59
- function extractDocumentedSignature(documentation) {
60
- if (!documentation || !documentation.includes("|")) {
61
- return null;
62
- }
63
- const extracted = documentation.slice(documentation.indexOf("|") + 1).replace(/\n/g, " ").trim();
64
- return extracted.length > 0 ? extracted : null;
65
- }
66
- function extractDeclarationHead(db, relativePath, startLine, endLine, leaf) {
67
- const source = getSourceText(db, relativePath);
68
- if (!source) return null;
69
- const lines = source.split(/\r?\n/);
70
- const candidates = declarationStartLines(lines, startLine, endLine, leaf);
71
- for (const candidate of candidates) {
72
- const maxLine = Math.min(lines.length - 1, Math.max(candidate, candidate + 4));
73
- let collected = "";
74
- for (let lineIndex = candidate; lineIndex <= maxLine; lineIndex += 1) {
75
- const line = lines[lineIndex]?.trim();
76
- if (!line) continue;
77
- collected = collected ? `${collected} ${line}` : line;
78
- if (looksCompleteDeclaration(collected)) {
79
- return collected;
80
- }
81
- }
82
- if (collected && collected.includes("(")) {
83
- return collected;
84
- }
85
- }
86
- return null;
87
- }
88
- function looksCompleteDeclaration(declaration) {
89
- const normalized = declaration.replace(/\s+/g, " ").trim();
90
- if (!normalized.includes("(")) return false;
91
- if (parenBalance(normalized) > 0) return false;
92
- return /[;{]$/.test(normalized) || /\)\s*(?::\s*[^={]+)?\s*(?:=>|=|throws\b|where\b|$)/i.test(normalized) || /\)\s*As\s+.+$/i.test(normalized);
93
- }
94
- function normalizeSignature(raw) {
95
- if (!raw || !raw.trim()) return null;
96
- let sig = raw.replace(/^```\w*\s*/, "").replace(/\s*```$/, "").replace(/^\(method\)\s*/, "").replace(/^\(property\)\s*/, "").replace(/^\(function\)\s*/, "").replace(/^\(class\)\s*/, "").replace(/^\(interface\)\s*/, "").replace(/^\(enum\)\s*/, "").replace(/^\(type alias\)\s*/, "").replace(/^\(const\)\s*/, "").replace(/^\(var\)\s*/, "").trim();
97
- const parenIdx = sig.indexOf("(");
98
- if (parenIdx === -1) return null;
99
- sig = sig.slice(parenIdx);
100
- sig = sig.replace(/\s+/g, "").toLowerCase();
101
- if (sig.length < 3) return null;
102
- return sig;
103
- }
104
- function normalizeSourceSignature(raw, leaf) {
105
- if (!raw || !raw.trim()) return null;
106
- const declaration = raw.replace(/\s+/g, " ").trim();
107
- const parenIdx = declaration.indexOf("(");
108
- if (parenIdx === -1) return null;
109
- let prefix = declaration.slice(0, parenIdx);
110
- const leafPattern = new RegExp(`\\b${escapeRegex(leaf)}\\b`, "i");
111
- const leafMatch = leafPattern.exec(prefix);
112
- if (leafMatch && typeof leafMatch.index === "number") {
113
- prefix = prefix.slice(0, leafMatch.index);
114
- }
115
- prefix = prefix.replace(/\b(public|private|protected|internal|final|static|abstract|sealed|virtual|override|async|suspend|inline|constexpr|consteval|constinit|const|pub|fn|function|def|sub|friend|shared|readonly|new|open|partial|export)\b/gi, " ").replace(/\s+/g, " ").trim();
116
- const suffix = declaration.slice(parenIdx).replace(/\s*\{[\s\S]*$/, "").replace(/\s*=>[\s\S]*$/, "").replace(/\)\s*=\s*[\s\S]*$/, ")").replace(/\s+throws\s+[^={]+$/i, "").replace(/\s+where\s+.+$/i, "").replace(/\s+/g, " ").trim();
117
- if (!suffix.startsWith("(")) {
118
- return null;
119
- }
120
- const normalized = `${prefix ? `${prefix} ` : ""}${suffix}`.replace(/\s+/g, "").toLowerCase();
121
- return normalized.length >= 3 ? normalized : null;
122
- }
123
- function declarationStartLines(lines, startLine, endLine, leaf) {
124
- const escapedLeaf = escapeRegex(leaf);
125
- const callablePattern = new RegExp(`\\b${escapedLeaf}\\b\\s*\\(`, "i");
126
- const rubyPattern = new RegExp(`\\bdef\\s+${escapedLeaf}\\b`, "i");
127
- const candidates = [];
128
- const seen = /* @__PURE__ */ new Set();
129
- const preferredStart = Math.max(0, Math.min(startLine, lines.length - 1));
130
- const preferredEnd = Math.max(preferredStart, Math.min(lines.length - 1, Math.max(endLine, startLine + 4)));
131
- for (let lineIndex = preferredStart; lineIndex <= preferredEnd; lineIndex += 1) {
132
- const line = lines[lineIndex] ?? "";
133
- if ((callablePattern.test(line) || rubyPattern.test(line)) && !seen.has(lineIndex)) {
134
- seen.add(lineIndex);
135
- candidates.push(lineIndex);
136
- }
137
- }
138
- for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {
139
- const line = lines[lineIndex] ?? "";
140
- if ((callablePattern.test(line) || rubyPattern.test(line)) && !seen.has(lineIndex)) {
141
- seen.add(lineIndex);
142
- candidates.push(lineIndex);
143
- }
144
- }
145
- return candidates;
146
- }
147
- function parenBalance(value) {
148
- let balance = 0;
149
- for (const char of value) {
150
- if (char === "(") balance += 1;
151
- if (char === ")") balance -= 1;
152
- }
153
- return balance;
154
- }
155
- function escapeRegex(value) {
156
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
157
- }
158
-
159
- export {
160
- similarSignatures
161
- };
162
- //# sourceMappingURL=chunk-WJWQEU4A.js.map
@@ -1,40 +0,0 @@
1
- import {
2
- getAllDefinitions,
3
- getCalleeRowsForSymbol,
4
- getCallerRowsForSymbol
5
- } from "./chunk-OMCRXXDX.js";
6
- import {
7
- shortenSymbol
8
- } from "./chunk-YMSJCSRG.js";
9
-
10
- // src/queries/complexity-hotspots.ts
11
- function complexityHotspots(db, opts) {
12
- const { scope, minLoc = 10, limit = 30 } = opts ?? {};
13
- return getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).map((definition) => {
14
- const loc = definition.endLine - definition.startLine + 1;
15
- const callerRows = getCallerRowsForSymbol(db, definition, { limit: 500 });
16
- const calleeRows = getCalleeRowsForSymbol(db, definition, { limit: 500 });
17
- const fanIn = new Set(callerRows.map((row) => row.file)).size;
18
- const fanOut = new Set(
19
- calleeRows.filter((row) => row.file !== definition.relativePath).map((row) => `${row.symbol}|${row.file}`)
20
- ).size;
21
- const calleeCount = new Set(calleeRows.map((row) => `${row.symbol}|${row.file}`)).size;
22
- return {
23
- symbol: definition.symbol,
24
- shortName: shortenSymbol(definition.symbol),
25
- file: definition.relativePath,
26
- startLine: definition.startLine,
27
- endLine: definition.endLine,
28
- loc,
29
- fanIn,
30
- fanOut,
31
- calleeCount,
32
- score: Math.round(loc / 50 * (fanIn / 5) * Math.max(fanOut / 5, 1) * 100) / 100
33
- };
34
- }).filter((row) => row.loc >= minLoc).sort((left, right) => right.score - left.score || right.loc - left.loc).slice(0, limit);
35
- }
36
-
37
- export {
38
- complexityHotspots
39
- };
40
- //# sourceMappingURL=chunk-WJZHDUSB.js.map
@@ -1,34 +0,0 @@
1
- import {
2
- findFirstSymbolMatch,
3
- getDefinitionsForFile
4
- } from "./chunk-OMCRXXDX.js";
5
- import {
6
- isCallableSymbol,
7
- leafName
8
- } from "./chunk-YMSJCSRG.js";
9
-
10
- // src/queries/methods.ts
11
- import { basename } from "path";
12
- function methods(db, className) {
13
- const classMatch = findFirstSymbolMatch(db, className);
14
- if (!classMatch) {
15
- return [];
16
- }
17
- const ownerName = leafName(classMatch.symbol);
18
- const definitions = getDefinitionsForFile(db, classMatch.relativePath).filter((definition) => isCallableSymbol(definition.symbol));
19
- const directMethods = definitions.filter((definition) => definition.parentTypeName === ownerName || definition.symbol.includes(ownerName));
20
- const fileScopedMethods = directMethods.length > 0 ? directMethods : stripExtension(basename(classMatch.relativePath)) === ownerName ? definitions.filter((definition) => definition.symbol.includes("<invalid-global-code>")) : [];
21
- return fileScopedMethods.map((definition) => ({
22
- startLine: definition.startLine,
23
- endLine: definition.endLine,
24
- name: leafName(definition.symbol)
25
- }));
26
- }
27
- function stripExtension(relativePath) {
28
- return relativePath.replace(/\.[^.]+$/, "");
29
- }
30
-
31
- export {
32
- methods
33
- };
34
- //# sourceMappingURL=chunk-WWOCQ5W4.js.map
@@ -1,77 +0,0 @@
1
- import {
2
- findFirstSymbolMatch,
3
- getResolvedReferenceSites,
4
- getSourceReferenceSites,
5
- getSourceText
6
- } from "./chunk-OMCRXXDX.js";
7
- import {
8
- isFunctionLikeSymbol
9
- } from "./chunk-YMSJCSRG.js";
10
-
11
- // src/queries/refs.ts
12
- function refs(db, symbolPattern) {
13
- const match = findFirstSymbolMatch(db, symbolPattern);
14
- if (!match) return [];
15
- const includeDefinitionSite = !isFunctionLikeSymbol(match.symbol);
16
- const definitionRows = includeDefinitionSite && !db.isIgnored(match.relativePath) ? [{ relativePath: match.relativePath, line: match.startLine }] : [];
17
- const sourceSites = getSourceReferenceSites(db, match);
18
- const referenceSites = (sourceSites.length > 0 ? sourceSites : getResolvedReferenceSites(db, match)).filter((site) => !db.isIgnored(site.file)).map((site) => ({ relativePath: site.file, line: site.line }));
19
- const rubySites = getRubySemanticRefs(db, match);
20
- const seen = /* @__PURE__ */ new Set();
21
- const out = [];
22
- for (const row of [...definitionRows, ...referenceSites, ...rubySites]) {
23
- const key = `${row.relativePath}:${row.line}`;
24
- if (seen.has(key)) continue;
25
- seen.add(key);
26
- out.push(row);
27
- }
28
- return out;
29
- }
30
- function getRubySemanticRefs(db, match) {
31
- if (!match.relativePath.endsWith(".rb")) {
32
- return [];
33
- }
34
- const tokens = rubyReferenceTokens(match.symbol);
35
- if (tokens.length === 0) {
36
- return [];
37
- }
38
- const rows = db.all(
39
- `SELECT relative_path
40
- FROM documents
41
- WHERE relative_path LIKE '%.rb'
42
- ${db.pathExclusionsFor("documents")}
43
- ORDER BY relative_path`
44
- );
45
- const results = [];
46
- for (const row of rows) {
47
- if (db.isIgnored(row.relative_path)) continue;
48
- const source = getSourceText(db, row.relative_path);
49
- if (!source) continue;
50
- const lines = source.split("\n");
51
- for (let index = 0; index < lines.length; index++) {
52
- const line = lines[index] ?? "";
53
- if (tokens.some((token) => new RegExp(`@${token}\\b|\\b${token}:`).test(line))) {
54
- results.push({
55
- relativePath: row.relative_path,
56
- line: index
57
- });
58
- }
59
- }
60
- }
61
- return results;
62
- }
63
- function rubyReferenceTokens(rawSymbol) {
64
- const leaf = rawSymbol.split(":").pop() ?? rawSymbol;
65
- const snake = leaf.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^A-Za-z0-9_]+/g, "_").toLowerCase().replace(/^_+|_+$/g, "");
66
- const parts = snake.split("_").filter(Boolean);
67
- const candidates = /* @__PURE__ */ new Set();
68
- if (snake) candidates.add(snake);
69
- if (parts.length >= 1) candidates.add(parts[parts.length - 1]);
70
- if (parts.length >= 2) candidates.add(parts.slice(-2).join("_"));
71
- return [...candidates];
72
- }
73
-
74
- export {
75
- refs
76
- };
77
- //# sourceMappingURL=chunk-X3Q2OVRL.js.map
@@ -1,27 +0,0 @@
1
- import {
2
- findFirstSymbolMatch,
3
- getDefinitionsForFile
4
- } from "./chunk-OMCRXXDX.js";
5
- import {
6
- isDirectChildSymbol,
7
- leafSuffix,
8
- shortenSymbol
9
- } from "./chunk-YMSJCSRG.js";
10
-
11
- // src/queries/members.ts
12
- function members(db, symbolPattern) {
13
- const parent = findFirstSymbolMatch(db, symbolPattern);
14
- if (!parent) return [];
15
- return getDefinitionsForFile(db, parent.relativePath).filter((definition) => definition.symbol !== parent.symbol).filter((definition) => isDirectChildSymbol(parent.symbol, definition.symbol)).sort((a, b) => a.startLine - b.startLine || a.endLine - b.endLine).map((definition) => ({
16
- symbol: definition.symbol,
17
- shortName: shortenSymbol(definition.symbol),
18
- startLine: definition.startLine,
19
- endLine: definition.endLine,
20
- kind: leafSuffix(definition.symbol) ?? "unknown"
21
- }));
22
- }
23
-
24
- export {
25
- members
26
- };
27
- //# sourceMappingURL=chunk-Y3P7QKKN.js.map