mta-mcp 3.10.0 → 3.11.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/flutter.agent.md +168 -9
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/standards/mcp-tools/sketch-mcp.md +229 -6
- package/standards/troubleshooting-cases/flutter/text-vertical-centering-strutstyle.md +161 -0
- package/standards/workflows/design-restoration-guide.md +4 -2
- package/standards/workflows/design-restoration.md +134 -1
- package/standards/workflows/sketch-pitfalls.md +310 -0
- package/templates/design-measurement/component-measurement.js +72 -19
- package/templates/design-measurement/gap-measurement.js +83 -48
- package/templates/design-measurement/style-extraction.js +13 -0
- package/troubleshooting/README.md +368 -0
- package/troubleshooting/USAGE_GUIDE.md +289 -0
- package/troubleshooting/flutter/clip-/351/230/264/345/275/261/350/243/201/345/211/252.md +244 -0
- package/troubleshooting/flutter/component-/351/200/232/347/224/250/345/214/226/346/217/220/345/217/226.md +269 -0
- package/troubleshooting/flutter/input-/345/255/227/346/256/265/347/274/272/345/244/261.md +240 -0
- package/troubleshooting/flutter/input-/350/276/271/346/241/206/351/227/256/351/242/230.md +236 -0
- package/troubleshooting/flutter/layout-/345/260/272/345/257/270/344/270/215/345/214/271/351/205/215.md +214 -0
- package/troubleshooting/flutter/shadow-/351/200/217/345/207/272/351/227/256/351/242/230.md +172 -0
- package/troubleshooting/flutter/sketch-overflow-container.md +200 -0
- package/troubleshooting/flutter/sketch-/345/210/227/350/241/250item/345/214/272/345/237/237.md +212 -0
- package/troubleshooting/flutter/sketch-/345/233/276/346/240/207/345/260/272/345/257/270.md +135 -0
- package/troubleshooting/flutter/sketch-/345/256/214/346/225/264/346/217/220/345/217/226.md +201 -0
- package/troubleshooting/flutter/sketch-/345/261/236/346/200/247/346/234/252/344/275/277/347/224/250.md +139 -0
- package/troubleshooting/flutter/sketch-/350/203/214/346/231/257/345/261/202/351/253/230/345/272/246.md +264 -0
- package/troubleshooting/flutter/svg-/345/220/253/350/203/214/346/231/257/350/267/257/345/276/204.md +172 -0
- package/troubleshooting/flutter/svg-/346/234/252/345/261/205/344/270/255.md +120 -0
- package/troubleshooting/flutter/svg-/351/242/234/350/211/262/345/274/202/345/270/270.md +117 -0
- package/troubleshooting/flutter/tabbar-/345/212/250/347/224/273/345/220/214/346/255/245.md +107 -0
- package/troubleshooting/flutter/withopacity-/345/274/203/347/224/250.md +81 -0
- package/troubleshooting/vue3/cascader-/350/257/257/346/233/277/346/215/242.md +130 -0
- package/troubleshooting/vue3/drawer-input-/346/240/267/345/274/217.md +181 -0
- package/troubleshooting/vue3/table-/347/274/226/350/276/221/345/217/226/346/266/210.md +148 -0
- package/troubleshooting/vue3/table-/350/276/271/346/241/206/351/227/256/351/242/230.md +178 -0
package/agents/flutter.agent.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Flutter 开发代理
|
|
2
2
|
|
|
3
3
|
> 此 Agent 引导 AI 通过 MCP 工具获取 npm 包中的详细规范
|
|
4
|
-
> 版本:
|
|
4
|
+
> 版本: v4.0.0 | 最后更新: 2026-02-11
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -42,11 +42,129 @@
|
|
|
42
42
|
| `siblingGaps` | 元素间距 | `SizedBox(height:)` |
|
|
43
43
|
| `layoutIntent` | 布局方式 | `Column`/`Row`/`Center` |
|
|
44
44
|
| `flutterHints` | 建议代码 | 直接参考 |
|
|
45
|
+
| `iconContentBounds` | Icon 实际路径尺寸 | 渲染用 contentSize,占位用 containerSize |
|
|
46
|
+
| `tagStyle` | Tag/标签容器样式 | background, padding, cornerRadius |
|
|
47
|
+
| `siblingIconAlignment` | 同行 Icon 对齐 | 统一 SizedBox 插槽尺寸 |
|
|
45
48
|
|
|
46
49
|
**禁止**:未测量就凭感觉还原、硬编码尺寸、忽略 layoutIntent
|
|
47
50
|
|
|
48
51
|
---
|
|
49
52
|
|
|
53
|
+
## 🔴 设计稿还原五大陷阱(最高优先级)
|
|
54
|
+
|
|
55
|
+
> 以下陷阱基于真实项目多轮修复总结,每条都曾导致 2-5 轮无效对话
|
|
56
|
+
|
|
57
|
+
### 陷阱 1:Icon Group 尺寸 ≠ 视觉尺寸
|
|
58
|
+
|
|
59
|
+
**问题**:Sketch Icon 的 Group 容器包含 padding,直接用 Group.frame 渲染会导致 Icon 偏大。
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
Sketch 结构:
|
|
63
|
+
├─ Group "Fee Icon" (16×16) ← 外层容器,含 padding
|
|
64
|
+
│ └─ ShapePath "path" (12×12) ← 实际可见图形
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**规则**:
|
|
68
|
+
- 测量插件输出 `iconContentBounds.containerSize`(Group 尺寸)和 `iconContentBounds.contentSize`(路径尺寸)
|
|
69
|
+
- **渲染 SVG 用 `contentSize`**(SvgPicture 的 width/height)
|
|
70
|
+
- **占位槽用 `containerSize`**(外层 SizedBox 的 width/height)
|
|
71
|
+
|
|
72
|
+
```dart
|
|
73
|
+
// 正确:分离占位与渲染
|
|
74
|
+
SizedBox(
|
|
75
|
+
width: 16, height: 16, // containerSize - 占位
|
|
76
|
+
child: Center(
|
|
77
|
+
child: SvgPicture.asset('icon.svg',
|
|
78
|
+
width: 12, height: 12, // contentSize - 渲染
|
|
79
|
+
),
|
|
80
|
+
),
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
// 错误:直接用 Group 尺寸渲染
|
|
84
|
+
SvgPicture.asset('icon.svg', width: 16, height: 16) // 太大!
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 陷阱 2:同行 Icon 不同尺寸导致文字错位
|
|
88
|
+
|
|
89
|
+
**问题**:同一行的多个 Icon(如手续费 14px、优惠券 12px)如果直接用各自尺寸,后面的文字起始位置不一致。
|
|
90
|
+
|
|
91
|
+
**规则**:
|
|
92
|
+
- 测量插件输出 `siblingIconAlignment.maxSlotSize`
|
|
93
|
+
- 所有同行 Icon 用**相同的 SizedBox 占位**,内部 Center 包裹实际 Icon
|
|
94
|
+
|
|
95
|
+
```dart
|
|
96
|
+
// 正确:统一占位 16px,文字从 20px 位置开始(16 + 4gap)
|
|
97
|
+
Row(children: [
|
|
98
|
+
SizedBox(width: 16, height: 16, child: Center(
|
|
99
|
+
child: SvgPicture.asset('fee.svg', width: 14, height: 14),
|
|
100
|
+
)),
|
|
101
|
+
Gap(4),
|
|
102
|
+
Text('手续费'),
|
|
103
|
+
])
|
|
104
|
+
Row(children: [
|
|
105
|
+
SizedBox(width: 16, height: 16, child: Center(
|
|
106
|
+
child: SvgPicture.asset('coupon.svg', width: 12, height: 12),
|
|
107
|
+
)),
|
|
108
|
+
Gap(4),
|
|
109
|
+
Text('优惠券'),
|
|
110
|
+
])
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 陷阱 3:Tag/标签容器样式丢失
|
|
114
|
+
|
|
115
|
+
**问题**:小型 Tag(如"支付宝"标签)的 background、padding、cornerRadius 未从 Sketch 提取,凭感觉写出的样式与设计稿不符。
|
|
116
|
+
|
|
117
|
+
**规则**:
|
|
118
|
+
- 测量插件输出 `tagStyle`,包含 `background`、`padding`(horizontal/vertical)、`cornerRadius`
|
|
119
|
+
- **直接使用测量值**,不要猜测 padding
|
|
120
|
+
|
|
121
|
+
```dart
|
|
122
|
+
// 正确:使用测量数据
|
|
123
|
+
Container(
|
|
124
|
+
padding: EdgeInsets.symmetric(horizontal: 3, vertical: 1), // 测量值
|
|
125
|
+
decoration: BoxDecoration(
|
|
126
|
+
color: Color(0x991676FE), // 测量的 bg + 透明度
|
|
127
|
+
borderRadius: BorderRadius.circular(3), // 测量的圆角
|
|
128
|
+
),
|
|
129
|
+
child: Text('支付宝', style: TextStyle(fontSize: 8)),
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
// 错误:凭感觉
|
|
133
|
+
Container(
|
|
134
|
+
padding: EdgeInsets.symmetric(horizontal: 6, vertical: 2), // 猜的
|
|
135
|
+
decoration: BoxDecoration(
|
|
136
|
+
color: Color(0xFF1677FF), // 丢失透明度
|
|
137
|
+
borderRadius: BorderRadius.circular(4), // 猜的
|
|
138
|
+
),
|
|
139
|
+
)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 陷阱 4:字体权重的平台可用性
|
|
143
|
+
|
|
144
|
+
**问题**:Sketch fontWeight=8(Heavy/w800)在 PingFang SC 字体中不存在真实字重文件,Flutter 会用合成加粗(synthetic bold),视觉效果过粗。
|
|
145
|
+
|
|
146
|
+
**规则**:
|
|
147
|
+
- 使用 PostScript 字体名(如 `PingFangSC-Semibold`)映射权重,而非 Sketch 的 `fontWeight` 数值
|
|
148
|
+
- **PingFang SC 最大真实字重 = Semibold (w600)**,超过此值一律降为 w600
|
|
149
|
+
- **Helvetica 最大真实字重 = Bold (w700)**,超过此值一律降为 w700
|
|
150
|
+
|
|
151
|
+
| Sketch fontWeight | PostScript 名 | Flutter 正确映射 |
|
|
152
|
+
|-------------------|--------------|-----------------|
|
|
153
|
+
| 8 (Heavy) | PingFangSC-Semibold | `FontWeight.w600`(而非 w800) |
|
|
154
|
+
| 9 (Black) | 不存在 | `FontWeight.w600`(降级) |
|
|
155
|
+
| 7 (Bold) | HelveticaNeue-Bold | `FontWeight.w700` |
|
|
156
|
+
|
|
157
|
+
### 陷阱 5:添加设计稿中不存在的元素
|
|
158
|
+
|
|
159
|
+
**问题**:AI 根据语义推测添加了设计稿中没有的 UI 元素(如在"汇率"标签前加了 swap_horiz 图标)。
|
|
160
|
+
|
|
161
|
+
**规则**:
|
|
162
|
+
- **只还原测量数据中存在的元素**,不自行添加
|
|
163
|
+
- 如果测量数据中某个标签没有关联 Icon,则不添加 Icon
|
|
164
|
+
- 如果不确定某元素是否存在,向用户确认
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
50
168
|
## 🔴 问题诊断优先(最高优先级)
|
|
51
169
|
|
|
52
170
|
**当用户描述任何问题时,必须首先调用:**
|
|
@@ -66,6 +184,10 @@ troubleshoot({ problem: "用户描述的问题" })
|
|
|
66
184
|
| 输入框边框异常 | input, border, focus |
|
|
67
185
|
| TextField 垂直居中 | textfield, placeholder, 居中, 光标, 输入框 |
|
|
68
186
|
| **Tab 嵌套导航** | tabbar, navigator, 返回无效, tab切换卡顿, 嵌套 |
|
|
187
|
+
| **Icon 尺寸偏差** | icon, 图标大小, Group, contentSize |
|
|
188
|
+
| **文字过粗/合成加粗** | fontWeight, 字体粗, 加粗, synthetic bold |
|
|
189
|
+
| **同行元素错位** | 对齐, 错位, 文字不齐, slot |
|
|
190
|
+
| **Tag/标签样式错误** | tag, 标签, padding, 背景色 |
|
|
69
191
|
|
|
70
192
|
> 💡 详细诊断方案由 MCP 工具从 npm 包动态加载
|
|
71
193
|
|
|
@@ -145,6 +267,11 @@ get_standard_by_id({ ids: ['flutter', 'flutter-ui-system'] })
|
|
|
145
267
|
- `api-layer` - API 层封装模式
|
|
146
268
|
- `component-design` - 组件设计模式
|
|
147
269
|
|
|
270
|
+
**设计稿还原**
|
|
271
|
+
- `sketch-pitfalls` - Sketch 测量五大陷阱(Icon尺寸/Tag样式/字重/对齐/幽灵元素)
|
|
272
|
+
- `design-restoration` - 设计稿还原通用流程
|
|
273
|
+
- `sketch-mcp` - Sketch MCP 深度测量规范
|
|
274
|
+
|
|
148
275
|
---
|
|
149
276
|
|
|
150
277
|
## 🎨 设计稿还原规范
|
|
@@ -172,6 +299,10 @@ get_standard_by_id({ ids: ['flutter', 'flutter-ui-system'] })
|
|
|
172
299
|
| `siblingGaps` | 兄弟元素间的间距 | 转换为 `Gap()`、`SizedBox(height:)` |
|
|
173
300
|
| `layoutIntent` | 布局意图(居中、填充等) | 选择 `Center`、`Column`、`Row` |
|
|
174
301
|
| `flutterHints` | 直接可用的 Flutter 代码 | 参考建议代码快速实现 |
|
|
302
|
+
| `iconContentBounds` | Icon 容器 vs 路径尺寸 | containerSize→占位, contentSize→渲染 |
|
|
303
|
+
| `tagStyle` | Tag 容器完整样式 | bg/padding/cornerRadius 精确还原 |
|
|
304
|
+
| `siblingIconAlignment` | 同行 Icon 统一尺寸 | maxSlotSize→统一 SizedBox |
|
|
305
|
+
| `fontName` | PostScript 字体名 | 正确映射 FontWeight(防合成加粗) |
|
|
175
306
|
|
|
176
307
|
### 还原检查清单
|
|
177
308
|
|
|
@@ -183,6 +314,11 @@ get_standard_by_id({ ids: ['flutter', 'flutter-ui-system'] })
|
|
|
183
314
|
- [ ] 使用 Token 系统($c, $t, $s, $r)替代硬编码
|
|
184
315
|
- [ ] **计算内容总高度**,验证不超出容器(详见陷阱规范)
|
|
185
316
|
- [ ] **避免 EdgeInsets.symmetric**,精确布局用 EdgeInsets.only
|
|
317
|
+
- [ ] **Icon 用 contentSize 渲染,containerSize 占位**(防 Icon 偏大)
|
|
318
|
+
- [ ] **同行 Icon 统一 SizedBox 占位**(防文字错位)
|
|
319
|
+
- [ ] **Tag 容器使用测量的 padding/bg/cornerRadius**(防样式猜测)
|
|
320
|
+
- [ ] **字体权重检查平台可用性**(PingFang≤w600, Helvetica≤w700)
|
|
321
|
+
- [ ] **只还原测量数据中存在的元素**(防添加幽灵元素)
|
|
186
322
|
|
|
187
323
|
### ⚠️ 常见陷阱(必读)
|
|
188
324
|
|
|
@@ -197,6 +333,11 @@ get_standard_by_id({ id: 'sketch-pitfalls' })
|
|
|
197
333
|
| 固定高度容器 | OVERFLOWED BY X PIXELS | 移除 height,用 MainAxisSize.min |
|
|
198
334
|
| EdgeInsets.symmetric | 溢出 1-5px | 用 EdgeInsets.only 精确控制 |
|
|
199
335
|
| 文本行高 | 容器高度不足 | 计算 fontSize × height 的实际占用 |
|
|
336
|
+
| Icon 用 Group 尺寸 | Icon 比设计稿大 2-4px | 用 contentSize 渲染,containerSize 占位 |
|
|
337
|
+
| 同行 Icon 不等大 | 文字起始位置不一致 | 统一 SizedBox 插槽 + Center |
|
|
338
|
+
| Tag 凭感觉写样式 | padding/bg/圆角全错 | 使用 tagStyle 测量数据 |
|
|
339
|
+
| 字重超出平台上限 | 文字过粗(合成加粗) | PingFang≤w600, Helvetica≤w700 |
|
|
340
|
+
| 添加不存在的元素 | UI 与设计稿不符 | 只还原测量数据中存在的元素 |
|
|
200
341
|
|
|
201
342
|
> 📖 **详细案例**:`mcp-server/troubleshooting/flutter/sketch-overflow-container.md`
|
|
202
343
|
|
|
@@ -206,7 +347,11 @@ get_standard_by_id({ id: 'sketch-pitfalls' })
|
|
|
206
347
|
❌ **禁止**使用简单的 `Positioned` 绝对定位所有元素
|
|
207
348
|
❌ **禁止**硬编码内边距值(如 `EdgeInsets.all(16)`)而不基于测量数据
|
|
208
349
|
❌ **禁止**忽略 `layoutIntent` 字段,导致嵌套层级错误
|
|
209
|
-
❌ **禁止**硬编码颜色/尺寸(必须使用 Token 系统)
|
|
350
|
+
❌ **禁止**硬编码颜色/尺寸(必须使用 Token 系统)
|
|
351
|
+
❌ **禁止**用 Icon Group 的 frame 尺寸直接渲染 SVG(必须用 contentSize)
|
|
352
|
+
❌ **禁止**凭推测添加设计稿中不存在的 UI 元素(如猜测性添加图标)
|
|
353
|
+
❌ **禁止**使用超出字体平台可用范围的 FontWeight(合成加粗视觉差异大)
|
|
354
|
+
❌ **禁止**同行不同尺寸 Icon 各用各的宽度(必须统一占位槽)
|
|
210
355
|
|
|
211
356
|
### 🎯 深度还原模式(像素级)
|
|
212
357
|
|
|
@@ -237,27 +382,41 @@ get_standard_by_id({ id: 'sketch-pitfalls' })
|
|
|
237
382
|
**检测到 icon 时的处理流程**:
|
|
238
383
|
|
|
239
384
|
```
|
|
240
|
-
1.
|
|
241
|
-
2.
|
|
242
|
-
3.
|
|
243
|
-
4.
|
|
385
|
+
1. 测量插件标记 `isIcon: true` 并输出 iconContentBounds
|
|
386
|
+
2. 读取 containerSize(Group 尺寸)和 contentSize(实际路径尺寸)
|
|
387
|
+
3. 将 SVG 文件放入 assets/icons/ 目录
|
|
388
|
+
4. 在 pubspec.yaml 中声明 assets
|
|
389
|
+
5. 使用 flutter_svg 包加载,宽高用 contentSize
|
|
390
|
+
6. 外层用 SizedBox(containerSize) + Center 包裹
|
|
244
391
|
```
|
|
245
392
|
|
|
246
393
|
**Flutter Icon 使用方式**:
|
|
247
394
|
|
|
248
395
|
| 场景 | 代码示例 | 说明 |
|
|
249
396
|
|------|---------|------|
|
|
250
|
-
| **SVG Icon
|
|
397
|
+
| **SVG Icon(标准)** | `SizedBox(width: 16, height: 16, child: Center(child: SvgPicture.asset('icon.svg', width: 12, height: 12, colorFilter: ColorFilter.mode($c.iconPrimary, BlendMode.srcIn))))` | containerSize 占位 + contentSize 渲染 |
|
|
251
398
|
| **系统 Icon** | `Icon(Icons.menu, size: 24, color: $c.iconPrimary)` | 优先使用 Material Icons |
|
|
252
|
-
|
|
|
399
|
+
| **同行对齐** | 所有 Icon 用 `SizedBox(width: maxSlotSize)` + `Center` | 确保后续文字对齐 |
|
|
400
|
+
|
|
401
|
+
**Icon 尺寸决策流程:**
|
|
402
|
+
|
|
403
|
+
```
|
|
404
|
+
测量数据 → iconContentBounds
|
|
405
|
+
├─ containerSize (Group frame) → 外层 SizedBox 占位
|
|
406
|
+
├─ contentSize (路径 union) → SvgPicture width/height
|
|
407
|
+
└─ siblingIconAlignment.maxSlotSize → 同行统一占位
|
|
408
|
+
```
|
|
253
409
|
|
|
254
|
-
|
|
410
|
+
**Icon 禁止规则**:
|
|
255
411
|
|
|
256
412
|
| ❌ 禁止 | ✅ 正确 |
|
|
257
413
|
|--------|--------|
|
|
258
414
|
| `Image.asset('icon.png')` | `SvgPicture.asset('icon.svg')` |
|
|
259
415
|
| `width: 32, height: 28` | 保持 1:1 宽高比或使用原始比例 |
|
|
260
416
|
| 硬编码颜色 | `colorFilter: ColorFilter.mode($c.iconPrimary, ...)` |
|
|
417
|
+
| 直接用 Group 尺寸渲染 SVG | 用 contentSize 渲染,containerSize 占位 |
|
|
418
|
+
| 同行 Icon 各用各的宽度 | 统一 maxSlotSize + Center |
|
|
419
|
+
| 凭语义推测添加 Icon | 只添加测量数据中存在的 Icon |
|
|
261
420
|
|
|
262
421
|
#### Flutter 禁止规则
|
|
263
422
|
|
package/dist/index.js
CHANGED
|
@@ -3332,7 +3332,8 @@ var STANDARD_DIRS = [
|
|
|
3332
3332
|
"standards/frameworks",
|
|
3333
3333
|
"standards/libraries",
|
|
3334
3334
|
"standards/patterns",
|
|
3335
|
-
"standards/workflows"
|
|
3335
|
+
"standards/workflows",
|
|
3336
|
+
"standards/mcp-tools"
|
|
3336
3337
|
];
|
|
3337
3338
|
var standardsCache = null;
|
|
3338
3339
|
async function getStandardById(args) {
|