scip-query 0.19.3 → 0.19.4

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 (268) hide show
  1. package/README.md +1 -1
  2. package/dist/augment-vue-worker.js +1 -1
  3. package/dist/{chunk-LSJDKJIB.js → chunk-25LPM4DG.js} +2 -2
  4. package/dist/chunk-2CTX5CMX.js +4 -0
  5. package/dist/chunk-2Y373BDD.js +2 -0
  6. package/dist/{chunk-24ET4VLC.js → chunk-2YU7I3QO.js} +2 -2
  7. package/dist/{chunk-QNO3QIMN.js → chunk-3MJ5YA4Y.js} +2 -2
  8. package/dist/{chunk-B26UX7ZD.js → chunk-3SVWW4PN.js} +2 -2
  9. package/dist/{chunk-WWCZCH7W.js → chunk-4333ETTV.js} +2 -2
  10. package/dist/{chunk-6EWBPAA3.js → chunk-4RSI5EMG.js} +2 -2
  11. package/dist/{chunk-CIYUFF24.js → chunk-4SALD7RU.js} +2 -2
  12. package/dist/{chunk-XWE7PZQH.js → chunk-4T3LTWUS.js} +2 -2
  13. package/dist/{chunk-34MLC6UI.js → chunk-4XTA5OMB.js} +2 -2
  14. package/dist/chunk-52ZYCAEO.js +2 -0
  15. package/dist/{chunk-SJ6XSCG7.js → chunk-54HA4ZXH.js} +2 -2
  16. package/dist/{chunk-J4MYRIYT.js → chunk-64RFXJT5.js} +2 -2
  17. package/dist/{chunk-FUFNRZFJ.js → chunk-6E7UTQY7.js} +2 -2
  18. package/dist/{chunk-PNESKY2Z.js → chunk-6NSFJYRC.js} +2 -2
  19. package/dist/{chunk-AOSFSYEA.js → chunk-7B3UPBVA.js} +2 -2
  20. package/dist/{chunk-4BUMNEYQ.js → chunk-7GXM52MI.js} +2 -2
  21. package/dist/{chunk-SOS256TP.js → chunk-A2EZV2UM.js} +2 -2
  22. package/dist/{chunk-6FIA5BEB.js → chunk-ABMYA4TN.js} +2 -2
  23. package/dist/{chunk-64QITTX7.js → chunk-B5NLK2B3.js} +2 -2
  24. package/dist/{chunk-OLG2YPLS.js → chunk-BTEE5NZQ.js} +2 -2
  25. package/dist/{chunk-MP43RX4O.js → chunk-C7NIYIQ4.js} +1 -1
  26. package/dist/{chunk-AEM24WSF.js → chunk-CFMXJPHH.js} +2 -2
  27. package/dist/{chunk-HHOJH3RJ.js → chunk-CNKAGUPL.js} +2 -2
  28. package/dist/{chunk-MQ2B33LQ.js → chunk-D4U5Q3FT.js} +2 -2
  29. package/dist/{chunk-YZXV3CU3.js → chunk-DGAGY7RJ.js} +1 -1
  30. package/dist/{chunk-FRXB74RQ.js → chunk-DLWR3NUU.js} +5 -5
  31. package/dist/{chunk-YGQBJUS6.js → chunk-DZ74OMG6.js} +2 -2
  32. package/dist/{chunk-APLNTJPJ.js → chunk-EOOJGLDU.js} +2 -2
  33. package/dist/{chunk-TYEGFDOP.js → chunk-F6O7AAC3.js} +2 -2
  34. package/dist/{chunk-HFBNIIZX.js → chunk-FECYOO5O.js} +2 -2
  35. package/dist/{chunk-AFVU2GB2.js → chunk-FWUUZTIO.js} +2 -2
  36. package/dist/{chunk-KMOMNTB4.js → chunk-GBQ5NYPR.js} +2 -2
  37. package/dist/{chunk-2ROSOG2I.js → chunk-GPBBJ5Y4.js} +2 -2
  38. package/dist/{chunk-IXAALOUP.js → chunk-H7UKLTWJ.js} +2 -2
  39. package/dist/{chunk-YILKXTIY.js → chunk-HEXVUYFQ.js} +2 -2
  40. package/dist/{chunk-J5XJWCB3.js → chunk-HKEHS2AS.js} +2 -2
  41. package/dist/{chunk-JRCJEHRG.js → chunk-I5AWSI2G.js} +2 -2
  42. package/dist/{chunk-XYBNOILR.js → chunk-I5RJM53C.js} +2 -2
  43. package/dist/{chunk-AD7WUFFT.js → chunk-IG7N5ZIK.js} +2 -2
  44. package/dist/{chunk-C3KCSAQ4.js → chunk-IUFDSKGG.js} +2 -2
  45. package/dist/{chunk-OQ6TCHBB.js → chunk-IZKFSVBV.js} +2 -2
  46. package/dist/{chunk-5OZCNAVM.js → chunk-J77UIT3I.js} +2 -2
  47. package/dist/{chunk-EGKWRX5I.js → chunk-K2ERX4UT.js} +2 -2
  48. package/dist/{chunk-FYE4PWWP.js → chunk-KP6XRY5Z.js} +2 -2
  49. package/dist/{chunk-FC5K7T35.js → chunk-L7SPDE73.js} +1 -1
  50. package/dist/{chunk-YGBHQOB2.js → chunk-LBMJEAEW.js} +2 -2
  51. package/dist/chunk-LHMNRHGV.js +3 -0
  52. package/dist/{chunk-5TZ2MQBG.js → chunk-M7AIS73L.js} +2 -2
  53. package/dist/{chunk-53SUJOJA.js → chunk-M7MTH5NR.js} +2 -2
  54. package/dist/{chunk-HNTLCR4F.js → chunk-MITTUCEH.js} +2 -2
  55. package/dist/{chunk-5GCAM4JE.js → chunk-MSWVMDAH.js} +6 -6
  56. package/dist/chunk-NH5ALKPW.js +2 -0
  57. package/dist/{chunk-EHU4TZJJ.js → chunk-NPKYOIFM.js} +3 -3
  58. package/dist/{chunk-XWJ3JYRG.js → chunk-NRCXJDHL.js} +2 -2
  59. package/dist/{chunk-5GOBZI34.js → chunk-NSS46APD.js} +2 -2
  60. package/dist/{chunk-5FUAFNMP.js → chunk-NZL2DBT7.js} +2 -2
  61. package/dist/{chunk-C3VQZFP2.js → chunk-OMPZHGHO.js} +2 -2
  62. package/dist/{chunk-XYNWAZ6J.js → chunk-P2PC2WGR.js} +2 -2
  63. package/dist/{chunk-CAKPEQZB.js → chunk-Q3AFUTGB.js} +2 -2
  64. package/dist/{chunk-ZJGZCBYT.js → chunk-Q4IIEGXJ.js} +2 -2
  65. package/dist/chunk-QDV6RDCP.js +4 -0
  66. package/dist/{chunk-FTRNGQGR.js → chunk-QGXBRIM5.js} +2 -2
  67. package/dist/{chunk-WXVGNFAO.js → chunk-QOKYJ33H.js} +1 -1
  68. package/dist/{chunk-FB6IKAKZ.js → chunk-QRGV2F7L.js} +2 -2
  69. package/dist/chunk-QVWS2VWZ.js +7 -0
  70. package/dist/{chunk-77IOFJVY.js → chunk-R4FQGQ4X.js} +2 -2
  71. package/dist/{chunk-4CZJ4YJB.js → chunk-RV2FQIX3.js} +2 -2
  72. package/dist/{chunk-4FMT4HPC.js → chunk-S44IULR6.js} +2 -2
  73. package/dist/{chunk-PCIFZHWS.js → chunk-SOAT6NLA.js} +2 -2
  74. package/dist/{chunk-TDUU63FC.js → chunk-STOL2BTL.js} +2 -2
  75. package/dist/chunk-SVLTAG5O.js +927 -0
  76. package/dist/{chunk-2WCXKANA.js → chunk-U6WNH5GC.js} +2 -2
  77. package/dist/chunk-U7DSEKOM.js +30 -0
  78. package/dist/{chunk-EII5ZHL2.js → chunk-UKZBVX4U.js} +2 -2
  79. package/dist/chunk-UOAV44HR.js +38 -0
  80. package/dist/{chunk-VIKEPD4D.js → chunk-VGRICIQI.js} +2 -2
  81. package/dist/{chunk-TOIS2VAI.js → chunk-VMNZB6WI.js} +2 -2
  82. package/dist/{chunk-JFO2UVQP.js → chunk-VTKGCT3V.js} +5 -5
  83. package/dist/{chunk-PJENL245.js → chunk-VXQNNXJE.js} +2 -2
  84. package/dist/{chunk-HAC5EI2T.js → chunk-WER3B7MI.js} +2 -2
  85. package/dist/{chunk-5OR4QRPR.js → chunk-WQTAC523.js} +2 -2
  86. package/dist/{chunk-GAE7WCBK.js → chunk-X6D5IC6I.js} +2 -2
  87. package/dist/{chunk-FBUNGRKI.js → chunk-XLTP42QA.js} +2 -2
  88. package/dist/chunk-XTX6QHOF.js +4 -0
  89. package/dist/{chunk-AYRHVJXW.js → chunk-XYADIZHU.js} +5 -5
  90. package/dist/{chunk-WAU7HVDI.js → chunk-YGAGTIDK.js} +2 -2
  91. package/dist/{chunk-IICQP2DY.js → chunk-YIJ7ZAA4.js} +3 -3
  92. package/dist/{chunk-EYF5HOUZ.js → chunk-YNRNA5LK.js} +2 -2
  93. package/dist/{chunk-QKW7ISEW.js → chunk-YVVCVR2L.js} +2 -2
  94. package/dist/{chunk-MRYPDVOS.js → chunk-ZAIILQNP.js} +3 -3
  95. package/dist/{chunk-Z7M7X3ZG.js → chunk-ZGZUZ7XE.js} +2 -2
  96. package/dist/{chunk-PTYQQHZM.js → chunk-ZXJYMGD3.js} +2 -2
  97. package/dist/cli.js +2 -2
  98. package/dist/{command-descriptors-QJEYYND2.js → command-descriptors-MFU4BCJ7.js} +55 -50
  99. package/dist/{config-types-BA3xLCfG.d.ts → config-types-D20KuvvZ.d.ts} +67 -0
  100. package/dist/{db-CzA-9_rL.d.ts → db-G_II8yXU.d.ts} +1 -1
  101. package/dist/diff-gate-types-C9BoYwYD.d.ts +10 -0
  102. package/dist/direct-navigation-MRMQFIRB.js +3 -0
  103. package/dist/{health-DYy13GAe.d.ts → health-oblXYgkF.d.ts} +1 -1
  104. package/dist/index.d.ts +2 -2
  105. package/dist/index.js +1 -1
  106. package/dist/queries/affected.d.ts +2 -2
  107. package/dist/queries/affected.js +1 -1
  108. package/dist/queries/architecture.d.ts +86 -4
  109. package/dist/queries/architecture.js +1 -1
  110. package/dist/queries/bottlenecks.d.ts +2 -2
  111. package/dist/queries/bottlenecks.js +1 -1
  112. package/dist/queries/by-kind.d.ts +2 -2
  113. package/dist/queries/by-kind.js +1 -1
  114. package/dist/queries/call-graph.d.ts +2 -2
  115. package/dist/queries/call-graph.js +1 -1
  116. package/dist/queries/change-surface.d.ts +2 -2
  117. package/dist/queries/change-surface.js +1 -1
  118. package/dist/queries/cleanup-plan.d.ts +2 -2
  119. package/dist/queries/cleanup-plan.js +1 -1
  120. package/dist/queries/co-change.d.ts +2 -2
  121. package/dist/queries/co-change.js +1 -1
  122. package/dist/queries/code.d.ts +2 -2
  123. package/dist/queries/code.js +1 -1
  124. package/dist/queries/complexity-hotspots.d.ts +2 -2
  125. package/dist/queries/complexity-hotspots.js +1 -1
  126. package/dist/queries/complexity.d.ts +2 -2
  127. package/dist/queries/complexity.js +1 -1
  128. package/dist/queries/convergence.d.ts +2 -2
  129. package/dist/queries/convergence.js +1 -1
  130. package/dist/queries/coupling.d.ts +2 -2
  131. package/dist/queries/coupling.js +1 -1
  132. package/dist/queries/cycles.d.ts +2 -2
  133. package/dist/queries/cycles.js +1 -1
  134. package/dist/queries/dataflow.d.ts +2 -2
  135. package/dist/queries/dataflow.js +1 -1
  136. package/dist/queries/dead.d.ts +2 -2
  137. package/dist/queries/dead.js +1 -1
  138. package/dist/queries/decorative-checkers.d.ts +2 -2
  139. package/dist/queries/decorative-checkers.js +1 -1
  140. package/dist/queries/deep-chains.d.ts +2 -2
  141. package/dist/queries/deep-chains.js +1 -1
  142. package/dist/queries/deps.d.ts +2 -2
  143. package/dist/queries/deps.js +1 -1
  144. package/dist/queries/diff-gate.d.ts +3 -3
  145. package/dist/queries/diff-gate.js +1 -1
  146. package/dist/queries/diff-impact.d.ts +4 -8
  147. package/dist/queries/diff-impact.js +1 -1
  148. package/dist/queries/doc-drift.d.ts +3 -3
  149. package/dist/queries/doc-drift.js +1 -1
  150. package/dist/queries/drift.d.ts +2 -2
  151. package/dist/queries/drift.js +1 -1
  152. package/dist/queries/duplicate-bodies.d.ts +2 -2
  153. package/dist/queries/duplicate-bodies.js +1 -1
  154. package/dist/queries/extract-candidates.d.ts +2 -2
  155. package/dist/queries/extract-candidates.js +1 -1
  156. package/dist/queries/fan.d.ts +2 -2
  157. package/dist/queries/fan.js +1 -1
  158. package/dist/queries/files.d.ts +2 -2
  159. package/dist/queries/health.d.ts +3 -3
  160. package/dist/queries/health.js +1 -1
  161. package/dist/queries/hierarchy.d.ts +2 -2
  162. package/dist/queries/hierarchy.js +1 -1
  163. package/dist/queries/hotspots.d.ts +2 -2
  164. package/dist/queries/hotspots.js +1 -1
  165. package/dist/queries/imports.d.ts +2 -2
  166. package/dist/queries/imports.js +1 -1
  167. package/dist/queries/incomplete-migration.d.ts +3 -2
  168. package/dist/queries/incomplete-migration.js +1 -1
  169. package/dist/queries/index.d.ts +21 -5
  170. package/dist/queries/index.js +1 -1
  171. package/dist/queries/isolated.d.ts +2 -2
  172. package/dist/queries/isolated.js +1 -1
  173. package/dist/queries/locality-candidates.d.ts +2 -2
  174. package/dist/queries/locality-candidates.js +1 -1
  175. package/dist/queries/members.d.ts +2 -2
  176. package/dist/queries/members.js +1 -1
  177. package/dist/queries/methods.d.ts +2 -2
  178. package/dist/queries/methods.js +1 -1
  179. package/dist/queries/not-implemented.d.ts +2 -2
  180. package/dist/queries/not-implemented.js +1 -1
  181. package/dist/queries/outline.d.ts +2 -2
  182. package/dist/queries/outline.js +1 -1
  183. package/dist/queries/passthrough-candidates.d.ts +2 -2
  184. package/dist/queries/passthrough-candidates.js +1 -1
  185. package/dist/queries/plan-context.d.ts +2 -2
  186. package/dist/queries/plan-context.js +1 -1
  187. package/dist/queries/react-component-duplicates.d.ts +2 -2
  188. package/dist/queries/react-component-duplicates.js +1 -1
  189. package/dist/queries/react-hook-candidates.d.ts +2 -2
  190. package/dist/queries/react-hook-candidates.js +1 -1
  191. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  192. package/dist/queries/react-large-component-pressure.js +1 -1
  193. package/dist/queries/recent-duplicates.d.ts +2 -2
  194. package/dist/queries/recent-duplicates.js +1 -1
  195. package/dist/queries/redundant-reexports.d.ts +2 -2
  196. package/dist/queries/redundant-reexports.js +1 -1
  197. package/dist/queries/refs.d.ts +2 -2
  198. package/dist/queries/refs.js +1 -1
  199. package/dist/queries/self-audit.d.ts +2 -2
  200. package/dist/queries/self-audit.js +1 -1
  201. package/dist/queries/similar-chains.d.ts +2 -2
  202. package/dist/queries/similar-chains.js +1 -1
  203. package/dist/queries/similar-files.d.ts +2 -2
  204. package/dist/queries/similar-files.js +1 -1
  205. package/dist/queries/similar-signatures.d.ts +2 -2
  206. package/dist/queries/similar-signatures.js +1 -1
  207. package/dist/queries/similar.d.ts +2 -2
  208. package/dist/queries/similar.js +1 -1
  209. package/dist/queries/slice.d.ts +2 -2
  210. package/dist/queries/slice.js +1 -1
  211. package/dist/queries/stale-abstractions.d.ts +2 -2
  212. package/dist/queries/stale-abstractions.js +1 -1
  213. package/dist/queries/stats.d.ts +2 -2
  214. package/dist/queries/surface.d.ts +2 -2
  215. package/dist/queries/surface.js +1 -1
  216. package/dist/queries/symbols.d.ts +2 -2
  217. package/dist/queries/symbols.js +1 -1
  218. package/dist/queries/system.d.ts +2 -2
  219. package/dist/queries/system.js +1 -1
  220. package/dist/queries/test-quality.d.ts +2 -2
  221. package/dist/queries/test-quality.js +1 -1
  222. package/dist/queries/trace.d.ts +2 -2
  223. package/dist/queries/trace.js +1 -1
  224. package/dist/queries/twin-ab.d.ts +2 -2
  225. package/dist/queries/twin-ab.js +1 -1
  226. package/dist/queries/twin-drift.d.ts +2 -2
  227. package/dist/queries/twin-drift.js +1 -1
  228. package/dist/queries/unused-imports.d.ts +2 -2
  229. package/dist/queries/unused-imports.js +1 -1
  230. package/dist/queries/unused-params.d.ts +2 -2
  231. package/dist/queries/unused-params.js +1 -1
  232. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  233. package/dist/queries/vue-component-duplicates.js +1 -1
  234. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  235. package/dist/queries/vue-composable-candidates.js +1 -1
  236. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  237. package/dist/queries/vue-large-view-pressure.js +1 -1
  238. package/dist/queries/wrapper-candidates.d.ts +2 -2
  239. package/dist/queries/wrapper-candidates.js +1 -1
  240. package/dist/reindex-worker.js +7 -7
  241. package/dist/reindex.d.ts +3 -3
  242. package/dist/reindex.js +1 -1
  243. package/dist/runtime.d.ts +3 -3
  244. package/dist/runtime.js +2 -2
  245. package/dist/rust-semantic-session-worker.js +1 -1
  246. package/dist/rust-semantic-worker.js +1 -1
  247. package/dist/{scip-cli-1bVKJgXi.d.ts → scip-cli-kRpaexVJ.d.ts} +1 -1
  248. package/dist/watch-server.js +4 -4
  249. package/docs/AI_FAILURE_MODES.md +1 -1
  250. package/docs/COMMAND_REFERENCE.md +1 -1
  251. package/docs/DETECTOR_GUIDE.md +1 -1
  252. package/docs/analyzer-inventory.md +1 -1
  253. package/docs/analyzer-validation-ledger.md +131 -1
  254. package/docs/architecture-coherence-vision.md +29 -0
  255. package/package.json +2 -2
  256. package/dist/chunk-26JI77AY.js +0 -927
  257. package/dist/chunk-2E7QY4B5.js +0 -7
  258. package/dist/chunk-33RLKB6L.js +0 -4
  259. package/dist/chunk-DO775SYA.js +0 -2
  260. package/dist/chunk-HCSTQGQE.js +0 -4
  261. package/dist/chunk-NLNZK7RL.js +0 -5
  262. package/dist/chunk-OAM22BCR.js +0 -2
  263. package/dist/chunk-PLDIXTKR.js +0 -38
  264. package/dist/chunk-UJKZQLDB.js +0 -2
  265. package/dist/chunk-WFWQWQK6.js +0 -3
  266. package/dist/chunk-XAMVIPE2.js +0 -29
  267. package/dist/diff-gate-types-CG2YQ_ei.d.ts +0 -4
  268. package/dist/direct-navigation-TT23TDBS.js +0 -3
@@ -1,7 +0,0 @@
1
- import{a as j}from"./chunk-J5XJWCB3.js";import{a as N,b as g,c as R}from"./chunk-XYNWAZ6J.js";import{a as _}from"./chunk-FBUNGRKI.js";import{a as P}from"./chunk-OAM22BCR.js";import{a as E}from"./chunk-B75HZHUP.js";import{a as k}from"./chunk-BGBBVSH4.js";import{h as C}from"./chunk-PLDIXTKR.js";import{a as w}from"./chunk-YGBHQOB2.js";import{d,e as y,k as v,z as L}from"./chunk-AYRHVJXW.js";import{i as S}from"./chunk-GAE7WCBK.js";import{s as x}from"./chunk-FC5K7T35.js";import{basename as m,extname as b}from"path";function ae(t,n){let{scope:e,maxLoc:i=15,limit:a=30,scanLimit:o}=n??{},r=new P(t),s=z(r.fileDependencyGraph(e));return _({candidates:()=>B(t,r,e,i),orderCandidates:E,scanLimit:o,profile:{name:"wrapper-candidates"},prepare:l=>({callerFileMap:A(t,r,l,{semantic:n?.semantic!==!1}),reverseFanIn:s}),evaluate:(l,u)=>O(t,r,l,u),orderResults:(l,u)=>u.callerFanIn-l.callerFanIn||u.loc-l.loc,limit:a})}function A(t,n,e,i){let a=N(t,n),o=g(a.forDefinitions(e,{semantic:!1,sourceFallback:!1})),r=[];i.semantic&&x("wrapper.semantic-candidates",()=>{r=e.filter(c=>F(t,n,c,o).length<=1)},()=>({symbols:e.length,semanticCandidates:r.length}));let s=r.length===0?new Map:g(a.forDefinitions(r,{semantic:!0,sourceFallback:!1})),l=s.size===0?o:C(o,s),u=new Map(e.map(c=>[c.symbolId,c])),f=new Map;for(let c of e){let I=F(t,n,c,l);if(I.length>1||(f.set(c.symbolId,c),I.length!==1))continue;let D=I[0],M=T(t,c.symbolId,D);if(!M)continue;let p=W(n,t,D,c.symbol,M);p?.isFunctionLike&&u.has(p.symbolId)&&f.set(p.symbolId,u.get(p.symbolId))}let h=[...f.values()];return h.length===0?l:C(l,g(a.forDefinitions(h,{semantic:!1,sourceFallback:!0})))}function O(t,n,e,i){let a=F(t,n,e,i.callerFileMap);if(a.length!==1)return null;let o=a[0],r=T(t,e.symbolId,o);if(!r)return null;let s=W(n,t,o,e.symbol,r);if(s&&v(s.symbol))return null;let{fanIn:l,source:u}=J(i.callerFileMap,i.reverseFanIn,o,s);if(u==="function"?l<=3:l<=5)return null;let f=H(t,e,o,s);return{symbol:e.symbol,shortName:d(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:k(e),singleCaller:s?.symbol??"",singleCallerShort:s?.isFunctionLike?d(s.symbol):m(o),callerFanIn:l,actionTier:f.length>0?"signal":"direct",boundaryEvidence:f}}function B(t,n,e,i){return n.productionCallableDefinitions({scope:e,minLoc:2,maxLoc:i,requireFunctionLikeSymbol:!0,excludeRootedSymbols:!0,excludeRustTraitImplMembers:!0}).filter(a=>!S(t,a))}function F(t,n,e,i){let a=m(e.relativePath,b(e.relativePath)),o=[...i.get(e.symbolId)??[]].filter(r=>r!==e.relativePath).filter(r=>m(r,b(r))!==a).filter(r=>{let s=n.fileKind(r);return s!=="barrel"&&s!=="entry"&&s!=="test"});return R(t,e,o).realConsumers}function T(t,n,e){return t.get(`SELECT c.start_line, c.end_line
2
- FROM mentions m
3
- JOIN chunks c ON m.chunk_id = c.id
4
- JOIN documents d ON c.document_id = d.id
5
- WHERE m.symbol_id = ? AND m.role != 1 AND d.relative_path = ?
6
- LIMIT 1`,n,e)}function W(t,n,e,i,a){let o=t.definitionsForFile(e),r=q(n,e,i,a.start_line,a.end_line);return L(o,r)}function J(t,n,e,i){if(i?.isFunctionLike){let a=[...t.get(i.symbolId)??[]].filter(o=>o!==i.relativePath);if(a.length>0)return{fanIn:a.length,source:"function"}}return{fanIn:G(n,e),source:"file"}}function q(t,n,e,i,a){let o=y(e);if(!o)return i;let r=w(t,n).get(o);if(!r||r.length===0)return i;for(let s of r)if(s>=i&&s<=a)return s;return i}function z(t){let n=new Map;for(let[e,i]of t){n.has(e)||n.set(e,n.get(e)??0);for(let a of i)n.set(a,(n.get(a)??0)+1)}return n}function G(t,n){let e=t.get(n)??0;if(e>0)return e;let i=m(n,b(n)),a=0;for(let[o,r]of t)o!==n&&m(o,b(o))===i&&r>a&&(a=r);return a}function H(t,n,e,i){return j(t,n.relativePath,n.startLine,"wrapper","explicit ignore-wrapper comment",[{label:"wrapper name",value:d(n.symbol)},{label:"caller name",value:i?.symbol?d(i.symbol):m(e)},{label:"wrapper path",value:n.relativePath},{label:"caller path",value:e}])}export{ae as a};
7
- //# sourceMappingURL=chunk-2E7QY4B5.js.map
@@ -1,4 +0,0 @@
1
- import{a as M}from"./chunk-FBUNGRKI.js";import{c as C}from"./chunk-QNO3QIMN.js";import{a as I}from"./chunk-OAM22BCR.js";import{h as f}from"./chunk-PLDIXTKR.js";import{f as d}from"./chunk-XAMVIPE2.js";import{d as h}from"./chunk-MTDBHTSF.js";import{d as g}from"./chunk-AYRHVJXW.js";import{f as y}from"./chunk-GAE7WCBK.js";var x=new Set(h());function N(e,n){let{scope:o,minLoc:r=10,limit:i=30,scanLimit:t}=n??{},s=new I(e);return M({candidates:()=>s.productionCallableDefinitions({scope:o,minLoc:r,requireFunctionLikeSymbol:!0,includeSuppressed:!0,sortByLocDesc:typeof t=="number"&&t>0}),scanLimit:t,filterCandidate:S,profile:{name:"complexity-hotspots"},prepare:a=>{let l=B(e,a),m=n?.semantic!==!1,c=m?d(e):null;c?.materializeReferences(a,{prefetchCallees:!0});let u=s.crossFileCallerMap(a,{semantic:!1});return{callerMap:c?f(u,c.callerMap(a)):u,calleeMap:s.calleeMap(a,{semantic:m}),languageByFile:l,clojureCallableIds:D(e,a,l),branchEstimates:C(e,a)}},evaluate:(a,l)=>L(a,l,r),orderResults:(a,l)=>l.score-a.score||l.loc-a.loc,limit:i})}function S(e){return e.symbol.startsWith("rust-analyzer ")?typeof e.kind=="number"&&x.has(e.kind):!0}function L(e,n,o){if(n.languageByFile.get(e.relativePath)==="clojure"&&!n.clojureCallableIds.has(e.symbolId))return null;let r=e.endLine-e.startLine+1;if(r<o)return null;let i=n.callerMap.get(e.symbolId)?.size??0,t=n.calleeMap.get(e.symbolId)??[],s=new Set,a=new Set;for(let p of t){let b=`${p.symbol}|${p.file}`;s.add(b),p.file!==e.relativePath&&a.add(b)}let l=a.size,m=s.size,c=n.branchEstimates.get(e.symbolId)??{branches:0,estimateBasis:"regex-fallback"},u=c.branches+1;return{symbol:e.symbol,shortName:g(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:r,fanIn:i,fanOut:l,calleeCount:m,branches:c.branches,estimateBasis:c.estimateBasis,score:Math.round(r/50*(i/5)*Math.max(l/5,1)*Math.max(u/5,1)*100)/100}}function B(e,n){let o=[...new Set(n.map(t=>t.relativePath))];if(o.length===0)return new Map;let r=o.map(()=>"?").join(", "),i=e.all(`SELECT relative_path, language
2
- FROM documents
3
- WHERE relative_path IN (${r})`,...o);return new Map(i.map(t=>[t.relative_path,t.language?.toLowerCase()??null]))}function D(e,n,o){let r=new Set,i=new Map;for(let t of n){if(o.get(t.relativePath)!=="clojure")continue;let s=i.get(t.relativePath);s||(s=new Set((y(e,t.relativePath)?.callables??[]).map(a=>`${a.name}:${a.startLine}`)),i.set(t.relativePath,s)),s.has(`${t.leaf}:${t.startLine}`)&&r.add(t.symbolId)}return r}export{N as a};
4
- //# sourceMappingURL=chunk-33RLKB6L.js.map
@@ -1,2 +0,0 @@
1
- import{a as B}from"./chunk-QZ4JVECJ.js";import{a as R}from"./chunk-35NLDRZC.js";import{a as P}from"./chunk-AOSFSYEA.js";import{a as w}from"./chunk-64MNV6AB.js";var h="architecture:";function D(r,o,t){let i=M(r,o);if(!t||t.boundaries.length===0)return{configured:!1,boundaries:[],edges:[],forbiddenEdges:[],reciprocalPairs:[],cycles:[],coverage:{totalFiles:i.length,mappedFiles:0,unmappedFiles:[],ambiguousFiles:[]},policyCoverage:{declaredRows:0,totalBoundaries:0,missingRows:[],requiresCompletePolicy:!1}};let n=new Map,l=new Map(t.boundaries.map(e=>[e.name,new Set])),m=[],a=[];for(let e of i){let s=t.boundaries.filter(c=>c.paths.some(p=>B(p,e))).map(c=>c.name).sort();if(s.length===0)m.push(e);else if(s.length>1)a.push({file:e,boundaries:s});else{let c=s[0];n.set(e,c),l.get(c).add(e)}}let f=new Map;for(let[e,s]of r){let c=n.get(e);if(c)for(let p of s){let g=n.get(p);if(!g||c===g)continue;let F=y(c,g),d=f.get(F);d||(d={from:c,to:g,fileEdges:[],importers:new Set,importedFiles:new Set},f.set(F,d)),d.fileEdges.push({fromFile:e,toFile:p}),d.importers.add(e),d.importedFiles.add(p)}}let u=[...f.values()].map(e=>j(e,t)).sort(q),S=new Map(u.map(e=>[y(e.from,e.to),e])),b=new Map(t.boundaries.map(e=>[e.name,new Set]));for(let e of u)b.get(e.from).add(e.to);let A=[];for(let e of u){if(e.from>=e.to)continue;let s=S.get(y(e.to,e.from));s&&A.push({boundaries:[e.from,e.to],forward:e,reverse:s})}let{components:v}=R(b),x=v.filter(e=>e.length>1).map(e=>$(e,u,t.requireAcyclic===!0)).sort((e,s)=>s.boundaries.length-e.boundaries.length||e.boundaries.join("/").localeCompare(s.boundaries.join("/"))),C=t.allowedDependencies??{},E=t.boundaries.map(e=>e.name).filter(e=>!Object.hasOwn(C,e)).sort();return{configured:!0,boundaries:t.boundaries.map(e=>({name:e.name,paths:[...e.paths],fileCount:l.get(e.name).size,dependencyPolicyDeclared:Object.hasOwn(C,e.name)})).sort((e,s)=>e.name.localeCompare(s.name)),edges:u,forbiddenEdges:u.filter(e=>e.policyStatus==="forbidden"),reciprocalPairs:A,cycles:x,coverage:{totalFiles:i.length,mappedFiles:n.size,unmappedFiles:m,ambiguousFiles:a},policyCoverage:{declaredRows:t.boundaries.length-E.length,totalBoundaries:t.boundaries.length,missingRows:E,requiresCompletePolicy:t.requireCompletePolicy===!0}}}function k(r,o={}){let t=P(r,o.scope,{scipEdges:"imports-only",sourceEdges:"imports-and-reexports"}),i=w(r,{includeIgnored:!1}).filter(n=>!o.scope||n.includes(o.scope));return D(t,i,r.config.architecture)}function K(r){let o=r.forbiddenEdges.map(t=>`${h}forbidden-edge:${encodeURIComponent(t.from)}:${encodeURIComponent(t.to)}`);if(r.policyCoverage.requiresCompletePolicy)for(let t of r.policyCoverage.missingRows)o.push(`${h}missing-policy-row:${encodeURIComponent(t)}`);for(let t of r.cycles)t.violatesPolicy&&o.push(`${h}cycle:${t.boundaries.map(i=>encodeURIComponent(i)).sort().join("|")}`);return[...new Set(o)].sort()}function T(r){return!!r&&(Object.keys(r.allowedDependencies??{}).length>0||r.requireCompletePolicy===!0||r.requireAcyclic===!0)}function M(r,o){let t=new Set(o);for(let[i,n]of r){t.add(i);for(let l of n)t.add(l)}return[...t].sort()}function j(r,o){let t=[...r.fileEdges].sort((i,n)=>i.fromFile.localeCompare(n.fromFile)||i.toFile.localeCompare(n.toFile));return{from:r.from,to:r.to,policyStatus:I(o,r.from,r.to),fileEdgeCount:t.length,importerCount:r.importers.size,importedFileCount:r.importedFiles.size,examples:t.slice(0,5)}}function I(r,o,t){return!r.allowedDependencies||!Object.hasOwn(r.allowedDependencies,o)?"undeclared":r.allowedDependencies[o].includes(t)?"allowed":"forbidden"}function $(r,o,t){let i=[...r].sort(),n=new Set(i),l=o.filter(a=>n.has(a.from)&&n.has(a.to)),m=Math.min(...l.map(a=>a.fileEdgeCount));return{boundaries:i,internalEdges:l,narrowestEdges:l.filter(a=>a.fileEdgeCount===m),violatesPolicy:t}}function y(r,o){return`${r}\0${o}`}function q(r,o){return r.from.localeCompare(o.from)||r.to.localeCompare(o.to)}export{h as a,D as b,k as c,K as d,T as e};
2
- //# sourceMappingURL=chunk-DO775SYA.js.map
@@ -1,4 +0,0 @@
1
- import{a as D,b as v,c as $,d as B}from"./chunk-XYNWAZ6J.js";import{a as K}from"./chunk-FBUNGRKI.js";import{a as A}from"./chunk-OAM22BCR.js";import{b as M,g as R}from"./chunk-CAKPEQZB.js";import{a as g}from"./chunk-BGBBVSH4.js";import{h as I}from"./chunk-PLDIXTKR.js";import{b as k,d as F,e as b}from"./chunk-AYRHVJXW.js";import{l as w}from"./chunk-GAE7WCBK.js";import{y as C}from"./chunk-FC5K7T35.js";function de(t,e){let{scope:n,minLoc:i=3,maxLoc:s=80,limit:r=30,includeLowConfidence:l=!1,scanLimit:o}=e??{},d=e?.semantic!==!1,a=new A(t),m=a.scopedDefinitions(n),y=Q(a,n),p={high:0,medium:1,low:2};return K({candidates:()=>O(t,a,m,{minLoc:i,maxLoc:s}),orderCandidates:(u,c)=>g(c)-g(u)||u.relativePath.localeCompare(c.relativePath),scanLimit:o,profile:{name:"stale-abstractions"},prepare:u=>{let c=U(u),f=W(t,a,u,c,{semantic:d}),h=u.filter(P=>{let x=S(t,P,f,c);return x.realConsumers.length<=1&&!x.transitivelyReachable&&j(P,x.realConsumers.length,y)});return{consumerFileMap:f,singletonBackedClassIds:H(t,a,m,h,{semantic:d}),candidateIndex:c}},evaluate:(u,c)=>{if(c.singletonBackedClassIds.has(u.symbolId))return null;let f=S(t,u,c.consumerFileMap,c.candidateIndex);if(f.transitivelyReachable||f.realConsumers.length>1||f.realConsumers.length===0&&f.barrelConsumers>0||!j(f.definition,f.realConsumers.length,y))return null;let h=V(t,f);return!l&&h.confidence==="low"?null:h},orderResults:(u,c)=>p[u.confidence]-p[c.confidence]||c.loc-u.loc||u.file.localeCompare(c.file)||u.startLine-c.startLine,limit:r})}function O(t,e,n,i){return n.filter(s=>s.isTypeLike&&g(s)>=i.minLoc).filter(s=>g(s)<=i.maxLoc).filter(s=>!t.isIgnored(s.relativePath)).filter(s=>!s.relativePath.endsWith(".d.ts")).filter(s=>M(s.relativePath)!=="test").filter(s=>!R(t,s.symbol,s.relativePath)).filter(s=>!X(s.symbol)).filter(s=>!e.hasSuppressionComment(s))}function L(t,e,n,i){return v(D(t,e).forDefinitions(n,{semantic:i.semantic,sourceFallback:i.sourceFallback}))}function W(t,e,n,i,s){let r=L(t,e,n,{semantic:!1,sourceFallback:!1}),l=n.filter(a=>{let m=S(t,a,r,i);return m.realConsumers.length<=1&&!(m.realConsumers.length>0&&T(a.relativePath))}),o=s.semantic&&l.length>0?I(r,L(t,e,l,{semantic:!0,sourceFallback:!1})):r,d=l.filter(a=>S(t,a,o,i).realConsumers.length<=1);return I(o,L(t,e,d,{semantic:!1,sourceFallback:!0}))}function U(t){let e=new Map;for(let n of t){let i=e.get(n.relativePath);i||(i=new Map,e.set(n.relativePath,i));let s=b(n.symbol);s&&i.set(s,n)}return e}function S(t,e,n,i){let r=[...n.get(e.symbolId)??new Set].filter(m=>m!==e.relativePath&&!t.isIgnored(m)),{realConsumers:l,barrelConsumers:o,importOnlyConsumers:d}=$(t,e,r),a=Y(t,e,n,i);return{definition:e,realConsumers:l,barrelConsumers:o+d,transitivelyReachable:a}}function V(t,e){let n=E(t,e.definition.relativePath,e.definition.startLine),i=T(e.definition.relativePath)?!0:ee(t,e.definition),{confidence:s,reason:r}=ne(e.realConsumers.length,n,i),l=z(e.realConsumers.length,n,i);return{symbol:e.definition.symbol,shortName:F(e.definition.symbol),file:e.definition.relativePath,startLine:e.definition.startLine,endLine:e.definition.endLine,loc:g(e.definition),consumers:e.realConsumers.length,barrelConsumers:e.barrelConsumers,kind:n,definerUsesType:i,confidence:s,reason:r,actionTier:l.actionTier,stalenessKind:l.stalenessKind,recommendation:l.recommendation}}function z(t,e,n){return t===0?{actionTier:"direct",stalenessKind:"unused-abstraction",recommendation:"Delete the abstraction or wire the missing consumer after checking public/package surfaces."}:e==="class"?{actionTier:"signal",stalenessKind:"one-to-one-class-encapsulation",recommendation:"Treat as weak signal: a one-consumer class may be intentional encapsulation, so inline only after reviewing ownership and state boundaries."}:n?{actionTier:"signal",stalenessKind:"single-consumer-abstraction",recommendation:"Review whether this single-consumer abstraction earns its name or should be folded into the owning feature."}:{actionTier:"signal",stalenessKind:"misplaced-single-consumer-type",recommendation:"Review moving or co-locating the type with its only real consumer; keep it here only if this file owns the public contract."}}function H(t,e,n,i,s){let r=_(t,Z(n),i),l=r.map(a=>a.singleton);if(r.length===0)return new Set;let o=v(D(t,e).forDefinitions(l,{semantic:s.semantic,sourceFallback:!0})),d=new Set;for(let{singleton:a,classId:m}of r)G(t,a,o)&&d.add(m);return d}function Z(t){let e=new Map;for(let n of t){let i=b(n.symbol);i&&e.set(N(n.relativePath,i),n)}return e}function _(t,e,n){let i=[];for(let s of n){let r=q(t,e,s);r&&i.push({singleton:r,classId:s.symbolId})}return i}function q(t,e,n){if(E(t,n.relativePath,n.startLine)!=="class")return null;let i=b(n.symbol);if(!i)return null;let s=J(t,n.relativePath,i);return s?e.get(N(n.relativePath,s))??null:null}function G(t,e,n){let i=b(e.symbol),s=n.get(e.symbolId);return!i||!s?!1:[...s].some(r=>r!==e.relativePath&&!t.isIgnored(r)&&!B(t,r,i))}function N(t,e){return`${t}\0${e}`}function J(t,e,n){let i=C(t,e);if(!i)return null;let s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`\\bexport\\s+const\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*new\\s+${s}\\s*\\(`);return i.match(r)?.[1]??null}function Q(t,e){return new Set(t.scopedDefinitions(e).filter(n=>n.isFunctionLike).map(n=>n.relativePath))}function X(t){let e=k(t);if("kind"in e)return!1;let n=e.descriptors;if(n.length<2)return!1;let i=n[n.length-1],s=n[n.length-2];return i?.suffix==="type"&&s?.suffix==="type"}function T(t){let n=(t.split("/").pop()??"").replace(/\.[^.]+$/,"");return!!(n==="types"||n.endsWith("-types")||n==="models"||n==="schema"||n==="common"||n==="protocol"||n==="proto"||n==="dto"||n==="mod"||n==="contracts"||/(^|\/)types(\/|\.)/.test(t)||/(^|\/)models?(\/|\.)/.test(t)||/(^|\/)proto(?:col)?(\/|\.)/.test(t)||/(^|\/)schema(\/|\.)/.test(t)||/(^|\/)contracts?(\/|\.)/.test(t))}function j(t,e,n){return!(T(t.relativePath)&&e>0||e===0&&n.has(t.relativePath))}function Y(t,e,n,i){let s=w(t,e.relativePath),r=b(e.symbol);if(!r)return!1;let l=i.get(e.relativePath);if(!l)return!1;let o=[...s.get(r)??[]],d=new Set;for(;o.length>0;){let a=o.pop();if(d.has(a))continue;d.add(a);let m=l.get(a);if(!m)continue;let y=n.get(m.symbolId);if(y){for(let p of y)if(p!==e.relativePath&&!t.isIgnored(p))return!0}for(let p of s.get(a)??[])o.push(p)}return!1}function E(t,e,n){let i=C(t,e);if(!i)return"other";let s=i.split(`
2
- `),r=Math.max(0,n-2),l=Math.min(s.length-1,n+2);for(let o=r;o<=l;o++){let a=(s[o]??"").replace(/^\s*\/\/.*$/g,"");if(/\b(?:export\s+)?(?:abstract\s+)?class\s+\w/.test(a))return"class";if(/\b(?:export\s+)?interface\s+\w/.test(a))return"interface";if(/\b(?:export\s+)?type\s+\w/.test(a))return"type";if(/\b(?:export\s+)?(?:const\s+)?enum\s+\w/.test(a))return"enum"}return"other"}function ee(t,e){let n=C(t,e.relativePath);if(!n)return!1;let i=b(e.symbol);if(!i)return!1;let s=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`\\b${s}\\b`),l=n.split(`
3
- `);for(let o=0;o<l.length;o++)if(!(o>=e.startLine&&o<=e.endLine)&&r.test(l[o]??""))return!0;return!1}function ne(t,e,n){return t===0?{confidence:"high",reason:"unused \u2014 no consumers and defining file has no real usage"}:t===1&&e==="class"?{confidence:"low",reason:"1 consumer + class kind \u2014 likely 1:1 encapsulation, not over-abstraction"}:t===1&&!n?{confidence:"high",reason:"1 consumer + defining file never uses it \u2014 type belongs with its consumer"}:{confidence:"medium",reason:"1 consumer \u2014 single-use abstraction"}}export{de as a};
4
- //# sourceMappingURL=chunk-HCSTQGQE.js.map
@@ -1,5 +0,0 @@
1
- import{a as G}from"./chunk-P5XHIJHI.js";import{a as Qe,c as nn,g as rn}from"./chunk-LM72NQ7T.js";import{a as ye}from"./chunk-AOSFSYEA.js";import{b as en,e as $,f as ge,h as tn,j as re,s as q,t as Se}from"./chunk-AYRHVJXW.js";import{a as Yt,f as me,n as Xt,p as Zt}from"./chunk-GAE7WCBK.js";import{B as Gt,E as Qt,e as $t,f as Ht,s as Ge}from"./chunk-WAU7HVDI.js";import{a as Wt,c as qt,d as zt,g as Ye,q as W,r as Kt,s as C,u as de,v as Vt,x as Jt}from"./chunk-FC5K7T35.js";import{a as Y}from"./chunk-64MNV6AB.js";import{execFileSync as on}from"child_process";import{existsSync as Xe,readFileSync as Hr}from"fs";import{createRequire as Kr}from"module";import{platform as an}from"os";import{dirname as sn,join as Re}from"path";var Vr=Kr(import.meta.url),cn={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function Ze(t){return[t.indexerBinary,...t.binaryAliases??[]]}function Jr(t){let e=Ze(t);return e.length===1?e[0]:e.join(" or ")}function et(t){for(let e of Ze(t))if(an()==="win32"){let n=nn(e);if(n)return n}else if(Qe(e))return e;return Gr(t)}function oa(t){return et(t)!==null||Yr(t)}function Yr(t){return ln(t)!==null}function Gr(t){let e=ln(t);if(!e)return null;let r=JSON.parse(Hr(e,"utf8")).bin;if(!r)return null;if(typeof r=="string")return Re(sn(e),r);for(let i of Ze(t)){let s=r[i];if(s)return Re(sn(e),s)}return null}function ln(t){if(!t.bundledNpmPackage)return null;try{return Vr.resolve(`${t.bundledNpmPackage}/package.json`)}catch{return null}}function Qr(t,e){for(let n of t.projectLocalBinaries??[]){let r=Re(e,n);if(Xe(r))return r}return null}function Xr(t,e){return Qr(t,e)??et(t)}function aa(t,e=process.env,n=t.indexerBinary){if(t.indexerBinary!=="scip-dotnet"||tt(n,e))return e;let r=pn(n,e);return r?{...e,DOTNET_ROOT:r}:e}function un(t,e){let n=Jr(t),r=e?Xr(t,e):et(t);if(!r)return{language:t.language,binaryLabel:n,installed:!1,runnable:!1,resolvedBinary:null,installUrl:t.installUrl};if(t.indexerBinary!=="scip-dotnet")return{language:t.language,binaryLabel:n,installed:!0,runnable:!0,resolvedBinary:r};let i=Zr(r);return{language:t.language,binaryLabel:n,installed:!0,runnable:i.runnable,resolvedBinary:r,installUrl:t.installUrl,note:i.note}}function Zr(t){if(tt(t,process.env))return{runnable:!0};let e=pn(t,process.env);if(e)return{runnable:!0,note:`using .NET 9 runtime from ${e}`};let n=fn(process.env);return{runnable:!1,note:n.length>0?`.NET 9 runtime still unavailable after checking ${n.join(", ")}`:"binary is present, but scip-dotnet still needs a .NET 9 runtime"}}function pn(t,e){for(let n of fn(e))if(tt(t,{...e,DOTNET_ROOT:n}))return n;return null}function fn(t){let e=[],n=t.DOTNET_ROOT;if(n&&Xe(n)&&e.push(n),an()==="darwin"&&Qe("brew"))try{let r=on("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:t}).toString().trim(),i=Re(r,"libexec");Xe(i)&&!e.includes(i)&&e.push(i)}catch{}return e}function tt(t,e){try{return on(t,["--version"],{stdio:"pipe",env:e}),!0}catch{return!1}}function he(t){try{return process.kill(t,0),!0}catch(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EPERM"}}import{mkdirSync as ei,renameSync as ti,writeFileSync as ni}from"fs";import{dirname as ri}from"path";function be(t,e,n={}){ei(ri(t),{recursive:!0});let r=`${t}.${process.pid}.${Date.now()}.tmp`,i=JSON.stringify(e,null,n.spacing);ni(r,n.trailingNewline?`${i}
2
- `:i),ti(r,t)}function nt(t,e){let n=t.split("/").at(-1)??t;if(Rn.has(n)||n===".scipquery.json"||/^tsconfig(?:\..+)?\.json$/.test(n))return"config";if(/\.d\.(?:ts|mts|cts)$/.test(t.toLowerCase()))return"ambient";let r=t.includes(".")?`.${t.split(".").at(-1).toLowerCase()}`:"";return e.some(i=>(hn[i]??[]).includes(r))?"source":"other"}function gn(t,e,n){let r=t.split("/").at(-1)??t;if(n?.includes(t)||n?.includes(r)||Rn.has(r))return!0;let i=t.includes(".")?`.${t.split(".").at(-1).toLowerCase()}`:"";return(hn[e]??[]).includes(i)}function Sn(t){if(typeof t!="object"||t===null)return null;let e=t;return typeof e.version!="number"||!dn(e.languages)||typeof e.pnpmWorkspaces!="boolean"||typeof e.typescriptProjectMode!="string"||!dn(e.typescriptProjects)||e.clojureConfigPath!==void 0&&typeof e.clojureConfigPath!="string"||!Array.isArray(e.files)||!e.files.every(ii)?null:e}function da(t,e){let n=new Map((t?.files??[]).map(a=>[a.path,a])),r=new Map(e.files.map(a=>[a.path,a])),i=new Set([...n.keys(),...r.keys()]),s=[];for(let a of[...i].sort()){let c=n.get(a),l=r.get(a),p=nt(a,e.languages);!c&&l?s.push({kind:"added",path:a,inputKind:p,after:l}):c&&!l?s.push({kind:"deleted",path:a,inputKind:p,before:c}):c&&l&&(c.hash!==l.hash||c.size!==l.size)&&s.push({kind:"modified",path:a,inputKind:p,before:c,after:l})}let o=new Set;return t||o.add("prior-snapshot-unavailable"),t&&t.version!==e.version&&o.add("snapshot-version-changed"),(mn(t?.files??[])||mn(e.files))&&o.add("duplicate-input-path"),[...t?.files??[],...e.files].some(si)&&o.add("unreadable-input"),{version:1,changes:s,projectIdentityChanged:t?!oi(t,e):!0,uncertainty:[...o].sort()}}function dn(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function mn(t){return new Set(t.map(e=>e.path)).size!==t.length}function ii(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.path=="string"&&typeof e.size=="number"&&typeof e.hash=="string"}function si(t){return t.hash==="unreadable"||t.size<0}function oi(t,e){return yn(t.languages,e.languages)&&t.pnpmWorkspaces===e.pnpmWorkspaces&&t.typescriptProjectMode===e.typescriptProjectMode&&yn(t.typescriptProjects,e.typescriptProjects)&&t.clojureConfigPath===e.clojureConfigPath}function yn(t,e){if(t.length!==e.length)return!1;let n=[...t].sort(),r=[...e].sort();return n.every((i,s)=>i===r[s])}var Rn=new Set(["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lockb","tsconfig.json","tsconfig.base.json","pyproject.toml","setup.py","setup.cfg","Cargo.toml","Cargo.lock","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","build.sbt","compile_commands.json","CMakeLists.txt","Makefile","Gemfile","Gemfile.lock","composer.json","composer.lock","pubspec.yaml","pubspec.lock","deps.edn","project.clj","bb.edn","shadow-cljs.edn"]),hn={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"],clojure:[".clj",".cljs",".cljc"]};import{execFileSync as ai}from"child_process";import{createHash as bn}from"crypto";import{lstatSync as ci,readdirSync as li,readFileSync as ui,readlinkSync as pi,realpathSync as In}from"fs";import{isAbsolute as fi,join as vn,relative as di,sep as mi}from"path";function yi(t){return[...new Set((t??[]).map(e=>e.trim()).filter(Boolean))].sort((e,n)=>e.localeCompare(n))}function gi(t){return(Ri(t)??hi(t)).filter(e=>e&&!xn(e)).sort()}function rt(t,e={}){let n=gi(t).filter(i=>!e.language||gn(i,e.language,e.markerFiles)).filter(i=>!e.includePath||e.includePath(i)),r=In(t);return n.map(i=>{let s=vn(t,i);try{if(ci(s).isSymbolicLink()){let a=In(s),c=di(r,a);if(c===".."||c.startsWith(`..${mi}`)||fi(c))throw new Error("external symlink");let l=pi(s);return{path:i,size:Buffer.byteLength(l),hash:bn("sha256").update("symlink\0").update(l).digest("hex")}}let o=ui(s);return{path:i,size:o.byteLength,hash:bn("sha256").update(o).digest("hex")}}catch{return{path:i,size:-1,hash:"unreadable"}}})}function ba(t,e,n){return{version:2,languages:[...e].sort(),pnpmWorkspaces:n.typescriptProjectMode!=="workspace"&&n.pnpmWorkspaces===!0,typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:yi(n.typescriptProjects),clojureConfigPath:Si(n.clojureConfigPath),files:rt(t)}}function Si(t){return t?.trim()||void 0}function Ri(t){try{return ai("git",["-C",t,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
3
- `).filter(Boolean)}catch{return null}}function hi(t){let e=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?vn(t,r):t,s;try{s=li(i,{withFileTypes:!0})}catch{continue}for(let o of s){let a=r?`${r}/${o.name}`:o.name;if(o.isDirectory()){xn(a)||n.push(a);continue}e.push(a)}}return e}function xn(t){let e=t.split("/");return t==="meta.json"||e.some(n=>bi.has(n))||t.endsWith(".db")||t.endsWith(".db-wal")||t.endsWith(".db-shm")||t.endsWith(".scip")}var bi=new Set([".git","node_modules",".scipquery-cache",".scipquery-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);function Mn(t){let e=new Map,n=vi(t),r=new Map;return i=>{let s=Ii(i),o=r.get(s);if(o!==void 0)return o;if(!n.has(i.file))return r.set(s,i.symbol),i.symbol;let a=e.get(i.file);a||(a=xi(q(t,i.file)),e.set(i.file,a));let c=Mi(a,i);return r.set(s,c),c}}function Ii(t){return`${t.file}\0${t.symbol}\0${t.line}`}function vi(t){return new Set(t.all("SELECT relative_path FROM documents").map(e=>e.relative_path))}function xi(t){let e=new Map,n=new Map;for(let r of t){let i=e.get(r.leaf);i?i.push(r):e.set(r.leaf,[r]);let s=n.get(r.startLine);s?s.push(r):n.set(r.startLine,[r])}return{definitions:t,byLeaf:e,byStartLine:n}}function Mi(t,e){if(t.definitions.length===0)return e.symbol;let n=Ti(e.symbol),r=Ci(t.byLeaf,n),i=Di(r,e.line);if(i)return i.symbol;let s=t.byStartLine.get(e.line)??[];return s.length===1?s[0].symbol:e.symbol}function Ci(t,e){let n=[],r=new Set;for(let i of e)for(let s of t.get(i)??[])r.has(s.symbolId)||(r.add(s.symbolId),n.push(s));return n}function Di(t,e){let n=null;for(let r of t)if(!(r.startLine>e||r.endLine<e)){if(r.startLine===e)return r;(!n||r.endLine-r.startLine<n.endLine-n.startLine)&&(n=r)}return n}function Ti(t){let e=new Set([t]),r=t.split(/::|\.|#/).filter(Boolean).at(-1);return r&&e.add(r),e}function Cn(t,e){let r=Zt(t,e).map(i=>ki(e,i));return{usage:r,positions:Fi(t,e,r)}}function Dn(t,e){return{importUsage(n){let r=t.importUsageFacts(n);if(!e||r.positions.length===0)return r.usage;let i=e.importDefinitionsForFile(n,r.positions);return i.available?Pi(r.usage,i.sourcePaths):r.usage}}}function Pi(t,e){return t.map((n,r)=>{let i=e.get(String(r));return i?{...n,sourcePath:i}:n})}function ki(t,e){let n=e.isTypeOnly===!0,r=e.kind==="side-effect"||n||e.used;return{importer:t,sourcePath:e.sourcePath,importedName:e.importedName,localName:e.localName,kind:e.kind,isTypeOnly:n,isUsed:r,isTypeUsed:n,isValueUsed:e.kind==="side-effect"||!n&&e.used,references:[]}}function Fi(t,e,n){let r=Qt(t,e);if(!r)return[];let i=wi(r.rootNode),s=new Map;for(let a of i){let c=s.get(st(a.importedName,a.localName));c?c.push(a.position):s.set(st(a.importedName,a.localName),[a.position])}let o=[];return n.forEach((a,c)=>{let l=s.get(st(a.importedName,a.localName??a.importedName))?.shift();l&&o.push({...l,id:String(c),file:e})}),o}function wi(t){let e=[];for(let n of t.descendantsOfType("use_declaration")){let r=n.namedChildren.find(i=>i.type!=="visibility_modifier");r&&e.push(...Ie(r,""))}return e.filter(n=>n.importedName!=="*")}function Ie(t,e){switch(t.type){case"identifier":case"super":case"self":case"crate":return[{importedName:t.text,localName:t.text,position:it(t,t.text)}];case"scoped_identifier":{let n=t.text.split("::").pop()??t.text;return[{importedName:n,localName:n,position:it(t,n)}]}case"scoped_use_list":{let n=t.namedChild(0),r=t.namedChild(1);if(!n||!r)return[];let i=Xt(e,n.text);return r.namedChildren.flatMap(s=>Ie(s,i))}case"use_list":return t.namedChildren.flatMap(n=>Ie(n,e));case"use_as_clause":{let n=t.namedChild(0),r=t.namedChild(1);return!n||!r?[]:Ie(n,e).map(i=>({...i,localName:r.text}))}case"use_wildcard":{let n=t.namedChild(0),r="*";return[{importedName:r,localName:r,position:it(n??t,r)}]}default:return[]}}function it(t,e){let n=Math.max(0,t.text.lastIndexOf(e));return{id:"",file:"",line:t.startPosition.row,column:t.startPosition.column+n+Ei(e)}}function Ei(t){return Math.max(0,Math.min(t.length-1,1))}function st(t,e){return`${t}\0${e}`}import{spawnSync as mt}from"child_process";import{existsSync as yt}from"fs";import{fileURLToPath as vs}from"url";function ve(t){let e=un(cn,t),n=e.runnable;return{available:n,dependencyAvailable:n,resolvedBinary:e.resolvedBinary??void 0,reason:n?"rust-analyzer semantic reference queries are enabled.":"rust-analyzer is not runnable; Rust semantic checks will use SCIP/source evidence only."}}import{existsSync as ss,mkdtempSync as Kn,readFileSync as Vn,rmSync as lt}from"fs";import{tmpdir as Jn}from"os";import{join as ut}from"path";import{fileURLToPath as we,pathToFileURL as os}from"url";import{SHARE_ENV as as,Worker as cs}from"worker_threads";function z(t,e,n=new Set){let r=new Map;for(let i of t)n.has(i.symbolId)||r.set(i.symbolId,e.get(i.symbolId)??[]);return r}function H(t,e,n){let r=G(process.env.SCIP_RUST_SEMANTIC_BATCH_TIMEOUT_MS)??0;if(r>0)return r;let i=Math.max(1,Math.ceil(t/Math.max(1,n)));return Math.max(12e4,3e4+i*e)}import{spawn as Ki}from"child_process";import{createHash as Vi,randomUUID as Ji}from"crypto";import{existsSync as On,mkdirSync as Nn,readFileSync as Pe,realpathSync as Yi,rmSync as ct}from"fs";import{tmpdir as Gi}from"os";import{resolve as _}from"path";import{execFileSync as Wi}from"child_process";import{existsSync as Ni,readFileSync as Ai}from"fs";import{deserializeSCIP as _i,SymbolRole as ji}from"@c4312/scip";import{existsSync as Na,readFileSync as Aa}from"fs";import{relative as ja,resolve as La,sep as Oa}from"path";import{fileURLToPath as Ba,pathToFileURL as Wa}from"url";function Tn(t){let e=new Map;for(let n of t)e.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...e.values()].sort((n,r)=>{let i=n.file.localeCompare(r.file);return i!==0?i:n.line!==r.line?n.line-r.line:n.column-r.column})}var ot=new WeakMap,Li="SCIP_RUST_SCIP_OCCURRENCE_REFERENCE_MODE";function Va(t,e){let n=new Map,r=xe(),i=e.filter(o=>kn(o,r));if(i.length===0)return n;let s=Fn(t);if(!s)return n;for(let o of i){let a=Pn(s,o);a!==null&&n.set(o.symbolId,a)}return n}function Ja(t,e){if(!kn(e,xe()))return null;let n=Fn(t);return n?Pn(n,e):null}function Pn(t,e){return t.referencesBySymbol.get(e.symbol)??[]}function kn(t,e="safe"){if(!t.symbol.startsWith("rust-analyzer ")||!t.relativePath.endsWith(".rs")||re(t.symbol)||/impl#\[[^\]]+\]\[Default\]default\(\)\.$/.test(t.symbol))return!1;if(e==="all")return!0;let n=ge(t.symbol);if(n==="method")return!0;if(n!=="term")return!1;let r=en(t.symbol);return"kind"in r?!1:!Oi(r)}function Oi(t){for(let e=0;e<t.descriptors.length-1;e+=1)if(t.descriptors[e]?.suffix==="type")return!0;return!1}function Fn(t){if(ot.has(t))return ot.get(t)??null;let e=Ui(t);return ot.set(t,e),e}function Ui(t){if(!Ni(t.config.indexPath))return null;try{let e=_i(Ai(t.config.indexPath)),n=new Map;for(let r of e.documents??[]){let i=r.relativePath;if(!(!i||t.isIgnored(i)))for(let s of r.occurrences??[]){if(!s.symbol||(s.symbolRoles&ji.Definition)!==0)continue;let o=Bi(i,s.range);if(!o)continue;let a=n.get(s.symbol)??[];a.push(o),n.set(s.symbol,a)}}for(let[r,i]of n)n.set(r,Tn(i));return{referencesBySymbol:n}}catch{return null}}function Bi(t,e){if(e.length<3)return null;let n=e[0],r=e[1];return!Number.isInteger(n)||!Number.isInteger(r)?null:{file:t,line:n,column:r}}function xe(){return process.env[Li]==="all"?"all":"safe"}var wn=new Map;function at(t){let n=ve(t).resolvedBinary??null;return{engine:"rust-analyzer",resolvedBinary:n,version:n?qi(t,n):"unavailable"}}function Za(t){return{...at(t),scipOccurrenceReferenceMode:xe()}}function qi(t,e){let n=`${t}\0${e}`,r=wn.get(n);if(r)return r;let i;try{i=Wi(e,["--version"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3}).trim()}catch{i="unknown"}return wn.set(n,i),i}import{createHash as zi}from"crypto";var $i=new Set(["Cargo.lock","Cargo.toml","rust-project.json","rust-toolchain","rust-toolchain.toml"]);function En(t){let e=rt(t,{includePath:Hi});return zi("sha256").update(JSON.stringify(e)).digest("hex")}function Hi(t){let e=t.replaceAll("\\","/"),n=e.split("/").at(-1)??e;return e.endsWith(".rs")||$i.has(n)?!0:e===".cargo/config"||e===".cargo/config.toml"||e.endsWith("/.cargo/config")||e.endsWith("/.cargo/config.toml")}var Un=2,Qi=5e3,Xi=5e3,Bn=10,Zi=3e4;function An(t,e,n,r=Hn){let i=r.engineIdentity(t),s={protocolVersion:Un,projectRoot:r.canonicalProjectRoot(t),projectFingerprint:r.projectFingerprint(t),engine:{engine:i.engine,resolvedBinary:i.resolvedBinary,version:i.version},workerFingerprint:r.fileFingerprint(e),environment:qn(r.environment())};return{key:Te(De(s)),...s}}function Me(t,e,n){return t.protocolVersion===Un&&(e-t.heartbeatAtMs<=Qi||t.busyUntilMs!==void 0&&e<=t.busyUntilMs)&&n(t.pid)}function Wn(t,e,n){let r;try{r=Te(Pe(e))}catch{r="missing"}let i=Te(De({projectRoot:_(t),serverPath:_(e),serverFingerprint:r})).slice(0,20);return _(n,`scip-query-rust-session-${i}`)}function _n(t){let e=t===void 0?Number.NaN:Number(t);return Number.isInteger(e)&&e>=0?e:0}function qn(t){return Object.fromEntries(Object.entries(t).filter(([e])=>$n(e)).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>[e,n??null]))}function zn(t,e){let n=e.runtime??is,r=e.identityRuntime??Hn,i=Wn(t,e.serverPath,e.tempRoot??Gi()),s=!1,o=(a,c)=>{if(s)throw new Error("Durable Rust semantic session was already disposed.");return ts(i,e.serverPath,e.semanticWorkerPath,a,c,n)};return{requestSemantic(a,c){let l=An(t,e.semanticWorkerPath,a,r),p=n.now()+Math.max(1,c-1e3);return o({kind:"semantic",identityKey:l.key,workerEnvironment:Ln(),request:{...a,readinessDeadlineMs:p,referenceRetryTimeoutMs:es(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,a.referenceRetryTimeoutMs),settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:_n(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},requestImportDefinitions(a,c){let l=An(t,e.semanticWorkerPath,a,r),p=n.now()+Math.max(1,c-1e3);return o({kind:"import-definitions",identityKey:l.key,workerEnvironment:Ln(),request:{...a,readinessDeadlineMs:p,settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:_n(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},shutdown(){s=!0}}}function es(t,e){return e!==void 0?e:t===void 0?Zi:void 0}function ts(t,e,n,r,i,s){let o=s.randomId(),a=s.now(),c=_(t,"requests"),l=_(t,"responses"),p=_(c,`${o}.json`),u=_(l,`${o}.json`);Nn(c,{recursive:!0}),Nn(l,{recursive:!0}),be(p,{id:o,request:r});let f=s.now()+i;try{for(jn(t,e,n,f,s);s.now()<=f;){if(On(u)){let m=ns(Pe(u,"utf8"));if(!m.ok)throw new Error(m.error);return W()&&de({type:"span",name:"rust.semantic.durable-session.request",durationMs:s.now()-a,ok:!0,session:m.session,kind:r.kind}),m.response}let d=Ce(t);(!d||!Me(d,s.now(),s.isProcessAlive))&&jn(t,e,n,f,s),s.sleep(Bn)}throw new Error(`Durable Rust semantic session timed out after ${(i/1e3).toFixed(0)}s.`)}finally{ct(p,{force:!0}),ct(u,{force:!0})}}function jn(t,e,n,r,i){let s=Ce(t);if(s&&Me(s,i.now(),i.isProcessAlive))return;ct(_(t,"server.json"),{force:!0}),i.spawnServer(e,t,n);let o=Math.min(r,i.now()+Xi);for(;i.now()<=o;){let a=Ce(t);if(a&&Me(a,i.now(),i.isProcessAlive))return;i.sleep(Bn)}throw new Error("Durable Rust semantic session helper did not become ready within 5s.")}function Ce(t){try{let e=JSON.parse(Pe(_(t,"server.json"),"utf8"));return typeof e.protocolVersion!="number"||typeof e.pid!="number"||typeof e.heartbeatAtMs!="number"||e.busyUntilMs!==void 0&&typeof e.busyUntilMs!="number"?null:{protocolVersion:e.protocolVersion,pid:e.pid,heartbeatAtMs:e.heartbeatAtMs,...e.busyUntilMs===void 0?{}:{busyUntilMs:e.busyUntilMs}}}catch{return null}}function ns(t){try{let e=JSON.parse(t);return e.ok===!0&&(e.session==="created"||e.session==="reused"||e.session==="invalidated")&&e.response&&typeof e.response=="object"?{ok:!0,session:e.session,response:e.response}:{ok:!1,error:typeof e.error=="string"?e.error:"helper wrote an invalid response"}}catch(e){return{ok:!1,error:`helper wrote malformed JSON: ${e instanceof Error?e.message:String(e)}`}}}function Ln(){return Object.fromEntries(Object.entries(process.env).filter(([t])=>rs(t)).sort(([t],[e])=>t.localeCompare(e)).map(([t,e])=>[t,e??null]))}function $n(t){return t==="HOME"||t==="PATH"||t.startsWith("CARGO_")||t.startsWith("RA_")||t.startsWith("RUST")}function rs(t){return $n(t)||t.startsWith("SCIP_RUST_")||t==="SCIP_QUERY_PROFILE"||t==="SCIP_QUERY_PROFILE_CACHE_STATE"||t==="SCIP_QUERY_PROFILE_COMMAND"||t==="SCIP_QUERY_PROFILE_OUT"||t==="SCIP_QUERY_PROFILE_RUN_ID"||t==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||t==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||t==="SCIP_QUERY_PROFILE_MIN_MS"}var Hn={canonicalProjectRoot(t){try{return Yi(t)}catch{return _(t)}},projectFingerprint(t){return En(t)},engineIdentity:at,fileFingerprint(t){return Te(Pe(t))},environment(){return qn(process.env)}},is={now:Date.now,randomId:Ji,isProcessAlive:he,spawnServer(t,e,n){if(!On(t))throw new Error(`Durable Rust semantic session helper was not found at ${t}. Run npm run build first.`);Ki(process.execPath,[t,e,n],{detached:!0,stdio:"ignore"}).unref()},sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)}};function De(t){return Array.isArray(t)?`[${t.map(De).join(",")}]`:t&&typeof t=="object"?`{${Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>`${JSON.stringify(e)}:${De(n)}`).join(",")}}`:JSON.stringify(t)}function Te(t){return Vi("sha256").update(t).digest("hex")}var Yn=15e3,Gn=8,Xn=5e3,ls=64,us=96,ft=class{constructor(e,n,r={}){this.projectRoot=e;this.status=n;this.opts=r;this.requester=r.requester??ms(e,process.env.SCIP_RUST_SEMANTIC_DURABLE_SESSION)}projectRoot;status;opts;requester;referencesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,references:ie(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,references:z(e,new Map(r.references),new Set(r.incompleteReferenceSymbolIds??[]))}}catch(r){return this.opts.fallbackReferenceResolver?.referencesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),references:ie(e)}}}calleesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,callees:se(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!1,includeCallees:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,callees:pt(e,new Map(r.callees??[]))}}catch(r){return this.opts.fallbackCalleeResolver?.calleesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),callees:se(e)}}}referencesAndCalleesForDefinitions(e,n){let r=this.status(this.projectRoot);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,references:ie(e),callees:se(n)};let i=[...e,...n];try{let s=this.requestSession(r.resolvedBinary,i,{includeReferences:e.length>0,includeCallees:n.length>0,referenceDefinitions:e,calleeDefinitions:n});return{available:s.available,resolvedBinary:r.resolvedBinary,reason:s.reason,references:z(e,new Map(s.references),new Set(s.incompleteReferenceSymbolIds??[])),callees:pt(n,new Map(s.callees??[]))}}catch(s){return this.fallbackReferencesAndCallees(r,e,n,s)}}signaturesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:n.reason,signatures:Qn(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!1,includeCallees:!1,includeSignatures:!0});return{available:r.available,resolvedBinary:n.resolvedBinary,reason:r.reason,signatures:hs(e,new Map(r.signatures??[]))}}catch(r){return this.opts.fallbackSignatureResolver?.signaturesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),signatures:Qn(e)}}}importDefinitionsForFile(e,n){let r=this.status(this.projectRoot);if(n.length===0)return{available:r.available,resolvedBinary:r.resolvedBinary,reason:r.reason,sourcePaths:new Map};if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,sourcePaths:new Map(n.map(i=>[i.id,null]))};try{let i=this.requestImportDefinitions(r.resolvedBinary,e,n);return{available:i.available,resolvedBinary:r.resolvedBinary,reason:i.reason,sourcePaths:new Map(i.sourcePaths)}}catch(i){return{available:!1,resolvedBinary:r.resolvedBinary,reason:i instanceof Error?i.message:String(i),sourcePaths:new Map(n.map(s=>[s.id,null]))}}}dispose(){this.requester.shutdown()}requestSession(e,n,r){let i=ke(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Yn),s=Fe(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),o=ke(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Gn),a=Fe(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),c=r.referenceDefinitions?[...r.referenceDefinitions]:void 0,l=r.calleeDefinitions?[...r.calleeDefinitions]:void 0,p=r.signatureDefinitions?[...r.signatureDefinitions]:void 0,u=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,...r}),f={projectRoot:this.projectRoot,rustAnalyzerBinary:e,definitions:[...n],...c?{referenceDefinitions:c}:{},...l?{calleeDefinitions:l}:{},...p?{signatureDefinitions:p}:{},requestTimeoutMs:i,...r.includeReferences!==!1&&s>0?{referenceRetryTimeoutMs:s}:{},diagnosticsTimeoutMs:a,settleDelayMs:u,concurrency:o,includeReferences:r.includeReferences,includeCallees:r.includeCallees,includeSignatures:r.includeSignatures},d=bs(f);return C("rust.semantic.session.request",()=>this.requester.requestSemantic(f,H(d,dt(i,f.referenceRetryTimeoutMs),o)),()=>({definitions:n.length,operationDefinitions:d,referenceDefinitions:f.referenceDefinitions?.length,calleeDefinitions:f.calleeDefinitions?.length,signatureDefinitions:f.signatureDefinitions?.length,references:f.includeReferences!==!1,callees:f.includeCallees===!0,signatures:f.includeSignatures===!0,referenceRetryTimeoutMs:f.referenceRetryTimeoutMs}))}fallbackReferencesAndCallees(e,n,r,i){let s=n.length===0?{available:!0,references:ie(n)}:this.opts.fallbackReferenceResolver?.referencesForDefinitions(n),o=r.length===0?{available:!0,callees:se(r)}:this.opts.fallbackCalleeResolver?.calleesForDefinitions(r);return s&&o?{available:s.available&&o.available,resolvedBinary:s.resolvedBinary??o.resolvedBinary??e.resolvedBinary,reason:s.reason??o.reason,references:z(n,s.references),callees:pt(r,o.callees)}:{available:!1,resolvedBinary:e.resolvedBinary,reason:i instanceof Error?i.message:String(i),references:ie(n),callees:se(r)}}requestImportDefinitions(e,n,r){let i=ke(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Yn),s=ke(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Gn),o=Fe(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),a=Fe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,Xn),c={projectRoot:this.projectRoot,rustAnalyzerBinary:e,file:n,positions:[...r],requestTimeoutMs:i,diagnosticsTimeoutMs:o,settleDelayMs:a,concurrency:s};return C("rust.semantic.import-definitions.session.request",()=>this.requester.requestImportDefinitions(c,H(r.length,i,s)),()=>({file:n,positions:r.length}))}};function Zn(t,e,n={}){return new ft(t,e,n)}function oe(t,e){let n=tr(t);if(n!==null)return n;let r=e.includeReferences!==!1;return r&&e.includeCallees!==!0&&e.includeSignatures!==!0&&e.definitionCount<=ls||r&&e.includeCallees===!0&&e.includeSignatures!==!0&&e.definitionCount<=us?0:Xn}function ps(t){let e=t?.trim().toLowerCase(),n=e==="0"||e==="false"||e==="off"||e==="worker",r=e==="1"||e==="true"||e==="on"||e==="durable",i=e===void 0||e==="";return{transport:n||!i&&!r?"worker":"durable",source:i?"default":"environment",fallback:"worker",valid:i||n||r,optOut:"SCIP_RUST_SEMANTIC_DURABLE_SESSION=0"}}function fs(t){return ps(t).transport}function ds(t,e){let n=null,r=!1,i=!1,s=!1,o=()=>n??=e(),a=()=>{i||(t.shutdown(),i=!0)},c=(p,u,f)=>{let d=Rs(p);r=!0;try{a()}catch{}W()&&de({type:"span",name:"rust.semantic.durable-session.request",durationMs:f,ok:!1,kind:u,session:"worker-fallback",reason:d})},l=(p,u,f)=>{if(s)throw new Error("Rust semantic failover session was already disposed.");if(r)return f(o());let d=Date.now();try{return u(t)}catch(m){c(m,p,Date.now()-d)}return f(o())};return{requestSemantic(p,u){return l("semantic",f=>f.requestSemantic(p,u),f=>f.requestSemantic(p,u))},requestImportDefinitions(p,u){return l("import-definitions",f=>f.requestImportDefinitions(p,u),f=>f.requestImportDefinitions(p,u))},shutdown(){if(s)return;s=!0;let p=[];try{a()}catch(u){p.push(u)}try{n?.shutdown()}catch(u){p.push(u)}if(p.length>0)throw p[0]}}}function ms(t,e,n={worker:()=>ys(),durable:()=>zn(t,{serverPath:we(Is()),semanticWorkerPath:we(er())})}){return fs(e)==="durable"?ds(n.durable(),n.worker):n.worker()}function ys(t={}){let e=null,n=null,r=1,i=!1,s=()=>{n&&(lt(n,{recursive:!0,force:!0}),n=null)},o=()=>{let l=e;e=null,l&&l.terminate(),s()},a=()=>{if(e)return e;let l=t.semanticWorkerPath?os(t.semanticWorkerPath):er();if(!ss(we(l)))throw new Error(`Rust semantic session worker was not found at ${we(l)}. Run npm run build before using built semantic Rust queries.`);return n=Kn(ut(Jn(),"scip-query-rust-session-")),e=new cs(l,t.shareEnvironment?{env:as}:void 0),e.unref(),e},c=()=>{let l=n??Kn(ut(Jn(),"scip-query-rust-session-"));return n=l,ut(l,`${r++}.json`)};return{requestSemantic(l,p){if(i)throw new Error("Rust semantic session was already disposed.");let u=a(),f=c(),d=new SharedArrayBuffer(4),m=new Int32Array(d);if(u.postMessage({kind:"semantic",request:l,responsePath:f,sharedBuffer:d}),Atomics.wait(m,0,0,p)==="timed-out")throw o(),new Error(`Rust semantic session worker timed out after ${(p/1e3).toFixed(0)}s`);try{let y=gs(Vn(f,"utf8"));if(!y.ok)throw new Error(y.error);return y.response}finally{lt(f,{force:!0})}},requestImportDefinitions(l,p){if(i)throw new Error("Rust semantic session was already disposed.");let u=a(),f=c(),d=new SharedArrayBuffer(4),m=new Int32Array(d);if(u.postMessage({kind:"import-definitions",request:l,responsePath:f,sharedBuffer:d}),Atomics.wait(m,0,0,p)==="timed-out")throw o(),new Error(`Rust semantic import-definition session worker timed out after ${(p/1e3).toFixed(0)}s`);try{let y=Ss(Vn(f,"utf8"));if(!y.ok)throw new Error(y.error);return y.response}finally{lt(f,{force:!0})}},shutdown(){if(i)return;if(i=!0,!e){s();return}let l=c(),p=new SharedArrayBuffer(4),u=new Int32Array(p);e.postMessage({kind:"shutdown",responsePath:l,sharedBuffer:p}),Atomics.wait(u,0,0,5e3),o()}}}function gs(t){let e=JSON.parse(t);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=e;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Ss(t){let e=JSON.parse(t);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=e;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Rs(t){let e=t instanceof Error?`${t.name} ${t.message}`.toLowerCase():String(t).toLowerCase();return e.includes("readiness")?"readiness":e.includes("timeout")||e.includes("timed out")?"timeout":e.includes("helper")?"helper":"request"}function ie(t){return new Map(t.map(e=>[e.symbolId,[]]))}function se(t){return new Map(t.map(e=>[e.symbolId,[]]))}function Qn(t){return new Map(t.map(e=>[e.symbolId,null]))}function pt(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??[]]))}function hs(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??null]))}function bs(t){let e=0;return t.includeReferences!==!1&&(e+=(t.referenceDefinitions??t.definitions).length),t.includeCallees===!0&&(e+=(t.calleeDefinitions??t.definitions).length),t.includeSignatures===!0&&(e+=(t.signatureDefinitions??t.definitions).length),Math.max(1,e)}function dt(t,e){return e&&e>0?Math.max(t,e):t}function er(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}function Is(){return new URL("./rust-semantic-session-server.js",import.meta.url)}function ke(t,e){return G(t)??e}function Fe(t,e){return tr(t)??e}function tr(t){if(!t)return null;let e=Number(t);return Number.isInteger(e)&&e>=0?e:null}var gt=15e3,St=8;function sr(t,e={}){let n=e.status??ve,r=Cs(t,n),i=Ds(t,n),s=Ts(t,n),o=e.referenceResolver||e.calleeResolver||e.signatureResolver||!xs(e)?null:Zn(t,n,{fallbackReferenceResolver:r,fallbackCalleeResolver:i,fallbackSignatureResolver:s}),a=e.referenceResolver??o??r,c=e.calleeResolver??o??i,l=e.signatureResolver??o??s,p=e.importUsageResolver??Dn(e.sourceImportUsageResolver??Ms(),e.importDefinitionResolver??o),u=e.calleeSymbolResolver,f=e.sourceZeroCalleeOracle,d=e.scipOccurrenceCalleeOracle,m=new Map,h=new Map,y=null,S=null,v=()=>(y??=n(t),y),L=()=>{let g=v();return g.dependencyAvailable?S??g:g},P=g=>{if(g.length===0)return new Map;let I=ae(g);try{let R=a.referencesForDefinitions(I),x=v();return S={...x,available:R.available,resolvedBinary:R.resolvedBinary??x.resolvedBinary,reason:R.reason??x.reason},R.available?new Map(R.references):z(I,R.references)}catch(R){return S={...v(),available:!1,reason:R instanceof Error?R.message:String(R)},K(I)}},O=g=>{if(g.length===0)return new Map;let I=ae(g),R=I.filter(nr);if(R.length===0)return V(I);let x=new Map,ne=ir(R,d),A=[];for(let M of R)h.has(M.symbolId)?x.set(M.symbolId,h.get(M.symbolId)??[]):ne.has(M.symbolId)?x.set(M.symbolId,ne.get(M.symbolId)??[]):rr(M,f)?x.set(M.symbolId,[]):A.push(M);if(A.length===0)return Q(I,x,void 0);try{let M=c.calleesForDefinitions(A),B=v();S={...B,available:M.available,resolvedBinary:M.resolvedBinary??B.resolvedBinary,reason:M.reason??B.reason};let D=Q(A,M.callees,u);for(let[J,Ke]of D)x.set(J,Ke);return Q(I,x,void 0)}catch(M){return S={...v(),available:!1,reason:M instanceof Error?M.message:String(M)},V(I)}},U=(g,I)=>{let R=ae(g),x=ae(I),ne=x.filter(nr),A=new Map,M=ir(ne,d),B=[];for(let D of ne)M.has(D.symbolId)?A.set(D.symbolId,M.get(D.symbolId)??[]):rr(D,f)?A.set(D.symbolId,[]):B.push(D);if(R.length===0&&B.length===0)return{references:K(R),callees:Q(x,A,void 0)};try{let D=o?o.referencesAndCalleesForDefinitions(R,B):ws(a,c,{referenceDefinitions:R,calleeDefinitions:B}),J=v();S={...J,available:D.available,resolvedBinary:D.resolvedBinary??J.resolvedBinary,reason:D.reason??J.reason};let Ke=D.available?new Map(D.references):z(R,D.references);for(let[Ve,Je]of D.callees)A.set(Ve,Je);let Bt=Q(x,A,u);for(let[Ve,Je]of Bt)h.set(Ve,Je);return{references:Ke,callees:Bt}}catch(D){return S={...v(),available:!1,reason:D instanceof Error?D.message:String(D)},{references:K(R),callees:V(x)}}},N=g=>{if(g.length===0)return new Map;let I=ae(g);try{let R=l.signaturesForDefinitions(I),x=v();return S={...x,available:R.available,resolvedBinary:R.resolvedBinary??x.resolvedBinary,reason:R.reason??x.reason},or(I,R.signatures)}catch(R){return S={...v(),available:!1,reason:R instanceof Error?R.message:String(R)},Ee(I)}};return{language:"rust",availability:L,dispose:()=>{o?.dispose()},importUsage:g=>{let I=m.get(g);if(I)return I;try{let R=p.importUsage(g);return m.set(g,R),R}catch(R){return S={...v(),available:!1,reason:R instanceof Error?R.message:String(R)},[]}},referencesFor:g=>P([g]).get(g.symbolId)??[],referencesForDefinitions:P,referencesAndCalleesForDefinitions:U,calleesFor:g=>O([g]).get(g.symbolId)??[],calleesForDefinitions:O,signatureFor:g=>N([g]).get(g.symbolId)??null}}function xs(t){if(t.usePersistentSession!==void 0)return t.usePersistentSession;let e=process.env.SCIP_RUST_SEMANTIC_SESSION;return e!=="0"&&e!=="false"}function Ms(){return{importUsageFacts:()=>({usage:[],positions:[]})}}function ae(t){return t.map(e=>{let n=e;return{...e,leaf:typeof n.leaf=="string"?n.leaf:$(e.symbol),parentTypeName:n.parentTypeName??null,isFunctionLike:typeof n.isFunctionLike=="boolean"?n.isFunctionLike:tn(e.symbol),isTypeLike:n.isTypeLike??!1,kind:n.kind??null,documentation:n.documentation??null,enclosingSymbol:n.enclosingSymbol??null}})}function nr(t){return t.isFunctionLike}function rr(t,e){if(!e)return!1;try{return e(t)}catch{return!1}}function ir(t,e){if(!e||t.length===0)return new Map;try{return e(t)}catch{return new Map}}function Cs(t,e){return{referencesForDefinitions:n=>Ps(t,e,n)}}function Ds(t,e){return{calleesForDefinitions:n=>ks(t,e,n)}}function Ts(t,e){return{signaturesForDefinitions:n=>Fs(t,e,n)}}function Ps(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,references:K(n)};let i=Rt();if(!yt(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,references:K(n)};let s=X(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,gt),o=Ne(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),a=X(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,St),c=Ne(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),l=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!0}),p={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,...o>0?{referenceRetryTimeoutMs:o}:{},diagnosticsTimeoutMs:c,settleDelayMs:l,concurrency:a},u=mt(process.execPath,[i],{cwd:t,input:JSON.stringify(p),encoding:"utf8",maxBuffer:50*1024*1024,timeout:H(n.length,dt(s,p.referenceRetryTimeoutMs),a)}),f=ht(u.stdout);if(f)return{available:f.available,resolvedBinary:r.resolvedBinary,reason:f.reason,references:z(n,new Map(f.references),new Set(f.incompleteReferenceSymbolIds??[]))};let d=u.error instanceof Error?u.error.message:u.stderr.trim()||`Rust semantic worker exited with status ${u.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:d,references:K(n)}}function ks(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,callees:V(n)};let i=Rt();if(!yt(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,callees:V(n)};let s=X(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,gt),o=X(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,St),a=Ne(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),c=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!1,includeCallees:!0}),l={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:o,includeReferences:!1,includeCallees:!0},p=mt(process.execPath,[i],{cwd:t,input:JSON.stringify(l),encoding:"utf8",maxBuffer:50*1024*1024,timeout:H(n.length,s,o)}),u=ht(p.stdout);if(u)return{available:u.available,resolvedBinary:r.resolvedBinary,reason:u.reason,callees:Q(n,new Map(u.callees??[]),void 0)};let f=p.error instanceof Error?p.error.message:p.stderr.trim()||`Rust semantic worker exited with status ${p.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:f,callees:V(n)}}function Fs(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,signatures:Ee(n)};let i=Rt();if(!yt(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,signatures:Ee(n)};let s=X(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,gt),o=X(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,St),a=Ne(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),c=oe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!1,includeCallees:!1,includeSignatures:!0}),l={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:o,includeReferences:!1,includeCallees:!1,includeSignatures:!0},p=mt(process.execPath,[i],{cwd:t,input:JSON.stringify(l),encoding:"utf8",maxBuffer:50*1024*1024,timeout:H(n.length,s,o)}),u=ht(p.stdout);if(u)return{available:u.available,resolvedBinary:r.resolvedBinary,reason:u.reason,signatures:or(n,new Map(u.signatures??[]))};let f=p.error instanceof Error?p.error.message:p.stderr.trim()||`Rust semantic worker exited with status ${p.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:f,signatures:Ee(n)}}function ws(t,e,n){let r=n.referenceDefinitions.length>0?t.referencesForDefinitions(n.referenceDefinitions):{available:!0,references:K(n.referenceDefinitions)},i=n.calleeDefinitions.length>0?e.calleesForDefinitions(n.calleeDefinitions):{available:!0,callees:V(n.calleeDefinitions)};return{available:r.available&&i.available,resolvedBinary:r.resolvedBinary??i.resolvedBinary,reason:r.reason??i.reason,references:r.references,callees:i.callees}}function K(t){return new Map(t.map(e=>[e.symbolId,[]]))}function V(t){return new Map(t.map(e=>[e.symbolId,[]]))}function Ee(t){return new Map(t.map(e=>[e.symbolId,null]))}function Q(t,e,n){let r=0,i=0;return C("rust.semantic.callees.complete-map",()=>{let s=new Map;for(let o of t){let a=e.get(o.symbolId)??[];a.length>0&&(r+=1),i+=a.length,s.set(o.symbolId,a.map(c=>({...c,symbol:n?n(c):c.symbol})))}return s},()=>({definitions:t.length,rows:r,callees:i,resolveSymbols:!!n}))}function or(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??null]))}function Rt(){return vs(new URL("./rust-semantic-worker.js",import.meta.url))}function ht(t){try{let e=JSON.parse(t);if(!e||typeof e!="object")return null;let n=e;return typeof n.available!="boolean"||!Array.isArray(n.references)?null:{available:n.available,reason:typeof n.reason=="string"?n.reason:void 0,references:n.references,incompleteReferenceSymbolIds:Array.isArray(n.incompleteReferenceSymbolIds)?n.incompleteReferenceSymbolIds.filter(r=>typeof r=="number"):void 0,callees:Array.isArray(n.callees)?n.callees:void 0,signatures:Array.isArray(n.signatures)?n.signatures:void 0}}catch{return null}}function X(t,e){return G(t)??e}function Ne(t,e){if(!t)return e;let n=Number(t);return Number.isInteger(n)&&n>=0?n:e}import{existsSync as Es,readFileSync as Ns}from"fs";import{deserializeSCIP as As,SymbolRole as _s}from"@c4312/scip";var bt=new WeakMap;function cr(t,e){let n=e.filter(js);if(n.length===0)return new Map;let r=!1,i=0,s=0;return C("rust.scip-occurrence.callees",()=>{let o=Us(t);if(r=!!o,!o)return new Map;let a=new Map;for(let c of n){let l=Ls(t,o,c);l!==null&&(a.set(c.symbolId,l),i+=1,s+=l.length)}return a},()=>({definitions:e.length,candidates:n.length,indexAvailable:r,resolvedDefinitions:i,resolvedCallees:s}))}function js(t){return!(!t.symbol.startsWith("rust-analyzer ")||!t.relativePath.endsWith(".rs")||!t.isFunctionLike||t.leaf==="main"||re(t.symbol))}function Ls(t,e,n){let r=me(t,n.relativePath);if(!r||r.language!=="rust")return null;let i=r.callables.find(l=>l.startLine!==n.startLine||l.endLine!==n.endLine?!1:l.name===n.leaf||n.leaf.endsWith(l.name)||l.name.endsWith(n.leaf));if(!i)return null;let s=r.callSites.filter(l=>l.line>=i.startLine&&l.line<=i.endLine);if(s.length===0)return null;let o=(e.occurrencesByFile.get(n.relativePath)??[]).filter(l=>l.line>=i.startLine&&l.line<=i.endLine&&l.callee.symbol!==n.symbol);if(o.some(l=>l.traitImplMember)||!Os(s,o))return null;let a=[],c=new Set;for(let l of o){let p=`${l.callee.symbol}\0${l.callee.file}\0${l.callee.line}`;c.has(p)||(c.add(p),a.push(l.callee))}return a}function Os(t,e){let n=ar(t),r=ar(e);if(n.size!==r.size)return!1;for(let[i,s]of n)if(r.get(i)!==s)return!1;return!0}function ar(t){let e=new Map;for(let n of t){let r=n.calleeLeaf??n.leaf;if(!r)continue;let i=`${n.line}\0${r}`;e.set(i,(e.get(i)??0)+1)}return e}function Us(t){if(bt.has(t))return bt.get(t)??null;let e=Bs(t);return bt.set(t,e),e}function Bs(t){if(!Es(t.config.indexPath))return null;try{let e=Se(t).filter(s=>s.symbol.startsWith("rust-analyzer ")&&s.relativePath.endsWith(".rs")&&s.isFunctionLike),n=new Map(e.map(s=>[s.symbol,s])),r=As(Ns(t.config.indexPath)),i=new Map;for(let s of r.documents??[]){let o=s.relativePath;if(!o||!o.endsWith(".rs")||t.isIgnored(o))continue;let a=[];for(let c of s.occurrences??[]){if(!c.symbol||(c.symbolRoles&_s.Definition)!==0)continue;let l=n.get(c.symbol);if(!l)continue;let p=c.range?.[0];Number.isInteger(p)&&a.push({line:p,leaf:l.leaf,traitImplMember:re(l.symbol),callee:{symbol:l.symbol,file:l.relativePath,line:l.startLine}})}i.set(o,a)}return{occurrencesByFile:i}}catch{return null}}var Ae=class{sessions=new WeakMap;getOrCreate(e,n,r){let i=Ws(e,n),s=this.sessions.get(e);s||(s=new Map,this.sessions.set(e,s));let o=s.get(i);if(o)return o.hits+=1,o.lastUsedAtMs=Date.now(),o.provider;let a=Date.now(),c=r();return s.set(i,{key:i,language:n,projectRoot:e.config.projectRoot,provider:c,createdAtMs:a,lastUsedAtMs:a,hits:1}),c}sessionsFor(e){return[...this.sessions.get(e)?.values()??[]]}clear(e){let n=this.sessions.get(e);if(n)for(let r of n.values())r.provider.dispose?.();this.sessions.delete(e)}};function Ws(t,e){return`${t.config.projectRoot}:${e}-workspace`}import{randomUUID as ko}from"crypto";import{existsSync as Fo,mkdirSync as Lr,readFileSync as wo,rmSync as Or}from"fs";import{dirname as Eo,resolve as Ur}from"path";import{readFileSync as qs}from"fs";import{join as It}from"path";var lr=5e3,zs="watch.lock",$s="watch-state.json",Hs="watch-activity.json";function ur(t){return{lockPath:It(t,zs),statePath:It(t,$s),activityPath:It(t,Hs)}}function vt(t){try{return Ks(JSON.parse(qs(t,"utf8")))}catch{return null}}function Ks(t){if(!t||typeof t!="object")return null;let e=t;return e.version!==1||typeof e.protocolVersion!="number"||typeof e.pid!="number"||!Number.isInteger(e.pid)||e.pid<=0||typeof e.projectRoot!="string"||e.worktreeId!==void 0&&(typeof e.worktreeId!="string"||e.worktreeId.length===0)||typeof e.cliVersion!="string"||!w(e.startedAt)||!w(e.heartbeatAt)||!w(e.lastActivityAt)||!Vs(e.watcher)||e.idleDeadlineAt!==void 0&&!w(e.idleDeadlineAt)||e.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(e.indexGeneration)||e.lastError!==void 0&&!Js(e.lastError)||e.lastRefresh!==void 0&&!Ys(e.lastRefresh)||e.reindexActivity!==void 0&&!Gs(e.reindexActivity)||e.typescriptSemantic!==void 0&&!Qs(e.typescriptSemantic)||e.typescriptIndex!==void 0&&!Xs(e.typescriptIndex)?null:e}function w(t){return typeof t=="string"&&Number.isFinite(Date.parse(t))}function Vs(t){if(!t||typeof t!="object"||!("state"in t))return!1;let e=t;switch(e.state){case"idle":return!0;case"waiting":return F(e.changedFiles)&&F(e.reindexAt);case"indexing":return F(e.startedAt);case"cooldown":return F(e.until)&&typeof e.dirty=="boolean";default:return!1}}function Js(t){if(!t||typeof t!="object")return!1;let e=t;return w(e.at)&&typeof e.message=="string"}function Ys(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.trigger?.kind=="string"&&typeof e.result=="string"&&w(e.startedAt)&&w(e.completedAt)&&F(e.durationMs)}function Gs(t){if(!t||typeof t!="object")return!1;let e=t;return!w(e.windowStartedAt)||!w(e.windowEndedAt)||!k(e.runs)||!k(e.rebuilt)||!k(e.reused)||!k(e.failed)||!k(e.suppressed)||!F(e.estimatedLogicalOutputBytes)||e.estimatedLogicalOutputBytes<0||!e.byTrigger||typeof e.byTrigger!="object"?!1:Object.values(e.byTrigger).every(n=>n===void 0||k(n))}function Qs(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&(e.state==="idle"||e.state==="ready"||e.state==="unavailable"||e.state==="error")&&F(e.requests)&&F(e.sessionsCreated)&&F(e.sessionsReused)&&F(e.sessionsRefreshed)&&F(e.sessionsReplaced)&&F(e.projectsCreated)&&(e.lastRequestAt===void 0||w(e.lastRequestAt))&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||w(e.busyUntil))}function Xs(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&(e.state==="idle"||e.state==="ready"||e.state==="unavailable"||e.state==="error")&&k(e.requests)&&k(e.sessionsCreated)&&k(e.sessionsReplaced)&&k(e.initializations)&&k(e.programUpdates)&&k(e.documentsEmitted)&&k(e.documentsRemoved)&&(e.lastRequestAt===void 0||w(e.lastRequestAt))&&(e.lastDurationMs===void 0||F(e.lastDurationMs)&&e.lastDurationMs>=0)&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||w(e.busyUntil))}function F(t){return typeof t=="number"&&Number.isFinite(t)}function k(t){return typeof t=="number"&&Number.isInteger(t)&&t>=0}import{performance as b}from"perf_hooks";function E(t,e,n){if(t.has(e))return t.get(e);let r=n();return t.set(e,r),r}import pr from"path";function Zs(t,e){return t.getReferences().map(n=>{let r=n.getNode();return _e(r,e)})}function eo(t){let e=t;return typeof e.findReferences=="function"?e.findReferences():[]}function fr(t,e,n,r){let i=[];for(let s of eo(t))for(let o of Zs(s,r))o.file===e.relativePath&&o.line>=e.startLine&&o.line<=e.endLine||i.push(o);for(let s of n)i.push(s);return Z(i)}function dr(t,e,n,r){let i=[],s=n?.getStart();for(let o of t.getReferences()){let a=o.getNode();ee(r,a.getSourceFile().getFilePath())===e&&(s!==void 0&&a.getStart()===s||i.push({location:_e(a,r),node:a}))}return i}function _e(t,e){let n=t.getSourceFile(),r=n.getLineAndColumnAtPos(t.getStart());return{file:ee(e,n.getFilePath())??n.getBaseName(),line:r.line-1,column:r.column-1}}function mr(t,e,n){let r=t.getSourceFile(),i=Mt(r,t),s=t.getText(),o=new RegExp(`\\b${Yt(s)}\\b`,"g"),a=r.getFullText().split(`
4
- `),c=[];for(let l=0;l<a.length;l++){if(l===i)continue;let p=a[l]??"";o.lastIndex=0;let u;for(;(u=o.exec(p))!==null;)c.push({file:e,line:l,column:u.index})}return Z(c.filter(l=>ee(n,pr.join(n,l.file))===e))}function xt(t){for(let e=t;e;e=e.getParent()){let n=e.getKindName();if(n.includes("Type")||n==="InterfaceDeclaration"||n==="TypeAliasDeclaration")return!0;if(n==="CallExpression"||n==="NewExpression"||n==="ExpressionStatement")return!1}return!1}function Mt(t,e){return t.getLineAndColumnAtPos(e.getStart()).line-1}function Z(t){let e=new Set,n=[];for(let r of t){let i=`${r.file}:${r.line}:${r.column}`;e.has(i)||(e.add(i),n.push(r))}return n}function ee(t,e){let n=pr.relative(t||process.cwd(),e).replace(/\\/g,"/");return!n||n.startsWith("..")?null:n}function yr(t,e,n,r){let i=to(e,r);return i.size===0?new Map:no(t,n,i)}function to(t,e){let n=new Map;for(let r of q(t,e)){let i=$(r.symbol)??r.leaf;if(!i)continue;let s=n.get(i);s||(s=[],n.set(i,s)),s.push(r)}return n}function no(t,e,n){let r=new Map,i=new Map;return e.forEachDescendant(s=>{for(let o of ro(t,s)){let a=n.get(o);if(!a)continue;let c=Mt(e,s);for(let l of a){if(c<l.startLine-1||c>l.endLine+1)continue;let p=Math.abs(c-l.startLine),u=i.get(l.symbolId);u!==void 0&&u<=p||(i.set(l.symbolId,p),r.set(l.symbolId,s))}}}),r}function ro(t,e){let n=[],r=i=>{i&&!n.includes(i)&&n.push(i)};if("getNameNode"in e&&typeof e.getNameNode=="function"){let i=e.getNameNode();r(i?.getText())}if("getName"in e&&typeof e.getName=="function"){let i=e.getName();r(i)}return t.Node.isIdentifier(e)&&r(e.getText()),n}var io=qt("ts-definition-leaf-candidates",{clearGroups:["definition-catalog"]});function gr(t,e,n,r){let i=Tt(t,e),s=Ct(i.get(r)??[],n);if(s)return s;let o=[];for(let a of i.values())for(let c of a)((c.leaf||$(c.symbol)||"").includes(r)||c.symbol.includes(r))&&o.push(c);return Ct(o,n)}function Dt(t,e,n,r){return Ct(Tt(t,e).get(r)??[],n)}function Sr(t,e){let n=new Map;for(let[r,i]of Tt(t,e)){let s=i[0];s&&n.set(r,s)}return n}function Tt(t,e){return io.get(t,e,()=>{let n=new Map;for(let r of q(t,e)){let i=r.leaf||$(r.symbol);if(!i)continue;let s=n.get(i);s||(s=[],n.set(i,s)),s.push({...r,leaf:i})}for(let r of n.values())r.sort((i,s)=>i.startLine-s.startLine||i.endLine-s.endLine||i.symbolId-s.symbolId);return n})}function Ct(t,e){let n=null,r=Number.POSITIVE_INFINITY;for(let i of t){let s=Math.abs(i.startLine-e);(s<r||s===r&&n&&i.startLine<n.startLine)&&(n=i,r=s)}return n}import Pt from"path";var ce=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function j(t){let e=t.toLowerCase();return ce.some(n=>e.endsWith(n))}function Rr(t,e){let n=new Map,r=null,i=null,s=()=>(i??=Y(t,{extensions:ce}),i),o=()=>(r??=C("typescript.source-file-index",()=>so(t.config.projectRoot,e,s()),()=>({projects:e.length,indexedDocuments:s().length})),r),a=c=>j(c)?E(n,c,()=>{let l=le(Pt.resolve(t.config.projectRoot,c));for(let{project:p,sourceFiles:u}of o()){let f=u.get(l)??null;if(f||(f=p.addSourceFileAtPathIfExists(l)??null,f&&u.set(le(f.getFilePath()),f)),f)return{project:p,sourceFile:f}}return null}):null;return{sourceFile:c=>a(c)?.sourceFile??null,sourceFileMatch:a,indexedTypeScriptLikeDocuments:s}}function so(t,e,n){let r=e.map(({project:i})=>({project:i,sourceFiles:new Map(i.getSourceFiles().map(s=>[le(s.getFilePath()),s]))}));for(let i of n){let s=le(Pt.resolve(t,i));for(let o of r){if(o.sourceFiles.has(s))break;let a=o.project.addSourceFileAtPathIfExists(s)??null;if(a){o.sourceFiles.set(le(a.getFilePath()),a);break}}}return r}function le(t){return Pt.resolve(t)}function kt(t,e){for(let n of t)if(e===n.name||e.startsWith(`${n.name}/`))return n.name;return null}function hr(t){let e=`${t.relativeDir}/src`;return[`${e}/index.ts`,`${e}/index.tsx`,`${e}/index.mts`,`${e}/index.cts`]}import{existsSync as ue,readFileSync as oo}from"fs";import T from"path";var Ft=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function wt(t,e){let r=e?T.dirname(T.join(t,e)):t,i=T.resolve(t);for(;r.startsWith(i);){for(let o of Ft){let a=T.join(r,o);if(ue(a))return a}let s=T.dirname(r);if(s===r)break;r=s}for(let s of Ft){let o=T.join(t,s);if(ue(o))return o}return null}function br(t){let e=t.config.projectRoot,n=new Set(ao(e,t.config.semantic?.typescript?.tsconfigs)),r=Y(t,{includeIgnored:!1,extensions:ce});for(let i of r){let s=wt(e,i);s&&n.add(T.resolve(s))}if(n.size===0){let i=wt(e);i&&n.add(T.resolve(i))}return[...n].filter(i=>!Ir(e,i)).sort((i,s)=>i.localeCompare(s))}function ao(t,e=[]){let n=new Set;for(let r of e){let i=T.isAbsolute(r)?r:T.join(t,r);ue(i)&&n.add(T.resolve(i))}for(let r of co(t))for(let i of Ft){let s=T.join(r,i);ue(s)&&n.add(T.resolve(s))}if(n.size===0){let r=wt(t);r&&n.add(T.resolve(r))}return[...n].filter(r=>!Ir(t,r)).sort((r,i)=>r.localeCompare(i))}function co(t){let e=T.join(t,"package.json");if(!ue(e))return[];let n;try{n=JSON.parse(oo(e,"utf8"))}catch{return[]}return(Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages??[]).flatMap(i=>Ht(t,i))}function Ir(t,e){let n=T.relative(t,e).replace(/\\/g,"/");return n.startsWith("..")||n.includes("/node_modules/")||n.startsWith("node_modules/")||n.includes("/dist/")||n.startsWith("dist/")}import{createRequire as lo}from"module";var vr=lo(import.meta.url),pe,je;function Et(){if(pe!==void 0)return pe;try{pe=vr("ts-morph")}catch{pe=null}return pe}function Le(){if(je)return je;let t=Et();if(!t)return"ts-morph:unavailable";let e="unknown";try{e=vr("ts-morph/package.json").version??"unknown"}catch{}return je=`ts-morph:${e}:typescript:${t.ts.version}`,je}function xr(t,e){return e.map(n=>({tsconfigPath:n,project:new t.Project({tsConfigFilePath:n,skipFileDependencyResolution:!0})}))}function Oe(t,e,n){return{language:"typescript",availability:()=>({available:!1,reason:t,tsconfigPath:e,tsconfigPaths:n}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function Ue(t,e){let n=new Map(t.map(i=>[i.symbol,i])),r=new Map(t.map(i=>[i.symbolId,[]]));for(let i of e.values())for(let s of i){let o=n.get(s.targetSymbol);o&&r.get(o.symbolId).push(s.location)}for(let[i,s]of r)r.set(i,uo(s));return r}function Dr(t,e,n){let r=Cr(t,e),i=Cr(t,n),s=[...r].filter(u=>!i.has(u)).sort(),o=[...i].filter(u=>!r.has(u)).sort(),a=Mr(t,e),c=Mr(t,n),l=[...a].filter(u=>!c.has(u)).sort(),p=[...c].filter(u=>!a.has(u)).sort();return{passed:s.length===0&&o.length===0,expectedCount:r.size,actualCount:i.size,missing:s,extra:o,callerFiles:{passed:l.length===0&&p.length===0,expectedCount:a.size,actualCount:c.size,missing:l,extra:p}}}function Mr(t,e){let n=new Set;for(let r of t)for(let i of e.get(r.symbolId)??[])i.file!==r.relativePath&&n.add(`${r.symbol}\0${i.file}`);return n}function Tr(t,e,n){let r=new Set(n),i=new Map(n.map(s=>[s,[]]));for(let s of t)for(let o of e.get(s.symbolId)??[])r.has(o.file)&&i.get(o.file).push({targetSymbol:s.symbol,location:o});for(let[s,o]of i)i.set(s,po(o));return i}function Cr(t,e){let n=new Set;for(let r of t)for(let i of e.get(r.symbolId)??[])n.add(`${r.symbol}\0${i.file}\0${i.line}\0${i.column}`);return n}function uo(t){let e=new Map;for(let n of t)e.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...e.values()].sort(Pr)}function po(t){let e=new Map;for(let n of t){let{location:r}=n;e.set(`${n.targetSymbol}\0${r.file}\0${r.line}\0${r.column}`,n)}return[...e.values()].sort((n,r)=>n.targetSymbol.localeCompare(r.targetSymbol)||Pr(n.location,r.location))}function Pr(t,e){return t.file.localeCompare(e.file)||t.line-e.line||t.column-e.column}var fo=32;function Ar(t,e){let n=C("typescript.provider.load",()=>Et());if(!n)return Oe("ts-morph is not installed");let r=C("typescript.provider.tsconfig-discovery",()=>br(t));if(r.length===0)return Oe("no tsconfig found");try{let i=C("typescript.provider.project-bundles",()=>xr(n,r),()=>({tsconfigs:r.length}));return mo(t,n,i)}catch(i){return Oe(i instanceof Error?i.message:String(i),r[0],r)}}function mo(t,e,n,r={}){return C("typescript.provider.construct",()=>new At(t,e,n),()=>({tsconfigs:n.length,reusedProjects:r.reusedProjects===!0}))}var At=class{constructor(e,n,r){this.db=e;this.tsMorph=n;this.projects=r;this.workspacePackages=$t(e.config.projectRoot),this.sourceFiles=Rr(e,r)}db;tsMorph;projects;language="typescript";importUsageCache=new Map;referencesCache=new Map;calleesCache=new Map;fileCalleesCache=new Map;signatureCache=new Map;definitionNodeCache=new Map;fileDefinitionNodeCache=new Map;indexedDefinitionLeafCache=new Map;compilerCheckerCache=new WeakMap;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;sourceFiles;availability(){return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(e=>e.tsconfigPath)}}importUsage(e){return E(this.importUsageCache,e,()=>{let n=this.sourceFiles.sourceFile(e);if(!n)return[];let r=go();return C("typescript.import-usage.file",()=>this.importUsageForSourceFile(e,n,r),()=>({file:e,...r}))})}referencesFor(e){return E(this.referencesCache,e.symbolId,()=>{let n=this.nodeForDefinition(e);return this.referencesForDefinitionNode(e,n)})}referencesForDefinitions(e,n={}){let r=new Map,i=W(),s=[];for(let p of e){let u=this.referencesCache.get(p.symbolId);u?r.set(p.symbolId,u):s.push(p)}if(s.length===0)return r;let o=s,a=n.exact?[]:s.filter(p=>!Fr(p));if(a.length>=fo){let p=this.referencesForDefinitionsBySymbolScan(a);for(let u of a){let f=p.get(u.symbolId)??[];this.referencesCache.set(u.symbolId,f),r.set(u.symbolId,f)}if(o=s.filter(u=>Fr(u)),o.length===0)return r}let c=new Map;for(let p of o){let u=c.get(p.relativePath);u?u.push(p):c.set(p.relativePath,[p])}let l=[];for(let[p,u]of c){let f=wr();C("typescript.references-map.file",()=>{let d=this.definitionNodesForFile(p);for(let m of u){i&&(f.cacheMisses+=1);let h=d.get(m.symbolId)??null;i&&(h?f.nodeHits+=1:f.nodeMisses+=1);try{let y=this.referencesForDefinitionNode(m,h,i?f:void 0);this.referencesCache.set(m.symbolId,y),r.set(m.symbolId,y)}catch{f.preciseSearchFailures+=1,l.push(m)}}},()=>({relativePath:p,definitions:u.length,...Er(f)}))}if(l.length>0){let p=this.referencesForDefinitionsBySymbolScan(l);for(let u of l){let f=p.get(u.symbolId)??[];this.referencesCache.set(u.symbolId,f),r.set(u.symbolId,f)}}return r}referenceFragmentsForFiles(e){let n=Se(this.db).filter(s=>j(s.relativePath)),r=e.filter(s=>this.sourceFiles.sourceFile(s)!==null),i=this.referencesForDefinitionsBySymbolScan(n,r);return Tr(n,i,r)}referencesForDefinitionsBySymbolScan(e,n){let r=W(),i=wr(),s=new Map,o=new Set(e.map(c=>c.symbolId)),a=new Map(e.map(c=>[c.symbolId,c]));for(let c of e)s.set(c.symbolId,[]);return C("typescript.references-map.inverted-scan",()=>{let c=r?b.now():0,l=n?this.packageImportReferencesForFiles(n):this.packageImportReferences();for(let y of e){let S=l.get(y.symbolId)??[];if(S.length>0){let v=s.get(y.symbolId)??[];v.push(...S),s.set(y.symbolId,v)}r&&(i.packageReferenceCount+=S.length)}r&&(i.packageRefsMs+=b.now()-c);let p=new Map,u=new Map,f=this.hierarchyTargetsForDefinitions(e),d=new Set(e.map(y=>y.leaf).filter(Boolean)),m=r?b.now():0;for(let y of n??this.sourceFiles.indexedTypeScriptLikeDocuments()){if(this.db.isIgnored(y))continue;let S=this.sourceFiles.sourceFile(y);S&&(r&&(i.scanFiles+=1),this.addReferencesFromSourceFileScan(S,y,o,a,f,d,p,u,s,r?i:void 0))}r&&(i.scanMs+=b.now()-m);let h=r?b.now():0;this.addHierarchyMemberReferences(e,s,r?i:void 0),r&&(i.hierarchyMs+=b.now()-h);for(let[y,S]of s){let v=Z(S);s.set(y,v),r&&(i.referenceCount+=v.length)}},()=>({definitions:e.length,...Er(i)})),s}addReferencesFromSourceFileScan(e,n,r,i,s,o,a,c,l,p){let u=this.compilerCheckerForSourceFile(e),f=e.compilerNode,d=ho(e),m=h=>{if(this.tsMorph.ts.isIdentifier(h)){if(p&&(p.identifiers+=1),!o.has(h.text)&&!d.has(h.text)){this.tsMorph.ts.forEachChild(h,m);return}let y=this.compilerReferenceSymbol(u,h,p);if(y){let S;a.has(y)?S=a.get(y)??null:(S=this.referenceDefinitionFromCompilerSymbol(y),a.set(y,S)),p&&(S?p.targetHits+=1:p.targetMisses+=1);let v=E(c,y,()=>this.compilerSymbolKeys(y)),L=null,P=null,O=S&&r.has(S.symbolId)?i.get(S.symbolId):void 0;if(O&&(L=Nt(f,h),!kr(O,n,L))){let U=f.getLineAndCharacterOfPosition(h.getStart(f));P={file:n,line:U.line,column:U.character};let N=l.get(O.symbolId)??[];N.push(P),l.set(O.symbolId,N),p&&(p.requestedHits+=1)}for(let U of v)for(let N of s.get(U)?.values()??[]){if(L??=Nt(f,h),kr(N,n,L))continue;if(!P){let I=f.getLineAndCharacterOfPosition(h.getStart(f));P={file:n,line:I.line,column:I.character}}let g=l.get(N.symbolId)??[];g.push(P),l.set(N.symbolId,g),p&&(p.requestedHits+=1)}}}this.tsMorph.ts.forEachChild(h,m)};m(f)}hierarchyTargetsForDefinitions(e){let n=new Map;for(let r of e){let i=this.nodeForDefinition(r),s=i?.compilerNode;if(!s||!this.isHierarchyMethod(s))continue;let o=s.parent;if(!this.isHierarchyContainer(o))continue;let a=this.compilerCheckerForSourceFile(i.getSourceFile()),c=a.getSymbolAtLocation(s.name);if(c)for(let l of this.hierarchyMemberSymbols(a,o,c))for(let p of this.compilerSymbolKeys(l)){let u=n.get(p)??new Map;u.set(r.symbolId,r),n.set(p,u)}}return n}hierarchyMemberSymbols(e,n,r){let i=new Set,s=new Set,o=(a,c,l)=>{if(!s.has(a)){s.add(a),i.add(c);for(let p of l){let u=p.getProperty(r.name);u&&o(p,u,this.hierarchyAncestorTypesForType(e,p))}}};return o(e.getTypeAtLocation(n),r,this.hierarchyAncestorTypes(e,n)),i}addHierarchyMemberReferences(e,n,r){let i=new Map;for(let s of e){let o=this.nodeForDefinition(s),a=o?.compilerNode;if(!a||!this.isHierarchyMethod(a))continue;let c=a.parent;if(!this.isHierarchyContainer(c))continue;let l=this.compilerCheckerForSourceFile(o.getSourceFile()),p=l.getSymbolAtLocation(a.name);if(!p)continue;let u=a.getSourceFile(),f=u.getLineAndCharacterOfPosition(a.name.getStart(u)),d={definition:s,location:{file:s.relativePath,line:f.line,column:f.character}},m=n.get(s.symbolId)??[];for(let y of this.hierarchyMemberSymbols(l,c,p))if(y!==p)for(let S of this.compilerSymbolLocations(y))m.push(S),r&&(r.hierarchyReferences+=1);n.set(s.symbolId,m);let h=this.hierarchyRootMemberSymbols(l,c,p);for(let y of h){let S=i.get(y)??new Map;S.set(s.symbolId,d),i.set(y,S)}r&&(r.hierarchyDefinitions+=1)}for(let s of i.values())if(!(s.size<2)){r&&(r.hierarchyFamilies+=1);for(let{definition:o}of s.values()){let a=n.get(o.symbolId)??[];for(let c of s.values())c.definition.symbolId!==o.symbolId&&(a.push(c.location),r&&(r.hierarchyReferences+=1));n.set(o.symbolId,a)}}}hierarchyRootMemberSymbols(e,n,r){let i=new Set,s=new Set,o=(a,c,l)=>{if(s.has(a))return;s.add(a);let p=!1;for(let u of l){let f=u.getProperty(r.name);f&&(p=!0,o(u,f,this.hierarchyAncestorTypesForType(e,u)))}if(!p)for(let u of this.compilerSymbolKeys(c))i.add(u)};return o(e.getTypeAtLocation(n),r,this.hierarchyAncestorTypes(e,n)),i}compilerSymbolKeys(e){return(e.declarations??[]).map(n=>{let r=n.getSourceFile();return`${r.fileName}\0${n.getStart(r)}\0${e.name}`})}compilerSymbolLocations(e){let n=[];for(let r of e.declarations??[]){let i=r.getSourceFile(),s=ee(this.db.config.projectRoot,i.fileName);if(!s)continue;let o=r.name,a=i.getLineAndCharacterOfPosition((o??r).getStart(i));n.push({file:s,line:a.line,column:a.character})}return n}baseTypes(e,n){try{return e.getBaseTypes(n)??[]}catch{return[]}}hierarchyAncestorTypes(e,n){let r=new Set(this.hierarchyAncestorTypesForType(e,e.getTypeAtLocation(n)));for(let i of n.heritageClauses??[])for(let s of i.types)r.add(e.getTypeAtLocation(s));return[...r]}hierarchyAncestorTypesForType(e,n){let r=new Set(this.baseTypes(e,n));for(let i of n.getSymbol()?.declarations??[])if(this.isHierarchyContainer(i))for(let s of i.heritageClauses??[])for(let o of s.types)r.add(e.getTypeAtLocation(o));return[...r]}isHierarchyMethod(e){return this.tsMorph.ts.isMethodDeclaration(e)||this.tsMorph.ts.isMethodSignature(e)}isHierarchyContainer(e){return this.tsMorph.ts.isClassDeclaration(e)||this.tsMorph.ts.isClassExpression(e)||this.tsMorph.ts.isInterfaceDeclaration(e)}compilerReferenceSymbol(e,n,r){r&&(r.symbolLookups+=1);let i=e.getSymbolAtLocation(n);if(i){if((i.flags&this.tsMorph.ts.SymbolFlags.Alias)===0)return i;try{return r&&(r.aliasResolutions+=1),e.getAliasedSymbol(i)}catch{return i}}}calleesFor(e){return E(this.calleesCache,e.symbolId,()=>E(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath)).get(e.symbolId)??[])}calleesForDefinitions(e){let n=new Map,r=new Map;for(let i of e){let s=r.get(i.relativePath);s?s.push(i):r.set(i.relativePath,[i])}for(let[i,s]of r){let o=this.fileCalleesCache.get(i),a=new Set(s.map(l=>l.symbolId)),c=o??this.calleeMapForFile(i,a);for(let l of s){let p=c.get(l.symbolId)??[];this.calleesCache.set(l.symbolId,p),n.set(l.symbolId,p)}}return n}referencesForDefinitionNode(e,n,r){let i=r?b.now():0,s=this.packageImportReferencesForDefinition(e);if(r&&(r.packageRefsMs+=b.now()-i,r.packageReferenceCount+=s.length),!n)return s;let o=r?b.now():0,a=fr(n,e,s,this.db.config.projectRoot);return r&&(r.semanticRefsMs+=b.now()-o,r.referenceCount+=a.length),a}signatureFor(e){return E(this.signatureCache,e.symbolId,()=>{let n=this.nodeForDefinition(e);if(!n||!this.tsMorph.Node.isFunctionDeclaration(n)&&!this.tsMorph.Node.isMethodDeclaration(n)&&!this.tsMorph.Node.isArrowFunction(n)&&!this.tsMorph.Node.isFunctionExpression(n)&&!this.tsMorph.Node.isConstructorDeclaration(n))return null;let r=n.getType().getCallSignatures()[0];if(!r)return null;let i=r.getParameters().map(o=>{let a=o.getDeclarations()[0],c=a?o.getTypeAtLocation(a).getText(a):o.getValueDeclaration()?.getType().getText()??"unknown";return Nr(c)}),s=r.getReturnType().getText(n);return`(${i.join(",")})=>${Nr(s)}`})}importUsageForSourceFile(e,n,r){let i=[],s=new Map;for(let o of n.getImportDeclarations()){r.declarations+=1;let a=Ge(this.db,e,o.getModuleSpecifierValue()),c=o.getImportClause()?.isTypeOnly()??!1;for(let l of _t(o)){r.entries+=1;let p=c?null:l.identifier?.getSymbol()?.compilerSymbol??null;!c&&l.identifier&&(p?r.bindingSymbols+=1:r.missingBindingSymbols+=1);let u={sourcePath:a,entry:l,typeOnlyDeclaration:c,bindingSymbol:p,references:[]};if(i.push(u),c||!l.localName||!p)continue;let f=s.get(l.localName);f?f.push(u):s.set(l.localName,[u])}}return s.size>0&&n.forEachDescendant(o=>{if(o.getKindName()!=="Identifier")return;let a=s.get(o.getText());if(!a||So(o))return;r.scannedIdentifiers+=1;let c=o.getSymbol()?.compilerSymbol;if(r.symbolLookups+=1,!!c){for(let l of a)if(l.bindingSymbol===c){l.references.push({location:_e(o,this.db.config.projectRoot),node:o}),r.matchedReferences+=1;break}}}),i.map(o=>o.typeOnlyDeclaration?yo(e,o.sourcePath,o.entry):o.entry.identifier&&!o.bindingSymbol?(r.fallbackEntries+=1,this.valueImportUsageForEntry(e,o.sourcePath,o.entry)):this.valueImportUsageFromLocations(e,o.sourcePath,o.entry,o.references))}valueImportUsageForEntry(e,n,r){let i=r.identifier?r.identifier.findReferences():[],s=[];for(let o of i)for(let a of dr(o,e,r.identifier,this.db.config.projectRoot))s.push(a);return this.valueImportUsageFromLocations(e,n,r,s)}valueImportUsageFromLocations(e,n,r,i){let s=i.some(c=>!xt(c.node)),o=i.some(c=>xt(c.node)),a=r.isTypeOnly;return{importer:e,sourcePath:n,importedName:r.importedName,localName:r.localName,kind:r.kind,isTypeOnly:a,isUsed:a||i.length>0,isTypeUsed:a||o,isValueUsed:s,references:i.map(c=>c.location)}}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferencesForFiles(e){let n=new Map,r=new Set;for(let s of e){let o=this.sourceFiles.sourceFile(s);if(o)for(let a of o.getImportDeclarations()){let c=kt(this.workspacePackages,a.getModuleSpecifierValue());c&&r.add(c)}}if(r.size===0)return n;let i=this.packageExportsForNames(r);for(let s of e)this.addPackageImportReferencesForDocument(n,i,s);for(let[s,o]of n)n.set(s,Z(o));return n}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,n=this.packageExports();for(let r of this.sourceFiles.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,n,r);for(let[r,i]of e)e.set(r,Z(i));return this.packageImportReferenceIndex=e,e}addPackageImportReferencesForDocument(e,n,r){if(this.db.isIgnored(r))return;let i=this.sourceFiles.sourceFileMatch(r);if(i)for(let s of i.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,n,r,s)}addPackageImportReferencesForDeclaration(e,n,r,i){let s=kt(this.workspacePackages,i.getModuleSpecifierValue());if(!s)return;let o=n.get(s);if(o)for(let a of _t(i)){if(a.kind!=="named"||!a.identifier)continue;let c=o.get(a.importedName);if(!c||c.size===0)continue;let l=mr(a.identifier,r,this.db.config.projectRoot);l.length>0&&xo(e,c,l)}}packageExports(){return this.packageExportIndex?this.packageExportIndex:(this.packageExportIndex=this.packageExportsForNames(new Set(this.workspacePackages.map(e=>e.name))),this.packageExportIndex)}packageExportsForNames(e){let n=new Map;for(let r of this.workspacePackages){if(!e.has(r.name))continue;let i=new Map;for(let s of hr(r))this.collectPackageExports(r,s,i,new Set);i.size>0&&n.set(r.name,i)}return n}collectPackageExports(e,n,r,i){if(i.has(n))return;i.add(n);let s=this.sourceFiles.sourceFile(n);if(s)for(let o of s.getExportDeclarations()){let a=o.getModuleSpecifierValue(),c=a?Ge(this.db,n,a):n;if(!c||!c.startsWith(`${e.relativeDir}/src/`))continue;let l=o.getNamedExports();if(l.length===0){if(o.isNamespaceExport())continue;this.collectPackageExports(e,c,r,i);continue}for(let p of l){let u=p.getNameNode().getText(),f=p.getAliasNode()?.getText()??u,d=this.indexedDefinitionByLeaf(c,u);if(!d)continue;let m=r.get(f);m||(m=new Set,r.set(f,m)),m.add(d.symbolId)}}}indexedDefinitionByLeaf(e,n){return E(this.indexedDefinitionLeafCache,e,()=>Sr(this.db,e)).get(n)??null}nodeForDefinition(e){return E(this.definitionNodeCache,e.symbolId,()=>this.definitionNodesForFile(e.relativePath).get(e.symbolId)??null)}definitionNodesForFile(e){return E(this.fileDefinitionNodeCache,e,()=>{let n=this.sourceFiles.sourceFile(e);return n?yr(this.tsMorph,this.db,n,e):new Map})}referenceDefinitionFromCompilerSymbol(e){return this.definitionFromCompilerSymbol(e,void 0,!0)}definitionFromCompilerSymbol(e,n,r=!1){let i=e.name,s=n?b.now():0,o=e.declarations??[];n&&(n.declarationsMs+=b.now()-s,n.declarationChecks+=o.length);for(let a of o){let c=n?b.now():0,l=a.getSourceFile(),p=ee(this.db.config.projectRoot,l.fileName),u=l.getLineAndCharacterOfPosition(a.getStart(l)).line;if(n&&(n.declarationLocationMs+=b.now()-c),!p||this.db.isIgnored(p))continue;let f=n?b.now():0,d=this.compilerDeclarationName(a),m=r?Dt(this.db,p,u,i)??(d&&d!==i?Dt(this.db,p,u,d):null):gr(this.db,p,u,i);if(n&&(n.indexedLookupMs+=b.now()-f),m)return{symbolId:m.symbolId,symbol:m.symbol,file:m.relativePath,line:m.startLine}}return null}compilerDeclarationName(e){let n=e.name;return n&&this.tsMorph.ts.isIdentifier(n)?n.text:null}calleeMapForFile(e,n){let r=W(),i=0,s=0,o=0,a=0,c=0,l=0,p=0,u=0,f=r?Io():void 0;return C("typescript.callee-map.file",()=>{let d=r?b.now():0,m=this.sourceFiles.sourceFile(e);if(r&&(c=Math.round(b.now()-d)),!m)return new Map;let h=r?b.now():0,y=q(this.db,e).sort((g,I)=>g.startLine-I.startLine||I.endLine-g.endLine);if(r&&(l=Math.round(b.now()-h)),i=y.length,y.length===0)return new Map;let S=new Map,v=r?b.now():0,L=this.compilerCheckerForSourceFile(m),P=m.compilerNode;r&&(p=Math.round(b.now()-v));let O=new Map,U=g=>{if(this.tsMorph.ts.isCallExpression(g)||this.tsMorph.ts.isNewExpression(g)){r&&(s+=1);let I=this.semanticCalleeForCallNode(L,P,y,g,O,n,f);I&&(r&&(o+=1),Ro(S,I.callerId,I.target))}this.tsMorph.ts.forEachChild(g,U)},N=r?b.now():0;U(P),r&&(u=Math.round(b.now()-N));for(let[g,I]of S)S.set(g,Mo(I));return a=S.size,S},()=>({relativePath:e,definitions:i,callNodes:s,resolvedCallees:o,outputRows:a,requestedDefinitions:n?.size??i,sourceFileLookupMs:c,definitionsLoadMs:l,checkerLookupMs:p,traversalMs:u,...f?vo(f):{}}))}semanticCalleeForCallNode(e,n,r,i,s,o,a){let c=a?b.now():0,l=bo(r,Nt(n,i));if(a&&(a.callerLookupMs+=b.now()-c),!l)return null;if(o&&!o.has(l.symbolId))return a&&(a.skippedUnrequestedCallers+=1),null;let p=i.expression,u=this.compilerSymbolForExpression(e,p,a),f=null;if(u)if(a&&(a.targetSymbolHits+=1),s.has(u))a&&(a.compilerSymbolCacheHits+=1),f=s.get(u)??null;else{a&&(a.compilerSymbolCacheMisses+=1);let d=a?b.now():0;f=this.definitionFromCompilerSymbol(u,a),a&&(a.targetLookupMs+=b.now()-d),s.set(u,f)}else a&&(a.targetMisses+=1);return f?{callerId:l.symbolId,target:{symbol:f.symbol,file:f.file,line:f.line}}:null}compilerSymbolForExpression(e,n,r){let i=r?b.now():0,s=e.getSymbolAtLocation(n);if(r&&(r.expressionSymbolMs+=b.now()-i),s)return s;r&&(r.typeFallbacks+=1);let o=r?b.now():0,a=e.getTypeAtLocation(n).getSymbol();return r&&(r.typeSymbolMs+=b.now()-o),a}compilerCheckerForSourceFile(e){let n=e.getProject(),r=this.compilerCheckerCache.get(n);return r||(r=n.getTypeChecker().compilerObject,this.compilerCheckerCache.set(n,r)),r}};function _t(t){let e=[],n=t.getDefaultImport();n&&e.push({identifier:n,importedName:"default",localName:n.getText(),kind:"default",isTypeOnly:t.getImportClause()?.isTypeOnly()??!1});let r=t.getNamespaceImport();r&&e.push({identifier:r,importedName:"*",localName:r.getText(),kind:"namespace",isTypeOnly:t.getImportClause()?.isTypeOnly()??!1});for(let i of t.getNamedImports()){let s=i.getNameNode(),a=i.getAliasNode()??(s.getKindName()==="Identifier"?s:null);e.push({identifier:a,importedName:s.getText(),localName:a?.getText()??s.getText(),kind:"named",isTypeOnly:i.isTypeOnly()||(t.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function yo(t,e,n){return{importer:t,sourcePath:e,importedName:n.importedName,localName:n.localName,kind:n.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function go(){return{declarations:0,entries:0,bindingSymbols:0,missingBindingSymbols:0,scannedIdentifiers:0,symbolLookups:0,matchedReferences:0,fallbackEntries:0}}function So(t){for(let e=t;e;e=e.getParent())if(e.getKindName()==="ImportDeclaration")return!0;return!1}function Ro(t,e,n){let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}function ho(t){let e=new Set;for(let n of t.getImportDeclarations())for(let r of _t(n))r.localName&&e.add(r.localName);return e}function bo(t,e){let n=null;for(let r of t)e<r.startLine||e>r.endLine||(!n||r.startLine>=n.startLine)&&(n=r);return n}function Nt(t,e){return t.getLineAndCharacterOfPosition(e.getStart(t)).line}function kr(t,e,n){return e===t.relativePath&&n>=t.startLine&&n<=t.endLine}function Fr(t){return t.symbol.includes("#")?ge(t.symbol)==="type"&&t.relativePath.endsWith(".d.ts"):!1}function Io(){return{callerLookupMs:0,expressionSymbolMs:0,typeSymbolMs:0,targetLookupMs:0,declarationsMs:0,declarationLocationMs:0,indexedLookupMs:0,compilerSymbolCacheHits:0,compilerSymbolCacheMisses:0,targetSymbolHits:0,targetMisses:0,typeFallbacks:0,declarationChecks:0,skippedUnrequestedCallers:0}}function vo(t){return{...t,callerLookupMs:Math.round(t.callerLookupMs),expressionSymbolMs:Math.round(t.expressionSymbolMs),typeSymbolMs:Math.round(t.typeSymbolMs),targetLookupMs:Math.round(t.targetLookupMs),declarationsMs:Math.round(t.declarationsMs),declarationLocationMs:Math.round(t.declarationLocationMs),indexedLookupMs:Math.round(t.indexedLookupMs)}}function wr(){return{cacheHits:0,cacheMisses:0,nodeHits:0,nodeMisses:0,scanFiles:0,identifiers:0,symbolLookups:0,aliasResolutions:0,targetHits:0,targetMisses:0,requestedHits:0,scanMs:0,packageRefsMs:0,semanticRefsMs:0,packageReferenceCount:0,referenceCount:0,preciseSearchFailures:0,hierarchyDefinitions:0,hierarchyFamilies:0,hierarchyReferences:0,hierarchyMs:0}}function Er(t){return{...t,scanMs:Math.round(t.scanMs),packageRefsMs:Math.round(t.packageRefsMs),semanticRefsMs:Math.round(t.semanticRefsMs),hierarchyMs:Math.round(t.hierarchyMs)}}function xo(t,e,n){for(let r of e){let i=t.get(r)??[];i.push(...n),t.set(r,i)}}function Mo(t){let e=new Set,n=[];for(let r of t){let i=`${r.symbol}|${r.file}|${r.line}`;e.has(i)||(e.add(i),n.push(r))}return n}function Nr(t){return t.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}import{createHash as Co}from"crypto";import{readFileSync as Do}from"fs";import{dirname as To,join as Be}from"path";var We=2,Po="typescript-semantic";function _r(t){let e=Be(t,Po);return{rootDir:e,requestDir:Be(e,"requests"),responseDir:Be(e,"responses")}}function jr(t){try{let e=JSON.parse(Do(Be(To(t),"meta.json"),"utf8"));return e.version!==2&&e.version!==3||typeof e.status!="string"||typeof e.updatedAt!="string"||e.fingerprint===void 0?null:Co("sha256").update(JSON.stringify({version:e.version,status:e.status,updatedAt:e.updatedAt,fingerprint:e.fingerprint,indexedLanguages:e.indexedLanguages})).digest("hex")}catch{return null}}var No=12e4,Ao=5;function qr(t,e,n={}){let r=new jt(t,n),i=null,s=null,o=process.env.SCIP_QUERY_SKIP_WATCH_SERVICE==="1",a=()=>(i??=Ar(t,e),i),c=(u,f,d)=>{if(o)return d();try{return f(r.request(u))}catch{return o=!0,d()}},l=(u,f)=>c({kind:"references",definitions:[...u],...f?.exact?{exact:!0}:{}},d=>Wr(d),()=>a().referencesForDefinitions?.(u,f)??new Map(u.map(d=>[d.symbolId,a().referencesFor(d)]))),p=u=>c({kind:"callees",definitions:[...u]},f=>Wr(f),()=>a().calleesForDefinitions?.(u)??new Map(u.map(f=>[f.symbolId,a().calleesFor(f)])));return{language:"typescript",availability:()=>(s??=c({kind:"availability"},Lo,()=>a().availability()),s),importUsage:u=>c({kind:"import-usage",file:u},f=>f,()=>a().importUsage(u)),referencesFor:u=>l([u]).get(u.symbolId)??[],referencesForDefinitions:l,referenceFragmentsForFiles:u=>c({kind:"reference-fragments",files:[...u]},f=>jo(f),()=>a().referenceFragmentsForFiles?.(u)??new Map),calleesFor:u=>p([u]).get(u.symbolId)??[],calleesForDefinitions:p,signatureFor:u=>c({kind:"signature",definition:u},Oo,()=>a().signatureFor(u)),dispose:()=>i?.dispose?.()}}var jt=class{constructor(e,n={}){this.db=e;this.runtime=n.runtime??Bo,this.timeoutMs=n.timeoutMs??Uo(),this.cacheDir=Eo(e.config.dbPath),this.projectRoot=rn(e.config.projectRoot)}db;runtime;timeoutMs;cacheDir;projectRoot;request(e){let n=ur(this.cacheDir),r=_r(this.cacheDir),i=vt(n.statePath);if(!Br(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript semantic service is not running.");let s=jr(this.db.config.dbPath);if(!s)throw new Error("Published TypeScript generation identity is unavailable.");let o=this.runtime.randomId(),a=Ur(r.requestDir,`${o}.json`),c=Ur(r.responseDir,`${o}.json`),l=this.runtime.now()+this.timeoutMs;Lr(r.requestDir,{recursive:!0}),Lr(r.responseDir,{recursive:!0}),be(a,{protocolVersion:We,id:o,generation:s,deadlineAtMs:l,profileEnvironment:Kt(),request:e});try{for(;this.runtime.now()<=l;){if(Fo(c))return _o(wo(c,"utf8"),o,s);let p=vt(n.statePath);if(!Br(p,this.projectRoot,this.runtime))throw new Error("TypeScript semantic service stopped while processing a request.");this.runtime.sleep(Ao)}throw new Error(`TypeScript semantic service timed out after ${this.timeoutMs}ms.`)}finally{Or(a,{force:!0}),Or(c,{force:!0})}}};function Br(t,e,n){let r=t!==null&&n.now()-Date.parse(t.heartbeatAt)<=lr,i=t?.typescriptSemantic?.busyUntil!==void 0&&n.now()<=Date.parse(t.typescriptSemantic.busyUntil);return t!==null&&t.projectRoot===e&&t.typescriptSemantic?.protocolVersion===We&&n.isProcessAlive(t.pid)&&(r||i)}function _o(t,e,n){let r=JSON.parse(t);if(r.protocolVersion!==We||r.id!==e||r.ok===!0&&r.generation!==n)throw new Error("TypeScript semantic service wrote an incompatible response.");if(r.ok===!0)return r.response;throw new Error(typeof r.error=="string"?r.error:"TypeScript semantic service request failed.")}function Wr(t){if(!Array.isArray(t))throw new Error("TypeScript semantic service wrote an invalid numeric map.");return new Map(t)}function jo(t){if(!Array.isArray(t))throw new Error("TypeScript semantic service wrote an invalid string map.");return new Map(t)}function Lo(t){if(!t||typeof t!="object"||typeof t.available!="boolean")throw new Error("TypeScript semantic service wrote invalid availability.");return t}function Oo(t){if(t!==null&&typeof t!="string")throw new Error("TypeScript semantic service wrote an invalid signature.");return t}function Uo(){let t=Number(process.env.SCIP_TYPESCRIPT_SEMANTIC_TIMEOUT_MS);return Number.isInteger(t)&&t>0?t:No}var Bo={now:Date.now,randomId:ko,sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)},isProcessAlive:he};var zr=new Ae;Wt({name:"semantic-provider",groups:["semantic-provider"],clearAll:t=>zr.clear(t)});function Lt(t,e){let n=Wo(e)??"typescript";return zr.getOrCreate(t,n,()=>n==="rust"?sr(t.config.projectRoot,{sourceImportUsageResolver:{importUsageFacts:r=>Cn(t,r)},calleeSymbolResolver:Mn(t),sourceZeroCalleeOracle:r=>qo(t,r),scipOccurrenceCalleeOracle:r=>cr(t,r)}):qr(t,e))}function Wo(t){return t?Gt(t)==="rust"?"rust":j(t)?"typescript":null:"typescript"}function qo(t,e){let n=me(t,e.relativePath);if(!n||n.language!=="rust")return!1;let r=n.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine&&i.name===e.leaf)??n.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine);return r?!n.callSites.some(i=>i.line>=r.startLine&&i.line<=r.endLine):!1}import{readFileSync as Ko}from"fs";import{dirname as Vo,join as Jo}from"path";function ze(t){let e=qe(t.projectFiles),n=new Set(e),r=new Map(t.snapshot.files.map(u=>[u.path,u])),i=t.snapshot.files.filter(u=>{let f=nt(u.path,["typescript"]);return f==="config"||f==="ambient"}).map(u=>u.path),s=qe([...e,...i]),o=s.find(u=>!r.has(u)),a=new Set(t.snapshot.files.map(u=>u.path)).size!==t.snapshot.files.length,c=!o&&s.some(u=>$r(r.get(u))),l=Ye(JSON.stringify({pnpmWorkspaces:t.snapshot.pnpmWorkspaces,typescriptProjectMode:t.snapshot.typescriptProjectMode,typescriptProjects:qe(t.snapshot.typescriptProjects),membership:e})),p=new Map;return{identityFor(u,f){if(!n.has(u))return te("target-outside-project");if(a)return te("duplicate-input-path");if(o)return te("missing-input-fingerprint");if(c)return te("unreadable-input");let d=[],m,h;if(t.graph===null)d.push("dependency-graph-unavailable"),h="whole-project",m=s;else{let v=$o(u,t.graph,p);if(v.find(P=>!r.has(P)))return te("missing-input-fingerprint");if(m=qe([...v,...i]),m.some(P=>$r(r.get(P))))return te("unreadable-input");h="dependency-closure"}let y=m.map(v=>Ho(r.get(v)));return{version:1,key:Ye(JSON.stringify({version:1,engineIdentity:t.engineIdentity,schemaVersion:f,projectIdentity:l,inputs:y})),mode:h,inputFiles:m,reasons:d}}}}function zo(t,e){let n=new Set,r=[t];for(let i=0;i<r.length;i+=1){let s=r[i];if(!(s===void 0||n.has(s))){n.add(s);for(let o of[...e.get(s)??[]].sort())n.has(o)||r.push(o)}}return[...n].sort()}function $o(t,e,n){let r=n.get(t);if(r)return r;let i=zo(t,e);return n.set(t,i),i}function Ho(t){return{path:t.path,size:t.size,hash:t.hash}}function $r(t){return t.size<0||t.hash==="unreadable"}function te(t){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[t]}}function qe(t){return[...new Set(t)].sort()}var Yo=zt("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function Ot(t,e,n){let r=Yo.get(t,()=>Go(t));if(!r)return null;let i=`${n}\0${e}`,s=r.identities.get(i);if(s)return s;let o=r.builder.identityFor(e,n);return r.identities.set(i,o),o}function fe(t){return Y(t,{includeIgnored:!1}).filter(j).sort()}function Go(t){try{let e=JSON.parse(Ko(Jo(Vo(t.config.dbPath),"meta.json"),"utf8")),n=Sn(e.fingerprint);return n?{builder:ze({projectFiles:fe(t),snapshot:n,graph:ye(t),engineIdentity:Le()}),identities:new Map}:null}catch{return null}}var Ut="typescript-reference-fragment-v2",He=Vt({kind:"typescript-reference-fragments",invalidation:Jt("typescript-reference-fragments"),serialize:t=>JSON.stringify(t),deserialize:Xo});function Nu(t,e,n,r=t){let i=fe(t),s=ze({projectFiles:i,snapshot:e,graph:ye(t),engineIdentity:Le()}),o=[...n].map(([a,c])=>({relativePath:a,contentHash:s.identityFor(a,Ut).key,value:[...c]}));if(o.some(a=>a.contentHash===null))throw new Error("TypeScript reference fragment identity is unavailable for an affected document.");return He.writeBatch(r,o.map(a=>({...a,contentHash:a.contentHash}))),o.length}function Au(t,e,n){let r=e.filter(s=>j(s.relativePath));if(r.length===0)return $e("no TypeScript definitions");let i=$e("shadow did not run");return C("typescript.reference-fragments.shadow",()=>{try{let s=Lt(t,r[0].relativePath);if(!s.availability().available||!s.referenceFragmentsForFiles)return i=$e("TypeScript reference fragment provider is unavailable"),i;let o=fe(t),a=new Set(o),c=s.referenceFragmentsForFiles(o),l=Ue(r,c),p=Dr(r,Qo(n,a),l);if(!p.passed)return i={state:"failing",files:o.length,keyedFiles:0,writtenFiles:0,...p},i;let u=[];for(let f of o){let d=Ot(t,f,Ut);d?.key&&u.push({relativePath:f,contentHash:d.key,value:c.get(f)??[]})}return He.writeBatch(t,u),i={state:"passing",files:o.length,keyedFiles:u.length,writtenFiles:u.length,...p},i}catch(s){return i=$e(s instanceof Error?s.message:String(s)),i}},()=>({...i}))}function Qo(t,e){return new Map([...t].map(([n,r])=>[n,r.filter(i=>e.has(i.file))]))}function _u(t,e){if(e.length===0)return{references:new Map,files:0,cacheHits:0,cacheMisses:0,computedFiles:0};let n="fallback",r=0,i=0,s=0,o=0;return C("typescript.reference-fragments.materialize",()=>{try{let a=fe(t);r=a.length;let c=new Map,l=new Map,p=[];for(let d of a){let m=Ot(t,d,Ut);if(!m?.key)return null;c.set(d,m.key);let h=He.read(t,d,m.key);h===null?(s+=1,p.push(d)):(i+=1,l.set(d,h))}if(s===0)return n="hit",{references:Ue(e,l),files:r,cacheHits:i,cacheMisses:s,computedFiles:o};let u=Lt(t,e[0].relativePath);if(!u.availability().available||!u.referenceFragmentsForFiles)return null;let f=u.referenceFragmentsForFiles(p);if(p.some(d=>!f.has(d)))return null;o=f.size,He.writeBatch(t,p.map(d=>({relativePath:d,contentHash:c.get(d),value:f.get(d)??[]})));for(let[d,m]of f)l.set(d,m);return n="computed",{references:Ue(e,l),files:r,cacheHits:i,cacheMisses:s,computedFiles:o}}catch{return null}},()=>({state:n,files:r,cacheHits:i,cacheMisses:s,computedFiles:o}))}function $e(t){return{state:"unavailable",files:0,keyedFiles:0,writtenFiles:0,expectedCount:0,actualCount:0,missing:[],extra:[],reason:t}}function Xo(t){try{let e=JSON.parse(t);return!Array.isArray(e)||!e.every(Zo)?null:e}catch{return null}}function Zo(t){if(!t||typeof t!="object")return!1;let e=t,n=e.location;return typeof e.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}export{cn as a,Jr as b,et as c,oa as d,Qr as e,aa as f,he as g,be as h,Tn as i,Va as j,Ja as k,Za as l,nt as m,Sn as n,da as o,yi as p,rt as q,ba as r,lr as s,ur as t,vt as u,j as v,Lt as w,Wo as x,ze as y,Ot as z,Nu as A,Au as B,_u as C};
5
- //# sourceMappingURL=chunk-NLNZK7RL.js.map
@@ -1,2 +0,0 @@
1
- import{b as I,f as Y,g as _}from"./chunk-CAKPEQZB.js";import{a as M}from"./chunk-BGBBVSH4.js";import{b as X,e as Z,f as $,g as ee}from"./chunk-PLDIXTKR.js";import{a as z,f as J,g as Q,i as w,j as U,n as v}from"./chunk-YGBHQOB2.js";import{a as B}from"./chunk-AOSFSYEA.js";import{a as V,g as T,h as P,j as H,k as O,s as D,u as G,v as W,w as N}from"./chunk-AYRHVJXW.js";import{m as F}from"./chunk-GAE7WCBK.js";import{B as R,C as K,L as j}from"./chunk-WAU7HVDI.js";import{B as h,s as E,y as A}from"./chunk-FC5K7T35.js";import{a as q}from"./chunk-64MNV6AB.js";function ne(n,e,t){let r=e.identifierResolution==="strict"?w:U,l=e.candidateNames?J(e.candidateNames):null,o=0,f=0,m=0,p=0,y="";for(let a of e.paths)if(o+=1,y=a,!(!R(a)&&!(e.includeVueSfc&&K(a)))&&!n.isIgnored(a)&&!e.skipPath?.(a))try{if(l&&!Q(A(n,a),l))continue;f+=1;let S=(s,u,L,b)=>{if(e.candidateNames&&!e.candidateNames.has(s))return;m+=1;let g=e.resolveTargets?e.resolveTargets({sourceFile:a,name:s,kind:u,defaultTargets:b}):b();for(let k of g)p+=1,t({sourceFile:a,name:s,target:k,occurrences:L,kind:u})},C=z(n,a);for(let[s,u]of C)S(s,"identifier",u.length,()=>r(n,a,s));for(let s of F(n,a,{includeCrossLanguageDispatchNames:e.includeCrossLanguageDispatchNames,includeRustAttributeNames:e.includeRustAttributeNames})){let u=s.kind==="cross-language-dispatch"?()=>w(n,a,s.name):()=>r(n,a,s.name);S(s.name,s.kind,s.occurrences,u)}}finally{e.afterPath?.(a),o%10===0&&E("source-reference-scan.progress",()=>{},()=>({scannedPaths:o,currentPath:y,candidateMatchedPaths:f,visitedNames:m,visitedHits:p}))}}function te(n,e={}){let{scope:t,files:r,minLoc:l=1,maxLoc:o=Number.POSITIVE_INFINITY,excludeSymbol:f,excludeEntrySurfaces:m=!1,excludeTypesFiles:p=!1,excludeRootedSymbols:y=!1,requireFunctionLikeSymbol:a=!1,requireCallableSymbol:x=!1,excludeRustTraitImplMembers:S=!1,includeSuppressed:C=!1,sortByLocDesc:s=!1}=e,u=[],L=oe(n,{scope:t,files:r,requireFunctionLikeSymbol:a,requireCallableSymbol:x}),b=new Map,g=new Map,k=i=>{let c=b.get(i);if(c!==void 0)return c;let d=Y(n,i);return b.set(i,d),d},re=i=>{let c=g.get(i);if(c!==void 0)return c;let d=I(i);return g.set(i,d),d};for(let i of L){let c=i.relativePath;if(n.isIgnored(c)||m&&k(c)||!ae(i,{requireFunctionLikeSymbol:a,requireCallableSymbol:x})||f!==void 0&&i.symbol===f)continue;let d=M(i);d<l||d>o||p&&se(c)||y&&_(n,i.symbol,c)||S&&H(i.symbol)||re(c)!=="test"&&(O(i.symbol)||!C&&h(n,c,i.startLine)||u.push(i))}return s?u.sort((i,c)=>M(c)-M(i)):u}function oe(n,e){return e.files!==void 0?[...new Set(e.files.map(r=>r.replace(/\\/g,"/")))].sort().filter(r=>!e.scope||r.includes(e.scope)).flatMap(r=>D(n,r)):e.requireCallableSymbol?N(n,{scope:e.scope,symbolMatches:T,sqlPrefilter:"callable"}):e.requireFunctionLikeSymbol?N(n,{scope:e.scope,symbolMatches:P,sqlPrefilter:"function-like"}):W(n,e.scope)}function ae(n,e){return e.requireCallableSymbol?T(n.symbol):e.requireFunctionLikeSymbol?P(n.symbol):n.isFunctionLike}function se(n){return(n.split("/").pop()??"").includes("types")}var ie=class{constructor(e){this.db=e}db;scopedDefinitions(e){return G(this.db,e)}definitionsForFile(e){return D(this.db,e)}productionCallableDefinitions(e={}){return te(this.db,e)}calleeMap(e,t={}){return X(this.db,e,{...t,semanticEvidence:v})}crossFileCallerMap(e,t={}){return Z(this.db,e,{...t,semanticEvidence:v})}sourceFallbackCallerFiles(e,t={}){return $(this.db,e,t)}callerFileMap(e,t={}){return ee(this.db,e,{...t,semanticEvidence:v})}frameworkReferencedSymbolIds(e){let t=new Map;for(let l of e){if(!l.leaf)continue;let o=t.get(l.leaf)??[];o.push(l.symbolId),t.set(l.leaf,o)}let r=new Set;for(let l of q(this.db,{includeIgnored:!1}))if(R(l)==="rust")for(let{name:o}of F(this.db,l,{includeRustAttributeNames:!0}))for(let f of t.get(o)??[])r.add(f);return r}symbolsWithNonSelfCallees(e,t={}){if(e.length===0)return new Set;let r=new Map(e.map(o=>[o.symbolId,o.symbol])),l=this.calleeMap(e,t);return new Set([...l.entries()].filter(([o,f])=>{let m=r.get(o);return f.some(p=>p.symbol!==m)}).map(([o])=>o))}fileDependencyGraph(e){return B(this.db,e)}fileKind(e){return I(e)}hasSuppressionComment(e){return h(this.db,e.relativePath,e.startLine)}sourceFiles(){return j(this.db)}scanSourceReferences(e,t){ne(this.db,e,t)}callableSignature(e){let t=V(this.db).forFile(e.relativePath,{facts:!0}).facts?.callables.find(r=>r.startLine===e.startLine&&r.endLine===e.endLine);return t?{paramCount:t.paramCount}:null}};export{ie as a};
2
- //# sourceMappingURL=chunk-OAM22BCR.js.map
@@ -1,38 +0,0 @@
1
- import{b as U,c as k,d as D,e as A,k as Y,l as Z}from"./chunk-YGBHQOB2.js";import{d as z}from"./chunk-XAMVIPE2.js";import{d as q,e as X}from"./chunk-MTDBHTSF.js";import{e as w,g as W,s as J,t as L,y as V,z as Q}from"./chunk-AYRHVJXW.js";import{k as R,m as G,p as B}from"./chunk-GAE7WCBK.js";import{B as C,c as K}from"./chunk-WAU7HVDI.js";import{d as $}from"./chunk-FC5K7T35.js";import{a as H}from"./chunk-64MNV6AB.js";function Ge(t,n,e={}){let o=te(t,[n],{additive:e.additive,semantic:e.semantic,semanticEvidence:e.semanticEvidence}),i=e.callableOnly?(o.get(n.symbolId)??[]).filter(a=>W(a.symbol)||a.source==="ast-callsite"):o.get(n.symbolId)??[];return typeof e.limit=="number"?i.slice(0,e.limit):i}function ne(t,n,e){return F(t,[n],e).get(n.symbolId)??[]}function F(t,n,e){let o=ce(t)?de(t,n,{semantic:e.semantic!==!1,semanticEvidence:e.semanticEvidence}):me(t,e.semanticEvidence);return typeof e.limit!="number"?new Map(n.map(i=>[i.symbolId,o.get(i.symbolId)??[]])):new Map(n.map(i=>[i.symbolId,(o.get(i.symbolId)??[]).slice(0,e.limit)]))}var se=$("caller-rows",{clearGroups:["whole-project"]}),re=2e4;function ce(t){return(t.get("SELECT COUNT(*) AS count FROM global_symbols")?.count??0)>re}function me(t,n){return se.get(t,()=>{let e=L(t),o=te(t,e,{semanticEvidence:n}),i=new Map;for(let s of e)i.set(s.symbol,s.symbolId);let a=new Map,l=new Map;for(let s of e){let m=o.get(s.symbolId);if(!(!m||m.length===0))for(let d of m){let c=i.get(d.symbol);if(c===void 0||c===s.symbolId)continue;let f=a.get(c);f||(f=[],a.set(c,f),l.set(c,new Set));let u=`${s.symbol}|${s.relativePath}`;l.get(c).has(u)||(l.get(c).add(u),f.push({symbol:s.symbol,file:s.relativePath,source:"caller-map-inversion"}))}}return a})}function de(t,n,e){let o=e.semantic&&e.semanticEvidence?n.flatMap(s=>{let m=ue(t,s);return m?[m]:[]}):[],i=new Map(o.map(s=>[s.symbolId,s])),a=e.semanticEvidence?.referenceMap(t,o)??new Map,l=new Map;for(let s of n){let m=[],d=new Set,c=u=>{if(u.symbol===s.symbol)return;let r=`${u.symbol}|${u.file}`;d.has(r)||(d.add(r),m.push(u))};for(let u of Z(t,s))u.file!==s.relativePath&&c({symbol:u.enclosingSymbol??u.file,file:u.file,source:"resolved-reference"});let f=i.get(s.symbolId);if(f)for(let u of a.get(f.symbolId)??[]){if(u.file===s.relativePath||t.isIgnored(u.file))continue;let r=Q(J(t,u.file),u.line);c({symbol:r?.symbol??u.file,file:u.file,source:"semantic-reference"})}l.set(s.symbolId,m)}return l}function ue(t,n){let e=q().join(", "),o=X().join(", ");return t.get(`SELECT
2
- d.id AS documentId,
3
- gs.id AS symbolId,
4
- gs.symbol,
5
- d.relative_path AS relativePath,
6
- COALESCE(der.start_line, c.start_line) AS startLine,
7
- COALESCE(der.end_line, c.end_line) AS endLine,
8
- COALESCE(gs.display_name, '') AS leaf,
9
- NULL AS parentTypeName,
10
- CASE WHEN gs.kind IN (${e}) OR gs.symbol LIKE '%().' THEN 1 ELSE 0 END AS isFunctionLike,
11
- CASE WHEN gs.kind IN (${o}) THEN 1 ELSE 0 END AS isTypeLike,
12
- gs.kind AS kind,
13
- gs.documentation AS documentation,
14
- gs.enclosing_symbol AS enclosingSymbol
15
- FROM global_symbols gs
16
- LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
17
- LEFT JOIN chunks c ON c.document_id = der.document_id
18
- JOIN documents d ON d.id = COALESCE(der.document_id, c.document_id)
19
- WHERE gs.id = ?
20
- LIMIT 1`,n.symbolId)??null}function te(t,n,e={}){if(n.length===0)return new Map;let o=e.additive??!1,i=[],a=[];for(let c of n)C(c.relativePath)&&R(t,c.relativePath)!==null?i.push(c):a.push(c);let l=new Map,s=new Map,m=c=>{for(let[f,u]of c){let r=l.get(f);r||(r=[],l.set(f,r));let p=s.get(f);p||(p=new Set,s.set(f,p));for(let E of u){let h=`${E.symbol}|${E.chunkId}`;p.has(h)||(p.add(h),r.push(E))}}};i.length>0&&m(fe(t,i)),e.semantic!==!1&&e.semanticEvidence&&m(he(e.semanticEvidence.calleeMap(t,n)));let d=o?n:a;return d.length>0&&m(Se(t,d)),l}function fe(t,n){let e=new Map,o=be(n,e),i=A(t);for(let[a,l]of o){let s=R(t,a);if(!s)continue;let m=V(l);for(let d of s){let c=m.get(d.line);if(!c)continue;let f=ye(t,a,i,d);f&&f.symbol!==c.symbol&&e.get(c.symbolId).push({symbol:f.symbol,file:f.file,chunkId:d.line,source:"ast-callsite"})}}return e}function be(t,n){let e=new Map;for(let o of t){let i=e.get(o.relativePath);i?i.push(o):e.set(o.relativePath,[o]),n.set(o.symbolId,[])}for(let o of e.values())o.sort((i,a)=>i.endLine-i.startLine-(a.endLine-a.startLine));return e}function ye(t,n,e,o){let i=k(n,e.get(o.calleeLeaf)??[]);if(i.length===0)return null;let a=pe(t,n,i,o.calleeQualifier);return a||D(t,n,i,o.memberAccess)}function pe(t,n,e,o){if(!o||C(n)!=="clojure")return null;let a=B(t,n).filter(l=>l.kind==="namespace"&&l.localName===o&&l.sourcePath).map(l=>l.sourcePath);for(let l of a){let s=e.find(m=>K(l,m.file));if(s)return s}return e.find(l=>/`([^`]+)`\//.exec(l.symbol)?.[1]===o)??null}function Se(t,n){if(n.length===0)return new Map;let o=P(n.map(r=>r.documentId)).flatMap(r=>t.all(`SELECT c.document_id, c.id AS chunk_id, c.start_line, c.end_line, m.symbol_id
21
- FROM mentions m
22
- JOIN chunks c ON m.chunk_id = c.id
23
- WHERE m.role != 1
24
- AND c.document_id IN (${r.map(()=>"?").join(",")})`,...r)),i=new Map;for(let r of o)i.has(r.document_id)||i.set(r.document_id,[]),i.get(r.document_id).push(r);let l=P(o.map(r=>r.symbol_id)).flatMap(r=>t.all(`SELECT gs.id AS symbol_id, gs.symbol,
25
- COALESCE(der.document_id, def_chunk.document_id) AS document_id
26
- FROM global_symbols gs
27
- LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
28
- LEFT JOIN (
29
- SELECT m.symbol_id, MIN(c.document_id) AS document_id
30
- FROM mentions m
31
- JOIN chunks c ON m.chunk_id = c.id
32
- WHERE m.role = 1
33
- AND m.symbol_id IN (${r.map(()=>"?").join(",")})
34
- GROUP BY m.symbol_id
35
- ) def_chunk ON def_chunk.symbol_id = gs.id
36
- WHERE gs.id IN (${r.map(()=>"?").join(",")})`,...r,...r)),s=P([...n.map(r=>r.documentId),...l.flatMap(r=>r.document_id===null?[]:[r.document_id])]),m=new Map(s.flatMap(r=>t.all(`SELECT id, relative_path FROM documents
37
- WHERE id IN (${r.map(()=>"?").join(",")})`,...r).map(p=>[p.id,p.relative_path]))),d=new Map;for(let r of l)d.has(r.symbol_id)||d.set(r.symbol_id,{symbol:r.symbol,file:r.document_id!==null?m.get(r.document_id)??"":""});let c=new Map,f=m,u=ge(n);for(let[r,p]of u){let h=[...i.get(r)??[]].sort((b,S)=>b.start_line-S.start_line||b.end_line-S.end_line),ie=[...p].sort((b,S)=>b.startLine-S.startLine||b.endLine-S.endLine),_=new Set,v=0;for(let b of ie){for(;v<h.length&&h[v].start_line<=b.endLine;)_.add(h[v]),v+=1;for(let y of _)y.end_line<b.startLine&&_.delete(y);let S=new Set,T=[],N=null,ae=()=>{if(N)return N;let y=f.get(b.documentId)??"",g=new Set;if(y){let x=U(t,y),I=Math.max(0,b.startLine),j=Math.min(x.length-1,b.endLine);for(let M=I;M<=j;M+=1)for(let le of x[M])g.add(le)}return N=g,g};for(let y of _){if(y.symbol_id===b.symbolId)continue;let g=d.get(y.symbol_id);if(!g)continue;if(!(y.start_line>=b.startLine&&y.end_line<=b.endLine)){if(!(y.start_line<=b.endLine&&y.end_line>=b.startLine))continue;let M=w(g.symbol);if(!M||!ae().has(M))continue}let I=`${g.symbol}|${y.chunk_id}`;S.has(I)||(S.add(I),T.push({...g,chunkId:y.chunk_id,source:"scip-chunk"}))}c.set(b.symbolId,T)}}return c}var ee=500;function P(t){let n=[...new Set(t)],e=[];for(let o=0;o<n.length;o+=ee)e.push(n.slice(o,o+ee));return e}function ge(t){let n=new Map;for(let e of t){let o=n.get(e.documentId);o?o.push(e):n.set(e.documentId,[e])}return n}function he(t){let n=new Map;for(let[e,o]of t){let i=[];for(let a of o)i.push({symbol:a.symbol,file:a.file,chunkId:-1,source:"semantic-callee"});n.set(e,i)}return n}function oe(t,n,e={}){let o=new Map;if(n&&n.length===0)return o;let i=H(t,{includeIgnored:!1}),a=A(t),l=n??L(t),s=new Set(l.map(d=>d.symbolId)),m=Ie(l);return Me(t,o,i,a,s,m),Ce(t,o,l,s),ve(t,o,i,a,s,m),e.semantic!==!1&&e.semanticEvidence&&Le(o,e.semanticEvidence.callerMap(t,we(l))),o}function Me(t,n,e,o,i,a){for(let l of e){if(!C(l))continue;let s=R(t,l);if(s)for(let m of s){if(a&&!a.has(m.calleeLeaf))continue;let d=k(l,o.get(m.calleeLeaf)??[]);if(!d||d.length===0)continue;let c=D(t,l,d,m.memberAccess);c&&i.has(c.symbolId)&&c.file!==l&&O(n,c.symbolId,l)}}}function Ce(t,n,e,o){let i=Ee(e);for(let a of Re(t,o))t.isIgnored(a.relative_path)||_e(a,i.get(a.symbol_id))||O(n,a.symbol_id,a.relative_path)}function Re(t,n){return z(t,n?[...n]:void 0)}function Ee(t){let n=new Map;for(let e of t)n.set(e.symbolId,{docId:e.documentId,startLine:e.startLine,endLine:e.endLine});return n}function _e(t,n){return!!n&&n.docId===t.document_id&&t.chunk_start>=n.startLine&&t.chunk_end<=n.endLine}function ve(t,n,e,o,i,a){for(let l of e){if(C(l)!=="rust")continue;let s=G(t,l,{includeRustAttributeNames:!0});if(s.length!==0)for(let{name:m}of s){if(a&&!a.has(m))continue;let d=o.get(m);if(d)for(let c of d)i.has(c.symbolId)&&c.file!==l&&O(n,c.symbolId,l)}}}function O(t,n,e){let o=t.get(n);o||(o=new Set,t.set(n,o)),o.add(e)}function Ie(t){let n=new Set;for(let e of t){let o="leaf"in e&&typeof e.leaf=="string"?e.leaf:"symbol"in e&&typeof e.symbol=="string"?w(e.symbol):"";o&&n.add(o)}return n.size>0?n:null}function we(t){return t.filter(n=>"relativePath"in n&&"symbol"in n&&"leaf"in n)}function Le(t,n){for(let[e,o]of n){let i=t.get(e);i||(i=new Set,t.set(e,i));for(let a of o)i.add(a)}}function en(t,n,e){return ne(t,n,e)}function nn(t,n,e){return F(t,n,e)}function ke(t,n,e={}){return oe(t,n,e)}function De(t,n,e={}){return Y(t,n,e)}function tn(t,n,e={}){let o=ke(t,n,{semantic:e.semantic,semanticEvidence:e.semanticEvidence});return e.sourceFallback===!1?o:Ae(o,De(t,n))}function Ae(t,n){let e=new Map;for(let[o,i]of t)e.set(o,new Set(i));for(let[o,i]of n){let a=e.get(o)??new Set;for(let l of i)a.add(l);e.set(o,a)}return e}export{Ge as a,te as b,en as c,nn as d,ke as e,De as f,tn as g,Ae as h};
38
- //# sourceMappingURL=chunk-PLDIXTKR.js.map
@@ -1,2 +0,0 @@
1
- import{b as r}from"./chunk-SJ6XSCG7.js";import{x as e}from"./chunk-AYRHVJXW.js";function l(t,s){let o=r(t,s);return e(t,o).map(({relativePath:n,...a})=>a)}export{l as a};
2
- //# sourceMappingURL=chunk-UJKZQLDB.js.map
@@ -1,3 +0,0 @@
1
- import{a as Ae}from"./chunk-PJENL245.js";import{a as Te}from"./chunk-5TZ2MQBG.js";import{a as ce,b as F,e as le}from"./chunk-FRXB74RQ.js";import{a as he,c as ge,d as pe,e as v}from"./chunk-24ET4VLC.js";import{a as Re}from"./chunk-2E7QY4B5.js";import{a as De}from"./chunk-HCSTQGQE.js";import{a as Fe}from"./chunk-C2QSK7E7.js";import{a as we}from"./chunk-Z7M7X3ZG.js";import{a as $e}from"./chunk-IXAALOUP.js";import{a as Ce}from"./chunk-XWJ3JYRG.js";import{a as Se}from"./chunk-PTYQQHZM.js";import{a as me}from"./chunk-5GOBZI34.js";import{b as ue}from"./chunk-53SUJOJA.js";import{a as de,b as fe}from"./chunk-WWCZCH7W.js";import{a as oe,b as se,c as ae,g as _,h as H}from"./chunk-EHU4TZJJ.js";import{b as be}from"./chunk-EGKWRX5I.js";import{a as L,c as ie,d as ne,e as re}from"./chunk-FB6IKAKZ.js";import{a as te}from"./chunk-KMOMNTB4.js";import{a as ke,e as ve}from"./chunk-HHOJH3RJ.js";import{a as I,c as z,d as O,e as ye}from"./chunk-DO775SYA.js";import{a as ee}from"./chunk-OAM22BCR.js";import{f as x,g as G}from"./chunk-CAKPEQZB.js";import{e as Q}from"./chunk-YGBHQOB2.js";import{d as M,e as R,f as Z,g as P}from"./chunk-AYRHVJXW.js";import{a as X}from"./chunk-GAE7WCBK.js";import{e as V}from"./chunk-WAU7HVDI.js";import{s as Y}from"./chunk-FC5K7T35.js";import{createHash as ct}from"crypto";import{existsSync as K}from"fs";function U(e){let[t,i]=T(e,":"),r=t||"unknown",n=(a={})=>{let s=a.actionTier??We(r);return{sourceAnalyzer:r,actionTier:s,rootCauseKey:a.rootCauseKey??(i||e),label:a.label??`${r} finding`,relatedFiles:a.relatedFiles??[],why:a.why??[],remediation:a.remediation??Je(s,r),file:a.file}};if(!i)return n({rootCauseKey:e,why:["Baseline identity did not include analyzer payload."]});if(["dead","isolated","extract","wrapper","passthrough","stale"].includes(r)){let[a,s]=T(i,":");return n({file:a,relatedFiles:a?[a]:[],rootCauseKey:s?`${a}:${s}`:i,label:`${r} finding`,why:s?[`Baseline subject: ${s}.`]:[]})}if(r==="cycle"){let a=i.split(">").filter(Boolean);return n({relatedFiles:a,rootCauseKey:i,label:"cycle finding",why:a.length>0?[`Cycle path: ${a.join(" > ")}.`]:[]})}if(r==="similar"){let a=i.split("|").filter(Boolean);return n({relatedFiles:[],rootCauseKey:i,label:"similarity finding",why:a.length>0?[`Similar symbols: ${a.join(" | ")}.`]:[]})}if(r==="architecture"){let[a,s]=T(i,":");if(a==="forbidden-edge"){let[c,l]=T(s,":"),o=N(c),f=N(l);return n({actionTier:"direct",rootCauseKey:i,label:"architecture boundary violation",why:[`Declared boundary rule rejects ${o} -> ${f}.`],remediation:`Move the dependency behind an allowed boundary, or deliberately update the ${o} dependency rule and baseline.`})}if(a==="cycle"){let c=s.split("|").filter(Boolean).map(N);return n({actionTier:"direct",rootCauseKey:i,label:"forbidden architecture cycle",why:[`requireAcyclic rejects the connected boundary group: ${c.join(", ")}.`],remediation:"Break the boundary cycle, or deliberately revise the acyclicity rule and baseline."})}if(a==="missing-policy-row"){let c=N(s);return n({actionTier:"direct",rootCauseKey:i,label:"incomplete architecture policy",why:[`requireCompletePolicy rejects the missing outgoing dependency row for ${c}.`],remediation:`Declare the allowed outgoing dependencies for ${c}, including an empty row when it must depend on nothing.`})}}if(r==="drift"){let[a,s]=T(i,":"),[c,l]=T(s,":");return n({actionTier:a==="unused-import"?"direct":"signal",file:c,relatedFiles:[...new Set([c,l].filter(Boolean))],rootCauseKey:i,label:`${a||"drift"} finding`,why:[...a?[`Drift kind: ${a}.`]:[],...l?[`Related dependency: ${l}.`]:[]]})}return n({why:["Baseline analyzer prefix is not recognized by this diff-gate version."]})}function We(e){switch(e){case"dead":case"isolated":case"cycle":case"passthrough":case"architecture":return"direct";case"similar":case"extract":case"wrapper":case"stale":return"signal";default:return"signal"}}function Je(e,t){return e==="direct"?`Fix the new ${t} baseline finding, or knowingly accept it via health --write-baseline.`:`Review the new ${t} baseline signal; fix it if it reflects real debt, or knowingly accept it via health --write-baseline.`}function T(e,t){let i=e.indexOf(t);return i<0?[e,""]:[e.slice(0,i),e.slice(i+t.length)]}function N(e){try{return decodeURIComponent(e)}catch{return e}}import{existsSync as xe,readFileSync as Ge,writeFileSync as Ve}from"fs";import{isAbsolute as Ye,join as Xe}from"path";var Ze=25e3,Qe=2500,et=2500;function tt(e){let t=Fe(e);return t.symbols>=Ze||t.documents>=Qe?et:void 0}var it=".scipquery-baseline.json";function q(e){if(e.startsWith("similar:")){let t=e.slice(8).split("|");return t.length!==2?e:`similar:${t.map(M).sort().join("|")}`}if(e.startsWith("duplicate-bodies:")){let t=e.slice(17),i=t.indexOf(":");if(i<0)return e;let r=t.slice(0,i),n=t.slice(i+1).split("|");return n.length<2?e:`duplicate-bodies:${r}:${n.map(M).sort().join("|")}`}return e}function A(e,t){return t&&Ye(t)?t:Xe(e.config.projectRoot,t??it)}function Ee(e,t={}){let{scope:i}=t,r=tt(e),n=[],a=be(e,{scope:i,...v.dead,scanLimit:r});for(let s of a.symbols)x(e,s.relativePath)||G(e,s.symbol,s.relativePath)||s.kind==="dead-code"&&n.push(`dead:${s.relativePath}:${s.shortName}`);for(let s of $e(e,{scope:i,...v.isolated,scanLimit:r}))x(e,s.relativePath)||G(e,s.symbol,s.relativePath)||n.push(`isolated:${s.relativePath}:${s.shortName}`);for(let s of me(e,{scope:i}))s.kind==="real"&&n.push(`cycle:${nt(s.path)}`);for(let s of ve(e,{scope:i,...v.similar,scanLimit:r}))n.push(`similar:${[s.symbolA,s.symbolB].sort().join("|")}`);for(let s of de(e,{scope:i,...v.duplicateBodies,scanLimit:r}))n.push(`duplicate-bodies:${s.hash}:${s.functions.map(c=>c.symbol).sort().join("|")}`);for(let s of Se(e,{scope:i,...v.extract,scanLimit:r}))n.push(`extract:${s.relativePath}:${s.shortName}`);for(let s of Re(e,{scope:i,...v.wrappers,scanLimit:r}))n.push(`wrapper:${s.file}:${s.shortName}`);for(let s of we(e,{scope:i,...v.passthroughs,scanLimit:r}))n.push(`passthrough:${s.file}:${s.shortName}`);for(let s of De(e,{scope:i,...v.stale,scanLimit:r}))n.push(`stale:${s.file}:${s.shortName}`);for(let s of Ce(e,{scope:i,...v.drift,includePatternDeviations:!1,limit:Number.POSITIVE_INFINITY}).results)s.kind!=="architecture-violation"&&n.push(`drift:${s.kind}:${s.file}:${s.dep}`);return n.push(...O(z(e,{scope:i}))),[...new Set(n.map(q))].sort()}function nt(e){if(e.length===0)return"";let t=0;for(let i=1;i<e.length;i++)e[i]<e[t]&&(t=i);return[...e.slice(t),...e.slice(0,t)].join(">")}function ni(e,t={}){let i=Ee(e,{scope:t.scope}),r=A(e,t.path);return Ve(r,JSON.stringify({version:1,findings:i},null,2)+`
2
- `),{path:r,findingCount:i.length}}function je(e,t={}){let i=A(e,t.path);if(!xe(i))throw new Error(`No baseline found at ${i}. Create one with: scip-query health --write-baseline`);let r=JSON.parse(Ge(i,"utf-8")),n=new Set((r.findings??[]).map(q)),a=Ee(e,{scope:t.scope}),s=new Set(a);return{baselinePath:i,baselineCount:n.size,current:a,newFindings:a.filter(c=>!n.has(c)),fixedFindings:[...n].filter(c=>!s.has(c))}}function Ie(e,t={}){let i=A(e,t.path);if(!xe(i))throw new Error(`No baseline found at ${i}. Create one with: scip-query health --write-baseline`);let r=JSON.parse(Ge(i,"utf-8")),n=new Set((r.findings??[]).map(q).filter(c=>c.startsWith(I))),a=O(z(e,{scope:t.scope})),s=new Set(a);return{baselinePath:i,baselineCount:n.size,current:a,newFindings:a.filter(c=>!n.has(c)),fixedFindings:[...n].filter(c=>!s.has(c))}}import{existsSync as rt,mkdirSync as si,readdirSync as ot,readFileSync as st,writeFileSync as ai}from"fs";import{createHash as li}from"crypto";import{join as W}from"path";var E=W(".scipquery","suppressions");function at(e){return W(e,E)}function Ne(e){let t=at(e);if(!rt(t))return{suppressions:[],warnings:[]};let i=[],r=[];for(let n of ot(t).sort()){if(!n.endsWith(".json"))continue;let a=W(t,n),s;try{s=JSON.parse(st(a,"utf-8"))}catch{r.push(`${E}/${n}: malformed JSON \u2014 ignored`);continue}if(typeof s!="object"||s===null||Array.isArray(s)){r.push(`${E}/${n}: not a suppression object \u2014 ignored`);continue}let c=s;if(typeof c.reason!="string"||c.reason.trim()===""){r.push(`${E}/${n}: missing reason \u2014 ignored`);continue}if(!c.id&&!c.check){r.push(`${E}/${n}: needs an id or a check \u2014 ignored`);continue}i.push(c)}return{suppressions:i,warnings:r}}var Bi=["echo","incomplete-migration","co-change-partner","twin-partner","coverage-contract","architecture","doc-reference","unused-params","new-dead","baseline"];function Ki(e,t={}){let i=t.base??"HEAD",{minTogether:r=6,minConfidence:n=.6,maxEchoChecks:a=Number.POSITIVE_INFINITY,maxHelpers:s=Number.POSITIVE_INFINITY,minSimilarity:c=.8,includeBaseline:l=!1,scanLimit:o}=t,f=t.semantic!==!1,p=t.historyMode??"bounded",u=new Set(t.skip??[]),h=ae(e,{base:i}),m=se(e,{base:i,plan:h}),y=m.changedFiles,S=new Set(y),d=new Set(h.changedFileLines),w=new Set([...S,...d]),$=_(e.config.projectRoot,i,H(h,y)),C=Nt(e.config.projectRoot,i,h,$),g={base:i,changedFiles:y,changedSymbols:m.changedSymbols.length,checksRun:[],skipped:[],suppressed:[],findings:[],attributionNotes:m.attributionNotes,rootCauseGroups:[],note:m.summary.note};if(y.length===0)return g;let k=(j,ze)=>{if(u.has(j)){g.skipped.push({check:j,reason:"skipped via --skip"});return}let Oe=g.findings.length,Ue=g.skipped.length,qe=g.checksRun.length;Y(`diff-gate.check.${j}`,ze,()=>({check:j,changedFiles:y.length,changedSymbols:m.changedSymbols.length,findingsAdded:g.findings.length-Oe,skippedAdded:g.skipped.length-Ue,checksRunAdded:g.checksRun.length-qe}))};return k("echo",()=>ut(e,m.changedSymbols,S,C,a,c,o,f,g)),k("incomplete-migration",()=>bt(e,i,h,s,o,f,$,g)),k("co-change-partner",()=>Ct(e,w,r,n,p,g)),k("twin-partner",()=>St(e,m.changedSymbols,S,o,g)),k("coverage-contract",()=>$t(e,w,g)),k("architecture",()=>Mt(e,g)),k("doc-reference",()=>Ft(e,S,d,h.changedRanges,h.renamedFiles,g)),k("unused-params",()=>xt(e,y,g)),k("new-dead",()=>Gt(e,m.changedSymbols,C,g)),l&&k("baseline",()=>Kt(e,g)),dt(g,[...e.config.suppressions??[],...Ne(e.config.projectRoot).suppressions]),g.rootCauseGroups=lt(g.findings),g}function Mi(e){return e.checksRun.length===0&&e.note===oe}function Pi(e){return e.filter(t=>!t.advisory)}function lt(e){let t=new Map;for(let i of e){let r=i.groupKey??`${i.check}:${i.id}`,n=t.get(r);n||(n={groupKey:r,check:i.check,severity:i.severity,actionTier:i.actionTier,sourceAnalyzer:i.sourceAnalyzer,rootCauseKey:i.rootCauseKey,count:0,findingIds:[],files:new Set,relatedFiles:new Set,message:i.message,remediation:i.remediation},t.set(r,n)),n.count+=1,n.findingIds.push(i.id),n.severity=_e(n.severity,i.severity),n.actionTier=He(n.actionTier,i.actionTier),i.file&&n.files.add(i.file);for(let a of i.relatedFiles??[])n.relatedFiles.add(a)}return[...t.values()].map(i=>({...i,files:[...i.files].sort(),relatedFiles:[...i.relatedFiles].sort()})).sort((i,r)=>r.count-i.count||B(r.severity)-B(i.severity)||i.groupKey.localeCompare(r.groupKey))}function _e(e,t){return B(t)>B(e)?t:e}function B(e){return e==="error"?2:e==="warning"?1:0}function He(e,t){return e?t&&Be(t)>Be(e)?t:e:t}function Be(e){return e==="direct"?2:e==="signal"?1:0}function dt(e,t){if(t.length===0||e.findings.length===0)return;let i=[];for(let r of e.findings){let n=t.find(a=>ft(a,r));n?e.suppressed.push({finding:r,suppression:n}):i.push(r)}e.findings=i}function ft(e,t){return!e.reason||e.reason.trim()===""||e.expiresAt&&Date.parse(e.expiresAt)<=Date.now()||e.id&&e.id!==t.id&&!t.legacySuppressionIds?.includes(e.id)||e.check&&e.check!==t.check||e.file&&e.file!==t.file?!1:!!(e.id||e.check)}function D(e,t){e.findings.push({...t,suppressionHint:`scip-query: ignore ${t.check} ${t.id} -- <reason>`})}function ut(e,t,i,r,n,a,s,c,l){l.checksRun.push("echo");for(let o of t.slice(0,n)){if(!P(o.symbol)||r(o))continue;let f=fe(e,o.symbol,{maxLoc:15,scanLimit:s}).filter(d=>!i.has(d.file)).slice(0,5).map(d=>({otherFile:d.file,otherShort:d.shortName,otherSymbol:d.symbol,similarity:1,similarityBasis:"exact-body",sharedEvidence:[`exact normalized body (${d.loc} LOC)`]}));if(f.length>0){let d=b("echo",o.symbol,o.file),w=b("echo",o.symbol,o.file,...f.map(C=>`${C.otherSymbol}|${C.otherFile}`).sort()),$=f[0];D(l,{id:d,legacySuppressionIds:w===d?void 0:[w],groupKey:d,actionTier:"direct",check:"echo",severity:"warning",evidence:"heuristic",confidence:1,file:o.file,symbol:o.symbol,relatedFiles:[...new Set(f.map(C=>C.otherFile))].sort(),sourceAnalyzer:"duplicate-bodies",rootCauseKey:`${o.symbol}:${$.otherSymbol}`,message:Me(o,f),why:Pe(o,f),remediation:Le("direct",o.shortName,$.otherShort)});continue}let p=ke(e,o.symbol,{minSimilarity:a,limit:5,scanLimit:s,semantic:c,sourceCandidateMode:"target-pruned"}),u=[];for(let d of p){let w=d.fileA===o.file?d.fileB:d.fileA,$=d.fileA===o.file?d.shortNameB:d.shortNameA,C=d.fileA===o.file?d.symbolB:d.symbolA;i.has(w)||u.push({otherFile:w,otherShort:$,otherSymbol:C,similarity:d.similarity,similarityBasis:d.similarityBasis??"callees",sharedEvidence:d.sharedCallees})}if(u.length===0)continue;let h=u[0],m=b("echo",o.symbol,o.file,...u.map(d=>`${d.otherSymbol}|${d.otherFile}`).sort()),y=b("echo",o.symbol,o.file),S=ht(o,u);D(l,{id:y,legacySuppressionIds:m===y?void 0:[m],groupKey:y,actionTier:S,check:"echo",severity:"warning",evidence:"heuristic",confidence:h.similarity,file:o.file,symbol:o.symbol,relatedFiles:[...new Set(u.map(d=>d.otherFile))].sort(),message:Me(o,u),why:Pe(o,u),remediation:Le(S,o.shortName,h.otherShort)})}t.length>n&&l.skipped.push({check:"echo",reason:`echo check capped at ${n} of ${t.length} changed symbols`})}function ht(e,t){return t.some(r=>gt(e.symbol,r))?"direct":"signal"}function gt(e,t){if(t.similarityBasis==="exact-body")return!0;if(t.similarityBasis!=="source-tokens"||t.similarity<.98||t.sharedEvidence.length>8)return!1;let i=R(e),r=R(t.otherSymbol);return!i||!r?!1:i===r?!0:yt(t.sharedEvidence)?!1:pt(i,r)}function pt(e,t){let i=Ke(e),r=Ke(t);if(i.length===0||r.length===0)return!1;let n=new Set(r),a=i.filter(s=>n.has(s)).length;return a>=2&&a/Math.min(i.length,r.length)>=.5}function Ke(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).map(t=>t.toLowerCase()).filter(t=>t.length>=2)}var mt=new Set(["bytes","crypto","hex","num","random","secret","to","token"]);function yt(e){return e.length>=3&&e.every(t=>mt.has(t.toLowerCase()))}function Me(e,t){let i=t[0],r=Math.round(i.similarity*100);return t.length===1?`${e.shortName} (${e.file}) is ${r}% similar to established ${i.otherShort} (${i.otherFile})`:`${e.shortName} (${e.file}) resembles ${t.length} established symbol(s); strongest is ${r}% similar to ${i.otherShort} (${i.otherFile})`}function Pe(e,t){let i=[`${e.shortName} was changed in this diff.`];for(let r of t.slice(0,3))i.push(`${r.otherShort} is outside this diff and scored ${Math.round(r.similarity*100)}% similar by ${r.similarityBasis} evidence.`),i.push(`Shared evidence: ${r.sharedEvidence.slice(0,5).join(", ")||"(none listed)"}.`);return t.length>3&&i.push(`${t.length-3} additional similar match(es) grouped into this finding.`),i}function Le(e,t,i){return e==="direct"?`Extract or reuse the shared behavior with ${i}, or keep the duplicate with a suppression reason.`:`Review whether ${t} is intentionally parallel to the established implementation(s); extract shared behavior only if the product semantics match.`}function bt(e,t,i,r,n,a,s,c){let l=Te(e,{base:t,maxHelpers:r,diffPlan:i,scanLimit:n,semantic:a,baseContentAt:s});if(!l.available){c.skipped.push({check:"incomplete-migration",reason:"no git history"});return}c.checksRun.push("incomplete-migration"),l.note&&c.skipped.push({check:"incomplete-migration",reason:l.note});for(let o of l.findings){let f=o.leftovers.map(d=>`${d.shortName} (${d.file}, ${Math.round(d.containment*100)}% helper / ${Math.round(d.siteCoverage*100)}% site, ${d.migrationScope})`).join(", "),p=o.leftovers.map(d=>`${d.shortName}: ${d.migrationScope} (${d.migrationScopeReasons[0]})`).join("; "),u=[...o.migratedFiles,...o.leftovers.map(d=>d.file)],h=o.leftovers.length===0?void 0:Math.max(...o.leftovers.map(d=>Math.min(d.containment,d.siteCoverage))),m=o.leftovers.some(d=>d.migrationScope==="possible-subtype"),y=b("incomplete-migration",o.helperSymbol,o.helperFile,u.join("|")),S=b("incomplete-migration",o.helperSymbol,o.helperFile);D(c,{id:S,legacySuppressionIds:y===S?void 0:[y],check:"incomplete-migration",severity:"warning",evidence:"heuristic",confidence:h,file:o.helperFile,symbol:o.helperSymbol,relatedFiles:u,message:`new helper ${o.helperShortName} (${o.helperFile}) is wired into ${o.migratedFiles.length} file(s), but ${o.leftovers.length} similar un-migrated site(s) remain: ${f}`,why:[`${o.helperShortName} is new in this diff and already referenced by ${o.migratedFiles.join(", ")}.`,`Helper shape: ${o.helperShape}; ${o.specificHelperCalleeCount}/${o.helperCalleeCount} helper callees are specific enough to score.`,`Unchanged site(s) still contain the helper's callee pattern: ${f}.`,`Migration scope hints: ${p}.`],remediation:m?`Migrate same-scope sites to ${o.helperShortName}; review possible subtype/variant sites before applying the helper.`:`Migrate the remaining sites to ${o.helperShortName}, or confirm they are intentionally different.`})}}function Ct(e,t,i,r,n,a){let s=te(e,{historyMode:n}).directionalCoChangePairsForFiles(t,{minTogether:i,minConfidence:0,maxFilesPerCommit:20});if(!s){a.skipped.push({check:"co-change-partner",reason:"no git history"});return}a.checksRun.push("co-change-partner");let c=new Set,l;for(let o of s){let f=t.has(o.fileA),p=t.has(o.fileB);if(f===p)continue;let u=f?o.fileA:o.fileB,h=f?o.fileB:o.fileA,m=f?o.changesA:o.changesB,y=m>0?o.together/m:0;if(y<r||L(h)||L(u)||!K(`${e.config.projectRoot}/${h}`))continue;let S=`${u}|${h}`;if(c.has(S))continue;c.add(S);let d=b("co-change-partner",u,h,String(o.together)),w=b("co-change-partner",u,h),$=ie(u,h),C=ne({fileA:u,fileB:h,together:o.together,confidence:y,commitScope:o.commitScope,recency:o.recency,subjectContext:o.subjectContext},$,(l??=re(e))(u,h)),g=[u,h].sort().join("|");a.findings.push({id:w,legacySuppressionIds:d===w?void 0:[d],check:"co-change-partner",severity:"warning",evidence:"change-graph",actionTier:"signal",groupKey:`co-change-partner:${g}`,confidence:y,file:u,relatedFiles:[h],sourceAnalyzer:"co-change",rootCauseKey:g,partnerClass:$.partnerClass,partnerClassReasons:$.reasons,commitScope:o.commitScope,recency:o.recency,focusedTogether:o.focusedTogether,broadTogether:o.broadTogether,broadCommitRatio:o.broadCommitRatio,lastTogetherAt:o.lastTogetherAt,recentTogether:o.recentTogether,subjectContext:o.subjectContext,...C?{declaredCouplingSuggestion:C}:{},message:`${u} changed, but ${h} did not \u2014 they change together ${o.together}x (${Math.round(y*100)}% of the time)`,why:[`${u} is in this diff and ${h} is not.`,`Git history shows ${o.together} co-change(s), which is ${Math.round(y*100)}% of changes to the edited side.`,`History context: ${wt(o)}.`,`Subject context: ${kt(o.subjectContext)}.`,...vt(o),`Partner class: ${$.partnerClass} (${$.reasons.join("; ")}).`],remediation:C?`Update ${h} alongside this change, declare the coupling "${C.name}", or confirm the coupling no longer holds.`:`Update ${h} alongside this change, or confirm the coupling no longer holds.`})}}function St(e,t,i,r,n){n.checksRun.push("twin-partner");let a=ue(e,{scanLimit:r}).filter(l=>l.relationship==="divergent"||l.relationship==="identical");if(a.length===0)return;let s=new Map;for(let l of a)for(let o of l.members)s.set(o.symbol,l);let c=new Set;for(let l of t){if(!P(l.symbol))continue;let o=s.get(l.symbol);if(!o)continue;let f=o.members.filter(m=>m.symbol!==l.symbol&&!i.has(m.file));if(f.length===0)continue;let p=[l.symbol,...f.map(m=>m.symbol)].sort().join("|");if(c.has(p))continue;c.add(p);let u=f[0],h=b("twin-partner",l.symbol,l.file,u.symbol);D(n,{id:h,groupKey:`twin-partner:${p}`,check:"twin-partner",severity:"warning",evidence:"heuristic",actionTier:"signal",advisory:!0,confidence:o.relationship==="identical"?1:Math.max(0,1-o.maxDivergence),file:l.file,symbol:l.symbol,relatedFiles:f.map(m=>m.file).sort(),sourceAnalyzer:"twin-drift",rootCauseKey:p,message:`${l.shortName} (${l.file}) changed but its same-name twin ${u.shortName} (${u.file}) did not \u2014 verify the change shouldn't apply to both, or consolidate them.`,why:[`${l.symbol} is in this diff.`,`${u.symbol} shares its (near-)name and is classified '${o.relationship}' with it, but ${u.file} is not in this diff.`,o.relationship==="divergent"?`The two bodies already diverge (~${Math.round(o.maxDivergence*100)}% token difference) \u2014 this diff may widen or narrow that drift.`:"The two bodies were byte-identical before this diff.","Advisory: twin-partner never fails the gate by itself \u2014 see the twin-partner entry in the diff-gate checks table."],remediation:`Update ${u.file} alongside this change, consolidate ${l.shortName}/${u.shortName} into one helper, or confirm the twin should diverge on purpose.`})}}function $t(e,t,i){i.checksRun.push("coverage-contract");let r=e.config.coverageContracts??[];for(let n of r){if(!ge(n,t))continue;let a=he(e,n);if(a.status==="ok")continue;let s=b("coverage-contract",n.name,n.file);D(i,{id:s,groupKey:`coverage-contract:${n.name}`,check:"coverage-contract",severity:a.status==="unavailable"?"warning":"error",evidence:"graph-fact",actionTier:"direct",file:n.file,sourceAnalyzer:"coverage-contracts",rootCauseKey:n.name,message:pe(a),why:[`Contract "${n.name}" declares that ${n.file} (${n.keys.type}) must track ${n.mustEqual.type}.`,a.status==="unavailable"?`The declared side could not be evaluated: ${a.unavailableReason}.`:`Missing: ${a.missing.join(", ")||"none"}. Extra: ${a.extra.join(", ")||"none"}.`,"Either side of this contract changed in this diff."],remediation:a.status==="unavailable"?"Investigate why the declared key set could not be parsed (see the reason above) \u2014 do not treat this as a pass.":`Update ${n.file} so its ${n.keys.type==="object-literal-keys"||n.keys.type==="string-array"?n.keys.identifier:n.keys.marker} matches ${n.mustEqual.type}, or fix the ground-truth source if the declared set is right.`})}}function wt(e){return`${e.commitScope}/${e.recency}; ${e.focusedTogether} focused, ${e.broadTogether} broad-sweep (${Math.round(e.broadCommitRatio*100)}% broad), ${e.recentTogether} recent, last ${Dt(e.lastTogetherAt)}`}function kt(e){let t=e.subjectLabels.length>0?e.subjectLabels.slice(0,5).join(", "):"none inferred",i=e.issueRefs.length>0?e.issueRefs.slice(0,5).join(", "):"none",r=e.sampleSubjects.length>0?e.sampleSubjects.slice(0,3).map(n=>`"${n}"`).join("; "):"none";return`labels ${t}; refs ${i}; samples ${r}; external issue/PR labels ${e.externalIssueLabelStatus}`}function vt(e){let t=[];return e.commitScope==="broad-sweep"&&t.push("Broad-sweep history is weaker than focused co-edits; confirm this is a real coordination contract."),e.recency==="stale"&&t.push("The pair has no co-change in the recent history window; confirm the coupling still holds."),t}function Dt(e){return e<=0?"unknown":new Date(e*1e3).toISOString().slice(0,10)}var J=3;function Ft(e,t,i,r,n,a){a.checksRun.push("doc-reference");let s=F.referenceTargets(e,t,r);if(s.size===0)return;let c=new Set(n.map(o=>o.from)),l=[];for(let o of le(e,s))i.has(o.doc)||ce(e,o.doc)||l.push(Rt(e,o,c));for(let o of Tt(l))D(a,o)}function Rt(e,t,i){let r=t.citedClaims.length>0?t.citedClaims:F.citationContexts(e,t.doc,t.cited),n=F.classifyCitation(r),a=F.hasLineAnchoredCitation(t.citations),s=t.cited.some(p=>i.has(p)||!K(`${e.config.projectRoot}/${p}`)),c=!(a||s),l=t.cited[0]??"",o=b("doc-reference",t.doc,t.cited.join("|")),f=b("doc-reference",t.doc,l);return{id:f,legacySuppressionIds:o===f?void 0:[o],check:"doc-reference",severity:"warning",evidence:"change-graph",actionTier:n.actionTier,groupKey:`doc-reference:${l}`,rootCauseKey:l,confidence:1,file:t.doc,relatedFiles:t.cited,citationKind:n.citationKind,citationKindReasons:n.reasons,citedClaims:r,...c?{advisory:!0}:{},message:`${t.doc} cites ${t.cited.join(", ")} as ${F.citationKindLabel(n.citationKind)} \u2014 changed in this diff, doc untouched`,why:[`${t.cited.join(", ")} changed in this diff.`,`${t.doc} cites the changed file(s) but was not updated in the same diff.`,...n.reasons.map(p=>`Citation kind evidence: ${p}`),c?"Advisory: bare file-mention citation (no line anchor, cited file still present under the same path) \u2014 21.2 calibration found this citation shape low-precision; verify at your leisure.":a?"Blocking: citation includes a line anchor that may now point at the wrong lines.":"Blocking: the cited file was deleted or renamed in this diff \u2014 the citation almost certainly needs an update."],remediation:F.citationRemediation(n.citationKind,t.doc)}}function Tt(e){let t=new Map;for(let r of e){let n=r.rootCauseKey??"",a=t.get(n);a?a.push(r):t.set(n,[r])}let i=[];for(let[r,n]of t)n.length<=J?i.push(...n):i.push(At(r,n));return i}function At(e,t){let i=[...t].sort((f,p)=>(f.file??"").localeCompare(p.file??"")),r=i.slice(0,J).map(f=>({doc:f.file??"",citedClaims:f.citedClaims??[]})),n=i.length-r.length,a=i.every(f=>f.advisory===!0),s=i.reduce((f,p)=>_e(f,p.severity),"info"),c=i.reduce((f,p)=>He(f,p.actionTier),void 0),l=i.map(f=>f.file??"").filter(f=>f.length>0),o=[...new Set(i.flatMap(f=>[f.id,...f.legacySuppressionIds??[]]))];return{id:b("doc-reference","hub-cluster",e),memberFindingIds:o,check:"doc-reference",severity:s,evidence:"change-graph",actionTier:c,groupKey:`doc-reference:${e}`,rootCauseKey:e,confidence:1,file:r[0]?.doc,relatedFiles:[e],citationCount:i.length,citationExemplars:r,suppressedCount:n,...a?{advisory:!0}:{},message:`${e} is cited by ${i.length} doc(s) changed in this diff, doc(s) untouched \u2014 showing ${r.length} example(s), ${n} more damped`,why:[`${e} changed in this diff.`,`${i.length} doc(s) cite it but were not updated in the same diff: ${l.join(", ")}.`,...r.map(f=>`Example \u2014 ${f.doc}: ${f.citedClaims[0]??"(no captured citation text)"}`),`${n} additional doc(s) also cite this file, past the per-hub-file cascade cap (${J}) \u2014 not silently dropped: counted in citationCount/suppressedCount and individually addressable via memberFindingIds.`,a?"Advisory: every citation in this cluster is a bare file-mention (no line anchor, cited file still present).":"Blocking: at least one citation in this cluster is line-anchored or cites a deleted/renamed file."],remediation:`Review the ${r.length} example doc(s) above; ${i.length} total doc(s) cite ${e} the same way \u2014 see citationExemplars and memberFindingIds in --json for the complete list.`}}function xt(e,t,i){i.checksRun.push("unused-params");for(let r of Ae(e,{files:t,limit:50})){let n=b("unused-params",r.symbol,r.file,r.unusedTrailing.join("|")),a=b("unused-params",r.symbol,r.file);D(i,{id:a,legacySuppressionIds:n===a?void 0:[n],check:"unused-params",severity:"warning",evidence:"heuristic",confidence:.85,file:r.file,startLine:r.startLine,endLine:r.endLine,symbol:r.symbol,message:`${r.shortName} (${r.file}) has trailing unused parameter(s): ${r.unusedTrailing.join(", ")}`,why:[`${r.shortName} is in a changed file.`,`The trailing parameter(s) ${r.unusedTrailing.join(", ")} are not referenced in the function body.`],remediation:"Drop the unused trailing parameters and their call-site arguments."})}}function Gt(e,t,i,r){r.checksRun.push("new-dead");let n=new ee(e),a=V(e.config.projectRoot),s=a.length>1;for(let c of t){if(i(c)||c.fanIn>0||n.fileKind(c.file)==="test"||x(e,c.file)||G(e,c.symbol,c.file)||It(c.symbol))continue;let l=b("new-dead",c.symbol,c.file),o=s&&Et(a,c.file)&&jt(e,c.symbol);D(r,{id:l,check:"new-dead",severity:"warning",evidence:o?"heuristic":"graph-fact",confidence:o?.4:.9,file:c.file,symbol:c.symbol,message:o?`${c.shortName} (${c.file}) unconfirmed (cross-package ambiguous-name resolution gap): zero indexed consumers found, but this name is ambiguous project-wide and lives in a workspace package \u2014 verify manually before treating as dead`:`${c.shortName} (${c.file}) was changed but has zero indexed consumers`,why:o?[`${c.shortName} is a changed production symbol in a workspace package.`,"The index, semantic, and source-fallback layers all report zero consumers for this symbol.","Its leaf name is ambiguous project-wide (a same-named definition exists elsewhere), and cross-package consumers reached only through a re-exporting barrel are a known unresolvable shape for this tool \u2014 see docs/plans/2026-07-02-followups.md item 2."]:[`${c.shortName} is a changed production symbol.`,"The index reports zero consumers for this symbol.","The symbol is not in a detected entry surface or configured live root."],remediation:o?"Verify with a direct code search before deleting; this tool cannot confidently resolve this symbol.":"Wire it up, or remove it before it becomes permanent dead code."})}}function Et(e,t){return e.some(i=>t===i.relativeDir||t.startsWith(`${i.relativeDir}/`))}function jt(e,t){let i=R(t);return i?(Q(e).get(i)?.length??0)>1:!1}function It(e){if(Z(e)!=="type")return!1;let t=R(e);return t.startsWith("_Assert")||t.startsWith("Assert")}function Nt(e,t,i,r){let n=new Map(i.renamedFiles.map(s=>[s.to,s.from])),a=r??_(e,t,H(i));return s=>{let c=n.get(s.file)??s.file,l=R(s.symbol);if(!l)return!1;let o=a(c);return o!==null&&Bt(o,l)}}function Bt(e,t){return new RegExp(`\\b${X(t)}\\b`).test(e)}function Kt(e,t){if(!K(A(e))){t.skipped.push({check:"baseline",reason:"no .scipquery-baseline.json \u2014 run health --write-baseline to enable"});return}t.checksRun.push("baseline");let i=je(e);for(let r of i.newFindings.filter(n=>!n.startsWith(I))){let n=U(r),a=b("baseline",r);D(t,{id:a,groupKey:`baseline:${n.sourceAnalyzer}:${n.rootCauseKey}`,check:"baseline",severity:"error",evidence:"baseline",actionTier:n.actionTier,confidence:1,file:n.file,relatedFiles:n.relatedFiles.length>0?n.relatedFiles:void 0,sourceAnalyzer:n.sourceAnalyzer,rootCauseKey:n.rootCauseKey,message:`new ${n.label} vs committed baseline: ${r}`,why:["A committed health baseline exists.","The current health result contains a finding not present in that baseline.",`Underlying analyzer: ${n.sourceAnalyzer}.`,`Inherited action tier: ${n.actionTier}.`,`Root cause key: ${n.rootCauseKey}.`,...n.why],remediation:n.remediation})}}function Mt(e,t){if(!ye(e.config.architecture)){t.skipped.push({check:"architecture",reason:"no closed architecture dependency rows, requireCompletePolicy rule, or requireAcyclic rule configured"});return}if(!K(A(e))){t.skipped.push({check:"architecture",reason:"no .scipquery-baseline.json \u2014 run health --write-baseline to enable"});return}t.checksRun.push("architecture");let i=Ie(e);for(let r of i.newFindings){let n=U(r),a=b("architecture",r);D(t,{id:a,groupKey:`architecture:${n.rootCauseKey}`,check:"architecture",severity:"error",evidence:"baseline",actionTier:"direct",confidence:1,sourceAnalyzer:"architecture",rootCauseKey:n.rootCauseKey,message:`new ${n.label} vs committed baseline: ${r}`,why:["The project declares an enforceable architecture rule.","The current boundary graph contains a violation not present in the committed baseline.",...n.why],remediation:n.remediation})}}function b(e,...t){return`SQ${ct("sha256").update([e,...t].join("\0")).digest("hex").slice(0,12).toUpperCase()}`}export{Ee as a,ni as b,je as c,Bi as d,Ki as e,Mi as f,Pi as g,Nt as h};
3
- //# sourceMappingURL=chunk-WFWQWQK6.js.map
@@ -1,29 +0,0 @@
1
- import{B as W,C as Z,i as te,j as ie,k as re,l as $,w as B,x,z as G}from"./chunk-NLNZK7RL.js";import{a as J}from"./chunk-GAE7WCBK.js";import{d as X,g as U,i as z,k as ee,m as ne,q as O,s as P,v as L,w as j,x as F}from"./chunk-FC5K7T35.js";import{existsSync as Re,readFileSync as Ie}from"fs";import{resolve as De}from"path";function Je(n,e){return N(n,e,t=>{let i=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT
2
- m.symbol_id,
3
- d.relative_path,
4
- COUNT(*) AS ref_count
5
- FROM mentions m
6
- JOIN chunks c ON m.chunk_id = c.id
7
- JOIN documents d ON c.document_id = d.id
8
- WHERE m.role != 1
9
- ${i}
10
- ${n.pathExclusionsFor("d")}
11
- GROUP BY m.symbol_id, d.relative_path`,...t??[])})}function $e(n,e){return N(n,e,t=>{let i=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT DISTINCT m.symbol_id, d.relative_path
12
- FROM mentions m
13
- JOIN chunks c ON m.chunk_id = c.id
14
- JOIN documents d ON c.document_id = d.id
15
- WHERE m.role != 1
16
- ${i}
17
- ${n.pathExclusionsFor("d")}`,...t??[])}).filter(t=>t.symbol_id!==null)}function Be(n,e){return N(n,e,t=>{let i=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT DISTINCT m.symbol_id
18
- FROM mentions m
19
- WHERE m.role != 1
20
- ${i}`,...t??[])}).filter(t=>t.symbol_id!==null)}function ae(n,e){return N(n,e,t=>{let i=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT DISTINCT m.symbol_id, d.relative_path, c.document_id,
21
- c.start_line AS chunk_start, c.end_line AS chunk_end
22
- FROM mentions m
23
- JOIN chunks c ON m.chunk_id = c.id
24
- JOIN documents d ON c.document_id = d.id
25
- WHERE m.role != 1
26
- ${i}
27
- ${n.pathExclusionsFor("d")}
28
- ORDER BY d.relative_path, c.start_line`,...t??[])})}function N(n,e,t){if(!e)return t();if(e.length===0)return[];let i=[];for(let r=0;r<e.length;r+=750)i.push(...t(e.slice(r,r+750)));return i}var ve=/^[A-Za-z_][A-Za-z0-9_]*$/,oe=/\bDefault::default\b/g,Me=/^\.\.\s*Default::default\b/;function se(n,e){let t=new Map,i=new Map;for(let r of e){let a=Y(n,r,i);a!==null&&t.set(r.symbolId,a)}return t}function Y(n,e,t=new Map){let i=xe(e.symbol);if(!i)return null;let r=ae(n,[e.symbolId]);if(r.length===0)return null;let a=new RegExp(`(^|[^A-Za-z0-9_])${J(i)}::default\\b`,"g"),o=new RegExp(`(^|[^A-Za-z0-9_])${J(i)}\\s*$`),f=Ce(n,e.symbolId),m=[];for(let S of r){let d=Ee(n,S.relative_path,t);if(d===null)return null;let l=d.split(/\r?\n/),u=0,p=[],b=0;for(let R=S.chunk_start;R<=S.chunk_end&&R<l.length;R+=1){let D=l[R]??"",w=new Set;a.lastIndex=0;let M;for(;M=a.exec(D);)m.push({file:S.relative_path,line:R,column:M.index+M[1].length+i.length+2}),b+=1;for(let c=0;c<D.length;c+=1){let y=Me.exec(D.slice(c));if(y){if(f&&p.includes(u)){let g=c+y[0].lastIndexOf("default");m.push({file:S.relative_path,line:R,column:g}),w.add(g),b+=1}c+=y[0].length-1;continue}let h=D[c];if(h==="{"){let g=o.test(D.slice(0,c));u+=1,g&&p.push(u);continue}if(h==="}")for(u=Math.max(0,u-1);p.length>0&&p[p.length-1]>u;)p.pop()}for(oe.lastIndex=0;M=oe.exec(D);){let c=M.index+9;if(!w.has(c))return null}}if(b===0)return null}return te(m)}function Ce(n,e){return n.get("SELECT 1 AS present FROM mentions WHERE symbol_id = ? AND role = 1 LIMIT 1",e)?.present===1}function xe(n){let e=/impl#\[([^\]]+)\]\[Default\]default\(\)\./.exec(n)?.[1]??null;return!e||!ve.test(e)?null:e}function Ee(n,e,t){if(t.has(e))return t.get(e)??null;let i=n.get("SELECT text FROM documents WHERE relative_path = ?",e),r=typeof i?.text=="string"?i.text:_e(n,e);return t.set(e,r),r}function _e(n,e){let t=De(n.config.projectRoot,e);if(!Re(t))return null;try{return Ie(t,"utf8")}catch{return null}}function ce(n){let e=new Map;for(let t of n){let i=e.get(t.relativePath)??[];i.push(t),e.set(t.relativePath,i)}return e}var Pe="typescript-import-usage-v1",we="typescript-signatures-v1",Q=X("semantic-prefetched-callees",{clearGroups:["whole-project","source-file","semantic-provider"]}),le=j({kind:"semantic-import-usage",invalidation:F("semantic-import-usage"),serialize:n=>JSON.stringify(n),deserialize:he}),ue=j({kind:"semantic-signatures",invalidation:F("semantic-signatures"),serialize:n=>JSON.stringify(n),deserialize:Le}),fe=L({kind:"typescript-import-usage",invalidation:F("typescript-import-usage"),serialize:n=>JSON.stringify(n),deserialize:he}),me=L({kind:"typescript-signatures",invalidation:F("typescript-signatures"),serialize:n=>JSON.stringify(n),deserialize:je});function k(n){let e=new Map,t=new Set;return{capability:(i,r)=>ye(n,i,r),importUsage:i=>Fe(n,i),references:i=>de(n,i),materializeReferences:(i,r)=>ge(n,i,e,t,r),callerMap:i=>Ae(n,i,e,t),calleeMap:i=>He(n,i),signature:i=>Ue(n,i)}}function Te(n,e){if(e.size===0)return;let t=Q.get(n,()=>new Map);for(let[i,r]of e)t.set(i,[...r])}function fn(n,e){if(!Q.has(n))return{hits:[],misses:[...e]};let t=Q.get(n,()=>new Map),i=[],r=[];for(let a of e)t.has(a.symbolId)?i.push({definition:a,callees:t.get(a.symbolId)??[]}):r.push(a);return{hits:i,misses:r}}function mn(n,e){return k(n).importUsage(e)}function Fe(n,e){if(x(e)==="typescript"){let a="fallback",o=0,f=0,m=0,S=0;return P("typescript.import-usage.materialize",()=>{let d=G(n,e,Pe);if(d?.key){o=1;let u=fe.read(n,e,d.key);if(u)return a="hit",f=1,u;m=1;let p=E(n,e);if(!p)return a="unavailable",[];let b=p.importUsage(e);return fe.write(n,e,d.key,b),a="computed",b}S=1;let l=E(n,e);return l?(a="direct-fallback",l.importUsage(e)):(a="unavailable",[])},()=>({state:a,eligible:o,cacheHits:f,cacheMisses:m,fallbacks:S}))}let t=Se(n,"semantic-import-usage",e);if(t){let a=le.read(n,e,t);if(a)return a}let i=E(n,e);if(!i)return[];let r=i.importUsage(e);return t&&le.write(n,e,t,r),r}function pn(n,e){return k(n).references(e)}function de(n,e){let t=Y(n,e);if(t)return t;let i=re(n,e);if(i)return i;let r=E(n,e.relativePath);return r?r.referencesFor(e):[]}function dn(n,e){return k(n).callerMap(e)}function gn(n,e){let t=new Map,i=new Map;for(let r of e){if(x(r.relativePath)==="typescript"){let a=E(n,r.relativePath);if(!a)continue;let o=i.get(a)??[];o.push(r),i.set(a,o);continue}K(n,t,r,de(n,r))}for(let[r,a]of i){let o=Z(n,a),f=o?.references??(r.referencesForDefinitions?r.referencesForDefinitions(a,{exact:!0}):new Map(a.map(m=>[m.symbolId,r.referencesFor(m)])));!o&&O()&&W(n,a,f);for(let m of a)K(n,t,m,f.get(m.symbolId)??[])}return t}function Ae(n,e,t=new Map,i=new Set){let r=new Map,a=ge(n,e,t,i),o=0;return P("semantic.callers.from-references",()=>{for(let f of e)o+=K(n,r,f,t.get(f.symbolId)??[])},()=>({definitions:e.length,materialized:a.definitions,inMemoryHits:a.inMemoryHits,incompleteInMemoryHits:a.incompleteInMemoryHits,resultRows:r.size,callerFiles:o})),r}function ge(n,e,t,i,r={}){let a=z(n),o=[],f=[],m=[],S=0,d=0,l=0,u=0,p=0,b=0,R=0,_=0,D=0,w=0,M=0,c=0,y=[],h=new Map,g=e.filter(s=>x(s.relativePath)==="typescript"&&!t.has(s.symbolId)&&!i.has(s.symbolId)),v=Z(n,g);if(v){D=g.length,w=v.cacheHits,M=v.cacheMisses,c=v.computedFiles;for(let s of g)t.set(s.symbolId,v.references.get(s.symbolId)??[])}if(P("semantic.references.cache-scan",()=>{for(let[s,I]of ce(e)){let T=[];for(let C of I)t.has(C.symbolId)?d+=1:i.has(C.symbolId)?_+=1:T.push(C);if(T.length===0){R+=1;continue}let H=ke(n,a,s);if(!H){for(let C of T)x(C.relativePath)||(S+=1),m.push(C);continue}b+=1;let be=ee(n,s,H);for(let C of T){let V=be.get(C.symbol)??null;if(V!==null){let q=Ne(V);if(q){l+=1,t.set(C.symbolId,q);continue}u+=1}f.push({definition:C,cacheFingerprint:H})}}},()=>({definitions:e.length,skippedUnsupportedLanguage:S,cacheHits:l,parseFailures:u,misses:f.length,unkeyed:m.length,inMemoryHits:d,incompleteInMemoryHits:_,fullyInMemoryFiles:R,cacheReadFiles:b})),f.length>0||m.length>0){y=[...m,...f.map(s=>s.definition)],h=P("semantic.references.compute-misses",()=>{let s=Oe(n,y,r);return p=s.size,s},()=>({definitions:y.length,misses:f.length,unkeyed:m.length,rows:p}));for(let s of y)h.has(s.symbolId)?(t.set(s.symbolId,h.get(s.symbolId)??[]),i.delete(s.symbolId)):i.add(s.symbolId);for(let{definition:s,cacheFingerprint:I}of f)h.has(s.symbolId)&&ye(n,"semantic-references",s.relativePath).available&&o.push({relativePath:s.relativePath,symbol:s.symbol,projectFingerprint:I,payload:JSON.stringify(h.get(s.symbolId)??[])})}return o.length>0&&P("semantic.references.cache-write",()=>ne(n,o),()=>({entries:o.length})),h.size>0&&W(n,y,h),{definitions:e.length,inMemoryHits:d,incompleteInMemoryHits:_,cacheHits:l,misses:f.length,unkeyed:m.length,skippedUnsupportedLanguage:S,parseFailures:u,computed:p,incomplete:i.size,cacheWrites:o.length,fragmentDefinitions:D,fragmentCacheHits:w,fragmentCacheMisses:M,fragmentComputedFiles:c}}function ke(n,e,t){if(!e)return null;let i=x(t);return i==="typescript"?e:i==="rust"?U(JSON.stringify({kind:"semantic-references",language:i,engine:$(n.config.projectRoot),projectFingerprint:e})):null}function Oe(n,e,t={}){let i=O(),r=new Map,a=0,o=0,f=0,m=0,S=0,d=0,l=0,u=0,p=0;return P("semantic.references.provider-loop",()=>{let b=se(n,e),R=ie(n,e),_=new Map,D=t.prefetchCallees?new Map:null,w=[];for(let c of e){let y,h=()=>(y??=E(n,c.relativePath),y);if(D){let I=h();if(I?.referencesAndCalleesForDefinitions){let T=D.get(I);T?T.push(c):D.set(I,[c]),p+=1}}let g=b.get(c.symbolId);if(g){f+=1,m+=g.length,A(r,c.symbolId,g,i,I=>{l+=1,u+=I});continue}let v=R.get(c.symbolId);if(v){S+=1,d+=v.length,A(r,c.symbolId,v,i,I=>{l+=1,u+=I});continue}let s=h();if(!s){i&&(o+=1);continue}if(i&&(a+=1),s.referencesForDefinitions){let I=_.get(s);I?I.push(c):_.set(s,[c])}else w.push({provider:s,definition:c})}let M=new Set;if(D)for(let[c,y]of D){if(!c.referencesAndCalleesForDefinitions)continue;let h=_.get(c)??[],g=c.referencesAndCalleesForDefinitions(h,y);M.add(c),Te(n,g.callees);for(let v of h){if(!g.references.has(v.symbolId))continue;let s=g.references.get(v.symbolId)??[];A(r,v.symbolId,s,i,I=>{l+=1,u+=I})}}for(let[c,y]of _){if(M.has(c))continue;let h=c.referencesForDefinitions(y);for(let g of y){if(!h.has(g.symbolId))continue;let v=h.get(g.symbolId)??[];A(r,g.symbolId,v,i,s=>{l+=1,u+=s})}}for(let{provider:c,definition:y}of w){let h=c.referencesFor(y);A(r,y.symbolId,h,i,g=>{l+=1,u+=g})}return r},()=>({definitions:e.length,providerHits:a,providerMisses:o,rustDefaultFastPathRows:f,rustDefaultFastPathReferences:m,rustScipOccurrenceFastPathRows:S,rustScipOccurrenceFastPathReferences:d,prefetchCalleeDefinitions:p,definitionsWithReferences:l,referenceCount:u,rows:r.size}))}function A(n,e,t,i,r){n.set(e,t),i&&t.length>0&&r(t.length)}function K(n,e,t,i){let r=0;for(let a of i){if(a.file===t.relativePath||n.isIgnored(a.file))continue;let o=e.get(t.symbolId);o||(o=new Set,e.set(t.symbolId,o));let f=o.size;o.add(a.file),o.size!==f&&(r+=1)}return r}function Ne(n){try{return JSON.parse(n)}catch{return null}}function Sn(n,e){return k(n).calleeMap(e)}function He(n,e){let t=O(),i=new Map,r=0,a=0,o=0,f=0;return P("semantic.callees.provider-loop",()=>{let m=new Map,S=[];for(let d of e){let l=E(n,d.relativePath);if(!l){t&&(a+=1);continue}t&&(r+=1);let u=d;if(l.calleesForDefinitions){let p=m.get(l);p?p.push(u):m.set(l,[u])}else S.push({provider:l,definition:u})}for(let[d,l]of m){let u=d.calleesForDefinitions(l);for(let p of l){let b=u.get(p.symbolId)??[];pe(i,p.symbolId,b,t,R=>{o+=1,f+=R})}}for(let{provider:d,definition:l}of S){let u=d.calleesFor(l);pe(i,l.symbolId,u,t,p=>{o+=1,f+=p})}return i},()=>({definitions:e.length,providerHits:r,providerMisses:a,definitionsWithCallees:o,calleeCount:f,rows:i.size}))}function pe(n,e,t,i,r){t.length>0&&(n.set(e,t),i&&r(t.length))}function hn(n,e){return k(n).signature(e)}function Ue(n,e){if(x(e.relativePath)==="typescript"){let o="fallback",f=0,m=0,S=0,d=0;return P("typescript.signature.materialize",()=>{let l=G(n,e.relativePath,we);if(l?.key){f=1;let p=me.read(n,e.relativePath,l.key)??{};if(Object.prototype.hasOwnProperty.call(p,e.symbol))return o="hit",m=1,p[e.symbol]??null;S=1;let b=E(n,e.relativePath);if(!b)return o="unavailable",null;let R=b.signatureFor(e);return me.write(n,e.relativePath,l.key,{...p,[e.symbol]:R}),o="computed",R}d=1;let u=E(n,e.relativePath);return u?(o="direct-fallback",u.signatureFor(e)):(o="unavailable",null)},()=>({state:o,eligible:f,cacheHits:m,cacheMisses:S,fallbacks:d}))}let t=Se(n,"semantic-signatures",e.relativePath),i=ze(e);if(t){let o=ue.read(n,i,t);if(o)return o.signature}let r=E(n,e.relativePath);if(!r)return null;let a=r.signatureFor(e);return t&&ue.write(n,i,t,{signature:a}),a}function Se(n,e,t){let i=z(n);if(!i)return null;let r=x(t);return r!=="rust"?null:U(JSON.stringify({kind:e,language:r,engine:$(n.config.projectRoot),projectFingerprint:i}))}function ze(n){return`${n.relativePath}\0${n.symbol}`}function he(n){try{let e=JSON.parse(n);return Array.isArray(e)?e:null}catch{return null}}function Le(n){try{let e=JSON.parse(n);if(!e||typeof e!="object")return null;let t=e.signature;return t!==null&&typeof t!="string"?null:{signature:t}}catch{return null}}function je(n){try{let e=JSON.parse(n);if(!e||typeof e!="object"||Array.isArray(e))return null;for(let t of Object.values(e))if(t!==null&&typeof t!="string")return null;return e}catch{return null}}function ye(n,e,t){let i=x(t);if(!i)return{slot:e,language:"typescript",available:!1,reason:"semantic evidence is only available for TypeScript or Rust files"};try{return{slot:e,language:i,...B(n,t).availability()}}catch(r){return{slot:e,language:i,available:!1,reason:r instanceof Error?r.message:String(r)}}}function E(n,e){if(!x(e))return null;let t=B(n,e);return t.availability().available?t:null}export{Je as a,$e as b,Be as c,ae as d,ce as e,k as f,fn as g,mn as h,pn as i,dn as j,gn as k,Oe as l,Sn as m,hn as n};
29
- //# sourceMappingURL=chunk-XAMVIPE2.js.map
@@ -1,4 +0,0 @@
1
- type DiffGateActionTier = 'direct' | 'signal' | 'support';
2
- type DocCitationKind = 'behavioral-claim' | 'configuration-example' | 'guide-reference' | 'intentional-record';
3
-
4
- export type { DiffGateActionTier as D, DocCitationKind as a };
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import{n as a}from"./chunk-MRYPDVOS.js";import"./chunk-26JI77AY.js";export{a as directNavigationQueryCommandDescriptors};
3
- //# sourceMappingURL=direct-navigation-TT23TDBS.js.map