scip-query 0.1.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 (330) hide show
  1. package/IMPROVEMENTS.md +143 -0
  2. package/PLAN.md +320 -0
  3. package/README.md +1213 -0
  4. package/dist/chunk-2QZ23IBN.js +55 -0
  5. package/dist/chunk-2QZ23IBN.js.map +1 -0
  6. package/dist/chunk-36OMT7ZJ.js +144 -0
  7. package/dist/chunk-36OMT7ZJ.js.map +1 -0
  8. package/dist/chunk-3E2X7RIE.js +101 -0
  9. package/dist/chunk-3E2X7RIE.js.map +1 -0
  10. package/dist/chunk-3UOUTZQT.js +45 -0
  11. package/dist/chunk-3UOUTZQT.js.map +1 -0
  12. package/dist/chunk-3ZZJVBIO.js +88 -0
  13. package/dist/chunk-3ZZJVBIO.js.map +1 -0
  14. package/dist/chunk-4TYLS5XX.js +10 -0
  15. package/dist/chunk-4TYLS5XX.js.map +1 -0
  16. package/dist/chunk-5FGUEU7N.js +101 -0
  17. package/dist/chunk-5FGUEU7N.js.map +1 -0
  18. package/dist/chunk-5WTJAXY2.js +61 -0
  19. package/dist/chunk-5WTJAXY2.js.map +1 -0
  20. package/dist/chunk-6NBLIDF4.js +24 -0
  21. package/dist/chunk-6NBLIDF4.js.map +1 -0
  22. package/dist/chunk-6SXADWLW.js +43 -0
  23. package/dist/chunk-6SXADWLW.js.map +1 -0
  24. package/dist/chunk-6VJ6Q7IE.js +65 -0
  25. package/dist/chunk-6VJ6Q7IE.js.map +1 -0
  26. package/dist/chunk-7OZPA5OO.js +258 -0
  27. package/dist/chunk-7OZPA5OO.js.map +1 -0
  28. package/dist/chunk-BEPIEVLR.js +76 -0
  29. package/dist/chunk-BEPIEVLR.js.map +1 -0
  30. package/dist/chunk-BFSCMC22.js +42 -0
  31. package/dist/chunk-BFSCMC22.js.map +1 -0
  32. package/dist/chunk-BP2ATLK2.js +110 -0
  33. package/dist/chunk-BP2ATLK2.js.map +1 -0
  34. package/dist/chunk-CM454WL3.js +114 -0
  35. package/dist/chunk-CM454WL3.js.map +1 -0
  36. package/dist/chunk-DCKMSTJ4.js +74 -0
  37. package/dist/chunk-DCKMSTJ4.js.map +1 -0
  38. package/dist/chunk-DEZKCZXD.js +40 -0
  39. package/dist/chunk-DEZKCZXD.js.map +1 -0
  40. package/dist/chunk-DVWGWHFW.js +99 -0
  41. package/dist/chunk-DVWGWHFW.js.map +1 -0
  42. package/dist/chunk-EMDQWNYR.js +102 -0
  43. package/dist/chunk-EMDQWNYR.js.map +1 -0
  44. package/dist/chunk-FFSWWE5O.js +33 -0
  45. package/dist/chunk-FFSWWE5O.js.map +1 -0
  46. package/dist/chunk-FGXRVW7G.js +73 -0
  47. package/dist/chunk-FGXRVW7G.js.map +1 -0
  48. package/dist/chunk-FUHJCHS4.js +158 -0
  49. package/dist/chunk-FUHJCHS4.js.map +1 -0
  50. package/dist/chunk-GJFURBEW.js +64 -0
  51. package/dist/chunk-GJFURBEW.js.map +1 -0
  52. package/dist/chunk-GTILYBH6.js +102 -0
  53. package/dist/chunk-GTILYBH6.js.map +1 -0
  54. package/dist/chunk-JJP7KQND.js +1 -0
  55. package/dist/chunk-JJP7KQND.js.map +1 -0
  56. package/dist/chunk-JKP5GH6T.js +213 -0
  57. package/dist/chunk-JKP5GH6T.js.map +1 -0
  58. package/dist/chunk-KCBMVQL5.js +38 -0
  59. package/dist/chunk-KCBMVQL5.js.map +1 -0
  60. package/dist/chunk-KVSW5KYP.js +78 -0
  61. package/dist/chunk-KVSW5KYP.js.map +1 -0
  62. package/dist/chunk-LAWMH22O.js +172 -0
  63. package/dist/chunk-LAWMH22O.js.map +1 -0
  64. package/dist/chunk-LB7OS35Q.js +72 -0
  65. package/dist/chunk-LB7OS35Q.js.map +1 -0
  66. package/dist/chunk-LUSIFBXO.js +57 -0
  67. package/dist/chunk-LUSIFBXO.js.map +1 -0
  68. package/dist/chunk-MBVNHJVN.js +44 -0
  69. package/dist/chunk-MBVNHJVN.js.map +1 -0
  70. package/dist/chunk-MGNMHKX3.js +15 -0
  71. package/dist/chunk-MGNMHKX3.js.map +1 -0
  72. package/dist/chunk-N5KEREIA.js +41 -0
  73. package/dist/chunk-N5KEREIA.js.map +1 -0
  74. package/dist/chunk-NDSQYIWT.js +71 -0
  75. package/dist/chunk-NDSQYIWT.js.map +1 -0
  76. package/dist/chunk-NUZ4OMU3.js +28 -0
  77. package/dist/chunk-NUZ4OMU3.js.map +1 -0
  78. package/dist/chunk-QOV2R2WT.js +170 -0
  79. package/dist/chunk-QOV2R2WT.js.map +1 -0
  80. package/dist/chunk-SEFSL2GF.js +78 -0
  81. package/dist/chunk-SEFSL2GF.js.map +1 -0
  82. package/dist/chunk-T6ARFSBZ.js +103 -0
  83. package/dist/chunk-T6ARFSBZ.js.map +1 -0
  84. package/dist/chunk-TBP6BICL.js +46 -0
  85. package/dist/chunk-TBP6BICL.js.map +1 -0
  86. package/dist/chunk-TDNNOR6D.js +97 -0
  87. package/dist/chunk-TDNNOR6D.js.map +1 -0
  88. package/dist/chunk-TSPZOMHC.js +195 -0
  89. package/dist/chunk-TSPZOMHC.js.map +1 -0
  90. package/dist/chunk-UNTPVD36.js +55 -0
  91. package/dist/chunk-UNTPVD36.js.map +1 -0
  92. package/dist/chunk-VRUJH4BO.js +88 -0
  93. package/dist/chunk-VRUJH4BO.js.map +1 -0
  94. package/dist/chunk-VZ7AMAFL.js +76 -0
  95. package/dist/chunk-VZ7AMAFL.js.map +1 -0
  96. package/dist/chunk-XFXDXEUN.js +24 -0
  97. package/dist/chunk-XFXDXEUN.js.map +1 -0
  98. package/dist/chunk-YZAA4LYG.js +169 -0
  99. package/dist/chunk-YZAA4LYG.js.map +1 -0
  100. package/dist/chunk-Z73NYSBZ.js +92 -0
  101. package/dist/chunk-Z73NYSBZ.js.map +1 -0
  102. package/dist/chunk-ZJRYBOEE.js +125 -0
  103. package/dist/chunk-ZJRYBOEE.js.map +1 -0
  104. package/dist/cli.js +5798 -0
  105. package/dist/cli.js.map +1 -0
  106. package/dist/db-BxaevAyc.d.ts +683 -0
  107. package/dist/index.d.ts +254 -0
  108. package/dist/index.js +1271 -0
  109. package/dist/index.js.map +1 -0
  110. package/dist/postinstall.js +167 -0
  111. package/dist/postinstall.js.map +1 -0
  112. package/dist/queries/affected.d.ts +14 -0
  113. package/dist/queries/affected.js +9 -0
  114. package/dist/queries/affected.js.map +1 -0
  115. package/dist/queries/bottlenecks.d.ts +18 -0
  116. package/dist/queries/bottlenecks.js +8 -0
  117. package/dist/queries/bottlenecks.js.map +1 -0
  118. package/dist/queries/by-kind.d.ts +20 -0
  119. package/dist/queries/by-kind.js +10 -0
  120. package/dist/queries/by-kind.js.map +1 -0
  121. package/dist/queries/call-graph.d.ts +13 -0
  122. package/dist/queries/call-graph.js +9 -0
  123. package/dist/queries/call-graph.js.map +1 -0
  124. package/dist/queries/change-surface.d.ts +10 -0
  125. package/dist/queries/change-surface.js +9 -0
  126. package/dist/queries/change-surface.js.map +1 -0
  127. package/dist/queries/clean-signature.d.ts +9 -0
  128. package/dist/queries/clean-signature.js +7 -0
  129. package/dist/queries/clean-signature.js.map +1 -0
  130. package/dist/queries/code.d.ts +17 -0
  131. package/dist/queries/code.js +9 -0
  132. package/dist/queries/code.js.map +1 -0
  133. package/dist/queries/complexity-hotspots.d.ts +19 -0
  134. package/dist/queries/complexity-hotspots.js +9 -0
  135. package/dist/queries/complexity-hotspots.js.map +1 -0
  136. package/dist/queries/complexity.d.ts +13 -0
  137. package/dist/queries/complexity.js +9 -0
  138. package/dist/queries/complexity.js.map +1 -0
  139. package/dist/queries/convergence.d.ts +11 -0
  140. package/dist/queries/convergence.js +9 -0
  141. package/dist/queries/convergence.js.map +1 -0
  142. package/dist/queries/coupling.d.ts +17 -0
  143. package/dist/queries/coupling.js +9 -0
  144. package/dist/queries/coupling.js.map +1 -0
  145. package/dist/queries/cycles.d.ts +16 -0
  146. package/dist/queries/cycles.js +8 -0
  147. package/dist/queries/cycles.js.map +1 -0
  148. package/dist/queries/dataflow.d.ts +19 -0
  149. package/dist/queries/dataflow.js +9 -0
  150. package/dist/queries/dataflow.js.map +1 -0
  151. package/dist/queries/dead.d.ts +10 -0
  152. package/dist/queries/dead.js +9 -0
  153. package/dist/queries/dead.js.map +1 -0
  154. package/dist/queries/deep-chains.d.ts +16 -0
  155. package/dist/queries/deep-chains.js +8 -0
  156. package/dist/queries/deep-chains.js.map +1 -0
  157. package/dist/queries/deps.d.ts +9 -0
  158. package/dist/queries/deps.js +9 -0
  159. package/dist/queries/deps.js.map +1 -0
  160. package/dist/queries/diff-impact.d.ts +13 -0
  161. package/dist/queries/diff-impact.js +9 -0
  162. package/dist/queries/diff-impact.js.map +1 -0
  163. package/dist/queries/doc-coverage.d.ts +14 -0
  164. package/dist/queries/doc-coverage.js +8 -0
  165. package/dist/queries/doc-coverage.js.map +1 -0
  166. package/dist/queries/drift.d.ts +25 -0
  167. package/dist/queries/drift.js +8 -0
  168. package/dist/queries/drift.js.map +1 -0
  169. package/dist/queries/extract-candidates.d.ts +25 -0
  170. package/dist/queries/extract-candidates.js +9 -0
  171. package/dist/queries/extract-candidates.js.map +1 -0
  172. package/dist/queries/fan.d.ts +29 -0
  173. package/dist/queries/fan.js +14 -0
  174. package/dist/queries/fan.js.map +1 -0
  175. package/dist/queries/files.d.ts +6 -0
  176. package/dist/queries/files.js +7 -0
  177. package/dist/queries/files.js.map +1 -0
  178. package/dist/queries/health.d.ts +18 -0
  179. package/dist/queries/health.js +21 -0
  180. package/dist/queries/health.js.map +1 -0
  181. package/dist/queries/hierarchy.d.ts +13 -0
  182. package/dist/queries/hierarchy.js +8 -0
  183. package/dist/queries/hierarchy.js.map +1 -0
  184. package/dist/queries/hotspots.d.ts +13 -0
  185. package/dist/queries/hotspots.js +8 -0
  186. package/dist/queries/hotspots.js.map +1 -0
  187. package/dist/queries/imports.d.ts +19 -0
  188. package/dist/queries/imports.js +12 -0
  189. package/dist/queries/imports.js.map +1 -0
  190. package/dist/queries/index.d.ts +47 -0
  191. package/dist/queries/index.js +207 -0
  192. package/dist/queries/index.js.map +1 -0
  193. package/dist/queries/isolated.d.ts +14 -0
  194. package/dist/queries/isolated.js +9 -0
  195. package/dist/queries/isolated.js.map +1 -0
  196. package/dist/queries/members.d.ts +10 -0
  197. package/dist/queries/members.js +8 -0
  198. package/dist/queries/members.js.map +1 -0
  199. package/dist/queries/methods.d.ts +6 -0
  200. package/dist/queries/methods.js +8 -0
  201. package/dist/queries/methods.js.map +1 -0
  202. package/dist/queries/outline.d.ts +10 -0
  203. package/dist/queries/outline.js +8 -0
  204. package/dist/queries/outline.js.map +1 -0
  205. package/dist/queries/passthrough-candidates.d.ts +18 -0
  206. package/dist/queries/passthrough-candidates.js +9 -0
  207. package/dist/queries/passthrough-candidates.js.map +1 -0
  208. package/dist/queries/redundant-reexports.d.ts +22 -0
  209. package/dist/queries/redundant-reexports.js +8 -0
  210. package/dist/queries/redundant-reexports.js.map +1 -0
  211. package/dist/queries/refs.d.ts +6 -0
  212. package/dist/queries/refs.js +7 -0
  213. package/dist/queries/refs.js.map +1 -0
  214. package/dist/queries/similar-chains.d.ts +29 -0
  215. package/dist/queries/similar-chains.js +8 -0
  216. package/dist/queries/similar-chains.js.map +1 -0
  217. package/dist/queries/similar-files.d.ts +19 -0
  218. package/dist/queries/similar-files.js +8 -0
  219. package/dist/queries/similar-files.js.map +1 -0
  220. package/dist/queries/similar-signatures.d.ts +21 -0
  221. package/dist/queries/similar-signatures.js +8 -0
  222. package/dist/queries/similar-signatures.js.map +1 -0
  223. package/dist/queries/similar.d.ts +34 -0
  224. package/dist/queries/similar.js +11 -0
  225. package/dist/queries/similar.js.map +1 -0
  226. package/dist/queries/slice.d.ts +21 -0
  227. package/dist/queries/slice.js +9 -0
  228. package/dist/queries/slice.js.map +1 -0
  229. package/dist/queries/stale-abstractions.d.ts +18 -0
  230. package/dist/queries/stale-abstractions.js +9 -0
  231. package/dist/queries/stale-abstractions.js.map +1 -0
  232. package/dist/queries/stats.d.ts +6 -0
  233. package/dist/queries/stats.js +7 -0
  234. package/dist/queries/stats.js.map +1 -0
  235. package/dist/queries/surface.d.ts +7 -0
  236. package/dist/queries/surface.js +8 -0
  237. package/dist/queries/surface.js.map +1 -0
  238. package/dist/queries/symbols.d.ts +6 -0
  239. package/dist/queries/symbols.js +9 -0
  240. package/dist/queries/symbols.js.map +1 -0
  241. package/dist/queries/system.d.ts +7 -0
  242. package/dist/queries/system.js +9 -0
  243. package/dist/queries/system.js.map +1 -0
  244. package/dist/queries/test-coverage.d.ts +22 -0
  245. package/dist/queries/test-coverage.js +11 -0
  246. package/dist/queries/test-coverage.js.map +1 -0
  247. package/dist/queries/trace.d.ts +6 -0
  248. package/dist/queries/trace.js +8 -0
  249. package/dist/queries/trace.js.map +1 -0
  250. package/dist/queries/wrapper-candidates.d.ts +17 -0
  251. package/dist/queries/wrapper-candidates.js +9 -0
  252. package/dist/queries/wrapper-candidates.js.map +1 -0
  253. package/dist/reindex-worker.js +368 -0
  254. package/dist/reindex-worker.js.map +1 -0
  255. package/docs/AGENT_GUIDE.md +359 -0
  256. package/package.json +70 -0
  257. package/reports/debloat/2026-04-10-scip-query-self-audit.md +161 -0
  258. package/skills/concrete-plan/SKILL.md +318 -0
  259. package/skills/scip-debloat/SKILL.md +413 -0
  260. package/skills/scip-explore/SKILL.md +235 -0
  261. package/skills/scip-verify/SKILL.md +323 -0
  262. package/src/cli.ts +1480 -0
  263. package/src/config.ts +117 -0
  264. package/src/db.ts +127 -0
  265. package/src/gitignore-filter.ts +143 -0
  266. package/src/index.ts +11 -0
  267. package/src/postinstall.ts +8 -0
  268. package/src/queries/affected.ts +86 -0
  269. package/src/queries/bottlenecks.ts +67 -0
  270. package/src/queries/by-kind.ts +204 -0
  271. package/src/queries/call-graph.ts +66 -0
  272. package/src/queries/change-surface.ts +110 -0
  273. package/src/queries/clean-signature.ts +22 -0
  274. package/src/queries/code.ts +101 -0
  275. package/src/queries/complexity-hotspots.ts +119 -0
  276. package/src/queries/complexity.ts +152 -0
  277. package/src/queries/convergence.ts +82 -0
  278. package/src/queries/coupling.ts +99 -0
  279. package/src/queries/cycles.ts +78 -0
  280. package/src/queries/dataflow.ts +128 -0
  281. package/src/queries/dead.ts +122 -0
  282. package/src/queries/deep-chains.ts +59 -0
  283. package/src/queries/deps.ts +46 -0
  284. package/src/queries/diff-impact.ts +204 -0
  285. package/src/queries/doc-coverage.ts +86 -0
  286. package/src/queries/drift.ts +224 -0
  287. package/src/queries/extract-candidates.ts +167 -0
  288. package/src/queries/fan.ts +148 -0
  289. package/src/queries/files.ts +16 -0
  290. package/src/queries/health.ts +324 -0
  291. package/src/queries/hierarchy.ts +49 -0
  292. package/src/queries/hotspots.ts +53 -0
  293. package/src/queries/imports.ts +95 -0
  294. package/src/queries/index.ts +45 -0
  295. package/src/queries/isolated.ts +67 -0
  296. package/src/queries/members.ts +54 -0
  297. package/src/queries/methods.ts +27 -0
  298. package/src/queries/outline.ts +52 -0
  299. package/src/queries/passthrough-candidates.ts +94 -0
  300. package/src/queries/redundant-reexports.ts +170 -0
  301. package/src/queries/refs.ts +27 -0
  302. package/src/queries/similar-chains.ts +314 -0
  303. package/src/queries/similar-files.ts +140 -0
  304. package/src/queries/similar-signatures.ts +151 -0
  305. package/src/queries/similar.ts +305 -0
  306. package/src/queries/slice.ts +154 -0
  307. package/src/queries/stale-abstractions.ts +82 -0
  308. package/src/queries/stats.ts +22 -0
  309. package/src/queries/surface.ts +34 -0
  310. package/src/queries/symbols.ts +39 -0
  311. package/src/queries/system.ts +86 -0
  312. package/src/queries/test-coverage.ts +106 -0
  313. package/src/queries/trace.ts +55 -0
  314. package/src/queries/wrapper-candidates.ts +112 -0
  315. package/src/query-support.ts +226 -0
  316. package/src/reindex/detect.ts +58 -0
  317. package/src/reindex/index.ts +153 -0
  318. package/src/reindex/indexers.ts +220 -0
  319. package/src/reindex/install.ts +125 -0
  320. package/src/reindex-worker.ts +35 -0
  321. package/src/setup.ts +202 -0
  322. package/src/symbol-parser.ts +278 -0
  323. package/src/types.ts +654 -0
  324. package/src/watch.ts +274 -0
  325. package/tests/gitignore-filter.test.ts +48 -0
  326. package/tests/queries.test.ts +300 -0
  327. package/tests/symbol-parser.test.ts +157 -0
  328. package/tsconfig.json +20 -0
  329. package/tsup.config.ts +40 -0
  330. package/vitest.config.ts +7 -0
@@ -0,0 +1,683 @@
1
+ import Database from 'better-sqlite3';
2
+
3
+ /**
4
+ * Builds a gitignore-based path filter from .gitignore files found
5
+ * in the project directory tree. This replaces hardcoded path exclusions
6
+ * like "node_modules/", "dist/", "target/", "__pycache__/" — instead,
7
+ * we respect whatever the project already ignores.
8
+ *
9
+ * Falls back to sensible defaults if no .gitignore is found.
10
+ */
11
+ declare function createGitignoreFilter(projectRoot: string): PathFilter;
12
+ interface PathFilter {
13
+ /** Returns true if this path should be excluded from results */
14
+ isIgnored: (relativePath: string) => boolean;
15
+ /** Filter an array of paths, keeping only non-ignored ones */
16
+ filter: (paths: string[]) => string[];
17
+ }
18
+
19
+ /** Parsed components of a SCIP symbol string */
20
+ interface ScipSymbol {
21
+ /** The indexer scheme (e.g. "scip-typescript", "scip-java", "rust-analyzer") */
22
+ scheme: string;
23
+ /** Package manager (e.g. "npm", "maven", "cargo") */
24
+ manager: string;
25
+ /** Package name (e.g. "@vega/api", "com.example/mylib") */
26
+ packageName: string;
27
+ /** Package version */
28
+ version: string;
29
+ /** Descriptor chain — the path to the symbol within the file */
30
+ descriptors: ScipDescriptor[];
31
+ /** The raw, unparsed symbol string */
32
+ raw: string;
33
+ }
34
+ interface ScipDescriptor {
35
+ name: string;
36
+ suffix: DescriptorSuffix;
37
+ }
38
+ type DescriptorSuffix = 'namespace' | 'type' | 'term' | 'method' | 'type-param' | 'parameter' | 'meta' | 'macro';
39
+ /** A local symbol (file-scoped, no cross-file identity) */
40
+ interface ScipLocalSymbol {
41
+ kind: 'local';
42
+ id: string;
43
+ raw: string;
44
+ }
45
+ interface StatsResult {
46
+ documents: number;
47
+ symbols: number;
48
+ definitions: number;
49
+ references: number;
50
+ indexSizeBytes: number;
51
+ lastBuilt: Date | null;
52
+ }
53
+ interface FileResult {
54
+ relativePath: string;
55
+ }
56
+ interface SymbolResult {
57
+ startLine: number;
58
+ endLine: number;
59
+ symbol: string;
60
+ shortName: string;
61
+ signature: string | null;
62
+ }
63
+ interface MethodResult {
64
+ startLine: number;
65
+ endLine: number;
66
+ name: string;
67
+ }
68
+ interface RefResult {
69
+ relativePath: string;
70
+ line: number;
71
+ }
72
+ interface DepResult {
73
+ relativePath: string;
74
+ }
75
+ interface TraceResult {
76
+ definitions: Array<{
77
+ relativePath: string;
78
+ startLine: number;
79
+ endLine: number;
80
+ signature: string | null;
81
+ }>;
82
+ referencedBy: string[];
83
+ }
84
+ interface SystemResult {
85
+ files: string[];
86
+ symbols: SymbolResult[];
87
+ dependsOn: string[];
88
+ dependedOnBy: string[];
89
+ }
90
+ interface SurfaceResult {
91
+ consumer: string;
92
+ symbol: string;
93
+ shortName: string;
94
+ }
95
+ interface DeadSymbolResult {
96
+ relativePath: string;
97
+ startLine: number;
98
+ endLine: number;
99
+ loc: number;
100
+ symbol: string;
101
+ shortName: string;
102
+ sameFileRefs: number;
103
+ kind: 'dead-code' | 'file-internal';
104
+ }
105
+ interface DeadSummary {
106
+ symbols: DeadSymbolResult[];
107
+ totalCount: number;
108
+ /** Symbols with zero references anywhere — safe to delete */
109
+ deadCodeCount: number;
110
+ /** Symbols referenced only within their own file — no cross-file consumers.
111
+ * May be private helpers (fine) or forgotten exports (needs review). */
112
+ fileInternalCount: number;
113
+ totalLoc: number;
114
+ }
115
+ interface HotspotResult {
116
+ symbol: string;
117
+ shortName: string;
118
+ refCount: number;
119
+ fileCount: number;
120
+ definedIn: string;
121
+ }
122
+ interface ImportResult {
123
+ symbol: string;
124
+ shortName: string;
125
+ fromFile: string;
126
+ }
127
+ interface UnusedImportResult {
128
+ symbol: string;
129
+ shortName: string;
130
+ importedIn: string;
131
+ }
132
+ interface OutlineNode {
133
+ symbol: string;
134
+ shortName: string;
135
+ startLine: number;
136
+ endLine: number;
137
+ children: OutlineNode[];
138
+ }
139
+ interface MemberResult {
140
+ symbol: string;
141
+ shortName: string;
142
+ startLine: number;
143
+ endLine: number;
144
+ kind: string;
145
+ }
146
+ interface FanResult {
147
+ name: string;
148
+ count: number;
149
+ }
150
+ interface CouplingResult {
151
+ file1: string;
152
+ file2: string;
153
+ sharedSymbols: number;
154
+ }
155
+ interface CycleResult {
156
+ /** Files forming a cycle, in order */
157
+ path: string[];
158
+ }
159
+ interface BottleneckResult {
160
+ symbol: string;
161
+ shortName: string;
162
+ fanIn: number;
163
+ fanOut: number;
164
+ /** fanIn * fanOut — higher = more central coupling hub */
165
+ score: number;
166
+ definedIn: string;
167
+ }
168
+ interface IsolatedResult {
169
+ symbol: string;
170
+ shortName: string;
171
+ relativePath: string;
172
+ startLine: number;
173
+ endLine: number;
174
+ loc: number;
175
+ }
176
+ interface ByKindResult {
177
+ symbol: string;
178
+ shortName: string;
179
+ kind: number;
180
+ kindName: string;
181
+ relativePath: string;
182
+ startLine: number;
183
+ endLine: number;
184
+ }
185
+ interface TestCoverageResult {
186
+ symbol: string;
187
+ shortName: string;
188
+ definedIn: string;
189
+ testFiles: string[];
190
+ covered: boolean;
191
+ }
192
+ interface DocCoverageResult {
193
+ totalSymbols: number;
194
+ documented: number;
195
+ undocumented: number;
196
+ coveragePercent: number;
197
+ undocumentedSymbols: Array<{
198
+ symbol: string;
199
+ shortName: string;
200
+ relativePath: string;
201
+ startLine: number;
202
+ }>;
203
+ }
204
+ interface DeepChainResult {
205
+ /** Files in the chain, from leaf to root */
206
+ chain: string[];
207
+ depth: number;
208
+ }
209
+ interface HierarchyNode {
210
+ symbol: string;
211
+ shortName: string;
212
+ depth: number;
213
+ }
214
+ interface CallGraphResult {
215
+ symbol: string;
216
+ shortName: string;
217
+ /** Symbols that call this one (incoming) */
218
+ callers: Array<{
219
+ symbol: string;
220
+ shortName: string;
221
+ file: string;
222
+ }>;
223
+ /** Symbols called by this one (outgoing) */
224
+ callees: Array<{
225
+ symbol: string;
226
+ shortName: string;
227
+ file: string;
228
+ }>;
229
+ }
230
+ interface DriftResult {
231
+ file: string;
232
+ kind: 'unused-import' | 'layer-violation' | 'pattern-deviation';
233
+ description: string;
234
+ /** The dependency involved */
235
+ dep: string;
236
+ /** For layer violations: the expected layer boundary */
237
+ detail?: string;
238
+ }
239
+ interface DriftSummary {
240
+ results: DriftResult[];
241
+ unusedImports: number;
242
+ layerViolations: number;
243
+ patternDeviations: number;
244
+ }
245
+ interface WrapperCandidate {
246
+ symbol: string;
247
+ shortName: string;
248
+ file: string;
249
+ startLine: number;
250
+ endLine: number;
251
+ loc: number;
252
+ singleCaller: string;
253
+ singleCallerShort: string;
254
+ callerFanIn: number;
255
+ }
256
+ interface PassthroughCandidate {
257
+ symbol: string;
258
+ shortName: string;
259
+ file: string;
260
+ startLine: number;
261
+ endLine: number;
262
+ loc: number;
263
+ forwardsTo: string;
264
+ forwardsToShort: string;
265
+ forwardsToFile: string;
266
+ }
267
+ interface StaleAbstraction {
268
+ symbol: string;
269
+ shortName: string;
270
+ file: string;
271
+ startLine: number;
272
+ endLine: number;
273
+ loc: number;
274
+ consumers: number;
275
+ }
276
+ interface ComplexityHotspot {
277
+ symbol: string;
278
+ shortName: string;
279
+ file: string;
280
+ startLine: number;
281
+ endLine: number;
282
+ loc: number;
283
+ fanIn: number;
284
+ fanOut: number;
285
+ calleeCount: number;
286
+ score: number;
287
+ }
288
+ interface SimilarSymbolResult {
289
+ symbolA: string;
290
+ shortNameA: string;
291
+ fileA: string;
292
+ symbolB: string;
293
+ shortNameB: string;
294
+ fileB: string;
295
+ /** Jaccard similarity of callee sets (0-1) */
296
+ similarity: number;
297
+ /** Callees shared by both symbols */
298
+ sharedCallees: string[];
299
+ /** Callees unique to A */
300
+ uniqueToA: string[];
301
+ /** Callees unique to B */
302
+ uniqueToB: string[];
303
+ }
304
+ interface SimilarFileResult {
305
+ fileA: string;
306
+ fileB: string;
307
+ /** Jaccard similarity of dependency sets (0-1) */
308
+ similarity: number;
309
+ sharedDeps: string[];
310
+ uniqueToA: string[];
311
+ uniqueToB: string[];
312
+ }
313
+ interface SimilarChainResult {
314
+ chainA: string[];
315
+ chainB: string[];
316
+ /** Fraction of nodes shared (0-1) */
317
+ similarity: number;
318
+ /** Edit distance between the two chains */
319
+ editDistance: number;
320
+ /** Indices where the chains diverge — the consolidation targets */
321
+ divergencePoints: Array<{
322
+ index: number;
323
+ nodeA: string;
324
+ nodeB: string;
325
+ }>;
326
+ /** Shared prefix */
327
+ commonPrefix: string[];
328
+ /** Shared suffix */
329
+ commonSuffix: string[];
330
+ }
331
+ interface ExtractCandidate {
332
+ symbol: string;
333
+ shortName: string;
334
+ relativePath: string;
335
+ startLine: number;
336
+ endLine: number;
337
+ loc: number;
338
+ /** Total callees */
339
+ totalCallees: number;
340
+ /** Distinct clusters of callees (natural extraction seams) */
341
+ clusters: Array<{
342
+ callees: string[];
343
+ /** How isolated this cluster is from the rest (0-1, higher = more extractable) */
344
+ isolation: number;
345
+ }>;
346
+ }
347
+ interface HealthAction {
348
+ category: string;
349
+ description: string;
350
+ effort: 'low' | 'medium' | 'high';
351
+ impact: 'low' | 'medium' | 'high';
352
+ count: number;
353
+ locRecoverable: number;
354
+ }
355
+ interface HealthReport {
356
+ score: number;
357
+ overview: {
358
+ documents: number;
359
+ symbols: number;
360
+ indexSizeBytes: number;
361
+ };
362
+ findings: {
363
+ deadSymbols: number;
364
+ deadLoc: number;
365
+ isolatedSymbols: number;
366
+ isolatedLoc: number;
367
+ cycles: number;
368
+ similarPairs: number;
369
+ extractionCandidates: number;
370
+ wrappers: number;
371
+ passthroughs: number;
372
+ staleTypes: number;
373
+ driftedFiles: number;
374
+ complexityHotspotCount: number;
375
+ testCoveragePercent: number;
376
+ };
377
+ actions: HealthAction[];
378
+ topComplexity: Array<{
379
+ symbol: string;
380
+ score: number;
381
+ }>;
382
+ }
383
+ interface ConvergenceResult {
384
+ symbolA: {
385
+ symbol: string;
386
+ shortName: string;
387
+ file: string;
388
+ loc: number;
389
+ };
390
+ symbolB: {
391
+ symbol: string;
392
+ shortName: string;
393
+ file: string;
394
+ loc: number;
395
+ };
396
+ similarity: number;
397
+ sharedCallees: string[];
398
+ uniqueToA: string[];
399
+ uniqueToB: string[];
400
+ consolidationStrategy: string;
401
+ }
402
+ interface CodeResult {
403
+ symbol: string;
404
+ shortName: string;
405
+ relativePath: string;
406
+ startLine: number;
407
+ endLine: number;
408
+ language: string | null;
409
+ source: string;
410
+ }
411
+ interface ComplexityResult {
412
+ symbol: string;
413
+ shortName: string;
414
+ relativePath: string;
415
+ startLine: number;
416
+ endLine: number;
417
+ loc: number;
418
+ /** Branch count from source-level regex (if, else, for, while, switch, catch, ternary, &&, ||) */
419
+ branches: number;
420
+ /** Cyclomatic complexity estimate: branches + 1 */
421
+ cyclomaticEstimate: number;
422
+ /** Number of distinct callees within the definition */
423
+ calleeCount: number;
424
+ fanIn: number;
425
+ fanOut: number;
426
+ }
427
+ interface DataflowResult {
428
+ symbol: string;
429
+ shortName: string;
430
+ relativePath: string;
431
+ /** Where the symbol is defined (role=1) */
432
+ definitionSites: Array<{
433
+ file: string;
434
+ line: number;
435
+ }>;
436
+ /** Where the symbol is referenced (role=0) */
437
+ usageSites: Array<{
438
+ file: string;
439
+ line: number;
440
+ enclosingSymbol: string;
441
+ enclosingShort: string;
442
+ }>;
443
+ /** Symbols that appear in the same function that defines this symbol (producers/inputs) */
444
+ producers: Array<{
445
+ symbol: string;
446
+ shortName: string;
447
+ file: string;
448
+ }>;
449
+ /** Symbols defined by functions that reference this symbol (consumers/outputs) */
450
+ consumers: Array<{
451
+ symbol: string;
452
+ shortName: string;
453
+ file: string;
454
+ }>;
455
+ }
456
+ interface SliceResult {
457
+ symbol: string;
458
+ shortName: string;
459
+ direction: 'backward' | 'forward';
460
+ /** Backward: symbols referenced in the same function as the target's definition (inputs) */
461
+ /** Forward: symbols defined by functions that reference the target (outputs) */
462
+ connectedSymbols: Array<{
463
+ symbol: string;
464
+ shortName: string;
465
+ file: string;
466
+ relationship: string;
467
+ }>;
468
+ }
469
+ interface AffectedResult {
470
+ symbol: string;
471
+ shortName: string;
472
+ file: string;
473
+ depth: number;
474
+ }
475
+ interface ChangeSurfaceEntry {
476
+ symbol: string;
477
+ shortName: string;
478
+ startLine: number;
479
+ endLine: number;
480
+ externalConsumers: number;
481
+ testFiles: string[];
482
+ riskLevel: 'low' | 'medium' | 'high';
483
+ }
484
+ interface ChangeSurfaceResult {
485
+ file: string;
486
+ symbols: ChangeSurfaceEntry[];
487
+ totalExternalConsumers: number;
488
+ testCoveragePercent: number;
489
+ }
490
+ interface DiffImpactResult {
491
+ changedFiles: string[];
492
+ changedSymbols: Array<{
493
+ symbol: string;
494
+ shortName: string;
495
+ file: string;
496
+ fanIn: number;
497
+ }>;
498
+ affectedConsumers: Array<{
499
+ file: string;
500
+ consumedSymbols: number;
501
+ }>;
502
+ uncoveredSymbols: Array<{
503
+ symbol: string;
504
+ shortName: string;
505
+ file: string;
506
+ }>;
507
+ summary: {
508
+ totalChangedFiles: number;
509
+ totalChangedSymbols: number;
510
+ totalAffectedFiles: number;
511
+ testCoveragePercent: number;
512
+ };
513
+ }
514
+ interface DeadOptions {
515
+ scope?: string;
516
+ minLoc?: number;
517
+ includeTests?: boolean;
518
+ skipBarrels?: boolean;
519
+ includeMembers?: boolean;
520
+ }
521
+ interface InstallMethod {
522
+ /** Human-readable label (e.g., "npm", "pip", "go install") */
523
+ label: string;
524
+ /** Binary that must exist for this install method to work (e.g., "npm", "pip3", "go") */
525
+ prerequisite: string;
526
+ /** Command to execute */
527
+ binary: string;
528
+ /** Arguments for the command */
529
+ args: string[];
530
+ }
531
+ type SupportedLanguage = 'typescript' | 'javascript' | 'java' | 'scala' | 'kotlin' | 'rust' | 'python' | 'ruby' | 'go' | 'cpp' | 'c' | 'csharp' | 'dart' | 'php';
532
+ interface IndexerConfig {
533
+ language: SupportedLanguage;
534
+ /** The npm/cargo/pip package or binary that produces the SCIP index */
535
+ indexerBinary: string;
536
+ /** Command to check if the indexer is installed */
537
+ checkCommand: string;
538
+ /** Returns the binary + args array for execFileSync (no shell injection) */
539
+ indexArgs: (opts: {
540
+ projectRoot: string;
541
+ outputPath: string;
542
+ pnpmWorkspaces?: boolean;
543
+ }) => {
544
+ binary: string;
545
+ args: string[];
546
+ };
547
+ /** Marker files that indicate this language is present */
548
+ markerFiles: string[];
549
+ /** Installation methods to try in order of preference */
550
+ installMethods?: InstallMethod[];
551
+ /** URL for manual installation if auto-install fails */
552
+ installUrl?: string;
553
+ }
554
+ interface ScipQueryConfig {
555
+ /** Path to the SQLite database (index.db) */
556
+ dbPath: string;
557
+ /** Path to the SCIP protobuf index (index.scip) */
558
+ indexPath: string;
559
+ /** Project root directory */
560
+ projectRoot: string;
561
+ /** Paths to .gitignore files to load for filtering */
562
+ gitignorePaths?: string[];
563
+ }
564
+ interface ProjectConfig {
565
+ /** Override which languages to index (default: auto-detect) */
566
+ languages?: SupportedLanguage[];
567
+ /** Watch mode settings */
568
+ watch?: WatchConfig;
569
+ /** Per-language indexer overrides */
570
+ indexer?: Partial<Record<SupportedLanguage, IndexerOverrides>>;
571
+ /** Override the database storage path (default: ~/.cache/scip-query/<hash>/) */
572
+ dbPath?: string;
573
+ }
574
+ interface WatchConfig {
575
+ /** Enable file watching (default: false, must opt in) */
576
+ enabled?: boolean;
577
+ /** Ms to wait after the last file change before triggering reindex (default: 30000) */
578
+ debounceMs?: number;
579
+ /** Minimum ms between reindex completions (default: 60000) */
580
+ cooldownMs?: number;
581
+ /** Extra glob patterns to ignore beyond .gitignore */
582
+ ignore?: string[];
583
+ }
584
+ interface IndexerOverrides {
585
+ /** Enable pnpm workspace support (TypeScript) */
586
+ pnpmWorkspaces?: boolean;
587
+ }
588
+ interface RedundantReexport {
589
+ barrelFile: string;
590
+ symbol: string;
591
+ shortName: string;
592
+ originalFile: string;
593
+ /** How many consumers import through the barrel */
594
+ barrelConsumers: number;
595
+ /** How many consumers import directly from the source */
596
+ directConsumers: number;
597
+ }
598
+ interface SimilarSignatureGroup {
599
+ /** The normalized signature shared by all functions in the group */
600
+ signature: string;
601
+ /** Functions that share this signature */
602
+ functions: Array<{
603
+ symbol: string;
604
+ shortName: string;
605
+ file: string;
606
+ startLine: number;
607
+ endLine: number;
608
+ loc: number;
609
+ }>;
610
+ }
611
+ type WatcherStatus = {
612
+ state: 'idle';
613
+ } | {
614
+ state: 'waiting';
615
+ changedFiles: number;
616
+ reindexAt: number;
617
+ } | {
618
+ state: 'indexing';
619
+ startedAt: number;
620
+ } | {
621
+ state: 'cooldown';
622
+ until: number;
623
+ dirty: boolean;
624
+ };
625
+
626
+ /**
627
+ * Thin wrapper around better-sqlite3 with a pre-configured connection
628
+ * and helper methods for the SCIP SQLite schema.
629
+ *
630
+ * The schema is produced by `scip expt-convert` and is identical
631
+ * regardless of source language (TypeScript, Rust, Python, etc.).
632
+ *
633
+ * Tables:
634
+ * documents — indexed files (id, language, relative_path)
635
+ * global_symbols — all symbols (id, symbol, display_name, kind, documentation)
636
+ * defn_enclosing_ranges — definition locations (document_id, symbol_id, start/end line/char)
637
+ * mentions — references & definitions (chunk_id, symbol_id, role)
638
+ * chunks — code segments (document_id, chunk_index, start/end line, occurrences)
639
+ */
640
+ declare class ScipDatabase {
641
+ readonly db: Database.Database;
642
+ readonly config: ScipQueryConfig;
643
+ private pathFilter;
644
+ constructor(config: ScipQueryConfig, pathFilter?: PathFilter);
645
+ /** Attach a gitignore-based path filter for query results */
646
+ setPathFilter(filter: PathFilter): void;
647
+ /** Check if a path should be excluded based on .gitignore rules */
648
+ isIgnored(relativePath: string): boolean;
649
+ /** Filter an array of paths using the gitignore filter */
650
+ filterPaths(paths: string[]): string[];
651
+ /**
652
+ * The local-symbol predicate: only match symbols that are defined
653
+ * in files NOT excluded by gitignore. This replaces the old hardcoded
654
+ * `NOT LIKE 'node_modules/%'` check.
655
+ *
656
+ * Since SQLite can't evaluate JS gitignore rules inline, we use a
657
+ * simpler approach: query broadly, then filter in JS. For queries
658
+ * that need SQL-level filtering, use excludedPathPatterns().
659
+ */
660
+ get localSymbolPredicate(): string;
661
+ /**
662
+ * SQL WHERE clause fragments to exclude common build/dependency paths.
663
+ * Complements the JS-level gitignore filtering for performance.
664
+ */
665
+ get pathExclusions(): string;
666
+ /** Reusable SQL fragment: filter out synthetic/internal symbol noise */
667
+ get symbolNoise(): string;
668
+ /** Build SQL path exclusions for one or more document table aliases */
669
+ pathExclusionsFor(...aliases: string[]): string;
670
+ /** Build SQL symbol exclusions for the given global_symbols alias */
671
+ symbolNoiseFor(alias: string): string;
672
+ /** Run a raw SQL query and return all rows */
673
+ all<T = Record<string, unknown>>(sql: string, ...params: unknown[]): T[];
674
+ /** Run a raw SQL query and return the first row */
675
+ get<T = Record<string, unknown>>(sql: string, ...params: unknown[]): T | undefined;
676
+ /** Get the database file size in bytes */
677
+ sizeBytes(): number;
678
+ /** Get the last modification time of the database file */
679
+ lastModified(): Date | null;
680
+ close(): void;
681
+ }
682
+
683
+ export { type WatcherStatus as $, type AffectedResult as A, type BottleneckResult as B, type CallGraphResult as C, type DataflowResult as D, type ExtractCandidate as E, type FanResult as F, type SimilarFileResult as G, type HealthReport as H, type ImportResult as I, type SimilarChainResult as J, type StaleAbstraction as K, type SliceResult as L, type MemberResult as M, type RedundantReexport as N, type OutlineNode as O, type PassthroughCandidate as P, type SimilarSignatureGroup as Q, type RefResult as R, ScipDatabase as S, type TraceResult as T, type UnusedImportResult as U, type ScipSymbol as V, type WrapperCandidate as W, type ScipLocalSymbol as X, type SupportedLanguage as Y, type IndexerConfig as Z, type ProjectConfig as _, type ByKindResult as a, type ChangeSurfaceEntry as a0, type DeadSymbolResult as a1, type DescriptorSuffix as a2, type DriftResult as a3, type HealthAction as a4, type IndexerOverrides as a5, type InstallMethod as a6, type ScipDescriptor as a7, type ScipQueryConfig as a8, type WatchConfig as a9, createGitignoreFilter as aa, type ChangeSurfaceResult as b, type CodeResult as c, type ComplexityHotspot as d, type ComplexityResult as e, type ConvergenceResult as f, type CouplingResult as g, type CycleResult as h, type DeadOptions as i, type DeadSummary as j, type DeepChainResult as k, type DepResult as l, type DiffImpactResult as m, type DocCoverageResult as n, type DriftSummary as o, type FileResult as p, type HierarchyNode as q, type HotspotResult as r, type IsolatedResult as s, type MethodResult as t, type StatsResult as u, type SymbolResult as v, type SystemResult as w, type SurfaceResult as x, type TestCoverageResult as y, type SimilarSymbolResult as z };