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
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tasks 管理器
|
|
3
|
+
* 实现 MCP 2025-11-25 Tasks API
|
|
4
|
+
*
|
|
5
|
+
* 支持长时间运行的工具任务化执行:
|
|
6
|
+
* - 创建任务
|
|
7
|
+
* - 查询任务状态
|
|
8
|
+
* - 获取任务结果
|
|
9
|
+
* - 取消任务
|
|
10
|
+
* - 列出任务
|
|
11
|
+
*/
|
|
12
|
+
import { randomUUID } from 'crypto';
|
|
13
|
+
/**
|
|
14
|
+
* Tasks 管理器类
|
|
15
|
+
*/
|
|
16
|
+
export class TasksManager {
|
|
17
|
+
tasks = new Map();
|
|
18
|
+
cleanupInterval;
|
|
19
|
+
constructor() {
|
|
20
|
+
// 每分钟清理过期任务
|
|
21
|
+
this.cleanupInterval = setInterval(() => {
|
|
22
|
+
this.cleanupExpiredTasks();
|
|
23
|
+
}, 60000);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 创建新任务
|
|
27
|
+
*
|
|
28
|
+
* @param ttl - 任务生存时间(毫秒),null 表示无限
|
|
29
|
+
* @param pollInterval - 建议的轮询间隔(毫秒)
|
|
30
|
+
* @returns 任务元数据
|
|
31
|
+
*/
|
|
32
|
+
createTask(ttl, pollInterval = 5000) {
|
|
33
|
+
const taskId = randomUUID();
|
|
34
|
+
const now = new Date().toISOString();
|
|
35
|
+
const metadata = {
|
|
36
|
+
taskId,
|
|
37
|
+
status: 'working',
|
|
38
|
+
statusMessage: 'The operation is now in progress.',
|
|
39
|
+
createdAt: now,
|
|
40
|
+
lastUpdatedAt: now,
|
|
41
|
+
pollInterval,
|
|
42
|
+
};
|
|
43
|
+
if (ttl !== null && ttl !== undefined) {
|
|
44
|
+
metadata.ttl = ttl;
|
|
45
|
+
}
|
|
46
|
+
const task = {
|
|
47
|
+
metadata,
|
|
48
|
+
};
|
|
49
|
+
// 设置过期时间
|
|
50
|
+
if (ttl) {
|
|
51
|
+
task.expiresAt = Date.now() + ttl;
|
|
52
|
+
}
|
|
53
|
+
this.tasks.set(taskId, task);
|
|
54
|
+
console.error(`[Tasks] Created task ${taskId} (TTL: ${ttl || 'unlimited'}ms)`);
|
|
55
|
+
return metadata;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 更新任务状态
|
|
59
|
+
*
|
|
60
|
+
* @param taskId - 任务 ID
|
|
61
|
+
* @param status - 新状态
|
|
62
|
+
* @param statusMessage - 状态消息
|
|
63
|
+
*/
|
|
64
|
+
updateTaskStatus(taskId, status, statusMessage) {
|
|
65
|
+
const task = this.tasks.get(taskId);
|
|
66
|
+
if (!task) {
|
|
67
|
+
throw new Error(`Task not found: ${taskId}`);
|
|
68
|
+
}
|
|
69
|
+
task.metadata.status = status;
|
|
70
|
+
task.metadata.lastUpdatedAt = new Date().toISOString();
|
|
71
|
+
if (statusMessage) {
|
|
72
|
+
task.metadata.statusMessage = statusMessage;
|
|
73
|
+
}
|
|
74
|
+
console.error(`[Tasks] Updated task ${taskId} status: ${status}`);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 设置任务结果
|
|
78
|
+
*
|
|
79
|
+
* @param taskId - 任务 ID
|
|
80
|
+
* @param result - 任务结果
|
|
81
|
+
*/
|
|
82
|
+
setTaskResult(taskId, result) {
|
|
83
|
+
const task = this.tasks.get(taskId);
|
|
84
|
+
if (!task) {
|
|
85
|
+
throw new Error(`Task not found: ${taskId}`);
|
|
86
|
+
}
|
|
87
|
+
task.result = result;
|
|
88
|
+
task.metadata.status = result.isError ? 'failed' : 'completed';
|
|
89
|
+
task.metadata.lastUpdatedAt = new Date().toISOString();
|
|
90
|
+
console.error(`[Tasks] Set result for task ${taskId}`);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 获取任务元数据
|
|
94
|
+
*
|
|
95
|
+
* @param taskId - 任务 ID
|
|
96
|
+
* @returns 任务元数据
|
|
97
|
+
*/
|
|
98
|
+
getTask(taskId) {
|
|
99
|
+
const task = this.tasks.get(taskId);
|
|
100
|
+
if (!task) {
|
|
101
|
+
throw new Error(`Task not found: ${taskId}`);
|
|
102
|
+
}
|
|
103
|
+
return task.metadata;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 获取任务结果
|
|
107
|
+
*
|
|
108
|
+
* @param taskId - 任务 ID
|
|
109
|
+
* @returns 任务结果
|
|
110
|
+
*/
|
|
111
|
+
getTaskResult(taskId) {
|
|
112
|
+
const task = this.tasks.get(taskId);
|
|
113
|
+
if (!task) {
|
|
114
|
+
throw new Error(`Task not found: ${taskId}`);
|
|
115
|
+
}
|
|
116
|
+
if (task.metadata.status === 'working') {
|
|
117
|
+
throw new Error(`Task is still in progress: ${taskId}`);
|
|
118
|
+
}
|
|
119
|
+
if (!task.result) {
|
|
120
|
+
throw new Error(`Task result not available: ${taskId}`);
|
|
121
|
+
}
|
|
122
|
+
return task.result;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* 取消任务
|
|
126
|
+
*
|
|
127
|
+
* @param taskId - 任务 ID
|
|
128
|
+
*/
|
|
129
|
+
cancelTask(taskId) {
|
|
130
|
+
const task = this.tasks.get(taskId);
|
|
131
|
+
if (!task) {
|
|
132
|
+
throw new Error(`Task not found: ${taskId}`);
|
|
133
|
+
}
|
|
134
|
+
if (task.metadata.status !== 'working') {
|
|
135
|
+
throw new Error(`Task is not in progress: ${taskId}`);
|
|
136
|
+
}
|
|
137
|
+
task.metadata.status = 'cancelled';
|
|
138
|
+
task.metadata.statusMessage = 'Task was cancelled by user.';
|
|
139
|
+
task.metadata.lastUpdatedAt = new Date().toISOString();
|
|
140
|
+
console.error(`[Tasks] Cancelled task ${taskId}`);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* 列出所有任务
|
|
144
|
+
*
|
|
145
|
+
* @returns 任务元数据列表
|
|
146
|
+
*/
|
|
147
|
+
listTasks() {
|
|
148
|
+
return Array.from(this.tasks.values()).map(task => task.metadata);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* 执行异步任务
|
|
152
|
+
*
|
|
153
|
+
* @param taskId - 任务 ID
|
|
154
|
+
* @param executor - 任务执行函数
|
|
155
|
+
*/
|
|
156
|
+
async executeTask(taskId, executor) {
|
|
157
|
+
const task = this.tasks.get(taskId);
|
|
158
|
+
if (!task) {
|
|
159
|
+
throw new Error(`Task not found: ${taskId}`);
|
|
160
|
+
}
|
|
161
|
+
try {
|
|
162
|
+
console.error(`[Tasks] Executing task ${taskId}...`);
|
|
163
|
+
const result = await executor();
|
|
164
|
+
this.setTaskResult(taskId, result);
|
|
165
|
+
console.error(`[Tasks] Task ${taskId} completed successfully`);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
169
|
+
console.error(`[Tasks] Task ${taskId} failed:`, errorMessage);
|
|
170
|
+
this.setTaskResult(taskId, {
|
|
171
|
+
content: [
|
|
172
|
+
{
|
|
173
|
+
type: 'text',
|
|
174
|
+
text: `Task failed: ${errorMessage}`,
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
isError: true,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* 清理过期任务
|
|
183
|
+
*/
|
|
184
|
+
cleanupExpiredTasks() {
|
|
185
|
+
const now = Date.now();
|
|
186
|
+
let cleanedCount = 0;
|
|
187
|
+
for (const [taskId, task] of this.tasks.entries()) {
|
|
188
|
+
if (task.expiresAt && task.expiresAt < now) {
|
|
189
|
+
this.tasks.delete(taskId);
|
|
190
|
+
cleanedCount++;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (cleanedCount > 0) {
|
|
194
|
+
console.error(`[Tasks] Cleaned up ${cleanedCount} expired tasks`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* 销毁管理器
|
|
199
|
+
*/
|
|
200
|
+
destroy() {
|
|
201
|
+
if (this.cleanupInterval) {
|
|
202
|
+
clearInterval(this.cleanupInterval);
|
|
203
|
+
}
|
|
204
|
+
this.tasks.clear();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// 全局单例
|
|
208
|
+
let globalTasksManager = null;
|
|
209
|
+
/**
|
|
210
|
+
* 获取全局 Tasks 管理器实例
|
|
211
|
+
*/
|
|
212
|
+
export function getTasksManager() {
|
|
213
|
+
if (!globalTasksManager) {
|
|
214
|
+
globalTasksManager = new TasksManager();
|
|
215
|
+
}
|
|
216
|
+
return globalTasksManager;
|
|
217
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 工具集管理器
|
|
3
|
+
* 根据环境变量 MCP_TOOLSET 过滤工具列表
|
|
4
|
+
*/
|
|
5
|
+
export type ToolsetType = 'core' | 'ui' | 'workflow' | 'full';
|
|
6
|
+
/**
|
|
7
|
+
* 工具集定义
|
|
8
|
+
*
|
|
9
|
+
* - core: 14 个核心工具(高频使用)
|
|
10
|
+
* - ui: 5 个 UI/UX 工具(推荐使用 start_ui 统一入口)
|
|
11
|
+
* - workflow: 27 个工作流工具(包含 core + 编排工具)
|
|
12
|
+
* - full: 所有 39 个工具(默认)
|
|
13
|
+
*/
|
|
14
|
+
export declare const TOOLSET_DEFINITIONS: {
|
|
15
|
+
core: string[];
|
|
16
|
+
ui: string[];
|
|
17
|
+
workflow: string[];
|
|
18
|
+
full: "all";
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* 工具接口(简化版,用于过滤)
|
|
22
|
+
*/
|
|
23
|
+
export interface Tool {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
inputSchema: any;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 根据工具集类型过滤工具列表
|
|
30
|
+
*
|
|
31
|
+
* @param tools - 完整的工具列表
|
|
32
|
+
* @param toolset - 工具集类型
|
|
33
|
+
* @returns 过滤后的工具列表
|
|
34
|
+
*/
|
|
35
|
+
export declare function filterTools(tools: Tool[], toolset: ToolsetType): Tool[];
|
|
36
|
+
/**
|
|
37
|
+
* 从环境变量获取工具集类型
|
|
38
|
+
*
|
|
39
|
+
* @returns 工具集类型,默认为 'full'
|
|
40
|
+
*/
|
|
41
|
+
export declare function getToolsetFromEnv(): ToolsetType;
|
|
42
|
+
/**
|
|
43
|
+
* 获取工具集的工具数量
|
|
44
|
+
*
|
|
45
|
+
* @param toolset - 工具集类型
|
|
46
|
+
* @returns 工具数量
|
|
47
|
+
*/
|
|
48
|
+
export declare function getToolsetSize(toolset: ToolsetType): number;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 工具集管理器
|
|
3
|
+
* 根据环境变量 MCP_TOOLSET 过滤工具列表
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 工具集定义
|
|
7
|
+
*
|
|
8
|
+
* - core: 14 个核心工具(高频使用)
|
|
9
|
+
* - ui: 5 个 UI/UX 工具(推荐使用 start_ui 统一入口)
|
|
10
|
+
* - workflow: 27 个工作流工具(包含 core + 编排工具)
|
|
11
|
+
* - full: 所有 39 个工具(默认)
|
|
12
|
+
*/
|
|
13
|
+
export const TOOLSET_DEFINITIONS = {
|
|
14
|
+
// 核心工具集(14 个)- 最常用的基础工具
|
|
15
|
+
core: [
|
|
16
|
+
'gencommit',
|
|
17
|
+
'code_review',
|
|
18
|
+
'debug',
|
|
19
|
+
'gentest',
|
|
20
|
+
'gendoc',
|
|
21
|
+
'refactor',
|
|
22
|
+
'perf',
|
|
23
|
+
'security_scan',
|
|
24
|
+
'fix_bug',
|
|
25
|
+
'genapi',
|
|
26
|
+
'gensql',
|
|
27
|
+
'genreadme',
|
|
28
|
+
'check_deps',
|
|
29
|
+
'gen_mock',
|
|
30
|
+
],
|
|
31
|
+
// UI/UX 工具集(5 个)- 对外工具,推荐使用 start_ui 统一入口
|
|
32
|
+
ui: [
|
|
33
|
+
'start_ui', // ⭐ 统一入口(编排工具)
|
|
34
|
+
'ui_search', // 搜索 UI/UX 数据库
|
|
35
|
+
'ui_design_system', // 生成设计系统
|
|
36
|
+
'sync_ui_data', // 同步 UI 数据
|
|
37
|
+
// 注意:不包含内部工具 init_component_catalog 和 render_ui
|
|
38
|
+
],
|
|
39
|
+
// 工作流工具集(27 个)- 包含核心工具 + 编排工具
|
|
40
|
+
workflow: [
|
|
41
|
+
// 核心工具(复用)
|
|
42
|
+
'gencommit',
|
|
43
|
+
'code_review',
|
|
44
|
+
'debug',
|
|
45
|
+
'gentest',
|
|
46
|
+
'gendoc',
|
|
47
|
+
'refactor',
|
|
48
|
+
'perf',
|
|
49
|
+
'security_scan',
|
|
50
|
+
'fix_bug',
|
|
51
|
+
'genapi',
|
|
52
|
+
'gensql',
|
|
53
|
+
'genreadme',
|
|
54
|
+
'check_deps',
|
|
55
|
+
'gen_mock',
|
|
56
|
+
// 编排工具(10 个)
|
|
57
|
+
'start_feature',
|
|
58
|
+
'start_bugfix',
|
|
59
|
+
'start_review',
|
|
60
|
+
'start_release',
|
|
61
|
+
'start_refactor',
|
|
62
|
+
'start_onboard',
|
|
63
|
+
'start_api',
|
|
64
|
+
'start_doc',
|
|
65
|
+
'start_ralph',
|
|
66
|
+
'start_ui',
|
|
67
|
+
// 交互工具(2 个)
|
|
68
|
+
'interview',
|
|
69
|
+
'ask_user',
|
|
70
|
+
],
|
|
71
|
+
// 完整工具集(39 个)- 包含所有工具(包括内部工具)
|
|
72
|
+
full: 'all',
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* 根据工具集类型过滤工具列表
|
|
76
|
+
*
|
|
77
|
+
* @param tools - 完整的工具列表
|
|
78
|
+
* @param toolset - 工具集类型
|
|
79
|
+
* @returns 过滤后的工具列表
|
|
80
|
+
*/
|
|
81
|
+
export function filterTools(tools, toolset) {
|
|
82
|
+
if (toolset === 'full') {
|
|
83
|
+
return tools;
|
|
84
|
+
}
|
|
85
|
+
const allowedTools = TOOLSET_DEFINITIONS[toolset];
|
|
86
|
+
return tools.filter(tool => allowedTools.includes(tool.name));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 从环境变量获取工具集类型
|
|
90
|
+
*
|
|
91
|
+
* @returns 工具集类型,默认为 'full'
|
|
92
|
+
*/
|
|
93
|
+
export function getToolsetFromEnv() {
|
|
94
|
+
const toolset = process.env.MCP_TOOLSET?.toLowerCase();
|
|
95
|
+
if (toolset === 'core' || toolset === 'ui' || toolset === 'workflow') {
|
|
96
|
+
return toolset;
|
|
97
|
+
}
|
|
98
|
+
return 'full';
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* 获取工具集的工具数量
|
|
102
|
+
*
|
|
103
|
+
* @param toolset - 工具集类型
|
|
104
|
+
* @returns 工具数量
|
|
105
|
+
*/
|
|
106
|
+
export function getToolsetSize(toolset) {
|
|
107
|
+
if (toolset === 'full') {
|
|
108
|
+
return 39;
|
|
109
|
+
}
|
|
110
|
+
const allowedTools = TOOLSET_DEFINITIONS[toolset];
|
|
111
|
+
return allowedTools.length;
|
|
112
|
+
}
|
|
@@ -2,38 +2,6 @@
|
|
|
2
2
|
* 基础工具的 Schema 定义
|
|
3
3
|
*/
|
|
4
4
|
export declare const basicToolSchemas: readonly [{
|
|
5
|
-
readonly name: "detect_shell";
|
|
6
|
-
readonly description: "当用户询问当前 AI 环境、是否为套壳产品时使用。检测 AI 应用环境指纹,返回 JSON 检测报告";
|
|
7
|
-
readonly inputSchema: {
|
|
8
|
-
readonly type: "object";
|
|
9
|
-
readonly properties: {
|
|
10
|
-
readonly nonce: {
|
|
11
|
-
readonly type: "string";
|
|
12
|
-
readonly description: "随机数,用于网络检测。可选";
|
|
13
|
-
};
|
|
14
|
-
readonly skip_network: {
|
|
15
|
-
readonly type: "boolean";
|
|
16
|
-
readonly description: "是否跳过网络检测。可选,默认 false";
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
readonly required: readonly [];
|
|
20
|
-
readonly additionalProperties: true;
|
|
21
|
-
};
|
|
22
|
-
}, {
|
|
23
|
-
readonly name: "init_setting";
|
|
24
|
-
readonly description: "当用户需要初始化或配置 Cursor IDE 设置时使用。写入推荐的 AI 配置到 .cursor/settings.json";
|
|
25
|
-
readonly inputSchema: {
|
|
26
|
-
readonly type: "object";
|
|
27
|
-
readonly properties: {
|
|
28
|
-
readonly project_path: {
|
|
29
|
-
readonly type: "string";
|
|
30
|
-
readonly description: "项目路径。可选,默认为当前工作区路径";
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
readonly required: readonly [];
|
|
34
|
-
readonly additionalProperties: true;
|
|
35
|
-
};
|
|
36
|
-
}, {
|
|
37
5
|
readonly name: "init_project";
|
|
38
6
|
readonly description: "当用户需要创建新项目、生成项目结构时使用。按 Spec-Driven Development 方式生成需求/设计/任务文档";
|
|
39
7
|
readonly inputSchema: {
|
|
@@ -2,40 +2,6 @@
|
|
|
2
2
|
* 基础工具的 Schema 定义
|
|
3
3
|
*/
|
|
4
4
|
export const basicToolSchemas = [
|
|
5
|
-
{
|
|
6
|
-
name: "detect_shell",
|
|
7
|
-
description: "当用户询问当前 AI 环境、是否为套壳产品时使用。检测 AI 应用环境指纹,返回 JSON 检测报告",
|
|
8
|
-
inputSchema: {
|
|
9
|
-
type: "object",
|
|
10
|
-
properties: {
|
|
11
|
-
nonce: {
|
|
12
|
-
type: "string",
|
|
13
|
-
description: "随机数,用于网络检测。可选",
|
|
14
|
-
},
|
|
15
|
-
skip_network: {
|
|
16
|
-
type: "boolean",
|
|
17
|
-
description: "是否跳过网络检测。可选,默认 false",
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
required: [],
|
|
21
|
-
additionalProperties: true,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: "init_setting",
|
|
26
|
-
description: "当用户需要初始化或配置 Cursor IDE 设置时使用。写入推荐的 AI 配置到 .cursor/settings.json",
|
|
27
|
-
inputSchema: {
|
|
28
|
-
type: "object",
|
|
29
|
-
properties: {
|
|
30
|
-
project_path: {
|
|
31
|
-
type: "string",
|
|
32
|
-
description: "项目路径。可选,默认为当前工作区路径",
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
required: [],
|
|
36
|
-
additionalProperties: true,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
5
|
{
|
|
40
6
|
name: "init_project",
|
|
41
7
|
description: "当用户需要创建新项目、生成项目结构时使用。按 Spec-Driven Development 方式生成需求/设计/任务文档",
|
|
@@ -37,24 +37,6 @@ export declare const codeAnalysisToolSchemas: readonly [{
|
|
|
37
37
|
readonly required: readonly [];
|
|
38
38
|
readonly additionalProperties: true;
|
|
39
39
|
};
|
|
40
|
-
}, {
|
|
41
|
-
readonly name: "explain";
|
|
42
|
-
readonly description: "当用户不理解某段代码、需要代码解释时使用。解释代码逻辑和实现原理,包含执行流程、关键概念";
|
|
43
|
-
readonly inputSchema: {
|
|
44
|
-
readonly type: "object";
|
|
45
|
-
readonly properties: {
|
|
46
|
-
readonly code: {
|
|
47
|
-
readonly type: "string";
|
|
48
|
-
readonly description: "要解释的代码。可以是代码片段或完整函数";
|
|
49
|
-
};
|
|
50
|
-
readonly context: {
|
|
51
|
-
readonly type: "string";
|
|
52
|
-
readonly description: "业务背景或上下文。可选,有助于更好的解释";
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
readonly required: readonly [];
|
|
56
|
-
readonly additionalProperties: true;
|
|
57
|
-
};
|
|
58
40
|
}, {
|
|
59
41
|
readonly name: "perf";
|
|
60
42
|
readonly description: "当用户关注代码性能、需要优化性能时使用。分析性能瓶颈(算法/内存/数据库/React渲染),输出瓶颈清单和优化建议";
|
|
@@ -113,24 +95,6 @@ export declare const codeAnalysisToolSchemas: readonly [{
|
|
|
113
95
|
readonly required: readonly [];
|
|
114
96
|
readonly additionalProperties: true;
|
|
115
97
|
};
|
|
116
|
-
}, {
|
|
117
|
-
readonly name: "fix";
|
|
118
|
-
readonly description: "当用户需要自动修复代码问题(Lint/格式化/类型错误)时使用。自动修复可机械化问题,输出补丁(unified diff)";
|
|
119
|
-
readonly inputSchema: {
|
|
120
|
-
readonly type: "object";
|
|
121
|
-
readonly properties: {
|
|
122
|
-
readonly code: {
|
|
123
|
-
readonly type: "string";
|
|
124
|
-
readonly description: "要修复的代码";
|
|
125
|
-
};
|
|
126
|
-
readonly type: {
|
|
127
|
-
readonly type: "string";
|
|
128
|
-
readonly description: "修复类型:lint(代码规范)、ts(TypeScript错误)、format(格式化)、import(导入)。可选,会自动识别";
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
readonly required: readonly [];
|
|
132
|
-
readonly additionalProperties: true;
|
|
133
|
-
};
|
|
134
98
|
}, {
|
|
135
99
|
readonly name: "fix_bug";
|
|
136
100
|
readonly description: "当用户需要修复 Bug、获取修复指导时使用。提供 Bug 修复流程指导,包含根因分析、修复方案、验证步骤";
|
|
@@ -40,25 +40,6 @@ export const codeAnalysisToolSchemas = [
|
|
|
40
40
|
additionalProperties: true,
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
|
-
{
|
|
44
|
-
name: "explain",
|
|
45
|
-
description: "当用户不理解某段代码、需要代码解释时使用。解释代码逻辑和实现原理,包含执行流程、关键概念",
|
|
46
|
-
inputSchema: {
|
|
47
|
-
type: "object",
|
|
48
|
-
properties: {
|
|
49
|
-
code: {
|
|
50
|
-
type: "string",
|
|
51
|
-
description: "要解释的代码。可以是代码片段或完整函数",
|
|
52
|
-
},
|
|
53
|
-
context: {
|
|
54
|
-
type: "string",
|
|
55
|
-
description: "业务背景或上下文。可选,有助于更好的解释",
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
required: [],
|
|
59
|
-
additionalProperties: true,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
43
|
{
|
|
63
44
|
name: "perf",
|
|
64
45
|
description: "当用户关注代码性能、需要优化性能时使用。分析性能瓶颈(算法/内存/数据库/React渲染),输出瓶颈清单和优化建议",
|
|
@@ -120,25 +101,6 @@ export const codeAnalysisToolSchemas = [
|
|
|
120
101
|
additionalProperties: true,
|
|
121
102
|
},
|
|
122
103
|
},
|
|
123
|
-
{
|
|
124
|
-
name: "fix",
|
|
125
|
-
description: "当用户需要自动修复代码问题(Lint/格式化/类型错误)时使用。自动修复可机械化问题,输出补丁(unified diff)",
|
|
126
|
-
inputSchema: {
|
|
127
|
-
type: "object",
|
|
128
|
-
properties: {
|
|
129
|
-
code: {
|
|
130
|
-
type: "string",
|
|
131
|
-
description: "要修复的代码",
|
|
132
|
-
},
|
|
133
|
-
type: {
|
|
134
|
-
type: "string",
|
|
135
|
-
description: "修复类型:lint(代码规范)、ts(TypeScript错误)、format(格式化)、import(导入)。可选,会自动识别",
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
required: [],
|
|
139
|
-
additionalProperties: true,
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
104
|
{
|
|
143
105
|
name: "fix_bug",
|
|
144
106
|
description: "当用户需要修复 Bug、获取修复指导时使用。提供 Bug 修复流程指导,包含根因分析、修复方案、验证步骤",
|
|
@@ -59,24 +59,6 @@ export declare const codeGenToolSchemas: readonly [{
|
|
|
59
59
|
readonly required: readonly [];
|
|
60
60
|
readonly additionalProperties: true;
|
|
61
61
|
};
|
|
62
|
-
}, {
|
|
63
|
-
readonly name: "genui";
|
|
64
|
-
readonly description: "当用户需要生成 UI 组件代码时使用。根据描述生成 UI 组件代码(React/Vue/HTML),包含 Props 和样式";
|
|
65
|
-
readonly inputSchema: {
|
|
66
|
-
readonly type: "object";
|
|
67
|
-
readonly properties: {
|
|
68
|
-
readonly description: {
|
|
69
|
-
readonly type: "string";
|
|
70
|
-
readonly description: "组件描述。可以是简短描述(如'登录表单组件')或详细的UI需求";
|
|
71
|
-
};
|
|
72
|
-
readonly framework: {
|
|
73
|
-
readonly type: "string";
|
|
74
|
-
readonly description: "前端框架:react、vue、html。可选,默认 react";
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
readonly required: readonly [];
|
|
78
|
-
readonly additionalProperties: true;
|
|
79
|
-
};
|
|
80
62
|
}, {
|
|
81
63
|
readonly name: "gensql";
|
|
82
64
|
readonly description: "当用户需要根据自然语言生成 SQL 查询时使用。将自然语言描述转换为 SQL 语句(PostgreSQL/MySQL/SQLite)";
|
|
@@ -121,30 +103,4 @@ export declare const codeGenToolSchemas: readonly [{
|
|
|
121
103
|
readonly required: readonly [];
|
|
122
104
|
readonly additionalProperties: true;
|
|
123
105
|
};
|
|
124
|
-
}, {
|
|
125
|
-
readonly name: "design2code";
|
|
126
|
-
readonly description: "当用户需要将设计稿转换为代码时使用。将设计稿(图片URL/描述/HTML)转换为前端代码(React/Vue),1:1 还原布局和样式";
|
|
127
|
-
readonly inputSchema: {
|
|
128
|
-
readonly type: "object";
|
|
129
|
-
readonly properties: {
|
|
130
|
-
readonly input: {
|
|
131
|
-
readonly type: "string";
|
|
132
|
-
readonly description: "设计稿输入:图片 URL、base64 图片、HTML 代码或设计稿描述";
|
|
133
|
-
};
|
|
134
|
-
readonly framework: {
|
|
135
|
-
readonly type: "string";
|
|
136
|
-
readonly description: "目标框架:vue、react。可选,默认为 vue";
|
|
137
|
-
};
|
|
138
|
-
readonly style_solution: {
|
|
139
|
-
readonly type: "string";
|
|
140
|
-
readonly description: "样式方案:tailwind、css-modules、styled-components。可选,默认为 tailwind";
|
|
141
|
-
};
|
|
142
|
-
readonly component_type: {
|
|
143
|
-
readonly type: "string";
|
|
144
|
-
readonly description: "组件类型:page(页面组件)、component(通用组件)。可选,默认为 page";
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
readonly required: readonly [];
|
|
148
|
-
readonly additionalProperties: true;
|
|
149
|
-
};
|
|
150
106
|
}];
|
|
@@ -63,25 +63,6 @@ export const codeGenToolSchemas = [
|
|
|
63
63
|
additionalProperties: true,
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
|
-
{
|
|
67
|
-
name: "genui",
|
|
68
|
-
description: "当用户需要生成 UI 组件代码时使用。根据描述生成 UI 组件代码(React/Vue/HTML),包含 Props 和样式",
|
|
69
|
-
inputSchema: {
|
|
70
|
-
type: "object",
|
|
71
|
-
properties: {
|
|
72
|
-
description: {
|
|
73
|
-
type: "string",
|
|
74
|
-
description: "组件描述。可以是简短描述(如'登录表单组件')或详细的UI需求",
|
|
75
|
-
},
|
|
76
|
-
framework: {
|
|
77
|
-
type: "string",
|
|
78
|
-
description: "前端框架:react、vue、html。可选,默认 react",
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
required: [],
|
|
82
|
-
additionalProperties: true,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
66
|
{
|
|
86
67
|
name: "gensql",
|
|
87
68
|
description: "当用户需要根据自然语言生成 SQL 查询时使用。将自然语言描述转换为 SQL 语句(PostgreSQL/MySQL/SQLite)",
|
|
@@ -128,31 +109,4 @@ export const codeGenToolSchemas = [
|
|
|
128
109
|
additionalProperties: true,
|
|
129
110
|
},
|
|
130
111
|
},
|
|
131
|
-
{
|
|
132
|
-
name: "design2code",
|
|
133
|
-
description: "当用户需要将设计稿转换为代码时使用。将设计稿(图片URL/描述/HTML)转换为前端代码(React/Vue),1:1 还原布局和样式",
|
|
134
|
-
inputSchema: {
|
|
135
|
-
type: "object",
|
|
136
|
-
properties: {
|
|
137
|
-
input: {
|
|
138
|
-
type: "string",
|
|
139
|
-
description: "设计稿输入:图片 URL、base64 图片、HTML 代码或设计稿描述",
|
|
140
|
-
},
|
|
141
|
-
framework: {
|
|
142
|
-
type: "string",
|
|
143
|
-
description: "目标框架:vue、react。可选,默认为 vue",
|
|
144
|
-
},
|
|
145
|
-
style_solution: {
|
|
146
|
-
type: "string",
|
|
147
|
-
description: "样式方案:tailwind、css-modules、styled-components。可选,默认为 tailwind",
|
|
148
|
-
},
|
|
149
|
-
component_type: {
|
|
150
|
-
type: "string",
|
|
151
|
-
description: "组件类型:page(页面组件)、component(通用组件)。可选,默认为 page",
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
required: [],
|
|
155
|
-
additionalProperties: true,
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
112
|
];
|