mcp-probe-kit 1.15.0 → 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/css_order.js +55 -55
- 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 +4 -4
- package/build/utils/design-docs-generator.d.ts +0 -1
- package/build/utils/design-docs-generator.js +0 -1
- 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,4 +1,6 @@
|
|
|
1
1
|
import { parseArgs, getString } from "../utils/parseArgs.js";
|
|
2
|
+
import { okStructured } from "../lib/response.js";
|
|
3
|
+
import { FeatureReportSchema } from "../schemas/structured-output.js";
|
|
2
4
|
/**
|
|
3
5
|
* start_feature 智能编排工具
|
|
4
6
|
*
|
|
@@ -180,9 +182,59 @@ export async function startFeature(args) {
|
|
|
180
182
|
.replace(/{feature_name}/g, featureName)
|
|
181
183
|
.replace(/{description}/g, description)
|
|
182
184
|
.replace(/{docs_dir}/g, docsDir);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
+
// 创建结构化的功能开发报告
|
|
186
|
+
const featureReport = {
|
|
187
|
+
summary: `新功能开发工作流:${featureName}`,
|
|
188
|
+
status: 'pending',
|
|
189
|
+
steps: [
|
|
190
|
+
{
|
|
191
|
+
name: '检查项目上下文',
|
|
192
|
+
status: 'pending',
|
|
193
|
+
description: `检查 ${docsDir}/project-context.md 是否存在,如不存在则调用 init_project_context`,
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: '生成功能规格',
|
|
197
|
+
status: 'pending',
|
|
198
|
+
description: '调用 add_feature 工具生成需求、设计和任务文档',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: '工作量估算',
|
|
202
|
+
status: 'pending',
|
|
203
|
+
description: '调用 estimate 工具进行工作量估算',
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
artifacts: [],
|
|
207
|
+
nextSteps: [
|
|
208
|
+
'检查并读取项目上下文文档',
|
|
209
|
+
'调用 add_feature 工具生成功能规格文档',
|
|
210
|
+
'调用 estimate 工具进行工作量估算',
|
|
211
|
+
'按照 tasks.md 开始开发',
|
|
212
|
+
],
|
|
213
|
+
specArtifacts: [
|
|
214
|
+
{
|
|
215
|
+
path: `${docsDir}/specs/${featureName}/requirements.md`,
|
|
216
|
+
type: 'requirements',
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
path: `${docsDir}/specs/${featureName}/design.md`,
|
|
220
|
+
type: 'design',
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
path: `${docsDir}/specs/${featureName}/tasks.md`,
|
|
224
|
+
type: 'tasks',
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
estimate: {
|
|
228
|
+
optimistic: '待估算',
|
|
229
|
+
normal: '待估算',
|
|
230
|
+
pessimistic: '待估算',
|
|
231
|
+
},
|
|
232
|
+
dependencies: [],
|
|
185
233
|
};
|
|
234
|
+
return okStructured(guide, featureReport, {
|
|
235
|
+
schema: FeatureReportSchema,
|
|
236
|
+
note: 'AI 应该按照指南执行步骤,并在每个步骤完成后更新 structuredContent 中的状态和估算信息',
|
|
237
|
+
});
|
|
186
238
|
}
|
|
187
239
|
catch (error) {
|
|
188
240
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
export declare function startOnboard(args: any): Promise<{
|
|
2
|
-
content: {
|
|
3
|
-
type: string;
|
|
4
|
-
text: string;
|
|
5
|
-
}[];
|
|
6
|
-
isError?: undefined;
|
|
7
|
-
} | {
|
|
1
|
+
export declare function startOnboard(args: any): Promise<import("../lib/response.js").ToolResponse | {
|
|
8
2
|
content: {
|
|
9
3
|
type: string;
|
|
10
4
|
text: string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { parseArgs, getString } from "../utils/parseArgs.js";
|
|
2
|
+
import { okStructured } from "../lib/response.js";
|
|
3
|
+
import { OnboardingReportSchema } from "../schemas/structured-output.js";
|
|
2
4
|
/**
|
|
3
5
|
* start_onboard 智能编排工具
|
|
4
6
|
*
|
|
@@ -145,9 +147,45 @@ export async function startOnboard(args) {
|
|
|
145
147
|
const guide = PROMPT_TEMPLATE
|
|
146
148
|
.replace(/{project_path}/g, projectPath)
|
|
147
149
|
.replace(/{docs_dir}/g, docsDir);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
// Create structured onboarding report
|
|
151
|
+
const onboardingReport = {
|
|
152
|
+
summary: `项目上手工作流:${projectPath}`,
|
|
153
|
+
status: 'pending',
|
|
154
|
+
steps: [
|
|
155
|
+
{
|
|
156
|
+
name: '项目分析',
|
|
157
|
+
status: 'pending',
|
|
158
|
+
description: '调用 analyze_project 分析项目结构和技术栈',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: '生成项目上下文',
|
|
162
|
+
status: 'pending',
|
|
163
|
+
description: '调用 init_project_context 生成项目文档',
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
artifacts: [],
|
|
167
|
+
nextSteps: [
|
|
168
|
+
'调用 analyze_project 分析项目',
|
|
169
|
+
'调用 init_project_context 生成文档',
|
|
170
|
+
`阅读 ${docsDir}/project-context.md`,
|
|
171
|
+
'查看 README.md 了解项目背景',
|
|
172
|
+
],
|
|
173
|
+
projectSummary: {
|
|
174
|
+
name: '待分析',
|
|
175
|
+
description: '待分析',
|
|
176
|
+
techStack: [],
|
|
177
|
+
architecture: '待分析',
|
|
178
|
+
},
|
|
179
|
+
quickstart: {
|
|
180
|
+
setup: ['待分析'],
|
|
181
|
+
commonTasks: [],
|
|
182
|
+
},
|
|
183
|
+
keyFiles: [],
|
|
150
184
|
};
|
|
185
|
+
return okStructured(guide, onboardingReport, {
|
|
186
|
+
schema: OnboardingReportSchema,
|
|
187
|
+
note: 'AI 应该按照指南执行步骤,并在分析完成后更新 structuredContent 中的项目信息',
|
|
188
|
+
});
|
|
151
189
|
}
|
|
152
190
|
catch (error) {
|
|
153
191
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* start_ralph 主函数
|
|
3
3
|
*/
|
|
4
|
-
export declare function startRalph(args: any): Promise<{
|
|
5
|
-
content: {
|
|
6
|
-
type: string;
|
|
7
|
-
text: string;
|
|
8
|
-
}[];
|
|
9
|
-
isError?: undefined;
|
|
10
|
-
} | {
|
|
4
|
+
export declare function startRalph(args: any): Promise<import("../lib/response.js").ToolResponse | {
|
|
11
5
|
content: {
|
|
12
6
|
type: string;
|
|
13
7
|
text: string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { parseArgs, getString, getNumber } from "../utils/parseArgs.js";
|
|
2
|
+
import { okStructured } from "../lib/response.js";
|
|
3
|
+
import { RalphLoopReportSchema } from "../schemas/structured-output.js";
|
|
2
4
|
// 默认值(保守安全)
|
|
3
5
|
const DEFAULTS = {
|
|
4
6
|
mode: "safe",
|
|
@@ -765,9 +767,93 @@ ${normalScript}
|
|
|
765
767
|
|
|
766
768
|
**Happy coding! 🚀**
|
|
767
769
|
`;
|
|
768
|
-
|
|
769
|
-
|
|
770
|
+
// Create structured Ralph Loop report
|
|
771
|
+
const ralphReport = {
|
|
772
|
+
summary: `Ralph Loop 循环开发:${params.goal}`,
|
|
773
|
+
status: 'pending',
|
|
774
|
+
steps: [
|
|
775
|
+
{
|
|
776
|
+
name: '创建 .ralph 目录',
|
|
777
|
+
status: 'pending',
|
|
778
|
+
description: '创建 .ralph/ 目录结构',
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
name: '复制配置文件',
|
|
782
|
+
status: 'pending',
|
|
783
|
+
description: '复制 PROMPT.md, @fix_plan.md, PROGRESS.md 和脚本文件',
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
name: '配置脚本权限',
|
|
787
|
+
status: 'pending',
|
|
788
|
+
description: '使脚本可执行(Linux/Mac)',
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
name: '启动循环',
|
|
792
|
+
status: 'pending',
|
|
793
|
+
description: '运行 ralph_loop_safe 脚本',
|
|
794
|
+
},
|
|
795
|
+
],
|
|
796
|
+
artifacts: [
|
|
797
|
+
{
|
|
798
|
+
path: '.ralph/PROMPT.md',
|
|
799
|
+
type: 'doc',
|
|
800
|
+
purpose: '循环提示词和规则',
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
path: '.ralph/@fix_plan.md',
|
|
804
|
+
type: 'doc',
|
|
805
|
+
purpose: '任务分解和优先级',
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
path: '.ralph/PROGRESS.md',
|
|
809
|
+
type: 'doc',
|
|
810
|
+
purpose: '迭代日志',
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
path: `.ralph/ralph_loop_safe.${isWindows ? 'ps1' : 'sh'}`,
|
|
814
|
+
type: 'config',
|
|
815
|
+
purpose: '安全模式脚本',
|
|
816
|
+
},
|
|
817
|
+
],
|
|
818
|
+
nextSteps: [
|
|
819
|
+
'创建 .ralph/ 目录',
|
|
820
|
+
'复制文件内容到对应文件',
|
|
821
|
+
'使脚本可执行',
|
|
822
|
+
'运行 ralph_loop_safe 脚本',
|
|
823
|
+
],
|
|
824
|
+
loopPolicy: {
|
|
825
|
+
maxIterations: params.max_iterations,
|
|
826
|
+
maxMinutes: params.max_minutes,
|
|
827
|
+
confirmEvery: params.confirm_every,
|
|
828
|
+
cooldownSeconds: params.cooldown_seconds,
|
|
829
|
+
},
|
|
830
|
+
iterations: [],
|
|
831
|
+
stopConditions: {
|
|
832
|
+
reason: '未启动',
|
|
833
|
+
metConditions: [],
|
|
834
|
+
},
|
|
835
|
+
safetyChecks: [
|
|
836
|
+
{
|
|
837
|
+
check: 'Max iterations limit',
|
|
838
|
+
passed: true,
|
|
839
|
+
message: `设置为 ${params.max_iterations} 次`,
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
check: 'Max time limit',
|
|
843
|
+
passed: true,
|
|
844
|
+
message: `设置为 ${params.max_minutes} 分钟`,
|
|
845
|
+
},
|
|
846
|
+
{
|
|
847
|
+
check: 'Confirmation required',
|
|
848
|
+
passed: true,
|
|
849
|
+
message: `每 ${params.confirm_every} 轮确认一次`,
|
|
850
|
+
},
|
|
851
|
+
],
|
|
770
852
|
};
|
|
853
|
+
return okStructured(output, ralphReport, {
|
|
854
|
+
schema: RalphLoopReportSchema,
|
|
855
|
+
note: 'AI 应该帮助用户创建 .ralph/ 目录并复制文件,然后指导用户启动循环',
|
|
856
|
+
});
|
|
771
857
|
}
|
|
772
858
|
catch (error) {
|
|
773
859
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
content: {
|
|
9
|
-
type: string;
|
|
10
|
-
text: string;
|
|
11
|
-
}[];
|
|
12
|
-
isError: boolean;
|
|
13
|
-
}>;
|
|
1
|
+
/**
|
|
2
|
+
* start_refactor 智能编排工具
|
|
3
|
+
*
|
|
4
|
+
* 场景:代码重构
|
|
5
|
+
* 编排:[检查上下文] → code_review → refactor → gentest
|
|
6
|
+
*/
|
|
7
|
+
export declare function startRefactor(args: any): Promise<import("../lib/response.js").ToolResponse>;
|
|
@@ -1,150 +1,11 @@
|
|
|
1
1
|
import { parseArgs, getString } from "../utils/parseArgs.js";
|
|
2
|
+
import { okStructured } from "../lib/response.js";
|
|
2
3
|
/**
|
|
3
4
|
* start_refactor 智能编排工具
|
|
4
5
|
*
|
|
5
6
|
* 场景:代码重构
|
|
6
7
|
* 编排:[检查上下文] → code_review → refactor → gentest
|
|
7
8
|
*/
|
|
8
|
-
const PROMPT_TEMPLATE = `# ♻️ 代码重构编排指南
|
|
9
|
-
|
|
10
|
-
## 🎯 目标
|
|
11
|
-
|
|
12
|
-
重构以下代码:
|
|
13
|
-
|
|
14
|
-
\`\`\`
|
|
15
|
-
{code}
|
|
16
|
-
\`\`\`
|
|
17
|
-
|
|
18
|
-
**重构目标**: {goal}
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## 📋 步骤 0: 项目上下文(自动处理)
|
|
23
|
-
|
|
24
|
-
**操作**:
|
|
25
|
-
1. 检查 \`docs/project-context.md\` 是否存在
|
|
26
|
-
2. **如果不存在**:
|
|
27
|
-
- 调用 \`init_project_context\` 工具
|
|
28
|
-
- 等待生成完成
|
|
29
|
-
3. **读取** \`docs/project-context.md\` 内容
|
|
30
|
-
4. 了解项目的架构模式、编码规范
|
|
31
|
-
5. 重构要符合项目规范
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## 🔍 步骤 1: 代码审查(发现问题)
|
|
36
|
-
|
|
37
|
-
**调用工具**: \`code_review\`
|
|
38
|
-
|
|
39
|
-
**参数**:
|
|
40
|
-
\`\`\`json
|
|
41
|
-
{
|
|
42
|
-
"code": "[待重构代码]",
|
|
43
|
-
"focus": "quality"
|
|
44
|
-
}
|
|
45
|
-
\`\`\`
|
|
46
|
-
|
|
47
|
-
**目的**:
|
|
48
|
-
- 识别代码坏味道
|
|
49
|
-
- 发现可改进点
|
|
50
|
-
- 评估当前代码质量
|
|
51
|
-
|
|
52
|
-
**产出**: 问题清单
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## ♻️ 步骤 2: 生成重构方案
|
|
57
|
-
|
|
58
|
-
**调用工具**: \`refactor\`
|
|
59
|
-
|
|
60
|
-
**参数**:
|
|
61
|
-
\`\`\`json
|
|
62
|
-
{
|
|
63
|
-
"code": "[待重构代码]",
|
|
64
|
-
"goal": "{goal}"
|
|
65
|
-
}
|
|
66
|
-
\`\`\`
|
|
67
|
-
|
|
68
|
-
**重构方向**:
|
|
69
|
-
- improve_readability: 提高可读性
|
|
70
|
-
- reduce_complexity: 降低复杂度
|
|
71
|
-
- extract_function: 提取函数
|
|
72
|
-
- remove_duplication: 消除重复
|
|
73
|
-
- improve_naming: 改进命名
|
|
74
|
-
|
|
75
|
-
**产出**: 重构后的代码 + 重构说明
|
|
76
|
-
|
|
77
|
-
---
|
|
78
|
-
|
|
79
|
-
## 🧪 步骤 3: 生成保护测试
|
|
80
|
-
|
|
81
|
-
**调用工具**: \`gentest\`
|
|
82
|
-
|
|
83
|
-
**参数**:
|
|
84
|
-
\`\`\`json
|
|
85
|
-
{
|
|
86
|
-
"code": "[重构后的代码]",
|
|
87
|
-
"framework": "[根据项目上下文选择]"
|
|
88
|
-
}
|
|
89
|
-
\`\`\`
|
|
90
|
-
|
|
91
|
-
**目的**:
|
|
92
|
-
- 确保重构不改变行为
|
|
93
|
-
- 为重构后的代码提供测试保护
|
|
94
|
-
- 覆盖主要功能和边界情况
|
|
95
|
-
|
|
96
|
-
**产出**: 测试代码
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
## ✅ 完成检查
|
|
101
|
-
|
|
102
|
-
- [ ] 项目上下文已读取
|
|
103
|
-
- [ ] 代码问题已识别
|
|
104
|
-
- [ ] 重构方案已生成
|
|
105
|
-
- [ ] 代码已重构
|
|
106
|
-
- [ ] 测试已添加
|
|
107
|
-
- [ ] 测试已通过
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
## 📝 输出汇总
|
|
112
|
-
|
|
113
|
-
完成后,向用户提供:
|
|
114
|
-
|
|
115
|
-
### 1. 重构前后对比
|
|
116
|
-
|
|
117
|
-
**重构前**:
|
|
118
|
-
\`\`\`
|
|
119
|
-
[原代码]
|
|
120
|
-
\`\`\`
|
|
121
|
-
|
|
122
|
-
**重构后**:
|
|
123
|
-
\`\`\`
|
|
124
|
-
[新代码]
|
|
125
|
-
\`\`\`
|
|
126
|
-
|
|
127
|
-
### 2. 改进说明
|
|
128
|
-
|
|
129
|
-
| 改进项 | 说明 |
|
|
130
|
-
|--------|------|
|
|
131
|
-
| [改进1] | [说明] |
|
|
132
|
-
| [改进2] | [说明] |
|
|
133
|
-
|
|
134
|
-
### 3. 测试覆盖
|
|
135
|
-
|
|
136
|
-
- 测试用例数: X
|
|
137
|
-
- 覆盖场景: [列出]
|
|
138
|
-
|
|
139
|
-
### 4. 注意事项
|
|
140
|
-
|
|
141
|
-
- [重构可能影响的地方]
|
|
142
|
-
- [需要同步修改的地方]
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
*编排工具: MCP Probe Kit - start_refactor*
|
|
147
|
-
`;
|
|
148
9
|
export async function startRefactor(args) {
|
|
149
10
|
try {
|
|
150
11
|
// 智能参数解析,支持自然语言输入
|
|
@@ -171,18 +32,84 @@ export async function startRefactor(args) {
|
|
|
171
32
|
remove_duplication: "消除重复",
|
|
172
33
|
improve_naming: "改进命名",
|
|
173
34
|
};
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
35
|
+
const message = `# ♻️ 代码重构编排
|
|
36
|
+
|
|
37
|
+
重构以下代码:
|
|
38
|
+
|
|
39
|
+
\`\`\`
|
|
40
|
+
${code}
|
|
41
|
+
\`\`\`
|
|
42
|
+
|
|
43
|
+
**重构目标**: ${goalDesc[goal] || goal}
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 📋 执行步骤
|
|
48
|
+
|
|
49
|
+
### 步骤 1: 代码审查(发现问题)
|
|
50
|
+
调用 \`code_review\` 工具,识别代码坏味道、发现可改进点、评估当前代码质量。
|
|
51
|
+
|
|
52
|
+
### 步骤 2: 生成重构方案
|
|
53
|
+
调用 \`refactor\` 工具,根据重构目标生成重构后的代码和重构说明。
|
|
54
|
+
|
|
55
|
+
### 步骤 3: 生成保护测试
|
|
56
|
+
调用 \`gentest\` 工具,为重构后的代码生成测试,确保重构不改变行为。
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 📝 输出内容
|
|
61
|
+
|
|
62
|
+
完成后,提供:
|
|
63
|
+
1. 重构前后对比
|
|
64
|
+
2. 改进说明
|
|
65
|
+
3. 测试覆盖
|
|
66
|
+
4. 注意事项
|
|
67
|
+
|
|
68
|
+
**重要**: 请使用结构化输出格式返回结果。`;
|
|
69
|
+
// 创建结构化数据对象
|
|
70
|
+
const structuredData = {
|
|
71
|
+
summary: `代码重构 - ${goalDesc[goal] || goal}`,
|
|
72
|
+
status: "pending",
|
|
73
|
+
steps: [
|
|
74
|
+
{
|
|
75
|
+
name: "code_review",
|
|
76
|
+
description: "代码审查",
|
|
77
|
+
status: "pending",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "refactor",
|
|
81
|
+
description: "生成重构方案",
|
|
82
|
+
status: "pending",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "gentest",
|
|
86
|
+
description: "生成保护测试",
|
|
87
|
+
status: "pending",
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
refactorPlan: {}, // AI 将填充实际的重构计划
|
|
91
|
+
riskAssessment: {
|
|
92
|
+
level: "medium",
|
|
93
|
+
},
|
|
179
94
|
};
|
|
95
|
+
return okStructured(message, structuredData, {
|
|
96
|
+
schema: (await import("../schemas/output/workflow-tools.js")).RefactorWorkflowSchema,
|
|
97
|
+
});
|
|
180
98
|
}
|
|
181
99
|
catch (error) {
|
|
182
100
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
101
|
+
const errorData = {
|
|
102
|
+
summary: "代码重构失败",
|
|
103
|
+
status: "failed",
|
|
104
|
+
steps: [],
|
|
105
|
+
refactorPlan: {},
|
|
106
|
+
riskAssessment: {
|
|
107
|
+
level: "high",
|
|
108
|
+
},
|
|
109
|
+
warnings: [errorMsg],
|
|
186
110
|
};
|
|
111
|
+
return okStructured(`❌ 编排执行失败: ${errorMsg}`, errorData, {
|
|
112
|
+
schema: (await import("../schemas/output/workflow-tools.js")).RefactorWorkflowSchema,
|
|
113
|
+
});
|
|
187
114
|
}
|
|
188
115
|
}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
content: {
|
|
9
|
-
type: string;
|
|
10
|
-
text: string;
|
|
11
|
-
}[];
|
|
12
|
-
isError: boolean;
|
|
13
|
-
}>;
|
|
1
|
+
/**
|
|
2
|
+
* start_release 智能编排工具
|
|
3
|
+
*
|
|
4
|
+
* 场景:发布准备
|
|
5
|
+
* 编排:[检查上下文] → genchangelog → genpr
|
|
6
|
+
*/
|
|
7
|
+
export declare function startRelease(args: any): Promise<import("../lib/response.js").ToolResponse>;
|