@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
package/package.css ADDED
@@ -0,0 +1,131 @@
1
+ .sm-ui-page[data-view="package"] {
2
+ --sm-package-gutter: clamp(24px, 4vw, 48px);
3
+ max-inline-size: calc(960px + 2 * var(--sm-package-gutter));
4
+ padding: 0 var(--sm-package-gutter) 48px;
5
+ }
6
+ @media (max-width: 767px) {
7
+ .sm-ui-page[data-view="package"] { --sm-package-gutter: 20px; }
8
+ }
9
+
10
+ :is(.sm-package, .sm-file-view) { min-inline-size: 0; color: var(--sm-ink); }
11
+ :is(.sm-package, .sm-file-view)[hidden], :is(.sm-package, .sm-file-view) [hidden] { display: none !important; }
12
+ :is(.sm-package, .sm-file-view) :is(h1, p, pre, ul, ol):not(:where(.sm-document-scroll *)) { margin: 0; }
13
+ .sm-pkg-top { display: flex; padding-block-start: 28px; }
14
+ [data-platform="darwin"] .sm-pkg-top { padding-block-start: calc(28px + var(--dsh-frame-top-clearance, 0px)); }
15
+ .sm-package .sm-pkg-tile { margin-block: 32px 20px; color: var(--sm-muted); }
16
+ .sm-pkg-identity, .sm-pkg-description { display: block; overflow-wrap: anywhere; }
17
+ .sm-package .sm-pkg-identity { margin-block-start: 4px; color: var(--sm-tertiary); font: 400 12px/18px var(--sm-font-mono); }
18
+ .sm-package .sm-pkg-description { margin-block-start: 8px; color: var(--sm-muted); font: 400 14px/22px var(--sm-font); }
19
+ .sm-package .sm-pkg-gate { gap: 12px; padding-block: 18px 12px; border-color: var(--dsw-alias-border-l2, var(--sm-line)); }
20
+ .sm-pkg-gate h2 { margin: 0; font: 500 14px/20px var(--sm-font); }
21
+ .sm-package .sm-pkg-gate-error { color: var(--sm-ui-error); font: 400 12px/18px var(--sm-font); overflow-wrap: anywhere; }
22
+ .sm-pkg-gate-error:empty { display: none; }
23
+
24
+ .sm-pkg-tabs { margin-block: 28px 24px; }
25
+ .sm-pkg-tabs .sm-ui-tabs { inline-size: 244px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
26
+ .sm-pkg-tabs .sm-ui-tabs::before { width: calc((100% - 4px) / 2); }
27
+ .sm-pkg-tabs .sm-ui-tab { gap: 5px; }
28
+ .sm-pkg-total { font-size: 12px; font-variant-numeric: tabular-nums; }
29
+ .sm-pkg-panel { min-inline-size: 0; }
30
+ .sm-pkg-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-block-end: 12px; }
31
+ .sm-pkg-filters .sm-ui-search { flex: 1 1 150px; min-inline-size: 0; margin: 0; }
32
+ .sm-pkg-filters .sm-pkg-filter {
33
+ min-block-size: 32px;
34
+ max-inline-size: 100%;
35
+ gap: 6px;
36
+ }
37
+ :is(.sm-package, .sm-file-view) :is(.sm-pkg-note, .sm-pkg-file-meta) {
38
+ margin-block: 8px 12px;
39
+ color: var(--sm-muted);
40
+ font: 400 13px/20px var(--sm-font);
41
+ overflow-wrap: anywhere;
42
+ }
43
+ :is(.sm-package, .sm-file-view) .sm-pkg-list { list-style: none; padding: 0; }
44
+ .sm-pkg-list > li + li { border-block-start: 0.5px solid var(--dsw-alias-border-l2, var(--sm-line)); }
45
+ .sm-pkg-row {
46
+ display: flex;
47
+ align-items: center;
48
+ gap: 10px;
49
+ min-inline-size: 0;
50
+ min-block-size: 40px;
51
+ inline-size: 100%;
52
+ padding: 8px 2px;
53
+ border: 0;
54
+ border-radius: var(--dsw-radius-sm, 8px);
55
+ background: transparent;
56
+ color: var(--sm-ink);
57
+ text-align: start;
58
+ font: 400 13px/20px var(--sm-font);
59
+ }
60
+ :is(.sm-package, .sm-file-view) button.sm-pkg-row, .sm-pkg-crumb { cursor: pointer; }
61
+ .sm-pkg-member { gap: 16px; padding-block: 12px; }
62
+ .sm-pkg-member-icon {
63
+ flex: none;
64
+ display: grid;
65
+ place-items: center;
66
+ inline-size: 40px;
67
+ block-size: 40px;
68
+ border: 0.5px solid var(--dsw-alias-border-l3, var(--sm-control-line));
69
+ border-radius: var(--dsw-radius-md, 12px);
70
+ }
71
+ .sm-pkg-copy { display: grid; gap: 2px; }
72
+ .sm-pkg-copy, .sm-pkg-entry-name { flex: 1; min-inline-size: 0; overflow-wrap: anywhere; }
73
+ .sm-pkg-name { color: var(--sm-ink); font: 500 13.5px/20px var(--sm-font); }
74
+ .sm-pkg-list :is([data-state="off"], [data-state="excluded"], [data-state="shadowed"]) .sm-pkg-name { color: var(--sm-muted); }
75
+ .sm-pkg-desc {
76
+ display: -webkit-box;
77
+ overflow: hidden;
78
+ -webkit-box-orient: vertical;
79
+ -webkit-line-clamp: 2;
80
+ color: var(--sm-tertiary);
81
+ font: 400 13px/18px var(--sm-font);
82
+ }
83
+ .sm-pkg-state, .sm-pkg-entry-meta { color: var(--sm-muted); font: 400 12px/18px var(--sm-font); }
84
+ .sm-pkg-state { flex: none; max-inline-size: 32%; overflow-wrap: anywhere; text-align: end; }
85
+ .sm-pkg-entry-meta { max-inline-size: 38%; text-align: end; overflow-wrap: anywhere; }
86
+ .sm-pkg-arrow { color: var(--sm-tertiary); transform: rotate(180deg); }
87
+ .sm-pkg-link { color: var(--sm-muted); }
88
+
89
+ .sm-pkg-root { display: grid; gap: 4px; min-inline-size: 0; margin-block-end: 10px; }
90
+ .sm-pkg-root-label { color: var(--sm-muted); font: 400 12px/18px var(--sm-font); }
91
+ .sm-pkg-root-value {
92
+ user-select: text;
93
+ white-space: pre-wrap;
94
+ overflow-wrap: anywhere;
95
+ color: var(--sm-ink);
96
+ font: 400 12px/18px var(--sm-font-mono);
97
+ }
98
+ .sm-pkg-path, .sm-pkg-crumbs, .sm-pkg-crumbs li { min-inline-size: 0; display: flex; gap: 6px; align-items: center; }
99
+ .sm-pkg-path { margin-block-end: 10px; }
100
+ .sm-file-view .sm-pkg-path > button { flex: none; }
101
+ .sm-file-view .sm-pkg-crumbs { flex-wrap: wrap; list-style: none; padding: 0; font: 400 13px/20px var(--sm-font); }
102
+ .sm-pkg-crumbs li { max-inline-size: 100%; }
103
+ .sm-pkg-crumbs li + li::before { content: '/'; color: var(--sm-tertiary); }
104
+ .sm-pkg-crumbs [aria-current], .sm-pkg-crumb { min-inline-size: 0; overflow-wrap: anywhere; }
105
+ .sm-pkg-crumb { padding: 2px; border: 0; border-radius: 4px; background: transparent; color: var(--sm-muted); font: inherit; text-align: start; }
106
+ .sm-file-view .sm-pkg-more { min-block-size: 28px; margin-block-start: 12px; padding-inline: 10px; font: 400 12px/18px var(--sm-font); }
107
+ .sm-pkg-more[aria-disabled="true"] { opacity: .4; cursor: progress; }
108
+ .sm-file-view .sm-pkg-file-text {
109
+ min-inline-size: 0;
110
+ padding: 14px 16px;
111
+ border: .5px solid var(--dsw-alias-border-l3, var(--sm-line));
112
+ border-radius: var(--dsw-radius-md, 12px);
113
+ background: var(--dsw-alias-bg-layer-1, var(--sm-bg));
114
+ color: var(--sm-ink);
115
+ white-space: pre-wrap;
116
+ overflow-wrap: anywhere;
117
+ tab-size: 4;
118
+ font: 400 12.5px/20px var(--sm-font-mono);
119
+ }
120
+ :is(.sm-package, .sm-file-view) :is(.sm-pkg-row, .sm-pkg-filter, .sm-pkg-file-text, .sm-pkg-crumb, .sm-pkg-crumbs [aria-current]):focus-visible {
121
+ outline: var(--dsw-focus-ring-width, 2px) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
122
+ outline-offset: -2px;
123
+ }
124
+ @media (hover: hover) {
125
+ .sm-pkg-crumb:hover { color: var(--sm-ink); }
126
+ button.sm-pkg-row:hover :is(.sm-pkg-name, .sm-pkg-entry-name) { text-decoration: underline; text-underline-offset: 3px; }
127
+ }
128
+ @container sm-ui (width < 480px) {
129
+ .sm-pkg-member { gap: 8px; }
130
+ .sm-pkg-row:not(.sm-pkg-member) { gap: 6px; }
131
+ }
package/package.json CHANGED
@@ -1,6 +1,77 @@
1
1
  {
2
2
  "name": "@kafukatree/dsh-skill-manager",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.1",
4
+ "type": "module",
5
+ "description": "A DeepSeek Harness sidebar for browsing, importing, and creating agent skills by workspace and mode.",
6
+ "license": "MIT",
7
+ "author": "KafukaTree",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/KafukaTree/dsh-skill-manager.git"
11
+ },
12
+ "homepage": "https://github.com/KafukaTree/dsh-skill-manager#readme",
13
+ "bugs": { "url": "https://github.com/KafukaTree/dsh-skill-manager/issues" },
14
+ "keywords": ["deepseek-harness", "dsh", "agent-skills", "skill-manager", "plugin"],
15
+ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
16
+ "main": "./host.mjs",
17
+ "exports": {
18
+ ".": "./host.mjs",
19
+ "./client": "./client.js",
20
+ "./locale/*.json": "./locale/*.json",
21
+ "./icon": "./icon.svg",
22
+ "./package.json": "./package.json"
23
+ },
24
+ "files": [
25
+ "*.mjs",
26
+ "*.css",
27
+ "client.js",
28
+ "cordis.patch.yml",
29
+ "design/",
30
+ "scripts/build.mjs",
31
+ "scripts/export-design.py",
32
+ "scripts/run-tests.mjs",
33
+ "skills/skill-creator/SKILL.md",
34
+ "test/*.test.mjs",
35
+ "locale/*.json",
36
+ "icon.svg",
37
+ "README.md",
38
+ "LICENSE",
39
+ "LICENSE-lucide.txt"
40
+ ],
41
+ "engines": {
42
+ "node": ">=22.19.0",
43
+ "dsh": "^0.2.3-alpha.3"
44
+ },
45
+ "dsh": {
46
+ "bundle": { "patch": "./cordis.patch.yml" },
47
+ "client": {
48
+ "platform": "web",
49
+ "immediately": true,
50
+ "inject": [
51
+ "@deepseek-ai/dsh-api-session-controller",
52
+ "@deepseek-ai/dsh-api-workspace-controller",
53
+ "@deepseek-ai/dsh-client-connection",
54
+ "@deepseek-ai/dsh-client-locale",
55
+ "@deepseek-ai/dsh-client-ui-conversation",
56
+ "@deepseek-ai/dsh-client-ui-layout",
57
+ "@deepseek-ai/dsh-client-ui-primitives",
58
+ "@deepseek-ai/dsh-client-ui-renderer",
59
+ "@deepseek-ai/dsh-client-ui-sidebar",
60
+ "@deepseek-ai/dsh-client-ui-workspace"
61
+ ]
62
+ }
63
+ },
64
+ "scripts": {
65
+ "build": "node scripts/build.mjs",
66
+ "design:check": "python3 scripts/export-design.py --check",
67
+ "test": "node scripts/run-tests.mjs"
68
+ },
69
+ "dependencies": {
70
+ "yaml": "2.9.1",
71
+ "yauzl": "3.4.0"
72
+ },
73
+ "bundleDependencies": ["yaml", "yauzl"],
74
+ "devDependencies": {
75
+ "esbuild-wasm": "0.27.4"
76
+ }
77
+ }
package/removal.mjs ADDED
@@ -0,0 +1,313 @@
1
+ import { createHash, randomUUID } from 'node:crypto'
2
+ import { constants } from 'node:fs'
3
+ import { access, link, lstat, mkdir, open, opendir, realpath, rmdir, unlink } from 'node:fs/promises'
4
+ import { basename, dirname, isAbsolute, join, resolve } from 'node:path'
5
+ import { withSkillWriteLock } from './import-commit.mjs'
6
+ import { deriveFamily, FAMILY_MARKER, parseFamilyMarker } from './import-family.mjs'
7
+ import { limits, parseSkillMetadata, problem, readFolder, readRegular } from './import-files.mjs'
8
+ import { publishFamily } from './import-native.mjs'
9
+
10
+ const recycleName = '.dsh-skill-removals'
11
+ const journalName = 'receipt.json'
12
+ const payloadName = 'payload'
13
+ const receiptId = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/
14
+ const skillName = /^[a-z0-9]+(?:-[a-z0-9]+)*$/
15
+ const metadataLimit = 64 * 1024
16
+ const changed = () => problem('TARGET_CHANGED', '技能文件或目录已经改变,请刷新后重新确认。')
17
+ const denied = message => problem('REMOVAL_NOT_ALLOWED', message)
18
+
19
+ async function infoAt(path) {
20
+ return lstat(path, { bigint: true }).catch(error => {
21
+ if (['ENOENT', 'ENOTDIR'].includes(error.code)) return null
22
+ throw error
23
+ })
24
+ }
25
+
26
+ function owned(info) {
27
+ return Boolean(info && (process.getuid === undefined || BigInt(process.getuid()) === info.uid))
28
+ }
29
+
30
+ function identity(info) { return info ? `${info.dev}/${info.ino}` : null }
31
+ function version(info) { return info ? `${identity(info)}/${info.size}/${info.mtimeNs}/${info.ctimeNs}` : null }
32
+
33
+ function validLeaf(name) {
34
+ return typeof name === 'string' && name.length > 0 && !name.startsWith('.') && !/[\\/:\x00-\x1f\x7f]|[. ]$/.test(name)
35
+ }
36
+
37
+ async function anchorRoot(dir) {
38
+ const path = resolve(dir.path)
39
+ const info = await infoAt(path)
40
+ if (!info?.isDirectory() || !owned(info) || dirname(path) === path) throw denied('技能来源目录无法验证为当前用户拥有的普通目录。')
41
+ const root = await realpath(path)
42
+ if (identity(await infoAt(root)) !== identity(info) || dirname(root) === root) throw changed()
43
+ return { root, rootId: identity(info) }
44
+ }
45
+
46
+ async function verifyAnchor(dir, anchor) {
47
+ const fresh = await anchorRoot(dir)
48
+ if (fresh.root !== anchor.root || fresh.rootId !== anchor.rootId) throw changed()
49
+ return fresh
50
+ }
51
+
52
+ // Catalog checks are shallow. The confirmation also checks every attachment and
53
+ // validates the actual skill headers and package manifest before offering a move.
54
+ export async function inspectRemoval(target, { deep = false, signal } = {}) {
55
+ const { dir, kind, scope, entry, lockName, members } = target
56
+ const leaf = basename(target.path)
57
+ if (!validLeaf(leaf) || !skillName.test(lockName) || dirname(target.path) !== resolve(dir.path)) throw denied('只能移除技能来源目录下的独立条目。')
58
+ const anchor = await anchorRoot(dir)
59
+ const path = join(anchor.root, leaf)
60
+ const info = await infoAt(path)
61
+ if (!owned(info) || (scope === 'file' ? !info.isFile() : !info.isDirectory()) || await realpath(path) !== path) {
62
+ throw denied('只能移除当前用户拥有的普通文件或目录,不能移除符号链接。')
63
+ }
64
+ await access(anchor.root, constants.W_OK | constants.X_OK)
65
+ if (kind === 'package') {
66
+ const manifest = join(path, FAMILY_MARKER)
67
+ if (!owned(await infoAt(manifest))) throw denied('工具包缺少可验证的导入归属文件。')
68
+ const marker = parseFamilyMarker((await readRegular(manifest, limits.file)).bytes.toString('utf8'))
69
+ // An existing collection can acquire a marker just by toggling it. That
70
+ // marker carries catalogName and does not establish import ownership.
71
+ if (Object.hasOwn(marker, 'catalogName') || marker.id !== leaf || marker.id !== lockName || marker.members.length !== members.length ||
72
+ !marker.members.every(member => members.some(current => current.name === member.name && current.path === join(path, member.entry)))) {
73
+ throw denied('工具包的导入归属或完整成员清单无法验证。')
74
+ }
75
+ } else {
76
+ const entryPath = join(anchor.root, entry)
77
+ const instruction = await infoAt(entryPath)
78
+ if (!instruction?.isFile() || !owned(instruction) || await realpath(entryPath) !== entryPath) throw denied('技能说明文件无法安全验证。')
79
+ if (scope === 'directory' && (await infoAt(join(path, FAMILY_MARKER)) || await infoAt(join(path, 'package.json')))) {
80
+ throw denied('技能目录属于一个工具包或项目,请从所属来源管理。')
81
+ }
82
+ }
83
+ if (!deep) return
84
+ signal?.throwIfAborted()
85
+ const content = await fingerprint(path, scope, signal)
86
+ if (version(info) !== content.version) throw changed()
87
+ const records = content.records
88
+ if (kind === 'package') {
89
+ if (deriveFamily(records, { sourceName: leaf })?.id !== lockName) throw changed()
90
+ } else {
91
+ if (records && deriveFamily(records, { sourceName: leaf })) throw denied('不能拆删一个工具包中的技能。')
92
+ const bytes = records ? records.find(record => record.path === 'SKILL.md')?.bytes : content.bytes
93
+ if (!bytes || parseSkillMetadata(bytes.toString('utf8')).name !== lockName) throw changed()
94
+ }
95
+ await verifyAnchor(dir, anchor)
96
+ return { ...target, ...anchor, path, leaf, identity: identity(info), version: content.version, digest: content.digest }
97
+ }
98
+
99
+ async function fingerprint(path, scope, signal) {
100
+ const before = await infoAt(path)
101
+ if (!owned(before) || (scope === 'directory' ? !before.isDirectory() : !before.isFile()) || await realpath(path) !== path) throw changed()
102
+ const digest = createHash('sha256').update(`${identity(before)}/${before.mode}\0`)
103
+ let records, bytes
104
+ if (scope === 'directory') {
105
+ records = await readFolder(path, { previous: true, signal })
106
+ for (const record of records.toSorted((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0)) {
107
+ signal?.throwIfAborted()
108
+ const info = await infoAt(join(path, record.path))
109
+ if (!owned(info) || info.dev !== before.dev || (record.directory ? !info.isDirectory() : !info.isFile())) throw changed()
110
+ digest.update(JSON.stringify([record.path, identity(info), String(info.mode), String(info.mtimeNs), record.directory, record.bytes?.length])).update('\0')
111
+ if (record.bytes) digest.update(record.bytes)
112
+ }
113
+ } else {
114
+ const file = await readRegular(path, limits.file)
115
+ bytes = file.bytes
116
+ digest.update(bytes)
117
+ }
118
+ if (version(await infoAt(path)) !== version(before)) throw changed()
119
+ return { digest: digest.digest('hex'), version: version(before), records, bytes }
120
+ }
121
+
122
+ async function privateDirectory(path, create = false) {
123
+ if (create) await mkdir(path, { mode: 0o700 }).catch(error => { if (error.code !== 'EEXIST') throw error })
124
+ const info = await infoAt(path)
125
+ if (!info) return null
126
+ if (!info.isDirectory() || !owned(info) || (process.platform !== 'win32' && (info.mode & 0o077n) !== 0n) || await realpath(path) !== path) {
127
+ throw denied('技能回收目录无法安全访问。')
128
+ }
129
+ return identity(info)
130
+ }
131
+
132
+ async function syncDirectory(path) {
133
+ if (process.platform === 'win32') return
134
+ const handle = await open(path, constants.O_RDONLY)
135
+ try { await handle.sync() } finally { await handle.close() }
136
+ }
137
+
138
+ function receipt(record, restoreReason = null, restored = false) {
139
+ const { id, kind, name, scope, memberCount, removedAt, leaf, root } = record
140
+ return { id, kind, name, scope, path: join(root, leaf), removedAt, ...(memberCount !== undefined && { memberCount }),
141
+ canRestore: !restored && restoreReason === null, restoreReason }
142
+ }
143
+
144
+ async function moveWithoutReplacing(source, destination, scope) {
145
+ if (process.platform !== 'win32' || scope !== 'file') return publishFamily(source, destination, false)
146
+ // Windows rename can replace a regular file. A hard link reserves the name
147
+ // exclusively, and preserves the source inode until the new name is visible.
148
+ try { await link(source, destination) } catch (error) {
149
+ if (error.code === 'EEXIST') throw problem('TARGET_OCCUPIED', '原位置已被占用。')
150
+ throw error
151
+ }
152
+ try { await unlink(source) } catch {
153
+ throw problem('RECOVERY_REQUIRED', `两个文件名都已保留,请核对 ${source} 与 ${destination}。`, { backupPath: source, path: destination })
154
+ }
155
+ }
156
+
157
+ async function withRemovalLock(root, name, operation) {
158
+ const result = await withSkillWriteLock(root, name, async () => {
159
+ try { return { receipt: await operation() } } catch (error) {
160
+ // Import preserves its lock directory when a backup inside it needs
161
+ // attention. Removal keeps its backup in a separate durable journal.
162
+ if (error.code === 'RECOVERY_REQUIRED') return { error }
163
+ throw error
164
+ }
165
+ })
166
+ if (result.error) throw result.error
167
+ return result.receipt
168
+ }
169
+
170
+ // A durable receipt precedes the move. A crash before the move leaves no
171
+ // payload, so it will not offer recovery for a skill that was never removed.
172
+ export async function removeSkill(plan, locate, signal) {
173
+ return withRemovalLock(plan.root, plan.lockName, async () => {
174
+ const current = await locate()
175
+ if (!current || current.dir.id !== plan.dir.id || current.root !== plan.root || current.rootId !== plan.rootId || current.path !== plan.path ||
176
+ current.lockName !== plan.lockName || current.version !== plan.version || current.digest !== plan.digest) throw changed()
177
+ const recycle = join(plan.root, recycleName)
178
+ const recycleId = await privateDirectory(recycle, true)
179
+ const id = randomUUID(), work = join(recycle, id), file = join(work, journalName), payload = join(work, payloadName)
180
+ await mkdir(work, { mode: 0o700 })
181
+ const workId = await privateDirectory(work)
182
+ const record = { version: 1, id, root: plan.root, rootId: plan.rootId, directoryId: plan.dir.id, leaf: plan.leaf,
183
+ kind: plan.kind, scope: plan.scope, name: plan.name, lockName: plan.lockName, removedAt: Date.now(),
184
+ identity: plan.identity, digest: plan.digest, ...(plan.members && { memberCount: plan.members.length }) }
185
+ try {
186
+ const journal = await open(file, 'wx', 0o600)
187
+ try { await journal.writeFile(JSON.stringify(record)); await journal.sync() } finally { await journal.close() }
188
+ await syncDirectory(work)
189
+ await syncDirectory(recycle)
190
+ await syncDirectory(plan.root)
191
+ await verifyAnchor(plan.dir, plan)
192
+ if (await privateDirectory(recycle) !== recycleId || await privateDirectory(work) !== workId || version(await infoAt(plan.path)) !== plan.version) throw changed()
193
+ signal?.throwIfAborted()
194
+ // The destination lives in our exclusively created private directory.
195
+ await publishFamily(plan.path, payload, false)
196
+ } catch (error) {
197
+ await cleanEmptyJournal(work, workId).catch(() => {})
198
+ throw error
199
+ }
200
+ // A process outside the manager can change the target between inspection
201
+ // and rename. Verify the moved tree and roll back without overwriting.
202
+ try {
203
+ if ((await fingerprint(payload, plan.scope)).digest !== plan.digest) throw changed()
204
+ } catch (error) {
205
+ try {
206
+ await verifyAnchor(plan.dir, plan)
207
+ if (await privateDirectory(recycle) !== recycleId || await privateDirectory(work) !== workId) throw changed()
208
+ await moveWithoutReplacing(payload, plan.path, plan.scope)
209
+ } catch {
210
+ throw problem('RECOVERY_REQUIRED', `技能发生变化且原位置无法恢复。内容仍在 ${payload}。`, { backupPath: payload })
211
+ }
212
+ await cleanEmptyJournal(work, workId).catch(() => {})
213
+ throw error
214
+ }
215
+ await syncDirectory(work).catch(() => {})
216
+ await syncDirectory(plan.root).catch(() => {})
217
+ return receipt(record)
218
+ })
219
+ }
220
+
221
+ async function cleanEmptyJournal(work, workId) {
222
+ if (await privateDirectory(work) !== workId || await infoAt(join(work, payloadName))) return
223
+ await unlink(join(work, journalName)).catch(error => { if (error.code !== 'ENOENT') throw error })
224
+ await rmdir(work)
225
+ }
226
+
227
+ async function readReceipt(dir, anchor, id) {
228
+ const recycle = join(anchor.root, recycleName), work = join(recycle, id), payload = join(work, payloadName)
229
+ const recycleId = await privateDirectory(recycle), workId = recycleId && await privateDirectory(work)
230
+ if (!workId || !await infoAt(payload)) return null
231
+ const record = JSON.parse((await readRegular(join(work, journalName), metadataLimit)).bytes.toString('utf8'))
232
+ if (!record || record.version !== 1 || record.id !== id || record.root !== anchor.root || record.rootId !== anchor.rootId || record.directoryId !== dir.id ||
233
+ !validLeaf(record.leaf) || !skillName.test(record.lockName) || !['skill', 'package'].includes(record.kind) ||
234
+ typeof record.name !== 'string' || !Number.isSafeInteger(record.removedAt) || !['file', 'directory'].includes(record.scope) ||
235
+ !/^\d+\/\d+$/.test(record.identity) || !/^[0-9a-f]{64}$/.test(record.digest)) return null
236
+ if (record.kind === 'package' && (record.scope !== 'directory' || record.leaf !== record.lockName || !Number.isSafeInteger(record.memberCount) || record.memberCount < 2)) return null
237
+ if (record.kind === 'skill' && record.scope === 'file' && (!record.leaf.endsWith('.md') || record.leaf === 'SKILL.md')) return null
238
+ return { record, recycle, recycleId, work, workId, payload, destination: join(anchor.root, record.leaf) }
239
+ }
240
+
241
+ async function restorationReason({ record, payload, destination }) {
242
+ const info = await infoAt(payload)
243
+ if (!owned(info) || identity(info) !== record.identity || (record.scope === 'directory' ? !info.isDirectory() : !info.isFile())) return '回收区内容已变化,需要手动核对。'
244
+ if (await infoAt(destination)) return '原位置已被占用。请处理占用后刷新恢复列表。'
245
+ return null
246
+ }
247
+
248
+ const protectedReason = '原位置现与共享目录或提供方管理的来源重叠。'
249
+
250
+ export async function listRemovedSkills({ directories, withinBoundary }, signal) {
251
+ const removed = new Map()
252
+ for (const dir of directories) {
253
+ signal?.throwIfAborted()
254
+ const anchor = await anchorRoot(dir).catch(() => null)
255
+ if (!anchor) continue
256
+ const recycle = join(anchor.root, recycleName)
257
+ if (!await privateDirectory(recycle).catch(() => null)) continue
258
+ for await (const entry of await opendir(recycle)) {
259
+ signal?.throwIfAborted()
260
+ if (!receiptId.test(entry.name)) continue
261
+ const stored = await readReceipt(dir, anchor, entry.name).catch(() => null)
262
+ if (stored) removed.set(stored.record.id, receipt(stored.record,
263
+ withinBoundary(stored.destination) ? await restorationReason(stored) : protectedReason))
264
+ }
265
+ }
266
+ return [...removed.values()].sort((a, b) => b.removedAt - a.removedAt)
267
+ }
268
+
269
+ export async function restoreSkill(sources, id, signal) {
270
+ if (!receiptId.test(id)) throw problem('INVALID_INPUT', '恢复编号无效。')
271
+ const { directories } = await sources()
272
+ for (const dir of directories) {
273
+ signal?.throwIfAborted()
274
+ const anchor = await anchorRoot(dir).catch(() => null)
275
+ if (!anchor) continue
276
+ const stored = await readReceipt(dir, anchor, id).catch(() => null)
277
+ if (!stored) continue
278
+ const { record } = stored
279
+ return withRemovalLock(anchor.root, record.lockName, async () => {
280
+ const currentSources = await sources()
281
+ const currentDir = currentSources.directories.find(candidate => candidate.id === dir.id && candidate.path === dir.path)
282
+ if (!currentDir || !currentSources.withinBoundary(stored.destination)) throw denied(protectedReason)
283
+ await verifyAnchor(dir, anchor)
284
+ const current = await readReceipt(dir, anchor, id)
285
+ if (current?.workId !== stored.workId || current?.recycleId !== stored.recycleId || current?.record.digest !== record.digest) throw changed()
286
+ const reason = await restorationReason(current)
287
+ if (reason) throw problem(await infoAt(current.destination) ? 'TARGET_OCCUPIED' : 'TARGET_CHANGED', reason)
288
+ const content = await fingerprint(current.payload, record.scope, signal)
289
+ if (content.digest !== record.digest) throw changed()
290
+ await verifyAnchor(dir, anchor)
291
+ if (await privateDirectory(current.recycle) !== stored.recycleId || await privateDirectory(current.work) !== stored.workId ||
292
+ version(await infoAt(current.payload)) !== content.version) throw changed()
293
+ signal?.throwIfAborted()
294
+ await moveWithoutReplacing(current.payload, current.destination, record.scope)
295
+ // Check the moved path too. Put back a substituted payload if the
296
+ // verified source name became stale immediately before the move.
297
+ if ((await fingerprint(current.destination, record.scope).catch(() => null))?.digest !== record.digest) {
298
+ try {
299
+ await verifyAnchor(dir, anchor)
300
+ if (await privateDirectory(current.recycle) !== stored.recycleId || await privateDirectory(current.work) !== stored.workId) throw changed()
301
+ await moveWithoutReplacing(current.destination, current.payload, record.scope)
302
+ } catch {
303
+ throw problem('RECOVERY_REQUIRED', `恢复位置的内容已变化,请核对 ${current.destination}。`, { path: current.destination })
304
+ }
305
+ throw changed()
306
+ }
307
+ await syncDirectory(anchor.root).catch(() => {})
308
+ await cleanEmptyJournal(current.work, current.workId).catch(() => {})
309
+ return receipt(record, null, true)
310
+ })
311
+ }
312
+ throw problem('REMOVAL_NOT_FOUND', '当前技能来源中找不到这条恢复记录。')
313
+ }
@@ -0,0 +1,19 @@
1
+ import path from 'node:path'
2
+ import { fileURLToPath } from 'node:url'
3
+ import { build } from 'esbuild-wasm'
4
+
5
+ const project = fileURLToPath(new URL('../', import.meta.url))
6
+
7
+ await build({
8
+ absWorkingDir: project,
9
+ entryPoints: ['client-entry.mjs'],
10
+ outfile: path.join(project, 'client.js'),
11
+ bundle: true,
12
+ format: 'iife',
13
+ platform: 'browser',
14
+ target: 'es2022',
15
+ loader: { '.css': 'text', '.svg': 'dataurl' },
16
+ charset: 'utf8',
17
+ legalComments: 'inline',
18
+ banner: { js: '// Generated from the plugin sources and the approved Pen design. See LICENSE-lucide.txt.' },
19
+ })