dsh-motion-ui 0.5.6 → 0.7.0

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 (164) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/README.md +112 -4
  3. package/VERIFICATION.md +145 -0
  4. package/client.js +4869 -22533
  5. package/examples/mechanism-assembly.json +50 -0
  6. package/examples/mechanism-crank.json +103 -0
  7. package/examples/mechanism-gears.json +103 -0
  8. package/index.js +52 -15
  9. package/lib/assets/echarts-core.js +47 -0
  10. package/lib/assets/echarts-full.js +78 -0
  11. package/lib/assets/katex-fonts/KaTeX_AMS-Regular.woff2 +0 -0
  12. package/lib/assets/katex-fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  13. package/lib/assets/katex-fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  14. package/lib/assets/katex-fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  15. package/lib/assets/katex-fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  16. package/lib/assets/katex-fonts/KaTeX_Main-Bold.woff2 +0 -0
  17. package/lib/assets/katex-fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  18. package/lib/assets/katex-fonts/KaTeX_Main-Italic.woff2 +0 -0
  19. package/lib/assets/katex-fonts/KaTeX_Main-Regular.woff2 +0 -0
  20. package/lib/assets/katex-fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  21. package/lib/assets/katex-fonts/KaTeX_Math-Italic.woff2 +0 -0
  22. package/lib/assets/katex-fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  23. package/lib/assets/katex-fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  24. package/lib/assets/katex-fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  25. package/lib/assets/katex-fonts/KaTeX_Script-Regular.woff2 +0 -0
  26. package/lib/assets/katex-fonts/KaTeX_Size1-Regular.woff2 +0 -0
  27. package/lib/assets/katex-fonts/KaTeX_Size2-Regular.woff2 +0 -0
  28. package/lib/assets/katex-fonts/KaTeX_Size3-Regular.woff2 +0 -0
  29. package/lib/assets/katex-fonts/KaTeX_Size4-Regular.woff2 +0 -0
  30. package/lib/assets/katex-fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  31. package/lib/assets/katex.css +1 -0
  32. package/lib/assets/mermaid.js +3644 -0
  33. package/lib/assets/standalone-runtime.css +1 -0
  34. package/lib/assets/standalone-runtime.js +330 -0
  35. package/lib/assets/three.js +3842 -0
  36. package/lib/assets/visual.css +1 -0
  37. package/lib/assets/visual.js +416 -0
  38. package/lib/author-expression.js +3 -2
  39. package/lib/authoring-guide.js +4 -3
  40. package/lib/build-info.js +1 -1
  41. package/lib/canvas-system.js +3 -3
  42. package/lib/catalog.js +94 -92
  43. package/lib/components.js +11 -6
  44. package/lib/delivery.js +18 -0
  45. package/lib/diagnostics-route.js +6 -0
  46. package/lib/document-update.js +27 -0
  47. package/lib/export-runtime-bundle.js +1 -1
  48. package/lib/expressive-examples.js +6 -0
  49. package/lib/fence-feedback.js +61 -0
  50. package/lib/fence-route.js +14 -0
  51. package/lib/fences.js +9 -0
  52. package/lib/freeform.js +4 -3
  53. package/lib/inspection.js +3 -2
  54. package/lib/links.js +13 -0
  55. package/lib/mechanism-catalog.js +24 -0
  56. package/lib/mechanism-css.js +13 -0
  57. package/lib/mechanism-entry.js +20 -0
  58. package/lib/mechanism-geometry.js +62 -0
  59. package/lib/mechanism-render.js +24 -0
  60. package/lib/mechanism-runtime-bundle.js +2 -0
  61. package/lib/mechanism-scenes.js +20 -0
  62. package/lib/motion-library.js +18 -0
  63. package/lib/normalize-authoring.js +52 -3
  64. package/lib/normalize-visual.js +36 -0
  65. package/lib/presentation.js +1 -1
  66. package/lib/protocol.js +361 -318
  67. package/lib/sandbox.js +2 -0
  68. package/lib/scene-library.js +13 -0
  69. package/lib/store.js +17 -2
  70. package/lib/stream.js +12 -0
  71. package/lib/style-system.js +28 -0
  72. package/lib/text-document.js +25 -0
  73. package/lib/text-guide.js +13 -0
  74. package/lib/third-party/anatomy-LICENSE.txt +21 -0
  75. package/lib/third-party/anatomy-NOTICE.md +13 -0
  76. package/lib/third-party/anatomy-iso.mjs +674 -0
  77. package/lib/third-party/bundled/@braintree_sanitize-url-LICENSE +21 -0
  78. package/lib/third-party/bundled/@iconify_utils-license.txt +21 -0
  79. package/lib/third-party/bundled/@mermaid-js_parser-LICENSE +21 -0
  80. package/lib/third-party/bundled/@upsetjs_venn.js-LICENSE +22 -0
  81. package/lib/third-party/bundled/cose-base-LICENSE +21 -0
  82. package/lib/third-party/bundled/cytoscape-LICENSE +19 -0
  83. package/lib/third-party/bundled/cytoscape-cose-bilkent-LICENSE +21 -0
  84. package/lib/third-party/bundled/cytoscape-fcose-LICENSE +19 -0
  85. package/lib/third-party/bundled/cytoscape-license-update.mjs +32 -0
  86. package/lib/third-party/bundled/d3-LICENSE +13 -0
  87. package/lib/third-party/bundled/d3-array-LICENSE +27 -0
  88. package/lib/third-party/bundled/d3-axis-LICENSE +13 -0
  89. package/lib/third-party/bundled/d3-brush-LICENSE +13 -0
  90. package/lib/third-party/bundled/d3-chord-LICENSE +13 -0
  91. package/lib/third-party/bundled/d3-color-LICENSE +13 -0
  92. package/lib/third-party/bundled/d3-contour-LICENSE +13 -0
  93. package/lib/third-party/bundled/d3-delaunay-LICENSE +14 -0
  94. package/lib/third-party/bundled/d3-dispatch-LICENSE +13 -0
  95. package/lib/third-party/bundled/d3-drag-LICENSE +13 -0
  96. package/lib/third-party/bundled/d3-dsv-LICENSE +13 -0
  97. package/lib/third-party/bundled/d3-ease-LICENSE +28 -0
  98. package/lib/third-party/bundled/d3-fetch-LICENSE +13 -0
  99. package/lib/third-party/bundled/d3-force-LICENSE +13 -0
  100. package/lib/third-party/bundled/d3-format-LICENSE +13 -0
  101. package/lib/third-party/bundled/d3-geo-LICENSE +34 -0
  102. package/lib/third-party/bundled/d3-hierarchy-LICENSE +13 -0
  103. package/lib/third-party/bundled/d3-interpolate-LICENSE +13 -0
  104. package/lib/third-party/bundled/d3-path-LICENSE +27 -0
  105. package/lib/third-party/bundled/d3-polygon-LICENSE +13 -0
  106. package/lib/third-party/bundled/d3-quadtree-LICENSE +13 -0
  107. package/lib/third-party/bundled/d3-random-LICENSE +13 -0
  108. package/lib/third-party/bundled/d3-sankey-LICENSE +27 -0
  109. package/lib/third-party/bundled/d3-scale-LICENSE +13 -0
  110. package/lib/third-party/bundled/d3-scale-chromatic-LICENSE +28 -0
  111. package/lib/third-party/bundled/d3-selection-LICENSE +13 -0
  112. package/lib/third-party/bundled/d3-shape-LICENSE +13 -0
  113. package/lib/third-party/bundled/d3-time-LICENSE +13 -0
  114. package/lib/third-party/bundled/d3-time-format-LICENSE +13 -0
  115. package/lib/third-party/bundled/d3-timer-LICENSE +13 -0
  116. package/lib/third-party/bundled/d3-transition-LICENSE +13 -0
  117. package/lib/third-party/bundled/d3-zoom-LICENSE +13 -0
  118. package/lib/third-party/bundled/dagre-d3-es-LICENSE.md +23 -0
  119. package/lib/third-party/bundled/dayjs-LICENSE +21 -0
  120. package/lib/third-party/bundled/delaunator-LICENSE +15 -0
  121. package/lib/third-party/bundled/dompurify-LICENSE +202 -0
  122. package/lib/third-party/bundled/dompurify-LICENSE-MPL +373 -0
  123. package/lib/third-party/bundled/echarts-LICENSE +222 -0
  124. package/lib/third-party/bundled/echarts-NOTICE +5 -0
  125. package/lib/third-party/bundled/es-toolkit-LICENSE +21 -0
  126. package/lib/third-party/bundled/es-toolkit-NOTICE +39 -0
  127. package/lib/third-party/bundled/internmap-LICENSE +13 -0
  128. package/lib/third-party/bundled/katex-LICENSE +21 -0
  129. package/lib/third-party/bundled/khroma-license +21 -0
  130. package/lib/third-party/bundled/layout-base-LICENSE +21 -0
  131. package/lib/third-party/bundled/lodash-es-LICENSE +47 -0
  132. package/lib/third-party/bundled/marked-LICENSE.md +44 -0
  133. package/lib/third-party/bundled/mermaid-LICENSE +21 -0
  134. package/lib/third-party/bundled/react-LICENSE +21 -0
  135. package/lib/third-party/bundled/react-dom-LICENSE +21 -0
  136. package/lib/third-party/bundled/robust-predicates-LICENSE +24 -0
  137. package/lib/third-party/bundled/roughjs-LICENSE +21 -0
  138. package/lib/third-party/bundled/scheduler-LICENSE +21 -0
  139. package/lib/third-party/bundled/stylis-LICENSE +21 -0
  140. package/lib/third-party/bundled/three-LICENSE +21 -0
  141. package/lib/third-party/bundled/ts-dedent-LICENSE +21 -0
  142. package/lib/third-party/bundled/tslib-LICENSE.txt +12 -0
  143. package/lib/third-party/bundled/uuid-LICENSE.md +9 -0
  144. package/lib/third-party/bundled/zrender-LICENSE +29 -0
  145. package/lib/third-party/dsh-genui-LICENSE.txt +21 -0
  146. package/lib/third-party/dsh-genui-NOTICE.md +26 -0
  147. package/lib/third-party/echarts-LICENSE.txt +222 -0
  148. package/lib/third-party/echarts-NOTICE.txt +5 -0
  149. package/lib/third-party/katex-LICENSE.txt +21 -0
  150. package/lib/third-party/lucian-uxui-LICENSE.txt +21 -0
  151. package/lib/third-party/lucian-uxui-NOTICE.md +1 -0
  152. package/lib/third-party/mermaid-LICENSE.txt +21 -0
  153. package/lib/third-party/three-LICENSE.txt +21 -0
  154. package/lib/tool-schema.js +20 -9
  155. package/lib/typography.js +16 -0
  156. package/lib/ui-intent.js +15 -14
  157. package/lib/ui-skill.js +54 -47
  158. package/lib/visual-assets.js +7 -0
  159. package/lib/visual-defaults.js +2 -0
  160. package/lib/visual-guard.js +2 -0
  161. package/lib/visual-styles.js +142 -0
  162. package/lib/visual.js +40 -0
  163. package/package.json +20 -5
  164. package/skills/intelligent-ui/SKILL.md +22 -2
@@ -0,0 +1,222 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
204
+
205
+
206
+
207
+
208
+ ========================================================================
209
+ Apache ECharts Subcomponents:
210
+
211
+ The Apache ECharts project contains subcomponents with separate copyright
212
+ notices and license terms. Your use of the source code for these
213
+ subcomponents is also subject to the terms and conditions of the following
214
+ licenses.
215
+
216
+ BSD 3-Clause (d3.js):
217
+ The following files embed [d3.js](https://github.com/d3/d3) BSD 3-Clause:
218
+ `/src/chart/treemap/treemapLayout.ts`,
219
+ `/src/chart/tree/layoutHelper.ts`,
220
+ `/src/chart/graph/forceHelper.ts`,
221
+ `/src/util/number.ts`
222
+ See `/licenses/LICENSE-d3` for details of the license.
@@ -0,0 +1,5 @@
1
+ Apache ECharts
2
+ Copyright 2017-2026 The Apache Software Foundation
3
+
4
+ This product includes software developed at
5
+ The Apache Software Foundation (https://www.apache.org/).
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013-2020 Khan Academy and other contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Seokwoooo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ Motion UI expressive controls adapt visual interaction patterns and selected CSS from Lucian UX/UI Prompt #002, #013, #018, by Seokwoooo, MIT License. Reference: https://github.com/Seokwoooo/lucian-uxui-prompt . Local user-provided copies were reviewed. Host actions, persistence, React controls and truthful result feedback are implemented by Motion UI. No simulated download, clipboard success or glass materials are included.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 - 2022 Knut Sveidqvist
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright © 2010-2025 three.js authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -4,36 +4,47 @@ import {COMPONENTS} from './components.js';
4
4
  const dictionary=description=>({type:'object',additionalProperties:true,description});
5
5
  export const DOCUMENT_PARAMETER={
6
6
  required:true,
7
- description:'Pass the document as an OBJECT. Do not manually escape/serialize it. For HTML/SVG source prefer render_canvas.',
7
+ description:'Pass one COMPLETE object, never manually serialize or send a partial patch. v1 always needs nodes:[...] beside state/derived; state alone creates no controls. Choose v1 {version:1,title,fallback,nodes} for shared state/formulas/canvas, OR extended {title,items:[components]} for charts/plots/quiz/forms/mermaid/3D. Do not mix the two root languages.',
8
8
  type:'object',additionalProperties:false,
9
9
  properties:{
10
- version:{type:'number',const:1,required:true},
10
+ version:{type:'number',const:1},
11
11
  title:{type:'string',required:true},
12
- fallback:{type:'string',required:true,description:'Useful plain-text explanation if the UI is unavailable.'},
13
- nodes:{type:'array',required:true,items:{type:'object',additionalProperties:true,properties:{
12
+ fallback:{type:'string',description:'Required for v1 nodes: useful plain-text explanation if UI is unavailable.'},
13
+ items:{type:'array',description:'Extended visual components: use their compact type-specific fields. See injected guide or ui_catalog topic=visual.',items:{type:'json'}},
14
+ nodes:{type:'array',items:{type:'object',additionalProperties:true,properties:{
14
15
  id:{type:'string',required:true,description:'Unique letter/underscore identifier; Chinese supported, max64.'},
15
16
  type:{type:'string',required:true,enum:Object.keys(COMPONENTS)},
17
+ spec:{type:'json',description:'visual only: extended {title?,items:[components]} composition.'},stateKey:{type:'string',description:'visual only: optional dedicated json state key, auto-created when omitted.'},warnings:{type:'json'},
16
18
  label:{type:'string'},title:{type:'string'},
19
+ copyable:{type:'boolean',description:'text only: rounded reusable text block with a copy button.'},code:{type:'string',description:'code only: literal source, preserved exactly and never executed.'},lang:{type:'string'},wrap:{type:'boolean'},
17
20
  items:{type:'array',description:'steps only: direct array, not {item:[...]}. 1..12 step objects. Omit status for a static process guide.',items:{type:'object',additionalProperties:false,properties:{
18
21
  title:{type:'string',required:true},description:{type:'string'},status:{type:'string',enum:['pending','active','done','error']}
19
22
  }}},
20
23
  open:{type:'boolean',description:'details only; defaults to closed.'},
21
24
  icon:{type:'string'},tone:{type:'string'},surface:{type:'string'},
25
+ size:{type:'json',description:'text/heading: 12..48 pixels or sm/md/lg/xl/hero.'},weight:{type:'number',enum:[400,500,600,700,800]},color:{type:'string',description:'default/muted/accent/success/warning/danger/violet or #RGB/#RRGGBB.'},align:{type:'string',enum:['left','center','right']},lineHeight:{type:'number'},
26
+ spans:{type:'json',description:'text/heading: array of {text,size?,weight?,color?}; use instead of text for inline emphasis.'},gap:{type:'number'},
22
27
  max:{type:'json',description:'progress only: positive numeric value or binding.'},unit:{type:'string'},decimals:{type:'number'},
23
28
  action:{type:'string',description:'button only: a key declared in document.actions.'},
29
+ href:{type:'string',description:'link/button: absolute http/https URL. Choose exactly one href/path/action.'},path:{type:'string',description:'link/button: local file path opened through DSH on user click; never a shell command.'},variant:{type:'string',enum:['primary','secondary','text','dropdown','segmented']},
24
30
  kind:{type:'string',enum:['bar','line']},labelKey:{type:'string'},valueKey:{type:'string'},xScale:{type:'string'},
25
31
  html:{type:'string'},css:{type:'string'},script:{type:'string'},fallback:{type:'string'},height:{type:'number'},
26
- stateKeys:{type:'array',items:{type:'string'}},dataKeys:{type:'array',items:{type:'string'}},derivedKeys:{type:'array',items:{type:'string'}},
32
+ libraries:{type:'array',items:{type:'string',enum:['mechanism']},description:'Optional local mechanism drawing helper; ui_catalog topic=mechanism.'},stateKeys:{type:'array',items:{type:'string'}},dataKeys:{type:'array',items:{type:'string'}},derivedKeys:{type:'array',items:{type:'string'}},
27
33
  text:{type:'json',description:'Literal scalar or {ref}/{expr}.'},
28
34
  value:{type:'json',description:'metric: number or display string/boolean, or {ref}/{expr}. progress: numeric.'},
29
- rows:{type:'json',description:'table/chart: inline array of objects, {ref:"data.rows"}/{ref:"derived.rows"}, or scoped reference string.'},
30
- columns:{type:'array',items:{type:'object',additionalProperties:false,properties:{key:{type:'string',required:true},label:{type:'string',required:true},unit:{type:'string'}}}},
35
+ rows:{type:'json',description:'table/chart: inline rows with literal or formula cells, e.g. [{label:"餐饮",value:{ref:"derived.food"}}] or [{label:"住宿",value:{expr:"ceil(state.people / 2) * state.room"}}]. This is the simplest live breakdown; no map required. Also accepts {ref:"data.rows"}/{ref:"derived.rows"}, or scoped reference string.'},
36
+ columns:{type:'json',description:'table: column object array; row: optional integer 1..4 for equal grid columns.'},
31
37
  bind:{type:'string',description:'Controls bind state.key.'},children:{type:'array',description:'row/column/card/details: array of registered nodes using the same fields and type-specific rules. steps uses items instead of children.',items:{type:'json'}}
32
38
  }}},
33
39
  state:dictionary('key -> state specification object, e.g. {people:{type:"number",default:2,min:1,max:12,step:1}}. Numeric defaults/min/max/step are JSON numbers, no units. String/boolean/json state keeps its declared type; options is a direct scalar array. Do not omit numeric limits. json is bounded array/object state for canvas controls.'),
34
40
  data:dictionary('Static data; Chinese identifier keys supported. Omit if rows are inline.'),
35
- derived:dictionary('Local formulas, e.g. {food:{expr:"state.people * state.days * 100"}}. Prefer expr shorthand to deeply nested op/args. round(x) has one argument and uses Math.round (ties toward positive infinity); ceil/floor are not native formula functions. op/args uses direct arrays and numeric constants, not item wrappers. Use ui_catalog for protocol questions, not installation source searches. Omit when unused.'),
41
+ derived:dictionary('Local formulas, e.g. {food:{expr:"state.people * state.days * 100"}}. Prefer expr shorthand to deeply nested op/args. round(x), ceil(x), floor(x) and abs(x) each take one argument. ceil(state.people / 2) is supported directly; do not search source or switch to a canvas for rounding. op/args uses direct arrays and numeric constants, not item wrappers. Use ui_catalog for protocol questions, not installation source searches. Omit when unused.'),
36
42
  actions:dictionary('Declared agent.followup actions. Omit when unused.'),
37
- presentation:dictionary('Optional layout/accent/density from registered tokens.')
43
+ presentation:dictionary('Optional layout/accent/density and preset: reading/brief/comparison/list/callout/scorecard/flow/minimal. Every document owns its own styles.')
38
44
  }
39
45
  };
46
+
47
+ // Keep the native transport schema shallow. A recursively expanded union of
48
+ // every component makes the lightweight tool harder to call; the shared
49
+ // runtime validator still enforces exact component fields and limits.
50
+ export const TEXT_BLOCKS_PARAMETER={type:'array',required:true,items:{type:'json'},description:'Direct array of text strings or native v1 nodes with optional IDs. Examples: [{type:"text",text:"Answer"}], or [{type:"steps",items:[{title:"First",description:"One sentence"}]}]. Reusable text: {type:"text",copyable:true,title:"Draft",text:"..."}; code: {type:"code",lang:"bash",code:"..."}, always copyable. Layout nodes use children:[nodes]; text may use spans:[{text,weight?,color?}] instead of text. Keep all content/styling inside blocks. Do not serialize the array or wrap it in {item:[...]}. ui_catalog topic=quick supplies exact fields and examples.'};
@@ -0,0 +1,16 @@
1
+ // Small native vocabulary: no arbitrary CSS, markup or callbacks.
2
+ export const TEXT_PRESETS=Object.freeze(['reading','brief','comparison','list','callout','scorecard','flow','minimal']);
3
+ export const TYPE_FIELDS=Object.freeze(['size','weight','color','align','lineHeight']);
4
+ export const TEXT_SIZES=Object.freeze({sm:14,md:16,lg:20,xl:26,hero:36});
5
+ export const TEXT_COLORS=Object.freeze({default:'var(--du-ink)',muted:'var(--du-muted)',accent:'var(--du-accent)',success:'var(--du-green)',warning:'var(--du-amber)',danger:'var(--du-red)',violet:'var(--du-violet)'});
6
+ export function validateTypography(value,at='text'){
7
+ const fail=message=>{throw Error(`DSH UI: ${at}.${message}`)};
8
+ if(value.size!==undefined&&!(typeof value.size==='number'&&Number.isFinite(value.size)&&value.size>=12&&value.size<=48)&&!Object.hasOwn(TEXT_SIZES,value.size))fail('size must be 12..48 px or sm/md/lg/xl/hero');
9
+ if(value.weight!==undefined&&![400,500,600,700,800].includes(value.weight))fail('weight must be 400/500/600/700/800');
10
+ if(value.color!==undefined&&(typeof value.color!=='string'||!Object.hasOwn(TEXT_COLORS,value.color)&&!/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(value.color)))fail('color must be default/muted/accent/success/warning/danger/violet or #RGB/#RRGGBB');
11
+ if(value.align!==undefined&&!['left','center','right'].includes(value.align))fail('align must be left/center/right');
12
+ if(value.lineHeight!==undefined&&!(typeof value.lineHeight==='number'&&value.lineHeight>=1.2&&value.lineHeight<=2.4))fail('lineHeight must be 1.2..2.4');
13
+ }
14
+ export function typographyStyle(value){
15
+ return {fontSize:value.size===undefined?undefined:TEXT_SIZES[value.size]??value.size,fontWeight:value.weight,color:value.color===undefined?undefined:TEXT_COLORS[value.color]??value.color,textAlign:value.align,lineHeight:value.lineHeight};
16
+ }
package/lib/ui-intent.js CHANGED
@@ -1,14 +1,15 @@
1
- // Shared behavior, not a visual template: free mode keeps the same intent policy.
2
- export const UI_INTENT_POLICY = `## 表达选择与首次交付
3
- 简单公式可用 {expr:"state.V * state.V / state.R"},无需堆叠 op/args。支持显式 state/data/derived/item 引用、四则运算、比较、三元条件及 min/max/round/abs;编译后仍按原协议校验。函数、语句和其他 JavaScript 不受支持,复杂动画使用画布。
4
- 无需等待用户说“UI”“可视化”或指定工具。先用一个简短判断选择表达方式,然后直接回答或提交界面,不向用户复述设计推理:
5
- - 用户明确要求交互界面、图解或动画:交付对应 UI;已要求纯文字、不要界面、只给代码时遵从用户。
6
- - 用户没提 UI,但问题的关键是参数变化如何影响结果、多个方案的权衡、时间趋势、空间结构或流程关系:当图形或操作比文字明显更易懂时主动使用 UI。不能只因出现数字、多个条目或技术名词就触发。
7
- - 简单事实、单次数值换算、短定义、普通代码排错:直接文字。一个静态小表格足够时不必创建交互应用;静态图解、方案对比、流程和看板也都是 UI 的正常用途。不确定有无收益时选更简单的表达,不询问“要不要我做个 UI”。
8
- 对照:问“复利是什么,简短解释”→文字;问“5万元按3%、5%、7%存10年,为什么后期差距更大”→可主动给增长曲线与年数调整,配准确数值和简短解释;问“解释七速自行车各档如何影响踏频和行进”→可主动给传动示意与档位选择;问“1 GiB是多少字节”→文字。例子只指导时机,不规定构图或配色。
9
- 首次交付只解决一个核心关系。立即选择最小完整方案并调用工具,不穷举设计选项,不先写长篇视觉规划,不等待“完美”再提交。默认一幅静态主图、一个短流程、一个对齐对比或一个简洁看板即可;没有明确交互收益时不建 state、不写 script、不加控件和动画。静态可视化本身就是完整交付;只有用户需要操作时才保证对应交互。用户的必要要求不能省略。
10
- 仅数值试算优先原生组件;计算超出 derived 白名单(例如幂、三角函数)时不要臆造算子或堆复杂表达式,改用小画布中的单一计算函数同步图与数值。结构或运动讲解选择一块自由画布,直接使用 render_canvas 的独立源码字段。避免首次创建多页应用、自制组件库或庞大绘图引擎。除非用户或宿主另有要求,对话内的简短交互讲解无需建立项目、编辑文件或制定任务清单。工具提交前检查绑定、初始图可见、改变参数有反馈、标签/单位和 fallback;不为简单任务反复读全部目录。
11
- 必要的布局与排版从首次提交就做好:DSH 以 PC 横屏为主要使用场景,优先保证 1365px/1920px 桌面视口中实际聊天区域的构图与可读性,不假设画布等于整个浏览器宽度。主体突出、文字可读、控件有标签,装饰不挤占内容;手机适配是补充,不为窄屏牺牲桌面主体。Canvas 2D 按实际 CSS 像素布局,不整体缩放到文字难辨;动态数值和关键标签可放 HTML,绘图高度匹配内容,避免大块空白。
12
- 首屏应能看见主要关系、关键操作及当前结果。用户问“为什么变化不同”,优先用能对照变化的图形;发光、粒子或装饰不能代替趋势或关系证据。主图紧邻控件,推导、完整表格和次要说明随后呈现;同一数值不在指标、图注、卡片和正文反复展示。不要把所有可用组件都用一遍,也不为减少滚动而缩小字。比较不同单位的量,分别标轴或明确使用相对同一基准的无量纲倍数,不能把原始数值放在同一未说明尺度上暗示快慢。这些是信息优先级要求,具体图形、构图与风格仍按问题自行设计。
13
- 不把“最小”理解成粗糙或缺功能。成功后简短说明如何操作和假设;针对实际问题再局部修改。主动增强最多一次且确有价值,自动纠错仍最多两轮。无法交付时提供有效解释并如实说明,不声称已展示。
14
- 这是一项行为要求,不能保证模型推理时长;宿主没有提供真实计时信息时不要虚报交付秒数。`;
1
+ // Shared behavior, not a visual template: free mode keeps the same intent policy.
2
+ export const UI_INTENT_POLICY = `## 表达选择与首次交付
3
+ 简单公式可用 {expr:"state.V * state.V / state.R"},无需堆叠 op/args。支持显式 state/data/derived/item 引用、四则运算、比较、三元条件及 min/max/round/abs;编译后仍按原协议校验。函数、语句和其他 JavaScript 不受支持,复杂动画使用画布。
4
+ 无需等待用户说“UI”“可视化”或指定工具。先用一个简短判断选择表达方式,然后直接回答或提交界面,不向用户复述设计推理:
5
+ - 用户明确要求交互界面、图解或动画:交付对应 UI;已要求纯文字、不要界面、只给代码时遵从用户。
6
+ - 用户没提 UI,但问题的关键是参数变化如何影响结果、多个方案的权衡、时间趋势、空间结构或流程关系:当图形或操作比文字明显更易懂时主动使用 UI。不能只因出现数字、多个条目或技术名词就触发。
7
+ - 简单事实、单次数值换算、短定义、普通代码排错:直接文字。一个静态小表格足够时不必创建交互应用;静态图解、方案对比、流程和看板也都是 UI 的正常用途。不确定有无收益时选更简单的表达,不询问“要不要我做个 UI”。
8
+ 对照:问“复利是什么,简短解释”→文字;问“5万元按3%、5%、7%存10年,为什么后期差距更大”→可主动给增长曲线与年数调整,配准确数值和简短解释;问“解释七速自行车各档如何影响踏频和行进”→可主动给传动示意与档位选择;问“1 GiB是多少字节”→文字。例子只指导时机,不规定构图或配色。
9
+ 每块界面只解决一个核心关系;一轮回复可按讲解顺序生成多块独立界面。立即选择最小完整方案并调用工具,不穷举设计选项,不先写长篇视觉规划,不等待“完美”再提交。每块默认用一幅静态主图、一个短流程、一个对齐对比或一个简洁看板即可;没有明确交互收益时不建 state、不写 script、不加控件和动画。静态可视化本身就是完整交付;只有用户需要操作时才保证对应交互。用户的必要要求不能省略。
10
+ 仅数值试算优先原生组件;计算超出 derived 白名单(例如幂、三角函数)时不要臆造算子或堆复杂表达式,改用小画布中的单一计算函数同步图与数值。常见装配/齿轮/曲柄连杆讲解优先用 render_mechanism 的少量参数直接交付;其他结构或运动讲解选择自由画布,使用 render_canvas 的独立源码字段,按需读取 mechanism 辅助库接口。避免首次创建多页应用、自制组件库或庞大绘图引擎。除非用户或宿主另有要求,对话内的简短交互讲解无需建立项目、编辑文件或制定任务清单。工具提交前检查绑定、初始图可见、改变参数有反馈、标签/单位和 fallback;不为简单任务反复读全部目录。
11
+ 必要的布局与排版从首次提交就做好:DSH 以 PC 横屏为主要使用场景,优先保证 1365px/1920px 桌面视口中实际聊天区域的构图与可读性,不假设画布等于整个浏览器宽度。主体突出、文字可读、控件有标签,装饰不挤占内容;手机适配是补充,不为窄屏牺牲桌面主体。Canvas 2D 按实际 CSS 像素布局,不整体缩放到文字难辨;动态数值和关键标签可放 HTML,绘图高度匹配内容,避免大块空白。
12
+ 首屏应能看见主要关系、关键操作及当前结果。用户问“为什么变化不同”,优先用能对照变化的图形;发光、粒子或装饰不能代替趋势或关系证据。主图紧邻控件,推导、完整表格和次要说明随后呈现;同一数值不在指标、图注、卡片和正文反复展示。不要把所有可用组件都用一遍,也不为减少滚动而缩小字。比较不同单位的量,分别标轴或明确使用相对同一基准的无量纲倍数,不能把原始数值放在同一未说明尺度上暗示快慢。这些是信息优先级要求,具体图形、构图与风格仍按问题自行设计。
13
+ 不把“最小”理解成粗糙或缺功能。交付所有必要内容后简短说明如何操作和假设;针对实际问题再局部修改。主动增强最多一次且确有价值,这是完成用户要求后的额外润色,不限制同一回复的 UI 数量或必要工具次数;用户要求几块不同内容就分别完成,不能第一块成功后提前结束。自动纠错仍最多两轮。无法交付时提供有效解释并如实说明,不声称已展示。
14
+ 交付检查:如果决定生成 UI,先实际调用渲染工具并检查成功结果,或写出完整的 UI 源码围栏,然后再结束回复。“现在补上组件”“我会画图”只是承诺,不是交付。工具报错后修正实际参数并重新提交;若无法完成,给出有用的文字答案和真实失败原因,不用另一句承诺收尾。
15
+ 这是一项行为要求,不能保证模型推理时长;宿主没有提供真实计时信息时不要虚报交付秒数。`;
package/lib/ui-skill.js CHANGED
@@ -1,47 +1,54 @@
1
- import { readFileSync } from 'node:fs';
2
- import { PROTOCOL_GUIDE } from './catalog.js';
3
- import { CANVAS_DESIGN_GUIDE } from './canvas-design.js';
4
- import { FREE_UI_CONTRACT } from './freeform.js';
5
- import { UI_INTENT_POLICY } from './ui-intent.js';
6
- import { CANVAS_SYSTEM_GUIDE } from './canvas-system.js';
7
- import {QUICK_EXAMPLES,QUICK_GUIDE} from './quick-examples.js';
8
-
9
- // Authored examples are deliberately small enough to be present in every model's context.
10
- export const SKILL_EXAMPLES = [
11
- {
12
- version: 1, title: '示例 · 数量与费用', fallback: '演示:单价 12 元,数量默认 2,总额 24 元。不是报价。',
13
- presentation: { layout: 'workbench', accent: 'teal', density: 'comfortable' },
14
- state: { quantity: { type: 'number', default: 2, min: 1, max: 10, step: 1 } },
15
- derived: { total: { op: 'mul', args: [{ ref: 'state.quantity' }, { const: 12 }] } },
16
- nodes: [
17
- { id: 'quantity', type: 'slider', label: '数量(件)', bind: 'state.quantity' },
18
- { id: 'total', type: 'metric', label: '演示总额', value: { ref: 'derived.total' }, unit: '元', decimals: 0 },
19
- { id: 'note', type: 'text', text: '示例单价,非实际报价。' }
20
- ]
21
- },
22
- {
23
- version: 1, title: '示例 · 周期运动', fallback: '一个圆点沿横向做周期运动。速度可调,运行可暂停;数学动画示意,非真实物理仿真。',
24
- presentation: { layout: 'workbench', accent: 'blue' },
25
- state: { speed: { type: 'number', default: 1, min: 1, max: 3, step: 1 }, running: { type: 'boolean', default: false } },
26
- nodes: [
27
- { id: 'motion', type: 'sandbox', title: '周期运动示意', height: 220, stateKeys: ['speed', 'running'], fallback: '圆点沿直线往返。运行开关控制暂停,速度从 1 到 3。',
28
- html: '<svg viewBox="0 0 360 140" role="img" aria-label="圆点沿直线往返"><path d="M40 70H320" stroke="var(--canvas-line)"/><circle id="dot" cx="180" cy="70" r="16" fill="var(--canvas-accent)"/></svg><p id="caption"></p>',
29
- css: 'svg{display:block;width:100%;height:150px}p{margin:8px 12px;font-size:14px;color:var(--canvas-ink)}',
30
- script: "let state={speed:1,running:false},phase=0;const dot=document.getElementById('dot'),caption=document.getElementById('caption');const unsubscribe=DSHUI.subscribe(s=>{state=s.state;caption.textContent=(state.running?'运行':'暂停')+' · 速度 '+state.speed+' · 数学示意,非物理仿真'});const stop=DSHUI.animate(({delta,reducedMotion,visible})=>{if(state.running&&!reducedMotion&&visible)phase+=delta*state.speed;dot.setAttribute('cx',String(180+120*Math.sin(phase)))});addEventListener('pagehide',()=>{stop();unsubscribe()},{once:true});"
31
- },
32
- { id: 'speed', type: 'slider', label: '演示速度(倍)', bind: 'state.speed' },
33
- { id: 'running', type: 'toggle', label: '运行(关闭后保持当前位置)', bind: 'state.running' }
34
- ]
35
- }
36
- ];
37
-
38
- const skill = readFileSync(new URL('../skills/intelligent-ui/SKILL.md', import.meta.url), 'utf8');
39
- export const UI_SKILL_SECTIONS = Object.freeze([
40
- { name: 'generative-ui:design-skill', order: 850, interpolate: false, text: UI_INTENT_POLICY + '\n\n' + skill + '\n\nCanvas composition details:\n' + CANVAS_DESIGN_GUIDE + '\n\nConstruction handbook:\n' + CANVAS_SYSTEM_GUIDE },
41
- { name: 'generative-ui:protocol', order: 851, interpolate: false, text: PROTOCOL_GUIDE },
42
- { name: 'generative-ui:worked-examples', order: 852, interpolate: false, text: QUICK_GUIDE+'\nThese valid render_ui examples start with static flow and comparison; the last adds a control only for a calculation. Adapt to the user, not their demo claims. Submit as render_ui({document: ...}). Animation examples remain available via ui_catalog({topic:"canvas"}).\n' + [QUICK_EXAMPLES[0],QUICK_EXAMPLES[1],SKILL_EXAMPLES[0]].map(doc => JSON.stringify(doc)).join('\n') }
43
- ]);
44
- export function promptSections(mode='guided'){
45
- if(!['guided','free'].includes(mode))throw new Error('DSH UI: designMode must be guided or free');
46
- return mode==='guided'?UI_SKILL_SECTIONS:UI_SKILL_SECTIONS.map((s,i)=>({...s,text:i===0?UI_INTENT_POLICY+'\n\n'+FREE_UI_CONTRACT:''}));
47
- }
1
+ import {MOTION_GUIDE,MOTION_INTERFACE} from './motion-library.js';
2
+ import { readFileSync } from 'node:fs';
3
+ import { PROTOCOL_GUIDE } from './catalog.js';
4
+ import { CANVAS_DESIGN_GUIDE } from './canvas-design.js';
5
+ import { FREE_UI_CONTRACT } from './freeform.js';
6
+ import { UI_INTENT_POLICY } from './ui-intent.js';
7
+ import { CANVAS_SYSTEM_GUIDE } from './canvas-system.js';
8
+ import {QUICK_EXAMPLES,QUICK_GUIDE} from './quick-examples.js';
9
+ import {TEXT_GUIDE,TEXT_INTERFACE} from './text-guide.js';
10
+ import {DEFAULT_VISUAL_STYLE,stylePrompt,styleExamples,visualStyle} from './visual-styles.js';
11
+ import {VISUAL_GUIDE,VISUAL_INTERFACE} from './visual.js';
12
+
13
+ // Authored examples are deliberately small enough to be present in every model's context.
14
+ export const SKILL_EXAMPLES = [
15
+ {
16
+ version: 1, title: '示例 · 数量与费用', fallback: '演示:单价 12 元,数量默认 2,总额 24 元。不是报价。',
17
+ presentation: { layout: 'workbench', accent: 'teal', density: 'comfortable' },
18
+ state: { quantity: { type: 'number', default: 2, min: 1, max: 10, step: 1 } },
19
+ derived: { total: { op: 'mul', args: [{ ref: 'state.quantity' }, { const: 12 }] } },
20
+ nodes: [
21
+ { id: 'quantity', type: 'slider', label: '数量(件)', bind: 'state.quantity' },
22
+ { id: 'total', type: 'metric', label: '演示总额', value: { ref: 'derived.total' }, unit: '元', decimals: 0 },
23
+ { id: 'note', type: 'text', text: '示例单价,非实际报价。' }
24
+ ]
25
+ },
26
+ {
27
+ version: 1, title: '示例 · 周期运动', fallback: '一个圆点沿横向做周期运动。速度可调,运行可暂停;数学动画示意,非真实物理仿真。',
28
+ presentation: { layout: 'workbench', accent: 'blue' },
29
+ state: { speed: { type: 'number', default: 1, min: 1, max: 3, step: 1 }, running: { type: 'boolean', default: false } },
30
+ nodes: [
31
+ { id: 'motion', type: 'sandbox', title: '周期运动示意', height: 220, stateKeys: ['speed', 'running'], fallback: '圆点沿直线往返。运行开关控制暂停,速度从 1 到 3。',
32
+ html: '<svg viewBox="0 0 360 140" role="img" aria-label="圆点沿直线往返"><path d="M40 70H320" stroke="var(--canvas-line)"/><circle id="dot" cx="180" cy="70" r="16" fill="var(--canvas-accent)"/></svg><p id="caption"></p>',
33
+ css: 'svg{display:block;width:100%;height:150px}p{margin:8px 12px;font-size:14px;color:var(--canvas-ink)}',
34
+ script: "let state={speed:1,running:false},phase=0;const dot=document.getElementById('dot'),caption=document.getElementById('caption');const unsubscribe=DSHUI.subscribe(s=>{state=s.state;caption.textContent=(state.running?'运行':'暂停')+' · 速度 '+state.speed+' · 数学示意,非物理仿真'});const stop=DSHUI.animate(({delta,reducedMotion,visible})=>{if(state.running&&!reducedMotion&&visible)phase+=delta*state.speed;dot.setAttribute('cx',String(180+120*Math.sin(phase)))});addEventListener('pagehide',()=>{stop();unsubscribe()},{once:true});"
35
+ },
36
+ { id: 'speed', type: 'slider', label: '演示速度(倍)', bind: 'state.speed' },
37
+ { id: 'running', type: 'toggle', label: '运行(关闭后保持当前位置)', bind: 'state.running' }
38
+ ]
39
+ }
40
+ ];
41
+
42
+ const skill = readFileSync(new URL('../skills/intelligent-ui/SKILL.md', import.meta.url), 'utf8');
43
+ export const UI_SKILL_SECTIONS = Object.freeze([
44
+ { name: 'generative-ui:design-skill', order: 850, interpolate: false, text: TEXT_GUIDE+'\n\n'+MOTION_GUIDE+'\n\n'+UI_INTENT_POLICY + '\n\n' + skill + '\n\nCanvas composition details:\n' + CANVAS_DESIGN_GUIDE + '\n\nConstruction handbook:\n' + CANVAS_SYSTEM_GUIDE },
45
+ { name: 'generative-ui:protocol', order: 851, interpolate: false, text: PROTOCOL_GUIDE },
46
+ { name: 'generative-ui:worked-examples', order: 852, interpolate: false, text: QUICK_GUIDE+'\nThese valid render_ui examples start with static flow and comparison; the last adds a control only for a calculation. Adapt to the user, not their demo claims. Submit as render_ui({document: ...}). Animation examples remain available via ui_catalog({topic:"canvas"}).\n' + [QUICK_EXAMPLES[0],QUICK_EXAMPLES[1],SKILL_EXAMPLES[0]].map(doc => JSON.stringify(doc)).join('\n') }
47
+ ]);
48
+ export function promptSections(mode='guided',style=DEFAULT_VISUAL_STYLE){
49
+ if(!['guided','free'].includes(mode))throw new Error('DSH UI: designMode must be guided or free');
50
+ visualStyle(style);
51
+ return mode==='guided'?UI_SKILL_SECTIONS.map((s,i)=>({...s,text:i===0?VISUAL_GUIDE+'\n\n'+s.text+'\n\n'+stylePrompt(style):i===2?QUICK_GUIDE+'\nSelected visual-style examples follow. Each entry names the tool and its args; call that tool with args only. The shared calculation example preserves the same protocol and interaction.\n'+styleExamples(style)+'\n'+JSON.stringify({tool:'render_ui',args:{document:SKILL_EXAMPLES[0]}}):s.text})):UI_SKILL_SECTIONS.map((s,i)=>({...s,text:i===0?VISUAL_INTERFACE+'\n\n'+TEXT_INTERFACE+'\n\n'+MOTION_INTERFACE+'\n\n'+UI_INTENT_POLICY+'\n\n'+FREE_UI_CONTRACT:''}));
52
+ }
53
+
54
+
@@ -0,0 +1,7 @@
1
+ import {readFileSync,readdirSync} from 'node:fs';
2
+ const root=new URL('./assets/',import.meta.url);
3
+ export function registerVisualAssets(ctx){
4
+ const register=(directory,prefix='')=>{for(const f of readdirSync(directory,{withFileTypes:true})){if(f.isDirectory()){register(new URL(f.name+'/',directory),prefix+f.name+'/');continue}const name=prefix+f.name;if(!/\.(js|css|woff2)$/.test(name))continue;
5
+ ctx.effect(()=>ctx.connection.fetch.register({path:'/api/plugins/dsh-generative-ui/assets/'+name,methods:['GET'],requestBody:'buffered',fetch:()=>new Response(readFileSync(new URL(f.name,directory)),{headers:{'Content-Type':name.endsWith('.js')?'text/javascript; charset=utf-8':name.endsWith('.css')?'text/css; charset=utf-8':'font/woff2','Cache-Control':'private, no-cache','X-Content-Type-Options':'nosniff'}})}));
6
+ }};register(root);
7
+ }
@@ -0,0 +1,2 @@
1
+ // Only declared form defaults participate; opaque JSON/source is not traversed.
2
+ export function visualDefaults(spec){const fields={};const walk=items=>{for(const n of items??[]){if(!n||typeof n!=='object')continue;if(n.id){if(['input','textarea'].includes(n.type)&&typeof n.value==='string')fields[n.id]=n.value;if(n.type==='slider')fields[n.id]=String(n.value??n.min??0);if(n.type==='select'&&Number.isInteger(n.selected)&&typeof n.options?.[n.selected]==='string')fields[n.id]=n.options[n.selected]}if(['card','row','col','grid'].includes(n.type))walk(n.items);if(n.type==='tabs')for(const t of n.tabs??[])walk(t.items);if(n.type==='accordion')for(const t of n.items??[])walk(t.items)}};walk(spec.items);return fields}