mcp-probe-kit 3.0.5 → 3.0.7
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 +458 -431
- package/build/index.js +875 -141
- package/build/lib/gitnexus-bridge.d.ts +58 -0
- package/build/lib/gitnexus-bridge.js +379 -0
- package/build/lib/template-loader.js +317 -317
- package/build/lib/tool-execution-context.d.ts +8 -0
- package/build/lib/tool-execution-context.js +20 -0
- package/build/lib/toolset-manager.d.ts +1 -1
- package/build/lib/toolset-manager.js +7 -5
- package/build/schemas/code-analysis-tools.d.ts +46 -0
- package/build/schemas/code-analysis-tools.js +47 -0
- package/build/schemas/git-tools.js +16 -16
- package/build/schemas/index.d.ts +46 -0
- package/build/tools/__tests__/code_insight.unit.test.d.ts +1 -0
- package/build/tools/__tests__/code_insight.unit.test.js +35 -0
- package/build/tools/__tests__/start_bugfix.unit.test.js +14 -14
- package/build/tools/__tests__/start_ui.unit.test.js +11 -11
- package/build/tools/add_feature.js +79 -79
- package/build/tools/ask_user.js +5 -5
- package/build/tools/code_insight.d.ts +8 -0
- package/build/tools/code_insight.js +129 -0
- package/build/tools/index.d.ts +1 -0
- package/build/tools/index.js +1 -0
- package/build/tools/interview.js +9 -9
- package/build/tools/start_bugfix.d.ts +2 -1
- package/build/tools/start_bugfix.js +170 -126
- package/build/tools/start_feature.d.ts +2 -1
- package/build/tools/start_feature.js +156 -112
- package/build/tools/start_onboard.d.ts +2 -1
- package/build/tools/start_onboard.js +57 -51
- package/build/tools/start_product.d.ts +2 -1
- package/build/tools/start_product.js +9 -1
- package/build/tools/start_ralph.d.ts +2 -1
- package/build/tools/start_ralph.js +9 -3
- package/build/tools/start_ui.d.ts +2 -1
- package/build/tools/start_ui.js +102 -88
- package/build/tools/ui-ux-tools.d.ts +2 -1
- package/build/tools/ui-ux-tools.js +19 -3
- package/build/utils/ui-sync.d.ts +6 -2
- package/build/utils/ui-sync.js +125 -29
- package/docs/assets/font/MaterialSymbolsOutlined.codepoints +4102 -0
- package/docs/assets/font/MaterialSymbolsOutlined.ttf +0 -0
- package/docs/assets/font/noto-sans-sc-400.ttf +0 -0
- package/docs/assets/font/noto-sans-sc-700.ttf +0 -0
- package/docs/assets/font/noto-sans-sc-900.ttf +0 -0
- package/docs/assets/js/i18n.js +122 -21
- package/docs/assets/js/tailwind.js +83 -83
- package/docs/data/tools.js +419 -399
- package/docs/debug-i18n.html +163 -0
- package/docs/i18n/all-tools/en.json +157 -0
- package/docs/i18n/all-tools/ja.json +157 -0
- package/docs/i18n/all-tools/ko.json +157 -0
- package/docs/i18n/all-tools/zh-CN.json +157 -0
- package/docs/pages/all-tools.html +514 -352
- package/docs/pages/examples.html +689 -689
- package/docs/pages/getting-started.html +589 -589
- package/docs/pages/migration.html +298 -298
- package/docs/specs/user-auth/design.md +82 -0
- package/docs/specs/user-auth/requirements.md +52 -0
- package/docs/specs/user-auth/tasks.md +55 -0
- package/package.json +5 -5
- package/docs/project-context/architecture.md +0 -0
- package/docs/project-context/how-to-develop.md +0 -313
- package/docs/project-context/how-to-test.md +0 -457
- package/docs/project-context/tech-stack.md +0 -96
- package/docs/project-context.md +0 -53
- package/docs/specs/git-work-report/design.md +0 -568
- package/docs/specs/git-work-report/requirements.md +0 -131
- package/docs/specs/git-work-report/tasks.md +0 -197
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { allToolSchemas } from '../schemas/index.js';
|
|
6
6
|
/**
|
|
7
|
-
* 工具集定义 (v3.0 精简版
|
|
7
|
+
* 工具集定义 (v3.0 精简版)
|
|
8
8
|
*
|
|
9
9
|
* - core: 核心工具(日常高频)
|
|
10
10
|
* - ui: UI/UX 工具(推荐使用 start_ui 统一入口)
|
|
@@ -12,10 +12,11 @@ import { allToolSchemas } from '../schemas/index.js';
|
|
|
12
12
|
* - full: 所有工具(默认)
|
|
13
13
|
*/
|
|
14
14
|
export const TOOLSET_DEFINITIONS = {
|
|
15
|
-
// 核心工具集 -
|
|
15
|
+
// 核心工具集 - 日常高频工具
|
|
16
16
|
core: [
|
|
17
17
|
'gencommit',
|
|
18
18
|
'code_review',
|
|
19
|
+
'code_insight',
|
|
19
20
|
'gentest',
|
|
20
21
|
'refactor',
|
|
21
22
|
'fix_bug',
|
|
@@ -31,11 +32,12 @@ export const TOOLSET_DEFINITIONS = {
|
|
|
31
32
|
'ui_search', // 搜索 UI/UX 数据库
|
|
32
33
|
'sync_ui_data', // 同步 UI 数据
|
|
33
34
|
],
|
|
34
|
-
// 工作流工具集 - 包含核心 + 编排 +
|
|
35
|
+
// 工作流工具集 - 包含核心 + 编排 + 交互
|
|
35
36
|
workflow: [
|
|
36
|
-
//
|
|
37
|
+
// 核心工具
|
|
37
38
|
'gencommit',
|
|
38
39
|
'code_review',
|
|
40
|
+
'code_insight',
|
|
39
41
|
'gentest',
|
|
40
42
|
'refactor',
|
|
41
43
|
'fix_bug',
|
|
@@ -58,7 +60,7 @@ export const TOOLSET_DEFINITIONS = {
|
|
|
58
60
|
'ui_search',
|
|
59
61
|
'sync_ui_data',
|
|
60
62
|
],
|
|
61
|
-
// 完整工具集 -
|
|
63
|
+
// 完整工具集 - 所有工具
|
|
62
64
|
full: 'all',
|
|
63
65
|
};
|
|
64
66
|
/**
|
|
@@ -19,6 +19,52 @@ export declare const codeAnalysisToolSchemas: readonly [{
|
|
|
19
19
|
readonly required: readonly [];
|
|
20
20
|
readonly additionalProperties: true;
|
|
21
21
|
};
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "code_insight";
|
|
24
|
+
readonly description: "当用户需要基于代码图谱分析调用链、上下文和影响面时使用。默认桥接 GitNexus,支持 query/context/impact 模式;不可用时自动降级并返回原因";
|
|
25
|
+
readonly inputSchema: {
|
|
26
|
+
readonly type: "object";
|
|
27
|
+
readonly properties: {
|
|
28
|
+
readonly mode: {
|
|
29
|
+
readonly type: "string";
|
|
30
|
+
readonly description: "分析模式:auto(默认)、query、context、impact";
|
|
31
|
+
};
|
|
32
|
+
readonly query: {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
readonly description: "查询文本(query 模式推荐)";
|
|
35
|
+
};
|
|
36
|
+
readonly target: {
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
readonly description: "目标符号(context/impact 模式推荐)";
|
|
39
|
+
};
|
|
40
|
+
readonly repo: {
|
|
41
|
+
readonly type: "string";
|
|
42
|
+
readonly description: "仓库名称(多仓库场景可选)";
|
|
43
|
+
};
|
|
44
|
+
readonly goal: {
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
readonly description: "分析目标(可选)";
|
|
47
|
+
};
|
|
48
|
+
readonly task_context: {
|
|
49
|
+
readonly type: "string";
|
|
50
|
+
readonly description: "任务上下文(可选)";
|
|
51
|
+
};
|
|
52
|
+
readonly direction: {
|
|
53
|
+
readonly type: "string";
|
|
54
|
+
readonly description: "impact 方向:upstream / downstream";
|
|
55
|
+
};
|
|
56
|
+
readonly max_depth: {
|
|
57
|
+
readonly type: "number";
|
|
58
|
+
readonly description: "impact 最大深度(可选,默认 3)";
|
|
59
|
+
};
|
|
60
|
+
readonly include_tests: {
|
|
61
|
+
readonly type: "boolean";
|
|
62
|
+
readonly description: "impact 是否包含测试文件(可选,默认 false)";
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
readonly required: readonly [];
|
|
66
|
+
readonly additionalProperties: true;
|
|
67
|
+
};
|
|
22
68
|
}, {
|
|
23
69
|
readonly name: "refactor";
|
|
24
70
|
readonly description: "当用户需要重构代码、改善代码结构时使用。分析代码结构,提供重构建议、重构步骤和风险评估";
|
|
@@ -21,6 +21,53 @@ export const codeAnalysisToolSchemas = [
|
|
|
21
21
|
additionalProperties: true,
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
|
+
{
|
|
25
|
+
name: "code_insight",
|
|
26
|
+
description: "当用户需要基于代码图谱分析调用链、上下文和影响面时使用。默认桥接 GitNexus,支持 query/context/impact 模式;不可用时自动降级并返回原因",
|
|
27
|
+
inputSchema: {
|
|
28
|
+
type: "object",
|
|
29
|
+
properties: {
|
|
30
|
+
mode: {
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "分析模式:auto(默认)、query、context、impact",
|
|
33
|
+
},
|
|
34
|
+
query: {
|
|
35
|
+
type: "string",
|
|
36
|
+
description: "查询文本(query 模式推荐)",
|
|
37
|
+
},
|
|
38
|
+
target: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "目标符号(context/impact 模式推荐)",
|
|
41
|
+
},
|
|
42
|
+
repo: {
|
|
43
|
+
type: "string",
|
|
44
|
+
description: "仓库名称(多仓库场景可选)",
|
|
45
|
+
},
|
|
46
|
+
goal: {
|
|
47
|
+
type: "string",
|
|
48
|
+
description: "分析目标(可选)",
|
|
49
|
+
},
|
|
50
|
+
task_context: {
|
|
51
|
+
type: "string",
|
|
52
|
+
description: "任务上下文(可选)",
|
|
53
|
+
},
|
|
54
|
+
direction: {
|
|
55
|
+
type: "string",
|
|
56
|
+
description: "impact 方向:upstream / downstream",
|
|
57
|
+
},
|
|
58
|
+
max_depth: {
|
|
59
|
+
type: "number",
|
|
60
|
+
description: "impact 最大深度(可选,默认 3)",
|
|
61
|
+
},
|
|
62
|
+
include_tests: {
|
|
63
|
+
type: "boolean",
|
|
64
|
+
description: "impact 是否包含测试文件(可选,默认 false)",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
required: [],
|
|
68
|
+
additionalProperties: true,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
24
71
|
{
|
|
25
72
|
name: "refactor",
|
|
26
73
|
description: "当用户需要重构代码、改善代码结构时使用。分析代码结构,提供重构建议、重构步骤和风险评估",
|
|
@@ -23,22 +23,22 @@ export const gitToolSchemas = [
|
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
name: "git_work_report",
|
|
26
|
-
description: `基于 Git diff 分析生成工作报告(日报/周期报)
|
|
27
|
-
|
|
28
|
-
核心功能:
|
|
29
|
-
- 支持日报模式(单个日期)和周期报模式(日期范围)
|
|
30
|
-
- 自动读取指定日期的所有 Git 提交
|
|
31
|
-
- 对每个提交执行 git show 获取完整 diff
|
|
32
|
-
- 使用 AI 分析 diff 内容提取实际工作内容
|
|
33
|
-
|
|
34
|
-
输出格式:
|
|
35
|
-
- 只输出「工作内容」部分
|
|
36
|
-
- 每条以 - 开头,中文,简洁专业
|
|
37
|
-
- 格式:做了什么 + 改了哪里/达到什么效果
|
|
38
|
-
- 不输出:提交哈希、文件列表、统计数据、风险总结
|
|
39
|
-
|
|
40
|
-
使用示例:
|
|
41
|
-
- 日报:git_work_report --date 2026-1-27
|
|
26
|
+
description: `基于 Git diff 分析生成工作报告(日报/周期报)
|
|
27
|
+
|
|
28
|
+
核心功能:
|
|
29
|
+
- 支持日报模式(单个日期)和周期报模式(日期范围)
|
|
30
|
+
- 自动读取指定日期的所有 Git 提交
|
|
31
|
+
- 对每个提交执行 git show 获取完整 diff
|
|
32
|
+
- 使用 AI 分析 diff 内容提取实际工作内容
|
|
33
|
+
|
|
34
|
+
输出格式:
|
|
35
|
+
- 只输出「工作内容」部分
|
|
36
|
+
- 每条以 - 开头,中文,简洁专业
|
|
37
|
+
- 格式:做了什么 + 改了哪里/达到什么效果
|
|
38
|
+
- 不输出:提交哈希、文件列表、统计数据、风险总结
|
|
39
|
+
|
|
40
|
+
使用示例:
|
|
41
|
+
- 日报:git_work_report --date 2026-1-27
|
|
42
42
|
- 周期报:git_work_report --start_date 2026-2-1 --end_date 2026-2-6`,
|
|
43
43
|
inputSchema: {
|
|
44
44
|
type: "object",
|
package/build/schemas/index.d.ts
CHANGED
|
@@ -81,6 +81,52 @@ export declare const allToolSchemas: ({
|
|
|
81
81
|
readonly required: readonly [];
|
|
82
82
|
readonly additionalProperties: true;
|
|
83
83
|
};
|
|
84
|
+
} | {
|
|
85
|
+
readonly name: "code_insight";
|
|
86
|
+
readonly description: "当用户需要基于代码图谱分析调用链、上下文和影响面时使用。默认桥接 GitNexus,支持 query/context/impact 模式;不可用时自动降级并返回原因";
|
|
87
|
+
readonly inputSchema: {
|
|
88
|
+
readonly type: "object";
|
|
89
|
+
readonly properties: {
|
|
90
|
+
readonly mode: {
|
|
91
|
+
readonly type: "string";
|
|
92
|
+
readonly description: "分析模式:auto(默认)、query、context、impact";
|
|
93
|
+
};
|
|
94
|
+
readonly query: {
|
|
95
|
+
readonly type: "string";
|
|
96
|
+
readonly description: "查询文本(query 模式推荐)";
|
|
97
|
+
};
|
|
98
|
+
readonly target: {
|
|
99
|
+
readonly type: "string";
|
|
100
|
+
readonly description: "目标符号(context/impact 模式推荐)";
|
|
101
|
+
};
|
|
102
|
+
readonly repo: {
|
|
103
|
+
readonly type: "string";
|
|
104
|
+
readonly description: "仓库名称(多仓库场景可选)";
|
|
105
|
+
};
|
|
106
|
+
readonly goal: {
|
|
107
|
+
readonly type: "string";
|
|
108
|
+
readonly description: "分析目标(可选)";
|
|
109
|
+
};
|
|
110
|
+
readonly task_context: {
|
|
111
|
+
readonly type: "string";
|
|
112
|
+
readonly description: "任务上下文(可选)";
|
|
113
|
+
};
|
|
114
|
+
readonly direction: {
|
|
115
|
+
readonly type: "string";
|
|
116
|
+
readonly description: "impact 方向:upstream / downstream";
|
|
117
|
+
};
|
|
118
|
+
readonly max_depth: {
|
|
119
|
+
readonly type: "number";
|
|
120
|
+
readonly description: "impact 最大深度(可选,默认 3)";
|
|
121
|
+
};
|
|
122
|
+
readonly include_tests: {
|
|
123
|
+
readonly type: "boolean";
|
|
124
|
+
readonly description: "impact 是否包含测试文件(可选,默认 false)";
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
readonly required: readonly [];
|
|
128
|
+
readonly additionalProperties: true;
|
|
129
|
+
};
|
|
84
130
|
} | {
|
|
85
131
|
readonly name: "refactor";
|
|
86
132
|
readonly description: "当用户需要重构代码、改善代码结构时使用。分析代码结构,提供重构建议、重构步骤和风险评估";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { codeInsight } from "../code_insight.js";
|
|
3
|
+
describe("code_insight 单元测试", () => {
|
|
4
|
+
test("mode 非法时返回错误", async () => {
|
|
5
|
+
const result = await codeInsight({
|
|
6
|
+
mode: "unknown-mode",
|
|
7
|
+
query: "auth",
|
|
8
|
+
});
|
|
9
|
+
expect(result.isError).toBe(true);
|
|
10
|
+
expect(result.content[0].text).toMatch(/不支持的 mode/i);
|
|
11
|
+
});
|
|
12
|
+
test("bridge 禁用时返回降级结果(非硬错误)", async () => {
|
|
13
|
+
const prev = process.env.MCP_ENABLE_GITNEXUS_BRIDGE;
|
|
14
|
+
process.env.MCP_ENABLE_GITNEXUS_BRIDGE = "0";
|
|
15
|
+
try {
|
|
16
|
+
const result = await codeInsight({
|
|
17
|
+
mode: "query",
|
|
18
|
+
query: "authentication middleware",
|
|
19
|
+
});
|
|
20
|
+
expect(result.isError).toBe(false);
|
|
21
|
+
expect("structuredContent" in result).toBe(true);
|
|
22
|
+
const structured = result.structuredContent;
|
|
23
|
+
expect(structured.status).toBe("degraded");
|
|
24
|
+
expect(structured.provider).toBe("gitnexus");
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
if (prev === undefined) {
|
|
28
|
+
delete process.env.MCP_ENABLE_GITNEXUS_BRIDGE;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
process.env.MCP_ENABLE_GITNEXUS_BRIDGE = prev;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -47,20 +47,20 @@ describe('start_bugfix 单元测试', () => {
|
|
|
47
47
|
});
|
|
48
48
|
test('template_profile 自动选择 strict(结构化输入)', async () => {
|
|
49
49
|
const result = await startBugfix({
|
|
50
|
-
error_message: `## 复现步骤
|
|
51
|
-
1. 打开登录页
|
|
52
|
-
2. 输入错误账号
|
|
53
|
-
3. 点击登录
|
|
54
|
-
|
|
55
|
-
## 期望
|
|
56
|
-
提示错误信息并保持页面可交互
|
|
57
|
-
|
|
58
|
-
## 实际
|
|
59
|
-
页面白屏,控制台报错
|
|
60
|
-
|
|
61
|
-
## 环境
|
|
62
|
-
- 浏览器: Chrome 120
|
|
63
|
-
- 系统: Windows 11
|
|
50
|
+
error_message: `## 复现步骤
|
|
51
|
+
1. 打开登录页
|
|
52
|
+
2. 输入错误账号
|
|
53
|
+
3. 点击登录
|
|
54
|
+
|
|
55
|
+
## 期望
|
|
56
|
+
提示错误信息并保持页面可交互
|
|
57
|
+
|
|
58
|
+
## 实际
|
|
59
|
+
页面白屏,控制台报错
|
|
60
|
+
|
|
61
|
+
## 环境
|
|
62
|
+
- 浏览器: Chrome 120
|
|
63
|
+
- 系统: Windows 11
|
|
64
64
|
- 版本: v2.3.0`,
|
|
65
65
|
stack_trace: 'TypeError: Cannot read property',
|
|
66
66
|
template_profile: 'auto',
|
|
@@ -62,17 +62,17 @@ describe('start_ui 单元测试', () => {
|
|
|
62
62
|
describe('模板档位', () => {
|
|
63
63
|
test('auto 模式可自动选择 strict', async () => {
|
|
64
64
|
const result = await startUi({
|
|
65
|
-
description: `# 页面目标
|
|
66
|
-
需要一个带筛选和批量操作的管理后台,用于管理订单与用户数据,包含导出与权限控制。
|
|
67
|
-
|
|
68
|
-
## 关键交互
|
|
69
|
-
1. 支持筛选、排序、分页、导出
|
|
70
|
-
2. 批量启用/禁用、批量标签、批量删除
|
|
71
|
-
|
|
72
|
-
## 数据来源
|
|
73
|
-
来自订单服务与用户服务接口,刷新频率 30s
|
|
74
|
-
|
|
75
|
-
## 状态
|
|
65
|
+
description: `# 页面目标
|
|
66
|
+
需要一个带筛选和批量操作的管理后台,用于管理订单与用户数据,包含导出与权限控制。
|
|
67
|
+
|
|
68
|
+
## 关键交互
|
|
69
|
+
1. 支持筛选、排序、分页、导出
|
|
70
|
+
2. 批量启用/禁用、批量标签、批量删除
|
|
71
|
+
|
|
72
|
+
## 数据来源
|
|
73
|
+
来自订单服务与用户服务接口,刷新频率 30s
|
|
74
|
+
|
|
75
|
+
## 状态
|
|
76
76
|
空态、加载态、错误态、无权限提示、空筛选结果`,
|
|
77
77
|
template_profile: 'auto',
|
|
78
78
|
});
|
|
@@ -206,85 +206,85 @@ export async function addFeature(args) {
|
|
|
206
206
|
};
|
|
207
207
|
const fenceOpen = "````markdown";
|
|
208
208
|
const fenceClose = "````";
|
|
209
|
-
const guide = `# 添加新功能指南(模板驱动)
|
|
210
|
-
|
|
211
|
-
## 🎯 任务目标
|
|
212
|
-
|
|
213
|
-
为项目添加新功能:**${featureName}**
|
|
214
|
-
|
|
215
|
-
**功能描述**: ${description}
|
|
216
|
-
|
|
217
|
-
**模板档位**: ${templateProfile}${profileDecision.requested === 'auto' ? '(自动)' : ''}
|
|
218
|
-
${profileDecision.requested === 'auto' && profileDecision.reason ? `**选择理由**: ${profileDecision.reason}` : ''}
|
|
219
|
-
|
|
220
|
-
---
|
|
221
|
-
|
|
222
|
-
## 📋 前置检查
|
|
223
|
-
|
|
224
|
-
1. 检查文件 \`${docsDir}/project-context.md\` 是否存在
|
|
225
|
-
2. 如果存在,读取并参考其中的技术栈、架构模式、编码规范
|
|
226
|
-
3. 如果不存在,建议先运行 \`init_project_context\` 工具
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
## ✅ 模板校验结果
|
|
231
|
-
|
|
232
|
-
${formatValidation('requirements.md', requirementsTemplate.validation)}
|
|
233
|
-
${formatValidation('design.md', designTemplate.validation)}
|
|
234
|
-
${formatValidation('tasks.md', tasksTemplate.validation)}
|
|
235
|
-
${combinedValidation.warnings.length > 0 ? `- 其他警告: ${combinedValidation.warnings.join(';')}` : ''}
|
|
236
|
-
|
|
237
|
-
---
|
|
238
|
-
|
|
239
|
-
## 📝 创建文档
|
|
240
|
-
|
|
241
|
-
请在 \`${docsDir}/specs/${featureName}/\` 目录下创建以下三个文件:
|
|
242
|
-
|
|
243
|
-
### 文件 1: requirements.md
|
|
244
|
-
|
|
245
|
-
**文件路径**: \`${docsDir}/specs/${featureName}/requirements.md\`
|
|
246
|
-
**模板来源**: ${requirementsTemplate.source}
|
|
247
|
-
|
|
248
|
-
${fenceOpen}
|
|
249
|
-
${requirementsTemplate.content}
|
|
250
|
-
${fenceClose}
|
|
251
|
-
|
|
252
|
-
---
|
|
253
|
-
|
|
254
|
-
### 文件 2: design.md
|
|
255
|
-
|
|
256
|
-
**文件路径**: \`${docsDir}/specs/${featureName}/design.md\`
|
|
257
|
-
**模板来源**: ${designTemplate.source}
|
|
258
|
-
|
|
259
|
-
${fenceOpen}
|
|
260
|
-
${designTemplate.content}
|
|
261
|
-
${fenceClose}
|
|
262
|
-
|
|
263
|
-
---
|
|
264
|
-
|
|
265
|
-
### 文件 3: tasks.md
|
|
266
|
-
|
|
267
|
-
**文件路径**: \`${docsDir}/specs/${featureName}/tasks.md\`
|
|
268
|
-
**模板来源**: ${tasksTemplate.source}
|
|
269
|
-
|
|
270
|
-
${fenceOpen}
|
|
271
|
-
${tasksTemplate.content}
|
|
272
|
-
${fenceClose}
|
|
273
|
-
|
|
274
|
-
---
|
|
275
|
-
|
|
276
|
-
## ✅ 完成后检查
|
|
277
|
-
|
|
278
|
-
- [ ] \`${docsDir}/specs/${featureName}/requirements.md\` 已创建
|
|
279
|
-
- [ ] \`${docsDir}/specs/${featureName}/design.md\` 已创建
|
|
280
|
-
- [ ] \`${docsDir}/specs/${featureName}/tasks.md\` 已创建
|
|
281
|
-
- [ ] 所有占位符已替换
|
|
282
|
-
- [ ] 内容与项目上下文一致(如有)
|
|
283
|
-
|
|
284
|
-
---
|
|
285
|
-
|
|
286
|
-
*指南版本: 1.1.0*
|
|
287
|
-
*工具: MCP Probe Kit - add_feature*
|
|
209
|
+
const guide = `# 添加新功能指南(模板驱动)
|
|
210
|
+
|
|
211
|
+
## 🎯 任务目标
|
|
212
|
+
|
|
213
|
+
为项目添加新功能:**${featureName}**
|
|
214
|
+
|
|
215
|
+
**功能描述**: ${description}
|
|
216
|
+
|
|
217
|
+
**模板档位**: ${templateProfile}${profileDecision.requested === 'auto' ? '(自动)' : ''}
|
|
218
|
+
${profileDecision.requested === 'auto' && profileDecision.reason ? `**选择理由**: ${profileDecision.reason}` : ''}
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## 📋 前置检查
|
|
223
|
+
|
|
224
|
+
1. 检查文件 \`${docsDir}/project-context.md\` 是否存在
|
|
225
|
+
2. 如果存在,读取并参考其中的技术栈、架构模式、编码规范
|
|
226
|
+
3. 如果不存在,建议先运行 \`init_project_context\` 工具
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## ✅ 模板校验结果
|
|
231
|
+
|
|
232
|
+
${formatValidation('requirements.md', requirementsTemplate.validation)}
|
|
233
|
+
${formatValidation('design.md', designTemplate.validation)}
|
|
234
|
+
${formatValidation('tasks.md', tasksTemplate.validation)}
|
|
235
|
+
${combinedValidation.warnings.length > 0 ? `- 其他警告: ${combinedValidation.warnings.join(';')}` : ''}
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## 📝 创建文档
|
|
240
|
+
|
|
241
|
+
请在 \`${docsDir}/specs/${featureName}/\` 目录下创建以下三个文件:
|
|
242
|
+
|
|
243
|
+
### 文件 1: requirements.md
|
|
244
|
+
|
|
245
|
+
**文件路径**: \`${docsDir}/specs/${featureName}/requirements.md\`
|
|
246
|
+
**模板来源**: ${requirementsTemplate.source}
|
|
247
|
+
|
|
248
|
+
${fenceOpen}
|
|
249
|
+
${requirementsTemplate.content}
|
|
250
|
+
${fenceClose}
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
### 文件 2: design.md
|
|
255
|
+
|
|
256
|
+
**文件路径**: \`${docsDir}/specs/${featureName}/design.md\`
|
|
257
|
+
**模板来源**: ${designTemplate.source}
|
|
258
|
+
|
|
259
|
+
${fenceOpen}
|
|
260
|
+
${designTemplate.content}
|
|
261
|
+
${fenceClose}
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
### 文件 3: tasks.md
|
|
266
|
+
|
|
267
|
+
**文件路径**: \`${docsDir}/specs/${featureName}/tasks.md\`
|
|
268
|
+
**模板来源**: ${tasksTemplate.source}
|
|
269
|
+
|
|
270
|
+
${fenceOpen}
|
|
271
|
+
${tasksTemplate.content}
|
|
272
|
+
${fenceClose}
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## ✅ 完成后检查
|
|
277
|
+
|
|
278
|
+
- [ ] \`${docsDir}/specs/${featureName}/requirements.md\` 已创建
|
|
279
|
+
- [ ] \`${docsDir}/specs/${featureName}/design.md\` 已创建
|
|
280
|
+
- [ ] \`${docsDir}/specs/${featureName}/tasks.md\` 已创建
|
|
281
|
+
- [ ] 所有占位符已替换
|
|
282
|
+
- [ ] 内容与项目上下文一致(如有)
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
*指南版本: 1.1.0*
|
|
287
|
+
*工具: MCP Probe Kit - add_feature*
|
|
288
288
|
`;
|
|
289
289
|
return okText(guide, {
|
|
290
290
|
schema: (await import("../schemas/output/project-tools.js")).FeatureSpecSchema,
|
package/build/tools/ask_user.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ToolExecutionContext } from "../lib/tool-execution-context.js";
|
|
2
|
+
export declare function codeInsight(args: any, context?: ToolExecutionContext): Promise<import("../lib/response.js").ToolResponse | {
|
|
3
|
+
content: {
|
|
4
|
+
type: string;
|
|
5
|
+
text: string;
|
|
6
|
+
}[];
|
|
7
|
+
isError: boolean;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { parseArgs, getString, getNumber, getBoolean } from "../utils/parseArgs.js";
|
|
2
|
+
import { okStructured } from "../lib/response.js";
|
|
3
|
+
import { runCodeInsightBridge, } from "../lib/gitnexus-bridge.js";
|
|
4
|
+
import { throwIfAborted, } from "../lib/tool-execution-context.js";
|
|
5
|
+
const ALLOWED_MODES = new Set(["auto", "query", "context", "impact"]);
|
|
6
|
+
const ALLOWED_DIRECTIONS = new Set(["upstream", "downstream"]);
|
|
7
|
+
function normalizeMode(value) {
|
|
8
|
+
const mode = (value || "auto").trim().toLowerCase();
|
|
9
|
+
if (!ALLOWED_MODES.has(mode)) {
|
|
10
|
+
throw new Error(`不支持的 mode: ${value}(可选: auto/query/context/impact)`);
|
|
11
|
+
}
|
|
12
|
+
return mode;
|
|
13
|
+
}
|
|
14
|
+
function normalizeDirection(value) {
|
|
15
|
+
if (!value) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const direction = value.trim().toLowerCase();
|
|
19
|
+
if (!ALLOWED_DIRECTIONS.has(direction)) {
|
|
20
|
+
throw new Error(`不支持的 direction: ${value}(可选: upstream/downstream)`);
|
|
21
|
+
}
|
|
22
|
+
return direction;
|
|
23
|
+
}
|
|
24
|
+
function summarizeExecutions(executions) {
|
|
25
|
+
if (executions.length === 0) {
|
|
26
|
+
return "- 未执行图谱调用";
|
|
27
|
+
}
|
|
28
|
+
return executions
|
|
29
|
+
.map((item) => {
|
|
30
|
+
if (item.ok) {
|
|
31
|
+
return `- ✅ ${item.tool}: ${(item.text || "已返回结果").replace(/\s+/g, " ").slice(0, 180)}`;
|
|
32
|
+
}
|
|
33
|
+
return `- ⚠️ ${item.tool}: ${(item.error || "调用失败").replace(/\s+/g, " ").slice(0, 180)}`;
|
|
34
|
+
})
|
|
35
|
+
.join("\n");
|
|
36
|
+
}
|
|
37
|
+
export async function codeInsight(args, context) {
|
|
38
|
+
try {
|
|
39
|
+
throwIfAborted(context?.signal, "code_insight 已取消");
|
|
40
|
+
const parsedArgs = parseArgs(args, {
|
|
41
|
+
defaultValues: {
|
|
42
|
+
mode: "auto",
|
|
43
|
+
query: "",
|
|
44
|
+
target: "",
|
|
45
|
+
repo: "",
|
|
46
|
+
goal: "",
|
|
47
|
+
task_context: "",
|
|
48
|
+
direction: "",
|
|
49
|
+
max_depth: 3,
|
|
50
|
+
include_tests: false,
|
|
51
|
+
},
|
|
52
|
+
primaryField: "input",
|
|
53
|
+
fieldAliases: {
|
|
54
|
+
mode: ["m", "模式"],
|
|
55
|
+
query: ["q", "keyword", "关键词"],
|
|
56
|
+
target: ["symbol", "name", "目标符号"],
|
|
57
|
+
repo: ["repository", "仓库"],
|
|
58
|
+
goal: ["目的", "目标"],
|
|
59
|
+
task_context: ["context", "taskContext", "任务上下文"],
|
|
60
|
+
direction: ["dir", "方向"],
|
|
61
|
+
max_depth: ["depth", "maxDepth", "最大深度"],
|
|
62
|
+
include_tests: ["includeTests", "包含测试"],
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
const mode = normalizeMode(getString(parsedArgs.mode, "auto"));
|
|
66
|
+
const query = getString(parsedArgs.query);
|
|
67
|
+
const target = getString(parsedArgs.target);
|
|
68
|
+
const repo = getString(parsedArgs.repo);
|
|
69
|
+
const goal = getString(parsedArgs.goal);
|
|
70
|
+
const taskContext = getString(parsedArgs.task_context);
|
|
71
|
+
const direction = normalizeDirection(getString(parsedArgs.direction));
|
|
72
|
+
const maxDepth = Math.max(1, getNumber(parsedArgs.max_depth, 3));
|
|
73
|
+
const includeTests = getBoolean(parsedArgs.include_tests, false);
|
|
74
|
+
const input = getString(parsedArgs.input);
|
|
75
|
+
const finalQuery = query || (mode === "query" ? input : "");
|
|
76
|
+
const finalTarget = target || ((mode === "context" || mode === "impact") ? input : "");
|
|
77
|
+
throwIfAborted(context?.signal, "code_insight 已取消");
|
|
78
|
+
const result = await runCodeInsightBridge({
|
|
79
|
+
mode,
|
|
80
|
+
query: finalQuery,
|
|
81
|
+
target: finalTarget,
|
|
82
|
+
repo: repo || undefined,
|
|
83
|
+
goal: goal || undefined,
|
|
84
|
+
taskContext: taskContext || undefined,
|
|
85
|
+
direction,
|
|
86
|
+
maxDepth,
|
|
87
|
+
includeTests,
|
|
88
|
+
signal: context?.signal,
|
|
89
|
+
});
|
|
90
|
+
const executionSummary = summarizeExecutions(result.executions.map((item) => ({
|
|
91
|
+
tool: item.tool,
|
|
92
|
+
ok: item.ok,
|
|
93
|
+
text: item.text,
|
|
94
|
+
error: item.error,
|
|
95
|
+
})));
|
|
96
|
+
const message = `# code_insight 图谱分析结果
|
|
97
|
+
|
|
98
|
+
状态: ${result.available ? "可用" : "降级"}
|
|
99
|
+
模式: ${result.modeRequested} -> ${result.modeResolved}
|
|
100
|
+
来源: ${result.provider}
|
|
101
|
+
|
|
102
|
+
摘要:
|
|
103
|
+
${result.summary}
|
|
104
|
+
|
|
105
|
+
执行详情:
|
|
106
|
+
${executionSummary}
|
|
107
|
+
|
|
108
|
+
${result.warnings.length > 0 ? `警告: ${result.warnings.join(", ")}` : ""}`.trim();
|
|
109
|
+
return okStructured(message, {
|
|
110
|
+
status: result.available ? "ok" : "degraded",
|
|
111
|
+
provider: result.provider,
|
|
112
|
+
mode: {
|
|
113
|
+
requested: result.modeRequested,
|
|
114
|
+
resolved: result.modeResolved,
|
|
115
|
+
},
|
|
116
|
+
summary: result.summary,
|
|
117
|
+
warnings: result.warnings,
|
|
118
|
+
executions: result.executions,
|
|
119
|
+
repo: result.repo || null,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
124
|
+
return {
|
|
125
|
+
content: [{ type: "text", text: `❌ code_insight 执行失败: ${errorMessage}` }],
|
|
126
|
+
isError: true,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|