@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,587 @@
1
+ #!/usr/bin/env python3
2
+ """Export the bundled design source with Python 3.10+ and Pen CLI 0.3.17."""
3
+
4
+ import argparse
5
+ import hashlib
6
+ import json
7
+ import os
8
+ import re
9
+ import shutil
10
+ import subprocess
11
+ import tempfile
12
+ from collections import defaultdict
13
+ from pathlib import Path
14
+ from xml.etree import ElementTree as ET
15
+
16
+
17
+ PACKAGE = Path(__file__).resolve().parents[1]
18
+ DEFAULT_BOARD = PACKAGE / 'design' / 'skill-manager.pen'
19
+ EMPTY_ART = {'emptySearch': 'skv-224', 'emptyLibrary': 'skv-247'}
20
+ COMPONENT_IDS = ('official-head', 'sm70', 'sm-r5-33', 'skv-282', 'skv-297', *EMPTY_ART.values())
21
+ GLYPH_CATALOG = 'design-glyph-catalog'
22
+ MENU_ACTIONS = {
23
+ 'add': ('sm-r5-33', {'sm-r5-19': 'local', 'sm-r5-23': 'tool', 'sm-r5-27': 'github', 'sm-r5-32': 'agent'}),
24
+ 'sort': ('skv-282', {'skv-277': 'updated', 'skv-279': 'az', 'skv-281': 'za'}),
25
+ 'row': ('skv-297', {'skv-290': 'detail', 'skv-293': 'file', 'skv-296': 'folder'}),
26
+ }
27
+ DIALOG_FRAMES = {
28
+ 'local': 'skv-378', 'tool': 'sm-r5-350', 'github': 'sm-r5-480',
29
+ 'tool-skills': 'sm-r5-439', 'github-skills': 'sm-r5-528', 'agent': 'sm-r5-57',
30
+ 'archive': 'sm-r5-196', 'review': 'skv-408', 'working': 'skv-425',
31
+ 'error': 'skv-478', 'conflict': 'skv-504',
32
+ }
33
+
34
+
35
+ def walk(roots):
36
+ for node in roots:
37
+ yield node
38
+ yield from walk(node.get('children', ()))
39
+
40
+
41
+ def js(value, indent=None):
42
+ return json.dumps(value, ensure_ascii=False, indent=indent, separators=None if indent else (',', ':'))
43
+
44
+
45
+ def native_export(board, nodes, icons):
46
+ roots = [nodes[node_id] for node_id in COMPONENT_IDS]
47
+ included_icons = {n['icon'] for n in walk(roots) if n['type'] == 'icon'}
48
+ roots.extend(node for name, node in icons.items() if name not in included_icons)
49
+
50
+ # The installed CLI 0.3.17 understands Pen 2.25, while the approved file uses
51
+ # 2.26 page wrappers. Export the actual component subtrees as loose roots in
52
+ # a private 2.25 document. Positions inside each component stay intact.
53
+ projection = {
54
+ 'version': '2.25',
55
+ 'variables': board.get('variables', {}),
56
+ 'children': [dict(node, x=0, y=0) for node in roots],
57
+ }
58
+ if board.get('themes'):
59
+ projection['themes'] = board['themes']
60
+ pen = shutil.which(os.environ.get('PENX_PEN_CLI') or 'pen')
61
+ if not pen:
62
+ raise ValueError('pen CLI is required. Set PENX_PEN_CLI to the local executable or put pen on PATH.')
63
+ with tempfile.TemporaryDirectory(prefix='dsh-skill-design-') as work:
64
+ directory = Path(work)
65
+ projected_file = directory / 'components.pen'
66
+ projected_file.write_text(js(projection), encoding='utf-8')
67
+ html_file = directory / 'components.html'
68
+ root_ids = [node['id'] for node in roots]
69
+ operation = f'Export({js(root_ids)}, "html-css", {js(str(html_file))})'
70
+ command = 'execute(' + js({'input': operation}) + ')\nexit()\n'
71
+ result = subprocess.run(
72
+ [pen, 'interactive', '--in', str(projected_file), '--out', str(directory / 'session.pen')],
73
+ cwd=work, input=command, capture_output=True, text=True, timeout=90, check=False,
74
+ )
75
+ # The interactive CLI exits with status 0 even for a rejected Export operation.
76
+ if result.returncode or not html_file.is_file():
77
+ detail = (result.stderr or result.stdout).strip()[-3500:]
78
+ raise ValueError(f'Pen did not export the selected components.\n{detail}')
79
+ html = html_file.read_text(encoding='utf-8')
80
+
81
+ body = re.search(r'<body>(.*?)</body>', html, re.DOTALL)
82
+ if body is None:
83
+ raise ValueError('The Pen export has no HTML body.')
84
+ # The CSS exporter writes one XHTML-compatible wrapper around these frame/icon roots.
85
+ wrapper = ET.fromstring(body.group(1).strip())
86
+ exported = {}
87
+
88
+ def match(source, element):
89
+ if element.get('data-pencil-name') != source['name']:
90
+ raise ValueError(f'Unexpected exported node for {source["id"]}: {element.attrib}')
91
+ exported[source['id']] = element
92
+ if source['type'] != 'icon':
93
+ for child, child_element in zip(source.get('children', []), element, strict=True):
94
+ match(child, child_element)
95
+
96
+ for root, element in zip(roots, wrapper, strict=True):
97
+ match(root, element)
98
+ return exported
99
+
100
+
101
+ def svg_shapes(exported):
102
+ shapes = {}
103
+ for element in exported.values():
104
+ name = element.get('data-icon-name')
105
+ if not name or name in shapes:
106
+ continue
107
+ if element.get('data-icon-set') != 'lucide':
108
+ raise ValueError(f'Unexpected icon set for {name}')
109
+ paths = []
110
+ for child in element:
111
+ if child.tag != '{http://www.w3.org/2000/svg}path' or set(child.attrib) - {'d', 'fill', 'fill-rule'}:
112
+ raise ValueError(f'The Pen SVG for {name} uses an unhandled shape: {child.tag}, {child.attrib.keys()}')
113
+ path = {'d': child.attrib['d']}
114
+ if child.get('fill-rule'):
115
+ path['fill-rule'] = child.get('fill-rule')
116
+ paths.append(path)
117
+ if not paths:
118
+ raise ValueError(f'No native SVG geometry for {name}')
119
+ shapes[name] = {'viewBox': element.attrib['viewBox'], 'paths': paths}
120
+ return shapes
121
+
122
+
123
+ def content(element):
124
+ return ''.join(element.itertext()).strip()
125
+
126
+
127
+ def export_menus(nodes, exported):
128
+ menus = {}
129
+ for key, (frame_id, actions) in MENU_ACTIONS.items():
130
+ entries = []
131
+ separator = False
132
+ for child in nodes[frame_id]['children']:
133
+ if child['type'] == 'rectangle':
134
+ separator = True
135
+ continue
136
+ children = child['children']
137
+ texts = [item['id'] for item in children if item['type'] == 'text']
138
+ glyph = next((item['icon'] for item in children if item['type'] == 'icon'), None)
139
+ entry = {'action': actions[child['id']], 'nodeId': child['id'], 'labelId': texts[0],
140
+ 'label': content(exported[texts[0]]), 'icon': glyph}
141
+ if len(texts) > 1:
142
+ entry.update(descriptionId=texts[1], description=content(exported[texts[1]]))
143
+ if separator:
144
+ entry['separatorBefore'] = True
145
+ separator = False
146
+ entries.append(entry)
147
+ if len(entries) != len(actions):
148
+ raise ValueError(f'Menu {frame_id} no longer contains all configured actions.')
149
+ menus[key] = entries
150
+ return menus
151
+
152
+
153
+ # Semantic roles attached to matching exported nodes. Wrapper elements added below
154
+ # let each row have three independent focus targets and let the header wrap naturally.
155
+ HEADER_PARTS = {
156
+ 'official-head': ('header', None), 'sm41': ('h1', 'title'), 'sm42': ('p', 'description'),
157
+ 'sm45': ('div', 'actions'), 'sm-r5-10': ('button', 'directories'), 'sm-r5-9': ('span', 'directories-label'),
158
+ 'sm-r5-13': ('button', 'refresh'), 'sm-r5-12': ('span', 'refresh-label'),
159
+ 'sm-r5-7': ('div', 'split'), 'sm-r5-3': ('button', 'add'), 'sm-r5-2': ('span', 'add-label'),
160
+ 'sm-r5-6': ('button', 'add-menu'), 'sm-r5-4': ('span', 'divider'),
161
+ }
162
+ ROW_PARTS = {
163
+ 'sm70': ('div', None), 'sm70-tile': ('span', 'tile'), 'sm70-glyph': ('span', 'glyph'),
164
+ 'sm70-title': ('span', 'title'), 'sm70-description': ('span', 'description'),
165
+ 'sm70-more': ('button', 'more'), 'sm70-switch': ('button', 'switch'), 'sm70-thumb': ('span', 'thumb'),
166
+ }
167
+
168
+
169
+ def build_template(root_id, parts, name, nodes, exported):
170
+ elements = {}
171
+
172
+ def render(node):
173
+ node_id = node['id']
174
+ original = exported[node_id]
175
+ tag, part = parts.get(node_id, ('span', None)) if node['type'] == 'icon' else parts[node_id]
176
+ element = ET.Element(tag, {'data-pen-id': node_id})
177
+ elements[node_id] = element
178
+ if part:
179
+ element.set('data-part', part)
180
+ if tag == 'button':
181
+ element.set('type', 'button')
182
+ if node['type'] == 'icon':
183
+ element.set('data-pen-icon', original.attrib['data-icon-name'])
184
+ element.set('data-size', str(node['width']))
185
+ element.set('aria-hidden', 'true')
186
+ elif node['type'] == 'text':
187
+ element.text = content(original)
188
+ else:
189
+ element.extend(render(child) for child in node.get('children', ()))
190
+ return element
191
+
192
+ root = render(nodes[root_id])
193
+ root.set('class', f'sm-pen-{name}')
194
+ if name == 'header':
195
+ heading = ET.Element('div', {'data-part': 'heading'})
196
+ for key in ('sm41', 'sm42'):
197
+ root.remove(elements[key])
198
+ heading.append(elements[key])
199
+ root.insert(0, heading)
200
+ elements['sm-r5-6'].attrib.update({'aria-label': nodes['sm-r5-6']['name'], 'aria-haspopup': 'menu', 'aria-expanded': 'false'})
201
+ elements['sm-r5-4'].set('aria-hidden', 'true')
202
+ else:
203
+ open_skill = ET.Element('button', {'data-part': 'open', 'type': 'button'})
204
+ copy = ET.Element('span', {'data-part': 'copy'})
205
+ for key in ('sm70-tile', 'sm70-title', 'sm70-description'):
206
+ root.remove(elements[key])
207
+ open_skill.extend([elements['sm70-tile'], copy])
208
+ copy.extend([elements['sm70-title'], elements['sm70-description']])
209
+ root.insert(0, open_skill)
210
+ elements['sm70-more'].attrib.update({'aria-label': nodes['sm70-more']['name'], 'aria-haspopup': 'menu'})
211
+ elements['sm70-switch'].attrib.update({'role': 'switch', 'aria-label': nodes['sm70-switch']['name'], 'aria-checked': 'true'})
212
+ elements['sm70-thumb'].set('aria-hidden', 'true')
213
+ return ET.tostring(root, encoding='unicode', method='html')
214
+
215
+
216
+ def illustration(root_id, nodes, exported):
217
+ # These small compositions have a fixed coordinate space. Keep the CSS
218
+ # exported by Pen for every shape, with the original paints as fallbacks.
219
+ paints = {'#E3E7EB': 'border-l1', '#F0F2F4': 'bg-layer-2', '#CAD0D5': 'border-l2',
220
+ '#F6F7F8': 'bg-layer-2', '#D8DDE1': 'border-l1', '#E8EBED': 'border-l1'}
221
+
222
+ def render(node):
223
+ node_id = node['id']
224
+ style = css_style(exported[node_id])
225
+ for prop in ('background-color', 'border'):
226
+ if prop in style:
227
+ style[prop] = re.sub(r'#[a-f\d]+', lambda m: f'var(--dsw-alias-{paints[m[0].upper()]}, {m[0]})', style[prop], flags=re.I)
228
+ attributes = {'data-pen-id': node_id}
229
+ if node_id == root_id:
230
+ style['position'] = 'relative'
231
+ style.pop('top', None)
232
+ style.pop('left', None)
233
+ attributes.update({'aria-hidden': 'true', 'class': 'sm-pen-illustration'})
234
+ if node['type'] == 'icon':
235
+ attributes.update({'data-pen-icon': node['icon'], 'data-size': str(node['width'])})
236
+ style['color'] = f'var(--dsw-alias-label-secondary, {node["fill"]})'
237
+ style['display'] = 'inline-flex'
238
+ attributes['style'] = ';'.join(f'{key}:{value}' for key, value in style.items())
239
+ element = ET.Element('div', attributes)
240
+ element.extend(render(child) for child in node.get('children', ()))
241
+ return element
242
+
243
+ return ET.tostring(render(nodes[root_id]), encoding='unicode', method='html')
244
+
245
+
246
+ RUNTIME = '''
247
+ const textById = new Map()
248
+ for (const [text, ...nodeIds] of textGroups) {
249
+ for (const id of nodeIds) textById.set(id, text)
250
+ }
251
+
252
+ export function designText(id, fallback = '') {
253
+ return textById.get(id) ?? fallback
254
+ }
255
+
256
+ const aliases = {
257
+ add: 'plus', refresh: 'refresh-cw', directories: 'folder-cog', more: 'ellipsis',
258
+ back: 'arrow-left', close: 'x', local: 'upload', tool: 'monitor', github: 'git-branch',
259
+ agent: 'bot', file: 'file-text', archive: 'file-archive', external: 'external-link',
260
+ lock: 'lock-keyhole', success: 'circle-check', warning: 'circle-alert',
261
+ }
262
+
263
+ // Geometry comes from the native Pen HTML export. The host supplies the paint color.
264
+ export function icon(name, size = 18) {
265
+ const key = Object.hasOwn(aliases, name) ? aliases[name] : name
266
+ const glyph = Object.hasOwn(glyphs, key) ? key : 'file-text'
267
+ const shape = glyphs[glyph]
268
+ const ns = 'http://www.w3.org/2000/svg'
269
+ const svg = document.createElementNS(ns, 'svg')
270
+ svg.setAttribute('data-icon-name', glyph)
271
+ svg.setAttribute('viewBox', shape.viewBox)
272
+ svg.setAttribute('width', String(size))
273
+ svg.setAttribute('height', String(size))
274
+ svg.setAttribute('fill', 'currentColor')
275
+ svg.setAttribute('aria-hidden', 'true')
276
+ svg.setAttribute('focusable', 'false')
277
+ for (const attrs of shape.paths) {
278
+ const path = document.createElementNS(ns, 'path')
279
+ for (const [attribute, value] of Object.entries(attrs)) path.setAttribute(attribute, value)
280
+ svg.append(path)
281
+ }
282
+ return svg
283
+ }
284
+
285
+ export function skillAppearance(name) {
286
+ return Object.hasOwn(appearances, name) ? appearances[name] : { icon: 'file-text', color: 'var(--sm-muted)' }
287
+ }
288
+
289
+ // Only trusted, build-time Pen markup reaches these templates. Runtime skill data
290
+ // is applied by the caller using textContent and DOM properties on a fresh clone.
291
+ const templates = new Map()
292
+ export function designFragment(name) {
293
+ if (!Object.hasOwn(markup, name)) throw new RangeError(`Unknown design fragment: ${name}`)
294
+ let template = templates.get(name)
295
+ if (!template) {
296
+ template = document.createElement('template')
297
+ template.innerHTML = markup[name]
298
+ for (const slot of template.content.querySelectorAll('[data-pen-icon]')) {
299
+ slot.append(icon(slot.dataset.penIcon, Number(slot.dataset.size)))
300
+ }
301
+ templates.set(name, template)
302
+ }
303
+ return template.content.firstElementChild.cloneNode(true)
304
+ }
305
+ '''
306
+
307
+
308
+ def module(board, source_file, revision, nodes, icons, exported):
309
+ groups = defaultdict(list)
310
+ for node in nodes.values():
311
+ if node['type'] == 'text':
312
+ groups[node['content']].append(node['id'])
313
+ shapes = svg_shapes(exported)
314
+ if set(shapes) != set(icons):
315
+ raise ValueError('Exported SVG inventory differs from the product node inventory.')
316
+ appearances = {}
317
+ for row in nodes['sm113']['children']:
318
+ for child in row.get('children', []):
319
+ if child.get('name') == '技能图标':
320
+ glyph, = child['children']
321
+ appearances[row['name']] = {'icon': glyph['icon'], 'color': glyph['fill']}
322
+ metadata = {'file': source_file.name, 'version': board['version'], 'revision': revision, 'exportFormat': 'html-css'}
323
+ markup = {
324
+ 'header': build_template('official-head', HEADER_PARTS, 'header', nodes, exported),
325
+ 'row': build_template('sm70', ROW_PARTS, 'row', nodes, exported),
326
+ **{name: illustration(node_id, nodes, exported) for name, node_id in EMPTY_ART.items()},
327
+ }
328
+ group_lines = ',\n'.join(' ' + js([text, *ids]) for text, ids in groups.items())
329
+ return '\n\n'.join([
330
+ '// Generated by scripts/export-design.py from the saved Pen board.',
331
+ 'export const designSource = ' + js(metadata, 2),
332
+ 'export const designMenus = ' + js(export_menus(nodes, exported), 2),
333
+ 'const markup = ' + js(markup, 2),
334
+ 'const appearances = ' + js(appearances, 2),
335
+ 'const textGroups = [\n' + group_lines + '\n]',
336
+ 'const glyphs = ' + js(shapes, 2),
337
+ RUNTIME.strip(),
338
+ ]) + '\n'
339
+
340
+
341
+ def css_style(element):
342
+ return dict(part.strip().split(': ', 1) for part in element.get('style', '').split(';') if part.strip())
343
+
344
+
345
+ def rule(selector, values):
346
+ return selector + ' {\n' + ''.join(f' {name}: {value};\n' for name, value in values.items()) + '}\n'
347
+
348
+
349
+ def stylesheet(board, revision, nodes, exported):
350
+ styles = {node_id: css_style(node) for node_id, node in exported.items()}
351
+ variables = {key: value['value'] for key, value in board['variables'].items()}
352
+
353
+ def number(node_id, prop):
354
+ return nodes[node_id][prop]
355
+
356
+ def px(value):
357
+ return f'{value:g}px'
358
+
359
+ def geom(node_id, prop):
360
+ return px(number(node_id, prop))
361
+
362
+ native_tokens = {
363
+ 'bg': ('bg-layer-1', variables['--surface']), 'ink': ('label-primary', variables['--foreground']),
364
+ 'muted': ('label-secondary', variables['--muted-foreground']), 'line': ('border-l1', variables['--border']),
365
+ 'soft': ('bg-layer-2', variables['--disabled-background']), 'overlay': ('bg-overlay', variables['--popover']),
366
+ 'control-line': ('border-l2', variables['--control-border']), 'focus': ('label-secondary', variables['--ring']),
367
+ 'primary': ('label-primary', nodes['sm-r5-7']['fill']), 'on-primary': ('bg-layer-1', variables['--primary-foreground']),
368
+ 'switch-off': ('border-l2', nodes['sm110-switch']['fill']), 'switch-on': ('label-primary', nodes['sm70-switch']['fill']),
369
+ }
370
+ tokens = {f'--sm-{key}': f'var(--dsw-alias-{host}, {fallback})' for key, (host, fallback) in native_tokens.items()}
371
+ for step in (4, 8, 12, 16):
372
+ tokens[f'--sm-space-{step}'] = px(variables[f'--space-{step}'])
373
+ tokens.update({
374
+ '--sm-control-h': styles['sm-r5-13']['height'], '--sm-radius': px(variables['--radius-control']),
375
+ '--sm-font': f'"{variables["--font-sans"]}", system-ui, sans-serif',
376
+ '--sm-font-mono': f'"{variables["--font-mono"]}", ui-monospace, monospace',
377
+ '--sm-content-width': styles['official-head']['width'], '--sm-header-h': styles['official-head']['height'],
378
+ '--sm-row-h': styles['sm70']['height'], '--sm-row-gap': px(number('sm78', 'y') - number('sm70', 'y') - number('sm70', 'height')),
379
+ '--sm-search-h': geom('sm56', 'height'), '--sm-search-radius': geom('sm56', 'cornerRadius'),
380
+ '--sm-menu-add-w': styles['sm-r5-33']['width'], '--sm-menu-sort-w': styles['skv-282']['width'],
381
+ '--sm-menu-row-w': styles['skv-297']['width'], '--sm-menu-shadow': styles['sm-r5-33']['box-shadow'],
382
+ })
383
+ css = [f'/* Generated by scripts/export-design.py from Pen revision {revision}. */\n', rule('.sm-design', tokens)]
384
+ for view, node_id in DIALOG_FRAMES.items():
385
+ frame = nodes[node_id]
386
+ shadows = [f'{px(s["offset"]["x"])} {px(s["offset"]["y"])} {px(s["blur"])} {s["color"]}' for s in frame['effect']]
387
+ css.append(rule(f'.sm-flow[data-view="{view}"]', {
388
+ '--smf-width': px(frame['width']), '--smf-min-height': px(frame['height']),
389
+ '--sm-dialog-radius': px(frame['cornerRadius']), '--sm-dialog-shadow': ', '.join(shadows),
390
+ }))
391
+
392
+ # Keep the native component typography, borders and corner radii. Paints are
393
+ # inherited from DSH so the same controls respond to a live theme switch.
394
+ muted = {nodes['sm70-description']['fill'].upper()}
395
+ dim = {nodes['sm-r5-9']['fill'].upper()}
396
+ for group, parts in [('header', HEADER_PARTS), ('row', ROW_PARTS)]:
397
+ for node_id, (_, part) in parts.items():
398
+ if not part:
399
+ continue
400
+ style = styles[node_id]
401
+ kept = {key: style[key] for key in ('font-family', 'font-size', 'font-weight', 'text-align', 'border-radius') if key in style}
402
+ if 'border' in style:
403
+ kept['border'] = re.sub(r'#[a-f\d]+', 'var(--sm-line)', style['border'], flags=re.I)
404
+ if 'color' in style:
405
+ color = style['color'].upper()
406
+ role = 'on-primary' if color == '#FFFFFF' else 'muted' if color in muted else 'ink'
407
+ kept['color'] = f'var(--sm-{role})'
408
+ if color in dim:
409
+ kept['color'] = f'var(--dsw-alias-label-primary, {style["color"]})'
410
+ if 'background-color' in style:
411
+ surfaces = {'split': '--sm-primary', 'switch': '--sm-switch-off', 'thumb': '--sm-on-primary'}
412
+ kept['background-color'] = f'var({surfaces.get(part, "--sm-bg")})'
413
+ if part == 'divider':
414
+ kept['background-color'] = 'color-mix(in srgb, var(--sm-on-primary) 32%, var(--sm-primary))'
415
+ if kept:
416
+ css.append(rule(f'.sm-pen-{group} [data-part="{part}"]', kept))
417
+
418
+ action_gap = number('sm-r5-13', 'x') - number('sm-r5-10', 'width')
419
+ row_gap = number('sm70-switch', 'x') - number('sm70-more', 'x') - number('sm70-more', 'width')
420
+ copy_gap = number('sm70-title', 'x') - number('sm70-tile', 'width')
421
+ label_gap = number('sm-r5-9', 'x') - number('sm-r5-8', 'x') - number('sm-r5-8', 'width')
422
+ title_leading = 1.4
423
+ header_leading = number('sm42', 'y') - number('sm41', 'y') - number('sm41', 'fontSize') * title_leading
424
+ row_leading = number('sm70-description', 'y') - number('sm70-title', 'y') - number('sm70-title', 'fontSize') * title_leading
425
+ css.append(f'''
426
+ .sm-pen-header, .sm-pen-row, .sm-pen-header *, .sm-pen-row * {{ box-sizing: border-box; }}
427
+ .sm-pen-header, .sm-pen-row {{ color: var(--sm-ink); font-family: var(--sm-font); }}
428
+ .sm-pen-header button, .sm-pen-row button {{
429
+ appearance: none;
430
+ margin: 0;
431
+ padding: 0;
432
+ border: 0;
433
+ background: transparent;
434
+ color: inherit;
435
+ font: inherit;
436
+ line-height: normal;
437
+ cursor: pointer;
438
+ }}
439
+ .sm-pen-header button:focus-visible, .sm-pen-row button:focus-visible {{
440
+ outline: {px(variables['--ring-width'])} solid var(--sm-focus);
441
+ outline-offset: 2px;
442
+ }}
443
+ .sm-pen-header button:disabled, .sm-pen-row button:disabled {{ opacity: .55; cursor: default; }}
444
+ .sm-pen-header [data-pen-icon], .sm-pen-row [data-pen-icon] {{ display: inline-flex; flex: none; }}
445
+ .sm-pen-header {{
446
+ display: flex;
447
+ flex-wrap: wrap;
448
+ align-items: flex-start;
449
+ justify-content: space-between;
450
+ column-gap: var(--sm-space-16);
451
+ row-gap: var(--sm-space-12);
452
+ min-height: var(--sm-header-h);
453
+ }}
454
+ .sm-pen-header [data-part="heading"] {{ flex: 1 1 18rem; min-width: 0; }}
455
+ .sm-pen-header [data-part="title"], .sm-pen-header [data-part="description"] {{ margin: 0; line-height: {title_leading}; }}
456
+ .sm-pen-header [data-part="description"] {{ margin-top: {px(header_leading)}; }}
457
+ .sm-pen-header [data-part="actions"] {{
458
+ display: flex;
459
+ flex-wrap: wrap;
460
+ align-items: center;
461
+ gap: {px(action_gap)};
462
+ max-width: 100%;
463
+ margin-top: {geom('sm45', 'y')};
464
+ }}
465
+ .sm-pen-header button {{
466
+ display: inline-flex;
467
+ align-items: center;
468
+ justify-content: center;
469
+ gap: {px(label_gap)};
470
+ height: var(--sm-control-h);
471
+ white-space: nowrap;
472
+ }}
473
+ .sm-pen-header [data-part="directories"] {{ min-width: {styles['sm-r5-10']['width']}; }}
474
+ .sm-pen-header [data-part="refresh"] {{ min-width: {styles['sm-r5-13']['width']}; }}
475
+ .sm-pen-header [data-part="split"] {{ display: inline-flex; color: var(--sm-on-primary); }}
476
+ .sm-pen-header [data-part="add"] {{ min-width: {styles['sm-r5-3']['width']}; border-radius: inherit; }}
477
+ .sm-pen-header [data-part="add-menu"] {{ position: relative; width: {styles['sm-r5-6']['width']}; border-radius: inherit; }}
478
+ .sm-pen-header [data-part="divider"] {{
479
+ position: absolute;
480
+ inset-inline-start: 0;
481
+ width: {styles['sm-r5-4']['width']};
482
+ height: {styles['sm-r5-4']['height']};
483
+ }}
484
+ .sm-pen-header :is([data-part="directories"], [data-part="refresh"]):hover:enabled,
485
+ .sm-pen-row [data-part="more"]:hover:enabled {{ background: var(--sm-soft); }}
486
+ .sm-pen-header :is([data-part="add"], [data-part="add-menu"]):hover:enabled,
487
+ .sm-pen-header [data-part="add-menu"][aria-expanded="true"] {{ background: color-mix(in srgb, var(--sm-on-primary) 13%, var(--sm-primary)); }}
488
+ .sm-pen-row {{
489
+ display: grid;
490
+ grid-template-columns: minmax(0, 1fr) auto auto;
491
+ align-items: center;
492
+ gap: clamp(var(--sm-space-8), 2.5%, {px(row_gap)});
493
+ min-height: var(--sm-row-h);
494
+ }}
495
+ .sm-pen-row [data-part="open"] {{
496
+ display: flex;
497
+ align-items: center;
498
+ gap: {px(copy_gap)};
499
+ min-width: 0;
500
+ min-height: var(--sm-row-h);
501
+ text-align: start;
502
+ border-radius: var(--sm-radius);
503
+ }}
504
+ .sm-pen-row [data-part="open"]:hover:enabled [data-part="title"] {{ text-decoration: underline; text-underline-offset: .16em; }}
505
+ .sm-pen-row [data-part="tile"] {{
506
+ display: grid;
507
+ flex: none;
508
+ place-items: center;
509
+ width: {styles['sm70-tile']['width']};
510
+ height: {styles['sm70-tile']['height']};
511
+ }}
512
+ .sm-pen-row [data-part="copy"] {{ display: grid; gap: {px(row_leading)}; min-width: 0; }}
513
+ .sm-pen-row :is([data-part="title"], [data-part="description"]) {{
514
+ display: block;
515
+ overflow: hidden;
516
+ text-overflow: ellipsis;
517
+ white-space: nowrap;
518
+ line-height: {title_leading};
519
+ }}
520
+ .sm-pen-row [data-part="more"] {{
521
+ display: grid;
522
+ place-items: center;
523
+ width: {styles['sm70-more']['width']};
524
+ height: {styles['sm70-more']['height']};
525
+ border-radius: {px(variables['--radius-inset'])};
526
+ color: var(--sm-muted);
527
+ }}
528
+ .sm-pen-row [data-part="switch"] {{
529
+ position: relative;
530
+ width: {styles['sm70-switch']['width']};
531
+ height: {styles['sm70-switch']['height']};
532
+ }}
533
+ .sm-pen-row [data-part="switch"][aria-checked="true"] {{ background: var(--sm-switch-on); }}
534
+ .sm-pen-row [data-part="thumb"] {{
535
+ display: block;
536
+ position: absolute;
537
+ inset-inline-start: {geom('sm110-thumb', 'x')};
538
+ top: {styles['sm70-thumb']['top']};
539
+ width: {styles['sm70-thumb']['width']};
540
+ height: {styles['sm70-thumb']['height']};
541
+ }}
542
+ .sm-pen-row [aria-checked="true"] [data-part="thumb"] {{ inset-inline-start: {geom('sm70-thumb', 'x')}; }}
543
+ '''.strip() + '\n')
544
+ return '\n'.join(css)
545
+
546
+
547
+ def main():
548
+ parser = argparse.ArgumentParser(description=__doc__)
549
+ parser.add_argument('board', nargs='?', type=Path, default=DEFAULT_BOARD,
550
+ help='Path to a copy of the bundled design source (default: design/skill-manager.pen).')
551
+ parser.add_argument('--check', action='store_true', help='Render again and verify the packaged files byte for byte.')
552
+ args = parser.parse_args()
553
+ raw = args.board.read_bytes()
554
+ revision = hashlib.sha256(raw).hexdigest()
555
+ board = json.loads(raw)
556
+ nodes = {n['id']: n for n in walk(board['children'])}
557
+ component_nodes = walk(nodes[node_id] for node_id in COMPONENT_IDS)
558
+ icons = {node['icon']: node for node in component_nodes if node['type'] == 'icon'}
559
+ for node in nodes[GLYPH_CATALOG]['children']:
560
+ if node['type'] != 'icon' or node['icon'] in icons:
561
+ raise ValueError(f'Unexpected or duplicate icon in the glyph catalog: {node["id"]}')
562
+ icons[node['icon']] = node
563
+ exported = native_export(board, nodes, icons)
564
+ outputs = {
565
+ PACKAGE / 'design.mjs': module(board, args.board, revision, nodes, icons, exported),
566
+ PACKAGE / 'design.css': stylesheet(board, revision, nodes, exported),
567
+ }
568
+ for path, text in outputs.items():
569
+ data = text.encode('utf-8')
570
+ saved = path.read_bytes() if path.is_file() else None
571
+ if saved == data:
572
+ continue
573
+ if args.check:
574
+ previous = hashlib.sha256(saved).hexdigest() if saved is not None else 'missing'
575
+ expected = hashlib.sha256(data).hexdigest()
576
+ raise SystemExit(f'{path.name} differs for Pen revision {revision}.\n'
577
+ f'Saved {previous}\nGenerated {expected}\nRun without --check to regenerate it.')
578
+ # Watchers and independent check processes should always read a complete file.
579
+ with tempfile.TemporaryDirectory(prefix='.design-export-', dir=path.parent) as work:
580
+ staged = Path(work) / path.name
581
+ staged.write_bytes(data)
582
+ staged.replace(path)
583
+ print(f'{"Verified" if args.check else "Exported"} {len(COMPONENT_IDS)} native components and {len(icons)} SVG icons from {revision}')
584
+
585
+
586
+ if __name__ == '__main__':
587
+ main()
@@ -0,0 +1,14 @@
1
+ import { spawnSync } from 'node:child_process'
2
+ import { fileURLToPath } from 'node:url'
3
+
4
+ // Desktop DSH ships its Host libraries inside Electron's application archive.
5
+ // Use the same filesystem and module loader for the tests and the running Host.
6
+ const executable = process.env.DSH_NODE_EXECUTABLE || process.execPath
7
+ const result = spawnSync(executable, ['--test', ...process.argv.slice(2)], {
8
+ cwd: fileURLToPath(new URL('../', import.meta.url)),
9
+ env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' },
10
+ stdio: 'inherit',
11
+ })
12
+
13
+ if (result.error) throw result.error
14
+ process.exitCode = result.status ?? 1