@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
|
@@ -0,0 +1,785 @@
|
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import { chmod, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, rmdir, stat, symlink, unlink, writeFile } from 'node:fs/promises'
|
|
3
|
+
import { createRequire } from 'node:module'
|
|
4
|
+
import { tmpdir } from 'node:os'
|
|
5
|
+
import { dirname, join } from 'node:path'
|
|
6
|
+
import test from 'node:test'
|
|
7
|
+
import { coldSkillView, Config, createLibrary, hostRequire, registerCreatorSkill } from '../library.mjs'
|
|
8
|
+
import { managementSelection } from '../management-view.mjs'
|
|
9
|
+
import { FAMILY_MARKER } from '../import-family.mjs'
|
|
10
|
+
import { createImports } from '../imports.mjs'
|
|
11
|
+
import { skillState } from '../skill-state.mjs'
|
|
12
|
+
|
|
13
|
+
const { Context } = hostRequire('@deepseek-ai/cordis')
|
|
14
|
+
const { SkillRegistry } = hostRequire('@deepseek-ai/dsh-skill')
|
|
15
|
+
const { bindScopeParent, createScope, scopeOf } = hostRequire('@deepseek-ai/dsh-scope')
|
|
16
|
+
const filesystem = hostRequire('@deepseek-ai/dsh-skill-filesystem')
|
|
17
|
+
const { updateVolatile } = hostRequire('@deepseek-ai/cosmokit')
|
|
18
|
+
|
|
19
|
+
function markdown(name, description, body = description) {
|
|
20
|
+
return `---\nname: ${name}\ndescription: ${description}\n---\n\n${body}\n`
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function put(path, text) {
|
|
24
|
+
await mkdir(dirname(path), { recursive: true })
|
|
25
|
+
await writeFile(path, text)
|
|
26
|
+
return path
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Real Cordis, scoped DSH registry, schema and filesystem plugin. Only the
|
|
30
|
+
// profile editor and the default-preset lease are isolated test substitutes.
|
|
31
|
+
async function fixture(t, options = {}) {
|
|
32
|
+
const temp = await mkdtemp(join(await realpath(tmpdir()), 'dsh-library-test-'))
|
|
33
|
+
const dsh = join(temp, 'dsh'), agents = join(temp, 'agents'), bundle = join(temp, 'bundled')
|
|
34
|
+
const project = join(temp, 'project'), cwd = join(project, 'deep', 'child')
|
|
35
|
+
const custom = join(temp, 'team'), other = join(temp, 'other'), settings = join(temp, 'settings.json')
|
|
36
|
+
await Promise.all([cwd, custom, other, bundle].map(path => mkdir(path, { recursive: true })))
|
|
37
|
+
await Promise.all([put(join(project, '.git'), 'gitdir: test\n'), put(settings, JSON.stringify({ otherSetting: 23 }))])
|
|
38
|
+
const root = new Context()
|
|
39
|
+
const registered = await root.plugin(SkillRegistry)
|
|
40
|
+
const preset = {}, agent = { id: 'session' }
|
|
41
|
+
const scope = createScope(root, preset)
|
|
42
|
+
bindScopeParent(agent, preset)
|
|
43
|
+
const nativeConfig = { dshHome: dsh, agentsHome: agents, bundledSkillDir: bundle, watch: false, ...options }
|
|
44
|
+
const native = await scope.ctx.plugin(filesystem, nativeConfig)
|
|
45
|
+
const h = { root, scope, preset, agent, cwd, dsh, agents, project, custom, other, bundle, settings, temp, leases: 0, released: 0 }
|
|
46
|
+
h.presets = {
|
|
47
|
+
async acquireScope() { h.leases++; return { key: preset, [Symbol.asyncDispose]: async () => { h.released++ } } },
|
|
48
|
+
}
|
|
49
|
+
root.provide('agentPresets', h.presets)
|
|
50
|
+
let tail = Promise.resolve()
|
|
51
|
+
root.provide('configEditor', {
|
|
52
|
+
async edit(entry, change) {
|
|
53
|
+
const next = tail.then(async () => {
|
|
54
|
+
if (h.failSave) throw new Error('fixture denied configuration write')
|
|
55
|
+
assert.equal(entry, h.fiber.entry)
|
|
56
|
+
const value = change(JSON.parse(await readFile(settings, 'utf8')))
|
|
57
|
+
const checked = Config['~standard'].validate(value)
|
|
58
|
+
assert.equal(checked.issues, undefined)
|
|
59
|
+
await writeFile(settings, JSON.stringify(value))
|
|
60
|
+
updateVolatile(h.fiber.effectiveConfig.customDirectories, checked.value.customDirectories)
|
|
61
|
+
h.fiber.ctx.emit('loader/volatile-update', [['customDirectories']])
|
|
62
|
+
})
|
|
63
|
+
tail = next.catch(() => {})
|
|
64
|
+
await next
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
const managerPlugin = { name: 'manager-test', Config, inject: ['skills'], apply(ctx, config) {
|
|
68
|
+
ctx.fiber.entry = { options: { id: 'fixture' } }
|
|
69
|
+
h.library = createLibrary(ctx, config)
|
|
70
|
+
} }
|
|
71
|
+
h.start = async () => { h.fiber = await root.plugin(managerPlugin, JSON.parse(await readFile(settings, 'utf8'))) }
|
|
72
|
+
await h.start()
|
|
73
|
+
// All deletions are confined to this exact mkdtemp path after plugin teardown.
|
|
74
|
+
t.after(async () => {
|
|
75
|
+
await h.fiber.dispose()
|
|
76
|
+
await native.dispose()
|
|
77
|
+
await scope.dispose()
|
|
78
|
+
await registered.dispose()
|
|
79
|
+
await rm(temp, { recursive: true, force: true })
|
|
80
|
+
})
|
|
81
|
+
h.snapshot = () => root.skills.snapshot({ cwd, scope: agent, signal: new AbortController().signal })
|
|
82
|
+
return h
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
test('creator prefers the selected writable mode, respects exclusions and uses the winning definition’s slash policy', async t => {
|
|
86
|
+
const h = await fixture(t)
|
|
87
|
+
const modes = new Map([['standard', h.scope]])
|
|
88
|
+
for (const id of ['cordis', 'review', 'blocked', 'minimal', 'program', 'read-program']) modes.set(id, createScope(h.root, {}))
|
|
89
|
+
const keys = new Map([...modes].map(([id, scope]) => [id, scopeOf(scope.ctx)]))
|
|
90
|
+
h.presets.list = async () => [...modes.keys()].map(id => ({ id }))
|
|
91
|
+
const acquired = []
|
|
92
|
+
h.presets.acquireScope = async id => {
|
|
93
|
+
acquired.push(id)
|
|
94
|
+
return { key: keys.get(id), [Symbol.asyncDispose]: async () => {} }
|
|
95
|
+
}
|
|
96
|
+
h.root.provide('agents', {})
|
|
97
|
+
h.root.provide('workingDirectory', {})
|
|
98
|
+
h.root.provide('tools', { register() {}, get(name, key) {
|
|
99
|
+
if (key === keys.get('program') || key === keys.get('read-program')) return name === 'run_code' ? { name } : undefined
|
|
100
|
+
return name === 'write' && key !== keys.get('review') ? { name } : undefined
|
|
101
|
+
} })
|
|
102
|
+
const fsContribution = { name: 'tool-fs', Config: hostRequire('@deepseek-ai/dsh-tool-fs').Config, apply() {} }
|
|
103
|
+
await modes.get('program').ctx.plugin(fsContribution, { write: false, applyPatch: true })
|
|
104
|
+
await modes.get('read-program').ctx.plugin(fsContribution, { write: false, edit: false })
|
|
105
|
+
for (const [id, scope] of modes) {
|
|
106
|
+
if (id !== 'minimal') await scope.ctx.plugin(hostRequire('@deepseek-ai/dsh-tool-skill'), {
|
|
107
|
+
excludedSkills: id === 'blocked' ? ['skill-creator'] : [],
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
const provider = await h.root.plugin({ name: 'manager-creator-test', inject: ['skills'], apply: registerCreatorSkill })
|
|
111
|
+
t.after(async () => {
|
|
112
|
+
await provider.dispose()
|
|
113
|
+
for (const [id, scope] of modes) if (id !== 'standard') await scope.dispose()
|
|
114
|
+
})
|
|
115
|
+
const select = async id => h.library.creatorPreset(h.cwd, await managementSelection(h.presets, id))
|
|
116
|
+
assert.equal(await select('cordis'), 'cordis')
|
|
117
|
+
assert.deepEqual(acquired, ['cordis'])
|
|
118
|
+
assert.equal(await select('program'), 'program')
|
|
119
|
+
for (const id of [null, 'review', 'blocked', 'minimal', 'read-program']) assert.equal(await select(id), 'standard')
|
|
120
|
+
|
|
121
|
+
// The project's same-name skill owns the slash policy. A disabled command
|
|
122
|
+
// must not fall through to a lower-precedence bundled definition.
|
|
123
|
+
await h.root.plugin(filesystem, { dshHome: h.dsh, agentsHome: h.agents, watch: false })
|
|
124
|
+
const local = await put(join(h.project, '.dsh/skills/skill-creator.md'), markdown('skill-creator', 'User-owned namesake'))
|
|
125
|
+
await h.library.refresh(h.cwd, await managementSelection(h.presets, null))
|
|
126
|
+
assert.equal(await select('cordis'), 'cordis')
|
|
127
|
+
await put(local, markdown('skill-creator', 'User-owned namesake').replace('\n---\n', '\nuser-invocable: false\n---\n'))
|
|
128
|
+
await h.library.refresh(h.cwd, await managementSelection(h.presets, null))
|
|
129
|
+
await assert.rejects(select('standard'), { code: 'CREATOR_UNAVAILABLE' })
|
|
130
|
+
assert.equal(await h.library.creatorPreset(h.other, await managementSelection(h.presets, 'standard')), 'standard')
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
test('default, live and cold views follow their own preset policies and release stale leases', async t => {
|
|
134
|
+
const h = await fixture(t)
|
|
135
|
+
const creator = {}
|
|
136
|
+
const scope = createScope(h.root, creator)
|
|
137
|
+
t.after(async () => { await scope.dispose() })
|
|
138
|
+
h.root.provide('agents', {}); h.root.provide('tools', { register() {} }); h.root.provide('workingDirectory', {})
|
|
139
|
+
await scope.ctx.plugin(filesystem, { dshHome: h.dsh, agentsHome: h.agents, bundledSkillDir: h.bundle, watch: false })
|
|
140
|
+
await scope.ctx.plugin(hostRequire('@deepseek-ai/dsh-tool-skill'), { excludedSkills: ['limited'] })
|
|
141
|
+
await put(join(h.dsh, 'skills/limited.md'), markdown('limited', 'limited'))
|
|
142
|
+
await put(join(h.dsh, 'skills/editable.md'), markdown('editable', 'editable'))
|
|
143
|
+
const keys = new Map([['standard', h.preset], ['cordis', creator]])
|
|
144
|
+
let defaultId = 'standard'
|
|
145
|
+
const data = []
|
|
146
|
+
h.presets.resolve = async () => ({ id: defaultId })
|
|
147
|
+
h.presets.composedPreset = ctx => ctx === scope.ctx ? 'cordis' : undefined
|
|
148
|
+
h.presets.acquireScope = async id => {
|
|
149
|
+
const key = keys.get(id)
|
|
150
|
+
if (!key) throw Object.assign(new Error('stale preset'), { code: 'agent-preset/not-found' })
|
|
151
|
+
data.push(['acquire', id, key])
|
|
152
|
+
return { key, [Symbol.asyncDispose]: async () => { data.push(['release', id, key]) } }
|
|
153
|
+
}
|
|
154
|
+
const ordinary = await h.library.list(h.cwd)
|
|
155
|
+
assert.deepEqual(ordinary.mode, { id: 'standard', source: 'default' })
|
|
156
|
+
const limited = ordinary.items.find(row => row.name === 'limited')
|
|
157
|
+
assert.equal(limited.enabled, true)
|
|
158
|
+
assert.equal(limited.excluded, false)
|
|
159
|
+
const cold = coldSkillView('cordis')
|
|
160
|
+
const projected = await h.library.refresh(h.cwd, cold)
|
|
161
|
+
assert.deepEqual(projected.mode, { id: 'cordis', source: 'session' })
|
|
162
|
+
const detail = await h.library.detail(h.cwd, limited.id, cold)
|
|
163
|
+
assert.deepEqual(detail.mode, projected.mode)
|
|
164
|
+
assert.equal(detail.excluded, true)
|
|
165
|
+
assert.equal(detail.enabled, false)
|
|
166
|
+
assert.deepEqual(detail.invocation, limited.invocation)
|
|
167
|
+
assert.match(detail.toggleReason, /当前模式限制/)
|
|
168
|
+
const edited = await h.library.setEnabled(h.cwd, ordinary.items.find(row => row.name === 'editable').id, false, cold)
|
|
169
|
+
assert.deepEqual(edited.mode, projected.mode)
|
|
170
|
+
assert.equal(edited.items.find(row => row.name === 'editable').enabled, false)
|
|
171
|
+
|
|
172
|
+
const live = { id: 'live-creator', ctx: scope.ctx }
|
|
173
|
+
bindScopeParent(live, creator)
|
|
174
|
+
const liveView = await h.library.list(h.cwd, live)
|
|
175
|
+
assert.deepEqual(liveView.mode, projected.mode)
|
|
176
|
+
assert.equal(liveView.items.find(row => row.id === limited.id).excluded, true)
|
|
177
|
+
assert.deepEqual((await h.library.list(h.cwd, coldSkillView(null))).mode, { id: null, source: 'session' })
|
|
178
|
+
defaultId = 'cordis'
|
|
179
|
+
assert.deepEqual((await h.library.list(h.cwd)).mode, { id: 'cordis', source: 'default' })
|
|
180
|
+
await assert.rejects(h.library.detail(h.cwd, 'missing', cold), /刷新列表/)
|
|
181
|
+
keys.delete('cordis')
|
|
182
|
+
await assert.rejects(h.library.list(h.cwd, cold), { code: 'SESSION_MODE_UNAVAILABLE' })
|
|
183
|
+
assert.deepEqual(data.map(([action]) => action), Array.from({ length: 6 }, () => ['acquire', 'release']).flat())
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
test('Minimal reports missing skill invocation only when the scoped native tool and dispatcher are absent', async t => {
|
|
187
|
+
const h = await fixture(t)
|
|
188
|
+
const minimal = {}, other = {}
|
|
189
|
+
const scope = createScope(h.root, minimal)
|
|
190
|
+
const otherScope = createScope(h.root, other)
|
|
191
|
+
t.after(async () => { await scope.dispose(); await otherScope.dispose() })
|
|
192
|
+
const { ToolsService, defineTool } = hostRequire('@deepseek-ai/dsh-tools')
|
|
193
|
+
h.root.provide('systemPrompt', { tools() {} })
|
|
194
|
+
h.root.provide('agents', {}); h.root.provide('workingDirectory', {})
|
|
195
|
+
await h.root.plugin(ToolsService)
|
|
196
|
+
await h.root.plugin(hostRequire('@deepseek-ai/dsh-tool-registry-native'))
|
|
197
|
+
h.root.skills.register({ name: 'readable', description: 'Visible provider', content: 'body', source: 'bundled',
|
|
198
|
+
invocation: { modelInvocable: true, userInvocable: true } })
|
|
199
|
+
h.presets.resolve = async id => ({ id: id ?? 'minimal' })
|
|
200
|
+
h.presets.readDocument = async () => ({ name: 'My mode' })
|
|
201
|
+
h.presets.acquireScope = async id => ({ key: id === 'minimal' ? minimal : other, async [Symbol.asyncDispose]() {} })
|
|
202
|
+
const read = async view => (await h.library.list(h.cwd, view)).items.find(row => row.name === 'readable')
|
|
203
|
+
|
|
204
|
+
assert.equal(h.root.tools.get('skill', minimal), undefined)
|
|
205
|
+
const row = await read(coldSkillView('minimal'))
|
|
206
|
+
assert.equal(row.invocationAvailable, false)
|
|
207
|
+
assert.equal(row.enabled, false)
|
|
208
|
+
assert.deepEqual(row.invocation, { modelInvocable: true, userInvocable: true })
|
|
209
|
+
assert.match(row.toggleReason, /当前模式未提供技能调用功能/)
|
|
210
|
+
assert.equal((await h.library.detail(h.cwd, row.id, coldSkillView('minimal'))).content, 'body')
|
|
211
|
+
|
|
212
|
+
const custom = await h.library.list(h.cwd, coldSkillView('custom'))
|
|
213
|
+
assert.deepEqual(custom.mode, { id: 'custom', source: 'session', name: 'My mode' })
|
|
214
|
+
assert.equal(custom.items[0].invocationAvailable, undefined)
|
|
215
|
+
|
|
216
|
+
const nativeSkill = hostRequire('@deepseek-ai/dsh-tool-skill')
|
|
217
|
+
const installedElsewhere = await otherScope.ctx.plugin(nativeSkill, {})
|
|
218
|
+
assert.ok(h.root.tools.get('skill', other))
|
|
219
|
+
assert.equal(h.root.tools.get('skill', minimal), undefined)
|
|
220
|
+
assert.equal((await read(coldSkillView('minimal'))).invocationAvailable, false)
|
|
221
|
+
await installedElsewhere.dispose()
|
|
222
|
+
|
|
223
|
+
const registration = await scope.ctx.plugin({ inject: ['tools'], apply(ctx) {
|
|
224
|
+
ctx.tools.register(defineTool({ name: 'skill', description: 'Custom skill handler', parameters: {},
|
|
225
|
+
output: { schema: { type: 'string' } }, async execute() { return '' } }))
|
|
226
|
+
} })
|
|
227
|
+
assert.ok(h.root.tools.get('skill', minimal))
|
|
228
|
+
assert.equal((await read(coldSkillView('minimal'))).invocationAvailable, undefined)
|
|
229
|
+
await registration.dispose()
|
|
230
|
+
|
|
231
|
+
const override = await scope.ctx.plugin(nativeSkill, {})
|
|
232
|
+
assert.equal((await read(coldSkillView('minimal'))).enabled, true)
|
|
233
|
+
await override.dispose()
|
|
234
|
+
assert.equal((await read(coldSkillView('minimal'))).invocationAvailable, false)
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
test('default, preset, project, runtime and managed roots follow the scoped registry and keep same-name files distinct', async t => {
|
|
238
|
+
const h = await fixture(t)
|
|
239
|
+
const same = 'common-skill'
|
|
240
|
+
const files = [
|
|
241
|
+
[join(h.project, '.dsh/skills/project/SKILL.md'), 'project-dsh'],
|
|
242
|
+
[join(h.project, '.agents/skills/agent.md'), 'project-agents'],
|
|
243
|
+
[join(h.custom, 'ANY-NAME/SKILL.md'), 'custom'],
|
|
244
|
+
[join(h.dsh, 'skills/personal.md'), 'user-dsh'],
|
|
245
|
+
[join(h.agents, 'skills/sharing/SKILL.md'), 'user-agents'],
|
|
246
|
+
[join(h.bundle, 'official/SKILL.md'), 'bundled'],
|
|
247
|
+
]
|
|
248
|
+
await Promise.all(files.map(([path, description]) => put(path, markdown(same, description))))
|
|
249
|
+
await put(join(h.dsh, 'skills/.system/SKILL.md'), markdown('hidden-special', 'system directory'))
|
|
250
|
+
await put(join(h.custom, 'standalone.md'), markdown('team-only', 'custom only'))
|
|
251
|
+
h.root.skills.register({ name: 'virtual-skill', description: 'plugin supplied', source: 'runtime', content: 'virtual text' })
|
|
252
|
+
const initial = await h.library.list(h.cwd)
|
|
253
|
+
assert.equal(h.leases, h.released)
|
|
254
|
+
assert.equal(initial.directories.filter(x => ['project', 'shared'].includes(x.kind)).length, 3)
|
|
255
|
+
assert.equal(initial.directories.find(x => x.source === 'project-dsh').path, join(h.project, '.dsh/skills'))
|
|
256
|
+
assert.equal(initial.items.some(x => x.name === 'hidden-special' || x.name === 'team-only'), false)
|
|
257
|
+
assert.equal((await h.snapshot()).complete, true) // AbortSignal must work even with zero extra roots.
|
|
258
|
+
const inventory = await h.library.addDirectory(h.cwd, h.custom, '团队技能', h.agent)
|
|
259
|
+
const choices = inventory.items.filter(x => x.name === same)
|
|
260
|
+
assert.equal(new Set(choices.map(x => x.id)).size, 6)
|
|
261
|
+
assert.equal(choices.filter(x => x.effective).length, 1)
|
|
262
|
+
const winner = choices.find(x => x.effective)
|
|
263
|
+
assert.equal(winner.source, 'project-dsh')
|
|
264
|
+
assert.equal(winner.sourceDirectoryPath, join(h.project, '.dsh/skills'))
|
|
265
|
+
for (const item of choices) {
|
|
266
|
+
const detail = await h.library.detail(h.cwd, item.id, h.agent)
|
|
267
|
+
assert.equal(detail.content, item.source)
|
|
268
|
+
assert.equal(detail.category, item.source === 'bundled' ? 'builtin' : 'user')
|
|
269
|
+
assert.equal(detail.category, item.category)
|
|
270
|
+
assert.equal(detail.package, null)
|
|
271
|
+
if (!item.effective) assert.equal(item.shadowedBy, winner.id)
|
|
272
|
+
if (item.source === 'bundled') assert.equal(item.canToggle, false)
|
|
273
|
+
}
|
|
274
|
+
const virtual = inventory.items.find(x => x.name === 'virtual-skill')
|
|
275
|
+
assert.equal(virtual.canToggle, false)
|
|
276
|
+
assert.equal(virtual.category, 'provided')
|
|
277
|
+
assert.equal(virtual.path, null)
|
|
278
|
+
assert.equal((await h.library.detail(h.cwd, virtual.id, h.agent)).content, 'virtual text')
|
|
279
|
+
assert.equal((await h.root.skills.get('team-only', { cwd: h.cwd, scope: h.agent })).content, 'custom only')
|
|
280
|
+
assert.equal(await h.root.skills.get('team-only', { cwd: h.cwd }), undefined)
|
|
281
|
+
const plainScope = {}
|
|
282
|
+
assert.deepEqual(await h.library.targets(h.cwd, plainScope), [])
|
|
283
|
+
assert.equal((await h.library.list(h.cwd, plainScope)).items.some(x => x.name === 'team-only'), false)
|
|
284
|
+
await Promise.all(files.slice(0, 2).map(([target]) => unlink(target)))
|
|
285
|
+
await h.library.refresh(h.cwd, h.agent)
|
|
286
|
+
assert.equal((await h.root.skills.get(same, { cwd: h.cwd, scope: h.agent })).description, 'custom')
|
|
287
|
+
await h.library.removeDirectory(h.cwd, inventory.directories.find(x => x.kind === 'custom').id, h.agent)
|
|
288
|
+
assert.equal((await h.root.skills.get(same, { cwd: h.cwd, scope: h.agent })).description, 'user-dsh')
|
|
289
|
+
assert.equal(await readFile(files[2][0], 'utf8'), markdown(same, 'custom'))
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
test('custom configuration survives remount, concurrent edits, retries, save rejection and preset replacement', async t => {
|
|
293
|
+
const h = await fixture(t)
|
|
294
|
+
let targets = await h.library.targets(h.cwd)
|
|
295
|
+
assert.equal(targets.length, 1)
|
|
296
|
+
assert.equal(targets[0].exists, false)
|
|
297
|
+
assert.equal(targets[0].writable, true)
|
|
298
|
+
await assert.rejects(stat(join(h.dsh, 'skills')), { code: 'ENOENT' })
|
|
299
|
+
await put(join(h.custom, 'skill.md'), markdown('survivor', 'loaded'))
|
|
300
|
+
await Promise.all([h.library.addDirectory(h.cwd, h.custom, h.agent), h.library.addDirectory(h.cwd, h.other, 'other', h.agent)])
|
|
301
|
+
const alias = join(h.temp, 'alias')
|
|
302
|
+
await symlink(h.custom, alias, 'dir')
|
|
303
|
+
await h.library.addDirectory(h.cwd, alias, h.agent)
|
|
304
|
+
targets = await h.library.targets(h.cwd)
|
|
305
|
+
assert.equal(targets.filter(x => x.kind === 'custom').length, 2)
|
|
306
|
+
assert.equal(JSON.parse(await readFile(h.settings, 'utf8')).otherSetting, 23)
|
|
307
|
+
await h.fiber.dispose()
|
|
308
|
+
assert.equal(await h.root.skills.get('survivor', { cwd: h.cwd, scope: h.agent }), undefined)
|
|
309
|
+
await h.start()
|
|
310
|
+
assert.equal((await h.root.skills.get('survivor', { cwd: h.cwd, scope: h.agent })).description, 'loaded')
|
|
311
|
+
const newer = {}, next = createScope(h.root, newer)
|
|
312
|
+
try {
|
|
313
|
+
await next.ctx.plugin(filesystem, { dshHome: h.dsh, agentsHome: h.agents, bundledSkillDir: h.bundle, watch: false })
|
|
314
|
+
assert.equal((await h.root.skills.get('survivor', { cwd: h.cwd, scope: newer })).description, 'loaded')
|
|
315
|
+
} finally { await next.dispose() }
|
|
316
|
+
assert.equal(await h.root.skills.get('survivor', { cwd: h.cwd, scope: newer }), undefined)
|
|
317
|
+
const dir = (await h.library.targets(h.cwd)).find(x => x.path === h.custom)
|
|
318
|
+
h.failSave = true
|
|
319
|
+
await assert.rejects(h.library.removeDirectory(h.cwd, dir.id), /denied configuration write/)
|
|
320
|
+
assert.equal((await h.root.skills.get('survivor', { cwd: h.cwd, scope: h.agent })).description, 'loaded')
|
|
321
|
+
h.failSave = false
|
|
322
|
+
await h.library.removeDirectory(h.cwd, dir.id)
|
|
323
|
+
await h.library.removeDirectory(h.cwd, dir.id)
|
|
324
|
+
assert.equal(await readFile(join(h.custom, 'skill.md'), 'utf8'), markdown('survivor', 'loaded'))
|
|
325
|
+
await assert.rejects(h.library.removeDirectory(h.cwd, targets[0].id), /仅可移除/)
|
|
326
|
+
await assert.rejects(h.library.addDirectory(h.cwd, join(h.temp, 'missing')), /不存在/)
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
test('model flag edits preserve instructions, YAML/comments, CRLF, Unix mode and user invocation', async t => {
|
|
330
|
+
const h = await fixture(t)
|
|
331
|
+
const original = '---\r\n# 中文\r\nname: toggle-me\r\ndescription: >-\r\n multiple lines\r\n of detail\r\nuser-invocable: false\r\nmetadata: {v: 3}\r\n---\r\n\r\nA literal line.\r\n---\r\nBody text.\r\n'
|
|
332
|
+
const target = await put(join(h.dsh, 'skills/toggle-me/SKILL.md'), original)
|
|
333
|
+
await chmod(target, 0o664)
|
|
334
|
+
const key = (await h.library.list(h.cwd)).items.find(x => x.name === 'toggle-me').id
|
|
335
|
+
const disabled = await h.library.setEnabled(h.cwd, key, false, h.agent)
|
|
336
|
+
assert.equal(disabled.items.find(x => x.id === key).enabled, false)
|
|
337
|
+
assert.deepEqual((await h.snapshot()).skills[0].invocation, { modelInvocable: false, userInvocable: false })
|
|
338
|
+
const saved = await readFile(target, 'utf8')
|
|
339
|
+
assert.equal(saved.replace('disable-model-invocation: true\r\n', ''), original)
|
|
340
|
+
assert.equal((await stat(target)).mode & 0o777, 0o664)
|
|
341
|
+
const first = (await stat(target)).ino
|
|
342
|
+
await h.library.setEnabled(h.cwd, key, false)
|
|
343
|
+
assert.equal((await stat(target)).ino, first)
|
|
344
|
+
await Promise.all([h.library.setEnabled(h.cwd, key, true), h.library.setEnabled(h.cwd, key, true)])
|
|
345
|
+
assert.deepEqual((await h.root.skills.get('toggle-me', { cwd: h.cwd, scope: h.agent })).invocation, { modelInvocable: true, userInvocable: false })
|
|
346
|
+
assert.equal((await h.library.detail(h.cwd, key)).metadata.v, 3)
|
|
347
|
+
assert.deepEqual(await readdir(join(h.dsh, 'skills')), ['toggle-me'])
|
|
348
|
+
const samples = [
|
|
349
|
+
['disable-model-invocation: "YES" # keep', 'disable-model-invocation: "false" # keep'],
|
|
350
|
+
['disable-model-invocation: on # keep', 'disable-model-invocation: false # keep'],
|
|
351
|
+
["disable-model-invocation: '1' # keep", "disable-model-invocation: 'false' # keep"],
|
|
352
|
+
['disable-model-invocation: |-\n true', 'disable-model-invocation: |-\n false'],
|
|
353
|
+
]
|
|
354
|
+
for (const [before, after] of samples) {
|
|
355
|
+
const input = `---\nname: toggle-me\ndescription: test\n${before}\n---\noriginal\n`
|
|
356
|
+
await writeFile(target, input)
|
|
357
|
+
await h.library.refresh(h.cwd)
|
|
358
|
+
await h.library.setEnabled(h.cwd, key, true)
|
|
359
|
+
assert.equal(await readFile(target, 'utf8'), input.replace(before, after))
|
|
360
|
+
}
|
|
361
|
+
const flow = '---\n{name: toggle-me, description: test} # keep map\n---\nbody\n'
|
|
362
|
+
await writeFile(target, flow)
|
|
363
|
+
await h.library.refresh(h.cwd)
|
|
364
|
+
await h.library.setEnabled(h.cwd, key, false)
|
|
365
|
+
assert.equal(await readFile(target, 'utf8'), flow.replace('{name:', '{disable-model-invocation: true, name:'))
|
|
366
|
+
})
|
|
367
|
+
|
|
368
|
+
test('external symlinks and runtime policy stay read-only, and model discovery exposes only eligible summaries', async t => {
|
|
369
|
+
const h = await fixture(t)
|
|
370
|
+
const original = markdown('from-link', 'readable via link')
|
|
371
|
+
const external = await put(join(h.temp, 'outside', 'folder', 'SKILL.md'), original)
|
|
372
|
+
const personal = join(h.dsh, 'skills')
|
|
373
|
+
await mkdir(personal, { recursive: true })
|
|
374
|
+
await symlink(dirname(external), join(personal, 'shortcut'), 'dir')
|
|
375
|
+
await put(join(personal, 'blocked.md'), markdown('excluded', 'private detail'))
|
|
376
|
+
await put(join(personal, 'disabled.md'), '---\nname: disabled\ndescription: disabled test\ndisable-model-invocation: true\n---\nbody')
|
|
377
|
+
// Mount the shipped tool-skill policy with inert tool/agent dependencies.
|
|
378
|
+
const tool = hostRequire('@deepseek-ai/dsh-tool-skill')
|
|
379
|
+
h.root.provide('agents', {})
|
|
380
|
+
h.root.provide('tools', { register() {} })
|
|
381
|
+
h.root.provide('workingDirectory', {})
|
|
382
|
+
const policy = await h.scope.ctx.plugin(tool, { excludedSkills: ['excluded'] })
|
|
383
|
+
try {
|
|
384
|
+
const rows = (await h.library.list(h.cwd, h.agent)).items
|
|
385
|
+
for (const name of ['excluded', 'from-link']) {
|
|
386
|
+
const row = rows.find(x => x.name === name)
|
|
387
|
+
assert.equal(row.canToggle, false)
|
|
388
|
+
assert.equal(row.category, 'user')
|
|
389
|
+
assert.equal(row.excluded, name === 'excluded')
|
|
390
|
+
assert.match(row.toggleReason, name === 'excluded' ? /当前模式限制/ : /读取权限/)
|
|
391
|
+
await assert.rejects(h.library.setEnabled(h.cwd, row.id, false, h.agent), error => error.message === row.toggleReason)
|
|
392
|
+
}
|
|
393
|
+
assert.equal(skillState(rows.find(x => x.name === 'excluded')).key, 'excluded')
|
|
394
|
+
assert.equal(skillState(rows.find(x => x.name === 'disabled')).key, 'manual')
|
|
395
|
+
assert.equal(await readFile(external, 'utf8'), original)
|
|
396
|
+
assert.deepEqual(await h.library.modelCatalog(h.cwd, h.agent, { refresh: true, signal: new AbortController().signal }),
|
|
397
|
+
{ complete: true, skills: [{ name: 'from-link', description: 'readable via link' }] })
|
|
398
|
+
await assert.rejects(h.library.modelCatalog(h.cwd, h.agent, { signal: AbortSignal.abort() }), { name: 'AbortError' })
|
|
399
|
+
} finally { await policy.dispose() }
|
|
400
|
+
})
|
|
401
|
+
|
|
402
|
+
test('import registration identifies the exact shadowed definition, reports its winner and can be retried', async t => {
|
|
403
|
+
const h = await fixture(t)
|
|
404
|
+
await put(join(h.project, '.dsh/skills/project.md'), markdown('shared-name', 'project'))
|
|
405
|
+
const source = await put(join(h.temp, 'incoming.md'), markdown('shared-name', 'incoming'))
|
|
406
|
+
const initial = await h.library.addDirectory(h.cwd, h.custom)
|
|
407
|
+
const target = initial.directories.find(d => d.kind === 'custom')
|
|
408
|
+
const imports = createImports({ home: h.temp })
|
|
409
|
+
t.after(() => imports.dispose())
|
|
410
|
+
const draft = await imports.preview({ type: 'local', path: source })
|
|
411
|
+
const receipt = await imports.commit({ token: draft.token, directory: target })
|
|
412
|
+
const { path } = receipt
|
|
413
|
+
const changed = await h.library.imported(h.cwd, receipt, false)
|
|
414
|
+
assert.equal(changed.importedItem.enabled, false)
|
|
415
|
+
assert.equal(changed.importedItem, changed.items.find(x => x.path === path))
|
|
416
|
+
assert.equal(changed.items.find(x => x.effective).enabled, true)
|
|
417
|
+
assert.match(changed.warnings.join('\n'), /同名技能/)
|
|
418
|
+
await h.library.imported(h.cwd, receipt, false)
|
|
419
|
+
const next = await imports.preview({ type: 'local', path: source })
|
|
420
|
+
await assert.rejects(imports.commit({ token: next.token, directory: target }), { code: 'CONFLICT' })
|
|
421
|
+
await h.library.setEnabled(h.cwd, changed.importedItem.id, true)
|
|
422
|
+
await assert.rejects(imports.commit({ token: next.token, directory: target, conflict: 'replace' }), { code: 'CONFLICT' })
|
|
423
|
+
const replaced = await imports.commit({ token: next.token, directory: target, conflict: 'replace' })
|
|
424
|
+
assert.equal(replaced.replaced, true)
|
|
425
|
+
assert.equal((await h.library.imported(h.cwd, replaced, true)).importedItem.enabled, true)
|
|
426
|
+
await assert.rejects(h.library.imported(h.cwd, { ...receipt, directoryId: 'no-such-directory' }, false), /尚未发现/)
|
|
427
|
+
assert.equal(await readFile(join(h.project, '.dsh/skills/project.md'), 'utf8'), markdown('shared-name', 'project'))
|
|
428
|
+
})
|
|
429
|
+
|
|
430
|
+
test('custom-only native presets refresh their own candidates and never acquire managed import targets', async t => {
|
|
431
|
+
const h = await fixture(t, { includeDefaultRoots: false })
|
|
432
|
+
const file = await put(join(h.bundle, 'readme.md'), markdown('bundled-fixture', 'first version'))
|
|
433
|
+
const initial = await h.library.list(h.cwd, h.agent)
|
|
434
|
+
assert.deepEqual(initial.directories, [])
|
|
435
|
+
assert.equal(initial.items[0].description, 'first version')
|
|
436
|
+
await h.library.addDirectory(h.cwd, h.custom)
|
|
437
|
+
await put(join(h.custom, 'extra.md'), markdown('hidden-extra', 'owner added elsewhere'))
|
|
438
|
+
await writeFile(file, markdown('bundled-fixture', 'second version'))
|
|
439
|
+
const model = await h.library.modelCatalog(h.cwd, h.agent, { refresh: true })
|
|
440
|
+
assert.deepEqual(model.skills, [{ name: 'bundled-fixture', description: 'second version' }])
|
|
441
|
+
assert.deepEqual(await h.library.targets(h.cwd, h.agent), [])
|
|
442
|
+
})
|
|
443
|
+
|
|
444
|
+
test('an unavailable custom directory remains removable, can recover and emits an incomplete warning on a failing root', async t => {
|
|
445
|
+
const h = await fixture(t)
|
|
446
|
+
const file = await put(join(h.custom, 'maybe.md'), markdown('available-again', 'ok'))
|
|
447
|
+
const initial = await h.library.addDirectory(h.cwd, h.custom)
|
|
448
|
+
const alias = join(h.temp, 'parked')
|
|
449
|
+
await rename(h.custom, alias)
|
|
450
|
+
await symlink(h.custom, h.custom)
|
|
451
|
+
const failed = await h.library.refresh(h.cwd)
|
|
452
|
+
assert.equal(failed.complete, false)
|
|
453
|
+
assert.ok(failed.warnings.length > 0)
|
|
454
|
+
assert.ok(failed.directories.some(row => row.removable && !row.writable))
|
|
455
|
+
assert.equal((await h.library.targets(h.cwd)).some(row => row.path === h.custom), false)
|
|
456
|
+
await unlink(h.custom)
|
|
457
|
+
await rename(alias, h.custom)
|
|
458
|
+
const recovered = await h.library.refresh(h.cwd)
|
|
459
|
+
assert.equal(recovered.complete, true)
|
|
460
|
+
assert.equal(recovered.items.find(row => row.path === file).id, initial.items.find(row => row.path === file).id)
|
|
461
|
+
})
|
|
462
|
+
|
|
463
|
+
test('installed preset documentation, Office, the official badge bundle and ordinary plugins have distinct origins', async t => {
|
|
464
|
+
const from = createRequire(process.resourcesPath ? join(process.resourcesPath, 'app.asar/dsh/package.json') : join(process.env.DSH_INSTALL_DIR, 'package.json'))
|
|
465
|
+
const presetRoot = join(dirname(from.resolve('@deepseek-ai/dsh-agent-preset/package.json')), 'skills')
|
|
466
|
+
const h = await fixture(t, { customSkillDirs: [presetRoot] })
|
|
467
|
+
const office = await h.scope.ctx.plugin(hostRequire('@deepseek-ai/dsh-skill-office'), {})
|
|
468
|
+
const badge = await h.scope.ctx.plugin(hostRequire('@deepseek-ai/dsh-skill-badge'))
|
|
469
|
+
t.after(async () => { await badge.dispose(); await office.dispose() })
|
|
470
|
+
h.root.skills.register({ name: 'experimental-name', description: 'ordinary third-party', content: 'body', provider: 'pstack', source: 'bundled', metadata: { experimental: 'true' } })
|
|
471
|
+
h.root.skills.register({ name: 'trial', description: 'explicitly experimental', content: 'body', source: 'runtime', metadata: { experimental: true } })
|
|
472
|
+
let rows = (await h.library.list(h.cwd)).items
|
|
473
|
+
const expected = { 'dsh-doc': 'builtin', office: 'builtin', 'dsh-badge': 'experimental', 'experimental-name': 'provided', trial: 'experimental' }
|
|
474
|
+
for (const [name, category] of Object.entries(expected)) {
|
|
475
|
+
const row = rows.find(row => row.name === name)
|
|
476
|
+
assert.equal(row.category, category, name)
|
|
477
|
+
assert.equal(row.canToggle, false)
|
|
478
|
+
assert.equal(row.package, null)
|
|
479
|
+
assert.equal((await h.library.detail(h.cwd, row.id)).category, category)
|
|
480
|
+
}
|
|
481
|
+
const officeItem = rows.find(row => row.name === 'office')
|
|
482
|
+
const officeRoot = join(dirname(from.resolve('@deepseek-ai/dsh-skill-office/package.json')), 'assets', 'office')
|
|
483
|
+
const officeEntry = join(officeRoot, 'SKILL.md')
|
|
484
|
+
const { candidate: publishedOffice } = (await h.root.skills.collect({ cwd: h.cwd, scope: h.agent })).entries.get('office')
|
|
485
|
+
assert.equal(publishedOffice.path, undefined)
|
|
486
|
+
assert.equal(publishedOffice.locator, officeEntry)
|
|
487
|
+
assert.equal(officeItem.path, officeEntry)
|
|
488
|
+
assert.equal(officeItem.updatedAt, (await stat(officeEntry)).mtimeMs)
|
|
489
|
+
assert.match((await h.library.detail(h.cwd, officeItem.id)).content, /## Python environment/)
|
|
490
|
+
const doc = rows.find(row => row.name === 'dsh-doc')
|
|
491
|
+
assert.deepEqual([doc.provider, doc.source, doc.effective, doc.enabled], ['filesystem', 'custom', true, true])
|
|
492
|
+
assert.match(doc.toggleReason, /当前预设启用/)
|
|
493
|
+
await assert.rejects(h.library.setEnabled(h.cwd, doc.id, false), error => error.message === doc.toggleReason)
|
|
494
|
+
await put(join(h.project, '.dsh/skills/my-doc.md'), markdown('dsh-doc', 'project override'))
|
|
495
|
+
rows = (await h.library.refresh(h.cwd)).items
|
|
496
|
+
assert.equal(rows.find(row => row.name === 'dsh-doc' && row.effective).category, 'user')
|
|
497
|
+
assert.match(rows.find(row => row.id === doc.id).toggleReason, /同名/)
|
|
498
|
+
h.root.provide('agents', {}); h.root.provide('tools', { register() {} }); h.root.provide('workingDirectory', {})
|
|
499
|
+
const policy = await h.scope.ctx.plugin(hostRequire('@deepseek-ai/dsh-tool-skill'), { excludedSkills: ['dsh-doc'] })
|
|
500
|
+
try { assert.match((await h.library.detail(h.cwd, doc.id)).toggleReason, /当前模式限制/) } finally { await policy.dispose() }
|
|
501
|
+
})
|
|
502
|
+
|
|
503
|
+
test('pathless candidates need a real entry locator inside their declared resource directory', async t => {
|
|
504
|
+
const h = await fixture(t)
|
|
505
|
+
const root = join(h.temp, 'provider-assets')
|
|
506
|
+
const entry = await put(join(root, 'SKILL.md'), 'entry')
|
|
507
|
+
const outside = await put(join(h.other, 'SKILL.md'), 'outside')
|
|
508
|
+
const linkDir = join(h.temp, 'linked-asset')
|
|
509
|
+
await symlink(root, linkDir, 'dir')
|
|
510
|
+
const fake = [
|
|
511
|
+
['opaque', root, 'SKILL.md'],
|
|
512
|
+
['out-of-root', root, outside],
|
|
513
|
+
['unavailable', join(h.temp, 'missing'), join(h.temp, 'missing', 'SKILL.md')],
|
|
514
|
+
['linked-entry', linkDir, join(linkDir, 'SKILL.md')],
|
|
515
|
+
['valid-entry', root, entry],
|
|
516
|
+
['virtual-entry', null, entry],
|
|
517
|
+
]
|
|
518
|
+
const withdraw = h.root.skills.registerProvider(() => ({
|
|
519
|
+
name: 'resources',
|
|
520
|
+
async list() {
|
|
521
|
+
return fake.map(([name, directory, locator]) => ({ name, description: name, provider: 'resources', source: 'runtime', rank: 500,
|
|
522
|
+
locator, resourceBase: directory ? { kind: 'directory', path: directory } : { kind: 'virtual', description: 'virtual' },
|
|
523
|
+
invocation: { modelInvocable: true, userInvocable: true } }))
|
|
524
|
+
},
|
|
525
|
+
async get(candidate) { return { ...candidate, content: 'provider Overview' } },
|
|
526
|
+
}))
|
|
527
|
+
t.after(withdraw)
|
|
528
|
+
const { items } = await h.library.list(h.cwd)
|
|
529
|
+
for (const [name] of fake) {
|
|
530
|
+
const item = items.find(row => row.name === name)
|
|
531
|
+
assert.equal(item.path, name === 'valid-entry' ? entry : null, name)
|
|
532
|
+
assert.equal((await h.library.detail(h.cwd, item.id)).content, 'provider Overview')
|
|
533
|
+
}
|
|
534
|
+
})
|
|
535
|
+
|
|
536
|
+
test('package identity uses a real manifest, member root and localized title without loading member bodies', async t => {
|
|
537
|
+
const h = await fixture(t)
|
|
538
|
+
const root = join(h.temp, 'node_modules/@vendor/kit'), other = join(h.temp, 'second/node_modules/@vendor/kit')
|
|
539
|
+
const declared = { package: '@vendor/kit' }
|
|
540
|
+
const candidates = [], calls = []
|
|
541
|
+
for (const [directory, names] of [[root, ['write-doc', 'read-doc']], [other, ['other-copy']]]) {
|
|
542
|
+
await put(join(directory, 'package.json'), JSON.stringify({ name: '@vendor/kit', description: 'package description' }))
|
|
543
|
+
await put(join(directory, 'locale/zh.json'), JSON.stringify({ meta: { title: 'Toolkit', description: '本地化说明' } }))
|
|
544
|
+
for (const name of names) {
|
|
545
|
+
const body = name === 'write-doc' ? 'Open `../read-doc/SKILL.md` for further steps. Also see `../other-copy/SKILL.md` and /unproven.' : name
|
|
546
|
+
const path = await put(join(directory, 'skills', name, 'SKILL.md'), markdown(name, name, body))
|
|
547
|
+
candidates.push({ provider: 'third-party', source: 'bundled', name, description: name, rank: 600, locator: name, path,
|
|
548
|
+
resourceBase: { kind: 'directory', path: dirname(path) }, invocation: { modelInvocable: name === 'write-doc', userInvocable: true }, metadata: declared })
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
const withdraw = h.root.skills.registerProvider(() => ({ name: 'third-party', async list() { return candidates },
|
|
552
|
+
async get(candidate) { calls.push(candidate.name); return { ...candidate, content: 'exact detail' } } }))
|
|
553
|
+
t.after(withdraw)
|
|
554
|
+
await put(join(h.dsh, 'skills/local.md'), '---\nname: testing-lab\ndescription: ordinary file\nmetadata: {experimental: "true", package: "@vendor/kit"}\n---\nbody\n')
|
|
555
|
+
await put(join(h.dsh, 'skills/preview.md'), '---\nname: early-access\ndescription: declared preview\nmetadata: {experimental: true}\n---\nbody\n')
|
|
556
|
+
const rows = (await h.library.list(h.cwd)).items
|
|
557
|
+
assert.deepEqual(calls, [])
|
|
558
|
+
const first = rows.find(row => row.name === 'write-doc'), second = rows.find(row => row.name === 'read-doc')
|
|
559
|
+
const separate = rows.find(row => row.name === 'other-copy')
|
|
560
|
+
assert.equal(first.category, 'provided')
|
|
561
|
+
assert.equal(first.package.name, '@vendor/kit')
|
|
562
|
+
assert.equal(first.package.label, 'Toolkit')
|
|
563
|
+
assert.equal(first.package.description, '本地化说明')
|
|
564
|
+
assert.equal(first.package.root, root)
|
|
565
|
+
assert.equal(first.package.canToggle, false)
|
|
566
|
+
assert.equal(second.package.id, first.package.id)
|
|
567
|
+
assert.notEqual(separate.package.id, first.package.id)
|
|
568
|
+
assert.deepEqual(second.referencedBy, ['write-doc'])
|
|
569
|
+
assert.equal(separate.referencedBy, undefined)
|
|
570
|
+
assert.equal(skillState(second).key, 'manual')
|
|
571
|
+
assert.equal(rows.find(row => row.name === 'testing-lab').package, null)
|
|
572
|
+
assert.equal(rows.find(row => row.name === 'testing-lab').category, 'user')
|
|
573
|
+
assert.equal(rows.find(row => row.name === 'early-access').category, 'experimental')
|
|
574
|
+
assert.deepEqual((await h.library.detail(h.cwd, first.id)).package, first.package)
|
|
575
|
+
assert.deepEqual(calls, ['write-doc'])
|
|
576
|
+
await put(first.path, markdown(first.name, first.name, 'Open /read-doc.'))
|
|
577
|
+
const updated = (await h.library.refresh(h.cwd)).items.find(row => row.id === second.id)
|
|
578
|
+
assert.equal(updated.referencedBy, undefined)
|
|
579
|
+
})
|
|
580
|
+
|
|
581
|
+
test('an imported family retains its shared switch, same-name winner and independent member flags after remount', async t => {
|
|
582
|
+
const h = await fixture(t)
|
|
583
|
+
const target = (await h.library.list(h.cwd)).directories.find(row => row.kind === 'personal')
|
|
584
|
+
const root = join(target.path, 'writing-kit')
|
|
585
|
+
const names = ['shared-member', 'quiet-member'], members = []
|
|
586
|
+
for (const name of names) {
|
|
587
|
+
const entry = `skills/${name}/SKILL.md`
|
|
588
|
+
const text = markdown(name, `from ${name}`).replace('---\n\n', `${name === 'quiet-member' ? 'disable-model-invocation: true\n' : ''}---\n\n`)
|
|
589
|
+
members.push({ name, entry, path: await put(join(root, entry), text) })
|
|
590
|
+
}
|
|
591
|
+
const readme = await put(join(root, 'README.md'), '# Writing Kit\n')
|
|
592
|
+
const marker = { version: 1, id: 'writing-kit', name: 'Writing Kit', description: 'A family', entry: 'README.md', enabled: true,
|
|
593
|
+
members: members.map(({ name, entry }) => ({ name, entry })), source: { format: 'archive', label: 'writing.zip' } }
|
|
594
|
+
await put(join(root, FAMILY_MARKER), JSON.stringify(marker))
|
|
595
|
+
await put(join(h.project, '.dsh/skills/project.md'), markdown('shared-member', 'project override'))
|
|
596
|
+
const receipt = { name: 'Writing Kit', path: readme, familyRoot: root, directoryId: target.id, family: marker, members }
|
|
597
|
+
let result = await h.library.imported(h.cwd, receipt)
|
|
598
|
+
assert.equal(result.importedPackage.root, root)
|
|
599
|
+
assert.equal(result.importedPackage.label, 'Writing Kit')
|
|
600
|
+
assert.equal(result.importedPackage.canToggle, true)
|
|
601
|
+
assert.equal(result.importedItems.length, 2)
|
|
602
|
+
assert.ok(result.importedItems.every(row => row.category === 'user' && row.directoryId === target.id))
|
|
603
|
+
const [first, quiet] = result.importedItems
|
|
604
|
+
assert.equal(first.effective, false)
|
|
605
|
+
assert.equal(first.enabled, true)
|
|
606
|
+
assert.equal(skillState(first).key, 'shadowed')
|
|
607
|
+
assert.equal((await h.library.detail(h.cwd, first.id)).content, 'from shared-member')
|
|
608
|
+
assert.equal(quiet.enabled, false)
|
|
609
|
+
assert.equal(skillState(quiet).key, 'manual')
|
|
610
|
+
assert.match(result.warnings.join('\n'), /同名/)
|
|
611
|
+
await assert.rejects(h.library.imported(h.cwd, { ...receipt, members: members.slice(0, 1) }), /清单/)
|
|
612
|
+
await assert.rejects(h.library.imported(h.cwd, { ...receipt, directoryId: 'wrong' }), /尚未发现/)
|
|
613
|
+
const originals = await Promise.all(members.map(member => readFile(member.path, 'utf8')))
|
|
614
|
+
const switched = await h.library.setPackageEnabled(h.cwd, first.package.id, false)
|
|
615
|
+
assert.ok(switched.items.filter(row => row.package).every(row => !row.enabled && !row.invocation.userInvocable))
|
|
616
|
+
assert.ok(switched.items.filter(row => row.package).every(row => skillState(row).key === 'off'))
|
|
617
|
+
assert.deepEqual(await Promise.all(members.map(member => readFile(member.path, 'utf8'))), originals)
|
|
618
|
+
assert.equal((await h.root.skills.get('quiet-member', { cwd: h.cwd, scope: h.agent })).invocation.userInvocable, false)
|
|
619
|
+
await h.fiber.dispose(); await h.start()
|
|
620
|
+
result = await h.library.imported(h.cwd, receipt)
|
|
621
|
+
assert.equal(result.importedPackage.id, first.package.id)
|
|
622
|
+
assert.equal(result.importedPackage.enabled, false)
|
|
623
|
+
await h.library.setPackageEnabled(h.cwd, first.package.id, true)
|
|
624
|
+
await h.library.setEnabled(h.cwd, quiet.id, true)
|
|
625
|
+
assert.equal((await h.root.skills.get('quiet-member', { cwd: h.cwd, scope: h.agent })).invocation.modelInvocable, true)
|
|
626
|
+
assert.equal((await h.root.skills.get('shared-member', { cwd: h.cwd, scope: h.agent })).description, 'project override')
|
|
627
|
+
})
|
|
628
|
+
|
|
629
|
+
test('a second filesystem provider in the same preset discovers its own independent package and releases it on disposal', async t => {
|
|
630
|
+
const h = await fixture(t)
|
|
631
|
+
const extra = join(h.temp, 'additional'), root = join(extra, 'compose')
|
|
632
|
+
await put(join(root, 'skills/outline/SKILL.md'), markdown('outline', 'outline'))
|
|
633
|
+
await put(join(root, 'skills/finalize/SKILL.md'), markdown('finalize', 'finalize'))
|
|
634
|
+
await h.library.list(h.cwd)
|
|
635
|
+
const more = await h.scope.ctx.plugin(filesystem, { includeDefaultRoots: false, customSkillDirs: [extra], providerName: 'additional-skills', watch: false })
|
|
636
|
+
try {
|
|
637
|
+
const members = (await h.library.list(h.cwd)).items.filter(item => item.package?.root === root)
|
|
638
|
+
assert.equal(members.length, 2)
|
|
639
|
+
assert.ok(members.every(item => item.category === 'provided' && !item.canToggle))
|
|
640
|
+
assert.equal((await h.root.skills.get('outline', { scope: h.agent, cwd: h.cwd })).content, 'outline')
|
|
641
|
+
} finally { await more.dispose() }
|
|
642
|
+
assert.equal((await h.library.refresh(h.cwd)).items.some(item => item.package?.root === root), false)
|
|
643
|
+
})
|
|
644
|
+
|
|
645
|
+
test('first disabling a verified unpacked family preserves its identity, readme and member invocation across remount', async t => {
|
|
646
|
+
const h = await fixture(t)
|
|
647
|
+
const directory = join(h.dsh, 'skills'), root = join(directory, '铺写'), marker = join(root, FAMILY_MARKER)
|
|
648
|
+
const first = await put(join(root, 'skills/check/SKILL.md'), markdown('check', 'Check files'))
|
|
649
|
+
const second = await put(join(root, 'skills/quiet/SKILL.md'), markdown('quiet', 'Quiet').replace('---\n\n', 'disable-model-invocation: true\n---\n\n'))
|
|
650
|
+
await put(join(root, 'package.json'), JSON.stringify({ name: '@example/checks' }))
|
|
651
|
+
const readme = await put(join(root, 'README.md'), '# 本地检查\n\n检查源文件。\n')
|
|
652
|
+
const before = await Promise.all([first, second, readme].map(path => readFile(path)))
|
|
653
|
+
let view = await h.library.refresh(h.cwd)
|
|
654
|
+
const pkg = view.items.find(row => row.name === 'check').package
|
|
655
|
+
assert.equal(pkg.name, '@example/checks')
|
|
656
|
+
assert.equal(pkg.canRemove, false)
|
|
657
|
+
assert.deepEqual([pkg.enabled, pkg.canToggle], [true, true])
|
|
658
|
+
await h.library.setPackageEnabled(h.cwd, pkg.id, true)
|
|
659
|
+
await assert.rejects(stat(marker), { code: 'ENOENT' })
|
|
660
|
+
view = await h.library.setPackageEnabled(h.cwd, pkg.id, false)
|
|
661
|
+
assert.deepEqual(view.items.map(row => [row.package.id, row.enabled]), [[pkg.id, false], [pkg.id, false]])
|
|
662
|
+
assert.equal(JSON.parse(await readFile(marker)).enabled, false)
|
|
663
|
+
assert.equal(view.items[0].package.canRemove, false)
|
|
664
|
+
await assert.rejects(stat(join(directory, FAMILY_MARKER)), { code: 'ENOENT' })
|
|
665
|
+
await h.fiber.dispose(); await h.start()
|
|
666
|
+
assert.equal((await h.library.list(h.cwd)).items[0].package.name, '@example/checks')
|
|
667
|
+
assert.equal((await h.root.skills.get('check', { cwd: h.cwd, scope: h.agent })).invocation.modelInvocable, false)
|
|
668
|
+
view = await h.library.setPackageEnabled(h.cwd, pkg.id, true)
|
|
669
|
+
assert.deepEqual(view.items.map(row => [row.name, row.enabled]), [['check', true], ['quiet', false]])
|
|
670
|
+
assert.deepEqual(await Promise.all([first, second, readme].map(path => readFile(path))), before)
|
|
671
|
+
})
|
|
672
|
+
|
|
673
|
+
test('only standalone owned entries can be removed and recovered after manager remount', async t => {
|
|
674
|
+
const h = await fixture(t)
|
|
675
|
+
const root = join(h.dsh, 'skills')
|
|
676
|
+
const flat = await put(join(root, 'notes.md'), markdown('notes', 'Flat personal skill'))
|
|
677
|
+
const safe = await put(join(root, 'chapter/SKILL.md'), markdown('chapter', 'Local directory skill'))
|
|
678
|
+
const asset = await put(join(root, 'chapter/docs/example.txt'), 'ordinary attachment')
|
|
679
|
+
const project = await put(join(h.project, '.dsh/skills/project.md'), markdown('project', 'Project skill'))
|
|
680
|
+
const shared = await put(join(h.agents, 'skills/shared.md'), markdown('shared', 'Shared source skill'))
|
|
681
|
+
const unsafe = await put(join(root, 'workspace/SKILL.md'), markdown('workspace', 'Surrounding workspace'))
|
|
682
|
+
const nested = await put(join(root, 'workspace/registered/keep.md'), markdown('keep', 'Another registered directory'))
|
|
683
|
+
const foreign = await put(join(h.bundle, 'native.md'), markdown('native', 'Shipped provider skill'))
|
|
684
|
+
const link = join(root, 'linked.md')
|
|
685
|
+
await symlink(await put(join(h.other, 'linked.md'), markdown('linked', 'External skill')), link)
|
|
686
|
+
await h.library.addDirectory(h.cwd, dirname(nested))
|
|
687
|
+
const initial = await h.library.refresh(h.cwd)
|
|
688
|
+
const item = name => initial.items.find(entry => entry.name === name)
|
|
689
|
+
for (const name of ['notes', 'chapter', 'project', 'shared', 'keep']) assert.equal(item(name)?.canRemove, true, name)
|
|
690
|
+
for (const name of ['workspace', 'native', 'linked']) assert.equal(item(name)?.canRemove, false, name)
|
|
691
|
+
await assert.rejects(h.library.prepareRemoval(h.cwd, 'skill', item('workspace').id), { code: 'REMOVAL_NOT_ALLOWED' })
|
|
692
|
+
const plan = await h.library.prepareRemoval(h.cwd, 'skill', item('chapter').id)
|
|
693
|
+
assert.equal(plan.path, dirname(safe))
|
|
694
|
+
assert.equal(plan.scope, 'directory')
|
|
695
|
+
await writeFile(asset, 'edited attachment')
|
|
696
|
+
await assert.rejects(h.library.commitRemoval(h.cwd, plan), { code: 'TARGET_CHANGED' })
|
|
697
|
+
assert.equal(await readFile(asset, 'utf8'), 'edited attachment')
|
|
698
|
+
|
|
699
|
+
const fresh = await h.library.prepareRemoval(h.cwd, 'skill', item('chapter').id)
|
|
700
|
+
const results = await Promise.allSettled([h.library.commitRemoval(h.cwd, fresh), h.library.commitRemoval(h.cwd, fresh)])
|
|
701
|
+
assert.deepEqual(results.map(result => result.status).sort(), ['fulfilled', 'rejected'])
|
|
702
|
+
const { receipt, snapshot } = results.find(result => result.status === 'fulfilled').value
|
|
703
|
+
assert.equal(snapshot.items.some(row => row.id === item('chapter').id), false)
|
|
704
|
+
await assert.rejects(stat(safe), { code: 'ENOENT' })
|
|
705
|
+
await h.fiber.dispose(); await h.start()
|
|
706
|
+
assert.deepEqual(await h.library.listRemovals(h.cwd), [receipt])
|
|
707
|
+
|
|
708
|
+
await mkdir(dirname(safe))
|
|
709
|
+
assert.equal((await h.library.listRemovals(h.cwd))[0].canRestore, false)
|
|
710
|
+
await assert.rejects(h.library.restoreRemoval(h.cwd, receipt.id), { code: 'TARGET_OCCUPIED' })
|
|
711
|
+
assert.deepEqual(await readdir(dirname(safe)), [])
|
|
712
|
+
const { directories } = await h.library.addDirectory(h.cwd, dirname(safe))
|
|
713
|
+
const registered = directories.find(dir => dir.path === dirname(safe))
|
|
714
|
+
await rmdir(dirname(safe))
|
|
715
|
+
assert.match((await h.library.listRemovals(h.cwd))[0].restoreReason, /来源重叠/)
|
|
716
|
+
await assert.rejects(h.library.restoreRemoval(h.cwd, receipt.id), { code: 'REMOVAL_NOT_ALLOWED' })
|
|
717
|
+
await h.library.removeDirectory(h.cwd, registered.id)
|
|
718
|
+
assert.equal((await h.library.listRemovals(h.cwd))[0].canRestore, true)
|
|
719
|
+
const restored = await h.library.restoreRemoval(h.cwd, receipt.id)
|
|
720
|
+
assert.equal(restored.snapshot.items.some(row => row.id === item('chapter').id), true)
|
|
721
|
+
assert.equal(restored.receipt.canRestore, false)
|
|
722
|
+
assert.deepEqual(await h.library.listRemovals(h.cwd), [])
|
|
723
|
+
assert.equal(await readFile(asset, 'utf8'), 'edited attachment')
|
|
724
|
+
for (const path of [flat, project, shared, foreign, unsafe, nested, link]) assert.ok(await stat(path))
|
|
725
|
+
})
|
|
726
|
+
|
|
727
|
+
test('flat removal rejects substituted files and a linked recycle area, and restores without disturbing siblings', async t => {
|
|
728
|
+
const h = await fixture(t)
|
|
729
|
+
const root = join(h.dsh, 'skills')
|
|
730
|
+
const instruction = markdown('skill', 'Flat fixture')
|
|
731
|
+
const file = await put(join(root, 'skill.md'), instruction)
|
|
732
|
+
const sibling = await put(join(root, 'notes.txt'), 'unrelated sibling')
|
|
733
|
+
const recycle = join(root, '.dsh-skill-removals')
|
|
734
|
+
const id = (await h.library.refresh(h.cwd)).items.find(row => row.name === 'skill').id
|
|
735
|
+
const prepare = () => h.library.prepareRemoval(h.cwd, 'skill', id)
|
|
736
|
+
const original = await prepare()
|
|
737
|
+
assert.equal(original.scope, 'file')
|
|
738
|
+
const moved = join(h.other, 'original.md')
|
|
739
|
+
await rename(file, moved)
|
|
740
|
+
await writeFile(file, instruction)
|
|
741
|
+
await assert.rejects(h.library.commitRemoval(h.cwd, original), { code: 'TARGET_CHANGED' })
|
|
742
|
+
assert.equal(await readFile(file, 'utf8'), instruction)
|
|
743
|
+
await symlink(h.other, recycle)
|
|
744
|
+
await assert.rejects(h.library.commitRemoval(h.cwd, await prepare()), { code: 'REMOVAL_NOT_ALLOWED' })
|
|
745
|
+
assert.deepEqual(await readdir(h.other), ['original.md'])
|
|
746
|
+
await unlink(recycle)
|
|
747
|
+
|
|
748
|
+
const { receipt } = await h.library.commitRemoval(h.cwd, await prepare())
|
|
749
|
+
await assert.rejects(stat(file), { code: 'ENOENT' })
|
|
750
|
+
await writeFile(file, 'new same-path file')
|
|
751
|
+
await assert.rejects(h.library.restoreRemoval(h.cwd, receipt.id), { code: 'TARGET_OCCUPIED' })
|
|
752
|
+
assert.equal(await readFile(file, 'utf8'), 'new same-path file')
|
|
753
|
+
await unlink(file)
|
|
754
|
+
await h.library.restoreRemoval(h.cwd, receipt.id)
|
|
755
|
+
assert.equal(await readFile(file, 'utf8'), instruction)
|
|
756
|
+
assert.equal(await readFile(sibling, 'utf8'), 'unrelated sibling')
|
|
757
|
+
assert.equal(await readFile(moved, 'utf8'), instruction)
|
|
758
|
+
})
|
|
759
|
+
|
|
760
|
+
test('installed action-card registrations are builtin only in their own scope layer', async t => {
|
|
761
|
+
const h = await fixture(t)
|
|
762
|
+
for (const [name, service] of Object.entries({ pluginManager: { async listBundles() { return [] } }, tools: { guard() {} },
|
|
763
|
+
agents: { list() { return [] } }, subagents: {}, profileContext: { dir: h.temp },
|
|
764
|
+
actionCards: { register() {}, skillProvider(candidate, get) { return () => ({ name: candidate.provider, async list() { return [candidate] }, get }) } } })) {
|
|
765
|
+
h.root.provide(name, service)
|
|
766
|
+
}
|
|
767
|
+
const creation = await h.root.plugin(hostRequire('@deepseek-ai/dsh-creation-recommendations'))
|
|
768
|
+
const plugins = await h.root.plugin(hostRequire('@deepseek-ai/dsh-plugin-recommendations'))
|
|
769
|
+
try {
|
|
770
|
+
const rows = (await h.library.refresh(h.cwd)).items
|
|
771
|
+
for (const name of ['personalized-pages', 'official-plugins']) {
|
|
772
|
+
const row = rows.find(item => item.name === name)
|
|
773
|
+
assert.equal(row?.category, 'builtin', name)
|
|
774
|
+
assert.equal(row.enabled, true)
|
|
775
|
+
assert.equal(row.canToggle, false)
|
|
776
|
+
assert.equal(row.package, null)
|
|
777
|
+
}
|
|
778
|
+
const substitute = await h.scope.ctx.plugin({ name: 'another-card-plugin', inject: ['skills'], apply(ctx) {
|
|
779
|
+
ctx.skills.registerProvider(() => ({ name: 'dsh-personalized-pages', async list() { return [{ name: 'personalized-pages',
|
|
780
|
+
description: 'external preset', provider: 'dsh-personalized-pages', invocation: { modelInvocable: true, userInvocable: false },
|
|
781
|
+
source: 'bundled', rank: 600, locator: null }] }, async get() {} }))
|
|
782
|
+
} })
|
|
783
|
+
try { assert.equal((await h.library.list(h.cwd)).items.find(row => row.name === 'personalized-pages').category, 'provided') } finally { await substitute.dispose() }
|
|
784
|
+
} finally { await plugins.dispose(); await creation.dispose() }
|
|
785
|
+
})
|