dsh-m3e-mcp 0.0.0-stage → 0.5.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/AGENTS.md +236 -0
- package/README.md +90 -2
- package/client.js +212 -0
- package/cordis.patch.yml +44 -0
- package/dsh.plugin.json +27 -0
- package/host/http-util.js +122 -0
- package/host/index.js +745 -0
- package/host/mcp-client.js +250 -0
- package/host/studio-serve.mjs +53 -0
- package/icon.svg +18 -0
- package/package.json +70 -5
- package/studio/app.js +2320 -0
- package/studio/demos.js +221 -0
- package/studio/index.html +281 -0
- package/studio/manifest.json +779 -0
- package/studio/shapes.json +37 -0
- package/studio/styles.css +527 -0
- package/studio/tokens.json +1 -0
- package/studio/vendor/@lit/reactive-element/css-tag.js +7 -0
- package/studio/vendor/@lit/reactive-element/decorators/base.js +7 -0
- package/studio/vendor/@lit/reactive-element/decorators/custom-element.js +7 -0
- package/studio/vendor/@lit/reactive-element/decorators/event-options.js +7 -0
- package/studio/vendor/@lit/reactive-element/decorators/property.js +7 -0
- package/studio/vendor/@lit/reactive-element/decorators/query-all.js +8 -0
- package/studio/vendor/@lit/reactive-element/decorators/query-assigned-elements.js +7 -0
- package/studio/vendor/@lit/reactive-element/decorators/query-assigned-nodes.js +7 -0
- package/studio/vendor/@lit/reactive-element/decorators/query-async.js +8 -0
- package/studio/vendor/@lit/reactive-element/decorators/query.js +7 -0
- package/studio/vendor/@lit/reactive-element/decorators/state.js +7 -0
- package/studio/vendor/@lit/reactive-element/decorators.js +2 -0
- package/studio/vendor/@lit/reactive-element/development/css-tag.js +133 -0
- package/studio/vendor/@lit/reactive-element/development/decorators/base.js +32 -0
- package/studio/vendor/@lit/reactive-element/development/decorators/custom-element.js +30 -0
- package/studio/vendor/@lit/reactive-element/development/decorators/event-options.js +45 -0
- package/studio/vendor/@lit/reactive-element/development/decorators/property.js +147 -0
- package/studio/vendor/@lit/reactive-element/development/decorators/query-all.js +44 -0
- package/studio/vendor/@lit/reactive-element/development/decorators/query-assigned-elements.js +51 -0
- package/studio/vendor/@lit/reactive-element/development/decorators/query-assigned-nodes.js +46 -0
- package/studio/vendor/@lit/reactive-element/development/decorators/query-async.js +54 -0
- package/studio/vendor/@lit/reactive-element/development/decorators/query.js +120 -0
- package/studio/vendor/@lit/reactive-element/development/decorators/state.js +33 -0
- package/studio/vendor/@lit/reactive-element/development/decorators.js +18 -0
- package/studio/vendor/@lit/reactive-element/development/polyfill-support.js +99 -0
- package/studio/vendor/@lit/reactive-element/development/reactive-controller.js +7 -0
- package/studio/vendor/@lit/reactive-element/development/reactive-element.js +1122 -0
- package/studio/vendor/@lit/reactive-element/node/css-tag.js +7 -0
- package/studio/vendor/@lit/reactive-element/node/decorators/base.js +7 -0
- package/studio/vendor/@lit/reactive-element/node/decorators/custom-element.js +7 -0
- package/studio/vendor/@lit/reactive-element/node/decorators/event-options.js +7 -0
- package/studio/vendor/@lit/reactive-element/node/decorators/property.js +7 -0
- package/studio/vendor/@lit/reactive-element/node/decorators/query-all.js +8 -0
- package/studio/vendor/@lit/reactive-element/node/decorators/query-assigned-elements.js +7 -0
- package/studio/vendor/@lit/reactive-element/node/decorators/query-assigned-nodes.js +7 -0
- package/studio/vendor/@lit/reactive-element/node/decorators/query-async.js +8 -0
- package/studio/vendor/@lit/reactive-element/node/decorators/query.js +7 -0
- package/studio/vendor/@lit/reactive-element/node/decorators/state.js +7 -0
- package/studio/vendor/@lit/reactive-element/node/decorators.js +2 -0
- package/studio/vendor/@lit/reactive-element/node/development/css-tag.js +134 -0
- package/studio/vendor/@lit/reactive-element/node/development/decorators/base.js +34 -0
- package/studio/vendor/@lit/reactive-element/node/development/decorators/custom-element.js +32 -0
- package/studio/vendor/@lit/reactive-element/node/development/decorators/event-options.js +47 -0
- package/studio/vendor/@lit/reactive-element/node/development/decorators/property.js +149 -0
- package/studio/vendor/@lit/reactive-element/node/development/decorators/query-all.js +47 -0
- package/studio/vendor/@lit/reactive-element/node/development/decorators/query-assigned-elements.js +54 -0
- package/studio/vendor/@lit/reactive-element/node/development/decorators/query-assigned-nodes.js +49 -0
- package/studio/vendor/@lit/reactive-element/node/development/decorators/query-async.js +57 -0
- package/studio/vendor/@lit/reactive-element/node/development/decorators/query.js +121 -0
- package/studio/vendor/@lit/reactive-element/node/development/decorators/state.js +36 -0
- package/studio/vendor/@lit/reactive-element/node/development/decorators.js +10 -0
- package/studio/vendor/@lit/reactive-element/node/development/reactive-controller.js +2 -0
- package/studio/vendor/@lit/reactive-element/node/development/reactive-element.js +1106 -0
- package/studio/vendor/@lit/reactive-element/node/reactive-controller.js +2 -0
- package/studio/vendor/@lit/reactive-element/node/reactive-element.js +2 -0
- package/studio/vendor/@lit/reactive-element/polyfill-support.js +7 -0
- package/studio/vendor/@lit/reactive-element/reactive-controller.js +2 -0
- package/studio/vendor/@lit/reactive-element/reactive-element.js +7 -0
- package/studio/vendor/@m3e/icons/dist/outlined/add.js +2 -0
- package/studio/vendor/@m3e/icons/dist/outlined/animation.js +2 -0
- package/studio/vendor/@m3e/icons/dist/outlined/category.js +2 -0
- package/studio/vendor/@m3e/icons/dist/outlined/check.js +2 -0
- package/studio/vendor/@m3e/icons/dist/outlined/code.js +2 -0
- package/studio/vendor/@m3e/icons/dist/outlined/contrast.js +2 -0
- package/studio/vendor/@m3e/icons/dist/outlined/palette.js +2 -0
- package/studio/vendor/@m3e/icons/dist/outlined/settings.js +2 -0
- package/studio/vendor/@m3e/icons/dist/outlined/text_fields.js +2 -0
- package/studio/vendor/@m3e/icons/dist/outlined/widgets.js +2 -0
- package/studio/vendor/@m3e/web/dist/all.js +62259 -0
- package/studio/vendor/@m3e/web/dist/app-bar.js +822 -0
- package/studio/vendor/@m3e/web/dist/autocomplete.js +1163 -0
- package/studio/vendor/@m3e/web/dist/avatar.js +58 -0
- package/studio/vendor/@m3e/web/dist/badge.js +277 -0
- package/studio/vendor/@m3e/web/dist/bottom-sheet.js +1011 -0
- package/studio/vendor/@m3e/web/dist/breadcrumb.js +439 -0
- package/studio/vendor/@m3e/web/dist/button-group.js +370 -0
- package/studio/vendor/@m3e/web/dist/button.js +1583 -0
- package/studio/vendor/@m3e/web/dist/calendar.js +1228 -0
- package/studio/vendor/@m3e/web/dist/callout.js +267 -0
- package/studio/vendor/@m3e/web/dist/card.js +531 -0
- package/studio/vendor/@m3e/web/dist/carousel.js +2430 -0
- package/studio/vendor/@m3e/web/dist/checkbox.js +230 -0
- package/studio/vendor/@m3e/web/dist/chips.js +1402 -0
- package/studio/vendor/@m3e/web/dist/content-pane.js +76 -0
- package/studio/vendor/@m3e/web/dist/core-a11y.js +1328 -0
- package/studio/vendor/@m3e/web/dist/core-anchoring.js +2182 -0
- package/studio/vendor/@m3e/web/dist/core-bidi.js +109 -0
- package/studio/vendor/@m3e/web/dist/core-layout.js +64 -0
- package/studio/vendor/@m3e/web/dist/core-platform.js +46 -0
- package/studio/vendor/@m3e/web/dist/core.js +5813 -0
- package/studio/vendor/@m3e/web/dist/date-input.js +1321 -0
- package/studio/vendor/@m3e/web/dist/datepicker.js +883 -0
- package/studio/vendor/@m3e/web/dist/dialog.js +420 -0
- package/studio/vendor/@m3e/web/dist/divider.js +131 -0
- package/studio/vendor/@m3e/web/dist/drawer-container.js +569 -0
- package/studio/vendor/@m3e/web/dist/expansion-panel.js +605 -0
- package/studio/vendor/@m3e/web/dist/fab-menu.js +868 -0
- package/studio/vendor/@m3e/web/dist/fab.js +1181 -0
- package/studio/vendor/@m3e/web/dist/form-field.js +738 -0
- package/studio/vendor/@m3e/web/dist/gestures-long-press.js +325 -0
- package/studio/vendor/@m3e/web/dist/gestures-pan.js +394 -0
- package/studio/vendor/@m3e/web/dist/gestures-repeat.js +303 -0
- package/studio/vendor/@m3e/web/dist/gestures-rotate.js +218 -0
- package/studio/vendor/@m3e/web/dist/gestures-scale.js +203 -0
- package/studio/vendor/@m3e/web/dist/gestures-sequence.js +347 -0
- package/studio/vendor/@m3e/web/dist/gestures-swipe.js +392 -0
- package/studio/vendor/@m3e/web/dist/gestures-tap.js +309 -0
- package/studio/vendor/@m3e/web/dist/gestures.js +1188 -0
- package/studio/vendor/@m3e/web/dist/heading.js +259 -0
- package/studio/vendor/@m3e/web/dist/icon-button.js +1333 -0
- package/studio/vendor/@m3e/web/dist/icon.js +349 -0
- package/studio/vendor/@m3e/web/dist/list.js +1566 -0
- package/studio/vendor/@m3e/web/dist/loading-indicator.js +207 -0
- package/studio/vendor/@m3e/web/dist/menu.js +1293 -0
- package/studio/vendor/@m3e/web/dist/nav-bar.js +464 -0
- package/studio/vendor/@m3e/web/dist/nav-menu.js +841 -0
- package/studio/vendor/@m3e/web/dist/nav-rail.js +213 -0
- package/studio/vendor/@m3e/web/dist/option.js +419 -0
- package/studio/vendor/@m3e/web/dist/paginator.js +385 -0
- package/studio/vendor/@m3e/web/dist/progress-indicator.js +1217 -0
- package/studio/vendor/@m3e/web/dist/radio-group.js +437 -0
- package/studio/vendor/@m3e/web/dist/search.js +939 -0
- package/studio/vendor/@m3e/web/dist/segmented-button.js +445 -0
- package/studio/vendor/@m3e/web/dist/select.js +755 -0
- package/studio/vendor/@m3e/web/dist/shape.js +206 -0
- package/studio/vendor/@m3e/web/dist/skeleton.js +390 -0
- package/studio/vendor/@m3e/web/dist/slide-group.js +284 -0
- package/studio/vendor/@m3e/web/dist/slider.js +852 -0
- package/studio/vendor/@m3e/web/dist/snackbar.js +304 -0
- package/studio/vendor/@m3e/web/dist/split-button.js +340 -0
- package/studio/vendor/@m3e/web/dist/split-pane.js +760 -0
- package/studio/vendor/@m3e/web/dist/stepper.js +1056 -0
- package/studio/vendor/@m3e/web/dist/swipe-reveal.js +1435 -0
- package/studio/vendor/@m3e/web/dist/switch.js +397 -0
- package/studio/vendor/@m3e/web/dist/tabs.js +764 -0
- package/studio/vendor/@m3e/web/dist/textarea-autosize.js +325 -0
- package/studio/vendor/@m3e/web/dist/theme.js +7565 -0
- package/studio/vendor/@m3e/web/dist/timepicker.js +2043 -0
- package/studio/vendor/@m3e/web/dist/toc.js +480 -0
- package/studio/vendor/@m3e/web/dist/toolbar.js +574 -0
- package/studio/vendor/@m3e/web/dist/tooltip.js +903 -0
- package/studio/vendor/@m3e/web/dist/tree.js +868 -0
- package/studio/vendor/lit/async-directive.js +2 -0
- package/studio/vendor/lit/decorators/custom-element.js +2 -0
- package/studio/vendor/lit/decorators/event-options.js +2 -0
- package/studio/vendor/lit/decorators/property.js +2 -0
- package/studio/vendor/lit/decorators/query-all.js +2 -0
- package/studio/vendor/lit/decorators/query-assigned-elements.js +2 -0
- package/studio/vendor/lit/decorators/query-assigned-nodes.js +2 -0
- package/studio/vendor/lit/decorators/query-async.js +2 -0
- package/studio/vendor/lit/decorators/query.js +2 -0
- package/studio/vendor/lit/decorators/state.js +2 -0
- package/studio/vendor/lit/decorators.js +2 -0
- package/studio/vendor/lit/development/async-directive.js +7 -0
- package/studio/vendor/lit/development/decorators/custom-element.js +7 -0
- package/studio/vendor/lit/development/decorators/event-options.js +7 -0
- package/studio/vendor/lit/development/decorators/property.js +7 -0
- package/studio/vendor/lit/development/decorators/query-all.js +7 -0
- package/studio/vendor/lit/development/decorators/query-assigned-elements.js +7 -0
- package/studio/vendor/lit/development/decorators/query-assigned-nodes.js +7 -0
- package/studio/vendor/lit/development/decorators/query-async.js +7 -0
- package/studio/vendor/lit/development/decorators/query.js +7 -0
- package/studio/vendor/lit/development/decorators/state.js +7 -0
- package/studio/vendor/lit/development/decorators.js +15 -0
- package/studio/vendor/lit/development/directive-helpers.js +7 -0
- package/studio/vendor/lit/development/directive.js +7 -0
- package/studio/vendor/lit/development/directives/async-append.js +7 -0
- package/studio/vendor/lit/development/directives/async-replace.js +7 -0
- package/studio/vendor/lit/development/directives/cache.js +7 -0
- package/studio/vendor/lit/development/directives/choose.js +7 -0
- package/studio/vendor/lit/development/directives/class-map.js +7 -0
- package/studio/vendor/lit/development/directives/guard.js +7 -0
- package/studio/vendor/lit/development/directives/if-defined.js +7 -0
- package/studio/vendor/lit/development/directives/join.js +7 -0
- package/studio/vendor/lit/development/directives/keyed.js +7 -0
- package/studio/vendor/lit/development/directives/live.js +7 -0
- package/studio/vendor/lit/development/directives/map.js +7 -0
- package/studio/vendor/lit/development/directives/range.js +7 -0
- package/studio/vendor/lit/development/directives/ref.js +7 -0
- package/studio/vendor/lit/development/directives/repeat.js +7 -0
- package/studio/vendor/lit/development/directives/style-map.js +7 -0
- package/studio/vendor/lit/development/directives/template-content.js +7 -0
- package/studio/vendor/lit/development/directives/unsafe-html.js +7 -0
- package/studio/vendor/lit/development/directives/unsafe-mathml.js +7 -0
- package/studio/vendor/lit/development/directives/unsafe-svg.js +7 -0
- package/studio/vendor/lit/development/directives/until.js +7 -0
- package/studio/vendor/lit/development/directives/when.js +7 -0
- package/studio/vendor/lit/development/html.js +7 -0
- package/studio/vendor/lit/development/index.all.js +37 -0
- package/studio/vendor/lit/development/index.js +13 -0
- package/studio/vendor/lit/development/polyfill-support.js +7 -0
- package/studio/vendor/lit/development/static-html.js +7 -0
- package/studio/vendor/lit/directive-helpers.js +2 -0
- package/studio/vendor/lit/directive.js +2 -0
- package/studio/vendor/lit/directives/async-append.js +2 -0
- package/studio/vendor/lit/directives/async-replace.js +2 -0
- package/studio/vendor/lit/directives/cache.js +2 -0
- package/studio/vendor/lit/directives/choose.js +2 -0
- package/studio/vendor/lit/directives/class-map.js +2 -0
- package/studio/vendor/lit/directives/guard.js +2 -0
- package/studio/vendor/lit/directives/if-defined.js +2 -0
- package/studio/vendor/lit/directives/join.js +2 -0
- package/studio/vendor/lit/directives/keyed.js +2 -0
- package/studio/vendor/lit/directives/live.js +2 -0
- package/studio/vendor/lit/directives/map.js +2 -0
- package/studio/vendor/lit/directives/range.js +2 -0
- package/studio/vendor/lit/directives/ref.js +2 -0
- package/studio/vendor/lit/directives/repeat.js +2 -0
- package/studio/vendor/lit/directives/style-map.js +2 -0
- package/studio/vendor/lit/directives/template-content.js +2 -0
- package/studio/vendor/lit/directives/unsafe-html.js +2 -0
- package/studio/vendor/lit/directives/unsafe-mathml.js +2 -0
- package/studio/vendor/lit/directives/unsafe-svg.js +2 -0
- package/studio/vendor/lit/directives/until.js +2 -0
- package/studio/vendor/lit/directives/when.js +2 -0
- package/studio/vendor/lit/html.js +2 -0
- package/studio/vendor/lit/index.js +2 -0
- package/studio/vendor/lit/polyfill-support.js +7 -0
- package/studio/vendor/lit/static-html.js +2 -0
- package/studio/vendor/lit-element/decorators/custom-element.js +2 -0
- package/studio/vendor/lit-element/decorators/event-options.js +2 -0
- package/studio/vendor/lit-element/decorators/property.js +2 -0
- package/studio/vendor/lit-element/decorators/query-all.js +2 -0
- package/studio/vendor/lit-element/decorators/query-assigned-elements.js +2 -0
- package/studio/vendor/lit-element/decorators/query-assigned-nodes.js +2 -0
- package/studio/vendor/lit-element/decorators/query-async.js +2 -0
- package/studio/vendor/lit-element/decorators/query.js +2 -0
- package/studio/vendor/lit-element/decorators/state.js +2 -0
- package/studio/vendor/lit-element/decorators.js +2 -0
- package/studio/vendor/lit-element/development/decorators/custom-element.js +7 -0
- package/studio/vendor/lit-element/development/decorators/event-options.js +7 -0
- package/studio/vendor/lit-element/development/decorators/property.js +7 -0
- package/studio/vendor/lit-element/development/decorators/query-all.js +7 -0
- package/studio/vendor/lit-element/development/decorators/query-assigned-elements.js +7 -0
- package/studio/vendor/lit-element/development/decorators/query-assigned-nodes.js +7 -0
- package/studio/vendor/lit-element/development/decorators/query-async.js +7 -0
- package/studio/vendor/lit-element/development/decorators/query.js +7 -0
- package/studio/vendor/lit-element/development/decorators/state.js +7 -0
- package/studio/vendor/lit-element/development/decorators.js +15 -0
- package/studio/vendor/lit-element/development/index.js +9 -0
- package/studio/vendor/lit-element/development/lit-element.js +241 -0
- package/studio/vendor/lit-element/development/polyfill-support.js +63 -0
- package/studio/vendor/lit-element/development/private-ssr-support.js +23 -0
- package/studio/vendor/lit-element/index.js +2 -0
- package/studio/vendor/lit-element/lit-element.js +7 -0
- package/studio/vendor/lit-element/polyfill-support.js +7 -0
- package/studio/vendor/lit-element/private-ssr-support.js +7 -0
- package/studio/vendor/lit-html/async-directive.js +7 -0
- package/studio/vendor/lit-html/development/async-directive.js +243 -0
- package/studio/vendor/lit-html/development/directive-helpers.js +179 -0
- package/studio/vendor/lit-html/development/directive.js +48 -0
- package/studio/vendor/lit-html/development/directives/async-append.js +53 -0
- package/studio/vendor/lit-html/development/directives/async-replace.js +100 -0
- package/studio/vendor/lit-html/development/directives/cache.js +88 -0
- package/studio/vendor/lit-html/development/directives/choose.js +41 -0
- package/studio/vendor/lit-html/development/directives/class-map.js +86 -0
- package/studio/vendor/lit-html/development/directives/guard.js +80 -0
- package/studio/vendor/lit-html/development/directives/if-defined.js +14 -0
- package/studio/vendor/lit-html/development/directives/join.js +19 -0
- package/studio/vendor/lit-html/development/directives/keyed.js +39 -0
- package/studio/vendor/lit-html/development/directives/live.js +77 -0
- package/studio/vendor/lit-html/development/directives/map.js +30 -0
- package/studio/vendor/lit-html/development/directives/private-async-helpers.js +83 -0
- package/studio/vendor/lit-html/development/directives/range.js +13 -0
- package/studio/vendor/lit-html/development/directives/ref.js +127 -0
- package/studio/vendor/lit-html/development/directives/repeat.js +413 -0
- package/studio/vendor/lit-html/development/directives/style-map.js +105 -0
- package/studio/vendor/lit-html/development/directives/template-content.js +31 -0
- package/studio/vendor/lit-html/development/directives/unsafe-html.js +61 -0
- package/studio/vendor/lit-html/development/directives/unsafe-mathml.js +24 -0
- package/studio/vendor/lit-html/development/directives/unsafe-svg.js +24 -0
- package/studio/vendor/lit-html/development/directives/until.js +123 -0
- package/studio/vendor/lit-html/development/directives/when.js +9 -0
- package/studio/vendor/lit-html/development/is-server.js +22 -0
- package/studio/vendor/lit-html/development/lit-html.js +1514 -0
- package/studio/vendor/lit-html/development/polyfill-support.js +195 -0
- package/studio/vendor/lit-html/development/private-ssr-support.js +81 -0
- package/studio/vendor/lit-html/development/static.js +149 -0
- package/studio/vendor/lit-html/directive-helpers.js +7 -0
- package/studio/vendor/lit-html/directive.js +7 -0
- package/studio/vendor/lit-html/directives/async-append.js +7 -0
- package/studio/vendor/lit-html/directives/async-replace.js +7 -0
- package/studio/vendor/lit-html/directives/cache.js +7 -0
- package/studio/vendor/lit-html/directives/choose.js +7 -0
- package/studio/vendor/lit-html/directives/class-map.js +7 -0
- package/studio/vendor/lit-html/directives/guard.js +8 -0
- package/studio/vendor/lit-html/directives/if-defined.js +7 -0
- package/studio/vendor/lit-html/directives/join.js +7 -0
- package/studio/vendor/lit-html/directives/keyed.js +7 -0
- package/studio/vendor/lit-html/directives/live.js +7 -0
- package/studio/vendor/lit-html/directives/map.js +7 -0
- package/studio/vendor/lit-html/directives/private-async-helpers.js +7 -0
- package/studio/vendor/lit-html/directives/range.js +7 -0
- package/studio/vendor/lit-html/directives/ref.js +7 -0
- package/studio/vendor/lit-html/directives/repeat.js +8 -0
- package/studio/vendor/lit-html/directives/style-map.js +7 -0
- package/studio/vendor/lit-html/directives/template-content.js +7 -0
- package/studio/vendor/lit-html/directives/unsafe-html.js +7 -0
- package/studio/vendor/lit-html/directives/unsafe-mathml.js +7 -0
- package/studio/vendor/lit-html/directives/unsafe-svg.js +7 -0
- package/studio/vendor/lit-html/directives/until.js +7 -0
- package/studio/vendor/lit-html/directives/when.js +7 -0
- package/studio/vendor/lit-html/is-server.js +7 -0
- package/studio/vendor/lit-html/lit-html.js +7 -0
- package/studio/vendor/lit-html/node/async-directive.js +7 -0
- package/studio/vendor/lit-html/node/development/async-directive.js +245 -0
- package/studio/vendor/lit-html/node/development/directive-helpers.js +177 -0
- package/studio/vendor/lit-html/node/development/directive.js +50 -0
- package/studio/vendor/lit-html/node/development/directives/async-append.js +56 -0
- package/studio/vendor/lit-html/node/development/directives/async-replace.js +104 -0
- package/studio/vendor/lit-html/node/development/directives/cache.js +91 -0
- package/studio/vendor/lit-html/node/development/directives/choose.js +43 -0
- package/studio/vendor/lit-html/node/development/directives/class-map.js +89 -0
- package/studio/vendor/lit-html/node/development/directives/guard.js +83 -0
- package/studio/vendor/lit-html/node/development/directives/if-defined.js +17 -0
- package/studio/vendor/lit-html/node/development/directives/join.js +21 -0
- package/studio/vendor/lit-html/node/development/directives/keyed.js +42 -0
- package/studio/vendor/lit-html/node/development/directives/live.js +80 -0
- package/studio/vendor/lit-html/node/development/directives/map.js +32 -0
- package/studio/vendor/lit-html/node/development/directives/private-async-helpers.js +85 -0
- package/studio/vendor/lit-html/node/development/directives/range.js +15 -0
- package/studio/vendor/lit-html/node/development/directives/ref.js +131 -0
- package/studio/vendor/lit-html/node/development/directives/repeat.js +416 -0
- package/studio/vendor/lit-html/node/development/directives/style-map.js +108 -0
- package/studio/vendor/lit-html/node/development/directives/template-content.js +34 -0
- package/studio/vendor/lit-html/node/development/directives/unsafe-html.js +64 -0
- package/studio/vendor/lit-html/node/development/directives/unsafe-mathml.js +27 -0
- package/studio/vendor/lit-html/node/development/directives/unsafe-svg.js +27 -0
- package/studio/vendor/lit-html/node/development/directives/until.js +127 -0
- package/studio/vendor/lit-html/node/development/directives/when.js +11 -0
- package/studio/vendor/lit-html/node/development/is-server.js +24 -0
- package/studio/vendor/lit-html/node/development/lit-html.js +1491 -0
- package/studio/vendor/lit-html/node/development/polyfill-support.js +186 -0
- package/studio/vendor/lit-html/node/development/private-ssr-support.js +84 -0
- package/studio/vendor/lit-html/node/development/static.js +152 -0
- package/studio/vendor/lit-html/node/directive-helpers.js +7 -0
- package/studio/vendor/lit-html/node/directive.js +7 -0
- package/studio/vendor/lit-html/node/directives/async-append.js +7 -0
- package/studio/vendor/lit-html/node/directives/async-replace.js +7 -0
- package/studio/vendor/lit-html/node/directives/cache.js +7 -0
- package/studio/vendor/lit-html/node/directives/choose.js +7 -0
- package/studio/vendor/lit-html/node/directives/class-map.js +7 -0
- package/studio/vendor/lit-html/node/directives/guard.js +8 -0
- package/studio/vendor/lit-html/node/directives/if-defined.js +7 -0
- package/studio/vendor/lit-html/node/directives/join.js +7 -0
- package/studio/vendor/lit-html/node/directives/keyed.js +7 -0
- package/studio/vendor/lit-html/node/directives/live.js +7 -0
- package/studio/vendor/lit-html/node/directives/map.js +7 -0
- package/studio/vendor/lit-html/node/directives/private-async-helpers.js +7 -0
- package/studio/vendor/lit-html/node/directives/range.js +7 -0
- package/studio/vendor/lit-html/node/directives/ref.js +7 -0
- package/studio/vendor/lit-html/node/directives/repeat.js +8 -0
- package/studio/vendor/lit-html/node/directives/style-map.js +7 -0
- package/studio/vendor/lit-html/node/directives/template-content.js +7 -0
- package/studio/vendor/lit-html/node/directives/unsafe-html.js +7 -0
- package/studio/vendor/lit-html/node/directives/unsafe-mathml.js +7 -0
- package/studio/vendor/lit-html/node/directives/unsafe-svg.js +7 -0
- package/studio/vendor/lit-html/node/directives/until.js +7 -0
- package/studio/vendor/lit-html/node/directives/when.js +7 -0
- package/studio/vendor/lit-html/node/is-server.js +7 -0
- package/studio/vendor/lit-html/node/lit-html.js +7 -0
- package/studio/vendor/lit-html/node/polyfill-support.js +7 -0
- package/studio/vendor/lit-html/node/private-ssr-support.js +8 -0
- package/studio/vendor/lit-html/node/static.js +8 -0
- package/studio/vendor/lit-html/polyfill-support.js +7 -0
- package/studio/vendor/lit-html/private-ssr-support.js +8 -0
- package/studio/vendor/lit-html/static.js +8 -0
- package/studio/vendor/tslib/tslib.es6.mjs +410 -0
- package/tests/fixtures/fake-mcp.mjs +52 -0
- package/tests/fixtures/studio/dev/serve.mjs +21 -0
- package/tests/probe.mjs +285 -0
- package/tests/reconnect.mjs +59 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# AGENTS.md — 接手 dsh-m3e-mcp 的人(或模型)先读这个
|
|
2
|
+
|
|
3
|
+
## 这是什么
|
|
4
|
+
|
|
5
|
+
**一句话**:把官方 `@m3e/mcp` 服务器桥进 DeepSeek Harness,并给一个两档开关。
|
|
6
|
+
|
|
7
|
+
**为什么需要它**:DSH 不读工作区的 `.mcp.json`,也不随包提供通用的 MCP 客户端。
|
|
8
|
+
现在每个 `mcp__*` 工具都是某个插件自己 spawn 子进程换来的(`dsh-aoci`、`dsh-unslop` 都是这个模式)。
|
|
9
|
+
所以这个包做三件事,一件都不能少:
|
|
10
|
+
|
|
11
|
+
1. 用 `process.execPath` 起 `@m3e/mcp` 的 stdio 进程(不依赖 PATH、不依赖 npx)
|
|
12
|
+
2. 把它 `tools/list` 出来的工具注册成 `mcp__m3e__<tool>`
|
|
13
|
+
3. 给一个开关:关掉时**连进程都不留**,工具全部摘掉
|
|
14
|
+
|
|
15
|
+
第 3 条是它和"照抄一份 unslop"的区别:六个编目工具在不用的时候是纯噪声,`0 工具 + 0 进程` 才是真的省。
|
|
16
|
+
|
|
17
|
+
## 结构
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
host/index.js 桥本体:CLI 解析、surface 读写、工具注册/摘除、Studio 自启、/m3e/api/* 五条路由
|
|
21
|
+
host/mcp-client.js 通用 stdio MCP 客户端(从 dsh-unslop 复制,只改了导出名与 clientInfo)
|
|
22
|
+
host/http-util.js 令牌鉴权 + 环回/Host 校验(同上复制,未改)
|
|
23
|
+
host/studio-serve.mjs 包内 Studio 的只读静态服务器:同 argv 约定,但不实现 POST /bake
|
|
24
|
+
client.js 输入框左侧那颗开关(关闭 / 开启),走 /m3e/api/surface
|
|
25
|
+
icon.svg 插件图标:24×24 透明底,造型取自 <m3e-switch>(胶囊 track + 选中态 handle + 目录圆点),紫 #7c5cff 与 chip 同色
|
|
26
|
+
icon-preview.html 图标的预览页(16/20/24/32/48/64,明暗两套,外加和 chip 的并排对照);开发用,不打进包
|
|
27
|
+
cordis.patch.yml bundle patch,一行挂进 Harness;注释里列了十一个可调 knob(十个常用 + reconnectDelaysMs 只给测试用)
|
|
28
|
+
dsh.plugin.json 插件清单:contributes.tools 两个 + contributes.mcp ["m3e"]
|
|
29
|
+
tests/probe.mjs 不重启就能验的冒烟脚本(见下)
|
|
30
|
+
tests/fixtures/fake-mcp.mjs 按模式装死的假 MCP server,只给错误注入用(hang-init / hang-list / hang-call / crash)
|
|
31
|
+
tests/fixtures/studio/dev/serve.mjs 只回 200 的假 Studio,验"插件拉起/收起它"这个动作,不复制真站的渲染
|
|
32
|
+
tests/reconnect.mjs 自动重连的独立验证进程(子进程归属清晰,探针读它的 JSON 结论)
|
|
33
|
+
scripts/vendor-studio.mjs 发版前把 ../m3e-studio 拷成包内 studio/,清单只取它自己的 import map
|
|
34
|
+
studio/ 生成产物:384 个文件 / 8.5 MB 的静态站。不进 git,但**必须在 package.json 的 files 里**
|
|
35
|
+
.gitignore 挡 node_modules / dist / studio / *.log;studio/ 虽被忽略,仍随 npm 包发出去
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
状态文件:`<DSH_HOME>/plugins-data/m3e/bridge.json`(`{ surface: "on" | "off", updatedAt }`),令牌在 `http.token`。
|
|
39
|
+
|
|
40
|
+
`npm install` 之后会多出 `node_modules/`(109 个包、约 59 MB)和 `package-lock.json`:
|
|
41
|
+
`@m3e/mcp` 现在是本插件的普通 dependency,随插件走,不再要求用户先 `npm i -g`。
|
|
42
|
+
|
|
43
|
+
## 三条硬事实(踩过才知道)
|
|
44
|
+
|
|
45
|
+
1. **DSH 不吃 `.mcp.json`。** 往工作区根写 `{"mcpServers":{...}}` 不会生效——那是 VS Code / Codex 的约定。DSH 的 MCP 只能由插件自己持有客户端。判断依据:`settings.yaml` 和 profile 里都没有 MCP 配置位,`dsh-aoci` 源码注释也直说了 "the Harness does not ship `@deepseek-ai/dsh-mcp-client` for every profile"。
|
|
46
|
+
2. **`ctx.tools.register()` 返回 disposer。** 摘工具就是调它。开关切到 off 时先 `dispose()` 再 `client.stop()`,两个都要做,否则会剩一个空转的进程。
|
|
47
|
+
3. **`--dsw-alias-brand-primary` 不是紫的。** 它是 `neutral-bluish-50/1000`,深色主题下接近白;`--dsw-alias-state-warn-primary` 是琥珀 `rgb(245,158,11)`。所以开关的"开启"态用了自己的变量 `--dsh-m3e-on`,默认 `#7c5cff`(从用户给的截图里采样出来的紫色,不是随手挑的)。想换色就覆盖这一个变量。
|
|
48
|
+
|
|
49
|
+
## 开关的工作方式
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
client.js → POST /m3e/api/surface {surface:"off"|"on"}
|
|
53
|
+
→ host: writeSurface() 写 bridge.json
|
|
54
|
+
applySurface(): off → disposeMcpTools() + stopClient()
|
|
55
|
+
on → startClient()(首次)或 registerVisible()
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- 启动时:`startOnBoot !== false` 且 bridge 里是 `on` 才自动拉起;关着就一个进程都不起。
|
|
59
|
+
- 切换是**立即**的,不用重启 DSH;只有 `client.js`(前端那一半)改动才需要刷新窗口。
|
|
60
|
+
- 工具自身的 `execute` 会检查 `runtime.client`,关掉后调用会报一句明确的话,而不是挂死。
|
|
61
|
+
- 子进程意外死后 `autoReconnect`(默认 true)按 1s/4s/9s 退避重连,60 秒窗口内最多 3 次;第 4 次停手并把原因写进 `lastError`。手动 `off` 会清空这个计数。
|
|
62
|
+
- 三个入口都能切:chip 菜单、`m3e_surface` 工具、`/m3e on|off|status|selfcheck|update|studio` 命令。
|
|
63
|
+
- Studio **现在随包发**:`studio/` 是 `npm run vendor` 从 m3e-studio 生成的一份静态站(按它的 import map 裁剪,384 个文件 / 8.5 MB),装完插件就有,不用再配 `studioDir`。桥不代理它、不依赖它的源码,但**会把它拉起来**:插件加载时先探活 `studioUrl`(默认 `http://127.0.0.1:4317/`),没起就 spawn,卸载时收掉。目录三源,顺序是 `studioDir` 配置 → 包内 `studio/` → 插件旁边的 `m3e-studio`(开发态),**每个来源自带入口脚本**(包内走 `host/studio-serve.mjs`,其余走 `dev/serve.mjs`)。包内那份不实现 `/bake`。`studioAutostart: false` 退回"只探活、只跳转"。`/m3e/api/studio?start=1` 是"点了才起"的那条路,chip 的"打开 Studio"在不可达时会走它。
|
|
64
|
+
- `selfcheck` 会真的调一次 `list_components`(不是只列工具),结论带阶段与耗时;它**不会**替用户把开关打开——surface 关着就直接报 `surface is off`。
|
|
65
|
+
|
|
66
|
+
## 怎么开发
|
|
67
|
+
|
|
68
|
+
```powershell
|
|
69
|
+
cd E:\test\dsh-m3e-mcp
|
|
70
|
+
|
|
71
|
+
# 0) 依赖(首次、或 package.json 变了之后)
|
|
72
|
+
npm install
|
|
73
|
+
# @m3e/mcp 是 dependency。link: 安装法下 pnpm 只建软链、不装被链对象的依赖,
|
|
74
|
+
# 所以开发态这一步必须自己跑,否则 CLI 会回落到全局那份、probe 的路线判据直接红。
|
|
75
|
+
|
|
76
|
+
# 1) 不重启就验(假 ctx 跑 apply,真起进程、真调一次、再关再开)
|
|
77
|
+
node tests/probe.mjs
|
|
78
|
+
# 期望:8 个工具 → list_components 有输出 → running 6/6 → 关掉后 0 工具、再打开 6 个
|
|
79
|
+
# 另加:CLI 的 source 必须是 package;kill 子进程后 status 必须报 not running 且能重启;
|
|
80
|
+
# 并发两次开启只起一个进程、关闭后不留孤儿(这两条只在 win32 上跑进程计数);
|
|
81
|
+
# 三个版本比较用例、两条门槛(CLI >= 2.13.8 / node >= 22)、渲染带计数;
|
|
82
|
+
# 错误注入四组:握手超时 / tools-list 超时 / tools-call 超时 / 启动即崩;
|
|
83
|
+
# /m3e 命令四条、自动重连两条(后者在独立进程 tests/reconnect.mjs 里跑)
|
|
84
|
+
# 全绿是 36 项(含 /m3e studio 探活、Studio 自动启动三条:拉起 / 收起 / 关开关不起)。
|
|
85
|
+
|
|
86
|
+
# 2) 语法
|
|
87
|
+
node --check host/index.js ; node --check client.js
|
|
88
|
+
|
|
89
|
+
# 3) 重装(开发态用 link,不需要 npm i)
|
|
90
|
+
# profile: dependencies["dsh-m3e-mcp"] = "link:E:/test/dsh-m3e-mcp"
|
|
91
|
+
# dsh.profile.bundles 里加 "dsh-m3e-mcp"
|
|
92
|
+
# node_modules 下建 junction 指向本目录
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
打包给别处用:
|
|
96
|
+
|
|
97
|
+
```powershell
|
|
98
|
+
npm pack --pack-destination dist # 注意 files 白名单,别把 tests/ 漏了
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## 已知坑
|
|
102
|
+
|
|
103
|
+
- **CLI 找不到 ≠ 插件坏了。** 四条路,顺序即优先级:`config.cli` → 插件自带的 `@m3e/mcp`(`require.resolve('@m3e/mcp/package.json')` 定包目录,再读该包自己的 `bin` 找 `dist/cli.js`;`require.resolve` 失手时手动逐级往上走兜底)→ npm 全局目录(`%APPDATA%\npm`)→ `npm_config_prefix`。前两条命中时 `m3e_status` 报 `source: package`。四者都不中时它会明说,`startClient` 抛错但不会让插件崩。配了 `config.cli` 但文件不存在 → 直接报"这个路径不存在",不会悄悄回落到下一路。
|
|
104
|
+
- **`link:` 不装依赖,全局那份也不会自动消失。** profile 用 pnpm + `nodeLinker: hoisted`,插件写成 `link:E:/test/dsh-m3e-mcp`:pnpm 只建软链,不装被链对象的依赖;而且 profile 里提升出来的 `@m3e/mcp` 落在 `~/.dsh/profiles/*/node_modules`,不在插件的真路径上(Node 从 realpath 开始解析)。所以开发态必须自己 `npm install`。两份同时存在时跑的是插件自带那份——版本由本包的 `package-lock.json` 决定,全局那份只当兜底,`m3e_status` 会多一行 `also on disk(未使用)` 点名它。
|
|
105
|
+
- **两道门槛,不满足就不启动。** `MIN_CLI_VERSION = 2.13.8`(这个桥对着那版协议写的)和 `MIN_NODE_MAJOR = 22`(`@m3e/mcp` 的 engines,而子进程用的是 Host 自己的 `process.execPath`)。`startClient` 先判这两条再 spawn,`m3e_status` 会打出 `cliOutdated` / `nodeSupported` 和"比在用的新"的那份闲置副本。版本比较在 `compareVersions()`,解析不了的一律当相等——宁可漏一个告警,也不制造假告警。
|
|
106
|
+
- **`runtime.client` 非空 ≠ 进程活着。** 子进程退出后 client 对象还在,所以判活一律走 `clientAlive()`(`client.state.running`),不能用 `Boolean(runtime.client)`。`onDown` 会 `stopClient()` 把工具面归零。改回旧写法会重演"status 报 running、再点开启也不重启"——`tests/probe.mjs` 有两条用例守着。
|
|
107
|
+
- **`applySurface` 是串行的。** 并发两次 on 会各 spawn 一个子进程,先起的那个没人 stop,变成孤儿(宿主活着期间一直在跑)。`switching` 那个 Promise 保证后到的调用复用同一次切换。
|
|
108
|
+
- **自动重连只补"意外死",不补"用户想要它停"。** 触发条件三条:`autoReconnect` 开、`bridge.json` 仍是 on、60 秒窗口内崩溃次数 ≤ 3。手动 `off` 会清空计数并从"off"分支直接返回,不会把进程又拉起来。重连走的是同一个 `applySurface`,所以和手动切档不会各起一个。
|
|
109
|
+
- **Studio 永远是"先探活、再 spawn"。** 顺序反了就会在端口上叠出第二个进程(重启电脑后残留的那个还没死,新起的抢不到端口、退出,然后用户看到"起不来")。同理:只有 `probeStudio()` 明确不可达才 spawn,`startStudio()` 并发调用共享同一个 Promise。卸载时必须 `stopStudio()`,否则 DSH 关了它还占着 4317。
|
|
110
|
+
- **vendor 的清单只有 import map 一份。** `scripts/vendor-studio.mjs` 直接读 studio 自己的 import map 逐条拷——页面里少一条映射就是整页白屏,所以不要另外维护第二份文件清单。`@m3e/web/dist` 超过 2 MB 不整份搬(9.9 MB 的 .js 里只有 85 个模块被映射),因此**显式条目必须完整**:加一条 import 就得确认它在那张表里,否则打包版会在那个组件上白屏。
|
|
111
|
+
- **`/m3e` 不依赖 DSH 的内部包。** `CommandDefinitionId` 在运行时就是恒等函数(`brand.js` 里 `return id`),所以传字符串 `'dsh-m3e-mcp'` 即可;用 `ctx.inject(['commands'], …)` 注入而不是写进 `inject` 数组,这样没有该服务的 profile 也能加载插件。
|
|
112
|
+
- **`update` 是整个插件唯一会主动联网的动作。** 只在用户显式敲 `/m3e update` 或点 chip 里的"检查更新"时才请求 registry(先 npmmirror、失败再 npmjs,6s 超时),不做后台轮询、不改装任何东西;其余全部路径运行期零外网。
|
|
113
|
+
- **Windows 上建软链用 junction。** `New-Item -ItemType SymbolicLink` 需要开发者模式/管理员;`Junction` 不需要,且 `npm pack` / Node 解析都认。
|
|
114
|
+
- **`/m3e/api/*` 五条路由都要过 `guarded()`。** token 路由本身是 `{ token: false }`(否则先有鸡还是先有蛋),其余四条(surface / selfcheck / update / studio)必须带 Bearer;client 侧对 401 会重新 bootstrap 一次。
|
|
115
|
+
- **不要在 host 里硬编码那六个工具名。** 它们是 `tools/list` 的返回值;上游加一个工具,这里应该自动多一个。硬编码清单会让"官方更新了我们却没跟上"变成静默错误。
|
|
116
|
+
- **客户端渲染失败是静默的。** `Chip()` 包了 try/catch,异常会渲染成一行红字而不是消失——改了 `client.js` 之后如果那颗开关不见了,先看有没有红字。
|
|
117
|
+
|
|
118
|
+
## 路线图
|
|
119
|
+
|
|
120
|
+
1. ~~**把 `@m3e/mcp` 变成插件的普通 dependency**~~ —— **0.2.0 做了**:`dependencies: { "@m3e/mcp": "^2.13.8" }`;四条路按"自带优先"重排,全局那份降级为兜底;`m3e_status` 报 `cliSource` / `cliVersion` / 没被用上的那份;`tests/probe.mjs` 加了一条路线判据(不中就是 `source=global`,直接判失败)。
|
|
121
|
+
2. ~~**版本共存**~~ —— **0.2.1 做了**:`MIN_CLI_VERSION = 2.13.8` + `MIN_NODE_MAJOR = 22` 两道门槛,`compareVersions()` 自己写(不引依赖),`m3e_status` 报 `cliOutdated` / `nodeSupported`,并把"比在用的新"的闲置副本标出来。
|
|
122
|
+
3. ~~**错误注入测试**~~ —— **0.2.2 做了**:`tests/fixtures/fake-mcp.mjs` 按 `FAKE_MCP_MODE` 装死(hang-init / hang-list / hang-call / crash),probe 用独立假 ctx 起四个实例断言:超时后不进 running、`lastError` 指到具体阶段、`tools/list` 失败会回滚工具面、握手失败会收掉子进程、`tools/call` 超时不误杀 server、崩溃带退出码。为此 `initTimeoutMs` / `listTimeoutMs` 从常量变成可注入(默认 20s / 30s)。
|
|
123
|
+
4. ~~**工具校验收紧**~~ —— **0.2.1 做了**:`client.js` 的 POST 不再 `.catch(() => {})`;失败时 chip 变红、显示"失败"+原因、8 秒后退场,并重拉一次真实状态把档位弹回。
|
|
124
|
+
|
|
125
|
+
5. ~~**Studio 随包发**~~ —— **做了**:`scripts/vendor-studio.mjs` 按 import map 裁出 384 个文件 / 8.5 MB 的静态站;`host/studio-serve.mjs` 只读服务且不实现 `/bake`;目录解析变成 `studioDir` → 包内 → 兄弟目录,每个来源自带入口脚本。装完插件就有 Studio,不用再配路径。
|
|
126
|
+
|
|
127
|
+
## 不要做
|
|
128
|
+
|
|
129
|
+
- **不要在这层再包一层语义**(比如"帮我挑组件")。官方工具就是编目,桥就该只做搬运。
|
|
130
|
+
- **不要把开关做成三档以上**。用户明确要的是"要 / 不要",多一档就多一份解释成本。
|
|
131
|
+
- **不要在没有 `tests/probe.mjs` 通过的情况下说"改好了"**。它 20 秒跑完,能同时验证注册、调用、卸载三件事。
|
|
132
|
+
- **不要假设 `.mcp.json` 会生效**(见上面硬事实 1),这条已经浪费过一次时间。
|
|
133
|
+
|
|
134
|
+
<!-- aoci:begin -->
|
|
135
|
+
## AOCI Repository Cognition
|
|
136
|
+
|
|
137
|
+
AOCI maintains a stable, versioned, incrementally updatable repository-level cognition layer so models can reuse their understanding of this system across tasks.
|
|
138
|
+
|
|
139
|
+
`aoci.txt` is a structured cognition index for models. It assigns one independent Entry to every managed file, database table, or other managed object. Symbolic tags and F/R/A/S semantics describe the object's core responsibility, important relationships, external contracts, and non-obvious constraints or design decisions needed to understand or modify the system.
|
|
140
|
+
|
|
141
|
+
The Header, directory sections, and all Entries form the complete repository index. They can cover frontend, backend, configuration, database structures, and other managed content. When managed content changes, normally only the affected cognition Entries need maintenance; the complete index does not need to be regenerated.
|
|
142
|
+
|
|
143
|
+
AOCI provides a high-density view of system architecture, object responsibilities, important relationships, external contracts, and key constraints.
|
|
144
|
+
|
|
145
|
+
### How it works
|
|
146
|
+
|
|
147
|
+
AOCI uses a model-generated, model-read cognition loop.
|
|
148
|
+
|
|
149
|
+
Header, Entry, and Curation semantics follow only the current machine-issued Plan and live Guide. The Host model independently authors them from the current bound evidence.
|
|
150
|
+
|
|
151
|
+
Entry semantics must come from the model's understanding of actual evidence. Never derive, prefill, assemble, or rewrite index semantics solely from paths, filenames, extensions, an AST, symbol lists, dependency scans, regular expressions, fixed templates, or rule engines.
|
|
152
|
+
|
|
153
|
+
For a Fresh Bootstrap, follow only the current machine-issued Plan and live Guide. When they require authoring, the Host model authors Root, Meta, tags, and F/R/A/S, supplies its authoring-run declaration, and binds it to the Plan, Evidence, and complete Candidate. Never ask AOCI to set `origin=host_model`, manufacture a receipt, or turn a generated framework into semantics. Do not reconstruct the Onboarding progression here. Internal batches are not user decisions; stop only at an existing approval boundary or a real safety, drift, CAS, or Recovery condition.
|
|
154
|
+
|
|
155
|
+
### Minimal entry points
|
|
156
|
+
|
|
157
|
+
- `aoci_rules`: obtain the session-level runtime contract for the current AOCI version.
|
|
158
|
+
- `aoci_overview`: establish or restore complete cognition for this repository.
|
|
159
|
+
- `aoci_maintain`: after managed objects reach their final stable state, check whether cognition needs maintenance.
|
|
160
|
+
- `aoci_update_entry`: submit a complete semantic update batch bound to current evidence and source digests.
|
|
161
|
+
- `aoci_report`: when the current layout and tool state support it, record follow-up work if evidence is insufficient to generate semantics reliably; do not guess.
|
|
162
|
+
|
|
163
|
+
For other MCP tools, CLI commands, parameters, and specialized workflows, follow current tool descriptions, Guide, and `--help` output. This file does not duplicate the full manual.
|
|
164
|
+
|
|
165
|
+
This managed block defines only repository integration, cognition use, and task-closing principles. `aoci_rules` carries the current session contract. Live Guide output carries the execution order and stop conditions of the current Plan. Tool Schema, Spec, and Validator carry machine structures and criteria. Prompt, Description, README, and static documentation cannot override those machine facts.
|
|
166
|
+
|
|
167
|
+
### Establishing, generating, and restoring cognition
|
|
168
|
+
|
|
169
|
+
1. At the beginning of every new Agent Run, first determine:
|
|
170
|
+
|
|
171
|
+
- whether this repository already has a usable complete AOCI index; and
|
|
172
|
+
- whether current context already contains complete repository cognition that matches this repository root, current index version, and current AOCI service, and that the model can still use reliably.
|
|
173
|
+
|
|
174
|
+
2. When the repository has a usable complete index but the current Run lacks reliable complete cognition, call `aoci_rules` first and then `aoci_overview`.
|
|
175
|
+
|
|
176
|
+
Reuse complete cognition directly while it remains reliable. Local uncertainty does not by itself require mechanically rereading the system-wide view. Once reliable cognition is established, use it as the repository-level system context by default and read only the source, tests, configuration, and contracts the current task directly needs, widening that evidence only when a specific missing fact could change the answer or the verification; AOCI never replaces direct source evidence for the objects being changed or the behavior being verified.
|
|
177
|
+
|
|
178
|
+
A Run that resumes from a known Host context compaction, including a Host-injected compaction summary, must treat prior model cognition as unreliable. The compacted handoff must not retain or summarize the formal Whole-Index or any Overview Header, Entry, Chunk, Challenge, or Attestation body; it may retain only receipt identity, unfinished write or Recovery state needed for safe continuation, and an instruction to reload immediately. Whole-Index semantics or a receipt copied into that handoff cannot prove that the resumed model's current cognition is reliable. If the runtime contract is no longer reliably present, call `aoci_rules` first. Before continuing the business task, make an ordinary complete Whole-Index `aoci_overview` request (`check_only` absent or false) with `refresh_reasons=["context_compaction"]` and a fresh `refresh_event_id`; do not use `check_only` or a cognition probe. Follow every exact `next_cursor` through `completed=true`, confirm delivery, and submit one Attestation based only on the newly delivered body. After that fresh complete transport, a partial or failed Attestation consumes the generation and permits the existing source-bound continuation without another automatic Overview. If that request answers `delivery_mode=capacity_stop`, the Whole-Index does not fit this Host's context: do not retry or lower `chunk_tokens`; the stop consumes the generation, and the task continues source-bound without an unqualified complete-system claim.
|
|
179
|
+
|
|
180
|
+
AOCI can report checkpoint and cognition-status facts for `context_compaction`, the machine `semantic_threshold` under the project `cognition_refresh_threshold`, or a major `phase_transition`. Use `check_only=true` when only those compact facts are needed. They advise the Agent but do not decide whether the model needs the system-wide view.
|
|
181
|
+
|
|
182
|
+
When the Agent explicitly calls ordinary `aoci_overview` (`check_only` absent or false), AOCI must deliver the complete requested scope whenever a coherent CognitionSet can be formed. It must not suppress that body because a receipt already exists, a threshold was not reached, or no refresh reason is pending; the one exception is that capacity stop of a pending compaction refresh. Dirty or stale formal cognition is still delivered but is marked unreliable. Pending recovery or an incoherent snapshot fails closed without a mixed body.
|
|
183
|
+
|
|
184
|
+
When an ordinary Overview reports `continuation_required=true`, submit its exact `next_cursor` automatically until `completed=true`. Do not ask the user to continue, begin the business task, or state a partial system conclusion. Request each Chunk in its own tool call; never fetch several in one script or merge their output. Stop the cognition chain on a missing, duplicate, or reordered Chunk, cursor failure, Index change, or `chunk_tokens` change. Until Attestation completes, never use Memory, source, Spec, `aoci.txt`, historical sessions, scope, search, or Entry reads to repair or supplement Whole-Index cognition. A challenge ordinal is the 1-based position in the formal Entry sequence; Header content, comments, blank lines, Section/Overview/Chunk markers, receipts, and Metadata are excluded, and Chunk Receipt ordinals use that same sequence. The Attestation must echo the Challenge's exact current `index_sha256`, `entry_sequence_sha256`, and `entry_count`; a prior Index, Entry sequence, count, or Attestation is invalid. After the complete chain, submit the existing model cognition Attestation once. One same-response JSON Schema or field-format error may be corrected once without changing semantic answers; a result short of pass (fewer than 80 percent of the ordinals fully correct, or more than one object identity miss) records an uncertain receipt, with no semantic retry or information bypass. During initial cognition it also blocks Root/Meta, Migration, layout-wide, or other unbound system decisions. During a context-compaction refresh with complete transport, unchanged cognition identity, aligned governance, and no Recovery or third-party conflict, the attempt consumes that refresh generation even when Attestation is partial or failed; continue the existing task without another automatic Overview. `system_mastery_percent` self-assesses only the system framework—architecture, responsibilities, strong relationships, stable external contracts, and high-entropy safety and maintenance constraints—not complete implementation or runtime knowledge. Keep machine Index coverage separate, and normally give the user only the prescribed single success or failure sentence derived from actual coverage, Challenge, Chunk, token, and mastery results. If the Host truncates a Chunk, request the same cursor once more and check its `chunk_sha256`; the server returns the identical bytes. Only if it is truncated again, stop and ask the user to set `overview_delivery.chunk_tokens` to a smaller valid value and restart; do not change it automatically.
|
|
185
|
+
|
|
186
|
+
Interpret the additive cognition level independently from strict proof fields. `delivery_verified` means the Index was loaded and Host delivery was confirmed while complete cognition verification is still unfinished; describe that state as loaded and delivery-verified, never as no cognition or failure to understand the system. `cognition_verified` requires a passing Attestation (at least 80 percent of Challenge ordinals fully correct with at most one object identity miss), and `cognition_governed` additionally requires governance alignment. A generic complete-read failure sentence is reserved for an actual delivery fault.
|
|
187
|
+
|
|
188
|
+
When an Overview response contains the optional `cognition-state/v2` projection, use its dimensions independently. Its Level ends at `model_cognition_usable`; `strict_attestation_verified`, `governance_aligned`, and `current_system_cognition_reliable` are independent states and never participate in that Level. An ordinal, object identity, Tag, or core F mismatch can make strict Attestation fail while model cognition remains usable; do not report that mismatch alone as proof that the model did not understand the system. Only `current_system_cognition_reliable=true` permits an unqualified current complete-system cognition claim. When the projection is absent, keep using the legacy interpretation above.
|
|
189
|
+
|
|
190
|
+
An ordinary read-only audit, analysis, or check, a request not to modify code, or a request not to commit or push does not automatically mean strictly zero writes and does not alter the cognition-validity decision above. Codex Memory and historical Skills may only help recover experience, user preferences, and investigation directions. They cannot replace a current cognition receipt matching the repository root, index digest, AOCI service identity, and cognition scope. Project AGENTS and current AOCI identity take precedence over historical Memory for AOCI state.
|
|
191
|
+
|
|
192
|
+
Treat a task as strictly zero-write only when the user explicitly prohibits Ledger, metadata, `.aoci` runtime assets, and every filesystem write. If necessary cognition establishment conflicts with that boundary, report the conflict and ask the user to decide or recommend an isolated copy. Never silently substitute Memory for current repository cognition.
|
|
193
|
+
|
|
194
|
+
3. If the repository has no usable complete index, or has only a minimal skeleton, an incomplete Header, unfinished Entries, or undecided required Curation, obtain `aoci_rules` and enter the current AOCI Guide when a formal complete AOCI index is required. Let Guide choose the next phase from actual repository state and complete the required safety steps.
|
|
195
|
+
|
|
196
|
+
`aoci_maintain` does not replace the index-establishment workflow.
|
|
197
|
+
|
|
198
|
+
Do not reconstruct or hard-code the full-index generation state machine in this file.
|
|
199
|
+
|
|
200
|
+
4. During a long-running task, the model is responsible for preserving the current cognition receipt and using the refresh gate correctly:
|
|
201
|
+
|
|
202
|
+
- when the Host reports context compaction or the model knows the system-wide view was lost, follow the mandatory `context_compaction` reload rule above; AOCI cannot infer the Host event;
|
|
203
|
+
- when entering a genuinely major phase, declare `phase_transition`, not a function, test run, or small step;
|
|
204
|
+
- at a plausible stable checkpoint, use `check_only=true` to obtain the machine semantic count when that fact is useful;
|
|
205
|
+
- except for the mandatory known-compaction reload, decide whether the current task needs another explicit scoped or complete Overview; and
|
|
206
|
+
- keep the Dirty or Stale reliability state reported by AOCI until maintenance and alignment complete.
|
|
207
|
+
|
|
208
|
+
### Task closing and cognition maintenance
|
|
209
|
+
|
|
210
|
+
5. A purely read-only question, analysis, version check, or task that changes no AOCI-managed object does not require a maintenance-tool call. The AOCI version in use is `cognition_receipt.mcp_service_version` in any `aoci_overview` check_only or `aoci_maintain` response; the binary path is the `command` in the project's `.mcp.json`, and the CLI need not be on PATH.
|
|
211
|
+
|
|
212
|
+
6. When AOCI-managed objects change, call `aoci_maintain` once after they reach the task's final stable state. Do not maintain files individually after each intermediate edit.
|
|
213
|
+
|
|
214
|
+
7. If maintenance returns actual semantic candidates, the Host model must independently author the complete tag and F/R/A/S updates from each candidate's bound object and necessary evidence. Submit the complete candidate set for that current machine-issued batch in one `aoci_update_entry` call while preserving each path and the domain batch identity; `source_sha256` and `candidate_id` may be omitted, since the server takes them from the issued batch. `max_entries` limits one request and atomic transaction, not the logical plan, Whole-Index, or Managed Scope. When `remaining` is nonzero, call Maintain again after the successful Apply and continue from the new preimage; never shrink Index coverage or slice a returned batch to satisfy transport limits.
|
|
215
|
+
|
|
216
|
+
When evidence is insufficient and the current layout supports `aoci_report`, use it instead of guessing, applying a template, or generating unsupported cognition merely to eliminate follow-up work.
|
|
217
|
+
|
|
218
|
+
8. Obey structured tool states and safety boundaries:
|
|
219
|
+
|
|
220
|
+
- `repair_required`: repair only the explicitly identified candidates, then resubmit the complete current machine-issued batch;
|
|
221
|
+
- `stopped`: end that write attempt and inspect `failed_step`, error, formal-write evidence, and Recovery. In auto mode, a proven zero-write closure is followed by a fresh Plan; a complete Intent with provable postimage is resumed; a policy-selected Rollback with exact preimage is completed and replanned. Stop the user task only when proof is unavailable, third-party bytes conflict, approval or external action is required, or another real safety boundary applies;
|
|
222
|
+
- never ignore conflicts, approvals, human decisions, permissions, or safety signals; and
|
|
223
|
+
- after alignment, do not repeat maintenance or writes; `refresh_ready_for_overview` is a checkpoint fact, and the Agent decides whether to request an ordinary complete Overview for its next phase.
|
|
224
|
+
|
|
225
|
+
If any managed object changes after maintenance completes, the previous result is invalid. Complete closing again from the new final stable state.
|
|
226
|
+
|
|
227
|
+
9. When the user limits only business-file scope and does not explicitly forbid repository-managed assets, AOCI-managed assets may be updated during closing to preserve cognition consistency. Distinguish them from business files in audits and commits.
|
|
228
|
+
|
|
229
|
+
When the user explicitly forbids changes to `aoci.txt`, `.aoci`, metadata, or any additional file, obey that restriction, do not write, and report any remaining inconsistency accurately.
|
|
230
|
+
|
|
231
|
+
### Specialized workflows
|
|
232
|
+
|
|
233
|
+
Initialization, complete-index generation, Header generation, Entries generation, database-structure indexing, Curation, human review, and failure recovery must follow only the instructions, commands, and safety stops returned by the current AOCI Guide or tool at the corresponding stage.
|
|
234
|
+
|
|
235
|
+
Do not preload, guess, or reconstruct these specialized workflows. The relevant Guide, tool descriptions, model Prompt, and CLI help provide platform invocation, request format, batch limits, approval rules, index-format details, and recovery steps as needed.
|
|
236
|
+
<!-- aoci:end -->
|
package/README.md
CHANGED
|
@@ -1,3 +1,91 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-m3e-mcp — 官方 @m3e/mcp 的 DSH 桥
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
把官方编目服务器 [`@m3e/mcp`](https://github.com/matraic/m3e/tree/main/packages/mcp) 的六个工具桥进 DeepSeek Harness,并给一个两档开关:
|
|
4
|
+
|
|
5
|
+
| 档位 | 行为 |
|
|
6
|
+
|---|---|
|
|
7
|
+
| **开启** | spawn `node <@m3e/mcp>/dist/cli.js`,把它的工具注册成 `mcp__m3e__*` |
|
|
8
|
+
| **关闭** | 全部从注册表摘掉,子进程停掉 —— 0 工具、0 进程、0 上下文 |
|
|
9
|
+
|
|
10
|
+
六个工具:`list_components` / `get_component` / `search_components` / `get_usage_example` / `get_react_wrapper` / `list_css_properties`。
|
|
11
|
+
两个自己的:`m3e_status`(只读体检)、`m3e_surface`(开关,也可直接用工具切)。
|
|
12
|
+
|
|
13
|
+
## 装
|
|
14
|
+
|
|
15
|
+
`@m3e/mcp` 是这个插件自己的 dependency,**装插件就把它一起装下来,不用再 `npm i -g`**。
|
|
16
|
+
|
|
17
|
+
```powershell
|
|
18
|
+
# profile 里加两行:
|
|
19
|
+
# dependencies: "dsh-m3e-mcp": "link:<本目录>"
|
|
20
|
+
# dsh.profile.bundles: ["dsh-m3e-mcp"]
|
|
21
|
+
# 重启 DSH
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
用 `link:` 挂开发目录时,profile 那侧的包管理器不会替你装被链对象的依赖 —— 先在插件目录跑一次 `npm install`。
|
|
25
|
+
从 tarball / registry 安装的话 npm 会自己装好,这一步可以跳过。
|
|
26
|
+
|
|
27
|
+
> **国内网络**:`npm install` 这一步要从 npm 源拉 109 个包(约 59 MB),慢或不通时先把源换成国内镜像:
|
|
28
|
+
> `npm config set registry https://registry.npmmirror.com`(或单次 `npm i --registry=https://registry.npmmirror.com`)。
|
|
29
|
+
> 只有安装期需要网络:装完之后运行期不联网——插件只 spawn 本地 CLI,不访问 GitHub,也不访问任何 CDN。
|
|
30
|
+
|
|
31
|
+
CLI 按四条路找,顺序即优先级:
|
|
32
|
+
|
|
33
|
+
1. `config.cli` —— 显式写死,永远第一(写错了就报错,不会被别的路悄悄顶掉)
|
|
34
|
+
2. 插件自带的 `@m3e/mcp` —— `require.resolve` 从包目录往上走,覆盖 npm 嵌套落点与 pnpm 提升两种
|
|
35
|
+
3. npm 全局目录 `%APPDATA%\npm\node_modules` —— `npm i -g` 的老用户仍然算数
|
|
36
|
+
4. `npm_config_prefix` —— 换过 `--prefix` 的人
|
|
37
|
+
|
|
38
|
+
自带那份永远排在全局前面:跑哪一版由插件的 `package-lock.json` 决定,不被用户碰巧全局装了什么牵着走。
|
|
39
|
+
全局那份不会消失,只是降级成兜底;两份同时存在时 `m3e_status` 会多一行 `also on disk(未使用)`,
|
|
40
|
+
如果闲置那份反而更新,会在后面标一个 `(比在用的新)`。
|
|
41
|
+
|
|
42
|
+
两道硬门槛:Host 的 Node 必须 >= 22,解析到的 `@m3e/mcp` 必须 >= 2.13.8。不满足时 `startClient` 直接拒绝并说明原因,
|
|
43
|
+
`m3e_status` 里 `nodeSupported` / `cliOutdated` 会亮出来——不会让你对着一个起不来的进程猜。
|
|
44
|
+
四者都不中时它会明说查过哪几处。
|
|
45
|
+
|
|
46
|
+
代价:插件目录会多出约 59 MB(`@m3e/mcp` 拖着 `@m3e/web`、`@modelcontextprotocol/sdk`、`lit` 等 109 个包)。
|
|
47
|
+
|
|
48
|
+
## 三个入口
|
|
49
|
+
|
|
50
|
+
同一件事可以在三个地方做,行为一致:
|
|
51
|
+
|
|
52
|
+
| 入口 | 适合 |
|
|
53
|
+
|---|---|
|
|
54
|
+
| 输入框左侧那颗 chip | 鼠标党;菜单里还有「自检」「检查更新」 |
|
|
55
|
+
| `m3e_surface` 工具 | 让模型自己切;`m3e_status` 看体检结果 |
|
|
56
|
+
| `/m3e on\|off\|status\|selfcheck\|update\|studio` | 键盘党、headless、没有 web 界面的 profile |
|
|
57
|
+
|
|
58
|
+
`/m3e selfcheck` 会真的调一次 `list_components` 并报出阶段与耗时——比"工具好像没反应"有用。
|
|
59
|
+
`/m3e update` 是**唯一**会联网的动作:显式触发,查 npmmirror、失败再查 npmjs,6 秒超时,只报告不安装。
|
|
60
|
+
`/m3e studio` 与 chip 菜单里的「打开 Studio」是同一条路:先探活 `127.0.0.1:4317`,可达就开新标签页。
|
|
61
|
+
|
|
62
|
+
Studio **随包发**:插件里带了一份从 m3e-studio 裁出来的静态站(`studio/`,384 个文件 / 8.5 MB),装完插件就有,不用另外 clone 一个仓库。它会**跟着插件一起启动**(`studioAutostart`,默认开):插件加载时先探活,没起就 spawn,DSH 关掉时收掉——所以重启电脑之后不用再手动 `npm run studio`。探活可达时不会起第二个(沿用已在跑的那个)。
|
|
63
|
+
|
|
64
|
+
细节:
|
|
65
|
+
- 目录优先级:`studioDir` 配置 → 包内 `studio/` → 插件旁边的 `m3e-studio`(开发态)。包内那份由 `host/studio-serve.mjs` 提供,另外两种走各自的 `dev/serve.mjs`
|
|
66
|
+
- 想换回自己的 Studio 源码:在 `cordis.patch.yml` 里写 `studioDir: <目录>`,该目录必须含 `dev/serve.mjs`
|
|
67
|
+
- 想让桥"只管跳转、不要替我起进程":`studioAutostart: false`
|
|
68
|
+
- 端口被别的程序占着:探活会看到它,桥不会去抢
|
|
69
|
+
- 起不来时 chip 会红字说明原因(目录没找到 / 没有入口脚本 / 超时),`/m3e studio` 也给同一句话
|
|
70
|
+
- 包内那份**没有「固化剪影」按钮**:它要写盘,而包目录可能只读。重新固化是开发态的事,结果随包发
|
|
71
|
+
- 桥不代理 Studio、也不读它的源码
|
|
72
|
+
|
|
73
|
+
子进程意外死掉时,插件的 `autoReconnect`(默认开)会按 1s / 4s / 9s 重连,60 秒内最多 3 次;第 4 次停手并把原因写进状态。手动关掉会清空这个计数,不会把进程又拉起来。
|
|
74
|
+
|
|
75
|
+
## 开关状态
|
|
76
|
+
|
|
77
|
+
存在 `<DSH_HOME>/plugins-data/m3e/bridge.json`,重启后保持上次选择。
|
|
78
|
+
|
|
79
|
+
## 开发
|
|
80
|
+
|
|
81
|
+
```powershell
|
|
82
|
+
npm install # 首次 / 拉新代码之后:@m3e/mcp 是 dependency
|
|
83
|
+
node tests/probe.mjs # 不重启就验:起假 ctx、真跑一个 tools/call、再关再开
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`tests/probe.mjs` 除了四条功能判据,还断言 CLI 走的是插件自带那份(`source=package`)——
|
|
87
|
+
回落到全局就判失败,因为那意味着"装插件就自带了"这条没成立。
|
|
88
|
+
另外它用 `tests/fixtures/fake-mcp.mjs` 注入四种故障:握手超时、`tools/list` 超时、`tools/call` 超时、
|
|
89
|
+
启动即崩,确认失败会被如实报出来、工具面会回滚、进程不会漏。
|
|
90
|
+
|
|
91
|
+
细节和踩过的坑见 `AGENTS.md`。
|
package/client.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// dsh-m3e-mcp — Client half.
|
|
2
|
+
//
|
|
3
|
+
// 输入框左侧一颗开关("m3e 开启 6/6 ▾"),两档:关闭 / 开启。
|
|
4
|
+
// 关闭 = 官方的 mcp__m3e__* 全部从注册表摘掉、子进程也停掉,省上下文也省内存。
|
|
5
|
+
// 它只跟自己那条路由说话(/m3e/api/surface),不碰别的 DOM。
|
|
6
|
+
window.__ModuleLoader__.load({
|
|
7
|
+
id: 'dsh-m3e-mcp',
|
|
8
|
+
factory(require) {
|
|
9
|
+
const React = require('react')
|
|
10
|
+
const h = React.createElement
|
|
11
|
+
|
|
12
|
+
const TOKEN_ROUTE = '/m3e/api/token'
|
|
13
|
+
const SURFACE_ROUTE = '/m3e/api/surface'
|
|
14
|
+
// 两个窗口共用一个 bridge.json:一个窗口切了档,另一个不该等 20 秒轮询才发现。
|
|
15
|
+
const CHANNEL = typeof BroadcastChannel === 'function' ? new BroadcastChannel('dsh-m3e-mcp') : null
|
|
16
|
+
|
|
17
|
+
let tokenPromise = null
|
|
18
|
+
function fetchToken() {
|
|
19
|
+
if (!tokenPromise) {
|
|
20
|
+
tokenPromise = fetch(TOKEN_ROUTE, { headers: { accept: 'application/json' }, credentials: 'same-origin' })
|
|
21
|
+
.then((response) => (response.ok ? response.json() : Promise.reject(new Error(`token route HTTP ${response.status}`))))
|
|
22
|
+
.then((body) => {
|
|
23
|
+
if (!body || typeof body.token !== 'string' || body.token.length < 16) throw new Error('token route returned no token')
|
|
24
|
+
return body.token
|
|
25
|
+
})
|
|
26
|
+
.catch((error) => { tokenPromise = null; throw error })
|
|
27
|
+
}
|
|
28
|
+
return tokenPromise
|
|
29
|
+
}
|
|
30
|
+
function apiFetch(pathname, options = {}) {
|
|
31
|
+
const request = (token) => fetch(pathname, {
|
|
32
|
+
...options,
|
|
33
|
+
credentials: 'same-origin',
|
|
34
|
+
headers: { accept: 'application/json', ...(options.headers || {}), authorization: `Bearer ${token}` },
|
|
35
|
+
})
|
|
36
|
+
return fetchToken().then(request).then((response) => {
|
|
37
|
+
if (response.status !== 401) return response
|
|
38
|
+
tokenPromise = null
|
|
39
|
+
return fetchToken().then(request)
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
const getJson = (pathname) => apiFetch(pathname).then((response) => response.json())
|
|
43
|
+
const postJson = (pathname, body) => apiFetch(pathname, {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: { 'content-type': 'application/json' },
|
|
46
|
+
body: JSON.stringify(body || {}),
|
|
47
|
+
}).then((response) => response.json())
|
|
48
|
+
|
|
49
|
+
const TIERS = [['off', '关闭'], ['on', '开启']]
|
|
50
|
+
const labelOf = (tier) => { const found = TIERS.find((x) => x[0] === tier); return found ? found[1] : tier }
|
|
51
|
+
|
|
52
|
+
function Chip() {
|
|
53
|
+
try { return ChipInner() } catch (error) {
|
|
54
|
+
return h('span', { style: { fontSize: '11px', color: '#e06060' } }, 'm3e: ' + String(error && error.message ? error.message : error))
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function ChipInner() {
|
|
59
|
+
const [state, setState] = React.useState(null)
|
|
60
|
+
const [open, setOpen] = React.useState(false)
|
|
61
|
+
const [busy, setBusy] = React.useState(false)
|
|
62
|
+
const [error, setError] = React.useState(null)
|
|
63
|
+
const [note, setNote] = React.useState(null)
|
|
64
|
+
// 失败要说出来、8 秒后自己退场;别像早先那样 .catch(() => {}) 吞掉,让界面停在旧档装作没事。
|
|
65
|
+
React.useEffect(() => {
|
|
66
|
+
if (!error) return undefined
|
|
67
|
+
const timer = setTimeout(() => setError(null), 8000)
|
|
68
|
+
return () => clearTimeout(timer)
|
|
69
|
+
}, [error])
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
if (!note) return undefined
|
|
72
|
+
const timer = setTimeout(() => setNote(null), 6000)
|
|
73
|
+
return () => clearTimeout(timer)
|
|
74
|
+
}, [note])
|
|
75
|
+
const load = React.useCallback(() => {
|
|
76
|
+
getJson(SURFACE_ROUTE).then((next) => { setState(next); setError(null) }).catch(() => setState({ surface: 'unknown' }))
|
|
77
|
+
}, [])
|
|
78
|
+
React.useEffect(() => {
|
|
79
|
+
load()
|
|
80
|
+
const timer = setInterval(load, 20_000)
|
|
81
|
+
if (CHANNEL) CHANNEL.onmessage = () => load()
|
|
82
|
+
return () => { clearInterval(timer); if (CHANNEL) CHANNEL.onmessage = null }
|
|
83
|
+
}, [load])
|
|
84
|
+
const surface = state && state.surface ? state.surface : 'on'
|
|
85
|
+
const tools = state && (state.mcpTools || state.mcp) ? (state.mcpTools || state.mcp) : null
|
|
86
|
+
const pick = (tier) => {
|
|
87
|
+
if (busy || tier === surface) { setOpen(false); return }
|
|
88
|
+
setBusy(true)
|
|
89
|
+
setError(null)
|
|
90
|
+
postJson(SURFACE_ROUTE, { surface: tier })
|
|
91
|
+
.then((next) => {
|
|
92
|
+
if (!next || next.ok !== true) throw new Error((next && next.error) || '切档失败')
|
|
93
|
+
const applied = next.mcpTools || next
|
|
94
|
+
if (tier === 'on' && applied && applied.running === false) throw new Error(next.error || 'server 没起来')
|
|
95
|
+
setState(next)
|
|
96
|
+
if (CHANNEL) CHANNEL.postMessage({ surface: next.surface })
|
|
97
|
+
})
|
|
98
|
+
.catch((thrown) => { setError(String(thrown && thrown.message ? thrown.message : thrown)); load() })
|
|
99
|
+
.finally(() => { setBusy(false); setOpen(false) })
|
|
100
|
+
}
|
|
101
|
+
const runSelfCheck = () => {
|
|
102
|
+
setError(null); setNote(null); setBusy(true)
|
|
103
|
+
postJson('/m3e/api/selfcheck', {})
|
|
104
|
+
.then((r) => setNote(`自检:${r.ok ? '通过' : '失败'}(${r.phase},${r.ms}ms)${r.error ? ` · ${r.error}` : ''}`))
|
|
105
|
+
.catch((thrown) => setError(String(thrown && thrown.message ? thrown.message : thrown)))
|
|
106
|
+
.finally(() => setBusy(false))
|
|
107
|
+
}
|
|
108
|
+
const openStudio = () => {
|
|
109
|
+
setError(null); setNote(null)
|
|
110
|
+
const open = (r) => {
|
|
111
|
+
if (!r || r.reachable !== true) throw new Error(r && r.error ? r.error : 'Studio 起不来:检查 studioDir / studioAutostart')
|
|
112
|
+
window.open(r.url, '_blank', 'noopener')
|
|
113
|
+
setNote(`已打开 ${r.url}${r.managed ? '(由桥拉起)' : ''}`)
|
|
114
|
+
}
|
|
115
|
+
// 先问状态;不可达就让宿主当场起来(?start=1),起好了再开新标签页。
|
|
116
|
+
getJson('/m3e/api/studio')
|
|
117
|
+
.then((r) => (r && r.reachable === true ? r : getJson('/m3e/api/studio?start=1')))
|
|
118
|
+
.then(open)
|
|
119
|
+
.catch((thrown) => setError(String(thrown && thrown.message ? thrown.message : thrown)))
|
|
120
|
+
}
|
|
121
|
+
const runUpdate = () => {
|
|
122
|
+
setError(null); setNote(null); setBusy(true)
|
|
123
|
+
postJson('/m3e/api/update', {})
|
|
124
|
+
.then((r) => {
|
|
125
|
+
if (!r.ok) throw new Error(r.error || 'update check failed')
|
|
126
|
+
setNote(`${r.current} → ${r.latest}${r.upToDate ? '(已是最新)' : '(有更新)'}`)
|
|
127
|
+
})
|
|
128
|
+
.catch((thrown) => setError(String(thrown && thrown.message ? thrown.message : thrown)))
|
|
129
|
+
.finally(() => setBusy(false))
|
|
130
|
+
}
|
|
131
|
+
return h('div', { className: 'dsh-m3e-chip-wrap' },
|
|
132
|
+
h('button', {
|
|
133
|
+
type: 'button',
|
|
134
|
+
className: `dsh-m3e-chip${surface === 'off' ? ' is-off' : ' is-on'}${open ? ' is-open' : ''}${error ? ' is-error' : ''}`,
|
|
135
|
+
title: error ? `m3e:${error}` : 'm3e:官方的 mcp__m3e__* 工具要不要挂进这轮对话。关闭会停掉子进程,省上下文。',
|
|
136
|
+
onClick: () => setOpen((value) => !value),
|
|
137
|
+
},
|
|
138
|
+
h('span', { className: 'dsh-m3e-dot', 'aria-hidden': 'true' }),
|
|
139
|
+
h('span', { className: 'dsh-m3e-label' }, 'm3e'),
|
|
140
|
+
h('span', { className: 'dsh-m3e-tier' }, busy ? '切换中' : error ? '失败' : labelOf(surface)),
|
|
141
|
+
tools ? h('span', { className: 'dsh-m3e-count' }, `${tools.visible}/${tools.total}`) : null,
|
|
142
|
+
h('span', { className: `dsh-m3e-caret${open ? ' is-open' : ''}`, 'aria-hidden': 'true' }, '▾')),
|
|
143
|
+
open ? h('div', { className: 'dsh-m3e-menu' },
|
|
144
|
+
TIERS.map(([tier, label]) => h('button', {
|
|
145
|
+
key: tier,
|
|
146
|
+
type: 'button',
|
|
147
|
+
className: `dsh-m3e-item${tier === surface ? ' is-on' : ''}`,
|
|
148
|
+
onClick: () => pick(tier),
|
|
149
|
+
}, label)),
|
|
150
|
+
h('div', { className: 'dsh-m3e-sep' }),
|
|
151
|
+
h('button', { type: 'button', className: 'dsh-m3e-item', disabled: busy, onClick: runSelfCheck }, '自检'),
|
|
152
|
+
h('button', { type: 'button', className: 'dsh-m3e-item', disabled: busy, onClick: runUpdate }, '检查更新'),
|
|
153
|
+
h('button', { type: 'button', className: 'dsh-m3e-item', disabled: busy, onClick: openStudio }, '打开 Studio'),
|
|
154
|
+
error ? h('div', { className: 'dsh-m3e-error' }, error) : null,
|
|
155
|
+
!error && note ? h('div', { className: 'dsh-m3e-note' }, note) : null) : null)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const css = `
|
|
159
|
+
.dsh-m3e-chip-wrap { position: relative; display: inline-flex; }
|
|
160
|
+
.dsh-m3e-chip { appearance: none; -webkit-appearance: none; display: inline-flex; align-items: center; gap: 6px;
|
|
161
|
+
border: 1px solid var(--dsw-alias-border-l2); box-shadow: none; background: transparent;
|
|
162
|
+
color: var(--dsw-alias-label-secondary); font: inherit; font-size: 12px; line-height: 1;
|
|
163
|
+
padding: 5px 9px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
|
|
164
|
+
.dsh-m3e-chip:hover { color: var(--dsw-alias-label-primary); background: var(--dsw-alias-bg-layer-2); }
|
|
165
|
+
.dsh-m3e-chip.is-on { color: var(--dsh-m3e-on, #7c5cff); border-color: var(--dsh-m3e-on, #7c5cff); }
|
|
166
|
+
.dsh-m3e-chip.is-on .dsh-m3e-dot { background: var(--dsh-m3e-on, #7c5cff); }
|
|
167
|
+
.dsh-m3e-chip.is-off { color: var(--dsw-alias-label-secondary); border-color: var(--dsw-alias-border-l2); opacity: .7; }
|
|
168
|
+
.dsh-m3e-chip.is-off .dsh-m3e-dot { background: var(--dsw-alias-state-idle-primary); }
|
|
169
|
+
.dsh-m3e-chip.is-error { color: #e06060; border-color: #e06060; opacity: 1; }
|
|
170
|
+
.dsh-m3e-chip.is-error .dsh-m3e-dot { background: #e06060; }
|
|
171
|
+
.dsh-m3e-error { font-size: 11px; line-height: 1.35; color: #e06060; padding: 4px 9px 2px; max-width: 230px; white-space: normal; }
|
|
172
|
+
.dsh-m3e-note { font-size: 11px; line-height: 1.35; color: var(--dsw-alias-label-secondary); padding: 4px 9px 2px; max-width: 230px; white-space: normal; }
|
|
173
|
+
.dsh-m3e-sep { height: 1px; margin: 4px 6px; background: color-mix(in srgb, currentColor 16%, transparent); }
|
|
174
|
+
.dsh-m3e-item[disabled] { opacity: .5; cursor: default; }
|
|
175
|
+
.dsh-m3e-chip.is-open { background: var(--dsw-alias-bg-layer-2); }
|
|
176
|
+
.dsh-m3e-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dsw-alias-brand-primary); flex: none; }
|
|
177
|
+
.dsh-m3e-label { opacity: .85; }
|
|
178
|
+
.dsh-m3e-tier { font-weight: 600; }
|
|
179
|
+
.dsh-m3e-count { opacity: .7; font-variant-numeric: tabular-nums; }
|
|
180
|
+
.dsh-m3e-caret { font-size: 9px; opacity: .7; line-height: 1; transition: transform .12s ease; }
|
|
181
|
+
.dsh-m3e-caret.is-open { transform: rotate(180deg); }
|
|
182
|
+
.dsh-m3e-menu { position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 40; min-width: 110px; padding: 5px;
|
|
183
|
+
border-radius: 9px; border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
|
|
184
|
+
background: var(--dsh-surface, rgba(28,28,30,.98)); box-shadow: 0 8px 26px rgba(0,0,0,.35); display: flex; flex-direction: column; }
|
|
185
|
+
.dsh-m3e-item { font: inherit; font-size: 12px; text-align: left; padding: 6px 9px; border-radius: 6px;
|
|
186
|
+
border: 0; background: transparent; color: inherit; cursor: pointer; }
|
|
187
|
+
.dsh-m3e-item:hover { background: color-mix(in srgb, currentColor 9%, transparent); }
|
|
188
|
+
.dsh-m3e-item.is-on { background: color-mix(in srgb, var(--dsh-m3e-on, #7c5cff) 22%, transparent); }
|
|
189
|
+
`
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
inject: ['slots'],
|
|
193
|
+
apply(ctx) {
|
|
194
|
+
try {
|
|
195
|
+
if (typeof document !== 'undefined' && !document.getElementById('dsh-m3e-styles')) {
|
|
196
|
+
const style = document.createElement('style')
|
|
197
|
+
style.id = 'dsh-m3e-styles'
|
|
198
|
+
style.textContent = css
|
|
199
|
+
document.head.appendChild(style)
|
|
200
|
+
}
|
|
201
|
+
} catch { /* non-DOM host */ }
|
|
202
|
+
const slots = ctx.slots
|
|
203
|
+
slots.inject('conversation.input.left', () => slots.register({
|
|
204
|
+
name: 'conversation.input.left',
|
|
205
|
+
id: 'dsh-m3e-mcp/surface',
|
|
206
|
+
order: 87,
|
|
207
|
+
label: () => 'm3e',
|
|
208
|
+
}, Chip))
|
|
209
|
+
},
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
})
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# dsh-m3e-mcp — 官方 @m3e/mcp 的宿主桥,带一个两档开关。
|
|
2
|
+
#
|
|
3
|
+
# 一行:把这一行挂进 Harness,插件自己 spawn `node <@m3e/mcp>/dist/cli.js`,
|
|
4
|
+
# 把它列出的工具注册成 mcp__m3e__<tool>。不依赖 @deepseek-ai/dsh-mcp-client,
|
|
5
|
+
# 也不依赖 PATH——node 用 process.execPath,CLI 用绝对路径解析。
|
|
6
|
+
#
|
|
7
|
+
# 为什么要有开关:这六个工具是"查资料"用的,不用的时候挂在上下文里全是噪声。
|
|
8
|
+
# 关闭 = 全部从注册表摘掉 + 子进程停掉(0 工具、0 进程)
|
|
9
|
+
# 开启 = 起进程、列出工具、全部注册
|
|
10
|
+
# 状态存在 <DSH_HOME>/plugins-data/m3e/bridge.json,重启后保持上次的选择。
|
|
11
|
+
#
|
|
12
|
+
# 前提:@m3e/mcp 是这个插件自己的 dependency,装插件时就装好了,不用再 npm i -g。
|
|
13
|
+
# 用 link: 挂开发目录时包管理器不会替你装被链对象的依赖,先在插件目录跑一次 npm install。
|
|
14
|
+
# 还是找不到的话 m3e_status 会明说(并列出它查过的每一处)。
|
|
15
|
+
#
|
|
16
|
+
# Knobs:
|
|
17
|
+
# - cli 显式指定 CLI 路径(默认自动找:插件自带 → npm 全局目录 → npm_config_prefix)
|
|
18
|
+
# - initTimeoutMs 握手超时(默认 20000);慢机器可以调大,错误注入测试会调小
|
|
19
|
+
# - listTimeoutMs tools/list 超时(默认 30000)
|
|
20
|
+
# - callTimeoutMs 单次 tools/call 超时(默认 120000)
|
|
21
|
+
# - startOnBoot 默认 true;设 false 则启动时不自动拉起,等 m3e_surface 叫它
|
|
22
|
+
# - autoReconnect 默认 true;子进程意外死后按 1s/4s/9s 退避重连,60s 内最多 3 次
|
|
23
|
+
#
|
|
24
|
+
# - studioUrl Studio 的地址(默认 http://127.0.0.1:4317/),只用于探活和跳转
|
|
25
|
+
# - studioAutostart 默认 true;插件加载时先探活,没起就 spawn 对应目录的入口脚本
|
|
26
|
+
# (上次没被收掉的进程会被沿用,不会起第二个抢端口)。设 false 退回"只探活"
|
|
27
|
+
# - studioDir Studio 目录。不填就用包内 studio/(npm run vendor 生成),
|
|
28
|
+
# 再没有才找插件旁边的 m3e-studio;写死的目录必须含 dev/serve.mjs
|
|
29
|
+
# - studioStartTimeoutMs 等它应答的上限(默认 15000)
|
|
30
|
+
#
|
|
31
|
+
# 另有 reconnectDelaysMs(数组,测试用)与 initTimeoutMs/listTimeoutMs,一般不用动。
|
|
32
|
+
- insert:
|
|
33
|
+
- id: m3e-mcp-host
|
|
34
|
+
name: dsh-m3e-mcp
|
|
35
|
+
config:
|
|
36
|
+
# cli: 'C:\Users\me\AppData\Roaming\npm\node_modules\@m3e\mcp\dist\cli.js'
|
|
37
|
+
# initTimeoutMs: 20000
|
|
38
|
+
# listTimeoutMs: 30000
|
|
39
|
+
# callTimeoutMs: 120000
|
|
40
|
+
# startOnBoot: true
|
|
41
|
+
# autoReconnect: true
|
|
42
|
+
# studioUrl: 'http://127.0.0.1:4317/'
|
|
43
|
+
# studioAutostart: true
|
|
44
|
+
# studioDir: 'E:\test\m3e-studio'
|