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,2 +1,2 @@
1
- import{c as _t,d as j}from"./chunk-WYPL7GF7.js";import{b as k}from"./chunk-RTQ7NEKG.js";import{d as Se,f as Ct}from"./chunk-GUFSG5TX.js";import{b as Ft}from"./chunk-3AF4TUFK.js";import{a as xe,b as V,c as G}from"./chunk-FGA2U4OR.js";import{a as be}from"./chunk-B3PYOSCX.js";import{e as X}from"./chunk-HGFDYOVB.js";import{a as Pt,b as Tt,c as ye,d as Lt}from"./chunk-JFMEXGFE.js";import{A as Ne,C as jt,D as Nt,F as qt,a as Gt,c as Dt,d as At,e as he,ga as qe,j as Ie,k as O,l as Z,n as Me,r as Fe,s as kt,u as Ot,v as Mt,w as _e,x as je}from"./chunk-KYSDI3GE.js";import{a as v,b as J,c as S,f as I,g as R,h as b,k as Et,l as H}from"./chunk-7F45LJKI.js";import{createHash as en,randomUUID as tn}from"crypto";import{existsSync as Y,mkdirSync as rn,readdirSync as nn,rmSync as Bt,statSync as Wt}from"fs";import{basename as on,dirname as we,join as w}from"path";var N=1,ze=1,te=".scipquery-generations",ve="manifest.json",zt="readers",an="gc.lock",sn=128,ee=new Map,Ut={pid:process.pid,now:()=>new Date,randomToken:()=>tn(),isProcessAlive:be,readProcessIdentity:ye};function h(e){return w(we(e),te)}function Ue(e){return w(h(e),an)}function Po(e,t=Ut){let r=j(Ue(e.dbPath),{waitMs:5e3,directoryDurability:"recoverable"});if(!r)throw new Error("SQLite generation retention is busy; retry opening the index.");let n;try{let i=ln(e);if(i.source!=="immutable")return{generation:i,release(){}};let o=t.randomToken();if(!/^[A-Za-z0-9._-]+$/.test(o))throw new Error("SQLite generation reader token is unsafe.");let a=w(h(e.dbPath),zt);rn(a,{recursive:!0}),n=w(a,`${t.pid}-${o}.json`);let s=t.readProcessIdentity(t.pid);V(n,{version:1,token:o,generationIdentity:i.identity,pid:t.pid,...s?{processIdentity:s}:{},acquiredAt:t.now().toISOString()},{spacing:2,trailingNewline:!0});let c=!1;return{generation:i,release(){c||!n||(c=!0,Bt(n,{force:!0}))}}}finally{r.release()}}function Ht(e,t,r=Ut,n={}){let i=w(h(e),zt);if(!Y(i))return{protectedGenerations:new Set,activeLeases:0,staleLeasesRemoved:0,malformedLeases:0};let o=new Set,a=0,s=0,c=0;for(let d of nn(i,{withFileTypes:!0})){if(!d.isFile()||!d.name.endsWith(".json"))continue;let l=w(i,d.name),f;try{f=cn(JSON.parse(b(l,"SQLite generation reader lease")))}catch{f=null}if(!f){c+=1;for(let m of t)o.add(m);continue}if(!dn(f,r)){n.removeStale!==!1&&(Bt(l,{force:!0}),s+=1);continue}a+=1,o.add(f.generationIdentity)}return{protectedGenerations:o,activeLeases:a,staleLeasesRemoved:s,malformedLeases:c}}function cn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=t.processIdentity===void 0?null:Pt(t.processIdentity);return t.version!==1||typeof t.token!="string"||t.token.trim()===""||typeof t.generationIdentity!="string"||!/^[a-f0-9]{64}$/.test(t.generationIdentity)||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.acquiredAt!="string"||!Number.isFinite(Date.parse(t.acquiredAt))||t.processIdentity!==void 0&&(!r||r.pid!==t.pid)?null:{version:1,token:t.token,generationIdentity:t.generationIdentity,pid:t.pid,...r?{processIdentity:r}:{},acquiredAt:t.acquiredAt}}function dn(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let r=t.readProcessIdentity(e.pid);return r===null||Tt(e.processIdentity,r)}function q(e){try{let t=JSON.parse(b(w(h(e),"state.json"),"SQLite generation state"));return mn(t)?t:null}catch{return null}}function re(e,t){return ne(h(e),t)}function ne(e,t){try{let r=JSON.parse(b(w(e,t,ve),"SQLite generation manifest"));return pn(r,t)?r:null}catch{return null}}function ln(e){let t=q(e.dbPath);if(t){let r=un(e,t.currentGeneration);if(r)return r;if(t.artifactSet==="immutable-v1")throw new Error(`Published SQLite generation ${t.currentGeneration} is missing or invalid.`)}if(Y(w(we(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return fn(e,t?.currentGeneration)}function To(e){let t=q(e);if(t)return t.currentGeneration;try{let r=w(we(e),"meta.json"),n=Y(r)?b(r,"reindex metadata"):void 0;return Vt(e,n)}catch{return null}}function M(e){return Ct(Se(e))??e}function un(e,t){try{let r=w(h(e.dbPath),t),n=re(e.dbPath,t);if(!n)return null;let i=$e(r,n.database),o=n.index?$e(r,n.index):void 0,a=n.metadata?$e(r,n.metadata):void 0;return!Be(i,n.database)||n.index&&(!o||!Be(o,n.index))||n.metadata&&(!a||!Be(a,n.metadata))?null:{identity:t,databasePath:i,...o?{indexPath:o}:{},...a?{metadataPath:a,metadataRaw:b(a,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function fn(e,t){let r=$(e.dbPath),n=w(we(e.dbPath),"meta.json"),i=Y(n)?b(n,"reindex metadata"):void 0,o=Y(e.indexPath)?e.indexPath:void 0;return{identity:t??Vt(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:n,metadataRaw:i},source:"legacy",databaseFileIdentity:r}}function Vt(e,t){let r=en("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&r.update(M(t)),r.update(`\0${$(e)}`),r.digest("hex")}function $(e){let t=Wt(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function $e(e,t){if(on(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return w(e,t.file)}function Be(e,t){if(!Y(e))return!1;let r=$t(e);if(!r||r.size!==t.size)return!1;let n=`${e}\0${t.sha256}\0${r.identity}`;if(ee.has(n))return!0;let i=H(e,{inputKind:"immutable SQLite generation artifact",maxBytes:t.size}),o=$t(e);if(!o||o.identity!==r.identity||i!==t.sha256)return!1;for(ee.set(n,!0);ee.size>sn;){let a=ee.keys().next().value;if(a===void 0)break;ee.delete(a)}return!0}function $t(e){let t=Wt(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function pn(e,t){return e.version===ze&&e.identity===t&&We(e.database)&&(e.index===void 0||We(e.index))&&(e.metadata===void 0||We(e.metadata))}function We(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.file=="string"&&!!t.file&&Number.isSafeInteger(t.size)&&(t.size??-1)>=0&&typeof t.sha256=="string"&&/^[a-f0-9]{64}$/.test(t.sha256)}function mn(e){return e.version===N&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&gn(e.stableMirrors)&&yn(e.previousGeneration)&&hn(e.publication)}function gn(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.databaseFileIdentity=="string"&&!!t.databaseFileIdentity&&(t.indexFileIdentity===void 0||typeof t.indexFileIdentity=="string"&&!!t.indexFileIdentity)}function yn(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.generationIdentity=="string"&&!!t.generationIdentity&&typeof t.databasePath=="string"&&!!t.databasePath&&(t.metadataPath===void 0||typeof t.metadataPath=="string"&&!!t.metadataPath)}function hn(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,r=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(n=>n!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&r.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}import{execFileSync as Sn}from"child_process";import{existsSync as In,readdirSync as Yt}from"fs";import{extname as Qt,join as Kt}from"path";var Jt=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),bn=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function ko(e){let t=[],r=xn(e),n=En(e);for(let i of bn){if(wn(e,i.files)){t.push(i.language);continue}if(vn(r,i.globs)){t.push(i.language);continue}Tn(n,i.extensions)&&t.push(i.language)}if(t.includes("typescript")&&He(t,"javascript"),t.includes("cpp")&&t.includes("c")){let i=n.has(".c"),o=[".cc",".cpp",".cxx"].some(a=>n.has(a));i&&!o?He(t,"cpp"):i||He(t,"c")}return t}function xn(e){try{return Yt(e)}catch{return[]}}function wn(e,t){return t?.length?t.some(r=>In(Kt(e,r))):!1}function vn(e,t){return t?.length?e.some(r=>t.some(n=>Rn(r,n))):!1}function Rn(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[r,n]=t.split("*");return e.startsWith(r??"")&&e.endsWith(n??"")}function En(e){let t=Pn(e);if(t)return t;let r=new Set,n=[e];for(;n.length>0;){let i=n.pop();if(!i)continue;let o;try{o=Yt(i,{withFileTypes:!0})}catch{continue}for(let a of o){if(a.name.startsWith(".")&&!a.name.endsWith("proj")&&!a.name.endsWith("sln")&&a.isDirectory())continue;let s=Kt(i,a.name);if(a.isDirectory()){Jt.has(a.name)||n.push(s);continue}let c=Qt(a.name).toLowerCase();c&&r.add(c)}}return r}function Pn(e){try{let t=jt(e,26214400,()=>Sn("git",["-C",e,"ls-files","-co","-v","-z","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:52428800,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"})),r=new Set;for(let n of Nt(t)){if(n.split("/").some(o=>Jt.has(o)))continue;let i=Qt(n).toLowerCase();i&&r.add(i)}return r}catch{return null}}function Tn(e,t){return t?.length?t.some(r=>e.has(r)):!1}function He(e,t){let r=e.indexOf(t);r!==-1&&e.splice(r,1)}import{closeSync as Zt,openSync as kn,renameSync as On,rmSync as Mn,writeSync as Fn}from"fs";import{create as er,fromBinary as _n,toBinary as jn}from"@bufbuild/protobuf";import{DocumentSchema as Ye,IndexSchema as Nn,SymbolRole as Ke}from"@c4312/scip";var E=class extends Error{},Gn=0,Dn=1,Xt=2,An=5;function Ve(e,t,r){let n=0,i=0;for(;t<r;){let o=e[t];if(t+=1,i<53)n+=(o&127)*2**i;else if((o&127)!==0)throw new E("varint exceeds the safe integer range");if((o&128)===0)return{value:n,pos:t};if(i+=7,i>63)throw new E("varint is longer than 64 bits")}throw new E("varint runs past the end of the buffer")}function*P(e,t=0,r=e.length){let n=t;for(;n<r;){let i=n,o=Ve(e,n,r);n=o.pos;let a=Math.floor(o.value/8),s=o.value%8;if(a===0)throw new E("field number 0 is invalid");let c=n,d=0;if(s===Gn){let l=Ve(e,n,r);d=l.value,n=l.pos}else if(s===Xt){let l=Ve(e,n,r);if(c=l.pos,n=l.pos+l.value,n>r)throw new E("length-delimited field runs past the end of the buffer")}else if(s===Dn)n+=8;else if(s===An)n+=4;else throw new E(`unsupported wire type ${s}`);if(n>r)throw new E("field value runs past the end of the buffer");yield{fieldNumber:a,wireType:s,fieldStart:i,valueStart:c,valueEnd:n,fieldEnd:n,varint:d}}}function ie(e){if(!Number.isSafeInteger(e)||e<0)throw new E(`cannot encode varint ${e}`);let t=[],r=e;do{let n=r%128;r=Math.floor(r/128),r>0&&(n|=128),t.push(n)}while(r>0);return Uint8Array.from(t)}function Re(e){return ie(e*8+Xt)}var Cn=1,Ln=3;function oe(e){let t=new TextDecoder,r;for(let n of P(e))if(!(n.fieldNumber!==Cn||n.wireType!==2))for(let i of P(e,n.valueStart,n.valueEnd)){if(i.fieldNumber!==Ln||i.wireType!==2)continue;let o=t.decode(e.subarray(i.valueStart,i.valueEnd));o&&(r=o)}return r}var Qe=2,qn=3,$n=1,Bn=2,Wn=3,zn=1,Un=2,Hn=3;function Bo(e){let t;try{t=I(e,{inputKind:"SCIP sanitization input",maxBytes:S})}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}try{return Vn(t,e)}catch(r){if(r instanceof E)return{removedDefinitionOccurrences:0,touchedDocuments:0};throw r}}function Vn(e,t){let r=new TextDecoder,n=new Set;for(let a of P(e))if(a.wireType===2)if(a.fieldNumber===Qe)for(let s of P(e,a.valueStart,a.valueEnd))s.wireType===2&&(s.fieldNumber===$n?Fe(r.decode(e.subarray(s.valueStart,s.valueEnd))):s.fieldNumber===Wn&&tr(e,s,r,n));else a.fieldNumber===qn&&tr(e,a,r,n);let i=0,o=[];for(let a of P(e)){if(a.wireType!==2||a.fieldNumber!==Qe)continue;let s=Yn(e,a,r,n);s>0&&(i+=s,o.push(a))}return i===0?{removedDefinitionOccurrences:0,touchedDocuments:0}:(Qn(e,t,o,n),{removedDefinitionOccurrences:i,touchedDocuments:o.length})}function tr(e,t,r,n){for(let i of P(e,t.valueStart,t.valueEnd)){if(i.wireType!==2||i.fieldNumber!==zn)continue;let o=r.decode(e.subarray(i.valueStart,i.valueEnd));o&&n.add(o)}}function Yn(e,t,r,n){let i=0;for(let o of P(e,t.valueStart,t.valueEnd)){if(o.wireType!==2||o.fieldNumber!==Bn)continue;let a="",s=0;for(let c of P(e,o.valueStart,o.valueEnd))c.fieldNumber===Un&&c.wireType===2?a=r.decode(e.subarray(c.valueStart,c.valueEnd)):c.fieldNumber===Hn&&c.wireType===0&&(s=c.varint);(s&Ke.Definition)!==0&&!n.has(a)&&(i+=1)}return i}function Qn(e,t,r,n){let i=`${t}.sanitize-tmp`,o=kn(i,"w",384);try{let a=0;for(let s of r){ae(o,e.subarray(a,s.fieldStart));let c=_n(Ye,e.subarray(s.valueStart,s.valueEnd));c.occurrences=c.occurrences.filter(l=>(l.symbolRoles&Ke.Definition)===0||n.has(l.symbol));let d=jn(Ye,c);ae(o,Re(Qe)),ae(o,ie(d.byteLength)),ae(o,d),a=s.fieldEnd}ae(o,e.subarray(a))}catch(a){throw Zt(o),Mn(i,{force:!0}),a}Zt(o),On(i,t)}function ae(e,t){let r=0;for(;r<t.byteLength;)r+=Fn(e,t,r,t.byteLength-r)}function rr(e){let t=new Set;for(let o of e.documents){Fe(o.relativePath);for(let a of o.symbols)a.symbol&&t.add(a.symbol)}for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let r=0,n=0,i=[];for(let o of e.documents){let a=o.occurrences.filter(s=>(s.symbolRoles&Ke.Definition)===0||t.has(s.symbol)?!0:(r+=1,!1));if(a.length===o.occurrences.length){i.push(o);continue}n+=1,i.push(er(Ye,{language:o.language,relativePath:o.relativePath,occurrences:a,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:r===0?e:er(Nn,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:r,touchedDocuments:n}}import{closeSync as ce,openSync as Je,readSync as Kn,renameSync as Jn,rmSync as or,statSync as Xn,writeFileSync as ar,writeSync as sr}from"fs";import{create as Xe,fromBinary as Zn,toBinary as ei}from"@bufbuild/protobuf";import{deserializeSCIP as cr,serializeSCIP as dr,DocumentSchema as ti,IndexSchema as ri,MetadataSchema as nr,SymbolInformationSchema as ni}from"@c4312/scip";function lr(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=ii(e),r=oi(e.flatMap(i=>i.documents??[])),n=fr(e.flatMap(i=>i.externalSymbols??[]));return Xe(ri,{metadata:t,documents:r,externalSymbols:n})}function Jo(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>cr(I(i,{inputKind:"SCIP merge input",maxBytes:S}))),n=lr(r);return ar(t,dr(n)),{documentCount:n.documents.length,externalSymbolCount:n.externalSymbols.length,inputCount:e.length}}function Xo(e,t){if(e.length===0)throw new Error("Cannot concatenate zero SCIP files");let r=0;for(let o of e)if(r+=Xn(o).size,r>S)throw new Error(`Concatenated SCIP output exceeds the ${S}-byte artifact limit. Reduce the indexed project scope or use compatible cached generations.`);let n=Buffer.allocUnsafe(1024*1024),i=Je(t,"w",384);try{for(let o of e){let a=Je(o,"r");try{let s=0;for(;(s=Kn(a,n,0,n.byteLength,null))>0;){let c=0;for(;c<s;)c+=sr(i,n,c,s-c)}}finally{ce(a)}}}catch(o){throw ce(i),or(t,{force:!0}),o}ce(i)}function Zo(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=X("reindex.publish.scip-output.deserialize",()=>e.map(o=>cr(I(o,{inputKind:"SCIP merge input",maxBytes:S})))),n=X("reindex.publish.scip-output.merge",()=>lr(r)),i=X("reindex.publish.scip-output.sanitize",()=>rr(n));return X("reindex.publish.scip-output.serialize",()=>ar(t,dr(i.index))),{documentCount:i.index.documents.length,externalSymbolCount:i.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:i.removedDefinitionOccurrences,touchedDocuments:i.touchedDocuments}}var ir=1;function ur(e,t,r){let n=I(e,{inputKind:"SCIP normalization input",maxBytes:S}),i=oe(n),o=[];for(let c of P(n))c.fieldNumber===ir&&c.wireType===2&&o.push(c);if(o.length===0)throw new Error("Cannot rebase a SCIP index without metadata");if((i??"")!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${i??""}`);let a=`${e}.rebase-tmp`,s=Je(a,"w",384);try{let c=0;for(let d of o){se(s,n.subarray(c,d.fieldStart));let l=Zn(nr,n.subarray(d.valueStart,d.valueEnd));l.projectRoot=r;let f=ei(nr,l);se(s,Re(ir)),se(s,ie(f.byteLength)),se(s,f),c=d.fieldEnd}se(s,n.subarray(c))}catch(c){throw ce(s),or(a,{force:!0}),c}ce(s),Jn(a,e)}function se(e,t){let r=0;for(;r<t.byteLength;)r+=sr(e,t,r,t.byteLength-r)}function ii(e){let t=e[0]?.metadata;if(!t)return;let r=t.projectRoot;for(let n of e.slice(1)){let i=n.metadata?.projectRoot;if(r&&i&&i!==r)throw new Error(`Cannot merge SCIP indexes with different project roots: ${r} vs ${i}`)}return t}function oi(e){let t=new Map;for(let r of e){let n=t.get(r.relativePath);if(!n){t.set(r.relativePath,r);continue}t.set(r.relativePath,Xe(ti,{language:n.language||r.language,relativePath:n.relativePath||r.relativePath,occurrences:ai([...n.occurrences,...r.occurrences]),symbols:fr([...n.symbols,...r.symbols]),text:ci(n.text,r.text),positionEncoding:n.positionEncoding||r.positionEncoding}))}return[...t.values()]}function ai(e){let t=new Set,r=[];for(let n of e){let i=JSON.stringify(n);t.has(i)||(t.add(i),r.push(n))}return r}function fr(e){let t=new Map;for(let r of e){let n=t.get(r.symbol);if(!n){t.set(r.symbol,r);continue}t.set(r.symbol,Xe(ni,{symbol:n.symbol,documentation:di([...n.documentation,...r.documentation]),relationships:si([...n.relationships,...r.relationships]),kind:n.kind||r.kind,displayName:n.displayName||r.displayName,enclosingSymbol:n.enclosingSymbol||r.enclosingSymbol,signatureDocumentation:n.signatureDocumentation??r.signatureDocumentation}))}return[...t.values()]}function si(e){let t=new Set,r=[];for(let n of e){let i=[n.symbol,n.isReference?"1":"0",n.isImplementation?"1":"0",n.isTypeDefinition?"1":"0",n.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),r.push(n))}return r}function ci(e,t){return e?t?e.length>=t.length?e:t:e:t}function di(e){return[...new Set(e)]}import li from"better-sqlite3";var ui=25,fi=new Set(["typescript","javascript"]);function ia(e,t,r){let n=null;try{n=new li(e,{readonly:!0,fileMustExist:!0});let i=new Set(n.prepare("SELECT relative_path FROM documents").pluck().all().map(Me)),o=pi(t,r),a=new Set([...o.values()].flatMap(l=>[...l])),s=[...a].filter(l=>!i.has(l)).sort();if(s.length===0)return{state:"complete",expectedDocumentCount:a.size,actualDocumentCount:i.size};let c=new Set(s),d=r.filter(l=>[...o.get(l)??[]].some(f=>c.has(f)));return{state:"incomplete",expectedDocumentCount:a.size,actualDocumentCount:i.size,missingDocumentCount:s.length,missingPaths:s.slice(0,ui),affectedLanguages:d}}catch(i){return{state:"unavailable",reason:i instanceof Error?i.message:String(i)}}finally{n?.close()}}function pi(e,t){let r=new Map,n=t.filter(i=>fi.has(i));for(let i of n)r.set(i,new Set);for(let i of e.files){let o=Me(i.path);for(let a of n)Gt(o,[a])==="source"&&r.get(a).add(o)}return r}import{existsSync as mr,readdirSync as gr,rmSync as yr}from"fs";import{join as Q}from"path";import{create as Sr,fromBinary as Ir,toBinary as ma}from"@bufbuild/protobuf";import{deserializeSCIP as Ze,DocumentSchema as br,IndexSchema as xr,serializeSCIP as wr}from"@c4312/scip";import{existsSync as mi,mkdirSync as gi,renameSync as yi,writeFileSync as hi}from"fs";import{join as Si}from"path";function pr(e){gi(e.blobDir,{recursive:!0});let t=Si(e.blobDir,`${e.blobHash}.scipdoc`);if(mi(t)){let n=I(t,{maxBytes:J,inputKind:e.inputKind});if(n.byteLength!==e.bytes.byteLength||k(n)!==e.blobHash)throw new Error(`existing ${e.inputKind} is corrupt: ${e.relativePath}`);return}let r=`${t}.${process.pid}.${Date.now()}.tmp`;hi(r,e.bytes),yi(r,t)}var et=1,de="typescript-scip-fragments";function Sa(e){let t=new Set,r=[];for(let o of e){let a=Ee(o.relativePath);if(t.has(a))throw new Error(`duplicate TypeScript fragment replacement: ${a}`);if(t.add(a),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${a}`);let s=Ir(br,o.bytes);if(s.relativePath!==a)throw new Error(`TypeScript fragment path mismatch: expected ${a}, got ${s.relativePath}`);r.push(s)}let n=wr(Sr(xr,{documents:r,externalSymbols:[]})),i=Ze(n);if(i.documents.length!==r.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return n}function Ii(e){let t=Q(e,de);return{rootDir:t,blobDir:Q(t,"blobs"),generationDir:Q(t,"generations")}}function vr(e){let t=bi(e);return xi(t.baseIndex,t.completeDocuments,"assembled")}function bi(e){let t=Ze(e.baseIndexBytes);Ei(t.metadata,Pi(e)),Ri(t.externalSymbols);let r=new Map;for(let s of e.fragments){let c=Ee(s.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);r.set(c,s)}if(r.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let n=new Set,i=[],o=[],a=[];for(let s of t.documents){let c=Ee(s.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);n.add(c);let d=r.get(c);if(!d){i.push(s);continue}if(r.delete(c),d.bytes===null){a.push(c);continue}let l=hr(c,d.bytes);i.push(l),o.push(l)}for(let s of[...r.keys()].sort()){let c=r.get(s);if(c.bytes===null)continue;if(n.has(s))throw new Error(`duplicate TypeScript SCIP document path: ${s}`);n.add(s);let d=hr(s,c.bytes);i.push(d),o.push(d)}return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:a}}function hr(e,t){let r=Ir(br,t);if(r.relativePath!==e)throw new Error(`TypeScript fragment path mismatch: expected ${e}, got ${r.relativePath}`);return r}function xi(e,t,r){let n=wr(Sr(xr,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=Ze(n);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${r} TypeScript SCIP index failed structural verification`);return n}function Ia(e,t){let r=Ii(e);if(!mr(r.generationDir))return;let n=new Set(t.map(a=>vi(a))),i=gr(r.generationDir).filter(a=>a.endsWith(".json")),o=new Set;for(let a of i.filter(s=>n.has(s))){let s=wi(R(Q(r.generationDir,a),{maxBytes:v,inputKind:"TypeScript fragment manifest"}));for(let c of s.documents)o.add(`${c.blobHash}.scipdoc`)}for(let a of i)n.has(a)||yr(Q(r.generationDir,a),{force:!0});if(mr(r.blobDir))for(let a of gr(r.blobDir))o.has(a)||yr(Q(r.blobDir,a),{force:!0})}function wi(e){let t=JSON.parse(e);if(t.version!==et||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let r=new Set;for(let n of t.documents){if(!n||typeof n.relativePath!="string"||typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash)||typeof n.byteLength!="number"||!Number.isInteger(n.byteLength)||n.byteLength<0||typeof n.documentIdentity!="string"||!n.documentIdentity)throw new Error("invalid TypeScript fragment record");if(Ee(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript fragment record");r.add(n.relativePath)}return t}function vi(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${k(e)}.json`}function Ri(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function Ei(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let r=e,n=r.toolInfo??r.tool_info;if(!n||typeof n!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=n;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function Pi(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function Ee(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}import{existsSync as Pe,readdirSync as tt,rmSync as Rr}from"fs";import{join as D}from"path";var Te=1,le="typescript-scip-overlays",Er="typescript-project-v3:";function Ga(e){let t=Tr(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t?.producerIdentity!==void 0&&t.producerIdentity!==e.producerIdentity)throw new Error("TypeScript overlay producer identity changed");let r=e.allowLegacyProjectIdentityMigration===!0&&t!==null&&!t.projectIdentity.startsWith(Er)&&e.projectIdentity.startsWith(Er);if(t&&t.projectIdentity!==e.projectIdentity&&!e.allowProjectIdentityChange&&!r)throw new Error("TypeScript overlay project identity changed");let n=new Map((t?.overlays??[]).map(a=>[a.relativePath,a])),i=new Set;for(let a of e.fragments){let s=it(a.relativePath);if(i.has(s))throw new Error(`duplicate TypeScript overlay: ${s}`);i.add(s),n.set(s,Ti(e.cacheDir,a))}if(i.size===0)throw new Error("TypeScript overlay generation requires affected documents");let o={version:Te,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...n.values()].sort((a,s)=>a.relativePath.localeCompare(s.relativePath))};return Gi(e.cacheDir,o),o}function Da(e){let t=Tr(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let r=t.overlays.map(n=>{if(n.blobHash===null)return{relativePath:n.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=I(D(ue(e.cacheDir),"blobs",`${n.blobHash}.scipdoc`),{maxBytes:J,inputKind:"TypeScript overlay blob"});if(i.byteLength!==n.byteLength||k(i)!==n.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${n.relativePath}`);return{relativePath:n.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return vr({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:r})}function Aa(e,t){let r=ue(e),n=D(r,"generations");if(!Pe(n))return;let i=new Set(t.map(nt)),o=new Set;for(let s of tt(n).filter(c=>i.has(c))){let c=rt(R(D(n,s),{maxBytes:v,inputKind:"TypeScript overlay manifest"}));for(let d of c.overlays)d.blobHash&&o.add(`${d.blobHash}.scipdoc`)}for(let s of tt(n))i.has(s)||Rr(D(n,s),{force:!0});let a=D(r,"blobs");if(Pe(a))for(let s of tt(a))o.has(s)||Rr(D(a,s),{force:!0})}function Tr(e,t){let r=D(ue(e),"generations",nt(t));if(!Pe(r))return null;let n=rt(R(r,{maxBytes:v,inputKind:"TypeScript overlay manifest"}));if(n.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return n}function Ti(e,t){let r=it(t.relativePath);if(t.bytes===null)return{relativePath:r,blobHash:null,byteLength:0};let n=Buffer.from(t.bytes),i=k(n);return pr({blobDir:D(ue(e),"blobs"),blobHash:i,bytes:n,relativePath:r,inputKind:"TypeScript overlay blob"}),{relativePath:r,blobHash:i,byteLength:n.byteLength}}function Gi(e,t){let r=D(ue(e),"generations",nt(t.generationIdentity));if(Pe(r)){let n=rt(R(r,{maxBytes:v,inputKind:"TypeScript overlay manifest"}));if(Pr(n)!==Pr(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}V(r,t,{spacing:2,trailingNewline:!0})}function rt(e){let t=JSON.parse(e);if(t.version!==Te||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let r=new Set;for(let n of t.overlays){if(!n||typeof n.relativePath!="string"||n.blobHash!==null&&(typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash))||!Number.isInteger(n.byteLength)||n.byteLength<0||n.blobHash===null&&n.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(it(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript overlay record");r.add(n.relativePath)}return t}function ue(e){return D(e,le)}function nt(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${k(e)}.json`}function Pr(e){return k(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function it(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}import{createHash as lt}from"crypto";import{closeSync as Di,existsSync as g,mkdirSync as Ai,openSync as Ci,readSync as Li,readdirSync as ut,renameSync as ct,rmSync as fe,statSync as B}from"fs";import{basename as ft,dirname as A,join as p,relative as Gr}from"path";var ki=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function Ar(e){let t=h(e.outputDb),r=ji(e);e.onStage?.("after-recovery-retained");let n=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=Ni(e,r),o=mt({generationRoot:t,databasePath:e.tempOutputDb,indexPath:g(n)?n:void 0,verifiedIndexArtifact:i,metadataPath:g(e.tempMetaPath)?e.tempMetaPath:void 0}),a=(e.now??(()=>new Date))().toISOString(),s={version:N,currentGeneration:o.identity,artifactSet:"immutable-v1",...r?{previousGeneration:r}:{},...e.publication?{publication:e.publication}:{},publishedAt:a},c=G(p(t,"state.json"),s,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||st(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),st(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),st(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let d=o.identity,l={...s,stableMirrors:pt(e.outputDb,e.outputScip)};G(p(t,"state.json"),l,{spacing:2,trailingNewline:!0});let f=Cr(e.outputDb,{now:e.now}),m=Z(o.directorySync,c.directorySync);return{currentGeneration:d,...r?{previousGeneration:r}:{},retention:f,achievedDurability:m==="synced"?"directory-durable":"file-flushed",directorySync:m}}function Oi(e,t,r,n=()=>new Date){if(!g(e))return null;let i=q(e),o=p(h(e),"state.json");if(i?.artifactSet==="immutable-v1"&&re(e,i.currentGeneration))return i;let a=h(e),s=!i&&g(o)?$i(r,e,t):void 0;if(s&&!ne(a,s))return null;let c=mt({generationRoot:a,databasePath:e,indexPath:g(t)?t:void 0,metadataPath:g(r)?r:void 0,forcedIdentity:i?.currentGeneration??s}),d={version:N,currentGeneration:c.identity,artifactSet:"immutable-v1",stableMirrors:pt(e,t),...i?.previousGeneration?{previousGeneration:i.previousGeneration}:{},...i?.publication?{publication:i.publication}:{},publishedAt:i?.publishedAt??n().toISOString()};return G(p(a,"state.json"),d,{spacing:2,trailingNewline:!0}),d}function Ba(e,t,r=()=>new Date){if(!g(e)||!g(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let n=q(e),i=h(e),o=mt({generationRoot:i,databasePath:e,indexPath:g(p(A(e),"index.scip"))?p(A(e),"index.scip"):void 0,metadataPath:t}),a=n&&n.currentGeneration!==o.identity?kr(e,n.currentGeneration):void 0,s={version:N,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:pt(e,p(A(e),"index.scip")),...a?{previousGeneration:a}:{},...n?.publication?{publication:n.publication}:{},publishedAt:r().toISOString()};return G(p(h(e),"state.json"),s,{spacing:2,trailingNewline:!0}),Cr(e,{now:r}),s}function Cr(e,t={}){let r=Mi(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=j(Ue(e),{waitMs:0});if(!o)return{state:"deferred",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:r,at:i,reason:"another process owns local generation retention"};try{let a=q(e),s=Fi(e),c=Ht(e,s.map(x=>x.identity),{isProcessAlive:t.isProcessAlive??be,readProcessIdentity:t.readProcessIdentity??ye}),d=new Set(c.protectedGenerations);a?.currentGeneration&&d.add(a.currentGeneration),a?.previousGeneration?.generationIdentity&&d.add(a.previousGeneration.generationIdentity);let l=s.length,f=s.reduce((x,Oe)=>x+Oe.logicalBytes,0),m=0,T=0;for(let x of s){if(l<=r.maxGenerations&&f<=r.maxLogicalBytes)break;d.has(x.identity)||(t.onBeforeRemove?.(x.identity),fe(x.path,{recursive:!0,force:!0}),l-=1,f-=x.logicalBytes,m+=1,T+=x.logicalBytes)}let y=l>r.maxGenerations||f>r.maxLogicalBytes,L={state:y?"protected":m>0?"collected":"within-bounds",generationCount:l,logicalBytes:f,protectedGenerations:d.size,activeReaderLeases:c.activeLeases,staleReaderLeasesRemoved:c.staleLeasesRemoved,malformedReaderLeases:c.malformedLeases,removedGenerations:m,removedLogicalBytes:T,limits:r,at:i,...y?{reason:c.malformedLeases>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}:{}};return Dr(e,L),L}catch(a){let s={state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:r,at:i,reason:a instanceof Error?a.message:String(a)};try{Dr(e,s)}catch{}return s}finally{o.release()}}function Mi(e={}){let t={...ki,...e};if(!Number.isSafeInteger(t.maxGenerations)||t.maxGenerations<2)throw new Error("Local SQLite generation retention must keep at least current and previous generations.");if(!Number.isSafeInteger(t.maxLogicalBytes)||t.maxLogicalBytes<=0)throw new Error("Local SQLite generation byte retention must be a positive safe integer.");return t}function Fi(e){let t=h(e);return g(t)?ut(t,{withFileTypes:!0}).filter(r=>r.isDirectory()&&/^[a-f0-9]{64}$/.test(r.name)).map(r=>{let n=p(t,r.name),i=ne(t,r.name),o=i?i.database.size+(i.index?.size??0)+(i.metadata?.size??0):Lr(n);return{identity:r.name,path:n,logicalBytes:o,modifiedAtMs:B(n).mtimeMs}}).sort((r,n)=>r.modifiedAtMs-n.modifiedAtMs||r.identity.localeCompare(n.identity)):[]}function Lr(e){let t=0;for(let r of ut(e,{withFileTypes:!0})){let n=p(e,r.name);r.isDirectory()?t+=Lr(n):r.isFile()&&(t+=B(n).size)}return t}function Dr(e,t){V(p(h(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function De(e,t=p(A(e),"meta.json")){let r=p(h(e),"state.json");if(!g(r))return{state:"legacy",statePath:r};let n=q(e);if(!n)return{state:"invalid",statePath:r,reason:"generation state is malformed"};try{let i=re(e,n.currentGeneration),o=i!==null,a=i?_i(e,t,i,n):!1,s=n.previousGeneration?g(p(A(e),n.previousGeneration.databasePath)):!0;return!a||!o||!s?{state:"drifted",statePath:r,currentMatches:a,recoveryExists:s,generation:n,reason:o?a?"retained recovery database is missing":"stable database or metadata no longer matches the published generation":"published immutable generation is missing"}:{state:"current",statePath:r,currentMatches:a,recoveryExists:s,generation:n}}catch(i){return{state:"drifted",statePath:r,currentMatches:!1,recoveryExists:!1,generation:n,reason:i instanceof Error?i.message:String(i)}}}function _i(e,t,r,n){if(n.stableMirrors&&(n.stableMirrors.databaseFileIdentity!==$(e)||n.stableMirrors.indexFileIdentity!==void 0&&n.stableMirrors.indexFileIdentity!==$(p(A(e),"index.scip")))||!dt(e,r.database))return!1;let i=p(A(e),"index.scip");if(r.index&&!dt(i,r.index))return!1;if(!r.metadata)return!g(t);if(!g(t))return!1;let o=p(h(e),r.identity,r.metadata.file);return g(o)&&M(b(t,"reindex metadata"))===M(b(o,"immutable reindex metadata"))}function dt(e,t){return g(e)&&B(e).isFile()&&B(e).size===t.size}function ji(e){let t=Oi(e.outputDb,e.outputScip,e.metaPath);return t?kr(e.outputDb,t.currentGeneration):void 0}function Ni(e,t){if(!e.preserveOutputScip)return;if(!t)throw new Error("deferred SCIP publication requires an accepted immutable generation");let r=De(e.outputDb,e.metaPath);if(r.state!=="current"||r.generation.currentGeneration!==t.generationIdentity){let i=r.state==="current"?"generation identity changed":"reason"in r?r.reason:`generation state is ${r.state}`;throw new Error(`deferred SCIP publication requires a verified accepted companion: ${i}`)}let n=re(e.outputDb,t.generationIdentity);if(!n?.index||!dt(e.outputScip,n.index))throw new Error("deferred SCIP publication requires the verified accepted index artifact");return n.index}function pt(e,t){return{databaseFileIdentity:$(e),...g(t)?{indexFileIdentity:$(t)}:{}}}function kr(e,t){let r=p(h(e),t),n=p(r,ft(e)),i=p(r,"meta.json");return{generationIdentity:t,databasePath:Gr(A(e),n),...g(i)?{metadataPath:Gr(A(e),i)}:{}}}function qi(e){if(g(e))for(let t of ut(e,{withFileTypes:!0}))t.isDirectory()&&t.name.endsWith(".tmp")&&fe(p(e,t.name),{recursive:!0,force:!0})}function $i(e,t,r=p(A(t),"index.scip")){let n=lt("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(Ge(t)),g(r)&&n.update(`\0${Ge(r)}`),g(e)&&n.update(`\0${M(b(e,"reindex metadata"))}`),n.digest("hex")}function mt(e){let t=ot(e.databasePath),r=e.indexPath?e.verifiedIndexArtifact?Wi(e.indexPath,e.verifiedIndexArtifact):ot(e.indexPath):void 0,n=e.metadataPath?ot(e.metadataPath):void 0,i=e.forcedIdentity??Bi(t,r,e.metadataPath),o=p(e.generationRoot,i),a=p(o,ve);if(g(a)){let d=ne(e.generationRoot,i);if(d&&Or(o,d.database,t)&&Ui(o,d.index,r)&&Hi(o,d.metadata,e.metadataPath))return{identity:i,directorySync:O(e.generationRoot)};throw new Error(`SQLite generation ${i} already exists with different or corrupt artifacts.`)}let s=[Ie(e.generationRoot)];qi(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;fe(c,{recursive:!0,force:!0}),Ai(c,{recursive:!0});try{s.push(at(e.databasePath,p(c,t.file))),r&&e.indexPath&&s.push(at(e.indexPath,p(c,r.file))),n&&e.metadataPath&&s.push(at(e.metadataPath,p(c,n.file)));let d=G(p(c,ve),{version:ze,identity:i,database:t,...r?{index:r}:{},...n?{metadata:n}:{}},{spacing:2,trailingNewline:!0});d.directorySync!=="not-requested"&&s.push(d.directorySync),s.push(O(c)),ct(c,o),s.push(O(e.generationRoot))}finally{fe(c,{recursive:!0,force:!0})}return{identity:i,directorySync:Z(...s)}}function Bi(e,t,r){let n=lt("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(e.sha256),t&&n.update(`\0${t.sha256}`),r&&n.update(`\0${M(b(r,"reindex metadata"))}`),n.digest("hex")}function ot(e){return{file:ft(e),size:B(e).size,sha256:Ge(e)}}function Wi(e,t){if(t.file!==ft(e)||B(e).size!==t.size)throw new Error(`verified SQLite generation artifact changed before publication: ${e}`);return t}function Ge(e){let t=lt("sha256"),r=Ci(e,"r"),n=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=zi(r,n);if(i===0)break;t.update(n.subarray(0,i))}}finally{Di(r)}return t.digest("hex")}function zi(e,t){let r=0;for(;r<t.length;){let n=Li(e,t,r,t.length-r,null);if(r+=n,n===0)break}return r}function at(e,t){return xe(e,t,{mode:292})}function Or(e,t,r){let n=p(e,t.file);return t.file===r.file&&t.size===r.size&&t.sha256===r.sha256&&g(n)&&B(n).size===t.size&&Ge(n)===t.sha256}function Ui(e,t,r){return!t||!r?t===r:Or(e,t,r)}function Hi(e,t,r){if(!t||!r)return t===void 0&&r===void 0;let n=p(e,t.file);return g(n)&&M(b(n,"stored reindex metadata"))===M(b(r,"candidate reindex metadata"))}function st(e,t){fe(`${t}.tmp-replace`,{force:!0}),ct(e,`${t}.tmp-replace`),ct(`${t}.tmp-replace`,t)}import{createHash as Wr,randomUUID as Zi}from"crypto";import{existsSync as _,lstatSync as ht,mkdirSync as K,mkdtempSync as zr,readdirSync as Ur,realpathSync as Hr,renameSync as z,rmSync as F,statSync as ke}from"fs";import{dirname as St,join as u,resolve as W}from"path";import{setTimeout as eo}from"timers/promises";import{pathToFileURL as jr}from"url";import to from"better-sqlite3";import{lstatSync as Vi,readdirSync as Yi}from"fs";import{join as Qi,relative as Ki,resolve as gt,sep as Ji}from"path";var pe=1,yt="language-indexes",Mr=["index.db","index.scip","meta.json"],Fr=[yt,de,le];function Ae(e){let t=[];for(let r of Mr)Xi(e,r),t.push(r);for(let r of Fr)_r(e,r,t);return{version:pe,files:t.sort()}}function Ce(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(n=>!n||n==="."||n===".."))throw new Error(`invalid index artifact path: ${e}`);let r=t[0];if(!Mr.includes(e)&&!Fr.includes(r))throw new Error(`index artifact path is not shareable: ${e}`);return e}function C(e,t){let r=Ce(t),n=gt(e),i=gt(n,...r.split("/"));if(i!==n&&!i.startsWith(`${n}${Ji}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function _r(e,t,r){let n=Qi(e,t),i;try{i=Yi(n,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let a=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${a}`);o.isDirectory()?_r(e,a,r):o.isFile()&&r.push(Ce(a))}}function Xi(e,t){let r=C(e,t),n;try{n=Vi(r)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!n.isFile()||n.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(Ki(gt(e),r).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var It=1,Nr="SCIP_QUERY_SHARED_CACHE",ro=2,Le=JSON.stringify({cliVersion:kt,artifactCatalogVersion:pe,postIndexAugmentationSchemaVersion:ro,sqliteGenerationStoreVersion:N,typescriptFragmentStoreVersion:et,typescriptOverlayStoreVersion:Te}),bt="manifest.json",Vr="shared-cache.json";var xt=[yt,de,le];function no(e,t){if(!e.clean||!e.treeOid)return;let r=Zr(JSON.stringify({version:It,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:At(t),producerIdentity:Le}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:Le,generationId:r,repositoryCacheDir:_e(e.repositoryId)}}function xs(e,t,r){if(!go(r))return!1;let n=no(e,r);if(!n)return!1;try{let i=lo(t);if(!i||i.repositoryId!==e.repositoryId||i.worktreeId!==e.worktreeId)return!1;let o=JSON.parse(R(u(n.repositoryCacheDir,"worktrees",`${i.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:v}));return o.version!==1||o.repositoryId!==i.repositoryId||o.worktreeId!==i.worktreeId||W(o.projectRoot)!==W(e.projectRoot)||o.treeOid!==e.treeOid||W(o.localCacheDir)!==W(t)||o.ownershipChecksum!==wt(o)||o.baseGenerationId!==n.generationId||o.activeGenerationId!==n.generationId?!1:U(n,!1)!==null}catch{return!1}}function ws(e,t,r){if(process.env[Nr]==="0")return`${Nr}=0`;if(!je(r))return"explicit cache or database override";if(Ne(St(t))!==Ne(Mt(e))||t!==u(St(t),"index.db"))return"index database is outside the managed worktree cache"}function vs(e,t,r){if(!je(t))return;let n=r??qt(e);return n?u(_e(n.repositoryId),"evidence.db"):void 0}function U(e,t=!0){let r=vt(e),n;try{n=Yr(R(u(r,bt),{inputKind:"shared-generation manifest",maxBytes:v}))}catch{return null}if(n.generationId!==e.generationId||n.repositoryId!==e.repositoryId||n.treeOid!==e.treeOid||n.producerIdentity!==e.producerIdentity||!he(n.fingerprint,e.fingerprint)||!so(r))return null;if(!t)return n;try{for(let i of n.artifacts){let o=C(r,i.path),a=ke(o);if(!a.isFile()||a.size!==i.size||H(o,{inputKind:"shared-generation artifact",maxBytes:S})!==i.sha256)return null}}catch{return null}return n}function Rs(e,t,r,n){if(!e.treeOid)return null;let i=qe(t,r),o=u(Ot(),"repositories",e.repositoryId),a;try{let d=ht(o);if(!d.isDirectory()||d.isSymbolicLink())return null;a=Hr(o)}catch{return null}let s=u(a,"generations"),c=[];try{for(let d of Ur(s)){if(!/^[a-f0-9]{64}$/.test(d))continue;let l=u(s,d),f;try{f=ht(l)}catch{continue}if(!(!f.isDirectory()||f.isSymbolicLink()))try{let m=Yr(R(u(l,bt),{inputKind:"shared-generation baseline manifest",maxBytes:v}));m.generationId===d&&m.repositoryId===e.repositoryId&&m.producerIdentity===Le&&co(m.fingerprint,i)&&c.push(m)}catch{continue}}}catch{return null}c.sort((d,l)=>{let f=d.treeOid===e.treeOid?0:1,m=l.treeOid===e.treeOid?0:1;if(f!==m)return f-m;if(n){let y=Br(d.fingerprint,n)-Br(l.fingerprint,n);if(y!==0)return y}return Date.parse(l.createdAt)-Date.parse(d.createdAt)||d.generationId.localeCompare(l.generationId)});for(let d of c){let l={repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:d.treeOid,fingerprint:d.fingerprint,producerIdentity:d.producerIdentity,generationId:d.generationId,repositoryCacheDir:a},f=U(l);if(f)return{snapshot:l,manifest:f}}return null}function Es(e){let t=j(u(e.snapshot.repositoryCacheDir,"locks",`${e.snapshot.generationId}.publish.lock`));if(!t)throw new Error(`shared generation publication is already in progress for ${e.snapshot.generationId}`);try{return io(e)}finally{t.release()}}function io(e){let t=U(e.snapshot);if(t)return qr(e.snapshot,t);if(!Xr(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let r=$r(e.sourceCacheDir);if(!r)throw new Error("source index artifacts are incomplete");let n=Ae(e.sourceCacheDir),i=u(e.snapshot.repositoryCacheDir,"generations"),o=[Ie(i)],a=zr(u(i,`.tmp-${process.pid}-`));try{let s=[];for(let y of n.files){let L=C(e.sourceCacheDir,y),x=C(a,y);o.push(ge(L,x,292)),e.onPublicationStage?.("after-artifact-flushed",y);let Oe=ke(x).size;s.push({path:y,size:Oe,sha256:H(x,{inputKind:"staged shared-generation artifact",maxBytes:S})})}let c=oe(I(u(a,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:S}));if(!c)throw new Error("shared SCIP generation has no project root metadata");let d=Rt(e.sourceProjectRoot);if(c!==d)throw new Error("shared SCIP generation root does not match its source worktree");if($r(e.sourceCacheDir)!==r||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let l={version:It,artifactCatalogVersion:pe,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:c,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:s.sort((y,L)=>y.path.localeCompare(L.path))},f=G(u(a,bt),l,{spacing:2,trailingNewline:!0});f.directorySync!=="not-requested"&&o.push(f.directorySync),e.onPublicationStage?.("after-manifest-flushed"),o.push(O(a)),e.onPublicationStage?.("after-staging-directory-synced");let m=vt(e.snapshot);try{if(_(m)&&!U(e.snapshot)){let y=`${m}.corrupt-${process.pid}-${Date.now()}`;z(m,y),F(y,{recursive:!0,force:!0})}z(a,m)}catch(y){let L=U(e.snapshot);if(L)return qr(e.snapshot,L);throw y}e.onPublicationStage?.("after-generation-renamed"),o.push(O(i)),e.onPublicationStage?.("after-generations-directory-synced");let T=Z(...o);return{kind:"published",manifest:l,achievedDurability:T==="synced"?"directory-durable":"file-flushed",directorySync:T}}finally{F(a,{recursive:!0,force:!0})}}function qr(e,t){let r=O(u(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:r==="synced"?"directory-durable":"file-flushed",directorySync:r}}function Ps(e){let t=vt(e.snapshot);K(e.targetCacheDir,{recursive:!0});let r=j(u(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:e.lockWaitMs??3e4});if(!r)throw new Error("timed out waiting for another cache hydration");let n,i,o=!1;try{n=zr(u(e.targetCacheDir,".shared-hydrate-")),mo(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let d=C(t,c.path),l=C(n,c.path);if(ge(d,l),ke(l).size!==c.size||H(l,{inputKind:"hydrated shared-generation artifact",maxBytes:S})!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let a=Rt(e.targetProjectRoot);if(a!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&ur(C(n,c.path),e.manifest.scipProjectRoot,a);if(!Xr(n,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=uo(e.targetCacheDir,n),o=!0,fo(n,e.targetCacheDir,i),Ar({tempOutputScip:u(n,"index.scip"),tempOutputDb:u(n,"index.db"),tempMetaPath:u(n,"meta.json"),outputScip:u(e.targetCacheDir,"index.scip"),outputDb:u(e.targetCacheDir,"index.db"),metaPath:u(e.targetCacheDir,"meta.json"),now:e.now});let s=De(u(e.targetCacheDir,"index.db"),u(e.targetCacheDir,"meta.json"));if(s.state==="invalid"||s.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${s.reason}`);e.persistLease!==!1&&oo(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(a){throw o&&i&&po(e.targetCacheDir,i),a}finally{n&&F(n,{recursive:!0,force:!0}),r.release()}}async function Ts(e,t={}){let r=t.timeoutMs??3e4,n=t.pollMs??100,i=t.now??Lt,o=i()+r,a=u(e.repositoryCacheDir,"locks"),s=u(a,`${e.generationId}.lock`),c=d=>{if(!d||typeof d!="object"||Array.isArray(d))return null;let l=d.pid;return typeof l=="number"&&Number.isSafeInteger(l)&&l>0?{pid:l}:null};for(;i()<=o;){if(U(e))return{kind:"generation-ready"};let d=Ft(s,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:c});if(d.kind==="acquired")return{kind:"owner",release:()=>d.lock.release()};let l=o-i();if(l<=0)break;await eo(Math.min(n,l))}return U(e)?{kind:"generation-ready"}:{kind:"timeout"}}function oo(e,t,r,n=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:r,lastSeenAt:(n??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:wt(i)};return Kr(e.repositoryCacheDir,o,!0),o}function Gs(e,t,r=void 0){let n={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,lastAction:"overlay",lastReason:`private cache forked from shared baseline ${e.generationId}`,lastSeenAt:(r??(()=>new Date))().toISOString()},i={...n,ownershipChecksum:wt(n)};return Kr(e.repositoryCacheDir,i,!0),i}function wt(e){return Zr(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:W(e.projectRoot),localCacheDir:W(e.localCacheDir)}))}function Yr(e){let t=JSON.parse(e);if(t.version!==It||t.artifactCatalogVersion!==pe||typeof t.generationId!="string"||!/^[a-f0-9]{64}$/.test(t.generationId)||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.treeOid!="string"||!t.treeOid||typeof t.producerIdentity!="string"||t.producerIdentity!==Le||typeof t.sourceProjectRoot!="string"||typeof t.scipProjectRoot!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!t.fingerprint||!Array.isArray(t.artifacts))throw new Error("invalid shared generation manifest");let r=new Set;for(let n of t.artifacts){if(!n||typeof n.path!="string"||typeof n.size!="number"||n.size<0||typeof n.sha256!="string"||!/^[a-f0-9]{64}$/.test(n.sha256))throw new Error("invalid shared generation artifact");if(Ce(n.path),r.has(n.path))throw new Error(`duplicate shared generation artifact: ${n.path}`);r.add(n.path)}for(let n of["index.db","index.scip","meta.json"])if(!r.has(n))throw new Error(`shared generation is missing ${n}`);return t}function ge(e,t,r=384){return xe(e,t,{mode:r})}function ao(e,t,r){K(e,{recursive:!0}),G(u(e,Vr),{version:1,repositoryId:t,worktreeId:r},{spacing:2,trailingNewline:!0})}function $r(e){try{let t=Ae(e),r=Wr("sha256");for(let n of t.files){let i=C(e,n),o=ke(i).size;r.update(n).update("\0").update(String(o)).update("\0"),Et(i,{inputKind:"source-generation artifact",maxBytes:S},a=>r.update(a)),r.update("\0")}return r.digest("hex")}catch{return null}}function Qr(e){try{let t=Se(R(u(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:v}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function so(e){return Qr(e)?.scipCompanion!=="deferred"}function co(e,t){let r=qe(e.languages,e);return JSON.stringify(r)===JSON.stringify(t)}function Br(e,t){let r=new Map(e.files.map(o=>[o.path,`${o.size}\0${o.hash}`])),n=new Map(t.files.map(o=>[o.path,`${o.size}\0${o.hash}`])),i=0;for(let[o,a]of r)n.get(o)!==a&&(i+=1);for(let o of n.keys())r.has(o)||(i+=1);return i}function vt(e){return u(e.repositoryCacheDir,"generations",e.generationId)}function lo(e){let t=JSON.parse(R(u(e,Vr),{inputKind:"worktree cache pointer",maxBytes:v}));return t.version!==1||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.worktreeId!="string"||!/^[a-f0-9]{24}$/.test(t.worktreeId)?null:{version:t.version,repositoryId:t.repositoryId,worktreeId:t.worktreeId}}function Kr(e,t,r){let n=_t(e,{waitMs:5e3});if(!n)throw new Error("repository cache cleanup is busy");try{if(r){let o=t.activeGenerationId??t.baseGenerationId;if(!o||!_(u(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=u(e,"worktrees");K(i,{recursive:!0}),G(u(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),ao(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{n.release()}}function uo(e,t){let r=u(t,".rollback"),n=new Map,i=new Map;K(r,{recursive:!0});for(let s of["index.scip","index.db","meta.json"]){let c=u(e,s),d=_(c);n.set(s,d),d&&ge(c,u(r,"stable",s))}for(let s of xt){let c=u(e,s),d=_(c);if(d){let l=ht(c);if(!l.isDirectory()||l.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${s}`)}i.set(s,d)}let o=u(e,te),a=_(o);return a&&Jr(o,u(r,"sqlite-generations")),{root:r,stableFiles:n,managedDirectories:i,generationStoreExisted:a}}function fo(e,t,r){for(let n of xt){let i=u(t,n);if(r.managedDirectories.get(n)){let a=u(r.root,"managed",n);K(St(a),{recursive:!0}),z(i,a)}let o=u(e,n);_(o)&&z(o,i)}}function po(e,t){for(let i of xt){let o=u(e,i),a=u(t.root,"managed",i);t.managedDirectories.get(i)?_(a)&&(F(o,{recursive:!0,force:!0}),z(a,o)):F(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let a=u(e,i);if(!o){F(a,{force:!0});continue}let s=`${a}.shared-restore-${Zi()}`;ge(u(t.root,"stable",i),s),F(a,{force:!0}),z(s,a)}let r=u(e,te);F(r,{recursive:!0,force:!0});let n=u(t.root,"sqlite-generations");t.generationStoreExisted&&_(n)&&z(n,r)}function Jr(e,t){K(t,{recursive:!0});for(let r of Ur(e,{withFileTypes:!0})){let n=u(e,r.name),i=u(t,r.name);if(r.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${n}`);r.isDirectory()?Jr(n,i):r.isFile()&&ge(n,i)}}function mo(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||!he(e.fingerprint,t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function Xr(e,t,r,n=!0,i=!0){try{let o=Qr(e);if(!o||o.scipCompanion==="deferred"||!he(Dt(o.fingerprint),r)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...r.languages].sort()))return me("source validation rejected metadata"),!1;let a=Ae(e),s=De(u(e,"index.db"),u(e,"meta.json"));if(n?s.state!=="current":s.state==="invalid"||s.state==="drifted")return me(`source validation rejected SQLite generation state ${s.state}`),!1;let c=new to(u(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let d=Rt(t),f=(i?a.files.filter(m=>m.endsWith(".scip")):["index.scip"]).every(m=>{let T=oe(I(C(e,m),{inputKind:"shared SCIP validation artifact",maxBytes:S}));return T!==d&&me(`source validation rejected SCIP root for ${m}: ${String(T)}`),T===d});return f||me("source validation rejected SCIP project roots"),f}catch(o){return me(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function me(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function Rt(e){try{return jr(Hr(e)).href}catch{return jr(W(e)).href}}function go(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===3&&Array.isArray(t.languages)&&typeof t.pnpmWorkspaces=="boolean"&&(t.typescriptProjectMode==="single"||t.typescriptProjectMode==="workspace")&&Array.isArray(t.typescriptProjects)&&Array.isArray(t.files)&&t.files.every(r=>r!==null&&typeof r=="object"&&typeof r.path=="string"&&typeof r.size=="number"&&typeof r.hash=="string"&&(r.semanticHash===void 0||typeof r.semanticHash=="string"))}function Zr(e){return Wr("sha256").update(e).digest("hex")}export{Po as a,ln as b,To as c,$ as d,ko as e,P as f,ie as g,Re as h,Bo as i,Jo as j,Xo as k,Zo as l,ia as m,Sa as n,Ia as o,Ga as p,Da as q,Aa as r,Ar as s,Oi as t,Ba as u,De as v,no as w,xs as x,ws as y,vs as z,U as A,Rs as B,Es as C,Ps as D,Ts as E,oo as F,Gs as G,wt as H};
2
- //# sourceMappingURL=chunk-IZDPJ2QI.js.map
1
+ import{c as _t,d as j}from"./chunk-WYPL7GF7.js";import{b as k}from"./chunk-ATXPTSEI.js";import{d as Se,f as Ct}from"./chunk-CKBUBRYD.js";import{b as Ft}from"./chunk-3AF4TUFK.js";import{a as xe,b as V,c as G}from"./chunk-T3CZAZSI.js";import{a as be}from"./chunk-B3PYOSCX.js";import{e as X}from"./chunk-HGFDYOVB.js";import{a as Pt,b as Tt,c as ye,d as Lt}from"./chunk-JFMEXGFE.js";import{B as Ne,D as jt,E as Nt,G as qt,a as Gt,c as Dt,d as At,e as he,ha as qe,j as Ie,k as O,l as Z,n as Me,r as Fe,s as kt,v as Ot,w as Mt,x as _e,y as je}from"./chunk-7HXT6YLU.js";import{a as v,b as J,c as S,f as I,g as R,h as b,k as Et,l as H}from"./chunk-7F45LJKI.js";import{createHash as en,randomUUID as tn}from"crypto";import{existsSync as Y,mkdirSync as rn,readdirSync as nn,rmSync as Bt,statSync as Wt}from"fs";import{basename as on,dirname as we,join as w}from"path";var N=1,ze=1,te=".scipquery-generations",ve="manifest.json",zt="readers",an="gc.lock",sn=128,ee=new Map,Ut={pid:process.pid,now:()=>new Date,randomToken:()=>tn(),isProcessAlive:be,readProcessIdentity:ye};function h(e){return w(we(e),te)}function Ue(e){return w(h(e),an)}function Po(e,t=Ut){let r=j(Ue(e.dbPath),{waitMs:5e3,directoryDurability:"recoverable"});if(!r)throw new Error("SQLite generation retention is busy; retry opening the index.");let n;try{let i=ln(e);if(i.source!=="immutable")return{generation:i,release(){}};let o=t.randomToken();if(!/^[A-Za-z0-9._-]+$/.test(o))throw new Error("SQLite generation reader token is unsafe.");let a=w(h(e.dbPath),zt);rn(a,{recursive:!0}),n=w(a,`${t.pid}-${o}.json`);let s=t.readProcessIdentity(t.pid);V(n,{version:1,token:o,generationIdentity:i.identity,pid:t.pid,...s?{processIdentity:s}:{},acquiredAt:t.now().toISOString()},{spacing:2,trailingNewline:!0});let c=!1;return{generation:i,release(){c||!n||(c=!0,Bt(n,{force:!0}))}}}finally{r.release()}}function Ht(e,t,r=Ut,n={}){let i=w(h(e),zt);if(!Y(i))return{protectedGenerations:new Set,activeLeases:0,staleLeasesRemoved:0,malformedLeases:0};let o=new Set,a=0,s=0,c=0;for(let d of nn(i,{withFileTypes:!0})){if(!d.isFile()||!d.name.endsWith(".json"))continue;let l=w(i,d.name),f;try{f=cn(JSON.parse(b(l,"SQLite generation reader lease")))}catch{f=null}if(!f){c+=1;for(let m of t)o.add(m);continue}if(!dn(f,r)){n.removeStale!==!1&&(Bt(l,{force:!0}),s+=1);continue}a+=1,o.add(f.generationIdentity)}return{protectedGenerations:o,activeLeases:a,staleLeasesRemoved:s,malformedLeases:c}}function cn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=t.processIdentity===void 0?null:Pt(t.processIdentity);return t.version!==1||typeof t.token!="string"||t.token.trim()===""||typeof t.generationIdentity!="string"||!/^[a-f0-9]{64}$/.test(t.generationIdentity)||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.acquiredAt!="string"||!Number.isFinite(Date.parse(t.acquiredAt))||t.processIdentity!==void 0&&(!r||r.pid!==t.pid)?null:{version:1,token:t.token,generationIdentity:t.generationIdentity,pid:t.pid,...r?{processIdentity:r}:{},acquiredAt:t.acquiredAt}}function dn(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let r=t.readProcessIdentity(e.pid);return r===null||Tt(e.processIdentity,r)}function q(e){try{let t=JSON.parse(b(w(h(e),"state.json"),"SQLite generation state"));return mn(t)?t:null}catch{return null}}function re(e,t){return ne(h(e),t)}function ne(e,t){try{let r=JSON.parse(b(w(e,t,ve),"SQLite generation manifest"));return pn(r,t)?r:null}catch{return null}}function ln(e){let t=q(e.dbPath);if(t){let r=un(e,t.currentGeneration);if(r)return r;if(t.artifactSet==="immutable-v1")throw new Error(`Published SQLite generation ${t.currentGeneration} is missing or invalid.`)}if(Y(w(we(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return fn(e,t?.currentGeneration)}function To(e){let t=q(e);if(t)return t.currentGeneration;try{let r=w(we(e),"meta.json"),n=Y(r)?b(r,"reindex metadata"):void 0;return Vt(e,n)}catch{return null}}function M(e){return Ct(Se(e))??e}function un(e,t){try{let r=w(h(e.dbPath),t),n=re(e.dbPath,t);if(!n)return null;let i=$e(r,n.database),o=n.index?$e(r,n.index):void 0,a=n.metadata?$e(r,n.metadata):void 0;return!Be(i,n.database)||n.index&&(!o||!Be(o,n.index))||n.metadata&&(!a||!Be(a,n.metadata))?null:{identity:t,databasePath:i,...o?{indexPath:o}:{},...a?{metadataPath:a,metadataRaw:b(a,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function fn(e,t){let r=$(e.dbPath),n=w(we(e.dbPath),"meta.json"),i=Y(n)?b(n,"reindex metadata"):void 0,o=Y(e.indexPath)?e.indexPath:void 0;return{identity:t??Vt(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:n,metadataRaw:i},source:"legacy",databaseFileIdentity:r}}function Vt(e,t){let r=en("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&r.update(M(t)),r.update(`\0${$(e)}`),r.digest("hex")}function $(e){let t=Wt(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function $e(e,t){if(on(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return w(e,t.file)}function Be(e,t){if(!Y(e))return!1;let r=$t(e);if(!r||r.size!==t.size)return!1;let n=`${e}\0${t.sha256}\0${r.identity}`;if(ee.has(n))return!0;let i=H(e,{inputKind:"immutable SQLite generation artifact",maxBytes:t.size}),o=$t(e);if(!o||o.identity!==r.identity||i!==t.sha256)return!1;for(ee.set(n,!0);ee.size>sn;){let a=ee.keys().next().value;if(a===void 0)break;ee.delete(a)}return!0}function $t(e){let t=Wt(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function pn(e,t){return e.version===ze&&e.identity===t&&We(e.database)&&(e.index===void 0||We(e.index))&&(e.metadata===void 0||We(e.metadata))}function We(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.file=="string"&&!!t.file&&Number.isSafeInteger(t.size)&&(t.size??-1)>=0&&typeof t.sha256=="string"&&/^[a-f0-9]{64}$/.test(t.sha256)}function mn(e){return e.version===N&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&gn(e.stableMirrors)&&yn(e.previousGeneration)&&hn(e.publication)}function gn(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.databaseFileIdentity=="string"&&!!t.databaseFileIdentity&&(t.indexFileIdentity===void 0||typeof t.indexFileIdentity=="string"&&!!t.indexFileIdentity)}function yn(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.generationIdentity=="string"&&!!t.generationIdentity&&typeof t.databasePath=="string"&&!!t.databasePath&&(t.metadataPath===void 0||typeof t.metadataPath=="string"&&!!t.metadataPath)}function hn(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,r=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(n=>n!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&r.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}import{execFileSync as Sn}from"child_process";import{existsSync as In,readdirSync as Yt}from"fs";import{extname as Qt,join as Kt}from"path";var Jt=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),bn=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function ko(e){let t=[],r=xn(e),n=En(e);for(let i of bn){if(wn(e,i.files)){t.push(i.language);continue}if(vn(r,i.globs)){t.push(i.language);continue}Tn(n,i.extensions)&&t.push(i.language)}if(t.includes("typescript")&&He(t,"javascript"),t.includes("cpp")&&t.includes("c")){let i=n.has(".c"),o=[".cc",".cpp",".cxx"].some(a=>n.has(a));i&&!o?He(t,"cpp"):i||He(t,"c")}return t}function xn(e){try{return Yt(e)}catch{return[]}}function wn(e,t){return t?.length?t.some(r=>In(Kt(e,r))):!1}function vn(e,t){return t?.length?e.some(r=>t.some(n=>Rn(r,n))):!1}function Rn(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[r,n]=t.split("*");return e.startsWith(r??"")&&e.endsWith(n??"")}function En(e){let t=Pn(e);if(t)return t;let r=new Set,n=[e];for(;n.length>0;){let i=n.pop();if(!i)continue;let o;try{o=Yt(i,{withFileTypes:!0})}catch{continue}for(let a of o){if(a.name.startsWith(".")&&!a.name.endsWith("proj")&&!a.name.endsWith("sln")&&a.isDirectory())continue;let s=Kt(i,a.name);if(a.isDirectory()){Jt.has(a.name)||n.push(s);continue}let c=Qt(a.name).toLowerCase();c&&r.add(c)}}return r}function Pn(e){try{let t=jt(e,26214400,()=>Sn("git",["-C",e,"ls-files","-co","-v","-z","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:52428800,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"})),r=new Set;for(let n of Nt(t)){if(n.split("/").some(o=>Jt.has(o)))continue;let i=Qt(n).toLowerCase();i&&r.add(i)}return r}catch{return null}}function Tn(e,t){return t?.length?t.some(r=>e.has(r)):!1}function He(e,t){let r=e.indexOf(t);r!==-1&&e.splice(r,1)}import{closeSync as Zt,openSync as kn,renameSync as On,rmSync as Mn,writeSync as Fn}from"fs";import{create as er,fromBinary as _n,toBinary as jn}from"@bufbuild/protobuf";import{DocumentSchema as Ye,IndexSchema as Nn,SymbolRole as Ke}from"@c4312/scip";var E=class extends Error{},Gn=0,Dn=1,Xt=2,An=5;function Ve(e,t,r){let n=0,i=0;for(;t<r;){let o=e[t];if(t+=1,i<53)n+=(o&127)*2**i;else if((o&127)!==0)throw new E("varint exceeds the safe integer range");if((o&128)===0)return{value:n,pos:t};if(i+=7,i>63)throw new E("varint is longer than 64 bits")}throw new E("varint runs past the end of the buffer")}function*P(e,t=0,r=e.length){let n=t;for(;n<r;){let i=n,o=Ve(e,n,r);n=o.pos;let a=Math.floor(o.value/8),s=o.value%8;if(a===0)throw new E("field number 0 is invalid");let c=n,d=0;if(s===Gn){let l=Ve(e,n,r);d=l.value,n=l.pos}else if(s===Xt){let l=Ve(e,n,r);if(c=l.pos,n=l.pos+l.value,n>r)throw new E("length-delimited field runs past the end of the buffer")}else if(s===Dn)n+=8;else if(s===An)n+=4;else throw new E(`unsupported wire type ${s}`);if(n>r)throw new E("field value runs past the end of the buffer");yield{fieldNumber:a,wireType:s,fieldStart:i,valueStart:c,valueEnd:n,fieldEnd:n,varint:d}}}function ie(e){if(!Number.isSafeInteger(e)||e<0)throw new E(`cannot encode varint ${e}`);let t=[],r=e;do{let n=r%128;r=Math.floor(r/128),r>0&&(n|=128),t.push(n)}while(r>0);return Uint8Array.from(t)}function Re(e){return ie(e*8+Xt)}var Cn=1,Ln=3;function oe(e){let t=new TextDecoder,r;for(let n of P(e))if(!(n.fieldNumber!==Cn||n.wireType!==2))for(let i of P(e,n.valueStart,n.valueEnd)){if(i.fieldNumber!==Ln||i.wireType!==2)continue;let o=t.decode(e.subarray(i.valueStart,i.valueEnd));o&&(r=o)}return r}var Qe=2,qn=3,$n=1,Bn=2,Wn=3,zn=1,Un=2,Hn=3;function Bo(e){let t;try{t=I(e,{inputKind:"SCIP sanitization input",maxBytes:S})}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}try{return Vn(t,e)}catch(r){if(r instanceof E)return{removedDefinitionOccurrences:0,touchedDocuments:0};throw r}}function Vn(e,t){let r=new TextDecoder,n=new Set;for(let a of P(e))if(a.wireType===2)if(a.fieldNumber===Qe)for(let s of P(e,a.valueStart,a.valueEnd))s.wireType===2&&(s.fieldNumber===$n?Fe(r.decode(e.subarray(s.valueStart,s.valueEnd))):s.fieldNumber===Wn&&tr(e,s,r,n));else a.fieldNumber===qn&&tr(e,a,r,n);let i=0,o=[];for(let a of P(e)){if(a.wireType!==2||a.fieldNumber!==Qe)continue;let s=Yn(e,a,r,n);s>0&&(i+=s,o.push(a))}return i===0?{removedDefinitionOccurrences:0,touchedDocuments:0}:(Qn(e,t,o,n),{removedDefinitionOccurrences:i,touchedDocuments:o.length})}function tr(e,t,r,n){for(let i of P(e,t.valueStart,t.valueEnd)){if(i.wireType!==2||i.fieldNumber!==zn)continue;let o=r.decode(e.subarray(i.valueStart,i.valueEnd));o&&n.add(o)}}function Yn(e,t,r,n){let i=0;for(let o of P(e,t.valueStart,t.valueEnd)){if(o.wireType!==2||o.fieldNumber!==Bn)continue;let a="",s=0;for(let c of P(e,o.valueStart,o.valueEnd))c.fieldNumber===Un&&c.wireType===2?a=r.decode(e.subarray(c.valueStart,c.valueEnd)):c.fieldNumber===Hn&&c.wireType===0&&(s=c.varint);(s&Ke.Definition)!==0&&!n.has(a)&&(i+=1)}return i}function Qn(e,t,r,n){let i=`${t}.sanitize-tmp`,o=kn(i,"w",384);try{let a=0;for(let s of r){ae(o,e.subarray(a,s.fieldStart));let c=_n(Ye,e.subarray(s.valueStart,s.valueEnd));c.occurrences=c.occurrences.filter(l=>(l.symbolRoles&Ke.Definition)===0||n.has(l.symbol));let d=jn(Ye,c);ae(o,Re(Qe)),ae(o,ie(d.byteLength)),ae(o,d),a=s.fieldEnd}ae(o,e.subarray(a))}catch(a){throw Zt(o),Mn(i,{force:!0}),a}Zt(o),On(i,t)}function ae(e,t){let r=0;for(;r<t.byteLength;)r+=Fn(e,t,r,t.byteLength-r)}function rr(e){let t=new Set;for(let o of e.documents){Fe(o.relativePath);for(let a of o.symbols)a.symbol&&t.add(a.symbol)}for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let r=0,n=0,i=[];for(let o of e.documents){let a=o.occurrences.filter(s=>(s.symbolRoles&Ke.Definition)===0||t.has(s.symbol)?!0:(r+=1,!1));if(a.length===o.occurrences.length){i.push(o);continue}n+=1,i.push(er(Ye,{language:o.language,relativePath:o.relativePath,occurrences:a,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:r===0?e:er(Nn,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:r,touchedDocuments:n}}import{closeSync as ce,openSync as Je,readSync as Kn,renameSync as Jn,rmSync as or,statSync as Xn,writeFileSync as ar,writeSync as sr}from"fs";import{create as Xe,fromBinary as Zn,toBinary as ei}from"@bufbuild/protobuf";import{deserializeSCIP as cr,serializeSCIP as dr,DocumentSchema as ti,IndexSchema as ri,MetadataSchema as nr,SymbolInformationSchema as ni}from"@c4312/scip";function lr(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=ii(e),r=oi(e.flatMap(i=>i.documents??[])),n=fr(e.flatMap(i=>i.externalSymbols??[]));return Xe(ri,{metadata:t,documents:r,externalSymbols:n})}function Jo(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>cr(I(i,{inputKind:"SCIP merge input",maxBytes:S}))),n=lr(r);return ar(t,dr(n)),{documentCount:n.documents.length,externalSymbolCount:n.externalSymbols.length,inputCount:e.length}}function Xo(e,t){if(e.length===0)throw new Error("Cannot concatenate zero SCIP files");let r=0;for(let o of e)if(r+=Xn(o).size,r>S)throw new Error(`Concatenated SCIP output exceeds the ${S}-byte artifact limit. Reduce the indexed project scope or use compatible cached generations.`);let n=Buffer.allocUnsafe(1024*1024),i=Je(t,"w",384);try{for(let o of e){let a=Je(o,"r");try{let s=0;for(;(s=Kn(a,n,0,n.byteLength,null))>0;){let c=0;for(;c<s;)c+=sr(i,n,c,s-c)}}finally{ce(a)}}}catch(o){throw ce(i),or(t,{force:!0}),o}ce(i)}function Zo(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=X("reindex.publish.scip-output.deserialize",()=>e.map(o=>cr(I(o,{inputKind:"SCIP merge input",maxBytes:S})))),n=X("reindex.publish.scip-output.merge",()=>lr(r)),i=X("reindex.publish.scip-output.sanitize",()=>rr(n));return X("reindex.publish.scip-output.serialize",()=>ar(t,dr(i.index))),{documentCount:i.index.documents.length,externalSymbolCount:i.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:i.removedDefinitionOccurrences,touchedDocuments:i.touchedDocuments}}var ir=1;function ur(e,t,r){let n=I(e,{inputKind:"SCIP normalization input",maxBytes:S}),i=oe(n),o=[];for(let c of P(n))c.fieldNumber===ir&&c.wireType===2&&o.push(c);if(o.length===0)throw new Error("Cannot rebase a SCIP index without metadata");if((i??"")!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${i??""}`);let a=`${e}.rebase-tmp`,s=Je(a,"w",384);try{let c=0;for(let d of o){se(s,n.subarray(c,d.fieldStart));let l=Zn(nr,n.subarray(d.valueStart,d.valueEnd));l.projectRoot=r;let f=ei(nr,l);se(s,Re(ir)),se(s,ie(f.byteLength)),se(s,f),c=d.fieldEnd}se(s,n.subarray(c))}catch(c){throw ce(s),or(a,{force:!0}),c}ce(s),Jn(a,e)}function se(e,t){let r=0;for(;r<t.byteLength;)r+=sr(e,t,r,t.byteLength-r)}function ii(e){let t=e[0]?.metadata;if(!t)return;let r=t.projectRoot;for(let n of e.slice(1)){let i=n.metadata?.projectRoot;if(r&&i&&i!==r)throw new Error(`Cannot merge SCIP indexes with different project roots: ${r} vs ${i}`)}return t}function oi(e){let t=new Map;for(let r of e){let n=t.get(r.relativePath);if(!n){t.set(r.relativePath,r);continue}t.set(r.relativePath,Xe(ti,{language:n.language||r.language,relativePath:n.relativePath||r.relativePath,occurrences:ai([...n.occurrences,...r.occurrences]),symbols:fr([...n.symbols,...r.symbols]),text:ci(n.text,r.text),positionEncoding:n.positionEncoding||r.positionEncoding}))}return[...t.values()]}function ai(e){let t=new Set,r=[];for(let n of e){let i=JSON.stringify(n);t.has(i)||(t.add(i),r.push(n))}return r}function fr(e){let t=new Map;for(let r of e){let n=t.get(r.symbol);if(!n){t.set(r.symbol,r);continue}t.set(r.symbol,Xe(ni,{symbol:n.symbol,documentation:di([...n.documentation,...r.documentation]),relationships:si([...n.relationships,...r.relationships]),kind:n.kind||r.kind,displayName:n.displayName||r.displayName,enclosingSymbol:n.enclosingSymbol||r.enclosingSymbol,signatureDocumentation:n.signatureDocumentation??r.signatureDocumentation}))}return[...t.values()]}function si(e){let t=new Set,r=[];for(let n of e){let i=[n.symbol,n.isReference?"1":"0",n.isImplementation?"1":"0",n.isTypeDefinition?"1":"0",n.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),r.push(n))}return r}function ci(e,t){return e?t?e.length>=t.length?e:t:e:t}function di(e){return[...new Set(e)]}import li from"better-sqlite3";var ui=25,fi=new Set(["typescript","javascript"]);function ia(e,t,r){let n=null;try{n=new li(e,{readonly:!0,fileMustExist:!0});let i=new Set(n.prepare("SELECT relative_path FROM documents").pluck().all().map(Me)),o=pi(t,r),a=new Set([...o.values()].flatMap(l=>[...l])),s=[...a].filter(l=>!i.has(l)).sort();if(s.length===0)return{state:"complete",expectedDocumentCount:a.size,actualDocumentCount:i.size};let c=new Set(s),d=r.filter(l=>[...o.get(l)??[]].some(f=>c.has(f)));return{state:"incomplete",expectedDocumentCount:a.size,actualDocumentCount:i.size,missingDocumentCount:s.length,missingPaths:s.slice(0,ui),affectedLanguages:d}}catch(i){return{state:"unavailable",reason:i instanceof Error?i.message:String(i)}}finally{n?.close()}}function pi(e,t){let r=new Map,n=t.filter(i=>fi.has(i));for(let i of n)r.set(i,new Set);for(let i of e.files){let o=Me(i.path);for(let a of n)Gt(o,[a])==="source"&&r.get(a).add(o)}return r}import{existsSync as mr,readdirSync as gr,rmSync as yr}from"fs";import{join as Q}from"path";import{create as Sr,fromBinary as Ir,toBinary as ma}from"@bufbuild/protobuf";import{deserializeSCIP as Ze,DocumentSchema as br,IndexSchema as xr,serializeSCIP as wr}from"@c4312/scip";import{existsSync as mi,mkdirSync as gi,renameSync as yi,writeFileSync as hi}from"fs";import{join as Si}from"path";function pr(e){gi(e.blobDir,{recursive:!0});let t=Si(e.blobDir,`${e.blobHash}.scipdoc`);if(mi(t)){let n=I(t,{maxBytes:J,inputKind:e.inputKind});if(n.byteLength!==e.bytes.byteLength||k(n)!==e.blobHash)throw new Error(`existing ${e.inputKind} is corrupt: ${e.relativePath}`);return}let r=`${t}.${process.pid}.${Date.now()}.tmp`;hi(r,e.bytes),yi(r,t)}var et=1,de="typescript-scip-fragments";function Sa(e){let t=new Set,r=[];for(let o of e){let a=Ee(o.relativePath);if(t.has(a))throw new Error(`duplicate TypeScript fragment replacement: ${a}`);if(t.add(a),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${a}`);let s=Ir(br,o.bytes);if(s.relativePath!==a)throw new Error(`TypeScript fragment path mismatch: expected ${a}, got ${s.relativePath}`);r.push(s)}let n=wr(Sr(xr,{documents:r,externalSymbols:[]})),i=Ze(n);if(i.documents.length!==r.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return n}function Ii(e){let t=Q(e,de);return{rootDir:t,blobDir:Q(t,"blobs"),generationDir:Q(t,"generations")}}function vr(e){let t=bi(e);return xi(t.baseIndex,t.completeDocuments,"assembled")}function bi(e){let t=Ze(e.baseIndexBytes);Ei(t.metadata,Pi(e)),Ri(t.externalSymbols);let r=new Map;for(let s of e.fragments){let c=Ee(s.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);r.set(c,s)}if(r.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let n=new Set,i=[],o=[],a=[];for(let s of t.documents){let c=Ee(s.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);n.add(c);let d=r.get(c);if(!d){i.push(s);continue}if(r.delete(c),d.bytes===null){a.push(c);continue}let l=hr(c,d.bytes);i.push(l),o.push(l)}for(let s of[...r.keys()].sort()){let c=r.get(s);if(c.bytes===null)continue;if(n.has(s))throw new Error(`duplicate TypeScript SCIP document path: ${s}`);n.add(s);let d=hr(s,c.bytes);i.push(d),o.push(d)}return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:a}}function hr(e,t){let r=Ir(br,t);if(r.relativePath!==e)throw new Error(`TypeScript fragment path mismatch: expected ${e}, got ${r.relativePath}`);return r}function xi(e,t,r){let n=wr(Sr(xr,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=Ze(n);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${r} TypeScript SCIP index failed structural verification`);return n}function Ia(e,t){let r=Ii(e);if(!mr(r.generationDir))return;let n=new Set(t.map(a=>vi(a))),i=gr(r.generationDir).filter(a=>a.endsWith(".json")),o=new Set;for(let a of i.filter(s=>n.has(s))){let s=wi(R(Q(r.generationDir,a),{maxBytes:v,inputKind:"TypeScript fragment manifest"}));for(let c of s.documents)o.add(`${c.blobHash}.scipdoc`)}for(let a of i)n.has(a)||yr(Q(r.generationDir,a),{force:!0});if(mr(r.blobDir))for(let a of gr(r.blobDir))o.has(a)||yr(Q(r.blobDir,a),{force:!0})}function wi(e){let t=JSON.parse(e);if(t.version!==et||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let r=new Set;for(let n of t.documents){if(!n||typeof n.relativePath!="string"||typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash)||typeof n.byteLength!="number"||!Number.isInteger(n.byteLength)||n.byteLength<0||typeof n.documentIdentity!="string"||!n.documentIdentity)throw new Error("invalid TypeScript fragment record");if(Ee(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript fragment record");r.add(n.relativePath)}return t}function vi(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${k(e)}.json`}function Ri(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function Ei(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let r=e,n=r.toolInfo??r.tool_info;if(!n||typeof n!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=n;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function Pi(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function Ee(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}import{existsSync as Pe,readdirSync as tt,rmSync as Rr}from"fs";import{join as D}from"path";var Te=1,le="typescript-scip-overlays",Er="typescript-project-v3:";function Ga(e){let t=Tr(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t?.producerIdentity!==void 0&&t.producerIdentity!==e.producerIdentity)throw new Error("TypeScript overlay producer identity changed");let r=e.allowLegacyProjectIdentityMigration===!0&&t!==null&&!t.projectIdentity.startsWith(Er)&&e.projectIdentity.startsWith(Er);if(t&&t.projectIdentity!==e.projectIdentity&&!e.allowProjectIdentityChange&&!r)throw new Error("TypeScript overlay project identity changed");let n=new Map((t?.overlays??[]).map(a=>[a.relativePath,a])),i=new Set;for(let a of e.fragments){let s=it(a.relativePath);if(i.has(s))throw new Error(`duplicate TypeScript overlay: ${s}`);i.add(s),n.set(s,Ti(e.cacheDir,a))}if(i.size===0)throw new Error("TypeScript overlay generation requires affected documents");let o={version:Te,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...n.values()].sort((a,s)=>a.relativePath.localeCompare(s.relativePath))};return Gi(e.cacheDir,o),o}function Da(e){let t=Tr(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let r=t.overlays.map(n=>{if(n.blobHash===null)return{relativePath:n.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=I(D(ue(e.cacheDir),"blobs",`${n.blobHash}.scipdoc`),{maxBytes:J,inputKind:"TypeScript overlay blob"});if(i.byteLength!==n.byteLength||k(i)!==n.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${n.relativePath}`);return{relativePath:n.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return vr({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:r})}function Aa(e,t){let r=ue(e),n=D(r,"generations");if(!Pe(n))return;let i=new Set(t.map(nt)),o=new Set;for(let s of tt(n).filter(c=>i.has(c))){let c=rt(R(D(n,s),{maxBytes:v,inputKind:"TypeScript overlay manifest"}));for(let d of c.overlays)d.blobHash&&o.add(`${d.blobHash}.scipdoc`)}for(let s of tt(n))i.has(s)||Rr(D(n,s),{force:!0});let a=D(r,"blobs");if(Pe(a))for(let s of tt(a))o.has(s)||Rr(D(a,s),{force:!0})}function Tr(e,t){let r=D(ue(e),"generations",nt(t));if(!Pe(r))return null;let n=rt(R(r,{maxBytes:v,inputKind:"TypeScript overlay manifest"}));if(n.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return n}function Ti(e,t){let r=it(t.relativePath);if(t.bytes===null)return{relativePath:r,blobHash:null,byteLength:0};let n=Buffer.from(t.bytes),i=k(n);return pr({blobDir:D(ue(e),"blobs"),blobHash:i,bytes:n,relativePath:r,inputKind:"TypeScript overlay blob"}),{relativePath:r,blobHash:i,byteLength:n.byteLength}}function Gi(e,t){let r=D(ue(e),"generations",nt(t.generationIdentity));if(Pe(r)){let n=rt(R(r,{maxBytes:v,inputKind:"TypeScript overlay manifest"}));if(Pr(n)!==Pr(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}V(r,t,{spacing:2,trailingNewline:!0})}function rt(e){let t=JSON.parse(e);if(t.version!==Te||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let r=new Set;for(let n of t.overlays){if(!n||typeof n.relativePath!="string"||n.blobHash!==null&&(typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash))||!Number.isInteger(n.byteLength)||n.byteLength<0||n.blobHash===null&&n.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(it(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript overlay record");r.add(n.relativePath)}return t}function ue(e){return D(e,le)}function nt(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${k(e)}.json`}function Pr(e){return k(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function it(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}import{createHash as lt}from"crypto";import{closeSync as Di,existsSync as g,mkdirSync as Ai,openSync as Ci,readSync as Li,readdirSync as ut,renameSync as ct,rmSync as fe,statSync as B}from"fs";import{basename as ft,dirname as A,join as p,relative as Gr}from"path";var ki=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function Ar(e){let t=h(e.outputDb),r=ji(e);e.onStage?.("after-recovery-retained");let n=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=Ni(e,r),o=mt({generationRoot:t,databasePath:e.tempOutputDb,indexPath:g(n)?n:void 0,verifiedIndexArtifact:i,metadataPath:g(e.tempMetaPath)?e.tempMetaPath:void 0}),a=(e.now??(()=>new Date))().toISOString(),s={version:N,currentGeneration:o.identity,artifactSet:"immutable-v1",...r?{previousGeneration:r}:{},...e.publication?{publication:e.publication}:{},publishedAt:a},c=G(p(t,"state.json"),s,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||st(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),st(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),st(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let d=o.identity,l={...s,stableMirrors:pt(e.outputDb,e.outputScip)};G(p(t,"state.json"),l,{spacing:2,trailingNewline:!0});let f=Cr(e.outputDb,{now:e.now}),m=Z(o.directorySync,c.directorySync);return{currentGeneration:d,...r?{previousGeneration:r}:{},retention:f,achievedDurability:m==="synced"?"directory-durable":"file-flushed",directorySync:m}}function Oi(e,t,r,n=()=>new Date){if(!g(e))return null;let i=q(e),o=p(h(e),"state.json");if(i?.artifactSet==="immutable-v1"&&re(e,i.currentGeneration))return i;let a=h(e),s=!i&&g(o)?$i(r,e,t):void 0;if(s&&!ne(a,s))return null;let c=mt({generationRoot:a,databasePath:e,indexPath:g(t)?t:void 0,metadataPath:g(r)?r:void 0,forcedIdentity:i?.currentGeneration??s}),d={version:N,currentGeneration:c.identity,artifactSet:"immutable-v1",stableMirrors:pt(e,t),...i?.previousGeneration?{previousGeneration:i.previousGeneration}:{},...i?.publication?{publication:i.publication}:{},publishedAt:i?.publishedAt??n().toISOString()};return G(p(a,"state.json"),d,{spacing:2,trailingNewline:!0}),d}function Ba(e,t,r=()=>new Date){if(!g(e)||!g(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let n=q(e),i=h(e),o=mt({generationRoot:i,databasePath:e,indexPath:g(p(A(e),"index.scip"))?p(A(e),"index.scip"):void 0,metadataPath:t}),a=n&&n.currentGeneration!==o.identity?kr(e,n.currentGeneration):void 0,s={version:N,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:pt(e,p(A(e),"index.scip")),...a?{previousGeneration:a}:{},...n?.publication?{publication:n.publication}:{},publishedAt:r().toISOString()};return G(p(h(e),"state.json"),s,{spacing:2,trailingNewline:!0}),Cr(e,{now:r}),s}function Cr(e,t={}){let r=Mi(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=j(Ue(e),{waitMs:0});if(!o)return{state:"deferred",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:r,at:i,reason:"another process owns local generation retention"};try{let a=q(e),s=Fi(e),c=Ht(e,s.map(x=>x.identity),{isProcessAlive:t.isProcessAlive??be,readProcessIdentity:t.readProcessIdentity??ye}),d=new Set(c.protectedGenerations);a?.currentGeneration&&d.add(a.currentGeneration),a?.previousGeneration?.generationIdentity&&d.add(a.previousGeneration.generationIdentity);let l=s.length,f=s.reduce((x,Oe)=>x+Oe.logicalBytes,0),m=0,T=0;for(let x of s){if(l<=r.maxGenerations&&f<=r.maxLogicalBytes)break;d.has(x.identity)||(t.onBeforeRemove?.(x.identity),fe(x.path,{recursive:!0,force:!0}),l-=1,f-=x.logicalBytes,m+=1,T+=x.logicalBytes)}let y=l>r.maxGenerations||f>r.maxLogicalBytes,L={state:y?"protected":m>0?"collected":"within-bounds",generationCount:l,logicalBytes:f,protectedGenerations:d.size,activeReaderLeases:c.activeLeases,staleReaderLeasesRemoved:c.staleLeasesRemoved,malformedReaderLeases:c.malformedLeases,removedGenerations:m,removedLogicalBytes:T,limits:r,at:i,...y?{reason:c.malformedLeases>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}:{}};return Dr(e,L),L}catch(a){let s={state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:r,at:i,reason:a instanceof Error?a.message:String(a)};try{Dr(e,s)}catch{}return s}finally{o.release()}}function Mi(e={}){let t={...ki,...e};if(!Number.isSafeInteger(t.maxGenerations)||t.maxGenerations<2)throw new Error("Local SQLite generation retention must keep at least current and previous generations.");if(!Number.isSafeInteger(t.maxLogicalBytes)||t.maxLogicalBytes<=0)throw new Error("Local SQLite generation byte retention must be a positive safe integer.");return t}function Fi(e){let t=h(e);return g(t)?ut(t,{withFileTypes:!0}).filter(r=>r.isDirectory()&&/^[a-f0-9]{64}$/.test(r.name)).map(r=>{let n=p(t,r.name),i=ne(t,r.name),o=i?i.database.size+(i.index?.size??0)+(i.metadata?.size??0):Lr(n);return{identity:r.name,path:n,logicalBytes:o,modifiedAtMs:B(n).mtimeMs}}).sort((r,n)=>r.modifiedAtMs-n.modifiedAtMs||r.identity.localeCompare(n.identity)):[]}function Lr(e){let t=0;for(let r of ut(e,{withFileTypes:!0})){let n=p(e,r.name);r.isDirectory()?t+=Lr(n):r.isFile()&&(t+=B(n).size)}return t}function Dr(e,t){V(p(h(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function De(e,t=p(A(e),"meta.json")){let r=p(h(e),"state.json");if(!g(r))return{state:"legacy",statePath:r};let n=q(e);if(!n)return{state:"invalid",statePath:r,reason:"generation state is malformed"};try{let i=re(e,n.currentGeneration),o=i!==null,a=i?_i(e,t,i,n):!1,s=n.previousGeneration?g(p(A(e),n.previousGeneration.databasePath)):!0;return!a||!o||!s?{state:"drifted",statePath:r,currentMatches:a,recoveryExists:s,generation:n,reason:o?a?"retained recovery database is missing":"stable database or metadata no longer matches the published generation":"published immutable generation is missing"}:{state:"current",statePath:r,currentMatches:a,recoveryExists:s,generation:n}}catch(i){return{state:"drifted",statePath:r,currentMatches:!1,recoveryExists:!1,generation:n,reason:i instanceof Error?i.message:String(i)}}}function _i(e,t,r,n){if(n.stableMirrors&&(n.stableMirrors.databaseFileIdentity!==$(e)||n.stableMirrors.indexFileIdentity!==void 0&&n.stableMirrors.indexFileIdentity!==$(p(A(e),"index.scip")))||!dt(e,r.database))return!1;let i=p(A(e),"index.scip");if(r.index&&!dt(i,r.index))return!1;if(!r.metadata)return!g(t);if(!g(t))return!1;let o=p(h(e),r.identity,r.metadata.file);return g(o)&&M(b(t,"reindex metadata"))===M(b(o,"immutable reindex metadata"))}function dt(e,t){return g(e)&&B(e).isFile()&&B(e).size===t.size}function ji(e){let t=Oi(e.outputDb,e.outputScip,e.metaPath);return t?kr(e.outputDb,t.currentGeneration):void 0}function Ni(e,t){if(!e.preserveOutputScip)return;if(!t)throw new Error("deferred SCIP publication requires an accepted immutable generation");let r=De(e.outputDb,e.metaPath);if(r.state!=="current"||r.generation.currentGeneration!==t.generationIdentity){let i=r.state==="current"?"generation identity changed":"reason"in r?r.reason:`generation state is ${r.state}`;throw new Error(`deferred SCIP publication requires a verified accepted companion: ${i}`)}let n=re(e.outputDb,t.generationIdentity);if(!n?.index||!dt(e.outputScip,n.index))throw new Error("deferred SCIP publication requires the verified accepted index artifact");return n.index}function pt(e,t){return{databaseFileIdentity:$(e),...g(t)?{indexFileIdentity:$(t)}:{}}}function kr(e,t){let r=p(h(e),t),n=p(r,ft(e)),i=p(r,"meta.json");return{generationIdentity:t,databasePath:Gr(A(e),n),...g(i)?{metadataPath:Gr(A(e),i)}:{}}}function qi(e){if(g(e))for(let t of ut(e,{withFileTypes:!0}))t.isDirectory()&&t.name.endsWith(".tmp")&&fe(p(e,t.name),{recursive:!0,force:!0})}function $i(e,t,r=p(A(t),"index.scip")){let n=lt("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(Ge(t)),g(r)&&n.update(`\0${Ge(r)}`),g(e)&&n.update(`\0${M(b(e,"reindex metadata"))}`),n.digest("hex")}function mt(e){let t=ot(e.databasePath),r=e.indexPath?e.verifiedIndexArtifact?Wi(e.indexPath,e.verifiedIndexArtifact):ot(e.indexPath):void 0,n=e.metadataPath?ot(e.metadataPath):void 0,i=e.forcedIdentity??Bi(t,r,e.metadataPath),o=p(e.generationRoot,i),a=p(o,ve);if(g(a)){let d=ne(e.generationRoot,i);if(d&&Or(o,d.database,t)&&Ui(o,d.index,r)&&Hi(o,d.metadata,e.metadataPath))return{identity:i,directorySync:O(e.generationRoot)};throw new Error(`SQLite generation ${i} already exists with different or corrupt artifacts.`)}let s=[Ie(e.generationRoot)];qi(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;fe(c,{recursive:!0,force:!0}),Ai(c,{recursive:!0});try{s.push(at(e.databasePath,p(c,t.file))),r&&e.indexPath&&s.push(at(e.indexPath,p(c,r.file))),n&&e.metadataPath&&s.push(at(e.metadataPath,p(c,n.file)));let d=G(p(c,ve),{version:ze,identity:i,database:t,...r?{index:r}:{},...n?{metadata:n}:{}},{spacing:2,trailingNewline:!0});d.directorySync!=="not-requested"&&s.push(d.directorySync),s.push(O(c)),ct(c,o),s.push(O(e.generationRoot))}finally{fe(c,{recursive:!0,force:!0})}return{identity:i,directorySync:Z(...s)}}function Bi(e,t,r){let n=lt("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(e.sha256),t&&n.update(`\0${t.sha256}`),r&&n.update(`\0${M(b(r,"reindex metadata"))}`),n.digest("hex")}function ot(e){return{file:ft(e),size:B(e).size,sha256:Ge(e)}}function Wi(e,t){if(t.file!==ft(e)||B(e).size!==t.size)throw new Error(`verified SQLite generation artifact changed before publication: ${e}`);return t}function Ge(e){let t=lt("sha256"),r=Ci(e,"r"),n=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=zi(r,n);if(i===0)break;t.update(n.subarray(0,i))}}finally{Di(r)}return t.digest("hex")}function zi(e,t){let r=0;for(;r<t.length;){let n=Li(e,t,r,t.length-r,null);if(r+=n,n===0)break}return r}function at(e,t){return xe(e,t,{mode:292})}function Or(e,t,r){let n=p(e,t.file);return t.file===r.file&&t.size===r.size&&t.sha256===r.sha256&&g(n)&&B(n).size===t.size&&Ge(n)===t.sha256}function Ui(e,t,r){return!t||!r?t===r:Or(e,t,r)}function Hi(e,t,r){if(!t||!r)return t===void 0&&r===void 0;let n=p(e,t.file);return g(n)&&M(b(n,"stored reindex metadata"))===M(b(r,"candidate reindex metadata"))}function st(e,t){fe(`${t}.tmp-replace`,{force:!0}),ct(e,`${t}.tmp-replace`),ct(`${t}.tmp-replace`,t)}import{createHash as Wr,randomUUID as Zi}from"crypto";import{existsSync as _,lstatSync as ht,mkdirSync as K,mkdtempSync as zr,readdirSync as Ur,realpathSync as Hr,renameSync as z,rmSync as F,statSync as ke}from"fs";import{dirname as St,join as u,resolve as W}from"path";import{setTimeout as eo}from"timers/promises";import{pathToFileURL as jr}from"url";import to from"better-sqlite3";import{lstatSync as Vi,readdirSync as Yi}from"fs";import{join as Qi,relative as Ki,resolve as gt,sep as Ji}from"path";var pe=1,yt="language-indexes",Mr=["index.db","index.scip","meta.json"],Fr=[yt,de,le];function Ae(e){let t=[];for(let r of Mr)Xi(e,r),t.push(r);for(let r of Fr)_r(e,r,t);return{version:pe,files:t.sort()}}function Ce(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(n=>!n||n==="."||n===".."))throw new Error(`invalid index artifact path: ${e}`);let r=t[0];if(!Mr.includes(e)&&!Fr.includes(r))throw new Error(`index artifact path is not shareable: ${e}`);return e}function C(e,t){let r=Ce(t),n=gt(e),i=gt(n,...r.split("/"));if(i!==n&&!i.startsWith(`${n}${Ji}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function _r(e,t,r){let n=Qi(e,t),i;try{i=Yi(n,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let a=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${a}`);o.isDirectory()?_r(e,a,r):o.isFile()&&r.push(Ce(a))}}function Xi(e,t){let r=C(e,t),n;try{n=Vi(r)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!n.isFile()||n.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(Ki(gt(e),r).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var It=1,Nr="SCIP_QUERY_SHARED_CACHE",ro=2,Le=JSON.stringify({cliVersion:kt,artifactCatalogVersion:pe,postIndexAugmentationSchemaVersion:ro,sqliteGenerationStoreVersion:N,typescriptFragmentStoreVersion:et,typescriptOverlayStoreVersion:Te}),bt="manifest.json",Vr="shared-cache.json";var xt=[yt,de,le];function no(e,t){if(!e.clean||!e.treeOid)return;let r=Zr(JSON.stringify({version:It,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:At(t),producerIdentity:Le}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:Le,generationId:r,repositoryCacheDir:_e(e.repositoryId)}}function xs(e,t,r){if(!go(r))return!1;let n=no(e,r);if(!n)return!1;try{let i=lo(t);if(!i||i.repositoryId!==e.repositoryId||i.worktreeId!==e.worktreeId)return!1;let o=JSON.parse(R(u(n.repositoryCacheDir,"worktrees",`${i.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:v}));return o.version!==1||o.repositoryId!==i.repositoryId||o.worktreeId!==i.worktreeId||W(o.projectRoot)!==W(e.projectRoot)||o.treeOid!==e.treeOid||W(o.localCacheDir)!==W(t)||o.ownershipChecksum!==wt(o)||o.baseGenerationId!==n.generationId||o.activeGenerationId!==n.generationId?!1:U(n,!1)!==null}catch{return!1}}function ws(e,t,r){if(process.env[Nr]==="0")return`${Nr}=0`;if(!je(r))return"explicit cache or database override";if(Ne(St(t))!==Ne(Mt(e))||t!==u(St(t),"index.db"))return"index database is outside the managed worktree cache"}function vs(e,t,r){if(!je(t))return;let n=r??qt(e);return n?u(_e(n.repositoryId),"evidence.db"):void 0}function U(e,t=!0){let r=vt(e),n;try{n=Yr(R(u(r,bt),{inputKind:"shared-generation manifest",maxBytes:v}))}catch{return null}if(n.generationId!==e.generationId||n.repositoryId!==e.repositoryId||n.treeOid!==e.treeOid||n.producerIdentity!==e.producerIdentity||!he(n.fingerprint,e.fingerprint)||!so(r))return null;if(!t)return n;try{for(let i of n.artifacts){let o=C(r,i.path),a=ke(o);if(!a.isFile()||a.size!==i.size||H(o,{inputKind:"shared-generation artifact",maxBytes:S})!==i.sha256)return null}}catch{return null}return n}function Rs(e,t,r,n){if(!e.treeOid)return null;let i=qe(t,r),o=u(Ot(),"repositories",e.repositoryId),a;try{let d=ht(o);if(!d.isDirectory()||d.isSymbolicLink())return null;a=Hr(o)}catch{return null}let s=u(a,"generations"),c=[];try{for(let d of Ur(s)){if(!/^[a-f0-9]{64}$/.test(d))continue;let l=u(s,d),f;try{f=ht(l)}catch{continue}if(!(!f.isDirectory()||f.isSymbolicLink()))try{let m=Yr(R(u(l,bt),{inputKind:"shared-generation baseline manifest",maxBytes:v}));m.generationId===d&&m.repositoryId===e.repositoryId&&m.producerIdentity===Le&&co(m.fingerprint,i)&&c.push(m)}catch{continue}}}catch{return null}c.sort((d,l)=>{let f=d.treeOid===e.treeOid?0:1,m=l.treeOid===e.treeOid?0:1;if(f!==m)return f-m;if(n){let y=Br(d.fingerprint,n)-Br(l.fingerprint,n);if(y!==0)return y}return Date.parse(l.createdAt)-Date.parse(d.createdAt)||d.generationId.localeCompare(l.generationId)});for(let d of c){let l={repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:d.treeOid,fingerprint:d.fingerprint,producerIdentity:d.producerIdentity,generationId:d.generationId,repositoryCacheDir:a},f=U(l);if(f)return{snapshot:l,manifest:f}}return null}function Es(e){let t=j(u(e.snapshot.repositoryCacheDir,"locks",`${e.snapshot.generationId}.publish.lock`));if(!t)throw new Error(`shared generation publication is already in progress for ${e.snapshot.generationId}`);try{return io(e)}finally{t.release()}}function io(e){let t=U(e.snapshot);if(t)return qr(e.snapshot,t);if(!Xr(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let r=$r(e.sourceCacheDir);if(!r)throw new Error("source index artifacts are incomplete");let n=Ae(e.sourceCacheDir),i=u(e.snapshot.repositoryCacheDir,"generations"),o=[Ie(i)],a=zr(u(i,`.tmp-${process.pid}-`));try{let s=[];for(let y of n.files){let L=C(e.sourceCacheDir,y),x=C(a,y);o.push(ge(L,x,292)),e.onPublicationStage?.("after-artifact-flushed",y);let Oe=ke(x).size;s.push({path:y,size:Oe,sha256:H(x,{inputKind:"staged shared-generation artifact",maxBytes:S})})}let c=oe(I(u(a,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:S}));if(!c)throw new Error("shared SCIP generation has no project root metadata");let d=Rt(e.sourceProjectRoot);if(c!==d)throw new Error("shared SCIP generation root does not match its source worktree");if($r(e.sourceCacheDir)!==r||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let l={version:It,artifactCatalogVersion:pe,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:c,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:s.sort((y,L)=>y.path.localeCompare(L.path))},f=G(u(a,bt),l,{spacing:2,trailingNewline:!0});f.directorySync!=="not-requested"&&o.push(f.directorySync),e.onPublicationStage?.("after-manifest-flushed"),o.push(O(a)),e.onPublicationStage?.("after-staging-directory-synced");let m=vt(e.snapshot);try{if(_(m)&&!U(e.snapshot)){let y=`${m}.corrupt-${process.pid}-${Date.now()}`;z(m,y),F(y,{recursive:!0,force:!0})}z(a,m)}catch(y){let L=U(e.snapshot);if(L)return qr(e.snapshot,L);throw y}e.onPublicationStage?.("after-generation-renamed"),o.push(O(i)),e.onPublicationStage?.("after-generations-directory-synced");let T=Z(...o);return{kind:"published",manifest:l,achievedDurability:T==="synced"?"directory-durable":"file-flushed",directorySync:T}}finally{F(a,{recursive:!0,force:!0})}}function qr(e,t){let r=O(u(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:r==="synced"?"directory-durable":"file-flushed",directorySync:r}}function Ps(e){let t=vt(e.snapshot);K(e.targetCacheDir,{recursive:!0});let r=j(u(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:e.lockWaitMs??3e4});if(!r)throw new Error("timed out waiting for another cache hydration");let n,i,o=!1;try{n=zr(u(e.targetCacheDir,".shared-hydrate-")),mo(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let d=C(t,c.path),l=C(n,c.path);if(ge(d,l),ke(l).size!==c.size||H(l,{inputKind:"hydrated shared-generation artifact",maxBytes:S})!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let a=Rt(e.targetProjectRoot);if(a!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&ur(C(n,c.path),e.manifest.scipProjectRoot,a);if(!Xr(n,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=uo(e.targetCacheDir,n),o=!0,fo(n,e.targetCacheDir,i),Ar({tempOutputScip:u(n,"index.scip"),tempOutputDb:u(n,"index.db"),tempMetaPath:u(n,"meta.json"),outputScip:u(e.targetCacheDir,"index.scip"),outputDb:u(e.targetCacheDir,"index.db"),metaPath:u(e.targetCacheDir,"meta.json"),now:e.now});let s=De(u(e.targetCacheDir,"index.db"),u(e.targetCacheDir,"meta.json"));if(s.state==="invalid"||s.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${s.reason}`);e.persistLease!==!1&&oo(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(a){throw o&&i&&po(e.targetCacheDir,i),a}finally{n&&F(n,{recursive:!0,force:!0}),r.release()}}async function Ts(e,t={}){let r=t.timeoutMs??3e4,n=t.pollMs??100,i=t.now??Lt,o=i()+r,a=u(e.repositoryCacheDir,"locks"),s=u(a,`${e.generationId}.lock`),c=d=>{if(!d||typeof d!="object"||Array.isArray(d))return null;let l=d.pid;return typeof l=="number"&&Number.isSafeInteger(l)&&l>0?{pid:l}:null};for(;i()<=o;){if(U(e))return{kind:"generation-ready"};let d=Ft(s,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:c});if(d.kind==="acquired")return{kind:"owner",release:()=>d.lock.release()};let l=o-i();if(l<=0)break;await eo(Math.min(n,l))}return U(e)?{kind:"generation-ready"}:{kind:"timeout"}}function oo(e,t,r,n=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:r,lastSeenAt:(n??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:wt(i)};return Kr(e.repositoryCacheDir,o,!0),o}function Gs(e,t,r=void 0){let n={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,lastAction:"overlay",lastReason:`private cache forked from shared baseline ${e.generationId}`,lastSeenAt:(r??(()=>new Date))().toISOString()},i={...n,ownershipChecksum:wt(n)};return Kr(e.repositoryCacheDir,i,!0),i}function wt(e){return Zr(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:W(e.projectRoot),localCacheDir:W(e.localCacheDir)}))}function Yr(e){let t=JSON.parse(e);if(t.version!==It||t.artifactCatalogVersion!==pe||typeof t.generationId!="string"||!/^[a-f0-9]{64}$/.test(t.generationId)||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.treeOid!="string"||!t.treeOid||typeof t.producerIdentity!="string"||t.producerIdentity!==Le||typeof t.sourceProjectRoot!="string"||typeof t.scipProjectRoot!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!t.fingerprint||!Array.isArray(t.artifacts))throw new Error("invalid shared generation manifest");let r=new Set;for(let n of t.artifacts){if(!n||typeof n.path!="string"||typeof n.size!="number"||n.size<0||typeof n.sha256!="string"||!/^[a-f0-9]{64}$/.test(n.sha256))throw new Error("invalid shared generation artifact");if(Ce(n.path),r.has(n.path))throw new Error(`duplicate shared generation artifact: ${n.path}`);r.add(n.path)}for(let n of["index.db","index.scip","meta.json"])if(!r.has(n))throw new Error(`shared generation is missing ${n}`);return t}function ge(e,t,r=384){return xe(e,t,{mode:r})}function ao(e,t,r){K(e,{recursive:!0}),G(u(e,Vr),{version:1,repositoryId:t,worktreeId:r},{spacing:2,trailingNewline:!0})}function $r(e){try{let t=Ae(e),r=Wr("sha256");for(let n of t.files){let i=C(e,n),o=ke(i).size;r.update(n).update("\0").update(String(o)).update("\0"),Et(i,{inputKind:"source-generation artifact",maxBytes:S},a=>r.update(a)),r.update("\0")}return r.digest("hex")}catch{return null}}function Qr(e){try{let t=Se(R(u(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:v}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function so(e){return Qr(e)?.scipCompanion!=="deferred"}function co(e,t){let r=qe(e.languages,e);return JSON.stringify(r)===JSON.stringify(t)}function Br(e,t){let r=new Map(e.files.map(o=>[o.path,`${o.size}\0${o.hash}`])),n=new Map(t.files.map(o=>[o.path,`${o.size}\0${o.hash}`])),i=0;for(let[o,a]of r)n.get(o)!==a&&(i+=1);for(let o of n.keys())r.has(o)||(i+=1);return i}function vt(e){return u(e.repositoryCacheDir,"generations",e.generationId)}function lo(e){let t=JSON.parse(R(u(e,Vr),{inputKind:"worktree cache pointer",maxBytes:v}));return t.version!==1||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.worktreeId!="string"||!/^[a-f0-9]{24}$/.test(t.worktreeId)?null:{version:t.version,repositoryId:t.repositoryId,worktreeId:t.worktreeId}}function Kr(e,t,r){let n=_t(e,{waitMs:5e3});if(!n)throw new Error("repository cache cleanup is busy");try{if(r){let o=t.activeGenerationId??t.baseGenerationId;if(!o||!_(u(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=u(e,"worktrees");K(i,{recursive:!0}),G(u(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),ao(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{n.release()}}function uo(e,t){let r=u(t,".rollback"),n=new Map,i=new Map;K(r,{recursive:!0});for(let s of["index.scip","index.db","meta.json"]){let c=u(e,s),d=_(c);n.set(s,d),d&&ge(c,u(r,"stable",s))}for(let s of xt){let c=u(e,s),d=_(c);if(d){let l=ht(c);if(!l.isDirectory()||l.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${s}`)}i.set(s,d)}let o=u(e,te),a=_(o);return a&&Jr(o,u(r,"sqlite-generations")),{root:r,stableFiles:n,managedDirectories:i,generationStoreExisted:a}}function fo(e,t,r){for(let n of xt){let i=u(t,n);if(r.managedDirectories.get(n)){let a=u(r.root,"managed",n);K(St(a),{recursive:!0}),z(i,a)}let o=u(e,n);_(o)&&z(o,i)}}function po(e,t){for(let i of xt){let o=u(e,i),a=u(t.root,"managed",i);t.managedDirectories.get(i)?_(a)&&(F(o,{recursive:!0,force:!0}),z(a,o)):F(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let a=u(e,i);if(!o){F(a,{force:!0});continue}let s=`${a}.shared-restore-${Zi()}`;ge(u(t.root,"stable",i),s),F(a,{force:!0}),z(s,a)}let r=u(e,te);F(r,{recursive:!0,force:!0});let n=u(t.root,"sqlite-generations");t.generationStoreExisted&&_(n)&&z(n,r)}function Jr(e,t){K(t,{recursive:!0});for(let r of Ur(e,{withFileTypes:!0})){let n=u(e,r.name),i=u(t,r.name);if(r.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${n}`);r.isDirectory()?Jr(n,i):r.isFile()&&ge(n,i)}}function mo(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||!he(e.fingerprint,t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function Xr(e,t,r,n=!0,i=!0){try{let o=Qr(e);if(!o||o.scipCompanion==="deferred"||!he(Dt(o.fingerprint),r)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...r.languages].sort()))return me("source validation rejected metadata"),!1;let a=Ae(e),s=De(u(e,"index.db"),u(e,"meta.json"));if(n?s.state!=="current":s.state==="invalid"||s.state==="drifted")return me(`source validation rejected SQLite generation state ${s.state}`),!1;let c=new to(u(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let d=Rt(t),f=(i?a.files.filter(m=>m.endsWith(".scip")):["index.scip"]).every(m=>{let T=oe(I(C(e,m),{inputKind:"shared SCIP validation artifact",maxBytes:S}));return T!==d&&me(`source validation rejected SCIP root for ${m}: ${String(T)}`),T===d});return f||me("source validation rejected SCIP project roots"),f}catch(o){return me(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function me(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function Rt(e){try{return jr(Hr(e)).href}catch{return jr(W(e)).href}}function go(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===3&&Array.isArray(t.languages)&&typeof t.pnpmWorkspaces=="boolean"&&(t.typescriptProjectMode==="single"||t.typescriptProjectMode==="workspace")&&Array.isArray(t.typescriptProjects)&&Array.isArray(t.files)&&t.files.every(r=>r!==null&&typeof r=="object"&&typeof r.path=="string"&&typeof r.size=="number"&&typeof r.hash=="string"&&(r.semanticHash===void 0||typeof r.semanticHash=="string"))}function Zr(e){return Wr("sha256").update(e).digest("hex")}export{Po as a,ln as b,To as c,$ as d,ko as e,P as f,ie as g,Re as h,Bo as i,Jo as j,Xo as k,Zo as l,ia as m,Sa as n,Ia as o,Ga as p,Da as q,Aa as r,Ar as s,Oi as t,Ba as u,De as v,no as w,xs as x,ws as y,vs as z,U as A,Rs as B,Es as C,Ps as D,Ts as E,oo as F,Gs as G,wt as H};
2
+ //# sourceMappingURL=chunk-RMDPFPNW.js.map
@@ -0,0 +1,4 @@
1
+ import{b as y}from"./chunk-A4WEAK35.js";import{a as v}from"./chunk-BJWFVAA5.js";import{p as S}from"./chunk-SKKXTABJ.js";import{a as b}from"./chunk-F5GSBHC6.js";import{d as u,e as f,j as m,r as p,s as g}from"./chunk-C7C6AKAT.js";import{h as d}from"./chunk-ETC674NS.js";function q(e,t,i={}){let n=T(e,t,i);return{definitions:n.definitions,referencedBy:n.referencedBy.map(r=>({relativePath:r.relativePath,line:r.line,enclosingSymbol:r.enclosingSymbol,enclosingShort:r.enclosingShort}))}}function T(e,t,i={}){let n=R(e,t,i);return{definitions:n.definitions,referencedBy:n.referencedBy}}function R(e,t,i={}){let n=b(e,t);if(!n)return{definitions:[],referencedBy:[],referenceEvidence:[],claimSupport:null};let r=e.get("SELECT display_name, documentation FROM global_symbols WHERE id = ?",n.symbolId),c=g(r?.documentation??null),o=e.isIgnored(n.relativePath)?[]:[{relativePath:n.relativePath,startLine:n.startLine,endLine:n.endLine,signature:K(c,r?.display_name??null,n.symbol),source:B(e,n.relativePath,n.startLine,n.endLine)}],h=i.referenceContext??2,s=S(e,n,{semantic:i.semantic,semanticEvidence:v}).map(l=>{let a=y(e,l.file,l.line,h,f(n.symbol));return{relativePath:l.file,line:l.line,enclosingSymbol:l.enclosingSymbol,enclosingShort:l.enclosingSymbol?u(l.enclosingSymbol):"(top-level)",provenance:l.provenance,sourceStartLine:a?.startLine??null,sourceEndLine:a?.endLine??null,source:a?.source??null,sourceKind:a?.kind??"unavailable"}}),E=s.map(x);return{definitions:o,referencedBy:E,referenceEvidence:s.map(l=>({relativePath:l.relativePath,line:l.line,provenance:l.provenance,sourceKind:l.sourceKind})),claimSupport:P(s)}}function x(e){return{relativePath:e.relativePath,line:e.line,enclosingSymbol:e.enclosingSymbol,enclosingShort:e.enclosingShort,sourceStartLine:e.sourceStartLine,sourceEndLine:e.sourceEndLine,source:e.source}}function P(e){let t="resolved source-attributed or SCIP-indexed references to this exact symbol",i=["Dynamic dispatch, reflection, generated calls, and unindexed source are outside this scope."],n=e.filter(c=>c.sourceKind!=="complete-call-expression"&&c.sourceKind!=="non-call-reference"),r="direct, statically visible call expressions among the resolved reference sites";return{referenceAbsence:{status:"eligible",scope:t,limitations:i},callsitePredicates:n.length===0?{status:"eligible",scope:r,limitations:i}:{status:"ineligible",scope:r,reason:`${n.length} reference site(s) lack one unambiguous complete call expression.`,followup:L(n)}}}function L(e){let t=[...new Set(e.map(i=>`${i.relativePath}:${i.line+1}`))];return t.length===0||t.length>24?null:`scip-query inspect ${t.map(i=>`--at ${C(i)}`).join(" ")} --view behavior`}function C(e){return`'${e.replaceAll("'","'\\''")}'`}function B(e,t,i,n){let r=d(e,t);if(!r)return null;let o=r.split(`
2
+ `).slice(i,n+1).join(`
3
+ `).trimEnd();return o.length>0?o:null}function K(e,t,i){let n=p(e);if(n&&!A(n))return n;let r=(t??"").trim();return r?m(i)&&!r.endsWith("()")?`${r}()`:r:u(i)}function A(e){return e.startsWith("undefined")||e.includes("|")||e.includes("```")}export{q as a,T as b,R as c};
4
+ //# sourceMappingURL=chunk-ROPJDEJZ.js.map
@@ -1,2 +1,2 @@
1
- import{a as u}from"./chunk-HOENASQM.js";import{b as i}from"./chunk-YXPUP5G2.js";import{existsSync as h}from"fs";import{isAbsolute as p,join as g}from"path";function D(e,n){let t=l(e,n,{allowMultiple:!1})[0]?.relativePath;return t||d(e,n)}function P(e,n){return l(e,n,{allowMultiple:!0}).map(t=>t.relativePath)}function S(e,n){let t=l(e,n,{allowMultiple:!0});return t.length===1?t[0].relativePath:null}function d(e,n){if(!n)return null;let t=n.replace(/\\/g,"/").replace(/^\.\//,""),r=p(t)&&t.startsWith(e.config.projectRoot)?t.slice(e.config.projectRoot.length).replace(/^\/+/,""):t,o=g(e.config.projectRoot,r);return h(o)?r:null}function l(e,n,t){let r=d(e,n);if(r)return i(e,r,t).filter(a=>a.relativePath===r);let o=n.replace(/\\/g,"/").replace(/^\.\//,""),s=p(o)||o.includes("/"),c=i(e,n,{...t,requirePathMatch:s});if(c.length===0){if(s)return[];let a=u(e,n);return!a||e.isIgnored(a.relativePath)?[]:[{relativePath:a.relativePath,score:700}]}return c}export{D as a,P as b,S as c};
2
- //# sourceMappingURL=chunk-EKV5HX33.js.map
1
+ import{a as u}from"./chunk-2USA3S3P.js";import{b as i}from"./chunk-YXPUP5G2.js";import{existsSync as h}from"fs";import{isAbsolute as p,join as g}from"path";function D(e,n){let t=l(e,n,{allowMultiple:!1})[0]?.relativePath;return t||d(e,n)}function P(e,n){return l(e,n,{allowMultiple:!0}).map(t=>t.relativePath)}function S(e,n){let t=l(e,n,{allowMultiple:!0});return t.length===1?t[0].relativePath:null}function d(e,n){if(!n)return null;let t=n.replace(/\\/g,"/").replace(/^\.\//,""),r=p(t)&&t.startsWith(e.config.projectRoot)?t.slice(e.config.projectRoot.length).replace(/^\/+/,""):t,o=g(e.config.projectRoot,r);return h(o)?r:null}function l(e,n,t){let r=d(e,n);if(r)return i(e,r,t).filter(a=>a.relativePath===r);let o=n.replace(/\\/g,"/").replace(/^\.\//,""),s=p(o)||o.includes("/"),c=i(e,n,{...t,requirePathMatch:s});if(c.length===0){if(s)return[];let a=u(e,n);return!a||e.isIgnored(a.relativePath)?[]:[{relativePath:a.relativePath,score:700}]}return c}export{D as a,P as b,S as c};
2
+ //# sourceMappingURL=chunk-RVZC6TJE.js.map
@@ -1,3 +1,3 @@
1
- import{a as b}from"./chunk-3TNRNKAT.js";import{a as D}from"./chunk-WIWY3CRX.js";import{c as C}from"./chunk-CJZXN4NU.js";import{a as I}from"./chunk-W7CXK74K.js";import{c as P}from"./chunk-E73UNJTF.js";import{b as F}from"./chunk-OSSESPDX.js";import{f as M,g as S}from"./chunk-XRYABF57.js";import{d as g}from"./chunk-N2ZSIIGR.js";function re(e,n={}){let t=new C(e).productionCallableDefinitions({scope:n.scope,requireCallableSymbol:!0,includeSuppressed:!0}),r=L(e,t),l=n.search?.trim().toLocaleLowerCase();return t.map(s=>j(e,s,r.get(s.symbolId)??[])).filter(s=>s!==null).map(s=>s.result).filter(s=>!l||T(s).includes(l)).sort(G)}function ie(e,n,o={}){let t=F(e,n);if(!t.match)return{kind:"missing",query:n};if(t.total>1)return{kind:"ambiguous",query:n,total:t.total,candidates:[{symbol:t.match.symbol,shortName:g(t.match.symbol),relativePath:t.match.relativePath,startLine:t.match.startLine},...t.candidates]};let r=new C(e),l=r.definitionsForFile(t.match.relativePath).find(a=>a.symbol===t.match.symbol);if(!l?.isFunctionLike)return{kind:"not-entry",query:n,symbol:t.match.symbol,shortName:g(t.match.symbol),file:t.match.relativePath,reason:"The resolved symbol is not a callable definition."};let s=L(e,[l]),f=j(e,l,s.get(l.symbolId)??[]);if(!f)return{kind:"not-entry",query:n,symbol:l.symbol,shortName:g(l.symbol),file:l.relativePath,reason:"The callable is neither an external root nor an uncalled callable on a detected entry surface."};let m=K(e,r,l),i=new Set(o.expand??[]),c=z(m,i),d=new Set(c.regions.filter(a=>a.expanded).map(a=>a.id)),p=[...i].filter(a=>!d.has(a)).sort();return{kind:"matched",query:n,entry:f.result,regions:c.regions,regionEdges:c.regionEdges,unmatchedExpansions:p,coverage:{completeWithinIndexedStaticCallEdges:!0,completeWithinSelectedStaticEvidence:!0,candidateReachabilityIncluded:m.edges.some(a=>a.evidenceStrength==="candidate"),dynamicDispatchRepresented:!1,symbolCount:m.symbols.length,symbolEdgeCount:m.edges.length,exactSymbolEdgeCount:m.edges.filter(a=>a.evidenceStrength==="exact").length,candidateSymbolEdgeCount:m.edges.filter(a=>a.evidenceStrength==="candidate").length,regionCount:c.regions.length,regionEdgeCount:c.regionEdges.length,externalCallCount:m.externalCalls.length}}}function L(e,n){let o=n.filter(t=>B(e,t.relativePath)||S(e,t.symbol,t.relativePath).length>0);return P(e,o,{semantic:!1,semanticEvidence:I})}function j(e,n,o){let t=$(e,n),r=t.length>0,l=B(e,n.relativePath)&&o.length===0;if(!r&&!l)return null;let s=[...t];return l&&s.push("entry-surface-without-indexed-caller"),{definition:n,result:{symbol:n.symbol,shortName:g(n.symbol),file:n.relativePath,startLine:n.startLine,endLine:n.endLine,documentation:n.documentation,confidence:r?"root":"candidate",evidence:s,indexedCallerCount:o.length}}}function B(e,n){return M(e,n)||/(?:^|\/)entry\.(?:ts|tsx|js|jsx|mjs|cjs)$/.test(n)}function $(e,n){let o=S(e,n.symbol,n.relativePath),t=[];return w(o,["package-surface-file","transitive-package-surface"])&&D(e,n)&&t.push("package-public-export"),o.includes("rust-public-library")&&t.push("rust-public-library"),o.includes("framework-entrypoint")&&t.push("framework-dispatched-export"),w(o,["configured-file","configured-path-prefix","configured-qualified-var","configured-symbol-pattern"])&&t.push("configured-entry-root"),t}function w(e,n){return n.some(o=>e.includes(o))}function T(e){return[e.symbol,e.shortName,e.file,e.documentation??"",...e.evidence].join(`
1
+ import{a as b}from"./chunk-3TNRNKAT.js";import{a as D}from"./chunk-2GJSD5GY.js";import{c as C}from"./chunk-2BMSSRBH.js";import{a as I}from"./chunk-BJWFVAA5.js";import{h as P}from"./chunk-U3SXIMII.js";import{b as F}from"./chunk-F5GSBHC6.js";import{f as M,g as S}from"./chunk-NJQISBL4.js";import{d as g}from"./chunk-C7C6AKAT.js";function re(e,n={}){let t=new C(e).productionCallableDefinitions({scope:n.scope,requireCallableSymbol:!0,includeSuppressed:!0}),r=L(e,t),l=n.search?.trim().toLocaleLowerCase();return t.map(s=>j(e,s,r.get(s.symbolId)??[])).filter(s=>s!==null).map(s=>s.result).filter(s=>!l||T(s).includes(l)).sort(G)}function ie(e,n,o={}){let t=F(e,n);if(!t.match)return{kind:"missing",query:n};if(t.total>1)return{kind:"ambiguous",query:n,total:t.total,candidates:[{symbol:t.match.symbol,shortName:g(t.match.symbol),relativePath:t.match.relativePath,startLine:t.match.startLine},...t.candidates]};let r=new C(e),l=r.definitionsForFile(t.match.relativePath).find(a=>a.symbol===t.match.symbol);if(!l?.isFunctionLike)return{kind:"not-entry",query:n,symbol:t.match.symbol,shortName:g(t.match.symbol),file:t.match.relativePath,reason:"The resolved symbol is not a callable definition."};let s=L(e,[l]),f=j(e,l,s.get(l.symbolId)??[]);if(!f)return{kind:"not-entry",query:n,symbol:l.symbol,shortName:g(l.symbol),file:l.relativePath,reason:"The callable is neither an external root nor an uncalled callable on a detected entry surface."};let m=K(e,r,l),i=new Set(o.expand??[]),c=z(m,i),d=new Set(c.regions.filter(a=>a.expanded).map(a=>a.id)),p=[...i].filter(a=>!d.has(a)).sort();return{kind:"matched",query:n,entry:f.result,regions:c.regions,regionEdges:c.regionEdges,unmatchedExpansions:p,coverage:{completeWithinIndexedStaticCallEdges:!0,completeWithinSelectedStaticEvidence:!0,candidateReachabilityIncluded:m.edges.some(a=>a.evidenceStrength==="candidate"),dynamicDispatchRepresented:!1,symbolCount:m.symbols.length,symbolEdgeCount:m.edges.length,exactSymbolEdgeCount:m.edges.filter(a=>a.evidenceStrength==="exact").length,candidateSymbolEdgeCount:m.edges.filter(a=>a.evidenceStrength==="candidate").length,regionCount:c.regions.length,regionEdgeCount:c.regionEdges.length,externalCallCount:m.externalCalls.length}}}function L(e,n){let o=n.filter(t=>B(e,t.relativePath)||S(e,t.symbol,t.relativePath).length>0);return P(e,o,{semantic:!1,semanticEvidence:I})}function j(e,n,o){let t=$(e,n),r=t.length>0,l=B(e,n.relativePath)&&o.length===0;if(!r&&!l)return null;let s=[...t];return l&&s.push("entry-surface-without-indexed-caller"),{definition:n,result:{symbol:n.symbol,shortName:g(n.symbol),file:n.relativePath,startLine:n.startLine,endLine:n.endLine,documentation:n.documentation,confidence:r?"root":"candidate",evidence:s,indexedCallerCount:o.length}}}function B(e,n){return M(e,n)||/(?:^|\/)entry\.(?:ts|tsx|js|jsx|mjs|cjs)$/.test(n)}function $(e,n){let o=S(e,n.symbol,n.relativePath),t=[];return w(o,["package-surface-file","transitive-package-surface"])&&D(e,n)&&t.push("package-public-export"),o.includes("rust-public-library")&&t.push("rust-public-library"),o.includes("framework-entrypoint")&&t.push("framework-dispatched-export"),w(o,["configured-file","configured-path-prefix","configured-qualified-var","configured-symbol-pattern"])&&t.push("configured-entry-root"),t}function w(e,n){return n.some(o=>e.includes(o))}function T(e){return[e.symbol,e.shortName,e.file,e.documentation??"",...e.evidence].join(`
2
2
  `).toLocaleLowerCase()}function G(e,n){return N(e.confidence)-N(n.confidence)||e.file.localeCompare(n.file)||e.startLine-n.startLine||e.symbol.localeCompare(n.symbol)}function N(e){return e==="root"?0:1}function K(e,n,o){let t=new Map([[o.symbol,0]]),r=new Map,l=new Map([[o.symbol,o]]),s=new Map,f=new Map,m=[o];for(;m.length>0;){let i=n.calleeMap(m,{additive:!1,semantic:!1}),c=[];for(let d of m){let p=t.get(d.symbol)??0;r.set(d.symbol,k(d,p));for(let a of i.get(d.symbolId)??[]){let y=W(n,a,l);if(!y){let R=O(d,a);f.set(J(R),R);continue}let u=p+1,h=t.get(y.symbol);(h===void 0||u<h)&&t.set(y.symbol,u),r.set(y.symbol,k(y,Math.min(u,h??u)));let v=q(d,y,a);s.set(H(v),v),h===void 0&&c.push(y)}}m=c}return{symbols:[...r.values()].sort(Q),edges:[...s.values()].sort(U),externalCalls:[...f.values()].sort(V)}}function W(e,n,o){let t=o.get(n.symbol);if(t)return t;let r=e.definitionsForFile(n.file).find(l=>l.symbol===n.symbol)??null;return r&&o.set(r.symbol,r),r}function k(e,n){return{symbol:e.symbol,shortName:g(e.symbol),file:e.relativePath,depth:n}}function q(e,n,o){return{fromSymbol:e.symbol,fromShortName:g(e.symbol),fromFile:e.relativePath,toSymbol:n.symbol,toShortName:g(n.symbol),toFile:n.relativePath,source:o.source,evidenceStrength:o.source==="scip-chunk"?"candidate":"exact"}}function O(e,n){return{fromSymbol:e.symbol,fromShortName:g(e.symbol),fromFile:e.relativePath,toSymbol:n.symbol,toShortName:g(n.symbol),reportedFile:n.file,source:n.source,evidenceStrength:n.source==="scip-chunk"?"candidate":"exact"}}function z(e,n){let o=b(e.symbols,i=>i.file),t=b(e.edges.filter(i=>i.fromFile===i.toFile),i=>i.fromFile),r=b(e.externalCalls,i=>i.fromFile),l=A(e.edges.filter(i=>i.fromFile!==i.toFile)),s=b(l,i=>i.toRegionId),f=b(l,i=>i.fromRegionId);return{regions:[...o.entries()].map(([i,c])=>{let d=x(i),p=n.has(d),a=t.get(i)??[],y=r.get(i)??[];return{id:d,file:i,minDepth:Math.min(...c.map(u=>u.depth)),symbolCount:c.length,internalEdgeCount:a.length,externalCallCount:y.length,incomingRegionIds:E((s.get(d)??[]).map(u=>u.fromRegionId)),outgoingRegionIds:E((f.get(d)??[]).map(u=>u.toRegionId)),expanded:p,symbols:p?c:[],internalEdges:p?a:[],externalCalls:p?y:[]}}).sort((i,c)=>i.minDepth-c.minDepth||i.file.localeCompare(c.file)),regionEdges:l}}function A(e){let n=new Map;for(let o of e){let t=`${o.fromFile}\0${o.toFile}`,r=n.get(t)??[];r.push(o),n.set(t,r)}return[...n.values()].map(o=>{let t=o[0];return{fromRegionId:x(t.fromFile),fromFile:t.fromFile,toRegionId:x(t.toFile),toFile:t.toFile,callCount:o.length,exactCallCount:o.filter(r=>r.evidenceStrength==="exact").length,candidateCallCount:o.filter(r=>r.evidenceStrength==="candidate").length,fromSymbols:E(o.map(r=>r.fromShortName)),toSymbols:E(o.map(r=>r.toShortName)),evidence:E(o.map(r=>r.source))}}).sort((o,t)=>o.fromFile.localeCompare(t.fromFile)||o.toFile.localeCompare(t.toFile))}function x(e){return`file:${e}`}function E(e){return[...new Set(e)].sort()}function H(e){return`${e.fromSymbol}\0${e.toSymbol}`}function J(e){return`${e.fromSymbol}\0${e.toSymbol}`}function Q(e,n){return e.depth-n.depth||e.file.localeCompare(n.file)||e.symbol.localeCompare(n.symbol)}function U(e,n){return e.fromFile.localeCompare(n.fromFile)||e.fromSymbol.localeCompare(n.fromSymbol)||e.toSymbol.localeCompare(n.toSymbol)}function V(e,n){return e.fromFile.localeCompare(n.fromFile)||e.fromSymbol.localeCompare(n.fromSymbol)||e.toSymbol.localeCompare(n.toSymbol)}export{re as a,ie as b};
3
- //# sourceMappingURL=chunk-XFA4SSO3.js.map
3
+ //# sourceMappingURL=chunk-S4QZBKSR.js.map
@@ -1,2 +1,2 @@
1
- import{N as c}from"./chunk-ZOHS7AQV.js";import{h as u,l as p}from"./chunk-FESCRNVV.js";import{d as a}from"./chunk-JWTGMPIT.js";var g=a("suppression-inventory",{clearGroups:["whole-project"]});function C(t){return g.get(t,()=>y(t))}function y(t){let e={dead:0,stale:0,wrapper:0,passthrough:0,drift:0,extract:0,similar:0,twin:0,uncategorized:0},n=new Map,i=0;for(let r of c(t)){let o=u(t,r);if(!(!o||!o.includes("scip-query")))for(let f of o.split(/\r?\n/)){let s=p(f);if(s===null)continue;i+=1,n.set(r,(n.get(r)??0)+1);let d=l(s);e[d]+=1}}for(let r of t.config.suppressions??[])r.expiresAt&&Date.parse(r.expiresAt)<=Date.now()||(i+=1,r.file&&n.set(r.file,(n.get(r.file)??0)+1),e[l(r.check)]+=1);return{total:i,byCategory:e,byFile:n}}function l(t){if(!t)return"uncategorized";let e=t.toLowerCase();return e==="dead-code"||e==="new-dead"?"dead":e.includes("twin")?"twin":e.includes("similar")||e.includes("duplicate")?"similar":e.includes("wrapper")?"wrapper":e.includes("passthrough")?"passthrough":e.includes("drift")?"drift":e.includes("extract")?"extract":e.includes("stale")?"stale":"uncategorized"}export{C as a};
2
- //# sourceMappingURL=chunk-D2DHWI3D.js.map
1
+ import{O as c}from"./chunk-ZLMXIQLC.js";import{h as u,l as p}from"./chunk-ETC674NS.js";import{d as a}from"./chunk-KNLQGXVH.js";var g=a("suppression-inventory",{clearGroups:["whole-project"]});function C(t){return g.get(t,()=>y(t))}function y(t){let e={dead:0,stale:0,wrapper:0,passthrough:0,drift:0,extract:0,similar:0,twin:0,uncategorized:0},n=new Map,i=0;for(let r of c(t)){let o=u(t,r);if(!(!o||!o.includes("scip-query")))for(let f of o.split(/\r?\n/)){let s=p(f);if(s===null)continue;i+=1,n.set(r,(n.get(r)??0)+1);let d=l(s);e[d]+=1}}for(let r of t.config.suppressions??[])r.expiresAt&&Date.parse(r.expiresAt)<=Date.now()||(i+=1,r.file&&n.set(r.file,(n.get(r.file)??0)+1),e[l(r.check)]+=1);return{total:i,byCategory:e,byFile:n}}function l(t){if(!t)return"uncategorized";let e=t.toLowerCase();return e==="dead-code"||e==="new-dead"?"dead":e.includes("twin")?"twin":e.includes("similar")||e.includes("duplicate")?"similar":e.includes("wrapper")?"wrapper":e.includes("passthrough")?"passthrough":e.includes("drift")?"drift":e.includes("extract")?"extract":e.includes("stale")?"stale":"uncategorized"}export{C as a};
2
+ //# sourceMappingURL=chunk-SCPMZ73U.js.map
@@ -1,4 +1,4 @@
1
- import{a as c}from"./chunk-BRV7PIFF.js";import{a as r}from"./chunk-OSSESPDX.js";import{b as l}from"./chunk-TEBQMNVI.js";import{d as m}from"./chunk-N2ZSIIGR.js";function N(n,t){let e=r(n,t);if(!e)return[];let s=n.get(`SELECT COUNT(DISTINCT c.document_id) AS file_count
1
+ import{a as c}from"./chunk-NSM5IEVW.js";import{a as r}from"./chunk-F5GSBHC6.js";import{b as l}from"./chunk-BOW7SSQH.js";import{d as m}from"./chunk-C7C6AKAT.js";function N(n,t){let e=r(n,t);if(!e)return[];let s=n.get(`SELECT COUNT(DISTINCT c.document_id) AS file_count
2
2
  FROM mentions m
3
3
  JOIN chunks c ON m.chunk_id = c.id
4
4
  JOIN (
@@ -70,4 +70,4 @@ import{a as c}from"./chunk-BRV7PIFF.js";import{a as r}from"./chunk-OSSESPDX.js";
70
70
  GROUP BY d.id
71
71
  ORDER BY symbol_count DESC
72
72
  LIMIT ?`,...i,e).filter(d=>!n.isIgnored(d.relative_path)).map(d=>({name:d.relative_path,count:d.symbol_count}))}export{N as a,a as b,u as c,g as d,I as e,R as f};
73
- //# sourceMappingURL=chunk-PZL5T7SU.js.map
73
+ //# sourceMappingURL=chunk-SIAP5RGI.js.map
@@ -1,3 +1,3 @@
1
- import{a as R}from"./chunk-W7CXK74K.js";import{o as h}from"./chunk-DYGHBZ2N.js";import{a as g}from"./chunk-OSSESPDX.js";import{h as d}from"./chunk-N2ZSIIGR.js";import{a as m}from"./chunk-ZOHS7AQV.js";import{h as p}from"./chunk-FESCRNVV.js";function D(t,r,n={}){let e=g(t,r);if(!e)return[];let l=!d(e.symbol)&&!t.isIgnored(e.relativePath)?[{relativePath:e.relativePath,line:e.startLine}]:[],c=h(t,e,{semantic:n.semantic,semanticEvidence:R}).map(s=>({relativePath:s.file,line:s.line})),o=b(t,e),f=new Set,a=[];for(let s of[...l,...c,...o]){let u=`${s.relativePath}:${s.line}`;f.has(u)||(f.add(u),a.push(s))}return a}function b(t,r){if(!r.relativePath.endsWith(".rb"))return[];let n=S(r.symbol);if(n.length===0)return[];let e=[];for(let i of m(t,{extensions:[".rb"],includeIgnored:!1})){let l=p(t,i);if(!l)continue;let c=l.split(`
1
+ import{a as R}from"./chunk-BJWFVAA5.js";import{o as h}from"./chunk-SKKXTABJ.js";import{a as g}from"./chunk-F5GSBHC6.js";import{j as d}from"./chunk-C7C6AKAT.js";import{a as m}from"./chunk-ZLMXIQLC.js";import{h as p}from"./chunk-ETC674NS.js";function D(t,r,n={}){let e=g(t,r);if(!e)return[];let l=!d(e.symbol)&&!t.isIgnored(e.relativePath)?[{relativePath:e.relativePath,line:e.startLine}]:[],c=h(t,e,{semantic:n.semantic,semanticEvidence:R}).map(s=>({relativePath:s.file,line:s.line})),o=b(t,e),f=new Set,a=[];for(let s of[...l,...c,...o]){let u=`${s.relativePath}:${s.line}`;f.has(u)||(f.add(u),a.push(s))}return a}function b(t,r){if(!r.relativePath.endsWith(".rb"))return[];let n=S(r.symbol);if(n.length===0)return[];let e=[];for(let i of m(t,{extensions:[".rb"],includeIgnored:!1})){let l=p(t,i);if(!l)continue;let c=l.split(`
2
2
  `);for(let o=0;o<c.length;o++){let f=c[o]??"";n.some(a=>new RegExp(`@${a}\\b|\\b${a}:`).test(f))&&e.push({relativePath:i,line:o})}}return e}function S(t){let n=(t.split(":").pop()??t).replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9_]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),e=n.split("_").filter(Boolean),i=new Set;return n&&i.add(n),e.length>=1&&i.add(e[e.length-1]),e.length>=2&&i.add(e.slice(-2).join("_")),[...i]}export{D as a};
3
- //# sourceMappingURL=chunk-7IWV2EG3.js.map
3
+ //# sourceMappingURL=chunk-SIX4RFR3.js.map
@@ -1,4 +1,4 @@
1
- import{d as z}from"./chunk-KK7GPALL.js";import{d as y}from"./chunk-OSSESPDX.js";import{A as $,c as E,e as b,t as O}from"./chunk-N2ZSIIGR.js";import{a as A,b as F,n as L,y as R}from"./chunk-ODDUPDP7.js";import{N as v,z as T}from"./chunk-ZOHS7AQV.js";import{h as p}from"./chunk-FESCRNVV.js";import{c as h,d as k}from"./chunk-JWTGMPIT.js";import{b as P,d as g}from"./chunk-N5B2NILC.js";function _(e,n,t,r={}){if(!t)return[];let i=p(e,n);return i?i.indexOf(t)===-1?[]:(N(e,n).get(t)??[]).filter(s=>!X(s,r)):[]}function X(e,n){return typeof n.excludeStartLine=="number"&&typeof n.excludeEndLine=="number"&&e>=n.excludeStartLine&&e<=n.excludeEndLine}var q=h("file-identifiers",{clearGroups:["whole-project","source-file"]});function B(e,n){let t=L(e,n);return t?t.fileIdentifiers:q.get(e,n,()=>new Set(N(e,n).keys()))}var K=h("file-ident-lines",{clearGroups:["whole-project","source-file"]});function N(e,n){let t=L(e,n);return t?t.identifierLineMap:K.get(e,n,()=>ee(e,n))}var Q=h("file-idents-by-line",{clearGroups:["whole-project","source-file"]});function Re(e,n){let t=L(e,n);return t?t.identifiersByLine:Q.get(e,n,()=>{let r=N(e,n),i=0;for(let s of r.values()){let c=s[s.length-1];c!==void 0&&c>i&&(i=c)}let o=new Array(i+1);for(let s=0;s<=i;s+=1)o[s]=new Set;for(let[s,c]of r)for(let a of c)o[a].add(s);return o})}function ee(e,n){let t=new Map,r=(c,a)=>{let l=t.get(c);if(!l){t.set(c,[a]);return}l[l.length-1]!==a&&l.push(a)},i=p(e,n);if(!i)return t;let o=F(i).split(/\r?\n/),s=/\b([A-Za-z_$][\w$]*)\b/g;for(let c=0;c<o.length;c+=1){let a=o[c]??"";for(let l of a.matchAll(s))l[1]&&r(l[1],c)}return t}function we(e,n){let t=j(e);return t?n.filter(r=>j(r.file)===t):n}function De(e,n,t,r,i){let o=R(e,n);if(r){let f=i?.match(/^[A-Za-z_$][\w$]*/u)?.[0];if(!f)return null;let d=new Set(o.filter(u=>u.localName===f||u.importedName===f).map(u=>u.sourcePath).filter(u=>!!u));for(let u of t)for(let S of d)if(g(S,u.file))return u;if(f==="this"||f==="self"||f==="cls"){let u=t.filter(S=>S.file===n&&E(S.symbol)!==null);if(u.length===1)return u[0]}let m=te(p(e,n)??"",f);if(m.size===0)return null;let V=new Set(o.filter(u=>m.has(u.localName??u.importedName)).map(u=>u.sourcePath).filter(u=>!!u)),D=t.filter(u=>m.has(E(u.symbol)??"")&&(u.file===n||[...V].some(S=>g(S,u.file))));return D.length===1?D[0]:null}let s=t.filter(f=>E(f.symbol)===null),c=s.find(f=>f.file===n);if(c)return c;let a=b(t[0].symbol),l=o.filter(f=>f.kind!=="namespace"&&f.kind!=="side-effect"&&(f.localName===a||f.localName===null&&f.importedName===a));if(l.length>0){let f=s.filter(d=>l.some(m=>m.sourcePath!==null&&g(m.sourcePath,d.file)));return f.length===1?f[0]:null}return s.length===1?s[0]:null}function te(e,n){let t=n.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),r=new Set,i=[new RegExp(`\\b${t}\\s*:\\s*([A-Za-z_$][\\w$]*)`,"gu"),new RegExp(`\\b${t}\\s*=\\s*(?:new\\s+)?([A-Za-z_$][\\w$]*)\\s*\\(`,"gu")];for(let o of i)for(let s of e.matchAll(o))r.add(s[1]);return r.size===1?r:new Set}function j(e){let n=T(e);return n?n==="typescript"||n==="tsx"||n==="javascript"?"javascript-family":n:null}var ne=k("global-leaf-index",{clearGroups:["whole-project"]});function M(e){return ne.get(e,()=>{let n=e.all(`SELECT gs.id, gs.symbol,
1
+ import{d as z}from"./chunk-KK7GPALL.js";import{d as y}from"./chunk-F5GSBHC6.js";import{C as $,c as E,e as b,v as O}from"./chunk-C7C6AKAT.js";import{a as A,b as F,n as L,y as R}from"./chunk-RBAD4GJ2.js";import{A as T,O as v}from"./chunk-ZLMXIQLC.js";import{h as p}from"./chunk-ETC674NS.js";import{c as h,d as k}from"./chunk-KNLQGXVH.js";import{b as P,d as g}from"./chunk-JZ2A7LDM.js";function _(e,n,t,r={}){if(!t)return[];let i=p(e,n);return i?i.indexOf(t)===-1?[]:(N(e,n).get(t)??[]).filter(s=>!X(s,r)):[]}function X(e,n){return typeof n.excludeStartLine=="number"&&typeof n.excludeEndLine=="number"&&e>=n.excludeStartLine&&e<=n.excludeEndLine}var q=h("file-identifiers",{clearGroups:["whole-project","source-file"]});function B(e,n){let t=L(e,n);return t?t.fileIdentifiers:q.get(e,n,()=>new Set(N(e,n).keys()))}var K=h("file-ident-lines",{clearGroups:["whole-project","source-file"]});function N(e,n){let t=L(e,n);return t?t.identifierLineMap:K.get(e,n,()=>ee(e,n))}var Q=h("file-idents-by-line",{clearGroups:["whole-project","source-file"]});function Re(e,n){let t=L(e,n);return t?t.identifiersByLine:Q.get(e,n,()=>{let r=N(e,n),i=0;for(let s of r.values()){let c=s[s.length-1];c!==void 0&&c>i&&(i=c)}let o=new Array(i+1);for(let s=0;s<=i;s+=1)o[s]=new Set;for(let[s,c]of r)for(let a of c)o[a].add(s);return o})}function ee(e,n){let t=new Map,r=(c,a)=>{let l=t.get(c);if(!l){t.set(c,[a]);return}l[l.length-1]!==a&&l.push(a)},i=p(e,n);if(!i)return t;let o=F(i).split(/\r?\n/),s=/\b([A-Za-z_$][\w$]*)\b/g;for(let c=0;c<o.length;c+=1){let a=o[c]??"";for(let l of a.matchAll(s))l[1]&&r(l[1],c)}return t}function we(e,n){let t=j(e);return t?n.filter(r=>j(r.file)===t):n}function De(e,n,t,r,i){let o=R(e,n);if(r){let f=i?.match(/^[A-Za-z_$][\w$]*/u)?.[0];if(!f)return null;let d=new Set(o.filter(u=>u.localName===f||u.importedName===f).map(u=>u.sourcePath).filter(u=>!!u));for(let u of t)for(let S of d)if(g(S,u.file))return u;if(f==="this"||f==="self"||f==="cls"){let u=t.filter(S=>S.file===n&&E(S.symbol)!==null);if(u.length===1)return u[0]}let m=te(p(e,n)??"",f);if(m.size===0)return null;let V=new Set(o.filter(u=>m.has(u.localName??u.importedName)).map(u=>u.sourcePath).filter(u=>!!u)),D=t.filter(u=>m.has(E(u.symbol)??"")&&(u.file===n||[...V].some(S=>g(S,u.file))));return D.length===1?D[0]:null}let s=t.filter(f=>E(f.symbol)===null),c=s.find(f=>f.file===n);if(c)return c;let a=b(t[0].symbol),l=o.filter(f=>f.kind!=="namespace"&&f.kind!=="side-effect"&&(f.localName===a||f.localName===null&&f.importedName===a));if(l.length>0){let f=s.filter(d=>l.some(m=>m.sourcePath!==null&&g(m.sourcePath,d.file)));return f.length===1?f[0]:null}return s.length===1?s[0]:null}function te(e,n){let t=n.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),r=new Set,i=[new RegExp(`\\b${t}\\s*:\\s*([A-Za-z_$][\\w$]*)`,"gu"),new RegExp(`\\b${t}\\s*=\\s*(?:new\\s+)?([A-Za-z_$][\\w$]*)\\s*\\(`,"gu")];for(let o of i)for(let s of e.matchAll(o))r.add(s[1]);return r.size===1?r:new Set}function j(e){let n=T(e);return n?n==="typescript"||n==="tsx"||n==="javascript"?"javascript-family":n:null}var ne=k("global-leaf-index",{clearGroups:["whole-project"]});function M(e){return ne.get(e,()=>{let n=e.all(`SELECT gs.id, gs.symbol,
2
2
  COALESCE(der_doc.relative_path, mention_doc.relative_path) AS relative_path
3
3
  FROM global_symbols gs
4
4
  LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
@@ -13,4 +13,4 @@ import{d as z}from"./chunk-KK7GPALL.js";import{d as y}from"./chunk-OSSESPDX.js";
13
13
  ) mention_doc ON mention_doc.symbol_id = gs.id
14
14
  WHERE 1 = 1
15
15
  ${e.symbolNoiseFor("gs")}`),t=new Map;for(let r of n){if(!r.relative_path||e.isIgnored(r.relative_path))continue;let i=b(r.symbol);if(!i)continue;let o=t.get(i);o||(o=[],t.set(i,o)),o.some(s=>s.symbolId===r.id)||o.push({symbol:r.symbol,symbolId:r.id,file:r.relative_path})}return t})}var re=h("source-import-paths-by-local-name",{clearGroups:["whole-project","source-file"]});function Z(e,n){let t=P(n);return re.get(e,t,()=>ie(e,t))}function ie(e,n){let t=new Map;for(let r of R(e,n)){if(!r.sourcePath)continue;let i=r.localName??r.importedName;if(i&&G(t,i,r.sourcePath),r.kind==="namespace")for(let o of r.usedMembers)G(t,o,r.sourcePath)}return t}function G(e,n,t){let r=e.get(n);r||(r=new Set,e.set(n,r)),r.add(t)}var H=/[A-Za-z_$][A-Za-z0-9_$]*/g,U=/^[A-Za-z_$][A-Za-z0-9_$]*$/,oe=512;function C(e){let n=[],t=!1;for(let r of e)r&&(t=!0,U.test(r)||n.push(r));return{candidateNames:e,hasUsableCandidate:t,nonIdentifierNames:n}}function J(e,n){let t=se(n)?n:C(n);if(t.candidateNames.size===0||!t.hasUsableCandidate)return!0;if(t.candidateNames.size<=oe){for(let i of t.candidateNames)if(i){if(U.test(i)){if(ae(i).test(e))return!0;continue}if(e.includes(i))return!0}return!1}H.lastIndex=0;let r;for(;(r=H.exec(e))!==null;)if(t.candidateNames.has(r[0]))return!0;for(let i of t.nonIdentifierNames)if(e.includes(i))return!0;return!1}function se(e){return"candidateNames"in e}function ae(e){return new RegExp(`(?<![A-Za-z_$0-9])${A(e)}(?![A-Za-z_$0-9])`)}function w(e,n,t){let r=M(e).get(t);if(!r||r.length===0)return[];if(r.length===1)return[I(r[0])];let i=r.filter(a=>a.file===n);if(i.length>0)return i.map(I);let o=Z(e,n),s=o.get(t);if(s)for(let a of s){let l=r.filter(f=>g(a,f.file));if(l.length>0)return l.map(I)}let c=new Set;for(let a of o.values())for(let l of a)c.add(l);for(let a of c){let l=r.filter(f=>g(a,f.file));if(l.length>0&&l.length===r.length)return l.map(I)}return[]}function Ve(e,n,t){let r=w(e,n,t);if(r.length>0)return r;let i=M(e).get(t);return!i||i.length===0?[]:i.map(I)}function Y(e,n,t={}){let r=ce(e,n);if(!r)return[];let i=y(e,n);if(t.semantic!==!1&&t.semanticEvidence){let s=t.semanticEvidence.references(e,{...i,leaf:r.identifier,parentTypeName:null,isFunctionLike:!1,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:null});if(s.length>0){let c=new Map;for(let a of s){let l=c.get(a.file)??[];l.push(a.line),c.set(a.file,l)}return x(e,c)}}let o=new Map;for(let s of v(e)){let c=le(e,r,s);c.length>0&&o.set(s,c)}return x(e,o)}function ce(e,n){let t=y(e,n);if(!t)return null;let r=b(t.symbol);return r?{symbolId:t.symbolId,relativePath:t.relativePath,startLine:t.startLine,endLine:t.endLine,identifier:r}:null}function le(e,n,t){let r=p(e,t);return!r||r.indexOf(n.identifier)===-1?[]:t!==n.relativePath&&!w(e,t,n.identifier).some(o=>o.symbolId===n.symbolId)?[]:_(e,t,n.identifier,t===n.relativePath?{excludeStartLine:n.startLine,excludeEndLine:n.endLine}:{})}function Xe(e,n,t={}){let r=new Map;for(let a of n){if(!a.leaf)continue;let l=r.get(a.leaf)??[];l.push(a),r.set(a.leaf,l)}if(r.size===0)return new Map;let i=new Set(n.map(a=>a.symbolId)),o=new Set(r.keys()),s=C(o),c=new Map;for(let a of v(e)){if(t.skipPath?.(a)||!J(p(e,a),s))continue;let l=B(e,a);if(l.size!==0){for(let f of l)if(r.has(f))for(let d of w(e,a,f)){if(!i.has(d.symbolId)||a===d.relativePath)continue;let m=c.get(d.symbolId);m||(m=new Set,c.set(d.symbolId,m)),m.add(a)}}}return c}function I(e){return{symbolId:e.symbolId,symbol:e.symbol,relativePath:e.file}}function x(e,n){let t=[],r=new Set;for(let[i,o]of n){let s=O(e,i);for(let c of o){let a=$(s,c),l=`${i}|${c}|${a?.symbol??""}`;r.has(l)||(r.add(l),t.push({file:i,line:c,enclosingSymbol:a?.symbol??null}))}}return t}function fe(e,n){return ue(e,[n]).get(n.symbolId)??[]}function ue(e,n){let t=n.map(o=>({symbolId:o.symbolId,prelude:Se(e,o)})).filter(o=>o.prelude!==null),r=pe(e,t.map(o=>o.symbolId)),i=new Map;for(let{symbolId:o,prelude:s}of t){let c=de(e,r.get(o)??new Map,s.match,s.identifier);i.set(o,x(e,c))}return i}function rt(e,n,t={}){return me(e,n,t).map(r=>({file:r.file,line:r.line,enclosingSymbol:r.enclosingSymbol}))}function me(e,n,t={}){let r=Y(e,n,{semantic:t.semantic,semanticEvidence:t.semanticEvidence}),i=r.length>0?W(r,"source-attribution"):W(fe(e,n),"scip-reference-chunk");return t.includeIgnored===!0?i:i.filter(o=>!e.isIgnored(o.file))}function W(e,n){return e.map(t=>({...t,provenance:n}))}function de(e,n,t,r){let i=new Map;for(let[o,s]of n)i.set(o,ge(e,o,s,t,r));return i}function pe(e,n){let t=new Map;for(let r of z(e,n)){if(e.isIgnored(r.relative_path))continue;let i=t.get(r.symbol_id);i||(i=new Map,t.set(r.symbol_id,i));let o=i.get(r.relative_path);o||(o=[],i.set(r.relative_path,o)),o.push({start_line:r.chunk_start,end_line:r.chunk_end})}return t}function ge(e,n,t,r,i){let o=n===r.relativePath?{excludeStartLine:r.startLine,excludeEndLine:r.endLine}:{},s=i?_(e,n,i,o):[];return t.flatMap(c=>be(s,c))}function be(e,n){let t=e.filter(r=>r>=n.start_line&&r<=n.end_line);return t.length>0?t:[n.start_line]}function Se(e,n){let t=y(e,n);return t?{match:t,identifier:b(t.symbol)||null}:null}export{_ as a,N as b,Re as c,we as d,De as e,M as f,C as g,J as h,Z as i,w as j,Ve as k,Xe as l,fe as m,ue as n,rt as o,me as p};
16
- //# sourceMappingURL=chunk-DYGHBZ2N.js.map
16
+ //# sourceMappingURL=chunk-SKKXTABJ.js.map
@@ -1,2 +1,2 @@
1
- import{a as P,b as y}from"./chunk-2E7CX53V.js";import{a as C,c as b,e as r,f}from"./chunk-B3X6KU75.js";import{a as g,b as h,c as k}from"./chunk-KMVGRIO2.js";import{P as v}from"./chunk-ZOHS7AQV.js";function L(e,i={}){let{minSimilarity:o=.62,minTokens:n=8,limit:c=20,scope:l,scanLimit:u,filePattern:m,focusFiles:d}=i,s=B(e,{scope:l,minTokens:n,scanLimit:u}),p=P(s,t=>t.tokens);return y({profiles:s,limit:c,filePattern:m,focusFiles:d,candidateIndex:p,profile:{name:"vue-component-duplicates"},compare:(t,a)=>V(t,a,o),sort:(t,a)=>a.similarity-t.similarity||t.fileA.localeCompare(a.fileA)||t.fileB.localeCompare(a.fileB)})}function B(e,i){return v(e).vueProfiles({scope:i.scope,minTemplateTokens:i.minTokens,scanLimit:i.scanLimit}).map(o=>({file:o.file,tokens:o.templateTokens,loc:T(o)}))}function T(e){return e.totalLines}function V(e,i,o){let n=g(e.tokens,i.tokens);if(n.size<6||!R(n))return null;let c=k(e.tokens,i.tokens);if(c<o)return null;let l=r(n,"component:"),u=r(n,"prop:"),m=r(n,"event:"),d=r(n,"directive:"),s=r(n,"slot:"),p=r(n,"id:"),t=S({sharedComponents:l,sharedProps:u,sharedEvents:m,sharedDirectives:d,sharedSlots:s,sharedIdentifiers:p});return{fileA:e.file,fileB:i.file,similarity:c,tokenCountA:e.tokens.size,tokenCountB:i.tokens.size,sharedTokens:f(n),sharedComponents:l,sharedProps:u,sharedEvents:m,sharedDirectives:d,sharedSlots:s,sharedIdentifiers:p,evidenceClass:t.evidenceClass,actionTier:t.actionTier,evidenceClassReasons:t.reasons,recommendation:t.recommendation,uniqueToA:f(h(e.tokens,i.tokens)).slice(0,25),uniqueToB:f(h(i.tokens,e.tokens)).slice(0,25),locA:e.loc,locB:i.loc}}function R(e){let i=0,o=0;for(let n of e)n.startsWith("component:")&&(i+=1),(n.startsWith("prop:")||n.startsWith("event:")||n.startsWith("directive:")||n.startsWith("slot:"))&&(o+=1);return b([{name:"component",count:i},{name:"behavior",count:o}],[{min:{component:1},reason:"shared custom component"},{min:{behavior:3},reason:"shared Vue template structure"}]).pass}function S(e){return C({genericWords:x,primitiveGroups:[{values:e.sharedProps,reasonPrefix:"shared props",bucket:"generic"},{values:e.sharedEvents,reasonPrefix:"shared events",bucket:"generic"},{values:e.sharedDirectives,reasonPrefix:"shared directives",bucket:"generic"},{values:e.sharedSlots,reasonPrefix:"shared slots",bucket:"generic"}],nameGroups:[{names:e.sharedComponents,label:"shared component",fallbackBucket:"generic"},{names:e.sharedIdentifiers,label:"shared identifier",fallbackBucket:"generic"}],recommendation:w})}function w(e){switch(e){case"domain-behavior":case"mixed":return"Review for a shared component or feature-specific Vue primitive around the named domain structure.";case"shared-abstraction":return"Review the existing shared component usage first; extract only if duplicated structure remains outside it.";case"generic-workflow-scaffolding":return"Generic structural overlap \u2014 verify intent before consolidating."}}var x=new Set(["actions","app","button","card","content","container","dialog","field","form","header","input","item","label","layout","list","modal","page","panel","row","section","shell","table","text","toolbar","ui","value","view","wrapper"]);export{L as a};
2
- //# sourceMappingURL=chunk-F7DY272B.js.map
1
+ import{a as P,b as y}from"./chunk-V2RBODHL.js";import{a as C,c as b,e as r,f}from"./chunk-B3X6KU75.js";import{a as g,b as h,c as k}from"./chunk-KMVGRIO2.js";import{Q as v}from"./chunk-ZLMXIQLC.js";function L(e,i={}){let{minSimilarity:o=.62,minTokens:n=8,limit:c=20,scope:l,scanLimit:u,filePattern:m,focusFiles:d}=i,s=B(e,{scope:l,minTokens:n,scanLimit:u}),p=P(s,t=>t.tokens);return y({profiles:s,limit:c,filePattern:m,focusFiles:d,candidateIndex:p,profile:{name:"vue-component-duplicates"},compare:(t,a)=>V(t,a,o),sort:(t,a)=>a.similarity-t.similarity||t.fileA.localeCompare(a.fileA)||t.fileB.localeCompare(a.fileB)})}function B(e,i){return v(e).vueProfiles({scope:i.scope,minTemplateTokens:i.minTokens,scanLimit:i.scanLimit}).map(o=>({file:o.file,tokens:o.templateTokens,loc:T(o)}))}function T(e){return e.totalLines}function V(e,i,o){let n=g(e.tokens,i.tokens);if(n.size<6||!R(n))return null;let c=k(e.tokens,i.tokens);if(c<o)return null;let l=r(n,"component:"),u=r(n,"prop:"),m=r(n,"event:"),d=r(n,"directive:"),s=r(n,"slot:"),p=r(n,"id:"),t=S({sharedComponents:l,sharedProps:u,sharedEvents:m,sharedDirectives:d,sharedSlots:s,sharedIdentifiers:p});return{fileA:e.file,fileB:i.file,similarity:c,tokenCountA:e.tokens.size,tokenCountB:i.tokens.size,sharedTokens:f(n),sharedComponents:l,sharedProps:u,sharedEvents:m,sharedDirectives:d,sharedSlots:s,sharedIdentifiers:p,evidenceClass:t.evidenceClass,actionTier:t.actionTier,evidenceClassReasons:t.reasons,recommendation:t.recommendation,uniqueToA:f(h(e.tokens,i.tokens)).slice(0,25),uniqueToB:f(h(i.tokens,e.tokens)).slice(0,25),locA:e.loc,locB:i.loc}}function R(e){let i=0,o=0;for(let n of e)n.startsWith("component:")&&(i+=1),(n.startsWith("prop:")||n.startsWith("event:")||n.startsWith("directive:")||n.startsWith("slot:"))&&(o+=1);return b([{name:"component",count:i},{name:"behavior",count:o}],[{min:{component:1},reason:"shared custom component"},{min:{behavior:3},reason:"shared Vue template structure"}]).pass}function S(e){return C({genericWords:x,primitiveGroups:[{values:e.sharedProps,reasonPrefix:"shared props",bucket:"generic"},{values:e.sharedEvents,reasonPrefix:"shared events",bucket:"generic"},{values:e.sharedDirectives,reasonPrefix:"shared directives",bucket:"generic"},{values:e.sharedSlots,reasonPrefix:"shared slots",bucket:"generic"}],nameGroups:[{names:e.sharedComponents,label:"shared component",fallbackBucket:"generic"},{names:e.sharedIdentifiers,label:"shared identifier",fallbackBucket:"generic"}],recommendation:w})}function w(e){switch(e){case"domain-behavior":case"mixed":return"Review for a shared component or feature-specific Vue primitive around the named domain structure.";case"shared-abstraction":return"Review the existing shared component usage first; extract only if duplicated structure remains outside it.";case"generic-workflow-scaffolding":return"Generic structural overlap \u2014 verify intent before consolidating."}}var x=new Set(["actions","app","button","card","content","container","dialog","field","form","header","input","item","label","layout","list","modal","page","panel","row","section","shell","table","text","toolbar","ui","value","view","wrapper"]);export{L as a};
2
+ //# sourceMappingURL=chunk-SSRFUQBD.js.map
@@ -0,0 +1,3 @@
1
+ import{a as P,b as k,c as S,d as I,e as E,i as z}from"./chunk-QBQE7ZJ5.js";import{J as u,O as Q,P as $,Q as v,x as _,z as C}from"./chunk-JZ2A7LDM.js";function F(t,e){return t.reason instanceof Error?t.reason:new Error(e)}function j(t,e){if(t?.aborted)throw F(t,e)}import{randomUUID as oe}from"crypto";import{closeSync as se,fsyncSync as ae,linkSync as ce,mkdirSync as de,openSync as le,statSync as ue,unlinkSync as fe,writeSync as ye}from"fs";import{dirname as x}from"path";var G="scip-query-process-lock",A=1,w=Object.freeze({wallNow:()=>Date.now(),isProcessAlive:I,readProcessIdentity:S,randomToken:()=>oe(),makeDirectory:t=>de(t,{recursive:!0}),openFile:(t,e,r)=>le(t,e,r),writeFile:(t,e,r,n)=>ye(t,e,r,n),syncFile:t=>ae(t),closeFile:t=>se(t),linkFile:(t,e)=>ce(t,e),readFile:t=>u(t,"process lock record"),statFile:t=>{let e=ue(t);return{dev:e.dev,ino:e.ino,size:e.size,mtimeMs:e.mtimeMs}},removeFile:t=>fe(t)});function B(t,e){let r=e.runtime??w;r.makeDirectory(x(t));let n;for(let i=0;i<2;i+=1)try{return{kind:"acquired",lock:J(t,e,r),...n?{reclaimed:n}:{}}}catch(o){if(o.code!=="EEXIST")throw o;let s=m(t,{parseLegacy:e.parseLegacy,runtime:r});if(i===0&&me(t,s,{creationGraceMs:e.creationGraceMs,parseLegacy:e.parseLegacy,runtime:r})){n=s;continue}return{kind:"contended",observation:s}}return{kind:"contended",observation:m(t,{parseLegacy:e.parseLegacy,runtime:r})}}function m(t,e={}){let r=e.runtime??w,n,i;try{n=r.statFile(t),i=r.readFile(t)}catch(c){return c.code==="ENOENT"?{state:"missing"}:{state:"malformed"}}let o;try{o=JSON.parse(i)}catch{return{state:"malformed",raw:i,identity:n}}let s=pe(o);if(s)return{state:"valid",raw:i,identity:n,record:s,owner:ke(s),parsed:o};let a=e.parseLegacy?.(o)??null;return a?{state:"legacy",raw:i,identity:n,owner:a,parsed:o}:{state:"malformed",raw:i,identity:n,parsed:o}}function pe(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;if(e.protocol!==G||e.version!==A||typeof e.kind!="string"||e.kind.trim()===""||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0||typeof e.token!="string"||e.token.trim()===""||typeof e.startedAt!="string"||!Number.isFinite(Date.parse(e.startedAt))||e.detail!==void 0&&(typeof e.detail!="object"||e.detail===null||Array.isArray(e.detail)))return null;let r=e.processIdentity===void 0?null:P(e.processIdentity);return e.processIdentity!==void 0&&(!r||r.pid!==e.pid)?null:{protocol:G,version:A,kind:e.kind,pid:e.pid,token:e.token,...r?{processIdentity:r}:{},startedAt:e.startedAt,...e.detail?{detail:e.detail}:{}}}function me(t,e,r={}){let n=r.runtime??w;if(!q(e,n))return!1;let i=ge(`${t}.reclaim`,n);if(!i)return!1;try{let o=m(t,{parseLegacy:r.parseLegacy,runtime:n});return!V(e,o)||!q(o,n)?!1:O(t,n)}finally{i.release()}}function J(t,e,r){let n=e.directoryDurability??"durable",i=e.pid??process.pid,o=r.randomToken(),s=e.processIdentity===void 0?r.readProcessIdentity(i):e.processIdentity,a={protocol:G,version:A,kind:e.kind,pid:i,token:o,...s?{processIdentity:s}:{},startedAt:new Date(r.wallNow()).toISOString(),...e.detail?{detail:e.detail}:{}},c=`${t}.${o}.candidate`,y=r.openFile(c,"wx",384),p;try{$(y,Buffer.from(`${JSON.stringify(a)}
2
+ `),r,"process lock"),r.syncFile(y)}catch(l){p=l}try{r.closeFile(y)}catch(l){p??=l}if(p!==void 0)throw h(c,r),p;try{r.linkFile(c,t)}catch(l){throw h(c,r),l}if(h(c,r),n==="durable")try{H(x(t),r)}catch(l){throw be(t,a,r),l}let f=!1;return{path:t,record:a,release:()=>f?!1:(f=!0,K(t,a,r,n))}}function be(t,e,r=w){return K(t,e,r,"durable")}function K(t,e,r,n){let i=m(t,{runtime:r});return i.state!=="valid"||!i.record||i.record.pid!==e.pid||i.record.token!==e.token||e.processIdentity&&(!i.record.processIdentity||!k(e.processIdentity,i.record.processIdentity))?!1:O(t,r,n)}function ge(t,e){for(let r=0;r<2;r+=1)try{return J(t,{kind:"reclaim-guard",runtime:e},e)}catch(n){if(n.code!=="EEXIST")return null;let i=m(t,{runtime:e});if(r>0||!q(i,e))return null;let o=m(t,{runtime:e});if(!V(i,o)||!O(t,e))return null}return null}function q(t,e){if(t.state==="missing")return!1;if(t.owner){if(!e.isProcessAlive(t.owner.pid))return!0;if(!t.owner.processIdentity)return!1;let r=e.readProcessIdentity(t.owner.pid);return r!==null&&!k(t.owner.processIdentity,r)}return!1}function V(t,e){return t.state===e.state&&t.raw===e.raw&&t.identity!==void 0&&e.identity!==void 0&&t.identity.dev===e.identity.dev&&t.identity.ino===e.identity.ino&&t.identity.size===e.identity.size&&t.identity.mtimeMs===e.identity.mtimeMs}function ke(t){return{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}}function H(t,e){let r;try{r=e.openFile(t,"r")}catch(n){if(v(n,process.platform))return;throw n}try{e.syncFile(r)}catch(n){if(!v(n,process.platform))throw n}finally{e.closeFile(r)}}function O(t,e,r="durable"){try{return e.removeFile(t),r==="durable"&&H(x(t),e),!0}catch{return!1}}function h(t,e){try{e.removeFile(t)}catch{}}import{join as Le}from"path";var Pe=t=>{if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t.pid;return typeof e=="number"&&Number.isSafeInteger(e)&&e>0?{pid:e}:null};function at(t,e={}){return D(Le(t,"gc.lock"),e)}function D(t,e={}){let r=e.waitMs??0,n=e.pollMs??10,i=e.now??E,o=i()+r;do{let s=U(t,e.directoryDurability);if(s)return W(s);let a=o-i();if(a<=0)return null;Se(Math.min(n,a))}while(i()<=o);return null}async function ct(t,e={}){let r=e.waitMs??0,n=e.pollMs??10,i=e.now??E,o=i()+r;do{j(e.signal,"Lock acquisition was aborted.");let s=U(t,e.directoryDurability);if(s)return W(s);let a=o-i();if(a<=0)return null;await Ie(Math.min(n,a),e.signal)}while(i()<=o);return null}function U(t,e){let r=B(t,{kind:"generic",parseLegacy:Pe,...e?{directoryDurability:e}:{}});return r.kind==="acquired"?r.lock:null}function W(t){return{release:()=>{t.release()}}}function Se(t){let e=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(e,0,0,t)}function Ie(t,e){return e?.aborted?Promise.reject(F(e,"Lock acquisition was aborted.")):new Promise((r,n)=>{let i=setTimeout(()=>{e?.removeEventListener("abort",o),r()},t),o=()=>{clearTimeout(i),e?.removeEventListener("abort",o),n(e?F(e,"Lock acquisition was aborted."):new Error("Lock acquisition was aborted."))};e?.addEventListener("abort",o,{once:!0})})}import{createHash as Fe,randomUUID as we}from"crypto";import{existsSync as b,mkdirSync as Re,readdirSync as Ee,rmSync as Y,statSync as Z}from"fs";import{basename as ve,dirname as R,join as d}from"path";var he=1,Ge=1,Ae=".scipquery-generations",qe="manifest.json",ee="readers",xe="gc.lock",Oe=128,L=new Map,te={pid:process.pid,now:()=>new Date,randomToken:()=>we(),isProcessAlive:I,readProcessIdentity:S};function g(t){return d(R(t),Ae)}function De(t){return d(g(t),xe)}function Pt(t,e=te){let r=D(De(t.dbPath),{waitMs:5e3,directoryDurability:"recoverable"});if(!r)throw new Error("SQLite generation retention is busy; retry opening the index.");let n;try{let i=Ce(t);if(i.source!=="immutable")return{generation:i,release(){}};let o=e.randomToken();if(!/^[A-Za-z0-9._-]+$/.test(o))throw new Error("SQLite generation reader token is unsafe.");let s=d(g(t.dbPath),ee);Re(s,{recursive:!0}),n=d(s,`${e.pid}-${o}.json`);let a=e.readProcessIdentity(e.pid);z(n,{version:1,token:o,generationIdentity:i.identity,pid:e.pid,...a?{processIdentity:a}:{},acquiredAt:e.now().toISOString()},{spacing:2,trailingNewline:!0});let c=!1;return{generation:i,release(){c||!n||(c=!0,Y(n,{force:!0}))}}}finally{r.release()}}function St(t,e,r=te,n={}){let i=d(g(t),ee);if(!b(i))return{protectedGenerations:new Set,activeLeases:0,staleLeasesRemoved:0,malformedLeases:0};let o=new Set,s=0,a=0,c=0;for(let y of Ee(i,{withFileTypes:!0})){if(!y.isFile()||!y.name.endsWith(".json"))continue;let p=d(i,y.name),f;try{f=Me(JSON.parse(u(p,"SQLite generation reader lease")))}catch{f=null}if(!f){c+=1;for(let l of e)o.add(l);continue}if(!Ne(f,r)){n.removeStale!==!1&&(Y(p,{force:!0}),a+=1);continue}s+=1,o.add(f.generationIdentity)}return{protectedGenerations:o,activeLeases:s,staleLeasesRemoved:a,malformedLeases:c}}function Me(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t,r=e.processIdentity===void 0?null:P(e.processIdentity);return e.version!==1||typeof e.token!="string"||e.token.trim()===""||typeof e.generationIdentity!="string"||!/^[a-f0-9]{64}$/.test(e.generationIdentity)||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0||typeof e.acquiredAt!="string"||!Number.isFinite(Date.parse(e.acquiredAt))||e.processIdentity!==void 0&&(!r||r.pid!==e.pid)?null:{version:1,token:e.token,generationIdentity:e.generationIdentity,pid:e.pid,...r?{processIdentity:r}:{},acquiredAt:e.acquiredAt}}function Ne(t,e){if(!e.isProcessAlive(t.pid))return!1;if(!t.processIdentity)return!0;let r=e.readProcessIdentity(t.pid);return r===null||k(t.processIdentity,r)}function re(t){try{let e=JSON.parse(u(d(g(t),"state.json"),"SQLite generation state"));return Be(e)?e:null}catch{return null}}function Te(t,e){return _e(g(t),e)}function _e(t,e){try{let r=JSON.parse(u(d(t,e,qe),"SQLite generation manifest"));return je(r,e)?r:null}catch{return null}}function Ce(t){let e=re(t.dbPath);if(e){let r=$e(t,e.currentGeneration);if(r)return r;if(e.artifactSet==="immutable-v1")throw new Error(`Published SQLite generation ${e.currentGeneration} is missing or invalid.`)}if(b(d(R(t.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return ze(t,e?.currentGeneration)}function It(t){let e=re(t);if(e)return e.currentGeneration;try{let r=d(R(t),"meta.json"),n=b(r)?u(r,"reindex metadata"):void 0;return ne(t,n)}catch{return null}}function Qe(t){return C(_(t))??t}function $e(t,e){try{let r=d(g(t.dbPath),e),n=Te(t.dbPath,e);if(!n)return null;let i=M(r,n.database),o=n.index?M(r,n.index):void 0,s=n.metadata?M(r,n.metadata):void 0;return!N(i,n.database)||n.index&&(!o||!N(o,n.index))||n.metadata&&(!s||!N(s,n.metadata))?null:{identity:e,databasePath:i,...o?{indexPath:o}:{},...s?{metadataPath:s,metadataRaw:u(s,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function ze(t,e){let r=ie(t.dbPath),n=d(R(t.dbPath),"meta.json"),i=b(n)?u(n,"reindex metadata"):void 0,o=b(t.indexPath)?t.indexPath:void 0;return{identity:e??ne(t.dbPath,i),databasePath:t.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:n,metadataRaw:i},source:"legacy",databaseFileIdentity:r}}function ne(t,e){let r=Fe("sha256").update("sqlite-generation-legacy-v1\0");return e!==void 0&&r.update(Qe(e)),r.update(`\0${ie(t)}`),r.digest("hex")}function ie(t){let e=Z(t);return`${e.dev}:${e.ino}:${e.size}:${e.mtimeMs}`}function M(t,e){if(ve(e.file)!==e.file||e.file==="."||e.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return d(t,e.file)}function N(t,e){if(!b(t))return!1;let r=X(t);if(!r||r.size!==e.size)return!1;let n=`${t}\0${e.sha256}\0${r.identity}`;if(L.has(n))return!0;let i=Q(t,{inputKind:"immutable SQLite generation artifact",maxBytes:e.size}),o=X(t);if(!o||o.identity!==r.identity||i!==e.sha256)return!1;for(L.set(n,!0);L.size>Oe;){let s=L.keys().next().value;if(s===void 0)break;L.delete(s)}return!0}function X(t){let e=Z(t,{bigint:!0});return e.isFile()?{identity:`${e.dev}:${e.ino}:${e.size}:${e.mtimeNs}:${e.ctimeNs}`,size:Number(e.size)}:null}function je(t,e){return t.version===Ge&&t.identity===e&&T(t.database)&&(t.index===void 0||T(t.index))&&(t.metadata===void 0||T(t.metadata))}function T(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.file=="string"&&!!e.file&&Number.isSafeInteger(e.size)&&(e.size??-1)>=0&&typeof e.sha256=="string"&&/^[a-f0-9]{64}$/.test(e.sha256)}function Be(t){return t.version===he&&typeof t.currentGeneration=="string"&&!!t.currentGeneration&&typeof t.publishedAt=="string"&&Number.isFinite(Date.parse(t.publishedAt))&&(t.artifactSet===void 0||t.artifactSet==="immutable-v1")&&Je(t.stableMirrors)&&Ke(t.previousGeneration)&&Ve(t.publication)}function Je(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 Ke(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 Ve(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t,r=[e.converterDurationMs,e.affectedDocumentCount,e.changedDocumentCount,e.producerDurationMs,e.materializationDurationMs,e.patchDurationMs].filter(n=>n!==void 0);return(e.mode==="incremental"||e.mode==="full")&&e.validation==="passed"&&e.converterDurationMs!==void 0&&r.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=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")}export{F as a,j as b,B as c,m as d,me as e,at as f,D as g,ct as h,he as i,Ge as j,Ae as k,qe as l,g as m,De as n,Pt as o,St as p,re as q,Te as r,_e as s,Ce as t,It as u,Qe as v,ie as w};
3
+ //# sourceMappingURL=chunk-SYVJEEUJ.js.map
@@ -1,8 +1,8 @@
1
- import{a as ee,b as q,d as v}from"./chunk-JFMEXGFE.js";import{i as te,j as h,k as f,l as p}from"./chunk-KYSDI3GE.js";import{e as Q,g as Z,h as F,n as P}from"./chunk-7F45LJKI.js";import{randomUUID as Le}from"crypto";import{closeSync as Ne,existsSync as Oe,fsyncSync as ke,linkSync as qe,mkdirSync as Pe,openSync as $e,renameSync as Ce,unlinkSync as Te,writeSync as _e}from"fs";import{dirname as ne}from"path";import{chmodSync as Ie,constants as Fe,copyFileSync as Re}from"fs";import{dirname as Ee}from"path";var ie=Object.freeze({...te,copyFile:(e,t)=>Re(e,t,Fe.COPYFILE_FICLONE),chmodFile:(e,t)=>Ie(e,t)});function ve(e,t,i={}){let n=i.runtime??ie,r=Ee(t),o=h(r,n);n.copyFile(e,t),i.mode!==void 0&&n.chmodFile(t,i.mode);let s=n.openFile(t,"r");try{n.syncFile(s)}finally{n.closeFile(s)}return p(o,f(r,n))}var re=Object.freeze({platform:process.platform,randomToken:()=>Le(),pathExists:e=>Oe(e),makeDirectory:e=>Pe(e,{recursive:!0}),openFile:(e,t,i)=>$e(e,t,i),writeFile:(e,t,i,n)=>_e(e,t,i,n),syncFile:e=>ke(e),closeFile:e=>Ne(e),renameFile:(e,t)=>Ce(e,t),linkFile:(e,t)=>qe(e,t),removeFile:e=>Te(e)});function $(e,t,i={}){let n=i.durability??"visibility",r=i.runtime??re,o=ne(e),s=n==="durable"?h(o,r):(r.makeDirectory(o),"not-requested"),a=`${e}.tmp-${r.randomToken()}`,l=typeof t=="string"?Buffer.from(t):t,d,c=!1;try{d=r.openFile(a,"wx",i.mode??384),c=!0,P(d,l,r,"atomic file"),n==="durable"&&r.syncFile(d),r.closeFile(d),d=void 0,r.renameFile(a,e),c=!1;let m=n==="durable"?p(s,f(o,r)):"not-requested";return oe(n,m)}finally{if(d!==void 0)try{r.closeFile(d)}catch{}if(c)try{r.removeFile(a)}catch{}}}function L(e,t,i={}){let n=i.durability??"visibility",r=i.runtime??re;if(!r.linkFile)throw new Error("Exclusive atomic file publication requires hard-link support.");let o=ne(e),s=n==="durable"?h(o,r):(r.makeDirectory(o),"not-requested"),a=`${e}.tmp-${r.randomToken()}`,l=typeof t=="string"?Buffer.from(t):t,d,c=!1;try{d=r.openFile(a,"wx",i.mode??384),c=!0,P(d,l,r,"exclusive atomic file"),n==="durable"&&r.syncFile(d),r.closeFile(d),d=void 0,r.linkFile(a,e);let m=n==="durable"?f(o,r):"not-requested";r.removeFile(a),c=!1;let b=n==="durable"?p(s,m,f(o,r)):"not-requested";return oe(n,b)}finally{if(d!==void 0)try{r.closeFile(d)}catch{}if(c)try{r.removeFile(a)}catch{}}}function oe(e,t){return{requestedDurability:e,achievedDurability:e==="visibility"?"visibility":t==="synced"?"directory-durable":"file-flushed",directorySync:t}}function se(e,t,i={}){$(e,ae(t,i),{durability:"visibility",runtime:i.runtime})}function C(e,t,i={}){return $(e,ae(t,i),{durability:"durable",runtime:i.runtime})}function ae(e,t){let i=JSON.stringify(e,null,t.spacing);return t.trailingNewline?`${i}
1
+ import{a as ee,b as q,d as v}from"./chunk-JFMEXGFE.js";import{i as te,j as h,k as f,l as p}from"./chunk-7HXT6YLU.js";import{e as Q,g as Z,h as F,n as P}from"./chunk-7F45LJKI.js";import{randomUUID as Le}from"crypto";import{closeSync as Ne,existsSync as Oe,fsyncSync as ke,linkSync as qe,mkdirSync as Pe,openSync as $e,renameSync as Ce,unlinkSync as Te,writeSync as _e}from"fs";import{dirname as ne}from"path";import{chmodSync as Ie,constants as Fe,copyFileSync as Re}from"fs";import{dirname as Ee}from"path";var ie=Object.freeze({...te,copyFile:(e,t)=>Re(e,t,Fe.COPYFILE_FICLONE),chmodFile:(e,t)=>Ie(e,t)});function ve(e,t,i={}){let n=i.runtime??ie,r=Ee(t),o=h(r,n);n.copyFile(e,t),i.mode!==void 0&&n.chmodFile(t,i.mode);let s=n.openFile(t,"r");try{n.syncFile(s)}finally{n.closeFile(s)}return p(o,f(r,n))}var re=Object.freeze({platform:process.platform,randomToken:()=>Le(),pathExists:e=>Oe(e),makeDirectory:e=>Pe(e,{recursive:!0}),openFile:(e,t,i)=>$e(e,t,i),writeFile:(e,t,i,n)=>_e(e,t,i,n),syncFile:e=>ke(e),closeFile:e=>Ne(e),renameFile:(e,t)=>Ce(e,t),linkFile:(e,t)=>qe(e,t),removeFile:e=>Te(e)});function $(e,t,i={}){let n=i.durability??"visibility",r=i.runtime??re,o=ne(e),s=n==="durable"?h(o,r):(r.makeDirectory(o),"not-requested"),a=`${e}.tmp-${r.randomToken()}`,l=typeof t=="string"?Buffer.from(t):t,d,c=!1;try{d=r.openFile(a,"wx",i.mode??384),c=!0,P(d,l,r,"atomic file"),n==="durable"&&r.syncFile(d),r.closeFile(d),d=void 0,r.renameFile(a,e),c=!1;let m=n==="durable"?p(s,f(o,r)):"not-requested";return oe(n,m)}finally{if(d!==void 0)try{r.closeFile(d)}catch{}if(c)try{r.removeFile(a)}catch{}}}function L(e,t,i={}){let n=i.durability??"visibility",r=i.runtime??re;if(!r.linkFile)throw new Error("Exclusive atomic file publication requires hard-link support.");let o=ne(e),s=n==="durable"?h(o,r):(r.makeDirectory(o),"not-requested"),a=`${e}.tmp-${r.randomToken()}`,l=typeof t=="string"?Buffer.from(t):t,d,c=!1;try{d=r.openFile(a,"wx",i.mode??384),c=!0,P(d,l,r,"exclusive atomic file"),n==="durable"&&r.syncFile(d),r.closeFile(d),d=void 0,r.linkFile(a,e);let m=n==="durable"?f(o,r):"not-requested";r.removeFile(a),c=!1;let b=n==="durable"?p(s,m,f(o,r)):"not-requested";return oe(n,b)}finally{if(d!==void 0)try{r.closeFile(d)}catch{}if(c)try{r.removeFile(a)}catch{}}}function oe(e,t){return{requestedDurability:e,achievedDurability:e==="visibility"?"visibility":t==="synced"?"directory-durable":"file-flushed",directorySync:t}}function se(e,t,i={}){$(e,ae(t,i),{durability:"visibility",runtime:i.runtime})}function C(e,t,i={}){return $(e,ae(t,i),{durability:"durable",runtime:i.runtime})}function ae(e,t){let i=JSON.stringify(e,null,t.spacing);return t.trailingNewline?`${i}
2
2
  `:i}import{createHash as T,randomUUID as pe}from"crypto";import{closeSync as Ue,existsSync as D,fstatSync as We,lstatSync as B,mkdirSync as Ke,openSync as ze,readdirSync as w,readSync as Xe,renameSync as _,rmSync as g}from"fs";import{basename as S,dirname as J,join as y}from"path";function de(e){return N(e,Je)}function St(e){return N(e,je)}function N(e,t){return Array.isArray(e)?`[${e.map(i=>N(i,t)).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).sort(([i],[n])=>t(i,n)).map(([i,n])=>`${JSON.stringify(i)}:${N(n,t)}`).join(",")}}`:JSON.stringify(e)}function Je(e,t){return e.localeCompare(t)}function je(e,t){return e<t?-1:e>t?1:0}var j=1,He=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}),x=class extends Error{constructor(i,n,r,o){let s=i==="item-too-large"?`request is ${o} bytes; per-item limit is ${r.maxItemBytes}`:i==="item-capacity"?`mailbox has ${n.totalItems} retained items; limit is ${r.maxItems}`:i==="byte-capacity"?`mailbox retains ${n.totalBytes} bytes and the request adds ${o}; limit is ${r.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=i;this.status=n;this.limits=r;this.attemptedBytes=o;this.name="MailboxBackpressureError"}code;status;limits;attemptedBytes},ge=".owner.json",U={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function qt(e){return{rootDir:e,pendingDir:y(e,"pending"),inflightDir:y(e,"inflight"),responseDir:y(e,"responses"),deadLetterDir:y(e,"dead-letter"),legacyRequestDir:y(e,"requests")}}function I(e={}){let t={...He,...e};for(let[i,n]of Object.entries(t))if(!Number.isFinite(n)||n<=0||!Number.isInteger(n))throw new Error(`Mailbox limit ${i} must be a positive integer.`);return t}function k(e){let t=[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir].map(i=>h(i));return p(...t)}function Pt(e,t){return T("sha256").update(de({namespace:e,payload:t})).digest("hex")}function xe(e){if(!/^[a-f0-9]{64}$/.test(e))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${e}`}function $t(e,t,i={}){let n=I(i.limits),r=i.nowMs??Date.now(),o=k(e);return st(t),K(e,n,i.admissionLockTimeoutMs??2e3,i.monotonicNow??v,i.durability??"durable",()=>{W(e,r,n);let s=y(e.pendingDir,`${t.id}.json`),a=y(e.responseDir,`${t.id}.json`),l=ce(e,t.id);if(l){let b=ue(l,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:b.deadlineAtMs??t.deadlineAtMs}}let d=`${JSON.stringify(t)}
3
3
  `,c=Buffer.byteLength(d),m=R(e);if(c>n.maxItemBytes)throw new x("item-too-large",m,n,c);if(m.totalItems+1>n.maxItems)throw new x("item-capacity",m,n,c);if(m.totalBytes+c>n.maxBytes)throw new x("byte-capacity",m,n,c);i.onBeforePublish?.();try{let b=i.durability??"durable",u=L(s,d,{durability:b}),M=b==="durable"?p(o,u.directorySync):"not-requested";return{disposition:"accepted",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:t.deadlineAtMs,achievedDurability:u.achievedDurability,directorySync:M}}catch(b){if(b.code!=="EEXIST")throw b;let u=ce(e,t.id);if(!u)throw b;let M=ue(u,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:M.deadlineAtMs??t.deadlineAtMs}}})}function Ve(e,t){if(!t.ownerId.trim())throw new Error("Mailbox claim owner identity is required.");if(t.owner&&(!Number.isSafeInteger(t.owner.pid)||t.owner.pid<=0||t.owner.processIdentity!==void 0&&t.owner.processIdentity.pid!==t.owner.pid))throw new Error("Mailbox claim process identity is invalid.");let i=t.nowMs??Date.now(),n=I(t.limits),r=k(e);try{return K(e,n,2e3,t.monotonicNow??v,t.durability??"durable",()=>Ye(e,t.ownerId,i,n,t.liveness??U,t.owner??{pid:process.pid},r,t.durability??"durable",t.onClaimStage))}catch(o){if(o instanceof x&&o.code==="admission-busy")return[];throw o}}function Ct(e,t){return!be(e.pendingDir)&&!be(e.legacyRequestDir)?[]:Ve(e,t)}function Ye(e,t,i,n,r,o,s,a,l){W(e,i,n,r);let d=y(e.inflightDir,O(t)),c=[...me(e.pendingDir,!1),...me(e.legacyRequestDir,!0)].sort((u,M)=>u.orderAtMs-M.orderAtMs||u.header.id.localeCompare(M.header.id)||u.path.localeCompare(M.path)),m=a==="durable"?s:"not-requested";c.length>0&&(a==="durable"?m=p(m,h(d)):Ke(d,{recursive:!0}),l?.("after-owner-directory-durable"),rt(d,t,o,a),l?.("after-owner-record-published"));let b=[];for(let u of c){if(b.length>=n.maxBatch)break;let M=y(e.responseDir,`${u.header.id}.json`);if(D(M)){g(u.path,{force:!0});continue}let H=Math.max(i+n.claimLeaseMs,(u.header.deadlineAtMs??i)+5e3),we=`${O(u.originalFile)}.${H}.claim`,V=y(d,we);try{_(u.path,V)}catch(Y){let G=Y.code;if(G==="ENOENT"||G==="EEXIST")continue;throw Y}l?.("after-claim-renamed");let Ae=a==="durable"?f(J(u.path)):"not-requested";l?.("after-source-directory-synced");let Se=a==="durable"?f(d):"not-requested";l?.("after-destination-directory-synced");let Be=p(m,Ae,Se);b.push({requestId:u.header.id,ownerId:t,path:V,originalFile:u.originalFile,claimedAtMs:i,claimExpiresAtMs:H,byteLength:u.byteLength,...u.header.operationKey?{operationKey:u.header.operationKey}:{},...u.header.clientId?{clientId:u.header.clientId}:{},...u.header.enqueuedAtMs===void 0?{}:{enqueuedAtMs:u.header.enqueuedAtMs},...u.header.deadlineAtMs===void 0?{}:{deadlineAtMs:u.header.deadlineAtMs},legacy:u.legacy,directorySync:Be})}return b}function Tt(e,t={}){let i=I(t);if(e.byteLength>i.maxItemBytes)throw new x("item-too-large",{pending:0,inflight:1,responses:0,deadLetters:0,invalid:0,totalItems:1,totalBytes:e.byteLength},i,e.byteLength);return Z(e.path,{maxBytes:i.maxItemBytes,inputKind:"bounded mailbox item"})}function Ge(e,t,i,n={}){let r=n.nowMs??Date.now(),o=I(n.limits),s=t.deadlineAtMs===void 0?r+o.responseRetentionMs:Math.min(r+o.responseRetentionMs,Math.max(t.deadlineAtMs,r)+Me),a={mailboxVersion:j,operationKey:t.operationKey??`legacy-${t.requestId}`,clientId:t.clientId??"legacy",...t.deadlineAtMs===void 0?{}:{deadlineAtMs:t.deadlineAtMs},completedAtMs:r,expiresAtMs:s},l={...a,...i,...a},d=Buffer.byteLength(`${JSON.stringify(l)}
4
4
  `),c=R(e);if(d>o.maxItemBytes)throw new x("item-too-large",c,o,d);let m=Math.max(0,c.totalBytes-t.byteLength)+d;if(m>o.maxBytes&&m>c.totalBytes&&(Ze(e,r).removed>0&&(c=R(e),m=Math.max(0,c.totalBytes-t.byteLength)+d),m>o.maxBytes&&m>c.totalBytes))throw new x("byte-capacity",c,o,d);let b=n.durability??"durable";if(et(e,t,l,b),n.onAfterResponsePublished?.(),g(t.path,{force:!0}),b==="durable"){let u=J(t.path);f(D(u)?u:e.inflightDir)}}var Me=3e4,Qe=4096;function Ze(e,t){let i={removed:0,bytesFreed:0},n;try{n=w(e.responseDir)}catch{return i}for(let r of n){if(!r.endsWith(".json"))continue;let o=y(e.responseDir,r),s,a;try{let m=ze(o,"r");try{a=We(m).size;let b=Buffer.alloc(Math.min(Qe,a));Xe(m,b,0,b.length,0),s=b.toString("utf8")}finally{Ue(m)}}catch{continue}let l=le(s,"expiresAtMs"),d=le(s,"deadlineAtMs");if(l!==null&&l<=t||d!==null&&d+Me<=t)try{g(o,{force:!0}),i.removed+=1,i.bytesFreed+=a}catch{}}return i}function le(e,t){let i=new RegExp(`"${t}":(\\d+)`).exec(e);if(!i)return null;let n=Number(i[1]);return Number.isSafeInteger(n)?n:null}function _t(e,t,i,n,r={}){let o=r.nowMs??Date.now(),s=I(r.limits);if(Ge(e,t,i,{...r,nowMs:o,limits:s}),!D(t.path)){let a=y(e.deadLetterDir,`${lt(t.requestId)}.${o}.${T("sha256").update(n).digest("hex").slice(0,12)}.json`),l={mailboxVersion:j,requestId:t.requestId,ownerId:t.ownerId,rejectedAtMs:o,reason:n,originalFile:t.originalFile},d=Buffer.byteLength(`${JSON.stringify(l,null,2)}
5
5
  `),c=R(e);c.totalItems<s.maxItems&&c.totalBytes+d<=s.maxBytes&&C(a,l,{spacing:2,trailingNewline:!0})}}function Jt(e,t={}){let i=t.nowMs??Date.now(),n=I(t.limits);return k(e),K(e,n,2e3,t.monotonicNow??v,"durable",()=>W(e,i,n,t.liveness??U))}function W(e,t,i,n=U){let r={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=i.cleanupBatch;for(let s of X(e.inflightDir)){if(o<=0)break;let a=y(e.responseDir,`${s.requestId}.json`);if(D(a)){g(s.path,{force:!0}),r.completedClaimsRemoved++,o--;continue}if(s.claimExpiresAtMs>t||ot(e,s.ownerId,n)!=="dead")continue;let l=y(e.pendingDir,s.originalFile);try{_(s.path,l),r.reclaimed++}catch(d){if(d.code!=="EEXIST")throw d;g(s.path,{force:!0})}f(J(s.path)),f(e.pendingDir),o--}o=ye(e.responseDir,o,(s,a)=>a+i.responseRetentionMs,t,()=>{r.responsesRemoved++}),o=ye(e.deadLetterDir,o,(s,a)=>a+i.deadLetterRetentionMs,t,()=>{r.deadLettersRemoved++});for(let s of[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir]){if(o<=0)break;for(let a of De(s)){if(o<=0)break;if(!S(a).includes(".tmp-"))continue;let l;try{l=B(a).mtimeMs}catch(d){if(d.code==="ENOENT")continue;throw d}l+i.temporaryRetentionMs>t||(g(a,{force:!0}),r.temporaryFilesRemoved++,o--)}}return at(e.inflightDir),r}function R(e){k(e);let t=[...A(e.pendingDir).map(l=>({path:l,pending:!0})),...A(e.legacyRequestDir).map(l=>({path:l,pending:!0}))],i=X(e.inflightDir).map(l=>({path:l.path,pending:!1})),n=A(e.responseDir).map(l=>({path:l,pending:!1})),r=A(e.deadLetterDir).map(l=>({path:l,pending:!1})),o=[...t,...i,...n,...r],s=0,a;for(let l of t){let d=E(l.path);if(!d){s++;continue}let c=d.enqueuedAtMs;if(c===void 0)try{c=B(l.path).mtimeMs}catch(m){if(m.code==="ENOENT")continue;throw m}a=a===void 0?c:Math.min(a,c)}return{pending:t.length,inflight:i.length,responses:n.length,deadLetters:r.length,invalid:s,totalItems:o.length,totalBytes:o.reduce((l,d)=>l+dt(d.path),0),...a===void 0?{}:{oldestPendingAt:new Date(a).toISOString()}}}function et(e,t,i,n){let r=y(e.responseDir,`${t.requestId}.json`),o=`${JSON.stringify(i)}
6
6
  `;try{L(r,o,{durability:n})}catch(s){if(s.code!=="EEXIST")throw s;let a=E(r),l=t.operationKey??`legacy-${t.requestId}`;if(a?.operationKey!==l)throw new Error(`Mailbox completion ${t.requestId} conflicts with an existing operation.`,{cause:s})}}function K(e,t,i,n,r,o){let s=y(e.rootDir,".admission.lock"),a=`${process.pid}-${pe()}`,l=n()+Math.max(0,i);for(;!tt(e.rootDir,s,a,r);){if(it(s),n()>=l)throw new x("admission-busy",R(e),t,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return o()}finally{try{z(s).ownerToken===a&&(g(s,{recursive:!0,force:!0}),r==="durable"&&f(e.rootDir))}catch{}}}function tt(e,t,i,n){let r=`${JSON.stringify({ownerToken:i,pid:process.pid,acquiredAtMs:Date.now()})}
7
7
  `;try{return L(t,r,{durability:n}),!0}catch(o){if(o.code==="EEXIST")return!1;try{z(t).ownerToken===i&&(g(t,{force:!0}),n==="durable"&&f(e))}catch{}throw o}}function it(e){let t=null;try{let n=z(e);typeof n.ownerToken=="string"&&Number.isSafeInteger(n.pid)&&Number(n.pid)>0&&(t=Number(n.pid))}catch{}if(t===null||nt(t))return;let i=`${e}.stale-${pe()}`;try{_(e,i)}catch(n){let r=n.code;if(r==="ENOENT"||r==="EEXIST")return;throw n}g(i,{recursive:!0,force:!0})}function z(e){try{return JSON.parse(F(e,"mailbox lock record"))}catch(t){if(t.code!=="EISDIR"&&!(t instanceof Q&&t.reason==="not-regular"))throw t;return JSON.parse(F(y(e,"owner.json"),"mailbox lock owner record"))}}function nt(e){try{return process.kill(e,0),!0}catch(t){let i=t.code;return i==="EPERM"||i!=="ESRCH"}}function rt(e,t,i,n){let r=y(e,ge),o=i.processIdentity,s=he(r);if(s&&s.ownerId===t&&s.pid===i.pid&&(!s.processIdentity&&!o||s.processIdentity&&o&&q(s.processIdentity,o)))return;if(A(e).some(l=>l.endsWith(".claim")))throw new Error(`Mailbox owner identity ${t} collides with retained work from another process instance.`);let a={version:1,ownerId:t,pid:i.pid,...o?{processIdentity:o}:{}};n==="durable"?C(r,a):se(r,a)}function ot(e,t,i){let n=he(y(e.inflightDir,O(t),ge));if(!n)return"unknown";if(!i.isProcessAlive(n.pid))return"dead";if(!n.processIdentity)return"live";let r=i.readProcessIdentity(n.pid);return r?q(n.processIdentity,r)?"live":"dead":"unknown"}function he(e){try{let t=JSON.parse(F(e,"mailbox owner record"));if(t.version!==1||typeof t.ownerId!="string"||!t.ownerId||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0)return null;let i=t.processIdentity===void 0?null:ee(t.processIdentity);return t.processIdentity!==void 0&&(!i||i.pid!==t.pid)?null:{version:1,ownerId:t.ownerId,pid:t.pid,...i?{processIdentity:i}:{}}}catch{return null}}function ce(e,t){for(let i of[y(e.pendingDir,`${t}.json`),y(e.legacyRequestDir,`${t}.json`),y(e.responseDir,`${t}.json`)])if(D(i))return i;for(let i of X(e.inflightDir))if(i.requestId===t)return i.path;return null}function ue(e,t,i){let n=E(e);if(n?.operationKey===t)return n;if(S(e)===`${xe(t)}.json`)return{id:i,operationKey:t};throw new Error(`Mailbox operation ${i} conflicts with an existing retained record.`)}function st(e){if(e.mailboxVersion!==j||e.id!==xe(e.operationKey)||!e.clientId.trim()||!Number.isFinite(e.enqueuedAtMs)||!Number.isFinite(e.deadlineAtMs)||e.deadlineAtMs<e.enqueuedAtMs)throw new Error("Mailbox request has an invalid lifecycle identity.")}function me(e,t){return A(e).filter(i=>i.endsWith(".json")).map(i=>{let n=B(i),r=S(i,".json"),o=E(i)??{id:r};return{path:i,originalFile:S(i),header:o,byteLength:n.size,orderAtMs:o.enqueuedAtMs??n.mtimeMs,legacy:t}})}function X(e){if(!D(e))return[];let t=[];for(let i of w(e,{withFileTypes:!0})){if(!i.isDirectory())continue;let n=fe(i.name);if(n===null)continue;let r=y(e,i.name);for(let o of w(r,{withFileTypes:!0})){if(!o.isFile()||!o.name.endsWith(".claim"))continue;let s=/^(.*)\.(\d+)\.claim$/.exec(o.name);if(!s)continue;let a=fe(s[1]),l=Number(s[2]);if(a===null||S(a)!==a||!a.endsWith(".json")||!Number.isSafeInteger(l))continue;let d=y(r,o.name),c=E(d)??{id:S(a,".json")},m;try{m=B(d)}catch(b){if(b.code==="ENOENT")continue;throw b}t.push({requestId:c.id,ownerId:n,path:d,originalFile:a,claimedAtMs:m.mtimeMs,claimExpiresAtMs:l,byteLength:m.size,...c.operationKey?{operationKey:c.operationKey}:{},...c.clientId?{clientId:c.clientId}:{},...c.enqueuedAtMs===void 0?{}:{enqueuedAtMs:c.enqueuedAtMs},...c.deadlineAtMs===void 0?{}:{deadlineAtMs:c.deadlineAtMs},legacy:c.operationKey===void 0})}}return t.sort((i,n)=>i.claimedAtMs-n.claimedAtMs||i.path.localeCompare(n.path))}function E(e){try{let t=JSON.parse(F(e,"mailbox record"));return typeof t.id!="string"||!t.id?null:{id:t.id,...typeof t.operationKey=="string"?{operationKey:t.operationKey}:{},...typeof t.clientId=="string"?{clientId:t.clientId}:{},...typeof t.enqueuedAtMs=="number"?{enqueuedAtMs:t.enqueuedAtMs}:{},...typeof t.deadlineAtMs=="number"?{deadlineAtMs:t.deadlineAtMs}:{}}}catch{return null}}function ye(e,t,i,n,r){for(let o of A(e)){if(t<=0)break;let s;try{s=B(o)}catch(a){if(a.code==="ENOENT")continue;throw a}i(o,s.mtimeMs)>n||(g(o,{force:!0}),r(),t--)}return t}function A(e){return D(e)?w(e,{withFileTypes:!0}).filter(t=>t.isFile()).map(t=>y(e,t.name)).sort():[]}function be(e){try{return w(e).some(t=>t.endsWith(".json"))}catch{return!1}}function De(e){if(!D(e))return[];let t=[];for(let i of w(e,{withFileTypes:!0})){let n=y(e,i.name);i.isFile()?t.push(n):i.isDirectory()&&t.push(...De(n))}return t.sort()}function at(e){if(D(e))for(let t of w(e,{withFileTypes:!0})){if(!t.isDirectory())continue;let i=y(e,t.name);w(i).some(n=>n.endsWith(".claim"))||g(i,{recursive:!0,force:!0})}}function dt(e){try{return B(e).size}catch{return 0}}function O(e){return Buffer.from(e,"utf8").toString("base64url")}function fe(e){try{let t=Buffer.from(e,"base64url").toString("utf8");return O(t)===e?t:null}catch{return null}}function lt(e){return/^[a-z0-9][a-z0-9-]{0,127}$/i.test(e)?e:`invalid-${T("sha256").update(e).digest("hex")}`}export{ve as a,se as b,C as c,de as d,St as e,j as f,x as g,qt as h,k as i,Pt as j,xe as k,$t as l,Ct as m,Tt as n,Ge as o,_t as p,Jt as q,R as r};
8
- //# sourceMappingURL=chunk-FGA2U4OR.js.map
8
+ //# sourceMappingURL=chunk-T3CZAZSI.js.map
@@ -0,0 +1,2 @@
1
+ import{getHeapStatistics as r}from"v8";var o=2560,n=1.25;function _(t){let e=t/1048576;return Math.max(0,Math.floor((e-o)/n))}function p(){return _(r().heap_size_limit)}export{o as a,n as b,p as c};
2
+ //# sourceMappingURL=chunk-T3I6NHBH.js.map
@@ -1,3 +1,3 @@
1
- import{a as R}from"./chunk-WYCTJDVR.js";import{p as h}from"./chunk-YEN6CYC7.js";import{a as g}from"./chunk-HOENASQM.js";import{i as p}from"./chunk-3L2ZBPEX.js";import{a as m}from"./chunk-YXPUP5G2.js";import{g as d}from"./chunk-DRENNWRG.js";function D(t,r,n={}){let e=g(t,r);if(!e)return[];let l=!d(e.symbol)&&!t.isIgnored(e.relativePath)?[{relativePath:e.relativePath,line:e.startLine}]:[],c=h(t,e,{semantic:n.semantic,semanticEvidence:R}).map(s=>({relativePath:s.file,line:s.line})),o=b(t,e),f=new Set,a=[];for(let s of[...l,...c,...o]){let u=`${s.relativePath}:${s.line}`;f.has(u)||(f.add(u),a.push(s))}return a}function b(t,r){if(!r.relativePath.endsWith(".rb"))return[];let n=S(r.symbol);if(n.length===0)return[];let e=[];for(let i of m(t,{extensions:[".rb"],includeIgnored:!1})){let l=p(t,i);if(!l)continue;let c=l.split(`
1
+ import{a as R}from"./chunk-WDSFQDPN.js";import{p as h}from"./chunk-FI7VGOR4.js";import{a as g}from"./chunk-2USA3S3P.js";import{i as p}from"./chunk-2VAHDDLM.js";import{a as m}from"./chunk-YXPUP5G2.js";import{g as d}from"./chunk-BL6DCHQP.js";function D(t,r,n={}){let e=g(t,r);if(!e)return[];let l=!d(e.symbol)&&!t.isIgnored(e.relativePath)?[{relativePath:e.relativePath,line:e.startLine}]:[],c=h(t,e,{semantic:n.semantic,semanticEvidence:R}).map(s=>({relativePath:s.file,line:s.line})),o=b(t,e),f=new Set,a=[];for(let s of[...l,...c,...o]){let u=`${s.relativePath}:${s.line}`;f.has(u)||(f.add(u),a.push(s))}return a}function b(t,r){if(!r.relativePath.endsWith(".rb"))return[];let n=S(r.symbol);if(n.length===0)return[];let e=[];for(let i of m(t,{extensions:[".rb"],includeIgnored:!1})){let l=p(t,i);if(!l)continue;let c=l.split(`
2
2
  `);for(let o=0;o<c.length;o++){let f=c[o]??"";n.some(a=>new RegExp(`@${a}\\b|\\b${a}:`).test(f))&&e.push({relativePath:i,line:o})}}return e}function S(t){let n=(t.split(":").pop()??t).replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9_]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),e=n.split("_").filter(Boolean),i=new Set;return n&&i.add(n),e.length>=1&&i.add(e[e.length-1]),e.length>=2&&i.add(e.slice(-2).join("_")),[...i]}export{D as a};
3
- //# sourceMappingURL=chunk-EQHFIL6T.js.map
3
+ //# sourceMappingURL=chunk-T6DWDI5E.js.map