codebaseiq 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (432) hide show
  1. package/CHANGELOG.md +481 -0
  2. package/LICENSE +202 -0
  3. package/README.md +349 -0
  4. package/dist/augment-vue-worker.js +2 -0
  5. package/dist/call-graph-evidence-gNsxjCW8.d.ts +16 -0
  6. package/dist/change-analysis-types-CCtoCHbC.d.ts +9 -0
  7. package/dist/chunk-2Q2LW5JW.js +14 -0
  8. package/dist/chunk-2X7V4HS4.js +88 -0
  9. package/dist/chunk-34WBMAYK.js +2 -0
  10. package/dist/chunk-35NLDRZC.js +2 -0
  11. package/dist/chunk-362QOSFD.js +3 -0
  12. package/dist/chunk-3IER7Q6H.js +12 -0
  13. package/dist/chunk-3JSXXYTZ.js +345 -0
  14. package/dist/chunk-3LCDIREB.js +4 -0
  15. package/dist/chunk-476NR5B7.js +2 -0
  16. package/dist/chunk-4FC325IF.js +30 -0
  17. package/dist/chunk-4WKDMDEW.js +9 -0
  18. package/dist/chunk-4XTAUQFD.js +2 -0
  19. package/dist/chunk-5PUWMSDU.js +26 -0
  20. package/dist/chunk-5VKBFZZU.js +3 -0
  21. package/dist/chunk-6BQ3DSPK.js +2 -0
  22. package/dist/chunk-6CS3UQTN.js +3 -0
  23. package/dist/chunk-6MUIJMVL.js +6 -0
  24. package/dist/chunk-6NW7MU72.js +40 -0
  25. package/dist/chunk-6OAHRI2D.js +6 -0
  26. package/dist/chunk-6YTSKJJ3.js +2 -0
  27. package/dist/chunk-7FND7D7N.js +2 -0
  28. package/dist/chunk-7MGU3HPH.js +2 -0
  29. package/dist/chunk-7NVGT435.js +2 -0
  30. package/dist/chunk-7XAN6GKB.js +2 -0
  31. package/dist/chunk-AAQQPKCU.js +2 -0
  32. package/dist/chunk-ADTBPVUZ.js +21 -0
  33. package/dist/chunk-AKB7V7TV.js +2 -0
  34. package/dist/chunk-ANFVSJWQ.js +11 -0
  35. package/dist/chunk-B2OB55RR.js +3 -0
  36. package/dist/chunk-B3UYV66Z.js +4 -0
  37. package/dist/chunk-B75HZHUP.js +2 -0
  38. package/dist/chunk-BFFZDZQV.js +2 -0
  39. package/dist/chunk-BGBBVSH4.js +2 -0
  40. package/dist/chunk-BH5F2Q4O.js +2 -0
  41. package/dist/chunk-BJ6SQAEN.js +2 -0
  42. package/dist/chunk-BMYOV5GP.js +77 -0
  43. package/dist/chunk-BVAJLC5A.js +7 -0
  44. package/dist/chunk-C6SBF2WH.js +4 -0
  45. package/dist/chunk-C74PPYLA.js +3 -0
  46. package/dist/chunk-C7QOQX32.js +8 -0
  47. package/dist/chunk-CAUCPUOF.js +7 -0
  48. package/dist/chunk-CO5R3UNA.js +2 -0
  49. package/dist/chunk-CQP3THUZ.js +7 -0
  50. package/dist/chunk-CVYSU6BX.js +16 -0
  51. package/dist/chunk-CWONGW6P.js +3 -0
  52. package/dist/chunk-DDZ7VHWV.js +20 -0
  53. package/dist/chunk-DGXRDLV5.js +2 -0
  54. package/dist/chunk-DO6WQD2T.js +3 -0
  55. package/dist/chunk-DQMDCD24.js +2 -0
  56. package/dist/chunk-DR2LURYU.js +3 -0
  57. package/dist/chunk-DRENNWRG.js +2 -0
  58. package/dist/chunk-ECQBG7PW.js +564 -0
  59. package/dist/chunk-EF2R3WNQ.js +2 -0
  60. package/dist/chunk-ELNRLMC5.js +29 -0
  61. package/dist/chunk-EMNIHCRB.js +18 -0
  62. package/dist/chunk-ENCCHKM6.js +5 -0
  63. package/dist/chunk-EZNMUY67.js +5 -0
  64. package/dist/chunk-FAJQ7LWY.js +3 -0
  65. package/dist/chunk-FDGD5AB5.js +2 -0
  66. package/dist/chunk-FETNQCFO.js +117 -0
  67. package/dist/chunk-FM5BPL4V.js +60 -0
  68. package/dist/chunk-FQKZWM4L.js +49 -0
  69. package/dist/chunk-FW53T7EB.js +2 -0
  70. package/dist/chunk-G6XFR4ZL.js +4 -0
  71. package/dist/chunk-GCHRX4YW.js +4 -0
  72. package/dist/chunk-GTIYTDRE.js +562 -0
  73. package/dist/chunk-GTXSJDCO.js +2 -0
  74. package/dist/chunk-GW6Z3WGY.js +2 -0
  75. package/dist/chunk-H3LGFZVK.js +2 -0
  76. package/dist/chunk-HKQUXIFO.js +2 -0
  77. package/dist/chunk-HOA5YGOH.js +3 -0
  78. package/dist/chunk-HPJRBHVT.js +3 -0
  79. package/dist/chunk-HRWGYWRJ.js +49 -0
  80. package/dist/chunk-I2T2LLK2.js +4 -0
  81. package/dist/chunk-ICFDQHAM.js +3 -0
  82. package/dist/chunk-ID63777H.js +4 -0
  83. package/dist/chunk-IJ4HMYBE.js +3 -0
  84. package/dist/chunk-ILMHV3KM.js +2 -0
  85. package/dist/chunk-IOP6FWIM.js +2 -0
  86. package/dist/chunk-IRQOAM5G.js +2 -0
  87. package/dist/chunk-J77SU6VA.js +38 -0
  88. package/dist/chunk-JE3WZ6II.js +2 -0
  89. package/dist/chunk-JEJLSICM.js +4 -0
  90. package/dist/chunk-JOIRNPPY.js +2 -0
  91. package/dist/chunk-JSOYNVWH.js +3 -0
  92. package/dist/chunk-KMITESMT.js +2 -0
  93. package/dist/chunk-KUW32IRO.js +2 -0
  94. package/dist/chunk-KWVHSKHK.js +31 -0
  95. package/dist/chunk-L4NRUAGJ.js +18 -0
  96. package/dist/chunk-L57ZKWVG.js +6 -0
  97. package/dist/chunk-LTA3BRZX.js +2 -0
  98. package/dist/chunk-LU3BMVH2.js +10 -0
  99. package/dist/chunk-LZYFLFEH.js +2 -0
  100. package/dist/chunk-MOVBWNIP.js +16 -0
  101. package/dist/chunk-MVB3DAEY.js +3 -0
  102. package/dist/chunk-N3IQCBCF.js +29 -0
  103. package/dist/chunk-NAUD7LCA.js +2 -0
  104. package/dist/chunk-NCZUNH3E.js +109 -0
  105. package/dist/chunk-NE6IU5ZD.js +5 -0
  106. package/dist/chunk-NEDP5RFQ.js +60 -0
  107. package/dist/chunk-NMTSZXCL.js +2 -0
  108. package/dist/chunk-NNJ2KZZG.js +4 -0
  109. package/dist/chunk-NNO6A2PO.js +2 -0
  110. package/dist/chunk-NNOKTMZT.js +20 -0
  111. package/dist/chunk-O6QTXQPJ.js +13 -0
  112. package/dist/chunk-OANDYLJQ.js +2 -0
  113. package/dist/chunk-OFBE4NGP.js +2 -0
  114. package/dist/chunk-OGTFJ3XD.js +2 -0
  115. package/dist/chunk-OL6KJP3N.js +16 -0
  116. package/dist/chunk-OLF4MA5W.js +8 -0
  117. package/dist/chunk-OTOKVOJ3.js +2 -0
  118. package/dist/chunk-OVTS4DKB.js +2 -0
  119. package/dist/chunk-OZYRSMSH.js +3 -0
  120. package/dist/chunk-P5XHIJHI.js +2 -0
  121. package/dist/chunk-PBI2LFKH.js +2 -0
  122. package/dist/chunk-PIOMTC27.js +2 -0
  123. package/dist/chunk-PTAWHLVJ.js +6 -0
  124. package/dist/chunk-PX4RYAAK.js +2 -0
  125. package/dist/chunk-PYAB5SM6.js +7 -0
  126. package/dist/chunk-Q5ELPRKQ.js +2 -0
  127. package/dist/chunk-Q65CQ4XL.js +2 -0
  128. package/dist/chunk-Q72QSKXC.js +308 -0
  129. package/dist/chunk-QCN62RTF.js +3 -0
  130. package/dist/chunk-QDCCHMVZ.js +2 -0
  131. package/dist/chunk-QHRNXP3C.js +3 -0
  132. package/dist/chunk-QKPLA6IC.js +2 -0
  133. package/dist/chunk-QOKYJ33H.js +2 -0
  134. package/dist/chunk-QW7EP6WI.js +21 -0
  135. package/dist/chunk-R2NOK63J.js +4 -0
  136. package/dist/chunk-RBAS5ZHI.js +2 -0
  137. package/dist/chunk-RDBI2RXU.js +9 -0
  138. package/dist/chunk-RKEJ6VTF.js +73 -0
  139. package/dist/chunk-RR7SX44N.js +35 -0
  140. package/dist/chunk-RU65DDUP.js +215 -0
  141. package/dist/chunk-SELM5MER.js +2 -0
  142. package/dist/chunk-SGX43S2L.js +2 -0
  143. package/dist/chunk-SMRBZ6EC.js +2 -0
  144. package/dist/chunk-SNNWPCN7.js +4 -0
  145. package/dist/chunk-ST7V3SKN.js +2 -0
  146. package/dist/chunk-SWHMHUKF.js +2 -0
  147. package/dist/chunk-SYDJMPES.js +2 -0
  148. package/dist/chunk-SZD2KF7Q.js +2 -0
  149. package/dist/chunk-T3DGWPXM.js +3 -0
  150. package/dist/chunk-TFZB6XTM.js +239 -0
  151. package/dist/chunk-TIIC3ZE7.js +2 -0
  152. package/dist/chunk-TRRC4ZJ7.js +2 -0
  153. package/dist/chunk-TXXOEMZJ.js +2 -0
  154. package/dist/chunk-UBGWN7I4.js +2 -0
  155. package/dist/chunk-UCD3H3UZ.js +5 -0
  156. package/dist/chunk-UDS562V4.js +5 -0
  157. package/dist/chunk-UNBY47BC.js +3 -0
  158. package/dist/chunk-UP3BUZR5.js +74 -0
  159. package/dist/chunk-UXM43C7T.js +3 -0
  160. package/dist/chunk-UZGZB3VB.js +3 -0
  161. package/dist/chunk-VE5AVNMP.js +2 -0
  162. package/dist/chunk-VEXUL62T.js +2 -0
  163. package/dist/chunk-VFY6Y2H6.js +61 -0
  164. package/dist/chunk-VUIYB2V3.js +2 -0
  165. package/dist/chunk-VXYS3FZD.js +23 -0
  166. package/dist/chunk-WE5RZHZ7.js +5 -0
  167. package/dist/chunk-WMPRTGH2.js +2 -0
  168. package/dist/chunk-WOQBZPIF.js +2 -0
  169. package/dist/chunk-XLQ3GLWZ.js +2 -0
  170. package/dist/chunk-XME3HPXZ.js +2 -0
  171. package/dist/chunk-XMQ23E27.js +2 -0
  172. package/dist/chunk-XWUOUWYI.js +2 -0
  173. package/dist/chunk-XZEE23VG.js +5 -0
  174. package/dist/chunk-Y6KHROC3.js +7 -0
  175. package/dist/chunk-YESXMKX3.js +3 -0
  176. package/dist/chunk-YMGZZEW4.js +2 -0
  177. package/dist/chunk-YSNONTJ2.js +2 -0
  178. package/dist/chunk-YUKYB54I.js +1 -0
  179. package/dist/chunk-YVCIMIOC.js +12 -0
  180. package/dist/chunk-Z54RD7VL.js +3 -0
  181. package/dist/chunk-ZKX2FRS6.js +15 -0
  182. package/dist/chunk-ZMI2JSX2.js +2 -0
  183. package/dist/chunk-ZV3JV5G5.js +8 -0
  184. package/dist/chunk-ZZ3MWF33.js +4 -0
  185. package/dist/chunk-ZZXSWSN6.js +2 -0
  186. package/dist/cli-context-3SNLDYBM.js +3 -0
  187. package/dist/cli-context-T3B7W6GG.js +2 -0
  188. package/dist/cli-program-YNOXO72B.js +7 -0
  189. package/dist/cli.js +3 -0
  190. package/dist/code-DlqpBDd0.d.ts +121 -0
  191. package/dist/command-descriptors-6AOUKWW7.js +346 -0
  192. package/dist/command-descriptors-ZFKJSRUP.js +344 -0
  193. package/dist/command-panels-SZONPMLJ.js +3 -0
  194. package/dist/config-types-BNoC96J3.d.ts +560 -0
  195. package/dist/db-D7sauVFH.d.ts +95 -0
  196. package/dist/direct-navigation-DP4LVMRX.js +3 -0
  197. package/dist/direct-navigation-FLUS3BT6.js +2 -0
  198. package/dist/exploration-topology-BG4v30HZ.d.ts +256 -0
  199. package/dist/file-dep-graph-Bqg3t3Px.d.ts +4 -0
  200. package/dist/file-kind-BKCVMNUf.d.ts +10 -0
  201. package/dist/frontend-behavior-evidence-EfM4_9bc.d.ts +4 -0
  202. package/dist/git-history-ChNHbfZQ.d.ts +13 -0
  203. package/dist/graph-evidence-BIFqyisO.d.ts +131 -0
  204. package/dist/health-DJaZXg8I.d.ts +340 -0
  205. package/dist/index.d.ts +183 -0
  206. package/dist/index.js +2 -0
  207. package/dist/invocation-command-descriptors-QT2JMY5J.js +3 -0
  208. package/dist/invocation-command-descriptors-YN4QJEAX.js +2 -0
  209. package/dist/next-anchor-candidates-BwMczMvX.d.ts +90 -0
  210. package/dist/output-continuation-command-2V2SL4TD.js +2 -0
  211. package/dist/output-continuation-command-65J5IP3O.js +3 -0
  212. package/dist/postinstall.js +3 -0
  213. package/dist/project-reindex-5JOKXAXT.js +2 -0
  214. package/dist/project-reindex-UQBIKO4M.js +3 -0
  215. package/dist/queries/affected.d.ts +40 -0
  216. package/dist/queries/affected.js +2 -0
  217. package/dist/queries/anchors.d.ts +123 -0
  218. package/dist/queries/anchors.js +2 -0
  219. package/dist/queries/architecture.d.ts +166 -0
  220. package/dist/queries/architecture.js +2 -0
  221. package/dist/queries/bottlenecks.d.ts +68 -0
  222. package/dist/queries/bottlenecks.js +2 -0
  223. package/dist/queries/by-kind.d.ts +27 -0
  224. package/dist/queries/by-kind.js +2 -0
  225. package/dist/queries/call-graph.d.ts +52 -0
  226. package/dist/queries/call-graph.js +2 -0
  227. package/dist/queries/change-surface.d.ts +55 -0
  228. package/dist/queries/change-surface.js +2 -0
  229. package/dist/queries/cleanup-plan.d.ts +66 -0
  230. package/dist/queries/cleanup-plan.js +2 -0
  231. package/dist/queries/co-change.d.ts +90 -0
  232. package/dist/queries/co-change.js +2 -0
  233. package/dist/queries/code.d.ts +6 -0
  234. package/dist/queries/code.js +2 -0
  235. package/dist/queries/complexity-hotspots.d.ts +61 -0
  236. package/dist/queries/complexity-hotspots.js +2 -0
  237. package/dist/queries/complexity.d.ts +74 -0
  238. package/dist/queries/complexity.js +2 -0
  239. package/dist/queries/context.d.ts +146 -0
  240. package/dist/queries/context.js +2 -0
  241. package/dist/queries/convergence.d.ts +33 -0
  242. package/dist/queries/convergence.js +2 -0
  243. package/dist/queries/coupling.d.ts +32 -0
  244. package/dist/queries/coupling.js +2 -0
  245. package/dist/queries/cycles.d.ts +66 -0
  246. package/dist/queries/cycles.js +2 -0
  247. package/dist/queries/dataflow.d.ts +77 -0
  248. package/dist/queries/dataflow.js +2 -0
  249. package/dist/queries/dead.d.ts +58 -0
  250. package/dist/queries/dead.js +2 -0
  251. package/dist/queries/decorative-checkers.d.ts +34 -0
  252. package/dist/queries/decorative-checkers.js +2 -0
  253. package/dist/queries/deep-chains.d.ts +5 -0
  254. package/dist/queries/deep-chains.js +2 -0
  255. package/dist/queries/dependence-slice.d.ts +46 -0
  256. package/dist/queries/dependence-slice.js +2 -0
  257. package/dist/queries/dependency-depth.d.ts +49 -0
  258. package/dist/queries/dependency-depth.js +2 -0
  259. package/dist/queries/deps.d.ts +15 -0
  260. package/dist/queries/deps.js +2 -0
  261. package/dist/queries/diff-impact.d.ts +165 -0
  262. package/dist/queries/diff-impact.js +2 -0
  263. package/dist/queries/doc-drift.d.ts +115 -0
  264. package/dist/queries/doc-drift.js +2 -0
  265. package/dist/queries/drift.d.ts +79 -0
  266. package/dist/queries/drift.js +2 -0
  267. package/dist/queries/duplicate-bodies.d.ts +55 -0
  268. package/dist/queries/duplicate-bodies.js +2 -0
  269. package/dist/queries/entry-map.d.ts +121 -0
  270. package/dist/queries/entry-map.js +2 -0
  271. package/dist/queries/evidence.d.ts +70 -0
  272. package/dist/queries/evidence.js +2 -0
  273. package/dist/queries/extract-candidates.d.ts +52 -0
  274. package/dist/queries/extract-candidates.js +2 -0
  275. package/dist/queries/fan.d.ts +53 -0
  276. package/dist/queries/fan.js +2 -0
  277. package/dist/queries/files.d.ts +20 -0
  278. package/dist/queries/files.js +2 -0
  279. package/dist/queries/health.d.ts +8 -0
  280. package/dist/queries/health.js +2 -0
  281. package/dist/queries/hierarchy.d.ts +21 -0
  282. package/dist/queries/hierarchy.js +2 -0
  283. package/dist/queries/hotspots.d.ts +42 -0
  284. package/dist/queries/hotspots.js +2 -0
  285. package/dist/queries/imports.d.ts +34 -0
  286. package/dist/queries/imports.js +2 -0
  287. package/dist/queries/incomplete-migration.d.ts +90 -0
  288. package/dist/queries/incomplete-migration.js +2 -0
  289. package/dist/queries/index.d.ts +180 -0
  290. package/dist/queries/index.js +2 -0
  291. package/dist/queries/isolated.d.ts +24 -0
  292. package/dist/queries/isolated.js +2 -0
  293. package/dist/queries/locality-candidates.d.ts +51 -0
  294. package/dist/queries/locality-candidates.js +2 -0
  295. package/dist/queries/members.d.ts +21 -0
  296. package/dist/queries/members.js +2 -0
  297. package/dist/queries/methods.d.ts +43 -0
  298. package/dist/queries/methods.js +2 -0
  299. package/dist/queries/not-implemented.d.ts +33 -0
  300. package/dist/queries/not-implemented.js +2 -0
  301. package/dist/queries/outline.d.ts +22 -0
  302. package/dist/queries/outline.js +2 -0
  303. package/dist/queries/passthrough-candidates.d.ts +41 -0
  304. package/dist/queries/passthrough-candidates.js +2 -0
  305. package/dist/queries/plan-context.d.ts +33 -0
  306. package/dist/queries/plan-context.js +2 -0
  307. package/dist/queries/react-component-duplicates.d.ts +39 -0
  308. package/dist/queries/react-component-duplicates.js +2 -0
  309. package/dist/queries/react-hook-candidates.d.ts +44 -0
  310. package/dist/queries/react-hook-candidates.js +2 -0
  311. package/dist/queries/react-large-component-pressure.d.ts +34 -0
  312. package/dist/queries/react-large-component-pressure.js +2 -0
  313. package/dist/queries/recent-duplicates.d.ts +79 -0
  314. package/dist/queries/recent-duplicates.js +2 -0
  315. package/dist/queries/redundant-reexports.d.ts +37 -0
  316. package/dist/queries/redundant-reexports.js +2 -0
  317. package/dist/queries/reference-neighborhood.d.ts +4 -0
  318. package/dist/queries/reference-neighborhood.js +2 -0
  319. package/dist/queries/reference-reachability.d.ts +48 -0
  320. package/dist/queries/reference-reachability.js +2 -0
  321. package/dist/queries/refs.d.ts +13 -0
  322. package/dist/queries/refs.js +2 -0
  323. package/dist/queries/self-audit.d.ts +65 -0
  324. package/dist/queries/self-audit.js +2 -0
  325. package/dist/queries/similar-chains.d.ts +48 -0
  326. package/dist/queries/similar-chains.js +2 -0
  327. package/dist/queries/similar-files.d.ts +35 -0
  328. package/dist/queries/similar-files.js +2 -0
  329. package/dist/queries/similar-signatures.d.ts +46 -0
  330. package/dist/queries/similar-signatures.js +2 -0
  331. package/dist/queries/similar.d.ts +187 -0
  332. package/dist/queries/similar.js +2 -0
  333. package/dist/queries/slice.d.ts +4 -0
  334. package/dist/queries/slice.js +2 -0
  335. package/dist/queries/source-inspection.d.ts +209 -0
  336. package/dist/queries/source-inspection.js +2 -0
  337. package/dist/queries/source-search.d.ts +85 -0
  338. package/dist/queries/source-search.js +2 -0
  339. package/dist/queries/stale-abstractions.d.ts +72 -0
  340. package/dist/queries/stale-abstractions.js +2 -0
  341. package/dist/queries/stats.d.ts +15 -0
  342. package/dist/queries/stats.js +2 -0
  343. package/dist/queries/surface.d.ts +22 -0
  344. package/dist/queries/surface.js +2 -0
  345. package/dist/queries/symbols.d.ts +14 -0
  346. package/dist/queries/symbols.js +2 -0
  347. package/dist/queries/system-map.d.ts +449 -0
  348. package/dist/queries/system-map.js +2 -0
  349. package/dist/queries/system.d.ts +21 -0
  350. package/dist/queries/system.js +2 -0
  351. package/dist/queries/test-quality.d.ts +56 -0
  352. package/dist/queries/test-quality.js +2 -0
  353. package/dist/queries/trace.d.ts +68 -0
  354. package/dist/queries/trace.js +2 -0
  355. package/dist/queries/twin-ab.d.ts +66 -0
  356. package/dist/queries/twin-ab.js +2 -0
  357. package/dist/queries/twin-drift.d.ts +119 -0
  358. package/dist/queries/twin-drift.js +2 -0
  359. package/dist/queries/unused-imports.d.ts +4 -0
  360. package/dist/queries/unused-imports.js +2 -0
  361. package/dist/queries/unused-params.d.ts +38 -0
  362. package/dist/queries/unused-params.js +2 -0
  363. package/dist/queries/value-flow.d.ts +42 -0
  364. package/dist/queries/value-flow.js +2 -0
  365. package/dist/queries/vue-component-duplicates.d.ts +43 -0
  366. package/dist/queries/vue-component-duplicates.js +2 -0
  367. package/dist/queries/vue-composable-candidates.d.ts +44 -0
  368. package/dist/queries/vue-composable-candidates.js +2 -0
  369. package/dist/queries/vue-large-view-pressure.d.ts +41 -0
  370. package/dist/queries/vue-large-view-pressure.js +2 -0
  371. package/dist/queries/wrapper-candidates.d.ts +34 -0
  372. package/dist/queries/wrapper-candidates.js +2 -0
  373. package/dist/reindex-worker.js +3 -0
  374. package/dist/reindex.d.ts +254 -0
  375. package/dist/reindex.js +298 -0
  376. package/dist/repository-text-C0Q8VYdN.d.ts +19 -0
  377. package/dist/runtime.d.ts +555 -0
  378. package/dist/runtime.js +4 -0
  379. package/dist/rust-semantic-session-server.js +2 -0
  380. package/dist/rust-semantic-session-worker.js +2 -0
  381. package/dist/rust-semantic-worker.js +2 -0
  382. package/dist/scip-cli-B7N3haxa.d.ts +67 -0
  383. package/dist/source-snippet-_wrcgmZc.d.ts +15 -0
  384. package/dist/symbol-types-BIQwfoAx.d.ts +74 -0
  385. package/dist/typescript-mailbox-worker.js +2 -0
  386. package/dist/watch-server.js +8 -0
  387. package/docs/AGENT_GUIDE.md +148 -0
  388. package/docs/AI_FAILURE_MODES.md +43 -0
  389. package/docs/API.md +40 -0
  390. package/docs/API_EVOLUTION.md +77 -0
  391. package/docs/CLI_JSON_OUTPUT.md +389 -0
  392. package/docs/COMMAND_REFERENCE.md +294 -0
  393. package/docs/CONFIGURATION_WRITE_SAFETY.md +131 -0
  394. package/docs/DETECTOR_GUIDE.md +46 -0
  395. package/docs/DURABILITY.md +159 -0
  396. package/docs/INDEX_GENERATIONS.md +167 -0
  397. package/docs/LOCK_PROTOCOL.md +133 -0
  398. package/docs/MAILBOX_LIFECYCLE.md +224 -0
  399. package/docs/REGEX_POLICY.md +36 -0
  400. package/docs/REINDEX_METADATA_COMPATIBILITY.md +104 -0
  401. package/docs/RUST_DURABLE_SESSION_PROTOCOL.md +126 -0
  402. package/docs/SECURITY_MODEL.md +125 -0
  403. package/docs/TELEMETRY_RETENTION.md +84 -0
  404. package/docs/TIME_SEMANTICS.md +77 -0
  405. package/docs/WATCH_REFRESH_REQUESTS.md +123 -0
  406. package/docs/WINDOWS_SIDECAR_RELEASE.md +424 -0
  407. package/docs/accuracy-audit-checklist.md +304 -0
  408. package/docs/accuracy-hardening-goal.md +500 -0
  409. package/docs/analyzer-inventory.md +78 -0
  410. package/docs/analyzer-validation-protocol.md +84 -0
  411. package/docs/architecture-coherence-vision.md +254 -0
  412. package/docs/assets/codebaseiq-logo-dark.svg +21 -0
  413. package/docs/assets/codebaseiq-logo.svg +24 -0
  414. package/docs/locality-analyzer-design.md +193 -0
  415. package/docs/schemas/cli-json-envelope.schema.json +237 -0
  416. package/docs/schemas/cli-output-page.schema.json +104 -0
  417. package/docs/schemas/npm-release-state.schema.json +146 -0
  418. package/docs/schemas/observation-receipt.schema.json +164 -0
  419. package/docs/schemas/project-config.schema.json +318 -0
  420. package/docs/schemas/suppression-record.schema.json +79 -0
  421. package/docs/schemas/windows-sidecar-provenance.schema.json +137 -0
  422. package/package.json +482 -0
  423. package/scripts/build-codebaseiq-windows.mjs +197 -0
  424. package/scripts/codebaseiq-windows-provenance.mjs +364 -0
  425. package/scripts/evidence-product-contract.mjs +197 -0
  426. package/scripts/verify-codebaseiq-windows.mjs +29 -0
  427. package/skills/codebaseiq/SKILL.md +75 -0
  428. package/skills/codebaseiq/agents/openai.yaml +4 -0
  429. package/skills/codebaseiq-explore/SKILL.md +34 -0
  430. package/skills/codebaseiq-explore/agents/openai.yaml +4 -0
  431. package/skills/concrete-plan/SKILL.md +79 -0
  432. package/skills/concrete-plan/agents/openai.yaml +4 -0
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{d as R,e as k}from"./chunk-DO6WQD2T.js";import{h as f,i as L,v as E,w as v}from"./chunk-SNNWPCN7.js";import{connect as D}from"net";import{performance as S}from"perf_hooks";import{createHash as b}from"crypto";import{tmpdir as V,userInfo as j}from"os";import{join as h}from"path";var c=1,Q=1*1024*1024,_=64*1024*1024,y=12e4,x=["NO_COLOR","FORCE_COLOR","CLICOLOR","CLICOLOR_FORCE","TERM","CODEBASEIQ_DEBUG"],P=1500;function O(t){let e=T(),r=b("sha256").update(`${e}\0${t}`).digest("hex");return process.platform==="win32"?`\\\\.\\pipe\\codebaseiq-lane-${r.slice(0,32)}`:h(Y(),`lane-${r.slice(0,24)}.sock`)}function Y(){let t=T(),e=b("sha256").update(t).digest("hex").slice(0,16);return h(V(),`codebaseiq-${e}`)}function T(){try{return j().username}catch{return`uid-${typeof process.getuid=="function"?process.getuid():"unknown"}`}}function A(t,e){let r=Buffer.from(JSON.stringify(t),"utf8");if(r.byteLength>e)throw new Error(`query-lane frame of ${r.byteLength} bytes exceeds the ${e}-byte limit`);let n=Buffer.allocUnsafe(4+r.byteLength);return n.writeUInt32LE(r.byteLength,0),r.copy(n,4),n}function w(t,e,r){let n=Buffer.alloc(0),u=!1,i=s=>{u||(u=!0,r(new Error(s)))};return{push(s){if(!u)for(n=n.byteLength===0?s:Buffer.concat([n,s]);n.byteLength>=4;){let a=n.readUInt32LE(0);if(a>t){i(`query-lane frame of ${a} bytes exceeds the ${t}-byte limit`);return}if(n.byteLength<4+a)return;let l=n.subarray(4,4+a);n=n.subarray(4+a);let o;try{o=JSON.parse(l.toString("utf8"))}catch{i("query-lane frame carried invalid JSON");return}if(e(o),u)return}}}}function N(t){if(!t||typeof t!="object")return null;let e=t;if(e.protocolVersion!==c)return null;if(e.ok===!1)return e.code!=="unsupported"&&e.code!=="invalid-request"&&e.code!=="wrong-project"&&e.code!=="busy"&&e.code!=="stale-index"&&e.code!=="ineligible-command"&&e.code!=="execution-error"||typeof e.message!="string"?null:{ok:!1,protocolVersion:c,code:e.code,message:e.message};if(e.ok!==!0)return null;if(e.kind==="accepted"){let n=e.serverPid;return typeof n!="number"||!Number.isInteger(n)||n<=0?null:{ok:!0,kind:"accepted",protocolVersion:c,serverPid:n}}if(e.kind==="executed"){let n=e;return typeof n.serverPid!="number"||!Number.isInteger(n.serverPid)||n.serverPid<=0||typeof n.exitCode!="number"||!Number.isInteger(n.exitCode)||typeof n.stdout!="string"||typeof n.stderr!="string"||typeof n.generation!="string"||!/^[a-f0-9]{64}$/.test(n.generation)||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)?null:{ok:!0,kind:"executed",protocolVersion:c,serverPid:n.serverPid,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr,generation:n.generation,durationMs:n.durationMs}}if(e.kind!=="pong"||typeof e.serverPid!="number"||!Number.isInteger(e.serverPid)||e.serverPid<=0||typeof e.cliVersion!="string"||typeof e.projectRoot!="string"||e.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(e.indexGeneration))return null;let r;if(e.processIdentity!==void 0){let n=E(e.processIdentity);if(!n||n.pid!==e.serverPid)return null;r=n}return{ok:!0,kind:"pong",protocolVersion:c,serverPid:e.serverPid,...r?{processIdentity:r}:{},cliVersion:e.cliVersion,projectRoot:e.projectRoot,...e.indexGeneration!==void 0?{indexGeneration:e.indexGeneration}:{}}}var I=250,C=2e3,q="CODEBASEIQ_NO_DAEMON",$="CODEBASEIQ_DAEMON";async function se(t,e={}){let r=await M(t,{protocolVersion:c,kind:"ping",projectRoot:f(t.projectRoot)},e);if(r.kind!=="ok")return r;let n=r.response;return n.ok!==!0?{kind:"incompatible",reason:`query lane refused ping: ${n.code}: ${n.message}`}:n.kind!=="pong"?{kind:"incompatible",reason:"query lane answered ping with a non-pong response"}:n.serverPid!==r.state.pid?{kind:"incompatible",reason:"query lane responder is not the advertised watch service process"}:n.processIdentity&&r.state.processIdentity&&!v(n.processIdentity,r.state.processIdentity)?{kind:"incompatible",reason:"query lane responder identity differs from the advertised service"}:{kind:"ok",pong:n,roundTripMs:r.roundTripMs,state:r.state}}async function ie(t){let e=t[0];if(!e||e.startsWith("-"))return{served:!1,reason:"no eligible command was invoked"};if(process.env.CODEBASEIQ_INDEX_DB)return{served:!1,reason:"an explicit index database is pinned by the environment"};if(process.env.CODEBASEIQ_SESSION)return{served:!1,reason:"session-ledger evidence runs in-process"};let r;try{let{resolveProjectRoot:d,resolveCliProjectContext:p,sharedCachePreparationEligible:U}=await import("./cli-context-3SNLDYBM.js");if(!U(e))return{served:!1,reason:`command ${e} always executes in-process`};let m=d(),g=p(m);r={projectRoot:m,cacheDir:g.paths.cacheDir,enabled:process.env[$]==="1"||g.config.daemon?.enabled===!0}}catch(d){return{served:!1,reason:`project resolution failed: ${d instanceof Error?d.message:d}`}}if(!r.enabled)return{served:!1,reason:"resident execution is not enabled for this project"};let{normalizeLegacyEvidenceInvocation:n}=await import("./invocation-command-descriptors-QT2JMY5J.js"),u=["node","codebaseiq",...t];n(u);let i=u.slice(2),s={};for(let d of x){let p=process.env[d];p!==void 0&&(s[d]=p)}let a={protocolVersion:c,kind:"execute",projectRoot:f(r.projectRoot),argv:i,cwd:process.cwd(),envAllowlist:s,tty:{isTTY:process.stdout.isTTY===!0,...typeof process.stdout.columns=="number"?{columns:process.stdout.columns}:{}},deadlineMs:y,clientInvocation:{execPath:process.execPath,...process.argv[1]!==void 0?{scriptPath:process.argv[1]}:{}}},l=await M(r,a,{acceptTimeoutMs:P,responseTimeoutMs:y+5e3});if(l.kind!=="ok")return{served:!1,reason:l.reason};let o=l.response;return o.ok!==!0||o.kind!=="executed"?{served:!1,reason:o.ok===!1?`${o.code}: ${o.message}`:"the lane answered with a non-execution response"}:o.serverPid!==l.state.pid?{served:!1,reason:"the executing process is not the advertised watch service"}:(o.stdout.length>0&&process.stdout.write(o.stdout),o.stderr.length>0&&process.stderr.write(o.stderr),process.exitCode=o.exitCode,{served:!0,exitCode:o.exitCode})}async function M(t,e,r={}){if(process.env[q]==="1")return{kind:"unavailable",reason:`${q}=1 disables the query lane`};let n=B(t);if("reason"in n)return n;let u=r.socketPathOverride??O(t.cacheDir),i=S.now(),s=await W(u,e,r);if("reason"in s)return s;let a=N(s.value);return a?{kind:"ok",response:a,roundTripMs:S.now()-i,state:n.state}:{kind:"incompatible",reason:"query lane returned a response this client cannot validate"}}function F(t){return!!t&&typeof t=="object"&&t.kind==="accepted"&&t.ok===!0}function B(t){let e=k(R(t.cacheDir).statePath);return e?e.projectRoot!==f(t.projectRoot)?{kind:"unavailable",reason:"the published watch service serves a different project root"}:e.queryLane===void 0?{kind:"unavailable",reason:"the running watch service does not advertise a query lane"}:e.queryLane.protocolVersion!==c?{kind:"incompatible",reason:`query lane protocol ${e.queryLane.protocolVersion} does not match client protocol ${c}`}:L(e.pid)?{state:e}:{kind:"unavailable",reason:"the advertised watch service process is not alive"}:{kind:"unavailable",reason:"no watch service state is published for this cache"}}function W(t,e,r){return new Promise(n=>{let u=!1,i=o=>{u||(u=!0,clearTimeout(a),s.destroy(),n(o))},s=D({path:t,timeout:r.connectTimeoutMs??I}),a=setTimeout(()=>i({kind:"unavailable",reason:"query lane response timed out"}),(r.connectTimeoutMs??I)+(r.acceptTimeoutMs??r.responseTimeoutMs??C)),l=w(_,o=>{if(F(o)){clearTimeout(a),a=setTimeout(()=>i({kind:"unavailable",reason:"query lane response timed out after acknowledgement"}),r.responseTimeoutMs??C);return}i({value:o})},o=>i({kind:"unavailable",reason:`query lane response was malformed: ${o.message}`}));s.on("timeout",()=>i({kind:"unavailable",reason:"query lane connection timed out"})),s.on("error",o=>i({kind:"unavailable",reason:`query lane connection failed: ${o.message}`})),s.on("close",()=>i({kind:"unavailable",reason:"query lane closed before responding"})),s.on("data",o=>l.push(o)),s.on("connect",()=>{s.setTimeout(0);try{s.write(A(e,Q))}catch(o){i({kind:"unavailable",reason:`query lane request could not be encoded: ${o instanceof Error?o.message:String(o)}`})}})})}export{se as a,ie as b};
3
+ //# sourceMappingURL=chunk-QCN62RTF.js.map
@@ -0,0 +1,2 @@
1
+ import{readdirSync as d}from"fs";import{join as p}from"path";function h(t,i){let r=g(t),e=g(i);if(r.endsWith("/**")){let n=r.slice(0,-3);return e===n||e.startsWith(`${n}/`)}if(r.endsWith("/*")){let n=r.slice(0,-2);if(!e.startsWith(`${n}/`))return!1;let s=e.slice(n.length+1);return s.length>0&&!s.includes("/")}return r==="**"?!0:r==="*"?e.length>0&&!e.includes("/"):r===e}function g(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/+$/,"")}function x(t,i){return h(t,i)}function b(t){return m(t).replace(/\/\*\*?$/,"")}function z(t,i){let r=m(i),e=b(r),n=r.endsWith("/**"),s=[],l=(a,u)=>{let f;try{f=d(a,{withFileTypes:!0})}catch{return}for(let o of f){if(o.name.startsWith("."))continue;let c=u?`${u}/${o.name}`:o.name;x(r,c)&&s.push(c),n&&o.isDirectory()&&l(p(a,o.name),c)}};return l(p(t,e),e),s.sort()}function m(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/+$/,"")}export{x as a,z as b};
2
+ //# sourceMappingURL=chunk-QDCCHMVZ.js.map
@@ -0,0 +1,3 @@
1
+ import{e as i}from"./chunk-FETNQCFO.js";import{a as o}from"./chunk-O6QTXQPJ.js";import{v as s}from"./chunk-BMYOV5GP.js";function u(r,e){let t=s(r,e.relativePath);if(t.length===0)return!1;let n=i(e.symbol);if(!n)return!1;let c=t.slice(Math.max(0,e.startLine-2),e.startLine+1).join(`
2
+ `),a=o(n);return new RegExp(`^\\s*export\\s+(?:default\\s+)?(?:(?:async\\s+)?function\\s+${a}\\b|(?:abstract\\s+)?class\\s+${a}\\b|(?:interface|type|enum|namespace|module)\\s+${a}\\b|(?:const|let|var)\\s+${a}\\b)`,"m").test(c)?!0:p(t,n)}function p(r,e){if(!e)return!1;let t=new RegExp(`^\\s*export\\s*\\{[^}\\n]*\\b${o(e)}\\b`);return r.some(n=>t.test(n))}export{u as a};
3
+ //# sourceMappingURL=chunk-QHRNXP3C.js.map
@@ -0,0 +1,2 @@
1
+ import{a as s}from"./chunk-XLQ3GLWZ.js";import{h as o}from"./chunk-NNJ2KZZG.js";function g(e,r){return s(e).filter(t=>c({pattern:r,relativePath:t})).map(t=>({relativePath:t}))}function c(e,r){let t=typeof e=="string"?{pattern:e,relativePath:r}:e;if(typeof t.pattern!="string"||typeof t.relativePath!="string")throw new TypeError("pathMatchesGlob requires pattern and relativePath.");let n=o(t.pattern),a=o(t.relativePath);if(!/[*?]/.test(n))return a.includes(n);let l=n.includes("/")?n:`**/${n}`;return i(l.split("/"),a.split("/"))}function i(e,r){if(e.length===0)return r.length===0;let[t,...n]=e;return t==="**"?i(n,r)||r.length>0&&i(e,r.slice(1)):r.length===0||!f(t??"",r[0]??"")?!1:i(n,r.slice(1))}function f(e,r){let t="^";for(let n of e)n==="*"?t+="[^/]*":n==="?"?t+="[^/]":t+=p(n);return t+="$",new RegExp(t).test(r)}function p(e){return/[\\^$.*+?()[\]{}|]/.test(e)?`\\${e}`:e}export{g as a,c as b};
2
+ //# sourceMappingURL=chunk-QKPLA6IC.js.map
@@ -0,0 +1,2 @@
1
+ function i(t){let n=new Map;for(let a of t){let e=n.get(a.file);e||(e=[],n.set(a.file,e)),e.push(a)}return n}export{i as a};
2
+ //# sourceMappingURL=chunk-QOKYJ33H.js.map
@@ -0,0 +1,21 @@
1
+ import{c as Yt}from"./chunk-FM5BPL4V.js";import{a as _,b as Vt,i as I,j as ie,l as Te,o as Ce,r as F,s as G}from"./chunk-RDBI2RXU.js";import{a as $t,b as zt,c as te,d as re}from"./chunk-EF2R3WNQ.js";import{C as Qt,D as K,F as Pe,G as Ht,J as Ut,K as ze,L as Ge,M as We,P as Ve,S as oe,U as Jt,a as v,b as J,c as R,f as S,g as E,ga as Qe,h as b,ha as He,l as Bt,m as Y,q as Wt,v as Ee,w as j,x as ne}from"./chunk-WE5RZHZ7.js";var Kt=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"],ho=["entry-surface","generated-code","compatibility-shim","reflection-or-registration","test-fixture","intentional-twin","historical-coupling-ended","detector-counterexample"];var Ue=2,z=3;var Je=new Set(Kt);function Ae(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(a){return{kind:"malformed",reason:`invalid JSON: ${En(a)}`}}if(!_(t))return{kind:"malformed",reason:"metadata must be a JSON object"};let r=t.version;if(!Number.isInteger(r))return{kind:"malformed",reason:"version must be an integer"};if(r!==Ue&&r!==z)return{kind:"unsupported",version:r,direction:r<Ue?"older":"future"};let n=In(t,r);if(n)return{kind:"malformed",reason:n};let i=t,o={metadata:i,capabilities:bn(i)};return r===Ue?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function Ro(e){return e.kind==="legacy"||e.kind==="supported"?e.metadata:null}function Xt(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===z?t.sqliteLayoutVersion:void 0})}function bn(e){let t=e.fingerprint!==void 0,r=_(e.fingerprint),n=e.indexedLanguages!==void 0,i=e.status==="complete",o=e.version===z?e:null;return{usableForQuery:n,usableForEvidenceCache:t,publishableGeneration:i&&r&&n,stableGenerationIdentity:i&&t&&typeof e.updatedAt=="string",languageShardReuse:!!o?.languageFingerprints,typescriptProjectShardReuse:!!o?.typescriptProjectShards}}function In(e,t){if(e.status!=="complete"&&e.status!=="partial")return"status must be complete or partial";if(e.updatedAt!==void 0&&!Vt(e.updatedAt))return"updatedAt must be a valid timestamp";for(let r of["requestedLanguages","indexedLanguages"])if(e[r]!==void 0&&!xn(e[r]))return`${r} must contain unique supported languages`;return e.skipped!==void 0&&!wn(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":t===z&&e.sqliteLayoutVersion!==void 0&&(!Number.isSafeInteger(e.sqliteLayoutVersion)||e.sqliteLayoutVersion<1)?"sqliteLayoutVersion must be a positive safe integer":t===z&&e.languageFingerprints!==void 0&&!Rn(e.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":t===z&&e.typescriptProjectShards!==void 0&&!vn(e.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function vo(e){return e.version===z&&e.sqliteLayoutVersion===1}function xn(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string"&&Je.has(t))?!1:new Set(e).size===e.length}function wn(e){return Array.isArray(e)&&e.every(t=>_(t)&&typeof t.language=="string"&&Je.has(t.language)&&typeof t.reason=="string")}function Rn(e){return _(e)&&Object.entries(e).every(([t,r])=>Je.has(t)&&_(r))}function vn(e){return _(e)&&Object.values(e).every(t=>_(t)&&Array.isArray(t.files)&&t.files.every(Wt))}function En(e){return e instanceof Error?e.message:String(e)}import Vn from"better-sqlite3";import{createHash as An,randomUUID as kn}from"crypto";import{existsSync as W,mkdirSync as Dn,readdirSync as Ln,rmSync as ir,statSync as or}from"fs";import{basename as On,dirname as se,join as x}from"path";import{join as Pn}from"path";function ke(e,t){return e.reason instanceof Error?e.reason:new Error(t)}function Zt(e,t){if(e?.aborted)throw ke(e,t)}var Gn=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.pid;return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?{pid:t}:null};function er(e,t={}){return T(Pn(e,"gc.lock"),t)}function T(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??re,o=i()+r;do{let a=tr(e);if(a)return rr(a);let s=o-i();if(s<=0)return null;Tn(Math.min(n,s))}while(i()<=o);return null}async function ko(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??re,o=i()+r;do{Zt(t.signal,"Lock acquisition was aborted.");let a=tr(e);if(a)return rr(a);let s=o-i();if(s<=0)return null;await Cn(Math.min(n,s),t.signal)}while(i()<=o);return null}function tr(e){let t=Te(e,{kind:"generic",parseLegacy:Gn});return t.kind==="acquired"?t.lock:null}function rr(e){return{release:()=>{e.release()}}}function Tn(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}function Cn(e,t){return t?.aborted?Promise.reject(ke(t,"Lock acquisition was aborted.")):new Promise((r,n)=>{let i=setTimeout(()=>{t?.removeEventListener("abort",o),r()},e),o=()=>{clearTimeout(i),t?.removeEventListener("abort",o),n(t?ke(t,"Lock acquisition was aborted."):new Error("Lock acquisition was aborted."))};t?.addEventListener("abort",o,{once:!0})})}var V=1,Ze=1,ce=".codebaseiq-generations",De="manifest.json",ar="readers",Mn="gc.lock",_n=128,ae=new Map,sr={pid:process.pid,now:()=>new Date,randomToken:()=>kn(),isProcessAlive:ie,readProcessIdentity:te,resolveImmutableGeneration:dr};function m(e){return x(se(e),ce)}function de(e){return x(m(e),Mn)}function cr(e,t=sr){let r=T(de(e.dbPath),{waitMs:5e3});if(!r)throw new Error("SQLite generation retention is busy; retry opening the index.");let n;try{let o=C(e.dbPath);if(!o||!le(e.dbPath,o.currentGeneration))return{generation:tt(e),release(){}};let a=t.randomToken();if(!/^[A-Za-z0-9._-]+$/.test(a))throw new Error("SQLite generation reader token is unsafe.");let s=x(m(e.dbPath),ar);Dn(s,{recursive:!0});let c=x(s,`${t.pid}-${a}.json`),d=t.readProcessIdentity(t.pid);F(c,{version:1,token:a,generationIdentity:o.currentGeneration,pid:t.pid,...d?{processIdentity:d}:{},acquiredAt:t.now().toISOString()},{spacing:2,trailingNewline:!0});let l=!1;n={identity:o.currentGeneration,required:o.artifactSet==="immutable-v1",release(){l||(l=!0,ir(c,{force:!0}))}}}finally{r.release()}let i;try{i=t.resolveImmutableGeneration(e,n.identity)}catch(o){throw n.release(),o}if(i?.source==="immutable"&&i.identity===n.identity)return{generation:i,release:n.release};if(n.release(),n.required)throw new Error(`Published SQLite generation ${n.identity} is missing or invalid.`);return jn(e,n.identity)}function jn(e,t){let r=T(de(e.dbPath),{waitMs:5e3});if(!r)throw new Error("SQLite generation retention is busy; retry opening the index.");try{let n=C(e.dbPath);if(n?.currentGeneration!==t)throw new Error("SQLite index publication changed while opening a legacy generation.");if(W(x(se(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return{generation:lr(e,n.currentGeneration),release(){}}}finally{r.release()}}function et(e,t,r=sr,n={}){let i=x(m(e),ar);if(!W(i))return{protectedGenerations:new Set,activeLeases:0,staleLeasesRemoved:0,malformedLeases:0};let o=new Set,a=0,s=0,c=0;for(let d of Ln(i,{withFileTypes:!0})){if(!d.isFile()||!d.name.endsWith(".json"))continue;let l=x(i,d.name),p;try{p=Fn(JSON.parse(b(l,"SQLite generation reader lease")))}catch{p=null}if(!p){c+=1;for(let h of t)o.add(h);continue}if(!Nn(p,r)){n.removeStale!==!1&&(ir(l,{force:!0}),s+=1);continue}a+=1,o.add(p.generationIdentity)}return{protectedGenerations:o,activeLeases:a,staleLeasesRemoved:s,malformedLeases:c}}function Fn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=t.processIdentity===void 0?null:$t(t.processIdentity);return t.version!==1||typeof t.token!="string"||t.token.trim()===""||typeof t.generationIdentity!="string"||!/^[a-f0-9]{64}$/.test(t.generationIdentity)||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.acquiredAt!="string"||!Number.isFinite(Date.parse(t.acquiredAt))||t.processIdentity!==void 0&&(!r||r.pid!==t.pid)?null:{version:1,token:t.token,generationIdentity:t.generationIdentity,pid:t.pid,...r?{processIdentity:r}:{},acquiredAt:t.acquiredAt}}function Nn(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let r=t.readProcessIdentity(e.pid);return r===null||zt(e.processIdentity,r)}function C(e){try{let t=JSON.parse(b(x(m(e),"state.json"),"SQLite generation state"));return Bn(t)?t:null}catch{return null}}function le(e,t){return ue(m(e),t)}function ue(e,t){try{let r=JSON.parse(b(x(e,t,De),"SQLite generation manifest"));return qn(r,t)?r:null}catch{return null}}function tt(e){let t=C(e.dbPath);if(t){let r=dr(e,t.currentGeneration);if(r)return r;if(t.artifactSet==="immutable-v1")throw new Error(`Published SQLite generation ${t.currentGeneration} is missing or invalid.`)}if(W(x(se(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return lr(e,t?.currentGeneration)}function zo(e){let t=C(e);if(t)return t.currentGeneration;try{let r=x(se(e),"meta.json"),n=W(r)?b(r,"reindex metadata"):void 0;return ur(e,n)}catch{return null}}function N(e){return Xt(Ae(e))??e}function dr(e,t){try{let r=x(m(e.dbPath),t),n=le(e.dbPath,t);if(!n)return null;let i=Ye(r,n.database),o=n.index?Ye(r,n.index):void 0,a=n.metadata?Ye(r,n.metadata):void 0;return!Ke(i,n.database)||n.index&&(!o||!Ke(o,n.index))||n.metadata&&(!a||!Ke(a,n.metadata))?null:{identity:t,databasePath:i,...o?{indexPath:o}:{},...a?{metadataPath:a,metadataRaw:b(a,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function lr(e,t){let r=O(e.dbPath),n=x(se(e.dbPath),"meta.json"),i=W(n)?b(n,"reindex metadata"):void 0,o=W(e.indexPath)?e.indexPath:void 0;return{identity:t??ur(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:n,metadataRaw:i},source:"legacy",databaseFileIdentity:r}}function ur(e,t){let r=An("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&r.update(N(t)),r.update(`\0${O(e)}`),r.digest("hex")}function O(e){let t=or(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function Ye(e,t){if(On(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return x(e,t.file)}function Ke(e,t){if(!W(e))return!1;let r=nr(e);if(!r||r.size!==t.size)return!1;let n=`${e}\0${t.sha256}\0${r.identity}`;if(ae.has(n))return!0;let i=Y(e,{inputKind:"immutable SQLite generation artifact",maxBytes:t.size}),o=nr(e);if(!o||o.identity!==r.identity||i!==t.sha256)return!1;for(ae.set(n,!0);ae.size>_n;){let a=ae.keys().next().value;if(a===void 0)break;ae.delete(a)}return!0}function nr(e){let t=or(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function qn(e,t){return e.version===Ze&&e.identity===t&&Xe(e.database)&&(e.index===void 0||Xe(e.index))&&(e.metadata===void 0||Xe(e.metadata))}function Xe(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.file=="string"&&!!t.file&&Number.isSafeInteger(t.size)&&(t.size??-1)>=0&&typeof t.sha256=="string"&&/^[a-f0-9]{64}$/.test(t.sha256)}function Bn(e){return e.version===V&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&$n(e.stableMirrors)&&zn(e.previousGeneration)&&Wn(e.publication)}function $n(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 zn(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 Wn(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,r=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(n=>n!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&r.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}var Qn=["busy_timeout = 5000","query_only = ON","temp_store = MEMORY","cache_size = -64000","mmap_size = 268435456"],rt=class{constructor(t,r){this.connection=t;this.releaseGenerationReader=r}connection;releaseGenerationReader;active=!0;initialize(t){try{for(let r of Qn)this.connection.pragma(r);t(this.connection)}catch(r){try{this.close()}catch(n){throw new AggregateError([r,n],"SQLite initialization and rollback both failed.",{cause:n})}throw r}}close(){if(!this.active)return;this.active=!1;let t,r;try{this.connection.close()}catch(n){t=n}try{this.releaseGenerationReader()}catch(n){r=n}if(t!==void 0&&r!==void 0)throw new AggregateError([t,r],"SQLite connection close and generation-reader release both failed.");if(t!==void 0)throw t;if(r!==void 0)throw r}},Hn=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".codebaseiq-cache","__pycache__",".venv","venv"],pr=class{db;config;generation;pathFilter;connection;connectionOwnership;statementCache=new Map;closed=!1;constructor(t,r){this.config=t,this.pathFilter=r??null;let n=Kn(t),i=new rt(n.db,n.release);try{i.initialize(Yn),this.generation=n.generation,this.connection=n.db,this.connectionOwnership=i,this.db=Un(n.db)}catch(o){try{i.close()}catch(a){throw new AggregateError([o,a],"SQLite construction and rollback both failed.",{cause:a})}throw o}}isIgnored(t){return this.pathFilter?.isIgnored(t)??!1}get localSymbolPredicate(){return`(
2
+ EXISTS (
3
+ SELECT 1
4
+ FROM defn_enclosing_ranges local_der
5
+ JOIN documents local_d ON local_der.document_id = local_d.id
6
+ WHERE local_der.symbol_id = gs.id
7
+ ${this.pathExclusionsFor("local_d").trimStart()}
8
+ )
9
+ OR EXISTS (
10
+ SELECT 1
11
+ FROM mentions local_m
12
+ JOIN chunks local_c ON local_m.chunk_id = local_c.id
13
+ JOIN documents local_d ON local_c.document_id = local_d.id
14
+ WHERE local_m.symbol_id = gs.id
15
+ AND local_m.role = 1
16
+ ${this.pathExclusionsFor("local_d").trimStart()}
17
+ )
18
+ )`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(r=>Hn.flatMap(n=>[`AND ${r}.relative_path NOT LIKE '${n}/%'`,`AND ${r}.relative_path NOT LIKE '%/${n}/%'`])).join(`
19
+ `)}symbolNoiseFor(t){return`AND ${t}.symbol NOT LIKE '%().(%' AND ${t}.symbol NOT LIKE '%typeLiteral%'`}all(t,...r){return this.statement(t).all(...r)}get(t,...r){return this.statement(t).get(...r)}close(){if(this.closed)return;this.closed=!0,this.statementCache.clear();let t,r;try{Yt(this)}catch(n){t=n}try{this.connectionOwnership.close()}catch(n){r=n}if(t!==void 0&&r!==void 0)throw new AggregateError([t,r],"Database-owned resource and SQLite connection cleanup both failed.");if(t!==void 0)throw t;if(r!==void 0)throw r}statement(t){let r=this.statementCache.get(t);return r||(r=this.connection.prepare(t),this.statementCache.set(t,r)),r}};function Un(e){return Object.freeze({prepare(t){let r=e.prepare(t);if(!r.readonly||!r.reader)throw new Error("ScipDatabase.db only permits read-only statements that return rows.");return Jn(r)}})}function Jn(e){let t={get:(...r)=>e.get(...r),all:(...r)=>e.all(...r),iterate:(...r)=>e.iterate(...r),pluck(r){return r===void 0?e.pluck():e.pluck(r),t},expand(r){return r===void 0?e.expand():e.expand(r),t},raw(r){return r===void 0?e.raw():e.raw(r),t},bind(...r){return e.bind(...r),t},columns:()=>e.columns(),safeIntegers(r){return r===void 0?e.safeIntegers():e.safeIntegers(r),t}};return Object.freeze(t)}function Yn(e){if(!e.prepare("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = 'documents'").get())return;let r=e.prepare("SELECT relative_path FROM documents").iterate();for(let n of r)Pe(n.relative_path)}function Kn(e){for(let t=0;t<4;t+=1){let r=cr(e),n=r.generation,i;try{i=new Vn(n.databasePath,{readonly:!0,fileMustExist:!0})}catch(o){throw r.release(),o}if(n.source==="immutable")return{db:i,generation:n,release:r.release};try{let o=tt(e);if(n.databaseFileIdentity===O(n.databasePath)&&o.source==="legacy"&&o.identity===n.identity&&o.databaseFileIdentity===n.databaseFileIdentity&&o.metadataRaw===n.metadataRaw)return{db:i,generation:n,release:r.release}}catch(o){throw i.close(),r.release(),o}i.close(),r.release()}throw new Error("SQLite index publication changed repeatedly while opening a coherent generation.")}import{createHash as cn,randomUUID as no}from"crypto";import{existsSync as B,lstatSync as Tt,mkdirSync as ee,mkdtempSync as dn,readdirSync as ln,realpathSync as un,renameSync as U,rmSync as q,statSync as Be}from"fs";import{dirname as Ct,join as u,resolve as we}from"path";import{setTimeout as io}from"timers/promises";import{pathToFileURL as nn}from"url";import{deserializeSCIP as pn}from"@c4312/scip";import oo from"better-sqlite3";import{execFileSync as Xn}from"child_process";import{existsSync as Zn,readdirSync as gr}from"fs";import{extname as mr,join as yr}from"path";var hr=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),ei=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function nt(e){let t=[],r=ti(e),n=oi(e);for(let i of ei){if(ri(e,i.files)){t.push(i.language);continue}if(ni(r,i.globs)){t.push(i.language);continue}si(n,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&fr(t,"javascript"),t.includes("cpp")&&!n.has(".c")&&fr(t,"c"),t}function ti(e){try{return gr(e)}catch{return[]}}function ri(e,t){return t?.length?t.some(r=>Zn(yr(e,r))):!1}function ni(e,t){return t?.length?e.some(r=>t.some(n=>ii(r,n))):!1}function ii(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[r,n]=t.split("*");return e.startsWith(r??"")&&e.endsWith(n??"")}function oi(e){let t=ai(e);if(t)return t;let r=new Set,n=[e];for(;n.length>0;){let i=n.pop();if(!i)continue;let o;try{o=gr(i,{withFileTypes:!0})}catch{continue}for(let a of o){if(a.name.startsWith(".")&&!a.name.endsWith("proj")&&!a.name.endsWith("sln")&&a.isDirectory())continue;let s=yr(i,a.name);if(a.isDirectory()){hr.has(a.name)||n.push(s);continue}let c=mr(a.name).toLowerCase();c&&r.add(c)}}return r}function ai(e){try{let t=Xn("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"}),r=new Set;for(let n of t.split(`
20
+ `)){if(!n||n.split("/").some(o=>hr.has(o)))continue;let i=mr(n).toLowerCase();i&&r.add(i)}return r}catch{return null}}function si(e,t){return t?.length?t.some(r=>e.has(r)):!1}function fr(e,t){let r=e.indexOf(t);r!==-1&&e.splice(r,1)}import{lstatSync as xi,readdirSync as wi}from"fs";import{join as Ri,relative as vi,resolve as pt,sep as Ei}from"path";import{createHash as ci}from"crypto";import{existsSync as pe,mkdirSync as di,readdirSync as Sr,renameSync as li,rmSync as br,writeFileSync as ui}from"fs";import{join as M}from"path";import{create as xr,fromBinary as wr,toBinary as pi}from"@bufbuild/protobuf";import{deserializeSCIP as Le,DocumentSchema as ot,IndexSchema as Rr,serializeSCIP as vr}from"@c4312/scip";var Oe=1,fe="typescript-scip-fragments";function sa(e){if(e.length===0)throw new Error("affected TypeScript mini index requires documents");let t=new Set,r=[];for(let o of e){let a=Q(o.relativePath);if(t.has(a))throw new Error(`duplicate TypeScript fragment replacement: ${a}`);if(t.add(a),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${a}`);let s=wr(ot,o.bytes);if(s.relativePath!==a)throw new Error(`TypeScript fragment path mismatch: expected ${a}, got ${s.relativePath}`);r.push(s)}let n=vr(xr(Rr,{documents:r,externalSymbols:[]})),i=Le(n);if(i.documents.length!==r.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return n}function ge(e){let t=M(e,fe);return{rootDir:t,blobDir:M(t,"blobs"),generationDir:M(t,"generations")}}function fi(e){let t=Le(e.indexBytes);Lr(t.metadata,Or(e)),Dr(t.externalSymbols);let r=new Set,n=[];for(let o of t.documents){let a=Q(o.relativePath);if(r.has(a))throw new Error(`duplicate TypeScript SCIP document path: ${a}`);r.add(a);let s=pi(ot,o),c=e.documentIdentities.get(a)??(e.allowUntrackedDocuments?H(JSON.stringify({version:1,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,untrackedDocument:a,contentHash:H(s)})):null);if(!c)throw new Error(`missing TypeScript document identity: ${a}`);n.push(Tr(e.cacheDir,{relativePath:a,bytes:s,occurrences:o.occurrences.length,symbols:o.symbols.length,referenceFragments:[]},c))}let i=Cr(e,n);return Ar(e.cacheDir,i),i}function ca(e){let t=ge(e.cacheDir);if(!pe(st(t,e.generationIdentity)))return fi(e);let r=Er({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity});if(!e.allowUntrackedDocuments&&r.manifest.documents.length!==e.documentIdentities.size)throw new Error("TypeScript fragment generation document identities changed");for(let n of r.manifest.documents){let i=e.documentIdentities.get(n.relativePath);if(!(i===void 0&&e.allowUntrackedDocuments)&&i!==n.documentIdentity)throw new Error(`TypeScript fragment generation document identity changed: ${n.relativePath}`)}return r.manifest}function da(e){let t=Er({cacheDir:e.cacheDir,generationIdentity:e.previousGenerationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity}).manifest,r=new Map(t.documents.map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let a=Q(o.relativePath);if(n.has(a))throw new Error(`duplicate TypeScript fragment replacement: ${a}`);if(n.add(a),!r.has(a))throw new Error(`TypeScript fragment replacement has no prior document: ${a}`);let s=e.documentIdentities.get(a);if(!s)throw new Error(`missing TypeScript document identity: ${a}`);o.bytes===null?r.delete(a):r.set(a,Tr(e.cacheDir,o,s))}if(n.size===0)throw new Error("TypeScript fragment generation requires at least one replacement");let i=Cr(e,[...r.values()]);return Ar(e.cacheDir,i),i}function Er(e){let t=ge(e.cacheDir),r=st(t,e.generationIdentity),n;try{n=at(E(r,{maxBytes:v,inputKind:"TypeScript fragment manifest"}))}catch(o){throw new Error(`TypeScript fragment generation is unavailable: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(n.generationIdentity!==e.generationIdentity)throw new Error("TypeScript fragment generation identity does not match its manifest path");if(e.producerIdentity&&n.producerIdentity!==e.producerIdentity)throw new Error("TypeScript fragment producer identity changed");if(e.projectIdentity&&n.projectIdentity!==e.projectIdentity)throw new Error("TypeScript fragment project identity changed");let i=new Map;for(let o of n.documents){let a=M(t.blobDir,`${o.blobHash}.scipdoc`),s=S(a,{maxBytes:J,inputKind:"TypeScript fragment blob"});if(s.byteLength!==o.byteLength||H(s)!==o.blobHash)throw new Error(`TypeScript fragment blob is corrupt: ${o.relativePath}`);i.set(o.relativePath,s)}return{manifest:n,fragments:i}}function Pr(e){let t=Gr(e);return it(t.baseIndex,t.completeDocuments,"assembled")}function la(e){let t=Gr(e);return gi(t.deletedAffectedPaths),{completeIndexBytes:it(t.baseIndex,t.completeDocuments,"assembled"),affectedIndexBytes:it(t.baseIndex,t.affectedDocuments,"affected")}}function Gr(e){let t=Le(e.baseIndexBytes);Lr(t.metadata,Or(e)),Dr(t.externalSymbols);let r=new Map;for(let s of e.fragments){let c=Q(s.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);r.set(c,s)}if(r.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let n=new Set,i=[],o=[],a=[];for(let s of t.documents){let c=Q(s.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);n.add(c);let d=r.get(c);if(!d){i.push(s);continue}if(r.delete(c),d.bytes===null){a.push(c);continue}let l=wr(ot,d.bytes);if(l.relativePath!==c)throw new Error(`TypeScript fragment path mismatch: expected ${c}, got ${l.relativePath}`);i.push(l),o.push(l)}if(r.size>0)throw new Error(`TypeScript fragment replacement has no prior document: ${[...r.keys()].sort()[0]}`);return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:a}}function it(e,t,r){let n=vr(xr(Rr,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=Le(n);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${r} TypeScript SCIP index failed structural verification`);return n}function gi(e){if(e.length>0)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${e[0]}`)}function ua(e,t){let r=ge(e);if(!pe(r.generationDir))return;let n=new Set(t.map(a=>kr(a))),i=Sr(r.generationDir).filter(a=>a.endsWith(".json")),o=new Set;for(let a of i.filter(s=>n.has(s))){let s=at(E(M(r.generationDir,a),{maxBytes:v,inputKind:"TypeScript fragment manifest"}));for(let c of s.documents)o.add(`${c.blobHash}.scipdoc`)}for(let a of i)n.has(a)||br(M(r.generationDir,a),{force:!0});if(pe(r.blobDir))for(let a of Sr(r.blobDir))o.has(a)||br(M(r.blobDir,a),{force:!0})}function Tr(e,t,r){if(t.bytes===null)throw new Error(`cannot persist an empty TypeScript fragment: ${t.relativePath}`);let n=Q(t.relativePath),i=Buffer.from(t.bytes),o=H(i),a=ge(e);di(a.blobDir,{recursive:!0});let s=M(a.blobDir,`${o}.scipdoc`);if(pe(s)){let c=S(s,{maxBytes:J,inputKind:"TypeScript fragment blob"});if(c.byteLength!==i.byteLength||H(c)!==o)throw new Error(`existing TypeScript fragment blob is corrupt: ${n}`)}else{let c=`${s}.${process.pid}.${Date.now()}.tmp`;ui(c,i),li(c,s)}return{relativePath:n,blobHash:o,byteLength:i.byteLength,documentIdentity:r}}function Cr(e,t){if(!e.producerIdentity||!e.projectIdentity||!e.generationIdentity)throw new Error("TypeScript fragment generation identities must be non-empty");let r=[...t].sort((n,i)=>n.relativePath.localeCompare(i.relativePath));if(new Set(r.map(n=>n.relativePath)).size!==r.length)throw new Error("TypeScript fragment generation contains duplicate document paths");return{version:Oe,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),documents:r}}function Ar(e,t){let r=ge(e),n=st(r,t.generationIdentity);if(pe(n)){let i=at(E(n,{maxBytes:v,inputKind:"TypeScript fragment manifest"}));if(Ir(i)!==Ir(t))throw new Error(`TypeScript fragment generation is immutable: ${t.generationIdentity}`);return}F(n,t,{spacing:2,trailingNewline:!0})}function Ir(e){return H(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,documents:e.documents}))}function at(e){let t=JSON.parse(e);if(t.version!==Oe||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let r=new Set;for(let n of t.documents){if(!n||typeof n.relativePath!="string"||typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash)||typeof n.byteLength!="number"||!Number.isInteger(n.byteLength)||n.byteLength<0||typeof n.documentIdentity!="string"||!n.documentIdentity)throw new Error("invalid TypeScript fragment record");if(Q(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript fragment record");r.add(n.relativePath)}return t}function st(e,t){return M(e.generationDir,kr(t))}function kr(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${H(e)}.json`}function Dr(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function Lr(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let r=e,n=r.toolInfo??r.tool_info;if(!n||typeof n!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=n;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function Or(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function Q(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}function H(e){return ci("sha256").update(e).digest("hex")}import{createHash as mi}from"crypto";import{existsSync as me,mkdirSync as yi,readdirSync as ct,renameSync as hi,rmSync as Mr,writeFileSync as Si}from"fs";import{join as P}from"path";var Me=1,ba=64*1024*1024,he="typescript-scip-overlays";function Ia(e){let t=jr(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t&&(t.producerIdentity!==e.producerIdentity||t.projectIdentity!==e.projectIdentity))throw new Error("TypeScript overlay producer or project identity changed");let r=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let a=ut(o.relativePath);if(n.has(a))throw new Error(`duplicate TypeScript overlay: ${a}`);n.add(a),r.set(a,bi(e.cacheDir,o))}if(n.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:Me,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...r.values()].sort((o,a)=>o.relativePath.localeCompare(a.relativePath))};return Ii(e.cacheDir,i),i}function xa(e){let t=jr(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let r=t.overlays.map(n=>{if(n.blobHash===null)return{relativePath:n.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=S(P(Se(e.cacheDir),"blobs",`${n.blobHash}.scipdoc`),{maxBytes:J,inputKind:"TypeScript overlay blob"});if(i.byteLength!==n.byteLength||ye(i)!==n.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${n.relativePath}`);return{relativePath:n.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return Pr({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:r})}function wa(e,t){let r=Se(e),n=P(r,"generations");if(!me(n))return;let i=new Set(t.map(lt)),o=new Set;for(let s of ct(n).filter(c=>i.has(c))){let c=dt(E(P(n,s),{maxBytes:v,inputKind:"TypeScript overlay manifest"}));for(let d of c.overlays)d.blobHash&&o.add(`${d.blobHash}.scipdoc`)}for(let s of ct(n))i.has(s)||Mr(P(n,s),{force:!0});let a=P(r,"blobs");if(me(a))for(let s of ct(a))o.has(s)||Mr(P(a,s),{force:!0})}function jr(e,t){let r=P(Se(e),"generations",lt(t));if(!me(r))return null;let n=dt(E(r,{maxBytes:v,inputKind:"TypeScript overlay manifest"}));if(n.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return n}function bi(e,t){let r=ut(t.relativePath);if(t.bytes===null)return{relativePath:r,blobHash:null,byteLength:0};let n=Buffer.from(t.bytes),i=ye(n),o=P(Se(e),"blobs");yi(o,{recursive:!0});let a=P(o,`${i}.scipdoc`);if(me(a)){let s=S(a,{maxBytes:J,inputKind:"TypeScript overlay blob"});if(s.byteLength!==n.byteLength||ye(s)!==i)throw new Error(`existing TypeScript overlay blob is corrupt: ${r}`)}else{let s=`${a}.${process.pid}.${Date.now()}.tmp`;Si(s,n),hi(s,a)}return{relativePath:r,blobHash:i,byteLength:n.byteLength}}function Ii(e,t){let r=P(Se(e),"generations",lt(t.generationIdentity));if(me(r)){let n=dt(E(r,{maxBytes:v,inputKind:"TypeScript overlay manifest"}));if(_r(n)!==_r(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}F(r,t,{spacing:2,trailingNewline:!0})}function dt(e){let t=JSON.parse(e);if(t.version!==Me||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let r=new Set;for(let n of t.overlays){if(!n||typeof n.relativePath!="string"||n.blobHash!==null&&(typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash))||!Number.isInteger(n.byteLength)||n.byteLength<0||n.blobHash===null&&n.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(ut(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript overlay record");r.add(n.relativePath)}return t}function Se(e){return P(e,he)}function lt(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${ye(e)}.json`}function _r(e){return ye(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function ut(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}function ye(e){return mi("sha256").update(e).digest("hex")}var be=1,ft="language-indexes",Fr=["index.db","index.scip","meta.json"],Nr=[ft,fe,he];function _e(e){let t=[];for(let r of Fr)Pi(e,r),t.push(r);for(let r of Nr)qr(e,r,t);return{version:be,files:t.sort()}}function je(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(n=>!n||n==="."||n===".."))throw new Error(`invalid index artifact path: ${e}`);let r=t[0];if(!Fr.includes(e)&&!Nr.includes(r))throw new Error(`index artifact path is not shareable: ${e}`);return e}function A(e,t){let r=je(t),n=pt(e),i=pt(n,...r.split("/"));if(i!==n&&!i.startsWith(`${n}${Ei}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function qr(e,t,r){let n=Ri(e,t),i;try{i=wi(n,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let a=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${a}`);o.isDirectory()?qr(e,a,r):o.isFile()&&r.push(je(a))}}function Pi(e,t){let r=A(e,t),n;try{n=xi(r)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!n.isFile()||n.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(vi(pt(e),r).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}import{writeFileSync as mt}from"fs";import{create as X}from"@bufbuild/protobuf";import{deserializeSCIP as yt,serializeSCIP as ht,DocumentSchema as Li,IndexSchema as $r,MetadataSchema as zr,SymbolInformationSchema as Oi}from"@c4312/scip";import{writeFileSync as Gi}from"fs";import{create as Br}from"@bufbuild/protobuf";import{deserializeSCIP as Ti,DocumentSchema as Ci,IndexSchema as Ai,serializeSCIP as ki,SymbolRole as Di}from"@c4312/scip";function Oa(e){let t;try{t=Ti(S(e,{inputKind:"SCIP sanitization input",maxBytes:R}))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let r=gt(t);return r.touchedDocuments>0&&Gi(e,Buffer.from(ki(r.index))),{removedDefinitionOccurrences:r.removedDefinitionOccurrences,touchedDocuments:r.touchedDocuments}}function gt(e){let t=new Set,r=new Map;for(let a of e.documents){r.set(a,Pe(a.relativePath));for(let s of a.symbols)s.symbol&&t.add(s.symbol)}for(let a of e.externalSymbols)a.symbol&&t.add(a.symbol);let n=0,i=0,o=[];for(let a of e.documents){let s=r.get(a),c=a.occurrences.filter(d=>(d.symbolRoles&Di.Definition)===0||t.has(d.symbol)?!0:(n+=1,!1));if(s===a.relativePath&&c.length===a.occurrences.length){o.push(a);continue}i+=1,o.push(Br(Ci,{language:a.language,relativePath:s,occurrences:c,symbols:a.symbols,text:a.text,positionEncoding:a.positionEncoding}))}return{index:i===0?e:Br(Ai,{metadata:e.metadata,documents:o,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:i}}function Wr(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=_i(e),r=ji(e.flatMap(i=>i.documents??[])),n=Qr(e.flatMap(i=>i.externalSymbols??[]));return X($r,{metadata:t,documents:r,externalSymbols:n})}function $a(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>yt(S(i,{inputKind:"SCIP merge input",maxBytes:R}))),n=Wr(r);return mt(t,Buffer.from(ht(n))),{documentCount:n.documents.length,externalSymbolCount:n.externalSymbols.length,inputCount:e.length}}function za(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>yt(S(i,{inputKind:"SCIP merge input",maxBytes:R}))),n=gt(Wr(r));return mt(t,Buffer.from(ht(n.index))),{documentCount:n.index.documents.length,externalSymbolCount:n.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function Mi(e,t,r){let n=e.metadata;if(!n)throw new Error("Cannot rebase a SCIP index without metadata");if(!K(n.projectRoot,t))throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${n.projectRoot}`);return X($r,{metadata:X(zr,{...n,projectRoot:r}),documents:e.documents,externalSymbols:e.externalSymbols})}function Vr(e,t,r){let n=yt(S(e,{inputKind:"SCIP normalization input",maxBytes:R})),i=Mi(n,t,r);mt(e,Buffer.from(ht(i)))}function _i(e){let t=e[0]?.metadata;if(!t)return;let r=t.projectRoot;for(let i of e.slice(1)){let o=i.metadata?.projectRoot;if(r&&o&&!K(o,r))throw new Error(`Cannot merge SCIP indexes with different project roots: ${r} vs ${o}`)}let n=r&&Qt(r);return n===r?t:X(zr,{...t,projectRoot:n})}function ji(e){let t=new Map;for(let r of e){let n=t.get(r.relativePath);if(!n){t.set(r.relativePath,r);continue}t.set(r.relativePath,X(Li,{language:n.language||r.language,relativePath:n.relativePath||r.relativePath,occurrences:Fi([...n.occurrences,...r.occurrences]),symbols:Qr([...n.symbols,...r.symbols]),text:qi(n.text,r.text),positionEncoding:n.positionEncoding||r.positionEncoding}))}return[...t.values()]}function Fi(e){let t=new Set,r=[];for(let n of e){let i=JSON.stringify(n);t.has(i)||(t.add(i),r.push(n))}return r}function Qr(e){let t=new Map;for(let r of e){let n=t.get(r.symbol);if(!n){t.set(r.symbol,r);continue}t.set(r.symbol,X(Oi,{symbol:n.symbol,documentation:Bi([...n.documentation,...r.documentation]),relationships:Ni([...n.relationships,...r.relationships]),kind:n.kind||r.kind,displayName:n.displayName||r.displayName,enclosingSymbol:n.enclosingSymbol||r.enclosingSymbol,signatureDocumentation:n.signatureDocumentation??r.signatureDocumentation}))}return[...t.values()]}function Ni(e){let t=new Set,r=[];for(let n of e){let i=[n.symbol,n.isReference?"1":"0",n.isImplementation?"1":"0",n.isTypeDefinition?"1":"0",n.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),r.push(n))}return r}function qi(e,t){return e?t?e.length>=t.length?e:t:e:t}function Bi(e){return[...new Set(e)]}import{createHash as Rt}from"crypto";import{closeSync as $i,existsSync as g,mkdirSync as zi,openSync as Wi,readSync as Vi,readdirSync as vt,renameSync as xt,rmSync as Ie,statSync as Z}from"fs";import{basename as Yr,dirname as k,join as f,relative as Hr}from"path";var wt=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function Kr(e){let t=m(e.outputDb),r=Yi(e);e.onStage?.("after-recovery-retained");let n=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=Gt({generationRoot:t,databasePath:e.tempOutputDb,indexPath:g(n)?n:void 0,metadataPath:g(e.tempMetaPath)?e.tempMetaPath:void 0}),o=(e.now??(()=>new Date))().toISOString(),a={version:V,currentGeneration:i.identity,artifactSet:"immutable-v1",...r?{previousGeneration:r}:{},...e.publication?{publication:e.publication}:{},publishedAt:o},s=G(f(t,"state.json"),a,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||It(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),It(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),It(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let c=i.identity,d={...a,stableMirrors:Pt(e.outputDb,e.outputScip)};G(f(t,"state.json"),d,{spacing:2,trailingNewline:!0});let l=Xr(e.outputDb,{now:e.now}),p=ne(i.directorySync,s.directorySync);return{currentGeneration:c,...r?{previousGeneration:r}:{},retention:l,achievedDurability:p==="synced"?"directory-durable":"file-flushed",directorySync:p}}function Qi(e,t,r,n=()=>new Date){if(!g(e))return null;let i=C(e),o=f(m(e),"state.json");if(i?.artifactSet==="immutable-v1"&&le(e,i.currentGeneration))return i;let a=m(e),s=!i&&g(o)?Xi(r,e,t):void 0;if(s&&!ue(a,s))return null;let c=Gt({generationRoot:a,databasePath:e,indexPath:g(t)?t:void 0,metadataPath:g(r)?r:void 0,forcedIdentity:i?.currentGeneration??s}),d={version:V,currentGeneration:c.identity,artifactSet:"immutable-v1",stableMirrors:Pt(e,t),...i?.previousGeneration?{previousGeneration:i.previousGeneration}:{},...i?.publication?{publication:i.publication}:{},publishedAt:i?.publishedAt??n().toISOString()};return G(f(a,"state.json"),d,{spacing:2,trailingNewline:!0}),d}function rs(e,t,r=()=>new Date){if(!g(e)||!g(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let n=C(e),i=m(e),o=Gt({generationRoot:i,databasePath:e,indexPath:g(f(k(e),"index.scip"))?f(k(e),"index.scip"):void 0,metadataPath:t}),a=n&&n.currentGeneration!==o.identity?tn(e,n.currentGeneration):void 0,s={version:V,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:Pt(e,f(k(e),"index.scip")),...a?{previousGeneration:a}:{},...n?.publication?{publication:n.publication}:{},publishedAt:r().toISOString()};return G(f(m(e),"state.json"),s,{spacing:2,trailingNewline:!0}),Xr(e,{now:r}),s}function Xr(e,t={}){let r=Hi(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=T(de(e),{waitMs:0});if(!o)return{state:"deferred",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:r,at:i,reason:"another process owns local generation retention"};try{let a=C(e),s=Zr(e),c=et(e,s.map(w=>w.identity),{isProcessAlive:t.isProcessAlive??ie,readProcessIdentity:t.readProcessIdentity??te}),d=new Set(c.protectedGenerations);a?.currentGeneration&&d.add(a.currentGeneration),a?.previousGeneration?.generationIdentity&&d.add(a.previousGeneration.generationIdentity);let l=s.length,p=s.reduce((w,$e)=>w+$e.logicalBytes,0),h=0,D=0;for(let w of s){if(l<=r.maxGenerations&&p<=r.maxLogicalBytes)break;d.has(w.identity)||(t.onBeforeRemove?.(w.identity),Ie(w.path,{recursive:!0,force:!0}),l-=1,p-=w.logicalBytes,h+=1,D+=w.logicalBytes)}let y=l>r.maxGenerations||p>r.maxLogicalBytes,L={state:y?"protected":h>0?"collected":"within-bounds",generationCount:l,logicalBytes:p,protectedGenerations:d.size,activeReaderLeases:c.activeLeases,staleReaderLeasesRemoved:c.staleLeasesRemoved,malformedReaderLeases:c.malformedLeases,removedGenerations:h,removedLogicalBytes:D,limits:r,at:i,...y?{reason:c.malformedLeases>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}:{}};return Ur(e,L),L}catch(a){let s={state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:r,at:i,reason:a instanceof Error?a.message:String(a)};try{Ur(e,s)}catch{}return s}finally{o.release()}}function ns(e){let t=m(e);if(!g(t))return{state:"absent",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:{...wt},reason:"local immutable generation store does not exist"};let r=Ui(e),n=r?.limits??{...wt},i=T(de(e),{waitMs:0});if(!i)return{state:"deferred",generationCount:r?.generationCount??0,logicalBytes:r?.logicalBytes??0,protectedGenerations:r?.protectedGenerations??0,activeReaderLeases:r?.activeReaderLeases??0,malformedReaderLeases:r?.malformedReaderLeases??0,limits:n,...r?{lastCollection:r}:{},reason:"another process owns local generation retention"};try{let o=Zr(e),a=C(e),s=et(e,o.map(d=>d.identity),{isProcessAlive:ie,readProcessIdentity:te},{removeStale:!1}),c=new Set(s.protectedGenerations);return a?.currentGeneration&&c.add(a.currentGeneration),a?.previousGeneration?.generationIdentity&&c.add(a.previousGeneration.generationIdentity),{state:"managed",generationCount:o.length,logicalBytes:o.reduce((d,l)=>d+l.logicalBytes,0),...o[0]?{oldestGenerationAt:new Date(o[0].modifiedAtMs).toISOString()}:{},protectedGenerations:c.size,activeReaderLeases:s.activeLeases,malformedReaderLeases:s.malformedLeases,limits:n,...r?{lastCollection:r}:{},...s.malformedLeases>0?{reason:"malformed reader ownership evidence prevents unsafe collection"}:{}}}catch(o){return{state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:n,...r?{lastCollection:r}:{},reason:o instanceof Error?o.message:String(o)}}finally{i.release()}}function Hi(e={}){let t={...wt,...e};if(!Number.isSafeInteger(t.maxGenerations)||t.maxGenerations<2)throw new Error("Local SQLite generation retention must keep at least current and previous generations.");if(!Number.isSafeInteger(t.maxLogicalBytes)||t.maxLogicalBytes<=0)throw new Error("Local SQLite generation byte retention must be a positive safe integer.");return t}function Zr(e){let t=m(e);return g(t)?vt(t,{withFileTypes:!0}).filter(r=>r.isDirectory()&&/^[a-f0-9]{64}$/.test(r.name)).map(r=>{let n=f(t,r.name),i=ue(t,r.name),o=i?i.database.size+(i.index?.size??0)+(i.metadata?.size??0):en(n);return{identity:r.name,path:n,logicalBytes:o,modifiedAtMs:Z(n).mtimeMs}}).sort((r,n)=>r.modifiedAtMs-n.modifiedAtMs||r.identity.localeCompare(n.identity)):[]}function en(e){let t=0;for(let r of vt(e,{withFileTypes:!0})){let n=f(e,r.name);r.isDirectory()?t+=en(n):r.isFile()&&(t+=Z(n).size)}return t}function Ur(e,t){F(f(m(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function Ui(e){try{let t=JSON.parse(b(f(m(e),"gc.json"),"local SQLite generation GC status"));return!t||t.state!=="within-bounds"&&t.state!=="collected"&&t.state!=="protected"&&t.state!=="deferred"&&t.state!=="error"||!Number.isSafeInteger(t.generationCount)||t.generationCount<0||!Number.isFinite(t.logicalBytes)||t.logicalBytes<0||!Number.isFinite(Date.parse(t.at))?void 0:t}catch{return}}function Et(e,t=f(k(e),"meta.json")){let r=f(m(e),"state.json");if(!g(r))return{state:"legacy",statePath:r};let n=C(e);if(!n)return{state:"invalid",statePath:r,reason:"generation state is malformed"};try{let i=le(e,n.currentGeneration),o=i!==null,a=i?Ji(e,t,i,n):!1,s=n.previousGeneration?g(f(k(e),n.previousGeneration.databasePath)):!0;return!a||!o||!s?{state:"drifted",statePath:r,currentMatches:a,recoveryExists:s,generation:n,reason:o?a?"retained recovery database is missing":"stable database or metadata no longer matches the published generation":"published immutable generation is missing"}:{state:"current",statePath:r,currentMatches:a,recoveryExists:s,generation:n}}catch(i){return{state:"drifted",statePath:r,currentMatches:!1,recoveryExists:!1,generation:n,reason:i instanceof Error?i.message:String(i)}}}function Ji(e,t,r,n){if(n.stableMirrors&&(n.stableMirrors.databaseFileIdentity!==O(e)||n.stableMirrors.indexFileIdentity!==void 0&&n.stableMirrors.indexFileIdentity!==O(f(k(e),"index.scip")))||!Jr(e,r.database))return!1;let i=f(k(e),"index.scip");if(r.index&&!Jr(i,r.index))return!1;if(!r.metadata)return!g(t);if(!g(t))return!1;let o=f(m(e),r.identity,r.metadata.file);return g(o)&&N(b(t,"reindex metadata"))===N(b(o,"immutable reindex metadata"))}function Jr(e,t){return g(e)&&Z(e).isFile()&&Z(e).size===t.size}function Yi(e){let t=Qi(e.outputDb,e.outputScip,e.metaPath);return t?tn(e.outputDb,t.currentGeneration):void 0}function Pt(e,t){return{databaseFileIdentity:O(e),...g(t)?{indexFileIdentity:O(t)}:{}}}function tn(e,t){let r=f(m(e),t),n=f(r,Yr(e)),i=f(r,"meta.json");return{generationIdentity:t,databasePath:Hr(k(e),n),...g(i)?{metadataPath:Hr(k(e),i)}:{}}}function Ki(e){if(g(e)){for(let t of vt(e,{withFileTypes:!0}))if(t.isDirectory()&&t.name.endsWith(".tmp"))try{Ie(f(e,t.name),{recursive:!0,force:!0})}catch{}}}function Xi(e,t,r=f(k(t),"index.scip")){let n=Rt("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(Fe(t)),g(r)&&n.update(`\0${Fe(r)}`),g(e)&&n.update(`\0${N(b(e,"reindex metadata"))}`),n.digest("hex")}function Gt(e){let t=St(e.databasePath),r=e.indexPath?St(e.indexPath):void 0,n=e.metadataPath?St(e.metadataPath):void 0,i=e.forcedIdentity??Zi(t,r,e.metadataPath),o=f(e.generationRoot,i),a=f(o,De);if(g(a)){let d=ue(e.generationRoot,i);if(d&&rn(o,d.database,t)&&to(o,d.index,r)&&ro(o,d.metadata,e.metadataPath))return{identity:i,directorySync:j(e.generationRoot)};throw new Error(`SQLite generation ${i} already exists with different or corrupt artifacts.`)}let s=[Ee(e.generationRoot)];Ki(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;Ie(c,{recursive:!0,force:!0}),zi(c,{recursive:!0});try{s.push(bt(e.databasePath,f(c,t.file))),r&&e.indexPath&&s.push(bt(e.indexPath,f(c,r.file))),n&&e.metadataPath&&s.push(bt(e.metadataPath,f(c,n.file)));let d=G(f(c,De),{version:Ze,identity:i,database:t,...r?{index:r}:{},...n?{metadata:n}:{}},{spacing:2,trailingNewline:!0});d.directorySync!=="not-requested"&&s.push(d.directorySync),s.push(j(c)),I(()=>xt(c,o)),s.push(j(e.generationRoot))}finally{try{Ie(c,{recursive:!0,force:!0})}catch{}}return{identity:i,directorySync:ne(...s)}}function Zi(e,t,r){let n=Rt("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(e.sha256),t&&n.update(`\0${t.sha256}`),r&&n.update(`\0${N(b(r,"reindex metadata"))}`),n.digest("hex")}function St(e){return{file:Yr(e),size:Z(e).size,sha256:Fe(e)}}function Fe(e){let t=Rt("sha256"),r=Wi(e,"r"),n=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=eo(r,n);if(i===0)break;t.update(n.subarray(0,i))}}finally{$i(r)}return t.digest("hex")}function eo(e,t){let r=0;for(;r<t.length;){let n=Vi(e,t,r,t.length-r,null);if(r+=n,n===0)break}return r}function bt(e,t){return Ce(e,t,{mode:292})}function rn(e,t,r){let n=f(e,t.file);return t.file===r.file&&t.size===r.size&&t.sha256===r.sha256&&g(n)&&Z(n).size===t.size&&Fe(n)===t.sha256}function to(e,t,r){return!t||!r?t===r:rn(e,t,r)}function ro(e,t,r){if(!t||!r)return t===void 0&&r===void 0;let n=f(e,t.file);return g(n)&&N(b(n,"stored reindex metadata"))===N(b(r,"candidate reindex metadata"))}function It(e,t){I(()=>Ie(`${t}.tmp-replace`,{force:!0})),I(()=>xt(e,`${t}.tmp-replace`)),I(()=>xt(`${t}.tmp-replace`,t))}var Lt=1,on="CODEBASEIQ_SHARED_CACHE",ao=2,Ne=JSON.stringify({cliVersion:Ht,artifactCatalogVersion:be,postIndexAugmentationSchemaVersion:ao,sqliteGenerationStoreVersion:V,typescriptFragmentStoreVersion:Oe,typescriptOverlayStoreVersion:Me}),Ot="manifest.json",so="shared-cache.json",Mt=[ft,fe,he];function At(e,t){if(!e.clean||!e.treeOid)return;let r=Sn(JSON.stringify({version:Lt,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:t,producerIdentity:Ne}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:Ne,generationId:r,repositoryCacheDir:Ge(e.repositoryId)}}function fn(e,t,r){if(process.env[on]==="0")return`${on}=0`;if(!We(r))return"explicit cache or database override";if(Ve(Ct(t))!==Ve(ze(e))||t!==u(Ct(t),"index.db"))return"index database is outside the managed worktree cache"}function ks(e,t,r){if(!We(t))return;let n=r??oe(e);return n?u(Ge(n.repositoryId),"evidence.db"):void 0}function $(e,t=!0){let r=Ft(e),n;try{n=mn(E(u(r,Ot),{inputKind:"shared-generation manifest",maxBytes:v}))}catch{return null}if(n.generationId!==e.generationId||n.repositoryId!==e.repositoryId||n.treeOid!==e.treeOid||n.producerIdentity!==e.producerIdentity||JSON.stringify(n.fingerprint)!==JSON.stringify(e.fingerprint))return null;if(!t)return n;try{for(let i of n.artifacts){let o=A(r,i.path),a=Be(o);if(!a.isFile()||a.size!==i.size||Y(o,{inputKind:"shared-generation artifact",maxBytes:R})!==i.sha256)return null}}catch{return null}return n}function Ds(e,t,r){if(!e.treeOid)return null;let n=He(t,r),i=u(Ut(),"repositories",e.repositoryId),o;try{let c=Tt(i);if(!c.isDirectory()||c.isSymbolicLink())return null;o=un(i)}catch{return null}let a=u(o,"generations"),s=[];try{for(let c of ln(a)){if(!/^[a-f0-9]{64}$/.test(c))continue;let d=u(a,c),l;try{l=Tt(d)}catch{continue}if(!(!l.isDirectory()||l.isSymbolicLink()))try{let p=mn(E(u(d,Ot),{inputKind:"shared-generation baseline manifest",maxBytes:v}));p.generationId===c&&p.repositoryId===e.repositoryId&&p.treeOid===e.treeOid&&p.producerIdentity===Ne&&po(p.fingerprint,n)&&s.push(p)}catch{continue}}}catch{return null}s.sort((c,d)=>Date.parse(d.createdAt)-Date.parse(c.createdAt)||c.generationId.localeCompare(d.generationId));for(let c of s){let d={repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:c.fingerprint,producerIdentity:c.producerIdentity,generationId:c.generationId,repositoryCacheDir:o},l=$(d);if(l)return{snapshot:d,manifest:l}}return null}function gn(e){let t=T(u(e.snapshot.repositoryCacheDir,"locks",`${e.snapshot.generationId}.publish.lock`));if(!t)throw new Error(`shared generation publication is already in progress for ${e.snapshot.generationId}`);try{return co(e)}finally{t.release()}}function co(e){let t=$(e.snapshot);if(t)return an(e.snapshot,t);if(!Re(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let r=sn(e.sourceCacheDir);if(!r)throw new Error("source index artifacts are incomplete");let n=_e(e.sourceCacheDir),i=u(e.snapshot.repositoryCacheDir,"generations"),o=[Ee(i)],a=dn(u(i,`.tmp-${process.pid}-`));try{let s=[];for(let y of n.files){let L=A(e.sourceCacheDir,y),w=A(a,y);o.push(ve(L,w,292)),e.onPublicationStage?.("after-artifact-flushed",y);let $e=Be(w).size;s.push({path:y,size:$e,sha256:Y(w,{inputKind:"staged shared-generation artifact",maxBytes:R})})}let c=pn(S(u(a,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:R})).metadata?.projectRoot;if(!c)throw new Error("shared SCIP generation has no project root metadata");let d=qt(e.sourceProjectRoot);if(!K(c,d))throw new Error("shared SCIP generation root does not match its source worktree");if(sn(e.sourceCacheDir)!==r||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let l={version:Lt,artifactCatalogVersion:be,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:c,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:s.sort((y,L)=>y.path.localeCompare(L.path))},p=G(u(a,Ot),l,{spacing:2,trailingNewline:!0});p.directorySync!=="not-requested"&&o.push(p.directorySync),e.onPublicationStage?.("after-manifest-flushed"),o.push(j(a)),e.onPublicationStage?.("after-staging-directory-synced");let h=Ft(e.snapshot);try{if(B(h)&&!$(e.snapshot)){let y=`${h}.corrupt-${process.pid}-${Date.now()}`;I(()=>U(h,y)),q(y,{recursive:!0,force:!0})}I(()=>U(a,h))}catch(y){let L=$(e.snapshot);if(L)return an(e.snapshot,L);throw y}e.onPublicationStage?.("after-generation-renamed"),o.push(j(i)),e.onPublicationStage?.("after-generations-directory-synced");let D=ne(...o);return{kind:"published",manifest:l,achievedDurability:D==="synced"?"directory-durable":"file-flushed",directorySync:D}}finally{q(a,{recursive:!0,force:!0})}}function an(e,t){let r=j(u(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:r==="synced"?"directory-durable":"file-flushed",directorySync:r}}function kt(e){let t=Ft(e.snapshot);ee(e.targetCacheDir,{recursive:!0});let r=T(u(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:3e4});if(!r)throw new Error("timed out waiting for another cache hydration");let n,i,o=!1;try{n=dn(u(e.targetCacheDir,".shared-hydrate-")),yo(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let d=A(t,c.path),l=A(n,c.path);if(ve(d,l),Be(l).size!==c.size||Y(l,{inputKind:"hydrated shared-generation artifact",maxBytes:R})!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let a=qt(e.targetProjectRoot);if(a!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&Vr(A(n,c.path),e.manifest.scipProjectRoot,a);if(!Re(n,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=fo(e.targetCacheDir,n),o=!0,go(n,e.targetCacheDir,i),Kr({tempOutputScip:u(n,"index.scip"),tempOutputDb:u(n,"index.db"),tempMetaPath:u(n,"meta.json"),outputScip:u(e.targetCacheDir,"index.scip"),outputDb:u(e.targetCacheDir,"index.db"),metaPath:u(e.targetCacheDir,"meta.json"),now:e.now});let s=Et(u(e.targetCacheDir,"index.db"),u(e.targetCacheDir,"meta.json"));if(s.state==="invalid"||s.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${s.reason}`);e.persistLease!==!1&&Dt(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(a){throw o&&i&&mo(e.targetCacheDir,i),a}finally{n&&q(n,{recursive:!0,force:!0}),r.release()}}function Ls(e,t,r,n){let i=fn(e,r.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=n??oe(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean)return qe(o,r.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"};let a=t.languages??nt(e),s=Qe(e,a,yn(t)),c=At(o,s);if(!c)return{kind:"missed",reason:"clean committed snapshot is unavailable"};let d=$(c);if(d)return kt({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId};let l=lo(c,e);return l?(d=l.manifest,kt({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e,action:"peer-imported"}),{kind:"peer-imported",generationId:c.generationId,sourceProjectRoot:l.sourceProjectRoot}):(qe(o,r.cacheDir,"missed",void 0,"no exact shared or peer generation exists"),{kind:"missed",reason:"no exact shared or peer generation exists"})}catch(o){return{kind:"failed",reason:o instanceof Error?o.message:String(o)}}}function Os(e,t,r,n){let i=fn(e,r.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=n??oe(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean)return qe(o,r.cacheDir,"missed",void 0,"worktree is not a clean committed snapshot"),{kind:"missed",reason:"worktree is not a clean committed snapshot"};let a=t.languages??nt(e),s=Qe(e,a,yn(t)),c=At(o,s);if(!c)return qe(o,r.cacheDir,"missed",void 0,"worktree is not a clean committed snapshot"),{kind:"missed",reason:"worktree is not a clean committed snapshot"};let d=$(c);if(d)return Re(r.cacheDir,e,s)?(Dt(c,r.cacheDir,"local-fresh"),{kind:"local-fresh"}):(kt({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId});let l=jt(r.cacheDir);return!l||JSON.stringify(l.fingerprint)!==JSON.stringify(s)||JSON.stringify([...l.indexedLanguages??[]].sort())!==JSON.stringify([...a].sort())?{kind:"missed",reason:"local metadata does not match the clean worktree snapshot"}:Re(r.cacheDir,e,s)?(gn({snapshot:c,sourceCacheDir:r.cacheDir,sourceProjectRoot:e,sourceStillValid:()=>{let p=oe(e);return(p?At(p,s):void 0)?.generationId===c.generationId}}),Dt(c,r.cacheDir,"built"),{kind:"built",generationId:c.generationId}):{kind:"missed",reason:"local index artifacts are incomplete or incompatible"}}catch(o){return{kind:"failed",reason:o instanceof Error?o.message:String(o)}}}async function Ms(e,t={}){let r=t.timeoutMs??3e4,n=t.pollMs??100,i=t.now??re,o=i()+r,a=u(e.repositoryCacheDir,"locks"),s=u(a,`${e.generationId}.lock`),c=d=>{if(!d||typeof d!="object"||Array.isArray(d))return null;let l=d.pid;return typeof l=="number"&&Number.isSafeInteger(l)&&l>0?{pid:l}:null};for(;i()<=o;){if($(e))return{kind:"generation-ready"};let d=Te(s,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:c});if(d.kind==="acquired")return{kind:"owner",release:()=>d.lock.release()};let l=o-i();if(l<=0)break;await io(Math.min(n,l))}return $(e)?{kind:"generation-ready"}:{kind:"timeout"}}function Dt(e,t,r,n=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:r,lastSeenAt:(n??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:_t(i)};return Nt(e.repositoryCacheDir,o,!0),o}function _s(e,t,r=void 0){let n={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,lastAction:"overlay",lastReason:`private cache forked from shared baseline ${e.generationId}`,lastSeenAt:(r??(()=>new Date))().toISOString()},i={...n,ownershipChecksum:_t(n)};return Nt(e.repositoryCacheDir,i,!0),i}function qe(e,t,r,n=void 0,i=void 0){let o={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,lastAction:r,...i?{lastReason:i}:{},lastSeenAt:(n??(()=>new Date))().toISOString()},a={...o,ownershipChecksum:_t(o)};return Nt(Ge(e.repositoryId),a,!1),a}function _t(e){return Sn(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:we(e.projectRoot),localCacheDir:we(e.localCacheDir)}))}function mn(e){let t=JSON.parse(e);if(t.version!==Lt||t.artifactCatalogVersion!==be||typeof t.generationId!="string"||!/^[a-f0-9]{64}$/.test(t.generationId)||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.treeOid!="string"||!t.treeOid||typeof t.producerIdentity!="string"||t.producerIdentity!==Ne||typeof t.sourceProjectRoot!="string"||typeof t.scipProjectRoot!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!t.fingerprint||!Array.isArray(t.artifacts))throw new Error("invalid shared generation manifest");let r=new Set;for(let n of t.artifacts){if(!n||typeof n.path!="string"||typeof n.size!="number"||n.size<0||typeof n.sha256!="string"||!/^[a-f0-9]{64}$/.test(n.sha256))throw new Error("invalid shared generation artifact");if(je(n.path),r.has(n.path))throw new Error(`duplicate shared generation artifact: ${n.path}`);r.add(n.path)}for(let n of["index.db","index.scip","meta.json"])if(!r.has(n))throw new Error(`shared generation is missing ${n}`);return t}function ve(e,t,r=384){return Ce(e,t,{mode:r})}function lo(e,t){for(let r of Jt(t)){if(we(r.path)===we(t))continue;let n=ze(r.path),i=jt(n);if(!(!i||JSON.stringify(i.fingerprint)!==JSON.stringify(e.fingerprint)||JSON.stringify([...i.indexedLanguages??[]].sort())!==JSON.stringify([...e.fingerprint.languages].sort()))&&Re(n,r.path,e.fingerprint))try{return{manifest:gn({snapshot:e,sourceCacheDir:n,sourceProjectRoot:r.path}).manifest,sourceProjectRoot:r.path}}catch{continue}}return null}function uo(e,t,r){ee(e,{recursive:!0}),G(u(e,so),{version:1,repositoryId:t,worktreeId:r},{spacing:2,trailingNewline:!0})}function sn(e){try{let t=_e(e),r=cn("sha256");for(let n of t.files){let i=A(e,n),o=Be(i).size;r.update(n).update("\0").update(String(o)).update("\0"),Bt(i,{inputKind:"source-generation artifact",maxBytes:R},a=>r.update(a)),r.update("\0")}return r.digest("hex")}catch{return null}}function jt(e){try{let t=Ae(E(u(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:v}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function yn(e){return{pnpmWorkspaces:e.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:e.indexer?.typescript?.projectMode,typescriptProjects:e.indexer?.typescript?.projects,clojureConfigPath:e.indexer?.clojure?.configPath}}function po(e,t){let r=He(e.languages,e);return JSON.stringify(r)===JSON.stringify(t)}function Ft(e){return u(e.repositoryCacheDir,"generations",e.generationId)}function Nt(e,t,r){let n=er(e,{waitMs:5e3});if(!n)throw new Error("repository cache cleanup is busy");try{if(r){let o=t.activeGenerationId??t.baseGenerationId;if(!o||!B(u(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=u(e,"worktrees");ee(i,{recursive:!0}),G(u(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),uo(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{n.release()}}function fo(e,t){let r=u(t,".rollback"),n=new Map,i=new Map;ee(r,{recursive:!0});for(let s of["index.scip","index.db","meta.json"]){let c=u(e,s),d=B(c);n.set(s,d),d&&ve(c,u(r,"stable",s))}for(let s of Mt){let c=u(e,s),d=B(c);if(d){let l=Tt(c);if(!l.isDirectory()||l.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${s}`)}i.set(s,d)}let o=u(e,ce),a=B(o);return a&&hn(o,u(r,"sqlite-generations")),{root:r,stableFiles:n,managedDirectories:i,generationStoreExisted:a}}function go(e,t,r){for(let n of Mt){let i=u(t,n);if(r.managedDirectories.get(n)){let a=u(r.root,"managed",n);ee(Ct(a),{recursive:!0}),I(()=>U(i,a))}let o=u(e,n);B(o)&&I(()=>U(o,i))}}function mo(e,t){for(let i of Mt){let o=u(e,i),a=u(t.root,"managed",i);t.managedDirectories.get(i)?B(a)&&(q(o,{recursive:!0,force:!0}),I(()=>U(a,o))):q(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let a=u(e,i);if(!o){q(a,{force:!0});continue}let s=`${a}.shared-restore-${no()}`;ve(u(t.root,"stable",i),s),I(()=>q(a,{force:!0})),I(()=>U(s,a))}let r=u(e,ce);q(r,{recursive:!0,force:!0});let n=u(t.root,"sqlite-generations");t.generationStoreExisted&&B(n)&&I(()=>U(n,r))}function hn(e,t){ee(t,{recursive:!0});for(let r of ln(e,{withFileTypes:!0})){let n=u(e,r.name),i=u(t,r.name);if(r.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${n}`);r.isDirectory()?hn(n,i):r.isFile()&&ve(n,i)}}function yo(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||JSON.stringify(e.fingerprint)!==JSON.stringify(t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function Re(e,t,r,n=!0,i=!0){try{let o=jt(e);if(!o||JSON.stringify(o.fingerprint)!==JSON.stringify(r)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...r.languages].sort()))return xe("source validation rejected metadata"),!1;let a=_e(e),s=Et(u(e,"index.db"),u(e,"meta.json"));if(n?s.state!=="current":s.state==="invalid"||s.state==="drifted")return xe(`source validation rejected SQLite generation state ${s.state}`),!1;let c=new oo(u(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let d=qt(t),p=(i?a.files.filter(h=>h.endsWith(".scip")):["index.scip"]).every(h=>{let D=pn(S(A(e,h),{inputKind:"shared SCIP validation artifact",maxBytes:R})).metadata?.projectRoot,y=D!==void 0&&K(D,d);return y||xe(`source validation rejected SCIP root for ${h}: ${String(D)}`),y});return p||xe("source validation rejected SCIP project roots"),p}catch(o){return xe(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function xe(e){process.env.CODEBASEIQ_DEBUG&&console.error(`shared-cache: ${e}`)}function qt(e){try{return nn(un(e)).href}catch{return nn(we(e)).href}}function Sn(e){return cn("sha256").update(e).digest("hex")}function Fs(e){return typeof e=="object"&&e!==null}function Ns(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}export{Kt as a,ho as b,z as c,Ae as d,Ro as e,Xt as f,bn as g,vo as h,ke as i,Zt as j,er as k,T as l,ko as m,zo as n,pr as o,Fs as p,Ns as q,nt as r,Oa as s,$a as t,za as u,sa as v,ca as w,da as x,la as y,ua as z,ba as A,Ia as B,xa as C,wa as D,Kr as E,Qi as F,rs as G,ns as H,Et as I,At as J,fn as K,ks as L,$ as M,Ds as N,gn as O,kt as P,Ls as Q,Os as R,Ms as S,Dt as T,_s as U,_t as V};
21
+ //# sourceMappingURL=chunk-QW7EP6WI.js.map
@@ -0,0 +1,4 @@
1
+ import{appendFileSync as w,mkdirSync as D}from"fs";import{createHash as N,randomUUID as F}from"crypto";import{dirname as k}from"path";import{performance as s}from"perf_hooks";var _="CODEBASEIQ_PROFILE",g="CODEBASEIQ_PROFILE_OUT",P="CODEBASEIQ_PROFILE_COMMAND",m="CODEBASEIQ_PROFILE_CACHE_STATE",u="CODEBASEIQ_PROFILE_RUN_ID",l="CODEBASEIQ_PROFILE_WORKLOAD_IDENTITY",p="CODEBASEIQ_PROFILE_WORKLOAD_IDENTITY_KIND",E=[_,g,P,m,u,l,p],x=new Set(E),I=new Set,O=new Map,y=!1;function a(){let e=process.env[_];return e==="1"||e==="true"}function L(){return process.env[g]}function v(){return process.env[P]}function T(){return process.env[m]}function M(){let e=process.env[u];if(e)return e;if(!a())return;let n=F();return process.env[u]=n,n}function R(){return process.env[l]}function h(e){let n=R();if(n)return n;if(!a())return;let t=M();if(!t)return;let o=e.projectFingerprint?"published-project":"run-only",r=S(["profile-workload-v1",e.toolVersion,e.command,e.projectFingerprint??t]);return process.env[l]=r,process.env[p]=o,r}function S(e){return N("sha256").update(JSON.stringify(e)).digest("hex").slice(0,24)}function V(){return Object.fromEntries(E.flatMap(e=>{let n=process.env[e];return n===void 0?[]:[[e,n]]}))}function j(e){for(let n of E)delete process.env[n];for(let[n,t]of Object.entries(e))x.has(n)&&t!==null&&(process.env[n]=t)}function B(e,n,t){if(!a())return n();let o=s.now();try{let r=n();return d({type:"span",name:e,durationMs:Math.round(s.now()-o),ok:!0,...f(t)??{}}),r}catch(r){throw d({type:"span",name:e,durationMs:Math.round(s.now()-o),ok:!1,error:r instanceof Error?r.message:String(r),...f(t)??{}}),r}}async function Q(e,n,t){if(!a())return n();let o=s.now();try{let r=await n();return d({type:"span",name:e,durationMs:Math.round(s.now()-o),ok:!0,...f(t)??{}}),r}catch(r){throw d({type:"span",name:e,durationMs:Math.round(s.now()-o),ok:!1,error:r instanceof Error?r.message:String(r),...f(t)??{}}),r}}function d(e,n=L()){let t=A(e),o={timestamp:new Date().toISOString(),pid:process.pid,runId:M(),command:v(),cacheState:T(),...t,...e},r=`${JSON.stringify(o)}
2
+ `;if(n)try{let i=k(n);I.has(i)||(D(i,{recursive:!0}),I.add(i)),w(n,r);return}catch(i){y||(y=!0,process.stderr.write(`[profile] failed to write ${n}: ${i instanceof Error?i.message:String(i)}
3
+ `));return}a()&&process.stderr.write(r)}function A(e){let n=R()??h({command:v()??"unknown",toolVersion:"unknown",projectFingerprint:null});if(!n)return{};let t=process.env[p],o=typeof e.name=="string"?e.name:void 0;if(!o)return{workloadIdentity:n,workloadIdentityKind:t};let r=o.split(/[.:]/,1)[0]??o,i=`${n}\0${o}`,c=O.get(i);return c||(c=S(["profile-subsystem-v1",n,o]),O.set(i,c)),{workloadIdentity:n,workloadIdentityKind:t,subsystem:r,subsystemWorkIdentity:c}}function f(e){return typeof e=="function"?e():e}export{a,v as b,M as c,R as d,h as e,S as f,V as g,j as h,B as i,Q as j,d as k};
4
+ //# sourceMappingURL=chunk-R2NOK63J.js.map
@@ -0,0 +1,2 @@
1
+ import{a as P,b as y}from"./chunk-IRQOAM5G.js";import{a as C,c as b,e as r,f}from"./chunk-OTOKVOJ3.js";import{a as g,b as h,c as k}from"./chunk-NMTSZXCL.js";import{M as v}from"./chunk-ADTBPVUZ.js";function L(e,i={}){let{minSimilarity:o=.62,minTokens:n=8,limit:c=20,scope:l,scanLimit:u,filePattern:m,focusFiles:d}=i,s=B(e,{scope:l,minTokens:n,scanLimit:u}),p=P(s,t=>t.tokens);return y({profiles:s,limit:c,filePattern:m,focusFiles:d,candidateIndex:p,profile:{name:"vue-component-duplicates"},compare:(t,a)=>V(t,a,o),sort:(t,a)=>a.similarity-t.similarity||t.fileA.localeCompare(a.fileA)||t.fileB.localeCompare(a.fileB)})}function B(e,i){return v(e).vueProfiles({scope:i.scope,minTemplateTokens:i.minTokens,scanLimit:i.scanLimit}).map(o=>({file:o.file,tokens:o.templateTokens,loc:T(o)}))}function T(e){return e.totalLines}function V(e,i,o){let n=g(e.tokens,i.tokens);if(n.size<6||!R(n))return null;let c=k(e.tokens,i.tokens);if(c<o)return null;let l=r(n,"component:"),u=r(n,"prop:"),m=r(n,"event:"),d=r(n,"directive:"),s=r(n,"slot:"),p=r(n,"id:"),t=S({sharedComponents:l,sharedProps:u,sharedEvents:m,sharedDirectives:d,sharedSlots:s,sharedIdentifiers:p});return{fileA:e.file,fileB:i.file,similarity:c,tokenCountA:e.tokens.size,tokenCountB:i.tokens.size,sharedTokens:f(n),sharedComponents:l,sharedProps:u,sharedEvents:m,sharedDirectives:d,sharedSlots:s,sharedIdentifiers:p,evidenceClass:t.evidenceClass,actionTier:t.actionTier,evidenceClassReasons:t.reasons,recommendation:t.recommendation,uniqueToA:f(h(e.tokens,i.tokens)).slice(0,25),uniqueToB:f(h(i.tokens,e.tokens)).slice(0,25),locA:e.loc,locB:i.loc}}function R(e){let i=0,o=0;for(let n of e)n.startsWith("component:")&&(i+=1),(n.startsWith("prop:")||n.startsWith("event:")||n.startsWith("directive:")||n.startsWith("slot:"))&&(o+=1);return b([{name:"component",count:i},{name:"behavior",count:o}],[{min:{component:1},reason:"shared custom component"},{min:{behavior:3},reason:"shared Vue template structure"}]).pass}function S(e){return C({genericWords:x,primitiveGroups:[{values:e.sharedProps,reasonPrefix:"shared props",bucket:"generic"},{values:e.sharedEvents,reasonPrefix:"shared events",bucket:"generic"},{values:e.sharedDirectives,reasonPrefix:"shared directives",bucket:"generic"},{values:e.sharedSlots,reasonPrefix:"shared slots",bucket:"generic"}],nameGroups:[{names:e.sharedComponents,label:"shared component",fallbackBucket:"generic"},{names:e.sharedIdentifiers,label:"shared identifier",fallbackBucket:"generic"}],recommendation:w})}function w(e){switch(e){case"domain-behavior":case"mixed":return"Review for a shared component or feature-specific Vue primitive around the named domain structure.";case"shared-abstraction":return"Review the existing shared component usage first; extract only if duplicated structure remains outside it.";case"generic-workflow-scaffolding":return"Generic structural overlap \u2014 verify intent before consolidating."}}var x=new Set(["actions","app","button","card","content","container","dialog","field","form","header","input","item","label","layout","list","modal","page","panel","row","section","shell","table","text","toolbar","ui","value","view","wrapper"]);export{L as a};
2
+ //# sourceMappingURL=chunk-RBAS5ZHI.js.map
@@ -0,0 +1,9 @@
1
+ import{a as P,b as k,c as le,d as B}from"./chunk-EF2R3WNQ.js";import{e as ae,g as de,h as F,s as L,t as $,u as ue,v as w,w as f,x as b}from"./chunk-WE5RZHZ7.js";function me(e){try{return process.kill(e,0),!0}catch(r){return typeof r=="object"&&r!==null&&"code"in r&&r.code==="EPERM"}}import{randomUUID as _e}from"crypto";import{closeSync as Ce,fsyncSync as qe,linkSync as $e,mkdirSync as je,openSync as Je,statSync as We,unlinkSync as Ke,writeSync as Ue}from"fs";import{dirname as U}from"path";var J="codebaseiq-process-lock",W=1,O=Object.freeze({wallNow:()=>Date.now(),isProcessAlive:me,readProcessIdentity:le,randomToken:()=>_e(),makeDirectory:e=>je(e,{recursive:!0}),openFile:(e,r,t)=>Je(e,r,t),writeFile:(e,r,t,n)=>Ue(e,r,t,n),syncFile:e=>qe(e),closeFile:e=>Ce(e),linkFile:(e,r)=>$e(e,r),readFile:e=>F(e,"process lock record"),statFile:e=>{let r=We(e);return{dev:r.dev,ino:r.ino,size:r.size,mtimeMs:r.mtimeMs}},removeFile:e=>Ke(e)});function $r(e,r){let t=r.runtime??O;t.makeDirectory(U(e));let n;for(let i=0;i<2;i+=1)try{return{kind:"acquired",lock:fe(e,r,t),...n?{reclaimed:n}:{}}}catch(o){if(o.code!=="EEXIST")throw o;let s=R(e,{parseLegacy:r.parseLegacy,runtime:t});if(i===0&&Xe(e,s,{creationGraceMs:r.creationGraceMs,parseLegacy:r.parseLegacy,runtime:t})){n=s;continue}return{kind:"contended",observation:s}}return{kind:"contended",observation:R(e,{parseLegacy:r.parseLegacy,runtime:t})}}function R(e,r={}){let t=r.runtime??O,n,i;try{n=t.statFile(e),i=t.readFile(e)}catch(a){return a.code==="ENOENT"?{state:"missing"}:{state:"malformed"}}let o;try{o=JSON.parse(i)}catch{return{state:"malformed",raw:i,identity:n}}let s=ze(o);if(s)return{state:"valid",raw:i,identity:n,record:s,owner:He(s),parsed:o};let c=r.parseLegacy?.(o)??null;return c?{state:"legacy",raw:i,identity:n,owner:c,parsed:o}:{state:"malformed",raw:i,identity:n,parsed:o}}function ze(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e;if(r.protocol!==J||r.version!==W||typeof r.kind!="string"||r.kind.trim()===""||typeof r.pid!="number"||!Number.isSafeInteger(r.pid)||r.pid<=0||typeof r.token!="string"||r.token.trim()===""||typeof r.startedAt!="string"||!Number.isFinite(Date.parse(r.startedAt))||r.detail!==void 0&&(typeof r.detail!="object"||r.detail===null||Array.isArray(r.detail)))return null;let t=r.processIdentity===void 0?null:P(r.processIdentity);return r.processIdentity!==void 0&&(!t||t.pid!==r.pid)?null:{protocol:J,version:W,kind:r.kind,pid:r.pid,token:r.token,...t?{processIdentity:t}:{},startedAt:r.startedAt,...r.detail?{detail:r.detail}:{}}}function Xe(e,r,t={}){let n=t.runtime??O;if(!K(r,n))return!1;let i=Ve(`${e}.reclaim`,n);if(!i)return!1;try{let o=R(e,{parseLegacy:t.parseLegacy,runtime:n});return!pe(r,o)||!K(o,n)?!1:z(e,n)}finally{i.release()}}function fe(e,r,t){let n=r.pid??process.pid,i=t.randomToken(),o=r.processIdentity===void 0?t.readProcessIdentity(n):r.processIdentity,s={protocol:J,version:W,kind:r.kind,pid:n,token:i,...o?{processIdentity:o}:{},startedAt:new Date(t.wallNow()).toISOString(),...r.detail?{detail:r.detail}:{}},c=`${e}.${i}.candidate`,a=t.openFile(c,"wx",384),d;try{L(a,Buffer.from(`${JSON.stringify(s)}
2
+ `),t,"process lock"),t.syncFile(a)}catch(y){d=y}try{t.closeFile(a)}catch(y){d??=y}if(d!==void 0)throw j(c,t),d;try{t.linkFile(c,e)}catch(y){throw j(c,t),y}j(c,t);try{be(U(e),t)}catch(y){throw ye(e,s,t),y}let l=!1;return{path:e,record:s,release:()=>l?!1:(l=!0,ye(e,s,t))}}function ye(e,r,t=O){let n=R(e,{runtime:t});return n.state!=="valid"||!n.record||n.record.pid!==r.pid||n.record.token!==r.token||r.processIdentity&&(!n.record.processIdentity||!k(r.processIdentity,n.record.processIdentity))?!1:z(e,t)}function Ve(e,r){for(let t=0;t<2;t+=1)try{return fe(e,{kind:"reclaim-guard",runtime:r},r)}catch(n){if(n.code!=="EEXIST")return null;let i=R(e,{runtime:r});if(t>0||!K(i,r))return null;let o=R(e,{runtime:r});if(!pe(i,o)||!z(e,r))return null}return null}function K(e,r){if(e.state==="missing")return!1;if(e.owner){if(!r.isProcessAlive(e.owner.pid))return!0;if(!e.owner.processIdentity)return!1;let t=r.readProcessIdentity(e.owner.pid);return t!==null&&!k(e.owner.processIdentity,t)}return!1}function pe(e,r){return e.state===r.state&&e.raw===r.raw&&e.identity!==void 0&&r.identity!==void 0&&e.identity.dev===r.identity.dev&&e.identity.ino===r.identity.ino&&e.identity.size===r.identity.size&&e.identity.mtimeMs===r.identity.mtimeMs}function He(e){return{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}}function be(e,r){let t;try{t=r.openFile(e,"r")}catch(n){if($(n,process.platform))return;throw n}try{r.syncFile(t)}catch(n){if(!$(n,process.platform))throw n}finally{r.closeFile(t)}}function z(e,r){try{return r.removeFile(e),be(U(e),r),!0}catch{return!1}}function j(e,r){try{r.removeFile(e)}catch{}}import{randomUUID as sr}from"crypto";import{closeSync as cr,existsSync as ar,fsyncSync as dr,linkSync as lr,mkdirSync as ur,openSync as mr,renameSync as yr,unlinkSync as fr,writeSync as pr}from"fs";import{dirname as we}from"path";var Ye=Object.freeze(["EPERM","EACCES","EBUSY"]),Ge=Object.freeze([10,20,40,80,160,320,640,1e3,1e3,1e3]);function Qe(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}var X=Object.freeze({platform:process.platform,sleep:Qe});function Ze(e,r){if(r!=="win32")return!1;let t=e?.code;return typeof t=="string"&&Ye.includes(t)}function ge(e,r={}){let t=r.runtime??X,n=r.delaysMs??Ge;for(let i of n)try{return e()}catch(o){if(!Ze(o,t.platform))throw o;t.sleep(i)}return e()}import{chmodSync as er,constants as rr,copyFileSync as tr}from"fs";import{dirname as nr}from"path";var xe=Object.freeze({...ue,copyFile:(e,r)=>tr(e,r,rr.COPYFILE_FICLONE),chmodFile:(e,r)=>er(e,r)});function ir(e,r,t={}){let n=t.runtime??xe,i=nr(r),o=w(i,n);if(n.copyFile(e,r),n.platform==="win32")or(r,t.mode,n);else{t.mode!==void 0&&n.chmodFile(r,t.mode);let s=n.openFile(r,"r");try{n.syncFile(s)}finally{n.closeFile(s)}}return b(o,f(i,n))}function or(e,r,t){let n=!1,i;try{i=t.openFile(e,"r+")}catch(o){let s=o.code;if(s!=="EACCES"&&s!=="EPERM")throw o;t.chmodFile(e,384),n=!0,i=t.openFile(e,"r+")}try{t.syncFile(i)}finally{t.closeFile(i)}r!==void 0?t.chmodFile(e,r):n&&t.chmodFile(e,292)}var Me=Object.freeze({platform:process.platform,randomToken:()=>sr(),pathExists:e=>ar(e),makeDirectory:e=>ur(e,{recursive:!0}),openFile:(e,r,t)=>mr(e,r,t),writeFile:(e,r,t,n)=>pr(e,r,t,n),syncFile:e=>dr(e),closeFile:e=>cr(e),renameFile:(e,r)=>yr(e,r),linkFile:(e,r)=>lr(e,r),removeFile:e=>fr(e)});function V(e,r,t={}){let n=t.durability??"visibility",i=t.runtime??Me,o=we(e),s=n==="durable"?w(o,i):(i.makeDirectory(o),"not-requested"),c=`${e}.tmp-${i.randomToken()}`,a=typeof r=="string"?Buffer.from(r):r,d,l=!1;try{d=i.openFile(c,"wx",t.mode??384),l=!0,L(d,a,i,"atomic file"),n==="durable"&&i.syncFile(d),i.closeFile(d),d=void 0,ge(()=>i.renameFile(c,e),{runtime:{platform:i.platform,sleep:i.sleep??X.sleep}}),l=!1;let y=n==="durable"?b(s,f(o,i)):"not-requested";return Fe(n,y)}finally{if(d!==void 0)try{i.closeFile(d)}catch{}if(l)try{i.removeFile(c)}catch{}}}function N(e,r,t={}){let n=t.durability??"visibility",i=t.runtime??Me;if(!i.linkFile)throw new Error("Exclusive atomic file publication requires hard-link support.");let o=we(e),s=n==="durable"?w(o,i):(i.makeDirectory(o),"not-requested"),c=`${e}.tmp-${i.randomToken()}`,a=typeof r=="string"?Buffer.from(r):r,d,l=!1;try{d=i.openFile(c,"wx",t.mode??384),l=!0,L(d,a,i,"exclusive atomic file"),n==="durable"&&i.syncFile(d),i.closeFile(d),d=void 0,i.linkFile(c,e);let y=n==="durable"?f(o,i):"not-requested";i.removeFile(c),l=!1;let u=n==="durable"?b(s,y,f(o,i)):"not-requested";return Fe(n,u)}finally{if(d!==void 0)try{i.closeFile(d)}catch{}if(l)try{i.removeFile(c)}catch{}}}function Fe(e,r){return{requestedDurability:e,achievedDurability:e==="visibility"?"visibility":r==="synced"?"directory-durable":"file-flushed",directorySync:r}}function nt(e,r,t={}){V(e,he(r,t),{durability:"visibility",runtime:t.runtime})}function H(e,r,t={}){return V(e,he(r,t),{durability:"durable",runtime:t.runtime})}function he(e,r){let t=JSON.stringify(e,null,r.spacing);return r.trailingNewline?`${t}
3
+ `:t}import{createHash as Y,randomUUID as Ae}from"crypto";import{existsSync as M,lstatSync as D,readdirSync as I,renameSync as G,rmSync as g}from"fs";import{basename as A,dirname as Q,join as m}from"path";function T(e){return Array.isArray(e)?`[${e.map(T).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).sort(([r],[t])=>r.localeCompare(t)).map(([r,t])=>`${JSON.stringify(r)}:${T(t)}`).join(",")}}`:JSON.stringify(e)}var Z=1,br=Object.freeze({maxItems:1024,maxBytes:512*1024*1024,maxItemBytes:64*1024*1024,maxBatch:16,claimLeaseMs:5*6e4,responseRetentionMs:10*6e4,deadLetterRetentionMs:1440*6e4,temporaryRetentionMs:6e4,cleanupBatch:64}),x=class extends Error{constructor(t,n,i,o){let s=t==="item-too-large"?`request is ${o} bytes; per-item limit is ${i.maxItemBytes}`:t==="item-capacity"?`mailbox has ${n.totalItems} retained items; limit is ${i.maxItems}`:t==="byte-capacity"?`mailbox retains ${n.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=t;this.status=n;this.limits=i;this.attemptedBytes=o;this.name="MailboxBackpressureError"}code;status;limits;attemptedBytes},Ee=".owner.json",ee={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function pt(e){return{rootDir:e,pendingDir:m(e,"pending"),inflightDir:m(e,"inflight"),responseDir:m(e,"responses"),deadLetterDir:m(e,"dead-letter"),legacyRequestDir:m(e,"requests")}}function S(e={}){let r={...br,...e};for(let[t,n]of Object.entries(r))if(!Number.isFinite(n)||n<=0||!Number.isInteger(n))throw new Error(`Mailbox limit ${t} must be a positive integer.`);return r}function C(e){let r=[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir].map(t=>w(t));return b(...r)}function bt(e,r){return Y("sha256").update(T({namespace:e,payload:r})).digest("hex")}function gr(e){if(!/^[a-f0-9]{64}$/.test(e))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${e}`}function gt(e,r,t={}){let n=S(t.limits),i=t.nowMs??Date.now(),o=C(e);return Sr(r),te(e,n,t.admissionLockTimeoutMs??2e3,t.monotonicNow??B,()=>{re(e,i,n);let s=m(e.pendingDir,`${r.id}.json`),c=m(e.responseDir,`${r.id}.json`),a=Ie(e,r.id);if(a){let u=ke(a,r.operationKey,r.id);return{disposition:"duplicate",requestId:r.id,responsePath:c,authoritativeDeadlineAtMs:u.deadlineAtMs??r.deadlineAtMs}}let d=`${JSON.stringify(r)}
4
+ `,l=Buffer.byteLength(d),y=q(e);if(l>n.maxItemBytes)throw new x("item-too-large",y,n,l);if(y.totalItems+1>n.maxItems)throw new x("item-capacity",y,n,l);if(y.totalBytes+l>n.maxBytes)throw new x("byte-capacity",y,n,l);t.onBeforePublish?.();try{let u=N(s,d,{durability:"durable"}),p=b(o,u.directorySync);return{disposition:"accepted",requestId:r.id,responsePath:c,authoritativeDeadlineAtMs:r.deadlineAtMs,achievedDurability:p==="synced"?"directory-durable":"file-flushed",directorySync:p}}catch(u){if(u.code!=="EEXIST")throw u;let p=Ie(e,r.id);if(!p)throw u;let v=ke(p,r.operationKey,r.id);return{disposition:"duplicate",requestId:r.id,responsePath:c,authoritativeDeadlineAtMs:v.deadlineAtMs??r.deadlineAtMs}}})}function xr(e,r){if(!r.ownerId.trim())throw new Error("Mailbox claim owner identity is required.");if(r.owner&&(!Number.isSafeInteger(r.owner.pid)||r.owner.pid<=0||r.owner.processIdentity!==void 0&&r.owner.processIdentity.pid!==r.owner.pid))throw new Error("Mailbox claim process identity is invalid.");let t=r.nowMs??Date.now(),n=S(r.limits),i=C(e);try{return te(e,n,2e3,r.monotonicNow??B,()=>wr(e,r.ownerId,t,n,r.liveness??ee,r.owner??{pid:process.pid},i,r.onClaimStage))}catch(o){if(o instanceof x&&o.code==="admission-busy")return[];throw o}}function xt(e,r){return!Se(e.pendingDir)&&!Se(e.legacyRequestDir)?[]:xr(e,r)}function wr(e,r,t,n,i,o,s,c){re(e,t,n,i);let a=m(e.inflightDir,_(r)),d=[...Re(e.pendingDir,!1),...Re(e.legacyRequestDir,!0)].sort((u,p)=>u.orderAtMs-p.orderAtMs||u.header.id.localeCompare(p.header.id)||u.path.localeCompare(p.path)),l=s;d.length>0&&(l=b(l,w(a)),c?.("after-owner-directory-durable"),Rr(a,r,o),c?.("after-owner-record-published"));let y=[];for(let u of d){if(y.length>=n.maxBatch)break;let p=m(e.responseDir,`${u.header.id}.json`);if(M(p)){g(u.path,{force:!0});continue}let v=Math.max(t+n.claimLeaseMs,(u.header.deadlineAtMs??t)+5e3),Be=`${_(u.originalFile)}.${v}.claim`,oe=m(a,Be);try{G(u.path,oe)}catch(se){let ce=se.code;if(ce==="ENOENT"||ce==="EEXIST")continue;throw se}c?.("after-claim-renamed");let Oe=f(Q(u.path));c?.("after-source-directory-synced");let Ne=f(a);c?.("after-destination-directory-synced");let Te=b(l,Oe,Ne);y.push({requestId:u.header.id,ownerId:r,path:oe,originalFile:u.originalFile,claimedAtMs:t,claimExpiresAtMs:v,byteLength:u.byteLength,...u.header.operationKey?{operationKey:u.header.operationKey}:{},...u.header.clientId?{clientId:u.header.clientId}:{},...u.header.enqueuedAtMs===void 0?{}:{enqueuedAtMs:u.header.enqueuedAtMs},...u.header.deadlineAtMs===void 0?{}:{deadlineAtMs:u.header.deadlineAtMs},legacy:u.legacy,directorySync:Te})}return y}function wt(e,r={}){let t=S(r);if(e.byteLength>t.maxItemBytes)throw new x("item-too-large",{pending:0,inflight:1,responses:0,deadLetters:0,invalid:0,totalItems:1,totalBytes:e.byteLength},t,e.byteLength);return de(e.path,{maxBytes:t.maxItemBytes,inputKind:"bounded mailbox item"})}function Mr(e,r,t,n={}){let i=n.nowMs??Date.now(),o=S(n.limits),s={...t,mailboxVersion:Z,operationKey:r.operationKey??`legacy-${r.requestId}`,clientId:r.clientId??"legacy",...r.deadlineAtMs===void 0?{}:{deadlineAtMs:r.deadlineAtMs},completedAtMs:i,expiresAtMs:i+o.responseRetentionMs},c=Buffer.byteLength(`${JSON.stringify(s)}
5
+ `),a=q(e);if(c>o.maxItemBytes)throw new x("item-too-large",a,o,c);let d=Math.max(0,a.totalBytes-r.byteLength)+c;if(d>o.maxBytes&&d>a.totalBytes)throw new x("byte-capacity",a,o,c);Fr(e,r,s),n.onAfterResponsePublished?.(),g(r.path,{force:!0});let l=Q(r.path);f(M(l)?l:e.inflightDir)}function Mt(e,r,t,n,i={}){let o=i.nowMs??Date.now(),s=S(i.limits);if(Mr(e,r,t,{...i,nowMs:o,limits:s}),!M(r.path)){let c=m(e.deadLetterDir,`${Er(r.requestId)}.${o}.${Y("sha256").update(n).digest("hex").slice(0,12)}.json`),a={mailboxVersion:Z,requestId:r.requestId,ownerId:r.ownerId,rejectedAtMs:o,reason:n,originalFile:r.originalFile},d=Buffer.byteLength(`${JSON.stringify(a,null,2)}
6
+ `),l=q(e);l.totalItems<s.maxItems&&l.totalBytes+d<=s.maxBytes&&H(c,a,{spacing:2,trailingNewline:!0})}}function Ft(e,r={}){let t=r.nowMs??Date.now(),n=S(r.limits);return C(e),te(e,n,2e3,r.monotonicNow??B,()=>re(e,t,n,r.liveness??ee))}function re(e,r,t,n=ee){let i={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=t.cleanupBatch;for(let s of ie(e.inflightDir)){if(o<=0)break;let c=m(e.responseDir,`${s.requestId}.json`);if(M(c)){g(s.path,{force:!0}),i.completedClaimsRemoved++,o--;continue}if(s.claimExpiresAtMs>r||Dr(e,s.ownerId,n)!=="dead")continue;let a=m(e.pendingDir,s.originalFile);try{G(s.path,a),i.reclaimed++}catch(d){if(d.code!=="EEXIST")throw d;g(s.path,{force:!0})}f(Q(s.path)),f(e.pendingDir),o--}o=De(e.responseDir,o,(s,c)=>c+t.responseRetentionMs,r,()=>{i.responsesRemoved++}),o=De(e.deadLetterDir,o,(s,c)=>c+t.deadLetterRetentionMs,r,()=>{i.deadLettersRemoved++});for(let s of[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir]){if(o<=0)break;for(let c of Pe(s)){if(o<=0)break;A(c).includes(".tmp-")&&(D(c).mtimeMs+t.temporaryRetentionMs>r||(g(c,{force:!0}),i.temporaryFilesRemoved++,o--))}}return Lr(e.inflightDir),i}function q(e){C(e);let r=[...h(e.pendingDir).map(a=>({path:a,pending:!0})),...h(e.legacyRequestDir).map(a=>({path:a,pending:!0}))],t=ie(e.inflightDir).map(a=>({path:a.path,pending:!1})),n=h(e.responseDir).map(a=>({path:a,pending:!1})),i=h(e.deadLetterDir).map(a=>({path:a,pending:!1})),o=[...r,...t,...n,...i],s=0,c;for(let a of r){let d=E(a.path);if(!d){s++;continue}let l=d.enqueuedAtMs??D(a.path).mtimeMs;c=c===void 0?l:Math.min(c,l)}return{pending:r.length,inflight:t.length,responses:n.length,deadLetters:i.length,invalid:s,totalItems:o.length,totalBytes:o.reduce((a,d)=>a+Ar(d.path),0),...c===void 0?{}:{oldestPendingAt:new Date(c).toISOString()}}}function Fr(e,r,t){let n=m(e.responseDir,`${r.requestId}.json`),i=`${JSON.stringify(t)}
7
+ `;try{N(n,i,{durability:"durable"})}catch(o){if(o.code!=="EEXIST")throw o;let s=E(n),c=r.operationKey??`legacy-${r.requestId}`;if(s?.operationKey!==c)throw new Error(`Mailbox completion ${r.requestId} conflicts with an existing operation.`,{cause:o})}}function te(e,r,t,n,i){let o=m(e.rootDir,".admission.lock"),s=`${process.pid}-${Ae()}`,c=n()+Math.max(0,t);for(;!hr(e.rootDir,o,s);){if(Ir(o),n()>=c)throw new x("admission-busy",q(e),r,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return i()}finally{try{ne(o).ownerToken===s&&(g(o,{recursive:!0,force:!0}),f(e.rootDir))}catch{}}}function hr(e,r,t){let n=`${JSON.stringify({ownerToken:t,pid:process.pid,acquiredAtMs:Date.now()})}
8
+ `;try{return N(r,n,{durability:"durable"}),!0}catch(i){if(i.code==="EEXIST")return!1;try{ne(r).ownerToken===t&&(g(r,{force:!0}),f(e))}catch{}throw i}}function Ir(e){let r=null;try{let n=ne(e);typeof n.ownerToken=="string"&&Number.isSafeInteger(n.pid)&&Number(n.pid)>0&&(r=Number(n.pid))}catch{}if(r===null||kr(r))return;let t=`${e}.stale-${Ae()}`;try{G(e,t)}catch(n){let i=n.code;if(i==="ENOENT"||i==="EEXIST")return;throw n}g(t,{recursive:!0,force:!0})}function ne(e){try{return JSON.parse(F(e,"mailbox lock record"))}catch(r){if(r.code!=="EISDIR"&&!(r instanceof ae&&r.reason==="not-regular"))throw r;return JSON.parse(F(m(e,"owner.json"),"mailbox lock owner record"))}}function kr(e){try{return process.kill(e,0),!0}catch(r){let t=r.code;return t==="EPERM"||t!=="ESRCH"}}function Rr(e,r,t){let n=m(e,Ee),i=t.processIdentity,o=ve(n);if(!(o&&o.ownerId===r&&o.pid===t.pid&&(!o.processIdentity&&!i||o.processIdentity&&i&&k(o.processIdentity,i)))){if(h(e).some(s=>s.endsWith(".claim")))throw new Error(`Mailbox owner identity ${r} collides with retained work from another process instance.`);H(n,{version:1,ownerId:r,pid:t.pid,...i?{processIdentity:i}:{}})}}function Dr(e,r,t){let n=ve(m(e.inflightDir,_(r),Ee));if(!n)return"unknown";if(!t.isProcessAlive(n.pid))return"dead";if(!n.processIdentity)return"live";let i=t.readProcessIdentity(n.pid);return i?k(n.processIdentity,i)?"live":"dead":"unknown"}function ve(e){try{let r=JSON.parse(F(e,"mailbox owner record"));if(r.version!==1||typeof r.ownerId!="string"||!r.ownerId||typeof r.pid!="number"||!Number.isSafeInteger(r.pid)||r.pid<=0)return null;let t=r.processIdentity===void 0?null:P(r.processIdentity);return r.processIdentity!==void 0&&(!t||t.pid!==r.pid)?null:{version:1,ownerId:r.ownerId,pid:r.pid,...t?{processIdentity:t}:{}}}catch{return null}}function Ie(e,r){for(let t of[m(e.pendingDir,`${r}.json`),m(e.legacyRequestDir,`${r}.json`),m(e.responseDir,`${r}.json`)])if(M(t))return t;for(let t of ie(e.inflightDir))if(t.requestId===r)return t.path;return null}function ke(e,r,t){let n=E(e);if(!n||n.operationKey!==r)throw new Error(`Mailbox operation ${t} conflicts with an existing retained record.`);return n}function Sr(e){if(e.mailboxVersion!==Z||e.id!==gr(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 Re(e,r){return h(e).filter(t=>t.endsWith(".json")).map(t=>{let n=D(t),i=A(t,".json"),o=E(t)??{id:i};return{path:t,originalFile:A(t),header:o,byteLength:n.size,orderAtMs:o.enqueuedAtMs??n.mtimeMs,legacy:r}})}function ie(e){if(!M(e))return[];let r=[];for(let t of I(e,{withFileTypes:!0})){if(!t.isDirectory())continue;let n=Le(t.name);if(n===null)continue;let i=m(e,t.name);for(let o of I(i,{withFileTypes:!0})){if(!o.isFile()||!o.name.endsWith(".claim"))continue;let s=/^(.*)\.(\d+)\.claim$/.exec(o.name);if(!s)continue;let c=Le(s[1]),a=Number(s[2]);if(c===null||A(c)!==c||!c.endsWith(".json")||!Number.isSafeInteger(a))continue;let d=m(i,o.name),l=E(d)??{id:A(c,".json")},y=D(d);r.push({requestId:l.id,ownerId:n,path:d,originalFile:c,claimedAtMs:y.mtimeMs,claimExpiresAtMs:a,byteLength:y.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 r.sort((t,n)=>t.claimedAtMs-n.claimedAtMs||t.path.localeCompare(n.path))}function E(e){try{let r=JSON.parse(F(e,"mailbox record"));return typeof r.id!="string"||!r.id?null:{id:r.id,...typeof r.operationKey=="string"?{operationKey:r.operationKey}:{},...typeof r.clientId=="string"?{clientId:r.clientId}:{},...typeof r.enqueuedAtMs=="number"?{enqueuedAtMs:r.enqueuedAtMs}:{},...typeof r.deadlineAtMs=="number"?{deadlineAtMs:r.deadlineAtMs}:{}}}catch{return null}}function De(e,r,t,n,i){for(let o of h(e)){if(r<=0)break;let s=D(o);t(o,s.mtimeMs)>n||(g(o,{force:!0}),i(),r--)}return r}function h(e){return M(e)?I(e,{withFileTypes:!0}).filter(r=>r.isFile()).map(r=>m(e,r.name)).sort():[]}function Se(e){try{return I(e).some(r=>r.endsWith(".json"))}catch{return!1}}function Pe(e){if(!M(e))return[];let r=[];for(let t of I(e,{withFileTypes:!0})){let n=m(e,t.name);t.isFile()?r.push(n):t.isDirectory()&&r.push(...Pe(n))}return r.sort()}function Lr(e){if(M(e))for(let r of I(e,{withFileTypes:!0})){if(!r.isDirectory())continue;let t=m(e,r.name);I(t).some(n=>n.endsWith(".claim"))||g(t,{recursive:!0,force:!0})}}function Ar(e){try{return D(e).size}catch{return 0}}function _(e){return Buffer.from(e,"utf8").toString("base64url")}function Le(e){try{let r=Buffer.from(e,"base64url").toString("utf8");return _(r)===e?r:null}catch{return null}}function Er(e){return/^[a-z0-9][a-z0-9-]{0,127}$/i.test(e)?e:`invalid-${Y("sha256").update(e).digest("hex")}`}function vr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function It(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function kt(e){return vr(e)&&Object.values(e).every(r=>typeof r=="string"||r===null)}function Rt(e){return typeof e=="string"&&e.length>0}function Dt(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function St(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function Lt(e){return typeof e=="string"&&e.length>0&&e.length<=256&&!/[\0\r\n]/u.test(e)}function At(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}export{vr as a,It as b,kt as c,Rt as d,Dt as e,St as f,Lt as g,At as h,ge as i,me as j,O as k,$r as l,R as m,Xe as n,ir as o,V as p,N as q,nt as r,H as s,T as t,Z as u,pt as v,C as w,bt as x,gr as y,gt as z,xt as A,wt as B,Mr as C,Mt as D,Ft as E,q as F};
9
+ //# sourceMappingURL=chunk-RDBI2RXU.js.map
@@ -0,0 +1,73 @@
1
+ import{a as c}from"./chunk-GTXSJDCO.js";import{a as r}from"./chunk-UZGZB3VB.js";import{a as l}from"./chunk-NNOKTMZT.js";import{d as m}from"./chunk-FETNQCFO.js";function N(n,t){let e=r(n,t);if(!e)return[];let s=n.get(`SELECT COUNT(DISTINCT c.document_id) AS file_count
2
+ FROM mentions m
3
+ JOIN chunks c ON m.chunk_id = c.id
4
+ JOIN (
5
+ SELECT m2.symbol_id, c2.document_id
6
+ FROM mentions m2
7
+ JOIN chunks c2 ON m2.chunk_id = c2.id
8
+ WHERE m2.role = 1
9
+ GROUP BY m2.symbol_id
10
+ ) sym_def ON sym_def.symbol_id = m.symbol_id
11
+ WHERE m.symbol_id = ?
12
+ AND m.role != 1
13
+ AND sym_def.document_id != c.document_id`,e.symbolId);return[{name:m(e.symbol),count:s?.file_count??0,symbol:e.symbol,definedIn:e.relativePath}]}function a(n,t){let e=c(n,t);return e?n.all(`SELECT d.relative_path, COUNT(DISTINCT gs.id) AS symbol_count
14
+ FROM mentions m
15
+ JOIN chunks c ON m.chunk_id = c.id
16
+ JOIN documents d ON c.document_id = d.id
17
+ JOIN global_symbols gs ON m.symbol_id = gs.id
18
+ JOIN (
19
+ SELECT m2.symbol_id, c2.document_id
20
+ FROM mentions m2
21
+ JOIN chunks c2 ON m2.chunk_id = c2.id
22
+ WHERE m2.role = 1
23
+ GROUP BY m2.symbol_id
24
+ ) sym_def ON sym_def.symbol_id = gs.id
25
+ JOIN documents def_d ON sym_def.document_id = def_d.id
26
+ WHERE d.relative_path = ?
27
+ AND m.role != 1
28
+ AND def_d.id != d.id
29
+ GROUP BY d.id
30
+ ORDER BY symbol_count DESC`,e).filter(i=>!n.isIgnored(i.relative_path)).map(i=>({name:i.relative_path,count:i.symbol_count,file:i.relative_path,basis:"external-symbol-references"})):[]}function u(n,t){let e=c(n,t);if(!e)return[];let o=l(n).get(e);return!o||o.size===0?[]:[{name:e,count:o.size,file:e,basis:"file-dependency-edges"}]}function g(n,t){let e=a(n,t);return e.length>0?e:u(n,t)}function I(n,t={}){return _(n,t).map(e=>({name:m(e.symbol),count:e.file_count,symbol:e.symbol,definedIn:e.defined_in}))}function _(n,t){let{limit:e=30,scope:s}=t,o=s?"AND def_d.relative_path LIKE ?":"",i=s?[`%${s}%`]:[];return n.all(`SELECT gs.symbol,
31
+ COUNT(DISTINCT c.document_id) AS file_count,
32
+ def_d.relative_path AS defined_in
33
+ FROM mentions m
34
+ JOIN chunks c ON m.chunk_id = c.id
35
+ JOIN global_symbols gs ON m.symbol_id = gs.id
36
+ JOIN (
37
+ SELECT m2.symbol_id, c2.document_id
38
+ FROM mentions m2
39
+ JOIN chunks c2 ON m2.chunk_id = c2.id
40
+ WHERE m2.role = 1
41
+ GROUP BY m2.symbol_id
42
+ ) sym_def ON sym_def.symbol_id = gs.id
43
+ JOIN documents def_d ON sym_def.document_id = def_d.id
44
+ WHERE m.role != 1
45
+ AND def_d.id != c.document_id
46
+ ${n.pathExclusionsFor("def_d")}
47
+ ${n.symbolNoiseFor("gs")}
48
+ ${o}
49
+ GROUP BY gs.id
50
+ HAVING file_count > 1
51
+ ORDER BY file_count DESC
52
+ LIMIT ?`,...i,e)}function R(n,t={}){let{limit:e=30,scope:s}=t,o=s?"AND d.relative_path LIKE ?":"",i=s?[`%${s}%`]:[];return n.all(`SELECT d.relative_path, COUNT(DISTINCT gs.id) AS symbol_count
53
+ FROM mentions m
54
+ JOIN chunks c ON m.chunk_id = c.id
55
+ JOIN documents d ON c.document_id = d.id
56
+ JOIN global_symbols gs ON m.symbol_id = gs.id
57
+ JOIN (
58
+ SELECT m2.symbol_id, c2.document_id
59
+ FROM mentions m2
60
+ JOIN chunks c2 ON m2.chunk_id = c2.id
61
+ WHERE m2.role = 1
62
+ GROUP BY m2.symbol_id
63
+ ) sym_def ON sym_def.symbol_id = gs.id
64
+ JOIN documents def_d ON sym_def.document_id = def_d.id
65
+ WHERE m.role != 1
66
+ AND def_d.id != d.id
67
+ ${n.pathExclusionsFor("d")}
68
+ ${n.symbolNoiseFor("gs")}
69
+ ${o}
70
+ GROUP BY d.id
71
+ ORDER BY symbol_count DESC
72
+ LIMIT ?`,...i,e).filter(d=>!n.isIgnored(d.relative_path)).map(d=>({name:d.relative_path,count:d.symbol_count}))}export{N as a,a as b,u as c,g as d,I as e,R as f};
73
+ //# sourceMappingURL=chunk-RKEJ6VTF.js.map
@@ -0,0 +1,35 @@
1
+ import{a as g}from"./chunk-GTXSJDCO.js";import{h as p}from"./chunk-6CS3UQTN.js";import{a as f}from"./chunk-UZGZB3VB.js";import{d as u,e as _,i as N}from"./chunk-FETNQCFO.js";import{p as d}from"./chunk-O6QTXQPJ.js";import{a as I,z as l}from"./chunk-ADTBPVUZ.js";import{u as b}from"./chunk-BMYOV5GP.js";import{c}from"./chunk-NNJ2KZZG.js";function Y(e,t,r={}){return T(e,t,r)?.map(s=>({symbol:s.symbol,shortName:s.shortName,fromFile:s.fromFile}))??[]}function Z(e,t){let r=f(e,t),s=O(e,t);if(s.length>0&&!x(r))return s;let o=k(e,t,r);return h(t)&&o.length>0?o:D([...s,...o])}function G(e,t,r={}){let s=g(e,t);if(!s)return[];let o=S(e,s),n=r.semantic===!1?null:E(e,s);return(n?R(n,o):o).filter(m=>!m.used).map(m=>({symbol:m.symbol,shortName:m.shortName,importedIn:m.importer}))}function R(e,t){let r=new Map;for(let o of t){let n=r.get(o.shortName);n?n.push(o):r.set(o.shortName,[o])}let s=e.map(o=>{let n=r.get(o.shortName),i=n?.shift();return n?.length===0&&r.delete(o.shortName),i?{...o,used:o.used||i.used}:o});return s.push(...[...r.values()].flat()),s}function O(e,t){return e.all(`SELECT DISTINCT gs.symbol, d.relative_path AS importer
2
+ FROM mentions m
3
+ JOIN chunks c ON m.chunk_id = c.id
4
+ JOIN documents d ON c.document_id = d.id
5
+ JOIN global_symbols gs ON m.symbol_id = gs.id
6
+ WHERE gs.symbol LIKE ?
7
+ AND m.role = 2
8
+ ORDER BY d.relative_path`,`%${t}%`).filter(s=>!e.isIgnored(s.importer)).map(s=>({symbol:s.symbol,shortName:u(s.symbol),fromFile:s.importer}))}function k(e,t,r=f(e,t)){let s=r?.relativePath??null,o=r?_(r.symbol):t.replace(/\(\)$/,""),n=r?N(r.symbol):!1,i=new Set;for(let a of I(e,{includeIgnored:!1}))for(let F of d(e,a))M(F,a,{targetFile:s,targetLeaf:o,targetIsModule:n,targetPattern:t})&&i.add(a);let m=h(t)?t.trim():null;return[...i].sort().map(a=>({symbol:m??r?.symbol??o,shortName:m??(r?u(r.symbol):o),fromFile:a}))}function x(e){return!!(e&&(e.symbol.startsWith("scip-clojure ")||l(e.relativePath)==="clojure"))}function D(e){let t=new Set,r=[];for(let s of e){let o=`${s.symbol}|${s.fromFile}`;t.has(o)||(t.add(o),r.push(s))}return r.sort((s,o)=>s.fromFile.localeCompare(o.fromFile)||s.shortName.localeCompare(o.shortName))}function M(e,t,r){return!e.sourcePath||r.targetFile&&c(e.sourcePath)!==c(r.targetFile)?!1:e.kind==="side-effect"||r.targetFile&&$(t)||e.kind==="namespace"&&P(e,r.targetPattern)||r.targetIsModule||e.kind==="named"&&e.importedName===r.targetLeaf?!0:e.kind==="namespace"&&e.usedMembers.includes(r.targetLeaf)}function P(e,t){let r=t.trim().replace(/\(\)$/,"");return h(r)?e.importedName===r||e.localName===r:!1}function h(e){let t=e.trim().replace(/\(\)$/,"");return t.includes(".")&&!t.includes("/")&&!t.includes(":")}function T(e,t,r={}){let s=g(e,t);return s?L(e,s,r)??(r.semantic===!1?null:E(e,s))??S(e,s):null}function L(e,t,r){let o=e.all(`SELECT DISTINCT
9
+ gs.symbol,
10
+ def_d.relative_path AS from_file,
11
+ imp_d.relative_path AS importer,
12
+ EXISTS (
13
+ SELECT 1
14
+ FROM mentions ref_m
15
+ JOIN chunks ref_c ON ref_m.chunk_id = ref_c.id
16
+ WHERE ref_m.symbol_id = gs.id
17
+ AND ref_m.role != 1
18
+ AND ref_c.document_id = imp_d.id
19
+ ) AS used
20
+ FROM mentions m
21
+ JOIN chunks c ON m.chunk_id = c.id
22
+ JOIN documents imp_d ON c.document_id = imp_d.id
23
+ JOIN global_symbols gs ON m.symbol_id = gs.id
24
+ LEFT JOIN (
25
+ SELECT m2.symbol_id, c2.document_id
26
+ FROM mentions m2
27
+ JOIN chunks c2 ON m2.chunk_id = c2.id
28
+ WHERE m2.role = 1
29
+ GROUP BY m2.symbol_id
30
+ ) sym_def ON sym_def.symbol_id = gs.id
31
+ LEFT JOIN documents def_d ON sym_def.document_id = def_d.id
32
+ WHERE imp_d.relative_path = ?
33
+ AND m.role = 2
34
+ ORDER BY def_d.relative_path, gs.symbol`,t).filter(n=>!e.isIgnored(n.importer));if(o.length>0){let n=r.semantic===!1?[]:p(e,t);return o.map(i=>({symbol:i.symbol,shortName:u(i.symbol),fromFile:i.from_file??"(external)",importer:i.importer,used:i.used!==0||n.some(m=>m.isUsed&&m.sourcePath===i.from_file)}))}return null}function E(e,t){let r=p(e,t);return r.length>0?r.map(s=>{let o=y(s.importedName,s.localName,s.kind);return{symbol:o,shortName:o,fromFile:s.sourcePath??"(external)",importer:t,used:s.kind==="side-effect"?!0:s.isUsed}}):null}function S(e,t){let r=A(t,b(e,t));return d(e,t).map(s=>{let o=y(s.importedName,s.localName,s.kind),n=s.kind==="side-effect"||v(t,s)||r.has(s.localName??s.importedName)?!0:s.used;return{symbol:o,shortName:o,fromFile:s.sourcePath??"(external)",importer:t,used:n}})}function A(e,t){let r=new Set;if(l(e)!=="python")return r;let s=/(?:^|\n)\s*__all__\s*(?:\+?=)\s*[[(]([\s\S]*?)[\])]/g;for(let o of t.matchAll(s)){let n=o[1]??"";for(let i of n.matchAll(/(['"])([A-Za-z_]\w*)\1/g))r.add(i[2])}return r}function v(e,t){if(l(e)!=="rust"||t.used||t.kind==="side-effect")return!1;let r=t.localName??t.importedName;return r==="_"||/^[A-Z]/.test(r)}function y(e,t,r){return r==="namespace"&&e==="*"&&t?`* as ${t}`:r==="default"&&t?`default as ${t}`:r==="side-effect"?"(side effect import)":t&&t!==e?`${e} as ${t}`:e}function $(e){return/\.(?:c|h|cc|cpp|cxx|hpp|hh|hxx)$/i.test(e)}export{Y as a,Z as b,G as c};
35
+ //# sourceMappingURL=chunk-RR7SX44N.js.map