agentic-qe 3.14.7 → 3.14.8
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.
- package/.claude/helpers/.helpers-version +1 -1
- package/.claude/helpers/auto-memory-hook.mjs +18 -9
- package/.claude/helpers/helpers.manifest.json +6 -5
- package/.claude/helpers/hook-handler.cjs +40 -12
- package/.claude/helpers/memory.cjs +86 -0
- package/.claude/helpers/router.cjs +105 -0
- package/.claude/helpers/session.cjs +166 -0
- package/.claude/helpers/statusline.cjs +73 -621
- package/.claude/skills/skills-manifest.json +1 -1
- package/CHANGELOG.md +130 -0
- package/assets/skills/skills-manifest.json +1 -1
- package/dist/adapters/a2a/notifications/retry-queue.js +5 -0
- package/dist/adapters/claude-flow/pretrain-bridge.js +3 -2
- package/dist/agents/claim-verifier/verifiers/file-verifier.js +3 -2
- package/dist/cli/bundle.js +6 -6
- package/dist/cli/chunks/adapter-XYCOXQCC.js +2 -0
- package/dist/cli/chunks/{agent-booster-wasm-AK2W76RG.js → agent-booster-wasm-67OKGDGZ.js} +2 -2
- package/dist/cli/chunks/{agent-handler-MGZCWHIY.js → agent-handler-4HZEQ3WQ.js} +2 -2
- package/dist/cli/chunks/{agent-memory-branch-JZ54MCSP.js → agent-memory-branch-IBHZQSRN.js} +2 -2
- package/dist/cli/chunks/aqe-learning-engine-DTJCROTG.js +2 -0
- package/dist/cli/chunks/{arena-CUVH3V7H.js → arena-EJBIGSF4.js} +2 -2
- package/dist/cli/chunks/{arena-YSWTKBCL.js → arena-LCLRGUIK.js} +4 -4
- package/dist/cli/chunks/{audit-LVU76QGA.js → audit-PY4JNDQQ.js} +3 -3
- package/dist/cli/chunks/base-5TQ34GMD.js +2 -0
- package/dist/cli/chunks/{better-sqlite3-DB3LOJQU.js → better-sqlite3-2JG5K6XT.js} +2 -2
- package/dist/cli/chunks/{brain-handler-SD63KOQ6.js → brain-handler-3UYK55GA.js} +4 -4
- package/dist/cli/chunks/{branch-enumerator-4MNOPUC7.js → branch-enumerator-GOSWOX46.js} +2 -2
- package/dist/cli/chunks/{browser-OLPNTWQE.js → browser-DC2JV47Z.js} +2 -2
- package/dist/cli/chunks/browser-workflow-KWX4ESTJ.js +2 -0
- package/dist/cli/chunks/{chunk-QQFQDEUE.js → chunk-25EEIAHS.js} +2 -2
- package/dist/cli/chunks/{chunk-DOBKEXMJ.js → chunk-3576QGPP.js} +1 -1
- package/dist/cli/chunks/{chunk-3M7J4U74.js → chunk-3EKG7HFV.js} +4 -4
- package/dist/cli/chunks/{chunk-DYTQHRUS.js → chunk-3FCHH4VP.js} +1 -1
- package/dist/cli/chunks/{chunk-EJ6MMYLK.js → chunk-3S5IIK32.js} +1 -1
- package/dist/cli/chunks/{chunk-NOHWJOBS.js → chunk-3X2JSW3R.js} +1 -1
- package/dist/cli/chunks/{chunk-7EZ2Z2CK.js → chunk-4HXFPBAA.js} +1 -1
- package/dist/cli/chunks/{chunk-XBYQ2BS4.js → chunk-4PY44TKH.js} +2 -2
- package/dist/cli/chunks/{chunk-5FSLMYAC.js → chunk-4RNCVSVN.js} +2 -2
- package/dist/cli/chunks/{chunk-X7ADKL7T.js → chunk-56M4QNXU.js} +2 -2
- package/dist/cli/chunks/{chunk-JHJUSSAU.js → chunk-5X4HDW5W.js} +2 -2
- package/dist/cli/chunks/{chunk-7MIOK72I.js → chunk-673XJBGW.js} +7 -7
- package/dist/cli/chunks/{chunk-77QZHIVX.js → chunk-6F7MFHTY.js} +2 -2
- package/dist/cli/chunks/{chunk-Q6NTEICT.js → chunk-6GJWT2OY.js} +2 -2
- package/dist/cli/chunks/{chunk-GV4DYPJP.js → chunk-6GNWVPMR.js} +2 -2
- package/dist/cli/chunks/{chunk-V5AK56DA.js → chunk-6VTC3OHD.js} +2 -2
- package/dist/cli/chunks/{chunk-MM56VPNE.js → chunk-775WGWLL.js} +3 -3
- package/dist/cli/chunks/{chunk-A3DK3XNZ.js → chunk-77WL5HQW.js} +1 -1
- package/dist/cli/chunks/chunk-7STWD4KJ.js +3 -0
- package/dist/cli/chunks/{chunk-RC2A4JZ5.js → chunk-7TNCEVWX.js} +2 -2
- package/dist/cli/chunks/{chunk-XL5KIYE3.js → chunk-7X3LMTRA.js} +2 -2
- package/dist/cli/chunks/{chunk-VW6FRMLW.js → chunk-A53MMSGC.js} +2 -2
- package/dist/cli/chunks/{chunk-UFSVUBTR.js → chunk-A5CLVZC3.js} +2 -2
- package/dist/cli/chunks/{chunk-4INST4ZL.js → chunk-AEYJ4ZLA.js} +1 -1
- package/dist/cli/chunks/{chunk-5U6N4V5M.js → chunk-AJ5PCJQ2.js} +4 -4
- package/dist/cli/chunks/{chunk-OAZX6WFU.js → chunk-AJMAKUS3.js} +2 -2
- package/dist/cli/chunks/{chunk-74IOEOMH.js → chunk-AOD2ES44.js} +2 -2
- package/dist/cli/chunks/chunk-AR2S4DOB.js +2 -0
- package/dist/cli/chunks/{chunk-PYKY22GC.js → chunk-AUFV2G2J.js} +5 -5
- package/dist/cli/chunks/{chunk-KD2BLA5Y.js → chunk-B2QKBQYD.js} +1 -1
- package/dist/cli/chunks/{chunk-6EGS77BB.js → chunk-BCCSV3RH.js} +1 -1
- package/dist/cli/chunks/{chunk-JOZ47MV6.js → chunk-BFIXUKOR.js} +1 -1
- package/dist/cli/chunks/chunk-BHPTHC5O.js +4 -0
- package/dist/cli/chunks/{chunk-OIDWDGLG.js → chunk-BITFGVZ4.js} +2 -2
- package/dist/cli/chunks/{chunk-ONR2NXXD.js → chunk-BL6273KR.js} +3 -3
- package/dist/cli/chunks/{chunk-BLG7SH4A.js → chunk-BOIUENWW.js} +1 -1
- package/dist/cli/chunks/{chunk-T77GZF4B.js → chunk-BT3MI2BW.js} +1 -1
- package/dist/cli/chunks/{chunk-UYUJT6QO.js → chunk-BTBJ2NLH.js} +2 -2
- package/dist/cli/chunks/{chunk-YMW57PEL.js → chunk-BUVJIVFG.js} +1 -1
- package/dist/cli/chunks/{chunk-QUORH2MG.js → chunk-BZIPW2PA.js} +8 -8
- package/dist/cli/chunks/{chunk-GVVFTFMB.js → chunk-C647D42G.js} +2 -2
- package/dist/cli/chunks/{chunk-AJUBT4NP.js → chunk-CBWM5NOO.js} +3 -3
- package/dist/cli/chunks/{chunk-F2OPFVQH.js → chunk-CIEXUYY7.js} +1 -1
- package/dist/cli/chunks/{chunk-QGOWNVVG.js → chunk-CLUHGBLN.js} +4 -4
- package/dist/cli/chunks/{chunk-WOV6XI3A.js → chunk-CQEWL32R.js} +1 -1
- package/dist/cli/chunks/{chunk-3QJU4Q4R.js → chunk-CXUC7YKA.js} +2 -2
- package/dist/cli/chunks/{chunk-HZY42OVU.js → chunk-D2Y36V5J.js} +2 -2
- package/dist/cli/chunks/{chunk-WF6UISKW.js → chunk-DSJJHPPS.js} +4 -4
- package/dist/cli/chunks/{chunk-FYPX5WBJ.js → chunk-DZHXCOSK.js} +1 -1
- package/dist/cli/chunks/{chunk-TXSPBLBT.js → chunk-EBV3WFIR.js} +2 -2
- package/dist/cli/chunks/{chunk-Y6AKKQIQ.js → chunk-EKO5QL2B.js} +1 -1
- package/dist/cli/chunks/{chunk-MZB2UV2O.js → chunk-EMOZ5O5S.js} +1 -1
- package/dist/cli/chunks/{chunk-23CX7JNL.js → chunk-ES7TAJRJ.js} +2 -2
- package/dist/cli/chunks/{chunk-Z4Q5PCRZ.js → chunk-EXQGHTPD.js} +4 -4
- package/dist/cli/chunks/{chunk-A2VUCUTT.js → chunk-F2WAB4WK.js} +2 -2
- package/dist/cli/chunks/{chunk-CQNMGK6Y.js → chunk-F57FTFWS.js} +2 -2
- package/dist/cli/chunks/{chunk-OEPNNLR4.js → chunk-F6JJNBE5.js} +1 -1
- package/dist/cli/chunks/{chunk-UBJG3IHT.js → chunk-FRC7AFB4.js} +2 -2
- package/dist/cli/chunks/{chunk-2G63VIJE.js → chunk-G36RZF2Y.js} +1 -1
- package/dist/cli/chunks/{chunk-YRHTQZU4.js → chunk-G3C7Z6FO.js} +2 -2
- package/dist/cli/chunks/{chunk-B4I43GE2.js → chunk-GA63ESNT.js} +2 -2
- package/dist/cli/chunks/{chunk-7QYOTUOX.js → chunk-GHMJFICO.js} +2 -2
- package/dist/cli/chunks/{chunk-HYOPJHHW.js → chunk-GK5WLUX3.js} +1 -1
- package/dist/cli/chunks/{chunk-A5MA7A23.js → chunk-GQJ4QDEN.js} +6 -6
- package/dist/cli/chunks/{chunk-UA7TDVL7.js → chunk-GVLRE3BV.js} +4 -4
- package/dist/cli/chunks/{chunk-25P6JA6V.js → chunk-H5UH234L.js} +1 -1
- package/dist/cli/chunks/{chunk-BE4KALTE.js → chunk-HBAFXWSO.js} +1 -1
- package/dist/cli/chunks/{chunk-EGOIIUBD.js → chunk-HE3BDBAO.js} +2 -2
- package/dist/cli/chunks/{chunk-P2UPYSDJ.js → chunk-HHANMCD2.js} +1 -1
- package/dist/cli/chunks/{chunk-ZUOVNFXK.js → chunk-HPVYJ6JH.js} +2 -2
- package/dist/cli/chunks/{chunk-RKI3IQKQ.js → chunk-I6NZFBT3.js} +3 -3
- package/dist/cli/chunks/{chunk-QVH5Y7AP.js → chunk-ISBOHF6Y.js} +1 -1
- package/dist/cli/chunks/{chunk-IWFFO6VT.js → chunk-J24AJEDE.js} +2 -2
- package/dist/cli/chunks/{chunk-5GFKTJ65.js → chunk-J5HTQHJK.js} +2 -2
- package/dist/cli/chunks/{chunk-LY7MFGBD.js → chunk-JDOVO4E4.js} +150 -149
- package/dist/cli/chunks/chunk-JQAJUXRE.js +2 -0
- package/dist/cli/chunks/{chunk-HXXHMLJ5.js → chunk-JRK5GX56.js} +1 -1
- package/dist/cli/chunks/{chunk-36VKMAMN.js → chunk-JRLZ7LZ3.js} +2 -2
- package/dist/cli/chunks/{chunk-6PJPQGF4.js → chunk-JTOFLDU7.js} +2 -2
- package/dist/cli/chunks/{chunk-CVOQ6ESD.js → chunk-K6EOHGKS.js} +2 -2
- package/dist/cli/chunks/{chunk-LU2EDWQK.js → chunk-KKXH25IH.js} +2 -2
- package/dist/cli/chunks/{chunk-EYXE2XKP.js → chunk-KNSQWM2E.js} +2 -2
- package/dist/cli/chunks/{chunk-IEJ7ZV3M.js → chunk-L5T32SRF.js} +1 -1
- package/dist/cli/chunks/{chunk-BEFTQVEW.js → chunk-LKFBW2QM.js} +2 -2
- package/dist/cli/chunks/{chunk-C3FXFU2T.js → chunk-LMAI74EP.js} +1 -1
- package/dist/cli/chunks/{chunk-P7XSPP5D.js → chunk-LQVS5IWH.js} +2 -2
- package/dist/cli/chunks/{chunk-4EKV7PHB.js → chunk-LRGTPUJA.js} +2 -2
- package/dist/cli/chunks/{chunk-MT7UNBZ7.js → chunk-LTHV4PIG.js} +2 -2
- package/dist/cli/chunks/{chunk-B2YGVSOP.js → chunk-M7QKCHLQ.js} +2 -2
- package/dist/cli/chunks/{chunk-H5RQPO3X.js → chunk-N3ASALOL.js} +2 -2
- package/dist/cli/chunks/{chunk-MQZ53OR3.js → chunk-NEXBTLN6.js} +2 -2
- package/dist/cli/chunks/{chunk-BD7FEUN3.js → chunk-NJEEKYEP.js} +3 -3
- package/dist/cli/chunks/{chunk-UOI6ULCH.js → chunk-NWUFTLSF.js} +2 -2
- package/dist/cli/chunks/{chunk-RT6O2HW2.js → chunk-O4QB2GFL.js} +2 -2
- package/dist/cli/chunks/{chunk-MZMG6CUJ.js → chunk-OA75C4HY.js} +2 -2
- package/dist/cli/chunks/{chunk-HYFQUWNB.js → chunk-OVMG6EEF.js} +2 -2
- package/dist/cli/chunks/{chunk-FSSR6WBE.js → chunk-OX7MJFLC.js} +2 -2
- package/dist/cli/chunks/{chunk-ENK44A6Q.js → chunk-OZJQN7YE.js} +2 -2
- package/dist/cli/chunks/{chunk-LXZMP3VX.js → chunk-PFXCRRR6.js} +25 -25
- package/dist/cli/chunks/{chunk-WIH522AP.js → chunk-PVJLQ2YZ.js} +1 -1
- package/dist/cli/chunks/{chunk-ZUB5YOCM.js → chunk-QDRFLM77.js} +2 -2
- package/dist/cli/chunks/{chunk-NHUGHAY6.js → chunk-QH7C4PTX.js} +1 -1
- package/dist/cli/chunks/{chunk-VXKWNRGA.js → chunk-QKM4XT2F.js} +2 -2
- package/dist/cli/chunks/{chunk-ON2UTP2U.js → chunk-QP7EKLWU.js} +2 -2
- package/dist/cli/chunks/{chunk-KUHLTVWC.js → chunk-QPACHVDI.js} +1 -1
- package/dist/cli/chunks/{chunk-PCJQCEBA.js → chunk-QQVE65ER.js} +2 -2
- package/dist/cli/chunks/{chunk-Q3NSU24F.js → chunk-QYCZYJH7.js} +2 -2
- package/dist/cli/chunks/{chunk-AEUEMVJK.js → chunk-R6I5I724.js} +2 -2
- package/dist/cli/chunks/{chunk-5D7ZFWDS.js → chunk-RJJIPTVH.js} +2 -2
- package/dist/cli/chunks/{chunk-ZWEKAEEV.js → chunk-RM6OC35G.js} +1 -1
- package/dist/cli/chunks/{chunk-ZELWDJXT.js → chunk-RTD4U7IW.js} +2 -2
- package/dist/cli/chunks/{chunk-O5V7RHVG.js → chunk-SKJQKOFJ.js} +2 -2
- package/dist/cli/chunks/{chunk-6RD44SCE.js → chunk-SMBGK7XI.js} +1 -1
- package/dist/cli/chunks/{chunk-ND4QTZOL.js → chunk-SPS472C5.js} +2 -2
- package/dist/cli/chunks/{chunk-TFK2AYIN.js → chunk-SUNXA2UR.js} +2 -2
- package/dist/cli/chunks/{chunk-RDGPXENG.js → chunk-SVP3BP52.js} +2 -2
- package/dist/cli/chunks/{chunk-NBLDBVAW.js → chunk-T4WQPE77.js} +1 -1
- package/dist/cli/chunks/{chunk-ZS4XVJGV.js → chunk-T53ZN4NO.js} +2 -2
- package/dist/cli/chunks/chunk-T6W2EYHC.js +2 -0
- package/dist/cli/chunks/{chunk-JZT7BU44.js → chunk-T7YCNOW5.js} +2 -2
- package/dist/cli/chunks/{chunk-EADSQN5T.js → chunk-TCQWVVSR.js} +1 -1
- package/dist/cli/chunks/{chunk-XYLQZWF6.js → chunk-TGRHO4ES.js} +2 -2
- package/dist/cli/chunks/{chunk-QPLSYEWJ.js → chunk-TP7L4EX6.js} +2 -2
- package/dist/cli/chunks/{chunk-N5XOXPHZ.js → chunk-TT45RCLN.js} +2 -2
- package/dist/cli/chunks/{chunk-OZGIOKEA.js → chunk-TUZNWRYC.js} +1 -1
- package/dist/cli/chunks/{chunk-53BXTTRO.js → chunk-U2QTL5T2.js} +3 -3
- package/dist/cli/chunks/chunk-U64QORFO.js +2 -0
- package/dist/cli/chunks/{chunk-SRPLERER.js → chunk-UHLZKH6B.js} +4 -4
- package/dist/cli/chunks/{chunk-HPWWYT67.js → chunk-UIWXKRTK.js} +2 -2
- package/dist/cli/chunks/{chunk-XWYELBZS.js → chunk-UNFE4RPV.js} +1 -1
- package/dist/cli/chunks/{chunk-FW4DJ4FJ.js → chunk-UQGIC5OX.js} +1 -1
- package/dist/cli/chunks/{chunk-GLGKQX2V.js → chunk-VAXTPLO3.js} +2 -2
- package/dist/cli/chunks/{chunk-VYDVI6FZ.js → chunk-VCSNNLWL.js} +2 -2
- package/dist/cli/chunks/{chunk-J7AQZLIH.js → chunk-VSPNIDQK.js} +4 -4
- package/dist/cli/chunks/{chunk-EIGRV3J6.js → chunk-VV2JVYOI.js} +2 -2
- package/dist/cli/chunks/{chunk-CBONQM5D.js → chunk-VW7AXJQS.js} +2 -2
- package/dist/cli/chunks/{chunk-O6MO5KMR.js → chunk-W7JUD4EZ.js} +2 -2
- package/dist/cli/chunks/{chunk-QFETNCNN.js → chunk-WFKE7NZ5.js} +2 -2
- package/dist/cli/chunks/{chunk-ROVZSZCS.js → chunk-WVEHKAIH.js} +3 -3
- package/dist/cli/chunks/{chunk-YO4ESCB4.js → chunk-XAESN54Q.js} +1 -1
- package/dist/cli/chunks/{chunk-RKUAWQOF.js → chunk-XECZYQT5.js} +2 -2
- package/dist/cli/chunks/{chunk-RLW25X66.js → chunk-XFT4FYTC.js} +2 -2
- package/dist/cli/chunks/{chunk-SM2YJ2AL.js → chunk-YHX74M7C.js} +2 -2
- package/dist/cli/chunks/chunk-YIWBJ637.js +2 -0
- package/dist/cli/chunks/{chunk-IAENZ2DR.js → chunk-Z5UZOYQS.js} +2 -2
- package/dist/cli/chunks/{chunk-G367W7XR.js → chunk-Z6G3QVZ4.js} +12 -12
- package/dist/cli/chunks/ci-5LIV2HW5.js +82 -0
- package/dist/cli/chunks/{ci-output-RLS32FUY.js → ci-output-UO5BDFU4.js} +2 -2
- package/dist/cli/chunks/{circuit-breaker-MRCC7WCM.js → circuit-breaker-UQDPXYRD.js} +2 -2
- package/dist/cli/chunks/{claude-flow-setup-LIZCEKDF.js → claude-flow-setup-62QES3QX.js} +2 -2
- package/dist/cli/chunks/client-AJZKCP4I.js +2 -0
- package/dist/cli/chunks/{cline-installer-T7H6R2RC.js → cline-installer-X7VZTSZG.js} +2 -2
- package/dist/cli/chunks/{code-XMBLI7OF.js → code-H3BF4L4H.js} +3 -3
- package/dist/cli/chunks/{code-index-extractor-QS7BYLEX.js → code-index-extractor-BJGFZGGL.js} +2 -2
- package/dist/cli/chunks/{codex-installer-6PGT5FM6.js → codex-installer-KVZWKU6S.js} +2 -2
- package/dist/cli/chunks/{completions-2A3WRXY2.js → completions-YMILE6V7.js} +2 -2
- package/dist/cli/chunks/{complexity-analyzer-23HOOGJ7.js → complexity-analyzer-J26N2PWG.js} +2 -2
- package/dist/cli/chunks/{continuedev-installer-4FSF7B3N.js → continuedev-installer-MAR42OV7.js} +2 -2
- package/dist/cli/chunks/{copilot-installer-A5GRQQUU.js → copilot-installer-CVOJF6OT.js} +2 -2
- package/dist/cli/chunks/core-handlers-MQHEMGDV.js +2 -0
- package/dist/cli/chunks/{cost-tracker-Z4STQ5VB.js → cost-tracker-SXLWXE55.js} +2 -2
- package/dist/cli/chunks/{coverage-NUPP6KZZ.js → coverage-D7HCHFP3.js} +3 -3
- package/dist/cli/chunks/cross-domain-router-3QNMZV5R.js +2 -0
- package/dist/cli/chunks/{cursor-installer-FVJ7ROPJ.js → cursor-installer-X37VHIKW.js} +2 -2
- package/dist/cli/chunks/{daemon-D662EX5N.js → daemon-JN7SOH6F.js} +4 -4
- package/dist/cli/chunks/{daemon-7ZZA2MMN.js → daemon-LIW47IDM.js} +4 -4
- package/dist/cli/chunks/{dag-attention-scheduler-IB4TQ2KA.js → dag-attention-scheduler-QCHHIZBT.js} +2 -2
- package/dist/cli/chunks/{detect-LGLBZN4I.js → detect-WRFCWAX5.js} +2 -2
- package/dist/cli/chunks/{dist-node-Z3OL42YE.js → dist-node-6FWT4XZO.js} +2 -2
- package/dist/cli/chunks/{domain-handler-L3CLNL7U.js → domain-handler-SNFPNMRT.js} +2 -2
- package/dist/cli/chunks/{domain-plugins-GQ3V5X6L.js → domain-plugins-MXKHH62P.js} +2 -2
- package/dist/cli/chunks/domain-transfer-47UJNERX.js +2 -0
- package/dist/cli/chunks/dream-OSWAITPT.js +2 -0
- package/dist/cli/chunks/{embed-and-insert-pattern-UGD6USYH.js → embed-and-insert-pattern-LZFAUNBQ.js} +2 -2
- package/dist/cli/chunks/{eval-3B7UIYGY.js → eval-AMUXTMJB.js} +2 -2
- package/dist/cli/chunks/{experience-capture-middleware-3RQ4NYY3.js → experience-capture-middleware-3D65TR2C.js} +4 -4
- package/dist/cli/chunks/{fast-paths-QOSAEPYD.js → fast-paths-Y7BBMM56.js} +2 -2
- package/dist/cli/chunks/{feature-flags-TLF4NKOH.js → feature-flags-JMQQ7JW4.js} +2 -2
- package/dist/cli/chunks/{feature-flags-3S5TH6P4.js → feature-flags-VESRRQ6V.js} +2 -2
- package/dist/cli/chunks/{file-discovery-AEVMJRNB.js → file-discovery-JJKQQUV6.js} +2 -2
- package/dist/cli/chunks/{fleet-E6WTXWFL.js → fleet-WIGHICJF.js} +4 -4
- package/dist/cli/chunks/{gnn-wrapper-MCKH3AUU.js → gnn-wrapper-BFNPETTT.js} +2 -2
- package/dist/cli/chunks/{heartbeat-handler-U7XENHRR.js → heartbeat-handler-HDXKTGUI.js} +4 -4
- package/dist/cli/chunks/heartbeat-scheduler-BVRVVIE2.js +2 -0
- package/dist/cli/chunks/hnsw-adapter-MZTHXULS.js +2 -0
- package/dist/cli/chunks/hnsw-index-KHEX4VDG.js +2 -0
- package/dist/cli/chunks/{hnsw-legacy-bridge-5GW4SAEI.js → hnsw-legacy-bridge-6A7OTAPT.js} +2 -2
- package/dist/cli/chunks/{hnswlib-node-7BLZBK5T.js → hnswlib-node-LKV2H47B.js} +2 -2
- package/dist/cli/chunks/{hooks-F3O2SB6H.js → hooks-KDSFYQQG.js} +10 -10
- package/dist/cli/chunks/hybrid-backend-2B3LCLR4.js +2 -0
- package/dist/cli/chunks/{hypergraph-engine-PV4EKXHB.js → hypergraph-engine-GDLPEPUC.js} +2 -2
- package/dist/cli/chunks/{hypergraph-handler-VOWO5ZTW.js → hypergraph-handler-4UMFA2EW.js} +3 -3
- package/dist/cli/chunks/impact-analyzer-4R4VWOGQ.js +2 -0
- package/dist/cli/chunks/{init-handler-ENJ5ONJX.js → init-handler-4GCHPQHD.js} +6 -6
- package/dist/cli/chunks/init-wizard-TAOPXHHD.js +2 -0
- package/dist/cli/chunks/kernel-6I6VZUWY.js +2 -0
- package/dist/cli/chunks/{kilocode-installer-HNNJOOPE.js → kilocode-installer-HJZMT2G5.js} +2 -2
- package/dist/cli/chunks/{kiro-installer-UZBIQ3IC.js → kiro-installer-WUPY67HG.js} +2 -2
- package/dist/cli/chunks/knowledge-graph-KFMTTUR5.js +2 -0
- package/dist/cli/chunks/{learning-YMLCVFUT.js → learning-AXKIS7IG.js} +4 -4
- package/dist/cli/chunks/{llm-router-YWTARCCT.js → llm-router-HUDPNZLJ.js} +4 -4
- package/dist/cli/chunks/llm-router-service-2D74XVM3.js +2 -0
- package/dist/cli/chunks/{load-DKE3F3IP.js → load-RM44POD7.js} +2 -2
- package/dist/cli/chunks/load-test-53FWOWNS.js +2 -0
- package/dist/cli/chunks/{mcp-5PSGIUCW.js → mcp-5JVQRBOP.js} +2 -2
- package/dist/cli/chunks/{memory-3L3O6JMM.js → memory-VGZ2V6PL.js} +5 -5
- package/dist/cli/chunks/memory-backend-KFJDDPEZ.js +2 -0
- package/dist/cli/chunks/memory-handlers-EI537Z32.js +2 -0
- package/dist/cli/chunks/{multi-model-executor-AEEO7IA4.js → multi-model-executor-WPRKCSCM.js} +2 -2
- package/dist/cli/chunks/{opencode-installer-ABBO355U.js → opencode-installer-YAJMRCQO.js} +2 -2
- package/dist/cli/chunks/{orchestrator-E36Q7MKE.js → orchestrator-MUGWBUYP.js} +6 -6
- package/dist/cli/chunks/pattern-null-store-7DMU5CJ4.js +2 -0
- package/dist/cli/chunks/{pattern-usage-recorder-H4XKSID4.js → pattern-usage-recorder-ZQJJ2YNG.js} +2 -2
- package/dist/cli/chunks/{pipeline-BGFEHXIN.js → pipeline-F4DXDUDC.js} +2 -2
- package/dist/cli/chunks/{platform-GK7ZVDJI.js → platform-HI3A3OWF.js} +2 -2
- package/dist/cli/chunks/{plugin-CAH2CKI6.js → plugin-XRITPTR7.js} +2 -2
- package/dist/cli/chunks/{prime-radiant-advanced-wasm-M5EYRONA.js → prime-radiant-advanced-wasm-HHNJP7CQ.js} +2 -2
- package/dist/cli/chunks/{project-root-BSNZC243.js → project-root-2VN4WO2A.js} +2 -2
- package/dist/cli/chunks/protocol-executor-2EMTBTMG.js +2 -0
- package/dist/cli/chunks/{protocol-handler-JDSSC2SF.js → protocol-handler-ZEVHSEBG.js} +2 -2
- package/dist/cli/chunks/{prove-ANPTOZJE.js → prove-C4BLZWBS.js} +2 -2
- package/dist/cli/chunks/qe-reasoning-bank-VZHZZPHE.js +2 -0
- package/dist/cli/chunks/{quality-SXWGYRQR.js → quality-M3DTE4KK.js} +2 -2
- package/dist/cli/chunks/quality-gate-V6KS7ML3.js +7 -0
- package/dist/cli/chunks/queen-coordinator-7MYTTUHI.js +2 -0
- package/dist/cli/chunks/{real-embeddings-WSRYAOZM.js → real-embeddings-YWSE3IRT.js} +2 -2
- package/dist/cli/chunks/{ref-validation-AZ3LRWEK.js → ref-validation-ZWOTFA3T.js} +2 -2
- package/dist/cli/chunks/{roocode-installer-2QKGFIEU.js → roocode-installer-GJBIWETD.js} +2 -2
- package/dist/cli/chunks/router-ZD4LXAWA.js +2 -0
- package/dist/cli/chunks/routing-feedback-FSLMDVGD.js +2 -0
- package/dist/cli/chunks/{routing-handler-UYDC5MMD.js → routing-handler-CFYLGNAR.js} +2 -2
- package/dist/cli/chunks/{ruvector-commands-QXADPVEY.js → ruvector-commands-EDKG456B.js} +2 -2
- package/dist/cli/chunks/rvf-dual-writer-LTKTDRFS.js +2 -0
- package/dist/cli/chunks/rvf-migration-adapter-IF24EVC5.js +2 -0
- package/dist/cli/chunks/{rvf-migration-coordinator-GD4NBFKT.js → rvf-migration-coordinator-ZMEYMAI6.js} +2 -2
- package/dist/cli/chunks/rvf-native-adapter-E6JNBKMZ.js +2 -0
- package/dist/cli/chunks/{rvf-store-integrity-7SXG66IL.js → rvf-store-integrity-AH6PNJP6.js} +2 -2
- package/dist/cli/chunks/safe-db-F6TRB5KZ.js +2 -0
- package/dist/cli/chunks/schedule-HBD4BYTE.js +2 -0
- package/dist/cli/chunks/scheduler-6FYWPMQC.js +2 -0
- package/dist/cli/chunks/{security-YKB622PK.js → security-ZU2GW3ZM.js} +3 -3
- package/dist/cli/chunks/{shared-rvf-adapter-KMLAV7JK.js → shared-rvf-adapter-5FOVSL3T.js} +2 -2
- package/dist/cli/chunks/{shared-rvf-dual-writer-OYY27DFV.js → shared-rvf-dual-writer-IO4DC4XV.js} +2 -2
- package/dist/cli/chunks/sqlite-persistence-DOU72F5Z.js +2 -0
- package/dist/cli/chunks/{standalone-memory-2DOABVLC.js → standalone-memory-3UXDZ7HI.js} +2 -2
- package/dist/cli/chunks/{status-handler-EXRKETV7.js → status-handler-264CHTWS.js} +2 -2
- package/dist/cli/chunks/{structural-health-2SKK6DU6.js → structural-health-E2QPUOZE.js} +2 -2
- package/dist/cli/chunks/{sync-UW7SX7GO.js → sync-2ACMWM7D.js} +2 -2
- package/dist/cli/chunks/{sync-DQ2YUNI6.js → sync-N2L2OST4.js} +2 -2
- package/dist/cli/chunks/{task-handler-LYQ6WYUY.js → task-handler-IB5CVOTY.js} +2 -2
- package/dist/cli/chunks/{task-handlers-DIJO232S.js → task-handlers-QBMYNJHE.js} +3 -3
- package/dist/cli/chunks/{test-WRHZMUCW.js → test-7RGLRDSP.js} +6 -6
- package/dist/cli/chunks/{test-scheduling-HI23RXFK.js → test-scheduling-RJABJT2W.js} +3 -3
- package/dist/cli/chunks/{token-bootstrap-23SA6SWZ.js → token-bootstrap-JVHMHB72.js} +2 -2
- package/dist/cli/chunks/{token-usage-M7RRDPXO.js → token-usage-3ECHQVCY.js} +2 -2
- package/dist/cli/chunks/{transformers-4TC35KKS.js → transformers-KJH3IJWI.js} +2 -2
- package/dist/cli/chunks/{tree-sitter-wasm-parser-F4LTKAWD.js → tree-sitter-wasm-parser-XN6PFI32.js} +2 -2
- package/dist/cli/chunks/{types-NBXV6LXQ.js → types-5BAPXOLS.js} +2 -2
- package/dist/cli/chunks/unified-memory-GHAYAXWZ.js +2 -0
- package/dist/cli/chunks/unified-memory-hnsw-CCC63YXT.js +2 -0
- package/dist/cli/chunks/unified-persistence-HKRHI5PG.js +2 -0
- package/dist/cli/chunks/{upgrade-4BGOU5RM.js → upgrade-S5NFQZID.js} +2 -2
- package/dist/cli/chunks/{validate-EDWAR63H.js → validate-BIBWOLJD.js} +2 -2
- package/dist/cli/chunks/{validate-swarm-VI72CPR7.js → validate-swarm-WAA3LBHH.js} +2 -2
- package/dist/cli/chunks/visual-security-APOXJ3Q3.js +2 -0
- package/dist/cli/chunks/{web-tree-sitter-Y5XBRQXF.js → web-tree-sitter-OTBQTHAV.js} +2 -2
- package/dist/cli/chunks/{windsurf-installer-VEX23WAF.js → windsurf-installer-NNQ22EW6.js} +2 -2
- package/dist/cli/chunks/witness-chain-7IP5IJGT.js +2 -0
- package/dist/cli/chunks/{witness-chain-3YNL6YGY.js → witness-chain-E7MUBOJW.js} +2 -2
- package/dist/cli/chunks/{witness-chain-repair-MJZGZRWT.js → witness-chain-repair-FW4QSN4C.js} +2 -2
- package/dist/cli/chunks/{witness-chain-verifier-TTJYXTBE.js → witness-chain-verifier-YMROEBVL.js} +2 -2
- package/dist/cli/chunks/{witness-key-manager-EM6YXYOY.js → witness-key-manager-4CGRNDMJ.js} +2 -2
- package/dist/cli/chunks/{workflow-2RBDOM7V.js → workflow-4VRSTRAN.js} +4 -4
- package/dist/cli/chunks/workflow-orchestrator-2HNW5ZMQ.js +2 -0
- package/dist/cli/chunks/{wrappers-5OTAVVOV.js → wrappers-4M4UTGEU.js} +2 -2
- package/dist/cli/commands/ci.js +17 -6
- package/dist/cli/commands/quality-gate.js +6 -1
- package/dist/cli/index.js +7 -2
- package/dist/cli/process-store-cleanup.d.ts +7 -0
- package/dist/cli/process-store-cleanup.js +27 -0
- package/dist/cli/utils/ci-config.d.ts +3 -3
- package/dist/cli/utils/ci-config.js +202 -68
- package/dist/domains/quality-assessment/quality-evidence.d.ts +3 -1
- package/dist/domains/quality-assessment/quality-evidence.js +7 -2
- package/dist/domains/test-execution/services/retry-handler.js +32 -13
- package/dist/domains/test-execution/services/test-executor.d.ts +3 -3
- package/dist/domains/test-execution/services/test-executor.js +66 -22
- package/dist/init/fleet-integration.js +3 -2
- package/dist/init/init-wizard-steps.js +3 -2
- package/dist/init/phases/06-code-intelligence.js +6 -4
- package/dist/integrations/ruvector/sona-persistence.d.ts +1 -0
- package/dist/integrations/ruvector/sona-persistence.js +74 -20
- package/dist/integrations/ruvector/sona-wrapper.d.ts +2 -0
- package/dist/integrations/ruvector/sona-wrapper.js +13 -0
- package/dist/kernel/memory-backend.js +5 -4
- package/dist/kernel/unified-memory.js +3 -2
- package/dist/learning/aqe-learning-engine.js +3 -2
- package/dist/mcp/bundle.js +440 -439
- package/dist/mcp/connection-pool.d.ts +2 -0
- package/dist/mcp/connection-pool.js +13 -2
- package/dist/mcp/handlers/memory-handlers.d.ts +1 -0
- package/dist/mcp/handlers/memory-handlers.js +16 -6
- package/dist/mcp/protocol-server.js +29 -8
- package/dist/mcp/types.d.ts +2 -0
- package/dist/optimization/session-cache.js +13 -11
- package/dist/plugins/cache.js +10 -3
- package/dist/shared/embeddings/embedding-cache.js +4 -4
- package/dist/shared/llm/cache.js +7 -10
- package/dist/shared/retry-engine.js +4 -0
- package/dist/shared/test-runner-process.d.ts +10 -0
- package/dist/shared/test-runner-process.js +210 -0
- package/dist/validation/quality-verdict.js +3 -2
- package/dist/workers/quality-daemon/priority-queue.js +4 -1
- package/package.json +4 -4
- package/dist/cli/chunks/adapter-TVQKH65T.js +0 -2
- package/dist/cli/chunks/aqe-learning-engine-ULGTVVWE.js +0 -2
- package/dist/cli/chunks/base-W42BURDL.js +0 -2
- package/dist/cli/chunks/browser-workflow-HKGHFFFT.js +0 -2
- package/dist/cli/chunks/chunk-2IMSJ7IO.js +0 -2
- package/dist/cli/chunks/chunk-FBZC4IGB.js +0 -2
- package/dist/cli/chunks/chunk-MNQN7UZX.js +0 -4
- package/dist/cli/chunks/chunk-OXHF3L2T.js +0 -2
- package/dist/cli/chunks/chunk-PELENDDQ.js +0 -2
- package/dist/cli/chunks/chunk-TW3SR4TS.js +0 -2
- package/dist/cli/chunks/chunk-V6RE4YRQ.js +0 -2
- package/dist/cli/chunks/chunk-ZQZD55MN.js +0 -3
- package/dist/cli/chunks/ci-J3TDK5RA.js +0 -81
- package/dist/cli/chunks/client-3BD2DI4N.js +0 -2
- package/dist/cli/chunks/core-handlers-C3H2ZCS2.js +0 -2
- package/dist/cli/chunks/cross-domain-router-JCQ7SWDP.js +0 -2
- package/dist/cli/chunks/domain-transfer-MFCI76IY.js +0 -2
- package/dist/cli/chunks/dream-FTP33IJB.js +0 -2
- package/dist/cli/chunks/heartbeat-scheduler-HXBJVJL2.js +0 -2
- package/dist/cli/chunks/hnsw-adapter-TU6WG2ME.js +0 -2
- package/dist/cli/chunks/hnsw-index-MS5KODD7.js +0 -2
- package/dist/cli/chunks/hybrid-backend-HT45LBHC.js +0 -2
- package/dist/cli/chunks/impact-analyzer-AP4AGTG5.js +0 -2
- package/dist/cli/chunks/init-wizard-I5DFZUQL.js +0 -2
- package/dist/cli/chunks/kernel-MISPSPPA.js +0 -2
- package/dist/cli/chunks/knowledge-graph-L26JESGE.js +0 -2
- package/dist/cli/chunks/llm-router-service-MWGC43ZA.js +0 -2
- package/dist/cli/chunks/load-test-H5ISNNM5.js +0 -2
- package/dist/cli/chunks/memory-backend-HWDNOBKW.js +0 -2
- package/dist/cli/chunks/memory-handlers-ZFDVQZM5.js +0 -2
- package/dist/cli/chunks/pattern-null-store-GQP6ICWK.js +0 -2
- package/dist/cli/chunks/protocol-executor-AD5A4DAI.js +0 -2
- package/dist/cli/chunks/qe-reasoning-bank-W3Z2PKTR.js +0 -2
- package/dist/cli/chunks/quality-gate-GYNCA4ZY.js +0 -7
- package/dist/cli/chunks/queen-coordinator-HQRHLIJX.js +0 -2
- package/dist/cli/chunks/router-MTP5LH4H.js +0 -2
- package/dist/cli/chunks/routing-feedback-GWETVB4L.js +0 -2
- package/dist/cli/chunks/rvf-dual-writer-4UE5S7WP.js +0 -2
- package/dist/cli/chunks/rvf-migration-adapter-PHH3HF4Q.js +0 -2
- package/dist/cli/chunks/rvf-native-adapter-KTLZBUWV.js +0 -2
- package/dist/cli/chunks/safe-db-FWWGAPVE.js +0 -2
- package/dist/cli/chunks/schedule-TPA4V4D5.js +0 -2
- package/dist/cli/chunks/scheduler-5ZTEPNDD.js +0 -2
- package/dist/cli/chunks/sqlite-persistence-HPTT624C.js +0 -2
- package/dist/cli/chunks/unified-memory-OVFEPRPS.js +0 -2
- package/dist/cli/chunks/unified-memory-hnsw-KKRSCZHR.js +0 -2
- package/dist/cli/chunks/unified-persistence-7GLR4RI3.js +0 -2
- package/dist/cli/chunks/visual-security-2FUM5GLI.js +0 -2
- package/dist/cli/chunks/witness-chain-MH6GA5L6.js +0 -2
- package/dist/cli/chunks/workflow-orchestrator-H6G65YKU.js +0 -2
|
@@ -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.
|
|
2
|
-
import{d as
|
|
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.8");process.exit(0)}
|
|
2
|
+
import{d as W,f as it}from"./chunk-RTD4U7IW.js";import{b as I,d as de}from"./chunk-BITFGVZ4.js";import{a as Y,c as ot}from"./chunk-A5CLVZC3.js";import{a as le,d as F,e as ge,f as pe}from"./chunk-LQVS5IWH.js";import{a as X,b as ue,e as st}from"./chunk-VCSNNLWL.js";import{a as _e,c as me,d as at}from"./chunk-T6W2EYHC.js";import{a as tt}from"./chunk-U64QORFO.js";import{e as Te}from"./chunk-J5HTQHJK.js";import{a as O,e as ce}from"./chunk-HPVYJ6JH.js";import{a as H,b as y,c as nt}from"./chunk-Z5UZOYQS.js";import{a as Ee,b as rt}from"./chunk-SPS472C5.js";import{b as R,d as et}from"./chunk-XAESN54Q.js";import{createHash as Se}from"node:crypto";function Tt(n){let e=Buffer.alloc(8);return e.writeBigUInt64LE(BigInt(n)),e}function Et(n){return typeof n=="string"?Buffer.from(n,"utf8"):n instanceof Uint8Array?Buffer.from(n):Buffer.from($(n),"utf8")}function $(n){return n===null||typeof n!="object"?JSON.stringify(n)??"null":Array.isArray(n)?`[${n.map($).join(",")}]`:`{${Object.keys(n).sort().map(t=>`${JSON.stringify(t)}:${$(n[t])}`).join(",")}}`}function he(...n){let e=Se("sha256");for(let t of n)e.update(t);return e.digest()}function Ne(n,e,t){return he(ct,n,e,Tt(t))}var ct,fe,A,Re=R(()=>{"use strict";ct=Buffer.from("ruvector:chain:"),fe=Se("sha256").update("ruvector-proof-gate-v1").digest();A=class n{seq=0;prev=fe;chain=[];payloadHashes=[];admit(e){let t=he(Et(e)),r=Ne(this.prev,t,this.seq);this.prev=r,this.chain.push(r),this.payloadHashes.push(t);let i={sequence:this.seq,payloadHash:t.toString("hex"),chainCommitment:r.toString("hex")};return this.seq+=1,i}verifyReceipt(e){return e.sequence>=0&&e.sequence<this.chain.length&&this.chain[e.sequence].toString("hex")===e.chainCommitment}chainRoot(){return this.prev.toString("hex")}get length(){return this.seq}get isEmpty(){return this.seq===0}verifyIntegrity(){if(this.chain.length!==this.payloadHashes.length)return!1;let e=fe;for(let t=0;t<this.chain.length;t++){if(!Ne(e,this.payloadHashes[t],t).equals(this.chain[t]))return!1;e=this.chain[t]}return e.equals(this.prev)}toJSON(){return{seq:this.seq,head:this.prev.toString("hex"),chain:this.chain.map(e=>e.toString("hex")),payloadHashes:this.payloadHashes.map(e=>e.toString("hex"))}}static fromJSON(e){let t=new n;t.seq=e.seq,t.prev=Buffer.from(e.head,"hex");for(let r of e.chain)t.chain.push(Buffer.from(r,"hex"));for(let r of e.payloadHashes)t.payloadHashes.push(Buffer.from(r,"hex"));return t}}});function v(n){if(!K.has(n))throw new Error(`Invalid table name: "${n}" is not in the allowlist`);return n}function It(n){let e=n.split(".");if(e.length>2)throw new Error(`Invalid SQL identifier: "${n}" has too many parts (max: schema.table)`);for(let t of e)if(!Le.test(t))throw new Error(`Invalid SQL identifier: "${n}" \u2014 part "${t}" does not match pattern ${Le}`);return n}var K,Le,V=R(()=>{"use strict";K=new Set(["schema_version","kv_store","vectors","rl_q_values","goap_goals","goap_actions","goap_plans","goap_plan_signatures","concept_nodes","concept_edges","dream_cycles","dream_insights","qe_patterns","qe_pattern_embeddings","qe_pattern_usage","qe_trajectories","embeddings","execution_results","executed_steps","mincut_snapshots","mincut_history","mincut_weak_vertices","mincut_alerts","mincut_healing_actions","mincut_observations","sona_patterns","sona_fisher_matrices","test_outcomes","routing_outcomes","coverage_sessions","patterns","hypergraph_nodes","hypergraph_edges","hypergraph_vertices","hypergraph_hyperedges","hypergraph_edge_vertices","hypergraph_vertex_properties","hypergraph_edge_properties","captured_experiences","experience_applications","witness_chain","witness_chain_receipts","witness_chain_archive","trajectories","trajectory_steps","pattern_evolution_events","pattern_relationships","pattern_versions","learning_daily_snapshots","metrics_outcomes","experience_consolidation_log","qe_pattern_reuse","learning_evidence_manifests","learning_evidence_segments","learning_segment_edges","learning_evidence_admissions","pattern_manifest_lineage","pattern_segment_lineage","qe_agent_co_execution"]);Le=/^[a-z_][a-z0-9_]{0,62}$/});function Ce(n){n.exec(Ie),n.exec(`
|
|
3
3
|
INSERT OR IGNORE INTO learning_evidence_manifests (
|
|
4
4
|
id, trajectory_id, trajectory_hash, manifest_hash, task_family,
|
|
5
5
|
outcome, oracle_refs_json, source_kind, process_signals_json
|
|
@@ -732,16 +732,16 @@ import{d as H,f as it}from"./chunk-ZELWDJXT.js";import{b as I,d as ge}from"./chu
|
|
|
732
732
|
CREATE INDEX IF NOT EXISTS idx_coverage_sessions_agent ON coverage_sessions(agent_id);
|
|
733
733
|
CREATE INDEX IF NOT EXISTS idx_coverage_sessions_created ON coverage_sessions(created_at);
|
|
734
734
|
`,Me=["kv_store","vectors","rl_q_values","goap_actions","goap_goals","goap_plans","goap_plan_signatures","goap_execution_steps","concept_nodes","concept_edges","dream_cycles","dream_insights","qe_patterns","qe_pattern_embeddings","qe_pattern_usage","qe_trajectories","embeddings","execution_results","executed_steps","mincut_snapshots","mincut_history","mincut_weak_vertices","mincut_alerts","mincut_healing_actions","mincut_observations","hypergraph_nodes","hypergraph_edges","sona_patterns","witness_chain","learning_evidence_manifests","learning_evidence_segments","learning_segment_edges","learning_evidence_admissions","pattern_manifest_lineage","pattern_segment_lineage"]});function ne(n,e,t){return n.prepare("SELECT 1 FROM sqlite_master WHERE type = ? AND name = ?").get(e,t)!==void 0}function ke(n){return n.replace(/\s+/g," ").trim().replace(/^CREATE TRIGGER IF NOT EXISTS /i,"CREATE TRIGGER ").replace(/ ?;$/,"").toLowerCase()}function w(n,e){return n.prepare(e).get()?.n??0}function Ge(n){let e=ne(n,"table","qe_patterns_fts"),t=e&&ne(n,"table","qe_patterns_fts_docsize"),r=[],i=[],o=n.prepare("SELECT sql FROM sqlite_master WHERE type = 'trigger' AND name = ?");for(let u of dt){let l=o.get(u);l===void 0?r.push(u):ke(l.sql??"")!==ut[u]&&i.push(u)}let E=w(n,"SELECT count(*) AS n FROM qe_patterns"),c=t?w(n,"SELECT count(*) AS n FROM qe_patterns_fts_docsize"):-1,T=t&&c===E?w(n,`SELECT count(*) AS n FROM qe_patterns p
|
|
735
|
-
WHERE NOT EXISTS (SELECT 1 FROM qe_patterns_fts_docsize d WHERE d.id = p.rowid)`):0;return{hasTable:e,hasDocsize:t,missingTriggers:r,mismatchedTriggers:i,patterns:E,indexed:c,unindexed:T}}function Pe(n){return!n.hasTable||n.missingTriggers.length>0||n.mismatchedTriggers.length>0?!0:n.hasDocsize?n.indexed!==n.patterns||n.unindexed>0:!1}function lt(n){if(n.readonly)return!0;try{return Number(n.pragma("query_only",{simple:!0}))===1}catch{return!1}}function qe(n,e={}){let t=e.log??(o=>console.warn(o)),r=e.logPrefix??"[PatternFTS]",i={status:"healthy",createdTable:!1,recreatedTriggers:[],replacedTriggers:[],rebuilt:!1,patternsBefore:-1,indexedBefore:-1,indexedAfter:-1};try{if(!ne(n,"table","qe_patterns"))return i.status="no-patterns",i;if(lt(n))return i.status="readonly",i;let o=Ge(n);if(i.patternsBefore=o.patterns,i.indexedBefore=o.indexed,!Pe(o))return i;let E=n.transaction(()=>{let c=Ge(n);if(!Pe(c))return null;c.hasTable||n.exec(Z);for(let T of c.missingTriggers)n.exec(b[T]);for(let T of c.mismatchedTriggers)n.exec(`DROP TRIGGER IF EXISTS ${T}`),n.exec(b[T]);return n.exec("INSERT INTO qe_patterns_fts(qe_patterns_fts) VALUES('rebuild')"),{s:c,indexedAfter:w(n,"SELECT count(*) AS n FROM qe_patterns_fts_docsize")}}).immediate();if(E){let{s:c}=E;i.createdTable=!c.hasTable,i.recreatedTriggers=[...c.missingTriggers],i.replacedTriggers=[...c.mismatchedTriggers],i.patternsBefore=c.patterns,i.indexedBefore=c.indexed,i.indexedAfter=E.indexedAfter,i.rebuilt=!0}if(i.rebuilt){i.status="healed";let c=[];i.createdTable&&c.push("created qe_patterns_fts"),i.recreatedTriggers.length>0&&c.push(`recreated triggers [${i.recreatedTriggers.join(", ")}]`),i.replacedTriggers.length>0&&c.push(`replaced triggers [${i.replacedTriggers.join(", ")}]`);let T=i.indexedBefore<0?"n/a":String(i.indexedBefore);c.push(`rebuilt index (indexed ${T} -> ${i.indexedAfter}, qe_patterns ${i.patternsBefore})`),t(`${r} Healed qe_patterns FTS5 index: ${c.join("; ")}`)}return i}catch(o){i.status="failed",i.error=O(o);try{t(`${r} qe_patterns FTS5 self-heal skipped: ${i.error} (keyword search may be degraded; vector search unaffected)`)}catch{}return i}}var dt,ut,Be=R(()=>{"use strict";ce();te();dt=Object.keys(b);ut=Object.freeze(Object.fromEntries(Object.entries(b).map(([n,e])=>[n,ke(e)])))});function M(n,e,t){let r={value:e,timestamp:t??(e!==void 0?Date.now():0),nodeId:e!==void 0?n:"",version:e!==void 0?1:0,lastUpdated:Date.now()};function i(o,E,c,T){return o!==c?o-c:E.localeCompare(T)}return{get(){return r.value},set(o,E){let c=E??Date.now();(r.timestamp===0||i(c,n,r.timestamp,r.nodeId)>0)&&(r={value:o,timestamp:c,nodeId:n,version:r.version+1,lastUpdated:Date.now()})},merge(o){let E=o.getState();this.applyState(E)},getState(){return{value:r.value,timestamp:r.timestamp,nodeId:r.nodeId,version:r.version,lastUpdated:r.lastUpdated}},applyState(o){(r.timestamp===0||i(o.timestamp,o.nodeId,r.timestamp,r.nodeId)>0)&&(r={value:o.value,timestamp:o.timestamp,nodeId:o.nodeId,version:Math.max(r.version,o.version)+1,lastUpdated:Date.now()})},getNodeId(){return n},getTimestamp(){return r.timestamp}}}function G(n,e){let t=M(n);return t.applyState(e),t}var re=R(()=>{"use strict"});function C(n){let e={counts:{},version:0,lastUpdated:Date.now()};return e.counts[n]=0,{get(){return Object.values(e.counts).reduce((t,r)=>t+r,0)},increment(t=1){if(t<0)throw new Error("G-Counter can only increment by positive values");t!==0&&(e.counts[n]=(e.counts[n]||0)+t,e.version++,e.lastUpdated=Date.now())},merge(t){let r=t.getState();this.applyState(r)},getState(){return{counts:{...e.counts},version:e.version,lastUpdated:e.lastUpdated}},applyState(t){let r=!1;for(let[i,o]of Object.entries(t.counts)){let E=e.counts[i]||0;o>E&&(e.counts[i]=o,r=!0)}r&&(e.version=Math.max(e.version,t.version)+1,e.lastUpdated=Date.now())},getNodeId(){return n},getLocalCount(){return e.counts[n]||0}}}function P(n,e){let t=C(n);return t.applyState(e),t}var k=R(()=>{"use strict"});function q(n){let e=C(n),t=C(n),r=0,i=Date.now();return{get(){return e.get()-t.get()},increment(o=1){if(o<0)throw new Error("Use decrement() for negative values");o!==0&&(e.increment(o),r++,i=Date.now())},decrement(o=1){if(o<0)throw new Error("Use increment() for negative values");o!==0&&(t.increment(o),r++,i=Date.now())},merge(o){let E=o.getState();this.applyState(E)},getState(){return{positive:e.getState(),negative:t.getState(),version:r,lastUpdated:i}},applyState(o){let E=this.get();e.applyState(o.positive),t.applyState(o.negative);let c=this.get();E!==c&&(r=Math.max(r,o.version)+1,i=Date.now())},getNodeId(){return n}}}function B(n,e){let t=q(n);return t.applyState(e),t}var se=R(()=>{"use strict";k()});function gt(n,e){return`${n}:${Date.now()}:${e}`}function ie(n){return typeof n=="string"?`s:${n}`:typeof n=="number"?`n:${n}`:typeof n=="boolean"?`b:${n}`:`j:${JSON.stringify(n)}`}function pt(n){let e=n.substring(0,2),t=n.substring(2);switch(e){case"s:":return t;case"n:":return Number(t);case"b:":return t==="true";case"j:":return I(t);default:throw new Error(`Unknown serialization type: ${e}`)}}function j(n){let e=new Map,t=new Map,r=0,i=Date.now(),o=0;function E(T){let u=e.get(T);if(!u||u.size===0)return!1;let l=t.get(T);if(!l||l.size===0)return!0;for(let m of u)if(!l.has(m))return!0;return!1}function c(T){let u=e.get(T);if(!u)return new Set;let l=t.get(T)||new Set,m=new Set;for(let p of u)l.has(p)||m.add(p);return m}return{has(T){let u=ie(T);return E(u)},values(){let T=[];for(let[u]of e)E(u)&&T.push(pt(u));return T},size(){let T=0;for(let[u]of e)E(u)&&T++;return T},add(T){let u=ie(T),l=gt(n,o++);e.has(u)||e.set(u,new Set),e.get(u).add(l),r++,i=Date.now()},remove(T){let u=ie(T),l=e.get(u);if(!l||l.size===0)return;t.has(u)||t.set(u,new Set);let m=t.get(u);for(let p of l)m.add(p);r++,i=Date.now()},merge(T){let u=T.getState();this.applyState(u)},getState(){let T={};for(let[l,m]of e)T[l]=Array.from(m);let u={};for(let[l,m]of t)m.size>0&&(u[l]=Array.from(m));return{elements:T,tombstones:u,version:r,lastUpdated:i}},applyState(T){let u=!1;for(let[l,m]of Object.entries(T.elements)){e.has(l)||e.set(l,new Set);let p=e.get(l);for(let g of m)p.has(g)||(p.add(g),u=!0)}for(let[l,m]of Object.entries(T.tombstones)){t.has(l)||t.set(l,new Set);let p=t.get(l);for(let g of m)p.has(g)||(p.add(g),u=!0)}u&&(r=Math.max(r,T.version)+1,i=Date.now())},getNodeId(){return n},clear(){for(let[T,u]of e){t.has(T)||t.set(T,new Set);let l=t.get(T);for(let m of u)l.add(m)}r++,i=Date.now()}}}function z(n,e){let t=j(n);return t.applyState(e),t}var oe=R(()=>{"use strict";ge()});function ae(n){let e={..._t,...n},{nodeId:t,enableDeltaTracking:r,maxDeltaHistory:i}=e,o=new Map,E=new Map,c=new Map,T=new Map,u=0,l=[],m=new Set,p={registers:new Set,gCounters:new Set,pnCounters:new Set,sets:new Set};function g(a,s,d){let N={key:a,type:s,operation:d,timestamp:Date.now(),nodeId:t};for(let Je of m)try{Je(N)}catch(Ze){console.error("[CRDTStore] Error in change listener:",Ze)}}function _(a,s){u++,r&&p[a].add(s)}function L(){if(!r||!(p.registers.size>0||p.gCounters.size>0||p.pnCounters.size>0||p.sets.size>0))return;let s={fromVersion:l.length>0?l[l.length-1].toVersion:0,toVersion:u,timestamp:Date.now(),nodeId:t};if(p.registers.size>0){s.registers={};for(let d of p.registers){let N=o.get(d);N&&(s.registers[d]=N.getState())}p.registers.clear()}if(p.gCounters.size>0){s.gCounters={};for(let d of p.gCounters){let N=E.get(d);N&&(s.gCounters[d]=N.getState())}p.gCounters.clear()}if(p.pnCounters.size>0){s.pnCounters={};for(let d of p.pnCounters){let N=c.get(d);N&&(s.pnCounters[d]=N.getState())}p.pnCounters.clear()}if(p.sets.size>0){s.sets={};for(let d of p.sets){let N=T.get(d);N&&(s.sets[d]=N.getState())}p.sets.clear()}for(l.push(s);l.length>i;)l.shift()}let h={getRegister(a){return o.has(a)||o.set(a,M(t)),o.get(a)},setRegister(a,s){h.getRegister(a).set(s),_("registers",a),g(a,"lww-register","set")},hasRegister(a){return o.has(a)},deleteRegister(a){let s=o.delete(a);return s&&_("registers",a),s},getGCounter(a){return E.has(a)||E.set(a,C(t)),E.get(a)},incrementGCounter(a,s){h.getGCounter(a).increment(s),_("gCounters",a),g(a,"g-counter","increment")},hasGCounter(a){return E.has(a)},deleteGCounter(a){let s=E.delete(a);return s&&_("gCounters",a),s},getCounter(a){return c.has(a)||c.set(a,q(t)),c.get(a)},incrementCounter(a,s){h.getCounter(a).increment(s),_("pnCounters",a),g(a,"pn-counter","increment")},decrementCounter(a,s){h.getCounter(a).decrement(s),_("pnCounters",a),g(a,"pn-counter","decrement")},hasCounter(a){return c.has(a)},deleteCounter(a){let s=c.delete(a);return s&&_("pnCounters",a),s},getSet(a){return T.has(a)||T.set(a,j(t)),T.get(a)},addToSet(a,s){h.getSet(a).add(s),_("sets",a),g(a,"or-set","add")},removeFromSet(a,s){h.getSet(a).remove(s),_("sets",a),g(a,"or-set","remove")},hasSet(a){return T.has(a)},deleteSet(a){let s=T.delete(a);return s&&_("sets",a),s},merge(a){let s=a.getState();h.applyState(s)},getState(){L();let a={version:u,timestamp:Date.now(),nodeId:t,registers:{},gCounters:{},pnCounters:{},sets:{}};for(let[s,d]of o)a.registers[s]=d.getState();for(let[s,d]of E)a.gCounters[s]=d.getState();for(let[s,d]of c)a.pnCounters[s]=d.getState();for(let[s,d]of T)a.sets[s]=d.getState();return a},applyState(a){for(let[s,d]of Object.entries(a.registers))o.has(s)?o.get(s).applyState(d):o.set(s,G(t,d)),_("registers",s),g(s,"lww-register","merge");for(let[s,d]of Object.entries(a.gCounters))E.has(s)?E.get(s).applyState(d):E.set(s,P(t,d)),_("gCounters",s),g(s,"g-counter","merge");for(let[s,d]of Object.entries(a.pnCounters))c.has(s)?c.get(s).applyState(d):c.set(s,B(t,d)),_("pnCounters",s),g(s,"pn-counter","merge");for(let[s,d]of Object.entries(a.sets))T.has(s)?T.get(s).applyState(d):T.set(s,z(t,d)),_("sets",s),g(s,"or-set","merge");u=Math.max(u,a.version)+1},getDelta(a){if(L(),l.length===0)return a>=u,null;let s=l.filter(N=>N.toVersion>a);if(s.length===0)return null;let d={fromVersion:a,toVersion:u,timestamp:Date.now(),nodeId:t,registers:{},gCounters:{},pnCounters:{},sets:{}};for(let N of s)N.registers&&Object.assign(d.registers,N.registers),N.gCounters&&Object.assign(d.gCounters,N.gCounters),N.pnCounters&&Object.assign(d.pnCounters,N.pnCounters),N.sets&&Object.assign(d.sets,N.sets);return Object.keys(d.registers).length===0&&delete d.registers,Object.keys(d.gCounters).length===0&&delete d.gCounters,Object.keys(d.pnCounters).length===0&&delete d.pnCounters,Object.keys(d.sets).length===0&&delete d.sets,d},applyDelta(a){if(a.registers)for(let[s,d]of Object.entries(a.registers))o.has(s)?o.get(s).applyState(d):o.set(s,G(t,d)),_("registers",s),g(s,"lww-register","merge");if(a.gCounters)for(let[s,d]of Object.entries(a.gCounters))E.has(s)?E.get(s).applyState(d):E.set(s,P(t,d)),_("gCounters",s),g(s,"g-counter","merge");if(a.pnCounters)for(let[s,d]of Object.entries(a.pnCounters))c.has(s)?c.get(s).applyState(d):c.set(s,B(t,d)),_("pnCounters",s),g(s,"pn-counter","merge");if(a.sets)for(let[s,d]of Object.entries(a.sets))T.has(s)?T.get(s).applyState(d):T.set(s,z(t,d)),_("sets",s),g(s,"or-set","merge");u=Math.max(u,a.toVersion)+1},getVersion(){return u},getNodeId(){return t},on(a,s){if(a==="change")return m.add(s),()=>{m.delete(s)};throw new Error(`Unknown event type: ${a}`)},removeAllListeners(){m.clear()},keys(a){let s=[];return(!a||a==="lww-register")&&s.push(...Array.from(o.keys())),(!a||a==="g-counter")&&s.push(...Array.from(E.keys())),(!a||a==="pn-counter")&&s.push(...Array.from(c.keys())),(!a||a==="or-set")&&s.push(...Array.from(T.keys())),s},clear(){o.clear(),E.clear(),c.clear(),T.clear(),l.length=0,p.registers.clear(),p.gCounters.clear(),p.pnCounters.clear(),p.sets.clear(),u=0},getStats(){return{total:o.size+E.size+c.size+T.size,registers:o.size,gCounters:E.size,pnCounters:c.size,sets:T.size,version:u,nodeId:t,deltaHistorySize:l.length}}};return h}var _t,je=R(()=>{"use strict";re();k();se();oe();_t={nodeId:"default-node",enableDeltaTracking:!0,maxDeltaHistory:100}});var ze=R(()=>{"use strict"});var He=R(()=>{"use strict";re();k();se();oe();je();ze()});var St={};et(St,{ALLOWED_TABLE_NAMES:()=>K,BinaryHeap:()=>pe,DEFAULT_UNIFIED_MEMORY_CONFIG:()=>Ke,UnifiedHnswIndex:()=>F,UnifiedMemoryManager:()=>D,clearProjectRootCache:()=>Y,createHnswIndex:()=>_e,findProjectRoot:()=>X,getDefaultDbPath:()=>$e,getResolvedDefaultConfig:()=>Ve,getUnifiedMemory:()=>Qe,initializeUnifiedMemory:()=>mt,resetUnifiedMemory:()=>ft,validateTableName:()=>v});import*as f from"fs";import*as Ye from"os";import*as S from"path";function $e(){let n=X();return S.join(n,".agentic-qe","memory.db")}function Ve(){return{...Ke,dbPath:$e()}}function Qe(n){return D.getInstance(n)}async function mt(n){let e=Qe(n);return await e.initialize(),e}function ft(){D.resetInstance()}function Nt(){if(We)return;We=!0;let n=()=>{try{let t=D.instance;t&&t.close()}catch(t){console.debug("[UnifiedMemory] Cleanup error:",t instanceof Error?t.message:t)}};process.on("beforeExit",n),Ee(n);let e=t=>{de(t)||(n(),process.exit(0))};process.on("SIGINT",e),process.on("SIGTERM",e)}var U,Ke,D,We,ht=R(()=>{st();ge();ce();rt();tt();Re();V();V();me();me();te();Be();Q();He();at();nt();U=Te.create("unified-memory");Ke={dbPath:".agentic-qe/memory.db",walMode:!0,mmapSize:y.MMAP_SIZE_BYTES,cacheSize:y.CACHE_SIZE_KB,busyTimeout:y.BUSY_TIMEOUT_MS,vectorDimensions:y.DEFAULT_VECTOR_DIMENSIONS};D=class n{static instance=null;static instancePromise=null;db=null;config;initialized=!1;vectorsLoaded=!1;initPromise=null;preparedStatements=new Map;vectorIndex=new F("qe-memory");crdtStore=null;proofGate=null;proofGateEnvChecked=!1;static PROOF_NS="__proofgate__";static PROOF_KEY="chain";constructor(e){let t=Ve();if(this.config={...t,...e},process.env.AQE_MEMORY_BACKEND==="memory"){this.config.dbPath=":memory:";return}if(this.config.dbPath!==":memory:"&&!S.isAbsolute(this.config.dbPath)){let r=X();this.config.dbPath=S.join(r,this.config.dbPath)}}static getInstance(e){return n.instance||(n.instance=new n(e)),n.instance}static async getInstanceAsync(e){return n.instance?.initialized?n.instance:(n.instancePromise||(n.instancePromise=(async()=>{let t=n.getInstance(e);return await t.initialize(),t})()),n.instancePromise)}static resetInstance(){n.instance&&(n.instance.close(),n.instance=null),n.instancePromise=null,Y()}async initialize(e){if(!this.initialized)return this.initPromise||(this.initPromise=this._doInitialize(e?.signal)),this.initPromise}async _doInitialize(e){if(!this.initialized){e?.throwIfAborted();try{let t=this.config.dbPath===":memory:",r="",i=!1,o=0;if(!t){let E=process.env.AQE_PROJECT_ROOT;if(E){let c=S.resolve(this.config.dbPath),T=S.resolve(E);!c.startsWith(T)&&!c.startsWith(Ye.tmpdir())&&c.includes(".agentic-qe")&&(console.error(`[UnifiedMemory] WARNING: DB path "${this.config.dbPath}" points to a production .agentic-qe/ while AQE_PROJECT_ROOT="${E}". Redirecting to test-safe path.`),this.config.dbPath=S.join(E,".agentic-qe","memory.db"))}if(r=S.dirname(this.config.dbPath),f.existsSync(r)||f.mkdirSync(r,{recursive:!0}),i=f.existsSync(this.config.dbPath),i)o=f.statSync(this.config.dbPath).size;else if(f.existsSync(r)){let c=this.findRecentBackups(r);if(c.length>0){let T=c[0];console.error(`[UnifiedMemory] CRITICAL: Database file missing but directory exists!
|
|
735
|
+
WHERE NOT EXISTS (SELECT 1 FROM qe_patterns_fts_docsize d WHERE d.id = p.rowid)`):0;return{hasTable:e,hasDocsize:t,missingTriggers:r,mismatchedTriggers:i,patterns:E,indexed:c,unindexed:T}}function Pe(n){return!n.hasTable||n.missingTriggers.length>0||n.mismatchedTriggers.length>0?!0:n.hasDocsize?n.indexed!==n.patterns||n.unindexed>0:!1}function lt(n){if(n.readonly)return!0;try{return Number(n.pragma("query_only",{simple:!0}))===1}catch{return!1}}function qe(n,e={}){let t=e.log??(o=>console.warn(o)),r=e.logPrefix??"[PatternFTS]",i={status:"healthy",createdTable:!1,recreatedTriggers:[],replacedTriggers:[],rebuilt:!1,patternsBefore:-1,indexedBefore:-1,indexedAfter:-1};try{if(!ne(n,"table","qe_patterns"))return i.status="no-patterns",i;if(lt(n))return i.status="readonly",i;let o=Ge(n);if(i.patternsBefore=o.patterns,i.indexedBefore=o.indexed,!Pe(o))return i;let E=n.transaction(()=>{let c=Ge(n);if(!Pe(c))return null;c.hasTable||n.exec(Z);for(let T of c.missingTriggers)n.exec(b[T]);for(let T of c.mismatchedTriggers)n.exec(`DROP TRIGGER IF EXISTS ${T}`),n.exec(b[T]);return n.exec("INSERT INTO qe_patterns_fts(qe_patterns_fts) VALUES('rebuild')"),{s:c,indexedAfter:w(n,"SELECT count(*) AS n FROM qe_patterns_fts_docsize")}}).immediate();if(E){let{s:c}=E;i.createdTable=!c.hasTable,i.recreatedTriggers=[...c.missingTriggers],i.replacedTriggers=[...c.mismatchedTriggers],i.patternsBefore=c.patterns,i.indexedBefore=c.indexed,i.indexedAfter=E.indexedAfter,i.rebuilt=!0}if(i.rebuilt){i.status="healed";let c=[];i.createdTable&&c.push("created qe_patterns_fts"),i.recreatedTriggers.length>0&&c.push(`recreated triggers [${i.recreatedTriggers.join(", ")}]`),i.replacedTriggers.length>0&&c.push(`replaced triggers [${i.replacedTriggers.join(", ")}]`);let T=i.indexedBefore<0?"n/a":String(i.indexedBefore);c.push(`rebuilt index (indexed ${T} -> ${i.indexedAfter}, qe_patterns ${i.patternsBefore})`),t(`${r} Healed qe_patterns FTS5 index: ${c.join("; ")}`)}return i}catch(o){i.status="failed",i.error=O(o);try{t(`${r} qe_patterns FTS5 self-heal skipped: ${i.error} (keyword search may be degraded; vector search unaffected)`)}catch{}return i}}var dt,ut,Be=R(()=>{"use strict";ce();te();dt=Object.keys(b);ut=Object.freeze(Object.fromEntries(Object.entries(b).map(([n,e])=>[n,ke(e)])))});function M(n,e,t){let r={value:e,timestamp:t??(e!==void 0?Date.now():0),nodeId:e!==void 0?n:"",version:e!==void 0?1:0,lastUpdated:Date.now()};function i(o,E,c,T){return o!==c?o-c:E.localeCompare(T)}return{get(){return r.value},set(o,E){let c=E??Date.now();(r.timestamp===0||i(c,n,r.timestamp,r.nodeId)>0)&&(r={value:o,timestamp:c,nodeId:n,version:r.version+1,lastUpdated:Date.now()})},merge(o){let E=o.getState();this.applyState(E)},getState(){return{value:r.value,timestamp:r.timestamp,nodeId:r.nodeId,version:r.version,lastUpdated:r.lastUpdated}},applyState(o){(r.timestamp===0||i(o.timestamp,o.nodeId,r.timestamp,r.nodeId)>0)&&(r={value:o.value,timestamp:o.timestamp,nodeId:o.nodeId,version:Math.max(r.version,o.version)+1,lastUpdated:Date.now()})},getNodeId(){return n},getTimestamp(){return r.timestamp}}}function G(n,e){let t=M(n);return t.applyState(e),t}var re=R(()=>{"use strict"});function C(n){let e={counts:{},version:0,lastUpdated:Date.now()};return e.counts[n]=0,{get(){return Object.values(e.counts).reduce((t,r)=>t+r,0)},increment(t=1){if(t<0)throw new Error("G-Counter can only increment by positive values");t!==0&&(e.counts[n]=(e.counts[n]||0)+t,e.version++,e.lastUpdated=Date.now())},merge(t){let r=t.getState();this.applyState(r)},getState(){return{counts:{...e.counts},version:e.version,lastUpdated:e.lastUpdated}},applyState(t){let r=!1;for(let[i,o]of Object.entries(t.counts)){let E=e.counts[i]||0;o>E&&(e.counts[i]=o,r=!0)}r&&(e.version=Math.max(e.version,t.version)+1,e.lastUpdated=Date.now())},getNodeId(){return n},getLocalCount(){return e.counts[n]||0}}}function P(n,e){let t=C(n);return t.applyState(e),t}var k=R(()=>{"use strict"});function q(n){let e=C(n),t=C(n),r=0,i=Date.now();return{get(){return e.get()-t.get()},increment(o=1){if(o<0)throw new Error("Use decrement() for negative values");o!==0&&(e.increment(o),r++,i=Date.now())},decrement(o=1){if(o<0)throw new Error("Use increment() for negative values");o!==0&&(t.increment(o),r++,i=Date.now())},merge(o){let E=o.getState();this.applyState(E)},getState(){return{positive:e.getState(),negative:t.getState(),version:r,lastUpdated:i}},applyState(o){let E=this.get();e.applyState(o.positive),t.applyState(o.negative);let c=this.get();E!==c&&(r=Math.max(r,o.version)+1,i=Date.now())},getNodeId(){return n}}}function B(n,e){let t=q(n);return t.applyState(e),t}var se=R(()=>{"use strict";k()});function gt(n,e){return`${n}:${Date.now()}:${e}`}function ie(n){return typeof n=="string"?`s:${n}`:typeof n=="number"?`n:${n}`:typeof n=="boolean"?`b:${n}`:`j:${JSON.stringify(n)}`}function pt(n){let e=n.substring(0,2),t=n.substring(2);switch(e){case"s:":return t;case"n:":return Number(t);case"b:":return t==="true";case"j:":return I(t);default:throw new Error(`Unknown serialization type: ${e}`)}}function j(n){let e=new Map,t=new Map,r=0,i=Date.now(),o=0;function E(T){let u=e.get(T);if(!u||u.size===0)return!1;let l=t.get(T);if(!l||l.size===0)return!0;for(let m of u)if(!l.has(m))return!0;return!1}function c(T){let u=e.get(T);if(!u)return new Set;let l=t.get(T)||new Set,m=new Set;for(let p of u)l.has(p)||m.add(p);return m}return{has(T){let u=ie(T);return E(u)},values(){let T=[];for(let[u]of e)E(u)&&T.push(pt(u));return T},size(){let T=0;for(let[u]of e)E(u)&&T++;return T},add(T){let u=ie(T),l=gt(n,o++);e.has(u)||e.set(u,new Set),e.get(u).add(l),r++,i=Date.now()},remove(T){let u=ie(T),l=e.get(u);if(!l||l.size===0)return;t.has(u)||t.set(u,new Set);let m=t.get(u);for(let p of l)m.add(p);r++,i=Date.now()},merge(T){let u=T.getState();this.applyState(u)},getState(){let T={};for(let[l,m]of e)T[l]=Array.from(m);let u={};for(let[l,m]of t)m.size>0&&(u[l]=Array.from(m));return{elements:T,tombstones:u,version:r,lastUpdated:i}},applyState(T){let u=!1;for(let[l,m]of Object.entries(T.elements)){e.has(l)||e.set(l,new Set);let p=e.get(l);for(let g of m)p.has(g)||(p.add(g),u=!0)}for(let[l,m]of Object.entries(T.tombstones)){t.has(l)||t.set(l,new Set);let p=t.get(l);for(let g of m)p.has(g)||(p.add(g),u=!0)}u&&(r=Math.max(r,T.version)+1,i=Date.now())},getNodeId(){return n},clear(){for(let[T,u]of e){t.has(T)||t.set(T,new Set);let l=t.get(T);for(let m of u)l.add(m)}r++,i=Date.now()}}}function z(n,e){let t=j(n);return t.applyState(e),t}var oe=R(()=>{"use strict";de()});function ae(n){let e={..._t,...n},{nodeId:t,enableDeltaTracking:r,maxDeltaHistory:i}=e,o=new Map,E=new Map,c=new Map,T=new Map,u=0,l=[],m=new Set,p={registers:new Set,gCounters:new Set,pnCounters:new Set,sets:new Set};function g(a,s,d){let N={key:a,type:s,operation:d,timestamp:Date.now(),nodeId:t};for(let Je of m)try{Je(N)}catch(Ze){console.error("[CRDTStore] Error in change listener:",Ze)}}function _(a,s){u++,r&&p[a].add(s)}function L(){if(!r||!(p.registers.size>0||p.gCounters.size>0||p.pnCounters.size>0||p.sets.size>0))return;let s={fromVersion:l.length>0?l[l.length-1].toVersion:0,toVersion:u,timestamp:Date.now(),nodeId:t};if(p.registers.size>0){s.registers={};for(let d of p.registers){let N=o.get(d);N&&(s.registers[d]=N.getState())}p.registers.clear()}if(p.gCounters.size>0){s.gCounters={};for(let d of p.gCounters){let N=E.get(d);N&&(s.gCounters[d]=N.getState())}p.gCounters.clear()}if(p.pnCounters.size>0){s.pnCounters={};for(let d of p.pnCounters){let N=c.get(d);N&&(s.pnCounters[d]=N.getState())}p.pnCounters.clear()}if(p.sets.size>0){s.sets={};for(let d of p.sets){let N=T.get(d);N&&(s.sets[d]=N.getState())}p.sets.clear()}for(l.push(s);l.length>i;)l.shift()}let h={getRegister(a){return o.has(a)||o.set(a,M(t)),o.get(a)},setRegister(a,s){h.getRegister(a).set(s),_("registers",a),g(a,"lww-register","set")},hasRegister(a){return o.has(a)},deleteRegister(a){let s=o.delete(a);return s&&_("registers",a),s},getGCounter(a){return E.has(a)||E.set(a,C(t)),E.get(a)},incrementGCounter(a,s){h.getGCounter(a).increment(s),_("gCounters",a),g(a,"g-counter","increment")},hasGCounter(a){return E.has(a)},deleteGCounter(a){let s=E.delete(a);return s&&_("gCounters",a),s},getCounter(a){return c.has(a)||c.set(a,q(t)),c.get(a)},incrementCounter(a,s){h.getCounter(a).increment(s),_("pnCounters",a),g(a,"pn-counter","increment")},decrementCounter(a,s){h.getCounter(a).decrement(s),_("pnCounters",a),g(a,"pn-counter","decrement")},hasCounter(a){return c.has(a)},deleteCounter(a){let s=c.delete(a);return s&&_("pnCounters",a),s},getSet(a){return T.has(a)||T.set(a,j(t)),T.get(a)},addToSet(a,s){h.getSet(a).add(s),_("sets",a),g(a,"or-set","add")},removeFromSet(a,s){h.getSet(a).remove(s),_("sets",a),g(a,"or-set","remove")},hasSet(a){return T.has(a)},deleteSet(a){let s=T.delete(a);return s&&_("sets",a),s},merge(a){let s=a.getState();h.applyState(s)},getState(){L();let a={version:u,timestamp:Date.now(),nodeId:t,registers:{},gCounters:{},pnCounters:{},sets:{}};for(let[s,d]of o)a.registers[s]=d.getState();for(let[s,d]of E)a.gCounters[s]=d.getState();for(let[s,d]of c)a.pnCounters[s]=d.getState();for(let[s,d]of T)a.sets[s]=d.getState();return a},applyState(a){for(let[s,d]of Object.entries(a.registers))o.has(s)?o.get(s).applyState(d):o.set(s,G(t,d)),_("registers",s),g(s,"lww-register","merge");for(let[s,d]of Object.entries(a.gCounters))E.has(s)?E.get(s).applyState(d):E.set(s,P(t,d)),_("gCounters",s),g(s,"g-counter","merge");for(let[s,d]of Object.entries(a.pnCounters))c.has(s)?c.get(s).applyState(d):c.set(s,B(t,d)),_("pnCounters",s),g(s,"pn-counter","merge");for(let[s,d]of Object.entries(a.sets))T.has(s)?T.get(s).applyState(d):T.set(s,z(t,d)),_("sets",s),g(s,"or-set","merge");u=Math.max(u,a.version)+1},getDelta(a){if(L(),l.length===0)return a>=u,null;let s=l.filter(N=>N.toVersion>a);if(s.length===0)return null;let d={fromVersion:a,toVersion:u,timestamp:Date.now(),nodeId:t,registers:{},gCounters:{},pnCounters:{},sets:{}};for(let N of s)N.registers&&Object.assign(d.registers,N.registers),N.gCounters&&Object.assign(d.gCounters,N.gCounters),N.pnCounters&&Object.assign(d.pnCounters,N.pnCounters),N.sets&&Object.assign(d.sets,N.sets);return Object.keys(d.registers).length===0&&delete d.registers,Object.keys(d.gCounters).length===0&&delete d.gCounters,Object.keys(d.pnCounters).length===0&&delete d.pnCounters,Object.keys(d.sets).length===0&&delete d.sets,d},applyDelta(a){if(a.registers)for(let[s,d]of Object.entries(a.registers))o.has(s)?o.get(s).applyState(d):o.set(s,G(t,d)),_("registers",s),g(s,"lww-register","merge");if(a.gCounters)for(let[s,d]of Object.entries(a.gCounters))E.has(s)?E.get(s).applyState(d):E.set(s,P(t,d)),_("gCounters",s),g(s,"g-counter","merge");if(a.pnCounters)for(let[s,d]of Object.entries(a.pnCounters))c.has(s)?c.get(s).applyState(d):c.set(s,B(t,d)),_("pnCounters",s),g(s,"pn-counter","merge");if(a.sets)for(let[s,d]of Object.entries(a.sets))T.has(s)?T.get(s).applyState(d):T.set(s,z(t,d)),_("sets",s),g(s,"or-set","merge");u=Math.max(u,a.toVersion)+1},getVersion(){return u},getNodeId(){return t},on(a,s){if(a==="change")return m.add(s),()=>{m.delete(s)};throw new Error(`Unknown event type: ${a}`)},removeAllListeners(){m.clear()},keys(a){let s=[];return(!a||a==="lww-register")&&s.push(...Array.from(o.keys())),(!a||a==="g-counter")&&s.push(...Array.from(E.keys())),(!a||a==="pn-counter")&&s.push(...Array.from(c.keys())),(!a||a==="or-set")&&s.push(...Array.from(T.keys())),s},clear(){o.clear(),E.clear(),c.clear(),T.clear(),l.length=0,p.registers.clear(),p.gCounters.clear(),p.pnCounters.clear(),p.sets.clear(),u=0},getStats(){return{total:o.size+E.size+c.size+T.size,registers:o.size,gCounters:E.size,pnCounters:c.size,sets:T.size,version:u,nodeId:t,deltaHistorySize:l.length}}};return h}var _t,je=R(()=>{"use strict";re();k();se();oe();_t={nodeId:"default-node",enableDeltaTracking:!0,maxDeltaHistory:100}});var ze=R(()=>{"use strict"});var He=R(()=>{"use strict";re();k();se();oe();je();ze()});var St={};et(St,{ALLOWED_TABLE_NAMES:()=>K,BinaryHeap:()=>le,DEFAULT_UNIFIED_MEMORY_CONFIG:()=>Ke,UnifiedHnswIndex:()=>F,UnifiedMemoryManager:()=>D,clearProjectRootCache:()=>H,createHnswIndex:()=>ge,findProjectRoot:()=>y,getDefaultDbPath:()=>$e,getResolvedDefaultConfig:()=>Ve,getUnifiedMemory:()=>Qe,initializeUnifiedMemory:()=>mt,resetUnifiedMemory:()=>ft,validateTableName:()=>v});import*as f from"fs";import*as Ye from"os";import*as S from"path";function $e(){let n=y();return S.join(n,".agentic-qe","memory.db")}function Ve(){return{...Ke,dbPath:$e()}}function Qe(n){return D.getInstance(n)}async function mt(n){let e=Qe(n);return await e.initialize(),e}function ft(){D.resetInstance()}function Nt(){if(We)return;We=!0;let n=()=>{try{let t=D.instance;t&&t.close()}catch(t){console.debug("[UnifiedMemory] Cleanup error:",t instanceof Error?t.message:t)}};process.on("beforeExit",n),_e(n);let e=t=>{me(t)||(n(),process.exit(0))};process.on("SIGINT",e),process.on("SIGTERM",e)}var U,Ke,D,We,ht=R(()=>{rt();de();ce();st();tt();Re();V();V();pe();pe();te();Be();Q();He();nt();at();U=Te.create("unified-memory");Ke={dbPath:".agentic-qe/memory.db",walMode:!0,mmapSize:X.MMAP_SIZE_BYTES,cacheSize:X.CACHE_SIZE_KB,busyTimeout:X.BUSY_TIMEOUT_MS,vectorDimensions:X.DEFAULT_VECTOR_DIMENSIONS};D=class n{static instance=null;static instancePromise=null;db=null;config;initialized=!1;vectorsLoaded=!1;initPromise=null;preparedStatements=new Map;vectorIndex=new F("qe-memory");crdtStore=null;proofGate=null;proofGateEnvChecked=!1;static PROOF_NS="__proofgate__";static PROOF_KEY="chain";constructor(e){let t=Ve();if(this.config={...t,...e},process.env.AQE_MEMORY_BACKEND==="memory"){this.config.dbPath=":memory:";return}if(this.config.dbPath!==":memory:"&&!S.isAbsolute(this.config.dbPath)){let r=y();this.config.dbPath=S.join(r,this.config.dbPath)}}static getInstance(e){return n.instance||(n.instance=new n(e)),n.instance}static async getInstanceAsync(e){return n.instance?.initialized?n.instance:(n.instancePromise||(n.instancePromise=(async()=>{let t=n.getInstance(e);return await t.initialize(),t})()),n.instancePromise)}static resetInstance(){n.instance&&(n.instance.close(),n.instance=null),n.instancePromise=null,H()}async initialize(e){if(!this.initialized)return this.initPromise||(this.initPromise=this._doInitialize(e?.signal)),this.initPromise}async _doInitialize(e){if(!this.initialized){e?.throwIfAborted();try{let t=this.config.dbPath===":memory:",r="",i=!1,o=0;if(!t){let E=process.env.AQE_PROJECT_ROOT;if(E){let c=S.resolve(this.config.dbPath),T=S.resolve(E);!c.startsWith(T)&&!c.startsWith(Ye.tmpdir())&&c.includes(".agentic-qe")&&(console.error(`[UnifiedMemory] WARNING: DB path "${this.config.dbPath}" points to a production .agentic-qe/ while AQE_PROJECT_ROOT="${E}". Redirecting to test-safe path.`),this.config.dbPath=S.join(E,".agentic-qe","memory.db"))}if(r=S.dirname(this.config.dbPath),f.existsSync(r)||f.mkdirSync(r,{recursive:!0}),i=f.existsSync(this.config.dbPath),i)o=f.statSync(this.config.dbPath).size;else if(f.existsSync(r)){let c=this.findRecentBackups(r);if(c.length>0){let T=c[0];console.error(`[UnifiedMemory] CRITICAL: Database file missing but directory exists!
|
|
736
736
|
Expected: ${this.config.dbPath}
|
|
737
737
|
Found ${c.length} backup(s), newest: ${T.path} (${(T.size/1024/1024).toFixed(1)}MB)
|
|
738
|
-
Restoring from backup to prevent data loss...`),f.copyFileSync(T.path,this.config.dbPath);for(let u of["-wal","-shm"]){let l=this.config.dbPath+u;f.existsSync(l)&&f.unlinkSync(l)}o=T.size}}}if(e?.throwIfAborted(),this.db=
|
|
738
|
+
Restoring from backup to prevent data loss...`),f.copyFileSync(T.path,this.config.dbPath);for(let u of["-wal","-shm"]){let l=this.config.dbPath+u;f.existsSync(l)&&f.unlinkSync(l)}o=T.size}}}if(e?.throwIfAborted(),this.db=Ee(this.config.dbPath,{walMode:this.config.walMode,busyTimeout:this.config.busyTimeout,autoRestore:!0}),this.db.pragma(`mmap_size = ${this.config.mmapSize}`),this.db.pragma(`cache_size = ${this.config.cacheSize}`),this.db.pragma("foreign_keys = ON"),e?.aborted){try{this.db.close()}catch{}this.db=null,e.throwIfAborted()}if(await this.runMigrations(),qe(this.db,{logPrefix:"[UnifiedMemory]"}),e?.throwIfAborted(),i&&o>1e6)try{let E=this.db.prepare("SELECT COUNT(*) as cnt FROM qe_patterns").get();if(E&&E.cnt===0){let c=f.statSync(this.config.dbPath).size;c<o*.1&&console.error(`[UnifiedMemory] CRITICAL: Possible data loss detected!
|
|
739
739
|
DB was ${(o/1024/1024).toFixed(1)}MB, now ${(c/1024/1024).toFixed(1)}MB with 0 patterns.
|
|
740
740
|
This looks like the DB was replaced with an empty schema.
|
|
741
|
-
Check backups in ${r} and restore manually.`)}}catch{}this.vectorsLoaded=!1,this.initialized=!0,console.log(`[UnifiedMemory] Initialized: ${this.config.dbPath}`),this.warnIfDuplicateDatabases()}catch(t){throw this.initPromise=null,t instanceof Error&&(t.name==="AbortError"||(e?.aborted??!1))?t:new Error(`Failed to initialize UnifiedMemoryManager: ${O(t)}`)}}}findRecentBackups(e){try{let r=f.readdirSync(e).filter(o=>o.startsWith("memory")&&o.endsWith(".db")&&o!=="memory.db").map(o=>{let E=S.join(e,o),c=f.statSync(E);return{path:E,size:c.size,mtime:c.mtimeMs}}).filter(o=>o.size>1e6).sort((o,E)=>E.mtime-o.mtime),i=S.join(e,"backups");if(f.existsSync(i)){let o=f.readdirSync(i);for(let E of o)if(E.endsWith(".db")){let c=S.join(i,E),T=f.statSync(c);T.size>1e6&&r.push({path:c,size:T.size,mtime:T.mtimeMs})}r.sort((E,c)=>c.mtime-E.mtime)}return r}catch{return[]}}warnIfDuplicateDatabases(){if(this.config.dbPath!==":memory:")try{let e=
|
|
741
|
+
Check backups in ${r} and restore manually.`)}}catch{}this.vectorsLoaded=!1,this.initialized=!0,console.log(`[UnifiedMemory] Initialized: ${this.config.dbPath}`),this.warnIfDuplicateDatabases()}catch(t){throw this.initPromise=null,t instanceof Error&&(t.name==="AbortError"||(e?.aborted??!1))?t:new Error(`Failed to initialize UnifiedMemoryManager: ${O(t)}`)}}}findRecentBackups(e){try{let r=f.readdirSync(e).filter(o=>o.startsWith("memory")&&o.endsWith(".db")&&o!=="memory.db").map(o=>{let E=S.join(e,o),c=f.statSync(E);return{path:E,size:c.size,mtime:c.mtimeMs}}).filter(o=>o.size>1e6).sort((o,E)=>E.mtime-o.mtime),i=S.join(e,"backups");if(f.existsSync(i)){let o=f.readdirSync(i);for(let E of o)if(E.endsWith(".db")){let c=S.join(i,E),T=f.statSync(c);T.size>1e6&&r.push({path:c,size:T.size,mtime:T.mtimeMs})}r.sort((E,c)=>c.mtime-E.mtime)}return r}catch{return[]}}warnIfDuplicateDatabases(){if(this.config.dbPath!==":memory:")try{let e=y(),t=S.resolve(this.config.dbPath),i=[S.join(e,".agentic-qe","memory.db"),S.join(e,"v3",".agentic-qe","memory.db")].map(o=>S.resolve(o)).filter(o=>o!==t&&f.existsSync(o));i.length>0&&console.warn(`[UnifiedMemory] WARNING: Duplicate database(s) detected!
|
|
742
742
|
Canonical: ${t}
|
|
743
743
|
Duplicates: ${i.join(", ")}
|
|
744
|
-
This can cause data splits. Remove duplicates or set AQE_PROJECT_ROOT.`)}catch(e){U.debug("Duplicate database check failed",{error:e instanceof Error?e.message:String(e)})}}columnExists(e,t){if(!this.db)return!1;try{let r=v(e);return this.db.prepare(`PRAGMA table_info(${r})`).all().some(o=>o.name===t)}catch(r){return U.debug("Column existence check failed",{table:e,column:t,error:r instanceof Error?r.message:String(r)}),!1}}handleV2SchemaIncompatibilities(){if(!this.db)return;let e=[{table:"goap_plans",requiredColumn:"status",columnDef:"TEXT DEFAULT 'pending'"},{table:"goap_actions",requiredColumn:"agent_type",columnDef:"TEXT DEFAULT 'unknown'"},{table:"concept_nodes",requiredColumn:"concept_type",columnDef:"TEXT DEFAULT 'general'"},{table:"concept_edges",requiredColumn:"edge_type",columnDef:"TEXT DEFAULT 'related'"},{table:"dream_insights",requiredColumn:"cycle_id",columnDef:"TEXT DEFAULT ''"},{table:"rl_q_values",requiredColumn:"algorithm",columnDef:"TEXT DEFAULT 'q-learning'"}];for(let{table:t,requiredColumn:r,columnDef:i}of e)if(this.db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name=?").get(t)&&!this.columnExists(t,r)){let E=v(t);try{this.db.exec(`ALTER TABLE ${E} ADD COLUMN ${r} ${i}`),console.log(`[UnifiedMemory] Added column ${r} to ${t} (safe migration)`)}catch(c){console.log(`[UnifiedMemory] Column ${r} on ${t}: ${c instanceof Error?c.message:String(c)}`)}}}async runMigrations(){if(!this.db)throw new Error("Database not initialized");this.db.exec(Oe),this.handleV2SchemaIncompatibilities();let t=this.db.prepare("SELECT version FROM schema_version WHERE id = 1").get()?.version??0;t<x&&(console.log(`[UnifiedMemory] Migrating from v${t} to v${x}`),this.db.transaction(()=>{t<1&&this.db.exec(Ae),t<2&&this.db.exec(ve),t<3&&(this.db.exec(be),this.db.exec(J),this.db.exec(De)),t<4&&this.db.exec(Xe),t<5&&this.db.exec(Fe),t<6&&this.db.exec(
|
|
744
|
+
This can cause data splits. Remove duplicates or set AQE_PROJECT_ROOT.`)}catch(e){U.debug("Duplicate database check failed",{error:e instanceof Error?e.message:String(e)})}}columnExists(e,t){if(!this.db)return!1;try{let r=v(e);return this.db.prepare(`PRAGMA table_info(${r})`).all().some(o=>o.name===t)}catch(r){return U.debug("Column existence check failed",{table:e,column:t,error:r instanceof Error?r.message:String(r)}),!1}}handleV2SchemaIncompatibilities(){if(!this.db)return;let e=[{table:"goap_plans",requiredColumn:"status",columnDef:"TEXT DEFAULT 'pending'"},{table:"goap_actions",requiredColumn:"agent_type",columnDef:"TEXT DEFAULT 'unknown'"},{table:"concept_nodes",requiredColumn:"concept_type",columnDef:"TEXT DEFAULT 'general'"},{table:"concept_edges",requiredColumn:"edge_type",columnDef:"TEXT DEFAULT 'related'"},{table:"dream_insights",requiredColumn:"cycle_id",columnDef:"TEXT DEFAULT ''"},{table:"rl_q_values",requiredColumn:"algorithm",columnDef:"TEXT DEFAULT 'q-learning'"}];for(let{table:t,requiredColumn:r,columnDef:i}of e)if(this.db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name=?").get(t)&&!this.columnExists(t,r)){let E=v(t);try{this.db.exec(`ALTER TABLE ${E} ADD COLUMN ${r} ${i}`),console.log(`[UnifiedMemory] Added column ${r} to ${t} (safe migration)`)}catch(c){console.log(`[UnifiedMemory] Column ${r} on ${t}: ${c instanceof Error?c.message:String(c)}`)}}}async runMigrations(){if(!this.db)throw new Error("Database not initialized");this.db.exec(Oe),this.handleV2SchemaIncompatibilities();let t=this.db.prepare("SELECT version FROM schema_version WHERE id = 1").get()?.version??0;t<x&&(console.log(`[UnifiedMemory] Migrating from v${t} to v${x}`),this.db.transaction(()=>{t<1&&this.db.exec(Ae),t<2&&this.db.exec(ve),t<3&&(this.db.exec(be),this.db.exec(J),this.db.exec(De)),t<4&&this.db.exec(Xe),t<5&&this.db.exec(Fe),t<6&&this.db.exec(W),t<7&&this.db.exec(xe),t<8&&this.db.exec(we),t<9&&(this.db.exec(ee),this.db.exec("INSERT INTO qe_patterns_fts(qe_patterns_fts) VALUES('rebuild')")),t<10&&this.db.exec(Y),t<11&&this.migrateToV11GoapExecutionSteps(),t<12&&Ce(this.db),t<13&&this.migrateToV13EmbeddingSpace(),this.db.prepare(`
|
|
745
745
|
INSERT OR REPLACE INTO schema_version (id, version, migrated_at)
|
|
746
746
|
VALUES (1, ?, datetime('now'))
|
|
747
747
|
`).run(x)})(),console.log("[UnifiedMemory] Migration complete"))}migrateToV11GoapExecutionSteps(){let e=this.db;e.exec(J);let t=(r,i,o)=>{e.prepare(`SELECT name FROM pragma_table_info('${r}')`).all().some(c=>c.name===i)||e.exec(`ALTER TABLE ${r} ADD COLUMN ${i} ${o}`)};t("goap_execution_steps","execution_id","TEXT"),t("goap_execution_steps","retries","INTEGER DEFAULT 0"),t("goap_execution_steps","started_at","TEXT"),t("goap_execution_steps","agent_output","TEXT"),t("goap_actions","method","TEXT"),t("goap_actions","params","TEXT"),t("goap_actions","implemented","INTEGER DEFAULT 0"),e.exec("CREATE INDEX IF NOT EXISTS idx_goap_exec_steps_execution ON goap_execution_steps(execution_id)")}async loadVectorIndex(){if(this.vectorsLoaded)return;if(!this.db)throw new Error("Database not initialized");this.vectorIndex.clear();let e=this.db.prepare("SELECT id, embedding, dimensions FROM vectors").all();for(let t of e){let r=this.bufferToFloatArray(t.embedding,t.dimensions);this.vectorIndex.add(t.id,r)}this.vectorsLoaded=!0,console.log(`[UnifiedMemory] Loaded ${e.length} vectors into vector index (ruvector flat)`)}async kvSet(e,t,r="default",i){this.ensureInitialized();let o=i?Date.now()+i*1e3:null,E=JSON.stringify(t);this.db.prepare(`
|
|
@@ -753,9 +753,9 @@ import{d as H,f as it}from"./chunk-ZELWDJXT.js";import{b as I,d as ge}from"./chu
|
|
|
753
753
|
`).get(e,t);if(r){if(r.expires_at&&Date.now()>r.expires_at){this.db.prepare("DELETE FROM kv_store WHERE key = ? AND namespace = ?").run(e,t);return}return I(r.value)}}async kvDelete(e,t="default"){this.ensureInitialized();let r=this.db.prepare("DELETE FROM kv_store WHERE key = ? AND namespace = ?").run(e,t);return r.changes>0&&this.auditWrite("kvDelete",t,e,""),r.changes>0}async kvExists(e,t="default"){return this.ensureInitialized(),this.db.prepare(`
|
|
754
754
|
SELECT 1 FROM kv_store
|
|
755
755
|
WHERE key = ? AND namespace = ? AND (expires_at IS NULL OR expires_at > ?)
|
|
756
|
-
`).get(e,t,Date.now())!==void 0}async kvSearch(e,t="default",r=100){this.ensureInitialized();let i=e.replace(/\*/g,"%").replace(/\?/g,"_");return this.db.prepare(`
|
|
756
|
+
`).get(e,t,Date.now())!==void 0}async kvSearch(e,t="default",r=100){this.ensureInitialized();let i=e.replace(/[!%_]/g,"!$&").replace(/\*/g,"%").replace(/\?/g,"_");return this.db.prepare(`
|
|
757
757
|
SELECT key FROM kv_store
|
|
758
|
-
WHERE namespace = ? AND key LIKE ?
|
|
758
|
+
WHERE namespace = ? AND key LIKE ? ESCAPE '!'
|
|
759
759
|
AND (expires_at IS NULL OR expires_at > ?)
|
|
760
760
|
LIMIT ?
|
|
761
761
|
`).all(t,i,Date.now(),r).map(E=>E.key)}async kvCleanupExpired(){return this.ensureInitialized(),this.db.prepare("DELETE FROM kv_store WHERE expires_at IS NOT NULL AND expires_at < ?").run(Date.now()).changes}enableProofGate(){this.ensureInitialized(),this.proofGateEnvChecked=!0,!this.proofGate&&(this.proofGate=this.loadProofChain()??new A)}isProofGateEnabled(){return this.proofGate!==null}verifyMemoryIntegrity(){if(!this.proofGate)throw new Error("Proof-gate not enabled \u2014 call enableProofGate() or set AQE_PROOF_GATE=1");return this.proofGate.verifyIntegrity()}getProofChainRoot(){return this.proofGate?this.proofGate.chainRoot():null}getProofChainLength(){return this.proofGate?this.proofGate.length:0}auditWrite(e,t,r,i){if(!this.proofGate){if(this.proofGateEnvChecked||(this.proofGateEnvChecked=!0,process.env.AQE_PROOF_GATE!=="1"))return;this.proofGate=this.loadProofChain()??new A}if(t!==n.PROOF_NS)try{this.proofGate.admit({op:e,ns:t,key:r,value:i}),this.persistProofChain()}catch(o){U.warn(`proof-gate audit skipped for ${t}/${r}: ${O(o)}`)}}persistProofChain(){!this.proofGate||!this.db||this.db.prepare(`
|
|
@@ -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.
|
|
2
|
-
import{a as R}from"./chunk-
|
|
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.8");process.exit(0)}
|
|
2
|
+
import{a as R}from"./chunk-U64QORFO.js";import{e as g}from"./chunk-J5HTQHJK.js";import{S as v,b as l}from"./chunk-R6I5I724.js";R();v();import{createHash as m,randomUUID as f}from"crypto";var a=g.create("witness-chain"),p=class{logLikelihoodRatio=0;upperBound;lowerBound;observations=0;constructor(t=.05,e=.05){this.upperBound=Math.log(1/t),this.lowerBound=Math.log(e)}addWeightedEvidence(t,e){return this.logLikelihoodRatio+=t?e:-e,this.observations++,this.logLikelihoodRatio>=this.upperBound?"PASS":this.logLikelihoodRatio<=this.lowerBound?"FAIL":"INCONCLUSIVE"}addEvidence(t){return this.addWeightedEvidence(t,.5)}getRatio(){return this.logLikelihoodRatio}getObservations(){return this.observations}getBounds(){return{upper:this.upperBound,lower:this.lowerBound}}reset(){this.logLikelihoodRatio=0,this.observations=0}},c="0".repeat(64),h=class{receipts=[];lastHash=c;sprtAccumulators=new Map;appendWitness(t){let e=f(),i=Date.now(),s=this.receipts.length,n=this.lastHash+JSON.stringify(t)+i,o=m("sha256").update(n).digest("hex"),u={id:e,timestamp:i,previousHash:this.lastHash,hash:o,decision:t,chainIndex:s};return this.receipts.push(u),this.lastHash=o,this.updateSPRT(t),a.debug("Witness appended",{chainIndex:s,type:t.type,decision:t.decision,hash:o.slice(0,16)+"..."}),u}verifyChain(){if(this.receipts.length===0)return{valid:!0,length:0,brokenAt:-1,message:"Chain is empty (valid)",lastHash:c};let t=c;for(let e=0;e<this.receipts.length;e++){let i=this.receipts[e];if(i.previousHash!==t)return{valid:!1,length:this.receipts.length,brokenAt:e,message:`Chain broken at index ${e}: previousHash mismatch`,lastHash:this.lastHash};let s=i.previousHash+JSON.stringify(i.decision)+i.timestamp,n=m("sha256").update(s).digest("hex");if(i.hash!==n)return{valid:!1,length:this.receipts.length,brokenAt:e,message:`Chain broken at index ${e}: hash mismatch (tamper detected)`,lastHash:this.lastHash};t=i.hash}return{valid:!0,length:this.receipts.length,brokenAt:-1,message:`Chain valid (${this.receipts.length} receipts)`,lastHash:this.lastHash}}getChain(t){return t!==void 0&&t>0?[...this.receipts.slice(-t)]:[...this.receipts]}getChainLength(){return this.receipts.length}getLastHash(){return this.lastHash}exportChain(){let t={version:"1.0.0",exportedAt:Date.now(),length:this.receipts.length,receipts:this.receipts};return JSON.stringify(t,null,2)}importChain(t){try{let e=JSON.parse(t);if(!e||e.version!=="1.0.0"||!Array.isArray(e.receipts))return a.warn("Import failed: invalid format"),!1;let i=this.receipts,s=this.lastHash;this.receipts=e.receipts,this.lastHash=e.receipts.length>0?e.receipts[e.receipts.length-1].hash:c;let n=this.verifyChain();return n.valid?(a.info("Chain imported successfully",{length:e.receipts.length}),!0):(this.receipts=i,this.lastHash=s,a.warn("Import failed: chain integrity check failed",{message:n.message}),!1)}catch(e){return a.warn("Import failed: parse error",{error:e instanceof Error?e.message:String(e)}),!1}}getSPRT(t,e,i){return this.sprtAccumulators.has(t)||this.sprtAccumulators.set(t,new p(e,i)),this.sprtAccumulators.get(t)}getReceipt(t){return this.receipts[t]}updateSPRT(t){let e=t.decision==="PASS"||t.decision==="PERMIT";this.getSPRT(t.type).addEvidence(e)}},d=class extends h{persistence;constructor(t){super(),this.persistence=t;let e=t.loadAllReceipts();if(e.length>0){let i={version:"1.0.0",exportedAt:Date.now(),length:e.length,receipts:e};this.importChain(JSON.stringify(i))?a.info("Witness chain restored from SQLite",{receipts:e.length}):a.warn("Failed to restore witness chain from SQLite \u2014 starting fresh")}}appendWitness(t){let e=super.appendWitness(t);try{this.persistence.insertReceipt(e)}catch(i){a.warn("Failed to persist witness receipt to SQLite",{chainIndex:e.chainIndex,error:i instanceof Error?i.message:String(i)})}return e}};function C(r){r.exec(`
|
|
3
3
|
CREATE TABLE IF NOT EXISTS witness_chain_receipts (
|
|
4
4
|
id TEXT PRIMARY KEY,
|
|
5
5
|
chain_index INTEGER NOT NULL,
|
|
@@ -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.
|
|
2
|
-
import{b as
|
|
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.8");process.exit(0)}
|
|
2
|
+
import{b as i,c}from"./chunk-A5CLVZC3.js";import{i as l}from"./chunk-UQGIC5OX.js";c();var u=.15,d=.03,p=.25,s=class{constructor(t){this.db=t;i(t)}db;recordNull(t){this.db.prepare(`
|
|
3
3
|
INSERT INTO qe_pattern_nulls (id, pattern_id, context_fingerprint, failure_mode, trajectory_ref, evidence_class)
|
|
4
4
|
VALUES (?, ?, ?, ?, ?, ?)
|
|
5
5
|
ON CONFLICT(pattern_id, context_fingerprint) DO UPDATE SET
|
|
@@ -7,7 +7,7 @@ import{b as l,c}from"./chunk-UFSVUBTR.js";import{i}from"./chunk-FW4DJ4FJ.js";c()
|
|
|
7
7
|
failure_mode = excluded.failure_mode,
|
|
8
8
|
trajectory_ref = COALESCE(excluded.trajectory_ref, trajectory_ref),
|
|
9
9
|
updated_at = datetime('now')
|
|
10
|
-
`).run(
|
|
10
|
+
`).run(l(),t.patternId,t.contextFingerprint,t.failureMode,t.trajectoryRef??null,t.evidenceClass??"EXECUTED")}getNullSummaries(t){let e=new Map;if(t.length===0)return e;let a=t.map(()=>"?").join(","),o=this.db.prepare(`
|
|
11
11
|
SELECT pattern_id, context_fingerprint, consolidated_count
|
|
12
12
|
FROM qe_pattern_nulls
|
|
13
13
|
WHERE pattern_id IN (${a})
|
|
@@ -1,4 +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.
|
|
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.8");process.exit(0)}
|
|
2
2
|
var a=class extends Error{constructor(r){super(r),this.name="TestRunnerExecutionError"}};function y(t,r,s,e,n,i){let d=(i?.testResults??[]).filter(u=>u.status==="failed"&&(t==="vitest"&&u.message||!u.assertionResults?.some(f=>f.status==="failed"))),o;if(s===null?o="terminated without an exit code":e.passed+e.failed+e.skipped===0?o="reported zero tests":d.length>0||(i?.numRuntimeErrorTestSuites??0)>0||(i?.numFailedTestSuites??0)>0&&e.failed===0?o="reported a suite execution error":(s!==0||i?.success===!1)&&e.failed===0&&(o="failed without a failed assertion"),!o)return;let l=[...d.map(u=>u.message).filter(Boolean),n.trim()].filter(Boolean).join(`
|
|
3
3
|
`).slice(0,4e3);return new a(`${t} ${o} for ${r} (exit code ${s??"unknown"}).`+(l?`
|
|
4
4
|
${l}`:""))}import{mkdtempSync as p,readFileSync as m,rmSync as g}from"node:fs";import{tmpdir as R}from"node:os";import{join as c}from"node:path";function h(t,r){if(!r)return;let s;try{s=m(r,"utf-8")}catch(e){if(e.code==="ENOENT")return;throw new Error("Could not read the current Vitest JSON report.")}try{let e=JSON.parse(s);if(!e||!Array.isArray(e.testResults))throw new Error("Invalid report")}catch{throw new Error("The current Vitest JSON report is malformed.")}return s}function b(){let t=p(c(R(),"aqe-vitest-report-")),r=c(t,"report.json"),s=!1;return{path:r,args:[`--outputFile=${r}`],read:e=>h(e,r),cleanup:()=>{if(!s){s=!0;try{g(t,{recursive:!0,force:!0})}catch{}}}}}function j(t){let r=t.some(n=>/(^|[\\/])vitest(\.cmd|\.js|\.mjs)?$/i.test(n)),s=t.some((n,i)=>n==="--reporter=json"||n==="--reporter"&&t[i+1]==="json"),e=t.some(n=>n.startsWith("--outputFile"));return r&&s&&!e}export{a,y as b,b as c,j as d};
|
|
@@ -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.
|
|
2
|
-
var P="quality-daemon",x=class{constructor(e){this.backend=e}backend;async get(e){return this.backend.kvGet(e,P)}async set(e,t){await this.backend.kvSet(e,t,P)}async search(e){return this.backend.kvSearch(e,P)}};import{cpus as Z,freemem as ee,totalmem as te,loadavg as ie}from"os";var
|
|
3
|
-
`)){if(!i)continue;let[o,r]=i.split(" "),n=this.lastKnownHeads.get(o);n&&n!==r&&(e.push(o),await this.enqueueCommitAnalysis(o,r)),this.lastKnownHeads.set(o,r)}}catch{}finally{this._polling=!1}return e}handleRefChange(e){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.processRefChange(e).catch(t=>{console.debug("[GitWatcher] Error processing ref change:",t)})},this.options.debounceMs)}async processRefChange(e){let t=e.replace(/\\/g,"/"),i=q(this.options.repoRoot,".git","refs","heads"),o=H(i,e),r;try{r=
|
|
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.8");process.exit(0)}
|
|
2
|
+
var P="quality-daemon",x=class{constructor(e){this.backend=e}backend;async get(e){return this.backend.kvGet(e,P)}async set(e,t){await this.backend.kvSet(e,t,P)}async search(e){return this.backend.kvSearch(e,P)}};import{cpus as Z,freemem as ee,totalmem as te,loadavg as ie}from"os";var p=class{queues={now:[],next:[],later:[]};_maxSize;constructor(e=1e3){this._maxSize=e}enqueue(e){return this.size>=this._maxSize&&(this.pruneExpired(),this.size>=this._maxSize)?!1:(this.queues[e.priority].push(e),!0)}dequeue(){let e=Date.now();for(let t of["now","next","later"]){let i=this.queues[t];for(;i.length>0;){let o=i.shift();if(!(o.ttlMs&&e-o.createdAt>o.ttlMs))return o}}}peek(){let e=Date.now();for(let t of["now","next","later"]){let i=this.queues[t];for(let o of i)if(!o.ttlMs||e-o.createdAt<=o.ttlMs)return o}}drainPriority(e){let t=this.queues[e].splice(0),i=Date.now();return t.filter(o=>!o.ttlMs||i-o.createdAt<=o.ttlMs)}pruneExpired(){let e=0,t=Date.now();for(let i of["now","next","later"]){let o=this.queues[i].length;this.queues[i]=this.queues[i].filter(r=>!r.ttlMs||t-r.createdAt<=r.ttlMs),e+=o-this.queues[i].length}return e}get size(){return this.queues.now.length+this.queues.next.length+this.queues.later.length}get depths(){return{now:this.queues.now.length,next:this.queues.next.length,later:this.queues.later.length}}get isEmpty(){return this.size===0}clear(){this.queues.now=[],this.queues.next=[],this.queues.later=[]}};import{watch as G}from"fs";import{execFile as Q}from"child_process";import{promisify as $}from"util";import{resolve as q,join as H}from"path";import{existsSync as z,readFileSync as E}from"fs";var _=$(Q),L={repoRoot:process.cwd(),debounceMs:500,maxChangedFiles:200,pollIntervalMs:5e3},g=class{constructor(e,t){this.queue=e;this.options={...L,...t}}queue;watcher;pollTimer;options;lastKnownHeads=new Map;debounceTimer;_running=!1;_polling=!1;get running(){return this._running}async start(){if(this._running)return;let e=q(this.options.repoRoot,".git","refs","heads");if(!z(e))throw new Error(`Git refs directory not found: ${e}`);await this.snapshotHeads(),process.platform==="darwin"||process.platform==="win32"?this.watcher=G(e,{recursive:!0},(i,o)=>{o&&this.handleRefChange(o)}):(this.pollTimer=setInterval(()=>{this.poll().catch(i=>{console.debug("[GitWatcher] Poll error:",i)})},this.options.pollIntervalMs),this.pollTimer.unref?.()),this._running=!0}stop(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=void 0),this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=void 0),this.watcher&&(this.watcher.close(),this.watcher=void 0),this._running=!1}async poll(){if(this._polling)return[];this._polling=!0;let e=[];try{let{stdout:t}=await _("git",["for-each-ref","--format=%(refname:short) %(objectname:short)","refs/heads/"],{cwd:this.options.repoRoot});for(let i of t.trim().split(`
|
|
3
|
+
`)){if(!i)continue;let[o,r]=i.split(" "),n=this.lastKnownHeads.get(o);n&&n!==r&&(e.push(o),await this.enqueueCommitAnalysis(o,r)),this.lastKnownHeads.set(o,r)}}catch{}finally{this._polling=!1}return e}handleRefChange(e){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.processRefChange(e).catch(t=>{console.debug("[GitWatcher] Error processing ref change:",t)})},this.options.debounceMs)}async processRefChange(e){let t=e.replace(/\\/g,"/"),i=q(this.options.repoRoot,".git","refs","heads"),o=H(i,e),r;try{r=E(o,"utf-8").trim()}catch{return}this.lastKnownHeads.get(t)!==r&&(this.lastKnownHeads.set(t,r),await this.enqueueCommitAnalysis(t,r))}async enqueueCommitAnalysis(e,t){let i=[];try{let{stdout:n}=await _("git",["diff-tree","--no-commit-id","--name-only","-r",t],{cwd:this.options.repoRoot});i=n.trim().split(`
|
|
4
4
|
`).filter(Boolean).slice(0,this.options.maxChangedFiles)}catch{}let o={type:"git_commit",branch:e,commitHash:t,changedFiles:i},r={id:`git-${t}-${Date.now()}`,priority:"next",payload:o,createdAt:Date.now(),source:"git-watcher",ttlMs:300*1e3};this.queue.enqueue(r)}async snapshotHeads(){try{let{stdout:e}=await _("git",["for-each-ref","--format=%(refname:short) %(objectname:short)","refs/heads/"],{cwd:this.options.repoRoot});for(let t of e.trim().split(`
|
|
5
|
-
`)){if(!t)continue;let[i,o]=t.split(" ");this.lastKnownHeads.set(i,o)}}catch{}}};var E={regressionThreshold:2,gapThreshold:60,memoryPrefix:"quality-daemon:coverage"},f=class{constructor(e,t){this.queue=e;this.options={...E,...t}}queue;options;async analyze(e,t,i){let o=await t.get(`${this.options.memoryPrefix}:snapshot`);if(await t.set(`${this.options.memoryPrefix}:snapshot`,e),!o)return{regressionDetected:!1,overallDelta:{line:0,branch:0,function:0,statement:0},affectedFiles:[],newGaps:[]};let r=o,n={line:e.overall.line-r.overall.line,branch:e.overall.branch-r.overall.branch,function:e.overall.function-r.overall.function,statement:e.overall.statement-r.overall.statement},s=n.line<-this.options.regressionThreshold||n.branch<-this.options.regressionThreshold,a=i??Object.keys(e.files),u=[],c=[];for(let d of a){let l=e.files[d],m=r.files[d];if(!l)continue;let M=m?l.line-m.line:0,I=m?l.branch-m.branch:0,D=m?l.uncoveredLines.filter(T=>!m.uncoveredLines.includes(T)):l.uncoveredLines;if((M!==0||I!==0||D.length>0)&&u.push({file:d,lineDelta:M,branchDelta:I,newUncoveredLines:D}),l.line<this.options.gapThreshold){let T=this.computeRiskScore(l,D.length);c.push({file:d,uncoveredLines:l.uncoveredLines,currentCoverage:l.line,riskScore:T})}}return(s||c.length>0)&&this.enqueueTestSuggestion(e,r,c),await t.set(`${this.options.memoryPrefix}:delta`,{timestamp:Date.now(),overallDelta:n,regressionDetected:s,affectedFileCount:u.length,gapCount:c.length}),{regressionDetected:s,overallDelta:n,affectedFiles:u,newGaps:c}}async buildSnapshot(e){let t=await e.get("coverage:latest");if(t)return{timestamp:Date.now(),overall:{line:t.line,branch:t.branch,function:t.function,statement:t.statement},files:t.files??{}}}computeRiskScore(e,t){let o=1-Math.min(100,Math.max(0,e.line))/100,r=Math.min(t/50,1);return Math.min(1,o*.6+r*.4)}enqueueTestSuggestion(e,t,i){let o={type:"coverage_delta",previousSnapshot:`snapshot-${t.timestamp}`,currentSnapshot:`snapshot-${e.timestamp}`},r={id:`coverage-delta-${Date.now()}`,priority:i.some(n=>n.riskScore>.8)?"now":"next",payload:o,createdAt:Date.now(),source:"coverage-delta",ttlMs:600*1e3};this.queue.enqueue(r)}};import{execFile as j}from"child_process";import{promisify as B}from"util";var J=B(j),K={runsPerWorkflow:10,flakyThreshold:3,repo:""},y=class{constructor(e,t){this.queue=e;this.options={...K,...t}}queue;options;async check(){let e=await this.fetchRecentRuns(),t=this.groupByWorkflow(e),i=[],o=[],r=0;for(let[s,a]of Object.entries(t)){let u=a.filter(m=>m.conclusion==="failure").length,c=a.length>0?(a.length-u)/a.length*100:100,d=this.countConsecutiveFailures(a),l=a[0]?.conclusion??"unknown";l==="failure"&&r++,d>=this.options.flakyThreshold&&(o.push(s),this.enqueueFailureAlert(s,a[0])),i.push({name:s,recentRuns:a.length,failedRuns:u,successRate:Math.round(c*10)/10,lastConclusion:l,consecutiveFailures:d})}let n=this.calculateHealthScore(i);return{timestamp:Date.now(),workflows:i,failingWorkflows:r,flakyWorkflows:o,healthScore:n}}async fetchRecentRuns(){try{let e=["run","list","--limit",String(this.options.runsPerWorkflow*5),"--json","name,status,conclusion,headBranch,number,databaseId,createdAt"];this.options.repo&&e.push("--repo",this.options.repo);let{stdout:t}=await J("gh",e,{timeout:15e3});return JSON.parse(t).map(o=>({name:o.name,status:o.status,conclusion:o.conclusion??"pending",headBranch:o.headBranch,runNumber:o.number,databaseId:o.databaseId,createdAt:o.createdAt}))}catch{return[]}}groupByWorkflow(e){let t={};for(let i of e)t[i.name]||(t[i.name]=[]),t[i.name].push(i);for(let i of Object.keys(t))t[i]=t[i].slice(0,this.options.runsPerWorkflow);return t}countConsecutiveFailures(e){let t=0;for(let i of e)if(i.conclusion==="failure")t++;else break;return t}calculateHealthScore(e){if(e.length===0)return 100;let t=e.reduce((i,o)=>i+o.successRate,0)/e.length;return Math.round(t)}enqueueFailureAlert(e,t){let i={type:"ci_failure",workflowName:e,runId:t.databaseId,conclusion:t.conclusion},o={id:`ci-failure-${e}-${Date.now()}`,priority:"now",payload:i,createdAt:Date.now(),source:"ci-monitor",ttlMs:1800*1e3};this.queue.enqueue(o)}};var V={memoryPrefix:"quality-daemon:suggestions",maxSuggestions:100,minRiskScore:.3},v=class{options;constructor(e){this.options={...V,...e}}async suggest(e,t,i){let o=[],r=e.filter(s=>s.riskScore>=this.options.minRiskScore);for(let s of r){let a=t.includes(s.file),u=this.determinePriority(s,a),c=this.determineTestType(s.file),d=this.estimateEffort(s);o.push({id:`suggestion-${Date.now()}-${o.length}`,file:s.file,uncoveredLines:s.uncoveredLines.slice(0,50),suggestedTestType:c,description:this.generateDescription(s,c),priority:u,estimatedEffort:d,createdAt:Date.now(),status:"pending"})}o.sort((s,a)=>{let u={high:0,medium:1,low:2};return u[s.priority]-u[a.priority]});let n=o.slice(0,this.options.maxSuggestions);return await this.storeSuggestions(n,i),n}async getPending(e){return(await e.get(`${this.options.memoryPrefix}:list`)??[]).filter(i=>i.status==="pending")}async updateStatus(e,t,i){let o=await i.get(`${this.options.memoryPrefix}:list`);if(!o)return!1;let r=o.findIndex(s=>s.id===e);if(r===-1)return!1;let n=o.map((s,a)=>a===r?{...s,status:t}:s);return await i.set(`${this.options.memoryPrefix}:list`,n),!0}determinePriority(e,t){return e.riskScore>.8?"high":t||e.riskScore>.5?"medium":"low"}determineTestType(e){return e.includes("/api/")||e.includes("/routes/")||e.includes("/handlers/")?"integration":e.includes("/e2e/")||e.includes("/pages/")||e.includes("/views/")?"e2e":"unit"}estimateEffort(e){return e.uncoveredLines.length<=10?"small":e.uncoveredLines.length<=50?"medium":"large"}generateDescription(e,t){let i=e.uncoveredLines.length,o=Math.round(e.currentCoverage);return`Add ${t} tests for ${e.file} (${i} uncovered lines, ${o}% coverage, risk ${(e.riskScore*100).toFixed(0)}%)`}async storeSuggestions(e,t){let r=[...(await t.get(`${this.options.memoryPrefix}:list`)??[]).filter(n=>n.status!=="pending"),...e].slice(-this.options.maxSuggestions);await t.set(`${this.options.memoryPrefix}:list`,r),await t.set(`${this.options.memoryPrefix}:count`,{pending:e.length,total:r.length,lastUpdated:Date.now()})}};var Y={memoryPrefix:"quality-daemon:nightly",maxEntryAge:6048e5,nightlyHour:2},w=class{constructor(e,t){this.queue=e;this.options={...Y,...t}}queue;options;lastRunDate;shouldRun(){let e=new Date,t=e.toISOString().split("T")[0];return this.lastRunDate===t?!1:e.getHours()>=this.options.nightlyHour}scheduleIfDue(){if(!this.shouldRun())return!1;let e={type:"nightly",tasks:["consolidate_patterns","prune_expired","generate_report"]},t={id:`nightly-${Date.now()}`,priority:"later",payload:e,createdAt:Date.now(),source:"nightly-consolidation",ttlMs:720*60*1e3};return this.queue.enqueue(t)}async execute(e,t){let i=Date.now(),o=new Date().toISOString().split("T")[0],r=await this.consolidatePatterns(e),n=await this.pruneExpired(e),s=this.generateReport(o,t);await e.set(`${this.options.memoryPrefix}:report:${o}`,s),this.lastRunDate=o;let a={timestamp:Date.now(),patternsConsolidated:r,entriesPruned:n,reportGenerated:!0,durationMs:Date.now()-i};return await e.set(`${this.options.memoryPrefix}:last-result`,a),a}async getLastResult(e){return e.get(`${this.options.memoryPrefix}:last-result`)}async consolidatePatterns(e){let t=await e.search("quality-daemon:*"),i=0;return await e.get("quality-daemon:suggestions:count")&&i++,await e.get("quality-daemon:coverage:delta")&&i++,i}async pruneExpired(e){let t=await e.search("quality-daemon:*"),i=0,o=Date.now();for(let r of t){if(r.endsWith(":snapshot")||r.endsWith(":list"))continue;let n=await e.get(r);n&&typeof n.timestamp=="number"&&o-n.timestamp>this.options.maxEntryAge&&(await e.set(r,{pruned:!0,prunedAt:o}),i++)}return i}generateReport(e,t){return{date:e,coverageHealth:t.coverageHealth??0,ciHealth:t.ciHealth??0,commitsAnalyzed:t.commitsAnalyzed??0,suggestionsGenerated:t.suggestionsGenerated??0,notificationsSent:t.notificationsSent??0,queueDepthAvg:t.queueDepthAvg??0,daemonUptime:t.uptimeSeconds??0}}};import{writeFileSync as R,mkdirSync as W,readdirSync as S,readFileSync as A,unlinkSync as N}from"fs";import{join as b,resolve as X}from"path";var F={notificationsDir:X(process.cwd(),".agentic-qe","notifications"),maxNotifications:200},k=class{notificationsDir;maxNotifications;webhookUrl;urlValidator;_sentCount=0;constructor(e){this.notificationsDir=e?.notificationsDir??F.notificationsDir,this.maxNotifications=e?.maxNotifications??F.maxNotifications,this.webhookUrl=e?.webhookUrl,this.urlValidator=e?.urlValidator}get sentCount(){return this._sentCount}initialize(){W(this.notificationsDir,{recursive:!0})}async send(e){let t={...e,id:`notif-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,timestamp:Date.now(),read:!1};return this.writeToFile(t),this.webhookUrl&&await this.sendWebhook(t),this._sentCount++,this.pruneOldNotifications(),t}list(e){let t=e?.limit??50;try{let i=S(this.notificationsDir).filter(r=>r.endsWith(".json")).sort().reverse(),o=[];for(let r of i){if(o.length>=t)break;try{let n=A(b(this.notificationsDir,r),"utf-8"),s=JSON.parse(n);if(e?.unreadOnly&&s.read||e?.type&&s.type!==e.type)continue;o.push(s)}catch{}}return o}catch{return[]}}markRead(e){try{let t=S(this.notificationsDir).filter(n=>n.endsWith(`-${e}.json`));if(t.length===0)return!1;let i=b(this.notificationsDir,t[0]),r={...JSON.parse(A(i,"utf-8")),read:!0};return R(i,JSON.stringify(r,null,2)),!0}catch{return!1}}clear(){try{let e=S(this.notificationsDir).filter(t=>t.endsWith(".json"));for(let t of e)N(b(this.notificationsDir,t));return e.length}catch{return 0}}writeToFile(e){try{W(this.notificationsDir,{recursive:!0});let t=`${e.timestamp}-${e.id}.json`,i=b(this.notificationsDir,t);R(i,JSON.stringify(e,null,2))}catch(t){console.debug("[NotificationService] Failed to write notification:",t)}}async sendWebhook(e){if(this.webhookUrl){if(this.urlValidator&&!this.urlValidator(this.webhookUrl)){console.warn("[NotificationService] Webhook URL blocked by SSRF guard:",this.webhookUrl);return}try{let t=await fetch(this.webhookUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:AbortSignal.timeout(5e3)});t.ok||console.debug(`[NotificationService] Webhook returned ${t.status}`)}catch(t){console.debug("[NotificationService] Webhook delivery failed:",t)}}}pruneOldNotifications(){try{let e=S(this.notificationsDir).filter(i=>i.endsWith(".json")).sort();if(e.length<=this.maxNotifications)return;let t=e.slice(0,e.length-this.maxNotifications);for(let i of t)N(b(this.notificationsDir,i))}catch{}}};var C={tickIntervalMs:3e4,ciPollIntervalMs:5*6e4,coverageCheckIntervalMs:2*6e4,cpuThreshold:.7,memoryThreshold:.8},O=class{queue;gitWatcher;coverageDelta;ciMonitor;testSuggester;nightlyConsolidation;notificationService;tickTimer;_running=!1;_startedAt=0;_tickCount=0;_lastTickAt;_throttled=!1;_commitsAnalyzed=0;_suggestionsGenerated=0;_ciHealth=100;_coverageHealth=100;_lastCICheck;_lastCoverageCheck;_memory;config;constructor(e){this.config={tickIntervalMs:e?.tickIntervalMs??C.tickIntervalMs,ciPollIntervalMs:e?.ciPollIntervalMs??C.ciPollIntervalMs,coverageCheckIntervalMs:e?.coverageCheckIntervalMs??C.coverageCheckIntervalMs,cpuThreshold:e?.cpuThreshold??C.cpuThreshold,memoryThreshold:e?.memoryThreshold??C.memoryThreshold},this.queue=new g,this.gitWatcher=new p(this.queue,e?.git),this.coverageDelta=new f(this.queue,e?.coverage),this.ciMonitor=new y(this.queue,e?.ci),this.testSuggester=new v(e?.suggestions),this.nightlyConsolidation=new w(this.queue,e?.nightly),this.notificationService=new k(e?.notifications)}get running(){return this._running}async start(e){this._running||(this._memory=e,this._running=!0,this._startedAt=Date.now(),this.notificationService.initialize(),await this.gitWatcher.start().catch(t=>{console.debug("[QualityDaemon] Git watcher failed to start:",t)}),this.scheduleTick())}async stop(){this._running&&(this._running=!1,this.tickTimer&&(clearTimeout(this.tickTimer),this.tickTimer=void 0),this.gitWatcher.stop(),this._memory&&await this._memory.set("quality-daemon:state",{stoppedAt:Date.now(),tickCount:this._tickCount,commitsAnalyzed:this._commitsAnalyzed,suggestionsGenerated:this._suggestionsGenerated}))}getStatus(){return{running:this._running,uptimeSeconds:this._running?Math.floor((Date.now()-this._startedAt)/1e3):0,tickCount:this._tickCount,queueDepth:this.queue.depths,lastTickAt:this._lastTickAt,throttled:this._throttled,commitsAnalyzed:this._commitsAnalyzed,suggestionsGenerated:this._suggestionsGenerated,notificationsSent:this.notificationService.sentCount,ciHealth:this._ciHealth,coverageHealth:this._coverageHealth,lastCICheck:this._lastCICheck,lastCoverageCheck:this._lastCoverageCheck}}scheduleTick(){this._running&&(this.tickTimer=setTimeout(()=>this.tick(),this.config.tickIntervalMs),this.tickTimer.unref?.())}async tick(){if(!(!this._running||!this._memory)){if(this._tickCount++,this._lastTickAt=Date.now(),this._throttled=this.isResourceConstrained(),this._throttled){await this.processNowItems(this._memory),this.scheduleTick();return}await this.processQueue(this._memory),await this.runPeriodicChecks(this._memory),this.nightlyConsolidation.scheduleIfDue(),this.queue.pruneExpired(),this.scheduleTick()}}async processQueue(e){let t=0,i=10;for(;t<i&&!this.queue.isEmpty;){let o=this.queue.dequeue();if(!o)break;await this.handleQueueItem(o,e),t++}}async processNowItems(e){let t=this.queue.drainPriority("now");for(let i of t)await this.handleQueueItem(i,e)}async handleQueueItem(e,t){let i=e.payload;switch(i.type){case"git_commit":{this._commitsAnalyzed++;let o=await this.coverageDelta.buildSnapshot(t);if(o){let r=await this.coverageDelta.analyze(o,t,i.changedFiles);if(r.regressionDetected&&await this.notificationService.send({type:"coverage_drop",title:"Coverage Regression Detected",message:`Line coverage delta: ${r.overallDelta.line.toFixed(1)}% (${r.affectedFiles.length} files affected)`,severity:"high",metadata:{delta:r.overallDelta,commit:i.commitHash}}),r.newGaps.length>0){let n=await this.testSuggester.suggest(r.newGaps,i.changedFiles,t);this._suggestionsGenerated+=n.length,n.length>0&&await this.notificationService.send({type:"suggestion_available",title:"New Test Suggestions Available",message:`${n.length} test suggestions generated for uncovered code`,severity:"info",metadata:{count:n.length}})}}break}case"coverage_delta":{let o=await this.testSuggester.getPending(t);o.length>0&&await this.notificationService.send({type:"suggestion_available",title:"Test Suggestions Pending",message:`${o.length} test suggestions awaiting review`,severity:"info",metadata:{count:o.length}});break}case"gate_failure":await this.notificationService.send({type:"gate_failure",title:`Quality Gate Failed: ${i.gateName}`,message:`Score ${i.score} below threshold ${i.threshold}`,severity:"critical",metadata:{gate:i.gateName,score:i.score,threshold:i.threshold}});break;case"ci_failure":await this.notificationService.send({type:"ci_failure",title:`CI Failure: ${i.workflowName}`,message:`Workflow ${i.workflowName} run #${i.runId} concluded: ${i.conclusion}`,severity:"high",metadata:{workflow:i.workflowName,runId:i.runId}});break;case"nightly":{let o={coverageHealth:this._coverageHealth,ciHealth:this._ciHealth,commitsAnalyzed:this._commitsAnalyzed,suggestionsGenerated:this._suggestionsGenerated,notificationsSent:this.notificationService.sentCount,queueDepthAvg:this.queue.size,uptimeSeconds:Math.floor((Date.now()-this._startedAt)/1e3)};await this.nightlyConsolidation.execute(t,o);break}default:console.warn("[QualityDaemon] Unhandled payload type:",i.type)}}async runPeriodicChecks(e){let t=Date.now();if(!this._lastCICheck||t-this._lastCICheck>=this.config.ciPollIntervalMs)try{let i=await this.ciMonitor.check();this._ciHealth=i.healthScore,this._lastCICheck=t,i.flakyWorkflows.length>0&&await this.notificationService.send({type:"flaky_detected",title:"Flaky Workflows Detected",message:`${i.flakyWorkflows.length} workflows showing repeated failures: ${i.flakyWorkflows.join(", ")}`,severity:"medium",metadata:{workflows:i.flakyWorkflows}})}catch{}if(!this._lastCoverageCheck||t-this._lastCoverageCheck>=this.config.coverageCheckIntervalMs)try{let i=await this.coverageDelta.buildSnapshot(e);i&&(this._coverageHealth=Math.round((i.overall.line+i.overall.branch+i.overall.function+i.overall.statement)/4),this._lastCoverageCheck=t)}catch{}}isResourceConstrained(){if(1-ee()/te()>this.config.memoryThreshold)return!0;let t=Z().length;return(t>0?ie()[0]/t:0)>this.config.cpuThreshold}};export{x as a,O as b};
|
|
5
|
+
`)){if(!t)continue;let[i,o]=t.split(" ");this.lastKnownHeads.set(i,o)}}catch{}}};var U={regressionThreshold:2,gapThreshold:60,memoryPrefix:"quality-daemon:coverage"},f=class{constructor(e,t){this.queue=e;this.options={...U,...t}}queue;options;async analyze(e,t,i){let o=await t.get(`${this.options.memoryPrefix}:snapshot`);if(await t.set(`${this.options.memoryPrefix}:snapshot`,e),!o)return{regressionDetected:!1,overallDelta:{line:0,branch:0,function:0,statement:0},affectedFiles:[],newGaps:[]};let r=o,n={line:e.overall.line-r.overall.line,branch:e.overall.branch-r.overall.branch,function:e.overall.function-r.overall.function,statement:e.overall.statement-r.overall.statement},s=n.line<-this.options.regressionThreshold||n.branch<-this.options.regressionThreshold,a=i??Object.keys(e.files),u=[],c=[];for(let d of a){let l=e.files[d],m=r.files[d];if(!l)continue;let M=m?l.line-m.line:0,I=m?l.branch-m.branch:0,D=m?l.uncoveredLines.filter(T=>!m.uncoveredLines.includes(T)):l.uncoveredLines;if((M!==0||I!==0||D.length>0)&&u.push({file:d,lineDelta:M,branchDelta:I,newUncoveredLines:D}),l.line<this.options.gapThreshold){let T=this.computeRiskScore(l,D.length);c.push({file:d,uncoveredLines:l.uncoveredLines,currentCoverage:l.line,riskScore:T})}}return(s||c.length>0)&&this.enqueueTestSuggestion(e,r,c),await t.set(`${this.options.memoryPrefix}:delta`,{timestamp:Date.now(),overallDelta:n,regressionDetected:s,affectedFileCount:u.length,gapCount:c.length}),{regressionDetected:s,overallDelta:n,affectedFiles:u,newGaps:c}}async buildSnapshot(e){let t=await e.get("coverage:latest");if(t)return{timestamp:Date.now(),overall:{line:t.line,branch:t.branch,function:t.function,statement:t.statement},files:t.files??{}}}computeRiskScore(e,t){let o=1-Math.min(100,Math.max(0,e.line))/100,r=Math.min(t/50,1);return Math.min(1,o*.6+r*.4)}enqueueTestSuggestion(e,t,i){let o={type:"coverage_delta",previousSnapshot:`snapshot-${t.timestamp}`,currentSnapshot:`snapshot-${e.timestamp}`},r={id:`coverage-delta-${Date.now()}`,priority:i.some(n=>n.riskScore>.8)?"now":"next",payload:o,createdAt:Date.now(),source:"coverage-delta",ttlMs:600*1e3};this.queue.enqueue(r)}};import{execFile as j}from"child_process";import{promisify as B}from"util";var J=B(j),K={runsPerWorkflow:10,flakyThreshold:3,repo:""},y=class{constructor(e,t){this.queue=e;this.options={...K,...t}}queue;options;async check(){let e=await this.fetchRecentRuns(),t=this.groupByWorkflow(e),i=[],o=[],r=0;for(let[s,a]of Object.entries(t)){let u=a.filter(m=>m.conclusion==="failure").length,c=a.length>0?(a.length-u)/a.length*100:100,d=this.countConsecutiveFailures(a),l=a[0]?.conclusion??"unknown";l==="failure"&&r++,d>=this.options.flakyThreshold&&(o.push(s),this.enqueueFailureAlert(s,a[0])),i.push({name:s,recentRuns:a.length,failedRuns:u,successRate:Math.round(c*10)/10,lastConclusion:l,consecutiveFailures:d})}let n=this.calculateHealthScore(i);return{timestamp:Date.now(),workflows:i,failingWorkflows:r,flakyWorkflows:o,healthScore:n}}async fetchRecentRuns(){try{let e=["run","list","--limit",String(this.options.runsPerWorkflow*5),"--json","name,status,conclusion,headBranch,number,databaseId,createdAt"];this.options.repo&&e.push("--repo",this.options.repo);let{stdout:t}=await J("gh",e,{timeout:15e3});return JSON.parse(t).map(o=>({name:o.name,status:o.status,conclusion:o.conclusion??"pending",headBranch:o.headBranch,runNumber:o.number,databaseId:o.databaseId,createdAt:o.createdAt}))}catch{return[]}}groupByWorkflow(e){let t={};for(let i of e)t[i.name]||(t[i.name]=[]),t[i.name].push(i);for(let i of Object.keys(t))t[i]=t[i].slice(0,this.options.runsPerWorkflow);return t}countConsecutiveFailures(e){let t=0;for(let i of e)if(i.conclusion==="failure")t++;else break;return t}calculateHealthScore(e){if(e.length===0)return 100;let t=e.reduce((i,o)=>i+o.successRate,0)/e.length;return Math.round(t)}enqueueFailureAlert(e,t){let i={type:"ci_failure",workflowName:e,runId:t.databaseId,conclusion:t.conclusion},o={id:`ci-failure-${e}-${Date.now()}`,priority:"now",payload:i,createdAt:Date.now(),source:"ci-monitor",ttlMs:1800*1e3};this.queue.enqueue(o)}};var V={memoryPrefix:"quality-daemon:suggestions",maxSuggestions:100,minRiskScore:.3},v=class{options;constructor(e){this.options={...V,...e}}async suggest(e,t,i){let o=[],r=e.filter(s=>s.riskScore>=this.options.minRiskScore);for(let s of r){let a=t.includes(s.file),u=this.determinePriority(s,a),c=this.determineTestType(s.file),d=this.estimateEffort(s);o.push({id:`suggestion-${Date.now()}-${o.length}`,file:s.file,uncoveredLines:s.uncoveredLines.slice(0,50),suggestedTestType:c,description:this.generateDescription(s,c),priority:u,estimatedEffort:d,createdAt:Date.now(),status:"pending"})}o.sort((s,a)=>{let u={high:0,medium:1,low:2};return u[s.priority]-u[a.priority]});let n=o.slice(0,this.options.maxSuggestions);return await this.storeSuggestions(n,i),n}async getPending(e){return(await e.get(`${this.options.memoryPrefix}:list`)??[]).filter(i=>i.status==="pending")}async updateStatus(e,t,i){let o=await i.get(`${this.options.memoryPrefix}:list`);if(!o)return!1;let r=o.findIndex(s=>s.id===e);if(r===-1)return!1;let n=o.map((s,a)=>a===r?{...s,status:t}:s);return await i.set(`${this.options.memoryPrefix}:list`,n),!0}determinePriority(e,t){return e.riskScore>.8?"high":t||e.riskScore>.5?"medium":"low"}determineTestType(e){return e.includes("/api/")||e.includes("/routes/")||e.includes("/handlers/")?"integration":e.includes("/e2e/")||e.includes("/pages/")||e.includes("/views/")?"e2e":"unit"}estimateEffort(e){return e.uncoveredLines.length<=10?"small":e.uncoveredLines.length<=50?"medium":"large"}generateDescription(e,t){let i=e.uncoveredLines.length,o=Math.round(e.currentCoverage);return`Add ${t} tests for ${e.file} (${i} uncovered lines, ${o}% coverage, risk ${(e.riskScore*100).toFixed(0)}%)`}async storeSuggestions(e,t){let r=[...(await t.get(`${this.options.memoryPrefix}:list`)??[]).filter(n=>n.status!=="pending"),...e].slice(-this.options.maxSuggestions);await t.set(`${this.options.memoryPrefix}:list`,r),await t.set(`${this.options.memoryPrefix}:count`,{pending:e.length,total:r.length,lastUpdated:Date.now()})}};var Y={memoryPrefix:"quality-daemon:nightly",maxEntryAge:6048e5,nightlyHour:2},w=class{constructor(e,t){this.queue=e;this.options={...Y,...t}}queue;options;lastRunDate;shouldRun(){let e=new Date,t=e.toISOString().split("T")[0];return this.lastRunDate===t?!1:e.getHours()>=this.options.nightlyHour}scheduleIfDue(){if(!this.shouldRun())return!1;let e={type:"nightly",tasks:["consolidate_patterns","prune_expired","generate_report"]},t={id:`nightly-${Date.now()}`,priority:"later",payload:e,createdAt:Date.now(),source:"nightly-consolidation",ttlMs:720*60*1e3};return this.queue.enqueue(t)}async execute(e,t){let i=Date.now(),o=new Date().toISOString().split("T")[0],r=await this.consolidatePatterns(e),n=await this.pruneExpired(e),s=this.generateReport(o,t);await e.set(`${this.options.memoryPrefix}:report:${o}`,s),this.lastRunDate=o;let a={timestamp:Date.now(),patternsConsolidated:r,entriesPruned:n,reportGenerated:!0,durationMs:Date.now()-i};return await e.set(`${this.options.memoryPrefix}:last-result`,a),a}async getLastResult(e){return e.get(`${this.options.memoryPrefix}:last-result`)}async consolidatePatterns(e){let t=await e.search("quality-daemon:*"),i=0;return await e.get("quality-daemon:suggestions:count")&&i++,await e.get("quality-daemon:coverage:delta")&&i++,i}async pruneExpired(e){let t=await e.search("quality-daemon:*"),i=0,o=Date.now();for(let r of t){if(r.endsWith(":snapshot")||r.endsWith(":list"))continue;let n=await e.get(r);n&&typeof n.timestamp=="number"&&o-n.timestamp>this.options.maxEntryAge&&(await e.set(r,{pruned:!0,prunedAt:o}),i++)}return i}generateReport(e,t){return{date:e,coverageHealth:t.coverageHealth??0,ciHealth:t.ciHealth??0,commitsAnalyzed:t.commitsAnalyzed??0,suggestionsGenerated:t.suggestionsGenerated??0,notificationsSent:t.notificationsSent??0,queueDepthAvg:t.queueDepthAvg??0,daemonUptime:t.uptimeSeconds??0}}};import{writeFileSync as R,mkdirSync as W,readdirSync as S,readFileSync as A,unlinkSync as N}from"fs";import{join as b,resolve as X}from"path";var F={notificationsDir:X(process.cwd(),".agentic-qe","notifications"),maxNotifications:200},k=class{notificationsDir;maxNotifications;webhookUrl;urlValidator;_sentCount=0;constructor(e){this.notificationsDir=e?.notificationsDir??F.notificationsDir,this.maxNotifications=e?.maxNotifications??F.maxNotifications,this.webhookUrl=e?.webhookUrl,this.urlValidator=e?.urlValidator}get sentCount(){return this._sentCount}initialize(){W(this.notificationsDir,{recursive:!0})}async send(e){let t={...e,id:`notif-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,timestamp:Date.now(),read:!1};return this.writeToFile(t),this.webhookUrl&&await this.sendWebhook(t),this._sentCount++,this.pruneOldNotifications(),t}list(e){let t=e?.limit??50;try{let i=S(this.notificationsDir).filter(r=>r.endsWith(".json")).sort().reverse(),o=[];for(let r of i){if(o.length>=t)break;try{let n=A(b(this.notificationsDir,r),"utf-8"),s=JSON.parse(n);if(e?.unreadOnly&&s.read||e?.type&&s.type!==e.type)continue;o.push(s)}catch{}}return o}catch{return[]}}markRead(e){try{let t=S(this.notificationsDir).filter(n=>n.endsWith(`-${e}.json`));if(t.length===0)return!1;let i=b(this.notificationsDir,t[0]),r={...JSON.parse(A(i,"utf-8")),read:!0};return R(i,JSON.stringify(r,null,2)),!0}catch{return!1}}clear(){try{let e=S(this.notificationsDir).filter(t=>t.endsWith(".json"));for(let t of e)N(b(this.notificationsDir,t));return e.length}catch{return 0}}writeToFile(e){try{W(this.notificationsDir,{recursive:!0});let t=`${e.timestamp}-${e.id}.json`,i=b(this.notificationsDir,t);R(i,JSON.stringify(e,null,2))}catch(t){console.debug("[NotificationService] Failed to write notification:",t)}}async sendWebhook(e){if(this.webhookUrl){if(this.urlValidator&&!this.urlValidator(this.webhookUrl)){console.warn("[NotificationService] Webhook URL blocked by SSRF guard:",this.webhookUrl);return}try{let t=await fetch(this.webhookUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:AbortSignal.timeout(5e3)});t.ok||console.debug(`[NotificationService] Webhook returned ${t.status}`)}catch(t){console.debug("[NotificationService] Webhook delivery failed:",t)}}}pruneOldNotifications(){try{let e=S(this.notificationsDir).filter(i=>i.endsWith(".json")).sort();if(e.length<=this.maxNotifications)return;let t=e.slice(0,e.length-this.maxNotifications);for(let i of t)N(b(this.notificationsDir,i))}catch{}}};var C={tickIntervalMs:3e4,ciPollIntervalMs:5*6e4,coverageCheckIntervalMs:2*6e4,cpuThreshold:.7,memoryThreshold:.8},O=class{queue;gitWatcher;coverageDelta;ciMonitor;testSuggester;nightlyConsolidation;notificationService;tickTimer;_running=!1;_startedAt=0;_tickCount=0;_lastTickAt;_throttled=!1;_commitsAnalyzed=0;_suggestionsGenerated=0;_ciHealth=100;_coverageHealth=100;_lastCICheck;_lastCoverageCheck;_memory;config;constructor(e){this.config={tickIntervalMs:e?.tickIntervalMs??C.tickIntervalMs,ciPollIntervalMs:e?.ciPollIntervalMs??C.ciPollIntervalMs,coverageCheckIntervalMs:e?.coverageCheckIntervalMs??C.coverageCheckIntervalMs,cpuThreshold:e?.cpuThreshold??C.cpuThreshold,memoryThreshold:e?.memoryThreshold??C.memoryThreshold},this.queue=new p,this.gitWatcher=new g(this.queue,e?.git),this.coverageDelta=new f(this.queue,e?.coverage),this.ciMonitor=new y(this.queue,e?.ci),this.testSuggester=new v(e?.suggestions),this.nightlyConsolidation=new w(this.queue,e?.nightly),this.notificationService=new k(e?.notifications)}get running(){return this._running}async start(e){this._running||(this._memory=e,this._running=!0,this._startedAt=Date.now(),this.notificationService.initialize(),await this.gitWatcher.start().catch(t=>{console.debug("[QualityDaemon] Git watcher failed to start:",t)}),this.scheduleTick())}async stop(){this._running&&(this._running=!1,this.tickTimer&&(clearTimeout(this.tickTimer),this.tickTimer=void 0),this.gitWatcher.stop(),this._memory&&await this._memory.set("quality-daemon:state",{stoppedAt:Date.now(),tickCount:this._tickCount,commitsAnalyzed:this._commitsAnalyzed,suggestionsGenerated:this._suggestionsGenerated}))}getStatus(){return{running:this._running,uptimeSeconds:this._running?Math.floor((Date.now()-this._startedAt)/1e3):0,tickCount:this._tickCount,queueDepth:this.queue.depths,lastTickAt:this._lastTickAt,throttled:this._throttled,commitsAnalyzed:this._commitsAnalyzed,suggestionsGenerated:this._suggestionsGenerated,notificationsSent:this.notificationService.sentCount,ciHealth:this._ciHealth,coverageHealth:this._coverageHealth,lastCICheck:this._lastCICheck,lastCoverageCheck:this._lastCoverageCheck}}scheduleTick(){this._running&&(this.tickTimer=setTimeout(()=>this.tick(),this.config.tickIntervalMs),this.tickTimer.unref?.())}async tick(){if(!(!this._running||!this._memory)){if(this._tickCount++,this._lastTickAt=Date.now(),this._throttled=this.isResourceConstrained(),this._throttled){await this.processNowItems(this._memory),this.scheduleTick();return}await this.processQueue(this._memory),await this.runPeriodicChecks(this._memory),this.nightlyConsolidation.scheduleIfDue(),this.queue.pruneExpired(),this.scheduleTick()}}async processQueue(e){let t=0,i=10;for(;t<i&&!this.queue.isEmpty;){let o=this.queue.dequeue();if(!o)break;await this.handleQueueItem(o,e),t++}}async processNowItems(e){let t=this.queue.drainPriority("now");for(let i of t)await this.handleQueueItem(i,e)}async handleQueueItem(e,t){let i=e.payload;switch(i.type){case"git_commit":{this._commitsAnalyzed++;let o=await this.coverageDelta.buildSnapshot(t);if(o){let r=await this.coverageDelta.analyze(o,t,i.changedFiles);if(r.regressionDetected&&await this.notificationService.send({type:"coverage_drop",title:"Coverage Regression Detected",message:`Line coverage delta: ${r.overallDelta.line.toFixed(1)}% (${r.affectedFiles.length} files affected)`,severity:"high",metadata:{delta:r.overallDelta,commit:i.commitHash}}),r.newGaps.length>0){let n=await this.testSuggester.suggest(r.newGaps,i.changedFiles,t);this._suggestionsGenerated+=n.length,n.length>0&&await this.notificationService.send({type:"suggestion_available",title:"New Test Suggestions Available",message:`${n.length} test suggestions generated for uncovered code`,severity:"info",metadata:{count:n.length}})}}break}case"coverage_delta":{let o=await this.testSuggester.getPending(t);o.length>0&&await this.notificationService.send({type:"suggestion_available",title:"Test Suggestions Pending",message:`${o.length} test suggestions awaiting review`,severity:"info",metadata:{count:o.length}});break}case"gate_failure":await this.notificationService.send({type:"gate_failure",title:`Quality Gate Failed: ${i.gateName}`,message:`Score ${i.score} below threshold ${i.threshold}`,severity:"critical",metadata:{gate:i.gateName,score:i.score,threshold:i.threshold}});break;case"ci_failure":await this.notificationService.send({type:"ci_failure",title:`CI Failure: ${i.workflowName}`,message:`Workflow ${i.workflowName} run #${i.runId} concluded: ${i.conclusion}`,severity:"high",metadata:{workflow:i.workflowName,runId:i.runId}});break;case"nightly":{let o={coverageHealth:this._coverageHealth,ciHealth:this._ciHealth,commitsAnalyzed:this._commitsAnalyzed,suggestionsGenerated:this._suggestionsGenerated,notificationsSent:this.notificationService.sentCount,queueDepthAvg:this.queue.size,uptimeSeconds:Math.floor((Date.now()-this._startedAt)/1e3)};await this.nightlyConsolidation.execute(t,o);break}default:console.warn("[QualityDaemon] Unhandled payload type:",i.type)}}async runPeriodicChecks(e){let t=Date.now();if(!this._lastCICheck||t-this._lastCICheck>=this.config.ciPollIntervalMs)try{let i=await this.ciMonitor.check();this._ciHealth=i.healthScore,this._lastCICheck=t,i.flakyWorkflows.length>0&&await this.notificationService.send({type:"flaky_detected",title:"Flaky Workflows Detected",message:`${i.flakyWorkflows.length} workflows showing repeated failures: ${i.flakyWorkflows.join(", ")}`,severity:"medium",metadata:{workflows:i.flakyWorkflows}})}catch{}if(!this._lastCoverageCheck||t-this._lastCoverageCheck>=this.config.coverageCheckIntervalMs)try{let i=await this.coverageDelta.buildSnapshot(e);i&&(this._coverageHealth=Math.round((i.overall.line+i.overall.branch+i.overall.function+i.overall.statement)/4),this._lastCoverageCheck=t)}catch{}}isResourceConstrained(){if(1-ee()/te()>this.config.memoryThreshold)return!0;let t=Z().length;return(t>0?ie()[0]/t:0)>this.config.cpuThreshold}};export{x as a,O as b};
|
|
@@ -1,4 +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.
|
|
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.8");process.exit(0)}
|
|
2
2
|
import{readFileSync as O,existsSync as x,readdirSync as A}from"fs";import{join as y,basename as v}from"path";function m(r){let e=[];if(!r||typeof r!="object")return e.push("Overlay must be a non-null object"),e;let t=r;if((!t.agent||typeof t.agent!="string")&&e.push('Overlay must have a string "agent" field'),t.replace!==void 0)if(typeof t.replace!="object"||t.replace===null)e.push('"replace" must be an object');else{let n=t.replace;n.description!==void 0&&typeof n.description!="string"&&e.push('"replace.description" must be a string'),n.domains!==void 0&&!Array.isArray(n.domains)&&e.push('"replace.domains" must be an array'),n.complexity!==void 0&&typeof n.complexity!="string"&&e.push('"replace.complexity" must be a string')}if(t.append!==void 0)if(typeof t.append!="object"||t.append===null)e.push('"append" must be an object');else{let n=t.append;n.instructions!==void 0&&typeof n.instructions!="string"&&e.push('"append.instructions" must be a string'),n.capabilities!==void 0&&!Array.isArray(n.capabilities)&&e.push('"append.capabilities" must be an array'),n.tags!==void 0&&!Array.isArray(n.tags)&&e.push('"append.tags" must be an array')}if(t.config!==void 0)if(typeof t.config!="object"||t.config===null)e.push('"config" must be an object');else{let n=t.config;n.minimumFindings!==void 0&&typeof n.minimumFindings!="number"&&e.push('"config.minimumFindings" must be a number'),n.maxParallelAgents!==void 0&&typeof n.maxParallelAgents!="number"&&e.push('"config.maxParallelAgents" must be a number'),n.preferredFrameworks!==void 0&&!Array.isArray(n.preferredFrameworks)&&e.push('"config.preferredFrameworks" must be an array'),n.needsContext!==void 0&&typeof n.needsContext!="boolean"&&e.push('"config.needsContext" must be a boolean')}return e}var w=".claude/agent-overrides";function $(r){let e={},t=r.split(`
|
|
3
3
|
`),n=null,i=null,s=null,a=null;for(let o of t){let l=o.replace(/\r$/,"");if(l.trim().startsWith("#")||l.trim()==="")continue;let u=l.length-l.trimStart().length,g=l.trim();if(g.startsWith("- ")){let c=g.slice(2).trim().replace(/^["']|["']$/g,"");s&&s.push(c);continue}if(s&&a){if(i&&n){let c=e[n]||{};c[a]=s,e[n]=c}else if(n){let c=e[n]||{};c[a]=s,e[n]=c}s=null,a=null}let f=g.match(/^(\w[\w.-]*)\s*:\s*(.*)$/);if(!f)continue;let[,p,b]=f,d=b.trim().replace(/^["']|["']$/g,"");if(u===0)d===""||d===void 0?(n=p,i=null,e[p]||(e[p]={})):(e[p]=h(d),n=null,i=null);else if(u<=4&&n)if(d===""||d===void 0)i=p,s=[],a=p;else{let c=e[n]||{};c[p]=h(d),e[n]=c}}if(s&&a&&n){let o=e[n]||{};o[a]=s,e[n]=o}return e}function h(r){if(r==="true")return!0;if(r==="false")return!1;if(r==="null")return null;let e=Number(r);return!isNaN(e)&&r!==""?e:r}function N(r){let e=y(r,w),t={overlays:[],warnings:[],errors:[]};if(!x(e))return t;let n;try{n=A(e).filter(i=>(i.endsWith(".yaml")||i.endsWith(".yml"))&&!i.startsWith("_"))}catch(i){return t.errors.push(`Failed to read overrides directory: ${i.message}`),t}for(let i of n){let s=y(e,i);try{let a=O(s,"utf-8"),o=$(a);if(!o.agent){let u=v(i).replace(/\.(override|customize)\.(yaml|yml)$/,"");o.agent=u}let l=m(o);if(l.length>0){t.warnings.push(`Overlay ${i} has validation issues: ${l.join("; ")}. Loading without overlay.`);continue}t.overlays.push(o)}catch(a){t.warnings.push(`Failed to parse overlay ${i}: ${a.message}. Agent loads without overlay.`)}}return t}function E(r,e){let t=r,n={agentName:e.agent,overlayFile:`${e.agent}.override.yaml`,replacedFields:[],appendedFields:[],configOverrides:[]};if(e.replace){if(e.replace.description){let i=/^(description:\s*).+$/m;i.test(t)&&(t=t.replace(i,`$1${e.replace.description}`),n.replacedFields.push("description"))}if(e.replace.domains){let i=/^(domain:\s*).+$/m;i.test(t)&&(t=t.replace(i,`$1${e.replace.domains.join(", ")}`),n.replacedFields.push("domains"))}if(e.replace.complexity){let i=/^(complexity:\s*).+$/m;i.test(t)&&(t=t.replace(i,`$1${e.replace.complexity}`),n.replacedFields.push("complexity"))}}if(e.append){if(e.append.instructions&&(t+=`
|
|
4
4
|
|