codebaseiq 0.1.0 → 0.2.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 (422) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/augment-vue-worker.js +1 -1
  3. package/dist/{chunk-DQMDCD24.js → chunk-27PHVDKL.js} +2 -2
  4. package/dist/{chunk-ZMI2JSX2.js → chunk-2DMVFAY7.js} +2 -2
  5. package/dist/{chunk-5PUWMSDU.js → chunk-2E6BTWER.js} +2 -2
  6. package/dist/{chunk-YESXMKX3.js → chunk-2F5ERMNI.js} +2 -2
  7. package/dist/chunk-2VKB5CMA.js +60 -0
  8. package/dist/{chunk-NNJ2KZZG.js → chunk-327YK6TB.js} +4 -4
  9. package/dist/chunk-347TXATM.js +2 -0
  10. package/dist/{chunk-VEXUL62T.js → chunk-35YYZD3D.js} +2 -2
  11. package/dist/chunk-36WRYYTE.js +3 -0
  12. package/dist/chunk-37TKC6MB.js +2 -0
  13. package/dist/{chunk-FAJQ7LWY.js → chunk-3AC56WAR.js} +2 -2
  14. package/dist/{chunk-JE3WZ6II.js → chunk-3NUZVLR7.js} +2 -2
  15. package/dist/{chunk-UZGZB3VB.js → chunk-3XFJUWJE.js} +2 -2
  16. package/dist/{chunk-OVTS4DKB.js → chunk-4AOOSCZ7.js} +2 -2
  17. package/dist/{chunk-LU3BMVH2.js → chunk-4IFISPQW.js} +2 -2
  18. package/dist/chunk-4NHWNAWQ.js +11 -0
  19. package/dist/chunk-4O52YNKL.js +5 -0
  20. package/dist/{chunk-HPJRBHVT.js → chunk-54K6556S.js} +2 -2
  21. package/dist/{chunk-HRWGYWRJ.js → chunk-57GCCPLS.js} +2 -2
  22. package/dist/{chunk-J77SU6VA.js → chunk-57KEZDPT.js} +2 -2
  23. package/dist/{chunk-OFBE4NGP.js → chunk-57KFVPVZ.js} +2 -2
  24. package/dist/{chunk-WOQBZPIF.js → chunk-5BDK6QC3.js} +2 -2
  25. package/dist/{chunk-7MGU3HPH.js → chunk-5IO2APSS.js} +2 -2
  26. package/dist/chunk-5NJPH3QZ.js +61 -0
  27. package/dist/{chunk-GW6Z3WGY.js → chunk-5WXOEJ4G.js} +2 -2
  28. package/dist/chunk-5XEVXVTK.js +3 -0
  29. package/dist/{chunk-RR7SX44N.js → chunk-6OVNYYY4.js} +2 -2
  30. package/dist/{chunk-ZV3JV5G5.js → chunk-6SDEQTVY.js} +2 -2
  31. package/dist/{chunk-EF2R3WNQ.js → chunk-6URCE5QY.js} +2 -2
  32. package/dist/{chunk-UCD3H3UZ.js → chunk-6ZV5EDUT.js} +2 -2
  33. package/dist/{chunk-C6SBF2WH.js → chunk-77GHPR2R.js} +2 -2
  34. package/dist/{chunk-YVCIMIOC.js → chunk-7R64XY4Y.js} +2 -2
  35. package/dist/{chunk-VXYS3FZD.js → chunk-7Z7HCZ7J.js} +2 -2
  36. package/dist/{chunk-CO5R3UNA.js → chunk-A67HT5FR.js} +2 -2
  37. package/dist/{chunk-UDS562V4.js → chunk-A7XQT7MH.js} +2 -2
  38. package/dist/{chunk-RDBI2RXU.js → chunk-ACZDU5GK.js} +2 -2
  39. package/dist/{chunk-FETNQCFO.js → chunk-AM5SUGHF.js} +2 -2
  40. package/dist/{chunk-NNOKTMZT.js → chunk-B2E3HZ2A.js} +2 -2
  41. package/dist/{chunk-CVYSU6BX.js → chunk-BH5CE4LN.js} +2 -2
  42. package/dist/chunk-BLKYYQ7C.js +543 -0
  43. package/dist/{chunk-4WKDMDEW.js → chunk-BX2U3QQV.js} +2 -2
  44. package/dist/{chunk-ZKX2FRS6.js → chunk-CANBLFVQ.js} +2 -2
  45. package/dist/{chunk-SMRBZ6EC.js → chunk-CCRZLRWJ.js} +2 -2
  46. package/dist/chunk-CDWSLAPN.js +21 -0
  47. package/dist/chunk-CIVYHK7U.js +22 -0
  48. package/dist/{chunk-L57ZKWVG.js → chunk-CMXW7MFV.js} +2 -2
  49. package/dist/{chunk-T3DGWPXM.js → chunk-CSZOQ7YO.js} +2 -2
  50. package/dist/{chunk-ZZXSWSN6.js → chunk-CWMHWD56.js} +2 -2
  51. package/dist/{chunk-6NW7MU72.js → chunk-CZEIHYMP.js} +2 -2
  52. package/dist/{chunk-DO6WQD2T.js → chunk-D62CTZX6.js} +2 -2
  53. package/dist/{chunk-XWUOUWYI.js → chunk-DFPAZXLU.js} +2 -2
  54. package/dist/{chunk-MOVBWNIP.js → chunk-DKJXK3HA.js} +2 -2
  55. package/dist/{chunk-XMQ23E27.js → chunk-DLC6JDN7.js} +2 -2
  56. package/dist/chunk-DUKHVPU5.js +4 -0
  57. package/dist/{chunk-ID63777H.js → chunk-DVYG3JTA.js} +2 -2
  58. package/dist/{chunk-NE6IU5ZD.js → chunk-EFFMFK7C.js} +2 -2
  59. package/dist/{chunk-I2T2LLK2.js → chunk-EM5UHLAM.js} +2 -2
  60. package/dist/chunk-EN4AHLL3.js +3 -0
  61. package/dist/chunk-EXMVF3JR.js +3 -0
  62. package/dist/{chunk-SWHMHUKF.js → chunk-FEBLLMTL.js} +2 -2
  63. package/dist/chunk-FIXYHQ3W.js +3 -0
  64. package/dist/{chunk-RKEJ6VTF.js → chunk-FLLXYUOL.js} +2 -2
  65. package/dist/{chunk-KWVHSKHK.js → chunk-FPDL2TUB.js} +2 -2
  66. package/dist/chunk-FQA3KIFX.js +17 -0
  67. package/dist/chunk-FWY2PRIF.js +3 -0
  68. package/dist/chunk-FY5V4V4F.js +2 -0
  69. package/dist/chunk-G2XUZCF2.js +88 -0
  70. package/dist/{chunk-QHRNXP3C.js → chunk-GXVDTHFC.js} +2 -2
  71. package/dist/{chunk-6MUIJMVL.js → chunk-H3CKAL6P.js} +2 -2
  72. package/dist/chunk-H5QXP63L.js +2 -0
  73. package/dist/{chunk-VUIYB2V3.js → chunk-HBQGKMM3.js} +2 -2
  74. package/dist/{chunk-PYAB5SM6.js → chunk-HBXZAGY6.js} +2 -2
  75. package/dist/{chunk-NNO6A2PO.js → chunk-HCMQZPEO.js} +2 -2
  76. package/dist/{chunk-Q65CQ4XL.js → chunk-HHBBGWES.js} +2 -2
  77. package/dist/{chunk-GTXSJDCO.js → chunk-HIEXRDJF.js} +2 -2
  78. package/dist/{chunk-4FC325IF.js → chunk-HYKSLTAR.js} +2 -2
  79. package/dist/{chunk-XLQ3GLWZ.js → chunk-I2KP4AGR.js} +2 -2
  80. package/dist/chunk-I5FCDTK2.js +2 -0
  81. package/dist/{chunk-QKPLA6IC.js → chunk-I645ZF75.js} +2 -2
  82. package/dist/{chunk-FDGD5AB5.js → chunk-IBM3F2BJ.js} +2 -2
  83. package/dist/{chunk-Q72QSKXC.js → chunk-IEL6Q5W3.js} +38 -38
  84. package/dist/{chunk-NCZUNH3E.js → chunk-IGQQUENU.js} +12 -12
  85. package/dist/chunk-IGYAZPRX.js +4 -0
  86. package/dist/chunk-IOVPAZWP.js +3 -0
  87. package/dist/{chunk-OL6KJP3N.js → chunk-IVJJNVSX.js} +2 -2
  88. package/dist/{chunk-AKB7V7TV.js → chunk-IWAMYGPN.js} +2 -2
  89. package/dist/chunk-IYBIBMPF.js +90 -0
  90. package/dist/{chunk-IOP6FWIM.js → chunk-J24VICI5.js} +2 -2
  91. package/dist/{chunk-C7QOQX32.js → chunk-JN5LIBT3.js} +2 -2
  92. package/dist/{chunk-O6QTXQPJ.js → chunk-JOALNFY3.js} +2 -2
  93. package/dist/{chunk-GCHRX4YW.js → chunk-JUO3Z644.js} +2 -2
  94. package/dist/{chunk-BJ6SQAEN.js → chunk-JXHLB7TP.js} +2 -2
  95. package/dist/{chunk-IJ4HMYBE.js → chunk-JYX5UZSZ.js} +2 -2
  96. package/dist/chunk-K2O7SBAU.js +2 -0
  97. package/dist/{chunk-OLF4MA5W.js → chunk-K5G7SPAG.js} +2 -2
  98. package/dist/{chunk-YSNONTJ2.js → chunk-KDYQQJ6X.js} +2 -2
  99. package/dist/{chunk-7NVGT435.js → chunk-KM4QRWI5.js} +2 -2
  100. package/dist/{chunk-HKQUXIFO.js → chunk-KNV5VFDV.js} +2 -2
  101. package/dist/chunk-L3YSDLNB.js +2 -0
  102. package/dist/{chunk-EZNMUY67.js → chunk-LAGDJXFY.js} +2 -2
  103. package/dist/{chunk-ENCCHKM6.js → chunk-LY2NB5XR.js} +4 -4
  104. package/dist/chunk-M4EVGA5S.js +14 -0
  105. package/dist/chunk-M7LAIM77.js +127 -0
  106. package/dist/{chunk-BVAJLC5A.js → chunk-MRGTCMDK.js} +2 -2
  107. package/dist/{chunk-OZYRSMSH.js → chunk-MT5W4DUG.js} +2 -2
  108. package/dist/{chunk-VE5AVNMP.js → chunk-MTMF4N7F.js} +2 -2
  109. package/dist/chunk-N3Q3AWGW.js +545 -0
  110. package/dist/{chunk-TXXOEMZJ.js → chunk-NDGTJHQN.js} +2 -2
  111. package/dist/chunk-NIO346UL.js +2 -0
  112. package/dist/chunk-NJA4MMBD.js +2 -0
  113. package/dist/{chunk-7FND7D7N.js → chunk-NK76RSB6.js} +2 -2
  114. package/dist/{chunk-H3LGFZVK.js → chunk-NTRW52UR.js} +2 -2
  115. package/dist/{chunk-JOIRNPPY.js → chunk-OJFLPVBP.js} +2 -2
  116. package/dist/{chunk-KMITESMT.js → chunk-OMBRP7BB.js} +2 -2
  117. package/dist/{chunk-UP3BUZR5.js → chunk-OVKZM2XI.js} +2 -2
  118. package/dist/{chunk-MVB3DAEY.js → chunk-PARCKE3Q.js} +2 -2
  119. package/dist/{chunk-CAUCPUOF.js → chunk-PFPHS4NO.js} +2 -2
  120. package/dist/chunk-PHPQ24UG.js +22 -0
  121. package/dist/chunk-PLZXWZHY.js +77 -0
  122. package/dist/{chunk-34WBMAYK.js → chunk-PNVZIJ57.js} +2 -2
  123. package/dist/{chunk-SYDJMPES.js → chunk-QKVTWODE.js} +2 -2
  124. package/dist/{chunk-FW53T7EB.js → chunk-QLTFXVUI.js} +2 -2
  125. package/dist/{chunk-PBI2LFKH.js → chunk-QMGWSEPL.js} +2 -2
  126. package/dist/{chunk-CQP3THUZ.js → chunk-QVHZB75Z.js} +2 -2
  127. package/dist/{chunk-6BQ3DSPK.js → chunk-QVWDQTMG.js} +2 -2
  128. package/dist/{chunk-ST7V3SKN.js → chunk-RCPZOPV6.js} +2 -2
  129. package/dist/chunk-RJWAB4VR.js +345 -0
  130. package/dist/chunk-RRPK327J.js +20 -0
  131. package/dist/chunk-RVYLJDXC.js +21 -0
  132. package/dist/chunk-RWKEXCHU.js +3 -0
  133. package/dist/{chunk-L4NRUAGJ.js → chunk-S5SKXCND.js} +2 -2
  134. package/dist/{chunk-RBAS5ZHI.js → chunk-S64NCE2Z.js} +2 -2
  135. package/dist/{chunk-WMPRTGH2.js → chunk-SF34QLK2.js} +2 -2
  136. package/dist/{chunk-ANFVSJWQ.js → chunk-SJZQ2PTZ.js} +2 -2
  137. package/dist/{chunk-4XTAUQFD.js → chunk-SRY26ITJ.js} +2 -2
  138. package/dist/chunk-SV2LEFVM.js +2 -0
  139. package/dist/{chunk-7XAN6GKB.js → chunk-T3YFIJ5P.js} +2 -2
  140. package/dist/chunk-T55YPJGB.js +3 -0
  141. package/dist/chunk-TAJ6UGCO.js +21 -0
  142. package/dist/{chunk-PIOMTC27.js → chunk-TUTSO7UZ.js} +2 -2
  143. package/dist/{chunk-FQKZWM4L.js → chunk-U24M5RQM.js} +5 -5
  144. package/dist/{chunk-XME3HPXZ.js → chunk-U2XX3BT4.js} +2 -2
  145. package/dist/{chunk-SZD2KF7Q.js → chunk-UWB5WMC2.js} +2 -2
  146. package/dist/{chunk-6CS3UQTN.js → chunk-VCL7FK3E.js} +2 -2
  147. package/dist/{chunk-N3IQCBCF.js → chunk-VCWAJPXQ.js} +2 -2
  148. package/dist/{chunk-LZYFLFEH.js → chunk-VG55NFXF.js} +2 -2
  149. package/dist/{chunk-PTAWHLVJ.js → chunk-VLTUX4IF.js} +2 -2
  150. package/dist/{chunk-JEJLSICM.js → chunk-VVCBMH5O.js} +2 -2
  151. package/dist/{chunk-JSOYNVWH.js → chunk-VYZQZ4ZN.js} +2 -2
  152. package/dist/chunk-W3FK73MD.js +8 -0
  153. package/dist/{chunk-UNBY47BC.js → chunk-W6C6QTXJ.js} +2 -2
  154. package/dist/chunk-WH5SYOMD.js +2 -0
  155. package/dist/chunk-WJOQC4P7.js +7 -0
  156. package/dist/chunk-WO47BIPY.js +3 -0
  157. package/dist/chunk-WOOTEWQT.js +239 -0
  158. package/dist/{chunk-UBGWN7I4.js → chunk-X5I2BQGX.js} +2 -2
  159. package/dist/{chunk-PX4RYAAK.js → chunk-XNUWRTYM.js} +2 -2
  160. package/dist/{chunk-ICFDQHAM.js → chunk-XUJM6474.js} +2 -2
  161. package/dist/chunk-XYLV727H.js +21 -0
  162. package/dist/{chunk-TRRC4ZJ7.js → chunk-YFQPWKHR.js} +2 -2
  163. package/dist/{chunk-NEDP5RFQ.js → chunk-YIOQJ45A.js} +2 -2
  164. package/dist/{chunk-Y6KHROC3.js → chunk-YXJ4IAHH.js} +2 -2
  165. package/dist/chunk-YYFV32WR.js +3 -0
  166. package/dist/{chunk-BH5F2Q4O.js → chunk-ZB3V5QM7.js} +2 -2
  167. package/dist/chunk-ZJZQ7Q2Q.js +3 -0
  168. package/dist/{chunk-EMNIHCRB.js → chunk-ZNQCR656.js} +2 -2
  169. package/dist/{chunk-TIIC3ZE7.js → chunk-ZOEDRCR4.js} +2 -2
  170. package/dist/cli-context-TSADTXLB.js +2 -0
  171. package/dist/cli-context-XEPPF4RX.js +3 -0
  172. package/dist/cli-program-KJGQEM72.js +7 -0
  173. package/dist/cli.js +1 -1
  174. package/dist/{code-DlqpBDd0.d.ts → code-CDe-mIjx.d.ts} +1 -1
  175. package/dist/code-viewer-YGDON6SY.js +12 -0
  176. package/dist/code-viewer-ZCTHXQ5C.js +11 -0
  177. package/dist/command-descriptors-5VAB2MZX.js +335 -0
  178. package/dist/command-descriptors-EAHKIRAG.js +337 -0
  179. package/dist/{config-types-BNoC96J3.d.ts → config-types-D6X5S68_.d.ts} +50 -0
  180. package/dist/{db-D7sauVFH.d.ts → db-DmRNdCtm.d.ts} +1 -1
  181. package/dist/direct-navigation-B3SGOOBW.js +2 -0
  182. package/dist/direct-navigation-ZL362KXF.js +3 -0
  183. package/dist/{graph-evidence-BIFqyisO.d.ts → graph-evidence-Bs54NWws.d.ts} +1 -1
  184. package/dist/{health-DJaZXg8I.d.ts → health-BnzbSLCE.d.ts} +1 -1
  185. package/dist/index.d.ts +2 -2
  186. package/dist/index.js +1 -1
  187. package/dist/invocation-command-descriptors-CSUGUHTT.js +2 -0
  188. package/dist/invocation-command-descriptors-PPVZOIE5.js +3 -0
  189. package/dist/output-continuation-command-FTVVBVSN.js +2 -0
  190. package/dist/output-continuation-command-ITPRC3YV.js +3 -0
  191. package/dist/project-reindex-7HZSLLLY.js +3 -0
  192. package/dist/project-reindex-NGM3DYBN.js +2 -0
  193. package/dist/queries/affected.d.ts +2 -2
  194. package/dist/queries/affected.js +1 -1
  195. package/dist/queries/anchors.d.ts +2 -2
  196. package/dist/queries/anchors.js +1 -1
  197. package/dist/queries/architecture.d.ts +2 -2
  198. package/dist/queries/architecture.js +1 -1
  199. package/dist/queries/bottlenecks.d.ts +2 -2
  200. package/dist/queries/bottlenecks.js +1 -1
  201. package/dist/queries/by-kind.d.ts +2 -2
  202. package/dist/queries/by-kind.js +1 -1
  203. package/dist/queries/call-graph.d.ts +2 -2
  204. package/dist/queries/call-graph.js +1 -1
  205. package/dist/queries/change-surface.d.ts +2 -2
  206. package/dist/queries/change-surface.js +1 -1
  207. package/dist/queries/cleanup-plan.d.ts +2 -2
  208. package/dist/queries/cleanup-plan.js +1 -1
  209. package/dist/queries/co-change.d.ts +2 -2
  210. package/dist/queries/co-change.js +1 -1
  211. package/dist/queries/code.d.ts +3 -3
  212. package/dist/queries/code.js +1 -1
  213. package/dist/queries/complexity-hotspots.d.ts +2 -2
  214. package/dist/queries/complexity-hotspots.js +1 -1
  215. package/dist/queries/complexity.d.ts +2 -2
  216. package/dist/queries/complexity.js +1 -1
  217. package/dist/queries/context.d.ts +2 -2
  218. package/dist/queries/context.js +1 -1
  219. package/dist/queries/convergence.d.ts +2 -2
  220. package/dist/queries/convergence.js +1 -1
  221. package/dist/queries/coupling.d.ts +2 -2
  222. package/dist/queries/coupling.js +1 -1
  223. package/dist/queries/cycles.d.ts +2 -2
  224. package/dist/queries/cycles.js +1 -1
  225. package/dist/queries/dataflow.d.ts +2 -2
  226. package/dist/queries/dataflow.js +1 -1
  227. package/dist/queries/dead.d.ts +2 -2
  228. package/dist/queries/dead.js +1 -1
  229. package/dist/queries/decorative-checkers.d.ts +2 -2
  230. package/dist/queries/decorative-checkers.js +1 -1
  231. package/dist/queries/deep-chains.d.ts +2 -2
  232. package/dist/queries/deep-chains.js +1 -1
  233. package/dist/queries/dependence-slice.d.ts +3 -3
  234. package/dist/queries/dependence-slice.js +1 -1
  235. package/dist/queries/dependency-depth.d.ts +2 -2
  236. package/dist/queries/dependency-depth.js +1 -1
  237. package/dist/queries/deps.d.ts +2 -2
  238. package/dist/queries/deps.js +1 -1
  239. package/dist/queries/diff-impact.d.ts +2 -2
  240. package/dist/queries/diff-impact.js +1 -1
  241. package/dist/queries/doc-drift.d.ts +2 -2
  242. package/dist/queries/doc-drift.js +1 -1
  243. package/dist/queries/drift.d.ts +2 -2
  244. package/dist/queries/drift.js +1 -1
  245. package/dist/queries/duplicate-bodies.d.ts +2 -2
  246. package/dist/queries/duplicate-bodies.js +1 -1
  247. package/dist/queries/entry-map.d.ts +2 -2
  248. package/dist/queries/entry-map.js +1 -1
  249. package/dist/queries/evidence.d.ts +3 -3
  250. package/dist/queries/evidence.js +1 -1
  251. package/dist/queries/extract-candidates.d.ts +2 -2
  252. package/dist/queries/extract-candidates.js +1 -1
  253. package/dist/queries/fan.d.ts +2 -2
  254. package/dist/queries/fan.js +1 -1
  255. package/dist/queries/files.d.ts +2 -2
  256. package/dist/queries/files.js +1 -1
  257. package/dist/queries/health.d.ts +3 -3
  258. package/dist/queries/health.js +1 -1
  259. package/dist/queries/hierarchy.d.ts +2 -2
  260. package/dist/queries/hierarchy.js +1 -1
  261. package/dist/queries/hotspots.d.ts +2 -2
  262. package/dist/queries/hotspots.js +1 -1
  263. package/dist/queries/imports.d.ts +2 -2
  264. package/dist/queries/imports.js +1 -1
  265. package/dist/queries/incomplete-migration.d.ts +2 -2
  266. package/dist/queries/incomplete-migration.js +1 -1
  267. package/dist/queries/index.d.ts +5 -5
  268. package/dist/queries/index.js +1 -1
  269. package/dist/queries/isolated.d.ts +2 -2
  270. package/dist/queries/isolated.js +1 -1
  271. package/dist/queries/locality-candidates.d.ts +2 -2
  272. package/dist/queries/locality-candidates.js +1 -1
  273. package/dist/queries/members.d.ts +2 -2
  274. package/dist/queries/members.js +1 -1
  275. package/dist/queries/methods.d.ts +2 -2
  276. package/dist/queries/methods.js +1 -1
  277. package/dist/queries/not-implemented.d.ts +2 -2
  278. package/dist/queries/not-implemented.js +1 -1
  279. package/dist/queries/outline.d.ts +2 -2
  280. package/dist/queries/outline.js +1 -1
  281. package/dist/queries/passthrough-candidates.d.ts +2 -2
  282. package/dist/queries/passthrough-candidates.js +1 -1
  283. package/dist/queries/plan-context.d.ts +2 -2
  284. package/dist/queries/plan-context.js +1 -1
  285. package/dist/queries/react-component-duplicates.d.ts +2 -2
  286. package/dist/queries/react-component-duplicates.js +1 -1
  287. package/dist/queries/react-hook-candidates.d.ts +2 -2
  288. package/dist/queries/react-hook-candidates.js +1 -1
  289. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  290. package/dist/queries/react-large-component-pressure.js +1 -1
  291. package/dist/queries/recent-duplicates.d.ts +2 -2
  292. package/dist/queries/recent-duplicates.js +1 -1
  293. package/dist/queries/redundant-reexports.d.ts +2 -2
  294. package/dist/queries/redundant-reexports.js +1 -1
  295. package/dist/queries/reference-neighborhood.d.ts +2 -2
  296. package/dist/queries/reference-neighborhood.js +1 -1
  297. package/dist/queries/reference-reachability.d.ts +2 -2
  298. package/dist/queries/reference-reachability.js +1 -1
  299. package/dist/queries/refs.d.ts +2 -2
  300. package/dist/queries/refs.js +1 -1
  301. package/dist/queries/self-audit.d.ts +2 -2
  302. package/dist/queries/self-audit.js +1 -1
  303. package/dist/queries/similar-chains.d.ts +2 -2
  304. package/dist/queries/similar-chains.js +1 -1
  305. package/dist/queries/similar-files.d.ts +2 -2
  306. package/dist/queries/similar-files.js +1 -1
  307. package/dist/queries/similar-signatures.d.ts +2 -2
  308. package/dist/queries/similar-signatures.js +1 -1
  309. package/dist/queries/similar.d.ts +2 -2
  310. package/dist/queries/similar.js +1 -1
  311. package/dist/queries/slice.d.ts +2 -2
  312. package/dist/queries/slice.js +1 -1
  313. package/dist/queries/source-inspection.d.ts +4 -4
  314. package/dist/queries/source-inspection.js +1 -1
  315. package/dist/queries/source-search.d.ts +2 -2
  316. package/dist/queries/source-search.js +1 -1
  317. package/dist/queries/stale-abstractions.d.ts +2 -2
  318. package/dist/queries/stale-abstractions.js +1 -1
  319. package/dist/queries/stats.d.ts +2 -2
  320. package/dist/queries/surface.d.ts +2 -2
  321. package/dist/queries/surface.js +1 -1
  322. package/dist/queries/symbols.d.ts +2 -2
  323. package/dist/queries/symbols.js +1 -1
  324. package/dist/queries/system-map.d.ts +2 -2
  325. package/dist/queries/system-map.js +1 -1
  326. package/dist/queries/system.d.ts +2 -2
  327. package/dist/queries/system.js +1 -1
  328. package/dist/queries/test-quality.d.ts +2 -2
  329. package/dist/queries/test-quality.js +1 -1
  330. package/dist/queries/trace.d.ts +2 -2
  331. package/dist/queries/trace.js +1 -1
  332. package/dist/queries/twin-ab.d.ts +2 -2
  333. package/dist/queries/twin-ab.js +1 -1
  334. package/dist/queries/twin-drift.d.ts +2 -2
  335. package/dist/queries/twin-drift.js +1 -1
  336. package/dist/queries/unused-imports.d.ts +2 -2
  337. package/dist/queries/unused-imports.js +1 -1
  338. package/dist/queries/unused-params.d.ts +2 -2
  339. package/dist/queries/unused-params.js +1 -1
  340. package/dist/queries/value-flow.d.ts +3 -3
  341. package/dist/queries/value-flow.js +1 -1
  342. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  343. package/dist/queries/vue-component-duplicates.js +1 -1
  344. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  345. package/dist/queries/vue-composable-candidates.js +1 -1
  346. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  347. package/dist/queries/vue-large-view-pressure.js +1 -1
  348. package/dist/queries/wrapper-candidates.d.ts +2 -2
  349. package/dist/queries/wrapper-candidates.js +1 -1
  350. package/dist/reindex-worker.js +1 -1
  351. package/dist/reindex.d.ts +3 -3
  352. package/dist/reindex.js +31 -31
  353. package/dist/runtime.d.ts +24 -4
  354. package/dist/runtime.js +3 -3
  355. package/dist/rust-semantic-session-server.js +1 -1
  356. package/dist/rust-semantic-session-worker.js +1 -1
  357. package/dist/rust-semantic-worker.js +1 -1
  358. package/dist/{scip-cli-B7N3haxa.d.ts → scip-cli-BRFKkHQn.d.ts} +1 -1
  359. package/dist/sentinel-ensure-command-KYYULCFU.js +2 -0
  360. package/dist/sentinel-ensure-command-RIZA3RY7.js +3 -0
  361. package/dist/sentinel-hook.js +39 -0
  362. package/dist/sentinel-worker.js +16 -0
  363. package/dist/typescript-mailbox-worker.js +1 -1
  364. package/dist/watch-server.js +6 -6
  365. package/docs/COMMAND_REFERENCE.md +5 -3
  366. package/docs/schemas/project-config.schema.json +159 -0
  367. package/package.json +9 -5
  368. package/skills/codebaseiq/SKILL.md +1 -1
  369. package/skills/concrete-plan/SKILL.md +1 -1
  370. package/ui/view/api.js +450 -0
  371. package/ui/view/app.js +394 -0
  372. package/ui/view/builder.js +323 -0
  373. package/ui/view/file-panel.js +170 -0
  374. package/ui/view/focus.js +379 -0
  375. package/ui/view/index.html +54 -0
  376. package/ui/view/map.js +424 -0
  377. package/ui/view/styles.css +1125 -0
  378. package/dist/chunk-2X7V4HS4.js +0 -88
  379. package/dist/chunk-3IER7Q6H.js +0 -12
  380. package/dist/chunk-3JSXXYTZ.js +0 -345
  381. package/dist/chunk-476NR5B7.js +0 -2
  382. package/dist/chunk-5VKBFZZU.js +0 -3
  383. package/dist/chunk-ADTBPVUZ.js +0 -21
  384. package/dist/chunk-BFFZDZQV.js +0 -2
  385. package/dist/chunk-BMYOV5GP.js +0 -77
  386. package/dist/chunk-C74PPYLA.js +0 -3
  387. package/dist/chunk-CWONGW6P.js +0 -3
  388. package/dist/chunk-DDZ7VHWV.js +0 -20
  389. package/dist/chunk-DR2LURYU.js +0 -3
  390. package/dist/chunk-ECQBG7PW.js +0 -564
  391. package/dist/chunk-FM5BPL4V.js +0 -60
  392. package/dist/chunk-G6XFR4ZL.js +0 -4
  393. package/dist/chunk-GTIYTDRE.js +0 -562
  394. package/dist/chunk-HOA5YGOH.js +0 -3
  395. package/dist/chunk-KUW32IRO.js +0 -2
  396. package/dist/chunk-LTA3BRZX.js +0 -2
  397. package/dist/chunk-NAUD7LCA.js +0 -2
  398. package/dist/chunk-OGTFJ3XD.js +0 -2
  399. package/dist/chunk-Q5ELPRKQ.js +0 -2
  400. package/dist/chunk-QCN62RTF.js +0 -3
  401. package/dist/chunk-QW7EP6WI.js +0 -21
  402. package/dist/chunk-RU65DDUP.js +0 -215
  403. package/dist/chunk-SELM5MER.js +0 -2
  404. package/dist/chunk-SNNWPCN7.js +0 -4
  405. package/dist/chunk-TFZB6XTM.js +0 -239
  406. package/dist/chunk-UXM43C7T.js +0 -3
  407. package/dist/chunk-VFY6Y2H6.js +0 -61
  408. package/dist/chunk-WE5RZHZ7.js +0 -5
  409. package/dist/chunk-Z54RD7VL.js +0 -3
  410. package/dist/cli-context-3SNLDYBM.js +0 -3
  411. package/dist/cli-context-T3B7W6GG.js +0 -2
  412. package/dist/cli-program-YNOXO72B.js +0 -7
  413. package/dist/command-descriptors-6AOUKWW7.js +0 -346
  414. package/dist/command-descriptors-ZFKJSRUP.js +0 -344
  415. package/dist/direct-navigation-DP4LVMRX.js +0 -3
  416. package/dist/direct-navigation-FLUS3BT6.js +0 -2
  417. package/dist/invocation-command-descriptors-QT2JMY5J.js +0 -3
  418. package/dist/invocation-command-descriptors-YN4QJEAX.js +0 -2
  419. package/dist/output-continuation-command-2V2SL4TD.js +0 -2
  420. package/dist/output-continuation-command-65J5IP3O.js +0 -3
  421. package/dist/project-reindex-5JOKXAXT.js +0 -2
  422. package/dist/project-reindex-UQBIKO4M.js +0 -3
@@ -0,0 +1,21 @@
1
+ import{a as Ee,b as We,e as Xt}from"./chunk-2VKB5CMA.js";import{a as _,b as Ht,i as I,j as ie,l as Ce,o as Ae,r as F,s as G}from"./chunk-ACZDU5GK.js";import{a as Wt,b as Vt,c as te,d as re}from"./chunk-6URCE5QY.js";import{C as Ut,D as K,F as Ge,G as Jt,J as Yt,K as Ve,L as Te,M as Qe,P as He,T as oe,V as Kt,a as v,b as J,c as R,f as S,g as E,h as b,ha as Ue,ia as Je,l as zt,m as Y,q as Qt,v as Pe,w as j,x as ne}from"./chunk-4O52YNKL.js";var Zt=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"],So=["entry-surface","generated-code","compatibility-shim","reflection-or-registration","test-fixture","intentional-twin","historical-coupling-ended","detector-counterexample"];var Ye=2,z=3;var Ke=new Set(Zt);function ke(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(a){return{kind:"malformed",reason:`invalid JSON: ${Pn(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!==Ye&&r!==z)return{kind:"unsupported",version:r,direction:r<Ye?"older":"future"};let n=xn(t,r);if(n)return{kind:"malformed",reason:n};let i=t,o={metadata:i,capabilities:In(i)};return r===Ye?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function vo(e){return e.kind==="legacy"||e.kind==="supported"?e.metadata:null}function er(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 In(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 xn(e,t){if(e.status!=="complete"&&e.status!=="partial")return"status must be complete or partial";if(e.updatedAt!==void 0&&!Ht(e.updatedAt))return"updatedAt must be a valid timestamp";for(let r of["requestedLanguages","indexedLanguages"])if(e[r]!==void 0&&!wn(e[r]))return`${r} must contain unique supported languages`;return e.skipped!==void 0&&!Rn(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&&!vn(e.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":t===z&&e.typescriptProjectShards!==void 0&&!En(e.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function Eo(e){return e.version===z&&e.sqliteLayoutVersion===1}function wn(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string"&&Ke.has(t))?!1:new Set(e).size===e.length}function Rn(e){return Array.isArray(e)&&e.every(t=>_(t)&&typeof t.language=="string"&&Ke.has(t.language)&&typeof t.reason=="string")}function vn(e){return _(e)&&Object.entries(e).every(([t,r])=>Ke.has(t)&&_(r))}function En(e){return _(e)&&Object.values(e).every(t=>_(t)&&Array.isArray(t.files)&&t.files.every(Qt))}function Pn(e){return e instanceof Error?e.message:String(e)}import Qn from"better-sqlite3";import{createHash as kn,randomUUID as Dn}from"crypto";import{existsSync as W,mkdirSync as Ln,readdirSync as On,rmSync as ar,statSync as sr}from"fs";import{basename as Mn,dirname as se,join as x}from"path";import{join as Gn}from"path";function De(e,t){return e.reason instanceof Error?e.reason:new Error(t)}function tr(e,t){if(e?.aborted)throw De(e,t)}var Tn=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 rr(e,t={}){return T(Gn(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=nr(e);if(a)return ir(a);let s=o-i();if(s<=0)return null;Cn(Math.min(n,s))}while(i()<=o);return null}async function Do(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??re,o=i()+r;do{tr(t.signal,"Lock acquisition was aborted.");let a=nr(e);if(a)return ir(a);let s=o-i();if(s<=0)return null;await An(Math.min(n,s),t.signal)}while(i()<=o);return null}function nr(e){let t=Ce(e,{kind:"generic",parseLegacy:Tn});return t.kind==="acquired"?t.lock:null}function ir(e){return{release:()=>{e.release()}}}function Cn(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}function An(e,t){return t?.aborted?Promise.reject(De(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?De(t,"Lock acquisition was aborted."):new Error("Lock acquisition was aborted."))};t?.addEventListener("abort",o,{once:!0})})}var V=1,tt=1,ce=".codebaseiq-generations",Le="manifest.json",cr="readers",_n="gc.lock",jn=128,ae=new Map,dr={pid:process.pid,now:()=>new Date,randomToken:()=>Dn(),isProcessAlive:ie,readProcessIdentity:te,resolveImmutableGeneration:ur};function m(e){return x(se(e),ce)}function de(e){return x(m(e),_n)}function lr(e,t=dr){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:nt(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),cr);Ln(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,ar(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 Fn(e,n.identity)}function Fn(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:pr(e,n.currentGeneration),release(){}}}finally{r.release()}}function rt(e,t,r=dr,n={}){let i=x(m(e),cr);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 On(i,{withFileTypes:!0})){if(!d.isFile()||!d.name.endsWith(".json"))continue;let l=x(i,d.name),p;try{p=Nn(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(!qn(p,r)){n.removeStale!==!1&&(ar(l,{force:!0}),s+=1);continue}a+=1,o.add(p.generationIdentity)}return{protectedGenerations:o,activeLeases:a,staleLeasesRemoved:s,malformedLeases:c}}function Nn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=t.processIdentity===void 0?null:Wt(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 qn(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let r=t.readProcessIdentity(e.pid);return r===null||Vt(e.processIdentity,r)}function C(e){try{let t=JSON.parse(b(x(m(e),"state.json"),"SQLite generation state"));return $n(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,Le),"SQLite generation manifest"));return Bn(r,t)?r:null}catch{return null}}function nt(e){let t=C(e.dbPath);if(t){let r=ur(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 pr(e,t?.currentGeneration)}function Wo(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 fr(e,n)}catch{return null}}function N(e){return er(ke(e))??e}function ur(e,t){try{let r=x(m(e.dbPath),t),n=le(e.dbPath,t);if(!n)return null;let i=Xe(r,n.database),o=n.index?Xe(r,n.index):void 0,a=n.metadata?Xe(r,n.metadata):void 0;return!Ze(i,n.database)||n.index&&(!o||!Ze(o,n.index))||n.metadata&&(!a||!Ze(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 pr(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??fr(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:n,metadataRaw:i},source:"legacy",databaseFileIdentity:r}}function fr(e,t){let r=kn("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=sr(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function Xe(e,t){if(Mn(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 Ze(e,t){if(!W(e))return!1;let r=or(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=or(e);if(!o||o.identity!==r.identity||i!==t.sha256)return!1;for(ae.set(n,!0);ae.size>jn;){let a=ae.keys().next().value;if(a===void 0)break;ae.delete(a)}return!0}function or(e){let t=sr(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function Bn(e,t){return e.version===tt&&e.identity===t&&et(e.database)&&(e.index===void 0||et(e.index))&&(e.metadata===void 0||et(e.metadata))}function et(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 $n(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")&&zn(e.stableMirrors)&&Wn(e.previousGeneration)&&Vn(e.publication)}function zn(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 Wn(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 Vn(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 Hn=["busy_timeout = 5000","query_only = ON","temp_store = MEMORY","cache_size = -64000","mmap_size = 268435456"],it=class{constructor(t,r){this.connection=t;this.releaseGenerationReader=r}connection;releaseGenerationReader;active=!0;initialize(t){try{for(let r of Hn)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}},Un=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".codebaseiq-cache","__pycache__",".venv","venv"],gr=class{db;config;generation;pathFilter;connection;connectionOwnership;statementCache=new Map;closed=!1;constructor(t,r){this.config=t,this.pathFilter=r??null;let n=Xn(t),i=new it(n.db,n.release);try{i.initialize(Kn),this.generation=n.generation,this.connection=n.db,this.connectionOwnership=i,this.db=Jn(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=>Un.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{Xt(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 Jn(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 Yn(r)}})}function Yn(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 Kn(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)Ge(n.relative_path)}function Xn(e){for(let t=0;t<4;t+=1){let r=lr(e),n=r.generation,i;try{i=new Qn(Ee(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=nt(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 ln,randomUUID as io}from"crypto";import{existsSync as B,lstatSync as At,mkdirSync as ee,readdirSync as un,realpathSync as pn,renameSync as U,rmSync as q,statSync as $e}from"fs";import{dirname as kt,join as u,resolve as we}from"path";import{setTimeout as oo}from"timers/promises";import{pathToFileURL as an}from"url";import{deserializeSCIP as fn}from"@c4312/scip";import ao from"better-sqlite3";import{execFileSync as Zn}from"child_process";import{existsSync as ei,readdirSync as yr}from"fs";import{extname as hr,join as Sr}from"path";var br=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),ti=[{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 ot(e){let t=[],r=ri(e),n=ai(e);for(let i of ti){if(ni(e,i.files)){t.push(i.language);continue}if(ii(r,i.globs)){t.push(i.language);continue}ci(n,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&mr(t,"javascript"),t.includes("cpp")&&!n.has(".c")&&mr(t,"c"),t}function ri(e){try{return yr(e)}catch{return[]}}function ni(e,t){return t?.length?t.some(r=>ei(Sr(e,r))):!1}function ii(e,t){return t?.length?e.some(r=>t.some(n=>oi(r,n))):!1}function oi(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 ai(e){let t=si(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=yr(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=Sr(i,a.name);if(a.isDirectory()){br.has(a.name)||n.push(s);continue}let c=hr(a.name).toLowerCase();c&&r.add(c)}}return r}function si(e){try{let t=Zn("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=>br.has(o)))continue;let i=hr(n).toLowerCase();i&&r.add(i)}return r}catch{return null}}function ci(e,t){return t?.length?t.some(r=>e.has(r)):!1}function mr(e,t){let r=e.indexOf(t);r!==-1&&e.splice(r,1)}import{lstatSync as wi,readdirSync as Ri}from"fs";import{join as vi,relative as Ei,resolve as gt,sep as Pi}from"path";import{createHash as di}from"crypto";import{existsSync as pe,mkdirSync as li,readdirSync as Ir,renameSync as ui,rmSync as xr,writeFileSync as pi}from"fs";import{join as M}from"path";import{create as Rr,fromBinary as vr,toBinary as fi}from"@bufbuild/protobuf";import{deserializeSCIP as Oe,DocumentSchema as st,IndexSchema as Er,serializeSCIP as Pr}from"@c4312/scip";var Me=1,fe="typescript-scip-fragments";function da(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=vr(st,o.bytes);if(s.relativePath!==a)throw new Error(`TypeScript fragment path mismatch: expected ${a}, got ${s.relativePath}`);r.push(s)}let n=Pr(Rr(Er,{documents:r,externalSymbols:[]})),i=Oe(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 gi(e){let t=Oe(e.indexBytes);Mr(t.metadata,_r(e)),Or(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=fi(st,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(Ar(e.cacheDir,{relativePath:a,bytes:s,occurrences:o.occurrences.length,symbols:o.symbols.length,referenceFragments:[]},c))}let i=kr(e,n);return Dr(e.cacheDir,i),i}function la(e){let t=ge(e.cacheDir);if(!pe(dt(t,e.generationIdentity)))return gi(e);let r=Gr({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 ua(e){let t=Gr({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,Ar(e.cacheDir,o,s))}if(n.size===0)throw new Error("TypeScript fragment generation requires at least one replacement");let i=kr(e,[...r.values()]);return Dr(e.cacheDir,i),i}function Gr(e){let t=ge(e.cacheDir),r=dt(t,e.generationIdentity),n;try{n=ct(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 Tr(e){let t=Cr(e);return at(t.baseIndex,t.completeDocuments,"assembled")}function pa(e){let t=Cr(e);return mi(t.deletedAffectedPaths),{completeIndexBytes:at(t.baseIndex,t.completeDocuments,"assembled"),affectedIndexBytes:at(t.baseIndex,t.affectedDocuments,"affected")}}function Cr(e){let t=Oe(e.baseIndexBytes);Mr(t.metadata,_r(e)),Or(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=vr(st,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 at(e,t,r){let n=Pr(Rr(Er,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=Oe(n);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${r} TypeScript SCIP index failed structural verification`);return n}function mi(e){if(e.length>0)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${e[0]}`)}function fa(e,t){let r=ge(e);if(!pe(r.generationDir))return;let n=new Set(t.map(a=>Lr(a))),i=Ir(r.generationDir).filter(a=>a.endsWith(".json")),o=new Set;for(let a of i.filter(s=>n.has(s))){let s=ct(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)||xr(M(r.generationDir,a),{force:!0});if(pe(r.blobDir))for(let a of Ir(r.blobDir))o.has(a)||xr(M(r.blobDir,a),{force:!0})}function Ar(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);li(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`;pi(c,i),ui(c,s)}return{relativePath:n,blobHash:o,byteLength:i.byteLength,documentIdentity:r}}function kr(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:Me,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),documents:r}}function Dr(e,t){let r=ge(e),n=dt(r,t.generationIdentity);if(pe(n)){let i=ct(E(n,{maxBytes:v,inputKind:"TypeScript fragment manifest"}));if(wr(i)!==wr(t))throw new Error(`TypeScript fragment generation is immutable: ${t.generationIdentity}`);return}F(n,t,{spacing:2,trailingNewline:!0})}function wr(e){return H(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,documents:e.documents}))}function ct(e){let t=JSON.parse(e);if(t.version!==Me||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 dt(e,t){return M(e.generationDir,Lr(t))}function Lr(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${H(e)}.json`}function Or(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function Mr(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 _r(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 di("sha256").update(e).digest("hex")}import{createHash as yi}from"crypto";import{existsSync as me,mkdirSync as hi,readdirSync as lt,renameSync as Si,rmSync as jr,writeFileSync as bi}from"fs";import{join as P}from"path";var _e=1,xa=64*1024*1024,he="typescript-scip-overlays";function wa(e){let t=Nr(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=ft(o.relativePath);if(n.has(a))throw new Error(`duplicate TypeScript overlay: ${a}`);n.add(a),r.set(a,Ii(e.cacheDir,o))}if(n.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:_e,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 xi(e.cacheDir,i),i}function Ra(e){let t=Nr(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 Tr({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:r})}function va(e,t){let r=Se(e),n=P(r,"generations");if(!me(n))return;let i=new Set(t.map(pt)),o=new Set;for(let s of lt(n).filter(c=>i.has(c))){let c=ut(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 lt(n))i.has(s)||jr(P(n,s),{force:!0});let a=P(r,"blobs");if(me(a))for(let s of lt(a))o.has(s)||jr(P(a,s),{force:!0})}function Nr(e,t){let r=P(Se(e),"generations",pt(t));if(!me(r))return null;let n=ut(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 Ii(e,t){let r=ft(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");hi(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`;bi(s,n),Si(s,a)}return{relativePath:r,blobHash:i,byteLength:n.byteLength}}function xi(e,t){let r=P(Se(e),"generations",pt(t.generationIdentity));if(me(r)){let n=ut(E(r,{maxBytes:v,inputKind:"TypeScript overlay manifest"}));if(Fr(n)!==Fr(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}F(r,t,{spacing:2,trailingNewline:!0})}function ut(e){let t=JSON.parse(e);if(t.version!==_e||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(ft(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 pt(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${ye(e)}.json`}function Fr(e){return ye(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function ft(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 yi("sha256").update(e).digest("hex")}var be=1,mt="language-indexes",qr=["index.db","index.scip","meta.json"],Br=[mt,fe,he];function je(e){let t=[];for(let r of qr)Gi(e,r),t.push(r);for(let r of Br)$r(e,r,t);return{version:be,files:t.sort()}}function Fe(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(!qr.includes(e)&&!Br.includes(r))throw new Error(`index artifact path is not shareable: ${e}`);return e}function A(e,t){let r=Fe(t),n=gt(e),i=gt(n,...r.split("/"));if(i!==n&&!i.startsWith(`${n}${Pi}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function $r(e,t,r){let n=vi(e,t),i;try{i=Ri(n,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let a=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${a}`);o.isDirectory()?$r(e,a,r):o.isFile()&&r.push(Fe(a))}}function Gi(e,t){let r=A(e,t),n;try{n=wi(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(Ei(gt(e),r).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}import{writeFileSync as ht}from"fs";import{create as X}from"@bufbuild/protobuf";import{deserializeSCIP as St,serializeSCIP as bt,DocumentSchema as Oi,IndexSchema as Wr,MetadataSchema as Vr,SymbolInformationSchema as Mi}from"@c4312/scip";import{writeFileSync as Ti}from"fs";import{create as zr}from"@bufbuild/protobuf";import{deserializeSCIP as Ci,DocumentSchema as Ai,IndexSchema as ki,serializeSCIP as Di,SymbolRole as Li}from"@c4312/scip";function _a(e){let t;try{t=Ci(S(e,{inputKind:"SCIP sanitization input",maxBytes:R}))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let r=yt(t);return r.touchedDocuments>0&&Ti(e,Buffer.from(Di(r.index))),{removedDefinitionOccurrences:r.removedDefinitionOccurrences,touchedDocuments:r.touchedDocuments}}function yt(e){let t=new Set,r=new Map;for(let a of e.documents){r.set(a,Ge(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&Li.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(zr(Ai,{language:a.language,relativePath:s,occurrences:c,symbols:a.symbols,text:a.text,positionEncoding:a.positionEncoding}))}return{index:i===0?e:zr(ki,{metadata:e.metadata,documents:o,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:i}}function Qr(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=ji(e),r=Fi(e.flatMap(i=>i.documents??[])),n=Ur(e.flatMap(i=>i.externalSymbols??[]));return X(Wr,{metadata:t,documents:r,externalSymbols:n})}function Wa(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>St(S(i,{inputKind:"SCIP merge input",maxBytes:R}))),n=Qr(r);return ht(t,Buffer.from(bt(n))),{documentCount:n.documents.length,externalSymbolCount:n.externalSymbols.length,inputCount:e.length}}function Va(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>St(S(i,{inputKind:"SCIP merge input",maxBytes:R}))),n=yt(Qr(r));return ht(t,Buffer.from(bt(n.index))),{documentCount:n.index.documents.length,externalSymbolCount:n.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function _i(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(Wr,{metadata:X(Vr,{...n,projectRoot:r}),documents:e.documents,externalSymbols:e.externalSymbols})}function Hr(e,t,r){let n=St(S(e,{inputKind:"SCIP normalization input",maxBytes:R})),i=_i(n,t,r);ht(e,Buffer.from(bt(i)))}function ji(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&&Ut(r);return n===r?t:X(Vr,{...t,projectRoot:n})}function Fi(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(Oi,{language:n.language||r.language,relativePath:n.relativePath||r.relativePath,occurrences:Ni([...n.occurrences,...r.occurrences]),symbols:Ur([...n.symbols,...r.symbols]),text:Bi(n.text,r.text),positionEncoding:n.positionEncoding||r.positionEncoding}))}return[...t.values()]}function Ni(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 Ur(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(Mi,{symbol:n.symbol,documentation:$i([...n.documentation,...r.documentation]),relationships:qi([...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 qi(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 Bi(e,t){return e?t?e.length>=t.length?e:t:e:t}function $i(e){return[...new Set(e)]}import{createHash as Et}from"crypto";import{closeSync as zi,existsSync as g,mkdirSync as Wi,openSync as Vi,readSync as Qi,readdirSync as Pt,renameSync as Rt,rmSync as Ie,statSync as Z}from"fs";import{basename as Xr,dirname as k,join as f,relative as Jr}from"path";var vt=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function Zr(e){let t=m(e.outputDb),r=Ki(e);e.onStage?.("after-recovery-retained");let n=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=Ct({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||wt(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),wt(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),wt(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let c=i.identity,d={...a,stableMirrors:Tt(e.outputDb,e.outputScip)};G(f(t,"state.json"),d,{spacing:2,trailingNewline:!0});let l=en(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 Hi(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)?Zi(r,e,t):void 0;if(s&&!ue(a,s))return null;let c=Ct({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:Tt(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 is(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=Ct({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?nn(e,n.currentGeneration):void 0,s={version:V,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:Tt(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}),en(e,{now:r}),s}function en(e,t={}){let r=Ui(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=tn(e),c=rt(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,ze)=>w+ze.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 Yr(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{Yr(e,s)}catch{}return s}finally{o.release()}}function os(e){let t=m(e);if(!g(t))return{state:"absent",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:{...vt},reason:"local immutable generation store does not exist"};let r=Ji(e),n=r?.limits??{...vt},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=tn(e),a=C(e),s=rt(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 Ui(e={}){let t={...vt,...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 tn(e){let t=m(e);return g(t)?Pt(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):rn(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 rn(e){let t=0;for(let r of Pt(e,{withFileTypes:!0})){let n=f(e,r.name);r.isDirectory()?t+=rn(n):r.isFile()&&(t+=Z(n).size)}return t}function Yr(e,t){F(f(m(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function Ji(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 Gt(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?Yi(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 Yi(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")))||!Kr(e,r.database))return!1;let i=f(k(e),"index.scip");if(r.index&&!Kr(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 Kr(e,t){return g(e)&&Z(e).isFile()&&Z(e).size===t.size}function Ki(e){let t=Hi(e.outputDb,e.outputScip,e.metaPath);return t?nn(e.outputDb,t.currentGeneration):void 0}function Tt(e,t){return{databaseFileIdentity:O(e),...g(t)?{indexFileIdentity:O(t)}:{}}}function nn(e,t){let r=f(m(e),t),n=f(r,Xr(e)),i=f(r,"meta.json");return{generationIdentity:t,databasePath:Jr(k(e),n),...g(i)?{metadataPath:Jr(k(e),i)}:{}}}function Xi(e){if(g(e)){for(let t of Pt(e,{withFileTypes:!0}))if(t.isDirectory()&&t.name.endsWith(".tmp"))try{Ie(f(e,t.name),{recursive:!0,force:!0})}catch{}}}function Zi(e,t,r=f(k(t),"index.scip")){let n=Et("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(Ne(t)),g(r)&&n.update(`\0${Ne(r)}`),g(e)&&n.update(`\0${N(b(e,"reindex metadata"))}`),n.digest("hex")}function Ct(e){let t=It(e.databasePath),r=e.indexPath?It(e.indexPath):void 0,n=e.metadataPath?It(e.metadataPath):void 0,i=e.forcedIdentity??eo(t,r,e.metadataPath),o=f(e.generationRoot,i),a=f(o,Le);if(g(a)){let d=ue(e.generationRoot,i);if(d&&on(o,d.database,t)&&ro(o,d.index,r)&&no(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=[Pe(e.generationRoot)];Xi(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;Ie(c,{recursive:!0,force:!0}),Wi(c,{recursive:!0});try{s.push(xt(e.databasePath,f(c,t.file))),r&&e.indexPath&&s.push(xt(e.indexPath,f(c,r.file))),n&&e.metadataPath&&s.push(xt(e.metadataPath,f(c,n.file)));let d=G(f(c,Le),{version:tt,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(()=>Rt(c,o)),s.push(j(e.generationRoot))}finally{try{Ie(c,{recursive:!0,force:!0})}catch{}}return{identity:i,directorySync:ne(...s)}}function eo(e,t,r){let n=Et("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 It(e){return{file:Xr(e),size:Z(e).size,sha256:Ne(e)}}function Ne(e){let t=Et("sha256"),r=Vi(e,"r"),n=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=to(r,n);if(i===0)break;t.update(n.subarray(0,i))}}finally{zi(r)}return t.digest("hex")}function to(e,t){let r=0;for(;r<t.length;){let n=Qi(e,t,r,t.length-r,null);if(r+=n,n===0)break}return r}function xt(e,t){return Ae(e,t,{mode:292})}function on(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&&Ne(n)===t.sha256}function ro(e,t,r){return!t||!r?t===r:on(e,t,r)}function no(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 wt(e,t){I(()=>Ie(`${t}.tmp-replace`,{force:!0})),I(()=>Rt(e,`${t}.tmp-replace`)),I(()=>Rt(`${t}.tmp-replace`,t))}var Mt=1,sn="CODEBASEIQ_SHARED_CACHE",so=2,qe=JSON.stringify({cliVersion:Jt,artifactCatalogVersion:be,postIndexAugmentationSchemaVersion:so,sqliteGenerationStoreVersion:V,typescriptFragmentStoreVersion:Me,typescriptOverlayStoreVersion:_e}),_t="manifest.json",co="shared-cache.json",jt=[mt,fe,he];function Dt(e,t){if(!e.clean||!e.treeOid)return;let r=bn(JSON.stringify({version:Mt,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:t,producerIdentity:qe}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:qe,generationId:r,repositoryCacheDir:Te(e.repositoryId)}}function gn(e,t,r){if(process.env[sn]==="0")return`${sn}=0`;if(!Qe(r))return"explicit cache or database override";if(He(kt(t))!==He(Ve(e))||t!==u(kt(t),"index.db"))return"index database is outside the managed worktree cache"}function Os(e,t,r){if(!Qe(t))return;let n=r??oe(e);return n?u(Te(n.repositoryId),"evidence.db"):void 0}function $(e,t=!0){let r=qt(e),n;try{n=yn(E(u(r,_t),{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=$e(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 Ms(e,t,r){if(!e.treeOid)return null;let n=Je(t,r),i=u(Yt(),"repositories",e.repositoryId),o;try{let c=At(i);if(!c.isDirectory()||c.isSymbolicLink())return null;o=pn(i)}catch{return null}let a=u(o,"generations"),s=[];try{for(let c of un(a)){if(!/^[a-f0-9]{64}$/.test(c))continue;let d=u(a,c),l;try{l=At(d)}catch{continue}if(!(!l.isDirectory()||l.isSymbolicLink()))try{let p=yn(E(u(d,_t),{inputKind:"shared-generation baseline manifest",maxBytes:v}));p.generationId===c&&p.repositoryId===e.repositoryId&&p.treeOid===e.treeOid&&p.producerIdentity===qe&&fo(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 mn(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 lo(e)}finally{t.release()}}function lo(e){let t=$(e.snapshot);if(t)return cn(e.snapshot,t);if(!Re(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let r=dn(e.sourceCacheDir);if(!r)throw new Error("source index artifacts are incomplete");let n=je(e.sourceCacheDir),i=u(e.snapshot.repositoryCacheDir,"generations"),o=[Pe(i)],a=We(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 ze=$e(w).size;s.push({path:y,size:ze,sha256:Y(w,{inputKind:"staged shared-generation artifact",maxBytes:R})})}let c=fn(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=$t(e.sourceProjectRoot);if(!K(c,d))throw new Error("shared SCIP generation root does not match its source worktree");if(dn(e.sourceCacheDir)!==r||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let l={version:Mt,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,_t),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=qt(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 cn(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 cn(e,t){let r=j(u(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:r==="synced"?"directory-durable":"file-flushed",directorySync:r}}function Lt(e){let t=qt(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=We(u(e.targetCacheDir,".shared-hydrate-")),ho(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),$e(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=$t(e.targetProjectRoot);if(a!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&Hr(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=go(e.targetCacheDir,n),o=!0,mo(n,e.targetCacheDir,i),Zr({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=Gt(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&&Ot(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(a){throw o&&i&&yo(e.targetCacheDir,i),a}finally{n&&q(n,{recursive:!0,force:!0}),r.release()}}function _s(e,t,r,n){let i=gn(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 Be(o,r.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"};let a=t.languages??ot(e),s=Ue(e,a,hn(t)),c=Dt(o,s);if(!c)return{kind:"missed",reason:"clean committed snapshot is unavailable"};let d=$(c);if(d)return Lt({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId};let l=uo(c,e);return l?(d=l.manifest,Lt({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e,action:"peer-imported"}),{kind:"peer-imported",generationId:c.generationId,sourceProjectRoot:l.sourceProjectRoot}):(Be(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 js(e,t,r,n){let i=gn(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 Be(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??ot(e),s=Ue(e,a,hn(t)),c=Dt(o,s);if(!c)return Be(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)?(Ot(c,r.cacheDir,"local-fresh"),{kind:"local-fresh"}):(Lt({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId});let l=Nt(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)?(mn({snapshot:c,sourceCacheDir:r.cacheDir,sourceProjectRoot:e,sourceStillValid:()=>{let p=oe(e);return(p?Dt(p,s):void 0)?.generationId===c.generationId}}),Ot(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 Fs(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=Ce(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 oo(Math.min(n,l))}return $(e)?{kind:"generation-ready"}:{kind:"timeout"}}function Ot(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:Ft(i)};return Bt(e.repositoryCacheDir,o,!0),o}function Ns(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:Ft(n)};return Bt(e.repositoryCacheDir,i,!0),i}function Be(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:Ft(o)};return Bt(Te(e.repositoryId),a,!1),a}function Ft(e){return bn(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:we(e.projectRoot),localCacheDir:we(e.localCacheDir)}))}function yn(e){let t=JSON.parse(e);if(t.version!==Mt||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!==qe||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(Fe(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 Ae(e,t,{mode:r})}function uo(e,t){for(let r of Kt(t)){if(we(r.path)===we(t))continue;let n=Ve(r.path),i=Nt(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:mn({snapshot:e,sourceCacheDir:n,sourceProjectRoot:r.path}).manifest,sourceProjectRoot:r.path}}catch{continue}}return null}function po(e,t,r){ee(e,{recursive:!0}),G(u(e,co),{version:1,repositoryId:t,worktreeId:r},{spacing:2,trailingNewline:!0})}function dn(e){try{let t=je(e),r=ln("sha256");for(let n of t.files){let i=A(e,n),o=$e(i).size;r.update(n).update("\0").update(String(o)).update("\0"),zt(i,{inputKind:"source-generation artifact",maxBytes:R},a=>r.update(a)),r.update("\0")}return r.digest("hex")}catch{return null}}function Nt(e){try{let t=ke(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 hn(e){return{pnpmWorkspaces:e.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:e.indexer?.typescript?.projectMode,typescriptProjects:e.indexer?.typescript?.projects,clojureConfigPath:e.indexer?.clojure?.configPath}}function fo(e,t){let r=Je(e.languages,e);return JSON.stringify(r)===JSON.stringify(t)}function qt(e){return u(e.repositoryCacheDir,"generations",e.generationId)}function Bt(e,t,r){let n=rr(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}),po(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{n.release()}}function go(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 jt){let c=u(e,s),d=B(c);if(d){let l=At(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&&Sn(o,u(r,"sqlite-generations")),{root:r,stableFiles:n,managedDirectories:i,generationStoreExisted:a}}function mo(e,t,r){for(let n of jt){let i=u(t,n);if(r.managedDirectories.get(n)){let a=u(r.root,"managed",n);ee(kt(a),{recursive:!0}),I(()=>U(i,a))}let o=u(e,n);B(o)&&I(()=>U(o,i))}}function yo(e,t){for(let i of jt){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-${io()}`;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 Sn(e,t){ee(t,{recursive:!0});for(let r of un(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()?Sn(n,i):r.isFile()&&ve(n,i)}}function ho(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=Nt(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=je(e),s=Gt(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 ao(Ee(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=$t(t),p=(i?a.files.filter(h=>h.endsWith(".scip")):["index.scip"]).every(h=>{let D=fn(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 $t(e){try{return an(pn(e)).href}catch{return an(we(e)).href}}function bn(e){return ln("sha256").update(e).digest("hex")}function Bs(e){return typeof e=="object"&&e!==null}function $s(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}export{Zt as a,So as b,z as c,ke as d,vo as e,er as f,In as g,Eo as h,De as i,tr as j,rr as k,T as l,Do as m,Wo as n,gr as o,Bs as p,$s as q,ot as r,_a as s,Wa as t,Va as u,da as v,la as w,ua as x,pa as y,fa as z,xa as A,wa as B,Ra as C,va as D,Zr as E,Hi as F,is as G,os as H,Gt as I,Dt as J,gn as K,Os as L,$ as M,Ms as N,mn as O,Lt as P,_s as Q,js as R,Fs as S,Ot as T,Ns as U,Ft as V};
21
+ //# sourceMappingURL=chunk-XYLV727H.js.map
@@ -1,2 +1,2 @@
1
- import{a as D}from"./chunk-35NLDRZC.js";import{a as C}from"./chunk-NNOKTMZT.js";function v(t,n={}){let{limit:o=10,scope:s,minDepth:h=3,edgeBasis:c="symbol-references"}=n,u=C(t,s,c==="imports"?{scipEdges:"imports-only",sourceEdges:"imports-only"}:void 0),{components:p,componentOf:y}=D(u),m=new Map;for(let e=0;e<p.length;e++)m.set(e,new Set);for(let[e,a]of u){let i=y.get(e);for(let l of a){let r=y.get(l);r!==i&&m.get(i).add(r)}}let f=new Array(p.length),b=new Array(p.length);for(let e=0;e<p.length;e++){let a=[],i=0;for(let l of[...m.get(e)].sort((r,d)=>r-d)){let r=b[l];(r>i||r===i&&I(f[l],a,p)<0)&&(i=r,a=f[l])}f[e]=[e,...a],b[e]=1+i}function R(e){return f[e]}let w=p.map(e=>[...e].sort()),S=new Set,g=[];for(let e=0;e<p.length;e++){let i=R(e).map(d=>w[d]),l=i.map(d=>d[0]);if(i.length<h)continue;let r=l.join(" ");S.has(r)||(S.add(r),g.push(j(l,i,c)))}return g.sort((e,a)=>a.depth-e.depth||e.chain.join("\0").localeCompare(a.chain.join("\0"))),B(g).slice(0,o)}function K(t,n={}){return v(t,n)}function I(t,n,o){if(n.length===0)return-1;let s=t.map(c=>[...o[c]].sort()[0]??"").join("\0"),h=n.map(c=>[...o[c]].sort()[0]??"").join("\0");return s.localeCompare(h)}function j(t,n,o){let s=n.reduce((c,u)=>c+u.length,0),h=n.filter(c=>c.length>1).length;return{chain:t,components:n,depth:n.length,fileCount:s,edgeBasis:o,actionTier:"signal",chainKind:"transitive-dependency-depth",evidenceReasons:[`${n.length} condensed dependency component(s) form the representative transitive path`,`${s} file(s) are represented; ${h} component(s) contain a dependency cycle`,`edge basis: ${o==="imports"?"resolved file imports":"cross-file symbol references plus resolved source imports"}`,"cycles count once toward depth and retain their full membership separately"],recommendation:"Review whether the chain crosses ownership or layer boundaries; shorten it only when the dependency direction is accidental."}}function B(t){let n=[];for(let o of t)n.some(s=>E(o.chain,s.chain))||n.push(o);return n}function E(t,n){if(t.length>=n.length)return!1;let o=n.length-t.length;for(let s=0;s<t.length;s++)if(t[s]!==n[o+s])return!1;return!0}export{v as a,K as b};
2
- //# sourceMappingURL=chunk-TRRC4ZJ7.js.map
1
+ import{a as D}from"./chunk-35NLDRZC.js";import{a as C}from"./chunk-B2E3HZ2A.js";function v(t,n={}){let{limit:o=10,scope:s,minDepth:h=3,edgeBasis:c="symbol-references"}=n,u=C(t,s,c==="imports"?{scipEdges:"imports-only",sourceEdges:"imports-only"}:void 0),{components:p,componentOf:y}=D(u),m=new Map;for(let e=0;e<p.length;e++)m.set(e,new Set);for(let[e,a]of u){let i=y.get(e);for(let l of a){let r=y.get(l);r!==i&&m.get(i).add(r)}}let f=new Array(p.length),b=new Array(p.length);for(let e=0;e<p.length;e++){let a=[],i=0;for(let l of[...m.get(e)].sort((r,d)=>r-d)){let r=b[l];(r>i||r===i&&I(f[l],a,p)<0)&&(i=r,a=f[l])}f[e]=[e,...a],b[e]=1+i}function R(e){return f[e]}let w=p.map(e=>[...e].sort()),S=new Set,g=[];for(let e=0;e<p.length;e++){let i=R(e).map(d=>w[d]),l=i.map(d=>d[0]);if(i.length<h)continue;let r=l.join(" ");S.has(r)||(S.add(r),g.push(j(l,i,c)))}return g.sort((e,a)=>a.depth-e.depth||e.chain.join("\0").localeCompare(a.chain.join("\0"))),B(g).slice(0,o)}function K(t,n={}){return v(t,n)}function I(t,n,o){if(n.length===0)return-1;let s=t.map(c=>[...o[c]].sort()[0]??"").join("\0"),h=n.map(c=>[...o[c]].sort()[0]??"").join("\0");return s.localeCompare(h)}function j(t,n,o){let s=n.reduce((c,u)=>c+u.length,0),h=n.filter(c=>c.length>1).length;return{chain:t,components:n,depth:n.length,fileCount:s,edgeBasis:o,actionTier:"signal",chainKind:"transitive-dependency-depth",evidenceReasons:[`${n.length} condensed dependency component(s) form the representative transitive path`,`${s} file(s) are represented; ${h} component(s) contain a dependency cycle`,`edge basis: ${o==="imports"?"resolved file imports":"cross-file symbol references plus resolved source imports"}`,"cycles count once toward depth and retain their full membership separately"],recommendation:"Review whether the chain crosses ownership or layer boundaries; shorten it only when the dependency direction is accidental."}}function B(t){let n=[];for(let o of t)n.some(s=>E(o.chain,s.chain))||n.push(o);return n}function E(t,n){if(t.length>=n.length)return!1;let o=n.length-t.length;for(let s=0;s<t.length;s++)if(t[s]!==n[o+s])return!1;return!0}export{v as a,K as b};
2
+ //# sourceMappingURL=chunk-YFQPWKHR.js.map
@@ -1,4 +1,4 @@
1
- import{A as f,G as u}from"./chunk-NNJ2KZZG.js";import b from"ignore";import{existsSync as y,readdirSync as v}from"fs";import{dirname as d,isAbsolute as m,join as l,relative as T,resolve as S}from"path";function E(n){let t=b();return _(n,t)||t.add(F),{isIgnored:e=>g(t,n,e),filter:e=>e.filter(i=>!g(t,n,i))}}function _(n,t){let r=new Set,e=(s,a)=>{if(!(r.has(s)||!y(s)))try{let c=u(s,{maxBytes:f,inputKind:"gitignore file"});t.add(a?$(c,a):c),r.add(s)}catch{}},i=d(n),o=0;for(;i!==d(i)&&o<5&&(e(l(i,".gitignore"),""),!y(l(i,".git")));)i=d(i),o++;return h(n,"",t,e),r.size>0}function h(n,t,r,e){let i=t?l(n,t):n;e(l(i,".gitignore"),t);let o;try{o=v(i,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name===".git")continue;let a=t?`${t}/${s.name}`:s.name;g(r,n,`${a}/`)||h(n,a,r,e)}}function $(n,t){let r=t.replaceAll("\\","/").replace(/\/+$/,"");return n.split(/\r?\n/).map(e=>A(e,r)).join(`
1
+ import{A as f,G as u}from"./chunk-327YK6TB.js";import b from"ignore";import{existsSync as y,readdirSync as v}from"fs";import{dirname as d,isAbsolute as m,join as l,relative as T,resolve as S}from"path";function E(n){let t=b();return _(n,t)||t.add(F),{isIgnored:e=>g(t,n,e),filter:e=>e.filter(i=>!g(t,n,i))}}function _(n,t){let r=new Set,e=(s,a)=>{if(!(r.has(s)||!y(s)))try{let c=u(s,{maxBytes:f,inputKind:"gitignore file"});t.add(a?$(c,a):c),r.add(s)}catch{}},i=d(n),o=0;for(;i!==d(i)&&o<5&&(e(l(i,".gitignore"),""),!y(l(i,".git")));)i=d(i),o++;return h(n,"",t,e),r.size>0}function h(n,t,r,e){let i=t?l(n,t):n;e(l(i,".gitignore"),t);let o;try{o=v(i,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name===".git")continue;let a=t?`${t}/${s.name}`:s.name;g(r,n,`${a}/`)||h(n,a,r,e)}}function $(n,t){let r=t.replaceAll("\\","/").replace(/\/+$/,"");return n.split(/\r?\n/).map(e=>A(e,r)).join(`
2
2
  `)}function A(n,t){let r=n.trimStart();if(!r||r.startsWith("#"))return n;let e=n.slice(0,n.length-r.length),i=r.startsWith("!"),o=i?r.slice(1):r;if(!o||o.startsWith("#"))return n;let s=o.startsWith("/"),a=s?o.slice(1):o,p=(a.endsWith("/")?a.slice(0,-1):a).includes("/")||s?`${t}/${a}`:`${t}/**/${a}`;return`${e}${i?"!":""}${p}`}var F=`
3
3
  # Dependencies
4
4
  node_modules/
@@ -57,4 +57,4 @@ Thumbs.db
57
57
  # Type definitions (often noise in queries)
58
58
  *.d.ts
59
59
  `;function g(n,t,r){let e=x(t,r);if(!e)return!1;try{return n.ignores(e)}catch{return!1}}function x(n,t){if(!t||t===".")return null;if(!m(t)&&!t.startsWith(".."))return t.replaceAll("\\","/");let r=m(t)?t:S(n,t),e=T(n,r).replaceAll("\\","/");return!e||e==="."||e.startsWith("..")?null:e}export{E as a};
60
- //# sourceMappingURL=chunk-NEDP5RFQ.js.map
60
+ //# sourceMappingURL=chunk-YIOQJ45A.js.map
@@ -1,7 +1,7 @@
1
- import{d as j}from"./chunk-PTAWHLVJ.js";import{a as k}from"./chunk-ST7V3SKN.js";import{a as _}from"./chunk-QHRNXP3C.js";import{b as C}from"./chunk-XLQ3GLWZ.js";import{a as T}from"./chunk-VE5AVNMP.js";import{g as S}from"./chunk-J77SU6VA.js";import{a as O,b as w,e as $}from"./chunk-UZGZB3VB.js";import{d as L,e as I,t as g}from"./chunk-FETNQCFO.js";import{f as B,p as M}from"./chunk-O6QTXQPJ.js";import{v as P}from"./chunk-BMYOV5GP.js";import{a as F}from"./chunk-NNJ2KZZG.js";import{basename as le,extname as U}from"path";var ee=12,ne=280;function y(n,e,t,o){let i=te(n,e,t,o);if(i.size===0)return se();let r=[],s=new Set,l=(a,d,c,f)=>{if(d===e&&c<=o&&f>=t)return;let b=`${d}:${c}:${f}:${a}`;s.has(b)||(s.add(b),r.push({name:a,relativePath:d,startLine:c,endLine:f}))};for(let a of g(n,e))i.has(a.leaf)&&l(a.leaf,a.relativePath,a.startLine,a.endLine);for(let a of M(n,e)){let d=a.localName;if(!d||!i.has(d)||!a.sourcePath||a.kind==="namespace")continue;let c=a.importedName==="default"?d:a.importedName;for(let f of T(n,a.sourcePath,c,{maxReexportDepth:3}))l(d,f.relativePath,f.startLine,f.endLine)}r.sort(W);let u=r.map(a=>{let d=ie(n,a);return d?{...a,source:d}:null}).filter(a=>a!==null).slice(0,ee);return D(u)}function A(n,e=[]){return D(re(n.flatMap(t=>t?.inline??[]),e))}function Ne(n){return n?n.inline.reduce((e,t)=>e+t.name.length+t.source.length+32,0):0}function te(n,e,t,o){let i=B(n,e),r=new Set;if(!i)return r;for(let s=t;s<=o;s+=1)for(let l of i.identifiersByLine[s]??[])r.add(l);return r}function ie(n,e){if(e.startLine!==e.endLine)return null;let t=(P(n,e.relativePath)[e.startLine]??"").trim();if(!t||t.length>ne)return null;let o=t.indexOf("=");if(o<0||t[o+1]===">")return null;let i=t.slice(o+1).replace(/(?:\/\/|#).*$/u,"").trim();if(!i||i.includes("${")||/\b(?:function|class|struct|interface|trait|enum|lambda)\b/u.test(i))return null;let s=i.replace(/(['"`])(?:\\.|(?!\1).)*\1/gu,"").replace(/\b(?:0[xX][\dA-Fa-f_]+|0[bB][01_]+|0[oO][0-7_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)n?\b/gu,""),l=new Set(["true","false","null","undefined","None","True","False"]);return(s.match(/[A-Za-z_][A-Za-z0-9_]*/gu)??[]).some(a=>!l.has(a))?null:t}function re(n,e){let t=new Map;for(let o of n){if(oe(o,e))continue;let i=`${o.relativePath}:${o.startLine}:${o.endLine}:${o.name}`;t.has(i)||t.set(i,{...o})}return[...t.values()].sort(W)}function oe(n,e){return e.some(t=>t.relativePath===n.relativePath&&t.startLine<=n.startLine&&t.endLine>=n.endLine)}function W(n,e){return n.relativePath.localeCompare(e.relativePath)||n.startLine-e.startLine||n.name.localeCompare(e.name)}function D(n){return{coverage:"indexed-project-literal-values",inline:n}}function se(){return D([])}function Ae(n,e,t={}){let{context:o=0}=t,i=Y(e);if(i)return q(n,i.filePath,i.startLine,i.endLine,o);let r=Q(n,e);if(r)return K(n,r);let s=O(n,e);return s?p(n,s,o):null}function We(n,e,t={}){if(e.length===0)throw new RangeError("code requires at least one selector.");if(e.length>24)throw new RangeError(`code accepts at most ${24} selectors per complete packet; received ${e.length}.`);let o=t.context??0,i=t.members??"exported",r=e.map(u=>ue(n,u,o,i)),s=r.flatMap(u=>u.results),l=s.map(u=>({relativePath:u.relativePath,startLine:u.startLine,endLine:u.endLine}));return{requested:e.length,matched:r.filter(u=>u.status==="matched").length,ambiguous:r.filter(u=>u.status==="ambiguous").length,missing:r.filter(u=>u.status==="missing").length,entries:r,bindingClosure:A(s.map(u=>u.bindingClosure),l)}}function ue(n,e,t,o){let i=Y(e);if(i){let d=q(n,i.filePath,i.startLine,i.endLine,t);return d?de(n,e,d,t):x(n,e,"definition-source-unreadable")}let r=Q(n,e);if(r)return fe(n,e,r,t,o);let s=w(n,e);if(!s.match)return x(n,e,"definition-not-found");let l=Le(n,s),u=l.map(V);if(s.total>1){let d=s.total<=4&&l.length===s.total;return{selector:e,status:"ambiguous",kind:"source",totalCandidates:s.total,results:d?l.flatMap(c=>{let f=p(n,c,t);return f?[f]:[]}):[],definitions:[],candidates:u,omittedCandidates:Math.max(0,s.total-u.length),suggestions:[]}}let a=p(n,s.match,t);return a?ve(e,a):x(n,e,"definition-source-unreadable")}function de(n,e,t,o){let i=g(n,t.relativePath).filter(a=>!X(a,t.relativePath)),r=ce(n,t,i),s=G(r.map(a=>p(n,a,o)).filter(a=>a!==null)).filter(a=>!J(t,a)),l=new Set(s.map(a=>a.symbol)),u=r.filter(a=>!l.has(a.symbol)&&!(t.startLine<=a.startLine&&t.endLine>=a.endLine)).map(V);return{selector:e,status:"matched",kind:"source",totalCandidates:1,results:[t,...s],definitions:[],candidates:[],omittedCandidates:0,suggestions:[],rangeCoverage:{basis:"requested-range-and-same-file-call-closure",referencedDefinitions:r.length,returnedDefinitions:r.length-u.length,returnedBodies:s.length,omittedDefinitions:u.length,omittedLedger:u}}}function ce(n,e,t){if(!h(e.freshness))return[];if(t.length===0)return[];let o=S(n,t,{additive:!1,semantic:!1}),i=new Map;for(let s of t){let l=i.get(s.symbol)??[];l.push(s),i.set(s.symbol,l)}let r=new Map;for(let s of t)if(!(s.endLine<e.startLine||s.startLine>e.endLine)){for(let l of o.get(s.symbolId)??[])if(l.file===e.relativePath&&!(l.source==="ast-callsite"&&(l.chunkId<e.startLine||l.chunkId>e.endLine)))for(let u of i.get(l.symbol)??[])r.set(u.symbolId,u)}return H(n,[...r.values()],t)}function fe(n,e,t,o,i){let r=t.relativePath,s=ge(n,r),l=h(t.freshness)?g(n,r).filter(m=>!X(m,r)):[],u=l.filter(m=>_(n,m)),a=u.length>0?u:me(s,l),d=i==="all"?[]:H(n,a,l),c=i==="all"||l.length===0?[K(n,t)]:G(d.map(m=>p(n,m,o)).filter(m=>m!==null)),f=he(s,c),b=be(r,s,c),N=Ce(s);return{selector:e,status:"matched",kind:"file-source",totalCandidates:1,results:c,definitions:[],candidates:[],omittedCandidates:0,suggestions:[],fileCoverage:{members:i,basis:i==="all"||l.length===0?"complete-file-source":u.length>0?"explicit-exports-and-same-file-reference-closure":"top-level-and-same-file-reference-closure",totalDefinitions:N,returnedDefinitions:f,returnedBodies:c.length,omittedDefinitions:Math.max(0,N-f),omittedLedger:b}}}function me(n,e){let t=new Set(n.map(o=>o.symbol));return e.filter(o=>t.has(o.symbol))}function ge(n,e){return k(n,e).flatMap(t=>pe(t,e)?t.children:[t])}function X(n,e){return z(e).has(n.leaf)}function pe(n,e){return z(e).has(I(n.symbol))}function z(n){let e=le(n);return new Set([e,e.slice(0,Math.max(0,e.length-U(e).length))])}function H(n,e,t){if(e.length===0)return[];let o=S(n,t,{additive:!0,semantic:!1}),i=new Map;for(let l of t){let u=i.get(l.symbol)??[];u.push(l),i.set(l.symbol,u)}let r=new Map,s=[...e];for(;s.length>0;){let l=s.shift();if(!r.has(l.symbolId)){r.set(l.symbolId,l);for(let u of o.get(l.symbolId)??[])for(let a of i.get(u.symbol)??[])r.has(a.symbolId)||s.push(a)}}return[...r.values()].sort(ye)}function G(n){let e=[...n].sort((o,i)=>o.relativePath.localeCompare(i.relativePath)||o.startLine-i.startLine||i.endLine-o.endLine),t=[];for(let o of e)t.some(i=>J(i,o))||t.push(o);return t}function K(n,e){let t=e.text.split(`
1
+ import{d as j}from"./chunk-VLTUX4IF.js";import{a as k}from"./chunk-RCPZOPV6.js";import{a as _}from"./chunk-GXVDTHFC.js";import{b as C}from"./chunk-I2KP4AGR.js";import{a as T}from"./chunk-MTMF4N7F.js";import{g as S}from"./chunk-57KEZDPT.js";import{a as O,b as w,e as $}from"./chunk-3XFJUWJE.js";import{d as L,e as I,t as g}from"./chunk-AM5SUGHF.js";import{f as B,p as M}from"./chunk-JOALNFY3.js";import{x as P}from"./chunk-PLZXWZHY.js";import{a as F}from"./chunk-327YK6TB.js";import{basename as le,extname as U}from"path";var ee=12,ne=280;function y(n,e,t,o){let i=te(n,e,t,o);if(i.size===0)return se();let r=[],s=new Set,l=(a,d,c,f)=>{if(d===e&&c<=o&&f>=t)return;let b=`${d}:${c}:${f}:${a}`;s.has(b)||(s.add(b),r.push({name:a,relativePath:d,startLine:c,endLine:f}))};for(let a of g(n,e))i.has(a.leaf)&&l(a.leaf,a.relativePath,a.startLine,a.endLine);for(let a of M(n,e)){let d=a.localName;if(!d||!i.has(d)||!a.sourcePath||a.kind==="namespace")continue;let c=a.importedName==="default"?d:a.importedName;for(let f of T(n,a.sourcePath,c,{maxReexportDepth:3}))l(d,f.relativePath,f.startLine,f.endLine)}r.sort(W);let u=r.map(a=>{let d=ie(n,a);return d?{...a,source:d}:null}).filter(a=>a!==null).slice(0,ee);return D(u)}function A(n,e=[]){return D(re(n.flatMap(t=>t?.inline??[]),e))}function Ne(n){return n?n.inline.reduce((e,t)=>e+t.name.length+t.source.length+32,0):0}function te(n,e,t,o){let i=B(n,e),r=new Set;if(!i)return r;for(let s=t;s<=o;s+=1)for(let l of i.identifiersByLine[s]??[])r.add(l);return r}function ie(n,e){if(e.startLine!==e.endLine)return null;let t=(P(n,e.relativePath)[e.startLine]??"").trim();if(!t||t.length>ne)return null;let o=t.indexOf("=");if(o<0||t[o+1]===">")return null;let i=t.slice(o+1).replace(/(?:\/\/|#).*$/u,"").trim();if(!i||i.includes("${")||/\b(?:function|class|struct|interface|trait|enum|lambda)\b/u.test(i))return null;let s=i.replace(/(['"`])(?:\\.|(?!\1).)*\1/gu,"").replace(/\b(?:0[xX][\dA-Fa-f_]+|0[bB][01_]+|0[oO][0-7_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)n?\b/gu,""),l=new Set(["true","false","null","undefined","None","True","False"]);return(s.match(/[A-Za-z_][A-Za-z0-9_]*/gu)??[]).some(a=>!l.has(a))?null:t}function re(n,e){let t=new Map;for(let o of n){if(oe(o,e))continue;let i=`${o.relativePath}:${o.startLine}:${o.endLine}:${o.name}`;t.has(i)||t.set(i,{...o})}return[...t.values()].sort(W)}function oe(n,e){return e.some(t=>t.relativePath===n.relativePath&&t.startLine<=n.startLine&&t.endLine>=n.endLine)}function W(n,e){return n.relativePath.localeCompare(e.relativePath)||n.startLine-e.startLine||n.name.localeCompare(e.name)}function D(n){return{coverage:"indexed-project-literal-values",inline:n}}function se(){return D([])}function Ae(n,e,t={}){let{context:o=0}=t,i=Y(e);if(i)return q(n,i.filePath,i.startLine,i.endLine,o);let r=Q(n,e);if(r)return K(n,r);let s=O(n,e);return s?p(n,s,o):null}function We(n,e,t={}){if(e.length===0)throw new RangeError("code requires at least one selector.");if(e.length>24)throw new RangeError(`code accepts at most ${24} selectors per complete packet; received ${e.length}.`);let o=t.context??0,i=t.members??"exported",r=e.map(u=>ue(n,u,o,i)),s=r.flatMap(u=>u.results),l=s.map(u=>({relativePath:u.relativePath,startLine:u.startLine,endLine:u.endLine}));return{requested:e.length,matched:r.filter(u=>u.status==="matched").length,ambiguous:r.filter(u=>u.status==="ambiguous").length,missing:r.filter(u=>u.status==="missing").length,entries:r,bindingClosure:A(s.map(u=>u.bindingClosure),l)}}function ue(n,e,t,o){let i=Y(e);if(i){let d=q(n,i.filePath,i.startLine,i.endLine,t);return d?de(n,e,d,t):x(n,e,"definition-source-unreadable")}let r=Q(n,e);if(r)return fe(n,e,r,t,o);let s=w(n,e);if(!s.match)return x(n,e,"definition-not-found");let l=Le(n,s),u=l.map(V);if(s.total>1){let d=s.total<=4&&l.length===s.total;return{selector:e,status:"ambiguous",kind:"source",totalCandidates:s.total,results:d?l.flatMap(c=>{let f=p(n,c,t);return f?[f]:[]}):[],definitions:[],candidates:u,omittedCandidates:Math.max(0,s.total-u.length),suggestions:[]}}let a=p(n,s.match,t);return a?ve(e,a):x(n,e,"definition-source-unreadable")}function de(n,e,t,o){let i=g(n,t.relativePath).filter(a=>!X(a,t.relativePath)),r=ce(n,t,i),s=G(r.map(a=>p(n,a,o)).filter(a=>a!==null)).filter(a=>!J(t,a)),l=new Set(s.map(a=>a.symbol)),u=r.filter(a=>!l.has(a.symbol)&&!(t.startLine<=a.startLine&&t.endLine>=a.endLine)).map(V);return{selector:e,status:"matched",kind:"source",totalCandidates:1,results:[t,...s],definitions:[],candidates:[],omittedCandidates:0,suggestions:[],rangeCoverage:{basis:"requested-range-and-same-file-call-closure",referencedDefinitions:r.length,returnedDefinitions:r.length-u.length,returnedBodies:s.length,omittedDefinitions:u.length,omittedLedger:u}}}function ce(n,e,t){if(!h(e.freshness))return[];if(t.length===0)return[];let o=S(n,t,{additive:!1,semantic:!1}),i=new Map;for(let s of t){let l=i.get(s.symbol)??[];l.push(s),i.set(s.symbol,l)}let r=new Map;for(let s of t)if(!(s.endLine<e.startLine||s.startLine>e.endLine)){for(let l of o.get(s.symbolId)??[])if(l.file===e.relativePath&&!(l.source==="ast-callsite"&&(l.chunkId<e.startLine||l.chunkId>e.endLine)))for(let u of i.get(l.symbol)??[])r.set(u.symbolId,u)}return H(n,[...r.values()],t)}function fe(n,e,t,o,i){let r=t.relativePath,s=ge(n,r),l=h(t.freshness)?g(n,r).filter(m=>!X(m,r)):[],u=l.filter(m=>_(n,m)),a=u.length>0?u:me(s,l),d=i==="all"?[]:H(n,a,l),c=i==="all"||l.length===0?[K(n,t)]:G(d.map(m=>p(n,m,o)).filter(m=>m!==null)),f=he(s,c),b=be(r,s,c),N=Ce(s);return{selector:e,status:"matched",kind:"file-source",totalCandidates:1,results:c,definitions:[],candidates:[],omittedCandidates:0,suggestions:[],fileCoverage:{members:i,basis:i==="all"||l.length===0?"complete-file-source":u.length>0?"explicit-exports-and-same-file-reference-closure":"top-level-and-same-file-reference-closure",totalDefinitions:N,returnedDefinitions:f,returnedBodies:c.length,omittedDefinitions:Math.max(0,N-f),omittedLedger:b}}}function me(n,e){let t=new Set(n.map(o=>o.symbol));return e.filter(o=>t.has(o.symbol))}function ge(n,e){return k(n,e).flatMap(t=>pe(t,e)?t.children:[t])}function X(n,e){return z(e).has(n.leaf)}function pe(n,e){return z(e).has(I(n.symbol))}function z(n){let e=le(n);return new Set([e,e.slice(0,Math.max(0,e.length-U(e).length))])}function H(n,e,t){if(e.length===0)return[];let o=S(n,t,{additive:!0,semantic:!1}),i=new Map;for(let l of t){let u=i.get(l.symbol)??[];u.push(l),i.set(l.symbol,u)}let r=new Map,s=[...e];for(;s.length>0;){let l=s.shift();if(!r.has(l.symbolId)){r.set(l.symbolId,l);for(let u of o.get(l.symbolId)??[])for(let a of i.get(u.symbol)??[])r.has(a.symbolId)||s.push(a)}}return[...r.values()].sort(ye)}function G(n){let e=[...n].sort((o,i)=>o.relativePath.localeCompare(i.relativePath)||o.startLine-i.startLine||i.endLine-o.endLine),t=[];for(let o of e)t.some(i=>J(i,o))||t.push(o);return t}function K(n,e){let t=e.text.split(`
2
2
  `);return{symbol:e.relativePath,shortName:e.relativePath,relativePath:e.relativePath,startLine:0,endLine:Math.max(0,t.length-1),language:n.get("SELECT language FROM documents WHERE relative_path = ?",e.relativePath)?.language??E(e.relativePath),source:e.text,freshness:e.freshness,...h(e.freshness)?{bindingClosure:y(n,e.relativePath,0,Math.max(0,t.length-1))}:{}}}function he(n,e){return v(n).filter(t=>e.some(o=>R(t,o))).length}function be(n,e,t){let o=[];return Z(o,n,e,t,0),o}function Z(n,e,t,o,i){for(let r of t){if(o.some(l=>R(r,l)))continue;let s=v(r.children).filter(l=>!o.some(u=>R(l,u))).length;n.push({symbol:r.symbol,shortName:r.shortName,relativePath:e,startLine:r.startLine,endLine:r.endLine,signature:r.signature,depth:i,nestedDefinitions:s}),Z(n,e,r.children,o,i+1)}}function v(n){return n.flatMap(e=>[e,...v(e.children)])}function Ce(n){return v(n).length}function R(n,e){return e.startLine<=n.startLine&&e.endLine>=n.endLine}function J(n,e){return n.relativePath===e.relativePath&&n.startLine<=e.startLine&&n.endLine>=e.endLine}function ye(n,e){return n.startLine-e.startLine||e.endLine-n.endLine||n.symbol.localeCompare(e.symbol)}function ve(n,e){return{selector:n,status:"matched",kind:"source",totalCandidates:1,results:[e],definitions:[],candidates:[],omittedCandidates:0,suggestions:[]}}function x(n,e,t){return{selector:e,status:"missing",kind:"source",totalCandidates:0,results:[],definitions:[],candidates:[],omittedCandidates:0,suggestions:$(n,e,5),reason:t}}function Q(n,e){try{return C(n,e)}catch(t){if(t instanceof F)return null;throw t}}function Le(n,e){if(!e.match)return[];let t=[e.match];for(let i of e.candidates){let r=g(n,i.relativePath).find(s=>s.symbol===i.symbol&&s.startLine===i.startLine);r&&t.push(r)}let o=new Set;return t.filter(i=>{let r=`${i.relativePath}:${i.startLine}:${i.endLine}:${i.symbol}`;return o.has(r)?!1:(o.add(r),!0)})}function V(n){return{symbol:n.symbol,shortName:L(n.symbol),relativePath:n.relativePath,startLine:n.startLine,endLine:n.endLine}}function Y(n){let e=n.match(/^(.+):(\d+)-(\d+)$/);if(!e)return null;let t=Number(e[2]),o=Number(e[3]);if(!Number.isSafeInteger(t)||t<1)throw new RangeError(`Source range start line must be a positive integer, got "${e[2]}".`);if(!Number.isSafeInteger(o)||o<t)throw new RangeError(`Source range end line must be an integer at or after ${t}, got "${e[3]}".`);return{filePath:e[1],startLine:t,endLine:o}}function p(n,e,t){let o=n.get("SELECT language FROM documents WHERE relative_path = ?",e.relativePath),i=C(n,e.relativePath);if(!i)return null;let s=i.text.split(`
3
3
  `),l=e.endLine<=e.startLine?j(n,e.relativePath,e.startLine,Number.MAX_SAFE_INTEGER):null,u=l?.unitType?l.unitStartLine:e.startLine,a=l?.unitType?l.unitEndLine:e.endLine,d=Math.max(0,u-t),c=Math.min(s.length-1,a+t),f=s.slice(d,c+1).join(`
4
4
  `);return{symbol:e.symbol,shortName:L(e.symbol),relativePath:e.relativePath,startLine:d,endLine:c,language:o?.language??E(e.relativePath),source:f,freshness:i.freshness,...h(i.freshness)?{bindingClosure:y(n,e.relativePath,d,c)}:{}}}function q(n,e,t,o,i){let r=C(n,e);if(!r)return null;let s=n.get("SELECT language FROM documents WHERE relative_path = ?",r.relativePath),u=r.text.split(`
5
5
  `);if(t>u.length)return null;let a=Math.max(0,t-1-i),d=Math.min(u.length-1,o-1+i),c=u.slice(a,d+1).join(`
6
6
  `);return{symbol:`${r.relativePath}:${t}-${o}`,shortName:`${r.relativePath}:${t}-${o}`,relativePath:r.relativePath,startLine:a,endLine:d,language:s?.language??E(r.relativePath),source:c,freshness:r.freshness,...h(r.freshness)?{bindingClosure:y(n,r.relativePath,a,d)}:{}}}function h(n){return!!(n&&n.semantic.state!=="stale"&&n.semantic.basis!=="no-compiler-document")}function E(n){switch(U(n).toLowerCase()){case".ts":case".tsx":case".mts":case".cts":return"typescript";case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".py":case".pyi":return"python";case".rs":return"rust";case".go":return"go";case".java":return"java";case".kt":case".kts":return"kotlin";case".scala":return"scala";case".rb":return"ruby";case".php":return"php";case".cs":return"csharp";case".vb":return"vb";case".dart":return"dart";case".c":case".h":return"c";case".cc":case".cpp":case".cxx":case".hpp":case".hh":case".hxx":return"cpp";case".vue":return"vue";default:return null}}export{y as a,A as b,Ne as c,Ae as d,We as e};
7
- //# sourceMappingURL=chunk-Y6KHROC3.js.map
7
+ //# sourceMappingURL=chunk-YXJ4IAHH.js.map
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{t as Y}from"./chunk-CIVYHK7U.js";import{f as H}from"./chunk-RJWAB4VR.js";import{d as L,e as W}from"./chunk-D62CTZX6.js";import{R as $,S as w,Wa as F,X as G,Xa as J,fb as M,m as B,o as m,p as N,q as z,t as v}from"./chunk-G2XUZCF2.js";import{d as A,f as O,j as C,r as R}from"./chunk-DUKHVPU5.js";import{existsSync as k,lstatSync as b,readdirSync as K,realpathSync as U,rmSync as S,statSync as Q}from"fs";import{join as l,resolve as P,sep as V}from"path";var ne=3600*1e3,oe=2*1024*1024*1024,x=300*1e3,se="gc-state.json",ae="gc.lock",ie="projects-gc-state.json",ce="projects-gc.lock",le=1440*60*1e3;function de(t){let e=t.leases.filter(o=>o.managed&&!o.live&&!o.busy),n=X(t.leases,t.locks),r={};for(let o of t.generations)n.has(o.generationId)||(r[o.generationId]=o.unreferencedAt??t.nowMs);let a=t.generations.filter(o=>!n.has(o.generationId)).sort((o,d)=>r[o.generationId]-r[d.generationId]||o.generationId.localeCompare(d.generationId)),s=new Set;for(let o of a)t.nowMs-r[o.generationId]>=t.policy.generationTtlMs&&s.add(o.generationId);let c=t.generations.filter(o=>!s.has(o.generationId)).reduce((o,d)=>o+d.size,0);for(let o of a){if(c<=t.policy.budgetBytes)break;s.has(o.generationId)||(s.add(o.generationId),c-=o.size)}for(let o of s)delete r[o];return{deleteWorktrees:e,deleteGenerations:t.generations.filter(o=>s.has(o.generationId)),deleteLocks:t.locks.filter(o=>!o.live),deleteTemporaries:t.temporaries.filter(o=>!o.live),protectedGenerationIds:[...n].sort(),unreferencedSince:r}}function X(t,e){let n=new Set(t.filter(r=>r.managed&&(r.live||r.busy)).flatMap(r=>[r.lease.baseGenerationId,r.lease.activeGenerationId]).filter(r=>r!==void 0));for(let r of e)r.live&&n.add(r.generationId);return n}function Le(t,e,n={}){if(!z())return{kind:"disabled"};let r=A(t);if(!r)return{kind:"unavailable"};let a=l(m(),"repositories",r.repositoryId),s=(n.now??Date.now)(),c=k(a)?Z(t,a,r.repositoryId,e,s,n):{kind:"unavailable"};return fe(t,r.repositoryId,e,s,n),ue(s,n),c}function ue(t,e){let n=l(m(),"projects"),r={examined:0,reclaimed:0};if(!k(n))return r;let a=l(n,ie),s=re(a);if(!e.force&&s!==void 0&&t-s<x)return r;let c=w(l(n,ce));if(!c)return r;try{for(let o of I(n)){let d=l(n,o),i;try{i=b(d)}catch{continue}if(!(!i.isDirectory()||i.isSymbolicLink())&&(r.examined+=1,!!pe(d,t)))try{S(d,{recursive:!0,force:!0}),r.reclaimed+=1}catch{}}G(a,{version:1,lastSweepAt:new Date(t).toISOString()},{spacing:2,trailingNewline:!0})}finally{c.release()}return r}function pe(t,e){let n=l(t,B),r;try{let c=JSON.parse(R(n,"cache-ownership"));if(typeof c.canonicalProjectRoot!="string"||c.canonicalProjectRoot.length===0)return!1;r=c.canonicalProjectRoot}catch{return!1}if(k(r))return!1;try{if(e-b(t).mtimeMs<le)return!1}catch{return!1}let a=W(L(t).statePath);if(a&&C(a.pid))return!1;let s=w(l(t,"cache-lifecycle.lock"));return s===null?!1:(s.release(),!0)}function Z(t,e,n,r,a,s){let c=l(e,"gc-state.json"),o=te(c);if(!s.force&&o&&a-Date.parse(o.lastSweepAt)<x)return{kind:"throttled",sweptAt:o.lastSweepAt};let d=$(e,{now:()=>a});if(!d)return{kind:"busy"};try{let i=ee(t,e,n,o?.unreferencedSince??{}),u=de({nowMs:a,...i,policy:{generationTtlMs:s.policy?.generationTtlMs??ne,budgetBytes:s.policy?.budgetBytes??oe}}),p=0,y=0;for(let f of u.deleteWorktrees){if(!T(f.lease))continue;if(!k(f.lease.localCacheDir)){S(f.leasePath,{force:!0}),y+=1;continue}if(!he(f.lease))continue;let _=w(l(f.lease.localCacheDir,"cache-lifecycle.lock"));if(_)try{if(E(f.lease,!0))continue;try{Y({projectRoot:f.lease.projectRoot,cacheDir:f.lease.localCacheDir,cliVersion:r})}catch{continue}if(E(f.lease,!0))continue;S(f.lease.localCacheDir,{recursive:!0,force:!0}),S(f.leasePath,{force:!0}),y+=1}finally{_.release()}}for(let f of u.deleteLocks)S(f.path,{force:!0});for(let f of u.deleteTemporaries)S(f.path,{recursive:!0,force:!0});for(let f of u.deleteGenerations)S(f.path,{recursive:!0,force:!0}),p+=f.size;H(l(e,"evidence.db"));let g={kind:"swept",sweptAt:new Date(a).toISOString(),deletedWorktrees:y,deletedGenerations:u.deleteGenerations.length,deletedBytes:p,protectedGenerations:u.protectedGenerationIds.length},h={version:1,lastSweepAt:g.sweptAt,unreferencedSince:u.unreferencedSince,lastResult:g};return G(c,h,{spacing:2,trailingNewline:!0}),g}catch(i){return{kind:"failed",error:i instanceof Error?i.message:String(i)}}finally{d.release()}}function fe(t,e,n,r,a){let s=l(m(),"repositories");if(!k(s))return;let c=l(s,se),o=re(c);if(!a.force&&o!==void 0&&r-o<x)return;let d=w(l(s,ae));if(d)try{for(let i of I(s)){if(i===e||!/^[a-f0-9]{24}$/.test(i))continue;let u=l(s,i),p;try{p=b(u)}catch{continue}if(!p.isDirectory()||p.isSymbolicLink())continue;let y=ge(u)??t;Z(y,u,i,n,r,a)}G(c,{version:1,lastSweepAt:new Date(r).toISOString()},{spacing:2,trailingNewline:!0})}finally{d.release()}}function Ee(t,e,n){let r=F(t,n.dbPath,e);if(r)return{state:"bypassed",reason:r,localCacheDir:n.cacheDir,generations:0,generationBytes:0,protectedGenerations:0,unreferencedGenerations:0,unreferencedBytes:0,temporaryGenerations:0,sharedEvidence:{exists:!1,bytes:0}};let a=A(t);if(!a)return{state:"unavailable",reason:"Git worktree identity is unavailable",localCacheDir:n.cacheDir,generations:0,generationBytes:0,protectedGenerations:0,unreferencedGenerations:0,unreferencedBytes:0,temporaryGenerations:0,sharedEvidence:{exists:!1,bytes:0}};let s=l(m(),"repositories",a.repositoryId),c=j(l(s,"worktrees",`${a.worktreeId}.json`)),o=te(l(s,"gc-state.json")),d=ee(t,s,a.repositoryId,o?.unreferencedSince??{}),i=X(d.leases,d.locks),u=d.generations.filter(h=>!i.has(h.generationId)),p=d.generations.reduce((h,f)=>h+f.size,0),y=J(t,e),g=0;return y&&(g=ye(y)),{state:"managed",repositoryId:a.repositoryId,worktreeId:a.worktreeId,localCacheDir:n.cacheDir,...c?{baseGenerationId:c.baseGenerationId,activeGenerationId:c.activeGenerationId,lastAction:c.lastAction,reason:c.lastReason,lastSeenAt:c.lastSeenAt}:{},generations:d.generations.length,generationBytes:p,protectedGenerations:d.generations.filter(h=>i.has(h.generationId)).length,unreferencedGenerations:u.length,unreferencedBytes:u.reduce((h,f)=>h+f.size,0),temporaryGenerations:d.temporaries.length,sharedEvidence:{path:y,exists:g>0,bytes:g},cleanup:o?.lastResult}}function ye(t){return[t,`${t}-wal`,`${t}-shm`].reduce((e,n)=>{try{return e+Q(n).size}catch{return e}},0)}function ee(t,e,n,r){let a=new Set(O(t).map(i=>P(i.path))),s=[];for(let i of I(l(e,"worktrees"))){if(!i.endsWith(".json"))continue;let u=l(e,"worktrees",i),p=j(u);if(!p)continue;let y=P(p.projectRoot);s.push({leasePath:u,lease:p,managed:p.repositoryId===n&&T(p),live:a.has(y)||k(y),busy:E(p)})}let c=[];for(let i of I(l(e,"locks"))){let u=/^([a-f0-9]{64})\.lock$/.exec(i);if(!u)continue;let p=l(e,"locks",i),y=D(p),g=y!==void 0&&C(y),h=u[1];c.push({generationId:h,path:p,live:g})}let o=[],d=[];for(let i of I(l(e,"generations"))){let u=/^\.tmp-(\d+)-/.exec(i);if(u){let g=l(e,"generations",i),h=Number(u[1]);try{d.push({path:g,size:q(g),live:Number.isSafeInteger(h)&&C(h)})}catch{}continue}if(!/^[a-f0-9]{64}$/.test(i))continue;let p=l(e,"generations",i),y;try{y=b(p)}catch{continue}!y.isDirectory()||y.isSymbolicLink()||o.push({generationId:i,path:p,size:q(p),...r[i]===void 0?{}:{unreferencedAt:r[i]}})}return{leases:s,generations:o,locks:c,temporaries:d}}function T(t){if(t.ownershipChecksum!==M(t)||v(t.localCacheDir)!==v(N(t.projectRoot)))return!1;let e=v(l(m(),"projects"));return v(t.localCacheDir).startsWith(`${e}${V}`)}function he(t){if(!T(t))return!1;let e=P(m()),n=P(l(e,"projects")),r=P(t.localCacheDir);try{let a=b(e),s=b(n),c=b(r);if(!a.isDirectory()||a.isSymbolicLink()||!s.isDirectory()||s.isSymbolicLink()||!c.isDirectory()||c.isSymbolicLink())return!1;let o=U(n);return U(r).startsWith(`${o}${V}`)}catch{return!1}}function ge(t){for(let e of I(l(t,"worktrees"))){if(!e.endsWith(".json"))continue;let n=j(l(t,"worktrees",e));if(n)return n.projectRoot}}function E(t,e=!1){for(let r of e?["index.lock"]:["index.lock","cache-lifecycle.lock"]){let a=D(l(t.localCacheDir,r));if(a!==void 0&&C(a))return!0}let n=D(L(t.localCacheDir).lockPath);return n!==void 0&&C(n)}function j(t){try{let e=JSON.parse(R(t,"worktree cache lease"));return e.version!==1||typeof e.repositoryId!="string"||typeof e.worktreeId!="string"||typeof e.projectRoot!="string"||e.treeOid!==void 0&&typeof e.treeOid!="string"||typeof e.localCacheDir!="string"||e.baseGenerationId!==void 0&&typeof e.baseGenerationId!="string"||e.activeGenerationId!==void 0&&typeof e.activeGenerationId!="string"||typeof e.ownershipChecksum!="string"||!/^[a-f0-9]{64}$/.test(e.ownershipChecksum)||typeof e.lastAction!="string"||e.lastReason!==void 0&&typeof e.lastReason!="string"||typeof e.lastSeenAt!="string"?null:e}catch{return null}}function D(t){try{let e=JSON.parse(R(t,"watch lock record"));return typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0?e.pid:void 0}catch{return}}function te(t){try{let e=JSON.parse(R(t,"repository cache GC state"));return e.version!==1||typeof e.lastSweepAt!="string"||!Number.isFinite(Date.parse(e.lastSweepAt))||!e.unreferencedSince||typeof e.unreferencedSince!="object"||!e.lastResult?null:e}catch{return null}}function re(t){try{let e=JSON.parse(R(t,"global repository cache GC state"));if(e.version!==1||typeof e.lastSweepAt!="string")return;let n=Date.parse(e.lastSweepAt);return Number.isFinite(n)?n:void 0}catch{return}}function I(t){try{return K(t)}catch{return[]}}function q(t){let e=0,n=[t];for(;n.length>0;){let r=n.pop();for(let a of K(r,{withFileTypes:!0})){let s=l(r,a.name);a.isDirectory()?n.push(s):a.isFile()&&(e+=Q(s).size)}}return e}export{Le as a,Ee as b};
3
+ //# sourceMappingURL=chunk-YYFV32WR.js.map
@@ -1,2 +1,2 @@
1
- import{b as i}from"./chunk-UDS562V4.js";function l(n,o,s,t={}){let e=i(n,o,s,t);return e?{symbolA:e.symbolA,symbolB:e.symbolB,similarity:e.similarity,sharedCallees:e.sharedEvidence,uniqueToA:e.uniqueToA,uniqueToB:e.uniqueToB,consolidationStrategy:e.consolidationStrategy}:null}export{l as a};
2
- //# sourceMappingURL=chunk-BH5F2Q4O.js.map
1
+ import{b as i}from"./chunk-A7XQT7MH.js";function l(n,o,s,t={}){let e=i(n,o,s,t);return e?{symbolA:e.symbolA,symbolB:e.symbolB,similarity:e.similarity,sharedCallees:e.sharedEvidence,uniqueToA:e.uniqueToA,uniqueToB:e.uniqueToB,consolidationStrategy:e.consolidationStrategy}:null}export{l as a};
2
+ //# sourceMappingURL=chunk-ZB3V5QM7.js.map
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{d as R,e as k}from"./chunk-D62CTZX6.js";import{i as f,j as L,w as E,x as v}from"./chunk-DUKHVPU5.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 Q}from"path";var c=1,_=1*1024*1024,h=64*1024*1024,y=12e4,x=["NO_COLOR","FORCE_COLOR","CLICOLOR","CLICOLOR_FORCE","TERM","CODEBASEIQ_DEBUG"],O=1500;function P(t){let e=T(),r=b("sha256").update(`${e}\0${t}`).digest("hex");return process.platform==="win32"?`\\\\.\\pipe\\codebaseiq-lane-${r.slice(0,32)}`:Q(Y(),`lane-${r.slice(0,24)}.sock`)}function Y(){let t=T(),e=b("sha256").update(t).digest("hex").slice(0,16);return Q(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,q=2e3,C="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,residentQueryLaneEligible:U}=await import("./cli-context-XEPPF4RX.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-PPVZOIE5.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:O,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[C]==="1")return{kind:"unavailable",reason:`${C}=1 disables the query lane`};let n=B(t);if("reason"in n)return n;let u=r.socketPathOverride??P(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??q)),l=w(h,o=>{if(F(o)){clearTimeout(a),a=setTimeout(()=>i({kind:"unavailable",reason:"query lane response timed out after acknowledgement"}),r.responseTimeoutMs??q);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,_))}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-ZJZQ7Q2Q.js.map
@@ -1,4 +1,4 @@
1
- import{c as S}from"./chunk-WMPRTGH2.js";import{c as m}from"./chunk-7FND7D7N.js";import{h as y}from"./chunk-6CS3UQTN.js";import{a as h}from"./chunk-TIIC3ZE7.js";import{p}from"./chunk-O6QTXQPJ.js";import{a as g}from"./chunk-ADTBPVUZ.js";import f from"path";function W(e,t){let{scope:i,minDeviation:r=5,limit:n=50}=t??{},a=t?.semantic!==!1,u=t?.includePatternDeviations===!0,o=new m(e).fileDependencyGraph(i),l=S(e,{scope:i}),c=x([...D(e,o,{scope:i,semantic:a}),...R(l.forbiddenEdges),...u?E(o,r):[]]);return t?.includeArchitecture===!0&&(c.architecture=l),n<=0||c.results.length<=n?c:{...c,results:c.results.slice(0,n),totalResults:c.results.length}}function D(e,t,i){let r=_(e,i.scope),n=[],a=new Set;for(let[s,o]of t){if(d(s))continue;let l=r.get(s)??new Set;for(let c of o)d(c)||l.has(c)||v(e,s,c,i)||(n.push({file:s,dep:c}),a.add(s))}a.size>0&&w(e,r,{paths:[...a]});let u=[];for(let{file:s,dep:o}of n)(r.get(s)??new Set).has(o)||u.push({file:s,kind:"unused-import",description:`Depends on ${o} but references none of its symbols`,dep:o,actionTier:"direct",evidenceReasons:[`dependency edge exists from ${s} to ${o}`,"no semantic, source, type-only, side-effect, or Vue-template usage survived the conservative skip gates"],recommendation:"Remove the unused import or dependency edge after running the project checks."});return u}function v(e,t,i,r){return C(e,t,i)||M(e,t,i)||O(i)||P(e,t,i)||N(i)?!0:r.semantic&&A(e,t,i)}function R(e){return e.flatMap(t=>{let i=t.examples[0];return i?[{file:i.fromFile,kind:"architecture-violation",description:`${t.from} depends on forbidden boundary ${t.to} through ${t.fileEdgeCount} file edge(s)`,dep:i.toFile,detail:`${t.from} may not depend on ${t.to}`,actionTier:"direct",policyBasis:"explicit",architecture:{fromBoundary:t.from,toBoundary:t.to,fileEdgeCount:t.fileEdgeCount,importerCount:t.importerCount,importedFileCount:t.importedFileCount,examples:t.examples},evidenceReasons:[`configured dependency row for ${t.from} does not allow ${t.to}`,`${t.fileEdgeCount} file edge(s) connect ${t.importerCount} importer(s) to ${t.importedFileCount} imported file(s)`,...t.examples.map(r=>`${r.fromFile} imports ${r.toFile}`)],recommendation:"Move the dependency behind an allowed boundary, reverse the dependency through an owned interface, or deliberately update the project architecture rule."}]:[]})}function E(e,t){let i=[];for(let[r,n]of k(e)){let a=n.filter(s=>!d(s));if(a.length<t)continue;let u=I(e,a);for(let s of a)for(let o of e.get(s)??[])d(o)||(u.get(o)??0)===1&&f.dirname(o)!==r&&f.dirname(o)!==f.dirname(r)&&i.push({file:s,kind:"pattern-deviation",description:`Only file in ${r}/ that depends on ${o}`,dep:o,actionTier:"signal",evidenceReasons:[`${a.length} sibling file(s) in ${r}/ were compared`,`${s} is the only non-skipped sibling depending on ${o}`],recommendation:"Review sibling ownership before changing this import; unique dependency shape can be intentional specialization."})}return i}function x(e){let t=e.filter(i=>i.kind==="architecture-violation").length;return{results:e,unusedImports:e.filter(i=>i.kind==="unused-import").length,architectureViolations:t,layerViolations:t,patternDeviations:e.filter(i=>i.kind==="pattern-deviation").length}}function k(e){let t=new Map;for(let i of e.keys()){let r=f.dirname(i),n=t.get(r);n||(n=[],t.set(r,n)),n.push(i)}return t}function I(e,t){let i=new Map;for(let r of t)for(let n of e.get(r)??[])d(n)||i.set(n,(i.get(n)??0)+1);return i}function _(e,t){let i=new Map;return $(e,i,t),i}function $(e,t,i){for(let r of F(e,i))b(e,t,r.from_file,r.to_file)}function F(e,t){let i=t?"AND d1.relative_path LIKE ?":"",r=t?[`%${t}%`]:[];return e.all(`SELECT DISTINCT d1.relative_path AS from_file, d2.relative_path AS to_file
1
+ import{c as S}from"./chunk-SF34QLK2.js";import{c as m}from"./chunk-NK76RSB6.js";import{h as y}from"./chunk-VCL7FK3E.js";import{a as h}from"./chunk-ZOEDRCR4.js";import{p}from"./chunk-JOALNFY3.js";import{a as g}from"./chunk-RVYLJDXC.js";import f from"path";function W(e,t){let{scope:i,minDeviation:r=5,limit:n=50}=t??{},a=t?.semantic!==!1,u=t?.includePatternDeviations===!0,o=new m(e).fileDependencyGraph(i),l=S(e,{scope:i}),c=x([...D(e,o,{scope:i,semantic:a}),...R(l.forbiddenEdges),...u?E(o,r):[]]);return t?.includeArchitecture===!0&&(c.architecture=l),n<=0||c.results.length<=n?c:{...c,results:c.results.slice(0,n),totalResults:c.results.length}}function D(e,t,i){let r=_(e,i.scope),n=[],a=new Set;for(let[s,o]of t){if(d(s))continue;let l=r.get(s)??new Set;for(let c of o)d(c)||l.has(c)||v(e,s,c,i)||(n.push({file:s,dep:c}),a.add(s))}a.size>0&&w(e,r,{paths:[...a]});let u=[];for(let{file:s,dep:o}of n)(r.get(s)??new Set).has(o)||u.push({file:s,kind:"unused-import",description:`Depends on ${o} but references none of its symbols`,dep:o,actionTier:"direct",evidenceReasons:[`dependency edge exists from ${s} to ${o}`,"no semantic, source, type-only, side-effect, or Vue-template usage survived the conservative skip gates"],recommendation:"Remove the unused import or dependency edge after running the project checks."});return u}function v(e,t,i,r){return C(e,t,i)||M(e,t,i)||O(i)||P(e,t,i)||N(i)?!0:r.semantic&&A(e,t,i)}function R(e){return e.flatMap(t=>{let i=t.examples[0];return i?[{file:i.fromFile,kind:"architecture-violation",description:`${t.from} depends on forbidden boundary ${t.to} through ${t.fileEdgeCount} file edge(s)`,dep:i.toFile,detail:`${t.from} may not depend on ${t.to}`,actionTier:"direct",policyBasis:"explicit",architecture:{fromBoundary:t.from,toBoundary:t.to,fileEdgeCount:t.fileEdgeCount,importerCount:t.importerCount,importedFileCount:t.importedFileCount,examples:t.examples},evidenceReasons:[`configured dependency row for ${t.from} does not allow ${t.to}`,`${t.fileEdgeCount} file edge(s) connect ${t.importerCount} importer(s) to ${t.importedFileCount} imported file(s)`,...t.examples.map(r=>`${r.fromFile} imports ${r.toFile}`)],recommendation:"Move the dependency behind an allowed boundary, reverse the dependency through an owned interface, or deliberately update the project architecture rule."}]:[]})}function E(e,t){let i=[];for(let[r,n]of k(e)){let a=n.filter(s=>!d(s));if(a.length<t)continue;let u=I(e,a);for(let s of a)for(let o of e.get(s)??[])d(o)||(u.get(o)??0)===1&&f.dirname(o)!==r&&f.dirname(o)!==f.dirname(r)&&i.push({file:s,kind:"pattern-deviation",description:`Only file in ${r}/ that depends on ${o}`,dep:o,actionTier:"signal",evidenceReasons:[`${a.length} sibling file(s) in ${r}/ were compared`,`${s} is the only non-skipped sibling depending on ${o}`],recommendation:"Review sibling ownership before changing this import; unique dependency shape can be intentional specialization."})}return i}function x(e){let t=e.filter(i=>i.kind==="architecture-violation").length;return{results:e,unusedImports:e.filter(i=>i.kind==="unused-import").length,architectureViolations:t,layerViolations:t,patternDeviations:e.filter(i=>i.kind==="pattern-deviation").length}}function k(e){let t=new Map;for(let i of e.keys()){let r=f.dirname(i),n=t.get(r);n||(n=[],t.set(r,n)),n.push(i)}return t}function I(e,t){let i=new Map;for(let r of t)for(let n of e.get(r)??[])d(n)||i.set(n,(i.get(n)??0)+1);return i}function _(e,t){let i=new Map;return $(e,i,t),i}function $(e,t,i){for(let r of F(e,i))b(e,t,r.from_file,r.to_file)}function F(e,t){let i=t?"AND d1.relative_path LIKE ?":"",r=t?[`%${t}%`]:[];return e.all(`SELECT DISTINCT d1.relative_path AS from_file, d2.relative_path AS to_file
2
2
  FROM mentions m
3
3
  JOIN chunks c ON m.chunk_id = c.id
4
4
  JOIN documents d1 ON c.document_id = d1.id
@@ -15,4 +15,4 @@ import{c as S}from"./chunk-WMPRTGH2.js";import{c as m}from"./chunk-7FND7D7N.js";
15
15
  AND m.role != 1
16
16
  ${e.pathExclusionsFor("d1","d2")}
17
17
  ${i}`,...r)}function w(e,t,i={}){new m(e).scanSourceReferences({paths:i.paths??g(e,{includeIgnored:!1}),includeRustAttributeNames:!0,identifierResolution:"permissive"},n=>{n.target.relativePath!==n.sourceFile&&(e.isIgnored(n.target.relativePath)||b(e,t,n.sourceFile,n.target.relativePath))})}function b(e,t,i,r){if(e.isIgnored(i)||e.isIgnored(r))return;let n=t.get(i);n||(n=new Set,t.set(i,n)),n.add(r)}function O(e){return e.includes("types")||e.endsWith(".d.ts")}function A(e,t,i){let r=y(e,t).filter(n=>n.sourcePath===i);return r.length>0&&r.some(n=>n.isUsed)}function C(e,t,i){let r=p(e,t).filter(n=>n.sourcePath===i);return r.length>0&&r.some(n=>n.used)}function M(e,t,i){let r=p(e,t).filter(n=>n.sourcePath===i);return r.length>0&&r.every(n=>n.isTypeOnly===!0)}function N(e){return e.endsWith(".vue")}function P(e,t,i){let r=p(e,t).filter(n=>n.sourcePath===i);return r.length===0?!1:r.every(n=>n.kind==="side-effect"||n.kind==="namespace"&&n.usedMembers.length===0&&!n.used)}function d(e){let t=h(e);return!!(t==="entry"||t==="barrel"||t==="test"||t==="worker"||T(f.basename(e)))}function T(e){return!!(e==="index.ts"||e==="index.js"||e==="cli.ts"||e==="main.ts"||e==="main.rs"||e.includes("worker.")||e.includes("postinstall.")||e==="health.ts"||e==="health.js")}export{W as a};
18
- //# sourceMappingURL=chunk-EMNIHCRB.js.map
18
+ //# sourceMappingURL=chunk-ZNQCR656.js.map
@@ -1,2 +1,2 @@
1
- import{c as r}from"./chunk-NNJ2KZZG.js";function _(t){let s=r(t);return i(s)?"test":u(s)?"worker":n(s)?"entry":f(s)?"barrel":"source"}function i(t){return!!(/\.(?:test|spec)\.[a-z0-9]+$/i.test(t)||/(?:^|\/)(?:_)?test_[^/]+$/i.test(t)||/(?:^|\/)spec_[^/]+$/i.test(t)||/(?:^|\/)[^/]+_test\.[a-z0-9]+$/i.test(t)||/(?:^|\/)[^/]+_tests\.rs$/i.test(t)||/(?:^|\/)tests\.rs$/i.test(t)||/(?:^|\/)[^/]+_spec\.[a-z0-9]+$/i.test(t)||/(?:^|\/)__tests__\//i.test(t)||/(?:^|\/)test\//i.test(t)||/(?:^|\/)tests\//i.test(t)||/(?:^|\/)__fixtures__\//i.test(t)||/(?:^|\/)__mocks__\//i.test(t)||/(?:^|\/)test-support\//i.test(t)||/(?:^|\/)test-utils\//i.test(t)||/(?:^|\/)testing\//i.test(t))}function u(t){return/(?:^|\/)[^/]*worker\.(?:ts|tsx|js|mjs|cjs|rs|py|go)$/.test(t)}function n(t){let s=t.split("/"),e=s[s.length-1]??t;return e==="cli.ts"||e==="cli.js"||e==="postinstall.ts"||e==="postinstall.js"||e==="main.ts"||e==="main.js"||e==="main.rs"||e==="main.go"||e==="main.py"||e==="build.rs"||e==="lib.rs"||/\bsrc\/bin\/[^/]+\.rs$/.test(t)||/(?:^|\/)examples\/[^/]+\.rs$/.test(t)||/(?:^|\/)tests\/[^/]+\.rs$/.test(t)||/(?:^|\/)benches\/[^/]+\.rs$/.test(t)?!0:e==="index.ts"||e==="index.js"?/(?:^|\/)(?:apps|services)\/[^/]+\/src\/index\.(?:ts|js)$/.test(t)?!0:s.length<=2:!1}function f(t){return t==="index.ts"||t==="index.js"||t.endsWith("/index.ts")||t.endsWith("/index.js")||t.endsWith("/mod.rs")||t.endsWith("/__init__.py")}export{_ as a};
2
- //# sourceMappingURL=chunk-TIIC3ZE7.js.map
1
+ import{c as r}from"./chunk-327YK6TB.js";function _(t){let s=r(t);return i(s)?"test":u(s)?"worker":n(s)?"entry":f(s)?"barrel":"source"}function i(t){return!!(/\.(?:test|spec)\.[a-z0-9]+$/i.test(t)||/(?:^|\/)(?:_)?test_[^/]+$/i.test(t)||/(?:^|\/)spec_[^/]+$/i.test(t)||/(?:^|\/)[^/]+_test\.[a-z0-9]+$/i.test(t)||/(?:^|\/)[^/]+_tests\.rs$/i.test(t)||/(?:^|\/)tests\.rs$/i.test(t)||/(?:^|\/)[^/]+_spec\.[a-z0-9]+$/i.test(t)||/(?:^|\/)__tests__\//i.test(t)||/(?:^|\/)test\//i.test(t)||/(?:^|\/)tests\//i.test(t)||/(?:^|\/)__fixtures__\//i.test(t)||/(?:^|\/)__mocks__\//i.test(t)||/(?:^|\/)test-support\//i.test(t)||/(?:^|\/)test-utils\//i.test(t)||/(?:^|\/)testing\//i.test(t))}function u(t){return/(?:^|\/)[^/]*worker\.(?:ts|tsx|js|mjs|cjs|rs|py|go)$/.test(t)}function n(t){let s=t.split("/"),e=s[s.length-1]??t;return e==="cli.ts"||e==="cli.js"||e==="postinstall.ts"||e==="postinstall.js"||e==="main.ts"||e==="main.js"||e==="main.rs"||e==="main.go"||e==="main.py"||e==="build.rs"||e==="lib.rs"||/\bsrc\/bin\/[^/]+\.rs$/.test(t)||/(?:^|\/)examples\/[^/]+\.rs$/.test(t)||/(?:^|\/)tests\/[^/]+\.rs$/.test(t)||/(?:^|\/)benches\/[^/]+\.rs$/.test(t)?!0:e==="index.ts"||e==="index.js"?/(?:^|\/)(?:apps|services)\/[^/]+\/src\/index\.(?:ts|js)$/.test(t)?!0:s.length<=2:!1}function f(t){return t==="index.ts"||t==="index.js"||t.endsWith("/index.ts")||t.endsWith("/index.js")||t.endsWith("/mod.rs")||t.endsWith("/__init__.py")}export{_ as a};
2
+ //# sourceMappingURL=chunk-ZOEDRCR4.js.map
@@ -0,0 +1,2 @@
1
+ import{da as a,ea as b,fa as c,ga as d,ha as e,ia as f,ja as g,ka as h,la as i,ma as j,na as k,oa as l,pa as m,qa as n,ra as o,sa as p}from"./chunk-WJOQC4P7.js";import"./chunk-XYLV727H.js";import"./chunk-2VKB5CMA.js";import"./chunk-ACZDU5GK.js";import"./chunk-R2NOK63J.js";import"./chunk-6URCE5QY.js";import"./chunk-4O52YNKL.js";export{b as activateCliProjectContext,n as collect,c as currentCliDatabase,o as formatBytes,p as formatStatus,i as openDb,j as openProjectDb,f as prepareWorktreeIndex,h as residentQueryLaneEligible,e as resolveActiveDbPath,d as resolveCliProjectContext,a as resolveProjectRoot,k as rootIndexFallbackWarning,l as setResidentDatabaseProvider,g as sharedCachePreparationEligible,m as withDb};
2
+ //# sourceMappingURL=cli-context-TSADTXLB.js.map
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{$ as b,_ as a,aa as c,ba as d,ca as e,da as f,ea as g,fa as h,ga as i,ha as j,ia as k,ja as l,ka as m,la as n,ma as o,na as p}from"./chunk-W3FK73MD.js";import"./chunk-G2XUZCF2.js";import"./chunk-DUKHVPU5.js";export{b as activateCliProjectContext,n as collect,c as currentCliDatabase,o as formatBytes,p as formatStatus,i as openDb,j as openProjectDb,f as prepareWorktreeIndex,h as residentQueryLaneEligible,e as resolveActiveDbPath,d as resolveCliProjectContext,a as resolveProjectRoot,k as rootIndexFallbackWarning,l as setResidentDatabaseProvider,g as sharedCachePreparationEligible,m as withDb};
3
+ //# sourceMappingURL=cli-context-XEPPF4RX.js.map
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import{c as K}from"./chunk-RWKEXCHU.js";import{c as Q}from"./chunk-B3UYV66Z.js";import{a as J}from"./chunk-T55YPJGB.js";import{a as h}from"./chunk-YYFV32WR.js";import"./chunk-362QOSFD.js";import{c as F,d as H,e as q,f as W,g as B,h as G}from"./chunk-FIXYHQ3W.js";import{j as _,l as V,n as U}from"./chunk-PHPQ24UG.js";import{p as L,q as z}from"./chunk-CIVYHK7U.js";import"./chunk-N3Q3AWGW.js";import"./chunk-B2OB55RR.js";import{a as v,b as I}from"./chunk-XZEE23VG.js";import{$ as p,N as A,O as R,_ as j,ba as $,ea as k,ka as T}from"./chunk-W3FK73MD.js";import{e as M}from"./chunk-RJWAB4VR.js";import"./chunk-D62CTZX6.js";import{aa as P,ba as O,ca as N,da as S,ea as D,l as s}from"./chunk-G2XUZCF2.js";import{d as E,r as x}from"./chunk-DUKHVPU5.js";import{Command as Pe,Help as Oe}from"commander";import{Option as se}from"commander";function y(e){return e.evidence?e.evidence:ae.has(e.id)?"mixed":e.heuristic?"heuristic":"graph-fact"}var ae=new Set(["health","context","co-change"]);function X(e){if(e.claims){if(e.claims.origin==="mixed"&&!e.claims.families?.length)throw new Error(`Mixed command ${e.id} must declare at least one claim family.`);return e.claims}let t=y(e);if(t==="mixed")throw new Error(`Mixed command ${e.id} must declare claim families.`);let n=e.agent?H(e.agent.operation):[];return n.length>0&&n.every(o=>o==="repository-observation"||o==="repository-preview")?{origin:t==="heuristic"?"heuristic":"compiler-graph",observedSources:["index-generation"],producerValidation:{status:"not-evaluated"}}:{origin:"unknown",observedSources:["process"],producerValidation:{status:"not-evaluated"}}}var Y;function Z(){return Y||{argv:process.argv.slice(2),execPath:process.execPath,...process.argv[1]!==void 0?{scriptPath:process.argv[1]}:{},cwd:process.cwd()}}function ee(e,t){return W(new Map(t.map(n=>[n.id,y(n)]))),G(new Map(t.map(n=>[n.id,X(n)]))),B(new Map(t.flatMap(n=>n.agent?[[n.id,{...n.agent,resultUnits:me(n)}]]:[]))),t.map(n=>{let i=n.hidden?e.command(n.command,{hidden:!0}):e.command(n.command);i.description(n.description),n.helpAfter&&i.addHelpText("after",`
3
+ ${n.helpAfter.trim()}
4
+ `);for(let o of n.arguments??[])i.argument(o.name);for(let o of n.options??[])if(o.hidden){let r=new se(o.flags,o.description).hideHelp();o.parser&&r.argParser(o.parser),Object.hasOwn(o,"defaultValue")&&r.default(o.defaultValue),i.addOption(r)}else o.parser&&Object.hasOwn(o,"defaultValue")?i.option(o.flags,o.description,o.parser,o.defaultValue):o.parser?i.option(o.flags,o.description,o.parser):Object.hasOwn(o,"defaultValue")?i.option(o.flags,o.description,o.defaultValue):i.option(o.flags,o.description);return i.action(async(...o)=>{try{let r=i.optsWithGlobals();ce(r);let a=Z(),d=()=>n.id===_?n.handler(...o):V({command:n.id,producerVersion:s,invocationPrefix:a.scriptPath?[a.execPath,a.scriptPath]:["codebaseiq"],argv:[...a.argv],cwd:a.cwd,json:r.json===!0,sourceSession:r.session!==!1,reemitSource:r.reemit===!0,...typeof r.outputPageSize=="number"?{pageSize:r.outputPageSize}:{},...typeof r.outputCursor=="string"?{cursor:r.outputCursor}:{}},()=>n.handler(...o)),c=n.agent?F(n.agent.operation,{args:o.slice(0,-1),options:r}):void 0;await(c?q(c,d):d())}catch(r){de(r)}finally{p(void 0),R()}}),{descriptor:n,command:i}})}function ce(e){if(e.resultOnly===!0&&e.json!==!0)throw new Error("--result-only requires --json.");if(e.compact===!0&&e.json!==!0)throw new Error("--compact requires --json.")}function me(e){let t=e.agent?.resultUnits;if(t?.kind==="field"&&t.field.trim()==="")throw new Error(`Command ${e.id} declares an empty result-unit field.`);return t||(e.renderShape==="list"||e.renderShape==="table"||e.renderShape==="grouped-by-file"?{kind:"rows"}:{kind:"report"})}function de(e){let t=e instanceof Error?e.message:String(e);console.error(`error: ${I(t)}`),process.exitCode=1}import{existsSync as le,mkdirSync as pe,writeFileSync as ue}from"fs";import{homedir as fe}from"os";import{join as g}from"path";var he=1440*60*1e3,ne="update-check.json",ge="https://registry.npmjs.org/codebaseiq/latest";async function oe(e={}){let t=e.env??process.env;if(t.CODEBASEIQ_UPDATE_CHECK==="0"||t.NO_UPDATE_NOTIFIER)return;let n=e.cacheDir??ye(t),i=e.now??Date.now(),o=e.currentVersion??s,r=be(n),a=r&&i-r.checkedAt<he?r.latestVersion:await we(n,e.fetchLatestVersion??xe,i);if(!a||!ve(a,o))return;(e.writeNotice??(c=>console.error(c)))(Ce(o,a))}function Ce(e,t){return[`codebaseiq update available: ${e} -> ${t}.`,"Agent: tell your human to update with: npm install -g codebaseiq@latest",""].join(`
5
+ `)}function ve(e,t){let n=te(e),i=te(t);if(!n||!i)return e!==t;for(let o=0;o<n.length;o++){let r=n[o]-i[o];if(r>0)return!0;if(r<0)return!1}return!1}function ye(e){let t=e.XDG_CACHE_HOME||g(fe(),".cache");return g(t,"codebaseiq")}function be(e){let t=g(e,ne);if(!le(t))return null;try{let n=JSON.parse(x(t,"update notice cache"));return typeof n.checkedAt=="number"&&(typeof n.latestVersion=="string"||n.latestVersion===null)?{checkedAt:n.checkedAt,latestVersion:n.latestVersion}:null}catch{return null}}async function we(e,t,n){let i;try{i=await t()}catch{i=null}return Ee(e,{checkedAt:n,latestVersion:i}),i}function Ee(e,t){try{pe(e,{recursive:!0}),ue(g(e,ne),`${JSON.stringify(t,null,2)}
6
+ `)}catch{}}async function xe(){let e=await fetch(ge,{signal:AbortSignal.timeout(1e3)});if(!e.ok)return null;let t=await e.json();return typeof t.version=="string"?t.version:null}function te(e){let t=/^v?(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(e);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}async function ct(e={}){let t=new Pe;e.resident&&t.exitOverride(),e.terminalOutput&&t.configureOutput({writeOut:o=>process.stdout.write(v(o)),writeErr:o=>process.stderr.write(v(o))}),t.name("codebaseiq").description("Language-agnostic code intelligence CLI powered by SCIP indexes").version(s).option("--output-page-size <characters>","Return bounded output pages with an exact continuation command",U).option("--output-cursor <cursor>","Continue a bounded output page").option("--no-session","Disable the explicit exploration evidence ledger").option("--reemit","Recovery only: render source and graph evidence again instead of citing session receipts").option("--help-all","Display every command, including compatibility and deprecated controls");let n=await K(e.invocationCommand);ee(t,n);let i=new Oe;return t.configureHelp({formatHelp:(o,r)=>o===t?Q(t,n):i.formatHelp(o,r)}),t.hook("preAction",async(o,r)=>{let a=r.name();if(e.resident){await e.resident.preAction(a);return}let d=k(a),c=L(a);if(!d&&!c){ie(),await re(a);return}let m=j(),u=E(m);A(u);let C=$(m,u);p(C),ie(),await re(a);let{config:b,paths:w}=C;if(d){let l=await J({commandName:a,projectRoot:m,config:b,paths:w,dbPathSource:C.dbPathSource,gitContext:u});process.env.CODEBASEIQ_DEBUG&&console.error(`evidence-freshness: ${l.source}`),l.service.kind==="failed"&&console.error(`warning: codebaseiq watch service did not start: ${l.service.message}`),(l.service.kind==="failed"||l.service.kind==="skipped")&&h(m,s);return}if(!c){h(m,s);return}let f=z({commandName:a,projectRoot:m,cacheDir:w.cacheDir,cliVersion:s,config:b,gitContext:u});f.kind==="failed"&&console.error(`warning: codebaseiq watch service did not start: ${f.message}`),(f.kind==="failed"||f.kind==="skipped")&&h(m,s)}),t.hook("postAction",()=>p(void 0)),{program:t,descriptors:n}}async function re(e){e.startsWith("__")||await oe({commandName:e})}function ie(){if(N(),!P()||S())return;let e=null;try{e=T(t=>M(t))}catch{}D({command:O()??`codebaseiq ${process.argv.slice(2).join(" ")}`,toolVersion:s,projectFingerprint:e})}export{ct as createCliProgram};
7
+ //# sourceMappingURL=cli-program-KJGQEM72.js.map
package/dist/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{b as n}from"./chunk-QCN62RTF.js";import{d as s}from"./chunk-XZEE23VG.js";import"./chunk-DO6WQD2T.js";import"./chunk-SNNWPCN7.js";import{realpathSync as p}from"fs";import{fileURLToPath as y}from"url";import{constants as a,setPriority as u}from"os";var m="CODEBASEIQ_PROCESS_PRIORITY";function P(r=process.env){let o=r[m]?.trim().toLowerCase();return o==="low"||o==="idle"?o:null}function c(r=process.env,o=u){let e=P(r);if(e===null)return null;let t=e==="idle"?a.priority.PRIORITY_LOW:a.priority.PRIORITY_BELOW_NORMAL;try{o(t)}catch{}return e}f()&&(c(),s(),await d());async function d(){let r=process.argv.includes("--help-all");if(!r){let i=await n(process.argv.slice(2));if(i.served)return;process.env.CODEBASEIQ_DEBUG&&console.error(`query-lane: ${i.reason}`)}let{normalizeLegacyEvidenceInvocation:o}=await import("./invocation-command-descriptors-QT2JMY5J.js");o(process.argv);let{createCliProgram:e}=await import("./cli-program-YNOXO72B.js"),{program:t,descriptors:l}=await e({...process.argv[2]!==void 0?{invocationCommand:process.argv[2]}:{},terminalOutput:!0});if(r){let{renderRootCommandHelp:i}=await import("./command-panels-SZONPMLJ.js");process.stdout.write(i(t,l,{includeCompatibility:!0}));return}await t.parseAsync()}function f(){if(!process.argv[1])return!1;let r=y(import.meta.url);try{return p(r)===p(process.argv[1])}catch{return r===process.argv[1]}}
2
+ import{b as n}from"./chunk-ZJZQ7Q2Q.js";import{d as s}from"./chunk-XZEE23VG.js";import"./chunk-D62CTZX6.js";import"./chunk-DUKHVPU5.js";import{realpathSync as p}from"fs";import{fileURLToPath as y}from"url";import{constants as a,setPriority as u}from"os";var m="CODEBASEIQ_PROCESS_PRIORITY";function P(r=process.env){let o=r[m]?.trim().toLowerCase();return o==="low"||o==="idle"?o:null}function c(r=process.env,o=u){let e=P(r);if(e===null)return null;let t=e==="idle"?a.priority.PRIORITY_LOW:a.priority.PRIORITY_BELOW_NORMAL;try{o(t)}catch{}return e}f()&&(c(),s(),await d());async function d(){let r=process.argv.includes("--help-all");if(!r){let i=await n(process.argv.slice(2));if(i.served)return;process.env.CODEBASEIQ_DEBUG&&console.error(`query-lane: ${i.reason}`)}let{normalizeLegacyEvidenceInvocation:o}=await import("./invocation-command-descriptors-PPVZOIE5.js");o(process.argv);let{createCliProgram:e}=await import("./cli-program-KJGQEM72.js"),{program:t,descriptors:l}=await e({...process.argv[2]!==void 0?{invocationCommand:process.argv[2]}:{},terminalOutput:!0});if(r){let{renderRootCommandHelp:i}=await import("./command-panels-SZONPMLJ.js");process.stdout.write(i(t,l,{includeCompatibility:!0}));return}await t.parseAsync()}function f(){if(!process.argv[1])return!1;let r=y(import.meta.url);try{return p(r)===p(process.argv[1])}catch{return r===process.argv[1]}}
3
3
  //# sourceMappingURL=cli.js.map
@@ -1,5 +1,5 @@
1
1
  import { S as SourceObservationFreshness } from './repository-text-C0Q8VYdN.js';
2
- import { S as ScipDatabase } from './db-D7sauVFH.js';
2
+ import { S as ScipDatabase } from './db-DmRNdCtm.js';
3
3
  import { OutlineNode } from './queries/outline.js';
4
4
 
5
5
  interface BindingDefinitionEvidence {
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import{a as ke}from"./chunk-T55YPJGB.js";import{a as Me,b as Fe}from"./chunk-FQA3KIFX.js";import{r as xe}from"./chunk-CIVYHK7U.js";import{H as ee,X as Ee,f as ve,v as Re,w as Z}from"./chunk-N3Q3AWGW.js";import"./chunk-B2OB55RR.js";import"./chunk-XZEE23VG.js";import{K as ge,_ as be,a as I,b as pe,ba as X,c as me,ha as he}from"./chunk-W3FK73MD.js";import"./chunk-EN4AHLL3.js";import{Ha as Se,ca as Q,ga as q,ha as C,ia as U,k as O,m as ye,ta as we}from"./chunk-RJWAB4VR.js";import"./chunk-D62CTZX6.js";import{E as ue,F as le,X as de,Z as fe,l as z}from"./chunk-G2XUZCF2.js";import{d as oe,i as Y,j as se,k as ie,p as ae,r as ce}from"./chunk-DUKHVPU5.js";import{rmSync as En}from"fs";import{createConnection as xn}from"net";import{basename as Mn,join as Fn,resolve as dt}from"path";import{spawn as wt}from"child_process";var St=/^https?:\/\//iu,vt=2e3;function Le(e,t={}){let n=t.platform??process.platform,r=t.env??process.env;if(!St.test(e))return Promise.resolve({launched:!1});if(Et(r.CI))return Promise.resolve({launched:!1});if(n!=="win32"&&n!=="darwin"&&!r.DISPLAY&&!r.WAYLAND_DISPLAY)return Promise.resolve({launched:!1});let{command:s,args:o}=Rt(n,e);return new Promise(i=>{let a;try{a=(t.spawn??wt)(s,o,{detached:!0,stdio:"ignore",windowsHide:!0})}catch{i({launched:!1});return}let d=m=>{clearTimeout(p),i({launched:m})},p=setTimeout(()=>d(!0),vt);a.once("spawn",()=>d(!0)),a.on("error",()=>d(!1)),a.unref()})}function Rt(e,t){return e==="win32"?{command:"rundll32.exe",args:["url.dll,FileProtocolHandler",t]}:e==="darwin"?{command:"open",args:[t]}:{command:"xdg-open",args:[t]}}function Et(e){return e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false"}var xt=5;function j(e){let t=e.trim().replace(/\\/g,"/");for(;t.startsWith("./");)t=t.slice(2);return t=t.replace(/^\/+/,"").replace(/\/+$/,""),t==="."?"":t}function Mt(e,t,n,r){let s=j(n),o=s?`${s}/`:"",i=[...new Set(e)].filter(l=>l.startsWith(o)).sort(F);if(i.length===0)return null;let a=new Set(i),d=new Map;for(let l of i){let f=l.slice(o.length),w=f.indexOf("/"),c=w<0?l:`${o}${f.slice(0,w)}`,u=d.get(c)??{kind:w<0?"file":"dir",files:[]};u.files.push(l),d.set(c,u)}let p=new Map,m=[];for(let[l,f]of d){let w=f.kind==="dir"?Ft(f.files):l;for(let c of f.files)p.set(c,w);m.push({id:w,kind:f.kind,name:f.kind==="dir"?w.slice(o.length):l.slice(o.length),path:w,files:f.files.length,internalEdges:0,cycle:null})}m.sort((l,f)=>(l.kind===f.kind?0:l.kind==="dir"?-1:1)||F(l.name,f.name));let b=new Map(m.map(l=>[l.id,l])),M=s?s.split("/"):[],y=new Map,R=new Map,x=0,E=(l,f,w)=>{x+=1;let c=`${l}\0${f}`,u=y.get(c)??{from:l,to:f,count:0,cycle:!1,samples:[]};u.count+=1,u.samples.length<xt&&u.samples.push(w),y.set(c,u)},P=l=>{let f=kt(M,l);return R.has(f)||R.set(f,{id:f,kind:"external",path:f}),f};for(let l of[...t.keys()].sort(F)){let f=a.has(l);for(let w of[...t.get(l)].sort(F)){let c=a.has(w);if(!f&&!c||!f&&l.startsWith(o)||!c&&w.startsWith(o))continue;let u={from:l,to:w};if(f&&c){let g=p.get(l),h=p.get(w);g===h?(x+=1,b.get(g).internalEdges+=1):E(g,h,u)}else f?E(p.get(l),P(w),u):E(P(l),p.get(w),u)}}let S=Lt(m,y);for(let l of m)l.cycle=S.get(l.id)??null;for(let l of y.values()){let f=S.get(l.from);l.cycle=f!==void 0&&f===S.get(l.to)}return{scope:s,basis:r,breadcrumbs:Dt(M),nodes:m,external:[...R.values()].sort((l,f)=>F(l.path,f.path)),edges:[...y.values()].sort((l,f)=>F(l.from,f.from)||F(l.to,f.to)),totals:{files:i.length,edges:x}}}function De(e,t){return Mt(O(e,{includeIgnored:!1}),Oe(e,t.basis),t.scope,t.basis)}function Pe(e,t){let n=O(e,{includeIgnored:!1}),r=j(t);for(;r;){let s=`${r}/`;if(n.some(i=>i.startsWith(s)))return r;let o=r.lastIndexOf("/");r=o<0?"":r.slice(0,o)}return""}function Ve(e,t,n){let r=j(t);if(!O(e,{includeIgnored:!1}).includes(r))return null;let s=Oe(e,n),o=[];for(let[i,a]of s)a.has(r)&&o.push(i);return{file:r,dependsOn:[...s.get(r)??[]].sort(F),dependedOnBy:o.sort(F)}}function Oe(e,t){return t==="imports"?Q(e,void 0,{scipEdges:"imports-only",sourceEdges:"imports-and-reexports"}):Q(e)}function Ft(e){let t=e.map(r=>r.split("/").slice(0,-1)),n=[...t[0]];for(let r of t){let s=0;for(;s<n.length&&s<r.length&&n[s]===r[s];)s+=1;n.length=s}return n.join("/")}function kt(e,t){let n=t.split("/"),r=0;for(;r<e.length&&r<n.length&&e[r]===n[r];)r+=1;return n.slice(0,r+1).join("/")}function Lt(e,t){let n=new Map(e.map(o=>[o.id,new Set]));for(let o of t.values())n.has(o.from)&&n.has(o.to)&&n.get(o.from).add(o.to);let r=Ee(n).components.filter(o=>o.length>1).map(o=>[...o].sort(F)).sort((o,i)=>F(o[0],i[0])),s=new Map;return r.forEach((o,i)=>{for(let a of o)s.set(a,i+1)}),s}function Dt(e){return[{name:"root",path:""},...e.map((t,n)=>({name:t,path:e.slice(0,n+1).join("/")}))]}function F(e,t){return e<t?-1:e>t?1:0}var Ce=["callers","callees","contracts","data","state","runtime"],Pt={families:["execution","identity","contract","dataflow","state","runtime"],subtypes:["call","result-callback","references","uses-contract-symbol","argument-to-parameter","constant-to-parameter","property-to-parameter","return-to-parameter","return-to-call-result","reads-resource","writes-resource","deletes-resource","enqueues-resource","consumes-resource","runtime-handoff","discriminator-dispatch"],direction:"both",maxDepth:1,maxEdges:2e3},Ne={exact:0,derived:1,mixed:2,candidate:3,unknown:4},N="root",Vt=new Set(["source-construct","runtime-boundary-participant","call-result","argument-expression","static-value"]);function _e(e,t){let n=t.trim();if(!n)return{status:"missing"};let r=Se(e,n),s=r.match;if(!s)return{status:"missing"};let o=new Map,i=(a,d,p)=>{o.has(a)||o.set(a,{symbol:a,name:q(a),file:d,line:p})};i(s.symbol,s.relativePath,s.startLine);for(let a of r.candidates)i(a.symbol,a.relativePath,a.startLine);return o.size===1&&At(n,s)?{status:"matched",symbol:s.symbol}:{status:"ambiguous",candidates:[...o.values()],total:r.total}}function $e(e,t,n={}){let r=ee(e,{symbols:[t]},Pt),s=r.targets[0]?.nodeIds[0],o=s?Bt(r,s):null,i=s&&o?qe(r,s,It(o)):Tt(r);if(!n.statements)return i;let a=ee(e,{symbols:[t]},{view:"complete",maxDepth:1,maxEdges:400});return{...i,statements:{inventory:a.inventory??[],edges:a.edges.map(jt)}}}function qe(e,t,n){let r=new Map(Ce.map(i=>[i,new Map])),s=[];for(let i of e.edges){let a=Te(i.from,t,n),d=Te(i.to,t,n);if(!a||!d)continue;let p,m;if(a===N&&d!==N)p=!1,m=d;else if(d===N&&a!==N)p=!0,m=a;else continue;if(i.family==="identity"){p&&i.subtype==="references"&&s.push({target:m,edge:i});continue}let b=Ot(i,p);b&&je(r.get(b),m,i,!1)}let o=r.get("callers");for(let{target:i,edge:a}of s){let d=o.get(i.key);(!d||d.reference)&&je(o,i,a,!0)}return{lanes:Object.fromEntries(Ce.map(i=>[i,Nt(r.get(i))])),coverage:{status:e.coverage.status,omittedEdges:e.coverage.omittedEdges}}}function Ot(e,t){let{family:n,subtype:r}=e;return n==="execution"&&(r==="call"||r==="result-callback")?t?"callers":"callees":n==="contract"&&r==="uses-contract-symbol"?t?null:"contracts":n==="dataflow"&&(r.endsWith("-to-parameter")||r==="return-to-call-result")?"data":n==="state"?"state":n==="runtime"?"runtime":null}function Te(e,t,n){if(e.id===t)return N;if(e.kind==="symbol"&&e.symbol)return Be(e.symbol,e.label,e);if(e.kind==="structural-region")return{key:`region:${e.id}`,kind:"region",label:e.label};if(e.kind==="program-resource"||e.kind==="runtime-state-resource")return{key:`resource:${e.id}`,kind:"resource",label:e.label,...te(e),...e.kind==="program-resource"&&Ie(e,n)?{local:!0}:{}};if(Ie(e,n))return N;if(e.location&&Vt.has(e.kind))return{key:`location:${e.id}`,kind:"location",label:e.label,...te(e)};let r=Ct(e);return r?Be(r,q(r),e):null}function Be(e,t,n){return{key:`symbol:${e}`,kind:"symbol",label:t,symbol:e,...te(n)}}function te(e){return e.location?{file:e.location.file,line:e.location.line}:{}}function Ie(e,t){return e.location!==null&&e.location.file===t.file&&e.location.line>=t.startLine&&e.location.line<=t.endLine}function Ct(e){if(e.kind!=="parameter")return null;let[t,n]=e.id.split(":");return t==="parameter"&&n?decodeURIComponent(n):null}function je(e,t,n,r){let s=e.get(t.key);if(!s){e.set(t.key,{kind:t.kind,label:t.label,...t.symbol?{symbol:t.symbol}:{},...t.file!==void 0?{file:t.file,line:t.line}:{},subtypes:[n.subtype],count:1,strength:n.evidenceStrength,...t.local?{local:!0}:{},...r?{reference:!0}:{}});return}s.count+=1,s.subtypes.includes(n.subtype)||s.subtypes.push(n.subtype),Ne[n.evidenceStrength]<Ne[s.strength]&&(s.strength=n.evidenceStrength)}function Nt(e){return[...e.values()].map(t=>({...t,subtypes:[...t.subtypes].sort()})).sort((t,n)=>Ae(t.label,n.label)||Ae(t.file??"",n.file??"")||(t.line??0)-(n.line??0))}function Tt(e){return qe({...e,edges:[]},"",{file:"",startLine:0,endLine:-1})}function Bt(e,t){for(let n of e.edges){if(n.from.id===t)return n.from;if(n.to.id===t)return n.to}return null}function It(e){return e.location?{file:e.location.file,startLine:e.location.line,endLine:e.location.endLine??e.location.line}:{file:"",startLine:0,endLine:-1}}function jt(e){return{id:e.id,family:e.family,subtype:e.subtype,from:e.from,to:e.to,strength:e.evidenceStrength,methods:e.evidenceMethods}}function At(e,t){if(e===t.symbol)return!0;let n=e.replace(/\\/g,"/").replace(/\(\)$/u,""),r=C(t.symbol);if(n===q(t.symbol).replace(/\(\)$/u,"")||n===r)return!0;let s=e.match(/^(.+):(\d+)(?:-(\d+))?$/);if(s){let i=ye(s[1]);return t.relativePath===i||t.relativePath.endsWith(`/${i}`)}let o=n.lastIndexOf("/");return o>0&&n.slice(o+1)===r&&t.relativePath.toLowerCase().includes(n.slice(0,o).toLowerCase())}function Ae(e,t){return e<t?-1:e>t?1:0}function Ue(e){let t=e.published??fe,n=e.open(),r=null,s=o=>{try{o.close()}catch{}};return{acquire(){if(!n)throw new Error("The viewer database is closed.");let o=t(e.dbPath);if(o!==null&&o!==n.generation.identity&&o!==r)try{let i=e.open();s(n),n=i,r=o}catch{}return n},generation(){return n?.generation.identity??null},close(){let o=n;n=void 0,o&&s(o)}}}import{posix as Ge,resolve as _t}from"path";var He=400,We=2e3,$t=["callers","callees","contracts","data","state","runtime"],qt=4096,Ut=/:\d+(?:-\d+)?$/u,Gt=/^\s*```[^\n]*\n[\s\S]*?```[^\S\n]*(?:\n|$)/u;function Ye(e,t){return{status:200,body:{projectRoot:t.projectRoot,projectName:t.meta.projectName,cliVersion:t.meta.cliVersion,generation:D(e),watcher:{state:t.meta.watcherState()},builder:{available:t.meta.builder.available,modes:[...I],defaultMode:t.meta.builder.defaultMode}}}}function ze(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path")??"",o=B(s);if(o===null)return L(e,`Path is outside the project: ${T(s)}`,{nearest:""});let i=n.queries.normalizeMapScope(o),a=n.queries.codeMapScope(e,{scope:i,basis:r});return a?{status:200,body:{...a,generation:D(e)}}:L(e,`No indexed files under "${i}".`,{nearest:n.queries.nearestMapScope(e,i)})}function Xe(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path");if(!s)return k(e,"path is required.");let o=B(s);if(o===null||o===""||!n.queries.isIndexedFile(e,o))return L(e,`No indexed file at "${T(s)}".`);let i=n.queries.codeMapFile(e,o,r);return{status:200,body:{file:o,breadcrumbs:Yt(o),editorUri:ne(n.projectRoot,o,1),outline:tt(e,o,n),dependsOn:i?.dependsOn??[],dependedOnBy:i?.dependedOnBy??[],stale:n.queries.fileIsStale(e,o),generation:D(e)}}}function Qe(e,t,n){let r=t.get("symbol"),s=t.get("focus"),o=r||s;if(!o)return k(e,"symbol or focus is required.");if(o.length>qt)return k(e,"The selector is too long.");let i=r||"";if(!r){let S=n.queries.resolveFocus(e,o);if(S.status==="ambiguous")return{status:200,body:{status:"ambiguous",candidates:S.candidates.map(l=>({symbol:l.symbol,name:l.name,file:l.file,line:l.line+1})),total:S.total,generation:D(e)}};if(S.status==="missing")return L(e,`No symbol matches "${T(o)}".`);i=S.symbol}let a=Ut.test(i)?null:n.queries.code(e,i);if(!a||a.symbol!==i||a.symbol===a.relativePath||!n.queries.isIndexedFile(e,a.relativePath))return L(e,`No indexed definition for "${T(i)}".`);let d=a.relativePath,p=nt(tt(e,d,n),i),m=n.queries.fileSymbolFacts(e,d);if(!p&&!m.has(i))return L(e,`No indexed definition for "${T(i)}".`);let b=m.get(i),M=t.get("statements")==="1",y=n.queries.symbolFocusLanes(e,i,M?{statements:!0}:void 0),R=a.startLine+1,x=a.source.split(`
3
+ `),E=x.length>He,P=E?x.slice(0,He):x;return{status:200,body:{status:"matched",definition:{symbol:i,name:C(i),file:d,startLine:R,endLine:a.endLine+1,signature:p?.entry.signature??null,documentation:Wt(b?.documentation),editorUri:ne(n.projectRoot,d,R)},parent:p?.parent?{symbol:p.parent.symbol,name:p.parent.name}:null,members:(p?.entry.children??[]).map(S=>({symbol:S.symbol,name:S.name,line:S.startLine})),lanes:Qt(y.lanes,n.projectRoot),fileImports:n.queries.codeMapFile(e,d,"imports")?.dependsOn??[],coverage:y.coverage,source:{startLine:R,endLine:R+P.length-1,text:P.join(`
4
+ `),truncated:E,stale:et(a)},...M&&y.statements?{statements:Jt(y.statements)}:{},generation:D(e)}}}function Ze(e,t,n){let r=t.get("file");if(!r)return k(e,"file is required.");let s=t.get("start"),o=t.get("end"),i=s===null?1:Ke(s);if(i===null)return k(e,"start must be a positive integer.");let a=o===null?i+We-1:Ke(o);if(a===null||a<i)return k(e,"end must be an integer at or after start.");let d=B(r);if(d===null||d===""||!n.queries.isIndexedFile(e,d))return L(e,`No indexed file at "${T(r)}".`);let p=Math.min(a,i+We-1),m=n.queries.code(e,`${d}:${i}-${p}`);return m?{status:200,body:{file:d,startLine:m.startLine+1,endLine:m.endLine+1,text:m.source,stale:et(m),generation:D(e)}}:L(e,`Lines ${i}-${p} are outside "${d}".`)}function B(e){if([...e].some(r=>r.charCodeAt(0)<32))return null;let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:/u.test(t))return null;let n=t.split("/").filter(r=>r!==""&&r!==".");return n.includes("..")?null:n.join("/")}function ne(e,t,n){return Ht(_t(e,t),n)}function Ht(e,t){let r=e.replaceAll("\\","/").replace(/[%#? ]/gu,s=>encodeURIComponent(s));return`vscode://file${r.startsWith("/")?"":"/"}${r}:${t}`}function Wt(e){if(!e)return null;let t=e.replace(Gt,"").trim();return t===""?null:t}function et(e){return e.freshness?.semantic.state==="stale"}function Jt(e){return{...e,edges:e.edges.map(Kt)}}function Kt(e){return{...e,from:Je(e.from),to:Je(e.to)}}function Je(e){let{location:t}=e;return t?{...e,location:{...t,line:t.line+1,...t.endLine!==void 0?{endLine:t.endLine+1}:{}}}:e}function Yt(e){let t=[{name:"root",path:""}],n="";for(let r of e.split("/"))n=n===""?r:`${n}/${r}`,t.push({name:r,path:n});return t}function tt(e,t,n){let r=n.queries.fileSymbolFacts(e,t),s=Xt(t),o=n.queries.outline(e,t).flatMap(a=>U(a.symbol)==="namespace"&&s.has(C(a.symbol))?a.children:[a]),i=(a,d)=>({symbol:a.symbol,name:C(a.symbol),kind:r.get(a.symbol)?.kind??zt(a.symbol,d),startLine:a.startLine+1,endLine:a.endLine+1,signature:a.signature,children:a.children.map(p=>i(p,a.symbol))});return o.map(a=>i(a))}function zt(e,t){let n=U(e);return n==="method"?t!==void 0&&U(t)==="type"?"method":"function":n==="term"?"variable":n??"unknown"}function Xt(e){let t=Ge.basename(e);return new Set([t,t.slice(0,Math.max(0,t.length-Ge.extname(t).length))])}function nt(e,t,n=null){for(let r of e){if(r.symbol===t)return{entry:r,parent:n};let s=nt(r.children,t,r);if(s)return s}return null}function Qt(e,t){let n={};for(let r of $t)n[r]=(e[r]??[]).map(s=>{let{line:o,...i}=s,a={...i};return o!==void 0&&(a.line=o+1),s.file!==void 0&&(a.editorUri=ne(t,s.file,(o??0)+1)),a});return n}function rt(e){return e===null||e===""?"references":e==="references"||e==="imports"?e:null}function Ke(e){if(!/^\d{1,9}$/u.test(e))return null;let t=Number(e);return t>=1?t:null}function D(e){return e.generation.identity}function k(e,t){return{status:400,body:{error:t,generation:D(e)}}}function L(e,t,n={}){return{status:404,body:{error:t,...n,generation:D(e)}}}function T(e){return e.length>200?`${e.slice(0,200)}...`:e}import{createHash as ct,randomBytes as Zt,timingSafeEqual as en}from"crypto";import{existsSync as A}from"fs";import{createServer as tn}from"http";import{createRequire as nn}from"module";import{dirname as rn,join as H}from"path";import{fileURLToPath as on}from"url";var _="127.0.0.1",sn=80,an="__CODEBASEIQ_TOKEN__",cn="x-codebaseiq-token",ot=64*1024,un=18e4,st=50,it=["reuse","rework","compose"],ln="cytoscape.esm.min.mjs",dn=["index.html","styles.css","app.js","api.js","map.js","file-panel.js","focus.js","builder.js"],fn={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".js":"text/javascript; charset=utf-8"},pn=["default-src 'self'","script-src 'self'","style-src 'self' 'unsafe-inline'","img-src 'self' data:","connect-src 'self'","frame-ancestors 'none'"].join("; ");function mn(){for(let e of["../ui/view/","../../../ui/view/"]){let t=on(new URL(e,import.meta.url));if(A(H(t,"index.html")))return t}}function gn(){try{let e=nn(import.meta.url).resolve("cytoscape"),t=H(rn(e),ln);return A(t)?t:void 0}catch{return}}function at(e,t){return{body:ae(e,{maxBytes:ie,inputKind:"viewer asset"}),contentType:t}}function bn(e,t){let n=e.uiDirectory??mn();if(!n||!A(H(n,"index.html")))throw new Error("The viewer UI files were not found; reinstall codebaseiq or rebuild the package.");let r=new Map;for(let i of dn){let a=H(n,i);if(!A(a))continue;let d=at(a,fn[i.slice(i.lastIndexOf("."))]??"application/octet-stream");r.set(i,i==="index.html"?{...d,body:Buffer.from(d.body.toString("utf8").replaceAll(an,t),"utf8")}:d)}let s=e.cytoscapePath??gn(),o=s&&A(s)?at(s,"text/javascript"):void 0;return{assets:r,...o?{vendor:o}:{}}}async function ut(e){let t=e.token??Zt(24).toString("base64url"),{assets:n,vendor:r}=bn(e,t),s=e.builderTimeoutMs??un,o=ct("sha256").update(t).digest(),i=0,a=!1,d=new Set,p=()=>lt(i),m=()=>yn(i),b=(c,u,g)=>{let h=JSON.stringify({generation:e.database.generation(),...g});c.writeHead(u,{...G(),"Content-Type":"application/json; charset=utf-8","Content-Length":Buffer.byteLength(h)}),c.end(h)},M=(c,u)=>{c.writeHead(200,{...G(),"Content-Type":u.contentType,"Content-Length":u.body.byteLength,...u.contentType.startsWith("text/html")?{"Content-Security-Policy":pn}:{}}),c.end(u.body)},y=(c,u,g,h={})=>{c.writeHead(u,{...G(),"Content-Type":"text/plain; charset=utf-8","Content-Length":Buffer.byteLength(g),...h}),c.end(g)},R=(c,u,g)=>{let h=hn.get(u);if(!h){b(c,404,{error:"Not found."});return}let v=h(e.database.acquire(),g,e.routes);b(c,v.status,v.body)},x=(c,u)=>{if(u==="/"){let v=n.get("index.html");v?M(c,v):y(c,404,"Not found.");return}if(u==="/favicon.ico"){c.writeHead(204,G()),c.end();return}if(u==="/vendor/cytoscape.mjs"&&r){M(c,r);return}let g=u.startsWith("/assets/")?u.slice(8):void 0,h=g===void 0?void 0:n.get(g);h?M(c,h):y(c,404,"Not found.")},E=async(c,u)=>{let g=c.headers.origin;if(g!==void 0&&!m().has(g)){b(u,403,{error:"Origin is not allowed."});return}if(!wn(c.headers["content-type"])){b(u,415,{error:"Content-Type must be application/json."});return}if(!Sn(o,c.headers[cn])){b(u,403,{error:"The viewer token is missing or wrong; reload the page."});return}let h=e.builder;if(!h){b(u,501,{error:"The symbol builder is not available in this viewer."});return}if(a){b(u,409,{error:"A builder query is already running."});return}a=!0;try{let v=await vn(c,ot);if(v===void 0){b(u,400,{error:`The request body must be at most ${ot/1024} KiB.`});return}let V=Rn(v);if(!V.ok){b(u,400,{error:V.error});return}await P(u,h,V.request,V.diagnostics)}finally{a=!1}},P=async(c,u,g,h)=>{let v=new AbortController;d.add(v);let V=()=>{c.writableEnded||v.abort(new Error("The client disconnected."))};c.on("close",V);let W;try{let $=await new Promise(J=>{W=setTimeout(()=>{v.abort(new Error("The builder query timed out.")),J({kind:"timeout"})},s),u(g,v.signal).then(K=>J({kind:"done",response:K}),K=>J({kind:"failed",error:K}))});if(c.destroyed)return;$.kind==="timeout"?b(c,504,{error:`The builder query took longer than ${Math.round(s/1e3)} s.`}):$.kind==="failed"?b(c,502,{error:re($.error)}):b(c,200,{...$.response,...h.length>0?{probeDiagnostics:h}:{}})}finally{W&&clearTimeout(W),c.off("close",V),d.delete(v)}},S=async(c,u)=>{if(!p().has((c.headers.host??"").toLowerCase())){y(u,403,"Forbidden host.");return}let g;try{g=new URL(c.url??"/",`http://${_}`)}catch{y(u,400,"Bad request.");return}let h=c.method??"GET";if(g.pathname==="/api/builder"){h==="POST"?await E(c,u):b(u,405,{error:"Use POST."});return}if(h!=="GET"&&h!=="HEAD"){y(u,405,"Method not allowed.",{Allow:"GET, HEAD"});return}g.pathname.startsWith("/api/")?R(u,g.pathname,g.searchParams):x(u,g.pathname)},l=tn((c,u)=>{S(c,u).catch(g=>{if(u.headersSent){u.destroy();return}b(u,500,{error:re(g)})})});await new Promise((c,u)=>{l.once("error",u),l.listen({host:_,port:e.port??0},()=>{l.off("error",u),c()})}),l.on("error",c=>{process.stderr.write(`codebaseiq view: server error: ${re(c)}
5
+ `)});let f=l.address();i=typeof f=="object"&&f?f.port:0;let w=`http://${_}:${i}`;return{port:i,origin:w,url:`${w}/`,token:t,close(){for(let c of d)c.abort(new Error("The viewer is shutting down."));return new Promise(c=>{l.close(()=>c()),l.closeAllConnections()})}}}var hn=new Map([["/api/meta",(e,t,n)=>Ye(e,n)],["/api/scope",ze],["/api/file",Xe],["/api/symbol",Qe],["/api/source",Ze]]);function lt(e){let t=new Set([`${_}:${e}`,`localhost:${e}`]);return e===sn&&(t.add(_),t.add("localhost")),t}function yn(e){return new Set([...lt(e)].map(t=>`http://${t}`))}function G(){return{"Cache-Control":"no-store","X-Content-Type-Options":"nosniff","Referrer-Policy":"no-referrer"}}function wn(e){return e!==void 0&&e.split(";")[0].trim().toLowerCase()==="application/json"}function Sn(e,t){return typeof t!="string"||t===""?!1:en(ct("sha256").update(t).digest(),e)}function vn(e,t){return new Promise((n,r)=>{let s=[],o=0,i=!1;e.on("data",a=>{o+=a.byteLength,o>t?(i=!0,s.length=0):i||s.push(a)}),e.on("end",()=>n(i?void 0:Buffer.concat(s).toString("utf8"))),e.on("error",r)})}function Rn(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:"The request body must be valid JSON."}}if(typeof t!="object"||t===null||Array.isArray(t))return{ok:!1,error:"The request body must be a JSON object."};let n=t,r={},s=[];if(n.description!==void 0){if(typeof n.description!="string")return{ok:!1,error:"description must be a string."};n.description.trim()!==""&&(r.description=n.description)}if(n.probes!==void 0){let o=me(n.probes);s=o.diagnostics,(pe(o.probes)||o.probes.kinds.length>0)&&(r.probes=o.probes)}if(n.mode!==void 0){if(typeof n.mode!="string"||!I.includes(n.mode))return{ok:!1,error:`mode must be one of ${I.join(", ")}.`};r.mode=n.mode}if(n.bucket!==void 0){if(typeof n.bucket!="string"||!it.includes(n.bucket))return{ok:!1,error:`bucket must be one of ${it.join(", ")}.`};r.bucket=n.bucket}if(n.limit!==void 0){let o=n.limit;if(typeof o!="number"||!Number.isInteger(o)||o<1||o>st)return{ok:!1,error:`limit must be an integer from 1 to ${st}.`};r.limit=o}return r.description===void 0&&r.probes===void 0?{ok:!1,error:"Give a description or at least one probe."}:{ok:!0,request:r,diagnostics:s}}function re(e){return e instanceof Error?e.message:String(e)}var kn="view-server.json",ft="127.0.0.1",Ln=1e3,Dn=5e3,Pn=2e3,gt={isProcessAlive:se,canConnect(e,t){return new Promise(n=>{let r=xn({host:ft,port:e}),s=o=>{r.destroy(),n(o)};r.setTimeout(t,()=>s(!1)),r.once("connect",()=>s(!0)),r.once("error",()=>s(!1))})},async fetchProjectRoot(e,t){try{let n=await fetch(`http://${ft}:${e}/api/meta`,{signal:AbortSignal.timeout(t)});if(!n.ok)return{kind:"answered",projectRoot:void 0};let r=await n.json();return{kind:"answered",projectRoot:typeof r.projectRoot=="string"?r.projectRoot:void 0}}catch{return{kind:"unanswered"}}}};function pt(e,t){let n=new URL(e);return t.focus!==void 0?n.searchParams.set("focus",t.focus):t.file!==void 0?n.searchParams.set("file",t.file):t.scope!==void 0&&n.searchParams.set("scope",t.scope),n.toString()}async function bt(e,t,n=gt){let r=ht(e);if(!r||!n.isProcessAlive(r.pid)||!await n.canConnect(r.port,Ln))return;let s=await n.fetchProjectRoot(r.port,Dn);if(s.kind==="unanswered")return r;let o=s.projectRoot;if(!(o===void 0||Y(dt(o))!==Y(dt(t))))return r}async function Vn(e,t,n=gt){let r=await bt(e,t.projectRoot,n);if(r&&r.pid!==t.pid)return process.stderr.write(`warning: a viewer (pid ${r.pid}, ${r.url}) is already recorded for this project, so this one is not.
6
+ `),!1;try{return de(e,t,{spacing:2,trailingNewline:!0}),!0}catch(s){return process.stderr.write(`warning: could not record the running viewer, so another \`codebaseiq view\` will start its own: ${yt(s)}
7
+ `),!1}}function ht(e){try{let{pid:t,port:n,url:r,projectRoot:s,startedAt:o}=JSON.parse(ce(e,"viewer state"));if(typeof t=="number"&&Number.isSafeInteger(t)&&t>0&&typeof n=="number"&&Number.isSafeInteger(n)&&n>0&&n<65536&&typeof r=="string"&&typeof s=="string"&&typeof o=="string")return{pid:t,port:n,url:r,projectRoot:s,startedAt:o}}catch{}}async function jr(e,t=Le){let n=On(e),r=be(),s=oe(r),o=X(r,s),i=Fn(o.paths.cacheDir,kn),a=await bt(i,r);if(a){let E=pt(`http://127.0.0.1:${a.port}/`,n);console.log(`Viewer already running (pid ${a.pid}): ${E}`),e.open&&mt(await t(E));return}process.stderr.write(`codebaseiq view: preparing index
8
+ `),await ke({commandName:"view",projectRoot:r,config:o.config,paths:o.paths,dbPathSource:o.dbPathSource,gitContext:s});let d=X(r,s),p=Ue({dbPath:d.dbPath,open:()=>he(r)}),m=Nn(d,p),b=In(r,d,s),M={queries:jn(),projectRoot:r,meta:{projectName:Mn(r),cliVersion:z,watcherState:b,builder:{available:m.run!==void 0,defaultMode:m.defaultMode}}},y;try{y=await ut({database:p,routes:M,...m.run?{builder:m.run}:{},...e.port!==void 0?{port:e.port}:{}})}catch(E){throw m.close(),p.close(),Cn(E,e.port)}let R={pid:process.pid,port:y.port,url:y.url,projectRoot:r,startedAt:new Date().toISOString()};await Vn(i,R),_n({server:y,database:p,builder:m,stateFile:i,state:R});let x=pt(y.url,n);console.log(`Viewer running at ${x}`),console.log("Press Ctrl+C to stop."),e.open&&mt(await t(x))}function On(e){if([e.focus,e.scope,e.file].filter(n=>n!==void 0).length>1)throw new Error("Use at most one of --focus, --scope, and --file.");if(e.port!==void 0&&(!Number.isInteger(e.port)||e.port<0||e.port>65535))throw new Error("--port must be an integer from 0 to 65535.");if(e.focus!==void 0){if(e.focus.trim()==="")throw new Error("--focus needs a symbol selector.");return{focus:e.focus}}if(e.scope!==void 0){let n=B(e.scope);if(n===null)throw new Error("--scope must be a directory inside the project.");return{scope:n}}if(e.file!==void 0){let n=B(e.file);if(n===null||n==="")throw new Error("--file must be a file path inside the project.");return{file:n}}return{}}function mt(e){e.launched||process.stderr.write(`codebaseiq view: no browser was opened; open the address above.
9
+ `)}function Cn(e,t){return e?.code==="EADDRINUSE"&&t?new Error(`Port ${t} is already in use; choose another with --port.`):e instanceof Error?e:new Error(String(e))}function Nn(e,t){try{let n=ge(e.projectRoot,e.config),r=Fe({settings:n,storeRoot:Me(e.paths.cacheDir),languages:Bn(t.acquire()),openDb:()=>t.acquire(),env:Tn(process.env)});return{run:(s,o)=>r.query(s,{signal:o}),defaultMode:n.mode,close:()=>r.close()}}catch(n){return process.stderr.write(`codebaseiq view: the symbol builder is unavailable: ${yt(n)}
10
+ `),{defaultMode:"agent",close:()=>{}}}}function Tn(e){return Object.fromEntries(Object.entries(e).filter(([t])=>t!=="CLAUDECODE"&&!t.startsWith("CODEX_")))}function Bn(e){let t=e.generation.metadataRaw;return(t?le(ue(t))?.indexedLanguages:void 0)??[]}function In(e,t,n){let r;return()=>{let s=Date.now();if(r&&s-r.at<Pn)return r.value;let o;try{let{classification:i}=xe({projectRoot:e,cacheDir:t.paths.cacheDir,cliVersion:z,...n?{gitContext:n}:{}});o=i.kind==="live"?i.state.watcher.state:i.kind}catch{o="unknown"}return r={at:s,value:o},o}}function jn(){let e=new WeakMap;return{normalizeMapScope:j,codeMapScope:De,nearestMapScope:Pe,codeMapFile:Ve,isIndexedFile(t,n){let r=e.get(t);return r||(r=new Set(O(t,{includeIgnored:!1})),e.set(t,r)),r.has(n)},outline:Re,fileSymbolFacts(t,n){let r=new Map;for(let s of we(t,n))r.set(s.symbol,{kind:s.kind===null?null:An(s.kind),documentation:s.documentation});return r},resolveFocus:_e,symbolFocusLanes:$e,code:Z,fileIsStale(t,n){return Z(t,`${n}:1-1`)?.freshness?.semantic.state==="stale"}}}function An(e){let t=ve(e).toLowerCase();return t==="unknown"||t==="unspecifiedkind"?null:t}function _n(e){let t=()=>{let s=ht(e.stateFile);s?.pid===e.state.pid&&s.startedAt===e.state.startedAt&&En(e.stateFile,{force:!0})},n=!1,r=()=>{n||(n=!0,e.server.close().finally(()=>{e.builder.close(),e.database.close(),t(),console.log(`
11
+ Stopped.`),process.exit(0)}))};process.on("SIGINT",r),process.on("SIGTERM",r),process.on("exit",t)}function yt(e){return e instanceof Error?e.message:String(e)}export{kn as VIEW_STATE_FILE,jn as createViewerQueries,bt as findRunningViewer,ht as readViewerState,Vn as recordRunningViewer,jr as runCodeViewer,Tn as viewerBuilderEnvironment,pt as viewerDeepLink};
12
+ //# sourceMappingURL=code-viewer-YGDON6SY.js.map