agentic-qe 3.15.17 → 3.15.18
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/brain-checkpoint.cjs +107 -10
- package/.claude/skills/agentic-quality-engineering/SKILL.md +67 -44
- package/.claude/skills/brutal-honesty-review/SKILL.md +12 -7
- package/.claude/skills/brutal-honesty-review/evals/brutal-honesty-review.yaml +120 -0
- package/.claude/skills/brutal-honesty-review/schemas/output.json +9 -3
- package/.claude/skills/code-review-quality/SKILL.md +2 -2
- package/.claude/skills/holistic-testing-pact/SKILL.md +11 -11
- package/.claude/skills/sherlock-review/SKILL.md +4 -2
- package/.claude/skills/sherlock-review/evals/sherlock-review.yaml +124 -0
- package/.claude/skills/skills-manifest.json +1 -1
- package/.claude/skills/technical-writing/SKILL.md +12 -6
- package/.claude/skills/technical-writing/evals/technical-writing.yaml +96 -0
- package/.opencode/skills/qe-agentic-quality-engineering.yaml +2 -2
- package/.opencode/skills/qe-holistic-testing-pact.yaml +2 -2
- package/CHANGELOG.md +123 -0
- package/assets/skills/agentic-quality-engineering/SKILL.md +67 -44
- package/assets/skills/brutal-honesty-review/SKILL.md +12 -8
- package/assets/skills/brutal-honesty-review/evals/brutal-honesty-review.yaml +120 -0
- package/assets/skills/brutal-honesty-review/schemas/output.json +9 -3
- package/assets/skills/code-review-quality/SKILL.md +2 -2
- package/assets/skills/holistic-testing-pact/SKILL.md +11 -11
- package/assets/skills/sherlock-review/SKILL.md +4 -3
- package/assets/skills/sherlock-review/evals/sherlock-review.yaml +124 -0
- package/assets/skills/skills-manifest.json +1 -1
- package/assets/skills/technical-writing/SKILL.md +12 -6
- package/assets/skills/technical-writing/evals/technical-writing.yaml +96 -0
- package/dist/cli/brain-commands.d.ts +5 -0
- package/dist/cli/brain-commands.js +4 -0
- package/dist/cli/bundle.js +6 -6
- package/dist/cli/chunks/adapter-WRSDXLOT.js +2 -0
- package/dist/cli/chunks/{agent-booster-wasm-6BUOFQZA.js → agent-booster-wasm-UFNJNF3M.js} +2 -2
- package/dist/cli/chunks/{agent-handler-HPDK3JI3.js → agent-handler-EAYVRJXN.js} +2 -2
- package/dist/cli/chunks/{agent-memory-branch-5QKUTWK5.js → agent-memory-branch-M65C6WAQ.js} +2 -2
- package/dist/cli/chunks/aqe-learning-engine-O6NJBCCM.js +2 -0
- package/dist/cli/chunks/{arena-HZ35LESR.js → arena-2GDICP6R.js} +4 -4
- package/dist/cli/chunks/{arena-7OKPMNHD.js → arena-CG3X67OE.js} +2 -2
- package/dist/cli/chunks/{audit-XI575SVK.js → audit-F4FSPJPL.js} +3 -3
- package/dist/cli/chunks/base-J2FXOE77.js +2 -0
- package/dist/cli/chunks/{better-sqlite3-YO5X7ZJS.js → better-sqlite3-2MCFXW4J.js} +2 -2
- package/dist/cli/chunks/brain-handler-WGTJNYNB.js +95 -0
- package/dist/cli/chunks/{branch-enumerator-N6G44UU2.js → branch-enumerator-KL7C535H.js} +2 -2
- package/dist/cli/chunks/{browser-EVKPTLOI.js → browser-SJEXDVHS.js} +2 -2
- package/dist/cli/chunks/browser-workflow-LXGER6ZD.js +2 -0
- package/dist/cli/chunks/{chunk-VLTDW7XJ.js → chunk-244RKAEP.js} +2 -2
- package/dist/cli/chunks/{chunk-CVPXHDQU.js → chunk-27TUMXPD.js} +1 -1
- package/dist/cli/chunks/{chunk-FBBPRVNF.js → chunk-2MBYDPCP.js} +2 -2
- package/dist/cli/chunks/{chunk-P3D7SEHW.js → chunk-2Q6DTBMT.js} +1 -1
- package/dist/cli/chunks/{chunk-NE3LRUNC.js → chunk-355MI7RV.js} +13 -13
- package/dist/cli/chunks/{chunk-YCVLKU6H.js → chunk-3LX5OKBD.js} +2 -2
- package/dist/cli/chunks/{chunk-74MDUIAZ.js → chunk-3RPDKJGV.js} +1 -1
- package/dist/cli/chunks/{chunk-OWIQR6N2.js → chunk-3YMIT73A.js} +2 -2
- package/dist/cli/chunks/{chunk-VKREKVFI.js → chunk-43KUVBSU.js} +2 -2
- package/dist/cli/chunks/chunk-477FKXSS.js +2 -0
- package/dist/cli/chunks/{chunk-XPTCQKVE.js → chunk-4BIMTRRX.js} +1 -1
- package/dist/cli/chunks/{chunk-HD6W6PHV.js → chunk-4CVNVBX5.js} +2 -2
- package/dist/cli/chunks/{chunk-CQER6IJ5.js → chunk-4HL3SD4A.js} +1 -1
- package/dist/cli/chunks/{chunk-ZNXM6WVL.js → chunk-4PEG4DU2.js} +2 -2
- package/dist/cli/chunks/{chunk-BSIWI4ES.js → chunk-4QSQKFED.js} +2 -2
- package/dist/cli/chunks/chunk-53ZBETYR.js +16 -0
- package/dist/cli/chunks/{chunk-BHQ2DLJU.js → chunk-544KDWL4.js} +1 -1
- package/dist/cli/chunks/chunk-54RCGMLB.js +8 -0
- package/dist/cli/chunks/{chunk-TDZ6N43D.js → chunk-5AGXIZQ5.js} +2 -2
- package/dist/cli/chunks/{chunk-RKCN4B26.js → chunk-5M24X6W7.js} +2 -2
- package/dist/cli/chunks/{chunk-GG7PMTHD.js → chunk-5O5T4LEU.js} +1 -1
- package/dist/cli/chunks/{chunk-OWIZBZLN.js → chunk-5RFXX4IF.js} +2 -2
- package/dist/cli/chunks/{chunk-VQFV2IPV.js → chunk-62MLAQRJ.js} +1 -1
- package/dist/cli/chunks/{chunk-PCL5JRKN.js → chunk-6D6TGL2E.js} +2 -2
- package/dist/cli/chunks/{chunk-WBDWHHKP.js → chunk-6IHZDSDL.js} +2 -2
- package/dist/cli/chunks/{chunk-UOVCTK5L.js → chunk-6P3Y45QL.js} +2 -2
- package/dist/cli/chunks/{chunk-45223KK6.js → chunk-6TEVM3X3.js} +10 -10
- package/dist/cli/chunks/{chunk-K7WAI662.js → chunk-7XTUKKRA.js} +1 -1
- package/dist/cli/chunks/chunk-A3GDX6UF.js +2 -0
- package/dist/cli/chunks/{chunk-GN6OE3JT.js → chunk-A5YTKKNA.js} +1 -1
- package/dist/cli/chunks/{chunk-KR2TAAF6.js → chunk-ADNGZAT2.js} +1 -1
- package/dist/cli/chunks/{chunk-J7Q5TXFZ.js → chunk-AWQAE3SW.js} +2 -2
- package/dist/cli/chunks/{chunk-ZN35XSKF.js → chunk-AXDBQFR4.js} +2 -2
- package/dist/cli/chunks/{chunk-ND72UDVH.js → chunk-AXVD7O3F.js} +2 -2
- package/dist/cli/chunks/{chunk-SAEECT23.js → chunk-B52ULNYO.js} +2 -2
- package/dist/cli/chunks/chunk-B6S4FC7M.js +3 -0
- package/dist/cli/chunks/{chunk-Z7SKUC6P.js → chunk-BDVFSMOQ.js} +1 -1
- package/dist/cli/chunks/{chunk-CXCMATZ6.js → chunk-BGXXMX3Y.js} +2 -2
- package/dist/cli/chunks/{chunk-R3KBOQ3O.js → chunk-BKMQQY5T.js} +2 -2
- package/dist/cli/chunks/{chunk-SAZ4PJBR.js → chunk-BN2FROBQ.js} +2 -2
- package/dist/cli/chunks/{chunk-G2X3OLMN.js → chunk-BO6EQNOC.js} +2 -2
- package/dist/cli/chunks/{chunk-776K4ZLE.js → chunk-BOVAKCDC.js} +2 -2
- package/dist/cli/chunks/{chunk-QSQNXBD2.js → chunk-BSXKZDKO.js} +2 -2
- package/dist/cli/chunks/{chunk-MGZ6XZHU.js → chunk-C5QVJ5XQ.js} +1 -1
- package/dist/cli/chunks/{chunk-LOLSZG5J.js → chunk-CFQLLF3D.js} +2 -2
- package/dist/cli/chunks/{chunk-J6QRNQJF.js → chunk-DUCVLT3F.js} +7 -7
- package/dist/cli/chunks/{chunk-QTQDX4TZ.js → chunk-E4RMJCGA.js} +3 -3
- package/dist/cli/chunks/{chunk-MLMD3I75.js → chunk-EONDCWY4.js} +1 -1
- package/dist/cli/chunks/{chunk-7BSOO3CY.js → chunk-F4AGNKL2.js} +2 -2
- package/dist/cli/chunks/{chunk-IKB3M7OF.js → chunk-F6YD3BOW.js} +1 -1
- package/dist/cli/chunks/{chunk-LIF6UWHV.js → chunk-FQRS7WVA.js} +2 -2
- package/dist/cli/chunks/{chunk-QJSSUBO3.js → chunk-FT24SSDG.js} +2 -2
- package/dist/cli/chunks/chunk-FV4YNSAJ.js +5 -0
- package/dist/cli/chunks/{chunk-VITV7AEC.js → chunk-FVDM3X42.js} +2 -2
- package/dist/cli/chunks/{chunk-LN7NKE3N.js → chunk-FVH7TXWU.js} +2 -2
- package/dist/cli/chunks/{chunk-FBSBXCZS.js → chunk-FWR5QY37.js} +2 -2
- package/dist/cli/chunks/{chunk-X2DWHGCC.js → chunk-FYINK2B7.js} +2 -2
- package/dist/cli/chunks/{chunk-ECKHDHR2.js → chunk-GGISVPOZ.js} +2 -2
- package/dist/cli/chunks/{chunk-SRBCBVSI.js → chunk-GPIJIZJQ.js} +2 -2
- package/dist/cli/chunks/{chunk-YR5QBUHZ.js → chunk-GXEVOT5F.js} +2 -2
- package/dist/cli/chunks/{chunk-ZTP3DQ5M.js → chunk-GZ4VB5RI.js} +1 -1
- package/dist/cli/chunks/{chunk-HWQPMUSN.js → chunk-HBDSCYSK.js} +2 -2
- package/dist/cli/chunks/{chunk-XBTGEYED.js → chunk-HGG4HR7C.js} +2 -2
- package/dist/cli/chunks/{chunk-YD2C6EPN.js → chunk-HSCKWWO2.js} +2 -2
- package/dist/cli/chunks/{chunk-LOMT4UC2.js → chunk-HSQ3GUYJ.js} +2 -2
- package/dist/cli/chunks/{chunk-ZC3KDNJW.js → chunk-HZQBW5EM.js} +3 -3
- package/dist/cli/chunks/{chunk-SUAZ5Z47.js → chunk-IGIYANVT.js} +2 -2
- package/dist/cli/chunks/{chunk-IHQGNDMX.js → chunk-IPWMSXBF.js} +2 -2
- package/dist/cli/chunks/{chunk-6V6BD6PH.js → chunk-IWVNC7VY.js} +1 -1
- package/dist/cli/chunks/{chunk-M2YI5YUR.js → chunk-IZODXKZD.js} +2 -2
- package/dist/cli/chunks/{chunk-LG5PPJT7.js → chunk-J2MT2OJV.js} +1 -1
- package/dist/cli/chunks/{chunk-6LSZCEW2.js → chunk-JKIJVVSP.js} +1 -1
- package/dist/cli/chunks/{chunk-REY52O7J.js → chunk-JMRDT2XK.js} +1 -1
- package/dist/cli/chunks/{chunk-XEYFZLIT.js → chunk-JR2UMTKG.js} +1 -1
- package/dist/cli/chunks/{chunk-DJDVD6RM.js → chunk-K6CH4CFF.js} +2 -2
- package/dist/cli/chunks/{chunk-2PCEMDIX.js → chunk-K7KW5QB5.js} +78 -87
- package/dist/cli/chunks/{chunk-EPVPXHL7.js → chunk-KFCQP434.js} +2 -2
- package/dist/cli/chunks/{chunk-TWBZONKT.js → chunk-KH4T6STG.js} +2 -2
- package/dist/cli/chunks/{chunk-JI33PMPZ.js → chunk-KJBYZO57.js} +1 -1
- package/dist/cli/chunks/{chunk-PK34KJH7.js → chunk-KP4OKOKV.js} +2 -2
- package/dist/cli/chunks/chunk-L2MBKVSE.js +2 -0
- package/dist/cli/chunks/{chunk-JVWZAE2H.js → chunk-L3IPUIT3.js} +2 -2
- package/dist/cli/chunks/{chunk-KT2QCXO6.js → chunk-L7PSU2YN.js} +2 -2
- package/dist/cli/chunks/{chunk-HAQJFUAQ.js → chunk-LA3JPGQA.js} +2 -2
- package/dist/cli/chunks/{chunk-LV7UIK4Q.js → chunk-LC2QRN7V.js} +14 -13
- package/dist/cli/chunks/{chunk-KTORRIX3.js → chunk-LHY7TMTM.js} +2 -2
- package/dist/cli/chunks/{chunk-IJSROBM6.js → chunk-LLQ2UMF6.js} +3 -3
- package/dist/cli/chunks/{chunk-NKUHMA4T.js → chunk-LOJ7OO6W.js} +2 -2
- package/dist/cli/chunks/{chunk-OJIUIEI4.js → chunk-LPUSH3VF.js} +1 -1
- package/dist/cli/chunks/{chunk-WAOEQA3W.js → chunk-LSEC2BU7.js} +2 -2
- package/dist/cli/chunks/{chunk-YMUY3TES.js → chunk-LTGB7OIU.js} +2 -2
- package/dist/cli/chunks/{chunk-CVYPMGUM.js → chunk-LUG7YNVZ.js} +2 -2
- package/dist/cli/chunks/{chunk-YAJOBZE5.js → chunk-LWAFRYKE.js} +2 -2
- package/dist/cli/chunks/{chunk-ZP5AWQRO.js → chunk-M24ZAZ4U.js} +2 -2
- package/dist/cli/chunks/{chunk-HFZD5KLR.js → chunk-MKRKRXTX.js} +1 -1
- package/dist/cli/chunks/{chunk-4YM45Z5B.js → chunk-MNNLONAD.js} +1 -1
- package/dist/cli/chunks/{chunk-CMN7PU2H.js → chunk-MQM37KAR.js} +2 -2
- package/dist/cli/chunks/{chunk-COTQ44YO.js → chunk-MSX2OHYT.js} +2 -2
- package/dist/cli/chunks/{chunk-4UKTIQDT.js → chunk-MVYQRVLP.js} +2 -2
- package/dist/cli/chunks/{chunk-HRUHHHVR.js → chunk-MZC5WM2P.js} +2 -2
- package/dist/cli/chunks/{chunk-YKRLUTK7.js → chunk-MZRBNBB3.js} +2 -2
- package/dist/cli/chunks/{chunk-XEMCHGAJ.js → chunk-N3KQU4UC.js} +2 -2
- package/dist/cli/chunks/{chunk-DS5IFRY6.js → chunk-NKU3FFM4.js} +2 -2
- package/dist/cli/chunks/chunk-O5EWFR76.js +2 -0
- package/dist/cli/chunks/{chunk-J3QFJI2Y.js → chunk-O5RDHD5T.js} +2 -2
- package/dist/cli/chunks/chunk-O6UWIXME.js +3 -0
- package/dist/cli/chunks/{chunk-Q6F3DYZN.js → chunk-OA4EQDC4.js} +2 -2
- package/dist/cli/chunks/{chunk-NQFDJ6BT.js → chunk-OBCXCRXK.js} +1 -1
- package/dist/cli/chunks/{chunk-S3TBOKAZ.js → chunk-OHU5P25N.js} +4 -4
- package/dist/cli/chunks/{chunk-DNVRTJKB.js → chunk-OOSV2RIA.js} +2 -2
- package/dist/cli/chunks/{chunk-NZJVDOUN.js → chunk-OW23N2Y5.js} +2 -2
- package/dist/cli/chunks/{chunk-ZWUF27P4.js → chunk-OXOO3YDL.js} +2 -2
- package/dist/cli/chunks/{chunk-4L6WX5KC.js → chunk-OYGKSSSI.js} +1 -1
- package/dist/cli/chunks/{chunk-DCDSN67A.js → chunk-PGO46IIW.js} +1 -1
- package/dist/cli/chunks/{chunk-C7QLLMYI.js → chunk-PZOYQHWS.js} +1 -1
- package/dist/cli/chunks/{chunk-BKHEQIRZ.js → chunk-Q2BZSG7Z.js} +2 -2
- package/dist/cli/chunks/{chunk-5FSPELOG.js → chunk-Q7V722K5.js} +2 -2
- package/dist/cli/chunks/{chunk-2EQK7B5L.js → chunk-QZU6M5IO.js} +2 -2
- package/dist/cli/chunks/{chunk-HVT7RMGV.js → chunk-R55Y76SJ.js} +1 -1
- package/dist/cli/chunks/{chunk-POPSZDI2.js → chunk-RMEQYJPU.js} +4 -4
- package/dist/cli/chunks/{chunk-H2LHWZRE.js → chunk-RTYXFXTI.js} +2 -2
- package/dist/cli/chunks/{chunk-QN7HP2UW.js → chunk-SJF3O4FX.js} +236 -236
- package/dist/cli/chunks/{chunk-2YWYW7NU.js → chunk-SOUS7Z2H.js} +2 -2
- package/dist/cli/chunks/{chunk-U5SMBJ6F.js → chunk-SRVNR3R3.js} +2 -2
- package/dist/cli/chunks/{chunk-ZAQMRFBB.js → chunk-SU3SXMVG.js} +2 -2
- package/dist/cli/chunks/chunk-SWGPLXWW.js +32 -0
- package/dist/cli/chunks/{chunk-S3DT5TPR.js → chunk-TRB3EVH3.js} +2 -2
- package/dist/cli/chunks/{chunk-IJZFJPHS.js → chunk-TVBDUMKT.js} +2 -2
- package/dist/cli/chunks/{chunk-7SNSI4VY.js → chunk-TWTXPSFU.js} +1 -1
- package/dist/cli/chunks/{chunk-ORQ2YBRR.js → chunk-ULYUVUL2.js} +2 -2
- package/dist/cli/chunks/{chunk-MVVVGQJ6.js → chunk-UNTBVJ5X.js} +2 -2
- package/dist/cli/chunks/{chunk-5WATBVU6.js → chunk-UQAA4PHU.js} +2 -2
- package/dist/cli/chunks/{chunk-5WYZVSL2.js → chunk-UWSJVKTE.js} +1 -1
- package/dist/cli/chunks/{chunk-JHKKIJT2.js → chunk-V2LJ54KP.js} +2 -2
- package/dist/cli/chunks/{chunk-2UUZCQSD.js → chunk-VCCTTKP3.js} +2 -2
- package/dist/cli/chunks/{chunk-P4OB6WDJ.js → chunk-VEGUYUVS.js} +1 -1
- package/dist/cli/chunks/{chunk-WX4PO65Q.js → chunk-VUQPVWNK.js} +2 -2
- package/dist/cli/chunks/{chunk-IQL6XRF5.js → chunk-VVGUE2T2.js} +2 -2
- package/dist/cli/chunks/{chunk-HZ5O7G2P.js → chunk-W5ASDHJQ.js} +1 -1
- package/dist/cli/chunks/{chunk-U4S74IIZ.js → chunk-WGXT5NWQ.js} +1 -1
- package/dist/cli/chunks/chunk-WJN3V7QB.js +7 -0
- package/dist/cli/chunks/chunk-WPCRQIIF.js +29 -0
- package/dist/cli/chunks/{chunk-AGCS5GSO.js → chunk-WQNLXUWA.js} +6 -6
- package/dist/cli/chunks/{chunk-LRY6UIRI.js → chunk-WZVRMKG2.js} +2 -2
- package/dist/cli/chunks/{chunk-KPIPVSIP.js → chunk-X27IUWTD.js} +2 -2
- package/dist/cli/chunks/{chunk-VDEKVIP5.js → chunk-X4B345B6.js} +2 -2
- package/dist/cli/chunks/{chunk-ERYADKMZ.js → chunk-X5I2Y4VO.js} +2 -2
- package/dist/cli/chunks/{chunk-EUWG2JG4.js → chunk-X7IQIFTS.js} +2 -2
- package/dist/cli/chunks/chunk-XJN3RKUD.js +3 -0
- package/dist/cli/chunks/{chunk-JRIJM4LE.js → chunk-XQMGXTHJ.js} +3 -3
- package/dist/cli/chunks/{chunk-VYPVU3JF.js → chunk-XTSAMB2Q.js} +2 -2
- package/dist/cli/chunks/{chunk-4NKZU2JZ.js → chunk-XZLIF4O2.js} +2 -2
- package/dist/cli/chunks/{chunk-XFTX3KLE.js → chunk-Y4LSEOZ3.js} +1 -1
- package/dist/cli/chunks/{chunk-ZVMSSCTH.js → chunk-Y4YN2RXR.js} +2 -2
- package/dist/cli/chunks/{chunk-X5QD76IU.js → chunk-YDI56L35.js} +2 -2
- package/dist/cli/chunks/{chunk-LRKLATSH.js → chunk-YFILS5D5.js} +2 -2
- package/dist/cli/chunks/{chunk-AVHYJ3XP.js → chunk-YISDX6WB.js} +2 -2
- package/dist/cli/chunks/{chunk-GPPTRKEM.js → chunk-YP2GHQSV.js} +2 -2
- package/dist/cli/chunks/{chunk-OO2M2QUV.js → chunk-YSX756AM.js} +4 -4
- package/dist/cli/chunks/{chunk-E7XIMOKW.js → chunk-YWANOASW.js} +2 -2
- package/dist/cli/chunks/{chunk-UHJVZEQA.js → chunk-YYIJLG7S.js} +2 -2
- package/dist/cli/chunks/{chunk-LCWEQRZI.js → chunk-Z7SD7LXM.js} +2 -2
- package/dist/cli/chunks/{chunk-TM75GAXG.js → chunk-ZDWD73UF.js} +2 -2
- package/dist/cli/chunks/{chunk-IRHXGCQR.js → chunk-ZFT3RLA4.js} +2 -2
- package/dist/cli/chunks/{chunk-ZGV7L4MW.js → chunk-ZNTHX5G3.js} +1 -1
- package/dist/cli/chunks/{chunk-D75GLKEL.js → chunk-ZS27R7VL.js} +2 -2
- package/dist/cli/chunks/{chunk-INI3Q4CN.js → chunk-ZXHHHR7K.js} +1 -1
- package/dist/cli/chunks/{ci-3RTTTS2D.js → ci-N5MOMNXH.js} +2 -2
- package/dist/cli/chunks/{ci-config-XRUR3I4K.js → ci-config-6L2ROQCW.js} +2 -2
- package/dist/cli/chunks/{ci-output-E5IAMU2U.js → ci-output-DSRBYEIK.js} +2 -2
- package/dist/cli/chunks/{circuit-breaker-SHR2P44P.js → circuit-breaker-VRPTNBL7.js} +2 -2
- package/dist/cli/chunks/{claude-flow-setup-ZDDILFMF.js → claude-flow-setup-4YFG3FU5.js} +2 -2
- package/dist/cli/chunks/client-I3L6BKRQ.js +2 -0
- package/dist/cli/chunks/{cline-installer-BGYVUM6G.js → cline-installer-7RGYJWGN.js} +2 -2
- package/dist/cli/chunks/{code-PJ4MC3MC.js → code-ISC6NW2K.js} +3 -3
- package/dist/cli/chunks/{code-index-extractor-IW2P22YG.js → code-index-extractor-2FID75YV.js} +2 -2
- package/dist/cli/chunks/{codex-installer-A7WZ6OGL.js → codex-installer-DZ7OG6KM.js} +2 -2
- package/dist/cli/chunks/{completions-KS23WD5J.js → completions-SM3LICWK.js} +2 -2
- package/dist/cli/chunks/{complexity-analyzer-Q7GLSR2E.js → complexity-analyzer-ZWD2CTAD.js} +2 -2
- package/dist/cli/chunks/{continuedev-installer-SK55BFW2.js → continuedev-installer-AGASOA26.js} +2 -2
- package/dist/cli/chunks/{copilot-installer-3N5J3WTM.js → copilot-installer-CLPZYTQC.js} +2 -2
- package/dist/cli/chunks/core-handlers-5EFOJ37H.js +2 -0
- package/dist/cli/chunks/{cost-tracker-NENVSO4A.js → cost-tracker-7PIGQYDV.js} +2 -2
- package/dist/cli/chunks/{coverage-5L7UQWDH.js → coverage-T2GEBTYS.js} +9 -9
- package/dist/cli/chunks/cross-domain-router-65WJAKVD.js +2 -0
- package/dist/cli/chunks/{cursor-installer-XXBO2ZE6.js → cursor-installer-KXBID4MB.js} +2 -2
- package/dist/cli/chunks/daemon-43MXIVH3.js +18 -0
- package/dist/cli/chunks/{daemon-CDCQU3LR.js → daemon-VAMJLQJ5.js} +3 -3
- package/dist/cli/chunks/{dag-attention-scheduler-HOMMF7FA.js → dag-attention-scheduler-UBP4VHTA.js} +2 -2
- package/dist/cli/chunks/{detect-FXCOUG6X.js → detect-QWFIQRKI.js} +2 -2
- package/dist/cli/chunks/{dist-node-GXQ7FMTY.js → dist-node-I2GICS3W.js} +2 -2
- package/dist/cli/chunks/{domain-handler-TI3JBAPC.js → domain-handler-Z66ISB2A.js} +2 -2
- package/dist/cli/chunks/{domain-plugins-R7LTUM32.js → domain-plugins-KHMD3FKT.js} +2 -2
- package/dist/cli/chunks/{domain-transfer-LBIAFHIQ.js → domain-transfer-JWGNNA6K.js} +2 -2
- package/dist/cli/chunks/dream-VQ2PZCVR.js +2 -0
- package/dist/cli/chunks/embed-and-insert-pattern-F5P5B6JX.js +3 -0
- package/dist/cli/chunks/{embedding-space-HHLWTBF5.js → embedding-space-KHG6TITM.js} +2 -2
- package/dist/cli/chunks/{eval-KDOZMAXJ.js → eval-43OHU7EI.js} +2 -2
- package/dist/cli/chunks/{experience-capture-middleware-X45PECQN.js → experience-capture-middleware-KXD47H6P.js} +3 -3
- package/dist/cli/chunks/{fast-paths-462V6UUB.js → fast-paths-6D75D5KD.js} +2 -2
- package/dist/cli/chunks/{feature-flags-NIRQ4YDM.js → feature-flags-IE35Y55N.js} +2 -2
- package/dist/cli/chunks/{feature-flags-G66OT3AS.js → feature-flags-OYYHY7LS.js} +2 -2
- package/dist/cli/chunks/file-discovery-LGBTY3ID.js +2 -0
- package/dist/cli/chunks/{fleet-PXWGB7CU.js → fleet-AGVJMFGD.js} +16 -16
- package/dist/cli/chunks/{gnn-wrapper-7MUW3M5M.js → gnn-wrapper-5L66A7LW.js} +2 -2
- package/dist/cli/chunks/{heartbeat-handler-5237PB35.js → heartbeat-handler-2BY6YYOT.js} +5 -5
- package/dist/cli/chunks/heartbeat-scheduler-3DU3M5AT.js +2 -0
- package/dist/cli/chunks/hnsw-adapter-N2IMSRPV.js +2 -0
- package/dist/cli/chunks/hnsw-index-DVU7TTJE.js +2 -0
- package/dist/cli/chunks/{hnsw-legacy-bridge-OSQPW7JP.js → hnsw-legacy-bridge-RYMWFNAH.js} +2 -2
- package/dist/cli/chunks/{hnswlib-node-GX6WG2GB.js → hnswlib-node-GG47HP2P.js} +2 -2
- package/dist/cli/chunks/{hooks-GUWHL7VC.js → hooks-FQNACS24.js} +10 -10
- package/dist/cli/chunks/hybrid-backend-AS2PNHOD.js +2 -0
- package/dist/cli/chunks/{hypergraph-engine-SRWLLCU3.js → hypergraph-engine-6BYNJQEP.js} +2 -2
- package/dist/cli/chunks/{hypergraph-handler-AVOPRHHO.js → hypergraph-handler-CYTAXZKJ.js} +3 -3
- package/dist/cli/chunks/impact-analyzer-Y4OONLFP.js +2 -0
- package/dist/cli/chunks/{init-guard-P4N6EVZS.js → init-guard-METTAV5O.js} +2 -2
- package/dist/cli/chunks/{init-handler-LRGWOJMD.js → init-handler-GFT74U5Y.js} +6 -6
- package/dist/cli/chunks/init-wizard-HLNUBJQN.js +2 -0
- package/dist/cli/chunks/kernel-XKFWCL7Y.js +2 -0
- package/dist/cli/chunks/{kilocode-installer-7R2EPOQ6.js → kilocode-installer-GZV2D3FF.js} +2 -2
- package/dist/cli/chunks/{kiro-installer-QNM7DPOB.js → kiro-installer-Q4ZXUFC7.js} +2 -2
- package/dist/cli/chunks/knowledge-graph-CNL77CSZ.js +2 -0
- package/dist/cli/chunks/{learning-7OIZBPXZ.js → learning-WA2QEYL7.js} +35 -34
- package/dist/cli/chunks/{llm-router-SIDXES23.js → llm-router-GRTCHWH7.js} +4 -4
- package/dist/cli/chunks/llm-router-service-UIYTYKP6.js +2 -0
- package/dist/cli/chunks/{load-EI2E2C3S.js → load-WXN3Q7Y5.js} +2 -2
- package/dist/cli/chunks/load-test-PXLW4A5B.js +2 -0
- package/dist/cli/chunks/{mcp-IOE5WOCS.js → mcp-LIQCPSJN.js} +2 -2
- package/dist/cli/chunks/{memory-DLYGJAP7.js → memory-OP6CHRFH.js} +5 -5
- package/dist/cli/chunks/memory-backend-XYOSO73Q.js +2 -0
- package/dist/cli/chunks/memory-handlers-PQFYVNVG.js +2 -0
- package/dist/cli/chunks/{multi-model-executor-WHH4YCHM.js → multi-model-executor-H54DEVRZ.js} +2 -2
- package/dist/cli/chunks/{opencode-installer-63FDZAMS.js → opencode-installer-BSQV6UAT.js} +2 -2
- package/dist/cli/chunks/{orchestrator-3LA776KK.js → orchestrator-TJDPQ4VL.js} +122 -35
- package/dist/cli/chunks/pattern-null-store-BKGTQFNF.js +2 -0
- package/dist/cli/chunks/{pattern-usage-recorder-NW54QUGI.js → pattern-usage-recorder-FOVS4M5L.js} +2 -2
- package/dist/cli/chunks/{pipeline-P3TYX6J6.js → pipeline-4AY2ZIC6.js} +2 -2
- package/dist/cli/chunks/{platform-FNA2WLI6.js → platform-FCSITYMR.js} +2 -2
- package/dist/cli/chunks/{plugin-NJS7BC2S.js → plugin-E56TV5S2.js} +2 -2
- package/dist/cli/chunks/{prime-radiant-advanced-wasm-NIAVL2OT.js → prime-radiant-advanced-wasm-ACOPC533.js} +2 -2
- package/dist/cli/chunks/project-root-MPX7CN2C.js +2 -0
- package/dist/cli/chunks/protocol-executor-CRQOCC4A.js +2 -0
- package/dist/cli/chunks/{protocol-handler-JU5C4JHY.js → protocol-handler-KRVXF4LS.js} +2 -2
- package/dist/cli/chunks/{prove-35VOSLYP.js → prove-KMFPSKGD.js} +2 -2
- package/dist/cli/chunks/qe-reasoning-bank-UEGQ3O7F.js +2 -0
- package/dist/cli/chunks/{quality-ET74X7HN.js → quality-6DBI3HLB.js} +2 -2
- package/dist/cli/chunks/{quality-gate-FEDQISNB.js → quality-gate-3ROZMEIL.js} +3 -3
- package/dist/cli/chunks/queen-coordinator-32574XSG.js +2 -0
- package/dist/cli/chunks/real-embeddings-MIGZNKK3.js +2 -0
- package/dist/cli/chunks/{ref-validation-DTBPYCEB.js → ref-validation-EYIP7DHW.js} +2 -2
- package/dist/cli/chunks/{roocode-installer-LYQEMR4J.js → roocode-installer-IGGZHR2Y.js} +2 -2
- package/dist/cli/chunks/router-CZJY5WX6.js +2 -0
- package/dist/cli/chunks/routing-feedback-RC3UBNFX.js +2 -0
- package/dist/cli/chunks/{routing-handler-DJOJFPII.js → routing-handler-BWNHBYDC.js} +2 -2
- package/dist/cli/chunks/{ruvector-commands-VXYGJDPW.js → ruvector-commands-PXIHF432.js} +2 -2
- package/dist/cli/chunks/rvf-dual-writer-OG7OV2AK.js +2 -0
- package/dist/cli/chunks/rvf-migration-adapter-THYMW7ZO.js +2 -0
- package/dist/cli/chunks/rvf-migration-coordinator-3H6CLFU7.js +2 -0
- package/dist/cli/chunks/rvf-native-adapter-6JQJIKKW.js +2 -0
- package/dist/cli/chunks/{rvf-store-integrity-GA2ZYOEG.js → rvf-store-integrity-CVB3NMSL.js} +2 -2
- package/dist/cli/chunks/safe-db-QFKCVTIJ.js +2 -0
- package/dist/cli/chunks/schedule-6JLVMMYB.js +2 -0
- package/dist/cli/chunks/scheduler-3MPZRMJD.js +2 -0
- package/dist/cli/chunks/{security-MM6YOECX.js → security-DCRGOTWU.js} +3 -3
- package/dist/cli/chunks/{shared-rvf-adapter-6AHPA3V5.js → shared-rvf-adapter-GKD74QUB.js} +2 -2
- package/dist/cli/chunks/{shared-rvf-dual-writer-EYAVY2GZ.js → shared-rvf-dual-writer-HVAAVEOH.js} +2 -2
- package/dist/cli/chunks/sqlite-persistence-LGTIKAEX.js +2 -0
- package/dist/cli/chunks/{standalone-memory-A3PLB4CZ.js → standalone-memory-O7O2U5N4.js} +2 -2
- package/dist/cli/chunks/{status-handler-OSSFAP4Z.js → status-handler-BQTPJJTL.js} +2 -2
- package/dist/cli/chunks/{structural-health-PGY5XUNO.js → structural-health-4H6J4OHK.js} +2 -2
- package/dist/cli/chunks/sync-DJ4TF6QX.js +2 -0
- package/dist/cli/chunks/{sync-CWEHYGNN.js → sync-WW5TAVYW.js} +2 -2
- package/dist/cli/chunks/{task-handler-LHMQ75W4.js → task-handler-HEM4IEOW.js} +2 -2
- package/dist/cli/chunks/{task-handlers-S2TX5FTR.js → task-handlers-JRA3NXIR.js} +3 -3
- package/dist/cli/chunks/{test-4EGZZ6NJ.js → test-772ZXVG2.js} +4 -4
- package/dist/cli/chunks/test-runner-process-XGF2U3NG.js +2 -0
- package/dist/cli/chunks/{test-scheduling-YJQHH3XE.js → test-scheduling-4TRB7LZ7.js} +3 -3
- package/dist/cli/chunks/token-bootstrap-CICBIJ7T.js +2 -0
- package/dist/cli/chunks/{token-usage-WPNOJR6H.js → token-usage-B7PEKE2G.js} +2 -2
- package/dist/cli/chunks/{transformers-4MRPXCPU.js → transformers-V7X7BDZX.js} +2 -2
- package/dist/cli/chunks/tree-sitter-wasm-parser-OXPFKFZS.js +2 -0
- package/dist/cli/chunks/{types-6P5FB4EB.js → types-AHHTUY3I.js} +2 -2
- package/dist/cli/chunks/unified-memory-GUR3IUI6.js +2 -0
- package/dist/cli/chunks/unified-memory-hnsw-NJP2F2RY.js +2 -0
- package/dist/cli/chunks/unified-persistence-NILBWXDP.js +2 -0
- package/dist/cli/chunks/{upgrade-4ICTN63Y.js → upgrade-DZ4DLUQ5.js} +2 -2
- package/dist/cli/chunks/{validate-HQF5GZ7L.js → validate-4DTLIDJE.js} +2 -2
- package/dist/cli/chunks/{validate-swarm-45JYG7VW.js → validate-swarm-A26UFVIS.js} +2 -2
- package/dist/cli/chunks/visual-security-YECYZ27X.js +2 -0
- package/dist/cli/chunks/{web-tree-sitter-UOTWZLNH.js → web-tree-sitter-F2C7QRYT.js} +2 -2
- package/dist/cli/chunks/{windsurf-installer-WDWSBXGN.js → windsurf-installer-OOBTDA6W.js} +2 -2
- package/dist/cli/chunks/{witness-chain-DOYMNPC7.js → witness-chain-KGFZJP32.js} +2 -2
- package/dist/cli/chunks/witness-chain-LYBXFLJB.js +2 -0
- package/dist/cli/chunks/witness-chain-repair-CNTXOGPN.js +2 -0
- package/dist/cli/chunks/{witness-chain-verifier-JB42X62J.js → witness-chain-verifier-OB7ZZOI3.js} +2 -2
- package/dist/cli/chunks/{witness-key-manager-LXXO6L2G.js → witness-key-manager-YCKGKGQI.js} +2 -2
- package/dist/cli/chunks/{workflow-6ARK47NF.js → workflow-PRERHWKY.js} +4 -4
- package/dist/cli/chunks/workflow-orchestrator-UIBGWCU3.js +2 -0
- package/dist/cli/chunks/wrappers-L4UY4V63.js +2 -0
- package/dist/cli/commands/coverage.js +4 -1
- package/dist/cli/commands/learning-prune.js +9 -1
- package/dist/cli/handlers/brain-handler.js +32 -2
- package/dist/cli/handlers/heartbeat-handler.js +3 -1
- package/dist/cli/utils/coverage-data.js +5 -1
- package/dist/cli/utils/coverage-verdict.d.ts +10 -2
- package/dist/cli/utils/coverage-verdict.js +23 -8
- package/dist/cli/utils/fleet-operation.js +9 -3
- package/dist/coordination/handlers/code-intelligence-handlers.js +17 -3
- package/dist/coordination/handlers/coverage-handlers.js +22 -9
- package/dist/coordination/handlers/coverage-target.d.ts +22 -2
- package/dist/coordination/handlers/coverage-target.js +45 -9
- package/dist/coordination/handlers/handler-utils.d.ts +19 -0
- package/dist/coordination/handlers/handler-utils.js +22 -8
- package/dist/coordination/protocols/code-intelligence-index.js +6 -3
- package/dist/coordination/protocols/learning-consolidation-archive.d.ts +6 -3
- package/dist/coordination/protocols/learning-consolidation-archive.js +4 -3
- package/dist/coordination/workflow-builtin.js +1 -0
- package/dist/domains/defect-intelligence/interfaces.d.ts +2 -0
- package/dist/domains/defect-intelligence/prediction-history.d.ts +15 -1
- package/dist/domains/defect-intelligence/prediction-history.js +63 -7
- package/dist/domains/defect-intelligence/services/defect-predictor.d.ts +1 -0
- package/dist/domains/defect-intelligence/services/defect-predictor.js +33 -13
- package/dist/domains/learning-optimization/coordinator.js +17 -10
- package/dist/domains/learning-optimization/domain-ranking.d.ts +26 -0
- package/dist/domains/learning-optimization/domain-ranking.js +28 -0
- package/dist/domains/learning-optimization/interfaces.d.ts +5 -0
- package/dist/domains/learning-optimization/pattern-archive.d.ts +55 -8
- package/dist/domains/learning-optimization/pattern-archive.js +90 -17
- package/dist/domains/learning-optimization/pattern-consolidation.js +18 -2
- package/dist/domains/learning-optimization/pattern-merge.d.ts +26 -0
- package/dist/domains/learning-optimization/pattern-merge.js +127 -0
- package/dist/domains/learning-optimization/services/learning-coordinator.js +21 -35
- package/dist/domains/test-execution/services/test-executor.js +6 -2
- package/dist/init/init-wizard-steps.js +3 -1
- package/dist/init/phases/07-hooks.js +97 -10
- package/dist/integrations/embeddings/cache/EmbeddingCache.js +1 -1
- package/dist/integrations/ruvector/brain-rvf-exporter.d.ts +16 -1
- package/dist/integrations/ruvector/brain-rvf-exporter.js +18 -32
- package/dist/integrations/ruvector/brain-rvf-richness.d.ts +75 -0
- package/dist/integrations/ruvector/brain-rvf-richness.js +127 -0
- package/dist/kernel/unified-memory-migration.js +1 -1
- package/dist/learning/checkpoint-shrink-ack.d.ts +25 -0
- package/dist/learning/checkpoint-shrink-ack.js +57 -0
- package/dist/learning/dream/dream-engine.d.ts +44 -3
- package/dist/learning/dream/dream-engine.js +6 -2
- package/dist/learning/embedder-identity-store.js +3 -1
- package/dist/learning/embedding-space-legacy-adoption.d.ts +53 -0
- package/dist/learning/embedding-space-legacy-adoption.js +115 -0
- package/dist/learning/embedding-space-registry.d.ts +15 -0
- package/dist/learning/embedding-space-registry.js +50 -11
- package/dist/learning/experience-capture.d.ts +3 -1
- package/dist/learning/experience-capture.js +15 -5
- package/dist/learning/experience-space-verification.d.ts +2 -0
- package/dist/learning/experience-space-verification.js +3 -2
- package/dist/learning/learning-retention.js +4 -0
- package/dist/learning/pattern-promotion.d.ts +7 -0
- package/dist/learning/pattern-promotion.js +64 -12
- package/dist/learning/real-embeddings.js +31 -7
- package/dist/learning/rvf-pattern-store.js +6 -1
- package/dist/mcp/bundle.js +570 -558
- package/dist/mcp/handlers/domain-handler-configs.d.ts +3 -0
- package/dist/mcp/handlers/domain-handler-configs.js +1 -0
- package/dist/mcp/handlers/heartbeat-handlers.d.ts +4 -2
- package/dist/mcp/tools/learning-optimization/optimize.d.ts +6 -1
- package/dist/mcp/tools/learning-optimization/optimize.js +20 -11
- package/dist/planning/goap-planner.js +4 -0
- package/dist/planning/plan-executor.js +6 -2
- package/dist/shared/git/git-analyzer.d.ts +30 -11
- package/dist/shared/git/git-analyzer.js +95 -48
- package/dist/shared/io/confined-read.d.ts +32 -7
- package/dist/shared/io/confined-read.js +58 -25
- package/dist/shared/io/file-reader.js +4 -1
- package/dist/shared/safe-db.d.ts +1 -1
- package/dist/shared/safe-db.js +20 -5
- package/dist/shared/sqlite-journal-mode.d.ts +39 -0
- package/dist/shared/sqlite-journal-mode.js +53 -0
- package/dist/sync/claude-flow-bridge.js +1 -1
- package/dist/sync/readers/sqlite-reader.js +3 -4
- package/dist/sync/writers/sqlite-writer.js +1 -1
- package/dist/workers/interfaces.d.ts +2 -2
- package/dist/workers/quality-daemon/git-watcher.d.ts +8 -0
- package/dist/workers/quality-daemon/git-watcher.js +54 -12
- package/dist/workers/quality-daemon/index.js +1 -1
- package/dist/workers/quality-daemon/priority-queue.d.ts +2 -1
- package/dist/workers/workers/defect-predictor.d.ts +9 -4
- package/dist/workers/workers/defect-predictor.js +98 -37
- package/package.json +1 -1
- package/dist/cli/chunks/adapter-OMILP6KH.js +0 -2
- package/dist/cli/chunks/aqe-learning-engine-OXH5CCOS.js +0 -2
- package/dist/cli/chunks/base-MAK2BLTG.js +0 -2
- package/dist/cli/chunks/brain-handler-GCQZFZGQ.js +0 -95
- package/dist/cli/chunks/browser-workflow-IR3VF2TL.js +0 -2
- package/dist/cli/chunks/chunk-4EJLHNER.js +0 -12
- package/dist/cli/chunks/chunk-A4BVDYIL.js +0 -2
- package/dist/cli/chunks/chunk-BE7ZHM34.js +0 -3
- package/dist/cli/chunks/chunk-DHKSPOUQ.js +0 -16
- package/dist/cli/chunks/chunk-FAQ24UHB.js +0 -29
- package/dist/cli/chunks/chunk-IOWEBPXJ.js +0 -5
- package/dist/cli/chunks/chunk-KB34MTFZ.js +0 -3
- package/dist/cli/chunks/chunk-MCXW3DKE.js +0 -8
- package/dist/cli/chunks/chunk-O7VJ3VKD.js +0 -2
- package/dist/cli/chunks/chunk-PIWGKGWP.js +0 -3
- package/dist/cli/chunks/chunk-SFITYZLV.js +0 -7
- package/dist/cli/chunks/chunk-TIVKDIF7.js +0 -2
- package/dist/cli/chunks/client-NO5FOWT4.js +0 -2
- package/dist/cli/chunks/core-handlers-JNAZPXE2.js +0 -2
- package/dist/cli/chunks/cross-domain-router-HEBM767Z.js +0 -2
- package/dist/cli/chunks/daemon-JEBJGEUK.js +0 -18
- package/dist/cli/chunks/dream-GQDCEJMS.js +0 -2
- package/dist/cli/chunks/embed-and-insert-pattern-33KLHDD5.js +0 -3
- package/dist/cli/chunks/file-discovery-33USPLB5.js +0 -2
- package/dist/cli/chunks/heartbeat-scheduler-LIXLC5IH.js +0 -2
- package/dist/cli/chunks/hnsw-adapter-62D5UH27.js +0 -2
- package/dist/cli/chunks/hnsw-index-GSGUMQQC.js +0 -2
- package/dist/cli/chunks/hybrid-backend-FRWP4BOY.js +0 -2
- package/dist/cli/chunks/impact-analyzer-7KF3AQXV.js +0 -2
- package/dist/cli/chunks/init-wizard-XWWAXY25.js +0 -2
- package/dist/cli/chunks/kernel-ZEJPNDBW.js +0 -2
- package/dist/cli/chunks/knowledge-graph-RRZQS7KY.js +0 -2
- package/dist/cli/chunks/llm-router-service-3OSW67LC.js +0 -2
- package/dist/cli/chunks/load-test-7TRIH2WJ.js +0 -2
- package/dist/cli/chunks/memory-backend-G7ZW6Q2B.js +0 -2
- package/dist/cli/chunks/memory-handlers-TPF3KCO5.js +0 -2
- package/dist/cli/chunks/pattern-null-store-OU3ZC3NR.js +0 -2
- package/dist/cli/chunks/project-root-GMOFJEKD.js +0 -2
- package/dist/cli/chunks/protocol-executor-AD345XRO.js +0 -2
- package/dist/cli/chunks/qe-reasoning-bank-NLTP26RC.js +0 -2
- package/dist/cli/chunks/queen-coordinator-2TB4FWS6.js +0 -2
- package/dist/cli/chunks/real-embeddings-II6CXTCI.js +0 -2
- package/dist/cli/chunks/router-PLM3MWME.js +0 -2
- package/dist/cli/chunks/routing-feedback-I7VOX2HU.js +0 -2
- package/dist/cli/chunks/rvf-dual-writer-GQZHFWO2.js +0 -2
- package/dist/cli/chunks/rvf-migration-adapter-3TVKBCAM.js +0 -2
- package/dist/cli/chunks/rvf-migration-coordinator-XUHKLMT6.js +0 -2
- package/dist/cli/chunks/rvf-native-adapter-5GUTYOWS.js +0 -2
- package/dist/cli/chunks/safe-db-RZPQGLGQ.js +0 -2
- package/dist/cli/chunks/schedule-G7JMQDUX.js +0 -2
- package/dist/cli/chunks/scheduler-4SEGPCKD.js +0 -2
- package/dist/cli/chunks/sqlite-persistence-IVE4SQXR.js +0 -2
- package/dist/cli/chunks/sync-PM6D7EQF.js +0 -2
- package/dist/cli/chunks/test-runner-process-72YACW6M.js +0 -2
- package/dist/cli/chunks/token-bootstrap-DJNETMVW.js +0 -2
- package/dist/cli/chunks/tree-sitter-wasm-parser-UVWSDXFR.js +0 -2
- package/dist/cli/chunks/unified-memory-2VMGSGQL.js +0 -2
- package/dist/cli/chunks/unified-memory-hnsw-3KULVD3N.js +0 -2
- package/dist/cli/chunks/unified-persistence-QCSLU2SV.js +0 -2
- package/dist/cli/chunks/visual-security-ZYP2KPH7.js +0 -2
- package/dist/cli/chunks/witness-chain-5QRT7EMX.js +0 -2
- package/dist/cli/chunks/witness-chain-repair-CUF2AFQB.js +0 -2
- package/dist/cli/chunks/workflow-orchestrator-RYDDWIXN.js +0 -2
- package/dist/cli/chunks/wrappers-CYQBOMPL.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.15.
|
|
2
|
-
import{a as Re,c as Me}from"./chunk-O7VJ3VKD.js";import{c as Ce}from"./chunk-HWQPMUSN.js";import{d as Se}from"./chunk-ND72UDVH.js";import{a as Le,b as Ke}from"./chunk-LRY6UIRI.js";import{m as Pe,n as Ue}from"./chunk-H2LHWZRE.js";import{b as O,d as Ie}from"./chunk-CMN7PU2H.js";import{c as R,d as I}from"./chunk-REY52O7J.js";import{a as je}from"./chunk-TIVKDIF7.js";import{c as ve,d as Ee,e as _e}from"./chunk-DS5IFRY6.js";import{c as we,d as $e}from"./chunk-GPPTRKEM.js";import{a as W,b as N,e as Y}from"./chunk-J7Q5TXFZ.js";je();import{createRequire as Ge}from"module";var D;function z(){if(!D){let p=Ge(import.meta.url);try{D=p("typescript")}catch{try{D=p("typescript/lib/typescript.js")}catch{D=new Proxy({},{get(e,t){if(!(t==="__esModule"||typeof t=="symbol"))throw new Error("TypeScript is required for code analysis. Install it: npm install -g typescript")}})}}}return D}var m=new Proxy({},{get(p,e){return z()[e]},has(p,e){return e in z()},ownKeys(){return Object.keys(z())},getOwnPropertyDescriptor(p,e){let t=z()[e];if(t!==void 0)return{configurable:!0,enumerable:!0,value:t}}});var F=class{parseFile(e,t){return m.createSourceFile(e,t,m.ScriptTarget.Latest,!0,this.getScriptKind(e))}countSyntaxErrors(e){let t={noLib:!0,noResolve:!0,allowJs:!0,types:[]},s=m.createCompilerHost(t);return s.getSourceFile=()=>e,m.createProgram({rootNames:[e.fileName],options:t,host:s}).getSyntacticDiagnostics(e).length}extractFunctions(e){let t=[],s=n=>{m.isFunctionDeclaration(n)&&n.name?t.push(this.extractFunctionDeclaration(n,e)):m.isVariableStatement(n)&&this.extractArrowFunctions(n,e,t),m.forEachChild(n,s)};return m.forEachChild(e,s),t}extractClasses(e){let t=[],s=n=>{m.isClassDeclaration(n)&&n.name&&t.push(this.extractClassDeclaration(n,e)),m.forEachChild(n,s)};return m.forEachChild(e,s),t}extractImports(e){let t=[],s=n=>{m.isImportDeclaration(n)&&t.push(this.extractImportDeclaration(n)),m.forEachChild(n,s)};return m.forEachChild(e,s),t}extractExports(e){let t=[],s=n=>{if(m.isExportDeclaration(n))this.extractExportDeclaration(n,t);else if(m.isExportAssignment(n))t.push({name:this.getExportAssignmentName(n),type:"unknown",isDefault:!0,isReexport:!1,sourceModule:void 0});else if(m.isFunctionDeclaration(n)&&n.name&&this.hasExportModifier(n))t.push({name:n.name.text,type:"function",isDefault:this.hasDefaultModifier(n),isReexport:!1,sourceModule:void 0});else if(m.isClassDeclaration(n)&&n.name&&this.hasExportModifier(n))t.push({name:n.name.text,type:"class",isDefault:this.hasDefaultModifier(n),isReexport:!1,sourceModule:void 0});else if(m.isVariableStatement(n)&&this.hasExportModifier(n))for(let i of n.declarationList.declarations)m.isIdentifier(i.name)&&t.push({name:i.name.text,type:"variable",isDefault:!1,isReexport:!1,sourceModule:void 0});else m.isInterfaceDeclaration(n)&&this.hasExportModifier(n)?t.push({name:n.name.text,type:"interface",isDefault:!1,isReexport:!1,sourceModule:void 0}):m.isTypeAliasDeclaration(n)&&this.hasExportModifier(n)?t.push({name:n.name.text,type:"type",isDefault:!1,isReexport:!1,sourceModule:void 0}):m.isEnumDeclaration(n)&&this.hasExportModifier(n)&&t.push({name:n.name.text,type:"enum",isDefault:!1,isReexport:!1,sourceModule:void 0});m.forEachChild(n,s)};return m.forEachChild(e,s),t}extractInterfaces(e){let t=[],s=n=>{m.isInterfaceDeclaration(n)&&t.push(this.extractInterfaceDeclaration(n,e)),m.forEachChild(n,s)};return m.forEachChild(e,s),t}extractEntities(e,t){let s=this.parseFile(t,e),n=[],i=this.extractFunctions(s);for(let a of i)n.push({name:a.name,type:"function",line:a.startLine,endLine:a.endLine,visibility:a.isExported?"public":"internal",isAsync:a.isAsync,isExported:a.isExported,parameters:a.parameters,returnType:a.returnType});let o=this.extractClasses(s);for(let a of o)n.push({name:a.name,type:"class",line:a.startLine,endLine:a.endLine,visibility:a.isExported?"public":"internal",isAsync:!1,isExported:a.isExported,extends:a.extends,implements:a.implements});let r=this.extractInterfaces(s);for(let a of r)n.push({name:a.name,type:"interface",line:a.startLine,endLine:a.endLine,visibility:a.isExported?"public":"internal",isAsync:!1,isExported:a.isExported});return n}getScriptKind(e){return e.endsWith(".tsx")?m.ScriptKind.TSX:e.endsWith(".ts")?m.ScriptKind.TS:e.endsWith(".jsx")?m.ScriptKind.JSX:/\.(js|mjs|cjs)$/.test(e)?m.ScriptKind.JS:m.ScriptKind.TS}extractFunctionDeclaration(e,t){let{line:s}=t.getLineAndCharacterOfPosition(e.getStart()),{line:n}=t.getLineAndCharacterOfPosition(e.getEnd());return{name:e.name?.text??"anonymous",parameters:this.extractParameters(e.parameters),returnType:e.type?e.type.getText(t):void 0,startLine:s+1,endLine:n+1,isAsync:this.hasAsyncModifier(e),isExported:this.hasExportModifier(e),isGenerator:!!e.asteriskToken,typeParameters:this.extractTypeParameters(e.typeParameters)}}extractArrowFunctions(e,t,s){for(let n of e.declarationList.declarations)if(m.isIdentifier(n.name)&&n.initializer&&m.isArrowFunction(n.initializer)){let i=n.initializer,{line:o}=t.getLineAndCharacterOfPosition(e.getStart()),{line:r}=t.getLineAndCharacterOfPosition(e.getEnd());s.push({name:n.name.text,parameters:this.extractParameters(i.parameters),returnType:i.type?i.type.getText(t):void 0,startLine:o+1,endLine:r+1,isAsync:this.hasAsyncModifier(i),isExported:this.hasExportModifier(e),isGenerator:!1,typeParameters:this.extractTypeParameters(i.typeParameters)})}}extractClassDeclaration(e,t){let{line:s}=t.getLineAndCharacterOfPosition(e.getStart()),{line:n}=t.getLineAndCharacterOfPosition(e.getEnd()),i=[],o=[];for(let c of e.members)m.isMethodDeclaration(c)&&c.name?i.push(this.extractMethodDeclaration(c,t)):m.isPropertyDeclaration(c)&&c.name?o.push(this.extractPropertyDeclaration(c,t)):m.isConstructorDeclaration(c)&&(i.push(this.extractConstructor(c,t)),this.extractParameterProperties(c,o,t));let r,a=[];if(e.heritageClauses){for(let c of e.heritageClauses)if(c.token===m.SyntaxKind.ExtendsKeyword)r=c.types[0]?.expression.getText(t);else if(c.token===m.SyntaxKind.ImplementsKeyword)for(let l of c.types)a.push(l.expression.getText(t))}return{name:e.name?.text??"anonymous",methods:i,properties:o,extends:r,implements:a,isAbstract:this.hasAbstractModifier(e),isExported:this.hasExportModifier(e),startLine:s+1,endLine:n+1,typeParameters:this.extractTypeParameters(e.typeParameters)}}extractMethodDeclaration(e,t){let{line:s}=t.getLineAndCharacterOfPosition(e.getStart()),{line:n}=t.getLineAndCharacterOfPosition(e.getEnd());return{name:this.getPropertyName(e.name,t),parameters:this.extractParameters(e.parameters),returnType:e.type?e.type.getText(t):void 0,isAsync:this.hasAsyncModifier(e),isStatic:this.hasStaticModifier(e),isAbstract:this.hasAbstractModifier(e),visibility:this.getVisibility(e),startLine:s+1,endLine:n+1}}extractConstructor(e,t){let{line:s}=t.getLineAndCharacterOfPosition(e.getStart()),{line:n}=t.getLineAndCharacterOfPosition(e.getEnd());return{name:"constructor",parameters:this.extractParameters(e.parameters),returnType:void 0,isAsync:!1,isStatic:!1,isAbstract:!1,visibility:"public",startLine:s+1,endLine:n+1}}extractParameterProperties(e,t,s){for(let n of e.parameters)this.isParameterProperty(n)&&t.push({name:m.isIdentifier(n.name)?n.name.text:n.name.getText(s),type:n.type?n.type.getText(s):void 0,isStatic:!1,isReadonly:this.hasReadonlyModifier(n),visibility:this.getVisibility(n),hasInitializer:!!n.initializer})}isParameterProperty(e){return!!e.modifiers?.some(t=>t.kind===m.SyntaxKind.PublicKeyword||t.kind===m.SyntaxKind.PrivateKeyword||t.kind===m.SyntaxKind.ProtectedKeyword||t.kind===m.SyntaxKind.ReadonlyKeyword)}extractPropertyDeclaration(e,t){return{name:this.getPropertyName(e.name,t),type:e.type?e.type.getText(t):void 0,isStatic:this.hasStaticModifier(e),isReadonly:this.hasReadonlyModifier(e),visibility:this.getVisibility(e),hasInitializer:!!e.initializer}}extractImportDeclaration(e){let t=e.moduleSpecifier.text,s=[],n,i,o=e.importClause?.isTypeOnly??!1;if(e.importClause&&(e.importClause.name&&(n=e.importClause.name.text),e.importClause.namedBindings)){if(m.isNamespaceImport(e.importClause.namedBindings))i=e.importClause.namedBindings.name.text;else if(m.isNamedImports(e.importClause.namedBindings))for(let r of e.importClause.namedBindings.elements)s.push({name:r.propertyName?.text??r.name.text,alias:r.propertyName?r.name.text:void 0})}return{module:t,namedImports:s,defaultImport:n,namespaceImport:i,isTypeOnly:o}}extractExportDeclaration(e,t){let s=e.moduleSpecifier?e.moduleSpecifier.text:void 0;if(e.exportClause&&m.isNamedExports(e.exportClause))for(let n of e.exportClause.elements)t.push({name:n.name.text,type:"unknown",isDefault:!1,isReexport:!!s,sourceModule:s});else!e.exportClause&&s&&t.push({name:"*",type:"unknown",isDefault:!1,isReexport:!0,sourceModule:s})}extractInterfaceDeclaration(e,t){let{line:s}=t.getLineAndCharacterOfPosition(e.getStart()),{line:n}=t.getLineAndCharacterOfPosition(e.getEnd()),i=[],o=[];for(let a of e.members)m.isPropertySignature(a)&&a.name?i.push({name:this.getPropertyName(a.name,t),type:a.type?a.type.getText(t):void 0,isOptional:!!a.questionToken,isReadonly:this.hasReadonlyModifier(a)}):m.isMethodSignature(a)&&a.name&&o.push({name:this.getPropertyName(a.name,t),parameters:this.extractParameters(a.parameters),returnType:a.type?a.type.getText(t):void 0,isOptional:!!a.questionToken});let r=[];if(e.heritageClauses){for(let a of e.heritageClauses)if(a.token===m.SyntaxKind.ExtendsKeyword)for(let c of a.types)r.push(c.expression.getText(t))}return{name:e.name.text,properties:i,methods:o,extends:r,isExported:this.hasExportModifier(e),startLine:s+1,endLine:n+1,typeParameters:this.extractTypeParameters(e.typeParameters)}}extractParameters(e){return e.map(t=>{let s=t.getSourceFile();return{name:m.isIdentifier(t.name)?t.name.text:t.name.getText(s),type:t.type?t.type.getText(s):void 0,isOptional:!!t.questionToken||!!t.initializer,isRest:!!t.dotDotDotToken,defaultValue:t.initializer?t.initializer.getText(s):void 0}})}extractTypeParameters(e){return e?e.map(t=>t.name.text):[]}getPropertyName(e,t){return m.isIdentifier(e)||m.isStringLiteral(e)||m.isNumericLiteral(e)?e.text:e.getText(t)}getExportAssignmentName(e){return m.isIdentifier(e.expression)?e.expression.text:"default"}hasExportModifier(e){return m.canHaveModifiers(e)&&!!m.getModifiers(e)?.some(t=>t.kind===m.SyntaxKind.ExportKeyword)}hasDefaultModifier(e){return m.canHaveModifiers(e)&&!!m.getModifiers(e)?.some(t=>t.kind===m.SyntaxKind.DefaultKeyword)}hasAsyncModifier(e){return m.canHaveModifiers(e)&&!!m.getModifiers(e)?.some(t=>t.kind===m.SyntaxKind.AsyncKeyword)}hasStaticModifier(e){return m.canHaveModifiers(e)&&!!m.getModifiers(e)?.some(t=>t.kind===m.SyntaxKind.StaticKeyword)}hasAbstractModifier(e){return m.canHaveModifiers(e)&&!!m.getModifiers(e)?.some(t=>t.kind===m.SyntaxKind.AbstractKeyword)}hasReadonlyModifier(e){return m.canHaveModifiers(e)&&!!m.getModifiers(e)?.some(t=>t.kind===m.SyntaxKind.ReadonlyKeyword)}getVisibility(e){if(!m.canHaveModifiers(e))return"public";let t=m.getModifiers(e);return t?t.some(s=>s.kind===m.SyntaxKind.PrivateKeyword)?"private":t.some(s=>s.kind===m.SyntaxKind.ProtectedKeyword)?"protected":"public":"public"}},ot=new F,Z=class{language="typescript";supportedExtensions=[".ts",".tsx",".js",".jsx",".mjs",".cjs"];parser=new F;async parseFile(e,t){let s=this.parser.parseFile(t,e),n=this.parser.extractFunctions(s),i=this.parser.extractClasses(s),o=this.parser.extractImports(s);return{functions:n.map(r=>this.mapFunction(r)),classes:i.map(r=>this.mapClass(r)),imports:o.map(r=>this.mapImport(r)),language:t.endsWith(".js")||t.endsWith(".jsx")||t.endsWith(".mjs")||t.endsWith(".cjs")?"javascript":"typescript",filePath:t}}mapFunction(e){return{name:e.name,parameters:e.parameters.map(t=>({name:t.name,type:t.type,isOptional:t.isOptional,defaultValue:t.defaultValue})),returnType:e.returnType,isAsync:e.isAsync,isPublic:e.isExported,complexity:1,decorators:[],genericParams:e.typeParameters,startLine:e.startLine,endLine:e.endLine}}mapClass(e){return{name:e.name,methods:e.methods.map(t=>({name:t.name,parameters:t.parameters.map(s=>({name:s.name,type:s.type,isOptional:s.isOptional,defaultValue:s.defaultValue})),returnType:t.returnType,isAsync:t.isAsync,isPublic:t.visibility==="public",complexity:1,decorators:[],genericParams:[],startLine:t.startLine,endLine:t.endLine})),properties:e.properties.map(t=>this.mapProperty(t)),isPublic:e.isExported,implements:e.implements,extends:e.extends,decorators:[],startLine:e.startLine,endLine:e.endLine}}mapProperty(e){return{name:e.name,type:e.type,isPublic:e.visibility==="public",isReadonly:e.isReadonly}}mapImport(e){return{module:e.module,namedImports:e.namedImports.map(t=>t.alias||t.name),isTypeOnly:e.isTypeOnly}}},ct=new Z;_e();var P=1e3;function L(p){let e=p.split(`
|
|
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.15.18");process.exit(0)}
|
|
2
|
+
import{a as Re,c as Me}from"./chunk-A3GDX6UF.js";import{c as Ce}from"./chunk-HBDSCYSK.js";import{d as Se}from"./chunk-AXVD7O3F.js";import{a as Le,b as Ke}from"./chunk-WZVRMKG2.js";import{m as Pe,n as Ue}from"./chunk-RTYXFXTI.js";import{b as O,d as Ie}from"./chunk-MQM37KAR.js";import{c as R,d as I}from"./chunk-JMRDT2XK.js";import{a as $e}from"./chunk-O5EWFR76.js";import{c as ve,d as Ee,e as _e}from"./chunk-NKU3FFM4.js";import{c as we,d as je}from"./chunk-YP2GHQSV.js";import{a as W,b as N,e as Y}from"./chunk-AWQAE3SW.js";$e();import{createRequire as Ge}from"module";var D;function z(){if(!D){let p=Ge(import.meta.url);try{D=p("typescript")}catch{try{D=p("typescript/lib/typescript.js")}catch{D=new Proxy({},{get(e,t){if(!(t==="__esModule"||typeof t=="symbol"))throw new Error("TypeScript is required for code analysis. Install it: npm install -g typescript")}})}}}return D}var m=new Proxy({},{get(p,e){return z()[e]},has(p,e){return e in z()},ownKeys(){return Object.keys(z())},getOwnPropertyDescriptor(p,e){let t=z()[e];if(t!==void 0)return{configurable:!0,enumerable:!0,value:t}}});var F=class{parseFile(e,t){return m.createSourceFile(e,t,m.ScriptTarget.Latest,!0,this.getScriptKind(e))}countSyntaxErrors(e){let t={noLib:!0,noResolve:!0,allowJs:!0,types:[]},s=m.createCompilerHost(t);return s.getSourceFile=()=>e,m.createProgram({rootNames:[e.fileName],options:t,host:s}).getSyntacticDiagnostics(e).length}extractFunctions(e){let t=[],s=n=>{m.isFunctionDeclaration(n)&&n.name?t.push(this.extractFunctionDeclaration(n,e)):m.isVariableStatement(n)&&this.extractArrowFunctions(n,e,t),m.forEachChild(n,s)};return m.forEachChild(e,s),t}extractClasses(e){let t=[],s=n=>{m.isClassDeclaration(n)&&n.name&&t.push(this.extractClassDeclaration(n,e)),m.forEachChild(n,s)};return m.forEachChild(e,s),t}extractImports(e){let t=[],s=n=>{m.isImportDeclaration(n)&&t.push(this.extractImportDeclaration(n)),m.forEachChild(n,s)};return m.forEachChild(e,s),t}extractExports(e){let t=[],s=n=>{if(m.isExportDeclaration(n))this.extractExportDeclaration(n,t);else if(m.isExportAssignment(n))t.push({name:this.getExportAssignmentName(n),type:"unknown",isDefault:!0,isReexport:!1,sourceModule:void 0});else if(m.isFunctionDeclaration(n)&&n.name&&this.hasExportModifier(n))t.push({name:n.name.text,type:"function",isDefault:this.hasDefaultModifier(n),isReexport:!1,sourceModule:void 0});else if(m.isClassDeclaration(n)&&n.name&&this.hasExportModifier(n))t.push({name:n.name.text,type:"class",isDefault:this.hasDefaultModifier(n),isReexport:!1,sourceModule:void 0});else if(m.isVariableStatement(n)&&this.hasExportModifier(n))for(let i of n.declarationList.declarations)m.isIdentifier(i.name)&&t.push({name:i.name.text,type:"variable",isDefault:!1,isReexport:!1,sourceModule:void 0});else m.isInterfaceDeclaration(n)&&this.hasExportModifier(n)?t.push({name:n.name.text,type:"interface",isDefault:!1,isReexport:!1,sourceModule:void 0}):m.isTypeAliasDeclaration(n)&&this.hasExportModifier(n)?t.push({name:n.name.text,type:"type",isDefault:!1,isReexport:!1,sourceModule:void 0}):m.isEnumDeclaration(n)&&this.hasExportModifier(n)&&t.push({name:n.name.text,type:"enum",isDefault:!1,isReexport:!1,sourceModule:void 0});m.forEachChild(n,s)};return m.forEachChild(e,s),t}extractInterfaces(e){let t=[],s=n=>{m.isInterfaceDeclaration(n)&&t.push(this.extractInterfaceDeclaration(n,e)),m.forEachChild(n,s)};return m.forEachChild(e,s),t}extractEntities(e,t){let s=this.parseFile(t,e),n=[],i=this.extractFunctions(s);for(let a of i)n.push({name:a.name,type:"function",line:a.startLine,endLine:a.endLine,visibility:a.isExported?"public":"internal",isAsync:a.isAsync,isExported:a.isExported,parameters:a.parameters,returnType:a.returnType});let o=this.extractClasses(s);for(let a of o)n.push({name:a.name,type:"class",line:a.startLine,endLine:a.endLine,visibility:a.isExported?"public":"internal",isAsync:!1,isExported:a.isExported,extends:a.extends,implements:a.implements});let r=this.extractInterfaces(s);for(let a of r)n.push({name:a.name,type:"interface",line:a.startLine,endLine:a.endLine,visibility:a.isExported?"public":"internal",isAsync:!1,isExported:a.isExported});return n}getScriptKind(e){return e.endsWith(".tsx")?m.ScriptKind.TSX:e.endsWith(".ts")?m.ScriptKind.TS:e.endsWith(".jsx")?m.ScriptKind.JSX:/\.(js|mjs|cjs)$/.test(e)?m.ScriptKind.JS:m.ScriptKind.TS}extractFunctionDeclaration(e,t){let{line:s}=t.getLineAndCharacterOfPosition(e.getStart()),{line:n}=t.getLineAndCharacterOfPosition(e.getEnd());return{name:e.name?.text??"anonymous",parameters:this.extractParameters(e.parameters),returnType:e.type?e.type.getText(t):void 0,startLine:s+1,endLine:n+1,isAsync:this.hasAsyncModifier(e),isExported:this.hasExportModifier(e),isGenerator:!!e.asteriskToken,typeParameters:this.extractTypeParameters(e.typeParameters)}}extractArrowFunctions(e,t,s){for(let n of e.declarationList.declarations)if(m.isIdentifier(n.name)&&n.initializer&&m.isArrowFunction(n.initializer)){let i=n.initializer,{line:o}=t.getLineAndCharacterOfPosition(e.getStart()),{line:r}=t.getLineAndCharacterOfPosition(e.getEnd());s.push({name:n.name.text,parameters:this.extractParameters(i.parameters),returnType:i.type?i.type.getText(t):void 0,startLine:o+1,endLine:r+1,isAsync:this.hasAsyncModifier(i),isExported:this.hasExportModifier(e),isGenerator:!1,typeParameters:this.extractTypeParameters(i.typeParameters)})}}extractClassDeclaration(e,t){let{line:s}=t.getLineAndCharacterOfPosition(e.getStart()),{line:n}=t.getLineAndCharacterOfPosition(e.getEnd()),i=[],o=[];for(let c of e.members)m.isMethodDeclaration(c)&&c.name?i.push(this.extractMethodDeclaration(c,t)):m.isPropertyDeclaration(c)&&c.name?o.push(this.extractPropertyDeclaration(c,t)):m.isConstructorDeclaration(c)&&(i.push(this.extractConstructor(c,t)),this.extractParameterProperties(c,o,t));let r,a=[];if(e.heritageClauses){for(let c of e.heritageClauses)if(c.token===m.SyntaxKind.ExtendsKeyword)r=c.types[0]?.expression.getText(t);else if(c.token===m.SyntaxKind.ImplementsKeyword)for(let l of c.types)a.push(l.expression.getText(t))}return{name:e.name?.text??"anonymous",methods:i,properties:o,extends:r,implements:a,isAbstract:this.hasAbstractModifier(e),isExported:this.hasExportModifier(e),startLine:s+1,endLine:n+1,typeParameters:this.extractTypeParameters(e.typeParameters)}}extractMethodDeclaration(e,t){let{line:s}=t.getLineAndCharacterOfPosition(e.getStart()),{line:n}=t.getLineAndCharacterOfPosition(e.getEnd());return{name:this.getPropertyName(e.name,t),parameters:this.extractParameters(e.parameters),returnType:e.type?e.type.getText(t):void 0,isAsync:this.hasAsyncModifier(e),isStatic:this.hasStaticModifier(e),isAbstract:this.hasAbstractModifier(e),visibility:this.getVisibility(e),startLine:s+1,endLine:n+1}}extractConstructor(e,t){let{line:s}=t.getLineAndCharacterOfPosition(e.getStart()),{line:n}=t.getLineAndCharacterOfPosition(e.getEnd());return{name:"constructor",parameters:this.extractParameters(e.parameters),returnType:void 0,isAsync:!1,isStatic:!1,isAbstract:!1,visibility:"public",startLine:s+1,endLine:n+1}}extractParameterProperties(e,t,s){for(let n of e.parameters)this.isParameterProperty(n)&&t.push({name:m.isIdentifier(n.name)?n.name.text:n.name.getText(s),type:n.type?n.type.getText(s):void 0,isStatic:!1,isReadonly:this.hasReadonlyModifier(n),visibility:this.getVisibility(n),hasInitializer:!!n.initializer})}isParameterProperty(e){return!!e.modifiers?.some(t=>t.kind===m.SyntaxKind.PublicKeyword||t.kind===m.SyntaxKind.PrivateKeyword||t.kind===m.SyntaxKind.ProtectedKeyword||t.kind===m.SyntaxKind.ReadonlyKeyword)}extractPropertyDeclaration(e,t){return{name:this.getPropertyName(e.name,t),type:e.type?e.type.getText(t):void 0,isStatic:this.hasStaticModifier(e),isReadonly:this.hasReadonlyModifier(e),visibility:this.getVisibility(e),hasInitializer:!!e.initializer}}extractImportDeclaration(e){let t=e.moduleSpecifier.text,s=[],n,i,o=e.importClause?.isTypeOnly??!1;if(e.importClause&&(e.importClause.name&&(n=e.importClause.name.text),e.importClause.namedBindings)){if(m.isNamespaceImport(e.importClause.namedBindings))i=e.importClause.namedBindings.name.text;else if(m.isNamedImports(e.importClause.namedBindings))for(let r of e.importClause.namedBindings.elements)s.push({name:r.propertyName?.text??r.name.text,alias:r.propertyName?r.name.text:void 0})}return{module:t,namedImports:s,defaultImport:n,namespaceImport:i,isTypeOnly:o}}extractExportDeclaration(e,t){let s=e.moduleSpecifier?e.moduleSpecifier.text:void 0;if(e.exportClause&&m.isNamedExports(e.exportClause))for(let n of e.exportClause.elements)t.push({name:n.name.text,type:"unknown",isDefault:!1,isReexport:!!s,sourceModule:s});else!e.exportClause&&s&&t.push({name:"*",type:"unknown",isDefault:!1,isReexport:!0,sourceModule:s})}extractInterfaceDeclaration(e,t){let{line:s}=t.getLineAndCharacterOfPosition(e.getStart()),{line:n}=t.getLineAndCharacterOfPosition(e.getEnd()),i=[],o=[];for(let a of e.members)m.isPropertySignature(a)&&a.name?i.push({name:this.getPropertyName(a.name,t),type:a.type?a.type.getText(t):void 0,isOptional:!!a.questionToken,isReadonly:this.hasReadonlyModifier(a)}):m.isMethodSignature(a)&&a.name&&o.push({name:this.getPropertyName(a.name,t),parameters:this.extractParameters(a.parameters),returnType:a.type?a.type.getText(t):void 0,isOptional:!!a.questionToken});let r=[];if(e.heritageClauses){for(let a of e.heritageClauses)if(a.token===m.SyntaxKind.ExtendsKeyword)for(let c of a.types)r.push(c.expression.getText(t))}return{name:e.name.text,properties:i,methods:o,extends:r,isExported:this.hasExportModifier(e),startLine:s+1,endLine:n+1,typeParameters:this.extractTypeParameters(e.typeParameters)}}extractParameters(e){return e.map(t=>{let s=t.getSourceFile();return{name:m.isIdentifier(t.name)?t.name.text:t.name.getText(s),type:t.type?t.type.getText(s):void 0,isOptional:!!t.questionToken||!!t.initializer,isRest:!!t.dotDotDotToken,defaultValue:t.initializer?t.initializer.getText(s):void 0}})}extractTypeParameters(e){return e?e.map(t=>t.name.text):[]}getPropertyName(e,t){return m.isIdentifier(e)||m.isStringLiteral(e)||m.isNumericLiteral(e)?e.text:e.getText(t)}getExportAssignmentName(e){return m.isIdentifier(e.expression)?e.expression.text:"default"}hasExportModifier(e){return m.canHaveModifiers(e)&&!!m.getModifiers(e)?.some(t=>t.kind===m.SyntaxKind.ExportKeyword)}hasDefaultModifier(e){return m.canHaveModifiers(e)&&!!m.getModifiers(e)?.some(t=>t.kind===m.SyntaxKind.DefaultKeyword)}hasAsyncModifier(e){return m.canHaveModifiers(e)&&!!m.getModifiers(e)?.some(t=>t.kind===m.SyntaxKind.AsyncKeyword)}hasStaticModifier(e){return m.canHaveModifiers(e)&&!!m.getModifiers(e)?.some(t=>t.kind===m.SyntaxKind.StaticKeyword)}hasAbstractModifier(e){return m.canHaveModifiers(e)&&!!m.getModifiers(e)?.some(t=>t.kind===m.SyntaxKind.AbstractKeyword)}hasReadonlyModifier(e){return m.canHaveModifiers(e)&&!!m.getModifiers(e)?.some(t=>t.kind===m.SyntaxKind.ReadonlyKeyword)}getVisibility(e){if(!m.canHaveModifiers(e))return"public";let t=m.getModifiers(e);return t?t.some(s=>s.kind===m.SyntaxKind.PrivateKeyword)?"private":t.some(s=>s.kind===m.SyntaxKind.ProtectedKeyword)?"protected":"public":"public"}},ot=new F,Z=class{language="typescript";supportedExtensions=[".ts",".tsx",".js",".jsx",".mjs",".cjs"];parser=new F;async parseFile(e,t){let s=this.parser.parseFile(t,e),n=this.parser.extractFunctions(s),i=this.parser.extractClasses(s),o=this.parser.extractImports(s);return{functions:n.map(r=>this.mapFunction(r)),classes:i.map(r=>this.mapClass(r)),imports:o.map(r=>this.mapImport(r)),language:t.endsWith(".js")||t.endsWith(".jsx")||t.endsWith(".mjs")||t.endsWith(".cjs")?"javascript":"typescript",filePath:t}}mapFunction(e){return{name:e.name,parameters:e.parameters.map(t=>({name:t.name,type:t.type,isOptional:t.isOptional,defaultValue:t.defaultValue})),returnType:e.returnType,isAsync:e.isAsync,isPublic:e.isExported,complexity:1,decorators:[],genericParams:e.typeParameters,startLine:e.startLine,endLine:e.endLine}}mapClass(e){return{name:e.name,methods:e.methods.map(t=>({name:t.name,parameters:t.parameters.map(s=>({name:s.name,type:s.type,isOptional:s.isOptional,defaultValue:s.defaultValue})),returnType:t.returnType,isAsync:t.isAsync,isPublic:t.visibility==="public",complexity:1,decorators:[],genericParams:[],startLine:t.startLine,endLine:t.endLine})),properties:e.properties.map(t=>this.mapProperty(t)),isPublic:e.isExported,implements:e.implements,extends:e.extends,decorators:[],startLine:e.startLine,endLine:e.endLine}}mapProperty(e){return{name:e.name,type:e.type,isPublic:e.visibility==="public",isReadonly:e.isReadonly}}mapImport(e){return{module:e.module,namedImports:e.namedImports.map(t=>t.alias||t.name),isTypeOnly:e.isTypeOnly}}},ct=new Z;_e();var P=1e3;function L(p){let e=p.split(`
|
|
3
3
|
`),t=[],s=[],n="",i=0,o=0,r=0,a=0;for(let c=0;c<e.length;c++){let l=e[c],d=l.trim();if(d===""||d.startsWith("//")||d.startsWith("#")||d.startsWith("*")){if(n){n+=" "+d;continue}t.push(l),s.push(c+1);continue}n||(i=c+1),n=n?n+" "+d:l;for(let u of d)u==="("?o++:u===")"?o=Math.max(0,o-1):u==="<"?r++:u===">"?r=Math.max(0,r-1):u==="["?a++:u==="]"&&(a=Math.max(0,a-1));o===0&&r===0&&a===0&&(t.push(n),s.push(i),n="")}return n&&(t.push(n),s.push(i)),{logicalLines:t,lineMap:s}}function q(p,e,t="<",s=">"){if(p[e]!==t)return;let n=1,i=e+1;for(;i<p.length&&n>0;)p[i]===t?n++:p[i]===s&&n--,i++;if(n===0)return p.substring(e+1,i-1)}function C(p,e,t){let s=[];for(let n=e-1;n>=0;n--){let i=p[n].trim();if(i.startsWith(t))s.unshift(i);else{if(i===""||i.startsWith("//")||i.startsWith("*")||i.startsWith("#"))continue;break}}return s}function T(p){let e=[],t=0,s="";for(let n of p)n==="<"||n==="("?t++:(n===">"||n===")")&&t--,n===","&&t===0?(e.push(s.trim()),s=""):s+=n;return s.trim()&&e.push(s.trim()),e}function de(p){let e=0,t=!1,s="";for(let n=0;n<p.length;n++){let i=p[n];if(t){i===s&&p[n-1]!=="\\"&&(t=!1);continue}i==='"'||i==="'"||i==="`"?(t=!0,s=i):i==="{"?e++:i==="}"&&e--}return e}var ee=class{language="python";supportedExtensions=[".py"];async parseFile(e,t){return{functions:this.extractFunctions(e),classes:this.extractClasses(e),imports:this.extractImports(e),language:"python",filePath:t}}extractFunctions(e){let t=[],s=e.split(`
|
|
4
4
|
`),{logicalLines:n,lineMap:i}=L(e),o=/^(\s*)(async\s+)?def\s+(\w+)\s*\(([^)]*)\)(?:\s*->\s*([^:]*\S))?\s*:/;for(let r=0;r<n.length;r++){if(n[r].length>P)continue;let a=n[r].match(o);if(a){let c=a[1].length,l=!!a[2],d=a[3],u=a[4],h=a[5]?.trim(),g=i[r]-1,y=g+1;for(let f=g+1;f<s.length;f++){let x=s[f];if(x.trim()===""||x.trim().startsWith("#"))continue;if((x.match(/^(\s*)/)?.[1].length??0)<=c&&x.trim()!==""){y=f;break}y=f+1}let b=C(s,g,"@");t.push({name:d,parameters:this.parseParams(u),returnType:h,isAsync:l,isPublic:!d.startsWith("_"),complexity:1,decorators:b,genericParams:[],startLine:i[r],endLine:y})}}return t}extractClasses(e){let t=[],s=e.split(`
|
|
5
5
|
`),{logicalLines:n,lineMap:i}=L(e),o=/^(\s*)class\s+(\w+)(?:\(([^)]*)\))?\s*:/;for(let r=0;r<n.length;r++){let a=n[r].match(o);if(a){let c=a[1].length,l=a[2],d=a[3]?a[3].split(",").map(f=>f.trim()):[],u=i[r]-1,h=u+1;for(let f=u+1;f<s.length;f++){let x=s[f];if(x.trim()===""||x.trim().startsWith("#"))continue;if((x.match(/^(\s*)/)?.[1].length??0)<=c&&x.trim()!==""){h=f;break}h=f+1}let g=s.slice(u+1,h).join(`
|
|
@@ -20,7 +20,7 @@ import{a as Re,c as Me}from"./chunk-O7VJ3VKD.js";import{c as Ce}from"./chunk-HWQ
|
|
|
20
20
|
`),{logicalLines:n,lineMap:i}=L(e),o=/^\s*(public|private|protected|internal)?\s*(suspend)?\s*fun\s+(?:<[^{]*> +)?(\w+)\s*\(([^)]*)\)(?:\s*:\s*([^{=\s]+(?:\s+[^{=\s]+)*))?\s*/,r=0;for(let a=0;a<n.length;a++){let c=n[a];if(c.length>P){r+=(c.match(/\{/g)?.length??0)-(c.match(/\}/g)?.length??0);continue}let l=c.match(o);if(l&&r<=1){let d=l[1]||"public",u=!!l[2],h=l[3],g=l[4],y=l[5]?.trim();if(y&&y.includes("<")){let x=y.indexOf("<"),w=q(y,x);w!==void 0&&(y=y.substring(0,x)+"<"+w+">")}let b=i[a]-1,f=C(s,b,"@");t.push({name:h,parameters:this.parseParams(g),returnType:y,isAsync:u,isPublic:d==="public",complexity:1,decorators:f,genericParams:[],startLine:i[a],endLine:i[a]})}r+=de(c),r<0&&(r=0)}return t}extractClasses(e){let t=[],s=e.split(`
|
|
21
21
|
`),{logicalLines:n,lineMap:i}=L(e),o=/^\s*(public|private|protected|internal)?\s*(data|sealed|abstract|open)?\s*class\s+(\w+)(?:<[^{]*>)?(?:\s*(?:\([^)]*\))?\s*:\s*([^{\s]+(?:\s+[^{\s]+)*))?\s*\{?/;for(let r=0;r<n.length;r++){if(n[r].length>P)continue;let a=n[r].match(o);if(a){let c=a[3],l=a[4]?a[4].split(",").map(h=>h.trim().split("(")[0].trim()):[],d=i[r]-1,u=C(s,d,"@");t.push({name:c,methods:[],properties:[],isPublic:(a[1]||"public")==="public",implements:l.slice(1),extends:l[0]||void 0,decorators:u,startLine:i[r],endLine:i[r]})}}return t}extractImports(e){let t=[],s=e.split(`
|
|
22
22
|
`);for(let n of s){let i=n.match(/^\s*import\s+([^\s]+)/);i&&t.push({module:i[1],namedImports:[],isTypeOnly:!1})}return t}parseParams(e){return e.trim()?T(e).map(t=>{let s=t.indexOf(":");if(s===-1)return{name:t.replace("val ","").replace("var ","").trim(),type:void 0,isOptional:!1,defaultValue:void 0};let n=t.substring(0,s).replace("val ","").replace("var ","").trim(),i=t.substring(s+1).trim(),o=i.indexOf("="),r=o>=0?i.substring(0,o).trim():i,a=o>=0;return{name:n,type:r,isOptional:a||r?.endsWith("?")||!1,defaultValue:void 0}}):[]}},oe=class{language="dart";supportedExtensions=[".dart"];async parseFile(e,t){return{functions:this.extractFunctions(e),classes:this.extractClasses(e),imports:this.extractImports(e),language:"dart",filePath:t}}extractFunctions(e){let t=[],{logicalLines:s,lineMap:n}=L(e),i=/^\s*([\w<>,.?]+(?:\s+[\w<>,.?]+)*)\s+(\w+)\s*\(([^)]*)\)(?:\s*(async))?\s*\{/;for(let o=0;o<s.length;o++){let r=s[o];if(r.includes(" class ")||r.length>P)continue;let a=r.match(i);if(a){let c=a[1].trim(),l=c;if(c&&c.includes("<")){let g=c.indexOf("<"),y=q(c,g);y!==void 0&&(l=c.substring(0,g)+"<"+y+">")}let d=a[2],u=a[3],h=!!a[4]||l.includes("Future");t.push({name:d,parameters:this.parseParams(u),returnType:l==="void"?void 0:l,isAsync:h,isPublic:!d.startsWith("_"),complexity:1,decorators:[],genericParams:[],startLine:n[o],endLine:n[o]})}}return t}extractClasses(e){let t=[],{logicalLines:s,lineMap:n}=L(e),i=/^\s*(abstract +)?class\s+(\w+)(?:<[^{]*>)?(?:\s+extends\s+(\w+))?(?:\s+(?:with|implements)\s+([^{\s]+(?:\s+[^{\s]+)*))?\s*\{/;for(let o=0;o<s.length;o++){if(s[o].length>P)continue;let r=s[o].match(i);if(r){let a=r[2],c=r[3],l=r[4]?r[4].split(",").map(d=>d.trim()):[];t.push({name:a,methods:[],properties:[],isPublic:!a.startsWith("_"),implements:l,extends:c,decorators:[],startLine:n[o],endLine:n[o]})}}return t}extractImports(e){let t=[],s=e.split(`
|
|
23
|
-
`);for(let n of s){let i=n.match(/^\s*import\s+'([^']+)'/);i&&t.push({module:i[1],namedImports:[],isTypeOnly:!1})}return t}parseParams(e){if(!e.trim())return[];let t=e.replace(/[{}[\]]/g,"");return T(t).map(s=>s.trim()).filter(s=>s).map(s=>{let n=s.replace("required ","").trim().split(/\s+/),i=n[n.length-1]||"",o=n.slice(0,-1).join(" ")||void 0;return{name:i,type:o,isOptional:s.includes("?")||s.includes("{"),defaultValue:void 0}})}},B=Ee("ParserRegistry"),Te=["python","java","csharp","rust","swift"],ce=class p{language;supportedExtensions;wasmParser;regexParser;wasmFailCount=0;static MAX_WASM_RETRIES=3;constructor(e,t){this.wasmParser=e,this.regexParser=t,this.language=e.language,this.supportedExtensions=e.supportedExtensions}async parseFile(e,t){if(this.wasmFailCount<p.MAX_WASM_RETRIES)try{return await this.wasmParser.parseFile(e,t)}catch(s){this.wasmFailCount++;let n=s instanceof Error?s.message:String(s),i=this.wasmFailCount>=p.MAX_WASM_RETRIES;B.warn(`[${this.language}] tree-sitter WASM parser failed (attempt ${this.wasmFailCount}/${p.MAX_WASM_RETRIES}): ${n}. Falling back to regex parser (~97-98% accuracy). `+(i?"Set AQE_PARSER_REGEX_ONLY=1 to silence this warning.":"Will retry WASM on next parse."))}return this.regexParser.parseFile(e,t)}},le=class{parsers=new Map;_wasmInitPromise=null;constructor(){this.register(new ee),this.register(new te),this.register(new se),this.register(new ne),this.register(new ie),this.register(new re),this.register(new ae),this.register(new oe),this._wasmInitPromise=this._tryLoadWasmParsers()}async _tryLoadWasmParsers(){try{let e=await import("./tree-sitter-wasm-parser-UVWSDXFR.js");if(!e.isWasmAvailable()){B.info("tree-sitter WASM parsers disabled or unavailable. Using regex parsers (~97-98% accuracy). Set AQE_PARSER_REGEX_ONLY=0 or ensure web-tree-sitter is installed to enable WASM.");return}let t=e.createWasmParsers();for(let s of Te){let n=t.get(s),i=this.parsers.get(s);n&&i&&this.parsers.set(s,new ce(n,i))}B.info("tree-sitter WASM parsers available for: "+Te.join(", "))}catch{B.info("tree-sitter WASM parser module not available. Using regex parsers for all languages.")}}register(e){this.parsers.set(e.language,e)}getParser(e){return this.parsers.get(e)}async parseFile(e,t,s){this._wasmInitPromise&&(await this._wasmInitPromise,this._wasmInitPromise=null);let n=this.parsers.get(s);if(n)return n.parseFile(e,t)}getSupportedLanguages(){return Array.from(this.parsers.keys())}supportsLanguage(e){return this.parsers.has(e)}},pt=new le;import*as M from"node:fs/promises";import*as E from"node:path";var We=[/\.\./,/%2e%2e/i,/%252e%252e/i,/\.\.%2f/i,/%2f\.\./i,/\.\.%5c/i,/\.\.\\/,/%c0%ae/i,/%c0%2f/i,/%c1%9c/i,/\0/,/%00/i],ze=[/^\/etc\//i,/^\/proc\//i,/^\/sys\//i,/^\/dev\//i,/^\/root\//i,/^\/home\/.+\/\./i,/^[A-Z]:\\Windows/i,/^[A-Z]:\\System/i,/^[A-Z]:\\Users\\.+\\AppData/i],pe=class{name="path-traversal";getRiskLevel(){return"critical"}validate(e,t={}){let{basePath:s="",allowAbsolute:n=!1,allowedExtensions:i=[],deniedExtensions:o=[".exe",".bat",".cmd",".sh",".ps1",".dll",".so"],maxDepth:r=10,maxLength:a=4096}=t;if(e.length>a)return{valid:!1,error:`Path exceeds maximum length of ${a}`,riskLevel:"medium"};for(let g of We)if(g.test(e))return{valid:!1,error:"Path traversal attempt detected",riskLevel:"critical"};if(!n&&(e.startsWith("/")||/^[A-Z]:/i.test(e)))return{valid:!1,error:"Absolute paths are not allowed",riskLevel:"high"};for(let g of ze)if(g.test(e))return{valid:!1,error:"Access to system paths is not allowed",riskLevel:"critical"};let c=this.normalizePath(e);if(c.includes(".."))return{valid:!1,error:"Path traversal detected after normalization",riskLevel:"critical"};if(c.split("/").filter(Boolean).length>r)return{valid:!1,error:`Path depth exceeds maximum of ${r}`,riskLevel:"low"};let d=this.getExtension(c);if(d){let g=`.${d.toLowerCase()}`,y=d.toLowerCase();if(o.length>0&&o.some(f=>f.toLowerCase()===g||f.toLowerCase()===y))return{valid:!1,error:`File extension '${d}' is not allowed`,riskLevel:"high"};if(i.length>0&&!i.some(f=>f.toLowerCase()===g||f.toLowerCase()===y))return{valid:!1,error:`File extension '${d}' is not in allowed list`,riskLevel:"medium"}}let u=s?this.joinPathsAbsolute(s,c):c,h=s.startsWith("/")?`/${this.normalizePath(s)}`:this.normalizePath(s);return s&&!u.startsWith(h)?{valid:!1,error:"Path escapes base directory",riskLevel:"critical"}:{valid:!0,normalizedPath:u,riskLevel:"none"}}normalizePath(e){let t=e.replace(/\\/g,"/");t=t.replace(/\/+/g,"/");let s=t.split("/"),n=[];for(let i of s)i==="."||i===""||(i===".."?n.length>0&&n[n.length-1]!==".."&&n.pop():n.push(i));return n.join("/")}joinPaths(...e){return e.length===0?"":e.map(t=>t.replace(/^\/+/,"").replace(/\/+$/,"")).filter(Boolean).join("/")}joinPathsAbsolute(...e){if(e.length===0)return"";let t=e[0].startsWith("/"),s=e.map(n=>{for(;n.startsWith("/");)n=n.slice(1);for(;n.endsWith("/");)n=n.slice(0,-1);return n}).filter(Boolean).join("/");return t?`/${s}`:s}getExtension(e){let t=e.match(/\.([^./\\]+)$/);return t?t[1]:null}},Be=new pe,Ae=(p,e)=>Be.validate(p,e);Ie();var Ne=[".exe",".bat",".cmd",".ps1",".dll",".so"],A=class extends Error{constructor(t,s,n,i){super(t);this.filePath=s;this.code=n;this.cause=i;this.name="FileReadError"}filePath;code;cause},V=class extends Error{constructor(t,s,n){super(t);this.filePath=s;this.cause=n;this.name="JsonParseError"}filePath;cause},S=class extends Error{constructor(t,s,n){super(`Path traversal detected: ${s.join(", ")}`);this.requestedPath=t;this.issues=s;this.riskLevel=n;this.name="PathTraversalError"}requestedPath;issues;riskLevel};function ue(p,e){let t=p,s;switch(t.code){case"ENOENT":s="File not found: "+e;break;case"EACCES":s="Permission denied: "+e;break;case"EISDIR":s="Path is a directory: "+e;break;default:s="Failed to read file: "+e}return new A(s,e,t.code,t)}function qe(p,e){let t=E.relative(p,e);return t===""||!t.startsWith(`..${E.sep}`)&&t!==".."&&!E.isAbsolute(t)}var me=class{constructor(e,t){this.maxSize=e;this.ttlMs=t}maxSize;ttlMs;cache=new Map;accessOrder=[];get(e){let t=this.cache.get(e);if(t){if(Date.now()-t.timestamp>this.ttlMs){this.delete(e);return}return this.updateAccessOrder(e),t.value}}set(e,t,s){for(this.cache.has(e)&&this.delete(e);this.cache.size>=this.maxSize&&this.accessOrder.length>0;){let n=this.accessOrder.shift();n&&this.cache.delete(n)}this.cache.set(e,{value:t,timestamp:Date.now(),size:s}),this.accessOrder.push(e)}delete(e){let t=this.cache.delete(e);if(t){let s=this.accessOrder.indexOf(e);s>-1&&this.accessOrder.splice(s,1)}return t}clear(){this.cache.clear(),this.accessOrder=[]}get size(){return this.cache.size}get totalBytes(){let e=0;return this.cache.forEach(t=>{e+=t.size}),e}updateAccessOrder(e){let t=this.accessOrder.indexOf(e);t>-1&&(this.accessOrder.splice(t,1),this.accessOrder.push(e))}prune(){let e=Date.now(),t=0,s=[];return this.cache.forEach((n,i)=>{e-n.timestamp>this.ttlMs&&s.push(i)}),s.forEach(n=>{this.delete(n),t++}),t}};function Ve(p){let e="",t=0;for(;t<p.length;){let s=p[t],n=p[t+1];s==="*"&&n==="*"?p[t+2]==="/"?(e+="(?:.*/)?",t+=3):(e+=".*",t+=2):s==="*"?(e+="[^/]*",t++):s==="?"?(e+="[^/]",t++):".+^${}()|[]\\".includes(s)?(e+="\\"+s,t++):(e+=s,t++)}return new RegExp("^"+e+"$")}async function Fe(p,e,t,s){try{let n=await M.readdir(p,{withFileTypes:!0});for(let i of n){let o=E.join(p,i.name),r=E.relative(s,o);if(i.isDirectory())i.name!=="node_modules"&&!i.name.startsWith(".")&&await Fe(o,e,t,s);else if(i.isFile()){let a=r.replace(/\\/g,"/");e.test(a)&&t.push(o)}}}catch(n){console.debug("[FileReader] Directory read error:",n instanceof Error?n.message:n)}}var k=class{basePath;cache;enableCache;projectRoot;projectRootReal;stats={cacheHits:0,cacheMisses:0,totalReads:0,cacheSize:0,cacheEntries:0};constructor(e={}){this.basePath=e.basePath??process.cwd(),this.enableCache=e.enableCache??!0,this.projectRoot=e.projectRoot?E.resolve(e.projectRoot):void 0,this.cache=new me(e.maxCacheSize??100,e.cacheTtlMs??300*1e3)}resolvePath(e){let t=E.isAbsolute(e),s=E.resolve(this.basePath),n=E.resolve(s,e),i=E.relative(s,n);if(this.basePath&&(i===".."||i.startsWith(`..${E.sep}`)||E.isAbsolute(i)))throw new S(e,["Path escapes base directory"],"critical");let o=this.basePath?s.split(/[\\/]/).filter(Boolean).length:0,r=Ae(e,{basePath:t?"":this.basePath,allowAbsolute:!0,maxDepth:10+(t?o:0),deniedExtensions:Ne});if(!r.valid)throw new S(e,[r.error||"Path validation failed"],r.riskLevel);return t?n:r.normalizedPath?r.normalizedPath:t?e:E.resolve(this.basePath,e)}async inProjectRoot(e){if(!this.projectRoot)return;if(e.includes("\0"))throw new S(e,["Null byte in path"],"critical");let t=E.resolve(this.basePath,e);if(!qe(this.projectRoot,t))return;if(Ne.includes(E.extname(t).toLowerCase()))throw new S(e,[`File extension '${E.extname(t)}' is not allowed`],"high");this.projectRootReal??=M.realpath(this.projectRoot).catch(()=>null);let s=await this.projectRootReal;if(s)return{lexical:t,rootReal:s}}async readContained(e,t,s){this.stats.totalReads++;try{return R(await Me(t,{projectRoot:this.projectRoot??s}))}catch(n){return n instanceof Re?n.reason==="outside-project-root"?I(new S(e,["Path resolves outside the project root"],"critical")):n.reason==="not-a-file"?I(new A("Not a regular file: "+t,t,n.code==="NOT_A_FILE"?"EISDIR":n.code)):I(ue({code:n.reason==="not-found"?"ENOENT":n.code},t)):I(ue(n,t))}}async readFile(e){let t;try{let s=await this.inProjectRoot(e);if(s)return this.readContained(e,s.lexical,s.rootReal);t=this.resolvePath(e)}catch(s){if(s instanceof S)return I(s);throw s}if(this.stats.totalReads++,this.enableCache){let s=this.cache.get(t);if(s!==void 0)return this.stats.cacheHits++,this.updateCacheStats(),R(s);this.stats.cacheMisses++}try{let s=await M.readFile(t,"utf-8");return this.enableCache&&(this.cache.set(t,s,Buffer.byteLength(s,"utf-8")),this.updateCacheStats()),R(s)}catch(s){return I(ue(s,t))}}async readJSON(e){let t=await this.readFile(e);if(!t.success)return t;try{let s=O(t.value);return R(s)}catch(s){let n=s,i=e;try{i=this.resolvePath(e)}catch{}return I(new V("Invalid JSON in file: "+i+" - "+n.message,i,n))}}async fileExists(e){let t;try{t=this.resolvePath(e)}catch(s){if(s instanceof S)return I(s);throw s}try{return await M.access(t,M.constants.F_OK),R(!0)}catch(s){let n=s;return n.code==="ENOENT"?R(!1):I(new A("Cannot check file existence: "+t,t,n.code,n))}}async listFiles(e,t){let s;try{s=t?this.resolvePath(t):this.basePath}catch(n){if(n instanceof S)return I(n);throw n}try{if(!(await M.stat(s)).isDirectory())return I(new A("Base path is not a directory: "+s,s,"ENOTDIR"));let i=Ve(e),o=[];return await Fe(s,i,o,s),o.sort(),R(o)}catch(n){let i=n;return I(new A("Failed to list files in: "+s,s,i.code,i))}}invalidateCache(e){let t=this.resolvePath(e);this.cache.delete(t),this.updateCacheStats()}clearCache(){this.cache.clear(),this.updateCacheStats()}pruneCache(){let e=this.cache.prune();return this.updateCacheStats(),e}getStats(){return{...this.stats}}resetStats(){this.stats={cacheHits:0,cacheMisses:0,totalReads:0,cacheSize:this.cache.totalBytes,cacheEntries:this.cache.size}}updateCacheStats(){this.stats.cacheSize=this.cache.totalBytes,this.stats.cacheEntries=this.cache.size}};Y();var v={MODEL:"all-MiniLM-L6-v2",DIMENSIONS:384,CONTEXT_WINDOW:8192,BATCH_SIZE:100,MAX_RETRIES:3,RETRY_DELAY_MS:1e3,TIMEOUT_MS:3e4,DEFAULT_OLLAMA_URL:"http://localhost:11434",OLLAMA_PULL_NAME:"all-minilm:22m",OLLAMA_MODEL_ENV:"AQE_OLLAMA_EMBEDDING_MODEL"};Ke();var He=/^(latest|22m(-.*)?|l6-v2(-.*)?)?$/i;function Oe(p){let e=p.lastIndexOf(":");return e>p.lastIndexOf("/")?{base:p.slice(0,e),tag:p.slice(e+1)}:{base:p,tag:""}}function he(p){let{base:e,tag:t}=Oe(p);return e.slice(e.lastIndexOf("/")+1).toLowerCase()===v.MODEL.toLowerCase()?!0:e.toLowerCase()==="all-minilm"&&He.test(t)}var _=class{baseUrl;maxRetries;retryDelayMs;timeoutMs;requestedModel;installedModel=null;constructor(e=Le(v.DEFAULT_OLLAMA_URL),t=v.MAX_RETRIES,s=v.RETRY_DELAY_MS,n=v.TIMEOUT_MS,i=process.env[v.OLLAMA_MODEL_ENV]){this.baseUrl=e.replace(/\/$/,""),this.maxRetries=t,this.retryDelayMs=s,this.timeoutMs=n,this.requestedModel=i?.trim()||void 0}getBaseUrl(){return this.baseUrl}getModelId(){return!this.requestedModel||he(this.requestedModel)?v.MODEL:`ollama:${this.requestedModel}`}async healthCheck(){return(await this.checkModel()).status==="available"}async checkModel(){let e=this.requestedModel??v.MODEL,t;try{t=await this.fetchWithTimeout(`${this.baseUrl}/api/tags`,{method:"GET",headers:{"Content-Type":"application/json"}},5e3,async i=>i.ok?await i.json():{httpStatus:i.status})}catch{return{status:"unreachable",reason:`Ollama at ${this.baseUrl} is not reachable`}}if(t&&"httpStatus"in t)return{status:"unreachable",reason:`Ollama at ${this.baseUrl} answered HTTP ${t.httpStatus} when listing models`};let s=this.requestedModel,n=s?i=>i===s||!Oe(s).tag&&i===`${s}:latest`:he;for(let i of t?.models??[]){let o=[i.name,i.model].find(r=>!!r&&n(r));if(o)return this.installedModel=o,{status:"available",model:o}}return{status:"missing",reason:`model '${e}' not installed in Ollama at ${this.baseUrl}; install it with: ollama pull ${s??v.OLLAMA_PULL_NAME}`}}async generateEmbedding(e){let t={model:this.installedModel??this.requestedModel??v.MODEL,prompt:e},s=null;for(let n=0;n<this.maxRetries;n++)try{let i=await this.fetchWithTimeout(`${this.baseUrl}/api/embeddings`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},this.timeoutMs,async o=>{if(!o.ok){let r=await o.text();throw new Error(`Ollama API error (${o.status}): ${r}`)}return await o.json()});if(i.embedding.length!==v.DIMENSIONS)throw new Error(`Invalid embedding dimensions: expected ${v.DIMENSIONS}, got ${i.embedding.length}`);return i.embedding}catch(i){if(s=N(i),s.message.includes("Invalid embedding dimensions"))throw s;if(n<this.maxRetries-1){let o=this.retryDelayMs*Math.pow(2,n);await this.sleep(o)}}throw new Error(`Failed to generate embedding after ${this.maxRetries} attempts: ${s?.message}`)}async fetchWithTimeout(e,t,s,n){let i=new AbortController,o=setTimeout(()=>i.abort(),s);try{let r=await fetch(e,{...t,signal:i.signal});return await n(r)}finally{clearTimeout(o)}}sleep(e){return new Promise(t=>setTimeout(t,e))}async getServerInfo(){try{return await this.fetchWithTimeout(`${this.baseUrl}/api/tags`,{method:"GET",headers:{"Content-Type":"application/json"}},5e3,async e=>e.ok?await e.json():null)}catch{return null}}async ensureModelAvailable(){let e=await this.checkModel();if(e.status!=="available")throw new Error(`Ollama model '${this.requestedModel??v.MODEL}' is not available: ${e.reason}`)}};import{createHash as Je}from"crypto";var j=class{cache;maxSize;hits;misses;constructor(e=1e4){this.cache=new Map,this.maxSize=e,this.hits=0,this.misses=0}hashContent(e,t,s){return Je("sha256").update(JSON.stringify(s===void 0?[t,e]:[t,s,e])).digest("hex")}get(e,t,s){let n=this.hashContent(e,t,s),i=this.cache.get(n);return i?(this.hits++,this.cache.delete(n),this.cache.set(n,i),[...i.embedding]):(this.misses++,null)}set(e,t,s,n){let i=this.hashContent(e,t,n);if(this.cache.size>=this.maxSize&&!this.cache.has(i)){let r=this.cache.keys().next().value;r&&this.cache.delete(r)}let o={embedding:[...s],timestamp:Date.now(),model:t};this.cache.set(i,o)}has(e,t,s){let n=this.hashContent(e,t,s);return this.cache.has(n)}getStats(){let e=this.hits+this.misses,t=e>0?this.hits/e:0;return{size:this.cache.size,hitRate:t,hits:this.hits,misses:this.misses}}clear(){this.cache.clear(),this.hits=0,this.misses=0}evictOlderThan(e){let s=Date.now()-e,n=0;for(let[i,o]of this.cache.entries())o.timestamp<s&&(this.cache.delete(i),n++);return n}getMemoryUsageEstimate(){return this.cache.size*3172}export(){return Array.from(this.cache.entries()).map(([e,t])=>({key:e,entry:{...t,embedding:[...t.embedding]}}))}import(e){this.cache.clear();for(let{key:t,entry:s}of e)this.cache.size<this.maxSize&&this.cache.set(t,{...s,embedding:[...s.embedding]})}};Y();var $="pseudo-embedding",ge="verified-backend-v1",H=p=>p===$?void 0:ge,U=class{client;cache;batchSize;enableFallback;ollamaAvailable=null;constructor(e={}){this.client=new _(e.ollamaBaseUrl,void 0,void 0,void 0,e.ollamaModel),this.cache=e.cache??new j(e.maxCacheSize),this.batchSize=e.batchSize??v.BATCH_SIZE,this.enableFallback=e.enableFallback??!0}async embed(e){let t=this.cache.has(e,this.getModelId(),ge)||await this.isOllamaAvailable()||!this.enableFallback?this.getModelId():$,s=this.cache.get(e,t,H(t));if(s)return s;let n;if(await this.isOllamaAvailable())t=this.getModelId(),n=await this.client.generateEmbedding(e);else if(this.enableFallback)t=$,n=this.generatePseudoEmbedding(e);else throw new Error(`Ollama is not available and fallback is disabled. Please run: ollama pull ${v.OLLAMA_PULL_NAME}`);return this.cache.set(e,t,n,H(t)),n}formatForEmbedding(e){let t=[];e.language&&t.push(e.language),e.type&&t.push(e.type),e.name&&t.push(e.name);let s=t.length>0?`${t.join(" ")}: `:"",n=v.CONTEXT_WINDOW*4,i=e.content.trim();if(s.length+i.length>n){let o=n-s.length-3;i=i.substring(0,o)+"..."}return s+i}async embedBatch(e){let t=[];for(let s of e){let n=await this.embed(s);t.push(n)}return t}async embedCodeChunks(e,t){let s=Date.now(),n=[],i=0,o=0,r=await this.isOllamaAvailable();if(r)await this.client.ensureModelAvailable();else if(!this.enableFallback)throw new Error(`Ollama is not available and fallback is disabled. Please run: ollama pull ${v.OLLAMA_PULL_NAME}`);for(let c=0;c<e.length;c+=this.batchSize){let l=e.slice(c,Math.min(c+this.batchSize,e.length)),d=await this.processBatch(l,r);n.push(...d);for(let u of d)u.cached?i++:o++;if(t){let u=c+l.length,h=e.length,y=(Date.now()-s)/u,f=(h-u)*y;t({current:u,total:h,percentage:u/h*100,estimatedTimeRemainingMs:f})}}let a=Date.now()-s;return{results:n,stats:{totalChunks:e.length,cachedHits:i,computedNew:o,totalTimeMs:a,avgTimePerChunk:a/e.length}}}async processBatch(e,t){let s=[],n=e.map(async o=>{let r=this.formatForEmbedding(o),a=Date.now(),c=t||this.cache.has(r,this.getModelId(),ge)?this.getModelId():$,l=this.cache.get(r,c,H(c));if(l)return{chunkId:o.id,embedding:l,model:c,cached:!0,computeTimeMs:Date.now()-a};try{let d;t?d=await this.client.generateEmbedding(r):d=this.generatePseudoEmbedding(r);let u=t?this.getModelId():$;return this.cache.set(r,u,d,H(u)),{chunkId:o.id,embedding:d,model:u,cached:!1,computeTimeMs:Date.now()-a}}catch(d){throw new Error(`Failed to generate embedding for chunk ${o.id}: ${W(d)}`)}}),i=await Promise.all(n);return s.push(...i),s}async isOllamaAvailable(){return this.ollamaAvailable!==null?this.ollamaAvailable:(this.ollamaAvailable=await this.client.healthCheck(),this.ollamaAvailable)}resetOllamaCheck(){this.ollamaAvailable=null}generatePseudoEmbedding(e){let t=new Array(v.DIMENSIONS).fill(0),s=e.split(/\s+|[^\w]+/).filter(o=>o.length>0);for(let o=0;o<s.length;o++){let r=s[o];for(let a=0;a<r.length&&a<t.length;a++)t[(o+a)%t.length]+=r.charCodeAt(a)/1e3}let n=[[/class\s+\w+/,0],[/function\s+\w+/,1],[/async\s+|await\s+|Promise/,2],[/interface\s+\w+/,3],[/export\s+/,4],[/import\s+/,5],[/try\s*{/,6],[/\.(map|filter|reduce)\(/,7]];for(let[o,r]of n)o.test(e)&&(t[r]+=.5);let i=Math.sqrt(t.reduce((o,r)=>o+r*r,0))||1;return t.map(o=>o/i)}clearCache(){this.cache.clear()}getCacheStats(){return this.cache.getStats()}async healthCheck(){return await this.client.healthCheck()}async checkModel(){return await this.client.checkModel()}getModelId(){return this.client.getModelId()}async getServerInfo(){return await this.client.getServerInfo()}getDimensions(){return v.DIMENSIONS}getConfig(){return{model:this.getModelId(),dimensions:v.DIMENSIONS,contextWindow:v.CONTEXT_WINDOW,batchSize:this.batchSize,maxRetries:v.MAX_RETRIES,enableFallback:this.enableFallback}}};$e();Y();Ie();import{existsSync as Ze,statSync as et}from"fs";import{dirname as tt,resolve as st,join as J}from"path";function Xe(p){switch(p){case"ts":case"mts":case"cts":return"tree-sitter-typescript.wasm";case"tsx":return"tree-sitter-tsx.wasm";case"js":case"jsx":case"mjs":case"cjs":return"tree-sitter-javascript.wasm";default:return null}}var K=p=>p.startPosition.row+1,G=(p,e)=>p.childForFieldName(e)?.text??"";function ye(p){for(let e=0;e<p.childCount;e++){let t=p.child(e);if(t){if(t.type==="async")return!0;if(t.type==="function"||t.type==="function_declaration")break}}return!1}function Qe(p){for(let e=0;e<p.childCount;e++)if(p.child(e)?.type==="accessibility_modifier"){let s=p.child(e).text;if(s==="private")return"private";if(s==="protected")return"protected"}return"public"}function Ye(p){let e=G(p,"name")||"(anonymous)",t=p.childForFieldName("body"),s=[];if(t)for(let n=0;n<t.childCount;n++){let i=t.child(n);i&&i.type==="method_definition"&&s.push({name:G(i,"name"),startLine:K(i),isAsync:ye(i),visibility:Qe(i)})}return{name:e,startLine:K(p),methods:s}}function fe(p){return p.replace(/^['"`]|['"`]$/g,"")}async function be(p,e){let t=Xe(e);if(!t)return null;let s=await Se(t);if(!s)return null;let n=null;try{let i=s.parse(p);n=i;let o=i.rootNode;if(!o)return null;let r={functions:[],classes:[],interfaces:[],imports:[]},a=[o];for(;a.length;){let c=a.pop(),l=!0;switch(c.type){case"function_declaration":case"generator_function_declaration":r.functions.push({name:G(c,"name"),startLine:K(c),isAsync:ye(c),visibility:"public"}),l=!1;break;case"class_declaration":case"class":r.classes.push(Ye(c)),l=!1;break;case"interface_declaration":r.interfaces.push({name:G(c,"name"),startLine:K(c)}),l=!1;break;case"lexical_declaration":case"variable_declaration":{for(let d=0;d<c.childCount;d++){let u=c.child(d);if(!u||u.type!=="variable_declarator")continue;let h=u.childForFieldName("value");if(h&&(h.type==="arrow_function"||h.type==="function"||h.type==="function_expression"))r.functions.push({name:G(u,"name"),startLine:K(u),isAsync:ye(h),visibility:"public"});else if(h&&h.type==="call_expression"&&h.child(0)?.text==="require"){let g=h.childForFieldName("arguments")?.child(1);g&&g.type==="string"&&r.imports.push(fe(g.text))}}l=!1;break}case"import_statement":{let d=c.childForFieldName("source");d&&r.imports.push(fe(d.text)),l=!1;break}case"call_expression":{let d=c.child(0);if(d&&d.text==="require"){let h=c.childForFieldName("arguments")?.child(1);h&&h.type==="string"&&r.imports.push(fe(h.text))}break}}if(l)for(let d=c.childCount-1;d>=0;d--){let u=c.child(d);u&&a.push(u)}}return r}catch{return null}finally{n?.delete?.()}}Ue();var nt={maxNodes:1e5,maxEdgesPerNode:500,namespace:"code-intelligence:kg",enableVectorEmbeddings:!0,embeddingDimension:384,enableLLMExtraction:!0,llmModelTier:2,llmMaxTokens:2048},xe=ve.create("code-intelligence/knowledge-graph"),X=new Set(["ts","tsx","js","jsx"]),De=class{config;memory;nodeCache=new Map;edgeIndex=new Map;allEdgesCache;tsParser;fileReader;projectRoot;embedder;llmRouter;constructor(e,t={}){this.config={...nt,...t},this.isKnowledgeGraphDependencies(e)?(this.memory=e.memory,this.llmRouter=e.llmRouter):(this.memory=e,this.llmRouter=void 0),this.tsParser=new F,this.projectRoot=this.config.projectRoot??this.config.basePath??we(),this.fileReader=new k({...this.config.basePath?{basePath:this.config.basePath}:{},projectRoot:this.projectRoot}),this.embedder=new U({enableFallback:!0})}isKnowledgeGraphDependencies(e){return e.memory!==void 0}get nsOpts(){return{namespace:this.config.namespace}}async index(e){let t=Date.now(),s=[],n=0,i=0,o=new Map;try{let{paths:r,incremental:a=!1,includeTests:c=!0,languages:l}=e,{accepted:d,skipped:u}=await Ce(r,this.projectRoot,this.config.basePath??process.cwd()),h=0;if(!a)await this.clear();else for(let b of u)b.reason==="not-found"&&await this.removeFileFromGraph(b.path);for(let b of d)try{if(l&&l.length>0){let w=this.getFileExtension(b);if(!this.matchesLanguage(w,l)){u.push({path:b,reason:"excluded-by-language"});continue}}if(!c&&this.isTestFile(b)){u.push({path:b,reason:"excluded-test-file"});continue}let f=this.getFileExtension(b);X.has(f)||o.set(f||"(none)",(o.get(f||"(none)")??0)+1);let x=await this.indexFile(b,a);n+=x.nodes,i+=x.edges,h++}catch(f){s.push({file:b,error:W(f)})}let g=Date.now()-t,y=[];if(o.size>0){let b=Array.from(X).join(", ");for(let[f,x]of o){let w=`${x} file(s) with extension '.${f}' were indexed as plain nodes: no dependency extractor for this language, so 'deps'/'impact' will report 0 edges for them. Supported: ${b}.`;y.push(w),xe.warn(w)}}return await this.storeIndexMetadata({filesIndexed:h,nodesCreated:n,edgesCreated:i,duration:g,indexedAt:new Date().toISOString()}),R({filesIndexed:h,nodesCreated:n,edgesCreated:i,duration:g,errors:s,warnings:y,skipped:u})}catch(r){return I(N(r))}}async query(e){try{let{query:t,type:s,limit:n=100}=e;return s==="cypher"?this.executeCypherQuery(t,n):this.executeNaturalLanguageQuery(t,n)}catch(t){return I(N(t))}}async mapDependencies(e){try{let{files:t,direction:s,depth:n=3}=e,i=[],o=[],r=new Set,a=[];for(let l of t)await this.traverseDependencies(l,s,n,r,i,o,[],a);let c=this.calculateDependencyMetrics(i,o);return R({nodes:i,edges:o,cycles:a,metrics:c})}catch(t){return I(N(t))}}async getNode(e){if(this.nodeCache.has(e))return this.nodeCache.get(e);let t=`${this.config.namespace}:node:${e}`,s=await this.memory.get(t,this.nsOpts);return s&&this.nodeCache.set(e,s),s}async getEdges(e,t){let s=await this.loadAllEdges();return this.filterEdgesByDirection(s,e,t)}async loadAllEdges(){if(this.allEdgesCache)return this.allEdgesCache;let e=[],t=`${this.config.namespace}:edge:*`,s=await this.memory.search(t,Number.MAX_SAFE_INTEGER,this.nsOpts);for(let n of s){let i=await this.memory.get(n,this.nsOpts);i&&e.push(i)}return this.allEdgesCache=e,e}async clear(){this.nodeCache.clear(),this.edgeIndex.clear(),this.allEdgesCache=void 0;for(let e of[`${this.config.namespace}:node:`,`${this.config.namespace}:edge:`]){let t=await this.memory.search(`${e}*`,Number.MAX_SAFE_INTEGER,this.nsOpts);for(let s of t)await this.memory.delete(s,this.nsOpts)}}async removeFileFromGraph(e){let t=this.pathToNodeId(e),s=this.config.namespace,n=await this.memory.search(`${s}:node:${t}*`,Number.MAX_SAFE_INTEGER,this.nsOpts);for(let o of n)await this.memory.delete(o,this.nsOpts),this.nodeCache.delete(o.slice(`${s}:node:`.length));let i=await this.memory.search(`${s}:edge:*`,Number.MAX_SAFE_INTEGER,this.nsOpts);for(let o of i){let r=await this.memory.get(o,this.nsOpts);r&&(r.source===t||r.source.startsWith(`${t}:`))&&await this.memory.delete(o,this.nsOpts)}this.edgeIndex.delete(t),this.allEdgesCache=void 0}isLLMExtractionAvailable(){return this.config.enableLLMExtraction===!0&&this.llmRouter!==void 0}getModelForTier(e){return Pe(e)}async extractRelationshipsWithLLM(e,t){if(!this.llmRouter)return{semanticRelationships:[],designPatterns:[],architecturalBoundaries:[],dependencyImpacts:[]};try{let s=this.buildRelationshipExtractionPrompt(e,t),n=this.getModelForTier(this.config.llmModelTier??2),i=await this.llmRouter.chat({messages:[{role:"system",content:`You are an expert software architect analyzing code structure. Extract:
|
|
23
|
+
`);for(let n of s){let i=n.match(/^\s*import\s+'([^']+)'/);i&&t.push({module:i[1],namedImports:[],isTypeOnly:!1})}return t}parseParams(e){if(!e.trim())return[];let t=e.replace(/[{}[\]]/g,"");return T(t).map(s=>s.trim()).filter(s=>s).map(s=>{let n=s.replace("required ","").trim().split(/\s+/),i=n[n.length-1]||"",o=n.slice(0,-1).join(" ")||void 0;return{name:i,type:o,isOptional:s.includes("?")||s.includes("{"),defaultValue:void 0}})}},B=Ee("ParserRegistry"),Te=["python","java","csharp","rust","swift"],ce=class p{language;supportedExtensions;wasmParser;regexParser;wasmFailCount=0;static MAX_WASM_RETRIES=3;constructor(e,t){this.wasmParser=e,this.regexParser=t,this.language=e.language,this.supportedExtensions=e.supportedExtensions}async parseFile(e,t){if(this.wasmFailCount<p.MAX_WASM_RETRIES)try{return await this.wasmParser.parseFile(e,t)}catch(s){this.wasmFailCount++;let n=s instanceof Error?s.message:String(s),i=this.wasmFailCount>=p.MAX_WASM_RETRIES;B.warn(`[${this.language}] tree-sitter WASM parser failed (attempt ${this.wasmFailCount}/${p.MAX_WASM_RETRIES}): ${n}. Falling back to regex parser (~97-98% accuracy). `+(i?"Set AQE_PARSER_REGEX_ONLY=1 to silence this warning.":"Will retry WASM on next parse."))}return this.regexParser.parseFile(e,t)}},le=class{parsers=new Map;_wasmInitPromise=null;constructor(){this.register(new ee),this.register(new te),this.register(new se),this.register(new ne),this.register(new ie),this.register(new re),this.register(new ae),this.register(new oe),this._wasmInitPromise=this._tryLoadWasmParsers()}async _tryLoadWasmParsers(){try{let e=await import("./tree-sitter-wasm-parser-OXPFKFZS.js");if(!e.isWasmAvailable()){B.info("tree-sitter WASM parsers disabled or unavailable. Using regex parsers (~97-98% accuracy). Set AQE_PARSER_REGEX_ONLY=0 or ensure web-tree-sitter is installed to enable WASM.");return}let t=e.createWasmParsers();for(let s of Te){let n=t.get(s),i=this.parsers.get(s);n&&i&&this.parsers.set(s,new ce(n,i))}B.info("tree-sitter WASM parsers available for: "+Te.join(", "))}catch{B.info("tree-sitter WASM parser module not available. Using regex parsers for all languages.")}}register(e){this.parsers.set(e.language,e)}getParser(e){return this.parsers.get(e)}async parseFile(e,t,s){this._wasmInitPromise&&(await this._wasmInitPromise,this._wasmInitPromise=null);let n=this.parsers.get(s);if(n)return n.parseFile(e,t)}getSupportedLanguages(){return Array.from(this.parsers.keys())}supportsLanguage(e){return this.parsers.has(e)}},pt=new le;import*as M from"node:fs/promises";import*as v from"node:path";var We=[/\.\./,/%2e%2e/i,/%252e%252e/i,/\.\.%2f/i,/%2f\.\./i,/\.\.%5c/i,/\.\.\\/,/%c0%ae/i,/%c0%2f/i,/%c1%9c/i,/\0/,/%00/i],ze=[/^\/etc\//i,/^\/proc\//i,/^\/sys\//i,/^\/dev\//i,/^\/root\//i,/^\/home\/.+\/\./i,/^[A-Z]:\\Windows/i,/^[A-Z]:\\System/i,/^[A-Z]:\\Users\\.+\\AppData/i],pe=class{name="path-traversal";getRiskLevel(){return"critical"}validate(e,t={}){let{basePath:s="",allowAbsolute:n=!1,allowedExtensions:i=[],deniedExtensions:o=[".exe",".bat",".cmd",".sh",".ps1",".dll",".so"],maxDepth:r=10,maxLength:a=4096}=t;if(e.length>a)return{valid:!1,error:`Path exceeds maximum length of ${a}`,riskLevel:"medium"};for(let g of We)if(g.test(e))return{valid:!1,error:"Path traversal attempt detected",riskLevel:"critical"};if(!n&&(e.startsWith("/")||/^[A-Z]:/i.test(e)))return{valid:!1,error:"Absolute paths are not allowed",riskLevel:"high"};for(let g of ze)if(g.test(e))return{valid:!1,error:"Access to system paths is not allowed",riskLevel:"critical"};let c=this.normalizePath(e);if(c.includes(".."))return{valid:!1,error:"Path traversal detected after normalization",riskLevel:"critical"};if(c.split("/").filter(Boolean).length>r)return{valid:!1,error:`Path depth exceeds maximum of ${r}`,riskLevel:"low"};let d=this.getExtension(c);if(d){let g=`.${d.toLowerCase()}`,y=d.toLowerCase();if(o.length>0&&o.some(f=>f.toLowerCase()===g||f.toLowerCase()===y))return{valid:!1,error:`File extension '${d}' is not allowed`,riskLevel:"high"};if(i.length>0&&!i.some(f=>f.toLowerCase()===g||f.toLowerCase()===y))return{valid:!1,error:`File extension '${d}' is not in allowed list`,riskLevel:"medium"}}let u=s?this.joinPathsAbsolute(s,c):c,h=s.startsWith("/")?`/${this.normalizePath(s)}`:this.normalizePath(s);return s&&!u.startsWith(h)?{valid:!1,error:"Path escapes base directory",riskLevel:"critical"}:{valid:!0,normalizedPath:u,riskLevel:"none"}}normalizePath(e){let t=e.replace(/\\/g,"/");t=t.replace(/\/+/g,"/");let s=t.split("/"),n=[];for(let i of s)i==="."||i===""||(i===".."?n.length>0&&n[n.length-1]!==".."&&n.pop():n.push(i));return n.join("/")}joinPaths(...e){return e.length===0?"":e.map(t=>t.replace(/^\/+/,"").replace(/\/+$/,"")).filter(Boolean).join("/")}joinPathsAbsolute(...e){if(e.length===0)return"";let t=e[0].startsWith("/"),s=e.map(n=>{for(;n.startsWith("/");)n=n.slice(1);for(;n.endsWith("/");)n=n.slice(0,-1);return n}).filter(Boolean).join("/");return t?`/${s}`:s}getExtension(e){let t=e.match(/\.([^./\\]+)$/);return t?t[1]:null}},Be=new pe,Ae=(p,e)=>Be.validate(p,e);Ie();var Ne=[".exe",".bat",".cmd",".ps1",".dll",".so"],A=class extends Error{constructor(t,s,n,i){super(t);this.filePath=s;this.code=n;this.cause=i;this.name="FileReadError"}filePath;code;cause},V=class extends Error{constructor(t,s,n){super(t);this.filePath=s;this.cause=n;this.name="JsonParseError"}filePath;cause},S=class extends Error{constructor(t,s,n){super(`Path traversal detected: ${s.join(", ")}`);this.requestedPath=t;this.issues=s;this.riskLevel=n;this.name="PathTraversalError"}requestedPath;issues;riskLevel};function ue(p,e){let t=p,s;switch(t.code){case"ENOENT":s="File not found: "+e;break;case"EACCES":s="Permission denied: "+e;break;case"EISDIR":s="Path is a directory: "+e;break;default:s="Failed to read file: "+e}return new A(s,e,t.code,t)}function qe(p,e){let t=v.relative(p,e);return t===""||!t.startsWith(`..${v.sep}`)&&t!==".."&&!v.isAbsolute(t)}var me=class{constructor(e,t){this.maxSize=e;this.ttlMs=t}maxSize;ttlMs;cache=new Map;accessOrder=[];get(e){let t=this.cache.get(e);if(t){if(Date.now()-t.timestamp>this.ttlMs){this.delete(e);return}return this.updateAccessOrder(e),t.value}}set(e,t,s){for(this.cache.has(e)&&this.delete(e);this.cache.size>=this.maxSize&&this.accessOrder.length>0;){let n=this.accessOrder.shift();n&&this.cache.delete(n)}this.cache.set(e,{value:t,timestamp:Date.now(),size:s}),this.accessOrder.push(e)}delete(e){let t=this.cache.delete(e);if(t){let s=this.accessOrder.indexOf(e);s>-1&&this.accessOrder.splice(s,1)}return t}clear(){this.cache.clear(),this.accessOrder=[]}get size(){return this.cache.size}get totalBytes(){let e=0;return this.cache.forEach(t=>{e+=t.size}),e}updateAccessOrder(e){let t=this.accessOrder.indexOf(e);t>-1&&(this.accessOrder.splice(t,1),this.accessOrder.push(e))}prune(){let e=Date.now(),t=0,s=[];return this.cache.forEach((n,i)=>{e-n.timestamp>this.ttlMs&&s.push(i)}),s.forEach(n=>{this.delete(n),t++}),t}};function Ve(p){let e="",t=0;for(;t<p.length;){let s=p[t],n=p[t+1];s==="*"&&n==="*"?p[t+2]==="/"?(e+="(?:.*/)?",t+=3):(e+=".*",t+=2):s==="*"?(e+="[^/]*",t++):s==="?"?(e+="[^/]",t++):".+^${}()|[]\\".includes(s)?(e+="\\"+s,t++):(e+=s,t++)}return new RegExp("^"+e+"$")}async function Fe(p,e,t,s){try{let n=await M.readdir(p,{withFileTypes:!0});for(let i of n){let o=v.join(p,i.name),r=v.relative(s,o);if(i.isDirectory())i.name!=="node_modules"&&!i.name.startsWith(".")&&await Fe(o,e,t,s);else if(i.isFile()){let a=r.replace(/\\/g,"/");e.test(a)&&t.push(o)}}}catch(n){console.debug("[FileReader] Directory read error:",n instanceof Error?n.message:n)}}var k=class{basePath;cache;enableCache;projectRoot;projectRootReal;stats={cacheHits:0,cacheMisses:0,totalReads:0,cacheSize:0,cacheEntries:0};constructor(e={}){this.basePath=e.basePath??process.cwd(),this.enableCache=e.enableCache??!0,this.projectRoot=e.projectRoot?v.resolve(e.projectRoot):void 0,this.cache=new me(e.maxCacheSize??100,e.cacheTtlMs??300*1e3)}resolvePath(e){let t=v.isAbsolute(e),s=v.resolve(this.basePath),n=v.resolve(s,e),i=v.relative(s,n);if(this.basePath&&(i===".."||i.startsWith(`..${v.sep}`)||v.isAbsolute(i)))throw new S(e,["Path escapes base directory"],"critical");let o=this.basePath?s.split(/[\\/]/).filter(Boolean).length:0,r=Ae(e,{basePath:t?"":this.basePath,allowAbsolute:!0,maxDepth:10+(t?o:0),deniedExtensions:Ne});if(!r.valid)throw new S(e,[r.error||"Path validation failed"],r.riskLevel);return t?n:r.normalizedPath?r.normalizedPath:t?e:v.resolve(this.basePath,e)}async inProjectRoot(e){if(!this.projectRoot)return;if(e.includes("\0"))throw new S(e,["Null byte in path"],"critical");let t=v.resolve(this.basePath,e);if(!qe(this.projectRoot,t))return;if(Ne.includes(v.extname(t).toLowerCase()))throw new S(e,[`File extension '${v.extname(t)}' is not allowed`],"high");this.projectRootReal??=M.realpath(this.projectRoot).catch(()=>null);let s=await this.projectRootReal;if(s)return{lexical:t,rootReal:s}}async readContained(e,t,s){this.stats.totalReads++;try{let n=v.isAbsolute(e)?e:`${v.resolve(this.basePath)}${v.sep}${e}`;return R(await Me(n,{projectRoot:this.projectRoot??s}))}catch(n){return n instanceof Re?n.reason==="outside-project-root"?I(new S(e,["Path resolves outside the project root"],"critical")):n.reason==="not-a-file"?I(new A("Not a regular file: "+t,t,n.code==="NOT_A_FILE"?"EISDIR":n.code)):I(ue({code:n.reason==="not-found"?"ENOENT":n.code},t)):I(ue(n,t))}}async readFile(e){let t;try{let s=await this.inProjectRoot(e);if(s)return this.readContained(e,s.lexical,s.rootReal);t=this.resolvePath(e)}catch(s){if(s instanceof S)return I(s);throw s}if(this.stats.totalReads++,this.enableCache){let s=this.cache.get(t);if(s!==void 0)return this.stats.cacheHits++,this.updateCacheStats(),R(s);this.stats.cacheMisses++}try{let s=await M.readFile(t,"utf-8");return this.enableCache&&(this.cache.set(t,s,Buffer.byteLength(s,"utf-8")),this.updateCacheStats()),R(s)}catch(s){return I(ue(s,t))}}async readJSON(e){let t=await this.readFile(e);if(!t.success)return t;try{let s=O(t.value);return R(s)}catch(s){let n=s,i=e;try{i=this.resolvePath(e)}catch{}return I(new V("Invalid JSON in file: "+i+" - "+n.message,i,n))}}async fileExists(e){let t;try{t=this.resolvePath(e)}catch(s){if(s instanceof S)return I(s);throw s}try{return await M.access(t,M.constants.F_OK),R(!0)}catch(s){let n=s;return n.code==="ENOENT"?R(!1):I(new A("Cannot check file existence: "+t,t,n.code,n))}}async listFiles(e,t){let s;try{s=t?this.resolvePath(t):this.basePath}catch(n){if(n instanceof S)return I(n);throw n}try{if(!(await M.stat(s)).isDirectory())return I(new A("Base path is not a directory: "+s,s,"ENOTDIR"));let i=Ve(e),o=[];return await Fe(s,i,o,s),o.sort(),R(o)}catch(n){let i=n;return I(new A("Failed to list files in: "+s,s,i.code,i))}}invalidateCache(e){let t=this.resolvePath(e);this.cache.delete(t),this.updateCacheStats()}clearCache(){this.cache.clear(),this.updateCacheStats()}pruneCache(){let e=this.cache.prune();return this.updateCacheStats(),e}getStats(){return{...this.stats}}resetStats(){this.stats={cacheHits:0,cacheMisses:0,totalReads:0,cacheSize:this.cache.totalBytes,cacheEntries:this.cache.size}}updateCacheStats(){this.stats.cacheSize=this.cache.totalBytes,this.stats.cacheEntries=this.cache.size}};Y();var E={MODEL:"all-MiniLM-L6-v2",DIMENSIONS:384,CONTEXT_WINDOW:8192,BATCH_SIZE:100,MAX_RETRIES:3,RETRY_DELAY_MS:1e3,TIMEOUT_MS:3e4,DEFAULT_OLLAMA_URL:"http://localhost:11434",OLLAMA_PULL_NAME:"all-minilm:22m",OLLAMA_MODEL_ENV:"AQE_OLLAMA_EMBEDDING_MODEL"};Ke();var He=/^(latest|22m(-.*)?|l6-v2(-.*)?)?$/i;function Oe(p){let e=p.lastIndexOf(":");return e>p.lastIndexOf("/")?{base:p.slice(0,e),tag:p.slice(e+1)}:{base:p,tag:""}}function he(p){let{base:e,tag:t}=Oe(p);return e.slice(e.lastIndexOf("/")+1).toLowerCase()===E.MODEL.toLowerCase()?!0:e.toLowerCase()==="all-minilm"&&He.test(t)}var _=class{baseUrl;maxRetries;retryDelayMs;timeoutMs;requestedModel;installedModel=null;constructor(e=Le(E.DEFAULT_OLLAMA_URL),t=E.MAX_RETRIES,s=E.RETRY_DELAY_MS,n=E.TIMEOUT_MS,i=process.env[E.OLLAMA_MODEL_ENV]){this.baseUrl=e.replace(/\/$/,""),this.maxRetries=t,this.retryDelayMs=s,this.timeoutMs=n,this.requestedModel=i?.trim()||void 0}getBaseUrl(){return this.baseUrl}getModelId(){return!this.requestedModel||he(this.requestedModel)?E.MODEL:`ollama:${this.requestedModel}`}async healthCheck(){return(await this.checkModel()).status==="available"}async checkModel(){let e=this.requestedModel??E.MODEL,t;try{t=await this.fetchWithTimeout(`${this.baseUrl}/api/tags`,{method:"GET",headers:{"Content-Type":"application/json"}},5e3,async i=>i.ok?await i.json():{httpStatus:i.status})}catch{return{status:"unreachable",reason:`Ollama at ${this.baseUrl} is not reachable`}}if(t&&"httpStatus"in t)return{status:"unreachable",reason:`Ollama at ${this.baseUrl} answered HTTP ${t.httpStatus} when listing models`};let s=this.requestedModel,n=s?i=>i===s||!Oe(s).tag&&i===`${s}:latest`:he;for(let i of t?.models??[]){let o=[i.name,i.model].find(r=>!!r&&n(r));if(o)return this.installedModel=o,{status:"available",model:o}}return{status:"missing",reason:`model '${e}' not installed in Ollama at ${this.baseUrl}; install it with: ollama pull ${s??E.OLLAMA_PULL_NAME}`}}async generateEmbedding(e){let t={model:this.installedModel??this.requestedModel??E.MODEL,prompt:e},s=null;for(let n=0;n<this.maxRetries;n++)try{let i=await this.fetchWithTimeout(`${this.baseUrl}/api/embeddings`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},this.timeoutMs,async o=>{if(!o.ok){let r=await o.text();throw new Error(`Ollama API error (${o.status}): ${r}`)}return await o.json()});if(i.embedding.length!==E.DIMENSIONS)throw new Error(`Invalid embedding dimensions: expected ${E.DIMENSIONS}, got ${i.embedding.length}`);return i.embedding}catch(i){if(s=N(i),s.message.includes("Invalid embedding dimensions"))throw s;if(n<this.maxRetries-1){let o=this.retryDelayMs*Math.pow(2,n);await this.sleep(o)}}throw new Error(`Failed to generate embedding after ${this.maxRetries} attempts: ${s?.message}`)}async fetchWithTimeout(e,t,s,n){let i=new AbortController,o=setTimeout(()=>i.abort(),s);try{let r=await fetch(e,{...t,signal:i.signal});return await n(r)}finally{clearTimeout(o)}}sleep(e){return new Promise(t=>setTimeout(t,e))}async getServerInfo(){try{return await this.fetchWithTimeout(`${this.baseUrl}/api/tags`,{method:"GET",headers:{"Content-Type":"application/json"}},5e3,async e=>e.ok?await e.json():null)}catch{return null}}async ensureModelAvailable(){let e=await this.checkModel();if(e.status!=="available")throw new Error(`Ollama model '${this.requestedModel??E.MODEL}' is not available: ${e.reason}`)}};import{createHash as Je}from"crypto";var $=class{cache;maxSize;hits;misses;constructor(e=1e4){this.cache=new Map,this.maxSize=e,this.hits=0,this.misses=0}hashContent(e,t,s){return Je("sha256").update(JSON.stringify(s===void 0?[t,e]:[t,s,e])).digest("hex")}get(e,t,s){let n=this.hashContent(e,t,s),i=this.cache.get(n);return i?(this.hits++,this.cache.delete(n),this.cache.set(n,i),[...i.embedding]):(this.misses++,null)}set(e,t,s,n){let i=this.hashContent(e,t,n);if(this.cache.size>=this.maxSize&&!this.cache.has(i)){let r=this.cache.keys().next().value;r&&this.cache.delete(r)}let o={embedding:[...s],timestamp:Date.now(),model:t};this.cache.set(i,o)}has(e,t,s){let n=this.hashContent(e,t,s);return this.cache.has(n)}getStats(){let e=this.hits+this.misses,t=e>0?this.hits/e:0;return{size:this.cache.size,hitRate:t,hits:this.hits,misses:this.misses}}clear(){this.cache.clear(),this.hits=0,this.misses=0}evictOlderThan(e){let s=Date.now()-e,n=0;for(let[i,o]of this.cache.entries())o.timestamp<s&&(this.cache.delete(i),n++);return n}getMemoryUsageEstimate(){return this.cache.size*3172}export(){return Array.from(this.cache.entries()).map(([e,t])=>({key:e,entry:{...t,embedding:[...t.embedding]}}))}import(e){this.cache.clear();for(let{key:t,entry:s}of e)this.cache.size<this.maxSize&&this.cache.set(t,{...s,embedding:[...s.embedding]})}};Y();var j="pseudo-embedding",ge="verified-backend-v1",H=p=>p===j?void 0:ge,U=class{client;cache;batchSize;enableFallback;ollamaAvailable=null;constructor(e={}){this.client=new _(e.ollamaBaseUrl,void 0,void 0,void 0,e.ollamaModel),this.cache=e.cache??new $(e.maxCacheSize),this.batchSize=e.batchSize??E.BATCH_SIZE,this.enableFallback=e.enableFallback??!0}async embed(e){let t=this.cache.has(e,this.getModelId(),ge)||await this.isOllamaAvailable()||!this.enableFallback?this.getModelId():j,s=this.cache.get(e,t,H(t));if(s)return s;let n;if(await this.isOllamaAvailable())t=this.getModelId(),n=await this.client.generateEmbedding(e);else if(this.enableFallback)t=j,n=this.generatePseudoEmbedding(e);else throw new Error(`Ollama is not available and fallback is disabled. Please run: ollama pull ${E.OLLAMA_PULL_NAME}`);return this.cache.set(e,t,n,H(t)),n}formatForEmbedding(e){let t=[];e.language&&t.push(e.language),e.type&&t.push(e.type),e.name&&t.push(e.name);let s=t.length>0?`${t.join(" ")}: `:"",n=E.CONTEXT_WINDOW*4,i=e.content.trim();if(s.length+i.length>n){let o=n-s.length-3;i=i.substring(0,o)+"..."}return s+i}async embedBatch(e){let t=[];for(let s of e){let n=await this.embed(s);t.push(n)}return t}async embedCodeChunks(e,t){let s=Date.now(),n=[],i=0,o=0,r=await this.isOllamaAvailable();if(r)await this.client.ensureModelAvailable();else if(!this.enableFallback)throw new Error(`Ollama is not available and fallback is disabled. Please run: ollama pull ${E.OLLAMA_PULL_NAME}`);for(let c=0;c<e.length;c+=this.batchSize){let l=e.slice(c,Math.min(c+this.batchSize,e.length)),d=await this.processBatch(l,r);n.push(...d);for(let u of d)u.cached?i++:o++;if(t){let u=c+l.length,h=e.length,y=(Date.now()-s)/u,f=(h-u)*y;t({current:u,total:h,percentage:u/h*100,estimatedTimeRemainingMs:f})}}let a=Date.now()-s;return{results:n,stats:{totalChunks:e.length,cachedHits:i,computedNew:o,totalTimeMs:a,avgTimePerChunk:a/e.length}}}async processBatch(e,t){let s=[],n=e.map(async o=>{let r=this.formatForEmbedding(o),a=Date.now(),c=t||this.cache.has(r,this.getModelId(),ge)?this.getModelId():j,l=this.cache.get(r,c,H(c));if(l)return{chunkId:o.id,embedding:l,model:c,cached:!0,computeTimeMs:Date.now()-a};try{let d;t?d=await this.client.generateEmbedding(r):d=this.generatePseudoEmbedding(r);let u=t?this.getModelId():j;return this.cache.set(r,u,d,H(u)),{chunkId:o.id,embedding:d,model:u,cached:!1,computeTimeMs:Date.now()-a}}catch(d){throw new Error(`Failed to generate embedding for chunk ${o.id}: ${W(d)}`)}}),i=await Promise.all(n);return s.push(...i),s}async isOllamaAvailable(){return this.ollamaAvailable!==null?this.ollamaAvailable:(this.ollamaAvailable=await this.client.healthCheck(),this.ollamaAvailable)}resetOllamaCheck(){this.ollamaAvailable=null}generatePseudoEmbedding(e){let t=new Array(E.DIMENSIONS).fill(0),s=e.split(/\s+|[^\w]+/).filter(o=>o.length>0);for(let o=0;o<s.length;o++){let r=s[o];for(let a=0;a<r.length&&a<t.length;a++)t[(o+a)%t.length]+=r.charCodeAt(a)/1e3}let n=[[/class\s+\w+/,0],[/function\s+\w+/,1],[/async\s+|await\s+|Promise/,2],[/interface\s+\w+/,3],[/export\s+/,4],[/import\s+/,5],[/try\s*{/,6],[/\.(map|filter|reduce)\(/,7]];for(let[o,r]of n)o.test(e)&&(t[r]+=.5);let i=Math.sqrt(t.reduce((o,r)=>o+r*r,0))||1;return t.map(o=>o/i)}clearCache(){this.cache.clear()}getCacheStats(){return this.cache.getStats()}async healthCheck(){return await this.client.healthCheck()}async checkModel(){return await this.client.checkModel()}getModelId(){return this.client.getModelId()}async getServerInfo(){return await this.client.getServerInfo()}getDimensions(){return E.DIMENSIONS}getConfig(){return{model:this.getModelId(),dimensions:E.DIMENSIONS,contextWindow:E.CONTEXT_WINDOW,batchSize:this.batchSize,maxRetries:E.MAX_RETRIES,enableFallback:this.enableFallback}}};je();Y();Ie();import{existsSync as Ze,statSync as et}from"fs";import{dirname as tt,resolve as st,join as J}from"path";function Xe(p){switch(p){case"ts":case"mts":case"cts":return"tree-sitter-typescript.wasm";case"tsx":return"tree-sitter-tsx.wasm";case"js":case"jsx":case"mjs":case"cjs":return"tree-sitter-javascript.wasm";default:return null}}var K=p=>p.startPosition.row+1,G=(p,e)=>p.childForFieldName(e)?.text??"";function ye(p){for(let e=0;e<p.childCount;e++){let t=p.child(e);if(t){if(t.type==="async")return!0;if(t.type==="function"||t.type==="function_declaration")break}}return!1}function Qe(p){for(let e=0;e<p.childCount;e++)if(p.child(e)?.type==="accessibility_modifier"){let s=p.child(e).text;if(s==="private")return"private";if(s==="protected")return"protected"}return"public"}function Ye(p){let e=G(p,"name")||"(anonymous)",t=p.childForFieldName("body"),s=[];if(t)for(let n=0;n<t.childCount;n++){let i=t.child(n);i&&i.type==="method_definition"&&s.push({name:G(i,"name"),startLine:K(i),isAsync:ye(i),visibility:Qe(i)})}return{name:e,startLine:K(p),methods:s}}function fe(p){return p.replace(/^['"`]|['"`]$/g,"")}async function be(p,e){let t=Xe(e);if(!t)return null;let s=await Se(t);if(!s)return null;let n=null;try{let i=s.parse(p);n=i;let o=i.rootNode;if(!o)return null;let r={functions:[],classes:[],interfaces:[],imports:[]},a=[o];for(;a.length;){let c=a.pop(),l=!0;switch(c.type){case"function_declaration":case"generator_function_declaration":r.functions.push({name:G(c,"name"),startLine:K(c),isAsync:ye(c),visibility:"public"}),l=!1;break;case"class_declaration":case"class":r.classes.push(Ye(c)),l=!1;break;case"interface_declaration":r.interfaces.push({name:G(c,"name"),startLine:K(c)}),l=!1;break;case"lexical_declaration":case"variable_declaration":{for(let d=0;d<c.childCount;d++){let u=c.child(d);if(!u||u.type!=="variable_declarator")continue;let h=u.childForFieldName("value");if(h&&(h.type==="arrow_function"||h.type==="function"||h.type==="function_expression"))r.functions.push({name:G(u,"name"),startLine:K(u),isAsync:ye(h),visibility:"public"});else if(h&&h.type==="call_expression"&&h.child(0)?.text==="require"){let g=h.childForFieldName("arguments")?.child(1);g&&g.type==="string"&&r.imports.push(fe(g.text))}}l=!1;break}case"import_statement":{let d=c.childForFieldName("source");d&&r.imports.push(fe(d.text)),l=!1;break}case"call_expression":{let d=c.child(0);if(d&&d.text==="require"){let h=c.childForFieldName("arguments")?.child(1);h&&h.type==="string"&&r.imports.push(fe(h.text))}break}}if(l)for(let d=c.childCount-1;d>=0;d--){let u=c.child(d);u&&a.push(u)}}return r}catch{return null}finally{n?.delete?.()}}Ue();var nt={maxNodes:1e5,maxEdgesPerNode:500,namespace:"code-intelligence:kg",enableVectorEmbeddings:!0,embeddingDimension:384,enableLLMExtraction:!0,llmModelTier:2,llmMaxTokens:2048},xe=ve.create("code-intelligence/knowledge-graph"),X=new Set(["ts","tsx","js","jsx"]),De=class{config;memory;nodeCache=new Map;edgeIndex=new Map;allEdgesCache;tsParser;fileReader;projectRoot;embedder;llmRouter;constructor(e,t={}){this.config={...nt,...t},this.isKnowledgeGraphDependencies(e)?(this.memory=e.memory,this.llmRouter=e.llmRouter):(this.memory=e,this.llmRouter=void 0),this.tsParser=new F,this.projectRoot=this.config.projectRoot??this.config.basePath??we(),this.fileReader=new k({...this.config.basePath?{basePath:this.config.basePath}:{},projectRoot:this.projectRoot}),this.embedder=new U({enableFallback:!0})}isKnowledgeGraphDependencies(e){return e.memory!==void 0}get nsOpts(){return{namespace:this.config.namespace}}async index(e){let t=Date.now(),s=[],n=0,i=0,o=new Map;try{let{paths:r,incremental:a=!1,includeTests:c=!0,languages:l}=e,{accepted:d,skipped:u}=await Ce(r,this.projectRoot,this.config.basePath??process.cwd()),h=0;if(!a)await this.clear();else for(let b of u)b.reason==="not-found"&&await this.removeFileFromGraph(b.path);for(let b of d)try{if(l&&l.length>0){let w=this.getFileExtension(b);if(!this.matchesLanguage(w,l)){u.push({path:b,reason:"excluded-by-language"});continue}}if(!c&&this.isTestFile(b)){u.push({path:b,reason:"excluded-test-file"});continue}let f=this.getFileExtension(b);X.has(f)||o.set(f||"(none)",(o.get(f||"(none)")??0)+1);let x=await this.indexFile(b,a);n+=x.nodes,i+=x.edges,h++}catch(f){s.push({file:b,error:W(f)})}let g=Date.now()-t,y=[];if(o.size>0){let b=Array.from(X).join(", ");for(let[f,x]of o){let w=`${x} file(s) with extension '.${f}' were indexed as plain nodes: no dependency extractor for this language, so 'deps'/'impact' will report 0 edges for them. Supported: ${b}.`;y.push(w),xe.warn(w)}}return await this.storeIndexMetadata({filesIndexed:h,nodesCreated:n,edgesCreated:i,duration:g,indexedAt:new Date().toISOString()}),R({filesIndexed:h,nodesCreated:n,edgesCreated:i,duration:g,errors:s,warnings:y,skipped:u})}catch(r){return I(N(r))}}async query(e){try{let{query:t,type:s,limit:n=100}=e;return s==="cypher"?this.executeCypherQuery(t,n):this.executeNaturalLanguageQuery(t,n)}catch(t){return I(N(t))}}async mapDependencies(e){try{let{files:t,direction:s,depth:n=3}=e,i=[],o=[],r=new Set,a=[];for(let l of t)await this.traverseDependencies(l,s,n,r,i,o,[],a);let c=this.calculateDependencyMetrics(i,o);return R({nodes:i,edges:o,cycles:a,metrics:c})}catch(t){return I(N(t))}}async getNode(e){if(this.nodeCache.has(e))return this.nodeCache.get(e);let t=`${this.config.namespace}:node:${e}`,s=await this.memory.get(t,this.nsOpts);return s&&this.nodeCache.set(e,s),s}async getEdges(e,t){let s=await this.loadAllEdges();return this.filterEdgesByDirection(s,e,t)}async loadAllEdges(){if(this.allEdgesCache)return this.allEdgesCache;let e=[],t=`${this.config.namespace}:edge:*`,s=await this.memory.search(t,Number.MAX_SAFE_INTEGER,this.nsOpts);for(let n of s){let i=await this.memory.get(n,this.nsOpts);i&&e.push(i)}return this.allEdgesCache=e,e}async clear(){this.nodeCache.clear(),this.edgeIndex.clear(),this.allEdgesCache=void 0;for(let e of[`${this.config.namespace}:node:`,`${this.config.namespace}:edge:`]){let t=await this.memory.search(`${e}*`,Number.MAX_SAFE_INTEGER,this.nsOpts);for(let s of t)await this.memory.delete(s,this.nsOpts)}}async removeFileFromGraph(e){let t=this.pathToNodeId(e),s=this.config.namespace,n=await this.memory.search(`${s}:node:${t}*`,Number.MAX_SAFE_INTEGER,this.nsOpts);for(let o of n)await this.memory.delete(o,this.nsOpts),this.nodeCache.delete(o.slice(`${s}:node:`.length));let i=await this.memory.search(`${s}:edge:*`,Number.MAX_SAFE_INTEGER,this.nsOpts);for(let o of i){let r=await this.memory.get(o,this.nsOpts);r&&(r.source===t||r.source.startsWith(`${t}:`))&&await this.memory.delete(o,this.nsOpts)}this.edgeIndex.delete(t),this.allEdgesCache=void 0}isLLMExtractionAvailable(){return this.config.enableLLMExtraction===!0&&this.llmRouter!==void 0}getModelForTier(e){return Pe(e)}async extractRelationshipsWithLLM(e,t){if(!this.llmRouter)return{semanticRelationships:[],designPatterns:[],architecturalBoundaries:[],dependencyImpacts:[]};try{let s=this.buildRelationshipExtractionPrompt(e,t),n=this.getModelForTier(this.config.llmModelTier??2),i=await this.llmRouter.chat({messages:[{role:"system",content:`You are an expert software architect analyzing code structure. Extract:
|
|
24
24
|
1. Semantic relationships between code entities (inheritance, composition, dependency, collaboration)
|
|
25
25
|
2. Design patterns used (Factory, Singleton, Observer, Strategy, etc.)
|
|
26
26
|
3. Architectural boundaries (layers, modules, domains)
|
|
@@ -56,4 +56,4 @@ Return JSON: { "rankedIds": ["id1", "id2", ...], "insights": ["insight1", "insig
|
|
|
56
56
|
|
|
57
57
|
Results:
|
|
58
58
|
${JSON.stringify(t.map(i=>({id:i.id,label:i.label,properties:i.properties})),null,2)}`}],model:s,maxTokens:1024,temperature:.3,agentType:"qe-code-intelligence"});if(n.content)try{let i=n.content.match(/\{[\s\S]*\}/);if(i){let o=O(i[0]),r=o.rankedIds||[],a=o.insights||[],c=new Map(t.map(d=>[d.id,d])),l=[];for(let d of r){let u=c.get(d);u&&(l.push(u),c.delete(d))}return l.push(...Array.from(c.values())),{enhancedResults:l,insights:a}}}catch{}return{enhancedResults:t,insights:[]}}catch{return xe.warn("LLM query enhancement failed:"),{enhancedResults:t,insights:[]}}}async indexFile(e,t=!1){let s=0,n=0;try{this.fileReader.invalidateCache(e)}catch{}let i=await this.fileReader.readFile(e);if(!i.success)throw i.error;t&&await this.removeFileFromGraph(e);let o=await this.createFileNode(e);s++;let r=await this.extractEntities(e);for(let c of r){let l=await this.createEntityNode(c,e);s++,await this.createEdge(o.id,l.id,"contains"),n++}let a=await this.extractImports(e);for(let c of a){let l=this.resolveImportPath(c,e),d=this.pathToNodeId(l);await this.createEdge(o.id,d,"import"),n++}if(this.isLLMExtractionAvailable()){let c=await this.fileReader.readFile(e);if(c.success){let l=await this.extractRelationshipsWithLLM(c.value,r);n+=await this.storeLLMRelationships(o.id,l)}}return{nodes:s,edges:n}}async storeLLMRelationships(e,t){let s=0;for(let i of t.semanticRelationships){let o=`${e}:*:${i.source}`,r=`${e}:*:${i.target}`;await this.createEdge(o,r,i.type),s++}let n=this.nodeCache.get(e);return n&&(t.designPatterns.length>0&&(n.properties.designPatterns=t.designPatterns),t.architecturalBoundaries.length>0&&(n.properties.architecturalBoundaries=t.architecturalBoundaries),t.dependencyImpacts.length>0&&(n.properties.dependencyImpacts=t.dependencyImpacts),this.nodeCache.set(e,n)),s}async createFileNode(e){let s={id:this.pathToNodeId(e),label:"File",properties:{path:e,name:this.getFileName(e),extension:this.getFileExtension(e),type:this.getFileType(e)}};return await this.storeNode(s),s}async createEntityNode(e,t){let s=`${this.pathToNodeId(t)}:${e.type}:${e.name}`,n={id:s,label:e.type,properties:{name:e.name,file:t,line:e.line,visibility:e.visibility,async:e.isAsync}};if(await this.storeNode(n),this.config.enableVectorEmbeddings){let i=await this.generateEmbedding(e);await this.memory.storeVector(`${this.config.namespace}:node:${s}`,i,{nodeId:s,type:e.type,name:e.name})}return n}async createEdge(e,t,s){let n=`${e}--${s}-->${t}`,i={source:e,target:t,type:s},o=this.edgeIndex.get(e)||[];return o.push(i),this.edgeIndex.set(e,o),await this.memory.set(`${this.config.namespace}:edge:${n}`,i,this.nsOpts),this.allEdgesCache=void 0,i}async storeNode(e){if(this.nodeCache.size>=this.config.maxNodes){let t=this.nodeCache.keys().next().value;t&&(this.nodeCache.delete(t),this.edgeIndex.delete(t))}this.nodeCache.set(e.id,e),await this.memory.set(`${this.config.namespace}:node:${e.id}`,e,this.nsOpts)}async extractEntities(e){let t=this.getFileExtension(e),s=[];if(X.has(t)){let n=await this.fileReader.readFile(e),i=this.getFileName(e);if(n.success){let o=!1;try{let r=await be(n.value,t);if(r){for(let a of r.functions)s.push({type:"function",name:a.name,line:a.startLine,visibility:a.visibility,isAsync:a.isAsync});for(let a of r.classes){s.push({type:"class",name:a.name,line:a.startLine,visibility:"public",isAsync:!1});for(let c of a.methods)s.push({type:"function",name:`${a.name}.${c.name}`,line:c.startLine,visibility:c.visibility,isAsync:c.isAsync})}for(let a of r.interfaces)s.push({type:"interface",name:a.name,line:a.startLine,visibility:"public",isAsync:!1});o=!0}}catch{}if(!o)try{let r=this.tsParser.parseFile(i,n.value);for(let a of this.tsParser.extractFunctions(r))s.push({type:"function",name:a.name,line:a.startLine,visibility:"public",isAsync:a.isAsync});for(let a of this.tsParser.extractClasses(r)){s.push({type:"class",name:a.name,line:a.startLine,visibility:"public",isAsync:!1});for(let c of a.methods)s.push({type:"function",name:`${a.name}.${c.name}`,line:c.startLine,visibility:c.visibility,isAsync:c.isAsync})}for(let a of this.tsParser.extractInterfaces(r))s.push({type:"interface",name:a.name,line:a.startLine,visibility:"public",isAsync:!1})}catch{}s.length===0&&s.push({type:"module",name:i.replace(/\.[^.]+$/,""),line:1,visibility:"public",isAsync:!1})}else s.push({type:"module",name:this.getFileName(e).replace(/\.[^.]+$/,""),line:1,visibility:"public",isAsync:!1})}else if(t==="py"){let n=await this.fileReader.readFile(e);if(n.success){let o=n.value.split(`
|
|
59
|
-
`),r=/^class\s+(\w+)\s*(?:\([^)]*\))?\s*:/,a=/^(async\s+)?def\s+(\w+)\s*\(/,c=null,l=0;for(let d=0;d<o.length;d++){let u=o[d],h=d+1,g=u.trimStart(),y=u.length-g.length;c&&y<=l&&(c=null);let b=g.match(r);if(b){let x=b[1];s.push({type:"class",name:x,line:h,visibility:x.startsWith("_")?"private":"public",isAsync:!1}),c=x,l=y;continue}let f=g.match(a);if(f){let x=!!f[1],w=f[2],ke=c!==null&&y>l,Q="public";w.startsWith("__")&&!w.endsWith("__")?Q="private":w.startsWith("_")&&(Q="protected"),s.push({type:"function",name:ke?`${c}.${w}`:w,line:h,visibility:Q,isAsync:x})}}s.length===0&&s.push({type:"module",name:this.getFileName(e).replace(".py",""),line:1,visibility:"public",isAsync:!1})}else s.push({type:"module",name:this.getFileName(e).replace(".py",""),line:1,visibility:"public",isAsync:!1})}return s}async extractImports(e){let t=this.getFileExtension(e),s=[];if(X.has(t)){let n=await this.fileReader.readFile(e);if(n.success){let i=this.getFileName(e),o=null;try{let r=await be(n.value,t);r&&(o=r.imports)}catch{o=null}if(o===null)try{let r=this.tsParser.parseFile(i,n.value);o=this.tsParser.extractImports(r).map(a=>a.module)}catch{o=[]}for(let r of o)r.startsWith("node:")||s.push(r)}}return s}async executeCypherQuery(e,t){let s=[],n=[],i=new Map,o=/MATCH\s+\((\w+):(\w+)\)\s*-\[(\w+)?:?(\w+)?\]\s*->\s*\((\w+):(\w+)\)/i.exec(e);if(o){let[,a,c,,l,d,u]=o,h=await this.findNodesByLabel(c,t*2);i.set(a,h);for(let g of h.slice(0,t)){let y=await this.getEdges(g.id,"outgoing");for(let b of y){if(l&&b.type!==l)continue;let f=await this.getNode(b.target);f&&f.label===u&&(s.some(x=>x.id===g.id)||s.push(g),s.some(x=>x.id===f.id)||s.push(f),n.some(x=>x.source===b.source&&x.target===b.target&&x.type===b.type)||n.push(b))}}d&&i.set(d,s.filter(g=>g.label===u))}else{let a=/MATCH\s+\((\w+):(\w+)\)/i.exec(e);if(a){let[,c,l]=a,d=await this.findNodesByLabel(l,t);i.set(c,d),s.push(...d)}}let r=/WHERE\s+(\w+)\.(\w+)\s*=\s*['"]?([^'")\s]+)['"]?/i.exec(e);if(r){let[,a,c,l]=r,u=(i.get(a)||s).filter(y=>{let b=y.properties[c];return b!==void 0&&String(b)===l});s.length=0,s.push(...u.slice(0,t));let h=new Set(s.map(y=>y.id)),g=n.filter(y=>h.has(y.source)&&h.has(y.target));n.length=0,n.push(...g)}return R({nodes:s.slice(0,t),edges:n,metadata:{query:e,type:"cypher",resultCount:s.length,edgeCount:n.length}})}async findNodesByLabel(e,t){let s=[],n=`${this.config.namespace}:node:*`,i=await this.memory.search(n,t*2,this.nsOpts);for(let o of i){let r=await this.memory.get(o,this.nsOpts);if(r&&r.label===e&&(s.push(r),s.length>=t))break}return s}async executeNaturalLanguageQuery(e,t){if(this.config.enableVectorEmbeddings){let r=await this.generateQueryEmbedding(e),a=await this.memory.vectorSearch(r,t),c=[];for(let l of a){let d=l.metadata?.nodeId;if(d){let u=await this.getNode(d);u&&c.push(u)}}return R({nodes:c,edges:[],metadata:{query:e,type:"natural-language",resultCount:c.length,searchScores:a.map(l=>l.score)}})}let s=e.toLowerCase().split(/\s+/),n=`${this.config.namespace}:node:*`,i=await this.memory.search(n,t*3,this.nsOpts),o=[];for(let r of i){let a=await this.memory.get(r,this.nsOpts);if(a){let c=JSON.stringify(a.properties).toLowerCase();if(s.some(l=>c.includes(l))&&(o.push(a),o.length>=t))break}}return R({nodes:o,edges:[],metadata:{query:e,type:"keyword",resultCount:o.length}})}async traverseDependencies(e,t,s,n,i,o,r,a){if(s<=0||n.has(e)){let g=r.indexOf(e);g>=0&&a.push([...r.slice(g),e]);return}n.add(e),r.push(e);let c=this.pathToNodeId(e),l=new Set(["import","call","extends","implements"]),d=(await this.getEdges(c,t)).filter(g=>l.has(g.type)),u=d.filter(g=>g.target===c).length,h=d.filter(g=>g.source===c).length;i.push({id:c,path:e,type:"file",inDegree:u,outDegree:h});for(let g of d){let y={source:g.source,target:g.target,type:g.type};if(o.some(f=>f.source===y.source&&f.target===y.target)||o.push(y),g.source!==c)continue;let b=this.nodeIdToPath(g.target);b&&await this.traverseDependencies(b,t,s-1,n,i,o,r,a)}r.pop()}calculateDependencyMetrics(e,t){let s=e.length,n=t.length,i=s>0?e.reduce((a,c)=>a+c.inDegree+c.outDegree,0)/s:0,o=0;if(e.length>0){let a=new Map;for(let l of t){let d=a.get(l.source)||[];d.push(l.target),a.set(l.source,d)}let c=new Map;for(let l of e)c.has(l.id)||this.bfsDepth(l.id,a,c),o=Math.max(o,c.get(l.id)||0)}let r=n-s+2;return{totalNodes:s,totalEdges:n,avgDegree:Math.round(i*100)/100,maxDepth:o,cyclomaticComplexity:Math.max(1,r)}}bfsDepth(e,t,s){let n=[{id:e,depth:0}];for(;n.length>0;){let i=n.shift(),o=s.get(i.id)??-1;i.depth>o&&s.set(i.id,i.depth);let r=t.get(i.id)||[];for(let a of r)(!s.has(a)||(s.get(a)??0)<i.depth+1)&&n.push({id:a,depth:i.depth+1})}}filterEdgesByDirection(e,t,s){return e.filter(n=>s==="incoming"?n.target===t:s==="outgoing"?n.source===t:n.source===t||n.target===t)}async storeIndexMetadata(e){}async generateEmbedding(e){let t=`${e.type} ${e.name} ${e.visibility}${e.isAsync?" async":""}`;try{return await this.embedder.embed(t)}catch{return this.fallbackEmbedding(t)}}async generateQueryEmbedding(e){try{return await this.embedder.embed(e)}catch{return this.fallbackEmbedding(e)}}fallbackEmbedding(e){let t=new Array(this.config.embeddingDimension).fill(0),s=e.toLowerCase().split(/\s+/);for(let i=0;i<s.length;i++){let o=s[i];for(let r=0;r<o.length&&r<t.length;r++)t[(i+r)%t.length]+=o.charCodeAt(r)/1e3}let n=Math.sqrt(t.reduce((i,o)=>i+o*o,0))||1;return t.map(i=>i/n)}pathToNodeId(e){return e.replace(/[/\\]/g,":").replace(/\./g,"_")}resolveImportPath(e,t){if(!e.startsWith("."))return e;let s=st(tt(t),e),n=[s,`${s}.ts`,`${s}.tsx`,`${s}.js`,`${s}.jsx`,`${s}.mjs`,`${s}.cjs`,J(s,"index.ts"),J(s,"index.tsx"),J(s,"index.js"),J(s,"index.jsx")];for(let i of n)try{if(Ze(i)&&et(i).isFile())return i}catch{}return`${s}.ts`}nodeIdToPath(e){let t=e.replace(/:/g,"/").replace(/_(?=[^_]*$)/,".");return t.includes("/")?t:null}getFileName(e){return e.split(/[/\\]/).pop()||e}getFileExtension(e){let s=this.getFileName(e).split(".");return s.length>1?s.pop():""}getFileType(e){let t=this.getFileExtension(e);return{ts:"typescript",tsx:"typescript-react",js:"javascript",jsx:"javascript-react",py:"python",go:"go",java:"java",rs:"rust",rb:"ruby",cs:"csharp",swift:"swift"}[t]||"unknown"}matchesLanguage(e,t){let s={typescript:["ts","tsx"],javascript:["js","jsx"],python:["py"],go:["go"],java:["java"],rust:["rs"],csharp:["cs"],swift:["swift"]};return t.some(n=>(s[n.toLowerCase()]||[n]).includes(e))}isTestFile(e){return[/\.test\.[tj]sx?$/,/\.spec\.[tj]sx?$/,/_test\.[tj]sx?$/,/test_.*\.py$/,/.*_test\.py$/,/.*_test\.go$/].some(s=>s.test(e))}destroy(){this.nodeCache.clear(),this.edgeIndex.clear()}};export{m as a,pt as b,
|
|
59
|
+
`),r=/^class\s+(\w+)\s*(?:\([^)]*\))?\s*:/,a=/^(async\s+)?def\s+(\w+)\s*\(/,c=null,l=0;for(let d=0;d<o.length;d++){let u=o[d],h=d+1,g=u.trimStart(),y=u.length-g.length;c&&y<=l&&(c=null);let b=g.match(r);if(b){let x=b[1];s.push({type:"class",name:x,line:h,visibility:x.startsWith("_")?"private":"public",isAsync:!1}),c=x,l=y;continue}let f=g.match(a);if(f){let x=!!f[1],w=f[2],ke=c!==null&&y>l,Q="public";w.startsWith("__")&&!w.endsWith("__")?Q="private":w.startsWith("_")&&(Q="protected"),s.push({type:"function",name:ke?`${c}.${w}`:w,line:h,visibility:Q,isAsync:x})}}s.length===0&&s.push({type:"module",name:this.getFileName(e).replace(".py",""),line:1,visibility:"public",isAsync:!1})}else s.push({type:"module",name:this.getFileName(e).replace(".py",""),line:1,visibility:"public",isAsync:!1})}return s}async extractImports(e){let t=this.getFileExtension(e),s=[];if(X.has(t)){let n=await this.fileReader.readFile(e);if(n.success){let i=this.getFileName(e),o=null;try{let r=await be(n.value,t);r&&(o=r.imports)}catch{o=null}if(o===null)try{let r=this.tsParser.parseFile(i,n.value);o=this.tsParser.extractImports(r).map(a=>a.module)}catch{o=[]}for(let r of o)r.startsWith("node:")||s.push(r)}}return s}async executeCypherQuery(e,t){let s=[],n=[],i=new Map,o=/MATCH\s+\((\w+):(\w+)\)\s*-\[(\w+)?:?(\w+)?\]\s*->\s*\((\w+):(\w+)\)/i.exec(e);if(o){let[,a,c,,l,d,u]=o,h=await this.findNodesByLabel(c,t*2);i.set(a,h);for(let g of h.slice(0,t)){let y=await this.getEdges(g.id,"outgoing");for(let b of y){if(l&&b.type!==l)continue;let f=await this.getNode(b.target);f&&f.label===u&&(s.some(x=>x.id===g.id)||s.push(g),s.some(x=>x.id===f.id)||s.push(f),n.some(x=>x.source===b.source&&x.target===b.target&&x.type===b.type)||n.push(b))}}d&&i.set(d,s.filter(g=>g.label===u))}else{let a=/MATCH\s+\((\w+):(\w+)\)/i.exec(e);if(a){let[,c,l]=a,d=await this.findNodesByLabel(l,t);i.set(c,d),s.push(...d)}}let r=/WHERE\s+(\w+)\.(\w+)\s*=\s*['"]?([^'")\s]+)['"]?/i.exec(e);if(r){let[,a,c,l]=r,u=(i.get(a)||s).filter(y=>{let b=y.properties[c];return b!==void 0&&String(b)===l});s.length=0,s.push(...u.slice(0,t));let h=new Set(s.map(y=>y.id)),g=n.filter(y=>h.has(y.source)&&h.has(y.target));n.length=0,n.push(...g)}return R({nodes:s.slice(0,t),edges:n,metadata:{query:e,type:"cypher",resultCount:s.length,edgeCount:n.length}})}async findNodesByLabel(e,t){let s=[],n=`${this.config.namespace}:node:*`,i=await this.memory.search(n,t*2,this.nsOpts);for(let o of i){let r=await this.memory.get(o,this.nsOpts);if(r&&r.label===e&&(s.push(r),s.length>=t))break}return s}async executeNaturalLanguageQuery(e,t){if(this.config.enableVectorEmbeddings){let r=await this.generateQueryEmbedding(e),a=await this.memory.vectorSearch(r,t),c=[];for(let l of a){let d=l.metadata?.nodeId;if(d){let u=await this.getNode(d);u&&c.push(u)}}return R({nodes:c,edges:[],metadata:{query:e,type:"natural-language",resultCount:c.length,searchScores:a.map(l=>l.score)}})}let s=e.toLowerCase().split(/\s+/),n=`${this.config.namespace}:node:*`,i=await this.memory.search(n,t*3,this.nsOpts),o=[];for(let r of i){let a=await this.memory.get(r,this.nsOpts);if(a){let c=JSON.stringify(a.properties).toLowerCase();if(s.some(l=>c.includes(l))&&(o.push(a),o.length>=t))break}}return R({nodes:o,edges:[],metadata:{query:e,type:"keyword",resultCount:o.length}})}async traverseDependencies(e,t,s,n,i,o,r,a){if(s<=0||n.has(e)){let g=r.indexOf(e);g>=0&&a.push([...r.slice(g),e]);return}n.add(e),r.push(e);let c=this.pathToNodeId(e),l=new Set(["import","call","extends","implements"]),d=(await this.getEdges(c,t)).filter(g=>l.has(g.type)),u=d.filter(g=>g.target===c).length,h=d.filter(g=>g.source===c).length;i.push({id:c,path:e,type:"file",inDegree:u,outDegree:h});for(let g of d){let y={source:g.source,target:g.target,type:g.type};if(o.some(f=>f.source===y.source&&f.target===y.target)||o.push(y),g.source!==c)continue;let b=this.nodeIdToPath(g.target);b&&await this.traverseDependencies(b,t,s-1,n,i,o,r,a)}r.pop()}calculateDependencyMetrics(e,t){let s=e.length,n=t.length,i=s>0?e.reduce((a,c)=>a+c.inDegree+c.outDegree,0)/s:0,o=0;if(e.length>0){let a=new Map;for(let l of t){let d=a.get(l.source)||[];d.push(l.target),a.set(l.source,d)}let c=new Map;for(let l of e)c.has(l.id)||this.bfsDepth(l.id,a,c),o=Math.max(o,c.get(l.id)||0)}let r=n-s+2;return{totalNodes:s,totalEdges:n,avgDegree:Math.round(i*100)/100,maxDepth:o,cyclomaticComplexity:Math.max(1,r)}}bfsDepth(e,t,s){let n=[{id:e,depth:0}];for(;n.length>0;){let i=n.shift(),o=s.get(i.id)??-1;i.depth>o&&s.set(i.id,i.depth);let r=t.get(i.id)||[];for(let a of r)(!s.has(a)||(s.get(a)??0)<i.depth+1)&&n.push({id:a,depth:i.depth+1})}}filterEdgesByDirection(e,t,s){return e.filter(n=>s==="incoming"?n.target===t:s==="outgoing"?n.source===t:n.source===t||n.target===t)}async storeIndexMetadata(e){}async generateEmbedding(e){let t=`${e.type} ${e.name} ${e.visibility}${e.isAsync?" async":""}`;try{return await this.embedder.embed(t)}catch{return this.fallbackEmbedding(t)}}async generateQueryEmbedding(e){try{return await this.embedder.embed(e)}catch{return this.fallbackEmbedding(e)}}fallbackEmbedding(e){let t=new Array(this.config.embeddingDimension).fill(0),s=e.toLowerCase().split(/\s+/);for(let i=0;i<s.length;i++){let o=s[i];for(let r=0;r<o.length&&r<t.length;r++)t[(i+r)%t.length]+=o.charCodeAt(r)/1e3}let n=Math.sqrt(t.reduce((i,o)=>i+o*o,0))||1;return t.map(i=>i/n)}pathToNodeId(e){return e.replace(/[/\\]/g,":").replace(/\./g,"_")}resolveImportPath(e,t){if(!e.startsWith("."))return e;let s=st(tt(t),e),n=[s,`${s}.ts`,`${s}.tsx`,`${s}.js`,`${s}.jsx`,`${s}.mjs`,`${s}.cjs`,J(s,"index.ts"),J(s,"index.tsx"),J(s,"index.js"),J(s,"index.jsx")];for(let i of n)try{if(Ze(i)&&et(i).isFile())return i}catch{}return`${s}.ts`}nodeIdToPath(e){let t=e.replace(/:/g,"/").replace(/_(?=[^_]*$)/,".");return t.includes("/")?t:null}getFileName(e){return e.split(/[/\\]/).pop()||e}getFileExtension(e){let s=this.getFileName(e).split(".");return s.length>1?s.pop():""}getFileType(e){let t=this.getFileExtension(e);return{ts:"typescript",tsx:"typescript-react",js:"javascript",jsx:"javascript-react",py:"python",go:"go",java:"java",rs:"rust",rb:"ruby",cs:"csharp",swift:"swift"}[t]||"unknown"}matchesLanguage(e,t){let s={typescript:["ts","tsx"],javascript:["js","jsx"],python:["py"],go:["go"],java:["java"],rust:["rs"],csharp:["cs"],swift:["swift"]};return t.some(n=>(s[n.toLowerCase()]||[n]).includes(e))}isTestFile(e){return[/\.test\.[tj]sx?$/,/\.spec\.[tj]sx?$/,/_test\.[tj]sx?$/,/test_.*\.py$/,/.*_test\.py$/,/.*_test\.go$/].some(s=>s.test(e))}destroy(){this.nodeCache.clear(),this.edgeIndex.clear()}};export{m as a,pt as b,E as c,U as d,F as e,S as f,k as g,De as h};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.
|
|
2
|
-
import{h as g}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.15.18");process.exit(0)}
|
|
2
|
+
import{h as g}from"./chunk-OHU5P25N.js";import{i as h}from"./chunk-4BIMTRRX.js";import{c as p,d}from"./chunk-JMRDT2XK.js";import{b as m,e as f}from"./chunk-AWQAE3SW.js";f();var I={maxDepth:5,riskWeights:{directImpact:.4,transitiveImpact:.2,testCoverage:.2,criticalPath:.15,dependencyCount:.05},testPatterns:["**/*.test.ts","**/*.test.tsx","**/*.spec.ts","**/*.spec.tsx","**/test_*.py","**/*_test.py","**/*_test.go"],criticalPaths:["**/auth/**","**/security/**","**/payment/**","**/api/**","**/core/**"],namespace:"code-intelligence:impact"},u=class{constructor(e,t,i={}){this.memory=e;this.config={...I,...i},this.knowledgeGraph=t||new g(e)}memory;config;knowledgeGraph;async analyzeImpact(e){try{let{changedFiles:t,depth:i=this.config.maxDepth,includeTests:r=!0}=e;if(t.length===0)return p({directImpact:[],transitiveImpact:[],impactedTests:[],riskLevel:"info",recommendations:[]});let n=await this.analyzeDirectImpact(t),l=await this.analyzeTransitiveImpact(t,n,i),s=[];if(r){let a=await this.getImpactedTests(t);a.success&&(s=a.value)}let c={directImpact:n,transitiveImpact:l,impactedTests:s,riskLevel:"info",recommendations:[]};return c.riskLevel=this.calculateRiskLevel(c),c.recommendations=this.getRecommendations(c),await this.storeAnalysis(t,c),p(c)}catch(t){return d(m(t))}}async getImpactedTests(e){try{let t=new Set;for(let i of e){if(this.isTestFile(i)){t.add(i);continue}let r=await this.knowledgeGraph.mapDependencies({files:[i],direction:"incoming",depth:3});if(r.success)for(let s of r.value.nodes)this.isTestFile(s.path)&&t.add(s.path);let n=this.getBaseName(i),l=[`${n}.test`,`${n}.spec`,`test_${n}`,`${n}_test`];for(let s of l){let c=await this.memory.search(`code-intelligence:kg:node:*${s}*`,10,{namespace:"code-intelligence:kg"});for(let a of c){let o=await this.memory.get(a,{namespace:"code-intelligence:kg"});o?.properties?.path&&this.isTestFile(o.properties.path)&&t.add(o.properties.path)}}}return p(Array.from(t))}catch(t){return d(m(t))}}calculateRiskLevel(e){let t=this.config.riskWeights,i=0,r=Math.min(1,e.directImpact.length/10);i+=r*t.directImpact;let n=Math.min(1,e.transitiveImpact.length/20);i+=n*t.transitiveImpact;let l=e.impactedTests.length>0?Math.max(0,1-e.impactedTests.length/(e.directImpact.length||1)):1;i+=l*t.testCoverage;let s=this.countCriticalFiles([...e.directImpact.map(o=>o.file),...e.transitiveImpact.map(o=>o.file)]),c=Math.min(1,s/5);i+=c*t.criticalPath;let a=this.calculateAverageRiskScore([...e.directImpact,...e.transitiveImpact]);return i+=a*t.dependencyCount,i>=.8?"critical":i>=.6?"high":i>=.4?"medium":i>=.2?"low":"info"}getRecommendations(e){let t=[];(e.riskLevel==="critical"||e.riskLevel==="high")&&t.push("This change has significant impact - consider peer review before merging"),e.impactedTests.length===0&&e.directImpact.length>0?t.push("No tests found for impacted files - add test coverage"):e.impactedTests.length<e.directImpact.length/2&&t.push("Test coverage appears low for impacted files"),e.impactedTests.length>0&&(e.impactedTests.length<=10?t.push(`Run these ${e.impactedTests.length} tests: ${e.impactedTests.slice(0,3).join(", ")}${e.impactedTests.length>3?"...":""}`):t.push(`Run all ${e.impactedTests.length} impacted tests before deployment`));let i=[...e.directImpact,...e.transitiveImpact].filter(n=>this.isCriticalPath(n.file));i.length>0&&t.push(`${i.length} critical path files affected - extra scrutiny recommended`),e.transitiveImpact.length>10&&t.push("Large transitive impact - consider breaking down into smaller changes");let r=[...e.directImpact,...e.transitiveImpact].filter(n=>n.riskScore>=.7);return r.length>0&&t.push(`${r.length} high-risk files impacted: ${r.slice(0,2).map(n=>this.getFileName(n.file)).join(", ")}`),t}async analyzeDirectImpact(e){let t=[];for(let i of e){let r=await this.knowledgeGraph.mapDependencies({files:[i],direction:"incoming",depth:1});if(r.success){let{nodes:n,edges:l}=r.value;for(let s of n){if(s.path===i)continue;let c=l.find(o=>o.target===s.id||o.source===s.id),a=this.calculateFileRiskScore(s.path,s.inDegree,s.outDegree);t.push({file:s.path,reason:`Directly ${c?.type||"depends on"} ${this.getFileName(i)}`,distance:1,riskScore:a})}}}return this.deduplicateImpact(t)}async analyzeTransitiveImpact(e,t,i){let r=[],n=new Set([...e,...t.map(s=>s.file)]),l=t.map(s=>({file:s.file,distance:1}));for(;l.length>0;){let s=l.shift();if(s.distance>=i)continue;let c=await this.knowledgeGraph.mapDependencies({files:[s.file],direction:"incoming",depth:1});if(c.success)for(let a of c.value.nodes){if(n.has(a.path)||a.path===s.file)continue;n.add(a.path);let o=this.calculateFileRiskScore(a.path,a.inDegree,a.outDegree,s.distance+1);r.push({file:a.path,reason:`Transitively depends via ${this.getFileName(s.file)}`,distance:s.distance+1,riskScore:o}),l.push({file:a.path,distance:s.distance+1})}}return this.deduplicateImpact(r)}calculateFileRiskScore(e,t,i,r=1){let n=0;return n+=Math.min(.3,t/20),n+=Math.min(.2,i/30),this.isCriticalPath(e)&&(n+=.3),this.isEntryPoint(e)&&(n+=.2),n=n*Math.pow(.8,r-1),Math.min(1,Math.max(0,n))}calculateAverageRiskScore(e){return e.length===0?0:e.reduce((i,r)=>i+r.riskScore,0)/e.length}countCriticalFiles(e){return e.filter(t=>this.isCriticalPath(t)).length}isTestFile(e){return[/\.test\.[tj]sx?$/,/\.spec\.[tj]sx?$/,/_test\.[tj]sx?$/,/test_.*\.py$/,/.*_test\.py$/,/.*_test\.go$/].some(i=>i.test(e))}isCriticalPath(e){return this.config.criticalPaths.map(i=>i.replace(/\*\*/g,".*").replace(/\*/g,"[^/]*")).some(i=>new RegExp(i).test(e))}isEntryPoint(e){return[/\/index\.[tj]sx?$/,/\/main\.[tj]sx?$/,/\/app\.[tj]sx?$/,/^src\/[^/]+\.[tj]sx?$/,/\/server\.[tj]sx?$/,/\/__init__\.py$/,/\/main\.go$/].some(i=>i.test(e))}getBaseName(e){return this.getFileName(e).replace(/\.[^.]+$/,"")}getFileName(e){return e.split(/[/\\]/).pop()||e}deduplicateImpact(e){let t=new Map;for(let i of e){let r=t.get(i.file);(!r||i.distance<r.distance)&&t.set(i.file,i)}return Array.from(t.values()).sort((i,r)=>r.riskScore!==i.riskScore?r.riskScore-i.riskScore:i.distance-r.distance)}async storeAnalysis(e,t){let i=h();await this.memory.set(`${this.config.namespace}:analysis:${i}`,{id:i,changedFiles:e,analysis:t,timestamp:new Date().toISOString()},{namespace:this.config.namespace,persist:!0})}};export{u as a};
|
|
@@ -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.15.
|
|
2
|
-
import{d as W,f as It}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.15.18");process.exit(0)}
|
|
2
|
+
import{d as W,f as It}from"./chunk-YDI56L35.js";import{a as Y,c as Ct}from"./chunk-ZFT3RLA4.js";import{a as K,b as $,c as V,d as Ae,e as Ot}from"./chunk-MZRBNBB3.js";import{a as Ie,d as x,e as Ce,f as Oe}from"./chunk-MSX2OHYT.js";import{a as U,b as Le,e as Lt}from"./chunk-Z7SD7LXM.js";import{a as Se,b as he,c as Re,d as Rt}from"./chunk-YFILS5D5.js";import{b as I,d as Ne}from"./chunk-MQM37KAR.js";import{a as be,c as ve,d as At}from"./chunk-4QSQKFED.js";import{a as Nt}from"./chunk-O5EWFR76.js";import{c as me}from"./chunk-NKU3FFM4.js";import{a as z,c as X,d as St}from"./chunk-YP2GHQSV.js";import{d as fe,e as ht}from"./chunk-WJN3V7QB.js";import{a as b,e as _e}from"./chunk-AWQAE3SW.js";import{b as h,d as ft}from"./chunk-BDVFSMOQ.js";function Q(n){return ye===null?n:Math.min(n,ye)}var ye,De=h(()=>{"use strict";ye=null});function J(n){let e=n?.code;if(typeof e=="string"&&/^SQLITE_(BUSY|LOCKED)/.test(e))return!0;let t=n instanceof Error?n.message:String(n);return/database is locked|database table is locked|SQLITE_BUSY/i.test(t)}function Z(n,e,t){let s=n.pragma("busy_timeout",{simple:!0});n.pragma(`busy_timeout = ${e}`);try{return t()}finally{try{n.pragma(`busy_timeout = ${s}`)}catch{}}}async function Xe(n,e,t={}){let s=t.waitMs??200,r=t.budgetMs??6e4,c=t.sleep??(d=>new Promise(u=>setTimeout(u,d))),a=t.now??Date.now,T=a(),l=25;for(;;){if(t.shouldContinue&&!t.shouldContinue())throw t.cancelledError?.()??new Error("Cancelled while waiting for a locked database");try{return Z(n,s,e)}catch(d){if(!J(d)||a()-T+l>=r)throw d}await c(l),l=Math.min(l*2,1e3)}}var Wt,Ue=h(()=>{"use strict";Wt=1e3});import{createHash as Fe}from"node:crypto";function vt(n){let e=Buffer.alloc(8);return e.writeBigUInt64LE(BigInt(n)),e}function yt(n){return typeof n=="string"?Buffer.from(n,"utf8"):n instanceof Uint8Array?Buffer.from(n):Buffer.from(ee(n),"utf8")}function ee(n){return n===null||typeof n!="object"?JSON.stringify(n)??"null":Array.isArray(n)?`[${n.map(ee).join(",")}]`:`{${Object.keys(n).sort().map(t=>`${JSON.stringify(t)}:${ee(n[t])}`).join(",")}}`}function Me(...n){let e=Fe("sha256");for(let t of n)e.update(t);return e.digest()}function xe(n,e,t){return Me(bt,n,e,vt(t))}var bt,we,v,Ge=h(()=>{"use strict";bt=Buffer.from("ruvector:chain:"),we=Fe("sha256").update("ruvector-proof-gate-v1").digest();v=class n{seq=0;prev=we;chain=[];payloadHashes=[];admit(e){let t=Me(yt(e)),s=xe(this.prev,t,this.seq);this.prev=s,this.chain.push(s),this.payloadHashes.push(t);let r={sequence:this.seq,payloadHash:t.toString("hex"),chainCommitment:s.toString("hex")};return this.seq+=1,r}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=we;for(let t=0;t<this.chain.length;t++){if(!xe(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 s of e.chain)t.chain.push(Buffer.from(s,"hex"));for(let s of e.payloadHashes)t.payloadHashes.push(Buffer.from(s,"hex"));return t}}});function y(n){if(!te.has(n))throw new Error(`Invalid table name: "${n}" is not in the allowlist`);return n}function Vt(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(!Pe.test(t))throw new Error(`Invalid SQL identifier: "${n}" \u2014 part "${t}" does not match pattern ${Pe}`);return n}var te,Pe,ne=h(()=>{"use strict";te=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"]);Pe=/^[a-z_][a-z0-9_]{0,62}$/});function qe(n){n.exec(ke),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
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.
|
|
2
|
-
import{a as r,e as a}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.15.18");process.exit(0)}
|
|
2
|
+
import{a as r,e as a}from"./chunk-OW23N2Y5.js";a();var e=!1;function n(t){if(!e){for(let i of["ALTER TABLE routing_outcomes ADD COLUMN exploration INTEGER NOT NULL DEFAULT 0","ALTER TABLE routing_outcomes ADD COLUMN criticality REAL","ALTER TABLE routing_outcomes ADD COLUMN q_weight REAL"])try{t.prepare(i).run()}catch(o){if(r(o))throw o}try{t.prepare("CREATE INDEX IF NOT EXISTS idx_routing_outcomes_exploration ON routing_outcomes(exploration)").run()}catch{}e=!0}}export{n as a};
|
|
@@ -1,3 +1,3 @@
|
|
|
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.15.
|
|
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.15.18");process.exit(0)}
|
|
2
2
|
import*as h from"fs";import*as s from"path";import{isCollection as v,isScalar as q,parseDocument as _,visit as A}from"yaml";var m={version:"1",name:"aqe-ci",phases:[{name:"Test Generation",type:"test",enabled:!0,config:{target:".",framework:"vitest",type:"unit"},continueOnFailure:!1,timeout:300},{name:"Coverage Analysis",type:"coverage",enabled:!0,config:{target:".",threshold:80},continueOnFailure:!0,timeout:300},{name:"Security Scan",type:"security",enabled:!0,config:{sast:!0},continueOnFailure:!0,timeout:300},{name:"Quality Gate",type:"quality-gate",enabled:!0,config:{},continueOnFailure:!1,timeout:60}],output:{format:"json",directory:".aqe-ci-output",combinedReport:!0},qualityGate:{enforced:!0,thresholds:{coverage:80,security:"medium",quality:70}}},x=[".aqe-ci.yml",".aqe-ci.yaml","aqe-ci.yml","aqe-ci.yaml"];function R(u=process.cwd()){let f=s.resolve(u);for(let n=0;n<10;n++){for(let r of x){let a=s.join(f,r);if(h.existsSync(a))return a}let i=s.dirname(f);if(i===f)break;f=i}return null}function G(u){if(!h.existsSync(u))return{success:!1,errors:[`Config file not found: ${u}`]};let f;try{f=h.readFileSync(u,"utf-8")}catch(n){return{success:!1,errors:[`Failed to read config: ${n}`]}}return k(f,u)}var w=1e4,I=1e4,b=20,$=new Set(["__proto__","constructor","prototype"]);function g(u){return u!==null&&typeof u=="object"&&!Array.isArray(u)&&(Object.getPrototypeOf(u)===Object.prototype||Object.getPrototypeOf(u)===null)}function P(u){let f=u.split(`
|
|
3
3
|
`);if(f.length>w)throw new Error(`YAML exceeds maximum allowed lines (${w})`);if(f.some(a=>a.length>I))throw new Error(`YAML exceeds maximum line length (${I})`);let n=_(u,{prettyErrors:!1,merge:!0});if(n.errors.length)throw new Error(n.errors.map(a=>a.message).join("; "));A(n,{Collection:(a,l,d)=>{if(d.filter(v).length>=b)throw new Error(`YAML exceeds maximum depth (${b})`)},Pair:(a,l)=>{if(q(l.key)&&$.has(String(l.key.value)))throw new Error(`Unsafe YAML key: ${l.key.value}`)}});let i=n.contents===null?{}:n.toJS({maxAliasCount:100});function r(a,l,d){if(!(a===null||typeof a!="object")){if(l>b)throw new Error(`YAML exceeds maximum depth (${b})`);if(d.has(a))throw new Error("Cyclic YAML aliases are not supported");d.add(a);for(let y of Object.values(a))r(y,l+1,d);d.delete(a)}}if(r(i,0,new Set),!g(i))throw new Error("CI config must be a YAML mapping");return i}function k(u,f){let n;try{n=P(u)}catch(t){return{success:!1,errors:[`Invalid YAML: ${t}`]}}let i=[],r=E();function a(t,e,o,p){let c=t[e];return c===void 0?o:typeof c!="string"||!c.trim()?(i.push(`${p} must be a non-empty string`),o):c}function l(t,e,o,p){let c=t[e];return c===void 0?o:typeof c!="boolean"?(i.push(`${p} must be a boolean`),o):c}if(n.version!==void 0&&(typeof n.version=="number"&&Number.isFinite(n.version)?r.version=String(n.version):r.version=a(n,"version",r.version,"version")),r.name=a(n,"name",r.name,"name"),n.output!==void 0&&(g(n.output)?(r.output.format=a(n.output,"format",r.output.format,"output.format"),r.output.directory=a(n.output,"directory",r.output.directory,"output.directory"),r.output.combinedReport=l(n.output,"combined_report",r.output.combinedReport,"output.combined_report")):i.push("output must be a mapping")),n.quality_gate!==void 0)if(!g(n.quality_gate))i.push("quality_gate must be a mapping");else{let t=n.quality_gate;if(r.qualityGate.enforced=l(t,"enforced",r.qualityGate.enforced,"quality_gate.enforced"),t.thresholds!==void 0)if(!g(t.thresholds))i.push("quality_gate.thresholds must be a mapping");else{for(let e of["coverage","quality"]){let o=t.thresholds[e];o!==void 0&&(typeof o!="number"||!Number.isFinite(o)||o<0||o>100?i.push(`quality_gate.thresholds.${e} must be a finite number between 0 and 100`):r.qualityGate.thresholds[e]=o)}if(t.thresholds.security!==void 0){let e=t.thresholds.security;typeof e!="string"||!["none","low","medium","high"].includes(e)?i.push("quality_gate.thresholds.security must be none, low, medium or high"):r.qualityGate.thresholds.security=e}}}if(n.phases!==void 0)if(r.phases=[],!Array.isArray(n.phases))i.push("phases must be a sequence");else for(let[t,e]of n.phases.entries()){if(!g(e)){i.push(`Phase ${t+1} must be a mapping`);continue}e.name===void 0&&i.push(`Phase ${t+1} must have a name`);let o=a(e,"name","",`Phase ${t+1} name`),p=["test","coverage","security","quality-gate","code-intelligence","custom"];if(!p.includes(e.type)){i.push(`Phase "${o}" has invalid type "${e.type}". Valid: ${p.join(", ")}`);continue}let c=300;e.timeout!==void 0&&(typeof e.timeout!="number"||!Number.isFinite(e.timeout)||e.timeout<=0?i.push(`Phase "${o}" timeout must be a positive finite number`):c=e.timeout),e.config!==void 0&&!g(e.config)&&i.push(`Phase "${o}" config must be a mapping`),r.phases.push({name:o,type:e.type,timeout:c,enabled:l(e,"enabled",!0,`Phase "${o}" enabled`),continueOnFailure:l(e,"continue_on_failure",!1,`Phase "${o}" continue_on_failure`),config:g(e.config)?{...e.config}:{}})}r.phases.length===0&&i.push("Config must have at least one phase");let d=s.resolve(f?s.dirname(f):process.cwd());function y(t){let e=t,o=[];for(;!h.existsSync(e);){let p=s.dirname(e);if(p===e)break;o.unshift(s.basename(e)),e=p}return s.resolve(h.realpathSync(e),...o)}function C(t,e){if(typeof t!="string"||!t.trim()||t.includes("\0")){i.push(`${e} must be a non-empty relative path`);return}let o=s.resolve(d,t),p=s.relative(d,o);if(s.isAbsolute(t)||s.win32.isAbsolute(t)||p===".."||p.startsWith(`..${s.sep}`)||s.isAbsolute(p)){i.push(`${e} must stay inside the project and use a relative path`);return}try{let c=s.relative(y(d),y(o));if(c===".."||c.startsWith(`..${s.sep}`)||s.isAbsolute(c)){i.push(`${e} must stay inside the project (symlink escapes are not allowed)`);return}}catch(c){i.push(`${e} cannot be resolved safely: ${c}`);return}return f?o:t}r.output.directory=C(r.output.directory,"output.directory")??r.output.directory;for(let t of r.phases)if(t.config.target!==void 0){let e=C(t.config.target,`Phase "${t.name}" config.target`);e!==void 0&&(t.config.target=e)}return i.length>0?{success:!1,config:r,errors:i}:{success:!0,config:r,errors:[],configPath:f}}function E(){return{...m,phases:m.phases.map(u=>({...u,config:{...u.config}})),output:{...m.output},qualityGate:{...m.qualityGate,thresholds:{...m.qualityGate.thresholds}}}}export{R as a,G as b,k as c,E as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.
|
|
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.15.18");process.exit(0)}
|
|
2
2
|
import{mkdtempSync as u,readFileSync as d,rmSync as c}from"node:fs";import{tmpdir as p}from"node:os";import{join as s}from"node:path";function a(t,e){if(!e)return;let r;try{r=d(e,"utf-8")}catch(n){if(n.code==="ENOENT")return;throw new Error("Could not read the current Vitest JSON report.")}try{let n=JSON.parse(r);if(!n||!Array.isArray(n.testResults))throw new Error("Invalid report")}catch{throw new Error("The current Vitest JSON report is malformed.")}return r}function y(){let t=u(s(p(),"aqe-vitest-report-")),e=s(t,"report.json"),r=!1;return{path:e,args:[`--outputFile=${e}`],read:n=>a(n,e),cleanup:()=>{if(!r){r=!0;try{c(t,{recursive:!0,force:!0})}catch{}}}}}function h(t){let e=t.some(o=>/(^|[\\/])vitest(\.cmd|\.js|\.mjs)?$/i.test(o)),r=t.some((o,i)=>o==="--reporter=json"||o==="--reporter"&&t[i+1]==="json"),n=t.some(o=>o.startsWith("--outputFile"));return e&&r&&!n}export{y as a,h as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.
|
|
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.15.18");process.exit(0)}
|
|
2
2
|
var i=/[\s\x00-\x1f\x7f]/;function e(t,n="git ref"){if(typeof t!="string"||t.length===0)return`Invalid ${n}: must be a non-empty string`;if(t.length>256)return`Invalid ${n}: longer than 256 characters`;if(t.startsWith("-"))return`Invalid ${n} "${t}": must not start with "-"`;if(i.test(t))return`Invalid ${n}: must not contain whitespace or control characters`}function s(t,n="git ref"){let r=e(t,n);if(r)throw new Error(r)}export{e as a,s as b};
|
|
@@ -1,3 +1,3 @@
|
|
|
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.15.
|
|
2
|
-
import{b as C,d as G}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.15.18");process.exit(0)}
|
|
2
|
+
import{b as C,d as G}from"./chunk-MQM37KAR.js";import{a as R}from"./chunk-JMRDT2XK.js";import{a as x,e as K}from"./chunk-AWQAE3SW.js";import{randomUUID as ne}from"crypto";import*as l from"fs";import*as g from"path";import*as k from"os";import*as P from"fs";var H={"aqe test generate":{domain:"test-generation",action:"generateTests"},"aqe test execute":{domain:"test-execution",action:"execute"},"aqe coverage analyze":{domain:"coverage-analysis",action:"analyze"},"aqe coverage gaps":{domain:"coverage-analysis",action:"detectGaps"},"aqe quality gate":{domain:"quality-assessment",action:"evaluateGate"},"aqe quality assess":{domain:"quality-assessment",action:"analyzeQuality"},"aqe security scan":{domain:"security-compliance",action:"runSASTScan"},"aqe security audit":{domain:"security-compliance",action:"runAudit"},"aqe defect predict":{domain:"defect-intelligence",action:"predictDefects"},"aqe code index":{domain:"code-intelligence",action:"index"},"aqe code impact":{domain:"code-intelligence",action:"analyzeImpact"},"aqe contract validate":{domain:"contract-testing",action:"validateContract"},"aqe chaos test":{domain:"chaos-resilience",action:"runChaosTest"},"aqe requirements validate":{domain:"requirements-validation",action:"validateRequirements"},"aqe visual test":{domain:"visual-accessibility",action:"runVisualTest"},"aqe accessibility test":{domain:"visual-accessibility",action:"runAccessibilityTest"},"aqe learn optimize":{domain:"learning-optimization",action:"optimizeAllStrategies"}},D={daily:"0 0 * * *",weekly:"0 0 * * 0",hourly:"0 * * * *",minutely:"* * * * *"},T=1e4,I=20,O=1e4,X=["__proto__","constructor","prototype"];function _(t){return!X.includes(t)}function B(t){let e=t.split(`
|
|
3
3
|
`);if(e.length>T)throw new Error(`YAML content exceeds maximum allowed lines (${T}). File has ${e.length} lines.`);for(let s=0;s<e.length;s++)if(e[s].length>O)throw new Error(`YAML line ${s+1} exceeds maximum allowed length (${O} characters).`);let i={};for(let s=0;s<e.length;s++){let r=e[s];if(r.trim()===""||r.trim().startsWith("#")||r.search(/\S/)!==0)continue;let c=r.match(/^([\w_-]+):\s*(.+)$/);if(c){let[,a,d]=c;_(a)&&(i[a]=w(d))}}let n=["tags","stages","triggers"];for(let s of n){let r=new RegExp(`^${s}:\\s*$`),o=-1;for(let h=0;h<e.length;h++){let u=e[h];if(!(u.trim()===""||u.trim().startsWith("#"))&&r.test(u.trim())){o=h;break}}if(o===-1)continue;let c=[];i[s]=c;let a=e[o].search(/\S/),d=o+1;for(;d<e.length;){let h=e[d];if(h.trim()===""||h.trim().startsWith("#")){d++;continue}let u=h.search(/\S/),m=h.trim();if(u<=a&&!m.startsWith("-"))break;if(m.startsWith("- ")){let f=m.slice(2).trim();if(!f.includes(":")){c.push(w(f)),d++;continue}let p={},y=f.match(/^([\w_-]+):\s*(.*)$/);if(y){let[,S,v]=y;p[S]=w(v)}let V=u;for(d++;d<e.length;){let S=e[d];if(S.trim()===""||S.trim().startsWith("#")){d++;continue}let v=S.search(/\S/),U=S.trim();if(v<=V)break;let L=U.match(/^([\w_-]+):\s*(.*)$/);if(L){let[,E,F]=L;if(F===""){let M=J(e,d+1,v,1);p[E]=M.value,d=M.nextLine;continue}else p[E]=w(F)}d++}c.push(p)}else d++}}return i}function J(t,e,i,n=0){if(n>I)throw new Error(`YAML nesting exceeds maximum allowed depth (${I}).`);let s={},r=null,o=null,c=e;for(;c<t.length;){let d=t[c];if(d.trim()===""||d.trim().startsWith("#")){c++;continue}let h=d.search(/\S/),u=d.trim();if(h<=i)break;if(u.startsWith("- ")){let f=u.slice(2).trim();o&&!Array.isArray(s[o])&&(s[o]=[]),o?s[o].push(w(f)):(r||(r=[]),r.push(w(f))),c++;continue}let m=u.match(/^([\w_-]+):\s*(.*)$/);if(m){let[,f,p]=m;if(!_(f)){c++;continue}p===""?(o=f,s[f]=[]):(s[f]=w(p),o=null)}c++}if(r&&Object.keys(s).length===0)return{value:r,nextLine:c};let a=Object.keys(s);return a.length===1&&Array.isArray(s[a[0]])?{value:s[a[0]],nextLine:c}:{value:s,nextLine:c}}function w(t){if(t==="")return"";if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t==="true")return!0;if(t==="false")return!1;if(t==="null"||t==="~")return null;let e=Number(t);return!isNaN(e)&&t!==""?e:t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1).split(",").map(n=>w(n.trim())):t}function he(t){let e=[];if(!P.existsSync(t))return{success:!1,errors:[`File not found: ${t}`]};let i;try{i=P.readFileSync(t,"utf-8")}catch(n){return{success:!1,errors:[`Failed to read file: ${n}`]}}return Q(i,t)}function Q(t,e){let i=[],n;try{n=B(t)}catch(o){return{success:!1,errors:[`Invalid YAML syntax: ${o}`]}}if((!n.name||typeof n.name!="string")&&i.push('Pipeline must have a "name" field'),(!n.stages||!Array.isArray(n.stages))&&i.push('Pipeline must have a "stages" array'),i.length>0)return{success:!1,errors:i};let s={name:n.name,description:n.description,version:n.version||"1.0.0",schedule:n.schedule,stages:n.stages.map((o,c)=>{let a=o;return{name:a.name||`stage-${c}`,command:a.command,params:a.params,depends_on:a.depends_on,condition:a.condition,timeout:a.timeout,retry:a.retry,continue_on_failure:a.continue_on_failure}}),triggers:n.triggers,tags:n.tags,timeout:n.timeout};for(let o=0;o<s.stages.length;o++){let c=s.stages[o];c.command||i.push(`Stage ${o+1} (${c.name}) must have a "command" field`)}if(i.length>0)return{success:!1,pipeline:s,errors:i};let r=Z(s,e);return{success:!0,pipeline:s,workflow:r,errors:[]}}function Z(t,e){let i=`pipeline-${t.name.replace(/\s+/g,"-").toLowerCase()}`,n=t.stages.map((r,o)=>{let c=W(r.command),a={};if(r.params)for(let[h,u]of Object.entries(r.params))_(h)&&(a[h]=`input.${h}`);let d={id:`stage-${r.name.replace(/\s+/g,"-").toLowerCase()}`,name:r.name,domain:c.domain,action:c.action,inputMapping:Object.keys(a).length>0?a:void 0,dependsOn:r.depends_on?.map(h=>`stage-${h.replace(/\s+/g,"-").toLowerCase()}`),timeout:r.timeout?r.timeout*1e3:void 0,continueOnFailure:r.continue_on_failure};return r.condition&&(d.condition={path:r.condition.path,operator:r.condition.operator,value:r.condition.value}),r.retry&&(d.retry={maxAttempts:r.retry.max_attempts||3,backoffMs:(r.retry.backoff_seconds||1)*1e3}),d}),s=t.triggers?.map(r=>{let o={eventType:ee(r),sourceDomain:r.source_domain};return r.condition&&(o.condition={path:r.condition.path,operator:r.condition.operator,value:r.condition.value}),o});return{id:i,name:t.name,description:t.description||`Pipeline from ${e||"inline YAML"}`,version:t.version||"1.0.0",steps:n,triggers:s,tags:t.tags,timeout:t.timeout?t.timeout*1e3:void 0}}function W(t){let e=t.trim().replace(/\s+/g," ").toLowerCase();for(let[i,n]of Object.entries(H))if(e.startsWith(i.toLowerCase()))return n;return e.includes("test")&&e.includes("generate")?{domain:"test-generation",action:"generateTests"}:e.includes("test")&&(e.includes("execute")||e.includes("run"))?{domain:"test-execution",action:"execute"}:e.includes("coverage")?{domain:"coverage-analysis",action:"analyze"}:e.includes("quality")||e.includes("gate")?{domain:"quality-assessment",action:"evaluateGate"}:e.includes("security")||e.includes("scan")?{domain:"security-compliance",action:"runSASTScan"}:e.includes("defect")||e.includes("predict")?{domain:"defect-intelligence",action:"predictDefects"}:{domain:"learning-optimization",action:"runLearningCycle"}}function ee(t){let e=t.event.toLowerCase();return e==="push"?"code-intelligence.CodePushed":e==="pull_request"||e==="pr"?"code-intelligence.PullRequestOpened":e==="schedule"?"workflow.ScheduleTrigger":e==="quality_gate"?"quality-assessment.QualityGateEvaluated":e==="test_complete"?"test-execution.TestRunCompleted":e}function fe(t){let e=[],i=[];if(t.name||e.push({path:"name",message:"Pipeline name is required",severity:"error"}),!t.stages||t.stages.length===0)e.push({path:"stages",message:"Pipeline must have at least one stage",severity:"error"});else{let n=new Set;for(let r=0;r<t.stages.length;r++){let o=t.stages[r],c=`stages[${r}]`;if(n.has(o.name)&&e.push({path:`${c}.name`,message:`Duplicate stage name: ${o.name}`,severity:"error"}),n.add(o.name),o.command?W(o.command).domain==="learning-optimization"&&!o.command.toLowerCase().includes("learn")&&i.push({path:`${c}.command`,message:`Command "${o.command}" not recognized, will default to learning-optimization domain`,severity:"warning"}):e.push({path:`${c}.command`,message:"Stage must have a command",severity:"error"}),o.depends_on)for(let a of o.depends_on)t.stages.some(d=>d.name===a)||e.push({path:`${c}.depends_on`,message:`Unknown dependency: ${a}`,severity:"error"});o.timeout!==void 0&&o.timeout<=0&&e.push({path:`${c}.timeout`,message:"Timeout must be a positive number",severity:"error"}),o.retry&&o.retry.max_attempts!==void 0&&o.retry.max_attempts<1&&e.push({path:`${c}.retry.max_attempts`,message:"max_attempts must be at least 1",severity:"error"})}let s=te(t.stages);s&&e.push({path:"stages",message:`Circular dependency detected: ${s}`,severity:"error"})}if(t.schedule&&(A(t.schedule)||e.push({path:"schedule",message:`Invalid cron expression: ${t.schedule}`,severity:"error"})),t.triggers)for(let n=0;n<t.triggers.length;n++){let s=t.triggers[n],r=`triggers[${n}]`;s.event||e.push({path:`${r}.event`,message:"Trigger must have an event type",severity:"error"}),s.source_domain&&!R.includes(s.source_domain)&&i.push({path:`${r}.source_domain`,message:`Unknown domain: ${s.source_domain}`,severity:"warning"})}return{valid:e.length===0,errors:e,warnings:i}}function te(t){let e=new Set,i=new Set,n=(s,r)=>{if(i.has(s))return[...r,s].join(" -> ");if(e.has(s))return null;e.add(s),i.add(s);let o=t.find(c=>c.name===s);if(o?.depends_on)for(let c of o.depends_on){let a=n(c,[...r,s]);if(a)return a}return i.delete(s),null};for(let s of t){let r=n(s.name,[]);if(r)return r}return null}function A(t){return q(t)!==void 0}function q(t){let i=(Object.hasOwn(D,t)?D[t]:t).trim().split(/\s+/);if(i.length!==5)return;let n=[[0,59],[0,23],[1,31],[1,12],[0,7]],s=[/^(\*|[0-5]?\d)(-[0-5]?\d)?(\/\d+)?$/,/^(\*|1?\d|2[0-3])(-\d+)?(\/\d+)?$/,/^(\*|[1-9]|[12]\d|3[01])(-\d+)?(\/\d+)?$/,/^(\*|[1-9]|1[0-2])(-\d+)?(\/\d+)?$/,/^(\*|[0-7])(-[0-7])?(\/\d+)?$/],r=[];for(let o=0;o<i.length;o++){let[c,a]=n[o],d=new Set;for(let h of i[o].split(",")){if(!s[o].test(h))return;let u=/^(\*|\d+)(?:-(\d+))?(?:\/(\d+))?$/.exec(h);if(!u||u[1]==="*"&&u[2]!==void 0)return;let m=u[1]==="*"?c:Number(u[1]),f=u[2]!==void 0?Number(u[2]):u[1]==="*"||u[3]!==void 0?a:m,p=u[3]===void 0?1:Number(u[3]);if(!Number.isSafeInteger(m)||!Number.isSafeInteger(f)||!Number.isSafeInteger(p)||p<=0||m<c||f>a||m>f)return;for(let y=m;y<=f;y+=p)d.add(o===4&&y===7?0:y)}r.push(d)}return{fields:r,wildcardDay:i[2].startsWith("*")||i[4].startsWith("*")}}function me(t){let e={"@daily":"Daily at midnight","@weekly":"Weekly on Sunday at midnight","@hourly":"Every hour","@minutely":"Every minute"};if(e[t])return e[t];if(Object.keys(D).includes(t))return{daily:"Daily at midnight",weekly:"Weekly on Sunday at midnight",hourly:"Every hour",minutely:"Every minute"}[t]||t;let i=t.trim().split(/\s+/);if(i.length!==5)return t;let[n,s,r,o,c]=i;return n==="0"&&s==="0"&&r==="*"&&o==="*"&&c==="*"?"Daily at midnight":n==="0"&&r==="*"&&o==="*"&&c==="*"?`Daily at ${s}:00`:n!=="*"&&s!=="*"&&r==="*"&&o==="*"?`Daily at ${s}:${n.padStart(2,"0")}`:s==="*"&&n==="0"?"Every hour":n!=="*"&&s==="*"?`Every hour at minute ${n}`:t}function b(t,e=new Date){let i=q(t);if(!i)throw new Error(`Invalid cron expression: ${t}`);if(!Number.isFinite(e.getTime()))throw new Error("Invalid schedule start date");let[n,s,r,o,c]=i.fields,a=new Date(Math.floor(e.getTime()/6e4)*6e4+6e4),d=new Date(e);d.setFullYear(e.getFullYear()+400);let h=Number.isFinite(d.getTime())?d.getTime():864e13;for(;Number.isFinite(a.getTime())&&a.getTime()<=h;){let u=r.has(a.getDate()),m=c.has(a.getDay());if(!(o.has(a.getMonth()+1)&&(i.wildcardDay?u&&m:u||m))){a.setHours(24,0,0,0);continue}if(s.has(a.getHours())&&n.has(a.getMinutes()))return a;a=new Date(a.getTime()+6e4)}throw new Error(`No matching cron date within a 400-year Gregorian cycle and the supported Date range: ${t}`)}G();K();var ie=".aqe",se="schedules.json",re="1.0.0",N=5e3,oe=50,Y=10*1024*1024,$=class{schedulesPath;debug;lockFile;initialized=!1;constructor(e={}){e.schedulesPath&&this.validateSchedulesPath(e.schedulesPath),this.schedulesPath=e.schedulesPath??this.getDefaultSchedulesPath(),this.lockFile=`${this.schedulesPath}.lock`,this.debug=e.debug??!1}validateSchedulesPath(e){let i=k.homedir(),n=g.resolve(e),s=g.resolve(i);if(n.startsWith(s+g.sep)||n===s)return;let r=process.cwd(),o=g.resolve(r);if(n.startsWith(o+g.sep)||n===o)return;let c=k.tmpdir(),a=g.resolve(c);if(!(n.startsWith(a+g.sep)||n===a))throw new Error(`Security: Custom schedulesPath must be within home directory (${i}), current working directory (${r}), or temp directory (${c}). Provided path: ${e}`)}getDefaultSchedulesPath(){let e=k.homedir();return g.join(e,ie,se)}async initialize(){if(this.initialized)return;let e=g.dirname(this.schedulesPath);l.existsSync(e)||(l.mkdirSync(e,{recursive:!0}),this.log(`Created directory: ${e}`)),this.initialized=!0}async loadSchedules(){if(await this.initialize(),!l.existsSync(this.schedulesPath))return this.log("Schedules file does not exist, returning empty array"),[];try{let e=l.readFileSync(this.schedulesPath,"utf-8"),{file:i,skipped:n}=this.parseSchedulesFile(e);return n.length>0&&console.warn(`[PersistentScheduler] Skipped ${n.length} malformed schedule entries in ${this.schedulesPath} (not an object, no id, or duplicate id)`),this.log(`Loaded ${i.schedules.length} schedules`),i.schedules}catch(e){return await this.handleCorruptFile(e),[]}}async saveSchedule(e){await this.initialize(),await this.withFileLock(async()=>{let{schedules:i,skipped:n}=this.loadForWrite(),s=i.findIndex(r=>r.id===e.id);s>=0?(i[s]=e,this.log(`Updated schedule: ${e.id}`)):(i.push(e),this.log(`Added schedule: ${e.id}`)),await this.writeSchedules(i,n)})}async removeSchedule(e){await this.initialize(),await this.withFileLock(async()=>{let{schedules:i,skipped:n}=this.loadForWrite(),s=i.filter(r=>r.id!==e);if(s.length===i.length){this.log(`Schedule not found: ${e}`);return}await this.writeSchedules(s,n),this.log(`Removed schedule: ${e}`)})}async getSchedules(){return this.loadSchedules()}async getSchedule(e){return(await this.loadSchedules()).find(n=>n.id===e)}async getDueSchedules(){let e=await this.loadSchedules(),i=new Date;return e.filter(n=>n.enabled?new Date(n.nextRun)<=i:!1)}async markExecuted(e){await this.initialize(),await this.withFileLock(async()=>{let{schedules:i,skipped:n}=this.loadForWrite(),s=i.find(o=>o.id===e);if(!s)throw new Error(`Schedule not found: ${e}`);let r=new Date;s.lastRun=r.toISOString(),s.disabledReason||(s.nextRun=b(s.schedule,r).toISOString()),await this.writeSchedules(i,n),this.log(`Marked executed: ${e}, next run: ${s.nextRun}`)})}async setEnabled(e,i){await this.initialize(),await this.withFileLock(async()=>{let{schedules:n,skipped:s}=this.loadForWrite(),r=n.find(o=>o.id===e);if(!r)throw new Error(`Schedule not found: ${e}`);if(i&&r.disabledReason)throw new Error(`Cannot enable schedule ${e}: ${r.disabledReason}`);r.enabled=i,i&&(r.nextRun=b(r.schedule,new Date).toISOString()),await this.writeSchedules(n,s),this.log(`Set enabled=${i}: ${e}`)})}async getEnabledSchedules(){return(await this.loadSchedules()).filter(i=>i.enabled)}async getSchedulesByWorkflow(e){return(await this.loadSchedules()).filter(n=>n.workflowId===e)}async clearAll(){await this.initialize(),await this.withFileLock(async()=>{let{skipped:e}=this.loadForWrite();await this.writeSchedules([],e),this.log("Cleared all schedules")})}async getStats(){let e=await this.loadSchedules(),i=new Date;return{total:e.length,enabled:e.filter(n=>n.enabled).length,disabled:e.filter(n=>!n.enabled).length,due:e.filter(n=>n.enabled&&new Date(n.nextRun)<=i).length}}loadForWrite(){if(!l.existsSync(this.schedulesPath))return{schedules:[],skipped:[]};try{let e=l.readFileSync(this.schedulesPath,"utf-8"),{file:i,skipped:n}=this.parseSchedulesFile(e);return{schedules:i.schedules,skipped:n}}catch(e){return this.backupCorruptFile(e),{schedules:[],skipped:[]}}}parseSchedulesFile(e){let i=Buffer.byteLength(e,"utf-8");if(i>Y)throw new Error(`Schedules file exceeds maximum allowed size (${Y/(1024*1024)}MB). File is ${(i/(1024*1024)).toFixed(2)}MB.`);let n=C(e);if(!z(n)||!Array.isArray(n.schedules))throw new Error("Invalid schedules file: missing schedules array");let s=[],r=[],o=new Set;for(let c of n.schedules){if(!z(c)||typeof c.id!="string"||c.id.length===0||o.has(c.id)){r.push(c);continue}let a=c;o.add(a.id);let d=ae(c);d?(a.disabledReason=d,a.enabled&&console.warn(`[PersistentScheduler] Disabled schedule ${a.id}: ${d}`),a.enabled=!1):delete a.disabledReason,s.push(a)}return{file:{...n,schedules:s},skipped:r}}async writeSchedules(e,i=[]){if(i.length>0){let r=`${this.schedulesPath}.quarantine.${Date.now()}.json`;l.writeFileSync(r,JSON.stringify({quarantinedAt:new Date().toISOString(),reason:"Malformed schedule entries (not an object, no id, or duplicate id)",entries:i},null,2),{encoding:"utf-8",flag:"wx"}),console.warn(`[PersistentScheduler] Moved ${i.length} malformed schedule entries to ${r}`)}let n={version:re,updatedAt:new Date().toISOString(),schedules:e},s=JSON.stringify(n,null,2);l.writeFileSync(this.schedulesPath,s,"utf-8"),this.log(`Wrote ${e.length} schedules to disk`)}async handleCorruptFile(e){let i=x(e);this.log(`Corrupt schedules file detected: ${i}`),this.backupCorruptFile(e);try{l.existsSync(this.schedulesPath)&&(l.unlinkSync(this.schedulesPath),this.log("Removed corrupt schedules file"))}catch(n){this.log(`Failed to remove corrupt file: ${n}`)}}backupCorruptFile(e){this.log(`Corrupt schedules file detected: ${x(e)}`);let i=`${this.schedulesPath}.corrupt.${Date.now()}`;try{l.existsSync(this.schedulesPath)&&(l.copyFileSync(this.schedulesPath,i,l.constants.COPYFILE_EXCL),this.log(`Backed up corrupt file to: ${i}`))}catch(n){this.log(`Failed to backup corrupt file: ${n}`)}}async withFileLock(e){await this.acquireLock();try{return await e()}finally{this.releaseLock()}}async acquireLock(){let e=Date.now();for(;l.existsSync(this.lockFile);){try{let i=l.statSync(this.lockFile);if(Date.now()-i.mtimeMs>N){l.unlinkSync(this.lockFile),this.log("Removed stale lock file");break}}catch{break}if(Date.now()-e>N)throw new Error("Timeout waiting for scheduler lock");await this.sleep(oe)}try{l.writeFileSync(this.lockFile,`${process.pid}:${Date.now()}`,{flag:"wx"})}catch(i){if(i.code==="EEXIST")return this.acquireLock();throw i}}releaseLock(){try{l.existsSync(this.lockFile)&&l.unlinkSync(this.lockFile)}catch(e){console.debug("[PersistentScheduler] Lock release error:",e instanceof Error?e.message:e)}}sleep(e){return new Promise(i=>setTimeout(i,e))}log(e){this.debug&&console.log(`[PersistentScheduler] ${e}`)}};function z(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ae(t){if(!Object.prototype.hasOwnProperty.call(t,"schedule"))return"Missing cron expression (no schedule field)";if(typeof t.schedule!="string"||!A(t.schedule))return`Invalid cron expression: ${String(t.schedule)}`;if(typeof t.workflowId!="string"||t.workflowId.length===0)return"Missing workflowId"}function ce(t={}){return new $(t)}function j(){let t=Date.now().toString(36),e=ne().slice(0,8);return`sched-${t}-${e}`}function de(t){let e=new Date;return{id:j(),workflowId:t.workflowId,pipelinePath:t.pipelinePath,schedule:t.schedule,scheduleDescription:t.scheduleDescription,nextRun:b(t.schedule,e).toISOString(),enabled:t.enabled??!0,createdAt:e.toISOString()}}export{he as a,fe as b,me as c,$ as d,ce as e,j as f,de as g};
|
|
@@ -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.15.
|
|
2
|
-
import{b as m,d as $}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.15.18");process.exit(0)}
|
|
2
|
+
import{b as m,d as $}from"./chunk-KH4T6STG.js";import{b as A}from"./chunk-BDVFSMOQ.js";function T(n){let i=Buffer.from(n,"base64").toString("latin1");return i.includes(":")&&/^[\x20-\x7e]+$/.test(i)}function _(n){return/^[A-Z]?[a-z]+\.?$/.test(n)&&n.replace(/\.$/,"").length<=16}function x(n){let i=new RegExp(b.source,b.flags),t="",r=0;for(let e=i.exec(n);e!==null;e=i.exec(n)){let[s,o="",a,u,S,f]=e,l=a??u,d=e.index+s.length-f.length;if(!D(l)){i.lastIndex=d+1;continue}let E=f==="{"||f==="["?C(n,d,o.length===2):f.length===2&&f[0]==="\\"?k(n,d+2,f):e.index+s.length;t+=`${n.slice(r,e.index)}${o}${l}${o}${S}${o}<REDACTED:sensitive-key>${o}`,r=E,i.lastIndex=E}return r===0?n:t+n.slice(r)}function k(n,i,t){let r=!1;for(let e=i;e<n.length;e++){let s=n[e]==="\\";s&&e++;let o=n[e];if(o===`
|
|
3
3
|
`||o===void 0)return e;if(r)r=!1;else if(s&&o==="\\")r=!0;else if(s&&o===t[1])return e+1}return n.length}function C(n,i,t){let r=0;for(let e=i;e<n.length;e++){let s=n[e];if(t&&s==="\\"&&(n[e+1]==='"'||n[e+1]==="'"))e=k(n,e+2,n.slice(e,e+2))-1;else if(!t&&(s==='"'||s==="'"))for(e++;e<n.length&&n[e]!==s&&n[e]!==`
|
|
4
4
|
`;e++)n[e]==="\\"&&e++;else if(s==="{"||s==="[")r++;else if((s==="}"||s==="]")&&--r===0)return e+1}return n.length}function D(n){let i=n.toLowerCase().replace(/[^a-z0-9]/g,"");return w.has(i)||z.some(t=>i.endsWith(t))}function c(n,i=y.maxStringLength){if(typeof n!="string")return I(n);if(n.length>L)return`[REDACTED:size-limit ${n.length} chars]`;let t=n;for(let[r,e]of O)t=t.replace(r,e);return t=x(t),t=m(t,"balanced").text,t.length>i?`${t.slice(0,i)}\u2026[truncated ${t.length-i} chars]`:t}function p(n,i={}){return g(n,{...y,...i},0,[])}function I(n){try{if(n instanceof Error){let i=h(n),t=n.cause;for(let r=0;t!==void 0&&r<3;r++)i+=`
|
|
5
5
|
Caused by: ${t instanceof Error?h(t):JSON.stringify(p(t,{maxDepth:3}))}`,t=t instanceof Error?t.cause:void 0;return i}return typeof n=="string"?c(n):JSON.stringify(p(n,{maxDepth:3}))??String(n)}catch{return"[REDACTED:sanitization-failed]"}}function R(n){let i={};for(let t of N){let r=Object.getOwnPropertyDescriptor(n,t)??(t==="name"?{value:n.name}:void 0),e=r&&"value"in r?r.value:void 0;typeof e=="string"?i[t]=c(e,j):typeof e=="number"&&Number.isFinite(e)&&(i[t]=e)}return i}function h(n){let i=c(n.stack||`${n.name}: ${n.message}`),t=R(n),r=Object.keys(t);return r.length===0||r.length===1&&i.startsWith(`${t.name}`)?i:`${i} ${JSON.stringify(t)}`}function g(n,i,t,r){try{if(n==null||typeof n=="number"||typeof n=="boolean")return n;if(typeof n=="string")return c(n,i.maxStringLength);if(typeof n=="bigint"||typeof n=="symbol")return n.toString();if(typeof n=="function")return"[function]";let e=n;if(r.includes(e))return"[circular]";if(t>=i.maxDepth)return"[object]";if(ArrayBuffer.isView(e))return`[binary ${e.byteLength} bytes]`;if(e instanceof ArrayBuffer)return`[binary ${e.byteLength} bytes]`;if(e instanceof Date)return Number.isNaN(e.getTime())?"[invalid date]":e.toISOString();if(e instanceof Map||e instanceof Set)return`[${e.constructor.name}(${e.size})]`;let s=[...r,e];if(Array.isArray(e)){let o=e.slice(0,i.maxEntries).map(a=>g(a,i,t+1,s));return e.length>i.maxEntries&&o.push(`[+${e.length-i.maxEntries} more]`),o}return e instanceof Error?F(e,i,t,s):Z(e,Object.keys(e),i,t,s)}catch{return"[REDACTED:sanitization-failed]"}}function F(n,i,t,r){let e={name:c(String(n.name),i.maxStringLength),message:c(String(n.message),i.maxStringLength)};typeof n.stack=="string"&&(e.stack=c(n.stack,i.maxStringLength));let{code:s,status:o}=R(n);s!==void 0&&(e.code=s),o!==void 0&&(e.status=o);let a=n.cause;return a!==void 0&&(e.cause=g(a,i,t+1,r)),e}function Z(n,i,t,r,e){let s={};for(let o of i.slice(0,t.maxEntries)){let a=Object.getOwnPropertyDescriptor(n,o);if(!a)continue;if(!("value"in a)){s[o]="[getter]";continue}let u=a.value;if(D(o)&&u!==null&&u!==void 0&&typeof u!="boolean"){s[o]="[REDACTED:sensitive-key]";continue}s[o]=g(u,t,r+1,e)}return i.length>t.maxEntries&&(s["[truncated]"]=`${i.length-t.maxEntries} more keys`),s}var y,L,w,z,O,b,N,j,B=A(()=>{"use strict";$();y={maxDepth:6,maxEntries:100,maxStringLength:8192},L=1e6,w=new Set(["auth","dsn","pwd","proxyauthorization","setcookie","sessionid"]),z=["token","secret","password","passwd","passphrase","apikey","privatekey","accesskey","secretkey","credential","credentials","cookie","authorization","sessionid","connectionstring"];O=[[/(:\/\/)[^\s/@:"']*:[^\s/@"']+@/g,"$1<REDACTED:credentials>@"],[/\b(authorization:\s*Basic)\s+[^\s"']+/gi,"$1 <REDACTED:credential>"],[/\b(Basic)\s+([A-Za-z0-9+/]{8,}={0,2})(?![A-Za-z0-9._~+/=-])/gi,(n,i,t)=>T(t)?`${i} <REDACTED:credential>`:n],[/\b(authorization:\s*Bearer)\s+[^\s"']+/gi,"$1 <REDACTED:credential>"],[/\b(Bearer)\s+([A-Za-z0-9._~+/=-]{8,})/gi,(n,i,t)=>_(t)?n:`${i} <REDACTED:credential>`],[/\bsk-(?:ant-|proj-)?[A-Za-z0-9_-]{16,}/g,"<REDACTED:api_key>"],[/\b(set-cookie|cookie):\s*[^\n]+/gi,"$1: <REDACTED:cookie>"],[/\b([A-Za-z0-9_-]{0,64}?[_-](?:token|secret|password|passwd))=([^\s&"'#]+)/gi,"$1=<REDACTED:credential>"]],b=/(?:(\\?["'])([A-Za-z0-9_.-]{1,64})\1|(?<![A-Za-z0-9_.$-])([A-Za-z_$][A-Za-z0-9_.$-]{0,63}))(\s*:\s*)("(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|\\["']|-?\d[\d.eE+-]*|[{[])/g;N=["name","code","status"],j=200});export{c as a,p as b,I as c,B as d};
|