mcp-probe-kit 1.10.0 → 1.11.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.
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 所有工具 Schema 的统一导出
3
+ */
4
+ import { basicToolSchemas } from "./basic-tools.js";
5
+ import { gitToolSchemas } from "./git-tools.js";
6
+ import { codeAnalysisToolSchemas } from "./code-analysis-tools.js";
7
+ import { codeGenToolSchemas } from "./code-gen-tools.js";
8
+ import { docUtilToolSchemas } from "./doc-util-tools.js";
9
+ import { projectToolSchemas } from "./project-tools.js";
10
+ import { orchestrationToolSchemas } from "./orchestration-tools.js";
11
+ // 合并所有工具 schemas
12
+ export const allToolSchemas = [
13
+ ...basicToolSchemas,
14
+ ...gitToolSchemas,
15
+ ...codeAnalysisToolSchemas,
16
+ ...codeGenToolSchemas,
17
+ ...docUtilToolSchemas,
18
+ ...projectToolSchemas,
19
+ ...orchestrationToolSchemas,
20
+ ];
@@ -0,0 +1,186 @@
1
+ /**
2
+ * 智能编排工具的 Schema 定义
3
+ */
4
+ export declare const orchestrationToolSchemas: readonly [{
5
+ readonly name: "start_feature";
6
+ readonly description: "当用户需要完整的新功能开发流程时使用。编排:检查上下文→生成规格→估算工作量。若只需规格文档请用 add_feature";
7
+ readonly inputSchema: {
8
+ readonly type: "object";
9
+ readonly properties: {
10
+ readonly feature_name: {
11
+ readonly type: "string";
12
+ readonly description: "功能名称(kebab-case 格式,如 user-auth)。可选,如果不提供会从 description 自动提取";
13
+ };
14
+ readonly description: {
15
+ readonly type: "string";
16
+ readonly description: "功能详细描述。可以是简短的自然语言(如'开发用户认证功能')或详细的需求说明";
17
+ };
18
+ readonly docs_dir: {
19
+ readonly type: "string";
20
+ readonly description: "文档输出目录,默认为 docs";
21
+ };
22
+ };
23
+ readonly required: readonly [];
24
+ readonly additionalProperties: true;
25
+ };
26
+ }, {
27
+ readonly name: "start_bugfix";
28
+ readonly description: "当用户需要完整的 Bug 修复流程时使用。编排:检查上下文→分析定位→修复方案→生成测试。若只需定位请用 debug";
29
+ readonly inputSchema: {
30
+ readonly type: "object";
31
+ readonly properties: {
32
+ readonly error_message: {
33
+ readonly type: "string";
34
+ readonly description: "错误信息";
35
+ };
36
+ readonly stack_trace: {
37
+ readonly type: "string";
38
+ readonly description: "堆栈跟踪。可选";
39
+ };
40
+ readonly code_context: {
41
+ readonly type: "string";
42
+ readonly description: "相关代码。可选";
43
+ };
44
+ };
45
+ readonly required: readonly [];
46
+ readonly additionalProperties: true;
47
+ };
48
+ }, {
49
+ readonly name: "start_review";
50
+ readonly description: "当用户需要全面审查代码时使用。编排:代码审查+安全扫描+性能分析,输出综合报告。若只需单项请用对应工具";
51
+ readonly inputSchema: {
52
+ readonly type: "object";
53
+ readonly properties: {
54
+ readonly code: {
55
+ readonly type: "string";
56
+ readonly description: "要审查的代码";
57
+ };
58
+ readonly language: {
59
+ readonly type: "string";
60
+ readonly description: "编程语言。可选,会自动识别";
61
+ };
62
+ };
63
+ readonly required: readonly [];
64
+ readonly additionalProperties: true;
65
+ };
66
+ }, {
67
+ readonly name: "start_release";
68
+ readonly description: "当用户需要准备版本发布时使用。编排:生成 Changelog→生成 PR 描述。若只需单项请用 genchangelog 或 genpr";
69
+ readonly inputSchema: {
70
+ readonly type: "object";
71
+ readonly properties: {
72
+ readonly version: {
73
+ readonly type: "string";
74
+ readonly description: "版本号(如 v1.2.0)";
75
+ };
76
+ readonly from_tag: {
77
+ readonly type: "string";
78
+ readonly description: "起始 tag。可选";
79
+ };
80
+ };
81
+ readonly required: readonly [];
82
+ readonly additionalProperties: true;
83
+ };
84
+ }, {
85
+ readonly name: "start_refactor";
86
+ readonly description: "当用户需要完整的代码重构流程时使用。编排:审查现状→重构建议→生成测试。若只需建议请用 refactor";
87
+ readonly inputSchema: {
88
+ readonly type: "object";
89
+ readonly properties: {
90
+ readonly code: {
91
+ readonly type: "string";
92
+ readonly description: "要重构的代码";
93
+ };
94
+ readonly goal: {
95
+ readonly type: "string";
96
+ readonly description: "重构目标。可选";
97
+ };
98
+ };
99
+ readonly required: readonly [];
100
+ readonly additionalProperties: true;
101
+ };
102
+ }, {
103
+ readonly name: "start_onboard";
104
+ readonly description: "当用户需要快速上手新项目时使用。编排:分析项目→生成上下文文档。若只需分析请用 analyze_project";
105
+ readonly inputSchema: {
106
+ readonly type: "object";
107
+ readonly properties: {
108
+ readonly project_path: {
109
+ readonly type: "string";
110
+ readonly description: "项目路径。可选,默认当前目录";
111
+ };
112
+ readonly docs_dir: {
113
+ readonly type: "string";
114
+ readonly description: "文档目录。可选,默认 docs";
115
+ };
116
+ };
117
+ readonly required: readonly [];
118
+ readonly additionalProperties: true;
119
+ };
120
+ }, {
121
+ readonly name: "start_api";
122
+ readonly description: "当用户需要完整的 API 开发流程时使用。编排:生成文档→生成 Mock→生成测试。若只需单项请用对应生成工具";
123
+ readonly inputSchema: {
124
+ readonly type: "object";
125
+ readonly properties: {
126
+ readonly code: {
127
+ readonly type: "string";
128
+ readonly description: "API 代码";
129
+ };
130
+ readonly language: {
131
+ readonly type: "string";
132
+ readonly description: "编程语言。可选,会自动识别";
133
+ };
134
+ readonly format: {
135
+ readonly type: "string";
136
+ readonly description: "文档格式。可选,默认 openapi";
137
+ };
138
+ };
139
+ readonly required: readonly [];
140
+ readonly additionalProperties: true;
141
+ };
142
+ }, {
143
+ readonly name: "start_doc";
144
+ readonly description: "当用户需要补全项目文档时使用。编排:注释→README→API 文档。若只需单项文档请用对应生成工具";
145
+ readonly inputSchema: {
146
+ readonly type: "object";
147
+ readonly properties: {
148
+ readonly code: {
149
+ readonly type: "string";
150
+ readonly description: "代码或项目信息";
151
+ };
152
+ readonly project_info: {
153
+ readonly type: "string";
154
+ readonly description: "项目信息。可选";
155
+ };
156
+ readonly style: {
157
+ readonly type: "string";
158
+ readonly description: "文档风格。可选,默认 jsdoc";
159
+ };
160
+ };
161
+ readonly required: readonly [];
162
+ readonly additionalProperties: true;
163
+ };
164
+ }, {
165
+ readonly name: "gen_skill";
166
+ readonly description: "当用户需要生成 Agent Skills 文档时使用。为 MCP Probe Kit 工具生成符合开放标准的技能文档,输出到 skills/ 目录";
167
+ readonly inputSchema: {
168
+ readonly type: "object";
169
+ readonly properties: {
170
+ readonly scope: {
171
+ readonly type: "string";
172
+ readonly description: "生成范围:all(所有工具)、single(单个工具)。可选,默认 all";
173
+ };
174
+ readonly tool_name: {
175
+ readonly type: "string";
176
+ readonly description: "工具名称。当 scope 为 single 时必填";
177
+ };
178
+ readonly lang: {
179
+ readonly type: "string";
180
+ readonly description: "文档语言:zh(中文)、en(英文)。可选,默认 zh";
181
+ };
182
+ };
183
+ readonly required: readonly [];
184
+ readonly additionalProperties: true;
185
+ };
186
+ }];
@@ -0,0 +1,196 @@
1
+ /**
2
+ * 智能编排工具的 Schema 定义
3
+ */
4
+ export const orchestrationToolSchemas = [
5
+ {
6
+ name: "start_feature",
7
+ description: "当用户需要完整的新功能开发流程时使用。编排:检查上下文→生成规格→估算工作量。若只需规格文档请用 add_feature",
8
+ inputSchema: {
9
+ type: "object",
10
+ properties: {
11
+ feature_name: {
12
+ type: "string",
13
+ description: "功能名称(kebab-case 格式,如 user-auth)。可选,如果不提供会从 description 自动提取",
14
+ },
15
+ description: {
16
+ type: "string",
17
+ description: "功能详细描述。可以是简短的自然语言(如'开发用户认证功能')或详细的需求说明",
18
+ },
19
+ docs_dir: {
20
+ type: "string",
21
+ description: "文档输出目录,默认为 docs",
22
+ },
23
+ },
24
+ required: [],
25
+ additionalProperties: true,
26
+ },
27
+ },
28
+ {
29
+ name: "start_bugfix",
30
+ description: "当用户需要完整的 Bug 修复流程时使用。编排:检查上下文→分析定位→修复方案→生成测试。若只需定位请用 debug",
31
+ inputSchema: {
32
+ type: "object",
33
+ properties: {
34
+ error_message: {
35
+ type: "string",
36
+ description: "错误信息",
37
+ },
38
+ stack_trace: {
39
+ type: "string",
40
+ description: "堆栈跟踪。可选",
41
+ },
42
+ code_context: {
43
+ type: "string",
44
+ description: "相关代码。可选",
45
+ },
46
+ },
47
+ required: [],
48
+ additionalProperties: true,
49
+ },
50
+ },
51
+ {
52
+ name: "start_review",
53
+ description: "当用户需要全面审查代码时使用。编排:代码审查+安全扫描+性能分析,输出综合报告。若只需单项请用对应工具",
54
+ inputSchema: {
55
+ type: "object",
56
+ properties: {
57
+ code: {
58
+ type: "string",
59
+ description: "要审查的代码",
60
+ },
61
+ language: {
62
+ type: "string",
63
+ description: "编程语言。可选,会自动识别",
64
+ },
65
+ },
66
+ required: [],
67
+ additionalProperties: true,
68
+ },
69
+ },
70
+ {
71
+ name: "start_release",
72
+ description: "当用户需要准备版本发布时使用。编排:生成 Changelog→生成 PR 描述。若只需单项请用 genchangelog 或 genpr",
73
+ inputSchema: {
74
+ type: "object",
75
+ properties: {
76
+ version: {
77
+ type: "string",
78
+ description: "版本号(如 v1.2.0)",
79
+ },
80
+ from_tag: {
81
+ type: "string",
82
+ description: "起始 tag。可选",
83
+ },
84
+ },
85
+ required: [],
86
+ additionalProperties: true,
87
+ },
88
+ },
89
+ {
90
+ name: "start_refactor",
91
+ description: "当用户需要完整的代码重构流程时使用。编排:审查现状→重构建议→生成测试。若只需建议请用 refactor",
92
+ inputSchema: {
93
+ type: "object",
94
+ properties: {
95
+ code: {
96
+ type: "string",
97
+ description: "要重构的代码",
98
+ },
99
+ goal: {
100
+ type: "string",
101
+ description: "重构目标。可选",
102
+ },
103
+ },
104
+ required: [],
105
+ additionalProperties: true,
106
+ },
107
+ },
108
+ {
109
+ name: "start_onboard",
110
+ description: "当用户需要快速上手新项目时使用。编排:分析项目→生成上下文文档。若只需分析请用 analyze_project",
111
+ inputSchema: {
112
+ type: "object",
113
+ properties: {
114
+ project_path: {
115
+ type: "string",
116
+ description: "项目路径。可选,默认当前目录",
117
+ },
118
+ docs_dir: {
119
+ type: "string",
120
+ description: "文档目录。可选,默认 docs",
121
+ },
122
+ },
123
+ required: [],
124
+ additionalProperties: true,
125
+ },
126
+ },
127
+ {
128
+ name: "start_api",
129
+ description: "当用户需要完整的 API 开发流程时使用。编排:生成文档→生成 Mock→生成测试。若只需单项请用对应生成工具",
130
+ inputSchema: {
131
+ type: "object",
132
+ properties: {
133
+ code: {
134
+ type: "string",
135
+ description: "API 代码",
136
+ },
137
+ language: {
138
+ type: "string",
139
+ description: "编程语言。可选,会自动识别",
140
+ },
141
+ format: {
142
+ type: "string",
143
+ description: "文档格式。可选,默认 openapi",
144
+ },
145
+ },
146
+ required: [],
147
+ additionalProperties: true,
148
+ },
149
+ },
150
+ {
151
+ name: "start_doc",
152
+ description: "当用户需要补全项目文档时使用。编排:注释→README→API 文档。若只需单项文档请用对应生成工具",
153
+ inputSchema: {
154
+ type: "object",
155
+ properties: {
156
+ code: {
157
+ type: "string",
158
+ description: "代码或项目信息",
159
+ },
160
+ project_info: {
161
+ type: "string",
162
+ description: "项目信息。可选",
163
+ },
164
+ style: {
165
+ type: "string",
166
+ description: "文档风格。可选,默认 jsdoc",
167
+ },
168
+ },
169
+ required: [],
170
+ additionalProperties: true,
171
+ },
172
+ },
173
+ {
174
+ name: "gen_skill",
175
+ description: "当用户需要生成 Agent Skills 文档时使用。为 MCP Probe Kit 工具生成符合开放标准的技能文档,输出到 skills/ 目录",
176
+ inputSchema: {
177
+ type: "object",
178
+ properties: {
179
+ scope: {
180
+ type: "string",
181
+ description: "生成范围:all(所有工具)、single(单个工具)。可选,默认 all",
182
+ },
183
+ tool_name: {
184
+ type: "string",
185
+ description: "工具名称。当 scope 为 single 时必填",
186
+ },
187
+ lang: {
188
+ type: "string",
189
+ description: "文档语言:zh(中文)、en(英文)。可选,默认 zh",
190
+ },
191
+ },
192
+ required: [],
193
+ additionalProperties: true,
194
+ },
195
+ },
196
+ ];
@@ -0,0 +1,84 @@
1
+ /**
2
+ * 项目管理工具的 Schema 定义
3
+ */
4
+ export declare const projectToolSchemas: readonly [{
5
+ readonly name: "analyze_project";
6
+ readonly description: "当用户需要了解项目结构、分析项目技术栈时使用。分析项目结构、技术栈、架构模式,输出项目全景报告";
7
+ readonly inputSchema: {
8
+ readonly type: "object";
9
+ readonly properties: {
10
+ readonly project_path: {
11
+ readonly type: "string";
12
+ readonly description: "项目路径。可选,默认为当前目录";
13
+ };
14
+ readonly max_depth: {
15
+ readonly type: "number";
16
+ readonly description: "分析深度。可选,默认 5";
17
+ };
18
+ };
19
+ readonly required: readonly [];
20
+ readonly additionalProperties: true;
21
+ };
22
+ }, {
23
+ readonly name: "init_project_context";
24
+ readonly description: "当用户需要生成项目上下文文档、帮助团队快速上手时使用。生成项目上下文文档(技术栈/架构/编码规范),供后续开发参考";
25
+ readonly inputSchema: {
26
+ readonly type: "object";
27
+ readonly properties: {
28
+ readonly docs_dir: {
29
+ readonly type: "string";
30
+ readonly description: "文档目录。可选,默认 docs";
31
+ };
32
+ };
33
+ readonly required: readonly [];
34
+ readonly additionalProperties: true;
35
+ };
36
+ }, {
37
+ readonly name: "add_feature";
38
+ readonly description: "当用户需要添加新功能、生成功能规格文档时使用。生成新功能规格文档(需求/设计/任务清单),基于项目上下文";
39
+ readonly inputSchema: {
40
+ readonly type: "object";
41
+ readonly properties: {
42
+ readonly feature_name: {
43
+ readonly type: "string";
44
+ readonly description: "功能名称(kebab-case 格式,如 user-auth)。可选,如果不提供会从 description 自动提取";
45
+ };
46
+ readonly description: {
47
+ readonly type: "string";
48
+ readonly description: "功能详细描述。可以是简短的自然语言(如'添加用户认证功能')或详细的需求说明";
49
+ };
50
+ readonly docs_dir: {
51
+ readonly type: "string";
52
+ readonly description: "文档输出目录,默认为 docs";
53
+ };
54
+ };
55
+ readonly required: readonly [];
56
+ readonly additionalProperties: true;
57
+ };
58
+ }, {
59
+ readonly name: "estimate";
60
+ readonly description: "当用户需要估算开发工作量、评估任务时间时使用。估算开发工作量,输出故事点、时间范围(乐观/正常/悲观)、风险点";
61
+ readonly inputSchema: {
62
+ readonly type: "object";
63
+ readonly properties: {
64
+ readonly task_description: {
65
+ readonly type: "string";
66
+ readonly description: "任务描述。可以是简短的自然语言(如'估算开发工作量')或详细的任务说明";
67
+ };
68
+ readonly code_context: {
69
+ readonly type: "string";
70
+ readonly description: "相关代码或文件上下文。可选,有助于更准确的估算";
71
+ };
72
+ readonly team_size: {
73
+ readonly type: "number";
74
+ readonly description: "团队规模(人数)。可选,默认为 1";
75
+ };
76
+ readonly experience_level: {
77
+ readonly type: "string";
78
+ readonly description: "经验水平:junior(初级)、mid(中级)、senior(高级)。可选,默认为 mid";
79
+ };
80
+ };
81
+ readonly required: readonly [];
82
+ readonly additionalProperties: true;
83
+ };
84
+ }];
@@ -0,0 +1,89 @@
1
+ /**
2
+ * 项目管理工具的 Schema 定义
3
+ */
4
+ export const projectToolSchemas = [
5
+ {
6
+ name: "analyze_project",
7
+ description: "当用户需要了解项目结构、分析项目技术栈时使用。分析项目结构、技术栈、架构模式,输出项目全景报告",
8
+ inputSchema: {
9
+ type: "object",
10
+ properties: {
11
+ project_path: {
12
+ type: "string",
13
+ description: "项目路径。可选,默认为当前目录",
14
+ },
15
+ max_depth: {
16
+ type: "number",
17
+ description: "分析深度。可选,默认 5",
18
+ },
19
+ },
20
+ required: [],
21
+ additionalProperties: true,
22
+ },
23
+ },
24
+ {
25
+ name: "init_project_context",
26
+ description: "当用户需要生成项目上下文文档、帮助团队快速上手时使用。生成项目上下文文档(技术栈/架构/编码规范),供后续开发参考",
27
+ inputSchema: {
28
+ type: "object",
29
+ properties: {
30
+ docs_dir: {
31
+ type: "string",
32
+ description: "文档目录。可选,默认 docs",
33
+ },
34
+ },
35
+ required: [],
36
+ additionalProperties: true,
37
+ },
38
+ },
39
+ {
40
+ name: "add_feature",
41
+ description: "当用户需要添加新功能、生成功能规格文档时使用。生成新功能规格文档(需求/设计/任务清单),基于项目上下文",
42
+ inputSchema: {
43
+ type: "object",
44
+ properties: {
45
+ feature_name: {
46
+ type: "string",
47
+ description: "功能名称(kebab-case 格式,如 user-auth)。可选,如果不提供会从 description 自动提取",
48
+ },
49
+ description: {
50
+ type: "string",
51
+ description: "功能详细描述。可以是简短的自然语言(如'添加用户认证功能')或详细的需求说明",
52
+ },
53
+ docs_dir: {
54
+ type: "string",
55
+ description: "文档输出目录,默认为 docs",
56
+ },
57
+ },
58
+ required: [],
59
+ additionalProperties: true,
60
+ },
61
+ },
62
+ {
63
+ name: "estimate",
64
+ description: "当用户需要估算开发工作量、评估任务时间时使用。估算开发工作量,输出故事点、时间范围(乐观/正常/悲观)、风险点",
65
+ inputSchema: {
66
+ type: "object",
67
+ properties: {
68
+ task_description: {
69
+ type: "string",
70
+ description: "任务描述。可以是简短的自然语言(如'估算开发工作量')或详细的任务说明",
71
+ },
72
+ code_context: {
73
+ type: "string",
74
+ description: "相关代码或文件上下文。可选,有助于更准确的估算",
75
+ },
76
+ team_size: {
77
+ type: "number",
78
+ description: "团队规模(人数)。可选,默认为 1",
79
+ },
80
+ experience_level: {
81
+ type: "string",
82
+ description: "经验水平:junior(初级)、mid(中级)、senior(高级)。可选,默认为 mid",
83
+ },
84
+ },
85
+ required: [],
86
+ additionalProperties: true,
87
+ },
88
+ },
89
+ ];
@@ -1,4 +1,4 @@
1
- import { parseArgs, getString, validateRequired } from "../utils/parseArgs.js";
1
+ import { parseArgs, getString } from "../utils/parseArgs.js";
2
2
  /**
3
3
  * add_feature 工具
4
4
  *
@@ -12,6 +12,46 @@ import { parseArgs, getString, validateRequired } from "../utils/parseArgs.js";
12
12
  */
13
13
  // 默认文档目录
14
14
  const DEFAULT_DOCS_DIR = "docs";
15
+ /**
16
+ * 从自然语言输入中提取功能名和描述
17
+ * @param input - 自然语言输入
18
+ * @returns 提取的功能名和描述
19
+ */
20
+ function extractFeatureInfo(input) {
21
+ // 移除常见的引导词
22
+ let text = input
23
+ .replace(/^(添加|实现|开发|创建|新增|生成|构建|做|要|想要|需要|帮我|请|麻烦)/i, "")
24
+ .trim();
25
+ // 移除结尾的"功能"、"模块"等词
26
+ text = text.replace(/(功能|模块|特性|组件|系统|服务)$/i, "").trim();
27
+ // 如果文本很短(少于20个字符),直接作为功能名
28
+ if (text.length < 20) {
29
+ const name = text
30
+ .toLowerCase()
31
+ .replace(/[\s\u4e00-\u9fa5]+/g, "-") // 将空格和中文替换为连字符
32
+ .replace(/[^a-z0-9-]/g, "") // 移除非字母数字和连字符
33
+ .replace(/-+/g, "-") // 合并多个连字符
34
+ .replace(/^-|-$/g, ""); // 移除首尾连字符
35
+ return {
36
+ name: name || "new-feature",
37
+ description: input,
38
+ };
39
+ }
40
+ // 如果文本较长,尝试提取关键词作为功能名
41
+ // 提取前几个关键词
42
+ const words = text.split(/[\s,,、]+/).filter(w => w.length > 0);
43
+ const keyWords = words.slice(0, 3).join(" ");
44
+ const name = keyWords
45
+ .toLowerCase()
46
+ .replace(/[\s\u4e00-\u9fa5]+/g, "-")
47
+ .replace(/[^a-z0-9-]/g, "")
48
+ .replace(/-+/g, "-")
49
+ .replace(/^-|-$/g, "");
50
+ return {
51
+ name: name || "new-feature",
52
+ description: input,
53
+ };
54
+ }
15
55
  // 提示词模板
16
56
  const PROMPT_TEMPLATE = `# 添加新功能指南
17
57
 
@@ -431,18 +471,41 @@ export async function addFeature(args) {
431
471
  description: "",
432
472
  docs_dir: DEFAULT_DOCS_DIR,
433
473
  },
434
- primaryField: "description", // 纯文本输入默认映射到 description 字段
474
+ primaryField: "input", // 纯文本输入默认映射到 input 字段
435
475
  fieldAliases: {
436
476
  feature_name: ["name", "feature", "功能名", "功能名称"],
437
477
  description: ["desc", "requirement", "描述", "需求"],
438
478
  docs_dir: ["dir", "output", "目录", "文档目录"],
439
479
  },
440
480
  });
441
- const featureName = getString(parsedArgs.feature_name);
442
- const description = getString(parsedArgs.description);
481
+ let featureName = getString(parsedArgs.feature_name);
482
+ let description = getString(parsedArgs.description);
443
483
  const docsDir = getString(parsedArgs.docs_dir) || DEFAULT_DOCS_DIR;
484
+ // 如果是纯自然语言输入(input 字段有值但 feature_name 和 description 为空)
485
+ const input = getString(parsedArgs.input);
486
+ if (input && !featureName && !description) {
487
+ // 智能提取功能名和描述
488
+ // 尝试从自然语言中提取功能名(通常是关键词)
489
+ const extracted = extractFeatureInfo(input);
490
+ featureName = extracted.name;
491
+ description = extracted.description;
492
+ }
493
+ // 如果只有 description 没有 feature_name,尝试从 description 提取
494
+ if (!featureName && description) {
495
+ const extracted = extractFeatureInfo(description);
496
+ featureName = extracted.name;
497
+ if (!description || description === featureName) {
498
+ description = extracted.description;
499
+ }
500
+ }
444
501
  // 验证必填参数
445
- validateRequired(parsedArgs, ["feature_name", "description"]);
502
+ if (!featureName || !description) {
503
+ throw new Error("请提供功能名称和描述。\n\n" +
504
+ "示例用法:\n" +
505
+ "- 自然语言:'添加用户认证功能'\n" +
506
+ "- 详细描述:'实现用户登录、注册和密码重置功能'\n" +
507
+ "- JSON格式:{\"feature_name\": \"user-auth\", \"description\": \"用户认证功能\"}");
508
+ }
446
509
  // 构建指南文本(替换占位符)
447
510
  const guide = PROMPT_TEMPLATE
448
511
  .replace(/{feature_name}/g, featureName)