mcp-probe-kit 3.3.0 → 3.6.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 +781 -765
- package/build/index.js +198 -191
- package/build/lib/__tests__/agents-md-template.unit.test.js +1 -0
- package/build/lib/__tests__/dev-workflow.unit.test.d.ts +1 -0
- package/build/lib/__tests__/dev-workflow.unit.test.js +22 -0
- package/build/lib/__tests__/handles.unit.test.d.ts +1 -0
- package/build/lib/__tests__/handles.unit.test.js +19 -0
- package/build/lib/__tests__/mcp-apps.unit.test.d.ts +1 -0
- package/build/lib/__tests__/mcp-apps.unit.test.js +52 -0
- package/build/lib/__tests__/mcp-tool-skill-registry.unit.test.d.ts +1 -0
- package/build/lib/__tests__/mcp-tool-skill-registry.unit.test.js +18 -0
- package/build/lib/__tests__/memory-client.unit.test.js +105 -0
- package/build/lib/__tests__/spec-gate.unit.test.d.ts +1 -0
- package/build/lib/__tests__/spec-gate.unit.test.js +54 -0
- package/build/lib/__tests__/task-defaults.unit.test.d.ts +1 -0
- package/build/lib/__tests__/task-defaults.unit.test.js +27 -0
- package/build/lib/__tests__/workflow-skill-installer.unit.test.d.ts +1 -0
- package/build/lib/__tests__/workflow-skill-installer.unit.test.js +110 -0
- package/build/lib/__tests__/workspace-root.unit.test.d.ts +1 -0
- package/build/lib/__tests__/workspace-root.unit.test.js +31 -0
- package/build/lib/agents-md-template.js +10 -2
- package/build/lib/dev-workflow.d.ts +36 -0
- package/build/lib/dev-workflow.js +497 -0
- package/build/lib/handles.d.ts +31 -0
- package/build/lib/handles.js +36 -0
- package/build/lib/mcp-apps.d.ts +14 -0
- package/build/lib/mcp-apps.js +234 -0
- package/build/lib/mcp-tool-skill-registry.d.ts +46 -0
- package/build/lib/mcp-tool-skill-registry.js +256 -0
- package/build/lib/memory-client.d.ts +19 -0
- package/build/lib/memory-client.js +69 -0
- package/build/lib/memory-orchestration.d.ts +5 -0
- package/build/lib/memory-orchestration.js +20 -0
- package/build/lib/merge-agents-md.d.ts +2 -2
- package/build/lib/merge-agents-md.js +7 -4
- package/build/lib/output-schema-registry.d.ts +11 -0
- package/build/lib/output-schema-registry.js +80 -0
- package/build/lib/spec-gate.d.ts +32 -0
- package/build/lib/spec-gate.js +83 -0
- package/build/lib/task-defaults.d.ts +6 -0
- package/build/lib/task-defaults.js +20 -0
- package/build/lib/tool-annotations.js +3 -0
- package/build/lib/toolset-manager.js +2 -0
- package/build/lib/workflow-skill-installer.d.ts +40 -0
- package/build/lib/workflow-skill-installer.js +172 -0
- package/build/lib/workflow-skill-template.d.ts +9 -0
- package/build/lib/workflow-skill-template.js +85 -0
- package/build/lib/workflow-skill-version.d.ts +15 -0
- package/build/lib/workflow-skill-version.js +68 -0
- package/build/lib/workspace-root.d.ts +4 -0
- package/build/lib/workspace-root.js +33 -0
- package/build/schemas/basic-tools.d.ts +4 -0
- package/build/schemas/basic-tools.js +4 -0
- package/build/schemas/index.d.ts +114 -0
- package/build/schemas/index.js +1 -0
- package/build/schemas/memory-tools.d.ts +83 -0
- package/build/schemas/memory-tools.js +43 -0
- package/build/schemas/orchestration-tools.d.ts +8 -0
- package/build/schemas/orchestration-tools.js +8 -0
- package/build/schemas/output/code-insight-tools.d.ts +65 -0
- package/build/schemas/output/code-insight-tools.js +42 -0
- package/build/schemas/output/memory-tools.d.ts +576 -0
- package/build/schemas/output/memory-tools.js +148 -0
- package/build/schemas/project-tools.d.ts +19 -0
- package/build/schemas/project-tools.js +20 -0
- package/build/tools/__tests__/delete_memory_asset.unit.test.d.ts +1 -0
- package/build/tools/__tests__/delete_memory_asset.unit.test.js +87 -0
- package/build/tools/__tests__/search_memory.unit.test.js +1 -0
- package/build/tools/__tests__/start_bugfix.unit.test.js +34 -1
- package/build/tools/__tests__/update_memory_asset.unit.test.d.ts +1 -0
- package/build/tools/__tests__/update_memory_asset.unit.test.js +82 -0
- package/build/tools/__tests__/workflow.unit.test.d.ts +1 -0
- package/build/tools/__tests__/workflow.unit.test.js +24 -0
- package/build/tools/code_insight.js +5 -1
- package/build/tools/delete_memory_asset.d.ts +7 -0
- package/build/tools/delete_memory_asset.js +57 -0
- package/build/tools/index.d.ts +3 -0
- package/build/tools/index.js +3 -0
- package/build/tools/init_project.js +170 -158
- package/build/tools/search_memory.js +5 -2
- package/build/tools/start_bugfix.js +37 -4
- package/build/tools/start_feature.js +4 -3
- package/build/tools/start_ui.js +5 -4
- package/build/tools/update_memory_asset.d.ts +7 -0
- package/build/tools/update_memory_asset.js +98 -0
- package/build/tools/workflow.d.ts +13 -0
- package/build/tools/workflow.js +69 -0
- package/package.json +5 -3
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { parseArgs, getString } from "../utils/parseArgs.js";
|
|
2
2
|
import { okStructured } from "../lib/response.js";
|
|
3
|
+
import { ensureMcpProbeKitBootstrap } from "../lib/workflow-skill-installer.js";
|
|
4
|
+
import { MCP_PROBE_SKILL_REL_PATH } from "../lib/workflow-skill-template.js";
|
|
5
|
+
import { resolveWorkspaceRoot } from "../lib/workspace-root.js";
|
|
3
6
|
/**
|
|
4
7
|
* init_project 工具
|
|
5
8
|
*
|
|
@@ -13,174 +16,183 @@ export async function initProject(args) {
|
|
|
13
16
|
defaultValues: {
|
|
14
17
|
input: "",
|
|
15
18
|
project_name: "新项目",
|
|
19
|
+
project_root: "",
|
|
16
20
|
},
|
|
17
21
|
primaryField: "input", // 纯文本输入默认映射到 input 字段
|
|
18
22
|
fieldAliases: {
|
|
19
23
|
input: ["requirement", "description", "需求", "项目需求"],
|
|
20
24
|
project_name: ["name", "project", "项目名", "项目名称"],
|
|
25
|
+
project_root: ["root", "path", "项目路径"],
|
|
21
26
|
},
|
|
22
27
|
});
|
|
23
28
|
const input = getString(parsedArgs.input);
|
|
24
29
|
const projectName = getString(parsedArgs.project_name) || "新项目";
|
|
30
|
+
const projectRoot = resolveWorkspaceRoot(getString(parsedArgs.project_root));
|
|
31
|
+
const bootstrap = ensureMcpProbeKitBootstrap(projectRoot);
|
|
25
32
|
const featureSlug = projectName.toLowerCase().replace(/\s+/g, '-');
|
|
26
|
-
const message = `你需要按照 Spec-Driven Development(规范驱动开发)的方式初始化项目,参考 https://github.com/github/spec-kit 的工作流程。
|
|
27
|
-
|
|
28
|
-
📋 **项目需求**:
|
|
29
|
-
${input}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
│
|
|
45
|
-
│
|
|
46
|
-
│
|
|
47
|
-
|
|
48
|
-
│
|
|
49
|
-
│
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
##
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
- [ ] 1.
|
|
127
|
-
-
|
|
128
|
-
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
- [ ] 2
|
|
132
|
-
-
|
|
133
|
-
- _需求:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
-
|
|
138
|
-
- _需求: 2.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
33
|
+
const message = `你需要按照 Spec-Driven Development(规范驱动开发)的方式初始化项目,参考 https://github.com/github/spec-kit 的工作流程。
|
|
34
|
+
|
|
35
|
+
📋 **项目需求**:
|
|
36
|
+
${input}
|
|
37
|
+
|
|
38
|
+
📌 **MCP Skill 已同步**(项目根: \`${projectRoot}\`):
|
|
39
|
+
- \`${MCP_PROBE_SKILL_REL_PATH}\`${bootstrap.skill.created ? "(已创建)" : bootstrap.skill.updated ? "(已升级)" : "(已是最新)"}
|
|
40
|
+
- \`${bootstrap.agentsMd.path}\`${bootstrap.agentsMd.created ? "(已创建)" : bootstrap.agentsMd.updated ? "(已更新)" : ""}
|
|
41
|
+
${bootstrap.workspaceWarning ? `\n⚠️ ${bootstrap.workspaceWarning}\n` : ""}
|
|
42
|
+
|
|
43
|
+
🎯 **初始化步骤**:
|
|
44
|
+
|
|
45
|
+
**第一步:创建项目基础结构**
|
|
46
|
+
在当前工作区创建以下目录和文件:
|
|
47
|
+
|
|
48
|
+
\`\`\`
|
|
49
|
+
.
|
|
50
|
+
├── docs/
|
|
51
|
+
│ ├── project-context.md # 项目上下文(技术栈、架构、规范)
|
|
52
|
+
│ ├── constitution.md # 项目宪法(核心原则和约束)
|
|
53
|
+
│ └── specs/
|
|
54
|
+
│ └── ${featureSlug}/
|
|
55
|
+
│ ├── requirements.md # 需求文档(EARS 格式)
|
|
56
|
+
│ ├── design.md # 设计文档
|
|
57
|
+
│ ├── tasks.md # 任务分解
|
|
58
|
+
│ └── research.md # 技术调研
|
|
59
|
+
├── scripts/
|
|
60
|
+
│ ├── check-prerequisites.sh
|
|
61
|
+
│ └── setup.sh
|
|
62
|
+
└── src/ # 源代码目录
|
|
63
|
+
\`\`\`
|
|
64
|
+
|
|
65
|
+
**第二步:生成 project-context.md**
|
|
66
|
+
在 \`docs/project-context.md\` 中记录项目的核心信息:
|
|
67
|
+
- 项目概览(名称、版本、类型、描述)
|
|
68
|
+
- 技术栈(语言、框架、构建工具、测试框架)
|
|
69
|
+
- 项目结构(目录说明、入口文件)
|
|
70
|
+
- 架构模式(设计模式、模块划分)
|
|
71
|
+
- 编码规范(代码风格、命名规范)
|
|
72
|
+
- 依赖管理(主要依赖列表)
|
|
73
|
+
- 开发流程(常用命令)
|
|
74
|
+
|
|
75
|
+
**第三步:生成 constitution.md**
|
|
76
|
+
在 \`docs/constitution.md\` 中定义项目的核心原则:
|
|
77
|
+
- 代码风格规范
|
|
78
|
+
- 架构原则
|
|
79
|
+
- 安全准则
|
|
80
|
+
- 测试要求
|
|
81
|
+
- 文档标准
|
|
82
|
+
|
|
83
|
+
**第四步:生成 requirements.md(需求文档)**
|
|
84
|
+
在 \`docs/specs/${featureSlug}/requirements.md\` 中详细描述:
|
|
85
|
+
- 功能概述
|
|
86
|
+
- 术语定义
|
|
87
|
+
- 需求列表(使用 EARS 格式)
|
|
88
|
+
- 用户故事(As a... I want... So that...)
|
|
89
|
+
- 验收标准(WHEN/WHILE/IF...THEN...SHALL)
|
|
90
|
+
- 非功能需求(性能、安全、兼容性)
|
|
91
|
+
- 依赖关系
|
|
92
|
+
|
|
93
|
+
**EARS 格式说明**:
|
|
94
|
+
| 模式 | 格式 | 适用场景 |
|
|
95
|
+
|------|------|----------|
|
|
96
|
+
| Ubiquitous | THE [system] SHALL [response] | 始终适用的需求 |
|
|
97
|
+
| Event-driven | WHEN [trigger], THE [system] SHALL [response] | 事件触发的需求 |
|
|
98
|
+
| State-driven | WHILE [condition], THE [system] SHALL [response] | 状态相关的需求 |
|
|
99
|
+
| Unwanted | IF [condition], THEN THE [system] SHALL [response] | 异常处理需求 |
|
|
100
|
+
|
|
101
|
+
**第五步:生成 design.md(设计文档)**
|
|
102
|
+
在 \`docs/specs/${featureSlug}/design.md\` 中描述:
|
|
103
|
+
- 技术方案(技术选型及理由)
|
|
104
|
+
- 架构设计(系统架构图)
|
|
105
|
+
- 数据模型(数据结构定义)
|
|
106
|
+
- API 设计(接口定义)
|
|
107
|
+
- 文件结构(新增/修改的文件)
|
|
108
|
+
- 设计决策(重要决策及理由)
|
|
109
|
+
- 风险评估
|
|
110
|
+
|
|
111
|
+
**第六步:生成 research.md(技术调研)**
|
|
112
|
+
在 \`docs/specs/${featureSlug}/research.md\` 中记录:
|
|
113
|
+
- 技术栈调研结果
|
|
114
|
+
- 版本兼容性确认
|
|
115
|
+
- 潜在风险识别
|
|
116
|
+
- 最佳实践记录
|
|
117
|
+
- 参考文档链接
|
|
118
|
+
|
|
119
|
+
**第七步:生成 tasks.md(任务分解)**
|
|
120
|
+
在 \`docs/specs/${featureSlug}/tasks.md\` 中分解任务:
|
|
121
|
+
|
|
122
|
+
\`\`\`markdown
|
|
123
|
+
# 任务清单:${projectName}
|
|
124
|
+
|
|
125
|
+
## 概述
|
|
126
|
+
实现 ${projectName} 的任务分解。
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 任务列表
|
|
131
|
+
|
|
132
|
+
### 阶段 1: 项目初始化
|
|
133
|
+
- [ ] 1.1 搭建项目骨架
|
|
134
|
+
- 创建目录结构
|
|
135
|
+
- 初始化 package.json
|
|
136
|
+
- _需求: 1.1_
|
|
137
|
+
|
|
138
|
+
- [ ] 1.2 配置开发环境
|
|
139
|
+
- 配置 TypeScript/ESLint/Prettier
|
|
140
|
+
- _需求: 1.1_
|
|
141
|
+
|
|
142
|
+
### 阶段 2: 核心功能实现
|
|
143
|
+
- [ ] 2.1 实现数据模型
|
|
144
|
+
- 定义数据结构
|
|
145
|
+
- _需求: 2.1_
|
|
146
|
+
|
|
147
|
+
- [ ] 2.2 实现业务逻辑
|
|
148
|
+
- 核心功能开发
|
|
149
|
+
- 依赖: 任务 2.1
|
|
150
|
+
- _需求: 2.2_
|
|
151
|
+
|
|
152
|
+
### 阶段 3: 集成测试
|
|
153
|
+
- [ ] 3.1 编写测试用例
|
|
154
|
+
- 单元测试
|
|
155
|
+
- 集成测试
|
|
156
|
+
- _需求: 3.1_
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 检查点
|
|
161
|
+
- [ ] 阶段 1 完成后:项目可运行
|
|
162
|
+
- [ ] 阶段 2 完成后:核心功能可用
|
|
163
|
+
- [ ] 阶段 3 完成后:测试通过
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 文件变更清单
|
|
168
|
+
| 文件 | 操作 | 说明 |
|
|
169
|
+
|------|------|------|
|
|
170
|
+
| src/index.ts | 新建 | 入口文件 |
|
|
171
|
+
| package.json | 新建 | 项目配置 |
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
**标记说明**:
|
|
176
|
+
- [P]: 可以并行执行的任务
|
|
177
|
+
- 依赖: 必须在指定任务完成后才能开始
|
|
178
|
+
- _需求: x.x_: 关联的需求编号
|
|
179
|
+
\`\`\`
|
|
180
|
+
|
|
181
|
+
**第八步:生成辅助脚本**
|
|
182
|
+
创建项目管理脚本:
|
|
183
|
+
- \`scripts/check-prerequisites.sh\`: 检查环境依赖
|
|
184
|
+
- \`scripts/setup.sh\`: 自动化项目初始化
|
|
185
|
+
|
|
186
|
+
📝 **注意事项**:
|
|
187
|
+
1. 所有文档统一放在 \`docs/\` 目录下
|
|
188
|
+
2. 功能规格放在 \`docs/specs/{feature-name}/\` 目录
|
|
189
|
+
3. 所有文件使用 Markdown 格式,保持清晰的结构
|
|
190
|
+
4. 遵循项目 constitution 中定义的原则
|
|
191
|
+
5. 任务分解要足够细致,每个任务应该在 2-4 小时内完成
|
|
192
|
+
6. 标记清楚任务之间的依赖关系
|
|
193
|
+
7. 识别可以并行执行的任务以优化开发效率
|
|
194
|
+
|
|
195
|
+
🚀 **开始执行**:
|
|
184
196
|
现在请按照上述步骤创建项目结构和所有必需的文档。`;
|
|
185
197
|
// 创建结构化数据对象
|
|
186
198
|
const structuredData = {
|
|
@@ -2,6 +2,7 @@ import { parseArgs, getString, getNumber } from '../utils/parseArgs.js';
|
|
|
2
2
|
import { okStructured } from '../lib/response.js';
|
|
3
3
|
import { createMemoryClient } from '../lib/memory-client.js';
|
|
4
4
|
import { formatSearchMemoryResultsText, shouldShowSourceInSearch, } from '../lib/memory-orchestration.js';
|
|
5
|
+
import { attachHandles, buildMemoryAssetHandles } from '../lib/handles.js';
|
|
5
6
|
import { getMemoryConfig } from '../lib/memory-config.js';
|
|
6
7
|
import { handleToolError } from '../utils/error-handler.js';
|
|
7
8
|
export async function searchMemory(args) {
|
|
@@ -46,12 +47,14 @@ export async function searchMemory(args) {
|
|
|
46
47
|
tags: item.tags,
|
|
47
48
|
sourcePath: shouldShowSourceInSearch(item, config) ? item.sourcePath : undefined,
|
|
48
49
|
}));
|
|
49
|
-
return okStructured(formatSearchMemoryResultsText(results, config), {
|
|
50
|
+
return okStructured(formatSearchMemoryResultsText(results, config), attachHandles({
|
|
50
51
|
enabled: true,
|
|
51
52
|
query,
|
|
52
53
|
count: results.length,
|
|
53
54
|
results: items,
|
|
54
|
-
}
|
|
55
|
+
}, {
|
|
56
|
+
memory_assets: buildMemoryAssetHandles(items),
|
|
57
|
+
}));
|
|
55
58
|
}
|
|
56
59
|
catch (error) {
|
|
57
60
|
return handleToolError(error, 'search_memory');
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import { parseArgs, getString, getNumber } from "../utils/parseArgs.js";
|
|
3
3
|
import { okStructured } from "../lib/response.js";
|
|
4
|
+
import { attachHandles } from "../lib/handles.js";
|
|
4
5
|
import { renderOrchestrationHeader } from "../lib/orchestration-guidance.js";
|
|
5
6
|
import { BugFixReportSchema, RequirementsLoopSchema } from "../schemas/structured-output.js";
|
|
6
7
|
import { reportToolProgress, throwIfAborted, } from "../lib/tool-execution-context.js";
|
|
7
8
|
import { buildBugfixGraphContext } from "../lib/gitnexus-bridge.js";
|
|
8
|
-
import { buildMemoryPlanStep, loadMemoryInjectionContext, renderMemoryGuideSection, } from "../lib/memory-orchestration.js";
|
|
9
|
+
import { buildMemoryPlanStep, loadMemoryInjectionContext, renderMemoryGuideSection, buildOrchestrationHandles, } from "../lib/memory-orchestration.js";
|
|
9
10
|
import { resolveWorkspaceRoot, isLikelyProjectNamedRelativePath, buildProjectRootRetryHint } from "../lib/workspace-root.js";
|
|
10
11
|
import { layoutAbsPath, parseLayoutArgsFromRecord, resolveProjectContextLayout, } from "../lib/project-context-layout.js";
|
|
12
|
+
import { buildCheckSpecPlanStep, renderSpecGatePromptSection, resolveBugfixSpecGate, } from "../lib/spec-gate.js";
|
|
11
13
|
function decideTemplateProfile(description) {
|
|
12
14
|
const text = description || '';
|
|
13
15
|
const lengthScore = text.length >= 200 ? 2 : text.length >= 120 ? 1 : 0;
|
|
@@ -120,6 +122,8 @@ const PROMPT_TEMPLATE_GUIDED = `# 🐛 Bug 修复编排指南(TBP 8 步真因
|
|
|
120
122
|
|
|
121
123
|
**产出**: 测试代码
|
|
122
124
|
|
|
125
|
+
{spec_gate_section}
|
|
126
|
+
|
|
123
127
|
---
|
|
124
128
|
|
|
125
129
|
## ✅ 完成检查
|
|
@@ -177,6 +181,7 @@ const PROMPT_TEMPLATE_STRICT = `# 🐛 Bug 修复编排(严格 | TBP 8 步)
|
|
|
177
181
|
"framework": "[根据项目上下文选择: jest/vitest/mocha]"
|
|
178
182
|
}
|
|
179
183
|
\`\`\`
|
|
184
|
+
{spec_gate_section}
|
|
180
185
|
|
|
181
186
|
---
|
|
182
187
|
|
|
@@ -307,6 +312,8 @@ export async function startBugfix(args, context) {
|
|
|
307
312
|
stack_trace: ["stack", "trace", "堆栈", "调用栈"],
|
|
308
313
|
code_context: ["code_context", "code", "context", "相关代码", "代码上下文"],
|
|
309
314
|
project_root: ["projectRoot", "project_path", "projectPath", "root", "project_root", "项目路径", "项目根目录"],
|
|
315
|
+
docs_dir: ["dir", "output", "目录", "文档目录"],
|
|
316
|
+
feature_name: ["name", "feature", "spec", "功能名", "功能名称", "规格"],
|
|
310
317
|
analysis_mode: ["analysis_mode", "methodology", "rca", "tbp", "分析方法"],
|
|
311
318
|
template_profile: ["profile", "template_profile", "模板档位", "模板模式"],
|
|
312
319
|
requirements_mode: ["mode", "requirements_mode", "loop", "需求模式"],
|
|
@@ -320,6 +327,7 @@ export async function startBugfix(args, context) {
|
|
|
320
327
|
const codeContext = getString(parsedArgs.code_context);
|
|
321
328
|
const projectRoot = getString(parsedArgs.project_root);
|
|
322
329
|
const docsDir = getString(parsedArgs.docs_dir) || "docs";
|
|
330
|
+
const featureNameInput = getString(parsedArgs.feature_name);
|
|
323
331
|
if (isLikelyProjectNamedRelativePath(projectRoot)) {
|
|
324
332
|
return {
|
|
325
333
|
content: [{
|
|
@@ -388,6 +396,18 @@ export async function startBugfix(args, context) {
|
|
|
388
396
|
layoutManifest: layout.manifestPath,
|
|
389
397
|
};
|
|
390
398
|
const graphDocsMissing = !bootstrapState.latestMarkdownExists || !bootstrapState.latestJsonExists;
|
|
399
|
+
const specGate = resolveBugfixSpecGate({
|
|
400
|
+
featureName: featureNameInput,
|
|
401
|
+
projectRoot: layout.projectRoot,
|
|
402
|
+
docsDir,
|
|
403
|
+
hintText: combinedText,
|
|
404
|
+
});
|
|
405
|
+
const specGateSection = specGate ? renderSpecGatePromptSection(specGate) : '';
|
|
406
|
+
if (specGate) {
|
|
407
|
+
headerNotes.push(specGate.detected
|
|
408
|
+
? `规格闸门: 已自动关联 ${specGate.specDir}/,修复后需 check_spec`
|
|
409
|
+
: `规格闸门: 关联 ${specGate.specDir}/,修复后需 check_spec`);
|
|
410
|
+
}
|
|
391
411
|
const graphContext = await buildBugfixGraphContext({
|
|
392
412
|
errorMessage,
|
|
393
413
|
stackTrace,
|
|
@@ -571,7 +591,7 @@ ${graphContext.highlights.length > 0
|
|
|
571
591
|
},
|
|
572
592
|
};
|
|
573
593
|
await reportToolProgress(context, 95, "start_bugfix: loop 输出已生成");
|
|
574
|
-
return okStructured(guide, loopReport, {
|
|
594
|
+
return okStructured(guide, attachHandles(loopReport, buildOrchestrationHandles(memoryContext)), {
|
|
575
595
|
schema: RequirementsLoopSchema,
|
|
576
596
|
note: 'AI 应按轮次澄清 Bug 需求并更新结构化输出,满足结束条件后再进入 fix_bug / gentest',
|
|
577
597
|
});
|
|
@@ -598,7 +618,8 @@ ${graphContext.highlights.length > 0
|
|
|
598
618
|
.replace(/{error_message}/g, errorMessage)
|
|
599
619
|
.replace(/{stack_trace}/g, stackTrace)
|
|
600
620
|
.replace(/{analysis_mode}/g, analysisMode)
|
|
601
|
-
.replace(/{stack_trace_section}/g, stackTraceSection)
|
|
621
|
+
.replace(/{stack_trace_section}/g, stackTraceSection)
|
|
622
|
+
.replace(/{spec_gate_section}/g, specGateSection);
|
|
602
623
|
const guide = header + memoryGuideSection + renderedPrompt + graphGuideSection;
|
|
603
624
|
const plan = {
|
|
604
625
|
mode: 'delegated',
|
|
@@ -635,6 +656,7 @@ ${graphContext.highlights.length > 0
|
|
|
635
656
|
},
|
|
636
657
|
outputs: [],
|
|
637
658
|
},
|
|
659
|
+
...(specGate ? [buildCheckSpecPlanStep(specGate.featureName, specGate.docsDir)] : []),
|
|
638
660
|
...(memoryContext.enabled ? [buildMemoryPlanStep('bugfix')] : []),
|
|
639
661
|
],
|
|
640
662
|
};
|
|
@@ -659,6 +681,13 @@ ${graphContext.highlights.length > 0
|
|
|
659
681
|
status: 'pending',
|
|
660
682
|
description: '调用 gentest 工具生成测试用例',
|
|
661
683
|
},
|
|
684
|
+
...(specGate
|
|
685
|
+
? [{
|
|
686
|
+
name: '规格闸门校验',
|
|
687
|
+
status: 'pending',
|
|
688
|
+
description: `修复后调用 check_spec 校验 ${specGate.specDir}/`,
|
|
689
|
+
}]
|
|
690
|
+
: []),
|
|
662
691
|
],
|
|
663
692
|
artifacts: [],
|
|
664
693
|
nextSteps: [
|
|
@@ -670,6 +699,9 @@ ${graphContext.highlights.length > 0
|
|
|
670
699
|
'调用 fix_bug 工具分析问题并形成因果句真因',
|
|
671
700
|
'调用 gentest 工具生成回归测试',
|
|
672
701
|
'运行测试验证修复',
|
|
702
|
+
...(specGate
|
|
703
|
+
? [`修复后调用 check_spec 校验 ${specGate.specDir}/,未通过先补规格再重跑`]
|
|
704
|
+
: []),
|
|
673
705
|
],
|
|
674
706
|
rootCause: '待分析(需要调用 fix_bug 工具)',
|
|
675
707
|
fixPlan: '待制定(需要调用 fix_bug 工具)',
|
|
@@ -709,10 +741,11 @@ ${graphContext.highlights.length > 0
|
|
|
709
741
|
graphDocsMissing,
|
|
710
742
|
},
|
|
711
743
|
graphContext,
|
|
744
|
+
...(specGate ? { specGate } : {}),
|
|
712
745
|
},
|
|
713
746
|
};
|
|
714
747
|
await reportToolProgress(context, 95, "start_bugfix: 执行计划输出已生成");
|
|
715
|
-
return okStructured(guide, bugfixReport, {
|
|
748
|
+
return okStructured(guide, attachHandles(bugfixReport, buildOrchestrationHandles(memoryContext)), {
|
|
716
749
|
schema: BugFixReportSchema,
|
|
717
750
|
note: 'AI 应该按照指南执行步骤,并在每个步骤完成后更新 structuredContent 中的状态',
|
|
718
751
|
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import { parseArgs, getString, getNumber } from "../utils/parseArgs.js";
|
|
3
3
|
import { okStructured } from "../lib/response.js";
|
|
4
|
+
import { attachHandles } from "../lib/handles.js";
|
|
4
5
|
import { renderOrchestrationHeader } from "../lib/orchestration-guidance.js";
|
|
5
6
|
import { FeatureReportSchema, RequirementsLoopSchema } from "../schemas/structured-output.js";
|
|
6
7
|
import { reportToolProgress, throwIfAborted, } from "../lib/tool-execution-context.js";
|
|
7
8
|
import { buildFeatureGraphContext } from "../lib/gitnexus-bridge.js";
|
|
8
|
-
import { buildMemoryPlanStep, loadMemoryInjectionContext, renderMemoryGuideSection, } from "../lib/memory-orchestration.js";
|
|
9
|
+
import { buildMemoryPlanStep, loadMemoryInjectionContext, renderMemoryGuideSection, buildOrchestrationHandles, } from "../lib/memory-orchestration.js";
|
|
9
10
|
import { resolveWorkspaceRoot, toWorkspacePath, isLikelyProjectNamedRelativePath, buildProjectRootRetryHint } from "../lib/workspace-root.js";
|
|
10
11
|
import { layoutAbsPath, parseLayoutArgsFromRecord, resolveProjectContextLayout, } from "../lib/project-context-layout.js";
|
|
11
12
|
/**
|
|
@@ -463,7 +464,7 @@ ${graphContext.highlights.length > 0
|
|
|
463
464
|
},
|
|
464
465
|
};
|
|
465
466
|
await reportToolProgress(context, 95, "start_feature: loop 输出已生成");
|
|
466
|
-
return okStructured(guide, loopReport, {
|
|
467
|
+
return okStructured(guide, attachHandles(loopReport, buildOrchestrationHandles(memoryContext)), {
|
|
467
468
|
schema: RequirementsLoopSchema,
|
|
468
469
|
note: 'AI 应按轮次澄清需求并更新结构化输出,满足结束条件后再进入 add_feature / estimate',
|
|
469
470
|
});
|
|
@@ -595,7 +596,7 @@ ${graphContext.highlights.length > 0
|
|
|
595
596
|
},
|
|
596
597
|
};
|
|
597
598
|
await reportToolProgress(context, 95, "start_feature: 执行计划输出已生成");
|
|
598
|
-
return okStructured(guide, featureReport, {
|
|
599
|
+
return okStructured(guide, attachHandles(featureReport, buildOrchestrationHandles(memoryContext)), {
|
|
599
600
|
schema: FeatureReportSchema,
|
|
600
601
|
note: 'AI 应该按照指南执行步骤,并在每个步骤完成后更新 structuredContent 中的状态和估算信息',
|
|
601
602
|
});
|
package/build/tools/start_ui.js
CHANGED
|
@@ -10,13 +10,14 @@
|
|
|
10
10
|
import { parseArgs, getString, getNumber } from "../utils/parseArgs.js";
|
|
11
11
|
import { getReasoningEngine } from "./ui-ux-tools.js";
|
|
12
12
|
import { okStructured } from "../lib/response.js";
|
|
13
|
+
import { attachHandles } from "../lib/handles.js";
|
|
13
14
|
import { renderOrchestrationHeader } from "../lib/orchestration-guidance.js";
|
|
14
15
|
import { buildSkillBridgePlanStep, buildSkillHeaderNote, detectSkillBridge, renderSkillBridgeSection, } from "../lib/skill-bridge.js";
|
|
15
16
|
import { UIReportSchema, RequirementsLoopSchema } from "../schemas/structured-output.js";
|
|
16
17
|
import { detectProjectType } from "../lib/project-detector.js";
|
|
17
18
|
import { resolveWorkspaceRoot, isLikelyProjectNamedRelativePath, buildProjectRootRetryHint } from "../lib/workspace-root.js";
|
|
18
19
|
import { reportToolProgress, throwIfAborted, } from "../lib/tool-execution-context.js";
|
|
19
|
-
import { buildMemoryPlanStep, loadMemoryInjectionContext, renderMemoryGuideSection, } from "../lib/memory-orchestration.js";
|
|
20
|
+
import { buildMemoryPlanStep, loadMemoryInjectionContext, renderMemoryGuideSection, buildOrchestrationHandles, } from "../lib/memory-orchestration.js";
|
|
20
21
|
import { isShadcnStack } from "../lib/shadcn-ui.js";
|
|
21
22
|
import { renderUiHardRules, renderUiBannedList, renderPreFlightChecklist } from "../lib/quality-constraints.js";
|
|
22
23
|
/** 渲染代码步骤统一注入的 UI 硬约束 + 黑名单 + 交付前自检 */
|
|
@@ -782,7 +783,7 @@ start_ui <描述> --requirements_mode=loop
|
|
|
782
783
|
},
|
|
783
784
|
};
|
|
784
785
|
await reportToolProgress(context, 95, "start_ui: loop 输出已生成");
|
|
785
|
-
return okStructured(guide, loopReport, {
|
|
786
|
+
return okStructured(guide, attachHandles(loopReport, buildOrchestrationHandles(memoryContext)), {
|
|
786
787
|
schema: RequirementsLoopSchema,
|
|
787
788
|
note: 'AI 应按轮次澄清 UI 需求并更新结构化输出,满足结束条件后再执行 UI 计划',
|
|
788
789
|
});
|
|
@@ -1035,7 +1036,7 @@ ${recommendation.reasoning}
|
|
|
1035
1036
|
},
|
|
1036
1037
|
};
|
|
1037
1038
|
await reportToolProgress(context, 95, "start_ui: auto 输出已生成");
|
|
1038
|
-
return okStructured(smartPlan, uiReport, {
|
|
1039
|
+
return okStructured(smartPlan, attachHandles(uiReport, buildOrchestrationHandles(memoryContext)), {
|
|
1039
1040
|
schema: UIReportSchema,
|
|
1040
1041
|
note: 'AI 应该按照智能计划执行步骤,并在每个步骤完成后更新 structuredContent',
|
|
1041
1042
|
});
|
|
@@ -1238,7 +1239,7 @@ start_ui "设置页面" --framework=react
|
|
|
1238
1239
|
},
|
|
1239
1240
|
};
|
|
1240
1241
|
await reportToolProgress(context, 95, "start_ui: manual 输出已生成");
|
|
1241
|
-
return okStructured(guide, uiReport, {
|
|
1242
|
+
return okStructured(guide, attachHandles(uiReport, buildOrchestrationHandles(memoryContext)), {
|
|
1242
1243
|
schema: UIReportSchema,
|
|
1243
1244
|
note: 'AI 应该按照指南执行步骤,并在每个步骤完成后更新 structuredContent',
|
|
1244
1245
|
});
|