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.
Files changed (162) hide show
  1. package/README.md +113 -1642
  2. package/build/index.js +75 -42
  3. package/build/lib/elicitation-helper.d.ts +73 -0
  4. package/build/lib/elicitation-helper.js +130 -0
  5. package/build/lib/response.d.ts +32 -0
  6. package/build/lib/response.js +28 -0
  7. package/build/lib/tasks-manager.d.ts +116 -0
  8. package/build/lib/tasks-manager.js +217 -0
  9. package/build/lib/toolset-manager.d.ts +48 -0
  10. package/build/lib/toolset-manager.js +112 -0
  11. package/build/schemas/basic-tools.d.ts +0 -32
  12. package/build/schemas/basic-tools.js +0 -34
  13. package/build/schemas/code-analysis-tools.d.ts +0 -36
  14. package/build/schemas/code-analysis-tools.js +0 -38
  15. package/build/schemas/code-gen-tools.d.ts +0 -44
  16. package/build/schemas/code-gen-tools.js +0 -46
  17. package/build/schemas/doc-util-tools.d.ts +0 -54
  18. package/build/schemas/doc-util-tools.js +0 -58
  19. package/build/schemas/index.d.ts +0 -188
  20. package/build/schemas/orchestration-tools.d.ts +0 -22
  21. package/build/schemas/orchestration-tools.js +0 -23
  22. package/build/schemas/output/core-tools.d.ts +817 -0
  23. package/build/schemas/output/core-tools.js +421 -0
  24. package/build/schemas/output/generation-tools.d.ts +936 -0
  25. package/build/schemas/output/generation-tools.js +446 -0
  26. package/build/schemas/output/helper-tools.d.ts +243 -0
  27. package/build/schemas/output/helper-tools.js +138 -0
  28. package/build/schemas/output/index.d.ts +76 -0
  29. package/build/schemas/output/index.js +96 -0
  30. package/build/schemas/output/project-tools.d.ts +702 -0
  31. package/build/schemas/output/project-tools.js +339 -0
  32. package/build/schemas/output/ui-ux-tools.d.ts +469 -0
  33. package/build/schemas/output/ui-ux-tools.js +218 -0
  34. package/build/schemas/output/workflow-tools.d.ts +267 -0
  35. package/build/schemas/output/workflow-tools.js +179 -0
  36. package/build/schemas/structured-output.d.ts +1317 -0
  37. package/build/schemas/structured-output.js +1017 -0
  38. package/build/tools/__tests__/start_ui.integration.test.js +5 -5
  39. package/build/tools/__tests__/start_ui.property.test.js +11 -11
  40. package/build/tools/add_feature.d.ts +1 -13
  41. package/build/tools/add_feature.js +48 -13
  42. package/build/tools/analyze_project.js +57 -18
  43. package/build/tools/check_deps.d.ts +1 -13
  44. package/build/tools/check_deps.js +24 -15
  45. package/build/tools/code_review.d.ts +1 -13
  46. package/build/tools/code_review.js +19 -16
  47. package/build/tools/debug.d.ts +1 -13
  48. package/build/tools/debug.js +18 -16
  49. package/build/tools/estimate.d.ts +1 -19
  50. package/build/tools/estimate.js +36 -6
  51. package/build/tools/fix_bug.d.ts +1 -13
  52. package/build/tools/fix_bug.js +24 -6
  53. package/build/tools/gen_mock.d.ts +1 -19
  54. package/build/tools/gen_mock.js +42 -227
  55. package/build/tools/genapi.d.ts +1 -13
  56. package/build/tools/genapi.js +18 -15
  57. package/build/tools/genchangelog.d.ts +1 -13
  58. package/build/tools/genchangelog.js +36 -212
  59. package/build/tools/gencommit.d.ts +1 -7
  60. package/build/tools/gencommit.js +21 -13
  61. package/build/tools/gendoc.d.ts +1 -13
  62. package/build/tools/gendoc.js +18 -15
  63. package/build/tools/genpr.d.ts +1 -13
  64. package/build/tools/genpr.js +28 -157
  65. package/build/tools/genreadme.d.ts +1 -13
  66. package/build/tools/genreadme.js +22 -587
  67. package/build/tools/gensql.d.ts +1 -13
  68. package/build/tools/gensql.js +24 -283
  69. package/build/tools/gentest.d.ts +1 -13
  70. package/build/tools/gentest.js +49 -16
  71. package/build/tools/index.d.ts +0 -10
  72. package/build/tools/index.js +0 -10
  73. package/build/tools/init_component_catalog.d.ts +3 -20
  74. package/build/tools/init_component_catalog.js +141 -786
  75. package/build/tools/init_project.d.ts +7 -13
  76. package/build/tools/init_project.js +54 -16
  77. package/build/tools/init_project_context.d.ts +1 -13
  78. package/build/tools/init_project_context.js +41 -14
  79. package/build/tools/perf.d.ts +1 -13
  80. package/build/tools/perf.js +18 -15
  81. package/build/tools/refactor.d.ts +1 -13
  82. package/build/tools/refactor.js +54 -15
  83. package/build/tools/render_ui.d.ts +2 -19
  84. package/build/tools/render_ui.js +201 -347
  85. package/build/tools/resolve_conflict.d.ts +1 -13
  86. package/build/tools/resolve_conflict.js +18 -15
  87. package/build/tools/security_scan.d.ts +1 -13
  88. package/build/tools/security_scan.js +16 -5
  89. package/build/tools/start_api.d.ts +7 -13
  90. package/build/tools/start_api.js +69 -157
  91. package/build/tools/start_bugfix.d.ts +1 -7
  92. package/build/tools/start_bugfix.js +38 -2
  93. package/build/tools/start_doc.d.ts +7 -13
  94. package/build/tools/start_doc.js +76 -169
  95. package/build/tools/start_feature.d.ts +1 -7
  96. package/build/tools/start_feature.js +54 -2
  97. package/build/tools/start_onboard.d.ts +1 -7
  98. package/build/tools/start_onboard.js +40 -2
  99. package/build/tools/start_ralph.d.ts +1 -7
  100. package/build/tools/start_ralph.js +88 -2
  101. package/build/tools/start_refactor.d.ts +7 -13
  102. package/build/tools/start_refactor.js +75 -148
  103. package/build/tools/start_release.d.ts +7 -13
  104. package/build/tools/start_release.js +56 -131
  105. package/build/tools/start_review.d.ts +7 -13
  106. package/build/tools/start_review.js +70 -142
  107. package/build/tools/start_ui.d.ts +1 -7
  108. package/build/tools/start_ui.js +98 -8
  109. package/build/tools/ui-ux-tools.d.ts +3 -39
  110. package/build/tools/ui-ux-tools.js +201 -125
  111. package/docs/data/tools.js +864 -0
  112. package/docs/index.html +594 -0
  113. package/docs/pages/all-tools.html +649 -0
  114. package/docs/pages/examples.html +564 -0
  115. package/docs/pages/getting-started.html +529 -0
  116. package/docs/pages/migration.html +308 -0
  117. package/docs/specs/algorithm-enhancement/roadmap.md +619 -0
  118. package/docs/specs/vnext-upgrade/00-OVERVIEW.md +258 -0
  119. package/docs/specs/vnext-upgrade/BETA_RELEASE_GUIDE.md +328 -0
  120. package/docs/specs/vnext-upgrade/GITHUB_DISCUSSION_TEMPLATE.md +236 -0
  121. package/docs/specs/vnext-upgrade/M8.9-PROGRESS-UPDATE.md +248 -0
  122. package/docs/specs/vnext-upgrade/PROGRESS-SUMMARY.md +195 -0
  123. package/docs/specs/vnext-upgrade/QUICK_REFERENCE.md +338 -0
  124. package/docs/specs/vnext-upgrade/README.md +125 -0
  125. package/docs/specs/vnext-upgrade/STATUS-UPDATE-2026-01-26.md +230 -0
  126. package/docs/specs/vnext-upgrade/TOOL_CLEANUP.md +343 -0
  127. package/docs/specs/vnext-upgrade/completed/M1-M2-SUMMARY.md +27 -0
  128. package/docs/specs/vnext-upgrade/completed/M3_COMPLETION_SUMMARY.md +273 -0
  129. package/docs/specs/vnext-upgrade/completed/M4-SUMMARY.md +19 -0
  130. package/docs/specs/vnext-upgrade/completed/M5_COMPLETION_SUMMARY.md +0 -0
  131. package/docs/specs/vnext-upgrade/completed/M8.1-SUMMARY.md +247 -0
  132. package/docs/specs/vnext-upgrade/completed/M8.2-SUMMARY.md +296 -0
  133. package/docs/specs/vnext-upgrade/completed/M8.3-SUMMARY.md +241 -0
  134. package/docs/specs/vnext-upgrade/completed/M8.3-TEST-SUMMARY.md +216 -0
  135. package/docs/specs/vnext-upgrade/completed/M8.4-SUMMARY.md +217 -0
  136. package/docs/specs/vnext-upgrade/completed/M8.4-TEST-SUMMARY.md +198 -0
  137. package/docs/specs/vnext-upgrade/completed/M8.5-SUMMARY.md +202 -0
  138. package/docs/specs/vnext-upgrade/completed/M8.5-TEST-SUMMARY.md +223 -0
  139. package/docs/specs/vnext-upgrade/completed/M8.6-SUMMARY.md +299 -0
  140. package/docs/specs/vnext-upgrade/completed/M8.8-TEST-SUMMARY.md +216 -0
  141. package/docs/specs/vnext-upgrade/completed/TOOL-CLEANUP-SUMMARY.md +210 -0
  142. package/docs/specs/vnext-upgrade/design.md +848 -0
  143. package/docs/specs/vnext-upgrade/requirements.md +221 -0
  144. package/docs/specs/vnext-upgrade/tasks/00-INDEX.md +335 -0
  145. package/docs/specs/vnext-upgrade/tasks/M8.1-SCHEMA-DEFINITION.md +300 -0
  146. package/docs/specs/vnext-upgrade/tasks/M8.2-P1-TOOLS.md +249 -0
  147. package/docs/specs/vnext-upgrade/tasks/M8.3-GENERATION-TOOLS.md +49 -0
  148. package/docs/specs/vnext-upgrade/tasks/M8.4-ORCHESTRATION-TOOLS.md +28 -0
  149. package/docs/specs/vnext-upgrade/tasks/M8.5-PROJECT-TOOLS.md +29 -0
  150. package/docs/specs/vnext-upgrade/tasks/M8.6-UI-TOOLS.md +66 -0
  151. package/docs/specs/vnext-upgrade/tasks/M8.7-HELPER-TOOLS.md +24 -0
  152. package/docs/specs/vnext-upgrade/tasks/M8.8-INTEGRATION-TESTS.md +90 -0
  153. package/docs/specs/vnext-upgrade/tasks/M8.9-DOCUMENTATION.md +103 -0
  154. package/docs/styles/docs.css +556 -0
  155. package/docs/styles/page.css +815 -0
  156. package/docs/vnext/MCP_2025-11-25_GUIDE.md +276 -0
  157. package/docs/vnext/vNext-PRD.md +488 -0
  158. package/package.json +6 -6
  159. package/docs/BEST_PRACTICES.md +0 -1185
  160. package/docs/HOW_TO_TRIGGER.md +0 -1141
  161. package/docs/MCP-Probe-Kit-/344/275/277/347/224/250/346/211/213/345/206/214.html +0 -544
  162. package/docs/MCP-Probe-Kit-/344/275/277/347/224/250/346/211/213/345/206/214.md +0 -1447
@@ -295,6 +295,7 @@ describe('[功能描述]', () => {
295
295
  *工具: MCP Probe Kit - fix_bug*
296
296
  `;
297
297
  import { parseArgs, getString } from "../utils/parseArgs.js";
298
+ import { okStructured } from "../lib/response.js";
298
299
  /**
299
300
  * fix_bug 工具实现
300
301
  */
@@ -347,15 +348,32 @@ export async function fixBug(args) {
347
348
  .replace(/{stack_trace_section}/g, stackTraceSection)
348
349
  .replace(/{reproduce_section}/g, reproduceSection)
349
350
  .replace(/{behavior_section}/g, behaviorSection);
350
- return {
351
- content: [{ type: "text", text: guide }],
351
+ // 创建结构化数据
352
+ const structuredData = {
353
+ summary: "Bug 修复指南已生成",
354
+ bugType: "functional", // AI 会填充
355
+ severity: "medium", // AI 会填充
356
+ rootCause: "", // AI 会填充
357
+ fixPlan: {
358
+ steps: [], // AI 会填充
359
+ },
360
+ testPlan: {}, // AI 会填充
352
361
  };
362
+ return okStructured(guide, structuredData, {
363
+ schema: (await import('../schemas/output/core-tools.js')).BugAnalysisSchema,
364
+ });
353
365
  }
354
366
  catch (error) {
355
367
  const errorMsg = error instanceof Error ? error.message : String(error);
356
- return {
357
- content: [{ type: "text", text: `❌ 生成修复指南失败: ${errorMsg}` }],
358
- isError: true,
359
- };
368
+ return okStructured(`❌ 生成修复指南失败: ${errorMsg}`, {
369
+ summary: `生成修复指南失败: ${errorMsg}`,
370
+ bugType: "functional",
371
+ severity: "low",
372
+ rootCause: errorMsg,
373
+ fixPlan: { steps: [] },
374
+ testPlan: {},
375
+ }, {
376
+ schema: (await import('../schemas/output/core-tools.js')).BugAnalysisSchema,
377
+ });
360
378
  }
361
379
  }
@@ -1,22 +1,4 @@
1
- /**
2
- * gen_mock 工具
3
- *
4
- * 功能:根据数据结构生成 Mock 数据
5
- * 模式:指令生成器模式 - 返回生成指南,由 AI 执行实际生成
6
- */
7
1
  /**
8
2
  * gen_mock 工具实现
9
3
  */
10
- export declare function genMock(args: any): Promise<{
11
- content: {
12
- type: string;
13
- text: string;
14
- }[];
15
- isError?: undefined;
16
- } | {
17
- content: {
18
- type: string;
19
- text: string;
20
- }[];
21
- isError: boolean;
22
- }>;
4
+ export declare function genMock(args: any): Promise<import("../lib/response.js").ToolResponse>;
@@ -1,208 +1,5 @@
1
- /**
2
- * gen_mock 工具
3
- *
4
- * 功能:根据数据结构生成 Mock 数据
5
- * 模式:指令生成器模式 - 返回生成指南,由 AI 执行实际生成
6
- */
7
- const PROMPT_TEMPLATE = `# Mock 数据生成指南
8
-
9
- ## 🎯 生成目标
10
-
11
- **数据结构**:
12
- \`\`\`
13
- {schema}
14
- \`\`\`
15
-
16
- **生成配置**:
17
- - 数量: {count} 条
18
- - 格式: {format}
19
- - 语言: {locale}
20
- {seed_section}
21
-
22
- ---
23
-
24
- ## 📋 生成步骤
25
-
26
- ### 步骤 1: 解析数据结构
27
-
28
- 分析输入的数据结构,识别:
29
- 1. 字段名称和类型
30
- 2. 必填/可选字段(?标记)
31
- 3. 嵌套结构
32
- 4. 数组类型
33
-
34
- ### 步骤 2: 字段语义识别
35
-
36
- 根据字段名自动匹配语义,生成符合语义的数据:
37
-
38
- | 字段名模式 | 生成规则 | 中文示例 | 英文示例 |
39
- |------------|----------|----------|----------|
40
- | id, _id | UUID/自增ID | uuid-xxx | uuid-xxx |
41
- | name, 姓名 | 人名 | 张三、李四 | John Doe |
42
- | email, 邮箱 | 邮箱格式 | zhangsan@example.com | john@example.com |
43
- | phone, mobile, 手机 | 手机号 | 138xxxx1234 | +1-xxx-xxx-xxxx |
44
- | avatar, 头像 | 图片URL | https://api.dicebear.com/... | |
45
- | address, 地址 | 地址 | 北京市朝阳区xxx | 123 Main St |
46
- | city, 城市 | 城市名 | 北京、上海 | New York |
47
- | country, 国家 | 国家名 | 中国 | United States |
48
- | date, 日期 | 日期 | 2024-01-15 | 2024-01-15 |
49
- | createdAt, created_at | 过去时间 | 2024-01-01T10:00:00Z | |
50
- | updatedAt, updated_at | 最近时间 | 2024-01-15T15:30:00Z | |
51
- | title, 标题 | 短句 | 这是一个标题 | A Sample Title |
52
- | description, desc, 描述 | 段落 | 这是描述内容... | Lorem ipsum... |
53
- | content, 内容 | 长文本 | 文章内容... | Article content... |
54
- | price, 价格 | 金额 | 99.00 | 99.00 |
55
- | amount, 数量 | 整数 | 10 | 10 |
56
- | status, 状态 | 枚举 | active/inactive | active/inactive |
57
- | type, 类型 | 枚举 | 根据上下文 | |
58
- | url, 链接 | URL | https://example.com | |
59
- | image, 图片 | 图片URL | https://picsum.photos/... | |
60
- | age, 年龄 | 18-60 | 25 | 25 |
61
- | gender, 性别 | 性别 | 男/女 | male/female |
62
- | username, 用户名 | 用户名 | user_123 | user_123 |
63
- | password, 密码 | 密码占位 | ******** | ******** |
64
- | token | Token | tok_xxx | tok_xxx |
65
- | code, 编码 | 编码 | CODE001 | CODE001 |
66
- | sort, order, 排序 | 序号 | 1, 2, 3 | 1, 2, 3 |
67
- | enabled, active | 布尔 | true/false | true/false |
68
- | tags, 标签 | 标签数组 | ["标签1", "标签2"] | ["tag1", "tag2"] |
69
-
70
- ### 步骤 3: 类型映射
71
-
72
- 基础类型的默认生成规则:
73
-
74
- | 类型 | 生成规则 |
75
- |------|----------|
76
- | string | 根据字段名语义,或随机字符串 |
77
- | number | 1-100 的随机整数 |
78
- | boolean | true/false 随机 |
79
- | Date | 最近30天内的随机时间 |
80
- | string[] | 3-5个随机字符串 |
81
- | number[] | 3-5个随机数字 |
82
- | enum | 从枚举值中随机选择 |
83
- | union | 从联合类型中随机选择 |
84
-
85
- ### 步骤 4: 生成数据
86
-
87
- 根据识别结果生成 {count} 条数据。
88
-
89
- **注意事项**:
90
- - 确保数据多样性,避免重复
91
- - 数值类型保持合理范围
92
- - 日期类型保持合理顺序(createdAt < updatedAt)
93
- - 关联字段保持一致性
94
-
95
- ---
96
-
97
- ## 📊 输出格式
98
-
99
- ### JSON 格式
100
- \`\`\`json
101
- [
102
- {
103
- "field1": "value1",
104
- "field2": 123
105
- }
106
- ]
107
- \`\`\`
108
-
109
- ### TypeScript 格式
110
- \`\`\`typescript
111
- const mockData: YourType[] = [
112
- {
113
- field1: "value1",
114
- field2: 123
115
- }
116
- ];
117
-
118
- export default mockData;
119
- \`\`\`
120
-
121
- ### JavaScript 格式
122
- \`\`\`javascript
123
- const mockData = [
124
- {
125
- field1: "value1",
126
- field2: 123
127
- }
128
- ];
129
-
130
- module.exports = mockData;
131
- \`\`\`
132
-
133
- ### CSV 格式(仅扁平数据)
134
- \`\`\`csv
135
- field1,field2
136
- value1,123
137
- \`\`\`
138
-
139
- ---
140
-
141
- ## 🔧 高级功能
142
-
143
- ### 自定义规则
144
-
145
- 在 schema 注释中指定规则:
146
-
147
- \`\`\`typescript
148
- interface User {
149
- id: string; // UUID
150
- age: number; // range: 18-60
151
- status: string; // enum: active, inactive, pending
152
- score: number; // range: 0-100, decimal: 2
153
- tags: string[]; // count: 3-5
154
- level: number; // enum: 1, 2, 3
155
- }
156
- \`\`\`
157
-
158
- ### 关联数据
159
-
160
- 生成有关联关系的数据:
161
-
162
- \`\`\`json
163
- // 先生成 users
164
- [
165
- { "id": "user-1", "name": "张三" },
166
- { "id": "user-2", "name": "李四" }
167
- ]
168
-
169
- // 再生成 orders,引用 user_id
170
- [
171
- { "id": "order-1", "user_id": "user-1", "amount": 100 },
172
- { "id": "order-2", "user_id": "user-2", "amount": 200 }
173
- ]
174
- \`\`\`
175
-
176
- ### 固定值
177
-
178
- 某些字段使用固定值:
179
-
180
- \`\`\`typescript
181
- interface Config {
182
- version: string; // fixed: "1.0.0"
183
- env: string; // fixed: "development"
184
- }
185
- \`\`\`
186
-
187
- ---
188
-
189
- ## ✅ 生成检查清单
190
-
191
- - [ ] 数据结构已正确解析
192
- - [ ] 字段语义已识别
193
- - [ ] 数据类型正确
194
- - [ ] 数量符合要求: {count} 条
195
- - [ ] 格式正确: {format}
196
- - [ ] 语言符合设置: {locale}
197
- - [ ] 数据具有多样性
198
- - [ ] 关联数据一致(如有)
199
-
200
- ---
201
-
202
- *指南版本: 1.0.0*
203
- *工具: MCP Probe Kit - gen_mock*
204
- `;
205
1
  import { parseArgs, getString, getNumber } from "../utils/parseArgs.js";
2
+ import { okStructured } from "../lib/response.js";
206
3
  /**
207
4
  * gen_mock 工具实现
208
5
  */
@@ -237,33 +34,51 @@ export async function genMock(args) {
237
34
  if (count < 1 || count > 1000) {
238
35
  throw new Error("count 参数必须在 1-1000 之间");
239
36
  }
240
- const formatMap = {
241
- json: "JSON",
242
- typescript: "TypeScript",
243
- javascript: "JavaScript",
244
- csv: "CSV",
245
- };
246
- const localeMap = {
247
- "zh-CN": "中文(简体)",
248
- "en-US": "英文(美国)",
249
- "ja-JP": "日文",
250
- };
251
- const seedSection = seed ? `- 随机种子: ${seed}(可重复生成)` : "";
252
- const guide = PROMPT_TEMPLATE
253
- .replace(/{schema}/g, schema)
254
- .replace(/{count}/g, String(count))
255
- .replace(/{format}/g, formatMap[format] || format)
256
- .replace(/{locale}/g, localeMap[locale] || locale)
257
- .replace(/{seed_section}/g, seedSection);
258
- return {
259
- content: [{ type: "text", text: guide }],
37
+ const message = `请生成 Mock 数据:
38
+
39
+ 📝 **数据结构**:
40
+ \`\`\`
41
+ ${schema}
42
+ \`\`\`
43
+
44
+ 📋 **生成配置**:
45
+ - 数量: ${count} 条
46
+ - 格式: ${format}
47
+ - 语言: ${locale}
48
+ ${seed ? `- 随机种子: ${seed}(可重复生成)` : ""}
49
+
50
+ ---
51
+
52
+ ## Mock 数据生成指南
53
+
54
+ 请根据数据结构生成 ${count} 条 Mock 数据,注意:
55
+ 1. 根据字段名识别语义(如 email、phone、name 等)
56
+ 2. 生成符合语义的真实数据
57
+ 3. 确保数据多样性
58
+ 4. 保持关联数据一致性
59
+
60
+ **重要**: 请使用结构化输出格式返回结果。`;
61
+ // 创建结构化数据对象
62
+ const structuredData = {
63
+ summary: `生成 ${count} 条 ${format} 格式的 Mock 数据`,
64
+ format: format,
65
+ count: count,
66
+ data: [], // AI 将填充实际的 Mock 数据
260
67
  };
68
+ return okStructured(message, structuredData, {
69
+ schema: (await import("../schemas/output/generation-tools.js")).MockDataSchema,
70
+ });
261
71
  }
262
72
  catch (error) {
263
73
  const errorMsg = error instanceof Error ? error.message : String(error);
264
- return {
265
- content: [{ type: "text", text: `❌ Mock 数据生成失败: ${errorMsg}` }],
266
- isError: true,
74
+ const errorData = {
75
+ summary: "Mock 数据生成失败",
76
+ format: "json",
77
+ count: 0,
78
+ data: [],
267
79
  };
80
+ return okStructured(`❌ Mock 数据生成失败: ${errorMsg}`, errorData, {
81
+ schema: (await import("../schemas/output/generation-tools.js")).MockDataSchema,
82
+ });
268
83
  }
269
84
  }
@@ -1,13 +1 @@
1
- export declare function genapi(args: any): Promise<{
2
- content: {
3
- type: string;
4
- text: string;
5
- }[];
6
- isError?: undefined;
7
- } | {
8
- content: {
9
- type: string;
10
- text: string;
11
- }[];
12
- isError: boolean;
13
- }>;
1
+ export declare function genapi(args: any): Promise<import("../lib/response.js").ToolResponse>;
@@ -1,4 +1,5 @@
1
1
  import { parseArgs, getString } from "../utils/parseArgs.js";
2
+ import { okStructured } from "../lib/response.js";
2
3
  // genapi 工具实现
3
4
  export async function genapi(args) {
4
5
  try {
@@ -150,25 +151,27 @@ paths:
150
151
  - ✅ 输出完整的 API 文档
151
152
 
152
153
  现在请根据上述代码生成完整的 API 文档。`;
153
- return {
154
- content: [
155
- {
156
- type: "text",
157
- text: message,
158
- },
159
- ],
154
+ // 创建结构化数据对象
155
+ const apiDoc = {
156
+ summary: `生成 ${format} 格式的 API 文档`,
157
+ format: format,
158
+ endpoints: [],
159
+ documentation: message,
160
160
  };
161
+ return okStructured(message, apiDoc, {
162
+ schema: (await import("../schemas/output/generation-tools.js")).APIDocumentationSchema,
163
+ });
161
164
  }
162
165
  catch (error) {
163
166
  const errorMessage = error instanceof Error ? error.message : String(error);
164
- return {
165
- content: [
166
- {
167
- type: "text",
168
- text: `❌ 生成 API 文档失败: ${errorMessage}`,
169
- },
170
- ],
171
- isError: true,
167
+ const errorData = {
168
+ summary: `生成 API 文档失败: ${errorMessage}`,
169
+ format: 'markdown',
170
+ endpoints: [],
171
+ documentation: '',
172
172
  };
173
+ return okStructured(`❌ 生成 API 文档失败: ${errorMessage}`, errorData, {
174
+ schema: (await import("../schemas/output/generation-tools.js")).APIDocumentationSchema,
175
+ });
173
176
  }
174
177
  }
@@ -1,13 +1 @@
1
- export declare function genchangelog(args: any): Promise<{
2
- content: {
3
- type: string;
4
- text: string;
5
- }[];
6
- isError?: undefined;
7
- } | {
8
- content: {
9
- type: string;
10
- text: string;
11
- }[];
12
- isError: boolean;
13
- }>;
1
+ export declare function genchangelog(args: any): Promise<import("../lib/response.js").ToolResponse>;
@@ -1,4 +1,5 @@
1
1
  import { parseArgs, getString } from "../utils/parseArgs.js";
2
+ import { okStructured } from "../lib/response.js";
2
3
  // genchangelog 工具实现
3
4
  export async function genchangelog(args) {
4
5
  try {
@@ -29,222 +30,45 @@ ${version || "请提供版本号(如:v1.2.0)"}
29
30
 
30
31
  ---
31
32
 
32
- ## Changelog 生成步骤
33
-
34
- ### 第一步:获取 Commit 历史
35
-
36
- 执行以下命令:
37
- \`\`\`bash
38
- # 查看 commit 历史
39
- git log ${from}..${to} --oneline --no-merges
40
-
41
- # 查看详细信息
42
- git log ${from}..${to} --pretty=format:"%h - %s (%an)" --no-merges
43
-
44
- # 查看所有 tags
45
- git tag -l
46
-
47
- # 查看贡献者
48
- git shortlog ${from}..${to} -sn
49
- \`\`\`
50
-
51
- ### 第二步:分类 Commits
52
-
53
- 按类型分组:
54
- - **✨ Features (feat)**:新功能
55
- - **🐛 Bug Fixes (fix)**:Bug 修复
56
- - **📝 Documentation (docs)**:文档变更
57
- - **💄 Styles (style)**:代码格式
58
- - **♻️ Refactoring (refactor)**:重构
59
- - **⚡ Performance (perf)**:性能优化
60
- - **✅ Tests (test)**:测试相关
61
- - **🔧 Chores (chore)**:构建/工具变更
62
- - **💥 BREAKING CHANGES**:破坏性变更
63
-
64
- ### 第三步:生成 Changelog
65
-
66
- **格式标准**:[Keep a Changelog](https://keepachangelog.com/)
67
-
68
- \`\`\`markdown
69
- # Changelog
70
-
71
- All notable changes to this project will be documented in this file.
72
-
73
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
74
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
75
-
76
- ## [版本号] - YYYY-MM-DD
77
-
78
- ### Added(新增)
79
- - 新功能 1 (#PR号)
80
- - 新功能 2 by @contributor
81
-
82
- ### Changed(变更)
83
- - 修改的功能 1
84
- - 修改的功能 2
85
-
86
- ### Deprecated(废弃)
87
- - 即将移除的功能
88
-
89
- ### Removed(移除)
90
- - 已移除的功能
91
-
92
- ### Fixed(修复)
93
- - Bug 修复 1 (#issue号)
94
- - Bug 修复 2
95
-
96
- ### Security(安全)
97
- - 安全漏洞修复
98
-
99
- ## [上一个版本] - YYYY-MM-DD
100
-
101
- ...
102
- \`\`\`
103
-
104
- ---
105
-
106
- ## Changelog 模板
107
-
108
- \`\`\`markdown
109
- # Changelog
110
-
111
- ## [${version || "1.2.0"}] - ${new Date().toISOString().split('T')[0]}
112
-
113
- ### ✨ Added
114
- - 新增用户认证功能 (#123) [@contributor1]
115
- - 新增数据导出功能 (#125)
116
- - 新增邮件通知系统
117
-
118
- ### 🔄 Changed
119
- - 优化数据库查询性能 (#130)
120
- - 更新 UI 设计风格
121
- - 升级依赖包到最新版本
122
-
123
- ### 🗑️ Deprecated
124
- - \`oldAPI()\` 方法即将在 v2.0 中移除,请使用 \`newAPI()\`
125
-
126
- ### ❌ Removed
127
- - 移除了废弃的 \`legacyFeature\`
128
- - 删除了未使用的配置项
129
-
130
- ### 🐛 Fixed
131
- - 修复登录页面样式错误 (#128)
132
- - 修复数据分页显示问题 (#132)
133
- - 修复内存泄漏问题 (#135)
134
-
135
- ### 🔒 Security
136
- - 修复 SQL 注入漏洞 (CVE-2024-XXXX)
137
- - 更新依赖以修复安全漏洞
138
-
139
- ### 💥 BREAKING CHANGES
140
- - API 端点从 \`/api/v1/users\` 改为 \`/api/v2/users\`
141
- - 配置文件格式从 JSON 改为 YAML
142
- - 最低 Node.js 版本要求提升到 18.x
143
-
144
- ### 📚 Documentation
145
- - 更新 README 文档
146
- - 添加 API 使用指南
147
- - 完善贡献指南
148
-
149
- ### 🏗️ Infrastructure
150
- - 升级 CI/CD 流程
151
- - 添加 Docker 支持
152
- - 配置自动化测试
153
-
154
- ### 👥 Contributors
155
- 感谢以下贡献者:
156
- - @contributor1 - 3 commits
157
- - @contributor2 - 2 commits
158
- - @contributor3 - 1 commit
159
-
160
- **Full Changelog**: https://github.com/owner/repo/compare/v1.1.0...v${version || "1.2.0"}
161
- \`\`\`
162
-
163
- ---
164
-
165
- ## Changelog 最佳实践
166
-
167
- ### 内容要求
168
-
169
- 1. **明确说明变更**
170
- - 用户能理解的语言(避免技术术语)
171
- - 说明影响范围
172
- - 提供迁移指南(破坏性变更)
173
-
174
- 2. **链接相关 Issue/PR**
175
- - 使用 (#123) 格式
176
- - 方便追溯详细信息
177
-
178
- 3. **归功贡献者**
179
- - 使用 @username 格式
180
- - 体现团队协作
181
-
182
- ### 版本规范
183
-
184
- **语义化版本 (Semantic Versioning)**:
185
- - **Major (X.0.0)**:破坏性变更
186
- - **Minor (x.X.0)**:新功能(向后兼容)
187
- - **Patch (x.x.X)**:Bug 修复
188
-
189
- ### 发布流程
190
-
191
- 1. 更新 CHANGELOG.md
192
- 2. 更新 package.json 版本号
193
- 3. 创建 Git tag:\`git tag -a v1.2.0 -m "Release v1.2.0"\`
194
- 4. 推送 tag:\`git push origin v1.2.0\`
195
- 5. 发布 GitHub Release
196
-
197
- ---
198
-
199
- ## 自动化工具
200
-
201
- **推荐工具**:
202
- - **standard-version**:自动生成 changelog
203
- - **conventional-changelog**:基于 commit 生成
204
- - **semantic-release**:自动发布版本
205
-
206
- **使用示例**:
207
- \`\`\`bash
208
- # 安装
209
- npm install -D standard-version
210
-
211
- # 生成 changelog
212
- npx standard-version
213
-
214
- # 首次发布
215
- npx standard-version --first-release
216
- \`\`\`
217
-
218
- ---
219
-
220
- ---
221
-
222
- ## ⚠️ 边界约束
223
-
224
- - ❌ 仅输出 CHANGELOG 文本,不自动写入文件
225
- - ❌ 不执行 git 命令
226
- - ✅ 输出完整的 CHANGELOG Markdown
227
-
228
- 现在请根据 commit 历史生成详细的 CHANGELOG.md 内容。`;
229
- return {
230
- content: [
231
- {
232
- type: "text",
233
- text: message,
234
- },
235
- ],
33
+ ## Changelog 生成指南
34
+
35
+ 请生成符合 [Keep a Changelog](https://keepachangelog.com/) 规范的 CHANGELOG,包括:
36
+
37
+ 1. **Added(新增)** - 新功能
38
+ 2. **Changed(变更)** - 功能修改
39
+ 3. **Deprecated(废弃)** - 即将移除的功能
40
+ 4. **Removed(移除)** - 已移除的功能
41
+ 5. **Fixed(修复)** - Bug 修复
42
+ 6. **Security(安全)** - 安全漏洞修复
43
+
44
+ **重要**: 请使用结构化输出格式返回结果。`;
45
+ // 创建结构化数据对象
46
+ const structuredData = {
47
+ summary: `生成 ${version || "新版本"} 的 Changelog`,
48
+ version: version || "",
49
+ date: new Date().toISOString().split('T')[0],
50
+ content: "", // AI 将填充实际的 Changelog 内容
51
+ changes: {
52
+ features: [],
53
+ fixes: [],
54
+ breaking: [],
55
+ },
236
56
  };
57
+ return okStructured(message, structuredData, {
58
+ schema: (await import("../schemas/output/generation-tools.js")).ChangelogSchema,
59
+ });
237
60
  }
238
61
  catch (error) {
239
62
  const errorMessage = error instanceof Error ? error.message : String(error);
240
- return {
241
- content: [
242
- {
243
- type: "text",
244
- text: `❌ 生成 Changelog 失败: ${errorMessage}`,
245
- },
246
- ],
247
- isError: true,
63
+ const errorData = {
64
+ summary: "Changelog 生成失败",
65
+ version: "",
66
+ date: new Date().toISOString().split('T')[0],
67
+ content: "",
68
+ changes: {},
248
69
  };
70
+ return okStructured(`❌ 生成 Changelog 失败: ${errorMessage}`, errorData, {
71
+ schema: (await import("../schemas/output/generation-tools.js")).ChangelogSchema,
72
+ });
249
73
  }
250
74
  }