scip-query 0.4.3 → 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 -8938
  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 +4 -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 -3
  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 +4 -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 +4 -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 +6 -2
  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-334PCFO3.js +0 -221
  151. package/dist/chunk-46ZTW4AI.js +0 -61
  152. package/dist/chunk-4TYLS5XX.js +0 -10
  153. package/dist/chunk-4YN3PE57.js +0 -124
  154. package/dist/chunk-5YB6UXQ3.js +0 -101
  155. package/dist/chunk-6PVHJ332.js +0 -44
  156. package/dist/chunk-74RFWB5T.js +0 -24
  157. package/dist/chunk-7KGTWDAX.js +0 -87
  158. package/dist/chunk-7OGXSMLY.js +0 -105
  159. package/dist/chunk-AEBM56CO.js +0 -69
  160. package/dist/chunk-B747RITP.js +0 -38
  161. package/dist/chunk-B7LDMCUS.js +0 -110
  162. package/dist/chunk-C2VSV54P.js +0 -110
  163. package/dist/chunk-DIYEUFVP.js +0 -81
  164. package/dist/chunk-E74RY6AQ.js +0 -93
  165. package/dist/chunk-FIMTTUGE.js +0 -165
  166. package/dist/chunk-FMAYH7GS.js +0 -2542
  167. package/dist/chunk-FO2CBB7U.js +0 -23
  168. package/dist/chunk-HESWGDIV.js +0 -162
  169. package/dist/chunk-HL2LXSBW.js +0 -34
  170. package/dist/chunk-HW76DVE4.js +0 -216
  171. package/dist/chunk-IC5NTO47.js +0 -53
  172. package/dist/chunk-J34HAAEQ.js +0 -59
  173. package/dist/chunk-JSXGC2EH.js +0 -151
  174. package/dist/chunk-LQXBFCP2.js +0 -87
  175. package/dist/chunk-NML6M5AS.js +0 -37
  176. package/dist/chunk-NNFP4ZRF.js +0 -72
  177. package/dist/chunk-NWXTQGUE.js +0 -49
  178. package/dist/chunk-NYZ6INK3.js +0 -95
  179. package/dist/chunk-OMVF3BHY.js +0 -84
  180. package/dist/chunk-P3VCDYMJ.js +0 -269
  181. package/dist/chunk-PGQXIAJF.js +0 -79
  182. package/dist/chunk-PKDFXASW.js +0 -76
  183. package/dist/chunk-PSK5BPFE.js +0 -82
  184. package/dist/chunk-QZ4FRB65.js +0 -341
  185. package/dist/chunk-R2QBMQQN.js +0 -185
  186. package/dist/chunk-T3ALCNCP.js +0 -113
  187. package/dist/chunk-T6UVM534.js +0 -213
  188. package/dist/chunk-U74VYTLX.js +0 -46
  189. package/dist/chunk-UIRCHPOU.js +0 -34
  190. package/dist/chunk-UNS6ZQVX.js +0 -71
  191. package/dist/chunk-VJMTX3OR.js +0 -115
  192. package/dist/chunk-XJSPWHNT.js +0 -64
  193. package/dist/chunk-XMZAC2VU.js +0 -84
  194. package/dist/chunk-Y7FKURZG.js +0 -130
  195. package/dist/chunk-YMSJCSRG.js +0 -213
  196. package/dist/chunk-YQIWS5V6.js +0 -172
  197. package/dist/chunk-ZPEI7DRJ.js +0 -66
  198. package/dist/queries/clean-signature.d.ts +0 -9
  199. package/dist/queries/clean-signature.js +0 -7
@@ -1,87 +0,0 @@
1
- import {
2
- findExactSymbolMatch,
3
- findFirstSymbolMatch,
4
- getCallerRowsForSymbol
5
- } from "./chunk-FMAYH7GS.js";
6
- import {
7
- shortenSymbol
8
- } from "./chunk-YMSJCSRG.js";
9
-
10
- // src/queries/affected.ts
11
- function affected(db, symbolPattern, opts = {}) {
12
- const { maxDepth = 5, scope } = opts;
13
- const target = findFirstSymbolMatch(db, symbolPattern);
14
- if (!target) return [];
15
- const results = [];
16
- const visited = /* @__PURE__ */ new Set([target.symbolId]);
17
- const seenResults = /* @__PURE__ */ new Set();
18
- let frontier = [target];
19
- for (let depth = 1; depth <= maxDepth; depth++) {
20
- if (frontier.length === 0) break;
21
- const nextFrontier = [];
22
- for (const current of frontier) {
23
- for (const row of getDirectAffectedRows(db, current, scope)) {
24
- const resultKey = `${row.file}|${row.shortName}`;
25
- if (row.symbolId !== null) {
26
- if (visited.has(row.symbolId)) continue;
27
- visited.add(row.symbolId);
28
- } else if (seenResults.has(resultKey)) {
29
- continue;
30
- }
31
- seenResults.add(resultKey);
32
- results.push({
33
- symbol: row.symbol,
34
- shortName: row.shortName,
35
- file: row.file,
36
- depth
37
- });
38
- if (row.symbolId !== null && row.symbolMatch) {
39
- nextFrontier.push(row.symbolMatch);
40
- }
41
- }
42
- }
43
- frontier = nextFrontier;
44
- }
45
- results.sort((a, b) => a.depth - b.depth || a.file.localeCompare(b.file));
46
- return results;
47
- }
48
- function getDirectAffectedRows(db, target, scope) {
49
- const callerRows = getCallerRowsForSymbol(db, target, { limit: 500 }).filter((row) => !db.isIgnored(row.file)).filter((row) => !scope || row.file.includes(scope));
50
- const results = [];
51
- const seen = /* @__PURE__ */ new Set();
52
- for (const row of callerRows) {
53
- const match = findExactSymbolMatch(db, row.symbol);
54
- if (!match) {
55
- const key2 = `${row.file}|${row.symbol}`;
56
- if (seen.has(key2)) continue;
57
- seen.add(key2);
58
- results.push({
59
- symbolId: null,
60
- symbol: row.symbol,
61
- shortName: shortenSymbol(row.symbol),
62
- file: row.file,
63
- symbolMatch: null
64
- });
65
- continue;
66
- }
67
- if (match.symbolId === target.symbolId || db.isIgnored(match.relativePath)) {
68
- continue;
69
- }
70
- const key = `${match.symbolId}|${match.relativePath}`;
71
- if (seen.has(key)) continue;
72
- seen.add(key);
73
- results.push({
74
- symbolId: match.symbolId,
75
- symbol: match.symbol,
76
- shortName: shortenSymbol(match.symbol),
77
- file: match.relativePath,
78
- symbolMatch: match
79
- });
80
- }
81
- return results;
82
- }
83
-
84
- export {
85
- affected
86
- };
87
- //# sourceMappingURL=chunk-LQXBFCP2.js.map
@@ -1,37 +0,0 @@
1
- import {
2
- findFirstSymbolMatch
3
- } from "./chunk-FMAYH7GS.js";
4
- import {
5
- isDirectChildSymbol,
6
- leafSuffix,
7
- shortenSymbol
8
- } from "./chunk-YMSJCSRG.js";
9
-
10
- // src/queries/members.ts
11
- function members(db, symbolPattern) {
12
- const parent = findFirstSymbolMatch(db, symbolPattern);
13
- if (!parent) return [];
14
- const rows = db.all(
15
- `SELECT gs.symbol, der.start_line, der.end_line
16
- FROM global_symbols gs
17
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
18
- WHERE der.document_id = ?
19
- AND gs.symbol != ?
20
- ${db.symbolNoiseFor("gs")}
21
- ORDER BY der.start_line`,
22
- parent.documentId,
23
- parent.symbol
24
- );
25
- return rows.filter((row) => isDirectChildSymbol(parent.symbol, row.symbol)).map((row) => ({
26
- symbol: row.symbol,
27
- shortName: shortenSymbol(row.symbol),
28
- startLine: row.start_line,
29
- endLine: row.end_line,
30
- kind: leafSuffix(row.symbol) ?? "unknown"
31
- }));
32
- }
33
-
34
- export {
35
- members
36
- };
37
- //# sourceMappingURL=chunk-NML6M5AS.js.map
@@ -1,72 +0,0 @@
1
- import {
2
- getDefinitionsForFile,
3
- resolveIndexedPaths
4
- } from "./chunk-FMAYH7GS.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-NNFP4ZRF.js.map
@@ -1,49 +0,0 @@
1
- import {
2
- getCalleeRowsForSymbol,
3
- getScopedDefinitions
4
- } from "./chunk-FMAYH7GS.js";
5
- import {
6
- isFunctionLikeSymbol,
7
- shortenSymbol
8
- } from "./chunk-YMSJCSRG.js";
9
-
10
- // src/queries/passthrough-candidates.ts
11
- function passthroughCandidates(db, opts) {
12
- const { scope, maxLoc = 15, limit = 30 } = opts ?? {};
13
- const symbols = getScopedDefinitions(db, scope).filter((definition) => definitionLoc(definition) >= 3 && definitionLoc(definition) <= maxLoc);
14
- const results = [];
15
- for (const sym of symbols) {
16
- if (db.isIgnored(sym.relativePath) || !isFunctionLikeSymbol(sym.symbol)) continue;
17
- const rawCallees = getCalleeRowsForSymbol(db, sym);
18
- const callees = rawCallees.some((callee2) => isFunctionLikeSymbol(callee2.symbol)) ? rawCallees.filter((callee2) => isFunctionLikeSymbol(callee2.symbol)) : rawCallees;
19
- const uniqueCallees = /* @__PURE__ */ new Map();
20
- for (const c of callees) {
21
- if (!uniqueCallees.has(c.symbol)) {
22
- uniqueCallees.set(c.symbol, { symbol: c.symbol, file: c.file });
23
- }
24
- }
25
- if (uniqueCallees.size !== 1) continue;
26
- const [, callee] = [...uniqueCallees.entries()][0];
27
- results.push({
28
- symbol: sym.symbol,
29
- shortName: shortenSymbol(sym.symbol),
30
- file: sym.relativePath,
31
- startLine: sym.startLine,
32
- endLine: sym.endLine,
33
- loc: definitionLoc(sym),
34
- forwardsTo: callee.symbol,
35
- forwardsToShort: shortenSymbol(callee.symbol),
36
- forwardsToFile: callee.file
37
- });
38
- }
39
- results.sort((a, b) => a.loc - b.loc || a.file.localeCompare(b.file));
40
- return results.slice(0, limit);
41
- }
42
- function definitionLoc(definition) {
43
- return definition.endLine - definition.startLine + 1;
44
- }
45
-
46
- export {
47
- passthroughCandidates
48
- };
49
- //# sourceMappingURL=chunk-NWXTQGUE.js.map
@@ -1,95 +0,0 @@
1
- import {
2
- cleanSignature
3
- } from "./chunk-4TYLS5XX.js";
4
- import {
5
- findFirstSymbolMatch,
6
- getSourceReferenceSites,
7
- getSourceText
8
- } from "./chunk-FMAYH7GS.js";
9
- import {
10
- isFunctionLikeSymbol,
11
- shortenSymbol
12
- } from "./chunk-YMSJCSRG.js";
13
-
14
- // src/queries/trace.ts
15
- function trace(db, symbolPattern) {
16
- const match = findFirstSymbolMatch(db, symbolPattern);
17
- if (!match) {
18
- return { definitions: [], referencedBy: [] };
19
- }
20
- const definitionMeta = db.get(
21
- `SELECT
22
- gs.display_name,
23
- REPLACE(SUBSTR(gs.documentation, INSTR(gs.documentation, '|') + 1), char(10), ' ') AS sig
24
- FROM global_symbols gs
25
- WHERE gs.id = ?
26
- LIMIT 10`,
27
- match.symbolId
28
- );
29
- const definitions = db.isIgnored(match.relativePath) ? [] : [{
30
- relativePath: match.relativePath,
31
- startLine: match.startLine,
32
- endLine: match.endLine,
33
- signature: buildTraceSignature(definitionMeta?.sig ?? null, definitionMeta?.display_name ?? null, match.symbol),
34
- source: definitionSource(db, match.relativePath, match.startLine, match.endLine)
35
- }];
36
- const sourceSites = getSourceReferenceSites(db, match);
37
- const referencedBy = sourceSites.length > 0 ? sourceSites.filter((site) => !db.isIgnored(site.file)).map((site) => ({
38
- relativePath: site.file,
39
- line: site.line,
40
- enclosingSymbol: site.enclosingSymbol,
41
- enclosingShort: site.enclosingSymbol ? shortenSymbol(site.enclosingSymbol) : "(top-level)"
42
- })) : db.all(
43
- `SELECT DISTINCT d.relative_path, c.start_line AS line,
44
- (SELECT enc_gs.symbol
45
- FROM defn_enclosing_ranges enc_der
46
- JOIN global_symbols enc_gs ON enc_der.symbol_id = enc_gs.id
47
- WHERE enc_der.document_id = d.id
48
- AND enc_der.start_line <= c.start_line
49
- AND enc_der.end_line >= c.end_line
50
- ORDER BY (enc_der.end_line - enc_der.start_line) ASC
51
- LIMIT 1
52
- ) AS enclosing_symbol
53
- FROM mentions m
54
- JOIN chunks c ON m.chunk_id = c.id
55
- JOIN documents d ON c.document_id = d.id
56
- WHERE m.symbol_id = ?
57
- AND m.role != 1
58
- ORDER BY d.relative_path, c.start_line`,
59
- match.symbolId
60
- ).filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({
61
- relativePath: r.relative_path,
62
- line: r.line,
63
- enclosingSymbol: r.enclosing_symbol,
64
- enclosingShort: r.enclosing_symbol ? shortenSymbol(r.enclosing_symbol) : "(top-level)"
65
- }));
66
- return { definitions, referencedBy };
67
- }
68
- function definitionSource(db, relativePath, startLine, endLine) {
69
- const source = getSourceText(db, relativePath);
70
- if (!source) {
71
- return null;
72
- }
73
- const lines = source.split("\n");
74
- const slice = lines.slice(startLine, endLine + 1).join("\n").trimEnd();
75
- return slice.length > 0 ? slice : null;
76
- }
77
- function buildTraceSignature(signature, displayName, rawSymbol) {
78
- const cleaned = cleanSignature(signature);
79
- if (cleaned && !looksBogusSignature(cleaned)) {
80
- return cleaned;
81
- }
82
- const fallback = (displayName ?? "").trim();
83
- if (fallback) {
84
- return isFunctionLikeSymbol(rawSymbol) && !fallback.endsWith("()") ? `${fallback}()` : fallback;
85
- }
86
- return shortenSymbol(rawSymbol);
87
- }
88
- function looksBogusSignature(signature) {
89
- return signature.startsWith("undefined") || signature.includes("|") || signature.includes("```");
90
- }
91
-
92
- export {
93
- trace
94
- };
95
- //# sourceMappingURL=chunk-NYZ6INK3.js.map
@@ -1,84 +0,0 @@
1
- import {
2
- buildFileDepGraph
3
- } from "./chunk-FMAYH7GS.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-OMVF3BHY.js.map
@@ -1,269 +0,0 @@
1
- // src/reindex/install.ts
2
- import { execFileSync } from "child_process";
3
- import { existsSync } from "fs";
4
- import { platform } from "os";
5
- import { join } from "path";
6
- var IS_WINDOWS = platform() === "win32";
7
- function isBinaryAvailable(name) {
8
- const cmd = IS_WINDOWS ? "where" : "which";
9
- try {
10
- execFileSync(cmd, [name], { stdio: "pipe" });
11
- return true;
12
- } catch {
13
- return false;
14
- }
15
- }
16
- function getBinaryCandidates(config) {
17
- return [config.indexerBinary, ...config.binaryAliases ?? []];
18
- }
19
- function describeIndexerBinary(config) {
20
- const candidates = getBinaryCandidates(config);
21
- return candidates.length === 1 ? candidates[0] : candidates.join(" or ");
22
- }
23
- function resolveIndexerBinary(config) {
24
- for (const candidate of getBinaryCandidates(config)) {
25
- if (isBinaryAvailable(candidate)) {
26
- return candidate;
27
- }
28
- }
29
- return null;
30
- }
31
- function isIndexerInstalled(config) {
32
- return resolveIndexerBinary(config) !== null;
33
- }
34
- function resolveProjectLocalIndexerBinary(config, projectRoot) {
35
- for (const relativePath of config.projectLocalBinaries ?? []) {
36
- const candidate = join(projectRoot, relativePath);
37
- if (existsSync(candidate)) {
38
- return candidate;
39
- }
40
- }
41
- return null;
42
- }
43
- function getIndexerExecutionEnv(config, baseEnv = process.env, binary = config.indexerBinary) {
44
- if (config.indexerBinary !== "scip-dotnet") {
45
- return baseEnv;
46
- }
47
- if (canRunDotnetIndexer(binary, baseEnv)) {
48
- return baseEnv;
49
- }
50
- const dotnetRoot = resolveWorkingDotnetRoot(binary, baseEnv);
51
- if (!dotnetRoot) {
52
- return baseEnv;
53
- }
54
- return {
55
- ...baseEnv,
56
- DOTNET_ROOT: dotnetRoot
57
- };
58
- }
59
- function tryInstallIndexer(config, onStatus) {
60
- const methods = config.installMethods;
61
- const binaryLabel = describeIndexerBinary(config);
62
- if (!methods?.length) {
63
- onStatus(`No auto-install method available for ${binaryLabel}.`);
64
- if (config.installUrl) {
65
- onStatus(`Install manually from: ${config.installUrl}`);
66
- }
67
- return false;
68
- }
69
- for (const method of methods) {
70
- if (!isBinaryAvailable(method.prerequisite)) {
71
- continue;
72
- }
73
- onStatus(`Installing ${binaryLabel} via ${method.label}...`);
74
- try {
75
- execFileSync(method.binary, method.args, {
76
- stdio: "inherit",
77
- timeout: 3e5,
78
- env: process.env
79
- });
80
- const resolvedBinary = resolveIndexerBinary(config);
81
- if (resolvedBinary) {
82
- const resolutionNote = resolvedBinary === config.indexerBinary ? "" : ` (using ${resolvedBinary})`;
83
- onStatus(`Successfully installed ${binaryLabel} via ${method.label}${resolutionNote}`);
84
- return true;
85
- }
86
- onStatus(`${method.label} command completed but ${binaryLabel} was not found on PATH`);
87
- } catch (err) {
88
- const msg = err instanceof Error ? err.message : String(err);
89
- onStatus(`${method.label} install failed: ${msg}`);
90
- }
91
- }
92
- onStatus(`Could not auto-install ${binaryLabel}.`);
93
- if (config.installUrl) {
94
- onStatus(`Install manually from: ${config.installUrl}`);
95
- }
96
- return false;
97
- }
98
- function resolveWorkingDotnetRoot(binary, env) {
99
- for (const dotnetRoot of getDotnetRootCandidates(env)) {
100
- if (canRunDotnetIndexer(binary, { ...env, DOTNET_ROOT: dotnetRoot })) {
101
- return dotnetRoot;
102
- }
103
- }
104
- return null;
105
- }
106
- function getDotnetRootCandidates(env) {
107
- const candidates = [];
108
- const configured = env["DOTNET_ROOT"];
109
- if (configured && existsSync(configured)) {
110
- candidates.push(configured);
111
- }
112
- if (platform() === "darwin" && isBinaryAvailable("brew")) {
113
- try {
114
- const prefix = execFileSync("brew", ["--prefix", "dotnet@9"], {
115
- stdio: "pipe",
116
- env
117
- }).toString().trim();
118
- const candidate = join(prefix, "libexec");
119
- if (existsSync(candidate) && !candidates.includes(candidate)) {
120
- candidates.push(candidate);
121
- }
122
- } catch {
123
- }
124
- }
125
- return candidates;
126
- }
127
- function canRunDotnetIndexer(binary, env) {
128
- try {
129
- execFileSync(binary, ["--version"], {
130
- stdio: "pipe",
131
- env
132
- });
133
- return true;
134
- } catch {
135
- return false;
136
- }
137
- }
138
-
139
- // src/scip-cli.ts
140
- import { execFileSync as execFileSync2 } from "child_process";
141
- import { platform as platform2, arch } from "os";
142
- var IS_WINDOWS2 = platform2() === "win32";
143
- var SCIP_VERSION = "v0.7.0";
144
- function isScipInstalled() {
145
- try {
146
- const cmd = IS_WINDOWS2 ? "where" : "which";
147
- execFileSync2(cmd, ["scip"], { stdio: "pipe" });
148
- return true;
149
- } catch {
150
- return false;
151
- }
152
- }
153
- function getScipVersion() {
154
- try {
155
- const output = execFileSync2("scip", ["--version"], { stdio: "pipe" }).toString().trim();
156
- return output;
157
- } catch {
158
- return null;
159
- }
160
- }
161
- function getScipDownloadUrl() {
162
- const os = platform2();
163
- const cpu = arch();
164
- let osName;
165
- let archName;
166
- let ext;
167
- switch (os) {
168
- case "darwin":
169
- osName = "darwin";
170
- ext = "tar.gz";
171
- break;
172
- case "linux":
173
- osName = "linux";
174
- ext = "tar.gz";
175
- break;
176
- case "win32":
177
- osName = "windows";
178
- ext = "zip";
179
- break;
180
- default:
181
- return null;
182
- }
183
- switch (cpu) {
184
- case "arm64":
185
- archName = "arm64";
186
- break;
187
- case "x64":
188
- archName = "amd64";
189
- break;
190
- default:
191
- return null;
192
- }
193
- const filename = `scip-${osName}-${archName}.${ext}`;
194
- const url = `https://github.com/sourcegraph/scip/releases/download/${SCIP_VERSION}/${filename}`;
195
- return { url, filename };
196
- }
197
- function printScipInstallInstructions() {
198
- const download = getScipDownloadUrl();
199
- console.log("\nThe `scip` CLI is required but not found on PATH.\n");
200
- if (platform2() === "darwin") {
201
- console.log("Install via Homebrew:");
202
- console.log(" brew install sourcegraph/scip/scip\n");
203
- console.log("Or download manually:");
204
- } else {
205
- console.log("Download from:");
206
- }
207
- if (download) {
208
- console.log(` ${download.url}
209
- `);
210
- } else {
211
- console.log(` https://github.com/sourcegraph/scip/releases/tag/${SCIP_VERSION}
212
- `);
213
- }
214
- console.log("After installing, ensure `scip` is on your PATH and run `scip-query reindex`.");
215
- }
216
- function tryInstallScipCli(onStatus) {
217
- if (platform2() === "darwin" && isBinaryAvailable("brew")) {
218
- onStatus("Installing scip CLI via Homebrew...");
219
- try {
220
- execFileSync2("brew", ["install", "sourcegraph/scip/scip"], {
221
- stdio: "inherit",
222
- timeout: 3e5,
223
- env: process.env
224
- });
225
- if (isBinaryAvailable("scip")) {
226
- onStatus("Successfully installed scip CLI via Homebrew");
227
- return true;
228
- }
229
- } catch (err) {
230
- const msg = err instanceof Error ? err.message : String(err);
231
- onStatus(`Homebrew install failed: ${msg}`);
232
- }
233
- }
234
- if (isBinaryAvailable("go")) {
235
- onStatus("Installing scip CLI via go install...");
236
- try {
237
- execFileSync2("go", ["install", "github.com/sourcegraph/scip/cmd/scip@latest"], {
238
- stdio: "inherit",
239
- timeout: 3e5,
240
- env: process.env
241
- });
242
- if (isBinaryAvailable("scip")) {
243
- onStatus("Successfully installed scip CLI via go install");
244
- return true;
245
- }
246
- } catch (err) {
247
- const msg = err instanceof Error ? err.message : String(err);
248
- onStatus(`go install failed: ${msg}`);
249
- }
250
- }
251
- onStatus("Could not auto-install scip CLI.");
252
- onStatus("Install manually from: https://github.com/sourcegraph/scip/releases");
253
- return false;
254
- }
255
-
256
- export {
257
- isBinaryAvailable,
258
- describeIndexerBinary,
259
- resolveIndexerBinary,
260
- isIndexerInstalled,
261
- resolveProjectLocalIndexerBinary,
262
- getIndexerExecutionEnv,
263
- tryInstallIndexer,
264
- isScipInstalled,
265
- getScipVersion,
266
- printScipInstallInstructions,
267
- tryInstallScipCli
268
- };
269
- //# sourceMappingURL=chunk-P3VCDYMJ.js.map