@capyclaw/publisher 0.0.0-stage → 0.1.3
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/README.md +112 -2
- package/client/client.js +717 -0
- package/cordis.patch.yml +13 -0
- package/icon.svg +6 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/node_modules/@capyclaw/foundation/README.md +51 -0
- package/node_modules/@capyclaw/foundation/abi/bridge.mjs +86 -0
- package/node_modules/@capyclaw/foundation/abi/errors.mjs +63 -0
- package/node_modules/@capyclaw/foundation/abi/index.mjs +35 -0
- package/node_modules/@capyclaw/foundation/abi/kinds.mjs +271 -0
- package/node_modules/@capyclaw/foundation/abi/loader.mjs +345 -0
- package/node_modules/@capyclaw/foundation/abi/schema.mjs +98 -0
- package/node_modules/@capyclaw/foundation/abi/spec.mjs +255 -0
- package/node_modules/@capyclaw/foundation/abi/validate.mjs +24 -0
- package/node_modules/@capyclaw/foundation/abi/version.mjs +82 -0
- package/node_modules/@capyclaw/foundation/cordis.patch.yml +5 -0
- package/node_modules/@capyclaw/foundation/kit/index.mjs +6 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/client-panel.mjs +98 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/host-event.mjs +35 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/http-router.mjs +69 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +55 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/own-server.mjs +113 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +68 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +113 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/service-provider.mjs +77 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/skill-provider.mjs +56 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/tool-provider.mjs +50 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/ui-panel.mjs +64 -0
- package/node_modules/@capyclaw/foundation/lib/ctx-service.mjs +42 -0
- package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +34 -0
- package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +85 -0
- package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +50 -0
- package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +160 -0
- package/node_modules/@capyclaw/foundation/lib/host.mjs +23 -0
- package/node_modules/@capyclaw/foundation/lib/kernel.mjs +185 -0
- package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +87 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/events.mjs +60 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/log.mjs +51 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +188 -0
- package/node_modules/@capyclaw/foundation/package.json +53 -0
- package/node_modules/@capyclaw/foundation/runtime/index.mjs +20 -0
- package/node_modules/@capyclaw/plugin-kit/INTEGRATION.md +100 -0
- package/node_modules/@capyclaw/plugin-kit/README.md +70 -0
- package/node_modules/@capyclaw/plugin-kit/bin/sync.mjs +103 -0
- package/node_modules/@capyclaw/plugin-kit/package.json +69 -0
- package/node_modules/@capyclaw/plugin-kit/src/cli.mjs +56 -0
- package/node_modules/@capyclaw/plugin-kit/src/config.mjs +142 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +129 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +139 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/shadow.mjs +219 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/transport.js +13 -0
- package/node_modules/@capyclaw/plugin-kit/src/index.mjs +13 -0
- package/node_modules/@capyclaw/plugin-kit/src/pack.mjs +230 -0
- package/node_modules/@capyclaw/plugin-kit/src/runtime/context.mjs +128 -0
- package/node_modules/@capyclaw/plugin-kit/src/self-contained.mjs +307 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/api.mjs +45 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/http.mjs +113 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +150 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/server.mjs +131 -0
- package/node_modules/@capyclaw/plugin-kit/src/skills/provider.mjs +82 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/blob-store.mjs +109 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/content-store.mjs +17 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/journal-store.mjs +89 -0
- package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +57 -0
- package/node_modules/@capyclaw/plugin-kit/src/tools/validate.mjs +150 -0
- package/node_modules/@capyclaw/plugin-kit/src/tuning.mjs +82 -0
- package/node_modules/@capyclaw/plugin-kit/src/util/fs-lock.mjs +132 -0
- package/node_modules/@capyclaw/plugin-kit/src/util/http.mjs +130 -0
- package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +656 -0
- package/node_modules/@capyclaw/plugin-kit/src/zip.mjs +181 -0
- package/node_modules/@capyclaw/plugin-validator/bin/cli.mjs +49 -0
- package/node_modules/@capyclaw/plugin-validator/lib/index.mjs +303 -0
- package/node_modules/@capyclaw/plugin-validator/package.json +28 -0
- package/node_modules/@capyclaw/tool-host/README.md +56 -0
- package/node_modules/@capyclaw/tool-host/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/tool-host/dsh-suite.json +30 -0
- package/node_modules/@capyclaw/tool-host/lib/host.mjs +16 -0
- package/node_modules/@capyclaw/tool-host/package.json +59 -0
- package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +166 -0
- package/node_modules/@capyclaw/tool-host/src/index.mjs +416 -0
- package/node_modules/semver/LICENSE +15 -0
- package/node_modules/semver/README.md +680 -0
- package/node_modules/semver/bin/semver.js +195 -0
- package/node_modules/semver/classes/comparator.js +143 -0
- package/node_modules/semver/classes/index.js +7 -0
- package/node_modules/semver/classes/range.js +577 -0
- package/node_modules/semver/classes/semver.js +350 -0
- package/node_modules/semver/functions/clean.js +8 -0
- package/node_modules/semver/functions/cmp.js +54 -0
- package/node_modules/semver/functions/coerce.js +62 -0
- package/node_modules/semver/functions/compare-build.js +9 -0
- package/node_modules/semver/functions/compare-loose.js +5 -0
- package/node_modules/semver/functions/compare.js +7 -0
- package/node_modules/semver/functions/diff.js +60 -0
- package/node_modules/semver/functions/eq.js +5 -0
- package/node_modules/semver/functions/gt.js +5 -0
- package/node_modules/semver/functions/gte.js +5 -0
- package/node_modules/semver/functions/inc.js +21 -0
- package/node_modules/semver/functions/lt.js +5 -0
- package/node_modules/semver/functions/lte.js +5 -0
- package/node_modules/semver/functions/major.js +5 -0
- package/node_modules/semver/functions/minor.js +5 -0
- package/node_modules/semver/functions/neq.js +5 -0
- package/node_modules/semver/functions/parse.js +18 -0
- package/node_modules/semver/functions/patch.js +5 -0
- package/node_modules/semver/functions/prerelease.js +8 -0
- package/node_modules/semver/functions/rcompare.js +5 -0
- package/node_modules/semver/functions/rsort.js +5 -0
- package/node_modules/semver/functions/satisfies.js +12 -0
- package/node_modules/semver/functions/sort.js +5 -0
- package/node_modules/semver/functions/truncate.js +48 -0
- package/node_modules/semver/functions/valid.js +8 -0
- package/node_modules/semver/index.js +93 -0
- package/node_modules/semver/internal/constants.js +67 -0
- package/node_modules/semver/internal/debug.js +11 -0
- package/node_modules/semver/internal/identifiers.js +29 -0
- package/node_modules/semver/internal/lrucache.js +42 -0
- package/node_modules/semver/internal/parse-options.js +17 -0
- package/node_modules/semver/internal/re.js +223 -0
- package/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
- package/node_modules/semver/package.json +78 -0
- package/node_modules/semver/preload.js +4 -0
- package/node_modules/semver/range.bnf +17 -0
- package/node_modules/semver/ranges/gtr.js +6 -0
- package/node_modules/semver/ranges/intersects.js +9 -0
- package/node_modules/semver/ranges/ltr.js +6 -0
- package/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/node_modules/semver/ranges/min-version.js +63 -0
- package/node_modules/semver/ranges/outside.js +82 -0
- package/node_modules/semver/ranges/simplify.js +49 -0
- package/node_modules/semver/ranges/subset.js +249 -0
- package/node_modules/semver/ranges/to-comparators.js +10 -0
- package/node_modules/semver/ranges/valid.js +13 -0
- package/node_modules/yaml/LICENSE +13 -0
- package/node_modules/yaml/README.md +172 -0
- package/node_modules/yaml/bin.mjs +11 -0
- package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
- package/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
- package/node_modules/yaml/browser/dist/compose/composer.js +219 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
- package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +226 -0
- package/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
- package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
- package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
- package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
- package/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
- package/node_modules/yaml/browser/dist/doc/Document.js +335 -0
- package/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
- package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
- package/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
- package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
- package/node_modules/yaml/browser/dist/errors.js +57 -0
- package/node_modules/yaml/browser/dist/index.js +17 -0
- package/node_modules/yaml/browser/dist/log.js +11 -0
- package/node_modules/yaml/browser/dist/nodes/Alias.js +118 -0
- package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
- package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
- package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
- package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
- package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
- package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
- package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
- package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
- package/node_modules/yaml/browser/dist/parse/lexer.js +721 -0
- package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
- package/node_modules/yaml/browser/dist/parse/parser.js +975 -0
- package/node_modules/yaml/browser/dist/public-api.js +102 -0
- package/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
- package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
- package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
- package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
- package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
- package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
- package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
- package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
- package/node_modules/yaml/browser/dist/schema/tags.js +96 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +67 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
- package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
- package/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +25 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
- package/node_modules/yaml/browser/dist/util.js +11 -0
- package/node_modules/yaml/browser/dist/visit.js +233 -0
- package/node_modules/yaml/browser/index.js +5 -0
- package/node_modules/yaml/browser/package.json +3 -0
- package/node_modules/yaml/dist/cli.d.ts +8 -0
- package/node_modules/yaml/dist/cli.mjs +201 -0
- package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
- package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
- package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
- package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
- package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
- package/node_modules/yaml/dist/compose/compose-node.js +112 -0
- package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
- package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
- package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
- package/node_modules/yaml/dist/compose/composer.js +224 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
- package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +228 -0
- package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
- package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
- package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
- package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
- package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
- package/node_modules/yaml/dist/doc/Document.js +337 -0
- package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
- package/node_modules/yaml/dist/doc/anchors.js +76 -0
- package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
- package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
- package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
- package/node_modules/yaml/dist/doc/createNode.js +90 -0
- package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
- package/node_modules/yaml/dist/doc/directives.js +178 -0
- package/node_modules/yaml/dist/errors.d.ts +21 -0
- package/node_modules/yaml/dist/errors.js +62 -0
- package/node_modules/yaml/dist/index.d.ts +25 -0
- package/node_modules/yaml/dist/index.js +50 -0
- package/node_modules/yaml/dist/log.d.ts +3 -0
- package/node_modules/yaml/dist/log.js +19 -0
- package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
- package/node_modules/yaml/dist/nodes/Alias.js +120 -0
- package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
- package/node_modules/yaml/dist/nodes/Collection.js +151 -0
- package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
- package/node_modules/yaml/dist/nodes/Node.js +40 -0
- package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
- package/node_modules/yaml/dist/nodes/Pair.js +39 -0
- package/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
- package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
- package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
- package/node_modules/yaml/dist/nodes/identity.js +53 -0
- package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
- package/node_modules/yaml/dist/nodes/toJS.js +39 -0
- package/node_modules/yaml/dist/options.d.ts +350 -0
- package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
- package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
- package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
- package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
- package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
- package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
- package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
- package/node_modules/yaml/dist/parse/cst.js +112 -0
- package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
- package/node_modules/yaml/dist/parse/lexer.js +723 -0
- package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
- package/node_modules/yaml/dist/parse/line-counter.js +41 -0
- package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
- package/node_modules/yaml/dist/parse/parser.js +980 -0
- package/node_modules/yaml/dist/public-api.d.ts +44 -0
- package/node_modules/yaml/dist/public-api.js +107 -0
- package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
- package/node_modules/yaml/dist/schema/Schema.js +39 -0
- package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/map.js +19 -0
- package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
- package/node_modules/yaml/dist/schema/common/null.js +17 -0
- package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/seq.js +19 -0
- package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/string.js +16 -0
- package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/bool.js +21 -0
- package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/float.js +47 -0
- package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/int.js +42 -0
- package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/core/schema.js +25 -0
- package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
- package/node_modules/yaml/dist/schema/json/schema.js +64 -0
- package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
- package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
- package/node_modules/yaml/dist/schema/tags.js +99 -0
- package/node_modules/yaml/dist/schema/types.d.ts +92 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
- package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
- package/node_modules/yaml/dist/stringify/stringify.js +132 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
- package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
- package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
- package/node_modules/yaml/dist/test-events.d.ts +4 -0
- package/node_modules/yaml/dist/test-events.js +134 -0
- package/node_modules/yaml/dist/util.d.ts +16 -0
- package/node_modules/yaml/dist/util.js +28 -0
- package/node_modules/yaml/dist/visit.d.ts +102 -0
- package/node_modules/yaml/dist/visit.js +236 -0
- package/node_modules/yaml/package.json +97 -0
- package/node_modules/yaml/util.js +2 -0
- package/package.json +78 -4
- package/plugin.mjs +113 -0
- package/server/archive.mjs +255 -0
- package/server/drop.mjs +498 -0
- package/server/impl.mjs +609 -0
- package/server/routes.mjs +339 -0
- package/server/tools.mjs +111 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 拖拽发布的同源 HTTP 面(挂在 DSH 自带 webServer 上,和插件页同源)。
|
|
3
|
+
*
|
|
4
|
+
* GET /publisher-drop/health 探活 + npm 身份 + 最近发布
|
|
5
|
+
* POST /publisher-drop/prepare 上传压缩包 → 解包 → 版本规划 + 预检结果
|
|
6
|
+
* POST /publisher-drop/publish 对 prepare 得到的 token 真发布(不可撤销)
|
|
7
|
+
* POST /publisher-drop/discard 放弃一次预检(回收 staging)
|
|
8
|
+
*
|
|
9
|
+
* 路由只做「读写 HTTP + 管句柄」,发布逻辑全在 drop.mjs;token 是唯一句柄,
|
|
10
|
+
* 浏览器永远拿不到本机路径,也就无法让宿主对任意目录执行 npm publish。
|
|
11
|
+
*/
|
|
12
|
+
import crypto from 'node:crypto'
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
MAX_ARCHIVE_BYTES, cleanupStage, npmRun, prepareUpload, previewStage, publishStage, sweepOrphans,
|
|
16
|
+
} from './drop.mjs'
|
|
17
|
+
|
|
18
|
+
const ROUTE_PREFIX = '/publisher-drop'
|
|
19
|
+
const MAX_JSON_BYTES = 64 * 1024
|
|
20
|
+
const STAGE_TTL_MS = 2 * 60 * 60 * 1000
|
|
21
|
+
const MAX_STAGES = 16
|
|
22
|
+
const RECENT_LIMIT = 8
|
|
23
|
+
const WHOAMI_TTL_MS = 60 * 1000
|
|
24
|
+
const WHOAMI_HINT = 'npm whoami 失败——在宿主机 npm login,或设置 NODE_AUTH_TOKEN'
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 建一套路由处理器;每次插件挂载一份独立状态(staging 句柄 / 最近发布 / 发布锁)。
|
|
28
|
+
* npm 调用全部异步:npm 一慢,卡住的只能这一个请求,不会把宿主事件循环钉住。
|
|
29
|
+
* `npm` / `whoami` 可注入,测试里用假实现代替真实 registry。
|
|
30
|
+
*/
|
|
31
|
+
export function createRoutes({ webServer, log, packageVersion = '', npm = npmRun, whoami = null, publishedTtlMs }) {
|
|
32
|
+
/** previewStage 的版本缓存时长;测试传 0 关掉缓存,生产用默认 15s。 */
|
|
33
|
+
const cacheOpts = publishedTtlMs === undefined ? {} : { cacheTtlMs: publishedTtlMs };
|
|
34
|
+
const stages = new Map()
|
|
35
|
+
const recent = []
|
|
36
|
+
let publishing = false
|
|
37
|
+
|
|
38
|
+
/* whoami 带 60s 缓存:插件页每次切回都会探活,不能每次都真跑一遍 npm。 */
|
|
39
|
+
let whoamiCache = null
|
|
40
|
+
let whoamiAt = 0
|
|
41
|
+
let whoamiPending = null
|
|
42
|
+
const probeWhoami = () => {
|
|
43
|
+
if (whoamiCache && Date.now() - whoamiAt < WHOAMI_TTL_MS) return whoamiCache
|
|
44
|
+
if (whoamiPending) return whoamiPending
|
|
45
|
+
const run = whoami || (async () => {
|
|
46
|
+
const result = await npm(['whoami'], { timeout: 15000 })
|
|
47
|
+
if (result.status !== 0) return { ok: false, hint: WHOAMI_HINT }
|
|
48
|
+
const user = String(result.stdout || '').trim()
|
|
49
|
+
return user ? { ok: true, user } : { ok: false, hint: WHOAMI_HINT }
|
|
50
|
+
})
|
|
51
|
+
whoamiPending = Promise.resolve(run())
|
|
52
|
+
.then((value) => {
|
|
53
|
+
whoamiCache = value
|
|
54
|
+
whoamiAt = Date.now()
|
|
55
|
+
return value
|
|
56
|
+
})
|
|
57
|
+
.catch(() => ({ ok: false, hint: WHOAMI_HINT }))
|
|
58
|
+
.finally(() => { whoamiPending = null })
|
|
59
|
+
return whoamiPending
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const remember = (entry) => {
|
|
63
|
+
recent.unshift(entry)
|
|
64
|
+
if (recent.length > RECENT_LIMIT) recent.length = RECENT_LIMIT
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const sweep = () => {
|
|
68
|
+
const cutoff = Date.now() - STAGE_TTL_MS
|
|
69
|
+
for (const [token, entry] of stages) {
|
|
70
|
+
if (entry.createdAt < cutoff) {
|
|
71
|
+
stages.delete(token)
|
|
72
|
+
cleanupStage(entry.stage)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* 内存里没记录、磁盘上却留下的 staging(崩溃/重启后的残骸)由这里兜底清掉。 */
|
|
78
|
+
const sweepDisk = () => {
|
|
79
|
+
const keep = new Set()
|
|
80
|
+
for (const entry of stages.values()) {
|
|
81
|
+
const base = entry.stage?.base
|
|
82
|
+
if (base) keep.add(base)
|
|
83
|
+
}
|
|
84
|
+
return sweepOrphans(keep, STAGE_TTL_MS)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* 拖拽多次却一直不发布时,最多留 MAX_STAGES 份解包结果,超出的丢最旧的。 */
|
|
88
|
+
const trimStages = () => {
|
|
89
|
+
if (stages.size < MAX_STAGES) return
|
|
90
|
+
const ordered = [...stages.values()].sort((a, b) => a.createdAt - b.createdAt)
|
|
91
|
+
for (const entry of ordered.slice(0, stages.size - MAX_STAGES + 1)) {
|
|
92
|
+
stages.delete(entry.token)
|
|
93
|
+
cleanupStage(entry.stage)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* 任何一个处理器抛错都不该变成「请求挂着不回」或未处理拒绝:统一回 500 JSON。 */
|
|
98
|
+
const guard = (handler) => async (req, res) => {
|
|
99
|
+
try {
|
|
100
|
+
await handler(req, res)
|
|
101
|
+
} catch (error) {
|
|
102
|
+
log?.warn?.(`[publisher] 路由异常:${messageOf(error)}`)
|
|
103
|
+
if (!res.headersSent) sendJson(res, 500, { ok: false, error: 'internal', message: messageOf(error) })
|
|
104
|
+
else res.end()
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
handlers: {
|
|
110
|
+
health: guard(async (req, res) => {
|
|
111
|
+
if (!allow(webServer, req, res, 'GET')) return
|
|
112
|
+
sweep()
|
|
113
|
+
const who = await probeWhoami()
|
|
114
|
+
const orphans = await sweepDisk().catch(() => 0)
|
|
115
|
+
sendJson(res, 200, {
|
|
116
|
+
ok: true,
|
|
117
|
+
contractVersion: '1.0.0',
|
|
118
|
+
packageVersion,
|
|
119
|
+
/* 客户端据此判断宿主是否支持预演:页面可能比宿主新(刷新过浏览器但没重启 DSH)。 */
|
|
120
|
+
features: ['dry-run', 'orphan-sweep'],
|
|
121
|
+
npm: who.ok ? { ok: true, user: who.user } : { ok: false, hint: who.hint },
|
|
122
|
+
pending: stages.size,
|
|
123
|
+
orphans,
|
|
124
|
+
recent,
|
|
125
|
+
})
|
|
126
|
+
}),
|
|
127
|
+
|
|
128
|
+
prepare: guard(async (req, res) => {
|
|
129
|
+
if (!allow(webServer, req, res, 'POST')) return
|
|
130
|
+
/* 每次上传顺带回收过期 staging:用户可能拖进来就关掉页面,从不 discard。 */
|
|
131
|
+
sweep()
|
|
132
|
+
await sweepDisk().catch(() => 0)
|
|
133
|
+
if (publishing) {
|
|
134
|
+
sendJson(res, 200, { ok: false, error: 'busy', message: '上一次发布还没结束,请稍等。' })
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
const buffer = await readBody(req, MAX_ARCHIVE_BYTES)
|
|
139
|
+
if (buffer.length === 0) {
|
|
140
|
+
sendJson(res, 200, { ok: false, error: 'empty', message: '上传的压缩包是空的。' })
|
|
141
|
+
return
|
|
142
|
+
}
|
|
143
|
+
const token = crypto.randomUUID()
|
|
144
|
+
const { stage, preview } = await prepareUpload({ token, buffer, filename: decodeFilename(req) }, { npm, ...cacheOpts })
|
|
145
|
+
stage.token = token
|
|
146
|
+
trimStages()
|
|
147
|
+
stages.set(token, { token, stage, createdAt: Date.now() })
|
|
148
|
+
if (!preview.ok) {
|
|
149
|
+
stages.delete(token)
|
|
150
|
+
cleanupStage(stage)
|
|
151
|
+
sendJson(res, 200, preview)
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
sendJson(res, 200, { ...preview, token })
|
|
155
|
+
} catch (error) {
|
|
156
|
+
if (error && error.code === 'too-large') {
|
|
157
|
+
/* readBody 已经把请求排空,这里只负责把原因回给客户端。 */
|
|
158
|
+
sendJson(res, 200, { ok: false, error: 'too-large', message: messageOf(error) })
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
sendJson(res, 200, { ok: false, error: 'unpack-failed', message: messageOf(error) })
|
|
162
|
+
}
|
|
163
|
+
}),
|
|
164
|
+
|
|
165
|
+
publish: guard(async (req, res) => {
|
|
166
|
+
if (!allow(webServer, req, res, 'POST')) return
|
|
167
|
+
let body
|
|
168
|
+
try {
|
|
169
|
+
body = await readJson(req)
|
|
170
|
+
} catch (error) {
|
|
171
|
+
sendJson(res, 200, { ok: false, error: 'bad-request', message: messageOf(error) })
|
|
172
|
+
return
|
|
173
|
+
}
|
|
174
|
+
if (publishing) {
|
|
175
|
+
sendJson(res, 200, { ok: false, error: 'busy', message: '上一次发布还没结束,请稍等。' })
|
|
176
|
+
return
|
|
177
|
+
}
|
|
178
|
+
const entry = stages.get(String(body.token || ''))
|
|
179
|
+
if (!entry) {
|
|
180
|
+
sendJson(res, 200, { ok: false, error: 'stage-missing', message: '这次预检已经过期,请重新把包拖进来。' })
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
publishing = true
|
|
185
|
+
try {
|
|
186
|
+
const preview = await previewStage(entry.stage, { npm, ...cacheOpts })
|
|
187
|
+
if (!preview.ok) {
|
|
188
|
+
sendJson(res, 200, preview)
|
|
189
|
+
return
|
|
190
|
+
}
|
|
191
|
+
if (preview.blocking.length > 0) {
|
|
192
|
+
sendJson(res, 200, { ok: false, error: 'gate-failed', message: preview.blocking[0], blocking: preview.blocking })
|
|
193
|
+
return
|
|
194
|
+
}
|
|
195
|
+
const version = typeof body.version === 'string' && body.version.trim() ? body.version.trim() : preview.plan.version
|
|
196
|
+
const tag = typeof body.tag === 'string' && body.tag.trim() ? body.tag.trim() : 'latest'
|
|
197
|
+
const dryRun = body.dryRun === true
|
|
198
|
+
const result = await publishStage(entry.stage, { version, tag, dryRun, npm })
|
|
199
|
+
const record = {
|
|
200
|
+
name: preview.name,
|
|
201
|
+
version,
|
|
202
|
+
tag,
|
|
203
|
+
ok: result.ok,
|
|
204
|
+
dryRun,
|
|
205
|
+
message: result.message || '',
|
|
206
|
+
at: new Date().toISOString(),
|
|
207
|
+
url: result.url || '',
|
|
208
|
+
fresh: preview.plan.mode,
|
|
209
|
+
from: preview.version,
|
|
210
|
+
}
|
|
211
|
+
remember(record)
|
|
212
|
+
if (result.ok && !dryRun) {
|
|
213
|
+
stages.delete(entry.token)
|
|
214
|
+
cleanupStage(entry.stage)
|
|
215
|
+
} else if (result.error === 'publish-failed') {
|
|
216
|
+
/* npm 明确拒绝(版本已存在/权限/2FA):staging 留着,改完再试。 */
|
|
217
|
+
log?.warn?.(`[publisher] 拖拽发布失败 ${preview.name}@${version}:${result.message}`)
|
|
218
|
+
}
|
|
219
|
+
sendJson(res, 200, { ...result, name: preview.name, fromVersion: preview.version, mode: preview.plan.mode, latest: preview.latest, dryRun })
|
|
220
|
+
} catch (error) {
|
|
221
|
+
sendJson(res, 200, { ok: false, error: 'publish-failed', message: messageOf(error) })
|
|
222
|
+
} finally {
|
|
223
|
+
publishing = false
|
|
224
|
+
}
|
|
225
|
+
}),
|
|
226
|
+
|
|
227
|
+
discard: guard(async (req, res) => {
|
|
228
|
+
if (!allow(webServer, req, res, 'POST')) return
|
|
229
|
+
let body
|
|
230
|
+
try {
|
|
231
|
+
body = await readJson(req)
|
|
232
|
+
} catch {
|
|
233
|
+
body = {}
|
|
234
|
+
}
|
|
235
|
+
const token = String(body.token || '')
|
|
236
|
+
const entry = stages.get(token)
|
|
237
|
+
if (entry) {
|
|
238
|
+
stages.delete(token)
|
|
239
|
+
cleanupStage(entry.stage)
|
|
240
|
+
}
|
|
241
|
+
sendJson(res, 200, { ok: true, discarded: Boolean(entry) })
|
|
242
|
+
}),
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
/* 插件卸载时把没发出去的 staging 一并回收,别在 %LOCALAPPDATA% 里越堆越多。 */
|
|
246
|
+
dispose: () => {
|
|
247
|
+
for (const [token, entry] of stages) {
|
|
248
|
+
stages.delete(token)
|
|
249
|
+
cleanupStage(entry.stage)
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export { ROUTE_PREFIX }
|
|
256
|
+
|
|
257
|
+
/** 只允许本机页面调用:无 Origin(同源 GET / 服务端)或 loopback / 本 webServer 的 origin。 */
|
|
258
|
+
function allow(webServer, req, res, method) {
|
|
259
|
+
if ((req.method || 'GET').toUpperCase() !== method) {
|
|
260
|
+
sendJson(res, 405, { ok: false, error: 'method-not-allowed', message: `Use ${method}.` })
|
|
261
|
+
return false
|
|
262
|
+
}
|
|
263
|
+
if (!isLocalCaller(webServer, req)) {
|
|
264
|
+
sendJson(res, 403, { ok: false, error: 'forbidden', message: 'Only a local page may publish packages.' })
|
|
265
|
+
return false
|
|
266
|
+
}
|
|
267
|
+
return true
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function isLocalCaller(webServer, req) {
|
|
271
|
+
const origin = req.headers.origin
|
|
272
|
+
if (!origin) return true
|
|
273
|
+
let url
|
|
274
|
+
try {
|
|
275
|
+
url = new URL(origin)
|
|
276
|
+
} catch {
|
|
277
|
+
return false
|
|
278
|
+
}
|
|
279
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') return false
|
|
280
|
+
const host = url.hostname.toLowerCase()
|
|
281
|
+
if (host === 'localhost' || host === '127.0.0.1' || host === '::1' || host === '[::1]') return true
|
|
282
|
+
try {
|
|
283
|
+
return origin === webServer.getOrigin()
|
|
284
|
+
} catch {
|
|
285
|
+
return false
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function decodeFilename(req) {
|
|
290
|
+
const raw = req.headers['x-dsh-filename']
|
|
291
|
+
const value = Array.isArray(raw) ? raw[0] : raw
|
|
292
|
+
if (!value) return 'package.zip'
|
|
293
|
+
try {
|
|
294
|
+
return decodeURIComponent(value)
|
|
295
|
+
} catch {
|
|
296
|
+
return value
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async function readBody(req, limit) {
|
|
301
|
+
const chunks = []
|
|
302
|
+
let total = 0
|
|
303
|
+
let overflow = false
|
|
304
|
+
/* 超限时继续把请求排空再报错:直接抛会被当成连接中断,客户端拿不到可读的原因。 */
|
|
305
|
+
for await (const chunk of req) {
|
|
306
|
+
total += chunk.length
|
|
307
|
+
if (total > limit) {
|
|
308
|
+
overflow = true
|
|
309
|
+
continue
|
|
310
|
+
}
|
|
311
|
+
chunks.push(chunk)
|
|
312
|
+
}
|
|
313
|
+
if (overflow) {
|
|
314
|
+
const error = new Error(`内容超过 ${Math.round(limit / 1024 / 1024)} MB 上限。`)
|
|
315
|
+
error.code = 'too-large'
|
|
316
|
+
throw error
|
|
317
|
+
}
|
|
318
|
+
return Buffer.concat(chunks)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
async function readJson(req) {
|
|
322
|
+
const buffer = await readBody(req, MAX_JSON_BYTES)
|
|
323
|
+
if (buffer.length === 0) return {}
|
|
324
|
+
return JSON.parse(buffer.toString('utf8'))
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function sendJson(res, status, payload) {
|
|
328
|
+
const body = Buffer.from(JSON.stringify(payload), 'utf8')
|
|
329
|
+
res.writeHead(status, {
|
|
330
|
+
'content-type': 'application/json; charset=utf-8',
|
|
331
|
+
'content-length': body.length,
|
|
332
|
+
'cache-control': 'no-store',
|
|
333
|
+
})
|
|
334
|
+
res.end(body)
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function messageOf(error) {
|
|
338
|
+
return error instanceof Error ? error.message : String(error)
|
|
339
|
+
}
|
package/server/tools.mjs
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP 工具面:能力声明 → 注册表 → 工具清单。
|
|
3
|
+
*
|
|
4
|
+
* 发布业务在 impl.mjs;这里只做 schema/分派。
|
|
5
|
+
* publisher_execute 是不可撤销动作:schema 强制 confirm: true。
|
|
6
|
+
*/
|
|
7
|
+
import fs from 'node:fs'
|
|
8
|
+
import path from 'node:path'
|
|
9
|
+
import { fileURLToPath } from 'node:url'
|
|
10
|
+
import {
|
|
11
|
+
defineTool, defineCapability, createRegistry, createMcpHandler,
|
|
12
|
+
createCapabilityReport, buildInstructions,
|
|
13
|
+
} from '@capyclaw/tool-host/src'
|
|
14
|
+
import { npmWhoami, runPublish, capabilities as capabilitiesImpl } from './impl.mjs'
|
|
15
|
+
|
|
16
|
+
export const contractVersion = '1.0.0'
|
|
17
|
+
|
|
18
|
+
const HERE = path.dirname(fileURLToPath(import.meta.url))
|
|
19
|
+
const PKG = JSON.parse(fs.readFileSync(path.join(HERE, '..', 'package.json'), 'utf8'))
|
|
20
|
+
|
|
21
|
+
const text = (value) => ({ content: [{ type: 'text', text: JSON.stringify(value, null, 2) }] })
|
|
22
|
+
|
|
23
|
+
const rootSchema = {
|
|
24
|
+
type: 'string',
|
|
25
|
+
maxLength: 500,
|
|
26
|
+
description: '插件工程工作区路径(要发布的仓库 checkout)。缺省用 DSH_PUBLISHER_ROOT。',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const whoamiTool = defineTool({
|
|
30
|
+
name: 'publisher_whoami',
|
|
31
|
+
description: 'npm 凭据预检:宿主环境是否已登录(npm whoami / NODE_AUTH_TOKEN)。发布前先调用。',
|
|
32
|
+
inputSchema: { type: 'object', additionalProperties: false, properties: {} },
|
|
33
|
+
kind: 'read',
|
|
34
|
+
handler: () => text(npmWhoami()),
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const previewTool = defineTool({
|
|
38
|
+
name: 'publisher_preview',
|
|
39
|
+
description: '发布预演(dry-run):发现集 → 发布闸/pack 闸 → 已发布与同版本漂移 → 依赖顺序闸,返回逐包结果与汇总。不真发布。',
|
|
40
|
+
inputSchema: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
additionalProperties: false,
|
|
43
|
+
properties: {
|
|
44
|
+
root: rootSchema,
|
|
45
|
+
only: { type: 'string', maxLength: 100, description: '只处理这个包名(@capyclaw/xxx)' },
|
|
46
|
+
skipTests: { type: 'boolean', description: '跳过各包 npm test(默认不跳,与原流水线一致)' },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
kind: 'read',
|
|
50
|
+
handler: (args) => runPublish({ ...args, dryRun: true }).then(text),
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const executeTool = defineTool({
|
|
54
|
+
name: 'publisher_execute',
|
|
55
|
+
description: '真发布到 npm(不可撤销)。必须显式传 confirm: true。流程与 preview 相同,过闸后逐包 npm publish 并做发布后 shasum 复核。',
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
additionalProperties: false,
|
|
59
|
+
properties: {
|
|
60
|
+
root: rootSchema,
|
|
61
|
+
only: { type: 'string', maxLength: 100, description: '只发布这个包名(@capyclaw/xxx)' },
|
|
62
|
+
tag: { type: 'string', maxLength: 20, description: 'dist-tag(默认 latest)' },
|
|
63
|
+
skipTests: { type: 'boolean', description: '跳过各包 npm test' },
|
|
64
|
+
confirm: { type: 'boolean', description: '必须为 true 才执行' },
|
|
65
|
+
},
|
|
66
|
+
required: ['confirm'],
|
|
67
|
+
},
|
|
68
|
+
kind: 'control',
|
|
69
|
+
handler: (args) => {
|
|
70
|
+
if (args.confirm !== true) {
|
|
71
|
+
return text({ ok: false, error: '发布是不可撤销动作:需要显式传 confirm: true(建议先跑 publisher_preview 核对批次)' })
|
|
72
|
+
}
|
|
73
|
+
return runPublish({ ...args, dryRun: false }).then(text)
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const capabilitiesTool = defineTool({
|
|
78
|
+
name: 'publisher_capabilities',
|
|
79
|
+
description: '返回契约版本、工具清单和能力说明。',
|
|
80
|
+
inputSchema: { type: 'object', additionalProperties: false, properties: {} },
|
|
81
|
+
kind: 'read',
|
|
82
|
+
handler: () => text({ ...capabilitiesImpl(), name: PKG.name, version: PKG.version }),
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
const capability = defineCapability({
|
|
86
|
+
id: 'publisher',
|
|
87
|
+
title: 'npm 发布器',
|
|
88
|
+
description: '在 dsh 内发布 capyclaw 插件工程:预演(闸门/顺序/漂移)与真发布(需显式 confirm)。',
|
|
89
|
+
tags: ['tool'],
|
|
90
|
+
tools: [whoamiTool, previewTool, executeTool, capabilitiesTool],
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
export const registry = createRegistry([capability], {
|
|
94
|
+
report: ({ editorUrl = '', runtime = {}, ...rest }) => createCapabilityReport({
|
|
95
|
+
...rest,
|
|
96
|
+
contractVersion,
|
|
97
|
+
packageVersion: PKG.version,
|
|
98
|
+
editorUrl,
|
|
99
|
+
runtime,
|
|
100
|
+
}),
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
export const tools = registry.TOOLS
|
|
104
|
+
export const callTool = (name, args) => registry.TOOL_IMPL[name]?.(args)
|
|
105
|
+
export function capabilities() { return registry.ctx.contract.report() }
|
|
106
|
+
|
|
107
|
+
export function createMcp(serverInfo, instructions) {
|
|
108
|
+
return createMcpHandler({ registry, serverInfo, instructions })
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { buildInstructions }
|