agentic-qe 3.14.4 → 3.14.5

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 (403) hide show
  1. package/.claude/skills/skills-manifest.json +1 -1
  2. package/CHANGELOG.md +93 -0
  3. package/assets/skills/skills-manifest.json +1 -1
  4. package/dist/audit/witness-chain.d.ts +1 -1
  5. package/dist/audit/witness-chain.js +29 -22
  6. package/dist/cli/bundle.js +13 -10
  7. package/dist/cli/chunks/adapter-IYC62SXA.js +2 -0
  8. package/dist/cli/chunks/{agent-booster-wasm-5PC7D2FW.js → agent-booster-wasm-EDNKP3SP.js} +2 -2
  9. package/dist/cli/chunks/{agent-handler-RDNTK4CA.js → agent-handler-V6CZ7Q6S.js} +2 -2
  10. package/dist/cli/chunks/{agent-memory-branch-NAAMBWIR.js → agent-memory-branch-ZMD6ULC3.js} +2 -2
  11. package/dist/cli/chunks/aqe-learning-engine-LLOU2IXD.js +2 -0
  12. package/dist/cli/chunks/{arena-HXTWJ5YY.js → arena-4UPAEHFT.js} +4 -4
  13. package/dist/cli/chunks/{arena-KXFHRWX4.js → arena-QLSBESC7.js} +2 -2
  14. package/dist/cli/chunks/{audit-YSGA7UWT.js → audit-CVZQMF55.js} +3 -3
  15. package/dist/cli/chunks/base-P3Z4IKCT.js +2 -0
  16. package/dist/cli/chunks/{better-sqlite3-UICJZIDG.js → better-sqlite3-4DSBPDRH.js} +2 -2
  17. package/dist/cli/chunks/brain-handler-GBY4EZ4P.js +94 -0
  18. package/dist/cli/chunks/{branch-enumerator-SS7UNVIA.js → branch-enumerator-XYBVXCNO.js} +2 -2
  19. package/dist/cli/chunks/{browser-77GI6KBE.js → browser-32F6MREU.js} +2 -2
  20. package/dist/cli/chunks/browser-workflow-YYHQQ25X.js +2 -0
  21. package/dist/cli/chunks/{chunk-FGYMFUE2.js → chunk-2JGEZHWY.js} +2 -2
  22. package/dist/cli/chunks/{chunk-MOBNBMFW.js → chunk-2KJQ2UQE.js} +1 -1
  23. package/dist/cli/chunks/{chunk-C2WU3533.js → chunk-2OMLTYQK.js} +1 -1
  24. package/dist/cli/chunks/{chunk-CU46J64M.js → chunk-37TUN44F.js} +2 -2
  25. package/dist/cli/chunks/{chunk-Z3RHREWF.js → chunk-3DDXWYMO.js} +1 -1
  26. package/dist/cli/chunks/{chunk-Q5DO24IJ.js → chunk-3EZ5DR2R.js} +3 -3
  27. package/dist/cli/chunks/{chunk-WLG5AJ4N.js → chunk-3KDL6QDK.js} +2 -2
  28. package/dist/cli/chunks/{chunk-MTZH7AHC.js → chunk-3VIXOHMS.js} +1 -1
  29. package/dist/cli/chunks/{chunk-ISDMD6EU.js → chunk-3YUB5HER.js} +96 -96
  30. package/dist/cli/chunks/{chunk-CDKG6EI7.js → chunk-4FWTLJEP.js} +2 -2
  31. package/dist/cli/chunks/{chunk-HDSAM2RE.js → chunk-52L77RMG.js} +2 -2
  32. package/dist/cli/chunks/{chunk-MEGDYJPV.js → chunk-5D36YHS3.js} +4 -4
  33. package/dist/cli/chunks/{chunk-T6BVLVI5.js → chunk-5WOSWNDN.js} +1 -1
  34. package/dist/cli/chunks/{chunk-M2JBBZQB.js → chunk-67YV75XP.js} +2 -2
  35. package/dist/cli/chunks/{chunk-KHFNNVJA.js → chunk-6A44AOGN.js} +2 -2
  36. package/dist/cli/chunks/{chunk-IPR4QP3H.js → chunk-6CR4VQBQ.js} +2 -2
  37. package/dist/cli/chunks/{chunk-XRT2WRMS.js → chunk-6ITZZIQX.js} +2 -2
  38. package/dist/cli/chunks/{chunk-4OYFXLBK.js → chunk-6LKDHEBY.js} +2 -2
  39. package/dist/cli/chunks/{chunk-FLYOJOKN.js → chunk-6TU7FEMD.js} +1 -1
  40. package/dist/cli/chunks/{chunk-6QYNWR7U.js → chunk-6VAZAHQG.js} +2 -2
  41. package/dist/cli/chunks/{chunk-TWAWHOP7.js → chunk-73EI4C2E.js} +2 -2
  42. package/dist/cli/chunks/{chunk-5R3QL7WN.js → chunk-75QJ5HWE.js} +2 -2
  43. package/dist/cli/chunks/{chunk-Y3MW3YBC.js → chunk-7CD7PBHY.js} +2 -2
  44. package/dist/cli/chunks/chunk-7DETTOPZ.js +14 -0
  45. package/dist/cli/chunks/{chunk-KSKEF7LZ.js → chunk-7JZJJA7U.js} +3 -3
  46. package/dist/cli/chunks/{chunk-AIHDEEJO.js → chunk-7VFY7TUR.js} +2 -2
  47. package/dist/cli/chunks/chunk-7X7JYWT4.js +27 -0
  48. package/dist/cli/chunks/chunk-AF4XKLXO.js +2 -0
  49. package/dist/cli/chunks/{chunk-6KJABXAR.js → chunk-AFEDJ3RU.js} +2 -2
  50. package/dist/cli/chunks/{chunk-5SJHQ2CO.js → chunk-AMMQOV35.js} +2 -2
  51. package/dist/cli/chunks/{chunk-6VRA2QGL.js → chunk-BHFR2EXL.js} +1 -1
  52. package/dist/cli/chunks/{chunk-ZBAKA4YB.js → chunk-BJPL6THQ.js} +1 -1
  53. package/dist/cli/chunks/{chunk-DOTK76IJ.js → chunk-BXVAVFGU.js} +2 -2
  54. package/dist/cli/chunks/{chunk-MNW6QGNJ.js → chunk-BYG36QC5.js} +2 -2
  55. package/dist/cli/chunks/chunk-C3HQL6S4.js +2 -0
  56. package/dist/cli/chunks/{chunk-PZJOPURC.js → chunk-C3Z4VVHP.js} +5 -5
  57. package/dist/cli/chunks/{chunk-OULHKEVH.js → chunk-CPC7FN52.js} +2 -2
  58. package/dist/cli/chunks/{chunk-BFP7KO7P.js → chunk-CVMNJSCB.js} +2 -2
  59. package/dist/cli/chunks/{chunk-AUXFKCQL.js → chunk-CYE2TJFV.js} +2 -2
  60. package/dist/cli/chunks/{chunk-7D777LTF.js → chunk-CZO4BJG5.js} +2 -2
  61. package/dist/cli/chunks/{chunk-VD6QRULW.js → chunk-D6OUCB2H.js} +2 -2
  62. package/dist/cli/chunks/{chunk-6UWGMOND.js → chunk-DDCIYOGT.js} +2 -2
  63. package/dist/cli/chunks/{chunk-STJCATGN.js → chunk-DKUBQQFG.js} +2 -2
  64. package/dist/cli/chunks/{chunk-M4WJKGVK.js → chunk-DLF5BOJD.js} +1 -1
  65. package/dist/cli/chunks/{chunk-DA5K5754.js → chunk-DO6EI5KB.js} +1 -1
  66. package/dist/cli/chunks/{chunk-BDESSCVR.js → chunk-DPBRWP4J.js} +3 -3
  67. package/dist/cli/chunks/{chunk-HV2J7KKQ.js → chunk-E3W6XQ57.js} +2 -2
  68. package/dist/cli/chunks/{chunk-MDWCE7YW.js → chunk-E4AZXCT5.js} +1 -1
  69. package/dist/cli/chunks/{chunk-F3SBRQC6.js → chunk-E4EYPYR3.js} +2 -2
  70. package/dist/cli/chunks/{chunk-55RWDRJD.js → chunk-EFV4ADMO.js} +4 -4
  71. package/dist/cli/chunks/{chunk-5YPYDPBJ.js → chunk-ELBZON4V.js} +2 -2
  72. package/dist/cli/chunks/{chunk-PO3IXGMQ.js → chunk-EOR2UT72.js} +2 -2
  73. package/dist/cli/chunks/{chunk-EDJ3O7RH.js → chunk-F34OAHOM.js} +2 -2
  74. package/dist/cli/chunks/{chunk-XRYF6JV7.js → chunk-FUNGTIF2.js} +2 -2
  75. package/dist/cli/chunks/{chunk-EKQ673SA.js → chunk-G3L5L6YQ.js} +1 -1
  76. package/dist/cli/chunks/{chunk-NJBGXDQ7.js → chunk-G3W6BMVJ.js} +1 -1
  77. package/dist/cli/chunks/{chunk-CIZ5JPDC.js → chunk-GTKCGPJZ.js} +3 -3
  78. package/dist/cli/chunks/{chunk-QGIU2WRL.js → chunk-HBCGYMQU.js} +1 -1
  79. package/dist/cli/chunks/{chunk-V3QLFNA2.js → chunk-HSVKZ5KI.js} +4 -4
  80. package/dist/cli/chunks/{chunk-BGE6FOLM.js → chunk-HVU64GP5.js} +2 -2
  81. package/dist/cli/chunks/chunk-HVXJC3OC.js +2 -0
  82. package/dist/cli/chunks/{chunk-MIQTXNBG.js → chunk-HYEJJJY3.js} +1 -1
  83. package/dist/cli/chunks/{chunk-CLTMDCSE.js → chunk-I2NENQ44.js} +2 -2
  84. package/dist/cli/chunks/{chunk-SGYJ4NFZ.js → chunk-I6X3EGJI.js} +1 -1
  85. package/dist/cli/chunks/{chunk-BOARZKU3.js → chunk-IGBEJ4UJ.js} +2 -2
  86. package/dist/cli/chunks/{chunk-FWGOHAAB.js → chunk-IIAR5S7Q.js} +2 -2
  87. package/dist/cli/chunks/{chunk-DHJPWQBR.js → chunk-IJHCIXJC.js} +2 -2
  88. package/dist/cli/chunks/{chunk-UEM7ZF5K.js → chunk-IUDWEOLX.js} +2 -2
  89. package/dist/cli/chunks/chunk-IUHB5GVS.js +3 -0
  90. package/dist/cli/chunks/{chunk-M5QUBZY6.js → chunk-IYTLXUBO.js} +2 -2
  91. package/dist/cli/chunks/chunk-J27F4NSB.js +2 -0
  92. package/dist/cli/chunks/{chunk-G6T45OIC.js → chunk-J5UNP6W3.js} +2 -2
  93. package/dist/cli/chunks/{chunk-3UPAMMCB.js → chunk-JES6R5KP.js} +1 -1
  94. package/dist/cli/chunks/{chunk-ZBQY5GLF.js → chunk-JROVR6YS.js} +2 -2
  95. package/dist/cli/chunks/chunk-JSZ663MU.js +2 -0
  96. package/dist/cli/chunks/{chunk-PFR4G3DJ.js → chunk-JVQBWYHW.js} +2 -2
  97. package/dist/cli/chunks/{chunk-JBNEE5UH.js → chunk-K27SU3RE.js} +2 -2
  98. package/dist/cli/chunks/{chunk-JZ3ORVZ3.js → chunk-K7NJHFLZ.js} +3 -3
  99. package/dist/cli/chunks/{chunk-3VOQRIQM.js → chunk-KEY43ANX.js} +2 -2
  100. package/dist/cli/chunks/chunk-KIP6WZGV.js +13 -0
  101. package/dist/cli/chunks/{chunk-UDHKLT4C.js → chunk-KKHYJF5U.js} +1 -1
  102. package/dist/cli/chunks/{chunk-ZNEMGX5O.js → chunk-KLTP5IDB.js} +1 -1
  103. package/dist/cli/chunks/{chunk-ONII3572.js → chunk-KO4FNAUR.js} +3 -3
  104. package/dist/cli/chunks/{chunk-TSRSV3LD.js → chunk-KYA5LARK.js} +1 -1
  105. package/dist/cli/chunks/{chunk-2JW3BCGG.js → chunk-LSUILON7.js} +1 -1
  106. package/dist/cli/chunks/chunk-LULD4JV2.js +15 -0
  107. package/dist/cli/chunks/{chunk-FRH6VAUS.js → chunk-M23ZOZVY.js} +1 -1
  108. package/dist/cli/chunks/{chunk-R5NE6B2M.js → chunk-M5AEL7IS.js} +2 -2
  109. package/dist/cli/chunks/chunk-MI5Q55DG.js +65 -0
  110. package/dist/cli/chunks/chunk-N7H767TP.js +4 -0
  111. package/dist/cli/chunks/{chunk-RJCYCLZV.js → chunk-NQI7FWCS.js} +2 -2
  112. package/dist/cli/chunks/{chunk-CXQPR5MY.js → chunk-NRE4NAVA.js} +1 -1
  113. package/dist/cli/chunks/{chunk-ODKLFVYC.js → chunk-NU7UTXMP.js} +2 -2
  114. package/dist/cli/chunks/{chunk-MVPCNSPY.js → chunk-NVYBM3R4.js} +2 -2
  115. package/dist/cli/chunks/{chunk-MVNP7GIR.js → chunk-O3JTQ7N4.js} +1 -1
  116. package/dist/cli/chunks/{chunk-6CQN24ZK.js → chunk-OEIQTWQP.js} +1 -1
  117. package/dist/cli/chunks/{chunk-U5K45TFH.js → chunk-PSPKSUF6.js} +1 -1
  118. package/dist/cli/chunks/{chunk-CDHQFHRP.js → chunk-QIRL6B3C.js} +2 -2
  119. package/dist/cli/chunks/{chunk-OSLYSG3B.js → chunk-QRCIZFNK.js} +2 -2
  120. package/dist/cli/chunks/{chunk-BOZZYWCR.js → chunk-QWUXCG2L.js} +1 -1
  121. package/dist/cli/chunks/{chunk-HIYXCDEP.js → chunk-QYOGD2VW.js} +1 -1
  122. package/dist/cli/chunks/{chunk-A4FYONNU.js → chunk-QZMUXJHZ.js} +2 -2
  123. package/dist/cli/chunks/{chunk-3TW5W5LX.js → chunk-R6IU3EWP.js} +2 -2
  124. package/dist/cli/chunks/{chunk-3X3DJZJJ.js → chunk-R74ZKREV.js} +1 -1
  125. package/dist/cli/chunks/{chunk-HIVA55CJ.js → chunk-RD2VGOUH.js} +1 -1
  126. package/dist/cli/chunks/{chunk-TPGED2IF.js → chunk-RD6TEZ64.js} +2 -2
  127. package/dist/cli/chunks/{chunk-4MHXCAG2.js → chunk-RGGK6VZ7.js} +1 -1
  128. package/dist/cli/chunks/{chunk-UGVHCMUN.js → chunk-RIZVC4XY.js} +3 -3
  129. package/dist/cli/chunks/{chunk-R4VL6E65.js → chunk-RKOUXVZZ.js} +2 -2
  130. package/dist/cli/chunks/{chunk-IFCLB7FJ.js → chunk-RP2ZKPYV.js} +1 -1
  131. package/dist/cli/chunks/{chunk-34WO57CW.js → chunk-SQF6HRXR.js} +1 -1
  132. package/dist/cli/chunks/{chunk-YNXS6CGV.js → chunk-SQKW3B6B.js} +1 -1
  133. package/dist/cli/chunks/{chunk-TDZ53WO2.js → chunk-SX4JLSLV.js} +2 -2
  134. package/dist/cli/chunks/{chunk-PAWXJ73E.js → chunk-TUSSPKRM.js} +1 -1
  135. package/dist/cli/chunks/{chunk-DFZCKIGY.js → chunk-TY5WC3FT.js} +3 -3
  136. package/dist/cli/chunks/{chunk-J6GNQS62.js → chunk-UDHVCKGA.js} +2 -2
  137. package/dist/cli/chunks/{chunk-CIKSHTEQ.js → chunk-UJWAWIRV.js} +4 -4
  138. package/dist/cli/chunks/{chunk-XJ7QNVI5.js → chunk-UKGXWW64.js} +3 -3
  139. package/dist/cli/chunks/{chunk-64PFWE2F.js → chunk-UMGFMKDW.js} +2 -2
  140. package/dist/cli/chunks/{chunk-DPFRKBOG.js → chunk-URVHZPWY.js} +2 -2
  141. package/dist/cli/chunks/{chunk-MCUJEZT6.js → chunk-UTBYJ4RF.js} +2 -2
  142. package/dist/cli/chunks/{chunk-HUWNIPZ5.js → chunk-VD5IO5EO.js} +1 -1
  143. package/dist/cli/chunks/{chunk-7ZIOFPL3.js → chunk-VTOVWHEM.js} +2 -2
  144. package/dist/cli/chunks/{chunk-SRKETSFF.js → chunk-W2XCZU62.js} +1 -1
  145. package/dist/cli/chunks/{chunk-CNG6GQEZ.js → chunk-WJHWH5D2.js} +2 -2
  146. package/dist/cli/chunks/{chunk-ZJ26AQA5.js → chunk-WJTSY5MC.js} +1 -1
  147. package/dist/cli/chunks/{chunk-OCWWP5PL.js → chunk-WK7B4B6Y.js} +2 -2
  148. package/dist/cli/chunks/{chunk-KPA7MZ6C.js → chunk-WLXK2KNU.js} +2 -2
  149. package/dist/cli/chunks/{chunk-ZBJ4XOOV.js → chunk-WOIGKU2N.js} +4 -4
  150. package/dist/cli/chunks/{chunk-ZZDIMOOV.js → chunk-WX6RRIGW.js} +2 -2
  151. package/dist/cli/chunks/{chunk-STM3UDNO.js → chunk-XEZIIQYJ.js} +2 -2
  152. package/dist/cli/chunks/{chunk-3QHGWY7T.js → chunk-XFPPERA2.js} +2 -2
  153. package/dist/cli/chunks/{chunk-VIHTL3U2.js → chunk-XLAUGSW7.js} +2 -2
  154. package/dist/cli/chunks/{chunk-XC7DYDSY.js → chunk-XQSIRBKT.js} +2 -2
  155. package/dist/cli/chunks/{chunk-GPLQ6DOK.js → chunk-XUR2M2WB.js} +2 -2
  156. package/dist/cli/chunks/{chunk-KCZR45PA.js → chunk-XZSMZHM2.js} +2 -2
  157. package/dist/cli/chunks/{chunk-ZNPKDCZR.js → chunk-Y5L3ES4L.js} +2 -2
  158. package/dist/cli/chunks/{chunk-W7BWUTVV.js → chunk-YDFL445W.js} +2 -2
  159. package/dist/cli/chunks/{chunk-AWWNB2T7.js → chunk-YQGPQBCX.js} +2 -2
  160. package/dist/cli/chunks/{chunk-DAEFDCJ4.js → chunk-YXP6BKGS.js} +17 -17
  161. package/dist/cli/chunks/{chunk-OBAP2TXZ.js → chunk-ZBABIZ2D.js} +2 -2
  162. package/dist/cli/chunks/{chunk-CSU5NYOX.js → chunk-ZCWERUYB.js} +4 -4
  163. package/dist/cli/chunks/{ci-464KPQNP.js → ci-RACDAJMR.js} +2 -2
  164. package/dist/cli/chunks/{ci-output-I7FX2RSO.js → ci-output-EHRSZBKG.js} +2 -2
  165. package/dist/cli/chunks/{circuit-breaker-3FW237WW.js → circuit-breaker-GBV7M5XG.js} +2 -2
  166. package/dist/cli/chunks/{claude-flow-setup-6JKMBPGU.js → claude-flow-setup-5LVJOFKP.js} +2 -2
  167. package/dist/cli/chunks/client-HUVFA5PF.js +2 -0
  168. package/dist/cli/chunks/{cline-installer-UWFHT6VY.js → cline-installer-W4NMXJSG.js} +2 -2
  169. package/dist/cli/chunks/{code-KQSUT3FS.js → code-JWXJMYXB.js} +3 -3
  170. package/dist/cli/chunks/{code-index-extractor-PABBNUSC.js → code-index-extractor-RVI2IFTM.js} +2 -2
  171. package/dist/cli/chunks/codex-installer-3BORJINH.js +14 -0
  172. package/dist/cli/chunks/{completions-7RWHAUAR.js → completions-A55NCTAO.js} +2 -2
  173. package/dist/cli/chunks/{complexity-analyzer-XPOAF33E.js → complexity-analyzer-JCXHGGLY.js} +2 -2
  174. package/dist/cli/chunks/{continuedev-installer-V4F2FIZP.js → continuedev-installer-PUVFMGYW.js} +2 -2
  175. package/dist/cli/chunks/{copilot-installer-JMICURQB.js → copilot-installer-4DCMYWHB.js} +2 -2
  176. package/dist/cli/chunks/core-handlers-UEXO3VAA.js +2 -0
  177. package/dist/cli/chunks/{cost-tracker-5OFHEYFJ.js → cost-tracker-5TV2GGKY.js} +2 -2
  178. package/dist/cli/chunks/{coverage-QKN57JDS.js → coverage-NNWM7TX3.js} +3 -3
  179. package/dist/cli/chunks/cross-domain-router-ODU5IZD6.js +2 -0
  180. package/dist/cli/chunks/{cursor-installer-GBJ7YXSM.js → cursor-installer-4NCHGJGK.js} +2 -2
  181. package/dist/cli/chunks/{daemon-IAVSO6HK.js → daemon-QIKCXKWO.js} +4 -4
  182. package/dist/cli/chunks/{daemon-GKP7CMEK.js → daemon-T4JO4IXP.js} +3 -3
  183. package/dist/cli/chunks/{dag-attention-scheduler-S225TCI7.js → dag-attention-scheduler-RPAAIDAD.js} +2 -2
  184. package/dist/cli/chunks/{detect-IUYH422U.js → detect-SBEEVDSN.js} +2 -2
  185. package/dist/cli/chunks/{dist-node-2YRE6A7C.js → dist-node-ZHI6NCSU.js} +2 -2
  186. package/dist/cli/chunks/{domain-handler-PL2TZC6H.js → domain-handler-LBC3GJ7Z.js} +2 -2
  187. package/dist/cli/chunks/{domain-plugins-HCGLXKIT.js → domain-plugins-H6IZ5USZ.js} +2 -2
  188. package/dist/cli/chunks/{domain-transfer-KQJRUPXA.js → domain-transfer-JZA5TMW3.js} +2 -2
  189. package/dist/cli/chunks/dream-HE3OX42F.js +2 -0
  190. package/dist/cli/chunks/embed-and-insert-pattern-AHTR7CRU.js +3 -0
  191. package/dist/cli/chunks/{eval-WCK7KNFN.js → eval-DZU2KISM.js} +2 -2
  192. package/dist/cli/chunks/{experience-capture-middleware-2MSQWSAR.js → experience-capture-middleware-5IQCWKSL.js} +4 -4
  193. package/dist/cli/chunks/{fast-paths-VYOSIBKF.js → fast-paths-2KLDUWCY.js} +2 -2
  194. package/dist/cli/chunks/{feature-flags-UJRHFBRX.js → feature-flags-7AC3XDZA.js} +2 -2
  195. package/dist/cli/chunks/{feature-flags-WCFUKHNQ.js → feature-flags-N6UAEZY4.js} +2 -2
  196. package/dist/cli/chunks/{file-discovery-JDGL4ZWS.js → file-discovery-5SDIW4V2.js} +2 -2
  197. package/dist/cli/chunks/{fleet-ROXVMZ2F.js → fleet-ZIQCAZ2Y.js} +3 -3
  198. package/dist/cli/chunks/{gnn-wrapper-NIO4ZCO3.js → gnn-wrapper-DUMBZJEV.js} +2 -2
  199. package/dist/cli/chunks/{heartbeat-handler-PI42WD3C.js → heartbeat-handler-6HVM6ZMR.js} +4 -4
  200. package/dist/cli/chunks/heartbeat-scheduler-QUIFGGLX.js +2 -0
  201. package/dist/cli/chunks/hnsw-adapter-42KB37KP.js +2 -0
  202. package/dist/cli/chunks/hnsw-index-T2PGO77J.js +2 -0
  203. package/dist/cli/chunks/{hnsw-legacy-bridge-YLC7SPK2.js → hnsw-legacy-bridge-5DRL5FLX.js} +2 -2
  204. package/dist/cli/chunks/{hnswlib-node-LG6OS3B7.js → hnswlib-node-GW67GTCL.js} +2 -2
  205. package/dist/cli/chunks/{hooks-WVALP5GX.js → hooks-QHH6FVO4.js} +10 -10
  206. package/dist/cli/chunks/hybrid-backend-FRNWYRKH.js +2 -0
  207. package/dist/cli/chunks/{hypergraph-engine-GJEMW3EG.js → hypergraph-engine-7XDCCVG2.js} +2 -2
  208. package/dist/cli/chunks/{hypergraph-handler-BLF6LXEV.js → hypergraph-handler-QHF7NOU5.js} +3 -3
  209. package/dist/cli/chunks/impact-analyzer-A5QYOYBR.js +2 -0
  210. package/dist/cli/chunks/{init-handler-K25RWRYY.js → init-handler-5UIVOM7K.js} +6 -6
  211. package/dist/cli/chunks/init-wizard-XBU674YH.js +2 -0
  212. package/dist/cli/chunks/kernel-DV5MTNZD.js +2 -0
  213. package/dist/cli/chunks/{kilocode-installer-BXN6WZ7G.js → kilocode-installer-TGGV6K5Q.js} +2 -2
  214. package/dist/cli/chunks/{kiro-installer-PM362DLN.js → kiro-installer-4XYBHZWW.js} +2 -2
  215. package/dist/cli/chunks/knowledge-graph-4ACGVJQK.js +2 -0
  216. package/dist/cli/chunks/{learning-CPERDDRG.js → learning-STE5W6BS.js} +3 -3
  217. package/dist/cli/chunks/{llm-router-GOAV5FPI.js → llm-router-NKF7J3RI.js} +4 -4
  218. package/dist/cli/chunks/llm-router-service-PSMASERT.js +2 -0
  219. package/dist/cli/chunks/{load-2BG6SHAK.js → load-B2T77UJQ.js} +2 -2
  220. package/dist/cli/chunks/load-test-MRUO2VPF.js +2 -0
  221. package/dist/cli/chunks/mcp-JGSFCEMH.js +2 -0
  222. package/dist/cli/chunks/{memory-4NHBYT6S.js → memory-WRFZKG56.js} +6 -6
  223. package/dist/cli/chunks/memory-backend-2MPGI6JW.js +2 -0
  224. package/dist/cli/chunks/memory-handlers-XT4HMITB.js +2 -0
  225. package/dist/cli/chunks/{multi-model-executor-KCWSGCDT.js → multi-model-executor-26Q5BSVG.js} +2 -2
  226. package/dist/cli/chunks/{opencode-installer-ATZLLK74.js → opencode-installer-J36EMQU7.js} +2 -2
  227. package/dist/cli/chunks/{orchestrator-RKB7XJRG.js → orchestrator-D5IFV65I.js} +18 -18
  228. package/dist/cli/chunks/pattern-null-store-TGWUL237.js +2 -0
  229. package/dist/cli/chunks/{pattern-usage-recorder-7VE4XDAI.js → pattern-usage-recorder-BVMTWI3E.js} +2 -2
  230. package/dist/cli/chunks/{pipeline-LQZSNDD2.js → pipeline-OWAHDUAQ.js} +2 -2
  231. package/dist/cli/chunks/platform-ANGBFWBV.js +2 -0
  232. package/dist/cli/chunks/{plugin-EJ6K2MGU.js → plugin-OO7ON2YW.js} +2 -2
  233. package/dist/cli/chunks/{prime-radiant-advanced-wasm-OIHTKJMN.js → prime-radiant-advanced-wasm-HFG3BXWU.js} +2 -2
  234. package/dist/cli/chunks/project-root-LNOYVTYY.js +2 -0
  235. package/dist/cli/chunks/protocol-executor-GEVH5KD6.js +2 -0
  236. package/dist/cli/chunks/{protocol-handler-NRBROAU7.js → protocol-handler-CE3Q6LY4.js} +2 -2
  237. package/dist/cli/chunks/{prove-EJOGEGD3.js → prove-7XPN53PY.js} +2 -2
  238. package/dist/cli/chunks/qe-reasoning-bank-DJ2JL6QB.js +2 -0
  239. package/dist/cli/chunks/{quality-E55UC73D.js → quality-TT23JRFX.js} +2 -2
  240. package/dist/cli/chunks/{quality-gate-OIQATNT3.js → quality-gate-PPPRP255.js} +3 -3
  241. package/dist/cli/chunks/queen-coordinator-F7E3AS26.js +2 -0
  242. package/dist/cli/chunks/real-embeddings-EYNZIFJE.js +2 -0
  243. package/dist/cli/chunks/{ref-validation-OPO6J7OL.js → ref-validation-QQR64ZXD.js} +2 -2
  244. package/dist/cli/chunks/{roocode-installer-ODY5KRWU.js → roocode-installer-UIGS7ZJD.js} +2 -2
  245. package/dist/cli/chunks/router-OZH3QSAU.js +2 -0
  246. package/dist/cli/chunks/routing-feedback-J2E3ADZB.js +2 -0
  247. package/dist/cli/chunks/{routing-handler-KQM6VWLC.js → routing-handler-6AENUIRG.js} +2 -2
  248. package/dist/cli/chunks/{ruvector-commands-U2GVV6PF.js → ruvector-commands-5AWMEV34.js} +2 -2
  249. package/dist/cli/chunks/rvf-dual-writer-HK525Y5Y.js +2 -0
  250. package/dist/cli/chunks/rvf-migration-adapter-Q7FB3BKR.js +2 -0
  251. package/dist/cli/chunks/rvf-migration-coordinator-NWRJ7C22.js +2 -0
  252. package/dist/cli/chunks/rvf-native-adapter-5ZRCGUI6.js +2 -0
  253. package/dist/cli/chunks/{rvf-store-integrity-KMIHD3LP.js → rvf-store-integrity-ISKRP563.js} +2 -2
  254. package/dist/cli/chunks/safe-db-3OYEPVEH.js +2 -0
  255. package/dist/cli/chunks/schedule-AG4C2EIQ.js +2 -0
  256. package/dist/cli/chunks/scheduler-SQS2CZFZ.js +2 -0
  257. package/dist/cli/chunks/{security-P5NM353C.js → security-325A7FMB.js} +3 -3
  258. package/dist/cli/chunks/{shared-rvf-adapter-LVIUOO4S.js → shared-rvf-adapter-NFL6QSZ6.js} +2 -2
  259. package/dist/cli/chunks/{shared-rvf-dual-writer-2CSG7C4W.js → shared-rvf-dual-writer-THFDYS2Z.js} +2 -2
  260. package/dist/cli/chunks/sqlite-persistence-MAKDFSHC.js +2 -0
  261. package/dist/cli/chunks/standalone-memory-UD4MJ6GZ.js +2 -0
  262. package/dist/cli/chunks/{status-handler-6TU6O37R.js → status-handler-CPFTN4XL.js} +2 -2
  263. package/dist/cli/chunks/{structural-health-KBIJSTXJ.js → structural-health-2MG2IVBL.js} +2 -2
  264. package/dist/cli/chunks/{sync-LNHI5SB7.js → sync-EE4VVKOW.js} +2 -2
  265. package/dist/cli/chunks/{sync-UHOX6RJW.js → sync-MBTW5XBF.js} +2 -2
  266. package/dist/cli/chunks/task-handler-7H5OYJG4.js +54 -0
  267. package/dist/cli/chunks/task-handlers-NH4GJHCJ.js +9 -0
  268. package/dist/cli/chunks/{test-DHAAI3DU.js → test-MPHGT4T6.js} +4 -4
  269. package/dist/cli/chunks/{test-scheduling-XDBZ3QC2.js → test-scheduling-CHQ4ZLLJ.js} +3 -3
  270. package/dist/cli/chunks/token-bootstrap-SSDCYEKK.js +2 -0
  271. package/dist/cli/chunks/{token-usage-Q2YG5YQN.js → token-usage-EBXUJNRB.js} +2 -2
  272. package/dist/cli/chunks/{transformers-F5UQTQCY.js → transformers-ZEKS2OJZ.js} +2 -2
  273. package/dist/cli/chunks/{tree-sitter-wasm-parser-DEGOHS6F.js → tree-sitter-wasm-parser-J6ZMAK37.js} +2 -2
  274. package/dist/cli/chunks/{types-JQ7EQO5Q.js → types-KYAA5VLV.js} +2 -2
  275. package/dist/cli/chunks/unified-memory-DDWMC435.js +2 -0
  276. package/dist/cli/chunks/unified-memory-hnsw-4JA7SGBK.js +2 -0
  277. package/dist/cli/chunks/unified-persistence-F6OSNTXY.js +2 -0
  278. package/dist/cli/chunks/{upgrade-TJRVGHGD.js → upgrade-UJBJ5AYM.js} +2 -2
  279. package/dist/cli/chunks/{validate-BWPCVHBN.js → validate-RUV6YMWS.js} +2 -2
  280. package/dist/cli/chunks/{validate-swarm-QVVKCQLP.js → validate-swarm-IVEVMGVM.js} +2 -2
  281. package/dist/cli/chunks/{vibium-ZFATIWHO.js → vibium-HOGMFJ2Z.js} +2 -2
  282. package/dist/cli/chunks/visual-security-25SMBIYT.js +2 -0
  283. package/dist/cli/chunks/{web-tree-sitter-KPLY7ONR.js → web-tree-sitter-AVWA6HKE.js} +2 -2
  284. package/dist/cli/chunks/{windsurf-installer-H7XM7ISA.js → windsurf-installer-DAH7HI2W.js} +2 -2
  285. package/dist/cli/chunks/{witness-chain-RRN6NDCH.js → witness-chain-PJOQPFUX.js} +2 -2
  286. package/dist/cli/chunks/witness-chain-ZW6KKUZU.js +2 -0
  287. package/dist/cli/chunks/{witness-key-manager-DFRL42GE.js → witness-key-manager-JSTBMG43.js} +2 -2
  288. package/dist/cli/chunks/{workflow-2ZQO6WYI.js → workflow-TWOIA6LZ.js} +4 -4
  289. package/dist/cli/chunks/workflow-orchestrator-UKSIDM7Q.js +2 -0
  290. package/dist/cli/chunks/{wrappers-SUS6XEJD.js → wrappers-UR7BLXKV.js} +2 -2
  291. package/dist/cli/commands/mcp.js +6 -0
  292. package/dist/cli/commands/memory.d.ts +1 -1
  293. package/dist/cli/commands/memory.js +8 -8
  294. package/dist/cli/commands/platform.js +15 -2
  295. package/dist/cli/commands/upgrade.d.ts +3 -3
  296. package/dist/cli/commands/upgrade.js +3 -3
  297. package/dist/cli/handlers/init-handler.d.ts +10 -0
  298. package/dist/cli/handlers/task-handler.js +24 -3
  299. package/dist/cli/helpers/standalone-memory.d.ts +12 -0
  300. package/dist/cli/helpers/standalone-memory.js +46 -0
  301. package/dist/cli/index.js +37 -41
  302. package/dist/cli/log-gate.d.ts +66 -0
  303. package/dist/cli/log-gate.js +170 -0
  304. package/dist/init/codex-installer.js +18 -6
  305. package/dist/init/orchestrator.js +1 -0
  306. package/dist/init/phases/09-assets.d.ts +10 -0
  307. package/dist/init/phases/09-assets.js +3 -0
  308. package/dist/init/token-bootstrap.d.ts +1 -1
  309. package/dist/init/token-bootstrap.js +12 -2
  310. package/dist/init/types.d.ts +10 -0
  311. package/dist/integrations/ruvector/brain-exporter.js +17 -0
  312. package/dist/integrations/ruvector/brain-import-audit.d.ts +20 -0
  313. package/dist/integrations/ruvector/brain-import-audit.js +22 -0
  314. package/dist/integrations/ruvector/brain-rvf-exporter.js +16 -0
  315. package/dist/integrations/ruvector/brain-shared.js +1 -1
  316. package/dist/integrations/ruvector/rvf-dual-writer.js +6 -1
  317. package/dist/kernel/hybrid-backend.d.ts +6 -0
  318. package/dist/kernel/hybrid-backend.js +18 -0
  319. package/dist/kernel/kernel.js +9 -14
  320. package/dist/kernel/project-root.d.ts +1 -1
  321. package/dist/kernel/project-root.js +24 -3
  322. package/dist/learning/embedder-identity-store.js +4 -3
  323. package/dist/learning/pattern-store.js +5 -1
  324. package/dist/learning/real-embeddings.d.ts +8 -0
  325. package/dist/learning/real-embeddings.js +16 -0
  326. package/dist/learning/rvf-pattern-store.js +10 -3
  327. package/dist/mcp/bundle.js +442 -442
  328. package/dist/mcp/entry.js +2 -0
  329. package/dist/mcp/handlers/memory-handlers.d.ts +6 -1
  330. package/dist/mcp/handlers/memory-handlers.js +44 -22
  331. package/dist/mcp/handlers/task-handlers.js +14 -1
  332. package/dist/mcp/protocol-server.js +1 -0
  333. package/dist/mcp/services/session-store.js +5 -1
  334. package/dist/plugins/cache.d.ts +2 -0
  335. package/dist/plugins/cache.js +15 -2
  336. package/dist/plugins/lifecycle.js +15 -2
  337. package/dist/plugins/manifest.js +7 -5
  338. package/dist/plugins/resolver.d.ts +13 -22
  339. package/dist/plugins/resolver.js +169 -61
  340. package/dist/plugins/version-policy.d.ts +13 -0
  341. package/dist/plugins/version-policy.js +18 -0
  342. package/dist/shared/types/index.d.ts +6 -0
  343. package/dist/shared/types/index.js +8 -0
  344. package/package.json +2 -1
  345. package/dist/cli/chunks/adapter-TNNNJRDG.js +0 -2
  346. package/dist/cli/chunks/aqe-learning-engine-5ZRMYJLB.js +0 -2
  347. package/dist/cli/chunks/base-KWZHOPSH.js +0 -2
  348. package/dist/cli/chunks/brain-handler-ET6YAP4B.js +0 -90
  349. package/dist/cli/chunks/browser-workflow-2FZTKDUL.js +0 -2
  350. package/dist/cli/chunks/chunk-33YYYWBQ.js +0 -4
  351. package/dist/cli/chunks/chunk-5Z6XZV7K.js +0 -65
  352. package/dist/cli/chunks/chunk-6J62K3SW.js +0 -2
  353. package/dist/cli/chunks/chunk-6TPKK7LD.js +0 -15
  354. package/dist/cli/chunks/chunk-DEYLEDJN.js +0 -27
  355. package/dist/cli/chunks/chunk-KGT36Z42.js +0 -14
  356. package/dist/cli/chunks/chunk-NA7B2QYB.js +0 -2
  357. package/dist/cli/chunks/chunk-NDPFGIMJ.js +0 -13
  358. package/dist/cli/chunks/chunk-PEPFCPES.js +0 -2
  359. package/dist/cli/chunks/chunk-TT23RRB7.js +0 -2
  360. package/dist/cli/chunks/chunk-XWMZ6D6N.js +0 -2
  361. package/dist/cli/chunks/client-7E4LM2WW.js +0 -2
  362. package/dist/cli/chunks/codex-installer-CQ24DTP5.js +0 -14
  363. package/dist/cli/chunks/core-handlers-IFG3757P.js +0 -2
  364. package/dist/cli/chunks/cross-domain-router-EK7W4PGP.js +0 -2
  365. package/dist/cli/chunks/dream-NFSCSLY7.js +0 -2
  366. package/dist/cli/chunks/embed-and-insert-pattern-ZPAG7235.js +0 -3
  367. package/dist/cli/chunks/heartbeat-scheduler-ZATCDJDK.js +0 -2
  368. package/dist/cli/chunks/hnsw-adapter-WXQABRCA.js +0 -2
  369. package/dist/cli/chunks/hnsw-index-TPSWLEA5.js +0 -2
  370. package/dist/cli/chunks/impact-analyzer-HNIU45P5.js +0 -2
  371. package/dist/cli/chunks/init-wizard-JUIPBMHG.js +0 -2
  372. package/dist/cli/chunks/kernel-5BOZQ754.js +0 -2
  373. package/dist/cli/chunks/knowledge-graph-EWDAENWM.js +0 -2
  374. package/dist/cli/chunks/llm-router-service-3YT7JGBS.js +0 -2
  375. package/dist/cli/chunks/load-test-BP2CPLIV.js +0 -2
  376. package/dist/cli/chunks/mcp-5TTB37DC.js +0 -2
  377. package/dist/cli/chunks/memory-backend-4PYQBPRM.js +0 -2
  378. package/dist/cli/chunks/memory-handlers-2B27NITS.js +0 -2
  379. package/dist/cli/chunks/pattern-null-store-OYOQOV2O.js +0 -2
  380. package/dist/cli/chunks/platform-OD5H5U6G.js +0 -2
  381. package/dist/cli/chunks/protocol-executor-3ATJTXWG.js +0 -2
  382. package/dist/cli/chunks/qe-reasoning-bank-LLMYZT4X.js +0 -2
  383. package/dist/cli/chunks/queen-coordinator-RN7L6KG5.js +0 -2
  384. package/dist/cli/chunks/real-embeddings-FPFFNOSZ.js +0 -2
  385. package/dist/cli/chunks/router-MDHITQ2V.js +0 -2
  386. package/dist/cli/chunks/routing-feedback-5XLNJ3Y3.js +0 -2
  387. package/dist/cli/chunks/rvf-dual-writer-JBW4O3II.js +0 -2
  388. package/dist/cli/chunks/rvf-migration-adapter-BPPQL4XJ.js +0 -2
  389. package/dist/cli/chunks/rvf-migration-coordinator-V2GHCJKN.js +0 -2
  390. package/dist/cli/chunks/rvf-native-adapter-S4562CG5.js +0 -2
  391. package/dist/cli/chunks/safe-db-FIRHSXVF.js +0 -2
  392. package/dist/cli/chunks/schedule-RVXFB4HK.js +0 -2
  393. package/dist/cli/chunks/scheduler-IKKAMAOO.js +0 -2
  394. package/dist/cli/chunks/sqlite-persistence-SQ3HCUQ7.js +0 -2
  395. package/dist/cli/chunks/task-handler-AVDHMLGI.js +0 -49
  396. package/dist/cli/chunks/task-handlers-KYK4VTRA.js +0 -9
  397. package/dist/cli/chunks/token-bootstrap-GUTTLPZX.js +0 -2
  398. package/dist/cli/chunks/unified-memory-CXHLHB5I.js +0 -2
  399. package/dist/cli/chunks/unified-memory-hnsw-I7WAE54M.js +0 -2
  400. package/dist/cli/chunks/unified-persistence-6CPF65WI.js +0 -2
  401. package/dist/cli/chunks/visual-security-GNPHME5H.js +0 -2
  402. package/dist/cli/chunks/witness-chain-VT4UHHBR.js +0 -2
  403. package/dist/cli/chunks/workflow-orchestrator-DB3HIECD.js +0 -2
@@ -1,2 +1,2 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.4");process.exit(0)}
2
- import{d as D,e as V}from"./chunk-Y3MW3YBC.js";V();import*as A from"node:fs";import B from"node:module";import*as N from"node:path";import{fileURLToPath as J}from"node:url";var b=D("TreeSitterWASM"),O={python:{wasmFile:"tree-sitter-python.wasm",nodeTypes:{functionDecl:["function_definition"],classDecl:["class_definition"],importDecl:["import_statement","import_from_statement"]}},java:{wasmFile:"tree-sitter-java.wasm",nodeTypes:{functionDecl:["method_declaration","constructor_declaration"],classDecl:["class_declaration","interface_declaration"],importDecl:["import_declaration"]}},csharp:{wasmFile:"tree-sitter-c_sharp.wasm",nodeTypes:{functionDecl:["method_declaration","constructor_declaration"],classDecl:["class_declaration","interface_declaration"],importDecl:["using_directive"]}},rust:{wasmFile:"tree-sitter-rust.wasm",nodeTypes:{functionDecl:["function_item"],classDecl:[],importDecl:["use_declaration"],implBlock:"impl_item",structDecl:"struct_item"}},swift:{wasmFile:"tree-sitter-swift.wasm",nodeTypes:{functionDecl:["function_declaration"],classDecl:["class_declaration"],importDecl:["import_declaration"],structDecl:"struct_declaration",protocolDecl:"protocol_declaration"}}},y=null,g=null,F=0,P=3,w=new Map;function I(i){let e=J(new URL(".",import.meta.url)),t=[N.resolve(e,"..","..","..","assets","grammars",i),N.resolve(e,"..","..","assets","grammars",i),N.resolve(process.cwd(),"assets","grammars",i),N.resolve(e,"..","assets","grammars",i)];for(let n of t)if(A.existsSync(n))return n;throw new Error(`Grammar file ${i} not found. Searched: ${t.join(", ")}`)}async function E(){if(F>=P)throw new Error(`web-tree-sitter failed to initialize after ${P} attempts`);if(!y)return g||(g=(async()=>{try{let i=await import("./web-tree-sitter-KPLY7ONR.js"),e=i.default??i;await(e.Parser?.init??e.init).call(e.Parser??e),y=e,F=0,b.info("web-tree-sitter WASM runtime initialized")}catch(i){F++,g=null;let e=i instanceof Error?i.message:String(i);throw b.warn(`web-tree-sitter WASM init failed (attempt ${F}/${P}): ${e}. `+(F<P?"Will retry on next parse.":"Falling back to regex permanently.")),i}})()),g}async function X(i){let e=w.get(i);if(e)return e;await E();let t=O[i];if(!t)throw new Error(`No WASM grammar config for ${i}`);try{let n=I(t.wasmFile),s=await y.Language.load(n);return w.set(i,s),b.info(`Loaded tree-sitter WASM grammar for ${i}`),s}catch(n){let s=n instanceof Error?n.message:String(n);throw b.warn(`Failed to load WASM grammar for ${i}: ${s}. Falling back to regex parser.`),n}}function u(i,e){let t=[];for(let n=0;n<i.childCount;n++){let s=i.child(n);e.includes(s.type)&&t.push(s)}return t}function h(i,e,t=10){let n=[];function s(r,o){if(!(o>t))for(let a=0;a<r.childCount;a++){let c=r.child(a);e.includes(c.type)&&n.push(c),s(c,o+1)}}return s(i,0),n}function x(i){let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);(n.type==="modifiers"||n.type==="modifier"||n.type==="visibility_modifier")&&e.push(n.text.trim())}return e}function C(i,e){return x(i).some(t=>t.includes(e))}var Y=new Set(["if_statement","if_expression","if_let_statement","while_statement","while_expression","for_statement","for_in_statement","for_expression","enhanced_for_statement","match_expression","switch_statement","switch_expression","case_clause","match_arm","switch_entry","catch_clause","except_clause","catch_block","binary_expression","conditional_expression","ternary_expression"]),q=new Set(["&&","||","and","or"]);function _(i){if(!i)return 1;let e=1;function t(n){if(Y.has(n.type))if(n.type==="binary_expression"){let s=n.childForFieldName("operator");s&&q.has(s.text)&&e++}else e++;for(let s=0;s<n.childCount;s++)t(n.child(s))}return t(i),e}function S(i,e){if(!i)return[];let t=[];for(let n=0;n<i.childCount;n++){let s=i.child(n);switch(e){case"java":if(s.type==="field_declaration"){let r=x(s),o=s.childForFieldName("type")?.text?.trim(),a=s.childForFieldName("declarator"),c=a?.childForFieldName("name")?.text??a?.text?.split(/[=;]/)[0]?.trim()??"";c&&t.push({name:c,type:o||void 0,isPublic:r.some(l=>l.includes("public")),isReadonly:r.some(l=>l.includes("final"))})}break;case"csharp":if(s.type==="field_declaration"||s.type==="property_declaration"){let r=x(s),o=s.childForFieldName("type")?.text?.trim(),a=s.childForFieldName("name")?.text??"";a&&t.push({name:a,type:o||void 0,isPublic:r.some(c=>c.includes("public")),isReadonly:r.some(c=>c.includes("readonly"))})}break;case"rust":if(s.type==="field_declaration"){let r=s.childForFieldName("name")?.text??"",o=s.childForFieldName("type")?.text?.trim(),a=C(s,"pub");r&&t.push({name:r,type:o||void 0,isPublic:a,isReadonly:!1})}break;case"swift":if(s.type==="property_declaration"){let r=L(s),o=s.childForFieldName("name")?.text??"",a=s.childForFieldName("type")?.text?.trim(),c=r.includes("public")||r.includes("open"),l=s.text.includes("let ");o&&t.push({name:o,type:a||void 0,isPublic:c,isReadonly:l})}break;case"python":if(s.type==="expression_statement"){let r=s.child(0);if(r?.type==="assignment"){let o=r.childForFieldName("left");if(o?.type==="attribute"||o?.type==="identifier"){let a=o.text.replace("self.","");t.push({name:a,type:void 0,isPublic:!a.startsWith("_"),isReadonly:!1})}}}break}}return t}function k(i){return i.map(e=>{let t=e.childForFieldName("name")?.text??"",n=e.childForFieldName("parameters"),s=e.childForFieldName("return_type"),r=e.childForFieldName("body"),o=e.text.trimStart().startsWith("async"),a=W(e);return{name:t,parameters:z(n),returnType:s?.text?.trim()||void 0,isAsync:o,isPublic:!t.startsWith("_"),complexity:_(r),decorators:a,genericParams:[],startLine:e.startPosition.row+1,endLine:e.endPosition.row+1}})}function z(i){if(!i)return[];let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);if(n.type==="identifier"){let s=n.text;if(s==="self"||s==="cls")continue;e.push({name:s,type:void 0,isOptional:!1,defaultValue:void 0})}else if(n.type==="typed_parameter"){let s=n.child(0)?.text??"";if(s==="self"||s==="cls")continue;let r=n.childForFieldName("type")?.text?.trim();e.push({name:s,type:r||void 0,isOptional:!1,defaultValue:void 0})}else if(n.type==="default_parameter"||n.type==="typed_default_parameter"){let s=n.childForFieldName("name")?.text??n.child(0)?.text??"";if(s==="self"||s==="cls")continue;let r=n.childForFieldName("type")?.text?.trim(),o=n.childForFieldName("value")?.text?.trim();e.push({name:s,type:r||void 0,isOptional:!0,defaultValue:o||void 0})}else if(n.type==="list_splat_pattern"||n.type==="dictionary_splat_pattern"){let s=n.text;e.push({name:s,type:void 0,isOptional:!0,defaultValue:void 0})}}return e}function W(i){let e=[],t=i.parent;if(!t)return e;if(t.type==="decorated_definition")for(let n=0;n<t.childCount;n++){let s=t.child(n);s.type==="decorator"&&e.push(s.text.trim())}return e}function Q(i){return i.map(e=>{let t=e.childForFieldName("name")?.text??"",n=e.childForFieldName("body"),s=e.childForFieldName("superclasses"),r=[];if(s)for(let l=0;l<s.childCount;l++){let d=s.child(l);d.isNamed&&r.push(d.text)}let o=n?h(n,["function_definition"],2):[],a=k(o),c=W(e);return{name:t,methods:a,properties:S(n,"python"),isPublic:!t.startsWith("_"),implements:[],extends:r[0]||void 0,decorators:c,startLine:e.startPosition.row+1,endLine:e.endPosition.row+1}})}function H(i){return i.map(e=>{if(e.type==="import_from_statement"){let n=e.childForFieldName("module_name")?.text??"",s=[];for(let r=0;r<e.childCount;r++){let o=e.child(r);e.fieldNameForChild(r)==="name"&&o.isNamed&&s.push(o.text)}return{module:n,namedImports:s,isTypeOnly:!1}}return{module:e.childForFieldName("name")?.text??"",namedImports:[],isTypeOnly:!1}})}function T(i){return i.map(e=>{let t=e.childForFieldName("name")?.text??"",n=e.childForFieldName("type"),s=e.childForFieldName("parameters"),r=e.childForFieldName("body"),a=x(e).some(d=>d.includes("public")),c=n?.text?.includes("CompletableFuture")??!1,l=M(e);return{name:t,parameters:K(s),returnType:n?.text==="void"?void 0:n?.text?.trim(),isAsync:c,isPublic:a,complexity:_(r),decorators:l,genericParams:[],startLine:e.startPosition.row+1,endLine:e.endPosition.row+1}})}function K(i){if(!i)return[];let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);if(n.type==="formal_parameter"||n.type==="spread_parameter"){let s=n.childForFieldName("name")?.text??"",r=n.childForFieldName("type")?.text?.trim();e.push({name:s,type:r||void 0,isOptional:!1,defaultValue:void 0})}}return e}function M(i){let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);if(n.type==="modifiers")for(let s=0;s<n.childCount;s++){let r=n.child(s);(r.type==="marker_annotation"||r.type==="annotation")&&e.push(r.text.trim())}}return e}function Z(i){return i.map(e=>{let t=e.childForFieldName("name")?.text??"",n=e.childForFieldName("body"),r=x(e).some(p=>p.includes("public")),o=e.childForFieldName("superclass")?.text,a=e.childForFieldName("interfaces"),c=[];if(a)for(let p=0;p<a.childCount;p++){let f=a.child(p);f.isNamed&&c.push(f.text)}let l=n?u(n,["method_declaration","constructor_declaration"]):[],d=T(l),m=M(e);return{name:t,methods:d,properties:S(n,"java"),isPublic:r,implements:c,extends:o||void 0,decorators:m,startLine:e.startPosition.row+1,endLine:e.endPosition.row+1}})}function ee(i){return i.map(e=>{let t=e.text.replace(/^\s*import\s+(static\s+)?/,"").replace(/;\s*$/,"").trim(),n=t.split("."),s=n[n.length-1];return{module:t,namedImports:s==="*"?[]:[s],isTypeOnly:!1}})}function te(i){return h(i,["method_declaration","constructor_declaration"]).map(t=>{let n=t.childForFieldName("name")?.text??"",s=t.childForFieldName("type"),r=t.childForFieldName("parameters"),o=x(t),a=o.some(d=>d.includes("public")),c=o.some(d=>d.includes("async"))||s?.text?.includes("Task")||!1,l=j(t);return{name:n,parameters:ne(r),returnType:s?.text==="void"?void 0:s?.text?.trim(),isAsync:c,isPublic:a,complexity:_(t.childForFieldName("body")),decorators:l,genericParams:[],startLine:t.startPosition.row+1,endLine:t.endPosition.row+1}})}function ne(i){if(!i)return[];let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);if(n.type==="parameter"){let s=n.childForFieldName("name")?.text??"",r=n.childForFieldName("type")?.text?.trim();e.push({name:s,type:r||void 0,isOptional:r?.endsWith("?")||!1,defaultValue:void 0})}}return e}function j(i){let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);n.type==="attribute_list"&&e.push(n.text.trim())}return e}function se(i){return h(i,["class_declaration","interface_declaration"]).map(t=>{let n=t.childForFieldName("name")?.text??"",s=t.childForFieldName("body"),o=x(t).some(p=>p.includes("public")),a=t.childForFieldName("bases"),c=[];if(a)for(let p=0;p<a.childCount;p++){let f=a.child(p);f.isNamed&&c.push(f.text)}let l=s?u(s,["method_declaration","constructor_declaration"]):[],d=T(l),m=j(t);return{name:n,methods:d,properties:S(s,"csharp"),isPublic:o,implements:c.slice(1),extends:c[0]||void 0,decorators:m,startLine:t.startPosition.row+1,endLine:t.endPosition.row+1}})}function ie(i){return h(i,["using_directive"]).map(t=>({module:t.text.replace(/^\s*using\s+(static\s+)?/,"").replace(/;\s*$/,"").trim(),namedImports:[],isTypeOnly:!1}))}function re(i,e){let t=[],n=u(i,e.nodeTypes.functionDecl);if(t.push(...n.map(U)),e.nodeTypes.implBlock){let s=u(i,[e.nodeTypes.implBlock]);for(let r of s){let o=r.childForFieldName("body");if(o){let a=u(o,e.nodeTypes.functionDecl);t.push(...a.map(U))}}}return t}function U(i){let e=i.childForFieldName("name")?.text??"",t=i.childForFieldName("parameters"),n=i.childForFieldName("return_type"),s=i.childForFieldName("body"),r=C(i,"pub"),o=i.text.trimStart().startsWith("pub async")||i.text.trimStart().startsWith("async"),a=G(i);return{name:e,parameters:oe(t),returnType:n?.text?.trim()||void 0,isAsync:o,isPublic:r,complexity:_(s),decorators:a,genericParams:[],startLine:i.startPosition.row+1,endLine:i.endPosition.row+1}}function oe(i){if(!i)return[];let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);if(n.type==="parameter"){let s=n.childForFieldName("pattern"),r=n.childForFieldName("type"),o=s?.text??"",a=r?.text?.trim();e.push({name:o,type:a||void 0,isOptional:!1,defaultValue:void 0})}else if(n.type==="self_parameter")continue}return e}function G(i){let e=[],t=i.previousNamedSibling;for(;t&&t.type==="attribute_item";)e.unshift(t.text.trim()),t=t.previousNamedSibling;return e}function ae(i){let e=[],t=u(i,["struct_item","enum_item","trait_item"]);for(let n of t){let s=n.childForFieldName("name")?.text??"",r=C(n,"pub"),o=G(n),a=n.childForFieldName("body");e.push({name:s,methods:[],properties:S(a,"rust"),isPublic:r,implements:[],extends:void 0,decorators:o,startLine:n.startPosition.row+1,endLine:n.endPosition.row+1})}return e}function ce(i){return u(i,["use_declaration"]).map(t=>({module:t.childForFieldName("argument")?.text??t.text.replace(/^\s*use\s+/,"").replace(/;\s*$/,"").trim(),namedImports:[],isTypeOnly:!1}))}function $(i){return i.map(e=>{let t="",n=[],s,r=L(e),o=r.includes("public")||r.includes("open"),a=!1;for(let l=0;l<e.childCount;l++){let d=e.child(l);e.fieldNameForChild(l)==="name"&&(d.type==="simple_identifier"?t=d.text:t||(s=d.text)),d.type==="parameter"&&n.push(d),(d.type==="async"||d.text==="async")&&(a=!0)}if(!t){for(let l=0;l<e.childCount;l++)if(e.child(l).type==="simple_identifier"){t=e.child(l).text;break}}let c=null;for(let l=0;l<e.childCount;l++)if(e.child(l).type==="function_body"){c=e.child(l);break}return{name:t,parameters:le(n),returnType:s,isAsync:a,isPublic:o,complexity:_(c),decorators:[],genericParams:[],startLine:e.startPosition.row+1,endLine:e.endPosition.row+1}})}function L(i){let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);if(n.type==="modifiers")for(let s=0;s<n.childCount;s++)e.push(n.child(s).text.trim())}return e}function le(i){return i.map(e=>{let n=e.text.split(":"),s=n[0]?.trim().split(/\s+/)??[],r=s[s.length-1]||"",o=n.slice(1).join(":").trim()||void 0;return{name:r,type:o,isOptional:o?.endsWith("?")||!1,defaultValue:void 0}})}function de(i){return u(i,["class_declaration","struct_declaration","protocol_declaration"]).map(n=>{let s=n.childForFieldName("name"),r=s?.text??"",o=L(n),a=o.includes("public")||o.includes("open"),c=[];for(let p=0;p<n.childCount;p++){let f=n.child(p);f.type==="type_identifier"&&f!==s&&c.push(f.text),(f.type==="inheritance_specifier"||f.type==="user_type")&&c.push(f.text)}let l=n.childForFieldName("body"),d=l?h(l,["function_declaration"],2):[],m=$(d);return{name:r,methods:m,properties:S(l,"swift"),isPublic:a,implements:c.slice(1),extends:c[0]||void 0,decorators:[],startLine:n.startPosition.row+1,endLine:n.endPosition.row+1}})}function ue(i){return u(i,["import_declaration"]).map(t=>{let n="";for(let s=0;s<t.childCount;s++){let r=t.child(s);(r.type==="identifier"||r.type==="simple_identifier")&&(n=r.text)}return{module:n,namedImports:[],isTypeOnly:!1}})}var v=class{language;supportedExtensions;constructor(e,t){this.language=e,this.supportedExtensions=t}async parseFile(e,t){let n=await X(this.language),s=y.Parser??y,r=new s;r.setLanguage(n);let o=r.parse(e),a=o.rootNode;try{return{...this.extractFromAST(a),language:this.language,filePath:t}}finally{o.delete(),r.delete()}}extractFromAST(e){let t=O[this.language];switch(this.language){case"python":{let n=u(e,t.nodeTypes.functionDecl),s=u(e,["decorated_definition"]).map(d=>{for(let m=0;m<d.childCount;m++)if(t.nodeTypes.functionDecl.includes(d.child(m).type))return d.child(m);return null}).filter(Boolean),r=[...n,...s],o=u(e,t.nodeTypes.classDecl),a=u(e,["decorated_definition"]).map(d=>{for(let m=0;m<d.childCount;m++)if(t.nodeTypes.classDecl.includes(d.child(m).type))return d.child(m);return null}).filter(Boolean),c=[...o,...a],l=u(e,t.nodeTypes.importDecl);return{functions:k(r),classes:Q(c),imports:H(l)}}case"java":{let n=h(e,t.nodeTypes.classDecl),s=u(e,t.nodeTypes.importDecl),o=[...u(e,t.nodeTypes.functionDecl)];for(let a of n){let c=a.childForFieldName("body");c&&o.push(...u(c,t.nodeTypes.functionDecl))}return{functions:T(o),classes:Z(n),imports:ee(s)}}case"csharp":return{functions:te(e),classes:se(e),imports:ie(e)};case"rust":return{functions:re(e,t),classes:ae(e),imports:ce(e)};case"swift":{let n=h(e,t.nodeTypes.functionDecl);return{functions:$(n),classes:de(e),imports:ue(e)}}default:return{functions:[],classes:[],imports:[]}}}},me={python:[".py"],java:[".java"],csharp:[".cs"],rust:[".rs"],swift:[".swift"]};function xe(){let i=new Map;for(let[e,t]of Object.entries(me))i.set(e,new v(e,t));return i}function pe(){if(process.env.AQE_PARSER_REGEX_ONLY==="1"||process.env.AQE_PARSER_REGEX_ONLY==="true")return!1;try{let{createRequire:i}=B;return i(import.meta.url).resolve("web-tree-sitter"),I("tree-sitter-python.wasm"),!0}catch{return!1}}var R=new Map;async function Fe(i){if(!pe())return null;try{await E();let e=R.get(i);return e||(e=await y.Language.load(I(i)),R.set(i,e)),{parse:t=>{let n=y.Parser??y,s=new n;s.setLanguage(e);let r=s.parse(t);return s.delete?.(),r}}}catch{return null}}function Ne(){y=null,g=null,F=0,w.clear()}export{v as a,xe as b,pe as c,Fe as d,Ne as e};
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
+ import{d as D,e as V}from"./chunk-7CD7PBHY.js";V();import*as A from"node:fs";import B from"node:module";import*as N from"node:path";import{fileURLToPath as J}from"node:url";var b=D("TreeSitterWASM"),O={python:{wasmFile:"tree-sitter-python.wasm",nodeTypes:{functionDecl:["function_definition"],classDecl:["class_definition"],importDecl:["import_statement","import_from_statement"]}},java:{wasmFile:"tree-sitter-java.wasm",nodeTypes:{functionDecl:["method_declaration","constructor_declaration"],classDecl:["class_declaration","interface_declaration"],importDecl:["import_declaration"]}},csharp:{wasmFile:"tree-sitter-c_sharp.wasm",nodeTypes:{functionDecl:["method_declaration","constructor_declaration"],classDecl:["class_declaration","interface_declaration"],importDecl:["using_directive"]}},rust:{wasmFile:"tree-sitter-rust.wasm",nodeTypes:{functionDecl:["function_item"],classDecl:[],importDecl:["use_declaration"],implBlock:"impl_item",structDecl:"struct_item"}},swift:{wasmFile:"tree-sitter-swift.wasm",nodeTypes:{functionDecl:["function_declaration"],classDecl:["class_declaration"],importDecl:["import_declaration"],structDecl:"struct_declaration",protocolDecl:"protocol_declaration"}}},y=null,g=null,F=0,P=3,w=new Map;function I(i){let e=J(new URL(".",import.meta.url)),t=[N.resolve(e,"..","..","..","assets","grammars",i),N.resolve(e,"..","..","assets","grammars",i),N.resolve(process.cwd(),"assets","grammars",i),N.resolve(e,"..","assets","grammars",i)];for(let n of t)if(A.existsSync(n))return n;throw new Error(`Grammar file ${i} not found. Searched: ${t.join(", ")}`)}async function E(){if(F>=P)throw new Error(`web-tree-sitter failed to initialize after ${P} attempts`);if(!y)return g||(g=(async()=>{try{let i=await import("./web-tree-sitter-AVWA6HKE.js"),e=i.default??i;await(e.Parser?.init??e.init).call(e.Parser??e),y=e,F=0,b.info("web-tree-sitter WASM runtime initialized")}catch(i){F++,g=null;let e=i instanceof Error?i.message:String(i);throw b.warn(`web-tree-sitter WASM init failed (attempt ${F}/${P}): ${e}. `+(F<P?"Will retry on next parse.":"Falling back to regex permanently.")),i}})()),g}async function X(i){let e=w.get(i);if(e)return e;await E();let t=O[i];if(!t)throw new Error(`No WASM grammar config for ${i}`);try{let n=I(t.wasmFile),s=await y.Language.load(n);return w.set(i,s),b.info(`Loaded tree-sitter WASM grammar for ${i}`),s}catch(n){let s=n instanceof Error?n.message:String(n);throw b.warn(`Failed to load WASM grammar for ${i}: ${s}. Falling back to regex parser.`),n}}function u(i,e){let t=[];for(let n=0;n<i.childCount;n++){let s=i.child(n);e.includes(s.type)&&t.push(s)}return t}function h(i,e,t=10){let n=[];function s(r,o){if(!(o>t))for(let a=0;a<r.childCount;a++){let c=r.child(a);e.includes(c.type)&&n.push(c),s(c,o+1)}}return s(i,0),n}function x(i){let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);(n.type==="modifiers"||n.type==="modifier"||n.type==="visibility_modifier")&&e.push(n.text.trim())}return e}function C(i,e){return x(i).some(t=>t.includes(e))}var Y=new Set(["if_statement","if_expression","if_let_statement","while_statement","while_expression","for_statement","for_in_statement","for_expression","enhanced_for_statement","match_expression","switch_statement","switch_expression","case_clause","match_arm","switch_entry","catch_clause","except_clause","catch_block","binary_expression","conditional_expression","ternary_expression"]),q=new Set(["&&","||","and","or"]);function _(i){if(!i)return 1;let e=1;function t(n){if(Y.has(n.type))if(n.type==="binary_expression"){let s=n.childForFieldName("operator");s&&q.has(s.text)&&e++}else e++;for(let s=0;s<n.childCount;s++)t(n.child(s))}return t(i),e}function S(i,e){if(!i)return[];let t=[];for(let n=0;n<i.childCount;n++){let s=i.child(n);switch(e){case"java":if(s.type==="field_declaration"){let r=x(s),o=s.childForFieldName("type")?.text?.trim(),a=s.childForFieldName("declarator"),c=a?.childForFieldName("name")?.text??a?.text?.split(/[=;]/)[0]?.trim()??"";c&&t.push({name:c,type:o||void 0,isPublic:r.some(l=>l.includes("public")),isReadonly:r.some(l=>l.includes("final"))})}break;case"csharp":if(s.type==="field_declaration"||s.type==="property_declaration"){let r=x(s),o=s.childForFieldName("type")?.text?.trim(),a=s.childForFieldName("name")?.text??"";a&&t.push({name:a,type:o||void 0,isPublic:r.some(c=>c.includes("public")),isReadonly:r.some(c=>c.includes("readonly"))})}break;case"rust":if(s.type==="field_declaration"){let r=s.childForFieldName("name")?.text??"",o=s.childForFieldName("type")?.text?.trim(),a=C(s,"pub");r&&t.push({name:r,type:o||void 0,isPublic:a,isReadonly:!1})}break;case"swift":if(s.type==="property_declaration"){let r=L(s),o=s.childForFieldName("name")?.text??"",a=s.childForFieldName("type")?.text?.trim(),c=r.includes("public")||r.includes("open"),l=s.text.includes("let ");o&&t.push({name:o,type:a||void 0,isPublic:c,isReadonly:l})}break;case"python":if(s.type==="expression_statement"){let r=s.child(0);if(r?.type==="assignment"){let o=r.childForFieldName("left");if(o?.type==="attribute"||o?.type==="identifier"){let a=o.text.replace("self.","");t.push({name:a,type:void 0,isPublic:!a.startsWith("_"),isReadonly:!1})}}}break}}return t}function k(i){return i.map(e=>{let t=e.childForFieldName("name")?.text??"",n=e.childForFieldName("parameters"),s=e.childForFieldName("return_type"),r=e.childForFieldName("body"),o=e.text.trimStart().startsWith("async"),a=W(e);return{name:t,parameters:z(n),returnType:s?.text?.trim()||void 0,isAsync:o,isPublic:!t.startsWith("_"),complexity:_(r),decorators:a,genericParams:[],startLine:e.startPosition.row+1,endLine:e.endPosition.row+1}})}function z(i){if(!i)return[];let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);if(n.type==="identifier"){let s=n.text;if(s==="self"||s==="cls")continue;e.push({name:s,type:void 0,isOptional:!1,defaultValue:void 0})}else if(n.type==="typed_parameter"){let s=n.child(0)?.text??"";if(s==="self"||s==="cls")continue;let r=n.childForFieldName("type")?.text?.trim();e.push({name:s,type:r||void 0,isOptional:!1,defaultValue:void 0})}else if(n.type==="default_parameter"||n.type==="typed_default_parameter"){let s=n.childForFieldName("name")?.text??n.child(0)?.text??"";if(s==="self"||s==="cls")continue;let r=n.childForFieldName("type")?.text?.trim(),o=n.childForFieldName("value")?.text?.trim();e.push({name:s,type:r||void 0,isOptional:!0,defaultValue:o||void 0})}else if(n.type==="list_splat_pattern"||n.type==="dictionary_splat_pattern"){let s=n.text;e.push({name:s,type:void 0,isOptional:!0,defaultValue:void 0})}}return e}function W(i){let e=[],t=i.parent;if(!t)return e;if(t.type==="decorated_definition")for(let n=0;n<t.childCount;n++){let s=t.child(n);s.type==="decorator"&&e.push(s.text.trim())}return e}function Q(i){return i.map(e=>{let t=e.childForFieldName("name")?.text??"",n=e.childForFieldName("body"),s=e.childForFieldName("superclasses"),r=[];if(s)for(let l=0;l<s.childCount;l++){let d=s.child(l);d.isNamed&&r.push(d.text)}let o=n?h(n,["function_definition"],2):[],a=k(o),c=W(e);return{name:t,methods:a,properties:S(n,"python"),isPublic:!t.startsWith("_"),implements:[],extends:r[0]||void 0,decorators:c,startLine:e.startPosition.row+1,endLine:e.endPosition.row+1}})}function H(i){return i.map(e=>{if(e.type==="import_from_statement"){let n=e.childForFieldName("module_name")?.text??"",s=[];for(let r=0;r<e.childCount;r++){let o=e.child(r);e.fieldNameForChild(r)==="name"&&o.isNamed&&s.push(o.text)}return{module:n,namedImports:s,isTypeOnly:!1}}return{module:e.childForFieldName("name")?.text??"",namedImports:[],isTypeOnly:!1}})}function T(i){return i.map(e=>{let t=e.childForFieldName("name")?.text??"",n=e.childForFieldName("type"),s=e.childForFieldName("parameters"),r=e.childForFieldName("body"),a=x(e).some(d=>d.includes("public")),c=n?.text?.includes("CompletableFuture")??!1,l=M(e);return{name:t,parameters:K(s),returnType:n?.text==="void"?void 0:n?.text?.trim(),isAsync:c,isPublic:a,complexity:_(r),decorators:l,genericParams:[],startLine:e.startPosition.row+1,endLine:e.endPosition.row+1}})}function K(i){if(!i)return[];let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);if(n.type==="formal_parameter"||n.type==="spread_parameter"){let s=n.childForFieldName("name")?.text??"",r=n.childForFieldName("type")?.text?.trim();e.push({name:s,type:r||void 0,isOptional:!1,defaultValue:void 0})}}return e}function M(i){let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);if(n.type==="modifiers")for(let s=0;s<n.childCount;s++){let r=n.child(s);(r.type==="marker_annotation"||r.type==="annotation")&&e.push(r.text.trim())}}return e}function Z(i){return i.map(e=>{let t=e.childForFieldName("name")?.text??"",n=e.childForFieldName("body"),r=x(e).some(p=>p.includes("public")),o=e.childForFieldName("superclass")?.text,a=e.childForFieldName("interfaces"),c=[];if(a)for(let p=0;p<a.childCount;p++){let f=a.child(p);f.isNamed&&c.push(f.text)}let l=n?u(n,["method_declaration","constructor_declaration"]):[],d=T(l),m=M(e);return{name:t,methods:d,properties:S(n,"java"),isPublic:r,implements:c,extends:o||void 0,decorators:m,startLine:e.startPosition.row+1,endLine:e.endPosition.row+1}})}function ee(i){return i.map(e=>{let t=e.text.replace(/^\s*import\s+(static\s+)?/,"").replace(/;\s*$/,"").trim(),n=t.split("."),s=n[n.length-1];return{module:t,namedImports:s==="*"?[]:[s],isTypeOnly:!1}})}function te(i){return h(i,["method_declaration","constructor_declaration"]).map(t=>{let n=t.childForFieldName("name")?.text??"",s=t.childForFieldName("type"),r=t.childForFieldName("parameters"),o=x(t),a=o.some(d=>d.includes("public")),c=o.some(d=>d.includes("async"))||s?.text?.includes("Task")||!1,l=j(t);return{name:n,parameters:ne(r),returnType:s?.text==="void"?void 0:s?.text?.trim(),isAsync:c,isPublic:a,complexity:_(t.childForFieldName("body")),decorators:l,genericParams:[],startLine:t.startPosition.row+1,endLine:t.endPosition.row+1}})}function ne(i){if(!i)return[];let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);if(n.type==="parameter"){let s=n.childForFieldName("name")?.text??"",r=n.childForFieldName("type")?.text?.trim();e.push({name:s,type:r||void 0,isOptional:r?.endsWith("?")||!1,defaultValue:void 0})}}return e}function j(i){let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);n.type==="attribute_list"&&e.push(n.text.trim())}return e}function se(i){return h(i,["class_declaration","interface_declaration"]).map(t=>{let n=t.childForFieldName("name")?.text??"",s=t.childForFieldName("body"),o=x(t).some(p=>p.includes("public")),a=t.childForFieldName("bases"),c=[];if(a)for(let p=0;p<a.childCount;p++){let f=a.child(p);f.isNamed&&c.push(f.text)}let l=s?u(s,["method_declaration","constructor_declaration"]):[],d=T(l),m=j(t);return{name:n,methods:d,properties:S(s,"csharp"),isPublic:o,implements:c.slice(1),extends:c[0]||void 0,decorators:m,startLine:t.startPosition.row+1,endLine:t.endPosition.row+1}})}function ie(i){return h(i,["using_directive"]).map(t=>({module:t.text.replace(/^\s*using\s+(static\s+)?/,"").replace(/;\s*$/,"").trim(),namedImports:[],isTypeOnly:!1}))}function re(i,e){let t=[],n=u(i,e.nodeTypes.functionDecl);if(t.push(...n.map(U)),e.nodeTypes.implBlock){let s=u(i,[e.nodeTypes.implBlock]);for(let r of s){let o=r.childForFieldName("body");if(o){let a=u(o,e.nodeTypes.functionDecl);t.push(...a.map(U))}}}return t}function U(i){let e=i.childForFieldName("name")?.text??"",t=i.childForFieldName("parameters"),n=i.childForFieldName("return_type"),s=i.childForFieldName("body"),r=C(i,"pub"),o=i.text.trimStart().startsWith("pub async")||i.text.trimStart().startsWith("async"),a=G(i);return{name:e,parameters:oe(t),returnType:n?.text?.trim()||void 0,isAsync:o,isPublic:r,complexity:_(s),decorators:a,genericParams:[],startLine:i.startPosition.row+1,endLine:i.endPosition.row+1}}function oe(i){if(!i)return[];let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);if(n.type==="parameter"){let s=n.childForFieldName("pattern"),r=n.childForFieldName("type"),o=s?.text??"",a=r?.text?.trim();e.push({name:o,type:a||void 0,isOptional:!1,defaultValue:void 0})}else if(n.type==="self_parameter")continue}return e}function G(i){let e=[],t=i.previousNamedSibling;for(;t&&t.type==="attribute_item";)e.unshift(t.text.trim()),t=t.previousNamedSibling;return e}function ae(i){let e=[],t=u(i,["struct_item","enum_item","trait_item"]);for(let n of t){let s=n.childForFieldName("name")?.text??"",r=C(n,"pub"),o=G(n),a=n.childForFieldName("body");e.push({name:s,methods:[],properties:S(a,"rust"),isPublic:r,implements:[],extends:void 0,decorators:o,startLine:n.startPosition.row+1,endLine:n.endPosition.row+1})}return e}function ce(i){return u(i,["use_declaration"]).map(t=>({module:t.childForFieldName("argument")?.text??t.text.replace(/^\s*use\s+/,"").replace(/;\s*$/,"").trim(),namedImports:[],isTypeOnly:!1}))}function $(i){return i.map(e=>{let t="",n=[],s,r=L(e),o=r.includes("public")||r.includes("open"),a=!1;for(let l=0;l<e.childCount;l++){let d=e.child(l);e.fieldNameForChild(l)==="name"&&(d.type==="simple_identifier"?t=d.text:t||(s=d.text)),d.type==="parameter"&&n.push(d),(d.type==="async"||d.text==="async")&&(a=!0)}if(!t){for(let l=0;l<e.childCount;l++)if(e.child(l).type==="simple_identifier"){t=e.child(l).text;break}}let c=null;for(let l=0;l<e.childCount;l++)if(e.child(l).type==="function_body"){c=e.child(l);break}return{name:t,parameters:le(n),returnType:s,isAsync:a,isPublic:o,complexity:_(c),decorators:[],genericParams:[],startLine:e.startPosition.row+1,endLine:e.endPosition.row+1}})}function L(i){let e=[];for(let t=0;t<i.childCount;t++){let n=i.child(t);if(n.type==="modifiers")for(let s=0;s<n.childCount;s++)e.push(n.child(s).text.trim())}return e}function le(i){return i.map(e=>{let n=e.text.split(":"),s=n[0]?.trim().split(/\s+/)??[],r=s[s.length-1]||"",o=n.slice(1).join(":").trim()||void 0;return{name:r,type:o,isOptional:o?.endsWith("?")||!1,defaultValue:void 0}})}function de(i){return u(i,["class_declaration","struct_declaration","protocol_declaration"]).map(n=>{let s=n.childForFieldName("name"),r=s?.text??"",o=L(n),a=o.includes("public")||o.includes("open"),c=[];for(let p=0;p<n.childCount;p++){let f=n.child(p);f.type==="type_identifier"&&f!==s&&c.push(f.text),(f.type==="inheritance_specifier"||f.type==="user_type")&&c.push(f.text)}let l=n.childForFieldName("body"),d=l?h(l,["function_declaration"],2):[],m=$(d);return{name:r,methods:m,properties:S(l,"swift"),isPublic:a,implements:c.slice(1),extends:c[0]||void 0,decorators:[],startLine:n.startPosition.row+1,endLine:n.endPosition.row+1}})}function ue(i){return u(i,["import_declaration"]).map(t=>{let n="";for(let s=0;s<t.childCount;s++){let r=t.child(s);(r.type==="identifier"||r.type==="simple_identifier")&&(n=r.text)}return{module:n,namedImports:[],isTypeOnly:!1}})}var v=class{language;supportedExtensions;constructor(e,t){this.language=e,this.supportedExtensions=t}async parseFile(e,t){let n=await X(this.language),s=y.Parser??y,r=new s;r.setLanguage(n);let o=r.parse(e),a=o.rootNode;try{return{...this.extractFromAST(a),language:this.language,filePath:t}}finally{o.delete(),r.delete()}}extractFromAST(e){let t=O[this.language];switch(this.language){case"python":{let n=u(e,t.nodeTypes.functionDecl),s=u(e,["decorated_definition"]).map(d=>{for(let m=0;m<d.childCount;m++)if(t.nodeTypes.functionDecl.includes(d.child(m).type))return d.child(m);return null}).filter(Boolean),r=[...n,...s],o=u(e,t.nodeTypes.classDecl),a=u(e,["decorated_definition"]).map(d=>{for(let m=0;m<d.childCount;m++)if(t.nodeTypes.classDecl.includes(d.child(m).type))return d.child(m);return null}).filter(Boolean),c=[...o,...a],l=u(e,t.nodeTypes.importDecl);return{functions:k(r),classes:Q(c),imports:H(l)}}case"java":{let n=h(e,t.nodeTypes.classDecl),s=u(e,t.nodeTypes.importDecl),o=[...u(e,t.nodeTypes.functionDecl)];for(let a of n){let c=a.childForFieldName("body");c&&o.push(...u(c,t.nodeTypes.functionDecl))}return{functions:T(o),classes:Z(n),imports:ee(s)}}case"csharp":return{functions:te(e),classes:se(e),imports:ie(e)};case"rust":return{functions:re(e,t),classes:ae(e),imports:ce(e)};case"swift":{let n=h(e,t.nodeTypes.functionDecl);return{functions:$(n),classes:de(e),imports:ue(e)}}default:return{functions:[],classes:[],imports:[]}}}},me={python:[".py"],java:[".java"],csharp:[".cs"],rust:[".rs"],swift:[".swift"]};function xe(){let i=new Map;for(let[e,t]of Object.entries(me))i.set(e,new v(e,t));return i}function pe(){if(process.env.AQE_PARSER_REGEX_ONLY==="1"||process.env.AQE_PARSER_REGEX_ONLY==="true")return!1;try{let{createRequire:i}=B;return i(import.meta.url).resolve("web-tree-sitter"),I("tree-sitter-python.wasm"),!0}catch{return!1}}var R=new Map;async function Fe(i){if(!pe())return null;try{await E();let e=R.get(i);return e||(e=await y.Language.load(I(i)),R.set(i,e)),{parse:t=>{let n=y.Parser??y,s=new n;s.setLanguage(e);let r=s.parse(t);return s.delete?.(),r}}}catch{return null}}function Ne(){y=null,g=null,F=0,w.clear()}export{v as a,xe as b,pe as c,Fe as d,Ne as e};
@@ -0,0 +1,65 @@
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
+ import{d as W,e as V,f as se,g as X}from"./chunk-5WOSWNDN.js";import{a as oe}from"./chunk-WJTSY5MC.js";import{b as ke}from"./chunk-ZBABIZ2D.js";import{a as ae,b as Ne,d as Me,f as dt}from"./chunk-SX4JLSLV.js";import{c as G,e as He,f as Le}from"./chunk-HBCGYMQU.js";import{a as ce}from"./chunk-6CR4VQBQ.js";import{c as _e,n as T,o as j}from"./chunk-KIP6WZGV.js";import{b as Oe,c as lt}from"./chunk-C3HQL6S4.js";import{c as P,d as v}from"./chunk-XEZIIQYJ.js";import{a as S,b as De,c as Fe}from"./chunk-J5UNP6W3.js";import{i as F}from"./chunk-W2XCZU62.js";import{B as $,D as L,G as ie,P as k,S as O,b as D}from"./chunk-WJHWH5D2.js";import{c as B,e as ct}from"./chunk-JSZ663MU.js";var Z=B(E=>{var St=E&&E.__extends||(function(){var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var s in i)i.hasOwnProperty(s)&&(r[s]=i[s])},n(e,t)};return function(e,t){n(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}})();Object.defineProperty(E,"__esModule",{value:!0});var wt=Object.prototype.hasOwnProperty;function me(n,e){return wt.call(n,e)}E.hasOwnProperty=me;function We(n){if(Array.isArray(n)){for(var e=new Array(n.length),t=0;t<e.length;t++)e[t]=""+t;return e}if(Object.keys)return Object.keys(n);var r=[];for(var i in n)me(n,i)&&r.push(i);return r}E._objectKeys=We;function Pt(n){switch(typeof n){case"object":return JSON.parse(JSON.stringify(n));case"undefined":return null;default:return n}}E._deepClone=Pt;function bt(n){for(var e=0,t=n.length,r;e<t;){if(r=n.charCodeAt(e),r>=48&&r<=57){e++;continue}return!1}return!0}E.isInteger=bt;function he(n){return n.indexOf("/")===-1&&n.indexOf("~")===-1?n:n.replace(/~/g,"~0").replace(/\//g,"~1")}E.escapePathComponent=he;function Et(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}E.unescapePathComponent=Et;function pe(n,e){var t;for(var r in n)if(me(n,r)){if(n[r]===e)return he(r)+"/";if(typeof n[r]=="object"&&(t=pe(n[r],e),t!=""))return he(r)+"/"+t}return""}E._getPathRecursive=pe;function Rt(n,e){if(n===e)return"/";var t=pe(n,e);if(t==="")throw new Error("Object not found in root");return"/"+t}E.getPath=Rt;function fe(n){if(n===void 0)return!0;if(n){if(Array.isArray(n)){for(var e=0,t=n.length;e<t;e++)if(fe(n[e]))return!0}else if(typeof n=="object"){for(var r=We(n),i=r.length,s=0;s<i;s++)if(fe(n[r[s]]))return!0}}return!1}E.hasUndefined=fe;function je(n,e){var t=[n];for(var r in e){var i=typeof e[r]=="object"?JSON.stringify(e[r],null,2):e[r];typeof i<"u"&&t.push(r+": "+i)}return t.join(`
3
+ `)}var At=(function(n){St(e,n);function e(t,r,i,s,o){var c=this.constructor,d=n.call(this,je(t,{name:r,index:i,operation:s,tree:o}))||this;return d.name=r,d.index=i,d.operation=s,d.tree=o,Object.setPrototypeOf(d,c.prototype),d.message=je(t,{name:r,index:i,operation:s,tree:o}),d}return e})(Error);E.PatchError=At});var ge=B(g=>{Object.defineProperty(g,"__esModule",{value:!0});var A=Z();g.JsonPatchError=A.PatchError;g.deepClone=A._deepClone;var U={add:function(n,e,t){return n[e]=this.value,{newDocument:t}},remove:function(n,e,t){var r=n[e];return delete n[e],{newDocument:t,removed:r}},replace:function(n,e,t){var r=n[e];return n[e]=this.value,{newDocument:t,removed:r}},move:function(n,e,t){var r=ee(t,this.path);r&&(r=A._deepClone(r));var i=_(t,{op:"remove",path:this.from}).removed;return _(t,{op:"add",path:this.path,value:i}),{newDocument:t,removed:r}},copy:function(n,e,t){var r=ee(t,this.from);return _(t,{op:"add",path:this.path,value:A._deepClone(r)}),{newDocument:t}},test:function(n,e,t){return{newDocument:t,test:J(n[e],this.value)}},_get:function(n,e,t){return this.value=n[e],{newDocument:t}}},Tt={add:function(n,e,t){return A.isInteger(e)?n.splice(e,0,this.value):n[e]=this.value,{newDocument:t,index:e}},remove:function(n,e,t){var r=n.splice(e,1);return{newDocument:t,removed:r[0]}},replace:function(n,e,t){var r=n[e];return n[e]=this.value,{newDocument:t,removed:r}},move:U.move,copy:U.copy,test:U.test,_get:U._get};function ee(n,e){if(e=="")return n;var t={op:"_get",path:e};return _(n,t),t.value}g.getValueByPointer=ee;function _(n,e,t,r,i,s){if(t===void 0&&(t=!1),r===void 0&&(r=!0),i===void 0&&(i=!0),s===void 0&&(s=0),t&&(typeof t=="function"?t(e,0,n,e.path):te(e,0)),e.path===""){var o={newDocument:n};if(e.op==="add")return o.newDocument=e.value,o;if(e.op==="replace")return o.newDocument=e.value,o.removed=n,o;if(e.op==="move"||e.op==="copy")return o.newDocument=ee(n,e.from),e.op==="move"&&(o.removed=n),o;if(e.op==="test"){if(o.test=J(n,e.value),o.test===!1)throw new g.JsonPatchError("Test operation failed","TEST_OPERATION_FAILED",s,e,n);return o.newDocument=n,o}else{if(e.op==="remove")return o.removed=n,o.newDocument=null,o;if(e.op==="_get")return e.value=n,o;if(t)throw new g.JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",s,e,n);return o}}else{r||(n=A._deepClone(n));var c=e.path||"",d=c.split("/"),a=n,l=1,h=d.length,f=void 0,u=void 0,m=void 0;for(typeof t=="function"?m=t:m=te;;){if(u=d[l],u&&u.indexOf("~")!=-1&&(u=A.unescapePathComponent(u)),i&&(u=="__proto__"||u=="prototype"&&l>0&&d[l-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(t&&f===void 0&&(a[u]===void 0?f=d.slice(0,l).join("/"):l==h-1&&(f=e.path),f!==void 0&&m(e,0,n,f)),l++,Array.isArray(a)){if(u==="-")u=a.length;else{if(t&&!A.isInteger(u))throw new g.JsonPatchError("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",s,e,n);A.isInteger(u)&&(u=~~u)}if(l>=h){if(t&&e.op==="add"&&u>a.length)throw new g.JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",s,e,n);var o=Tt[e.op].call(e,a,u,n);if(o.test===!1)throw new g.JsonPatchError("Test operation failed","TEST_OPERATION_FAILED",s,e,n);return o}}else if(l>=h){var o=U[e.op].call(e,a,u,n);if(o.test===!1)throw new g.JsonPatchError("Test operation failed","TEST_OPERATION_FAILED",s,e,n);return o}if(a=a[u],t&&l<h&&(!a||typeof a!="object"))throw new g.JsonPatchError("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",s,e,n)}}}g.applyOperation=_;function Ve(n,e,t,r,i){if(r===void 0&&(r=!0),i===void 0&&(i=!0),t&&!Array.isArray(e))throw new g.JsonPatchError("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(n=A._deepClone(n));for(var s=new Array(e.length),o=0,c=e.length;o<c;o++)s[o]=_(n,e[o],t,!0,i,o),n=s[o].newDocument;return s.newDocument=n,s}g.applyPatch=Ve;function Ct(n,e,t){var r=_(n,e);if(r.test===!1)throw new g.JsonPatchError("Test operation failed","TEST_OPERATION_FAILED",t,e,n);return r.newDocument}g.applyReducer=Ct;function te(n,e,t,r){if(typeof n!="object"||n===null||Array.isArray(n))throw new g.JsonPatchError("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,n,t);if(U[n.op]){if(typeof n.path!="string")throw new g.JsonPatchError("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,n,t);if(n.path.indexOf("/")!==0&&n.path.length>0)throw new g.JsonPatchError('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,n,t);if((n.op==="move"||n.op==="copy")&&typeof n.from!="string")throw new g.JsonPatchError("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,n,t);if((n.op==="add"||n.op==="replace"||n.op==="test")&&n.value===void 0)throw new g.JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,n,t);if((n.op==="add"||n.op==="replace"||n.op==="test")&&A.hasUndefined(n.value))throw new g.JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,n,t);if(t){if(n.op=="add"){var i=n.path.split("/").length,s=r.split("/").length;if(i!==s+1&&i!==s)throw new g.JsonPatchError("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,n,t)}else if(n.op==="replace"||n.op==="remove"||n.op==="_get"){if(n.path!==r)throw new g.JsonPatchError("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,n,t)}else if(n.op==="move"||n.op==="copy"){var o={op:"_get",path:n.from,value:void 0},c=Xe([o],t);if(c&&c.name==="OPERATION_PATH_UNRESOLVABLE")throw new g.JsonPatchError("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,n,t)}}}else throw new g.JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,n,t)}g.validator=te;function Xe(n,e,t){try{if(!Array.isArray(n))throw new g.JsonPatchError("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)Ve(A._deepClone(e),A._deepClone(n),t||!0);else{t=t||te;for(var r=0;r<n.length;r++)t(n[r],r,e,void 0)}}catch(i){if(i instanceof g.JsonPatchError)return i;throw i}}g.validate=Xe;function J(n,e){if(n===e)return!0;if(n&&e&&typeof n=="object"&&typeof e=="object"){var t=Array.isArray(n),r=Array.isArray(e),i,s,o;if(t&&r){if(s=n.length,s!=e.length)return!1;for(i=s;i--!==0;)if(!J(n[i],e[i]))return!1;return!0}if(t!=r)return!1;var c=Object.keys(n);if(s=c.length,s!==Object.keys(e).length)return!1;for(i=s;i--!==0;)if(!e.hasOwnProperty(c[i]))return!1;for(i=s;i--!==0;)if(o=c[i],!J(n[o],e[o]))return!1;return!0}return n!==n&&e!==e}g._areEquals=J});var Ge=B(q=>{Object.defineProperty(q,"__esModule",{value:!0});var b=Z(),xt=ge(),ve=new WeakMap,It=(function(){function n(e){this.observers=new Map,this.obj=e}return n})(),Dt=(function(){function n(e,t){this.callback=e,this.observer=t}return n})();function Ft(n){return ve.get(n)}function Ot(n,e){return n.observers.get(e)}function _t(n,e){n.observers.delete(e.callback)}function Nt(n,e){e.unobserve()}q.unobserve=Nt;function Mt(n,e){var t=[],r,i=Ft(n);if(!i)i=new It(n),ve.set(n,i);else{var s=Ot(i,e);r=s&&s.observer}if(r)return r;if(r={},i.value=b._deepClone(n),e){r.callback=e,r.next=null;var o=function(){ye(r)},c=function(){clearTimeout(r.next),r.next=setTimeout(o)};typeof window<"u"&&(window.addEventListener("mouseup",c),window.addEventListener("keyup",c),window.addEventListener("mousedown",c),window.addEventListener("keydown",c),window.addEventListener("change",c))}return r.patches=t,r.object=n,r.unobserve=function(){ye(r),clearTimeout(r.next),_t(i,r),typeof window<"u"&&(window.removeEventListener("mouseup",c),window.removeEventListener("keyup",c),window.removeEventListener("mousedown",c),window.removeEventListener("keydown",c),window.removeEventListener("change",c))},i.observers.set(e,new Dt(e,r)),r}q.observe=Mt;function ye(n,e){e===void 0&&(e=!1);var t=ve.get(n.object);Se(t.value,n.object,n.patches,"",e),n.patches.length&&xt.applyPatch(t.value,n.patches);var r=n.patches;return r.length>0&&(n.patches=[],n.callback&&n.callback(r)),r}q.generate=ye;function Se(n,e,t,r,i){if(e!==n){typeof e.toJSON=="function"&&(e=e.toJSON());for(var s=b._objectKeys(e),o=b._objectKeys(n),c=!1,d=!1,a=o.length-1;a>=0;a--){var l=o[a],h=n[l];if(b.hasOwnProperty(e,l)&&!(e[l]===void 0&&h!==void 0&&Array.isArray(e)===!1)){var f=e[l];typeof h=="object"&&h!=null&&typeof f=="object"&&f!=null&&Array.isArray(h)===Array.isArray(f)?Se(h,f,t,r+"/"+b.escapePathComponent(l),i):h!==f&&(c=!0,i&&t.push({op:"test",path:r+"/"+b.escapePathComponent(l),value:b._deepClone(h)}),t.push({op:"replace",path:r+"/"+b.escapePathComponent(l),value:b._deepClone(f)}))}else Array.isArray(n)===Array.isArray(e)?(i&&t.push({op:"test",path:r+"/"+b.escapePathComponent(l),value:b._deepClone(h)}),t.push({op:"remove",path:r+"/"+b.escapePathComponent(l)}),d=!0):(i&&t.push({op:"test",path:r,value:n}),t.push({op:"replace",path:r,value:e}),c=!0)}if(!(!d&&s.length==o.length))for(var a=0;a<s.length;a++){var l=s[a];!b.hasOwnProperty(n,l)&&e[l]!==void 0&&t.push({op:"add",path:r+"/"+b.escapePathComponent(l),value:b._deepClone(e[l])})}}}function Ht(n,e,t){t===void 0&&(t=!1);var r=[];return Se(n,e,r,"",t),r}q.compare=Ht});var Ye=B(N=>{var Lt=ge();Object.assign(N,Lt);var kt=Ge();Object.assign(N,kt);var re=Z();N.JsonPatchError=re.PatchError;N.deepClone=re._deepClone;N.escapePathComponent=re.escapePathComponent;N.unescapePathComponent=re.unescapePathComponent});var R=class extends Error{patternId;disposition;cause;constructor(e,t,r){super(`${t}: pattern ${e}: ${r instanceof Error?r.message:String(r)}`),this.name="PatternMutationError",this.patternId=e,this.disposition=t,this.cause=r}};lt();import{existsSync as Xt}from"node:fs";import{join as st}from"node:path";Fe();var z=class{constructor(e,t){this.createAdapter=e;this.config=t?.base??Y,this.rvfPath=t?.rvfPath??".agentic-qe/patterns.rvf",this.skipCloseOnDispose=t?.skipCloseOnDispose??!1,this.embeddingSpaceId=t?.embeddingSpaceId}createAdapter;config;rvfPath;skipCloseOnDispose;embeddingSpaceId;adapter=null;sqliteStore=null;initialized=!1;rvfInitError=null;searchOps=0;totalSearchMs=0;setSqliteStore(e){this.sqliteStore=e}getAdapter(){return this.adapter}async initialize(){if(!this.initialized){if(this.rvfInitError=null,process.env.AQE_MEMORY_BACKEND==="memory"){this.adapter=null,this.initialized=!0;return}try{!this.embeddingSpaceId&&!T()&&await j(),this.adapter=this.createAdapter(this.rvfPath,this.config.embeddingDimension);let e=T()?.spaceId??this.embeddingSpaceId??null;_e(this.rvfPath,e,this.adapter.status()?.totalVectors??0),this.initialized=!0,console.log(`[RvfPatternStore] Initialized: ${this.rvfPath} (dim=${this.config.embeddingDimension})`)}catch(e){this.rvfInitError=S(e);try{this.adapter?.close()}catch{}console.error(`[RvfPatternStore] ERROR: RVF initialization failed \u2014 vector search is DISABLED. Cause: ${this.rvfInitError}. Fix: check the embedder endpoint and @ruvector/rvf-node binding, or set RUVECTOR_USE_RVF_PATTERN_STORE=false to use SQLite HNSW.`),this.adapter=null,this.initialized=!0}if(!this.sqliteStore)try{let{createSQLitePatternStore:e}=await import("./sqlite-persistence-MAKDFSHC.js"),t=e();await t.initialize(),this.sqliteStore=t}catch{}await this.purgeOrphanedVectors()}}async purgeOrphanedVectors(){if(!(!this.adapter||!this.sqliteStore))try{let e=this.adapter.status()?.totalVectors??0,t=this.sqliteStore.getStats()?.totalPatterns??0;if(e<=t)return;let{readFileSync:r,existsSync:i}=await import("node:fs"),s=`${this.rvfPath}.idmap.json`;if(!i(s))return;let o=JSON.parse(r(s,"utf-8")),c=new Set((o.entries??[]).map(l=>Array.isArray(l)?l[0]:void 0).filter(l=>typeof l=="string")),d=new Set(this.sqliteStore.getPatterns({limit:1e4}).map(l=>l.id)),a=[...c].filter(l=>!d.has(l));if(a.length===0)return;this.adapter.delete(a),console.log(`[RvfPatternStore] Removed ${a.length} ghost vectors (index ${e} > DB ${t})`)}catch(e){console.warn(`[RvfPatternStore] orphan purge skipped: ${S(e)}`)}}async dispose(){if(this.adapter&&!this.skipCloseOnDispose)try{this.adapter.close()}catch{}this.adapter=null,this.initialized=!1}async store(e){await this.ensureInitialized();let t=X(e);if(!t.valid)return v(new Error(`Invalid pattern: ${t.errors.join(", ")}`));if(e.confidence<this.config.minConfidence)return v(new Error(`Pattern confidence ${e.confidence} below threshold ${this.config.minConfidence}`));if(!this.sqliteStore)return v(new R(e.id,"FAILED",new Error("authoritative SQLite pattern store is unavailable")));let r=T()?.spaceId??this.embeddingSpaceId;if(e.embedding&&!r)return v(new Error("VECTOR_SPACE_UNVERIFIED: refusing to persist or index an embedding without runtime provenance"));let i=!1;if(this.sqliteStore)try{let s=this.sqliteStore.storePattern(e,e.embedding,r);s&&s!==e.id&&(e.id=s),i=!0}catch(s){return v(new R(e.id,"FAILED",s))}if(e.embedding&&!this.adapter&&this.rvfInitError)return v(new R(e.id,i?"COMMITTED_PENDING_INDEX":"FAILED",new Error(`RVF unavailable ${i?"after":"before"} authoritative pattern commit: ${this.rvfInitError}`)));if(e.embedding&&this.adapter)try{let s=e.embedding instanceof Float32Array?e.embedding:new Float32Array(e.embedding),o=this.adapter.ingest([{id:e.id,vector:s}]);if(o.accepted!==1||o.rejected!==0)throw new Error(`RVF rejected pattern vector (accepted=${o.accepted}, rejected=${o.rejected})`)}catch(s){return v(new R(e.id,i?"COMMITTED_PENDING_INDEX":"FAILED",s))}return P(e.id)}async create(e){let t=e.confidence??.5,r=e.qeDomain??"test-generation",i={id:F(),patternType:e.patternType,qeDomain:r,domain:r,name:e.name,description:e.description,confidence:t,usageCount:0,successRate:0,qualityScore:W({confidence:t,usageCount:0,successRate:0}),context:{tags:[],...e.context},template:{example:"",...e.template},embedding:e.embedding,tier:"short-term",createdAt:new Date,lastUsedAt:new Date,successfulUses:0,reusable:!1,reuseCount:0,averageTokenSavings:0},s=await this.store(i);return s.success?P(i):v(s.error)}async get(e){if(this.sqliteStore)try{return this.sqliteStore.getPattern(e)??null}catch{return null}return null}async search(e,t={}){await this.ensureInitialized();let r=performance.now(),i=t.limit??10,s=[];if(Array.isArray(e)){let c=T()?.spaceId??this.embeddingSpaceId;if(!c||t.embeddingSpaceId!==c)return v(new Error("VECTOR_SPACE_UNVERIFIED: pre-computed query vectors require the active embeddingSpaceId"))}if(Array.isArray(e)&&this.adapter)try{let c=e instanceof Float32Array?e:new Float32Array(e),d=this.adapter.search(c,i*2);for(let a of d){let l=await this.get(a.id);if(l&&this.matchesFilters(l,t)){let h=this.calculateReuseInfo(l,a.score);s.push({pattern:l,score:a.score,matchType:"vector",similarity:a.score,canReuse:h.canReuse,estimatedTokenSavings:h.estimatedTokenSavings,reuseConfidence:h.reuseConfidence})}}}catch(c){console.warn("[RvfPatternStore] RVF search failed:",S(c))}if(Array.isArray(e)&&!this.adapter&&this.sqliteStore&&s.length===0)try{let c=this.sqliteStore.getPatterns({limit:i*4}),d=e,a=Math.sqrt(d.reduce((l,h)=>l+h*h,0));if(a>0)for(let l of c){if(!this.matchesFilters(l,t))continue;let h=this.sqliteStore.getPattern(l.id),f=h?.embedding;if(!f||f.length!==d.length)continue;let u=0,m=0;for(let w=0;w<d.length;w++)u+=d[w]*f[w],m+=f[w]*f[w];if(m=Math.sqrt(m),m===0)continue;let p=u/(a*m),y=this.calculateReuseInfo(h,p);s.push({pattern:h,score:p,matchType:"vector",similarity:p,canReuse:y.canReuse,estimatedTokenSavings:y.estimatedTokenSavings,reuseConfidence:y.reuseConfidence})}}catch{}if(typeof e=="string"&&!e.trim()&&this.sqliteStore)try{let c=this.sqliteStore.getPatterns({limit:i*2}),d=new Set(s.map(a=>a.pattern.id));for(let a of c){if(d.has(a.id)||!this.matchesFilters(a,t))continue;let l=this.calculateReuseInfo(a,a.confidence);s.push({pattern:a,score:a.confidence,matchType:"exact",similarity:a.confidence,canReuse:l.canReuse,estimatedTokenSavings:l.estimatedTokenSavings,reuseConfidence:l.reuseConfidence})}}catch{}if(typeof e=="string"&&e.trim()&&this.sqliteStore)try{let c=this.sqliteStore.searchFTS(e,i*2),d=new Set(s.map(a=>a.pattern.id));for(let a of c){if(d.has(a.id))continue;let l=await this.get(a.id);if(l&&this.matchesFilters(l,t)){let h=this.calculateReuseInfo(l,a.ftsScore);s.push({pattern:l,score:.5*a.ftsScore,matchType:"exact",similarity:a.ftsScore,canReuse:h.canReuse,estimatedTokenSavings:h.estimatedTokenSavings,reuseConfidence:h.reuseConfidence})}}}catch{}s.sort((c,d)=>d.score-c.score);let o=performance.now()-r;return this.searchOps++,this.totalSearchMs+=o,P(s.slice(0,i))}async recordUsage(e,t,r,i){if(!this.sqliteStore)return v(new Error("No SQLite store attached"));try{return this.sqliteStore.recordUsage(e,t,r,i),P(void 0)}catch(s){return v(new Error(`recordUsage failed: ${S(s)}`))}}async promote(e){if(!this.sqliteStore)return v(new Error("No SQLite store attached"));try{return this.sqliteStore.promotePattern(e),P(void 0)}catch(t){return v(new Error(`promote failed: ${S(t)}`))}}async delete(e){if(this.adapter)try{this.adapter.delete([e])}catch(t){console.warn(`[RvfPatternStore] RVF delete failed for ${e}:`,S(t))}if(this.sqliteStore)try{this.sqliteStore.deletePattern(e)}catch(t){return v(new Error(`SQLite delete failed: ${S(t)}`))}return P(void 0)}async getStats(){let e=this.adapter?.status(),t=0,r={},i={shortTerm:0,longTerm:0};if(this.sqliteStore)try{let s=this.sqliteStore.getStats();t=s.totalPatterns,r=s.byDomain,i={shortTerm:s.byTier["short-term"]??0,longTerm:s.byTier["long-term"]??0}}catch{}return{totalPatterns:t,byTier:i,byDomain:r,byType:{},avgConfidence:0,avgQualityScore:0,avgSuccessRate:0,searchOperations:this.searchOps,avgSearchLatencyMs:this.searchOps>0?this.totalSearchMs/this.searchOps:0,hnswStats:{nativeAvailable:this.adapter!==null,vectorCount:e?.totalVectors??0,indexSizeBytes:e?.fileSizeBytes??0,...this.rvfInitError?{rvfInitError:this.rvfInitError}:{}}}}async cleanup(){if(!this.sqliteStore)return{removed:0,promoted:0};let e=0,t=0;try{let r=this.sqliteStore.getPatterns({limit:1e4});for(let i of r)i.confidence<this.config.minConfidence&&i.usageCount>3?(await this.delete(i.id),e++):i.tier==="short-term"&&i.successfulUses>=V&&(await this.promote(i.id),t++)}catch(r){console.warn("[RvfPatternStore] Cleanup error:",S(r))}return{removed:e,promoted:t}}async ensureInitialized(){this.initialized||await this.initialize()}matchesFilters(e,t){return!(t.patternType&&e.patternType!==t.patternType||t.domain&&e.qeDomain!==t.domain||t.tier&&e.tier!==t.tier||t.minConfidence&&e.confidence<t.minConfidence||t.minQualityScore&&e.qualityScore<t.minQualityScore)}calculateReuseInfo(e,t){let r=this.config.reuseOptimization,i=r.enabled&&t>=r.minSimilarityForReuse&&e.successRate>=r.minSuccessRateForReuse;return{canReuse:i,estimatedTokenSavings:i?500:0,reuseConfidence:i?t*e.successRate:0}}};dt();Fe();O();function ht(n,e){let r=[n.pattern,n];for(let i of r){let s=e.split("."),o=i;for(let c of s){if(o==null)break;if(typeof o=="object")o=o[c];else{o=void 0;break}}if(o!==void 0)return o}}function ft(n,e,t){switch(e){case"eq":return n===t;case"gt":return typeof n=="number"&&typeof t=="number"&&n>t;case"lt":return typeof n=="number"&&typeof t=="number"&&n<t;case"gte":return typeof n=="number"&&typeof t=="number"&&n>=t;case"lte":return typeof n=="number"&&typeof t=="number"&&n<=t;case"in":return Array.isArray(t)?t.includes(n):!1;case"contains":return Array.isArray(n)||typeof n=="string"&&typeof t=="string"?n.includes(t):!1;case"between":{if(typeof n!="number"||!Array.isArray(t)||t.length!==2){if(n instanceof Date&&Array.isArray(t)&&t.length===2){let s=n.getTime(),o=t[0]instanceof Date?t[0].getTime():Number(t[0]),c=t[1]instanceof Date?t[1].getTime():Number(t[1]);return s>=o&&s<=c}return!1}let[r,i]=t;return n>=r&&n<=i}default:return!1}}function K(n,e){switch(e.type){case"AND":return(e.children??[]).every(r=>K(n,r));case"OR":{let t=e.children??[];return t.length===0?!0:t.some(r=>K(n,r))}case"NOT":return e.child?!K(n,e.child):!0;case"FIELD":{if(!e.field||!e.operator)return!0;let t=ht(n,e.field);return ft(t,e.operator,e.value)}default:return!0}}function Ue(n,e){return e?n.filter(t=>K(t,e)):n}O();O();var Qe=1e4,$e=2166136261;function ze(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0}var ue=new Uint8Array(256);for(let n=0;n<256;n++){let e=0,t=n;for(;t;)e++,t&=t-1;ue[n]=e}var qe="0123456789abcdef";function mt(n){let e=Math.min(n.length,16),t="";for(let r=0;r<e;r++){let i=n[r];t+=qe[i>>4]+qe[i&15]}return t}function pt(n,e){if(n.length!==e.length)throw new Error(`Cannot bind vectors of different lengths: ${n.length} vs ${e.length}`);let t=new Uint8Array(n.length);for(let r=0;r<n.length;r++)t[r]=n[r]^e[r];return t}function gt(n){if(n.length===0)throw new Error("Cannot bundle zero vectors");let e=n[0].length;for(let i=1;i<n.length;i++)if(n[i].length!==e)throw new Error(`Vector length mismatch at index ${i}: expected ${e}, got ${n[i].length}`);let t=new Uint8Array(e),r=n.length/2;for(let i=0;i<e;i++){let s=0;for(let o=0;o<8;o++){let c=0,d=1<<o;for(let a=0;a<n.length;a++)n[a][i]&d&&c++;c>=r&&(s|=d)}t[i]=s}return t}function yt(n,e,t){if(n.length!==e.length)throw new Error(`Cannot compute Hamming distance for vectors of different lengths: ${n.length} vs ${e.length}`);let r=0;for(let s=0;s<n.length;s++)r+=ue[n[s]^e[s]];let i=t??n.length*8;return i>0?r/i:0}function vt(n,e,t){return 1-yt(n,e,t)}var le=class{dimensions;baseSeed;byteLen;tokenCache=new Map;constructor(e){if(this.dimensions=e?.dimensions??Qe,this.baseSeed=e?.seed??$e,this.byteLen=Math.ceil(this.dimensions/8),this.dimensions<=0)throw new Error(`HDC dimensions must be positive, got ${this.dimensions}`)}tokenToHypervector(e){let t=this.tokenCache.get(e);if(t)return new Uint8Array(t);let r=ze(e)^this.baseSeed,i=this.generateSeededVector(r);return this.tokenCache.set(e,i),new Uint8Array(i)}fingerprintPattern(e){if(e.length===0)return new Uint8Array(this.byteLen);let t=this.tokenToHypervector(e[0]);for(let r=1;r<e.length;r++)t=pt(t,this.tokenToHypervector(e[r]));return t}fingerprintWithContext(e,t){let r=this.fingerprintPattern(e);if(t.length===0)return r;let i=this.fingerprintPattern(t);return gt([r,i])}similarity(e,t){return vt(e,t,this.dimensions)}generateSeededVector(e){let t=new Uint8Array(this.byteLen),r=new oe(e),i=0;for(;i<this.byteLen;){let o=r.next(),c=Math.min(4,this.byteLen-i);for(let d=0;d<c;d++)t[i++]=o>>>d*8&255}let s=this.dimensions%8;return s>0&&(t[this.byteLen-1]&=(1<<s)-1),t}},de=class{dimensions;baseSeed;constructor(e){if(this.dimensions=e?.dimensions??Qe,this.baseSeed=e?.seed??$e,this.dimensions<=0)throw new Error(`HDC dimensions must be positive, got ${this.dimensions}`)}fingerprint(e){let t=`${e.id}|${e.domain}|${e.type}|${e.content??""}`,r=ze(t)^this.baseSeed,i=this.generateVector(r);return{vector:i,dimensions:this.dimensions,hash:mt(i)}}compositionalBind(e,t){if(e.length!==t.length)throw new Error(`Cannot bind vectors of different lengths: ${e.length} vs ${t.length}`);let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e[i]^t[i];return r}hammingDistance(e,t){if(e.length!==t.length)throw new Error(`Cannot compute Hamming distance for vectors of different lengths: ${e.length} vs ${t.length}`);let r=0;for(let i=0;i<e.length;i++)r+=ue[e[i]^t[i]];return r}similarity(e,t){return 1-this.hammingDistance(e,t)/this.dimensions}batchFingerprint(e){return e.map(t=>this.fingerprint(t))}generateVector(e){let t=Math.ceil(this.dimensions/8),r=new Uint8Array(t),i=new oe(e),s=0;for(;s<t;){let c=i.next(),d=t-s,a=d<4?d:4;for(let l=0;l<a;l++)r[s++]=c>>>l*8&255}let o=this.dimensions%8;return o>0&&(r[t-1]&=(1<<o)-1),r}};function Je(n){return new de(n)}function Be(n){return $()?new le(n):null}var Pe=ct(Ye(),1),we=Pe.default??Pe,Ut=`
4
+ CREATE TABLE IF NOT EXISTS pattern_deltas (
5
+ id TEXT PRIMARY KEY,
6
+ pattern_id TEXT NOT NULL,
7
+ version INTEGER NOT NULL,
8
+ timestamp INTEGER NOT NULL,
9
+ type TEXT NOT NULL CHECK (type IN ('genesis', 'update', 'rollback')),
10
+ patch TEXT NOT NULL DEFAULT '[]',
11
+ reverse_patch TEXT NOT NULL DEFAULT '[]',
12
+ metadata TEXT
13
+ );
14
+ CREATE INDEX IF NOT EXISTS idx_pattern_deltas_pid_version
15
+ ON pattern_deltas (pattern_id, version);
16
+ CREATE INDEX IF NOT EXISTS idx_pattern_deltas_timestamp
17
+ ON pattern_deltas (timestamp);
18
+ `;function Ke(n,e){let t=we.compare(n,e),r=we.compare(e,n);return{forward:t,reverse:r}}function qt(n,e){let t=JSON.parse(JSON.stringify(n));return we.applyPatch(t,e).newDocument}function Ze(n){return{id:n.id,patternId:n.pattern_id,version:n.version,timestamp:n.timestamp,type:n.type,patch:JSON.parse(n.patch),reversePatch:JSON.parse(n.reverse_patch),metadata:n.metadata?JSON.parse(n.metadata):void 0}}var ne=class{db;config;prepared=new Map;initialized=!1;constructor(e,t){this.db=e,this.config={maxVersionsPerPattern:t?.maxVersionsPerPattern??100,compressDeltas:t?.compressDeltas??!1}}initialize(){this.initialized||(this.db.exec(Ut),this.prepareStatements(),this.initialized=!0)}prepareStatements(){this.prepared.set("insert",this.db.prepare(`
19
+ INSERT INTO pattern_deltas (id, pattern_id, version, timestamp, type, patch, reverse_patch, metadata)
20
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
21
+ `)),this.prepared.set("getHistory",this.db.prepare(`
22
+ SELECT * FROM pattern_deltas
23
+ WHERE pattern_id = ?
24
+ ORDER BY version ASC
25
+ `)),this.prepared.set("currentVersion",this.db.prepare(`
26
+ SELECT MAX(version) as max_version FROM pattern_deltas
27
+ WHERE pattern_id = ?
28
+ `)),this.prepared.set("incrementalSync",this.db.prepare(`
29
+ SELECT * FROM pattern_deltas
30
+ WHERE timestamp > ?
31
+ ORDER BY timestamp ASC
32
+ `)),this.prepared.set("countForPattern",this.db.prepare(`
33
+ SELECT COUNT(*) as cnt FROM pattern_deltas
34
+ WHERE pattern_id = ?
35
+ `)),this.prepared.set("deleteOldest",this.db.prepare(`
36
+ DELETE FROM pattern_deltas
37
+ WHERE pattern_id = ? AND version IN (
38
+ SELECT version FROM pattern_deltas
39
+ WHERE pattern_id = ?
40
+ ORDER BY version ASC
41
+ LIMIT ?
42
+ )
43
+ `))}ensureInitialized(){if(!this.initialized)throw new Error("DeltaTracker not initialized. Call initialize() first.")}createGenesis(e,t,r){this.ensureInitialized();let i=this.getCurrentVersion(e);if(i>=0)throw new Error(`Genesis already exists for pattern ${e} (current version: ${i})`);let s={id:F(),patternId:e,version:0,timestamp:Date.now(),type:"genesis",patch:[],reversePatch:[],metadata:{...r,snapshot:t}};return this.insertEvent(s),s}recordDelta(e,t,r,i){this.ensureInitialized();let s=this.getCurrentVersion(e);if(s<0)throw new Error(`No genesis found for pattern ${e}. Call createGenesis() first.`);let{forward:o,reverse:c}=Ke(t,r),d={id:F(),patternId:e,version:s+1,timestamp:Date.now(),type:"update",patch:o,reversePatch:c,metadata:i};return this.insertEvent(d),this.enforceRetention(e),d}rollback(e,t){this.ensureInitialized();let r=this.getHistory(e);if(r.length===0)throw new Error(`No history found for pattern ${e}`);let i=r[r.length-1].version;if(t<0||t>i)throw new Error(`Invalid rollback version ${t}. Valid range: 0-${i}`);if(t===i)return this.reconstructState(r,i);let s=this.reconstructState(r,t),o=this.reconstructState(r,i),{forward:c,reverse:d}=Ke(o,s),a={id:F(),patternId:e,version:i+1,timestamp:Date.now(),type:"rollback",patch:c,reversePatch:d,metadata:{rolledBackTo:t}};return this.insertEvent(a),this.enforceRetention(e),s}getHistory(e){return this.ensureInitialized(),this.prepared.get("getHistory").all(e).map(Ze)}incrementalSync(e){return this.ensureInitialized(),this.prepared.get("incrementalSync").all(e).map(Ze)}getCurrentVersion(e){return this.ensureInitialized(),this.prepared.get("currentVersion").get(e).max_version??-1}insertEvent(e){this.prepared.get("insert").run(e.id,e.patternId,e.version,e.timestamp,e.type,JSON.stringify(e.patch),JSON.stringify(e.reversePatch),e.metadata?JSON.stringify(e.metadata):null)}reconstructState(e,t){let r=e.find(s=>s.type==="genesis");if(!r||!r.metadata?.snapshot)throw new Error("Cannot reconstruct state: no genesis snapshot found");let i=JSON.parse(JSON.stringify(r.metadata.snapshot));for(let s of e)if(s.version!==0){if(s.version>t)break;i=qt(i,s.patch)}return i}enforceRetention(e){let{maxVersionsPerPattern:t}=this.config,i=this.prepared.get("countForPattern").get(e).cnt;if(i>t){let s=i-t;this.db.prepare(`DELETE FROM pattern_deltas
44
+ WHERE pattern_id = ? AND version != 0 AND id IN (
45
+ SELECT id FROM pattern_deltas
46
+ WHERE pattern_id = ? AND version != 0
47
+ ORDER BY version ASC
48
+ LIMIT ?
49
+ )`).run(e,e,s)}}};O();var Qt={maxHistoryPerPattern:50,snapshotInterval:10,batchSize:20,epsilon:1e-7},be=class{config;history=new Map;snapshots=new Map;versions=new Map;buffer=[];constructor(e){this.config={...Qt,...e}}recordGenesis(e,t,r){if(this.versions.has(e))throw new Error(`Genesis already exists for pattern ${e} (version ${this.versions.get(e)})`);let i=this.computeSparseChanges(new Array(t.length).fill(0),t),s={patternId:e,version:0,timestamp:Date.now(),deltaType:"genesis",sparseChanges:i,metadata:r,compressedSize:i.length},o={patternId:e,version:0,fullVector:[...t],timestamp:s.timestamp};return this.versions.set(e,0),this.getOrCreate(this.history,e).push(s),this.getOrCreate(this.snapshots,e).push(o),this.buffer.push(s),s}recordDelta(e,t,r,i){let s=this.versions.get(e);if(s===void 0)throw new Error(`No genesis found for pattern ${e}. Call recordGenesis() first.`);let o=s+1,c=this.computeSparseChanges(t,r),d={patternId:e,version:o,timestamp:Date.now(),deltaType:"update",sparseChanges:c,metadata:i,compressedSize:c.length};return this.versions.set(e,o),this.getOrCreate(this.history,e).push(d),this.buffer.push(d),o%this.config.snapshotInterval===0&&this.getOrCreate(this.snapshots,e).push({patternId:e,version:o,fullVector:[...r],timestamp:d.timestamp}),this.enforceRetention(e),d}getHistory(e,t){let r=this.history.get(e);if(!r||r.length===0)return[];let i=[...r].reverse();return t!==void 0&&t>0?i.slice(0,t):i}rollback(e,t){let r=this.reconstructAtVersion(e,t);return r===null?null:{patternId:e,version:t,fullVector:r,timestamp:Date.now()}}getVersion(e){return this.versions.get(e)??-1}reconstructAtVersion(e,t){let r=this.history.get(e);if(!r||r.length===0)return null;let i=this.versions.get(e);if(t<0||t>i)return null;let s=this.snapshots.get(e)||[],o=null;for(let a=s.length-1;a>=0;a--)if(s[a].version<=t){o=s[a];break}if(!o)return null;let c=[...o.fullVector],d=o.version+1;for(let a of r)if(!(a.version<d)){if(a.version>t)break;this.applySparseForward(c,a.sparseChanges)}return c}pruneHistory(e,t){let r=t??this.config.maxHistoryPerPattern,i=this.history.get(e);if(!i||i.length<=r)return 0;let s=i.length-r,o=i.slice(0,s),c=i.slice(s),d=o.findIndex(h=>h.deltaType==="genesis");d>=0&&(c.unshift(o[d]),o.splice(d,1)),this.history.set(e,c);let a=c[0]?.version??0,l=this.snapshots.get(e);return l&&this.snapshots.set(e,l.filter(h=>h.version===0||h.version>=a)),o.length}getStats(){let e=0;for(let r of this.history.values())e+=r.length;let t=this.history.size;return{totalPatterns:t,totalDeltas:e,avgDeltasPerPattern:t>0?e/t:0}}flush(){let e=[...this.buffer];return this.buffer.length=0,e}getBufferSize(){return this.buffer.length}clear(){this.history.clear(),this.snapshots.clear(),this.versions.clear(),this.buffer.length=0}computeSparseChanges(e,t){let r=[],i=Math.max(e.length,t.length);for(let s=0;s<i;s++){let o=s<e.length?e[s]:0,c=s<t.length?t[s]:0;Math.abs(o-c)>this.config.epsilon&&r.push({index:s,oldValue:o,newValue:c})}return r}applySparseForward(e,t){for(let r of t){for(;e.length<=r.index;)e.push(0);e[r.index]=r.newValue}}enforceRetention(e){this.pruneHistory(e,this.config.maxHistoryPerPattern)}getOrCreate(e,t){let r=e.get(t);return r||(r=[],e.set(t,r)),r}};function et(n){return L()?new be(n):null}O();var $t=128,zt=8,Jt=1e4,Ee=class{dimension;beta;maxPatterns;patterns;constructor(e){if(this.dimension=e?.dimension??$t,this.beta=e?.beta??zt,this.maxPatterns=e?.maxPatterns??Jt,this.patterns=[],this.dimension<=0)throw new Error(`Hopfield dimension must be positive, got ${this.dimension}`);if(this.beta<=0)throw new Error(`Hopfield beta must be positive, got ${this.beta}`);if(this.maxPatterns<=0)throw new Error(`Hopfield maxPatterns must be positive, got ${this.maxPatterns}`)}store(e,t){if(this.assertEnabled(),e.length!==this.dimension)throw new Error(`Pattern dimension mismatch: expected ${this.dimension}, got ${e.length}`);if(this.dotProduct(e,e)===0)throw new Error("Cannot store zero-magnitude pattern in Hopfield memory");let i=this.normalize(e);this.patterns.length>=this.maxPatterns&&this.patterns.shift(),this.patterns.push({pattern:i,metadata:t??{},storedAt:Date.now()})}recall(e){if(this.assertEnabled(),e.length!==this.dimension)throw new Error(`Query dimension mismatch: expected ${this.dimension}, got ${e.length}`);if(this.patterns.length===0)return null;let t=this.normalize(e),r=new Float32Array(this.patterns.length);for(let l=0;l<this.patterns.length;l++)r[l]=this.beta*this.dotProduct(this.patterns[l].pattern,t);let i=this.softmax(r),s=0,o=i[0];for(let l=1;l<i.length;l++)i[l]>o&&(o=i[l],s=l);let c=this.patterns[s],d=this.getEnergy(t),a=this.cosineSimilarity(t,c.pattern);return{pattern:new Float32Array(c.pattern),metadata:{...c.metadata},energy:d,similarity:a}}batchRecall(e){return this.assertEnabled(),e.map(t=>this.recall(t))}getPatternCount(){return this.patterns.length}clear(){this.patterns.length=0}getEnergy(e){if(e.length!==this.dimension)throw new Error(`State dimension mismatch: expected ${this.dimension}, got ${e.length}`);let t=this.normalize(e);if(this.patterns.length===0)return .5*this.dotProduct(t,t);let r=new Float32Array(this.patterns.length);for(let a=0;a<this.patterns.length;a++)r[a]=this.dotProduct(this.patterns[a].pattern,t);let i=new Float32Array(this.patterns.length),s=-1/0;for(let a=0;a<this.patterns.length;a++)i[a]=this.beta*r[a],i[a]>s&&(s=i[a]);let o=0;for(let a=0;a<this.patterns.length;a++)o+=Math.exp(i[a]-s);let c=1/this.beta*(s+Math.log(o)),d=this.dotProduct(t,t);return-c+.5*d}softmax(e){let t=new Float32Array(e.length),r=-1/0;for(let s=0;s<e.length;s++)e[s]>r&&(r=e[s]);let i=0;for(let s=0;s<e.length;s++)t[s]=Math.exp(e[s]-r),i+=t[s];if(i>0)for(let s=0;s<t.length;s++)t[s]/=i;return t}dotProduct(e,t){let r=0;for(let i=0;i<e.length;i++)r+=e[i]*t[i];return r}cosineSimilarity(e,t){let r=this.dotProduct(e,t),i=Math.sqrt(this.dotProduct(e,e)),s=Math.sqrt(this.dotProduct(t,t));return i===0||s===0?0:r/(i*s)}normalize(e){let t=Math.sqrt(this.dotProduct(e,e)),r=new Float32Array(e.length);if(t>0)for(let i=0;i<e.length;i++)r[i]=e[i]/t;return r}assertEnabled(){if(!D().useHopfieldMemory)throw new Error("Hopfield memory is disabled (useHopfieldMemory feature flag is false)")}};function tt(n){return new Ee(n)}O();var Bt={dimensions:32,curvature:-1,maxElements:1e4,efConstruction:200,M:16},M=1e-5,rt=1-M;function jt(n,e){let t=0;for(let r=0;r<n.length;r++)t+=n[r]*e[r];return t}function C(n){let e=0;for(let t=0;t<n.length;t++)e+=n[t]*n[t];return e}function Wt(n,e){let t=new Float32Array(n.length);for(let r=0;r<n.length;r++)t[r]=n[r]-e[r];return t}var x=class n{static poincareDistance(e,t){let r=C(Wt(e,t)),i=Math.max(M,1-C(e)),s=Math.max(M,1-C(t));return Math.acosh(Math.max(1,1+2*r/(i*s)))}static mobiusAdd(e,t){let r=jt(e,t),i=C(e),s=C(t),o=Math.max(M,1+2*r+i*s),c=1+2*r+s,d=1-i,a=new Float32Array(e.length);for(let l=0;l<e.length;l++)a[l]=(c*e[l]+d*t[l])/o;return n.project(a)}static expMap(e,t){let r=2/Math.max(M,1-C(e)),i=Math.sqrt(C(t));if(i<M)return new Float32Array(e);let s=Math.tanh(r*i/2),o=new Float32Array(t.length);for(let c=0;c<t.length;c++)o[c]=s/i*t[c];return n.mobiusAdd(e,o)}static project(e){let t=Math.sqrt(C(e));if(t<=rt)return new Float32Array(e);let r=rt/t,i=new Float32Array(e.length);for(let s=0;s<e.length;s++)i[s]=e[s]*r;return i}static euclideanToHyperbolic(e){let t=Math.sqrt(C(e));if(t<M)return new Float32Array(e.length);let r=Math.tanh(t)/t,i=new Float32Array(e.length);for(let s=0;s<e.length;s++)i[s]=e[s]*r;return n.project(i)}},Re=class{config;points=new Map;constructor(e){if(this.config={...Bt,...e},this.config.dimensions<=0)throw new Error(`dimensions must be positive, got ${this.config.dimensions}`);if(this.config.curvature>=0)throw new Error(`curvature must be negative for hyperbolic space, got ${this.config.curvature}`);if(this.config.maxElements<=0)throw new Error(`maxElements must be positive, got ${this.config.maxElements}`)}insert(e,t,r){if(t.length!==this.config.dimensions)throw new Error(`Dimension mismatch: expected ${this.config.dimensions}, got ${t.length}`);if(this.points.size>=this.config.maxElements)throw new Error(`Maximum elements (${this.config.maxElements}) reached`);this.points.set(e,{id:e,coordinates:x.project(t),metadata:r?{...r}:void 0})}search(e,t){if(e.length!==this.config.dimensions)throw new Error(`Query dimension mismatch: expected ${this.config.dimensions}, got ${e.length}`);let r=x.project(e),i=[];for(let s of this.points.values())i.push({id:s.id,distance:x.poincareDistance(r,s.coordinates),point:s});return i.sort((s,o)=>s.distance-o.distance),i.slice(0,Math.max(0,t))}embedHierarchy(e){let t=new Map;if(e.length===0)return t;let r=this.config.dimensions,i=new Map,s=new Map,o=[];for(let d of e)if(s.set(d.id,d),!d.parentId)o.push(d.id);else{let a=i.get(d.parentId);a||(a=[],i.set(d.parentId,a)),a.push(d.id)}let c=o.map((d,a)=>({id:d,depth:0,angOff:2*Math.PI*a/Math.max(1,o.length),angSpan:2*Math.PI/Math.max(1,o.length)}));for(;c.length>0;){let{id:d,depth:a,angOff:l,angSpan:h}=c.shift(),f=Math.tanh(.3*(a+.1)),u=l+h/2,m=new Float32Array(r);m[0]=f*Math.cos(u),m[1]=f*Math.sin(u);let p=s.get(d);if(p&&p.features.length>0){let H=f*.1;for(let I=2;I<r&&I-2<p.features.length;I++)m[I]=p.features[I-2]*H}let y=x.project(m);t.set(d,y),this.points.set(d,{id:d,coordinates:y,metadata:{depth:a,parentId:p?.parentId}});let w=i.get(d)??[];for(let H=0;H<w.length;H++){let I=h/Math.max(1,w.length);c.push({id:w[H],depth:a+1,angOff:l+H*I,angSpan:I})}}return t}getStats(){return{elementCount:this.points.size,dimensions:this.config.dimensions,curvature:this.config.curvature}}};function nt(n){return Vt()?new Re(n):null}function Vt(){return D().useHyperbolicHnsw}O();var Ae=class{index=null;initialized=!1;config;constructor(e){this.config=e??{}}ensureInitialized(){if(this.initialized)return this.index!==null;if(this.initialized=!0,!k())return!1;try{return this.index=nt(this.config),this.index!==null}catch(e){return console.warn("[HyperbolicPatternIndex] Failed to create HyperbolicHNSW:",e instanceof Error?e.message:e),this.index=null,!1}}get isAvailable(){return this.index!==null}indexPattern(e,t,r){if(!(!this.ensureInitialized()||!this.index))try{let i=t instanceof Float32Array?t:new Float32Array(t),s=x.euclideanToHyperbolic(i);this.index.insert(e,s,r)}catch(i){console.debug(`[HyperbolicPatternIndex] Failed to index pattern ${e}:`,i instanceof Error?i.message:i)}}search(e,t){if(!this.ensureInitialized()||!this.index)return[];try{let r=e instanceof Float32Array?e:new Float32Array(e),i=x.euclideanToHyperbolic(r);return this.index.search(i,t).map(o=>({patternId:o.id,distance:o.distance,metadata:o.point.metadata}))}catch(r){return console.warn("[HyperbolicPatternIndex] Search failed:",r instanceof Error?r.message:r),[]}}getStats(){return this.index?this.index.getStats():null}reset(){this.index=null,this.initialized=!1}};function it(n){return new Ae(n)}var Te=null;function at(){return Te||(Te=Je({dimensions:1e4})),Te}var Ce;function Gt(){return Ce===void 0&&(Ce=Be()),Ce}var Q=null,xe=0;function ot(n){return(!Q||xe!==n)&&(Q=tt({dimension:n,maxPatterns:1e4}),xe=n),Q}var Y={namespace:"qe-patterns",embeddingDimension:384,hnsw:{M:16,efConstruction:200,efSearch:100,maxElements:5e4},promotionThreshold:V,minConfidence:.3,maxPatternsPerDomain:5e3,autoCleanup:!0,cleanupIntervalMs:36e5,tokenTracking:{enabled:!0,trackInputOutput:!0,estimateCosts:!0,costPerInputToken:3e-6,costPerOutputToken:15e-6},reuseOptimization:{enabled:!0,minSimilarityForReuse:.85,minSuccessRateForReuse:.9,maxAgeForReuse:7}},Ie=class{constructor(e,t={}){this.memory=e;this.config={...Y,...t}}memory;config;initialized=!1;cleanupTimer;sqliteStore=null;nullStore=null;loadingPromise=null;patternCache=new Map;domainIndex=new Map;typeIndex=new Map;tierIndex=new Map;hnswIndex=null;hnswSpaceId=null;hnswAvailable=!1;hnswInitPromise=null;hdcCache=new Map;hdcTokenCache=new Map;deltaTracker=null;vectorDeltaTracker=void 0;hyperbolicIndex=null;stats={searchOperations:0,searchLatencies:[]};setSqliteStore(e){if(this.sqliteStore=e,L()&&!this.deltaTracker)try{let t=e.getDb();this.deltaTracker=new ne(t),this.deltaTracker.initialize(),console.log("[PatternStore] Delta event sourcing initialized")}catch(t){console.warn("[PatternStore] Delta tracker init failed:",t instanceof Error?t.message:t)}this.initialized&&(this.loadingPromise=this.loadPatterns().catch(t=>console.warn("[PatternStore] Failed to load patterns after setSqliteStore:",t)).finally(()=>{this.loadingPromise=null}))}async initialize(){this.initialized||(this.tierIndex.set("short-term",new Set),this.tierIndex.set("long-term",new Set),await this.loadPatterns(),this.config.autoCleanup&&(this.cleanupTimer=setInterval(()=>this.cleanup(),this.config.cleanupIntervalMs)),this.initialized=!0)}async ensureHNSW(){if(this.hnswIndex!==null){let e=T()?.spaceId??this.config.embeddingSpaceId??null;return this.hnswSpaceId!==e?(console.warn("[PatternStore] VECTOR_SPACE_MISMATCH: active embedder changed; semantic index disabled"),null):this.hnswIndex}return this.hnswAvailable===!1&&this.hnswInitPromise===null&&!(this.hnswIndex===null&&this.hnswAvailable===!1)?null:this.hnswInitPromise?(await this.hnswInitPromise,this.hnswIndex):(this.hnswInitPromise=this.initializeHNSWInternal(),await this.hnswInitPromise,this.hnswInitPromise=null,this.hnswIndex)}async initializeHNSWInternal(){try{if(!T()&&!this.config.embeddingSpaceId&&await j(),this.hnswSpaceId=T()?.spaceId??this.config.embeddingSpaceId??null,!this.hnswSpaceId)throw new Error("VECTOR_SPACE_UNVERIFIED: cannot initialize HNSW without runtime provenance");if(D().useUnifiedHnsw)try{let{HnswLegacyBridge:o}=await import("./hnsw-legacy-bridge-5DRL5FLX.js"),{HnswAdapter:c}=await import("./hnsw-adapter-42KB37KP.js"),d=new c("patterns",{dimensions:this.config.embeddingDimension,M:this.config.hnsw.M,efConstruction:this.config.hnsw.efConstruction,efSearch:this.config.hnsw.efSearch,metric:"cosine"});this.hnswIndex=new o(d),this.hnswAvailable=!0,console.log("[PatternStore] Using unified HNSW via HnswLegacyBridge (ADR-071)"),await this.loadEmbeddingsIntoHNSW();return}catch(o){console.warn("[PatternStore] Unified HNSW bridge failed, falling back:",o)}let{HNSWIndex:t}=await import("./hnsw-index-T2PGO77J.js");this.hnswIndex=new t(this.memory,{dimensions:this.config.embeddingDimension,M:this.config.hnsw.M,efConstruction:this.config.hnsw.efConstruction,efSearch:this.config.hnsw.efSearch,maxElements:this.config.hnsw.maxElements,namespace:`${this.config.namespace}:hnsw`,metric:"cosine"});let r=5e3,i=this.hnswIndex.initialize(),s=new Promise((o,c)=>setTimeout(()=>c(new Error("HNSW init timeout")),r));await Promise.race([i,s]),this.hnswAvailable=this.hnswIndex.isNativeAvailable(),await this.loadEmbeddingsIntoHNSW(),console.log(`[PatternStore] HNSW lazy-initialized (native: ${this.hnswAvailable})`)}catch(e){console.warn("[PatternStore] HNSW not available, using memory backend search:",S(e)),this.hnswIndex=null,this.hnswAvailable=!1}}async loadEmbeddingsIntoHNSW(){if(!(!this.hnswIndex||!this.sqliteStore))try{let e=this.sqliteStore.getAllEmbeddings(),t=this.config.hnsw.maxElements,r=0,i=0,s=T()?.spaceId??this.config.embeddingSpaceId;for(let{patternId:o,embedding:c,spaceId:d}of e){if(r>=t)break;if(!s||d!==s||!c||c.length!==this.config.embeddingDimension){i++;continue}let a=this.patternCache.get(o);if(!a){i++;continue}try{await this.hnswIndex.insert(o,c,{filePath:a.patternType,lineCoverage:a.confidence*100,branchCoverage:a.qualityScore*100,functionCoverage:0,statementCoverage:0,uncoveredLineCount:0,uncoveredBranchCount:0,riskScore:1-a.confidence,lastUpdated:Date.now(),totalLines:0}),r++}catch{i++}}r>0&&console.log(`[PatternStore] Loaded ${r} embeddings into HNSW (skipped ${i})`)}catch(e){console.warn("[PatternStore] Failed to load SQLite embeddings into HNSW:",S(e))}}getVectorDeltaTracker(){return this.vectorDeltaTracker===void 0&&(this.vectorDeltaTracker=et()),this.vectorDeltaTracker}async loadPatterns(){if(this.sqliteStore)try{let e=this.sqliteStore.getPatterns({limit:5e4});for(let t of e)this.indexPattern(t);e.length>0&&console.log(`[PatternStore] Loaded ${e.length} patterns from SQLite into memory cache`)}catch(e){console.warn("[PatternStore] Failed to load patterns from SQLite:",S(e))}}indexPattern(e){this.patternCache.set(e.id,e),this.domainIndex.has(e.qeDomain)||this.domainIndex.set(e.qeDomain,new Set),this.domainIndex.get(e.qeDomain).add(e.id),this.typeIndex.has(e.patternType)||this.typeIndex.set(e.patternType,new Set),this.typeIndex.get(e.patternType).add(e.id);let t=e.tier==="long-term"?"long-term":"short-term";e.tier!==t&&(e.tier=t),this.tierIndex.get(t).add(e.id)}unindexPattern(e){this.patternCache.delete(e.id),this.domainIndex.get(e.qeDomain)?.delete(e.id),this.typeIndex.get(e.patternType)?.delete(e.id),this.tierIndex.get(e.tier)?.delete(e.id),this.hdcCache.delete(e.id),this.hdcTokenCache.delete(e.id)}async store(e){this.initialized||await this.initialize(),this.loadingPromise&&await this.loadingPromise;let t=X(e);if(!t.valid)return v(new Error(`Invalid pattern: ${t.errors.join(", ")}`));if(e.confidence<this.config.minConfidence)return v(new Error(`Pattern confidence ${e.confidence} below threshold ${this.config.minConfidence}`));let r=(process.env.AQE_MEMORY_BACKEND??"memory")!=="memory";if(r&&!this.sqliteStore)return v(new R(e.id,"FAILED",new Error("authoritative SQLite pattern store is unavailable")));let i=T()?.spaceId??this.config.embeddingSpaceId;if(e.embedding&&!i)return v(new Error("VECTOR_SPACE_UNVERIFIED: refusing to persist or index an embedding without runtime provenance"));(this.domainIndex.get(e.qeDomain)?.size||0)>=this.config.maxPatternsPerDomain&&await this.cleanupDomain(e.qeDomain);let o=this.patternCache.get(e.id)??null,c=!1,d=()=>{this.unindexPattern(e),o&&this.indexPattern(o)};if(this.indexPattern(e),this.sqliteStore)try{let a=this.sqliteStore.storePattern(e,e.embedding,i);a&&a!==e.id&&(this.unindexPattern(e),e.id=a,this.indexPattern(e)),c=!0}catch(a){return d(),v(new R(e.id,"FAILED",a))}if(e.embedding){let a=await this.ensureHNSW();if(!a&&c)return v(new R(e.id,"COMMITTED_PENDING_INDEX",new Error("HNSW unavailable after authoritative pattern commit")));if(!a&&r)return d(),v(new R(e.id,"FAILED",new Error("HNSW unavailable before an authoritative pattern commit")));if(a)try{await a.insert(e.id,e.embedding,{filePath:e.patternType,lineCoverage:e.confidence*100,branchCoverage:e.qualityScore*100,functionCoverage:0,statementCoverage:0,uncoveredLineCount:0,uncoveredBranchCount:0,riskScore:1-e.confidence,lastUpdated:Date.now(),totalLines:0})}catch(l){return c||d(),v(new R(e.id,c?"COMMITTED_PENDING_INDEX":"FAILED",l))}}if($())try{let l=at().fingerprint({id:e.id,domain:e.qeDomain,type:e.patternType,content:e.description});this.hdcCache.set(e.id,l.vector)}catch(a){console.debug(`[PatternStore] HDC fingerprint failed for ${e.id}:`,S(a))}try{let a=Gt();if(a){let l=[e.patternType,e.qeDomain];e.context?.tags&&l.push(...e.context.tags),e.name&&l.push(e.name);let h=a.fingerprintPattern(l);this.hdcTokenCache.set(e.id,h)}}catch(a){console.debug(`[PatternStore] HDC token fingerprint failed for ${e.id}:`,S(a))}if(ie()&&e.embedding)try{ot(e.embedding.length).store(new Float32Array(e.embedding),{id:e.id,name:e.name,domain:e.qeDomain})}catch(a){console.debug(`[PatternStore] Hopfield store failed for ${e.id}:`,S(a))}if(L()&&this.deltaTracker)try{let a={id:e.id,name:e.name,confidence:e.confidence,qualityScore:e.qualityScore,usageCount:e.usageCount,successRate:e.successRate,tier:e.tier};this.deltaTracker.createGenesis(e.id,a)}catch(a){console.debug(`[PatternStore] Delta genesis for ${e.id}:`,S(a))}if(e.embedding)try{let a=this.getVectorDeltaTracker();a&&(o?.embedding?a.recordDelta(e.id,o.embedding,e.embedding):a.getVersion(e.id)<0&&a.recordGenesis(e.id,e.embedding))}catch(a){console.debug(`[PatternStore] VectorDeltaTracker for ${e.id}:`,S(a))}try{k()&&e.embedding&&this.indexHyperbolic(e.id,e.embedding,{domain:e.qeDomain,type:e.patternType,name:e.name})}catch{}return P(e.id)}async create(e){let t=new Date,r=e.qeDomain||this.detectDomainFromType(e.patternType),i={id:F(),patternType:e.patternType,qeDomain:r,domain:r,name:e.name,description:e.description,confidence:e.confidence??.5,usageCount:0,successRate:0,qualityScore:.25,context:{...e.context,tags:e.context?.tags||[]},template:{...e.template,example:void 0},embedding:e.embedding,tier:"short-term",createdAt:t,lastUsedAt:t,successfulUses:0,reusable:!1,reuseCount:0,averageTokenSavings:0},s=await this.store(i);return s.success?P(i):v(s.error)}detectDomainFromType(e){return{"test-template":"test-generation","assertion-pattern":"test-generation","mock-pattern":"test-generation","coverage-strategy":"coverage-analysis","mutation-strategy":"test-generation","api-contract":"contract-testing","visual-baseline":"visual-accessibility","a11y-check":"visual-accessibility","perf-benchmark":"chaos-resilience","flaky-fix":"test-execution","refactor-safe":"code-intelligence","error-handling":"test-generation","meta-optimization":"learning-optimization"}[e]||"test-generation"}async get(e){return this.initialized||await this.initialize(),this.loadingPromise&&await this.loadingPromise,this.patternCache.get(e)??null}async search(e,t={}){this.initialized||await this.initialize(),this.loadingPromise&&await this.loadingPromise;let r=performance.now(),i=t.limit||10,s=[];try{if(Array.isArray(e)&&ie())try{let f=ot(e.length);if(f.getPatternCount()>0){let u=f.recall(new Float32Array(e));if(u&&u.similarity>.98){let m=u.metadata.id,p=await this.get(m);if(p&&this.matchesFilters(p,t)){let y=this.calculateReuseInfo(p,u.similarity);s.push({pattern:p,score:u.similarity,matchType:"vector",similarity:u.similarity,canReuse:y.canReuse,estimatedTokenSavings:y.estimatedTokenSavings,reuseConfidence:y.reuseConfidence})}}}}catch(f){console.debug("[PatternStore] Hopfield recall failed:",S(f))}if(Array.isArray(e)&&t.useVectorSearch!==!1){let f=T()?.spaceId??this.config.embeddingSpaceId;if(!f||t.embeddingSpaceId!==f)throw new Error("VECTOR_SPACE_UNVERIFIED: pre-computed query vectors require the active embeddingSpaceId");let u=await this.ensureHNSW();if(u){let m=await u.search(e,i*2);for(let p of m){let y=await this.get(p.key);if(y&&this.matchesFilters(y,t)){let w=this.calculateReuseInfo(y,p.score);s.push({pattern:y,score:p.score,matchType:"vector",similarity:p.score,canReuse:w.canReuse,estimatedTokenSavings:w.estimatedTokenSavings,reuseConfidence:w.reuseConfidence})}}}}if(typeof e=="string"&&e.trim()&&this.sqliteStore)try{let f=this.sqliteStore.searchFTS(e,i*2);if(f.length>0){let u=new Map(f.map(p=>[p.id,p.ftsScore])),m=new Set(s.map(p=>p.pattern.id));for(let p of s){let y=u.get(p.pattern.id);y!==void 0&&(p.score=.75*p.score+.25*y)}for(let p of f){if(m.has(p.id))continue;let y=await this.get(p.id);if(y&&this.matchesFilters(y,t)){let w=this.calculateReuseInfo(y,p.ftsScore);s.push({pattern:y,score:.5*p.ftsScore,matchType:"exact",similarity:p.ftsScore,canReuse:w.canReuse,estimatedTokenSavings:w.estimatedTokenSavings,reuseConfidence:w.reuseConfidence})}}}}catch{}if(typeof e=="string"||s.length<i){let f=await this.searchByText(typeof e=="string"?e:"",t,i-s.length),u=new Set(s.map(m=>m.pattern.id));for(let m of f)u.has(m.pattern.id)||s.push(m)}let o=720*60*60*1e3,c=Date.now();for(let f of s){let u=f.pattern.lastUsedAt?.getTime()??f.pattern.createdAt.getTime(),m=c-u,p=Math.pow(.5,m/o),y=f.pattern.usageCount>0?p:.5;f.score=f.score*(.7+.3*y)}let d=this.sqliteStore?.getDatabase();if(d&&s.length>0)try{this.nullStore||(this.nullStore=new ce(d));let f=this.nullStore.getNullSummaries(s.map(u=>u.pattern.id));for(let u of s){let m=f.get(u.pattern.id);m&&(u.nullSummary=m,u.score=ce.applyNullDiscount(u.score,m,t.contextFingerprint))}}catch(f){console.debug("[PatternStore] null discount skipped:",S(f))}s.sort((f,u)=>u.score-f.score);let a=s;t.filter&&(a=Ue(s,t.filter));let l=a.slice(0,i),h=performance.now()-r;return this.recordSearchLatency(h),P(l)}catch(o){return v(De(o))}}async searchByText(e,t,r){let i=[],s=e.toLowerCase(),o;t.domain?o=this.domainIndex.get(t.domain)||new Set:t.patternType?o=this.typeIndex.get(t.patternType)||new Set:t.tier?o=this.tierIndex.get(t.tier)||new Set:o=new Set(this.patternCache.keys());let c=[...o];if($()&&s&&this.hdcCache.size>0)try{let d=at(),a=d.fingerprint({id:"query",domain:t.domain??"unknown",type:t.patternType??"unknown",content:e}),l=c.filter(u=>this.hdcCache.has(u)).map(u=>({id:u,similarity:d.similarity(a.vector,this.hdcCache.get(u))}));l.sort((u,m)=>m.similarity-u.similarity);let h=l.map(u=>u.id),f=c.filter(u=>!this.hdcCache.has(u));c=[...h,...f]}catch{}for(let d of c){if(i.length>=r)break;let a=this.patternCache.get(d);if(!a||!this.matchesFilters(a,t))continue;let l=0;if(s){let h=a.name.toLowerCase(),f=a.description.toLowerCase();h.includes(s)&&(l+=.5),f.includes(s)&&(s.length/f.length>.3?l+=.5:l+=.3);for(let u of a.context.tags)if(u.toLowerCase().includes(s)){l+=.2;break}l=Math.min(l,1)}else l=a.qualityScore;if(l>0||!s){let h=this.calculateReuseInfo(a,l);i.push({pattern:a,score:l||a.qualityScore,matchType:s?"exact":"context",similarity:l||a.qualityScore,canReuse:h.canReuse,estimatedTokenSavings:h.estimatedTokenSavings,reuseConfidence:h.reuseConfidence})}}return i}calculateReuseInfo(e,t){let{reuseOptimization:r}=this.config,i=t>=r.minSimilarityForReuse,s=e.successRate>=r.minSuccessRateForReuse,o=e.lastUsedAt instanceof Date?e.lastUsedAt.getTime():new Date(e.lastUsedAt).getTime(),d=(Date.now()-o)/(1e3*60*60*24)<=r.maxAgeForReuse,a=r.enabled&&e.reusable&&i&&s&&d,l=a?e.averageTokenSavings>0?e.averageTokenSavings:e.tokensUsed||0:0,h=t,f=e.successRate,u=Math.min(e.reuseCount/10,1),m=a?h*.4+f*.4+u*.2:0;return{canReuse:a,estimatedTokenSavings:l,reuseConfidence:m}}matchesFilters(e,t){if(t.patternType&&e.patternType!==t.patternType||t.domain&&e.qeDomain!==t.domain||t.tier&&e.tier!==t.tier||t.minConfidence!==void 0&&e.confidence<t.minConfidence||t.minQualityScore!==void 0&&e.qualityScore<t.minQualityScore)return!1;if(t.context){let r=t.context;if(r.language&&e.context.language!==r.language||r.framework&&e.context.framework!==r.framework||r.testType&&e.context.testType!==r.testType)return!1}return!0}async recordUsage(e,t,r,i){let s=await this.get(e);if(!s)return v(new Error(`Pattern not found: ${e}`));let o=new Date,c=s.usageCount+1,d=s.successfulUses+(t?1:0),a=d/c,l=t?.02:-.01,h=Math.max(.1,Math.min(1,s.confidence+l)),f=W({confidence:h,usageCount:c,successRate:a}),u={...s,usageCount:c,successfulUses:d,successRate:a,confidence:h,qualityScore:f,lastUsedAt:o};if(this.sqliteStore)try{this.sqliteStore.recordUsage(e,t,r,i)}catch(y){console.warn(`[PatternStore] SQLite recordUsage failed for ${e}:`,S(y))}if(L()&&this.deltaTracker)try{let y={id:s.id,name:s.name,confidence:s.confidence,qualityScore:s.qualityScore,usageCount:s.usageCount,successRate:s.successRate,tier:s.tier},w={id:u.id,name:u.name,confidence:u.confidence,qualityScore:u.qualityScore,usageCount:u.usageCount,successRate:u.successRate,tier:u.tier};this.deltaTracker.recordDelta(e,y,w,{success:t})}catch(y){console.debug(`[PatternStore] Delta recordDelta for ${e}:`,S(y))}let m=se(u);return m.meetsUsageCriteria&&m.meetsQualityCriteria&&m.meetsCoherenceCriteria&&u.tier==="short-term"?await this.promote(e):this.patternCache.set(e,u),P(void 0)}async promote(e){let t=await this.get(e);if(!t)return v(new Error(`Pattern not found: ${e}`));if(t.tier==="long-term")return P(void 0);let r={...t,tier:"long-term",confidence:Math.min(1,t.confidence+.1)};if(this.tierIndex.get("short-term")?.delete(e),this.tierIndex.get("long-term")?.add(e),this.patternCache.set(e,r),this.sqliteStore)try{this.sqliteStore.promotePattern(e)}catch(i){console.debug("[PatternStore] SQLite promotion error:",i instanceof Error?i.message:i)}return console.log(`[PatternStore] Promoted pattern ${e} (${t.name}) to long-term storage`),P(void 0)}async delete(e){let t=this.patternCache.get(e);if(!t)return v(new Error(`Pattern not found: ${e}`));if(this.unindexPattern(t),this.sqliteStore)try{this.sqliteStore.deletePattern(e)}catch(r){console.debug("[PatternStore] SQLite deletion error:",r instanceof Error?r.message:r)}if(this.hnswIndex!==null)try{await this.hnswIndex.delete(e)}catch(r){console.debug("[PatternStore] HNSW deletion error:",r instanceof Error?r.message:r)}return P(void 0)}async getStats(){let e={},t={};for(let[a,l]of this.domainIndex)e[a]=l.size;for(let[a,l]of this.typeIndex)t[a]=l.size;let r=0,i=0,s=0,o=0;for(let a of this.patternCache.values())r+=a.confidence,i+=a.qualityScore,s+=a.successRate,o++;let c=await this.ensureHNSW(),d=c!==null?await c.getStats():{nativeHNSW:!1,vectorCount:0,indexSizeBytes:0,lazyLoaded:!0};return{totalPatterns:this.patternCache.size,byTier:{shortTerm:this.tierIndex.get("short-term")?.size||0,longTerm:this.tierIndex.get("long-term")?.size||0},byDomain:e,byType:t,avgConfidence:o>0?r/o:0,avgQualityScore:o>0?i/o:0,avgSuccessRate:o>0?s/o:0,searchOperations:this.stats.searchOperations,avgSearchLatencyMs:this.calculateAvgLatency(),hnswStats:{nativeAvailable:d.nativeHNSW,vectorCount:d.vectorCount,indexSizeBytes:d.indexSizeBytes}}}async cleanup(){let e=0,t=0,r=[],i=[];for(let s of this.patternCache.values()){let o=se(s);if(o.meetsUsageCriteria&&o.meetsQualityCriteria&&o.meetsCoherenceCriteria){i.push(s.id);continue}if(s.tier==="short-term"){let d=s.createdAt instanceof Date?s.createdAt.getTime():new Date(s.createdAt).getTime(),a=Date.now()-d,l=a>10080*60*1e3,h=s.qualityScore<.2,f=s.usageCount===0&&a>1440*60*1e3;(l&&h||f)&&r.push(s.id)}}for(let s of i)(await this.promote(s)).success&&t++;for(let s of r)(await this.delete(s)).success&&e++;return console.log(`[PatternStore] Cleanup: removed ${e}, promoted ${t}`),{removed:e,promoted:t}}async cleanupDomain(e){let t=this.domainIndex.get(e);if(!t||t.size<this.config.maxPatternsPerDomain)return;let r=[];for(let o of t){let c=this.patternCache.get(o);c&&r.push(c)}r.sort((o,c)=>o.qualityScore-c.qualityScore);let i=Math.ceil(r.length*.1),s=0;for(let o of r){if(s>=i)break;o.tier==="short-term"&&(await this.delete(o.id),s++)}}recordSearchLatency(e){this.stats.searchOperations++,this.stats.searchLatencies.push(e),this.stats.searchLatencies.length>1e3&&(this.stats.searchLatencies=this.stats.searchLatencies.slice(-1e3))}calculateAvgLatency(){return this.stats.searchLatencies.length===0?0:this.stats.searchLatencies.reduce((t,r)=>t+r,0)/this.stats.searchLatencies.length}async dispose(){this.cleanupTimer&&(clearInterval(this.cleanupTimer),this.cleanupTimer=void 0),this.patternCache.clear(),this.domainIndex.clear(),this.typeIndex.clear(),this.tierIndex.clear(),this.hdcCache.clear(),this.deltaTracker=null,this.hyperbolicIndex&&(this.hyperbolicIndex.reset(),this.hyperbolicIndex=null),Q&&(Q.clear(),Q=null,xe=0),this.initialized=!1}indexHyperbolic(e,t,r){if(k())try{this.hyperbolicIndex||(this.hyperbolicIndex=it({dimensions:this.config.embeddingDimension,maxElements:this.config.hnsw.maxElements})),this.hyperbolicIndex.indexPattern(e,t,r)}catch(i){console.debug(`[PatternStore] Hyperbolic indexing failed for ${e}:`,i instanceof Error?i.message:i)}}async searchHyperbolic(e,t=10){if(!k()||!this.hyperbolicIndex)return P([]);try{let r=this.hyperbolicIndex.search(e,t),i=[];for(let s of r){let o=await this.get(s.patternId);if(!o)continue;let c=Math.exp(-s.distance),d=this.calculateReuseInfo(o,c);i.push({pattern:o,score:c,matchType:"vector",similarity:c,canReuse:d.canReuse,estimatedTokenSavings:d.estimatedTokenSavings,reuseConfidence:d.reuseConfidence})}return P(i)}catch(r){return console.warn("[PatternStore] Hyperbolic search failed, returning empty results:",r instanceof Error?r.message:r),P([])}}};function an(n,e){try{if(D().useRVFPatternStore&&Me()){let r=process.env.AQE_PROJECT_ROOT??Oe(),i=st(r,".agentic-qe"),s=st(i,"patterns.rvf");if(Xt(i)){let o={...Y,...e},c=!1;try{let d=ke(i,o.embeddingDimension);if(d){c=!0;let a=new z(()=>d,{rvfPath:s,base:o,skipCloseOnDispose:!0,embeddingSpaceId:o.embeddingSpaceId});return console.log("[PatternStore] Using RVF-backed store (ADR-066)"),a}}catch{}if(!c){let d=new z((a,l)=>{let h,f=()=>{try{return Ne(a)}catch(m){return h=m,null}},u=f();if(!u&&G(h)&&(!He(a)||(u=f(),!u&&G(h))))throw h;if(u){let m=u.dimension();if(m!==l){try{u.close()}catch{}throw new Error(`RVF dimension mismatch (file=${m}, requested=${l})`)}return u}try{return ae(a,l)}catch(m){if(u=f(),u){if(u.dimension()!==l){let p=u.dimension();try{u.close()}catch{}throw new Error(`RVF dimension mismatch (file=${p}, requested=${l})`)}return u}if(G(h))throw h;if(Le(a,m instanceof Error?m.message:String(m),h))return ae(a,l);throw m}},{rvfPath:s,base:o,embeddingSpaceId:o.embeddingSpaceId});return console.log("[PatternStore] Using RVF-backed store (ADR-066)"),d}}}}catch(t){console.warn("[PatternStore] RVF store unavailable, using in-memory HNSW:",t instanceof Error?t.message:t)}return new Ie(n,e)}export{R as a,an as b};
50
+ /*! Bundled license information:
51
+
52
+ fast-json-patch/commonjs/helpers.js:
53
+ (*!
54
+ * https://github.com/Starcounter-Jack/JSON-Patch
55
+ * (c) 2017-2022 Joachim Wester
56
+ * MIT licensed
57
+ *)
58
+
59
+ fast-json-patch/commonjs/duplex.js:
60
+ (*!
61
+ * https://github.com/Starcounter-Jack/JSON-Patch
62
+ * (c) 2017-2021 Joachim Wester
63
+ * MIT license
64
+ *)
65
+ */
@@ -0,0 +1,4 @@
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
+ import*as a from"fs";import*as m from"path";import{createRequire as z}from"node:module";var B=z(import.meta.url),b=B("semver"),L="3.14.5",y=t=>typeof t=="string"&&b.valid(t)===t.split("+")[0],E=t=>b.validRange(t)!==null,x=(t,e)=>b.satisfies(t,e),C=(t,e)=>b.compare(t,e),N=(t,e)=>C(e,t)||t.localeCompare(e);var R=class{cacheDir;keepVersions;constructor(e={}){this.cacheDir=e.cacheDir??m.join(process.cwd(),".agentic-qe","plugins"),this.keepVersions=e.keepVersions??2}has(e,n){let s=this.versionDir(e,n);return a.existsSync(s)&&a.existsSync(m.join(s,"qe-plugin.json"))}get(e,n){if(!this.has(e,n))return;let s=this.versionDir(e,n),i=a.readFileSync(m.join(s,"qe-plugin.json"),"utf-8"),r=JSON.parse(i),l=a.statSync(s);return{manifest:r,path:s,cachedAt:l.birthtime.toISOString()}}store(e,n){let s=this.versionDir(e.name,e.version);return a.existsSync(s)||(a.mkdirSync(s,{recursive:!0}),this.copyDir(n,s),a.writeFileSync(m.join(s,"qe-plugin.json"),JSON.stringify(e,null,2)),this.pruneOldVersions(e.name)),s}remove(e,n){let s=this.versionDir(e,n);return a.existsSync(s)?(a.rmSync(s,{recursive:!0,force:!0}),!0):!1}listVersions(e){let n=m.join(this.cacheDir,e);if(!a.existsSync(n))return[];let s=[],i=a.readdirSync(n);for(let r of i){let l=m.join(n,r),d=m.join(l,"qe-plugin.json");if(a.existsSync(d))try{let p=a.readFileSync(d,"utf-8"),v=JSON.parse(p);if(!y(v.version)){console.warn(`[PluginCache] Skipping cached plugin ${e}@${r}: invalid version ${JSON.stringify(v.version)}`);continue}let c=a.statSync(l);s.push({manifest:v,path:l,cachedAt:c.birthtime.toISOString()})}catch{}}return s}listAll(){if(!a.existsSync(this.cacheDir))return[];let e=[],n=a.readdirSync(this.cacheDir);for(let s of n){let i=this.listVersions(s);i.length>0&&(i.sort((r,l)=>N(r.manifest.version,l.manifest.version)),e.push(i[0]))}return e}listCandidates(){return a.existsSync(this.cacheDir)?a.readdirSync(this.cacheDir).flatMap(e=>this.listVersions(e)):[]}versionDir(e,n){return m.join(this.cacheDir,e,n)}pruneOldVersions(e){let n=this.listVersions(e);if(n.length<=this.keepVersions)return;n.sort((i,r)=>i.cachedAt.localeCompare(r.cachedAt));let s=n.slice(0,n.length-this.keepVersions);for(let i of s)a.rmSync(i.path,{recursive:!0,force:!0})}copyDir(e,n){if(!a.existsSync(e))return;let s=a.readdirSync(e,{withFileTypes:!0});for(let i of s){let r=m.join(e,i.name),l=m.join(n,i.name);if(i.isDirectory()){if(i.name===".git"||i.name==="node_modules")continue;a.mkdirSync(l,{recursive:!0}),this.copyDir(r,l)}else a.copyFileSync(r,l)}}};var K=/^[a-z][a-z0-9-]*$/,Z=["aqe-core-","agentic-qe-core-"],F=64,G=500;function k(t){let e=[],n=[];if(!t||typeof t!="object")return{valid:!1,errors:["Manifest must be a non-null object"],warnings:[]};let s=t;if(!s.name||typeof s.name!="string"?e.push("name is required and must be a string"):ee(s.name,e,n),!s.version||typeof s.version!="string"?e.push("version is required and must be a string"):y(s.version)||e.push(`version "${s.version}" is not valid semver (expected: major.minor.patch)`),!s.description||typeof s.description!="string"?e.push("description is required and must be a string"):s.description.length>G&&n.push(`description exceeds ${G} characters`),(!s.author||typeof s.author!="string")&&e.push("author is required and must be a string"),!Array.isArray(s.domains)||s.domains.length===0)e.push("domains is required and must be a non-empty array");else for(let i of s.domains)if(typeof i!="string"){e.push("Each domain must be a string");break}if(!s.entryPoint||typeof s.entryPoint!="string"?e.push("entryPoint is required and must be a string"):se(s.entryPoint,e),s.dependencies!==void 0)if(typeof s.dependencies!="object"||s.dependencies===null||Array.isArray(s.dependencies))e.push("dependencies must be an object mapping plugin names to semver ranges");else for(let[i,r]of Object.entries(s.dependencies))typeof r!="string"?e.push(`Dependency "${i}" must have a string version range`):E(r)||e.push(`Dependency "${i}" has an invalid semver range`);if(s.hooks!==void 0)if(typeof s.hooks!="object"||s.hooks===null||Array.isArray(s.hooks))e.push("hooks must be an object mapping event names to handler paths");else for(let[,i]of Object.entries(s.hooks)){if(typeof i!="string"){e.push("Hook handler paths must be strings");break}i.includes("..")&&e.push(`Hook handler path "${i}" must not contain ".." (path traversal)`)}if(s.minAqeVersion!==void 0&&(typeof s.minAqeVersion!="string"||!y(s.minAqeVersion))&&e.push("minAqeVersion must be valid semver"),s.permissions!==void 0){if(!Array.isArray(s.permissions))e.push("permissions must be an array of strings");else for(let i of s.permissions)if(typeof i!="string"){e.push("Each permission must be a string");break}}return{valid:e.length===0,errors:e,warnings:n}}function T(t){let e=typeof t=="string"?JSON.parse(t):t,n=k(e);if(!n.valid)throw new Error(`Invalid plugin manifest:
3
+ - ${n.errors.join(`
4
+ - `)}`);return e}function ee(t,e,n){t.length>F&&e.push(`name must be ${F} characters or fewer`),K.test(t)||e.push("name must be lowercase alphanumeric with hyphens, starting with a letter"),/[^\x00-\x7F]/.test(t)&&e.push("name must contain only ASCII characters");for(let s of Z)t.startsWith(s)&&e.push(`name cannot start with reserved prefix "${s}"`);["plugin","test","tool"].includes(t)&&n.push(`name "${t}" is very generic \u2014 consider a more descriptive name`)}function se(t,e){t.includes("..")&&e.push('entryPoint must not contain ".." (path traversal)'),(t.startsWith("/")||t.startsWith("\\"))&&e.push("entryPoint must be a relative path"),!t.endsWith(".js")&&!t.endsWith(".ts")&&!t.endsWith(".mjs")&&e.push("entryPoint must end in .js, .ts, or .mjs")}var I=class{constructor(e=L){this.aqeVersion=e}aqeVersion;resolve(e,n){let s=new Map,i=new Map;for(let o of e){let u=s.get(o.name)??[];s.set(o.name,u);let f=this.validateVersions(o);f?i.set(o.name,[...i.get(o.name)??[],f]):u.push(o)}for(let o of s.values())o.sort((u,f)=>N(u.version,f.version));let r=new Map,l=[],d=o=>({ordered:o.map((u,f)=>({manifest:u,order:f})),missing:r,errors:l,selectedVersions:Object.fromEntries(o.map(u=>[u.name,u.version])),aqeVersion:this.aqeVersion}),p=[...n??s.keys()].sort(),v=new Set(p),c=new Map,_=0,h=!1,J=()=>{for(let o of c.values())for(let[u,f]of Object.entries(o.dependencies??{})){let g=c.get(u);if(!(g?[g]:s.get(u)??[]).some(M=>x(M.version,f)))return!1}return!0},A,X=()=>{let o=new Set,u=new Set,f=(g,P)=>{if(u.has(g))return[...P.slice(P.indexOf(g)),g];if(!o.has(g)){u.add(g);for(let M of Object.keys(c.get(g)?.dependencies??{})){let Q=f(M,[...P,g]);if(Q)return Q}u.delete(g),o.add(g)}};for(let g of c.keys()){let P=f(g,[]);if(P)return P}},j=()=>{let o=new Set(p);for(let f of c.values())for(let g of Object.keys(f.dependencies??{}))o.add(g);let u=[...o].sort().find(f=>!c.has(f));if(!u){let f=X();return f?(A=f,!1):!0}v.add(u);for(let f of s.get(u)??[]){if(++_>1e4)return h=!0,!1;if(c.set(u,f),J()&&j())return!0;if(c.delete(u),h)return!1}return!1};if(!j()){if(A&&!h)throw new Error(`Dependency cycle detected: ${A.join(" -> ")}`);for(let o of v)s.get(o)?.length||l.push(...i.get(o)??[]);for(let[o,u]of s){let f=[...new Set(u.flatMap(g=>Object.keys(g.dependencies??{})))].filter(g=>!s.has(g));f.length&&r.set(o,f)}return l.push({code:h?"RESOLUTION_LIMIT":r.size?"MISSING_DEPENDENCY":"UNSATISFIED_DEPENDENCY_RANGE",plugin:p.join(", "),message:h?"Plugin dependency search exceeded 10000 candidates":"No cached plugin selection satisfies all dependency ranges"}),d([])}let O=[],q=new Set,w=new Set,$=(o,u)=>{if(q.has(o))return;if(w.has(o))throw new Error(`Dependency cycle detected: ${[...u.slice(u.indexOf(o)),o].join(" -> ")}`);w.add(o);let f=c.get(o);for(let g of Object.keys(f.dependencies??{}))$(g,[...u,o]);w.delete(o),q.add(o),O.push(f)};for(let o of[...c.keys()].sort())$(o,[]);return d(O)}resolveAvailable(e){let n=[],s=this.resolve(e,[]),i=[],r=new Map;for(let l of[...new Set(e.map(d=>d.name))].sort())try{let d=this.resolve(e,[...n,l]);if(d.errors.length){i.push(...d.errors.map(p=>({...p,plugin:l})));for(let[p,v]of d.missing)r.set(p,v);continue}n.push(l),s=d}catch(d){i.push({code:"DEPENDENCY_CYCLE",plugin:l,message:d instanceof Error?d.message:String(d)})}return{...s,errors:i,missing:r}}canLoad(e,n){let s=Object.entries(e.dependencies??{}).filter(([i,r])=>{let l=n instanceof Set?void 0:n.get(i);return!l||!E(r)||!x(l,r)}).map(([i])=>i);return{canLoad:!this.validateVersions(e)&&s.length===0,missingDeps:s}}validateVersions(e){if(!y(e.version))return{code:"INVALID_PLUGIN_VERSION",plugin:e.name,message:"Invalid plugin version"};for(let n of Object.values(e.dependencies??{}))if(!E(n))return{code:"INVALID_DEPENDENCY_RANGE",plugin:e.name,message:"Invalid dependency range"};if(e.minAqeVersion&&(!y(e.minAqeVersion)||!y(this.aqeVersion)||C(this.aqeVersion,e.minAqeVersion)<0))return{code:"AQE_VERSION_INCOMPATIBLE",plugin:e.name,message:`Requires AQE ${e.minAqeVersion}; running ${this.aqeVersion}`}}};var ne=["aqe-core-","agentic-qe-core-","agentic-qe-internal-"],U=new Set(["aqe","agentic-qe","ruflo","claude-flow"]),te=["..","~","/etc/","/proc/","/dev/","node_modules/"];function Y(t){let e=[];return ie(t.name,e),re(t.entryPoint,e),oe(t.hooks,e),ae(t.permissions,e),{safe:e.length===0,violations:e}}function ie(t,e){/[^\x20-\x7E]/.test(t)&&e.push(`Plugin name "${t}" contains non-ASCII characters`),U.has(t.toLowerCase())&&e.push(`Plugin name "${t}" is a reserved name`);for(let s of ne)t.toLowerCase().startsWith(s)&&e.push(`Plugin name "${t}" uses reserved prefix "${s}"`);let n=t.toLowerCase().replace(/[0o]/g,"o").replace(/[1il]/g,"l").replace(/[-_]/g,"");U.has(n)&&e.push(`Plugin name "${t}" is visually similar to a reserved name`)}function re(t,e){W(t,"entryPoint",e),(t.startsWith("/")||t.startsWith("\\"))&&e.push("entryPoint must be a relative path, not absolute")}function oe(t,e){if(t)for(let[n,s]of Object.entries(t))W(s,`hook[${n}]`,e)}function W(t,e,n){for(let s of te)t.includes(s)&&n.push(`${e} contains dangerous path pattern "${s}"`);t.includes("\0")&&n.push(`${e} contains null byte (path injection attempt)`)}function ae(t,e){if(!t)return;let n=["fs:write-root","net:arbitrary","exec:shell"];for(let s of t)n.includes(s)&&e.push(`Plugin requests dangerous permission: ${s}`)}import*as S from"fs";import*as V from"path";var D=class{type="local";async resolve(e){let n=V.resolve(e),s=V.join(n,"qe-plugin.json");if(!S.existsSync(s))throw new Error(`No qe-plugin.json found at ${s}`);let i=S.readFileSync(s,"utf-8");return T(i)}async getPluginPath(e){let n=V.resolve(e);if(!S.existsSync(n))throw new Error(`Plugin directory does not exist: ${n}`);return n}};var H=class{cache;resolver;sources=new Map;constructor(e={}){this.cache=e.cache??new R,this.resolver=new I;let n=new D;if(this.sources.set("local",n),e.sources)for(let s of e.sources)this.sources.set(s.type,s)}async install(e,n="local"){if(process.env.AQE_PLUGINS_DISABLED==="true")return{success:!1,errors:["Plugin loading is disabled (AQE_PLUGINS_DISABLED=true)"],securityViolations:[]};let s=[],i=this.sources.get(n);if(!i)return{success:!1,errors:[`Unknown source type: ${n}. Available: ${[...this.sources.keys()].join(", ")}`],securityViolations:[]};let r;try{r=await i.resolve(e)}catch(c){return{success:!1,errors:[`Failed to resolve plugin: ${c instanceof Error?c.message:String(c)}`],securityViolations:[]}}let l=k(r);if(!l.valid)return{success:!1,manifest:r,errors:l.errors,securityViolations:[]};let d=Y(r);if(!d.safe)return{success:!1,manifest:r,errors:["Plugin failed security checks"],securityViolations:d.violations};try{let c=this.cache.listCandidates().map(h=>h.manifest).filter(h=>h.name!==r.name),_=this.resolver.resolve([...c,r],[r.name]);if(_.errors.length)return{success:!1,manifest:r,errors:_.errors.map(h=>`${h.code}: ${h.message}`),securityViolations:[]}}catch(c){return{success:!1,manifest:r,errors:[c instanceof Error?c.message:String(c)],securityViolations:[]}}if(this.cache.has(r.name,r.version)){let c=this.cache.get(r.name,r.version);return{success:!0,manifest:r,cachePath:c.path,errors:[],securityViolations:[]}}let p;try{p=await i.getPluginPath(e)}catch(c){return{success:!1,manifest:r,errors:[`Failed to get plugin path: ${c instanceof Error?c.message:String(c)}`],securityViolations:[]}}let v=this.cache.store(r,p);return{success:!0,manifest:r,cachePath:v,errors:s,securityViolations:[]}}remove(e,n){if(n)return this.cache.remove(e,n);let s=this.cache.listVersions(e),i=!1;for(let r of s)this.cache.remove(e,r.manifest.version)&&(i=!0);return i}list(){return this.cache.listAll().map(n=>({name:n.manifest.name,version:n.manifest.version,description:n.manifest.description,domains:n.manifest.domains,source:"cached",cachePath:n.path}))}resolveLoadOrder(){let e=this.cache.listCandidates();return this.resolver.resolveAvailable(e.map(n=>n.manifest))}registerSource(e){this.sources.set(e.type,e)}};export{T as a,R as b,H as c};
@@ -1,5 +1,5 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.4");process.exit(0)}
2
- import{c as e}from"./chunk-TT23RRB7.js";function r(t){t.exec(n)}var n,a=e(()=>{"use strict";n=`
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
+ import{b as e}from"./chunk-JSZ663MU.js";function r(t){t.exec(n)}var n,a=e(()=>{"use strict";n=`
3
3
  -- Negative pattern records (ADR-110 kept nulls)
4
4
  CREATE TABLE IF NOT EXISTS qe_pattern_nulls (
5
5
  id TEXT PRIMARY KEY,
@@ -1,2 +1,2 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.4");process.exit(0)}
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
2
  import{readFileSync as l,writeFileSync as c,mkdirSync as m,renameSync as u}from"node:fs";import{join as d,dirname as h}from"node:path";import{homedir as p}from"node:os";var C={maxCallsPerSession:10},S=d(p(),".agentic-qe","advisor","circuit-breaker.json"),x=1440*60*1e3,n=class{maxCalls;statePath;constructor(t){this.maxCalls=t?.maxCallsPerSession??C.maxCallsPerSession,this.statePath=t?.statePath??S}acquire(t){let e=this.load(),a=e.sessions[t]?.count??0;if(a>=this.maxCalls)throw new i(`Advisor circuit breaker tripped: ${a} calls in session "${t}" (max: ${this.maxCalls}). Do not retry \u2014 continue without the advisor.`,t,a,this.maxCalls);let r=a+1;return e.sessions[t]={count:r,lastUpdated:new Date().toISOString()},this.save(e),{sessionId:t,callCount:r,maxCalls:this.maxCalls,remaining:this.maxCalls-r,tripped:!1}}getState(t){let s=this.load().sessions[t]?.count??0;return{sessionId:t,callCount:s,maxCalls:this.maxCalls,remaining:this.maxCalls-s,tripped:s>=this.maxCalls}}reset(t){if(t){let e=this.load();delete e.sessions[t],this.save(e)}else this.save({sessions:{}})}load(){try{let t=l(this.statePath,"utf-8"),e=JSON.parse(t);return this.evictStale(e),e}catch{return{sessions:{}}}}save(t){try{m(h(this.statePath),{recursive:!0});let e=this.statePath+".tmp."+process.pid;c(e,JSON.stringify(t,null,2)),u(e,this.statePath)}catch{}}evictStale(t){let e=Date.now();for(let[s,a]of Object.entries(t.sessions))e-new Date(a.lastUpdated).getTime()>x&&delete t.sessions[s]}},i=class extends Error{constructor(e,s,a,r){super(e);this.sessionId=s;this.callCount=a;this.maxCalls=r;this.name="AdvisorCircuitBreakerError"}sessionId;callCount;maxCalls;exitCode=3};export{n as a,i as b};
@@ -1,2 +1,2 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.4");process.exit(0)}
2
- import{c as h}from"./chunk-TT23RRB7.js";function i(t,r){if(t.length!==r.length)throw new Error(`Vector length mismatch: ${t.length} vs ${r.length}`);let e=0,o=0,l=0;for(let n=0;n<t.length;n++)e+=t[n]*r[n],o+=t[n]*t[n],l+=r[n]*r[n];let u=Math.sqrt(o)*Math.sqrt(l);return u===0?0:e/u}function c(t){let r=Math.sqrt(t.reduce((e,o)=>e+o*o,0));return r===0?t.slice():t.map(e=>e/r)}function g(t){let r=0;for(let e=0;e<t.length;e++)r+=t[e]*t[e];return Math.sqrt(r)}var m=h(()=>{"use strict"});export{i as a,c as b,g as c,m as d};
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
+ import{b as h}from"./chunk-JSZ663MU.js";function i(t,r){if(t.length!==r.length)throw new Error(`Vector length mismatch: ${t.length} vs ${r.length}`);let e=0,o=0,l=0;for(let n=0;n<t.length;n++)e+=t[n]*r[n],o+=t[n]*t[n],l+=r[n]*r[n];let u=Math.sqrt(o)*Math.sqrt(l);return u===0?0:e/u}function c(t){let r=Math.sqrt(t.reduce((e,o)=>e+o*o,0));return r===0?t.slice():t.map(e=>e/r)}function g(t){let r=0;for(let e=0;e<t.length;e++)r+=t[e]*t[e];return Math.sqrt(r)}var m=h(()=>{"use strict"});export{i as a,c as b,g as c,m as d};
@@ -1,2 +1,2 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.4");process.exit(0)}
2
- import{a as n}from"./chunk-6TPKK7LD.js";import{a as i}from"./chunk-AIHDEEJO.js";import{a as o,e as d}from"./chunk-BFP7KO7P.js";import{existsSync as m,statSync as s}from"node:fs";import{extname as l,join as c}from"node:path";d();var _=o.CLEANUP_INTERVAL_MS,y=".agentic-qe/memory.db";async function p(t,r=!0){let e;switch(t.type){case"memory":e=new i;break;case"sqlite":e=new n({sqlite:t.sqlite,enableFallback:!0});break;case"agentdb":e=new n({sqlite:{path:t.agentdb?.path??y},enableFallback:!0});break;case"hybrid":e=new n(t.hybrid);break;default:throw new Error(`Unknown memory backend type: ${t.type}`)}return r&&await e.initialize(),{backend:e,type:t.type,initialized:r}}async function P(t=!0){let r=process.env.AQE_MEMORY_BACKEND??"memory",e=process.env.AQE_MEMORY_PATH,a=e?e===":memory:"?e:m(e)?s(e).isDirectory()?c(e,"memory.db"):e:/\.(db|sqlite|sqlite3)$/i.test(l(e))?e:c(e,"memory.db"):y;return p({type:r,sqlite:{path:a,walMode:!0},agentdb:{path:a},hybrid:{enableFallback:!0,sqlite:{path:a}}},t)}export{p as a,P as b};
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
+ import{a as n}from"./chunk-LULD4JV2.js";import{a as i}from"./chunk-7VFY7TUR.js";import{a as o,e as d}from"./chunk-CVMNJSCB.js";import{existsSync as m,statSync as s}from"node:fs";import{extname as l,join as c}from"node:path";d();var _=o.CLEANUP_INTERVAL_MS,y=".agentic-qe/memory.db";async function p(t,r=!0){let e;switch(t.type){case"memory":e=new i;break;case"sqlite":e=new n({sqlite:t.sqlite,enableFallback:!0});break;case"agentdb":e=new n({sqlite:{path:t.agentdb?.path??y},enableFallback:!0});break;case"hybrid":e=new n(t.hybrid);break;default:throw new Error(`Unknown memory backend type: ${t.type}`)}return r&&await e.initialize(),{backend:e,type:t.type,initialized:r}}async function P(t=!0){let r=process.env.AQE_MEMORY_BACKEND??"memory",e=process.env.AQE_MEMORY_PATH,a=e?e===":memory:"?e:m(e)?s(e).isDirectory()?c(e,"memory.db"):e:/\.(db|sqlite|sqlite3)$/i.test(l(e))?e:c(e,"memory.db"):y;return p({type:r,sqlite:{path:a,walMode:!0},agentdb:{path:a},hybrid:{enableFallback:!0,sqlite:{path:a}}},t)}export{p as a,P as b};
@@ -1,2 +1,2 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.4");process.exit(0)}
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
2
  async function o(n){await n.loadAll();let a=new Map;for(let i of n.getLoaded())a.set(i,await n.load(i));return a}export{o as a};
@@ -1,2 +1,2 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.4");process.exit(0)}
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
2
  import{createHash as o}from"node:crypto";import a from"node:fs";function c(r){let n=[...r].sort((e,t)=>e.id.localeCompare(t.id)).map(e=>({id:e.id,inputUnderTest:e.inputUnderTest,moduleName:e.moduleName,referenceImpl:e.referenceImpl,requirements:e.requirements,expectedMutants:e.expectedMutants}));return JSON.stringify(n)}function s(r){return o("sha256").update(c(r)).digest("hex")}function u(r){let n=JSON.parse(a.readFileSync(r,"utf8")),e=s(n.items);if(e!==n.contentHash)throw new Error(`Anchor set hash drift at ${r}: recorded ${n.contentHash}, recomputed ${e}. Refusing to load a mutated frozen anchor (ADR-117). A legitimate change must be a versioned re-freeze (qe-anchor-v2), never an in-place edit.`);if(n.items.length===0)throw new Error(`Anchor set at ${r} has no items \u2014 a frozen anchor must be non-empty.`);return n}function h(r,n,e){return r>=n-e}export{u as a,h as b};
@@ -1,2 +1,2 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.4");process.exit(0)}
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
2
  function r(e,f){if(e==null)return e;let n={...e};for(let t of f){let o=n[t];typeof o=="string"&&(n[t]=new Date(o))}return n}export{r as a};