scip-query 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (432) hide show
  1. package/CHANGELOG.md +244 -1
  2. package/README.md +2 -0
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/by-kind-H3P6BR5G.js +2 -0
  5. package/dist/call-graph-VTG2CUOQ.js +2 -0
  6. package/dist/call-graph-evidence-BociKRpF.d.ts +19 -0
  7. package/dist/chunk-2BMSSRBH.js +2 -0
  8. package/dist/{chunk-WIWY3CRX.js → chunk-2GJSD5GY.js} +2 -2
  9. package/dist/{chunk-W5OXRYGE.js → chunk-2M2LSIMY.js} +3 -3
  10. package/dist/{chunk-2LDBDR6J.js → chunk-2N6WBNDC.js} +2 -2
  11. package/dist/{chunk-HOENASQM.js → chunk-2USA3S3P.js} +2 -2
  12. package/dist/chunk-2VAHDDLM.js +133 -0
  13. package/dist/chunk-2XWIUW5Z.js +455 -0
  14. package/dist/chunk-3D4BOXW6.js +20 -0
  15. package/dist/{chunk-BBCIS4DX.js → chunk-3LO4FST5.js} +2 -2
  16. package/dist/chunk-3WTY4LP2.js +3 -0
  17. package/dist/{chunk-UXW33INU.js → chunk-3Z5AMSK6.js} +2 -2
  18. package/dist/{chunk-4ILJCCXV.js → chunk-44IETFOU.js} +2 -2
  19. package/dist/chunk-4FR6GQIT.js +2 -0
  20. package/dist/chunk-4KBTHJLP.js +2 -0
  21. package/dist/{chunk-SSK6LDPC.js → chunk-5BIKR67W.js} +2 -2
  22. package/dist/{chunk-IHGQTTVW.js → chunk-5PROPLHI.js} +2 -2
  23. package/dist/{chunk-TA3QKLLU.js → chunk-5V7EPTII.js} +2 -2
  24. package/dist/{chunk-JS4PGXMV.js → chunk-62LPZCBQ.js} +2 -2
  25. package/dist/{chunk-DBRSYFXR.js → chunk-64O2JHQA.js} +2 -2
  26. package/dist/chunk-6D4F5VWG.js +10 -0
  27. package/dist/{chunk-BHVUJOCQ.js → chunk-6ERFBC3X.js} +2 -2
  28. package/dist/{chunk-ILTDAWEF.js → chunk-6ILKOOGH.js} +2 -2
  29. package/dist/chunk-6MFXCMZC.js +2 -0
  30. package/dist/chunk-6O7FACKB.js +2 -0
  31. package/dist/{chunk-XDQMU3BT.js → chunk-6TS3KOXR.js} +2 -2
  32. package/dist/{chunk-YI2AWIHC.js → chunk-76QOU4PK.js} +2 -2
  33. package/dist/{chunk-7CYG22FH.js → chunk-7DUI77BN.js} +2 -2
  34. package/dist/{chunk-IDFEUFKS.js → chunk-7F7T6DCR.js} +2 -2
  35. package/dist/chunk-7H6VHWWJ.js +2 -0
  36. package/dist/chunk-7HXT6YLU.js +5 -0
  37. package/dist/{chunk-DIRJWYBM.js → chunk-7R4V5ES6.js} +4 -4
  38. package/dist/{chunk-SZHGTCPP.js → chunk-7RIRIADH.js} +2 -2
  39. package/dist/chunk-7ZLWLOGT.js +2 -0
  40. package/dist/{chunk-M2O5NY6W.js → chunk-A4WEAK35.js} +2 -2
  41. package/dist/chunk-AADQLOQ4.js +38 -0
  42. package/dist/{chunk-OLNV6I6U.js → chunk-AN76MGUE.js} +2 -2
  43. package/dist/chunk-ANLNLY66.js +2 -0
  44. package/dist/chunk-ATXPTSEI.js +81 -0
  45. package/dist/{chunk-YPWBKGFU.js → chunk-AX7IDVFT.js} +2 -2
  46. package/dist/chunk-B7MPDEAK.js +3 -0
  47. package/dist/chunk-BBB5FBX4.js +2 -0
  48. package/dist/{chunk-6I6L7Z62.js → chunk-BHKK5RJY.js} +2 -2
  49. package/dist/chunk-BJWFVAA5.js +2 -0
  50. package/dist/{chunk-UHFYCMZO.js → chunk-BKZYTLGE.js} +2 -2
  51. package/dist/chunk-BL6DCHQP.js +2 -0
  52. package/dist/{chunk-TEBQMNVI.js → chunk-BOW7SSQH.js} +2 -2
  53. package/dist/{chunk-OWOOWNJ5.js → chunk-C4RHHCKL.js} +2 -2
  54. package/dist/{chunk-N2ZSIIGR.js → chunk-C7C6AKAT.js} +6 -6
  55. package/dist/chunk-CD6M6LS2.js +16 -0
  56. package/dist/chunk-CFE6PSG6.js +2 -0
  57. package/dist/{chunk-6V5CNXL6.js → chunk-CFNIGQMT.js} +2 -2
  58. package/dist/{chunk-GUFSG5TX.js → chunk-CKBUBRYD.js} +2 -2
  59. package/dist/{chunk-4WNW27SX.js → chunk-CZW5MZ5B.js} +2 -2
  60. package/dist/chunk-DBBZ63ZX.js +2 -0
  61. package/dist/{chunk-HCXEQRFF.js → chunk-DBN7DMJB.js} +2 -2
  62. package/dist/{chunk-6PQNKL3G.js → chunk-DUULLZHZ.js} +2 -2
  63. package/dist/{chunk-Z4CDXYNQ.js → chunk-DV5Y5NOS.js} +2 -2
  64. package/dist/chunk-DZOIKCTM.js +3 -0
  65. package/dist/chunk-E4PKTOL3.js +2 -0
  66. package/dist/{chunk-EG2CPZMJ.js → chunk-E65ELFKU.js} +2 -2
  67. package/dist/{chunk-CNO7TOKL.js → chunk-E7QR35ST.js} +2 -2
  68. package/dist/{chunk-3D3QG236.js → chunk-EFSXAINW.js} +2 -2
  69. package/dist/{chunk-IL676XCC.js → chunk-EHVEIEQN.js} +2 -2
  70. package/dist/{chunk-BE7ZZTMC.js → chunk-EHYDXE3Z.js} +2 -2
  71. package/dist/{chunk-LXABEJX3.js → chunk-EP63Y6LD.js} +2 -2
  72. package/dist/{chunk-QU5XRYB5.js → chunk-EPX6NQN6.js} +2 -2
  73. package/dist/{chunk-FESCRNVV.js → chunk-ETC674NS.js} +2 -2
  74. package/dist/{chunk-OSSESPDX.js → chunk-F5GSBHC6.js} +2 -2
  75. package/dist/chunk-FH3DGXC6.js +2 -0
  76. package/dist/{chunk-YEN6CYC7.js → chunk-FI7VGOR4.js} +2 -2
  77. package/dist/chunk-FJF6VO2P.js +2 -0
  78. package/dist/{chunk-FRUSVINH.js → chunk-FLMTCX5R.js} +2 -2
  79. package/dist/chunk-FVFDOIM3.js +2 -0
  80. package/dist/{chunk-PJFGPYTU.js → chunk-G2HU5WRN.js} +2 -2
  81. package/dist/{chunk-FIQRSHVM.js → chunk-G4ALYS4J.js} +2 -2
  82. package/dist/{chunk-UVGEWT4Y.js → chunk-G56I7K4W.js} +2 -2
  83. package/dist/{chunk-WOIKCX6A.js → chunk-GC4DG2V5.js} +2 -2
  84. package/dist/chunk-GG45PK4S.js +4 -0
  85. package/dist/{chunk-XBGWL66K.js → chunk-GHNPACNP.js} +2 -2
  86. package/dist/{chunk-IICPE7B2.js → chunk-GINH3YQU.js} +2 -2
  87. package/dist/{chunk-HLZTEXRA.js → chunk-GTZZVLKJ.js} +2 -2
  88. package/dist/chunk-GXXW5ZHH.js +2 -0
  89. package/dist/{chunk-B5D7QPBE.js → chunk-HAXXKRTD.js} +2 -2
  90. package/dist/chunk-HEZWBAZY.js +2 -0
  91. package/dist/chunk-HMEWLMML.js +2 -0
  92. package/dist/{chunk-QUU5OBVK.js → chunk-HOBOVYPO.js} +2 -2
  93. package/dist/{chunk-XGZEP6GR.js → chunk-HRFQ6GW5.js} +2 -2
  94. package/dist/{chunk-MPQ4OTBM.js → chunk-HX4X7KG3.js} +2 -2
  95. package/dist/{chunk-FDLOBR6P.js → chunk-HYT2R7LX.js} +2 -2
  96. package/dist/chunk-IKQVBVQL.js +40 -0
  97. package/dist/chunk-J6GLBBRK.js +4 -0
  98. package/dist/{chunk-ZTI4SBFV.js → chunk-J7A4PWFX.js} +2 -2
  99. package/dist/{chunk-OSR2GEHQ.js → chunk-JCSAZ35V.js} +2 -2
  100. package/dist/{chunk-ESIQ66Z7.js → chunk-JDU2IV3A.js} +2 -2
  101. package/dist/chunk-JFMI5SGB.js +4 -0
  102. package/dist/{chunk-W6STWDQI.js → chunk-JJP37RGX.js} +2 -2
  103. package/dist/chunk-JZ2A7LDM.js +5 -0
  104. package/dist/chunk-KNLQGXVH.js +80 -0
  105. package/dist/chunk-KVQCECPR.js +2 -0
  106. package/dist/{chunk-SQXRS7BG.js → chunk-KXXORBZ2.js} +2 -2
  107. package/dist/{chunk-DIUFNHRJ.js → chunk-L5KYH6U3.js} +2 -2
  108. package/dist/chunk-L6XHYJPZ.js +21 -0
  109. package/dist/{chunk-2GRUZAQF.js → chunk-L7KTFEAV.js} +2 -2
  110. package/dist/{chunk-QBE3YX64.js → chunk-LDXHR5EL.js} +2 -2
  111. package/dist/{chunk-HEHOQQKH.js → chunk-MHGDSBFX.js} +2 -2
  112. package/dist/{chunk-PWWAJSKV.js → chunk-MLQVVDG3.js} +2 -2
  113. package/dist/chunk-MOKUWRHO.js +3 -0
  114. package/dist/{chunk-VQILFTEH.js → chunk-MPYAPMNE.js} +2 -2
  115. package/dist/{chunk-UICY4GTQ.js → chunk-MV6SPXCR.js} +2 -2
  116. package/dist/{chunk-HYO3NP5Q.js → chunk-MZPXPSUJ.js} +2 -2
  117. package/dist/{chunk-VZRNID6A.js → chunk-N55KIE46.js} +2 -2
  118. package/dist/{chunk-YF5IB2LF.js → chunk-NB4D3BNM.js} +2 -2
  119. package/dist/{chunk-VVZSBTSU.js → chunk-NGKBOT6G.js} +2 -2
  120. package/dist/{chunk-NJITK2GP.js → chunk-NJGKXKQF.js} +2 -2
  121. package/dist/chunk-NJQISBL4.js +8 -0
  122. package/dist/{chunk-T4N4P2K5.js → chunk-NJT3ZEKY.js} +2 -2
  123. package/dist/{chunk-FPYLNQPT.js → chunk-NKMKZP6A.js} +2 -2
  124. package/dist/chunk-NODFZ6ED.js +2 -0
  125. package/dist/{chunk-BRV7PIFF.js → chunk-NSM5IEVW.js} +2 -2
  126. package/dist/{chunk-3WR4E3A3.js → chunk-NTGUVNR2.js} +2 -2
  127. package/dist/{chunk-VUPHCS7Y.js → chunk-NU3KFF2O.js} +2 -2
  128. package/dist/chunk-NWLVNU66.js +557 -0
  129. package/dist/{chunk-D4N5SQ2M.js → chunk-NYKZMCRC.js} +2 -2
  130. package/dist/{chunk-VNLGKHS6.js → chunk-O6BUXZEH.js} +2 -2
  131. package/dist/chunk-ODPDP7A4.js +3 -0
  132. package/dist/{chunk-JTQVMR42.js → chunk-OHIV323X.js} +2 -2
  133. package/dist/chunk-OIAPEKMT.js +3 -0
  134. package/dist/chunk-OIOC5EHF.js +3 -0
  135. package/dist/{chunk-YBGKCQIS.js → chunk-ONPPQM4G.js} +2 -2
  136. package/dist/{chunk-64BFSI5I.js → chunk-OUHEZBYI.js} +2 -2
  137. package/dist/{chunk-L6PJPETJ.js → chunk-OVGYW7UD.js} +2 -2
  138. package/dist/{chunk-I55I7XXP.js → chunk-OYKU4B3Y.js} +2 -2
  139. package/dist/{chunk-J66VOFW6.js → chunk-POBJ6FR2.js} +2 -2
  140. package/dist/{chunk-CWFP7GM5.js → chunk-PSZPMMWN.js} +2 -2
  141. package/dist/chunk-PXTRBKRK.js +3 -0
  142. package/dist/{chunk-HKGFPJ4T.js → chunk-Q5JRIHT3.js} +2 -2
  143. package/dist/{chunk-P42EIXTA.js → chunk-Q7ATHARX.js} +2 -2
  144. package/dist/{chunk-JYR66JN5.js → chunk-Q7CSKIDM.js} +2 -2
  145. package/dist/{chunk-TRNAEQ6P.js → chunk-QBQE7ZJ5.js} +2 -2
  146. package/dist/{chunk-DULC3QFP.js → chunk-QH22UIXP.js} +2 -2
  147. package/dist/chunk-QXCKQTKR.js +60 -0
  148. package/dist/{chunk-ODDUPDP7.js → chunk-RBAD4GJ2.js} +5 -5
  149. package/dist/{chunk-IZDPJ2QI.js → chunk-RMDPFPNW.js} +2 -2
  150. package/dist/chunk-ROPJDEJZ.js +4 -0
  151. package/dist/{chunk-EKV5HX33.js → chunk-RVZC6TJE.js} +2 -2
  152. package/dist/{chunk-XFA4SSO3.js → chunk-S4QZBKSR.js} +2 -2
  153. package/dist/{chunk-D2DHWI3D.js → chunk-SCPMZ73U.js} +2 -2
  154. package/dist/{chunk-PZL5T7SU.js → chunk-SIAP5RGI.js} +2 -2
  155. package/dist/{chunk-7IWV2EG3.js → chunk-SIX4RFR3.js} +2 -2
  156. package/dist/{chunk-DYGHBZ2N.js → chunk-SKKXTABJ.js} +2 -2
  157. package/dist/{chunk-F7DY272B.js → chunk-SSRFUQBD.js} +2 -2
  158. package/dist/chunk-SYVJEEUJ.js +3 -0
  159. package/dist/{chunk-FGA2U4OR.js → chunk-T3CZAZSI.js} +2 -2
  160. package/dist/chunk-T3I6NHBH.js +2 -0
  161. package/dist/{chunk-EQHFIL6T.js → chunk-T6DWDI5E.js} +2 -2
  162. package/dist/chunk-T6HRIROJ.js +7 -0
  163. package/dist/{chunk-GSP44ENC.js → chunk-TAA7HXHE.js} +2 -2
  164. package/dist/{chunk-BQGB4HBD.js → chunk-TJ2JQYT3.js} +2 -2
  165. package/dist/{chunk-XPDPNWTQ.js → chunk-TULNMD5T.js} +19 -19
  166. package/dist/chunk-U2FPY5XA.js +3 -0
  167. package/dist/chunk-U3SXIMII.js +38 -0
  168. package/dist/{chunk-NOGJXYFO.js → chunk-U6KCHXJ4.js} +2 -2
  169. package/dist/chunk-UH3XSKS5.js +9 -0
  170. package/dist/{chunk-AFHTBORT.js → chunk-UIFUZVCC.js} +2 -2
  171. package/dist/{chunk-7BWFZPPZ.js → chunk-UXKURIVI.js} +2 -2
  172. package/dist/{chunk-2E7CX53V.js → chunk-V2RBODHL.js} +2 -2
  173. package/dist/{chunk-KLFEXGQA.js → chunk-VBKUWB6N.js} +2 -2
  174. package/dist/{chunk-WUN6KBHV.js → chunk-VBV6ALJE.js} +2 -2
  175. package/dist/{chunk-GZIUDL6G.js → chunk-VDGFWCQV.js} +2 -2
  176. package/dist/chunk-VDSDOEWF.js +2 -0
  177. package/dist/{chunk-WDNVY4E7.js → chunk-VZPWVCLN.js} +2 -2
  178. package/dist/chunk-WDSFQDPN.js +2 -0
  179. package/dist/{chunk-CIYLO6SI.js → chunk-WFA35BGR.js} +2 -2
  180. package/dist/{chunk-LMZ5PRUV.js → chunk-WLMP3OCW.js} +2 -2
  181. package/dist/{chunk-3SVF22I5.js → chunk-WSA52GOR.js} +2 -2
  182. package/dist/{chunk-VMPRET3I.js → chunk-X3YVZAKZ.js} +2 -2
  183. package/dist/{chunk-GYIZ4NXB.js → chunk-X6OGVFIT.js} +2 -2
  184. package/dist/{chunk-6HFCYNYE.js → chunk-XKXTR6ZI.js} +2 -2
  185. package/dist/{chunk-6VVV4WRR.js → chunk-Y5DFAW5W.js} +2 -2
  186. package/dist/chunk-YSYPDRD5.js +3 -0
  187. package/dist/{chunk-TQPCBMWT.js → chunk-ZFVPWH62.js} +2 -2
  188. package/dist/chunk-ZGIHTH27.js +2 -0
  189. package/dist/{chunk-OR2E3AGZ.js → chunk-ZGIQN2SX.js} +2 -2
  190. package/dist/{chunk-WNTFFKAX.js → chunk-ZHG4WAHR.js} +2 -2
  191. package/dist/{chunk-DTZCKZEU.js → chunk-ZKB2XUEN.js} +2 -2
  192. package/dist/chunk-ZLMXIQLC.js +21 -0
  193. package/dist/chunk-ZMCQIHI4.js +2 -0
  194. package/dist/cli-main.js +2 -2
  195. package/dist/code-TAVIKWJI.js +2 -0
  196. package/dist/code-result-json-5FEFQCAQ.js +2 -0
  197. package/dist/{command-descriptors-P34VABY5.js → command-descriptors-7BKH53Y3.js} +124 -124
  198. package/dist/dataflow-GFBTVDH3.js +2 -0
  199. package/dist/dependence-slice-GWGQCODG.js +2 -0
  200. package/dist/deps-4QHVDPYA.js +2 -0
  201. package/dist/direct-navigation-4UBC6HNW.js +3 -0
  202. package/dist/entry-map-QCTF4RVY.js +2 -0
  203. package/dist/files-M2UBF5HJ.js +2 -0
  204. package/dist/frontend-profile-roles-D7eCum8P.d.ts +10 -0
  205. package/dist/{health-CPp2Jf1Z.d.ts → health-BI2a9WPy.d.ts} +60 -2
  206. package/dist/hierarchy-2UIHRLW4.js +2 -0
  207. package/dist/imports-WIE3YZOB.js +2 -0
  208. package/dist/index.d.ts +1 -1
  209. package/dist/index.js +1 -1
  210. package/dist/members-YKD636DA.js +2 -0
  211. package/dist/methods-VDF4IMYG.js +2 -0
  212. package/dist/output-continuation-command-4UMDOOLO.js +3 -0
  213. package/dist/output-pagination-2GME6OPY.js +19 -0
  214. package/dist/postinstall.js +1 -1
  215. package/dist/project-reindex-XEQTRCV5.js +3 -0
  216. package/dist/queries/affected.js +1 -1
  217. package/dist/queries/anchors.d.ts +1 -1
  218. package/dist/queries/anchors.js +1 -1
  219. package/dist/queries/architecture.js +1 -1
  220. package/dist/queries/bottlenecks.js +1 -1
  221. package/dist/queries/by-kind.js +1 -1
  222. package/dist/queries/call-graph.d.ts +2 -0
  223. package/dist/queries/call-graph.js +1 -1
  224. package/dist/queries/change-surface.js +1 -1
  225. package/dist/queries/cleanup-plan.js +1 -1
  226. package/dist/queries/co-change.d.ts +20 -2
  227. package/dist/queries/co-change.js +1 -1
  228. package/dist/queries/code.js +1 -1
  229. package/dist/queries/complexity-hotspots.js +1 -1
  230. package/dist/queries/complexity.js +1 -1
  231. package/dist/queries/context.js +1 -1
  232. package/dist/queries/convergence.js +1 -1
  233. package/dist/queries/coupling.js +1 -1
  234. package/dist/queries/cycles.js +1 -1
  235. package/dist/queries/dataflow.js +1 -1
  236. package/dist/queries/dead.d.ts +2 -0
  237. package/dist/queries/dead.js +1 -1
  238. package/dist/queries/decorative-checkers.js +1 -1
  239. package/dist/queries/deep-chains.js +1 -1
  240. package/dist/queries/dependence-slice.js +1 -1
  241. package/dist/queries/dependency-depth.js +1 -1
  242. package/dist/queries/deps.js +1 -1
  243. package/dist/queries/diff-impact.js +1 -1
  244. package/dist/queries/doc-drift.js +1 -1
  245. package/dist/queries/drift.js +1 -1
  246. package/dist/queries/duplicate-bodies.d.ts +28 -1
  247. package/dist/queries/duplicate-bodies.js +1 -1
  248. package/dist/queries/entry-map.d.ts +1 -1
  249. package/dist/queries/entry-map.js +1 -1
  250. package/dist/queries/evidence.js +1 -1
  251. package/dist/queries/extract-candidates.d.ts +50 -23
  252. package/dist/queries/extract-candidates.js +1 -1
  253. package/dist/queries/fan.js +1 -1
  254. package/dist/queries/files.js +1 -1
  255. package/dist/queries/health.d.ts +1 -1
  256. package/dist/queries/health.js +1 -1
  257. package/dist/queries/hierarchy.js +1 -1
  258. package/dist/queries/hotspots.js +1 -1
  259. package/dist/queries/imports.js +1 -1
  260. package/dist/queries/incomplete-migration.js +1 -1
  261. package/dist/queries/index.d.ts +4 -3
  262. package/dist/queries/index.js +1 -1
  263. package/dist/queries/isolated.js +1 -1
  264. package/dist/queries/locality-candidates.js +1 -1
  265. package/dist/queries/members.js +1 -1
  266. package/dist/queries/methods.js +1 -1
  267. package/dist/queries/not-implemented.js +1 -1
  268. package/dist/queries/outline.js +1 -1
  269. package/dist/queries/passthrough-candidates.d.ts +9 -1
  270. package/dist/queries/passthrough-candidates.js +1 -1
  271. package/dist/queries/plan-context.js +1 -1
  272. package/dist/queries/react-component-duplicates.d.ts +19 -3
  273. package/dist/queries/react-component-duplicates.js +1 -1
  274. package/dist/queries/react-hook-candidates.d.ts +22 -3
  275. package/dist/queries/react-hook-candidates.js +1 -1
  276. package/dist/queries/react-large-component-pressure.d.ts +17 -3
  277. package/dist/queries/react-large-component-pressure.js +1 -1
  278. package/dist/queries/recent-duplicates.js +1 -1
  279. package/dist/queries/redundant-reexports.js +1 -1
  280. package/dist/queries/reference-neighborhood.js +1 -1
  281. package/dist/queries/reference-reachability.js +1 -1
  282. package/dist/queries/refs.js +1 -1
  283. package/dist/queries/self-audit.d.ts +7 -1
  284. package/dist/queries/self-audit.js +1 -1
  285. package/dist/queries/similar-chains.js +1 -1
  286. package/dist/queries/similar-files.js +1 -1
  287. package/dist/queries/similar-signatures.js +1 -1
  288. package/dist/queries/similar.js +1 -1
  289. package/dist/queries/slice.js +1 -1
  290. package/dist/queries/source-inspection.js +1 -1
  291. package/dist/queries/source-search.js +1 -1
  292. package/dist/queries/stale-abstractions.js +1 -1
  293. package/dist/queries/surface.js +1 -1
  294. package/dist/queries/symbols.js +1 -1
  295. package/dist/queries/system-map.d.ts +1 -1
  296. package/dist/queries/system-map.js +1 -1
  297. package/dist/queries/system.js +1 -1
  298. package/dist/queries/test-quality.js +1 -1
  299. package/dist/queries/trace.js +1 -1
  300. package/dist/queries/twin-ab.js +1 -1
  301. package/dist/queries/twin-drift.d.ts +22 -6
  302. package/dist/queries/twin-drift.js +1 -1
  303. package/dist/queries/unused-imports.js +1 -1
  304. package/dist/queries/unused-params.js +1 -1
  305. package/dist/queries/value-flow.js +1 -1
  306. package/dist/queries/vue-component-duplicates.js +1 -1
  307. package/dist/queries/vue-composable-candidates.js +1 -1
  308. package/dist/queries/vue-large-view-pressure.js +1 -1
  309. package/dist/queries/wrapper-candidates.d.ts +16 -1
  310. package/dist/queries/wrapper-candidates.js +1 -1
  311. package/dist/query-service-fastpath.js +5 -5
  312. package/dist/query-service-server.js +2 -2
  313. package/dist/refs-JNK5CLM7.js +2 -0
  314. package/dist/refs-pagination-6BLRYGMV.js +2 -0
  315. package/dist/reindex-worker.js +10 -10
  316. package/dist/reindex.js +18 -18
  317. package/dist/runtime.js +4 -4
  318. package/dist/rust-semantic-session-server.js +1 -1
  319. package/dist/rust-semantic-session-worker.js +1 -1
  320. package/dist/rust-semantic-worker.js +1 -1
  321. package/dist/slice-PHPVNCWX.js +2 -0
  322. package/dist/surface-MQX5MPIV.js +2 -0
  323. package/dist/{symbol-resolution-WD5EU5JE.js → symbol-resolution-DBLVXLBC.js} +2 -2
  324. package/dist/system-JOPKV4OG.js +2 -0
  325. package/dist/trace-I2P2YFH4.js +2 -0
  326. package/dist/typescript-mailbox-worker.js +1 -1
  327. package/dist/value-flow-JJVMF7NP.js +2 -0
  328. package/dist/watch-server.js +3 -3
  329. package/docs/COMMAND_REFERENCE.md +2 -2
  330. package/docs/DETECTOR_GUIDE.md +51 -12
  331. package/docs/accuracy-audit-checklist.md +36 -13
  332. package/docs/locality-analyzer-design.md +9 -9
  333. package/package.json +2 -2
  334. package/skills/conductor/SKILL.md +110 -0
  335. package/skills/conductor/agents/openai.yaml +4 -0
  336. package/skills/principal-maintainability-review/SKILL.md +273 -0
  337. package/skills/principal-maintainability-review/agents/openai.yaml +4 -0
  338. package/skills/scip-calibrate/SKILL.md +102 -0
  339. package/skills/scip-calibrate/agents/openai.yaml +4 -0
  340. package/skills/scip-claim-audit/SKILL.md +113 -0
  341. package/skills/scip-claim-audit/agents/openai.yaml +4 -0
  342. package/skills/scip-probe-reachability/SKILL.md +93 -0
  343. package/skills/scip-probe-reachability/agents/openai.yaml +4 -0
  344. package/skills/scip-root-cause/SKILL.md +160 -0
  345. package/skills/scip-root-cause/agents/openai.yaml +4 -0
  346. package/skills/scip-system-compression/SKILL.md +252 -0
  347. package/skills/scip-system-compression/agents/openai.yaml +4 -0
  348. package/skills/scip-system-compression/references/compression-atlas.md +116 -0
  349. package/skills/scip-system-compression/references/compression-patterns.md +87 -0
  350. package/skills/scip-twin-drift/SKILL.md +109 -0
  351. package/skills/scip-twin-drift/agents/openai.yaml +4 -0
  352. package/dist/by-kind-XI2CSWEY.js +0 -2
  353. package/dist/call-graph-UONR6JR5.js +0 -2
  354. package/dist/call-graph-evidence-lZa2dwQA.d.ts +0 -11
  355. package/dist/chunk-2R3V3PSD.js +0 -4
  356. package/dist/chunk-2WC2OEDO.js +0 -4
  357. package/dist/chunk-3FHOF22C.js +0 -21
  358. package/dist/chunk-3JKSW6LJ.js +0 -2
  359. package/dist/chunk-3L2ZBPEX.js +0 -133
  360. package/dist/chunk-3PJABJSU.js +0 -2
  361. package/dist/chunk-4FTZ4P5G.js +0 -2
  362. package/dist/chunk-4UX2F3JX.js +0 -2
  363. package/dist/chunk-5ENOG4VP.js +0 -61
  364. package/dist/chunk-66DVSJQG.js +0 -455
  365. package/dist/chunk-AVRYW5OZ.js +0 -2
  366. package/dist/chunk-BDUVI7TO.js +0 -3
  367. package/dist/chunk-CEEZJXEF.js +0 -2
  368. package/dist/chunk-CJZXN4NU.js +0 -2
  369. package/dist/chunk-COF23M5F.js +0 -2
  370. package/dist/chunk-DHUIOLDT.js +0 -2
  371. package/dist/chunk-DRENNWRG.js +0 -2
  372. package/dist/chunk-E5R6AQ73.js +0 -40
  373. package/dist/chunk-E73UNJTF.js +0 -38
  374. package/dist/chunk-EVFUMY4R.js +0 -3
  375. package/dist/chunk-FBN2FGXG.js +0 -2
  376. package/dist/chunk-FFRKR4EQ.js +0 -2
  377. package/dist/chunk-GAS2LJMP.js +0 -3
  378. package/dist/chunk-HVF5VBG6.js +0 -2
  379. package/dist/chunk-JGKUET5J.js +0 -3
  380. package/dist/chunk-JWTGMPIT.js +0 -80
  381. package/dist/chunk-KFOYCQAJ.js +0 -9
  382. package/dist/chunk-KYSDI3GE.js +0 -5
  383. package/dist/chunk-LDVT66YM.js +0 -2
  384. package/dist/chunk-LQRQN2XA.js +0 -2
  385. package/dist/chunk-MNV5FSBW.js +0 -3
  386. package/dist/chunk-MV3CDXPI.js +0 -38
  387. package/dist/chunk-N5B2NILC.js +0 -5
  388. package/dist/chunk-NOYBFVJA.js +0 -554
  389. package/dist/chunk-NWQXSFFU.js +0 -3
  390. package/dist/chunk-OLIWTZI3.js +0 -3
  391. package/dist/chunk-PP7KNN7L.js +0 -2
  392. package/dist/chunk-PU7T5QYQ.js +0 -2
  393. package/dist/chunk-QGVTFRY2.js +0 -7
  394. package/dist/chunk-QOJONDS7.js +0 -2
  395. package/dist/chunk-RBLQNW26.js +0 -20
  396. package/dist/chunk-RTQ7NEKG.js +0 -81
  397. package/dist/chunk-TPFHAQ2G.js +0 -2
  398. package/dist/chunk-TQZV7KV4.js +0 -2
  399. package/dist/chunk-TY7CRN3Z.js +0 -2
  400. package/dist/chunk-W7CXK74K.js +0 -2
  401. package/dist/chunk-WB3WYIRE.js +0 -4
  402. package/dist/chunk-WK46TNUM.js +0 -3
  403. package/dist/chunk-WYCTJDVR.js +0 -2
  404. package/dist/chunk-XRYABF57.js +0 -8
  405. package/dist/chunk-YPWHBBIS.js +0 -2
  406. package/dist/chunk-YSH6U3L4.js +0 -3
  407. package/dist/chunk-YU5DZUZI.js +0 -10
  408. package/dist/chunk-YWO5DDRC.js +0 -16
  409. package/dist/chunk-ZF5KHH7C.js +0 -2
  410. package/dist/chunk-ZOHS7AQV.js +0 -21
  411. package/dist/code-MI6F2TTU.js +0 -2
  412. package/dist/code-result-json-FXALY4HE.js +0 -2
  413. package/dist/dataflow-4KEMJPC6.js +0 -2
  414. package/dist/dependence-slice-R7FPWD5M.js +0 -2
  415. package/dist/deps-7EMQUYUT.js +0 -2
  416. package/dist/direct-navigation-6YO234F2.js +0 -3
  417. package/dist/entry-map-KOOLR26E.js +0 -2
  418. package/dist/files-OPIPJIGZ.js +0 -2
  419. package/dist/hierarchy-QPD2CAER.js +0 -2
  420. package/dist/imports-M6HUXRXC.js +0 -2
  421. package/dist/members-I5MEFOCT.js +0 -2
  422. package/dist/methods-5JYGGHXA.js +0 -2
  423. package/dist/output-continuation-command-UPQAAKBP.js +0 -3
  424. package/dist/output-pagination-3OFL2MJV.js +0 -19
  425. package/dist/project-reindex-UKKQ5PLS.js +0 -3
  426. package/dist/refs-PSU4JZZW.js +0 -2
  427. package/dist/refs-pagination-JG6CJMRC.js +0 -2
  428. package/dist/slice-HYRATV64.js +0 -2
  429. package/dist/surface-VTGDYWF5.js +0 -2
  430. package/dist/system-LRQNFOR2.js +0 -2
  431. package/dist/trace-F4B6OLL4.js +0 -2
  432. package/dist/value-flow-VRPZY72V.js +0 -2
@@ -1,6 +1,6 @@
1
- import{A as Ie,B as st,C as we,G as at,b as Ze,f as O,g as et,h as xe,i as ie,j as _,k as q,l as tt,m as nt,n as B,o as I,p as f,q as oe,r as d,s as rt,t as it,u as k,v as ot,w as j,x as ee,y as G,z as V}from"./chunk-KFOYCQAJ.js";import{createRequire as Un}from"module";var Hn=Un(import.meta.url),$=Jn().version;function Jn(){for(let t of["../package.json","../../package.json"])try{return Hn(t)}catch{}return{version:"0.0.0"}}import{existsSync as bi,statSync as Si}from"fs";import{join as vi}from"path";import{createHash as ft,randomUUID as zn}from"crypto";import{chmodSync as yt,existsSync as ae,linkSync as Xn,lstatSync as Pe,readdirSync as mt,realpathSync as T,unlinkSync as Zn,writeSync as er}from"fs";import{homedir as tr}from"os";import{basename as Bs,dirname as Ce,isAbsolute as dt,join as E,resolve as Ee}from"path";import{isAbsolute as ct,relative as Kn}from"path";var C=class extends Error{constructor(n,r){super(`refusing unsafe project file path ${JSON.stringify(n)} (${r})`);this.relativePath=n;this.reason=r;this.name="UnsafeProjectPathError"}relativePath;reason;code="SCIP_QUERY_UNSAFE_PROJECT_PATH"};function Yn(t){return t.replace(/\\/g,"/").replace(/^\.\//,"")}function ke(t,e){let n=Kn(t,e);return n===""||!n.startsWith("..")&&!ct(n)}function ut(t){if(!t)throw new C(t,"empty-path");if(t.includes("\0"))throw new C(t,"nul-byte");if(ct(t)||/^[A-Za-z]:/.test(t)||t.startsWith("//")||t.startsWith("\\\\"))throw new C(t,"absolute-path");let e=Yn(t);if(e.split("/").some(r=>r===".."))throw new C(t,"parent-traversal");if(!e||e===".")throw new C(t,"empty-path");return e}var gt=1,ue=".scip-query-cache-owner.json",nr=16*1024,ht=Object.freeze({...xe,randomToken:()=>zn(),linkFile:(t,e)=>Xn(t,e),removeFile:t=>Zn(t),writeFile:(t,e,n,r)=>er(t,e,n,r)});function se(t,e){return Object.assign(new Error(`refusing unsafe project dbPath ${JSON.stringify(t)} (${e}); use a repository-relative directory that remains inside the checkout`),{name:"UnsafeCachePathError",code:"SCIP_QUERY_UNSAFE_CACHE_PATH",configuredPath:t,reason:e})}function D(t,e){return Object.assign(new Error(`refusing unowned cache directory ${JSON.stringify(t)} (${e}); move unrelated data elsewhere or choose a new empty dbPath`),{name:"CacheOwnershipError",code:"SCIP_QUERY_CACHE_OWNERSHIP",cacheDir:t,reason:e})}function rr(t,e){let n=T(t);return ar(n,ir(n,e))}function ir(t,e){let n=T(t),r=process.env.SCIP_QUERY_CACHE_DIR;return r?Ee(r):e?.dbPath?ur(n,e.dbPath):sr(n)}function or(){let t=process.env.XDG_CACHE_HOME;return E(t||E(tr(),".cache"),"scip-query")}function sr(t){let e=Ee(t);try{e=T(e)}catch{}let n=ft("sha256").update(e).digest("hex").slice(0,12);return E(or(),"projects",n)}function bt(t,e){let n=rr(t,e);return{cacheDir:n,dbPath:E(n,"index.db"),indexPath:E(n,"index.scip"),metaPath:E(n,"meta.json")}}function ar(t,e,n=ht){return cr(t,e,n).cacheDir}function cr(t,e,n=ht){let r=T(t),i=ae(e)?"synced":gr(e,n),o=T(e),s=E(o,ue);if(ae(s))return lt(r,o),St(s),ce(o),{kind:"existing",cacheDir:o};pt(o),yr(o),pt(o);let c=`${JSON.stringify({schemaVersion:gt,canonicalProjectRoot:r,canonicalCacheDir:o,creatorVersion:$},null,2)}
2
- `;try{let u=hr(s,c,n),l=q(i,u);return{kind:"published",cacheDir:o,achievedDurability:l==="synced"?"directory-durable":"file-flushed",directorySync:l}}catch(u){if(br(u))return lt(r,o),{kind:"existing",cacheDir:o};throw u}}function lt(t,e){let n=T(t),r=T(e);return lr(r,n,r)}function ur(t,e){let n;try{n=ut(e)}catch(s){throw s instanceof C?se(e,s.reason):s}let r=Ee(t,...n.split("/"));if(r===t||!ke(t,r))throw se(e,"outside-project");let i=dr(r),o=T(i);if(!ke(t,o)&&o!==t)throw se(e,"symlink-escape");return r}function dr(t){let e=t;for(;!ae(e);){let n=Ce(e);if(n===e)throw se(t,"no-existing-ancestor");e=n}return e}function lr(t,e,n){let r=E(t,ue);if(!ae(r)||Pe(r).isSymbolicLink())throw D(t,"missing regular ownership record");let i=Pe(r);if(!i.isFile()||i.size>nr)throw D(t,"invalid ownership record file");let o=I(r,"cache ownership record"),s=pr(o,t);if(e!==void 0&&s.canonicalProjectRoot!==e)throw D(t,"ownership record belongs to a different project");if(s.canonicalCacheDir!==n)throw D(t,"ownership record names a different cache directory");return{record:s,ownerSha256:ft("sha256").update(o).digest("hex"),physicalCacheDir:t}}function pr(t,e){try{let n=JSON.parse(t);if(n.schemaVersion!==gt||typeof n.canonicalProjectRoot!="string"||typeof n.canonicalCacheDir!="string"||typeof n.creatorVersion!="string"||!dt(n.canonicalProjectRoot)||!dt(n.canonicalCacheDir))throw new Error("invalid fields");return n}catch(n){throw D(e,`malformed ownership record: ${n instanceof Error?n.message:String(n)}`)}}function pt(t){let e=mt(t).filter(n=>n!==ue&&!fr(n));if(e.length>0)throw D(t,`unrecognized existing entries: ${e.slice(0,3).join(", ")}`)}function fr(t){return t.startsWith(`${ue}.tmp-`)||t.startsWith("git-worktree-context.json.tmp-")||[".scipquery-generations","affected-shadow-latest.json","affected-shadow.jsonl","agent-hooks","augment-vue-meta.json","cache-lifecycle.lock","evidence.db","evidence.db-shm","evidence.db-wal","health-report-cache.json","git-worktree-context.json","index.db","index.db-shm","index.db-wal","index.lock","index.scip","language-indexes","meta.json","reindex-activity.jsonl","shared-cache.json","typescript-index","typescript-scip-fragments","typescript-scip-overlays","typescript-semantic","typescript-shard-costs.json","watch-activity.json","watch-refresh-requests","watch-state.json","watch.lock"].includes(t)?!0:/^(?:reindex-|rust-|typescript-)/.test(t)}function yr(t){for(let e of mt(t)){let n=E(t,e);try{let r=Pe(n);if(r.isSymbolicLink())throw D(t,`legacy cache entry ${e} is a symlink`);if(r.isDirectory())ce(n);else if(r.isFile())St(n);else throw D(t,`legacy cache entry ${e} is not a file or directory`)}catch(r){if(mr(r))continue;throw r}}ce(t)}function mr(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function gr(t,e=xe){let n=ie(t,e);return ce(t),n}function hr(t,e,n){let r=`${t}.tmp-${process.pid}-${n.randomToken()}`,i,o=!1;try{i=n.openFile(r,"wx",384),o=!0,et(i,Buffer.from(e),n,"cache ownership record"),n.syncFile(i),n.closeFile(i),i=void 0,n.linkFile(r,t);let s=_(Ce(t),n);return n.removeFile(r),o=!1,q(s,_(Ce(t),n))}finally{if(i!==void 0)try{n.closeFile(i)}catch{}if(o)try{n.removeFile(r)}catch{}}}function ce(t){process.platform!=="win32"&&yt(t,448)}function St(t){process.platform!=="win32"&&yt(t,384)}function br(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EEXIST"}import{createHash as Pr,randomUUID as Cr}from"crypto";import{existsSync as Er,mkdirSync as ia,readdirSync as oa,rmSync as sa,statSync as Ar}from"fs";import{basename as ca,dirname as It,join as Oe}from"path";function vt(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.path=="string"&&typeof e.size=="number"&&Number.isFinite(e.size)&&typeof e.hash=="string"&&(e.semanticHash===void 0||typeof e.semanticHash=="string")}var Q=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var Ae=2,U=3;var Me=new Set(Q);function Rt(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(s){return{kind:"malformed",reason:`invalid JSON: ${kr(s)}`}}if(!f(e))return{kind:"malformed",reason:"metadata must be a JSON object"};let n=e.version;if(!Number.isInteger(n))return{kind:"malformed",reason:"version must be an integer"};if(n!==Ae&&n!==U)return{kind:"unsupported",version:n,direction:n<Ae?"older":"future"};let r=vr(e,n);if(r)return{kind:"malformed",reason:r};let i=e,o={metadata:i,capabilities:Sr(i)};return n===Ae?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function xt(t){if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.stableGenerationIdentity)return null;let e=t.metadata;return JSON.stringify({version:e.version,status:e.status,updatedAt:e.updatedAt,fingerprint:e.fingerprint,indexedLanguages:e.indexedLanguages,scipCompanion:e.scipCompanion,sqliteLayoutVersion:e.version===U?e.sqliteLayoutVersion:void 0})}function Sr(t){let e=t.fingerprint!==void 0,n=f(t.fingerprint),r=t.indexedLanguages!==void 0,i=t.status==="complete",o=t.version===U?t:null;return{usableForQuery:r,usableForEvidenceCache:e,publishableGeneration:i&&n&&r,stableGenerationIdentity:i&&e&&typeof t.updatedAt=="string",languageShardReuse:!!o?.languageFingerprints,typescriptProjectShardReuse:!!o?.typescriptProjectShards}}function vr(t,e){if(t.status!=="complete"&&t.status!=="partial")return"status must be complete or partial";if(t.updatedAt!==void 0&&!oe(t.updatedAt))return"updatedAt must be a valid timestamp";for(let n of["requestedLanguages","indexedLanguages"])if(t[n]!==void 0&&!Rr(t[n]))return`${n} must contain unique supported languages`;return t.skipped!==void 0&&!xr(t.skipped)?"skipped must contain supported language/reason pairs":t.scipCompanion!==void 0&&t.scipCompanion!=="current"&&t.scipCompanion!=="deferred"?"scipCompanion must be current or deferred":e===U&&t.sqliteLayoutVersion!==void 0&&(!Number.isSafeInteger(t.sqliteLayoutVersion)||t.sqliteLayoutVersion<1)?"sqliteLayoutVersion must be a positive safe integer":e===U&&t.languageFingerprints!==void 0&&!Ir(t.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":e===U&&t.typescriptProjectShards!==void 0&&!wr(t.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function Rr(t){return!Array.isArray(t)||!t.every(e=>typeof e=="string"&&Me.has(e))?!1:new Set(t).size===t.length}function xr(t){return Array.isArray(t)&&t.every(e=>f(e)&&typeof e.language=="string"&&Me.has(e.language)&&typeof e.reason=="string")}function Ir(t){return f(t)&&Object.entries(t).every(([e,n])=>Me.has(e)&&f(n))}function wr(t){return f(t)&&Object.values(t).every(e=>f(e)&&Array.isArray(e.files)&&e.files.every(vt))}function kr(t){return t instanceof Error?t.message:String(t)}function A(){return performance.now()}var Mr=1;var Or=".scipquery-generations";var fa={pid:process.pid,now:()=>new Date,randomToken:()=>Cr(),isProcessAlive:V,readProcessIdentity:G};function _r(t){return Oe(It(t),Or)}function jr(t){try{let e=JSON.parse(I(Oe(_r(t),"state.json"),"SQLite generation state"));return Fr(e)?e:null}catch{return null}}function wt(t){let e=jr(t);if(e)return e.currentGeneration;try{let n=Oe(It(t),"meta.json"),r=Er(n)?I(n,"reindex metadata"):void 0;return Tr(t,r)}catch{return null}}function Dr(t){return xt(Rt(t))??t}function Tr(t,e){let n=Pr("sha256").update("sqlite-generation-legacy-v1\0");return e!==void 0&&n.update(Dr(e)),n.update(`\0${Nr(t)}`),n.digest("hex")}function Nr(t){let e=Ar(t);return`${e.dev}:${e.ino}:${e.size}:${e.mtimeMs}`}function Fr(t){return t.version===Mr&&typeof t.currentGeneration=="string"&&!!t.currentGeneration&&typeof t.publishedAt=="string"&&Number.isFinite(Date.parse(t.publishedAt))&&(t.artifactSet===void 0||t.artifactSet==="immutable-v1")&&Lr(t.stableMirrors)&&Wr(t.previousGeneration)&&qr(t.publication)}function Lr(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t;return typeof e.databaseFileIdentity=="string"&&!!e.databaseFileIdentity&&(e.indexFileIdentity===void 0||typeof e.indexFileIdentity=="string"&&!!e.indexFileIdentity)}function Wr(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t;return typeof e.generationIdentity=="string"&&!!e.generationIdentity&&typeof e.databasePath=="string"&&!!e.databasePath&&(e.metadataPath===void 0||typeof e.metadataPath=="string"&&!!e.metadataPath)}function qr(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t,n=[e.converterDurationMs,e.affectedDocumentCount,e.changedDocumentCount,e.producerDurationMs,e.materializationDurationMs,e.patchDurationMs].filter(r=>r!==void 0);return(e.mode==="incremental"||e.mode==="full")&&e.validation==="passed"&&e.converterDurationMs!==void 0&&n.every(r=>typeof r=="number"&&Number.isFinite(r)&&r>=0)&&(e.scipCompanion===void 0||e.scipCompanion==="current"||e.scipCompanion==="deferred")&&(e.typescriptOverlayGeneration===void 0||typeof e.typescriptOverlayGeneration=="string"&&!!e.typescriptOverlayGeneration)&&(e.scipCompanion!=="deferred"||!!e.typescriptOverlayGeneration)&&(e.fallbackReason===void 0||typeof e.fallbackReason=="string")}import{existsSync as ti}from"fs";import{randomUUID as wa}from"crypto";import{isAbsolute as Pa,join as ni,relative as Ca,resolve as Ea}from"path";var L=1,H=2,Br="./node_modules/scip-query/docs/schemas/project-config.schema.json";function kt(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(a){return{kind:"malformed",reason:`invalid JSON: ${a instanceof Error?a.message:String(a)}`}}if(!f(e))return{kind:"malformed",reason:"project config must be a JSON object"};let n=e.schemaVersion;if(n!==void 0&&!Number.isInteger(n))return{kind:"malformed",reason:"schemaVersion must be an integer"};let r=n===void 0?L:n;if(r!==L&&r!==H)return{kind:"unsupported",schemaVersion:r,direction:r<L?"older":"future"};let i=e.$schema;if(i!==void 0&&(typeof i!="string"||i.trim()===""))return{kind:"malformed",reason:"$schema must be a non-empty string when present"};let o=Pt(e),s=r!==H||typeof e.$schema!="string";return r===L?{kind:"legacy",sourceVersion:L,config:o,needsMigration:s}:{kind:"supported",sourceVersion:H,config:o,needsMigration:s}}function Pt(t){let e=t,{$schema:n,schemaVersion:r,...i}=e;return{$schema:typeof n=="string"&&n.trim()!==""?n:Br,schemaVersion:H,...i}}import{createHash as ba}from"crypto";var _e=1,Ct=2,Gr=1,Vr=1,$r="sha256";function Et(t){if(!f(t))return{kind:"malformed",reason:"observation receipt must be an object"};let e=t.schemaVersion;if(!Number.isInteger(e))return{kind:"malformed",reason:"observation receipt schemaVersion must be an integer"};if(e===_e)return Ur(t)?{kind:"legacy",schemaVersion:_e,receipt:t}:{kind:"malformed",reason:"observation receipt v1 fields are malformed or contradictory"};if(e===Ct)return Hr(t)?{kind:"supported",schemaVersion:Ct,receipt:t}:{kind:"malformed",reason:"observation receipt v2 facts are malformed or contradictory"};let n=e;return{kind:"unsupported",schemaVersion:n,direction:n<_e?"older":"future"}}function Qr(t,e){return t.schemaVersion===e.schemaVersion&&t.canonicalizationVersion===e.canonicalizationVersion&&t.hashAlgorithm===e.hashAlgorithm&&t.projection.name===e.projection.name&&t.projection.version===e.projection.version}function Ur(t){if(!f(t))return!1;let e=t.index,n=t.worktree;return Mt(t.observedAt)&&k(t.projectIdentity)&&ei(t.authorityKind)&&(e===void 0||f(e)&&k(e.generationIdentity)&&(e.source==="immutable"||e.source==="legacy")&&(e.alignment==="not-certified"||e.alignment==="leased"))&&(n===void 0||f(n)&&k(n.identity)&&typeof n.clean=="boolean"&&(n.headCommit===void 0||k(n.headCommit))&&(n.treeOid===void 0||k(n.treeOid)))&&Zr(t.authorityKind,e,n)}function Hr(t){if(!f(t))return!1;let e=t.facts,n=t.observedSources,r=t.stabilityProofs;if(!Mt(t.observedAt)||!f(e)||!Array.isArray(n)||n.length===0||!n.every(Kr)||!De(n,c=>c.kind)||!Array.isArray(r)||!r.every(Yr)||!De(r,c=>c.source)||r.some(c=>!n.some(u=>u.kind===c.source))||!r.every(c=>Xr(c,e))||["collaborationDomain","repositoryLineage","workspaceInstance","wholeContent"].some(c=>e[c]!==void 0&&!N(e[c])))return!1;let o=e.relevantInputs;if(o!==void 0&&(!Array.isArray(o)||!o.every(Jr)||!De(o,c=>`${c.subject}\0${c.identity.projection.name}`)))return!1;let s=e.index;if(s!==void 0&&(!f(s)||!N(s.generation)||s.inputs!==void 0&&!N(s.inputs)||s.source!=="immutable"&&s.source!=="legacy"))return!1;let a=t.diagnostics;return(a===void 0||f(a)&&(a.clean===void 0||typeof a.clean=="boolean")&&(a.headCommit===void 0||k(a.headCommit))&&(a.treeOid===void 0||k(a.treeOid)))&&zr(e,n)}function N(t){return!f(t)||!f(t.projection)?!1:t.schemaVersion===Gr&&t.canonicalizationVersion===Vr&&t.hashAlgorithm===$r&&k(t.projection.name)&&rt(t.projection.version)&&it(t.digest)}function Jr(t){return f(t)&&k(t.subject)&&N(t.identity)}function Kr(t){return f(t)&&At(t.kind)&&(t.identity===void 0||N(t.identity))}function Yr(t){return f(t)&&At(t.source)&&(t.kind==="immutable"||t.kind==="fixed-snapshot"||t.kind==="bracketed"||t.kind==="not-established"||t.kind==="invalidated")}function zr(t,e){let n=t.index,r=e.find(c=>c.kind==="index-generation");if(r){if(!f(n)||!N(n.generation)||r.identity&&!je(r.identity,n.generation))return!1}else if(n!==void 0)return!1;let i=t.workspaceInstance,o=e.find(c=>c.kind==="live-workspace");if(o?.identity&&(!N(i)||!je(o.identity,i)))return!1;let s=t.wholeContent,a=e.find(c=>c.kind==="repository-snapshot");return!(a?.identity&&(!N(s)||!je(a.identity,s)))}function Xr(t,e){return t.kind==="not-established"||t.kind==="invalidated"?!0:t.source==="index-generation"?t.kind==="immutable"&&f(e.index)&&e.index.source==="immutable":t.source==="repository-snapshot"?t.kind==="fixed-snapshot":t.source==="live-workspace"?t.kind==="bracketed":!1}function je(t,e){return Qr(t,e)&&t.digest===e.digest}function Zr(t,e,n){return t==="index-worktree"?e!==void 0&&n!==void 0:t==="index-only"?e!==void 0&&n===void 0:t==="worktree-only"?e===void 0&&n!==void 0:t==="process-local"&&e===void 0&&n===void 0}function ei(t){return t==="index-worktree"||t==="index-only"||t==="worktree-only"||t==="process-local"}function At(t){return t==="index-generation"||t==="repository-snapshot"||t==="live-workspace"||t==="process"}function Mt(t){return typeof t=="string"&&!Number.isNaN(Date.parse(t))}function De(t,e){return new Set(t.map(e)).size===t.length}var de=".scipquery.json";var _a=15*6e4,ja={enabled:!0,windowMs:15*6e4,maxRebuilds:2,maxEstimatedWriteBytes:1024*1024*1024};var Da=new Set(Q);function Ot(t){let e=ni(t,de);if(!ti(e))return{};let n;try{n=B(e,{maxBytes:tt,inputKind:"scip-query project config"})}catch(r){let i=r instanceof Error?r.message:String(r);throw new Error(`unable to read ${de} at ${e}: ${i}`,{cause:r})}return ri(kt(n),e,"read").config}function ri(t,e,n){if(t.kind==="legacy"||t.kind==="supported")return t;if(t.kind==="malformed"){let i=n==="read"?`invalid ${de} at ${e}: ${t.reason}`:`Cannot update ${e}: the latest project config is ${t.reason}.`;throw new Error(`${i} The file was left untouched.`)}let r=n==="read"?`invalid ${de} at ${e}`:`Cannot update ${e}: the latest project config is invalid`;throw new Error(`${r} (unsupported ${t.direction} schemaVersion ${t.schemaVersion}; this scip-query reads legacy v${L} and current v${H}). Upgrade scip-query before retrying; the file was left untouched.`)}import{spawnSync as ii}from"child_process";import{createHash as oi}from"crypto";import{existsSync as si,lstatSync as ai,realpathSync as ci}from"fs";import{dirname as ui,isAbsolute as di,join as li,relative as Ga,resolve as pe,sep as Va}from"path";var _t=Symbol.for("scip-query.project-file-listing-context.v1"),jt=globalThis,Te=jt[_t],Dt=Te&&typeof Te=="object"?Te:{};jt[_t]=Dt;function Tt(){return Dt.sequence??0}var Fe={run(t,e){let n=Lt(t,e);return n.kind==="success"?n.output:void 0},runResult:Lt},pi=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],Wt=["status","--porcelain=v2","--branch","-z","--untracked-files=all"],Ne=/^[0-9a-f]{40,64}$/;function qt(t,e=Fe){return fi(t,e)?.context}function fi(t,e=Fe){let n=e.runResult(t,pi);if(n.kind==="success"){let i=yi(n.output);if(i){let o=mi(i,e);if(o)return Nt(o)}}let r=gi(t,e);return r?Nt(r):void 0}function Nt(t){return{context:t,projectFileInventorySequence:Tt()}}function Bt(t){let e=t.split("\0").filter(Boolean),n=e.find(i=>i.startsWith("# branch.oid "))?.slice(13),r=n==="(initial)"?void 0:n;if(!(r!==void 0&&!Ne.test(r))&&n!==void 0)return{headCommit:r,clean:e.every(i=>i.startsWith("# "))}}function yi(t){let e=t.split(`
3
- `).map(c=>c.trim());if(e.length!==5)return;let[n,r,i,o,s]=e;if(!n||!r||!i||!o||!s||!Ne.test(o)||!Ne.test(s))return;let a=M(n);return{root:a,gitDir:M(le(a,r)),commonDir:M(le(a,i)),headCommit:o,treeOid:s}}function mi(t,e){let n=e.run(t.root,Wt);if(n===void 0)return;let r=Bt(n);return r?.headCommit!==t.headCommit?void 0:{...Gt(t.root,t.gitDir),commonDir:t.commonDir,repositoryId:We("repository",t.commonDir),headCommit:t.headCommit,treeOid:t.treeOid,clean:r.clean}}function gi(t,e){let n=Le(t,e);if(n.kind!=="worktree")return;let r=n.identity,i=r.projectRoot,o=e.run(i,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=M(le(i,o)),a=Ft(e.run(i,["rev-parse","--verify","HEAD"])),c=Ft(e.run(i,["rev-parse","--verify","HEAD^{tree}"])),u=e.run(i,Wt);if(u===void 0)return;let l=Bt(u);if(!(!l||l.headCommit!==a))return{...r,commonDir:s,repositoryId:We("repository",s),headCommit:a,treeOid:c,clean:l.clean}}function Le(t,e=Fe){let n=e.runResult(t,["rev-parse","--show-toplevel"]);if(n.kind==="not-repository")return{kind:"non-git"};if(n.kind==="error")return n;let r=n.output.trim();if(!r)return{kind:"error",message:"Git returned an empty worktree root."};let i=M(r),o=e.run(i,["rev-parse","--absolute-git-dir"])?.trim();if(!o)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=M(le(i,o));return{kind:"worktree",identity:Gt(i,s)}}function Gt(t,e){return{projectRoot:t,gitDir:e,worktreeId:We("worktree",`${t}\0${e}`)}}function le(t,e){return di(e)?e:pe(t,e)}function M(t){try{return ci(t)}catch{return pe(t)}}function We(t,e){return oi("sha256").update(`${t}\0${e}`).digest("hex").slice(0,24)}function Ft(t){return t?.trim()||void 0}function Lt(t,e){let n=ii("git",["-C",t,...e],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"],timeout:3e4,killSignal:"SIGKILL"});if(n.status===0)return{kind:"success",output:n.stdout.trimEnd()};let i=(typeof n.stderr=="string"?n.stderr.trim():"")||n.error?.message||`git exited with status ${n.status??"unknown"}`,o=n.error?.code;return(/not a git repository/i.test(i)||o==="ENOENT"&&si(pe(t)))&&!hi(t)?{kind:"not-repository"}:{kind:"error",message:i}}function hi(t){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let e=pe(t);for(;;){try{return ai(li(e,".git")),!0}catch(r){let i=r.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let n=ui(e);if(n===e)return!1;e=n}}function qe(){return process.env.SCIP_QUERY_PROJECT_ROOT??process.cwd()}var Vt;function $t(t=qe(),e=void 0){if(e===void 0&&Vt?.projectRoot===t)return Vt;let n=Ot(t),r=bt(t,n),i=process.env.SCIP_QUERY_INDEX_DB;if(i)return{projectRoot:t,config:n,paths:r,dbPath:i,dbPathSource:"env",gitContext:e};if(bi(r.dbPath))return{projectRoot:t,config:n,paths:r,dbPath:r.dbPath,dbPathSource:"configured",gitContext:e};let o=vi(t,"index.db");return{projectRoot:t,config:n,paths:r,dbPath:o,dbPathSource:"root-fallback",rootFallbackWarning:Ri(o,r.dbPath),gitContext:e}}function Ri(t,e){let n="unknown time";try{n=Si(t).mtime.toISOString()}catch{}return`warning: using legacy project-root index.db (${t}, modified ${n}) because the configured index was not found at ${e}. This fallback may be stale; run 'scip-query reindex' to refresh the configured index.`}import{basename as xi}from"path";function Qt(t=process.argv,e=process.execPath){let n=t[1];return!n||xi(n)==="scip-query"?["scip-query"]:[e,n]}import{spawn as co}from"child_process";import{createHash as ve,randomUUID as uo}from"crypto";import{existsSync as Qe,realpathSync as lo}from"fs";import{tmpdir as po}from"os";import{join as Ue,resolve as re}from"path";import{fileURLToPath as fo}from"url";function fe(t){return Be(t,Ii)}function Be(t,e){return Array.isArray(t)?`[${t.map(n=>Be(n,e)).join(",")}]`:t&&typeof t=="object"?`{${Object.entries(t).sort(([n],[r])=>e(n,r)).map(([n,r])=>`${JSON.stringify(n)}:${Be(r,e)}`).join(",")}}`:JSON.stringify(t)}function Ii(t,e){return t<e?-1:t>e?1:0}import{createHash as tc,randomUUID as Yt}from"crypto";import{closeSync as rc,existsSync as Y,fstatSync as ic,lstatSync as ne,mkdirSync as oc,openSync as sc,readdirSync as K,readSync as ac,renameSync as zt,rmSync as F}from"fs";import{basename as ye,dirname as wi,join as g}from"path";var me=1,ki=Object.freeze({maxItems:1024,maxBytes:512*1024*1024,maxItemBytes:64*1024*1024,maxBatch:16,claimLeaseMs:5*6e4,responseRetentionMs:10*6e4,deadLetterRetentionMs:1440*6e4,temporaryRetentionMs:6e4,cleanupBatch:64}),J=class extends Error{constructor(n,r,i,o){let s=n==="item-too-large"?`request is ${o} bytes; per-item limit is ${i.maxItemBytes}`:n==="item-capacity"?`mailbox has ${r.totalItems} retained items; limit is ${i.maxItems}`:n==="byte-capacity"?`mailbox retains ${r.totalBytes} bytes and the request adds ${o}; limit is ${i.maxBytes}`:"another writer held the admission coordinator through the bounded wait";super(`Mailbox backpressure: ${s}. Retry after the service drains or expires retained work.`);this.code=n;this.status=r;this.limits=i;this.attemptedBytes=o;this.name="MailboxBackpressureError"}code;status;limits;attemptedBytes},Pi=".owner.json",Ci={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function Xt(t){return{rootDir:t,pendingDir:g(t,"pending"),inflightDir:g(t,"inflight"),responseDir:g(t,"responses"),deadLetterDir:g(t,"dead-letter"),legacyRequestDir:g(t,"requests")}}function Ei(t={}){let e={...ki,...t};for(let[n,r]of Object.entries(e))if(!Number.isFinite(r)||r<=0||!Number.isInteger(r))throw new Error(`Mailbox limit ${n} must be a positive integer.`);return e}function Zt(t){let e=[t.pendingDir,t.inflightDir,t.responseDir,t.deadLetterDir,t.legacyRequestDir].map(n=>ie(n));return q(...e)}function ge(t){if(!/^[a-f0-9]{64}$/.test(t))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${t}`}function en(t,e,n={}){let r=Ei(n.limits),i=n.nowMs??Date.now(),o=Zt(t);return Ni(e),Mi(t,r,n.admissionLockTimeoutMs??2e3,n.monotonicNow??A,n.durability??"durable",()=>{Ai(t,i,r);let s=g(t.pendingDir,`${e.id}.json`),a=g(t.responseDir,`${e.id}.json`),c=Ut(t,e.id);if(c){let y=Ht(c,e.operationKey,e.id);return{disposition:"duplicate",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:y.deadlineAtMs??e.deadlineAtMs}}let u=`${JSON.stringify(e)}
4
- `,l=Buffer.byteLength(u),p=tn(t);if(l>r.maxItemBytes)throw new J("item-too-large",p,r,l);if(p.totalItems+1>r.maxItems)throw new J("item-capacity",p,r,l);if(p.totalBytes+l>r.maxBytes)throw new J("byte-capacity",p,r,l);n.onBeforePublish?.();try{let y=n.durability??"durable",R=we(s,u,{durability:y}),P=y==="durable"?q(o,R.directorySync):"not-requested";return{disposition:"accepted",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:e.deadlineAtMs,achievedDurability:R.achievedDurability,directorySync:P}}catch(y){if(y.code!=="EEXIST")throw y;let R=Ut(t,e.id);if(!R)throw y;let P=Ht(R,e.operationKey,e.id);return{disposition:"duplicate",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:P.deadlineAtMs??e.deadlineAtMs}}})}function Ai(t,e,n,r=Ci){let i={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=n.cleanupBatch;for(let s of Ve(t.inflightDir)){if(o<=0)break;let a=g(t.responseDir,`${s.requestId}.json`);if(Y(a)){F(s.path,{force:!0}),i.completedClaimsRemoved++,o--;continue}if(s.claimExpiresAtMs>e||Di(t,s.ownerId,r)!=="dead")continue;let c=g(t.pendingDir,s.originalFile);try{zt(s.path,c),i.reclaimed++}catch(u){if(u.code!=="EEXIST")throw u;F(s.path,{force:!0})}_(wi(s.path)),_(t.pendingDir),o--}o=Jt(t.responseDir,o,(s,a)=>a+n.responseRetentionMs,e,()=>{i.responsesRemoved++}),o=Jt(t.deadLetterDir,o,(s,a)=>a+n.deadLetterRetentionMs,e,()=>{i.deadLettersRemoved++});for(let s of[t.pendingDir,t.inflightDir,t.responseDir,t.deadLetterDir,t.legacyRequestDir]){if(o<=0)break;for(let a of nn(s)){if(o<=0)break;if(!ye(a).includes(".tmp-"))continue;let c;try{c=ne(a).mtimeMs}catch(u){if(u.code==="ENOENT")continue;throw u}c+n.temporaryRetentionMs>e||(F(a,{force:!0}),i.temporaryFilesRemoved++,o--)}}return Fi(t.inflightDir),i}function tn(t){Zt(t);let e=[...te(t.pendingDir).map(c=>({path:c,pending:!0})),...te(t.legacyRequestDir).map(c=>({path:c,pending:!0}))],n=Ve(t.inflightDir).map(c=>({path:c.path,pending:!1})),r=te(t.responseDir).map(c=>({path:c,pending:!1})),i=te(t.deadLetterDir).map(c=>({path:c,pending:!1})),o=[...e,...n,...r,...i],s=0,a;for(let c of e){let u=$e(c.path);if(!u){s++;continue}let l=u.enqueuedAtMs;if(l===void 0)try{l=ne(c.path).mtimeMs}catch(p){if(p.code==="ENOENT")continue;throw p}a=a===void 0?l:Math.min(a,l)}return{pending:e.length,inflight:n.length,responses:r.length,deadLetters:i.length,invalid:s,totalItems:o.length,totalBytes:o.reduce((c,u)=>c+Li(u.path),0),...a===void 0?{}:{oldestPendingAt:new Date(a).toISOString()}}}function Mi(t,e,n,r,i,o){let s=g(t.rootDir,".admission.lock"),a=`${process.pid}-${Yt()}`,c=r()+Math.max(0,n);for(;!Oi(t.rootDir,s,a,i);){if(_i(s),r()>=c)throw new J("admission-busy",tn(t),e,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return o()}finally{try{Ge(s).ownerToken===a&&(F(s,{recursive:!0,force:!0}),i==="durable"&&_(t.rootDir))}catch{}}}function Oi(t,e,n,r){let i=`${JSON.stringify({ownerToken:n,pid:process.pid,acquiredAtMs:Date.now()})}
5
- `;try{return we(e,i,{durability:r}),!0}catch(o){if(o.code==="EEXIST")return!1;try{Ge(e).ownerToken===n&&(F(e,{force:!0}),r==="durable"&&_(t))}catch{}throw o}}function _i(t){let e=null;try{let r=Ge(t);typeof r.ownerToken=="string"&&Number.isSafeInteger(r.pid)&&Number(r.pid)>0&&(e=Number(r.pid))}catch{}if(e===null||ji(e))return;let n=`${t}.stale-${Yt()}`;try{zt(t,n)}catch(r){let i=r.code;if(i==="ENOENT"||i==="EEXIST")return;throw r}F(n,{recursive:!0,force:!0})}function Ge(t){try{return JSON.parse(I(t,"mailbox lock record"))}catch(e){if(e.code!=="EISDIR"&&!(e instanceof nt&&e.reason==="not-regular"))throw e;return JSON.parse(I(g(t,"owner.json"),"mailbox lock owner record"))}}function ji(t){try{return process.kill(t,0),!0}catch(e){let n=e.code;return n==="EPERM"||n!=="ESRCH"}}function Di(t,e,n){let r=Ti(g(t.inflightDir,rn(e),Pi));if(!r)return"unknown";if(!n.isProcessAlive(r.pid))return"dead";if(!r.processIdentity)return"live";let i=n.readProcessIdentity(r.pid);return i?ee(r.processIdentity,i)?"live":"dead":"unknown"}function Ti(t){try{let e=JSON.parse(I(t,"mailbox owner record"));if(e.version!==1||typeof e.ownerId!="string"||!e.ownerId||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0)return null;let n=e.processIdentity===void 0?null:j(e.processIdentity);return e.processIdentity!==void 0&&(!n||n.pid!==e.pid)?null:{version:1,ownerId:e.ownerId,pid:e.pid,...n?{processIdentity:n}:{}}}catch{return null}}function Ut(t,e){for(let n of[g(t.pendingDir,`${e}.json`),g(t.legacyRequestDir,`${e}.json`),g(t.responseDir,`${e}.json`)])if(Y(n))return n;for(let n of Ve(t.inflightDir))if(n.requestId===e)return n.path;return null}function Ht(t,e,n){let r=$e(t);if(r?.operationKey===e)return r;if(ye(t)===`${ge(e)}.json`)return{id:n,operationKey:e};throw new Error(`Mailbox operation ${n} conflicts with an existing retained record.`)}function Ni(t){if(t.mailboxVersion!==me||t.id!==ge(t.operationKey)||!t.clientId.trim()||!Number.isFinite(t.enqueuedAtMs)||!Number.isFinite(t.deadlineAtMs)||t.deadlineAtMs<t.enqueuedAtMs)throw new Error("Mailbox request has an invalid lifecycle identity.")}function Ve(t){if(!Y(t))return[];let e=[];for(let n of K(t,{withFileTypes:!0})){if(!n.isDirectory())continue;let r=Kt(n.name);if(r===null)continue;let i=g(t,n.name);for(let o of K(i,{withFileTypes:!0})){if(!o.isFile()||!o.name.endsWith(".claim"))continue;let s=/^(.*)\.(\d+)\.claim$/.exec(o.name);if(!s)continue;let a=Kt(s[1]),c=Number(s[2]);if(a===null||ye(a)!==a||!a.endsWith(".json")||!Number.isSafeInteger(c))continue;let u=g(i,o.name),l=$e(u)??{id:ye(a,".json")},p;try{p=ne(u)}catch(y){if(y.code==="ENOENT")continue;throw y}e.push({requestId:l.id,ownerId:r,path:u,originalFile:a,claimedAtMs:p.mtimeMs,claimExpiresAtMs:c,byteLength:p.size,...l.operationKey?{operationKey:l.operationKey}:{},...l.clientId?{clientId:l.clientId}:{},...l.enqueuedAtMs===void 0?{}:{enqueuedAtMs:l.enqueuedAtMs},...l.deadlineAtMs===void 0?{}:{deadlineAtMs:l.deadlineAtMs},legacy:l.operationKey===void 0})}}return e.sort((n,r)=>n.claimedAtMs-r.claimedAtMs||n.path.localeCompare(r.path))}function $e(t){try{let e=JSON.parse(I(t,"mailbox record"));return typeof e.id!="string"||!e.id?null:{id:e.id,...typeof e.operationKey=="string"?{operationKey:e.operationKey}:{},...typeof e.clientId=="string"?{clientId:e.clientId}:{},...typeof e.enqueuedAtMs=="number"?{enqueuedAtMs:e.enqueuedAtMs}:{},...typeof e.deadlineAtMs=="number"?{deadlineAtMs:e.deadlineAtMs}:{}}}catch{return null}}function Jt(t,e,n,r,i){for(let o of te(t)){if(e<=0)break;let s;try{s=ne(o)}catch(a){if(a.code==="ENOENT")continue;throw a}n(o,s.mtimeMs)>r||(F(o,{force:!0}),i(),e--)}return e}function te(t){return Y(t)?K(t,{withFileTypes:!0}).filter(e=>e.isFile()).map(e=>g(t,e.name)).sort():[]}function nn(t){if(!Y(t))return[];let e=[];for(let n of K(t,{withFileTypes:!0})){let r=g(t,n.name);n.isFile()?e.push(r):n.isDirectory()&&e.push(...nn(r))}return e.sort()}function Fi(t){if(Y(t))for(let e of K(t,{withFileTypes:!0})){if(!e.isDirectory())continue;let n=g(t,e.name);K(n).some(r=>r.endsWith(".claim"))||F(n,{recursive:!0,force:!0})}}function Li(t){try{return ne(t).size}catch{return 0}}function rn(t){return Buffer.from(t,"utf8").toString("base64url")}function Kt(t){try{let e=Buffer.from(t,"base64url").toString("utf8");return rn(e)===t?e:null}catch{return null}}import{spawn as Xi}from"child_process";import{existsSync as Zi,rmSync as wc}from"fs";import{dirname as Pc,resolve as eo}from"path";import{fileURLToPath as Ec}from"url";import{join as he}from"path";var on=6,sn=1e4,Wi="watch.lock",qi="watch-state.json",Bi="watch-activity.json",Gi="watch-refresh-requests";function an(t){return{lockPath:he(t,Wi),statePath:he(t,qi),activityPath:he(t,Bi),refreshRequestsPath:he(t,Gi)}}function cn(t){try{return Vi(JSON.parse(I(t,"watch service state")))}catch{return null}}function Vi(t){if(!t||typeof t!="object")return null;let e=t;if(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"||!h(e.startedAt)||!h(e.heartbeatAt)||!h(e.lastActivityAt)||!$i(e.watcher)||e.idleDeadlineAt!==void 0&&!h(e.idleDeadlineAt))return null;if(e.processIdentity!==void 0){let n=j(e.processIdentity);if(!n||n.pid!==e.pid)return null;e.processIdentity=n}return e.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(e.indexGeneration)||e.lastError!==void 0&&!Qi(e.lastError)||e.lastRefresh!==void 0&&!Ui(e.lastRefresh)||e.reindexActivity!==void 0&&!Hi(e.reindexActivity)||e.refreshRequests!==void 0&&!Ki(e.refreshRequests)||e.typescriptSemantic!==void 0&&!Yi(e.typescriptSemantic)||e.typescriptIndex!==void 0&&!zi(e.typescriptIndex)?null:e}function h(t){return oe(t)}function $i(t){if(!t||typeof t!="object"||!("state"in t))return!1;let e=t;switch(e.state){case"idle":return!0;case"waiting":return b(e.changedFiles)&&b(e.reindexAt);case"indexing":return b(e.startedAt);case"cooldown":return b(e.until)&&typeof e.dirty=="boolean";case"budget-paused":return b(e.until)&&typeof e.dirty=="boolean"&&typeof e.reason=="string"&&d(e.rebuilt)&&d(e.estimatedWriteBytes);case"draining":return b(e.startedAt)&&typeof e.reason=="string";default:return!1}}function Qi(t){if(!t||typeof t!="object")return!1;let e=t;return h(e.at)&&typeof e.message=="string"}function Ui(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.trigger?.kind=="string"&&typeof e.result=="string"&&h(e.startedAt)&&h(e.completedAt)&&b(e.durationMs)}function Hi(t){if(!t||typeof t!="object")return!1;let e=t;return e.confidence!==void 0&&e.confidence!=="complete"&&e.confidence!=="partial"&&e.confidence!=="unavailable"||e.recordsRead!==void 0&&!d(e.recordsRead)||e.invalidRecords!==void 0&&!d(e.invalidRecords)||e.skippedRecords!==void 0&&!d(e.skippedRecords)||e.readErrors!==void 0&&!d(e.readErrors)||e.ignoredPartialTailBytes!==void 0&&!d(e.ignoredPartialTailBytes)||!h(e.windowStartedAt)||!h(e.windowEndedAt)||!d(e.runs)||!d(e.rebuilt)||e.fullRebuilds!==void 0&&!d(e.fullRebuilds)||!d(e.reused)||!d(e.failed)||!d(e.suppressed)||!b(e.estimatedLogicalOutputBytes)||e.estimatedWriteBytes!==void 0&&!d(e.estimatedWriteBytes)||e.reflinkedBytes!==void 0&&!d(e.reflinkedBytes)||e.fallbackCopiedBytes!==void 0&&!d(e.fallbackCopiedBytes)||e.oldestRebuildAt!==void 0&&!h(e.oldestRebuildAt)||e.oldestWriteAt!==void 0&&!h(e.oldestWriteAt)||e.languageAttribution!==void 0&&e.languageAttribution!=="complete"&&e.languageAttribution!=="partial"&&e.languageAttribution!=="unavailable"||e.attributedRuns!==void 0&&!d(e.attributedRuns)||e.unattributedRuns!==void 0&&!d(e.unattributedRuns)||e.invalidLanguageDetails!==void 0&&!d(e.invalidLanguageDetails)||e.estimatedLogicalOutputBytes<0||!e.byTrigger||typeof e.byTrigger!="object"||Array.isArray(e.byTrigger)||e.byLanguage!==void 0&&!Ji(e.byLanguage)?!1:Object.values(e.byTrigger).every(n=>n===void 0||d(n))}function Ji(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;for(let[e,n]of Object.entries(t)){if(!Q.includes(e)||!n||typeof n!="object")return!1;let r=n;if(!d(r.runs)||!d(r.rebuilt)||!d(r.reused)||!d(r.producedOutputBytes)||!ot(r.durationMs)||r.rebuilt+r.reused!==r.runs)return!1}return!0}function Ki(t){if(!t||typeof t!="object")return!1;let e=t;return d(e.pending)&&d(e.claimed)&&d(e.completed)&&d(e.expired)&&d(e.invalid)&&(e.oldestPendingAt===void 0||h(e.oldestPendingAt))}function Yi(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")&&b(e.requests)&&b(e.sessionsCreated)&&b(e.sessionsReused)&&b(e.sessionsRefreshed)&&b(e.sessionsReplaced)&&b(e.projectsCreated)&&(e.lastRequestAt===void 0||h(e.lastRequestAt))&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||h(e.busyUntil))&&(e.mailbox===void 0||un(e.mailbox))}function zi(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")&&d(e.requests)&&d(e.sessionsCreated)&&d(e.sessionsReplaced)&&(e.sessionsEvicted===void 0||d(e.sessionsEvicted))&&(e.activeSessions===void 0||d(e.activeSessions))&&(e.maxActiveSessions===void 0||d(e.maxActiveSessions))&&(e.heapUsedBytes===void 0||d(e.heapUsedBytes))&&(e.heapLimitBytes===void 0||d(e.heapLimitBytes))&&(e.softMemoryLimitBytes===void 0||d(e.softMemoryLimitBytes))&&(e.retireRequested===void 0||typeof e.retireRequested=="boolean")&&d(e.initializations)&&d(e.programUpdates)&&d(e.documentsEmitted)&&d(e.documentsRemoved)&&(e.lastRequestAt===void 0||h(e.lastRequestAt))&&(e.lastDurationMs===void 0||b(e.lastDurationMs)&&e.lastDurationMs>=0)&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||h(e.busyUntil))&&(e.mailbox===void 0||un(e.mailbox))}function un(t){if(!t||typeof t!="object")return!1;let e=t;return d(e.pending)&&d(e.inflight)&&d(e.responses)&&d(e.deadLetters)&&d(e.invalid)&&d(e.totalItems)&&b(e.totalBytes)&&e.totalBytes>=0&&e.totalItems===e.pending+e.inflight+e.responses+e.deadLetters&&(e.oldestPendingAt===void 0||h(e.oldestPendingAt))}function b(t){return typeof t=="number"&&Number.isFinite(t)}function dn(t){let e=t.classification;if(e.kind!=="live")return;let{state:n}=e;return n.watcher.state==="idle"&&n.lastError===void 0?n.indexGeneration:void 0}function to(t,e,n){let r=M(eo(t));if(n&&M(n.projectRoot)===r)return{projectRoot:r,worktreeKind:"git",worktreeId:n.worktreeId,cliVersion:e};let i=Le(r);if(i.kind==="error")throw new Error(`Could not establish Git worktree identity for ${r}: ${i.message}`);return i.kind==="non-git"?{projectRoot:r,worktreeKind:"non-git",cliVersion:e}:{projectRoot:r,worktreeKind:"git",worktreeId:i.identity.worktreeId,cliVersion:e}}function ln(t){return no(t,to(t.projectRoot,t.cliVersion,t.gitContext))}function no(t,e){let n=t.runtime??ao,r=an(t.cacheDir),i=cn(r.statePath),o=ro(r.lockPath);return{identity:e,classification:so(i,e,n.now(),n.isProcessAlive),lock:o,lockIsLive:o!==null&&n.isProcessAlive(o.pid),paths:r}}function ro(t){return oo(st(t,{parseLegacy:io}))}var io=t=>{let e=pn(t);return e?{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}:null};function oo(t){if(t.state==="valid"&&t.record?.kind==="watch"){let e=t.record.detail?.projectRoot;return typeof e!="string"?null:{version:1,pid:t.record.pid,...t.record.processIdentity?{processIdentity:t.record.processIdentity}:{},projectRoot:e,startedAt:t.record.startedAt}}return pn(t.parsed)}function pn(t){try{let e=t;if(e.version!==1||typeof e.pid!="number"||!Number.isInteger(e.pid)||e.pid<=0||typeof e.projectRoot!="string"||!h(e.startedAt))return null;let n=e.processIdentity===void 0?null:j(e.processIdentity);return e.processIdentity!==void 0&&(!n||n.pid!==e.pid)?null:{version:1,pid:e.pid,...n?{processIdentity:n}:{},projectRoot:e.projectRoot,startedAt:e.startedAt}}catch{return null}}function so(t,e,n,r){if(!t)return{kind:"stopped"};if(t.protocolVersion!==on)return{kind:"incompatible",state:t,reason:"protocol"};if(t.projectRoot!==e.projectRoot)return{kind:"incompatible",state:t,reason:"project"};let i=e.worktreeKind==="git"?e.worktreeId:void 0;if(t.worktreeId!==i)return{kind:"incompatible",state:t,reason:"worktree"};if(t.cliVersion!==e.cliVersion)return{kind:"incompatible",state:t,reason:"cli-version"};if(!r(t.pid))return{kind:"stale",state:t,reason:"dead-process"};let o=Date.parse(t.heartbeatAt);return n-o>sn?{kind:"stale",state:t,reason:"old-heartbeat"}:{kind:"live",state:t}}var ao={now:Date.now,monotonicNow:A,isProcessAlive:V,readProcessIdentity:G,spawnServer(t,e,n,r){if(!Zi(t))throw new Error(`Watch service helper was not found at ${t}. Run npm run build first.`);Xi(process.execPath,[t,e,n,JSON.stringify(r)],{detached:!0,stdio:"ignore",env:{...process.env,SCIP_QUERY_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(t){process.kill(t,"SIGTERM")},forceSignalProcess(t){process.kill(t,"SIGKILL")},sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)}};var W=18,yo=1e3,mo=2*yo,go=4,ho=4,bo=5,So=3,vo=3,Ro=4,xo=3,Io=3,wo=8,fn=3e4,ko=5e3,mn=5,Po=10,Co=1,Eo=5,He=64*1024*1024,Ao={maxItems:64,maxBytes:128*1024*1024,maxItemBytes:He,maxBatch:1,responseRetentionMs:6e4};function gn(t,e,n={},r={}){return m(t,i=>({kind:"source-search",expectedGeneration:i,pattern:e,options:n}),as,"search result",r)}function hn(t,e,n={}){return m(t,r=>({kind:"outline",expectedGeneration:r,filePattern:e}),To,"outline result",n)}function bn(t,e={},n={}){return m(t,r=>({kind:"entrypoints",expectedGeneration:r,options:e}),No,"entrypoints result",n)}function Sn(t,e,n={}){return m(t,r=>({kind:"files",expectedGeneration:r,pattern:e}),Fo,"files result",n)}function vn(t,e={}){return m(t,n=>({kind:"stats",expectedGeneration:n}),Lo,"stats result",e)}function Rn(t,e,n={}){return m(t,r=>({kind:"members",expectedGeneration:r,symbolPattern:e}),Wo,"members result",n)}function xn(t,e,n={}){return m(t,r=>({kind:"methods",expectedGeneration:r,className:e}),qo,"methods result",n)}function In(t,e,n,r={}){return m(t,i=>({kind:"file-dependencies",expectedGeneration:i,direction:e,filePattern:n}),Bo,"file dependencies result",r)}function wn(t,e,n={}){return m(t,r=>({kind:"imported-by",expectedGeneration:r,symbolPattern:e}),Wn,"imported-by result",n)}function kn(t,e,n={}){return m(t,r=>({kind:"hierarchy",expectedGeneration:r,symbolPattern:e}),Qo,"hierarchy result",n)}function Pn(t,e,n={}){return m(t,r=>({kind:"by-kind",expectedGeneration:r,kindQuery:e}),Ho,"by-kind result",n)}function Cn(t,e={}){return m(t,n=>({kind:"kind-counts",expectedGeneration:n}),Ko,"kind-counts result",e)}function En(t,e,n={}){return m(t,r=>({kind:"refs",expectedGeneration:r,symbolPattern:e}),zo,"refs result",n)}function An(t,e,n={}){return m(t,r=>({kind:"trace",expectedGeneration:r,symbolPattern:e}),z,"trace result",n)}function Mn(t,e,n={}){return m(t,r=>({kind:"value-flow",expectedGeneration:r,symbolPattern:e}),z,"value-flow result",n)}function On(t,e,n={}){return m(t,r=>({kind:"dependence-slice",expectedGeneration:r,criterion:e}),z,"dependence-slice result",n)}function _n(t,e,n,r={}){return m(t,i=>({kind:e,expectedGeneration:i,symbolPattern:n}),z,`${e} result`,r)}function jn(t,e,n={}){return m(t,r=>({kind:"system",expectedGeneration:r,modulePattern:e}),z,"system result",n)}function Dn(t,e,n={}){return m(t,r=>({kind:"imports",expectedGeneration:r,filePattern:e}),Wn,"imports result",n)}function Tn(t,e,n={}){return m(t,r=>({kind:"unused-imports",expectedGeneration:r,filePattern:e}),Go,"unused imports result",n)}function Nn(t,e,n={}){return m(t,r=>({kind:"surface",expectedGeneration:r,modulePattern:e}),Zo,"surface result",n)}function Fn(t,e,n,r={}){return m(t,i=>({kind:"code",expectedGeneration:i,selectors:[...e],options:n}),z,"serialized code result",r)}function m(t,e,n,r,i){if(!ds(i.allowDefault===!0))return null;try{let o=i.allowDefault===!0&&process.env.SCIP_QUERY_QUERY_SERVICE!=="1",s=o?qt(t):void 0,a=$t(t,s);if(!Qe(a.dbPath))return null;let c=wt(a.dbPath);if(!c||o&&!Mo(a,s,c))return null;let u=_o({projectRoot:a.projectRoot,dbPath:a.dbPath,generationIdentity:c},e(c),n,r);return{result:u.result,generationIdentity:c,observationReceipt:u.observationReceipt}}catch(o){return qn()&&console.error(`query-service fallback: ${o instanceof Error?o.message:String(o)}`),null}}function Mo(t,e,n){if(t.config.watch?.enabled!==!0)return!1;try{return dn(ln({projectRoot:t.projectRoot,cacheDir:t.paths.cacheDir,cliVersion:$,gitContext:e}))===n}catch{return!1}}function Ln(t){return ve("sha256").update(fe({kind:"scip-query-service-mailbox",protocolVersion:W,sessionDir:re(t)})).digest("hex")}function be(t){let e=Ue(t,"server.json");try{let n=JSON.parse(B(e,{maxBytes:65536,inputKind:"query service state"}));if(!n||typeof n!="object"||Array.isArray(n))return null;let r=n,i=r.processIdentity===void 0?void 0:j(r.processIdentity);return r.protocolVersion!==W||typeof r.sessionIdentity!="string"||r.sessionIdentity!==Ln(t)||typeof r.pid!="number"||!Number.isSafeInteger(r.pid)||r.pid<=0||r.processIdentity!==void 0&&(!i||i.pid!==r.pid)||typeof r.generation!="string"||typeof r.heartbeatAtMs!="number"||!Number.isFinite(r.heartbeatAtMs)?null:{protocolVersion:W,sessionIdentity:r.sessionIdentity,pid:r.pid,...i?{processIdentity:i}:{},generation:r.generation,heartbeatAtMs:r.heartbeatAtMs}}catch{return null}}function Se(t,e=Date.now()){if(!V(t.pid))return!1;let n=e-t.heartbeatAtMs;if(n>=0&&n<=mo||!t.processIdentity)return!0;let r=G(t.pid);return r!==null&&ee(t.processIdentity,r)}function Oo(t){let e=t<Po;return{intervalMs:e?Co:mn,checkServerState:!e||t%Eo===0}}function _o(t,e,n,r){let i=us();if(!Qe(i))throw new Error("Query service server executable is unavailable.");let o=Math.abs(process.pid)%ps(e),s=cs(t,i,o),a=Xt(s),c=Date.now(),u=c+fn,l=A()+fn,p=uo(),y=jo(p,e),R=ge(y),P=Ln(s),x=en(a,{mailboxVersion:me,protocolVersion:W,id:R,operationKey:y,clientId:p,enqueuedAtMs:c,deadlineAtMs:u,sessionIdentity:P,request:e},{nowMs:c,limits:Ao,durability:"visibility"});yn(s,t.projectRoot,i,l);let Ye=0;for(;A()<=l;){if(Qe(x.responsePath))return Do(B(x.responsePath,{maxBytes:He,inputKind:"query service response"}),{id:R,operationKey:y,clientId:p,deadlineAtMs:x.authoritativeDeadlineAtMs,generation:t.generationIdentity},n,r);let ze=Oo(Ye);if(ze.checkServerState){let Xe=be(s);(!Xe||!Se(Xe))&&yn(s,t.projectRoot,i,l)}Bn(ze.intervalMs),Ye+=1}throw new Error("Persistent query service timed out.")}function jo(t,e){return ve("sha256").update(fe({namespace:"query-service-v18",payload:{clientId:t,request:e}})).digest("hex")}function yn(t,e,n,r){let i=be(t);if(i&&Se(i))return;let o=Math.min(r,A()+ko),s=Ie(Ue(t,"startup.lock"),{kind:"query-service-startup",detail:{projectRoot:re(e)},directoryDurability:"recoverable"});try{if(s.kind==="acquired"){let a=be(t);if(!a||!Se(a)){let c=qn();co(process.execPath,[n,t,e],{cwd:e,detached:!c,stdio:c?["ignore","ignore","inherit"]:"ignore",env:{...process.env,SCIP_QUERY_QUERY_SERVICE_SERVER:"1"}}).unref()}}for(;A()<=o;){let a=be(t);if(a&&Se(a))return;Bn(mn)}}finally{s.kind==="acquired"&&s.lock.release()}throw new Error("Persistent query service did not become ready within 5s.")}function Do(t,e,n,r){let i=JSON.parse(t);if(!i||typeof i!="object"||Array.isArray(i))throw new Error("Invalid query service response.");let o=i;if(o.mailboxVersion!==me||o.protocolVersion!==W||o.id!==e.id||o.operationKey!==e.operationKey||o.clientId!==e.clientId||o.deadlineAtMs!==e.deadlineAtMs)throw new Error("Query service response identity does not match the request.");if(o.ok!==!0)throw new Error(typeof o.error=="string"?o.error:"Persistent query service rejected the request.");if(o.generation!==e.generation)throw new Error("Persistent query service generation changed.");if(!n(o.result))throw new Error(`Persistent query service returned an invalid ${r}.`);let s=Et(o.observationReceipt);if(s.kind!=="supported")throw new Error("Persistent query service returned an invalid observation receipt.");return{ok:!0,protocolVersion:W,id:e.id,generation:e.generation,result:o.result,observationReceipt:s.receipt}}function To(t){if(!Array.isArray(t))return!1;let e=[...t];for(;e.length>0;){let n=e.pop();if(!n||typeof n!="object"||Array.isArray(n))return!1;let r=n;if(typeof r.symbol!="string"||typeof r.shortName!="string"||!Number.isSafeInteger(r.startLine)||r.startLine<0||!Number.isSafeInteger(r.endLine)||r.endLine<r.startLine||r.signature!==null&&typeof r.signature!="string"||!Array.isArray(r.children))return!1;e.push(...r.children)}return!0}function No(t){return Array.isArray(t)?t.every(e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.symbol=="string"&&typeof n.shortName=="string"&&typeof n.file=="string"&&Number.isSafeInteger(n.startLine)&&n.startLine>=0&&Number.isSafeInteger(n.endLine)&&n.endLine>=n.startLine&&(n.documentation===null||typeof n.documentation=="string")&&(n.confidence==="root"||n.confidence==="candidate")&&Array.isArray(n.evidence)&&n.evidence.every(r=>typeof r=="string")&&Number.isSafeInteger(n.indexedCallerCount)&&n.indexedCallerCount>=0}):!1}function Fo(t){return Array.isArray(t)?t.every(e=>!e||typeof e!="object"||Array.isArray(e)?!1:typeof e.relativePath=="string"):!1}function Lo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return S(e.documents)&&S(e.symbols)&&S(e.definitions)&&S(e.references)&&S(e.indexSizeBytes)&&(e.lastBuilt===null||typeof e.lastBuilt=="string")}function Wo(t){if(!Je(t))return!1;let e=t.members;return Array.isArray(e)&&e.every(ts)}function Je(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return e.matched===!1?e.resolved===void 0&&e.otherMatches===void 0&&e.totalMatches===void 0&&Array.isArray(e.suggestions)&&e.suggestions.every(n=>typeof n=="string"):e.matched===!0&&is(e.resolved)&&Array.isArray(e.otherMatches)&&e.otherMatches.every(os)&&S(e.totalMatches)&&e.totalMatches>=1&&e.suggestions===void 0}function qo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.query!="string"?!1:e.kind==="missing"?Array.isArray(e.suggestions)&&e.suggestions.every(n=>typeof n=="string"):e.kind==="ambiguous"?S(e.total)&&e.total>1&&Array.isArray(e.candidates)&&e.candidates.every(ss):e.kind==="matched"&&rs(e.owner)&&Array.isArray(e.methods)&&e.methods.every(ns)}function Bo(t){return Array.isArray(t)?t.every(e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.relativePath=="string"&&(n.edgeBasis===void 0||n.edgeBasis==="symbol-references")&&(n.evidence===void 0||n.evidence==="cross-file SCIP references plus resolved source imports")}):!1}function Wn(t){return Array.isArray(t)&&t.every($o)}function Go(t){return Array.isArray(t)&&t.every(Vo)}function Vo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.importedIn=="string"}function $o(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.fromFile=="string"}function Qo(t){if(!Je(t))return!1;let e=t.hierarchy;return Array.isArray(e)&&e.every(Uo)}function Uo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&S(e.depth)}function Ho(t){return Array.isArray(t)&&t.every(Jo)}function Jo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&S(e.kind)&&typeof e.kindName=="string"&&typeof e.relativePath=="string"&&Re(e)}function Ko(t){return Array.isArray(t)&&t.every(Yo)}function Yo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return S(e.kind)&&typeof e.kindName=="string"&&S(e.count)}function zo(t){if(!Je(t))return!1;let e=t,n=e.references,r=e.pagination;if(!Array.isArray(n)||!n.every(Xo)||!r||typeof r!="object"||Array.isArray(r))return!1;let i=r;return i.cursorVersion===2&&i.producer==="complete-only"&&typeof i.semanticEnrichment=="boolean"}function Xo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.relativePath=="string"&&S(e.line)}function Zo(t){return Array.isArray(t)&&t.every(es)}function es(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.consumer=="string"&&typeof e.symbol=="string"&&typeof e.shortName=="string"&&e.basis==="external-reference"}function ts(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.kind=="string"&&Re(e)}function ns(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.name=="string"&&Re(e)}function rs(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.relativePath=="string"&&Re(e)}function is(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.relativePath=="string"}function os(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.shortName=="string"&&typeof e.relativePath=="string"&&S(e.startLine)&&e.symbol===void 0}function ss(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.relativePath=="string"&&S(e.startLine)}function Re(t){return S(t.startLine)&&S(t.endLine)&&t.endLine>=t.startLine}function S(t){return Number.isSafeInteger(t)&&t>=0}function as(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.pattern=="string"&&(e.mode==="literal"||e.mode==="regexp")&&Array.isArray(e.matches)&&typeof e.matchingLines=="number"&&Number.isSafeInteger(e.matchingLines)&&e.matchingLines>=0&&typeof e.omittedMatches=="number"&&Number.isSafeInteger(e.omittedMatches)&&e.omittedMatches>=0&&typeof e.scannedFiles=="number"&&Number.isSafeInteger(e.scannedFiles)&&e.scannedFiles>=0}function z(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;if(typeof e.serializedJson!="string"||typeof e.sha256!="string"||e.serializedJson.length>He||ve("sha256").update(e.serializedJson).digest("hex")!==e.sha256)return!1;try{let n=JSON.parse(e.serializedJson);return n!==null&&typeof n=="object"&&!Array.isArray(n)}catch{return!1}}function cs(t,e,n){let r=fs(t.projectRoot),i=ve("sha256").update(fe({protocolVersion:W,projectRoot:r,dbPath:re(t.dbPath),serverPath:re(e),lane:n})).digest("hex");return Ue(po(),"scip-query-query-service",i)}function us(){return process.env.SCIP_QUERY_QUERY_SERVICE_SERVER_PATH??fo(new URL("./query-service-server.js",import.meta.url))}function ds(t){let e=process.env.SCIP_QUERY_QUERY_SERVICE;return process.env.SCIP_QUERY_QUERY_SERVICE_SERVER!=="1"&&e!=="0"&&(e==="1"||t)}function qn(){return process.env.SCIP_QUERY_QUERY_SERVICE_DEBUG==="1"}function ls(){let t=Number(process.env.SCIP_QUERY_QUERY_SERVICE_POOL_SIZE);return Number.isInteger(t)&&t>=1&&t<=wo?t:go}function ps(t){let e=ls();return t.kind==="value-flow"?Math.min(e,xo):t.kind==="dependence-slice"?Math.min(e,Io):t.kind==="call-graph"?Math.min(e,So):t.kind==="system"?Math.min(e,Ro):t.kind==="reference-reachability"||t.kind==="slice"?Math.min(e,vo):t.kind==="refs"||t.kind==="trace"||t.kind==="reference-neighborhood"||t.kind==="dataflow"||t.kind==="imports"||t.kind==="unused-imports"?Math.min(e,bo):t.kind==="imported-by"||t.kind==="hierarchy"||t.kind==="by-kind"||t.kind==="kind-counts"?Math.min(e,ho):e}function fs(t){try{return lo.native(t)}catch{return re(t)}}function Bn(t){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)}async function uu(t){if(process.env.SCIP_QUERY_PROFILE==="1"||process.env.SCIP_QUERY_PROFILE==="true")return!1;let e=ys(t);if(!e)return!1;let n=qe();if(e.kind==="code"){try{at(n,"code",e.session)}catch{return!1}let i=Fn(n,e.selectors,e.options,{allowDefault:!0});return i?(O(i.result.serializedJson),!0):!1}if(e.kind==="files"){let i=Sn(n,e.pattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="members"){let i=Rn(n,e.symbolPattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="methods"){let i=xn(n,e.className,{allowDefault:!0});return!i||!X(i.result)?!1:(i.result.kind!=="matched"&&(process.exitCode=1),!0)}if(e.kind==="file-dependencies"){let i=In(n,e.direction,e.filePattern,{allowDefault:!0});if(!i)return!1;let o=e.direction==="outgoing"?"deps":"rdeps";return await w(JSON.stringify(i.result),o,t),!0}if(e.kind==="imported-by"){let i=wn(n,e.symbolPattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="hierarchy"){let i=kn(n,e.symbolPattern,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="by-kind"){let i=Pn(n,e.kindQuery,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="kind-counts"){let i=Cn(n,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="refs"){let i=En(n,e.symbolPattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="trace"){let i=An(n,e.symbolPattern,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="value-flow"){let i=Mn(n,e.symbolPattern,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="dependence-slice"){let i=On(n,e.criterion,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="call-graph"||e.kind==="reference-neighborhood"||e.kind==="reference-reachability"||e.kind==="slice"||e.kind==="dataflow"){let i=_n(n,e.kind,e.symbolPattern,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="imports"){let i=Dn(n,e.filePattern,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="unused-imports"){let i=Tn(n,e.filePattern,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="system"){let i=jn(n,e.modulePattern,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="surface"){let i=Nn(n,e.modulePattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="stats"){let i=vn(n,{allowDefault:!0});return i?(O(JSON.stringify(i.result)),!0):!1}if(e.kind==="entrypoints"){let i=bn(n,e.options,{allowDefault:!0});return i?(O(JSON.stringify(i.result)),!0):!1}let r=e.kind==="source-search"?gn(n,e.pattern,e.options,{allowDefault:!0}):hn(n,e.filePattern,{allowDefault:!0});return r?(O(JSON.stringify(r.result)),!0):!1}function ys(t){return t[0]==="search"?Os(t):t[0]==="outline"?_s(t):t[0]==="code"?Ms(t):t[0]==="entrypoints"?As(t):t[0]==="files"?Es(t):t[0]==="stats"?$n(t,"stats"):t[0]==="kind-counts"?$n(t,"kind-counts"):t[0]==="members"?Gn(t,"members"):t[0]==="methods"?Gn(t,"methods"):t[0]==="deps"?Vn(t,"outgoing"):t[0]==="rdeps"?Vn(t,"incoming"):t[0]==="imported-by"?ms(t):t[0]==="hierarchy"?gs(t):t[0]==="by-kind"?hs(t):t[0]==="refs"?bs(t):t[0]==="trace"?Ss(t):t[0]==="value-flow"?vs(t):t[0]==="dependence-slice"?Rs(t):t[0]==="call-graph"||t[0]==="reference-neighborhood"||t[0]==="reference-reachability"||t[0]==="slice"||t[0]==="dataflow"?xs(t):t[0]==="imports"?Is(t):t[0]==="unused-imports"?ws(t):t[0]==="system"?ks(t):t[0]==="surface"?Ps(t):null}function Gn(t,e){let n=v(t);return n===null?null:e==="members"?{kind:e,symbolPattern:n}:{kind:e,className:n}}function Vn(t,e){let n=v(t);return n===null?null:{kind:"file-dependencies",direction:e,filePattern:n}}function ms(t){let e=v(t);return e===null?null:{kind:"imported-by",symbolPattern:e}}function gs(t){let e=v(t);return e===null?null:{kind:"hierarchy",symbolPattern:e}}function hs(t){let e=v(t);return e===null?null:{kind:"by-kind",kindQuery:e}}function bs(t){let e=v(t);return e===null?null:{kind:"refs",symbolPattern:e}}function Ss(t){let e=v(t);return e===null?null:{kind:"trace",symbolPattern:e}}function vs(t){let e=v(t);return e===null?null:{kind:"value-flow",symbolPattern:e}}function Rs(t){let e=v(t);return e===null?null:{kind:"dependence-slice",criterion:e}}function xs(t){let e=t[0];if(e!=="call-graph"&&e!=="reference-neighborhood"&&e!=="reference-reachability"&&e!=="slice"&&e!=="dataflow")return null;let n=v(t);return n===null?null:{kind:e,symbolPattern:n}}function Is(t){let e=v(t);return e===null?null:{kind:"imports",filePattern:e}}function ws(t){let e=v(t);return e===null?null:{kind:"unused-imports",filePattern:e}}function ks(t){let e=v(t);return e===null?null:{kind:"system",modulePattern:e}}function Ps(t){let e=v(t);return e===null?null:{kind:"surface",modulePattern:e}}function v(t){let e,n=!1,r=!1,i=!1;for(let o=1;o<t.length;o+=1){let s=t[o];if(s==="--"){let a=t.slice(o+1);if(a.length!==1||e!==void 0)return null;e=a[0];break}if(s==="--json"){n=!0;continue}if(s==="--result-only"){r=!0;continue}if(s==="--compact"){i=!0;continue}if(s.startsWith("-")||e!==void 0)return null;e=s}return!n||!r||!i||e===void 0?null:e}function X(t){return Cs(JSON.stringify(t))}function Cs(t){return Qn(t)?(O(t),!0):!1}async function w(t,e,n){if(Qn(t)){O(t);return}let{runWithCliOutputPagination:r}=await import("./output-pagination-3OFL2MJV.js");await r({command:e,producerVersion:$,invocationPrefix:Qt(),argv:[...n],cwd:process.cwd(),json:!0,sourceSession:!0,reemitSource:!1},()=>O(t))}function Qn(t){return Buffer.byteLength(t)+1<=Ze}function Es(t){let e,n=!1,r=!1,i=!1;for(let o=1;o<t.length;o+=1){let s=t[o];if(s==="--"){let a=t.slice(o+1);if(a.length!==1||e!==void 0)return null;e=a[0];break}if(s==="--json"){n=!0;continue}if(s==="--result-only"){r=!0;continue}if(s==="--compact"){i=!0;continue}if(s.startsWith("-")||e!==void 0)return null;e=s}return!n||!r||!i||e===void 0?null:{kind:"files",pattern:e}}function $n(t,e){let n=!1,r=!1,i=!1;for(let o=1;o<t.length;o+=1){let s=t[o];if(s==="--json"){n=!0;continue}if(s==="--result-only"){r=!0;continue}if(s==="--compact"){i=!0;continue}return null}return n&&r&&i?{kind:e}:null}function As(t){let e,n,r=!1,i=!1,o=!1;for(let s=1;s<t.length;s+=1){let a=t[s];if(a==="--"){let u=t.slice(s+1);if(u.length!==1||e!==void 0)return null;e=u[0];break}if(a==="--json"){r=!0;continue}if(a==="--result-only"){i=!0;continue}if(a==="--compact"){o=!0;continue}let c=Z(t,s,a,"--scope","-s");if(c){n=c.value,s=c.nextIndex;continue}if(a.startsWith("-")||e!==void 0)return null;e=a}return!r||!i||!o?null:{kind:"entrypoints",options:{...e===void 0?{}:{search:e},...n===void 0?{}:{scope:n}}}}function Ms(t){let e=[],n=0,r="exported",i=!0,o=!1,s=!1,a=!1;for(let c=1;c<t.length;c+=1){let u=t[c];if(u==="--"){e.push(...t.slice(c+1));break}if(u==="--json"){o=!0;continue}if(u==="--result-only"){s=!0;continue}if(u==="--compact"){a=!0;continue}if(u==="--no-session"){i=!1;continue}let l=Z(t,c,u,"--context","-C");if(l){let y=Ke(l.value,0);if(y===null)return null;n=y,c=l.nextIndex;continue}let p=Z(t,c,u,"--members");if(p){if(p.value!=="exported"&&p.value!=="all")return null;r=p.value,c=p.nextIndex;continue}if(u.startsWith("-"))return null;e.push(u)}return!o||!s||!a||e.length<1||e.length>24||e.some(c=>c.length===0)?null:{kind:"code",selectors:e,options:{context:n,members:r},session:i}}function Os(t){let e,n,r=2,i=6,o=!1,s=!1,a=!1,c=!1,u=!1;for(let l=1;l<t.length;l+=1){let p=t[l];if(p==="--"){let x=t.slice(l+1);if(x.length!==1||e!==void 0)return null;e=x[0];break}if(p==="--json"){a=!0;continue}if(p==="--result-only"){c=!0;continue}if(p==="--compact"){u=!0;continue}if(p==="--regexp"){o=!0;continue}if(p==="--ignore-case"||p==="-i"){s=!0;continue}let y=Z(t,l,p,"--scope","-s");if(y){n=y.value,l=y.nextIndex;continue}let R=Z(t,l,p,"--context","-C");if(R){let x=Ke(R.value,0);if(x===null)return null;r=x,l=R.nextIndex;continue}let P=Z(t,l,p,"--limit","-n");if(P){let x=Ke(P.value,1);if(x===null)return null;i=x,l=P.nextIndex;continue}if(p.startsWith("-")||e!==void 0)return null;e=p}return!a||!c||!u||e===void 0?null:{kind:"source-search",pattern:e,options:{scope:n,context:r,limit:i,regexp:o,ignoreCase:s,ranking:"structural"}}}function _s(t){let e,n=!1,r=!1,i=!1;for(let o=1;o<t.length;o+=1){let s=t[o];if(s==="--"){let a=t.slice(o+1);if(a.length!==1||e!==void 0)return null;e=a[0];break}if(s==="--json"){n=!0;continue}if(s==="--result-only"){r=!0;continue}if(s==="--compact"){i=!0;continue}if(s!=="--signatures"){if(s.startsWith("-")||e!==void 0)return null;e=s}}return!n||!r||!i||e===void 0?null:{kind:"outline",filePattern:e}}function Z(t,e,n,r,i){if(n.startsWith(`${r}=`))return{value:n.slice(r.length+1),nextIndex:e};if(n!==r&&(i===void 0||n!==i))return null;let o=t[e+1];return o===void 0?null:{value:o,nextIndex:e+1}}function Ke(t,e){if(!/^\d+$/.test(t))return null;let n=Number(t);return Number.isSafeInteger(n)&&n>=e?n:null}export{ys as parseFastPathInvocation,Qn as serializedJsonFitsClientBudget,uu as tryRunQueryServiceFastPath};
1
+ import{A as Ie,B as st,C as we,G as at,a as Ze,b as et,c as q,d as I,f as tt,j as O,k as nt,l as xe,m as ie,n as _,o as B,p as f,q as oe,r as d,s as rt,t as it,u as k,v as ot,w as j,x as ee,y as G,z as V}from"./chunk-UH3XSKS5.js";import{createHash as Ds}from"crypto";import{createRequire as Un}from"module";var Hn=Un(import.meta.url),$=Jn().version;function Jn(){for(let t of["../package.json","../../package.json"])try{return Hn(t)}catch{}return{version:"0.0.0"}}import{existsSync as bi,statSync as Si}from"fs";import{join as vi}from"path";import{createHash as ft,randomUUID as zn}from"crypto";import{chmodSync as yt,existsSync as ae,linkSync as Xn,lstatSync as Pe,readdirSync as mt,realpathSync as T,unlinkSync as Zn,writeSync as er}from"fs";import{homedir as tr}from"os";import{basename as Vs,dirname as Ce,isAbsolute as dt,join as E,resolve as Ee}from"path";import{isAbsolute as ct,relative as Kn}from"path";var C=class extends Error{constructor(n,r){super(`refusing unsafe project file path ${JSON.stringify(n)} (${r})`);this.relativePath=n;this.reason=r;this.name="UnsafeProjectPathError"}relativePath;reason;code="SCIP_QUERY_UNSAFE_PROJECT_PATH"};function Yn(t){return t.replace(/\\/g,"/").replace(/^\.\//,"")}function ke(t,e){let n=Kn(t,e);return n===""||!n.startsWith("..")&&!ct(n)}function ut(t){if(!t)throw new C(t,"empty-path");if(t.includes("\0"))throw new C(t,"nul-byte");if(ct(t)||/^[A-Za-z]:/.test(t)||t.startsWith("//")||t.startsWith("\\\\"))throw new C(t,"absolute-path");let e=Yn(t);if(e.split("/").some(r=>r===".."))throw new C(t,"parent-traversal");if(!e||e===".")throw new C(t,"empty-path");return e}var gt=1,ue=".scip-query-cache-owner.json",nr=16*1024,ht=Object.freeze({...xe,randomToken:()=>zn(),linkFile:(t,e)=>Xn(t,e),removeFile:t=>Zn(t),writeFile:(t,e,n,r)=>er(t,e,n,r)});function se(t,e){return Object.assign(new Error(`refusing unsafe project dbPath ${JSON.stringify(t)} (${e}); use a repository-relative directory that remains inside the checkout`),{name:"UnsafeCachePathError",code:"SCIP_QUERY_UNSAFE_CACHE_PATH",configuredPath:t,reason:e})}function D(t,e){return Object.assign(new Error(`refusing unowned cache directory ${JSON.stringify(t)} (${e}); move unrelated data elsewhere or choose a new empty dbPath`),{name:"CacheOwnershipError",code:"SCIP_QUERY_CACHE_OWNERSHIP",cacheDir:t,reason:e})}function rr(t,e){let n=T(t);return ar(n,ir(n,e))}function ir(t,e){let n=T(t),r=process.env.SCIP_QUERY_CACHE_DIR;return r?Ee(r):e?.dbPath?ur(n,e.dbPath):sr(n)}function or(){let t=process.env.XDG_CACHE_HOME;return E(t||E(tr(),".cache"),"scip-query")}function sr(t){let e=Ee(t);try{e=T(e)}catch{}let n=ft("sha256").update(e).digest("hex").slice(0,12);return E(or(),"projects",n)}function bt(t,e){let n=rr(t,e);return{cacheDir:n,dbPath:E(n,"index.db"),indexPath:E(n,"index.scip"),metaPath:E(n,"meta.json")}}function ar(t,e,n=ht){return cr(t,e,n).cacheDir}function cr(t,e,n=ht){let r=T(t),i=ae(e)?"synced":gr(e,n),o=T(e),s=E(o,ue);if(ae(s))return lt(r,o),St(s),ce(o),{kind:"existing",cacheDir:o};pt(o),yr(o),pt(o);let c=`${JSON.stringify({schemaVersion:gt,canonicalProjectRoot:r,canonicalCacheDir:o,creatorVersion:$},null,2)}
2
+ `;try{let u=hr(s,c,n),l=B(i,u);return{kind:"published",cacheDir:o,achievedDurability:l==="synced"?"directory-durable":"file-flushed",directorySync:l}}catch(u){if(br(u))return lt(r,o),{kind:"existing",cacheDir:o};throw u}}function lt(t,e){let n=T(t),r=T(e);return lr(r,n,r)}function ur(t,e){let n;try{n=ut(e)}catch(s){throw s instanceof C?se(e,s.reason):s}let r=Ee(t,...n.split("/"));if(r===t||!ke(t,r))throw se(e,"outside-project");let i=dr(r),o=T(i);if(!ke(t,o)&&o!==t)throw se(e,"symlink-escape");return r}function dr(t){let e=t;for(;!ae(e);){let n=Ce(e);if(n===e)throw se(t,"no-existing-ancestor");e=n}return e}function lr(t,e,n){let r=E(t,ue);if(!ae(r)||Pe(r).isSymbolicLink())throw D(t,"missing regular ownership record");let i=Pe(r);if(!i.isFile()||i.size>nr)throw D(t,"invalid ownership record file");let o=I(r,"cache ownership record"),s=pr(o,t);if(e!==void 0&&s.canonicalProjectRoot!==e)throw D(t,"ownership record belongs to a different project");if(s.canonicalCacheDir!==n)throw D(t,"ownership record names a different cache directory");return{record:s,ownerSha256:ft("sha256").update(o).digest("hex"),physicalCacheDir:t}}function pr(t,e){try{let n=JSON.parse(t);if(n.schemaVersion!==gt||typeof n.canonicalProjectRoot!="string"||typeof n.canonicalCacheDir!="string"||typeof n.creatorVersion!="string"||!dt(n.canonicalProjectRoot)||!dt(n.canonicalCacheDir))throw new Error("invalid fields");return n}catch(n){throw D(e,`malformed ownership record: ${n instanceof Error?n.message:String(n)}`)}}function pt(t){let e=mt(t).filter(n=>n!==ue&&!fr(n));if(e.length>0)throw D(t,`unrecognized existing entries: ${e.slice(0,3).join(", ")}`)}function fr(t){return t.startsWith(`${ue}.tmp-`)||t.startsWith("git-worktree-context.json.tmp-")||[".scipquery-generations","affected-shadow-latest.json","affected-shadow.jsonl","agent-hooks","augment-vue-meta.json","cache-lifecycle.lock","evidence.db","evidence.db-shm","evidence.db-wal","health-report-cache.json","git-worktree-context.json","index.db","index.db-shm","index.db-wal","index.lock","index.scip","language-indexes","meta.json","reindex-activity.jsonl","shared-cache.json","typescript-index","typescript-scip-fragments","typescript-scip-overlays","typescript-semantic","typescript-shard-costs.json","watch-activity.json","watch-refresh-requests","watch-state.json","watch.lock"].includes(t)?!0:/^(?:reindex-|rust-|typescript-)/.test(t)}function yr(t){for(let e of mt(t)){let n=E(t,e);try{let r=Pe(n);if(r.isSymbolicLink())throw D(t,`legacy cache entry ${e} is a symlink`);if(r.isDirectory())ce(n);else if(r.isFile())St(n);else throw D(t,`legacy cache entry ${e} is not a file or directory`)}catch(r){if(mr(r))continue;throw r}}ce(t)}function mr(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function gr(t,e=xe){let n=ie(t,e);return ce(t),n}function hr(t,e,n){let r=`${t}.tmp-${process.pid}-${n.randomToken()}`,i,o=!1;try{i=n.openFile(r,"wx",384),o=!0,nt(i,Buffer.from(e),n,"cache ownership record"),n.syncFile(i),n.closeFile(i),i=void 0,n.linkFile(r,t);let s=_(Ce(t),n);return n.removeFile(r),o=!1,B(s,_(Ce(t),n))}finally{if(i!==void 0)try{n.closeFile(i)}catch{}if(o)try{n.removeFile(r)}catch{}}}function ce(t){process.platform!=="win32"&&yt(t,448)}function St(t){process.platform!=="win32"&&yt(t,384)}function br(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EEXIST"}import{createHash as Pr,randomUUID as Cr}from"crypto";import{existsSync as Er,mkdirSync as sa,readdirSync as aa,rmSync as ca,statSync as Ar}from"fs";import{basename as da,dirname as It,join as Oe}from"path";function vt(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.path=="string"&&typeof e.size=="number"&&Number.isFinite(e.size)&&typeof e.hash=="string"&&(e.semanticHash===void 0||typeof e.semanticHash=="string")}var Q=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var Ae=2,U=3;var Me=new Set(Q);function Rt(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(s){return{kind:"malformed",reason:`invalid JSON: ${kr(s)}`}}if(!f(e))return{kind:"malformed",reason:"metadata must be a JSON object"};let n=e.version;if(!Number.isInteger(n))return{kind:"malformed",reason:"version must be an integer"};if(n!==Ae&&n!==U)return{kind:"unsupported",version:n,direction:n<Ae?"older":"future"};let r=vr(e,n);if(r)return{kind:"malformed",reason:r};let i=e,o={metadata:i,capabilities:Sr(i)};return n===Ae?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function xt(t){if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.stableGenerationIdentity)return null;let e=t.metadata;return JSON.stringify({version:e.version,status:e.status,updatedAt:e.updatedAt,fingerprint:e.fingerprint,indexedLanguages:e.indexedLanguages,scipCompanion:e.scipCompanion,sqliteLayoutVersion:e.version===U?e.sqliteLayoutVersion:void 0})}function Sr(t){let e=t.fingerprint!==void 0,n=f(t.fingerprint),r=t.indexedLanguages!==void 0,i=t.status==="complete",o=t.version===U?t:null;return{usableForQuery:r,usableForEvidenceCache:e,publishableGeneration:i&&n&&r,stableGenerationIdentity:i&&e&&typeof t.updatedAt=="string",languageShardReuse:!!o?.languageFingerprints,typescriptProjectShardReuse:!!o?.typescriptProjectShards}}function vr(t,e){if(t.status!=="complete"&&t.status!=="partial")return"status must be complete or partial";if(t.updatedAt!==void 0&&!oe(t.updatedAt))return"updatedAt must be a valid timestamp";for(let n of["requestedLanguages","indexedLanguages"])if(t[n]!==void 0&&!Rr(t[n]))return`${n} must contain unique supported languages`;return t.skipped!==void 0&&!xr(t.skipped)?"skipped must contain supported language/reason pairs":t.scipCompanion!==void 0&&t.scipCompanion!=="current"&&t.scipCompanion!=="deferred"?"scipCompanion must be current or deferred":e===U&&t.sqliteLayoutVersion!==void 0&&(!Number.isSafeInteger(t.sqliteLayoutVersion)||t.sqliteLayoutVersion<1)?"sqliteLayoutVersion must be a positive safe integer":e===U&&t.languageFingerprints!==void 0&&!Ir(t.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":e===U&&t.typescriptProjectShards!==void 0&&!wr(t.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function Rr(t){return!Array.isArray(t)||!t.every(e=>typeof e=="string"&&Me.has(e))?!1:new Set(t).size===t.length}function xr(t){return Array.isArray(t)&&t.every(e=>f(e)&&typeof e.language=="string"&&Me.has(e.language)&&typeof e.reason=="string")}function Ir(t){return f(t)&&Object.entries(t).every(([e,n])=>Me.has(e)&&f(n))}function wr(t){return f(t)&&Object.values(t).every(e=>f(e)&&Array.isArray(e.files)&&e.files.every(vt))}function kr(t){return t instanceof Error?t.message:String(t)}function A(){return performance.now()}var Mr=1;var Or=".scipquery-generations";var ma={pid:process.pid,now:()=>new Date,randomToken:()=>Cr(),isProcessAlive:V,readProcessIdentity:G};function _r(t){return Oe(It(t),Or)}function jr(t){try{let e=JSON.parse(I(Oe(_r(t),"state.json"),"SQLite generation state"));return Fr(e)?e:null}catch{return null}}function wt(t){let e=jr(t);if(e)return e.currentGeneration;try{let n=Oe(It(t),"meta.json"),r=Er(n)?I(n,"reindex metadata"):void 0;return Tr(t,r)}catch{return null}}function Dr(t){return xt(Rt(t))??t}function Tr(t,e){let n=Pr("sha256").update("sqlite-generation-legacy-v1\0");return e!==void 0&&n.update(Dr(e)),n.update(`\0${Nr(t)}`),n.digest("hex")}function Nr(t){let e=Ar(t);return`${e.dev}:${e.ino}:${e.size}:${e.mtimeMs}`}function Fr(t){return t.version===Mr&&typeof t.currentGeneration=="string"&&!!t.currentGeneration&&typeof t.publishedAt=="string"&&Number.isFinite(Date.parse(t.publishedAt))&&(t.artifactSet===void 0||t.artifactSet==="immutable-v1")&&Lr(t.stableMirrors)&&Wr(t.previousGeneration)&&qr(t.publication)}function Lr(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t;return typeof e.databaseFileIdentity=="string"&&!!e.databaseFileIdentity&&(e.indexFileIdentity===void 0||typeof e.indexFileIdentity=="string"&&!!e.indexFileIdentity)}function Wr(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t;return typeof e.generationIdentity=="string"&&!!e.generationIdentity&&typeof e.databasePath=="string"&&!!e.databasePath&&(e.metadataPath===void 0||typeof e.metadataPath=="string"&&!!e.metadataPath)}function qr(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t,n=[e.converterDurationMs,e.affectedDocumentCount,e.changedDocumentCount,e.producerDurationMs,e.materializationDurationMs,e.patchDurationMs].filter(r=>r!==void 0);return(e.mode==="incremental"||e.mode==="full")&&e.validation==="passed"&&e.converterDurationMs!==void 0&&n.every(r=>typeof r=="number"&&Number.isFinite(r)&&r>=0)&&(e.scipCompanion===void 0||e.scipCompanion==="current"||e.scipCompanion==="deferred")&&(e.typescriptOverlayGeneration===void 0||typeof e.typescriptOverlayGeneration=="string"&&!!e.typescriptOverlayGeneration)&&(e.scipCompanion!=="deferred"||!!e.typescriptOverlayGeneration)&&(e.fallbackReason===void 0||typeof e.fallbackReason=="string")}import{existsSync as ti}from"fs";import{randomUUID as Pa}from"crypto";import{isAbsolute as Ea,join as ni,relative as Aa,resolve as Ma}from"path";var L=1,H=2,Br="./node_modules/scip-query/docs/schemas/project-config.schema.json";function kt(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(a){return{kind:"malformed",reason:`invalid JSON: ${a instanceof Error?a.message:String(a)}`}}if(!f(e))return{kind:"malformed",reason:"project config must be a JSON object"};let n=e.schemaVersion;if(n!==void 0&&!Number.isInteger(n))return{kind:"malformed",reason:"schemaVersion must be an integer"};let r=n===void 0?L:n;if(r!==L&&r!==H)return{kind:"unsupported",schemaVersion:r,direction:r<L?"older":"future"};let i=e.$schema;if(i!==void 0&&(typeof i!="string"||i.trim()===""))return{kind:"malformed",reason:"$schema must be a non-empty string when present"};let o=Pt(e),s=r!==H||typeof e.$schema!="string";return r===L?{kind:"legacy",sourceVersion:L,config:o,needsMigration:s}:{kind:"supported",sourceVersion:H,config:o,needsMigration:s}}function Pt(t){let e=t,{$schema:n,schemaVersion:r,...i}=e;return{$schema:typeof n=="string"&&n.trim()!==""?n:Br,schemaVersion:H,...i}}import{createHash as va}from"crypto";var _e=1,Ct=2,Gr=1,Vr=1,$r="sha256";function Et(t){if(!f(t))return{kind:"malformed",reason:"observation receipt must be an object"};let e=t.schemaVersion;if(!Number.isInteger(e))return{kind:"malformed",reason:"observation receipt schemaVersion must be an integer"};if(e===_e)return Ur(t)?{kind:"legacy",schemaVersion:_e,receipt:t}:{kind:"malformed",reason:"observation receipt v1 fields are malformed or contradictory"};if(e===Ct)return Hr(t)?{kind:"supported",schemaVersion:Ct,receipt:t}:{kind:"malformed",reason:"observation receipt v2 facts are malformed or contradictory"};let n=e;return{kind:"unsupported",schemaVersion:n,direction:n<_e?"older":"future"}}function Qr(t,e){return t.schemaVersion===e.schemaVersion&&t.canonicalizationVersion===e.canonicalizationVersion&&t.hashAlgorithm===e.hashAlgorithm&&t.projection.name===e.projection.name&&t.projection.version===e.projection.version}function Ur(t){if(!f(t))return!1;let e=t.index,n=t.worktree;return Mt(t.observedAt)&&k(t.projectIdentity)&&ei(t.authorityKind)&&(e===void 0||f(e)&&k(e.generationIdentity)&&(e.source==="immutable"||e.source==="legacy")&&(e.alignment==="not-certified"||e.alignment==="leased"))&&(n===void 0||f(n)&&k(n.identity)&&typeof n.clean=="boolean"&&(n.headCommit===void 0||k(n.headCommit))&&(n.treeOid===void 0||k(n.treeOid)))&&Zr(t.authorityKind,e,n)}function Hr(t){if(!f(t))return!1;let e=t.facts,n=t.observedSources,r=t.stabilityProofs;if(!Mt(t.observedAt)||!f(e)||!Array.isArray(n)||n.length===0||!n.every(Kr)||!De(n,c=>c.kind)||!Array.isArray(r)||!r.every(Yr)||!De(r,c=>c.source)||r.some(c=>!n.some(u=>u.kind===c.source))||!r.every(c=>Xr(c,e))||["collaborationDomain","repositoryLineage","workspaceInstance","wholeContent"].some(c=>e[c]!==void 0&&!N(e[c])))return!1;let o=e.relevantInputs;if(o!==void 0&&(!Array.isArray(o)||!o.every(Jr)||!De(o,c=>`${c.subject}\0${c.identity.projection.name}`)))return!1;let s=e.index;if(s!==void 0&&(!f(s)||!N(s.generation)||s.inputs!==void 0&&!N(s.inputs)||s.source!=="immutable"&&s.source!=="legacy"))return!1;let a=t.diagnostics;return(a===void 0||f(a)&&(a.clean===void 0||typeof a.clean=="boolean")&&(a.headCommit===void 0||k(a.headCommit))&&(a.treeOid===void 0||k(a.treeOid)))&&zr(e,n)}function N(t){return!f(t)||!f(t.projection)?!1:t.schemaVersion===Gr&&t.canonicalizationVersion===Vr&&t.hashAlgorithm===$r&&k(t.projection.name)&&rt(t.projection.version)&&it(t.digest)}function Jr(t){return f(t)&&k(t.subject)&&N(t.identity)}function Kr(t){return f(t)&&At(t.kind)&&(t.identity===void 0||N(t.identity))}function Yr(t){return f(t)&&At(t.source)&&(t.kind==="immutable"||t.kind==="fixed-snapshot"||t.kind==="bracketed"||t.kind==="not-established"||t.kind==="invalidated")}function zr(t,e){let n=t.index,r=e.find(c=>c.kind==="index-generation");if(r){if(!f(n)||!N(n.generation)||r.identity&&!je(r.identity,n.generation))return!1}else if(n!==void 0)return!1;let i=t.workspaceInstance,o=e.find(c=>c.kind==="live-workspace");if(o?.identity&&(!N(i)||!je(o.identity,i)))return!1;let s=t.wholeContent,a=e.find(c=>c.kind==="repository-snapshot");return!(a?.identity&&(!N(s)||!je(a.identity,s)))}function Xr(t,e){return t.kind==="not-established"||t.kind==="invalidated"?!0:t.source==="index-generation"?t.kind==="immutable"&&f(e.index)&&e.index.source==="immutable":t.source==="repository-snapshot"?t.kind==="fixed-snapshot":t.source==="live-workspace"?t.kind==="bracketed":!1}function je(t,e){return Qr(t,e)&&t.digest===e.digest}function Zr(t,e,n){return t==="index-worktree"?e!==void 0&&n!==void 0:t==="index-only"?e!==void 0&&n===void 0:t==="worktree-only"?e===void 0&&n!==void 0:t==="process-local"&&e===void 0&&n===void 0}function ei(t){return t==="index-worktree"||t==="index-only"||t==="worktree-only"||t==="process-local"}function At(t){return t==="index-generation"||t==="repository-snapshot"||t==="live-workspace"||t==="process"}function Mt(t){return typeof t=="string"&&!Number.isNaN(Date.parse(t))}function De(t,e){return new Set(t.map(e)).size===t.length}var de=".scipquery.json";var Da=15*6e4,Ta={enabled:!0,windowMs:15*6e4,maxRebuilds:2,maxEstimatedWriteBytes:1024*1024*1024};var Na=new Set(Q);function Ot(t){let e=ni(t,de);if(!ti(e))return{};let n;try{n=q(e,{maxBytes:Ze,inputKind:"scip-query project config"})}catch(r){let i=r instanceof Error?r.message:String(r);throw new Error(`unable to read ${de} at ${e}: ${i}`,{cause:r})}return ri(kt(n),e,"read").config}function ri(t,e,n){if(t.kind==="legacy"||t.kind==="supported")return t;if(t.kind==="malformed"){let i=n==="read"?`invalid ${de} at ${e}: ${t.reason}`:`Cannot update ${e}: the latest project config is ${t.reason}.`;throw new Error(`${i} The file was left untouched.`)}let r=n==="read"?`invalid ${de} at ${e}`:`Cannot update ${e}: the latest project config is invalid`;throw new Error(`${r} (unsupported ${t.direction} schemaVersion ${t.schemaVersion}; this scip-query reads legacy v${L} and current v${H}). Upgrade scip-query before retrying; the file was left untouched.`)}import{spawnSync as ii}from"child_process";import{createHash as oi}from"crypto";import{existsSync as si,lstatSync as ai,realpathSync as ci}from"fs";import{dirname as ui,isAbsolute as di,join as li,relative as $a,resolve as pe,sep as Qa}from"path";var _t=Symbol.for("scip-query.project-file-listing-context.v1"),jt=globalThis,Te=jt[_t],Dt=Te&&typeof Te=="object"?Te:{};jt[_t]=Dt;function Tt(){return Dt.sequence??0}var Fe={run(t,e){let n=Lt(t,e);return n.kind==="success"?n.output:void 0},runResult:Lt},pi=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],Wt=["status","--porcelain=v2","--branch","-z","--untracked-files=all"],Ne=/^[0-9a-f]{40,64}$/;function qt(t,e=Fe){return fi(t,e)?.context}function fi(t,e=Fe){let n=e.runResult(t,pi);if(n.kind==="success"){let i=yi(n.output);if(i){let o=mi(i,e);if(o)return Nt(o)}}let r=gi(t,e);return r?Nt(r):void 0}function Nt(t){return{context:t,projectFileInventorySequence:Tt()}}function Bt(t){let e=t.split("\0").filter(Boolean),n=e.find(i=>i.startsWith("# branch.oid "))?.slice(13),r=n==="(initial)"?void 0:n;if(!(r!==void 0&&!Ne.test(r))&&n!==void 0)return{headCommit:r,clean:e.every(i=>i.startsWith("# "))}}function yi(t){let e=t.split(`
3
+ `).map(c=>c.trim());if(e.length!==5)return;let[n,r,i,o,s]=e;if(!n||!r||!i||!o||!s||!Ne.test(o)||!Ne.test(s))return;let a=M(n);return{root:a,gitDir:M(le(a,r)),commonDir:M(le(a,i)),headCommit:o,treeOid:s}}function mi(t,e){let n=e.run(t.root,Wt);if(n===void 0)return;let r=Bt(n);return r?.headCommit!==t.headCommit?void 0:{...Gt(t.root,t.gitDir),commonDir:t.commonDir,repositoryId:We("repository",t.commonDir),headCommit:t.headCommit,treeOid:t.treeOid,clean:r.clean}}function gi(t,e){let n=Le(t,e);if(n.kind!=="worktree")return;let r=n.identity,i=r.projectRoot,o=e.run(i,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=M(le(i,o)),a=Ft(e.run(i,["rev-parse","--verify","HEAD"])),c=Ft(e.run(i,["rev-parse","--verify","HEAD^{tree}"])),u=e.run(i,Wt);if(u===void 0)return;let l=Bt(u);if(!(!l||l.headCommit!==a))return{...r,commonDir:s,repositoryId:We("repository",s),headCommit:a,treeOid:c,clean:l.clean}}function Le(t,e=Fe){let n=e.runResult(t,["rev-parse","--show-toplevel"]);if(n.kind==="not-repository")return{kind:"non-git"};if(n.kind==="error")return n;let r=n.output.trim();if(!r)return{kind:"error",message:"Git returned an empty worktree root."};let i=M(r),o=e.run(i,["rev-parse","--absolute-git-dir"])?.trim();if(!o)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=M(le(i,o));return{kind:"worktree",identity:Gt(i,s)}}function Gt(t,e){return{projectRoot:t,gitDir:e,worktreeId:We("worktree",`${t}\0${e}`)}}function le(t,e){return di(e)?e:pe(t,e)}function M(t){try{return ci(t)}catch{return pe(t)}}function We(t,e){return oi("sha256").update(`${t}\0${e}`).digest("hex").slice(0,24)}function Ft(t){return t?.trim()||void 0}function Lt(t,e){let n=ii("git",["-C",t,...e],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"],timeout:3e4,killSignal:"SIGKILL"});if(n.status===0)return{kind:"success",output:n.stdout.trimEnd()};let i=(typeof n.stderr=="string"?n.stderr.trim():"")||n.error?.message||`git exited with status ${n.status??"unknown"}`,o=n.error?.code;return(/not a git repository/i.test(i)||o==="ENOENT"&&si(pe(t)))&&!hi(t)?{kind:"not-repository"}:{kind:"error",message:i}}function hi(t){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let e=pe(t);for(;;){try{return ai(li(e,".git")),!0}catch(r){let i=r.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let n=ui(e);if(n===e)return!1;e=n}}function qe(){return process.env.SCIP_QUERY_PROJECT_ROOT??process.cwd()}var Vt;function $t(t=qe(),e=void 0){if(e===void 0&&Vt?.projectRoot===t)return Vt;let n=Ot(t),r=bt(t,n),i=process.env.SCIP_QUERY_INDEX_DB;if(i)return{projectRoot:t,config:n,paths:r,dbPath:i,dbPathSource:"env",gitContext:e};if(bi(r.dbPath))return{projectRoot:t,config:n,paths:r,dbPath:r.dbPath,dbPathSource:"configured",gitContext:e};let o=vi(t,"index.db");return{projectRoot:t,config:n,paths:r,dbPath:o,dbPathSource:"root-fallback",rootFallbackWarning:Ri(o,r.dbPath),gitContext:e}}function Ri(t,e){let n="unknown time";try{n=Si(t).mtime.toISOString()}catch{}return`warning: using legacy project-root index.db (${t}, modified ${n}) because the configured index was not found at ${e}. This fallback may be stale; run 'scip-query reindex' to refresh the configured index.`}import{basename as xi}from"path";function Qt(t=process.argv,e=process.execPath){let n=t[1];return!n||xi(n)==="scip-query"?["scip-query"]:[e,n]}import{spawn as co}from"child_process";import{createHash as ve,randomUUID as uo}from"crypto";import{existsSync as Qe,realpathSync as lo}from"fs";import{tmpdir as po}from"os";import{join as Ue,resolve as re}from"path";import{fileURLToPath as fo}from"url";function fe(t){return Be(t,Ii)}function Be(t,e){return Array.isArray(t)?`[${t.map(n=>Be(n,e)).join(",")}]`:t&&typeof t=="object"?`{${Object.entries(t).sort(([n],[r])=>e(n,r)).map(([n,r])=>`${JSON.stringify(n)}:${Be(r,e)}`).join(",")}}`:JSON.stringify(t)}function Ii(t,e){return t<e?-1:t>e?1:0}import{createHash as rc,randomUUID as Yt}from"crypto";import{closeSync as oc,existsSync as Y,fstatSync as sc,lstatSync as ne,mkdirSync as ac,openSync as cc,readdirSync as K,readSync as uc,renameSync as zt,rmSync as F}from"fs";import{basename as ye,dirname as wi,join as g}from"path";var me=1,ki=Object.freeze({maxItems:1024,maxBytes:512*1024*1024,maxItemBytes:64*1024*1024,maxBatch:16,claimLeaseMs:5*6e4,responseRetentionMs:10*6e4,deadLetterRetentionMs:1440*6e4,temporaryRetentionMs:6e4,cleanupBatch:64}),J=class extends Error{constructor(n,r,i,o){let s=n==="item-too-large"?`request is ${o} bytes; per-item limit is ${i.maxItemBytes}`:n==="item-capacity"?`mailbox has ${r.totalItems} retained items; limit is ${i.maxItems}`:n==="byte-capacity"?`mailbox retains ${r.totalBytes} bytes and the request adds ${o}; limit is ${i.maxBytes}`:"another writer held the admission coordinator through the bounded wait";super(`Mailbox backpressure: ${s}. Retry after the service drains or expires retained work.`);this.code=n;this.status=r;this.limits=i;this.attemptedBytes=o;this.name="MailboxBackpressureError"}code;status;limits;attemptedBytes},Pi=".owner.json",Ci={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function Xt(t){return{rootDir:t,pendingDir:g(t,"pending"),inflightDir:g(t,"inflight"),responseDir:g(t,"responses"),deadLetterDir:g(t,"dead-letter"),legacyRequestDir:g(t,"requests")}}function Ei(t={}){let e={...ki,...t};for(let[n,r]of Object.entries(e))if(!Number.isFinite(r)||r<=0||!Number.isInteger(r))throw new Error(`Mailbox limit ${n} must be a positive integer.`);return e}function Zt(t){let e=[t.pendingDir,t.inflightDir,t.responseDir,t.deadLetterDir,t.legacyRequestDir].map(n=>ie(n));return B(...e)}function ge(t){if(!/^[a-f0-9]{64}$/.test(t))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${t}`}function en(t,e,n={}){let r=Ei(n.limits),i=n.nowMs??Date.now(),o=Zt(t);return Ni(e),Mi(t,r,n.admissionLockTimeoutMs??2e3,n.monotonicNow??A,n.durability??"durable",()=>{Ai(t,i,r);let s=g(t.pendingDir,`${e.id}.json`),a=g(t.responseDir,`${e.id}.json`),c=Ut(t,e.id);if(c){let y=Ht(c,e.operationKey,e.id);return{disposition:"duplicate",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:y.deadlineAtMs??e.deadlineAtMs}}let u=`${JSON.stringify(e)}
4
+ `,l=Buffer.byteLength(u),p=tn(t);if(l>r.maxItemBytes)throw new J("item-too-large",p,r,l);if(p.totalItems+1>r.maxItems)throw new J("item-capacity",p,r,l);if(p.totalBytes+l>r.maxBytes)throw new J("byte-capacity",p,r,l);n.onBeforePublish?.();try{let y=n.durability??"durable",R=we(s,u,{durability:y}),P=y==="durable"?B(o,R.directorySync):"not-requested";return{disposition:"accepted",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:e.deadlineAtMs,achievedDurability:R.achievedDurability,directorySync:P}}catch(y){if(y.code!=="EEXIST")throw y;let R=Ut(t,e.id);if(!R)throw y;let P=Ht(R,e.operationKey,e.id);return{disposition:"duplicate",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:P.deadlineAtMs??e.deadlineAtMs}}})}function Ai(t,e,n,r=Ci){let i={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=n.cleanupBatch;for(let s of Ve(t.inflightDir)){if(o<=0)break;let a=g(t.responseDir,`${s.requestId}.json`);if(Y(a)){F(s.path,{force:!0}),i.completedClaimsRemoved++,o--;continue}if(s.claimExpiresAtMs>e||Di(t,s.ownerId,r)!=="dead")continue;let c=g(t.pendingDir,s.originalFile);try{zt(s.path,c),i.reclaimed++}catch(u){if(u.code!=="EEXIST")throw u;F(s.path,{force:!0})}_(wi(s.path)),_(t.pendingDir),o--}o=Jt(t.responseDir,o,(s,a)=>a+n.responseRetentionMs,e,()=>{i.responsesRemoved++}),o=Jt(t.deadLetterDir,o,(s,a)=>a+n.deadLetterRetentionMs,e,()=>{i.deadLettersRemoved++});for(let s of[t.pendingDir,t.inflightDir,t.responseDir,t.deadLetterDir,t.legacyRequestDir]){if(o<=0)break;for(let a of nn(s)){if(o<=0)break;if(!ye(a).includes(".tmp-"))continue;let c;try{c=ne(a).mtimeMs}catch(u){if(u.code==="ENOENT")continue;throw u}c+n.temporaryRetentionMs>e||(F(a,{force:!0}),i.temporaryFilesRemoved++,o--)}}return Fi(t.inflightDir),i}function tn(t){Zt(t);let e=[...te(t.pendingDir).map(c=>({path:c,pending:!0})),...te(t.legacyRequestDir).map(c=>({path:c,pending:!0}))],n=Ve(t.inflightDir).map(c=>({path:c.path,pending:!1})),r=te(t.responseDir).map(c=>({path:c,pending:!1})),i=te(t.deadLetterDir).map(c=>({path:c,pending:!1})),o=[...e,...n,...r,...i],s=0,a;for(let c of e){let u=$e(c.path);if(!u){s++;continue}let l=u.enqueuedAtMs;if(l===void 0)try{l=ne(c.path).mtimeMs}catch(p){if(p.code==="ENOENT")continue;throw p}a=a===void 0?l:Math.min(a,l)}return{pending:e.length,inflight:n.length,responses:r.length,deadLetters:i.length,invalid:s,totalItems:o.length,totalBytes:o.reduce((c,u)=>c+Li(u.path),0),...a===void 0?{}:{oldestPendingAt:new Date(a).toISOString()}}}function Mi(t,e,n,r,i,o){let s=g(t.rootDir,".admission.lock"),a=`${process.pid}-${Yt()}`,c=r()+Math.max(0,n);for(;!Oi(t.rootDir,s,a,i);){if(_i(s),r()>=c)throw new J("admission-busy",tn(t),e,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return o()}finally{try{Ge(s).ownerToken===a&&(F(s,{recursive:!0,force:!0}),i==="durable"&&_(t.rootDir))}catch{}}}function Oi(t,e,n,r){let i=`${JSON.stringify({ownerToken:n,pid:process.pid,acquiredAtMs:Date.now()})}
5
+ `;try{return we(e,i,{durability:r}),!0}catch(o){if(o.code==="EEXIST")return!1;try{Ge(e).ownerToken===n&&(F(e,{force:!0}),r==="durable"&&_(t))}catch{}throw o}}function _i(t){let e=null;try{let r=Ge(t);typeof r.ownerToken=="string"&&Number.isSafeInteger(r.pid)&&Number(r.pid)>0&&(e=Number(r.pid))}catch{}if(e===null||ji(e))return;let n=`${t}.stale-${Yt()}`;try{zt(t,n)}catch(r){let i=r.code;if(i==="ENOENT"||i==="EEXIST")return;throw r}F(n,{recursive:!0,force:!0})}function Ge(t){try{return JSON.parse(I(t,"mailbox lock record"))}catch(e){if(e.code!=="EISDIR"&&!(e instanceof et&&e.reason==="not-regular"))throw e;return JSON.parse(I(g(t,"owner.json"),"mailbox lock owner record"))}}function ji(t){try{return process.kill(t,0),!0}catch(e){let n=e.code;return n==="EPERM"||n!=="ESRCH"}}function Di(t,e,n){let r=Ti(g(t.inflightDir,rn(e),Pi));if(!r)return"unknown";if(!n.isProcessAlive(r.pid))return"dead";if(!r.processIdentity)return"live";let i=n.readProcessIdentity(r.pid);return i?ee(r.processIdentity,i)?"live":"dead":"unknown"}function Ti(t){try{let e=JSON.parse(I(t,"mailbox owner record"));if(e.version!==1||typeof e.ownerId!="string"||!e.ownerId||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0)return null;let n=e.processIdentity===void 0?null:j(e.processIdentity);return e.processIdentity!==void 0&&(!n||n.pid!==e.pid)?null:{version:1,ownerId:e.ownerId,pid:e.pid,...n?{processIdentity:n}:{}}}catch{return null}}function Ut(t,e){for(let n of[g(t.pendingDir,`${e}.json`),g(t.legacyRequestDir,`${e}.json`),g(t.responseDir,`${e}.json`)])if(Y(n))return n;for(let n of Ve(t.inflightDir))if(n.requestId===e)return n.path;return null}function Ht(t,e,n){let r=$e(t);if(r?.operationKey===e)return r;if(ye(t)===`${ge(e)}.json`)return{id:n,operationKey:e};throw new Error(`Mailbox operation ${n} conflicts with an existing retained record.`)}function Ni(t){if(t.mailboxVersion!==me||t.id!==ge(t.operationKey)||!t.clientId.trim()||!Number.isFinite(t.enqueuedAtMs)||!Number.isFinite(t.deadlineAtMs)||t.deadlineAtMs<t.enqueuedAtMs)throw new Error("Mailbox request has an invalid lifecycle identity.")}function Ve(t){if(!Y(t))return[];let e=[];for(let n of K(t,{withFileTypes:!0})){if(!n.isDirectory())continue;let r=Kt(n.name);if(r===null)continue;let i=g(t,n.name);for(let o of K(i,{withFileTypes:!0})){if(!o.isFile()||!o.name.endsWith(".claim"))continue;let s=/^(.*)\.(\d+)\.claim$/.exec(o.name);if(!s)continue;let a=Kt(s[1]),c=Number(s[2]);if(a===null||ye(a)!==a||!a.endsWith(".json")||!Number.isSafeInteger(c))continue;let u=g(i,o.name),l=$e(u)??{id:ye(a,".json")},p;try{p=ne(u)}catch(y){if(y.code==="ENOENT")continue;throw y}e.push({requestId:l.id,ownerId:r,path:u,originalFile:a,claimedAtMs:p.mtimeMs,claimExpiresAtMs:c,byteLength:p.size,...l.operationKey?{operationKey:l.operationKey}:{},...l.clientId?{clientId:l.clientId}:{},...l.enqueuedAtMs===void 0?{}:{enqueuedAtMs:l.enqueuedAtMs},...l.deadlineAtMs===void 0?{}:{deadlineAtMs:l.deadlineAtMs},legacy:l.operationKey===void 0})}}return e.sort((n,r)=>n.claimedAtMs-r.claimedAtMs||n.path.localeCompare(r.path))}function $e(t){try{let e=JSON.parse(I(t,"mailbox record"));return typeof e.id!="string"||!e.id?null:{id:e.id,...typeof e.operationKey=="string"?{operationKey:e.operationKey}:{},...typeof e.clientId=="string"?{clientId:e.clientId}:{},...typeof e.enqueuedAtMs=="number"?{enqueuedAtMs:e.enqueuedAtMs}:{},...typeof e.deadlineAtMs=="number"?{deadlineAtMs:e.deadlineAtMs}:{}}}catch{return null}}function Jt(t,e,n,r,i){for(let o of te(t)){if(e<=0)break;let s;try{s=ne(o)}catch(a){if(a.code==="ENOENT")continue;throw a}n(o,s.mtimeMs)>r||(F(o,{force:!0}),i(),e--)}return e}function te(t){return Y(t)?K(t,{withFileTypes:!0}).filter(e=>e.isFile()).map(e=>g(t,e.name)).sort():[]}function nn(t){if(!Y(t))return[];let e=[];for(let n of K(t,{withFileTypes:!0})){let r=g(t,n.name);n.isFile()?e.push(r):n.isDirectory()&&e.push(...nn(r))}return e.sort()}function Fi(t){if(Y(t))for(let e of K(t,{withFileTypes:!0})){if(!e.isDirectory())continue;let n=g(t,e.name);K(n).some(r=>r.endsWith(".claim"))||F(n,{recursive:!0,force:!0})}}function Li(t){try{return ne(t).size}catch{return 0}}function rn(t){return Buffer.from(t,"utf8").toString("base64url")}function Kt(t){try{let e=Buffer.from(t,"base64url").toString("utf8");return rn(e)===t?e:null}catch{return null}}import{spawn as Xi}from"child_process";import{existsSync as Zi,rmSync as Pc}from"fs";import{dirname as Ec,resolve as eo}from"path";import{fileURLToPath as Mc}from"url";import{join as he}from"path";var on=6,sn=1e4,Wi="watch.lock",qi="watch-state.json",Bi="watch-activity.json",Gi="watch-refresh-requests";function an(t){return{lockPath:he(t,Wi),statePath:he(t,qi),activityPath:he(t,Bi),refreshRequestsPath:he(t,Gi)}}function cn(t){try{return Vi(JSON.parse(I(t,"watch service state")))}catch{return null}}function Vi(t){if(!t||typeof t!="object")return null;let e=t;if(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"||!h(e.startedAt)||!h(e.heartbeatAt)||!h(e.lastActivityAt)||!$i(e.watcher)||e.idleDeadlineAt!==void 0&&!h(e.idleDeadlineAt))return null;if(e.processIdentity!==void 0){let n=j(e.processIdentity);if(!n||n.pid!==e.pid)return null;e.processIdentity=n}return e.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(e.indexGeneration)||e.lastError!==void 0&&!Qi(e.lastError)||e.lastRefresh!==void 0&&!Ui(e.lastRefresh)||e.reindexActivity!==void 0&&!Hi(e.reindexActivity)||e.refreshRequests!==void 0&&!Ki(e.refreshRequests)||e.typescriptSemantic!==void 0&&!Yi(e.typescriptSemantic)||e.typescriptIndex!==void 0&&!zi(e.typescriptIndex)?null:e}function h(t){return oe(t)}function $i(t){if(!t||typeof t!="object"||!("state"in t))return!1;let e=t;switch(e.state){case"idle":return!0;case"waiting":return b(e.changedFiles)&&b(e.reindexAt);case"indexing":return b(e.startedAt);case"cooldown":return b(e.until)&&typeof e.dirty=="boolean";case"budget-paused":return b(e.until)&&typeof e.dirty=="boolean"&&typeof e.reason=="string"&&d(e.rebuilt)&&d(e.estimatedWriteBytes);case"draining":return b(e.startedAt)&&typeof e.reason=="string";default:return!1}}function Qi(t){if(!t||typeof t!="object")return!1;let e=t;return h(e.at)&&typeof e.message=="string"}function Ui(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.trigger?.kind=="string"&&typeof e.result=="string"&&h(e.startedAt)&&h(e.completedAt)&&b(e.durationMs)}function Hi(t){if(!t||typeof t!="object")return!1;let e=t;return e.confidence!==void 0&&e.confidence!=="complete"&&e.confidence!=="partial"&&e.confidence!=="unavailable"||e.recordsRead!==void 0&&!d(e.recordsRead)||e.invalidRecords!==void 0&&!d(e.invalidRecords)||e.skippedRecords!==void 0&&!d(e.skippedRecords)||e.readErrors!==void 0&&!d(e.readErrors)||e.ignoredPartialTailBytes!==void 0&&!d(e.ignoredPartialTailBytes)||!h(e.windowStartedAt)||!h(e.windowEndedAt)||!d(e.runs)||!d(e.rebuilt)||e.fullRebuilds!==void 0&&!d(e.fullRebuilds)||!d(e.reused)||!d(e.failed)||!d(e.suppressed)||!b(e.estimatedLogicalOutputBytes)||e.estimatedWriteBytes!==void 0&&!d(e.estimatedWriteBytes)||e.reflinkedBytes!==void 0&&!d(e.reflinkedBytes)||e.fallbackCopiedBytes!==void 0&&!d(e.fallbackCopiedBytes)||e.oldestRebuildAt!==void 0&&!h(e.oldestRebuildAt)||e.oldestWriteAt!==void 0&&!h(e.oldestWriteAt)||e.languageAttribution!==void 0&&e.languageAttribution!=="complete"&&e.languageAttribution!=="partial"&&e.languageAttribution!=="unavailable"||e.attributedRuns!==void 0&&!d(e.attributedRuns)||e.unattributedRuns!==void 0&&!d(e.unattributedRuns)||e.invalidLanguageDetails!==void 0&&!d(e.invalidLanguageDetails)||e.estimatedLogicalOutputBytes<0||!e.byTrigger||typeof e.byTrigger!="object"||Array.isArray(e.byTrigger)||e.byLanguage!==void 0&&!Ji(e.byLanguage)?!1:Object.values(e.byTrigger).every(n=>n===void 0||d(n))}function Ji(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;for(let[e,n]of Object.entries(t)){if(!Q.includes(e)||!n||typeof n!="object")return!1;let r=n;if(!d(r.runs)||!d(r.rebuilt)||!d(r.reused)||!d(r.producedOutputBytes)||!ot(r.durationMs)||r.rebuilt+r.reused!==r.runs)return!1}return!0}function Ki(t){if(!t||typeof t!="object")return!1;let e=t;return d(e.pending)&&d(e.claimed)&&d(e.completed)&&d(e.expired)&&d(e.invalid)&&(e.oldestPendingAt===void 0||h(e.oldestPendingAt))}function Yi(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")&&b(e.requests)&&b(e.sessionsCreated)&&b(e.sessionsReused)&&b(e.sessionsRefreshed)&&b(e.sessionsReplaced)&&b(e.projectsCreated)&&(e.lastRequestAt===void 0||h(e.lastRequestAt))&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||h(e.busyUntil))&&(e.mailbox===void 0||un(e.mailbox))}function zi(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")&&d(e.requests)&&d(e.sessionsCreated)&&d(e.sessionsReplaced)&&(e.sessionsEvicted===void 0||d(e.sessionsEvicted))&&(e.activeSessions===void 0||d(e.activeSessions))&&(e.maxActiveSessions===void 0||d(e.maxActiveSessions))&&(e.heapUsedBytes===void 0||d(e.heapUsedBytes))&&(e.heapLimitBytes===void 0||d(e.heapLimitBytes))&&(e.softMemoryLimitBytes===void 0||d(e.softMemoryLimitBytes))&&(e.retireRequested===void 0||typeof e.retireRequested=="boolean")&&d(e.initializations)&&d(e.programUpdates)&&d(e.documentsEmitted)&&d(e.documentsRemoved)&&(e.lastRequestAt===void 0||h(e.lastRequestAt))&&(e.lastDurationMs===void 0||b(e.lastDurationMs)&&e.lastDurationMs>=0)&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||h(e.busyUntil))&&(e.mailbox===void 0||un(e.mailbox))}function un(t){if(!t||typeof t!="object")return!1;let e=t;return d(e.pending)&&d(e.inflight)&&d(e.responses)&&d(e.deadLetters)&&d(e.invalid)&&d(e.totalItems)&&b(e.totalBytes)&&e.totalBytes>=0&&e.totalItems===e.pending+e.inflight+e.responses+e.deadLetters&&(e.oldestPendingAt===void 0||h(e.oldestPendingAt))}function b(t){return typeof t=="number"&&Number.isFinite(t)}function dn(t){let e=t.classification;if(e.kind!=="live")return;let{state:n}=e;return n.watcher.state==="idle"&&n.lastError===void 0?n.indexGeneration:void 0}function to(t,e,n){let r=M(eo(t));if(n&&M(n.projectRoot)===r)return{projectRoot:r,worktreeKind:"git",worktreeId:n.worktreeId,cliVersion:e};let i=Le(r);if(i.kind==="error")throw new Error(`Could not establish Git worktree identity for ${r}: ${i.message}`);return i.kind==="non-git"?{projectRoot:r,worktreeKind:"non-git",cliVersion:e}:{projectRoot:r,worktreeKind:"git",worktreeId:i.identity.worktreeId,cliVersion:e}}function ln(t){return no(t,to(t.projectRoot,t.cliVersion,t.gitContext))}function no(t,e){let n=t.runtime??ao,r=an(t.cacheDir),i=cn(r.statePath),o=ro(r.lockPath);return{identity:e,classification:so(i,e,n.now(),n.isProcessAlive),lock:o,lockIsLive:o!==null&&n.isProcessAlive(o.pid),paths:r}}function ro(t){return oo(st(t,{parseLegacy:io}))}var io=t=>{let e=pn(t);return e?{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}:null};function oo(t){if(t.state==="valid"&&t.record?.kind==="watch"){let e=t.record.detail?.projectRoot;return typeof e!="string"?null:{version:1,pid:t.record.pid,...t.record.processIdentity?{processIdentity:t.record.processIdentity}:{},projectRoot:e,startedAt:t.record.startedAt}}return pn(t.parsed)}function pn(t){try{let e=t;if(e.version!==1||typeof e.pid!="number"||!Number.isInteger(e.pid)||e.pid<=0||typeof e.projectRoot!="string"||!h(e.startedAt))return null;let n=e.processIdentity===void 0?null:j(e.processIdentity);return e.processIdentity!==void 0&&(!n||n.pid!==e.pid)?null:{version:1,pid:e.pid,...n?{processIdentity:n}:{},projectRoot:e.projectRoot,startedAt:e.startedAt}}catch{return null}}function so(t,e,n,r){if(!t)return{kind:"stopped"};if(t.protocolVersion!==on)return{kind:"incompatible",state:t,reason:"protocol"};if(t.projectRoot!==e.projectRoot)return{kind:"incompatible",state:t,reason:"project"};let i=e.worktreeKind==="git"?e.worktreeId:void 0;if(t.worktreeId!==i)return{kind:"incompatible",state:t,reason:"worktree"};if(t.cliVersion!==e.cliVersion)return{kind:"incompatible",state:t,reason:"cli-version"};if(!r(t.pid))return{kind:"stale",state:t,reason:"dead-process"};let o=Date.parse(t.heartbeatAt);return n-o>sn?{kind:"stale",state:t,reason:"old-heartbeat"}:{kind:"live",state:t}}var ao={now:Date.now,monotonicNow:A,isProcessAlive:V,readProcessIdentity:G,spawnServer(t,e,n,r){if(!Zi(t))throw new Error(`Watch service helper was not found at ${t}. Run npm run build first.`);Xi(process.execPath,[t,e,n,JSON.stringify(r)],{detached:!0,stdio:"ignore",env:{...process.env,SCIP_QUERY_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(t){process.kill(t,"SIGTERM")},forceSignalProcess(t){process.kill(t,"SIGKILL")},sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)}};var W=18,yo=1e3,mo=2*yo,go=4,ho=4,bo=5,So=3,vo=3,Ro=4,xo=3,Io=3,wo=8,fn=3e4,ko=5e3,mn=5,Po=10,Co=1,Eo=5,He=64*1024*1024,Ao={maxItems:64,maxBytes:128*1024*1024,maxItemBytes:He,maxBatch:1,responseRetentionMs:6e4};function gn(t,e,n={},r={}){return m(t,i=>({kind:"source-search",expectedGeneration:i,pattern:e,options:n}),as,"search result",r)}function hn(t,e,n={}){return m(t,r=>({kind:"outline",expectedGeneration:r,filePattern:e}),To,"outline result",n)}function bn(t,e={},n={}){return m(t,r=>({kind:"entrypoints",expectedGeneration:r,options:e}),No,"entrypoints result",n)}function Sn(t,e,n={}){return m(t,r=>({kind:"files",expectedGeneration:r,pattern:e}),Fo,"files result",n)}function vn(t,e={}){return m(t,n=>({kind:"stats",expectedGeneration:n}),Lo,"stats result",e)}function Rn(t,e,n={}){return m(t,r=>({kind:"members",expectedGeneration:r,symbolPattern:e}),Wo,"members result",n)}function xn(t,e,n={}){return m(t,r=>({kind:"methods",expectedGeneration:r,className:e}),qo,"methods result",n)}function In(t,e,n,r={}){return m(t,i=>({kind:"file-dependencies",expectedGeneration:i,direction:e,filePattern:n}),Bo,"file dependencies result",r)}function wn(t,e,n={}){return m(t,r=>({kind:"imported-by",expectedGeneration:r,symbolPattern:e}),Wn,"imported-by result",n)}function kn(t,e,n={}){return m(t,r=>({kind:"hierarchy",expectedGeneration:r,symbolPattern:e}),Qo,"hierarchy result",n)}function Pn(t,e,n={}){return m(t,r=>({kind:"by-kind",expectedGeneration:r,kindQuery:e}),Ho,"by-kind result",n)}function Cn(t,e={}){return m(t,n=>({kind:"kind-counts",expectedGeneration:n}),Ko,"kind-counts result",e)}function En(t,e,n={}){return m(t,r=>({kind:"refs",expectedGeneration:r,symbolPattern:e}),zo,"refs result",n)}function An(t,e,n={}){return m(t,r=>({kind:"trace",expectedGeneration:r,symbolPattern:e}),z,"trace result",n)}function Mn(t,e,n={}){return m(t,r=>({kind:"value-flow",expectedGeneration:r,symbolPattern:e}),z,"value-flow result",n)}function On(t,e,n={}){return m(t,r=>({kind:"dependence-slice",expectedGeneration:r,criterion:e}),z,"dependence-slice result",n)}function _n(t,e,n,r={}){return m(t,i=>({kind:e,expectedGeneration:i,symbolPattern:n}),z,`${e} result`,r)}function jn(t,e,n={}){return m(t,r=>({kind:"system",expectedGeneration:r,modulePattern:e}),z,"system result",n)}function Dn(t,e,n={}){return m(t,r=>({kind:"imports",expectedGeneration:r,filePattern:e}),Wn,"imports result",n)}function Tn(t,e,n={}){return m(t,r=>({kind:"unused-imports",expectedGeneration:r,filePattern:e}),Go,"unused imports result",n)}function Nn(t,e,n={}){return m(t,r=>({kind:"surface",expectedGeneration:r,modulePattern:e}),Zo,"surface result",n)}function Fn(t,e,n,r={}){return m(t,i=>({kind:"code",expectedGeneration:i,selectors:[...e],options:n}),z,"serialized code result",r)}function m(t,e,n,r,i){if(!ds(i.allowDefault===!0))return null;try{let o=i.allowDefault===!0&&process.env.SCIP_QUERY_QUERY_SERVICE!=="1",s=o?qt(t):void 0,a=$t(t,s);if(!Qe(a.dbPath))return null;let c=wt(a.dbPath);if(!c||o&&!Mo(a,s,c))return null;let u=_o({projectRoot:a.projectRoot,dbPath:a.dbPath,generationIdentity:c},e(c),n,r);return{result:u.result,generationIdentity:c,observationReceipt:u.observationReceipt}}catch(o){return qn()&&console.error(`query-service fallback: ${o instanceof Error?o.message:String(o)}`),null}}function Mo(t,e,n){if(t.config.watch?.enabled!==!0)return!1;try{return dn(ln({projectRoot:t.projectRoot,cacheDir:t.paths.cacheDir,cliVersion:$,gitContext:e}))===n}catch{return!1}}function Ln(t){return ve("sha256").update(fe({kind:"scip-query-service-mailbox",protocolVersion:W,sessionDir:re(t)})).digest("hex")}function be(t){let e=Ue(t,"server.json");try{let n=JSON.parse(q(e,{maxBytes:65536,inputKind:"query service state"}));if(!n||typeof n!="object"||Array.isArray(n))return null;let r=n,i=r.processIdentity===void 0?void 0:j(r.processIdentity);return r.protocolVersion!==W||typeof r.sessionIdentity!="string"||r.sessionIdentity!==Ln(t)||typeof r.pid!="number"||!Number.isSafeInteger(r.pid)||r.pid<=0||r.processIdentity!==void 0&&(!i||i.pid!==r.pid)||typeof r.generation!="string"||typeof r.heartbeatAtMs!="number"||!Number.isFinite(r.heartbeatAtMs)?null:{protocolVersion:W,sessionIdentity:r.sessionIdentity,pid:r.pid,...i?{processIdentity:i}:{},generation:r.generation,heartbeatAtMs:r.heartbeatAtMs}}catch{return null}}function Se(t,e=Date.now()){if(!V(t.pid))return!1;let n=e-t.heartbeatAtMs;if(n>=0&&n<=mo||!t.processIdentity)return!0;let r=G(t.pid);return r!==null&&ee(t.processIdentity,r)}function Oo(t){let e=t<Po;return{intervalMs:e?Co:mn,checkServerState:!e||t%Eo===0}}function _o(t,e,n,r){let i=us();if(!Qe(i))throw new Error("Query service server executable is unavailable.");let o=Math.abs(process.pid)%ps(e),s=cs(t,i,o),a=Xt(s),c=Date.now(),u=c+fn,l=A()+fn,p=uo(),y=jo(p,e),R=ge(y),P=Ln(s),x=en(a,{mailboxVersion:me,protocolVersion:W,id:R,operationKey:y,clientId:p,enqueuedAtMs:c,deadlineAtMs:u,sessionIdentity:P,request:e},{nowMs:c,limits:Ao,durability:"visibility"});yn(s,t.projectRoot,i,l);let Ye=0;for(;A()<=l;){if(Qe(x.responsePath))return Do(q(x.responsePath,{maxBytes:He,inputKind:"query service response"}),{id:R,operationKey:y,clientId:p,deadlineAtMs:x.authoritativeDeadlineAtMs,generation:t.generationIdentity},n,r);let ze=Oo(Ye);if(ze.checkServerState){let Xe=be(s);(!Xe||!Se(Xe))&&yn(s,t.projectRoot,i,l)}Bn(ze.intervalMs),Ye+=1}throw new Error("Persistent query service timed out.")}function jo(t,e){return ve("sha256").update(fe({namespace:"query-service-v18",payload:{clientId:t,request:e}})).digest("hex")}function yn(t,e,n,r){let i=be(t);if(i&&Se(i))return;let o=Math.min(r,A()+ko),s=Ie(Ue(t,"startup.lock"),{kind:"query-service-startup",detail:{projectRoot:re(e)},directoryDurability:"recoverable"});try{if(s.kind==="acquired"){let a=be(t);if(!a||!Se(a)){let c=qn();co(process.execPath,[n,t,e],{cwd:e,detached:!c,stdio:c?["ignore","ignore","inherit"]:"ignore",env:{...process.env,SCIP_QUERY_QUERY_SERVICE_SERVER:"1"}}).unref()}}for(;A()<=o;){let a=be(t);if(a&&Se(a))return;Bn(mn)}}finally{s.kind==="acquired"&&s.lock.release()}throw new Error("Persistent query service did not become ready within 5s.")}function Do(t,e,n,r){let i=JSON.parse(t);if(!i||typeof i!="object"||Array.isArray(i))throw new Error("Invalid query service response.");let o=i;if(o.mailboxVersion!==me||o.protocolVersion!==W||o.id!==e.id||o.operationKey!==e.operationKey||o.clientId!==e.clientId||o.deadlineAtMs!==e.deadlineAtMs)throw new Error("Query service response identity does not match the request.");if(o.ok!==!0)throw new Error(typeof o.error=="string"?o.error:"Persistent query service rejected the request.");if(o.generation!==e.generation)throw new Error("Persistent query service generation changed.");if(!n(o.result))throw new Error(`Persistent query service returned an invalid ${r}.`);let s=Et(o.observationReceipt);if(s.kind!=="supported")throw new Error("Persistent query service returned an invalid observation receipt.");return{ok:!0,protocolVersion:W,id:e.id,generation:e.generation,result:o.result,observationReceipt:s.receipt}}function To(t){if(!Array.isArray(t))return!1;let e=[...t];for(;e.length>0;){let n=e.pop();if(!n||typeof n!="object"||Array.isArray(n))return!1;let r=n;if(typeof r.symbol!="string"||typeof r.shortName!="string"||!Number.isSafeInteger(r.startLine)||r.startLine<0||!Number.isSafeInteger(r.endLine)||r.endLine<r.startLine||r.signature!==null&&typeof r.signature!="string"||!Array.isArray(r.children))return!1;e.push(...r.children)}return!0}function No(t){return Array.isArray(t)?t.every(e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.symbol=="string"&&typeof n.shortName=="string"&&typeof n.file=="string"&&Number.isSafeInteger(n.startLine)&&n.startLine>=0&&Number.isSafeInteger(n.endLine)&&n.endLine>=n.startLine&&(n.documentation===null||typeof n.documentation=="string")&&(n.confidence==="root"||n.confidence==="candidate")&&Array.isArray(n.evidence)&&n.evidence.every(r=>typeof r=="string")&&Number.isSafeInteger(n.indexedCallerCount)&&n.indexedCallerCount>=0}):!1}function Fo(t){return Array.isArray(t)?t.every(e=>!e||typeof e!="object"||Array.isArray(e)?!1:typeof e.relativePath=="string"):!1}function Lo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return S(e.documents)&&S(e.symbols)&&S(e.definitions)&&S(e.references)&&S(e.indexSizeBytes)&&(e.lastBuilt===null||typeof e.lastBuilt=="string")}function Wo(t){if(!Je(t))return!1;let e=t.members;return Array.isArray(e)&&e.every(ts)}function Je(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return e.matched===!1?e.resolved===void 0&&e.otherMatches===void 0&&e.totalMatches===void 0&&Array.isArray(e.suggestions)&&e.suggestions.every(n=>typeof n=="string"):e.matched===!0&&is(e.resolved)&&Array.isArray(e.otherMatches)&&e.otherMatches.every(os)&&S(e.totalMatches)&&e.totalMatches>=1&&e.suggestions===void 0}function qo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.query!="string"?!1:e.kind==="missing"?Array.isArray(e.suggestions)&&e.suggestions.every(n=>typeof n=="string"):e.kind==="ambiguous"?S(e.total)&&e.total>1&&Array.isArray(e.candidates)&&e.candidates.every(ss):e.kind==="matched"&&rs(e.owner)&&Array.isArray(e.methods)&&e.methods.every(ns)}function Bo(t){return Array.isArray(t)?t.every(e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.relativePath=="string"&&(n.edgeBasis===void 0||n.edgeBasis==="symbol-references")&&(n.evidence===void 0||n.evidence==="cross-file SCIP references plus resolved source imports")}):!1}function Wn(t){return Array.isArray(t)&&t.every($o)}function Go(t){return Array.isArray(t)&&t.every(Vo)}function Vo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.importedIn=="string"}function $o(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.fromFile=="string"}function Qo(t){if(!Je(t))return!1;let e=t.hierarchy;return Array.isArray(e)&&e.every(Uo)}function Uo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&S(e.depth)}function Ho(t){return Array.isArray(t)&&t.every(Jo)}function Jo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&S(e.kind)&&typeof e.kindName=="string"&&typeof e.relativePath=="string"&&Re(e)}function Ko(t){return Array.isArray(t)&&t.every(Yo)}function Yo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return S(e.kind)&&typeof e.kindName=="string"&&S(e.count)}function zo(t){if(!Je(t))return!1;let e=t,n=e.references,r=e.pagination;if(!Array.isArray(n)||!n.every(Xo)||!r||typeof r!="object"||Array.isArray(r))return!1;let i=r;return i.cursorVersion===2&&i.producer==="complete-only"&&typeof i.semanticEnrichment=="boolean"}function Xo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.relativePath=="string"&&S(e.line)}function Zo(t){return Array.isArray(t)&&t.every(es)}function es(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.consumer=="string"&&typeof e.symbol=="string"&&typeof e.shortName=="string"&&e.basis==="external-reference"}function ts(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.kind=="string"&&Re(e)}function ns(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.name=="string"&&Re(e)}function rs(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.relativePath=="string"&&Re(e)}function is(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.relativePath=="string"}function os(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.shortName=="string"&&typeof e.relativePath=="string"&&S(e.startLine)&&e.symbol===void 0}function ss(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.relativePath=="string"&&S(e.startLine)}function Re(t){return S(t.startLine)&&S(t.endLine)&&t.endLine>=t.startLine}function S(t){return Number.isSafeInteger(t)&&t>=0}function as(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.pattern=="string"&&(e.mode==="literal"||e.mode==="regexp")&&Array.isArray(e.matches)&&typeof e.matchingLines=="number"&&Number.isSafeInteger(e.matchingLines)&&e.matchingLines>=0&&typeof e.omittedMatches=="number"&&Number.isSafeInteger(e.omittedMatches)&&e.omittedMatches>=0&&typeof e.scannedFiles=="number"&&Number.isSafeInteger(e.scannedFiles)&&e.scannedFiles>=0}function z(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;if(typeof e.serializedJson!="string"||typeof e.sha256!="string"||e.serializedJson.length>He||ve("sha256").update(e.serializedJson).digest("hex")!==e.sha256)return!1;try{let n=JSON.parse(e.serializedJson);return n!==null&&typeof n=="object"&&!Array.isArray(n)}catch{return!1}}function cs(t,e,n){let r=fs(t.projectRoot),i=ve("sha256").update(fe({protocolVersion:W,projectRoot:r,dbPath:re(t.dbPath),serverPath:re(e),lane:n})).digest("hex");return Ue(po(),"scip-query-query-service",i)}function us(){return process.env.SCIP_QUERY_QUERY_SERVICE_SERVER_PATH??fo(new URL("./query-service-server.js",import.meta.url))}function ds(t){let e=process.env.SCIP_QUERY_QUERY_SERVICE;return process.env.SCIP_QUERY_QUERY_SERVICE_SERVER!=="1"&&e!=="0"&&(e==="1"||t)}function qn(){return process.env.SCIP_QUERY_QUERY_SERVICE_DEBUG==="1"}function ls(){let t=Number(process.env.SCIP_QUERY_QUERY_SERVICE_POOL_SIZE);return Number.isInteger(t)&&t>=1&&t<=wo?t:go}function ps(t){let e=ls();return t.kind==="value-flow"?Math.min(e,xo):t.kind==="dependence-slice"?Math.min(e,Io):t.kind==="call-graph"?Math.min(e,So):t.kind==="system"?Math.min(e,Ro):t.kind==="reference-reachability"||t.kind==="slice"?Math.min(e,vo):t.kind==="refs"||t.kind==="trace"||t.kind==="reference-neighborhood"||t.kind==="dataflow"||t.kind==="imports"||t.kind==="unused-imports"?Math.min(e,bo):t.kind==="imported-by"||t.kind==="hierarchy"||t.kind==="by-kind"||t.kind==="kind-counts"?Math.min(e,ho):e}function fs(t){try{return lo.native(t)}catch{return re(t)}}function Bn(t){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)}async function lu(t){if(process.env.SCIP_QUERY_PROFILE==="1"||process.env.SCIP_QUERY_PROFILE==="true")return!1;let e=ys(t);if(!e)return!1;let n=qe();if(e.kind==="code"){try{at(n,"code",e.session)}catch{return!1}let i=Fn(n,e.selectors,e.options,{allowDefault:!0});return i?(O(i.result.serializedJson),!0):!1}if(e.kind==="files"){let i=Sn(n,e.pattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="members"){let i=Rn(n,e.symbolPattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="methods"){let i=xn(n,e.className,{allowDefault:!0});return!i||!X(i.result)?!1:(i.result.kind!=="matched"&&(process.exitCode=1),!0)}if(e.kind==="file-dependencies"){let i=In(n,e.direction,e.filePattern,{allowDefault:!0});if(!i)return!1;let o=e.direction==="outgoing"?"deps":"rdeps";return await w(JSON.stringify(i.result),o,t),!0}if(e.kind==="imported-by"){let i=wn(n,e.symbolPattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="hierarchy"){let i=kn(n,e.symbolPattern,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="by-kind"){let i=Pn(n,e.kindQuery,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="kind-counts"){let i=Cn(n,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="refs"){let i=En(n,e.symbolPattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="trace"){let i=An(n,e.symbolPattern,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="value-flow"){let i=Mn(n,e.symbolPattern,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="dependence-slice"){let i=On(n,e.criterion,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="call-graph"||e.kind==="reference-neighborhood"||e.kind==="reference-reachability"||e.kind==="slice"||e.kind==="dataflow"){let i=_n(n,e.kind,e.symbolPattern,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="imports"){let i=Dn(n,e.filePattern,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="unused-imports"){let i=Tn(n,e.filePattern,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="system"){let i=jn(n,e.modulePattern,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="surface"){let i=Nn(n,e.modulePattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="stats"){let i=vn(n,{allowDefault:!0});return i?(O(JSON.stringify(i.result)),!0):!1}if(e.kind==="entrypoints"){let i=bn(n,e.options,{allowDefault:!0});return i?(O(JSON.stringify(i.result)),!0):!1}let r=e.kind==="source-search"?gn(n,e.pattern,e.options,{allowDefault:!0}):hn(n,e.filePattern,{allowDefault:!0});return r?(O(JSON.stringify(r.result)),!0):!1}function ys(t){return t[0]==="search"?Os(t):t[0]==="outline"?_s(t):t[0]==="code"?Ms(t):t[0]==="entrypoints"?As(t):t[0]==="files"?Es(t):t[0]==="stats"?$n(t,"stats"):t[0]==="kind-counts"?$n(t,"kind-counts"):t[0]==="members"?Gn(t,"members"):t[0]==="methods"?Gn(t,"methods"):t[0]==="deps"?Vn(t,"outgoing"):t[0]==="rdeps"?Vn(t,"incoming"):t[0]==="imported-by"?ms(t):t[0]==="hierarchy"?gs(t):t[0]==="by-kind"?hs(t):t[0]==="refs"?bs(t):t[0]==="trace"?Ss(t):t[0]==="value-flow"?vs(t):t[0]==="dependence-slice"?Rs(t):t[0]==="call-graph"||t[0]==="reference-neighborhood"||t[0]==="reference-reachability"||t[0]==="slice"||t[0]==="dataflow"?xs(t):t[0]==="imports"?Is(t):t[0]==="unused-imports"?ws(t):t[0]==="system"?ks(t):t[0]==="surface"?Ps(t):null}function Gn(t,e){let n=v(t);return n===null?null:e==="members"?{kind:e,symbolPattern:n}:{kind:e,className:n}}function Vn(t,e){let n=v(t);return n===null?null:{kind:"file-dependencies",direction:e,filePattern:n}}function ms(t){let e=v(t);return e===null?null:{kind:"imported-by",symbolPattern:e}}function gs(t){let e=v(t);return e===null?null:{kind:"hierarchy",symbolPattern:e}}function hs(t){let e=v(t);return e===null?null:{kind:"by-kind",kindQuery:e}}function bs(t){let e=v(t);return e===null?null:{kind:"refs",symbolPattern:e}}function Ss(t){let e=v(t);return e===null?null:{kind:"trace",symbolPattern:e}}function vs(t){let e=v(t);return e===null?null:{kind:"value-flow",symbolPattern:e}}function Rs(t){let e=v(t);return e===null?null:{kind:"dependence-slice",criterion:e}}function xs(t){let e=t[0];if(e!=="call-graph"&&e!=="reference-neighborhood"&&e!=="reference-reachability"&&e!=="slice"&&e!=="dataflow")return null;let n=v(t);return n===null?null:{kind:e,symbolPattern:n}}function Is(t){let e=v(t);return e===null?null:{kind:"imports",filePattern:e}}function ws(t){let e=v(t);return e===null?null:{kind:"unused-imports",filePattern:e}}function ks(t){let e=v(t);return e===null?null:{kind:"system",modulePattern:e}}function Ps(t){let e=v(t);return e===null?null:{kind:"surface",modulePattern:e}}function v(t){let e,n=!1,r=!1,i=!1;for(let o=1;o<t.length;o+=1){let s=t[o];if(s==="--"){let a=t.slice(o+1);if(a.length!==1||e!==void 0)return null;e=a[0];break}if(s==="--json"){n=!0;continue}if(s==="--result-only"){r=!0;continue}if(s==="--compact"){i=!0;continue}if(s.startsWith("-")||e!==void 0)return null;e=s}return!n||!r||!i||e===void 0?null:e}function X(t){return Cs(JSON.stringify(t))}function Cs(t){return Qn(t)?(O(t),!0):!1}async function w(t,e,n){if(Qn(t)){O(t);return}let{runWithCliOutputPagination:r}=await import("./output-pagination-2GME6OPY.js");await r({command:e,producerVersion:$,invocationPrefix:Qt(),argv:[...n],cwd:process.cwd(),json:!0,sourceSession:!0,reemitSource:!1},()=>O(t))}function Qn(t){return Buffer.byteLength(t)+1<=tt}function Es(t){let e,n=!1,r=!1,i=!1;for(let o=1;o<t.length;o+=1){let s=t[o];if(s==="--"){let a=t.slice(o+1);if(a.length!==1||e!==void 0)return null;e=a[0];break}if(s==="--json"){n=!0;continue}if(s==="--result-only"){r=!0;continue}if(s==="--compact"){i=!0;continue}if(s.startsWith("-")||e!==void 0)return null;e=s}return!n||!r||!i||e===void 0?null:{kind:"files",pattern:e}}function $n(t,e){let n=!1,r=!1,i=!1;for(let o=1;o<t.length;o+=1){let s=t[o];if(s==="--json"){n=!0;continue}if(s==="--result-only"){r=!0;continue}if(s==="--compact"){i=!0;continue}return null}return n&&r&&i?{kind:e}:null}function As(t){let e,n,r=!1,i=!1,o=!1;for(let s=1;s<t.length;s+=1){let a=t[s];if(a==="--"){let u=t.slice(s+1);if(u.length!==1||e!==void 0)return null;e=u[0];break}if(a==="--json"){r=!0;continue}if(a==="--result-only"){i=!0;continue}if(a==="--compact"){o=!0;continue}let c=Z(t,s,a,"--scope","-s");if(c){n=c.value,s=c.nextIndex;continue}if(a.startsWith("-")||e!==void 0)return null;e=a}return!r||!i||!o?null:{kind:"entrypoints",options:{...e===void 0?{}:{search:e},...n===void 0?{}:{scope:n}}}}function Ms(t){let e=[],n=0,r="exported",i=!0,o=!1,s=!1,a=!1;for(let c=1;c<t.length;c+=1){let u=t[c];if(u==="--"){e.push(...t.slice(c+1));break}if(u==="--json"){o=!0;continue}if(u==="--result-only"){s=!0;continue}if(u==="--compact"){a=!0;continue}if(u==="--no-session"){i=!1;continue}let l=Z(t,c,u,"--context","-C");if(l){let y=Ke(l.value,0);if(y===null)return null;n=y,c=l.nextIndex;continue}let p=Z(t,c,u,"--members");if(p){if(p.value!=="exported"&&p.value!=="all")return null;r=p.value,c=p.nextIndex;continue}if(u.startsWith("-"))return null;e.push(u)}return!o||!s||!a||e.length<1||e.length>24||e.some(c=>c.length===0)?null:{kind:"code",selectors:e,options:{context:n,members:r},session:i}}function Os(t){let e,n,r=2,i=6,o=!1,s=!1,a=!1,c=!1,u=!1;for(let l=1;l<t.length;l+=1){let p=t[l];if(p==="--"){let x=t.slice(l+1);if(x.length!==1||e!==void 0)return null;e=x[0];break}if(p==="--json"){a=!0;continue}if(p==="--result-only"){c=!0;continue}if(p==="--compact"){u=!0;continue}if(p==="--regexp"){o=!0;continue}if(p==="--ignore-case"||p==="-i"){s=!0;continue}let y=Z(t,l,p,"--scope","-s");if(y){n=y.value,l=y.nextIndex;continue}let R=Z(t,l,p,"--context","-C");if(R){let x=Ke(R.value,0);if(x===null)return null;r=x,l=R.nextIndex;continue}let P=Z(t,l,p,"--limit","-n");if(P){let x=Ke(P.value,1);if(x===null)return null;i=x,l=P.nextIndex;continue}if(p.startsWith("-")||e!==void 0)return null;e=p}return!a||!c||!u||e===void 0?null:{kind:"source-search",pattern:e,options:{scope:n,context:r,limit:i,regexp:o,ignoreCase:s,ranking:"structural"}}}function _s(t){let e,n=!1,r=!1,i=!1;for(let o=1;o<t.length;o+=1){let s=t[o];if(s==="--"){let a=t.slice(o+1);if(a.length!==1||e!==void 0)return null;e=a[0];break}if(s==="--json"){n=!0;continue}if(s==="--result-only"){r=!0;continue}if(s==="--compact"){i=!0;continue}if(s!=="--signatures"){if(s.startsWith("-")||e!==void 0)return null;e=s}}return!n||!r||!i||e===void 0?null:{kind:"outline",filePattern:e}}function Z(t,e,n,r,i){if(n.startsWith(`${r}=`))return{value:n.slice(r.length+1),nextIndex:e};if(n!==r&&(i===void 0||n!==i))return null;let o=t[e+1];return o===void 0?null:{value:o,nextIndex:e+1}}function Ke(t,e){if(!/^\d+$/.test(t))return null;let n=Number(t);return Number.isSafeInteger(n)&&n>=e?n:null}export{ys as parseFastPathInvocation,Qn as serializedJsonFitsClientBudget,lu as tryRunQueryServiceFastPath};
6
6
  //# sourceMappingURL=query-service-fastpath.js.map
@@ -1,5 +1,5 @@
1
- import"./chunk-ESIQ66Z7.js";import"./chunk-OLNV6I6U.js";import"./chunk-6V5CNXL6.js";import"./chunk-IHGQTTVW.js";import"./chunk-3FHOF22C.js";import"./chunk-26CT72HM.js";import"./chunk-EQHFIL6T.js";import"./chunk-SQXRS7BG.js";import"./chunk-UXW33INU.js";import"./chunk-DIUFNHRJ.js";import"./chunk-64BFSI5I.js";import"./chunk-VVZSBTSU.js";import"./chunk-ZTI4SBFV.js";import"./chunk-JS4PGXMV.js";import"./chunk-3TNRNKAT.js";import{a as H}from"./chunk-6YTSKJJ3.js";import"./chunk-YBGKCQIS.js";import"./chunk-YPWHBBIS.js";import"./chunk-7KCZELVM.js";import{a as ve}from"./chunk-W5OXRYGE.js";import"./chunk-XBGWL66K.js";import{c as O}from"./chunk-4FTZ4P5G.js";import"./chunk-HYO3NP5Q.js";import"./chunk-EKV5HX33.js";import"./chunk-D4N5SQ2M.js";import"./chunk-J66VOFW6.js";import{h as xe}from"./chunk-B5D7QPBE.js";import"./chunk-AFHTBORT.js";import{d as Ee}from"./chunk-2WC2OEDO.js";import"./chunk-BGBBVSH4.js";import"./chunk-MV3CDXPI.js";import"./chunk-MTDBHTSF.js";import{b as we}from"./chunk-WYCTJDVR.js";import{b as Ie,c as Ce,d as Pe}from"./chunk-CEEZJXEF.js";import"./chunk-BKVWUP7Y.js";import"./chunk-W6STWDQI.js";import"./chunk-MPQ4OTBM.js";import{e as oe}from"./chunk-OSR2GEHQ.js";import{a as P,b as ce}from"./chunk-FRUSVINH.js";import"./chunk-YEN6CYC7.js";import"./chunk-WRQXLNYE.js";import"./chunk-2GRUZAQF.js";import"./chunk-HOENASQM.js";import"./chunk-YUKYB54I.js";import"./chunk-BJT7LSPK.js";import{d as he}from"./chunk-SSK6LDPC.js";import"./chunk-4WNW27SX.js";import"./chunk-F4FNK44D.js";import"./chunk-GAS2LJMP.js";import{a as Re}from"./chunk-KLFEXGQA.js";import"./chunk-WK46TNUM.js";import"./chunk-IICPE7B2.js";import"./chunk-TQZV7KV4.js";import{B as ee,C as te,D as re,J as ne,L as ie,T as k,_ as ae,a as C,c as J,d as X,k as _}from"./chunk-3L2ZBPEX.js";import{a as Z}from"./chunk-YXPUP5G2.js";import{c as M,h as se}from"./chunk-DRENNWRG.js";import{a as be}from"./chunk-GYIZ4NXB.js";import"./chunk-MXNGIEPU.js";import"./chunk-BE7ZZTMC.js";import"./chunk-2OOY75BW.js";import{a as ge,b as g}from"./chunk-TY7CRN3Z.js";import{a as Se}from"./chunk-DHEQMPLW.js";import"./chunk-NOGJXYFO.js";import"./chunk-IZDPJ2QI.js";import"./chunk-WYPL7GF7.js";import{b as K,d as Y}from"./chunk-RTQ7NEKG.js";import{d as B}from"./chunk-GUFSG5TX.js";import"./chunk-MWN53KRN.js";import{b as z}from"./chunk-IW5XQG5G.js";import{b as G}from"./chunk-3AF4TUFK.js";import{b as $,c as q,d as le,e as ue,h as pe,i as de,m as me,n as fe,o as T,p as ye}from"./chunk-FGA2U4OR.js";import{a as U}from"./chunk-B3PYOSCX.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import{c as A,d as I,e as V}from"./chunk-JFMEXGFE.js";import{F as W,c as Q}from"./chunk-KYSDI3GE.js";import"./chunk-7F45LJKI.js";import{createHash as h,randomUUID as Dt}from"crypto";import{rmSync as Nt}from"fs";import{join as qe,resolve as Ze}from"path";import{pathToFileURL as Ft}from"url";function ke(e,t,i,o,l=!1){let r=[...e],n=[],s=new Set,a=0;for(;r.length>0&&n.length<t;){let c=r.filter(d=>a+d.evidenceCharacters<=i||l&&n.length===0);if(c.length===0)break;let u=c.filter(d=>d.roles.includes("location")||d.roles.includes("definition")).sort(o);c.sort((d,m)=>Ae(m,s)-Ae(d,s)||o(d,m));let p=u[0]??c[0];n.push(p),a+=p.evidenceCharacters;for(let d of _e(p))s.add(d.key);r.splice(r.indexOf(p),1)}return{selected:n,omitted:r.sort(o)}}function Ae(e,t){let i=_e(e).reduce((r,n)=>r+(t.has(n.key)?0:n.weight),0),o=Math.max(0,8-e.priority)*20,l=Math.min(500,Math.ceil(e.evidenceCharacters/160));return i+o-l}function _e(e){return[...e.reasons.map(tt),...e.roles.map(t=>({key:`role:${t}`,weight:rt(t)})),{key:`file:${e.relativePath}`,weight:180},{key:`scope:${nt(e.relativePath)}`,weight:120},{key:`kind:${e.fileKind}`,weight:40},...e.symbols.map(t=>({key:`symbol:${t}`,weight:100})),...e.behaviorSignals.map(t=>({key:`behavior:${t}`,weight:70}))]}function tt(e){let t=e.indexOf(":"),i=t<0?e:e.slice(0,t);return i==="dependency"||i==="consumer"?{key:`reason:${i}`,weight:220}:{key:`reason:${e}`,weight:i==="location"||i==="definition"?1400:800}}function rt(e){switch(e){case"location":return 1200;case"definition":return 1100;case"reference":return 600;case"caller":case"callee":return 550;case"dependency":case"consumer":return 500;case"search":return 400;default:return 300}}function nt(e){let t=e.lastIndexOf("/");return t<0?e:e.slice(0,t)}var Me=64,Te=12;function Ne(e,t,i={}){if(t.length===0)return[];let o=i.context??6;if(!Number.isSafeInteger(o)||o<0)throw new RangeError(`context must be a non-negative safe integer; received ${o}`);let l=i.limit??12;if(!Number.isSafeInteger(l)||l<=0)throw new RangeError(`limit must be a positive safe integer; received ${l}`);let r=t.map(n=>{if(n.length===0)throw new Error("The source search pattern must not be empty.");return{pattern:n,regexp:i.regexp?Se(n,"source search pattern",i.ignoreCase?"iu":"u"):null,literal:i.ignoreCase?n.toLocaleLowerCase():n,identities:[],fileCoverage:[],textByPath:new Map}});if(!i.regexp&&!i.ignoreCase){let n=r.map(a=>Buffer.from(a.pattern,"utf8")),s=O(e,{scope:i.scope,literalBytes:n.length===1?n[0]:n},(a,c)=>{let u=_(a.text);if(u.length!==0)for(let p of c){let d=r[p];d&&Oe(e,d,a,u,i)}});return r.map(a=>He(a,s,o,l,i))}return r.map(n=>{let s=O(e,{scope:i.scope},a=>{let c=_(a.text);c.length>0&&Oe(e,n,a,c,i)});return He(n,s,o,l,i)})}function Oe(e,t,i,o,l){let r=[];for(let c=0;c<o.length;c+=1){let u=o[c]??"",p=u.endsWith("\r")?u.slice(0,-1):u;(t.regexp?t.regexp.test(p):(l.ignoreCase?p.toLocaleLowerCase():p).includes(t.literal))&&r.push(c)}if(r.length===0)return;let n=i.relativePath;t.textByPath.set(n,i.text);let s=i.freshness.semantic.state!=="stale"&&i.freshness.semantic.basis!=="no-compiler-document"?k(e,n):[],a=te(e,n)?.callables??[];for(let c of r){let u=ae(s,c),p=ee(a,c),d=u&&!se(u.symbol)?u:null,m=d?.startLine??p?.startLine??u?.startLine??c,f=d?.endLine??p?.endLine??u?.endLine??c,R=xe(e,n,c,m,f);t.identities.push({relativePath:n,focusLine:c,ownerSymbol:d?.symbol??null,ownerShort:d?M(d.symbol):p?.name??(u?M(u.symbol):null),ownerStartLine:R.startLine,ownerEndLine:R.endLine,fileKind:ce(n),freshness:i.freshness})}t.fileCoverage.push({relativePath:n,matchingLines:r.length,returnedMatches:0,freshness:i.freshness})}function He(e,t,i,o,l){e.identities.sort(Fe);let r=e.identities.length>Me?De(e.identities,Me):e.identities,s=(o===Number.MAX_SAFE_INTEGER?e.identities:l.ranking?De(e.identities,o):e.identities.slice(0,o)).flatMap(u=>{let p=e.textByPath.get(u.relativePath),d=p===void 0?null:it(u.relativePath,p,u.focusLine,i);return d?[{...d,...u}]:[]}),a=new Map;for(let u of s)a.set(u.relativePath,(a.get(u.relativePath)??0)+1);for(let u of e.fileCoverage)u.returnedMatches=a.get(u.relativePath)??0;let c=ot(e.fileCoverage);return{pattern:e.pattern,mode:l.regexp?"regexp":"literal",identities:e.identities,...r.length<e.identities.length?{identityManifest:r}:{},identityCoverage:{mode:r.length===e.identities.length?"complete":"bounded",returned:r.length,total:e.identities.length,omitted:e.identities.length-r.length},matches:s,matchingLines:e.identities.length,matchingFiles:e.fileCoverage.length,omittedMatches:Math.max(0,e.identities.length-s.length),fileCoverage:e.fileCoverage,scopeHints:c.slice(0,Te),omittedScopeHints:Math.max(0,c.length-Te),scannedFiles:t.scannedTextFiles,textCoverage:{basis:"current-project-text-files",candidateFiles:t.candidateFiles,scannedTextFiles:t.scannedTextFiles,scannedBytes:t.scannedBytes,skippedBinaryPaths:t.skippedBinaryPaths,skippedUnreadablePaths:t.skippedUnreadablePaths,skippedOversizedPaths:t.skippedOversizedPaths,semanticFiles:t.semanticFiles}}}function it(e,t,i,o){let l=t.split(`
1
+ import"./chunk-JDU2IV3A.js";import"./chunk-AN76MGUE.js";import"./chunk-CFNIGQMT.js";import"./chunk-NB4D3BNM.js";import"./chunk-L6XHYJPZ.js";import"./chunk-26CT72HM.js";import"./chunk-T6DWDI5E.js";import"./chunk-HYT2R7LX.js";import"./chunk-2N6WBNDC.js";import"./chunk-L5KYH6U3.js";import"./chunk-OUHEZBYI.js";import"./chunk-NGKBOT6G.js";import"./chunk-J7A4PWFX.js";import"./chunk-62LPZCBQ.js";import"./chunk-3TNRNKAT.js";import{a as H}from"./chunk-6YTSKJJ3.js";import"./chunk-6TS3KOXR.js";import"./chunk-ZGIHTH27.js";import"./chunk-7KCZELVM.js";import{a as ve}from"./chunk-2M2LSIMY.js";import"./chunk-GHNPACNP.js";import{c as O}from"./chunk-6MFXCMZC.js";import"./chunk-MZPXPSUJ.js";import"./chunk-RVZC6TJE.js";import"./chunk-NYKZMCRC.js";import"./chunk-POBJ6FR2.js";import{h as xe}from"./chunk-HAXXKRTD.js";import"./chunk-UIFUZVCC.js";import{d as Ee}from"./chunk-JFMI5SGB.js";import"./chunk-BGBBVSH4.js";import"./chunk-AADQLOQ4.js";import"./chunk-MTDBHTSF.js";import{b as we}from"./chunk-WDSFQDPN.js";import{b as Ie,c as Pe,d as Ce}from"./chunk-ANLNLY66.js";import"./chunk-BKVWUP7Y.js";import"./chunk-JJP37RGX.js";import"./chunk-HX4X7KG3.js";import{e as oe}from"./chunk-JCSAZ35V.js";import{a as C,b as ce}from"./chunk-NJGKXKQF.js";import"./chunk-FI7VGOR4.js";import"./chunk-WRQXLNYE.js";import"./chunk-L7KTFEAV.js";import"./chunk-2USA3S3P.js";import"./chunk-YUKYB54I.js";import"./chunk-BJT7LSPK.js";import{d as he}from"./chunk-5BIKR67W.js";import"./chunk-CZW5MZ5B.js";import"./chunk-F4FNK44D.js";import"./chunk-ODPDP7A4.js";import{a as Re}from"./chunk-VBKUWB6N.js";import"./chunk-MOKUWRHO.js";import"./chunk-VZPWVCLN.js";import"./chunk-FVFDOIM3.js";import{B as ee,C as te,D as re,J as ne,L as ie,T as k,_ as ae,a as P,c as J,d as X,k as _}from"./chunk-2VAHDDLM.js";import{a as Z}from"./chunk-YXPUP5G2.js";import{c as M,h as se}from"./chunk-BL6DCHQP.js";import{a as be}from"./chunk-X6OGVFIT.js";import"./chunk-MXNGIEPU.js";import"./chunk-EHYDXE3Z.js";import"./chunk-2OOY75BW.js";import{a as ge,b as g}from"./chunk-HMEWLMML.js";import{a as Se}from"./chunk-DHEQMPLW.js";import"./chunk-U6KCHXJ4.js";import"./chunk-RMDPFPNW.js";import"./chunk-WYPL7GF7.js";import"./chunk-T3I6NHBH.js";import{b as K,d as Y}from"./chunk-ATXPTSEI.js";import{d as B}from"./chunk-CKBUBRYD.js";import"./chunk-MWN53KRN.js";import{b as z}from"./chunk-IW5XQG5G.js";import{b as $}from"./chunk-3AF4TUFK.js";import{b as W,c as q,d as le,e as ue,h as pe,i as de,m as me,n as fe,o as T,p as ye}from"./chunk-T3CZAZSI.js";import{a as U}from"./chunk-B3PYOSCX.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import{c as A,d as I,e as V}from"./chunk-JFMEXGFE.js";import{G,c as Q}from"./chunk-7HXT6YLU.js";import"./chunk-7F45LJKI.js";import{createHash as h,randomUUID as Dt}from"crypto";import{rmSync as Nt}from"fs";import{join as qe,resolve as Ze}from"path";import{pathToFileURL as Ft}from"url";function ke(e,t,i,o,l=!1){let r=[...e],n=[],s=new Set,a=0;for(;r.length>0&&n.length<t;){let c=r.filter(d=>a+d.evidenceCharacters<=i||l&&n.length===0);if(c.length===0)break;let u=c.filter(d=>d.roles.includes("location")||d.roles.includes("definition")).sort(o);c.sort((d,m)=>Ae(m,s)-Ae(d,s)||o(d,m));let p=u[0]??c[0];n.push(p),a+=p.evidenceCharacters;for(let d of _e(p))s.add(d.key);r.splice(r.indexOf(p),1)}return{selected:n,omitted:r.sort(o)}}function Ae(e,t){let i=_e(e).reduce((r,n)=>r+(t.has(n.key)?0:n.weight),0),o=Math.max(0,8-e.priority)*20,l=Math.min(500,Math.ceil(e.evidenceCharacters/160));return i+o-l}function _e(e){return[...e.reasons.map(tt),...e.roles.map(t=>({key:`role:${t}`,weight:rt(t)})),{key:`file:${e.relativePath}`,weight:180},{key:`scope:${nt(e.relativePath)}`,weight:120},{key:`kind:${e.fileKind}`,weight:40},...e.symbols.map(t=>({key:`symbol:${t}`,weight:100})),...e.behaviorSignals.map(t=>({key:`behavior:${t}`,weight:70}))]}function tt(e){let t=e.indexOf(":"),i=t<0?e:e.slice(0,t);return i==="dependency"||i==="consumer"?{key:`reason:${i}`,weight:220}:{key:`reason:${e}`,weight:i==="location"||i==="definition"?1400:800}}function rt(e){switch(e){case"location":return 1200;case"definition":return 1100;case"reference":return 600;case"caller":case"callee":return 550;case"dependency":case"consumer":return 500;case"search":return 400;default:return 300}}function nt(e){let t=e.lastIndexOf("/");return t<0?e:e.slice(0,t)}var Me=64,Te=12;function Ne(e,t,i={}){if(t.length===0)return[];let o=i.context??6;if(!Number.isSafeInteger(o)||o<0)throw new RangeError(`context must be a non-negative safe integer; received ${o}`);let l=i.limit??12;if(!Number.isSafeInteger(l)||l<=0)throw new RangeError(`limit must be a positive safe integer; received ${l}`);let r=t.map(n=>{if(n.length===0)throw new Error("The source search pattern must not be empty.");return{pattern:n,regexp:i.regexp?Se(n,"source search pattern",i.ignoreCase?"iu":"u"):null,literal:i.ignoreCase?n.toLocaleLowerCase():n,identities:[],fileCoverage:[],textByPath:new Map}});if(!i.regexp&&!i.ignoreCase){let n=r.map(a=>Buffer.from(a.pattern,"utf8")),s=O(e,{scope:i.scope,literalBytes:n.length===1?n[0]:n},(a,c)=>{let u=_(a.text);if(u.length!==0)for(let p of c){let d=r[p];d&&Oe(e,d,a,u,i)}});return r.map(a=>He(a,s,o,l,i))}return r.map(n=>{let s=O(e,{scope:i.scope},a=>{let c=_(a.text);c.length>0&&Oe(e,n,a,c,i)});return He(n,s,o,l,i)})}function Oe(e,t,i,o,l){let r=[];for(let c=0;c<o.length;c+=1){let u=o[c]??"",p=u.endsWith("\r")?u.slice(0,-1):u;(t.regexp?t.regexp.test(p):(l.ignoreCase?p.toLocaleLowerCase():p).includes(t.literal))&&r.push(c)}if(r.length===0)return;let n=i.relativePath;t.textByPath.set(n,i.text);let s=i.freshness.semantic.state!=="stale"&&i.freshness.semantic.basis!=="no-compiler-document"?k(e,n):[],a=te(e,n)?.callables??[];for(let c of r){let u=ae(s,c),p=ee(a,c),d=u&&!se(u.symbol)?u:null,m=d?.startLine??p?.startLine??u?.startLine??c,f=d?.endLine??p?.endLine??u?.endLine??c,R=xe(e,n,c,m,f);t.identities.push({relativePath:n,focusLine:c,ownerSymbol:d?.symbol??null,ownerShort:d?M(d.symbol):p?.name??(u?M(u.symbol):null),ownerStartLine:R.startLine,ownerEndLine:R.endLine,fileKind:ce(n),freshness:i.freshness})}t.fileCoverage.push({relativePath:n,matchingLines:r.length,returnedMatches:0,freshness:i.freshness})}function He(e,t,i,o,l){e.identities.sort(Fe);let r=e.identities.length>Me?De(e.identities,Me):e.identities,s=(o===Number.MAX_SAFE_INTEGER?e.identities:l.ranking?De(e.identities,o):e.identities.slice(0,o)).flatMap(u=>{let p=e.textByPath.get(u.relativePath),d=p===void 0?null:it(u.relativePath,p,u.focusLine,i);return d?[{...d,...u}]:[]}),a=new Map;for(let u of s)a.set(u.relativePath,(a.get(u.relativePath)??0)+1);for(let u of e.fileCoverage)u.returnedMatches=a.get(u.relativePath)??0;let c=ot(e.fileCoverage);return{pattern:e.pattern,mode:l.regexp?"regexp":"literal",identities:e.identities,...r.length<e.identities.length?{identityManifest:r}:{},identityCoverage:{mode:r.length===e.identities.length?"complete":"bounded",returned:r.length,total:e.identities.length,omitted:e.identities.length-r.length},matches:s,matchingLines:e.identities.length,matchingFiles:e.fileCoverage.length,omittedMatches:Math.max(0,e.identities.length-s.length),fileCoverage:e.fileCoverage,scopeHints:c.slice(0,Te),omittedScopeHints:Math.max(0,c.length-Te),scannedFiles:t.scannedTextFiles,textCoverage:{basis:"current-project-text-files",candidateFiles:t.candidateFiles,scannedTextFiles:t.scannedTextFiles,scannedBytes:t.scannedBytes,skippedBinaryPaths:t.skippedBinaryPaths,skippedUnreadablePaths:t.skippedUnreadablePaths,skippedOversizedPaths:t.skippedOversizedPaths,semanticFiles:t.semanticFiles}}}function it(e,t,i,o){let l=t.split(`
2
2
  `),r=t.endsWith(`
3
3
  `)?l.length-1:l.length;if(i<0||i>=r)return null;let n=Math.max(0,i-o),s=Math.min(r-1,i+o);return{relativePath:e,startLine:n,endLine:s,focusLine:i,source:l.slice(n,s+1).join(`
4
- `)}}function ot(e){let t=new Map;for(let i of e){let o=st(i.relativePath),l=t.get(o)??{matchingLines:0,matchingFiles:0};l.matchingLines+=i.matchingLines,l.matchingFiles+=1,t.set(o,l)}return[...t.entries()].map(([i,o])=>({scope:i,...o})).sort((i,o)=>o.matchingLines-i.matchingLines||o.matchingFiles-i.matchingFiles||i.scope.localeCompare(o.scope))}function st(e){let t=e.lastIndexOf("/");return t<0?e:e.slice(0,t)}function De(e,t){let i=e.map((l,r)=>({...l,priority:P(l.fileKind),sequence:r,evidenceCharacters:1,roles:["search"],reasons:["search"],symbols:l.ownerSymbol?[l.ownerSymbol]:[],behaviorSignals:[]})),o=[];for(let l of[0,1,2]){let r=t-o.length;if(r===0)break;let n=i.filter(s=>P(s.fileKind)===l);o.push(...ke(n,r,Number.MAX_SAFE_INTEGER,Fe).selected)}return o.map(({priority:l,sequence:r,evidenceCharacters:n,roles:s,reasons:a,symbols:c,behaviorSignals:u,...p})=>p)}function Fe(e,t){return P(e.fileKind)-P(t.fileKind)||+(t.ownerSymbol!==null)-+(e.ownerSymbol!==null)||e.relativePath.localeCompare(t.relativePath)||e.focusLine-t.focusLine}function Le(e,t,i={}){if(t.length===0)throw new Error("The source search pattern must not be empty.");return Ne(e,[t],i)[0]}import{availableParallelism as ft,totalmem as yt}from"os";import{fileURLToPath as tn}from"url";import{getHeapStatistics as ht}from"v8";async function je(e,t,i={}){let o=Math.max(1,Math.floor(i.batchSize??64)),l=i.collectGarbage??C,r=[],n=0;for(let s=0;s<t.length;s+=o){for(let a of t.slice(s,s+o)){for(let c of k(e,a))e.isIgnored(c.relativePath)||r.push(c);ie(e,a),ne(e,a),re(e,a),n+=1}i.onBatch?.({files:n,total:t.length,definitions:r.length}),l(),await i.yieldToEventLoop?.()}return{files:n,definitions:r}}import{execFileSync as vr}from"child_process";import{createHash as Er}from"crypto";import{lstatSync as Cr,readlinkSync as Pr,readdirSync as wr,realpathSync as Ar,statSync as kr}from"fs";import{dirname as Mr,isAbsolute as Tr,join as Or,posix as Hr,relative as Dr,resolve as Nr,sep as Fr}from"path";var jr=512*1024*1024;function Qe(e){return le({version:e.version,...e.base?{base:e.base}:{},files:[...e.files].sort((t,i)=>t.path.localeCompare(i.path))})}function D(e){return JSON.stringify({...e.clojureConfigPath?{clojureConfigPath:e.clojureConfigPath}:{},files:[...e.files].sort((t,i)=>t.path.localeCompare(i.path)).map(t=>({hash:t.hash,path:t.path,size:t.size})),languages:[...e.languages].sort(),pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),version:e.version})}var ct="scip-query:collaboration-domain",lt="scip-query:workspace-instance",ut="scip-query:index-generation",pt="scip-query:repository-content",Be="scip-query:index-inputs",dt="scip-query:index-inputs";function Ve(e){let t=e.snapshot,i=e.observedSourceKinds?new Set(e.observedSourceKinds):void 0,o=e.gitContext??t?.gitContext??(i?.has("live-workspace")?W(e.projectRoot):void 0),l=e.collaborationDomainId??e.db?.config.collaborationDomainId,r=l?g(ct,1,l):void 0,n=o?g(lt,1,o.worktreeId):void 0,s=t?g(pt,1,Qe(t.repositoryContent)):void 0,a=t?g(Be,t.indexInputs.version,D(t.indexInputs)):void 0,c=e.db&&t?mt(e.db.generation.metadataRaw):void 0,u=e.db?{generation:g(ut,1,e.db.generation.identity),...c?{inputs:c}:{},source:e.db.generation.source}:void 0,p=i??new Set([...u?["index-generation"]:[],...s?["repository-snapshot"]:n?["live-workspace"]:[]]),d=[...u&&p.has("index-generation")?[{kind:"index-generation",identity:u.generation}]:[],...s&&p.has("repository-snapshot")?[{kind:"repository-snapshot",identity:s}]:[],...n&&p.has("live-workspace")?[{kind:"live-workspace",identity:n}]:[],...p.has("process")?[{kind:"process"}]:[]],m=[...u&&p.has("index-generation")?[{source:"index-generation",kind:u.source==="immutable"?"immutable":"not-established"}]:[],...s&&p.has("repository-snapshot")?[{source:"repository-snapshot",kind:"fixed-snapshot"}]:[],...n&&p.has("live-workspace")?[{source:"live-workspace",kind:"not-established"}]:[],...p.has("process")?[{source:"process",kind:"not-established"}]:[]];return d.length===0&&(d.push({kind:"process"}),m.push({source:"process",kind:"not-established"})),{schemaVersion:ge,observedAt:(e.observedAt??(t?new Date(t.capturedAt):new Date)).toISOString(),facts:{...r?{collaborationDomain:r}:{},...n?{workspaceInstance:n}:{},...s?{wholeContent:s}:{},...a?{relevantInputs:[{subject:dt,identity:a}]}:{},...u?{index:u}:{}},observedSources:d,stabilityProofs:m,...o?{diagnostics:{clean:o.clean,...o.headCommit?{headCommit:o.headCommit}:{},...o.treeOid?{treeOid:o.treeOid}:{}}}:{}}}function mt(e){if(!e)return;let t=B(e);if(t.kind!=="legacy"&&t.kind!=="supported")return;let i=Q(t.metadata.fingerprint);return i&&Number.isSafeInteger(i.version)&&i.version>0?g(Be,i.version,D(i)):void 0}var gt=1,St=1;var hn=10*6e4,Rt=25e3,bt=2500;var vt=4,xt=12,Et=1,It=4,Ct=7*1024*1024*1024;var gn=10*6e4;var Sn=10*6e4;var Pt=new Set(["vue-component-duplicates","vue-composable-candidates","vue-large-view-pressure"]),Rn=new Set([...Pt,"suppressions"]);var Ue=2,Ge=J({kind:"health-semantic-prewarm",invalidation:X("health-semantic-prewarm"),serialize:e=>JSON.stringify(e),deserialize:wt});function wt(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let i=t;return i.version!==Ue||typeof i.definitions!="number"||!Number.isFinite(i.definitions)||typeof i.referenceCacheWrites!="number"||!Number.isFinite(i.referenceCacheWrites)||typeof i.referenceIncomplete!="number"||!Number.isFinite(i.referenceIncomplete)||typeof i.calleeRows!="number"||!Number.isFinite(i.calleeRows)||typeof i.warmedAt!="number"||!Number.isFinite(i.warmedAt)?null:{version:Ue,definitions:i.definitions,referenceCacheWrites:i.referenceCacheWrites,referenceIncomplete:i.referenceIncomplete,calleeRows:i.calleeRows,warmedAt:i.warmedAt}}catch{return null}}function At(e,t){return!t||t.count<=1?[...e]:e.filter((i,o)=>o%t.count===t.index)}function We(e){let t=H(e);return t.symbols>=Rt||t.documents>=bt}var bn={env:process.env,projectFingerprint:Y,semanticEngineFingerprint:kt,readMarker:(e,t,i)=>Ge.read(e,t,i),writeMarker:(e,t,i,o)=>Ge.write(e,t,i,o),projectFiles:(e,t)=>At(Z(e,{scope:t.scope,includeIgnored:!1}),t.shard),candidateDefinitions:async(e,t,i)=>{let o=await je(e,i,{collectGarbage:C,yieldToEventLoop:()=>new Promise(s=>setImmediate(s))}),l=new Set(i),r=new Set(o.definitions.map(s=>s.symbolId)),n=[];for(let s of[{},{requireCallableSymbol:!0},{requireFunctionLikeSymbol:!0}])for(let a of Ee(e,{...s,scope:t.scope}))!l.has(a.relativePath)||r.has(a.symbolId)||(r.add(a.symbolId),n.push(a));return[...o.definitions,...n].filter(s=>Ce(s.relativePath)!==null)},warmReferenceFragments:(e,t,i)=>oe(e,o=>Ie(e,o),{onBatch:t,...i?{files:i}:{}}),materializeReferences:(e,t,i)=>Pe(e).materializeReferences(t,i),materializeCallees:we,releaseSemanticMemory:e=>z(e,{groups:["semantic-provider"]}),heapUsedFraction:()=>{let e=ht();return e.heap_size_limit>0?e.used_heap_size/e.heap_size_limit:0},collectGarbage:C,yieldToEventLoop:()=>new Promise(e=>setImmediate(e))};function kt(e){return K(JSON.stringify({kind:"health-semantic-prewarm-engine",rust:he(e.config.projectRoot)}))}var vn=N({envKey:"SCIP_QUERY_HEALTH_CONCURRENCY",defaultMinimum:vt,defaultMaximum:xt}),xn=N({envKey:"SCIP_QUERY_HEALTH_FULL_CONCURRENCY",defaultMinimum:Et,defaultMaximum:It,memoryPerTaskBytes:Ct});var En=N({envKey:"SCIP_QUERY_DIFF_IMPACT_CONCURRENCY",defaultMinimum:gt,defaultMaximum:St});function N(e){return(t,i=process.env,o=ft,l=yt())=>_t(t,i,o,l,e)}function _t(e,t,i,o,l){let r=t[l.envKey],n=Mt(i,o,l),s=r?parseInt(r,10):n;return!Number.isFinite(s)||s<1?Math.min(n,e):Math.min(s,e)}function Mt(e,t,i){let o=e(),l=Number.isFinite(o)?Math.max(i.defaultMinimum,o-1):0,r=i.memoryPerTaskBytes!==void 0&&Number.isFinite(t)&&t>0?Math.floor(t/2/i.memoryPerTaskBytes):Number.POSITIVE_INFINITY;return Math.min(i.defaultMaximum,r,Math.max(i.defaultMinimum,l))}import{spawn as Pn}from"child_process";import{createHash as Tt,randomUUID as An}from"crypto";import{existsSync as _n,realpathSync as Mn}from"fs";import{tmpdir as On}from"os";import{join as Dn,resolve as Ot}from"path";import{fileURLToPath as Fn}from"url";var y=18,F=1e3,jn=2*F;var Ht=64*1024*1024,Qn={maxItems:64,maxBytes:128*1024*1024,maxItemBytes:Ht,maxBatch:1,responseRetentionMs:6e4};function $e(e){return Tt("sha256").update(ue({kind:"scip-query-service-mailbox",protocolVersion:y,sessionDir:Ot(e)})).digest("hex")}var Lt=3e4,ze=5,jt=100,Qt=1024*1024,Bt=1280*1024,w={maxItems:64,maxBytes:128*1024*1024,maxItemBytes:64*1024*1024,maxBatch:1,responseRetentionMs:6e4};async function Vt(e,t){let i=pe(e);de(i);let o=G(qe(e,"server.lock"),{kind:"query-service-server",detail:{projectRoot:Ze(t)}});if(o.kind!=="acquired")return;let l;try{l=Re(t)}catch(b){throw o.lock.release(),b}let r=be([i.pendingDir,i.legacyRequestDir]),n=qe(e,"server.json"),s=$e(e),a=A(process.pid),c=!1,u=!1,p=I(),d=Number.NEGATIVE_INFINITY,m=0,f=()=>{c=!0};process.once("SIGINT",f),process.once("SIGTERM",f);let R=(b=!1)=>{let E=I();if(!b&&E-d<F)return;d=E;let j={protocolVersion:y,sessionIdentity:s,pid:process.pid,...a?{processIdentity:a}:{},generation:l.generation.identity,heartbeatAtMs:Date.now()};b?q(n,j):$(n,j)};try{R(!0);let b=zt();for(;!c&&!u&&I()-p<b;){let E=await Ut(i,l,s,()=>{u=!0});E>0?(m=0,p=I(),R()):(m+=1,R()),await r.wait(Kt(E,m))}}finally{r.close(),l.close(),Nt(n,{force:!0}),o.lock.release()}}async function Ut(e,t,i,o){let l=me(e,{ownerId:Yt,nowMs:Date.now(),limits:w,owner:Jt,liveness:Xt,durability:"visibility"}),r=0;for(let n of l){let s=n.requestId;try{let a=Wt(fe(n,w),i);if(s=a.id,a.id!==n.requestId||a.operationKey!==n.operationKey||a.clientId!==n.clientId||a.deadlineAtMs!==n.deadlineAtMs)throw new Error("Query service request identity does not match its mailbox claim.");if(a.deadlineAtMs<Date.now())throw new Error("Query service request expired before processing.");if(a.request.expectedGeneration!==t.generation.identity){T(e,n,{ok:!1,protocolVersion:y,id:s,generation:t.generation.identity,errorCode:"generation-mismatch",error:"Persistent query service opened a different generation."},{nowMs:Date.now(),limits:w,durability:"visibility"}),o(),r+=1;continue}let c=await Gt(t,a.request),u=Ve({projectRoot:t.config.projectRoot,db:t,observedSourceKinds:["index-generation"]}),p=Date.now();if(a.deadlineAtMs<p)throw new Error("Query service request expired while processing.");T(e,n,{ok:!0,protocolVersion:y,id:s,generation:t.generation.identity,result:c,observationReceipt:u},{nowMs:p,limits:w,durability:"visibility"})}catch(a){let c=a instanceof Error?a.message:String(a);ye(e,n,{ok:!1,protocolVersion:y,id:s,errorCode:"request-failed",error:c},c,{nowMs:Date.now(),limits:w})}r+=1}return r}async function Gt(e,t){if(t.kind==="source-search")return Le(e,t.pattern,t.options);if(t.kind==="outline")return ve(e,t.filePattern);if(t.kind==="entrypoints"){let{entryPoints:n}=await import("./entry-map-KOOLR26E.js");return n(e,t.options)}if(t.kind==="files"){let{files:n}=await import("./files-OPIPJIGZ.js");return n(e,t.pattern)}if(t.kind==="stats"){let{stats:n}=await import("./stats-OOJ74B32.js");return n(e)}if(t.kind==="members"){let[{members:n},{symbolResolutionJson:s}]=await Promise.all([import("./members-I5MEFOCT.js"),import("./code-result-json-FXALY4HE.js")]);return{...s(e,t.symbolPattern),members:n(e,t.symbolPattern)}}if(t.kind==="methods"){let{resolveMethods:n}=await import("./methods-5JYGGHXA.js");return n(e,{className:t.className})}if(t.kind==="file-dependencies"){let{deps:n,rdeps:s}=await import("./deps-7EMQUYUT.js");return t.direction==="outgoing"?n(e,t.filePattern):s(e,t.filePattern)}if(t.kind==="imported-by"){let{importedBy:n}=await import("./imports-M6HUXRXC.js");return n(e,t.symbolPattern)}if(t.kind==="hierarchy"){let[{hierarchy:n},{withSymbolResolutionJson:s}]=await Promise.all([import("./hierarchy-QPD2CAER.js"),import("./symbol-resolution-WD5EU5JE.js")]);return s(e,t.symbolPattern,n(e,t.symbolPattern),"hierarchy")}if(t.kind==="by-kind"||t.kind==="kind-counts"){let{byKind:n,kindCounts:s}=await import("./by-kind-XI2CSWEY.js");return t.kind==="by-kind"?n(e,t.kindQuery):s(e)}if(t.kind==="refs"){let[{refs:n},{compareReferenceKey:s},{withSymbolResolutionJson:a}]=await Promise.all([import("./refs-PSU4JZZW.js"),import("./refs-pagination-JG6CJMRC.js"),import("./symbol-resolution-WD5EU5JE.js")]),c=S(e),u=n(e,t.symbolPattern,{semantic:c}).sort(s);return{...a(e,t.symbolPattern,u,"references"),pagination:{cursorVersion:2,producer:"complete-only",semanticEnrichment:c}}}if(t.kind==="trace"){let n=S(e);if(!n){let p=v(e,t.kind,t.symbolPattern);if(p)return p}let[{qualifiedTraceEvidence:s},{symbolResolutionJson:a}]=await Promise.all([import("./trace-F4B6OLL4.js"),import("./symbol-resolution-WD5EU5JE.js")]),c=JSON.stringify({...a(e,t.symbolPattern),...s(e,t.symbolPattern,{semantic:n})}),u={serializedJson:c,sha256:h("sha256").update(c).digest("hex")};return n||x(e,t.kind,t.symbolPattern,u,Bt),u}if(t.kind==="value-flow"){let n=v(e,t.kind,t.symbolPattern);if(n)return n;let{valueFlow:s}=await import("./value-flow-VRPZY72V.js"),a=JSON.stringify(s(e,{symbols:[t.symbolPattern]},{maxDepth:2,maxEdges:48})),c={serializedJson:a,sha256:h("sha256").update(a).digest("hex")};return x(e,t.kind,t.symbolPattern,c),c}if(t.kind==="dependence-slice"){let n=v(e,t.kind,t.criterion);if(n)return n;let{dependenceSlice:s}=await import("./dependence-slice-R7FPWD5M.js"),a=JSON.stringify(s(e,t.criterion)),c={serializedJson:a,sha256:h("sha256").update(a).digest("hex")};return x(e,t.kind,t.criterion,c),c}if(t.kind==="call-graph"){let[{callGraph:n},{symbolResolutionJson:s}]=await Promise.all([import("./call-graph-UONR6JR5.js"),import("./symbol-resolution-WD5EU5JE.js")]),a=JSON.stringify({...s(e,t.symbolPattern),callGraph:n(e,t.symbolPattern,{semantic:S(e)})});return{serializedJson:a,sha256:h("sha256").update(a).digest("hex")}}if(t.kind==="reference-neighborhood"||t.kind==="dataflow"){let n=S(e),s=t.kind==="reference-neighborhood"&&!n;if(s){let f=v(e,t.kind,t.symbolPattern);if(f)return f}let[{dataflow:a,referenceNeighborhood:c},{symbolResolutionJson:u}]=await Promise.all([import("./dataflow-4KEMJPC6.js"),import("./symbol-resolution-WD5EU5JE.js")]),p=t.kind==="dataflow"?a(e,t.symbolPattern,{semantic:n}):c(e,t.symbolPattern,{semantic:n}),d=JSON.stringify({...u(e,t.symbolPattern),[t.kind]:p}),m={serializedJson:d,sha256:h("sha256").update(d).digest("hex")};return s&&x(e,t.kind,t.symbolPattern,m),m}if(t.kind==="reference-reachability"||t.kind==="slice"){let n=S(e);if(!n){let p=v(e,t.kind,t.symbolPattern);if(p)return p}let[{referenceReachability:s},{symbolResolutionJson:a}]=await Promise.all([import("./slice-HYRATV64.js"),import("./symbol-resolution-WD5EU5JE.js")]),c=JSON.stringify({...a(e,t.symbolPattern),[t.kind]:s(e,t.symbolPattern,{semantic:n})}),u={serializedJson:c,sha256:h("sha256").update(c).digest("hex")};return n||x(e,t.kind,t.symbolPattern,u),u}if(t.kind==="imports"){let{imports:n}=await import("./imports-M6HUXRXC.js");return n(e,t.filePattern,{semantic:S(e)})}if(t.kind==="unused-imports"){let{unusedImports:n}=await import("./imports-M6HUXRXC.js");return n(e,t.filePattern,{semantic:S(e)})}if(t.kind==="system"){let n=v(e,t.kind,t.modulePattern);if(n)return n;let{system:s}=await import("./system-LRQNFOR2.js"),a=JSON.stringify(s(e,t.modulePattern)),c={serializedJson:a,sha256:h("sha256").update(a).digest("hex")};return x(e,t.kind,t.modulePattern,c),c}if(t.kind==="surface"){let{consumerSurface:n}=await import("./surface-VTGDYWF5.js");return n(e,t.modulePattern)}let[{codeBatch:i},{codeBatchResultOnlyJsonForSelectors:o}]=await Promise.all([import("./code-MI6F2TTU.js"),import("./code-result-json-FXALY4HE.js")]),l=i(e,t.selectors,t.options),r=JSON.stringify(o(e,t.selectors,l));return{serializedJson:r,sha256:h("sha256").update(r).digest("hex")}}function Wt(e,t){let i=JSON.parse(e);if(!i||typeof i!="object"||Array.isArray(i))throw new Error("Invalid query service request.");let o=i,l=o.request;if(o.mailboxVersion!==1||o.protocolVersion!==y||typeof o.id!="string"||o.id.length===0||typeof o.operationKey!="string"||o.operationKey.length===0||typeof o.clientId!="string"||o.clientId.length===0||typeof o.enqueuedAtMs!="number"||!Number.isSafeInteger(o.enqueuedAtMs)||o.enqueuedAtMs<0||typeof o.deadlineAtMs!="number"||!Number.isSafeInteger(o.deadlineAtMs)||o.deadlineAtMs<o.enqueuedAtMs||o.sessionIdentity!==t||!l||typeof l!="object"||Array.isArray(l))throw new Error("Invalid query service request envelope.");let r=l;if(typeof r.expectedGeneration!="string")throw new Error("Invalid query service request generation.");let n={mailboxVersion:1,protocolVersion:y,id:o.id,operationKey:o.operationKey,clientId:o.clientId,enqueuedAtMs:o.enqueuedAtMs,deadlineAtMs:o.deadlineAtMs,sessionIdentity:t};if(r.kind==="outline"){if(typeof r.filePattern!="string")throw new Error("Invalid query service outline request.");return{...n,request:{kind:"outline",expectedGeneration:r.expectedGeneration,filePattern:r.filePattern}}}if(r.kind==="files"){if(typeof r.pattern!="string")throw new Error("Invalid query service files request.");return{...n,request:{kind:"files",expectedGeneration:r.expectedGeneration,pattern:r.pattern}}}if(r.kind==="stats")return{...n,request:{kind:"stats",expectedGeneration:r.expectedGeneration}};if(r.kind==="members"){if(typeof r.symbolPattern!="string")throw new Error("Invalid query service members request.");return{...n,request:{kind:"members",expectedGeneration:r.expectedGeneration,symbolPattern:r.symbolPattern}}}if(r.kind==="methods"){if(typeof r.className!="string")throw new Error("Invalid query service methods request.");return{...n,request:{kind:"methods",expectedGeneration:r.expectedGeneration,className:r.className}}}if(r.kind==="file-dependencies"){if(r.direction!=="outgoing"&&r.direction!=="incoming"||typeof r.filePattern!="string")throw new Error("Invalid query service file dependencies request.");return{...n,request:{kind:"file-dependencies",expectedGeneration:r.expectedGeneration,direction:r.direction,filePattern:r.filePattern}}}if(r.kind==="imported-by"||r.kind==="hierarchy"||r.kind==="refs"||r.kind==="trace"||r.kind==="value-flow"||r.kind==="call-graph"||r.kind==="reference-neighborhood"||r.kind==="reference-reachability"||r.kind==="slice"||r.kind==="dataflow"){if(typeof r.symbolPattern!="string")throw new Error(`Invalid query service ${r.kind} request.`);return{...n,request:{kind:r.kind,expectedGeneration:r.expectedGeneration,symbolPattern:r.symbolPattern}}}if(r.kind==="dependence-slice"){if(typeof r.criterion!="string")throw new Error("Invalid query service dependence-slice request.");return{...n,request:{kind:"dependence-slice",expectedGeneration:r.expectedGeneration,criterion:r.criterion}}}if(r.kind==="by-kind"){if(typeof r.kindQuery!="string")throw new Error("Invalid query service by-kind request.");return{...n,request:{kind:"by-kind",expectedGeneration:r.expectedGeneration,kindQuery:r.kindQuery}}}if(r.kind==="kind-counts")return{...n,request:{kind:"kind-counts",expectedGeneration:r.expectedGeneration}};if(r.kind==="imports"||r.kind==="unused-imports"){if(typeof r.filePattern!="string")throw new Error(`Invalid query service ${r.kind} request.`);return{...n,request:{kind:r.kind,expectedGeneration:r.expectedGeneration,filePattern:r.filePattern}}}if(r.kind==="system"||r.kind==="surface"){if(typeof r.modulePattern!="string")throw new Error(`Invalid query service ${r.kind} request.`);return{...n,request:{kind:r.kind,expectedGeneration:r.expectedGeneration,modulePattern:r.modulePattern}}}if(r.kind==="code"){if(!Array.isArray(r.selectors)||r.selectors.length<1||r.selectors.length>24||r.selectors.some(p=>typeof p!="string"||p.length===0)||!r.options||typeof r.options!="object"||Array.isArray(r.options))throw new Error("Invalid query service code request.");let c=r.options,u=c.members;if(u!=="exported"&&u!=="all")throw new Error("Query service code members must be exported or all.");return{...n,request:{kind:"code",expectedGeneration:r.expectedGeneration,selectors:r.selectors,options:{context:Ke(c.context,"context"),members:u}}}}if(r.kind==="entrypoints"){if(!r.options||typeof r.options!="object"||Array.isArray(r.options))throw new Error("Invalid query service entrypoints request.");let c=r.options;return{...n,request:{kind:"entrypoints",expectedGeneration:r.expectedGeneration,options:{...c.search===void 0?{}:{search:L(c.search,"search")},...c.scope===void 0?{}:{scope:L(c.scope,"scope")}}}}}if(r.kind!=="source-search"||typeof r.pattern!="string"||r.pattern.length===0||!r.options||typeof r.options!="object"||Array.isArray(r.options))throw new Error("Invalid query service source-search request.");let s=r.options,a={...s.scope===void 0?{}:{scope:L(s.scope,"scope")},...s.context===void 0?{}:{context:Ke(s.context,"context")},...s.limit===void 0?{}:{limit:$t(s.limit,"limit")},...s.regexp===void 0?{}:{regexp:Je(s.regexp,"regexp")},...s.ignoreCase===void 0?{}:{ignoreCase:Je(s.ignoreCase,"ignoreCase")},...s.ranking===void 0?{}:{ranking:qt(s.ranking)}};return{...n,request:{kind:"source-search",expectedGeneration:r.expectedGeneration,pattern:r.pattern,options:a}}}function L(e,t){if(typeof e!="string")throw new Error(`Query service option ${t} must be a string.`);return e}function Ke(e,t){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Query service option ${t} must be a non-negative safe integer.`);return e}var Ye=new WeakMap,et=new WeakMap;function v(e,t,i){let o=et.get(e);return o?.kind===t&&o.operand===i?o.result:null}function x(e,t,i,o,l=Qt){Buffer.byteLength(o.serializedJson)<=l&&et.set(e,{kind:t,operand:i,result:o})}function S(e){let t=Ye.get(e);if(t!==void 0)return t;let i=!We(e);return Ye.set(e,i),i}function $t(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`Query service option ${t} must be a positive safe integer.`);return e}function Je(e,t){if(typeof e!="boolean")throw new Error(`Query service option ${t} must be a boolean.`);return e}function qt(e){if(e!=="structural")throw new Error("Query service option ranking must be structural.");return e}function zt(){let e=Number(process.env.SCIP_QUERY_QUERY_SERVICE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:Lt}function Kt(e,t){return V(e,t,ze,ze,jt,5)}var Yt=`query-service-${process.pid}-${Dt()}`,Xe=A(process.pid),Jt={pid:process.pid,...Xe?{processIdentity:Xe}:{}},Xt={isProcessAlive:U,readProcessIdentity:A},Zt=process.argv[1]?Ft(Ze(process.argv[1])).href:null;if(Zt===import.meta.url){let e=process.argv[2],t=process.argv[3];!e||!t?(console.error("query-service: expected <session-dir> <project-root>"),process.exitCode=1):await Vt(e,t)}export{Vt as runQueryServiceServer};
4
+ `)}}function ot(e){let t=new Map;for(let i of e){let o=st(i.relativePath),l=t.get(o)??{matchingLines:0,matchingFiles:0};l.matchingLines+=i.matchingLines,l.matchingFiles+=1,t.set(o,l)}return[...t.entries()].map(([i,o])=>({scope:i,...o})).sort((i,o)=>o.matchingLines-i.matchingLines||o.matchingFiles-i.matchingFiles||i.scope.localeCompare(o.scope))}function st(e){let t=e.lastIndexOf("/");return t<0?e:e.slice(0,t)}function De(e,t){let i=e.map((l,r)=>({...l,priority:C(l.fileKind),sequence:r,evidenceCharacters:1,roles:["search"],reasons:["search"],symbols:l.ownerSymbol?[l.ownerSymbol]:[],behaviorSignals:[]})),o=[];for(let l of[0,1,2]){let r=t-o.length;if(r===0)break;let n=i.filter(s=>C(s.fileKind)===l);o.push(...ke(n,r,Number.MAX_SAFE_INTEGER,Fe).selected)}return o.map(({priority:l,sequence:r,evidenceCharacters:n,roles:s,reasons:a,symbols:c,behaviorSignals:u,...p})=>p)}function Fe(e,t){return C(e.fileKind)-C(t.fileKind)||+(t.ownerSymbol!==null)-+(e.ownerSymbol!==null)||e.relativePath.localeCompare(t.relativePath)||e.focusLine-t.focusLine}function Le(e,t,i={}){if(t.length===0)throw new Error("The source search pattern must not be empty.");return Ne(e,[t],i)[0]}import{availableParallelism as ft,totalmem as yt}from"os";import{fileURLToPath as tn}from"url";import{getHeapStatistics as ht}from"v8";async function je(e,t,i={}){let o=Math.max(1,Math.floor(i.batchSize??64)),l=i.collectGarbage??P,r=[],n=0;for(let s=0;s<t.length;s+=o){for(let a of t.slice(s,s+o)){for(let c of k(e,a))e.isIgnored(c.relativePath)||r.push(c);ie(e,a),ne(e,a),re(e,a),n+=1}i.onBatch?.({files:n,total:t.length,definitions:r.length}),l(),await i.yieldToEventLoop?.()}return{files:n,definitions:r}}import{execFileSync as vr}from"child_process";import{createHash as Er}from"crypto";import{lstatSync as Pr,readlinkSync as Cr,readdirSync as wr,realpathSync as Ar,statSync as kr}from"fs";import{dirname as Mr,isAbsolute as Tr,join as Or,posix as Hr,relative as Dr,resolve as Nr,sep as Fr}from"path";var jr=512*1024*1024;function Qe(e){return le({version:e.version,...e.base?{base:e.base}:{},files:[...e.files].sort((t,i)=>t.path.localeCompare(i.path))})}function D(e){return JSON.stringify({...e.clojureConfigPath?{clojureConfigPath:e.clojureConfigPath}:{},files:[...e.files].sort((t,i)=>t.path.localeCompare(i.path)).map(t=>({hash:t.hash,path:t.path,size:t.size})),languages:[...e.languages].sort(),pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),version:e.version})}var ct="scip-query:collaboration-domain",lt="scip-query:workspace-instance",ut="scip-query:index-generation",pt="scip-query:repository-content",Be="scip-query:index-inputs",dt="scip-query:index-inputs";function Ve(e){let t=e.snapshot,i=e.observedSourceKinds?new Set(e.observedSourceKinds):void 0,o=e.gitContext??t?.gitContext??(i?.has("live-workspace")?G(e.projectRoot):void 0),l=e.collaborationDomainId??e.db?.config.collaborationDomainId,r=l?g(ct,1,l):void 0,n=o?g(lt,1,o.worktreeId):void 0,s=t?g(pt,1,Qe(t.repositoryContent)):void 0,a=t?g(Be,t.indexInputs.version,D(t.indexInputs)):void 0,c=e.db&&t?mt(e.db.generation.metadataRaw):void 0,u=e.db?{generation:g(ut,1,e.db.generation.identity),...c?{inputs:c}:{},source:e.db.generation.source}:void 0,p=i??new Set([...u?["index-generation"]:[],...s?["repository-snapshot"]:n?["live-workspace"]:[]]),d=[...u&&p.has("index-generation")?[{kind:"index-generation",identity:u.generation}]:[],...s&&p.has("repository-snapshot")?[{kind:"repository-snapshot",identity:s}]:[],...n&&p.has("live-workspace")?[{kind:"live-workspace",identity:n}]:[],...p.has("process")?[{kind:"process"}]:[]],m=[...u&&p.has("index-generation")?[{source:"index-generation",kind:u.source==="immutable"?"immutable":"not-established"}]:[],...s&&p.has("repository-snapshot")?[{source:"repository-snapshot",kind:"fixed-snapshot"}]:[],...n&&p.has("live-workspace")?[{source:"live-workspace",kind:"not-established"}]:[],...p.has("process")?[{source:"process",kind:"not-established"}]:[]];return d.length===0&&(d.push({kind:"process"}),m.push({source:"process",kind:"not-established"})),{schemaVersion:ge,observedAt:(e.observedAt??(t?new Date(t.capturedAt):new Date)).toISOString(),facts:{...r?{collaborationDomain:r}:{},...n?{workspaceInstance:n}:{},...s?{wholeContent:s}:{},...a?{relevantInputs:[{subject:dt,identity:a}]}:{},...u?{index:u}:{}},observedSources:d,stabilityProofs:m,...o?{diagnostics:{clean:o.clean,...o.headCommit?{headCommit:o.headCommit}:{},...o.treeOid?{treeOid:o.treeOid}:{}}}:{}}}function mt(e){if(!e)return;let t=B(e);if(t.kind!=="legacy"&&t.kind!=="supported")return;let i=Q(t.metadata.fingerprint);return i&&Number.isSafeInteger(i.version)&&i.version>0?g(Be,i.version,D(i)):void 0}var gt=1,St=1;var hn=10*6e4,Rt=25e3,bt=2500;var vt=4,xt=12,Et=1,It=4,Pt=7*1024*1024*1024;var gn=10*6e4;var Sn=10*6e4;var Ct=new Set(["vue-component-duplicates","vue-composable-candidates","vue-large-view-pressure"]),Rn=new Set([...Ct,"suppressions"]);var Ue=2,$e=J({kind:"health-semantic-prewarm",invalidation:X("health-semantic-prewarm"),serialize:e=>JSON.stringify(e),deserialize:wt});function wt(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let i=t;return i.version!==Ue||typeof i.definitions!="number"||!Number.isFinite(i.definitions)||typeof i.referenceCacheWrites!="number"||!Number.isFinite(i.referenceCacheWrites)||typeof i.referenceIncomplete!="number"||!Number.isFinite(i.referenceIncomplete)||typeof i.calleeRows!="number"||!Number.isFinite(i.calleeRows)||typeof i.warmedAt!="number"||!Number.isFinite(i.warmedAt)?null:{version:Ue,definitions:i.definitions,referenceCacheWrites:i.referenceCacheWrites,referenceIncomplete:i.referenceIncomplete,calleeRows:i.calleeRows,warmedAt:i.warmedAt}}catch{return null}}function At(e,t){return!t||t.count<=1?[...e]:e.filter((i,o)=>o%t.count===t.index)}function Ge(e){let t=H(e);return t.symbols>=Rt||t.documents>=bt}var bn={env:process.env,projectFingerprint:Y,semanticEngineFingerprint:kt,readMarker:(e,t,i)=>$e.read(e,t,i),writeMarker:(e,t,i,o)=>$e.write(e,t,i,o),projectFiles:(e,t)=>At(Z(e,{scope:t.scope,includeIgnored:!1}),t.shard),candidateDefinitions:async(e,t,i)=>{let o=await je(e,i,{collectGarbage:P,yieldToEventLoop:()=>new Promise(s=>setImmediate(s))}),l=new Set(i),r=new Set(o.definitions.map(s=>s.symbolId)),n=[];for(let s of[{},{requireCallableSymbol:!0},{requireFunctionLikeSymbol:!0}])for(let a of Ee(e,{...s,scope:t.scope}))!l.has(a.relativePath)||r.has(a.symbolId)||(r.add(a.symbolId),n.push(a));return[...o.definitions,...n].filter(s=>Pe(s.relativePath)!==null)},warmReferenceFragments:(e,t,i)=>oe(e,o=>Ie(e,o),{onBatch:t,...i?{files:i}:{}}),materializeReferences:(e,t,i)=>Ce(e).materializeReferences(t,i),materializeCallees:we,releaseSemanticMemory:e=>z(e,{groups:["semantic-provider"]}),heapUsedFraction:()=>{let e=ht();return e.heap_size_limit>0?e.used_heap_size/e.heap_size_limit:0},collectGarbage:P,yieldToEventLoop:()=>new Promise(e=>setImmediate(e))};function kt(e){return K(JSON.stringify({kind:"health-semantic-prewarm-engine",rust:he(e.config.projectRoot)}))}var vn=N({envKey:"SCIP_QUERY_HEALTH_CONCURRENCY",defaultMinimum:vt,defaultMaximum:xt}),xn=N({envKey:"SCIP_QUERY_HEALTH_FULL_CONCURRENCY",defaultMinimum:Et,defaultMaximum:It,memoryPerTaskBytes:Pt});var En=N({envKey:"SCIP_QUERY_DIFF_IMPACT_CONCURRENCY",defaultMinimum:gt,defaultMaximum:St});function N(e){return(t,i=process.env,o=ft,l=yt())=>_t(t,i,o,l,e)}function _t(e,t,i,o,l){let r=t[l.envKey],n=Mt(i,o,l),s=r?parseInt(r,10):n;return!Number.isFinite(s)||s<1?Math.min(n,e):Math.min(s,e)}function Mt(e,t,i){let o=e(),l=Number.isFinite(o)?Math.max(i.defaultMinimum,o-1):0,r=i.memoryPerTaskBytes!==void 0&&Number.isFinite(t)&&t>0?Math.floor(t/2/i.memoryPerTaskBytes):Number.POSITIVE_INFINITY;return Math.min(i.defaultMaximum,r,Math.max(i.defaultMinimum,l))}import{spawn as Cn}from"child_process";import{createHash as Tt,randomUUID as An}from"crypto";import{existsSync as _n,realpathSync as Mn}from"fs";import{tmpdir as On}from"os";import{join as Dn,resolve as Ot}from"path";import{fileURLToPath as Fn}from"url";var y=18,F=1e3,jn=2*F;var Ht=64*1024*1024,Qn={maxItems:64,maxBytes:128*1024*1024,maxItemBytes:Ht,maxBatch:1,responseRetentionMs:6e4};function We(e){return Tt("sha256").update(ue({kind:"scip-query-service-mailbox",protocolVersion:y,sessionDir:Ot(e)})).digest("hex")}var Lt=3e4,ze=5,jt=100,Qt=1024*1024,Bt=1280*1024,w={maxItems:64,maxBytes:128*1024*1024,maxItemBytes:64*1024*1024,maxBatch:1,responseRetentionMs:6e4};async function Vt(e,t){let i=pe(e);de(i);let o=$(qe(e,"server.lock"),{kind:"query-service-server",detail:{projectRoot:Ze(t)}});if(o.kind!=="acquired")return;let l;try{l=Re(t)}catch(b){throw o.lock.release(),b}let r=be([i.pendingDir,i.legacyRequestDir]),n=qe(e,"server.json"),s=We(e),a=A(process.pid),c=!1,u=!1,p=I(),d=Number.NEGATIVE_INFINITY,m=0,f=()=>{c=!0};process.once("SIGINT",f),process.once("SIGTERM",f);let R=(b=!1)=>{let E=I();if(!b&&E-d<F)return;d=E;let j={protocolVersion:y,sessionIdentity:s,pid:process.pid,...a?{processIdentity:a}:{},generation:l.generation.identity,heartbeatAtMs:Date.now()};b?q(n,j):W(n,j)};try{R(!0);let b=zt();for(;!c&&!u&&I()-p<b;){let E=await Ut(i,l,s,()=>{u=!0});E>0?(m=0,p=I(),R()):(m+=1,R()),await r.wait(Kt(E,m))}}finally{r.close(),l.close(),Nt(n,{force:!0}),o.lock.release()}}async function Ut(e,t,i,o){let l=me(e,{ownerId:Yt,nowMs:Date.now(),limits:w,owner:Jt,liveness:Xt,durability:"visibility"}),r=0;for(let n of l){let s=n.requestId;try{let a=Gt(fe(n,w),i);if(s=a.id,a.id!==n.requestId||a.operationKey!==n.operationKey||a.clientId!==n.clientId||a.deadlineAtMs!==n.deadlineAtMs)throw new Error("Query service request identity does not match its mailbox claim.");if(a.deadlineAtMs<Date.now())throw new Error("Query service request expired before processing.");if(a.request.expectedGeneration!==t.generation.identity){T(e,n,{ok:!1,protocolVersion:y,id:s,generation:t.generation.identity,errorCode:"generation-mismatch",error:"Persistent query service opened a different generation."},{nowMs:Date.now(),limits:w,durability:"visibility"}),o(),r+=1;continue}let c=await $t(t,a.request),u=Ve({projectRoot:t.config.projectRoot,db:t,observedSourceKinds:["index-generation"]}),p=Date.now();if(a.deadlineAtMs<p)throw new Error("Query service request expired while processing.");T(e,n,{ok:!0,protocolVersion:y,id:s,generation:t.generation.identity,result:c,observationReceipt:u},{nowMs:p,limits:w,durability:"visibility"})}catch(a){let c=a instanceof Error?a.message:String(a);ye(e,n,{ok:!1,protocolVersion:y,id:s,errorCode:"request-failed",error:c},c,{nowMs:Date.now(),limits:w})}r+=1}return r}async function $t(e,t){if(t.kind==="source-search")return Le(e,t.pattern,t.options);if(t.kind==="outline")return ve(e,t.filePattern);if(t.kind==="entrypoints"){let{entryPoints:n}=await import("./entry-map-QCTF4RVY.js");return n(e,t.options)}if(t.kind==="files"){let{files:n}=await import("./files-M2UBF5HJ.js");return n(e,t.pattern)}if(t.kind==="stats"){let{stats:n}=await import("./stats-OOJ74B32.js");return n(e)}if(t.kind==="members"){let[{members:n},{symbolResolutionJson:s}]=await Promise.all([import("./members-YKD636DA.js"),import("./code-result-json-5FEFQCAQ.js")]);return{...s(e,t.symbolPattern),members:n(e,t.symbolPattern)}}if(t.kind==="methods"){let{resolveMethods:n}=await import("./methods-VDF4IMYG.js");return n(e,{className:t.className})}if(t.kind==="file-dependencies"){let{deps:n,rdeps:s}=await import("./deps-4QHVDPYA.js");return t.direction==="outgoing"?n(e,t.filePattern):s(e,t.filePattern)}if(t.kind==="imported-by"){let{importedBy:n}=await import("./imports-WIE3YZOB.js");return n(e,t.symbolPattern)}if(t.kind==="hierarchy"){let[{hierarchy:n},{withSymbolResolutionJson:s}]=await Promise.all([import("./hierarchy-2UIHRLW4.js"),import("./symbol-resolution-DBLVXLBC.js")]);return s(e,t.symbolPattern,n(e,t.symbolPattern),"hierarchy")}if(t.kind==="by-kind"||t.kind==="kind-counts"){let{byKind:n,kindCounts:s}=await import("./by-kind-H3P6BR5G.js");return t.kind==="by-kind"?n(e,t.kindQuery):s(e)}if(t.kind==="refs"){let[{refs:n},{compareReferenceKey:s},{withSymbolResolutionJson:a}]=await Promise.all([import("./refs-JNK5CLM7.js"),import("./refs-pagination-6BLRYGMV.js"),import("./symbol-resolution-DBLVXLBC.js")]),c=S(e),u=n(e,t.symbolPattern,{semantic:c}).sort(s);return{...a(e,t.symbolPattern,u,"references"),pagination:{cursorVersion:2,producer:"complete-only",semanticEnrichment:c}}}if(t.kind==="trace"){let n=S(e);if(!n){let p=v(e,t.kind,t.symbolPattern);if(p)return p}let[{qualifiedTraceEvidence:s},{symbolResolutionJson:a}]=await Promise.all([import("./trace-I2P2YFH4.js"),import("./symbol-resolution-DBLVXLBC.js")]),c=JSON.stringify({...a(e,t.symbolPattern),...s(e,t.symbolPattern,{semantic:n})}),u={serializedJson:c,sha256:h("sha256").update(c).digest("hex")};return n||x(e,t.kind,t.symbolPattern,u,Bt),u}if(t.kind==="value-flow"){let n=v(e,t.kind,t.symbolPattern);if(n)return n;let{valueFlow:s}=await import("./value-flow-JJVMF7NP.js"),a=JSON.stringify(s(e,{symbols:[t.symbolPattern]},{maxDepth:2,maxEdges:48})),c={serializedJson:a,sha256:h("sha256").update(a).digest("hex")};return x(e,t.kind,t.symbolPattern,c),c}if(t.kind==="dependence-slice"){let n=v(e,t.kind,t.criterion);if(n)return n;let{dependenceSlice:s}=await import("./dependence-slice-GWGQCODG.js"),a=JSON.stringify(s(e,t.criterion)),c={serializedJson:a,sha256:h("sha256").update(a).digest("hex")};return x(e,t.kind,t.criterion,c),c}if(t.kind==="call-graph"){let[{callGraph:n},{symbolResolutionJson:s}]=await Promise.all([import("./call-graph-VTG2CUOQ.js"),import("./symbol-resolution-DBLVXLBC.js")]),a=JSON.stringify({...s(e,t.symbolPattern),callGraph:n(e,t.symbolPattern,{semantic:S(e)})});return{serializedJson:a,sha256:h("sha256").update(a).digest("hex")}}if(t.kind==="reference-neighborhood"||t.kind==="dataflow"){let n=S(e),s=t.kind==="reference-neighborhood"&&!n;if(s){let f=v(e,t.kind,t.symbolPattern);if(f)return f}let[{dataflow:a,referenceNeighborhood:c},{symbolResolutionJson:u}]=await Promise.all([import("./dataflow-GFBTVDH3.js"),import("./symbol-resolution-DBLVXLBC.js")]),p=t.kind==="dataflow"?a(e,t.symbolPattern,{semantic:n}):c(e,t.symbolPattern,{semantic:n}),d=JSON.stringify({...u(e,t.symbolPattern),[t.kind]:p}),m={serializedJson:d,sha256:h("sha256").update(d).digest("hex")};return s&&x(e,t.kind,t.symbolPattern,m),m}if(t.kind==="reference-reachability"||t.kind==="slice"){let n=S(e);if(!n){let p=v(e,t.kind,t.symbolPattern);if(p)return p}let[{referenceReachability:s},{symbolResolutionJson:a}]=await Promise.all([import("./slice-PHPVNCWX.js"),import("./symbol-resolution-DBLVXLBC.js")]),c=JSON.stringify({...a(e,t.symbolPattern),[t.kind]:s(e,t.symbolPattern,{semantic:n})}),u={serializedJson:c,sha256:h("sha256").update(c).digest("hex")};return n||x(e,t.kind,t.symbolPattern,u),u}if(t.kind==="imports"){let{imports:n}=await import("./imports-WIE3YZOB.js");return n(e,t.filePattern,{semantic:S(e)})}if(t.kind==="unused-imports"){let{unusedImports:n}=await import("./imports-WIE3YZOB.js");return n(e,t.filePattern,{semantic:S(e)})}if(t.kind==="system"){let n=v(e,t.kind,t.modulePattern);if(n)return n;let{system:s}=await import("./system-JOPKV4OG.js"),a=JSON.stringify(s(e,t.modulePattern)),c={serializedJson:a,sha256:h("sha256").update(a).digest("hex")};return x(e,t.kind,t.modulePattern,c),c}if(t.kind==="surface"){let{consumerSurface:n}=await import("./surface-MQX5MPIV.js");return n(e,t.modulePattern)}let[{codeBatch:i},{codeBatchResultOnlyJsonForSelectors:o}]=await Promise.all([import("./code-TAVIKWJI.js"),import("./code-result-json-5FEFQCAQ.js")]),l=i(e,t.selectors,t.options),r=JSON.stringify(o(e,t.selectors,l));return{serializedJson:r,sha256:h("sha256").update(r).digest("hex")}}function Gt(e,t){let i=JSON.parse(e);if(!i||typeof i!="object"||Array.isArray(i))throw new Error("Invalid query service request.");let o=i,l=o.request;if(o.mailboxVersion!==1||o.protocolVersion!==y||typeof o.id!="string"||o.id.length===0||typeof o.operationKey!="string"||o.operationKey.length===0||typeof o.clientId!="string"||o.clientId.length===0||typeof o.enqueuedAtMs!="number"||!Number.isSafeInteger(o.enqueuedAtMs)||o.enqueuedAtMs<0||typeof o.deadlineAtMs!="number"||!Number.isSafeInteger(o.deadlineAtMs)||o.deadlineAtMs<o.enqueuedAtMs||o.sessionIdentity!==t||!l||typeof l!="object"||Array.isArray(l))throw new Error("Invalid query service request envelope.");let r=l;if(typeof r.expectedGeneration!="string")throw new Error("Invalid query service request generation.");let n={mailboxVersion:1,protocolVersion:y,id:o.id,operationKey:o.operationKey,clientId:o.clientId,enqueuedAtMs:o.enqueuedAtMs,deadlineAtMs:o.deadlineAtMs,sessionIdentity:t};if(r.kind==="outline"){if(typeof r.filePattern!="string")throw new Error("Invalid query service outline request.");return{...n,request:{kind:"outline",expectedGeneration:r.expectedGeneration,filePattern:r.filePattern}}}if(r.kind==="files"){if(typeof r.pattern!="string")throw new Error("Invalid query service files request.");return{...n,request:{kind:"files",expectedGeneration:r.expectedGeneration,pattern:r.pattern}}}if(r.kind==="stats")return{...n,request:{kind:"stats",expectedGeneration:r.expectedGeneration}};if(r.kind==="members"){if(typeof r.symbolPattern!="string")throw new Error("Invalid query service members request.");return{...n,request:{kind:"members",expectedGeneration:r.expectedGeneration,symbolPattern:r.symbolPattern}}}if(r.kind==="methods"){if(typeof r.className!="string")throw new Error("Invalid query service methods request.");return{...n,request:{kind:"methods",expectedGeneration:r.expectedGeneration,className:r.className}}}if(r.kind==="file-dependencies"){if(r.direction!=="outgoing"&&r.direction!=="incoming"||typeof r.filePattern!="string")throw new Error("Invalid query service file dependencies request.");return{...n,request:{kind:"file-dependencies",expectedGeneration:r.expectedGeneration,direction:r.direction,filePattern:r.filePattern}}}if(r.kind==="imported-by"||r.kind==="hierarchy"||r.kind==="refs"||r.kind==="trace"||r.kind==="value-flow"||r.kind==="call-graph"||r.kind==="reference-neighborhood"||r.kind==="reference-reachability"||r.kind==="slice"||r.kind==="dataflow"){if(typeof r.symbolPattern!="string")throw new Error(`Invalid query service ${r.kind} request.`);return{...n,request:{kind:r.kind,expectedGeneration:r.expectedGeneration,symbolPattern:r.symbolPattern}}}if(r.kind==="dependence-slice"){if(typeof r.criterion!="string")throw new Error("Invalid query service dependence-slice request.");return{...n,request:{kind:"dependence-slice",expectedGeneration:r.expectedGeneration,criterion:r.criterion}}}if(r.kind==="by-kind"){if(typeof r.kindQuery!="string")throw new Error("Invalid query service by-kind request.");return{...n,request:{kind:"by-kind",expectedGeneration:r.expectedGeneration,kindQuery:r.kindQuery}}}if(r.kind==="kind-counts")return{...n,request:{kind:"kind-counts",expectedGeneration:r.expectedGeneration}};if(r.kind==="imports"||r.kind==="unused-imports"){if(typeof r.filePattern!="string")throw new Error(`Invalid query service ${r.kind} request.`);return{...n,request:{kind:r.kind,expectedGeneration:r.expectedGeneration,filePattern:r.filePattern}}}if(r.kind==="system"||r.kind==="surface"){if(typeof r.modulePattern!="string")throw new Error(`Invalid query service ${r.kind} request.`);return{...n,request:{kind:r.kind,expectedGeneration:r.expectedGeneration,modulePattern:r.modulePattern}}}if(r.kind==="code"){if(!Array.isArray(r.selectors)||r.selectors.length<1||r.selectors.length>24||r.selectors.some(p=>typeof p!="string"||p.length===0)||!r.options||typeof r.options!="object"||Array.isArray(r.options))throw new Error("Invalid query service code request.");let c=r.options,u=c.members;if(u!=="exported"&&u!=="all")throw new Error("Query service code members must be exported or all.");return{...n,request:{kind:"code",expectedGeneration:r.expectedGeneration,selectors:r.selectors,options:{context:Ke(c.context,"context"),members:u}}}}if(r.kind==="entrypoints"){if(!r.options||typeof r.options!="object"||Array.isArray(r.options))throw new Error("Invalid query service entrypoints request.");let c=r.options;return{...n,request:{kind:"entrypoints",expectedGeneration:r.expectedGeneration,options:{...c.search===void 0?{}:{search:L(c.search,"search")},...c.scope===void 0?{}:{scope:L(c.scope,"scope")}}}}}if(r.kind!=="source-search"||typeof r.pattern!="string"||r.pattern.length===0||!r.options||typeof r.options!="object"||Array.isArray(r.options))throw new Error("Invalid query service source-search request.");let s=r.options,a={...s.scope===void 0?{}:{scope:L(s.scope,"scope")},...s.context===void 0?{}:{context:Ke(s.context,"context")},...s.limit===void 0?{}:{limit:Wt(s.limit,"limit")},...s.regexp===void 0?{}:{regexp:Je(s.regexp,"regexp")},...s.ignoreCase===void 0?{}:{ignoreCase:Je(s.ignoreCase,"ignoreCase")},...s.ranking===void 0?{}:{ranking:qt(s.ranking)}};return{...n,request:{kind:"source-search",expectedGeneration:r.expectedGeneration,pattern:r.pattern,options:a}}}function L(e,t){if(typeof e!="string")throw new Error(`Query service option ${t} must be a string.`);return e}function Ke(e,t){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Query service option ${t} must be a non-negative safe integer.`);return e}var Ye=new WeakMap,et=new WeakMap;function v(e,t,i){let o=et.get(e);return o?.kind===t&&o.operand===i?o.result:null}function x(e,t,i,o,l=Qt){Buffer.byteLength(o.serializedJson)<=l&&et.set(e,{kind:t,operand:i,result:o})}function S(e){let t=Ye.get(e);if(t!==void 0)return t;let i=!Ge(e);return Ye.set(e,i),i}function Wt(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`Query service option ${t} must be a positive safe integer.`);return e}function Je(e,t){if(typeof e!="boolean")throw new Error(`Query service option ${t} must be a boolean.`);return e}function qt(e){if(e!=="structural")throw new Error("Query service option ranking must be structural.");return e}function zt(){let e=Number(process.env.SCIP_QUERY_QUERY_SERVICE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:Lt}function Kt(e,t){return V(e,t,ze,ze,jt,5)}var Yt=`query-service-${process.pid}-${Dt()}`,Xe=A(process.pid),Jt={pid:process.pid,...Xe?{processIdentity:Xe}:{}},Xt={isProcessAlive:U,readProcessIdentity:A},Zt=process.argv[1]?Ft(Ze(process.argv[1])).href:null;if(Zt===import.meta.url){let e=process.argv[2],t=process.argv[3];!e||!t?(console.error("query-service: expected <session-dir> <project-root>"),process.exitCode=1):await Vt(e,t)}export{Vt as runQueryServiceServer};
5
5
  //# sourceMappingURL=query-service-server.js.map
@@ -0,0 +1,2 @@
1
+ import{a}from"./chunk-T6DWDI5E.js";import"./chunk-WDSFQDPN.js";import"./chunk-ANLNLY66.js";import"./chunk-JCSAZ35V.js";import"./chunk-FI7VGOR4.js";import"./chunk-WRQXLNYE.js";import"./chunk-L7KTFEAV.js";import"./chunk-2USA3S3P.js";import"./chunk-BJT7LSPK.js";import"./chunk-5BIKR67W.js";import"./chunk-CZW5MZ5B.js";import"./chunk-F4FNK44D.js";import"./chunk-ODPDP7A4.js";import"./chunk-MOKUWRHO.js";import"./chunk-FVFDOIM3.js";import"./chunk-2VAHDDLM.js";import"./chunk-YXPUP5G2.js";import"./chunk-BL6DCHQP.js";import"./chunk-EHYDXE3Z.js";import"./chunk-2OOY75BW.js";import"./chunk-U6KCHXJ4.js";import"./chunk-T3I6NHBH.js";import"./chunk-ATXPTSEI.js";import"./chunk-CKBUBRYD.js";import"./chunk-IW5XQG5G.js";import"./chunk-T3CZAZSI.js";import"./chunk-B3PYOSCX.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-JFMEXGFE.js";import"./chunk-7HXT6YLU.js";import"./chunk-7F45LJKI.js";export{a as refs};
2
+ //# sourceMappingURL=refs-JNK5CLM7.js.map
@@ -0,0 +1,2 @@
1
+ import{a as y}from"./chunk-T6DWDI5E.js";import"./chunk-WDSFQDPN.js";import"./chunk-ANLNLY66.js";import"./chunk-JCSAZ35V.js";import{k as v,l as S,n as w}from"./chunk-FI7VGOR4.js";import"./chunk-WRQXLNYE.js";import"./chunk-L7KTFEAV.js";import{a as u}from"./chunk-2USA3S3P.js";import{c as d}from"./chunk-BJT7LSPK.js";import"./chunk-5BIKR67W.js";import"./chunk-CZW5MZ5B.js";import"./chunk-F4FNK44D.js";import"./chunk-ODPDP7A4.js";import"./chunk-MOKUWRHO.js";import"./chunk-FVFDOIM3.js";import"./chunk-2VAHDDLM.js";import"./chunk-YXPUP5G2.js";import{g}from"./chunk-BL6DCHQP.js";import"./chunk-EHYDXE3Z.js";import"./chunk-2OOY75BW.js";import"./chunk-U6KCHXJ4.js";import"./chunk-T3I6NHBH.js";import"./chunk-ATXPTSEI.js";import"./chunk-CKBUBRYD.js";import"./chunk-IW5XQG5G.js";import"./chunk-T3CZAZSI.js";import"./chunk-B3PYOSCX.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-JFMEXGFE.js";import"./chunk-7HXT6YLU.js";import"./chunk-7F45LJKI.js";function j(t,r,e){if(!Number.isSafeInteger(e.limit)||e.limit<=0)throw new Error("Reference page limit must be a positive safe integer.");let n=u(t,r);if(!n)return{rows:[],hasMore:!1,producer:e.producer??"source-keyset",semanticEnrichment:!1};if(e.producer==="complete-only"||e.semantic===!0||n.relativePath.endsWith(".rb"))return m(t,r,e);let a=v(t,n);if(!a)return m(t,r,e);let i=F(t,n),c=x(t,i),f=[],R=e.producer==="source-keyset";for(let l of c){if(e.after&&l<e.after.relativePath)continue;e.instrumentation?.fileScanned?.(l);let h=S(t,a,l);h.length>0&&(R=!0);let P=new Set(h);i?.relativePath===l&&P.add(i.line);for(let k of[...P].sort((s,M)=>s-M)){let s={relativePath:l,line:k};if(!(e.after&&p(s,e.after)<=0)&&(f.push(s),e.instrumentation?.rowAccepted?.(s),R&&f.length>e.limit))return b(f,e.limit)}}return R?b(f,e.limit):m(t,r,e,i)}function p(t,r){return(t.relativePath<r.relativePath?-1:t.relativePath>r.relativePath?1:0)||t.line-r.line}function b(t,r){return{rows:t.slice(0,r),hasMore:t.length>r,producer:"source-keyset",semanticEnrichment:!1}}function m(t,r,e,n){let o=u(t,r),a=e.semantic===!0||o?.relativePath.endsWith(".rb")?y(t,r,{semantic:e.semantic}):D(t,r,n),i=E(a).filter(c=>!e.after||p(c,e.after)>0);for(let c of i.slice(0,e.limit+1))e.instrumentation?.rowAccepted?.(c);return{rows:i.slice(0,e.limit),hasMore:i.length>e.limit,producer:"complete-only",semanticEnrichment:e.semantic===!0}}function D(t,r,e){let n=u(t,r);if(!n)return[];let o=e===void 0?F(t,n):e,a=w(t,n).map(i=>({relativePath:i.file,line:i.line}));return o?[o,...a]:a}function F(t,r){return!g(r.symbol)&&!t.isIgnored(r.relativePath)?{relativePath:r.relativePath,line:r.startLine}:null}function x(t,r){let e=d(t);return!r||e.includes(r.relativePath)?e:[...e,r.relativePath].sort((n,o)=>n<o?-1:n>o?1:0)}function E(t){let r=new Map;for(let e of t)r.set(`${e.relativePath}\0${e.line}`,e);return[...r.values()].sort(p)}export{p as compareReferenceKey,j as referencePage};
2
+ //# sourceMappingURL=refs-pagination-6BLRYGMV.js.map