mcp-probe-kit 2.0.2 → 2.1.1
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 +39 -3
- package/build/lib/analysis-tasks.d.ts +35 -0
- package/build/lib/analysis-tasks.js +788 -0
- package/build/lib/document-templates.d.ts +14 -0
- package/build/lib/document-templates.js +248 -0
- package/build/lib/project-detector.d.ts +19 -0
- package/build/lib/project-detector.js +344 -0
- package/build/lib/response.js +1 -0
- package/build/lib/task-generator.d.ts +11 -0
- package/build/lib/task-generator.js +109 -0
- package/build/lib/template-generator.d.ts +14 -0
- package/build/lib/template-generator.js +62 -0
- package/build/lib/templates/backend-templates.d.ts +8 -0
- package/build/lib/templates/backend-templates.js +26 -0
- package/build/schemas/output/project-tools.d.ts +6 -0
- package/build/schemas/output/project-tools.js +5 -0
- package/build/tools/__tests__/start_ui.unit.test.js +2 -2
- package/build/tools/init_project_context.d.ts +2 -1
- package/build/tools/init_project_context.js +586 -327
- package/docs/data/tools.js +15 -7
- package/docs/pages/all-tools.html +1 -1
- package/docs/specs/project-context-modular/example-output.md +123 -0
- package/docs/specs/project-context-modular/implementation-v2.md +275 -0
- package/docs/specs/project-context-modular/tasks.md +104 -9
- package/package.json +4 -4
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 任务生成器
|
|
3
|
+
*
|
|
4
|
+
* 将分析任务转换为格式化的指导文本
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* 生成完整的分析任务指导文本
|
|
8
|
+
*/
|
|
9
|
+
export function generateTaskGuide(detection, tasks, docsDir) {
|
|
10
|
+
const guide = `# 项目上下文初始化 - 智能分析工作流
|
|
11
|
+
|
|
12
|
+
⚠️ **重要说明**:本工具采用"分析任务"模式,不提供固定模板,而是指导你分析项目实际代码,生成真正有用的文档。
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 📊 项目检测结果
|
|
17
|
+
|
|
18
|
+
- **语言**:${detection.language}
|
|
19
|
+
- **框架**:${detection.framework || '未检测到'}
|
|
20
|
+
- **类型**:${detection.category}
|
|
21
|
+
- **置信度**:${detection.confidence}%
|
|
22
|
+
- **检测依据**:${detection.indicators.join(', ')}
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 📋 需要生成的文档
|
|
27
|
+
|
|
28
|
+
根据项目类型,需要生成 **${tasks.length}** 个文档:
|
|
29
|
+
|
|
30
|
+
${tasks.map((task, i) => `${i + 1}. \`${task.document}\` - ${task.title}`).join('\n')}
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 🔍 分析任务清单
|
|
35
|
+
|
|
36
|
+
请按照以下任务清单,逐个分析并生成文档。
|
|
37
|
+
|
|
38
|
+
${tasks.map((task, index) => generateSingleTaskGuide(task, index + 1, docsDir)).join('\n\n---\n\n')}
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## ✅ 完成标准
|
|
43
|
+
|
|
44
|
+
完成后,请确认:
|
|
45
|
+
|
|
46
|
+
- [ ] 已调用 fsWrite 工具 **${tasks.length}** 次
|
|
47
|
+
- [ ] 每个文档都包含真实的文件路径(不是占位符 [xxx])
|
|
48
|
+
- [ ] 每个文档都包含实际的代码示例(从项目中提取)
|
|
49
|
+
- [ ] 每个文档都回答了分析任务中的所有问题
|
|
50
|
+
- [ ] 每个文档都满足了内容要求
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
**工具**:MCP Probe Kit - init_project_context
|
|
55
|
+
**版本**:2.1.0
|
|
56
|
+
`;
|
|
57
|
+
return guide;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 生成单个任务的指导文本
|
|
61
|
+
*/
|
|
62
|
+
function generateSingleTaskGuide(task, index, docsDir) {
|
|
63
|
+
return `### 任务 ${index}:${task.title}
|
|
64
|
+
|
|
65
|
+
**文档**:\`${docsDir}/project-context/${task.document}\`
|
|
66
|
+
**用途**:${task.purpose}
|
|
67
|
+
|
|
68
|
+
#### 🔍 第一步:发现(Discover)
|
|
69
|
+
|
|
70
|
+
${task.analysis.discover.description}
|
|
71
|
+
|
|
72
|
+
**搜索位置**:
|
|
73
|
+
${task.analysis.discover.locations.map(loc => `- \`${loc}\``).join('\n')}
|
|
74
|
+
|
|
75
|
+
**寻找模式**:
|
|
76
|
+
${task.analysis.discover.patterns.map(p => `- ${p}`).join('\n')}
|
|
77
|
+
|
|
78
|
+
**目标**:找到 **${task.analysis.discover.examples}** 个现有示例作为参考
|
|
79
|
+
|
|
80
|
+
#### 📊 第二步:分析(Analyze)
|
|
81
|
+
|
|
82
|
+
${task.analysis.analyze.description}
|
|
83
|
+
|
|
84
|
+
**需要回答的问题**:
|
|
85
|
+
${task.analysis.analyze.questions.map((q, i) => `${i + 1}. ${q}`).join('\n')}
|
|
86
|
+
|
|
87
|
+
**需要提取的信息**:
|
|
88
|
+
${task.analysis.analyze.extract.map(e => `- ${e}`).join('\n')}
|
|
89
|
+
|
|
90
|
+
#### 📝 第三步:生成(Generate)
|
|
91
|
+
|
|
92
|
+
${task.analysis.generate.description}
|
|
93
|
+
|
|
94
|
+
**文档结构**:
|
|
95
|
+
\`\`\`
|
|
96
|
+
${task.analysis.generate.structure.join('\n')}
|
|
97
|
+
\`\`\`
|
|
98
|
+
|
|
99
|
+
**内容要求**:
|
|
100
|
+
${task.analysis.generate.requirements.map(r => `- ${r}`).join('\n')}
|
|
101
|
+
|
|
102
|
+
#### ✅ 完成标准
|
|
103
|
+
|
|
104
|
+
- [ ] 已找到现有示例
|
|
105
|
+
- [ ] 已回答所有分析问题
|
|
106
|
+
- [ ] 已提取所有必要信息
|
|
107
|
+
- [ ] 已使用 fsWrite 创建文档:\`${docsDir}/project-context/${task.document}\`
|
|
108
|
+
- [ ] 文档内容符合所有要求`;
|
|
109
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模板生成器
|
|
3
|
+
*
|
|
4
|
+
* 根据项目类型、语言、框架生成具体的文档模板内容
|
|
5
|
+
*/
|
|
6
|
+
import type { ProjectDetectionResult } from './project-detector.js';
|
|
7
|
+
import type { DocumentTemplate } from './document-templates.js';
|
|
8
|
+
/**
|
|
9
|
+
* 生成文档模板内容
|
|
10
|
+
*/
|
|
11
|
+
export declare function generateTemplateContent(doc: DocumentTemplate, detection: ProjectDetectionResult): string;
|
|
12
|
+
export * from './templates/backend-templates.js';
|
|
13
|
+
export * from './templates/frontend-templates.js';
|
|
14
|
+
export * from './templates/fullstack-templates.js';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模板生成器
|
|
3
|
+
*
|
|
4
|
+
* 根据项目类型、语言、框架生成具体的文档模板内容
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* 生成文档模板内容
|
|
8
|
+
*/
|
|
9
|
+
export function generateTemplateContent(doc, detection) {
|
|
10
|
+
const { language, framework, category } = detection;
|
|
11
|
+
// 根据文档类型选择生成器
|
|
12
|
+
const generator = templateGenerators[doc.filename];
|
|
13
|
+
if (!generator) {
|
|
14
|
+
return generateGenericTemplate(doc, detection);
|
|
15
|
+
}
|
|
16
|
+
return generator(detection);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 模板生成器映射
|
|
20
|
+
*/
|
|
21
|
+
const templateGenerators = {
|
|
22
|
+
'how-to-add-api.md': generateHowToAddApiTemplate,
|
|
23
|
+
'how-to-database.md': generateHowToDatabaseTemplate,
|
|
24
|
+
'how-to-auth.md': generateHowToAuthTemplate,
|
|
25
|
+
'how-to-test.md': generateHowToTestTemplate,
|
|
26
|
+
'how-to-deploy.md': generateHowToDeployTemplate,
|
|
27
|
+
'how-to-new-page.md': generateHowToNewPageTemplate,
|
|
28
|
+
'how-to-call-api.md': generateHowToCallApiTemplate,
|
|
29
|
+
'how-to-state.md': generateHowToStateTemplate,
|
|
30
|
+
'how-to-routing.md': generateHowToRoutingTemplate,
|
|
31
|
+
'how-to-styling.md': generateHowToStylingTemplate,
|
|
32
|
+
'how-to-new-feature.md': generateHowToNewFeatureTemplate,
|
|
33
|
+
'how-to-api-route.md': generateHowToApiRouteTemplate,
|
|
34
|
+
// ... 其他模板生成器
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 通用模板生成器
|
|
38
|
+
*/
|
|
39
|
+
function generateGenericTemplate(doc, detection) {
|
|
40
|
+
return `# ${doc.title}
|
|
41
|
+
|
|
42
|
+
> ${doc.purpose}
|
|
43
|
+
|
|
44
|
+
## 项目信息
|
|
45
|
+
- 语言:${detection.language}
|
|
46
|
+
- 框架:${detection.framework || '未检测到'}
|
|
47
|
+
- 类型:${detection.category}
|
|
48
|
+
|
|
49
|
+
## 操作步骤
|
|
50
|
+
|
|
51
|
+
请根据项目实际情况填写具体步骤。
|
|
52
|
+
|
|
53
|
+
## 参考资料
|
|
54
|
+
|
|
55
|
+
- 相关文档链接
|
|
56
|
+
- 示例代码文件
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
// 导入各个模板生成器
|
|
60
|
+
export * from './templates/backend-templates.js';
|
|
61
|
+
export * from './templates/frontend-templates.js';
|
|
62
|
+
export * from './templates/fullstack-templates.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 后端项目模板生成器
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 生成"如何添加新接口"模板
|
|
6
|
+
*/
|
|
7
|
+
export function generateHowToAddApiTemplate(detection) {
|
|
8
|
+
const { language, framework } = detection;
|
|
9
|
+
// 根据语言和框架选择模板
|
|
10
|
+
if (language === 'javascript' || language === 'typescript') {
|
|
11
|
+
return generateJSBackendApiTemplate(framework);
|
|
12
|
+
}
|
|
13
|
+
else if (language === 'python') {
|
|
14
|
+
return generatePythonBackendApiTemplate(framework);
|
|
15
|
+
}
|
|
16
|
+
else if (language === 'java') {
|
|
17
|
+
return generateJavaBackendApiTemplate(framework);
|
|
18
|
+
}
|
|
19
|
+
else if (language === 'go') {
|
|
20
|
+
return generateGoBackendApiTemplate(framework);
|
|
21
|
+
}
|
|
22
|
+
else if (language === 'rust') {
|
|
23
|
+
return generateRustBackendApiTemplate(framework);
|
|
24
|
+
}
|
|
25
|
+
return generateGenericBackendApiTemplate(detection);
|
|
26
|
+
}
|
|
@@ -70,6 +70,11 @@ export declare const ProjectContextSchema: {
|
|
|
70
70
|
readonly summary: {
|
|
71
71
|
readonly type: "string";
|
|
72
72
|
};
|
|
73
|
+
readonly mode: {
|
|
74
|
+
readonly type: "string";
|
|
75
|
+
readonly enum: readonly ["single", "modular"];
|
|
76
|
+
readonly description: "生成模式:single(单文件)或 modular(模块化)";
|
|
77
|
+
};
|
|
73
78
|
readonly projectOverview: {
|
|
74
79
|
readonly type: "object";
|
|
75
80
|
readonly properties: {
|
|
@@ -568,6 +573,7 @@ export interface ProjectInit {
|
|
|
568
573
|
}
|
|
569
574
|
export interface ProjectContext {
|
|
570
575
|
summary: string;
|
|
576
|
+
mode?: 'single' | 'modular';
|
|
571
577
|
projectOverview: {
|
|
572
578
|
name?: string;
|
|
573
579
|
description?: string;
|
|
@@ -46,6 +46,11 @@ export const ProjectContextSchema = {
|
|
|
46
46
|
type: 'object',
|
|
47
47
|
properties: {
|
|
48
48
|
summary: { type: 'string' },
|
|
49
|
+
mode: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
enum: ['single', 'modular'],
|
|
52
|
+
description: '生成模式:single(单文件)或 modular(模块化)'
|
|
53
|
+
},
|
|
49
54
|
projectOverview: {
|
|
50
55
|
type: 'object',
|
|
51
56
|
properties: {
|
|
@@ -73,13 +73,13 @@ describe('start_ui 单元测试', () => {
|
|
|
73
73
|
expect(result.isError).not.toBe(true);
|
|
74
74
|
expect(result.content[0].text).toMatch(/快速开始|Quick Start/i);
|
|
75
75
|
});
|
|
76
|
-
test('auto
|
|
76
|
+
test('auto 模式返回智能计划', async () => {
|
|
77
77
|
const result = await startUi({
|
|
78
78
|
description: '测试',
|
|
79
79
|
mode: 'auto'
|
|
80
80
|
});
|
|
81
81
|
expect(result.isError).toBe(false);
|
|
82
|
-
expect(result.content[0].text).toMatch(
|
|
82
|
+
expect(result.content[0].text).toMatch(/智能 UI 开发计划|智能分析结果/i);
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
85
|
describe('输出格式', () => {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param args - 工具参数
|
|
5
5
|
* @param args.docs_dir - 文档目录,默认 "docs"
|
|
6
|
-
* @
|
|
6
|
+
* @param args.project_root - 项目根目录,默认当前目录
|
|
7
|
+
* @returns MCP 响应,包含文档生成指导
|
|
7
8
|
*/
|
|
8
9
|
export declare function initProjectContext(args: any): Promise<import("../lib/response.js").ToolResponse>;
|