mta-mcp 2.14.0 → 2.16.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mta-mcp",
3
- "version": "2.14.0",
3
+ "version": "2.16.0",
4
4
  "description": "MTA - 智能项目分析与编码规范管理 MCP 服务器",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1,103 @@
1
+ # 底层必须规则(Mandatory Rules)
2
+
3
+ > 此规范由 MCP 底层自动注入,所有规范请求都会附加此内容。
4
+ > 版本: v1.0.0 | 最后更新: 2026-01-16
5
+
6
+ ---
7
+
8
+ ## 🚨 零容忍规则
9
+
10
+ **这些规则在任何情况下都不能违反,优先级最高:**
11
+
12
+ ### 1. 完整的标签配对
13
+
14
+ ```html
15
+ ✅ <div>...</div>
16
+ ✅ <el-table>...</el-table>
17
+ ❌ <div>...<div> <!-- 缺少结束标签 -->
18
+ ❌ </div> <!-- 孤立的结束标签 -->
19
+ ```
20
+
21
+ ### 2. 禁止 `any` 类型
22
+
23
+ ```typescript
24
+ // ❌ 禁止
25
+ const data: any = {}
26
+ function process(input: any) {}
27
+
28
+ // ✅ 正确
29
+ const data: Record<string, unknown> = {}
30
+ function process(input: UserData) {}
31
+ ```
32
+
33
+ ### 3. 国际化强制使用
34
+
35
+ ```vue
36
+ <!-- ✅ 正确 -->
37
+ <el-button>{{ $t('提交') }}</el-button>
38
+ :label="$t('名称')"
39
+ :placeholder="$t('请输入')"
40
+
41
+ <!-- ❌ 硬编码 -->
42
+ <el-button>提交</el-button>
43
+ label="名称"
44
+ ```
45
+
46
+ ---
47
+
48
+ ## ⚠️ 强制工作流
49
+
50
+ ### 问题诊断优先
51
+
52
+ 当用户描述问题时(错误、样式不对、效果不符预期),必须先调用:
53
+
54
+ ```
55
+ troubleshoot({ problem: "用户描述的问题" })
56
+ ```
57
+
58
+ ### 规范加载验证
59
+
60
+ 在生成代码前,必须确认已加载相关规范:
61
+
62
+ 1. **检查项目作用域** - 确认文件路径属于当前项目
63
+ 2. **声明已加载** - 在响应中说明:`✅ 已加载规范: [规范名称]`
64
+
65
+ ---
66
+
67
+ ## 🔍 代码审查清单
68
+
69
+ **每次编辑后必检:**
70
+
71
+ - [ ] 所有 HTML 标签正确闭合
72
+ - [ ] Vue SFC 只有一个 `<style>` 标签
73
+ - [ ] 所有用户可见文本已国际化
74
+ - [ ] 无 `any` 类型
75
+ - [ ] Props/Emits 有完整类型定义
76
+
77
+ ---
78
+
79
+ ## 🚫 全局禁止模式
80
+
81
+ | 禁止 | 替代方案 |
82
+ |------|----------|
83
+ | `any` 类型 | 具体类型或 `unknown` |
84
+ | Options API | Composition API (`<script setup>`) |
85
+ | 直接修改 Props | emit 事件或 computed |
86
+ | `<script>` 中使用 `this` | 使用响应式变量 |
87
+ | 多个 `<style>` 标签 | 合并为一个 |
88
+ | 硬编码文本 | `$t('...')` 国际化 |
89
+
90
+ ---
91
+
92
+ ## 📋 最小改动原则
93
+
94
+ | 判断项 | 是 | 否 |
95
+ |--------|---|---|
96
+ | 修改只影响当前文件? | 继续修改 | **停止,重新评估** |
97
+ | 存在类似模式? | **复用现有模式** | 可新建 |
98
+ | 需要改组件类型? | **先确认用户意图** | 继续 |
99
+ | 需要删除现有代码? | **先确认必要性** | 继续 |
100
+
101
+ ---
102
+
103
+ **此规范自动注入,无需手动加载。**
@@ -996,6 +996,84 @@ class UserProfile extends StatelessWidget {
996
996
 
997
997
  ---
998
998
 
999
+ ## 📝 TextField 垂直居中规范(重要)
1000
+
1001
+ > ⚠️ **此问题曾导致 15+ 轮对话才修复,必须一步到位**
1002
+
1003
+ ### 问题场景
1004
+ TextField 中 placeholder、光标、输入内容三者需要在固定高度容器中垂直居中对齐。
1005
+
1006
+ ### 正确方案(一步到位)
1007
+
1008
+ ```dart
1009
+ // ✅ 正确 - Container.alignment + 统一 height + contentPadding.zero
1010
+ Widget _buildCenteredTextField(String placeholder, TextEditingController controller) {
1011
+ return Container(
1012
+ height: 36, // 固定容器高度
1013
+ alignment: Alignment.center, // 关键1:让 TextField 整体居中
1014
+ child: TextField(
1015
+ controller: controller,
1016
+ textAlign: TextAlign.center,
1017
+ style: const TextStyle(
1018
+ fontSize: 14,
1019
+ height: 1.43, // 关键2:行高 = 期望文本高度 ÷ 字号
1020
+ ),
1021
+ decoration: InputDecoration(
1022
+ hintText: placeholder,
1023
+ hintStyle: const TextStyle(
1024
+ fontSize: 14,
1025
+ height: 1.43, // 关键3:必须与 style.height 完全一致
1026
+ ),
1027
+ contentPadding: EdgeInsets.zero, // 关键4:清除默认 padding
1028
+ isDense: true, // 关键5:移除额外空间
1029
+ border: InputBorder.none,
1030
+ ),
1031
+ ),
1032
+ );
1033
+ }
1034
+
1035
+ // ❌ 错误 - 会导致 placeholder 和输入内容位置不一致
1036
+ TextField(
1037
+ textAlignVertical: TextAlignVertical.center, // 只影响输入内容
1038
+ style: TextStyle(fontSize: 14, height: 1.43),
1039
+ decoration: InputDecoration(
1040
+ hintStyle: TextStyle(fontSize: 14), // height 不一致!
1041
+ contentPadding: EdgeInsets.symmetric(vertical: 8), // 干扰居中
1042
+ ),
1043
+ )
1044
+ ```
1045
+
1046
+ ### 行高计算公式
1047
+
1048
+ 从设计稿获取:
1049
+ - 容器高度:36px
1050
+ - 文本 Y 坐标:8px(距顶部)
1051
+ - 文本高度:20px
1052
+ - 字号:14px
1053
+
1054
+ ```
1055
+ height = 文本高度 ÷ 字号 = 20 ÷ 14 = 1.43
1056
+ ```
1057
+
1058
+ ### 禁止事项
1059
+
1060
+ | 禁止 | 原因 |
1061
+ |------|------|
1062
+ | `style.height` ≠ `hintStyle.height` | placeholder 和输入内容位置不一致 |
1063
+ | 同时用 `textAlignVertical` 和 `height` | 产生冲突,效果不可预测 |
1064
+ | 用 `strutStyle + forceStrutHeight` | 可能压缩文字 |
1065
+ | 反复调整 `contentPadding` 试错 | 应先确定行高配置 |
1066
+
1067
+ ### 调试顺序(遇到问题时)
1068
+
1069
+ 1. 先从设计稿获取:容器高度、文本 Y 坐标、文本高度
1070
+ 2. 计算 `height = 文本高度 ÷ 字号`
1071
+ 3. 确保 `style.height` = `hintStyle.height`
1072
+ 4. 设置 `Container.alignment: Alignment.center`
1073
+ 5. 设置 `contentPadding: EdgeInsets.zero` + `isDense: true`
1074
+
1075
+ ---
1076
+
999
1077
  ## 🎨 Sketch/Figma 设计稿还原规范
1000
1078
 
1001
1079
  > ⚠️ **此章节为强制执行规范** - 所有 UI 还原任务必须严格遵循