dsh-motion-ui 0.5.4 → 0.5.6
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 +16 -0
- package/README.md +5 -1
- package/VERIFICATION.md +15 -0
- package/client.js +179 -246
- package/index.js +5 -6
- package/lib/authoring-guide.js +8 -1
- package/lib/build-info.js +1 -1
- package/lib/catalog.js +1 -1
- package/lib/export-runtime-bundle.js +1 -1
- package/lib/freeform.js +1 -1
- package/lib/normalize-authoring.js +68 -0
- package/lib/protocol.js +42 -24
- package/lib/stream.js +1 -1
- package/lib/tool-schema.js +13 -3
- package/package.json +1 -1
- package/skills/intelligent-ui/SKILL.md +4 -0
package/lib/stream.js
CHANGED
|
@@ -63,7 +63,7 @@ export function previewDocument(raw) {
|
|
|
63
63
|
try {
|
|
64
64
|
const root=parseToolArguments(raw);if(!root)return null;
|
|
65
65
|
const document = root.members?.get('document');
|
|
66
|
-
if(document?.complete&&
|
|
66
|
+
if(document?.complete&&root.members.size===1)return validateDocument(toolJson(document.value,'document'));
|
|
67
67
|
if (!document?.members) return null;
|
|
68
68
|
if ([...root.members.keys()].some(k => k !== 'document')) return null;
|
|
69
69
|
const doc = { ...document.value }, nodes = document.members.get('nodes');
|
package/lib/tool-schema.js
CHANGED
|
@@ -14,15 +14,25 @@ export const DOCUMENT_PARAMETER={
|
|
|
14
14
|
id:{type:'string',required:true,description:'Unique letter/underscore identifier; Chinese supported, max64.'},
|
|
15
15
|
type:{type:'string',required:true,enum:Object.keys(COMPONENTS)},
|
|
16
16
|
label:{type:'string'},title:{type:'string'},
|
|
17
|
+
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
|
+
title:{type:'string',required:true},description:{type:'string'},status:{type:'string',enum:['pending','active','done','error']}
|
|
19
|
+
}}},
|
|
20
|
+
open:{type:'boolean',description:'details only; defaults to closed.'},
|
|
21
|
+
icon:{type:'string'},tone:{type:'string'},surface:{type:'string'},
|
|
22
|
+
max:{type:'json',description:'progress only: positive numeric value or binding.'},unit:{type:'string'},decimals:{type:'number'},
|
|
23
|
+
action:{type:'string',description:'button only: a key declared in document.actions.'},
|
|
24
|
+
kind:{type:'string',enum:['bar','line']},labelKey:{type:'string'},valueKey:{type:'string'},xScale:{type:'string'},
|
|
25
|
+
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'}},
|
|
17
27
|
text:{type:'json',description:'Literal scalar or {ref}/{expr}.'},
|
|
18
28
|
value:{type:'json',description:'metric: number or display string/boolean, or {ref}/{expr}. progress: numeric.'},
|
|
19
29
|
rows:{type:'json',description:'table/chart: inline array of objects, {ref:"data.rows"}/{ref:"derived.rows"}, or scoped reference string.'},
|
|
20
30
|
columns:{type:'array',items:{type:'object',additionalProperties:false,properties:{key:{type:'string',required:true},label:{type:'string',required:true},unit:{type:'string'}}}},
|
|
21
|
-
bind:{type:'string',description:'Controls bind state.key.'},children:{type:'array',items:{type:'json'}}
|
|
31
|
+
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'}}
|
|
22
32
|
}}},
|
|
23
|
-
state:dictionary('key -> {type:number
|
|
33
|
+
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.'),
|
|
24
34
|
data:dictionary('Static data; Chinese identifier keys supported. Omit if rows are inline.'),
|
|
25
|
-
derived:dictionary('Local
|
|
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.'),
|
|
26
36
|
actions:dictionary('Declared agent.followup actions. Omit when unused.'),
|
|
27
37
|
presentation:dictionary('Optional layout/accent/density from registered tokens.')
|
|
28
38
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# DSH Motion UI — 设计与生成技能
|
|
2
2
|
|
|
3
|
+
生成 UI 时直接使用已注册的 render_ui/render_canvas;不需要先 grep、glob 或用 Shell 查找 DSH 安装源码。协议疑问以本说明和 ui_catalog 为准。这不限制为完成用户实际任务、读取真实数据而使用文件或搜索工具。
|
|
4
|
+
|
|
5
|
+
`round(x)` 只有一个参数,等同 JavaScript `Math.round`:取最近整数,恰好一半时朝正无穷方向取整,如 `round(2.5)=3`、`round(-2.5)=-2`。它不是向上取整;原生公式不支持 ceil/floor。需要向上/向下取整时,用订阅已声明共享状态的画布及 `Math.ceil/Math.floor` 实现。指标 decimals 只控制显示精度,不改变计算值。
|
|
6
|
+
|
|
3
7
|
简单公式优先使用 `{expr:"state.V * state.V / state.R"}`,例如 `derived.power` 的表达式,然后用 `{ref:"derived.power"}` 在指标中显示。支持四则运算、比较、三元条件、括号、`min/max/round/abs`;字符串使用双引号,引用写完整的 `state.x/data.x/derived.x/item.x`。这会编译为现有解释器协议,不执行任意 JavaScript。复杂动画仍使用画布。
|
|
4
8
|
|
|
5
9
|
这是插件主动注入的能力指导;无需用户重复提供,也不依赖你先调用目录才获得这些规则。它是基于公开项目设计思想编写的 DSH 技能,不是 OpenAI 的内部提示词。以下协议与宿主工具权限共同约束输出。
|