@cc-monitoring/proxy-core 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/__tests__/commands.test.js +1 -1
- package/dist/cli/commands/exec.js +31 -42
- package/dist/docs/404.html +2 -2
- package/dist/docs/assets/{app.B9A39uFv.js → app.DtYNT5zS.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.C4sjikMO.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.DdhC696L.js → VPLocalSearchBox.DpXF9ZAI.js} +1 -1
- package/dist/docs/assets/chunks/{theme.CfB2tOFi.js → theme.TS_gUyc7.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__/providers-route.test.js +1 -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 +0 -1
- package/dist/server/data-push.js +0 -7
- package/dist/server/proxy.js +128 -224
- package/dist/server/ui-route.js +76 -59
- 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-CCx-FOtz.js} +1 -1
- package/dist/ui/assets/{abnf-Cu8RHCHK.js → abnf-Bwbi42Z8.js} +1 -1
- package/dist/ui/assets/{abnfDiagram-VRR7QNED-BUBToPXF.js → abnfDiagram-VRR7QNED-Dm1-8q0E.js} +1 -1
- package/dist/ui/assets/{accesslog-BG-34XOy.js → accesslog-DCytz_-m.js} +1 -1
- package/dist/ui/assets/{actionscript-iw0HHMGM.js → actionscript-3udf15oh.js} +1 -1
- package/dist/ui/assets/{ada-qRqj6VGQ.js → ada-M5Xa74xG.js} +1 -1
- package/dist/ui/assets/{angelscript-BeaXyx_P.js → angelscript-qlrFxfW-.js} +1 -1
- package/dist/ui/assets/{apache-CU8d-z9X.js → apache-B-sF-DQH.js} +1 -1
- package/dist/ui/assets/{applescript-d1Wxkqz1.js → applescript-4FdcBnbI.js} +1 -1
- package/dist/ui/assets/{arc-BMsPIm3j.js → arc-BB3K1enp.js} +1 -1
- package/dist/ui/assets/{arcade-CtbgrWTM.js → arcade-B_yqWaaG.js} +1 -1
- package/dist/ui/assets/{architectureDiagram-ZJ3FMSHR-CVjC5TrS.js → architectureDiagram-ZJ3FMSHR-B39vkY8V.js} +1 -1
- package/dist/ui/assets/{arduino-Bc9L39Hr.js → arduino-yAcBoTWU.js} +1 -1
- package/dist/ui/assets/{armasm-DuWmpjWR.js → armasm-wIcY84bI.js} +1 -1
- package/dist/ui/assets/{asciidoc-CDIhFTnx.js → asciidoc-Bxnu28-Z.js} +1 -1
- package/dist/ui/assets/{aspectj-SYj-57Es.js → aspectj-B2cKJA_O.js} +1 -1
- package/dist/ui/assets/{autohotkey-hBi5dq37.js → autohotkey-B_rMWTtE.js} +1 -1
- package/dist/ui/assets/{autoit-BSawXzhg.js → autoit-DwcuvMwv.js} +1 -1
- package/dist/ui/assets/{avrasm-CwYom8Np.js → avrasm-heGX1PXK.js} +1 -1
- package/dist/ui/assets/{awk-BvBRfGo2.js → awk-BiqCQAEf.js} +1 -1
- package/dist/ui/assets/{axapta-CqUavA8k.js → axapta-Cv8M-Ih6.js} +1 -1
- package/dist/ui/assets/{bash-BS_ZnmEu.js → bash-Divgn3JV.js} +1 -1
- package/dist/ui/assets/{basic-xbP4IXrN.js → basic-B9dnAP55.js} +1 -1
- package/dist/ui/assets/{blockDiagram-677ZJIJ3-CmpI3f5p.js → blockDiagram-677ZJIJ3-DQ1mf7A_.js} +1 -1
- package/dist/ui/assets/{bnf-BECwu6uW.js → bnf-kIL5mSsP.js} +1 -1
- package/dist/ui/assets/{brainfuck-QQgu4j4N.js → brainfuck-DqB7xDjH.js} +1 -1
- package/dist/ui/assets/{coq-IDMIFfem.js → c-HmsCM6sx.js} +1 -1
- package/dist/ui/assets/{c-like-DYrFOtXy.js → c-like-De5MhE7G.js} +1 -1
- package/dist/ui/assets/{c4Diagram-LMCZKHZV-B6Hgngz9.js → c4Diagram-LMCZKHZV-DQxtYsAx.js} +1 -1
- package/dist/ui/assets/{cal-CNMrJ6v5.js → cal-mYdfz9en.js} +1 -1
- package/dist/ui/assets/{capnproto-DYCKl6oY.js → capnproto-D04CRlOt.js} +1 -1
- package/dist/ui/assets/{ceylon-mb8tRPl0.js → ceylon-pi9lFCja.js} +1 -1
- package/dist/ui/assets/channel-ChTtxQDg.js +1 -0
- package/dist/ui/assets/{chunk-2Q5K7J3B-LxvQ-G67.js → chunk-2Q5K7J3B-BDD1nPt8.js} +1 -1
- package/dist/ui/assets/{chunk-32BRIVSS-DxzKK6Aw.js → chunk-32BRIVSS-DgeQFBb5.js} +1 -1
- package/dist/ui/assets/{chunk-5VM5RSS4-CZEoYJ2W.js → chunk-5VM5RSS4-C7Xf2SnI.js} +1 -1
- package/dist/ui/assets/{chunk-EX3LRPZG-DS2PytrN.js → chunk-EX3LRPZG-B_3p1HEv.js} +1 -1
- package/dist/ui/assets/{chunk-JWPE2WC7-UX0Sr1Ie.js → chunk-JWPE2WC7-Dvs7u8eY.js} +1 -1
- package/dist/ui/assets/{chunk-MOJQB5TN-YbJgT9t4.js → chunk-MOJQB5TN-By21wDCN.js} +1 -1
- package/dist/ui/assets/{chunk-RYQCIY6F-DS2VH_U9.js → chunk-RYQCIY6F-6NC700r1.js} +1 -1
- package/dist/ui/assets/{chunk-V7JOEXUC-CZr0pkI1.js → chunk-V7JOEXUC-vEUqZ3rh.js} +1 -1
- package/dist/ui/assets/{chunk-VR4S4FIN-50opPAD3.js → chunk-VR4S4FIN-6tX2dNN9.js} +1 -1
- package/dist/ui/assets/{chunk-XXDRQBXY-DAAX9l7U.js → chunk-XXDRQBXY-qDb2jxAR.js} +1 -1
- package/dist/ui/assets/classDiagram-OUVF2IWQ-Ccbvamlu.js +1 -0
- package/dist/ui/assets/classDiagram-v2-EOCWNBFH-Ccbvamlu.js +1 -0
- package/dist/ui/assets/{clean-C4X7dSkh.js → clean-CLCsDUl1.js} +1 -1
- package/dist/ui/assets/{clojure-DSg9gUa7.js → clojure-dVi5Xifj.js} +1 -1
- package/dist/ui/assets/{clojure-repl-CagRYx7h.js → clojure-repl-BO_FpFmF.js} +1 -1
- package/dist/ui/assets/{cmake-CFdBn53c.js → cmake-CP5aJbyK.js} +1 -1
- package/dist/ui/assets/{coffeescript-CJZtMOPx.js → coffeescript-ZEfu_9pF.js} +1 -1
- package/dist/ui/assets/{c-BRJEPYra.js → coq-6aKUn3zn.js} +1 -1
- package/dist/ui/assets/{cos-Bx2VJuzG.js → cos-BohCnRN2.js} +1 -1
- package/dist/ui/assets/{cose-bilkent-JH36ORCC-zWRLsZpZ.js → cose-bilkent-JH36ORCC-DyXCbbro.js} +1 -1
- package/dist/ui/assets/{cpp-CsG6DlC4.js → cpp-FOgPWPEt.js} +1 -1
- package/dist/ui/assets/{crmsh-DTy9MnmJ.js → crmsh-B0OYb-Oe.js} +1 -1
- package/dist/ui/assets/{crystal-BwgrLrZ1.js → crystal-CuWb_dXm.js} +1 -1
- package/dist/ui/assets/{csharp-B2VeTPAF.js → csharp-BbcqM09j.js} +1 -1
- package/dist/ui/assets/{csp-CTpydNhH.js → csp-rgHnTaDq.js} +1 -1
- package/dist/ui/assets/{css-B0mMUbpY.js → css-C-ibh7ZG.js} +1 -1
- package/dist/ui/assets/{cynefin-VYW2F7L2-BmjQEj6q.js → cynefin-VYW2F7L2-CkuBhgC4.js} +1 -1
- package/dist/ui/assets/{cynefinDiagram-TSTJHNR4-Dr0Zrke0.js → cynefinDiagram-TSTJHNR4-eycFyDao.js} +1 -1
- package/dist/ui/assets/{d-DjuDZnbI.js → d-C0gXxJ0O.js} +1 -1
- package/dist/ui/assets/{dagre-VKFMJZFB-xoTPT2Uu.js → dagre-VKFMJZFB-DzqX9e49.js} +1 -1
- package/dist/ui/assets/{dart-xR3GU9TJ.js → dart-C-fTpuUV.js} +1 -1
- package/dist/ui/assets/{delphi-bJas5QnG.js → delphi-Chm0B9xv.js} +1 -1
- package/dist/ui/assets/{diagram-FQU43EPY-rL_IU7gU.js → diagram-FQU43EPY-BEgCqfg1.js} +1 -1
- package/dist/ui/assets/{diagram-G47NLZAW-EcDiCVGj.js → diagram-G47NLZAW-Cw11Vs2v.js} +1 -1
- package/dist/ui/assets/{diagram-NH7WQ7WH-CGGXOjev.js → diagram-NH7WQ7WH-DSG_UWpP.js} +1 -1
- package/dist/ui/assets/{diagram-OA4YK3LP-DnE7hDjD.js → diagram-OA4YK3LP-CJz-WOaJ.js} +1 -1
- package/dist/ui/assets/{diagram-WEI45ONY-CTJH5eD8.js → diagram-WEI45ONY-CBXjBCvc.js} +1 -1
- package/dist/ui/assets/{diff-doJFF3fv.js → diff-C-vyuMSL.js} +1 -1
- package/dist/ui/assets/{django-D3b-owa_.js → django-CJK7lReT.js} +1 -1
- package/dist/ui/assets/{dns-C42KYV-Z.js → dns-D02SHjSy.js} +1 -1
- package/dist/ui/assets/{dockerfile-9KUINc2j.js → dockerfile-trKL1Bqu.js} +1 -1
- package/dist/ui/assets/{dos-CxnlJ6qp.js → dos-C52dy-sK.js} +1 -1
- package/dist/ui/assets/{dsconfig-6CMMCwmY.js → dsconfig-MzHgzVrt.js} +1 -1
- package/dist/ui/assets/{dts-D78rdUIB.js → dts-B137dHyX.js} +1 -1
- package/dist/ui/assets/{dust-Dv1uTfJU.js → dust-BcbM0r5C.js} +1 -1
- package/dist/ui/assets/{ebnf-BGbG1cFK.js → ebnf-DkbpI7bK.js} +1 -1
- package/dist/ui/assets/{ebnfDiagram-CCIWWBDH-z2VgRSUV.js → ebnfDiagram-CCIWWBDH-aI5uQ7w1.js} +1 -1
- package/dist/ui/assets/{elixir-ZgAQVY1J.js → elixir-BOtDuqQy.js} +1 -1
- package/dist/ui/assets/{elm-CudiFuNu.js → elm-DS8Tyyu-.js} +1 -1
- package/dist/ui/assets/{erDiagram-Q63AITRT-X1TODuRv.js → erDiagram-Q63AITRT-2vCbd4Mm.js} +1 -1
- package/dist/ui/assets/{erb-Bz_NZh6W.js → erb-CSXECRbn.js} +1 -1
- package/dist/ui/assets/{erlang-DNuj1nb2.js → erlang-BMxlgKPJ.js} +1 -1
- package/dist/ui/assets/{erlang-repl-SP1Gan9W.js → erlang-repl-DPzlolPg.js} +1 -1
- package/dist/ui/assets/{excel-0K77uECF.js → excel-CW2Uxed3.js} +1 -1
- package/dist/ui/assets/{fix-CalJq7JD.js → fix-UW84SlCs.js} +1 -1
- package/dist/ui/assets/{flix-BlIs11_w.js → flix-4UGiPULd.js} +1 -1
- package/dist/ui/assets/{flowDiagram-23GEKE2U-DA2dnmc0.js → flowDiagram-23GEKE2U-R5PbCbZI.js} +1 -1
- package/dist/ui/assets/{fortran-ZCobXY2R.js → fortran-nhHsngdu.js} +1 -1
- package/dist/ui/assets/{fsharp-Be8rwUtc.js → fsharp-CDyZ1ST5.js} +1 -1
- package/dist/ui/assets/{gams-DUat8frQ.js → gams-DHzkkUie.js} +1 -1
- package/dist/ui/assets/{ganttDiagram-NO4QXBWP-DdFwaIGZ.js → ganttDiagram-NO4QXBWP-CGcq4Ie_.js} +1 -1
- package/dist/ui/assets/{gauss-BB4U88dy.js → gauss-DdhFGyBv.js} +1 -1
- package/dist/ui/assets/{gcode-DzeUZuZg.js → gcode-ImHh8OLA.js} +1 -1
- package/dist/ui/assets/{gherkin-B_8vW_BO.js → gherkin-CTWAW-XR.js} +1 -1
- package/dist/ui/assets/{gitGraphDiagram-IHSO6WYX-B-Dn8x6I.js → gitGraphDiagram-IHSO6WYX-8nM2Z9lD.js} +1 -1
- package/dist/ui/assets/{glsl-DGHGjPC1.js → glsl-0_W_27G2.js} +1 -1
- package/dist/ui/assets/{gml-BYEku8Yh.js → gml-BoDggu2z.js} +1 -1
- package/dist/ui/assets/{go-D8aSgQMc.js → go-DYfFygwl.js} +1 -1
- package/dist/ui/assets/{golo-CDjCU_jh.js → golo-Mlq-TCg9.js} +1 -1
- package/dist/ui/assets/{gradle-BeUw7tl_.js → gradle-BALAinEB.js} +1 -1
- package/dist/ui/assets/{groovy-5iCQOtR3.js → groovy-Dht--dWU.js} +1 -1
- package/dist/ui/assets/{haml-BEdL8FJi.js → haml-DpMrxg0d.js} +1 -1
- package/dist/ui/assets/{handlebars-BuYQNzoK.js → handlebars-DqHzujNj.js} +1 -1
- package/dist/ui/assets/{haskell-I4FCBcW0.js → haskell-DZSchhkY.js} +1 -1
- package/dist/ui/assets/{haxe-yigyKfFr.js → haxe-C0zBRjdy.js} +1 -1
- package/dist/ui/assets/{hsp-ZUk4j7d1.js → hsp-D_PwbSv2.js} +1 -1
- package/dist/ui/assets/{htmlbars-QYP3lT3u.js → htmlbars-DxAFMG8u.js} +1 -1
- package/dist/ui/assets/{http-BJpD1O71.js → http-DvTRF0Do.js} +1 -1
- package/dist/ui/assets/{hy-CIJ1bP6S.js → hy-lVO-kNyp.js} +1 -1
- package/dist/ui/assets/{index-BDXWttnT.js → index-BbMRVVGt.js} +3 -3
- package/dist/ui/assets/{index-COAgrx1J.js → index-Ci23SMK2.js} +242 -242
- package/dist/ui/assets/index-DlsVXaHT.css +10 -0
- package/dist/ui/assets/{infoDiagram-FWYZ7A6U-fTg9eLNt.js → infoDiagram-FWYZ7A6U-C7WYDlvc.js} +1 -1
- package/dist/ui/assets/{inform7-DAsu-lC2.js → inform7-B8Tf2n8v.js} +1 -1
- package/dist/ui/assets/{ini-Bhz-zHCg.js → ini-DSoYMaLF.js} +1 -1
- package/dist/ui/assets/{irpf90-BunhbwBl.js → irpf90-RCPdkB14.js} +1 -1
- package/dist/ui/assets/{isbl-q9L6hOhP.js → isbl-C2p75PPj.js} +1 -1
- package/dist/ui/assets/{ishikawaDiagram-FXEZZL3T-B8G0sdgd.js → ishikawaDiagram-FXEZZL3T-Cm6jsPlc.js} +1 -1
- package/dist/ui/assets/{java-Iks5Pkau.js → java-DeY4Yuia.js} +1 -1
- package/dist/ui/assets/{javascript-C4vltXPw.js → javascript-3uX1CO-H.js} +1 -1
- package/dist/ui/assets/{jboss-cli-BQBvd2X2.js → jboss-cli-DgnD8mEc.js} +1 -1
- package/dist/ui/assets/{journeyDiagram-5HDEW3XC-Crbzgrum.js → journeyDiagram-5HDEW3XC-DEGV1uA5.js} +1 -1
- package/dist/ui/assets/{json-DXK0_jUK.js → json-BV2PmJJp.js} +1 -1
- package/dist/ui/assets/{julia-CCYoBiYK.js → julia-B-m8kQm7.js} +1 -1
- package/dist/ui/assets/{julia-repl-y8v2Oorl.js → julia-repl-C51atU2X.js} +1 -1
- package/dist/ui/assets/{kanban-definition-HUTT4EX6-C8sCOsBX.js → kanban-definition-HUTT4EX6-BJ4k5iTX.js} +1 -1
- package/dist/ui/assets/{kotlin-Bnjk7_fw.js → kotlin-CYBziIgl.js} +1 -1
- package/dist/ui/assets/{lasso-B-al6x63.js → lasso-Dw2SBMDW.js} +1 -1
- package/dist/ui/assets/{latex-BUmqlb9r.js → latex-Dpd35yke.js} +1 -1
- package/dist/ui/assets/{ldif-D42RWj6Q.js → ldif-Ce9EZU__.js} +1 -1
- package/dist/ui/assets/{leaf-CrH4BZ0m.js → leaf-CpkZzQtC.js} +1 -1
- package/dist/ui/assets/{less-upmRlQQW.js → less-Uzo7M0FD.js} +1 -1
- package/dist/ui/assets/{lisp-DHYS22SA.js → lisp-DWXDlJYm.js} +1 -1
- package/dist/ui/assets/{livecodeserver-CeQNmFP3.js → livecodeserver-uEyPEgVJ.js} +1 -1
- package/dist/ui/assets/{livescript-PJWpY1JI.js → livescript-BQ5f07oK.js} +1 -1
- package/dist/ui/assets/{llvm-BKtKWwCt.js → llvm-BAvP-skE.js} +1 -1
- package/dist/ui/assets/{lsl-RWRLRjk7.js → lsl-DhbiIKu6.js} +1 -1
- package/dist/ui/assets/{lua-BFUDiPGm.js → lua-COxeUeLx.js} +1 -1
- package/dist/ui/assets/{makefile-CUDyOz5D.js → makefile-DhDx-IgL.js} +1 -1
- package/dist/ui/assets/{markdown-zZCLypc6.js → markdown-DX5_kSxq.js} +1 -1
- package/dist/ui/assets/{mathematica-BHbxKxnq.js → mathematica-D351ZddB.js} +1 -1
- package/dist/ui/assets/{matlab-DlGtg--p.js → matlab-CELqIiwF.js} +1 -1
- package/dist/ui/assets/{maxima-BBBeS3Ra.js → maxima-B_YljrMm.js} +1 -1
- package/dist/ui/assets/{mel-nh8j7W_6.js → mel-DltsbNS8.js} +1 -1
- package/dist/ui/assets/{mercury-DyyD-pqr.js → mercury-axX-5Vjj.js} +1 -1
- package/dist/ui/assets/{mindmap-definition-LN4V7U3C-CJlhDHqM.js → mindmap-definition-LN4V7U3C-Bl1EJo6p.js} +1 -1
- package/dist/ui/assets/{mipsasm-hiEhRRiq.js → mipsasm-BxmerVwX.js} +1 -1
- package/dist/ui/assets/{mizar-BZa3iAAL.js → mizar-XNHfbpL2.js} +1 -1
- package/dist/ui/assets/{mojolicious-BCIm2V_y.js → mojolicious-BR0U_7zk.js} +1 -1
- package/dist/ui/assets/{monkey-zmK-7N8b.js → monkey-lLuu9_f-.js} +1 -1
- package/dist/ui/assets/{moonscript-BsS_Mn3D.js → moonscript-DoaZ3DRQ.js} +1 -1
- package/dist/ui/assets/{n1ql-D7xVgDP0.js → n1ql-C6TId6Iu.js} +1 -1
- package/dist/ui/assets/{nginx-ct2q4dtd.js → nginx-BezSG-JT.js} +1 -1
- package/dist/ui/assets/{nim-RO0UOmW3.js → nim-Bb0rfXie.js} +1 -1
- package/dist/ui/assets/{nix-BcRJxPKH.js → nix-o3sJ5-54.js} +1 -1
- package/dist/ui/assets/{node-repl-DgIefwxW.js → node-repl-Sv5hhcTf.js} +1 -1
- package/dist/ui/assets/{nsis-DqHs9QhB.js → nsis-B45BJFhF.js} +1 -1
- package/dist/ui/assets/{objectivec-BBcWqc7Y.js → objectivec-CzS6zVgh.js} +1 -1
- package/dist/ui/assets/{ocaml-BExfw7D6.js → ocaml-Bqux7PyP.js} +1 -1
- package/dist/ui/assets/{openscad-CHPRELQb.js → openscad-4Wf6mF84.js} +1 -1
- package/dist/ui/assets/{oxygene-DpS9uMJW.js → oxygene-Fvwqgkkt.js} +1 -1
- package/dist/ui/assets/{parser3-CjJ_QdBp.js → parser3-zEfzT5wv.js} +1 -1
- package/dist/ui/assets/{pegDiagram-2B236MQR-GM70woGy.js → pegDiagram-2B236MQR-Dd4rIztM.js} +1 -1
- package/dist/ui/assets/{perl-BSNM2Kt8.js → perl-CsS1Gs6o.js} +1 -1
- package/dist/ui/assets/{pf-Z-hKf_88.js → pf-BNH1jO0R.js} +1 -1
- package/dist/ui/assets/{pgsql-DDgznxBg.js → pgsql-DqPigHrq.js} +1 -1
- package/dist/ui/assets/{php-BzAhxF-l.js → php-CdOl9bRs.js} +1 -1
- package/dist/ui/assets/{php-template-DkgcKHRc.js → php-template-DPfirJg2.js} +1 -1
- package/dist/ui/assets/{pieDiagram-ENE6RG2P-Bst7mPyz.js → pieDiagram-ENE6RG2P-DGaJNf4S.js} +1 -1
- package/dist/ui/assets/{plaintext-BYEppD0R.js → plaintext-EHbgBKzw.js} +1 -1
- package/dist/ui/assets/{pony-BT_kQd1K.js → pony-DmJajtp2.js} +1 -1
- package/dist/ui/assets/{powershell-BfRsuSsf.js → powershell-DfGzdWR6.js} +1 -1
- package/dist/ui/assets/{processing-DpzWe5Iu.js → processing-BT0ETgPG.js} +1 -1
- package/dist/ui/assets/{profile-BCOhS5cM.js → profile-B3I-x5Lt.js} +1 -1
- package/dist/ui/assets/{prolog-OxaCCaW8.js → prolog-B_4QJIvI.js} +1 -1
- package/dist/ui/assets/{properties-DMFlA2Ca.js → properties-BFVI8weS.js} +1 -1
- package/dist/ui/assets/{protobuf-CRDFkXvZ.js → protobuf-PaF39oZZ.js} +1 -1
- package/dist/ui/assets/{puppet-DnrVyLzx.js → puppet-BDC6Q8VF.js} +1 -1
- package/dist/ui/assets/{purebasic-Dht4Hniv.js → purebasic-B2ejrOZK.js} +1 -1
- package/dist/ui/assets/{python-B0aMirWu.js → python-BOxtIk9H.js} +1 -1
- package/dist/ui/assets/{python-repl-BlYDBGa7.js → python-repl-BslBh_Mx.js} +1 -1
- package/dist/ui/assets/{q-DzrtW9kT.js → q-BPe8WLGW.js} +1 -1
- package/dist/ui/assets/{qml-DnfQsR3i.js → qml-BazRR6fz.js} +1 -1
- package/dist/ui/assets/{quadrantDiagram-ABIIQ3AL-DNRYurBT.js → quadrantDiagram-ABIIQ3AL-BQ7aPkHk.js} +1 -1
- package/dist/ui/assets/{r-DGI_ZuTD.js → r-C09pGNJC.js} +1 -1
- package/dist/ui/assets/{railroadDiagram-RFXS5EU6-CmbC3Vz4.js → railroadDiagram-RFXS5EU6-sCO9VGvE.js} +1 -1
- package/dist/ui/assets/{reasonml-3SohMgh2.js → reasonml-S7dzwVL9.js} +1 -1
- package/dist/ui/assets/{requirementDiagram-TGXJPOKE-8CxrXHco.js → requirementDiagram-TGXJPOKE-CfT5aVZg.js} +1 -1
- package/dist/ui/assets/{rib-DfRSd4Qa.js → rib-fM2EwQd4.js} +1 -1
- package/dist/ui/assets/{roboconf-CQczGdGW.js → roboconf-D7AaeyrW.js} +1 -1
- package/dist/ui/assets/{routeros-DCka-T2i.js → routeros-c6Q7mKuq.js} +1 -1
- package/dist/ui/assets/{rsl-Dr8MOwMo.js → rsl-sCpEQBxh.js} +1 -1
- package/dist/ui/assets/{ruby-C2zFSkh_.js → ruby-lcKhz2w9.js} +1 -1
- package/dist/ui/assets/{ruleslanguage-C97YsgQq.js → ruleslanguage-BW4ATOuX.js} +1 -1
- package/dist/ui/assets/{rust-H3h8kd9A.js → rust-BbpU-0VY.js} +1 -1
- package/dist/ui/assets/{sankeyDiagram-HTMAVEWB-DBXLWjEq.js → sankeyDiagram-HTMAVEWB-CaweCpvN.js} +1 -1
- package/dist/ui/assets/{sas-04z0Xu8P.js → sas-BPt5R0dx.js} +1 -1
- package/dist/ui/assets/{scala-DyB9Aoiv.js → scala-DxW_vqXs.js} +1 -1
- package/dist/ui/assets/{scheme-DBj6nxUi.js → scheme-T2Q_jWzT.js} +1 -1
- package/dist/ui/assets/{scilab-Btj7AD9s.js → scilab-DMORg9lV.js} +1 -1
- package/dist/ui/assets/{scss-BXZJyXt7.js → scss-t0VsosqT.js} +1 -1
- package/dist/ui/assets/{sequenceDiagram-DBY2YBRQ-DXIkBFKC.js → sequenceDiagram-DBY2YBRQ-o-H_R4zb.js} +1 -1
- package/dist/ui/assets/{shell-BsreQR1Z.js → shell-CnCDa1s9.js} +1 -1
- package/dist/ui/assets/{sizeCapture-X5ZJPWSS-ocS9jxAQ.js → sizeCapture-X5ZJPWSS-BNLkHGDS.js} +1 -1
- package/dist/ui/assets/{smali-D9wQw9zm.js → smali-_n-BxJyG.js} +1 -1
- package/dist/ui/assets/{smalltalk-Dku6G_H3.js → smalltalk-B90PXJwK.js} +1 -1
- package/dist/ui/assets/{sml-BknyU6ya.js → sml-fuY7bj-n.js} +1 -1
- package/dist/ui/assets/{sqf-DRYMaOg8.js → sqf-COpwkyuo.js} +1 -1
- package/dist/ui/assets/{sql-Cw3Ax4KA.js → sql-CXIT0j-x.js} +1 -1
- package/dist/ui/assets/{sql_more-vWdslLE0.js → sql_more-C1Oxq4rx.js} +1 -1
- package/dist/ui/assets/{stan-8XH5bDS6.js → stan-BZEpaHeC.js} +1 -1
- package/dist/ui/assets/{stata-4e77wgfe.js → stata-CkBwaiZM.js} +1 -1
- package/dist/ui/assets/{stateDiagram-2N3HPSRC-RMmL9jMG.js → stateDiagram-2N3HPSRC-BkdnNF7I.js} +1 -1
- package/dist/ui/assets/stateDiagram-v2-6OUMAXLB-0JnZ1VSQ.js +1 -0
- package/dist/ui/assets/{step21-ByIeDMY3.js → step21-fs9N_U3O.js} +1 -1
- package/dist/ui/assets/{stylus-ZAhJyWsw.js → stylus-Bs_9cvKZ.js} +1 -1
- package/dist/ui/assets/{subunit-pPW2UGkj.js → subunit-DvgcOCqJ.js} +1 -1
- package/dist/ui/assets/{swift-CX3BB5az.js → swift-BE4ONsur.js} +1 -1
- package/dist/ui/assets/{swimlanes-5IMT3BWC-C2zAuJ56.js → swimlanes-5IMT3BWC-uqTAc7o7.js} +2 -2
- package/dist/ui/assets/swimlanesDiagram-G3AALYLV-DQRIIEmi.js +8 -0
- package/dist/ui/assets/{taggerscript-BHcjbWIC.js → taggerscript-BhmPJ64C.js} +1 -1
- package/dist/ui/assets/{tap-BOl1lBlS.js → tap-DkueIVKV.js} +1 -1
- package/dist/ui/assets/{tcl-DZjeOBDh.js → tcl-DyXOOkFi.js} +1 -1
- package/dist/ui/assets/{thrift-BxboWg4x.js → thrift-Dhgbk56T.js} +1 -1
- package/dist/ui/assets/{timeline-definition-FHXFAJF6-BOxsxyq_.js → timeline-definition-FHXFAJF6-DBAk9Ouc.js} +1 -1
- package/dist/ui/assets/{tp-BNM6ql3J.js → tp-BsXyrRGH.js} +1 -1
- package/dist/ui/assets/{twig-Dj9ZiXD4.js → twig-J0HqIuHw.js} +1 -1
- package/dist/ui/assets/{typescript-7MEJlu_6.js → typescript-Dkwvul39.js} +1 -1
- package/dist/ui/assets/{vala-DNqOAgHJ.js → vala-CRGnf8aY.js} +1 -1
- package/dist/ui/assets/{vbnet-T0mNKVc_.js → vbnet-BtJAUe3z.js} +1 -1
- package/dist/ui/assets/{vbscript-CeuwVMAI.js → vbscript-RgFFNuM3.js} +1 -1
- package/dist/ui/assets/{vbscript-html-BbJSt2w6.js → vbscript-html-DO32Io9Y.js} +1 -1
- package/dist/ui/assets/{vennDiagram-L72KCM5P-BX9mWeiT.js → vennDiagram-L72KCM5P-BJi6y0hh.js} +1 -1
- package/dist/ui/assets/{verilog-DYuhYfkX.js → verilog-C4h6MLcI.js} +1 -1
- package/dist/ui/assets/{vhdl-Cf9aT-t7.js → vhdl-DOafePyU.js} +1 -1
- package/dist/ui/assets/{vim-DciP44K1.js → vim-BAdTA9TY.js} +1 -1
- package/dist/ui/assets/{wardleyDiagram-EHGQE667-CDj2rOzu.js → wardleyDiagram-EHGQE667-C7c_4IJ6.js} +1 -1
- package/dist/ui/assets/{x86asm-E-AN_LXO.js → x86asm-BCL6__QH.js} +1 -1
- package/dist/ui/assets/{xl-CxYLJelN.js → xl-qIzE4HOe.js} +1 -1
- package/dist/ui/assets/{xml-yz1SRLuU.js → xml-DE2sJXYU.js} +1 -1
- package/dist/ui/assets/{xquery-BLzBF3tV.js → xquery-CQ35t92y.js} +1 -1
- package/dist/ui/assets/{xychartDiagram-FW5EYKEG-Czapk9-Z.js → xychartDiagram-FW5EYKEG-D2ILn0jL.js} +1 -1
- package/dist/ui/assets/{yaml-Cv4Y7iN_.js → yaml-5KaAvG5C.js} +1 -1
- package/dist/ui/assets/{zephir-KRcdQfEX.js → zephir-CbR3Ryfq.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/utils/__tests__/abort-signals.test.js +67 -0
- 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.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 +271 -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__/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.d.ts +1 -0
- package/dist/utils/db.js +24 -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 +59 -30
- package/dist/utils/request-writer.js +178 -58
- 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.js +3 -0
- package/dist/utils/tool-injector.js +7 -0
- package/dist/utils/vault.d.ts +111 -0
- package/dist/utils/vault.js +434 -0
- package/package.json +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.B6Qfxe6W.js +0 -1
- 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/{types/api.js → utils/__tests__/abort-signals.test.d.ts} +0 -0
- /package/dist/{types/log.js → utils/__tests__/learn-tasks-db.test.d.ts} +0 -0
- /package/dist/utils/__tests__/{knowledge-store.test.d.ts → openai-converter.test.d.ts} +0 -0
- /package/dist/utils/__tests__/{sse-accumulator.test.d.ts → pi-events.test.d.ts} +0 -0
|
@@ -19,6 +19,7 @@ export function aggregateStats() {
|
|
|
19
19
|
COUNT(*) as request_count
|
|
20
20
|
FROM requests
|
|
21
21
|
WHERE timestamp >= ?
|
|
22
|
+
AND closed_at IS NULL
|
|
22
23
|
GROUP BY hour
|
|
23
24
|
`).all(hourlyCutoff);
|
|
24
25
|
// Upsert hourly stats
|
|
@@ -90,12 +91,14 @@ export function getTodayStats(since) {
|
|
|
90
91
|
COUNT(*) as request_count
|
|
91
92
|
FROM requests
|
|
92
93
|
WHERE timestamp >= ?
|
|
94
|
+
AND closed_at IS NULL
|
|
93
95
|
`).get(since);
|
|
94
96
|
// Per-model usage count since local midnight
|
|
95
97
|
const modelRows = db.prepare(`
|
|
96
98
|
SELECT model, COUNT(*) as count
|
|
97
99
|
FROM requests
|
|
98
100
|
WHERE timestamp >= ?
|
|
101
|
+
AND closed_at IS NULL
|
|
99
102
|
AND model IS NOT NULL AND model != ''
|
|
100
103
|
GROUP BY model
|
|
101
104
|
ORDER BY count DESC
|
|
@@ -10,6 +10,13 @@ import { mcpManager } from './mcp-manager.js';
|
|
|
10
10
|
* 无 tools 数组时自动创建,让裸请求也能使用 MCP tool。
|
|
11
11
|
*/
|
|
12
12
|
export function injectMcpTools(body) {
|
|
13
|
+
// 守卫:malformed body 直接返回,避免给原始值赋值抛 TypeError。
|
|
14
|
+
// 判定依据:有效 chat body 至少要有 messages 数组;null/非对象,或既无 tools 也无 messages(如 {}、{tools:'nope'})均不注入。
|
|
15
|
+
if (body === null ||
|
|
16
|
+
typeof body !== 'object' ||
|
|
17
|
+
(!Array.isArray(body?.tools) && !Array.isArray(body?.messages))) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
13
20
|
if (!Array.isArray(body?.tools)) {
|
|
14
21
|
body.tools = [];
|
|
15
22
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export declare function isValidSlug(slug: string): boolean;
|
|
2
|
+
export interface TopicSummary {
|
|
3
|
+
slug: string;
|
|
4
|
+
title: string;
|
|
5
|
+
summary: string;
|
|
6
|
+
tags: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface ChunkRef {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
summary: string;
|
|
12
|
+
tags: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface TopicIndex {
|
|
15
|
+
slug: string;
|
|
16
|
+
title: string;
|
|
17
|
+
summary: string;
|
|
18
|
+
tags: string[];
|
|
19
|
+
chunks: ChunkRef[];
|
|
20
|
+
}
|
|
21
|
+
interface TopicDetail {
|
|
22
|
+
title: string;
|
|
23
|
+
tags: string[];
|
|
24
|
+
sources: unknown[];
|
|
25
|
+
chunks: ChunkRef[];
|
|
26
|
+
}
|
|
27
|
+
interface ChunkHit {
|
|
28
|
+
topic: string;
|
|
29
|
+
chunkId: string;
|
|
30
|
+
title: string;
|
|
31
|
+
}
|
|
32
|
+
interface QueryHit {
|
|
33
|
+
topic: string;
|
|
34
|
+
chunkId: string;
|
|
35
|
+
title: string;
|
|
36
|
+
body: string;
|
|
37
|
+
}
|
|
38
|
+
export interface OutlineItem {
|
|
39
|
+
id: string;
|
|
40
|
+
title: string;
|
|
41
|
+
oneLine: string;
|
|
42
|
+
}
|
|
43
|
+
interface RootIndex {
|
|
44
|
+
topics: TopicSummary[];
|
|
45
|
+
}
|
|
46
|
+
export interface Vault {
|
|
47
|
+
/** vault 根目录(docsDir)绝对路径 */
|
|
48
|
+
readonly root: string;
|
|
49
|
+
listTopics(): Promise<TopicSummary[]>;
|
|
50
|
+
getTopic(topic: string): Promise<TopicDetail>;
|
|
51
|
+
searchChunks(query: string): Promise<ChunkHit[]>;
|
|
52
|
+
queryKnowledge(query: string, limit?: number): Promise<QueryHit[]>;
|
|
53
|
+
readChunk(topic: string, chunkId: string): Promise<string>;
|
|
54
|
+
upsertTopic(input: {
|
|
55
|
+
slug: string;
|
|
56
|
+
title: string;
|
|
57
|
+
summary: string;
|
|
58
|
+
tags: string[];
|
|
59
|
+
}): Promise<void>;
|
|
60
|
+
upsertChunkRef(input: {
|
|
61
|
+
topic: string;
|
|
62
|
+
chunkId: string;
|
|
63
|
+
title: string;
|
|
64
|
+
summary: string;
|
|
65
|
+
tags: string[];
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
readTopicIndex(slug: string): Promise<TopicIndex | null>;
|
|
68
|
+
readSidecarIndex(slug: string): Promise<TopicIndex | null>;
|
|
69
|
+
assertSlug(slug: string, field?: string): void;
|
|
70
|
+
/** 重建 topic 目录:rm -rf 后建 sources/ + chunks/ */
|
|
71
|
+
prepareTopic(slug: string): void;
|
|
72
|
+
/** 写 <slug>/sources/source-NNN.md(content 带 Source 头) */
|
|
73
|
+
writeSourceFile(slug: string, index: number, url: string, text: string): void;
|
|
74
|
+
/** 数 <slug>/sources 下 .md 文件;目录不存在按 0 */
|
|
75
|
+
countSourceFiles(slug: string): number;
|
|
76
|
+
/** 读 <slug>/sources 下全部 .md 正文(按文件名排序);目录缺失抛底层错误 */
|
|
77
|
+
readSourceBodies(slug: string): string[];
|
|
78
|
+
/** 写 <slug>/outline.json(校验目录已 prepare、sources 存在) */
|
|
79
|
+
writeOutline(slug: string, items: OutlineItem[]): void;
|
|
80
|
+
/** 读 <slug>/outline.json 的 items;文件不存在抛「outline 未生成」 */
|
|
81
|
+
readOutlineItems(slug: string): OutlineItem[];
|
|
82
|
+
/** 旁挂:<slug> → <slug>.old */
|
|
83
|
+
parkTopic(slug: string): void;
|
|
84
|
+
/** 还原:<slug>.old → <slug> */
|
|
85
|
+
restoreTopic(slug: string): void;
|
|
86
|
+
/** 重命名 topic 目录:<slug> → <newSlug> */
|
|
87
|
+
renameTopic(slug: string, newSlug: string): void;
|
|
88
|
+
/** 读 <entry>/index.json(entry 可为 slug 或 <slug>.old);缺失/坏抛底层错误 */
|
|
89
|
+
readEntryIndexSync(entry: string): TopicIndex;
|
|
90
|
+
/** 写 <entry>/index.json */
|
|
91
|
+
writeEntryIndexSync(entry: string, idx: TopicIndex): void;
|
|
92
|
+
readRootIndexSync(): RootIndex;
|
|
93
|
+
writeRootIndexSync(root: RootIndex): void;
|
|
94
|
+
/** 列 <entry>/<subdir> 下 .md 文件名(排序);目录缺失视为空 */
|
|
95
|
+
listEntryMd(entry: string, subdir: 'sources' | 'chunks'): string[];
|
|
96
|
+
mkdirEntrySubdir(entry: string, subdir: 'sources' | 'chunks'): void;
|
|
97
|
+
readEntryFile(entry: string, subdir: 'sources' | 'chunks', file: string): Buffer;
|
|
98
|
+
writeEntryFile(entry: string, subdir: 'sources' | 'chunks', file: string, body: Buffer): void;
|
|
99
|
+
unlinkEntryFile(entry: string, subdir: 'sources' | 'chunks', file: string): void;
|
|
100
|
+
/** 删除整个 <entry> 目录 */
|
|
101
|
+
removeEntry(entry: string): void;
|
|
102
|
+
/** docsDir 下存在任何 .old 旁挂目录时抛错 */
|
|
103
|
+
assertNoOldSidecars(): void;
|
|
104
|
+
/** 归一化路径并断言其在 docsDir 内,越界抛错 */
|
|
105
|
+
assertInside(absPath: string): string;
|
|
106
|
+
/** 目标为受管 index.json 时抛错 */
|
|
107
|
+
assertNotManagedIndexJson(absPath: string): void;
|
|
108
|
+
}
|
|
109
|
+
export declare function createVault(docsDir: string): Vault;
|
|
110
|
+
export declare const vault: Vault;
|
|
111
|
+
export {};
|
|
@@ -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'));
|