@szc-ft/mcp-szcd-client 0.23.0 → 0.24.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/agents/opencode-extension/agents/szcd-component-expert.md +97 -47
- package/agents/qwen-extension/agents/szcd-component-expert.md +97 -47
- package/agents/src/szcd-component-expert.md +110 -110
- package/agents/szcd-component-expert.md +97 -47
- package/agents/szcd-component-expert.qoder.md +106 -106
- package/agents/szcd-component-expert.trae.md +105 -105
- package/opencode-extension/agents/szcd-component-expert.md +97 -47
- package/opencode-extension/skills/szcd-component-helper/SKILL.md +15 -13
- package/opencode-extension/skills/szcd-design-to-code/SKILL.md +136 -25
- package/package.json +1 -1
- package/qwen-extension/agents/szcd-component-expert.md +97 -47
- package/qwen-extension/qwen-extension.json +1 -1
- package/qwen-extension/skills/szcd-component-helper/SKILL.md +15 -13
- package/qwen-extension/skills/szcd-design-to-code/SKILL.md +136 -25
- package/standard-skill/szcd-component-helper/SKILL.md +15 -13
- package/standard-skill/szcd-design-to-code/SKILL.md +136 -25
|
@@ -55,29 +55,140 @@ Ant Design → ProComponents → Cover 层 → Wrapper 层 → ProPackages →
|
|
|
55
55
|
|
|
56
56
|
### 步骤2.5:Sketch 文件解析(有 .sketch 文件时执行)
|
|
57
57
|
|
|
58
|
-
**核心原则**:写代码之前必须拿到所有 `text` 和 `rectangle` 节点的完整样式 Token
|
|
58
|
+
**核心原则**:写代码之前必须拿到所有 `text` 和 `rectangle` 节点的完整样式 Token,禁止凭节点名猜测颜色/字号/背景色。`getMultipleNodeInfo` 支持任意数量 ID(内部自动分片),比逐个 `getNodeInfo` 快 10 倍以上。
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
**工具调用顺序(优化后,4 次主调用)**:
|
|
61
61
|
|
|
62
|
-
1. `mcp__sketch-mcp-server__loadSketchByPath` —
|
|
62
|
+
1. `mcp__sketch-mcp-server__loadSketchByPath` — 加载文件(内部自动解压并保存目录,供后续 extractBitmaps 使用)
|
|
63
63
|
2. `mcp__sketch-mcp-server__listPages` — 获取页面列表
|
|
64
|
-
3. `mcp__sketch-mcp-
|
|
65
|
-
4. `mcp__sketch-mcp-server__getPageStructure`(pageId
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
- `
|
|
69
|
-
|
|
70
|
-
6. `mcp__sketch-mcp-server__getMultipleNodeInfo`([id1, id2, ...])— **批量查询所有 type=text 和 type=rectangle 节点**,每次 ≤ 100 个
|
|
64
|
+
3. `mcp__sketch-mcp-server__queryNodes`(pageId, type="artboard")— 获取画板列表,确定目标画板
|
|
65
|
+
4. `mcp__sketch-mcp-server__getPageStructure`(pageId, mode="ids")**替代旧的 getPageStructure + getNodesSummary 组合**
|
|
66
|
+
- 一次返回按类型分组的全量 ID:`{ text: [...], rectangle: [...], bitmap: [...], shapePath: [...] }`
|
|
67
|
+
- 可选 `typeFilter` 参数限制返回类型
|
|
68
|
+
- 同时返回 `summary`(各类型统计)和 `totalIds`(总数)
|
|
69
|
+
5. `mcp__sketch-mcp-server__getMultipleNodeInfo`([所有 text + rectangle ID])— **支持任意数量 ID,内部自动分批处理**
|
|
71
70
|
- 关键字段:`style.fills[0].color.hex`(背景色)、`text.color`(文字色)、`style.fontSize`、`style.fontWeight`
|
|
72
|
-
-
|
|
71
|
+
- 无需手动分批,传入全部 ID 即可(内部按 100 个一批自动处理)
|
|
72
|
+
|
|
73
|
+
**与旧策略的差异**:
|
|
74
|
+
- 旧策略:`getPageStructure`(可能截断) + `getNodesSummary` + 手动分批 `getMultipleNodeInfo`
|
|
75
|
+
- 新策略:`getPageStructure(mode="ids")`(轻量全量 ID) + `getMultipleNodeInfo`(自动分片)
|
|
76
|
+
- 调用次数:旧 6 次 → 新 4 次(含 loadSketch + listPages 合并)
|
|
77
|
+
|
|
78
|
+
**步骤 2.5 产出物**(**只产出数据,不做组件映射**):
|
|
79
|
+
- 按类型分组的全量节点 ID 列表
|
|
80
|
+
- text/rectangle 节点的完整样式 Token
|
|
81
|
+
- bitmap ID 列表(传给步骤 2.5.1)
|
|
82
|
+
- shapePath 节点名列表(传给步骤 2.5.1)
|
|
83
|
+
|
|
84
|
+
组件候选列表推理**不**在步骤 2.5 内部完成,**统一在主流程中结合步骤 1 的 `templatePatterns` 推理**(详见主流程步骤 4 前置说明)。
|
|
85
|
+
|
|
86
|
+
### 步骤2.5.1:图标与位图提取(有 bitmap/shapePath 节点时执行)
|
|
87
|
+
|
|
88
|
+
**输入**:步骤 2.5 产出的 bitmap ID 列表 + shapePath 节点名列表
|
|
89
|
+
|
|
90
|
+
**工具调用**:
|
|
91
|
+
|
|
92
|
+
1. `mcp__sketch-mcp-server__extractBitmaps`(bitmapIds)— 从 .sketch 解压目录提取 bitmap PNG 资源
|
|
93
|
+
- 返回 `{ bitmaps: [{ nodeId, name, base64, mimeType, size, fileName }] }`
|
|
94
|
+
- 位图资源用于 CSS `background-image` 引用
|
|
95
|
+
2. `mcp__sketch-mcp-server__matchIconFromName`(nodeNames, library="newFont")— 匹配 iconfont 图标库
|
|
96
|
+
- 输入 shapePath 节点名列表(如 `["表 icon", "文件 icon"]`)
|
|
97
|
+
- 匹配策略:节点名关键词 → 拼音匹配图标列表
|
|
98
|
+
- 返回格式:
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"matchedIcons": [
|
|
102
|
+
{ "nodeName": "表 icon", "iconType": "icon-biao", "library": "newFont" }
|
|
103
|
+
],
|
|
104
|
+
"unmatched": ["菜单icon"],
|
|
105
|
+
"recommendFallback": { "菜单icon": "antd MenuOutlined" },
|
|
106
|
+
"matchRate": "80.0%"
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**步骤 2.5.1 产出物**:
|
|
111
|
+
- bitmap base64 资源列表 → 用于代码中的 CSS background-image
|
|
112
|
+
- IconfontWapper 代码片段(`<IconfontWapper assets="newFont" type="icon-biao" />`)
|
|
113
|
+
- 未匹配节点的 fallback 建议(antd 图标替代)
|
|
114
|
+
|
|
115
|
+
### 步骤2.5.2:批量样式提取(合并入步骤 2.5)
|
|
116
|
+
|
|
117
|
+
此步骤已合并入步骤 2.5 第 5 步,`getMultipleNodeInfo` 现在支持自动分片,无需手动分批调用。
|
|
118
|
+
|
|
119
|
+
### 步骤2.5 实战经验沉淀(重要)
|
|
120
|
+
|
|
121
|
+
**经验1:用 `getPageStructure(mode="ids")` 一步拿全量 ID,避免 getPageStructure 截断**
|
|
122
|
+
- 错误做法:用 `getPageStructure(pageId)` 拿节点树 → 大文件截断 → 需要 agent 解析
|
|
123
|
+
- 正确做法:`getPageStructure(pageId, mode="ids")` 轻量返回 `{ text: [ids], rectangle: [ids], bitmap: [ids] }` → 无截断风险
|
|
124
|
+
- 如需节点层级关系,用 `getPageStructure(pageId, fields=["id","name","type"])` 过滤字段
|
|
125
|
+
|
|
126
|
+
**经验2:`getMultipleNodeInfo` 支持任意数量,无需手动分批**
|
|
127
|
+
- 旧做法:手动把 ID 分成每批 ≤ 100 个 → 多次调用
|
|
128
|
+
- 新做法:直接传入全部 ID(如 200 个)→ 内部自动按 100 个一批处理 → 返回合并结果
|
|
129
|
+
- 返回结构不变:`{ nodes: [...], total, requested, batches }`
|
|
130
|
+
|
|
131
|
+
**经验3:text 节点是颜色/DOM 映射的两级索引**
|
|
132
|
+
每个 text 节点同时关联两种上下文,**必须同批拉取**:
|
|
133
|
+
- 自身样式:`fontSize`、`fontWeight`、`text.color`
|
|
134
|
+
- 所属 group 父级 rectangle 样式:`bg`、`border`、`radius`、`shadow`
|
|
135
|
+
|
|
136
|
+
错误做法:先查 text 拿自身样式 → 再根据 parent ID 单独查 rectangle(多走一步)
|
|
137
|
+
正确做法:构造查询列表时,**把同一 group 内的 text + rectangle 节点 ID 合并提交**
|
|
138
|
+
|
|
139
|
+
**经验4:图表区样式提取有规律可循**
|
|
140
|
+
|
|
141
|
+
| 图表子元素 | 对应 Sketch 节点类型 | 关键样式字段 |
|
|
142
|
+
|---|---|---|
|
|
143
|
+
| 图表标题 | `text`(带蓝色矩形左饰线) | 14px Semibold;矩形 4×14 #0079f7 |
|
|
144
|
+
| 图例文字 | `text` | 14px |
|
|
145
|
+
| 图例色块 | `rectangle` | 8×8 / 10×3 |
|
|
146
|
+
| 坐标轴文字 | `text`(成组) | 12px #7b828d |
|
|
147
|
+
| 柱体颜色 | 区域 `rectangle` | `style.fills[0].hex` |
|
|
148
|
+
| 数据标签 | `text`(白字) | 12px #ffffff |
|
|
149
|
+
|
|
150
|
+
**图表区结构规律**:`标题 text + 标题装饰 rectangle + 图例 text*N + 色块 rectangle*N + 坐标轴 text*N + 柱体 rectangle*N + 标签 text*N`
|
|
151
|
+
|
|
152
|
+
识别出图表后,**图例色块**应归入 ECharts `legend` 配置(不要用 div 硬编码),**柱体色**映射到 `series.itemStyle.color`。
|
|
153
|
+
|
|
154
|
+
**经验5:矢量图形用 matchIconFromName 自动匹配,无需手动解压**
|
|
155
|
+
- `shapePath` / `shapeGroup` 在 sketch 节点中占比可能高达 46.8%,但 `renderNodeAsBase64` 不支持渲染
|
|
156
|
+
- **新方案**:`matchIconFromName(shapePathNames)` 自动查询 iconfont 库 → 返回匹配结果
|
|
157
|
+
- bitmap 用 `extractBitmaps(bitmapIds)` 自动提取 PNG 资源
|
|
158
|
+
- 兜底:未匹配的节点用 antd `@ant-design/icons` 同语义图标替代,在代码注释中标注“⚠️ 矢量图标用 antd 图标替代,原始 Sketch 为 shapePath”
|
|
73
159
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
160
|
+
### 步骤3:分析设计稿图片(有图片时执行)
|
|
161
|
+
|
|
162
|
+
- 主智能体已提供图片描述时,直接使用,跳过此步
|
|
163
|
+
- 否则调用 `mcp__szcd-component-helper__analyze_design_image` 分析
|
|
164
|
+
- 获得描述后,结合步骤1的 `templatePatterns` 推理组件候选列表
|
|
165
|
+
- 立即调用 `mcp__szcd-component-helper__get_component_full_profile`(批量,depth="gencode")
|
|
166
|
+
|
|
167
|
+
### 步骤3.5:组件候选列表推理(统一环节,结合步骤1 + 步骤2.5/3)
|
|
168
|
+
|
|
169
|
+
**这是统一推理环节**,无论设计稿来源是 .sketch 文件(步骤 2.5)还是图片(步骤 3),都需经过此环节:
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
步骤 1 templatePatterns + 步骤 2.5/3 设计稿数据 → 组件候选列表
|
|
173
|
+
(4 种模板模式 + llmMappingHints) (结构 + 样式 Token) (如 ["Query","TableOrList","LeftTree","TemplateMode"])
|
|
174
|
+
```
|
|
79
175
|
|
|
80
|
-
|
|
176
|
+
**输入**:
|
|
177
|
+
- 步骤 1 的 `templatePatterns`(TreeQueryTable / QueryTabsTables / LeftRight / UpDown)
|
|
178
|
+
- 步骤 1 的 `llmMappingHints.commonMistakes`(避免 LLM 常见映射错误)
|
|
179
|
+
- 步骤 2.5 的 Sketch 节点结构 + 样式 Token
|
|
180
|
+
- 或步骤 3 的图片分析描述
|
|
181
|
+
|
|
182
|
+
**输出**:
|
|
183
|
+
- **组件候选列表**(如 `["Query","TableOrList","LeftTree","TemplateMode"]`)
|
|
184
|
+
- 模板类型选择(如 `TemplateMode(templateType="LeftRight")`)
|
|
185
|
+
|
|
186
|
+
**禁止**:
|
|
187
|
+
- ❌ 在步骤 2.5 内部推理组件候选列表(应只产出 Sketch 数据 + 样式 Token)
|
|
188
|
+
- ❌ 在步骤 3 内部推理组件候选列表(应只产出图片描述)
|
|
189
|
+
- ❌ 跳过此环节直接调 `get_component_full_profile`(必须先有候选列表)
|
|
190
|
+
|
|
191
|
+
**推理时使用映射规则**(**此表为本步骤专用,核心高频场景**):
|
|
81
192
|
|
|
82
193
|
| Sketch 特征 | 推断组件 |
|
|
83
194
|
|---|---|
|
|
@@ -89,23 +200,23 @@ Ant Design → ProComponents → Cover 层 → Wrapper 层 → ProPackages →
|
|
|
89
200
|
| 弹窗/抽屉图层 | `ModelOrDrawer` |
|
|
90
201
|
| 页面标题 + 返回箭头 | `TitleAndBack` |
|
|
91
202
|
| 详情展示区域(只读字段) | `FormItemOrDetailItem(type="detail")` |
|
|
92
|
-
|
|
|
203
|
+
| 卡片列表 | `TableOrList(componentType="ProList")` |
|
|
93
204
|
| 可编辑表格 | `TableOrList(componentType="EditableProTable")` |
|
|
94
205
|
| 折线趋势图 | `Line` |
|
|
95
206
|
| 柱状对比图 | `Bar` |
|
|
96
207
|
| 饼图/环形图 | `Pie` |
|
|
97
208
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
209
|
+
**长尾场景走语义搜索**(不进文档,避免膨胀):
|
|
210
|
+
- 数据可视化长尾:`Radar` / `Gauge` / `Funnel`(用 `Line/Bar/Pie` 之外的图表)
|
|
211
|
+
- 表格子类型长尾:`DragSortTable`(拖拽排序)、`steps` 步骤条表单
|
|
212
|
+
- 辅助/插槽组件:`CustomOption`(LeftTree 添加按钮)、`TreeNode`(树节点右键菜单)、`ModeAvatar`(头像)、`Upload`(文件上传)
|
|
101
213
|
|
|
102
|
-
|
|
103
|
-
- 否则调用 `mcp__szcd-component-helper__analyze_design_image` 分析
|
|
104
|
-
- 获得描述后,结合步骤1的 `templatePatterns` 推理组件候选列表
|
|
105
|
-
- 立即调用 `mcp__szcd-component-helper__get_component_full_profile`(批量,depth="gencode")
|
|
214
|
+
**处理方式**:本表未覆盖的视觉特征 → 调用 `{{TOOL:search_components_semantic}}`(query="[场景描述,如'拖拽排序表格']")按需补全,再进入步骤 4。
|
|
106
215
|
|
|
107
216
|
### 步骤4:批量获取组件 API(必做)
|
|
108
217
|
|
|
218
|
+
**前置条件**:已通过步骤 3.5 获得组件候选列表。
|
|
219
|
+
|
|
109
220
|
调用 `mcp__szcd-component-helper__get_component_full_profile`:
|
|
110
221
|
- `name` 用逗号分隔一次性查询所有候选组件,如 `"Query,TableOrList,LeftTree,TemplateMode"`
|
|
111
222
|
- `depth="gencode"`(比 deep 小 30-50%,生成代码场景首选)
|