dsh-motion-ui 0.6.0 → 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.
- package/CHANGELOG.md +66 -0
- package/README.md +37 -1
- package/VERIFICATION.md +36 -0
- package/client.js +1856 -984
- package/examples/mechanism-assembly.json +50 -0
- package/examples/mechanism-crank.json +103 -0
- package/examples/mechanism-gears.json +103 -0
- package/index.js +115 -104
- package/lib/assets/standalone-runtime.js +3 -1
- package/lib/assets/visual.js +3 -1
- package/lib/author-expression.js +3 -2
- package/lib/authoring-guide.js +2 -1
- package/lib/build-info.js +1 -1
- package/lib/catalog.js +4 -4
- package/lib/components.js +2 -2
- package/lib/export-runtime-bundle.js +1 -1
- package/lib/expressive-examples.js +6 -0
- package/lib/fence-feedback.js +1 -1
- package/lib/freeform.js +4 -3
- package/lib/mechanism-catalog.js +24 -0
- package/lib/mechanism-css.js +13 -0
- package/lib/mechanism-entry.js +20 -0
- package/lib/mechanism-geometry.js +62 -0
- package/lib/mechanism-render.js +24 -0
- package/lib/mechanism-runtime-bundle.js +2 -0
- package/lib/mechanism-scenes.js +20 -0
- package/lib/motion-library.js +18 -0
- package/lib/normalize-authoring.js +6 -2
- package/lib/protocol.js +23 -8
- package/lib/sandbox.js +2 -0
- package/lib/style-system.js +28 -0
- package/lib/third-party/anatomy-LICENSE.txt +21 -0
- package/lib/third-party/anatomy-NOTICE.md +13 -0
- package/lib/third-party/anatomy-iso.mjs +674 -0
- package/lib/third-party/lucian-uxui-LICENSE.txt +21 -0
- package/lib/third-party/lucian-uxui-NOTICE.md +1 -0
- package/lib/tool-schema.js +5 -5
- package/lib/ui-intent.js +1 -1
- package/lib/ui-skill.js +3 -2
- package/lib/visual-styles.js +134 -22
- package/package.json +92 -92
- package/skills/intelligent-ui/SKILL.md +113 -100
|
@@ -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.
|
package/lib/tool-schema.js
CHANGED
|
@@ -4,7 +4,7 @@ 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
|
|
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
10
|
version:{type:'number',const:1},
|
|
@@ -26,19 +26,19 @@ export const DOCUMENT_PARAMETER={
|
|
|
26
26
|
spans:{type:'json',description:'text/heading: array of {text,size?,weight?,color?}; use instead of text for inline emphasis.'},gap:{type:'number'},
|
|
27
27
|
max:{type:'json',description:'progress only: positive numeric value or binding.'},unit:{type:'string'},decimals:{type:'number'},
|
|
28
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']},
|
|
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']},
|
|
30
30
|
kind:{type:'string',enum:['bar','line']},labelKey:{type:'string'},valueKey:{type:'string'},xScale:{type:'string'},
|
|
31
31
|
html:{type:'string'},css:{type:'string'},script:{type:'string'},fallback:{type:'string'},height:{type:'number'},
|
|
32
|
-
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'}},
|
|
33
33
|
text:{type:'json',description:'Literal scalar or {ref}/{expr}.'},
|
|
34
34
|
value:{type:'json',description:'metric: number or display string/boolean, or {ref}/{expr}. progress: numeric.'},
|
|
35
|
-
rows:{type:'json',description:'table/chart: inline
|
|
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
36
|
columns:{type:'json',description:'table: column object array; row: optional integer 1..4 for equal grid columns.'},
|
|
37
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'}}
|
|
38
38
|
}}},
|
|
39
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.'),
|
|
40
40
|
data:dictionary('Static data; Chinese identifier keys supported. Omit if rows are inline.'),
|
|
41
|
-
derived:dictionary('Local formulas, e.g. {food:{expr:"state.people * state.days * 100"}}. Prefer expr shorthand to deeply nested op/args. round(x)
|
|
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.'),
|
|
42
42
|
actions:dictionary('Declared agent.followup actions. Omit when unused.'),
|
|
43
43
|
presentation:dictionary('Optional layout/accent/density and preset: reading/brief/comparison/list/callout/scorecard/flow/minimal. Every document owns its own styles.')
|
|
44
44
|
}
|
package/lib/ui-intent.js
CHANGED
|
@@ -7,7 +7,7 @@ export const UI_INTENT_POLICY = `## 表达选择与首次交付
|
|
|
7
7
|
- 简单事实、单次数值换算、短定义、普通代码排错:直接文字。一个静态小表格足够时不必创建交互应用;静态图解、方案对比、流程和看板也都是 UI 的正常用途。不确定有无收益时选更简单的表达,不询问“要不要我做个 UI”。
|
|
8
8
|
对照:问“复利是什么,简短解释”→文字;问“5万元按3%、5%、7%存10年,为什么后期差距更大”→可主动给增长曲线与年数调整,配准确数值和简短解释;问“解释七速自行车各档如何影响踏频和行进”→可主动给传动示意与档位选择;问“1 GiB是多少字节”→文字。例子只指导时机,不规定构图或配色。
|
|
9
9
|
每块界面只解决一个核心关系;一轮回复可按讲解顺序生成多块独立界面。立即选择最小完整方案并调用工具,不穷举设计选项,不先写长篇视觉规划,不等待“完美”再提交。每块默认用一幅静态主图、一个短流程、一个对齐对比或一个简洁看板即可;没有明确交互收益时不建 state、不写 script、不加控件和动画。静态可视化本身就是完整交付;只有用户需要操作时才保证对应交互。用户的必要要求不能省略。
|
|
10
|
-
仅数值试算优先原生组件;计算超出 derived
|
|
10
|
+
仅数值试算优先原生组件;计算超出 derived 白名单(例如幂、三角函数)时不要臆造算子或堆复杂表达式,改用小画布中的单一计算函数同步图与数值。常见装配/齿轮/曲柄连杆讲解优先用 render_mechanism 的少量参数直接交付;其他结构或运动讲解选择自由画布,使用 render_canvas 的独立源码字段,按需读取 mechanism 辅助库接口。避免首次创建多页应用、自制组件库或庞大绘图引擎。除非用户或宿主另有要求,对话内的简短交互讲解无需建立项目、编辑文件或制定任务清单。工具提交前检查绑定、初始图可见、改变参数有反馈、标签/单位和 fallback;不为简单任务反复读全部目录。
|
|
11
11
|
必要的布局与排版从首次提交就做好:DSH 以 PC 横屏为主要使用场景,优先保证 1365px/1920px 桌面视口中实际聊天区域的构图与可读性,不假设画布等于整个浏览器宽度。主体突出、文字可读、控件有标签,装饰不挤占内容;手机适配是补充,不为窄屏牺牲桌面主体。Canvas 2D 按实际 CSS 像素布局,不整体缩放到文字难辨;动态数值和关键标签可放 HTML,绘图高度匹配内容,避免大块空白。
|
|
12
12
|
首屏应能看见主要关系、关键操作及当前结果。用户问“为什么变化不同”,优先用能对照变化的图形;发光、粒子或装饰不能代替趋势或关系证据。主图紧邻控件,推导、完整表格和次要说明随后呈现;同一数值不在指标、图注、卡片和正文反复展示。不要把所有可用组件都用一遍,也不为减少滚动而缩小字。比较不同单位的量,分别标轴或明确使用相对同一基准的无量纲倍数,不能把原始数值放在同一未说明尺度上暗示快慢。这些是信息优先级要求,具体图形、构图与风格仍按问题自行设计。
|
|
13
13
|
不把“最小”理解成粗糙或缺功能。交付所有必要内容后简短说明如何操作和假设;针对实际问题再局部修改。主动增强最多一次且确有价值,这是完成用户要求后的额外润色,不限制同一回复的 UI 数量或必要工具次数;用户要求几块不同内容就分别完成,不能第一块成功后提前结束。自动纠错仍最多两轮。无法交付时提供有效解释并如实说明,不声称已展示。
|
package/lib/ui-skill.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {MOTION_GUIDE,MOTION_INTERFACE} from './motion-library.js';
|
|
1
2
|
import { readFileSync } from 'node:fs';
|
|
2
3
|
import { PROTOCOL_GUIDE } from './catalog.js';
|
|
3
4
|
import { CANVAS_DESIGN_GUIDE } from './canvas-design.js';
|
|
@@ -40,14 +41,14 @@ export const SKILL_EXAMPLES = [
|
|
|
40
41
|
|
|
41
42
|
const skill = readFileSync(new URL('../skills/intelligent-ui/SKILL.md', import.meta.url), 'utf8');
|
|
42
43
|
export const UI_SKILL_SECTIONS = Object.freeze([
|
|
43
|
-
{ name: 'generative-ui:design-skill', order: 850, interpolate: false, text: TEXT_GUIDE+'\n\n'+UI_INTENT_POLICY + '\n\n' + skill + '\n\nCanvas composition details:\n' + CANVAS_DESIGN_GUIDE + '\n\nConstruction handbook:\n' + CANVAS_SYSTEM_GUIDE },
|
|
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 },
|
|
44
45
|
{ name: 'generative-ui:protocol', order: 851, interpolate: false, text: PROTOCOL_GUIDE },
|
|
45
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') }
|
|
46
47
|
]);
|
|
47
48
|
export function promptSections(mode='guided',style=DEFAULT_VISUAL_STYLE){
|
|
48
49
|
if(!['guided','free'].includes(mode))throw new Error('DSH UI: designMode must be guided or free');
|
|
49
50
|
visualStyle(style);
|
|
50
|
-
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'+UI_INTENT_POLICY+'\n\n'+FREE_UI_CONTRACT:''}));
|
|
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:''}));
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
|
package/lib/visual-styles.js
CHANGED
|
@@ -1,30 +1,142 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
const canvas=(title,html,css)=>({tool:'render_canvas',args:{title,fallback:title+',静态排版示例。',html,css}});
|
|
1
|
+
import {STYLE_SYSTEM,grammarPrompt,grammarExample} from './style-system.js';
|
|
2
|
+
// Stable user-facing IDs and palettes. Grammar and component tokens live together
|
|
3
|
+
// in style-system.js; the second example remains a small authored HTML/SVG surface.
|
|
5
4
|
export const DEFAULT_VISUAL_STYLE='prismframe';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
const PALETTES=[
|
|
6
|
+
{
|
|
7
|
+
"id": "editorial",
|
|
8
|
+
"name": "清爽阅读",
|
|
9
|
+
"preview": {
|
|
10
|
+
"bg": "#fff",
|
|
11
|
+
"ink": "#182537",
|
|
12
|
+
"accent": "#3e60d3",
|
|
13
|
+
"soft": "#f4f6fa",
|
|
14
|
+
"line": "#dfe5ed"
|
|
15
|
+
},
|
|
16
|
+
"canvasExample": {
|
|
17
|
+
"tool": "render_canvas",
|
|
18
|
+
"args": {
|
|
19
|
+
"title": "三步发布",
|
|
20
|
+
"fallback": "三步发布,静态排版示例。",
|
|
21
|
+
"html": "<section><h2>把一件事讲清楚</h2><div class=\"steps\"><p><b>01 整理</b><span>补齐说明与许可</span></p><p><b>02 验证</b><span>检查安装与运行</span></p><p><b>03 发布</b><span>记录本次变化</span></p></div></section>",
|
|
22
|
+
"css": "section{padding:20px;border:1px solid var(--canvas-line);border-radius:16px}h2{font-size:24px;margin:0 0 20px}.steps{display:grid;grid-template-columns:repeat(3,1fr);gap:20px}p{margin:0}b,span{display:block}span{color:var(--canvas-muted);margin-top:8px}@media(max-width:520px){.steps{grid-template-columns:1fr}}"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "soft",
|
|
28
|
+
"name": "柔和彩色",
|
|
29
|
+
"preview": {
|
|
30
|
+
"bg": "#fbf8ff",
|
|
31
|
+
"ink": "#32294c",
|
|
32
|
+
"accent": "#7954bb",
|
|
33
|
+
"soft": "#eee5fa",
|
|
34
|
+
"line": "#e6dcf2"
|
|
35
|
+
},
|
|
36
|
+
"canvasExample": {
|
|
37
|
+
"tool": "render_canvas",
|
|
38
|
+
"args": {
|
|
39
|
+
"title": "本周阅读计划",
|
|
40
|
+
"fallback": "本周阅读计划,静态排版示例。",
|
|
41
|
+
"html": "<section><span class=\"tag\">轻松开始</span><h2>每天一点,稳稳前进</h2><div class=\"plan\"><p><b>20 分钟</b><span>专注阅读</span></p><p><b>1 个收获</b><span>写下自己的理解</span></p></div></section>",
|
|
42
|
+
"css": "section{padding:24px;border-radius:24px;border:1px solid var(--canvas-line);background:linear-gradient(130deg,color-mix(in srgb,#9567d4 12%,var(--canvas-bg)),color-mix(in srgb,#58b7ae 9%,var(--canvas-bg)));color:var(--canvas-ink)}.tag{display:inline-block;border-radius:999px;padding:5px 12px;background:var(--canvas-bg);color:var(--canvas-accent)}h2{font-size:26px;margin:14px 0 20px}.plan{display:flex;flex-wrap:wrap;gap:24px}.plan p{margin:0;flex:1 1 180px;padding:18px;border-radius:18px;background:color-mix(in srgb,var(--canvas-bg) 80%,transparent)}b,span{display:block}b{font-size:22px}.plan span{margin-top:8px;color:var(--canvas-muted)}"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "technical",
|
|
48
|
+
"name": "技术图解",
|
|
49
|
+
"preview": {
|
|
50
|
+
"bg": "#f8fafb",
|
|
51
|
+
"ink": "#1b3440",
|
|
52
|
+
"accent": "#087e8b",
|
|
53
|
+
"soft": "#e7f1f3",
|
|
54
|
+
"line": "#cedde2"
|
|
55
|
+
},
|
|
56
|
+
"canvasExample": {
|
|
57
|
+
"tool": "render_canvas",
|
|
58
|
+
"args": {
|
|
59
|
+
"title": "请求处理流程",
|
|
60
|
+
"fallback": "请求处理流程,静态排版示例。",
|
|
61
|
+
"html": "<section><header><small>REQUEST FLOW</small><h2>输入 → 处理 → 输出</h2></header><div class=\"flow\"><div><i>01</i><b>输入</b><p>接收需求</p></div><span>→</span><div><i>02</i><b>处理</b><p>校验与计算</p></div><span>→</span><div><i>03</i><b>输出</b><p>返回反馈</p></div></div></section>",
|
|
62
|
+
"css": "section{padding:20px;border:1px solid var(--canvas-line);border-radius:10px}small,i{font:14px ui-monospace,monospace;color:var(--canvas-accent)}h2{font-size:24px;margin:8px 0 20px}.flow{display:flex;gap:12px;align-items:center}.flow div{flex:1;padding:16px;border:1px solid var(--canvas-line);border-radius:10px}.flow b,.flow i{display:block}.flow b{margin-top:10px;font-size:19px}p{margin:6px 0 0;color:var(--canvas-muted)}@media(max-width:520px){.flow{flex-direction:column}.flow div{width:100%}.flow>span{transform:rotate(90deg)}}"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"id": "expressive",
|
|
68
|
+
"name": "活力展示",
|
|
69
|
+
"preview": {
|
|
70
|
+
"bg": "#fff9f2",
|
|
71
|
+
"ink": "#362820",
|
|
72
|
+
"accent": "#bd4b26",
|
|
73
|
+
"soft": "#ffead8",
|
|
74
|
+
"line": "#edd7c5"
|
|
75
|
+
},
|
|
76
|
+
"canvasExample": {
|
|
77
|
+
"tool": "render_canvas",
|
|
78
|
+
"args": {
|
|
79
|
+
"title": "从第一步开始",
|
|
80
|
+
"fallback": "从第一步开始,静态排版示例。",
|
|
81
|
+
"html": "<section><div class=\"number\">01</div><div class=\"copy\"><span>今天的重点</span><h2>先做出一个<br>能演示的版本</h2><p>只保留一条主线,尽早获得反馈。</p></div></section>",
|
|
82
|
+
"css": "section{display:flex;align-items:center;gap:24px;padding:24px;border:1px solid var(--canvas-line);border-radius:22px;background:color-mix(in srgb,#f0984a 8%,var(--canvas-bg));color:var(--canvas-ink)}.number{font:800 54px/1 system-ui;padding:22px;border-radius:20px;color:var(--canvas-ink);background:color-mix(in srgb,#f0984a 28%,var(--canvas-bg))}.copy>span{font-size:14px;color:var(--canvas-muted)}h2{font-size:28px;line-height:1.3;margin:10px 0}p{margin:0;color:var(--canvas-muted)}@media(max-width:520px){section{align-items:flex-start;flex-direction:column}.number{font-size:36px;padding:16px}}"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "prismframe",
|
|
88
|
+
"name": "明亮扁平",
|
|
89
|
+
"preview": {
|
|
90
|
+
"bg": "#ecf6ff",
|
|
91
|
+
"ink": "#193858",
|
|
92
|
+
"accent": "#3182d9",
|
|
93
|
+
"soft": "#d3e8fc",
|
|
94
|
+
"line": "#9ec9ef"
|
|
95
|
+
},
|
|
96
|
+
"canvasExample": {
|
|
97
|
+
"tool": "render_canvas",
|
|
98
|
+
"args": {
|
|
99
|
+
"title": "三步让解释更清楚",
|
|
100
|
+
"fallback": "三步让解释更清楚,静态排版示例。",
|
|
101
|
+
"html": "<section><h2>把复杂问题讲清楚</h2><div class=\"cards\"><article><span>01</span><h3>明确目标</h3><p>先回答要解决什么。</p></article><article><span>02</span><h3>解释关系</h3><p>让图形承担说明。</p></article><article><span>03</span><h3>给出行动</h3><p>收成一个可执行步骤。</p></article></div></section>",
|
|
102
|
+
"css": "section{padding:24px 24px 30px;border-radius:26px;background:color-mix(in srgb,#3182d9 9%,var(--canvas-bg));color:var(--canvas-ink);font-family:ui-rounded,system-ui,sans-serif}h2{font-size:26px;line-height:1.35;margin:0 0 20px}.cards{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px}article{padding:20px;border:1.5px solid color-mix(in srgb,#3182d9 45%,var(--canvas-line));border-radius:22px;background:var(--canvas-bg);box-shadow:4px 6px 0 color-mix(in srgb,#3182d9 18%,var(--canvas-bg)),0 8px 16px #1637590b}article>span{color:var(--canvas-accent);font-size:14px;font-weight:700}h3{font-size:20px;margin:12px 0 8px}p{margin:0;line-height:1.6;color:var(--canvas-muted)}@media(max-width:580px){.cards{grid-template-columns:1fr}}"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"id": "aurora",
|
|
108
|
+
"name": "柔光渐彩",
|
|
109
|
+
"preview": {
|
|
110
|
+
"bg": "#f4f2ee",
|
|
111
|
+
"ink": "#16151b",
|
|
112
|
+
"accent": "#6a57f2",
|
|
113
|
+
"soft": "#f5f3ef",
|
|
114
|
+
"line": "#e2dfda"
|
|
115
|
+
},
|
|
116
|
+
"canvasExample": {
|
|
117
|
+
"tool": "render_canvas",
|
|
118
|
+
"args": {
|
|
119
|
+
"title": "选择一个方案",
|
|
120
|
+
"fallback": "点击选择此方案,本地记录选择状态。",
|
|
121
|
+
"state": {
|
|
122
|
+
"selected": {
|
|
123
|
+
"type": "boolean",
|
|
124
|
+
"default": false
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"html": "<section class=\"choice\"><h2>先选择,再继续</h2><p>渐变扩散和文字换位由实际操作触发。</p><button class=\"action\" type=\"button\" aria-pressed=\"false\"><i aria-hidden=\"true\"></i><span class=\"label\"><b>选择此方案</b><b aria-hidden=\"true\">选择此方案</b></span><span class=\"orb\" aria-hidden=\"true\">→</span></button><p class=\"status\" role=\"status\">尚未选择</p></section>",
|
|
128
|
+
"css": ".choice{padding:24px;border:1px solid var(--canvas-line);border-radius:26px;background:var(--canvas-bg);color:var(--canvas-ink)}h2{font-size:24px;margin:0 0 10px}p{color:var(--canvas-muted);line-height:1.7}.action{position:relative;isolation:isolate;overflow:hidden;display:inline-flex;align-items:center;gap:18px;min-height:54px;padding:8px 8px 8px 24px;border:0;border-radius:999px;background:var(--canvas-ink);color:var(--canvas-bg);translate:var(--x,0px) var(--y,0px);box-shadow:0 16px 28px -22px #54457988;transition:translate .7s cubic-bezier(.34,1.45,.64,1)}.action>i{position:absolute;inset:0;z-index:-1;background:linear-gradient(115deg,#7051ed,#326fce 55%,#188e97);clip-path:circle(21px at calc(100% - 29px) 50%);transition:clip-path .7s cubic-bezier(.2,.8,.2,1)}.action:is(:hover,:focus-visible){color:white}.action:is(:hover,:focus-visible)>i{clip-path:circle(160% at calc(100% - 29px) 50%)}.label{position:relative;overflow:hidden;line-height:1.5}.label b{display:block;transition:transform .55s cubic-bezier(.34,1.45,.64,1),opacity .3s}.label b+b{position:absolute;left:0;top:0;transform:translateY(130%);opacity:0}.action:is(:hover,:focus-visible) b:first-child{transform:translateY(-130%);opacity:0}.action:is(:hover,:focus-visible) b+b{transform:none;opacity:1}.orb{display:grid;place-items:center;width:42px;height:42px;border-radius:50%;background:linear-gradient(135deg,#438eff,#27b6ba);color:white;font-size:22px}.status{margin-bottom:0}@media(prefers-reduced-motion:reduce){.action,.action *{transition:none!important;translate:none!important}}",
|
|
129
|
+
"script": "const root=document.querySelector(\".choice\"),button=root.querySelector(\"button\");button.addEventListener(\"click\",()=>DSHUI.setState({selected:!DSHUI.snapshot.state.selected}));DSHUI.subscribe(({state})=>{button.setAttribute(\"aria-pressed\",String(state.selected));root.querySelectorAll(\"b\").forEach(b=>b.textContent=state.selected?\"取消选择\":\"选择此方案\");root.querySelector(\".status\").textContent=state.selected?\"已选择此方案\":\"尚未选择\"});button.addEventListener(\"pointermove\",e=>{if(matchMedia(\"(prefers-reduced-motion: reduce)\").matches)return;const r=button.getBoundingClientRect();button.style.setProperty(\"--x\",((e.clientX-r.left-r.width/2)*.035)+\"px\");button.style.setProperty(\"--y\",((e.clientY-r.top-r.height/2)*.07)+\"px\")});button.addEventListener(\"pointerleave\",()=>{button.style.setProperty(\"--x\",\"0px\");button.style.setProperty(\"--y\",\"0px\")});"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
export const VISUAL_STYLES=Object.freeze(PALETTES.map(({canvasExample,...s})=>Object.freeze({...s,description:STYLE_SYSTEM[s.id].description,prompt:grammarPrompt(s.id),examples:[grammarExample(s.id),canvasExample]})));
|
|
23
135
|
export const VISUAL_STYLE_IDS=Object.freeze(VISUAL_STYLES.map(s=>s.id));
|
|
24
136
|
export function visualStyle(id=DEFAULT_VISUAL_STYLE){
|
|
25
137
|
const style=VISUAL_STYLES.find(s=>s.id===id);
|
|
26
138
|
if(!style)throw Error('DSH UI: unknown visualStyle; use '+VISUAL_STYLE_IDS.join('/'));
|
|
27
139
|
return style;
|
|
28
140
|
}
|
|
29
|
-
export function stylePrompt(id){const s=visualStyle(id);return `## 用户选择的视觉风格:${s.name} (${s.id})\n${s.prompt}\n这套风格替代通用指导和旧案例中的默认配色、材质与圆角建议。只影响新生成内容的视觉方向;协议、工具入口、状态、权限、准确性、可读性与必要功能要求保持不变。引导模式下原生文本、卡片、指标、控件和代码块会自动跟随当前所选视觉风格;整份 UI 的原生内容和 HTML/SVG
|
|
141
|
+
export function stylePrompt(id){const s=visualStyle(id);return `## 用户选择的视觉风格:${s.name} (${s.id})\n采用${s.name}风格。\n${s.prompt}\n这套风格替代通用指导和旧案例中的默认配色、材质与圆角建议。只影响新生成内容的视觉方向;协议、工具入口、状态、权限、准确性、可读性与必要功能要求保持不变。引导模式下原生文本、卡片、指标、控件和代码块会自动跟随当前所选视觉风格;整份 UI 的原生内容和 HTML/SVG 应使用一致的色彩与层级。原生组件会改变表面、层级、控件与流程形态。通常省略 size/weight/color 和 presentation.accent,让所选风格管理默认层级;只有用户明确指定或确有语义强调才覆盖。不要每种风格都手写同一套字号。title 已显示文档标题,正文不再重复相同标题;模型负责根据上述构图原则组织内容,不要所有风格都生成等大卡片网格。少量语义色强调真实重点。不要为了给原生内容上色而额外生成 HTML。确实需要特殊图解时再使用小画布。用户在当前请求中明确指定的风格优先。不要为展示风格增加不必要的画布、代码、动画或工具调用。`}
|
|
30
142
|
export function styleExamples(id){return visualStyle(id).examples.map(example=>JSON.stringify(example)).join('\n')}
|
package/package.json
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dsh-motion-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Interactive UI, HTML/SVG animation and local calculations for DeepSeek Harness Web, with injected design guidance.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": "./index.js",
|
|
9
|
-
"./client": "./client.js",
|
|
10
|
-
"./package.json": "./package.json"
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
"index.js",
|
|
14
|
-
"client.js",
|
|
15
|
-
"lib",
|
|
16
|
-
"skills",
|
|
17
|
-
"examples",
|
|
18
|
-
"cordis.patch.yml",
|
|
19
|
-
"README.md",
|
|
20
|
-
"CHANGELOG.md",
|
|
21
|
-
"LICENSE",
|
|
22
|
-
"DESIGN.zh-CN.md",
|
|
23
|
-
"RELEASE-PLAN.zh-CN.md",
|
|
24
|
-
"VERIFICATION.md"
|
|
25
|
-
],
|
|
26
|
-
"scripts": {
|
|
27
|
-
"build": "node scripts/build.mjs",
|
|
28
|
-
"test": "node --test tests/*.test.mjs",
|
|
29
|
-
"verify:release": "node scripts/verify-release.mjs",
|
|
30
|
-
"check": "node --check index.js && node --check client.js"
|
|
31
|
-
},
|
|
32
|
-
"dsh": {
|
|
33
|
-
"bundle": {
|
|
34
|
-
"patch": "./cordis.patch.yml"
|
|
35
|
-
},
|
|
36
|
-
"client": {
|
|
37
|
-
"platform": "web"
|
|
38
|
-
},
|
|
39
|
-
"compatibility": {
|
|
40
|
-
"dsh": "0.2.0-rc.2",
|
|
41
|
-
"node": ">=22.19",
|
|
42
|
-
"profiles": [
|
|
43
|
-
"web"
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"peerDependencies": {
|
|
48
|
-
"@deepseek-ai/dsh-home-paths": "0.2.0-rc.2",
|
|
49
|
-
"@deepseek-ai/dsh-tools": "0.2.0-rc.2",
|
|
50
|
-
"react": "^18.2.0 || ^19.0.0",
|
|
51
|
-
"react-dom": "^18.2.0 || ^19.0.0"
|
|
52
|
-
},
|
|
53
|
-
"devDependencies": {
|
|
54
|
-
"echarts": "^6.1.0",
|
|
55
|
-
"echarts-wordcloud": "^2.1.0",
|
|
56
|
-
"esbuild": "^0.25.0",
|
|
57
|
-
"katex": "^0.19.0",
|
|
58
|
-
"mdast-util-from-markdown": "^2.0.3",
|
|
59
|
-
"mermaid": "^11.16.1",
|
|
60
|
-
"react": "^18.3.1",
|
|
61
|
-
"react-dom": "^18.3.1",
|
|
62
|
-
"three": "^0.180.0"
|
|
63
|
-
},
|
|
64
|
-
"dependencies": {
|
|
65
|
-
"@deepseek-ai/schemastery": "^3.18.4"
|
|
66
|
-
},
|
|
67
|
-
"license": "MIT",
|
|
68
|
-
"repository": {
|
|
69
|
-
"type": "git",
|
|
70
|
-
"url": "git+https://github.com/Scorp1o117/dsh-motion-ui.git"
|
|
71
|
-
},
|
|
72
|
-
"homepage": "https://github.com/Scorp1o117/dsh-motion-ui#readme",
|
|
73
|
-
"bugs": {
|
|
74
|
-
"url": "https://github.com/Scorp1o117/dsh-motion-ui/issues"
|
|
75
|
-
},
|
|
76
|
-
"author": "Scorp1o117",
|
|
77
|
-
"keywords": [
|
|
78
|
-
"dsh",
|
|
79
|
-
"deepseek-harness",
|
|
80
|
-
"generative-ui",
|
|
81
|
-
"interactive-ui",
|
|
82
|
-
"svg"
|
|
83
|
-
],
|
|
84
|
-
"overrides": {
|
|
85
|
-
"mermaid": {
|
|
86
|
-
"katex": "$katex"
|
|
87
|
-
},
|
|
88
|
-
"echarts-wordcloud": {
|
|
89
|
-
"echarts": "$echarts"
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-motion-ui",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Interactive UI, HTML/SVG animation and local calculations for DeepSeek Harness Web, with injected design guidance.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./client": "./client.js",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"index.js",
|
|
14
|
+
"client.js",
|
|
15
|
+
"lib",
|
|
16
|
+
"skills",
|
|
17
|
+
"examples",
|
|
18
|
+
"cordis.patch.yml",
|
|
19
|
+
"README.md",
|
|
20
|
+
"CHANGELOG.md",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"DESIGN.zh-CN.md",
|
|
23
|
+
"RELEASE-PLAN.zh-CN.md",
|
|
24
|
+
"VERIFICATION.md"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "node scripts/build.mjs",
|
|
28
|
+
"test": "node --test tests/*.test.mjs",
|
|
29
|
+
"verify:release": "node scripts/verify-release.mjs",
|
|
30
|
+
"check": "node --check index.js && node --check client.js"
|
|
31
|
+
},
|
|
32
|
+
"dsh": {
|
|
33
|
+
"bundle": {
|
|
34
|
+
"patch": "./cordis.patch.yml"
|
|
35
|
+
},
|
|
36
|
+
"client": {
|
|
37
|
+
"platform": "web"
|
|
38
|
+
},
|
|
39
|
+
"compatibility": {
|
|
40
|
+
"dsh": "0.2.0-rc.2",
|
|
41
|
+
"node": ">=22.19",
|
|
42
|
+
"profiles": [
|
|
43
|
+
"web"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@deepseek-ai/dsh-home-paths": "0.2.0-rc.2",
|
|
49
|
+
"@deepseek-ai/dsh-tools": "0.2.0-rc.2",
|
|
50
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
51
|
+
"react-dom": "^18.2.0 || ^19.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"echarts": "^6.1.0",
|
|
55
|
+
"echarts-wordcloud": "^2.1.0",
|
|
56
|
+
"esbuild": "^0.25.0",
|
|
57
|
+
"katex": "^0.19.0",
|
|
58
|
+
"mdast-util-from-markdown": "^2.0.3",
|
|
59
|
+
"mermaid": "^11.16.1",
|
|
60
|
+
"react": "^18.3.1",
|
|
61
|
+
"react-dom": "^18.3.1",
|
|
62
|
+
"three": "^0.180.0"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@deepseek-ai/schemastery": "^3.18.4"
|
|
66
|
+
},
|
|
67
|
+
"license": "MIT",
|
|
68
|
+
"repository": {
|
|
69
|
+
"type": "git",
|
|
70
|
+
"url": "git+https://github.com/Scorp1o117/dsh-motion-ui.git"
|
|
71
|
+
},
|
|
72
|
+
"homepage": "https://github.com/Scorp1o117/dsh-motion-ui#readme",
|
|
73
|
+
"bugs": {
|
|
74
|
+
"url": "https://github.com/Scorp1o117/dsh-motion-ui/issues"
|
|
75
|
+
},
|
|
76
|
+
"author": "Scorp1o117",
|
|
77
|
+
"keywords": [
|
|
78
|
+
"dsh",
|
|
79
|
+
"deepseek-harness",
|
|
80
|
+
"generative-ui",
|
|
81
|
+
"interactive-ui",
|
|
82
|
+
"svg"
|
|
83
|
+
],
|
|
84
|
+
"overrides": {
|
|
85
|
+
"mermaid": {
|
|
86
|
+
"katex": "$katex"
|
|
87
|
+
},
|
|
88
|
+
"echarts-wordcloud": {
|
|
89
|
+
"echarts": "$echarts"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|