scip-query 0.24.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (661) hide show
  1. package/CHANGELOG.md +247 -1
  2. package/README.md +111 -124
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/by-kind-PRVFAGTQ.js +2 -0
  5. package/dist/call-graph-DVPAQV2F.js +2 -0
  6. package/dist/{call-graph-evidence-BociKRpF.d.ts → call-graph-evidence-CUtj8V2I.d.ts} +1 -1
  7. package/dist/chunk-2FSBGL5P.js +2 -0
  8. package/dist/chunk-2HLAFUCY.js +2 -0
  9. package/dist/chunk-2IWUT6CJ.js +3 -0
  10. package/dist/chunk-2KNN7GTQ.js +2 -0
  11. package/dist/chunk-2LHXRE2B.js +8 -0
  12. package/dist/{chunk-E65ELFKU.js → chunk-2YXE77TJ.js} +2 -2
  13. package/dist/chunk-36SGVCGX.js +2 -0
  14. package/dist/chunk-3ABBFPTP.js +2 -0
  15. package/dist/chunk-3IVFU4FD.js +3 -0
  16. package/dist/chunk-3JIQS44J.js +7 -0
  17. package/dist/chunk-3ZRB6DNK.js +7 -0
  18. package/dist/{chunk-6YTSKJJ3.js → chunk-42EOW5VI.js} +1 -1
  19. package/dist/{chunk-BHKK5RJY.js → chunk-4BHGBMNO.js} +2 -2
  20. package/dist/chunk-4BP3UBDG.js +2 -0
  21. package/dist/chunk-4D6RO7G4.js +2 -0
  22. package/dist/chunk-4FEWQ6RH.js +2 -0
  23. package/dist/chunk-4IGEOBG7.js +2 -0
  24. package/dist/chunk-4QZXBUKC.js +2 -0
  25. package/dist/chunk-4WBDEVX2.js +4 -0
  26. package/dist/chunk-4WCUBZU3.js +8 -0
  27. package/dist/chunk-4WTUBQ36.js +40 -0
  28. package/dist/chunk-4XQ4O6IM.js +3 -0
  29. package/dist/chunk-55UQAMZO.js +4 -0
  30. package/dist/chunk-5D2LVK7O.js +125 -0
  31. package/dist/chunk-5IYJ56TT.js +2 -0
  32. package/dist/chunk-5PLMJC7Q.js +2 -0
  33. package/dist/chunk-5TNQJUR2.js +5 -0
  34. package/dist/chunk-62BDNPMI.js +2 -0
  35. package/dist/chunk-64DZ5TXR.js +7 -0
  36. package/dist/chunk-65245JCM.js +2 -0
  37. package/dist/chunk-6FFVZZL4.js +2 -0
  38. package/dist/chunk-6KO5JHAR.js +2 -0
  39. package/dist/chunk-6LRXOOSX.js +2 -0
  40. package/dist/chunk-6LSEIIF7.js +2 -0
  41. package/dist/chunk-6YMNWD3H.js +6 -0
  42. package/dist/chunk-72AD6ZRR.js +5 -0
  43. package/dist/chunk-73AAKPUC.js +4 -0
  44. package/dist/chunk-76CZ77DF.js +2 -0
  45. package/dist/chunk-7VPEEAAG.js +2 -0
  46. package/dist/chunk-7WTPQ4NX.js +14 -0
  47. package/dist/chunk-7Y5T6XDP.js +2 -0
  48. package/dist/chunk-A2IIGFMJ.js +5 -0
  49. package/dist/chunk-AB5KCTEV.js +2 -0
  50. package/dist/chunk-AC566WBP.js +6 -0
  51. package/dist/chunk-AGWFSTXC.js +3 -0
  52. package/dist/chunk-AOSIYPTA.js +2 -0
  53. package/dist/chunk-AUVEWPIF.js +2 -0
  54. package/dist/chunk-B56T42J3.js +25 -0
  55. package/dist/chunk-BIQEF5NE.js +2 -0
  56. package/dist/chunk-BL6XJKTA.js +3 -0
  57. package/dist/chunk-BMKOQJRI.js +2 -0
  58. package/dist/chunk-BOZ4EXBB.js +3 -0
  59. package/dist/chunk-BUTWYEPH.js +2 -0
  60. package/dist/chunk-BZB4QPIP.js +2 -0
  61. package/dist/{chunk-6ILKOOGH.js → chunk-CE357GEE.js} +4 -4
  62. package/dist/chunk-CFN45HFP.js +2 -0
  63. package/dist/chunk-CFYMZFXT.js +368 -0
  64. package/dist/chunk-CN5EH7O3.js +2 -0
  65. package/dist/chunk-D254DNNQ.js +4 -0
  66. package/dist/chunk-D3FDISIC.js +2 -0
  67. package/dist/chunk-D3NX5XIE.js +3 -0
  68. package/dist/chunk-DA7RPPDF.js +3 -0
  69. package/dist/chunk-DDMC3FON.js +3 -0
  70. package/dist/chunk-DIO3FUSG.js +2 -0
  71. package/dist/chunk-DJ2NNSUK.js +3 -0
  72. package/dist/chunk-DKYQIM3C.js +18 -0
  73. package/dist/{chunk-OHIV323X.js → chunk-DOOEL2IV.js} +2 -2
  74. package/dist/chunk-DVFP6PZI.js +2 -0
  75. package/dist/chunk-E3FDPXZK.js +2 -0
  76. package/dist/chunk-E7YNJLCB.js +2 -0
  77. package/dist/chunk-EFGW5JPH.js +2 -0
  78. package/dist/chunk-EJVTR244.js +13 -0
  79. package/dist/chunk-EOV7RTRZ.js +2 -0
  80. package/dist/chunk-ETOIKRHO.js +2 -0
  81. package/dist/chunk-EYK3ZAO2.js +3 -0
  82. package/dist/chunk-F2V2LPET.js +52 -0
  83. package/dist/chunk-F4LUHJTF.js +2 -0
  84. package/dist/chunk-F4PUT6IT.js +2 -0
  85. package/dist/chunk-F56GCXXS.js +5 -0
  86. package/dist/chunk-FC2EVQRM.js +2 -0
  87. package/dist/chunk-FL7NBMHP.js +3 -0
  88. package/dist/chunk-FMRN2TRL.js +3 -0
  89. package/dist/chunk-FVULPZDF.js +20 -0
  90. package/dist/chunk-GCKCF5FL.js +43 -0
  91. package/dist/chunk-GH2PYF46.js +2 -0
  92. package/dist/chunk-GHJAGXIP.js +2 -0
  93. package/dist/{chunk-2GJSD5GY.js → chunk-GMVSHUKZ.js} +2 -2
  94. package/dist/chunk-GS6KDO4R.js +2 -0
  95. package/dist/chunk-GUUBXNN7.js +2 -0
  96. package/dist/chunk-GVWX5T43.js +80 -0
  97. package/dist/chunk-GZKFETP5.js +2 -0
  98. package/dist/chunk-H4EQHO6J.js +9 -0
  99. package/dist/chunk-H73WY2RM.js +2 -0
  100. package/dist/chunk-H75GSPRV.js +60 -0
  101. package/dist/chunk-HDR3AHSV.js +61 -0
  102. package/dist/chunk-HQBSL74Y.js +2 -0
  103. package/dist/chunk-HRRFKWPZ.js +2 -0
  104. package/dist/chunk-HXENDJC6.js +2 -0
  105. package/dist/chunk-IIBAZNSW.js +21 -0
  106. package/dist/chunk-INLMWEUU.js +12 -0
  107. package/dist/chunk-IWQPAF4F.js +2 -0
  108. package/dist/chunk-IZJ6YUKP.js +35 -0
  109. package/dist/chunk-J2TMAIN5.js +60 -0
  110. package/dist/chunk-J5FJMODQ.js +142 -0
  111. package/dist/chunk-J7HZPIO3.js +2 -0
  112. package/dist/chunk-JEVRKFRL.js +2 -0
  113. package/dist/chunk-JFXSGAEB.js +30 -0
  114. package/dist/chunk-JVRTHGFS.js +3 -0
  115. package/dist/chunk-JYWEX7RR.js +360 -0
  116. package/dist/chunk-K3YL22N6.js +2 -0
  117. package/dist/chunk-K4CN7GXK.js +12 -0
  118. package/dist/chunk-K5TBVXU4.js +30 -0
  119. package/dist/chunk-KDDIE2DP.js +9 -0
  120. package/dist/chunk-KHWRRPV4.js +2 -0
  121. package/dist/chunk-KI6NBKDY.js +14 -0
  122. package/dist/chunk-KU3QRSTH.js +2 -0
  123. package/dist/chunk-KZBJWZJB.js +2 -0
  124. package/dist/chunk-L7GFM3NP.js +3 -0
  125. package/dist/chunk-LMO6PK3V.js +35 -0
  126. package/dist/chunk-LN4YXJJU.js +2 -0
  127. package/dist/chunk-LOVIZBJ4.js +43 -0
  128. package/dist/chunk-LPCRK4A2.js +11 -0
  129. package/dist/chunk-MMHZKBFA.js +2 -0
  130. package/dist/{chunk-A4WEAK35.js → chunk-MOQQBQRD.js} +2 -2
  131. package/dist/chunk-N2WN6I3L.js +2 -0
  132. package/dist/chunk-N3ORQT7L.js +2 -0
  133. package/dist/chunk-NAZ3RAIW.js +2 -0
  134. package/dist/chunk-NDUNO5JQ.js +2 -0
  135. package/dist/chunk-NEIWRNAZ.js +4 -0
  136. package/dist/chunk-NJJMVD65.js +2 -0
  137. package/dist/chunk-NLOQOBXI.js +20 -0
  138. package/dist/chunk-NOLZOVCU.js +2 -0
  139. package/dist/chunk-NOWINRRN.js +2 -0
  140. package/dist/chunk-NZAXKGRL.js +16 -0
  141. package/dist/chunk-O2C4UILI.js +2 -0
  142. package/dist/chunk-O3RHA6ZT.js +3 -0
  143. package/dist/chunk-O4UZSPPI.js +3 -0
  144. package/dist/chunk-OGFV2BUX.js +2 -0
  145. package/dist/chunk-OZCJXZK6.js +499 -0
  146. package/dist/chunk-P6ODM7BY.js +2 -0
  147. package/dist/{chunk-GHNPACNP.js → chunk-PAVGPRHJ.js} +2 -2
  148. package/dist/chunk-PH52RA7D.js +2 -0
  149. package/dist/chunk-PKN354TH.js +3 -0
  150. package/dist/chunk-PWOASWEG.js +11 -0
  151. package/dist/chunk-QIWXRW72.js +2 -0
  152. package/dist/chunk-QJRMOK5N.js +2 -0
  153. package/dist/{chunk-YXPUP5G2.js → chunk-QOIXNWQR.js} +2 -2
  154. package/dist/chunk-QXEUDXBT.js +3 -0
  155. package/dist/chunk-QYUVVBMR.js +6 -0
  156. package/dist/chunk-QZ7KQZRN.js +2 -0
  157. package/dist/chunk-R6LQBUDH.js +2 -0
  158. package/dist/chunk-RBS42E55.js +20 -0
  159. package/dist/chunk-RSJKPCFX.js +26 -0
  160. package/dist/chunk-S6CZA3MV.js +2 -0
  161. package/dist/chunk-STMVAHJP.js +2 -0
  162. package/dist/chunk-SYVPTTVW.js +2 -0
  163. package/dist/chunk-T6DK3ZP7.js +2 -0
  164. package/dist/chunk-TKD34PHN.js +4 -0
  165. package/dist/chunk-TNNQFH7W.js +2 -0
  166. package/dist/chunk-TNV7SSUF.js +2 -0
  167. package/dist/chunk-TO7ZR3EH.js +8 -0
  168. package/dist/chunk-TOU3CHK4.js +2 -0
  169. package/dist/chunk-TRBI4UKT.js +2 -0
  170. package/dist/chunk-TZCVNCAN.js +4 -0
  171. package/dist/chunk-U4LZA5LL.js +3 -0
  172. package/dist/chunk-U5RIG3JP.js +3 -0
  173. package/dist/chunk-UP5KXN2I.js +2 -0
  174. package/dist/chunk-UQFR3NDH.js +5 -0
  175. package/dist/chunk-UXYXF7GV.js +2 -0
  176. package/dist/chunk-VB3GOKOS.js +2 -0
  177. package/dist/{chunk-4FR6GQIT.js → chunk-VF5JZICY.js} +2 -2
  178. package/dist/chunk-VTY3VK6E.js +2 -0
  179. package/dist/chunk-VX2O4RIS.js +2 -0
  180. package/dist/chunk-WKPV2TDZ.js +2 -0
  181. package/dist/chunk-WOFQ5DTB.js +2 -0
  182. package/dist/chunk-WS4C6TCK.js +2 -0
  183. package/dist/chunk-WXU3DGPU.js +2 -0
  184. package/dist/{chunk-ATXPTSEI.js → chunk-X6RMKHJQ.js} +7 -7
  185. package/dist/{chunk-44IETFOU.js → chunk-XHMN6ZX7.js} +2 -2
  186. package/dist/chunk-XHTVFLWW.js +2 -0
  187. package/dist/chunk-XKIDJCIK.js +2 -0
  188. package/dist/chunk-XTYTYZPT.js +2 -0
  189. package/dist/chunk-Y2JHHTTA.js +2 -0
  190. package/dist/chunk-YGVRMGYN.js +4 -0
  191. package/dist/chunk-YNQCGEQE.js +2 -0
  192. package/dist/chunk-YOQVEXVE.js +14 -0
  193. package/dist/chunk-YRT2WLYY.js +2 -0
  194. package/dist/chunk-YTAP5Y2G.js +2 -0
  195. package/dist/chunk-YTYWI7VB.js +2 -0
  196. package/dist/chunk-YULZRALL.js +2 -0
  197. package/dist/chunk-Z33WQG4Q.js +2 -0
  198. package/dist/chunk-ZGTYGDMF.js +16 -0
  199. package/dist/chunk-ZHMRSZFD.js +43 -0
  200. package/dist/chunk-ZHSP366W.js +10 -0
  201. package/dist/chunk-ZIBYCYKK.js +7 -0
  202. package/dist/chunk-ZLADLUE6.js +3 -0
  203. package/dist/chunk-ZO4YXUT6.js +4 -0
  204. package/dist/{chunk-MZPXPSUJ.js → chunk-ZR4HBC2H.js} +2 -2
  205. package/dist/cli-main.js +6 -6
  206. package/dist/cli.js +1 -1
  207. package/dist/{code-B17qEMbt.d.ts → code-BNyrCF3_.d.ts} +3 -2
  208. package/dist/code-IL5WH3NZ.js +2 -0
  209. package/dist/code-result-json-ANTBEDFP.js +4 -0
  210. package/dist/command-descriptors-HEEMDHTU.js +222 -0
  211. package/dist/deps-EOWFC6FD.js +2 -0
  212. package/dist/direct-navigation-Y5B6OSIQ.js +3 -0
  213. package/dist/{exploration-topology-BG4v30HZ.d.ts → exploration-topology-CSgEyAz-.d.ts} +3 -1
  214. package/dist/files-K4AI3JUM.js +2 -0
  215. package/dist/{health-BI2a9WPy.d.ts → health-BtfmNrfa.d.ts} +5 -79
  216. package/dist/hierarchy-6W5NDIFI.js +2 -0
  217. package/dist/imports-WH365QY4.js +2 -0
  218. package/dist/index.d.ts +13 -1
  219. package/dist/index.js +1 -1
  220. package/dist/members-K3PHMF5S.js +2 -0
  221. package/dist/methods-E7KVMBX4.js +2 -0
  222. package/dist/output-continuation-command-BJSY67SN.js +3 -0
  223. package/dist/output-pagination-UZJ5ACIX.js +24 -0
  224. package/dist/postinstall.js +1 -1
  225. package/dist/project-reindex-EP24WT4X.js +3 -0
  226. package/dist/queries/affected.js +1 -1
  227. package/dist/queries/architecture.d.ts +15 -4
  228. package/dist/queries/architecture.js +1 -1
  229. package/dist/queries/bottlenecks.js +1 -1
  230. package/dist/queries/by-kind.js +1 -1
  231. package/dist/queries/call-graph.d.ts +1 -1
  232. package/dist/queries/call-graph.js +1 -1
  233. package/dist/queries/change-surface.d.ts +1 -0
  234. package/dist/queries/change-surface.js +1 -1
  235. package/dist/queries/cleanup-plan.d.ts +3 -3
  236. package/dist/queries/cleanup-plan.js +1 -1
  237. package/dist/queries/co-change.js +1 -1
  238. package/dist/queries/code.d.ts +1 -1
  239. package/dist/queries/code.js +1 -1
  240. package/dist/queries/complexity.d.ts +6 -3
  241. package/dist/queries/complexity.js +1 -1
  242. package/dist/queries/context.d.ts +1 -7
  243. package/dist/queries/context.js +1 -1
  244. package/dist/queries/coupling.js +1 -1
  245. package/dist/queries/cycles.js +1 -1
  246. package/dist/queries/dead.js +1 -1
  247. package/dist/queries/decorative-checkers.js +1 -1
  248. package/dist/queries/dependence-slice.d.ts +46 -22
  249. package/dist/queries/dependence-slice.js +1 -1
  250. package/dist/queries/dependency-depth.d.ts +1 -7
  251. package/dist/queries/dependency-depth.js +1 -1
  252. package/dist/queries/deps.js +1 -1
  253. package/dist/queries/diff-impact.d.ts +3 -1
  254. package/dist/queries/diff-impact.js +1 -1
  255. package/dist/queries/doc-drift.js +1 -1
  256. package/dist/queries/drift.d.ts +1 -1
  257. package/dist/queries/drift.js +1 -1
  258. package/dist/queries/duplicate-bodies.d.ts +1 -1
  259. package/dist/queries/duplicate-bodies.js +1 -1
  260. package/dist/queries/entry-map.d.ts +2 -4
  261. package/dist/queries/entry-map.js +1 -1
  262. package/dist/queries/evidence.d.ts +121 -61
  263. package/dist/queries/evidence.js +1 -1
  264. package/dist/queries/fan.js +1 -1
  265. package/dist/queries/files.js +1 -1
  266. package/dist/queries/health.d.ts +1 -1
  267. package/dist/queries/health.js +1 -1
  268. package/dist/queries/hierarchy.d.ts +2 -2
  269. package/dist/queries/hierarchy.js +1 -1
  270. package/dist/queries/hotspots.d.ts +1 -1
  271. package/dist/queries/hotspots.js +1 -1
  272. package/dist/queries/imports.d.ts +1 -0
  273. package/dist/queries/imports.js +1 -1
  274. package/dist/queries/incomplete-migration.d.ts +3 -3
  275. package/dist/queries/incomplete-migration.js +1 -1
  276. package/dist/queries/index.d.ts +15 -64
  277. package/dist/queries/index.js +1 -1
  278. package/dist/queries/locality-candidates.d.ts +4 -4
  279. package/dist/queries/locality-candidates.js +1 -1
  280. package/dist/queries/members.d.ts +2 -2
  281. package/dist/queries/members.js +1 -1
  282. package/dist/queries/methods.js +1 -1
  283. package/dist/queries/not-implemented.d.ts +2 -6
  284. package/dist/queries/not-implemented.js +1 -1
  285. package/dist/queries/outline.js +1 -1
  286. package/dist/queries/passthrough-candidates.js +1 -1
  287. package/dist/queries/react-component-duplicates.js +1 -1
  288. package/dist/queries/react-hook-candidates.js +1 -1
  289. package/dist/queries/react-large-component-pressure.js +1 -1
  290. package/dist/queries/recent-duplicates.js +1 -1
  291. package/dist/queries/redundant-reexports.d.ts +4 -14
  292. package/dist/queries/redundant-reexports.js +1 -1
  293. package/dist/queries/refs.d.ts +4 -1
  294. package/dist/queries/refs.js +1 -1
  295. package/dist/queries/review.d.ts +188 -0
  296. package/dist/queries/review.js +2 -0
  297. package/dist/queries/similar-files.d.ts +7 -10
  298. package/dist/queries/similar-files.js +1 -1
  299. package/dist/queries/similar-signatures.js +1 -1
  300. package/dist/queries/similar.d.ts +19 -1
  301. package/dist/queries/similar.js +1 -1
  302. package/dist/queries/slice-cohesion.d.ts +205 -0
  303. package/dist/queries/slice-cohesion.js +2 -0
  304. package/dist/queries/source-inspection.d.ts +6 -202
  305. package/dist/queries/source-inspection.js +1 -1
  306. package/dist/queries/source-search.d.ts +2 -3
  307. package/dist/queries/source-search.js +1 -1
  308. package/dist/queries/stats.d.ts +1 -0
  309. package/dist/queries/stats.js +1 -1
  310. package/dist/queries/surface.js +1 -1
  311. package/dist/queries/symbols.js +1 -1
  312. package/dist/queries/system.d.ts +4 -2
  313. package/dist/queries/system.js +1 -1
  314. package/dist/queries/test-quality.d.ts +1 -1
  315. package/dist/queries/test-quality.js +1 -1
  316. package/dist/queries/twin-drift.d.ts +1 -1
  317. package/dist/queries/twin-drift.js +1 -1
  318. package/dist/queries/unused-imports.js +1 -1
  319. package/dist/queries/unused-params.d.ts +3 -15
  320. package/dist/queries/unused-params.js +1 -1
  321. package/dist/queries/vue-component-duplicates.js +1 -1
  322. package/dist/queries/vue-composable-candidates.js +1 -1
  323. package/dist/queries/vue-large-view-pressure.js +1 -1
  324. package/dist/query-service-fastpath.js +5 -5
  325. package/dist/query-service-server.js +4 -4
  326. package/dist/refs-CCBJG7WK.js +2 -0
  327. package/dist/refs-pagination-DRNLVU4S.js +2 -0
  328. package/dist/reindex-worker.js +79 -29
  329. package/dist/reindex.js +45 -45
  330. package/dist/repository-cache-worker.js +2 -0
  331. package/dist/runtime.d.ts +8 -8
  332. package/dist/runtime.js +3 -4
  333. package/dist/rust-semantic-session-server.js +1 -1
  334. package/dist/rust-semantic-session-worker.js +1 -1
  335. package/dist/rust-semantic-worker.js +1 -1
  336. package/dist/service-queries-2WAJI7R6.js +6 -0
  337. package/dist/source-inspection-91U9zdO3.d.ts +341 -0
  338. package/dist/{source-search-types-Dwz8KeuW.d.ts → source-search-types-DWGYNg8M.d.ts} +15 -2
  339. package/dist/stats-G7DIV6VU.js +2 -0
  340. package/dist/surface-IO55UALI.js +2 -0
  341. package/dist/system-ZBMSHJXU.js +2 -0
  342. package/dist/{queries/trace.d.ts → trace-BMjw3prn.d.ts} +1 -18
  343. package/dist/typescript-indexer.js +2 -0
  344. package/dist/typescript-mailbox-worker.js +1 -1
  345. package/dist/watch-server.js +3 -3
  346. package/docs/AGENT_GUIDE.md +19 -128
  347. package/docs/CLI_JSON_OUTPUT.md +21 -17
  348. package/docs/COMMAND_REFERENCE.md +34 -49
  349. package/docs/CURRENT_COMMANDS.md +123 -0
  350. package/docs/DETECTOR_EVIDENCE_CONTRACTS.md +0 -40
  351. package/docs/DETECTOR_GUIDE.md +27 -23
  352. package/docs/PRODUCT_VISION.md +135 -0
  353. package/docs/PROPERTY_TESTING.md +73 -0
  354. package/docs/REVIEW.md +76 -0
  355. package/docs/SKILLS.md +51 -0
  356. package/docs/WINDOWS_SIDECAR_RELEASE.md +12 -3
  357. package/docs/accuracy-audit-checklist.md +34 -0
  358. package/docs/analyzer-inventory.md +2 -2
  359. package/package.json +18 -80
  360. package/scripts/evidence-product-contract.mjs +7 -3
  361. package/scripts/record-review-coverage.mjs +118 -0
  362. package/scripts/scip-windows-provenance.mjs +29 -19
  363. package/skills/scip-architecture-review/SKILL.md +57 -0
  364. package/skills/scip-architecture-review/agents/openai.yaml +4 -0
  365. package/skills/scip-architecture-review/references/design-checks.md +17 -0
  366. package/skills/scip-explore/SKILL.md +15 -59
  367. package/skills/scip-explore/agents/openai.yaml +3 -3
  368. package/skills/scip-explore/references/external-evidence.md +2 -2
  369. package/skills/scip-explore/references/information-model.md +26 -29
  370. package/skills/scip-explore/scripts/capture-evidence.mjs +68 -34
  371. package/skills/scip-integrity-audit/SKILL.md +53 -181
  372. package/skills/scip-integrity-audit/agents/openai.yaml +3 -3
  373. package/skills/scip-integrity-audit/references/integrity-probes.md +27 -0
  374. package/skills/scip-plan/SKILL.md +39 -65
  375. package/skills/scip-plan/agents/openai.yaml +2 -2
  376. package/skills/scip-query/SKILL.md +28 -81
  377. package/skills/scip-query/agents/openai.yaml +2 -2
  378. package/skills/scip-query/references/command-guide.md +169 -0
  379. package/skills/scip-setup/SKILL.md +4 -2
  380. package/skills/scip-setup/agents/openai.yaml +3 -3
  381. package/dist/by-kind-H3P6BR5G.js +0 -2
  382. package/dist/call-graph-VTG2CUOQ.js +0 -2
  383. package/dist/chunk-26CT72HM.js +0 -2
  384. package/dist/chunk-2BMSSRBH.js +0 -2
  385. package/dist/chunk-2M2LSIMY.js +0 -7
  386. package/dist/chunk-2N6WBNDC.js +0 -29
  387. package/dist/chunk-2OOY75BW.js +0 -2
  388. package/dist/chunk-2USA3S3P.js +0 -3
  389. package/dist/chunk-2VAHDDLM.js +0 -133
  390. package/dist/chunk-2XWIUW5Z.js +0 -455
  391. package/dist/chunk-35NLDRZC.js +0 -2
  392. package/dist/chunk-3AF4TUFK.js +0 -3
  393. package/dist/chunk-3D4BOXW6.js +0 -20
  394. package/dist/chunk-3LO4FST5.js +0 -16
  395. package/dist/chunk-3WTY4LP2.js +0 -3
  396. package/dist/chunk-3Z5AMSK6.js +0 -29
  397. package/dist/chunk-4KBTHJLP.js +0 -2
  398. package/dist/chunk-5BIKR67W.js +0 -2
  399. package/dist/chunk-5PROPLHI.js +0 -2
  400. package/dist/chunk-5V7EPTII.js +0 -2
  401. package/dist/chunk-62LPZCBQ.js +0 -3
  402. package/dist/chunk-64O2JHQA.js +0 -2
  403. package/dist/chunk-6D4F5VWG.js +0 -10
  404. package/dist/chunk-6ERFBC3X.js +0 -3
  405. package/dist/chunk-6MFXCMZC.js +0 -2
  406. package/dist/chunk-6O7FACKB.js +0 -2
  407. package/dist/chunk-6TS3KOXR.js +0 -2
  408. package/dist/chunk-76QOU4PK.js +0 -3
  409. package/dist/chunk-7DUI77BN.js +0 -2
  410. package/dist/chunk-7F45LJKI.js +0 -2
  411. package/dist/chunk-7F7T6DCR.js +0 -2
  412. package/dist/chunk-7H6VHWWJ.js +0 -2
  413. package/dist/chunk-7HXT6YLU.js +0 -5
  414. package/dist/chunk-7KCZELVM.js +0 -2
  415. package/dist/chunk-7R4V5ES6.js +0 -6
  416. package/dist/chunk-7RIRIADH.js +0 -7
  417. package/dist/chunk-7ZLWLOGT.js +0 -2
  418. package/dist/chunk-AADQLOQ4.js +0 -38
  419. package/dist/chunk-AN76MGUE.js +0 -2
  420. package/dist/chunk-ANLNLY66.js +0 -2
  421. package/dist/chunk-AX7IDVFT.js +0 -2
  422. package/dist/chunk-B3X6KU75.js +0 -2
  423. package/dist/chunk-B7MPDEAK.js +0 -3
  424. package/dist/chunk-BBB5FBX4.js +0 -2
  425. package/dist/chunk-BJT7LSPK.js +0 -3
  426. package/dist/chunk-BJWFVAA5.js +0 -2
  427. package/dist/chunk-BKVWUP7Y.js +0 -2
  428. package/dist/chunk-BKZYTLGE.js +0 -35
  429. package/dist/chunk-BL6DCHQP.js +0 -2
  430. package/dist/chunk-BOW7SSQH.js +0 -43
  431. package/dist/chunk-C4RHHCKL.js +0 -7
  432. package/dist/chunk-C7C6AKAT.js +0 -117
  433. package/dist/chunk-CD6M6LS2.js +0 -16
  434. package/dist/chunk-CFE6PSG6.js +0 -2
  435. package/dist/chunk-CFNIGQMT.js +0 -2
  436. package/dist/chunk-CKBUBRYD.js +0 -2
  437. package/dist/chunk-CZW5MZ5B.js +0 -2
  438. package/dist/chunk-DBBZ63ZX.js +0 -2
  439. package/dist/chunk-DBN7DMJB.js +0 -18
  440. package/dist/chunk-DUULLZHZ.js +0 -3
  441. package/dist/chunk-DV5Y5NOS.js +0 -2
  442. package/dist/chunk-DZOIKCTM.js +0 -3
  443. package/dist/chunk-E4PKTOL3.js +0 -2
  444. package/dist/chunk-E7QR35ST.js +0 -2
  445. package/dist/chunk-EFSXAINW.js +0 -2
  446. package/dist/chunk-EHVEIEQN.js +0 -18
  447. package/dist/chunk-EHYDXE3Z.js +0 -2
  448. package/dist/chunk-EP63Y6LD.js +0 -2
  449. package/dist/chunk-EPX6NQN6.js +0 -4
  450. package/dist/chunk-ETC674NS.js +0 -5
  451. package/dist/chunk-F5GSBHC6.js +0 -3
  452. package/dist/chunk-FH3DGXC6.js +0 -2
  453. package/dist/chunk-FI7VGOR4.js +0 -16
  454. package/dist/chunk-FJF6VO2P.js +0 -2
  455. package/dist/chunk-FLMTCX5R.js +0 -2
  456. package/dist/chunk-FVFDOIM3.js +0 -2
  457. package/dist/chunk-G2HU5WRN.js +0 -2
  458. package/dist/chunk-G4ALYS4J.js +0 -2
  459. package/dist/chunk-G56I7K4W.js +0 -26
  460. package/dist/chunk-GC4DG2V5.js +0 -2
  461. package/dist/chunk-GG45PK4S.js +0 -4
  462. package/dist/chunk-GINH3YQU.js +0 -20
  463. package/dist/chunk-GTZZVLKJ.js +0 -2
  464. package/dist/chunk-GXXW5ZHH.js +0 -2
  465. package/dist/chunk-H5EXS3HM.js +0 -2
  466. package/dist/chunk-HAXXKRTD.js +0 -4
  467. package/dist/chunk-HEZWBAZY.js +0 -2
  468. package/dist/chunk-HMEWLMML.js +0 -2
  469. package/dist/chunk-HOBOVYPO.js +0 -11
  470. package/dist/chunk-HRFQ6GW5.js +0 -8
  471. package/dist/chunk-HX4X7KG3.js +0 -2
  472. package/dist/chunk-HYT2R7LX.js +0 -4
  473. package/dist/chunk-IKQVBVQL.js +0 -40
  474. package/dist/chunk-IW5XQG5G.js +0 -2
  475. package/dist/chunk-J6GLBBRK.js +0 -4
  476. package/dist/chunk-J7A4PWFX.js +0 -3
  477. package/dist/chunk-JCSAZ35V.js +0 -2
  478. package/dist/chunk-JDU2IV3A.js +0 -2
  479. package/dist/chunk-JFMEXGFE.js +0 -2
  480. package/dist/chunk-JFMI5SGB.js +0 -4
  481. package/dist/chunk-JJP37RGX.js +0 -57
  482. package/dist/chunk-JZ2A7LDM.js +0 -5
  483. package/dist/chunk-KMVGRIO2.js +0 -2
  484. package/dist/chunk-KNLQGXVH.js +0 -80
  485. package/dist/chunk-KVQCECPR.js +0 -2
  486. package/dist/chunk-KXXORBZ2.js +0 -4
  487. package/dist/chunk-L5KYH6U3.js +0 -35
  488. package/dist/chunk-L6XHYJPZ.js +0 -21
  489. package/dist/chunk-L7KTFEAV.js +0 -43
  490. package/dist/chunk-LDXHR5EL.js +0 -23
  491. package/dist/chunk-LEECKFCJ.js +0 -2
  492. package/dist/chunk-MHGDSBFX.js +0 -2
  493. package/dist/chunk-MLQVVDG3.js +0 -74
  494. package/dist/chunk-MOKUWRHO.js +0 -3
  495. package/dist/chunk-MPYAPMNE.js +0 -2
  496. package/dist/chunk-MTDBHTSF.js +0 -2
  497. package/dist/chunk-MV6SPXCR.js +0 -7
  498. package/dist/chunk-MWN53KRN.js +0 -60
  499. package/dist/chunk-MXNGIEPU.js +0 -3
  500. package/dist/chunk-N55KIE46.js +0 -2
  501. package/dist/chunk-NB4D3BNM.js +0 -2
  502. package/dist/chunk-NGKBOT6G.js +0 -23
  503. package/dist/chunk-NJGKXKQF.js +0 -2
  504. package/dist/chunk-NJQISBL4.js +0 -8
  505. package/dist/chunk-NJT3ZEKY.js +0 -16
  506. package/dist/chunk-NKMKZP6A.js +0 -2
  507. package/dist/chunk-NODFZ6ED.js +0 -2
  508. package/dist/chunk-NSM5IEVW.js +0 -2
  509. package/dist/chunk-NTGUVNR2.js +0 -3
  510. package/dist/chunk-NU3KFF2O.js +0 -57
  511. package/dist/chunk-NWLVNU66.js +0 -557
  512. package/dist/chunk-NYKZMCRC.js +0 -4
  513. package/dist/chunk-O6BUXZEH.js +0 -6
  514. package/dist/chunk-ODPDP7A4.js +0 -3
  515. package/dist/chunk-OIAPEKMT.js +0 -3
  516. package/dist/chunk-OIOC5EHF.js +0 -3
  517. package/dist/chunk-ONPPQM4G.js +0 -2
  518. package/dist/chunk-OUHEZBYI.js +0 -2
  519. package/dist/chunk-OVGYW7UD.js +0 -29
  520. package/dist/chunk-OYKU4B3Y.js +0 -2
  521. package/dist/chunk-POBJ6FR2.js +0 -5
  522. package/dist/chunk-PSZPMMWN.js +0 -2
  523. package/dist/chunk-PXTRBKRK.js +0 -3
  524. package/dist/chunk-Q5JRIHT3.js +0 -4
  525. package/dist/chunk-Q7ATHARX.js +0 -2
  526. package/dist/chunk-Q7CSKIDM.js +0 -5
  527. package/dist/chunk-QBQE7ZJ5.js +0 -3
  528. package/dist/chunk-QH22UIXP.js +0 -5
  529. package/dist/chunk-QXCKQTKR.js +0 -60
  530. package/dist/chunk-RBAD4GJ2.js +0 -13
  531. package/dist/chunk-RMDPFPNW.js +0 -2
  532. package/dist/chunk-ROPJDEJZ.js +0 -4
  533. package/dist/chunk-RVZC6TJE.js +0 -2
  534. package/dist/chunk-S4QZBKSR.js +0 -3
  535. package/dist/chunk-SCPMZ73U.js +0 -2
  536. package/dist/chunk-SIAP5RGI.js +0 -73
  537. package/dist/chunk-SIX4RFR3.js +0 -3
  538. package/dist/chunk-SKKXTABJ.js +0 -16
  539. package/dist/chunk-SSRFUQBD.js +0 -2
  540. package/dist/chunk-SYVJEEUJ.js +0 -3
  541. package/dist/chunk-T3CZAZSI.js +0 -8
  542. package/dist/chunk-T6DWDI5E.js +0 -3
  543. package/dist/chunk-T6HRIROJ.js +0 -7
  544. package/dist/chunk-TAA7HXHE.js +0 -2
  545. package/dist/chunk-TJ2JQYT3.js +0 -2
  546. package/dist/chunk-TULNMD5T.js +0 -368
  547. package/dist/chunk-U2FPY5XA.js +0 -3
  548. package/dist/chunk-U3SXIMII.js +0 -38
  549. package/dist/chunk-U6KCHXJ4.js +0 -2
  550. package/dist/chunk-UH3XSKS5.js +0 -9
  551. package/dist/chunk-UIFUZVCC.js +0 -2
  552. package/dist/chunk-UXKURIVI.js +0 -2
  553. package/dist/chunk-V2RBODHL.js +0 -2
  554. package/dist/chunk-VBKUWB6N.js +0 -2
  555. package/dist/chunk-VBV6ALJE.js +0 -2
  556. package/dist/chunk-VDGFWCQV.js +0 -2
  557. package/dist/chunk-VDSDOEWF.js +0 -2
  558. package/dist/chunk-VZPWVCLN.js +0 -20
  559. package/dist/chunk-WDSFQDPN.js +0 -2
  560. package/dist/chunk-WFA35BGR.js +0 -7
  561. package/dist/chunk-WLMP3OCW.js +0 -2
  562. package/dist/chunk-WSA52GOR.js +0 -2
  563. package/dist/chunk-WYPL7GF7.js +0 -2
  564. package/dist/chunk-X3YVZAKZ.js +0 -5
  565. package/dist/chunk-X6OGVFIT.js +0 -2
  566. package/dist/chunk-XDAUYDFT.js +0 -2
  567. package/dist/chunk-XKXTR6ZI.js +0 -9
  568. package/dist/chunk-Y5DFAW5W.js +0 -4
  569. package/dist/chunk-YSYPDRD5.js +0 -3
  570. package/dist/chunk-ZFVPWH62.js +0 -5
  571. package/dist/chunk-ZGIHTH27.js +0 -2
  572. package/dist/chunk-ZGIQN2SX.js +0 -2
  573. package/dist/chunk-ZHG4WAHR.js +0 -12
  574. package/dist/chunk-ZKB2XUEN.js +0 -4
  575. package/dist/chunk-ZLMXIQLC.js +0 -21
  576. package/dist/chunk-ZMCQIHI4.js +0 -2
  577. package/dist/code-TAVIKWJI.js +0 -2
  578. package/dist/code-result-json-5FEFQCAQ.js +0 -2
  579. package/dist/command-descriptors-7BKH53Y3.js +0 -343
  580. package/dist/dataflow-GFBTVDH3.js +0 -2
  581. package/dist/dependence-slice-GWGQCODG.js +0 -2
  582. package/dist/deps-4QHVDPYA.js +0 -2
  583. package/dist/direct-navigation-4UBC6HNW.js +0 -3
  584. package/dist/entry-map-QCTF4RVY.js +0 -2
  585. package/dist/files-M2UBF5HJ.js +0 -2
  586. package/dist/graph-evidence-Bjyky2V4.d.ts +0 -126
  587. package/dist/hierarchy-2UIHRLW4.js +0 -2
  588. package/dist/imports-WIE3YZOB.js +0 -2
  589. package/dist/members-YKD636DA.js +0 -2
  590. package/dist/methods-VDF4IMYG.js +0 -2
  591. package/dist/next-anchor-candidates-BwMczMvX.d.ts +0 -90
  592. package/dist/output-continuation-command-4UMDOOLO.js +0 -3
  593. package/dist/output-pagination-2GME6OPY.js +0 -19
  594. package/dist/project-reindex-XEQTRCV5.js +0 -3
  595. package/dist/queries/anchors.d.ts +0 -123
  596. package/dist/queries/anchors.js +0 -2
  597. package/dist/queries/complexity-hotspots.d.ts +0 -40
  598. package/dist/queries/complexity-hotspots.js +0 -2
  599. package/dist/queries/convergence.d.ts +0 -33
  600. package/dist/queries/convergence.js +0 -2
  601. package/dist/queries/dataflow.d.ts +0 -77
  602. package/dist/queries/dataflow.js +0 -2
  603. package/dist/queries/deep-chains.d.ts +0 -5
  604. package/dist/queries/deep-chains.js +0 -2
  605. package/dist/queries/extract-candidates.d.ts +0 -79
  606. package/dist/queries/extract-candidates.js +0 -2
  607. package/dist/queries/isolated.d.ts +0 -24
  608. package/dist/queries/isolated.js +0 -2
  609. package/dist/queries/plan-context.d.ts +0 -33
  610. package/dist/queries/plan-context.js +0 -2
  611. package/dist/queries/reference-neighborhood.d.ts +0 -4
  612. package/dist/queries/reference-neighborhood.js +0 -2
  613. package/dist/queries/reference-reachability.d.ts +0 -48
  614. package/dist/queries/reference-reachability.js +0 -2
  615. package/dist/queries/self-audit.d.ts +0 -69
  616. package/dist/queries/self-audit.js +0 -2
  617. package/dist/queries/similar-chains.d.ts +0 -48
  618. package/dist/queries/similar-chains.js +0 -2
  619. package/dist/queries/slice.d.ts +0 -4
  620. package/dist/queries/slice.js +0 -2
  621. package/dist/queries/stale-abstractions.d.ts +0 -72
  622. package/dist/queries/stale-abstractions.js +0 -2
  623. package/dist/queries/system-map.d.ts +0 -449
  624. package/dist/queries/system-map.js +0 -2
  625. package/dist/queries/trace.js +0 -2
  626. package/dist/queries/twin-ab.d.ts +0 -66
  627. package/dist/queries/twin-ab.js +0 -2
  628. package/dist/queries/value-flow.d.ts +0 -43
  629. package/dist/queries/value-flow.js +0 -2
  630. package/dist/queries/wrapper-candidates.d.ts +0 -49
  631. package/dist/queries/wrapper-candidates.js +0 -2
  632. package/dist/refs-JNK5CLM7.js +0 -2
  633. package/dist/refs-pagination-6BLRYGMV.js +0 -2
  634. package/dist/slice-PHPVNCWX.js +0 -2
  635. package/dist/source-snippet-_wrcgmZc.d.ts +0 -15
  636. package/dist/stats-OOJ74B32.js +0 -2
  637. package/dist/surface-MQX5MPIV.js +0 -2
  638. package/dist/symbol-resolution-DBLVXLBC.js +0 -2
  639. package/dist/system-JOPKV4OG.js +0 -2
  640. package/dist/trace-I2P2YFH4.js +0 -2
  641. package/dist/value-flow-JJVMF7NP.js +0 -2
  642. package/skills/concrete-plan/SKILL.md +0 -8
  643. package/skills/concrete-plan/agents/openai.yaml +0 -4
  644. package/skills/conductor/SKILL.md +0 -110
  645. package/skills/conductor/agents/openai.yaml +0 -4
  646. package/skills/principal-maintainability-review/SKILL.md +0 -273
  647. package/skills/principal-maintainability-review/agents/openai.yaml +0 -4
  648. package/skills/scip-calibrate/SKILL.md +0 -102
  649. package/skills/scip-calibrate/agents/openai.yaml +0 -4
  650. package/skills/scip-claim-audit/SKILL.md +0 -113
  651. package/skills/scip-claim-audit/agents/openai.yaml +0 -4
  652. package/skills/scip-probe-reachability/SKILL.md +0 -93
  653. package/skills/scip-probe-reachability/agents/openai.yaml +0 -4
  654. package/skills/scip-root-cause/SKILL.md +0 -160
  655. package/skills/scip-root-cause/agents/openai.yaml +0 -4
  656. package/skills/scip-system-compression/SKILL.md +0 -252
  657. package/skills/scip-system-compression/agents/openai.yaml +0 -4
  658. package/skills/scip-system-compression/references/compression-atlas.md +0 -116
  659. package/skills/scip-system-compression/references/compression-patterns.md +0 -87
  660. package/skills/scip-twin-drift/SKILL.md +0 -109
  661. package/skills/scip-twin-drift/agents/openai.yaml +0 -4
@@ -1,6 +1,6 @@
1
- import{A as Ie,B as st,C as we,G as at,a as Ze,b as et,c as q,d as I,f as tt,j as O,k as nt,l as xe,m as ie,n as _,o as B,p as f,q as oe,r as d,s as rt,t as it,u as k,v as ot,w as j,x as ee,y as G,z as V}from"./chunk-UH3XSKS5.js";import{createHash as Ds}from"crypto";import{createRequire as Un}from"module";var Hn=Un(import.meta.url),$=Jn().version;function Jn(){for(let t of["../package.json","../../package.json"])try{return Hn(t)}catch{}return{version:"0.0.0"}}import{existsSync as bi,statSync as Si}from"fs";import{join as vi}from"path";import{createHash as ft,randomUUID as zn}from"crypto";import{chmodSync as yt,existsSync as ae,linkSync as Xn,lstatSync as Pe,readdirSync as mt,realpathSync as T,unlinkSync as Zn,writeSync as er}from"fs";import{homedir as tr}from"os";import{basename as Vs,dirname as Ce,isAbsolute as dt,join as E,resolve as Ee}from"path";import{isAbsolute as ct,relative as Kn}from"path";var C=class extends Error{constructor(n,r){super(`refusing unsafe project file path ${JSON.stringify(n)} (${r})`);this.relativePath=n;this.reason=r;this.name="UnsafeProjectPathError"}relativePath;reason;code="SCIP_QUERY_UNSAFE_PROJECT_PATH"};function Yn(t){return t.replace(/\\/g,"/").replace(/^\.\//,"")}function ke(t,e){let n=Kn(t,e);return n===""||!n.startsWith("..")&&!ct(n)}function ut(t){if(!t)throw new C(t,"empty-path");if(t.includes("\0"))throw new C(t,"nul-byte");if(ct(t)||/^[A-Za-z]:/.test(t)||t.startsWith("//")||t.startsWith("\\\\"))throw new C(t,"absolute-path");let e=Yn(t);if(e.split("/").some(r=>r===".."))throw new C(t,"parent-traversal");if(!e||e===".")throw new C(t,"empty-path");return e}var gt=1,ue=".scip-query-cache-owner.json",nr=16*1024,ht=Object.freeze({...xe,randomToken:()=>zn(),linkFile:(t,e)=>Xn(t,e),removeFile:t=>Zn(t),writeFile:(t,e,n,r)=>er(t,e,n,r)});function se(t,e){return Object.assign(new Error(`refusing unsafe project dbPath ${JSON.stringify(t)} (${e}); use a repository-relative directory that remains inside the checkout`),{name:"UnsafeCachePathError",code:"SCIP_QUERY_UNSAFE_CACHE_PATH",configuredPath:t,reason:e})}function D(t,e){return Object.assign(new Error(`refusing unowned cache directory ${JSON.stringify(t)} (${e}); move unrelated data elsewhere or choose a new empty dbPath`),{name:"CacheOwnershipError",code:"SCIP_QUERY_CACHE_OWNERSHIP",cacheDir:t,reason:e})}function rr(t,e){let n=T(t);return ar(n,ir(n,e))}function ir(t,e){let n=T(t),r=process.env.SCIP_QUERY_CACHE_DIR;return r?Ee(r):e?.dbPath?ur(n,e.dbPath):sr(n)}function or(){let t=process.env.XDG_CACHE_HOME;return E(t||E(tr(),".cache"),"scip-query")}function sr(t){let e=Ee(t);try{e=T(e)}catch{}let n=ft("sha256").update(e).digest("hex").slice(0,12);return E(or(),"projects",n)}function bt(t,e){let n=rr(t,e);return{cacheDir:n,dbPath:E(n,"index.db"),indexPath:E(n,"index.scip"),metaPath:E(n,"meta.json")}}function ar(t,e,n=ht){return cr(t,e,n).cacheDir}function cr(t,e,n=ht){let r=T(t),i=ae(e)?"synced":gr(e,n),o=T(e),s=E(o,ue);if(ae(s))return lt(r,o),St(s),ce(o),{kind:"existing",cacheDir:o};pt(o),yr(o),pt(o);let c=`${JSON.stringify({schemaVersion:gt,canonicalProjectRoot:r,canonicalCacheDir:o,creatorVersion:$},null,2)}
2
- `;try{let u=hr(s,c,n),l=B(i,u);return{kind:"published",cacheDir:o,achievedDurability:l==="synced"?"directory-durable":"file-flushed",directorySync:l}}catch(u){if(br(u))return lt(r,o),{kind:"existing",cacheDir:o};throw u}}function lt(t,e){let n=T(t),r=T(e);return lr(r,n,r)}function ur(t,e){let n;try{n=ut(e)}catch(s){throw s instanceof C?se(e,s.reason):s}let r=Ee(t,...n.split("/"));if(r===t||!ke(t,r))throw se(e,"outside-project");let i=dr(r),o=T(i);if(!ke(t,o)&&o!==t)throw se(e,"symlink-escape");return r}function dr(t){let e=t;for(;!ae(e);){let n=Ce(e);if(n===e)throw se(t,"no-existing-ancestor");e=n}return e}function lr(t,e,n){let r=E(t,ue);if(!ae(r)||Pe(r).isSymbolicLink())throw D(t,"missing regular ownership record");let i=Pe(r);if(!i.isFile()||i.size>nr)throw D(t,"invalid ownership record file");let o=I(r,"cache ownership record"),s=pr(o,t);if(e!==void 0&&s.canonicalProjectRoot!==e)throw D(t,"ownership record belongs to a different project");if(s.canonicalCacheDir!==n)throw D(t,"ownership record names a different cache directory");return{record:s,ownerSha256:ft("sha256").update(o).digest("hex"),physicalCacheDir:t}}function pr(t,e){try{let n=JSON.parse(t);if(n.schemaVersion!==gt||typeof n.canonicalProjectRoot!="string"||typeof n.canonicalCacheDir!="string"||typeof n.creatorVersion!="string"||!dt(n.canonicalProjectRoot)||!dt(n.canonicalCacheDir))throw new Error("invalid fields");return n}catch(n){throw D(e,`malformed ownership record: ${n instanceof Error?n.message:String(n)}`)}}function pt(t){let e=mt(t).filter(n=>n!==ue&&!fr(n));if(e.length>0)throw D(t,`unrecognized existing entries: ${e.slice(0,3).join(", ")}`)}function fr(t){return t.startsWith(`${ue}.tmp-`)||t.startsWith("git-worktree-context.json.tmp-")||[".scipquery-generations","affected-shadow-latest.json","affected-shadow.jsonl","agent-hooks","augment-vue-meta.json","cache-lifecycle.lock","evidence.db","evidence.db-shm","evidence.db-wal","health-report-cache.json","git-worktree-context.json","index.db","index.db-shm","index.db-wal","index.lock","index.scip","language-indexes","meta.json","reindex-activity.jsonl","shared-cache.json","typescript-index","typescript-scip-fragments","typescript-scip-overlays","typescript-semantic","typescript-shard-costs.json","watch-activity.json","watch-refresh-requests","watch-state.json","watch.lock"].includes(t)?!0:/^(?:reindex-|rust-|typescript-)/.test(t)}function yr(t){for(let e of mt(t)){let n=E(t,e);try{let r=Pe(n);if(r.isSymbolicLink())throw D(t,`legacy cache entry ${e} is a symlink`);if(r.isDirectory())ce(n);else if(r.isFile())St(n);else throw D(t,`legacy cache entry ${e} is not a file or directory`)}catch(r){if(mr(r))continue;throw r}}ce(t)}function mr(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function gr(t,e=xe){let n=ie(t,e);return ce(t),n}function hr(t,e,n){let r=`${t}.tmp-${process.pid}-${n.randomToken()}`,i,o=!1;try{i=n.openFile(r,"wx",384),o=!0,nt(i,Buffer.from(e),n,"cache ownership record"),n.syncFile(i),n.closeFile(i),i=void 0,n.linkFile(r,t);let s=_(Ce(t),n);return n.removeFile(r),o=!1,B(s,_(Ce(t),n))}finally{if(i!==void 0)try{n.closeFile(i)}catch{}if(o)try{n.removeFile(r)}catch{}}}function ce(t){process.platform!=="win32"&&yt(t,448)}function St(t){process.platform!=="win32"&&yt(t,384)}function br(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EEXIST"}import{createHash as Pr,randomUUID as Cr}from"crypto";import{existsSync as Er,mkdirSync as sa,readdirSync as aa,rmSync as ca,statSync as Ar}from"fs";import{basename as da,dirname as It,join as Oe}from"path";function vt(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.path=="string"&&typeof e.size=="number"&&Number.isFinite(e.size)&&typeof e.hash=="string"&&(e.semanticHash===void 0||typeof e.semanticHash=="string")}var Q=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var Ae=2,U=3;var Me=new Set(Q);function Rt(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(s){return{kind:"malformed",reason:`invalid JSON: ${kr(s)}`}}if(!f(e))return{kind:"malformed",reason:"metadata must be a JSON object"};let n=e.version;if(!Number.isInteger(n))return{kind:"malformed",reason:"version must be an integer"};if(n!==Ae&&n!==U)return{kind:"unsupported",version:n,direction:n<Ae?"older":"future"};let r=vr(e,n);if(r)return{kind:"malformed",reason:r};let i=e,o={metadata:i,capabilities:Sr(i)};return n===Ae?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function xt(t){if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.stableGenerationIdentity)return null;let e=t.metadata;return JSON.stringify({version:e.version,status:e.status,updatedAt:e.updatedAt,fingerprint:e.fingerprint,indexedLanguages:e.indexedLanguages,scipCompanion:e.scipCompanion,sqliteLayoutVersion:e.version===U?e.sqliteLayoutVersion:void 0})}function Sr(t){let e=t.fingerprint!==void 0,n=f(t.fingerprint),r=t.indexedLanguages!==void 0,i=t.status==="complete",o=t.version===U?t:null;return{usableForQuery:r,usableForEvidenceCache:e,publishableGeneration:i&&n&&r,stableGenerationIdentity:i&&e&&typeof t.updatedAt=="string",languageShardReuse:!!o?.languageFingerprints,typescriptProjectShardReuse:!!o?.typescriptProjectShards}}function vr(t,e){if(t.status!=="complete"&&t.status!=="partial")return"status must be complete or partial";if(t.updatedAt!==void 0&&!oe(t.updatedAt))return"updatedAt must be a valid timestamp";for(let n of["requestedLanguages","indexedLanguages"])if(t[n]!==void 0&&!Rr(t[n]))return`${n} must contain unique supported languages`;return t.skipped!==void 0&&!xr(t.skipped)?"skipped must contain supported language/reason pairs":t.scipCompanion!==void 0&&t.scipCompanion!=="current"&&t.scipCompanion!=="deferred"?"scipCompanion must be current or deferred":e===U&&t.sqliteLayoutVersion!==void 0&&(!Number.isSafeInteger(t.sqliteLayoutVersion)||t.sqliteLayoutVersion<1)?"sqliteLayoutVersion must be a positive safe integer":e===U&&t.languageFingerprints!==void 0&&!Ir(t.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":e===U&&t.typescriptProjectShards!==void 0&&!wr(t.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function Rr(t){return!Array.isArray(t)||!t.every(e=>typeof e=="string"&&Me.has(e))?!1:new Set(t).size===t.length}function xr(t){return Array.isArray(t)&&t.every(e=>f(e)&&typeof e.language=="string"&&Me.has(e.language)&&typeof e.reason=="string")}function Ir(t){return f(t)&&Object.entries(t).every(([e,n])=>Me.has(e)&&f(n))}function wr(t){return f(t)&&Object.values(t).every(e=>f(e)&&Array.isArray(e.files)&&e.files.every(vt))}function kr(t){return t instanceof Error?t.message:String(t)}function A(){return performance.now()}var Mr=1;var Or=".scipquery-generations";var ma={pid:process.pid,now:()=>new Date,randomToken:()=>Cr(),isProcessAlive:V,readProcessIdentity:G};function _r(t){return Oe(It(t),Or)}function jr(t){try{let e=JSON.parse(I(Oe(_r(t),"state.json"),"SQLite generation state"));return Fr(e)?e:null}catch{return null}}function wt(t){let e=jr(t);if(e)return e.currentGeneration;try{let n=Oe(It(t),"meta.json"),r=Er(n)?I(n,"reindex metadata"):void 0;return Tr(t,r)}catch{return null}}function Dr(t){return xt(Rt(t))??t}function Tr(t,e){let n=Pr("sha256").update("sqlite-generation-legacy-v1\0");return e!==void 0&&n.update(Dr(e)),n.update(`\0${Nr(t)}`),n.digest("hex")}function Nr(t){let e=Ar(t);return`${e.dev}:${e.ino}:${e.size}:${e.mtimeMs}`}function Fr(t){return t.version===Mr&&typeof t.currentGeneration=="string"&&!!t.currentGeneration&&typeof t.publishedAt=="string"&&Number.isFinite(Date.parse(t.publishedAt))&&(t.artifactSet===void 0||t.artifactSet==="immutable-v1")&&Lr(t.stableMirrors)&&Wr(t.previousGeneration)&&qr(t.publication)}function Lr(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t;return typeof e.databaseFileIdentity=="string"&&!!e.databaseFileIdentity&&(e.indexFileIdentity===void 0||typeof e.indexFileIdentity=="string"&&!!e.indexFileIdentity)}function Wr(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t;return typeof e.generationIdentity=="string"&&!!e.generationIdentity&&typeof e.databasePath=="string"&&!!e.databasePath&&(e.metadataPath===void 0||typeof e.metadataPath=="string"&&!!e.metadataPath)}function qr(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t,n=[e.converterDurationMs,e.affectedDocumentCount,e.changedDocumentCount,e.producerDurationMs,e.materializationDurationMs,e.patchDurationMs].filter(r=>r!==void 0);return(e.mode==="incremental"||e.mode==="full")&&e.validation==="passed"&&e.converterDurationMs!==void 0&&n.every(r=>typeof r=="number"&&Number.isFinite(r)&&r>=0)&&(e.scipCompanion===void 0||e.scipCompanion==="current"||e.scipCompanion==="deferred")&&(e.typescriptOverlayGeneration===void 0||typeof e.typescriptOverlayGeneration=="string"&&!!e.typescriptOverlayGeneration)&&(e.scipCompanion!=="deferred"||!!e.typescriptOverlayGeneration)&&(e.fallbackReason===void 0||typeof e.fallbackReason=="string")}import{existsSync as ti}from"fs";import{randomUUID as Pa}from"crypto";import{isAbsolute as Ea,join as ni,relative as Aa,resolve as Ma}from"path";var L=1,H=2,Br="./node_modules/scip-query/docs/schemas/project-config.schema.json";function kt(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(a){return{kind:"malformed",reason:`invalid JSON: ${a instanceof Error?a.message:String(a)}`}}if(!f(e))return{kind:"malformed",reason:"project config must be a JSON object"};let n=e.schemaVersion;if(n!==void 0&&!Number.isInteger(n))return{kind:"malformed",reason:"schemaVersion must be an integer"};let r=n===void 0?L:n;if(r!==L&&r!==H)return{kind:"unsupported",schemaVersion:r,direction:r<L?"older":"future"};let i=e.$schema;if(i!==void 0&&(typeof i!="string"||i.trim()===""))return{kind:"malformed",reason:"$schema must be a non-empty string when present"};let o=Pt(e),s=r!==H||typeof e.$schema!="string";return r===L?{kind:"legacy",sourceVersion:L,config:o,needsMigration:s}:{kind:"supported",sourceVersion:H,config:o,needsMigration:s}}function Pt(t){let e=t,{$schema:n,schemaVersion:r,...i}=e;return{$schema:typeof n=="string"&&n.trim()!==""?n:Br,schemaVersion:H,...i}}import{createHash as va}from"crypto";var _e=1,Ct=2,Gr=1,Vr=1,$r="sha256";function Et(t){if(!f(t))return{kind:"malformed",reason:"observation receipt must be an object"};let e=t.schemaVersion;if(!Number.isInteger(e))return{kind:"malformed",reason:"observation receipt schemaVersion must be an integer"};if(e===_e)return Ur(t)?{kind:"legacy",schemaVersion:_e,receipt:t}:{kind:"malformed",reason:"observation receipt v1 fields are malformed or contradictory"};if(e===Ct)return Hr(t)?{kind:"supported",schemaVersion:Ct,receipt:t}:{kind:"malformed",reason:"observation receipt v2 facts are malformed or contradictory"};let n=e;return{kind:"unsupported",schemaVersion:n,direction:n<_e?"older":"future"}}function Qr(t,e){return t.schemaVersion===e.schemaVersion&&t.canonicalizationVersion===e.canonicalizationVersion&&t.hashAlgorithm===e.hashAlgorithm&&t.projection.name===e.projection.name&&t.projection.version===e.projection.version}function Ur(t){if(!f(t))return!1;let e=t.index,n=t.worktree;return Mt(t.observedAt)&&k(t.projectIdentity)&&ei(t.authorityKind)&&(e===void 0||f(e)&&k(e.generationIdentity)&&(e.source==="immutable"||e.source==="legacy")&&(e.alignment==="not-certified"||e.alignment==="leased"))&&(n===void 0||f(n)&&k(n.identity)&&typeof n.clean=="boolean"&&(n.headCommit===void 0||k(n.headCommit))&&(n.treeOid===void 0||k(n.treeOid)))&&Zr(t.authorityKind,e,n)}function Hr(t){if(!f(t))return!1;let e=t.facts,n=t.observedSources,r=t.stabilityProofs;if(!Mt(t.observedAt)||!f(e)||!Array.isArray(n)||n.length===0||!n.every(Kr)||!De(n,c=>c.kind)||!Array.isArray(r)||!r.every(Yr)||!De(r,c=>c.source)||r.some(c=>!n.some(u=>u.kind===c.source))||!r.every(c=>Xr(c,e))||["collaborationDomain","repositoryLineage","workspaceInstance","wholeContent"].some(c=>e[c]!==void 0&&!N(e[c])))return!1;let o=e.relevantInputs;if(o!==void 0&&(!Array.isArray(o)||!o.every(Jr)||!De(o,c=>`${c.subject}\0${c.identity.projection.name}`)))return!1;let s=e.index;if(s!==void 0&&(!f(s)||!N(s.generation)||s.inputs!==void 0&&!N(s.inputs)||s.source!=="immutable"&&s.source!=="legacy"))return!1;let a=t.diagnostics;return(a===void 0||f(a)&&(a.clean===void 0||typeof a.clean=="boolean")&&(a.headCommit===void 0||k(a.headCommit))&&(a.treeOid===void 0||k(a.treeOid)))&&zr(e,n)}function N(t){return!f(t)||!f(t.projection)?!1:t.schemaVersion===Gr&&t.canonicalizationVersion===Vr&&t.hashAlgorithm===$r&&k(t.projection.name)&&rt(t.projection.version)&&it(t.digest)}function Jr(t){return f(t)&&k(t.subject)&&N(t.identity)}function Kr(t){return f(t)&&At(t.kind)&&(t.identity===void 0||N(t.identity))}function Yr(t){return f(t)&&At(t.source)&&(t.kind==="immutable"||t.kind==="fixed-snapshot"||t.kind==="bracketed"||t.kind==="not-established"||t.kind==="invalidated")}function zr(t,e){let n=t.index,r=e.find(c=>c.kind==="index-generation");if(r){if(!f(n)||!N(n.generation)||r.identity&&!je(r.identity,n.generation))return!1}else if(n!==void 0)return!1;let i=t.workspaceInstance,o=e.find(c=>c.kind==="live-workspace");if(o?.identity&&(!N(i)||!je(o.identity,i)))return!1;let s=t.wholeContent,a=e.find(c=>c.kind==="repository-snapshot");return!(a?.identity&&(!N(s)||!je(a.identity,s)))}function Xr(t,e){return t.kind==="not-established"||t.kind==="invalidated"?!0:t.source==="index-generation"?t.kind==="immutable"&&f(e.index)&&e.index.source==="immutable":t.source==="repository-snapshot"?t.kind==="fixed-snapshot":t.source==="live-workspace"?t.kind==="bracketed":!1}function je(t,e){return Qr(t,e)&&t.digest===e.digest}function Zr(t,e,n){return t==="index-worktree"?e!==void 0&&n!==void 0:t==="index-only"?e!==void 0&&n===void 0:t==="worktree-only"?e===void 0&&n!==void 0:t==="process-local"&&e===void 0&&n===void 0}function ei(t){return t==="index-worktree"||t==="index-only"||t==="worktree-only"||t==="process-local"}function At(t){return t==="index-generation"||t==="repository-snapshot"||t==="live-workspace"||t==="process"}function Mt(t){return typeof t=="string"&&!Number.isNaN(Date.parse(t))}function De(t,e){return new Set(t.map(e)).size===t.length}var de=".scipquery.json";var Da=15*6e4,Ta={enabled:!0,windowMs:15*6e4,maxRebuilds:2,maxEstimatedWriteBytes:1024*1024*1024};var Na=new Set(Q);function Ot(t){let e=ni(t,de);if(!ti(e))return{};let n;try{n=q(e,{maxBytes:Ze,inputKind:"scip-query project config"})}catch(r){let i=r instanceof Error?r.message:String(r);throw new Error(`unable to read ${de} at ${e}: ${i}`,{cause:r})}return ri(kt(n),e,"read").config}function ri(t,e,n){if(t.kind==="legacy"||t.kind==="supported")return t;if(t.kind==="malformed"){let i=n==="read"?`invalid ${de} at ${e}: ${t.reason}`:`Cannot update ${e}: the latest project config is ${t.reason}.`;throw new Error(`${i} The file was left untouched.`)}let r=n==="read"?`invalid ${de} at ${e}`:`Cannot update ${e}: the latest project config is invalid`;throw new Error(`${r} (unsupported ${t.direction} schemaVersion ${t.schemaVersion}; this scip-query reads legacy v${L} and current v${H}). Upgrade scip-query before retrying; the file was left untouched.`)}import{spawnSync as ii}from"child_process";import{createHash as oi}from"crypto";import{existsSync as si,lstatSync as ai,realpathSync as ci}from"fs";import{dirname as ui,isAbsolute as di,join as li,relative as $a,resolve as pe,sep as Qa}from"path";var _t=Symbol.for("scip-query.project-file-listing-context.v1"),jt=globalThis,Te=jt[_t],Dt=Te&&typeof Te=="object"?Te:{};jt[_t]=Dt;function Tt(){return Dt.sequence??0}var Fe={run(t,e){let n=Lt(t,e);return n.kind==="success"?n.output:void 0},runResult:Lt},pi=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],Wt=["status","--porcelain=v2","--branch","-z","--untracked-files=all"],Ne=/^[0-9a-f]{40,64}$/;function qt(t,e=Fe){return fi(t,e)?.context}function fi(t,e=Fe){let n=e.runResult(t,pi);if(n.kind==="success"){let i=yi(n.output);if(i){let o=mi(i,e);if(o)return Nt(o)}}let r=gi(t,e);return r?Nt(r):void 0}function Nt(t){return{context:t,projectFileInventorySequence:Tt()}}function Bt(t){let e=t.split("\0").filter(Boolean),n=e.find(i=>i.startsWith("# branch.oid "))?.slice(13),r=n==="(initial)"?void 0:n;if(!(r!==void 0&&!Ne.test(r))&&n!==void 0)return{headCommit:r,clean:e.every(i=>i.startsWith("# "))}}function yi(t){let e=t.split(`
3
- `).map(c=>c.trim());if(e.length!==5)return;let[n,r,i,o,s]=e;if(!n||!r||!i||!o||!s||!Ne.test(o)||!Ne.test(s))return;let a=M(n);return{root:a,gitDir:M(le(a,r)),commonDir:M(le(a,i)),headCommit:o,treeOid:s}}function mi(t,e){let n=e.run(t.root,Wt);if(n===void 0)return;let r=Bt(n);return r?.headCommit!==t.headCommit?void 0:{...Gt(t.root,t.gitDir),commonDir:t.commonDir,repositoryId:We("repository",t.commonDir),headCommit:t.headCommit,treeOid:t.treeOid,clean:r.clean}}function gi(t,e){let n=Le(t,e);if(n.kind!=="worktree")return;let r=n.identity,i=r.projectRoot,o=e.run(i,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=M(le(i,o)),a=Ft(e.run(i,["rev-parse","--verify","HEAD"])),c=Ft(e.run(i,["rev-parse","--verify","HEAD^{tree}"])),u=e.run(i,Wt);if(u===void 0)return;let l=Bt(u);if(!(!l||l.headCommit!==a))return{...r,commonDir:s,repositoryId:We("repository",s),headCommit:a,treeOid:c,clean:l.clean}}function Le(t,e=Fe){let n=e.runResult(t,["rev-parse","--show-toplevel"]);if(n.kind==="not-repository")return{kind:"non-git"};if(n.kind==="error")return n;let r=n.output.trim();if(!r)return{kind:"error",message:"Git returned an empty worktree root."};let i=M(r),o=e.run(i,["rev-parse","--absolute-git-dir"])?.trim();if(!o)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=M(le(i,o));return{kind:"worktree",identity:Gt(i,s)}}function Gt(t,e){return{projectRoot:t,gitDir:e,worktreeId:We("worktree",`${t}\0${e}`)}}function le(t,e){return di(e)?e:pe(t,e)}function M(t){try{return ci(t)}catch{return pe(t)}}function We(t,e){return oi("sha256").update(`${t}\0${e}`).digest("hex").slice(0,24)}function Ft(t){return t?.trim()||void 0}function Lt(t,e){let n=ii("git",["-C",t,...e],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"],timeout:3e4,killSignal:"SIGKILL"});if(n.status===0)return{kind:"success",output:n.stdout.trimEnd()};let i=(typeof n.stderr=="string"?n.stderr.trim():"")||n.error?.message||`git exited with status ${n.status??"unknown"}`,o=n.error?.code;return(/not a git repository/i.test(i)||o==="ENOENT"&&si(pe(t)))&&!hi(t)?{kind:"not-repository"}:{kind:"error",message:i}}function hi(t){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let e=pe(t);for(;;){try{return ai(li(e,".git")),!0}catch(r){let i=r.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let n=ui(e);if(n===e)return!1;e=n}}function qe(){return process.env.SCIP_QUERY_PROJECT_ROOT??process.cwd()}var Vt;function $t(t=qe(),e=void 0){if(e===void 0&&Vt?.projectRoot===t)return Vt;let n=Ot(t),r=bt(t,n),i=process.env.SCIP_QUERY_INDEX_DB;if(i)return{projectRoot:t,config:n,paths:r,dbPath:i,dbPathSource:"env",gitContext:e};if(bi(r.dbPath))return{projectRoot:t,config:n,paths:r,dbPath:r.dbPath,dbPathSource:"configured",gitContext:e};let o=vi(t,"index.db");return{projectRoot:t,config:n,paths:r,dbPath:o,dbPathSource:"root-fallback",rootFallbackWarning:Ri(o,r.dbPath),gitContext:e}}function Ri(t,e){let n="unknown time";try{n=Si(t).mtime.toISOString()}catch{}return`warning: using legacy project-root index.db (${t}, modified ${n}) because the configured index was not found at ${e}. This fallback may be stale; run 'scip-query reindex' to refresh the configured index.`}import{basename as xi}from"path";function Qt(t=process.argv,e=process.execPath){let n=t[1];return!n||xi(n)==="scip-query"?["scip-query"]:[e,n]}import{spawn as co}from"child_process";import{createHash as ve,randomUUID as uo}from"crypto";import{existsSync as Qe,realpathSync as lo}from"fs";import{tmpdir as po}from"os";import{join as Ue,resolve as re}from"path";import{fileURLToPath as fo}from"url";function fe(t){return Be(t,Ii)}function Be(t,e){return Array.isArray(t)?`[${t.map(n=>Be(n,e)).join(",")}]`:t&&typeof t=="object"?`{${Object.entries(t).sort(([n],[r])=>e(n,r)).map(([n,r])=>`${JSON.stringify(n)}:${Be(r,e)}`).join(",")}}`:JSON.stringify(t)}function Ii(t,e){return t<e?-1:t>e?1:0}import{createHash as rc,randomUUID as Yt}from"crypto";import{closeSync as oc,existsSync as Y,fstatSync as sc,lstatSync as ne,mkdirSync as ac,openSync as cc,readdirSync as K,readSync as uc,renameSync as zt,rmSync as F}from"fs";import{basename as ye,dirname as wi,join as g}from"path";var me=1,ki=Object.freeze({maxItems:1024,maxBytes:512*1024*1024,maxItemBytes:64*1024*1024,maxBatch:16,claimLeaseMs:5*6e4,responseRetentionMs:10*6e4,deadLetterRetentionMs:1440*6e4,temporaryRetentionMs:6e4,cleanupBatch:64}),J=class extends Error{constructor(n,r,i,o){let s=n==="item-too-large"?`request is ${o} bytes; per-item limit is ${i.maxItemBytes}`:n==="item-capacity"?`mailbox has ${r.totalItems} retained items; limit is ${i.maxItems}`:n==="byte-capacity"?`mailbox retains ${r.totalBytes} bytes and the request adds ${o}; limit is ${i.maxBytes}`:"another writer held the admission coordinator through the bounded wait";super(`Mailbox backpressure: ${s}. Retry after the service drains or expires retained work.`);this.code=n;this.status=r;this.limits=i;this.attemptedBytes=o;this.name="MailboxBackpressureError"}code;status;limits;attemptedBytes},Pi=".owner.json",Ci={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function Xt(t){return{rootDir:t,pendingDir:g(t,"pending"),inflightDir:g(t,"inflight"),responseDir:g(t,"responses"),deadLetterDir:g(t,"dead-letter"),legacyRequestDir:g(t,"requests")}}function Ei(t={}){let e={...ki,...t};for(let[n,r]of Object.entries(e))if(!Number.isFinite(r)||r<=0||!Number.isInteger(r))throw new Error(`Mailbox limit ${n} must be a positive integer.`);return e}function Zt(t){let e=[t.pendingDir,t.inflightDir,t.responseDir,t.deadLetterDir,t.legacyRequestDir].map(n=>ie(n));return B(...e)}function ge(t){if(!/^[a-f0-9]{64}$/.test(t))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${t}`}function en(t,e,n={}){let r=Ei(n.limits),i=n.nowMs??Date.now(),o=Zt(t);return Ni(e),Mi(t,r,n.admissionLockTimeoutMs??2e3,n.monotonicNow??A,n.durability??"durable",()=>{Ai(t,i,r);let s=g(t.pendingDir,`${e.id}.json`),a=g(t.responseDir,`${e.id}.json`),c=Ut(t,e.id);if(c){let y=Ht(c,e.operationKey,e.id);return{disposition:"duplicate",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:y.deadlineAtMs??e.deadlineAtMs}}let u=`${JSON.stringify(e)}
4
- `,l=Buffer.byteLength(u),p=tn(t);if(l>r.maxItemBytes)throw new J("item-too-large",p,r,l);if(p.totalItems+1>r.maxItems)throw new J("item-capacity",p,r,l);if(p.totalBytes+l>r.maxBytes)throw new J("byte-capacity",p,r,l);n.onBeforePublish?.();try{let y=n.durability??"durable",R=we(s,u,{durability:y}),P=y==="durable"?B(o,R.directorySync):"not-requested";return{disposition:"accepted",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:e.deadlineAtMs,achievedDurability:R.achievedDurability,directorySync:P}}catch(y){if(y.code!=="EEXIST")throw y;let R=Ut(t,e.id);if(!R)throw y;let P=Ht(R,e.operationKey,e.id);return{disposition:"duplicate",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:P.deadlineAtMs??e.deadlineAtMs}}})}function Ai(t,e,n,r=Ci){let i={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=n.cleanupBatch;for(let s of Ve(t.inflightDir)){if(o<=0)break;let a=g(t.responseDir,`${s.requestId}.json`);if(Y(a)){F(s.path,{force:!0}),i.completedClaimsRemoved++,o--;continue}if(s.claimExpiresAtMs>e||Di(t,s.ownerId,r)!=="dead")continue;let c=g(t.pendingDir,s.originalFile);try{zt(s.path,c),i.reclaimed++}catch(u){if(u.code!=="EEXIST")throw u;F(s.path,{force:!0})}_(wi(s.path)),_(t.pendingDir),o--}o=Jt(t.responseDir,o,(s,a)=>a+n.responseRetentionMs,e,()=>{i.responsesRemoved++}),o=Jt(t.deadLetterDir,o,(s,a)=>a+n.deadLetterRetentionMs,e,()=>{i.deadLettersRemoved++});for(let s of[t.pendingDir,t.inflightDir,t.responseDir,t.deadLetterDir,t.legacyRequestDir]){if(o<=0)break;for(let a of nn(s)){if(o<=0)break;if(!ye(a).includes(".tmp-"))continue;let c;try{c=ne(a).mtimeMs}catch(u){if(u.code==="ENOENT")continue;throw u}c+n.temporaryRetentionMs>e||(F(a,{force:!0}),i.temporaryFilesRemoved++,o--)}}return Fi(t.inflightDir),i}function tn(t){Zt(t);let e=[...te(t.pendingDir).map(c=>({path:c,pending:!0})),...te(t.legacyRequestDir).map(c=>({path:c,pending:!0}))],n=Ve(t.inflightDir).map(c=>({path:c.path,pending:!1})),r=te(t.responseDir).map(c=>({path:c,pending:!1})),i=te(t.deadLetterDir).map(c=>({path:c,pending:!1})),o=[...e,...n,...r,...i],s=0,a;for(let c of e){let u=$e(c.path);if(!u){s++;continue}let l=u.enqueuedAtMs;if(l===void 0)try{l=ne(c.path).mtimeMs}catch(p){if(p.code==="ENOENT")continue;throw p}a=a===void 0?l:Math.min(a,l)}return{pending:e.length,inflight:n.length,responses:r.length,deadLetters:i.length,invalid:s,totalItems:o.length,totalBytes:o.reduce((c,u)=>c+Li(u.path),0),...a===void 0?{}:{oldestPendingAt:new Date(a).toISOString()}}}function Mi(t,e,n,r,i,o){let s=g(t.rootDir,".admission.lock"),a=`${process.pid}-${Yt()}`,c=r()+Math.max(0,n);for(;!Oi(t.rootDir,s,a,i);){if(_i(s),r()>=c)throw new J("admission-busy",tn(t),e,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return o()}finally{try{Ge(s).ownerToken===a&&(F(s,{recursive:!0,force:!0}),i==="durable"&&_(t.rootDir))}catch{}}}function Oi(t,e,n,r){let i=`${JSON.stringify({ownerToken:n,pid:process.pid,acquiredAtMs:Date.now()})}
5
- `;try{return we(e,i,{durability:r}),!0}catch(o){if(o.code==="EEXIST")return!1;try{Ge(e).ownerToken===n&&(F(e,{force:!0}),r==="durable"&&_(t))}catch{}throw o}}function _i(t){let e=null;try{let r=Ge(t);typeof r.ownerToken=="string"&&Number.isSafeInteger(r.pid)&&Number(r.pid)>0&&(e=Number(r.pid))}catch{}if(e===null||ji(e))return;let n=`${t}.stale-${Yt()}`;try{zt(t,n)}catch(r){let i=r.code;if(i==="ENOENT"||i==="EEXIST")return;throw r}F(n,{recursive:!0,force:!0})}function Ge(t){try{return JSON.parse(I(t,"mailbox lock record"))}catch(e){if(e.code!=="EISDIR"&&!(e instanceof et&&e.reason==="not-regular"))throw e;return JSON.parse(I(g(t,"owner.json"),"mailbox lock owner record"))}}function ji(t){try{return process.kill(t,0),!0}catch(e){let n=e.code;return n==="EPERM"||n!=="ESRCH"}}function Di(t,e,n){let r=Ti(g(t.inflightDir,rn(e),Pi));if(!r)return"unknown";if(!n.isProcessAlive(r.pid))return"dead";if(!r.processIdentity)return"live";let i=n.readProcessIdentity(r.pid);return i?ee(r.processIdentity,i)?"live":"dead":"unknown"}function Ti(t){try{let e=JSON.parse(I(t,"mailbox owner record"));if(e.version!==1||typeof e.ownerId!="string"||!e.ownerId||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0)return null;let n=e.processIdentity===void 0?null:j(e.processIdentity);return e.processIdentity!==void 0&&(!n||n.pid!==e.pid)?null:{version:1,ownerId:e.ownerId,pid:e.pid,...n?{processIdentity:n}:{}}}catch{return null}}function Ut(t,e){for(let n of[g(t.pendingDir,`${e}.json`),g(t.legacyRequestDir,`${e}.json`),g(t.responseDir,`${e}.json`)])if(Y(n))return n;for(let n of Ve(t.inflightDir))if(n.requestId===e)return n.path;return null}function Ht(t,e,n){let r=$e(t);if(r?.operationKey===e)return r;if(ye(t)===`${ge(e)}.json`)return{id:n,operationKey:e};throw new Error(`Mailbox operation ${n} conflicts with an existing retained record.`)}function Ni(t){if(t.mailboxVersion!==me||t.id!==ge(t.operationKey)||!t.clientId.trim()||!Number.isFinite(t.enqueuedAtMs)||!Number.isFinite(t.deadlineAtMs)||t.deadlineAtMs<t.enqueuedAtMs)throw new Error("Mailbox request has an invalid lifecycle identity.")}function Ve(t){if(!Y(t))return[];let e=[];for(let n of K(t,{withFileTypes:!0})){if(!n.isDirectory())continue;let r=Kt(n.name);if(r===null)continue;let i=g(t,n.name);for(let o of K(i,{withFileTypes:!0})){if(!o.isFile()||!o.name.endsWith(".claim"))continue;let s=/^(.*)\.(\d+)\.claim$/.exec(o.name);if(!s)continue;let a=Kt(s[1]),c=Number(s[2]);if(a===null||ye(a)!==a||!a.endsWith(".json")||!Number.isSafeInteger(c))continue;let u=g(i,o.name),l=$e(u)??{id:ye(a,".json")},p;try{p=ne(u)}catch(y){if(y.code==="ENOENT")continue;throw y}e.push({requestId:l.id,ownerId:r,path:u,originalFile:a,claimedAtMs:p.mtimeMs,claimExpiresAtMs:c,byteLength:p.size,...l.operationKey?{operationKey:l.operationKey}:{},...l.clientId?{clientId:l.clientId}:{},...l.enqueuedAtMs===void 0?{}:{enqueuedAtMs:l.enqueuedAtMs},...l.deadlineAtMs===void 0?{}:{deadlineAtMs:l.deadlineAtMs},legacy:l.operationKey===void 0})}}return e.sort((n,r)=>n.claimedAtMs-r.claimedAtMs||n.path.localeCompare(r.path))}function $e(t){try{let e=JSON.parse(I(t,"mailbox record"));return typeof e.id!="string"||!e.id?null:{id:e.id,...typeof e.operationKey=="string"?{operationKey:e.operationKey}:{},...typeof e.clientId=="string"?{clientId:e.clientId}:{},...typeof e.enqueuedAtMs=="number"?{enqueuedAtMs:e.enqueuedAtMs}:{},...typeof e.deadlineAtMs=="number"?{deadlineAtMs:e.deadlineAtMs}:{}}}catch{return null}}function Jt(t,e,n,r,i){for(let o of te(t)){if(e<=0)break;let s;try{s=ne(o)}catch(a){if(a.code==="ENOENT")continue;throw a}n(o,s.mtimeMs)>r||(F(o,{force:!0}),i(),e--)}return e}function te(t){return Y(t)?K(t,{withFileTypes:!0}).filter(e=>e.isFile()).map(e=>g(t,e.name)).sort():[]}function nn(t){if(!Y(t))return[];let e=[];for(let n of K(t,{withFileTypes:!0})){let r=g(t,n.name);n.isFile()?e.push(r):n.isDirectory()&&e.push(...nn(r))}return e.sort()}function Fi(t){if(Y(t))for(let e of K(t,{withFileTypes:!0})){if(!e.isDirectory())continue;let n=g(t,e.name);K(n).some(r=>r.endsWith(".claim"))||F(n,{recursive:!0,force:!0})}}function Li(t){try{return ne(t).size}catch{return 0}}function rn(t){return Buffer.from(t,"utf8").toString("base64url")}function Kt(t){try{let e=Buffer.from(t,"base64url").toString("utf8");return rn(e)===t?e:null}catch{return null}}import{spawn as Xi}from"child_process";import{existsSync as Zi,rmSync as Pc}from"fs";import{dirname as Ec,resolve as eo}from"path";import{fileURLToPath as Mc}from"url";import{join as he}from"path";var on=6,sn=1e4,Wi="watch.lock",qi="watch-state.json",Bi="watch-activity.json",Gi="watch-refresh-requests";function an(t){return{lockPath:he(t,Wi),statePath:he(t,qi),activityPath:he(t,Bi),refreshRequestsPath:he(t,Gi)}}function cn(t){try{return Vi(JSON.parse(I(t,"watch service state")))}catch{return null}}function Vi(t){if(!t||typeof t!="object")return null;let e=t;if(e.version!==1||typeof e.protocolVersion!="number"||typeof e.pid!="number"||!Number.isInteger(e.pid)||e.pid<=0||typeof e.projectRoot!="string"||e.worktreeId!==void 0&&(typeof e.worktreeId!="string"||e.worktreeId.length===0)||typeof e.cliVersion!="string"||!h(e.startedAt)||!h(e.heartbeatAt)||!h(e.lastActivityAt)||!$i(e.watcher)||e.idleDeadlineAt!==void 0&&!h(e.idleDeadlineAt))return null;if(e.processIdentity!==void 0){let n=j(e.processIdentity);if(!n||n.pid!==e.pid)return null;e.processIdentity=n}return e.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(e.indexGeneration)||e.lastError!==void 0&&!Qi(e.lastError)||e.lastRefresh!==void 0&&!Ui(e.lastRefresh)||e.reindexActivity!==void 0&&!Hi(e.reindexActivity)||e.refreshRequests!==void 0&&!Ki(e.refreshRequests)||e.typescriptSemantic!==void 0&&!Yi(e.typescriptSemantic)||e.typescriptIndex!==void 0&&!zi(e.typescriptIndex)?null:e}function h(t){return oe(t)}function $i(t){if(!t||typeof t!="object"||!("state"in t))return!1;let e=t;switch(e.state){case"idle":return!0;case"waiting":return b(e.changedFiles)&&b(e.reindexAt);case"indexing":return b(e.startedAt);case"cooldown":return b(e.until)&&typeof e.dirty=="boolean";case"budget-paused":return b(e.until)&&typeof e.dirty=="boolean"&&typeof e.reason=="string"&&d(e.rebuilt)&&d(e.estimatedWriteBytes);case"draining":return b(e.startedAt)&&typeof e.reason=="string";default:return!1}}function Qi(t){if(!t||typeof t!="object")return!1;let e=t;return h(e.at)&&typeof e.message=="string"}function Ui(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.trigger?.kind=="string"&&typeof e.result=="string"&&h(e.startedAt)&&h(e.completedAt)&&b(e.durationMs)}function Hi(t){if(!t||typeof t!="object")return!1;let e=t;return e.confidence!==void 0&&e.confidence!=="complete"&&e.confidence!=="partial"&&e.confidence!=="unavailable"||e.recordsRead!==void 0&&!d(e.recordsRead)||e.invalidRecords!==void 0&&!d(e.invalidRecords)||e.skippedRecords!==void 0&&!d(e.skippedRecords)||e.readErrors!==void 0&&!d(e.readErrors)||e.ignoredPartialTailBytes!==void 0&&!d(e.ignoredPartialTailBytes)||!h(e.windowStartedAt)||!h(e.windowEndedAt)||!d(e.runs)||!d(e.rebuilt)||e.fullRebuilds!==void 0&&!d(e.fullRebuilds)||!d(e.reused)||!d(e.failed)||!d(e.suppressed)||!b(e.estimatedLogicalOutputBytes)||e.estimatedWriteBytes!==void 0&&!d(e.estimatedWriteBytes)||e.reflinkedBytes!==void 0&&!d(e.reflinkedBytes)||e.fallbackCopiedBytes!==void 0&&!d(e.fallbackCopiedBytes)||e.oldestRebuildAt!==void 0&&!h(e.oldestRebuildAt)||e.oldestWriteAt!==void 0&&!h(e.oldestWriteAt)||e.languageAttribution!==void 0&&e.languageAttribution!=="complete"&&e.languageAttribution!=="partial"&&e.languageAttribution!=="unavailable"||e.attributedRuns!==void 0&&!d(e.attributedRuns)||e.unattributedRuns!==void 0&&!d(e.unattributedRuns)||e.invalidLanguageDetails!==void 0&&!d(e.invalidLanguageDetails)||e.estimatedLogicalOutputBytes<0||!e.byTrigger||typeof e.byTrigger!="object"||Array.isArray(e.byTrigger)||e.byLanguage!==void 0&&!Ji(e.byLanguage)?!1:Object.values(e.byTrigger).every(n=>n===void 0||d(n))}function Ji(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;for(let[e,n]of Object.entries(t)){if(!Q.includes(e)||!n||typeof n!="object")return!1;let r=n;if(!d(r.runs)||!d(r.rebuilt)||!d(r.reused)||!d(r.producedOutputBytes)||!ot(r.durationMs)||r.rebuilt+r.reused!==r.runs)return!1}return!0}function Ki(t){if(!t||typeof t!="object")return!1;let e=t;return d(e.pending)&&d(e.claimed)&&d(e.completed)&&d(e.expired)&&d(e.invalid)&&(e.oldestPendingAt===void 0||h(e.oldestPendingAt))}function Yi(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&(e.state==="idle"||e.state==="ready"||e.state==="unavailable"||e.state==="error")&&b(e.requests)&&b(e.sessionsCreated)&&b(e.sessionsReused)&&b(e.sessionsRefreshed)&&b(e.sessionsReplaced)&&b(e.projectsCreated)&&(e.lastRequestAt===void 0||h(e.lastRequestAt))&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||h(e.busyUntil))&&(e.mailbox===void 0||un(e.mailbox))}function zi(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&(e.state==="idle"||e.state==="ready"||e.state==="unavailable"||e.state==="error")&&d(e.requests)&&d(e.sessionsCreated)&&d(e.sessionsReplaced)&&(e.sessionsEvicted===void 0||d(e.sessionsEvicted))&&(e.activeSessions===void 0||d(e.activeSessions))&&(e.maxActiveSessions===void 0||d(e.maxActiveSessions))&&(e.heapUsedBytes===void 0||d(e.heapUsedBytes))&&(e.heapLimitBytes===void 0||d(e.heapLimitBytes))&&(e.softMemoryLimitBytes===void 0||d(e.softMemoryLimitBytes))&&(e.retireRequested===void 0||typeof e.retireRequested=="boolean")&&d(e.initializations)&&d(e.programUpdates)&&d(e.documentsEmitted)&&d(e.documentsRemoved)&&(e.lastRequestAt===void 0||h(e.lastRequestAt))&&(e.lastDurationMs===void 0||b(e.lastDurationMs)&&e.lastDurationMs>=0)&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||h(e.busyUntil))&&(e.mailbox===void 0||un(e.mailbox))}function un(t){if(!t||typeof t!="object")return!1;let e=t;return d(e.pending)&&d(e.inflight)&&d(e.responses)&&d(e.deadLetters)&&d(e.invalid)&&d(e.totalItems)&&b(e.totalBytes)&&e.totalBytes>=0&&e.totalItems===e.pending+e.inflight+e.responses+e.deadLetters&&(e.oldestPendingAt===void 0||h(e.oldestPendingAt))}function b(t){return typeof t=="number"&&Number.isFinite(t)}function dn(t){let e=t.classification;if(e.kind!=="live")return;let{state:n}=e;return n.watcher.state==="idle"&&n.lastError===void 0?n.indexGeneration:void 0}function to(t,e,n){let r=M(eo(t));if(n&&M(n.projectRoot)===r)return{projectRoot:r,worktreeKind:"git",worktreeId:n.worktreeId,cliVersion:e};let i=Le(r);if(i.kind==="error")throw new Error(`Could not establish Git worktree identity for ${r}: ${i.message}`);return i.kind==="non-git"?{projectRoot:r,worktreeKind:"non-git",cliVersion:e}:{projectRoot:r,worktreeKind:"git",worktreeId:i.identity.worktreeId,cliVersion:e}}function ln(t){return no(t,to(t.projectRoot,t.cliVersion,t.gitContext))}function no(t,e){let n=t.runtime??ao,r=an(t.cacheDir),i=cn(r.statePath),o=ro(r.lockPath);return{identity:e,classification:so(i,e,n.now(),n.isProcessAlive),lock:o,lockIsLive:o!==null&&n.isProcessAlive(o.pid),paths:r}}function ro(t){return oo(st(t,{parseLegacy:io}))}var io=t=>{let e=pn(t);return e?{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}:null};function oo(t){if(t.state==="valid"&&t.record?.kind==="watch"){let e=t.record.detail?.projectRoot;return typeof e!="string"?null:{version:1,pid:t.record.pid,...t.record.processIdentity?{processIdentity:t.record.processIdentity}:{},projectRoot:e,startedAt:t.record.startedAt}}return pn(t.parsed)}function pn(t){try{let e=t;if(e.version!==1||typeof e.pid!="number"||!Number.isInteger(e.pid)||e.pid<=0||typeof e.projectRoot!="string"||!h(e.startedAt))return null;let n=e.processIdentity===void 0?null:j(e.processIdentity);return e.processIdentity!==void 0&&(!n||n.pid!==e.pid)?null:{version:1,pid:e.pid,...n?{processIdentity:n}:{},projectRoot:e.projectRoot,startedAt:e.startedAt}}catch{return null}}function so(t,e,n,r){if(!t)return{kind:"stopped"};if(t.protocolVersion!==on)return{kind:"incompatible",state:t,reason:"protocol"};if(t.projectRoot!==e.projectRoot)return{kind:"incompatible",state:t,reason:"project"};let i=e.worktreeKind==="git"?e.worktreeId:void 0;if(t.worktreeId!==i)return{kind:"incompatible",state:t,reason:"worktree"};if(t.cliVersion!==e.cliVersion)return{kind:"incompatible",state:t,reason:"cli-version"};if(!r(t.pid))return{kind:"stale",state:t,reason:"dead-process"};let o=Date.parse(t.heartbeatAt);return n-o>sn?{kind:"stale",state:t,reason:"old-heartbeat"}:{kind:"live",state:t}}var ao={now:Date.now,monotonicNow:A,isProcessAlive:V,readProcessIdentity:G,spawnServer(t,e,n,r){if(!Zi(t))throw new Error(`Watch service helper was not found at ${t}. Run npm run build first.`);Xi(process.execPath,[t,e,n,JSON.stringify(r)],{detached:!0,stdio:"ignore",env:{...process.env,SCIP_QUERY_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(t){process.kill(t,"SIGTERM")},forceSignalProcess(t){process.kill(t,"SIGKILL")},sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)}};var W=18,yo=1e3,mo=2*yo,go=4,ho=4,bo=5,So=3,vo=3,Ro=4,xo=3,Io=3,wo=8,fn=3e4,ko=5e3,mn=5,Po=10,Co=1,Eo=5,He=64*1024*1024,Ao={maxItems:64,maxBytes:128*1024*1024,maxItemBytes:He,maxBatch:1,responseRetentionMs:6e4};function gn(t,e,n={},r={}){return m(t,i=>({kind:"source-search",expectedGeneration:i,pattern:e,options:n}),as,"search result",r)}function hn(t,e,n={}){return m(t,r=>({kind:"outline",expectedGeneration:r,filePattern:e}),To,"outline result",n)}function bn(t,e={},n={}){return m(t,r=>({kind:"entrypoints",expectedGeneration:r,options:e}),No,"entrypoints result",n)}function Sn(t,e,n={}){return m(t,r=>({kind:"files",expectedGeneration:r,pattern:e}),Fo,"files result",n)}function vn(t,e={}){return m(t,n=>({kind:"stats",expectedGeneration:n}),Lo,"stats result",e)}function Rn(t,e,n={}){return m(t,r=>({kind:"members",expectedGeneration:r,symbolPattern:e}),Wo,"members result",n)}function xn(t,e,n={}){return m(t,r=>({kind:"methods",expectedGeneration:r,className:e}),qo,"methods result",n)}function In(t,e,n,r={}){return m(t,i=>({kind:"file-dependencies",expectedGeneration:i,direction:e,filePattern:n}),Bo,"file dependencies result",r)}function wn(t,e,n={}){return m(t,r=>({kind:"imported-by",expectedGeneration:r,symbolPattern:e}),Wn,"imported-by result",n)}function kn(t,e,n={}){return m(t,r=>({kind:"hierarchy",expectedGeneration:r,symbolPattern:e}),Qo,"hierarchy result",n)}function Pn(t,e,n={}){return m(t,r=>({kind:"by-kind",expectedGeneration:r,kindQuery:e}),Ho,"by-kind result",n)}function Cn(t,e={}){return m(t,n=>({kind:"kind-counts",expectedGeneration:n}),Ko,"kind-counts result",e)}function En(t,e,n={}){return m(t,r=>({kind:"refs",expectedGeneration:r,symbolPattern:e}),zo,"refs result",n)}function An(t,e,n={}){return m(t,r=>({kind:"trace",expectedGeneration:r,symbolPattern:e}),z,"trace result",n)}function Mn(t,e,n={}){return m(t,r=>({kind:"value-flow",expectedGeneration:r,symbolPattern:e}),z,"value-flow result",n)}function On(t,e,n={}){return m(t,r=>({kind:"dependence-slice",expectedGeneration:r,criterion:e}),z,"dependence-slice result",n)}function _n(t,e,n,r={}){return m(t,i=>({kind:e,expectedGeneration:i,symbolPattern:n}),z,`${e} result`,r)}function jn(t,e,n={}){return m(t,r=>({kind:"system",expectedGeneration:r,modulePattern:e}),z,"system result",n)}function Dn(t,e,n={}){return m(t,r=>({kind:"imports",expectedGeneration:r,filePattern:e}),Wn,"imports result",n)}function Tn(t,e,n={}){return m(t,r=>({kind:"unused-imports",expectedGeneration:r,filePattern:e}),Go,"unused imports result",n)}function Nn(t,e,n={}){return m(t,r=>({kind:"surface",expectedGeneration:r,modulePattern:e}),Zo,"surface result",n)}function Fn(t,e,n,r={}){return m(t,i=>({kind:"code",expectedGeneration:i,selectors:[...e],options:n}),z,"serialized code result",r)}function m(t,e,n,r,i){if(!ds(i.allowDefault===!0))return null;try{let o=i.allowDefault===!0&&process.env.SCIP_QUERY_QUERY_SERVICE!=="1",s=o?qt(t):void 0,a=$t(t,s);if(!Qe(a.dbPath))return null;let c=wt(a.dbPath);if(!c||o&&!Mo(a,s,c))return null;let u=_o({projectRoot:a.projectRoot,dbPath:a.dbPath,generationIdentity:c},e(c),n,r);return{result:u.result,generationIdentity:c,observationReceipt:u.observationReceipt}}catch(o){return qn()&&console.error(`query-service fallback: ${o instanceof Error?o.message:String(o)}`),null}}function Mo(t,e,n){if(t.config.watch?.enabled!==!0)return!1;try{return dn(ln({projectRoot:t.projectRoot,cacheDir:t.paths.cacheDir,cliVersion:$,gitContext:e}))===n}catch{return!1}}function Ln(t){return ve("sha256").update(fe({kind:"scip-query-service-mailbox",protocolVersion:W,sessionDir:re(t)})).digest("hex")}function be(t){let e=Ue(t,"server.json");try{let n=JSON.parse(q(e,{maxBytes:65536,inputKind:"query service state"}));if(!n||typeof n!="object"||Array.isArray(n))return null;let r=n,i=r.processIdentity===void 0?void 0:j(r.processIdentity);return r.protocolVersion!==W||typeof r.sessionIdentity!="string"||r.sessionIdentity!==Ln(t)||typeof r.pid!="number"||!Number.isSafeInteger(r.pid)||r.pid<=0||r.processIdentity!==void 0&&(!i||i.pid!==r.pid)||typeof r.generation!="string"||typeof r.heartbeatAtMs!="number"||!Number.isFinite(r.heartbeatAtMs)?null:{protocolVersion:W,sessionIdentity:r.sessionIdentity,pid:r.pid,...i?{processIdentity:i}:{},generation:r.generation,heartbeatAtMs:r.heartbeatAtMs}}catch{return null}}function Se(t,e=Date.now()){if(!V(t.pid))return!1;let n=e-t.heartbeatAtMs;if(n>=0&&n<=mo||!t.processIdentity)return!0;let r=G(t.pid);return r!==null&&ee(t.processIdentity,r)}function Oo(t){let e=t<Po;return{intervalMs:e?Co:mn,checkServerState:!e||t%Eo===0}}function _o(t,e,n,r){let i=us();if(!Qe(i))throw new Error("Query service server executable is unavailable.");let o=Math.abs(process.pid)%ps(e),s=cs(t,i,o),a=Xt(s),c=Date.now(),u=c+fn,l=A()+fn,p=uo(),y=jo(p,e),R=ge(y),P=Ln(s),x=en(a,{mailboxVersion:me,protocolVersion:W,id:R,operationKey:y,clientId:p,enqueuedAtMs:c,deadlineAtMs:u,sessionIdentity:P,request:e},{nowMs:c,limits:Ao,durability:"visibility"});yn(s,t.projectRoot,i,l);let Ye=0;for(;A()<=l;){if(Qe(x.responsePath))return Do(q(x.responsePath,{maxBytes:He,inputKind:"query service response"}),{id:R,operationKey:y,clientId:p,deadlineAtMs:x.authoritativeDeadlineAtMs,generation:t.generationIdentity},n,r);let ze=Oo(Ye);if(ze.checkServerState){let Xe=be(s);(!Xe||!Se(Xe))&&yn(s,t.projectRoot,i,l)}Bn(ze.intervalMs),Ye+=1}throw new Error("Persistent query service timed out.")}function jo(t,e){return ve("sha256").update(fe({namespace:"query-service-v18",payload:{clientId:t,request:e}})).digest("hex")}function yn(t,e,n,r){let i=be(t);if(i&&Se(i))return;let o=Math.min(r,A()+ko),s=Ie(Ue(t,"startup.lock"),{kind:"query-service-startup",detail:{projectRoot:re(e)},directoryDurability:"recoverable"});try{if(s.kind==="acquired"){let a=be(t);if(!a||!Se(a)){let c=qn();co(process.execPath,[n,t,e],{cwd:e,detached:!c,stdio:c?["ignore","ignore","inherit"]:"ignore",env:{...process.env,SCIP_QUERY_QUERY_SERVICE_SERVER:"1"}}).unref()}}for(;A()<=o;){let a=be(t);if(a&&Se(a))return;Bn(mn)}}finally{s.kind==="acquired"&&s.lock.release()}throw new Error("Persistent query service did not become ready within 5s.")}function Do(t,e,n,r){let i=JSON.parse(t);if(!i||typeof i!="object"||Array.isArray(i))throw new Error("Invalid query service response.");let o=i;if(o.mailboxVersion!==me||o.protocolVersion!==W||o.id!==e.id||o.operationKey!==e.operationKey||o.clientId!==e.clientId||o.deadlineAtMs!==e.deadlineAtMs)throw new Error("Query service response identity does not match the request.");if(o.ok!==!0)throw new Error(typeof o.error=="string"?o.error:"Persistent query service rejected the request.");if(o.generation!==e.generation)throw new Error("Persistent query service generation changed.");if(!n(o.result))throw new Error(`Persistent query service returned an invalid ${r}.`);let s=Et(o.observationReceipt);if(s.kind!=="supported")throw new Error("Persistent query service returned an invalid observation receipt.");return{ok:!0,protocolVersion:W,id:e.id,generation:e.generation,result:o.result,observationReceipt:s.receipt}}function To(t){if(!Array.isArray(t))return!1;let e=[...t];for(;e.length>0;){let n=e.pop();if(!n||typeof n!="object"||Array.isArray(n))return!1;let r=n;if(typeof r.symbol!="string"||typeof r.shortName!="string"||!Number.isSafeInteger(r.startLine)||r.startLine<0||!Number.isSafeInteger(r.endLine)||r.endLine<r.startLine||r.signature!==null&&typeof r.signature!="string"||!Array.isArray(r.children))return!1;e.push(...r.children)}return!0}function No(t){return Array.isArray(t)?t.every(e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.symbol=="string"&&typeof n.shortName=="string"&&typeof n.file=="string"&&Number.isSafeInteger(n.startLine)&&n.startLine>=0&&Number.isSafeInteger(n.endLine)&&n.endLine>=n.startLine&&(n.documentation===null||typeof n.documentation=="string")&&(n.confidence==="root"||n.confidence==="candidate")&&Array.isArray(n.evidence)&&n.evidence.every(r=>typeof r=="string")&&Number.isSafeInteger(n.indexedCallerCount)&&n.indexedCallerCount>=0}):!1}function Fo(t){return Array.isArray(t)?t.every(e=>!e||typeof e!="object"||Array.isArray(e)?!1:typeof e.relativePath=="string"):!1}function Lo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return S(e.documents)&&S(e.symbols)&&S(e.definitions)&&S(e.references)&&S(e.indexSizeBytes)&&(e.lastBuilt===null||typeof e.lastBuilt=="string")}function Wo(t){if(!Je(t))return!1;let e=t.members;return Array.isArray(e)&&e.every(ts)}function Je(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return e.matched===!1?e.resolved===void 0&&e.otherMatches===void 0&&e.totalMatches===void 0&&Array.isArray(e.suggestions)&&e.suggestions.every(n=>typeof n=="string"):e.matched===!0&&is(e.resolved)&&Array.isArray(e.otherMatches)&&e.otherMatches.every(os)&&S(e.totalMatches)&&e.totalMatches>=1&&e.suggestions===void 0}function qo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.query!="string"?!1:e.kind==="missing"?Array.isArray(e.suggestions)&&e.suggestions.every(n=>typeof n=="string"):e.kind==="ambiguous"?S(e.total)&&e.total>1&&Array.isArray(e.candidates)&&e.candidates.every(ss):e.kind==="matched"&&rs(e.owner)&&Array.isArray(e.methods)&&e.methods.every(ns)}function Bo(t){return Array.isArray(t)?t.every(e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.relativePath=="string"&&(n.edgeBasis===void 0||n.edgeBasis==="symbol-references")&&(n.evidence===void 0||n.evidence==="cross-file SCIP references plus resolved source imports")}):!1}function Wn(t){return Array.isArray(t)&&t.every($o)}function Go(t){return Array.isArray(t)&&t.every(Vo)}function Vo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.importedIn=="string"}function $o(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.fromFile=="string"}function Qo(t){if(!Je(t))return!1;let e=t.hierarchy;return Array.isArray(e)&&e.every(Uo)}function Uo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&S(e.depth)}function Ho(t){return Array.isArray(t)&&t.every(Jo)}function Jo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&S(e.kind)&&typeof e.kindName=="string"&&typeof e.relativePath=="string"&&Re(e)}function Ko(t){return Array.isArray(t)&&t.every(Yo)}function Yo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return S(e.kind)&&typeof e.kindName=="string"&&S(e.count)}function zo(t){if(!Je(t))return!1;let e=t,n=e.references,r=e.pagination;if(!Array.isArray(n)||!n.every(Xo)||!r||typeof r!="object"||Array.isArray(r))return!1;let i=r;return i.cursorVersion===2&&i.producer==="complete-only"&&typeof i.semanticEnrichment=="boolean"}function Xo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.relativePath=="string"&&S(e.line)}function Zo(t){return Array.isArray(t)&&t.every(es)}function es(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.consumer=="string"&&typeof e.symbol=="string"&&typeof e.shortName=="string"&&e.basis==="external-reference"}function ts(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.kind=="string"&&Re(e)}function ns(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.name=="string"&&Re(e)}function rs(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.relativePath=="string"&&Re(e)}function is(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.relativePath=="string"}function os(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.shortName=="string"&&typeof e.relativePath=="string"&&S(e.startLine)&&e.symbol===void 0}function ss(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.relativePath=="string"&&S(e.startLine)}function Re(t){return S(t.startLine)&&S(t.endLine)&&t.endLine>=t.startLine}function S(t){return Number.isSafeInteger(t)&&t>=0}function as(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.pattern=="string"&&(e.mode==="literal"||e.mode==="regexp")&&Array.isArray(e.matches)&&typeof e.matchingLines=="number"&&Number.isSafeInteger(e.matchingLines)&&e.matchingLines>=0&&typeof e.omittedMatches=="number"&&Number.isSafeInteger(e.omittedMatches)&&e.omittedMatches>=0&&typeof e.scannedFiles=="number"&&Number.isSafeInteger(e.scannedFiles)&&e.scannedFiles>=0}function z(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;if(typeof e.serializedJson!="string"||typeof e.sha256!="string"||e.serializedJson.length>He||ve("sha256").update(e.serializedJson).digest("hex")!==e.sha256)return!1;try{let n=JSON.parse(e.serializedJson);return n!==null&&typeof n=="object"&&!Array.isArray(n)}catch{return!1}}function cs(t,e,n){let r=fs(t.projectRoot),i=ve("sha256").update(fe({protocolVersion:W,projectRoot:r,dbPath:re(t.dbPath),serverPath:re(e),lane:n})).digest("hex");return Ue(po(),"scip-query-query-service",i)}function us(){return process.env.SCIP_QUERY_QUERY_SERVICE_SERVER_PATH??fo(new URL("./query-service-server.js",import.meta.url))}function ds(t){let e=process.env.SCIP_QUERY_QUERY_SERVICE;return process.env.SCIP_QUERY_QUERY_SERVICE_SERVER!=="1"&&e!=="0"&&(e==="1"||t)}function qn(){return process.env.SCIP_QUERY_QUERY_SERVICE_DEBUG==="1"}function ls(){let t=Number(process.env.SCIP_QUERY_QUERY_SERVICE_POOL_SIZE);return Number.isInteger(t)&&t>=1&&t<=wo?t:go}function ps(t){let e=ls();return t.kind==="value-flow"?Math.min(e,xo):t.kind==="dependence-slice"?Math.min(e,Io):t.kind==="call-graph"?Math.min(e,So):t.kind==="system"?Math.min(e,Ro):t.kind==="reference-reachability"||t.kind==="slice"?Math.min(e,vo):t.kind==="refs"||t.kind==="trace"||t.kind==="reference-neighborhood"||t.kind==="dataflow"||t.kind==="imports"||t.kind==="unused-imports"?Math.min(e,bo):t.kind==="imported-by"||t.kind==="hierarchy"||t.kind==="by-kind"||t.kind==="kind-counts"?Math.min(e,ho):e}function fs(t){try{return lo.native(t)}catch{return re(t)}}function Bn(t){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)}async function lu(t){if(process.env.SCIP_QUERY_PROFILE==="1"||process.env.SCIP_QUERY_PROFILE==="true")return!1;let e=ys(t);if(!e)return!1;let n=qe();if(e.kind==="code"){try{at(n,"code",e.session)}catch{return!1}let i=Fn(n,e.selectors,e.options,{allowDefault:!0});return i?(O(i.result.serializedJson),!0):!1}if(e.kind==="files"){let i=Sn(n,e.pattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="members"){let i=Rn(n,e.symbolPattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="methods"){let i=xn(n,e.className,{allowDefault:!0});return!i||!X(i.result)?!1:(i.result.kind!=="matched"&&(process.exitCode=1),!0)}if(e.kind==="file-dependencies"){let i=In(n,e.direction,e.filePattern,{allowDefault:!0});if(!i)return!1;let o=e.direction==="outgoing"?"deps":"rdeps";return await w(JSON.stringify(i.result),o,t),!0}if(e.kind==="imported-by"){let i=wn(n,e.symbolPattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="hierarchy"){let i=kn(n,e.symbolPattern,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="by-kind"){let i=Pn(n,e.kindQuery,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="kind-counts"){let i=Cn(n,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="refs"){let i=En(n,e.symbolPattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="trace"){let i=An(n,e.symbolPattern,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="value-flow"){let i=Mn(n,e.symbolPattern,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="dependence-slice"){let i=On(n,e.criterion,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="call-graph"||e.kind==="reference-neighborhood"||e.kind==="reference-reachability"||e.kind==="slice"||e.kind==="dataflow"){let i=_n(n,e.kind,e.symbolPattern,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="imports"){let i=Dn(n,e.filePattern,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="unused-imports"){let i=Tn(n,e.filePattern,{allowDefault:!0});return!(!i||!X(i.result))}if(e.kind==="system"){let i=jn(n,e.modulePattern,{allowDefault:!0});return i?(await w(i.result.serializedJson,e.kind,t),!0):!1}if(e.kind==="surface"){let i=Nn(n,e.modulePattern,{allowDefault:!0});return i?(await w(JSON.stringify(i.result),e.kind,t),!0):!1}if(e.kind==="stats"){let i=vn(n,{allowDefault:!0});return i?(O(JSON.stringify(i.result)),!0):!1}if(e.kind==="entrypoints"){let i=bn(n,e.options,{allowDefault:!0});return i?(O(JSON.stringify(i.result)),!0):!1}let r=e.kind==="source-search"?gn(n,e.pattern,e.options,{allowDefault:!0}):hn(n,e.filePattern,{allowDefault:!0});return r?(O(JSON.stringify(r.result)),!0):!1}function ys(t){return t[0]==="search"?Os(t):t[0]==="outline"?_s(t):t[0]==="code"?Ms(t):t[0]==="entrypoints"?As(t):t[0]==="files"?Es(t):t[0]==="stats"?$n(t,"stats"):t[0]==="kind-counts"?$n(t,"kind-counts"):t[0]==="members"?Gn(t,"members"):t[0]==="methods"?Gn(t,"methods"):t[0]==="deps"?Vn(t,"outgoing"):t[0]==="rdeps"?Vn(t,"incoming"):t[0]==="imported-by"?ms(t):t[0]==="hierarchy"?gs(t):t[0]==="by-kind"?hs(t):t[0]==="refs"?bs(t):t[0]==="trace"?Ss(t):t[0]==="value-flow"?vs(t):t[0]==="dependence-slice"?Rs(t):t[0]==="call-graph"||t[0]==="reference-neighborhood"||t[0]==="reference-reachability"||t[0]==="slice"||t[0]==="dataflow"?xs(t):t[0]==="imports"?Is(t):t[0]==="unused-imports"?ws(t):t[0]==="system"?ks(t):t[0]==="surface"?Ps(t):null}function Gn(t,e){let n=v(t);return n===null?null:e==="members"?{kind:e,symbolPattern:n}:{kind:e,className:n}}function Vn(t,e){let n=v(t);return n===null?null:{kind:"file-dependencies",direction:e,filePattern:n}}function ms(t){let e=v(t);return e===null?null:{kind:"imported-by",symbolPattern:e}}function gs(t){let e=v(t);return e===null?null:{kind:"hierarchy",symbolPattern:e}}function hs(t){let e=v(t);return e===null?null:{kind:"by-kind",kindQuery:e}}function bs(t){let e=v(t);return e===null?null:{kind:"refs",symbolPattern:e}}function Ss(t){let e=v(t);return e===null?null:{kind:"trace",symbolPattern:e}}function vs(t){let e=v(t);return e===null?null:{kind:"value-flow",symbolPattern:e}}function Rs(t){let e=v(t);return e===null?null:{kind:"dependence-slice",criterion:e}}function xs(t){let e=t[0];if(e!=="call-graph"&&e!=="reference-neighborhood"&&e!=="reference-reachability"&&e!=="slice"&&e!=="dataflow")return null;let n=v(t);return n===null?null:{kind:e,symbolPattern:n}}function Is(t){let e=v(t);return e===null?null:{kind:"imports",filePattern:e}}function ws(t){let e=v(t);return e===null?null:{kind:"unused-imports",filePattern:e}}function ks(t){let e=v(t);return e===null?null:{kind:"system",modulePattern:e}}function Ps(t){let e=v(t);return e===null?null:{kind:"surface",modulePattern:e}}function v(t){let e,n=!1,r=!1,i=!1;for(let o=1;o<t.length;o+=1){let s=t[o];if(s==="--"){let a=t.slice(o+1);if(a.length!==1||e!==void 0)return null;e=a[0];break}if(s==="--json"){n=!0;continue}if(s==="--result-only"){r=!0;continue}if(s==="--compact"){i=!0;continue}if(s.startsWith("-")||e!==void 0)return null;e=s}return!n||!r||!i||e===void 0?null:e}function X(t){return Cs(JSON.stringify(t))}function Cs(t){return Qn(t)?(O(t),!0):!1}async function w(t,e,n){if(Qn(t)){O(t);return}let{runWithCliOutputPagination:r}=await import("./output-pagination-2GME6OPY.js");await r({command:e,producerVersion:$,invocationPrefix:Qt(),argv:[...n],cwd:process.cwd(),json:!0,sourceSession:!0,reemitSource:!1},()=>O(t))}function Qn(t){return Buffer.byteLength(t)+1<=tt}function Es(t){let e,n=!1,r=!1,i=!1;for(let o=1;o<t.length;o+=1){let s=t[o];if(s==="--"){let a=t.slice(o+1);if(a.length!==1||e!==void 0)return null;e=a[0];break}if(s==="--json"){n=!0;continue}if(s==="--result-only"){r=!0;continue}if(s==="--compact"){i=!0;continue}if(s.startsWith("-")||e!==void 0)return null;e=s}return!n||!r||!i||e===void 0?null:{kind:"files",pattern:e}}function $n(t,e){let n=!1,r=!1,i=!1;for(let o=1;o<t.length;o+=1){let s=t[o];if(s==="--json"){n=!0;continue}if(s==="--result-only"){r=!0;continue}if(s==="--compact"){i=!0;continue}return null}return n&&r&&i?{kind:e}:null}function As(t){let e,n,r=!1,i=!1,o=!1;for(let s=1;s<t.length;s+=1){let a=t[s];if(a==="--"){let u=t.slice(s+1);if(u.length!==1||e!==void 0)return null;e=u[0];break}if(a==="--json"){r=!0;continue}if(a==="--result-only"){i=!0;continue}if(a==="--compact"){o=!0;continue}let c=Z(t,s,a,"--scope","-s");if(c){n=c.value,s=c.nextIndex;continue}if(a.startsWith("-")||e!==void 0)return null;e=a}return!r||!i||!o?null:{kind:"entrypoints",options:{...e===void 0?{}:{search:e},...n===void 0?{}:{scope:n}}}}function Ms(t){let e=[],n=0,r="exported",i=!0,o=!1,s=!1,a=!1;for(let c=1;c<t.length;c+=1){let u=t[c];if(u==="--"){e.push(...t.slice(c+1));break}if(u==="--json"){o=!0;continue}if(u==="--result-only"){s=!0;continue}if(u==="--compact"){a=!0;continue}if(u==="--no-session"){i=!1;continue}let l=Z(t,c,u,"--context","-C");if(l){let y=Ke(l.value,0);if(y===null)return null;n=y,c=l.nextIndex;continue}let p=Z(t,c,u,"--members");if(p){if(p.value!=="exported"&&p.value!=="all")return null;r=p.value,c=p.nextIndex;continue}if(u.startsWith("-"))return null;e.push(u)}return!o||!s||!a||e.length<1||e.length>24||e.some(c=>c.length===0)?null:{kind:"code",selectors:e,options:{context:n,members:r},session:i}}function Os(t){let e,n,r=2,i=6,o=!1,s=!1,a=!1,c=!1,u=!1;for(let l=1;l<t.length;l+=1){let p=t[l];if(p==="--"){let x=t.slice(l+1);if(x.length!==1||e!==void 0)return null;e=x[0];break}if(p==="--json"){a=!0;continue}if(p==="--result-only"){c=!0;continue}if(p==="--compact"){u=!0;continue}if(p==="--regexp"){o=!0;continue}if(p==="--ignore-case"||p==="-i"){s=!0;continue}let y=Z(t,l,p,"--scope","-s");if(y){n=y.value,l=y.nextIndex;continue}let R=Z(t,l,p,"--context","-C");if(R){let x=Ke(R.value,0);if(x===null)return null;r=x,l=R.nextIndex;continue}let P=Z(t,l,p,"--limit","-n");if(P){let x=Ke(P.value,1);if(x===null)return null;i=x,l=P.nextIndex;continue}if(p.startsWith("-")||e!==void 0)return null;e=p}return!a||!c||!u||e===void 0?null:{kind:"source-search",pattern:e,options:{scope:n,context:r,limit:i,regexp:o,ignoreCase:s,ranking:"structural"}}}function _s(t){let e,n=!1,r=!1,i=!1;for(let o=1;o<t.length;o+=1){let s=t[o];if(s==="--"){let a=t.slice(o+1);if(a.length!==1||e!==void 0)return null;e=a[0];break}if(s==="--json"){n=!0;continue}if(s==="--result-only"){r=!0;continue}if(s==="--compact"){i=!0;continue}if(s!=="--signatures"){if(s.startsWith("-")||e!==void 0)return null;e=s}}return!n||!r||!i||e===void 0?null:{kind:"outline",filePattern:e}}function Z(t,e,n,r,i){if(n.startsWith(`${r}=`))return{value:n.slice(r.length+1),nextIndex:e};if(n!==r&&(i===void 0||n!==i))return null;let o=t[e+1];return o===void 0?null:{value:o,nextIndex:e+1}}function Ke(t,e){if(!/^\d+$/.test(t))return null;let n=Number(t);return Number.isSafeInteger(n)&&n>=e?n:null}export{ys as parseFastPathInvocation,Qn as serializedJsonFitsClientBudget,lu as tryRunQueryServiceFastPath};
1
+ import{A as V,B as Q,C as yt,D as ke,E as ht,F as Ee,a as se,b as pt,c as ft,d as B,e as R,g as gt,k as X,l as mt,m as Pe,n as ae,o as O,p as G,q as l,r as T,s as a,t as N,u as ce,v as w,w as I,y as M,z as Z}from"./chunk-QYUVVBMR.js";import{createHash as mr,randomUUID as yr}from"crypto";import{readdirSync as hr}from"fs";import{dirname as St,extname as br,join as Ae,relative as vt,sep as Rt}from"path";import{fileURLToPath as Sr}from"url";import{createRequire as vr}from"module";var bt=vr(import.meta.url),te=xr(),$=te.version,gc=te.path?St(te.path):null,ee;function xt(){if(ee!==void 0)return ee;try{if(!te.path)throw new Error("Package location unavailable");let e=St(te.path),n=vt(e,Sr(import.meta.url)).startsWith(`src${Rt}`)?"src":"dist";ee=Rr(e,n)}catch{ee=`unavailable:${yr()}`}return ee}function Rr(e,t){let n=mr("sha256").update("scip-query-runtime-v2\0"),r=t==="src"?new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".json"]):new Set([".js",".mjs",".cjs",".json"]),i=It(Ae(e,t),r);if(i.length===0)throw new Error("Package runtime is empty");for(let o of[Ae(e,"package.json"),...i]){let s=ft(o,{maxBytes:se,inputKind:"Package runtime input"});n.update(vt(e,o).split(Rt).join("/")).update("\0"),n.update(String(s.length)).update("\0").update(s)}return n.digest("hex").slice(0,16)}function It(e,t){let n=[],r=hr(e,{withFileTypes:!0}).sort((i,o)=>i.name<o.name?-1:i.name>o.name?1:0);for(let i of r){let o=Ae(e,i.name);if(i.isDirectory())n.push(...It(o,t));else if(i.isFile())t.has(br(i.name))&&n.push(o);else throw new Error(`Unsupported runtime entry: ${o}`)}return n}function xr(){for(let e of["../package.json","../../package.json"])try{let t=bt(e);if(t.name==="scip-query"&&typeof t.version=="string")return{version:t.version,path:bt.resolve(e)}}catch{}return{version:"0.0.0"}}import{existsSync as ao,statSync as co}from"fs";import{join as uo}from"path";import{createHash as At,randomUUID as Cr}from"crypto";import{chmodSync as Ot,existsSync as de,linkSync as Pr,lstatSync as Me,readdirSync as Mt,realpathSync as j,unlinkSync as kr,writeSync as Er}from"fs";import{homedir as Ar}from"os";import{basename as xc,dirname as _e,isAbsolute as Pt,join as k,resolve as je}from"path";import{isAbsolute as wt,relative as Ir}from"path";var P=class extends Error{constructor(n,r){super(`refusing unsafe project file path ${JSON.stringify(n)} (${r})`);this.relativePath=n;this.reason=r;this.name="UnsafeProjectPathError"}relativePath;reason;code="SCIP_QUERY_UNSAFE_PROJECT_PATH"};function wr(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function Oe(e,t){let n=Ir(e,t);return n===""||!n.startsWith("..")&&!wt(n)}function Ct(e){if(!e)throw new P(e,"empty-path");if(e.includes("\0"))throw new P(e,"nul-byte");if(wt(e)||/^[A-Za-z]:/.test(e)||e.startsWith("//")||e.startsWith("\\\\"))throw new P(e,"absolute-path");let t=wr(e);if(t.split("/").some(r=>r===".."))throw new P(e,"parent-traversal");if(!t||t===".")throw new P(e,"empty-path");return t}var _t=1,pe=".scip-query-cache-owner.json",Or=16*1024,jt=Object.freeze({...Pe,randomToken:()=>Cr(),linkFile:(e,t)=>Pr(e,t),removeFile:e=>kr(e),writeFile:(e,t,n,r)=>Er(e,t,n,r)});function ue(e,t){return Object.assign(new Error(`refusing unsafe project dbPath ${JSON.stringify(e)} (${t}); use a repository-relative directory that remains inside the checkout`),{name:"UnsafeCachePathError",code:"SCIP_QUERY_UNSAFE_CACHE_PATH",configuredPath:e,reason:t})}function _(e,t){return Object.assign(new Error(`refusing unowned cache directory ${JSON.stringify(e)} (${t}); move unrelated data elsewhere or choose a new empty dbPath`),{name:"CacheOwnershipError",code:"SCIP_QUERY_CACHE_OWNERSHIP",cacheDir:e,reason:t})}function Mr(e,t){let n=j(e);return Fr(n,_r(n,t))}function _r(e,t){let n=j(e),r=process.env.SCIP_QUERY_CACHE_DIR;return r?je(r):t?.dbPath?Nr(n,t.dbPath):Dr(n)}function jr(){let e=process.env.XDG_CACHE_HOME;return k(e||k(Ar(),".cache"),"scip-query")}function Dr(e){let t=je(e);try{t=j(t)}catch{}let n=At("sha256").update(t).digest("hex").slice(0,12);return k(jr(),"projects",n)}function Dt(e,t){let n=Mr(e,t);return{cacheDir:n,dbPath:k(n,"index.db"),indexPath:k(n,"index.scip"),metaPath:k(n,"meta.json")}}function Fr(e,t,n=jt){return Tr(e,t,n).cacheDir}function Tr(e,t,n=jt){let r=j(e),i=de(t)?"synced":Qr(t,n),o=j(t),s=k(o,pe);if(de(s))return kt(r,o),Ft(s),le(o),{kind:"existing",cacheDir:o};Et(o),Gr(o),Et(o);let d=`${JSON.stringify({schemaVersion:_t,canonicalProjectRoot:r,canonicalCacheDir:o,creatorVersion:$},null,2)}
2
+ `;try{let p=$r(s,d,n),y=G(i,p);return{kind:"published",cacheDir:o,achievedDurability:y==="synced"?"directory-durable":"file-flushed",directorySync:y}}catch(p){if(Ur(p))return kt(r,o),{kind:"existing",cacheDir:o};throw p}}function kt(e,t){let n=j(e),r=j(t);return Wr(r,n,r)}function Nr(e,t){let n;try{n=Ct(t)}catch(s){throw s instanceof P?ue(t,s.reason):s}let r=je(e,...n.split("/"));if(r===e||!Oe(e,r))throw ue(t,"outside-project");let i=Lr(r),o=j(i);if(!Oe(e,o)&&o!==e)throw ue(t,"symlink-escape");return r}function Lr(e){let t=e;for(;!de(t);){let n=_e(t);if(n===t)throw ue(e,"no-existing-ancestor");t=n}return t}function Wr(e,t,n){let r=k(e,pe);if(!de(r)||Me(r).isSymbolicLink())throw _(e,"missing regular ownership record");let i=Me(r);if(!i.isFile()||i.size>Or)throw _(e,"invalid ownership record file");let o=R(r,"cache ownership record"),s=qr(o,e);if(t!==void 0&&s.canonicalProjectRoot!==t)throw _(e,"ownership record belongs to a different project");if(s.canonicalCacheDir!==n)throw _(e,"ownership record names a different cache directory");return{record:s,ownerSha256:At("sha256").update(o).digest("hex"),physicalCacheDir:e}}function qr(e,t){try{let n=JSON.parse(e);if(n.schemaVersion!==_t||typeof n.canonicalProjectRoot!="string"||typeof n.canonicalCacheDir!="string"||typeof n.creatorVersion!="string"||!Pt(n.canonicalProjectRoot)||!Pt(n.canonicalCacheDir))throw new Error("invalid fields");return n}catch(n){throw _(t,`malformed ownership record: ${n instanceof Error?n.message:String(n)}`)}}function Et(e){let t=Mt(e).filter(n=>n!==pe&&!Br(n));if(t.length>0)throw _(e,`unrecognized existing entries: ${t.slice(0,3).join(", ")}`)}function Br(e){return e.startsWith(`${pe}.tmp-`)||e.startsWith("git-worktree-context.json.tmp-")||[".scipquery-generations","affected-shadow-latest.json","affected-shadow.jsonl","agent-hooks","augment-vue-meta.json","cache-lifecycle.lock","evidence.db","evidence.db-shm","evidence.db-wal","health-report-cache.json","git-worktree-context.json","index.db","index.db-shm","index.db-wal","index.lock","index.scip","language-indexes","meta.json","reindex-activity.jsonl","shared-cache.json","typescript-index","typescript-scip-fragments","typescript-scip-overlays","typescript-semantic","typescript-shard-costs.json","watch-activity.json","watch-refresh-requests","watch-state.json","watch.lock"].includes(e)?!0:/^(?:reindex-|rust-|typescript-)/.test(e)}function Gr(e){for(let t of Mt(e)){let n=k(e,t);try{let r=Me(n);if(r.isSymbolicLink())throw _(e,`legacy cache entry ${t} is a symlink`);if(r.isDirectory())le(n);else if(r.isFile())Ft(n);else throw _(e,`legacy cache entry ${t} is not a file or directory`)}catch(r){if(Vr(r))continue;throw r}}le(e)}function Vr(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function Qr(e,t=Pe){let n=ae(e,t);return le(e),n}function $r(e,t,n){let r=`${e}.tmp-${process.pid}-${n.randomToken()}`,i,o=!1;try{i=n.openFile(r,"wx",384),o=!0,mt(i,Buffer.from(t),n,"cache ownership record"),n.syncFile(i),n.closeFile(i),i=void 0,n.linkFile(r,e);let s=O(_e(e),n);return n.removeFile(r),o=!1,G(s,O(_e(e),n))}finally{if(i!==void 0)try{n.closeFile(i)}catch{}if(o)try{n.removeFile(r)}catch{}}}function le(e){process.platform!=="win32"&&Ot(e,448)}function Ft(e){process.platform!=="win32"&&Ot(e,384)}function Ur(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EEXIST"}import{createHash as ni,randomUUID as ri}from"crypto";import{existsSync as ii,mkdirSync as Wc,readdirSync as qc,rmSync as Bc,statSync as oi}from"fs";import{basename as Vc,dirname as Wt,join as Te}from"path";function Tt(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.path=="string"&&typeof t.size=="number"&&Number.isFinite(t.size)&&typeof t.hash=="string"&&(t.semanticHash===void 0||typeof t.semanticHash=="string")}var U=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var De=2,fe=3;var Fe=new Set(U);function Nt(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(s){return{kind:"malformed",reason:`invalid JSON: ${ti(s)}`}}if(!l(t))return{kind:"malformed",reason:"metadata must be a JSON object"};let n=t.version;if(!Number.isInteger(n))return{kind:"malformed",reason:"version must be an integer"};if(n!==De&&n!==fe)return{kind:"unsupported",version:n,direction:n<De?"older":"future"};let r=Kr(t,n);if(r)return{kind:"malformed",reason:r};let i=t,o={metadata:i,capabilities:Hr(i)};return n===De?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function Lt(e){if(e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.stableGenerationIdentity)return null;let t=e.metadata;return JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages,scipCompanion:t.scipCompanion,sqliteLayoutVersion:t.version===fe?t.sqliteLayoutVersion:void 0})}function Hr(e){let t=e.fingerprint!==void 0,n=l(e.fingerprint),r=e.indexedLanguages!==void 0,i=e.status==="complete",o=e.version===fe?e:null;return{usableForQuery:r,usableForEvidenceCache:t,publishableGeneration:i&&n&&r,stableGenerationIdentity:i&&t&&typeof e.updatedAt=="string",languageShardReuse:!!o?.languageFingerprints,typescriptProjectShardReuse:!!o?.typescriptProjectShards}}function Kr(e,t){if(e.status!=="complete"&&e.status!=="partial")return"status must be complete or partial";if(e.updatedAt!==void 0&&!T(e.updatedAt))return"updatedAt must be a valid timestamp";let n=Jr(e);return n||(t===fe?Yr(e):null)}function Jr(e){for(let t of["requestedLanguages","indexedLanguages"])if(e[t]!==void 0&&!zr(e[t]))return`${t} must contain unique supported languages`;return e.skipped!==void 0&&!Xr(e.skipped)?"skipped must contain supported language/reason pairs":e.scipCompanion!==void 0&&e.scipCompanion!=="current"&&e.scipCompanion!=="deferred"?"scipCompanion must be current or deferred":null}function Yr(e){return e.sqliteLayoutVersion!==void 0&&(!Number.isSafeInteger(e.sqliteLayoutVersion)||e.sqliteLayoutVersion<1)?"sqliteLayoutVersion must be a positive safe integer":e.languageFingerprints!==void 0&&!Zr(e.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":e.typescriptProjectShards!==void 0&&!ei(e.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function zr(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string"&&Fe.has(t))?!1:new Set(e).size===e.length}function Xr(e){return Array.isArray(e)&&e.every(t=>l(t)&&typeof t.language=="string"&&Fe.has(t.language)&&typeof t.reason=="string")}function Zr(e){return l(e)&&Object.entries(e).every(([t,n])=>Fe.has(t)&&l(n))}function ei(e){return l(e)&&Object.values(e).every(t=>l(t)&&Array.isArray(t.files)&&t.files.every(Tt))}function ti(e){return e instanceof Error?e.message:String(e)}function E(){return performance.now()}var si=1;var ai=".scipquery-generations";var Kc={pid:process.pid,now:()=>new Date,randomToken:()=>ri(),isProcessAlive:Q,readProcessIdentity:V};function ci(e){return Te(Wt(e),ai)}function ui(e){try{let t=JSON.parse(R(Te(ci(e),"state.json"),"SQLite generation state"));return fi(t)?t:null}catch{return null}}function qt(e){let t=ui(e);if(t)return t.currentGeneration;try{let n=Te(Wt(e),"meta.json"),r=ii(n)?R(n,"reindex metadata"):void 0;return li(e,r)}catch{return null}}function di(e){return Lt(Nt(e))??e}function li(e,t){let n=ni("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&n.update(di(t)),n.update(`\0${pi(e)}`),n.digest("hex")}function pi(e){let t=oi(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function fi(e){return e.version===si&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&gi(e.stableMirrors)&&mi(e.previousGeneration)&&yi(e.publication)}function gi(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.databaseFileIdentity=="string"&&!!t.databaseFileIdentity&&(t.indexFileIdentity===void 0||typeof t.indexFileIdentity=="string"&&!!t.indexFileIdentity)}function mi(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.generationIdentity=="string"&&!!t.generationIdentity&&typeof t.databasePath=="string"&&!!t.databasePath&&(t.metadataPath===void 0||typeof t.metadataPath=="string"&&!!t.metadataPath)}function yi(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,n=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(r=>r!==void 0);return hi(t,n)&&bi(t)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}function hi(e,t){return(e.mode==="incremental"||e.mode==="full")&&e.validation==="passed"&&e.converterDurationMs!==void 0&&t.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=0)}function bi(e){return(e.scipCompanion===void 0||e.scipCompanion==="current"||e.scipCompanion==="deferred")&&(e.typescriptOverlayGeneration===void 0||typeof e.typescriptOverlayGeneration=="string"&&!!e.typescriptOverlayGeneration)&&(e.scipCompanion!=="deferred"||!!e.typescriptOverlayGeneration)}import{existsSync as Qi}from"fs";import{randomUUID as ou}from"crypto";import{isAbsolute as au,join as $i,relative as cu,resolve as uu}from"path";var L=1,H=2,Si="./node_modules/scip-query/docs/schemas/project-config.schema.json";function Bt(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(n){return{kind:"malformed",reason:`invalid JSON: ${n instanceof Error?n.message:String(n)}`}}return l(t)?vi(t):{kind:"malformed",reason:"project config must be a JSON object"}}function vi(e){let t=e.schemaVersion;if(t!==void 0&&!Number.isInteger(t))return{kind:"malformed",reason:"schemaVersion must be an integer"};let n=t===void 0?L:t;return n!==L&&n!==H?{kind:"unsupported",schemaVersion:n,direction:n<L?"older":"future"}:Ri(e,n)}function Ri(e,t){let n=e.$schema;if(n!==void 0&&(typeof n!="string"||n.trim()===""))return{kind:"malformed",reason:"$schema must be a non-empty string when present"};let r=Gt(e),i=t!==H||typeof e.$schema!="string";return t===L?{kind:"legacy",sourceVersion:L,config:r,needsMigration:i}:{kind:"supported",sourceVersion:H,config:r,needsMigration:i}}function Gt(e){let t=e,{$schema:n,schemaVersion:r,...i}=t;return{$schema:typeof n=="string"&&n.trim()!==""?n:Si,schemaVersion:H,...i}}import{createHash as Zc}from"crypto";var Ne=1,Vt=2,xi=1,Ii=1,wi="sha256";function Qt(e){if(!l(e))return{kind:"malformed",reason:"observation receipt must be an object"};let t=e.schemaVersion;if(!Number.isInteger(t))return{kind:"malformed",reason:"observation receipt schemaVersion must be an integer"};if(t===Ne)return Pi(e)?{kind:"legacy",schemaVersion:Ne,receipt:e}:{kind:"malformed",reason:"observation receipt v1 fields are malformed or contradictory"};if(t===Vt)return Ai(e)?{kind:"supported",schemaVersion:Vt,receipt:e}:{kind:"malformed",reason:"observation receipt v2 facts are malformed or contradictory"};let n=t;return{kind:"unsupported",schemaVersion:n,direction:n<Ne?"older":"future"}}function Ci(e,t){return e.schemaVersion===t.schemaVersion&&e.canonicalizationVersion===t.canonicalizationVersion&&e.hashAlgorithm===t.hashAlgorithm&&e.projection.name===t.projection.name&&e.projection.version===t.projection.version}function Pi(e){if(!l(e))return!1;let t=e.index,n=e.worktree;return T(e.observedAt)&&w(e.projectIdentity)&&Gi(e.authorityKind)&&ki(t)&&Ei(n)&&Bi(e.authorityKind,t,n)}function ki(e){return e===void 0||l(e)&&w(e.generationIdentity)&&(e.source==="immutable"||e.source==="legacy")&&(e.alignment==="not-certified"||e.alignment==="leased")}function Ei(e){return e===void 0||l(e)&&w(e.identity)&&typeof e.clean=="boolean"&&(e.headCommit===void 0||w(e.headCommit))&&(e.treeOid===void 0||w(e.treeOid))}function Ai(e){if(!l(e))return!1;let t=e.facts,n=e.observedSources;return!T(e.observedAt)||!l(t)||!Oi(n)||!Mi(e.stabilityProofs,n,t)||!_i(t)?!1:Fi(e.diagnostics)&&Wi(t,n)}function Oi(e){return Array.isArray(e)&&e.length>0&&e.every(Ni)&&We(e,t=>t.kind)}function Mi(e,t,n){return Array.isArray(e)&&e.every(Li)&&We(e,r=>r.source)&&!e.some(r=>!t.some(i=>i.kind===r.source))&&e.every(r=>qi(r,n))}function _i(e){return["collaborationDomain","repositoryLineage","workspaceInstance","wholeContent"].some(n=>e[n]!==void 0&&!D(e[n]))?!1:ji(e.relevantInputs)&&Di(e.index)}function ji(e){return e===void 0||Array.isArray(e)&&e.every(Ti)&&We(e,t=>`${t.subject}\0${t.identity.projection.name}`)}function Di(e){return e===void 0||l(e)&&D(e.generation)&&(e.inputs===void 0||D(e.inputs))&&(e.source==="immutable"||e.source==="legacy")}function Fi(e){return e===void 0||l(e)&&(e.clean===void 0||typeof e.clean=="boolean")&&(e.headCommit===void 0||w(e.headCommit))&&(e.treeOid===void 0||w(e.treeOid))}function D(e){return!l(e)||!l(e.projection)?!1:e.schemaVersion===xi&&e.canonicalizationVersion===Ii&&e.hashAlgorithm===wi&&w(e.projection.name)&&N(e.projection.version)&&ce(e.digest)}function Ti(e){return l(e)&&w(e.subject)&&D(e.identity)}function Ni(e){return l(e)&&$t(e.kind)&&(e.identity===void 0||D(e.identity))}function Li(e){return l(e)&&$t(e.source)&&(e.kind==="immutable"||e.kind==="fixed-snapshot"||e.kind==="bracketed"||e.kind==="not-established"||e.kind==="invalidated")}function Wi(e,t){let n=e.index,r=t.find(d=>d.kind==="index-generation");if(!Vi(n,r))return!1;let i=e.workspaceInstance,o=t.find(d=>d.kind==="live-workspace");if(o?.identity&&(!D(i)||!Le(o.identity,i)))return!1;let s=e.wholeContent,c=t.find(d=>d.kind==="repository-snapshot");return!(c?.identity&&(!D(s)||!Le(c.identity,s)))}function qi(e,t){return e.kind==="not-established"||e.kind==="invalidated"?!0:e.source==="index-generation"?e.kind==="immutable"&&l(t.index)&&t.index.source==="immutable":e.source==="repository-snapshot"?e.kind==="fixed-snapshot":e.source==="live-workspace"?e.kind==="bracketed":!1}function Le(e,t){return Ci(e,t)&&e.digest===t.digest}function Bi(e,t,n){return e==="index-worktree"?t!==void 0&&n!==void 0:e==="index-only"?t!==void 0&&n===void 0:e==="worktree-only"?t===void 0&&n!==void 0:e==="process-local"&&t===void 0&&n===void 0}function Gi(e){return e==="index-worktree"||e==="index-only"||e==="worktree-only"||e==="process-local"}function $t(e){return e==="index-generation"||e==="repository-snapshot"||e==="live-workspace"||e==="process"}function We(e,t){return new Set(e.map(t)).size===e.length}function Vi(e,t){if(t){if(!l(e)||!D(e.generation)||t.identity&&!Le(t.identity,e.generation))return!1}else if(e!==void 0)return!1;return!0}var ge=".scipquery.json";var fu=15*6e4,gu={enabled:!0,windowMs:15*6e4,maxRebuilds:2,maxEstimatedWriteBytes:1024*1024*1024};var mu=new Set(U);function Ut(e){let t=$i(e,ge);if(!Qi(t))return{};let n;try{n=B(t,{maxBytes:se,inputKind:"scip-query project config"})}catch(r){let i=r instanceof Error?r.message:String(r);throw new Error(`unable to read ${ge} at ${t}: ${i}`,{cause:r})}return Ui(Bt(n),t,"read").config}function Ui(e,t,n){if(e.kind==="legacy"||e.kind==="supported")return e;if(e.kind==="malformed"){let i=n==="read"?`invalid ${ge} at ${t}: ${e.reason}`:`Cannot update ${t}: the latest project config is ${e.reason}.`;throw new Error(`${i} The file was left untouched.`)}let r=n==="read"?`invalid ${ge} at ${t}`:`Cannot update ${t}: the latest project config is invalid`;throw new Error(`${r} (unsupported ${e.direction} schemaVersion ${e.schemaVersion}; this scip-query reads legacy v${L} and current v${H}). Upgrade scip-query before retrying; the file was left untouched.`)}import{spawnSync as Hi}from"child_process";import{createHash as Ki}from"crypto";import{existsSync as Ji,lstatSync as Yi,realpathSync as zi}from"fs";import{dirname as Xi,isAbsolute as Zi,join as eo,relative as Iu,resolve as ye,sep as wu}from"path";var Ht=Symbol.for("scip-query.project-file-listing-context.v1"),Kt=globalThis,qe=Kt[Ht],Jt=qe&&typeof qe=="object"?qe:{};Kt[Ht]=Jt;function Yt(){return Jt.sequence??0}var Ge={run(e,t){let n=Zt(e,t);return n.kind==="success"?n.output:void 0},runResult:Zt},to=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],en=["status","--porcelain=v2","--branch","-z","--untracked-files=all"],Be=/^[0-9a-f]{40,64}$/;function tn(e,t=Ge){return no(e,t)?.context}function no(e,t=Ge){let n=t.runResult(e,to);if(n.kind==="success"){let i=ro(n.output);if(i){let o=io(i,t);if(o)return zt(o)}}let r=oo(e,t);return r?zt(r):void 0}function zt(e){return{context:e,projectFileInventorySequence:Yt()}}function nn(e){let t=e.split("\0").filter(Boolean),n=t.find(i=>i.startsWith("# branch.oid "))?.slice(13),r=n==="(initial)"?void 0:n;if(!(r!==void 0&&!Be.test(r))&&n!==void 0)return{headCommit:r,clean:t.every(i=>i.startsWith("# "))}}function ro(e){let t=e.split(`
3
+ `).map(d=>d.trim());if(t.length!==5)return;let[n,r,i,o,s]=t;if(!n||!r||!i||!o||!s||!Be.test(o)||!Be.test(s))return;let c=A(n);return{root:c,gitDir:A(me(c,r)),commonDir:A(me(c,i)),headCommit:o,treeOid:s}}function io(e,t){let n=t.run(e.root,en);if(n===void 0)return;let r=nn(n);return r?.headCommit!==e.headCommit?void 0:{...rn(e.root,e.gitDir),commonDir:e.commonDir,repositoryId:Qe("repository",e.commonDir),headCommit:e.headCommit,treeOid:e.treeOid,clean:r.clean}}function oo(e,t){let n=Ve(e,t);if(n.kind!=="worktree")return;let r=n.identity,i=r.projectRoot,o=t.run(i,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=A(me(i,o)),c=Xt(t.run(i,["rev-parse","--verify","HEAD"])),d=Xt(t.run(i,["rev-parse","--verify","HEAD^{tree}"])),p=t.run(i,en);if(p===void 0)return;let y=nn(p);if(!(!y||y.headCommit!==c))return{...r,commonDir:s,repositoryId:Qe("repository",s),headCommit:c,treeOid:d,clean:y.clean}}function Ve(e,t=Ge){let n=t.runResult(e,["rev-parse","--show-toplevel"]);if(n.kind==="not-repository")return{kind:"non-git"};if(n.kind==="error")return n;let r=n.output.trim();if(!r)return{kind:"error",message:"Git returned an empty worktree root."};let i=A(r),o=t.run(i,["rev-parse","--absolute-git-dir"])?.trim();if(!o)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=A(me(i,o));return{kind:"worktree",identity:rn(i,s)}}function rn(e,t){return{projectRoot:e,gitDir:t,worktreeId:Qe("worktree",`${e}\0${t}`)}}function me(e,t){return Zi(t)?t:ye(e,t)}function A(e){try{return zi(e)}catch{return ye(e)}}function Qe(e,t){return Ki("sha256").update(`${e}\0${t}`).digest("hex").slice(0,24)}function Xt(e){return e?.trim()||void 0}function Zt(e,t){let n=Hi("git",["-C",e,...t],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"],timeout:3e4,killSignal:"SIGKILL"});if(n.status===0)return{kind:"success",output:n.stdout.trimEnd()};let i=(typeof n.stderr=="string"?n.stderr.trim():"")||n.error?.message||`git exited with status ${n.status??"unknown"}`,o=n.error?.code;return(/not a git repository/i.test(i)||o==="ENOENT"&&Ji(ye(e)))&&!so(e)?{kind:"not-repository"}:{kind:"error",message:i}}function so(e){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let t=ye(e);for(;;){try{return Yi(eo(t,".git")),!0}catch(r){let i=r.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let n=Xi(t);if(n===t)return!1;t=n}}function $e(){return process.env.SCIP_QUERY_PROJECT_ROOT??process.cwd()}var on;function sn(e=$e(),t=void 0){if(t===void 0&&on?.projectRoot===e)return on;let n=Ut(e),r=Dt(e,n),i=process.env.SCIP_QUERY_INDEX_DB;if(i)return{projectRoot:e,config:n,paths:r,dbPath:i,dbPathSource:"env",gitContext:t};if(ao(r.dbPath))return{projectRoot:e,config:n,paths:r,dbPath:r.dbPath,dbPathSource:"configured",gitContext:t};let o=uo(e,"index.db");return{projectRoot:e,config:n,paths:r,dbPath:o,dbPathSource:"root-fallback",rootFallbackWarning:lo(o,r.dbPath),gitContext:t}}function lo(e,t){let n="unknown time";try{n=co(e).mtime.toISOString()}catch{}return`warning: using legacy project-root index.db (${e}, modified ${n}) because the configured index was not found at ${t}. This fallback may be stale; run 'scip-query reindex' to refresh the configured index.`}import{basename as po}from"path";function an(e=process.argv,t=process.execPath){let n=e[1];return!n||po(n)==="scip-query"?["scip-query"]:[t,n]}var cn={context:2,limit:6},un={context:0,members:"exported"};function Ue(e,t=Number.MIN_SAFE_INTEGER){if(!/^[+-]?\d+$/u.test(e))return null;let n=Number(e);return Number.isSafeInteger(n)&&n>=t?n:null}import{spawn as ls}from"child_process";import{createHash as xe,randomUUID as ps}from"crypto";import{existsSync as nt,realpathSync as fs}from"fs";import{tmpdir as gs}from"os";import{join as rt,resolve as oe}from"path";import{fileURLToPath as ms}from"url";function ne(e){return He(e,fo)}function He(e,t){return Array.isArray(e)?`[${e.map(n=>He(n,t)).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).sort(([n],[r])=>t(n,r)).map(([n,r])=>`${JSON.stringify(n)}:${He(r,t)}`).join(",")}}`:JSON.stringify(e)}function fo(e,t){return e<t?-1:e>t?1:0}import{createHash as Nu,randomUUID as fn}from"crypto";import{closeSync as Wu,existsSync as Y,fstatSync as qu,lstatSync as ie,mkdirSync as Bu,openSync as Gu,readdirSync as J,readSync as Vu,renameSync as gn,rmSync as F}from"fs";import{basename as he,dirname as go,join as g}from"path";var be=1,mo=Object.freeze({maxItems:1024,maxBytes:512*1024*1024,maxItemBytes:64*1024*1024,maxBatch:16,claimLeaseMs:5*6e4,responseRetentionMs:10*6e4,deadLetterRetentionMs:1440*6e4,temporaryRetentionMs:6e4,cleanupBatch:64}),K=class extends Error{constructor(n,r,i,o){let s=n==="item-too-large"?`request is ${o} bytes; per-item limit is ${i.maxItemBytes}`:n==="item-capacity"?`mailbox has ${r.totalItems} retained items; limit is ${i.maxItems}`:n==="byte-capacity"?`mailbox retains ${r.totalBytes} bytes and the request adds ${o}; limit is ${i.maxBytes}`:"another writer held the admission coordinator through the bounded wait";super(`Mailbox backpressure: ${s}. Retry after the service drains or expires retained work.`);this.code=n;this.status=r;this.limits=i;this.attemptedBytes=o;this.name="MailboxBackpressureError"}code;status;limits;attemptedBytes},yo=".owner.json",ho={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function mn(e){return{rootDir:e,pendingDir:g(e,"pending"),inflightDir:g(e,"inflight"),responseDir:g(e,"responses"),deadLetterDir:g(e,"dead-letter"),legacyRequestDir:g(e,"requests")}}function bo(e={}){let t={...mo,...e};for(let[n,r]of Object.entries(t))if(!Number.isFinite(r)||r<=0||!Number.isInteger(r))throw new Error(`Mailbox limit ${n} must be a positive integer.`);return t}function yn(e){let t=[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir].map(n=>ae(n));return G(...t)}function Se(e){if(!/^[a-f0-9]{64}$/.test(e))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${e}`}function hn(e,t,n={}){let r=bo(n.limits),i=n.nowMs??Date.now(),o=yn(e);return Oo(t),wo(e,r,n.admissionLockTimeoutMs??2e3,n.monotonicNow??E,n.durability??"durable",()=>{Io(e,i,r);let s=g(e.pendingDir,`${t.id}.json`),c=g(e.responseDir,`${t.id}.json`),d=dn(e,t.id);if(d){let b=ln(d,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:c,authoritativeDeadlineAtMs:b.deadlineAtMs??t.deadlineAtMs}}let p=`${JSON.stringify(t)}
4
+ `,y=Buffer.byteLength(p);No(e,y,r),n.onBeforePublish?.();try{let b=n.durability??"durable",C=Ee(s,p,{durability:b}),q=b==="durable"?G(o,C.directorySync):"not-requested";return{disposition:"accepted",requestId:t.id,responsePath:c,authoritativeDeadlineAtMs:t.deadlineAtMs,achievedDurability:C.achievedDurability,directorySync:q}}catch(b){if(b.code!=="EEXIST")throw b;let C=dn(e,t.id);if(!C)throw b;let q=ln(C,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:c,authoritativeDeadlineAtMs:q.deadlineAtMs??t.deadlineAtMs}}})}function So(e,t,n,r,i){let o=g(e.responseDir,`${t.requestId}.json`);if(Y(o))return F(t.path,{force:!0}),i.completedClaimsRemoved++,!0;if(t.claimExpiresAtMs>n||Eo(e,t.ownerId,r)!=="dead")return!1;let s=g(e.pendingDir,t.originalFile);try{gn(t.path,s),i.reclaimed++}catch(c){if(c.code!=="EEXIST")throw c;F(t.path,{force:!0})}return O(go(t.path)),O(e.pendingDir),!0}function vo(e,t,n,r,i){for(let o of Je(e.inflightDir)){if(n<=0)break;So(e,o,t,r,i)&&n--}return n}function Ro(e,t,n){if(!he(e).includes(".tmp-"))return!1;let r;try{r=ie(e).mtimeMs}catch(i){if(i.code==="ENOENT")return!1;throw i}return r+n>t?!1:(F(e,{force:!0}),!0)}function xo(e,t,n,r,i){for(let o of[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir]){if(r<=0)break;for(let s of Sn(o)){if(r<=0)break;Ro(s,t,n.temporaryRetentionMs)&&(i.temporaryFilesRemoved++,r--)}}}function Io(e,t,n,r=ho){let i={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=n.cleanupBatch;return o=vo(e,t,o,r,i),o=pn(e.responseDir,o,(s,c)=>c+n.responseRetentionMs,t,()=>{i.responsesRemoved++}),o=pn(e.deadLetterDir,o,(s,c)=>c+n.deadLetterRetentionMs,t,()=>{i.deadLettersRemoved++}),xo(e,t,n,o,i),Do(e.inflightDir),i}function bn(e){yn(e);let t=[...re(e.pendingDir).map(d=>({path:d,pending:!0})),...re(e.legacyRequestDir).map(d=>({path:d,pending:!0}))],n=Je(e.inflightDir).map(d=>({path:d.path,pending:!1})),r=re(e.responseDir).map(d=>({path:d,pending:!1})),i=re(e.deadLetterDir).map(d=>({path:d,pending:!1})),o=[...t,...n,...r,...i],s=0,c;for(let d of t){let p=Ye(d.path);if(!p){s++;continue}let y=p.enqueuedAtMs;if(y===void 0)try{y=ie(d.path).mtimeMs}catch(b){if(b.code==="ENOENT")continue;throw b}c=c===void 0?y:Math.min(c,y)}return{pending:t.length,inflight:n.length,responses:r.length,deadLetters:i.length,invalid:s,totalItems:o.length,totalBytes:o.reduce((d,p)=>d+Fo(p.path),0),...c===void 0?{}:{oldestPendingAt:new Date(c).toISOString()}}}function wo(e,t,n,r,i,o){let s=g(e.rootDir,".admission.lock"),c=`${process.pid}-${fn()}`,d=r()+Math.max(0,n);for(;!Co(e.rootDir,s,c,i);){if(Po(s),r()>=d)throw new K("admission-busy",bn(e),t,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return o()}finally{try{Ke(s).ownerToken===c&&(F(s,{recursive:!0,force:!0}),i==="durable"&&O(e.rootDir))}catch{}}}function Co(e,t,n,r){let i=`${JSON.stringify({ownerToken:n,pid:process.pid,acquiredAtMs:Date.now()})}
5
+ `;try{return Ee(t,i,{durability:r}),!0}catch(o){if(o.code==="EEXIST")return!1;try{Ke(t).ownerToken===n&&(F(t,{force:!0}),r==="durable"&&O(e))}catch{}throw o}}function Po(e){let t=null;try{let r=Ke(e);typeof r.ownerToken=="string"&&Number.isSafeInteger(r.pid)&&Number(r.pid)>0&&(t=Number(r.pid))}catch{}if(t===null||ko(t))return;let n=`${e}.stale-${fn()}`;try{gn(e,n)}catch(r){let i=r.code;if(i==="ENOENT"||i==="EEXIST")return;throw r}F(n,{recursive:!0,force:!0})}function Ke(e){try{return JSON.parse(R(e,"mailbox lock record"))}catch(t){if(t.code!=="EISDIR"&&!(t instanceof pt&&t.reason==="not-regular"))throw t;return JSON.parse(R(g(e,"owner.json"),"mailbox lock owner record"))}}function ko(e){try{return process.kill(e,0),!0}catch(t){let n=t.code;return n==="EPERM"||n!=="ESRCH"}}function Eo(e,t,n){let r=Ao(g(e.inflightDir,vn(t),yo));if(!r)return"unknown";if(!n.isProcessAlive(r.pid))return"dead";if(!r.processIdentity)return"live";let i=n.readProcessIdentity(r.pid);return i?Z(r.processIdentity,i)?"live":"dead":"unknown"}function Ao(e){try{let t=JSON.parse(R(e,"mailbox owner record"));if(!To(t))return null;let n=t.processIdentity===void 0?null:M(t.processIdentity);return t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{version:1,ownerId:t.ownerId,pid:t.pid,...n?{processIdentity:n}:{}}}catch{return null}}function dn(e,t){for(let n of[g(e.pendingDir,`${t}.json`),g(e.legacyRequestDir,`${t}.json`),g(e.responseDir,`${t}.json`)])if(Y(n))return n;for(let n of Je(e.inflightDir))if(n.requestId===t)return n.path;return null}function ln(e,t,n){let r=Ye(e);if(r?.operationKey===t)return r;if(he(e)===`${Se(t)}.json`)return{id:n,operationKey:t};throw new Error(`Mailbox operation ${n} conflicts with an existing retained record.`)}function Oo(e){if(e.mailboxVersion!==be||e.id!==Se(e.operationKey)||!e.clientId.trim()||!Number.isFinite(e.enqueuedAtMs)||!Number.isFinite(e.deadlineAtMs)||e.deadlineAtMs<e.enqueuedAtMs)throw new Error("Mailbox request has an invalid lifecycle identity.")}function Mo(e){let t=/^(.*)\.(\d+)\.claim$/.exec(e);if(!t)return null;let n=Rn(t[1]),r=Number(t[2]);return n===null||he(n)!==n||!n.endsWith(".json")||!Number.isSafeInteger(r)?null:{originalFile:n,claimExpiresAtMs:r}}function _o(e,t,n){let r=Mo(n);if(!r)return null;let{originalFile:i,claimExpiresAtMs:o}=r,s=g(e,n),c=Ye(s)??{id:he(i,".json")},d;try{d=ie(s)}catch(p){if(p.code==="ENOENT")return null;throw p}return{requestId:c.id,ownerId:t,path:s,originalFile:i,claimedAtMs:d.mtimeMs,claimExpiresAtMs:o,byteLength:d.size,...c.operationKey?{operationKey:c.operationKey}:{},...c.clientId?{clientId:c.clientId}:{},...c.enqueuedAtMs===void 0?{}:{enqueuedAtMs:c.enqueuedAtMs},...c.deadlineAtMs===void 0?{}:{deadlineAtMs:c.deadlineAtMs},legacy:c.operationKey===void 0}}function jo(e,t){let n=[];for(let r of J(e,{withFileTypes:!0})){if(!r.isFile()||!r.name.endsWith(".claim"))continue;let i=_o(e,t,r.name);i&&n.push(i)}return n}function Je(e){if(!Y(e))return[];let t=[];for(let n of J(e,{withFileTypes:!0})){if(!n.isDirectory())continue;let r=Rn(n.name);r!==null&&t.push(...jo(g(e,n.name),r))}return t.sort((n,r)=>n.claimedAtMs-r.claimedAtMs||n.path.localeCompare(r.path))}function Ye(e){try{let t=JSON.parse(R(e,"mailbox record"));return typeof t.id!="string"||!t.id?null:{id:t.id,...typeof t.operationKey=="string"?{operationKey:t.operationKey}:{},...typeof t.clientId=="string"?{clientId:t.clientId}:{},...typeof t.enqueuedAtMs=="number"?{enqueuedAtMs:t.enqueuedAtMs}:{},...typeof t.deadlineAtMs=="number"?{deadlineAtMs:t.deadlineAtMs}:{}}}catch{return null}}function pn(e,t,n,r,i){for(let o of re(e)){if(t<=0)break;let s;try{s=ie(o)}catch(c){if(c.code==="ENOENT")continue;throw c}n(o,s.mtimeMs)>r||(F(o,{force:!0}),i(),t--)}return t}function re(e){return Y(e)?J(e,{withFileTypes:!0}).filter(t=>t.isFile()).map(t=>g(e,t.name)).sort():[]}function Sn(e){if(!Y(e))return[];let t=[];for(let n of J(e,{withFileTypes:!0})){let r=g(e,n.name);n.isFile()?t.push(r):n.isDirectory()&&t.push(...Sn(r))}return t.sort()}function Do(e){if(Y(e))for(let t of J(e,{withFileTypes:!0})){if(!t.isDirectory())continue;let n=g(e,t.name);J(n).some(r=>r.endsWith(".claim"))||F(n,{recursive:!0,force:!0})}}function Fo(e){try{return ie(e).size}catch{return 0}}function vn(e){return Buffer.from(e,"utf8").toString("base64url")}function Rn(e){try{let t=Buffer.from(e,"base64url").toString("utf8");return vn(t)===e?t:null}catch{return null}}function To(e){return!(e.version!==1||typeof e.ownerId!="string"||!e.ownerId||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0)}function No(e,t,n){let r=bn(e);if(t>n.maxItemBytes)throw new K("item-too-large",r,n,t);if(r.totalItems+1>n.maxItems)throw new K("item-capacity",r,n,t);if(r.totalBytes+t>n.maxBytes)throw new K("byte-capacity",r,n,t)}import{spawn as es}from"child_process";import{existsSync as ts,rmSync as cd}from"fs";import{dirname as dd,resolve as ns}from"path";import{fileURLToPath as pd}from"url";import{join as ve}from"path";var Lo={"manual-cli":!0,setup:!0,"watch-source":!0,"watch-startup":!0,"watch-demand":!0,"watch-git-head":!0,"watch-git-index":!0,"watch-git-state":!0,unknown:!0};function ze(e){return typeof e=="string"&&Object.hasOwn(Lo,e)}var In=6,wn=1e4,Wo="watch.lock",qo="watch-state.json",Bo="watch-activity.json",Go="watch-refresh-requests";function Cn(e){return{lockPath:ve(e,Wo),statePath:ve(e,qo),activityPath:ve(e,Bo),refreshRequestsPath:ve(e,Go)}}function Pn(e){try{return Vo(JSON.parse(R(e,"watch service state")))}catch{return null}}function Vo(e){if(!h(e,{version:n=>n===1,protocolVersion:N,pid:N,projectRoot:x,worktreeId:u(n=>x(n)&&n.length>0),cliVersion:x,startedAt:f,heartbeatAt:f,lastActivityAt:f,idleDeadlineAt:u(f),watcher:Qo,indexGeneration:u(ce),lastError:u($o),lastRefresh:u(Uo),reindexActivity:u(Ho),refreshRequests:u(zo),typescriptSemantic:u(Xo),typescriptIndex:u(Zo)}))return null;if(e.processIdentity===void 0)return e;let t=M(e.processIdentity);return!t||t.pid!==e.pid?null:{...e,processIdentity:t}}function f(e){return T(e)}function h(e,t){return l(e)&&Object.entries(t).every(([n,r])=>r(e[n]))}function u(e){return t=>t===void 0||e(t)}function x(e){return typeof e=="string"}function Qo(e){if(!l(e))return!1;switch(e.state){case"idle":return!0;case"waiting":return h(e,{changedFiles:a,reindexAt:I});case"indexing":return h(e,{startedAt:I});case"cooldown":return h(e,{until:I,dirty:Ze});case"budget-paused":return h(e,{until:I,dirty:Ze,reason:x,rebuilt:a,estimatedWriteBytes:a});case"draining":return h(e,{startedAt:I,reason:x});default:return!1}}function $o(e){return h(e,{at:f,message:x})}function Uo(e){return h(e,{trigger:t=>h(t,{kind:ze,detail:u(x)}),result:t=>t==="rebuilt"||t==="reused"||t==="failed",startedAt:f,completedAt:f,durationMs:I,indexedLanguages:u(t=>Array.isArray(t)&&t.every(Xe)),skipped:u(t=>Array.isArray(t)&&t.every(n=>h(n,{language:Xe,reason:x}))),error:u(x)})}function Xe(e){return x(e)&&U.includes(e)}function xn(e){return e==="complete"||e==="partial"||e==="unavailable"}function Ho(e){return h(e,{confidence:u(xn),recordsRead:u(a),invalidRecords:u(a),skippedRecords:u(a),readErrors:u(a),ignoredPartialTailBytes:u(a),windowStartedAt:f,windowEndedAt:f,runs:a,rebuilt:a,fullRebuilds:u(a),reused:a,failed:a,suppressed:a,estimatedLogicalOutputBytes:I,estimatedWriteBytes:u(a),reflinkedBytes:u(a),fallbackCopiedBytes:u(a),oldestRebuildAt:u(f),oldestWriteAt:u(f),languageAttribution:u(xn),attributedRuns:u(a),unattributedRuns:u(a),invalidLanguageDetails:u(a),byTrigger:t=>l(t)&&Object.entries(t).every(([n,r])=>ze(n)&&(r===void 0||a(r))),byLanguage:u(Jo),automatic:u(Ko)})}function Ko(e){return h(e,{runs:a,rebuilt:a,fullRebuilds:a,estimatedWriteBytes:a,oldestRebuildAt:u(f),oldestWriteAt:u(f)})}function Jo(e){return l(e)&&Object.entries(e).every(([t,n])=>Xe(t)&&Yo(n))}function Yo(e){return h(e,{runs:a,rebuilt:a,reused:a,producedOutputBytes:a,durationMs:I})?e.rebuilt+e.reused===e.runs:!1}function zo(e){return h(e,{pending:a,claimed:a,completed:a,expired:a,invalid:a,oldestPendingAt:u(f)})}function kn(e){return e==="idle"||e==="ready"||e==="unavailable"||e==="error"}function Xo(e){return h(e,{protocolVersion:N,state:kn,requests:a,sessionsCreated:a,sessionsReused:a,sessionsRefreshed:a,sessionsReplaced:a,projectsCreated:a,lastRequestAt:u(f),lastError:u(x),busyUntil:u(f),mailbox:u(En)})}function Ze(e){return typeof e=="boolean"}function Zo(e){return h(e,{protocolVersion:N,state:kn,requests:a,sessionsCreated:a,sessionsReplaced:a,sessionsEvicted:u(a),activeSessions:u(a),maxActiveSessions:u(a),heapUsedBytes:u(a),heapLimitBytes:u(a),softMemoryLimitBytes:u(a),retireRequested:u(Ze),initializations:a,programUpdates:a,documentsEmitted:a,documentsRemoved:a,lastRequestAt:u(f),lastDurationMs:u(I),lastError:u(x),busyUntil:u(f),mailbox:u(En)})}function En(e){return h(e,{pending:a,inflight:a,responses:a,deadLetters:a,invalid:a,totalItems:a,totalBytes:I,oldestPendingAt:u(f)})?e.totalItems===e.pending+e.inflight+e.responses+e.deadLetters:!1}function An(e){let t=e.classification;if(t.kind!=="live")return;let{state:n}=t;return n.watcher.state==="idle"&&n.lastError===void 0?n.indexGeneration:void 0}function rs(e,t,n){let r=A(ns(e));if(n&&A(n.projectRoot)===r)return{projectRoot:r,worktreeKind:"git",worktreeId:n.worktreeId,cliVersion:t};let i=Ve(r);if(i.kind==="error")throw new Error(`Could not establish Git worktree identity for ${r}: ${i.message}`);return i.kind==="non-git"?{projectRoot:r,worktreeKind:"non-git",cliVersion:t}:{projectRoot:r,worktreeKind:"git",worktreeId:i.identity.worktreeId,cliVersion:t}}function On(e){return is(e,rs(e.projectRoot,e.cliVersion,e.gitContext))}function is(e,t){let n=e.runtime??us,r=Cn(e.cacheDir),i=Pn(r.statePath),o=os(r.lockPath);return{identity:t,classification:cs(i,t,n.now(),n.isProcessAlive),lock:o,lockIsLive:o!==null&&n.isProcessAlive(o.pid),paths:r}}function os(e){return as(ht(e,{parseLegacy:ss}))}var ss=e=>{let t=Mn(e);return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function as(e){if(e.state==="valid"&&e.record?.kind==="watch"){let t=e.record.detail?.projectRoot;return typeof t!="string"?null:{version:1,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},projectRoot:t,startedAt:e.record.startedAt}}return Mn(e.parsed)}function Mn(e){try{let t=yt(e),n=e;if(!t||Object.hasOwn(n,"protocol")||n.version!==1||typeof n.projectRoot!="string"||!f(n.startedAt))return null;let r=n.processIdentity===void 0?null:M(n.processIdentity);return ds(n.processIdentity,r,t.pid)?null:{version:1,pid:t.pid,...r?{processIdentity:r}:{},projectRoot:n.projectRoot,startedAt:n.startedAt}}catch{return null}}function cs(e,t,n,r){if(!e)return{kind:"stopped"};if(e.protocolVersion!==In)return{kind:"incompatible",state:e,reason:"protocol"};if(e.projectRoot!==t.projectRoot)return{kind:"incompatible",state:e,reason:"project"};let i=t.worktreeKind==="git"?t.worktreeId:void 0;if(e.worktreeId!==i)return{kind:"incompatible",state:e,reason:"worktree"};if(e.cliVersion!==t.cliVersion)return{kind:"incompatible",state:e,reason:"cli-version"};if(!r(e.pid))return{kind:"stale",state:e,reason:"dead-process"};let o=Date.parse(e.heartbeatAt);return n-o>wn?{kind:"stale",state:e,reason:"old-heartbeat"}:{kind:"live",state:e}}var us={now:Date.now,monotonicNow:E,isProcessAlive:Q,readProcessIdentity:V,spawnServer(e,t,n,r){if(!ts(e))throw new Error(`Watch service helper was not found at ${e}. Run npm run build first.`);es(process.execPath,[e,t,n,JSON.stringify(r)],{detached:!0,stdio:"ignore",env:{...process.env,SCIP_QUERY_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(e){process.kill(e,"SIGTERM")},forceSignalProcess(e){process.kill(e,"SIGKILL")},sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)}};function ds(e,t,n){return e!==void 0&&(!t||t.pid!==n)}var W=27,ys=1e3,hs=2*ys,bs=4,Re=4,et=5,Ss=3,vs=4,Rs=3,xs=8,_n=3e4,Is=5e3,Dn=5,ws=10,Cs=1,Ps=5,it=64*1024*1024,ks=new Map([["dependence-slice",Rs],["call-graph",Ss],["system",vs],["refs",et],["imports",et],["unused-imports",et],["imported-by",Re],["hierarchy",Re],["by-kind",Re],["kind-counts",Re]]),Es={maxItems:64,maxBytes:128*1024*1024,maxItemBytes:it,maxBatch:1,responseRetentionMs:6e4};function Fn(e,t,n={},r={}){return m(e,i=>({kind:"source-search",expectedGeneration:i,pattern:t,options:n}),ya,"search result",r)}function Tn(e,t,n={}){return m(e,r=>({kind:"outline",expectedGeneration:r,filePattern:t}),Ls,"outline result",n)}function Nn(e,t={},n={}){return m(e,r=>({kind:"entrypoints",expectedGeneration:r,options:t}),qs,"entrypoints result",n)}function Ln(e,t,n={}){return m(e,r=>({kind:"files",expectedGeneration:r,pattern:t}),Qs,"files result",n)}function Wn(e,t={}){return m(e,n=>({kind:"stats",expectedGeneration:n}),$s,"stats result",t)}function qn(e,t,n={}){return m(e,r=>({kind:"members",expectedGeneration:r,symbolPattern:t}),Us,"members result",n)}function Bn(e,t,n={}){return m(e,r=>({kind:"methods",expectedGeneration:r,className:t}),Js,"methods result",n)}function Gn(e,t,n,r={}){return m(e,i=>({kind:"file-dependencies",expectedGeneration:i,direction:t,filePattern:n}),Ys,"file dependencies result",r)}function Vn(e,t,n={}){return m(e,r=>({kind:"imported-by",expectedGeneration:r,symbolPattern:t}),ir,"imported-by result",n)}function Qn(e,t,n={}){return m(e,r=>({kind:"hierarchy",expectedGeneration:r,symbolPattern:t}),ea,"hierarchy result",n)}function $n(e,t,n={}){return m(e,r=>({kind:"by-kind",expectedGeneration:r,kindQuery:t}),na,"by-kind result",n)}function Un(e,t={}){return m(e,n=>({kind:"kind-counts",expectedGeneration:n}),ia,"kind-counts result",t)}function Hn(e,t,n={}){return m(e,r=>({kind:"refs",expectedGeneration:r,symbolPattern:t}),sa,"refs result",n)}function Kn(e,t,n={}){return m(e,r=>({kind:"dependence-slice",expectedGeneration:r,criterion:t}),we,"dependence-slice result",n)}function Jn(e,t,n,r={}){return m(e,i=>({kind:t,expectedGeneration:i,symbolPattern:n}),we,`${t} result`,r)}function Yn(e,t,n={}){return m(e,r=>({kind:"system",expectedGeneration:r,modulePattern:t}),we,"system result",n)}function zn(e,t,n={}){return m(e,r=>({kind:"imports",expectedGeneration:r,filePattern:t}),ir,"imports result",n)}function Xn(e,t,n={}){return m(e,r=>({kind:"unused-imports",expectedGeneration:r,filePattern:t}),zs,"unused imports result",n)}function Zn(e,t,n={}){return m(e,r=>({kind:"surface",expectedGeneration:r,modulePattern:t}),ca,"surface result",n)}function er(e,t,n,r={}){return m(e,i=>({kind:"code",expectedGeneration:i,selectors:[...t],options:n}),we,"serialized code result",r)}function m(e,t,n,r,i){if(!va(i.allowDefault===!0))return null;try{let o=i.allowDefault===!0&&process.env.SCIP_QUERY_QUERY_SERVICE!=="1",s=o?tn(e):void 0,c=sn(e,s);if(!nt(c.dbPath))return null;let d=qt(c.dbPath);if(!d||o&&!As(c,s,d))return null;let p=Ds({projectRoot:c.projectRoot,dbPath:c.dbPath,generationIdentity:d,configurationIdentity:ne(c.config)},t(d),n,r);return{result:p.result,generationIdentity:d,observationReceipt:p.observationReceipt}}catch(o){return ka(o),null}}function As(e,t,n){if(e.config.watch?.enabled!==!0)return!1;try{return An(On({projectRoot:e.projectRoot,cacheDir:e.paths.cacheDir,cliVersion:$,gitContext:t}))===n}catch{return!1}}function tr(e){return xe("sha256").update(ne({kind:"scip-query-service-mailbox",protocolVersion:W,sessionDir:oe(e)})).digest("hex")}function nr(e){let t=rt(e,"server.json");try{let n=JSON.parse(B(t,{maxBytes:65536,inputKind:"query service state"}));if(!n||typeof n!="object"||Array.isArray(n))return null;let r=n,i=r.processIdentity===void 0?void 0:M(r.processIdentity);return!Os(r,e)||!Ms(r,i)||!_s(r)?null:{protocolVersion:W,sessionIdentity:r.sessionIdentity,pid:r.pid,...i?{processIdentity:i}:{},generation:r.generation,heartbeatAtMs:r.heartbeatAtMs}}catch{return null}}function Os(e,t){return e.protocolVersion===W&&typeof e.sessionIdentity=="string"&&e.sessionIdentity===tr(t)}function Ms(e,t){return typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0&&(e.processIdentity===void 0||!!(t&&t.pid===e.pid))}function _s(e){return typeof e.generation=="string"&&typeof e.heartbeatAtMs=="number"&&Number.isFinite(e.heartbeatAtMs)}function rr(e,t=Date.now()){if(!Q(e.pid))return!1;let n=t-e.heartbeatAtMs;if(n>=0&&n<=hs||!e.processIdentity)return!0;let r=V(e.pid);return r!==null&&Z(e.processIdentity,r)}function js(e){let t=e<ws;return{intervalMs:t?Cs:Dn,checkServerState:!t||e%Ps===0}}function Ds(e,t,n,r){let i=Sa();if(!nt(i))throw new Error("Query service server executable is unavailable.");let o=Math.abs(process.pid)%xa(t),s=ba(e,i,o),c=mn(s),d=Date.now(),p=d+_n,y=E()+_n,b=ps(),C=Fs(b,t),q=Se(C),gr=tr(s),Ce=hn(c,{mailboxVersion:be,protocolVersion:W,id:q,operationKey:C,clientId:b,enqueuedAtMs:d,deadlineAtMs:p,sessionIdentity:gr,request:t},{nowMs:d,limits:Es,durability:"visibility"});jn(s,e.projectRoot,i,y);let ut=0;for(;E()<=y;){if(nt(Ce.responsePath))return Ts(B(Ce.responsePath,{maxBytes:it,inputKind:"query service response"}),{id:q,operationKey:C,clientId:b,deadlineAtMs:Ce.authoritativeDeadlineAtMs,generation:e.generationIdentity},n,r);let dt=js(ut);if(dt.checkServerState){let lt=nr(s);(!lt||!rr(lt))&&jn(s,e.projectRoot,i,y)}sr(dt.intervalMs),ut+=1}throw new Error("Persistent query service timed out.")}function Fs(e,t){return xe("sha256").update(ne({namespace:"query-service-v18",payload:{clientId:e,request:t}})).digest("hex")}function jn(e,t,n,r){if(tt(e))return;let i=Math.min(r,E()+Is),o=ke(rt(e,"startup.lock"),{kind:"query-service-startup",detail:{projectRoot:oe(t)},directoryDurability:"recoverable"});try{if(o.kind==="acquired"&&!tt(e)){let s=or();ls(process.execPath,[n,e,t],{cwd:t,detached:!s,stdio:s?["ignore","ignore","inherit"]:"ignore",env:{...process.env,SCIP_QUERY_QUERY_SERVICE_SERVER:"1"}}).unref()}for(;E()<=i;){if(tt(e))return;sr(Dn)}}finally{o.kind==="acquired"&&o.lock.release()}throw new Error("Persistent query service did not become ready within 5s.")}function Ts(e,t,n,r){let i=JSON.parse(e);if(!i||typeof i!="object"||Array.isArray(i))throw new Error("Invalid query service response.");let o=i;if(Ns(o,t),o.ok!==!0)throw new Error(typeof o.error=="string"?o.error:"Persistent query service rejected the request.");if(o.generation!==t.generation)throw new Error("Persistent query service generation changed.");if(!n(o.result))throw new Error(`Persistent query service returned an invalid ${r}.`);let s=Qt(o.observationReceipt);if(s.kind!=="supported")throw new Error("Persistent query service returned an invalid observation receipt.");return{ok:!0,protocolVersion:W,id:t.id,generation:t.generation,result:o.result,observationReceipt:s.receipt}}function Ns(e,t){if(e.mailboxVersion!==be||e.protocolVersion!==W||e.id!==t.id||e.operationKey!==t.operationKey||e.clientId!==t.clientId||e.deadlineAtMs!==t.deadlineAtMs)throw new Error("Query service response identity does not match the request.")}function Ls(e){if(!Array.isArray(e))return!1;let t=[...e];for(;t.length>0;){let n=t.pop();if(!n||typeof n!="object"||Array.isArray(n))return!1;let r=n;if(!Ws(r)||r.signature!==null&&typeof r.signature!="string"||!Array.isArray(r.children))return!1;t.push(...r.children)}return!0}function Ws(e){return!(typeof e.symbol!="string"||typeof e.shortName!="string"||!Number.isSafeInteger(e.startLine)||e.startLine<0||!Number.isSafeInteger(e.endLine)||e.endLine<e.startLine)}function qs(e){return Array.isArray(e)?e.every(t=>{if(!t||typeof t!="object"||Array.isArray(t))return!1;let n=t;return Bs(n)&&Gs(n)&&Vs(n)}):!1}function Bs(e){return typeof e.symbol=="string"&&typeof e.shortName=="string"&&typeof e.file=="string"}function Gs(e){return Number.isSafeInteger(e.startLine)&&e.startLine>=0&&Number.isSafeInteger(e.endLine)&&e.endLine>=e.startLine}function Vs(e){return(e.documentation===null||typeof e.documentation=="string")&&(e.confidence==="root"||e.confidence==="candidate")&&Array.isArray(e.evidence)&&e.evidence.every(t=>typeof t=="string")&&Number.isSafeInteger(e.observedCallerCount)&&e.observedCallerCount>=0}function Qs(e){return Array.isArray(e)?e.every(t=>!t||typeof t!="object"||Array.isArray(t)?!1:typeof t.relativePath=="string"):!1}function $s(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return a(t.documents)&&a(t.symbols)&&a(t.definitions)&&a(t.references)&&a(t.indexSizeBytes)&&(t.lastBuilt===null||typeof t.lastBuilt=="string")}function Us(e){if(!ot(e))return!1;let t=e.members;return Array.isArray(t)&&t.every(da)}function ot(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.matched===!1?Hs(t):Ks(t)}function Hs(e){return e.resolved===void 0&&e.otherMatches===void 0&&e.totalMatches===void 0&&Array.isArray(e.suggestions)&&e.suggestions.every(t=>typeof t=="string")}function Ks(e){return e.matched===!0&&fa(e.resolved)&&Array.isArray(e.otherMatches)&&e.otherMatches.every(ga)&&a(e.totalMatches)&&e.totalMatches>=1&&e.suggestions===void 0}function Js(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.query!="string"?!1:t.kind==="missing"?Array.isArray(t.suggestions)&&t.suggestions.every(n=>typeof n=="string"):t.kind==="ambiguous"?wa(t):Ca(t)}function Ys(e){return Array.isArray(e)?e.every(t=>{if(!t||typeof t!="object"||Array.isArray(t))return!1;let n=t;return typeof n.relativePath=="string"&&(n.edgeBasis===void 0||n.edgeBasis==="symbol-references")&&(n.evidence===void 0||n.evidence==="cross-file SCIP references plus resolved source imports")}):!1}function ir(e){return Array.isArray(e)&&e.every(Zs)}function zs(e){return Array.isArray(e)&&e.every(Xs)}function Xs(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.symbol=="string"&&typeof t.shortName=="string"&&typeof t.importedIn=="string"}function Zs(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.symbol=="string"&&typeof t.shortName=="string"&&typeof t.fromFile=="string"}function ea(e){if(!ot(e))return!1;let t=e.hierarchy;return Array.isArray(t)&&t.every(ta)}function ta(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.symbol=="string"&&typeof t.shortName=="string"&&a(t.depth)}function na(e){return Array.isArray(e)&&e.every(ra)}function ra(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.symbol=="string"&&typeof t.shortName=="string"&&a(t.kind)&&typeof t.kindName=="string"&&typeof t.relativePath=="string"&&Ie(t)}function ia(e){return Array.isArray(e)&&e.every(oa)}function oa(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return a(t.kind)&&typeof t.kindName=="string"&&a(t.count)}function sa(e){if(!ot(e))return!1;let t=e,n=t.references,r=t.pagination;if(!Array.isArray(n)||!n.every(aa)||!r||typeof r!="object"||Array.isArray(r))return!1;let i=r;return i.cursorVersion===2&&i.producer==="complete-only"&&typeof i.semanticEnrichment=="boolean"}function aa(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.relativePath=="string"&&a(t.line)}function ca(e){return Array.isArray(e)&&e.every(ua)}function ua(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.consumer=="string"&&typeof t.symbol=="string"&&typeof t.shortName=="string"&&t.basis==="external-reference"}function da(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.symbol=="string"&&typeof t.shortName=="string"&&typeof t.kind=="string"&&Ie(t)}function la(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.name=="string"&&Ie(t)}function pa(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.symbol=="string"&&typeof t.shortName=="string"&&typeof t.relativePath=="string"&&Ie(t)}function fa(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.symbol=="string"&&typeof t.shortName=="string"&&typeof t.relativePath=="string"}function ga(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.shortName=="string"&&typeof t.relativePath=="string"&&a(t.startLine)&&t.symbol===void 0}function ma(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.symbol=="string"&&typeof t.shortName=="string"&&typeof t.relativePath=="string"&&a(t.startLine)}function Ie(e){return a(e.startLine)&&a(e.endLine)&&e.endLine>=e.startLine}function ya(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.pattern=="string"&&(t.mode==="literal"||t.mode==="regexp")&&Array.isArray(t.matches)&&ha(t)}function ha(e){return typeof e.matchingLines=="number"&&Number.isSafeInteger(e.matchingLines)&&e.matchingLines>=0&&typeof e.omittedMatches=="number"&&Number.isSafeInteger(e.omittedMatches)&&e.omittedMatches>=0&&typeof e.scannedFiles=="number"&&Number.isSafeInteger(e.scannedFiles)&&e.scannedFiles>=0}function we(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.serializedJson!="string"||typeof t.sha256!="string"||t.serializedJson.length>it||xe("sha256").update(t.serializedJson).digest("hex")!==t.sha256?!1:Pa(t.serializedJson)}function ba(e,t,n){let r=Ia(e.projectRoot),i=xe("sha256").update(ne({protocolVersion:W,projectRoot:r,dbPath:oe(e.dbPath),serverPath:oe(t),buildIdentity:xt(),configurationIdentity:e.configurationIdentity,lane:n})).digest("hex");return rt(gs(),"scip-query-query-service",i)}function Sa(){return process.env.SCIP_QUERY_QUERY_SERVICE_SERVER_PATH??ms(new URL("./query-service-server.js",import.meta.url))}function va(e){let t=process.env.SCIP_QUERY_QUERY_SERVICE;return process.env.SCIP_QUERY_QUERY_SERVICE_SERVER!=="1"&&t!=="0"&&(t==="1"||e)}function or(){return process.env.SCIP_QUERY_QUERY_SERVICE_DEBUG==="1"}function Ra(){let e=Number(process.env.SCIP_QUERY_QUERY_SERVICE_POOL_SIZE);return Number.isInteger(e)&&e>=1&&e<=xs?e:bs}function xa(e){let t=Ra(),n=ks.get(e.kind);return n===void 0?t:Math.min(t,n)}function Ia(e){try{return fs.native(e)}catch{return oe(e)}}function sr(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}function wa(e){return a(e.total)&&e.total>1&&Array.isArray(e.candidates)&&e.candidates.every(ma)}function Ca(e){return e.kind==="matched"&&pa(e.owner)&&Array.isArray(e.methods)&&e.methods.every(la)}function tt(e){let t=nr(e);return!!(t&&rr(t))}function Pa(e){try{let t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)}catch{return!1}}function ka(e){or()&&console.error(`query-service fallback: ${e instanceof Error?e.message:String(e)}`)}async function Kd(e){if(process.env.SCIP_QUERY_PROFILE==="1"||process.env.SCIP_QUERY_PROFILE==="true")return!1;let t=Ta(e);if(!t)return!1;let n=$e();if(t.kind==="methods")return Ea(n,t);if(t.kind==="dependence-slice")return Aa(n,t,e);let r=Oa(n,t);return r?r.mode==="bounded"?lr(r.serialized):(r.mode==="paged"?await pr(r.serialized,r.command??t.kind,e):X(r.serialized),!0):!1}function S(e,t,n){return e?{serialized:JSON.stringify(e.result),mode:t,command:n}:null}function st(e,t){return e?{serialized:e.result.serializedJson,mode:t}:null}function Ea(e,t){let n=Bn(e,t.className,{allowDefault:!0});return!n||!Ha(n.result)?!1:(n.result.kind!=="matched"&&(process.exitCode=1),!0)}async function Aa(e,t,n){let r=Kn(e,t.criterion,{allowDefault:!0});return r?(JSON.parse(r.result.serializedJson).resolution!=="matched"&&(process.exitCode=1),await pr(r.result.serializedJson,t.kind,n),!0):!1}function at(e,t){return t.includes(e.kind)}function Oa(e,t){return at(t,["code","call-graph","system"])?Ma(e,t):at(t,["files","members","file-dependencies","imported-by","refs","surface"])?_a(e,t):at(t,["hierarchy","by-kind","kind-counts","imports","unused-imports"])?ja(e,t):Da(e,t)}function Ma(e,t){switch(t.kind){case"code":return st(er(e,t.selectors,t.options,{allowDefault:!0}),"direct");case"call-graph":return st(Jn(e,t.kind,t.symbolPattern,{allowDefault:!0}),"paged");case"system":return st(Yn(e,t.modulePattern,{allowDefault:!0}),"paged")}}function _a(e,t){switch(t.kind){case"files":return S(Ln(e,t.pattern,{allowDefault:!0}),"paged");case"members":return S(qn(e,t.symbolPattern,{allowDefault:!0}),"paged");case"file-dependencies":return S(Gn(e,t.direction,t.filePattern,{allowDefault:!0}),"paged",t.direction==="outgoing"?"deps":"rdeps");case"imported-by":return S(Vn(e,t.symbolPattern,{allowDefault:!0}),"paged");case"refs":return S(Hn(e,t.symbolPattern,{allowDefault:!0}),"paged");case"surface":return S(Zn(e,t.modulePattern,{allowDefault:!0}),"paged")}}function ja(e,t){switch(t.kind){case"hierarchy":return S(Qn(e,t.symbolPattern,{allowDefault:!0}),"bounded");case"by-kind":return S($n(e,t.kindQuery,{allowDefault:!0}),"bounded");case"kind-counts":return S(Un(e,{allowDefault:!0}),"bounded");case"imports":return S(zn(e,t.filePattern,{allowDefault:!0}),"bounded");case"unused-imports":return S(Xn(e,t.filePattern,{allowDefault:!0}),"bounded")}}function Da(e,t){switch(t.kind){case"stats":return S(Wn(e,{allowDefault:!0}),"direct");case"entrypoints":return S(Nn(e,t.options,{allowDefault:!0}),"direct");case"source-search":return S(Fn(e,t.pattern,t.options,{allowDefault:!0}),"direct");case"outline":return S(Tn(e,t.filePattern,{allowDefault:!0}),"direct")}}var Fa=new Map([["search",tc],["outline",oc],["code",ec],["entrypoints",Ja],["files",Ka],["stats",e=>ur(e,"stats")],["kind-counts",e=>ur(e,"kind-counts")],["members",e=>ar(e,"members")],["methods",e=>ar(e,"methods")],["deps",e=>cr(e,"outgoing")],["rdeps",e=>cr(e,"incoming")],["imported-by",Na],["hierarchy",La],["by-kind",Wa],["refs",qa],["dependence-slice",Ba],["call-graph",Ga],["imports",Va],["unused-imports",Qa],["system",$a],["surface",Ua]]);function Ta(e){return Fa.get(e[0])?.(e)??null}function ar(e,t){let n=v(e);return n===null?null:t==="members"?{kind:t,symbolPattern:n}:{kind:t,className:n}}function cr(e,t){let n=v(e);return n===null?null:{kind:"file-dependencies",direction:t,filePattern:n}}function Na(e){let t=v(e);return t===null?null:{kind:"imported-by",symbolPattern:t}}function La(e){let t=v(e);return t===null?null:{kind:"hierarchy",symbolPattern:t}}function Wa(e){let t=v(e);return t===null?null:{kind:"by-kind",kindQuery:t}}function qa(e){let t=v(e);return t===null?null:{kind:"refs",symbolPattern:t}}function Ba(e){let t=v(e);return t===null?null:{kind:"dependence-slice",criterion:t}}function Ga(e){let t=e[0];if(t!=="call-graph")return null;let n=v(e);return n===null?null:{kind:t,symbolPattern:n}}function Va(e){let t=v(e);return t===null?null:{kind:"imports",filePattern:t}}function Qa(e){let t=v(e);return t===null?null:{kind:"unused-imports",filePattern:t}}function $a(e){let t=v(e);return t===null?null:{kind:"system",modulePattern:t}}function Ua(e){let t=v(e);return t===null?null:{kind:"surface",modulePattern:t}}function v(e){let t,n={json:!1,resultOnly:!1,compact:!1};for(let r=1;r<e.length;r+=1){let i=e[r];if(i==="--"){let o=e.slice(r+1);if(o.length!==1||t!==void 0)return null;t=o[0];break}if(!ct(n,i)){if(i.startsWith("-")||t!==void 0)return null;t=i}}return!ac(n)||t===void 0?null:t}function Ha(e){return lr(JSON.stringify(e))}function lr(e){return fr(e)?(X(e),!0):!1}async function pr(e,t,n){if(fr(e)){X(e);return}let{runWithCliOutputPagination:r}=await import("./output-pagination-UZJ5ACIX.js");await r({command:t,producerVersion:$,invocationPrefix:an(),argv:[...n],cwd:process.cwd(),json:!0,sourceSession:!0,reemitSource:!1},()=>X(e))}function fr(e){return Buffer.byteLength(e)+1<=gt}function Ka(e){let t=v(e);return t===null?null:{kind:"files",pattern:t}}function ur(e,t){let n=!1,r=!1,i=!1;for(let o=1;o<e.length;o+=1){let s=e[o];if(s==="--json"){n=!0;continue}if(s==="--result-only"){r=!0;continue}if(s==="--compact"){i=!0;continue}return null}return n&&r&&i?{kind:t}:null}function Ja(e){let t={json:!1,resultOnly:!1,compact:!1};for(let n=1;n<e.length;n+=1){let r=e[n];if(r==="--"){let o=e.slice(n+1);if(o.length!==1||t.search!==void 0)return null;t.search=o[0];break}if(ct(t,r))continue;let i=z(e,n,r,"--scope","-s");if(i){t.scope=i.value,n=i.nextIndex;continue}if(r.startsWith("-")||t.search!==void 0)return null;t.search=r}return Ya(t)}function ct(e,t){switch(t){case"--json":return e.json=!0,!0;case"--result-only":return e.resultOnly=!0,!0;case"--compact":return e.compact=!0,!0;default:return!1}}function Ya(e){let{search:t,scope:n,json:r,resultOnly:i,compact:o}=e;return!r||!i||!o?null:{kind:"entrypoints",options:{...t===void 0?{}:{search:t},...n===void 0?{}:{scope:n}}}}function za(e,t){switch(t){case"--json":return e.json=!0,!0;case"--result-only":return e.resultOnly=!0,!0;case"--compact":return e.compact=!0,!0;case"--no-session":return e.session=!1,!0;default:return!1}}function Xa(e,t,n){let r=t[n],i=z(t,n,r,"--context","-C");if(i){let s=Ue(i.value,0);return s===null?null:(e.context=s,i.nextIndex)}let o=z(t,n,r,"--members");return o?o.value!=="exported"&&o.value!=="all"?null:(e.members=o.value,o.nextIndex):r.startsWith("-")?null:(e.selectors.push(r),n)}function Za(e){return e.json&&e.resultOnly&&e.compact&&e.selectors.length>=1&&e.selectors.length<=24&&!e.selectors.some(t=>t.length===0)}function ec(e){let t={selectors:[],...un,session:!0,json:!1,resultOnly:!1,compact:!1};for(let s=1;s<e.length;s+=1){let c=e[s];if(c==="--"){t.selectors.push(...e.slice(s+1));break}if(za(t,c))continue;let d=Xa(t,e,s);if(d===null)return null;s=d}let{selectors:n,context:r,members:i,session:o}=t;return Za(t)?{kind:"code",selectors:n,options:{context:r,members:i},session:o}:null}function tc(e){let t={...cn,regexp:!1,ignoreCase:!1,json:!1,resultOnly:!1,compact:!1};for(let n=1;n<e.length;n+=1){let r=e[n];if(r==="--"){let o=e.slice(n+1);if(o.length!==1||t.pattern!==void 0)return null;t.pattern=o[0];break}if(rc(t,r))continue;let i=ic(t,e,n);if(i===null)return null;n=i}return nc(t)}function nc(e){if(!e.json||!e.resultOnly||!e.compact||e.pattern===void 0)return null;let{pattern:t,scope:n,context:r,limit:i,regexp:o,ignoreCase:s}=e;return{kind:"source-search",pattern:t,options:{scope:n,context:r,limit:i,regexp:o,ignoreCase:s,ranking:"structural"}}}function rc(e,t){switch(t){case"--json":return e.json=!0,!0;case"--result-only":return e.resultOnly=!0,!0;case"--compact":return e.compact=!0,!0;case"--regexp":return e.regexp=!0,!0;case"--ignore-case":case"-i":return e.ignoreCase=!0,!0;default:return!1}}function ic(e,t,n){let r=t[n],i=z(t,n,r,"--scope","-s");if(i)return e.scope=i.value,i.nextIndex;let o=z(t,n,r,"--context","-C");if(o)return dr(e,"context",o,0);let s=z(t,n,r,"--limit","-n");return s?dr(e,"limit",s,1):r.startsWith("-")||e.pattern!==void 0?null:(e.pattern=r,n)}function dr(e,t,n,r){let i=Ue(n.value,r);return i===null?null:(e[t]=i,n.nextIndex)}function oc(e){let t,n={json:!1,resultOnly:!1,compact:!1};for(let r=1;r<e.length;r+=1){let i=e[r];if(i==="--"){let o=e.slice(r+1);if(o.length!==1||t!==void 0)return null;t=o[0];break}if(!ct(n,i)&&i!=="--signatures"){if(i.startsWith("-")||t!==void 0)return null;t=i}}return sc(n,t)}function sc(e,t){return!e.json||!e.resultOnly||!e.compact||t===void 0?null:{kind:"outline",filePattern:t}}function z(e,t,n,r,i){if(n.startsWith(`${r}=`))return{value:n.slice(r.length+1),nextIndex:t};if(n!==r&&(i===void 0||n!==i))return null;let o=e[t+1];return o===void 0?null:{value:o,nextIndex:t+1}}function ac(e){return e.json&&e.resultOnly&&e.compact}export{Ta as parseFastPathInvocation,fr as serializedJsonFitsClientBudget,Kd as tryRunQueryServiceFastPath};
6
6
  //# sourceMappingURL=query-service-fastpath.js.map
@@ -1,5 +1,5 @@
1
- import"./chunk-JDU2IV3A.js";import"./chunk-AN76MGUE.js";import"./chunk-CFNIGQMT.js";import"./chunk-NB4D3BNM.js";import"./chunk-L6XHYJPZ.js";import"./chunk-26CT72HM.js";import"./chunk-T6DWDI5E.js";import"./chunk-HYT2R7LX.js";import"./chunk-2N6WBNDC.js";import"./chunk-L5KYH6U3.js";import"./chunk-OUHEZBYI.js";import"./chunk-NGKBOT6G.js";import"./chunk-J7A4PWFX.js";import"./chunk-62LPZCBQ.js";import"./chunk-3TNRNKAT.js";import{a as H}from"./chunk-6YTSKJJ3.js";import"./chunk-6TS3KOXR.js";import"./chunk-ZGIHTH27.js";import"./chunk-7KCZELVM.js";import{a as ve}from"./chunk-2M2LSIMY.js";import"./chunk-GHNPACNP.js";import{c as O}from"./chunk-6MFXCMZC.js";import"./chunk-MZPXPSUJ.js";import"./chunk-RVZC6TJE.js";import"./chunk-NYKZMCRC.js";import"./chunk-POBJ6FR2.js";import{h as xe}from"./chunk-HAXXKRTD.js";import"./chunk-UIFUZVCC.js";import{d as Ee}from"./chunk-JFMI5SGB.js";import"./chunk-BGBBVSH4.js";import"./chunk-AADQLOQ4.js";import"./chunk-MTDBHTSF.js";import{b as we}from"./chunk-WDSFQDPN.js";import{b as Ie,c as Pe,d as Ce}from"./chunk-ANLNLY66.js";import"./chunk-BKVWUP7Y.js";import"./chunk-JJP37RGX.js";import"./chunk-HX4X7KG3.js";import{e as oe}from"./chunk-JCSAZ35V.js";import{a as C,b as ce}from"./chunk-NJGKXKQF.js";import"./chunk-FI7VGOR4.js";import"./chunk-WRQXLNYE.js";import"./chunk-L7KTFEAV.js";import"./chunk-2USA3S3P.js";import"./chunk-YUKYB54I.js";import"./chunk-BJT7LSPK.js";import{d as he}from"./chunk-5BIKR67W.js";import"./chunk-CZW5MZ5B.js";import"./chunk-F4FNK44D.js";import"./chunk-ODPDP7A4.js";import{a as Re}from"./chunk-VBKUWB6N.js";import"./chunk-MOKUWRHO.js";import"./chunk-VZPWVCLN.js";import"./chunk-FVFDOIM3.js";import{B as ee,C as te,D as re,J as ne,L as ie,T as k,_ as ae,a as P,c as J,d as X,k as _}from"./chunk-2VAHDDLM.js";import{a as Z}from"./chunk-YXPUP5G2.js";import{c as M,h as se}from"./chunk-BL6DCHQP.js";import{a as be}from"./chunk-X6OGVFIT.js";import"./chunk-MXNGIEPU.js";import"./chunk-EHYDXE3Z.js";import"./chunk-2OOY75BW.js";import{a as ge,b as g}from"./chunk-HMEWLMML.js";import{a as Se}from"./chunk-DHEQMPLW.js";import"./chunk-U6KCHXJ4.js";import"./chunk-RMDPFPNW.js";import"./chunk-WYPL7GF7.js";import"./chunk-T3I6NHBH.js";import{b as K,d as Y}from"./chunk-ATXPTSEI.js";import{d as B}from"./chunk-CKBUBRYD.js";import"./chunk-MWN53KRN.js";import{b as z}from"./chunk-IW5XQG5G.js";import{b as $}from"./chunk-3AF4TUFK.js";import{b as W,c as q,d as le,e as ue,h as pe,i as de,m as me,n as fe,o as T,p as ye}from"./chunk-T3CZAZSI.js";import{a as U}from"./chunk-B3PYOSCX.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import{c as A,d as I,e as V}from"./chunk-JFMEXGFE.js";import{G,c as Q}from"./chunk-7HXT6YLU.js";import"./chunk-7F45LJKI.js";import{createHash as h,randomUUID as Dt}from"crypto";import{rmSync as Nt}from"fs";import{join as qe,resolve as Ze}from"path";import{pathToFileURL as Ft}from"url";function ke(e,t,i,o,l=!1){let r=[...e],n=[],s=new Set,a=0;for(;r.length>0&&n.length<t;){let c=r.filter(d=>a+d.evidenceCharacters<=i||l&&n.length===0);if(c.length===0)break;let u=c.filter(d=>d.roles.includes("location")||d.roles.includes("definition")).sort(o);c.sort((d,m)=>Ae(m,s)-Ae(d,s)||o(d,m));let p=u[0]??c[0];n.push(p),a+=p.evidenceCharacters;for(let d of _e(p))s.add(d.key);r.splice(r.indexOf(p),1)}return{selected:n,omitted:r.sort(o)}}function Ae(e,t){let i=_e(e).reduce((r,n)=>r+(t.has(n.key)?0:n.weight),0),o=Math.max(0,8-e.priority)*20,l=Math.min(500,Math.ceil(e.evidenceCharacters/160));return i+o-l}function _e(e){return[...e.reasons.map(tt),...e.roles.map(t=>({key:`role:${t}`,weight:rt(t)})),{key:`file:${e.relativePath}`,weight:180},{key:`scope:${nt(e.relativePath)}`,weight:120},{key:`kind:${e.fileKind}`,weight:40},...e.symbols.map(t=>({key:`symbol:${t}`,weight:100})),...e.behaviorSignals.map(t=>({key:`behavior:${t}`,weight:70}))]}function tt(e){let t=e.indexOf(":"),i=t<0?e:e.slice(0,t);return i==="dependency"||i==="consumer"?{key:`reason:${i}`,weight:220}:{key:`reason:${e}`,weight:i==="location"||i==="definition"?1400:800}}function rt(e){switch(e){case"location":return 1200;case"definition":return 1100;case"reference":return 600;case"caller":case"callee":return 550;case"dependency":case"consumer":return 500;case"search":return 400;default:return 300}}function nt(e){let t=e.lastIndexOf("/");return t<0?e:e.slice(0,t)}var Me=64,Te=12;function Ne(e,t,i={}){if(t.length===0)return[];let o=i.context??6;if(!Number.isSafeInteger(o)||o<0)throw new RangeError(`context must be a non-negative safe integer; received ${o}`);let l=i.limit??12;if(!Number.isSafeInteger(l)||l<=0)throw new RangeError(`limit must be a positive safe integer; received ${l}`);let r=t.map(n=>{if(n.length===0)throw new Error("The source search pattern must not be empty.");return{pattern:n,regexp:i.regexp?Se(n,"source search pattern",i.ignoreCase?"iu":"u"):null,literal:i.ignoreCase?n.toLocaleLowerCase():n,identities:[],fileCoverage:[],textByPath:new Map}});if(!i.regexp&&!i.ignoreCase){let n=r.map(a=>Buffer.from(a.pattern,"utf8")),s=O(e,{scope:i.scope,literalBytes:n.length===1?n[0]:n},(a,c)=>{let u=_(a.text);if(u.length!==0)for(let p of c){let d=r[p];d&&Oe(e,d,a,u,i)}});return r.map(a=>He(a,s,o,l,i))}return r.map(n=>{let s=O(e,{scope:i.scope},a=>{let c=_(a.text);c.length>0&&Oe(e,n,a,c,i)});return He(n,s,o,l,i)})}function Oe(e,t,i,o,l){let r=[];for(let c=0;c<o.length;c+=1){let u=o[c]??"",p=u.endsWith("\r")?u.slice(0,-1):u;(t.regexp?t.regexp.test(p):(l.ignoreCase?p.toLocaleLowerCase():p).includes(t.literal))&&r.push(c)}if(r.length===0)return;let n=i.relativePath;t.textByPath.set(n,i.text);let s=i.freshness.semantic.state!=="stale"&&i.freshness.semantic.basis!=="no-compiler-document"?k(e,n):[],a=te(e,n)?.callables??[];for(let c of r){let u=ae(s,c),p=ee(a,c),d=u&&!se(u.symbol)?u:null,m=d?.startLine??p?.startLine??u?.startLine??c,f=d?.endLine??p?.endLine??u?.endLine??c,R=xe(e,n,c,m,f);t.identities.push({relativePath:n,focusLine:c,ownerSymbol:d?.symbol??null,ownerShort:d?M(d.symbol):p?.name??(u?M(u.symbol):null),ownerStartLine:R.startLine,ownerEndLine:R.endLine,fileKind:ce(n),freshness:i.freshness})}t.fileCoverage.push({relativePath:n,matchingLines:r.length,returnedMatches:0,freshness:i.freshness})}function He(e,t,i,o,l){e.identities.sort(Fe);let r=e.identities.length>Me?De(e.identities,Me):e.identities,s=(o===Number.MAX_SAFE_INTEGER?e.identities:l.ranking?De(e.identities,o):e.identities.slice(0,o)).flatMap(u=>{let p=e.textByPath.get(u.relativePath),d=p===void 0?null:it(u.relativePath,p,u.focusLine,i);return d?[{...d,...u}]:[]}),a=new Map;for(let u of s)a.set(u.relativePath,(a.get(u.relativePath)??0)+1);for(let u of e.fileCoverage)u.returnedMatches=a.get(u.relativePath)??0;let c=ot(e.fileCoverage);return{pattern:e.pattern,mode:l.regexp?"regexp":"literal",identities:e.identities,...r.length<e.identities.length?{identityManifest:r}:{},identityCoverage:{mode:r.length===e.identities.length?"complete":"bounded",returned:r.length,total:e.identities.length,omitted:e.identities.length-r.length},matches:s,matchingLines:e.identities.length,matchingFiles:e.fileCoverage.length,omittedMatches:Math.max(0,e.identities.length-s.length),fileCoverage:e.fileCoverage,scopeHints:c.slice(0,Te),omittedScopeHints:Math.max(0,c.length-Te),scannedFiles:t.scannedTextFiles,textCoverage:{basis:"current-project-text-files",candidateFiles:t.candidateFiles,scannedTextFiles:t.scannedTextFiles,scannedBytes:t.scannedBytes,skippedBinaryPaths:t.skippedBinaryPaths,skippedUnreadablePaths:t.skippedUnreadablePaths,skippedOversizedPaths:t.skippedOversizedPaths,semanticFiles:t.semanticFiles}}}function it(e,t,i,o){let l=t.split(`
2
- `),r=t.endsWith(`
3
- `)?l.length-1:l.length;if(i<0||i>=r)return null;let n=Math.max(0,i-o),s=Math.min(r-1,i+o);return{relativePath:e,startLine:n,endLine:s,focusLine:i,source:l.slice(n,s+1).join(`
4
- `)}}function ot(e){let t=new Map;for(let i of e){let o=st(i.relativePath),l=t.get(o)??{matchingLines:0,matchingFiles:0};l.matchingLines+=i.matchingLines,l.matchingFiles+=1,t.set(o,l)}return[...t.entries()].map(([i,o])=>({scope:i,...o})).sort((i,o)=>o.matchingLines-i.matchingLines||o.matchingFiles-i.matchingFiles||i.scope.localeCompare(o.scope))}function st(e){let t=e.lastIndexOf("/");return t<0?e:e.slice(0,t)}function De(e,t){let i=e.map((l,r)=>({...l,priority:C(l.fileKind),sequence:r,evidenceCharacters:1,roles:["search"],reasons:["search"],symbols:l.ownerSymbol?[l.ownerSymbol]:[],behaviorSignals:[]})),o=[];for(let l of[0,1,2]){let r=t-o.length;if(r===0)break;let n=i.filter(s=>C(s.fileKind)===l);o.push(...ke(n,r,Number.MAX_SAFE_INTEGER,Fe).selected)}return o.map(({priority:l,sequence:r,evidenceCharacters:n,roles:s,reasons:a,symbols:c,behaviorSignals:u,...p})=>p)}function Fe(e,t){return C(e.fileKind)-C(t.fileKind)||+(t.ownerSymbol!==null)-+(e.ownerSymbol!==null)||e.relativePath.localeCompare(t.relativePath)||e.focusLine-t.focusLine}function Le(e,t,i={}){if(t.length===0)throw new Error("The source search pattern must not be empty.");return Ne(e,[t],i)[0]}import{availableParallelism as ft,totalmem as yt}from"os";import{fileURLToPath as tn}from"url";import{getHeapStatistics as ht}from"v8";async function je(e,t,i={}){let o=Math.max(1,Math.floor(i.batchSize??64)),l=i.collectGarbage??P,r=[],n=0;for(let s=0;s<t.length;s+=o){for(let a of t.slice(s,s+o)){for(let c of k(e,a))e.isIgnored(c.relativePath)||r.push(c);ie(e,a),ne(e,a),re(e,a),n+=1}i.onBatch?.({files:n,total:t.length,definitions:r.length}),l(),await i.yieldToEventLoop?.()}return{files:n,definitions:r}}import{execFileSync as vr}from"child_process";import{createHash as Er}from"crypto";import{lstatSync as Pr,readlinkSync as Cr,readdirSync as wr,realpathSync as Ar,statSync as kr}from"fs";import{dirname as Mr,isAbsolute as Tr,join as Or,posix as Hr,relative as Dr,resolve as Nr,sep as Fr}from"path";var jr=512*1024*1024;function Qe(e){return le({version:e.version,...e.base?{base:e.base}:{},files:[...e.files].sort((t,i)=>t.path.localeCompare(i.path))})}function D(e){return JSON.stringify({...e.clojureConfigPath?{clojureConfigPath:e.clojureConfigPath}:{},files:[...e.files].sort((t,i)=>t.path.localeCompare(i.path)).map(t=>({hash:t.hash,path:t.path,size:t.size})),languages:[...e.languages].sort(),pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),version:e.version})}var ct="scip-query:collaboration-domain",lt="scip-query:workspace-instance",ut="scip-query:index-generation",pt="scip-query:repository-content",Be="scip-query:index-inputs",dt="scip-query:index-inputs";function Ve(e){let t=e.snapshot,i=e.observedSourceKinds?new Set(e.observedSourceKinds):void 0,o=e.gitContext??t?.gitContext??(i?.has("live-workspace")?G(e.projectRoot):void 0),l=e.collaborationDomainId??e.db?.config.collaborationDomainId,r=l?g(ct,1,l):void 0,n=o?g(lt,1,o.worktreeId):void 0,s=t?g(pt,1,Qe(t.repositoryContent)):void 0,a=t?g(Be,t.indexInputs.version,D(t.indexInputs)):void 0,c=e.db&&t?mt(e.db.generation.metadataRaw):void 0,u=e.db?{generation:g(ut,1,e.db.generation.identity),...c?{inputs:c}:{},source:e.db.generation.source}:void 0,p=i??new Set([...u?["index-generation"]:[],...s?["repository-snapshot"]:n?["live-workspace"]:[]]),d=[...u&&p.has("index-generation")?[{kind:"index-generation",identity:u.generation}]:[],...s&&p.has("repository-snapshot")?[{kind:"repository-snapshot",identity:s}]:[],...n&&p.has("live-workspace")?[{kind:"live-workspace",identity:n}]:[],...p.has("process")?[{kind:"process"}]:[]],m=[...u&&p.has("index-generation")?[{source:"index-generation",kind:u.source==="immutable"?"immutable":"not-established"}]:[],...s&&p.has("repository-snapshot")?[{source:"repository-snapshot",kind:"fixed-snapshot"}]:[],...n&&p.has("live-workspace")?[{source:"live-workspace",kind:"not-established"}]:[],...p.has("process")?[{source:"process",kind:"not-established"}]:[]];return d.length===0&&(d.push({kind:"process"}),m.push({source:"process",kind:"not-established"})),{schemaVersion:ge,observedAt:(e.observedAt??(t?new Date(t.capturedAt):new Date)).toISOString(),facts:{...r?{collaborationDomain:r}:{},...n?{workspaceInstance:n}:{},...s?{wholeContent:s}:{},...a?{relevantInputs:[{subject:dt,identity:a}]}:{},...u?{index:u}:{}},observedSources:d,stabilityProofs:m,...o?{diagnostics:{clean:o.clean,...o.headCommit?{headCommit:o.headCommit}:{},...o.treeOid?{treeOid:o.treeOid}:{}}}:{}}}function mt(e){if(!e)return;let t=B(e);if(t.kind!=="legacy"&&t.kind!=="supported")return;let i=Q(t.metadata.fingerprint);return i&&Number.isSafeInteger(i.version)&&i.version>0?g(Be,i.version,D(i)):void 0}var gt=1,St=1;var hn=10*6e4,Rt=25e3,bt=2500;var vt=4,xt=12,Et=1,It=4,Pt=7*1024*1024*1024;var gn=10*6e4;var Sn=10*6e4;var Ct=new Set(["vue-component-duplicates","vue-composable-candidates","vue-large-view-pressure"]),Rn=new Set([...Ct,"suppressions"]);var Ue=2,$e=J({kind:"health-semantic-prewarm",invalidation:X("health-semantic-prewarm"),serialize:e=>JSON.stringify(e),deserialize:wt});function wt(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let i=t;return i.version!==Ue||typeof i.definitions!="number"||!Number.isFinite(i.definitions)||typeof i.referenceCacheWrites!="number"||!Number.isFinite(i.referenceCacheWrites)||typeof i.referenceIncomplete!="number"||!Number.isFinite(i.referenceIncomplete)||typeof i.calleeRows!="number"||!Number.isFinite(i.calleeRows)||typeof i.warmedAt!="number"||!Number.isFinite(i.warmedAt)?null:{version:Ue,definitions:i.definitions,referenceCacheWrites:i.referenceCacheWrites,referenceIncomplete:i.referenceIncomplete,calleeRows:i.calleeRows,warmedAt:i.warmedAt}}catch{return null}}function At(e,t){return!t||t.count<=1?[...e]:e.filter((i,o)=>o%t.count===t.index)}function Ge(e){let t=H(e);return t.symbols>=Rt||t.documents>=bt}var bn={env:process.env,projectFingerprint:Y,semanticEngineFingerprint:kt,readMarker:(e,t,i)=>$e.read(e,t,i),writeMarker:(e,t,i,o)=>$e.write(e,t,i,o),projectFiles:(e,t)=>At(Z(e,{scope:t.scope,includeIgnored:!1}),t.shard),candidateDefinitions:async(e,t,i)=>{let o=await je(e,i,{collectGarbage:P,yieldToEventLoop:()=>new Promise(s=>setImmediate(s))}),l=new Set(i),r=new Set(o.definitions.map(s=>s.symbolId)),n=[];for(let s of[{},{requireCallableSymbol:!0},{requireFunctionLikeSymbol:!0}])for(let a of Ee(e,{...s,scope:t.scope}))!l.has(a.relativePath)||r.has(a.symbolId)||(r.add(a.symbolId),n.push(a));return[...o.definitions,...n].filter(s=>Pe(s.relativePath)!==null)},warmReferenceFragments:(e,t,i)=>oe(e,o=>Ie(e,o),{onBatch:t,...i?{files:i}:{}}),materializeReferences:(e,t,i)=>Ce(e).materializeReferences(t,i),materializeCallees:we,releaseSemanticMemory:e=>z(e,{groups:["semantic-provider"]}),heapUsedFraction:()=>{let e=ht();return e.heap_size_limit>0?e.used_heap_size/e.heap_size_limit:0},collectGarbage:P,yieldToEventLoop:()=>new Promise(e=>setImmediate(e))};function kt(e){return K(JSON.stringify({kind:"health-semantic-prewarm-engine",rust:he(e.config.projectRoot)}))}var vn=N({envKey:"SCIP_QUERY_HEALTH_CONCURRENCY",defaultMinimum:vt,defaultMaximum:xt}),xn=N({envKey:"SCIP_QUERY_HEALTH_FULL_CONCURRENCY",defaultMinimum:Et,defaultMaximum:It,memoryPerTaskBytes:Pt});var En=N({envKey:"SCIP_QUERY_DIFF_IMPACT_CONCURRENCY",defaultMinimum:gt,defaultMaximum:St});function N(e){return(t,i=process.env,o=ft,l=yt())=>_t(t,i,o,l,e)}function _t(e,t,i,o,l){let r=t[l.envKey],n=Mt(i,o,l),s=r?parseInt(r,10):n;return!Number.isFinite(s)||s<1?Math.min(n,e):Math.min(s,e)}function Mt(e,t,i){let o=e(),l=Number.isFinite(o)?Math.max(i.defaultMinimum,o-1):0,r=i.memoryPerTaskBytes!==void 0&&Number.isFinite(t)&&t>0?Math.floor(t/2/i.memoryPerTaskBytes):Number.POSITIVE_INFINITY;return Math.min(i.defaultMaximum,r,Math.max(i.defaultMinimum,l))}import{spawn as Cn}from"child_process";import{createHash as Tt,randomUUID as An}from"crypto";import{existsSync as _n,realpathSync as Mn}from"fs";import{tmpdir as On}from"os";import{join as Dn,resolve as Ot}from"path";import{fileURLToPath as Fn}from"url";var y=18,F=1e3,jn=2*F;var Ht=64*1024*1024,Qn={maxItems:64,maxBytes:128*1024*1024,maxItemBytes:Ht,maxBatch:1,responseRetentionMs:6e4};function We(e){return Tt("sha256").update(ue({kind:"scip-query-service-mailbox",protocolVersion:y,sessionDir:Ot(e)})).digest("hex")}var Lt=3e4,ze=5,jt=100,Qt=1024*1024,Bt=1280*1024,w={maxItems:64,maxBytes:128*1024*1024,maxItemBytes:64*1024*1024,maxBatch:1,responseRetentionMs:6e4};async function Vt(e,t){let i=pe(e);de(i);let o=$(qe(e,"server.lock"),{kind:"query-service-server",detail:{projectRoot:Ze(t)}});if(o.kind!=="acquired")return;let l;try{l=Re(t)}catch(b){throw o.lock.release(),b}let r=be([i.pendingDir,i.legacyRequestDir]),n=qe(e,"server.json"),s=We(e),a=A(process.pid),c=!1,u=!1,p=I(),d=Number.NEGATIVE_INFINITY,m=0,f=()=>{c=!0};process.once("SIGINT",f),process.once("SIGTERM",f);let R=(b=!1)=>{let E=I();if(!b&&E-d<F)return;d=E;let j={protocolVersion:y,sessionIdentity:s,pid:process.pid,...a?{processIdentity:a}:{},generation:l.generation.identity,heartbeatAtMs:Date.now()};b?q(n,j):W(n,j)};try{R(!0);let b=zt();for(;!c&&!u&&I()-p<b;){let E=await Ut(i,l,s,()=>{u=!0});E>0?(m=0,p=I(),R()):(m+=1,R()),await r.wait(Kt(E,m))}}finally{r.close(),l.close(),Nt(n,{force:!0}),o.lock.release()}}async function Ut(e,t,i,o){let l=me(e,{ownerId:Yt,nowMs:Date.now(),limits:w,owner:Jt,liveness:Xt,durability:"visibility"}),r=0;for(let n of l){let s=n.requestId;try{let a=Gt(fe(n,w),i);if(s=a.id,a.id!==n.requestId||a.operationKey!==n.operationKey||a.clientId!==n.clientId||a.deadlineAtMs!==n.deadlineAtMs)throw new Error("Query service request identity does not match its mailbox claim.");if(a.deadlineAtMs<Date.now())throw new Error("Query service request expired before processing.");if(a.request.expectedGeneration!==t.generation.identity){T(e,n,{ok:!1,protocolVersion:y,id:s,generation:t.generation.identity,errorCode:"generation-mismatch",error:"Persistent query service opened a different generation."},{nowMs:Date.now(),limits:w,durability:"visibility"}),o(),r+=1;continue}let c=await $t(t,a.request),u=Ve({projectRoot:t.config.projectRoot,db:t,observedSourceKinds:["index-generation"]}),p=Date.now();if(a.deadlineAtMs<p)throw new Error("Query service request expired while processing.");T(e,n,{ok:!0,protocolVersion:y,id:s,generation:t.generation.identity,result:c,observationReceipt:u},{nowMs:p,limits:w,durability:"visibility"})}catch(a){let c=a instanceof Error?a.message:String(a);ye(e,n,{ok:!1,protocolVersion:y,id:s,errorCode:"request-failed",error:c},c,{nowMs:Date.now(),limits:w})}r+=1}return r}async function $t(e,t){if(t.kind==="source-search")return Le(e,t.pattern,t.options);if(t.kind==="outline")return ve(e,t.filePattern);if(t.kind==="entrypoints"){let{entryPoints:n}=await import("./entry-map-QCTF4RVY.js");return n(e,t.options)}if(t.kind==="files"){let{files:n}=await import("./files-M2UBF5HJ.js");return n(e,t.pattern)}if(t.kind==="stats"){let{stats:n}=await import("./stats-OOJ74B32.js");return n(e)}if(t.kind==="members"){let[{members:n},{symbolResolutionJson:s}]=await Promise.all([import("./members-YKD636DA.js"),import("./code-result-json-5FEFQCAQ.js")]);return{...s(e,t.symbolPattern),members:n(e,t.symbolPattern)}}if(t.kind==="methods"){let{resolveMethods:n}=await import("./methods-VDF4IMYG.js");return n(e,{className:t.className})}if(t.kind==="file-dependencies"){let{deps:n,rdeps:s}=await import("./deps-4QHVDPYA.js");return t.direction==="outgoing"?n(e,t.filePattern):s(e,t.filePattern)}if(t.kind==="imported-by"){let{importedBy:n}=await import("./imports-WIE3YZOB.js");return n(e,t.symbolPattern)}if(t.kind==="hierarchy"){let[{hierarchy:n},{withSymbolResolutionJson:s}]=await Promise.all([import("./hierarchy-2UIHRLW4.js"),import("./symbol-resolution-DBLVXLBC.js")]);return s(e,t.symbolPattern,n(e,t.symbolPattern),"hierarchy")}if(t.kind==="by-kind"||t.kind==="kind-counts"){let{byKind:n,kindCounts:s}=await import("./by-kind-H3P6BR5G.js");return t.kind==="by-kind"?n(e,t.kindQuery):s(e)}if(t.kind==="refs"){let[{refs:n},{compareReferenceKey:s},{withSymbolResolutionJson:a}]=await Promise.all([import("./refs-JNK5CLM7.js"),import("./refs-pagination-6BLRYGMV.js"),import("./symbol-resolution-DBLVXLBC.js")]),c=S(e),u=n(e,t.symbolPattern,{semantic:c}).sort(s);return{...a(e,t.symbolPattern,u,"references"),pagination:{cursorVersion:2,producer:"complete-only",semanticEnrichment:c}}}if(t.kind==="trace"){let n=S(e);if(!n){let p=v(e,t.kind,t.symbolPattern);if(p)return p}let[{qualifiedTraceEvidence:s},{symbolResolutionJson:a}]=await Promise.all([import("./trace-I2P2YFH4.js"),import("./symbol-resolution-DBLVXLBC.js")]),c=JSON.stringify({...a(e,t.symbolPattern),...s(e,t.symbolPattern,{semantic:n})}),u={serializedJson:c,sha256:h("sha256").update(c).digest("hex")};return n||x(e,t.kind,t.symbolPattern,u,Bt),u}if(t.kind==="value-flow"){let n=v(e,t.kind,t.symbolPattern);if(n)return n;let{valueFlow:s}=await import("./value-flow-JJVMF7NP.js"),a=JSON.stringify(s(e,{symbols:[t.symbolPattern]},{maxDepth:2,maxEdges:48})),c={serializedJson:a,sha256:h("sha256").update(a).digest("hex")};return x(e,t.kind,t.symbolPattern,c),c}if(t.kind==="dependence-slice"){let n=v(e,t.kind,t.criterion);if(n)return n;let{dependenceSlice:s}=await import("./dependence-slice-GWGQCODG.js"),a=JSON.stringify(s(e,t.criterion)),c={serializedJson:a,sha256:h("sha256").update(a).digest("hex")};return x(e,t.kind,t.criterion,c),c}if(t.kind==="call-graph"){let[{callGraph:n},{symbolResolutionJson:s}]=await Promise.all([import("./call-graph-VTG2CUOQ.js"),import("./symbol-resolution-DBLVXLBC.js")]),a=JSON.stringify({...s(e,t.symbolPattern),callGraph:n(e,t.symbolPattern,{semantic:S(e)})});return{serializedJson:a,sha256:h("sha256").update(a).digest("hex")}}if(t.kind==="reference-neighborhood"||t.kind==="dataflow"){let n=S(e),s=t.kind==="reference-neighborhood"&&!n;if(s){let f=v(e,t.kind,t.symbolPattern);if(f)return f}let[{dataflow:a,referenceNeighborhood:c},{symbolResolutionJson:u}]=await Promise.all([import("./dataflow-GFBTVDH3.js"),import("./symbol-resolution-DBLVXLBC.js")]),p=t.kind==="dataflow"?a(e,t.symbolPattern,{semantic:n}):c(e,t.symbolPattern,{semantic:n}),d=JSON.stringify({...u(e,t.symbolPattern),[t.kind]:p}),m={serializedJson:d,sha256:h("sha256").update(d).digest("hex")};return s&&x(e,t.kind,t.symbolPattern,m),m}if(t.kind==="reference-reachability"||t.kind==="slice"){let n=S(e);if(!n){let p=v(e,t.kind,t.symbolPattern);if(p)return p}let[{referenceReachability:s},{symbolResolutionJson:a}]=await Promise.all([import("./slice-PHPVNCWX.js"),import("./symbol-resolution-DBLVXLBC.js")]),c=JSON.stringify({...a(e,t.symbolPattern),[t.kind]:s(e,t.symbolPattern,{semantic:n})}),u={serializedJson:c,sha256:h("sha256").update(c).digest("hex")};return n||x(e,t.kind,t.symbolPattern,u),u}if(t.kind==="imports"){let{imports:n}=await import("./imports-WIE3YZOB.js");return n(e,t.filePattern,{semantic:S(e)})}if(t.kind==="unused-imports"){let{unusedImports:n}=await import("./imports-WIE3YZOB.js");return n(e,t.filePattern,{semantic:S(e)})}if(t.kind==="system"){let n=v(e,t.kind,t.modulePattern);if(n)return n;let{system:s}=await import("./system-JOPKV4OG.js"),a=JSON.stringify(s(e,t.modulePattern)),c={serializedJson:a,sha256:h("sha256").update(a).digest("hex")};return x(e,t.kind,t.modulePattern,c),c}if(t.kind==="surface"){let{consumerSurface:n}=await import("./surface-MQX5MPIV.js");return n(e,t.modulePattern)}let[{codeBatch:i},{codeBatchResultOnlyJsonForSelectors:o}]=await Promise.all([import("./code-TAVIKWJI.js"),import("./code-result-json-5FEFQCAQ.js")]),l=i(e,t.selectors,t.options),r=JSON.stringify(o(e,t.selectors,l));return{serializedJson:r,sha256:h("sha256").update(r).digest("hex")}}function Gt(e,t){let i=JSON.parse(e);if(!i||typeof i!="object"||Array.isArray(i))throw new Error("Invalid query service request.");let o=i,l=o.request;if(o.mailboxVersion!==1||o.protocolVersion!==y||typeof o.id!="string"||o.id.length===0||typeof o.operationKey!="string"||o.operationKey.length===0||typeof o.clientId!="string"||o.clientId.length===0||typeof o.enqueuedAtMs!="number"||!Number.isSafeInteger(o.enqueuedAtMs)||o.enqueuedAtMs<0||typeof o.deadlineAtMs!="number"||!Number.isSafeInteger(o.deadlineAtMs)||o.deadlineAtMs<o.enqueuedAtMs||o.sessionIdentity!==t||!l||typeof l!="object"||Array.isArray(l))throw new Error("Invalid query service request envelope.");let r=l;if(typeof r.expectedGeneration!="string")throw new Error("Invalid query service request generation.");let n={mailboxVersion:1,protocolVersion:y,id:o.id,operationKey:o.operationKey,clientId:o.clientId,enqueuedAtMs:o.enqueuedAtMs,deadlineAtMs:o.deadlineAtMs,sessionIdentity:t};if(r.kind==="outline"){if(typeof r.filePattern!="string")throw new Error("Invalid query service outline request.");return{...n,request:{kind:"outline",expectedGeneration:r.expectedGeneration,filePattern:r.filePattern}}}if(r.kind==="files"){if(typeof r.pattern!="string")throw new Error("Invalid query service files request.");return{...n,request:{kind:"files",expectedGeneration:r.expectedGeneration,pattern:r.pattern}}}if(r.kind==="stats")return{...n,request:{kind:"stats",expectedGeneration:r.expectedGeneration}};if(r.kind==="members"){if(typeof r.symbolPattern!="string")throw new Error("Invalid query service members request.");return{...n,request:{kind:"members",expectedGeneration:r.expectedGeneration,symbolPattern:r.symbolPattern}}}if(r.kind==="methods"){if(typeof r.className!="string")throw new Error("Invalid query service methods request.");return{...n,request:{kind:"methods",expectedGeneration:r.expectedGeneration,className:r.className}}}if(r.kind==="file-dependencies"){if(r.direction!=="outgoing"&&r.direction!=="incoming"||typeof r.filePattern!="string")throw new Error("Invalid query service file dependencies request.");return{...n,request:{kind:"file-dependencies",expectedGeneration:r.expectedGeneration,direction:r.direction,filePattern:r.filePattern}}}if(r.kind==="imported-by"||r.kind==="hierarchy"||r.kind==="refs"||r.kind==="trace"||r.kind==="value-flow"||r.kind==="call-graph"||r.kind==="reference-neighborhood"||r.kind==="reference-reachability"||r.kind==="slice"||r.kind==="dataflow"){if(typeof r.symbolPattern!="string")throw new Error(`Invalid query service ${r.kind} request.`);return{...n,request:{kind:r.kind,expectedGeneration:r.expectedGeneration,symbolPattern:r.symbolPattern}}}if(r.kind==="dependence-slice"){if(typeof r.criterion!="string")throw new Error("Invalid query service dependence-slice request.");return{...n,request:{kind:"dependence-slice",expectedGeneration:r.expectedGeneration,criterion:r.criterion}}}if(r.kind==="by-kind"){if(typeof r.kindQuery!="string")throw new Error("Invalid query service by-kind request.");return{...n,request:{kind:"by-kind",expectedGeneration:r.expectedGeneration,kindQuery:r.kindQuery}}}if(r.kind==="kind-counts")return{...n,request:{kind:"kind-counts",expectedGeneration:r.expectedGeneration}};if(r.kind==="imports"||r.kind==="unused-imports"){if(typeof r.filePattern!="string")throw new Error(`Invalid query service ${r.kind} request.`);return{...n,request:{kind:r.kind,expectedGeneration:r.expectedGeneration,filePattern:r.filePattern}}}if(r.kind==="system"||r.kind==="surface"){if(typeof r.modulePattern!="string")throw new Error(`Invalid query service ${r.kind} request.`);return{...n,request:{kind:r.kind,expectedGeneration:r.expectedGeneration,modulePattern:r.modulePattern}}}if(r.kind==="code"){if(!Array.isArray(r.selectors)||r.selectors.length<1||r.selectors.length>24||r.selectors.some(p=>typeof p!="string"||p.length===0)||!r.options||typeof r.options!="object"||Array.isArray(r.options))throw new Error("Invalid query service code request.");let c=r.options,u=c.members;if(u!=="exported"&&u!=="all")throw new Error("Query service code members must be exported or all.");return{...n,request:{kind:"code",expectedGeneration:r.expectedGeneration,selectors:r.selectors,options:{context:Ke(c.context,"context"),members:u}}}}if(r.kind==="entrypoints"){if(!r.options||typeof r.options!="object"||Array.isArray(r.options))throw new Error("Invalid query service entrypoints request.");let c=r.options;return{...n,request:{kind:"entrypoints",expectedGeneration:r.expectedGeneration,options:{...c.search===void 0?{}:{search:L(c.search,"search")},...c.scope===void 0?{}:{scope:L(c.scope,"scope")}}}}}if(r.kind!=="source-search"||typeof r.pattern!="string"||r.pattern.length===0||!r.options||typeof r.options!="object"||Array.isArray(r.options))throw new Error("Invalid query service source-search request.");let s=r.options,a={...s.scope===void 0?{}:{scope:L(s.scope,"scope")},...s.context===void 0?{}:{context:Ke(s.context,"context")},...s.limit===void 0?{}:{limit:Wt(s.limit,"limit")},...s.regexp===void 0?{}:{regexp:Je(s.regexp,"regexp")},...s.ignoreCase===void 0?{}:{ignoreCase:Je(s.ignoreCase,"ignoreCase")},...s.ranking===void 0?{}:{ranking:qt(s.ranking)}};return{...n,request:{kind:"source-search",expectedGeneration:r.expectedGeneration,pattern:r.pattern,options:a}}}function L(e,t){if(typeof e!="string")throw new Error(`Query service option ${t} must be a string.`);return e}function Ke(e,t){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Query service option ${t} must be a non-negative safe integer.`);return e}var Ye=new WeakMap,et=new WeakMap;function v(e,t,i){let o=et.get(e);return o?.kind===t&&o.operand===i?o.result:null}function x(e,t,i,o,l=Qt){Buffer.byteLength(o.serializedJson)<=l&&et.set(e,{kind:t,operand:i,result:o})}function S(e){let t=Ye.get(e);if(t!==void 0)return t;let i=!Ge(e);return Ye.set(e,i),i}function Wt(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`Query service option ${t} must be a positive safe integer.`);return e}function Je(e,t){if(typeof e!="boolean")throw new Error(`Query service option ${t} must be a boolean.`);return e}function qt(e){if(e!=="structural")throw new Error("Query service option ranking must be structural.");return e}function zt(){let e=Number(process.env.SCIP_QUERY_QUERY_SERVICE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:Lt}function Kt(e,t){return V(e,t,ze,ze,jt,5)}var Yt=`query-service-${process.pid}-${Dt()}`,Xe=A(process.pid),Jt={pid:process.pid,...Xe?{processIdentity:Xe}:{}},Xt={isProcessAlive:U,readProcessIdentity:A},Zt=process.argv[1]?Ft(Ze(process.argv[1])).href:null;if(Zt===import.meta.url){let e=process.argv[2],t=process.argv[3];!e||!t?(console.error("query-service: expected <session-dir> <project-root>"),process.exitCode=1):await Vt(e,t)}export{Vt as runQueryServiceServer};
1
+ import"./chunk-BOZ4EXBB.js";import"./chunk-P6ODM7BY.js";import"./chunk-K3YL22N6.js";import"./chunk-TNV7SSUF.js";import"./chunk-K5TBVXU4.js";import{c as xe}from"./chunk-TZCVNCAN.js";import"./chunk-IZJ6YUKP.js";import"./chunk-4D6RO7G4.js";import"./chunk-QJRMOK5N.js";import"./chunk-DDMC3FON.js";import{a as Ee}from"./chunk-F4PUT6IT.js";import"./chunk-STMVAHJP.js";import{a as D}from"./chunk-42EOW5VI.js";import"./chunk-XKIDJCIK.js";import"./chunk-VB3GOKOS.js";import"./chunk-BGBBVSH4.js";import{b as _e}from"./chunk-7VPEEAAG.js";import{b as Ce,c as we,d as Ae}from"./chunk-S6CZA3MV.js";import{a as Ie,b as Pe}from"./chunk-H4EQHO6J.js";import"./chunk-PAVGPRHJ.js";import"./chunk-2YXE77TJ.js";import"./chunk-OGFV2BUX.js";import"./chunk-IWQPAF4F.js";import{e as ae}from"./chunk-65245JCM.js";import"./chunk-NJJMVD65.js";import{b as E,c as le}from"./chunk-H73WY2RM.js";import"./chunk-ZHMRSZFD.js";import"./chunk-ZGTYGDMF.js";import"./chunk-WRQXLNYE.js";import"./chunk-DVFP6PZI.js";import{c as T}from"./chunk-QIWXRW72.js";import"./chunk-LOVIZBJ4.js";import"./chunk-QXEUDXBT.js";import"./chunk-O2C4UILI.js";import"./chunk-WXU3DGPU.js";import"./chunk-YUKYB54I.js";import{d as Se}from"./chunk-TRBI4UKT.js";import"./chunk-WKPV2TDZ.js";import"./chunk-F4FNK44D.js";import"./chunk-ZLADLUE6.js";import"./chunk-6FFVZZL4.js";import{a as ve}from"./chunk-XTYTYZPT.js";import{a as Re,b as y}from"./chunk-4IGEOBG7.js";import"./chunk-KU3QRSTH.js";import{a as be}from"./chunk-DHEQMPLW.js";import"./chunk-4XQ4O6IM.js";import"./chunk-BZB4QPIP.js";import"./chunk-RBS42E55.js";import"./chunk-4FEWQ6RH.js";import"./chunk-BIQEF5NE.js";import"./chunk-YTAP5Y2G.js";import"./chunk-CN5EH7O3.js";import"./chunk-T3I6NHBH.js";import{F as re,H as ne,I as ie,O as oe,Q as se,Y as w,ea as ue,f as Z,g as ee,m as M}from"./chunk-J5FJMODQ.js";import"./chunk-WOFQ5DTB.js";import"./chunk-PH52RA7D.js";import"./chunk-NDUNO5JQ.js";import{a as v}from"./chunk-7Y5T6XDP.js";import{c as z,e as K}from"./chunk-X6RMKHJQ.js";import{d as $}from"./chunk-JEVRKFRL.js";import"./chunk-H75GSPRV.js";import{a as te}from"./chunk-QOIXNWQR.js";import{b as G}from"./chunk-GZKFETP5.js";import{c as X}from"./chunk-BL6XJKTA.js";import{a as pe,b as de,e as me,f as fe,j as ye,k as he,l as H,m as ge}from"./chunk-3JIQS44J.js";import{c as U,d as W}from"./chunk-O4UZSPPI.js";import{a as Y}from"./chunk-B3PYOSCX.js";import{a as g,d as x,e as k}from"./chunk-HRRFKWPZ.js";import{c as O,h as ce}from"./chunk-YULZRALL.js";import"./chunk-HGFDYOVB.js";import{c as C,d as b,e as J}from"./chunk-QZ7KQZRN.js";import"./chunk-TKD34PHN.js";import"./chunk-2HLAFUCY.js";import{c as q,t as V}from"./chunk-U5RIG3JP.js";import"./chunk-62BDNPMI.js";import{createHash as A,randomUUID as tr}from"crypto";import{rmSync as rr}from"fs";import{join as et,resolve as st}from"path";import{pathToFileURL as nr}from"url";function Me(e,t,r,n,i=!1){let o=[...e],s=[],a=new Set,c=0;for(;o.length>0&&s.length<t;){let u=o.filter(d=>c+d.evidenceCharacters<=r||i&&s.length===0);if(u.length===0)break;let l=u.filter(d=>d.roles.includes("location")||d.roles.includes("definition")).sort(n);u.sort((d,h)=>ke(h,a)-ke(d,a)||n(d,h));let p=l[0]??u[0];s.push(p),c+=p.evidenceCharacters;for(let d of Te(p))a.add(d.key);o.splice(o.indexOf(p),1)}return{selected:s,omitted:o.sort(n)}}function ke(e,t){let r=Te(e).reduce((o,s)=>o+(t.has(s.key)?0:s.weight),0),n=Math.max(0,8-e.priority)*20,i=Math.min(500,Math.ceil(e.evidenceCharacters/160));return r+n-i}function Te(e){return[...e.reasons.map(ct),...e.roles.map(t=>({key:`role:${t}`,weight:ut(t)})),{key:`file:${e.relativePath}`,weight:180},{key:`scope:${lt(e.relativePath)}`,weight:120},{key:`kind:${e.fileKind}`,weight:40},...e.symbols.map(t=>({key:`symbol:${t}`,weight:100})),...e.behaviorSignals.map(t=>({key:`behavior:${t}`,weight:70}))]}function ct(e){let t=e.indexOf(":"),r=t<0?e:e.slice(0,t);return r==="dependency"||r==="consumer"?{key:`reason:${r}`,weight:220}:{key:`reason:${e}`,weight:r==="location"||r==="definition"?1400:800}}function ut(e){switch(e){case"location":return 1200;case"definition":return 1100;case"reference":return 600;case"caller":case"callee":return 550;case"dependency":case"consumer":return 500;case"search":return 400;default:return 300}}function lt(e){let t=e.lastIndexOf("/");return t<0?e:e.slice(0,t)}var Oe=64,He=12;function Le(e,t,r={}){if(t.length===0)return[];let{context:n,limit:i}=ht(r),o=t.map(s=>{if(s.length===0)throw new Error("The source search pattern must not be empty.");return{pattern:s,regexp:r.regexp?be(s,"source search pattern",r.ignoreCase?"iu":"u"):null,literal:r.ignoreCase?s.toLocaleLowerCase():s,identities:[],fileCoverage:[],textByPath:new Map}});if(!r.regexp&&!r.ignoreCase){let s=o.map(c=>Buffer.from(c.pattern,"utf8")),a=T(e,{scope:r.scope,literalBytes:s.length===1?s[0]:s},(c,u)=>{let l=M(c.text);if(l.length!==0)for(let p of u){let d=o[p];d&&De(e,d,c,l,r)}});return o.map(c=>Ne(c,a,n,i,r))}return o.map(s=>{let a=T(e,{scope:r.scope},c=>{let u=M(c.text);u.length>0&&De(e,s,c,u,r)});return Ne(s,a,n,i,r)})}function De(e,t,r,n,i){let o=[];for(let u=0;u<n.length;u+=1)pt(t,n[u]??"",i.ignoreCase)&&o.push(u);if(o.length===0)return;let s=r.relativePath;t.textByPath.set(s,r.text);let a=r.freshness.semantic.state!=="stale"&&r.freshness.semantic.basis!=="no-compiler-document"?w(e,s):[],c=ne(e,s)?.callables??[];for(let u of o)t.identities.push(dt(e,r,u,a,c));t.fileCoverage.push({relativePath:s,matchingLines:o.length,returnedMatches:0,freshness:r.freshness})}function pt(e,t,r){let n=t.endsWith("\r")?t.slice(0,-1):t;return e.regexp?e.regexp.test(n):(r?n.toLocaleLowerCase():n).includes(e.literal)}function dt(e,t,r,n,i){let o=t.relativePath,s=ue(n,r),a=re(i,r),c=s&&!ce(s.symbol)?s:null,u=Fe(c?.startLine,a?.startLine,s?.startLine,r),l=Fe(c?.endLine,a?.endLine,s?.endLine,r),p=Pe(e,o,r,u,l);return{relativePath:o,focusLine:r,ownerSymbol:c?.symbol??null,ownerShort:c?O(c.symbol):a?.name??(s?O(s.symbol):null),ownerStartLine:p.startLine,ownerEndLine:p.endLine,fileKind:le(o),freshness:t.freshness}}function Fe(e,t,r,n){return e??t??r??n}function Ne(e,t,r,n,i){e.identities.sort(je);let o=e.identities.length>Oe?Qe(e.identities,Oe):e.identities,a=gt(e,n,i).flatMap(l=>{let p=e.textByPath.get(l.relativePath),d=p===void 0?null:mt(l.relativePath,p,l.focusLine,r);return d?[{...d,...l}]:[]}),c=new Map;for(let l of a)c.set(l.relativePath,(c.get(l.relativePath)??0)+1);for(let l of e.fileCoverage)l.returnedMatches=c.get(l.relativePath)??0;let u=ft(e.fileCoverage);return{pattern:e.pattern,mode:i.regexp?"regexp":"literal",identities:e.identities,...o.length<e.identities.length?{identityManifest:o}:{},identityCoverage:{mode:o.length===e.identities.length?"complete":"bounded",returned:o.length,total:e.identities.length,omitted:e.identities.length-o.length},matches:a,matchingLines:e.identities.length,matchingFiles:e.fileCoverage.length,omittedMatches:Math.max(0,e.identities.length-a.length),fileCoverage:e.fileCoverage,scopeHints:u.slice(0,He),omittedScopeHints:Math.max(0,u.length-He),scannedFiles:t.scannedTextFiles,textCoverage:{basis:"current-project-text-files",candidateFiles:t.candidateFiles,scannedTextFiles:t.scannedTextFiles,scannedBytes:t.scannedBytes,skippedBinaryPaths:t.skippedBinaryPaths,skippedUnreadablePaths:t.skippedUnreadablePaths,skippedOversizedPaths:t.skippedOversizedPaths,semanticFiles:t.semanticFiles}}}function mt(e,t,r,n){let i=t.split(`
2
+ `),o=t.endsWith(`
3
+ `)?i.length-1:i.length;if(r<0||r>=o)return null;let s=Math.max(0,r-n),a=Math.min(o-1,r+n);return{relativePath:e,startLine:s,endLine:a,focusLine:r,source:i.slice(s,a+1).join(`
4
+ `)}}function ft(e){let t=new Map;for(let r of e){let n=yt(r.relativePath),i=t.get(n)??{matchingLines:0,matchingFiles:0};i.matchingLines+=r.matchingLines,i.matchingFiles+=1,t.set(n,i)}return[...t.entries()].map(([r,n])=>({scope:r,...n})).sort((r,n)=>n.matchingLines-r.matchingLines||n.matchingFiles-r.matchingFiles||r.scope.localeCompare(n.scope))}function yt(e){let t=e.lastIndexOf("/");return t<0?e:e.slice(0,t)}function Qe(e,t){let r=e.map((i,o)=>({...i,priority:E(i.fileKind),sequence:o,evidenceCharacters:1,roles:["search"],reasons:["search"],symbols:i.ownerSymbol?[i.ownerSymbol]:[],behaviorSignals:[]})),n=[];for(let i of[0,1,2]){let o=t-n.length;if(o===0)break;let s=r.filter(a=>E(a.fileKind)===i);n.push(...Me(s,o,Number.MAX_SAFE_INTEGER,je).selected)}return n.map(({priority:i,sequence:o,evidenceCharacters:s,roles:a,reasons:c,symbols:u,behaviorSignals:l,...p})=>p)}function je(e,t){return E(e.fileKind)-E(t.fileKind)||+(t.ownerSymbol!==null)-+(e.ownerSymbol!==null)||e.relativePath.localeCompare(t.relativePath)||e.focusLine-t.focusLine}function ht(e){let t=e.context??6;if(!Number.isSafeInteger(t)||t<0)throw new RangeError(`context must be a non-negative safe integer; received ${t}`);let r=e.limit??12;if(!Number.isSafeInteger(r)||r<=0)throw new RangeError(`limit must be a positive safe integer; received ${r}`);return{context:t,limit:r}}function gt(e,t,r){return t===Number.MAX_SAFE_INTEGER?e.identities:r.ranking?Qe(e.identities,t):e.identities.slice(0,t)}function Be(e,t,r={}){if(t.length===0)throw new Error("The source search pattern must not be empty.");return Le(e,[t],r)[0]}import{spawn as Or}from"child_process";import{createHash as St,randomUUID as Dr}from"crypto";import{existsSync as Nr,realpathSync as Lr}from"fs";import{tmpdir as jr}from"os";import{join as qr,resolve as Rt}from"path";import{fileURLToPath as Ur}from"url";var f=27,F=1e3,$r=2*F;var bt=64*1024*1024;var Gr={maxItems:64,maxBytes:128*1024*1024,maxItemBytes:bt,maxBatch:1,responseRetentionMs:6e4};function qe(e){return St("sha256").update(de({kind:"scip-query-service-mailbox",protocolVersion:f,sessionDir:Rt(e)})).digest("hex")}function vt(e,t){let{id:r,operationKey:n,clientId:i}=e;if(!x(r)||!x(n)||!x(i)||e.sessionIdentity!==t)throw new Error("Invalid query service request envelope.");return{id:r,operationKey:n,clientId:i,sessionIdentity:t}}function Et(e){let{enqueuedAtMs:t,deadlineAtMs:r}=e;if(!k(t)||!k(r)||r<t)throw new Error("Invalid query service request envelope.");return{enqueuedAtMs:t,deadlineAtMs:r}}function $e(e,t){let r=JSON.parse(e);if(!g(r))throw new Error("Invalid query service request.");let n=r.request;if(r.mailboxVersion!==1||r.protocolVersion!==f||!g(n))throw new Error("Invalid query service request envelope.");let i=vt(r,t),o=Et(r);if(typeof n.expectedGeneration!="string")throw new Error("Invalid query service request generation.");return{mailboxVersion:1,protocolVersion:f,...i,...o,request:It(n,n.expectedGeneration)}}function m(e,t,r){let n=e[t];if(typeof n!="string")throw new Error(`Invalid query service ${r} request.`);return n}var Ve={outline:(e,t)=>({kind:"outline",expectedGeneration:t,filePattern:m(e,"filePattern","outline")}),files:(e,t)=>({kind:"files",expectedGeneration:t,pattern:m(e,"pattern","files")}),members:(e,t)=>({kind:"members",expectedGeneration:t,symbolPattern:m(e,"symbolPattern","members")}),methods:(e,t)=>({kind:"methods",expectedGeneration:t,className:m(e,"className","methods")}),"imported-by":(e,t)=>({kind:"imported-by",expectedGeneration:t,symbolPattern:m(e,"symbolPattern","imported-by")}),hierarchy:(e,t)=>({kind:"hierarchy",expectedGeneration:t,symbolPattern:m(e,"symbolPattern","hierarchy")}),refs:(e,t)=>({kind:"refs",expectedGeneration:t,symbolPattern:m(e,"symbolPattern","refs")}),"call-graph":(e,t)=>({kind:"call-graph",expectedGeneration:t,symbolPattern:m(e,"symbolPattern","call-graph")}),"dependence-slice":(e,t)=>({kind:"dependence-slice",expectedGeneration:t,criterion:m(e,"criterion","dependence-slice")}),"by-kind":(e,t)=>({kind:"by-kind",expectedGeneration:t,kindQuery:m(e,"kindQuery","by-kind")}),imports:(e,t)=>({kind:"imports",expectedGeneration:t,filePattern:m(e,"filePattern","imports")}),"unused-imports":(e,t)=>({kind:"unused-imports",expectedGeneration:t,filePattern:m(e,"filePattern","unused-imports")}),system:(e,t)=>({kind:"system",expectedGeneration:t,modulePattern:m(e,"modulePattern","system")}),surface:(e,t)=>({kind:"surface",expectedGeneration:t,modulePattern:m(e,"modulePattern","surface")}),stats:(e,t)=>({kind:"stats",expectedGeneration:t}),"kind-counts":(e,t)=>({kind:"kind-counts",expectedGeneration:t}),"file-dependencies":(e,t)=>{let r=e.direction;if(r!=="incoming"&&r!=="outgoing")throw new Error("Invalid query service file dependencies request.");return{kind:"file-dependencies",expectedGeneration:t,direction:r,filePattern:m(e,"filePattern","file dependencies")}},code:(e,t)=>{if(!Array.isArray(e.selectors)||e.selectors.length<1||e.selectors.length>24||e.selectors.some(i=>typeof i!="string"||i.length===0)||!g(e.options))throw new Error("Invalid query service code request.");let r=e.options,n=r.members;if(n!=="exported"&&n!=="all")throw new Error("Query service code members must be exported or all.");return{kind:"code",expectedGeneration:t,selectors:e.selectors,options:{context:Ue(r.context,"context"),members:n}}},entrypoints:(e,t)=>{if(!g(e.options))throw new Error("Invalid query service entrypoints request.");let r=e.options;return{kind:"entrypoints",expectedGeneration:t,options:{...r.search===void 0?{}:{search:N(r.search,"search")},...r.scope===void 0?{}:{scope:N(r.scope,"scope")}}}},"source-search":(e,t)=>{if(typeof e.pattern!="string"||e.pattern.length===0||!g(e.options))throw new Error("Invalid query service source-search request.");let r=e.options,n={...r.scope===void 0?{}:{scope:N(r.scope,"scope")},...r.context===void 0?{}:{context:Ue(r.context,"context")},...r.limit===void 0?{}:{limit:Pt(r.limit,"limit")},...r.regexp===void 0?{}:{regexp:We(r.regexp,"regexp")},...r.ignoreCase===void 0?{}:{ignoreCase:We(r.ignoreCase,"ignoreCase")},...r.ranking===void 0?{}:{ranking:xt(r.ranking)}};return{kind:"source-search",expectedGeneration:t,pattern:e.pattern,options:n}}};function It(e,t){let r=e.kind;if(typeof r!="string"||!Object.hasOwn(Ve,r))throw new Error("Invalid query service source-search request.");return Ve[r](e,t)}function N(e,t){if(typeof e!="string")throw new Error(`Query service option ${t} must be a string.`);return e}function Ue(e,t){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Query service option ${t} must be a non-negative safe integer.`);return e}function Pt(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`Query service option ${t} must be a positive safe integer.`);return e}function We(e,t){if(typeof e!="boolean")throw new Error(`Query service option ${t} must be a boolean.`);return e}function xt(e){if(e!=="structural")throw new Error("Query service option ranking must be structural.");return e}import{availableParallelism as Nt,totalmem as Lt}from"os";import{fileURLToPath as jn}from"url";import{getHeapStatistics as Qt}from"v8";async function Ge(e,t,r={}){let n=Math.max(1,Math.floor(r.batchSize??64)),i=r.collectGarbage??v,o=[],s=0;for(let a=0;a<t.length;a+=n){for(let c of t.slice(a,a+n)){for(let u of w(e,c))e.isIgnored(u.relativePath)||o.push(u);se(e,c),oe(e,c),ie(e,c),s+=1}r.onBatch?.({files:s,total:t.length,definitions:o.length}),i(),await r.yieldToEventLoop?.()}return{files:s,definitions:o}}import{execFileSync as an}from"child_process";import{createHash as un}from"crypto";import{lstatSync as pn,readlinkSync as dn,realpathSync as mn,statSync as fn}from"fs";import{dirname as hn,isAbsolute as gn,join as Sn,posix as Rn,relative as bn,resolve as vn,sep as En}from"path";var Pn=512*1024*1024;function ze(e){return pe({version:e.version,...e.base?{base:e.base}:{},files:[...e.files].sort((t,r)=>t.path.localeCompare(r.path))})}function L(e){return JSON.stringify({...e.clojureConfigPath?{clojureConfigPath:e.clojureConfigPath}:{},files:[...e.files].sort((t,r)=>t.path.localeCompare(r.path)).map(t=>({hash:t.hash,path:t.path,size:t.size})),languages:[...e.languages].sort(),pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),version:e.version})}var wt="scip-query:collaboration-domain",At="scip-query:workspace-instance",_t="scip-query:index-generation",kt="scip-query:repository-content",Ke="scip-query:index-inputs",Mt="scip-query:index-inputs";function Ye(e){let t=e.snapshot,r=e.observedSourceKinds?new Set(e.observedSourceKinds):void 0,n=e.gitContext??t?.gitContext??(r?.has("live-workspace")?V(e.projectRoot):void 0),i=Tt(e,n),o=r??Ot(i),s=Ht(i,o);return{schemaVersion:Re,observedAt:(e.observedAt??(t?new Date(t.capturedAt):new Date)).toISOString(),facts:i,...s,...n?{diagnostics:Dt(n)}:{}}}function Tt(e,t){let r={},n=e.collaborationDomainId??e.db?.config.collaborationDomainId;if(n&&(r.collaborationDomain=y(wt,1,n)),t&&(r.workspaceInstance=y(At,1,t.worktreeId)),e.snapshot&&(r.wholeContent=y(kt,1,ze(e.snapshot.repositoryContent)),r.relevantInputs=[{subject:Mt,identity:y(Ke,e.snapshot.indexInputs.version,L(e.snapshot.indexInputs))}]),e.db){let i=e.snapshot?Ft(e.db.generation.metadataRaw):void 0;r.index={generation:y(_t,1,e.db.generation.identity),...i?{inputs:i}:{},source:e.db.generation.source}}return r}function Ot(e){let t=new Set;return e.index&&t.add("index-generation"),e.wholeContent?t.add("repository-snapshot"):e.workspaceInstance&&t.add("live-workspace"),t}function Ht(e,t){let r=[],n=[],i=(o,s)=>{r.push(o),n.push({source:o.kind,kind:s})};return e.index&&t.has("index-generation")&&i({kind:"index-generation",identity:e.index.generation},e.index.source==="immutable"?"immutable":"not-established"),e.wholeContent&&t.has("repository-snapshot")&&i({kind:"repository-snapshot",identity:e.wholeContent},"fixed-snapshot"),e.workspaceInstance&&t.has("live-workspace")&&i({kind:"live-workspace",identity:e.workspaceInstance},"not-established"),t.has("process")&&i({kind:"process"},"not-established"),r.length===0&&i({kind:"process"},"not-established"),{observedSources:r,stabilityProofs:n}}function Dt(e){return{clean:e.clean,...e.headCommit?{headCommit:e.headCommit}:{},...e.treeOid?{treeOid:e.treeOid}:{}}}function Ft(e){if(!e)return;let t=$(e);if(t.kind!=="legacy"&&t.kind!=="supported")return;let r=q(t.metadata.fingerprint);return r&&Number.isSafeInteger(r.version)&&r.version>0?y(Ke,r.version,L(r)):void 0}var jt=1,Bt=1;var ei=10*6e4,qt=25e3,Vt=2500;var Ut=4,Wt=12,$t=1,Gt=4,zt=7*1024*1024*1024;var ti=10*6e4;var ri=10*6e4;var Kt=new Set(["vue-component-duplicates","vue-composable-candidates","vue-large-view-pressure"]),ni=new Set([...Kt,"suppressions"]);var Je=2,Xe=Z({kind:"health-semantic-prewarm",invalidation:ee("health-semantic-prewarm"),serialize:e=>JSON.stringify(e),deserialize:Yt});function Yt(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let r=t;return r.version!==Je||!I(r.definitions)||!I(r.referenceCacheWrites)||!I(r.referenceIncomplete)||!I(r.calleeRows)||!I(r.warmedAt)?null:{version:Je,definitions:r.definitions,referenceCacheWrites:r.referenceCacheWrites,referenceIncomplete:r.referenceIncomplete,calleeRows:r.calleeRows,warmedAt:r.warmedAt}}catch{return null}}function I(e){return typeof e=="number"&&Number.isFinite(e)}function Jt(e,t){return!t||t.count<=1?[...e]:e.filter((r,n)=>n%t.count===t.index)}function Ze(e){let t=D(e);return t.symbols>=qt||t.documents>=Vt}var ii={env:process.env,projectFingerprint:K,semanticEngineFingerprint:Xt,readMarker:(e,t,r)=>Xe.read(e,t,r),writeMarker:(e,t,r,n)=>Xe.write(e,t,r,n),projectFiles:(e,t)=>Jt(te(e,{scope:t.scope,includeIgnored:!1}),t.shard),candidateDefinitions:async(e,t,r)=>{let n=await Ge(e,r,{collectGarbage:v,yieldToEventLoop:()=>new Promise(a=>setImmediate(a))}),i=new Set(r),o=new Set(n.definitions.map(a=>a.symbolId)),s=[];for(let a of[{},{requireCallableSymbol:!0},{requireFunctionLikeSymbol:!0}])for(let c of xe(e,{...a,scope:t.scope}))!i.has(c.relativePath)||o.has(c.symbolId)||(o.add(c.symbolId),s.push(c));return[...n.definitions,...s].filter(a=>we(a.relativePath)!==null)},warmReferenceFragments:(e,t,r)=>ae(e,n=>Ce(e,n),{onBatch:t,...r?{files:r}:{}}),materializeReferences:(e,t,r)=>Ae(e).materializeReferences(t,r),materializeCallees:_e,releaseSemanticMemory:e=>G(e,{groups:["semantic-provider"]}),heapUsedFraction:()=>{let e=Qt();return e.heap_size_limit>0?e.used_heap_size/e.heap_size_limit:0},collectGarbage:v,yieldToEventLoop:()=>new Promise(e=>setImmediate(e))};function Xt(e){return z(JSON.stringify({kind:"health-semantic-prewarm-engine",rust:Se(e.config.projectRoot)}))}var oi=Q({envKey:"SCIP_QUERY_HEALTH_CONCURRENCY",defaultMinimum:Ut,defaultMaximum:Wt}),si=Q({envKey:"SCIP_QUERY_HEALTH_FULL_CONCURRENCY",defaultMinimum:$t,defaultMaximum:Gt,memoryPerTaskBytes:zt});var ai=Q({envKey:"SCIP_QUERY_DIFF_IMPACT_CONCURRENCY",defaultMinimum:jt,defaultMaximum:Bt});function Q(e){return(t,r=process.env,n=Nt,i=Lt())=>Zt(t,r,n,i,e)}function Zt(e,t,r,n,i){let o=t[i.envKey],s=er(r,n,i),a=o?parseInt(o,10):s;return!Number.isFinite(a)||a<1?Math.min(s,e):Math.min(a,e)}function er(e,t,r){let n=e(),i=Number.isFinite(n)?Math.max(r.defaultMinimum,n-1):0,o=r.memoryPerTaskBytes!==void 0&&Number.isFinite(t)&&t>0?Math.floor(t/2/r.memoryPerTaskBytes):Number.POSITIVE_INFINITY;return Math.min(r.defaultMaximum,o,Math.max(r.defaultMinimum,i))}var ir=3e4,tt=5,or=100,sr=1024*1024,P={maxItems:64,maxBytes:128*1024*1024,maxItemBytes:64*1024*1024,maxBatch:1,responseRetentionMs:6e4};async function ar(e,t){let r=me(e);fe(r);let n=X(et(e,"server.lock"),{kind:"query-service-server",detail:{projectRoot:st(t)}});if(n.kind!=="acquired")return;let i=et(e,"server.json"),o=[()=>n.lock.release(),()=>rr(i,{force:!0})],s=[];try{let a=ve(t);o.push(()=>a.close());let c=Ee([r.pendingDir,r.legacyRequestDir]);o.push(()=>c.close()),await cr(e,r,i,a,c)}catch(a){s.push(a)}for(let a of o.reverse())try{a()}catch(c){s.push(c)}if(s.length===1)throw s[0];if(s.length>1)throw new AggregateError(s,"Query service execution and cleanup failed.")}async function cr(e,t,r,n,i){let o=qe(e),s=C(process.pid),a=!1,c=!1,u=b(),l=Number.NEGATIVE_INFINITY,p=0,d=()=>{a=!0};process.once("SIGINT",d),process.once("SIGTERM",d);let h=(S=!1)=>{let R=b();if(!S&&R-l<F)return;l=R;let B={protocolVersion:f,sessionIdentity:o,pid:process.pid,...s?{processIdentity:s}:{},generation:n.generation.identity,heartbeatAtMs:Date.now()};S?W(r,B):U(r,B)};try{h(!0);let S=pr();for(;!a&&!c&&b()-u<S;){let R=await ur(t,n,o,()=>{c=!0});R>0?(p=0,u=b(),h()):(p+=1,h()),await i.wait(dr(R,p))}}finally{process.off("SIGINT",d),process.off("SIGTERM",d)}}async function ur(e,t,r,n){let i=ye(e,{ownerId:mr,nowMs:Date.now(),limits:P,owner:fr,liveness:yr,durability:"visibility"}),o=0;for(let s of i){let a=s.requestId;try{let c=$e(he(s,P),r);if(a=c.id,gr(c,s),c.deadlineAtMs<Date.now())throw new Error("Query service request expired before processing.");if(c.request.expectedGeneration!==t.generation.identity){H(e,s,{ok:!1,protocolVersion:f,id:a,generation:t.generation.identity,errorCode:"generation-mismatch",error:"Persistent query service opened a different generation."},{nowMs:Date.now(),limits:P,durability:"visibility"}),n(),o+=1;continue}let u=await lr(t,c.request),l=Ye({projectRoot:t.config.projectRoot,db:t,observedSourceKinds:["index-generation"]}),p=Date.now();if(c.deadlineAtMs<p)throw new Error("Query service request expired while processing.");H(e,s,{ok:!0,protocolVersion:f,id:a,generation:t.generation.identity,result:u,observationReceipt:l},{nowMs:p,limits:P,durability:"visibility"})}catch(c){let u=c instanceof Error?c.message:String(c);ge(e,s,{ok:!1,protocolVersion:f,id:a,errorCode:"request-failed",error:u},u,{nowMs:Date.now(),limits:P})}o+=1}return o}var j={"source-search":async(e,t)=>Be(e,t.pattern,t.options),outline:async(e,t)=>Ie(e,t.filePattern),entrypoints:async(e,t)=>{let{entryPoints:r}=await import("./service-queries-2WAJI7R6.js");return r(e,t.options)},files:async(e,t)=>{let{files:r}=await import("./files-K4AI3JUM.js");return r(e,t.pattern)},stats:async e=>{let{stats:t}=await import("./stats-G7DIV6VU.js");return t(e)},members:async(e,t)=>{let[{members:r},{symbolResolutionJson:n}]=await Promise.all([import("./members-K3PHMF5S.js"),import("./code-result-json-ANTBEDFP.js")]);return{...n(e,t.symbolPattern),members:r(e,t.symbolPattern)}},methods:async(e,t)=>{let{resolveMethods:r}=await import("./methods-E7KVMBX4.js");return r(e,{className:t.className})},"file-dependencies":async(e,t)=>{let{deps:r,rdeps:n}=await import("./deps-EOWFC6FD.js");return t.direction==="outgoing"?r(e,t.filePattern):n(e,t.filePattern)},"imported-by":async(e,t)=>{let{importedBy:r}=await import("./imports-WH365QY4.js");return r(e,t.symbolPattern)},hierarchy:async(e,t)=>{let[{hierarchy:r},{withSymbolResolutionJson:n}]=await Promise.all([import("./hierarchy-6W5NDIFI.js"),import("./code-result-json-ANTBEDFP.js")]);return n(e,t.symbolPattern,r(e,t.symbolPattern),"hierarchy")},"by-kind":async(e,t)=>{let{byKind:r}=await import("./by-kind-PRVFAGTQ.js");return r(e,t.kindQuery)},"kind-counts":async e=>{let{kindCounts:t}=await import("./by-kind-PRVFAGTQ.js");return t(e)},refs:async(e,t)=>{let[{refs:r},{compareReferenceKey:n},{withSymbolResolutionJson:i}]=await Promise.all([import("./refs-CCBJG7WK.js"),import("./refs-pagination-DRNLVU4S.js"),import("./code-result-json-ANTBEDFP.js")]),o=_(e),s=r(e,t.symbolPattern,{semantic:o}).sort(n);return{...i(e,t.symbolPattern,s,"references"),pagination:{cursorVersion:2,producer:"complete-only",semanticEnrichment:o}}},"dependence-slice":async(e,t)=>{let r=nt(e,t.kind,t.criterion);if(r)return r;let{dependenceSlice:n}=await import("./service-queries-2WAJI7R6.js"),i=JSON.stringify(n(e,t.criterion)),o={serializedJson:i,sha256:A("sha256").update(i).digest("hex")};return it(e,t.kind,t.criterion,o),o},"call-graph":async(e,t)=>{let[{callGraph:r},{symbolResolutionJson:n}]=await Promise.all([import("./call-graph-DVPAQV2F.js"),import("./code-result-json-ANTBEDFP.js")]),i=JSON.stringify({...n(e,t.symbolPattern),callGraph:r(e,t.symbolPattern,{semantic:_(e)})});return{serializedJson:i,sha256:A("sha256").update(i).digest("hex")}},imports:async(e,t)=>{let{imports:r}=await import("./imports-WH365QY4.js");return r(e,t.filePattern,{semantic:_(e)})},"unused-imports":async(e,t)=>{let{unusedImports:r}=await import("./imports-WH365QY4.js");return r(e,t.filePattern,{semantic:_(e)})},system:async(e,t)=>{let r=nt(e,t.kind,t.modulePattern);if(r)return r;let{system:n}=await import("./system-ZBMSHJXU.js"),i=JSON.stringify(n(e,t.modulePattern)),o={serializedJson:i,sha256:A("sha256").update(i).digest("hex")};return it(e,t.kind,t.modulePattern,o),o},surface:async(e,t)=>{let{consumerSurface:r}=await import("./surface-IO55UALI.js");return r(e,t.modulePattern)},code:async(e,t)=>{let[{codeBatch:r},{codeBatchResultOnlyJsonForSelectors:n}]=await Promise.all([import("./code-IL5WH3NZ.js"),import("./code-result-json-ANTBEDFP.js")]),i=r(e,t.selectors,t.options),o=JSON.stringify(n(e,t.selectors,i));return{serializedJson:o,sha256:A("sha256").update(o).digest("hex")}}};async function lr(e,t){return(Object.hasOwn(j,t.kind)?j[t.kind]:j.code)(e,t)}var rt=new WeakMap,at=new WeakMap;function nt(e,t,r){let n=at.get(e);return n?.kind===t&&n.operand===r?n.result:null}function it(e,t,r,n,i=sr){Buffer.byteLength(n.serializedJson)<=i&&at.set(e,{kind:t,operand:r,result:n})}function _(e){let t=rt.get(e);if(t!==void 0)return t;let r=!Ze(e);return rt.set(e,r),r}function pr(){let e=Number(process.env.SCIP_QUERY_QUERY_SERVICE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:ir}function dr(e,t){return J(e,t,tt,tt,or,5)}var mr=`query-service-${process.pid}-${tr()}`,ot=C(process.pid),fr={pid:process.pid,...ot?{processIdentity:ot}:{}},yr={isProcessAlive:Y,readProcessIdentity:C},hr=process.argv[1]?nr(st(process.argv[1])).href:null;if(hr===import.meta.url){let e=process.argv[2],t=process.argv[3];!e||!t?(console.error("query-service: expected <session-dir> <project-root>"),process.exitCode=1):await ar(e,t)}function gr(e,t){if(e.id!==t.requestId||e.operationKey!==t.operationKey||e.clientId!==t.clientId||e.deadlineAtMs!==t.deadlineAtMs)throw new Error("Query service request identity does not match its mailbox claim.")}export{ar as runQueryServiceServer};
5
5
  //# sourceMappingURL=query-service-server.js.map
@@ -0,0 +1,2 @@
1
+ import{a,b}from"./chunk-K3YL22N6.js";import"./chunk-7VPEEAAG.js";import"./chunk-S6CZA3MV.js";import"./chunk-65245JCM.js";import"./chunk-NJJMVD65.js";import"./chunk-ZGTYGDMF.js";import"./chunk-WRQXLNYE.js";import"./chunk-LOVIZBJ4.js";import"./chunk-QXEUDXBT.js";import"./chunk-WXU3DGPU.js";import"./chunk-TRBI4UKT.js";import"./chunk-WKPV2TDZ.js";import"./chunk-F4FNK44D.js";import"./chunk-ZLADLUE6.js";import"./chunk-6FFVZZL4.js";import"./chunk-4XQ4O6IM.js";import"./chunk-BZB4QPIP.js";import"./chunk-CN5EH7O3.js";import"./chunk-T3I6NHBH.js";import"./chunk-J5FJMODQ.js";import"./chunk-WOFQ5DTB.js";import"./chunk-PH52RA7D.js";import"./chunk-7Y5T6XDP.js";import"./chunk-X6RMKHJQ.js";import"./chunk-JEVRKFRL.js";import"./chunk-QOIXNWQR.js";import"./chunk-GZKFETP5.js";import"./chunk-3JIQS44J.js";import"./chunk-O4UZSPPI.js";import"./chunk-B3PYOSCX.js";import"./chunk-HRRFKWPZ.js";import"./chunk-YULZRALL.js";import"./chunk-HGFDYOVB.js";import"./chunk-QZ7KQZRN.js";import"./chunk-TKD34PHN.js";import"./chunk-2HLAFUCY.js";import"./chunk-U5RIG3JP.js";import"./chunk-62BDNPMI.js";export{b as referenceLocation,a as refs};
2
+ //# sourceMappingURL=refs-CCBJG7WK.js.map