intention-coding 0.3.8 → 0.4.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.
Files changed (51) hide show
  1. package/package.json +1 -1
  2. package/dist/db/file-storage.js +0 -638
  3. package/dist/index.js +0 -26
  4. package/dist/server/index.js +0 -88
  5. package/dist/services/bug-fix-agent/index.js +0 -320
  6. package/dist/services/change-summarizer/index.js +0 -123
  7. package/dist/services/change-summarizer/prompt/change-analysis.js +0 -56
  8. package/dist/services/code-generator/index.js +0 -403
  9. package/dist/services/code-generator/stages/execution-stage.js +0 -549
  10. package/dist/services/code-generator/stages/ideation-stage.js +0 -267
  11. package/dist/services/code-generator/stages/optimization-stage.js +0 -334
  12. package/dist/services/code-generator/stages/planning-stage.js +0 -295
  13. package/dist/services/code-generator/stages/research-stage.js +0 -283
  14. package/dist/services/code-generator/stages/review-stage.js +0 -270
  15. package/dist/services/code-generator/types.js +0 -37
  16. package/dist/services/code-generator/utils/instruction-executor.js +0 -207
  17. package/dist/services/code-generator/workflow-manager.js +0 -252
  18. package/dist/services/image-analysis/analyzer.js +0 -530
  19. package/dist/services/image-analysis/index.js +0 -406
  20. package/dist/services/image-analysis/types.js +0 -46
  21. package/dist/services/image-converter/converter.js +0 -310
  22. package/dist/services/image-converter/index.js +0 -262
  23. package/dist/services/image-converter/types.js +0 -31
  24. package/dist/services/integrated-generator/index.js +0 -1297
  25. package/dist/services/pdf2md/index.js +0 -180
  26. package/dist/services/project-template/index.js +0 -83
  27. package/dist/services/project-template/prompt/project-rules.js +0 -98
  28. package/dist/services/requirement-analyzer/chunk-reader.js +0 -218
  29. package/dist/services/requirement-analyzer/core/document-generator.js +0 -254
  30. package/dist/services/requirement-analyzer/core/intelligent-analyzer.js +0 -169
  31. package/dist/services/requirement-analyzer/core/project-analyzer.js +0 -199
  32. package/dist/services/requirement-analyzer/core/requirement-analyzer-service.js +0 -191
  33. package/dist/services/requirement-analyzer/core/template-selector.js +0 -124
  34. package/dist/services/requirement-analyzer/core/types.js +0 -23
  35. package/dist/services/requirement-analyzer/index.js +0 -177
  36. package/dist/services/requirement-analyzer/prompt/api-template.js +0 -302
  37. package/dist/services/requirement-analyzer/prompt/app-template.js +0 -455
  38. package/dist/services/requirement-analyzer/prompt/intelligent-requirement-analysis.js +0 -92
  39. package/dist/services/requirement-analyzer/prompt/pc-page-template.js +0 -582
  40. package/dist/services/requirement-analyzer/prompt/requirement-analysis.js +0 -664
  41. package/dist/services/requirement-analyzer/prompt/sdk-template.js +0 -582
  42. package/dist/services/requirement-analyzer/utils/file-reader.js +0 -169
  43. package/dist/services/world2md/index.js +0 -157
  44. package/dist/types/index.js +0 -2
  45. package/dist/utils/common.js +0 -72
  46. package/dist/utils/config.js +0 -163
  47. package/dist/utils/context-manager.js +0 -114
  48. package/dist/utils/dify.js +0 -243
  49. package/dist/utils/logger.js +0 -129
  50. package/dist/utils/openai.js +0 -225
  51. package/dist/utils/pack.js +0 -75
@@ -1,295 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PlanningStage = void 0;
13
- const logger_1 = require("../../../utils/logger");
14
- const openai_1 = require("../../../utils/openai");
15
- const types_1 = require("../types");
16
- /**
17
- * 计划阶段处理器
18
- * 职责:将选定方案细化为详尽、有序、可执行的步骤清单
19
- */
20
- class PlanningStage {
21
- /**
22
- * 执行计划阶段
23
- */
24
- execute(task, input) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- try {
27
- logger_1.logger.info('开始执行计划阶段', { taskId: task.id });
28
- // 获取选定的方案
29
- const selectedSolution = this.getSelectedSolution(task, input);
30
- // 生成执行计划
31
- const executionPlan = yield this.generateExecutionPlan(task, selectedSolution);
32
- // 生成响应
33
- const response = this.generateResponse(executionPlan);
34
- logger_1.logger.info('计划阶段执行完成', {
35
- taskId: task.id,
36
- stepCount: executionPlan.steps.length
37
- });
38
- return response;
39
- }
40
- catch (error) {
41
- logger_1.logger.error('计划阶段执行失败', { error, taskId: task.id });
42
- throw new types_1.CodeGeneratorError('执行计划生成失败,请检查选定的方案', types_1.ErrorCodes.PLAN_CREATION_FAILED, types_1.WorkflowStage.PLANNING, { taskId: task.id, originalError: error });
43
- }
44
- });
45
- }
46
- /**
47
- * 获取选定的方案
48
- */
49
- getSelectedSolution(task, input) {
50
- var _a;
51
- // 从之前的构思阶段获取方案
52
- const ideationStage = task.stages.find(s => s.stage === types_1.WorkflowStage.IDEATION);
53
- if (!((_a = ideationStage === null || ideationStage === void 0 ? void 0 : ideationStage.output) === null || _a === void 0 ? void 0 : _a.solutions)) {
54
- throw new Error('未找到可用的解决方案');
55
- }
56
- const solutions = ideationStage.output.solutions;
57
- // 如果用户指定了方案ID,使用指定的方案
58
- if (input === null || input === void 0 ? void 0 : input.solutionId) {
59
- const selected = solutions.find((s) => s.id === input.solutionId);
60
- if (!selected) {
61
- throw new Error(`未找到指定的方案: ${input.solutionId}`);
62
- }
63
- return selected;
64
- }
65
- // 否则使用评分最高的方案
66
- return solutions[0];
67
- }
68
- /**
69
- * 生成执行计划
70
- */
71
- generateExecutionPlan(task, solution) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- const { taskDescription, projectInfo } = task.context;
74
- const prompt = `你是一位资深的项目经理,请为以下解决方案制定详细的执行计划。
75
-
76
- ## 任务描述
77
- ${taskDescription}
78
-
79
- ## 选定方案
80
- **方案名称**: ${solution.name}
81
- **方案描述**: ${solution.description}
82
- **技术要求**: ${solution.techRequirements.join(', ')}
83
- **复杂度**: ${solution.complexity}
84
- **预估时间**: ${solution.estimatedTime}
85
-
86
- ## 项目信息
87
- ${projectInfo ? `
88
- - 技术栈:${projectInfo.techStack.join(', ')}
89
- - 框架:${projectInfo.frameworks.join(', ')}
90
- - 语言:${projectInfo.language}
91
- ` : '- 通用项目'}
92
-
93
- 请将方案分解为原子的、可执行的步骤,每个步骤应该包含:
94
- 1. 明确的步骤名称和描述
95
- 2. 具体的目标文件和操作
96
- 3. 原子操作列表(文件创建、函数实现等)
97
- 4. 预期结果
98
- 5. 依赖关系
99
- 6. 时间估算
100
-
101
- 重要:生成的步骤将被转换为 MCP 客户端可执行的指令,请确保:
102
- - 文件路径准确且相对于项目根目录
103
- - 内容具体可执行,避免抽象描述
104
- - 依赖关系清晰,便于按序执行
105
-
106
- 请以JSON格式返回:
107
- {
108
- "id": "plan_id",
109
- "solutionId": "${solution.id}",
110
- "estimatedDuration": "总体时间估算",
111
- "dependencies": ["依赖1", "依赖2"],
112
- "riskAssessment": "风险评估",
113
- "rollbackPlan": "回滚计划",
114
- "steps": [
115
- {
116
- "id": "step_1",
117
- "name": "步骤名称",
118
- "description": "详细描述",
119
- "type": "file_creation|file_modification|function_implementation|class_implementation|test_creation|configuration",
120
- "targetFiles": ["文件路径1", "文件路径2"],
121
- "atomicOperations": [
122
- {
123
- "type": "create_file|modify_file|create_function|create_class|add_import|install_dependency",
124
- "target": "目标文件或函数名",
125
- "content": "具体的文件内容或代码",
126
- "parameters": {"key": "value"}
127
- }
128
- ],
129
- "expectedResult": "预期结果",
130
- "dependencies": ["依赖步骤ID"],
131
- "estimatedTime": "时间估算"
132
- }
133
- ]
134
- }`;
135
- try {
136
- const result = yield openai_1.openAIService.generateText({
137
- prompt,
138
- system_prompt: "你是专业的项目经理,请严格按照JSON格式返回执行计划。"
139
- });
140
- const jsonMatch = result.match(/\{[\s\S]*\}/);
141
- if (jsonMatch) {
142
- try {
143
- const plan = JSON.parse(jsonMatch[0]);
144
- return Object.assign(Object.assign({}, plan), { id: plan.id || `plan_${Date.now()}`, solutionId: solution.id });
145
- }
146
- catch (parseError) {
147
- logger_1.logger.error('JSON解析失败', {
148
- error: parseError,
149
- jsonString: jsonMatch[0].substring(0, 200) + '...'
150
- });
151
- throw new Error('AI返回的JSON格式无效');
152
- }
153
- }
154
- throw new Error('无法从AI响应中提取JSON');
155
- }
156
- catch (error) {
157
- logger_1.logger.error('执行计划生成失败', { error });
158
- // 返回默认计划
159
- return this.getDefaultExecutionPlan(solution, task);
160
- }
161
- });
162
- }
163
- /**
164
- * 生成响应
165
- */
166
- generateResponse(executionPlan) {
167
- return {
168
- stage: types_1.WorkflowStage.PLANNING,
169
- status: 'pending_approval',
170
- message: this.formatPlanMessage(executionPlan),
171
- data: { executionPlan },
172
- nextActions: ['批准计划开始执行', '修改计划', '重新规划'],
173
- requiresUserConfirmation: true
174
- };
175
- }
176
- /**
177
- * 格式化计划消息
178
- */
179
- formatPlanMessage(plan) {
180
- const stepsText = plan.steps.map((step, index) => `
181
- ### 步骤 ${index + 1}:${step.name}
182
-
183
- **描述**:${step.description}
184
- **类型**:${this.getStepTypeLabel(step.type)}
185
- **目标文件**:${step.targetFiles.join(', ')}
186
- **预期结果**:${step.expectedResult}
187
- **预估时间**:${step.estimatedTime}
188
- **依赖**:${step.dependencies.length > 0 ? step.dependencies.join(', ') : '无'}
189
-
190
- **原子操作**:
191
- ${step.atomicOperations.map(op => `- ${this.getOperationLabel(op.type)}: ${op.target}`).join('\n')}
192
- `).join('\n---\n');
193
- return `
194
- # [模式:计划] 执行计划制定完成 📋
195
-
196
- ## 📊 计划概览
197
-
198
- **方案ID**:${plan.solutionId}
199
- **总体时间**:${plan.estimatedDuration}
200
- **步骤数量**:${plan.steps.length}个
201
-
202
- ## 🔍 风险评估
203
-
204
- ${plan.riskAssessment}
205
-
206
- ## 📝 详细步骤
207
-
208
- ${stepsText}
209
-
210
- ## 🔄 回滚计划
211
-
212
- ${plan.rollbackPlan}
213
-
214
- ## ⚠️ 重要提醒
215
-
216
- - 执行前将在项目根目录 \`.claude/plan/\` 中保存计划文档
217
- - 关键步骤完成后会请求您的反馈
218
- - 如需修改计划,请在批准前提出
219
-
220
- **请确认是否批准此执行计划?批准后将开始代码实施阶段。**
221
- `.trim();
222
- }
223
- /**
224
- * 获取默认执行计划
225
- */
226
- getDefaultExecutionPlan(solution, task) {
227
- return {
228
- id: `plan_${Date.now()}`,
229
- solutionId: solution.id,
230
- estimatedDuration: solution.estimatedTime,
231
- dependencies: solution.techRequirements,
232
- riskAssessment: `基于${solution.complexity}复杂度和${solution.riskLevel}风险等级的标准评估`,
233
- rollbackPlan: '如遇问题,可回滚到当前代码状态,删除新增文件',
234
- steps: [
235
- {
236
- id: 'step_1',
237
- name: '环境准备',
238
- description: '检查和准备开发环境',
239
- type: 'configuration',
240
- targetFiles: ['package.json', 'tsconfig.json'],
241
- atomicOperations: [
242
- {
243
- type: 'install_dependency',
244
- target: 'dependencies',
245
- content: solution.techRequirements.join(', ')
246
- }
247
- ],
248
- expectedResult: '开发环境就绪',
249
- dependencies: [],
250
- estimatedTime: '30分钟'
251
- },
252
- {
253
- id: 'step_2',
254
- name: '核心功能实现',
255
- description: solution.description,
256
- type: 'function_implementation',
257
- targetFiles: ['src/main.ts'],
258
- atomicOperations: [
259
- {
260
- type: 'create_function',
261
- target: 'main function',
262
- content: '核心业务逻辑'
263
- }
264
- ],
265
- expectedResult: '核心功能完成',
266
- dependencies: ['step_1'],
267
- estimatedTime: '2-3小时'
268
- }
269
- ]
270
- };
271
- }
272
- getStepTypeLabel(type) {
273
- const labels = {
274
- 'file_creation': '📄 文件创建',
275
- 'file_modification': '✏️ 文件修改',
276
- 'function_implementation': '⚡ 函数实现',
277
- 'class_implementation': '🏗️ 类实现',
278
- 'test_creation': '🧪 测试创建',
279
- 'configuration': '⚙️ 配置设置'
280
- };
281
- return labels[type] || type;
282
- }
283
- getOperationLabel(type) {
284
- const labels = {
285
- 'create_file': '创建文件',
286
- 'modify_file': '修改文件',
287
- 'create_function': '创建函数',
288
- 'create_class': '创建类',
289
- 'add_import': '添加导入',
290
- 'install_dependency': '安装依赖'
291
- };
292
- return labels[type] || type;
293
- }
294
- }
295
- exports.PlanningStage = PlanningStage;
@@ -1,283 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.ResearchStage = void 0;
46
- const logger_1 = require("../../../utils/logger");
47
- const openai_1 = require("../../../utils/openai");
48
- const pack_1 = require("../../../utils/pack");
49
- const types_1 = require("../types");
50
- /**
51
- * 研究阶段处理器
52
- * 职责:理解需求并评估完整性,收集项目上下文
53
- */
54
- class ResearchStage {
55
- /**
56
- * 执行研究阶段
57
- */
58
- execute(task, _input) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- try {
61
- logger_1.logger.info('开始执行研究阶段', { taskId: task.id });
62
- // 1. 分析项目信息
63
- const projectInfo = yield this.analyzeProject();
64
- task.context.projectInfo = projectInfo;
65
- // 2. 分析需求完整性
66
- const requirements = yield this.analyzeRequirements(task.description, projectInfo);
67
- task.context.requirements = requirements;
68
- // 3. 生成响应
69
- const response = this.generateResponse(requirements, projectInfo);
70
- logger_1.logger.info('研究阶段执行完成', {
71
- taskId: task.id,
72
- completenessScore: requirements.completenessScore,
73
- needsClarification: requirements.completenessScore < 7
74
- });
75
- return response;
76
- }
77
- catch (error) {
78
- logger_1.logger.error('研究阶段执行失败', { error, taskId: task.id });
79
- throw new types_1.CodeGeneratorError('需求分析过程中发生错误,请检查任务描述', types_1.ErrorCodes.INCOMPLETE_REQUIREMENTS, types_1.WorkflowStage.RESEARCH, { taskId: task.id, originalError: error });
80
- }
81
- });
82
- }
83
- /**
84
- * 分析项目信息
85
- */
86
- analyzeProject() {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- try {
89
- logger_1.logger.info('开始分析项目信息');
90
- const projectAnalysisPath = yield (0, pack_1.packProject)();
91
- const fs = yield Promise.resolve().then(() => __importStar(require('fs/promises')));
92
- const projectAnalysisContent = yield fs.readFile(projectAnalysisPath, 'utf8');
93
- // 解析项目信息
94
- const projectInfo = this.parseProjectInfo(projectAnalysisContent);
95
- logger_1.logger.info('项目信息分析完成', { projectInfo });
96
- return projectInfo;
97
- }
98
- catch (error) {
99
- logger_1.logger.warn('项目信息分析失败,使用默认配置', { error });
100
- return undefined;
101
- }
102
- });
103
- }
104
- /**
105
- * 解析项目信息
106
- */
107
- parseProjectInfo(content) {
108
- // 提取技术栈
109
- const techStackMatch = content.match(/技术栈[::]\s*([^\n]+)/);
110
- const techStack = techStackMatch ? techStackMatch[1].split(/[,,、]/).map(s => s.trim()) : [];
111
- // 提取框架
112
- const frameworkMatch = content.match(/框架[::]\s*([^\n]+)/);
113
- const frameworks = frameworkMatch ? frameworkMatch[1].split(/[,,、]/).map(s => s.trim()) : [];
114
- // 提取编程语言
115
- const languageMatch = content.match(/语言[::]\s*([^\n]+)/);
116
- const language = languageMatch ? languageMatch[1].trim() : '';
117
- return {
118
- name: 'current-project',
119
- path: process.cwd(),
120
- techStack,
121
- frameworks,
122
- language,
123
- structure: {},
124
- devCommands: []
125
- };
126
- }
127
- /**
128
- * 分析需求完整性
129
- */
130
- analyzeRequirements(taskDescription, projectInfo) {
131
- return __awaiter(this, void 0, void 0, function* () {
132
- const prompt = `你是一位专业的需求分析师,请分析以下任务描述的完整性。
133
-
134
- 任务描述:${taskDescription}
135
-
136
- ${projectInfo ? `项目信息:
137
- - 技术栈:${projectInfo.techStack.join(', ')}
138
- - 框架:${projectInfo.frameworks.join(', ')}
139
- - 语言:${projectInfo.language}` : ''}
140
-
141
- 请按照以下维度评分(总分10分):
142
- 1. 目标明确性(0-3分):任务目标是否清晰具体,要解决什么问题
143
- 2. 预期结果(0-3分):成功标准和交付物是否明确定义
144
- 3. 边界范围(0-2分):任务范围和边界是否清楚
145
- 4. 约束条件(0-2分):时间、性能、业务限制等是否说明
146
-
147
- 请以JSON格式返回分析结果:
148
- {
149
- "targetClarity": 数字,
150
- "expectedResults": 数字,
151
- "scopeBoundary": 数字,
152
- "constraints": 数字,
153
- "completenessScore": 总分,
154
- "missingInfo": ["缺失信息1", "缺失信息2"],
155
- "clarificationQuestions": ["问题1", "问题2"]
156
- }`;
157
- try {
158
- const result = yield openai_1.openAIService.generateText({
159
- prompt,
160
- system_prompt: "你是专业的需求分析师,请严格按照JSON格式返回分析结果。"
161
- });
162
- const jsonMatch = result.match(/\{[\s\S]*\}/);
163
- if (jsonMatch) {
164
- const analysis = JSON.parse(jsonMatch[0]);
165
- return {
166
- completenessScore: analysis.completenessScore,
167
- targetClarity: analysis.targetClarity,
168
- expectedResults: analysis.expectedResults,
169
- scopeBoundary: analysis.scopeBoundary,
170
- constraints: analysis.constraints,
171
- missingInfo: analysis.missingInfo || [],
172
- clarificationQuestions: analysis.clarificationQuestions || []
173
- };
174
- }
175
- throw new Error('无法解析AI分析结果');
176
- }
177
- catch (error) {
178
- logger_1.logger.error('需求分析失败', { error });
179
- // 返回默认的低分分析
180
- return {
181
- completenessScore: 3,
182
- targetClarity: 1,
183
- expectedResults: 1,
184
- scopeBoundary: 1,
185
- constraints: 0,
186
- missingInfo: ['任务目标不够明确', '缺少成功标准', '范围边界不清晰'],
187
- clarificationQuestions: [
188
- '请详细描述您要实现的具体功能或解决的问题?',
189
- '期望的最终结果是什么?如何判断任务成功完成?',
190
- '有什么时间、性能或业务限制需要考虑?'
191
- ]
192
- };
193
- }
194
- });
195
- }
196
- /**
197
- * 生成响应
198
- */
199
- generateResponse(requirements, projectInfo) {
200
- const { completenessScore, clarificationQuestions } = requirements;
201
- if (completenessScore < 7) {
202
- // 需要补充信息
203
- return {
204
- stage: types_1.WorkflowStage.RESEARCH,
205
- status: 'needs_clarification',
206
- message: this.formatClarificationMessage(requirements),
207
- data: { requirements, projectInfo },
208
- nextActions: ['补充需求信息', '重新评估需求'],
209
- requiresUserConfirmation: true,
210
- clarificationQuestions
211
- };
212
- }
213
- else {
214
- // 需求完整,可以继续
215
- return {
216
- stage: types_1.WorkflowStage.RESEARCH,
217
- status: 'success',
218
- message: this.formatSuccessMessage(requirements, projectInfo),
219
- data: { requirements, projectInfo },
220
- nextActions: ['进入构思阶段', '重新分析需求'],
221
- requiresUserConfirmation: true
222
- };
223
- }
224
- }
225
- /**
226
- * 格式化需要澄清的消息
227
- */
228
- formatClarificationMessage(requirements) {
229
- return `
230
- # [模式:研究] 需求分析结果
231
-
232
- ## 📊 需求完整性评分:${requirements.completenessScore}/10
233
-
234
- ### 评分详情:
235
- - **目标明确性**:${requirements.targetClarity}/3分
236
- - **预期结果**:${requirements.expectedResults}/3分
237
- - **边界范围**:${requirements.scopeBoundary}/2分
238
- - **约束条件**:${requirements.constraints}/2分
239
-
240
- ## ⚠️ 需要补充信息
241
-
242
- 评分低于7分,需要补充关键信息才能继续:
243
-
244
- ### 缺失信息:
245
- ${requirements.missingInfo.map(info => `- ${info}`).join('\n')}
246
-
247
- ### 需要澄清的问题:
248
- ${requirements.clarificationQuestions.map((q, i) => `${i + 1}. ${q}`).join('\n')}
249
-
250
- **请补充上述信息后,我将重新评估需求完整性。**
251
- `.trim();
252
- }
253
- /**
254
- * 格式化成功消息
255
- */
256
- formatSuccessMessage(requirements, projectInfo) {
257
- return `
258
- # [模式:研究] 需求分析完成 ✅
259
-
260
- ## 📊 需求完整性评分:${requirements.completenessScore}/10
261
-
262
- ### 评分详情:
263
- - **目标明确性**:${requirements.targetClarity}/3分
264
- - **预期结果**:${requirements.expectedResults}/3分
265
- - **边界范围**:${requirements.scopeBoundary}/2分
266
- - **约束条件**:${requirements.constraints}/2分
267
-
268
- ## 🏗️ 项目信息:
269
- ${projectInfo ? `
270
- - **技术栈**:${projectInfo.techStack.join(', ') || '待确定'}
271
- - **框架**:${projectInfo.frameworks.join(', ') || '待确定'}
272
- - **语言**:${projectInfo.language || '待确定'}
273
- ` : '- 项目信息获取中...'}
274
-
275
- ## ✅ 需求分析通过
276
-
277
- 需求完整性评分达到${requirements.completenessScore}分,可以进入下一阶段。
278
-
279
- **准备进入构思阶段,生成解决方案...**
280
- `.trim();
281
- }
282
- }
283
- exports.ResearchStage = ResearchStage;