mcp-probe-kit 2.3.0 → 2.5.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/README.md +131 -48
- package/build/index.js +1 -7
- package/build/lib/guidance.d.ts +8 -0
- package/build/lib/guidance.js +30 -0
- package/build/lib/orchestration-guidance.d.ts +8 -0
- package/build/lib/orchestration-guidance.js +16 -0
- package/build/lib/template-loader.d.ts +25 -0
- package/build/lib/template-loader.js +473 -0
- package/build/lib/toolset-manager.d.ts +4 -4
- package/build/lib/toolset-manager.js +10 -13
- package/build/schemas/code-analysis-tools.d.ts +0 -18
- package/build/schemas/code-analysis-tools.js +0 -19
- package/build/schemas/doc-util-tools.d.ts +0 -9
- package/build/schemas/doc-util-tools.js +0 -10
- package/build/schemas/index.d.ts +46 -47
- package/build/schemas/orchestration-tools.d.ts +42 -2
- package/build/schemas/orchestration-tools.js +42 -2
- package/build/schemas/output/core-tools.d.ts +1 -117
- package/build/schemas/output/core-tools.js +1 -60
- package/build/schemas/output/index.d.ts +5 -4
- package/build/schemas/output/index.js +6 -4
- package/build/schemas/output/product-design-tools.d.ts +160 -0
- package/build/schemas/output/product-design-tools.js +75 -0
- package/build/schemas/output/project-tools.d.ts +1 -217
- package/build/schemas/output/project-tools.js +1 -103
- package/build/schemas/project-tools.d.ts +4 -18
- package/build/schemas/project-tools.js +4 -19
- package/build/schemas/structured-output.d.ts +309 -99
- package/build/schemas/structured-output.js +174 -72
- package/build/schemas/ui-ux-schemas.d.ts +26 -0
- package/build/schemas/ui-ux-schemas.js +26 -0
- package/build/tools/__tests__/add_feature.template.test.d.ts +4 -0
- package/build/tools/__tests__/add_feature.template.test.js +47 -0
- package/build/tools/__tests__/start_bugfix.unit.test.d.ts +4 -0
- package/build/tools/__tests__/start_bugfix.unit.test.js +85 -0
- package/build/tools/__tests__/start_feature.unit.test.d.ts +4 -0
- package/build/tools/__tests__/start_feature.unit.test.js +83 -0
- package/build/tools/__tests__/start_ui.integration.test.js +4 -3
- package/build/tools/__tests__/start_ui.loop.test.d.ts +4 -0
- package/build/tools/__tests__/start_ui.loop.test.js +24 -0
- package/build/tools/__tests__/start_ui.unit.test.js +39 -1
- package/build/tools/add_feature.js +184 -406
- package/build/tools/ask_user.js +18 -5
- package/build/tools/code_review.js +8 -1
- package/build/tools/estimate.js +9 -2
- package/build/tools/fix_bug.js +9 -2
- package/build/tools/gen_mock.js +8 -1
- package/build/tools/gen_prd.d.ts +1 -7
- package/build/tools/gen_prd.js +41 -27
- package/build/tools/gen_prototype.d.ts +1 -7
- package/build/tools/gen_prototype.js +47 -27
- package/build/tools/genapi.js +8 -1
- package/build/tools/genchangelog.js +8 -1
- package/build/tools/gencommit.d.ts +1 -1
- package/build/tools/gencommit.js +49 -18
- package/build/tools/gendoc.js +9 -1
- package/build/tools/genpr.js +8 -1
- package/build/tools/genreadme.js +8 -1
- package/build/tools/gensql.js +8 -1
- package/build/tools/gentest.js +8 -1
- package/build/tools/index.d.ts +0 -3
- package/build/tools/index.js +0 -3
- package/build/tools/interview.d.ts +1 -13
- package/build/tools/interview.js +96 -31
- package/build/tools/perf.js +8 -1
- package/build/tools/refactor.js +8 -1
- package/build/tools/resolve_conflict.js +8 -1
- package/build/tools/security_scan.js +9 -2
- package/build/tools/start_api.js +44 -4
- package/build/tools/start_bugfix.js +377 -15
- package/build/tools/start_doc.js +40 -4
- package/build/tools/start_feature.js +287 -92
- package/build/tools/start_onboard.js +83 -100
- package/build/tools/start_product.d.ts +1 -1
- package/build/tools/start_product.js +183 -6
- package/build/tools/start_ralph.js +51 -2
- package/build/tools/start_refactor.js +39 -4
- package/build/tools/start_release.js +33 -4
- package/build/tools/start_review.js +39 -4
- package/build/tools/start_ui.js +669 -52
- package/build/utils/design-reasoning-engine.d.ts +5 -0
- package/build/utils/design-reasoning-engine.js +85 -5
- package/docs/data/tools.js +308 -478
- package/docs/index.html +1 -1
- package/docs/pages/all-tools.html +37 -22
- package/docs/pages/examples.html +100 -35
- package/docs/pages/getting-started.html +43 -3
- package/docs/pages/migration.html +14 -8
- package/package.json +79 -79
- package/build/lib/analysis-tasks.d.ts +0 -35
- package/build/lib/analysis-tasks.js +0 -788
- package/build/lib/elicitation-helper.d.ts +0 -73
- package/build/lib/elicitation-helper.js +0 -130
- package/build/lib/task-generator.d.ts +0 -11
- package/build/lib/task-generator.js +0 -109
- package/build/lib/template-generator.d.ts +0 -14
- package/build/lib/template-generator.js +0 -62
- package/build/lib/templates/backend-templates.d.ts +0 -8
- package/build/lib/templates/backend-templates.js +0 -26
- package/build/resources/index.d.ts +0 -4
- package/build/resources/index.js +0 -4
- package/build/resources/tool-params-guide.d.ts +0 -571
- package/build/resources/tool-params-guide.js +0 -488
- package/build/tools/analyze_project.d.ts +0 -1
- package/build/tools/analyze_project.js +0 -566
- package/build/tools/check_deps.d.ts +0 -1
- package/build/tools/check_deps.js +0 -213
- package/build/tools/convert.d.ts +0 -13
- package/build/tools/convert.js +0 -599
- package/build/tools/css_order.d.ts +0 -13
- package/build/tools/css_order.js +0 -81
- package/build/tools/debug.d.ts +0 -1
- package/build/tools/debug.js +0 -133
- package/build/tools/design2code.d.ts +0 -20
- package/build/tools/design2code.js +0 -426
- package/build/tools/detect_shell.d.ts +0 -6
- package/build/tools/detect_shell.js +0 -151
- package/build/tools/explain.d.ts +0 -13
- package/build/tools/explain.js +0 -390
- package/build/tools/fix.d.ts +0 -13
- package/build/tools/fix.js +0 -303
- package/build/tools/gen_skill.d.ts +0 -13
- package/build/tools/gen_skill.js +0 -560
- package/build/tools/genui.d.ts +0 -13
- package/build/tools/genui.js +0 -803
- package/build/tools/init_setting.d.ts +0 -13
- package/build/tools/init_setting.js +0 -47
- package/build/tools/split.d.ts +0 -13
- package/build/tools/split.js +0 -599
- package/build/tools/templates/architecture-template.d.ts +0 -5
- package/build/tools/templates/architecture-template.js +0 -42
- package/build/tools/templates/coding-standards-template.d.ts +0 -5
- package/build/tools/templates/coding-standards-template.js +0 -41
- package/build/tools/templates/dependencies-template.d.ts +0 -5
- package/build/tools/templates/dependencies-template.js +0 -38
- package/build/tools/templates/index-template.d.ts +0 -5
- package/build/tools/templates/index-template.js +0 -64
- package/build/tools/templates/tech-stack-template.d.ts +0 -5
- package/build/tools/templates/tech-stack-template.js +0 -35
- package/build/tools/templates/workflows-template.d.ts +0 -5
- package/build/tools/templates/workflows-template.js +0 -31
- package/docs/specs/algorithm-enhancement/roadmap.md +0 -619
- package/docs/specs/project-context-modular/design.md +0 -722
- package/docs/specs/project-context-modular/example-output.md +0 -123
- package/docs/specs/project-context-modular/implementation-v2.md +0 -275
- package/docs/specs/project-context-modular/requirements.md +0 -234
- package/docs/specs/project-context-modular/tasks.md +0 -386
- package/docs/specs/v2.1-planning.md +0 -335
- package/docs/specs/vnext-upgrade/00-OVERVIEW.md +0 -258
- package/docs/specs/vnext-upgrade/BETA_RELEASE_GUIDE.md +0 -328
- package/docs/specs/vnext-upgrade/GITHUB_DISCUSSION_TEMPLATE.md +0 -236
- package/docs/specs/vnext-upgrade/M8.9-PROGRESS-UPDATE.md +0 -248
- package/docs/specs/vnext-upgrade/PROGRESS-SUMMARY.md +0 -195
- package/docs/specs/vnext-upgrade/QUICK_REFERENCE.md +0 -338
- package/docs/specs/vnext-upgrade/README.md +0 -125
- package/docs/specs/vnext-upgrade/STATUS-UPDATE-2026-01-26.md +0 -230
- package/docs/specs/vnext-upgrade/TOOL_CLEANUP.md +0 -343
- package/docs/specs/vnext-upgrade/completed/M1-M2-SUMMARY.md +0 -27
- package/docs/specs/vnext-upgrade/completed/M3_COMPLETION_SUMMARY.md +0 -273
- package/docs/specs/vnext-upgrade/completed/M4-SUMMARY.md +0 -19
- package/docs/specs/vnext-upgrade/completed/M5_COMPLETION_SUMMARY.md +0 -0
- package/docs/specs/vnext-upgrade/completed/M8.1-SUMMARY.md +0 -247
- package/docs/specs/vnext-upgrade/completed/M8.2-SUMMARY.md +0 -296
- package/docs/specs/vnext-upgrade/completed/M8.3-SUMMARY.md +0 -241
- package/docs/specs/vnext-upgrade/completed/M8.3-TEST-SUMMARY.md +0 -216
- package/docs/specs/vnext-upgrade/completed/M8.4-SUMMARY.md +0 -217
- package/docs/specs/vnext-upgrade/completed/M8.4-TEST-SUMMARY.md +0 -198
- package/docs/specs/vnext-upgrade/completed/M8.5-SUMMARY.md +0 -202
- package/docs/specs/vnext-upgrade/completed/M8.5-TEST-SUMMARY.md +0 -223
- package/docs/specs/vnext-upgrade/completed/M8.6-SUMMARY.md +0 -299
- package/docs/specs/vnext-upgrade/completed/M8.8-TEST-SUMMARY.md +0 -216
- package/docs/specs/vnext-upgrade/completed/TOOL-CLEANUP-SUMMARY.md +0 -210
- package/docs/specs/vnext-upgrade/design.md +0 -848
- package/docs/specs/vnext-upgrade/requirements.md +0 -221
- package/docs/specs/vnext-upgrade/tasks/00-INDEX.md +0 -335
- package/docs/specs/vnext-upgrade/tasks/M8.1-SCHEMA-DEFINITION.md +0 -300
- package/docs/specs/vnext-upgrade/tasks/M8.2-P1-TOOLS.md +0 -249
- package/docs/specs/vnext-upgrade/tasks/M8.3-GENERATION-TOOLS.md +0 -49
- package/docs/specs/vnext-upgrade/tasks/M8.4-ORCHESTRATION-TOOLS.md +0 -28
- package/docs/specs/vnext-upgrade/tasks/M8.5-PROJECT-TOOLS.md +0 -29
- package/docs/specs/vnext-upgrade/tasks/M8.6-UI-TOOLS.md +0 -66
- package/docs/specs/vnext-upgrade/tasks/M8.7-HELPER-TOOLS.md +0 -24
- package/docs/specs/vnext-upgrade/tasks/M8.8-INTEGRATION-TESTS.md +0 -90
- package/docs/specs/vnext-upgrade/tasks/M8.9-DOCUMENTATION.md +0 -103
- package/docs/vnext/MCP_2025-11-25_GUIDE.md +0 -276
- package/docs/vnext/vNext-PRD.md +0 -488
package/build/tools/start_ui.js
CHANGED
|
@@ -7,23 +7,97 @@
|
|
|
7
7
|
* 3. 搜索/生成 UI 模板
|
|
8
8
|
* 4. 渲染最终代码
|
|
9
9
|
*/
|
|
10
|
-
import { parseArgs, getString } from "../utils/parseArgs.js";
|
|
10
|
+
import { parseArgs, getString, getNumber } from "../utils/parseArgs.js";
|
|
11
11
|
import { getReasoningEngine } from "./ui-ux-tools.js";
|
|
12
12
|
import { okStructured } from "../lib/response.js";
|
|
13
|
-
import {
|
|
13
|
+
import { renderOrchestrationHeader } from "../lib/orchestration-guidance.js";
|
|
14
|
+
import { UIReportSchema, RequirementsLoopSchema } from "../schemas/structured-output.js";
|
|
14
15
|
import { detectProjectType } from "../lib/project-detector.js";
|
|
15
|
-
|
|
16
|
+
function inferProductType(description) {
|
|
17
|
+
const text = (description || '').toLowerCase();
|
|
18
|
+
if (/电商|e-?commerce|shop|商城|购物/.test(text))
|
|
19
|
+
return 'E-commerce';
|
|
20
|
+
if (/教育|course|learning|school|培训/.test(text))
|
|
21
|
+
return 'Educational App';
|
|
22
|
+
if (/医疗|health|med|clinic|hospital/.test(text))
|
|
23
|
+
return 'Healthcare App';
|
|
24
|
+
if (/政府|gov|public/.test(text))
|
|
25
|
+
return 'Government/Public Service';
|
|
26
|
+
if (/金融|fintech|bank|支付|crypto|区块链/.test(text))
|
|
27
|
+
return 'Fintech/Crypto';
|
|
28
|
+
if (/社交|social|community|forum|chat/.test(text))
|
|
29
|
+
return 'Social Media App';
|
|
30
|
+
if (/analytics|dashboard|报表|数据看板/.test(text))
|
|
31
|
+
return 'Analytics Dashboard';
|
|
32
|
+
if (/b2b|企业/.test(text))
|
|
33
|
+
return 'B2B Service';
|
|
34
|
+
if (/portfolio|作品集|个人网站/.test(text))
|
|
35
|
+
return 'Portfolio/Personal';
|
|
36
|
+
if (/agency|工作室|创意/.test(text))
|
|
37
|
+
return 'Creative Agency';
|
|
38
|
+
return 'SaaS (General)';
|
|
39
|
+
}
|
|
40
|
+
function normalizeTemplateName(value, fallback) {
|
|
41
|
+
const safe = (value || '')
|
|
42
|
+
.toLowerCase()
|
|
43
|
+
.replace(/页面|表单|组件/g, '')
|
|
44
|
+
.trim()
|
|
45
|
+
.replace(/[^\w\u4e00-\u9fa5-]/g, '-')
|
|
46
|
+
.replace(/-+/g, '-')
|
|
47
|
+
.replace(/^-|-$/g, '');
|
|
48
|
+
return safe || fallback;
|
|
49
|
+
}
|
|
50
|
+
function decideTemplateProfile(description) {
|
|
51
|
+
const text = description || '';
|
|
52
|
+
const lengthScore = text.length >= 200 ? 2 : text.length >= 120 ? 1 : 0;
|
|
53
|
+
const structureSignals = [
|
|
54
|
+
/(^|\n)\s*#{1,3}\s+\S+/m,
|
|
55
|
+
/(^|\n)\s*[-*]\s+\S+/m,
|
|
56
|
+
/(^|\n)\s*\d+\.\s+\S+/m,
|
|
57
|
+
/页面|组件|交互|状态|数据|权限|可访问性|响应式|视觉|风格/m,
|
|
58
|
+
];
|
|
59
|
+
const signalScore = structureSignals.reduce((score, regex) => score + (regex.test(text) ? 1 : 0), 0);
|
|
60
|
+
if (lengthScore >= 1 && signalScore >= 2) {
|
|
61
|
+
return 'strict';
|
|
62
|
+
}
|
|
63
|
+
return 'guided';
|
|
64
|
+
}
|
|
65
|
+
function resolveTemplateProfile(rawProfile, description) {
|
|
66
|
+
const normalized = (rawProfile || '').trim().toLowerCase();
|
|
67
|
+
if (!normalized || normalized === 'auto') {
|
|
68
|
+
const resolved = decideTemplateProfile(description);
|
|
69
|
+
return {
|
|
70
|
+
requested: 'auto',
|
|
71
|
+
resolved,
|
|
72
|
+
reason: resolved === 'strict' ? '需求结构化且较完整' : '需求较简略,需要更多指导',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (normalized === 'guided' || normalized === 'strict') {
|
|
76
|
+
return {
|
|
77
|
+
requested: normalized,
|
|
78
|
+
resolved: normalized,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const fallback = decideTemplateProfile(description);
|
|
82
|
+
return {
|
|
83
|
+
requested: 'auto',
|
|
84
|
+
resolved: fallback,
|
|
85
|
+
warning: `模板档位 \"${rawProfile}\" 不支持,已回退为 ${fallback}`,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const PROMPT_TEMPLATE_GUIDED = `# 快速开始
|
|
16
89
|
|
|
17
90
|
**职责说明**: 本工具仅提供执行指导,不执行实际操作。请按顺序调用以下 MCP 工具。
|
|
18
91
|
|
|
19
92
|
执行以下工具:
|
|
20
93
|
|
|
21
94
|
1. 检查 \`docs/project-context.md\` 是否存在,不存在则调用 \`init_project_context\`
|
|
22
|
-
2. 检查 \`docs/design-system.md\` 是否存在,不存在则调用 \`ui_design_system --product_type="
|
|
23
|
-
3. 检查 \`docs/component-catalog.json\` 是否存在,不存在则调用 \`init_component_catalog\`
|
|
95
|
+
2. 检查 \`docs/design-system.md\` 是否存在,不存在则调用 \`ui_design_system --product_type="{productType}" --stack="{framework}"\`
|
|
96
|
+
3. 检查 \`docs/ui/component-catalog.json\` 是否存在,不存在则调用 \`init_component_catalog\`
|
|
24
97
|
4. \`ui_search --mode=template --query="{description}"\`
|
|
25
|
-
5. \`
|
|
26
|
-
6.
|
|
98
|
+
5. 选择模板并保存到 \`docs/ui/{templateName}.json\`
|
|
99
|
+
6. \`render_ui --template="docs/ui/{templateName}.json" --framework="{framework}"\`
|
|
100
|
+
7. 将生成的 UI 文档添加到 \`docs/project-context.md\` 索引中
|
|
27
101
|
|
|
28
102
|
---
|
|
29
103
|
|
|
@@ -50,7 +124,7 @@ const PROMPT_TEMPLATE = `# 快速开始
|
|
|
50
124
|
**参数**:
|
|
51
125
|
\`\`\`json
|
|
52
126
|
{
|
|
53
|
-
"product_type": "{
|
|
127
|
+
"product_type": "{productType}",
|
|
54
128
|
"stack": "{framework}",
|
|
55
129
|
"description": "{description}"
|
|
56
130
|
}
|
|
@@ -63,12 +137,12 @@ const PROMPT_TEMPLATE = `# 快速开始
|
|
|
63
137
|
|
|
64
138
|
## 步骤 3: 生成组件目录(如不存在)📦
|
|
65
139
|
|
|
66
|
-
**检查**: 查看 \`docs/component-catalog.json\` 是否存在
|
|
140
|
+
**检查**: 查看 \`docs/ui/component-catalog.json\` 是否存在
|
|
67
141
|
|
|
68
142
|
**如果不存在,调用工具**: \`init_component_catalog\`
|
|
69
143
|
**参数**: 无
|
|
70
144
|
|
|
71
|
-
**预期输出**: \`docs/component-catalog.json\`
|
|
145
|
+
**预期输出**: \`docs/ui/component-catalog.json\`
|
|
72
146
|
**失败处理**: 确保步骤 2 的设计系统文件已生成
|
|
73
147
|
|
|
74
148
|
---
|
|
@@ -85,11 +159,28 @@ const PROMPT_TEMPLATE = `# 快速开始
|
|
|
85
159
|
\`\`\`
|
|
86
160
|
|
|
87
161
|
**预期输出**: 匹配的模板列表(可能为空)
|
|
88
|
-
**失败处理**:
|
|
162
|
+
**失败处理**: 如果没有找到模板,创建最小模板文件再进入渲染步骤
|
|
89
163
|
|
|
90
164
|
---
|
|
91
165
|
|
|
92
|
-
## 步骤 5:
|
|
166
|
+
## 步骤 5: 保存模板文件 🧩
|
|
167
|
+
|
|
168
|
+
**操作**: 从搜索结果选择模板或创建最小模板
|
|
169
|
+
|
|
170
|
+
**保存路径**: \`docs/ui/{templateName}.json\`
|
|
171
|
+
|
|
172
|
+
**最小模板示例**:
|
|
173
|
+
\`\`\`json
|
|
174
|
+
{
|
|
175
|
+
"name": "UiTemplate",
|
|
176
|
+
"description": "{description}",
|
|
177
|
+
"layout": "sectioned"
|
|
178
|
+
}
|
|
179
|
+
\`\`\`
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## 步骤 6: 渲染最终代码 💻
|
|
93
184
|
|
|
94
185
|
**工具**: \`render_ui\`
|
|
95
186
|
**参数**:
|
|
@@ -101,11 +192,11 @@ const PROMPT_TEMPLATE = `# 快速开始
|
|
|
101
192
|
\`\`\`
|
|
102
193
|
|
|
103
194
|
**预期输出**: 完整的 {framework} 组件代码
|
|
104
|
-
**失败处理**:
|
|
195
|
+
**失败处理**: 如果模板不存在,请先完成步骤 5 保存模板文件
|
|
105
196
|
|
|
106
197
|
---
|
|
107
198
|
|
|
108
|
-
## 步骤
|
|
199
|
+
## 步骤 7: 更新项目上下文索引 📝
|
|
109
200
|
|
|
110
201
|
**操作**: 将生成的 UI 文档添加到 \`docs/project-context.md\` 中
|
|
111
202
|
|
|
@@ -113,17 +204,17 @@ const PROMPT_TEMPLATE = `# 快速开始
|
|
|
113
204
|
在 "## 📚 文档导航" 部分添加:
|
|
114
205
|
|
|
115
206
|
\`\`\`markdown
|
|
116
|
-
### [UI 设计系统](./design-system.md)
|
|
117
|
-
项目的 UI 设计规范,包括颜色、字体、组件样式等
|
|
118
|
-
|
|
119
|
-
### [UI 组件目录](./component-catalog.json)
|
|
120
|
-
可用的 UI 组件及其属性定义
|
|
207
|
+
### [UI 设计系统](./design-system.md)
|
|
208
|
+
项目的 UI 设计规范,包括颜色、字体、组件样式等
|
|
209
|
+
|
|
210
|
+
### [UI 组件目录](./ui/component-catalog.json)
|
|
211
|
+
可用的 UI 组件及其属性定义
|
|
121
212
|
\`\`\`
|
|
122
213
|
|
|
123
214
|
在 "## 💡 开发时查看对应文档" 部分的 "添加新功能" 下添加:
|
|
124
215
|
\`\`\`markdown
|
|
125
216
|
- **UI 设计系统**: [design-system.md](./design-system.md) - 查看设计规范
|
|
126
|
-
- **UI 组件目录**: [component-catalog.json](./component-catalog.json) - 查看可用组件
|
|
217
|
+
- **UI 组件目录**: [ui/component-catalog.json](./ui/component-catalog.json) - 查看可用组件
|
|
127
218
|
\`\`\`
|
|
128
219
|
|
|
129
220
|
**预期结果**: \`docs/project-context.md\` 包含 UI 相关文档的链接
|
|
@@ -137,7 +228,7 @@ const PROMPT_TEMPLATE = `# 快速开始
|
|
|
137
228
|
编辑 \`docs/design-system.json\` 修改颜色、字体等,然后重新运行。
|
|
138
229
|
|
|
139
230
|
### 自定义组件
|
|
140
|
-
编辑 \`docs/component-catalog.json\` 添加新组件定义。
|
|
231
|
+
编辑 \`docs/ui/component-catalog.json\` 添加新组件定义。
|
|
141
232
|
|
|
142
233
|
### 常见问题
|
|
143
234
|
|
|
@@ -147,6 +238,161 @@ A: 不需要。如果文件已存在,直接跳过步骤 1。
|
|
|
147
238
|
**Q: 如何使用自定义模板?**
|
|
148
239
|
A: 在 \`docs/ui/\` 目录创建 JSON 模板文件,然后在步骤 4 中指定模板路径。
|
|
149
240
|
`;
|
|
241
|
+
const PROMPT_TEMPLATE_STRICT = `# UI 开发编排(严格)
|
|
242
|
+
|
|
243
|
+
**职责说明**: 本工具仅提供执行指导,不执行实际操作。请按顺序调用以下 MCP 工具。
|
|
244
|
+
|
|
245
|
+
## ✅ 执行计划
|
|
246
|
+
|
|
247
|
+
1. 检查 \`docs/project-context.md\`,缺失则调用 \`init_project_context\`
|
|
248
|
+
2. 检查 \`docs/design-system.md\`,缺失则调用 \`ui_design_system --product_type="{productType}" --stack="{framework}"\`
|
|
249
|
+
3. 检查 \`docs/ui/component-catalog.json\`,缺失则调用 \`init_component_catalog\`
|
|
250
|
+
4. \`ui_search --mode=template --query="{description}"\`
|
|
251
|
+
5. 选择模板并保存到 \`docs/ui/{templateName}.json\`
|
|
252
|
+
6. \`render_ui --template="docs/ui/{templateName}.json" --framework="{framework}"\`
|
|
253
|
+
7. 将生成的 UI 文档添加到 \`docs/project-context.md\` 索引中
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## 步骤 1: 生成项目上下文(如不存在)
|
|
258
|
+
|
|
259
|
+
**检查**: \`docs/project-context.md\`
|
|
260
|
+
**缺失则调用**: \`init_project_context\`
|
|
261
|
+
**预期输出**: \`docs/project-context.md\`
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## 步骤 2: 生成设计系统(如不存在)
|
|
266
|
+
|
|
267
|
+
**检查**: \`docs/design-system.md\`
|
|
268
|
+
**缺失则调用**: \`ui_design_system\`
|
|
269
|
+
\`\`\`json
|
|
270
|
+
{
|
|
271
|
+
"product_type": "{productType}",
|
|
272
|
+
"stack": "{framework}",
|
|
273
|
+
"description": "{description}"
|
|
274
|
+
}
|
|
275
|
+
\`\`\`
|
|
276
|
+
**预期输出**: \`docs/design-system.json\`、\`docs/design-system.md\`
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## 步骤 3: 生成组件目录(如不存在)
|
|
281
|
+
|
|
282
|
+
**检查**: \`docs/ui/component-catalog.json\`
|
|
283
|
+
**缺失则调用**: \`init_component_catalog\`
|
|
284
|
+
**预期输出**: \`docs/ui/component-catalog.json\`
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## 步骤 4: 搜索模板
|
|
289
|
+
|
|
290
|
+
**工具**: \`ui_search\`
|
|
291
|
+
\`\`\`json
|
|
292
|
+
{ "mode": "template", "query": "{description}" }
|
|
293
|
+
\`\`\`
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## 步骤 5: 保存模板文件
|
|
298
|
+
|
|
299
|
+
**操作**: 从搜索结果选择模板或创建最小模板
|
|
300
|
+
|
|
301
|
+
**保存路径**: \`docs/ui/{templateName}.json\`
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## 步骤 6: 渲染代码
|
|
306
|
+
|
|
307
|
+
**工具**: \`render_ui\`
|
|
308
|
+
\`\`\`json
|
|
309
|
+
{ "template": "docs/ui/{templateName}.json", "framework": "{framework}" }
|
|
310
|
+
\`\`\`
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## 步骤 7: 更新项目上下文索引
|
|
315
|
+
|
|
316
|
+
将 UI 文档链接添加到 \`docs/project-context.md\`
|
|
317
|
+
`;
|
|
318
|
+
const LOOP_PROMPT_TEMPLATE_GUIDED = `# 🧭 UI 需求澄清与补全(Requirements Loop)
|
|
319
|
+
|
|
320
|
+
本模式用于**生产级稳健补全**:在不改变用户意图的前提下补齐 UI 需求关键要素。
|
|
321
|
+
|
|
322
|
+
## 🎯 目标
|
|
323
|
+
UI 需求:{description}
|
|
324
|
+
|
|
325
|
+
## ✅ 规则
|
|
326
|
+
1. **不覆盖用户原始描述**
|
|
327
|
+
2. **补全内容必须标注来源**(User / Derived / Assumption)
|
|
328
|
+
3. **假设必须进入待确认列表**
|
|
329
|
+
4. **每轮问题 ≤ {question_budget},假设 ≤ {assumption_cap}**
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## 🔁 执行步骤(每轮)
|
|
334
|
+
|
|
335
|
+
### 1) 生成待确认问题
|
|
336
|
+
使用 \`ask_user\` 提问,问题来源于 UI 需求补全清单(目标/交互/状态/设备/可访问性)。
|
|
337
|
+
|
|
338
|
+
### 2) 更新结构化输出
|
|
339
|
+
将回答补入 \`requirements\`,并标注来源。
|
|
340
|
+
|
|
341
|
+
### 3) 自检与结束
|
|
342
|
+
若 \`openQuestions\` 为空且无高风险假设,则结束 loop,进入 UI 执行计划。
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
## ✅ 结束后继续
|
|
347
|
+
当满足结束条件时,按 delegated plan 执行:
|
|
348
|
+
- 设计系统 → 组件目录 → 模板搜索 → 保存模板 → 渲染代码 → 更新上下文
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
*编排工具: MCP Probe Kit - start_ui (requirements loop)*
|
|
353
|
+
`;
|
|
354
|
+
const LOOP_PROMPT_TEMPLATE_STRICT = `# 🧭 UI 需求澄清与补全(Requirements Loop | 严格)
|
|
355
|
+
|
|
356
|
+
本模式用于稳健补全 UI 需求关键要素,不改变用户意图。
|
|
357
|
+
|
|
358
|
+
## 🎯 目标
|
|
359
|
+
UI 需求:{description}
|
|
360
|
+
|
|
361
|
+
## ✅ 规则
|
|
362
|
+
1. 不覆盖用户原始描述
|
|
363
|
+
2. 补全内容必须标注来源(User / Derived / Assumption)
|
|
364
|
+
3. 假设必须进入待确认列表
|
|
365
|
+
4. 每轮问题 ≤ {question_budget},假设 ≤ {assumption_cap}
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
## 🔁 执行步骤(每轮)
|
|
370
|
+
1) 使用 \`ask_user\` 提问补全关键信息
|
|
371
|
+
2) 更新结构化输出并标注来源
|
|
372
|
+
3) 若 \`openQuestions\` 为空且无高风险假设则结束
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
## ✅ 结束后继续
|
|
377
|
+
当满足结束条件时,按 delegated plan 执行 UI 计划
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
*编排工具: MCP Probe Kit - start_ui (requirements loop)*
|
|
382
|
+
`;
|
|
383
|
+
function buildUiQuestions(questionBudget) {
|
|
384
|
+
const base = [
|
|
385
|
+
{ question: "页面目标是什么?用户需要完成什么任务?", context: "页面目标", required: true },
|
|
386
|
+
{ question: "核心功能与交互有哪些?", context: "核心交互", required: true },
|
|
387
|
+
{ question: "需要哪些状态(加载/空态/错误)?", context: "关键状态", required: true },
|
|
388
|
+
{ question: "数据来源与刷新频率是什么?", context: "数据来源", required: true },
|
|
389
|
+
{ question: "权限/可见性规则有哪些?", context: "权限规则", required: false },
|
|
390
|
+
{ question: "需要适配哪些设备/分辨率?", context: "响应式", required: false },
|
|
391
|
+
{ question: "是否有特定风格/品牌约束?", context: "视觉约束", required: false },
|
|
392
|
+
{ question: "可访问性要求有哪些?", context: "可访问性", required: false },
|
|
393
|
+
];
|
|
394
|
+
return base.slice(0, Math.max(0, questionBudget));
|
|
395
|
+
}
|
|
150
396
|
/**
|
|
151
397
|
* 从 project-context.md 读取框架信息
|
|
152
398
|
*/
|
|
@@ -218,6 +464,11 @@ export async function startUi(args) {
|
|
|
218
464
|
framework: detectedFramework, // 使用检测到的框架
|
|
219
465
|
template: "",
|
|
220
466
|
mode: "manual",
|
|
467
|
+
template_profile: "auto",
|
|
468
|
+
requirements_mode: "steady",
|
|
469
|
+
loop_max_rounds: 2,
|
|
470
|
+
loop_question_budget: 5,
|
|
471
|
+
loop_assumption_cap: 3,
|
|
221
472
|
},
|
|
222
473
|
primaryField: "description",
|
|
223
474
|
fieldAliases: {
|
|
@@ -225,12 +476,44 @@ export async function startUi(args) {
|
|
|
225
476
|
framework: ["stack", "lib", "框架"],
|
|
226
477
|
template: ["name", "模板名"],
|
|
227
478
|
mode: ["模式"],
|
|
479
|
+
template_profile: ["profile", "template_profile", "模板档位", "模板模式"],
|
|
480
|
+
requirements_mode: ["requirements_mode", "loop", "需求模式"],
|
|
481
|
+
loop_max_rounds: ["max_rounds", "rounds", "最大轮次"],
|
|
482
|
+
loop_question_budget: ["question_budget", "问题数量", "问题预算"],
|
|
483
|
+
loop_assumption_cap: ["assumption_cap", "假设上限"],
|
|
228
484
|
},
|
|
229
485
|
});
|
|
230
486
|
const description = getString(parsedArgs.description);
|
|
487
|
+
const productType = inferProductType(description);
|
|
231
488
|
const framework = getString(parsedArgs.framework) || detectedFramework;
|
|
232
489
|
const mode = getString(parsedArgs.mode) || "manual";
|
|
490
|
+
const rawProfile = getString(parsedArgs.template_profile);
|
|
491
|
+
const requirementsMode = getString(parsedArgs.requirements_mode) || "steady";
|
|
492
|
+
const maxRounds = getNumber(parsedArgs.loop_max_rounds, 2);
|
|
493
|
+
const questionBudget = getNumber(parsedArgs.loop_question_budget, 5);
|
|
494
|
+
const assumptionCap = getNumber(parsedArgs.loop_assumption_cap, 3);
|
|
233
495
|
let templateName = getString(parsedArgs.template);
|
|
496
|
+
templateName = normalizeTemplateName(templateName || description || 'ui-template', 'ui-template');
|
|
497
|
+
const profileDecision = resolveTemplateProfile(rawProfile, description || "");
|
|
498
|
+
const templateMeta = {
|
|
499
|
+
profile: profileDecision.resolved,
|
|
500
|
+
requested: profileDecision.requested,
|
|
501
|
+
};
|
|
502
|
+
if (profileDecision.reason) {
|
|
503
|
+
templateMeta.reason = profileDecision.reason;
|
|
504
|
+
}
|
|
505
|
+
if (profileDecision.warning) {
|
|
506
|
+
templateMeta.warning = profileDecision.warning;
|
|
507
|
+
}
|
|
508
|
+
const headerNotes = [
|
|
509
|
+
`模板档位: ${profileDecision.resolved}${profileDecision.requested === 'auto' ? '(自动)' : ''}`,
|
|
510
|
+
];
|
|
511
|
+
if (profileDecision.reason) {
|
|
512
|
+
headerNotes.push(`选择理由: ${profileDecision.reason}`);
|
|
513
|
+
}
|
|
514
|
+
if (profileDecision.warning) {
|
|
515
|
+
headerNotes.push(profileDecision.warning);
|
|
516
|
+
}
|
|
234
517
|
// 验证 mode 参数
|
|
235
518
|
const validModes = ["auto", "manual"];
|
|
236
519
|
if (mode && !validModes.includes(mode)) {
|
|
@@ -253,14 +536,174 @@ start_ui "用户列表" --mode=auto
|
|
|
253
536
|
isError: true,
|
|
254
537
|
};
|
|
255
538
|
}
|
|
539
|
+
// requirements loop 模式
|
|
540
|
+
if (requirementsMode === "loop") {
|
|
541
|
+
if (!description) {
|
|
542
|
+
return {
|
|
543
|
+
content: [
|
|
544
|
+
{
|
|
545
|
+
type: "text",
|
|
546
|
+
text: `❌ 缺少必要参数
|
|
547
|
+
|
|
548
|
+
**用法**:
|
|
549
|
+
\`\`\`
|
|
550
|
+
start_ui <描述> --requirements_mode=loop
|
|
551
|
+
\`\`\``,
|
|
552
|
+
},
|
|
553
|
+
],
|
|
554
|
+
isError: true,
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
const openQuestions = buildUiQuestions(questionBudget).map((q, index) => ({
|
|
558
|
+
id: `Q-${index + 1}`,
|
|
559
|
+
...q,
|
|
560
|
+
}));
|
|
561
|
+
const requirements = [
|
|
562
|
+
{
|
|
563
|
+
id: "UI-1",
|
|
564
|
+
title: description,
|
|
565
|
+
description: description,
|
|
566
|
+
source: "User",
|
|
567
|
+
acceptance: [
|
|
568
|
+
"WHEN 页面加载 THEN 系统 SHALL 展示加载状态",
|
|
569
|
+
"IF 无数据 THEN 系统 SHALL 展示空态且提示原因",
|
|
570
|
+
],
|
|
571
|
+
},
|
|
572
|
+
];
|
|
573
|
+
const assumptions = [];
|
|
574
|
+
const missingFields = openQuestions.map((q) => q.context || q.question);
|
|
575
|
+
const stopReady = openQuestions.length === 0 && assumptions.length === 0;
|
|
576
|
+
const plan = {
|
|
577
|
+
mode: 'delegated',
|
|
578
|
+
steps: [
|
|
579
|
+
{
|
|
580
|
+
id: 'loop-1',
|
|
581
|
+
tool: 'ask_user',
|
|
582
|
+
args: { questions: openQuestions.map(({ question, context, required }) => ({ question, context, required })) },
|
|
583
|
+
outputs: [],
|
|
584
|
+
},
|
|
585
|
+
...(maxRounds > 1
|
|
586
|
+
? [
|
|
587
|
+
{
|
|
588
|
+
id: 'loop-2',
|
|
589
|
+
tool: 'ask_user',
|
|
590
|
+
when: '仍存在 openQuestions 或 assumptions',
|
|
591
|
+
args: { questions: '[根据上一轮补全结果生成问题]' },
|
|
592
|
+
outputs: [],
|
|
593
|
+
},
|
|
594
|
+
]
|
|
595
|
+
: []),
|
|
596
|
+
{
|
|
597
|
+
id: 'context',
|
|
598
|
+
tool: 'init_project_context',
|
|
599
|
+
when: '缺少 docs/project-context.md',
|
|
600
|
+
args: {},
|
|
601
|
+
outputs: ['docs/project-context.md'],
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
id: 'design-system',
|
|
605
|
+
tool: 'ui_design_system',
|
|
606
|
+
when: '缺少 docs/design-system.json 或 docs/design-system.md',
|
|
607
|
+
args: {
|
|
608
|
+
product_type: productType,
|
|
609
|
+
stack: framework,
|
|
610
|
+
description,
|
|
611
|
+
},
|
|
612
|
+
outputs: ['docs/design-system.json', 'docs/design-system.md'],
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
id: 'catalog',
|
|
616
|
+
tool: 'init_component_catalog',
|
|
617
|
+
when: '缺少 docs/ui/component-catalog.json',
|
|
618
|
+
args: {},
|
|
619
|
+
outputs: ['docs/ui/component-catalog.json'],
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
id: 'template',
|
|
623
|
+
tool: 'ui_search',
|
|
624
|
+
args: { mode: 'template', query: description },
|
|
625
|
+
outputs: [],
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
id: 'save-template',
|
|
629
|
+
tool: 'manual',
|
|
630
|
+
action: 'save_ui_template',
|
|
631
|
+
outputs: [`docs/ui/${templateName}.json`],
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
id: 'render',
|
|
635
|
+
tool: 'render_ui',
|
|
636
|
+
args: {
|
|
637
|
+
template: `docs/ui/${templateName}.json`,
|
|
638
|
+
framework,
|
|
639
|
+
},
|
|
640
|
+
outputs: [],
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
id: 'update-context',
|
|
644
|
+
tool: 'manual',
|
|
645
|
+
action: 'update_project_context',
|
|
646
|
+
outputs: ['docs/project-context.md'],
|
|
647
|
+
},
|
|
648
|
+
],
|
|
649
|
+
};
|
|
650
|
+
const header = renderOrchestrationHeader({
|
|
651
|
+
tool: 'start_ui',
|
|
652
|
+
goal: `UI 需求:${description}`,
|
|
653
|
+
tasks: [
|
|
654
|
+
'按 Requirements Loop 规则提问并更新结构化输出',
|
|
655
|
+
'满足结束条件后按 delegated plan 执行 UI 计划',
|
|
656
|
+
],
|
|
657
|
+
notes: headerNotes,
|
|
658
|
+
});
|
|
659
|
+
const loopTemplate = profileDecision.resolved === 'strict'
|
|
660
|
+
? LOOP_PROMPT_TEMPLATE_STRICT
|
|
661
|
+
: LOOP_PROMPT_TEMPLATE_GUIDED;
|
|
662
|
+
const guide = header + loopTemplate
|
|
663
|
+
.replace(/{description}/g, description)
|
|
664
|
+
.replace(/{question_budget}/g, String(questionBudget))
|
|
665
|
+
.replace(/{assumption_cap}/g, String(assumptionCap));
|
|
666
|
+
const loopReport = {
|
|
667
|
+
mode: 'loop',
|
|
668
|
+
round: 1,
|
|
669
|
+
maxRounds,
|
|
670
|
+
questionBudget,
|
|
671
|
+
assumptionCap,
|
|
672
|
+
requirements,
|
|
673
|
+
openQuestions,
|
|
674
|
+
assumptions,
|
|
675
|
+
delta: {
|
|
676
|
+
added: ['UI-1'],
|
|
677
|
+
modified: [],
|
|
678
|
+
removed: [],
|
|
679
|
+
},
|
|
680
|
+
validation: {
|
|
681
|
+
passed: stopReady,
|
|
682
|
+
missingFields,
|
|
683
|
+
warnings: [],
|
|
684
|
+
},
|
|
685
|
+
stopConditions: {
|
|
686
|
+
ready: stopReady,
|
|
687
|
+
reasons: stopReady ? ['所有关键问题已确认'] : ['存在待确认问题'],
|
|
688
|
+
},
|
|
689
|
+
metadata: {
|
|
690
|
+
plan,
|
|
691
|
+
template: templateMeta,
|
|
692
|
+
},
|
|
693
|
+
};
|
|
694
|
+
return okStructured(guide, loopReport, {
|
|
695
|
+
schema: RequirementsLoopSchema,
|
|
696
|
+
note: 'AI 应按轮次澄清 UI 需求并更新结构化输出,满足结束条件后再执行 UI 计划',
|
|
697
|
+
});
|
|
698
|
+
}
|
|
256
699
|
// 自动模式实现
|
|
257
700
|
if (mode === "auto") {
|
|
258
701
|
// 1. 获取推理引擎
|
|
259
702
|
const engine = await getReasoningEngine();
|
|
260
703
|
// 2. 构造设计请求
|
|
261
704
|
const request = {
|
|
262
|
-
productType
|
|
263
|
-
description
|
|
705
|
+
productType,
|
|
706
|
+
description,
|
|
264
707
|
stack: framework,
|
|
265
708
|
};
|
|
266
709
|
// 3. 生成推荐
|
|
@@ -270,7 +713,8 @@ start_ui "用户列表" --mode=auto
|
|
|
270
713
|
const inferredKeywords = recommendation.style.keywords.join(", ");
|
|
271
714
|
const inferredStack = framework; // 保持用户指定的技术栈,或默认为 react
|
|
272
715
|
// 5. 生成智能执行计划
|
|
273
|
-
const
|
|
716
|
+
const searchQuery = description || templateName;
|
|
717
|
+
const smartPlanGuided = `# 🚀 智能 UI 开发计划
|
|
274
718
|
|
|
275
719
|
基于您的描述 "**${description}**",AI 引擎已为您规划了最佳开发路径。
|
|
276
720
|
|
|
@@ -302,19 +746,25 @@ ui_design_system --product_type="${inferredProductType}" --stack="${inferredStac
|
|
|
302
746
|
init_component_catalog
|
|
303
747
|
\`\`\`
|
|
304
748
|
|
|
305
|
-
### 4. 生成 UI 模板 📄
|
|
306
|
-
\`\`\`bash
|
|
307
|
-
# 搜索现有模板或生成新模板
|
|
308
|
-
ui_search --mode=template --query="${
|
|
309
|
-
\`\`\`
|
|
310
|
-
|
|
311
|
-
### 5.
|
|
312
|
-
\`\`\`bash
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
749
|
+
### 4. 生成 UI 模板 📄
|
|
750
|
+
\`\`\`bash
|
|
751
|
+
# 搜索现有模板或生成新模板
|
|
752
|
+
ui_search --mode=template --query="${searchQuery}"
|
|
753
|
+
\`\`\`
|
|
754
|
+
|
|
755
|
+
### 5. 保存模板文件 🧩
|
|
756
|
+
\`\`\`bash
|
|
757
|
+
# 将选中的模板保存到本地
|
|
758
|
+
# 目标路径:docs/ui/${templateName}.json
|
|
759
|
+
\`\`\`
|
|
760
|
+
|
|
761
|
+
### 6. 渲染代码 💻
|
|
762
|
+
\`\`\`bash
|
|
763
|
+
render_ui docs/ui/${templateName}.json --framework="${inferredStack}"
|
|
764
|
+
\`\`\`
|
|
765
|
+
|
|
766
|
+
### 7. 更新项目上下文 📝
|
|
767
|
+
将生成的 UI 文档链接添加到 \`docs/project-context.md\` 的文档导航部分。
|
|
318
768
|
|
|
319
769
|
---
|
|
320
770
|
|
|
@@ -322,6 +772,95 @@ render_ui docs/ui/${templateName || 'template'}.json --framework="${inferredStac
|
|
|
322
772
|
|
|
323
773
|
${recommendation.reasoning}
|
|
324
774
|
`;
|
|
775
|
+
const smartPlanStrict = `# 🚀 智能 UI 开发计划(严格)
|
|
776
|
+
|
|
777
|
+
## 🧠 智能分析结果
|
|
778
|
+
|
|
779
|
+
- **产品类型**: ${inferredProductType}
|
|
780
|
+
- **推荐风格**: ${recommendation.style.primary}
|
|
781
|
+
- **关键特性**: ${inferredKeywords}
|
|
782
|
+
- **技术栈**: ${inferredStack}
|
|
783
|
+
|
|
784
|
+
---
|
|
785
|
+
|
|
786
|
+
## 📋 执行步骤
|
|
787
|
+
|
|
788
|
+
1) init_project_context
|
|
789
|
+
2) ui_design_system --product_type="${inferredProductType}" --stack="${inferredStack}" --keywords="${inferredKeywords}" --description="${description}"
|
|
790
|
+
3) init_component_catalog
|
|
791
|
+
4) ui_search --mode=template --query="${searchQuery}"
|
|
792
|
+
5) 保存模板到 docs/ui/${templateName}.json
|
|
793
|
+
6) render_ui docs/ui/${templateName}.json --framework="${inferredStack}"
|
|
794
|
+
7) 更新 project-context.md 索引
|
|
795
|
+
`;
|
|
796
|
+
const plan = {
|
|
797
|
+
mode: 'delegated',
|
|
798
|
+
steps: [
|
|
799
|
+
{
|
|
800
|
+
id: 'context',
|
|
801
|
+
tool: 'init_project_context',
|
|
802
|
+
when: '缺少 docs/project-context.md',
|
|
803
|
+
args: {},
|
|
804
|
+
outputs: ['docs/project-context.md'],
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
id: 'design-system',
|
|
808
|
+
tool: 'ui_design_system',
|
|
809
|
+
when: '缺少 docs/design-system.json 或 docs/design-system.md',
|
|
810
|
+
args: {
|
|
811
|
+
product_type: inferredProductType,
|
|
812
|
+
stack: inferredStack,
|
|
813
|
+
keywords: inferredKeywords,
|
|
814
|
+
description,
|
|
815
|
+
},
|
|
816
|
+
outputs: ['docs/design-system.json', 'docs/design-system.md'],
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
id: 'catalog',
|
|
820
|
+
tool: 'init_component_catalog',
|
|
821
|
+
when: '缺少 docs/ui/component-catalog.json',
|
|
822
|
+
args: {},
|
|
823
|
+
outputs: ['docs/ui/component-catalog.json'],
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
id: 'template',
|
|
827
|
+
tool: 'ui_search',
|
|
828
|
+
args: { mode: 'template', query: searchQuery },
|
|
829
|
+
outputs: [],
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
id: 'save-template',
|
|
833
|
+
tool: 'manual',
|
|
834
|
+
action: 'save_ui_template',
|
|
835
|
+
outputs: [`docs/ui/${templateName}.json`],
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
id: 'render',
|
|
839
|
+
tool: 'render_ui',
|
|
840
|
+
args: {
|
|
841
|
+
template: `docs/ui/${templateName}.json`,
|
|
842
|
+
framework: inferredStack,
|
|
843
|
+
},
|
|
844
|
+
outputs: [],
|
|
845
|
+
},
|
|
846
|
+
{
|
|
847
|
+
id: 'update-context',
|
|
848
|
+
tool: 'manual',
|
|
849
|
+
action: 'update_project_context',
|
|
850
|
+
outputs: ['docs/project-context.md'],
|
|
851
|
+
},
|
|
852
|
+
],
|
|
853
|
+
};
|
|
854
|
+
const header = renderOrchestrationHeader({
|
|
855
|
+
tool: 'start_ui',
|
|
856
|
+
goal: `UI 需求:${description}`,
|
|
857
|
+
tasks: [
|
|
858
|
+
'按 delegated plan 顺序调用工具',
|
|
859
|
+
'生成设计系统、模板并渲染 UI 代码',
|
|
860
|
+
],
|
|
861
|
+
notes: headerNotes,
|
|
862
|
+
});
|
|
863
|
+
const smartPlan = header + (profileDecision.resolved === 'strict' ? smartPlanStrict : smartPlanGuided);
|
|
325
864
|
// Create structured UI report for auto mode
|
|
326
865
|
const uiReport = {
|
|
327
866
|
summary: `智能 UI 开发:${description}`,
|
|
@@ -347,6 +886,11 @@ ${recommendation.reasoning}
|
|
|
347
886
|
status: 'pending',
|
|
348
887
|
description: '调用 ui_search 搜索匹配的模板',
|
|
349
888
|
},
|
|
889
|
+
{
|
|
890
|
+
name: '保存模板文件',
|
|
891
|
+
status: 'pending',
|
|
892
|
+
description: `将模板保存为 docs/ui/${templateName}.json`,
|
|
893
|
+
},
|
|
350
894
|
{
|
|
351
895
|
name: '渲染最终代码',
|
|
352
896
|
status: 'pending',
|
|
@@ -364,6 +908,7 @@ ${recommendation.reasoning}
|
|
|
364
908
|
`调用 ui_design_system --product_type="${inferredProductType}" --stack="${inferredStack}"`,
|
|
365
909
|
'调用 init_component_catalog',
|
|
366
910
|
`调用 ui_search --mode=template --query="${description}"`,
|
|
911
|
+
`保存模板到 docs/ui/${templateName}.json`,
|
|
367
912
|
`调用 render_ui --framework="${inferredStack}"`,
|
|
368
913
|
'更新 docs/project-context.md 添加 UI 文档链接',
|
|
369
914
|
],
|
|
@@ -381,24 +926,16 @@ ${recommendation.reasoning}
|
|
|
381
926
|
'所有组件使用设计系统中定义的字体',
|
|
382
927
|
'所有组件使用设计系统中定义的间距',
|
|
383
928
|
],
|
|
929
|
+
metadata: {
|
|
930
|
+
plan,
|
|
931
|
+
template: templateMeta,
|
|
932
|
+
},
|
|
384
933
|
};
|
|
385
934
|
return okStructured(smartPlan, uiReport, {
|
|
386
935
|
schema: UIReportSchema,
|
|
387
936
|
note: 'AI 应该按照智能计划执行步骤,并在每个步骤完成后更新 structuredContent',
|
|
388
937
|
});
|
|
389
938
|
}
|
|
390
|
-
// 如果没有提供模板名,从描述中生成
|
|
391
|
-
if (!templateName && description) {
|
|
392
|
-
// 简单的命名转换:登录页面 → login-page
|
|
393
|
-
// 移除特殊字符,只保留字母、数字、中文和连字符
|
|
394
|
-
templateName = description
|
|
395
|
-
.toLowerCase()
|
|
396
|
-
.replace(/页面|表单|组件/g, '')
|
|
397
|
-
.trim()
|
|
398
|
-
.replace(/[^\w\u4e00-\u9fa5-]/g, '-')
|
|
399
|
-
.replace(/-+/g, '-')
|
|
400
|
-
.replace(/^-|-$/g, '');
|
|
401
|
-
}
|
|
402
939
|
if (!description) {
|
|
403
940
|
return {
|
|
404
941
|
content: [
|
|
@@ -440,10 +977,80 @@ start_ui "设置页面" --framework=react
|
|
|
440
977
|
const safeReplace = (template, placeholder, value) => {
|
|
441
978
|
return template.split(placeholder).join(value);
|
|
442
979
|
};
|
|
443
|
-
|
|
980
|
+
const header = renderOrchestrationHeader({
|
|
981
|
+
tool: 'start_ui',
|
|
982
|
+
goal: `UI 需求:${description}`,
|
|
983
|
+
tasks: [
|
|
984
|
+
'按 delegated plan 顺序调用工具',
|
|
985
|
+
'生成设计系统、模板并渲染 UI 代码',
|
|
986
|
+
],
|
|
987
|
+
notes: headerNotes,
|
|
988
|
+
});
|
|
989
|
+
const baseTemplate = profileDecision.resolved === 'strict'
|
|
990
|
+
? PROMPT_TEMPLATE_STRICT
|
|
991
|
+
: PROMPT_TEMPLATE_GUIDED;
|
|
992
|
+
let guide = header + baseTemplate;
|
|
444
993
|
guide = safeReplace(guide, '{description}', escapeJson(description));
|
|
994
|
+
guide = safeReplace(guide, '{productType}', productType);
|
|
445
995
|
guide = safeReplace(guide, '{framework}', framework);
|
|
446
|
-
guide = safeReplace(guide, '{templateName}', templateName
|
|
996
|
+
guide = safeReplace(guide, '{templateName}', templateName);
|
|
997
|
+
const plan = {
|
|
998
|
+
mode: 'delegated',
|
|
999
|
+
steps: [
|
|
1000
|
+
{
|
|
1001
|
+
id: 'context',
|
|
1002
|
+
tool: 'init_project_context',
|
|
1003
|
+
when: '缺少 docs/project-context.md',
|
|
1004
|
+
args: {},
|
|
1005
|
+
outputs: ['docs/project-context.md'],
|
|
1006
|
+
},
|
|
1007
|
+
{
|
|
1008
|
+
id: 'design-system',
|
|
1009
|
+
tool: 'ui_design_system',
|
|
1010
|
+
when: '缺少 docs/design-system.json 或 docs/design-system.md',
|
|
1011
|
+
args: {
|
|
1012
|
+
product_type: productType,
|
|
1013
|
+
stack: framework,
|
|
1014
|
+
description,
|
|
1015
|
+
},
|
|
1016
|
+
outputs: ['docs/design-system.json', 'docs/design-system.md'],
|
|
1017
|
+
},
|
|
1018
|
+
{
|
|
1019
|
+
id: 'catalog',
|
|
1020
|
+
tool: 'init_component_catalog',
|
|
1021
|
+
when: '缺少 docs/ui/component-catalog.json',
|
|
1022
|
+
args: {},
|
|
1023
|
+
outputs: ['docs/ui/component-catalog.json'],
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
id: 'template',
|
|
1027
|
+
tool: 'ui_search',
|
|
1028
|
+
args: { mode: 'template', query: description },
|
|
1029
|
+
outputs: [],
|
|
1030
|
+
},
|
|
1031
|
+
{
|
|
1032
|
+
id: 'save-template',
|
|
1033
|
+
tool: 'manual',
|
|
1034
|
+
action: 'save_ui_template',
|
|
1035
|
+
outputs: [`docs/ui/${templateName}.json`],
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
id: 'render',
|
|
1039
|
+
tool: 'render_ui',
|
|
1040
|
+
args: {
|
|
1041
|
+
template: `docs/ui/${templateName}.json`,
|
|
1042
|
+
framework,
|
|
1043
|
+
},
|
|
1044
|
+
outputs: [],
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
id: 'update-context',
|
|
1048
|
+
tool: 'manual',
|
|
1049
|
+
action: 'update_project_context',
|
|
1050
|
+
outputs: ['docs/project-context.md'],
|
|
1051
|
+
},
|
|
1052
|
+
],
|
|
1053
|
+
};
|
|
447
1054
|
// Create structured UI report for manual mode
|
|
448
1055
|
const uiReport = {
|
|
449
1056
|
summary: `UI 开发工作流:${description}`,
|
|
@@ -462,13 +1069,18 @@ start_ui "设置页面" --framework=react
|
|
|
462
1069
|
{
|
|
463
1070
|
name: '检查组件目录',
|
|
464
1071
|
status: 'pending',
|
|
465
|
-
description: '检查 docs/component-catalog.json 是否存在',
|
|
1072
|
+
description: '检查 docs/ui/component-catalog.json 是否存在',
|
|
466
1073
|
},
|
|
467
1074
|
{
|
|
468
1075
|
name: '搜索 UI 模板',
|
|
469
1076
|
status: 'pending',
|
|
470
1077
|
description: '调用 ui_search 搜索匹配的模板',
|
|
471
1078
|
},
|
|
1079
|
+
{
|
|
1080
|
+
name: '保存模板文件',
|
|
1081
|
+
status: 'pending',
|
|
1082
|
+
description: `将模板保存为 docs/ui/${templateName}.json`,
|
|
1083
|
+
},
|
|
472
1084
|
{
|
|
473
1085
|
name: '渲染最终代码',
|
|
474
1086
|
status: 'pending',
|
|
@@ -486,6 +1098,7 @@ start_ui "设置页面" --framework=react
|
|
|
486
1098
|
'检查设计系统文件,如不存在则调用 ui_design_system',
|
|
487
1099
|
'检查组件目录,如不存在则调用 init_component_catalog',
|
|
488
1100
|
`调用 ui_search --mode=template --query="${description}"`,
|
|
1101
|
+
`保存模板到 docs/ui/${templateName}.json`,
|
|
489
1102
|
`调用 render_ui --framework="${framework}"`,
|
|
490
1103
|
'更新 docs/project-context.md 添加 UI 文档链接',
|
|
491
1104
|
],
|
|
@@ -503,6 +1116,10 @@ start_ui "设置页面" --framework=react
|
|
|
503
1116
|
'所有组件使用设计系统中定义的字体',
|
|
504
1117
|
'所有组件使用设计系统中定义的间距',
|
|
505
1118
|
],
|
|
1119
|
+
metadata: {
|
|
1120
|
+
plan,
|
|
1121
|
+
template: templateMeta,
|
|
1122
|
+
},
|
|
506
1123
|
};
|
|
507
1124
|
return okStructured(guide, uiReport, {
|
|
508
1125
|
schema: UIReportSchema,
|