@cc-monitoring/proxy-core 0.3.1 → 0.4.1
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/dist/cli/__tests__/commands.test.js +20 -1
- package/dist/cli/commands/exec.js +31 -42
- package/dist/cli/commands/repair.d.ts +1 -0
- package/dist/cli/commands/repair.js +15 -0
- package/dist/cli/index.js +30 -0
- package/dist/docs/404.html +2 -2
- package/dist/docs/assets/{app.B9A39uFv.js → app.g7N9jkzn.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.IHxQqfJH.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.DdhC696L.js → VPLocalSearchBox.BHwI475_.js} +1 -1
- package/dist/docs/assets/chunks/{theme.CfB2tOFi.js → theme.FhAJSNDh.js} +2 -2
- package/dist/docs/assets/{proxy-cli_data-hooks.md.w9Oe1OD3.js → proxy-cli_data-hooks.md.Bz8CVbxO.js} +1 -1
- package/dist/docs/assets/{proxy-core_ui-routes.md.Dyqkeoiv.js → proxy-core_ui-routes.md.B21t1p7R.js} +1 -1
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/index.html +3 -3
- package/dist/docs/overview.html +3 -3
- package/dist/docs/packages-utils.html +3 -3
- package/dist/docs/proxy-admin/env-and-build.html +3 -3
- package/dist/docs/proxy-admin/index.html +3 -3
- package/dist/docs/proxy-admin/layout-and-menu.html +3 -3
- package/dist/docs/proxy-admin/pages.html +3 -3
- package/dist/docs/proxy-admin/routing-and-auth.html +3 -3
- package/dist/docs/proxy-admin/services-and-mock.html +3 -3
- package/dist/docs/proxy-cli/api-layer.html +3 -3
- package/dist/docs/proxy-cli/app-shell.html +3 -3
- package/dist/docs/proxy-cli/components-common.html +3 -3
- package/dist/docs/proxy-cli/components-config.html +3 -3
- package/dist/docs/proxy-cli/components-requests.html +3 -3
- package/dist/docs/proxy-cli/components-stats.html +3 -3
- package/dist/docs/proxy-cli/components-status.html +3 -3
- package/dist/docs/proxy-cli/data-hooks.html +5 -5
- package/dist/docs/proxy-cli/index.html +3 -3
- package/dist/docs/proxy-cli/utils-and-i18n.html +3 -3
- package/dist/docs/proxy-core/chat-api.html +3 -3
- package/dist/docs/proxy-core/cli.html +3 -3
- package/dist/docs/proxy-core/config.html +3 -3
- package/dist/docs/proxy-core/data-layer.html +3 -3
- package/dist/docs/proxy-core/entry.html +3 -3
- package/dist/docs/proxy-core/index.html +3 -3
- package/dist/docs/proxy-core/pm2.html +3 -3
- package/dist/docs/proxy-core/providers.html +3 -3
- package/dist/docs/proxy-core/proxy.html +3 -3
- package/dist/docs/proxy-core/stats.html +3 -3
- package/dist/docs/proxy-core/tool.html +3 -3
- package/dist/docs/proxy-core/ui-routes.html +5 -5
- package/dist/docs/proxy-core/utilities.html +3 -3
- package/dist/docs/quickstart.html +3 -3
- package/dist/docs/request-flow.html +3 -3
- package/dist/logger/index.d.ts +0 -3
- package/dist/logger/index.js +0 -1
- package/dist/mcp-server/tools.js +8 -9
- package/dist/server/__tests__/data-push.test.js +44 -0
- package/dist/server/__tests__/providers-route.test.js +1 -0
- package/dist/server/__tests__/proxy.test.js +281 -2
- package/dist/server/__tests__/server.test.js +15 -10
- package/dist/server/__tests__/ui-route.test.js +43 -0
- package/dist/server/auth.d.ts +0 -1
- package/dist/server/auth.js +1 -1
- package/dist/server/chat-route.js +48 -162
- package/dist/server/data-push.d.ts +2 -1
- package/dist/server/data-push.js +22 -7
- package/dist/server/index.js +4 -3
- package/dist/server/proxy.js +193 -229
- package/dist/server/ui-route.js +84 -60
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry.d.ts +0 -4
- package/dist/tools/registry.js +0 -8
- package/dist/types/config.d.ts +0 -13
- package/dist/types/pm2.d.ts +1 -2
- package/dist/ui/assets/{1c-DAu68mP4.js → 1c-CaPSZBmB.js} +1 -1
- package/dist/ui/assets/{abnf-Cu8RHCHK.js → abnf-DBDOsmne.js} +1 -1
- package/dist/ui/assets/{abnfDiagram-VRR7QNED-BUBToPXF.js → abnfDiagram-VRR7QNED-D8zK__Mj.js} +1 -1
- package/dist/ui/assets/{accesslog-BG-34XOy.js → accesslog-BOLs2Kig.js} +1 -1
- package/dist/ui/assets/{actionscript-iw0HHMGM.js → actionscript-BZYKhS1B.js} +1 -1
- package/dist/ui/assets/{ada-qRqj6VGQ.js → ada-DyacnMpg.js} +1 -1
- package/dist/ui/assets/{angelscript-BeaXyx_P.js → angelscript-CAN6j0H3.js} +1 -1
- package/dist/ui/assets/{apache-CU8d-z9X.js → apache-BE4vouiQ.js} +1 -1
- package/dist/ui/assets/{applescript-d1Wxkqz1.js → applescript-CS88I1yz.js} +1 -1
- package/dist/ui/assets/{arc-BMsPIm3j.js → arc-CTMmdrSV.js} +1 -1
- package/dist/ui/assets/{arcade-CtbgrWTM.js → arcade-B0f0f5SD.js} +1 -1
- package/dist/ui/assets/{architectureDiagram-ZJ3FMSHR-CVjC5TrS.js → architectureDiagram-ZJ3FMSHR-Dtvpnopp.js} +1 -1
- package/dist/ui/assets/{arduino-Bc9L39Hr.js → arduino-Bhm-OSb2.js} +1 -1
- package/dist/ui/assets/{armasm-DuWmpjWR.js → armasm-CEy-mDHc.js} +1 -1
- package/dist/ui/assets/{asciidoc-CDIhFTnx.js → asciidoc-CrZqQBTj.js} +1 -1
- package/dist/ui/assets/{aspectj-SYj-57Es.js → aspectj-B4IlFyyJ.js} +1 -1
- package/dist/ui/assets/{autohotkey-hBi5dq37.js → autohotkey-Cihy-FjA.js} +1 -1
- package/dist/ui/assets/{autoit-BSawXzhg.js → autoit-Dis_JVJq.js} +1 -1
- package/dist/ui/assets/{avrasm-CwYom8Np.js → avrasm-CVhMycHj.js} +1 -1
- package/dist/ui/assets/{awk-BvBRfGo2.js → awk-BCViwLf5.js} +1 -1
- package/dist/ui/assets/{axapta-CqUavA8k.js → axapta-pWB4JVB_.js} +1 -1
- package/dist/ui/assets/{bash-BS_ZnmEu.js → bash-B6Giryub.js} +1 -1
- package/dist/ui/assets/{basic-xbP4IXrN.js → basic-DcrjcHB0.js} +1 -1
- package/dist/ui/assets/{blockDiagram-677ZJIJ3-CmpI3f5p.js → blockDiagram-677ZJIJ3-DfhtgI1r.js} +1 -1
- package/dist/ui/assets/{bnf-BECwu6uW.js → bnf-cpKU0967.js} +1 -1
- package/dist/ui/assets/{brainfuck-QQgu4j4N.js → brainfuck-CFFdk4cM.js} +1 -1
- package/dist/ui/assets/{coq-IDMIFfem.js → c-CW6KPMeI.js} +1 -1
- package/dist/ui/assets/{c-like-DYrFOtXy.js → c-like-CWn59vrg.js} +1 -1
- package/dist/ui/assets/{c4Diagram-LMCZKHZV-B6Hgngz9.js → c4Diagram-LMCZKHZV-D1Oh6k37.js} +1 -1
- package/dist/ui/assets/{cal-CNMrJ6v5.js → cal-8i26_L39.js} +1 -1
- package/dist/ui/assets/{capnproto-DYCKl6oY.js → capnproto-CviwnFBf.js} +1 -1
- package/dist/ui/assets/{ceylon-mb8tRPl0.js → ceylon-CQyc4rWs.js} +1 -1
- package/dist/ui/assets/channel-Da2MvpNG.js +1 -0
- package/dist/ui/assets/{chunk-2Q5K7J3B-LxvQ-G67.js → chunk-2Q5K7J3B-oswPBwIn.js} +1 -1
- package/dist/ui/assets/{chunk-32BRIVSS-DxzKK6Aw.js → chunk-32BRIVSS-B5pU_9b9.js} +1 -1
- package/dist/ui/assets/{chunk-5VM5RSS4-CZEoYJ2W.js → chunk-5VM5RSS4-gvtfMc4w.js} +1 -1
- package/dist/ui/assets/{chunk-EX3LRPZG-DS2PytrN.js → chunk-EX3LRPZG-BkBaDMy4.js} +1 -1
- package/dist/ui/assets/{chunk-JWPE2WC7-UX0Sr1Ie.js → chunk-JWPE2WC7-Ch-C75ar.js} +1 -1
- package/dist/ui/assets/{chunk-MOJQB5TN-YbJgT9t4.js → chunk-MOJQB5TN-BfYhj1jN.js} +1 -1
- package/dist/ui/assets/{chunk-RYQCIY6F-DS2VH_U9.js → chunk-RYQCIY6F-D8izfruP.js} +1 -1
- package/dist/ui/assets/{chunk-V7JOEXUC-CZr0pkI1.js → chunk-V7JOEXUC-CbzHnW90.js} +1 -1
- package/dist/ui/assets/{chunk-VR4S4FIN-50opPAD3.js → chunk-VR4S4FIN-Dr4M5qZA.js} +1 -1
- package/dist/ui/assets/{chunk-XXDRQBXY-DAAX9l7U.js → chunk-XXDRQBXY-QE-R8dRe.js} +1 -1
- package/dist/ui/assets/classDiagram-OUVF2IWQ-mHUiWjcC.js +1 -0
- package/dist/ui/assets/classDiagram-v2-EOCWNBFH-mHUiWjcC.js +1 -0
- package/dist/ui/assets/{clean-C4X7dSkh.js → clean-DZeAtQ7H.js} +1 -1
- package/dist/ui/assets/{clojure-DSg9gUa7.js → clojure-U4ebZ7NQ.js} +1 -1
- package/dist/ui/assets/{clojure-repl-CagRYx7h.js → clojure-repl-B4QSIzUI.js} +1 -1
- package/dist/ui/assets/{cmake-CFdBn53c.js → cmake-UHexZySb.js} +1 -1
- package/dist/ui/assets/{coffeescript-CJZtMOPx.js → coffeescript-Dg56H9Mr.js} +1 -1
- package/dist/ui/assets/{c-BRJEPYra.js → coq-C1g3mm0X.js} +1 -1
- package/dist/ui/assets/{cos-Bx2VJuzG.js → cos-BL4DdyGh.js} +1 -1
- package/dist/ui/assets/{cose-bilkent-JH36ORCC-zWRLsZpZ.js → cose-bilkent-JH36ORCC-BHQslHP3.js} +1 -1
- package/dist/ui/assets/{cpp-CsG6DlC4.js → cpp-keZI-XAd.js} +1 -1
- package/dist/ui/assets/{crmsh-DTy9MnmJ.js → crmsh-DdXYVeeA.js} +1 -1
- package/dist/ui/assets/{crystal-BwgrLrZ1.js → crystal-C4AN0m0I.js} +1 -1
- package/dist/ui/assets/{csharp-B2VeTPAF.js → csharp-COUyKsNR.js} +1 -1
- package/dist/ui/assets/{csp-CTpydNhH.js → csp-DBc-rgSJ.js} +1 -1
- package/dist/ui/assets/{css-B0mMUbpY.js → css-B8m6O_Pw.js} +1 -1
- package/dist/ui/assets/{cynefin-VYW2F7L2-BmjQEj6q.js → cynefin-VYW2F7L2-B3L-WcKn.js} +1 -1
- package/dist/ui/assets/{cynefinDiagram-TSTJHNR4-Dr0Zrke0.js → cynefinDiagram-TSTJHNR4-fzaM4qcZ.js} +1 -1
- package/dist/ui/assets/{d-DjuDZnbI.js → d-dgQN4Rko.js} +1 -1
- package/dist/ui/assets/{dagre-VKFMJZFB-xoTPT2Uu.js → dagre-VKFMJZFB-DJHj16mR.js} +1 -1
- package/dist/ui/assets/{dart-xR3GU9TJ.js → dart-D2Y7LOq-.js} +1 -1
- package/dist/ui/assets/{delphi-bJas5QnG.js → delphi-DaGcSk5A.js} +1 -1
- package/dist/ui/assets/{diagram-FQU43EPY-rL_IU7gU.js → diagram-FQU43EPY-iZEZ1f-R.js} +1 -1
- package/dist/ui/assets/{diagram-G47NLZAW-EcDiCVGj.js → diagram-G47NLZAW-rkQb3r-C.js} +1 -1
- package/dist/ui/assets/{diagram-NH7WQ7WH-CGGXOjev.js → diagram-NH7WQ7WH-B4Fy72tP.js} +1 -1
- package/dist/ui/assets/{diagram-OA4YK3LP-DnE7hDjD.js → diagram-OA4YK3LP-BndmuIBq.js} +1 -1
- package/dist/ui/assets/{diagram-WEI45ONY-CTJH5eD8.js → diagram-WEI45ONY-CwlAiqOe.js} +1 -1
- package/dist/ui/assets/{diff-doJFF3fv.js → diff-prcRV1Y3.js} +1 -1
- package/dist/ui/assets/{django-D3b-owa_.js → django-B1zIoGSx.js} +1 -1
- package/dist/ui/assets/{dns-C42KYV-Z.js → dns-ZxI_aTwc.js} +1 -1
- package/dist/ui/assets/{dockerfile-9KUINc2j.js → dockerfile-Dp_fT6E-.js} +1 -1
- package/dist/ui/assets/{dos-CxnlJ6qp.js → dos-Cuu5c8vv.js} +1 -1
- package/dist/ui/assets/{dsconfig-6CMMCwmY.js → dsconfig-DcGTOhbS.js} +1 -1
- package/dist/ui/assets/{dts-D78rdUIB.js → dts-DCF8VaRk.js} +1 -1
- package/dist/ui/assets/{dust-Dv1uTfJU.js → dust-DeCmZWMK.js} +1 -1
- package/dist/ui/assets/{ebnf-BGbG1cFK.js → ebnf-BHQQcuF_.js} +1 -1
- package/dist/ui/assets/{ebnfDiagram-CCIWWBDH-z2VgRSUV.js → ebnfDiagram-CCIWWBDH-DJ_RuhTm.js} +1 -1
- package/dist/ui/assets/{elixir-ZgAQVY1J.js → elixir-BHmweJ4d.js} +1 -1
- package/dist/ui/assets/{elm-CudiFuNu.js → elm-v76Hd2B3.js} +1 -1
- package/dist/ui/assets/{erDiagram-Q63AITRT-X1TODuRv.js → erDiagram-Q63AITRT-DVZkY5RZ.js} +1 -1
- package/dist/ui/assets/{erb-Bz_NZh6W.js → erb-xvWF5bfx.js} +1 -1
- package/dist/ui/assets/{erlang-DNuj1nb2.js → erlang-CKBMURym.js} +1 -1
- package/dist/ui/assets/{erlang-repl-SP1Gan9W.js → erlang-repl-BjcfXt3Z.js} +1 -1
- package/dist/ui/assets/{excel-0K77uECF.js → excel-Cdrtxhml.js} +1 -1
- package/dist/ui/assets/{fix-CalJq7JD.js → fix-CB-So5So.js} +1 -1
- package/dist/ui/assets/{flix-BlIs11_w.js → flix-VM9AOrq6.js} +1 -1
- package/dist/ui/assets/{flowDiagram-23GEKE2U-DA2dnmc0.js → flowDiagram-23GEKE2U-vyGW67Xm.js} +1 -1
- package/dist/ui/assets/{fortran-ZCobXY2R.js → fortran-CcwJVO8H.js} +1 -1
- package/dist/ui/assets/{fsharp-Be8rwUtc.js → fsharp-DiATpw1u.js} +1 -1
- package/dist/ui/assets/{gams-DUat8frQ.js → gams-Csg9YNPz.js} +1 -1
- package/dist/ui/assets/{ganttDiagram-NO4QXBWP-DdFwaIGZ.js → ganttDiagram-NO4QXBWP-C2TRbwLw.js} +1 -1
- package/dist/ui/assets/{gauss-BB4U88dy.js → gauss-Bc4TC8Wh.js} +1 -1
- package/dist/ui/assets/{gcode-DzeUZuZg.js → gcode-Rig_2OoA.js} +1 -1
- package/dist/ui/assets/{gherkin-B_8vW_BO.js → gherkin-ByBU06QB.js} +1 -1
- package/dist/ui/assets/{gitGraphDiagram-IHSO6WYX-B-Dn8x6I.js → gitGraphDiagram-IHSO6WYX-CEiqfFIF.js} +1 -1
- package/dist/ui/assets/{glsl-DGHGjPC1.js → glsl-C8D6y2Tn.js} +1 -1
- package/dist/ui/assets/{gml-BYEku8Yh.js → gml-PHpGPHbT.js} +1 -1
- package/dist/ui/assets/{go-D8aSgQMc.js → go-BL_o_3ez.js} +1 -1
- package/dist/ui/assets/{golo-CDjCU_jh.js → golo-CWQ6dTUz.js} +1 -1
- package/dist/ui/assets/{gradle-BeUw7tl_.js → gradle-Y_I2KN2z.js} +1 -1
- package/dist/ui/assets/{groovy-5iCQOtR3.js → groovy-JnIv8p2l.js} +1 -1
- package/dist/ui/assets/{haml-BEdL8FJi.js → haml-B8W_h6mZ.js} +1 -1
- package/dist/ui/assets/{handlebars-BuYQNzoK.js → handlebars-DVm8mJuD.js} +1 -1
- package/dist/ui/assets/{haskell-I4FCBcW0.js → haskell-DlDi2Ty7.js} +1 -1
- package/dist/ui/assets/{haxe-yigyKfFr.js → haxe-CftFNVE-.js} +1 -1
- package/dist/ui/assets/{hsp-ZUk4j7d1.js → hsp-C67xnq9C.js} +1 -1
- package/dist/ui/assets/{htmlbars-QYP3lT3u.js → htmlbars-CmJCm67U.js} +1 -1
- package/dist/ui/assets/{http-BJpD1O71.js → http-b-FPEcHP.js} +1 -1
- package/dist/ui/assets/{hy-CIJ1bP6S.js → hy-BWD3ncpN.js} +1 -1
- package/dist/ui/assets/{index-COAgrx1J.js → index-C7s1zgJb.js} +242 -242
- package/dist/ui/assets/{index-BDXWttnT.js → index-D2UBwfSG.js} +3 -3
- package/dist/ui/assets/index-DlsVXaHT.css +10 -0
- package/dist/ui/assets/{infoDiagram-FWYZ7A6U-fTg9eLNt.js → infoDiagram-FWYZ7A6U-C0Px17IN.js} +1 -1
- package/dist/ui/assets/{inform7-DAsu-lC2.js → inform7-C-OYaMO5.js} +1 -1
- package/dist/ui/assets/{ini-Bhz-zHCg.js → ini-CVyYmykw.js} +1 -1
- package/dist/ui/assets/{irpf90-BunhbwBl.js → irpf90-BcpjWXIz.js} +1 -1
- package/dist/ui/assets/{isbl-q9L6hOhP.js → isbl-ZraBBeEr.js} +1 -1
- package/dist/ui/assets/{ishikawaDiagram-FXEZZL3T-B8G0sdgd.js → ishikawaDiagram-FXEZZL3T-BjmTMgpO.js} +1 -1
- package/dist/ui/assets/{java-Iks5Pkau.js → java-D_mE2DT6.js} +1 -1
- package/dist/ui/assets/{javascript-C4vltXPw.js → javascript-akXESsox.js} +1 -1
- package/dist/ui/assets/{jboss-cli-BQBvd2X2.js → jboss-cli-CFe3gTDt.js} +1 -1
- package/dist/ui/assets/{journeyDiagram-5HDEW3XC-Crbzgrum.js → journeyDiagram-5HDEW3XC-BpgJUvs6.js} +1 -1
- package/dist/ui/assets/{json-DXK0_jUK.js → json-sjN7AzRC.js} +1 -1
- package/dist/ui/assets/{julia-CCYoBiYK.js → julia-BJJYbUMV.js} +1 -1
- package/dist/ui/assets/{julia-repl-y8v2Oorl.js → julia-repl-BwruD8Ix.js} +1 -1
- package/dist/ui/assets/{kanban-definition-HUTT4EX6-C8sCOsBX.js → kanban-definition-HUTT4EX6-DFlE9edA.js} +1 -1
- package/dist/ui/assets/{kotlin-Bnjk7_fw.js → kotlin-CAIQsLCF.js} +1 -1
- package/dist/ui/assets/{lasso-B-al6x63.js → lasso-sU67h-5u.js} +1 -1
- package/dist/ui/assets/{latex-BUmqlb9r.js → latex-CVX-jP88.js} +1 -1
- package/dist/ui/assets/{ldif-D42RWj6Q.js → ldif-DGM9xbFZ.js} +1 -1
- package/dist/ui/assets/{leaf-CrH4BZ0m.js → leaf-AlB_zmwz.js} +1 -1
- package/dist/ui/assets/{less-upmRlQQW.js → less-CKwfEdZQ.js} +1 -1
- package/dist/ui/assets/{lisp-DHYS22SA.js → lisp-CXYLaAPw.js} +1 -1
- package/dist/ui/assets/{livecodeserver-CeQNmFP3.js → livecodeserver-C02fGGTS.js} +1 -1
- package/dist/ui/assets/{livescript-PJWpY1JI.js → livescript-CBMa8QF_.js} +1 -1
- package/dist/ui/assets/{llvm-BKtKWwCt.js → llvm-WXTIohTC.js} +1 -1
- package/dist/ui/assets/{lsl-RWRLRjk7.js → lsl-4obd2U_I.js} +1 -1
- package/dist/ui/assets/{lua-BFUDiPGm.js → lua-DTSy-TjF.js} +1 -1
- package/dist/ui/assets/{makefile-CUDyOz5D.js → makefile-Bf2UEO0i.js} +1 -1
- package/dist/ui/assets/{markdown-zZCLypc6.js → markdown-BgoGmFfJ.js} +1 -1
- package/dist/ui/assets/{mathematica-BHbxKxnq.js → mathematica-CSiA8KQh.js} +1 -1
- package/dist/ui/assets/{matlab-DlGtg--p.js → matlab-DoMvLsGB.js} +1 -1
- package/dist/ui/assets/{maxima-BBBeS3Ra.js → maxima-BFO4dfZO.js} +1 -1
- package/dist/ui/assets/{mel-nh8j7W_6.js → mel-DyBpmDxt.js} +1 -1
- package/dist/ui/assets/{mercury-DyyD-pqr.js → mercury-OL5G5uU6.js} +1 -1
- package/dist/ui/assets/{mindmap-definition-LN4V7U3C-CJlhDHqM.js → mindmap-definition-LN4V7U3C-s-nUZuCs.js} +1 -1
- package/dist/ui/assets/{mipsasm-hiEhRRiq.js → mipsasm-KQwdm39j.js} +1 -1
- package/dist/ui/assets/{mizar-BZa3iAAL.js → mizar-BqndJ30I.js} +1 -1
- package/dist/ui/assets/{mojolicious-BCIm2V_y.js → mojolicious-Bvc1uJd-.js} +1 -1
- package/dist/ui/assets/{monkey-zmK-7N8b.js → monkey-Dl_gLm7-.js} +1 -1
- package/dist/ui/assets/{moonscript-BsS_Mn3D.js → moonscript-BL6R6eAz.js} +1 -1
- package/dist/ui/assets/{n1ql-D7xVgDP0.js → n1ql-C09iOJfQ.js} +1 -1
- package/dist/ui/assets/{nginx-ct2q4dtd.js → nginx-C7W01nBr.js} +1 -1
- package/dist/ui/assets/{nim-RO0UOmW3.js → nim-Dj78szvD.js} +1 -1
- package/dist/ui/assets/{nix-BcRJxPKH.js → nix-BOtGyPmd.js} +1 -1
- package/dist/ui/assets/{node-repl-DgIefwxW.js → node-repl-19nZvZ4A.js} +1 -1
- package/dist/ui/assets/{nsis-DqHs9QhB.js → nsis-ByCl1zIm.js} +1 -1
- package/dist/ui/assets/{objectivec-BBcWqc7Y.js → objectivec-BhdaT_Jr.js} +1 -1
- package/dist/ui/assets/{ocaml-BExfw7D6.js → ocaml-D_NXvSO7.js} +1 -1
- package/dist/ui/assets/{openscad-CHPRELQb.js → openscad-DOhagvnA.js} +1 -1
- package/dist/ui/assets/{oxygene-DpS9uMJW.js → oxygene-5BnkqMRH.js} +1 -1
- package/dist/ui/assets/{parser3-CjJ_QdBp.js → parser3-jSWlxi8m.js} +1 -1
- package/dist/ui/assets/{pegDiagram-2B236MQR-GM70woGy.js → pegDiagram-2B236MQR-CideH-XT.js} +1 -1
- package/dist/ui/assets/{perl-BSNM2Kt8.js → perl-CfsqjZ4b.js} +1 -1
- package/dist/ui/assets/{pf-Z-hKf_88.js → pf-kOewxO29.js} +1 -1
- package/dist/ui/assets/{pgsql-DDgznxBg.js → pgsql-CXm2Xd-Z.js} +1 -1
- package/dist/ui/assets/{php-BzAhxF-l.js → php-CRiA_dH8.js} +1 -1
- package/dist/ui/assets/{php-template-DkgcKHRc.js → php-template-ByMrxqSd.js} +1 -1
- package/dist/ui/assets/{pieDiagram-ENE6RG2P-Bst7mPyz.js → pieDiagram-ENE6RG2P-CJkCdB38.js} +1 -1
- package/dist/ui/assets/{plaintext-BYEppD0R.js → plaintext-BJx0R6A5.js} +1 -1
- package/dist/ui/assets/{pony-BT_kQd1K.js → pony-CozCHtz4.js} +1 -1
- package/dist/ui/assets/{powershell-BfRsuSsf.js → powershell-BT7gMMgn.js} +1 -1
- package/dist/ui/assets/{processing-DpzWe5Iu.js → processing-FOIxn_W_.js} +1 -1
- package/dist/ui/assets/{profile-BCOhS5cM.js → profile-BsoUuD9w.js} +1 -1
- package/dist/ui/assets/{prolog-OxaCCaW8.js → prolog-Bd3gvQ2N.js} +1 -1
- package/dist/ui/assets/{properties-DMFlA2Ca.js → properties-BWGFdny9.js} +1 -1
- package/dist/ui/assets/{protobuf-CRDFkXvZ.js → protobuf-pQSKoOOY.js} +1 -1
- package/dist/ui/assets/{puppet-DnrVyLzx.js → puppet-DnEN_mgS.js} +1 -1
- package/dist/ui/assets/{purebasic-Dht4Hniv.js → purebasic-BqoOGoRw.js} +1 -1
- package/dist/ui/assets/{python-B0aMirWu.js → python-TeVYomkE.js} +1 -1
- package/dist/ui/assets/{python-repl-BlYDBGa7.js → python-repl-zqu5igFS.js} +1 -1
- package/dist/ui/assets/{q-DzrtW9kT.js → q-CZC9Dltd.js} +1 -1
- package/dist/ui/assets/{qml-DnfQsR3i.js → qml-ZNInP45Q.js} +1 -1
- package/dist/ui/assets/{quadrantDiagram-ABIIQ3AL-DNRYurBT.js → quadrantDiagram-ABIIQ3AL-Dd7PwxsF.js} +1 -1
- package/dist/ui/assets/{r-DGI_ZuTD.js → r-B39DAmkC.js} +1 -1
- package/dist/ui/assets/{railroadDiagram-RFXS5EU6-CmbC3Vz4.js → railroadDiagram-RFXS5EU6-DtO5PVFZ.js} +1 -1
- package/dist/ui/assets/{reasonml-3SohMgh2.js → reasonml-B-ZWFJt_.js} +1 -1
- package/dist/ui/assets/{requirementDiagram-TGXJPOKE-8CxrXHco.js → requirementDiagram-TGXJPOKE-DihF4OTj.js} +1 -1
- package/dist/ui/assets/{rib-DfRSd4Qa.js → rib-CnGG0qMF.js} +1 -1
- package/dist/ui/assets/{roboconf-CQczGdGW.js → roboconf-Ewtfps4u.js} +1 -1
- package/dist/ui/assets/{routeros-DCka-T2i.js → routeros-CPcmP1c7.js} +1 -1
- package/dist/ui/assets/{rsl-Dr8MOwMo.js → rsl-NbjWFbPH.js} +1 -1
- package/dist/ui/assets/{ruby-C2zFSkh_.js → ruby-DWDdy5yE.js} +1 -1
- package/dist/ui/assets/{ruleslanguage-C97YsgQq.js → ruleslanguage-Cv_DZe2r.js} +1 -1
- package/dist/ui/assets/{rust-H3h8kd9A.js → rust-NZnsfER5.js} +1 -1
- package/dist/ui/assets/{sankeyDiagram-HTMAVEWB-DBXLWjEq.js → sankeyDiagram-HTMAVEWB-D6i-Mzte.js} +1 -1
- package/dist/ui/assets/{sas-04z0Xu8P.js → sas-C4wv0P6G.js} +1 -1
- package/dist/ui/assets/{scala-DyB9Aoiv.js → scala-DUdTOIgx.js} +1 -1
- package/dist/ui/assets/{scheme-DBj6nxUi.js → scheme-DEdFa14t.js} +1 -1
- package/dist/ui/assets/{scilab-Btj7AD9s.js → scilab-xY51J2bR.js} +1 -1
- package/dist/ui/assets/{scss-BXZJyXt7.js → scss-BEYp1sXc.js} +1 -1
- package/dist/ui/assets/{sequenceDiagram-DBY2YBRQ-DXIkBFKC.js → sequenceDiagram-DBY2YBRQ-njQlqy_J.js} +1 -1
- package/dist/ui/assets/{shell-BsreQR1Z.js → shell-fq6bkhOw.js} +1 -1
- package/dist/ui/assets/{sizeCapture-X5ZJPWSS-ocS9jxAQ.js → sizeCapture-X5ZJPWSS-tLn70-Fb.js} +1 -1
- package/dist/ui/assets/{smali-D9wQw9zm.js → smali-CsSAuSYg.js} +1 -1
- package/dist/ui/assets/{smalltalk-Dku6G_H3.js → smalltalk-DJ7zrd87.js} +1 -1
- package/dist/ui/assets/{sml-BknyU6ya.js → sml-CnDwl0nH.js} +1 -1
- package/dist/ui/assets/{sqf-DRYMaOg8.js → sqf-Cc2SX4Zy.js} +1 -1
- package/dist/ui/assets/{sql-Cw3Ax4KA.js → sql-DUQA_V_4.js} +1 -1
- package/dist/ui/assets/{sql_more-vWdslLE0.js → sql_more-BHoH-8oO.js} +1 -1
- package/dist/ui/assets/{stan-8XH5bDS6.js → stan-D-7F5jH6.js} +1 -1
- package/dist/ui/assets/{stata-4e77wgfe.js → stata-xKD_DnDE.js} +1 -1
- package/dist/ui/assets/{stateDiagram-2N3HPSRC-RMmL9jMG.js → stateDiagram-2N3HPSRC-B4O8weor.js} +1 -1
- package/dist/ui/assets/stateDiagram-v2-6OUMAXLB-CO881_ht.js +1 -0
- package/dist/ui/assets/{step21-ByIeDMY3.js → step21-obc_kzQY.js} +1 -1
- package/dist/ui/assets/{stylus-ZAhJyWsw.js → stylus-CkAUSRd-.js} +1 -1
- package/dist/ui/assets/{subunit-pPW2UGkj.js → subunit-BDv8PGo1.js} +1 -1
- package/dist/ui/assets/{swift-CX3BB5az.js → swift-CHsYyW-p.js} +1 -1
- package/dist/ui/assets/{swimlanes-5IMT3BWC-C2zAuJ56.js → swimlanes-5IMT3BWC-DSr9Ty4A.js} +2 -2
- package/dist/ui/assets/swimlanesDiagram-G3AALYLV-DFMCDs8b.js +8 -0
- package/dist/ui/assets/{taggerscript-BHcjbWIC.js → taggerscript-C_2JQgO9.js} +1 -1
- package/dist/ui/assets/{tap-BOl1lBlS.js → tap-Bi497Z2c.js} +1 -1
- package/dist/ui/assets/{tcl-DZjeOBDh.js → tcl-B1XMvLaD.js} +1 -1
- package/dist/ui/assets/{thrift-BxboWg4x.js → thrift-D9X0Hmmc.js} +1 -1
- package/dist/ui/assets/{timeline-definition-FHXFAJF6-BOxsxyq_.js → timeline-definition-FHXFAJF6-C4_gj50B.js} +1 -1
- package/dist/ui/assets/{tp-BNM6ql3J.js → tp-CJG4Odbx.js} +1 -1
- package/dist/ui/assets/{twig-Dj9ZiXD4.js → twig-flj72_wc.js} +1 -1
- package/dist/ui/assets/{typescript-7MEJlu_6.js → typescript-CWPwVoLd.js} +1 -1
- package/dist/ui/assets/{vala-DNqOAgHJ.js → vala-LuCNWNuU.js} +1 -1
- package/dist/ui/assets/{vbnet-T0mNKVc_.js → vbnet-CGUT6ss0.js} +1 -1
- package/dist/ui/assets/{vbscript-CeuwVMAI.js → vbscript-CNiUBJhn.js} +1 -1
- package/dist/ui/assets/{vbscript-html-BbJSt2w6.js → vbscript-html-CJGgjjbc.js} +1 -1
- package/dist/ui/assets/{vennDiagram-L72KCM5P-BX9mWeiT.js → vennDiagram-L72KCM5P-BxcAUnYo.js} +1 -1
- package/dist/ui/assets/{verilog-DYuhYfkX.js → verilog-C4f9ZBTK.js} +1 -1
- package/dist/ui/assets/{vhdl-Cf9aT-t7.js → vhdl-CyDQIZve.js} +1 -1
- package/dist/ui/assets/{vim-DciP44K1.js → vim-XAUBqa0M.js} +1 -1
- package/dist/ui/assets/{wardleyDiagram-EHGQE667-CDj2rOzu.js → wardleyDiagram-EHGQE667-DlwSH77q.js} +1 -1
- package/dist/ui/assets/{x86asm-E-AN_LXO.js → x86asm-Cp6vHuUx.js} +1 -1
- package/dist/ui/assets/{xl-CxYLJelN.js → xl-BHgDofIM.js} +1 -1
- package/dist/ui/assets/{xml-yz1SRLuU.js → xml-QloVn4s_.js} +1 -1
- package/dist/ui/assets/{xquery-BLzBF3tV.js → xquery-spJZLmyM.js} +1 -1
- package/dist/ui/assets/{xychartDiagram-FW5EYKEG-Czapk9-Z.js → xychartDiagram-FW5EYKEG-BxGVZcnb.js} +1 -1
- package/dist/ui/assets/{yaml-Cv4Y7iN_.js → yaml-CUju4iq0.js} +1 -1
- package/dist/ui/assets/{zephir-KRcdQfEX.js → zephir-ChVpmD0Y.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/utils/__tests__/abort-signals.test.js +67 -0
- package/dist/utils/__tests__/db-maintenance.test.js +55 -0
- package/dist/utils/__tests__/db-migration.test.js +79 -1
- package/dist/utils/__tests__/inject-loop.test.js +1 -53
- package/dist/utils/__tests__/learn-tasks-db.test.js +82 -0
- package/dist/utils/__tests__/openai-converter.test.js +25 -0
- package/dist/utils/__tests__/pi-crawl-tools.test.js +15 -4
- package/dist/utils/__tests__/pi-dedup-reconcile.test.js +11 -9
- package/dist/utils/__tests__/pi-events.test.d.ts +1 -0
- package/dist/utils/__tests__/pi-events.test.js +172 -0
- package/dist/utils/__tests__/pi-learn-orchestrator.test.js +216 -6
- package/dist/utils/__tests__/pi-runtime-json.test.js +38 -3
- package/dist/utils/__tests__/providers-db.test.js +40 -2
- package/dist/utils/__tests__/request-writer.test.js +532 -39
- package/dist/utils/__tests__/sse-protocol.test.d.ts +1 -0
- package/dist/utils/__tests__/sse-protocol.test.js +115 -0
- package/dist/utils/__tests__/stats-aggregator.test.d.ts +1 -0
- package/dist/utils/__tests__/stats-aggregator.test.js +114 -0
- package/dist/utils/__tests__/vault.test.d.ts +1 -0
- package/dist/utils/__tests__/{knowledge-store.test.js → vault.test.js} +16 -16
- package/dist/utils/abort-signals.d.ts +13 -0
- package/dist/utils/abort-signals.js +33 -0
- package/dist/utils/db-maintenance.d.ts +8 -0
- package/dist/utils/db-maintenance.js +18 -0
- package/dist/utils/db.d.ts +2 -0
- package/dist/utils/db.js +86 -0
- package/dist/utils/esm-dirname.d.ts +0 -15
- package/dist/utils/esm-dirname.js +0 -4
- package/dist/utils/inject-loop.d.ts +0 -27
- package/dist/utils/inject-loop.js +2 -56
- package/dist/utils/learn-tasks-db.d.ts +15 -0
- package/dist/utils/learn-tasks-db.js +35 -0
- package/dist/utils/openai-converter.js +88 -78
- package/dist/utils/pi-browser-tools.d.ts +0 -2
- package/dist/utils/pi-browser-tools.js +0 -174
- package/dist/utils/pi-crawl-tools.d.ts +2 -1
- package/dist/utils/pi-crawl-tools.js +16 -11
- package/dist/utils/pi-dedup.d.ts +8 -30
- package/dist/utils/pi-dedup.js +32 -67
- package/dist/utils/pi-events.d.ts +65 -0
- package/dist/utils/pi-events.js +98 -0
- package/dist/utils/pi-learn-orchestrator.d.ts +6 -5
- package/dist/utils/pi-learn-orchestrator.js +71 -106
- package/dist/utils/pi-runtime.d.ts +5 -6
- package/dist/utils/pi-runtime.js +38 -42
- package/dist/utils/pi-sandbox-ops.d.ts +0 -36
- package/dist/utils/pi-sandbox-ops.js +5 -190
- package/dist/utils/providers-db.d.ts +3 -0
- package/dist/utils/providers-db.js +21 -7
- package/dist/utils/request-writer.d.ts +77 -26
- package/dist/utils/request-writer.js +362 -56
- package/dist/utils/sse-protocol.d.ts +34 -0
- package/dist/utils/sse-protocol.js +121 -0
- package/dist/utils/sse-stream-processor.d.ts +4 -9
- package/dist/utils/sse-stream-processor.js +13 -104
- package/dist/utils/sse-writer.d.ts +1 -1
- package/dist/utils/sse-writer.js +3 -2
- package/dist/utils/stats-aggregator.d.ts +1 -1
- package/dist/utils/stats-aggregator.js +44 -24
- package/dist/utils/tool-injector.js +7 -0
- package/dist/utils/vault.d.ts +111 -0
- package/dist/utils/vault.js +434 -0
- package/ecosystem.config.cjs +2 -1
- package/package.json +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.B6Qfxe6W.js +0 -1
- package/dist/server/middleware/__tests__/request-id.test.js +0 -28
- package/dist/server/middleware/request-id.d.ts +0 -2
- package/dist/server/middleware/request-id.js +0 -12
- package/dist/types/api.d.ts +0 -20
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.js +0 -4
- package/dist/types/log.d.ts +0 -13
- package/dist/ui/assets/channel-Bc4Td8eZ.js +0 -1
- package/dist/ui/assets/classDiagram-OUVF2IWQ-BicxhZFq.js +0 -1
- package/dist/ui/assets/classDiagram-v2-EOCWNBFH-BicxhZFq.js +0 -1
- package/dist/ui/assets/index-C0fxlU9d.css +0 -10
- package/dist/ui/assets/stateDiagram-v2-6OUMAXLB-QvaEO5U6.js +0 -1
- package/dist/ui/assets/swimlanesDiagram-G3AALYLV-DPgCOY0D.js +0 -8
- package/dist/utils/__tests__/sse-accumulator.test.js +0 -83
- package/dist/utils/knowledge-store.d.ts +0 -51
- package/dist/utils/knowledge-store.js +0 -241
- package/dist/utils/migrate-files-to-db.d.ts +0 -1
- package/dist/utils/migrate-files-to-db.js +0 -138
- package/dist/utils/sse-accumulator.d.ts +0 -9
- package/dist/utils/sse-accumulator.js +0 -59
- /package/dist/docs/assets/{proxy-cli_data-hooks.md.w9Oe1OD3.lean.js → proxy-cli_data-hooks.md.Bz8CVbxO.lean.js} +0 -0
- /package/dist/docs/assets/{proxy-core_ui-routes.md.Dyqkeoiv.lean.js → proxy-core_ui-routes.md.B21t1p7R.lean.js} +0 -0
- /package/dist/server/{middleware/__tests__/request-id.test.d.ts → __tests__/data-push.test.d.ts} +0 -0
- /package/dist/{types/api.js → utils/__tests__/abort-signals.test.d.ts} +0 -0
- /package/dist/{types/log.js → utils/__tests__/db-maintenance.test.d.ts} +0 -0
- /package/dist/utils/__tests__/{knowledge-store.test.d.ts → learn-tasks-db.test.d.ts} +0 -0
- /package/dist/utils/__tests__/{sse-accumulator.test.d.ts → openai-converter.test.d.ts} +0 -0
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
// vault:learn 文件型知识库(~/.cc-monitoring/docs)的深 module。
|
|
2
|
+
// 物理布局:
|
|
3
|
+
// - index.json 根索引 {"topics":[TopicSummary]}
|
|
4
|
+
// - <slug>/index.json 主题索引 TopicIndex(元数据 + chunks 引用)
|
|
5
|
+
// - <slug>/outline.json、<slug>/sources/source-NNN.md、<slug>/chunks/chunk-NNN.md
|
|
6
|
+
// - <slug>.old/ 旁挂备份
|
|
7
|
+
// 所有路径解析、slug/chunk-id 校验、物理读写均以本 module 为唯一权威。
|
|
8
|
+
import { promises as fs } from 'node:fs';
|
|
9
|
+
import fsSync from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { dataDir } from './paths.js';
|
|
12
|
+
// 合法 slug:小写字母数字开头,仅含小写字母数字与连字符
|
|
13
|
+
const SLUG_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
14
|
+
const CHUNK_RE = /^chunk-\d{3}$/;
|
|
15
|
+
export function isValidSlug(slug) {
|
|
16
|
+
return SLUG_RE.test(slug);
|
|
17
|
+
}
|
|
18
|
+
export function createVault(docsDir) {
|
|
19
|
+
// ---- 路径解析(单一权威)----
|
|
20
|
+
const rootIndexPath = () => path.join(docsDir, 'index.json');
|
|
21
|
+
const entryDir = (entry) => path.join(docsDir, entry);
|
|
22
|
+
const entryIndexPath = (entry) => path.join(docsDir, entry, 'index.json');
|
|
23
|
+
const entrySubdir = (entry, subdir) => path.join(docsDir, entry, subdir);
|
|
24
|
+
function assertTopic(topic) {
|
|
25
|
+
if (!SLUG_RE.test(topic)) {
|
|
26
|
+
throw new Error(`invalid topic slug: ${topic}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function assertChunkId(chunkId) {
|
|
30
|
+
if (!CHUNK_RE.test(chunkId)) {
|
|
31
|
+
throw new Error(`invalid chunk id: ${chunkId} (expect chunk-NNN)`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** 从 chunk 正文首行 `# xxx` 提取 title(用于 searchChunks) */
|
|
35
|
+
function parseChunkTitle(text) {
|
|
36
|
+
const m = text.match(/^#\s+(.+?)\s*$/m);
|
|
37
|
+
return m ? m[1].trim() : '';
|
|
38
|
+
}
|
|
39
|
+
/** 读 JSON 文件,不存在或解析失败时返回 fallback */
|
|
40
|
+
async function readJsonOr(file, fallback) {
|
|
41
|
+
try {
|
|
42
|
+
const text = await fs.readFile(file, 'utf8');
|
|
43
|
+
return JSON.parse(text);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return fallback;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// ============================================================
|
|
50
|
+
// 读 / 查(原 knowledge-store,逐字保持)
|
|
51
|
+
// ============================================================
|
|
52
|
+
async function listTopics() {
|
|
53
|
+
const parsed = await readJsonOr(rootIndexPath(), { topics: [] });
|
|
54
|
+
return Array.isArray(parsed.topics) ? parsed.topics : [];
|
|
55
|
+
}
|
|
56
|
+
async function getTopic(topic) {
|
|
57
|
+
assertTopic(topic);
|
|
58
|
+
const indexPath = entryIndexPath(topic);
|
|
59
|
+
let meta;
|
|
60
|
+
try {
|
|
61
|
+
const text = await fs.readFile(indexPath, 'utf8');
|
|
62
|
+
meta = JSON.parse(text);
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
if (e && e.code === 'ENOENT') {
|
|
66
|
+
throw new Error(`topic not found: ${topic}`);
|
|
67
|
+
}
|
|
68
|
+
throw new Error(`topic index corrupt: ${topic}, fix or delete ${topic}/index.json`);
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
title: meta.title || topic,
|
|
72
|
+
tags: Array.isArray(meta.tags) ? meta.tags : [],
|
|
73
|
+
sources: [],
|
|
74
|
+
chunks: Array.isArray(meta.chunks)
|
|
75
|
+
? meta.chunks.map(c => ({
|
|
76
|
+
id: c.id,
|
|
77
|
+
title: c.title,
|
|
78
|
+
summary: c.summary,
|
|
79
|
+
tags: Array.isArray(c.tags) ? c.tags : [],
|
|
80
|
+
}))
|
|
81
|
+
: [],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async function upsertTopic(input) {
|
|
85
|
+
assertTopic(input.slug);
|
|
86
|
+
const { slug, title, summary, tags } = input;
|
|
87
|
+
// 1. 更新根 index.json
|
|
88
|
+
const rootPath = rootIndexPath();
|
|
89
|
+
const rootIdx = await readJsonOr(rootPath, { topics: [] });
|
|
90
|
+
if (!Array.isArray(rootIdx.topics))
|
|
91
|
+
rootIdx.topics = [];
|
|
92
|
+
const existingRoot = rootIdx.topics.find(t => t.slug === slug);
|
|
93
|
+
if (existingRoot) {
|
|
94
|
+
existingRoot.title = title;
|
|
95
|
+
existingRoot.summary = summary;
|
|
96
|
+
existingRoot.tags = tags;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
rootIdx.topics.push({ slug, title, summary, tags });
|
|
100
|
+
}
|
|
101
|
+
await fs.writeFile(rootPath, JSON.stringify(rootIdx, null, 2), 'utf8');
|
|
102
|
+
// 2. 更新主题 index.json(不动 chunks 数组)
|
|
103
|
+
const topicDir = entryDir(slug);
|
|
104
|
+
const topicPath = entryIndexPath(slug);
|
|
105
|
+
const topicIdx = await readJsonOr(topicPath, { slug, title, summary, tags, chunks: [] });
|
|
106
|
+
topicIdx.slug = slug;
|
|
107
|
+
topicIdx.title = title;
|
|
108
|
+
topicIdx.summary = summary;
|
|
109
|
+
topicIdx.tags = tags;
|
|
110
|
+
if (!Array.isArray(topicIdx.chunks))
|
|
111
|
+
topicIdx.chunks = [];
|
|
112
|
+
await fs.mkdir(topicDir, { recursive: true });
|
|
113
|
+
await fs.writeFile(topicPath, JSON.stringify(topicIdx, null, 2), 'utf8');
|
|
114
|
+
}
|
|
115
|
+
async function upsertChunkRef(input) {
|
|
116
|
+
assertTopic(input.topic);
|
|
117
|
+
assertChunkId(input.chunkId);
|
|
118
|
+
const { topic, chunkId, title, summary, tags } = input;
|
|
119
|
+
const topicPath = entryIndexPath(topic);
|
|
120
|
+
let topicIdx;
|
|
121
|
+
try {
|
|
122
|
+
const text = await fs.readFile(topicPath, 'utf8');
|
|
123
|
+
topicIdx = JSON.parse(text);
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
if (e && e.code === 'ENOENT') {
|
|
127
|
+
throw new Error(`topic not found: ${topic}, call add_topic first`);
|
|
128
|
+
}
|
|
129
|
+
throw e;
|
|
130
|
+
}
|
|
131
|
+
if (!Array.isArray(topicIdx.chunks))
|
|
132
|
+
topicIdx.chunks = [];
|
|
133
|
+
const existing = topicIdx.chunks.find(c => c.id === chunkId);
|
|
134
|
+
if (existing) {
|
|
135
|
+
existing.title = title;
|
|
136
|
+
existing.summary = summary;
|
|
137
|
+
existing.tags = tags;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
topicIdx.chunks.push({ id: chunkId, title, summary, tags });
|
|
141
|
+
}
|
|
142
|
+
await fs.writeFile(topicPath, JSON.stringify(topicIdx, null, 2), 'utf8');
|
|
143
|
+
}
|
|
144
|
+
/** 匹配词集合:整体 query + whitespace 分割的长度 >1 的 token,去重 */
|
|
145
|
+
function buildTerms(query) {
|
|
146
|
+
const q = query.toLowerCase();
|
|
147
|
+
const terms = new Set([q]);
|
|
148
|
+
for (const tok of q.split(/\s+/)) {
|
|
149
|
+
if (tok.length > 1)
|
|
150
|
+
terms.add(tok);
|
|
151
|
+
}
|
|
152
|
+
return [...terms];
|
|
153
|
+
}
|
|
154
|
+
/** 扫描所有 topic/chunk,返回打分候选(searchChunks / queryKnowledge 共用) */
|
|
155
|
+
async function scanChunks(query) {
|
|
156
|
+
const q = query.toLowerCase();
|
|
157
|
+
if (!q.trim())
|
|
158
|
+
return [];
|
|
159
|
+
const terms = buildTerms(query);
|
|
160
|
+
const candidates = [];
|
|
161
|
+
// topic index 本函数作用域缓存,避免每个 chunk 重复读
|
|
162
|
+
const topicIndexCache = new Map();
|
|
163
|
+
let entries;
|
|
164
|
+
try {
|
|
165
|
+
entries = await fs.readdir(docsDir);
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
return [];
|
|
169
|
+
}
|
|
170
|
+
for (const topic of entries) {
|
|
171
|
+
if (!SLUG_RE.test(topic))
|
|
172
|
+
continue;
|
|
173
|
+
if (!topicIndexCache.has(topic)) {
|
|
174
|
+
const idx = await readJsonOr(entryIndexPath(topic), null);
|
|
175
|
+
topicIndexCache.set(topic, idx);
|
|
176
|
+
}
|
|
177
|
+
const topicIdx = topicIndexCache.get(topic) ?? null;
|
|
178
|
+
const topicTags = topicIdx && Array.isArray(topicIdx.tags) ? topicIdx.tags : [];
|
|
179
|
+
const chunkRefs = topicIdx && Array.isArray(topicIdx.chunks) ? topicIdx.chunks : [];
|
|
180
|
+
const topicTagHit = (term) => topicTags.some(t => t.toLowerCase().includes(term));
|
|
181
|
+
const chunksDir = entrySubdir(topic, 'chunks');
|
|
182
|
+
let files;
|
|
183
|
+
try {
|
|
184
|
+
files = await fs.readdir(chunksDir);
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
for (const file of files) {
|
|
190
|
+
const chunkId = file.replace(/\.md$/, '');
|
|
191
|
+
if (!CHUNK_RE.test(chunkId))
|
|
192
|
+
continue;
|
|
193
|
+
const text = await fs.readFile(path.join(chunksDir, file), 'utf8');
|
|
194
|
+
const textLc = text.toLowerCase();
|
|
195
|
+
const ref = chunkRefs.find(c => c.id === chunkId);
|
|
196
|
+
const refTitle = (ref?.title ?? '').toLowerCase();
|
|
197
|
+
const refSummary = (ref?.summary ?? '').toLowerCase();
|
|
198
|
+
const refTags = ref && Array.isArray(ref.tags) ? ref.tags : [];
|
|
199
|
+
let score = 0;
|
|
200
|
+
for (const term of terms) {
|
|
201
|
+
// 每个字段每词只计一次分,body 不按出现次数刷分
|
|
202
|
+
if (refTitle.includes(term))
|
|
203
|
+
score += 3;
|
|
204
|
+
if (refTags.some(t => t.toLowerCase().includes(term)))
|
|
205
|
+
score += 2;
|
|
206
|
+
if (topicTagHit(term))
|
|
207
|
+
score += 2;
|
|
208
|
+
if (refSummary.includes(term))
|
|
209
|
+
score += 1;
|
|
210
|
+
if (textLc.includes(term))
|
|
211
|
+
score += 1;
|
|
212
|
+
}
|
|
213
|
+
if (score === 0)
|
|
214
|
+
continue;
|
|
215
|
+
const wholeQueryHit = textLc.includes(q) ||
|
|
216
|
+
refTitle.includes(q) ||
|
|
217
|
+
refSummary.includes(q) ||
|
|
218
|
+
topicTagHit(q) ||
|
|
219
|
+
refTags.some(t => t.toLowerCase().includes(q));
|
|
220
|
+
candidates.push({ topic, chunkId, title: parseChunkTitle(text), score, wholeQueryHit });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return candidates;
|
|
224
|
+
}
|
|
225
|
+
async function searchChunks(query) {
|
|
226
|
+
if (!query.trim())
|
|
227
|
+
return [];
|
|
228
|
+
return (await scanChunks(query))
|
|
229
|
+
.filter(c => c.wholeQueryHit)
|
|
230
|
+
.map(({ topic, chunkId, title }) => ({ topic, chunkId, title }));
|
|
231
|
+
}
|
|
232
|
+
async function queryKnowledge(query, limit = 3) {
|
|
233
|
+
const capped = Math.min(Math.max(limit, 1), 5);
|
|
234
|
+
const candidates = (await scanChunks(query))
|
|
235
|
+
.sort((a, b) => b.score - a.score)
|
|
236
|
+
.slice(0, capped);
|
|
237
|
+
const hits = [];
|
|
238
|
+
for (const c of candidates) {
|
|
239
|
+
const body = await readChunk(c.topic, c.chunkId);
|
|
240
|
+
hits.push({ topic: c.topic, chunkId: c.chunkId, title: c.title, body });
|
|
241
|
+
}
|
|
242
|
+
return hits;
|
|
243
|
+
}
|
|
244
|
+
async function readChunk(topic, chunkId) {
|
|
245
|
+
assertTopic(topic);
|
|
246
|
+
assertChunkId(chunkId);
|
|
247
|
+
const filePath = path.join(entrySubdir(topic, 'chunks'), `${chunkId}.md`);
|
|
248
|
+
// 二次校验:解析后路径必须在 root/<topic>/chunks/ 内
|
|
249
|
+
const resolved = path.resolve(filePath);
|
|
250
|
+
const expectedDir = path.resolve(docsDir, topic, 'chunks');
|
|
251
|
+
if (!resolved.startsWith(expectedDir + path.sep)) {
|
|
252
|
+
throw new Error('access denied: chunk path escapes chunks dir');
|
|
253
|
+
}
|
|
254
|
+
return fs.readFile(resolved, 'utf8');
|
|
255
|
+
}
|
|
256
|
+
// ============================================================
|
|
257
|
+
// 主题索引(async;缺失/坏 → null)
|
|
258
|
+
// ============================================================
|
|
259
|
+
async function readTopicIndex(slug) {
|
|
260
|
+
try {
|
|
261
|
+
const raw = await fs.readFile(entryIndexPath(slug), 'utf8');
|
|
262
|
+
return JSON.parse(raw);
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
async function readSidecarIndex(slug) {
|
|
269
|
+
try {
|
|
270
|
+
const raw = await fs.readFile(entryIndexPath(`${slug}.old`), 'utf8');
|
|
271
|
+
return JSON.parse(raw);
|
|
272
|
+
}
|
|
273
|
+
catch {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// ============================================================
|
|
278
|
+
// 物理操作(sync)
|
|
279
|
+
// ============================================================
|
|
280
|
+
function assertSlug(slug, field = 'slug') {
|
|
281
|
+
if (!SLUG_RE.test(slug)) {
|
|
282
|
+
throw new Error(`invalid ${field}: ${slug}`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/** 重建 topic 目录:sources/(抓取/上传原料)+ chunks/(后续产物) */
|
|
286
|
+
function prepareTopic(slug) {
|
|
287
|
+
const dir = entryDir(slug);
|
|
288
|
+
fsSync.rmSync(dir, { recursive: true, force: true });
|
|
289
|
+
fsSync.mkdirSync(path.join(dir, 'sources'), { recursive: true });
|
|
290
|
+
fsSync.mkdirSync(path.join(dir, 'chunks'), { recursive: true });
|
|
291
|
+
}
|
|
292
|
+
/** 写一份原料到 <slug>/sources/source-NNN.md */
|
|
293
|
+
function writeSourceFile(slug, index, url, text) {
|
|
294
|
+
const dir = entrySubdir(slug, 'sources');
|
|
295
|
+
fsSync.mkdirSync(dir, { recursive: true });
|
|
296
|
+
const name = `source-${String(index + 1).padStart(3, '0')}.md`;
|
|
297
|
+
fsSync.writeFileSync(path.join(dir, name), `Source: ${url}\n\n${text}`, 'utf8');
|
|
298
|
+
}
|
|
299
|
+
/** 数 <slug>/sources 下 .md 文件数量;目录不存在按 0 */
|
|
300
|
+
function countSourceFiles(slug) {
|
|
301
|
+
try {
|
|
302
|
+
return fsSync.readdirSync(entrySubdir(slug, 'sources')).filter((f) => f.endsWith('.md')).length;
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
return 0;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function readSourceBodies(slug) {
|
|
309
|
+
const dir = entrySubdir(slug, 'sources');
|
|
310
|
+
const files = fsSync.readdirSync(dir).filter((f) => f.endsWith('.md')).sort();
|
|
311
|
+
return files.map((f) => fsSync.readFileSync(path.join(dir, f), 'utf8'));
|
|
312
|
+
}
|
|
313
|
+
function writeOutline(slug, items) {
|
|
314
|
+
assertSlug(slug, 'slug');
|
|
315
|
+
const topicDir = entryDir(slug);
|
|
316
|
+
if (!fsSync.existsSync(topicDir))
|
|
317
|
+
throw new Error(`topic dir not prepared: ${slug}`);
|
|
318
|
+
if (!fsSync.existsSync(path.join(topicDir, 'sources')))
|
|
319
|
+
throw new Error(`sources missing for topic: ${slug}`);
|
|
320
|
+
fsSync.writeFileSync(path.join(topicDir, 'outline.json'), JSON.stringify({ slug, source: 'sources/', items }, null, 2));
|
|
321
|
+
}
|
|
322
|
+
function readOutlineItems(slug) {
|
|
323
|
+
const outlinePath = path.join(entryDir(slug), 'outline.json');
|
|
324
|
+
if (!fsSync.existsSync(outlinePath))
|
|
325
|
+
throw new Error('outline 未生成');
|
|
326
|
+
const outline = JSON.parse(fsSync.readFileSync(outlinePath, 'utf8'));
|
|
327
|
+
return outline.items;
|
|
328
|
+
}
|
|
329
|
+
function parkTopic(slug) {
|
|
330
|
+
fsSync.renameSync(entryDir(slug), entryDir(`${slug}.old`));
|
|
331
|
+
}
|
|
332
|
+
function restoreTopic(slug) {
|
|
333
|
+
fsSync.renameSync(entryDir(`${slug}.old`), entryDir(slug));
|
|
334
|
+
}
|
|
335
|
+
function renameTopic(slug, newSlug) {
|
|
336
|
+
fsSync.renameSync(entryDir(slug), entryDir(newSlug));
|
|
337
|
+
}
|
|
338
|
+
function readEntryIndexSync(entry) {
|
|
339
|
+
return JSON.parse(fsSync.readFileSync(entryIndexPath(entry), 'utf8'));
|
|
340
|
+
}
|
|
341
|
+
function writeEntryIndexSync(entry, idx) {
|
|
342
|
+
fsSync.writeFileSync(entryIndexPath(entry), JSON.stringify(idx, null, 2));
|
|
343
|
+
}
|
|
344
|
+
function readRootIndexSync() {
|
|
345
|
+
return JSON.parse(fsSync.readFileSync(rootIndexPath(), 'utf8'));
|
|
346
|
+
}
|
|
347
|
+
function writeRootIndexSync(root) {
|
|
348
|
+
fsSync.writeFileSync(rootIndexPath(), JSON.stringify(root, null, 2));
|
|
349
|
+
}
|
|
350
|
+
/** 列出 dir 下的 .md 文件名(排序);目录缺失视为空 */
|
|
351
|
+
function listEntryMd(entry, subdir) {
|
|
352
|
+
try {
|
|
353
|
+
return fsSync.readdirSync(entrySubdir(entry, subdir)).filter(f => f.endsWith('.md')).sort();
|
|
354
|
+
}
|
|
355
|
+
catch {
|
|
356
|
+
return [];
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
function mkdirEntrySubdir(entry, subdir) {
|
|
360
|
+
fsSync.mkdirSync(entrySubdir(entry, subdir), { recursive: true });
|
|
361
|
+
}
|
|
362
|
+
function readEntryFile(entry, subdir, file) {
|
|
363
|
+
return fsSync.readFileSync(path.join(entrySubdir(entry, subdir), file));
|
|
364
|
+
}
|
|
365
|
+
function writeEntryFile(entry, subdir, file, body) {
|
|
366
|
+
fsSync.writeFileSync(path.join(entrySubdir(entry, subdir), file), body);
|
|
367
|
+
}
|
|
368
|
+
function unlinkEntryFile(entry, subdir, file) {
|
|
369
|
+
fsSync.unlinkSync(path.join(entrySubdir(entry, subdir), file));
|
|
370
|
+
}
|
|
371
|
+
function removeEntry(entry) {
|
|
372
|
+
fsSync.rmSync(entryDir(entry), { recursive: true, force: true });
|
|
373
|
+
}
|
|
374
|
+
// 阻断:docsDir 下存在任何 .old 旁挂目录时抛错,要求人工先处理。
|
|
375
|
+
// docsDir 本身缺失时直接让 readdirSync 抛错(调用方本就应在已初始化的库上学习)。
|
|
376
|
+
function assertNoOldSidecars() {
|
|
377
|
+
const oldDir = fsSync.readdirSync(docsDir).find(name => name.endsWith('.old'));
|
|
378
|
+
if (oldDir) {
|
|
379
|
+
throw new Error(`检测到未清理的旁挂目录 ${oldDir},请手工处理后再学习`);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
// ============================================================
|
|
383
|
+
// 沙箱判定
|
|
384
|
+
// ============================================================
|
|
385
|
+
function assertInside(absPath) {
|
|
386
|
+
const resolved = path.resolve(absPath);
|
|
387
|
+
if (resolved !== docsDir && !resolved.startsWith(docsDir + path.sep)) {
|
|
388
|
+
throw new Error(`Access denied: ${absPath} is outside the knowledge directory ${docsDir}`);
|
|
389
|
+
}
|
|
390
|
+
return resolved;
|
|
391
|
+
}
|
|
392
|
+
function assertNotManagedIndexJson(absPath) {
|
|
393
|
+
if (path.basename(absPath) === 'index.json') {
|
|
394
|
+
throw new Error('index.json is managed by add_topic/add_chunk tools, do not write directly');
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return {
|
|
398
|
+
root: docsDir,
|
|
399
|
+
listTopics,
|
|
400
|
+
getTopic,
|
|
401
|
+
searchChunks,
|
|
402
|
+
queryKnowledge,
|
|
403
|
+
readChunk,
|
|
404
|
+
upsertTopic,
|
|
405
|
+
upsertChunkRef,
|
|
406
|
+
readTopicIndex,
|
|
407
|
+
readSidecarIndex,
|
|
408
|
+
assertSlug,
|
|
409
|
+
prepareTopic,
|
|
410
|
+
writeSourceFile,
|
|
411
|
+
countSourceFiles,
|
|
412
|
+
readSourceBodies,
|
|
413
|
+
writeOutline,
|
|
414
|
+
readOutlineItems,
|
|
415
|
+
parkTopic,
|
|
416
|
+
restoreTopic,
|
|
417
|
+
renameTopic,
|
|
418
|
+
readEntryIndexSync,
|
|
419
|
+
writeEntryIndexSync,
|
|
420
|
+
readRootIndexSync,
|
|
421
|
+
writeRootIndexSync,
|
|
422
|
+
listEntryMd,
|
|
423
|
+
mkdirEntrySubdir,
|
|
424
|
+
readEntryFile,
|
|
425
|
+
writeEntryFile,
|
|
426
|
+
unlinkEntryFile,
|
|
427
|
+
removeEntry,
|
|
428
|
+
assertNoOldSidecars,
|
|
429
|
+
assertInside,
|
|
430
|
+
assertNotManagedIndexJson,
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
// 默认单例:绑生产 docsDir
|
|
434
|
+
export const vault = createVault(path.join(dataDir, 'docs'));
|
package/ecosystem.config.cjs
CHANGED
|
@@ -15,7 +15,8 @@ module.exports = {
|
|
|
15
15
|
exec_mode: 'fork', // Use fork mode for ESM compatibility
|
|
16
16
|
autorestart: true,
|
|
17
17
|
watch: false,
|
|
18
|
-
|
|
18
|
+
// 进程 baseline ~184MB 贴近 200M 线导致频繁 OOM kill,内存增长另排查
|
|
19
|
+
max_memory_restart: '600M',
|
|
19
20
|
env: {
|
|
20
21
|
NODE_ENV: 'production',
|
|
21
22
|
CONFIG_PATH: configPath,
|