agentic-qe 3.12.3 → 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.
Files changed (386) hide show
  1. package/.claude/helpers/.helpers-version +1 -1
  2. package/.claude/helpers/auto-memory-hook.mjs +430 -430
  3. package/.claude/helpers/helpers.manifest.json +6 -5
  4. package/.claude/helpers/hook-handler.cjs +565 -311
  5. package/.claude/helpers/intelligence.cjs +1058 -1058
  6. package/.claude/helpers/statusline.cjs +995 -682
  7. package/.claude/skills/qe-court/SKILL.md +186 -0
  8. package/.claude/skills/qe-court/config.json +27 -0
  9. package/.claude/skills/qe-court/evals/fixtures/seeded-mutant-delivery/README.md +38 -0
  10. package/.claude/skills/qe-court/evals/fixtures/seeded-mutant-delivery/budget.test.ts +21 -0
  11. package/.claude/skills/qe-court/evals/fixtures/seeded-mutant-delivery/budget.ts +25 -0
  12. package/.claude/skills/qe-court/evals/qe-court.yaml +70 -0
  13. package/.claude/skills/qe-court/schemas/output.json +92 -0
  14. package/.claude/skills/qe-court/scripts/validate-config.json +30 -0
  15. package/.claude/skills/skills-manifest.json +9 -8
  16. package/CHANGELOG.md +65 -0
  17. package/README.md +3 -3
  18. package/assets/skills/qe-court/SKILL.md +186 -0
  19. package/assets/skills/qe-court/config.json +27 -0
  20. package/assets/skills/qe-court/evals/fixtures/seeded-mutant-delivery/README.md +38 -0
  21. package/assets/skills/qe-court/evals/fixtures/seeded-mutant-delivery/budget.test.ts +21 -0
  22. package/assets/skills/qe-court/evals/fixtures/seeded-mutant-delivery/budget.ts +25 -0
  23. package/assets/skills/qe-court/evals/qe-court.yaml +70 -0
  24. package/assets/skills/qe-court/schemas/output.json +92 -0
  25. package/assets/skills/qe-court/scripts/validate-config.json +30 -0
  26. package/assets/skills/skills-manifest.json +9 -8
  27. package/dist/cli/bundle.js +5 -5
  28. package/dist/cli/chunks/adapter-CWIMFWAI.js +2 -0
  29. package/dist/cli/chunks/{agent-booster-wasm-XFAQATTH.js → agent-booster-wasm-ACX2DK7Y.js} +2 -2
  30. package/dist/cli/chunks/{agent-handler-2ZV4CA3U.js → agent-handler-B45WP4ZJ.js} +2 -2
  31. package/dist/cli/chunks/{agent-memory-branch-6WGP7F5T.js → agent-memory-branch-QQLZDE56.js} +2 -2
  32. package/dist/cli/chunks/aqe-learning-engine-OTXT2DLN.js +2 -0
  33. package/dist/cli/chunks/{arena-FWX7XZAE.js → arena-G3IKZAG5.js} +4 -4
  34. package/dist/cli/chunks/{arena-KJUNQK4N.js → arena-SDB7723R.js} +2 -2
  35. package/dist/cli/chunks/{audit-YFUDEOKN.js → audit-GY46XUZA.js} +3 -3
  36. package/dist/cli/chunks/base-O3SPSWBA.js +2 -0
  37. package/dist/cli/chunks/{hnswlib-node-SKTT5KIH.js → better-sqlite3-DUZ6FFAH.js} +2 -2
  38. package/dist/cli/chunks/{brain-handler-ZCK4WTPK.js → brain-handler-347CYMPN.js} +3 -3
  39. package/dist/cli/chunks/{branch-enumerator-HTVINRYG.js → branch-enumerator-Z3ULBFSM.js} +2 -2
  40. package/dist/cli/chunks/{browser-WUL2B77M.js → browser-OYEIHD7F.js} +2 -2
  41. package/dist/cli/chunks/browser-workflow-MXS3ZKY2.js +2 -0
  42. package/dist/cli/chunks/{chunk-OBL6W4Z5.js → chunk-2DIT5AUU.js} +2 -2
  43. package/dist/cli/chunks/{chunk-IWQHQLT6.js → chunk-2NRZYQSF.js} +2 -2
  44. package/dist/cli/chunks/chunk-2VQVEQS4.js +153 -0
  45. package/dist/cli/chunks/{chunk-E2U3LTGM.js → chunk-32ZGV4Q4.js} +1 -1
  46. package/dist/cli/chunks/{chunk-VUCVSKJC.js → chunk-34PEINFS.js} +2 -2
  47. package/dist/cli/chunks/{chunk-XUUVAAHV.js → chunk-3GSYD5SL.js} +2 -2
  48. package/dist/cli/chunks/{chunk-MOX25RZQ.js → chunk-3JVUWKCO.js} +2 -2
  49. package/dist/cli/chunks/{chunk-RLBNAB6Y.js → chunk-3K4SF57Q.js} +1 -1
  50. package/dist/cli/chunks/{chunk-MSDIIRLM.js → chunk-3NOCK6ED.js} +2 -2
  51. package/dist/cli/chunks/{chunk-3YC4YUGB.js → chunk-3UHEZ5HZ.js} +2 -2
  52. package/dist/cli/chunks/{chunk-J2RJOJ5Q.js → chunk-4BDLD7V2.js} +1 -1
  53. package/dist/cli/chunks/{chunk-ZGKQCUPB.js → chunk-4BESADKE.js} +2 -2
  54. package/dist/cli/chunks/{chunk-PDX7IYTJ.js → chunk-54MFKCLT.js} +2 -2
  55. package/dist/cli/chunks/{chunk-TP3UAWMB.js → chunk-56WZFXTQ.js} +2 -2
  56. package/dist/cli/chunks/{chunk-WFPGIP4N.js → chunk-5EIOQCGN.js} +2 -2
  57. package/dist/cli/chunks/{chunk-32L7DKNQ.js → chunk-5FLTZ3KT.js} +2 -2
  58. package/dist/cli/chunks/{chunk-Y5L37K7X.js → chunk-5ICQL42E.js} +2 -2
  59. package/dist/cli/chunks/{chunk-Y625LP6K.js → chunk-5KAT6WBQ.js} +2 -2
  60. package/dist/cli/chunks/{chunk-UIHZ34SJ.js → chunk-6AOBLBR4.js} +2 -2
  61. package/dist/cli/chunks/{chunk-7WF3TW3G.js → chunk-6DTOGSDV.js} +4 -4
  62. package/dist/cli/chunks/{chunk-NAMJGRGC.js → chunk-6SXKCIN5.js} +2 -2
  63. package/dist/cli/chunks/{chunk-FTM562PF.js → chunk-7DMXCCSD.js} +1 -1
  64. package/dist/cli/chunks/{chunk-KE3RK35K.js → chunk-7UNY32PU.js} +1 -1
  65. package/dist/cli/chunks/{chunk-BSNNTOHY.js → chunk-7YXT6BXN.js} +3 -3
  66. package/dist/cli/chunks/{chunk-DZ775UGW.js → chunk-A4QLGPYO.js} +2 -2
  67. package/dist/cli/chunks/{chunk-SFS3UHNF.js → chunk-A7GLWWSE.js} +1 -1
  68. package/dist/cli/chunks/{chunk-WKE6WL5C.js → chunk-ANIDFJCT.js} +3 -3
  69. package/dist/cli/chunks/{chunk-XDHGCBTS.js → chunk-ANYYTWOQ.js} +2 -2
  70. package/dist/cli/chunks/{chunk-NLDLUHOF.js → chunk-AO7AHX6K.js} +2 -2
  71. package/dist/cli/chunks/{chunk-Z3SXMYVI.js → chunk-BCKTBGDM.js} +3 -3
  72. package/dist/cli/chunks/{chunk-UGW23T6S.js → chunk-BGYLNCL6.js} +2 -2
  73. package/dist/cli/chunks/{chunk-KVHCWH4H.js → chunk-BOVH6WSM.js} +2 -2
  74. package/dist/cli/chunks/{chunk-L2X3BWMN.js → chunk-BUGWPTMF.js} +2 -2
  75. package/dist/cli/chunks/{chunk-DTZFZ5M7.js → chunk-CFVEDUTW.js} +2 -2
  76. package/dist/cli/chunks/{chunk-CL6SNCFF.js → chunk-CPH5JP4L.js} +1 -1
  77. package/dist/cli/chunks/{chunk-AIWRYWK2.js → chunk-CQFT7H3F.js} +2 -2
  78. package/dist/cli/chunks/{chunk-BQ2K4BPD.js → chunk-CWUBOLKY.js} +2 -2
  79. package/dist/cli/chunks/{chunk-2LNDU7AW.js → chunk-CYL2FV23.js} +2 -2
  80. package/dist/cli/chunks/{chunk-YEC55GO5.js → chunk-D3MPV5G7.js} +2 -2
  81. package/dist/cli/chunks/{chunk-DMD6WVJ2.js → chunk-DRIJYTSK.js} +2 -2
  82. package/dist/cli/chunks/{chunk-PXCJDB7J.js → chunk-DYUC7WFA.js} +1 -1
  83. package/dist/cli/chunks/{chunk-EOUJ6X5H.js → chunk-E3B5XTXJ.js} +1 -1
  84. package/dist/cli/chunks/{chunk-PSDH7CIL.js → chunk-EECM5XKY.js} +1 -1
  85. package/dist/cli/chunks/{chunk-E53UR2EW.js → chunk-EFRESRLB.js} +3 -3
  86. package/dist/cli/chunks/{chunk-SGMJ277D.js → chunk-ES7WCYOU.js} +1 -1
  87. package/dist/cli/chunks/{chunk-DDYP6FBC.js → chunk-FAQLI3P5.js} +2 -2
  88. package/dist/cli/chunks/{chunk-CXMOIE7D.js → chunk-FBBZHATF.js} +2 -2
  89. package/dist/cli/chunks/{chunk-KKOFH26C.js → chunk-FL3BM54K.js} +1 -1
  90. package/dist/cli/chunks/{chunk-MB7TZQW3.js → chunk-FQLWQWRU.js} +3 -3
  91. package/dist/cli/chunks/{chunk-GMFFMJD6.js → chunk-FQY3UTGA.js} +2 -2
  92. package/dist/cli/chunks/{chunk-SPI4LUJ6.js → chunk-FUU32QY5.js} +2 -2
  93. package/dist/cli/chunks/{chunk-RSZOCQOL.js → chunk-G4GTE3RJ.js} +2 -2
  94. package/dist/cli/chunks/{chunk-NOSQI2OW.js → chunk-G5DFYX3J.js} +3 -3
  95. package/dist/cli/chunks/{chunk-OPG2HV2W.js → chunk-G7FMYFTN.js} +1 -1
  96. package/dist/cli/chunks/{chunk-N4ML23ZG.js → chunk-GFBLWFRV.js} +1 -1
  97. package/dist/cli/chunks/{chunk-LNIHLNW4.js → chunk-GJMZR7WU.js} +3 -3
  98. package/dist/cli/chunks/{chunk-PTPN6HQ7.js → chunk-GTUFX7AR.js} +2 -2
  99. package/dist/cli/chunks/{chunk-67BCEHU5.js → chunk-GUEZQOHL.js} +1 -1
  100. package/dist/cli/chunks/{chunk-RE42RJYR.js → chunk-HL2QMM4M.js} +2 -2
  101. package/dist/cli/chunks/{chunk-QILF6BZH.js → chunk-HOKON5EL.js} +2 -2
  102. package/dist/cli/chunks/{chunk-YOG5KQZF.js → chunk-HTPM3URI.js} +2 -2
  103. package/dist/cli/chunks/chunk-HVB2L52I.js +2 -0
  104. package/dist/cli/chunks/{chunk-DHUZHT5D.js → chunk-IHQTXJAQ.js} +1 -1
  105. package/dist/cli/chunks/{chunk-SV7J5FDW.js → chunk-IPHLXAMX.js} +2 -2
  106. package/dist/cli/chunks/{chunk-Y6XNISHP.js → chunk-IYDYJ33J.js} +2 -2
  107. package/dist/cli/chunks/{chunk-CYSBM52D.js → chunk-IZRLIWFN.js} +2 -2
  108. package/dist/cli/chunks/{chunk-MS6VOSPY.js → chunk-J3L52EA4.js} +5 -5
  109. package/dist/cli/chunks/{chunk-WQASUQ5P.js → chunk-JGM6XCCP.js} +1 -1
  110. package/dist/cli/chunks/chunk-JPIBPKBP.js +54 -0
  111. package/dist/cli/chunks/{chunk-TXLPOXAN.js → chunk-K5N6SLHO.js} +1 -1
  112. package/dist/cli/chunks/{chunk-R6WMGSEK.js → chunk-KSYLRM4Q.js} +2 -2
  113. package/dist/cli/chunks/{chunk-2CPJCXV6.js → chunk-KUA4HHU6.js} +2 -2
  114. package/dist/cli/chunks/{chunk-WUE53ZPH.js → chunk-KVL63BSU.js} +1 -1
  115. package/dist/cli/chunks/{chunk-6SUSRXXF.js → chunk-KZTBNDNE.js} +1 -1
  116. package/dist/cli/chunks/{chunk-M7W6VJ65.js → chunk-L2SFGFE6.js} +1 -1
  117. package/dist/cli/chunks/{chunk-XZGOXLZH.js → chunk-L4LLA5U7.js} +1 -1
  118. package/dist/cli/chunks/{chunk-AZ24ONMX.js → chunk-L4S722JD.js} +1 -1
  119. package/dist/cli/chunks/{chunk-HJ4U64BL.js → chunk-LBE2P6UC.js} +2 -2
  120. package/dist/cli/chunks/{chunk-KA4EAMMQ.js → chunk-LOXVVMS4.js} +3 -3
  121. package/dist/cli/chunks/{chunk-UGXHMQ6P.js → chunk-LWYLW7RX.js} +2 -2
  122. package/dist/cli/chunks/{chunk-HJ2LG5IH.js → chunk-LXPB7H2P.js} +1 -1
  123. package/dist/cli/chunks/{chunk-WBZNLFTV.js → chunk-MBCGI3M2.js} +3 -3
  124. package/dist/cli/chunks/{chunk-7XUM4LBC.js → chunk-MVI2QMRW.js} +1 -1
  125. package/dist/cli/chunks/{chunk-2OX74DOO.js → chunk-N5MMBA35.js} +1 -1
  126. package/dist/cli/chunks/{chunk-VSD6JE2H.js → chunk-N7VOOI3U.js} +2 -2
  127. package/dist/cli/chunks/{chunk-ROFCS47F.js → chunk-NETN3OUG.js} +1 -1
  128. package/dist/cli/chunks/chunk-NQNKKVNO.js +29 -0
  129. package/dist/cli/chunks/{chunk-NJDLJ3KD.js → chunk-NUQBJGGF.js} +2 -2
  130. package/dist/cli/chunks/chunk-OETDMOOE.js +2 -0
  131. package/dist/cli/chunks/{chunk-4EHW4TNA.js → chunk-OXXMVQDF.js} +2 -2
  132. package/dist/cli/chunks/{chunk-6HQDPDN5.js → chunk-OZR25R7W.js} +2 -2
  133. package/dist/cli/chunks/{chunk-UZ7FXVH5.js → chunk-PERJO2DY.js} +1 -1
  134. package/dist/cli/chunks/{chunk-XQ5JT7KM.js → chunk-PP2RYSHT.js} +3 -3
  135. package/dist/cli/chunks/{chunk-DCYBV6HV.js → chunk-Q7PBGNUD.js} +1 -1
  136. package/dist/cli/chunks/{chunk-LCM7TY76.js → chunk-QCEW4ZDW.js} +2 -2
  137. package/dist/cli/chunks/{chunk-NKTLKMUB.js → chunk-QI4CGJNK.js} +1 -1
  138. package/dist/cli/chunks/{chunk-NT66CT73.js → chunk-QQB55ZJJ.js} +2 -2
  139. package/dist/cli/chunks/{chunk-KRS4KGX5.js → chunk-QTU3CVOB.js} +2 -2
  140. package/dist/cli/chunks/{chunk-DW7OI5IF.js → chunk-QWYISZTN.js} +2 -2
  141. package/dist/cli/chunks/{chunk-KNWBRMLL.js → chunk-R3GEXYO4.js} +2 -2
  142. package/dist/cli/chunks/{chunk-YUDGQZJN.js → chunk-RDU4WTV2.js} +2 -2
  143. package/dist/cli/chunks/{chunk-VFYMWDSJ.js → chunk-RJZRWVL4.js} +1 -1
  144. package/dist/cli/chunks/{chunk-D4GMAUTP.js → chunk-RLCWR7TS.js} +10 -10
  145. package/dist/cli/chunks/{chunk-YDYKFSD2.js → chunk-RSFIOR2I.js} +10 -10
  146. package/dist/cli/chunks/{chunk-EHO52NKU.js → chunk-RVJPWRV6.js} +2 -2
  147. package/dist/cli/chunks/{chunk-KGHSKDC7.js → chunk-RVRBTOWX.js} +2 -2
  148. package/dist/cli/chunks/{chunk-2YDZXFO2.js → chunk-SHCTEXNH.js} +2 -2
  149. package/dist/cli/chunks/chunk-SNTUKW4Q.js +2 -0
  150. package/dist/cli/chunks/{chunk-MOXKKY5Q.js → chunk-SRQ3CPJE.js} +4 -4
  151. package/dist/cli/chunks/{chunk-GS6G7AVS.js → chunk-THBTN7XB.js} +2 -2
  152. package/dist/cli/chunks/{chunk-LHAUFY4Y.js → chunk-TNRIGQ6U.js} +2 -2
  153. package/dist/cli/chunks/{chunk-UAPUA6OY.js → chunk-TVMFH5N2.js} +2 -2
  154. package/dist/cli/chunks/{chunk-HGJQSTQD.js → chunk-TZ73SXQ5.js} +1 -1
  155. package/dist/cli/chunks/{chunk-CHFTHSMM.js → chunk-TZPKTRJB.js} +2 -2
  156. package/dist/cli/chunks/{chunk-GV2BS5NC.js → chunk-U2SW6KK5.js} +2 -2
  157. package/dist/cli/chunks/{chunk-BDGKB2PT.js → chunk-UIPPJKON.js} +2 -2
  158. package/dist/cli/chunks/{chunk-FXOOOJQD.js → chunk-UMG5URNV.js} +1 -1
  159. package/dist/cli/chunks/{chunk-7Q74K3HZ.js → chunk-UNIBND6A.js} +1 -1
  160. package/dist/cli/chunks/{chunk-LGYEOYQJ.js → chunk-USMDIIHY.js} +2 -2
  161. package/dist/cli/chunks/{chunk-2HCMRGMO.js → chunk-VC6EXDGY.js} +2 -2
  162. package/dist/cli/chunks/{chunk-5FAWIIWF.js → chunk-VHYMSZNF.js} +2 -2
  163. package/dist/cli/chunks/{chunk-ZTKCGEB6.js → chunk-VLBV2VL3.js} +1 -1
  164. package/dist/cli/chunks/{chunk-6E47R27C.js → chunk-VLNPJAVH.js} +1 -1
  165. package/dist/cli/chunks/{chunk-EH7TSJPS.js → chunk-VSNRPMAZ.js} +2 -2
  166. package/dist/cli/chunks/{chunk-FJACKKRL.js → chunk-W5YEIHIO.js} +2 -2
  167. package/dist/cli/chunks/{chunk-4HP7N6SP.js → chunk-WRYT4HTZ.js} +2 -2
  168. package/dist/cli/chunks/{chunk-ZFLE4D4X.js → chunk-XFCWYQHW.js} +2 -2
  169. package/dist/cli/chunks/{chunk-72QQDR3Y.js → chunk-XKFE3FLI.js} +2 -2
  170. package/dist/cli/chunks/{chunk-KXKACV3E.js → chunk-YFGAHNCG.js} +2 -2
  171. package/dist/cli/chunks/{chunk-S47YGWXK.js → chunk-YPTGE5NJ.js} +2 -2
  172. package/dist/cli/chunks/{chunk-PEHEANAM.js → chunk-YRQLVGCI.js} +2 -2
  173. package/dist/cli/chunks/{chunk-L6GZGEFQ.js → chunk-Z6QCOZ2H.js} +2 -2
  174. package/dist/cli/chunks/{chunk-GGTCD4MA.js → chunk-ZCFZ4USU.js} +1 -1
  175. package/dist/cli/chunks/{chunk-MZ7SIO6R.js → chunk-ZEIG5IQ4.js} +2 -2
  176. package/dist/cli/chunks/{chunk-XBOCRCC6.js → chunk-ZJG6N2OK.js} +1 -1
  177. package/dist/cli/chunks/{chunk-M32DTUZM.js → chunk-ZJIX5FGQ.js} +3 -3
  178. package/dist/cli/chunks/{chunk-ADQFQBFJ.js → chunk-ZLXBNNNT.js} +2 -2
  179. package/dist/cli/chunks/{chunk-BEPP57C2.js → chunk-ZOXWASCC.js} +2 -2
  180. package/dist/cli/chunks/{ci-MMLUV6L6.js → ci-74ZUCO5V.js} +2 -2
  181. package/dist/cli/chunks/{ci-output-25GS6RXR.js → ci-output-HD6IZNJA.js} +2 -2
  182. package/dist/cli/chunks/{circuit-breaker-4OWAN6R6.js → circuit-breaker-USZVMA42.js} +2 -2
  183. package/dist/cli/chunks/{claude-flow-setup-LR3SRBX6.js → claude-flow-setup-S4XKNCD5.js} +2 -2
  184. package/dist/cli/chunks/client-33PGO5FA.js +2 -0
  185. package/dist/cli/chunks/{cline-installer-YSZWRZUI.js → cline-installer-6EW4CHAR.js} +2 -2
  186. package/dist/cli/chunks/{code-UUWUIXI7.js → code-TOLWD2XL.js} +2 -2
  187. package/dist/cli/chunks/{code-index-extractor-2LSPQORU.js → code-index-extractor-UA4QQ7B3.js} +2 -2
  188. package/dist/cli/chunks/{codex-installer-E5BVXZVA.js → codex-installer-C2CUP4FW.js} +2 -2
  189. package/dist/cli/chunks/{completions-YKXBKZSO.js → completions-KVUMQQ4K.js} +2 -2
  190. package/dist/cli/chunks/{complexity-analyzer-HNT2QRWB.js → complexity-analyzer-DFH6LMK2.js} +2 -2
  191. package/dist/cli/chunks/{continuedev-installer-AW5VCB66.js → continuedev-installer-LYDQSAU7.js} +2 -2
  192. package/dist/cli/chunks/{copilot-installer-B6SVZXQT.js → copilot-installer-7USXLZHZ.js} +2 -2
  193. package/dist/cli/chunks/core-handlers-CSNZIM3A.js +2 -0
  194. package/dist/cli/chunks/{cost-tracker-POZMBN2V.js → cost-tracker-JBDIUMKZ.js} +2 -2
  195. package/dist/cli/chunks/{coverage-V5BGPN5Q.js → coverage-RGO3K357.js} +3 -3
  196. package/dist/cli/chunks/cross-domain-router-DRIBR5L3.js +2 -0
  197. package/dist/cli/chunks/{cursor-installer-EYBI4QVK.js → cursor-installer-YEZGD37F.js} +2 -2
  198. package/dist/cli/chunks/{daemon-CF6ENQB2.js → daemon-FVETQ3LL.js} +3 -3
  199. package/dist/cli/chunks/{daemon-HKARXY2W.js → daemon-LPEXHNYG.js} +4 -4
  200. package/dist/cli/chunks/{dag-attention-scheduler-XIL5IAP7.js → dag-attention-scheduler-UKYE2FII.js} +2 -2
  201. package/dist/cli/chunks/{detect-RRX2U2KK.js → detect-WBG5P7ER.js} +2 -2
  202. package/dist/cli/chunks/{dist-node-DOANNRCS.js → dist-node-YW6YRBCU.js} +2 -2
  203. package/dist/cli/chunks/{domain-handler-QMTJV5OR.js → domain-handler-HH7J4A32.js} +2 -2
  204. package/dist/cli/chunks/{domain-transfer-FSNH75XW.js → domain-transfer-V34GXD5I.js} +2 -2
  205. package/dist/cli/chunks/dream-WUNO723O.js +2 -0
  206. package/dist/cli/chunks/{embed-and-insert-pattern-NI7PGONV.js → embed-and-insert-pattern-WYLRS3CL.js} +2 -2
  207. package/dist/cli/chunks/{eval-6ZAF2RY3.js → eval-EIMVXY5J.js} +2 -2
  208. package/dist/cli/chunks/{experience-capture-middleware-JMXR7N5G.js → experience-capture-middleware-QMZHRUKM.js} +3 -3
  209. package/dist/cli/chunks/{fast-paths-YB7XZZ76.js → fast-paths-NHLW6XS6.js} +2 -2
  210. package/dist/cli/chunks/{feature-flags-KJSP7KR6.js → feature-flags-N3UHMSZ3.js} +2 -2
  211. package/dist/cli/chunks/{feature-flags-2RC4GFC4.js → feature-flags-NE3MBL3P.js} +2 -2
  212. package/dist/cli/chunks/{file-discovery-SUPBXFYI.js → file-discovery-SI44X4YS.js} +2 -2
  213. package/dist/cli/chunks/{fleet-KSXFOLFW.js → fleet-MMYUXRRM.js} +3 -3
  214. package/dist/cli/chunks/{gnn-wrapper-DFZ5KPPK.js → gnn-wrapper-RLYXYU2Q.js} +2 -2
  215. package/dist/cli/chunks/{heartbeat-handler-G3EADK2H.js → heartbeat-handler-6EDRUYLV.js} +4 -4
  216. package/dist/cli/chunks/heartbeat-scheduler-VAFQDJLL.js +2 -0
  217. package/dist/cli/chunks/hnsw-adapter-TIRPA7XE.js +2 -0
  218. package/dist/cli/chunks/hnsw-index-SSQBRQCQ.js +2 -0
  219. package/dist/cli/chunks/{hnsw-legacy-bridge-MA676GER.js → hnsw-legacy-bridge-RVM7EAIH.js} +2 -2
  220. package/dist/cli/chunks/{better-sqlite3-FE55OGYB.js → hnswlib-node-RJPBJU2Q.js} +2 -2
  221. package/dist/cli/chunks/{hooks-HTCPMZNZ.js → hooks-ZF4VKHEO.js} +10 -10
  222. package/dist/cli/chunks/hybrid-router-AKBWZOQ3.js +2 -0
  223. package/dist/cli/chunks/{hypergraph-engine-QPB3IH4A.js → hypergraph-engine-YWS66PGO.js} +2 -2
  224. package/dist/cli/chunks/{hypergraph-handler-GBFSVD7N.js → hypergraph-handler-OQHVRPWB.js} +3 -3
  225. package/dist/cli/chunks/impact-analyzer-46FQIZ6Y.js +2 -0
  226. package/dist/cli/chunks/{init-handler-XYBTBCPD.js → init-handler-YW74YF2V.js} +6 -6
  227. package/dist/cli/chunks/init-wizard-U3NHGYSS.js +2 -0
  228. package/dist/cli/chunks/kernel-ZDXHT6QF.js +2 -0
  229. package/dist/cli/chunks/{kilocode-installer-LY6JOBFY.js → kilocode-installer-APWB2GMA.js} +2 -2
  230. package/dist/cli/chunks/{kiro-installer-JF6NXTJL.js → kiro-installer-DICKFVNC.js} +2 -2
  231. package/dist/cli/chunks/knowledge-graph-6XTW6WO6.js +2 -0
  232. package/dist/cli/chunks/{learning-BIISN67N.js → learning-MXHNYW5D.js} +3 -3
  233. package/dist/cli/chunks/{llm-router-YZUNVZQE.js → llm-router-LTFIX7NY.js} +5 -5
  234. package/dist/cli/chunks/llm-router-service-3F4E64SY.js +2 -0
  235. package/dist/cli/chunks/{load-MTWNBNLL.js → load-JUMIQ4LZ.js} +2 -2
  236. package/dist/cli/chunks/load-test-SWZNGEIY.js +2 -0
  237. package/dist/cli/chunks/{mcp-37PYMNHQ.js → mcp-WHIARJGO.js} +2 -2
  238. package/dist/cli/chunks/{memory-IXUUDCI3.js → memory-KAHS6Z5A.js} +5 -5
  239. package/dist/cli/chunks/memory-backend-PR74ZPBA.js +2 -0
  240. package/dist/cli/chunks/{memory-handlers-RM2VOFJX.js → memory-handlers-DG3RRXB6.js} +2 -2
  241. package/dist/cli/chunks/{multi-model-executor-RKKS5XYG.js → multi-model-executor-E3Y2RHMX.js} +2 -2
  242. package/dist/cli/chunks/{opencode-installer-3VXI5MTR.js → opencode-installer-3RKGNGGE.js} +2 -2
  243. package/dist/cli/chunks/{orchestrator-UO3ZOGFZ.js → orchestrator-TXITUKWD.js} +5 -5
  244. package/dist/cli/chunks/pattern-null-store-EPE36BVT.js +2 -0
  245. package/dist/cli/chunks/{pattern-usage-recorder-YJKRL2GI.js → pattern-usage-recorder-EE2BUFZT.js} +2 -2
  246. package/dist/cli/chunks/{pipeline-GJQJKXWX.js → pipeline-AXTT6KZB.js} +2 -2
  247. package/dist/cli/chunks/{platform-RHVCZK6C.js → platform-TICPVKE2.js} +2 -2
  248. package/dist/cli/chunks/{plugin-ZKAIW7O6.js → plugin-VQKNV3EM.js} +2 -2
  249. package/dist/cli/chunks/{prime-radiant-advanced-wasm-4X3DSKQV.js → prime-radiant-advanced-wasm-6GY5YY7D.js} +2 -2
  250. package/dist/cli/chunks/protocol-executor-IELENNST.js +2 -0
  251. package/dist/cli/chunks/{protocol-handler-KKYQZMB2.js → protocol-handler-YFWDR7UZ.js} +2 -2
  252. package/dist/cli/chunks/{prove-OD6RPKWX.js → prove-FUMRCXAA.js} +2 -2
  253. package/dist/cli/chunks/provider-manager-3R3KOBHG.js +2 -0
  254. package/dist/cli/chunks/qe-reasoning-bank-S2R2PCBS.js +2 -0
  255. package/dist/cli/chunks/{quality-ZRWBXCKO.js → quality-2APISBW5.js} +2 -2
  256. package/dist/cli/chunks/{quality-gate-Y6BWQV7J.js → quality-gate-MCC3E5TM.js} +3 -3
  257. package/dist/cli/chunks/queen-coordinator-2E23NEV4.js +2 -0
  258. package/dist/cli/chunks/{real-embeddings-YYEUO4P2.js → real-embeddings-CC5TNOTI.js} +2 -2
  259. package/dist/cli/chunks/{roocode-installer-JBCPS3FK.js → roocode-installer-YAHTEVPI.js} +2 -2
  260. package/dist/cli/chunks/router-3FVLWO6S.js +2 -0
  261. package/dist/cli/chunks/routing-feedback-ZQLRNNR7.js +2 -0
  262. package/dist/cli/chunks/{routing-handler-KTPJOSBJ.js → routing-handler-6NQBW4TQ.js} +2 -2
  263. package/dist/cli/chunks/{ruvector-commands-SCZZVRE7.js → ruvector-commands-ZHXLHUPG.js} +2 -2
  264. package/dist/cli/chunks/{rvf-dual-writer-IP7GELQJ.js → rvf-dual-writer-5KF2DGCW.js} +2 -2
  265. package/dist/cli/chunks/{rvf-migration-adapter-WLFTDARU.js → rvf-migration-adapter-BBU57BGF.js} +2 -2
  266. package/dist/cli/chunks/{rvf-migration-coordinator-MGFDQ5WD.js → rvf-migration-coordinator-VN4VRZA4.js} +2 -2
  267. package/dist/cli/chunks/rvf-native-adapter-YFGLQNEB.js +2 -0
  268. package/dist/cli/chunks/{rvf-store-integrity-OTOAGT5W.js → rvf-store-integrity-XCY2XQZA.js} +2 -2
  269. package/dist/cli/chunks/safe-db-4SBLBTW7.js +2 -0
  270. package/dist/cli/chunks/schedule-5Y3BGVAA.js +2 -0
  271. package/dist/cli/chunks/scheduler-DOID3QF3.js +2 -0
  272. package/dist/cli/chunks/{security-B2CLZKRB.js → security-PYP4H3KN.js} +3 -3
  273. package/dist/cli/chunks/{shared-rvf-adapter-2PMFAQMN.js → shared-rvf-adapter-3CJHRNX6.js} +2 -2
  274. package/dist/cli/chunks/{shared-rvf-dual-writer-B6P732AV.js → shared-rvf-dual-writer-MKSLKWDI.js} +2 -2
  275. package/dist/cli/chunks/sqlite-persistence-M4JEQO57.js +2 -0
  276. package/dist/cli/chunks/{status-handler-M6SN2W2D.js → status-handler-VYIZ3VJF.js} +2 -2
  277. package/dist/cli/chunks/{structural-health-YCCTGI3K.js → structural-health-MVV4OWXP.js} +2 -2
  278. package/dist/cli/chunks/{sync-KSRF77ID.js → sync-G47OYIQ3.js} +2 -2
  279. package/dist/cli/chunks/sync-VNX6L3TI.js +2 -0
  280. package/dist/cli/chunks/{task-handler-MIKRB2SL.js → task-handler-GOWF2GEH.js} +2 -2
  281. package/dist/cli/chunks/{task-handlers-YXKRUBQ4.js → task-handlers-J2WC6J37.js} +3 -3
  282. package/dist/cli/chunks/{test-MLOLQCB7.js → test-DMCJ3BXS.js} +4 -4
  283. package/dist/cli/chunks/{test-scheduling-3KXESUZS.js → test-scheduling-TRFHHKFM.js} +3 -3
  284. package/dist/cli/chunks/{token-bootstrap-6V2PMDBJ.js → token-bootstrap-KEQ7AHFF.js} +2 -2
  285. package/dist/cli/chunks/{token-usage-DP6THJ3I.js → token-usage-B54FOFOF.js} +2 -2
  286. package/dist/cli/chunks/transformers-IACZG7IV.js +2 -0
  287. package/dist/cli/chunks/{tree-sitter-wasm-parser-COK2XERS.js → tree-sitter-wasm-parser-N7H4X37E.js} +2 -2
  288. package/dist/cli/chunks/{types-PYHUCVOZ.js → types-B3SHT4OD.js} +2 -2
  289. package/dist/cli/chunks/unified-memory-WNYWTGVX.js +2 -0
  290. package/dist/cli/chunks/unified-memory-hnsw-YPAV7U4E.js +2 -0
  291. package/dist/cli/chunks/unified-persistence-TJ252S7L.js +2 -0
  292. package/dist/cli/chunks/{upgrade-ONP2HNGL.js → upgrade-A2PQ5EWK.js} +2 -2
  293. package/dist/cli/chunks/{validate-NWSICDAY.js → validate-UXV7UQUT.js} +2 -2
  294. package/dist/cli/chunks/{validate-swarm-KXS5P3U7.js → validate-swarm-MMBU4FPP.js} +2 -2
  295. package/dist/cli/chunks/{vibium-TZSGZRCQ.js → vibium-R4GUVADA.js} +2 -2
  296. package/dist/cli/chunks/visual-security-VKYXEGJB.js +2 -0
  297. package/dist/cli/chunks/{web-tree-sitter-V2FADNRA.js → web-tree-sitter-MP6E6CJB.js} +2 -2
  298. package/dist/cli/chunks/{windsurf-installer-GQM7KWDC.js → windsurf-installer-Z6BWMUUO.js} +2 -2
  299. package/dist/cli/chunks/{witness-chain-GTITDIA2.js → witness-chain-EFLTABBA.js} +2 -2
  300. package/dist/cli/chunks/witness-chain-WVXRXKQP.js +2 -0
  301. package/dist/cli/chunks/{witness-key-manager-AHRM2M52.js → witness-key-manager-PN36TV43.js} +2 -2
  302. package/dist/cli/chunks/{workflow-XCGHEL3I.js → workflow-A2AX3RJU.js} +4 -4
  303. package/dist/cli/chunks/workflow-orchestrator-GOWSPR3G.js +2 -0
  304. package/dist/cli/chunks/{wrappers-VGO2GO4J.js → wrappers-NA6FHA63.js} +2 -2
  305. package/dist/cli/commands/llm-router.js +1 -0
  306. package/dist/init/skills-installer.js +1 -0
  307. package/dist/integrations/embeddings/base/EmbeddingGenerator.js +13 -1
  308. package/dist/kernel/unified-memory.js +4 -0
  309. package/dist/learning/qe-flywheel/corpus-scorer.js +10 -7
  310. package/dist/learning/qe-flywheel/generation.d.ts +7 -0
  311. package/dist/learning/qe-flywheel/generation.js +5 -0
  312. package/dist/learning/qe-flywheel/witness-verify.d.ts +86 -0
  313. package/dist/learning/qe-flywheel/witness-verify.js +156 -0
  314. package/dist/mcp/bundle.js +397 -386
  315. package/dist/shared/db-recovery.d.ts +55 -0
  316. package/dist/shared/db-recovery.js +184 -0
  317. package/dist/shared/llm/billing-modes.js +5 -2
  318. package/dist/shared/llm/cost-tracker.js +1 -0
  319. package/dist/shared/llm/interfaces.d.ts +14 -1
  320. package/dist/shared/llm/provider-manager.d.ts +1 -1
  321. package/dist/shared/llm/provider-manager.js +7 -3
  322. package/dist/shared/llm/providers/claude-code.js +12 -3
  323. package/dist/shared/llm/providers/codex.d.ts +58 -0
  324. package/dist/shared/llm/providers/codex.js +305 -0
  325. package/dist/shared/llm/providers/index.d.ts +1 -0
  326. package/dist/shared/llm/providers/index.js +1 -0
  327. package/dist/shared/llm/router/config-store.js +5 -0
  328. package/dist/shared/llm/router/hybrid-router.js +2 -2
  329. package/dist/shared/llm/spend-ledger.d.ts +24 -0
  330. package/dist/shared/llm/spend-ledger.js +86 -15
  331. package/dist/shared/llm/translation/message-formatter.js +1 -0
  332. package/dist/shared/safe-db.d.ts +10 -0
  333. package/dist/shared/safe-db.js +17 -0
  334. package/dist/skills/qe-court/referee.d.ts +62 -0
  335. package/dist/skills/qe-court/referee.js +78 -0
  336. package/dist/validation/gate-reexecute.d.ts +9 -0
  337. package/dist/validation/gate-reexecute.js +61 -0
  338. package/dist/validation/paired-bootstrap.d.ts +36 -0
  339. package/dist/validation/paired-bootstrap.js +58 -0
  340. package/package.json +7 -3
  341. package/dist/cli/chunks/adapter-D657MKZY.js +0 -2
  342. package/dist/cli/chunks/aqe-learning-engine-AFR6OZJK.js +0 -2
  343. package/dist/cli/chunks/base-K5QRGZWE.js +0 -2
  344. package/dist/cli/chunks/browser-workflow-ZMMKCGYW.js +0 -2
  345. package/dist/cli/chunks/chunk-6SQ72FG7.js +0 -2
  346. package/dist/cli/chunks/chunk-FHHCH7WL.js +0 -2
  347. package/dist/cli/chunks/chunk-G5OGKVLO.js +0 -2
  348. package/dist/cli/chunks/chunk-ILRKO6A5.js +0 -43
  349. package/dist/cli/chunks/chunk-NX522PRH.js +0 -153
  350. package/dist/cli/chunks/chunk-PPUDKQ4X.js +0 -29
  351. package/dist/cli/chunks/chunk-ULQCEM7K.js +0 -2
  352. package/dist/cli/chunks/client-WI7RRUZO.js +0 -2
  353. package/dist/cli/chunks/core-handlers-T6URR57V.js +0 -2
  354. package/dist/cli/chunks/cross-domain-router-WHTTKHWM.js +0 -2
  355. package/dist/cli/chunks/dream-QUL6SURC.js +0 -2
  356. package/dist/cli/chunks/heartbeat-scheduler-VZNKE33K.js +0 -2
  357. package/dist/cli/chunks/hnsw-adapter-LGWLDZLC.js +0 -2
  358. package/dist/cli/chunks/hnsw-index-66FOOI7U.js +0 -2
  359. package/dist/cli/chunks/hybrid-router-I5MEVQDF.js +0 -2
  360. package/dist/cli/chunks/impact-analyzer-K6ANYIY3.js +0 -2
  361. package/dist/cli/chunks/init-wizard-URHGXJ32.js +0 -2
  362. package/dist/cli/chunks/kernel-OKI5ZY5P.js +0 -2
  363. package/dist/cli/chunks/knowledge-graph-VQQSK7T5.js +0 -2
  364. package/dist/cli/chunks/llm-router-service-TISH33SY.js +0 -2
  365. package/dist/cli/chunks/load-test-KWKWC4Q7.js +0 -2
  366. package/dist/cli/chunks/memory-backend-JSQQMXVS.js +0 -2
  367. package/dist/cli/chunks/pattern-null-store-SXBIUKE5.js +0 -2
  368. package/dist/cli/chunks/protocol-executor-D3Q5P3WY.js +0 -2
  369. package/dist/cli/chunks/provider-manager-2EIX7E5Q.js +0 -2
  370. package/dist/cli/chunks/qe-reasoning-bank-ITOW2ZHC.js +0 -2
  371. package/dist/cli/chunks/queen-coordinator-TO5X2EXL.js +0 -2
  372. package/dist/cli/chunks/router-GZJQEJU3.js +0 -2
  373. package/dist/cli/chunks/routing-feedback-CRXSKFNS.js +0 -2
  374. package/dist/cli/chunks/rvf-native-adapter-WHADT5HX.js +0 -2
  375. package/dist/cli/chunks/safe-db-MIZ2OFWC.js +0 -2
  376. package/dist/cli/chunks/schedule-XFILYTYC.js +0 -2
  377. package/dist/cli/chunks/scheduler-EIPJ777A.js +0 -2
  378. package/dist/cli/chunks/sqlite-persistence-PFU3GSRD.js +0 -2
  379. package/dist/cli/chunks/sync-3SDMVAIU.js +0 -2
  380. package/dist/cli/chunks/transformers-QFOBOP2Y.js +0 -2
  381. package/dist/cli/chunks/unified-memory-OUVCMFGK.js +0 -2
  382. package/dist/cli/chunks/unified-memory-hnsw-YGQPOHXB.js +0 -2
  383. package/dist/cli/chunks/unified-persistence-GFRZVDOW.js +0 -2
  384. package/dist/cli/chunks/visual-security-LVOOYQ64.js +0 -2
  385. package/dist/cli/chunks/witness-chain-QNFPV4UL.js +0 -2
  386. package/dist/cli/chunks/workflow-orchestrator-MIVBCALG.js +0 -2
@@ -1,430 +1,430 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Auto Memory Bridge Hook (ADR-048/049)
4
- *
5
- * Wires AutoMemoryBridge + LearningBridge + MemoryGraph into Claude Code
6
- * session lifecycle. Called by settings.json SessionStart/SessionEnd hooks.
7
- *
8
- * Usage:
9
- * node auto-memory-hook.mjs import # SessionStart: import auto memory files into backend
10
- * node auto-memory-hook.mjs sync # SessionEnd: sync insights back to MEMORY.md
11
- * node auto-memory-hook.mjs status # Show bridge status
12
- */
13
-
14
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
15
- import { join, dirname } from 'path';
16
- import { fileURLToPath } from 'url';
17
-
18
- const __filename = fileURLToPath(import.meta.url);
19
- const __dirname = dirname(__filename);
20
- const PROJECT_ROOT = join(__dirname, '../..');
21
- const DATA_DIR = join(PROJECT_ROOT, '.claude-flow', 'data');
22
- const STORE_PATH = join(DATA_DIR, 'auto-memory-store.json');
23
-
24
- // Colors
25
- const GREEN = '\x1b[0;32m';
26
- const CYAN = '\x1b[0;36m';
27
- const DIM = '\x1b[2m';
28
- const RESET = '\x1b[0m';
29
-
30
- const YELLOW = '\x1b[0;33m';
31
- const log = (msg) => console.log(`${CYAN}[AutoMemory] ${msg}${RESET}`);
32
- const success = (msg) => console.log(`${GREEN}[AutoMemory] ✓ ${msg}${RESET}`);
33
- const dim = (msg) => console.log(` ${DIM}${msg}${RESET}`);
34
-
35
- // #2545: fail LOUD instead of a silent dim skip. When @claude-flow/memory cannot
36
- // be resolved, self-learning imports are a no-op — the user must see this and be
37
- // told exactly how to fix it (on both stdout, so it shows in the Claude Code hook
38
- // transcript, and stderr, per the issue's requested channel).
39
- function warnMemoryUnavailable() {
40
- const line1 = `[AutoMemory] @claude-flow/memory not resolvable from ${PROJECT_ROOT} — self-learning imports are DISABLED.`;
41
- const line2 = ' Fix: npm i -D @claude-flow/memory (or re-run: npx ruflo@latest init, then npx ruflo@latest doctor --fix)';
42
- console.log(`${YELLOW}${line1}${RESET}`);
43
- console.log(`${YELLOW}${line2}${RESET}`);
44
- process.stderr.write(`${line1}\n${line2}\n`);
45
- }
46
-
47
- const DEBUG = !!(process.env.RUFLO_DEBUG || process.env.DEBUG);
48
-
49
- // ── Graceful shutdown (FIX 3) ───────────────────────────────────────────────
50
- // Track the backend in use so a SIGTERM/SIGINT mid-run can still flush it
51
- // (the JSON backend persists; a SQLite-backed one closes/flushes WAL) instead
52
- // of leaving a half-written store or a stale lock behind.
53
- let activeBackend = null;
54
- let shuttingDown = false;
55
- function trackBackend(b) { activeBackend = b; return b; }
56
- async function gracefulExit(signal) {
57
- if (shuttingDown) return;
58
- shuttingDown = true;
59
- if (DEBUG) process.stderr.write(`[AutoMemory] received ${signal}, flushing backend before exit\n`);
60
- try {
61
- if (activeBackend && typeof activeBackend.shutdown === 'function') await activeBackend.shutdown();
62
- } catch { /* best effort — never block exit on cleanup */ }
63
- process.exit(0);
64
- }
65
- process.on('SIGTERM', () => { gracefulExit('SIGTERM'); });
66
- process.on('SIGINT', () => { gracefulExit('SIGINT'); });
67
-
68
- // Ensure data dir
69
- if (!existsSync(DATA_DIR)) mkdirSync(DATA_DIR, { recursive: true });
70
-
71
- // ============================================================================
72
- // Simple JSON File Backend (implements IMemoryBackend interface)
73
- // ============================================================================
74
-
75
- class JsonFileBackend {
76
- constructor(filePath) {
77
- this.filePath = filePath;
78
- this.entries = new Map();
79
- }
80
-
81
- async initialize() {
82
- if (existsSync(this.filePath)) {
83
- try {
84
- const data = JSON.parse(readFileSync(this.filePath, 'utf-8'));
85
- if (Array.isArray(data)) {
86
- for (const entry of data) this.entries.set(entry.id, entry);
87
- }
88
- } catch { /* start fresh */ }
89
- }
90
- }
91
-
92
- async shutdown() { this._persist(); }
93
- async store(entry) { this.entries.set(entry.id, entry); this._persist(); }
94
- async get(id) { return this.entries.get(id) ?? null; }
95
- async getByKey(key, ns) {
96
- for (const e of this.entries.values()) {
97
- if (e.key === key && (!ns || e.namespace === ns)) return e;
98
- }
99
- return null;
100
- }
101
- async update(id, updates) {
102
- const e = this.entries.get(id);
103
- if (!e) return null;
104
- if (updates.metadata) Object.assign(e.metadata, updates.metadata);
105
- if (updates.content !== undefined) e.content = updates.content;
106
- if (updates.tags) e.tags = updates.tags;
107
- e.updatedAt = Date.now();
108
- this._persist();
109
- return e;
110
- }
111
- async delete(id) { return this.entries.delete(id); }
112
- async query(opts) {
113
- let results = [...this.entries.values()];
114
- if (opts?.namespace) results = results.filter(e => e.namespace === opts.namespace);
115
- if (opts?.type) results = results.filter(e => e.type === opts.type);
116
- if (opts?.limit) results = results.slice(0, opts.limit);
117
- return results;
118
- }
119
- async search() { return []; } // No vector search in JSON backend
120
- async bulkInsert(entries) { for (const e of entries) this.entries.set(e.id, e); this._persist(); }
121
- async bulkDelete(ids) { let n = 0; for (const id of ids) { if (this.entries.delete(id)) n++; } this._persist(); return n; }
122
- async count() { return this.entries.size; }
123
- async listNamespaces() {
124
- const ns = new Set();
125
- for (const e of this.entries.values()) ns.add(e.namespace || 'default');
126
- return [...ns];
127
- }
128
- async clearNamespace(ns) {
129
- let n = 0;
130
- for (const [id, e] of this.entries) {
131
- if (e.namespace === ns) { this.entries.delete(id); n++; }
132
- }
133
- this._persist();
134
- return n;
135
- }
136
- async getStats() {
137
- return {
138
- totalEntries: this.entries.size,
139
- entriesByNamespace: {},
140
- entriesByType: { semantic: 0, episodic: 0, procedural: 0, working: 0, cache: 0 },
141
- memoryUsage: 0, avgQueryTime: 0, avgSearchTime: 0,
142
- };
143
- }
144
- async healthCheck() {
145
- return {
146
- status: 'healthy',
147
- components: {
148
- storage: { status: 'healthy', latency: 0 },
149
- index: { status: 'healthy', latency: 0 },
150
- cache: { status: 'healthy', latency: 0 },
151
- },
152
- timestamp: Date.now(), issues: [], recommendations: [],
153
- };
154
- }
155
-
156
- _persist() {
157
- try {
158
- writeFileSync(this.filePath, JSON.stringify([...this.entries.values()], null, 2), 'utf-8');
159
- } catch { /* best effort */ }
160
- }
161
- }
162
-
163
- // ============================================================================
164
- // Resolve memory package path (local dev or npm installed)
165
- // ============================================================================
166
-
167
- async function loadMemoryPackage() {
168
- // Strategy 0 (#2545): sidecar recorded by `init` / `doctor --fix`. On the
169
- // documented `npx ruflo` path @claude-flow/memory (an optionalDependency of
170
- // the CLI) lands in the npx cache, which is NOT on the walk-up path from the
171
- // project — so init resolves it from the CLI's own context and records the
172
- // absolute path here. This is the only strategy that works on that install.
173
- try {
174
- const sidecar = join(PROJECT_ROOT, '.claude-flow', 'memory-package.json');
175
- if (existsSync(sidecar)) {
176
- const rec = JSON.parse(readFileSync(sidecar, 'utf-8'));
177
- if (rec?.distPath && existsSync(rec.distPath)) {
178
- return await import(`file://${rec.distPath}`);
179
- }
180
- }
181
- } catch { /* fall through */ }
182
-
183
- // Strategy 1: Local dev (built dist)
184
- const localDist = join(PROJECT_ROOT, 'v3/@claude-flow/memory/dist/index.js');
185
- if (existsSync(localDist)) {
186
- try {
187
- return await import(`file://${localDist}`);
188
- } catch { /* fall through */ }
189
- }
190
-
191
- // Strategy 2: Use createRequire for CJS-style resolution (handles nested node_modules
192
- // when installed as a transitive dependency via npx ruflo / npx claude-flow)
193
- try {
194
- const { createRequire } = await import('module');
195
- const require = createRequire(join(PROJECT_ROOT, 'package.json'));
196
- return require('@claude-flow/memory');
197
- } catch { /* fall through */ }
198
-
199
- // Strategy 3: ESM import (works when @claude-flow/memory is a direct dependency)
200
- try {
201
- return await import('@claude-flow/memory');
202
- } catch { /* fall through */ }
203
-
204
- // Strategy 4: Walk up from PROJECT_ROOT looking for @claude-flow/memory in any node_modules
205
- let searchDir = PROJECT_ROOT;
206
- const { parse } = await import('path');
207
- while (searchDir !== parse(searchDir).root) {
208
- const candidate = join(searchDir, 'node_modules', '@claude-flow', 'memory', 'dist', 'index.js');
209
- if (existsSync(candidate)) {
210
- try {
211
- return await import(`file://${candidate}`);
212
- } catch { /* fall through */ }
213
- }
214
- searchDir = dirname(searchDir);
215
- }
216
-
217
- return null;
218
- }
219
-
220
- // ============================================================================
221
- // Read config from .claude-flow/config.yaml
222
- // ============================================================================
223
-
224
- function readConfig() {
225
- const configPath = join(PROJECT_ROOT, '.claude-flow', 'config.yaml');
226
- const defaults = {
227
- learningBridge: { enabled: true, sonaMode: 'balanced', confidenceDecayRate: 0.005, accessBoostAmount: 0.03, consolidationThreshold: 10 },
228
- memoryGraph: { enabled: true, pageRankDamping: 0.85, maxNodes: 5000, similarityThreshold: 0.8 },
229
- agentScopes: { enabled: true, defaultScope: 'project' },
230
- };
231
-
232
- if (!existsSync(configPath)) return defaults;
233
-
234
- try {
235
- const yaml = readFileSync(configPath, 'utf-8');
236
- // Simple YAML parser for the memory section
237
- const getBool = (key) => {
238
- const match = yaml.match(new RegExp(`${key}:\\s*(true|false)`, 'i'));
239
- return match ? match[1] === 'true' : undefined;
240
- };
241
-
242
- const lbEnabled = getBool('learningBridge[\\s\\S]*?enabled');
243
- if (lbEnabled !== undefined) defaults.learningBridge.enabled = lbEnabled;
244
-
245
- const mgEnabled = getBool('memoryGraph[\\s\\S]*?enabled');
246
- if (mgEnabled !== undefined) defaults.memoryGraph.enabled = mgEnabled;
247
-
248
- const asEnabled = getBool('agentScopes[\\s\\S]*?enabled');
249
- if (asEnabled !== undefined) defaults.agentScopes.enabled = asEnabled;
250
-
251
- return defaults;
252
- } catch {
253
- return defaults;
254
- }
255
- }
256
-
257
- // ============================================================================
258
- // Commands
259
- // ============================================================================
260
-
261
- async function doImport() {
262
- log('Importing auto memory files into bridge...');
263
-
264
- const memPkg = await loadMemoryPackage();
265
- if (!memPkg || !memPkg.AutoMemoryBridge) {
266
- warnMemoryUnavailable();
267
- return;
268
- }
269
-
270
- const config = readConfig();
271
- const backend = trackBackend(new JsonFileBackend(STORE_PATH));
272
- await backend.initialize();
273
-
274
- const bridgeConfig = {
275
- workingDir: PROJECT_ROOT,
276
- syncMode: 'on-session-end',
277
- };
278
-
279
- // Wire learning if enabled and available
280
- if (config.learningBridge.enabled && memPkg.LearningBridge) {
281
- bridgeConfig.learning = {
282
- sonaMode: config.learningBridge.sonaMode,
283
- confidenceDecayRate: config.learningBridge.confidenceDecayRate,
284
- accessBoostAmount: config.learningBridge.accessBoostAmount,
285
- consolidationThreshold: config.learningBridge.consolidationThreshold,
286
- };
287
- }
288
-
289
- // Wire graph if enabled and available
290
- if (config.memoryGraph.enabled && memPkg.MemoryGraph) {
291
- bridgeConfig.graph = {
292
- pageRankDamping: config.memoryGraph.pageRankDamping,
293
- maxNodes: config.memoryGraph.maxNodes,
294
- similarityThreshold: config.memoryGraph.similarityThreshold,
295
- };
296
- }
297
-
298
- const bridge = new memPkg.AutoMemoryBridge(backend, bridgeConfig);
299
-
300
- try {
301
- const result = await bridge.importFromAutoMemory();
302
- success(`Imported ${result.imported} entries (${result.skipped} skipped)`);
303
- dim(`├─ Backend entries: ${await backend.count()}`);
304
- dim(`├─ Learning: ${config.learningBridge.enabled ? 'active' : 'disabled'}`);
305
- dim(`├─ Graph: ${config.memoryGraph.enabled ? 'active' : 'disabled'}`);
306
- dim(`└─ Agent scopes: ${config.agentScopes.enabled ? 'active' : 'disabled'}`);
307
- } catch (err) {
308
- dim(`Import failed (non-critical): ${err.message}`);
309
- }
310
-
311
- await backend.shutdown();
312
- }
313
-
314
- async function doSync() {
315
- log('Syncing insights to auto memory files...');
316
-
317
- const memPkg = await loadMemoryPackage();
318
- if (!memPkg || !memPkg.AutoMemoryBridge) {
319
- warnMemoryUnavailable();
320
- return;
321
- }
322
-
323
- const config = readConfig();
324
- const backend = trackBackend(new JsonFileBackend(STORE_PATH));
325
- await backend.initialize();
326
-
327
- const entryCount = await backend.count();
328
- if (entryCount === 0) {
329
- dim('No entries to sync');
330
- await backend.shutdown();
331
- return;
332
- }
333
-
334
- const bridgeConfig = {
335
- workingDir: PROJECT_ROOT,
336
- syncMode: 'on-session-end',
337
- };
338
-
339
- if (config.learningBridge.enabled && memPkg.LearningBridge) {
340
- bridgeConfig.learning = {
341
- sonaMode: config.learningBridge.sonaMode,
342
- confidenceDecayRate: config.learningBridge.confidenceDecayRate,
343
- consolidationThreshold: config.learningBridge.consolidationThreshold,
344
- };
345
- }
346
-
347
- if (config.memoryGraph.enabled && memPkg.MemoryGraph) {
348
- bridgeConfig.graph = {
349
- pageRankDamping: config.memoryGraph.pageRankDamping,
350
- maxNodes: config.memoryGraph.maxNodes,
351
- };
352
- }
353
-
354
- const bridge = new memPkg.AutoMemoryBridge(backend, bridgeConfig);
355
-
356
- try {
357
- const syncResult = await bridge.syncToAutoMemory();
358
- success(`Synced ${syncResult.synced} entries to auto memory`);
359
- dim(`├─ Categories updated: ${syncResult.categories?.join(', ') || 'none'}`);
360
- dim(`└─ Backend entries: ${entryCount}`);
361
-
362
- // Curate MEMORY.md index with graph-aware ordering
363
- await bridge.curateIndex();
364
- success('Curated MEMORY.md index');
365
- } catch (err) {
366
- dim(`Sync failed (non-critical): ${err.message}`);
367
- }
368
-
369
- if (bridge.destroy) bridge.destroy();
370
- await backend.shutdown();
371
- }
372
-
373
- async function doStatus() {
374
- const memPkg = await loadMemoryPackage();
375
- const config = readConfig();
376
-
377
- const sidecar = join(PROJECT_ROOT, '.claude-flow', 'memory-package.json');
378
- const hasSidecar = existsSync(sidecar);
379
-
380
- console.log('\n=== Auto Memory Bridge Status ===\n');
381
- console.log(` Package: ${memPkg ? '✅ Available' : '❌ Not found — self-learning DISABLED (fix: npm i -D @claude-flow/memory)'}`);
382
- console.log(` Resolver: ${hasSidecar ? '✅ .claude-flow/memory-package.json' : '⏸ no sidecar (run: npx ruflo@latest doctor --fix)'}`);
383
- console.log(` Store: ${existsSync(STORE_PATH) ? '✅ ' + STORE_PATH : '⏸ Not initialized'}`);
384
- console.log(` LearningBridge: ${config.learningBridge.enabled ? '✅ Enabled' : '⏸ Disabled'}`);
385
- console.log(` MemoryGraph: ${config.memoryGraph.enabled ? '✅ Enabled' : '⏸ Disabled'}`);
386
- console.log(` AgentScopes: ${config.agentScopes.enabled ? '✅ Enabled' : '⏸ Disabled'}`);
387
-
388
- if (existsSync(STORE_PATH)) {
389
- try {
390
- const data = JSON.parse(readFileSync(STORE_PATH, 'utf-8'));
391
- console.log(` Entries: ${Array.isArray(data) ? data.length : 0}`);
392
- } catch { /* ignore */ }
393
- }
394
-
395
- console.log('');
396
- }
397
-
398
- // ============================================================================
399
- // Main
400
- // ============================================================================
401
-
402
- const command = process.argv[2] || 'status';
403
-
404
- // Dynamic import() failures can surface as unhandled rejections on a later
405
- // microtask even when the awaiting call site already caught them, which would
406
- // otherwise force a non-zero exit. Swallow to keep hooks exit-0, but surface the
407
- // reason under RUFLO_DEBUG/DEBUG so genuine async bugs aren't silently hidden
408
- // (FIX 2 — the previous `() => {}` discarded every rejection process-wide).
409
- process.on('unhandledRejection', (reason) => {
410
- if (DEBUG) {
411
- const detail = reason && reason.message ? reason.message : String(reason);
412
- process.stderr.write(`[AutoMemory] unhandledRejection (suppressed): ${detail}\n`);
413
- }
414
- });
415
-
416
- try {
417
- switch (command) {
418
- case 'import': await doImport(); break;
419
- case 'sync': await doSync(); break;
420
- case 'status': await doStatus(); break;
421
- default:
422
- console.log('Usage: auto-memory-hook.mjs <import|sync|status>');
423
- break;
424
- }
425
- } catch (err) {
426
- // Hooks must never crash Claude Code - fail silently
427
- try { dim(`Error (non-critical): ${err.message}`); } catch (_) {}
428
- }
429
- // Force clean exit — process.exitCode alone isn't enough if async errors override it
430
- process.exit(0);
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Auto Memory Bridge Hook (ADR-048/049)
4
+ *
5
+ * Wires AutoMemoryBridge + LearningBridge + MemoryGraph into Claude Code
6
+ * session lifecycle. Called by settings.json SessionStart/SessionEnd hooks.
7
+ *
8
+ * Usage:
9
+ * node auto-memory-hook.mjs import # SessionStart: import auto memory files into backend
10
+ * node auto-memory-hook.mjs sync # SessionEnd: sync insights back to MEMORY.md
11
+ * node auto-memory-hook.mjs status # Show bridge status
12
+ */
13
+
14
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
15
+ import { join, dirname } from 'path';
16
+ import { fileURLToPath } from 'url';
17
+
18
+ const __filename = fileURLToPath(import.meta.url);
19
+ const __dirname = dirname(__filename);
20
+ const PROJECT_ROOT = join(__dirname, '../..');
21
+ const DATA_DIR = join(PROJECT_ROOT, '.claude-flow', 'data');
22
+ const STORE_PATH = join(DATA_DIR, 'auto-memory-store.json');
23
+
24
+ // Colors
25
+ const GREEN = '\x1b[0;32m';
26
+ const CYAN = '\x1b[0;36m';
27
+ const DIM = '\x1b[2m';
28
+ const RESET = '\x1b[0m';
29
+
30
+ const YELLOW = '\x1b[0;33m';
31
+ const log = (msg) => console.log(`${CYAN}[AutoMemory] ${msg}${RESET}`);
32
+ const success = (msg) => console.log(`${GREEN}[AutoMemory] ✓ ${msg}${RESET}`);
33
+ const dim = (msg) => console.log(` ${DIM}${msg}${RESET}`);
34
+
35
+ // #2545: fail LOUD instead of a silent dim skip. When @claude-flow/memory cannot
36
+ // be resolved, self-learning imports are a no-op — the user must see this and be
37
+ // told exactly how to fix it (on both stdout, so it shows in the Claude Code hook
38
+ // transcript, and stderr, per the issue's requested channel).
39
+ function warnMemoryUnavailable() {
40
+ const line1 = `[AutoMemory] @claude-flow/memory not resolvable from ${PROJECT_ROOT} — self-learning imports are DISABLED.`;
41
+ const line2 = ' Fix: npm i -D @claude-flow/memory (or re-run: npx ruflo@latest init, then npx ruflo@latest doctor --fix)';
42
+ console.log(`${YELLOW}${line1}${RESET}`);
43
+ console.log(`${YELLOW}${line2}${RESET}`);
44
+ process.stderr.write(`${line1}\n${line2}\n`);
45
+ }
46
+
47
+ const DEBUG = !!(process.env.RUFLO_DEBUG || process.env.DEBUG);
48
+
49
+ // ── Graceful shutdown (FIX 3) ───────────────────────────────────────────────
50
+ // Track the backend in use so a SIGTERM/SIGINT mid-run can still flush it
51
+ // (the JSON backend persists; a SQLite-backed one closes/flushes WAL) instead
52
+ // of leaving a half-written store or a stale lock behind.
53
+ let activeBackend = null;
54
+ let shuttingDown = false;
55
+ function trackBackend(b) { activeBackend = b; return b; }
56
+ async function gracefulExit(signal) {
57
+ if (shuttingDown) return;
58
+ shuttingDown = true;
59
+ if (DEBUG) process.stderr.write(`[AutoMemory] received ${signal}, flushing backend before exit\n`);
60
+ try {
61
+ if (activeBackend && typeof activeBackend.shutdown === 'function') await activeBackend.shutdown();
62
+ } catch { /* best effort — never block exit on cleanup */ }
63
+ process.exit(0);
64
+ }
65
+ process.on('SIGTERM', () => { gracefulExit('SIGTERM'); });
66
+ process.on('SIGINT', () => { gracefulExit('SIGINT'); });
67
+
68
+ // Ensure data dir
69
+ if (!existsSync(DATA_DIR)) mkdirSync(DATA_DIR, { recursive: true });
70
+
71
+ // ============================================================================
72
+ // Simple JSON File Backend (implements IMemoryBackend interface)
73
+ // ============================================================================
74
+
75
+ class JsonFileBackend {
76
+ constructor(filePath) {
77
+ this.filePath = filePath;
78
+ this.entries = new Map();
79
+ }
80
+
81
+ async initialize() {
82
+ if (existsSync(this.filePath)) {
83
+ try {
84
+ const data = JSON.parse(readFileSync(this.filePath, 'utf-8'));
85
+ if (Array.isArray(data)) {
86
+ for (const entry of data) this.entries.set(entry.id, entry);
87
+ }
88
+ } catch { /* start fresh */ }
89
+ }
90
+ }
91
+
92
+ async shutdown() { this._persist(); }
93
+ async store(entry) { this.entries.set(entry.id, entry); this._persist(); }
94
+ async get(id) { return this.entries.get(id) ?? null; }
95
+ async getByKey(key, ns) {
96
+ for (const e of this.entries.values()) {
97
+ if (e.key === key && (!ns || e.namespace === ns)) return e;
98
+ }
99
+ return null;
100
+ }
101
+ async update(id, updates) {
102
+ const e = this.entries.get(id);
103
+ if (!e) return null;
104
+ if (updates.metadata) Object.assign(e.metadata, updates.metadata);
105
+ if (updates.content !== undefined) e.content = updates.content;
106
+ if (updates.tags) e.tags = updates.tags;
107
+ e.updatedAt = Date.now();
108
+ this._persist();
109
+ return e;
110
+ }
111
+ async delete(id) { return this.entries.delete(id); }
112
+ async query(opts) {
113
+ let results = [...this.entries.values()];
114
+ if (opts?.namespace) results = results.filter(e => e.namespace === opts.namespace);
115
+ if (opts?.type) results = results.filter(e => e.type === opts.type);
116
+ if (opts?.limit) results = results.slice(0, opts.limit);
117
+ return results;
118
+ }
119
+ async search() { return []; } // No vector search in JSON backend
120
+ async bulkInsert(entries) { for (const e of entries) this.entries.set(e.id, e); this._persist(); }
121
+ async bulkDelete(ids) { let n = 0; for (const id of ids) { if (this.entries.delete(id)) n++; } this._persist(); return n; }
122
+ async count() { return this.entries.size; }
123
+ async listNamespaces() {
124
+ const ns = new Set();
125
+ for (const e of this.entries.values()) ns.add(e.namespace || 'default');
126
+ return [...ns];
127
+ }
128
+ async clearNamespace(ns) {
129
+ let n = 0;
130
+ for (const [id, e] of this.entries) {
131
+ if (e.namespace === ns) { this.entries.delete(id); n++; }
132
+ }
133
+ this._persist();
134
+ return n;
135
+ }
136
+ async getStats() {
137
+ return {
138
+ totalEntries: this.entries.size,
139
+ entriesByNamespace: {},
140
+ entriesByType: { semantic: 0, episodic: 0, procedural: 0, working: 0, cache: 0 },
141
+ memoryUsage: 0, avgQueryTime: 0, avgSearchTime: 0,
142
+ };
143
+ }
144
+ async healthCheck() {
145
+ return {
146
+ status: 'healthy',
147
+ components: {
148
+ storage: { status: 'healthy', latency: 0 },
149
+ index: { status: 'healthy', latency: 0 },
150
+ cache: { status: 'healthy', latency: 0 },
151
+ },
152
+ timestamp: Date.now(), issues: [], recommendations: [],
153
+ };
154
+ }
155
+
156
+ _persist() {
157
+ try {
158
+ writeFileSync(this.filePath, JSON.stringify([...this.entries.values()], null, 2), 'utf-8');
159
+ } catch { /* best effort */ }
160
+ }
161
+ }
162
+
163
+ // ============================================================================
164
+ // Resolve memory package path (local dev or npm installed)
165
+ // ============================================================================
166
+
167
+ async function loadMemoryPackage() {
168
+ // Strategy 0 (#2545): sidecar recorded by `init` / `doctor --fix`. On the
169
+ // documented `npx ruflo` path @claude-flow/memory (an optionalDependency of
170
+ // the CLI) lands in the npx cache, which is NOT on the walk-up path from the
171
+ // project — so init resolves it from the CLI's own context and records the
172
+ // absolute path here. This is the only strategy that works on that install.
173
+ try {
174
+ const sidecar = join(PROJECT_ROOT, '.claude-flow', 'memory-package.json');
175
+ if (existsSync(sidecar)) {
176
+ const rec = JSON.parse(readFileSync(sidecar, 'utf-8'));
177
+ if (rec?.distPath && existsSync(rec.distPath)) {
178
+ return await import(`file://${rec.distPath}`);
179
+ }
180
+ }
181
+ } catch { /* fall through */ }
182
+
183
+ // Strategy 1: Local dev (built dist)
184
+ const localDist = join(PROJECT_ROOT, 'v3/@claude-flow/memory/dist/index.js');
185
+ if (existsSync(localDist)) {
186
+ try {
187
+ return await import(`file://${localDist}`);
188
+ } catch { /* fall through */ }
189
+ }
190
+
191
+ // Strategy 2: Use createRequire for CJS-style resolution (handles nested node_modules
192
+ // when installed as a transitive dependency via npx ruflo / npx claude-flow)
193
+ try {
194
+ const { createRequire } = await import('module');
195
+ const require = createRequire(join(PROJECT_ROOT, 'package.json'));
196
+ return require('@claude-flow/memory');
197
+ } catch { /* fall through */ }
198
+
199
+ // Strategy 3: ESM import (works when @claude-flow/memory is a direct dependency)
200
+ try {
201
+ return await import('@claude-flow/memory');
202
+ } catch { /* fall through */ }
203
+
204
+ // Strategy 4: Walk up from PROJECT_ROOT looking for @claude-flow/memory in any node_modules
205
+ let searchDir = PROJECT_ROOT;
206
+ const { parse } = await import('path');
207
+ while (searchDir !== parse(searchDir).root) {
208
+ const candidate = join(searchDir, 'node_modules', '@claude-flow', 'memory', 'dist', 'index.js');
209
+ if (existsSync(candidate)) {
210
+ try {
211
+ return await import(`file://${candidate}`);
212
+ } catch { /* fall through */ }
213
+ }
214
+ searchDir = dirname(searchDir);
215
+ }
216
+
217
+ return null;
218
+ }
219
+
220
+ // ============================================================================
221
+ // Read config from .claude-flow/config.yaml
222
+ // ============================================================================
223
+
224
+ function readConfig() {
225
+ const configPath = join(PROJECT_ROOT, '.claude-flow', 'config.yaml');
226
+ const defaults = {
227
+ learningBridge: { enabled: true, sonaMode: 'balanced', confidenceDecayRate: 0.005, accessBoostAmount: 0.03, consolidationThreshold: 10 },
228
+ memoryGraph: { enabled: true, pageRankDamping: 0.85, maxNodes: 5000, similarityThreshold: 0.8 },
229
+ agentScopes: { enabled: true, defaultScope: 'project' },
230
+ };
231
+
232
+ if (!existsSync(configPath)) return defaults;
233
+
234
+ try {
235
+ const yaml = readFileSync(configPath, 'utf-8');
236
+ // Simple YAML parser for the memory section
237
+ const getBool = (key) => {
238
+ const match = yaml.match(new RegExp(`${key}:\\s*(true|false)`, 'i'));
239
+ return match ? match[1] === 'true' : undefined;
240
+ };
241
+
242
+ const lbEnabled = getBool('learningBridge[\\s\\S]*?enabled');
243
+ if (lbEnabled !== undefined) defaults.learningBridge.enabled = lbEnabled;
244
+
245
+ const mgEnabled = getBool('memoryGraph[\\s\\S]*?enabled');
246
+ if (mgEnabled !== undefined) defaults.memoryGraph.enabled = mgEnabled;
247
+
248
+ const asEnabled = getBool('agentScopes[\\s\\S]*?enabled');
249
+ if (asEnabled !== undefined) defaults.agentScopes.enabled = asEnabled;
250
+
251
+ return defaults;
252
+ } catch {
253
+ return defaults;
254
+ }
255
+ }
256
+
257
+ // ============================================================================
258
+ // Commands
259
+ // ============================================================================
260
+
261
+ async function doImport() {
262
+ log('Importing auto memory files into bridge...');
263
+
264
+ const memPkg = await loadMemoryPackage();
265
+ if (!memPkg || !memPkg.AutoMemoryBridge) {
266
+ warnMemoryUnavailable();
267
+ return;
268
+ }
269
+
270
+ const config = readConfig();
271
+ const backend = trackBackend(new JsonFileBackend(STORE_PATH));
272
+ await backend.initialize();
273
+
274
+ const bridgeConfig = {
275
+ workingDir: PROJECT_ROOT,
276
+ syncMode: 'on-session-end',
277
+ };
278
+
279
+ // Wire learning if enabled and available
280
+ if (config.learningBridge.enabled && memPkg.LearningBridge) {
281
+ bridgeConfig.learning = {
282
+ sonaMode: config.learningBridge.sonaMode,
283
+ confidenceDecayRate: config.learningBridge.confidenceDecayRate,
284
+ accessBoostAmount: config.learningBridge.accessBoostAmount,
285
+ consolidationThreshold: config.learningBridge.consolidationThreshold,
286
+ };
287
+ }
288
+
289
+ // Wire graph if enabled and available
290
+ if (config.memoryGraph.enabled && memPkg.MemoryGraph) {
291
+ bridgeConfig.graph = {
292
+ pageRankDamping: config.memoryGraph.pageRankDamping,
293
+ maxNodes: config.memoryGraph.maxNodes,
294
+ similarityThreshold: config.memoryGraph.similarityThreshold,
295
+ };
296
+ }
297
+
298
+ const bridge = new memPkg.AutoMemoryBridge(backend, bridgeConfig);
299
+
300
+ try {
301
+ const result = await bridge.importFromAutoMemory();
302
+ success(`Imported ${result.imported} entries (${result.skipped} skipped)`);
303
+ dim(`├─ Backend entries: ${await backend.count()}`);
304
+ dim(`├─ Learning: ${config.learningBridge.enabled ? 'active' : 'disabled'}`);
305
+ dim(`├─ Graph: ${config.memoryGraph.enabled ? 'active' : 'disabled'}`);
306
+ dim(`└─ Agent scopes: ${config.agentScopes.enabled ? 'active' : 'disabled'}`);
307
+ } catch (err) {
308
+ dim(`Import failed (non-critical): ${err.message}`);
309
+ }
310
+
311
+ await backend.shutdown();
312
+ }
313
+
314
+ async function doSync() {
315
+ log('Syncing insights to auto memory files...');
316
+
317
+ const memPkg = await loadMemoryPackage();
318
+ if (!memPkg || !memPkg.AutoMemoryBridge) {
319
+ warnMemoryUnavailable();
320
+ return;
321
+ }
322
+
323
+ const config = readConfig();
324
+ const backend = trackBackend(new JsonFileBackend(STORE_PATH));
325
+ await backend.initialize();
326
+
327
+ const entryCount = await backend.count();
328
+ if (entryCount === 0) {
329
+ dim('No entries to sync');
330
+ await backend.shutdown();
331
+ return;
332
+ }
333
+
334
+ const bridgeConfig = {
335
+ workingDir: PROJECT_ROOT,
336
+ syncMode: 'on-session-end',
337
+ };
338
+
339
+ if (config.learningBridge.enabled && memPkg.LearningBridge) {
340
+ bridgeConfig.learning = {
341
+ sonaMode: config.learningBridge.sonaMode,
342
+ confidenceDecayRate: config.learningBridge.confidenceDecayRate,
343
+ consolidationThreshold: config.learningBridge.consolidationThreshold,
344
+ };
345
+ }
346
+
347
+ if (config.memoryGraph.enabled && memPkg.MemoryGraph) {
348
+ bridgeConfig.graph = {
349
+ pageRankDamping: config.memoryGraph.pageRankDamping,
350
+ maxNodes: config.memoryGraph.maxNodes,
351
+ };
352
+ }
353
+
354
+ const bridge = new memPkg.AutoMemoryBridge(backend, bridgeConfig);
355
+
356
+ try {
357
+ const syncResult = await bridge.syncToAutoMemory();
358
+ success(`Synced ${syncResult.synced} entries to auto memory`);
359
+ dim(`├─ Categories updated: ${syncResult.categories?.join(', ') || 'none'}`);
360
+ dim(`└─ Backend entries: ${entryCount}`);
361
+
362
+ // Curate MEMORY.md index with graph-aware ordering
363
+ await bridge.curateIndex();
364
+ success('Curated MEMORY.md index');
365
+ } catch (err) {
366
+ dim(`Sync failed (non-critical): ${err.message}`);
367
+ }
368
+
369
+ if (bridge.destroy) bridge.destroy();
370
+ await backend.shutdown();
371
+ }
372
+
373
+ async function doStatus() {
374
+ const memPkg = await loadMemoryPackage();
375
+ const config = readConfig();
376
+
377
+ const sidecar = join(PROJECT_ROOT, '.claude-flow', 'memory-package.json');
378
+ const hasSidecar = existsSync(sidecar);
379
+
380
+ console.log('\n=== Auto Memory Bridge Status ===\n');
381
+ console.log(` Package: ${memPkg ? '✅ Available' : '❌ Not found — self-learning DISABLED (fix: npm i -D @claude-flow/memory)'}`);
382
+ console.log(` Resolver: ${hasSidecar ? '✅ .claude-flow/memory-package.json' : '⏸ no sidecar (run: npx ruflo@latest doctor --fix)'}`);
383
+ console.log(` Store: ${existsSync(STORE_PATH) ? '✅ ' + STORE_PATH : '⏸ Not initialized'}`);
384
+ console.log(` LearningBridge: ${config.learningBridge.enabled ? '✅ Enabled' : '⏸ Disabled'}`);
385
+ console.log(` MemoryGraph: ${config.memoryGraph.enabled ? '✅ Enabled' : '⏸ Disabled'}`);
386
+ console.log(` AgentScopes: ${config.agentScopes.enabled ? '✅ Enabled' : '⏸ Disabled'}`);
387
+
388
+ if (existsSync(STORE_PATH)) {
389
+ try {
390
+ const data = JSON.parse(readFileSync(STORE_PATH, 'utf-8'));
391
+ console.log(` Entries: ${Array.isArray(data) ? data.length : 0}`);
392
+ } catch { /* ignore */ }
393
+ }
394
+
395
+ console.log('');
396
+ }
397
+
398
+ // ============================================================================
399
+ // Main
400
+ // ============================================================================
401
+
402
+ const command = process.argv[2] || 'status';
403
+
404
+ // Dynamic import() failures can surface as unhandled rejections on a later
405
+ // microtask even when the awaiting call site already caught them, which would
406
+ // otherwise force a non-zero exit. Swallow to keep hooks exit-0, but surface the
407
+ // reason under RUFLO_DEBUG/DEBUG so genuine async bugs aren't silently hidden
408
+ // (FIX 2 — the previous `() => {}` discarded every rejection process-wide).
409
+ process.on('unhandledRejection', (reason) => {
410
+ if (DEBUG) {
411
+ const detail = reason && reason.message ? reason.message : String(reason);
412
+ process.stderr.write(`[AutoMemory] unhandledRejection (suppressed): ${detail}\n`);
413
+ }
414
+ });
415
+
416
+ try {
417
+ switch (command) {
418
+ case 'import': await doImport(); break;
419
+ case 'sync': await doSync(); break;
420
+ case 'status': await doStatus(); break;
421
+ default:
422
+ console.log('Usage: auto-memory-hook.mjs <import|sync|status>');
423
+ break;
424
+ }
425
+ } catch (err) {
426
+ // Hooks must never crash Claude Code - fail silently
427
+ try { dim(`Error (non-critical): ${err.message}`); } catch (_) {}
428
+ }
429
+ // Force clean exit — process.exitCode alone isn't enough if async errors override it
430
+ process.exit(0);