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
|
@@ -13,7 +13,7 @@ describe('start_ui 集成测试', () => {
|
|
|
13
13
|
framework: 'react'
|
|
14
14
|
});
|
|
15
15
|
expect(result.isError).not.toBe(true);
|
|
16
|
-
const text = result.content[0].text;
|
|
16
|
+
const text = result.content[0].text || '';
|
|
17
17
|
// 1. 应该包含快速开始部分
|
|
18
18
|
expect(text).toMatch(/^#\s+快速开始/m);
|
|
19
19
|
// 2. 应该包含 4 个步骤
|
|
@@ -69,7 +69,7 @@ describe('start_ui 集成测试', () => {
|
|
|
69
69
|
framework: 'react'
|
|
70
70
|
});
|
|
71
71
|
expect(result.isError).not.toBe(true);
|
|
72
|
-
const text = result.content[0].text;
|
|
72
|
+
const text = result.content[0].text || '';
|
|
73
73
|
// 应该包含转义后的描述
|
|
74
74
|
expect(text).toMatch(/带有用户认证和权限管理的管理后台/);
|
|
75
75
|
// 所有 JSON 应该是有效的
|
|
@@ -100,7 +100,7 @@ describe('start_ui 集成测试', () => {
|
|
|
100
100
|
mode: 'invalid'
|
|
101
101
|
});
|
|
102
102
|
expect(result.isError).toBe(true);
|
|
103
|
-
const text = result.content[0].text;
|
|
103
|
+
const text = result.content[0].text || '';
|
|
104
104
|
// 应该说明问题
|
|
105
105
|
expect(text).toMatch(/无效的模式/);
|
|
106
106
|
// 应该列出有效选项
|
|
@@ -116,7 +116,7 @@ describe('start_ui 集成测试', () => {
|
|
|
116
116
|
description: '用户列表',
|
|
117
117
|
framework: 'vue'
|
|
118
118
|
});
|
|
119
|
-
const text = result.content[0].text;
|
|
119
|
+
const text = result.content[0].text || '';
|
|
120
120
|
// 提取所有 JSON 代码块
|
|
121
121
|
const jsonBlocks = text.match(/```json\n([\s\S]*?)\n```/g);
|
|
122
122
|
expect(jsonBlocks).toBeTruthy();
|
|
@@ -139,7 +139,7 @@ describe('start_ui 集成测试', () => {
|
|
|
139
139
|
description: '测试',
|
|
140
140
|
framework: 'react'
|
|
141
141
|
});
|
|
142
|
-
const text = result.content[0].text;
|
|
142
|
+
const text = result.content[0].text || '';
|
|
143
143
|
// 定义有效的工具名称
|
|
144
144
|
const validTools = [
|
|
145
145
|
'ui_design_system',
|
|
@@ -14,7 +14,7 @@ describe('start_ui 属性测试', () => {
|
|
|
14
14
|
framework: fc.constantFrom('react', 'vue', 'html')
|
|
15
15
|
}), async (input) => {
|
|
16
16
|
const result = await startUi(input);
|
|
17
|
-
const text = result.content[0].text;
|
|
17
|
+
const text = result.content[0].text || '';
|
|
18
18
|
// 简单的 token 估算:按空格和标点分割
|
|
19
19
|
const tokenCount = text.split(/[\s\n]+/).length;
|
|
20
20
|
// 硬性约束:必须少于 800 tokens
|
|
@@ -28,7 +28,7 @@ describe('start_ui 属性测试', () => {
|
|
|
28
28
|
framework: fc.constantFrom('react', 'vue', 'html')
|
|
29
29
|
}), async (input) => {
|
|
30
30
|
const result = await startUi(input);
|
|
31
|
-
const text = result.content[0].text;
|
|
31
|
+
const text = result.content[0].text || '';
|
|
32
32
|
// 应该包含 H1 标题(快速开始)
|
|
33
33
|
expect(text).toMatch(/^#\s+快速开始/m);
|
|
34
34
|
// 应该包含 H2 标题(步骤)
|
|
@@ -46,7 +46,7 @@ describe('start_ui 属性测试', () => {
|
|
|
46
46
|
framework: fc.constantFrom('react', 'vue', 'html')
|
|
47
47
|
}), async (input) => {
|
|
48
48
|
const result = await startUi(input);
|
|
49
|
-
const text = result.content[0].text;
|
|
49
|
+
const text = result.content[0].text || '';
|
|
50
50
|
// 如果包含 JSON 参数,应该在代码块中
|
|
51
51
|
const jsonBlocks = text.match(/```json[\s\S]*?```/g);
|
|
52
52
|
expect(jsonBlocks).toBeTruthy();
|
|
@@ -60,7 +60,7 @@ describe('start_ui 属性测试', () => {
|
|
|
60
60
|
framework: fc.constantFrom('react', 'vue', 'html')
|
|
61
61
|
}), async (input) => {
|
|
62
62
|
const result = await startUi(input);
|
|
63
|
-
const text = result.content[0].text;
|
|
63
|
+
const text = result.content[0].text || '';
|
|
64
64
|
// 提取所有 JSON 代码块
|
|
65
65
|
const jsonBlocks = text.match(/```json\n([\s\S]*?)\n```/g);
|
|
66
66
|
if (jsonBlocks) {
|
|
@@ -87,7 +87,7 @@ describe('start_ui 属性测试', () => {
|
|
|
87
87
|
framework: fc.constantFrom('react', 'vue', 'html')
|
|
88
88
|
}), async (input) => {
|
|
89
89
|
const result = await startUi(input);
|
|
90
|
-
const text = result.content[0].text;
|
|
90
|
+
const text = result.content[0].text || '';
|
|
91
91
|
// 应该包含有效的工具名称
|
|
92
92
|
const validTools = [
|
|
93
93
|
'ui_design_system',
|
|
@@ -112,7 +112,7 @@ test('任务 3.4: 每个步骤包含预期输出', async () => {
|
|
|
112
112
|
framework: fc.constantFrom('react', 'vue', 'html')
|
|
113
113
|
}), async (input) => {
|
|
114
114
|
const result = await startUi(input);
|
|
115
|
-
const text = result.content[0].text;
|
|
115
|
+
const text = result.content[0].text || '';
|
|
116
116
|
// 应该包含"预期输出"部分
|
|
117
117
|
expect(text).toMatch(/预期输出|Expected Output/i);
|
|
118
118
|
// 每个步骤都应该有预期输出
|
|
@@ -131,7 +131,7 @@ test('任务 3.4: 步骤包含依赖关系说明', async () => {
|
|
|
131
131
|
framework: fc.constantFrom('react', 'vue', 'html')
|
|
132
132
|
}), async (input) => {
|
|
133
133
|
const result = await startUi(input);
|
|
134
|
-
const text = result.content[0].text;
|
|
134
|
+
const text = result.content[0].text || '';
|
|
135
135
|
// 应该包含依赖关系的说明(如"确保步骤 1")
|
|
136
136
|
const hasDependency = text.includes('确保步骤') ||
|
|
137
137
|
text.includes('确保') ||
|
|
@@ -147,7 +147,7 @@ test('任务 3.4: 每个步骤包含失败处理', async () => {
|
|
|
147
147
|
framework: fc.constantFrom('react', 'vue', 'html')
|
|
148
148
|
}), async (input) => {
|
|
149
149
|
const result = await startUi(input);
|
|
150
|
-
const text = result.content[0].text;
|
|
150
|
+
const text = result.content[0].text || '';
|
|
151
151
|
// 应该包含"失败处理"部分
|
|
152
152
|
expect(text).toMatch(/失败处理|Failure Handling|On Failure/i);
|
|
153
153
|
// 每个步骤都应该有失败处理
|
|
@@ -212,7 +212,7 @@ test('任务 6.4: 指导包含显式工具名称', async () => {
|
|
|
212
212
|
framework: fc.constantFrom('react', 'vue', 'html')
|
|
213
213
|
}), async (input) => {
|
|
214
214
|
const result = await startUi(input);
|
|
215
|
-
const text = result.content[0].text;
|
|
215
|
+
const text = result.content[0].text || '';
|
|
216
216
|
// 应该包含明确的工具名称
|
|
217
217
|
const hasToolNames = text.includes('ui_design_system') ||
|
|
218
218
|
text.includes('init_component_catalog') ||
|
|
@@ -230,7 +230,7 @@ test('任务 6.4: 无模糊语言', async () => {
|
|
|
230
230
|
framework: fc.constantFrom('react', 'vue', 'html')
|
|
231
231
|
}), async (input) => {
|
|
232
232
|
const result = await startUi(input);
|
|
233
|
-
const text = result.content[0].text;
|
|
233
|
+
const text = result.content[0].text || '';
|
|
234
234
|
// 不应该包含模糊的指令(没有具体工具名称或文件名)
|
|
235
235
|
// 如果包含"检查",应该伴随具体的文件名或工具名
|
|
236
236
|
const checkMatches = text.match(/检查[^。\n]*/g) || [];
|
|
@@ -254,7 +254,7 @@ test('任务 6.4: 包含职责范围声明', async () => {
|
|
|
254
254
|
framework: fc.constantFrom('react', 'vue', 'html')
|
|
255
255
|
}), async (input) => {
|
|
256
256
|
const result = await startUi(input);
|
|
257
|
-
const text = result.content[0].text;
|
|
257
|
+
const text = result.content[0].text || '';
|
|
258
258
|
// 应该包含职责说明
|
|
259
259
|
expect(text).toMatch(/职责说明|职责|Responsibility/i);
|
|
260
260
|
// 应该说明只提供指导
|
|
@@ -7,16 +7,4 @@
|
|
|
7
7
|
* @param args.docs_dir - 文档目录,默认 "docs"
|
|
8
8
|
* @returns MCP 响应,包含功能规格生成指南
|
|
9
9
|
*/
|
|
10
|
-
export declare function addFeature(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
|
-
}>;
|
|
10
|
+
export declare function addFeature(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
|
/**
|
|
3
4
|
* add_feature 工具
|
|
4
5
|
*
|
|
@@ -511,26 +512,60 @@ export async function addFeature(args) {
|
|
|
511
512
|
.replace(/{feature_name}/g, featureName)
|
|
512
513
|
.replace(/{description}/g, description)
|
|
513
514
|
.replace(/{docs_dir}/g, docsDir);
|
|
514
|
-
//
|
|
515
|
-
|
|
516
|
-
|
|
515
|
+
// 创建结构化数据对象
|
|
516
|
+
const structuredData = {
|
|
517
|
+
summary: `添加功能:${featureName}`,
|
|
518
|
+
featureName: featureName,
|
|
519
|
+
requirements: [
|
|
520
|
+
"待生成需求文档",
|
|
521
|
+
"使用 EARS 格式编写验收标准"
|
|
522
|
+
],
|
|
523
|
+
design: {
|
|
524
|
+
architecture: "待设计",
|
|
525
|
+
components: [],
|
|
526
|
+
dataFlow: "待设计"
|
|
527
|
+
},
|
|
528
|
+
tasks: [
|
|
517
529
|
{
|
|
518
|
-
|
|
519
|
-
|
|
530
|
+
id: "1",
|
|
531
|
+
title: "生成需求文档",
|
|
532
|
+
description: `创建 ${docsDir}/specs/${featureName}/requirements.md`,
|
|
533
|
+
estimatedHours: 1
|
|
520
534
|
},
|
|
535
|
+
{
|
|
536
|
+
id: "2",
|
|
537
|
+
title: "生成设计文档",
|
|
538
|
+
description: `创建 ${docsDir}/specs/${featureName}/design.md`,
|
|
539
|
+
estimatedHours: 2
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
id: "3",
|
|
543
|
+
title: "生成任务清单",
|
|
544
|
+
description: `创建 ${docsDir}/specs/${featureName}/tasks.md`,
|
|
545
|
+
estimatedHours: 1
|
|
546
|
+
}
|
|
521
547
|
],
|
|
548
|
+
estimate: {
|
|
549
|
+
storyPoints: 0,
|
|
550
|
+
optimistic: "待估算",
|
|
551
|
+
normal: "待估算",
|
|
552
|
+
pessimistic: "待估算"
|
|
553
|
+
}
|
|
522
554
|
};
|
|
555
|
+
return okStructured(guide, structuredData, {
|
|
556
|
+
schema: (await import("../schemas/output/project-tools.js")).FeatureSpecSchema,
|
|
557
|
+
});
|
|
523
558
|
}
|
|
524
559
|
catch (error) {
|
|
525
560
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
},
|
|
532
|
-
],
|
|
533
|
-
isError: true,
|
|
561
|
+
const errorData = {
|
|
562
|
+
summary: "添加功能失败",
|
|
563
|
+
featureName: "",
|
|
564
|
+
requirements: [],
|
|
565
|
+
tasks: []
|
|
534
566
|
};
|
|
567
|
+
return okStructured(`❌ 添加功能失败: ${errorMessage}`, errorData, {
|
|
568
|
+
schema: (await import("../schemas/output/project-tools.js")).FeatureSpecSchema,
|
|
569
|
+
});
|
|
535
570
|
}
|
|
536
571
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseArgs, getString, getNumber, getBoolean } from "../utils/parseArgs.js";
|
|
2
|
+
import { okStructured } from "../lib/response.js";
|
|
2
3
|
import { readFileSync, readdirSync, statSync, existsSync } from 'fs';
|
|
3
4
|
import { join, extname } from 'path';
|
|
4
5
|
import { VERSION } from '../version.js';
|
|
@@ -23,11 +24,7 @@ export async function analyzeProject(args) {
|
|
|
23
24
|
try {
|
|
24
25
|
console.error(`开始分析项目: ${projectPath}`);
|
|
25
26
|
const analysis = await performProjectAnalysis(projectPath, maxDepth, includeContent);
|
|
26
|
-
|
|
27
|
-
content: [
|
|
28
|
-
{
|
|
29
|
-
type: "text",
|
|
30
|
-
text: `# 📊 项目分析报告
|
|
27
|
+
const message = `# 📊 项目分析报告
|
|
31
28
|
|
|
32
29
|
## 🏗️ 项目概览
|
|
33
30
|
- **项目名称**: ${analysis.projectStructure.name}
|
|
@@ -62,10 +59,10 @@ ${analysis.dependencies.production.slice(0, 10).map(dep => `- ${dep}`).join('\n'
|
|
|
62
59
|
${analysis.codeMetrics.skippedFiles > 0 ? `- **跳过文件**: ${analysis.codeMetrics.skippedFiles} 个(过大或无法读取)` : ''}
|
|
63
60
|
- **文件类型分布**:
|
|
64
61
|
${Object.entries(analysis.codeMetrics.fileTypes)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
.sort(([, a], [, b]) => b - a)
|
|
63
|
+
.slice(0, 10)
|
|
64
|
+
.map(([type, count]) => ` - ${type}: ${count} 个文件`)
|
|
65
|
+
.join('\n')}
|
|
69
66
|
${Object.keys(analysis.codeMetrics.fileTypes).length > 10 ? ' - ... (更多类型已省略)' : ''}
|
|
70
67
|
|
|
71
68
|
### 最大文件
|
|
@@ -89,21 +86,63 @@ ${analysis.summary.recommendations.map(rec => `- ${rec}`).join('\n')}
|
|
|
89
86
|
**分析说明**:
|
|
90
87
|
- 大型项目会自动采样分析,限制最多扫描 5000 个文件
|
|
91
88
|
- 已自动忽略以下目录: \`node_modules\`, \`dist\`, \`build\`, \`.git\`, \`coverage\`, \`.next\`, \`.nuxt\`, \`vendor\` 等
|
|
92
|
-
- 单个文件大小限制: 1MB
|
|
89
|
+
- 单个文件大小限制: 1MB,超过则跳过`;
|
|
90
|
+
// 创建结构化数据对象
|
|
91
|
+
const structuredData = {
|
|
92
|
+
summary: `项目分析:${analysis.projectStructure.name}`,
|
|
93
|
+
structure: {
|
|
94
|
+
totalFiles: analysis.codeMetrics.totalFiles,
|
|
95
|
+
totalLines: analysis.codeMetrics.totalLines,
|
|
96
|
+
languages: analysis.codeMetrics.fileTypes
|
|
97
|
+
},
|
|
98
|
+
techStack: [
|
|
99
|
+
{
|
|
100
|
+
name: analysis.projectStructure.framework,
|
|
101
|
+
version: "待检测",
|
|
102
|
+
purpose: "主要框架"
|
|
93
103
|
},
|
|
104
|
+
{
|
|
105
|
+
name: analysis.projectStructure.language,
|
|
106
|
+
version: "待检测",
|
|
107
|
+
purpose: "编程语言"
|
|
108
|
+
}
|
|
94
109
|
],
|
|
110
|
+
architecture: {
|
|
111
|
+
pattern: analysis.architecture.patterns.join(', '),
|
|
112
|
+
layers: analysis.architecture.mainModules,
|
|
113
|
+
description: analysis.summary.purpose
|
|
114
|
+
},
|
|
115
|
+
dependencies: {
|
|
116
|
+
production: analysis.dependencies.production.length,
|
|
117
|
+
development: analysis.dependencies.development.length,
|
|
118
|
+
outdated: 0
|
|
119
|
+
},
|
|
120
|
+
codeQuality: {
|
|
121
|
+
complexity: analysis.summary.complexity,
|
|
122
|
+
maintainability: 0,
|
|
123
|
+
testCoverage: 0
|
|
124
|
+
},
|
|
125
|
+
recommendations: analysis.summary.recommendations
|
|
95
126
|
};
|
|
127
|
+
return okStructured(message, structuredData, {
|
|
128
|
+
schema: (await import("../schemas/output/project-tools.js")).ProjectAnalysisSchema,
|
|
129
|
+
});
|
|
96
130
|
}
|
|
97
131
|
catch (error) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
132
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
133
|
+
const errorData = {
|
|
134
|
+
summary: "项目分析失败",
|
|
135
|
+
structure: {
|
|
136
|
+
totalFiles: 0,
|
|
137
|
+
totalLines: 0,
|
|
138
|
+
languages: {}
|
|
139
|
+
},
|
|
140
|
+
techStack: [],
|
|
141
|
+
recommendations: [errorMsg]
|
|
106
142
|
};
|
|
143
|
+
return okStructured(`❌ 项目分析失败: ${errorMsg}`, errorData, {
|
|
144
|
+
schema: (await import("../schemas/output/project-tools.js")).ProjectAnalysisSchema,
|
|
145
|
+
});
|
|
107
146
|
}
|
|
108
147
|
}
|
|
109
148
|
async function performProjectAnalysis(projectPath, maxDepth, includeContent) {
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
export declare function checkDeps(_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 checkDeps(_args: any): Promise<import("../lib/response.js").ToolResponse>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { okStructured } from "../lib/response.js";
|
|
1
2
|
// check_deps 工具实现(无参数)
|
|
2
3
|
export async function checkDeps(_args) {
|
|
3
4
|
try {
|
|
@@ -180,25 +181,33 @@ grep -r "from 'package-name'" src/
|
|
|
180
181
|
---
|
|
181
182
|
|
|
182
183
|
现在请开始依赖分析,生成详细的分析报告和升级计划。`;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
],
|
|
184
|
+
// 创建结构化数据对象
|
|
185
|
+
const structuredData = {
|
|
186
|
+
summary: "依赖健康度分析",
|
|
187
|
+
totalDependencies: 0,
|
|
188
|
+
outdated: [],
|
|
189
|
+
vulnerabilities: [],
|
|
190
|
+
unused: [],
|
|
191
|
+
recommendations: [
|
|
192
|
+
"运行 npm outdated 检查过期依赖",
|
|
193
|
+
"运行 npm audit 检查安全漏洞",
|
|
194
|
+
"使用 depcheck 查找未使用的依赖",
|
|
195
|
+
"定期更新依赖以保持项目健康"
|
|
196
|
+
]
|
|
190
197
|
};
|
|
198
|
+
return okStructured(message, structuredData, {
|
|
199
|
+
schema: (await import("../schemas/output/project-tools.js")).DependencyReportSchema,
|
|
200
|
+
});
|
|
191
201
|
}
|
|
192
202
|
catch (error) {
|
|
193
203
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
text: `❌ 依赖分析失败: ${errorMessage}`,
|
|
199
|
-
},
|
|
200
|
-
],
|
|
201
|
-
isError: true,
|
|
204
|
+
const errorData = {
|
|
205
|
+
summary: "依赖分析失败",
|
|
206
|
+
totalDependencies: 0,
|
|
207
|
+
recommendations: [errorMessage]
|
|
202
208
|
};
|
|
209
|
+
return okStructured(`❌ 依赖分析失败: ${errorMessage}`, errorData, {
|
|
210
|
+
schema: (await import("../schemas/output/project-tools.js")).DependencyReportSchema,
|
|
211
|
+
});
|
|
203
212
|
}
|
|
204
213
|
}
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
export declare function codeReview(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 codeReview(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
|
// code_review 工具实现
|
|
3
4
|
export async function codeReview(args) {
|
|
4
5
|
try {
|
|
@@ -160,25 +161,27 @@ ${code || "请提供需要审查的代码"}
|
|
|
160
161
|
- ✅ 输出结构化问题清单和改进建议
|
|
161
162
|
|
|
162
163
|
现在请开始代码审查,生成详细的审查报告。`;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
],
|
|
164
|
+
// 创建结构化数据(示例数据,实际应由 AI 生成)
|
|
165
|
+
const structuredData = {
|
|
166
|
+
summary: "代码审查完成,请查看详细报告",
|
|
167
|
+
overallScore: 0, // AI 会填充实际分数
|
|
168
|
+
issues: [], // AI 会填充实际问题
|
|
169
|
+
strengths: [], // AI 会填充优点
|
|
170
|
+
recommendations: [], // AI 会填充建议
|
|
170
171
|
};
|
|
172
|
+
return okStructured(message, // 保持向后兼容的文本输出
|
|
173
|
+
structuredData, {
|
|
174
|
+
schema: (await import('../schemas/output/core-tools.js')).CodeReviewReportSchema,
|
|
175
|
+
});
|
|
171
176
|
}
|
|
172
177
|
catch (error) {
|
|
173
178
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
174
|
-
return {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
isError: true,
|
|
182
|
-
};
|
|
179
|
+
return okStructured(`❌ 代码审查失败: ${errorMessage}`, {
|
|
180
|
+
summary: `代码审查失败: ${errorMessage}`,
|
|
181
|
+
overallScore: 0,
|
|
182
|
+
issues: [],
|
|
183
|
+
}, {
|
|
184
|
+
schema: (await import('../schemas/output/core-tools.js')).CodeReviewReportSchema,
|
|
185
|
+
});
|
|
183
186
|
}
|
|
184
187
|
}
|
package/build/tools/css_order.js
CHANGED
|
@@ -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: [
|
package/build/tools/debug.d.ts
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
export declare function debug(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 debug(args: any): Promise<import("../lib/response.js").ToolResponse>;
|