agentic-qe 3.12.2 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/helpers/.helpers-version +1 -1
- package/.claude/helpers/auto-memory-hook.mjs +430 -430
- package/.claude/helpers/helpers.manifest.json +6 -5
- package/.claude/helpers/hook-handler.cjs +565 -311
- package/.claude/helpers/intelligence.cjs +1058 -1058
- package/.claude/helpers/statusline.cjs +995 -682
- package/.claude/skills/qe-court/SKILL.md +186 -0
- package/.claude/skills/qe-court/config.json +27 -0
- package/.claude/skills/qe-court/evals/fixtures/seeded-mutant-delivery/README.md +38 -0
- package/.claude/skills/qe-court/evals/fixtures/seeded-mutant-delivery/budget.test.ts +21 -0
- package/.claude/skills/qe-court/evals/fixtures/seeded-mutant-delivery/budget.ts +25 -0
- package/.claude/skills/qe-court/evals/qe-court.yaml +70 -0
- package/.claude/skills/qe-court/schemas/output.json +92 -0
- package/.claude/skills/qe-court/scripts/validate-config.json +30 -0
- package/.claude/skills/skills-manifest.json +9 -8
- package/CHANGELOG.md +104 -0
- package/README.md +3 -3
- package/assets/skills/qe-court/SKILL.md +186 -0
- package/assets/skills/qe-court/config.json +27 -0
- package/assets/skills/qe-court/evals/fixtures/seeded-mutant-delivery/README.md +38 -0
- package/assets/skills/qe-court/evals/fixtures/seeded-mutant-delivery/budget.test.ts +21 -0
- package/assets/skills/qe-court/evals/fixtures/seeded-mutant-delivery/budget.ts +25 -0
- package/assets/skills/qe-court/evals/qe-court.yaml +70 -0
- package/assets/skills/qe-court/schemas/output.json +92 -0
- package/assets/skills/qe-court/scripts/validate-config.json +30 -0
- package/assets/skills/skills-manifest.json +9 -8
- package/dist/cli/bundle.js +5 -5
- package/dist/cli/chunks/adapter-CWIMFWAI.js +2 -0
- package/dist/cli/chunks/{agent-booster-wasm-3KYNICBC.js → agent-booster-wasm-ACX2DK7Y.js} +2 -2
- package/dist/cli/chunks/{agent-handler-NGPTMI6E.js → agent-handler-B45WP4ZJ.js} +2 -2
- package/dist/cli/chunks/{agent-memory-branch-GNTQKQMG.js → agent-memory-branch-QQLZDE56.js} +2 -2
- package/dist/cli/chunks/aqe-learning-engine-OTXT2DLN.js +2 -0
- package/dist/cli/chunks/{arena-HQEP2NWI.js → arena-G3IKZAG5.js} +4 -4
- package/dist/cli/chunks/{arena-PA7VIYD4.js → arena-SDB7723R.js} +2 -2
- package/dist/cli/chunks/{audit-XSDM57GC.js → audit-GY46XUZA.js} +3 -3
- package/dist/cli/chunks/base-O3SPSWBA.js +2 -0
- package/dist/cli/chunks/{hnswlib-node-BCASOCNU.js → better-sqlite3-DUZ6FFAH.js} +2 -2
- package/dist/cli/chunks/brain-handler-347CYMPN.js +89 -0
- package/dist/cli/chunks/{branch-enumerator-ZW7RNMUF.js → branch-enumerator-Z3ULBFSM.js} +2 -2
- package/dist/cli/chunks/{browser-4LU22CPP.js → browser-OYEIHD7F.js} +2 -2
- package/dist/cli/chunks/browser-workflow-MXS3ZKY2.js +2 -0
- package/dist/cli/chunks/{chunk-CKFZOPZN.js → chunk-2DIT5AUU.js} +2 -2
- package/dist/cli/chunks/{chunk-RXH2TC2K.js → chunk-2NRZYQSF.js} +2 -2
- package/dist/cli/chunks/chunk-2VQVEQS4.js +153 -0
- package/dist/cli/chunks/{chunk-KDGLNJPB.js → chunk-32ZGV4Q4.js} +1 -1
- package/dist/cli/chunks/{chunk-327YEKBU.js → chunk-34PEINFS.js} +2 -2
- package/dist/cli/chunks/{chunk-CTFW7CMI.js → chunk-3GSYD5SL.js} +2 -2
- package/dist/cli/chunks/{chunk-YRO7HNS4.js → chunk-3JVUWKCO.js} +2 -2
- package/dist/cli/chunks/{chunk-TERRRQVY.js → chunk-3K4SF57Q.js} +1 -1
- package/dist/cli/chunks/{chunk-6N62KS3C.js → chunk-3NOCK6ED.js} +2 -2
- package/dist/cli/chunks/{chunk-7DV42KFP.js → chunk-3UHEZ5HZ.js} +2 -2
- package/dist/cli/chunks/{chunk-N57BKUVE.js → chunk-4BDLD7V2.js} +1 -1
- package/dist/cli/chunks/{chunk-5SM57X4D.js → chunk-4BESADKE.js} +2 -2
- package/dist/cli/chunks/{chunk-GCQATSMK.js → chunk-54MFKCLT.js} +2 -2
- package/dist/cli/chunks/{chunk-GUGUYFU5.js → chunk-56WZFXTQ.js} +2 -2
- package/dist/cli/chunks/{chunk-OELLHV7S.js → chunk-5EIOQCGN.js} +2 -2
- package/dist/cli/chunks/{chunk-Z63IOTDW.js → chunk-5FLTZ3KT.js} +2 -2
- package/dist/cli/chunks/{chunk-EKTWIEEO.js → chunk-5ICQL42E.js} +2 -2
- package/dist/cli/chunks/{chunk-VQU2JXTK.js → chunk-5KAT6WBQ.js} +2 -2
- package/dist/cli/chunks/{chunk-VHYACXLN.js → chunk-6AOBLBR4.js} +2 -2
- package/dist/cli/chunks/{chunk-Z3FA5KR6.js → chunk-6DTOGSDV.js} +4 -4
- package/dist/cli/chunks/{chunk-SYLTJKN2.js → chunk-6SXKCIN5.js} +2 -2
- package/dist/cli/chunks/{chunk-MF4FULAI.js → chunk-7DMXCCSD.js} +1 -1
- package/dist/cli/chunks/{chunk-BOR5MME3.js → chunk-7UNY32PU.js} +1 -1
- package/dist/cli/chunks/{chunk-T6TQPF5P.js → chunk-7YXT6BXN.js} +3 -3
- package/dist/cli/chunks/{chunk-ADZTWGEB.js → chunk-A4QLGPYO.js} +2 -2
- package/dist/cli/chunks/{chunk-RFQIC6ZF.js → chunk-A7GLWWSE.js} +1 -1
- package/dist/cli/chunks/{chunk-WC5PM33J.js → chunk-ANIDFJCT.js} +3 -3
- package/dist/cli/chunks/{chunk-TFVWUR2U.js → chunk-ANYYTWOQ.js} +2 -2
- package/dist/cli/chunks/{chunk-YZ44FUVJ.js → chunk-AO7AHX6K.js} +2 -2
- package/dist/cli/chunks/{chunk-PHIEJAQK.js → chunk-BCKTBGDM.js} +3 -3
- package/dist/cli/chunks/{chunk-GECWGFRR.js → chunk-BGYLNCL6.js} +2 -2
- package/dist/cli/chunks/{chunk-PXKVW6PT.js → chunk-BOVH6WSM.js} +2 -2
- package/dist/cli/chunks/{chunk-P65S7AZA.js → chunk-BUGWPTMF.js} +2 -2
- package/dist/cli/chunks/{chunk-RXEQB4OT.js → chunk-CFVEDUTW.js} +2 -2
- package/dist/cli/chunks/{chunk-HNU32LN3.js → chunk-CPH5JP4L.js} +1 -1
- package/dist/cli/chunks/{chunk-LIAW5FD7.js → chunk-CQFT7H3F.js} +2 -2
- package/dist/cli/chunks/{chunk-WY5CX3VH.js → chunk-CWUBOLKY.js} +2 -2
- package/dist/cli/chunks/{chunk-X47GHZY3.js → chunk-CYL2FV23.js} +2 -2
- package/dist/cli/chunks/{chunk-W7LBT3BF.js → chunk-D3MPV5G7.js} +2 -2
- package/dist/cli/chunks/{chunk-7KMYBRKJ.js → chunk-DRIJYTSK.js} +2 -2
- package/dist/cli/chunks/{chunk-BDVOXGY5.js → chunk-DYUC7WFA.js} +1 -1
- package/dist/cli/chunks/{chunk-ZBYMF2QJ.js → chunk-E3B5XTXJ.js} +1 -1
- package/dist/cli/chunks/{chunk-TMQ3S7HR.js → chunk-EECM5XKY.js} +1 -1
- package/dist/cli/chunks/{chunk-7OD6HFCP.js → chunk-EFRESRLB.js} +3 -3
- package/dist/cli/chunks/{chunk-HU6ETNA7.js → chunk-ES7WCYOU.js} +1 -1
- package/dist/cli/chunks/chunk-FAQLI3P5.js +2 -0
- package/dist/cli/chunks/{chunk-K43YXI7C.js → chunk-FBBZHATF.js} +2 -2
- package/dist/cli/chunks/{chunk-2R7J4ZGT.js → chunk-FL3BM54K.js} +1 -1
- package/dist/cli/chunks/{chunk-KBXW7S3W.js → chunk-FQLWQWRU.js} +3 -3
- package/dist/cli/chunks/{chunk-LWVUNBZO.js → chunk-FQY3UTGA.js} +2 -2
- package/dist/cli/chunks/{chunk-2L7K2J2T.js → chunk-FUU32QY5.js} +2 -2
- package/dist/cli/chunks/{chunk-3LELACAQ.js → chunk-G4GTE3RJ.js} +2 -2
- package/dist/cli/chunks/{chunk-APVXTHTA.js → chunk-G5DFYX3J.js} +3 -3
- package/dist/cli/chunks/chunk-G7FMYFTN.js +2 -0
- package/dist/cli/chunks/{chunk-CMKCPRWX.js → chunk-GFBLWFRV.js} +1 -1
- package/dist/cli/chunks/{chunk-5YLY2WT2.js → chunk-GJMZR7WU.js} +3 -3
- package/dist/cli/chunks/{chunk-R6LDR3IO.js → chunk-GTUFX7AR.js} +2 -2
- package/dist/cli/chunks/{chunk-5CGTBAVF.js → chunk-GUEZQOHL.js} +1 -1
- package/dist/cli/chunks/{chunk-DGOZ3CGB.js → chunk-HL2QMM4M.js} +2 -2
- package/dist/cli/chunks/{chunk-VOHYQ6MX.js → chunk-HOKON5EL.js} +2 -2
- package/dist/cli/chunks/{chunk-DTXHRALB.js → chunk-HTPM3URI.js} +2 -2
- package/dist/cli/chunks/chunk-HVB2L52I.js +2 -0
- package/dist/cli/chunks/{chunk-GP7IXYOY.js → chunk-IHQTXJAQ.js} +1 -1
- package/dist/cli/chunks/{chunk-LOZAUP6L.js → chunk-IPHLXAMX.js} +2 -2
- package/dist/cli/chunks/{chunk-56MXYSYY.js → chunk-IYDYJ33J.js} +2 -2
- package/dist/cli/chunks/{chunk-QYST2TZW.js → chunk-IZRLIWFN.js} +2 -2
- package/dist/cli/chunks/{chunk-XNNYHQLW.js → chunk-J3L52EA4.js} +5 -5
- package/dist/cli/chunks/{chunk-P2FYRAC5.js → chunk-JGM6XCCP.js} +1 -1
- package/dist/cli/chunks/chunk-JPIBPKBP.js +54 -0
- package/dist/cli/chunks/{chunk-ILNQPPKB.js → chunk-K5N6SLHO.js} +1 -1
- package/dist/cli/chunks/{chunk-UEIIIDBJ.js → chunk-KSYLRM4Q.js} +2 -2
- package/dist/cli/chunks/{chunk-TRHUH24V.js → chunk-KUA4HHU6.js} +2 -2
- package/dist/cli/chunks/{chunk-OEZNUXY7.js → chunk-KVL63BSU.js} +1 -1
- package/dist/cli/chunks/{chunk-WMNGPIP3.js → chunk-KZTBNDNE.js} +1 -1
- package/dist/cli/chunks/{chunk-OSAPKOGN.js → chunk-L2SFGFE6.js} +1 -1
- package/dist/cli/chunks/{chunk-IQ56KMMH.js → chunk-L4LLA5U7.js} +1 -1
- package/dist/cli/chunks/{chunk-KBAXD6PH.js → chunk-L4S722JD.js} +1 -1
- package/dist/cli/chunks/{chunk-C7VNQ4PY.js → chunk-LBE2P6UC.js} +2 -2
- package/dist/cli/chunks/{chunk-KNOO6TFO.js → chunk-LOXVVMS4.js} +3 -3
- package/dist/cli/chunks/{chunk-B7DI76SY.js → chunk-LWYLW7RX.js} +2 -2
- package/dist/cli/chunks/{chunk-6SWR2BN7.js → chunk-LXPB7H2P.js} +1 -1
- package/dist/cli/chunks/{chunk-LGEPR7MH.js → chunk-MBCGI3M2.js} +3 -3
- package/dist/cli/chunks/{chunk-WL5VMIO4.js → chunk-MVI2QMRW.js} +1 -1
- package/dist/cli/chunks/{chunk-OIUIVV2N.js → chunk-N5MMBA35.js} +1 -1
- package/dist/cli/chunks/{chunk-TQNNKW7K.js → chunk-N7VOOI3U.js} +2 -2
- package/dist/cli/chunks/{chunk-BPSEFLJ6.js → chunk-NETN3OUG.js} +1 -1
- package/dist/cli/chunks/chunk-NQNKKVNO.js +29 -0
- package/dist/cli/chunks/{chunk-ACDZ2CRV.js → chunk-NUQBJGGF.js} +2 -2
- package/dist/cli/chunks/chunk-OETDMOOE.js +2 -0
- package/dist/cli/chunks/{chunk-R5HC6JVJ.js → chunk-OXXMVQDF.js} +2 -2
- package/dist/cli/chunks/{chunk-J6EFAKDQ.js → chunk-OZR25R7W.js} +2 -2
- package/dist/cli/chunks/{chunk-ZL7ZOIHO.js → chunk-PERJO2DY.js} +1 -1
- package/dist/cli/chunks/{chunk-WKWIUS5G.js → chunk-PP2RYSHT.js} +3 -3
- package/dist/cli/chunks/{chunk-WE5QHYL7.js → chunk-Q7PBGNUD.js} +1 -1
- package/dist/cli/chunks/{chunk-E5XWCGSX.js → chunk-QCEW4ZDW.js} +2 -2
- package/dist/cli/chunks/{chunk-EGU54SNK.js → chunk-QI4CGJNK.js} +1 -1
- package/dist/cli/chunks/{chunk-MNNNA57O.js → chunk-QQB55ZJJ.js} +2 -2
- package/dist/cli/chunks/{chunk-KV5OZ6T3.js → chunk-QTU3CVOB.js} +2 -2
- package/dist/cli/chunks/{chunk-M4XVEUUM.js → chunk-QWYISZTN.js} +2 -2
- package/dist/cli/chunks/{chunk-OMIGKGJJ.js → chunk-R3GEXYO4.js} +2 -2
- package/dist/cli/chunks/{chunk-4KEOBDEI.js → chunk-RDU4WTV2.js} +2 -2
- package/dist/cli/chunks/{chunk-3AJUJAUJ.js → chunk-RJZRWVL4.js} +1 -1
- package/dist/cli/chunks/{chunk-UFPCNUJA.js → chunk-RLCWR7TS.js} +10 -10
- package/dist/cli/chunks/{chunk-FTG4ZVTX.js → chunk-RSFIOR2I.js} +10 -10
- package/dist/cli/chunks/{chunk-FKUH33L3.js → chunk-RVJPWRV6.js} +2 -2
- package/dist/cli/chunks/{chunk-AMPYON7M.js → chunk-RVRBTOWX.js} +2 -2
- package/dist/cli/chunks/{chunk-AJ6DZXKK.js → chunk-SHCTEXNH.js} +2 -2
- package/dist/cli/chunks/chunk-SNTUKW4Q.js +2 -0
- package/dist/cli/chunks/{chunk-F3CKOVZM.js → chunk-SRQ3CPJE.js} +6 -6
- package/dist/cli/chunks/{chunk-V2QYW5KW.js → chunk-THBTN7XB.js} +2 -2
- package/dist/cli/chunks/{chunk-6FBXYS6X.js → chunk-TNRIGQ6U.js} +2 -2
- package/dist/cli/chunks/{chunk-UF3YOGHV.js → chunk-TVMFH5N2.js} +2 -2
- package/dist/cli/chunks/{chunk-FUBN5GPY.js → chunk-TZ73SXQ5.js} +1 -1
- package/dist/cli/chunks/chunk-TZPKTRJB.js +9 -0
- package/dist/cli/chunks/{chunk-IKIKIHFQ.js → chunk-U2SW6KK5.js} +2 -2
- package/dist/cli/chunks/{chunk-ZHWXI4SK.js → chunk-UIPPJKON.js} +2 -2
- package/dist/cli/chunks/{chunk-MNHGBG4D.js → chunk-UMG5URNV.js} +1 -1
- package/dist/cli/chunks/{chunk-YYV3FYVB.js → chunk-UNIBND6A.js} +1 -1
- package/dist/cli/chunks/{chunk-HH5Y4NCR.js → chunk-USMDIIHY.js} +2 -2
- package/dist/cli/chunks/{chunk-TLYZPOA7.js → chunk-VC6EXDGY.js} +2 -2
- package/dist/cli/chunks/{chunk-BMRR3MBR.js → chunk-VHYMSZNF.js} +2 -2
- package/dist/cli/chunks/{chunk-SVUWAV6Y.js → chunk-VLBV2VL3.js} +1 -1
- package/dist/cli/chunks/{chunk-BDX54WJV.js → chunk-VLNPJAVH.js} +1 -1
- package/dist/cli/chunks/{chunk-R554WVIG.js → chunk-VSNRPMAZ.js} +2 -2
- package/dist/cli/chunks/{chunk-AL5QT6OX.js → chunk-W5YEIHIO.js} +2 -2
- package/dist/cli/chunks/{chunk-NDAJWCXN.js → chunk-WRYT4HTZ.js} +2 -2
- package/dist/cli/chunks/{chunk-PSA2SOON.js → chunk-XFCWYQHW.js} +2 -2
- package/dist/cli/chunks/{chunk-6X65BGGK.js → chunk-XKFE3FLI.js} +2 -2
- package/dist/cli/chunks/{chunk-ZF65VOQH.js → chunk-YFGAHNCG.js} +2 -2
- package/dist/cli/chunks/{chunk-YSCEUK55.js → chunk-YPTGE5NJ.js} +2 -2
- package/dist/cli/chunks/{chunk-YDZIPP3Y.js → chunk-YRQLVGCI.js} +2 -2
- package/dist/cli/chunks/{chunk-ERQL3D2O.js → chunk-Z6QCOZ2H.js} +2 -2
- package/dist/cli/chunks/{chunk-WYFEVPLO.js → chunk-ZCFZ4USU.js} +1 -1
- package/dist/cli/chunks/{chunk-2R7XZ2WP.js → chunk-ZEIG5IQ4.js} +2 -2
- package/dist/cli/chunks/{chunk-KJJP446A.js → chunk-ZJG6N2OK.js} +1 -1
- package/dist/cli/chunks/{chunk-BUKGW63B.js → chunk-ZJIX5FGQ.js} +3 -3
- package/dist/cli/chunks/{chunk-EZ3JVN6S.js → chunk-ZLXBNNNT.js} +2 -2
- package/dist/cli/chunks/{chunk-4FHJYJCH.js → chunk-ZOXWASCC.js} +2 -2
- package/dist/cli/chunks/{ci-NT4DUGQ4.js → ci-74ZUCO5V.js} +2 -2
- package/dist/cli/chunks/{ci-output-PXBD2QPH.js → ci-output-HD6IZNJA.js} +2 -2
- package/dist/cli/chunks/{circuit-breaker-ZPCCEEDX.js → circuit-breaker-USZVMA42.js} +2 -2
- package/dist/cli/chunks/{claude-flow-setup-CZCDFZOE.js → claude-flow-setup-S4XKNCD5.js} +2 -2
- package/dist/cli/chunks/client-33PGO5FA.js +2 -0
- package/dist/cli/chunks/{cline-installer-6J2S7GLM.js → cline-installer-6EW4CHAR.js} +2 -2
- package/dist/cli/chunks/{code-UTERK5AP.js → code-TOLWD2XL.js} +2 -2
- package/dist/cli/chunks/{code-index-extractor-O3MJTOS2.js → code-index-extractor-UA4QQ7B3.js} +2 -2
- package/dist/cli/chunks/{codex-installer-AZJIVXJR.js → codex-installer-C2CUP4FW.js} +2 -2
- package/dist/cli/chunks/{completions-A6ANQSZN.js → completions-KVUMQQ4K.js} +2 -2
- package/dist/cli/chunks/{complexity-analyzer-MRSN7VUP.js → complexity-analyzer-DFH6LMK2.js} +2 -2
- package/dist/cli/chunks/{continuedev-installer-6LMKQRUI.js → continuedev-installer-LYDQSAU7.js} +2 -2
- package/dist/cli/chunks/{copilot-installer-KP3TWUNO.js → copilot-installer-7USXLZHZ.js} +2 -2
- package/dist/cli/chunks/core-handlers-CSNZIM3A.js +2 -0
- package/dist/cli/chunks/{cost-tracker-R3C5IQPZ.js → cost-tracker-JBDIUMKZ.js} +2 -2
- package/dist/cli/chunks/{coverage-MR4QA2NM.js → coverage-RGO3K357.js} +3 -3
- package/dist/cli/chunks/cross-domain-router-DRIBR5L3.js +2 -0
- package/dist/cli/chunks/{cursor-installer-LPZ7NGOS.js → cursor-installer-YEZGD37F.js} +2 -2
- package/dist/cli/chunks/{daemon-X5KXHRY3.js → daemon-FVETQ3LL.js} +3 -3
- package/dist/cli/chunks/{daemon-K3KW2UDV.js → daemon-LPEXHNYG.js} +4 -4
- package/dist/cli/chunks/{dag-attention-scheduler-J4FJSGNN.js → dag-attention-scheduler-UKYE2FII.js} +2 -2
- package/dist/cli/chunks/{detect-22TX2NCA.js → detect-WBG5P7ER.js} +2 -2
- package/dist/cli/chunks/{dist-node-QI4I4QPS.js → dist-node-YW6YRBCU.js} +2 -2
- package/dist/cli/chunks/{domain-handler-ZYZGPNOQ.js → domain-handler-HH7J4A32.js} +2 -2
- package/dist/cli/chunks/{domain-transfer-2EEQTNIU.js → domain-transfer-V34GXD5I.js} +2 -2
- package/dist/cli/chunks/dream-WUNO723O.js +2 -0
- package/dist/cli/chunks/{embed-and-insert-pattern-LYCTU5BS.js → embed-and-insert-pattern-WYLRS3CL.js} +2 -2
- package/dist/cli/chunks/{eval-SOA72GUX.js → eval-EIMVXY5J.js} +2 -2
- package/dist/cli/chunks/{experience-capture-middleware-AFFYOMYM.js → experience-capture-middleware-QMZHRUKM.js} +3 -3
- package/dist/cli/chunks/{fast-paths-WNMHOSUH.js → fast-paths-NHLW6XS6.js} +2 -2
- package/dist/cli/chunks/{feature-flags-HAP5IAAY.js → feature-flags-N3UHMSZ3.js} +2 -2
- package/dist/cli/chunks/{feature-flags-FT4YBZH4.js → feature-flags-NE3MBL3P.js} +2 -2
- package/dist/cli/chunks/{file-discovery-B4FFOH3Z.js → file-discovery-SI44X4YS.js} +2 -2
- package/dist/cli/chunks/{fleet-2ICPYV3J.js → fleet-MMYUXRRM.js} +3 -3
- package/dist/cli/chunks/{gnn-wrapper-XIBJAHMW.js → gnn-wrapper-RLYXYU2Q.js} +2 -2
- package/dist/cli/chunks/{heartbeat-handler-NSLSKDOI.js → heartbeat-handler-6EDRUYLV.js} +4 -4
- package/dist/cli/chunks/heartbeat-scheduler-VAFQDJLL.js +2 -0
- package/dist/cli/chunks/hnsw-adapter-TIRPA7XE.js +2 -0
- package/dist/cli/chunks/hnsw-index-SSQBRQCQ.js +2 -0
- package/dist/cli/chunks/{hnsw-legacy-bridge-FTV4CCBB.js → hnsw-legacy-bridge-RVM7EAIH.js} +2 -2
- package/dist/cli/chunks/{better-sqlite3-RQCOOAZC.js → hnswlib-node-RJPBJU2Q.js} +2 -2
- package/dist/cli/chunks/{hooks-SM4EU52N.js → hooks-ZF4VKHEO.js} +10 -10
- package/dist/cli/chunks/hybrid-router-AKBWZOQ3.js +2 -0
- package/dist/cli/chunks/{hypergraph-engine-RRMX4N3L.js → hypergraph-engine-YWS66PGO.js} +2 -2
- package/dist/cli/chunks/{hypergraph-handler-MNFGDKAP.js → hypergraph-handler-OQHVRPWB.js} +3 -3
- package/dist/cli/chunks/impact-analyzer-46FQIZ6Y.js +2 -0
- package/dist/cli/chunks/{init-handler-BNHIJ5TX.js → init-handler-YW74YF2V.js} +6 -6
- package/dist/cli/chunks/init-wizard-U3NHGYSS.js +2 -0
- package/dist/cli/chunks/kernel-ZDXHT6QF.js +2 -0
- package/dist/cli/chunks/{kilocode-installer-GFKUKPLY.js → kilocode-installer-APWB2GMA.js} +2 -2
- package/dist/cli/chunks/{kiro-installer-YBIYKODN.js → kiro-installer-DICKFVNC.js} +2 -2
- package/dist/cli/chunks/knowledge-graph-6XTW6WO6.js +2 -0
- package/dist/cli/chunks/{learning-QEWUPCK6.js → learning-MXHNYW5D.js} +3 -3
- package/dist/cli/chunks/{llm-router-D5FQIMVQ.js → llm-router-LTFIX7NY.js} +5 -5
- package/dist/cli/chunks/llm-router-service-3F4E64SY.js +2 -0
- package/dist/cli/chunks/{load-CLBUCKZQ.js → load-JUMIQ4LZ.js} +2 -2
- package/dist/cli/chunks/load-test-SWZNGEIY.js +2 -0
- package/dist/cli/chunks/{mcp-VOMG5DPV.js → mcp-WHIARJGO.js} +2 -2
- package/dist/cli/chunks/{memory-WZO63VSC.js → memory-KAHS6Z5A.js} +5 -5
- package/dist/cli/chunks/memory-backend-PR74ZPBA.js +2 -0
- package/dist/cli/chunks/memory-handlers-DG3RRXB6.js +2 -0
- package/dist/cli/chunks/{multi-model-executor-7UKW43VV.js → multi-model-executor-E3Y2RHMX.js} +2 -2
- package/dist/cli/chunks/{opencode-installer-MLFPRRL2.js → opencode-installer-3RKGNGGE.js} +2 -2
- package/dist/cli/chunks/{orchestrator-XNYDBGIN.js → orchestrator-TXITUKWD.js} +5 -5
- package/dist/cli/chunks/pattern-null-store-EPE36BVT.js +2 -0
- package/dist/cli/chunks/{pattern-usage-recorder-ZAP7ASQI.js → pattern-usage-recorder-EE2BUFZT.js} +2 -2
- package/dist/cli/chunks/{pipeline-4EJYOPBC.js → pipeline-AXTT6KZB.js} +2 -2
- package/dist/cli/chunks/{platform-ALPOWCOH.js → platform-TICPVKE2.js} +2 -2
- package/dist/cli/chunks/{plugin-S2RX3KHR.js → plugin-VQKNV3EM.js} +2 -2
- package/dist/cli/chunks/{prime-radiant-advanced-wasm-P2JB73XX.js → prime-radiant-advanced-wasm-6GY5YY7D.js} +2 -2
- package/dist/cli/chunks/protocol-executor-IELENNST.js +2 -0
- package/dist/cli/chunks/{protocol-handler-ZBJXSESA.js → protocol-handler-YFWDR7UZ.js} +2 -2
- package/dist/cli/chunks/{prove-MYJ5YV45.js → prove-FUMRCXAA.js} +2 -2
- package/dist/cli/chunks/provider-manager-3R3KOBHG.js +2 -0
- package/dist/cli/chunks/qe-reasoning-bank-S2R2PCBS.js +2 -0
- package/dist/cli/chunks/{quality-NIACQC4M.js → quality-2APISBW5.js} +2 -2
- package/dist/cli/chunks/{quality-gate-OAZ23ON5.js → quality-gate-MCC3E5TM.js} +3 -3
- package/dist/cli/chunks/queen-coordinator-2E23NEV4.js +2 -0
- package/dist/cli/chunks/{real-embeddings-6I4LP7PL.js → real-embeddings-CC5TNOTI.js} +2 -2
- package/dist/cli/chunks/{roocode-installer-LRQHP6MK.js → roocode-installer-YAHTEVPI.js} +2 -2
- package/dist/cli/chunks/router-3FVLWO6S.js +2 -0
- package/dist/cli/chunks/routing-feedback-ZQLRNNR7.js +2 -0
- package/dist/cli/chunks/{routing-handler-A7BW7MV4.js → routing-handler-6NQBW4TQ.js} +2 -2
- package/dist/cli/chunks/{ruvector-commands-ZDRRFSJS.js → ruvector-commands-ZHXLHUPG.js} +2 -2
- package/dist/cli/chunks/{rvf-dual-writer-QWE3Z6BB.js → rvf-dual-writer-5KF2DGCW.js} +2 -2
- package/dist/cli/chunks/{rvf-migration-adapter-6UDAP7QB.js → rvf-migration-adapter-BBU57BGF.js} +2 -2
- package/dist/cli/chunks/{rvf-migration-coordinator-FEW2N4R4.js → rvf-migration-coordinator-VN4VRZA4.js} +2 -2
- package/dist/cli/chunks/rvf-native-adapter-YFGLQNEB.js +2 -0
- package/dist/cli/chunks/rvf-store-integrity-XCY2XQZA.js +2 -0
- package/dist/cli/chunks/safe-db-4SBLBTW7.js +2 -0
- package/dist/cli/chunks/schedule-5Y3BGVAA.js +2 -0
- package/dist/cli/chunks/scheduler-DOID3QF3.js +2 -0
- package/dist/cli/chunks/{security-KFXBV65O.js → security-PYP4H3KN.js} +3 -3
- package/dist/cli/chunks/shared-rvf-adapter-3CJHRNX6.js +2 -0
- package/dist/cli/chunks/{shared-rvf-dual-writer-CXXTB7CU.js → shared-rvf-dual-writer-MKSLKWDI.js} +2 -2
- package/dist/cli/chunks/sqlite-persistence-M4JEQO57.js +2 -0
- package/dist/cli/chunks/{status-handler-CXSVM236.js → status-handler-VYIZ3VJF.js} +2 -2
- package/dist/cli/chunks/{structural-health-LMHSM7MJ.js → structural-health-MVV4OWXP.js} +2 -2
- package/dist/cli/chunks/{sync-DMOUY2EY.js → sync-G47OYIQ3.js} +2 -2
- package/dist/cli/chunks/sync-VNX6L3TI.js +2 -0
- package/dist/cli/chunks/{task-handler-DMSNFIH3.js → task-handler-GOWF2GEH.js} +2 -2
- package/dist/cli/chunks/{task-handlers-3Z3QV7X7.js → task-handlers-J2WC6J37.js} +3 -3
- package/dist/cli/chunks/{test-U6CGMDLN.js → test-DMCJ3BXS.js} +4 -4
- package/dist/cli/chunks/{test-scheduling-YHYA3BP5.js → test-scheduling-TRFHHKFM.js} +3 -3
- package/dist/cli/chunks/token-bootstrap-KEQ7AHFF.js +2 -0
- package/dist/cli/chunks/{token-usage-EOOTM7Q3.js → token-usage-B54FOFOF.js} +2 -2
- package/dist/cli/chunks/transformers-IACZG7IV.js +2 -0
- package/dist/cli/chunks/{tree-sitter-wasm-parser-HTGAXDQA.js → tree-sitter-wasm-parser-N7H4X37E.js} +2 -2
- package/dist/cli/chunks/{types-GLRXY4RY.js → types-B3SHT4OD.js} +2 -2
- package/dist/cli/chunks/unified-memory-WNYWTGVX.js +2 -0
- package/dist/cli/chunks/unified-memory-hnsw-YPAV7U4E.js +2 -0
- package/dist/cli/chunks/unified-persistence-TJ252S7L.js +2 -0
- package/dist/cli/chunks/{upgrade-KU55H77X.js → upgrade-A2PQ5EWK.js} +2 -2
- package/dist/cli/chunks/{validate-26VSBOJN.js → validate-UXV7UQUT.js} +2 -2
- package/dist/cli/chunks/{validate-swarm-OIALRDKF.js → validate-swarm-MMBU4FPP.js} +2 -2
- package/dist/cli/chunks/{vibium-LOTWW25P.js → vibium-R4GUVADA.js} +2 -2
- package/dist/cli/chunks/visual-security-VKYXEGJB.js +2 -0
- package/dist/cli/chunks/{web-tree-sitter-6LWPPBYU.js → web-tree-sitter-MP6E6CJB.js} +2 -2
- package/dist/cli/chunks/{windsurf-installer-ILOQYENG.js → windsurf-installer-Z6BWMUUO.js} +2 -2
- package/dist/cli/chunks/{witness-chain-YBS6OHS4.js → witness-chain-EFLTABBA.js} +2 -2
- package/dist/cli/chunks/witness-chain-WVXRXKQP.js +2 -0
- package/dist/cli/chunks/{witness-key-manager-SI3WV3ZQ.js → witness-key-manager-PN36TV43.js} +2 -2
- package/dist/cli/chunks/{workflow-GY6SJRQW.js → workflow-A2AX3RJU.js} +4 -4
- package/dist/cli/chunks/workflow-orchestrator-GOWSPR3G.js +2 -0
- package/dist/cli/chunks/{wrappers-MMO5YKOZ.js → wrappers-NA6FHA63.js} +2 -2
- package/dist/cli/commands/llm-router.js +1 -0
- package/dist/init/skills-installer.js +1 -0
- package/dist/integrations/embeddings/base/EmbeddingGenerator.js +13 -1
- package/dist/integrations/ruvector/brain-rvf-exporter.js +115 -13
- package/dist/integrations/ruvector/rvf-dual-writer.js +20 -3
- package/dist/integrations/ruvector/rvf-store-integrity.d.ts +49 -0
- package/dist/integrations/ruvector/rvf-store-integrity.js +137 -0
- package/dist/integrations/ruvector/shared-rvf-adapter.js +23 -5
- package/dist/kernel/unified-memory.js +4 -0
- package/dist/learning/pattern-store.js +23 -5
- package/dist/learning/qe-flywheel/corpus-scorer.js +10 -7
- package/dist/learning/qe-flywheel/generation.d.ts +7 -0
- package/dist/learning/qe-flywheel/generation.js +5 -0
- package/dist/learning/qe-flywheel/platform-signer.d.ts +32 -0
- package/dist/learning/qe-flywheel/platform-signer.js +60 -0
- package/dist/learning/qe-flywheel/receipt.js +9 -2
- package/dist/learning/qe-flywheel/witness-verify.d.ts +86 -0
- package/dist/learning/qe-flywheel/witness-verify.js +156 -0
- package/dist/mcp/bundle.js +398 -387
- package/dist/shared/db-recovery.d.ts +55 -0
- package/dist/shared/db-recovery.js +184 -0
- package/dist/shared/llm/billing-modes.js +5 -2
- package/dist/shared/llm/cost-tracker.js +1 -0
- package/dist/shared/llm/interfaces.d.ts +14 -1
- package/dist/shared/llm/provider-manager.d.ts +1 -1
- package/dist/shared/llm/provider-manager.js +7 -3
- package/dist/shared/llm/providers/claude-code.js +12 -3
- package/dist/shared/llm/providers/codex.d.ts +58 -0
- package/dist/shared/llm/providers/codex.js +305 -0
- package/dist/shared/llm/providers/index.d.ts +1 -0
- package/dist/shared/llm/providers/index.js +1 -0
- package/dist/shared/llm/router/config-store.js +5 -0
- package/dist/shared/llm/router/hybrid-router.js +2 -2
- package/dist/shared/llm/spend-ledger.d.ts +24 -0
- package/dist/shared/llm/spend-ledger.js +86 -15
- package/dist/shared/llm/translation/message-formatter.js +1 -0
- package/dist/shared/safe-db.d.ts +10 -0
- package/dist/shared/safe-db.js +17 -0
- package/dist/skills/qe-court/referee.d.ts +62 -0
- package/dist/skills/qe-court/referee.js +78 -0
- package/dist/validation/gate-reexecute.d.ts +9 -0
- package/dist/validation/gate-reexecute.js +61 -0
- package/dist/validation/paired-bootstrap.d.ts +36 -0
- package/dist/validation/paired-bootstrap.js +58 -0
- package/package.json +8 -4
- package/dist/cli/chunks/adapter-RL6GNUOS.js +0 -2
- package/dist/cli/chunks/aqe-learning-engine-UEEW6AQG.js +0 -2
- package/dist/cli/chunks/base-JQA5YULE.js +0 -2
- package/dist/cli/chunks/brain-handler-T7RDPKNM.js +0 -89
- package/dist/cli/chunks/browser-workflow-XTKUHTIT.js +0 -2
- package/dist/cli/chunks/chunk-ABHKXMOJ.js +0 -2
- package/dist/cli/chunks/chunk-CDMAVNV5.js +0 -2
- package/dist/cli/chunks/chunk-CQKEVUMO.js +0 -153
- package/dist/cli/chunks/chunk-KPV4N4KT.js +0 -9
- package/dist/cli/chunks/chunk-MALFTRCT.js +0 -29
- package/dist/cli/chunks/chunk-T75VH6NT.js +0 -2
- package/dist/cli/chunks/chunk-VM6VBRRU.js +0 -43
- package/dist/cli/chunks/chunk-WRMUQVKY.js +0 -2
- package/dist/cli/chunks/chunk-YY4KXDI6.js +0 -2
- package/dist/cli/chunks/client-S7DIRNFJ.js +0 -2
- package/dist/cli/chunks/core-handlers-NM2KCI6Z.js +0 -2
- package/dist/cli/chunks/cross-domain-router-3TSZMCBM.js +0 -2
- package/dist/cli/chunks/dream-QIIJONYI.js +0 -2
- package/dist/cli/chunks/heartbeat-scheduler-CDNGLJJO.js +0 -2
- package/dist/cli/chunks/hnsw-adapter-CR7Y4OAM.js +0 -2
- package/dist/cli/chunks/hnsw-index-TEDO4MQC.js +0 -2
- package/dist/cli/chunks/hybrid-router-O24ZDIP5.js +0 -2
- package/dist/cli/chunks/impact-analyzer-PDM4SDB6.js +0 -2
- package/dist/cli/chunks/init-wizard-F4KODPNW.js +0 -2
- package/dist/cli/chunks/kernel-77UM35L6.js +0 -2
- package/dist/cli/chunks/knowledge-graph-R6ZWWV2K.js +0 -2
- package/dist/cli/chunks/llm-router-service-7QYCZ66H.js +0 -2
- package/dist/cli/chunks/load-test-AWVA3CAQ.js +0 -2
- package/dist/cli/chunks/memory-backend-YESSIHFW.js +0 -2
- package/dist/cli/chunks/memory-handlers-EOOWSUHI.js +0 -2
- package/dist/cli/chunks/pattern-null-store-X3UXLJNL.js +0 -2
- package/dist/cli/chunks/protocol-executor-KXDCTMWI.js +0 -2
- package/dist/cli/chunks/provider-manager-XJZVHYI6.js +0 -2
- package/dist/cli/chunks/qe-reasoning-bank-DPHPNIC6.js +0 -2
- package/dist/cli/chunks/queen-coordinator-EVGWME5C.js +0 -2
- package/dist/cli/chunks/router-R2N7TMAS.js +0 -2
- package/dist/cli/chunks/routing-feedback-G6W3H26L.js +0 -2
- package/dist/cli/chunks/rvf-native-adapter-D7R2GWXK.js +0 -2
- package/dist/cli/chunks/safe-db-CQZGF2KA.js +0 -2
- package/dist/cli/chunks/schedule-UP7E3LRC.js +0 -2
- package/dist/cli/chunks/scheduler-ENIZHYSL.js +0 -2
- package/dist/cli/chunks/shared-rvf-adapter-HDDCXCHY.js +0 -2
- package/dist/cli/chunks/sqlite-persistence-CEVJVWS5.js +0 -2
- package/dist/cli/chunks/sync-REEFKICL.js +0 -2
- package/dist/cli/chunks/token-bootstrap-MQCTJURQ.js +0 -2
- package/dist/cli/chunks/transformers-EKDJW2H6.js +0 -2
- package/dist/cli/chunks/unified-memory-PXOQ4N53.js +0 -2
- package/dist/cli/chunks/unified-memory-hnsw-VEXD6ASE.js +0 -2
- package/dist/cli/chunks/unified-persistence-46G6MZYC.js +0 -2
- package/dist/cli/chunks/visual-security-4X3T3MFL.js +0 -2
- package/dist/cli/chunks/witness-chain-XW4S3LVW.js +0 -2
- package/dist/cli/chunks/workflow-orchestrator-IIVV6TCP.js +0 -2
|
@@ -1,311 +1,565 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Claude Flow Hook Handler (Cross-Platform)
|
|
4
|
-
* Dispatches hook events to the appropriate helper modules.
|
|
5
|
-
*
|
|
6
|
-
* Usage: node hook-handler.cjs <command> [args...]
|
|
7
|
-
*
|
|
8
|
-
* Commands:
|
|
9
|
-
* route - Route a task to optimal agent (reads PROMPT from env/stdin)
|
|
10
|
-
* pre-bash - Validate command safety before execution
|
|
11
|
-
* post-edit - Record edit outcome for learning
|
|
12
|
-
* session-restore - Restore previous session state
|
|
13
|
-
* session-end - End session and persist state
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
const path = require('path');
|
|
17
|
-
const fs = require('fs');
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
//
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
console.log
|
|
218
|
-
|
|
219
|
-
console.log(
|
|
220
|
-
console.
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
//
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Claude Flow Hook Handler (Cross-Platform)
|
|
4
|
+
* Dispatches hook events to the appropriate helper modules.
|
|
5
|
+
*
|
|
6
|
+
* Usage: node hook-handler.cjs <command> [args...]
|
|
7
|
+
*
|
|
8
|
+
* Commands:
|
|
9
|
+
* route - Route a task to optimal agent (reads PROMPT from env/stdin)
|
|
10
|
+
* pre-bash - Validate command safety before execution
|
|
11
|
+
* post-edit - Record edit outcome for learning
|
|
12
|
+
* session-restore - Restore previous session state
|
|
13
|
+
* session-end - End session and persist state
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const path = require('path');
|
|
17
|
+
const fs = require('fs');
|
|
18
|
+
const os = require('os');
|
|
19
|
+
|
|
20
|
+
const helpersDir = __dirname;
|
|
21
|
+
|
|
22
|
+
// Resolve an installed @claude-flow/cli (or ruflo) bin — mirrors
|
|
23
|
+
// statusline-generator.ts's resolveCliBin() candidate list. Used only to
|
|
24
|
+
// spawn the detached funnel-refresh helper below; failures are silent (no
|
|
25
|
+
// candidate found just means the refresh never fires this session).
|
|
26
|
+
//
|
|
27
|
+
// Verifies dist/src/index.js exists alongside bin/cli.js, not just the bin
|
|
28
|
+
// itself — Claude Code's own plugin marketplace mechanism installs by
|
|
29
|
+
// `git clone`/`git pull` with no build step, so `~/.claude/plugins/
|
|
30
|
+
// marketplaces/ruflo` is a SOURCE-ONLY checkout by construction: bin/cli.js
|
|
31
|
+
// is present on disk but importing dist/src/index.js throws
|
|
32
|
+
// ERR_MODULE_NOT_FOUND on every real command (confirmed live — only
|
|
33
|
+
// `--version` happens to survive it, since it reads package.json directly).
|
|
34
|
+
// Without this check, resolveCliBinForHook() picked that doomed candidate
|
|
35
|
+
// first every time and spawnDetachedFunnelRefresh() below had no fallback,
|
|
36
|
+
// so the promo/disclosure row could never populate for any marketplace
|
|
37
|
+
// install, on any OS.
|
|
38
|
+
function resolveCliBinForHook() {
|
|
39
|
+
try {
|
|
40
|
+
const home = os.homedir();
|
|
41
|
+
const cwd = process.cwd();
|
|
42
|
+
const candidates = [
|
|
43
|
+
path.join(home, '.claude', 'plugins', 'marketplaces', 'ruflo', 'bin', 'cli.js'),
|
|
44
|
+
path.join(cwd, 'node_modules', '@claude-flow', 'cli', 'bin', 'cli.js'),
|
|
45
|
+
path.join(cwd, 'node_modules', 'ruflo', 'bin', 'cli.js'),
|
|
46
|
+
path.join(cwd, 'v3', '@claude-flow', 'cli', 'bin', 'cli.js'),
|
|
47
|
+
// helpersDir is .claude/helpers/ inside the package itself when this
|
|
48
|
+
// file is running from a real @claude-flow/cli install (not a project
|
|
49
|
+
// that merely copied the helper) — its bin/ is two levels up.
|
|
50
|
+
path.join(helpersDir, '..', '..', 'bin', 'cli.js'),
|
|
51
|
+
];
|
|
52
|
+
for (const p of candidates) {
|
|
53
|
+
try {
|
|
54
|
+
if (fs.existsSync(p) && fs.existsSync(path.join(path.dirname(p), '..', 'dist', 'src', 'index.js'))) {
|
|
55
|
+
return p;
|
|
56
|
+
}
|
|
57
|
+
} catch (e) { /* try next candidate */ }
|
|
58
|
+
}
|
|
59
|
+
} catch (e) { /* ignore */ }
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Fire-and-forget doesn't work when the CALLER is itself a short-lived
|
|
64
|
+
// subprocess (confirmed live: two consecutive statusline renders 5s apart
|
|
65
|
+
// both saw an empty funnel-messages-cache, because the async HTTPS fetch
|
|
66
|
+
// inside a `void refreshRemoteMessages()` call gets killed when the spawning
|
|
67
|
+
// process exits before the request completes). Spawning fully DETACHED +
|
|
68
|
+
// unref'd decouples the refresh's lifetime from this hook's — it keeps
|
|
69
|
+
// running (up to message-transport.ts's own 4s fetch timeout) even after
|
|
70
|
+
// session-restore's own process has already exited, so it actually gets a
|
|
71
|
+
// chance to write the cache. Never awaited here — must not add to
|
|
72
|
+
// SessionStart's own timeout budget.
|
|
73
|
+
//
|
|
74
|
+
// No usable local candidate (resolveCliBinForHook() returned null) falls
|
|
75
|
+
// back to npx: this call is detached/unref'd, so a slower npx cold-start
|
|
76
|
+
// costs nothing perceptible — unlike the statusline's own synchronous
|
|
77
|
+
// render path, where local-first exists purely for per-render latency.
|
|
78
|
+
// `--prefer-offline` avoids a registry round trip for the tarball when
|
|
79
|
+
// already cached while still resolving the current `@latest` version.
|
|
80
|
+
function spawnDetachedHookRefresh(subcommand) {
|
|
81
|
+
try {
|
|
82
|
+
const { spawn } = require('child_process');
|
|
83
|
+
const cliBin = resolveCliBinForHook();
|
|
84
|
+
const cmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
85
|
+
const spawnArgs = cliBin
|
|
86
|
+
? [process.execPath, [cliBin, 'hooks', subcommand, '--quiet']]
|
|
87
|
+
: [cmd, ['--prefer-offline', '@claude-flow/cli', 'hooks', subcommand, '--quiet']];
|
|
88
|
+
const child = spawn(spawnArgs[0], spawnArgs[1], {
|
|
89
|
+
detached: true,
|
|
90
|
+
stdio: 'ignore',
|
|
91
|
+
env: process.env,
|
|
92
|
+
windowsHide: true,
|
|
93
|
+
});
|
|
94
|
+
child.unref();
|
|
95
|
+
} catch (e) { /* best-effort only */ }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function spawnDetachedFunnelRefresh() {
|
|
99
|
+
spawnDetachedHookRefresh('refresh-funnel');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ADR-318/319: first-run auto-enable of spinner verbs (default ON) +
|
|
103
|
+
// announcements (default OFF, explicit opt-in). Fires ONCE per install
|
|
104
|
+
// (marker at ~/.ruflo/first-run-enabled.json), then never again —
|
|
105
|
+
// subsequent sessions see the marker and skip.
|
|
106
|
+
//
|
|
107
|
+
// Split posture rationale:
|
|
108
|
+
// - Spinner verbs = low-intrusion (per-spin flash, append-mode mix
|
|
109
|
+
// with Claude Code defaults, moderate visibility over time). Default ON.
|
|
110
|
+
// Disclosure notification + one-command disable satisfies the ethical bar.
|
|
111
|
+
// - Announcements = higher-intrusion (prominent line at every Claude Code
|
|
112
|
+
// startup, more attention per view). Default OFF; opt-in via
|
|
113
|
+
// RUFLO_AUTO_ENABLE_ANNOUNCEMENTS=1 or explicit `ruflo announcements enable`.
|
|
114
|
+
//
|
|
115
|
+
// Gates (spinner is default-on unless any is TRUE):
|
|
116
|
+
// - RUFLO_NO_AUTO_ENABLE truthy (master opt-out — kills both)
|
|
117
|
+
// - RUFLO_NO_AUTO_ENABLE_SPINNER truthy (spinner-only opt-out)
|
|
118
|
+
// - CI / GITHUB_ACTIONS truthy
|
|
119
|
+
// - stdout is not a TTY (piped, non-interactive)
|
|
120
|
+
// - Marker file already exists
|
|
121
|
+
//
|
|
122
|
+
// Announcements needs the same gates PLUS RUFLO_AUTO_ENABLE_ANNOUNCEMENTS=1.
|
|
123
|
+
//
|
|
124
|
+
// Marker is written even if the spawns fail — auto-enable is a "we tried once"
|
|
125
|
+
// contract, not "keep trying until success." Users can run enable manually.
|
|
126
|
+
function firstRunAutoEnableIfEligible() {
|
|
127
|
+
try {
|
|
128
|
+
const path = require('path');
|
|
129
|
+
const fs = require('fs');
|
|
130
|
+
const os = require('os');
|
|
131
|
+
const truthy = (v) => v && !/^(0|false|off|no)$/i.test(String(v));
|
|
132
|
+
if (truthy(process.env.RUFLO_NO_AUTO_ENABLE)) return;
|
|
133
|
+
if (process.env.CI || process.env.GITHUB_ACTIONS) return;
|
|
134
|
+
if (process.stdout && process.stdout.isTTY === false) return;
|
|
135
|
+
const markerPath = path.join(os.homedir(), '.ruflo', 'first-run-enabled.json');
|
|
136
|
+
if (fs.existsSync(markerPath)) return;
|
|
137
|
+
|
|
138
|
+
const enableSpinner = !truthy(process.env.RUFLO_NO_AUTO_ENABLE_SPINNER);
|
|
139
|
+
const enableAnnouncements = truthy(process.env.RUFLO_AUTO_ENABLE_ANNOUNCEMENTS);
|
|
140
|
+
|
|
141
|
+
// Nothing to do — user opted out of both. Skip marker write so if they
|
|
142
|
+
// change their mind and re-enable env vars later, first-run still fires.
|
|
143
|
+
if (!enableSpinner && !enableAnnouncements) return;
|
|
144
|
+
|
|
145
|
+
// Spawn the enable commands detached + non-blocking. Any failure
|
|
146
|
+
// (missing CLI, refused state, etc.) is silent — auto-enable is
|
|
147
|
+
// best-effort and MUST NOT block session-restore. Uses execPath +
|
|
148
|
+
// resolved cli.js directly rather than spawnDetachedHookRefresh
|
|
149
|
+
// because that helper hardcodes 'hooks' as the top-level command.
|
|
150
|
+
const { spawn } = require('child_process');
|
|
151
|
+
const cliBin = resolveCliBinForHook();
|
|
152
|
+
const runDetached = (args) => {
|
|
153
|
+
try {
|
|
154
|
+
const spawnArgs = cliBin
|
|
155
|
+
? [process.execPath, [cliBin, ...args]]
|
|
156
|
+
: [process.platform === 'win32' ? 'npx.cmd' : 'npx',
|
|
157
|
+
['--prefer-offline', '@claude-flow/cli', ...args]];
|
|
158
|
+
const child = spawn(spawnArgs[0], spawnArgs[1], {
|
|
159
|
+
detached: true, stdio: 'ignore', env: process.env, windowsHide: true,
|
|
160
|
+
});
|
|
161
|
+
child.unref();
|
|
162
|
+
} catch { /* best-effort */ }
|
|
163
|
+
};
|
|
164
|
+
if (enableSpinner) runDetached(['spinner', 'enable', '--yes']);
|
|
165
|
+
if (enableAnnouncements) runDetached(['announcements', 'enable', '--yes']);
|
|
166
|
+
|
|
167
|
+
try {
|
|
168
|
+
fs.mkdirSync(path.dirname(markerPath), { recursive: true, mode: 0o700 });
|
|
169
|
+
fs.writeFileSync(
|
|
170
|
+
markerPath,
|
|
171
|
+
JSON.stringify({
|
|
172
|
+
_ts: Date.now(),
|
|
173
|
+
source: 'session-restore-hook',
|
|
174
|
+
enabled: { spinner: enableSpinner, announcements: enableAnnouncements },
|
|
175
|
+
}, null, 2),
|
|
176
|
+
{ encoding: 'utf-8', mode: 0o600 }
|
|
177
|
+
);
|
|
178
|
+
} catch { /* ignore — best effort */ }
|
|
179
|
+
|
|
180
|
+
// Notification tells user exactly what happened. stderr so it doesn't
|
|
181
|
+
// corrupt any downstream JSON stdout consumer.
|
|
182
|
+
try {
|
|
183
|
+
const parts = [];
|
|
184
|
+
if (enableSpinner) parts.push('spinner verbs');
|
|
185
|
+
if (enableAnnouncements) parts.push('startup announcements');
|
|
186
|
+
const disableCmds = [];
|
|
187
|
+
if (enableSpinner) disableCmds.push('`ruflo spinner disable`');
|
|
188
|
+
if (enableAnnouncements) disableCmds.push('`ruflo announcements disable`');
|
|
189
|
+
process.stderr.write(
|
|
190
|
+
'[ruflo] First-run: enabled ' + parts.join(' + ') + '. ' +
|
|
191
|
+
'Disable anytime with ' + disableCmds.join(' / ') + '. ' +
|
|
192
|
+
(enableSpinner && !enableAnnouncements
|
|
193
|
+
? 'Announcements stay opt-in — set RUFLO_AUTO_ENABLE_ANNOUNCEMENTS=1 to enable those too. '
|
|
194
|
+
: '') +
|
|
195
|
+
'Restart Claude Code once to see the changes take effect.\n'
|
|
196
|
+
);
|
|
197
|
+
} catch { /* ignore */ }
|
|
198
|
+
} catch { /* auto-enable must never break session-restore */ }
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Same fallback-aware pattern as spawnDetachedFunnelRefresh() above, for
|
|
202
|
+
// ADR-316's co-pilot advisor tip. Safe to call on EVERY session-restore:
|
|
203
|
+
// refresh-advisor's own action checks consent + a 24h TTL BEFORE spending
|
|
204
|
+
// anything, so an unconsented or already-fresh install is a fast no-op file
|
|
205
|
+
// read, never a network call. Never awaited here — must not add to
|
|
206
|
+
// SessionStart's own timeout budget.
|
|
207
|
+
function spawnDetachedAdvisorRefresh() {
|
|
208
|
+
spawnDetachedHookRefresh('refresh-advisor');
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Safe require with stdout suppression - the helper modules have CLI
|
|
212
|
+
// sections that run unconditionally on require(), so we mute console
|
|
213
|
+
// during the require to prevent noisy output.
|
|
214
|
+
function safeRequire(modulePath) {
|
|
215
|
+
try {
|
|
216
|
+
if (fs.existsSync(modulePath)) {
|
|
217
|
+
const origLog = console.log;
|
|
218
|
+
const origError = console.error;
|
|
219
|
+
console.log = () => {};
|
|
220
|
+
console.error = () => {};
|
|
221
|
+
try {
|
|
222
|
+
const mod = require(modulePath);
|
|
223
|
+
return mod;
|
|
224
|
+
} finally {
|
|
225
|
+
console.log = origLog;
|
|
226
|
+
console.error = origError;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
} catch (e) {
|
|
230
|
+
// silently fail
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const router = safeRequire(path.join(helpersDir, 'router.js'));
|
|
236
|
+
const session = safeRequire(path.join(helpersDir, 'session.js'));
|
|
237
|
+
const memory = safeRequire(path.join(helpersDir, 'memory.js'));
|
|
238
|
+
const intelligence = safeRequire(path.join(helpersDir, 'intelligence.cjs'));
|
|
239
|
+
|
|
240
|
+
// ── Intelligence timeout protection (fixes #1530, #1531) ───────────────────
|
|
241
|
+
const INTELLIGENCE_TIMEOUT_MS = 3000;
|
|
242
|
+
// Race the (possibly-async) work against a real timeout. The previous version
|
|
243
|
+
// called fn() and clearTimeout(timer) immediately, so an async fn returned a
|
|
244
|
+
// pending promise that resolved THROUGH the race — the timeout protected
|
|
245
|
+
// nothing. This settles on whichever finishes first, then clears the timer.
|
|
246
|
+
//
|
|
247
|
+
// LIMITATION: a synchronous blocking fn (the current intelligence.init() does
|
|
248
|
+
// blocking fs reads) cannot be interrupted by any in-process timer — the event
|
|
249
|
+
// loop is blocked. The real guard for that case is the readJSON file-size
|
|
250
|
+
// limit in intelligence.cjs. This util only bounds work that yields (async I/O).
|
|
251
|
+
function runWithTimeout(fn, label) {
|
|
252
|
+
let timer;
|
|
253
|
+
const timeout = new Promise((resolve) => {
|
|
254
|
+
timer = setTimeout(() => {
|
|
255
|
+
process.stderr.write("[WARN] " + label + " timed out after " + INTELLIGENCE_TIMEOUT_MS + "ms, skipping\n");
|
|
256
|
+
resolve(null);
|
|
257
|
+
}, INTELLIGENCE_TIMEOUT_MS);
|
|
258
|
+
});
|
|
259
|
+
const work = Promise.resolve().then(fn).catch(() => null);
|
|
260
|
+
return Promise.race([work, timeout]).then((result) => {
|
|
261
|
+
clearTimeout(timer);
|
|
262
|
+
return result;
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
// Get the command from argv
|
|
268
|
+
const [,, command, ...args] = process.argv;
|
|
269
|
+
|
|
270
|
+
// Read stdin with timeout — Claude Code sends hook data as JSON via stdin.
|
|
271
|
+
// Timeout prevents hanging when stdin is not properly closed (common on Windows).
|
|
272
|
+
async function readStdin() {
|
|
273
|
+
if (process.stdin.isTTY) return '';
|
|
274
|
+
return new Promise((resolve) => {
|
|
275
|
+
let data = '';
|
|
276
|
+
const timer = setTimeout(() => {
|
|
277
|
+
process.stdin.removeAllListeners();
|
|
278
|
+
process.stdin.pause();
|
|
279
|
+
resolve(data);
|
|
280
|
+
}, 500);
|
|
281
|
+
process.stdin.setEncoding('utf8');
|
|
282
|
+
process.stdin.on('data', (chunk) => { data += chunk; });
|
|
283
|
+
process.stdin.on('end', () => { clearTimeout(timer); resolve(data); });
|
|
284
|
+
process.stdin.on('error', () => { clearTimeout(timer); resolve(data); });
|
|
285
|
+
process.stdin.resume();
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
async function main() {
|
|
290
|
+
// Global safety timeout: hooks must NEVER hang (#1530, #1531)
|
|
291
|
+
const safetyTimer = setTimeout(() => {
|
|
292
|
+
process.stderr.write("[WARN] Hook handler global timeout (5s), forcing exit\n");
|
|
293
|
+
process.exit(0);
|
|
294
|
+
}, 5000);
|
|
295
|
+
safetyTimer.unref(); // don't keep process alive just for this timer
|
|
296
|
+
|
|
297
|
+
let stdinData = '';
|
|
298
|
+
try { stdinData = await readStdin(); } catch (e) { /* ignore stdin errors */ }
|
|
299
|
+
|
|
300
|
+
let hookInput = {};
|
|
301
|
+
if (stdinData.trim()) {
|
|
302
|
+
try { hookInput = JSON.parse(stdinData); } catch (e) { /* ignore parse errors */ }
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Normalize snake_case/camelCase: Claude Code sends tool_input/tool_name (snake_case)
|
|
306
|
+
const toolInput = hookInput.toolInput || hookInput.tool_input || {};
|
|
307
|
+
const toolName = hookInput.toolName || hookInput.tool_name || '';
|
|
308
|
+
|
|
309
|
+
// Merge stdin data into prompt resolution: prefer stdin fields, then env, then argv.
|
|
310
|
+
// `toolInput` is an object (e.g. {command:"ls"}) — it's truthy but not a string,
|
|
311
|
+
// so falling back to it directly bound `prompt` to the object and tripped
|
|
312
|
+
// `.toLowerCase()` / `.substring()` on every Bash hook (#1944). Use the
|
|
313
|
+
// `.command` field instead, which is the actual string the hook needs.
|
|
314
|
+
const prompt = hookInput.prompt || hookInput.command || toolInput.command
|
|
315
|
+
|| process.env.PROMPT || process.env.TOOL_INPUT_command || args.join(' ') || '';
|
|
316
|
+
|
|
317
|
+
// ADR-174: capture FAILURES so the learning substrate has negative examples.
|
|
318
|
+
// Claude Code's PostToolUse payload carries the tool result; a failed
|
|
319
|
+
// Write/Edit/Bash surfaces as tool_response.is_error / an error string /
|
|
320
|
+
// a non-zero exit code. Conservative — only a positive error signal counts
|
|
321
|
+
// as failure (mirrors isToolFailure() in helpers-generator.ts).
|
|
322
|
+
const toolFailed = (function (hi) {
|
|
323
|
+
if (!hi || typeof hi !== 'object') return false;
|
|
324
|
+
const tr = hi.tool_response != null ? hi.tool_response : (hi.toolResponse != null ? hi.toolResponse : hi.result);
|
|
325
|
+
if (tr == null) return false;
|
|
326
|
+
if (typeof tr === 'string') return /\b(error|failed|failure|exception|not found|no such|permission denied|traceback)\b/i.test(tr);
|
|
327
|
+
if (typeof tr === 'object') {
|
|
328
|
+
if (tr.is_error === true || tr.isError === true || tr.success === false || tr.error != null) return true;
|
|
329
|
+
const code = tr.exit_code != null ? tr.exit_code : (tr.exitCode != null ? tr.exitCode : tr.code);
|
|
330
|
+
if (typeof code === 'number' && code !== 0) return true;
|
|
331
|
+
if (Array.isArray(tr.content) && tr.is_error === true) return true;
|
|
332
|
+
}
|
|
333
|
+
return false;
|
|
334
|
+
})(hookInput);
|
|
335
|
+
|
|
336
|
+
const handlers = {
|
|
337
|
+
'route': () => {
|
|
338
|
+
// Inject ranked intelligence context before routing
|
|
339
|
+
if (intelligence && intelligence.getContext) {
|
|
340
|
+
try {
|
|
341
|
+
const ctx = intelligence.getContext(prompt);
|
|
342
|
+
if (ctx) console.log(ctx);
|
|
343
|
+
} catch (e) { /* non-fatal */ }
|
|
344
|
+
}
|
|
345
|
+
if (router && router.routeTask) {
|
|
346
|
+
const result = router.routeTask(prompt);
|
|
347
|
+
// Format output for Claude Code hook consumption — real data only
|
|
348
|
+
const output = [
|
|
349
|
+
`[INFO] Routing task: ${prompt.substring(0, 80) || '(no prompt)'}`,
|
|
350
|
+
'',
|
|
351
|
+
'+------------------- Primary Recommendation -------------------+',
|
|
352
|
+
`| Agent: ${result.agent.padEnd(53)}|`,
|
|
353
|
+
`| Confidence: ${(result.confidence * 100).toFixed(1)}%${' '.repeat(44)}|`,
|
|
354
|
+
`| Reason: ${(result.reason || '').substring(0, 53).padEnd(53)}|`,
|
|
355
|
+
'+--------------------------------------------------------------+',
|
|
356
|
+
];
|
|
357
|
+
console.log(output.join('\n'));
|
|
358
|
+
} else {
|
|
359
|
+
console.log('[INFO] Router not available, using default routing');
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// Rate-limit -> sponsored-capacity nudge (ADR-312/313). Fires here,
|
|
363
|
+
// client-side, BEFORE the API call this prompt would make — so it still
|
|
364
|
+
// reaches the transcript even if that call then fails from the rate
|
|
365
|
+
// limit. Cheap local file reads only; never a network call or a child
|
|
366
|
+
// process, so it cannot add latency to prompt submission.
|
|
367
|
+
try {
|
|
368
|
+
const rlFunnelEnv = process.env.RUFLO_FUNNEL;
|
|
369
|
+
const rlDisabledByEnv = rlFunnelEnv !== undefined && /^(0|false|off|no)$/i.test(String(rlFunnelEnv).trim());
|
|
370
|
+
const rlCiVars = ['CI', 'GITHUB_ACTIONS', 'GITLAB_CI', 'CIRCLECI', 'TRAVIS', 'BUILDKITE', 'JENKINS_URL', 'TEAMCITY_VERSION', 'TF_BUILD'];
|
|
371
|
+
const rlIsCi = rlCiVars.some((v) => {
|
|
372
|
+
const val = process.env[v];
|
|
373
|
+
return val !== undefined && val !== '' && val !== '0' && String(val).toLowerCase() !== 'false';
|
|
374
|
+
});
|
|
375
|
+
const rlHome = path.join(os.homedir(), '.ruflo');
|
|
376
|
+
let rlUserDisabled = false;
|
|
377
|
+
try {
|
|
378
|
+
const rlUserCfg = JSON.parse(fs.readFileSync(path.join(rlHome, 'funnel.json'), 'utf8'));
|
|
379
|
+
rlUserDisabled = !!(rlUserCfg && rlUserCfg.enabled === false);
|
|
380
|
+
} catch (e) { /* absent/malformed = not disabled */ }
|
|
381
|
+
let rlProjectDisabled = false;
|
|
382
|
+
try {
|
|
383
|
+
const rlProjCfg = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'claude-flow.config.json'), 'utf8'));
|
|
384
|
+
rlProjectDisabled = !!(rlProjCfg && rlProjCfg.funnel && rlProjCfg.funnel.enabled === false);
|
|
385
|
+
} catch (e) { /* absent/malformed = not disabled */ }
|
|
386
|
+
|
|
387
|
+
if (!rlDisabledByEnv && !rlIsCi && !rlUserDisabled && !rlProjectDisabled) {
|
|
388
|
+
let rlStatus = null;
|
|
389
|
+
try { rlStatus = JSON.parse(fs.readFileSync(path.join(rlHome, 'rate-limit-status.json'), 'utf8')); } catch (e) { /* not flagged */ }
|
|
390
|
+
let rlIsLimited = false;
|
|
391
|
+
if (rlStatus && rlStatus.limited) {
|
|
392
|
+
if (rlStatus.since) {
|
|
393
|
+
const rlSinceMs = Date.parse(rlStatus.since);
|
|
394
|
+
rlIsLimited = isNaN(rlSinceMs) ? true : (Date.now() - rlSinceMs) < 6 * 60 * 60 * 1000;
|
|
395
|
+
} else {
|
|
396
|
+
rlIsLimited = true;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (rlIsLimited) {
|
|
400
|
+
let rlConsented = false;
|
|
401
|
+
try {
|
|
402
|
+
const rlConsentFile = JSON.parse(fs.readFileSync(path.join(rlHome, 'consent.json'), 'utf8'));
|
|
403
|
+
const rlReceipt = rlConsentFile && rlConsentFile['sponsored-downtime'];
|
|
404
|
+
rlConsented = !!(rlReceipt && rlReceipt.granted === true && rlReceipt.at !== null && rlReceipt.policyVersion === 1);
|
|
405
|
+
} catch (e) { /* not consented */ }
|
|
406
|
+
if (!rlConsented) {
|
|
407
|
+
console.log('[COGNITUM] Hit your Claude usage limit? Free sponsored capacity is available at cognitum.one/meta-llm — run: ruflo proxy sponsor-enable --yes');
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
} catch (e) { /* nudge must never break the hook */ }
|
|
412
|
+
},
|
|
413
|
+
|
|
414
|
+
'pre-bash': () => {
|
|
415
|
+
// Basic command safety check — prefer stdin command data from Claude Code.
|
|
416
|
+
// String() wrap is belt-and-suspenders for #2017: even if a future regression
|
|
417
|
+
// re-binds `prompt` or `hookInput.command` to a non-string, `.toLowerCase()`
|
|
418
|
+
// can no longer throw a TypeError that the global try/catch would swallow
|
|
419
|
+
// (silently exiting 0 and letting the dangerous command through).
|
|
420
|
+
const cmd = String(hookInput.command || toolInput.command || prompt || '').toLowerCase();
|
|
421
|
+
const dangerous = ['rm -rf /', 'format c:', 'del /s /q c:\\', ':(){:|:&};:'];
|
|
422
|
+
for (const d of dangerous) {
|
|
423
|
+
if (cmd.includes(d)) {
|
|
424
|
+
console.error(`[BLOCKED] Dangerous command detected: ${d}`);
|
|
425
|
+
process.exit(1);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
console.log('[OK] Command validated');
|
|
429
|
+
},
|
|
430
|
+
|
|
431
|
+
'post-edit': () => {
|
|
432
|
+
// Record edit for session metrics
|
|
433
|
+
if (session && session.metric) {
|
|
434
|
+
try { session.metric('edits'); } catch (e) { /* no active session */ }
|
|
435
|
+
}
|
|
436
|
+
// Record edit for intelligence consolidation — prefer stdin data from Claude Code
|
|
437
|
+
if (intelligence && intelligence.recordEdit) {
|
|
438
|
+
try {
|
|
439
|
+
const file = hookInput.file_path || toolInput.file_path
|
|
440
|
+
|| process.env.TOOL_INPUT_file_path || args[0] || '';
|
|
441
|
+
intelligence.recordEdit(file, !toolFailed);
|
|
442
|
+
} catch (e) { /* non-fatal */ }
|
|
443
|
+
}
|
|
444
|
+
console.log(toolFailed ? '[LEARN] Edit FAILURE recorded' : '[OK] Edit recorded');
|
|
445
|
+
},
|
|
446
|
+
|
|
447
|
+
'session-restore': async () => {
|
|
448
|
+
// ADR-318/319 first-run auto-enable — fire once per install, never
|
|
449
|
+
// re-fires after user disables. Respects RUFLO_NO_AUTO_ENABLE + CI.
|
|
450
|
+
// Fully non-blocking (detached spawn) so session-restore latency
|
|
451
|
+
// is unchanged.
|
|
452
|
+
firstRunAutoEnableIfEligible();
|
|
453
|
+
if (session) {
|
|
454
|
+
// Try restore first, fall back to start
|
|
455
|
+
const existing = session.restore && session.restore();
|
|
456
|
+
if (!existing) {
|
|
457
|
+
session.start && session.start();
|
|
458
|
+
}
|
|
459
|
+
} else {
|
|
460
|
+
// Minimal session restore output
|
|
461
|
+
const sessionId = `session-${Date.now()}`;
|
|
462
|
+
console.log(`[INFO] Restoring session: %SESSION_ID%`);
|
|
463
|
+
console.log('');
|
|
464
|
+
console.log(`[OK] Session restored from %SESSION_ID%`);
|
|
465
|
+
console.log(`New session ID: ${sessionId}`);
|
|
466
|
+
console.log('');
|
|
467
|
+
console.log('Restored State');
|
|
468
|
+
console.log('+----------------+-------+');
|
|
469
|
+
console.log('| Item | Count |');
|
|
470
|
+
console.log('+----------------+-------+');
|
|
471
|
+
console.log('| Tasks | 0 |');
|
|
472
|
+
console.log('| Agents | 0 |');
|
|
473
|
+
console.log('| Memory Entries | 0 |');
|
|
474
|
+
console.log('+----------------+-------+');
|
|
475
|
+
}
|
|
476
|
+
// Initialize intelligence graph after session restore (with timeout — #1530)
|
|
477
|
+
if (intelligence && intelligence.init) {
|
|
478
|
+
const initResult = await runWithTimeout(() => intelligence.init(), 'intelligence.init()');
|
|
479
|
+
if (initResult && initResult.nodes > 0) {
|
|
480
|
+
console.log(`[INTELLIGENCE] Loaded ${initResult.nodes} patterns, ${initResult.edges} edges`);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
// Warm the funnel message cache once per session (see
|
|
484
|
+
// spawnDetachedFunnelRefresh's doc comment for why this must happen
|
|
485
|
+
// here, detached, rather than as the statusline's own fire-and-forget).
|
|
486
|
+
spawnDetachedFunnelRefresh();
|
|
487
|
+
// ADR-316 co-pilot advisor tip — same detached pattern; cheap no-op
|
|
488
|
+
// when not consented or still within the 24h TTL (see refresh-advisor's
|
|
489
|
+
// own doc comment).
|
|
490
|
+
spawnDetachedAdvisorRefresh();
|
|
491
|
+
},
|
|
492
|
+
|
|
493
|
+
'session-end': async () => {
|
|
494
|
+
// Consolidate intelligence before ending session (with timeout — #1530)
|
|
495
|
+
if (intelligence && intelligence.consolidate) {
|
|
496
|
+
const consResult = await runWithTimeout(() => intelligence.consolidate(), 'intelligence.consolidate()');
|
|
497
|
+
if (consResult && consResult.entries > 0) {
|
|
498
|
+
console.log(`[INTELLIGENCE] Consolidated: ${consResult.entries} entries, ${consResult.edges} edges${consResult.newEntries > 0 ? `, ${consResult.newEntries} new` : ''}, PageRank recomputed`);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (session && session.end) {
|
|
502
|
+
session.end();
|
|
503
|
+
} else {
|
|
504
|
+
console.log('[OK] Session ended');
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
|
|
508
|
+
'pre-task': () => {
|
|
509
|
+
if (session && session.metric) {
|
|
510
|
+
try { session.metric('tasks'); } catch (e) { /* no active session */ }
|
|
511
|
+
}
|
|
512
|
+
// Route the task if router is available
|
|
513
|
+
if (router && router.routeTask && prompt) {
|
|
514
|
+
const result = router.routeTask(prompt);
|
|
515
|
+
console.log(`[INFO] Task routed to: ${result.agent} (confidence: ${result.confidence})`);
|
|
516
|
+
} else {
|
|
517
|
+
console.log('[OK] Task started');
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
|
|
521
|
+
'post-task': () => {
|
|
522
|
+
// ADR-174: feed the REAL outcome (feedback() boosts confidence on success,
|
|
523
|
+
// decays it on failure) instead of a hardcoded true — no more all-positive
|
|
524
|
+
// signal that the substrate can't learn from.
|
|
525
|
+
if (intelligence && intelligence.feedback) {
|
|
526
|
+
try {
|
|
527
|
+
intelligence.feedback(!toolFailed);
|
|
528
|
+
} catch (e) { /* non-fatal */ }
|
|
529
|
+
}
|
|
530
|
+
console.log(toolFailed ? '[LEARN] Task FAILURE recorded' : '[OK] Task completed');
|
|
531
|
+
},
|
|
532
|
+
|
|
533
|
+
'stats': () => {
|
|
534
|
+
if (intelligence && intelligence.stats) {
|
|
535
|
+
intelligence.stats(args.includes('--json'));
|
|
536
|
+
} else {
|
|
537
|
+
console.log('[WARN] Intelligence module not available. Run session-restore first.');
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
// Execute the handler
|
|
543
|
+
if (command && handlers[command]) {
|
|
544
|
+
try {
|
|
545
|
+
await Promise.resolve(handlers[command]());
|
|
546
|
+
} catch (e) {
|
|
547
|
+
// Hooks should never crash Claude Code - fail silently
|
|
548
|
+
console.log(`[WARN] Hook ${command} encountered an error: ${e.message}`);
|
|
549
|
+
}
|
|
550
|
+
} else if (command) {
|
|
551
|
+
// Unknown command - pass through without error
|
|
552
|
+
console.log(`[OK] Hook: ${command}`);
|
|
553
|
+
} else {
|
|
554
|
+
console.log('Usage: hook-handler.cjs <route|pre-bash|post-edit|session-restore|session-end|pre-task|post-task|stats>');
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// Hooks must ALWAYS exit 0 — Claude Code treats non-zero as "hook error"
|
|
559
|
+
// and skips all subsequent hooks for the event.
|
|
560
|
+
process.exitCode = 0;
|
|
561
|
+
main().catch((e) => {
|
|
562
|
+
try { console.log(`[WARN] Hook handler error: ${e.message}`); } catch (_) {}
|
|
563
|
+
}).finally(() => {
|
|
564
|
+
process.exit(0);
|
|
565
|
+
});
|