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
|
@@ -1,809 +1,164 @@
|
|
|
1
|
+
import { okStructured } from "../lib/response.js";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* 基于设计系统规范生成组件目录
|
|
5
|
-
* 组件定义包含占位符,渲染时自动替换为实际值
|
|
3
|
+
* 初始化组件目录工具(内部工具)
|
|
4
|
+
* 基于设计系统规范生成组件目录文件
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## 🎯 任务目标
|
|
10
|
-
|
|
11
|
-
基于设计系统规范(\`docs/design-system.json\`)生成组件目录文件。
|
|
12
|
-
|
|
13
|
-
**输出文件**: \`docs/component-catalog.json\`
|
|
14
|
-
|
|
15
|
-
**文件用途**: 定义可用的 UI 组件及其属性,供后续 UI 生成时使用。
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## 📋 前置检查
|
|
20
|
-
|
|
21
|
-
### 第1步:检查设计系统文件
|
|
22
|
-
|
|
23
|
-
**操作**:
|
|
24
|
-
1. 检查文件 \`docs/design-system.json\` 是否存在
|
|
25
|
-
2. 如果不存在:
|
|
26
|
-
- 提示用户先运行 \`ui_design_system\` 生成设计系统
|
|
27
|
-
- 停止执行
|
|
28
|
-
3. 如果存在:
|
|
29
|
-
- 读取文件内容
|
|
30
|
-
- 提取设计规范(颜色、字体、间距等)
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## 📝 生成组件目录
|
|
35
|
-
|
|
36
|
-
在 \`docs/component-catalog.json\` 中生成以下内容:
|
|
37
|
-
|
|
38
|
-
\`\`\`json
|
|
39
|
-
{
|
|
40
|
-
"version": "1.0.0",
|
|
41
|
-
"designSystem": "docs/design-system.json",
|
|
42
|
-
"components": {
|
|
43
|
-
"Button": {
|
|
44
|
-
"description": "按钮组件",
|
|
45
|
-
"props": {
|
|
46
|
-
"variant": {
|
|
47
|
-
"type": "enum",
|
|
48
|
-
"values": ["primary", "secondary", "outline", "ghost", "link"],
|
|
49
|
-
"default": "primary",
|
|
50
|
-
"mapping": {
|
|
51
|
-
"primary": "bg-[{colors.primary.500}] text-white hover:bg-[{colors.primary.600}]",
|
|
52
|
-
"secondary": "bg-[{colors.secondary.500}] text-white hover:bg-[{colors.secondary.600}]",
|
|
53
|
-
"outline": "border border-[{colors.neutral.300}] bg-transparent hover:bg-[{colors.neutral.50}]",
|
|
54
|
-
"ghost": "hover:bg-[{colors.neutral.100}]",
|
|
55
|
-
"link": "text-[{colors.primary.500}] underline-offset-4 hover:underline"
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
"size": {
|
|
59
|
-
"type": "enum",
|
|
60
|
-
"values": ["sm", "md", "lg"],
|
|
61
|
-
"default": "md",
|
|
62
|
-
"mapping": {
|
|
63
|
-
"sm": "h-9 px-3 text-sm",
|
|
64
|
-
"md": "h-10 px-4 text-base",
|
|
65
|
-
"lg": "h-11 px-6 text-lg"
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
"label": {
|
|
69
|
-
"type": "string",
|
|
70
|
-
"required": true
|
|
71
|
-
},
|
|
72
|
-
"disabled": {
|
|
73
|
-
"type": "boolean",
|
|
74
|
-
"default": false
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
"baseClasses": "inline-flex items-center justify-center rounded-[{borderRadius.md}] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[{colors.primary.500}] disabled:pointer-events-none disabled:opacity-50"
|
|
78
|
-
},
|
|
79
|
-
"Input": {
|
|
80
|
-
"description": "输入框组件",
|
|
81
|
-
"props": {
|
|
82
|
-
"label": {
|
|
83
|
-
"type": "string",
|
|
84
|
-
"required": true
|
|
85
|
-
},
|
|
86
|
-
"type": {
|
|
87
|
-
"type": "enum",
|
|
88
|
-
"values": ["text", "email", "password", "number", "tel", "url"],
|
|
89
|
-
"default": "text"
|
|
90
|
-
},
|
|
91
|
-
"placeholder": {
|
|
92
|
-
"type": "string"
|
|
93
|
-
},
|
|
94
|
-
"required": {
|
|
95
|
-
"type": "boolean",
|
|
96
|
-
"default": false
|
|
97
|
-
},
|
|
98
|
-
"disabled": {
|
|
99
|
-
"type": "boolean",
|
|
100
|
-
"default": false
|
|
101
|
-
},
|
|
102
|
-
"error": {
|
|
103
|
-
"type": "string"
|
|
104
|
-
},
|
|
105
|
-
"helperText": {
|
|
106
|
-
"type": "string"
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
"baseClasses": "w-full px-3 py-2 border border-[{colors.neutral.300}] rounded-[{borderRadius.md}] text-[{typography.fontSize.base}] focus:outline-none focus:ring-2 focus:ring-[{colors.primary.500}] focus:border-transparent disabled:bg-[{colors.neutral.50}] disabled:cursor-not-allowed"
|
|
110
|
-
},
|
|
111
|
-
"Card": {
|
|
112
|
-
"description": "卡片容器",
|
|
113
|
-
"props": {
|
|
114
|
-
"title": {
|
|
115
|
-
"type": "string"
|
|
116
|
-
},
|
|
117
|
-
"description": {
|
|
118
|
-
"type": "string"
|
|
119
|
-
},
|
|
120
|
-
"padding": {
|
|
121
|
-
"type": "enum",
|
|
122
|
-
"values": ["none", "sm", "md", "lg"],
|
|
123
|
-
"default": "md",
|
|
124
|
-
"mapping": {
|
|
125
|
-
"none": "p-0",
|
|
126
|
-
"sm": "p-4",
|
|
127
|
-
"md": "p-6",
|
|
128
|
-
"lg": "p-8"
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
"hasChildren": true,
|
|
133
|
-
"baseClasses": "bg-white rounded-[{borderRadius.lg}] shadow-[{shadows.md}] border border-[{colors.neutral.200}]"
|
|
134
|
-
},
|
|
135
|
-
"Form": {
|
|
136
|
-
"description": "表单容器",
|
|
137
|
-
"props": {
|
|
138
|
-
"title": {
|
|
139
|
-
"type": "string"
|
|
140
|
-
},
|
|
141
|
-
"submitLabel": {
|
|
142
|
-
"type": "string",
|
|
143
|
-
"default": "提交"
|
|
144
|
-
},
|
|
145
|
-
"cancelLabel": {
|
|
146
|
-
"type": "string"
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
"hasChildren": true,
|
|
150
|
-
"baseClasses": "space-y-[{spacing.scale.4}]"
|
|
151
|
-
},
|
|
152
|
-
"Modal": {
|
|
153
|
-
"description": "弹窗组件",
|
|
154
|
-
"props": {
|
|
155
|
-
"title": {
|
|
156
|
-
"type": "string",
|
|
157
|
-
"required": true
|
|
158
|
-
},
|
|
159
|
-
"size": {
|
|
160
|
-
"type": "enum",
|
|
161
|
-
"values": ["sm", "md", "lg", "xl"],
|
|
162
|
-
"default": "md",
|
|
163
|
-
"mapping": {
|
|
164
|
-
"sm": "max-w-md",
|
|
165
|
-
"md": "max-w-lg",
|
|
166
|
-
"lg": "max-w-2xl",
|
|
167
|
-
"xl": "max-w-4xl"
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
"hasChildren": true,
|
|
172
|
-
"baseClasses": "relative bg-white rounded-[{borderRadius.lg}] shadow-[{shadows.xl}] w-full mx-4 max-h-[90vh] flex flex-col"
|
|
173
|
-
},
|
|
174
|
-
"Table": {
|
|
175
|
-
"description": "数据表格",
|
|
176
|
-
"props": {
|
|
177
|
-
"columns": {
|
|
178
|
-
"type": "array",
|
|
179
|
-
"required": true
|
|
180
|
-
},
|
|
181
|
-
"striped": {
|
|
182
|
-
"type": "boolean",
|
|
183
|
-
"default": false
|
|
184
|
-
},
|
|
185
|
-
"hoverable": {
|
|
186
|
-
"type": "boolean",
|
|
187
|
-
"default": true
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
"hasChildren": false,
|
|
191
|
-
"baseClasses": "min-w-full divide-y divide-[{colors.neutral.200}]"
|
|
192
|
-
},
|
|
193
|
-
"Alert": {
|
|
194
|
-
"description": "提示信息",
|
|
195
|
-
"props": {
|
|
196
|
-
"variant": {
|
|
197
|
-
"type": "enum",
|
|
198
|
-
"values": ["info", "success", "warning", "error"],
|
|
199
|
-
"default": "info",
|
|
200
|
-
"mapping": {
|
|
201
|
-
"info": "bg-[{colors.primary.50}] text-[{colors.primary.700}] border-[{colors.primary.200}]",
|
|
202
|
-
"success": "bg-[{colors.success.50}] text-[{colors.success.700}] border-[{colors.success.200}]",
|
|
203
|
-
"warning": "bg-[{colors.warning.50}] text-[{colors.warning.700}] border-[{colors.warning.200}]",
|
|
204
|
-
"error": "bg-[{colors.error.50}] text-[{colors.error.700}] border-[{colors.error.200}]"
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
"title": {
|
|
208
|
-
"type": "string"
|
|
209
|
-
},
|
|
210
|
-
"message": {
|
|
211
|
-
"type": "string",
|
|
212
|
-
"required": true
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
"baseClasses": "p-4 rounded-[{borderRadius.md}] border"
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
"layouts": {
|
|
219
|
-
"Container": {
|
|
220
|
-
"description": "容器布局",
|
|
221
|
-
"props": {
|
|
222
|
-
"maxWidth": {
|
|
223
|
-
"type": "enum",
|
|
224
|
-
"values": ["sm", "md", "lg", "xl", "2xl", "full"],
|
|
225
|
-
"default": "lg",
|
|
226
|
-
"mapping": {
|
|
227
|
-
"sm": "max-w-screen-sm",
|
|
228
|
-
"md": "max-w-screen-md",
|
|
229
|
-
"lg": "max-w-screen-lg",
|
|
230
|
-
"xl": "max-w-screen-xl",
|
|
231
|
-
"2xl": "max-w-screen-2xl",
|
|
232
|
-
"full": "max-w-full"
|
|
233
|
-
}
|
|
234
|
-
},
|
|
235
|
-
"padding": {
|
|
236
|
-
"type": "boolean",
|
|
237
|
-
"default": true
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
"hasChildren": true,
|
|
241
|
-
"baseClasses": "mx-auto px-4"
|
|
242
|
-
},
|
|
243
|
-
"Stack": {
|
|
244
|
-
"description": "堆叠布局",
|
|
245
|
-
"props": {
|
|
246
|
-
"direction": {
|
|
247
|
-
"type": "enum",
|
|
248
|
-
"values": ["row", "column"],
|
|
249
|
-
"default": "column"
|
|
250
|
-
},
|
|
251
|
-
"spacing": {
|
|
252
|
-
"type": "enum",
|
|
253
|
-
"values": [2, 4, 6, 8],
|
|
254
|
-
"default": 4,
|
|
255
|
-
"mapping": {
|
|
256
|
-
"2": "space-{direction === 'row' ? 'x' : 'y'}-2",
|
|
257
|
-
"4": "space-{direction === 'row' ? 'x' : 'y'}-4",
|
|
258
|
-
"6": "space-{direction === 'row' ? 'x' : 'y'}-6",
|
|
259
|
-
"8": "space-{direction === 'row' ? 'x' : 'y'}-8"
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
"align": {
|
|
263
|
-
"type": "enum",
|
|
264
|
-
"values": ["start", "center", "end", "stretch"],
|
|
265
|
-
"default": "stretch"
|
|
266
|
-
}
|
|
267
|
-
},
|
|
268
|
-
"hasChildren": true,
|
|
269
|
-
"baseClasses": "flex"
|
|
270
|
-
},
|
|
271
|
-
"Grid": {
|
|
272
|
-
"description": "网格布局",
|
|
273
|
-
"props": {
|
|
274
|
-
"cols": {
|
|
275
|
-
"type": "enum",
|
|
276
|
-
"values": [1, 2, 3, 4, 6, 12],
|
|
277
|
-
"default": 1,
|
|
278
|
-
"mapping": {
|
|
279
|
-
"1": "grid-cols-1",
|
|
280
|
-
"2": "grid-cols-2",
|
|
281
|
-
"3": "grid-cols-3",
|
|
282
|
-
"4": "grid-cols-4",
|
|
283
|
-
"6": "grid-cols-6",
|
|
284
|
-
"12": "grid-cols-12"
|
|
285
|
-
}
|
|
286
|
-
},
|
|
287
|
-
"gap": {
|
|
288
|
-
"type": "enum",
|
|
289
|
-
"values": [2, 4, 6, 8],
|
|
290
|
-
"default": 4,
|
|
291
|
-
"mapping": {
|
|
292
|
-
"2": "gap-2",
|
|
293
|
-
"4": "gap-4",
|
|
294
|
-
"6": "gap-6",
|
|
295
|
-
"8": "gap-8"
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
},
|
|
299
|
-
"hasChildren": true,
|
|
300
|
-
"baseClasses": "grid"
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
\`\`\`
|
|
305
|
-
|
|
306
|
-
---
|
|
307
|
-
|
|
308
|
-
## 🔑 关键说明
|
|
309
|
-
|
|
310
|
-
### 占位符语法
|
|
311
|
-
|
|
312
|
-
组件定义中使用占位符引用设计规范:
|
|
313
|
-
|
|
314
|
-
- \`{colors.primary.500}\` → 引用主色
|
|
315
|
-
- \`{colors.neutral.300}\` → 引用中性色
|
|
316
|
-
- \`{borderRadius.md}\` → 引用圆角
|
|
317
|
-
- \`{shadows.md}\` → 引用阴影
|
|
318
|
-
- \`{spacing.scale.4}\` → 引用间距
|
|
319
|
-
- \`{typography.fontSize.base}\` → 引用字体大小
|
|
320
|
-
|
|
321
|
-
**渲染时自动替换**:
|
|
322
|
-
\`\`\`
|
|
323
|
-
占位符: bg-[{colors.primary.500}]
|
|
324
|
-
替换后: bg-[#3b82f6]
|
|
325
|
-
\`\`\`
|
|
326
|
-
|
|
327
|
-
### 组件属性
|
|
328
|
-
|
|
329
|
-
每个组件包含:
|
|
330
|
-
- \`description\`: 组件描述
|
|
331
|
-
- \`props\`: 属性定义
|
|
332
|
-
- \`type\`: 属性类型(string/boolean/enum/array)
|
|
333
|
-
- \`values\`: 枚举值(仅 enum 类型)
|
|
334
|
-
- \`default\`: 默认值
|
|
335
|
-
- \`required\`: 是否必填
|
|
336
|
-
- \`mapping\`: 值到样式的映射
|
|
337
|
-
- \`hasChildren\`: 是否可包含子组件
|
|
338
|
-
- \`baseClasses\`: 基础样式类(包含占位符)
|
|
339
|
-
|
|
340
|
-
---
|
|
341
|
-
|
|
342
|
-
## ✅ 验证清单
|
|
343
|
-
|
|
344
|
-
生成文件后,请验证:
|
|
345
|
-
|
|
346
|
-
- [ ] 文件已创建: \`docs/component-catalog.json\`
|
|
347
|
-
- [ ] JSON 格式正确(无语法错误)
|
|
348
|
-
- [ ] 包含所有基础组件(Button、Input、Card 等)
|
|
349
|
-
- [ ] 包含所有布局组件(Container、Stack、Grid)
|
|
350
|
-
- [ ] 所有占位符格式正确(\`{path.to.value}\`)
|
|
351
|
-
- [ ] 引用的设计规范路径正确
|
|
352
|
-
|
|
353
|
-
---
|
|
354
|
-
|
|
355
|
-
## 📌 注意事项
|
|
356
|
-
|
|
357
|
-
1. **依赖设计规范**: 必须先运行 \`ui_design_system\` 生成 \`design-system.json\`
|
|
358
|
-
2. **占位符一致性**: 确保占位符路径与 \`design-system.json\` 结构一致
|
|
359
|
-
3. **可扩展性**: 用户可以添加自定义组件到此文件
|
|
360
|
-
4. **版本控制**: 建议将此文件纳入 Git 版本控制
|
|
361
|
-
|
|
362
|
-
---
|
|
363
|
-
|
|
364
|
-
## 🚀 下一步
|
|
365
|
-
|
|
366
|
-
生成组件目录后,可以:
|
|
367
|
-
|
|
368
|
-
1. 使用 \`ui_search --mode=catalog\` 查看可用组件
|
|
369
|
-
2. 使用 \`ui_search --mode=template\` 获取 UI 模板
|
|
370
|
-
3. 使用 \`render_ui\` 渲染最终代码
|
|
371
|
-
|
|
372
|
-
**完整工作流**:
|
|
373
|
-
\`\`\`
|
|
374
|
-
ui_design_system → design-system.json
|
|
375
|
-
↓
|
|
376
|
-
init_component_catalog → component-catalog.json
|
|
377
|
-
↓
|
|
378
|
-
ui_search --mode=template → ui/template.json
|
|
379
|
-
↓
|
|
380
|
-
render_ui → 最终代码(自动应用设计规范)
|
|
381
|
-
\`\`\`
|
|
382
|
-
`;
|
|
383
|
-
/**
|
|
384
|
-
* 初始化组件目录工具
|
|
385
|
-
*/
|
|
386
|
-
export async function initComponentCatalog(args) {
|
|
6
|
+
export async function initComponentCatalog(_args) {
|
|
387
7
|
try {
|
|
388
8
|
const fs = await import('fs/promises');
|
|
389
9
|
const path = await import('path');
|
|
390
10
|
// 检查设计系统文件是否存在
|
|
391
|
-
const
|
|
392
|
-
|
|
393
|
-
const designSystemPath = path.join(docsDir, 'design-system.json');
|
|
11
|
+
const designSystemPath = path.join(process.cwd(), 'docs', 'design-system.json');
|
|
12
|
+
let designSystem = null;
|
|
394
13
|
try {
|
|
395
|
-
await fs.
|
|
14
|
+
const designSystemContent = await fs.readFile(designSystemPath, 'utf-8');
|
|
15
|
+
designSystem = JSON.parse(designSystemContent);
|
|
396
16
|
}
|
|
397
|
-
catch {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
17
|
+
catch (error) {
|
|
18
|
+
const errorData = {
|
|
19
|
+
summary: "未找到设计系统文件",
|
|
20
|
+
components: [],
|
|
21
|
+
catalogPath: '',
|
|
22
|
+
};
|
|
23
|
+
return okStructured(`❌ 未找到设计系统文件
|
|
403
24
|
|
|
404
|
-
请先运行 \`ui_design_system\`
|
|
25
|
+
请先运行 \`ui_design_system\` 生成设计系统。
|
|
405
26
|
|
|
27
|
+
**示例**:
|
|
406
28
|
\`\`\`
|
|
407
29
|
ui_design_system --product_type="SaaS" --stack="react"
|
|
408
30
|
\`\`\`
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
},
|
|
413
|
-
],
|
|
414
|
-
isError: true,
|
|
415
|
-
};
|
|
31
|
+
`, errorData, {
|
|
32
|
+
schema: (await import('../schemas/output/ui-ux-tools.js')).ComponentCatalogSchema,
|
|
33
|
+
});
|
|
416
34
|
}
|
|
417
|
-
//
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
}
|
|
487
|
-
},
|
|
488
|
-
baseClasses: "w-full px-3 py-2 border border-[{colors.neutral.300}] rounded-[{borderRadius.md}] text-[{typography.fontSize.base}] focus:outline-none focus:ring-2 focus:ring-[{colors.primary.500}] focus:border-transparent disabled:bg-[{colors.neutral.50}] disabled:cursor-not-allowed"
|
|
489
|
-
},
|
|
490
|
-
Card: {
|
|
491
|
-
description: "卡片容器",
|
|
492
|
-
props: {
|
|
493
|
-
title: {
|
|
494
|
-
type: "string"
|
|
495
|
-
},
|
|
496
|
-
description: {
|
|
497
|
-
type: "string"
|
|
498
|
-
},
|
|
499
|
-
padding: {
|
|
500
|
-
type: "enum",
|
|
501
|
-
values: ["none", "sm", "md", "lg"],
|
|
502
|
-
default: "md",
|
|
503
|
-
mapping: {
|
|
504
|
-
none: "p-0",
|
|
505
|
-
sm: "p-4",
|
|
506
|
-
md: "p-6",
|
|
507
|
-
lg: "p-8"
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
},
|
|
511
|
-
hasChildren: true,
|
|
512
|
-
baseClasses: "bg-white rounded-[{borderRadius.lg}] shadow-[{shadows.md}] border border-[{colors.neutral.200}]"
|
|
513
|
-
},
|
|
514
|
-
Form: {
|
|
515
|
-
description: "表单容器",
|
|
516
|
-
props: {
|
|
517
|
-
title: {
|
|
518
|
-
type: "string"
|
|
519
|
-
},
|
|
520
|
-
submitLabel: {
|
|
521
|
-
type: "string",
|
|
522
|
-
default: "提交"
|
|
523
|
-
},
|
|
524
|
-
cancelLabel: {
|
|
525
|
-
type: "string"
|
|
526
|
-
}
|
|
527
|
-
},
|
|
528
|
-
hasChildren: true,
|
|
529
|
-
baseClasses: "space-y-[{spacing.scale.4}]"
|
|
530
|
-
},
|
|
531
|
-
Modal: {
|
|
532
|
-
description: "弹窗组件",
|
|
533
|
-
props: {
|
|
534
|
-
title: {
|
|
535
|
-
type: "string",
|
|
536
|
-
required: true
|
|
537
|
-
},
|
|
538
|
-
size: {
|
|
539
|
-
type: "enum",
|
|
540
|
-
values: ["sm", "md", "lg", "xl"],
|
|
541
|
-
default: "md",
|
|
542
|
-
mapping: {
|
|
543
|
-
sm: "max-w-md",
|
|
544
|
-
md: "max-w-lg",
|
|
545
|
-
lg: "max-w-2xl",
|
|
546
|
-
xl: "max-w-4xl"
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
},
|
|
550
|
-
hasChildren: true,
|
|
551
|
-
baseClasses: "relative bg-white rounded-[{borderRadius.lg}] shadow-[{shadows.xl}] w-full mx-4 max-h-[90vh] flex flex-col"
|
|
552
|
-
},
|
|
553
|
-
Table: {
|
|
554
|
-
description: "数据表格",
|
|
555
|
-
props: {
|
|
556
|
-
columns: {
|
|
557
|
-
type: "array",
|
|
558
|
-
required: true
|
|
559
|
-
},
|
|
560
|
-
striped: {
|
|
561
|
-
type: "boolean",
|
|
562
|
-
default: false
|
|
563
|
-
},
|
|
564
|
-
hoverable: {
|
|
565
|
-
type: "boolean",
|
|
566
|
-
default: true
|
|
567
|
-
}
|
|
568
|
-
},
|
|
569
|
-
hasChildren: false,
|
|
570
|
-
baseClasses: "min-w-full divide-y divide-[{colors.neutral.200}]"
|
|
571
|
-
},
|
|
572
|
-
Alert: {
|
|
573
|
-
description: "提示信息",
|
|
574
|
-
props: {
|
|
575
|
-
variant: {
|
|
576
|
-
type: "enum",
|
|
577
|
-
values: ["info", "success", "warning", "error"],
|
|
578
|
-
default: "info",
|
|
579
|
-
mapping: {
|
|
580
|
-
info: "bg-[{colors.primary.50}] text-[{colors.primary.700}] border-[{colors.primary.200}]",
|
|
581
|
-
success: "bg-[{colors.success.50}] text-[{colors.success.700}] border-[{colors.success.200}]",
|
|
582
|
-
warning: "bg-[{colors.warning.50}] text-[{colors.warning.700}] border-[{colors.warning.200}]",
|
|
583
|
-
error: "bg-[{colors.error.50}] text-[{colors.error.700}] border-[{colors.error.200}]"
|
|
584
|
-
}
|
|
585
|
-
},
|
|
586
|
-
title: {
|
|
587
|
-
type: "string"
|
|
588
|
-
},
|
|
589
|
-
message: {
|
|
590
|
-
type: "string",
|
|
591
|
-
required: true
|
|
592
|
-
}
|
|
593
|
-
},
|
|
594
|
-
baseClasses: "p-4 rounded-[{borderRadius.md}] border"
|
|
595
|
-
}
|
|
35
|
+
// 定义基础组件目录
|
|
36
|
+
const components = [
|
|
37
|
+
{
|
|
38
|
+
name: 'Button',
|
|
39
|
+
category: 'interactive',
|
|
40
|
+
description: '按钮组件,支持多种变体和状态',
|
|
41
|
+
props: [
|
|
42
|
+
{ name: 'variant', type: 'string', required: false, default: 'primary' },
|
|
43
|
+
{ name: 'size', type: 'string', required: false, default: 'medium' },
|
|
44
|
+
{ name: 'disabled', type: 'boolean', required: false, default: 'false' },
|
|
45
|
+
{ name: 'onClick', type: 'function', required: false, default: 'undefined' },
|
|
46
|
+
],
|
|
47
|
+
variants: ['primary', 'secondary', 'outline', 'ghost'],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'Input',
|
|
51
|
+
category: 'form',
|
|
52
|
+
description: '输入框组件,支持多种类型和验证',
|
|
53
|
+
props: [
|
|
54
|
+
{ name: 'type', type: 'string', required: false, default: 'text' },
|
|
55
|
+
{ name: 'placeholder', type: 'string', required: false, default: '' },
|
|
56
|
+
{ name: 'value', type: 'string', required: false, default: '' },
|
|
57
|
+
{ name: 'onChange', type: 'function', required: false, default: 'undefined' },
|
|
58
|
+
{ name: 'error', type: 'string', required: false, default: '' },
|
|
59
|
+
],
|
|
60
|
+
variants: ['text', 'email', 'password', 'number'],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'Card',
|
|
64
|
+
category: 'layout',
|
|
65
|
+
description: '卡片容器组件',
|
|
66
|
+
props: [
|
|
67
|
+
{ name: 'title', type: 'string', required: false, default: '' },
|
|
68
|
+
{ name: 'children', type: 'ReactNode', required: true, default: 'undefined' },
|
|
69
|
+
{ name: 'footer', type: 'ReactNode', required: false, default: 'undefined' },
|
|
70
|
+
],
|
|
71
|
+
variants: ['default', 'elevated', 'outlined'],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'Container',
|
|
75
|
+
category: 'layout',
|
|
76
|
+
description: '容器组件,用于页面布局',
|
|
77
|
+
props: [
|
|
78
|
+
{ name: 'maxWidth', type: 'string', required: false, default: 'lg' },
|
|
79
|
+
{ name: 'children', type: 'ReactNode', required: true, default: 'undefined' },
|
|
80
|
+
],
|
|
81
|
+
variants: ['sm', 'md', 'lg', 'xl', 'full'],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'Text',
|
|
85
|
+
category: 'typography',
|
|
86
|
+
description: '文本组件,支持多种样式',
|
|
87
|
+
props: [
|
|
88
|
+
{ name: 'variant', type: 'string', required: false, default: 'body' },
|
|
89
|
+
{ name: 'color', type: 'string', required: false, default: 'default' },
|
|
90
|
+
{ name: 'children', type: 'ReactNode', required: true, default: 'undefined' },
|
|
91
|
+
],
|
|
92
|
+
variants: ['h1', 'h2', 'h3', 'h4', 'body', 'caption'],
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
// 创建组件目录对象
|
|
96
|
+
const catalog = {
|
|
97
|
+
version: '1.0.0',
|
|
98
|
+
designSystem: designSystem.name || 'Design System',
|
|
99
|
+
components,
|
|
100
|
+
tokens: {
|
|
101
|
+
colors: designSystem.colors || {},
|
|
102
|
+
typography: designSystem.typography || {},
|
|
103
|
+
spacing: designSystem.spacing || {},
|
|
596
104
|
},
|
|
597
|
-
layouts: {
|
|
598
|
-
Container: {
|
|
599
|
-
description: "容器布局",
|
|
600
|
-
props: {
|
|
601
|
-
maxWidth: {
|
|
602
|
-
type: "enum",
|
|
603
|
-
values: ["sm", "md", "lg", "xl", "2xl", "full"],
|
|
604
|
-
default: "lg",
|
|
605
|
-
mapping: {
|
|
606
|
-
sm: "max-w-screen-sm",
|
|
607
|
-
md: "max-w-screen-md",
|
|
608
|
-
lg: "max-w-screen-lg",
|
|
609
|
-
xl: "max-w-screen-xl",
|
|
610
|
-
"2xl": "max-w-screen-2xl",
|
|
611
|
-
full: "max-w-full"
|
|
612
|
-
}
|
|
613
|
-
},
|
|
614
|
-
padding: {
|
|
615
|
-
type: "boolean",
|
|
616
|
-
default: true
|
|
617
|
-
}
|
|
618
|
-
},
|
|
619
|
-
hasChildren: true,
|
|
620
|
-
baseClasses: "mx-auto px-4"
|
|
621
|
-
},
|
|
622
|
-
Stack: {
|
|
623
|
-
description: "堆叠布局",
|
|
624
|
-
props: {
|
|
625
|
-
direction: {
|
|
626
|
-
type: "enum",
|
|
627
|
-
values: ["row", "column"],
|
|
628
|
-
default: "column"
|
|
629
|
-
},
|
|
630
|
-
spacing: {
|
|
631
|
-
type: "enum",
|
|
632
|
-
values: [2, 4, 6, 8],
|
|
633
|
-
default: 4,
|
|
634
|
-
mapping: {
|
|
635
|
-
"2": "space-{direction === 'row' ? 'x' : 'y'}-2",
|
|
636
|
-
"4": "space-{direction === 'row' ? 'x' : 'y'}-4",
|
|
637
|
-
"6": "space-{direction === 'row' ? 'x' : 'y'}-6",
|
|
638
|
-
"8": "space-{direction === 'row' ? 'x' : 'y'}-8"
|
|
639
|
-
}
|
|
640
|
-
},
|
|
641
|
-
align: {
|
|
642
|
-
type: "enum",
|
|
643
|
-
values: ["start", "center", "end", "stretch"],
|
|
644
|
-
default: "stretch"
|
|
645
|
-
}
|
|
646
|
-
},
|
|
647
|
-
hasChildren: true,
|
|
648
|
-
baseClasses: "flex"
|
|
649
|
-
},
|
|
650
|
-
Grid: {
|
|
651
|
-
description: "网格布局",
|
|
652
|
-
props: {
|
|
653
|
-
cols: {
|
|
654
|
-
type: "enum",
|
|
655
|
-
values: [1, 2, 3, 4, 6, 12],
|
|
656
|
-
default: 1,
|
|
657
|
-
mapping: {
|
|
658
|
-
"1": "grid-cols-1",
|
|
659
|
-
"2": "grid-cols-2",
|
|
660
|
-
"3": "grid-cols-3",
|
|
661
|
-
"4": "grid-cols-4",
|
|
662
|
-
"6": "grid-cols-6",
|
|
663
|
-
"12": "grid-cols-12"
|
|
664
|
-
}
|
|
665
|
-
},
|
|
666
|
-
gap: {
|
|
667
|
-
type: "enum",
|
|
668
|
-
values: [2, 4, 6, 8],
|
|
669
|
-
default: 4,
|
|
670
|
-
mapping: {
|
|
671
|
-
"2": "gap-2",
|
|
672
|
-
"4": "gap-4",
|
|
673
|
-
"6": "gap-6",
|
|
674
|
-
"8": "gap-8"
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
},
|
|
678
|
-
hasChildren: true,
|
|
679
|
-
baseClasses: "grid"
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
105
|
};
|
|
683
|
-
//
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
${Object.entries(componentCatalog.layouts).map(([name, layout]) => `- **${name}**: ${layout.description}`).join('\n')}
|
|
715
|
-
|
|
716
|
-
**总计**: ${componentCount + layoutCount} 个组件
|
|
717
|
-
|
|
718
|
-
---
|
|
719
|
-
|
|
720
|
-
## 🔑 占位符说明
|
|
721
|
-
|
|
722
|
-
组件样式使用占位符引用设计规范:
|
|
723
|
-
|
|
724
|
-
- \`{colors.primary.500}\` → 主色
|
|
725
|
-
- \`{colors.neutral.300}\` → 中性色
|
|
726
|
-
- \`{borderRadius.md}\` → 圆角
|
|
727
|
-
- \`{shadows.md}\` → 阴影
|
|
728
|
-
- \`{spacing.scale.4}\` → 间距
|
|
729
|
-
- \`{typography.fontSize.base}\` → 字体大小
|
|
730
|
-
|
|
731
|
-
**渲染时自动替换**:
|
|
732
|
-
\`\`\`
|
|
733
|
-
占位符: bg-[{colors.primary.500}]
|
|
734
|
-
替换后: bg-[#3b82f6](从 design-system.json 读取)
|
|
735
|
-
\`\`\`
|
|
736
|
-
|
|
737
|
-
---
|
|
738
|
-
|
|
739
|
-
## 🚀 下一步
|
|
740
|
-
|
|
741
|
-
### 方式 1:一键生成 UI(推荐)
|
|
742
|
-
|
|
743
|
-
\`\`\`bash
|
|
744
|
-
start_ui "登录页面"
|
|
745
|
-
start_ui "用户列表"
|
|
746
|
-
start_ui "设置页面"
|
|
747
|
-
\`\`\`
|
|
748
|
-
|
|
749
|
-
所有页面将自动应用设计规范 ✨
|
|
750
|
-
|
|
751
|
-
### 方式 2:手动步骤
|
|
752
|
-
|
|
753
|
-
\`\`\`bash
|
|
754
|
-
# 第1步:查看组件目录
|
|
755
|
-
ui_search --mode=catalog
|
|
756
|
-
|
|
757
|
-
# 第2步:搜索 UI 模板
|
|
758
|
-
ui_search --mode=template --query="登录表单"
|
|
759
|
-
|
|
760
|
-
# 第3步:渲染代码
|
|
761
|
-
render_ui docs/ui/your-template.json
|
|
762
|
-
\`\`\`
|
|
763
|
-
|
|
764
|
-
---
|
|
765
|
-
|
|
766
|
-
## 💡 自定义组件
|
|
767
|
-
|
|
768
|
-
如需添加自定义组件:
|
|
769
|
-
|
|
770
|
-
1. 编辑 \`docs/ui/component-catalog.json\`
|
|
771
|
-
2. 添加新组件定义
|
|
772
|
-
3. 使用占位符语法(\`{path.to.value}\`)
|
|
773
|
-
4. 重新运行 \`start_ui\` 或 \`render_ui\`
|
|
774
|
-
|
|
775
|
-
**示例**:
|
|
776
|
-
\`\`\`json
|
|
777
|
-
{
|
|
778
|
-
"components": {
|
|
779
|
-
"MyButton": {
|
|
780
|
-
"description": "自定义按钮",
|
|
781
|
-
"props": {
|
|
782
|
-
"color": {
|
|
783
|
-
"type": "string",
|
|
784
|
-
"default": "{colors.primary.500}"
|
|
785
|
-
}
|
|
786
|
-
},
|
|
787
|
-
"baseClasses": "px-4 py-2 rounded-[{borderRadius.md}]"
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
\`\`\`
|
|
792
|
-
`,
|
|
793
|
-
},
|
|
794
|
-
],
|
|
106
|
+
// 确保目录存在
|
|
107
|
+
const catalogDir = path.join(process.cwd(), 'docs', 'ui');
|
|
108
|
+
await fs.mkdir(catalogDir, { recursive: true });
|
|
109
|
+
// 写入组件目录文件
|
|
110
|
+
const catalogPath = path.join(catalogDir, 'component-catalog.json');
|
|
111
|
+
await fs.writeFile(catalogPath, JSON.stringify(catalog, null, 2), 'utf-8');
|
|
112
|
+
const message = `✅ 组件目录已生成
|
|
113
|
+
|
|
114
|
+
**文件路径**: \`docs/ui/component-catalog.json\`
|
|
115
|
+
**组件数量**: ${components.length}
|
|
116
|
+
|
|
117
|
+
**可用组件**:
|
|
118
|
+
${components.map((comp, i) => `${i + 1}. **${comp.name}** (${comp.category}) - ${comp.description}`).join('\n')}
|
|
119
|
+
|
|
120
|
+
**下一步**:
|
|
121
|
+
1. 使用 \`ui_search --mode=catalog\` 查看组件详情
|
|
122
|
+
2. 使用 \`render_ui\` 渲染 UI 模板
|
|
123
|
+
3. 组件会自动使用设计系统中的样式 Token
|
|
124
|
+
|
|
125
|
+
**提示**: 组件定义包含占位符,渲染时会自动替换为设计规范中的实际值。
|
|
126
|
+
`;
|
|
127
|
+
const structuredData = {
|
|
128
|
+
summary: `组件目录已生成 - ${components.length} 个组件`,
|
|
129
|
+
components: components.map(comp => ({
|
|
130
|
+
name: comp.name,
|
|
131
|
+
category: comp.category,
|
|
132
|
+
description: comp.description,
|
|
133
|
+
props: comp.props,
|
|
134
|
+
variants: comp.variants,
|
|
135
|
+
})),
|
|
136
|
+
catalogPath: 'docs/ui/component-catalog.json',
|
|
795
137
|
};
|
|
138
|
+
return okStructured(message, structuredData, {
|
|
139
|
+
schema: (await import('../schemas/output/ui-ux-tools.js')).ComponentCatalogSchema,
|
|
140
|
+
});
|
|
796
141
|
}
|
|
797
142
|
catch (error) {
|
|
798
143
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
text: `❌ 初始化组件目录失败: ${errorMessage}`,
|
|
804
|
-
},
|
|
805
|
-
],
|
|
806
|
-
isError: true,
|
|
144
|
+
const errorData = {
|
|
145
|
+
summary: "组件目录生成失败",
|
|
146
|
+
components: [],
|
|
147
|
+
catalogPath: '',
|
|
807
148
|
};
|
|
149
|
+
return okStructured(`❌ 组件目录生成失败: ${errorMessage}
|
|
150
|
+
|
|
151
|
+
**可能的原因**:
|
|
152
|
+
1. 文件系统权限问题
|
|
153
|
+
2. 磁盘空间不足
|
|
154
|
+
3. 设计系统文件格式错误
|
|
155
|
+
|
|
156
|
+
**建议**:
|
|
157
|
+
1. 检查文件系统权限
|
|
158
|
+
2. 确保有足够的磁盘空间
|
|
159
|
+
3. 重新生成设计系统文件
|
|
160
|
+
`, errorData, {
|
|
161
|
+
schema: (await import('../schemas/output/ui-ux-tools.js')).ComponentCatalogSchema,
|
|
162
|
+
});
|
|
808
163
|
}
|
|
809
164
|
}
|