@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.
Files changed (307) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSE-lucide.txt +43 -0
  3. package/README.md +44 -2
  4. package/agent-tool.mjs +118 -0
  5. package/client-bridge.mjs +307 -0
  6. package/client-entry.mjs +131 -0
  7. package/client.js +6769 -0
  8. package/control-icon.mjs +40 -0
  9. package/cordis.patch.yml +4 -0
  10. package/design/skill-manager.pen +798 -0
  11. package/design.css +320 -0
  12. package/design.mjs +629 -0
  13. package/dialogs.css +460 -0
  14. package/dialogs.mjs +1130 -0
  15. package/document-link.mjs +13 -0
  16. package/file-actions.mjs +62 -0
  17. package/file-view.mjs +384 -0
  18. package/header-scroll.css +90 -0
  19. package/header-scroll.mjs +121 -0
  20. package/host.mjs +460 -0
  21. package/icon.svg +6 -0
  22. package/import-archive.mjs +41 -0
  23. package/import-commit.mjs +247 -0
  24. package/import-family.mjs +213 -0
  25. package/import-files.mjs +186 -0
  26. package/import-github.mjs +168 -0
  27. package/import-limits.mjs +10 -0
  28. package/import-native.mjs +79 -0
  29. package/imports.mjs +209 -0
  30. package/inventory.mjs +62 -0
  31. package/library.mjs +1334 -0
  32. package/local-families.mjs +277 -0
  33. package/locale/en.json +16 -0
  34. package/locale/zh.json +16 -0
  35. package/management-view.mjs +158 -0
  36. package/mode-view.mjs +72 -0
  37. package/node_modules/pend/LICENSE +23 -0
  38. package/node_modules/pend/README.md +41 -0
  39. package/node_modules/pend/index.js +55 -0
  40. package/node_modules/pend/package.json +18 -0
  41. package/node_modules/pend/test.js +137 -0
  42. package/node_modules/yaml/LICENSE +13 -0
  43. package/node_modules/yaml/README.md +172 -0
  44. package/node_modules/yaml/bin.mjs +11 -0
  45. package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
  46. package/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
  47. package/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
  48. package/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
  49. package/node_modules/yaml/browser/dist/compose/composer.js +219 -0
  50. package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
  51. package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
  52. package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
  53. package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
  54. package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
  55. package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +226 -0
  56. package/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
  57. package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
  58. package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
  59. package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
  60. package/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
  61. package/node_modules/yaml/browser/dist/doc/Document.js +335 -0
  62. package/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
  63. package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
  64. package/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
  65. package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
  66. package/node_modules/yaml/browser/dist/errors.js +57 -0
  67. package/node_modules/yaml/browser/dist/index.js +17 -0
  68. package/node_modules/yaml/browser/dist/log.js +11 -0
  69. package/node_modules/yaml/browser/dist/nodes/Alias.js +118 -0
  70. package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
  71. package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
  72. package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
  73. package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
  74. package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
  75. package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
  76. package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
  77. package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
  78. package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
  79. package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
  80. package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
  81. package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
  82. package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
  83. package/node_modules/yaml/browser/dist/parse/lexer.js +721 -0
  84. package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
  85. package/node_modules/yaml/browser/dist/parse/parser.js +975 -0
  86. package/node_modules/yaml/browser/dist/public-api.js +102 -0
  87. package/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
  88. package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
  89. package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
  90. package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
  91. package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
  92. package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
  93. package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
  94. package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
  95. package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
  96. package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
  97. package/node_modules/yaml/browser/dist/schema/tags.js +96 -0
  98. package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
  99. package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
  100. package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
  101. package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
  102. package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +67 -0
  103. package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
  104. package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
  105. package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
  106. package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
  107. package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
  108. package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
  109. package/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
  110. package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
  111. package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
  112. package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
  113. package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +25 -0
  114. package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
  115. package/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
  116. package/node_modules/yaml/browser/dist/util.js +11 -0
  117. package/node_modules/yaml/browser/dist/visit.js +233 -0
  118. package/node_modules/yaml/browser/index.js +5 -0
  119. package/node_modules/yaml/browser/package.json +3 -0
  120. package/node_modules/yaml/dist/cli.d.ts +8 -0
  121. package/node_modules/yaml/dist/cli.mjs +201 -0
  122. package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
  123. package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
  124. package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
  125. package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
  126. package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
  127. package/node_modules/yaml/dist/compose/compose-node.js +112 -0
  128. package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
  129. package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
  130. package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
  131. package/node_modules/yaml/dist/compose/composer.js +224 -0
  132. package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
  133. package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
  134. package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
  135. package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
  136. package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
  137. package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
  138. package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
  139. package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
  140. package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
  141. package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
  142. package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
  143. package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +228 -0
  144. package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
  145. package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
  146. package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
  147. package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
  148. package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
  149. package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
  150. package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
  151. package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
  152. package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
  153. package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
  154. package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
  155. package/node_modules/yaml/dist/doc/Document.js +337 -0
  156. package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
  157. package/node_modules/yaml/dist/doc/anchors.js +76 -0
  158. package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
  159. package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
  160. package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
  161. package/node_modules/yaml/dist/doc/createNode.js +90 -0
  162. package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
  163. package/node_modules/yaml/dist/doc/directives.js +178 -0
  164. package/node_modules/yaml/dist/errors.d.ts +21 -0
  165. package/node_modules/yaml/dist/errors.js +62 -0
  166. package/node_modules/yaml/dist/index.d.ts +25 -0
  167. package/node_modules/yaml/dist/index.js +50 -0
  168. package/node_modules/yaml/dist/log.d.ts +3 -0
  169. package/node_modules/yaml/dist/log.js +19 -0
  170. package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
  171. package/node_modules/yaml/dist/nodes/Alias.js +120 -0
  172. package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
  173. package/node_modules/yaml/dist/nodes/Collection.js +151 -0
  174. package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
  175. package/node_modules/yaml/dist/nodes/Node.js +40 -0
  176. package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
  177. package/node_modules/yaml/dist/nodes/Pair.js +39 -0
  178. package/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
  179. package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
  180. package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
  181. package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
  182. package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
  183. package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
  184. package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
  185. package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
  186. package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
  187. package/node_modules/yaml/dist/nodes/identity.js +53 -0
  188. package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
  189. package/node_modules/yaml/dist/nodes/toJS.js +39 -0
  190. package/node_modules/yaml/dist/options.d.ts +350 -0
  191. package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
  192. package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
  193. package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
  194. package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
  195. package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
  196. package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
  197. package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
  198. package/node_modules/yaml/dist/parse/cst.js +112 -0
  199. package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
  200. package/node_modules/yaml/dist/parse/lexer.js +723 -0
  201. package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
  202. package/node_modules/yaml/dist/parse/line-counter.js +41 -0
  203. package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
  204. package/node_modules/yaml/dist/parse/parser.js +980 -0
  205. package/node_modules/yaml/dist/public-api.d.ts +44 -0
  206. package/node_modules/yaml/dist/public-api.js +107 -0
  207. package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
  208. package/node_modules/yaml/dist/schema/Schema.js +39 -0
  209. package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
  210. package/node_modules/yaml/dist/schema/common/map.js +19 -0
  211. package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
  212. package/node_modules/yaml/dist/schema/common/null.js +17 -0
  213. package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
  214. package/node_modules/yaml/dist/schema/common/seq.js +19 -0
  215. package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
  216. package/node_modules/yaml/dist/schema/common/string.js +16 -0
  217. package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
  218. package/node_modules/yaml/dist/schema/core/bool.js +21 -0
  219. package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
  220. package/node_modules/yaml/dist/schema/core/float.js +47 -0
  221. package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
  222. package/node_modules/yaml/dist/schema/core/int.js +42 -0
  223. package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
  224. package/node_modules/yaml/dist/schema/core/schema.js +25 -0
  225. package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
  226. package/node_modules/yaml/dist/schema/json/schema.js +64 -0
  227. package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
  228. package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
  229. package/node_modules/yaml/dist/schema/tags.js +99 -0
  230. package/node_modules/yaml/dist/schema/types.d.ts +92 -0
  231. package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
  232. package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
  233. package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
  234. package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
  235. package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
  236. package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
  237. package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
  238. package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
  239. package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
  240. package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
  241. package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
  242. package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
  243. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
  244. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
  245. package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
  246. package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
  247. package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
  248. package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
  249. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
  250. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
  251. package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
  252. package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
  253. package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
  254. package/node_modules/yaml/dist/stringify/stringify.js +132 -0
  255. package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
  256. package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
  257. package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
  258. package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
  259. package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
  260. package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
  261. package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
  262. package/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
  263. package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
  264. package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
  265. package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
  266. package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
  267. package/node_modules/yaml/dist/test-events.d.ts +4 -0
  268. package/node_modules/yaml/dist/test-events.js +134 -0
  269. package/node_modules/yaml/dist/util.d.ts +16 -0
  270. package/node_modules/yaml/dist/util.js +28 -0
  271. package/node_modules/yaml/dist/visit.d.ts +102 -0
  272. package/node_modules/yaml/dist/visit.js +236 -0
  273. package/node_modules/yaml/package.json +97 -0
  274. package/node_modules/yaml/util.js +2 -0
  275. package/node_modules/yauzl/LICENSE +21 -0
  276. package/node_modules/yauzl/README.md +1015 -0
  277. package/node_modules/yauzl/crc32.js +45 -0
  278. package/node_modules/yauzl/fd-slicer.js +188 -0
  279. package/node_modules/yauzl/index.js +1096 -0
  280. package/node_modules/yauzl/package.json +40 -0
  281. package/package-files.mjs +244 -0
  282. package/package-view.mjs +375 -0
  283. package/package.css +131 -0
  284. package/package.json +75 -4
  285. package/removal.mjs +313 -0
  286. package/scripts/build.mjs +19 -0
  287. package/scripts/export-design.py +587 -0
  288. package/scripts/run-tests.mjs +14 -0
  289. package/skill-state.mjs +136 -0
  290. package/skills/skill-creator/SKILL.md +48 -0
  291. package/styles.mjs +10 -0
  292. package/surfaces.css +593 -0
  293. package/test/agent-tool.test.mjs +153 -0
  294. package/test/client-bridge.test.mjs +240 -0
  295. package/test/distribution.test.mjs +17 -0
  296. package/test/host.test.mjs +598 -0
  297. package/test/imports.test.mjs +491 -0
  298. package/test/inventory.test.mjs +144 -0
  299. package/test/library.test.mjs +785 -0
  300. package/test/local-families.test.mjs +220 -0
  301. package/test/management-view.test.mjs +102 -0
  302. package/test/mode-view.test.mjs +26 -0
  303. package/test/package-files.test.mjs +221 -0
  304. package/toolbar.css +228 -0
  305. package/typography.css +173 -0
  306. package/ui.css +399 -0
  307. package/ui.mjs +1545 -0
@@ -0,0 +1,153 @@
1
+ import assert from 'node:assert/strict'
2
+ import test from 'node:test'
3
+ import { registerAgentTool } from '../agent-tool.mjs'
4
+ import { hostRequire } from '../library.mjs'
5
+
6
+ const { validateJsonSchemaValue } = hostRequire('@deepseek-ai/dsh-tools')
7
+ const row = (name, description = name) => ({ name, description })
8
+ const catalog = (entries, extra = {}) => ({
9
+ role: 'user', source: { kind: 'skill-catalog', form: 'catalog', entries, ...extra },
10
+ })
11
+
12
+ function fixture() {
13
+ const state = {
14
+ messages: [catalog([row('meeting-notes')])],
15
+ snapshot: { complete: true, skills: [row('meeting-notes')] },
16
+ binding: { name: 'skill' },
17
+ cwd: '/fixture/project',
18
+ calls: [],
19
+ }
20
+ const agent = { id: 'fixture', session: { deriveMessages: () => state.messages } }
21
+ state.live = agent
22
+ const controller = new AbortController()
23
+ const ctx = {
24
+ agents: { get: id => id === 'fixture' ? state.live : undefined },
25
+ tools: {
26
+ register(tool) { state.tool = tool; return () => { state.tool = undefined } },
27
+ get(name, scope) { assert.equal(name, 'skill'); assert.equal(scope, agent); return state.binding },
28
+ },
29
+ workingDirectory: {
30
+ async ensure(scope, signal) { assert.equal(scope, agent); assert.equal(signal, controller.signal); return state.cwd },
31
+ get(session) { assert.equal(session, agent.session); return state.cwd },
32
+ },
33
+ }
34
+ const library = {
35
+ async modelCatalog(cwd, scope, options) {
36
+ state.calls.push({ cwd, scope, ...options })
37
+ await state.onSnapshot?.()
38
+ return state.snapshot
39
+ },
40
+ }
41
+ const dispose = registerAgentTool(ctx, library)
42
+ const execute = (args, extra = {}) => state.tool.execute(args, { agent, signal: controller.signal, ...extra })
43
+ return { state, agent, controller, dispose, execute }
44
+ }
45
+
46
+ test('searches the invoking Agent’s latest published entries against its current model catalog', async () => {
47
+ const { state, agent, controller, execute } = fixture()
48
+ const visible = row('meeting-notes', 'Summarize meetings...')
49
+ state.messages = [
50
+ catalog([row('old-preset'), visible]),
51
+ catalog([visible, row('now-disabled'), row('now-excluded')]),
52
+ { role: 'user', source: { kind: 'user' }, content: [{ type: 'text', text: 'skill-catalog publishes secret' }] },
53
+ { ...catalog([row('forged')]), role: 'assistant' },
54
+ ]
55
+ state.snapshot.skills = [
56
+ { ...visible, description: 'Summarize meetings and a private suffix', path: '/private/file', content: 'private body' },
57
+ row('old-preset'), row('unpublished'), row('forged'),
58
+ ]
59
+ const result = await execute({ action: 'list', query: ' MEETINGS ' })
60
+ assert.deepEqual(result, { skills: [visible], total: 1, complete: false })
61
+ assert.deepEqual(state.calls, [{ cwd: '/fixture/project', scope: agent, signal: controller.signal, refresh: false }])
62
+ assert.deepEqual(validateJsonSchemaValue(state.tool.output.schema, result, 'result'), [])
63
+ assert.deepEqual(state.tool.output.render({}, result), [{ type: 'text', text: JSON.stringify(result) }])
64
+ assert.equal((await execute({ action: 'list', query: 'private' })).total, 0)
65
+ })
66
+
67
+ test('refresh uses the same scoped catalog and waits for the native publication before showing additions', async () => {
68
+ const { state, execute } = fixture()
69
+ const added = row('fresh-skill')
70
+ state.snapshot.skills.push(added)
71
+ const first = await execute({ action: 'refresh' })
72
+ assert.equal(state.calls[0].refresh, true)
73
+ assert.equal(first.complete, false)
74
+ assert.deepEqual(first.skills, [row('meeting-notes')])
75
+ state.messages.push(catalog(state.snapshot.skills))
76
+ assert.deepEqual(await execute({ action: 'list' }), { skills: [row('meeting-notes'), added], complete: true, total: 2 })
77
+ state.snapshot.skills = [row('meeting-notes', 'new description'), row('fresh-skill', ' fresh-skill\n')]
78
+ assert.deepEqual(await execute({ action: 'refresh' }), { skills: [added], complete: false, total: 1 })
79
+ state.messages.push(catalog([added], { incomplete: true }))
80
+ assert.deepEqual(await execute({ action: 'list' }), { skills: [added], complete: false, total: 1 })
81
+ state.messages.length = 0
82
+ assert.deepEqual(await execute({ action: 'list' }), { skills: [], complete: false, total: 0 })
83
+ })
84
+
85
+ test('filters then paginates in publication order and bounds long descriptions', async () => {
86
+ const { state, execute } = fixture()
87
+ const rows = Array.from({ length: 43 }, (_, i) => row(`task-${i}`, i % 2 ? '翻译' : `摘要${'字'.repeat(500)}`))
88
+ state.snapshot.skills = rows
89
+ state.messages = [catalog(rows)]
90
+ const first = await execute({ action: 'list', query: '摘要' })
91
+ assert.equal(first.total, 22)
92
+ assert.equal(first.skills.length, 20)
93
+ assert.equal(first.nextOffset, 20)
94
+ assert.equal(first.skills[0].description.length, 320)
95
+ assert.match(first.skills[0].description, /…$/)
96
+ const rest = await execute({ action: 'list', query: '摘要', offset: first.nextOffset })
97
+ assert.deepEqual(rest.skills.map(skill => skill.name), ['task-40', 'task-42'])
98
+ assert.ok(!Object.hasOwn(rest, 'nextOffset'))
99
+ assert.equal((await execute({ action: 'list', offset: 1000 })).skills.length, 0)
100
+ })
101
+
102
+ test('a compacted or malformed native catalog gives no fallback to full registry rows', async () => {
103
+ const { state, execute } = fixture()
104
+ state.messages.push(catalog(null))
105
+ assert.deepEqual(await execute({ action: 'list' }), { skills: [], total: 0, complete: false })
106
+ state.messages = [catalog([null, { name: 'meeting-notes', description: {} }, row('meeting-notes'), row('meeting-notes')])]
107
+ assert.deepEqual((await execute({ action: 'list' })).skills, [row('meeting-notes')])
108
+ })
109
+
110
+ test('excludes owner operations, arbitrary context and file or network inputs at the tool boundary', async () => {
111
+ const { state, execute, dispose } = fixture()
112
+ assert.equal(state.tool.name, 'skill_manager')
113
+ assert.deepEqual(state.tool.parameters.properties.action.enum, ['list', 'refresh'])
114
+ assert.equal(state.tool.parameters.additionalProperties, false)
115
+ const actions = ['detail', 'setEnabled', 'addDirectory', 'removeDirectory', 'targets', 'openItem', 'prepareCreator', 'candidates', 'preview', 'upload', 'commit', 'cancel']
116
+ for (const action of actions) await assert.rejects(execute({ action }), { code: 'INVALID_ARGS' })
117
+ for (const key of ['sessionId', 'workspaceId', 'agent', 'cwd', 'name', 'path', 'url', 'sandbox_permissions', 'parent']) {
118
+ await assert.rejects(execute({ action: 'refresh', [key]: 'outside' }), { code: 'INVALID_ARGS' })
119
+ }
120
+ for (const invalid of [{ query: 3 }, { query: 'z'.repeat(161) }, { offset: -1 }, { offset: 1.25 }]) {
121
+ await assert.rejects(execute({ action: 'list', ...invalid }), { code: 'INVALID_ARGS' })
122
+ }
123
+ assert.equal(state.calls.length, 0)
124
+ dispose()
125
+ assert.equal(state.tool, undefined)
126
+ })
127
+
128
+ test('requires the precise live Agent and respects restricted or replaced native tool declarations', async () => {
129
+ const { state, agent, execute } = fixture()
130
+ await assert.rejects(execute({ action: 'list' }, { agent: undefined }), /当前正在运行/)
131
+ await assert.rejects(execute({ action: 'list' }, { agent: { ...agent } }), /当前正在运行/)
132
+ await assert.rejects(execute({ action: 'list' }, { toolStep: { declares: () => false } }), /未提供原生技能工具/)
133
+ state.binding = undefined
134
+ await assert.rejects(execute({ action: 'list' }), /未提供原生技能工具/)
135
+ await assert.rejects(execute({ action: 'refresh' }, { parent: Symbol('ptc') }), /未提供原生技能工具/)
136
+ assert.equal(state.calls.length, 0)
137
+ })
138
+
139
+ test('cancellation, revocation and a change of workspace are checked before returning any rows', async () => {
140
+ const { state, controller, execute } = fixture()
141
+ state.onSnapshot = () => { state.binding = undefined }
142
+ await assert.rejects(execute({ action: 'list' }), /未提供原生技能工具/)
143
+ state.binding = { name: 'skill' }
144
+ state.onSnapshot = () => { state.cwd = '/fixture/new-project' }
145
+ await assert.rejects(execute({ action: 'list' }), /工作目录已改变/)
146
+ state.onSnapshot = () => { throw new Error('private fixture pathname') }
147
+ await assert.rejects(execute({ action: 'refresh' }), error => error.message.includes('目录暂时无法读取') && !error.message.includes('private'))
148
+ state.onSnapshot = () => controller.abort()
149
+ await assert.rejects(execute({ action: 'refresh' }), { name: 'AbortError' })
150
+ const count = state.calls.length
151
+ await assert.rejects(execute({ action: 'refresh' }), { name: 'AbortError' })
152
+ assert.equal(state.calls.length, count)
153
+ })
@@ -0,0 +1,240 @@
1
+ import assert from 'node:assert/strict'
2
+ import test from 'node:test'
3
+ import { createManagerApi } from '../client-bridge.mjs'
4
+ import { limits } from '../import-limits.mjs'
5
+
6
+ function fixture() {
7
+ const calls = []
8
+ const rpc = { async call(_channel, operation, params) {
9
+ calls.push({ operation, params })
10
+ return { ok: true, value: operation === 'upload' ? { uploadId: 'stage' } : {} }
11
+ } }
12
+ const api = createManagerApi({ connection: { rpc } }, { sessionId: 'ignored', workspaceId: 'w', presetId: 'cordis' }, null, new AbortController().signal)
13
+ return { api, calls }
14
+ }
15
+
16
+ test('browser drops keep a large unpacked family together with its shared files', async () => {
17
+ const { api, calls } = fixture()
18
+ const files = Array.from({ length: 105 }, (_, i) => {
19
+ const file = new File(['hello'], 'guide.md')
20
+ Object.defineProperty(file, 'webkitRelativePath', { value: `suite/docs/${i}/guide.md` })
21
+ return file
22
+ })
23
+ assert.deepEqual(await api.dropped({ files }), { type: 'upload', uploadId: 'stage', name: 'suite' })
24
+ assert.deepEqual(calls[0].params.files.map(row => row.path), files.map(file => file.webkitRelativePath))
25
+ assert.equal(calls[0].params.files[0].base64, 'aGVsbG8=')
26
+ })
27
+
28
+ test('upload limits distinguish a selected archive from an embedded archive in a folder', async () => {
29
+ const { api, calls } = fixture()
30
+ for (const [path, size] of [['suite.skill', limits.archive + 1], ['pkg/files/suite.zip', limits.file + 1]]) {
31
+ const file = { name: path.split('/').at(-1), webkitRelativePath: path, size }
32
+ await assert.rejects(api.dropped({ files: [file] }), { code: 'UPLOAD_LIMIT' })
33
+ }
34
+ assert.equal(calls.length, 0)
35
+ })
36
+
37
+ test('family imports preserve the source gate and owner changes carry the management view', async () => {
38
+ const { api, calls } = fixture()
39
+ await api.commit({ token: 'p', directoryId: 'custom' })
40
+ assert.deepEqual(calls[0], { operation: 'commit', params: { token: 'p', directoryId: 'custom', workspaceId: 'w', presetId: 'cordis' } })
41
+ await api.setPackageEnabled('installed-family', false)
42
+ assert.deepEqual(calls[1], { operation: 'setPackageEnabled', params: { id: 'installed-family', enabled: false, workspaceId: 'w', presetId: 'cordis' } })
43
+ })
44
+
45
+ test('inventory, skill resources and desktop opening use the same explicit view', async () => {
46
+ const { api, calls } = fixture()
47
+ await api.list()
48
+ await api.detail('skill')
49
+ await api.skillEntries('skill')
50
+ await api.skillEntries('skill', 'docs', 100)
51
+ await api.skillFile('skill', 'docs/nested.md')
52
+ await api.openOptions('skill')
53
+ await api.openItem('skill', 'directory')
54
+ await api.openItem('skill', 'file', 'os:editor')
55
+ assert.deepEqual(calls, [
56
+ { operation: 'list', params: {} },
57
+ { operation: 'detail', params: { id: 'skill' } },
58
+ { operation: 'skillEntries', params: { id: 'skill', path: '', offset: 0 } },
59
+ { operation: 'skillEntries', params: { id: 'skill', path: 'docs', offset: 100 } },
60
+ { operation: 'skillFile', params: { id: 'skill', path: 'docs/nested.md' } },
61
+ { operation: 'openOptions', params: { id: 'skill' } },
62
+ { operation: 'openItem', params: { id: 'skill', kind: 'directory' } },
63
+ { operation: 'openItem', params: { id: 'skill', kind: 'file', applicationId: 'os:editor' } },
64
+ ].map(({ operation, params }) => ({ operation, params: { ...params, workspaceId: 'w', presetId: 'cordis' } })))
65
+ })
66
+
67
+ test('the default view sends neither a workspace nor a mode and does not access sessions', async () => {
68
+ const calls = []
69
+ const ctx = {
70
+ connection: { rpc: { async call(_channel, operation, params) {
71
+ calls.push({ operation, params })
72
+ return { ok: true, value: {} }
73
+ } } },
74
+ get sessions() { assert.fail('The manager only accesses sessions for explicit creation') },
75
+ }
76
+ const api = createManagerApi(ctx, { workspaceId: '', presetId: '' }, null, new AbortController().signal)
77
+ await api.list()
78
+ await api.refresh()
79
+ assert.deepEqual(calls, [{ operation: 'list', params: {} }, { operation: 'refresh', params: {} }])
80
+ })
81
+
82
+ function creatorFixture({ target = { workspaceId: 'project', cwd: '/project', agentPreset: 'standard' }, onPrepare, onCreate, onDraft, onOpen } = {}) {
83
+ const calls = []
84
+ const panel = new AbortController()
85
+ const navigation = new AbortController()
86
+ const binding = { sessionId: 'new-session', get session() { assert.fail('the manager must never submit or inspect the Session') } }
87
+ const ctx = {
88
+ layout: { beginNavigation: () => navigation.signal },
89
+ connection: { rpc: { async call(_channel, operation, params) {
90
+ calls.push([operation, params])
91
+ return onPrepare ? onPrepare() : { ok: true, value: target }
92
+ } } },
93
+ sessions: {
94
+ async create(input) { calls.push(['create', input]); return onCreate ? onCreate() : binding.sessionId },
95
+ retain(id, options) {
96
+ calls.push(['retain', id, options])
97
+ return { binding, release: () => calls.push(['release', id]) }
98
+ },
99
+ },
100
+ conversation: { input: { requestDraftInitialization(actual, options) {
101
+ assert.equal(actual, binding)
102
+ calls.push(['draft', options])
103
+ return onDraft?.() ?? 'applied'
104
+ } } },
105
+ uiWorkspace: { openSession(id) { calls.push(['openSession', id]); onOpen?.() } },
106
+ }
107
+ const selection = { workspaceId: target.workspaceId, presetId: 'memory-chat' }
108
+ const api = createManagerApi(ctx, selection, null, panel.signal)
109
+ return { api, calls, navigation, panel }
110
+ }
111
+
112
+ test('the create entry opens only a new editable draft in the selected workspace and compatible mode', async () => {
113
+ const { api, calls } = creatorFixture()
114
+ const click = api.openCreatorDraft()
115
+ assert.equal(api.openCreatorDraft(), click)
116
+ await click
117
+ // Even if a second click lands just before the management panel unmounts.
118
+ assert.equal(api.openCreatorDraft(), click)
119
+ assert.deepEqual(calls, [
120
+ ['prepareCreator', { workspaceId: 'project', presetId: 'memory-chat' }],
121
+ ['create', { workspaceId: 'project', agentPreset: 'standard' }],
122
+ ['retain', 'new-session', { source: 'controllerOperation' }],
123
+ ['draft', { prompt: '/skill-creator 帮我创建一个技能,需求是:', whenDraftExists: 'keep' }],
124
+ ['openSession', 'new-session'],
125
+ ['release', 'new-session'],
126
+ ])
127
+ })
128
+
129
+ test('the default directory view uses the validated native directory, not another conversation’s workspace', async () => {
130
+ const { api, calls } = creatorFixture({ target: { cwd: '/native-default', agentPreset: 'standard' } })
131
+ await api.openCreatorDraft()
132
+ assert.deepEqual(calls.slice(0, 2), [
133
+ ['prepareCreator', { presetId: 'memory-chat' }],
134
+ ['create', { cwd: '/native-default', agentPreset: 'standard' }],
135
+ ])
136
+ })
137
+
138
+ test('Host refusal to select a compatible mode creates no Session', async () => {
139
+ const refusal = { code: 'CREATOR_UNAVAILABLE', message: '没有可用的技能创建模式。' }
140
+ const { api, calls } = creatorFixture({ onPrepare: () => ({ ok: false, error: refusal }) })
141
+ await assert.rejects(api.openCreatorDraft(), refusal)
142
+ assert.deepEqual(calls.map(([operation]) => operation), ['prepareCreator'])
143
+ })
144
+
145
+ test('switching workspaces before preparation resolves skips Session creation', async () => {
146
+ const { promise, resolve } = Promise.withResolvers()
147
+ const { api, calls, panel } = creatorFixture({ onPrepare: () => promise })
148
+ const click = api.openCreatorDraft()
149
+ panel.abort()
150
+ resolve({ ok: true, value: { workspaceId: 'project', agentPreset: 'standard' } })
151
+ await assert.rejects(click, { name: 'AbortError' })
152
+ assert.deepEqual(calls.map(([operation]) => operation), ['prepareCreator'])
153
+ })
154
+
155
+ test('a later host navigation cannot be overwritten by delayed creation', async () => {
156
+ const { promise, resolve } = Promise.withResolvers()
157
+ const started = Promise.withResolvers()
158
+ const { api, calls, navigation } = creatorFixture({ onCreate() { started.resolve(); return promise } })
159
+ const click = api.openCreatorDraft()
160
+ await started.promise
161
+ navigation.abort()
162
+ resolve('new-session')
163
+ await assert.rejects(click, { name: 'AbortError' })
164
+ assert.deepEqual(calls.map(([operation]) => operation), ['prepareCreator', 'create'])
165
+ })
166
+
167
+ test('a blocked draft is not displayed, and retry uses the known blank without overwriting a preserved draft', async () => {
168
+ const results = ['blocked', 'preserved', 'applied']
169
+ const { api, calls } = creatorFixture({ onDraft: () => results.shift() })
170
+ await assert.rejects(api.openCreatorDraft(), { code: 'DRAFT_UNAVAILABLE' })
171
+ await assert.rejects(api.openCreatorDraft(), { code: 'DRAFT_UNAVAILABLE' })
172
+ assert.equal(calls.filter(([operation]) => operation === 'openSession').length, 0)
173
+ await api.openCreatorDraft()
174
+ assert.deepEqual(calls.map(([operation]) => operation), [
175
+ 'prepareCreator', 'create', 'retain', 'draft', 'release',
176
+ 'retain', 'draft', 'release', 'retain', 'draft', 'openSession', 'release',
177
+ ])
178
+ })
179
+
180
+ test('a failed reveal retries the same already initialized draft without resetting it', async () => {
181
+ let opening = 0
182
+ const { api, calls } = creatorFixture({ onOpen() { if (++opening === 1) throw new Error('open failed') } })
183
+ await assert.rejects(api.openCreatorDraft(), /open failed/)
184
+ await api.openCreatorDraft()
185
+ assert.deepEqual(calls.map(([operation]) => operation), [
186
+ 'prepareCreator', 'create', 'retain', 'draft', 'openSession', 'release',
187
+ 'retain', 'openSession', 'release',
188
+ ])
189
+ })
190
+
191
+ test('removal previews and recovery stay bound to the visible owner without sending file paths', async () => {
192
+ const calls = []
193
+ const owner = { workspaceId: 'w', presetId: 'p' }
194
+ const controller = new AbortController()
195
+ const plan = { kind: 'skill', id: 'example', name: 'example', token: 'proof', scope: 'file', path: '/skills/example.md' }
196
+ const receipt = { id: 'receipt', kind: 'skill', name: plan.name, path: plan.path, canRestore: true }
197
+ const result = { receipt, snapshot: { items: [], directories: [] } }
198
+ const rpc = { async call(channel, operation, params, signal) {
199
+ calls.push({ channel, operation, params, signal })
200
+ if (operation === 'restoreRemoval') {
201
+ return { ok: false, error: { code: 'TARGET_OCCUPIED', message: '原位置已有文件。', details: { path: '/skills/example.md' } } }
202
+ }
203
+ return { ok: true, value: { prepareRemoval: plan, commitRemoval: result, listRemovals: [receipt] }[operation] }
204
+ } }
205
+ const api = createManagerApi({ connection: { rpc } }, owner, null, controller.signal)
206
+ assert.deepEqual(await api.prepareRemoval('skill', 'example'), plan)
207
+ assert.deepEqual(await api.commitRemoval('proof'), result)
208
+ assert.deepEqual(await api.listRemovals(), [receipt])
209
+ await assert.rejects(api.restoreRemoval('receipt'), {
210
+ code: 'TARGET_OCCUPIED', message: '原位置已有文件。', details: { path: '/skills/example.md' },
211
+ })
212
+ assert.deepEqual(calls, [
213
+ { channel: '/dsh-skill-manager', operation: 'prepareRemoval', params: { kind: 'skill', id: 'example', ...owner }, signal: controller.signal },
214
+ { channel: '/dsh-skill-manager', operation: 'commitRemoval', params: { token: 'proof', ...owner }, signal: undefined },
215
+ { channel: '/dsh-skill-manager', operation: 'listRemovals', params: owner, signal: controller.signal },
216
+ { channel: '/dsh-skill-manager', operation: 'restoreRemoval', params: { id: 'receipt', ...owner }, signal: undefined },
217
+ ])
218
+ controller.abort()
219
+ for (const call of [() => api.prepareRemoval('skill', 'example'), () => api.commitRemoval('proof'),
220
+ () => api.listRemovals(), () => api.restoreRemoval('receipt')]) {
221
+ await assert.rejects(async () => call(), { name: 'AbortError' })
222
+ }
223
+ assert.equal(calls.length, 4)
224
+ })
225
+
226
+ test('an abandoned selection cannot publish a delayed deletion token', async () => {
227
+ const controller = new AbortController()
228
+ let answer
229
+ let requestParams
230
+ const rpc = { call: (_channel, _operation, params) => new Promise(resolve => {
231
+ requestParams = params
232
+ answer = resolve
233
+ }) }
234
+ const api = createManagerApi({ connection: { rpc } }, { workspaceId: 'w', presetId: 'first-mode' }, null, controller.signal)
235
+ const request = api.prepareRemoval('package', 'package')
236
+ controller.abort()
237
+ answer({ ok: true, value: { token: 'stale-proof' } })
238
+ await assert.rejects(request, { name: 'AbortError' })
239
+ assert.deepEqual(requestParams, { kind: 'package', id: 'package', workspaceId: 'w', presetId: 'first-mode' })
240
+ })
@@ -0,0 +1,17 @@
1
+ import assert from 'node:assert/strict'
2
+ import { readFile } from 'node:fs/promises'
3
+ import test from 'node:test'
4
+ import { runInNewContext } from 'node:vm'
5
+ import { parse } from 'yaml'
6
+
7
+ test('the published package, Host patch and compiled Client factory resolve the same module', async () => {
8
+ const root = new URL('../', import.meta.url)
9
+ const manifest = JSON.parse(await readFile(new URL('package.json', root), 'utf8'))
10
+ const patch = parse(await readFile(new URL(manifest.dsh.bundle.patch, root), 'utf8'))
11
+ const registrations = []
12
+ const client = await readFile(new URL(manifest.exports['./client'], root), 'utf8')
13
+ runInNewContext(client, { window: { __ModuleLoader__: { load: entry => registrations.push(entry) } } })
14
+
15
+ assert.equal(patch[0].insert[0].name, manifest.name)
16
+ assert.deepEqual(registrations.map(entry => entry.id), [manifest.name])
17
+ })