mcp-probe-kit 1.15.1 → 2.0.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 +113 -1642
- package/build/index.js +75 -42
- package/build/lib/elicitation-helper.d.ts +73 -0
- package/build/lib/elicitation-helper.js +130 -0
- package/build/lib/response.d.ts +32 -0
- package/build/lib/response.js +28 -0
- package/build/lib/tasks-manager.d.ts +116 -0
- package/build/lib/tasks-manager.js +217 -0
- package/build/lib/toolset-manager.d.ts +48 -0
- package/build/lib/toolset-manager.js +112 -0
- package/build/schemas/basic-tools.d.ts +0 -32
- package/build/schemas/basic-tools.js +0 -34
- package/build/schemas/code-analysis-tools.d.ts +0 -36
- package/build/schemas/code-analysis-tools.js +0 -38
- package/build/schemas/code-gen-tools.d.ts +0 -44
- package/build/schemas/code-gen-tools.js +0 -46
- package/build/schemas/doc-util-tools.d.ts +0 -54
- package/build/schemas/doc-util-tools.js +0 -58
- package/build/schemas/index.d.ts +0 -188
- package/build/schemas/orchestration-tools.d.ts +0 -22
- package/build/schemas/orchestration-tools.js +0 -23
- package/build/schemas/output/core-tools.d.ts +817 -0
- package/build/schemas/output/core-tools.js +421 -0
- package/build/schemas/output/generation-tools.d.ts +936 -0
- package/build/schemas/output/generation-tools.js +446 -0
- package/build/schemas/output/helper-tools.d.ts +243 -0
- package/build/schemas/output/helper-tools.js +138 -0
- package/build/schemas/output/index.d.ts +76 -0
- package/build/schemas/output/index.js +96 -0
- package/build/schemas/output/project-tools.d.ts +702 -0
- package/build/schemas/output/project-tools.js +339 -0
- package/build/schemas/output/ui-ux-tools.d.ts +469 -0
- package/build/schemas/output/ui-ux-tools.js +218 -0
- package/build/schemas/output/workflow-tools.d.ts +267 -0
- package/build/schemas/output/workflow-tools.js +179 -0
- package/build/schemas/structured-output.d.ts +1317 -0
- package/build/schemas/structured-output.js +1017 -0
- package/build/tools/__tests__/start_ui.integration.test.js +5 -5
- package/build/tools/__tests__/start_ui.property.test.js +11 -11
- package/build/tools/add_feature.d.ts +1 -13
- package/build/tools/add_feature.js +48 -13
- package/build/tools/analyze_project.js +57 -18
- package/build/tools/check_deps.d.ts +1 -13
- package/build/tools/check_deps.js +24 -15
- package/build/tools/code_review.d.ts +1 -13
- package/build/tools/code_review.js +19 -16
- package/build/tools/debug.d.ts +1 -13
- package/build/tools/debug.js +18 -16
- package/build/tools/estimate.d.ts +1 -19
- package/build/tools/estimate.js +36 -6
- package/build/tools/fix_bug.d.ts +1 -13
- package/build/tools/fix_bug.js +24 -6
- package/build/tools/gen_mock.d.ts +1 -19
- package/build/tools/gen_mock.js +42 -227
- package/build/tools/genapi.d.ts +1 -13
- package/build/tools/genapi.js +18 -15
- package/build/tools/genchangelog.d.ts +1 -13
- package/build/tools/genchangelog.js +36 -212
- package/build/tools/gencommit.d.ts +1 -7
- package/build/tools/gencommit.js +21 -13
- package/build/tools/gendoc.d.ts +1 -13
- package/build/tools/gendoc.js +18 -15
- package/build/tools/genpr.d.ts +1 -13
- package/build/tools/genpr.js +28 -157
- package/build/tools/genreadme.d.ts +1 -13
- package/build/tools/genreadme.js +22 -587
- package/build/tools/gensql.d.ts +1 -13
- package/build/tools/gensql.js +24 -283
- package/build/tools/gentest.d.ts +1 -13
- package/build/tools/gentest.js +49 -16
- package/build/tools/index.d.ts +0 -10
- package/build/tools/index.js +0 -10
- package/build/tools/init_component_catalog.d.ts +3 -20
- package/build/tools/init_component_catalog.js +141 -786
- package/build/tools/init_project.d.ts +7 -13
- package/build/tools/init_project.js +54 -16
- package/build/tools/init_project_context.d.ts +1 -13
- package/build/tools/init_project_context.js +41 -14
- package/build/tools/perf.d.ts +1 -13
- package/build/tools/perf.js +18 -15
- package/build/tools/refactor.d.ts +1 -13
- package/build/tools/refactor.js +54 -15
- package/build/tools/render_ui.d.ts +2 -19
- package/build/tools/render_ui.js +201 -347
- package/build/tools/resolve_conflict.d.ts +1 -13
- package/build/tools/resolve_conflict.js +18 -15
- package/build/tools/security_scan.d.ts +1 -13
- package/build/tools/security_scan.js +16 -5
- package/build/tools/start_api.d.ts +7 -13
- package/build/tools/start_api.js +69 -157
- package/build/tools/start_bugfix.d.ts +1 -7
- package/build/tools/start_bugfix.js +38 -2
- package/build/tools/start_doc.d.ts +7 -13
- package/build/tools/start_doc.js +76 -169
- package/build/tools/start_feature.d.ts +1 -7
- package/build/tools/start_feature.js +54 -2
- package/build/tools/start_onboard.d.ts +1 -7
- package/build/tools/start_onboard.js +40 -2
- package/build/tools/start_ralph.d.ts +1 -7
- package/build/tools/start_ralph.js +88 -2
- package/build/tools/start_refactor.d.ts +7 -13
- package/build/tools/start_refactor.js +75 -148
- package/build/tools/start_release.d.ts +7 -13
- package/build/tools/start_release.js +56 -131
- package/build/tools/start_review.d.ts +7 -13
- package/build/tools/start_review.js +70 -142
- package/build/tools/start_ui.d.ts +1 -7
- package/build/tools/start_ui.js +98 -8
- package/build/tools/ui-ux-tools.d.ts +3 -39
- package/build/tools/ui-ux-tools.js +201 -125
- package/docs/data/tools.js +864 -0
- package/docs/index.html +594 -0
- package/docs/pages/all-tools.html +649 -0
- package/docs/pages/examples.html +564 -0
- package/docs/pages/getting-started.html +529 -0
- package/docs/pages/migration.html +308 -0
- package/docs/specs/algorithm-enhancement/roadmap.md +619 -0
- package/docs/specs/vnext-upgrade/00-OVERVIEW.md +258 -0
- package/docs/specs/vnext-upgrade/BETA_RELEASE_GUIDE.md +328 -0
- package/docs/specs/vnext-upgrade/GITHUB_DISCUSSION_TEMPLATE.md +236 -0
- package/docs/specs/vnext-upgrade/M8.9-PROGRESS-UPDATE.md +248 -0
- package/docs/specs/vnext-upgrade/PROGRESS-SUMMARY.md +195 -0
- package/docs/specs/vnext-upgrade/QUICK_REFERENCE.md +338 -0
- package/docs/specs/vnext-upgrade/README.md +125 -0
- package/docs/specs/vnext-upgrade/STATUS-UPDATE-2026-01-26.md +230 -0
- package/docs/specs/vnext-upgrade/TOOL_CLEANUP.md +343 -0
- package/docs/specs/vnext-upgrade/completed/M1-M2-SUMMARY.md +27 -0
- package/docs/specs/vnext-upgrade/completed/M3_COMPLETION_SUMMARY.md +273 -0
- package/docs/specs/vnext-upgrade/completed/M4-SUMMARY.md +19 -0
- package/docs/specs/vnext-upgrade/completed/M5_COMPLETION_SUMMARY.md +0 -0
- package/docs/specs/vnext-upgrade/completed/M8.1-SUMMARY.md +247 -0
- package/docs/specs/vnext-upgrade/completed/M8.2-SUMMARY.md +296 -0
- package/docs/specs/vnext-upgrade/completed/M8.3-SUMMARY.md +241 -0
- package/docs/specs/vnext-upgrade/completed/M8.3-TEST-SUMMARY.md +216 -0
- package/docs/specs/vnext-upgrade/completed/M8.4-SUMMARY.md +217 -0
- package/docs/specs/vnext-upgrade/completed/M8.4-TEST-SUMMARY.md +198 -0
- package/docs/specs/vnext-upgrade/completed/M8.5-SUMMARY.md +202 -0
- package/docs/specs/vnext-upgrade/completed/M8.5-TEST-SUMMARY.md +223 -0
- package/docs/specs/vnext-upgrade/completed/M8.6-SUMMARY.md +299 -0
- package/docs/specs/vnext-upgrade/completed/M8.8-TEST-SUMMARY.md +216 -0
- package/docs/specs/vnext-upgrade/completed/TOOL-CLEANUP-SUMMARY.md +210 -0
- package/docs/specs/vnext-upgrade/design.md +848 -0
- package/docs/specs/vnext-upgrade/requirements.md +221 -0
- package/docs/specs/vnext-upgrade/tasks/00-INDEX.md +335 -0
- package/docs/specs/vnext-upgrade/tasks/M8.1-SCHEMA-DEFINITION.md +300 -0
- package/docs/specs/vnext-upgrade/tasks/M8.2-P1-TOOLS.md +249 -0
- package/docs/specs/vnext-upgrade/tasks/M8.3-GENERATION-TOOLS.md +49 -0
- package/docs/specs/vnext-upgrade/tasks/M8.4-ORCHESTRATION-TOOLS.md +28 -0
- package/docs/specs/vnext-upgrade/tasks/M8.5-PROJECT-TOOLS.md +29 -0
- package/docs/specs/vnext-upgrade/tasks/M8.6-UI-TOOLS.md +66 -0
- package/docs/specs/vnext-upgrade/tasks/M8.7-HELPER-TOOLS.md +24 -0
- package/docs/specs/vnext-upgrade/tasks/M8.8-INTEGRATION-TESTS.md +90 -0
- package/docs/specs/vnext-upgrade/tasks/M8.9-DOCUMENTATION.md +103 -0
- package/docs/styles/docs.css +556 -0
- package/docs/styles/page.css +815 -0
- package/docs/vnext/MCP_2025-11-25_GUIDE.md +276 -0
- package/docs/vnext/vNext-PRD.md +488 -0
- package/package.json +6 -6
- package/docs/BEST_PRACTICES.md +0 -1185
- package/docs/HOW_TO_TRIGGER.md +0 -1141
- package/docs/MCP-Probe-Kit-/344/275/277/347/224/250/346/211/213/345/206/214.html +0 -544
- package/docs/MCP-Probe-Kit-/344/275/277/347/224/250/346/211/213/345/206/214.md +0 -1447
package/build/tools/render_ui.js
CHANGED
|
@@ -1,384 +1,238 @@
|
|
|
1
|
+
import { okStructured } from "../lib/response.js";
|
|
1
2
|
/**
|
|
2
|
-
* UI
|
|
3
|
-
*
|
|
3
|
+
* UI 渲染引擎(内部工具)
|
|
4
4
|
* 将 JSON 模板渲染为最终代码
|
|
5
|
-
* 自动应用设计规范,确保样式统一
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
export async function renderUi(args) {
|
|
7
|
+
try {
|
|
8
|
+
const fs = await import('fs/promises');
|
|
9
|
+
const path = await import('path');
|
|
10
|
+
const templatePath = args.template;
|
|
11
|
+
const framework = args.framework || 'react';
|
|
12
|
+
if (!templatePath) {
|
|
13
|
+
const errorData = {
|
|
14
|
+
summary: "缺少模板路径参数",
|
|
15
|
+
framework: framework,
|
|
16
|
+
code: '',
|
|
17
|
+
};
|
|
18
|
+
return okStructured(`❌ 缺少模板路径参数
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
**用法**:
|
|
21
|
+
\`\`\`
|
|
22
|
+
render_ui --template="docs/ui/pages/login.json" --framework="react"
|
|
23
|
+
\`\`\`
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
**支持的框架**: react, vue, html
|
|
26
|
+
`, errorData, {
|
|
27
|
+
schema: (await import('../schemas/output/ui-ux-tools.js')).RenderResultSchema,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// 读取模板文件
|
|
31
|
+
const fullTemplatePath = path.join(process.cwd(), templatePath);
|
|
32
|
+
let template;
|
|
33
|
+
try {
|
|
34
|
+
const templateContent = await fs.readFile(fullTemplatePath, 'utf-8');
|
|
35
|
+
template = JSON.parse(templateContent);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
const errorData = {
|
|
39
|
+
summary: "模板文件读取失败",
|
|
40
|
+
framework: framework,
|
|
41
|
+
code: '',
|
|
42
|
+
};
|
|
43
|
+
return okStructured(`❌ 模板文件读取失败: ${templatePath}
|
|
44
|
+
|
|
45
|
+
**可能的原因**:
|
|
46
|
+
1. 文件不存在
|
|
47
|
+
2. 文件格式错误(不是有效的 JSON)
|
|
48
|
+
3. 文件路径错误
|
|
49
|
+
|
|
50
|
+
**建议**:
|
|
51
|
+
1. 检查文件路径是否正确
|
|
52
|
+
2. 使用 \`ui_search --mode=template\` 查看可用模板
|
|
53
|
+
3. 使用 \`start_ui\` 生成新模板
|
|
54
|
+
`, errorData, {
|
|
55
|
+
schema: (await import('../schemas/output/ui-ux-tools.js')).RenderResultSchema,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// 读取设计系统和组件目录
|
|
59
|
+
const designSystemPath = path.join(process.cwd(), 'docs', 'design-system.json');
|
|
60
|
+
const catalogPath = path.join(process.cwd(), 'docs', 'ui', 'component-catalog.json');
|
|
61
|
+
let designSystem = {};
|
|
62
|
+
let catalog = { components: [] };
|
|
63
|
+
try {
|
|
64
|
+
const designSystemContent = await fs.readFile(designSystemPath, 'utf-8');
|
|
65
|
+
designSystem = JSON.parse(designSystemContent);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.warn('Design system not found, using defaults');
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const catalogContent = await fs.readFile(catalogPath, 'utf-8');
|
|
72
|
+
catalog = JSON.parse(catalogContent);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
console.warn('Component catalog not found, using defaults');
|
|
76
|
+
}
|
|
77
|
+
// 渲染代码(简化版本,实际实现会更复杂)
|
|
78
|
+
let code = '';
|
|
79
|
+
const usedComponents = [];
|
|
80
|
+
const designTokens = {};
|
|
81
|
+
if (framework === 'react') {
|
|
82
|
+
code = renderReact(template, designSystem, catalog, usedComponents, designTokens);
|
|
83
|
+
}
|
|
84
|
+
else if (framework === 'vue') {
|
|
85
|
+
code = renderVue(template, designSystem, catalog, usedComponents, designTokens);
|
|
86
|
+
}
|
|
87
|
+
else if (framework === 'html') {
|
|
88
|
+
code = renderHtml(template, designSystem, catalog, usedComponents, designTokens);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const errorData = {
|
|
92
|
+
summary: "不支持的框架",
|
|
93
|
+
framework: framework,
|
|
94
|
+
code: '',
|
|
95
|
+
};
|
|
96
|
+
return okStructured(`❌ 不支持的框架: ${framework}
|
|
27
97
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
- 确保生成的代码符合设计理念
|
|
98
|
+
**支持的框架**: react, vue, html
|
|
99
|
+
`, errorData, {
|
|
100
|
+
schema: (await import('../schemas/output/ui-ux-tools.js')).RenderResultSchema,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const message = `✅ UI 代码已渲染
|
|
35
104
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
- [ ] 模板引用的组件在组件目录中存在
|
|
40
|
-
- [ ] 理解了 design-system.md 中的设计理念
|
|
105
|
+
**框架**: ${framework}
|
|
106
|
+
**模板**: ${templatePath}
|
|
107
|
+
**使用的组件**: ${usedComponents.join(', ') || '无'}
|
|
41
108
|
|
|
42
109
|
---
|
|
43
110
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
**操作**:
|
|
47
|
-
1. 解析 JSON 模板的 layout 结构
|
|
48
|
-
2. 识别所有使用的组件
|
|
49
|
-
3. 提取组件的 props
|
|
111
|
+
## 渲染的代码
|
|
50
112
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
"name": "LoginForm",
|
|
55
|
-
"layout": {
|
|
56
|
-
"type": "Container",
|
|
57
|
-
"props": { "maxWidth": "sm" },
|
|
58
|
-
"children": [
|
|
59
|
-
{
|
|
60
|
-
"type": "Card",
|
|
61
|
-
"props": { "title": "登录" },
|
|
62
|
-
"children": [
|
|
63
|
-
{
|
|
64
|
-
"type": "Input",
|
|
65
|
-
"props": { "label": "用户名", "type": "text" }
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"type": "Button",
|
|
69
|
-
"props": { "variant": "primary", "label": "登录" }
|
|
70
|
-
}
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
]
|
|
74
|
-
}
|
|
75
|
-
}
|
|
113
|
+
\`\`\`${framework === 'react' ? 'tsx' : framework === 'vue' ? 'vue' : 'html'}
|
|
114
|
+
${code}
|
|
76
115
|
\`\`\`
|
|
77
116
|
|
|
78
117
|
---
|
|
79
118
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
**操作**:
|
|
83
|
-
对每个组件,从组件目录中获取样式定义,然后替换占位符。
|
|
84
|
-
|
|
85
|
-
**占位符替换规则**:
|
|
86
|
-
|
|
87
|
-
1. **颜色占位符**:
|
|
88
|
-
- \`{colors.primary.500}\` → 从 design-system.json 读取 \`colors.primary["500"]\`
|
|
89
|
-
- 示例: \`bg-[{colors.primary.500}]\` → \`bg-[#3b82f6]\`
|
|
119
|
+
## 使用的设计 Token
|
|
90
120
|
|
|
91
|
-
|
|
92
|
-
- \`{typography.fontSize.base}\` → 从 design-system.json 读取
|
|
93
|
-
- 示例: \`text-[{typography.fontSize.base}]\` → \`text-[1rem]\`
|
|
121
|
+
${Object.entries(designTokens).map(([key, value]) => `- **${key}**: ${value}`).join('\n') || '无'}
|
|
94
122
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
123
|
+
**提示**: 代码已自动应用设计系统中的样式 Token。
|
|
124
|
+
`;
|
|
125
|
+
const structuredData = {
|
|
126
|
+
summary: `UI 代码已渲染 - ${framework}`,
|
|
127
|
+
framework: framework,
|
|
128
|
+
code,
|
|
129
|
+
usedComponents,
|
|
130
|
+
designTokens,
|
|
131
|
+
};
|
|
132
|
+
return okStructured(message, structuredData, {
|
|
133
|
+
schema: (await import('../schemas/output/ui-ux-tools.js')).RenderResultSchema,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
138
|
+
const errorData = {
|
|
139
|
+
summary: "UI 渲染失败",
|
|
140
|
+
framework: args.framework || 'react',
|
|
141
|
+
code: '',
|
|
142
|
+
};
|
|
143
|
+
return okStructured(`❌ UI 渲染失败: ${errorMessage}
|
|
144
|
+
|
|
145
|
+
**可能的原因**:
|
|
146
|
+
1. 模板格式错误
|
|
147
|
+
2. 设计系统文件缺失
|
|
148
|
+
3. 组件目录文件缺失
|
|
149
|
+
|
|
150
|
+
**建议**:
|
|
151
|
+
1. 检查模板文件格式
|
|
152
|
+
2. 运行 \`ui_design_system\` 生成设计系统
|
|
153
|
+
3. 运行 \`init_component_catalog\` 生成组件目录
|
|
154
|
+
`, errorData, {
|
|
155
|
+
schema: (await import('../schemas/output/ui-ux-tools.js')).RenderResultSchema,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* 渲染 React 代码
|
|
161
|
+
*/
|
|
162
|
+
function renderReact(template, designSystem, catalog, usedComponents, designTokens) {
|
|
163
|
+
const componentName = template.name || 'Component';
|
|
164
|
+
// 提取使用的设计 Token
|
|
165
|
+
if (designSystem.colors?.primary) {
|
|
166
|
+
designTokens['primary-color'] = Object.values(designSystem.colors.primary)[0];
|
|
167
|
+
}
|
|
168
|
+
if (designSystem.typography?.fontFamilies) {
|
|
169
|
+
designTokens['font-family'] = Object.values(designSystem.typography.fontFamilies)[0];
|
|
170
|
+
}
|
|
171
|
+
// 简化的渲染逻辑
|
|
172
|
+
return `import React from 'react';
|
|
106
173
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
function replacePlaceholders(styleString: string, designSystem: any): string {
|
|
110
|
-
// 匹配 {path.to.value} 格式
|
|
111
|
-
return styleString.replace(/\\{([^}]+)\\}/g, (match, path) => {
|
|
112
|
-
const value = getValueByPath(designSystem, path);
|
|
113
|
-
return value || match; // 找不到则保留原样
|
|
114
|
-
});
|
|
174
|
+
interface ${componentName}Props {
|
|
175
|
+
// Props will be defined here
|
|
115
176
|
}
|
|
116
177
|
|
|
117
|
-
|
|
118
|
-
return path.split('.').reduce((current, key) => {
|
|
119
|
-
if (current && typeof current === 'object') {
|
|
120
|
-
// 处理数组索引,如 spacing.scale.4
|
|
121
|
-
if (!isNaN(Number(key)) && Array.isArray(current)) {
|
|
122
|
-
return current[Number(key)];
|
|
123
|
-
}
|
|
124
|
-
return current[key];
|
|
125
|
-
}
|
|
126
|
-
return undefined;
|
|
127
|
-
}, obj);
|
|
128
|
-
}
|
|
129
|
-
\`\`\`
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
### 第4步:生成代码
|
|
134
|
-
|
|
135
|
-
根据框架生成对应的代码。
|
|
136
|
-
|
|
137
|
-
#### React 代码生成
|
|
138
|
-
|
|
139
|
-
\`\`\`tsx
|
|
140
|
-
import React from 'react';
|
|
141
|
-
|
|
142
|
-
export const {componentName}: React.FC = () => {
|
|
178
|
+
export const ${componentName}: React.FC<${componentName}Props> = (props) => {
|
|
143
179
|
return (
|
|
144
|
-
<div className="{
|
|
145
|
-
{
|
|
146
|
-
|
|
147
|
-
<h2 className="text-2xl font-semibold mb-4">{title}</h2>
|
|
148
|
-
|
|
149
|
-
<div className="space-y-4">
|
|
150
|
-
{/* Input 组件 */}
|
|
151
|
-
<div>
|
|
152
|
-
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
153
|
-
{label}
|
|
154
|
-
</label>
|
|
155
|
-
<input
|
|
156
|
-
type="{type}"
|
|
157
|
-
className="{inputClasses}"
|
|
158
|
-
/>
|
|
159
|
-
</div>
|
|
160
|
-
|
|
161
|
-
{/* Button 组件 */}
|
|
162
|
-
<button className="{buttonClasses}">
|
|
163
|
-
{buttonLabel}
|
|
164
|
-
</button>
|
|
165
|
-
</div>
|
|
166
|
-
</div>
|
|
180
|
+
<div className="${componentName.toLowerCase()}">
|
|
181
|
+
<h1>${template.description || componentName}</h1>
|
|
182
|
+
{/* Component content will be rendered here */}
|
|
167
183
|
</div>
|
|
168
184
|
);
|
|
169
185
|
};
|
|
170
|
-
\`\`\`
|
|
171
186
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
<div
|
|
182
|
-
<
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
<div class="space-y-4">
|
|
186
|
-
<div>
|
|
187
|
-
<label class="block text-sm font-medium text-gray-700 mb-1">
|
|
188
|
-
{{ label }}
|
|
189
|
-
</label>
|
|
190
|
-
<input
|
|
191
|
-
:type="type"
|
|
192
|
-
:class="inputClasses"
|
|
193
|
-
/>
|
|
194
|
-
</div>
|
|
195
|
-
|
|
196
|
-
<button :class="buttonClasses">
|
|
197
|
-
{{ buttonLabel }}
|
|
198
|
-
</button>
|
|
199
|
-
</div>
|
|
200
|
-
</div>
|
|
187
|
+
export default ${componentName};
|
|
188
|
+
`;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* 渲染 Vue 代码
|
|
192
|
+
*/
|
|
193
|
+
function renderVue(template, designSystem, catalog, usedComponents, designTokens) {
|
|
194
|
+
const componentName = template.name || 'Component';
|
|
195
|
+
return `<template>
|
|
196
|
+
<div class="${componentName.toLowerCase()}">
|
|
197
|
+
<h1>{{ title }}</h1>
|
|
198
|
+
<!-- Component content will be rendered here -->
|
|
201
199
|
</div>
|
|
202
200
|
</template>
|
|
203
201
|
|
|
204
202
|
<script setup lang="ts">
|
|
205
203
|
import { ref } from 'vue';
|
|
206
204
|
|
|
207
|
-
const title = ref('{
|
|
208
|
-
const label = ref('{label}');
|
|
209
|
-
const type = ref('{type}');
|
|
210
|
-
const buttonLabel = ref('{buttonLabel}');
|
|
211
|
-
|
|
212
|
-
const containerClasses = '{containerClasses}';
|
|
213
|
-
const cardClasses = '{cardClasses}';
|
|
214
|
-
const inputClasses = '{inputClasses}';
|
|
215
|
-
const buttonClasses = '{buttonClasses}';
|
|
205
|
+
const title = ref('${template.description || componentName}');
|
|
216
206
|
</script>
|
|
217
|
-
\`\`\`
|
|
218
|
-
|
|
219
|
-
---
|
|
220
|
-
|
|
221
|
-
### 第5步:代码优化
|
|
222
|
-
|
|
223
|
-
**操作**:
|
|
224
|
-
1. 格式化代码(缩进、换行)
|
|
225
|
-
2. 添加 TypeScript 类型
|
|
226
|
-
3. 添加注释说明
|
|
227
|
-
4. 提取可复用的样式类
|
|
228
|
-
|
|
229
|
-
**优化示例**:
|
|
230
|
-
\`\`\`tsx
|
|
231
|
-
// 提取常量
|
|
232
|
-
const BUTTON_CLASSES = {
|
|
233
|
-
primary: 'bg-[#3b82f6] text-white hover:bg-[#2563eb]',
|
|
234
|
-
secondary: 'bg-[#8b5cf6] text-white hover:bg-[#7c3aed]',
|
|
235
|
-
} as const;
|
|
236
|
-
|
|
237
|
-
// 使用常量
|
|
238
|
-
<button className={\`\${baseClasses} \${BUTTON_CLASSES[variant]}\`}>
|
|
239
|
-
{label}
|
|
240
|
-
</button>
|
|
241
|
-
\`\`\`
|
|
242
|
-
|
|
243
|
-
---
|
|
244
|
-
|
|
245
|
-
## ✅ 输出结果
|
|
246
|
-
|
|
247
|
-
生成的代码包含:
|
|
248
|
-
|
|
249
|
-
1. **完整的组件实现**
|
|
250
|
-
- React: Hooks + TypeScript
|
|
251
|
-
- Vue: Composition API + TypeScript
|
|
252
|
-
- HTML: 原生 JavaScript
|
|
253
|
-
|
|
254
|
-
2. **自动应用的设计规范**
|
|
255
|
-
- ✅ 设计理念来自 design-system.md(UI 风格、设计原则)
|
|
256
|
-
- ✅ 颜色来自 design-system.json(精确的色值)
|
|
257
|
-
- ✅ 字体来自 design-system.json(字体族和大小)
|
|
258
|
-
- ✅ 间距来自 design-system.json(间距比例)
|
|
259
|
-
- ✅ 圆角来自 design-system.json(圆角大小)
|
|
260
|
-
- ✅ 阴影来自 design-system.json(阴影效果)
|
|
261
|
-
- ✅ 最佳实践来自 design-system.md(使用建议)
|
|
262
|
-
|
|
263
|
-
3. **代码特点**
|
|
264
|
-
- ✅ 类型安全(TypeScript)
|
|
265
|
-
- ✅ 可访问性(A11y)
|
|
266
|
-
- ✅ 响应式设计
|
|
267
|
-
- ✅ 样式统一
|
|
268
|
-
- ✅ 符合设计理念
|
|
269
|
-
|
|
270
|
-
---
|
|
271
|
-
|
|
272
|
-
## 📌 注意事项
|
|
273
|
-
|
|
274
|
-
1. **占位符格式**: 必须严格遵循 \`{path.to.value}\` 格式
|
|
275
|
-
2. **路径正确性**: 确保路径在 design-system.json 中存在
|
|
276
|
-
3. **组件存在性**: 模板中的组件必须在 component-catalog.json 中定义
|
|
277
|
-
4. **嵌套处理**: 正确处理组件的嵌套关系
|
|
278
|
-
|
|
279
|
-
---
|
|
280
|
-
|
|
281
|
-
## 🚀 使用示例
|
|
282
|
-
|
|
283
|
-
### 示例 1:渲染登录表单
|
|
284
|
-
|
|
285
|
-
\`\`\`bash
|
|
286
|
-
# 假设已有 docs/ui/login-form.json
|
|
287
|
-
render_ui docs/ui/login-form.json --framework=react
|
|
288
|
-
\`\`\`
|
|
289
|
-
|
|
290
|
-
**输出**:
|
|
291
|
-
- 完整的 React 组件代码
|
|
292
|
-
- 自动应用设计规范
|
|
293
|
-
- 可直接使用
|
|
294
|
-
|
|
295
|
-
### 示例 2:渲染数据表格
|
|
296
|
-
|
|
297
|
-
\`\`\`bash
|
|
298
|
-
render_ui docs/ui/data-table.json --framework=vue
|
|
299
|
-
\`\`\`
|
|
300
|
-
|
|
301
|
-
**输出**:
|
|
302
|
-
- 完整的 Vue 3 组件代码
|
|
303
|
-
- 自动应用设计规范
|
|
304
|
-
- 包含 TypeScript 类型
|
|
305
207
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
- ❌ 不执行代码或命令
|
|
312
|
-
- ✅ 输出完整可用的组件代码
|
|
313
|
-
- ✅ 自动应用设计规范
|
|
314
|
-
- ✅ 保证样式统一
|
|
315
|
-
|
|
316
|
-
---
|
|
317
|
-
|
|
318
|
-
## 🔗 相关工具
|
|
319
|
-
|
|
320
|
-
- **ui_design_system**: 生成设计规范
|
|
321
|
-
- **init_component_catalog**: 生成组件目录
|
|
322
|
-
- **ui_search --mode=template**: 获取 UI 模板
|
|
323
|
-
- **start_ui**: 一键完成整个流程(推荐)
|
|
208
|
+
<style scoped>
|
|
209
|
+
.${componentName.toLowerCase()} {
|
|
210
|
+
/* Styles will be applied here */
|
|
211
|
+
}
|
|
212
|
+
</style>
|
|
324
213
|
`;
|
|
214
|
+
}
|
|
325
215
|
/**
|
|
326
|
-
*
|
|
216
|
+
* 渲染 HTML 代码
|
|
327
217
|
*/
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
render_ui docs/ui/login-form.json --framework=vue
|
|
349
|
-
\`\`\`
|
|
350
|
-
|
|
351
|
-
**提示**:
|
|
352
|
-
- 模板文件应该是 JSON 格式
|
|
353
|
-
- 确保已运行 \`ui_design_system\` 和 \`init_component_catalog\`
|
|
354
|
-
`,
|
|
355
|
-
},
|
|
356
|
-
],
|
|
357
|
-
isError: true,
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
const guide = PROMPT_TEMPLATE
|
|
361
|
-
.replace(/{templatePath}/g, templatePath)
|
|
362
|
-
.replace(/{framework}/g, framework);
|
|
363
|
-
return {
|
|
364
|
-
content: [
|
|
365
|
-
{
|
|
366
|
-
type: "text",
|
|
367
|
-
text: guide,
|
|
368
|
-
},
|
|
369
|
-
],
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
catch (error) {
|
|
373
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
374
|
-
return {
|
|
375
|
-
content: [
|
|
376
|
-
{
|
|
377
|
-
type: "text",
|
|
378
|
-
text: `❌ UI 渲染失败: ${errorMessage}`,
|
|
379
|
-
},
|
|
380
|
-
],
|
|
381
|
-
isError: true,
|
|
382
|
-
};
|
|
383
|
-
}
|
|
218
|
+
function renderHtml(template, designSystem, catalog, usedComponents, designTokens) {
|
|
219
|
+
const componentName = template.name || 'Component';
|
|
220
|
+
return `<!DOCTYPE html>
|
|
221
|
+
<html lang="zh-CN">
|
|
222
|
+
<head>
|
|
223
|
+
<meta charset="UTF-8">
|
|
224
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
225
|
+
<title>${componentName}</title>
|
|
226
|
+
<style>
|
|
227
|
+
/* Styles will be applied here */
|
|
228
|
+
</style>
|
|
229
|
+
</head>
|
|
230
|
+
<body>
|
|
231
|
+
<div class="${componentName.toLowerCase()}">
|
|
232
|
+
<h1>${template.description || componentName}</h1>
|
|
233
|
+
<!-- Component content will be rendered here -->
|
|
234
|
+
</div>
|
|
235
|
+
</body>
|
|
236
|
+
</html>
|
|
237
|
+
`;
|
|
384
238
|
}
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
export declare function resolveConflict(args: any): Promise<
|
|
2
|
-
content: {
|
|
3
|
-
type: string;
|
|
4
|
-
text: string;
|
|
5
|
-
}[];
|
|
6
|
-
isError?: undefined;
|
|
7
|
-
} | {
|
|
8
|
-
content: {
|
|
9
|
-
type: string;
|
|
10
|
-
text: string;
|
|
11
|
-
}[];
|
|
12
|
-
isError: boolean;
|
|
13
|
-
}>;
|
|
1
|
+
export declare function resolveConflict(args: any): Promise<import("../lib/response.js").ToolResponse>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseArgs, getString } from "../utils/parseArgs.js";
|
|
2
|
+
import { okStructured } from "../lib/response.js";
|
|
2
3
|
// resolve_conflict 工具实现
|
|
3
4
|
export async function resolveConflict(args) {
|
|
4
5
|
try {
|
|
@@ -325,25 +326,27 @@ git mergetool
|
|
|
325
326
|
2. 双方修改意图
|
|
326
327
|
3. 推荐的合并方案
|
|
327
328
|
4. 完整的解决后代码`;
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
],
|
|
329
|
+
// 创建结构化数据对象
|
|
330
|
+
const structuredData = {
|
|
331
|
+
summary: "Git 冲突解决指南",
|
|
332
|
+
conflicts: [],
|
|
333
|
+
resolvedCode: "待分析冲突后生成",
|
|
334
|
+
explanation: "请提供冲突内容以进行分析"
|
|
335
335
|
};
|
|
336
|
+
return okStructured(message, structuredData, {
|
|
337
|
+
schema: (await import("../schemas/output/project-tools.js")).ConflictResolutionSchema,
|
|
338
|
+
});
|
|
336
339
|
}
|
|
337
340
|
catch (error) {
|
|
338
341
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
},
|
|
345
|
-
],
|
|
346
|
-
isError: true,
|
|
342
|
+
const errorData = {
|
|
343
|
+
summary: "冲突解决失败",
|
|
344
|
+
conflicts: [],
|
|
345
|
+
resolvedCode: "",
|
|
346
|
+
explanation: errorMessage
|
|
347
347
|
};
|
|
348
|
+
return okStructured(`❌ 冲突解决失败: ${errorMessage}`, errorData, {
|
|
349
|
+
schema: (await import("../schemas/output/project-tools.js")).ConflictResolutionSchema,
|
|
350
|
+
});
|
|
348
351
|
}
|
|
349
352
|
}
|
|
@@ -7,16 +7,4 @@
|
|
|
7
7
|
/**
|
|
8
8
|
* security_scan 工具实现
|
|
9
9
|
*/
|
|
10
|
-
export declare function securityScan(args: any): Promise<
|
|
11
|
-
content: {
|
|
12
|
-
type: string;
|
|
13
|
-
text: string;
|
|
14
|
-
}[];
|
|
15
|
-
isError?: undefined;
|
|
16
|
-
} | {
|
|
17
|
-
content: {
|
|
18
|
-
type: string;
|
|
19
|
-
text: string;
|
|
20
|
-
}[];
|
|
21
|
-
isError: boolean;
|
|
22
|
-
}>;
|
|
10
|
+
export declare function securityScan(args: any): Promise<import("../lib/response.js").ToolResponse>;
|