mcp-probe-kit 3.0.5 → 3.0.7
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 +458 -431
- package/build/index.js +875 -141
- package/build/lib/gitnexus-bridge.d.ts +58 -0
- package/build/lib/gitnexus-bridge.js +379 -0
- package/build/lib/template-loader.js +317 -317
- package/build/lib/tool-execution-context.d.ts +8 -0
- package/build/lib/tool-execution-context.js +20 -0
- package/build/lib/toolset-manager.d.ts +1 -1
- package/build/lib/toolset-manager.js +7 -5
- package/build/schemas/code-analysis-tools.d.ts +46 -0
- package/build/schemas/code-analysis-tools.js +47 -0
- package/build/schemas/git-tools.js +16 -16
- package/build/schemas/index.d.ts +46 -0
- package/build/tools/__tests__/code_insight.unit.test.d.ts +1 -0
- package/build/tools/__tests__/code_insight.unit.test.js +35 -0
- package/build/tools/__tests__/start_bugfix.unit.test.js +14 -14
- package/build/tools/__tests__/start_ui.unit.test.js +11 -11
- package/build/tools/add_feature.js +79 -79
- package/build/tools/ask_user.js +5 -5
- package/build/tools/code_insight.d.ts +8 -0
- package/build/tools/code_insight.js +129 -0
- package/build/tools/index.d.ts +1 -0
- package/build/tools/index.js +1 -0
- package/build/tools/interview.js +9 -9
- package/build/tools/start_bugfix.d.ts +2 -1
- package/build/tools/start_bugfix.js +170 -126
- package/build/tools/start_feature.d.ts +2 -1
- package/build/tools/start_feature.js +156 -112
- package/build/tools/start_onboard.d.ts +2 -1
- package/build/tools/start_onboard.js +57 -51
- package/build/tools/start_product.d.ts +2 -1
- package/build/tools/start_product.js +9 -1
- package/build/tools/start_ralph.d.ts +2 -1
- package/build/tools/start_ralph.js +9 -3
- package/build/tools/start_ui.d.ts +2 -1
- package/build/tools/start_ui.js +102 -88
- package/build/tools/ui-ux-tools.d.ts +2 -1
- package/build/tools/ui-ux-tools.js +19 -3
- package/build/utils/ui-sync.d.ts +6 -2
- package/build/utils/ui-sync.js +125 -29
- package/docs/assets/font/MaterialSymbolsOutlined.codepoints +4102 -0
- package/docs/assets/font/MaterialSymbolsOutlined.ttf +0 -0
- package/docs/assets/font/noto-sans-sc-400.ttf +0 -0
- package/docs/assets/font/noto-sans-sc-700.ttf +0 -0
- package/docs/assets/font/noto-sans-sc-900.ttf +0 -0
- package/docs/assets/js/i18n.js +122 -21
- package/docs/assets/js/tailwind.js +83 -83
- package/docs/data/tools.js +419 -399
- package/docs/debug-i18n.html +163 -0
- package/docs/i18n/all-tools/en.json +157 -0
- package/docs/i18n/all-tools/ja.json +157 -0
- package/docs/i18n/all-tools/ko.json +157 -0
- package/docs/i18n/all-tools/zh-CN.json +157 -0
- package/docs/pages/all-tools.html +514 -352
- package/docs/pages/examples.html +689 -689
- package/docs/pages/getting-started.html +589 -589
- package/docs/pages/migration.html +298 -298
- package/docs/specs/user-auth/design.md +82 -0
- package/docs/specs/user-auth/requirements.md +52 -0
- package/docs/specs/user-auth/tasks.md +55 -0
- package/package.json +5 -5
- package/docs/project-context/architecture.md +0 -0
- package/docs/project-context/how-to-develop.md +0 -313
- package/docs/project-context/how-to-test.md +0 -457
- package/docs/project-context/tech-stack.md +0 -96
- package/docs/project-context.md +0 -53
- package/docs/specs/git-work-report/design.md +0 -568
- package/docs/specs/git-work-report/requirements.md +0 -131
- package/docs/specs/git-work-report/tasks.md +0 -197
package/build/tools/start_ui.js
CHANGED
|
@@ -13,6 +13,7 @@ import { okStructured } from "../lib/response.js";
|
|
|
13
13
|
import { renderOrchestrationHeader } from "../lib/orchestration-guidance.js";
|
|
14
14
|
import { UIReportSchema, RequirementsLoopSchema } from "../schemas/structured-output.js";
|
|
15
15
|
import { detectProjectType } from "../lib/project-detector.js";
|
|
16
|
+
import { reportToolProgress, throwIfAborted, } from "../lib/tool-execution-context.js";
|
|
16
17
|
function inferProductType(description) {
|
|
17
18
|
const text = (description || '').toLowerCase();
|
|
18
19
|
if (/电商|e-?commerce|shop|商城|购物/.test(text))
|
|
@@ -204,11 +205,11 @@ const PROMPT_TEMPLATE_GUIDED = `# 快速开始
|
|
|
204
205
|
在 "## 📚 文档导航" 部分添加:
|
|
205
206
|
|
|
206
207
|
\`\`\`markdown
|
|
207
|
-
### [UI 设计系统](./design-system.md)
|
|
208
|
-
项目的 UI 设计规范,包括颜色、字体、组件样式等
|
|
209
|
-
|
|
210
|
-
### [UI 组件目录](./ui/component-catalog.json)
|
|
211
|
-
可用的 UI 组件及其属性定义
|
|
208
|
+
### [UI 设计系统](./design-system.md)
|
|
209
|
+
项目的 UI 设计规范,包括颜色、字体、组件样式等
|
|
210
|
+
|
|
211
|
+
### [UI 组件目录](./ui/component-catalog.json)
|
|
212
|
+
可用的 UI 组件及其属性定义
|
|
212
213
|
\`\`\`
|
|
213
214
|
|
|
214
215
|
在 "## 💡 开发时查看对应文档" 部分的 "添加新功能" 下添加:
|
|
@@ -238,19 +239,19 @@ A: 不需要。如果文件已存在,直接跳过步骤 1。
|
|
|
238
239
|
**Q: 如何使用自定义模板?**
|
|
239
240
|
A: 在 \`docs/ui/\` 目录创建 JSON 模板文件,然后在步骤 4 中指定模板路径。
|
|
240
241
|
`;
|
|
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\` 索引中
|
|
242
|
+
const PROMPT_TEMPLATE_STRICT = `# UI 开发编排(严格)
|
|
243
|
+
|
|
244
|
+
**职责说明**: 本工具仅提供执行指导,不执行实际操作。请按顺序调用以下 MCP 工具。
|
|
245
|
+
|
|
246
|
+
## ✅ 执行计划
|
|
247
|
+
|
|
248
|
+
1. 检查 \`docs/project-context.md\`,缺失则调用 \`init_project_context\`
|
|
249
|
+
2. 检查 \`docs/design-system.md\`,缺失则调用 \`ui_design_system --product_type="{productType}" --stack="{framework}"\`
|
|
250
|
+
3. 检查 \`docs/ui/component-catalog.json\`,缺失则调用 \`init_component_catalog\`
|
|
251
|
+
4. \`ui_search --mode=template --query="{description}"\`
|
|
252
|
+
5. 选择模板并保存到 \`docs/ui/{templateName}.json\`
|
|
253
|
+
6. \`render_ui --template="docs/ui/{templateName}.json" --framework="{framework}"\`
|
|
254
|
+
7. 将生成的 UI 文档添加到 \`docs/project-context.md\` 索引中
|
|
254
255
|
|
|
255
256
|
---
|
|
256
257
|
|
|
@@ -264,16 +265,16 @@ const PROMPT_TEMPLATE_STRICT = `# UI 开发编排(严格)
|
|
|
264
265
|
|
|
265
266
|
## 步骤 2: 生成设计系统(如不存在)
|
|
266
267
|
|
|
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\`
|
|
268
|
+
**检查**: \`docs/design-system.md\`
|
|
269
|
+
**缺失则调用**: \`ui_design_system\`
|
|
270
|
+
\`\`\`json
|
|
271
|
+
{
|
|
272
|
+
"product_type": "{productType}",
|
|
273
|
+
"stack": "{framework}",
|
|
274
|
+
"description": "{description}"
|
|
275
|
+
}
|
|
276
|
+
\`\`\`
|
|
277
|
+
**预期输出**: \`docs/design-system.json\`、\`docs/design-system.md\`
|
|
277
278
|
|
|
278
279
|
---
|
|
279
280
|
|
|
@@ -285,35 +286,35 @@ const PROMPT_TEMPLATE_STRICT = `# UI 开发编排(严格)
|
|
|
285
286
|
|
|
286
287
|
---
|
|
287
288
|
|
|
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\`
|
|
289
|
+
## 步骤 4: 搜索模板
|
|
290
|
+
|
|
291
|
+
**工具**: \`ui_search\`
|
|
292
|
+
\`\`\`json
|
|
293
|
+
{ "mode": "template", "query": "{description}" }
|
|
294
|
+
\`\`\`
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## 步骤 5: 保存模板文件
|
|
299
|
+
|
|
300
|
+
**操作**: 从搜索结果选择模板或创建最小模板
|
|
301
|
+
|
|
302
|
+
**保存路径**: \`docs/ui/{templateName}.json\`
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## 步骤 6: 渲染代码
|
|
307
|
+
|
|
308
|
+
**工具**: \`render_ui\`
|
|
309
|
+
\`\`\`json
|
|
310
|
+
{ "template": "docs/ui/{templateName}.json", "framework": "{framework}" }
|
|
311
|
+
\`\`\`
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## 步骤 7: 更新项目上下文索引
|
|
316
|
+
|
|
317
|
+
将 UI 文档链接添加到 \`docs/project-context.md\`
|
|
317
318
|
`;
|
|
318
319
|
const LOOP_PROMPT_TEMPLATE_GUIDED = `# 🧭 UI 需求澄清与补全(Requirements Loop)
|
|
319
320
|
|
|
@@ -344,8 +345,8 @@ UI 需求:{description}
|
|
|
344
345
|
---
|
|
345
346
|
|
|
346
347
|
## ✅ 结束后继续
|
|
347
|
-
当满足结束条件时,按 delegated plan 执行:
|
|
348
|
-
- 设计系统 → 组件目录 → 模板搜索 → 保存模板 → 渲染代码 → 更新上下文
|
|
348
|
+
当满足结束条件时,按 delegated plan 执行:
|
|
349
|
+
- 设计系统 → 组件目录 → 模板搜索 → 保存模板 → 渲染代码 → 更新上下文
|
|
349
350
|
|
|
350
351
|
---
|
|
351
352
|
|
|
@@ -374,7 +375,7 @@ UI 需求:{description}
|
|
|
374
375
|
---
|
|
375
376
|
|
|
376
377
|
## ✅ 结束后继续
|
|
377
|
-
当满足结束条件时,按 delegated plan 执行 UI 计划
|
|
378
|
+
当满足结束条件时,按 delegated plan 执行 UI 计划
|
|
378
379
|
|
|
379
380
|
---
|
|
380
381
|
|
|
@@ -422,8 +423,10 @@ function getFrameworkFromContext(projectRoot) {
|
|
|
422
423
|
/**
|
|
423
424
|
* 统一 UI 开发编排工具
|
|
424
425
|
*/
|
|
425
|
-
export async function startUi(args) {
|
|
426
|
+
export async function startUi(args, context) {
|
|
426
427
|
try {
|
|
428
|
+
throwIfAborted(context?.signal, "start_ui 已取消");
|
|
429
|
+
await reportToolProgress(context, 10, "start_ui: 解析参数与检测项目框架");
|
|
427
430
|
const projectRoot = process.cwd();
|
|
428
431
|
// 优先从 project-context.md 读取框架信息
|
|
429
432
|
let detectedFramework = 'html'; // 默认值
|
|
@@ -494,6 +497,8 @@ export async function startUi(args) {
|
|
|
494
497
|
const assumptionCap = getNumber(parsedArgs.loop_assumption_cap, 3);
|
|
495
498
|
let templateName = getString(parsedArgs.template);
|
|
496
499
|
templateName = normalizeTemplateName(templateName || description || 'ui-template', 'ui-template');
|
|
500
|
+
throwIfAborted(context?.signal, "start_ui 已取消");
|
|
501
|
+
await reportToolProgress(context, 35, "start_ui: 参数解析完成");
|
|
497
502
|
const profileDecision = resolveTemplateProfile(rawProfile, description || "");
|
|
498
503
|
const templateMeta = {
|
|
499
504
|
profile: profileDecision.resolved,
|
|
@@ -538,6 +543,8 @@ start_ui "用户列表" --mode=auto
|
|
|
538
543
|
}
|
|
539
544
|
// requirements loop 模式
|
|
540
545
|
if (requirementsMode === "loop") {
|
|
546
|
+
throwIfAborted(context?.signal, "start_ui(loop) 已取消");
|
|
547
|
+
await reportToolProgress(context, 70, "start_ui: 生成 loop 计划");
|
|
541
548
|
if (!description) {
|
|
542
549
|
return {
|
|
543
550
|
content: [
|
|
@@ -691,6 +698,7 @@ start_ui <描述> --requirements_mode=loop
|
|
|
691
698
|
template: templateMeta,
|
|
692
699
|
},
|
|
693
700
|
};
|
|
701
|
+
await reportToolProgress(context, 95, "start_ui: loop 输出已生成");
|
|
694
702
|
return okStructured(guide, loopReport, {
|
|
695
703
|
schema: RequirementsLoopSchema,
|
|
696
704
|
note: 'AI 应按轮次澄清 UI 需求并更新结构化输出,满足结束条件后再执行 UI 计划',
|
|
@@ -698,6 +706,8 @@ start_ui <描述> --requirements_mode=loop
|
|
|
698
706
|
}
|
|
699
707
|
// 自动模式实现
|
|
700
708
|
if (mode === "auto") {
|
|
709
|
+
throwIfAborted(context?.signal, "start_ui(auto) 已取消");
|
|
710
|
+
await reportToolProgress(context, 55, "start_ui: 生成智能推荐");
|
|
701
711
|
// 1. 获取推理引擎
|
|
702
712
|
const engine = await getReasoningEngine();
|
|
703
713
|
// 2. 构造设计请求
|
|
@@ -708,13 +718,15 @@ start_ui <描述> --requirements_mode=loop
|
|
|
708
718
|
};
|
|
709
719
|
// 3. 生成推荐
|
|
710
720
|
const recommendation = engine.generateRecommendation(request);
|
|
721
|
+
throwIfAborted(context?.signal, "start_ui(auto) 已取消");
|
|
722
|
+
await reportToolProgress(context, 80, "start_ui: 智能计划已生成");
|
|
711
723
|
// 4. 提取推理结果
|
|
712
724
|
const inferredProductType = recommendation.target;
|
|
713
725
|
const inferredKeywords = recommendation.style.keywords.join(", ");
|
|
714
726
|
const inferredStack = framework; // 保持用户指定的技术栈,或默认为 react
|
|
715
727
|
// 5. 生成智能执行计划
|
|
716
728
|
const searchQuery = description || templateName;
|
|
717
|
-
const smartPlanGuided = `# 🚀 智能 UI 开发计划
|
|
729
|
+
const smartPlanGuided = `# 🚀 智能 UI 开发计划
|
|
718
730
|
|
|
719
731
|
基于您的描述 "**${description}**",AI 引擎已为您规划了最佳开发路径。
|
|
720
732
|
|
|
@@ -746,25 +758,25 @@ ui_design_system --product_type="${inferredProductType}" --stack="${inferredStac
|
|
|
746
758
|
init_component_catalog
|
|
747
759
|
\`\`\`
|
|
748
760
|
|
|
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\` 的文档导航部分。
|
|
761
|
+
### 4. 生成 UI 模板 📄
|
|
762
|
+
\`\`\`bash
|
|
763
|
+
# 搜索现有模板或生成新模板
|
|
764
|
+
ui_search --mode=template --query="${searchQuery}"
|
|
765
|
+
\`\`\`
|
|
766
|
+
|
|
767
|
+
### 5. 保存模板文件 🧩
|
|
768
|
+
\`\`\`bash
|
|
769
|
+
# 将选中的模板保存到本地
|
|
770
|
+
# 目标路径:docs/ui/${templateName}.json
|
|
771
|
+
\`\`\`
|
|
772
|
+
|
|
773
|
+
### 6. 渲染代码 💻
|
|
774
|
+
\`\`\`bash
|
|
775
|
+
render_ui docs/ui/${templateName}.json --framework="${inferredStack}"
|
|
776
|
+
\`\`\`
|
|
777
|
+
|
|
778
|
+
### 7. 更新项目上下文 📝
|
|
779
|
+
将生成的 UI 文档链接添加到 \`docs/project-context.md\` 的文档导航部分。
|
|
768
780
|
|
|
769
781
|
---
|
|
770
782
|
|
|
@@ -785,13 +797,13 @@ ${recommendation.reasoning}
|
|
|
785
797
|
|
|
786
798
|
## 📋 执行步骤
|
|
787
799
|
|
|
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 索引
|
|
800
|
+
1) init_project_context
|
|
801
|
+
2) ui_design_system --product_type="${inferredProductType}" --stack="${inferredStack}" --keywords="${inferredKeywords}" --description="${description}"
|
|
802
|
+
3) init_component_catalog
|
|
803
|
+
4) ui_search --mode=template --query="${searchQuery}"
|
|
804
|
+
5) 保存模板到 docs/ui/${templateName}.json
|
|
805
|
+
6) render_ui docs/ui/${templateName}.json --framework="${inferredStack}"
|
|
806
|
+
7) 更新 project-context.md 索引
|
|
795
807
|
`;
|
|
796
808
|
const plan = {
|
|
797
809
|
mode: 'delegated',
|
|
@@ -931,6 +943,7 @@ ${recommendation.reasoning}
|
|
|
931
943
|
template: templateMeta,
|
|
932
944
|
},
|
|
933
945
|
};
|
|
946
|
+
await reportToolProgress(context, 95, "start_ui: auto 输出已生成");
|
|
934
947
|
return okStructured(smartPlan, uiReport, {
|
|
935
948
|
schema: UIReportSchema,
|
|
936
949
|
note: 'AI 应该按照智能计划执行步骤,并在每个步骤完成后更新 structuredContent',
|
|
@@ -1121,6 +1134,7 @@ start_ui "设置页面" --framework=react
|
|
|
1121
1134
|
template: templateMeta,
|
|
1122
1135
|
},
|
|
1123
1136
|
};
|
|
1137
|
+
await reportToolProgress(context, 95, "start_ui: manual 输出已生成");
|
|
1124
1138
|
return okStructured(guide, uiReport, {
|
|
1125
1139
|
schema: UIReportSchema,
|
|
1126
1140
|
note: 'AI 应该按照指南执行步骤,并在每个步骤完成后更新 structuredContent',
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* 使用模板类实现文档生成的原子化
|
|
6
6
|
*/
|
|
7
7
|
import { DesignReasoningEngine, DesignSystemRecommendation } from '../utils/design-reasoning-engine.js';
|
|
8
|
+
import { type ToolExecutionContext } from '../lib/tool-execution-context.js';
|
|
8
9
|
/**
|
|
9
10
|
* 文件索引接口
|
|
10
11
|
* 定义需要创建的文件及其元数据
|
|
@@ -77,4 +78,4 @@ export declare function uiSearch(args: any): Promise<import("../lib/response.js"
|
|
|
77
78
|
/**
|
|
78
79
|
* UI 数据同步工具
|
|
79
80
|
*/
|
|
80
|
-
export declare function syncUiData(args: any): Promise<import("../lib/response.js").ToolResponse>;
|
|
81
|
+
export declare function syncUiData(args: any, context?: ToolExecutionContext): Promise<import("../lib/response.js").ToolResponse>;
|
|
@@ -10,6 +10,7 @@ import { ASCIIBoxFormatter } from '../utils/ascii-box-formatter.js';
|
|
|
10
10
|
import { syncUIDataToCache } from '../utils/ui-sync.js';
|
|
11
11
|
import { formatDesignSystemJson } from '../utils/design-system-json-formatter.js';
|
|
12
12
|
import { okStructured } from '../lib/response.js';
|
|
13
|
+
import { reportToolProgress, throwIfAborted, } from '../lib/tool-execution-context.js';
|
|
13
14
|
// 全局数据加载器实例
|
|
14
15
|
let dataLoader = null;
|
|
15
16
|
let reasoningEngine = null;
|
|
@@ -734,17 +735,22 @@ ${formattedResults}
|
|
|
734
735
|
/**
|
|
735
736
|
* UI 数据同步工具
|
|
736
737
|
*/
|
|
737
|
-
export async function syncUiData(args) {
|
|
738
|
+
export async function syncUiData(args, context) {
|
|
738
739
|
try {
|
|
740
|
+
throwIfAborted(context?.signal, 'sync_ui_data 已取消');
|
|
741
|
+
await reportToolProgress(context, 5, 'sync_ui_data: 开始同步流程');
|
|
739
742
|
const force = args.force || false;
|
|
740
743
|
const verbose = args.verbose || false;
|
|
741
744
|
// 检查是否需要更新
|
|
742
745
|
if (!force) {
|
|
746
|
+
throwIfAborted(context?.signal, 'sync_ui_data 已取消');
|
|
747
|
+
await reportToolProgress(context, 15, 'sync_ui_data: 检查上游版本');
|
|
743
748
|
const loader = await getDataLoader();
|
|
744
749
|
const cacheManager = loader.getCacheManager();
|
|
745
750
|
try {
|
|
746
751
|
const updateInfo = await cacheManager.checkUpdate();
|
|
747
752
|
if (!updateInfo.hasUpdate) {
|
|
753
|
+
await reportToolProgress(context, 100, 'sync_ui_data: 数据已是最新');
|
|
748
754
|
const upToDateData = {
|
|
749
755
|
summary: "UI/UX 数据已是最新版本",
|
|
750
756
|
status: 'success',
|
|
@@ -769,8 +775,17 @@ export async function syncUiData(args) {
|
|
|
769
775
|
}
|
|
770
776
|
}
|
|
771
777
|
// 执行同步
|
|
772
|
-
|
|
778
|
+
throwIfAborted(context?.signal, 'sync_ui_data 已取消');
|
|
779
|
+
await reportToolProgress(context, 30, 'sync_ui_data: 下载并处理数据');
|
|
780
|
+
await syncUIDataToCache(force, verbose, {
|
|
781
|
+
signal: context?.signal,
|
|
782
|
+
onProgress: async (progress, message) => {
|
|
783
|
+
await reportToolProgress(context, 30 + Math.round(progress * 0.6), `sync_ui_data: ${message}`);
|
|
784
|
+
},
|
|
785
|
+
});
|
|
773
786
|
// 重新加载数据
|
|
787
|
+
throwIfAborted(context?.signal, 'sync_ui_data 已取消');
|
|
788
|
+
await reportToolProgress(context, 92, 'sync_ui_data: 重载本地缓存');
|
|
774
789
|
if (dataLoader) {
|
|
775
790
|
await dataLoader.reload();
|
|
776
791
|
}
|
|
@@ -789,7 +804,8 @@ export async function syncUiData(args) {
|
|
|
789
804
|
},
|
|
790
805
|
timestamp: new Date().toISOString(),
|
|
791
806
|
};
|
|
792
|
-
|
|
807
|
+
await reportToolProgress(context, 100, 'sync_ui_data: 同步完成');
|
|
808
|
+
return okStructured(`✅ UI/UX 数据同步成功
|
|
793
809
|
|
|
794
810
|
数据已更新到缓存目录: ${cacheDir}
|
|
795
811
|
|
package/build/utils/ui-sync.d.ts
CHANGED
|
@@ -3,11 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 从 npm 包 uipro-cli 同步数据到缓存目录
|
|
5
5
|
*/
|
|
6
|
+
export interface SyncRuntimeOptions {
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
onProgress?: (progress: number, message: string) => Promise<void> | void;
|
|
9
|
+
}
|
|
6
10
|
/**
|
|
7
11
|
* 同步 UI/UX 数据到指定目录(通用函数)
|
|
8
12
|
*/
|
|
9
|
-
export declare function syncUIDataTo(outputDir: string, verbose?: boolean): Promise<void>;
|
|
13
|
+
export declare function syncUIDataTo(outputDir: string, verbose?: boolean, options?: SyncRuntimeOptions): Promise<void>;
|
|
10
14
|
/**
|
|
11
15
|
* 同步 UI/UX 数据到缓存
|
|
12
16
|
*/
|
|
13
|
-
export declare function syncUIDataToCache(force?: boolean, verbose?: boolean): Promise<void>;
|
|
17
|
+
export declare function syncUIDataToCache(force?: boolean, verbose?: boolean, options?: SyncRuntimeOptions): Promise<void>;
|