agentic-qe 3.8.13 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/.claude/skills/skills-manifest.json +1 -1
  2. package/CHANGELOG.md +48 -0
  3. package/dist/adapters/a2ui/integration/agui-sync.js +2 -1
  4. package/dist/audit/witness-chain.js +15 -3
  5. package/dist/boot/fast-paths.d.ts +24 -0
  6. package/dist/boot/fast-paths.js +43 -0
  7. package/dist/boot/parallel-prefetch.d.ts +26 -0
  8. package/dist/boot/parallel-prefetch.js +36 -0
  9. package/dist/cli/bundle.js +12 -9431
  10. package/dist/cli/chunks/adapter-WBR5NXS3.js +2 -0
  11. package/dist/cli/chunks/agent-booster-wasm-PQYB7VRU.js +2 -0
  12. package/dist/cli/chunks/agent-handler-QDAB5NQS.js +33 -0
  13. package/dist/cli/chunks/aqe-learning-engine-TK4JQCGT.js +2 -0
  14. package/dist/cli/chunks/audit-S7JUYYVP.js +3 -0
  15. package/dist/cli/chunks/base-2WXOSMBQ.js +2 -0
  16. package/dist/cli/chunks/better-sqlite3-7KY2RDXO.js +2 -0
  17. package/dist/cli/chunks/brain-handler-PPEGDCN4.js +68 -0
  18. package/dist/cli/chunks/branch-enumerator-XK4V5W7L.js +7 -0
  19. package/dist/cli/chunks/browser-PALA5PL3.js +4 -0
  20. package/dist/cli/chunks/browser-workflow-42F7GK5T.js +2 -0
  21. package/dist/cli/chunks/chunk-24FKIJNC.js +15 -0
  22. package/dist/cli/chunks/chunk-263XS447.js +2 -0
  23. package/dist/cli/chunks/chunk-2BZFNEN2.js +4 -0
  24. package/dist/cli/chunks/chunk-2E5NQNSU.js +180 -0
  25. package/dist/cli/chunks/chunk-2I7J3O6V.js +2 -0
  26. package/dist/cli/chunks/chunk-3ADGXLTM.js +14 -0
  27. package/dist/cli/chunks/chunk-3IHG3WOY.js +12 -0
  28. package/dist/cli/chunks/chunk-3IUNFTIF.js +2 -0
  29. package/dist/cli/chunks/chunk-3JPRUND5.js +2 -0
  30. package/dist/cli/chunks/chunk-3NZLZHJI.js +2 -0
  31. package/dist/cli/chunks/chunk-3THRQEZ2.js +95 -0
  32. package/dist/cli/chunks/chunk-3ZOONQG6.js +2 -0
  33. package/dist/cli/chunks/chunk-4B6NCELM.js +2 -0
  34. package/dist/cli/chunks/chunk-4I2IOUS4.js +2 -0
  35. package/dist/cli/chunks/chunk-4VBTXZRM.js +2 -0
  36. package/dist/cli/chunks/chunk-4VUPRTVX.js +3 -0
  37. package/dist/cli/chunks/chunk-4YOMLWEK.js +70 -0
  38. package/dist/cli/chunks/chunk-4YS3IJ45.js +2 -0
  39. package/dist/cli/chunks/chunk-5SKGFSKD.js +2 -0
  40. package/dist/cli/chunks/chunk-5T2ZQWKF.js +27 -0
  41. package/dist/cli/chunks/chunk-62ADTHV7.js +2 -0
  42. package/dist/cli/chunks/chunk-6EOS7KX2.js +2 -0
  43. package/dist/cli/chunks/chunk-6SVX4DJC.js +6 -0
  44. package/dist/cli/chunks/chunk-72WOAVK6.js +2 -0
  45. package/dist/cli/chunks/chunk-7R6YMLVS.js +3 -0
  46. package/dist/cli/chunks/chunk-7VDBAVTY.js +2 -0
  47. package/dist/cli/chunks/chunk-AFLLQ5PP.js +15 -0
  48. package/dist/cli/chunks/chunk-AKE543X2.js +2 -0
  49. package/dist/cli/chunks/chunk-B36CDR4U.js +2 -0
  50. package/dist/cli/chunks/chunk-B6LLWYQ6.js +2 -0
  51. package/dist/cli/chunks/chunk-BDIEMZ22.js +91 -0
  52. package/dist/cli/chunks/chunk-BGXNSCXX.js +4 -0
  53. package/dist/cli/chunks/chunk-BLBRY5UD.js +2 -0
  54. package/dist/cli/chunks/chunk-BPWXXEH2.js +3029 -0
  55. package/dist/cli/chunks/chunk-BR26T7ZS.js +180 -0
  56. package/dist/cli/chunks/chunk-BTREG4IW.js +2 -0
  57. package/dist/cli/chunks/chunk-BULKFVYX.js +2 -0
  58. package/dist/cli/chunks/chunk-BXAXGEFC.js +24 -0
  59. package/dist/cli/chunks/chunk-CL6POIX4.js +2 -0
  60. package/dist/cli/chunks/chunk-CS2KS7LP.js +2 -0
  61. package/dist/cli/chunks/chunk-CWFB6BSA.js +316 -0
  62. package/dist/cli/chunks/chunk-DRT3WKQW.js +2 -0
  63. package/dist/cli/chunks/chunk-EHDQJQ6Y.js +27 -0
  64. package/dist/cli/chunks/chunk-ESVQ6MEB.js +2 -0
  65. package/dist/cli/chunks/chunk-FEKY7T6Q.js +2 -0
  66. package/dist/cli/chunks/chunk-FGA7VIFR.js +7 -0
  67. package/dist/cli/chunks/chunk-FIA6X7UL.js +2 -0
  68. package/dist/cli/chunks/chunk-GAOJV3OX.js +2 -0
  69. package/dist/cli/chunks/chunk-GKNNSCLC.js +5 -0
  70. package/dist/cli/chunks/chunk-GPQ57KA4.js +2 -0
  71. package/dist/cli/chunks/chunk-GRUUQAR6.js +2 -0
  72. package/dist/cli/chunks/chunk-HRO6OZQD.js +2 -0
  73. package/dist/cli/chunks/chunk-HY6PMO5W.js +66 -0
  74. package/dist/cli/chunks/chunk-IAV2JMIX.js +167 -0
  75. package/dist/cli/chunks/chunk-IFNIIK34.js +21 -0
  76. package/dist/cli/chunks/chunk-IGJPMN4I.js +3 -0
  77. package/dist/cli/chunks/chunk-J3KWWR6Z.js +1 -0
  78. package/dist/cli/chunks/chunk-JBANAPWG.js +2 -0
  79. package/dist/cli/chunks/chunk-JJO7Y4H3.js +604 -0
  80. package/dist/cli/chunks/chunk-JRYGQO2W.js +2 -0
  81. package/dist/cli/chunks/chunk-JXM26HEE.js +2 -0
  82. package/dist/cli/chunks/chunk-JZSDOIXA.js +2 -0
  83. package/dist/cli/chunks/chunk-KP5NUODU.js +3 -0
  84. package/dist/cli/chunks/chunk-LHJQD2VU.js +750 -0
  85. package/dist/cli/chunks/chunk-LNQIY6BP.js +2 -0
  86. package/dist/cli/chunks/chunk-MDUHYUHF.js +2 -0
  87. package/dist/cli/chunks/chunk-MV6CMOJQ.js +65 -0
  88. package/dist/cli/chunks/chunk-MZOFWJTM.js +2 -0
  89. package/dist/cli/chunks/chunk-N2NS2PHA.js +45 -0
  90. package/dist/cli/chunks/chunk-N4TL73TH.js +314 -0
  91. package/dist/cli/chunks/chunk-N5UXCLFI.js +2 -0
  92. package/dist/cli/chunks/chunk-NZ2VCPN4.js +2 -0
  93. package/dist/cli/chunks/chunk-OF4D7MYI.js +2 -0
  94. package/dist/cli/chunks/chunk-OI5NGQO2.js +2 -0
  95. package/dist/cli/chunks/chunk-OLHKGP35.js +2 -0
  96. package/dist/cli/chunks/chunk-QOVHWZEP.js +1 -0
  97. package/dist/cli/chunks/chunk-RFSN6IDA.js +79 -0
  98. package/dist/cli/chunks/chunk-RTGGL7D7.js +4 -0
  99. package/dist/cli/chunks/chunk-RU5WAHB7.js +3 -0
  100. package/dist/cli/chunks/chunk-SUSEVMZT.js +2 -0
  101. package/dist/cli/chunks/chunk-TLHP5EII.js +2 -0
  102. package/dist/cli/chunks/chunk-TWUWL5EJ.js +2 -0
  103. package/dist/cli/chunks/chunk-U5RN7YQW.js +2 -0
  104. package/dist/cli/chunks/chunk-UFUVUO3J.js +2 -0
  105. package/dist/cli/chunks/chunk-UQHYFOBX.js +16 -0
  106. package/dist/cli/chunks/chunk-VOS4NQSF.js +2 -0
  107. package/dist/cli/chunks/chunk-VSVXUTJN.js +256 -0
  108. package/dist/cli/chunks/chunk-WBQSXPBI.js +2 -0
  109. package/dist/cli/chunks/chunk-WGMPEW2T.js +2 -0
  110. package/dist/cli/chunks/chunk-WIEC7VKK.js +2 -0
  111. package/dist/cli/chunks/chunk-WJ3DLOXF.js +14 -0
  112. package/dist/cli/chunks/chunk-X3KI6JOY.js +9 -0
  113. package/dist/cli/chunks/chunk-X5IJGWYG.js +2 -0
  114. package/dist/cli/chunks/chunk-XIBDETCS.js +146 -0
  115. package/dist/cli/chunks/chunk-XLRQYLWW.js +2 -0
  116. package/dist/cli/chunks/chunk-XO6PVK2P.js +3 -0
  117. package/dist/cli/chunks/chunk-XRE2HCWG.js +3 -0
  118. package/dist/cli/chunks/chunk-XT2V2322.js +2 -0
  119. package/dist/cli/chunks/chunk-Y7BHKZFJ.js +18 -0
  120. package/dist/cli/chunks/chunk-YAGODYIG.js +59 -0
  121. package/dist/cli/chunks/chunk-YANUP2RO.js +2 -0
  122. package/dist/cli/chunks/chunk-YPFOCNOE.js +30 -0
  123. package/dist/cli/chunks/chunk-YR6ZZGH7.js +81 -0
  124. package/dist/cli/chunks/chunk-YVA65UZL.js +2 -0
  125. package/dist/cli/chunks/chunk-YW2THB5Q.js +2 -0
  126. package/dist/cli/chunks/chunk-ZAPS3UGQ.js +20 -0
  127. package/dist/cli/chunks/chunk-ZDATDCYN.js +2 -0
  128. package/dist/cli/chunks/ci-J374KDLI.js +81 -0
  129. package/dist/cli/chunks/ci-output-7JN7F6CI.js +2 -0
  130. package/dist/cli/chunks/claude-flow-setup-245JLJCN.js +2 -0
  131. package/dist/cli/chunks/client-MCSNSH2C.js +2 -0
  132. package/dist/cli/chunks/cline-installer-LBA2M5N3.js +4 -0
  133. package/dist/cli/chunks/code-U4N4WONM.js +38 -0
  134. package/dist/cli/chunks/code-index-extractor-A57Z6BO4.js +3 -0
  135. package/dist/cli/chunks/codex-installer-UXMK2N4T.js +8 -0
  136. package/dist/cli/chunks/completions-W66BSCOE.js +1364 -0
  137. package/dist/cli/chunks/complexity-analyzer-AB4OZARV.js +2 -0
  138. package/dist/cli/chunks/continuedev-installer-LRFZ2SJM.js +14 -0
  139. package/dist/cli/chunks/copilot-installer-CQ3JYBIB.js +3 -0
  140. package/dist/cli/chunks/cost-tracker-4F723RB6.js +2 -0
  141. package/dist/cli/chunks/coverage-4PUEQXAY.js +27 -0
  142. package/dist/cli/chunks/cross-domain-router-OWR5IJ5G.js +2 -0
  143. package/dist/cli/chunks/cursor-installer-JZEDEDHA.js +3 -0
  144. package/dist/cli/chunks/daemon-B7TWGHXQ.js +19 -0
  145. package/dist/cli/chunks/dag-attention-scheduler-JWO6XI6A.js +2 -0
  146. package/dist/cli/chunks/detect-L6ZZHUSX.js +2 -0
  147. package/dist/cli/chunks/domain-handler-FT5FLZWL.js +25 -0
  148. package/dist/cli/chunks/domain-transfer-5Y4FGJAJ.js +2 -0
  149. package/dist/cli/chunks/dream-4TDBIYED.js +2 -0
  150. package/dist/cli/chunks/esm-node-2PKHKOTS.js +2 -0
  151. package/dist/cli/chunks/eval-GHMPFGWV.js +15 -0
  152. package/dist/cli/chunks/fast-paths-B3R647KN.js +2 -0
  153. package/dist/cli/chunks/feature-flags-DWS7ARSX.js +2 -0
  154. package/dist/cli/chunks/feature-flags-IVQ3AL4Q.js +2 -0
  155. package/dist/cli/chunks/file-discovery-QFPA6GMV.js +2 -0
  156. package/dist/cli/chunks/fleet-EKOKMOMW.js +43 -0
  157. package/dist/cli/chunks/gnn-wrapper-OYC55N5E.js +2 -0
  158. package/dist/cli/chunks/heartbeat-handler-MBBS4IBU.js +48 -0
  159. package/dist/cli/chunks/heartbeat-scheduler-XDGMOT7X.js +2 -0
  160. package/dist/cli/chunks/hnsw-index-YO7CT23I.js +2 -0
  161. package/dist/cli/chunks/hnswlib-node-56YWVXFE.js +2 -0
  162. package/dist/cli/chunks/hooks-L5VLZGEK.js +101 -0
  163. package/dist/cli/chunks/hypergraph-engine-A4Y2ZRAG.js +2 -0
  164. package/dist/cli/chunks/hypergraph-handler-3HDGB5SZ.js +35 -0
  165. package/dist/cli/chunks/impact-analyzer-UEIGXSZ4.js +2 -0
  166. package/dist/cli/chunks/init-handler-JDET6WUN.js +68 -0
  167. package/dist/cli/chunks/init-wizard-JWZUGIPJ.js +2 -0
  168. package/dist/cli/chunks/kernel-YNDTVKIW.js +2 -0
  169. package/dist/cli/chunks/kilocode-installer-GZZG5AFW.js +4 -0
  170. package/dist/cli/chunks/kiro-installer-IWNY5TKH.js +74 -0
  171. package/dist/cli/chunks/knowledge-graph-NGJKFTSN.js +2 -0
  172. package/dist/cli/chunks/learning-722ZNSZ6.js +107 -0
  173. package/dist/cli/chunks/llm-router-DNAV746L.js +30 -0
  174. package/dist/cli/chunks/load-Y3GCUFM4.js +2 -0
  175. package/dist/cli/chunks/load-test-GZUBXFF3.js +2 -0
  176. package/dist/cli/chunks/mcp-LKPIBZ3W.js +2 -0
  177. package/dist/cli/chunks/memory-L57MLFOP.js +32 -0
  178. package/dist/cli/chunks/memory-backend-3NQIZUXE.js +2 -0
  179. package/dist/cli/chunks/memory-handlers-MDZQ7HVW.js +2 -0
  180. package/dist/cli/chunks/opencode-installer-4HUB36H5.js +3 -0
  181. package/dist/cli/chunks/orchestrator-QHSBB2UC.js +371 -0
  182. package/dist/cli/chunks/pipeline-D3QER35Z.js +19 -0
  183. package/dist/cli/chunks/platform-T4E7Q3RD.js +2 -0
  184. package/dist/cli/chunks/plugin-JHW2YPRC.js +27 -0
  185. package/dist/cli/chunks/prime-radiant-advanced-wasm-G7CFNNQV.js +2 -0
  186. package/dist/cli/chunks/protocol-executor-SPUVRDWT.js +2 -0
  187. package/dist/cli/chunks/protocol-handler-2BQQ4HDM.js +20 -0
  188. package/dist/cli/chunks/prove-UQ6JFT73.js +3 -0
  189. package/dist/cli/chunks/qe-reasoning-bank-3HBK2FVD.js +2 -0
  190. package/dist/cli/chunks/quality-JRZYMC77.js +7 -0
  191. package/dist/cli/chunks/queen-coordinator-RW3NKO5A.js +2 -0
  192. package/dist/cli/chunks/real-embeddings-GK63VF35.js +2 -0
  193. package/dist/cli/chunks/roocode-installer-F4E2LAYR.js +4 -0
  194. package/dist/cli/chunks/router-RJGHWDQ3.js +2 -0
  195. package/dist/cli/chunks/routing-feedback-ZXBXFKX6.js +2 -0
  196. package/dist/cli/chunks/routing-handler-VNKFUUGB.js +20 -0
  197. package/dist/cli/chunks/ruvector-commands-2TLNHC3A.js +8 -0
  198. package/dist/cli/chunks/rvf-dual-writer-MQW2SJLT.js +2 -0
  199. package/dist/cli/chunks/rvf-native-adapter-LKFKTMUN.js +2 -0
  200. package/dist/cli/chunks/safe-db-G22E5ROA.js +2 -0
  201. package/dist/cli/chunks/schedule-Y7VVCPYV.js +2 -0
  202. package/dist/cli/chunks/scheduler-AUQIFQB7.js +2 -0
  203. package/dist/cli/chunks/security-EBEG2OPU.js +14 -0
  204. package/dist/cli/chunks/shared-rvf-dual-writer-BVSCQAFS.js +2 -0
  205. package/dist/cli/chunks/sqlite-persistence-JAVHUGGL.js +2 -0
  206. package/dist/cli/chunks/status-handler-VZ32M4G4.js +45 -0
  207. package/dist/cli/chunks/structural-health-K6LRCKV6.js +2 -0
  208. package/dist/cli/chunks/sync-MHSHNLIM.js +23 -0
  209. package/dist/cli/chunks/task-handler-JNOIBZ2G.js +49 -0
  210. package/dist/cli/chunks/task-handlers-P5DSUKND.js +2 -0
  211. package/dist/cli/chunks/test-DO22BNIL.js +33 -0
  212. package/dist/cli/chunks/test-scheduling-VLRQZEFL.js +15 -0
  213. package/dist/cli/chunks/token-bootstrap-4VJKGVMK.js +2 -0
  214. package/dist/cli/chunks/token-usage-LG3PXRXH.js +25 -0
  215. package/dist/cli/chunks/transformers-GY7SIKEU.js +2 -0
  216. package/dist/cli/chunks/tree-sitter-wasm-parser-FT2KB66N.js +2 -0
  217. package/dist/cli/chunks/types-QJGNBKP2.js +2 -0
  218. package/dist/cli/chunks/unified-memory-XYGENQUT.js +2 -0
  219. package/dist/cli/chunks/unified-memory-hnsw-MVEGQBF3.js +2 -0
  220. package/dist/cli/chunks/unified-persistence-PFRCWEUG.js +2 -0
  221. package/dist/cli/chunks/validate-VQCRSVNQ.js +21 -0
  222. package/dist/cli/chunks/validate-swarm-A5DHAWTP.js +14 -0
  223. package/dist/cli/chunks/vibium-RZBSL4EB.js +2 -0
  224. package/dist/cli/chunks/visual-security-V47BLGJM.js +2 -0
  225. package/dist/cli/chunks/web-tree-sitter-7C4NXEOF.js +2 -0
  226. package/dist/cli/chunks/windsurf-installer-ES3KPQG3.js +7 -0
  227. package/dist/cli/chunks/witness-chain-BR63P4A7.js +2 -0
  228. package/dist/cli/chunks/workflow-JETHX4ML.js +51 -0
  229. package/dist/cli/chunks/workflow-orchestrator-7PZMX3JZ.js +2 -0
  230. package/dist/cli/chunks/wrappers-WP5RH745.js +2 -0
  231. package/dist/cli/commands/daemon.d.ts +13 -0
  232. package/dist/cli/commands/daemon.js +224 -0
  233. package/dist/cli/commands/hooks-handlers/hooks-shared.js +2 -1
  234. package/dist/cli/commands/plugin.d.ts +12 -0
  235. package/dist/cli/commands/plugin.js +135 -0
  236. package/dist/cli/commands/workflow.d.ts +10 -0
  237. package/dist/cli/commands/workflow.js +587 -0
  238. package/dist/cli/handlers/brain-handler.js +13 -8
  239. package/dist/cli/handlers/heartbeat-handler.d.ts +1 -0
  240. package/dist/cli/handlers/heartbeat-handler.js +20 -10
  241. package/dist/cli/handlers/hypergraph-handler.js +3 -3
  242. package/dist/cli/handlers/init-handler.js +10 -9
  243. package/dist/cli/handlers/interfaces.d.ts +4 -4
  244. package/dist/cli/index.js +159 -638
  245. package/dist/cli/lazy-registry.d.ts +27 -0
  246. package/dist/cli/lazy-registry.js +70 -0
  247. package/dist/context/compaction/context-budget.d.ts +71 -0
  248. package/dist/context/compaction/context-budget.js +120 -0
  249. package/dist/context/compaction/index.d.ts +96 -0
  250. package/dist/context/compaction/index.js +259 -0
  251. package/dist/context/compaction/llm-caller-adapter.d.ts +14 -0
  252. package/dist/context/compaction/llm-caller-adapter.js +47 -0
  253. package/dist/context/compaction/tier1-microcompact.d.ts +33 -0
  254. package/dist/context/compaction/tier1-microcompact.js +47 -0
  255. package/dist/context/compaction/tier2-session-summary.d.ts +72 -0
  256. package/dist/context/compaction/tier2-session-summary.js +172 -0
  257. package/dist/context/compaction/tier3-llm-compact.d.ts +65 -0
  258. package/dist/context/compaction/tier3-llm-compact.js +166 -0
  259. package/dist/context/compaction/tier4-reactive.d.ts +54 -0
  260. package/dist/context/compaction/tier4-reactive.js +129 -0
  261. package/dist/coordination/consensus/providers/claude-provider.d.ts +1 -0
  262. package/dist/coordination/consensus/providers/claude-provider.js +23 -3
  263. package/dist/domains/test-generation/generators/base-test-generator.d.ts +1 -1
  264. package/dist/domains/test-generation/generators/base-test-generator.js +11 -11
  265. package/dist/domains/test-generation/generators/go-test-generator.js +12 -12
  266. package/dist/domains/test-generation/generators/junit5-generator.js +9 -9
  267. package/dist/domains/test-generation/generators/kotlin-junit-generator.js +10 -10
  268. package/dist/domains/test-generation/generators/pytest-generator.js +8 -8
  269. package/dist/domains/test-generation/generators/swift-testing-generator.js +8 -8
  270. package/dist/domains/test-generation/generators/test-value-helpers.d.ts +20 -0
  271. package/dist/domains/test-generation/generators/test-value-helpers.js +48 -0
  272. package/dist/domains/test-generation/generators/xunit-generator.js +11 -11
  273. package/dist/hooks/cross-phase-hooks.d.ts +11 -0
  274. package/dist/hooks/cross-phase-hooks.js +73 -9
  275. package/dist/hooks/security/config-snapshot.d.ts +21 -0
  276. package/dist/hooks/security/config-snapshot.js +33 -0
  277. package/dist/hooks/security/exit-codes.d.ts +28 -0
  278. package/dist/hooks/security/exit-codes.js +33 -0
  279. package/dist/hooks/security/index.d.ts +15 -0
  280. package/dist/hooks/security/index.js +15 -0
  281. package/dist/hooks/security/ssrf-guard.d.ts +25 -0
  282. package/dist/hooks/security/ssrf-guard.js +69 -0
  283. package/dist/index.d.ts +1 -1
  284. package/dist/index.js +1 -2
  285. package/dist/init/init-wizard-hooks.js +15 -1
  286. package/dist/init/phases/07-hooks.js +2 -2
  287. package/dist/init/settings-merge.js +3 -7
  288. package/dist/kernel/kernel.js +35 -0
  289. package/dist/kernel/memory-backend.js +3 -1
  290. package/dist/mcp/bundle.js +416 -362
  291. package/dist/mcp/entry.js +132 -77
  292. package/dist/mcp/http-server.js +4 -1
  293. package/dist/mcp/index.d.ts +2 -2
  294. package/dist/mcp/index.js +5 -4
  295. package/dist/mcp/middleware/batch-executor.d.ts +46 -0
  296. package/dist/mcp/middleware/batch-executor.js +150 -0
  297. package/dist/mcp/middleware/microcompact.d.ts +97 -0
  298. package/dist/mcp/middleware/microcompact.js +179 -0
  299. package/dist/mcp/middleware/middleware-chain.d.ts +37 -0
  300. package/dist/mcp/middleware/middleware-chain.js +60 -0
  301. package/dist/mcp/protocol-server.d.ts +16 -0
  302. package/dist/mcp/protocol-server.js +140 -36
  303. package/dist/mcp/services/session-durability-middleware.d.ts +22 -0
  304. package/dist/mcp/services/session-durability-middleware.js +64 -0
  305. package/dist/mcp/services/session-resume.d.ts +29 -0
  306. package/dist/mcp/services/session-resume.js +221 -0
  307. package/dist/mcp/services/session-store.d.ts +84 -0
  308. package/dist/mcp/services/session-store.js +163 -0
  309. package/dist/mcp/tool-registry.d.ts +9 -0
  310. package/dist/mcp/tool-registry.js +30 -1
  311. package/dist/mcp/types.d.ts +1 -0
  312. package/dist/plugins/cache.d.ts +44 -0
  313. package/dist/plugins/cache.js +149 -0
  314. package/dist/plugins/index.d.ts +15 -0
  315. package/dist/plugins/index.js +15 -0
  316. package/dist/plugins/lifecycle.d.ts +67 -0
  317. package/dist/plugins/lifecycle.js +175 -0
  318. package/dist/plugins/manifest.d.ts +45 -0
  319. package/dist/plugins/manifest.js +173 -0
  320. package/dist/plugins/resolver.d.ts +37 -0
  321. package/dist/plugins/resolver.js +80 -0
  322. package/dist/plugins/security.d.ts +23 -0
  323. package/dist/plugins/security.js +125 -0
  324. package/dist/plugins/sources/github.d.ts +17 -0
  325. package/dist/plugins/sources/github.js +77 -0
  326. package/dist/plugins/sources/local.d.ts +20 -0
  327. package/dist/plugins/sources/local.js +32 -0
  328. package/dist/plugins/sources/npm.d.ts +18 -0
  329. package/dist/plugins/sources/npm.js +82 -0
  330. package/dist/shared/llm/retry.d.ts +5 -2
  331. package/dist/shared/llm/retry.js +7 -3
  332. package/dist/shared/prompt-cache-latch.d.ts +41 -0
  333. package/dist/shared/prompt-cache-latch.js +63 -0
  334. package/dist/shared/retry-engine.d.ts +77 -0
  335. package/dist/shared/retry-engine.js +194 -0
  336. package/dist/workers/daemon.d.ts +8 -0
  337. package/dist/workers/daemon.js +13 -0
  338. package/dist/workers/quality-daemon/ci-monitor.d.ts +55 -0
  339. package/dist/workers/quality-daemon/ci-monitor.js +147 -0
  340. package/dist/workers/quality-daemon/coverage-delta.d.ts +72 -0
  341. package/dist/workers/quality-daemon/coverage-delta.js +135 -0
  342. package/dist/workers/quality-daemon/git-watcher.d.ts +51 -0
  343. package/dist/workers/quality-daemon/git-watcher.js +209 -0
  344. package/dist/workers/quality-daemon/index.d.ts +119 -0
  345. package/dist/workers/quality-daemon/index.js +343 -0
  346. package/dist/workers/quality-daemon/nightly-consolidation.d.ts +74 -0
  347. package/dist/workers/quality-daemon/nightly-consolidation.js +136 -0
  348. package/dist/workers/quality-daemon/notification-service.d.ts +67 -0
  349. package/dist/workers/quality-daemon/notification-service.js +178 -0
  350. package/dist/workers/quality-daemon/persistent-memory.d.ts +31 -0
  351. package/dist/workers/quality-daemon/persistent-memory.js +30 -0
  352. package/dist/workers/quality-daemon/priority-queue.d.ts +97 -0
  353. package/dist/workers/quality-daemon/priority-queue.js +126 -0
  354. package/dist/workers/quality-daemon/test-suggester.d.ts +50 -0
  355. package/dist/workers/quality-daemon/test-suggester.js +121 -0
  356. package/dist/workers/worker-manager.js +2 -1
  357. package/package.json +1 -1
  358. package/dist/mcp/server.d.ts +0 -46
  359. package/dist/mcp/server.js +0 -802
@@ -0,0 +1,2 @@
1
+ if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.9.0");process.exit(0)}
2
+ import{a,b,c}from"./chunk-6SVX4DJC.js";import"./chunk-B6LLWYQ6.js";import"./chunk-72WOAVK6.js";import"./chunk-WGMPEW2T.js";import"./chunk-JZSDOIXA.js";import"./chunk-4I2IOUS4.js";export{a as AgentBoosterAdapter,b as createAgentBoosterAdapter,c as createAgentBoosterAdapterSync};
@@ -0,0 +1,2 @@
1
+ if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.9.0");process.exit(0)}
2
+ import{a as x}from"./chunk-3JPRUND5.js";import{c as f}from"./chunk-4VUPRTVX.js";import"./chunk-4I2IOUS4.js";x();import{createRequire as w}from"module";var S=f.create("agent-booster-wasm"),t={JavaScript:0,TypeScript:1,Python:2,Rust:3,Go:4,Java:5,C:6,Cpp:7},l={ExactReplace:0,FuzzyReplace:1,InsertAfter:2,InsertBefore:3,Append:4},v={0:"JavaScript",1:"TypeScript",2:"Python",3:"Rust",4:"Go",5:"Java",6:"C",7:"Cpp"},a=null,u=null,p=null;async function g(){if(a)return!0;if(p)return!1;try{if(a=w(import.meta.url)("./agent_booster_wasm.js"),!a)throw new Error("WASM module loaded but is null");return u=new a.AgentBoosterWasm,!0}catch(e){return p=e,console.warn("[AgentBoosterWASM] Failed to load WASM module:",e),!1}}function A(e){return{".js":t.JavaScript,".mjs":t.JavaScript,".cjs":t.JavaScript,".jsx":t.JavaScript,".ts":t.TypeScript,".tsx":t.TypeScript,".mts":t.TypeScript,".cts":t.TypeScript,".py":t.Python,".rs":t.Rust,".go":t.Go,".java":t.Java,".c":t.C,".h":t.C,".cpp":t.Cpp,".cc":t.Cpp,".cxx":t.Cpp,".hpp":t.Cpp}[e.toLowerCase()]??t.JavaScript}var M=[{name:"var-to-const",detect:(e,r)=>e.includes("var ")&&r.includes("const "),apply:(e,r)=>e.replace(/\bvar\s+/g,"const ")},{name:"var-to-let",detect:(e,r)=>e.includes("var ")&&r.includes("let "),apply:(e,r)=>e.replace(/\bvar\s+/g,"let ")},{name:"add-types-function",detect:(e,r)=>e.includes("function")&&!e.includes(":")&&r.includes(":"),apply:(e,r)=>r},{name:"async-wrapper",detect:(e,r)=>!e.includes("async")&&r.includes("async")&&r.includes("await"),apply:(e,r)=>r},{name:"try-catch-wrapper",detect:(e,r)=>!e.includes("try {")&&r.includes("try {"),apply:(e,r)=>r},{name:"null-check",detect:(e,r)=>!e.includes("if (!")&&!e.includes("if (!")&&(r.includes("if (!")||r.includes("?.")),apply:(e,r)=>r},{name:"test-assertion",detect:(e,r)=>e.includes("test(")&&!e.includes("expect(")&&r.includes("expect("),apply:(e,r)=>r}];function y(e,r){for(let n of M)if(n.detect(e,r))try{return{success:!0,code:n.apply(e,r),pattern:n.name}}catch(s){S.debug("Pattern transform failed, trying next",{pattern:n.name,error:s instanceof Error?s.message:String(s)});continue}return{success:!1,code:r}}async function b(e,r,n,s={}){let o=performance.now(),{confidenceThreshold:T=.5,allowFallback:d=!0}=s;if(!e.trim())return{success:!0,mergedCode:r,confidence:1,strategy:l.Append,syntaxValid:!0,source:"fallback",latencyMs:performance.now()-o};if(await g()&&u&&a)try{let c=a.WasmLanguage[v[n]],i=u.apply_edit(e,r,c);return{success:!0,mergedCode:i.merged_code,confidence:i.confidence,strategy:i.strategy,syntaxValid:i.syntax_valid,source:"wasm",latencyMs:performance.now()-o}}catch(c){let i=c;if(d){let m=y(e,r);if(m.success)return{success:!0,mergedCode:m.code,confidence:.7,strategy:l.FuzzyReplace,syntaxValid:!0,source:"pattern",latencyMs:performance.now()-o}}return{success:!1,mergedCode:r,confidence:0,strategy:l.Append,syntaxValid:!1,source:"fallback",latencyMs:performance.now()-o,error:i.message}}if(d){let c=y(e,r);return{success:c.success,mergedCode:c.code,confidence:c.success?.7:0,strategy:l.FuzzyReplace,syntaxValid:!0,source:"pattern",latencyMs:performance.now()-o}}return{success:!1,mergedCode:r,confidence:0,strategy:l.Append,syntaxValid:!1,source:"fallback",latencyMs:performance.now()-o,error:p?.message??"WASM not available"}}async function W(e,r={}){return Promise.all(e.map(({original:n,edit:s,language:o})=>b(n,s,o,r)))}async function C(){return g()}async function L(){return await g()&&a?a.AgentBoosterWasm.version():"unavailable"}async function R(){if(await g(),u&&a)try{u.apply_edit("function x() {}","function x() {}",a.WasmLanguage.JavaScript)}catch(e){console.debug("[AgentBoosterWASM] Warmup error:",e instanceof Error?e.message:e)}}var _={transform:b,batchTransform:W,isWasmAvailable:C,getVersion:L,warmup:R,Language:t,MergeStrategy:l,languageFromExtension:A};export{t as Language,l as MergeStrategy,W as batchTransform,_ as default,L as getVersion,C as isWasmAvailable,A as languageFromExtension,b as transform,R as warmup};
@@ -0,0 +1,33 @@
1
+ if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.9.0");process.exit(0)}
2
+ import{b as p}from"./chunk-RTGGL7D7.js";import{a as g}from"./chunk-YANUP2RO.js";import"./chunk-WGMPEW2T.js";import"./chunk-4I2IOUS4.js";import s from"chalk";var l=class{name="agent";description="Manage QE agents";cleanupAndExit;ensureInitialized;constructor(n,t){this.cleanupAndExit=n,this.ensureInitialized=t}register(n,t){let a=n.command("agent").description(this.description);a.command("list").description("List all agents").option("-d, --domain <domain>","Filter by domain").option("-s, --status <status>","Filter by status").action(async e=>{await this.executeList(e,t)}),a.command("spawn <domain>").description("Spawn an agent in a domain").option("-t, --type <type>","Agent type","worker").option("-c, --capabilities <caps>","Comma-separated capabilities","general").option("--no-progress","Disable progress indicator").action(async(e,o)=>{await this.executeSpawn(e,o,t)})}async executeList(n,t){if(await this.ensureInitialized())try{let a=n.domain?t.queen.getAgentsByDomain(n.domain):t.queen.listAllAgents();if(n.status&&(a=a.filter(e=>e.status===n.status)),console.log(s.blue(`
3
+ Agents (${a.length})
4
+ `)),a.length===0)console.log(s.gray(" No agents found"));else{let e=new Map;for(let i of a)e.has(i.domain)||e.set(i.domain,[]),e.get(i.domain).push(i);let o=Array.from(e.entries());for(let[i,m]of o){console.log(s.cyan(` ${i}:`));for(let r of m)console.log(` ${r.id}`),console.log(` Type: ${r.type}`),console.log(` Status: ${g(r.status)}`),r.startedAt&&console.log(s.gray(` Started: ${r.startedAt.toISOString()}`));console.log("")}}}catch(a){console.error(s.red(`
5
+ Failed to list agents:`),a),await this.cleanupAndExit(1)}}async executeSpawn(n,t,a){if(await this.ensureInitialized())try{let e=t.capabilities.split(",");console.log(s.blue(`
6
+ Spawning agent in ${n}...
7
+ `));let o=t.progress!==!1?p(`Spawning ${t.type} agent`):null,i=await a.queen.requestAgentSpawn(n,t.type,e);o&&(i.success?o.succeed("Agent spawned successfully"):o.fail("Failed to spawn agent")),i.success?(console.log(s.cyan(` ID: ${i.value}`)),console.log(s.gray(` Domain: ${n}`)),console.log(s.gray(` Type: ${t.type}`)),console.log(s.gray(` Capabilities: ${e.join(", ")}`))):console.log(s.red(` Error: ${i.error.message}`)),console.log("")}catch(e){console.error(s.red(`
8
+ Failed to spawn agent:`),e),await this.cleanupAndExit(1)}}getHelp(){return`
9
+ Manage QE agents including listing and spawning.
10
+
11
+ Usage:
12
+ aqe agent <command> [options]
13
+
14
+ Commands:
15
+ list List all agents
16
+ spawn <domain> Spawn an agent in a domain
17
+
18
+ List Options:
19
+ -d, --domain <domain> Filter by domain
20
+ -s, --status <status> Filter by status
21
+
22
+ Spawn Options:
23
+ -t, --type <type> Agent type (default: worker)
24
+ -c, --capabilities <caps> Comma-separated capabilities (default: general)
25
+ --no-progress Disable progress indicator
26
+
27
+ Examples:
28
+ aqe agent list
29
+ aqe agent list --domain test-generation
30
+ aqe agent list --status running
31
+ aqe agent spawn test-generation --type worker
32
+ aqe agent spawn coverage-analysis --capabilities analysis,reporting
33
+ `}};function b(c,n){return new l(c,n)}export{l as AgentHandler,b as createAgentHandler};
@@ -0,0 +1,2 @@
1
+ if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.9.0");process.exit(0)}
2
+ import{a,b,c,d}from"./chunk-BXAXGEFC.js";import"./chunk-GKNNSCLC.js";import"./chunk-N4TL73TH.js";import"./chunk-YPFOCNOE.js";import"./chunk-VSVXUTJN.js";import"./chunk-XO6PVK2P.js";import"./chunk-X5IJGWYG.js";import"./chunk-J3KWWR6Z.js";import"./chunk-EHDQJQ6Y.js";import"./chunk-MV6CMOJQ.js";import"./chunk-JRYGQO2W.js";import"./chunk-4YS3IJ45.js";import"./chunk-YW2THB5Q.js";import"./chunk-3ZOONQG6.js";import"./chunk-SUSEVMZT.js";import"./chunk-JJO7Y4H3.js";import"./chunk-N2NS2PHA.js";import"./chunk-3JPRUND5.js";import"./chunk-4VUPRTVX.js";import"./chunk-WGMPEW2T.js";import"./chunk-JZSDOIXA.js";import"./chunk-263XS447.js";import"./chunk-MDUHYUHF.js";import"./chunk-GAOJV3OX.js";import"./chunk-62ADTHV7.js";import"./chunk-DRT3WKQW.js";import"./chunk-UFUVUO3J.js";import"./chunk-7VDBAVTY.js";import"./chunk-B36CDR4U.js";import"./chunk-2I7J3O6V.js";import"./chunk-4I2IOUS4.js";export{b as AQELearningEngine,a as DEFAULT_ENGINE_CONFIG,c as createAQELearningEngine,d as createDefaultLearningEngine};
@@ -0,0 +1,3 @@
1
+ if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.9.0");process.exit(0)}
2
+ import{d as c,e as u,f as h,g as m}from"./chunk-5T2ZQWKF.js";import{f as s,o as p}from"./chunk-JJO7Y4H3.js";import"./chunk-N2NS2PHA.js";import"./chunk-3JPRUND5.js";import"./chunk-4VUPRTVX.js";import"./chunk-WGMPEW2T.js";import"./chunk-JZSDOIXA.js";import"./chunk-263XS447.js";import{p as l,q as d}from"./chunk-MDUHYUHF.js";import"./chunk-GAOJV3OX.js";import"./chunk-62ADTHV7.js";import"./chunk-DRT3WKQW.js";import"./chunk-UFUVUO3J.js";import"./chunk-7VDBAVTY.js";import"./chunk-B36CDR4U.js";import"./chunk-2I7J3O6V.js";import{g as f}from"./chunk-4I2IOUS4.js";import{Command as g}from"commander";import a from"chalk";p();import{existsSync as y}from"node:fs";import b from"node:path";function C(n,i){let t=[];t.push(a.bold("Witness Chain Audit Verification")),t.push("");let e=i?a.green("ENABLED"):a.yellow("DISABLED");t.push(` Feature Flag: ${e}`),t.push(` Chain Length: ${n.length} receipts`);let r=n.valid?a.green("VALID"):a.red("BROKEN");return t.push(` Integrity: ${r}`),n.length>0&&t.push(` Last Hash: ${n.lastHash.slice(0,16)}...`),!n.valid&&n.brokenAt>=0&&(t.push(""),t.push(a.red(` Break detected at index ${n.brokenAt}`)),t.push(a.red(` ${n.message}`))),t.push(""),t.join(`
3
+ `)}function x(){try{let n=s(),i=b.join(n,".agentic-qe","memory.db");if(!y(i))return null;let t=(d(),f(l)),e=new t(i),r=c(e),o=h(r);return e.close(),o}catch{return null}}async function A(n){let i=m(),e=(x()??u()).verifyChain(),r={featureEnabled:i,chainLength:e.length,integrity:e.valid,brokenAt:e.brokenAt,lastHash:e.lastHash,message:e.message};return n.format==="json"?console.log(JSON.stringify(r,null,2)):console.log(C(e,i)),r}function v(n,i,t){let e=new g("audit").description("Witness chain audit trail management");return e.command("verify").description("Verify witness chain integrity").option("-F, --format <format>","Output format (json|text)","text").action(async r=>{try{await A({format:r.format}),await i(0)}catch(o){console.error("Failed to verify witness chain:",o),await i(1)}}),e}export{v as createAuditCommand,C as formatVerificationText,A as handleAuditVerify};
@@ -0,0 +1,2 @@
1
+ if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.9.0");process.exit(0)}
2
+ import{a,b,c,d,e,f}from"./chunk-NZ2VCPN4.js";import"./chunk-24FKIJNC.js";import"./chunk-SUSEVMZT.js";import"./chunk-JJO7Y4H3.js";import"./chunk-N2NS2PHA.js";import"./chunk-3JPRUND5.js";import"./chunk-4VUPRTVX.js";import"./chunk-WGMPEW2T.js";import"./chunk-JZSDOIXA.js";import"./chunk-263XS447.js";import"./chunk-MDUHYUHF.js";import"./chunk-GAOJV3OX.js";import"./chunk-62ADTHV7.js";import"./chunk-DRT3WKQW.js";import"./chunk-UFUVUO3J.js";import"./chunk-7VDBAVTY.js";import"./chunk-B36CDR4U.js";import"./chunk-2I7J3O6V.js";import"./chunk-4I2IOUS4.js";export{f as MCPToolBase,e as defaultToolLogger,d as getMemoryBackend,b as getSharedMemoryBackend,a as registerRvfResetFn,c as resetSharedMemoryBackend};
@@ -0,0 +1,2 @@
1
+ if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.9.0");process.exit(0)}
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,q as p}from"./chunk-MDUHYUHF.js";import"./chunk-4I2IOUS4.js";p();export{i as DotProductAttention,h as FlashAttention,k as HyperbolicAttention,l as LinearAttention,m as MoEAttention,j as MultiHeadAttention,b as RuvectorLayer,n as SonaEngine,c as TensorCompress,a as default,d as differentiableSearch,f as getCompressionLevel,e as hierarchicalForward,g as init,o as pipeline};
@@ -0,0 +1,68 @@
1
+ if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.9.0");process.exit(0)}
2
+ import{a as $,b as M,c as L,d as v,e as H,f as k,g as F,h as _,i as P,j as G,k as V,l as ce,m as q,n as Q,o as de,p as Y,q as j,r as W,s as U}from"./chunk-IAV2JMIX.js";import{b as ae}from"./chunk-EHDQJQ6Y.js";import{a as se,b as ie,c as le,d as O}from"./chunk-FIA6X7UL.js";import"./chunk-JJO7Y4H3.js";import"./chunk-N2NS2PHA.js";import"./chunk-3JPRUND5.js";import"./chunk-4VUPRTVX.js";import{b as N,d as Be}from"./chunk-WGMPEW2T.js";import"./chunk-JZSDOIXA.js";import{a as S,b as Ie}from"./chunk-263XS447.js";import"./chunk-MDUHYUHF.js";import"./chunk-GAOJV3OX.js";import"./chunk-62ADTHV7.js";import"./chunk-DRT3WKQW.js";import"./chunk-UFUVUO3J.js";import"./chunk-7VDBAVTY.js";import"./chunk-B36CDR4U.js";import"./chunk-2I7J3O6V.js";import"./chunk-4I2IOUS4.js";import T from"path";import r from"chalk";Ie();Be();import{existsSync as z,mkdirSync as Ne,writeFileSync as Oe,readFileSync as X}from"fs";import{join as E,resolve as Z}from"path";var ke={rl_q_values:"includeQValues",dream_insights:"includeDreamInsights",dream_cycles:"includeDreamInsights",witness_chain:"includeWitnessChain",vectors:"includeVectors"};function qe(n,t){let o=ke[n.tableName];return!(o&&t[o]===!1)}var Te=1e4;function Ae(n,t,o,e){if(!qe(t,o))return Q(E(e,t.fileName),[]),{count:0,rows:[]};let[s,i]=t.domainColumn?q(o.domains,t.domainColumn):[void 0,[]];if(G(n,t.tableName,s,i)>=Te){let d=t.blobColumns,f=d&&d.length>0?p=>k(p,d):void 0;return{count:de(E(e,t.fileName),ce(n,t.tableName,s,i),f)}}let a=V(n,t.tableName,s,i);return t.blobColumns&&t.blobColumns.length>0&&(a=a.map(d=>k(d,t.blobColumns))),Q(E(e,t.fileName),a),{count:a.length,rows:a}}function me(n){let t=[];for(let o of v){let e=E(n,o.fileName);z(e)?t.push(_(X(e,"utf-8"))):t.push(_(""))}return _(t.join(":"))}function fe(n,t,o="memory.db"){let e=Z(t.outputPath);z(e)||Ne(e,{recursive:!0});let s=0,i={},c=new Set;for(let u of v){let p=Ae(n,u,t,e);if(i[u.tableName]=p.count,s+=p.count,u.tableName==="qe_patterns"){if(p.rows)for(let l of p.rows)l.qe_domain&&c.add(l.qe_domain);else if(p.count>0){let[l,h]=u.domainColumn?q(t.domains,u.domainColumn):[void 0,[]],b=`SELECT DISTINCT qe_domain FROM qe_patterns ${l?`WHERE ${l} AND qe_domain IS NOT NULL`:"WHERE qe_domain IS NOT NULL"}`;try{let y=n.prepare(b).all(...h||[]);for(let R of y)c.add(R.qe_domain)}catch{}}}}let a=t.includeVectors!==!1?G(n,"vectors"):0,d=me(e),f={version:"3.0",exportedAt:new Date().toISOString(),sourceDb:o,stats:{patternCount:i.qe_patterns||0,vectorCount:a,qValueCount:i.rl_q_values||0,dreamInsightCount:i.dream_insights||0,witnessChainLength:i.witness_chain||0,totalRecords:s},domains:[...c].sort(),checksum:d,tableRecordCounts:i};return Oe(E(e,"manifest.json"),JSON.stringify(f,null,2),"utf-8"),f}var De=new Set(["qe_patterns","rl_q_values","dream_insights","witness_chain"]);function $e(n){return n==="1.0"?v.filter(t=>De.has(t.tableName)):n==="3.0"?v:(console.warn(`[brain-import] Unknown manifest version '${n}'. Attempting full import \u2014 some files may be missing.`),v)}function ue(n,t,o){let e=Z(t),s=E(e,"manifest.json");if(!z(s))throw new Error(`Manifest not found at ${s}`);let i=N(X(s,"utf-8")),c=me(e);if(c!==i.checksum)throw new Error(`Checksum mismatch: expected ${i.checksum}, got ${c}. The export may have been tampered with or corrupted.`);let a=$e(i.version);if(o.dryRun){let l=0;for(let h of a){let m=Y(E(e,h.fileName),N);l+=m.length}return{imported:l,skipped:0,conflicts:0}}U(n);let d=0,f=0,u=0;return n.transaction(()=>{for(let l of a){let h=E(e,l.fileName),m=Y(h,N);l.blobColumns&&l.blobColumns.length>0&&(m=m.map(b=>F(b,l.blobColumns)));for(let b of m){let y;if(l.dedupColumns&&l.dedupColumns.length>0)y=W(n,l.tableName,b,l.dedupColumns);else{let R=$[l.tableName]||"id",C=L[l.tableName],x=M[l.tableName];y=j(n,l.tableName,b,R,o.mergeStrategy,C,x)}d+=y.imported,f+=y.skipped,u+=y.conflicts}}})(),{imported:d,skipped:f,conflicts:u}}function pe(n){let t=Z(n),o=E(t,"manifest.json");if(!z(o))throw new Error(`Manifest not found at ${o}`);return N(X(o,"utf-8"))}import{existsSync as K,statSync as Me,unlinkSync as ge,writeFileSync as Le}from"fs";import{resolve as ee}from"path";function be(n,t,o="memory.db"){if(!O())throw new Error("@ruvector/rvf-node is not available. Install it or use --format jsonl instead.");let e=ee(t.outputPath),s=t.dimension??384;K(e)&&ge(e);let i=`${e}.idmap.json`;K(i)&&ge(i);let c=se(e,s);try{let a={},d=new Set,f=0;for(let w of v){let[g,oe]=w.domainColumn?q(t.domains,w.domainColumn):[void 0,[]],B=V(n,w.tableName,g,oe);if(w.tableName==="qe_patterns")for(let D of B)D.qe_domain&&d.add(D.qe_domain);let J=H[w.tableName];J&&J.length>0&&(B=B.map(D=>k(D,J))),a[w.tableName]=B,f+=B.length}let u=0,p=[];if(P(n,"qe_pattern_embeddings")){let w=n.prepare("SELECT pattern_id, embedding, dimension FROM qe_pattern_embeddings").all();for(let g of w)g.embedding&&g.dimension===s&&p.push({id:`pe:${g.pattern_id}`,vector:new Float32Array(g.embedding.buffer,g.embedding.byteOffset,s),metadata:{tableName:"qe_pattern_embeddings"}})}if(P(n,"captured_experiences")){let w=n.prepare("SELECT id, embedding, embedding_dimension, domain, quality FROM captured_experiences WHERE embedding IS NOT NULL").all();for(let g of w)g.embedding_dimension===s&&p.push({id:`exp:${g.id}`,vector:new Float32Array(g.embedding.buffer,g.embedding.byteOffset,s),metadata:{tableName:"captured_experiences",domain:g.domain,confidence:g.quality}})}if(P(n,"sona_patterns")){let w=n.prepare("SELECT id, state_embedding, domain, confidence FROM sona_patterns WHERE state_embedding IS NOT NULL").all();for(let g of w)g.state_embedding.byteLength/4===s&&p.push({id:`sona:${g.id}`,vector:new Float32Array(g.state_embedding.buffer,g.state_embedding.byteOffset,s),metadata:{tableName:"sona_patterns",domain:g.domain,confidence:g.confidence}})}p.length>0&&(u=c.ingest(p).accepted);let l={version:"3.0",format:"rvf",exportedAt:new Date().toISOString(),sourceDb:o,domains:[...d].sort(),tables:a},h=JSON.stringify(l),m=_(h),b=Buffer.from(h);c.embedKernel(b);let y=t.sign?c.sign(b)??void 0:void 0,R=y?t.signerKeyId??"default":void 0,C=c.fileId(),x=C?{fileId:C,parentId:c.parentId(),lineageDepth:c.lineageDepth()}:void 0,I=c.status(),A={version:"3.0",format:"rvf",exportedAt:l.exportedAt,sourceDb:o,stats:{patternCount:(a.qe_patterns||[]).length,embeddingCount:u,qValueCount:(a.rl_q_values||[]).length,dreamInsightCount:(a.dream_insights||[]).length,witnessChainLength:(a.witness_chain||[]).length,totalRecords:f},domains:l.domains,checksum:m,rvfStatus:{totalVectors:I.totalVectors,totalSegments:I.totalSegments,fileSizeBytes:I.fileSizeBytes},...y?{signature:y,signerKeyId:R}:{},...x?{lineage:x}:{}};if(y)try{c.freeze()}catch{}let Se=`${e}.manifest.json`;return Le(Se,JSON.stringify(A,null,2),"utf-8"),A}finally{c.close()}}var Fe={patterns:"qe_patterns",qValues:"rl_q_values",dreamInsights:"dream_insights",witnessChain:"witness_chain"};function ye(n,t,o){if(!O())throw new Error("@ruvector/rvf-node is not available. Install it or use JSONL format.");let e=ee(t);if(!K(e))throw new Error(`RVF file not found: ${e}`);let s=ie(e);try{let i=s.verifyWitness();if(!i.valid&&(i.totalEntries>0||i.errors.length>0)){let m=i.errors.length>0?i.errors.join("; "):"unknown integrity error";throw new Error(`RVF witness verification failed: ${m}`)}let c=s.extractKernel();if(!c||!c.image)throw new Error("No brain data found in RVF file (missing kernel segment)");let a;try{a=JSON.parse(c.image.toString("utf-8"))}catch(m){throw new Error(`Failed to parse brain kernel data as JSON: ${m instanceof Error?m.message:m}`)}if(o.dryRun){let m=0;if(a.tables)for(let b of Object.values(a.tables))m+=b?.length??0;else m=(a.patterns?.length??0)+(a.qValues?.length??0)+(a.dreamInsights?.length??0)+(a.witnessChain?.length??0);return{imported:m,skipped:0,conflicts:0,embeddingsRestored:0}}U(n);let d=0,f=0,u=0,p=0,l={};if(a.tables)Object.assign(l,a.tables);else for(let[m,b]of Object.entries(Fe)){let y=a[m];Array.isArray(y)&&(l[b]=y)}if(n.transaction(()=>{for(let m of v){let b=l[m.tableName];if(!b||!Array.isArray(b))continue;let y=H[m.tableName];if(y&&y.length>0){b=b.map(R=>F(R,y));for(let R of b)for(let C of y)R[C]instanceof Buffer&&p++}for(let R of b){let C;if(m.dedupColumns&&m.dedupColumns.length>0)C=W(n,m.tableName,R,m.dedupColumns);else{let x=$[m.tableName]||"id",I=L[m.tableName],A=M[m.tableName];C=j(n,m.tableName,R,x,o.mergeStrategy,I,A)}d+=C.imported,f+=C.skipped,u+=C.conflicts}}})(),u>0)try{s.compact()}catch{}return{imported:d,skipped:f,conflicts:u,embeddingsRestored:p}}finally{s.close()}}function he(n){if(!O())throw new Error("@ruvector/rvf-node is not available.");let t=ee(n);if(!K(t))throw new Error(`RVF file not found: ${t}`);let o=le(t);try{let e=o.extractKernel();if(!e||!e.image)throw new Error("No brain data found in RVF file");let s=e.image.toString("utf-8"),i;try{i=JSON.parse(s)}catch(h){throw new Error(`Failed to parse brain kernel data as JSON: ${h instanceof Error?h.message:h}`)}let c=o.status(),a=Me(t).size,d=i.tables,f=d?d.qe_patterns?.length??0:i.patterns?.length??0,u=d?d.rl_q_values?.length??0:i.qValues?.length??0,p=d?d.dream_insights?.length??0:i.dreamInsights?.length??0,l=d?d.witness_chain?.length??0:i.witnessChain?.length??0;return{version:"3.0",format:"rvf",exportedAt:i.exportedAt??"unknown",sourceDb:i.sourceDb??"unknown",stats:{patternCount:f,embeddingCount:c.totalVectors,qValueCount:u,dreamInsightCount:p,witnessChainLength:l},domains:i.domains??[],checksum:_(s),rvfStatus:{totalVectors:c.totalVectors,totalSegments:c.totalSegments,fileSizeBytes:a}}}finally{o.close()}}function te(){return O()}function we(n,t){if(!n.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='qe_patterns'").get())return{created:0,skipped:0};n.exec(`
3
+ CREATE TEMP TABLE IF NOT EXISTS _covered_patterns (
4
+ pattern_id TEXT PRIMARY KEY
5
+ )
6
+ `),n.exec("DELETE FROM _covered_patterns"),n.exec(`
7
+ INSERT INTO _covered_patterns (pattern_id)
8
+ SELECT DISTINCT json_extract(action_data, '$.patternId')
9
+ FROM witness_chain
10
+ WHERE action_type = 'PATTERN_CREATE'
11
+ AND json_extract(action_data, '$.patternId') IS NOT NULL
12
+ `),n.exec(`
13
+ INSERT OR IGNORE INTO _covered_patterns (pattern_id)
14
+ SELECT DISTINCT json_extract(action_data, '$.pattern_id')
15
+ FROM witness_chain
16
+ WHERE action_type = 'PATTERN_CREATE'
17
+ AND json_extract(action_data, '$.pattern_id') IS NOT NULL
18
+ `);let e=n.prepare(`SELECT p.id, p.pattern_type, p.qe_domain, p.name, p.created_at
19
+ FROM qe_patterns p
20
+ LEFT JOIN _covered_patterns c ON p.id = c.pattern_id
21
+ WHERE c.pattern_id IS NULL
22
+ ORDER BY p.created_at ASC`).all(),i=n.prepare("SELECT COUNT(*) as count FROM qe_patterns").get().count-e.length,c=0;for(let a of e)t.append("PATTERN_CREATE",{patternId:a.id,patternType:a.pattern_type,qeDomain:a.qe_domain,name:a.name,originalCreatedAt:a.created_at,backfilled:!0},"system:backfill"),c++;return n.exec("DROP TABLE IF EXISTS _covered_patterns"),{created:c,skipped:i}}async function Re(n,t){if(Pe(t.format)==="rvf"){let s=S(n,{readonly:!0});try{return be(s,{outputPath:t.outputPath,domains:t.domains},n)}finally{s.close()}}let e=S(n,{readonly:!0});try{return fe(e,t,n)}finally{e.close()}}async function Ce(n,t,o){if(_e(t,o.format)==="rvf"){let i=S(n);try{return ye(i,t,{mergeStrategy:o.mergeStrategy,dryRun:o.dryRun})}finally{i.close()}}let s=S(n);try{return ue(s,t,o)}finally{s.close()}}async function ve(n,t){return _e(n,t)==="rvf"?he(n):pe(n)}async function Ee(n){let t=S(n);try{let o=ae(t);return await o.initialize(),we(t,o)}finally{t.close()}}function Pe(n){if(n==="jsonl")return"jsonl";if(n==="rvf"){if(!te())throw new Error("RVF format requested but @ruvector/rvf-node is not available on this platform. Use --format jsonl instead.");return"rvf"}return te()?"rvf":"jsonl"}function _e(n,t){return t==="rvf"?"rvf":t==="jsonl"?"jsonl":n.endsWith(".rvf")?"rvf":"jsonl"}var re=class{name="brain";description="Export, import, and inspect QE brain state";cleanupAndExit;ensureInitialized;constructor(t,o){this.cleanupAndExit=t,this.ensureInitialized=o}register(t,o){let e=t.command("brain").description(this.description);e.command("export").description("Export brain state to a portable directory").requiredOption("-o, --output <path>","Output directory path").option("--format <format>","Export format: rvf (default) or jsonl","rvf").option("--db <path>","Source database path").action(async s=>{await this.executeExport(s)}),e.command("import").description("Import brain state from an export directory").requiredOption("-i, --input <path>","Path to brain export directory").option("--strategy <strategy>","Merge strategy","skip-conflicts").option("--dry-run","Preview import without writing",!1).option("--db <path>","Target database path").action(async s=>{await this.executeImport(s)}),e.command("info").description("Show manifest info for a brain export").requiredOption("-i, --input <path>","Path to brain export directory").action(async s=>{await this.executeInfo(s)}),e.command("witness-backfill").description("Create witness chain entries for patterns that predate the witness chain").option("--db <path>","Database path").action(async s=>{await this.executeWitnessBackfill(s)})}async executeExport(t){try{console.log(r.blue(`
23
+ Exporting brain state (format: ${t.format})...
24
+ `));let o=await ne(t.db),e=await Re(o,{outputPath:T.resolve(t.output),format:t.format});if(console.log(r.green(" Export complete.")),console.log(` Format: ${r.cyan("format"in e?e.format??"jsonl":"jsonl")}`),console.log(` Patterns: ${r.cyan(e.stats.patternCount)}`),"embeddingCount"in e.stats?console.log(` Vectors: ${r.cyan(e.stats.embeddingCount)}`):"vectorCount"in e.stats&&console.log(` Vectors: ${r.cyan(e.stats.vectorCount)}`),"rvfStatus"in e){let s=e.rvfStatus;console.log(` RVF Size: ${r.cyan(xe(s.fileSizeBytes))}`),console.log(` Segments: ${r.cyan(s.totalSegments)}`)}console.log(` Checksum: ${r.gray(e.checksum)}`),console.log(` Output: ${r.cyan(T.resolve(t.output))}`),console.log(""),await this.cleanupAndExit(0)}catch(o){console.error(r.red(`
25
+ Brain export failed:`),o),await this.cleanupAndExit(1)}}async executeImport(t){try{t.dryRun?console.log(r.yellow(`
26
+ Dry-run mode \u2014 no data will be written.
27
+ `)):console.log(r.blue(`
28
+ Importing brain state...
29
+ `));let o=await ne(t.db),e=await Ce(o,T.resolve(t.input),{mergeStrategy:t.strategy,dryRun:t.dryRun});console.log(r.green(" Import complete.")),console.log(` Imported: ${r.cyan(e.imported)}`),console.log(` Skipped: ${r.yellow(e.skipped)}`),console.log(` Conflicts: ${r.red(e.conflicts)}`),"embeddingsRestored"in e&&console.log(` Embeddings: ${r.cyan(e.embeddingsRestored)}`),console.log(""),await this.cleanupAndExit(0)}catch(o){console.error(r.red(`
30
+ Brain import failed:`),o),await this.cleanupAndExit(1)}}async executeInfo(t){try{console.log(r.blue(`
31
+ Brain Export Info
32
+ `));let o=T.resolve(t.input),e=await ve(o),s="format"in e?e.format??"jsonl":"jsonl";if(console.log(` Version: ${r.cyan(e.version)}`),console.log(` Format: ${r.cyan(s)}`),console.log(` Exported: ${r.cyan(e.exportedAt)}`),console.log(` Source DB: ${r.cyan(e.sourceDb)}`),console.log(r.blue(`
33
+ Learning Data:`)),console.log(` Patterns: ${r.cyan(e.stats.patternCount)}`),"qValueCount"in e.stats&&console.log(` Q-Values: ${r.cyan(e.stats.qValueCount)}`),"dreamInsightCount"in e.stats){let a=e.stats.dreamInsightCount,f=("tableRecordCounts"in e?e.tableRecordCounts:void 0)?.dream_cycles,u=f!==void 0?` (${f} cycles)`:"";console.log(` Dream Insights: ${r.cyan(a)}${r.gray(u)}`)}"witnessChainLength"in e.stats&&console.log(` Witness Chain: ${r.cyan(e.stats.witnessChainLength)} entries`),"embeddingCount"in e.stats?console.log(` Embeddings: ${r.cyan(e.stats.embeddingCount)}`):"vectorCount"in e.stats&&console.log(` Vectors: ${r.cyan(e.stats.vectorCount)}`);let i="tableRecordCounts"in e?e.tableRecordCounts:void 0;if(i){let a=Object.entries(i).filter(([d,f])=>f>0&&!["qe_patterns","rl_q_values","dream_insights","dream_cycles","witness_chain","vectors","qe_pattern_embeddings"].includes(d));if(a.length>0)for(let[d,f]of a){let p=`${d.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase())}:`.padEnd(15);console.log(` ${p}${r.cyan(f)}`)}}let c="totalRecords"in e.stats?e.stats.totalRecords:void 0;if(c!==void 0&&(console.log(r.blue(`
34
+ Summary:`)),console.log(` Total Records: ${r.cyan(c)}`)),"domains"in e&&Array.isArray(e.domains)&&e.domains.length>0&&(c||console.log(r.blue(`
35
+ Summary:`)),console.log(` Domains: ${r.cyan(e.domains.join(", "))}`)),"rvfStatus"in e){let a=e.rvfStatus;console.log(r.blue(`
36
+ RVF Details:`)),console.log(` File Size: ${r.cyan(xe(a.fileSizeBytes))}`),console.log(` Vectors: ${r.cyan(a.totalVectors)}`),console.log(` Segments: ${r.cyan(a.totalSegments)}`)}if("lineage"in e){let a=e.lineage;a&&(console.log(r.blue(`
37
+ Lineage:`)),console.log(` File ID: ${r.cyan(a.fileId)}`),console.log(` Parent ID: ${r.cyan(a.parentId??"none (root)")}`),console.log(` Depth: ${r.cyan(a.lineageDepth)}`))}if("signature"in e){let a=e.signature,d=e.signerKeyId;console.log(r.blue(`
38
+ Signature:`)),a?(console.log(` Status: ${r.green("Signed")}`),console.log(` Key ID: ${r.cyan(d??"unknown")}`),console.log(` Signature: ${r.gray(a.slice(0,32)+"...")}`)):console.log(` Status: ${r.yellow("Unsigned")}`)}console.log(`
39
+ Checksum: ${r.gray(e.checksum)}`),console.log(""),await this.cleanupAndExit(0)}catch(o){console.error(r.red(`
40
+ Failed to read brain info:`),o),await this.cleanupAndExit(1)}}async executeWitnessBackfill(t){try{console.log(r.blue(`
41
+ Running witness chain backfill...
42
+ `));let o=await ne(t.db),e=await Ee(o);console.log(r.green(" Backfill complete.")),console.log(` Created: ${r.cyan(e.created)} new witness entries`),console.log(` Skipped: ${r.cyan(e.skipped)} (already witnessed)`),console.log(""),await this.cleanupAndExit(0)}catch(o){console.error(r.red(`
43
+ Witness backfill failed:`),o),await this.cleanupAndExit(1)}}getHelp(){return`
44
+ Export, import, and inspect QE brain state.
45
+
46
+ Formats:
47
+ rvf \u2014 Single portable .rvf file (default, requires @ruvector/rvf-node)
48
+ jsonl \u2014 JSONL directory format (fallback when native not available)
49
+
50
+ Usage:
51
+ aqe brain export -o brain.rvf [--format rvf] [--db <path>]
52
+ aqe brain export -o ./brain-dir --format jsonl [--db <path>]
53
+ aqe brain import -i brain.rvf [--strategy skip-conflicts] [--dry-run] [--db <path>]
54
+ aqe brain info -i brain.rvf
55
+
56
+ Subcommands:
57
+ export Export brain state to a portable .rvf file or JSONL directory
58
+ import Import a brain export into the local database
59
+ info Show manifest metadata for an existing brain export
60
+
61
+ Examples:
62
+ aqe brain export -o .agentic-qe/brain.rvf
63
+ aqe brain export -o .agentic-qe/brain.rvf --format rvf
64
+ aqe brain export -o ./brain-export --format jsonl
65
+ aqe brain import -i .agentic-qe/brain.rvf --strategy latest-wins
66
+ aqe brain import -i .agentic-qe/brain.rvf --dry-run
67
+ aqe brain info -i .agentic-qe/brain.rvf
68
+ `}};async function ne(n){if(n)return n;let{findProjectRoot:t}=await import("./unified-memory-XYGENQUT.js");return T.join(t(),".agentic-qe","memory.db")}function xe(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}function it(n,t){return new re(n,t)}export{re as BrainHandler,it as createBrainHandler};
@@ -0,0 +1,7 @@
1
+ if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.9.0");process.exit(0)}
2
+ import"./chunk-4I2IOUS4.js";var f=class{language;constructor(e="typescript"){this.language=e}enumerate(e,s){let r=[],n=e.split(`
3
+ `),l=!1;for(let i=0;i<n.length;i++){let d=n[i],t=d.trim(),c=i+1,u=d.length-d.trimStart().length+1;if(l){t.includes("*/")&&(l=!1);continue}if(t.startsWith("/*")){l=!t.includes("*/");continue}if(t.startsWith("//"))continue;if(/^\s*if\s*\(/.test(d)&&(this.findMatchingElse(n,i)||r.push({file:s,line:c,column:u,language:this.language,construct:"if-without-else",triggerCondition:"when condition is false",currentHandling:"falls through \u2014 no else branch",suggestedGuard:"Add else branch or document why falsy path is safe",severity:"medium"})),/^\s*switch\s*\(/.test(d)){let a=this.extractBlock(n,i);if(a&&!a.includes("default:")&&!a.includes("default :")&&r.push({file:s,line:c,column:u,language:this.language,construct:"switch-no-default",triggerCondition:"when value matches no case",currentHandling:"falls through \u2014 no default case",suggestedGuard:"Add default case with error handling or exhaustive check",severity:"high"}),a){let g=a.match(/case\s+[^:]+:/g)||[],h=a.match(/\b(break|return|throw|continue)\b/g)||[];g.length>0&&h.length<g.length&&r.push({file:s,line:c,column:u,language:this.language,construct:"switch-missing-break",triggerCondition:"when case falls through to next case",currentHandling:"fall-through \u2014 may execute unintended cases",suggestedGuard:"Add break/return to each case or add explicit // falls through comment",severity:"medium"})}}if(/\bcatch\s*\(/.test(t)||/\bcatch\s*\{/.test(t)){let a=this.extractBlock(n,i);if(a!==null){let g=a.replace(/[{}]/g,"").trim();(g.length===0||/^\s*\/\//.test(g))&&r.push({file:s,line:c,column:u,language:this.language,construct:"try-empty-catch",triggerCondition:"when exception is thrown",currentHandling:"exception silently swallowed",suggestedGuard:"Log the error or rethrow with context",severity:"high"})}}if(/\btry\s*\{/.test(t)&&this.extractBlock(n,i)&&(n.slice(i,Math.min(i+30,n.length)).join(`
4
+ `).includes("finally")||r.push({file:s,line:c,column:u,language:this.language,construct:"try-no-finally",triggerCondition:"when cleanup is needed regardless of success/failure",currentHandling:"no finally block \u2014 cleanup may be skipped on exception",suggestedGuard:"Add finally block for resource cleanup if applicable",severity:"low"})),t.includes("?.")){let a=t.match(/(\w+(?:\.\w+)*)\?\./g)||[];for(let g of a)if(!t.includes("??")&&!t.includes("|| ")&&!t.includes("if")){r.push({file:s,line:c,column:u,language:this.language,construct:"optional-chaining-null-path",triggerCondition:`when ${g.replace("?.","")} is null/undefined`,currentHandling:"returns undefined \u2014 may propagate",suggestedGuard:"Add ?? fallback or explicit null check",severity:"low"});break}}if(t.includes("??")&&!t.includes("?.")&&r.push({file:s,line:c,column:u,language:this.language,construct:"nullish-coalescing-fallback",triggerCondition:"when left side is null/undefined",currentHandling:"uses fallback value",suggestedGuard:"Verify fallback value is appropriate for all null cases",severity:"low"}),/\.\s*then\s*\(/.test(t)&&!t.includes(".catch")&&!t.includes("await")){let a=n.slice(i,Math.min(i+5,n.length)).join(" ");!a.includes(".catch")&&!a.includes("try")&&r.push({file:s,line:c,column:u,language:this.language,construct:"promise-no-catch",triggerCondition:"when promise rejects",currentHandling:"unhandled rejection \u2014 may crash process",suggestedGuard:"Add .catch() handler or use try/catch with await",severity:"high"})}let p=["map","filter","reduce","forEach","find","some","every","flatMap"];for(let a of p)if(new RegExp(`\\.${a}\\s*\\(`).test(t)){let h=n.slice(Math.max(0,i-3),i).join(" ");if(!h.includes(".length")&&!h.includes("if (")&&!h.includes("?.")){r.push({file:s,line:c,column:u,language:this.language,construct:"array-callback-empty",triggerCondition:`when array is empty before .${a}()`,currentHandling:a==="reduce"?"may throw without initial value":"returns empty result \u2014 may cause downstream issues",suggestedGuard:a==="reduce"?"Provide initial value or check array length":"Check array length or handle empty result",severity:a==="reduce"?"high":"low"});break}}/\|\|\s*['"`\d]/.test(t)&&!t.includes("??")&&r.push({file:s,line:c,column:u,language:this.language,construct:"logical-or-falsy",triggerCondition:'when left side is falsy (0, "", false, null, undefined)',currentHandling:'uses fallback \u2014 may unintentionally override 0, "", or false',suggestedGuard:"Use ?? instead of || if only null/undefined should trigger fallback",severity:"medium"}),/&&\s*\w+\s*\(/.test(t)&&!t.includes("if")&&!t.includes("while")&&r.push({file:s,line:c,column:u,language:this.language,construct:"logical-and-short-circuit",triggerCondition:"when left side is falsy \u2014 right side never executes",currentHandling:"short-circuits \u2014 function call skipped silently",suggestedGuard:"Use explicit if-statement for clarity when side effects matter",severity:"low"}),(t.match(/\?/g)||[]).length>=2&&t.includes(":")&&r.push({file:s,line:c,column:u,language:this.language,construct:"ternary-complex",triggerCondition:"when nested ternary conditions interact",currentHandling:"nested ternary \u2014 hard to read and maintain",suggestedGuard:"Refactor to if/else or switch for readability",severity:"medium"}),(/\btypeof\s+\w+\s*===?\s*['"]/.test(t)||/\binstanceof\b/.test(t))&&!t.includes("else")&&!this.findMatchingElse(n,i)&&r.push({file:s,line:c,column:u,language:this.language,construct:"type-guard-unhandled",triggerCondition:"when value does not match the guarded type",currentHandling:"unguarded type path \u2014 may cause runtime type errors",suggestedGuard:"Add else branch or exhaustive type checking",severity:"medium"})}return r}findMatchingElse(e,s){let r={depth:0};for(let n=s;n<Math.min(s+30,e.length);n++){let l=e[n];for(let i of l)i==="{"&&r.depth++,i==="}"&&r.depth--;if(r.depth===0&&n>s){if((e[n+1]?.trim()||"").startsWith("else")||e[n].trim().endsWith("else")||e[n].trim().endsWith("else {")||e[n].includes("} else"))return!0;break}}return!1}extractBlock(e,s){let r=0,n=!1,l=[];for(let i=s;i<Math.min(s+50,e.length);i++){let d=e[i];for(let t of d)t==="{"&&(r++,n=!0),t==="}"&&r--;if(n&&(l.push(d),r===0))return l.join(`
5
+ `)}return null}};function y(o,e,s){let r=Date.now(),n=s||(e.endsWith(".ts")||e.endsWith(".tsx")?"typescript":"javascript"),i=new f(n).enumerate(o,e);return{file:e,language:n,branches:i,totalConstructs:i.length,unhandledCount:i.length,duration:Date.now()-r}}function b(o){let e=[];if(e.push(`# Branch Enumeration Report: ${o.file}`),e.push(""),e.push(`**Language**: ${o.language} | **Branches**: ${o.unhandledCount} | **Duration**: ${o.duration}ms`),e.push(""),o.branches.length===0)return e.push("No unhandled branches detected."),e.join(`
6
+ `);let s={high:[],medium:[],low:[]};for(let r of o.branches)s[r.severity].push(r);for(let r of["high","medium","low"]){let n=s[r];if(n.length!==0){e.push(`## ${r.toUpperCase()} Severity (${n.length})`),e.push("");for(let l of n)e.push(`### ${l.construct} \u2014 Line ${l.line}`),e.push(`- **Trigger**: ${l.triggerCondition}`),e.push(`- **Current**: ${l.currentHandling}`),e.push(`- **Suggested**: ${l.suggestedGuard}`),e.push("")}}return e.join(`
7
+ `)}function w(o){return JSON.stringify(o,null,2)}export{f as TSBranchEnumerator,y as enumerateBranches,w as formatBranchJSON,b as formatBranchReport};
@@ -0,0 +1,4 @@
1
+ if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.9.0");process.exit(0)}
2
+ import{a as p}from"./chunk-IGJPMN4I.js";import"./chunk-4I2IOUS4.js";import{readFile as m,readdir as k}from"fs/promises";import{join as c,basename as y}from"path";import{parse as d}from"yaml";var l=class{templatesDir;cache=new Map;constructor(r){this.templatesDir=r||c(__dirname,"templates")}async load(r){if(this.cache.has(r))return this.cache.get(r);try{let e=c(this.templatesDir,`${r}.yaml`),n=await m(e,"utf-8"),o=d(n),i=await this.validate(o);if(!i.valid)throw new Error(`Invalid workflow template ${r}:
3
+ ${i.errors.join(`
4
+ `)}`);return this.cache.set(r,o),o}catch(e){throw e.code==="ENOENT"?new Error(`Workflow template not found: ${r}`):e}}async list(){try{return(await k(this.templatesDir)).filter(e=>e.endsWith(".yaml")||e.endsWith(".yml")).map(e=>y(e,e.endsWith(".yaml")?".yaml":".yml")).sort()}catch(r){if(r.code==="ENOENT")return[];throw r}}async validate(r){let e=[],n=[];if(r.name||e.push("Workflow must have a name"),r.version||e.push("Workflow must have a version"),r.description||n.push("Workflow should have a description"),Array.isArray(r.variables)?r.variables.forEach((o,i)=>{o.name||e.push(`Variable at index ${i} must have a name`),o.type||e.push(`Variable ${o.name} must have a type`),o.required===void 0&&n.push(`Variable ${o.name} should specify if it's required`)}):e.push("Workflow must have a variables array"),!Array.isArray(r.steps))e.push("Workflow must have a steps array");else if(r.steps.length===0)e.push("Workflow must have at least one step");else{r.steps.forEach((t,s)=>{t.name||e.push(`Step at index ${s} must have a name`),t.action||e.push(`Step ${t.name||s} must have an action`),(!t.config||typeof t.config!="object")&&e.push(`Step ${t.name||s} must have a config object`),t.assertions&&Array.isArray(t.assertions)&&t.assertions.forEach((f,u)=>{f.condition||e.push(`Assertion ${u} in step ${t.name||s} must have a condition`),f.message||n.push(`Assertion ${u} in step ${t.name||s} should have a message`)})});let o=r.steps.map(t=>t.name),i=o.filter((t,s)=>o.indexOf(t)!==s);i.length>0&&e.push(`Duplicate step names found: ${i.join(", ")}`)}return{valid:e.length===0,errors:e,warnings:n}}async createContext(r,e){let n=await this.load(r),o=n.variables.filter(t=>t.required&&!(t.name in e)).map(t=>t.name);if(o.length>0)throw new Error(`Missing required variables: ${o.join(", ")}`);let i={};return n.variables.forEach(t=>{t.name in e?i[t.name]=e[t.name]:"default"in t&&(i[t.name]=t.default)}),{variables:i,results:new Map,metadata:{startTime:Date.now(),workflow:n.name,templateName:r}}}async getMetadata(r){try{let e=c(this.templatesDir,`${r}.yaml`),n=await m(e,"utf-8"),o=d(n);return{name:o.name,version:o.version,description:o.description}}catch(e){throw e.code==="ENOENT"?new Error(`Workflow template not found: ${r}`):e}}clearCache(){this.cache.clear()}async reload(r){return this.cache.delete(r),this.load(r)}},W=new l;function w(a,r){return a.replace(/\{\{([^}]+)\}\}/g,(e,n)=>{let i=n.trim().split("."),t=r;for(let s of i)if(t&&typeof t=="object"&&s in t)t=t[s];else return e;return t!=null?String(t):e})}function v(a,r){let e={...r.variables,result:r.results.get("__last_result__")},n=w(a,e);return p(n,e,!1)}var g=["login-flow","oauth-flow","scraping-workflow","visual-regression","form-validation","navigation-flow","api-integration","performance-audit","accessibility-audit"],b={"login-flow":"Authentication testing workflow for login forms with credential validation","oauth-flow":"OAuth2/OIDC authentication testing workflow with provider integration","scraping-workflow":"Data extraction workflow for web scraping with pagination and structured output","visual-regression":"Screenshot comparison workflow for visual regression testing across breakpoints","form-validation":"Input validation testing workflow for form fields with error handling","navigation-flow":"Multi-page navigation workflow for testing user journeys and state persistence","api-integration":"Browser-API hybrid testing workflow for validating frontend-backend integration","performance-audit":"Lighthouse-style performance audit workflow with Core Web Vitals","accessibility-audit":"WCAG 2.1 Level AA compliance audit workflow with automated accessibility testing"},h={authentication:["login-flow","oauth-flow"],testing:["form-validation","navigation-flow","api-integration"],quality:["visual-regression","performance-audit","accessibility-audit"],automation:["scraping-workflow"]};function R(a){return h[a]}function S(a){return g.includes(a)}function $(){return g.map(a=>{let r=Object.entries(h).find(([e,n])=>n.includes(a))?.[0]||"other";return{name:a,description:b[a],category:r}})}export{h as WORKFLOW_CATEGORIES,b as WORKFLOW_DESCRIPTIONS,g as WORKFLOW_TEMPLATES,l as WorkflowLoader,W as defaultWorkflowLoader,v as evaluateCondition,$ as getAllWorkflowTemplates,R as getWorkflowsByCategory,w as interpolateVariables,S as isValidWorkflowTemplate};
@@ -0,0 +1,2 @@
1
+ if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.9.0");process.exit(0)}
2
+ import{a}from"./chunk-BLBRY5UD.js";import"./chunk-NZ2VCPN4.js";import"./chunk-24FKIJNC.js";import"./chunk-SUSEVMZT.js";import"./chunk-JJO7Y4H3.js";import"./chunk-N2NS2PHA.js";import"./chunk-3JPRUND5.js";import"./chunk-4VUPRTVX.js";import"./chunk-WGMPEW2T.js";import"./chunk-JZSDOIXA.js";import"./chunk-263XS447.js";import"./chunk-MDUHYUHF.js";import"./chunk-GAOJV3OX.js";import"./chunk-62ADTHV7.js";import"./chunk-DRT3WKQW.js";import"./chunk-UFUVUO3J.js";import"./chunk-7VDBAVTY.js";import"./chunk-B36CDR4U.js";import"./chunk-2I7J3O6V.js";import"./chunk-4I2IOUS4.js";export{a as BrowserWorkflowTool};
@@ -0,0 +1,15 @@
1
+ if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.9.0");process.exit(0)}
2
+ import{h as s,k as o,o as m}from"./chunk-JJO7Y4H3.js";import{a as u}from"./chunk-3JPRUND5.js";import{c as r}from"./chunk-4VUPRTVX.js";import{a,e as c}from"./chunk-7VDBAVTY.js";m();c();u();var l=r.create("hybrid-backend"),d=class{unifiedMemory=null;config;cleanupInterval;cleanupCount=0;initialized=!1;constructor(e){this.config={sqlite:{path:e?.sqlite?.path??".agentic-qe/memory.db",walMode:e?.sqlite?.walMode??!0,poolSize:e?.sqlite?.poolSize??5,busyTimeout:e?.sqlite?.busyTimeout??a.BUSY_TIMEOUT_MS,...e?.sqlite},agentdb:{path:e?.agentdb?.path??".agentic-qe/memory.db",...e?.agentdb},enableFallback:e?.enableFallback??!0,defaultNamespace:e?.defaultNamespace??"default",cleanupInterval:e?.cleanupInterval??a.CLEANUP_INTERVAL_MS}}async initialize(){if(this.initialized)return;let e={dbPath:this.config.sqlite.path??s.dbPath,walMode:this.config.sqlite.walMode??!0,busyTimeout:this.config.sqlite.busyTimeout??a.BUSY_TIMEOUT_MS};this.unifiedMemory=o(e),await this.unifiedMemory.initialize(),this.cleanupInterval=setInterval(()=>this.cleanup(),this.config.cleanupInterval),this.cleanupInterval.unref&&this.cleanupInterval.unref(),this.initialized=!0,console.log(`[HybridBackend] Initialized with unified memory: ${this.unifiedMemory.getDbPath()}`)}async dispose(){this.cleanupInterval&&clearInterval(this.cleanupInterval),this.initialized=!1}async set(e,i,t){this.ensureInitialized();let n=t?.namespace??this.config.defaultNamespace;await this.unifiedMemory.kvSet(e,i,n,t?.ttl)}async get(e){return this.ensureInitialized(),this.unifiedMemory.kvGet(e,this.config.defaultNamespace)}async delete(e){this.ensureInitialized();let i=await this.unifiedMemory.kvDelete(e,this.config.defaultNamespace),t=await this.unifiedMemory.vectorDelete(e);return i||t}async has(e){return this.ensureInitialized(),this.unifiedMemory.kvExists(e,this.config.defaultNamespace)}async search(e,i=100){return this.ensureInitialized(),this.unifiedMemory.kvSearch(e,this.config.defaultNamespace,i)}async vectorSearch(e,i){return this.ensureInitialized(),(await this.unifiedMemory.vectorSearch(e,i)).map(n=>({key:n.id,score:n.score,metadata:n.metadata}))}async storeVector(e,i,t){this.ensureInitialized(),await this.unifiedMemory.vectorStore(e,i,this.config.defaultNamespace,t)}getHealth(){return{sqlite:this.unifiedMemory?.isInitialized()?"healthy":"unavailable",sqlitePersistent:!0,agentdb:this.unifiedMemory?.isInitialized()?"healthy":"unavailable",fallback:"inactive"}}isPersistent(){return this.unifiedMemory?.isInitialized()??!1}getConfig(){return{...this.config}}async setWithBackend(e,i,t,n){await this.set(e,i,n)}async getVectorStats(){if(!this.unifiedMemory?.isInitialized())return null;let e=await this.unifiedMemory.vectorCount(),i=this.unifiedMemory.getStats();return{vectorCount:e,indexSize:i.vectorIndexSize}}getUnifiedMemory(){return this.unifiedMemory}async count(e){return this.ensureInitialized(),this.unifiedMemory.getDatabase().prepare(`
3
+ SELECT COUNT(*) as count FROM kv_store
4
+ WHERE namespace LIKE ?
5
+ AND (expires_at IS NULL OR expires_at > ?)
6
+ `).get(`${e}%`,Date.now()).count}async hasCodeIntelligenceIndex(){return this.ensureInitialized(),this.unifiedMemory.getDatabase().prepare(`
7
+ SELECT 1 FROM kv_store
8
+ WHERE namespace = 'code-intelligence:kg'
9
+ AND (expires_at IS NULL OR expires_at > ?)
10
+ LIMIT 1
11
+ `).get(Date.now())!==void 0}ensureInitialized(){if(!this.initialized||!this.unifiedMemory)throw new Error("HybridMemoryBackend not initialized. Call initialize() first.")}async cleanup(){if(this.unifiedMemory?.isInitialized())try{await this.unifiedMemory.kvCleanupExpired();let e=this.unifiedMemory.getDatabase();try{let i=e.prepare("DELETE FROM kv_store WHERE expires_at IS NOT NULL AND expires_at < ?").run(Date.now());i.changes>0&&console.log(`[HybridBackend] Expired ${i.changes} kv_store entries`)}catch(i){l.debug("TTL expiration cleanup failed",{error:i instanceof Error?i.message:String(i)})}if(this.cleanupCount++,this.cleanupCount%10===0)try{if(e.prepare("SELECT COUNT(*) as cnt FROM kv_store").get().cnt>5e3){let t=e.prepare(`
12
+ DELETE FROM kv_store WHERE rowid NOT IN (
13
+ SELECT rowid FROM kv_store ORDER BY rowid DESC LIMIT 5000
14
+ )
15
+ `).run();t.changes>0&&console.log(`[HybridBackend] kv_store retention: pruned ${t.changes} rows (kept 5000)`)}}catch(i){l.debug("KV store retention pruning failed",{error:i instanceof Error?i.message:String(i)})}}catch(e){console.warn("[HybridBackend] Cleanup failed:",e)}}};export{d as a};
@@ -0,0 +1,2 @@
1
+ if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.9.0");process.exit(0)}
2
+ import{a as t,q as r}from"./chunk-MDUHYUHF.js";import{c as l}from"./chunk-4I2IOUS4.js";function m(s,e){let o=e?.readonly??!1,n=e?.fileMustExist??!1,i=e?.busyTimeout??5e3,b=e?.walMode??!o,a=new t(s,{readonly:o,fileMustExist:n});return a.pragma(`busy_timeout = ${i}`),b&&a.pragma("journal_mode = WAL"),a}var u=l(()=>{r()});export{m as a,u as b};
@@ -0,0 +1,4 @@
1
+ if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.9.0");process.exit(0)}
2
+ import*as o from"fs";import*as l from"path";var m=class{cacheDir;keepVersions;constructor(e={}){this.cacheDir=e.cacheDir??l.join(process.cwd(),".agentic-qe","plugins"),this.keepVersions=e.keepVersions??2}has(e,t){let s=this.versionDir(e,t);return o.existsSync(s)&&o.existsSync(l.join(s,"qe-plugin.json"))}get(e,t){if(!this.has(e,t))return;let s=this.versionDir(e,t),i=o.readFileSync(l.join(s,"qe-plugin.json"),"utf-8"),r=JSON.parse(i),c=o.statSync(s);return{manifest:r,path:s,cachedAt:c.birthtime.toISOString()}}store(e,t){let s=this.versionDir(e.name,e.version);return o.existsSync(s)||(o.mkdirSync(s,{recursive:!0}),this.copyDir(t,s),o.writeFileSync(l.join(s,"qe-plugin.json"),JSON.stringify(e,null,2)),this.pruneOldVersions(e.name)),s}remove(e,t){let s=this.versionDir(e,t);return o.existsSync(s)?(o.rmSync(s,{recursive:!0,force:!0}),!0):!1}listVersions(e){let t=l.join(this.cacheDir,e);if(!o.existsSync(t))return[];let s=[],i=o.readdirSync(t);for(let r of i){let c=l.join(t,r),h=l.join(c,"qe-plugin.json");if(o.existsSync(h))try{let a=o.readFileSync(h,"utf-8"),f=JSON.parse(a),u=o.statSync(c);s.push({manifest:f,path:c,cachedAt:u.birthtime.toISOString()})}catch{}}return s}listAll(){if(!o.existsSync(this.cacheDir))return[];let e=[],t=o.readdirSync(this.cacheDir);for(let s of t){let i=this.listVersions(s);i.length>0&&(i.sort((r,c)=>c.manifest.version.localeCompare(r.manifest.version)),e.push(i[0]))}return e}versionDir(e,t){return l.join(this.cacheDir,e,t)}pruneOldVersions(e){let t=this.listVersions(e);if(t.length<=this.keepVersions)return;t.sort((i,r)=>i.cachedAt.localeCompare(r.cachedAt));let s=t.slice(0,t.length-this.keepVersions);for(let i of s)o.rmSync(i.path,{recursive:!0,force:!0})}copyDir(e,t){if(!o.existsSync(e))return;let s=o.readdirSync(e,{withFileTypes:!0});for(let i of s){let r=l.join(e,i.name),c=l.join(t,i.name);if(i.isDirectory()){if(i.name===".git"||i.name==="node_modules")continue;o.mkdirSync(c,{recursive:!0}),this.copyDir(r,c)}else o.copyFileSync(r,c)}}};var R=/^[a-z][a-z0-9-]*$/,S=/^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?$/,j=["aqe-core-","agentic-qe-core-"];function E(n){let e=[],t=[];if(!n||typeof n!="object")return{valid:!1,errors:["Manifest must be a non-null object"],warnings:[]};let s=n;if(!s.name||typeof s.name!="string"?e.push("name is required and must be a string"):D(s.name,e,t),!s.version||typeof s.version!="string"?e.push("version is required and must be a string"):S.test(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>500&&t.push("description exceeds 500 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"):V(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`);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"||!S.test(s.minAqeVersion))&&t.push("minAqeVersion should 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:t}}function b(n){let e=typeof n=="string"?JSON.parse(n):n,t=E(e);if(!t.valid)throw new Error(`Invalid plugin manifest:
3
+ - ${t.errors.join(`
4
+ - `)}`);return e}function D(n,e,t){n.length>64&&e.push("name must be 64 characters or fewer"),R.test(n)||e.push("name must be lowercase alphanumeric with hyphens, starting with a letter"),/[^\x00-\x7F]/.test(n)&&e.push("name must contain only ASCII characters");for(let s of j)n.startsWith(s)&&e.push(`name cannot start with reserved prefix "${s}"`);["plugin","test","tool"].includes(n)&&t.push(`name "${n}" is very generic \u2014 consider a more descriptive name`)}function V(n,e){n.includes("..")&&e.push('entryPoint must not contain ".." (path traversal)'),(n.startsWith("/")||n.startsWith("\\"))&&e.push("entryPoint must be a relative path"),!n.endsWith(".js")&&!n.endsWith(".ts")&&!n.endsWith(".mjs")&&e.push("entryPoint must end in .js, .ts, or .mjs")}var y=class{resolve(e){let t=new Map;for(let a of e)t.set(a.name,a);let s=[],i=new Set,r=new Set,c=new Map,h=(a,f)=>{if(i.has(a))return;if(r.has(a)){let g=[...f.slice(f.indexOf(a)),a];throw new Error(`Dependency cycle detected: ${g.join(" -> ")}`)}let u=t.get(a);if(!u)return;r.add(a);let k=Object.keys(u.dependencies??{}),P=[];for(let g of k)t.has(g)?h(g,[...f,a]):P.push(g);P.length>0&&c.set(a,P),r.delete(a),i.add(a),s.push(u)};for(let a of e)h(a.name,[]);return{ordered:s.map((a,f)=>({manifest:a,order:f})),missing:c}}canLoad(e,t){let i=Object.keys(e.dependencies??{}).filter(r=>!t.has(r));return{canLoad:i.length===0,missingDeps:i}}};var N=["aqe-core-","agentic-qe-core-","agentic-qe-internal-"],M=new Set(["aqe","agentic-qe","ruflo","claude-flow"]),_=["..","~","/etc/","/proc/","/dev/","node_modules/"];function A(n){let e=[];return $(n.name,e),q(n.entryPoint,e),C(n.hooks,e),I(n.permissions,e),{safe:e.length===0,violations:e}}function $(n,e){/[^\x20-\x7E]/.test(n)&&e.push(`Plugin name "${n}" contains non-ASCII characters`),M.has(n.toLowerCase())&&e.push(`Plugin name "${n}" is a reserved name`);for(let s of N)n.toLowerCase().startsWith(s)&&e.push(`Plugin name "${n}" uses reserved prefix "${s}"`);let t=n.toLowerCase().replace(/[0o]/g,"o").replace(/[1il]/g,"l").replace(/[-_]/g,"");M.has(t)&&e.push(`Plugin name "${n}" is visually similar to a reserved name`)}function q(n,e){w(n,"entryPoint",e),(n.startsWith("/")||n.startsWith("\\"))&&e.push("entryPoint must be a relative path, not absolute")}function C(n,e){if(n)for(let[t,s]of Object.entries(n))w(s,`hook[${t}]`,e)}function w(n,e,t){for(let s of _)n.includes(s)&&t.push(`${e} contains dangerous path pattern "${s}"`);n.includes("\0")&&t.push(`${e} contains null byte (path injection attempt)`)}function I(n,e){if(!n)return;let t=["fs:write-root","net:arbitrary","exec:shell"];for(let s of n)t.includes(s)&&e.push(`Plugin requests dangerous permission: ${s}`)}import*as p from"fs";import*as d from"path";var v=class{type="local";async resolve(e){let t=d.resolve(e),s=d.join(t,"qe-plugin.json");if(!p.existsSync(s))throw new Error(`No qe-plugin.json found at ${s}`);let i=p.readFileSync(s,"utf-8");return b(i)}async getPluginPath(e){let t=d.resolve(e);if(!p.existsSync(t))throw new Error(`Plugin directory does not exist: ${t}`);return t}};var x=class{cache;resolver;sources=new Map;constructor(e={}){this.cache=e.cache??new m,this.resolver=new y;let t=new v;if(this.sources.set("local",t),e.sources)for(let s of e.sources)this.sources.set(s.type,s)}async install(e,t="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(t);if(!i)return{success:!1,errors:[`Unknown source type: ${t}. Available: ${[...this.sources.keys()].join(", ")}`],securityViolations:[]};let r;try{r=await i.resolve(e)}catch(u){return{success:!1,errors:[`Failed to resolve plugin: ${u instanceof Error?u.message:String(u)}`],securityViolations:[]}}let c=E(r);if(!c.valid)return{success:!1,manifest:r,errors:c.errors,securityViolations:[]};let h=A(r);if(!h.safe)return{success:!1,manifest:r,errors:["Plugin failed security checks"],securityViolations:h.violations};if(this.cache.has(r.name,r.version)){let u=this.cache.get(r.name,r.version);return{success:!0,manifest:r,cachePath:u.path,errors:[],securityViolations:[]}}let a;try{a=await i.getPluginPath(e)}catch(u){return{success:!1,manifest:r,errors:[`Failed to get plugin path: ${u instanceof Error?u.message:String(u)}`],securityViolations:[]}}let f=this.cache.store(r,a);return{success:!0,manifest:r,cachePath:f,errors:s,securityViolations:[]}}remove(e,t){if(t)return this.cache.remove(e,t);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(t=>({name:t.manifest.name,version:t.manifest.version,description:t.manifest.description,domains:t.manifest.domains,source:"cached",cachePath:t.path}))}resolveLoadOrder(){let e=this.cache.listAll();return this.resolver.resolve(e.map(t=>t.manifest))}registerSource(e){this.sources.set(e.type,e)}};export{b as a,m as b,x as c};