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,359 @@
1
+ # scip-query Agent Guide
2
+
3
+ Goal-oriented workflows for AI agents and developers. Each section starts with a goal and walks through the exact commands to run, what to expect back, and how to use the results.
4
+
5
+ For command syntax and options reference, see [README.md](../README.md).
6
+
7
+ ---
8
+
9
+ ## Workflow 1: Understand a system before making changes
10
+
11
+ **Goal:** Build a complete mental model of a module or feature area so you can write a precise implementation plan with no ambiguity about what code exists, what it does, and what depends on it.
12
+
13
+ ### Steps
14
+
15
+ 1. **Map the module**
16
+ ```bash
17
+ scip-query system <module-path>
18
+ ```
19
+ Returns: all files in the module, all exported symbols with line ranges, all inbound and outbound dependencies. This is your starting map.
20
+
21
+ 2. **Understand the public contract**
22
+ ```bash
23
+ scip-query surface <module-path>
24
+ ```
25
+ Returns: which symbols external consumers actually reference. This is the true public API — not what's exported, but what's used. Any change to these symbols is a breaking change.
26
+
27
+ 3. **Trace specific symbols**
28
+ ```bash
29
+ scip-query trace <symbol-name>
30
+ ```
31
+ Returns: where the symbol is defined (file + line range + signature) and every file that references it. Use this for any symbol you need to understand deeply.
32
+
33
+ 4. **Map the call graph**
34
+ ```bash
35
+ scip-query call-graph <function-name>
36
+ ```
37
+ Returns: what calls this function (incoming) and what this function calls (outgoing). Gives you the function's role in the execution flow.
38
+
39
+ 5. **Check blast radius**
40
+ ```bash
41
+ scip-query affected <symbol-name>
42
+ ```
43
+ Returns: the full transitive closure of symbols that could break if this symbol changes. Depth 1 = direct consumers. Depth 2 = consumers of consumers. Shows the complete ripple effect.
44
+
45
+ 6. **Pre-change briefing**
46
+ ```bash
47
+ scip-query change-surface <file>
48
+ ```
49
+ Returns: every symbol in the file, how many external consumers each has, which are test-covered, and a risk level (high/medium/low). Run this before modifying any file.
50
+
51
+ ### What you should know after this workflow
52
+
53
+ - Every file in the module and what it contains
54
+ - The true public API (what consumers actually use)
55
+ - The full dependency graph (what the module depends on and what depends on it)
56
+ - The blast radius of any specific symbol change
57
+ - Which symbols are high-risk (many consumers, no tests)
58
+
59
+ ---
60
+
61
+ ## Workflow 2: Write a concrete implementation plan
62
+
63
+ **Goal:** Produce an implementation plan where every file to create/modify is named, every symbol to change is identified with line numbers, every dependency is mapped, and every risk is called out.
64
+
65
+ ### Steps
66
+
67
+ 1. **Map the target area**
68
+ ```bash
69
+ scip-query system <module-path>
70
+ scip-query symbols <each-file-you-will-modify>
71
+ ```
72
+ Get the full symbol inventory with line ranges and signatures for every file in scope.
73
+
74
+ 2. **Identify the public contract you must preserve**
75
+ ```bash
76
+ scip-query surface <module-path>
77
+ ```
78
+ Any symbol that appears here must maintain backward compatibility or all consumers must be updated.
79
+
80
+ 3. **Map every symbol you plan to change**
81
+ ```bash
82
+ scip-query refs <symbol> # who uses it
83
+ scip-query affected <symbol> # transitive blast radius
84
+ scip-query fan-in <symbol> # quantified consumer count
85
+ ```
86
+ For each symbol you'll modify: know exactly who consumes it and how many layers deep the impact goes.
87
+
88
+ 4. **Check test coverage gaps**
89
+ ```bash
90
+ scip-query test-coverage <symbol>
91
+ scip-query change-surface <file>
92
+ ```
93
+ Identify which symbols in your change set lack test coverage. These are the risk points that need new tests.
94
+
95
+ 5. **Find reusable code**
96
+ ```bash
97
+ scip-query similar <symbol-you-plan-to-write>
98
+ scip-query deps <file>
99
+ ```
100
+ Before writing new code, check if something similar already exists. `similar` finds functions with overlapping callee patterns. `deps` shows what the file already imports that you can reuse.
101
+
102
+ 6. **After making changes, verify impact**
103
+ ```bash
104
+ scip-query diff-impact
105
+ ```
106
+ Shows every symbol affected by your git diff, every consumer file impacted, and test coverage gaps.
107
+
108
+ ### Plan template
109
+
110
+ ```
111
+ ## Change: [description]
112
+
113
+ ### Files to modify
114
+ - `path/to/file.ts` — [what changes, which symbols]
115
+ - `symbolName` (lines X-Y) — [change description]
116
+ - Fan-in: N, Test coverage: yes/no
117
+
118
+ ### Files to create
119
+ - `path/to/new-file.ts` — [purpose]
120
+ - Similar to: `existing-file.ts` (N% callee overlap via `similar`)
121
+
122
+ ### Public contract impact
123
+ - `surface` shows N symbols consumed externally
124
+ - [List any breaking changes]
125
+
126
+ ### Blast radius
127
+ - `affected` shows N symbols across M files at depth 1-2
128
+ - [List high-risk symbols]
129
+
130
+ ### Test plan
131
+ - `change-surface` shows N symbols without test coverage
132
+ - [Tests to add]
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Workflow 3: Clean up and de-bloat a codebase
138
+
139
+ **Goal:** Systematically reduce unnecessary code, eliminate duplication, and improve structural health.
140
+
141
+ ### Steps
142
+
143
+ 1. **Get the full health report**
144
+ ```bash
145
+ scip-query health
146
+ ```
147
+ This runs every analysis and produces a prioritized action list. Start here. The actions are sorted by impact/effort ratio — do the top ones first.
148
+
149
+ 2. **Delete dead code (safest, highest impact)**
150
+ ```bash
151
+ scip-query dead --min-loc 10 --skip-barrels
152
+ ```
153
+ These symbols have zero cross-file references. They can be safely deleted. `--skip-barrels` ignores re-exports through index.ts files which can create false negatives.
154
+
155
+ 3. **Delete isolated symbols**
156
+ ```bash
157
+ scip-query isolated --min-loc 5
158
+ ```
159
+ Stricter than `dead` — these symbols have zero references anywhere, including in their own file. Completely disconnected from the codebase.
160
+
161
+ 4. **Break circular dependencies**
162
+ ```bash
163
+ scip-query cycles
164
+ ```
165
+ If any exist, they need structural fixes: dependency inversion, module splitting, or interface extraction.
166
+
167
+ 5. **Consolidate similar functions**
168
+ ```bash
169
+ scip-query similar --min-similarity 0.5
170
+ ```
171
+ Pairs of functions with overlapping callee sets. For each pair:
172
+ ```bash
173
+ scip-query convergence <symbol1> <symbol2>
174
+ ```
175
+ Shows what the consolidated version would look like: shared callees = common body, unique callees = parameterization points.
176
+
177
+ 6. **Extract large functions**
178
+ ```bash
179
+ scip-query extract-candidates --min-loc 20
180
+ ```
181
+ Functions with isolated callee clusters — natural "Extract Method" seams.
182
+
183
+ 7. **Remove unnecessary indirection**
184
+ ```bash
185
+ scip-query wrapper-candidates
186
+ scip-query passthrough-candidates
187
+ ```
188
+ Wrappers: single-consumer symbols that can be inlined. Passthroughs: functions that just forward to one callee.
189
+
190
+ 8. **Prune premature abstractions**
191
+ ```bash
192
+ scip-query stale-abstractions
193
+ ```
194
+ Types and interfaces with 0-1 consumers. An interface with one implementation isn't an abstraction.
195
+
196
+ 9. **Fix pattern drift**
197
+ ```bash
198
+ scip-query drift
199
+ ```
200
+
201
+ 10. **Remove redundant re-exports**
202
+ ```bash
203
+ scip-query redundant-reexports
204
+ ```
205
+ Barrel file entries that nobody imports through. Clean up the barrel.
206
+
207
+ 11. **Find same-shape functions**
208
+ ```bash
209
+ scip-query similar-signatures --min-loc 5
210
+ ```
211
+ Functions with identical parameter/return types. Different signal from callee similarity — catches "same interface, different implementation."
212
+ Files that deviate from their directory's typical dependency pattern. Bring them into line with their neighbors.
213
+
214
+ ### Priority order
215
+
216
+ | Priority | What | Why |
217
+ |---|---|---|
218
+ | 1 | Dead code | Zero risk, immediate LOC reduction |
219
+ | 2 | Isolated symbols | Zero risk, zero consumers |
220
+ | 3 | Circular deps | Structural fix, prevents future problems |
221
+ | 4 | Similar functions | Reduces duplication, use `convergence` for prescription |
222
+ | 5 | Extraction candidates | Reduces function complexity |
223
+ | 6 | Wrappers / passthroughs | Removes unnecessary indirection |
224
+ | 7 | Stale abstractions | Removes premature over-engineering |
225
+ | 8 | Pattern drift | Consistency improvement |
226
+
227
+ ---
228
+
229
+ ## Workflow 4: Assess code quality and risk
230
+
231
+ **Goal:** Produce a quality assessment of a codebase or module with quantified metrics.
232
+
233
+ ### Steps
234
+
235
+ 1. **Overall health**
236
+ ```bash
237
+ scip-query health
238
+ scip-query health --json # for programmatic use
239
+ ```
240
+
241
+ 2. **Complexity risks**
242
+ ```bash
243
+ scip-query complexity-hotspots -n 20
244
+ ```
245
+ Symbols with the highest composite score (LOC x fan-in x fan-out). These are the most likely to contain bugs and the hardest to modify.
246
+
247
+ 3. **Coupling risks**
248
+ ```bash
249
+ scip-query bottlenecks -n 20
250
+ ```
251
+ Symbols with both high fan-in (many consumers) AND high fan-out (many dependencies). Changes to these are risky in both directions.
252
+
253
+ 4. **Architecture depth**
254
+ ```bash
255
+ scip-query deep-chains --min-depth 5
256
+ ```
257
+ Long transitive dependency chains. If chains are deeper than 6-7, the architecture may need flattening.
258
+
259
+ 5. **Test coverage**
260
+ ```bash
261
+ scip-query test-coverage
262
+ ```
263
+ Percentage of symbols referenced by test files. Not execution coverage, but structural coverage.
264
+
265
+ 6. **Documentation coverage**
266
+ ```bash
267
+ scip-query doc-coverage --min-loc 5
268
+ ```
269
+
270
+ ### Quality report template
271
+
272
+ ```
273
+ ## Quality Assessment: [project/module]
274
+
275
+ ### Overview
276
+ - Files: N | Symbols: N | Index size: N
277
+ - Health score: N/100
278
+
279
+ ### Risk Areas
280
+ - Complexity hotspots: [top 5 from complexity-hotspots]
281
+ - Coupling bottlenecks: [top 5 from bottlenecks]
282
+ - Deepest dependency chain: N layers
283
+ - Circular dependencies: N
284
+
285
+ ### Coverage
286
+ - Test coverage: N% of symbols referenced by tests
287
+ - Documentation coverage: N%
288
+
289
+ ### Cleanup Opportunities
290
+ - Dead code: N symbols (N LOC recoverable)
291
+ - Similar function pairs: N
292
+ - Stale abstractions: N
293
+ ```
294
+
295
+ ---
296
+
297
+ ## Workflow 5: Understand impact after making changes
298
+
299
+ **Goal:** After modifying code, verify what was affected and identify gaps.
300
+
301
+ ### Steps
302
+
303
+ 1. **Compute diff impact**
304
+ ```bash
305
+ scip-query diff-impact
306
+ ```
307
+ Shows: changed files, changed symbols with fan-in counts, affected consumer files, symbols without test coverage.
308
+
309
+ 2. **Check transitive impact for critical symbols**
310
+ ```bash
311
+ scip-query affected <changed-symbol>
312
+ ```
313
+ For any high fan-in symbol that changed, check the full transitive blast wave.
314
+
315
+ 3. **Verify test coverage**
316
+ ```bash
317
+ scip-query test-coverage <changed-symbol>
318
+ ```
319
+ For each affected symbol, verify tests exist.
320
+
321
+ ---
322
+
323
+ ## Quick Reference
324
+
325
+ | I want to... | Run |
326
+ |---|---|
327
+ | Understand a module | `system <module>` |
328
+ | See what consumers actually use | `surface <module>` |
329
+ | Find all references to a symbol | `refs <symbol>` or `trace <symbol>` |
330
+ | See what a function calls and who calls it | `call-graph <symbol>` |
331
+ | Check blast radius of a change | `affected <symbol>` |
332
+ | Get a pre-change briefing | `change-surface <file>` |
333
+ | See impact of my git changes | `diff-impact` |
334
+ | Find dead code to delete | `dead --min-loc 10 --skip-barrels` |
335
+ | Find duplicate functions | `similar --min-similarity 0.5` |
336
+ | Find same-shape functions | `similar-signatures --min-loc 5` |
337
+ | Get a refactoring prescription | `convergence <sym1> <sym2>` |
338
+ | Find redundant barrel re-exports | `redundant-reexports` |
339
+ | Find extraction opportunities | `extract-candidates --min-loc 20` |
340
+ | Find unnecessary wrappers | `wrapper-candidates` |
341
+ | Find single-implementation types | `stale-abstractions` |
342
+ | Find pattern outliers | `drift` |
343
+ | Get overall codebase health | `health` |
344
+ | Find riskiest symbols | `complexity-hotspots` |
345
+ | Find coupling pressure points | `bottlenecks` |
346
+ | Find circular dependencies | `cycles` |
347
+ | Check test coverage | `test-coverage` |
348
+
349
+ ---
350
+
351
+ ## Tips for AI Agents
352
+
353
+ - **Always reindex before analysis** if the codebase has changed significantly: `scip-query reindex`
354
+ - **Use `--json` on `health`** for programmatic consumption — parse the JSON to make decisions
355
+ - **Run `change-surface` before every file modification** — it takes <1 second and prevents surprises
356
+ - **Run `diff-impact` before committing** — catches test coverage gaps and unexpected blast radius
357
+ - **Use `convergence` after `similar`** — `similar` finds the problem, `convergence` gives the solution
358
+ - **Start cleanup with `health`** — it prioritizes for you so you don't have to decide what to fix first
359
+ - **Scope commands with `-s`** — most commands accept `--scope <path>` to limit analysis to a specific module. Use this on large codebases to keep results focused.
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "scip-query",
3
+ "version": "0.1.0",
4
+ "description": "Language-agnostic code intelligence CLI powered by SCIP indexes",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "scip-query": "dist/cli.js"
10
+ },
11
+ "sideEffects": false,
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ },
17
+ "./queries": {
18
+ "import": "./dist/queries/index.js",
19
+ "types": "./dist/queries/index.d.ts"
20
+ },
21
+ "./queries/*": {
22
+ "import": "./dist/queries/*.js",
23
+ "types": "./dist/queries/*.d.ts"
24
+ }
25
+ },
26
+ "scripts": {
27
+ "build": "tsup",
28
+ "dev": "tsup --watch",
29
+ "test": "vitest run",
30
+ "test:watch": "vitest",
31
+ "typecheck": "tsc --noEmit",
32
+ "lint": "eslint src/",
33
+ "prepublishOnly": "npm run build",
34
+ "postinstall": "node dist/postinstall.js || true"
35
+ },
36
+ "keywords": [
37
+ "scip",
38
+ "code-intelligence",
39
+ "code-navigation",
40
+ "go-to-definition",
41
+ "find-references",
42
+ "dead-code",
43
+ "dependency-graph",
44
+ "sourcegraph",
45
+ "typescript",
46
+ "python",
47
+ "rust",
48
+ "java",
49
+ "ruby",
50
+ "php",
51
+ "csharp"
52
+ ],
53
+ "license": "Apache-2.0",
54
+ "engines": {
55
+ "node": ">=18.0.0"
56
+ },
57
+ "dependencies": {
58
+ "better-sqlite3": "^11.7.0",
59
+ "commander": "^13.1.0",
60
+ "ignore": "^7.0.3"
61
+ },
62
+ "devDependencies": {
63
+ "@sourcegraph/scip-typescript": "^0.4.0",
64
+ "@types/better-sqlite3": "^7.6.12",
65
+ "@types/node": "^22.10.0",
66
+ "tsup": "^8.3.0",
67
+ "typescript": "^5.7.0",
68
+ "vitest": "^3.0.0"
69
+ }
70
+ }
@@ -0,0 +1,161 @@
1
+ # De-Bloat Report: scip-query
2
+
3
+ **Date:** 2026-04-10
4
+ **Health Score:** 33/100
5
+ **Scope:** 60 files, 1660 symbols, 996 KB
6
+
7
+ ## Summary
8
+
9
+ - Total findings: 52 actionable (excluding false positives and expected deviations)
10
+ - Estimated recoverable LOC: ~1,724
11
+ - Safe deletions: 30 symbols (~1,712 LOC)
12
+ - Structural fixes: 2 (duplicate type, unused function)
13
+ - Consolidation candidates: 0 logic-level (similarity is boilerplate, not logic)
14
+ - Critical gap: Test coverage at 4%
15
+
16
+ ---
17
+
18
+ ## Priority 1: Safe Deletions (29 dead exports + 1 isolated symbol)
19
+
20
+ **Source:** `scip-query dead --min-loc 5` + `scip-query isolated --min-loc 3`
21
+
22
+ These are `export`ed functions that are only called within their own file, or not called at all. Remove `export` or delete entirely.
23
+
24
+ | File | Symbol | LOC | Classification |
25
+ |---|---|---|---|
26
+ | `src/symbol-parser.ts:116` | `parseDescriptors()` | 85 | dead export |
27
+ | `src/queries/slice.ts:98` | `forwardSlice()` | 64 | dead export |
28
+ | `src/queries/complexity.ts:78` | `countBranches()` | 54 | dead export |
29
+ | `src/queries/slice.ts:44` | `backwardSlice()` | 53 | dead export |
30
+ | `src/queries/similar.ts:143` | `getAllCalleeFingerprints()` | 50 | dead export |
31
+ | `src/queries/similar-chains.ts:184` | `editDistance()` | 44 | dead export |
32
+ | `src/queries/similar-chains.ts:137` | `dfsChains()` | 38 | dead export |
33
+ | `src/queries/similar-files.ts:105` | `compareProfiles()` | 35 | dead export |
34
+ | `src/queries/similar-files.ts:60` | `buildFileProfiles()` | 21 | dead export |
35
+ | `src/queries/similar-files.ts:82` | `findUniversalDependencies()` | 22 | dead export |
36
+ | `src/setup.ts:121` | `getScipDownloadUrl()` | 25 | dead export |
37
+ | `src/query-support.ts:160` | `calleeQueryParams()` | 17 | dead export |
38
+ | `src/queries/similar.ts:126` | `findCallees()` | 16 | dead export |
39
+ | `src/cli.ts:17` | `openDb()` | 23 | dead export |
40
+ | `src/cli.ts:41` | `withDb()` | 8 | dead export |
41
+ | `src/cli.ts:50` | `runQuery()` | 8 | dead export |
42
+ | `src/cli.ts` | `formatBytes()` | 6 | dead export |
43
+ | `src/cli.ts` | `formatStatus()` | 16 | dead export |
44
+ | `src/queries/similar-chains.ts:121` | `generateChains()` | 15 | dead export |
45
+ | `src/queries/similar-chains.ts:231` | `getCommonPrefix()` | 8 | dead export |
46
+ | `src/queries/similar-chains.ts:240` | `getCommonSuffix()` | 10 | dead export |
47
+ | `src/queries/similar-chains.ts:251` | `isSubChain()` | 6 | dead export |
48
+ | `src/queries/similar.ts:194` | `intersection()` | 7 | dead export |
49
+ | `src/queries/similar.ts:202` | `difference()` | 7 | dead export |
50
+ | `src/queries/similar.ts:210` | `unionSize()` | 5 | dead export |
51
+ | `src/gitignore-filter.ts:53` | `findGitignoreFiles()` | 26 | dead export |
52
+ | `src/reindex/index.ts:114` | `ensureBinary()` | 7 | dead export |
53
+ | `src/config.ts:51` | `resolveCacheDir()` | 19 | dead export |
54
+ | `src/config.ts:90` | `writeMetaFile()` | 12 | dead code (isolated) |
55
+
56
+ **Action:** Remove `export` keyword from all of these. Delete `writeMetaFile()` entirely (never called). This is ~1,712 LOC of leaked internal surface.
57
+
58
+ **Risk:** Zero. These are private implementation details incorrectly exported. Removing `export` doesn't change behavior.
59
+
60
+ **False positives excluded:** `cli.ts` module, `reindex-worker.ts` module, `postinstall.ts` module, `index.ts` module (all entry points).
61
+
62
+ ---
63
+
64
+ ## Priority 2: Structural Fixes
65
+
66
+ ### 2a. Duplicate `HealthReport` type
67
+
68
+ **Source:** `scip-query stale-abstractions --min-loc 5`
69
+
70
+ `HealthReport` is defined in both `src/types.ts:380-399` and `src/queries/health.ts:22-46`. The one in `health.ts` is a local re-declaration.
71
+
72
+ **Action:** Remove the `HealthReport` interface from `queries/health.ts` and import from `types.ts`. ~25 LOC.
73
+
74
+ ### 2b. Unused `ReindexOptions` interface
75
+
76
+ **Source:** `scip-query stale-abstractions`
77
+
78
+ `ReindexOptions` in `src/reindex/index.ts:7-21` has 0 consumers. It may be intended for programmatic API consumers but is currently dead.
79
+
80
+ **Action:** Verify intent. If unused, remove. 15 LOC.
81
+
82
+ ---
83
+
84
+ ## Priority 3: Consolidation Opportunities
85
+
86
+ **Source:** `scip-query similar --min-similarity 0.6` + `scip-query convergence`
87
+
88
+ 10 function pairs at 60%+ similarity, but convergence analysis reveals the overlap is **shared boilerplate** (db, types, shortenSymbol imports), not logic duplication. Every query module follows the same pattern: import db → query SQLite → filter → map results → shorten symbols. This is correct architecture, not a problem.
89
+
90
+ **Action:** Optional low-priority refactor — extract a `withFilteredSymbols(db, scope, callback)` helper to reduce per-query scaffolding. Not urgent.
91
+
92
+ ---
93
+
94
+ ## Priority 4: Extraction Opportunities
95
+
96
+ **Source:** `scip-query extract-candidates --min-loc 10 --min-callees 4`
97
+
98
+ | File | LOC | Clusters | Action |
99
+ |---|---|---|---|
100
+ | `similar-chains.ts` | 258 | 2 (100% isolated each) | Split edit-distance + chain-generation into `chain-utils.ts` |
101
+ | `setup.ts` | 198 | 2 | Logically grouped (install vs detect) — no action |
102
+ | `types.ts` | 593 | 2 | Type barrel — consider splitting if it keeps growing |
103
+
104
+ **Action:** `similar-chains.ts` is the only actionable extraction. The two clusters (similarity logic vs edit-distance/chain-generation) are fully isolated.
105
+
106
+ ---
107
+
108
+ ## Priority 5: Indirection Removal
109
+
110
+ **Source:** `scip-query wrapper-candidates` + `scip-query passthrough-candidates`
111
+
112
+ - **Wrappers:** 4 found (`PathFilter`, `DescriptorSuffix`, `ScipLocalSymbol`, `ScipDescriptor`). All are type definitions consumed by core modules. Inlining would reduce clarity. **No action.**
113
+ - **Passthroughs:** 0 found. Clean.
114
+
115
+ ---
116
+
117
+ ## Priority 6: Convention Alignment
118
+
119
+ **Source:** `scip-query drift --min-deviation 40`
120
+
121
+ 9 files deviate. 4 are expected (barrel files, entry points, orchestrators). 5 are worth reviewing:
122
+
123
+ | File | Deviation | Issue |
124
+ |---|---|---|
125
+ | `postinstall.ts` | 100% | Only imports `setup.ts` — expected for a thin entry point |
126
+ | `query-support.ts` | 100% | Imports `db.ts` but not `types.ts` — expected, it provides helpers not query results |
127
+ | `trace.ts` | 43% | Missing `query-support.ts` import — uses `db.localSymbolPredicate` directly |
128
+ | `watch.ts` | 50% | Imports `config.ts` + `gitignore-filter.ts` — unique among src/ siblings, expected |
129
+ | `reindex/index.ts` | 50% | Imports sibling modules — expected for an orchestrator |
130
+
131
+ **Action:** `trace.ts` is the only questionable deviation — it could potentially use `query-support.ts` helpers. Low priority.
132
+
133
+ ---
134
+
135
+ ## Structural Metrics
136
+
137
+ | Metric | Value | Assessment |
138
+ |---|---|---|
139
+ | Circular dependencies | 0 | Clean |
140
+ | Max dependency chain depth | 6 | Acceptable (barrel → orchestrator → query → support → db → filter) |
141
+ | Top coupling bottleneck | `queries/index` (score 192) | Barrel file — expected |
142
+ | Top complexity hotspot | `types.ts` (score 121, 593 LOC) | Growing — monitor |
143
+ | Test coverage | **4%** (7/168 symbols) | **Critical gap** |
144
+ | Doc coverage | 100% (163/163) | Excellent |
145
+
146
+ ---
147
+
148
+ ## Action Plan
149
+
150
+ | # | Action | LOC Impact | Risk | Effort |
151
+ |---|---|---|---|---|
152
+ | 1 | Remove `export` from 29 dead exports | -0 (keyword removal) | Zero | 15 min |
153
+ | 2 | Delete `writeMetaFile()` | -12 | Zero | 1 min |
154
+ | 3 | Remove duplicate `HealthReport` from `health.ts` | -25 | Zero | 2 min |
155
+ | 4 | Verify/remove unused `ReindexOptions` | -15 | Low | 2 min |
156
+ | 5 | Split `similar-chains.ts` clusters | 0 (structural) | Low | 15 min |
157
+ | 6 | Add tests for `db`, `query-support`, `symbol-parser` | +200-400 | Zero | 1-2 hrs |
158
+ | 7 | Monitor `types.ts` growth (593 LOC) | — | — | — |
159
+
160
+ **Quick wins (items 1-4):** 20 minutes, ~52 LOC removed, zero risk.
161
+ **Test coverage (item 6):** Most impactful long-term investment. Core infrastructure at 4% is the biggest risk in this codebase.