scip-query 0.19.6 → 0.19.8

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 (304) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +28 -15
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/chunk-2465DLHK.js +3 -0
  5. package/dist/{chunk-2CVXCGL4.js → chunk-24GTWJ3N.js} +2 -2
  6. package/dist/{chunk-XVJ3V7LM.js → chunk-2SNGN6U4.js} +2 -2
  7. package/dist/{chunk-FKGN4A4E.js → chunk-2U3OLUNJ.js} +2 -2
  8. package/dist/{chunk-UUJBLG6J.js → chunk-33KUO7CG.js} +2 -2
  9. package/dist/{chunk-N3SE646F.js → chunk-33XTHFKR.js} +2 -2
  10. package/dist/{chunk-WXAAURU7.js → chunk-3EDFLQ6A.js} +2 -2
  11. package/dist/chunk-3ZSJ3PWF.js +16 -0
  12. package/dist/{chunk-G4UQL4CP.js → chunk-43KC6EQZ.js} +2 -2
  13. package/dist/{chunk-NQLSSVOB.js → chunk-464PLI5O.js} +2 -2
  14. package/dist/chunk-46XGSFNI.js +2 -0
  15. package/dist/{chunk-NN4ZIRPK.js → chunk-47BU5Z4T.js} +2 -2
  16. package/dist/chunk-4BV4QAZJ.js +5 -0
  17. package/dist/chunk-4YTUWQ6M.js +18 -0
  18. package/dist/{chunk-LMFVTUW2.js → chunk-5ML2BNRH.js} +2 -2
  19. package/dist/{chunk-OP3MTFJR.js → chunk-5YLUDDAF.js} +2 -2
  20. package/dist/chunk-67QRR5YC.js +6 -0
  21. package/dist/{chunk-273W2U4Y.js → chunk-6GXYN7YA.js} +2 -2
  22. package/dist/{chunk-JELJLXEE.js → chunk-6M7RONVB.js} +2 -2
  23. package/dist/{chunk-MLGTCX56.js → chunk-7FT5Y65S.js} +2 -2
  24. package/dist/{chunk-F42A3AKG.js → chunk-7KYNAMMH.js} +2 -2
  25. package/dist/{chunk-VP542C25.js → chunk-7LSVMFX7.js} +2 -2
  26. package/dist/{chunk-YWB2EBNB.js → chunk-7QHY3H7P.js} +2 -2
  27. package/dist/{chunk-UQK5CRUK.js → chunk-7RAG65VK.js} +2 -2
  28. package/dist/{chunk-CYJM7CYF.js → chunk-7SWJEWJF.js} +2 -2
  29. package/dist/{chunk-47X75ZKH.js → chunk-7VCOXZH3.js} +2 -2
  30. package/dist/chunk-A2TNXAXO.js +8 -0
  31. package/dist/{chunk-TYQ76QHQ.js → chunk-A3QXWFBK.js} +2 -2
  32. package/dist/{chunk-S2GP3CU3.js → chunk-AA4UWRNL.js} +2 -2
  33. package/dist/{chunk-OBKDTVZ3.js → chunk-ACAM6O5R.js} +2 -2
  34. package/dist/chunk-AQOFWNQJ.js +1 -0
  35. package/dist/chunk-AZFUMCQB.js +2 -0
  36. package/dist/{chunk-IYAOX36F.js → chunk-BDOIKGDI.js} +2 -2
  37. package/dist/{chunk-7E3TH5ZN.js → chunk-BNXICU42.js} +2 -2
  38. package/dist/chunk-C5Q44Q5D.js +3 -0
  39. package/dist/{chunk-OQ2A4G2G.js → chunk-CTF2GDEX.js} +2 -2
  40. package/dist/chunk-DHEQMPLW.js +2 -0
  41. package/dist/{chunk-EVOC5I5I.js → chunk-DQBCO2UY.js} +2 -2
  42. package/dist/{chunk-YLVE3SXZ.js → chunk-DQGSM7RZ.js} +2 -2
  43. package/dist/chunk-E2LAW7SL.js +30 -0
  44. package/dist/chunk-E3HYEQO7.js +2 -0
  45. package/dist/chunk-E4NFOAD4.js +6 -0
  46. package/dist/chunk-E5HNT4X2.js +3 -0
  47. package/dist/{chunk-6XHTISLI.js → chunk-ELLMY7XJ.js} +2 -2
  48. package/dist/chunk-FD3HFKXR.js +5 -0
  49. package/dist/{chunk-RJHCPSZ7.js → chunk-FIJCV235.js} +2 -2
  50. package/dist/{chunk-KLVJABXA.js → chunk-FJ5UDTQF.js} +2 -2
  51. package/dist/{chunk-SHKZ7OVJ.js → chunk-GHKEJTCE.js} +2 -2
  52. package/dist/{chunk-JERWGHQT.js → chunk-GLZTVKAB.js} +3 -3
  53. package/dist/{chunk-A43URCQ3.js → chunk-GNC4JVAN.js} +2 -2
  54. package/dist/chunk-HIB452NU.js +949 -0
  55. package/dist/{chunk-U5CNPPTZ.js → chunk-HZYDQPNY.js} +2 -2
  56. package/dist/chunk-IF6FP6B2.js +66 -0
  57. package/dist/{chunk-CSTYYXKC.js → chunk-JAY7YWS3.js} +2 -2
  58. package/dist/{chunk-6XFC7PQ5.js → chunk-JHF3E4YM.js} +2 -2
  59. package/dist/chunk-JORHF5AL.js +108 -0
  60. package/dist/{chunk-QBYYWGAT.js → chunk-K2WO7XY7.js} +2 -2
  61. package/dist/chunk-KFZNKUNT.js +2 -0
  62. package/dist/{chunk-J7VT2CRB.js → chunk-KJ2IIBZN.js} +2 -2
  63. package/dist/{chunk-336DC5NJ.js → chunk-KKME5ZAI.js} +2 -2
  64. package/dist/chunk-KSGTULOS.js +9 -0
  65. package/dist/{chunk-E2ZXPB7J.js → chunk-KXDJAG4N.js} +3 -3
  66. package/dist/{chunk-Z2LHPIOM.js → chunk-L4S2A7BV.js} +2 -2
  67. package/dist/chunk-LP3ARJKF.js +8 -0
  68. package/dist/chunk-LSOR3LQG.js +3 -0
  69. package/dist/{chunk-FHCTEANE.js → chunk-MLFZP76A.js} +2 -2
  70. package/dist/{chunk-RBFFD4V2.js → chunk-MNSTUIDD.js} +2 -2
  71. package/dist/{chunk-3OIKRYU5.js → chunk-MSBDMFER.js} +2 -2
  72. package/dist/{chunk-7LABSJSR.js → chunk-MZZBAITE.js} +5 -5
  73. package/dist/{chunk-QQWOFXNW.js → chunk-NE3TZUCI.js} +2 -2
  74. package/dist/{chunk-JZNLMHWY.js → chunk-NTUMF2X3.js} +2 -2
  75. package/dist/{chunk-DD5BOU5I.js → chunk-O23I56NA.js} +2 -2
  76. package/dist/{chunk-YHXBD52M.js → chunk-O3O4XXO6.js} +2 -2
  77. package/dist/{chunk-FQTPPXNA.js → chunk-OUBAF226.js} +2 -2
  78. package/dist/chunk-P3UO3EH3.js +2 -0
  79. package/dist/{chunk-5OC3HWP5.js → chunk-QGGLL3UH.js} +2 -2
  80. package/dist/chunk-QIQ63BHW.js +16 -0
  81. package/dist/{chunk-RWRLUZ6U.js → chunk-QJIVBYEK.js} +2 -2
  82. package/dist/chunk-QOXBSI6G.js +20 -0
  83. package/dist/{chunk-7Q6VYYCH.js → chunk-QXK6UUSM.js} +2 -2
  84. package/dist/{chunk-ZTTISZ7J.js → chunk-RA3AYNWP.js} +2 -2
  85. package/dist/chunk-RJMDJR3A.js +2 -0
  86. package/dist/{chunk-TFUU5MQQ.js → chunk-RLH5VUMG.js} +2 -2
  87. package/dist/{chunk-OHWZKLVA.js → chunk-S4S2WOIX.js} +2 -2
  88. package/dist/{chunk-YTUD45PU.js → chunk-SERUIGV5.js} +2 -2
  89. package/dist/{chunk-2OXVAGGT.js → chunk-SMQWE25B.js} +2 -2
  90. package/dist/{chunk-K42M2KWT.js → chunk-TAVELHYR.js} +2 -2
  91. package/dist/{chunk-MGBJHRFB.js → chunk-TWMJ3Y3G.js} +2 -2
  92. package/dist/chunk-VAXNI5NE.js +146 -0
  93. package/dist/chunk-VVY2G5ET.js +2 -0
  94. package/dist/{chunk-XF3KLXN3.js → chunk-W3DBTGL4.js} +2 -2
  95. package/dist/{chunk-26X7KCJR.js → chunk-WANA4KAQ.js} +2 -2
  96. package/dist/chunk-WJL2L6MV.js +60 -0
  97. package/dist/chunk-WUW7YUAH.js +11 -0
  98. package/dist/{chunk-PC44K7RF.js → chunk-WWKWUPSU.js} +2 -2
  99. package/dist/{chunk-2EZSOTSY.js → chunk-WY45BHKQ.js} +2 -2
  100. package/dist/chunk-X4FR5BZF.js +9 -0
  101. package/dist/chunk-X6RKPDY7.js +2 -0
  102. package/dist/{chunk-GK3GRUJX.js → chunk-YLFORA5G.js} +2 -2
  103. package/dist/{chunk-NBRUH7OE.js → chunk-YTVWB7YJ.js} +2 -2
  104. package/dist/{chunk-YGQN3XGZ.js → chunk-ZCEJ63SP.js} +2 -2
  105. package/dist/{chunk-2GSQR6YA.js → chunk-ZJ5CBXK3.js} +2 -2
  106. package/dist/chunk-ZL2OGDCD.js +2 -0
  107. package/dist/cli.js +8 -3
  108. package/dist/command-descriptors-ZW5J4ZEM.js +631 -0
  109. package/dist/{config-types-BWQ5xPGI.d.ts → config-types-B6MEoRNy.d.ts} +4 -0
  110. package/dist/{db-B0r1o7Vt.d.ts → db-DYLKr9Wn.d.ts} +1 -1
  111. package/dist/direct-navigation-42YHQPOI.js +3 -0
  112. package/dist/{health-CFnlCiTz.d.ts → health-DgxIDXJC.d.ts} +1 -1
  113. package/dist/index.d.ts +2 -2
  114. package/dist/index.js +1 -1
  115. package/dist/postinstall.js +1 -1
  116. package/dist/queries/affected.d.ts +2 -2
  117. package/dist/queries/affected.js +1 -1
  118. package/dist/queries/architecture.d.ts +2 -2
  119. package/dist/queries/architecture.js +1 -1
  120. package/dist/queries/bottlenecks.d.ts +2 -2
  121. package/dist/queries/bottlenecks.js +1 -1
  122. package/dist/queries/by-kind.d.ts +2 -2
  123. package/dist/queries/by-kind.js +1 -1
  124. package/dist/queries/call-graph.d.ts +2 -2
  125. package/dist/queries/call-graph.js +1 -1
  126. package/dist/queries/change-surface.d.ts +2 -2
  127. package/dist/queries/change-surface.js +1 -1
  128. package/dist/queries/cleanup-plan.d.ts +2 -2
  129. package/dist/queries/cleanup-plan.js +1 -1
  130. package/dist/queries/co-change.d.ts +2 -2
  131. package/dist/queries/co-change.js +1 -1
  132. package/dist/queries/code.d.ts +2 -2
  133. package/dist/queries/code.js +1 -1
  134. package/dist/queries/complexity-hotspots.d.ts +2 -2
  135. package/dist/queries/complexity-hotspots.js +1 -1
  136. package/dist/queries/complexity.d.ts +2 -2
  137. package/dist/queries/complexity.js +1 -1
  138. package/dist/queries/convergence.d.ts +2 -2
  139. package/dist/queries/convergence.js +1 -1
  140. package/dist/queries/coupling.d.ts +2 -2
  141. package/dist/queries/coupling.js +1 -1
  142. package/dist/queries/cycles.d.ts +2 -2
  143. package/dist/queries/cycles.js +1 -1
  144. package/dist/queries/dataflow.d.ts +2 -2
  145. package/dist/queries/dataflow.js +1 -1
  146. package/dist/queries/dead.d.ts +2 -2
  147. package/dist/queries/dead.js +1 -1
  148. package/dist/queries/decorative-checkers.d.ts +2 -2
  149. package/dist/queries/decorative-checkers.js +1 -1
  150. package/dist/queries/deep-chains.d.ts +2 -2
  151. package/dist/queries/deep-chains.js +1 -1
  152. package/dist/queries/deps.d.ts +2 -2
  153. package/dist/queries/deps.js +1 -1
  154. package/dist/queries/diff-gate.d.ts +2 -2
  155. package/dist/queries/diff-gate.js +1 -1
  156. package/dist/queries/diff-impact.d.ts +2 -2
  157. package/dist/queries/diff-impact.js +1 -1
  158. package/dist/queries/doc-drift.d.ts +2 -2
  159. package/dist/queries/doc-drift.js +1 -1
  160. package/dist/queries/drift.d.ts +2 -2
  161. package/dist/queries/drift.js +1 -1
  162. package/dist/queries/duplicate-bodies.d.ts +2 -2
  163. package/dist/queries/duplicate-bodies.js +1 -1
  164. package/dist/queries/extract-candidates.d.ts +2 -2
  165. package/dist/queries/extract-candidates.js +1 -1
  166. package/dist/queries/fan.d.ts +2 -2
  167. package/dist/queries/fan.js +1 -1
  168. package/dist/queries/files.d.ts +2 -2
  169. package/dist/queries/health.d.ts +3 -3
  170. package/dist/queries/health.js +1 -1
  171. package/dist/queries/hierarchy.d.ts +2 -2
  172. package/dist/queries/hierarchy.js +1 -1
  173. package/dist/queries/hotspots.d.ts +2 -2
  174. package/dist/queries/hotspots.js +1 -1
  175. package/dist/queries/imports.d.ts +2 -2
  176. package/dist/queries/imports.js +1 -1
  177. package/dist/queries/incomplete-migration.d.ts +2 -2
  178. package/dist/queries/incomplete-migration.js +1 -1
  179. package/dist/queries/index.d.ts +3 -3
  180. package/dist/queries/index.js +1 -1
  181. package/dist/queries/isolated.d.ts +2 -2
  182. package/dist/queries/isolated.js +1 -1
  183. package/dist/queries/locality-candidates.d.ts +2 -2
  184. package/dist/queries/locality-candidates.js +1 -1
  185. package/dist/queries/members.d.ts +2 -2
  186. package/dist/queries/members.js +1 -1
  187. package/dist/queries/methods.d.ts +2 -2
  188. package/dist/queries/methods.js +1 -1
  189. package/dist/queries/not-implemented.d.ts +2 -2
  190. package/dist/queries/not-implemented.js +1 -1
  191. package/dist/queries/outline.d.ts +2 -2
  192. package/dist/queries/outline.js +1 -1
  193. package/dist/queries/passthrough-candidates.d.ts +2 -2
  194. package/dist/queries/passthrough-candidates.js +1 -1
  195. package/dist/queries/plan-context.d.ts +2 -2
  196. package/dist/queries/plan-context.js +1 -1
  197. package/dist/queries/react-component-duplicates.d.ts +2 -2
  198. package/dist/queries/react-component-duplicates.js +1 -1
  199. package/dist/queries/react-hook-candidates.d.ts +2 -2
  200. package/dist/queries/react-hook-candidates.js +1 -1
  201. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  202. package/dist/queries/react-large-component-pressure.js +1 -1
  203. package/dist/queries/recent-duplicates.d.ts +2 -2
  204. package/dist/queries/recent-duplicates.js +1 -1
  205. package/dist/queries/redundant-reexports.d.ts +2 -2
  206. package/dist/queries/redundant-reexports.js +1 -1
  207. package/dist/queries/refs.d.ts +2 -2
  208. package/dist/queries/refs.js +1 -1
  209. package/dist/queries/self-audit.d.ts +2 -2
  210. package/dist/queries/self-audit.js +1 -1
  211. package/dist/queries/similar-chains.d.ts +2 -2
  212. package/dist/queries/similar-chains.js +1 -1
  213. package/dist/queries/similar-files.d.ts +2 -2
  214. package/dist/queries/similar-files.js +1 -1
  215. package/dist/queries/similar-signatures.d.ts +2 -2
  216. package/dist/queries/similar-signatures.js +1 -1
  217. package/dist/queries/similar.d.ts +2 -2
  218. package/dist/queries/similar.js +1 -1
  219. package/dist/queries/slice.d.ts +2 -2
  220. package/dist/queries/slice.js +1 -1
  221. package/dist/queries/stale-abstractions.d.ts +2 -2
  222. package/dist/queries/stale-abstractions.js +1 -1
  223. package/dist/queries/stats.d.ts +2 -2
  224. package/dist/queries/surface.d.ts +2 -2
  225. package/dist/queries/surface.js +1 -1
  226. package/dist/queries/symbols.d.ts +2 -2
  227. package/dist/queries/symbols.js +1 -1
  228. package/dist/queries/system.d.ts +2 -2
  229. package/dist/queries/system.js +1 -1
  230. package/dist/queries/test-quality.d.ts +2 -2
  231. package/dist/queries/test-quality.js +1 -1
  232. package/dist/queries/trace.d.ts +2 -2
  233. package/dist/queries/trace.js +1 -1
  234. package/dist/queries/twin-ab.d.ts +2 -2
  235. package/dist/queries/twin-ab.js +1 -1
  236. package/dist/queries/twin-drift.d.ts +2 -2
  237. package/dist/queries/twin-drift.js +1 -1
  238. package/dist/queries/unused-imports.d.ts +2 -2
  239. package/dist/queries/unused-imports.js +1 -1
  240. package/dist/queries/unused-params.d.ts +2 -2
  241. package/dist/queries/unused-params.js +1 -1
  242. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  243. package/dist/queries/vue-component-duplicates.js +1 -1
  244. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  245. package/dist/queries/vue-composable-candidates.js +1 -1
  246. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  247. package/dist/queries/vue-large-view-pressure.js +1 -1
  248. package/dist/queries/wrapper-candidates.d.ts +2 -2
  249. package/dist/queries/wrapper-candidates.js +1 -1
  250. package/dist/reindex-worker.js +26 -25
  251. package/dist/reindex.d.ts +7 -3
  252. package/dist/reindex.js +34 -33
  253. package/dist/runtime.d.ts +3 -10
  254. package/dist/runtime.js +3 -3
  255. package/dist/rust-semantic-session-server.js +1 -1
  256. package/dist/rust-semantic-session-worker.js +1 -1
  257. package/dist/rust-semantic-worker.js +1 -1
  258. package/dist/{scip-cli-DCvnlZCu.d.ts → scip-cli-Cc6c00-a.d.ts} +2 -2
  259. package/dist/watch-server.js +5 -5
  260. package/docs/AGENT_GUIDE.md +19 -3
  261. package/docs/CLI_JSON_OUTPUT.md +86 -1
  262. package/docs/COMMAND_REFERENCE.md +5 -3
  263. package/docs/SECURITY_MODEL.md +129 -0
  264. package/docs/TELEMETRY_RETENTION.md +5 -0
  265. package/docs/schemas/cli-output-page.schema.json +104 -0
  266. package/package.json +8 -7
  267. package/skills/_shared/SKILL.md +4 -2
  268. package/skills/scip-audit/SKILL.md +3 -2
  269. package/skills/scip-explore/SKILL.md +1 -1
  270. package/skills/scip-improve/SKILL.md +1 -1
  271. package/skills/scip-plan/SKILL.md +1 -1
  272. package/skills/scip-verify/SKILL.md +7 -2
  273. package/dist/chunk-24QNP7MN.js +0 -2
  274. package/dist/chunk-2ZOCHAL2.js +0 -8
  275. package/dist/chunk-35SQLYCQ.js +0 -2
  276. package/dist/chunk-4CGVLUDP.js +0 -18
  277. package/dist/chunk-4RI4BJGT.js +0 -8
  278. package/dist/chunk-52HQTTPB.js +0 -2
  279. package/dist/chunk-A63U2W3P.js +0 -3
  280. package/dist/chunk-ADFSIJP2.js +0 -16
  281. package/dist/chunk-AOLE4DYM.js +0 -6
  282. package/dist/chunk-B5MHCHP3.js +0 -107
  283. package/dist/chunk-DGAGY7RJ.js +0 -60
  284. package/dist/chunk-DGMCFMPG.js +0 -11
  285. package/dist/chunk-GA64UPMI.js +0 -6
  286. package/dist/chunk-HEBAY673.js +0 -2
  287. package/dist/chunk-HELS7KFF.js +0 -2
  288. package/dist/chunk-IPDCSB6N.js +0 -6
  289. package/dist/chunk-JJJCO4QC.js +0 -945
  290. package/dist/chunk-KP4KBDVF.js +0 -3
  291. package/dist/chunk-LRTP3DKL.js +0 -3
  292. package/dist/chunk-P6HBYNBE.js +0 -5
  293. package/dist/chunk-QHKUY4FW.js +0 -2
  294. package/dist/chunk-QHRL4LKM.js +0 -2
  295. package/dist/chunk-UXP636P5.js +0 -144
  296. package/dist/chunk-VEVBIAOJ.js +0 -16
  297. package/dist/chunk-VKRQDBW5.js +0 -9
  298. package/dist/chunk-VOQFGC2W.js +0 -67
  299. package/dist/chunk-WMXRRBII.js +0 -8
  300. package/dist/chunk-X3NLZHPA.js +0 -20
  301. package/dist/chunk-Z5QQPJ3U.js +0 -30
  302. package/dist/chunk-ZLJLE6LK.js +0 -2
  303. package/dist/command-descriptors-SJDZ7QGR.js +0 -617
  304. package/dist/direct-navigation-HTKOZEOM.js +0 -3
@@ -1,4 +1,4 @@
1
- import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5XHIJHI.js";import{Ba as de,Ca as tn,Ea as nn,Ga as rn,Ha as Te,I as wt,J as _t,Ja as an,Ka as sn,L as q,La as on,N as jt,R as Dt,S as kt,T as Tt,U as Mt,V as Ot,W as At,Y as _e,Z as Lt,b as B,c as ne,d as ve,e as Ee,ea as Nt,f as re,fa as Ct,ga as $t,ha as Bt,ia as Gt,ja as Ut,k as gt,ka as Jt,la as Ht,m as ht,ma as Wt,na as qt,o as k,oa as zt,p as H,pa as z,qa as oe,r as vt,ra as Xt,t as Et,ta as ce,u as Ft,ua as Vt,v as ie,va as je,w as W,wa as Yt,xa as De,za as ke}from"./chunk-UXP636P5.js";import{a as ee,b as ct,c as te,e as yt,f as St,g as bt,i as Rt,j as It,m as j}from"./chunk-VOQFGC2W.js";import{g as pt,h as J,i as M,j as O,l as ft,m as we,n as mt,p as Pt,q as xt,s as Qt,v as Kt,w as Zt,x as en}from"./chunk-VKRQDBW5.js";import{e as w,f as G}from"./chunk-HGFDYOVB.js";import{a as P}from"./chunk-APMMR5Y2.js";import{a as U,b as dt,c as lt,d as Fe,e as ut}from"./chunk-HELS7KFF.js";import{execFileSync as Ja}from"child_process";import{createHash as Ha}from"crypto";import{copyFileSync as xe,existsSync as F,mkdirSync as be,mkdtempSync as Wa,readdirSync as gr,readFileSync as nt,renameSync as fr,rmSync as C,statSync as qa}from"fs";import{basename as Se,dirname as S,extname as za,join as I,resolve as ar}from"path";import{platform as Xa}from"os";import{execFileSync as ln}from"child_process";import{existsSync as Me,readFileSync as Nr}from"fs";import{createRequire as Cr}from"module";import{platform as un}from"os";import{dirname as dn,join as le}from"path";var $r=Cr(import.meta.url),A={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function Oe(e){return[e.indexerBinary,...e.binaryAliases??[]]}function ue(e){let t=Oe(e);return t.length===1?t[0]:t.join(" or ")}function X(e){for(let t of Oe(e))if(un()==="win32"){let n=lt(t);if(n)return n}else if(U(t))return t;return Gr(e)}function pn(e){return X(e)!==null||Br(e)}function Br(e){return gn(e)!==null}function Gr(e){let t=gn(e);if(!t)return null;let r=JSON.parse(Nr(t,"utf8")).bin;if(!r)return null;if(typeof r=="string")return le(dn(t),r);for(let i of Oe(e)){let a=r[i];if(a)return le(dn(t),a)}return null}function gn(e){if(!e.bundledNpmPackage)return null;try{return $r.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function fn(e,t){for(let n of e.projectLocalBinaries??[]){let r=le(t,n);if(Me(r))return r}return null}function mn(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||hn(n,t))return t;let r=Ur(n,t);return r?{...t,DOTNET_ROOT:r}:t}function Ur(e,t){for(let n of Jr(t))if(hn(e,{...t,DOTNET_ROOT:n}))return n;return null}function Jr(e){let t=[],n=e.DOTNET_ROOT;if(n&&Me(n)&&t.push(n),un()==="darwin"&&U("brew"))try{let r=ln("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),i=le(r,"libexec");Me(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function hn(e,t){try{return ln(e,["--version"],{stdio:"pipe",env:t,timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}var yn=Ft({kind:"file-dependency-graph",invalidation:ie("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:Yr}),Hr=Rt("file-dep-graph",{clearGroups:["whole-project"]});function L(e,t,n={}){let r=n.scipEdges??"all-references",i=n.sourceEdges??"imports-only",a=zr(t,r,i);return Hr.get(e,a,()=>{let s=new Set(j(e,{includeIgnored:!1})),o=vt(e),c=0,d=0,l=null,u=!1,p=0,h=0;return w("file-dep-graph.product",()=>{if(o){let f=yn.read(e,a,o);if(f){u=!0;let y=Vr(f);return c=f.sourceFileCount,d=f.sourceEdgeCount,p=f.scipEdgeCount,h=y.size,l=f.sourceDependencyFingerprint,y}}let g=w("file-dep-graph.source-imports",()=>{let f=Wr(e,s,t,i);return c=f.files.length,d=f.edges.length,l=f.fingerprint,f},()=>({scope:t??null,sourceEdges:i,files:c,edges:d})),m=new Map,b=(f,y)=>ei(e,m,s,f,y);w("file-dep-graph.scip-edges",()=>{for(let f of Zr(e,t,r))p+=1,b(f.from_file,f.to_file)},()=>({scope:t??null,edges:p}));for(let f of g.edges)b(f.fromFile,f.toFile);return h=m.size,o&&yn.write(e,a,o,{sourceDependencyFingerprint:g.fingerprint,sourceFileCount:g.files.length,sourceEdgeCount:g.edges.length,scipEdgeCount:p,graph:Xr(m)}),m},()=>({scope:t??null,available:o!==null,hit:u,files:c,sourceEdges:d,sourceEdgeMode:i,scipEdges:p,graphFiles:h,sourceDependencyFingerprint:l}))})}function Wr(e,t,n,r){let i=[],a=[];for(let s of t)if(!(n&&!s.includes(n))){i.push(s);for(let o of _t(e,s))o.sourcePath&&a.push({fromFile:s,toFile:o.sourcePath});if(r==="imports-and-reexports")for(let o of wt(e,s))o.sourcePath&&a.push({fromFile:s,toFile:o.sourcePath})}return{files:i,edges:a,fingerprint:qr(i,a)}}function qr(e,t){let n=t.map(r=>`${r.fromFile}\0${r.toFile}`).sort();return H(JSON.stringify({files:e,edges:n}))}function zr(e,t,n){return`edge-mode-v3:${t}:${n}:${e??"<all>"}`}function Xr(e){return[...e].map(([t,n])=>[t,[...n]])}function Vr(e){return new Map(e.graph.map(([t,n])=>[t,new Set(n)]))}function Yr(e){let t=JSON.parse(e);return Qr(t)?t:null}function Qr(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.sourceDependencyFingerprint=="string"&&typeof t.sourceFileCount=="number"&&typeof t.sourceEdgeCount=="number"&&typeof t.scipEdgeCount=="number"&&Array.isArray(t.graph)&&t.graph.every(Kr)}function Kr(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&Array.isArray(e[1])&&e[1].every(t=>typeof t=="string")}function Zr(e,t,n){let r=t?"AND d1.relative_path LIKE ?":"",i=t?[`%${t}%`]:[],a=n==="imports-only"?"AND m.role = 2":"AND m.role != 1";return e.all(`SELECT DISTINCT
1
+ import{a as ce,b as de}from"./chunk-3ZSJ3PWF.js";import{a as Sn}from"./chunk-P5XHIJHI.js";import{$ as Wt,A as Lt,Aa as $e,B as se,Ca as pe,Da as pn,Fa as gn,Ha as fn,Ia as Be,Ka as mn,La as hn,Ma as yn,N as Nt,Na as Ge,O as Ct,Q as z,S as $t,W as Bt,X as Gt,Y as Ut,Z as Ht,_ as Jt,b as U,ba as Le,c as ie,ca as qt,d as De,e as ke,fa as zt,ga as Xt,ha as Kt,ia as Vt,j as Me,ja as Yt,ka as Qt,l as oe,la as Zt,ma as en,na as tn,oa as nn,pa as rn,q as xt,qa as X,ra as le,s as vt,sa as an,u as k,ua as ue,v as q,va as on,wa as Ne,x as Ot,xa as sn,ya as Ce,z as At}from"./chunk-VAXNI5NE.js";import{b as kt,c as Mt,f as _}from"./chunk-IF6FP6B2.js";import{a as ne,b as ht,c as re,g as J,i as Et,j as Ft,k as jt,n as wt,o as Tt}from"./chunk-C5Q44Q5D.js";import{g as Pt,h as W,i as O,j as A,l as Rt,m as Ae,n as It,p as _t,q as Dt,s as cn,v as dn,w as ln,x as un}from"./chunk-X4FR5BZF.js";import{e as j,f as H}from"./chunk-HGFDYOVB.js";import{a as P}from"./chunk-APMMR5Y2.js";import{a as mt,c as Te,f as _e,g as te,h as T}from"./chunk-46XGSFNI.js";import{a as ae,b as yt,c as St,d as Oe,e as bt}from"./chunk-KFZNKUNT.js";import{execFileSync as so}from"child_process";import{createHash as co}from"crypto";import{copyFileSync as Fe,existsSync as F,mkdirSync as ve,mkdtempSync as lo,readdirSync as Tr,renameSync as _r,rmSync as B,statSync as uo}from"fs";import{basename as Ie,dirname as y,extname as po,join as I,resolve as xr}from"path";import{platform as go}from"os";import{execFileSync as Pn}from"child_process";import{createHash as Zr}from"crypto";import{existsSync as ge,statSync as ei}from"fs";import{createRequire as ti}from"module";import{platform as ni}from"os";import{dirname as bn,join as K}from"path";var ri=ti(import.meta.url),L={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function Ue(e){return[e.indexerBinary,...e.binaryAliases??[]]}function fe(e){let t=Ue(e);return t.length===1?t[0]:t.join(" or ")}function N(e){for(let t of Ue(e)){let n=St(t);if(n)return n}return ai(e)}function xn(e){return N(e)!==null||ii(e)}function ii(e){return Rn(e)!==null}function ai(e){let t=Rn(e);if(!t)return null;let r=JSON.parse(T(t,"indexer package manifest")).bin;if(!r)return null;if(typeof r=="string")return K(bn(t),r);for(let i of Ue(e)){let a=r[i];if(a)return K(bn(t),a)}return null}function Rn(e){if(!e.bundledNpmPackage)return null;try{return ri.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function In(e,t){for(let n of e.projectLocalBinaries??[]){let r=K(t,n);if(ge(r))return r}return null}function vn(e,t){for(let n of e.projectLocalBinaries??[]){let r=K(t,n);if(ge(r))return Fn(t,n,r)}return null}function En(e,t){let n=oi(e,t);if(!n||n.canonicalPath!==t.canonicalPath||n.sha256!==t.sha256||n.size!==t.size||n.mtimeMs!==t.mtimeMs||n.device!==t.device||n.inode!==t.inode||n.executable!==t.executable)throw new Error(`refusing changed project-local indexer ${t.relativePath}; review the current file and rerun with --trust-project-tools`)}function oi(e,t){try{return Fn(e,t.relativePath,t.configuredPath)}catch{return null}}function Fn(e,t,n){let r={maxBytes:268435456,inputKind:"project-local indexer"},i=Ft(e,t,r),a=jt(e,t,r),o=ei(i.absolutePath);return{configuredPath:n,canonicalPath:i.absolutePath,relativePath:t,sha256:Zr("sha256").update(a).digest("hex"),size:i.size,mtimeMs:i.mtimeMs,device:i.device,inode:i.inode,executable:(o.mode&73)!==0}}function jn(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||wn(n,t))return t;let r=si(n,t);return r?{...t,DOTNET_ROOT:r}:t}function si(e,t){for(let n of ci(t))if(wn(e,{...t,DOTNET_ROOT:n}))return n;return null}function ci(e){let t=[],n=e.DOTNET_ROOT;if(n&&ge(n)&&t.push(n),ni()==="darwin"&&ae("brew"))try{let r=Pn("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),i=K(r,"libexec");ge(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function wn(e,t){try{return Pn(e,["--version"],{stdio:"pipe",env:t,timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}var Tn=Lt({kind:"file-dependency-graph",invalidation:se("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:mi}),di=kt("file-dep-graph",{clearGroups:["whole-project"]});function C(e,t,n={}){let r=n.scipEdges??"all-references",i=n.sourceEdges??"imports-only",a=pi(t,r,i);return di.get(e,a,()=>{let o=new Set(_(e,{includeIgnored:!1})),s=Ot(e),d=0,c=0,l=null,u=!1,p=0,h=0;return j("file-dep-graph.product",()=>{if(s){let f=Tn.read(e,a,s);if(f){u=!0;let S=fi(f);return d=f.sourceFileCount,c=f.sourceEdgeCount,p=f.scipEdgeCount,h=S.size,l=f.sourceDependencyFingerprint,S}}let g=j("file-dep-graph.source-imports",()=>{let f=li(e,o,t,i);return d=f.files.length,c=f.edges.length,l=f.fingerprint,f},()=>({scope:t??null,sourceEdges:i,files:d,edges:c})),m=new Map,b=(f,S)=>bi(e,m,o,f,S);j("file-dep-graph.scip-edges",()=>{for(let f of Si(e,t,r))p+=1,b(f.from_file,f.to_file)},()=>({scope:t??null,edges:p}));for(let f of g.edges)b(f.fromFile,f.toFile);return h=m.size,s&&Tn.write(e,a,s,{sourceDependencyFingerprint:g.fingerprint,sourceFileCount:g.files.length,sourceEdgeCount:g.edges.length,scipEdgeCount:p,graph:gi(m)}),m},()=>({scope:t??null,available:s!==null,hit:u,files:d,sourceEdges:c,sourceEdgeMode:i,scipEdges:p,graphFiles:h,sourceDependencyFingerprint:l}))})}function li(e,t,n,r){let i=[],a=[];for(let o of t)if(!(n&&!o.includes(n))){i.push(o);for(let s of Ct(e,o))s.sourcePath&&a.push({fromFile:o,toFile:s.sourcePath});if(r==="imports-and-reexports")for(let s of Nt(e,o))s.sourcePath&&a.push({fromFile:o,toFile:s.sourcePath})}return{files:i,edges:a,fingerprint:ui(i,a)}}function ui(e,t){let n=t.map(r=>`${r.fromFile}\0${r.toFile}`).sort();return q(JSON.stringify({files:e,edges:n}))}function pi(e,t,n){return`edge-mode-v3:${t}:${n}:${e??"<all>"}`}function gi(e){return[...e].map(([t,n])=>[t,[...n]])}function fi(e){return new Map(e.graph.map(([t,n])=>[t,new Set(n)]))}function mi(e){let t=JSON.parse(e);return hi(t)?t:null}function hi(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.sourceDependencyFingerprint=="string"&&typeof t.sourceFileCount=="number"&&typeof t.sourceEdgeCount=="number"&&typeof t.scipEdgeCount=="number"&&Array.isArray(t.graph)&&t.graph.every(yi)}function yi(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&Array.isArray(e[1])&&e[1].every(t=>typeof t=="string")}function Si(e,t,n){let r=t?"AND d1.relative_path LIKE ?":"",i=t?[`%${t}%`]:[],a=n==="imports-only"?"AND m.role = 2":"AND m.role != 1";return e.all(`SELECT DISTINCT
2
2
  d1.relative_path AS from_file,
3
3
  d2.relative_path AS to_file
4
4
  FROM mentions m
@@ -16,7 +16,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
16
16
  WHERE d1.id != d2.id
17
17
  ${a}
18
18
  ${e.pathExclusionsFor("d1","d2")}
19
- ${r}`,...i)}function ei(e,t,n,r,i){if(r===i||e.isIgnored(r)||e.isIgnored(i)||!n.has(i))return;let a=t.get(r);a||(a=new Set,t.set(r,a)),a.add(i)}function ge(e){let t=pe(e.projectFiles),n=new Set(t),r=new Map(e.snapshot.files.map(u=>[u.path,u])),i=e.snapshot.files.filter(u=>{let p=ee(u.path,["typescript"]);return p==="config"||p==="ambient"}).map(u=>u.path),a=pe([...t,...i]),s=a.find(u=>!r.has(u)),o=new Set(e.snapshot.files.map(u=>u.path)).size!==e.snapshot.files.length,c=!s&&a.some(u=>Sn(r.get(u))),d=H(JSON.stringify({pnpmWorkspaces:e.snapshot.pnpmWorkspaces,typescriptProjectMode:e.snapshot.typescriptProjectMode,typescriptProjects:pe(e.snapshot.typescriptProjects),membership:t})),l=new Map;return{identityFor(u,p){if(!n.has(u))return N("target-outside-project");if(o)return N("duplicate-input-path");if(s)return N("missing-input-fingerprint");if(c)return N("unreadable-input");let h=[],g,m;if(e.graph===null)h.push("dependency-graph-unavailable"),m="whole-project",g=a;else{let y=ni(u,e.graph,l);if(y.find(R=>!r.has(R)))return N("missing-input-fingerprint");if(g=pe([...y,...i]),g.some(R=>Sn(r.get(R))))return N("unreadable-input");m="dependency-closure"}let b=g.map(y=>ri(r.get(y)));return{version:1,key:H(JSON.stringify({version:1,engineIdentity:e.engineIdentity,schemaVersion:p,projectIdentity:d,inputs:b})),mode:m,inputFiles:g,reasons:h}}}}function ti(e,t){let n=new Set,r=[e];for(let i=0;i<r.length;i+=1){let a=r[i];if(!(a===void 0||n.has(a))){n.add(a);for(let s of[...t.get(a)??[]].sort())n.has(s)||r.push(s)}}return[...n].sort()}function ni(e,t,n){let r=n.get(e);if(r)return r;let i=ti(e,t);return n.set(e,i),i}function ri(e){return{path:e.path,size:e.size,hash:e.hash}}function Sn(e){return e.size<0||e.hash==="unreadable"}function N(e){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[e]}}function pe(e){return[...new Set(e)].sort()}var io=It("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function bn(e){return j(e,{includeIgnored:!1}).filter(q).sort()}var ii="typescript-reference-fragment-v2",ai=Et({kind:"typescript-reference-fragments",invalidation:ie("typescript-reference-fragments"),serialize:e=>JSON.stringify(e),deserialize:si});function Pn(e,t,n,r=e){let i=bn(e),a=ge({projectFiles:i,snapshot:t,graph:L(e),engineIdentity:jt()}),s=[...n].map(([o,c])=>({relativePath:o,contentHash:a.identityFor(o,ii).key,value:[...c]}));if(s.some(o=>o.contentHash===null))throw new Error("TypeScript reference fragment identity is unavailable for an affected document.");return ai.writeBatch(r,s.map(o=>({...o,contentHash:o.contentHash}))),s.length}function si(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(oi)?null:t}catch{return null}}function oi(e){if(!e||typeof e!="object")return!1;let t=e,n=t.location;return typeof t.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}import{createHash as di}from"crypto";import{existsSync as li,readFileSync as yo}from"fs";import{dirname as ui,join as Rn}from"path";function Ae(e){let t=new Set;for(let n of e.uncertainty)t.add(n);e.projectIdentityChanged&&t.add("project-identity-changed");for(let n of e.changes)n.kind==="added"&&t.add("file-added"),n.kind==="deleted"&&t.add("file-deleted"),n.inputKind==="config"&&t.add("configuration-changed"),n.inputKind==="ambient"&&t.add("ambient-declaration-changed"),n.inputKind==="other"&&t.add("unclassified-input");return{fullProject:t.size>0,reasons:[...t].sort()}}function fe(e,t,n){let r=e.changes.map(o=>o.path).sort();if(r.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:r,affectedFiles:[],reasons:[]};let i=new Set(n),a=Ae(e),s=new Set(a.reasons);return r.some(o=>!i.has(o))&&s.add("changed-file-outside-project"),t===null?(s.add("dependency-graph-unavailable"),xn(r,i,s)):s.size>0?xn(r,i,s):{mode:"closure",changedFiles:r,affectedFiles:ci(r,t,i),reasons:[]}}function xn(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function ci(e,t,n){let r=new Map;for(let[s,o]of t)if(n.has(s))for(let c of o){if(!n.has(c))continue;let d=r.get(c)??new Set;d.add(s),r.set(c,d)}let i=new Set(e),a=[...e];for(let s=0;s<a.length;s+=1){let o=a[s];if(o!==void 0)for(let c of r.get(o)??[])i.has(c)||(i.add(c),a.push(c))}return[...i].sort()}var pi="<global-symbols>";function gi(e){let t=[];for(let n of e.all(`
19
+ ${r}`,...i)}function bi(e,t,n,r,i){if(r===i||e.isIgnored(r)||e.isIgnored(i)||!n.has(i))return;let a=t.get(r);a||(a=new Set,t.set(r,a)),a.add(i)}function he(e){let t=me(e.projectFiles),n=new Set(t),r=new Map(e.snapshot.files.map(u=>[u.path,u])),i=e.snapshot.files.filter(u=>{let p=ne(u.path,["typescript"]);return p==="config"||p==="ambient"}).map(u=>u.path),a=me([...t,...i]),o=a.find(u=>!r.has(u)),s=new Set(e.snapshot.files.map(u=>u.path)).size!==e.snapshot.files.length,d=!o&&a.some(u=>_n(r.get(u))),c=q(JSON.stringify({pnpmWorkspaces:e.snapshot.pnpmWorkspaces,typescriptProjectMode:e.snapshot.typescriptProjectMode,typescriptProjects:me(e.snapshot.typescriptProjects),membership:t})),l=new Map;return{identityFor(u,p){if(!n.has(u))return $("target-outside-project");if(s)return $("duplicate-input-path");if(o)return $("missing-input-fingerprint");if(d)return $("unreadable-input");let h=[],g,m;if(e.graph===null)h.push("dependency-graph-unavailable"),m="whole-project",g=a;else{let S=xi(u,e.graph,l);if(S.find(R=>!r.has(R)))return $("missing-input-fingerprint");if(g=me([...S,...i]),g.some(R=>_n(r.get(R))))return $("unreadable-input");m="dependency-closure"}let b=g.map(S=>Ri(r.get(S)));return{version:1,key:q(JSON.stringify({version:1,engineIdentity:e.engineIdentity,schemaVersion:p,projectIdentity:c,inputs:b})),mode:m,inputFiles:g,reasons:h}}}}function Pi(e,t){let n=new Set,r=[e];for(let i=0;i<r.length;i+=1){let a=r[i];if(!(a===void 0||n.has(a))){n.add(a);for(let o of[...t.get(a)??[]].sort())n.has(o)||r.push(o)}}return[...n].sort()}function xi(e,t,n){let r=n.get(e);if(r)return r;let i=Pi(e,t);return n.set(e,i),i}function Ri(e){return{path:e.path,size:e.size,hash:e.hash}}function _n(e){return e.size<0||e.hash==="unreadable"}function $(e){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[e]}}function me(e){return[...new Set(e)].sort()}var Fs=Mt("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function Dn(e){return _(e,{includeIgnored:!1}).filter(z).sort()}var Ii="typescript-reference-fragment-v2",vi=At({kind:"typescript-reference-fragments",invalidation:se("typescript-reference-fragments"),serialize:e=>JSON.stringify(e),deserialize:Ei});function kn(e,t,n,r=e){let i=Dn(e),a=he({projectFiles:i,snapshot:t,graph:C(e),engineIdentity:$t()}),o=[...n].map(([s,d])=>({relativePath:s,contentHash:a.identityFor(s,Ii).key,value:[...d]}));if(o.some(s=>s.contentHash===null))throw new Error("TypeScript reference fragment identity is unavailable for an affected document.");return vi.writeBatch(r,o.map(s=>({...s,contentHash:s.contentHash}))),o.length}function Ei(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(Fi)?null:t}catch{return null}}function Fi(e){if(!e||typeof e!="object")return!1;let t=e,n=t.location;return typeof t.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}import{createHash as wi}from"crypto";import{existsSync as Ti}from"fs";import{dirname as _i,join as On}from"path";function He(e){let t=new Set;for(let n of e.uncertainty)t.add(n);e.projectIdentityChanged&&t.add("project-identity-changed");for(let n of e.changes)n.kind==="added"&&t.add("file-added"),n.kind==="deleted"&&t.add("file-deleted"),n.inputKind==="config"&&t.add("configuration-changed"),n.inputKind==="ambient"&&t.add("ambient-declaration-changed"),n.inputKind==="other"&&t.add("unclassified-input");return{fullProject:t.size>0,reasons:[...t].sort()}}function ye(e,t,n){let r=e.changes.map(s=>s.path).sort();if(r.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:r,affectedFiles:[],reasons:[]};let i=new Set(n),a=He(e),o=new Set(a.reasons);return r.some(s=>!i.has(s))&&o.add("changed-file-outside-project"),t===null?(o.add("dependency-graph-unavailable"),Mn(r,i,o)):o.size>0?Mn(r,i,o):{mode:"closure",changedFiles:r,affectedFiles:ji(r,t,i),reasons:[]}}function Mn(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function ji(e,t,n){let r=new Map;for(let[o,s]of t)if(n.has(o))for(let d of s){if(!n.has(d))continue;let c=r.get(d)??new Set;c.add(o),r.set(d,c)}let i=new Set(e),a=[...e];for(let o=0;o<a.length;o+=1){let s=a[o];if(s!==void 0)for(let d of r.get(s)??[])i.has(d)||(i.add(d),a.push(d))}return[...i].sort()}var Di="<global-symbols>";function ki(e){let t=[];for(let n of e.all(`
20
20
  SELECT relative_path, language, position_encoding, text
21
21
  FROM documents
22
22
  `))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
@@ -43,7 +43,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
43
43
  FROM defn_enclosing_ranges r
44
44
  JOIN documents d ON d.id = r.document_id
45
45
  JOIN global_symbols g ON g.id = r.symbol_id
46
- `))t.push({relativePath:n.relative_path,kind:"definition",values:Le(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
46
+ `))t.push({relativePath:n.relative_path,kind:"definition",values:Je(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
47
47
  SELECT d.relative_path,
48
48
  c.chunk_index,
49
49
  m.role,
@@ -58,7 +58,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
58
58
  JOIN chunks c ON c.id = m.chunk_id
59
59
  JOIN documents d ON d.id = c.document_id
60
60
  JOIN global_symbols g ON g.id = m.symbol_id
61
- `))t.push({relativePath:n.relative_path,kind:"mention",values:Le(n,[n.chunk_index,n.role])});for(let n of e.all(`
61
+ `))t.push({relativePath:n.relative_path,kind:"mention",values:Je(n,[n.chunk_index,n.role])});for(let n of e.all(`
62
62
  SELECT g.symbol,
63
63
  g.display_name,
64
64
  g.kind,
@@ -72,8 +72,8 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
72
72
  ) AND NOT EXISTS (
73
73
  SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
74
74
  )
75
- `))t.push({relativePath:pi,kind:"global-symbol",values:Le(n)});return fi(t)}function fi(e){let t=new Map;for(let r of e){let i=JSON.stringify([r.kind,r.values]),a=t.get(r.relativePath)??[];a.push(i),t.set(r.relativePath,a)}let n=new Map;for(let[r,i]of[...t].sort(([a],[s])=>a.localeCompare(s))){let a=di("sha256");for(let s of i.sort())a.update(String(Buffer.byteLength(s))),a.update(":"),a.update(s),a.update(`
76
- `);n.set(r,a.digest("hex"))}return n}function mi(e,t){let n=[],r=[],i=[],a=[],s=new Set([...e.keys(),...t.keys()]);for(let o of[...s].sort()){let c=e.get(o),d=t.get(o);c===void 0?n.push(o):d===void 0?i.push(o):c!==d?r.push(o):a.push(o)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:a}}function Ne(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),a=e.mode==="full-project"?[]:t.changedFiles.filter(c=>!r.has(c)),s=e.affectedFiles.filter(c=>!i.has(c)).sort(),o=t.changedFiles.length-a.length;return{passed:a.length===0,recall:t.changedFiles.length===0?1:o/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:a,extraFiles:s}}function Ce(e,t=xi){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,a=r(),s=(d,l)=>{let u=r();return Fn(e.refreshResult,d,n?u:i(),Math.max(0,u-a),l)};if(!t.databaseExists(e.previousDbPath))return s("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return s("candidate-index-unavailable");let o=null,c=null;try{o=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let d=[...new Set([...t.indexedPaths(o),...t.indexedPaths(c)])].sort(),l=te(e.previousSnapshot,e.currentSnapshot),u=new Set(d),p=l.changes.length>0&&!Ae(l).fullProject&&l.changes.every(b=>u.has(b.path)),h=fe(l,p?t.dependencyGraph(o):new Map,d),g=mi(t.factDigests(o),t.factDigests(c)),m=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?m:i()).toISOString(),durationMs:Math.max(0,m-a),manifest:l,plan:h,comparison:g,evaluation:Ne(h,g,d.length)}}catch(d){return s("oracle-error",d instanceof Error?d.message:String(d))}finally{In(o),In(c)}}function vn(e,t,n,r=Date.now()){return Fn(e,t,r,0,n)}function hi(e){let t=ui(e);return{latestPath:Rn(t,"affected-shadow-latest.json"),historyPath:Rn(t,"affected-shadow.jsonl")}}function En(e,t,n=Ri){let r=hi(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var yi=8*1024*1024,Si=Dt;function bi(e){let t={historyVersion:1,sourceVersion:e.version,refreshResult:e.refreshResult,recordedAt:e.recordedAt,durationMs:e.durationMs};return e.status==="unavailable"?{...t,status:"unavailable",reason:e.reason,...e.error?{error:e.error}:{}}:{...t,status:"evaluated",mode:e.plan.mode,passed:e.evaluation.passed,recall:e.evaluation.recall,affectedRatio:e.evaluation.affectedRatio,predictedFileCount:e.evaluation.predictedFiles.length,actualFileCount:e.evaluation.actualFiles.length,missingFileCount:e.evaluation.missingFiles.length,fallbackReasons:[...e.plan.reasons]}}function Pi(e,t,n=yi){kt(e,bi(t),{maxSegmentBytes:n,previousSuffix:Si})}function Le(e,t=[]){let n=[];for(let r of t)n.push(r);return n.push(e.symbol,e.display_name,e.kind,e.documentation,e.signature_hex,e.enclosing_symbol,e.relationships_hex),n}var xi={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:P,databaseExists:e=>li(e),openDatabase:(e,t,n)=>new k({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>j(e),dependencyGraph:e=>L(e),factDigests:e=>gi(e)},Ri={appendHistory:Pi,writeLatest:(e,t)=>Pt(e,t,{spacing:2,trailingNewline:!0})};function Fn(e,t,n,r,i){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...i?{error:i}:{}}}function In(e){try{e?.close()}catch{}}import{existsSync as wn,readdirSync as Ii}from"fs";import{isAbsolute as vi,join as $e,resolve as Ei}from"path";var Fi={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>{let i=r?["index","--output",e,"--no-progress-bar",r]:["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return t&&!r&&i.splice(1,0,"--pnpm-workspaces"),{binary:n,args:i}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:A.language,indexerBinary:A.indexerBinary,checkCommand:`${A.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:A.indexerBinary,args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:A.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","scip-python-plus"]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let i=["-root",e,"-output",t];return r&&i.push("-config",vi(r)?r:Ei(e,r)),{binary:n,args:i}},markerFiles:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:["go.mod"],installMethods:[{label:"go install",prerequisite:"go",binary:"go",args:["install","github.com/sourcegraph/scip-go@latest"]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",_n(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",_n(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({projectRoot:e,indexerBinary:t})=>{let n=$e(e,"vendor","bin","scip-php"),r=$e(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",wn(r)?r:wn(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Be(e){return Fi[e]}function _n(e,t){let n;try{n=Ii(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return $e(e,i);return null}import{createHash as wi}from"crypto";import{copyFileSync as _i,existsSync as jn,rmSync as Dn}from"fs";import{resolve as ji}from"path";import Mn from"better-sqlite3";var Di={documents:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"language",type:"TEXT",notnull:0,pk:0},{name:"relative_path",type:"TEXT",notnull:1,pk:0},{name:"position_encoding",type:"TEXT",notnull:0,pk:0},{name:"text",type:"TEXT",notnull:0,pk:0}],chunks:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"chunk_index",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"occurrences",type:"BLOB",notnull:1,pk:0}],global_symbols:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"symbol",type:"TEXT",notnull:1,pk:0},{name:"display_name",type:"TEXT",notnull:0,pk:0},{name:"kind",type:"INTEGER",notnull:0,pk:0},{name:"documentation",type:"TEXT",notnull:0,pk:0},{name:"signature",type:"BLOB",notnull:0,pk:0},{name:"enclosing_symbol",type:"TEXT",notnull:0,pk:0},{name:"relationships",type:"BLOB",notnull:0,pk:0}],mentions:[{name:"chunk_id",type:"INTEGER",notnull:1,pk:1},{name:"symbol_id",type:"INTEGER",notnull:1,pk:2},{name:"role",type:"INTEGER",notnull:1,pk:3}],defn_enclosing_ranges:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"symbol_id",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"start_char",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"end_char",type:"INTEGER",notnull:1,pk:0}]},ki={idx_chunks_doc_id:{table:"chunks",columns:["document_id"]},idx_chunks_line_range:{table:"chunks",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_document:{table:"defn_enclosing_ranges",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_symbol_id:{table:"defn_enclosing_ranges",columns:["symbol_id"]},idx_global_symbols_symbol:{table:"global_symbols",columns:["symbol"]},idx_mentions_symbol_id_role:{table:"mentions",columns:["symbol_id","role"]}};function On(e){let t=P(),n=Ti(e.affectedFiles);if(Mi(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Dn(e.candidateDbPath,{force:!0}),!jn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!jn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");kn(e.previousDbPath,"previous SQLite generation",!1),kn(e.miniDbPath,"incremental SQLite mini database"),_i(e.previousDbPath,e.candidateDbPath);let r=null;try{r=new Mn(e.candidateDbPath,{fileMustExist:!0}),r.pragma("busy_timeout = 5000"),r.pragma("foreign_keys = ON"),r.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Ge(r,"main","candidate SQLite generation"),Ge(r,"incremental","incremental SQLite mini database"),Oi(r,n),Ai(r,n.length);let i=Ue(r,"main",!0),a=D(r,"SELECT COUNT(*) AS value FROM main.documents");r.transaction(()=>{Li(r),Ni(r),Ci(r),e.onStage?.("after-delete"),$i(r),e.onStage?.("after-symbol-reconciliation"),Bi(r),e.onStage?.("after-insert"),Gi(r),Ui(r,n.length,a),e.onStage?.("before-commit")}).immediate(),An(r,"main","candidate SQLite generation");let c=[...Ji(r)].filter(([d,l])=>i.get(d)!==l).map(([d])=>d).sort();return r.exec("DETACH DATABASE incremental"),r.close(),r=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:c,durationMs:P()-t}}catch(i){try{r?.close()}finally{Dn(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${i instanceof Error?i.message:String(i)}`,{cause:i})}}function Ti(e){if(e.length===0)throw new Error("incremental SQLite publication requires affected documents");let t=[...e].sort();for(let n of t)if(!n||n.startsWith("/")||n.includes("\\")||n.split("/").includes(".."))throw new Error(`invalid affected document path: ${n}`);if(new Set(t).size!==t.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return t}function Mi(e,t,n){let r=[e,t,n].map(i=>ji(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function kn(e,t,n=!0){let r=new Mn(e,{readonly:!0,fileMustExist:!0});try{Ge(r,"main",t),n&&An(r,"main",t)}finally{r.close()}}function Ge(e,t,n){for(let[r,i]of Object.entries(Di)){let s=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:o,type:c,notnull:d,pk:l})=>({name:o,type:c.toUpperCase(),notnull:d,pk:l}));if(JSON.stringify(s)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(ki)){let a=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),s=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(o=>o.name);if(a?.tbl_name!==i.table||JSON.stringify(s)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}Tn(e,t,"documents",["relative_path"],n),Tn(e,t,"global_symbols",["symbol"],n)}function Tn(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(o=>{if(o.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${o.name}')`).all().map(d=>d.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function An(e,t,n){let r=e.prepare(`PRAGMA ${t}.integrity_check`).pluck().get();if(r!=="ok")throw new Error(`${n} failed integrity_check: ${String(r)}`);if(e.prepare(`PRAGMA ${t}.foreign_key_check`).all().length>0)throw new Error(`${n} failed foreign_key_check`)}function Oi(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(i=>{for(let a of i)n.run(a)})(t)}function Ai(e,t){let n=D(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=D(e,`SELECT COUNT(*) AS value
75
+ `))t.push({relativePath:Di,kind:"global-symbol",values:Je(n)});return Mi(t)}function Mi(e){let t=new Map;for(let r of e){let i=JSON.stringify([r.kind,r.values]),a=t.get(r.relativePath)??[];a.push(i),t.set(r.relativePath,a)}let n=new Map;for(let[r,i]of[...t].sort(([a],[o])=>a.localeCompare(o))){let a=wi("sha256");for(let o of i.sort())a.update(String(Buffer.byteLength(o))),a.update(":"),a.update(o),a.update(`
76
+ `);n.set(r,a.digest("hex"))}return n}function Oi(e,t){let n=[],r=[],i=[],a=[],o=new Set([...e.keys(),...t.keys()]);for(let s of[...o].sort()){let d=e.get(s),c=t.get(s);d===void 0?n.push(s):c===void 0?i.push(s):d!==c?r.push(s):a.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:a}}function We(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),a=e.mode==="full-project"?[]:t.changedFiles.filter(d=>!r.has(d)),o=e.affectedFiles.filter(d=>!i.has(d)).sort(),s=t.changedFiles.length-a.length;return{passed:a.length===0,recall:t.changedFiles.length===0?1:s/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:a,extraFiles:o}}function qe(e,t=Bi){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,a=r(),o=(c,l)=>{let u=r();return Cn(e.refreshResult,c,n?u:i(),Math.max(0,u-a),l)};if(!t.databaseExists(e.previousDbPath))return o("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return o("candidate-index-unavailable");let s=null,d=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),d=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let c=[...new Set([...t.indexedPaths(s),...t.indexedPaths(d)])].sort(),l=re(e.previousSnapshot,e.currentSnapshot),u=new Set(c),p=l.changes.length>0&&!He(l).fullProject&&l.changes.every(b=>u.has(b.path)),h=ye(l,p?t.dependencyGraph(s):new Map,c),g=Oi(t.factDigests(s),t.factDigests(d)),m=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?m:i()).toISOString(),durationMs:Math.max(0,m-a),manifest:l,plan:h,comparison:g,evaluation:We(h,g,c.length)}}catch(c){return o("oracle-error",c instanceof Error?c.message:String(c))}finally{An(s),An(d)}}function Ln(e,t,n,r=Date.now()){return Cn(e,t,r,0,n)}function Ai(e){let t=_i(e);return{latestPath:On(t,"affected-shadow-latest.json"),historyPath:On(t,"affected-shadow.jsonl")}}function Nn(e,t,n=Gi){let r=Ai(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var Li=8*1024*1024,Ni=Bt;function Ci(e){let t={historyVersion:1,sourceVersion:e.version,refreshResult:e.refreshResult,recordedAt:e.recordedAt,durationMs:e.durationMs};return e.status==="unavailable"?{...t,status:"unavailable",reason:e.reason,...e.error?{error:e.error}:{}}:{...t,status:"evaluated",mode:e.plan.mode,passed:e.evaluation.passed,recall:e.evaluation.recall,affectedRatio:e.evaluation.affectedRatio,predictedFileCount:e.evaluation.predictedFiles.length,actualFileCount:e.evaluation.actualFiles.length,missingFileCount:e.evaluation.missingFiles.length,fallbackReasons:[...e.plan.reasons]}}function $i(e,t,n=Li){Gt(e,Ci(t),{maxSegmentBytes:n,previousSuffix:Ni})}function Je(e,t=[]){let n=[];for(let r of t)n.push(r);return n.push(e.symbol,e.display_name,e.kind,e.documentation,e.signature_hex,e.enclosing_symbol,e.relationships_hex),n}var Bi={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:P,databaseExists:e=>Ti(e),openDatabase:(e,t,n)=>new k({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>_(e),dependencyGraph:e=>C(e),factDigests:e=>ki(e)},Gi={appendHistory:$i,writeLatest:(e,t)=>_t(e,t,{spacing:2,trailingNewline:!0})};function Cn(e,t,n,r,i){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...i?{error:i}:{}}}function An(e){try{e?.close()}catch{}}import{readdirSync as Ui}from"fs";import{isAbsolute as $n,join as Hi,resolve as Ji}from"path";var Se="@sourcegraph/scip-typescript@0.4.0",Bn="scip-python-plus@0.7.5",Gn="github.com/sourcegraph/scip-go@v0.2.7",Un="scip-dotnet@0.2.14",Wi="scip_dart@1.6.2",qi={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>{let i=r?["index","--output",e,"--no-progress-bar",r]:["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return t&&!r&&i.splice(1,0,"--pnpm-workspaces"),{binary:n,args:i}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",identity:Se,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Se]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",identity:Se,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Se]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:L.language,indexerBinary:L.indexerBinary,checkCommand:`${L.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:L.indexerBinary,args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[],installUrl:L.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",identity:Bn,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Bn]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let i=["-root",e,"-output",t];return r&&i.push("-config",$n(r)?r:Ji(e,r)),{binary:n,args:i}},markerFiles:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:["go.mod"],installMethods:[{label:"go install",identity:Gn,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",Gn]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Hn(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",identity:Un,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Hn(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",identity:Un,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",identity:Wi,destination:"Dart pub global cache",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart","1.6.2"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({indexerBinary:e})=>$n(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function ze(e){return qi[e]}function Hn(e,t){let n;try{n=Ui(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return Hi(e,i);return null}import{createHash as zi}from"crypto";import{copyFileSync as Xi,existsSync as Jn,rmSync as Wn}from"fs";import{resolve as Ki}from"path";import Xn from"better-sqlite3";var Vi={documents:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"language",type:"TEXT",notnull:0,pk:0},{name:"relative_path",type:"TEXT",notnull:1,pk:0},{name:"position_encoding",type:"TEXT",notnull:0,pk:0},{name:"text",type:"TEXT",notnull:0,pk:0}],chunks:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"chunk_index",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"occurrences",type:"BLOB",notnull:1,pk:0}],global_symbols:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"symbol",type:"TEXT",notnull:1,pk:0},{name:"display_name",type:"TEXT",notnull:0,pk:0},{name:"kind",type:"INTEGER",notnull:0,pk:0},{name:"documentation",type:"TEXT",notnull:0,pk:0},{name:"signature",type:"BLOB",notnull:0,pk:0},{name:"enclosing_symbol",type:"TEXT",notnull:0,pk:0},{name:"relationships",type:"BLOB",notnull:0,pk:0}],mentions:[{name:"chunk_id",type:"INTEGER",notnull:1,pk:1},{name:"symbol_id",type:"INTEGER",notnull:1,pk:2},{name:"role",type:"INTEGER",notnull:1,pk:3}],defn_enclosing_ranges:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"symbol_id",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"start_char",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"end_char",type:"INTEGER",notnull:1,pk:0}]},Yi={idx_chunks_doc_id:{table:"chunks",columns:["document_id"]},idx_chunks_line_range:{table:"chunks",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_document:{table:"defn_enclosing_ranges",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_symbol_id:{table:"defn_enclosing_ranges",columns:["symbol_id"]},idx_global_symbols_symbol:{table:"global_symbols",columns:["symbol"]},idx_mentions_symbol_id_role:{table:"mentions",columns:["symbol_id","role"]}};function Kn(e){let t=P(),n=Qi(e.affectedFiles);if(Zi(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Wn(e.candidateDbPath,{force:!0}),!Jn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Jn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");qn(e.previousDbPath,"previous SQLite generation",!1),qn(e.miniDbPath,"incremental SQLite mini database"),Xi(e.previousDbPath,e.candidateDbPath);let r=null;try{r=new Xn(e.candidateDbPath,{fileMustExist:!0}),r.pragma("busy_timeout = 5000"),r.pragma("foreign_keys = ON"),r.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Xe(r,"main","candidate SQLite generation"),Xe(r,"incremental","incremental SQLite mini database"),ea(r,n),ta(r,n.length);let i=Ke(r,"main",!0),a=D(r,"SELECT COUNT(*) AS value FROM main.documents");r.transaction(()=>{na(r),ra(r),ia(r),e.onStage?.("after-delete"),aa(r),e.onStage?.("after-symbol-reconciliation"),oa(r),e.onStage?.("after-insert"),sa(r),ca(r,n.length,a),e.onStage?.("before-commit")}).immediate(),Vn(r,"main","candidate SQLite generation");let d=[...da(r)].filter(([c,l])=>i.get(c)!==l).map(([c])=>c).sort();return r.exec("DETACH DATABASE incremental"),r.close(),r=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:d,durationMs:P()-t}}catch(i){try{r?.close()}finally{Wn(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${i instanceof Error?i.message:String(i)}`,{cause:i})}}function Qi(e){if(e.length===0)throw new Error("incremental SQLite publication requires affected documents");let t=[...e].sort();for(let n of t)if(!n||n.startsWith("/")||n.includes("\\")||n.split("/").includes(".."))throw new Error(`invalid affected document path: ${n}`);if(new Set(t).size!==t.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return t}function Zi(e,t,n){let r=[e,t,n].map(i=>Ki(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function qn(e,t,n=!0){let r=new Xn(e,{readonly:!0,fileMustExist:!0});try{Xe(r,"main",t),n&&Vn(r,"main",t)}finally{r.close()}}function Xe(e,t,n){for(let[r,i]of Object.entries(Vi)){let o=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:d,notnull:c,pk:l})=>({name:s,type:d.toUpperCase(),notnull:c,pk:l}));if(JSON.stringify(o)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(Yi)){let a=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),o=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(a?.tbl_name!==i.table||JSON.stringify(o)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}zn(e,t,"documents",["relative_path"],n),zn(e,t,"global_symbols",["symbol"],n)}function zn(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let d=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(c=>c.name);return JSON.stringify(d)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function Vn(e,t,n){let r=e.prepare(`PRAGMA ${t}.integrity_check`).pluck().get();if(r!=="ok")throw new Error(`${n} failed integrity_check: ${String(r)}`);if(e.prepare(`PRAGMA ${t}.foreign_key_check`).all().length>0)throw new Error(`${n} failed foreign_key_check`)}function ea(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(i=>{for(let a of i)n.run(a)})(t)}function ta(e,t){let n=D(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=D(e,`SELECT COUNT(*) AS value
77
77
  FROM main.documents d
78
78
  JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),i=e.prepare(`SELECT p.relative_path
79
79
  FROM temp.incremental_affected_paths p
@@ -83,7 +83,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
83
83
  FROM incremental.documents d
84
84
  LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
85
85
  WHERE p.relative_path IS NULL
86
- LIMIT 1`).pluck().get();if(n!==t||r!==t||i!==void 0||a!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set")}function Li(e){e.exec(`
86
+ LIMIT 1`).pluck().get();if(n!==t||r!==t||i!==void 0||a!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set")}function na(e){e.exec(`
87
87
  CREATE TEMP TABLE incremental_old_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
88
88
  INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
89
89
  SELECT g.symbol
@@ -110,7 +110,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
110
110
  FROM incremental.mentions m
111
111
  JOIN incremental.global_symbols g ON g.id = m.symbol_id
112
112
  WHERE m.role = 1;
113
- `)}function Ni(e){let t=e.prepare(`WITH changed_symbols AS (
113
+ `)}function ra(e){let t=e.prepare(`WITH changed_symbols AS (
114
114
  SELECT symbol FROM temp.incremental_old_defined_symbols
115
115
  UNION
116
116
  SELECT symbol FROM temp.incremental_new_defined_symbols
@@ -133,7 +133,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
133
133
  SELECT u.symbol
134
134
  FROM unaffected_definitions u
135
135
  JOIN changed_symbols c ON c.symbol = u.symbol
136
- LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function Ci(e){e.exec(`
136
+ LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function ia(e){e.exec(`
137
137
  DELETE FROM main.mentions
138
138
  WHERE chunk_id IN (
139
139
  SELECT c.id
@@ -155,7 +155,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
155
155
  );
156
156
  DELETE FROM main.documents
157
157
  WHERE relative_path IN (SELECT relative_path FROM temp.incremental_affected_paths);
158
- `)}function $i(e){e.exec(`
158
+ `)}function aa(e){e.exec(`
159
159
  UPDATE main.global_symbols
160
160
  SET display_name = NULL,
161
161
  kind = NULL,
@@ -197,7 +197,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
197
197
  WHERE source.symbol = main.global_symbols.symbol
198
198
  )
199
199
  WHERE symbol IN (SELECT symbol FROM temp.incremental_new_defined_symbols);
200
- `)}function Bi(e){let t=D(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=D(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=D(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.defn_enclosing_ranges");e.prepare(`INSERT INTO main.documents(id, language, relative_path, position_encoding, text)
200
+ `)}function oa(e){let t=D(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=D(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=D(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.defn_enclosing_ranges");e.prepare(`INSERT INTO main.documents(id, language, relative_path, position_encoding, text)
201
201
  SELECT id + ?, language, relative_path, position_encoding, text
202
202
  FROM incremental.documents`).run(t),e.prepare(`INSERT INTO main.chunks(id, document_id, chunk_index, start_line, end_line, occurrences)
203
203
  SELECT id + ?, document_id + ?, chunk_index, start_line, end_line, occurrences
@@ -212,22 +212,22 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
212
212
  r.start_line, r.start_char, r.end_line, r.end_char
213
213
  FROM incremental.defn_enclosing_ranges r
214
214
  JOIN incremental.global_symbols source ON source.id = r.symbol_id
215
- JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function Gi(e){e.exec(`
215
+ JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function sa(e){e.exec(`
216
216
  DELETE FROM main.global_symbols
217
217
  WHERE NOT EXISTS (SELECT 1 FROM main.mentions m WHERE m.symbol_id = main.global_symbols.id)
218
218
  AND NOT EXISTS (
219
219
  SELECT 1 FROM main.defn_enclosing_ranges r WHERE r.symbol_id = main.global_symbols.id
220
220
  );
221
- `)}function Ui(e,t,n){let r=D(e,"SELECT COUNT(*) AS value FROM main.documents"),i=D(e,`SELECT COUNT(*) AS value
221
+ `)}function ca(e,t,n){let r=D(e,"SELECT COUNT(*) AS value FROM main.documents"),i=D(e,`SELECT COUNT(*) AS value
222
222
  FROM main.documents d
223
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`);if(r!==n||i!==t)throw new Error("candidate SQLite document counts changed unexpectedly");let a=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),s=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(a!==void 0||s!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function Ji(e){let t=Ue(e,"main",!0),n=Ue(e,"incremental",!1);if(JSON.stringify([...t])!==JSON.stringify([...n]))throw new Error("candidate SQLite affected document facts differ from the mini database");return t}function Ue(e,t,n){let r=n?"JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path":"",i=e.prepare(`SELECT d.relative_path, d.language, d.position_encoding, d.text
223
+ JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`);if(r!==n||i!==t)throw new Error("candidate SQLite document counts changed unexpectedly");let a=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),o=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(a!==void 0||o!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function da(e){let t=Ke(e,"main",!0),n=Ke(e,"incremental",!1);if(JSON.stringify([...t])!==JSON.stringify([...n]))throw new Error("candidate SQLite affected document facts differ from the mini database");return t}function Ke(e,t,n){let r=n?"JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path":"",i=e.prepare(`SELECT d.relative_path, d.language, d.position_encoding, d.text
224
224
  FROM ${t}.documents d
225
225
  ${r}
226
226
  ORDER BY d.relative_path`).all(),a=e.prepare(`SELECT d.relative_path, c.chunk_index, c.start_line, c.end_line, hex(c.occurrences) AS occurrences
227
227
  FROM ${t}.chunks c
228
228
  JOIN ${t}.documents d ON d.id = c.document_id
229
229
  ${r}
230
- ORDER BY d.relative_path, c.chunk_index, c.start_line, c.end_line, c.id`).all(),s=e.prepare(`SELECT d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char,
230
+ ORDER BY d.relative_path, c.chunk_index, c.start_line, c.end_line, c.id`).all(),o=e.prepare(`SELECT d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char,
231
231
  g.symbol, g.display_name, g.kind, g.documentation,
232
232
  CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature,
233
233
  g.enclosing_symbol,
@@ -236,22 +236,23 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
236
236
  JOIN ${t}.documents d ON d.id = r.document_id
237
237
  JOIN ${t}.global_symbols g ON g.id = r.symbol_id
238
238
  ${r}
239
- ORDER BY d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char, g.symbol`).all(),o=e.prepare(`SELECT d.relative_path, c.chunk_index, m.role, g.symbol
239
+ ORDER BY d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char, g.symbol`).all(),s=e.prepare(`SELECT d.relative_path, c.chunk_index, m.role, g.symbol
240
240
  FROM ${t}.mentions m
241
241
  JOIN ${t}.chunks c ON c.id = m.chunk_id
242
242
  JOIN ${t}.documents d ON d.id = c.document_id
243
243
  JOIN ${t}.global_symbols g ON g.id = m.symbol_id
244
244
  ${r}
245
- ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),c=new Map;for(let[l,u]of Object.entries({documents:i,chunks:a,definitions:s,mentions:o}))for(let p of u){let h=JSON.stringify([l,p]),g=c.get(p.relative_path)??[];g.push(h),c.set(p.relative_path,g)}let d=new Map;for(let[l,u]of[...c].sort(([p],[h])=>p.localeCompare(h))){let p=wi("sha256");for(let h of u.sort())p.update(h).update(`
246
- `);d.set(l,p.digest("hex"))}return d}function D(e,t){return e.prepare(t).get().value}import{createHash as Hi}from"crypto";import{existsSync as Je,readFileSync as Wi,readdirSync as qi}from"fs";import{dirname as He,join as me,relative as zi,resolve as We,sep as Ln}from"path";function Nn(e,t){let n=t.includes("."),r={};for(let a of t)r[a]=[];let i=[];for(let a of e){let s=Gn(a.path,t);s?r[s].push(a):n?r["."].push(a):i.push(a)}return{files:r,shared:i}}function Cn(e,t){let n=new Map;for(let i of e){let a=t[i]?.packageName;a&&n.set(a,i)}let r=new Map;for(let i of e)r.set(i,new Set);for(let i of e){let a=t[i],s=r.get(i);if(!a||a.parseFailed){for(let o of e)o!==i&&s.add(o);continue}for(let o of a.dependencyNames){let c=n.get(o);c&&c!==i&&s.add(c)}for(let o of[...a.pathsTargets,...a.referencesPaths]){let c=Gn(o,e);c&&c!==i&&s.add(c)}}return Xi(e,r)}function $n(e,t,n){let r={};for(let i of e){let a=new Map;for(let s of t.files[i]??[])a.set(s.path,s);for(let s of n[i]??[])for(let o of t.files[s]??[])a.set(o.path,o);for(let s of t.shared)a.set(s.path,s);r[i]={files:[...a.values()].sort((s,o)=>s.path.localeCompare(o.path))}}return r}function qe(e){if(e===".")return"root";let t=Hi("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function Bn(e,t){let n=We(e),r={};for(let i of t)r[i]=Vi(n,i);return r}function Gn(e,t){let n;for(let r of t)r!=="."&&(e===r||e.startsWith(`${r}/`))&&(!n||r.length>n.length)&&(n=r);return n}function Xi(e,t){let n={};for(let r of e){let i=new Set,a=[...t.get(r)??[]];for(;a.length>0;){let s=a.pop();if(!(s===r||i.has(s))){i.add(s);for(let o of t.get(s)??[])o!==r&&!i.has(o)&&a.push(o)}}n[r]=[...i].sort((s,o)=>s.localeCompare(o))}return n}function Vi(e,t){let n=t==="."?e:me(e,t),r=Yi(n),i=Qi(n),a=i?Ki(i,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:a.pathsTargets,referencesPaths:a.referencesPaths,parseFailed:r.failed||a.failed}}function Yi(e){let t=me(e,"package.json");if(!Je(t))return{name:void 0,dependencyNames:[],failed:!1};let n=ze(t);if(!n.ok)return{name:void 0,dependencyNames:[],failed:!0};let r=typeof n.value.name=="string"?n.value.name:void 0,i=new Set;for(let a of["dependencies","devDependencies","peerDependencies"]){let s=n.value[a];if(s&&typeof s=="object"&&!Array.isArray(s))for(let o of Object.keys(s))i.add(o)}return{name:r,dependencyNames:[...i],failed:!1}}function Qi(e){let t=me(e,"tsconfig.json");if(Je(t))return t;let n;try{n=qi(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?me(e,n[0]):void 0}function Ki(e,t){let n=ze(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=Zi(n.value,e,t),i=Un(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function Zi(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=He(t),a=new Set;for(let s of r){if(!s||typeof s!="object")continue;let o=s.path;if(typeof o!="string"||o.trim()==="")continue;let c=Jn(o,i,n);c&&a.add(c)}return[...a]}function Un(e,t,n,r){let i=ea(t);if(i)return{pathsTargets:ta(i,He(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let a=na(t.extends,e,n);if(!a)return{pathsTargets:[],failed:!1};let s=ze(a);return s.ok?Un(a,s.value,n,r+1):{pathsTargets:[],failed:!0}}function ea(e){let t=e.compilerOptions;if(!t||typeof t!="object"||Array.isArray(t))return;let n=t.paths;return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function ta(e,t,n){let r=new Set;for(let i of Object.values(e))if(Array.isArray(i))for(let a of i){if(typeof a!="string")continue;let s=Jn(a,t,n);s&&r.add(s)}return[...r]}function na(e,t,n){let r=Array.isArray(e)?e.at(-1):e;if(typeof r!="string"||r.trim()===""||!r.startsWith(".")&&!r.startsWith("/"))return;let i=We(He(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(Ln).includes("node_modules")&&W(n,i)&&Je(i))return i}function Jn(e,t,n){let r=e.replace(/\/?\*+$/,""),i=We(t,r===""?".":r);if(!W(n,i))return;let s=zi(n,i).split(Ln).join("/");return s===""?".":s}function ra(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let a=e[n];if(r){if(t+=a,a==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}a==='"'&&(r=!1),n+=1;continue}if(a==='"'){r=!0,t+=a,n+=1;continue}if(a==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
247
- `;)n+=1;continue}if(a==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=a,n+=1}return t}function ze(e){try{let t=Wi(e,"utf-8"),n=JSON.parse(ra(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{existsSync as ia,readFileSync as aa,readdirSync as sa,statSync as oa}from"fs";import v from"path";var ca=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function V(e,t=[]){let n=v.resolve(e),r=t.flatMap(c=>la(n,c));if(r.length>0)return Hn(n,Wn(r));let i=da(n),a=Wn(i),s=pa(n,a)?[n,...a]:a,o=s.length>0?s:[n];return Hn(n,o)}function Hn(e,t){return[...new Set(t.map(n=>fa(e,n)))].sort((n,r)=>n.localeCompare(r))}function da(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=sa(r,{withFileTypes:!0})}catch{continue}for(let a of i){let s=v.join(r,a.name);if(a.isDirectory()){!ca.has(a.name)&&!a.name.startsWith(".")&&n.push(s);continue}a.isFile()&&ua(s)&&t.push(v.dirname(s))}}return t}function la(e,t){let n=t.trim();if(!n)return[];let r=v.resolve(e,n);if(!W(e,r))return[];try{let i=oa(r);if(i.isDirectory())return[r];if(i.isFile()&&qn(v.basename(r)))return[v.dirname(r)]}catch{return[]}return[]}function ua(e){if(!qn(v.basename(e)))return!1;let t=zn(e);return t?v.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function qn(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function Wn(e){let t=[...new Set(e.map(n=>v.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&ma(n,r)))}function pa(e,t){if(t.length===0||t.some(r=>v.resolve(r)===e))return!1;let n=v.join(e,"tsconfig.json");return ia(n)&&ga(n)}function ga(e){let n=zn(e)?.include;return Array.isArray(n)?n.some(r=>typeof r=="string"&&r.trim()!==""&&!r.startsWith("!")&&(r.includes("/")||r.includes("**")||!v.extname(r))):!1}function zn(e){try{let t=JSON.parse(aa(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function fa(e,t){let n=v.relative(e,t);return n?n.split(v.sep).join("/"):"."}function ma(e,t){let n=v.relative(e,t);return!!n&&!n.startsWith("..")&&!v.isAbsolute(n)}import{createHash as wa}from"crypto";import{existsSync as Xe,readFileSync as Kn,statSync as _a,writeFileSync as Ve}from"fs";import{join as ja}from"path";import{randomUUID as ha}from"crypto";import{existsSync as ya,readFileSync as Sa}from"fs";var ba=12e4,Pa=5,he=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=gt(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Ea(),this.runtime=n.runtime??Fa,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=rn(this.cacheDir),r=tn(this.cacheDir),i=Te(n.statePath);if(!Xn(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let a=this.runtime.now(),s=a+this.timeoutMs,o=(this.runtime.monotonicNow??P)()+this.timeoutMs,c=Kt("typescript-index-v3",{baseGeneration:this.baseGeneration,request:t}),d=Zt(c),l=en(r,{mailboxVersion:Qt,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:a,deadlineAtMs:s,protocolVersion:de,id:d,baseGeneration:this.baseGeneration,request:t},{nowMs:a,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??P)()<=o;){if(ya(l.responsePath))return xa(Sa(l.responsePath,"utf8"),d,c,this.baseGeneration,t.producerIdentity,t.affectedFiles);let u=Te(n.statePath);if(!Xn(u,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(Pa)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function Xn(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===de&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&J(e.processIdentity,r))}function xa(e,t,n,r,i,a){let s=JSON.parse(e);if(s.protocolVersion!==de||s.id!==t||s.operationKey!==n||s.ok===!0&&s.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(s.ok!==!0)throw new Error(typeof s.error=="string"?s.error:"TypeScript index service request failed.");let o=Ra(s.response,i),c=[...new Set(a)].sort(),d=o.fragments.map(l=>l.relativePath).sort();if(JSON.stringify(d)!==JSON.stringify(c))throw new Error("TypeScript index service omitted or added an affected document.");return o}function Ra(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,i=n.fragments.map(a=>{if(!a||typeof a.relativePath!="string"||a.bytesBase64!==null&&typeof a.bytesBase64!="string"||typeof a.occurrences!="number"||!Number.isInteger(a.occurrences)||a.occurrences<0||typeof a.symbols!="number"||!Number.isInteger(a.symbols)||a.symbols<0||!Array.isArray(a.referenceFragments)||!a.referenceFragments.every(Ia)||r.has(a.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(a.relativePath);let s=a.bytesBase64===null?null:va(a.bytesBase64);return{relativePath:a.relativePath,bytes:s,occurrences:a.occurrences,symbols:a.symbols,referenceFragments:a.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function Ia(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.targetSymbol=="string"&&!!t.location&&typeof t.location.file=="string"&&Number.isInteger(t.location.line)&&Number.isInteger(t.location.column)}function va(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function Ea(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:ba}var Fa={now:Date.now,monotonicNow:P,randomId:ha,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:O,readProcessIdentity:M};function Da(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."];if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let n=te(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(d=>d.kind!=="modified"||d.inputKind!=="source"||!q(d.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=fe(n,e.graph,e.projectFiles);if(r.mode!=="closure"||r.affectedFiles.length===0)return{eligible:!1,reason:r.reasons.length>0?`affected set widened: ${r.reasons.join(", ")}`:"empty affected set"};let i=ka([...r.changedFiles,...r.affectedFiles],t);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let a=Vn(e.currentSnapshot,e.projectFiles,e.producerIdentity),s=Vn(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(a!==s)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let o=Qn(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!o)return{eligible:!1,reason:"prior document identity unavailable"};let c=Qn(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);return c?{eligible:!0,manifest:n,plan:r,projectIdentity:a,previousFragmentGeneration:Yn(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:Yn(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:o,nextDocumentIdentities:c,tsconfigPath:i==="."?"tsconfig.json":`${i}/tsconfig.json`,projectArgument:i}:{eligible:!1,reason:"next document identity unavailable"}}function ka(e,t){let n=null;for(let r of e){let i=t.filter(a=>a==="."||r===a||r.startsWith(`${a}/`));if(i.length!==1||n!==null&&n!==i[0])return null;n=i[0]}return n}function Zn(e){let t=P();try{if(!Xe(e.previousDbPath)||!Xe(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=ke();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let a=new k({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),s,o;try{s=j(a,{includeIgnored:!1}).filter(q).sort(),o=L(a)}finally{a.close()}let c=performance.now()-n,d=Da({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?V(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:s,graph:o,producerIdentity:r.producerIdentity,rootTsconfigExists:Xe(ja(e.projectRoot,"tsconfig.json"))});if(!d.eligible)throw new Error(d.reason);let l=nn(e.previousDbPath);if(!l)throw new Error("published TypeScript base generation unavailable");n=performance.now();let p=new he({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:l}).request({kind:"emit-documents",tsconfigPath:d.tsconfigPath,projectArgument:d.projectArgument,projectIdentity:d.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:d.plan.changedFiles,affectedFiles:d.plan.affectedFiles}),h=performance.now()-n,g=_a(e.previousShardPath).size>=Gt;n=performance.now();let m=g?null:Kn(e.previousShardPath),b=g?{completeIndexBytes:null,affectedIndexBytes:Nt(p.fragments)}:Bt({packageVersion:r.packageVersion,baseIndexBytes:m,fragments:p.fragments}),f=performance.now()-n;n=performance.now(),g?Ut({cacheDir:e.cacheDir,previousGenerationIdentity:d.previousFragmentGeneration,nextGenerationIdentity:d.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:d.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:p.fragments}):(Ct({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:m,producerIdentity:r.producerIdentity,projectIdentity:d.projectIdentity,generationIdentity:d.previousFragmentGeneration,documentIdentities:d.previousDocumentIdentities,allowUntrackedDocuments:!0}),$t({cacheDir:e.cacheDir,previousGenerationIdentity:d.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:d.projectIdentity,generationIdentity:d.nextFragmentGeneration,fragments:p.fragments,documentIdentities:d.nextDocumentIdentities}));let y=performance.now()-n;n=performance.now(),b.completeIndexBytes&&Ve(e.candidateShardPath,b.completeIndexBytes),Ve(e.candidateAffectedScipPath,b.affectedIndexBytes);let x=performance.now()-n,R={scipPath:g?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!g,durationMs:P()-t,cold:p.cold,changedFiles:d.plan.changedFiles,affectedFiles:d.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:d.previousFragmentGeneration,nextFragmentGeneration:d.nextFragmentGeneration,manifest:d.manifest,plan:d.plan,projectFileCount:s.length,referenceFragmentsByFile:new Map(p.fragments.map(T=>[T.relativePath,T.referenceFragments])),timings:{runtimeMs:i,graphMs:c,requestMs:h,serviceMs:p.durationMs,assemblyMs:f,fragmentStoreMs:y,writeMs:x}};return e.onStatus(`Incremental TypeScript index emitted ${R.affectedFiles.length} affected document(s) in ${(R.durationMs/1e3).toFixed(3)}s (${R.cold?"cold":"warm"} service; ${g?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${c.toFixed(0)}ms, request ${h.toFixed(0)}ms, assembly ${f.toFixed(0)}ms, fragments ${y.toFixed(0)}ms, write ${x.toFixed(0)}ms).`),R}catch(n){return e.onStatus(`Incremental TypeScript index unavailable: ${n instanceof Error?n.message:String(n)}. Falling back to the whole-project indexer.`),null}}function er(e){let t=ke();if(!t.available)throw new Error(t.reason);let n=Jt({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:Kn(e.baseShardPath),packageVersion:t.packageVersion});Ve(e.candidateShardPath,n)}function Vn(e,t,n){let r=e.files.filter(i=>ee(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,a)=>i.path.localeCompare(a.path));return Ye(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function Yn(e,t){return Ye(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function Qn(e,t,n,r,i){let a=new Set(e.files.map(c=>c.path)),s=ge({projectFiles:t.filter(c=>a.has(c)),snapshot:e,graph:n,engineIdentity:r}),o=new Map;for(let c of i){let d=s.identityFor(c,"typescript-scip-document-v1");if(d.key){o.set(c,d.key);continue}if(a.has(c))return null;o.set(c,Ye(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return o}function Ye(e){return wa("sha256").update(e).digest("hex")}import{existsSync as ye,renameSync as Ke,rmSync as Ze,statSync as Ta}from"fs";import{cpus as Ma}from"os";import{join as nr}from"path";function Oa(e,t,n){if(!e.defaultOutputPath)return;let r=nr(t,e.defaultOutputPath);n!==r&&ye(r)&&Ke(r,n)}function Aa(e,t,n){if(!e.defaultOutputPath)return null;let r=nr(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return Ze(i,{force:!0}),ye(r)?(Ke(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function La(e){e&&(Ze(e.defaultOutputPath,{force:!0}),e.backupPath&&ye(e.backupPath)&&Ke(e.backupPath,e.defaultOutputPath))}function Na(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,Ma().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function rr(e,t,n,r){let i=e.filter(d=>d.config.defaultOutputPath),a=e.filter(d=>!d.config.defaultOutputPath),s=[],o=Na(a.length,r),c=await Ba(a,o,d=>Qe(d,t,n));if(o>1){let d=new Map;for(let l of c.filter(u=>u.result.skipped&&u.retryable)){let u=a.find(p=>p.id===l.result.id);u&&(n(`Retrying ${u.label} indexer serially after parallel failure...`),d.set(u.id,(await Qe(u,t,n)).result))}s.push(...c.map(({result:l})=>d.get(l.id)??l))}else s.push(...c.map(({result:d})=>d));for(let d of i)s.push((await Qe(d,t,n)).result);return s.sort((d,l)=>e.findIndex(u=>u.id===d.id)-e.findIndex(u=>u.id===l.id))}async function Qe(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),Ze(e.scipPath,{force:!0});let r=Aa(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),a=P();try{let o=dt(e.binary,e.args),c=await on({command:o.binary,args:o.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:Ca(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024});if(c.status!==0){let d=c.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${c.status}${d?`:
248
- ${d}`:""}`)}Oa(e.config,t,e.scipPath)}catch(o){let c=o instanceof Error?o.message:String(o),d=`${e.resolvedBinary} indexer failed: ${c.split(`
249
- `)[0]}`,l=e.label===e.language?d:`${e.label}: ${d}`;return n(`Skipping ${e.label}: ${d}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,skipped:{language:e.language,reason:l}},retryable:$a(o)}}finally{La(r)}if(!ye(e.scipPath)){let o=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,c=e.label===e.language?o:`${e.label}: ${o}`;return n(`Skipping ${e.label}: ${o}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,skipped:{language:e.language,reason:c}},retryable:!1}}let s;try{s=Ta(e.scipPath).size}catch{s=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,outputBytes:s},retryable:!1}}function Ca(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):an.indexer}function $a(e){return e instanceof sn?e.kind==="spawn"&&tr(e.cause):tr(e)}function tr(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}async function Ba(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,a=Math.max(1,Math.min(e.length,t)),s=Array.from({length:a},async()=>{for(;i<e.length;){let o=i++;r[o]=await n(e[o])}});return await Promise.all(s),r}import{execFileSync as Ga}from"child_process";import{platform as Ua}from"os";function ir(e,t){let n=e.installMethods,r=ue(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n)if(U(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{Ga(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:Ua()==="win32"});let a=X(e);if(a){let s=a===e.indexerBinary?"":` (using ${a})`;return t(`Successfully installed ${r} via ${i.label}${s}`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(a){let s=a instanceof Error?a.message:String(a);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}async function mr(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,a=Ya(e),s=Date.now(),o=P();be(S(a.outputScip),{recursive:!0}),be(S(a.outputDb),{recursive:!0});let c=e.languages??Tt(t);if(c.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${c.join(", ")}`);let d=w("reindex.fingerprint",()=>bt(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:c.length}),l,u;if(e.skipIfUnchanged!==!1&&!Xt(t,a.outputDb)&&ar(a.outputScip)===ar(I(S(a.outputDb),"index.scip"))){let m=re(t);if(l=m?oe(m,d):void 0,l){let b=ce(l);if(b){if(!Va(a,d))try{je({snapshot:l,manifest:b,targetCacheDir:S(a.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${l.generationId.slice(0,12)}`)}catch(f){r(`Shared generation attach failed; continuing locally: ${$(f)}`)}}else{let f=await Yt(l);if(f.kind==="owner")u=f.release;else if(f.kind==="generation-ready"){let y=ce(l);if(y)try{je({snapshot:l,manifest:y,targetCacheDir:S(a.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${l.generationId.slice(0,12)} after waiting`)}catch(x){r(`Shared generation attach failed after waiting; continuing locally: ${$(x)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let p=ht(I(S(a.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!p)throw u?.(),new Error(`Could not acquire scip-query cache lifecycle lock for ${S(a.outputDb)}.`);let h;try{h=await G("reindex.lock",()=>Is(I(S(a.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:c.length})}catch(m){throw p.release(),u?.(),m}let g=null;try{qt(a.outputDb,a.outputScip,a.metaPath);let m=es(S(a.outputDb));m.removed>0&&r(`Removed ${m.removed} abandoned reindex workspace(s)`);for(let T of m.errors)r(`Could not remove abandoned reindex workspace: ${T}`);let b=null,f=w("reindex.reuse-check",()=>(b=Qa({opts:e,paths:a,languages:c,fingerprint:d,start:s,monotonicStart:o,onStatus:r}),b),()=>({languages:c.length,reused:b!==null}));if(f)return sr({snapshot:l,paths:a,projectRoot:t,fingerprint:d,onStatus:r}),_e(a.outputDb,f),f;await G("reindex.scip-cli-ready",()=>ms(i,r));let y=Za(a);g=y.runDir;let x,R=await G("reindex.fresh",async()=>(x=await ts({opts:e,languages:c,projectRoot:t,paths:a,tempPaths:y,fingerprint:d,start:s,monotonicStart:o,maxHeapMb:n,skipAutoInstall:i,onStatus:r}),x),()=>({languages:c.length,reused:x?.reused,skipped:x?.skipped.length}));return sr({snapshot:l,paths:a,projectRoot:t,fingerprint:d,onStatus:r}),_e(a.outputDb,R),R}catch(m){let b=Ie({trigger:e.trigger,result:"failed",start:s,monotonicStart:o,error:m instanceof Error?m.message:String(m)});throw _r(a.metaPath,b),Lt(a.outputDb,b),m}finally{g&&C(g,{recursive:!0,force:!0}),h(),p.release(),u?.()}}function sr(e){if(e.snapshot){if(ce(e.snapshot)){De(e.snapshot,S(e.paths.outputDb),"local-fresh");return}try{let t=re(e.projectRoot),n=t?oe(t,e.fingerprint):void 0;if(!n||n.generationId!==e.snapshot.generationId){e.onStatus("Skipped shared generation publication because the worktree changed during indexing");return}Vt({snapshot:e.snapshot,sourceCacheDir:S(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let r=re(e.projectRoot);return(r?oe(r,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}}),De(e.snapshot,S(e.paths.outputDb),"built"),e.onStatus(`Published shared generation ${e.snapshot.generationId.slice(0,12)}`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${$(t)}`)}}}function Va(e,t){if(!F(e.outputScip)||!F(e.outputDb)||!wr(e.metaPath,t))return!1;let n=z(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function $(e){return e instanceof Error?e.message:String(e)}function Ya(e){let t=e.outputScip??I(e.projectRoot,"index.scip"),n=e.outputDb??I(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:I(S(n),"meta.json")}}function Qa(e){let t=z(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!F(e.paths.outputScip)||!F(e.paths.outputDb)||!wr(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;se(ae(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=P()-e.monotonicStart,r=Ie({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return _r(e.paths.metaPath,r),e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[],lastRefresh:r,shards:Ka(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function Ka(e,t,n,r){let i=Er(t,n,r);return n.map(a=>({id:a,language:a,reused:!0,fingerprint:Y(i[a]),outputBytes:Q(it(e.outputDb,a)),durationMs:0}))}function Za(e){let t=Wa(I(S(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:I(t,Se(e.outputScip)),tempOutputDb:I(t,Se(e.outputDb)),tempMetaPath:I(t,Se(e.metaPath))}}function es(e){let t=[],n;try{n=gr(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[$(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{C(I(e,i.name),{recursive:!0,force:!0}),r+=1}catch(a){t.push(`${i.name}: ${$(a)}`)}return{removed:r,errors:t}}async function ts(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await G("reindex.language-indexers",async()=>(n=await rs(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:a,reusedLanguages:s,languageFingerprints:o,shards:c,typescriptProjectShardContext:d,incrementalTypeScript:l}=r;if(s.length>0&&e.onStatus(`Reused ${s.length} cached language shard(s): ${s.join(", ")}`),ns({run:e,indexedOutputs:i,skippedLanguages:a,reusedLanguages:s})){let h=w("reindex.publish",()=>ps(e,i,a,s,o,d),{mode:"metadata-only",languages:i.length,reused:s.length}),g=h.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(g/1e3).toFixed(1)}s`),{languages:i.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:g,reused:!0,skipped:a,lastRefresh:h,shards:c}}let u=w("reindex.publish",()=>us(e,t,i,a,s,o,d,l),{mode:l?"incremental-or-fallback":"full",languages:i.length,reused:s.length,skipped:a.length}),p=u.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:i.map(h=>h.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:a,lastRefresh:u,shards:c}}function ns(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!F(e.run.paths.outputScip)||!F(e.run.paths.outputDb))return!1;let t=z(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(i=>i.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(i=>n.has(i)&&r.has(i))}async function rs(e,t){let n=cs({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),r=[],i=new Set;for(let[E,ot]of n)ot.reused&&(r.push({language:E,scipPath:ot.scipPath}),i.add(E));for(let E of i)e.onStatus(`Reusing cached ${E} SCIP shard (language inputs unchanged).`);let a=n.get("typescript"),s=z(e.paths.outputDb,e.paths.metaPath),o=Z(e.paths.metaPath),c=s.state==="legacy"||s.state==="current",d=o?.scipCompanion!=="deferred"&&(s.state!=="current"||s.generation.publication?.scipCompanion!=="deferred"),l=a&&!a.reused&&c?Zn({projectRoot:e.projectRoot,cacheDir:S(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:a.scipPath,candidateShardPath:K(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:K(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:d,previousSnapshot:rt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,u=new Set(l?["typescript"]:[]),p=l?void 0:is(e,n),{preparedRuns:h,skippedLanguages:g,languageOutputScipPaths:m}=hs({languages:e.languages.filter(E=>!i.has(E)&&!u.has(E)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:p?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),b=p?h.filter(E=>E.language!=="typescript"||p.missedProjectIds.has(E.id)):h,f=await rr(b,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),y=[];if(p){ss(e.paths.outputDb,f);let E=m.typescript??e.tempPaths.tempOutputScip;y=os({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:E,reusedProjects:p.reusedProjects})}let x=[...f,...y],{indexedOutputs:R}=Ss(x,g),T=l?[{language:"typescript",scipPath:l.scipPath}]:[],st=[...r,...T,...R];bs(st,g,e.languages,e.opts.allowPartial,e.onStatus);let Ar=l?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:l.scipPath,outputScipPath:l.scipPath,durationMs:l.durationMs,command:"watch-service:typescript-index",outputBytes:Q(l.scipPath)??void 0}]:[],Lr=ds(n,[...f,...Ar],p?{outputDb:e.paths.outputDb,classification:p.classification}:void 0);return{indexedOutputs:st,skippedLanguages:g,reusedLanguages:[...i],languageFingerprints:ls(n,e.languages),shards:Lr,typescriptProjectShardContext:p?{projects:p.allProjects,fingerprints:p.fingerprints}:void 0,incrementalTypeScript:l??void 0}}function is(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=V(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=Bn(e.projectRoot,r),a=Nn(n.fingerprint.files,r),s=Cn(r,i),o=$n(r,a,s),c=Z(e.paths.metaPath),l=as(c,o,g=>F(Re(e.paths.outputDb,g))),u=[...l.entries()].filter(([,g])=>g.reused).map(([g])=>g),p=new Set(u),h=new Set(r.filter(g=>!p.has(g)).map(g=>`typescript:${g}`));return{allProjects:r,fingerprints:o,classification:l,reusedProjects:u,missedProjectIds:h}}function as(e,t,n){let r=new Map;for(let i of Object.keys(t)){let a=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a});continue}let s=e.version===B&&Ee(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[i]:void 0;if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:a});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a});continue}if(_(s)!==_(a)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:a});continue}r.set(i,{reused:!0,fingerprint:a})}return r}function ss(e,t){for(let n of t){if(n.skipped||!n.id.startsWith("typescript:"))continue;let r=n.id.slice(11),i=Re(e,r);be(S(i),{recursive:!0}),xe(n.scipPath,i)}}function os(e){return e.reusedProjects.map((t,n)=>{let r=Re(e.outputDb,t),i=K(e.tempOutputScip,"typescript-project-cached",n);return xe(r,i),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:Q(i)??void 0}})}function cs(e){let t=Z(e.paths.metaPath),n=Er(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let a=it(e.paths.outputDb,i),s=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:s,scipPath:a});continue}if(t.version!==B){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:s,scipPath:a});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:s,scipPath:a});continue}if(!Ee(t).languageShardReuse||!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:s,scipPath:a});continue}let o=t.languageFingerprints[i];if(!o){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:s,scipPath:a});continue}if(!F(a)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s,scipPath:a});continue}if(_(o)!==_(s)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:s,scipPath:a});continue}r.set(i,{reused:!0,fingerprint:s,scipPath:a})}return r}function ds(e,t,n){let r=[];for(let[i,a]of e)a.reused&&r.push({id:i,language:i,reused:!0,fingerprint:Y(a.fingerprint),outputBytes:Q(a.scipPath),durationMs:0});for(let i of t){let a=e.get(i.language),s=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,o=s?n.classification.get(s):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:o?.reason??a?.reason??i.skipped?.reason,fingerprint:o?Y(o.fingerprint):a?Y(a.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,a]of n.classification)a.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:Y(a.fingerprint),outputBytes:Q(Re(n.outputDb,i)),durationMs:0});return r}function Y(e){return Ha("sha256").update(_(e)).digest("hex").slice(0,16)}function Q(e){try{return qa(e).size}catch{return null}}function ls(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}function us(e,t,n,r,i,a,s,o){let c=!o||o.completeScipUpdated,d=!1;c&&(or(e.paths.outputDb,n),d=cr(n,e.tempPaths.tempOutputScip,e.onStatus));let l=Ps({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:o,completeScipAvailable:c,completeScipSanitized:d,materializeFullFallback:()=>{if(!o||o.completeScipUpdated)return d;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),er({cacheDir:S(e.paths.outputDb),generationIdentity:o.nextFragmentGeneration,baseShardPath:o.scipPath,candidateShardPath:o.candidateScipPath});let y=n.map(x=>x.language==="typescript"?{language:x.language,scipPath:o.candidateScipPath}:x);return or(e.paths.outputDb,y),d=cr(y,e.tempPaths.tempOutputScip,e.onStatus),d}});if(se(ae(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),l.mode==="incremental"&&o){let y=null,x=null;try{y=new k({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),x=new k({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let R=Pn(y,e.fingerprint,o.referenceFragmentsByFile,x);e.onStatus(`Cached exact TypeScript reference fragments for ${R} affected document(s).`)}catch(R){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${R instanceof Error?R.message:String(R)}.`)}finally{y?.close(),x?.close()}}let u=rt(e.paths.metaPath),p=l.mode==="incremental"&&o?Rs(o,l.changedDocumentPaths):Ce({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:u,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),h=Ie({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(y=>y.language),skipped:[...r]}),g=l.mode==="incremental"&&l.scipCompanion==="deferred",m={...a};g&&delete m.typescript;let{metadata:b,pruneProjects:f}=yr({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:m,typescriptProjectShardContext:s,lastRefresh:h});return b.scipCompanion=g?"deferred":"current",Sr(e.paths.outputDb,f),at(e.tempPaths.tempMetaPath,b),Wt({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:o?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:o?.timings.serviceMs,materializationDurationMs:o?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&o?{typescriptOverlayGeneration:o.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}}),Ht(S(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[o.nextFragmentGeneration]:[]),hr(e.paths.outputDb,p,e.onStatus),h}function ps(e,t,n,r,i,a){let s=rt(e.paths.metaPath),o=null;try{xe(e.paths.outputDb,e.tempPaths.tempOutputDb)}catch(u){o=vn("reused","oracle-error",`Could not snapshot the prior database: ${u instanceof Error?u.message:String(u)}`)}se(ae(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),o??=Ce({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:s,currentSnapshot:e.fingerprint,refreshResult:"reused"});let c=Ie({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(u=>u.language),skipped:[...n]}),{metadata:d,pruneProjects:l}=yr({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:a,lastRefresh:c});return Sr(e.paths.outputDb,l),at(e.paths.metaPath,d),zt(e.paths.outputDb,e.paths.metaPath),hr(e.paths.outputDb,o,e.onStatus),c}function rt(e){return ct(Z(e)?.fingerprint)}function hr(e,t,n){try{En(e,t),t.status==="evaluated"?n(`Affected-set shadow: ${(t.evaluation.recall*100).toFixed(1)}% recall; ${t.plan.affectedFiles.length} predicted, ${t.comparison.changedFiles.length} changed.`):n(`Affected-set shadow unavailable: ${t.reason}.`)}catch(r){n(`Affected-set shadow telemetry unavailable: ${r instanceof Error?r.message:String(r)}`)}}function yr(e){let t=gs({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:B,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function gs(e){if(e.mode!=="workspace")return{field:void 0,pruneProjects:null};if(e.skippedLanguages.some(t=>t.language==="typescript"))return{field:void 0,pruneProjects:null};if(e.reusedLanguages.includes("typescript")){let t=Z(e.metaPath),n=t?.version===B?t.typescriptProjectShards:void 0;return{field:n,pruneProjects:n?Object.keys(n):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function Sr(e,t){let n=Fr(e);if(t===null){C(n,{recursive:!0,force:!0});return}let r;try{r=gr(n)}catch{return}for(let i of fs(r,t))C(I(n,i),{force:!0})}function fs(e,t){let n=new Set(t.map(r=>`${qe(r)}.scip`));return e.filter(r=>!n.has(r))}function or(e,t){for(let n of t){let r=it(e,n.language);be(S(r),{recursive:!0}),n.scipPath!==r&&xe(n.scipPath,r)}}async function ms(e,t){if(!Fe()){if(e)throw new Error(`The scip CLI is required but not found on PATH.
250
- Install from: https://github.com/sourcegraph/scip/releases`);if(Xa()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package scip-query-scip-windows (installed automatically with scip-query). Reinstall with optional dependencies enabled, run 'npm install -g scip-query-scip-windows', or set SCIP_QUERY_SCIP_BIN to a local scip.exe path.");if(t("scip CLI not found on PATH. Attempting auto-install..."),!ut(t))throw new Error(`The scip CLI is required but could not be installed.
251
- Install manually from: https://github.com/sourcegraph/scip/releases`)}}function hs(e){let t=[],n=[],r=e.languages.map((a,s)=>({language:a,scipPath:e.languages.length>1?K(e.tempOutputScip,a,s):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:a,scipPath:s})=>[a,s]));for(let{language:a,scipPath:s}of r){let o=ys({...e,language:a,scipPath:s});for(let c of o)"skipped"in c?br(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function ys(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[et({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??V(e.projectRoot,e.typescriptProjects);return t.length===0?[et({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(e.onStatus(`Indexing TypeScript workspace as ${t.length} project shard(s).`),t.map((n,r)=>et({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:K(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function et(e){let t=Be(e.language),n=ue(t),r=fn(t,e.projectRoot);if(!r&&!pn(t)){if(e.skipAutoInstall){let o=`${n} not found on PATH (auto-install disabled). ${t.installUrl??""}`.trim();return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!ir(t,e.onStatus)){let o=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}}let i=r??X(t);if(!i){let o=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}let{binary:a,args:s}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:i,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0});return{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:i,binary:a,args:s,env:mn(t,e.env,i)}}}function Ss(e,t){let n=new Map;for(let i of e)if(i.skipped)br(t,i.skipped);else{let a=`${i.language}\0${i.outputScipPath}`,s=n.get(a)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};s.scipPaths.push(i.scipPath),n.set(a,s)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)Ot(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let a=i.scipPaths[0];a!==i.outputScipPath&&fr(a,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function br(e,t){let n=e.find(r=>r.language===t.language);if(!n){e.push(t);return}n.reason.includes(t.reason)||(n.reason=`${n.reason}; ${t.reason}`)}function bs(e,t,n,r,i){if(e.length===0){let a=t.map(s=>` - ${s.language}: ${s.reason}`).join(`
245
+ ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),d=new Map;for(let[l,u]of Object.entries({documents:i,chunks:a,definitions:o,mentions:s}))for(let p of u){let h=JSON.stringify([l,p]),g=d.get(p.relative_path)??[];g.push(h),d.set(p.relative_path,g)}let c=new Map;for(let[l,u]of[...d].sort(([p],[h])=>p.localeCompare(h))){let p=zi("sha256");for(let h of u.sort())p.update(h).update(`
246
+ `);c.set(l,p.digest("hex"))}return c}function D(e,t){return e.prepare(t).get().value}import{createHash as la}from"crypto";import{existsSync as Ve,readdirSync as ua}from"fs";import{dirname as Ye,join as be,relative as pa,resolve as Qe,sep as Yn}from"path";function Qn(e,t){let n=t.includes("."),r={};for(let a of t)r[a]=[];let i=[];for(let a of e){let o=nr(a.path,t);o?r[o].push(a):n?r["."].push(a):i.push(a)}return{files:r,shared:i}}function Zn(e,t){let n=new Map;for(let i of e){let a=t[i]?.packageName;a&&n.set(a,i)}let r=new Map;for(let i of e)r.set(i,new Set);for(let i of e){let a=t[i],o=r.get(i);if(!a||a.parseFailed){for(let s of e)s!==i&&o.add(s);continue}for(let s of a.dependencyNames){let d=n.get(s);d&&d!==i&&o.add(d)}for(let s of[...a.pathsTargets,...a.referencesPaths]){let d=nr(s,e);d&&d!==i&&o.add(d)}}return ga(e,r)}function er(e,t,n){let r={};for(let i of e){let a=new Map;for(let o of t.files[i]??[])a.set(o.path,o);for(let o of n[i]??[])for(let s of t.files[o]??[])a.set(s.path,s);for(let o of t.shared)a.set(o.path,o);r[i]={files:[...a.values()].sort((o,s)=>o.path.localeCompare(s.path))}}return r}function Ze(e){if(e===".")return"root";let t=la("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function tr(e,t){let n=Qe(e),r={};for(let i of t)r[i]=fa(n,i);return r}function nr(e,t){let n;for(let r of t)r!=="."&&(e===r||e.startsWith(`${r}/`))&&(!n||r.length>n.length)&&(n=r);return n}function ga(e,t){let n={};for(let r of e){let i=new Set,a=[...t.get(r)??[]];for(;a.length>0;){let o=a.pop();if(!(o===r||i.has(o))){i.add(o);for(let s of t.get(o)??[])s!==r&&!i.has(s)&&a.push(s)}}n[r]=[...i].sort((o,s)=>o.localeCompare(s))}return n}function fa(e,t){let n=t==="."?e:be(e,t),r=ma(n),i=ha(n),a=i?ya(i,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:a.pathsTargets,referencesPaths:a.referencesPaths,parseFailed:r.failed||a.failed}}function ma(e){let t=be(e,"package.json");if(!Ve(t))return{name:void 0,dependencyNames:[],failed:!1};let n=et(t);if(!n.ok)return{name:void 0,dependencyNames:[],failed:!0};let r=typeof n.value.name=="string"?n.value.name:void 0,i=new Set;for(let a of["dependencies","devDependencies","peerDependencies"]){let o=n.value[a];if(o&&typeof o=="object"&&!Array.isArray(o))for(let s of Object.keys(o))i.add(s)}return{name:r,dependencyNames:[...i],failed:!1}}function ha(e){let t=be(e,"tsconfig.json");if(Ve(t))return t;let n;try{n=ua(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?be(e,n[0]):void 0}function ya(e,t){let n=et(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=Sa(n.value,e,t),i=rr(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function Sa(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=Ye(t),a=new Set;for(let o of r){if(!o||typeof o!="object")continue;let s=o.path;if(typeof s!="string"||s.trim()==="")continue;let d=ir(s,i,n);d&&a.add(d)}return[...a]}function rr(e,t,n,r){let i=ba(t);if(i)return{pathsTargets:Pa(i,Ye(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let a=xa(t.extends,e,n);if(!a)return{pathsTargets:[],failed:!1};let o=et(a);return o.ok?rr(a,o.value,n,r+1):{pathsTargets:[],failed:!0}}function ba(e){let t=e.compilerOptions;if(!t||typeof t!="object"||Array.isArray(t))return;let n=t.paths;return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function Pa(e,t,n){let r=new Set;for(let i of Object.values(e))if(Array.isArray(i))for(let a of i){if(typeof a!="string")continue;let o=ir(a,t,n);o&&r.add(o)}return[...r]}function xa(e,t,n){let r=Array.isArray(e)?e.at(-1):e;if(typeof r!="string"||r.trim()===""||!r.startsWith(".")&&!r.startsWith("/"))return;let i=Qe(Ye(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(Yn).includes("node_modules")&&J(n,i)&&Ve(i))return i}function ir(e,t,n){let r=e.replace(/\/?\*+$/,""),i=Qe(t,r===""?".":r);if(!J(n,i))return;let o=pa(n,i).split(Yn).join("/");return o===""?".":o}function Ra(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let a=e[n];if(r){if(t+=a,a==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}a==='"'&&(r=!1),n+=1;continue}if(a==='"'){r=!0,t+=a,n+=1;continue}if(a==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
247
+ `;)n+=1;continue}if(a==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=a,n+=1}return t}function et(e){try{let t=te(e,{maxBytes:mt,inputKind:"TypeScript project manifest"}),n=JSON.parse(Ra(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{existsSync as Ia,readdirSync as va,statSync as Ea}from"fs";import v from"path";var Fa=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function V(e,t=[]){let n=v.resolve(e),r=t.flatMap(d=>wa(n,d));if(r.length>0)return ar(n,or(r));let i=ja(n),a=or(i),o=_a(n,a)?[n,...a]:a,s=o.length>0?o:[n];return ar(n,s)}function ar(e,t){return[...new Set(t.map(n=>ka(e,n)))].sort((n,r)=>n.localeCompare(r))}function ja(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=va(r,{withFileTypes:!0})}catch{continue}for(let a of i){let o=v.join(r,a.name);if(a.isDirectory()){!Fa.has(a.name)&&!a.name.startsWith(".")&&n.push(o);continue}a.isFile()&&Ta(o)&&t.push(v.dirname(o))}}return t}function wa(e,t){let n=t.trim();if(!n)return[];let r=v.resolve(e,n);if(!J(e,r))return[];try{let i=Ea(r);if(i.isDirectory())return[r];if(i.isFile()&&sr(v.basename(r)))return[v.dirname(r)]}catch{return[]}return[]}function Ta(e){if(!sr(v.basename(e)))return!1;let t=cr(e);return t?v.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function sr(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function or(e){let t=[...new Set(e.map(n=>v.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&Ma(n,r)))}function _a(e,t){if(t.length===0||t.some(r=>v.resolve(r)===e))return!1;let n=v.join(e,"tsconfig.json");return Ia(n)&&Da(n)}function Da(e){let n=cr(e)?.include;return Array.isArray(n)?n.some(r=>typeof r=="string"&&r.trim()!==""&&!r.startsWith("!")&&(r.includes("/")||r.includes("**")||!v.extname(r))):!1}function cr(e){try{let t=JSON.parse(T(e,"TypeScript project config"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function ka(e,t){let n=v.relative(e,t);return n?n.split(v.sep).join("/"):"."}function Ma(e,t){let n=v.relative(e,t);return!!n&&!n.startsWith("..")&&!v.isAbsolute(n)}import{createHash as Ja}from"crypto";import{existsSync as tt,statSync as Wa,writeFileSync as nt}from"fs";import{join as qa}from"path";import{randomUUID as Oa}from"crypto";import{existsSync as Aa}from"fs";var La=12e4,Na=5,Pe=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=xt(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Ua(),this.runtime=n.runtime??Ha,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=fn(this.cacheDir),r=pn(this.cacheDir),i=Be(n.statePath);if(!dr(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let a=this.runtime.now(),o=a+this.timeoutMs,s=(this.runtime.monotonicNow??P)()+this.timeoutMs,d=dn("typescript-index-v3",{baseGeneration:this.baseGeneration,request:t}),c=ln(d),l=un(r,{mailboxVersion:cn,operationKey:d,clientId:this.runtime.randomId(),enqueuedAtMs:a,deadlineAtMs:o,protocolVersion:pe,id:c,baseGeneration:this.baseGeneration,request:t},{nowMs:a,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??P)()<=s;){if(Aa(l.responsePath))return Ca(te(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),c,d,this.baseGeneration,t.producerIdentity,t.affectedFiles);let u=Be(n.statePath);if(!dr(u,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(Na)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function dr(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===pe&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&W(e.processIdentity,r))}function Ca(e,t,n,r,i,a){let o=JSON.parse(e);if(o.protocolVersion!==pe||o.id!==t||o.operationKey!==n||o.ok===!0&&o.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(o.ok!==!0)throw new Error(typeof o.error=="string"?o.error:"TypeScript index service request failed.");let s=$a(o.response,i),d=[...new Set(a)].sort(),c=s.fragments.map(l=>l.relativePath).sort();if(JSON.stringify(c)!==JSON.stringify(d))throw new Error("TypeScript index service omitted or added an affected document.");return s}function $a(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,i=n.fragments.map(a=>{if(!a||typeof a.relativePath!="string"||a.bytesBase64!==null&&typeof a.bytesBase64!="string"||typeof a.occurrences!="number"||!Number.isInteger(a.occurrences)||a.occurrences<0||typeof a.symbols!="number"||!Number.isInteger(a.symbols)||a.symbols<0||!Array.isArray(a.referenceFragments)||!a.referenceFragments.every(Ba)||r.has(a.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(a.relativePath);let o=a.bytesBase64===null?null:Ga(a.bytesBase64);return{relativePath:a.relativePath,bytes:o,occurrences:a.occurrences,symbols:a.symbols,referenceFragments:a.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function Ba(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.targetSymbol=="string"&&!!t.location&&typeof t.location.file=="string"&&Number.isInteger(t.location.line)&&Number.isInteger(t.location.column)}function Ga(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function Ua(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:La}var Ha={now:Date.now,monotonicNow:P,randomId:Oa,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:A,readProcessIdentity:O};function za(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."];if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let n=re(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(c=>c.kind!=="modified"||c.inputKind!=="source"||!z(c.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=ye(n,e.graph,e.projectFiles);if(r.mode!=="closure"||r.affectedFiles.length===0)return{eligible:!1,reason:r.reasons.length>0?`affected set widened: ${r.reasons.join(", ")}`:"empty affected set"};let i=Xa([...r.changedFiles,...r.affectedFiles],t);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let a=lr(e.currentSnapshot,e.projectFiles,e.producerIdentity),o=lr(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(a!==o)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let s=pr(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!s)return{eligible:!1,reason:"prior document identity unavailable"};let d=pr(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);return d?{eligible:!0,manifest:n,plan:r,projectIdentity:a,previousFragmentGeneration:ur(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:ur(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:s,nextDocumentIdentities:d,tsconfigPath:i==="."?"tsconfig.json":`${i}/tsconfig.json`,projectArgument:i}:{eligible:!1,reason:"next document identity unavailable"}}function Xa(e,t){let n=null;for(let r of e){let i=t.filter(a=>a==="."||r===a||r.startsWith(`${a}/`));if(i.length!==1||n!==null&&n!==i[0])return null;n=i[0]}return n}function gr(e){let t=P();try{if(!tt(e.previousDbPath)||!tt(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=$e();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let a=new k({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),o,s;try{o=_(a,{includeIgnored:!1}).filter(z).sort(),s=C(a)}finally{a.close()}let d=performance.now()-n,c=za({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?V(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:o,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:tt(qa(e.projectRoot,"tsconfig.json"))});if(!c.eligible)throw new Error(c.reason);let l=gn(e.previousDbPath);if(!l)throw new Error("published TypeScript base generation unavailable");n=performance.now();let p=new Pe({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:l}).request({kind:"emit-documents",tsconfigPath:c.tsconfigPath,projectArgument:c.projectArgument,projectIdentity:c.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:c.plan.changedFiles,affectedFiles:c.plan.affectedFiles}),h=performance.now()-n,g=Wa(e.previousShardPath).size>=Yt;n=performance.now();let m=g?null:_e(e.previousShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:Te}),b=g?{completeIndexBytes:null,affectedIndexBytes:zt(p.fragments)}:Vt({packageVersion:r.packageVersion,baseIndexBytes:m,fragments:p.fragments}),f=performance.now()-n;n=performance.now(),g?Qt({cacheDir:e.cacheDir,previousGenerationIdentity:c.previousFragmentGeneration,nextGenerationIdentity:c.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:p.fragments}):(Xt({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:m,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,generationIdentity:c.previousFragmentGeneration,documentIdentities:c.previousDocumentIdentities,allowUntrackedDocuments:!0}),Kt({cacheDir:e.cacheDir,previousGenerationIdentity:c.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,generationIdentity:c.nextFragmentGeneration,fragments:p.fragments,documentIdentities:c.nextDocumentIdentities}));let S=performance.now()-n;n=performance.now(),b.completeIndexBytes&&nt(e.candidateShardPath,b.completeIndexBytes),nt(e.candidateAffectedScipPath,b.affectedIndexBytes);let x=performance.now()-n,R={scipPath:g?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!g,durationMs:P()-t,cold:p.cold,changedFiles:c.plan.changedFiles,affectedFiles:c.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:c.previousFragmentGeneration,nextFragmentGeneration:c.nextFragmentGeneration,manifest:c.manifest,plan:c.plan,projectFileCount:o.length,referenceFragmentsByFile:new Map(p.fragments.map(M=>[M.relativePath,M.referenceFragments])),timings:{runtimeMs:i,graphMs:d,requestMs:h,serviceMs:p.durationMs,assemblyMs:f,fragmentStoreMs:S,writeMs:x}};return e.onStatus(`Incremental TypeScript index emitted ${R.affectedFiles.length} affected document(s) in ${(R.durationMs/1e3).toFixed(3)}s (${R.cold?"cold":"warm"} service; ${g?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${d.toFixed(0)}ms, request ${h.toFixed(0)}ms, assembly ${f.toFixed(0)}ms, fragments ${S.toFixed(0)}ms, write ${x.toFixed(0)}ms).`),R}catch(n){return e.onStatus(`Incremental TypeScript index unavailable: ${n instanceof Error?n.message:String(n)}. Falling back to the whole-project indexer.`),null}}function fr(e){let t=$e();if(!t.available)throw new Error(t.reason);let n=Zt({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:_e(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:Te}),packageVersion:t.packageVersion});nt(e.candidateShardPath,n)}function lr(e,t,n){let r=e.files.filter(i=>ne(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,a)=>i.path.localeCompare(a.path));return rt(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function ur(e,t){return rt(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function pr(e,t,n,r,i){let a=new Set(e.files.map(d=>d.path)),o=he({projectFiles:t.filter(d=>a.has(d)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let d of i){let c=o.identityFor(d,"typescript-scip-document-v1");if(c.key){s.set(d,c.key);continue}if(a.has(d))return null;s.set(d,rt(JSON.stringify({version:1,producerIdentity:r,generatedDocument:d})))}return s}function rt(e){return Ja("sha256").update(e).digest("hex")}import{existsSync as xe,renameSync as at,rmSync as ot,statSync as Ka}from"fs";import{cpus as Va}from"os";import{join as hr}from"path";function Ya(e,t,n){if(!e.defaultOutputPath)return;let r=hr(t,e.defaultOutputPath);n!==r&&xe(r)&&at(r,n)}function Qa(e,t,n){if(!e.defaultOutputPath)return null;let r=hr(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return ot(i,{force:!0}),xe(r)?(at(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function Za(e){e&&(ot(e.defaultOutputPath,{force:!0}),e.backupPath&&xe(e.backupPath)&&at(e.backupPath,e.defaultOutputPath))}function eo(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,Va().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function yr(e,t,n,r){let i=e.filter(c=>c.config.defaultOutputPath),a=e.filter(c=>!c.config.defaultOutputPath),o=[],s=eo(a.length,r),d=await ro(a,s,c=>it(c,t,n));if(s>1){let c=new Map;for(let l of d.filter(u=>u.result.skipped&&u.retryable)){let u=a.find(p=>p.id===l.result.id);u&&(n(`Retrying ${u.label} indexer serially after parallel failure...`),c.set(u.id,(await it(u,t,n)).result))}o.push(...d.map(({result:l})=>c.get(l.id)??l))}else o.push(...d.map(({result:c})=>c));for(let c of i)o.push((await it(c,t,n)).result);return o.sort((c,l)=>e.findIndex(u=>u.id===c.id)-e.findIndex(u=>u.id===l.id))}async function it(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),ot(e.scipPath,{force:!0});let r=Qa(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),a=P();try{e.trustedProjectTool&&En(t,e.trustedProjectTool);let s=yt(e.binary,e.args),d=await yn({command:s.binary,args:s.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:to(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024});if(d.status!==0){let c=d.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${d.status}${c?`:
248
+ ${c}`:""}`)}Ya(e.config,t,e.scipPath)}catch(s){let d=s instanceof Error?s.message:String(s),c=`${e.resolvedBinary} indexer failed: ${d.split(`
249
+ `)[0]}`,l=e.label===e.language?c:`${e.label}: ${c}`;return n(`Skipping ${e.label}: ${c}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,skipped:{language:e.language,reason:l}},retryable:no(s)}}finally{Za(r)}if(!xe(e.scipPath)){let s=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,d=e.label===e.language?s:`${e.label}: ${s}`;return n(`Skipping ${e.label}: ${s}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,skipped:{language:e.language,reason:d}},retryable:!1}}let o;try{o=Ka(e.scipPath).size}catch{o=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,outputBytes:o},retryable:!1}}function to(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):mn.indexer}function no(e){return e instanceof hn?e.kind==="spawn"&&mr(e.cause):mr(e)}function mr(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}async function ro(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,a=Math.max(1,Math.min(e.length,t)),o=Array.from({length:a},async()=>{for(;i<e.length;){let s=i++;r[s]=await n(e[s])}});return await Promise.all(o),r}import{execFileSync as br}from"child_process";import{homedir as Sr,platform as io}from"os";import{delimiter as ao,join as Re}from"path";function Pr(e,t){let n=e.installMethods,r=fe(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n){if(!i.identity||!i.destination){t(`Refusing ${i.label} installation for ${r}: the installer descriptor lacks an immutable identity or destination.`);continue}if(!ae(i.prerequisite))continue;let a=oo(i);t(`Installing immutable ${i.identity} via ${i.label} into ${a}; expected executable: ${r}.`);try{br(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:io()==="win32"});let o=N(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${i.identity} via ${i.label}${s}; resolved executable: ${o}.`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function oo(e){if(e.binary==="npm")return st("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=st("go",["env","GOBIN"]);if(t)return t;let n=st("go",["env","GOPATH"]);if(n)return Re(n.split(ao)[0],"bin")}return e.binary==="dotnet"?Re(process.env.DOTNET_CLI_HOME??Sr(),".dotnet","tools"):e.binary==="dart"?Re(process.env.PUB_CACHE??Re(Sr(),".pub-cache"),"bin"):e.destination}function st(e,t){try{return br(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}async function Dr(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,i=e.skipAutoInstall===!0||e.installMissing!==!0,a=mo(e),o=Date.now(),s=P();ve(y(a.outputScip),{recursive:!0}),ve(y(a.outputDb),{recursive:!0});let d=e.languages??Ut(t);if(d.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${d.join(", ")}`);let c=j("reindex.fingerprint",()=>Tt(t,d,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:d.length}),l,u;if(e.skipIfUnchanged!==!1&&!an(t,a.outputDb)&&xr(a.outputScip)===xr(I(y(a.outputDb),"index.scip"))){let m=oe(t);if(l=m?le(m,c):void 0,l){let b=ue(l);if(b){if(!fo(a,c))try{Ne({snapshot:l,manifest:b,targetCacheDir:y(a.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${l.generationId.slice(0,12)}`)}catch(f){r(`Shared generation attach failed; continuing locally: ${G(f)}`)}}else{let f=await sn(l);if(f.kind==="owner")u=f.release;else if(f.kind==="generation-ready"){let S=ue(l);if(S)try{Ne({snapshot:l,manifest:S,targetCacheDir:y(a.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${l.generationId.slice(0,12)} after waiting`)}catch(x){r(`Shared generation attach failed after waiting; continuing locally: ${G(x)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let p=vt(I(y(a.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!p)throw u?.(),new Error(`Could not acquire scip-query cache lifecycle lock for ${y(a.outputDb)}.`);let h;try{h=await H("reindex.lock",()=>Uo(I(y(a.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:d.length})}catch(m){throw p.release(),u?.(),m}let g=null;try{nn(a.outputDb,a.outputScip,a.metaPath);let m=bo(y(a.outputDb));m.removed>0&&r(`Removed ${m.removed} abandoned reindex workspace(s)`);for(let M of m.errors)r(`Could not remove abandoned reindex workspace: ${M}`);let b=null,f=j("reindex.reuse-check",()=>(b=ho({opts:e,paths:a,languages:d,fingerprint:c,start:o,monotonicStart:s,onStatus:r}),b),()=>({languages:d.length,reused:b!==null}));if(f)return Rr({snapshot:l,paths:a,projectRoot:t,fingerprint:c,onStatus:r}),Le(a.outputDb,f),Me(t,y(a.outputDb)),f;await H("reindex.scip-cli-ready",()=>Oo(i,r));let S=So(a);g=S.runDir;let x,R=await H("reindex.fresh",async()=>(x=await Po({opts:e,languages:d,projectRoot:t,paths:a,tempPaths:S,fingerprint:c,start:o,monotonicStart:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r}),x),()=>({languages:d.length,reused:x?.reused,skipped:x?.skipped.length}));return Rr({snapshot:l,paths:a,projectRoot:t,fingerprint:c,onStatus:r}),Le(a.outputDb,R),Me(t,y(a.outputDb)),R}catch(m){let b=we({trigger:e.trigger,result:"failed",start:o,monotonicStart:s,error:m instanceof Error?m.message:String(m)});throw Jr(a.metaPath,b),qt(a.outputDb,b),m}finally{g&&B(g,{recursive:!0,force:!0}),h(),p.release(),u?.()}}function Rr(e){if(e.snapshot){if(ue(e.snapshot)){Ce(e.snapshot,y(e.paths.outputDb),"local-fresh");return}try{let t=oe(e.projectRoot),n=t?le(t,e.fingerprint):void 0;if(!n||n.generationId!==e.snapshot.generationId){e.onStatus("Skipped shared generation publication because the worktree changed during indexing");return}on({snapshot:e.snapshot,sourceCacheDir:y(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let r=oe(e.projectRoot);return(r?le(r,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}}),Ce(e.snapshot,y(e.paths.outputDb),"built"),e.onStatus(`Published shared generation ${e.snapshot.generationId.slice(0,12)}`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${G(t)}`)}}}function fo(e,t){if(!F(e.outputScip)||!F(e.outputDb)||!Hr(e.metaPath,t))return!1;let n=X(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function G(e){return e instanceof Error?e.message:String(e)}function mo(e){let t=e.outputScip??I(e.projectRoot,"index.scip"),n=e.outputDb??I(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:I(y(n),"meta.json")}}function ho(e){let t=X(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!F(e.paths.outputScip)||!F(e.paths.outputDb)||!Hr(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;de(ce(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=P()-e.monotonicStart,r=we({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return Jr(e.paths.metaPath,r),e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[],lastRefresh:r,shards:yo(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function yo(e,t,n,r){let i=Gr(t,n,r);return n.map(a=>({id:a,language:a,reused:!0,fingerprint:Y(i[a]),outputBytes:Q(ut(e.outputDb,a)),durationMs:0}))}function So(e){let t=lo(I(y(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:I(t,Ie(e.outputScip)),tempOutputDb:I(t,Ie(e.outputDb)),tempMetaPath:I(t,Ie(e.metaPath))}}function bo(e){let t=[],n;try{n=Tr(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[G(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{B(I(e,i.name),{recursive:!0,force:!0}),r+=1}catch(a){t.push(`${i.name}: ${G(a)}`)}return{removed:r,errors:t}}async function Po(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await H("reindex.language-indexers",async()=>(n=await Ro(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:a,reusedLanguages:o,languageFingerprints:s,shards:d,typescriptProjectShardContext:c,incrementalTypeScript:l}=r;if(o.length>0&&e.onStatus(`Reused ${o.length} cached language shard(s): ${o.join(", ")}`),xo({run:e,indexedOutputs:i,skippedLanguages:a,reusedLanguages:o})){let h=j("reindex.publish",()=>Do(e,i,a,o,s,c),{mode:"metadata-only",languages:i.length,reused:o.length}),g=h.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(g/1e3).toFixed(1)}s`),{languages:i.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:g,reused:!0,skipped:a,lastRefresh:h,shards:d}}let u=j("reindex.publish",()=>_o(e,t,i,a,o,s,c,l),{mode:l?"incremental-or-fallback":"full",languages:i.length,reused:o.length,skipped:a.length}),p=u.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:i.map(h=>h.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:a,lastRefresh:u,shards:d}}function xo(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!F(e.run.paths.outputScip)||!F(e.run.paths.outputDb))return!1;let t=X(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(i=>i.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(i=>n.has(i)&&r.has(i))}async function Ro(e,t){let n=jo({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),r=[],i=new Set;for(let[E,ft]of n)ft.reused&&(r.push({language:E,scipPath:ft.scipPath}),i.add(E));for(let E of i)e.onStatus(`Reusing cached ${E} SCIP shard (language inputs unchanged).`);let a=n.get("typescript"),o=X(e.paths.outputDb,e.paths.metaPath),s=ee(e.paths.metaPath),d=o.state==="legacy"||o.state==="current",c=s?.scipCompanion!=="deferred"&&(o.state!=="current"||o.generation.publication?.scipCompanion!=="deferred"),l=a&&!a.reused&&d?gr({projectRoot:e.projectRoot,cacheDir:y(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:a.scipPath,candidateShardPath:Z(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:Z(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:c,previousSnapshot:lt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,u=new Set(l?["typescript"]:[]),p=l?void 0:Io(e,n),{preparedRuns:h,skippedLanguages:g,languageOutputScipPaths:m}=Ao({languages:e.languages.filter(E=>!i.has(E)&&!u.has(E)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,trustProjectTools:e.opts.trustProjectTools===!0,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:p?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),b=p?h.filter(E=>E.language!=="typescript"||p.missedProjectIds.has(E.id)):h,f=await yr(b,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),S=[];if(p){Eo(e.paths.outputDb,f);let E=m.typescript??e.tempPaths.tempOutputScip;S=Fo({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:E,reusedProjects:p.reusedProjects})}let x=[...f,...S],{indexedOutputs:R}=No(x,g),M=l?[{language:"typescript",scipPath:l.scipPath}]:[],gt=[...r,...M,...R];Co(gt,g,e.languages,e.opts.allowPartial,e.onStatus);let Yr=l?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:l.scipPath,outputScipPath:l.scipPath,durationMs:l.durationMs,command:"watch-service:typescript-index",outputBytes:Q(l.scipPath)??void 0}]:[],Qr=wo(n,[...f,...Yr],p?{outputDb:e.paths.outputDb,classification:p.classification}:void 0);return{indexedOutputs:gt,skippedLanguages:g,reusedLanguages:[...i],languageFingerprints:To(n,e.languages),shards:Qr,typescriptProjectShardContext:p?{projects:p.allProjects,fingerprints:p.fingerprints}:void 0,incrementalTypeScript:l??void 0}}function Io(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=V(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=tr(e.projectRoot,r),a=Qn(n.fingerprint.files,r),o=Zn(r,i),s=er(r,a,o),d=ee(e.paths.metaPath),l=vo(d,s,g=>F(je(e.paths.outputDb,g))),u=[...l.entries()].filter(([,g])=>g.reused).map(([g])=>g),p=new Set(u),h=new Set(r.filter(g=>!p.has(g)).map(g=>`typescript:${g}`));return{allProjects:r,fingerprints:s,classification:l,reusedProjects:u,missedProjectIds:h}}function vo(e,t,n){let r=new Map;for(let i of Object.keys(t)){let a=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a});continue}let o=e.version===U&&ke(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[i]:void 0;if(!o){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:a});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a});continue}if(w(o)!==w(a)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:a});continue}r.set(i,{reused:!0,fingerprint:a})}return r}function Eo(e,t){for(let n of t){if(n.skipped||!n.id.startsWith("typescript:"))continue;let r=n.id.slice(11),i=je(e,r);ve(y(i),{recursive:!0}),Fe(n.scipPath,i)}}function Fo(e){return e.reusedProjects.map((t,n)=>{let r=je(e.outputDb,t),i=Z(e.tempOutputScip,"typescript-project-cached",n);return Fe(r,i),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:Q(i)??void 0}})}function jo(e){let t=ee(e.paths.metaPath),n=Gr(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let a=ut(e.paths.outputDb,i),o=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:o,scipPath:a});continue}if(t.version!==U){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:o,scipPath:a});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:o,scipPath:a});continue}if(!ke(t).languageShardReuse||!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:o,scipPath:a});continue}let s=t.languageFingerprints[i];if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:o,scipPath:a});continue}if(!F(a)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:o,scipPath:a});continue}if(w(s)!==w(o)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:o,scipPath:a});continue}r.set(i,{reused:!0,fingerprint:o,scipPath:a})}return r}function wo(e,t,n){let r=[];for(let[i,a]of e)a.reused&&r.push({id:i,language:i,reused:!0,fingerprint:Y(a.fingerprint),outputBytes:Q(a.scipPath),durationMs:0});for(let i of t){let a=e.get(i.language),o=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,s=o?n.classification.get(o):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:s?.reason??a?.reason??i.skipped?.reason,fingerprint:s?Y(s.fingerprint):a?Y(a.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,a]of n.classification)a.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:Y(a.fingerprint),outputBytes:Q(je(n.outputDb,i)),durationMs:0});return r}function Y(e){return co("sha256").update(w(e)).digest("hex").slice(0,16)}function Q(e){try{return uo(e).size}catch{return null}}function To(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}function _o(e,t,n,r,i,a,o,s){let d=!s||s.completeScipUpdated,c=!1;d&&(Ir(e.paths.outputDb,n),c=vr(n,e.tempPaths.tempOutputScip,e.onStatus));let l=$o({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:s,completeScipAvailable:d,completeScipSanitized:c,materializeFullFallback:()=>{if(!s||s.completeScipUpdated)return c;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),fr({cacheDir:y(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let S=n.map(x=>x.language==="typescript"?{language:x.language,scipPath:s.candidateScipPath}:x);return Ir(e.paths.outputDb,S),c=vr(S,e.tempPaths.tempOutputScip,e.onStatus),c}});if(de(ce(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),l.mode==="incremental"&&s){let S=null,x=null;try{S=new k({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),x=new k({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let R=kn(S,e.fingerprint,s.referenceFragmentsByFile,x);e.onStatus(`Cached exact TypeScript reference fragments for ${R} affected document(s).`)}catch(R){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${R instanceof Error?R.message:String(R)}.`)}finally{S?.close(),x?.close()}}let u=lt(e.paths.metaPath),p=l.mode==="incremental"&&s?Go(s,l.changedDocumentPaths):qe({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:u,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),h=we({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(S=>S.language),skipped:[...r]}),g=l.mode==="incremental"&&l.scipCompanion==="deferred",m={...a};g&&delete m.typescript;let{metadata:b,pruneProjects:f}=Mr({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:m,typescriptProjectShardContext:o,lastRefresh:h});return b.scipCompanion=g?"deferred":"current",Or(e.paths.outputDb,f),pt(e.tempPaths.tempMetaPath,b),tn({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}}),en(y(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),kr(e.paths.outputDb,p,e.onStatus),h}function Do(e,t,n,r,i,a){let o=lt(e.paths.metaPath),s=null;try{Fe(e.paths.outputDb,e.tempPaths.tempOutputDb)}catch(u){s=Ln("reused","oracle-error",`Could not snapshot the prior database: ${u instanceof Error?u.message:String(u)}`)}de(ce(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),s??=qe({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:o,currentSnapshot:e.fingerprint,refreshResult:"reused"});let d=we({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(u=>u.language),skipped:[...n]}),{metadata:c,pruneProjects:l}=Mr({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:a,lastRefresh:d});return Or(e.paths.outputDb,l),pt(e.paths.metaPath,c),rn(e.paths.outputDb,e.paths.metaPath),kr(e.paths.outputDb,s,e.onStatus),d}function lt(e){return ht(ee(e)?.fingerprint)}function kr(e,t,n){try{Nn(e,t),t.status==="evaluated"?n(`Affected-set shadow: ${(t.evaluation.recall*100).toFixed(1)}% recall; ${t.plan.affectedFiles.length} predicted, ${t.comparison.changedFiles.length} changed.`):n(`Affected-set shadow unavailable: ${t.reason}.`)}catch(r){n(`Affected-set shadow telemetry unavailable: ${r instanceof Error?r.message:String(r)}`)}}function Mr(e){let t=ko({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:U,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function ko(e){if(e.mode!=="workspace")return{field:void 0,pruneProjects:null};if(e.skippedLanguages.some(t=>t.language==="typescript"))return{field:void 0,pruneProjects:null};if(e.reusedLanguages.includes("typescript")){let t=ee(e.metaPath),n=t?.version===U?t.typescriptProjectShards:void 0;return{field:n,pruneProjects:n?Object.keys(n):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function Or(e,t){let n=Ur(e);if(t===null){B(n,{recursive:!0,force:!0});return}let r;try{r=Tr(n)}catch{return}for(let i of Mo(r,t))B(I(n,i),{force:!0})}function Mo(e,t){let n=new Set(t.map(r=>`${Ze(r)}.scip`));return e.filter(r=>!n.has(r))}function Ir(e,t){for(let n of t){let r=ut(e,n.language);ve(y(r),{recursive:!0}),n.scipPath!==r&&Fe(n.scipPath,r)}}async function Oo(e,t){if(!Oe()){if(go()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package scip-query-scip-windows (installed automatically with scip-query). Reinstall scip-query with optional dependencies enabled, or follow 'scip-query setup' guidance for the exact sidecar package version, or set SCIP_QUERY_SCIP_BIN to a local scip.exe path.");if(e)throw new Error(`The scip CLI is required but not found on PATH.
250
+ To install the reviewed version, run: scip-query reindex --install-missing
251
+ Or install manually from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!bt(t))throw new Error(`The scip CLI is required but could not be installed.
252
+ Install manually from: https://github.com/sourcegraph/scip/releases`)}}function Ao(e){let t=[],n=[],r=e.languages.map((a,o)=>({language:a,scipPath:e.languages.length>1?Z(e.tempOutputScip,a,o):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:a,scipPath:o})=>[a,o]));for(let{language:a,scipPath:o}of r){let s=Lo({...e,language:a,scipPath:o});for(let d of s)"skipped"in d?Ar(n,d.skipped):t.push(d.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function Lo(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[ct({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??V(e.projectRoot,e.typescriptProjects);return t.length===0?[ct({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(e.onStatus(`Indexing TypeScript workspace as ${t.length} project shard(s).`),t.map((n,r)=>ct({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:Z(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function ct(e){let t=ze(e.language),n=fe(t),r=In(t,e.projectRoot),i=e.trustProjectTools&&r?vn(t,e.projectRoot):null,a=N(t);if(!i&&!a&&r){let c=`${n} is available only as repository-local code at ${r}. Review that exact tool and rerun with --trust-project-tools.`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}if(!i&&!a&&!xn(t)){if(e.skipAutoInstall){let c=`${n} not found on PATH. To install the reviewed version, run: scip-query reindex --install-missing${t.installUrl?` (manual source: ${t.installUrl})`:""}`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!Pr(t,e.onStatus)){let c=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}}let o=i?.canonicalPath??N(t);if(!o){let c=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}let{binary:s,args:d}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:o,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0});if(i&&!i.executable){let c=`${i.relativePath} is not executable; refusing project-local indexer.`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}return i&&e.onStatus(`Trusted project-local ${e.language} indexer ${i.relativePath} (${i.sha256.slice(0,12)}\u2026, ${i.canonicalPath}).`),{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:o,binary:s,args:d,env:jn(t,e.env,o),...i?{trustedProjectTool:i}:{}}}}function No(e,t){let n=new Map;for(let i of e)if(i.skipped)Ar(t,i.skipped);else{let a=`${i.language}\0${i.outputScipPath}`,o=n.get(a)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};o.scipPaths.push(i.scipPath),n.set(a,o)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)Jt(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let a=i.scipPaths[0];a!==i.outputScipPath&&_r(a,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function Ar(e,t){let n=e.find(r=>r.language===t.language);if(!n){e.push(t);return}n.reason.includes(t.reason)||(n.reason=`${n.reason}; ${t.reason}`)}function Co(e,t,n,r,i){if(e.length===0){let a=t.map(o=>` - ${o.language}: ${o.reason}`).join(`
252
253
  `);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
253
254
  `+a)}if(t.length!==0&&(i(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(a=>a.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
254
255
  `+t.map(a=>` - ${a.language}: ${a.reason}`).join(`
255
- `))}function cr(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=At(e.map(a=>a.scipPath),t);return xr(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&fr(e[0].scipPath,t);return!1}function Ps(e){let t;if(xs(e)){let i=I(e.run.tempPaths.runDir,"typescript-affected.db");try{Pr(e.incrementalTypeScript.affectedScipPath,e.run.onStatus),e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let a=performance.now();dr(e.incrementalTypeScript.affectedScipPath,i,e.env,e.run.onStatus),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-a).toFixed(0)}ms.`);let s=On({previousDbPath:e.run.paths.outputDb,miniDbPath:i,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:e.incrementalTypeScript.affectedFiles});return e.run.onStatus(`Patched ${s.affectedDocumentCount} SQLite document(s) in ${(s.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:s.changedDocumentPaths,patchDurationMs:s.durationMs,converterDurationMs:performance.now()-a,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(a){t=a instanceof Error?a.message:String(a),C(i,{force:!0}),C(e.run.tempPaths.tempOutputDb,{force:!0}),e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}}let n=e.completeScipSanitized;e.completeScipAvailable||(n=e.materializeFullFallback());let r=performance.now();return dr(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.env,e.run.onStatus,n),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function xs(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!F(e.run.paths.outputDb)||!F(e.run.paths.outputScip))return!1;let t=new Set(e.reusedLanguages);return e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(n=>n==="typescript"||t.has(n))}function Rs(e,t){let n=P(),r=[...t].sort(),i=new Set(r),a={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(s=>!i.has(s)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:P()-n,manifest:e.manifest,plan:e.plan,comparison:a,evaluation:Ne(e.plan,a,e.projectFileCount)}}function dr(e,t,n,r,i=!1){if(r("Converting to SQLite..."),!F(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{i||Pr(e,r);let a=Fe();if(!a)throw new Error("scip CLI is not available");Ja(a,["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024,timeout:3e5,killSignal:"SIGKILL"})}catch(a){let s=a instanceof Error?a.message:String(a);throw new Error(`Failed to convert SCIP index to SQLite: ${s}`,{cause:a})}}function Pr(e,t){let n=Mt(e);xr(n,t)}function xr(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function K(e,t,n){let r=za(e)||".scip",i=Se(e,r);return I(S(e),`${i}.${n+1}.${t}${r}`)}async function Is(e,t){for(let n=0;n<2;n++){let r=vs(e,t);if(r)return r;let i=Es(e);if(i&&vr(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let a;try{a=await ws(i)}catch(o){throw new Error(`Could not verify the watcher's in-progress reindex owner (pid ${i.pid}); refusing to steal an active lock: ${$(o)}`,{cause:o})}if(!a)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${S(e)}; refusing to steal an active lock.`);let s=we(e,{parseLegacy:Pe});if(!mt(e,s,{parseLegacy:Pe}))throw new Error(`Reindex lock ownership changed before preemption completed for ${S(e)}.`);continue}throw new Error(`Another scip-query reindex is already running for ${S(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${S(e)}.`)}function vs(e,t){let n=M(process.pid),r=ft(e,{kind:"reindex",processIdentity:n,detail:{projectRoot:t.projectRoot,...process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1"?{processGroupLeader:!0}:{},...t.trigger?{trigger:t.trigger}:{}},parseLegacy:Pe});if(r.kind==="acquired"&&r.reclaimed){let i=Rr(r.reclaimed,e);i&&vr(t.trigger,i)?t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}; its prior owner was already stale.`):t.onStatus(`Recovered an abandoned or incomplete reindex lock for ${S(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function Es(e){return Rr(we(e,{parseLegacy:Pe}),e)}var Pe=e=>{let t=Ir(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function Rr(e,t){if(e.state==="valid"&&e.record?.kind==="reindex"){let n=e.record.detail??{};return{version:2,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:S(t),startedAt:e.record.startedAt,trigger:n.trigger}}return Ir(e.parsed,t)}function Ir(e,t){try{let n=e;return typeof n.pid!="number"||!Number.isInteger(n.pid)||n.pid<=0?null:{version:n.version===2?2:1,pid:n.pid,...n.processIdentity===void 0?{}:(()=>{let r=pt(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:S(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function vr(e,t){return e?.kind==="manual-cli"&&Fs(t?.trigger)}function Fs(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function ws(e){return!O(e.pid)||(tt(e),lr(e,"SIGTERM"),await ur(e,2e3))?!0:(tt(e),lr(e,"SIGKILL"),ur(e,1e3))}function lr(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!O(e.pid))return;tt(e)}try{process.kill(e.pid,t)}catch{}}async function ur(e,t){let n=P()+t;for(;P()<n;){if(pr(e))return!0;await _s(50)}return pr(e)}function tt(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=M(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!J(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function pr(e){if(!O(e.pid))return!0;if(!e.processIdentity)return!1;let t=M(e.pid);return t!==null&&!J(e.processIdentity,t)}function _s(e){return new Promise(t=>setTimeout(t,e))}function Er(e,t,n){return Object.fromEntries(t.map(r=>{let i=Be(r).markerFiles,a=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:yt(n.typescriptProjects)}:{typescriptProjectMode:"single",typescriptProjects:[]},s=r==="clojure"?js(n.clojureConfigPath):void 0;return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&Ds(n),...a,clojureConfigPath:s,files:St(e,{language:r,markerFiles:i})}]}))}function js(e){return e?.trim()||void 0}function Ds(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function it(e,t){return I(S(e),"language-indexes",`${t}.scip`)}function Fr(e){return I(S(e),"language-indexes","typescript-projects")}function Re(e,t){return I(Fr(e),`${qe(t)}.scip`)}function Z(e){try{return ve(ne(nt(e,"utf-8")))}catch{return null}}function wr(e,t){try{let n=ne(nt(e,"utf-8"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&_(r.fingerprint)===_(t)&&_([...r.indexedLanguages??[]].sort())===_(t.languages)}catch{return!1}}function at(e,t){xt(e,t,{spacing:2,trailingNewline:!0})}function _r(e,t){try{let n=ve(ne(nt(e,"utf-8")));if(!n)return;at(e,{...n,lastRefresh:t})}catch{}}function Ie(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:P()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function _(e){return JSON.stringify(e)}var Tr=process.env.SCIP_REINDEX_PROJECT_ROOT,Mr=process.env.SCIP_REINDEX_OUTPUT_SCIP,Or=process.env.SCIP_REINDEX_OUTPUT_DB,jr=process.env.SCIP_REINDEX_LANGUAGES,ks=cn(process.env.SCIP_REINDEX_INDEXER_CONCURRENCY),Ts=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1",Dr=Ns(process.env.SCIP_REINDEX_TYPESCRIPT_CONFIG),Ms=process.env.SCIP_REINDEX_CLOJURE_CONFIG_PATH||void 0,Os=Ls(process.env.SCIP_REINDEX_TRIGGER_KIND),As=process.env.SCIP_REINDEX_TRIGGER_DETAIL;(!Tr||!Mr||!Or)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var kr=jr?jr.split(",").filter(Boolean):void 0;mr({projectRoot:Tr,outputScip:Mr,outputDb:Or,languages:kr?.length?kr:void 0,pnpmWorkspaces:Ts,typescriptProjectMode:Dr.projectMode,typescriptProjects:Dr.projects,clojureConfigPath:Ms,indexerConcurrency:ks,trigger:{kind:Os,detail:As||void 0},onStatus:e=>process.stderr.write(`[reindex] ${e}
256
- `)}).then(()=>{process.exit(0)}).catch(e=>{console.error(`reindex-worker error: ${e}`),process.exit(1)});function Ls(e){switch(e){case"manual-cli":case"setup":case"watch-source":case"watch-git-head":case"watch-git-index":case"watch-git-state":return e;default:return"unknown"}}function Ns(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};let n=t,r=n.projectMode==="single"||n.projectMode==="workspace"?n.projectMode:void 0,i=Array.isArray(n.projects)?n.projects.filter(a=>typeof a=="string"&&a.trim()!==""):void 0;return{projectMode:r,projects:i&&i.length>0?i:void 0}}catch{return{}}}
256
+ `))}function vr(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=Wt(e.map(a=>a.scipPath),t);return Nr(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&_r(e[0].scipPath,t);return!1}function $o(e){let t;if(Bo(e)){let i=I(e.run.tempPaths.runDir,"typescript-affected.db");try{Lr(e.incrementalTypeScript.affectedScipPath,e.run.onStatus),e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let a=performance.now();Er(e.incrementalTypeScript.affectedScipPath,i,e.env,e.run.onStatus),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-a).toFixed(0)}ms.`);let o=Kn({previousDbPath:e.run.paths.outputDb,miniDbPath:i,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:e.incrementalTypeScript.affectedFiles});return e.run.onStatus(`Patched ${o.affectedDocumentCount} SQLite document(s) in ${(o.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:o.changedDocumentPaths,patchDurationMs:o.durationMs,converterDurationMs:performance.now()-a,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(a){t=a instanceof Error?a.message:String(a),B(i,{force:!0}),B(e.run.tempPaths.tempOutputDb,{force:!0}),e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}}let n=e.completeScipSanitized;e.completeScipAvailable||(n=e.materializeFullFallback());let r=performance.now();return Er(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.env,e.run.onStatus,n),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function Bo(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!F(e.run.paths.outputDb)||!F(e.run.paths.outputScip))return!1;let t=new Set(e.reusedLanguages);return e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(n=>n==="typescript"||t.has(n))}function Go(e,t){let n=P(),r=[...t].sort(),i=new Set(r),a={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(o=>!i.has(o)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:P()-n,manifest:e.manifest,plan:e.plan,comparison:a,evaluation:We(e.plan,a,e.projectFileCount)}}function Er(e,t,n,r,i=!1){if(r("Converting to SQLite..."),!F(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{i||Lr(e,r);let a=Oe();if(!a)throw new Error("scip CLI is not available");so(a,["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024,timeout:3e5,killSignal:"SIGKILL"})}catch(a){let o=a instanceof Error?a.message:String(a);throw new Error(`Failed to convert SCIP index to SQLite: ${o}`,{cause:a})}}function Lr(e,t){let n=Ht(e);Nr(n,t)}function Nr(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function Z(e,t,n){let r=po(e)||".scip",i=Ie(e,r);return I(y(e),`${i}.${n+1}.${t}${r}`)}async function Uo(e,t){for(let n=0;n<2;n++){let r=Ho(e,t);if(r)return r;let i=Jo(e);if(i&&Br(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let a;try{a=await qo(i)}catch(s){throw new Error(`Could not verify the watcher's in-progress reindex owner (pid ${i.pid}); refusing to steal an active lock: ${G(s)}`,{cause:s})}if(!a)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${y(e)}; refusing to steal an active lock.`);let o=Ae(e,{parseLegacy:Ee});if(!It(e,o,{parseLegacy:Ee}))throw new Error(`Reindex lock ownership changed before preemption completed for ${y(e)}.`);continue}throw new Error(`Another scip-query reindex is already running for ${y(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${y(e)}.`)}function Ho(e,t){let n=O(process.pid),r=Rt(e,{kind:"reindex",processIdentity:n,detail:{projectRoot:t.projectRoot,...process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1"?{processGroupLeader:!0}:{},...t.trigger?{trigger:t.trigger}:{}},parseLegacy:Ee});if(r.kind==="acquired"&&r.reclaimed){let i=Cr(r.reclaimed,e);i&&Br(t.trigger,i)?t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}; its prior owner was already stale.`):t.onStatus(`Recovered an abandoned or incomplete reindex lock for ${y(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function Jo(e){return Cr(Ae(e,{parseLegacy:Ee}),e)}var Ee=e=>{let t=$r(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function Cr(e,t){if(e.state==="valid"&&e.record?.kind==="reindex"){let n=e.record.detail??{};return{version:2,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:y(t),startedAt:e.record.startedAt,trigger:n.trigger}}return $r(e.parsed,t)}function $r(e,t){try{let n=e;return typeof n.pid!="number"||!Number.isInteger(n.pid)||n.pid<=0?null:{version:n.version===2?2:1,pid:n.pid,...n.processIdentity===void 0?{}:(()=>{let r=Pt(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:y(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function Br(e,t){return e?.kind==="manual-cli"&&Wo(t?.trigger)}function Wo(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function qo(e){return!A(e.pid)||(dt(e),Fr(e,"SIGTERM"),await jr(e,2e3))?!0:(dt(e),Fr(e,"SIGKILL"),jr(e,1e3))}function Fr(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!A(e.pid))return;dt(e)}try{process.kill(e.pid,t)}catch{}}async function jr(e,t){let n=P()+t;for(;P()<n;){if(wr(e))return!0;await zo(50)}return wr(e)}function dt(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=O(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!W(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function wr(e){if(!A(e.pid))return!0;if(!e.processIdentity)return!1;let t=O(e.pid);return t!==null&&!W(e.processIdentity,t)}function zo(e){return new Promise(t=>setTimeout(t,e))}function Gr(e,t,n){return Object.fromEntries(t.map(r=>{let i=ze(r).markerFiles,a=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:Et(n.typescriptProjects)}:{typescriptProjectMode:"single",typescriptProjects:[]},o=r==="clojure"?Xo(n.clojureConfigPath):void 0;return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&Ko(n),...a,clojureConfigPath:o,files:wt(e,{language:r,markerFiles:i})}]}))}function Xo(e){return e?.trim()||void 0}function Ko(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function ut(e,t){return I(y(e),"language-indexes",`${t}.scip`)}function Ur(e){return I(y(e),"language-indexes","typescript-projects")}function je(e,t){return I(Ur(e),`${Ze(t)}.scip`)}function ee(e){try{return De(ie(T(e,"reindex metadata")))}catch{return null}}function Hr(e,t){try{let n=ie(T(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&w(r.fingerprint)===w(t)&&w([...r.indexedLanguages??[]].sort())===w(t.languages)}catch{return!1}}function pt(e,t){Dt(e,t,{spacing:2,trailingNewline:!0})}function Jr(e,t){try{let n=De(ie(T(e,"reindex metadata")));if(!n)return;pt(e,{...n,lastRefresh:t})}catch{}}function we(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:P()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function w(e){return JSON.stringify(e)}var Xr=process.env.SCIP_REINDEX_PROJECT_ROOT,Kr=process.env.SCIP_REINDEX_OUTPUT_SCIP,Vr=process.env.SCIP_REINDEX_OUTPUT_DB,Wr=process.env.SCIP_REINDEX_LANGUAGES,Vo=Sn(process.env.SCIP_REINDEX_INDEXER_CONCURRENCY),Yo=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1",qr=ns(process.env.SCIP_REINDEX_TYPESCRIPT_CONFIG),Qo=process.env.SCIP_REINDEX_CLOJURE_CONFIG_PATH||void 0,Zo=ts(process.env.SCIP_REINDEX_TRIGGER_KIND),es=process.env.SCIP_REINDEX_TRIGGER_DETAIL;(!Xr||!Kr||!Vr)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var zr=Wr?Wr.split(",").filter(Boolean):void 0;Dr({projectRoot:Xr,outputScip:Kr,outputDb:Vr,languages:zr?.length?zr:void 0,pnpmWorkspaces:Yo,typescriptProjectMode:qr.projectMode,typescriptProjects:qr.projects,clojureConfigPath:Qo,indexerConcurrency:Vo,trigger:{kind:Zo,detail:es||void 0},onStatus:e=>process.stderr.write(`[reindex] ${Ge(e)}
257
+ `)}).then(()=>{process.exit(0)}).catch(e=>{console.error(`reindex-worker error: ${Ge(String(e))}`),process.exit(1)});function ts(e){switch(e){case"manual-cli":case"setup":case"watch-source":case"watch-git-head":case"watch-git-index":case"watch-git-state":return e;default:return"unknown"}}function ns(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};let n=t,r=n.projectMode==="single"||n.projectMode==="workspace"?n.projectMode:void 0,i=Array.isArray(n.projects)?n.projects.filter(a=>typeof a=="string"&&a.trim()!==""):void 0;return{projectMode:r,projects:i&&i.length>0?i:void 0}}catch{return{}}}
257
258
  //# sourceMappingURL=reindex-worker.js.map