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,44 +0,0 @@
1
- import {
2
- buildFileDepGraph
3
- } from "./chunk-OMCRXXDX.js";
4
-
5
- // src/queries/deep-chains.ts
6
- function deepChains(db, opts = {}) {
7
- const { limit = 10, scope, minDepth = 3 } = opts;
8
- const graph = buildFileDepGraph(db, scope);
9
- const results = [];
10
- function dfs(node, path, visited) {
11
- const neighbors = graph.get(node);
12
- if (!neighbors || neighbors.size === 0) {
13
- if (path.length >= minDepth) {
14
- results.push({ chain: [...path], depth: path.length });
15
- }
16
- return;
17
- }
18
- let extended = false;
19
- for (const next of neighbors) {
20
- if (visited.has(next)) continue;
21
- visited.add(next);
22
- path.push(next);
23
- dfs(next, path, visited);
24
- path.pop();
25
- visited.delete(next);
26
- extended = true;
27
- }
28
- if (!extended && path.length >= minDepth) {
29
- results.push({ chain: [...path], depth: path.length });
30
- }
31
- }
32
- for (const startNode of graph.keys()) {
33
- const visited = /* @__PURE__ */ new Set([startNode]);
34
- dfs(startNode, [startNode], visited);
35
- if (results.length > limit * 10) break;
36
- }
37
- results.sort((a, b) => b.depth - a.depth);
38
- return results.slice(0, limit);
39
- }
40
-
41
- export {
42
- deepChains
43
- };
44
- //# sourceMappingURL=chunk-OWJOHUZE.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
@@ -1,53 +0,0 @@
1
- import {
2
- resolveIndexedFile
3
- } from "./chunk-OMCRXXDX.js";
4
-
5
- // src/queries/deps.ts
6
- function deps(db, filePattern) {
7
- const resolvedFile = resolveIndexedFile(db, filePattern);
8
- if (!resolvedFile) {
9
- return [];
10
- }
11
- const rows = db.all(
12
- `SELECT DISTINCT d2.relative_path
13
- FROM mentions m
14
- JOIN chunks c ON m.chunk_id = c.id
15
- JOIN documents d1 ON c.document_id = d1.id
16
- JOIN global_symbols gs ON m.symbol_id = gs.id
17
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
18
- JOIN documents d2 ON der.document_id = d2.id
19
- WHERE d1.relative_path = ?
20
- AND d2.relative_path <> d1.relative_path
21
- AND ${db.localSymbolPredicate}
22
- ORDER BY d2.relative_path`,
23
- resolvedFile
24
- );
25
- return rows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({ relativePath: r.relative_path }));
26
- }
27
- function rdeps(db, filePattern) {
28
- const resolvedFile = resolveIndexedFile(db, filePattern);
29
- if (!resolvedFile) {
30
- return [];
31
- }
32
- const rows = db.all(
33
- `SELECT DISTINCT d1.relative_path
34
- FROM mentions m
35
- JOIN chunks c ON m.chunk_id = c.id
36
- JOIN documents d1 ON c.document_id = d1.id
37
- JOIN global_symbols gs ON m.symbol_id = gs.id
38
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
39
- JOIN documents d2 ON der.document_id = d2.id
40
- WHERE d2.relative_path = ?
41
- AND d1.relative_path != ?
42
- ORDER BY d1.relative_path`,
43
- resolvedFile,
44
- resolvedFile
45
- );
46
- return rows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({ relativePath: r.relative_path }));
47
- }
48
-
49
- export {
50
- deps,
51
- rdeps
52
- };
53
- //# sourceMappingURL=chunk-PEDH3D4G.js.map
@@ -1,46 +0,0 @@
1
- import {
2
- findFirstSymbolMatch,
3
- getCalleeRowsForSymbol,
4
- getCallerRowsForSymbol
5
- } from "./chunk-OMCRXXDX.js";
6
- import {
7
- shortenSymbol
8
- } from "./chunk-YMSJCSRG.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-POAN4SCR.js.map
@@ -1,101 +0,0 @@
1
- import {
2
- getCalleeRowsForSymbol,
3
- getScopedDefinitions
4
- } from "./chunk-OMCRXXDX.js";
5
- import {
6
- isFunctionLikeSymbol,
7
- shortenSymbol
8
- } from "./chunk-YMSJCSRG.js";
9
-
10
- // src/queries/extract-candidates.ts
11
- function extractCandidates(db, opts = {}) {
12
- const { scope, minLoc = 10, minCallees = 6, limit = 20 } = opts;
13
- const symbols = getScopedDefinitions(db, scope).filter((definition) => definitionLoc(definition) >= minLoc && isFunctionLikeSymbol(definition.symbol)).sort((left, right) => definitionLoc(right) - definitionLoc(left));
14
- const results = [];
15
- for (const sym of symbols) {
16
- if (db.isIgnored(sym.relativePath)) continue;
17
- const basename = sym.relativePath.split("/").pop() ?? "";
18
- if (basename.includes("types")) continue;
19
- const calleeChunks = getCalleeRowsForSymbol(db, sym);
20
- const calleeSet = new Set(calleeChunks.map((c) => c.symbol));
21
- if (calleeSet.size < minCallees) continue;
22
- const cooccurrence = /* @__PURE__ */ new Map();
23
- for (const callee of calleeSet) {
24
- cooccurrence.set(callee, /* @__PURE__ */ new Set());
25
- }
26
- const chunkToCallees = /* @__PURE__ */ new Map();
27
- for (const cc of calleeChunks) {
28
- if (!chunkToCallees.has(cc.chunkId)) chunkToCallees.set(cc.chunkId, /* @__PURE__ */ new Set());
29
- chunkToCallees.get(cc.chunkId).add(cc.symbol);
30
- }
31
- for (const callees of chunkToCallees.values()) {
32
- const arr = [...callees];
33
- for (let i = 0; i < arr.length; i++) {
34
- for (let j = i + 1; j < arr.length; j++) {
35
- cooccurrence.get(arr[i]).add(arr[j]);
36
- cooccurrence.get(arr[j]).add(arr[i]);
37
- }
38
- }
39
- }
40
- const visited = /* @__PURE__ */ new Set();
41
- const clusters = [];
42
- for (const callee of calleeSet) {
43
- if (visited.has(callee)) continue;
44
- const cluster = /* @__PURE__ */ new Set();
45
- const queue = [callee];
46
- while (queue.length > 0) {
47
- const current = queue.pop();
48
- if (visited.has(current)) continue;
49
- visited.add(current);
50
- cluster.add(current);
51
- for (const neighbor of cooccurrence.get(current) ?? []) {
52
- if (!visited.has(neighbor)) queue.push(neighbor);
53
- }
54
- }
55
- clusters.push(cluster);
56
- }
57
- if (clusters.length < 2) continue;
58
- const scoredClusters = clusters.filter((c) => c.size >= 2).map((cluster) => {
59
- const otherCallees = /* @__PURE__ */ new Set();
60
- for (const c of clusters) {
61
- if (c !== cluster) {
62
- for (const s of c) otherCallees.add(s);
63
- }
64
- }
65
- let crossEdges = 0;
66
- for (const callee of cluster) {
67
- for (const neighbor of cooccurrence.get(callee) ?? []) {
68
- if (otherCallees.has(neighbor)) crossEdges++;
69
- }
70
- }
71
- const maxCrossEdges = cluster.size * otherCallees.size;
72
- const isolation = maxCrossEdges > 0 ? 1 - crossEdges / maxCrossEdges : 1;
73
- return {
74
- callees: [...cluster].map(shortenSymbol),
75
- isolation
76
- };
77
- }).filter((c) => c.isolation > 0.5).sort((a, b) => b.isolation - a.isolation);
78
- if (scoredClusters.length > 0) {
79
- results.push({
80
- symbol: sym.symbol,
81
- shortName: shortenSymbol(sym.symbol),
82
- relativePath: sym.relativePath,
83
- startLine: sym.startLine,
84
- endLine: sym.endLine,
85
- loc: definitionLoc(sym),
86
- totalCallees: calleeSet.size,
87
- clusters: scoredClusters
88
- });
89
- }
90
- }
91
- results.sort((a, b) => b.clusters.length - a.clusters.length || b.loc - a.loc);
92
- return results.slice(0, limit);
93
- }
94
- function definitionLoc(definition) {
95
- return definition.endLine - definition.startLine + 1;
96
- }
97
-
98
- export {
99
- extractCandidates
100
- };
101
- //# sourceMappingURL=chunk-PTMGEBU3.js.map
@@ -1,87 +0,0 @@
1
- import {
2
- findExactSymbolMatch,
3
- findFirstSymbolMatch,
4
- getCallerRowsForSymbol
5
- } from "./chunk-OMCRXXDX.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-PU44HK7P.js.map