mcp-probe-kit 1.8.1 → 1.9.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.
Files changed (58) hide show
  1. package/build/tools/add_feature.d.ts +0 -11
  2. package/build/tools/add_feature.js +19 -10
  3. package/build/tools/analyze_project.js +76 -61
  4. package/build/tools/check_deps.d.ts +1 -1
  5. package/build/tools/check_deps.js +2 -2
  6. package/build/tools/code_review.js +15 -2
  7. package/build/tools/convert.js +18 -3
  8. package/build/tools/css_order.js +55 -55
  9. package/build/tools/debug.js +14 -2
  10. package/build/tools/design2code.d.ts +2 -11
  11. package/build/tools/design2code.js +21 -4
  12. package/build/tools/detect_shell.js +15 -2
  13. package/build/tools/estimate.js +21 -4
  14. package/build/tools/explain.js +15 -2
  15. package/build/tools/fix.js +15 -2
  16. package/build/tools/fix_bug.js +24 -5
  17. package/build/tools/gen_mock.js +24 -5
  18. package/build/tools/gen_skill.d.ts +0 -3
  19. package/build/tools/gen_skill.js +21 -4
  20. package/build/tools/genapi.js +15 -2
  21. package/build/tools/genchangelog.js +18 -3
  22. package/build/tools/gencommit.js +16 -2
  23. package/build/tools/gendoc.js +18 -3
  24. package/build/tools/genpr.js +15 -2
  25. package/build/tools/genreadme.js +15 -2
  26. package/build/tools/gensql.js +15 -2
  27. package/build/tools/gentest.js +15 -2
  28. package/build/tools/genui.js +15 -2
  29. package/build/tools/init_project.js +15 -2
  30. package/build/tools/init_project_context.d.ts +0 -6
  31. package/build/tools/init_project_context.js +12 -2
  32. package/build/tools/perf.js +15 -2
  33. package/build/tools/refactor.js +15 -2
  34. package/build/tools/resolve_conflict.js +12 -1
  35. package/build/tools/security_scan.js +18 -3
  36. package/build/tools/split.js +15 -2
  37. package/build/tools/start_api.d.ts +0 -6
  38. package/build/tools/start_api.js +18 -3
  39. package/build/tools/start_bugfix.d.ts +0 -6
  40. package/build/tools/start_bugfix.js +15 -2
  41. package/build/tools/start_doc.d.ts +0 -6
  42. package/build/tools/start_doc.js +20 -3
  43. package/build/tools/start_feature.d.ts +0 -6
  44. package/build/tools/start_feature.js +18 -3
  45. package/build/tools/start_onboard.d.ts +0 -6
  46. package/build/tools/start_onboard.js +15 -2
  47. package/build/tools/start_refactor.d.ts +0 -6
  48. package/build/tools/start_refactor.js +15 -2
  49. package/build/tools/start_release.d.ts +0 -6
  50. package/build/tools/start_release.js +18 -3
  51. package/build/tools/start_review.d.ts +0 -6
  52. package/build/tools/start_review.js +15 -2
  53. package/build/utils/parseArgs.d.ts +39 -0
  54. package/build/utils/parseArgs.js +153 -0
  55. package/docs/HOW_TO_TRIGGER.html +56 -0
  56. package/docs/MCP-Probe-Kit-/344/275/277/347/224/250/346/211/213/345/206/214.html +420 -0
  57. package/docs/MCP-Probe-Kit-/344/275/277/347/224/250/346/211/213/345/206/214.md +609 -0
  58. package/package.json +1 -1
@@ -1,14 +1,3 @@
1
- /**
2
- * add_feature 工具
3
- *
4
- * 功能:为已有项目添加新功能的规格文档
5
- * 模式:指令生成器模式 - 返回详细的生成指南,由 AI 执行实际操作
6
- *
7
- * 输出文件:
8
- * - docs/specs/{feature_name}/requirements.md - 需求文档
9
- * - docs/specs/{feature_name}/design.md - 设计文档
10
- * - docs/specs/{feature_name}/tasks.md - 任务清单
11
- */
12
1
  /**
13
2
  * add_feature 工具实现
14
3
  *
@@ -1,3 +1,4 @@
1
+ import { parseArgs, getString, validateRequired } from "../utils/parseArgs.js";
1
2
  /**
2
3
  * add_feature 工具
3
4
  *
@@ -423,17 +424,25 @@ interface [ModelName] {
423
424
  */
424
425
  export async function addFeature(args) {
425
426
  try {
427
+ // 智能参数解析,支持自然语言输入
428
+ const parsedArgs = parseArgs(args, {
429
+ defaultValues: {
430
+ feature_name: "",
431
+ description: "",
432
+ docs_dir: DEFAULT_DOCS_DIR,
433
+ },
434
+ primaryField: "description", // 纯文本输入默认映射到 description 字段
435
+ fieldAliases: {
436
+ feature_name: ["name", "feature", "功能名", "功能名称"],
437
+ description: ["desc", "requirement", "描述", "需求"],
438
+ docs_dir: ["dir", "output", "目录", "文档目录"],
439
+ },
440
+ });
441
+ const featureName = getString(parsedArgs.feature_name);
442
+ const description = getString(parsedArgs.description);
443
+ const docsDir = getString(parsedArgs.docs_dir) || DEFAULT_DOCS_DIR;
426
444
  // 验证必填参数
427
- const featureName = args?.feature_name;
428
- const description = args?.description;
429
- if (!featureName) {
430
- throw new Error("缺少必填参数: feature_name(功能名称)");
431
- }
432
- if (!description) {
433
- throw new Error("缺少必填参数: description(功能描述)");
434
- }
435
- // 解析可选参数
436
- const docsDir = args?.docs_dir || DEFAULT_DOCS_DIR;
445
+ validateRequired(parsedArgs, ["feature_name", "description"]);
437
446
  // 构建指南文本(替换占位符)
438
447
  const guide = PROMPT_TEMPLATE
439
448
  .replace(/{feature_name}/g, featureName)
@@ -1,10 +1,25 @@
1
+ import { parseArgs, getString, getNumber, getBoolean } from "../utils/parseArgs.js";
1
2
  import { readFileSync, readdirSync, statSync, existsSync } from 'fs';
2
3
  import { join, extname } from 'path';
3
4
  import { VERSION } from '../version.js';
4
5
  export async function analyzeProject(args) {
5
- const projectPath = args.project_path || process.cwd();
6
- const maxDepth = args.max_depth || 5;
7
- const includeContent = args.include_content !== false;
6
+ // 智能参数解析,支持自然语言输入
7
+ const parsedArgs = parseArgs(args, {
8
+ defaultValues: {
9
+ project_path: process.cwd(),
10
+ max_depth: 5,
11
+ include_content: true,
12
+ },
13
+ primaryField: "project_path", // 纯文本输入默认映射到 project_path 字段
14
+ fieldAliases: {
15
+ project_path: ["path", "dir", "directory", "路径", "项目路径"],
16
+ max_depth: ["depth", "level", "深度", "层级"],
17
+ include_content: ["content", "with_content", "包含内容"],
18
+ },
19
+ });
20
+ const projectPath = getString(parsedArgs.project_path) || process.cwd();
21
+ const maxDepth = getNumber(parsedArgs.max_depth, 5);
22
+ const includeContent = getBoolean(parsedArgs.include_content, true);
8
23
  try {
9
24
  console.error(`开始分析项目: ${projectPath}`);
10
25
  const analysis = await performProjectAnalysis(projectPath, maxDepth, includeContent);
@@ -12,68 +27,68 @@ export async function analyzeProject(args) {
12
27
  content: [
13
28
  {
14
29
  type: "text",
15
- text: `# 📊 项目分析报告
16
-
17
- ## 🏗️ 项目概览
18
- - **项目名称**: ${analysis.projectStructure.name}
19
- - **项目类型**: ${analysis.projectStructure.type}
20
- - **技术栈**: ${analysis.projectStructure.framework}
21
- - **主要语言**: ${analysis.projectStructure.language}
22
- - **包管理器**: ${analysis.projectStructure.packageManager}
23
-
24
- ## 📁 目录结构
25
- \`\`\`
26
- ${analysis.directoryTree}
27
- \`\`\`
28
-
29
- ## 🔑 关键文件
30
- ${analysis.keyFiles.map(file => `### ${file.path}
31
- **用途**: ${file.purpose}
32
- ${includeContent ? `\`\`\`${getFileExtension(file.path)}
33
- ${file.content.substring(0, 500)}${file.content.length > 500 ? '\n...' : ''}
34
- \`\`\`` : ''}`).join('\n\n')}
35
-
36
- ## 📦 依赖分析
37
- - **生产依赖**: ${analysis.dependencies.production.length} 个
38
- - **开发依赖**: ${analysis.dependencies.development.length} 个
39
- - **总依赖数**: ${analysis.dependencies.total} 个
40
-
41
- ### 主要依赖
42
- ${analysis.dependencies.production.slice(0, 10).map(dep => `- ${dep}`).join('\n')}
43
-
44
- ## 📈 代码指标
45
- - **总文件数**: ${analysis.codeMetrics.totalFiles}
46
- - **总行数**: ${analysis.codeMetrics.totalLines}
47
- ${analysis.codeMetrics.skippedFiles > 0 ? `- **跳过文件**: ${analysis.codeMetrics.skippedFiles} 个(过大或无法读取)` : ''}
48
- - **文件类型分布**:
30
+ text: `# 📊 项目分析报告
31
+
32
+ ## 🏗️ 项目概览
33
+ - **项目名称**: ${analysis.projectStructure.name}
34
+ - **项目类型**: ${analysis.projectStructure.type}
35
+ - **技术栈**: ${analysis.projectStructure.framework}
36
+ - **主要语言**: ${analysis.projectStructure.language}
37
+ - **包管理器**: ${analysis.projectStructure.packageManager}
38
+
39
+ ## 📁 目录结构
40
+ \`\`\`
41
+ ${analysis.directoryTree}
42
+ \`\`\`
43
+
44
+ ## 🔑 关键文件
45
+ ${analysis.keyFiles.map(file => `### ${file.path}
46
+ **用途**: ${file.purpose}
47
+ ${includeContent ? `\`\`\`${getFileExtension(file.path)}
48
+ ${file.content.substring(0, 500)}${file.content.length > 500 ? '\n...' : ''}
49
+ \`\`\`` : ''}`).join('\n\n')}
50
+
51
+ ## 📦 依赖分析
52
+ - **生产依赖**: ${analysis.dependencies.production.length} 个
53
+ - **开发依赖**: ${analysis.dependencies.development.length} 个
54
+ - **总依赖数**: ${analysis.dependencies.total} 个
55
+
56
+ ### 主要依赖
57
+ ${analysis.dependencies.production.slice(0, 10).map(dep => `- ${dep}`).join('\n')}
58
+
59
+ ## 📈 代码指标
60
+ - **总文件数**: ${analysis.codeMetrics.totalFiles}
61
+ - **总行数**: ${analysis.codeMetrics.totalLines}
62
+ ${analysis.codeMetrics.skippedFiles > 0 ? `- **跳过文件**: ${analysis.codeMetrics.skippedFiles} 个(过大或无法读取)` : ''}
63
+ - **文件类型分布**:
49
64
  ${Object.entries(analysis.codeMetrics.fileTypes)
50
65
  .sort(([, a], [, b]) => b - a)
51
66
  .slice(0, 10)
52
67
  .map(([type, count]) => ` - ${type}: ${count} 个文件`)
53
- .join('\n')}
54
- ${Object.keys(analysis.codeMetrics.fileTypes).length > 10 ? ' - ... (更多类型已省略)' : ''}
55
-
56
- ### 最大文件
57
- ${analysis.codeMetrics.largestFiles.slice(0, 5).map(file => `- ${file.path} (${file.lines} 行)`).join('\n')}
58
-
59
- ## 🏛️ 架构分析
60
- - **设计模式**: ${analysis.architecture.patterns.join(', ')}
61
- - **入口文件**: ${analysis.architecture.entryPoints.join(', ')}
62
- - **核心模块**: ${analysis.architecture.mainModules.join(', ')}
63
-
64
- ## 📋 项目总结
65
- **项目目的**: ${analysis.summary.purpose}
66
- **复杂度**: ${analysis.summary.complexity}
67
- **建议**:
68
- ${analysis.summary.recommendations.map(rec => `- ${rec}`).join('\n')}
69
-
70
- ---
71
- *分析完成时间: ${new Date().toLocaleString('zh-CN')}*
72
- *分析工具: MCP Probe Kit v${VERSION}*
73
-
74
- **分析说明**:
75
- - 大型项目会自动采样分析,限制最多扫描 5000 个文件
76
- - 已自动忽略以下目录: \`node_modules\`, \`dist\`, \`build\`, \`.git\`, \`coverage\`, \`.next\`, \`.nuxt\`, \`vendor\` 等
68
+ .join('\n')}
69
+ ${Object.keys(analysis.codeMetrics.fileTypes).length > 10 ? ' - ... (更多类型已省略)' : ''}
70
+
71
+ ### 最大文件
72
+ ${analysis.codeMetrics.largestFiles.slice(0, 5).map(file => `- ${file.path} (${file.lines} 行)`).join('\n')}
73
+
74
+ ## 🏛️ 架构分析
75
+ - **设计模式**: ${analysis.architecture.patterns.join(', ')}
76
+ - **入口文件**: ${analysis.architecture.entryPoints.join(', ')}
77
+ - **核心模块**: ${analysis.architecture.mainModules.join(', ')}
78
+
79
+ ## 📋 项目总结
80
+ **项目目的**: ${analysis.summary.purpose}
81
+ **复杂度**: ${analysis.summary.complexity}
82
+ **建议**:
83
+ ${analysis.summary.recommendations.map(rec => `- ${rec}`).join('\n')}
84
+
85
+ ---
86
+ *分析完成时间: ${new Date().toLocaleString('zh-CN')}*
87
+ *分析工具: MCP Probe Kit v${VERSION}*
88
+
89
+ **分析说明**:
90
+ - 大型项目会自动采样分析,限制最多扫描 5000 个文件
91
+ - 已自动忽略以下目录: \`node_modules\`, \`dist\`, \`build\`, \`.git\`, \`coverage\`, \`.next\`, \`.nuxt\`, \`vendor\` 等
77
92
  - 单个文件大小限制: 1MB,超过则跳过`,
78
93
  },
79
94
  ],
@@ -1,4 +1,4 @@
1
- export declare function checkDeps(args: any): Promise<{
1
+ export declare function checkDeps(_args: any): Promise<{
2
2
  content: {
3
3
  type: string;
4
4
  text: string;
@@ -1,5 +1,5 @@
1
- // check_deps 工具实现
2
- export async function checkDeps(args) {
1
+ // check_deps 工具实现(无参数)
2
+ export async function checkDeps(_args) {
3
3
  try {
4
4
  const message = `请分析项目依赖的健康状况:
5
5
 
@@ -1,8 +1,21 @@
1
+ import { parseArgs, getString } from "../utils/parseArgs.js";
1
2
  // code_review 工具实现
2
3
  export async function codeReview(args) {
3
4
  try {
4
- const code = args?.code || "";
5
- const focus = args?.focus || "all"; // quality, security, performance, all
5
+ // 智能参数解析,支持自然语言输入
6
+ const parsedArgs = parseArgs(args, {
7
+ defaultValues: {
8
+ code: "",
9
+ focus: "all",
10
+ },
11
+ primaryField: "code", // 纯文本输入默认映射到 code 字段
12
+ fieldAliases: {
13
+ code: ["source", "src", "代码", "content"],
14
+ focus: ["type", "category", "类型", "重点"],
15
+ },
16
+ });
17
+ const code = getString(parsedArgs.code);
18
+ const focus = getString(parsedArgs.focus) || "all"; // quality, security, performance, all
6
19
  const message = `请对以下代码进行全面审查:
7
20
 
8
21
  📝 **代码内容**:
@@ -1,9 +1,24 @@
1
+ import { parseArgs, getString } from "../utils/parseArgs.js";
1
2
  // convert 工具实现
2
3
  export async function convert(args) {
3
4
  try {
4
- const code = args?.code || "";
5
- const from = args?.from || "";
6
- const to = args?.to || "";
5
+ // 智能参数解析,支持自然语言输入
6
+ const parsedArgs = parseArgs(args, {
7
+ defaultValues: {
8
+ code: "",
9
+ from: "",
10
+ to: "",
11
+ },
12
+ primaryField: "code", // 纯文本输入默认映射到 code 字段
13
+ fieldAliases: {
14
+ code: ["source", "src", "代码", "content"],
15
+ from: ["source_format", "source_type", "源格式", "源类型"],
16
+ to: ["target_format", "target_type", "目标格式", "目标类型"],
17
+ },
18
+ });
19
+ const code = getString(parsedArgs.code);
20
+ const from = getString(parsedArgs.from);
21
+ const to = getString(parsedArgs.to);
7
22
  const message = `请转换以下代码:
8
23
 
9
24
  📝 **源代码**:
@@ -1,61 +1,61 @@
1
1
  // css_order 工具实现
2
2
  export async function cssOrder(_args) {
3
3
  try {
4
- const message = `请根据以下规则**书写或重排 CSS**(不是解释规则)。目标是让 CSS 属性顺序更一致、可读、可维护。
5
-
6
- 如果我提供了 CSS 片段/文件,请直接给出**已按规则整理后的 CSS**;如果没提供,请先让我提供需要处理的 CSS。
7
-
8
- ---
9
-
10
- ## 排序逻辑(由外向内,由大到小)
11
-
12
- 将属性分为五类,按顺序排列:
13
-
14
- ### 1. 定位属性 (Positioning)
15
- 决定元素“在哪里”。
16
- - \`position\` / \`z-index\` / \`top\` / \`right\` / \`bottom\` / \`left\` / \`float\` / \`clear\`
17
-
18
- ### 2. 盒子模型 (Box Model)
19
- 决定元素“占多大空间”。
20
- - \`display\` / \`flex\` / \`grid\` 相关属性
21
- - \`width\` / \`height\` / \`max-width\` / \`min-width\`
22
- - \`margin\` / \`padding\` / \`border\`
23
- - \`box-sizing\` / \`overflow\`
24
-
25
- ### 3. 文本排版 (Typography)
26
- 决定元素内“文字内容”的样式。
27
- - \`font-family\` / \`font-size\` / \`font-weight\` / \`line-height\`
28
- - \`text-align\` / \`text-transform\` / \`text-decoration\` / \`letter-spacing\` / \`white-space\` / \`color\`
29
-
30
- ### 4. 视觉表现 (Visual/Decoration)
31
- 决定元素“皮肤”的外观。
32
- - \`background\` / \`box-shadow\` / \`opacity\` / \`visibility\` / \`cursor\` / \`outline\`
33
-
34
- ### 5. 其他与交互 (Misc/Transitions)
35
- 动效和交互相关。
36
- - \`transition\` / \`animation\` / \`transform\` / \`will-change\`
37
-
38
- ---
39
-
40
- ## 处理要求
41
-
42
- 1. **只调整属性顺序,不改动语义**(除非存在明显重复/冲突属性)。
43
- 2. **保留注释与格式风格**(缩进、空行、选择器顺序不变)。
44
- 3. **同类属性保持原有相对顺序**,除非有明显更合理的排序。
45
- 4. 如果存在 **CSS 变量**(\`--*\`)或自定义属性,放在**当前类的最前**。
46
- 5. 如遇 CSS-in-JS、Tailwind 或非标准语法,**只处理可确定的纯 CSS 属性**。
47
-
48
- ---
49
-
50
- ## 快速对比表
51
-
52
- | 顺序 | 类别 | 常用属性举例 | 核心目的 |
53
- | --- | --- | --- | --- |
54
- | **1** | **定位** | \`position\`, \`z-index\`, \`top\` | 确定位置 |
55
- | **2** | **盒模型** | \`display\`, \`width\`, \`margin\`, \`padding\` | 确定形状和间距 |
56
- | **3** | **排版** | \`font\`, \`line-height\`, \`color\`, \`text-align\` | 确定内容样式 |
57
- | **4** | **视觉** | \`background\`, \`border-radius\`, \`box-shadow\` | 确定外观修饰 |
58
- | **5** | **其他** | \`transition\`, \`transform\`, \`animation\` | 确定动态交互 |
4
+ const message = `请根据以下规则**书写或重排 CSS**(不是解释规则)。目标是让 CSS 属性顺序更一致、可读、可维护。
5
+
6
+ 如果我提供了 CSS 片段/文件,请直接给出**已按规则整理后的 CSS**;如果没提供,请先让我提供需要处理的 CSS。
7
+
8
+ ---
9
+
10
+ ## 排序逻辑(由外向内,由大到小)
11
+
12
+ 将属性分为五类,按顺序排列:
13
+
14
+ ### 1. 定位属性 (Positioning)
15
+ 决定元素“在哪里”。
16
+ - \`position\` / \`z-index\` / \`top\` / \`right\` / \`bottom\` / \`left\` / \`float\` / \`clear\`
17
+
18
+ ### 2. 盒子模型 (Box Model)
19
+ 决定元素“占多大空间”。
20
+ - \`display\` / \`flex\` / \`grid\` 相关属性
21
+ - \`width\` / \`height\` / \`max-width\` / \`min-width\`
22
+ - \`margin\` / \`padding\` / \`border\`
23
+ - \`box-sizing\` / \`overflow\`
24
+
25
+ ### 3. 文本排版 (Typography)
26
+ 决定元素内“文字内容”的样式。
27
+ - \`font-family\` / \`font-size\` / \`font-weight\` / \`line-height\`
28
+ - \`text-align\` / \`text-transform\` / \`text-decoration\` / \`letter-spacing\` / \`white-space\` / \`color\`
29
+
30
+ ### 4. 视觉表现 (Visual/Decoration)
31
+ 决定元素“皮肤”的外观。
32
+ - \`background\` / \`box-shadow\` / \`opacity\` / \`visibility\` / \`cursor\` / \`outline\`
33
+
34
+ ### 5. 其他与交互 (Misc/Transitions)
35
+ 动效和交互相关。
36
+ - \`transition\` / \`animation\` / \`transform\` / \`will-change\`
37
+
38
+ ---
39
+
40
+ ## 处理要求
41
+
42
+ 1. **只调整属性顺序,不改动语义**(除非存在明显重复/冲突属性)。
43
+ 2. **保留注释与格式风格**(缩进、空行、选择器顺序不变)。
44
+ 3. **同类属性保持原有相对顺序**,除非有明显更合理的排序。
45
+ 4. 如果存在 **CSS 变量**(\`--*\`)或自定义属性,放在**当前类的最前**。
46
+ 5. 如遇 CSS-in-JS、Tailwind 或非标准语法,**只处理可确定的纯 CSS 属性**。
47
+
48
+ ---
49
+
50
+ ## 快速对比表
51
+
52
+ | 顺序 | 类别 | 常用属性举例 | 核心目的 |
53
+ | --- | --- | --- | --- |
54
+ | **1** | **定位** | \`position\`, \`z-index\`, \`top\` | 确定位置 |
55
+ | **2** | **盒模型** | \`display\`, \`width\`, \`margin\`, \`padding\` | 确定形状和间距 |
56
+ | **3** | **排版** | \`font\`, \`line-height\`, \`color\`, \`text-align\` | 确定内容样式 |
57
+ | **4** | **视觉** | \`background\`, \`border-radius\`, \`box-shadow\` | 确定外观修饰 |
58
+ | **5** | **其他** | \`transition\`, \`transform\`, \`animation\` | 确定动态交互 |
59
59
  `;
60
60
  return {
61
61
  content: [
@@ -1,8 +1,20 @@
1
+ import { parseArgs, getString } from "../utils/parseArgs.js";
1
2
  // debug 工具实现
2
3
  export async function debug(args) {
3
4
  try {
4
- const error = args?.error || "";
5
- const context = args?.context || "";
5
+ const parsedArgs = parseArgs(args, {
6
+ defaultValues: {
7
+ error: "",
8
+ context: "",
9
+ },
10
+ primaryField: "error", // 纯文本输入默认映射到 error 字段
11
+ fieldAliases: {
12
+ error: ["err", "exception", "错误", "异常"],
13
+ context: ["ctx", "code", "上下文", "代码"],
14
+ },
15
+ });
16
+ const error = getString(parsedArgs.error);
17
+ const context = getString(parsedArgs.context);
6
18
  const message = `请分析以下错误并提供调试策略:
7
19
 
8
20
  ❌ **错误信息**:
@@ -1,12 +1,3 @@
1
- /**
2
- * design2code - 设计稿转代码工具
3
- *
4
- * 功能:
5
- * 1. 根据设计稿图片生成页面代码(支持图片 URL 或 base64)
6
- * 2. 根据设计稿描述生成页面代码
7
- * 3. 将 HTML 转换为 Vue/React 组件
8
- * 4. 1:1 还原设计稿布局和样式
9
- */
10
1
  export declare function design2code(args: any): Promise<{
11
2
  content: ({
12
3
  type: string;
@@ -15,8 +6,8 @@ export declare function design2code(args: any): Promise<{
15
6
  mimeType?: undefined;
16
7
  } | {
17
8
  type: string;
18
- data: any;
19
- mimeType: any;
9
+ data: string;
10
+ mimeType: string;
20
11
  text?: undefined;
21
12
  })[];
22
13
  isError?: undefined;
@@ -1,3 +1,4 @@
1
+ import { parseArgs, getString } from "../utils/parseArgs.js";
1
2
  /**
2
3
  * design2code - 设计稿转代码工具
3
4
  *
@@ -244,10 +245,26 @@ src/components/
244
245
  `;
245
246
  export async function design2code(args) {
246
247
  try {
247
- const input = args?.input;
248
- const framework = args?.framework || "vue";
249
- const styleSolution = args?.style_solution || "tailwind";
250
- const componentType = args?.component_type || "page";
248
+ // 智能参数解析,支持自然语言输入
249
+ const parsedArgs = parseArgs(args, {
250
+ defaultValues: {
251
+ input: "",
252
+ framework: "vue",
253
+ style_solution: "tailwind",
254
+ component_type: "page",
255
+ },
256
+ primaryField: "input", // 纯文本输入默认映射到 input 字段
257
+ fieldAliases: {
258
+ input: ["design", "image", "url", "设计稿", "图片"],
259
+ framework: ["lib", "library", "框架", "前端框架"],
260
+ style_solution: ["style", "css", "样式", "样式方案"],
261
+ component_type: ["type", "kind", "类型", "组件类型"],
262
+ },
263
+ });
264
+ const input = getString(parsedArgs.input);
265
+ const framework = getString(parsedArgs.framework) || "vue";
266
+ const styleSolution = getString(parsedArgs.style_solution) || "tailwind";
267
+ const componentType = getString(parsedArgs.component_type) || "page";
251
268
  if (!input) {
252
269
  throw new Error("缺少必填参数: input(设计稿图片 URL/base64、设计稿描述或 HTML 代码)");
253
270
  }
@@ -1,3 +1,4 @@
1
+ import { parseArgs, getString, getBoolean } from "../utils/parseArgs.js";
1
2
  import crypto from "crypto";
2
3
  import https from "https";
3
4
  import http from "http";
@@ -51,8 +52,20 @@ async function probeUrl(url, timeoutMs) {
51
52
  }
52
53
  // detect_shell 工具实现
53
54
  export async function detectShell(args) {
54
- const nonce = args?.nonce || "gpt|gemini|claude|2025-10-25|guyu|boot";
55
- const skipNetwork = args?.skip_network;
55
+ // 智能参数解析,支持自然语言输入
56
+ const parsedArgs = parseArgs(args, {
57
+ defaultValues: {
58
+ nonce: "gpt|gemini|claude|2025-10-25|guyu|boot",
59
+ skip_network: false,
60
+ },
61
+ primaryField: "nonce", // 纯文本输入默认映射到 nonce 字段
62
+ fieldAliases: {
63
+ nonce: ["随机字符串", "校验字符串"],
64
+ skip_network: ["skip", "跳过网络", "跳过"],
65
+ },
66
+ });
67
+ const nonce = getString(parsedArgs.nonce) || "gpt|gemini|claude|2025-10-25|guyu|boot";
68
+ const skipNetwork = getBoolean(parsedArgs.skip_network, false);
56
69
  // 计算 nonce 的哈希
57
70
  const hash = crypto.createHash("sha256");
58
71
  hash.update(nonce, "utf8");
@@ -218,18 +218,35 @@ const PROMPT_TEMPLATE = `# 工作量估算指南
218
218
  *指南版本: 1.0.0*
219
219
  *工具: MCP Probe Kit - estimate*
220
220
  `;
221
+ import { parseArgs, getString, getNumber } from "../utils/parseArgs.js";
221
222
  /**
222
223
  * estimate 工具实现
223
224
  */
224
225
  export async function estimate(args) {
225
226
  try {
226
- const taskDescription = args?.task_description;
227
+ // 智能参数解析,支持自然语言输入
228
+ const parsedArgs = parseArgs(args, {
229
+ defaultValues: {
230
+ task_description: "",
231
+ code_context: "",
232
+ team_size: 1,
233
+ experience_level: "mid",
234
+ },
235
+ primaryField: "task_description", // 纯文本输入默认映射到 task_description 字段
236
+ fieldAliases: {
237
+ task_description: ["task", "description", "requirement", "任务", "任务描述"],
238
+ code_context: ["context", "code", "上下文", "相关代码"],
239
+ team_size: ["team", "size", "团队", "团队规模"],
240
+ experience_level: ["level", "experience", "经验", "经验水平"],
241
+ },
242
+ });
243
+ const taskDescription = getString(parsedArgs.task_description);
244
+ const codeContext = getString(parsedArgs.code_context);
245
+ const teamSize = getNumber(parsedArgs.team_size, 1);
246
+ const experienceLevel = getString(parsedArgs.experience_level) || "mid";
227
247
  if (!taskDescription) {
228
248
  throw new Error("缺少必填参数: task_description(任务描述)");
229
249
  }
230
- const codeContext = args?.code_context || "";
231
- const teamSize = args?.team_size || 1;
232
- const experienceLevel = args?.experience_level || "mid";
233
250
  const expLevelMap = {
234
251
  junior: "初级(1-2年经验)",
235
252
  mid: "中级(3-5年经验)",
@@ -1,8 +1,21 @@
1
+ import { parseArgs, getString } from "../utils/parseArgs.js";
1
2
  // explain 工具实现
2
3
  export async function explain(args) {
3
4
  try {
4
- const code = args?.code || "";
5
- const context = args?.context || "";
5
+ // 智能参数解析,支持自然语言输入
6
+ const parsedArgs = parseArgs(args, {
7
+ defaultValues: {
8
+ code: "",
9
+ context: "",
10
+ },
11
+ primaryField: "code", // 纯文本输入默认映射到 code 字段
12
+ fieldAliases: {
13
+ code: ["source", "src", "代码", "snippet"],
14
+ context: ["background", "info", "上下文", "背景"],
15
+ },
16
+ });
17
+ const code = getString(parsedArgs.code);
18
+ const context = getString(parsedArgs.context);
6
19
  const message = `请详细解释以下代码:
7
20
 
8
21
  📝 **代码内容**:
@@ -1,8 +1,21 @@
1
+ import { parseArgs, getString } from "../utils/parseArgs.js";
1
2
  // fix 工具实现
2
3
  export async function fix(args) {
3
4
  try {
4
- const code = args?.code || "";
5
- const type = args?.type || "all"; // lint, type, format, import, unused
5
+ // 智能参数解析,支持自然语言输入
6
+ const parsedArgs = parseArgs(args, {
7
+ defaultValues: {
8
+ code: "",
9
+ type: "all",
10
+ },
11
+ primaryField: "code", // 纯文本输入默认映射到 code 字段
12
+ fieldAliases: {
13
+ code: ["source", "src", "代码", "content"],
14
+ type: ["fix_type", "category", "类型", "修复类型"],
15
+ },
16
+ });
17
+ const code = getString(parsedArgs.code);
18
+ const type = getString(parsedArgs.type) || "all"; // lint, type, format, import, unused
6
19
  const message = `请自动修复以下代码问题:
7
20
 
8
21
  📝 **代码内容**:
@@ -294,19 +294,38 @@ describe('[功能描述]', () => {
294
294
  *指南版本: 1.0.0*
295
295
  *工具: MCP Probe Kit - fix_bug*
296
296
  `;
297
+ import { parseArgs, getString } from "../utils/parseArgs.js";
297
298
  /**
298
299
  * fix_bug 工具实现
299
300
  */
300
301
  export async function fixBug(args) {
301
302
  try {
302
- const errorMessage = args?.error_message;
303
+ // 智能参数解析,支持自然语言输入
304
+ const parsedArgs = parseArgs(args, {
305
+ defaultValues: {
306
+ error_message: "",
307
+ stack_trace: "",
308
+ steps_to_reproduce: "",
309
+ expected_behavior: "",
310
+ actual_behavior: "",
311
+ },
312
+ primaryField: "error_message", // 纯文本输入默认映射到 error_message 字段
313
+ fieldAliases: {
314
+ error_message: ["error", "err", "message", "错误", "错误信息"],
315
+ stack_trace: ["stack", "trace", "堆栈", "调用栈"],
316
+ steps_to_reproduce: ["steps", "reproduce", "步骤", "复现步骤"],
317
+ expected_behavior: ["expected", "期望", "期望行为"],
318
+ actual_behavior: ["actual", "实际", "实际行为"],
319
+ },
320
+ });
321
+ const errorMessage = getString(parsedArgs.error_message);
322
+ const stackTrace = getString(parsedArgs.stack_trace);
323
+ const stepsToReproduce = getString(parsedArgs.steps_to_reproduce);
324
+ const expectedBehavior = getString(parsedArgs.expected_behavior);
325
+ const actualBehavior = getString(parsedArgs.actual_behavior);
303
326
  if (!errorMessage) {
304
327
  throw new Error("缺少必填参数: error_message(错误信息)");
305
328
  }
306
- const stackTrace = args?.stack_trace || "";
307
- const stepsToReproduce = args?.steps_to_reproduce || "";
308
- const expectedBehavior = args?.expected_behavior || "";
309
- const actualBehavior = args?.actual_behavior || "";
310
329
  // 构建可选部分
311
330
  const stackTraceSection = stackTrace
312
331
  ? `**堆栈跟踪**:\n\`\`\`\n${stackTrace}\n\`\`\``