@kafukatree/dsh-skill-manager 0.0.0-stage → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSE-lucide.txt +43 -0
- package/README.md +44 -2
- package/agent-tool.mjs +118 -0
- package/client-bridge.mjs +307 -0
- package/client-entry.mjs +131 -0
- package/client.js +6769 -0
- package/control-icon.mjs +40 -0
- package/cordis.patch.yml +4 -0
- package/design/skill-manager.pen +798 -0
- package/design.css +320 -0
- package/design.mjs +629 -0
- package/dialogs.css +460 -0
- package/dialogs.mjs +1130 -0
- package/document-link.mjs +13 -0
- package/file-actions.mjs +62 -0
- package/file-view.mjs +384 -0
- package/header-scroll.css +90 -0
- package/header-scroll.mjs +121 -0
- package/host.mjs +460 -0
- package/icon.svg +6 -0
- package/import-archive.mjs +41 -0
- package/import-commit.mjs +247 -0
- package/import-family.mjs +213 -0
- package/import-files.mjs +186 -0
- package/import-github.mjs +168 -0
- package/import-limits.mjs +10 -0
- package/import-native.mjs +79 -0
- package/imports.mjs +209 -0
- package/inventory.mjs +62 -0
- package/library.mjs +1334 -0
- package/local-families.mjs +277 -0
- package/locale/en.json +16 -0
- package/locale/zh.json +16 -0
- package/management-view.mjs +158 -0
- package/mode-view.mjs +72 -0
- package/node_modules/pend/LICENSE +23 -0
- package/node_modules/pend/README.md +41 -0
- package/node_modules/pend/index.js +55 -0
- package/node_modules/pend/package.json +18 -0
- package/node_modules/pend/test.js +137 -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/node_modules/yauzl/LICENSE +21 -0
- package/node_modules/yauzl/README.md +1015 -0
- package/node_modules/yauzl/crc32.js +45 -0
- package/node_modules/yauzl/fd-slicer.js +188 -0
- package/node_modules/yauzl/index.js +1096 -0
- package/node_modules/yauzl/package.json +40 -0
- package/package-files.mjs +244 -0
- package/package-view.mjs +375 -0
- package/package.css +131 -0
- package/package.json +75 -4
- package/removal.mjs +313 -0
- package/scripts/build.mjs +19 -0
- package/scripts/export-design.py +587 -0
- package/scripts/run-tests.mjs +14 -0
- package/skill-state.mjs +136 -0
- package/skills/skill-creator/SKILL.md +48 -0
- package/styles.mjs +10 -0
- package/surfaces.css +593 -0
- package/test/agent-tool.test.mjs +153 -0
- package/test/client-bridge.test.mjs +240 -0
- package/test/distribution.test.mjs +17 -0
- package/test/host.test.mjs +598 -0
- package/test/imports.test.mjs +491 -0
- package/test/inventory.test.mjs +144 -0
- package/test/library.test.mjs +785 -0
- package/test/local-families.test.mjs +220 -0
- package/test/management-view.test.mjs +102 -0
- package/test/mode-view.test.mjs +26 -0
- package/test/package-files.test.mjs +221 -0
- package/toolbar.css +228 -0
- package/typography.css +173 -0
- package/ui.css +399 -0
- package/ui.mjs +1545 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KafukaTree
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lucide Icons and Contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
The following Lucide icons are derived from the Feather project:
|
|
20
|
+
|
|
21
|
+
airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
|
|
22
|
+
|
|
23
|
+
The MIT License (MIT) (for the icons listed above)
|
|
24
|
+
|
|
25
|
+
Copyright (c) 2013-present Cole Bemis
|
|
26
|
+
|
|
27
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
28
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
29
|
+
in the Software without restriction, including without limitation the rights
|
|
30
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
31
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
32
|
+
furnished to do so, subject to the following conditions:
|
|
33
|
+
|
|
34
|
+
The above copyright notice and this permission notice shall be included in all
|
|
35
|
+
copies or substantial portions of the Software.
|
|
36
|
+
|
|
37
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
38
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
39
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
40
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
41
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
42
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
43
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
<img src="https://raw.githubusercontent.com/KafukaTree/dsh-skill-manager/v0.3.1/icon.svg" alt="" width="80" height="80">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# DSH 技能管理器
|
|
4
|
+
|
|
5
|
+
在 DeepSeek Harness 侧栏集中查看 Agent 技能。选一个工作区和模式,就能看到该模式可用的技能、每项技能来自哪里,以及能用斜杠手动调用还是由 Agent 自动调用。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
打开 DSH 的「插件」→「添加插件」,输入完整的 npm 包名,然后安装。已在 DSH 桌面版 `0.2.3-alpha.3` 验证。
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
@kafukatree/dsh-skill-manager
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
需要单独的安装包时,从 GitHub Releases 下载 `.tgz`,在 DSH 中用文件的本地路径安装。安装成功后,从侧栏打开「技能管理器」。[npm 包](https://www.npmjs.com/package/@kafukatree/dsh-skill-manager) · [下载安装包](https://github.com/KafukaTree/dsh-skill-manager/releases/latest)
|
|
16
|
+
|
|
17
|
+
## 使用
|
|
18
|
+
|
|
19
|
+
- **查找技能** 按工作区和模式筛选,搜索技能名称,打开详情阅读说明及随附文件。项目技能会随工作区切换,个人技能可以跨项目复用。
|
|
20
|
+
- **导入技能** 展开「添加技能」旁的箭头,可以选本地 Markdown、技能目录或压缩包,也可以从 Claude Code、Codex、Gemini CLI 或公开 GitHub 仓库导入。核对预览后,选择保存位置。
|
|
21
|
+
- **创建技能** 选择「让 Agent 创建技能」,会打开所选工作区的新会话。输入框已填入 `/skill-creator 帮我创建一个技能,需求是:`,在冒号后写下需求并发送。默认在当前项目创建,也可以明确要求保存为个人技能。
|
|
22
|
+
- **管理自己的技能** 可以管理技能目录、调整调用方式,或在删除后恢复自己的技能和工具包。
|
|
23
|
+
|
|
24
|
+
## 本地开发
|
|
25
|
+
|
|
26
|
+
使用 Node.js 22.19 或更高版本。在仓库根目录执行下面两条命令即可构建浏览器端。安装包包含编译好的客户端。
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
npm ci
|
|
30
|
+
npm run build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
在 DSH 工作区中运行 `npm test`,集成测试会使用本机安装的 DSH Host 库。
|
|
34
|
+
|
|
35
|
+
常规构建直接使用仓库中的设计资源。如果修改了[界面画板](./design/skill-manager.pen),请使用 Python 3.10+ 和 Pen CLI(已验证 0.3.17)重新导出并核对结果。将 `pen` 加入 `PATH`,或用 `PENX_PEN_CLI` 指定本机可执行文件。
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
python3 scripts/export-design.py
|
|
39
|
+
npm run design:check
|
|
40
|
+
npm run build
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 许可
|
|
44
|
+
|
|
45
|
+
插件源码和原创黑白标志采用 MIT 许可证。界面控件使用 Lucide 图标,相关版权和许可随包分发。[MIT](./LICENSE) · [Lucide 与 Feather](./LICENSE-lucide.txt)
|
package/agent-tool.mjs
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { hostRequire } from './library.mjs'
|
|
2
|
+
|
|
3
|
+
const { defineTool, ToolArgsError } = hostRequire('@deepseek-ai/dsh-tools')
|
|
4
|
+
const pageSize = 20
|
|
5
|
+
const descriptionLimit = 320
|
|
6
|
+
|
|
7
|
+
function requireCurrentAgent(ctx, exec) {
|
|
8
|
+
exec.signal.throwIfAborted()
|
|
9
|
+
const agent = exec.agent
|
|
10
|
+
if (!agent?.session || ctx.agents.get(agent.id) !== agent) {
|
|
11
|
+
throw new Error('技能查询需要当前正在运行的 Agent。')
|
|
12
|
+
}
|
|
13
|
+
return agent
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Only the native catalog on the *current model surface* is an input. Old
|
|
17
|
+
// catalog messages removed by compaction and text in ordinary messages are not.
|
|
18
|
+
function publishedCatalog(session) {
|
|
19
|
+
const message = session.deriveMessages().findLast(message =>
|
|
20
|
+
message.role === 'user' && message.source?.kind === 'skill-catalog')
|
|
21
|
+
const source = message?.source
|
|
22
|
+
if (source?.form !== 'catalog' || !Array.isArray(source.entries)) return undefined
|
|
23
|
+
return source
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// The native catalog normalizes whitespace and may replace a suffix with three
|
|
27
|
+
// dots. A changed description becomes eligible when the Agent sees it published.
|
|
28
|
+
function matchesPublished(current, published) {
|
|
29
|
+
if (typeof current !== 'string' || typeof published !== 'string') return false
|
|
30
|
+
const normalized = current.replaceAll(/\s+/g, ' ').trim()
|
|
31
|
+
return normalized === published || (published.endsWith('...') && normalized.length > published.length
|
|
32
|
+
&& normalized.startsWith(published.slice(0, -3)))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function catalogPage(snapshot, published, query, offset) {
|
|
36
|
+
const current = new Map(snapshot.skills.map(skill => [skill.name, skill.description]))
|
|
37
|
+
const visible = new Set()
|
|
38
|
+
const skills = []
|
|
39
|
+
let total = 0
|
|
40
|
+
for (const entry of published?.entries ?? []) {
|
|
41
|
+
if (typeof entry?.name !== 'string' || visible.has(entry.name)
|
|
42
|
+
|| !matchesPublished(current.get(entry.name), entry.description)) continue
|
|
43
|
+
visible.add(entry.name)
|
|
44
|
+
// Reuse the published description. The model's preset may truncate it more
|
|
45
|
+
// strictly than the source provider, and searches must honor that limit too.
|
|
46
|
+
if (!entry.name.toLowerCase().includes(query) && !entry.description.toLowerCase().includes(query)) continue
|
|
47
|
+
total += 1
|
|
48
|
+
if (total <= offset || skills.length === pageSize) continue
|
|
49
|
+
const description = entry.description.length > descriptionLimit
|
|
50
|
+
? `${entry.description.slice(0, descriptionLimit - 1)}…` : entry.description
|
|
51
|
+
skills.push({ name: entry.name, description })
|
|
52
|
+
}
|
|
53
|
+
const nextOffset = offset + pageSize
|
|
54
|
+
return {
|
|
55
|
+
skills,
|
|
56
|
+
total,
|
|
57
|
+
...(nextOffset < total ? { nextOffset } : {}),
|
|
58
|
+
complete: snapshot.complete === true && published?.incomplete !== true && visible.size === current.size,
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function registerAgentTool(ctx, library) {
|
|
63
|
+
const tool = defineTool({
|
|
64
|
+
name: 'skill_manager',
|
|
65
|
+
description: '查询当前会话已公开的技能名称和简介,或刷新目录。读取技能说明使用原生 skill 工具。',
|
|
66
|
+
parameters: {
|
|
67
|
+
action: { type: 'string', enum: ['list', 'refresh'], required: true },
|
|
68
|
+
query: { type: 'string', description: '按名称或简介筛选,最多 160 个字符。' },
|
|
69
|
+
offset: { type: 'integer', description: '续页时使用上次返回的 nextOffset。' },
|
|
70
|
+
},
|
|
71
|
+
output: {
|
|
72
|
+
schema: {
|
|
73
|
+
type: 'object', additionalProperties: false,
|
|
74
|
+
properties: {
|
|
75
|
+
skills: { type: 'array', required: true, items: {
|
|
76
|
+
type: 'object', additionalProperties: false,
|
|
77
|
+
properties: { name: { type: 'string', required: true }, description: { type: 'string', required: true } },
|
|
78
|
+
} },
|
|
79
|
+
total: { type: 'integer', required: true },
|
|
80
|
+
nextOffset: { type: 'integer' },
|
|
81
|
+
complete: { type: 'boolean', required: true, description: '为 false 时,目录仍在发现或等待会话发布更新。' },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
render: (_args, value) => [{ type: 'text', text: JSON.stringify(value) }],
|
|
85
|
+
},
|
|
86
|
+
async execute({ action, query = '', offset = 0, ...other }, exec) {
|
|
87
|
+
if (Object.keys(other).length) throw new ToolArgsError(['仅支持 action、query 和 offset。'])
|
|
88
|
+
if (query.length > 160 || !Number.isSafeInteger(offset) || offset < 0) {
|
|
89
|
+
throw new ToolArgsError(['筛选文字最多 160 个字符,续页位置须为非负安全整数。'])
|
|
90
|
+
}
|
|
91
|
+
const agent = requireCurrentAgent(ctx, exec)
|
|
92
|
+
const { signal } = exec
|
|
93
|
+
// A program-only root exposes its entry instead of its bindings here.
|
|
94
|
+
// Nesting alone does not prove that the calling step can use `skill`.
|
|
95
|
+
const skill = ctx.tools.get('skill', agent)
|
|
96
|
+
const checkScope = () => {
|
|
97
|
+
requireCurrentAgent(ctx, exec)
|
|
98
|
+
if (!skill || ctx.tools.get('skill', agent) !== skill || (exec.toolStep && !exec.toolStep.declares(skill))) {
|
|
99
|
+
throw new Error('当前会话未提供原生技能工具。')
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
checkScope()
|
|
103
|
+
let cwd, snapshot
|
|
104
|
+
try {
|
|
105
|
+
cwd = await ctx.workingDirectory.ensure(agent, signal)
|
|
106
|
+
checkScope()
|
|
107
|
+
snapshot = await library.modelCatalog(cwd, agent, { refresh: action === 'refresh', signal })
|
|
108
|
+
} catch (error) {
|
|
109
|
+
signal.throwIfAborted()
|
|
110
|
+
throw new Error('当前会话的技能目录暂时无法读取,请重新查询。', { cause: error })
|
|
111
|
+
}
|
|
112
|
+
checkScope()
|
|
113
|
+
if (ctx.workingDirectory.get(agent.session) !== cwd) throw new Error('会话工作目录已改变,请重新查询。')
|
|
114
|
+
return catalogPage(snapshot, publishedCatalog(agent.session), query.trim().toLowerCase(), offset)
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
return ctx.tools.register({ ...tool, parameters: { ...tool.parameters, additionalProperties: false } })
|
|
118
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { limits } from './import-limits.mjs'
|
|
2
|
+
|
|
3
|
+
const channel = '/dsh-skill-manager'
|
|
4
|
+
const mib = 1024 * 1024
|
|
5
|
+
const creatorDraft = '/skill-creator 帮我创建一个技能,需求是:'
|
|
6
|
+
|
|
7
|
+
function failure(code, message, details = {}) {
|
|
8
|
+
return Object.assign(new Error(message), { code, details })
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function unwrap(result) {
|
|
12
|
+
if (result?.ok === true) return result.value
|
|
13
|
+
const error = result?.error
|
|
14
|
+
throw failure(error?.code || 'INVALID_RESPONSE', error?.message || '技能管理器收到了无效的响应。', error?.details)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function chooseFile(container, signal) {
|
|
18
|
+
if (signal.aborted) return Promise.resolve(null)
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const input = container.ownerDocument.createElement('input')
|
|
21
|
+
input.type = 'file'
|
|
22
|
+
input.accept = '.md,.skill,.zip'
|
|
23
|
+
input.hidden = true
|
|
24
|
+
const cleanup = () => {
|
|
25
|
+
input.remove()
|
|
26
|
+
signal.removeEventListener('abort', cancel)
|
|
27
|
+
}
|
|
28
|
+
const finish = file => { cleanup(); resolve(file) }
|
|
29
|
+
const cancel = () => finish(null)
|
|
30
|
+
input.onchange = () => finish(input.files?.[0] ?? null)
|
|
31
|
+
input.oncancel = cancel
|
|
32
|
+
signal.addEventListener('abort', cancel, { once: true })
|
|
33
|
+
container.append(input)
|
|
34
|
+
try {
|
|
35
|
+
input.click()
|
|
36
|
+
} catch (error) {
|
|
37
|
+
cleanup()
|
|
38
|
+
reject(error)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function fileCollection() {
|
|
44
|
+
const files = []
|
|
45
|
+
let bytes = 0
|
|
46
|
+
return {
|
|
47
|
+
files,
|
|
48
|
+
add(file, path) {
|
|
49
|
+
const archive = !path.includes('/') && /\.(?:zip|skill)$/i.test(file.name)
|
|
50
|
+
const limit = archive ? limits.archive : limits.file
|
|
51
|
+
if (file.size > limit) throw failure('UPLOAD_LIMIT', `“${file.name}”超过 ${limit / mib} MiB 的上传上限。`)
|
|
52
|
+
bytes += file.size
|
|
53
|
+
if (files.length >= limits.entries || bytes > limits.bundle) {
|
|
54
|
+
throw failure('UPLOAD_LIMIT', `一次最多上传 ${limits.entries} 个文件,总大小上限为 ${limits.bundle / mib} MiB。`)
|
|
55
|
+
}
|
|
56
|
+
files.push({ file, path })
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function collectEntry(entry, parent, collection, signal) {
|
|
62
|
+
signal.throwIfAborted()
|
|
63
|
+
const path = parent ? `${parent}/${entry.name}` : entry.name
|
|
64
|
+
if (entry.isFile) {
|
|
65
|
+
const file = await new Promise((resolve, reject) => entry.file(resolve, reject))
|
|
66
|
+
collection.add(file, path)
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
const reader = entry.createReader()
|
|
70
|
+
// A reader can return several batches for a single directory. Only the
|
|
71
|
+
// final empty batch signals that all of its children have been enumerated.
|
|
72
|
+
while (true) {
|
|
73
|
+
signal.throwIfAborted()
|
|
74
|
+
const batch = await new Promise((resolve, reject) => reader.readEntries(resolve, reject))
|
|
75
|
+
if (!batch.length) return
|
|
76
|
+
for (const child of batch) await collectEntry(child, path, collection, signal)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function collectHandle(handle, parent, collection, signal) {
|
|
81
|
+
signal.throwIfAborted()
|
|
82
|
+
const path = parent ? `${parent}/${handle.name}` : handle.name
|
|
83
|
+
if (handle.kind === 'file') {
|
|
84
|
+
collection.add(await handle.getFile(), path)
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
for await (const child of handle.values()) await collectHandle(child, path, collection, signal)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function collectDrop(transfer, signal) {
|
|
91
|
+
// The drag data store is protected after the drop event returns. Capture
|
|
92
|
+
// every entry, handle promise and File synchronously before the first await.
|
|
93
|
+
const fallback = Array.from(transfer.files || [])
|
|
94
|
+
const roots = Array.from(transfer.items || []).filter(item => item.kind === 'file').map(item => {
|
|
95
|
+
const entry = item.webkitGetAsEntry?.()
|
|
96
|
+
const handle = !entry && item.getAsFileSystemHandle?.().catch(() => null)
|
|
97
|
+
return { entry, handle, file: item.getAsFile?.() }
|
|
98
|
+
})
|
|
99
|
+
const collection = fileCollection()
|
|
100
|
+
if (!roots.length) {
|
|
101
|
+
for (const file of fallback) collection.add(file, file.webkitRelativePath || file.name)
|
|
102
|
+
} else {
|
|
103
|
+
for (const [index, root] of roots.entries()) {
|
|
104
|
+
if (root.entry) {
|
|
105
|
+
await collectEntry(root.entry, '', collection, signal)
|
|
106
|
+
continue
|
|
107
|
+
}
|
|
108
|
+
const handle = await root.handle
|
|
109
|
+
if (handle) {
|
|
110
|
+
await collectHandle(handle, '', collection, signal)
|
|
111
|
+
continue
|
|
112
|
+
}
|
|
113
|
+
const file = root.file || fallback[index]
|
|
114
|
+
if (!file) throw failure('UNREADABLE_SOURCE', '无法读取拖入的项目,请用文件或文件夹选择器打开。')
|
|
115
|
+
collection.add(file, file.webkitRelativePath || file.name)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (!collection.files.length) throw failure('EMPTY_SOURCE', '请拖入技能文档、压缩包或包含 SKILL.md 的文件夹。')
|
|
119
|
+
return collection.files
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async function fileBase64(file) {
|
|
123
|
+
const bytes = new Uint8Array(await file.arrayBuffer())
|
|
124
|
+
if (typeof bytes.toBase64 === 'function') return bytes.toBase64()
|
|
125
|
+
const chunks = []
|
|
126
|
+
for (let offset = 0; offset < bytes.length; offset += 32768) {
|
|
127
|
+
chunks.push(String.fromCharCode(...bytes.subarray(offset, offset + 32768)))
|
|
128
|
+
}
|
|
129
|
+
return btoa(chunks.join(''))
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function sourceFields(source) {
|
|
133
|
+
const { type, id } = source
|
|
134
|
+
const candidate = id ? { id } : {}
|
|
135
|
+
if (type === 'upload' || (type === 'local' && source.uploadId)) return { type: 'local', uploadId: source.uploadId }
|
|
136
|
+
if (type === 'local') return { type, path: source.path }
|
|
137
|
+
if (type === 'github') return { type, url: source.url, ...candidate }
|
|
138
|
+
if (type === 'tool') return { type, tool: source.tool, scope: source.scope, ...candidate }
|
|
139
|
+
throw failure('INVALID_SOURCE', '请选择有效的技能来源。')
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Bind every request and staged resource to this management view. */
|
|
143
|
+
export function createManagerApi(ctx, selection, container, signal) {
|
|
144
|
+
const context = {}
|
|
145
|
+
if (selection.workspaceId) context.workspaceId = selection.workspaceId
|
|
146
|
+
if (selection.presetId) context.presetId = selection.presetId
|
|
147
|
+
const uploads = new Set()
|
|
148
|
+
const previews = new Set()
|
|
149
|
+
const committing = new Set()
|
|
150
|
+
let creating = null
|
|
151
|
+
let attempt = null
|
|
152
|
+
|
|
153
|
+
const call = async (operation, params = {}, cancellable = true, requestSignal = signal) => {
|
|
154
|
+
if (cancellable) requestSignal.throwIfAborted()
|
|
155
|
+
let result
|
|
156
|
+
try {
|
|
157
|
+
result = await ctx.connection.rpc.call(channel, operation, { ...params, ...context }, cancellable ? requestSignal : undefined)
|
|
158
|
+
} catch (error) {
|
|
159
|
+
if (error?.name === 'AbortError') throw error
|
|
160
|
+
throw failure('CONNECTION_FAILED', '无法连接到技能管理器,请检查 DSH 连接后重试。')
|
|
161
|
+
}
|
|
162
|
+
return unwrap(result)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const cancel = async value => {
|
|
166
|
+
const token = typeof value === 'string' ? value : value?.token
|
|
167
|
+
if (token && !committing.has(token) && previews.delete(token)) {
|
|
168
|
+
await call('cancel', { token }, false)
|
|
169
|
+
} else if (value?.uploadId && uploads.delete(value.uploadId)) {
|
|
170
|
+
await call('cancel', { uploadId: value.uploadId }, false)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const release = resource => { void cancel(resource).catch(() => {}) }
|
|
174
|
+
signal.addEventListener('abort', () => {
|
|
175
|
+
for (const uploadId of uploads) release({ uploadId })
|
|
176
|
+
for (const token of previews) release({ token })
|
|
177
|
+
}, { once: true })
|
|
178
|
+
|
|
179
|
+
async function upload(selected) {
|
|
180
|
+
const files = []
|
|
181
|
+
for (const { path, file } of selected) {
|
|
182
|
+
signal.throwIfAborted()
|
|
183
|
+
files.push({ path, base64: await fileBase64(file) })
|
|
184
|
+
}
|
|
185
|
+
signal.throwIfAborted()
|
|
186
|
+
const { uploadId } = await call('upload', { files }, false)
|
|
187
|
+
uploads.add(uploadId)
|
|
188
|
+
if (signal.aborted) { release({ uploadId }); signal.throwIfAborted() }
|
|
189
|
+
return { type: 'upload', uploadId, name: selected[0].path.split('/')[0] }
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async function preview(source) {
|
|
193
|
+
signal.throwIfAborted()
|
|
194
|
+
const result = await call('preview', sourceFields(source), false)
|
|
195
|
+
previews.add(result.token)
|
|
196
|
+
if (signal.aborted) { release({ token: result.token }); signal.throwIfAborted() }
|
|
197
|
+
return result
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async function commit({ token, directoryId, enabled, conflict }) {
|
|
201
|
+
signal.throwIfAborted()
|
|
202
|
+
if (committing.has(token)) throw failure('IMPORT_IN_PROGRESS', '正在导入这个技能。')
|
|
203
|
+
committing.add(token)
|
|
204
|
+
try {
|
|
205
|
+
const result = await call('commit', { token, directoryId, ...(enabled === undefined ? {} : { enabled }), ...(conflict ? { conflict } : {}) }, false)
|
|
206
|
+
previews.delete(token)
|
|
207
|
+
return result
|
|
208
|
+
} finally {
|
|
209
|
+
committing.delete(token)
|
|
210
|
+
if (signal.aborted) release({ token })
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async function openCreatorDraft() {
|
|
215
|
+
signal.throwIfAborted()
|
|
216
|
+
const navigation = AbortSignal.any([signal, ctx.layout.beginNavigation()])
|
|
217
|
+
try {
|
|
218
|
+
const input = ctx.conversation.input
|
|
219
|
+
if (!attempt) {
|
|
220
|
+
const { workspaceId, cwd, agentPreset } = await call('prepareCreator', {}, true, navigation)
|
|
221
|
+
navigation.throwIfAborted()
|
|
222
|
+
if ((context.workspaceId && workspaceId !== context.workspaceId) || (!workspaceId && !cwd) || !agentPreset) {
|
|
223
|
+
throw failure('UNKNOWN_TARGET', '无法确定技能创建会话的工作目录或模式。')
|
|
224
|
+
}
|
|
225
|
+
// No named blank, so existing conversations and drafts cannot be reused.
|
|
226
|
+
const sessionId = await ctx.sessions.create({ ...(workspaceId ? { workspaceId } : { cwd }), agentPreset })
|
|
227
|
+
// Once the Host returns an ID, a failed handoff can retry it instead of creating another blank.
|
|
228
|
+
attempt = { sessionId, initialized: false }
|
|
229
|
+
}
|
|
230
|
+
navigation.throwIfAborted()
|
|
231
|
+
const current = attempt
|
|
232
|
+
const reference = ctx.sessions.retain(current.sessionId, { source: 'controllerOperation' })
|
|
233
|
+
try {
|
|
234
|
+
if (!current.initialized) {
|
|
235
|
+
const result = input.requestDraftInitialization(reference.binding, { prompt: creatorDraft, whenDraftExists: 'keep' })
|
|
236
|
+
if (result !== 'applied') throw failure('DRAFT_UNAVAILABLE', '未能预填技能创建草稿,请重试。')
|
|
237
|
+
current.initialized = true
|
|
238
|
+
}
|
|
239
|
+
// The Conversation view takes its own reference and focuses the editor on desktop.
|
|
240
|
+
navigation.throwIfAborted()
|
|
241
|
+
ctx.uiWorkspace.openSession(current.sessionId)
|
|
242
|
+
} finally {
|
|
243
|
+
reference.release()
|
|
244
|
+
}
|
|
245
|
+
attempt = null
|
|
246
|
+
} catch (error) {
|
|
247
|
+
if (navigation.aborted) navigation.throwIfAborted()
|
|
248
|
+
throw error
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
list: () => call('list'),
|
|
254
|
+
refresh: () => call('refresh'),
|
|
255
|
+
detail: id => call('detail', { id }),
|
|
256
|
+
packageEntries: (id, path = '', offset = 0) => call('packageEntries', { id, path, offset }),
|
|
257
|
+
packageFile: (id, path) => call('packageFile', { id, path }),
|
|
258
|
+
skillEntries: (id, path = '', offset = 0) => call('skillEntries', { id, path, offset }),
|
|
259
|
+
skillFile: (id, path) => call('skillFile', { id, path }),
|
|
260
|
+
setPackageEnabled: (id, enabled) => call('setPackageEnabled', { id, enabled }),
|
|
261
|
+
setEnabled: (id, enabled) => call('setEnabled', { id, enabled }),
|
|
262
|
+
prepareRemoval: async (kind, id) => {
|
|
263
|
+
const plan = await call('prepareRemoval', { kind, id })
|
|
264
|
+
signal.throwIfAborted()
|
|
265
|
+
return plan
|
|
266
|
+
},
|
|
267
|
+
commitRemoval: token => {
|
|
268
|
+
signal.throwIfAborted()
|
|
269
|
+
return call('commitRemoval', { token }, false)
|
|
270
|
+
},
|
|
271
|
+
listRemovals: () => call('listRemovals'),
|
|
272
|
+
restoreRemoval: id => {
|
|
273
|
+
signal.throwIfAborted()
|
|
274
|
+
return call('restoreRemoval', { id }, false)
|
|
275
|
+
},
|
|
276
|
+
addDirectory: (path, label) => call('addDirectory', { path, ...(label ? { label } : {}) }),
|
|
277
|
+
removeDirectory: id => call('removeDirectory', { id }),
|
|
278
|
+
openOptions: id => call('openOptions', { id }),
|
|
279
|
+
openItem: (id, kind, applicationId) => call('openItem', { id, kind, ...(applicationId === undefined ? {} : { applicationId }) }),
|
|
280
|
+
candidates: source => call('candidates', sourceFields(source)),
|
|
281
|
+
preview, commit, cancel,
|
|
282
|
+
async pick(kind) {
|
|
283
|
+
signal.throwIfAborted()
|
|
284
|
+
if (kind === 'directory') {
|
|
285
|
+
const path = await ctx.uiWorkspace.pickDirectory()
|
|
286
|
+
return signal.aborted ? null : path
|
|
287
|
+
}
|
|
288
|
+
if (kind !== 'file') throw failure('INVALID_SOURCE', '请选择文件或文件夹。')
|
|
289
|
+
const file = await chooseFile(container, signal)
|
|
290
|
+
if (!file) return null
|
|
291
|
+
const collection = fileCollection()
|
|
292
|
+
collection.add(file, file.name)
|
|
293
|
+
return upload(collection.files)
|
|
294
|
+
},
|
|
295
|
+
async dropped(transfer) {
|
|
296
|
+
return upload(await collectDrop(transfer, signal))
|
|
297
|
+
},
|
|
298
|
+
openCreatorDraft() {
|
|
299
|
+
// Success hands off the panel, so wait for unmount even if another click was queued.
|
|
300
|
+
creating ??= openCreatorDraft().catch(error => {
|
|
301
|
+
creating = null
|
|
302
|
+
throw error
|
|
303
|
+
})
|
|
304
|
+
return creating
|
|
305
|
+
},
|
|
306
|
+
}
|
|
307
|
+
}
|
package/client-entry.mjs
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { createManagerApi } from './client-bridge.mjs'
|
|
2
|
+
import { packageDocumentLink } from './document-link.mjs'
|
|
3
|
+
import brandIcon from './icon.svg'
|
|
4
|
+
import { workspaceProjection } from './mode-view.mjs'
|
|
5
|
+
import { stylesheet } from './styles.mjs'
|
|
6
|
+
import { mountManager } from './ui.mjs'
|
|
7
|
+
import { name as packageName } from './package.json'
|
|
8
|
+
import zh from './locale/zh.json'
|
|
9
|
+
import en from './locale/en.json'
|
|
10
|
+
|
|
11
|
+
const panelId = 'dsh-skill-manager'
|
|
12
|
+
|
|
13
|
+
// Preserve a skill's source metadata without letting the closing YAML marker become a Markdown heading.
|
|
14
|
+
function renderableMarkdown(source) {
|
|
15
|
+
const header = /^\uFEFF?---[ \t]*\r?\n([\s\S]*?)\r?\n(?:---|\.\.\.)[ \t]*(?=\r?\n|$)/u.exec(source)
|
|
16
|
+
if (!header || !/^(?:name|description)[ \t]*:/mu.test(header[1])) return source
|
|
17
|
+
let fence = '```'
|
|
18
|
+
for (const [run] of header[0].matchAll(/`+/gu)) {
|
|
19
|
+
if (run.length >= fence.length) fence = '`'.repeat(run.length + 1)
|
|
20
|
+
}
|
|
21
|
+
return `${fence}yaml\n${header[0]}\n${fence}\n${source.slice(header[0].length)}`
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
window.__ModuleLoader__.load({
|
|
25
|
+
id: packageName,
|
|
26
|
+
factory(require) {
|
|
27
|
+
const React = require('react')
|
|
28
|
+
const { createPortal } = require('react-dom')
|
|
29
|
+
const { DetailDocument, MarkdownDelegateProvider, useDetailDocumentLabels } = require('@deepseek-ai/dsh-client-ui-primitives/client')
|
|
30
|
+
|
|
31
|
+
function ManagerDocument({ view, t }) {
|
|
32
|
+
const { target, markdown, options } = view
|
|
33
|
+
const labels = useDetailDocumentLabels({
|
|
34
|
+
title: options.label, loading: t('document.loading'), retry: t('document.retry'),
|
|
35
|
+
copy: t('document.copy'), copied: t('document.copied'), codeBlock: t('document.codeBlock'),
|
|
36
|
+
wrap: t('document.wrap'), unwrap: t('document.unwrap'), footnotes: t('document.footnotes'),
|
|
37
|
+
})
|
|
38
|
+
const openFile = React.useMemo(() => options.onOpenFile && (destination => {
|
|
39
|
+
const path = packageDocumentLink(options.filePath, destination)
|
|
40
|
+
if (path) options.onOpenFile(path)
|
|
41
|
+
}), [options])
|
|
42
|
+
React.useLayoutEffect(() => {
|
|
43
|
+
const region = target.querySelector('[data-detail-document] > [role="region"]')
|
|
44
|
+
if (region) options.onReady?.(region)
|
|
45
|
+
}, [target, options])
|
|
46
|
+
return React.createElement(MarkdownDelegateProvider, { openFile },
|
|
47
|
+
React.createElement(DetailDocument, { state: { status: 'found', markdown }, labels }))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function SidebarIcon({ size }) {
|
|
51
|
+
return React.createElement('img', {
|
|
52
|
+
src: brandIcon, alt: '', 'aria-hidden': true, draggable: false,
|
|
53
|
+
width: size, height: size, style: { display: 'block', transform: 'scale(1.3)' },
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
inject: ['slots', 'locale', 'connection', 'layout', 'uiWorkspace', 'sessions', 'conversation'],
|
|
59
|
+
apply(ctx) {
|
|
60
|
+
// Keep the last management view for this plugin instance even if its panel unmounts.
|
|
61
|
+
let savedSelection = { workspaceId: '', presetId: '' }
|
|
62
|
+
const preferences = {}
|
|
63
|
+
ctx.effect(() => ctx.locale.register(panelId, {
|
|
64
|
+
zh: { title: zh.meta.title, document: zh.document }, en: { title: en.meta.title, document: en.document },
|
|
65
|
+
}), 'skill-manager: panel labels')
|
|
66
|
+
const t = ctx.locale.bind(panelId)
|
|
67
|
+
|
|
68
|
+
ctx.effect(() => {
|
|
69
|
+
const style = document.createElement('style')
|
|
70
|
+
style.dataset.dshPlugin = panelId
|
|
71
|
+
style.textContent = stylesheet
|
|
72
|
+
document.head.append(style)
|
|
73
|
+
return () => style.remove()
|
|
74
|
+
}, 'skill-manager: stylesheet')
|
|
75
|
+
|
|
76
|
+
function ManagerPanel({ useWorkspaces }) {
|
|
77
|
+
const container = React.useRef(null)
|
|
78
|
+
const [view, setView] = React.useState(null)
|
|
79
|
+
const [selection, setSelection] = React.useState(() => savedSelection)
|
|
80
|
+
const pendingFocus = React.useRef(null)
|
|
81
|
+
const workspaceKey = useWorkspaces(workspaceProjection)
|
|
82
|
+
const workspaces = React.useMemo(() => JSON.parse(workspaceKey), [workspaceKey])
|
|
83
|
+
const workspaceId = workspaces.some(workspace => workspace.id === selection.workspaceId) ? selection.workspaceId : ''
|
|
84
|
+
const { presetId } = selection
|
|
85
|
+
const renderMarkdown = React.useCallback((target, markdown, options) => {
|
|
86
|
+
const next = { target, markdown: renderableMarkdown(markdown), options }
|
|
87
|
+
setView(next)
|
|
88
|
+
return () => setView(active => active === next ? null : active)
|
|
89
|
+
}, [])
|
|
90
|
+
React.useEffect(() => {
|
|
91
|
+
const lifetime = new AbortController()
|
|
92
|
+
const api = createManagerApi(ctx, { workspaceId, presetId }, container.current, lifetime.signal)
|
|
93
|
+
const focus = pendingFocus.current
|
|
94
|
+
pendingFocus.current = null
|
|
95
|
+
let dispose
|
|
96
|
+
try {
|
|
97
|
+
dispose = mountManager(container.current, api, renderMarkdown, {
|
|
98
|
+
workspaceId, presetId, workspaces, preferences, focus,
|
|
99
|
+
onChange({ workspaceId, presetId, focus }) {
|
|
100
|
+
savedSelection = { workspaceId, presetId }
|
|
101
|
+
pendingFocus.current = focus
|
|
102
|
+
setSelection(savedSelection)
|
|
103
|
+
},
|
|
104
|
+
})
|
|
105
|
+
} catch (error) {
|
|
106
|
+
lifetime.abort()
|
|
107
|
+
throw error
|
|
108
|
+
}
|
|
109
|
+
return () => {
|
|
110
|
+
try { dispose() } finally { lifetime.abort() }
|
|
111
|
+
}
|
|
112
|
+
}, [workspaceId, presetId, workspaces, renderMarkdown])
|
|
113
|
+
|
|
114
|
+
return React.createElement(React.Fragment, null,
|
|
115
|
+
React.createElement('div', {
|
|
116
|
+
ref: container, 'data-dsh-skill-manager': '',
|
|
117
|
+
style: { display: 'flex', flexDirection: 'column', flex: 1, minWidth: 0, minHeight: 0, overflow: 'hidden' },
|
|
118
|
+
}),
|
|
119
|
+
view && createPortal(React.createElement(ManagerDocument, { view, t }), view.target))
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
ctx.slots.inject('main', () => ctx.slots.register({
|
|
123
|
+
name: 'main', key: panelId, locale: panelId,
|
|
124
|
+
}, ManagerPanel))
|
|
125
|
+
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
|
|
126
|
+
name: 'sidebar.panellist', id: panelId, order: 40, label: () => t('title'), locale: panelId,
|
|
127
|
+
}, SidebarIcon))
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
})
|