make_plan
Generate a feasible execution plan from clarified task requirements after all checks pass. The plan is ready for user confirmation.
Instructions
【生成计划】在需求已澄清(check_requirements 全部 ✅)后,生成可行执行计划,等待用户确认。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskDescription | Yes | 已澄清的任务需求描述 |
Implementation Reference
- src/index.ts:347-375 (handler)The handleMakePlan method is the handler for the make_plan tool. It extracts taskDescription from args, validates it's provided, checks requirements clarity via checkRequirements(), and if clear, generates and formats a plan via generatePlan()/formatPlan(). Returns an error if requirements are not all clear.
private async handleMakePlan(args: any) { const taskDescription = typeof args?.taskDescription === 'string' ? args.taskDescription : ''; if (!taskDescription) { return { content: [{ type: 'text', text: '❌ 请提供任务需求描述。' }], isError: true, }; } // 先检查需求是否明确 const checkResult = checkRequirements(taskDescription); if (!checkResult.allClear) { return { content: [{ type: 'text', text: `❌ **需求尚未完全明确,无法生成计划。**\n\n以下项目不明确: ${checkResult.unclearItems.join('、')}\n\n请先使用 \`check_requirements\` 工具追问澄清,待所有 5 项标准都 ✅ 后再生成计划。`, }], isError: true, }; } const plan = generatePlan(taskDescription, checkResult); const formatted = formatPlan(plan); return { content: [{ type: 'text', text: formatted }], }; } - src/index.ts:123-136 (schema)The input schema registration for the make_plan tool. It defines a 'taskDescription' string property (required) as the sole input parameter, with a description indicating it should be the clarified task requirement.
{ name: 'make_plan', description: '【生成计划】在需求已澄清(check_requirements 全部 ✅)后,生成可行执行计划,等待用户确认。', inputSchema: { type: 'object', properties: { taskDescription: { type: 'string', description: '已澄清的任务需求描述', }, }, required: ['taskDescription'], }, }, - src/index.ts:244-245 (registration)The tool dispatch/case statement in CallToolRequestSchema handler that routes 'make_plan' requests to handleMakePlan().
case 'make_plan': return this.handleMakePlan(args); - src/requirements-check.ts:208-299 (helper)The generatePlan() function that creates a Plan object with steps derived from the task description keywords (backend, frontend, database, config, docs, tests, logging). Core plan generation logic.
export function generatePlan( taskDescription: string, checkResult: ClarityCheckResult ): Plan { const desc = taskDescription.toLowerCase(); const steps: PlanStep[] = []; let order = 1; // Step 1: 需求分析 steps.push({ order: order++, action: '需求分析与设计', details: '根据明确的需求,分析技术方案和实现路径', estimatedFiles: [], }); // 检测是否涉及后端 if (/后端|api|接口|数据库|service|controller|java|spring|auth|login|register/i.test(desc)) { steps.push({ order: order++, action: '后端实现', details: '实现后端接口、业务逻辑、数据持久化', estimatedFiles: ['backend/src/**'], }); } // 检测是否涉及前端 if (/前端|页面|组件|ui|vue|react|界面|样式|交互/i.test(desc)) { steps.push({ order: order++, action: '前端实现', details: '实现前端页面、组件、交互逻辑', estimatedFiles: ['frontend/src/**'], }); } // 检测是否涉及数据库 if (/数据库|表|sql|mysql|migration|entity/i.test(desc)) { steps.push({ order: order++, action: '数据库变更', details: '创建/修改数据库表结构、迁移脚本', estimatedFiles: ['backend/sql/**', 'backend/src/main/**/model/**'], }); } // 检测是否涉及配置 if (/配置|config|yml|properties|环境/i.test(desc)) { steps.push({ order: order++, action: '配置更新', details: '更新配置文件和环境变量', estimatedFiles: ['backend/src/main/resources/**'], }); } // 文档更新 steps.push({ order: order++, action: '文档同步', details: '更新对应模块的 docs 文档和模块记录', estimatedFiles: ['docs/**', '.github/prompts/modules/**'], }); // 测试 steps.push({ order: order++, action: '测试验证', details: '编写/更新测试用例,验证功能正确性', estimatedFiles: ['**/*Test.*', '**/*.spec.*'], }); // 日志记录 steps.push({ order: order++, action: '日志记录', details: '记录本次对话日志(daily + recent-5 + summary-10 + 模块记录)', estimatedFiles: ['.github/prompts/**'], }); return { title: `执行计划: ${taskDescription.slice(0, 50)}${taskDescription.length > 50 ? '...' : ''}`, description: taskDescription, steps, risks: [ '需求变更可能导致计划调整', '依赖外部服务时可能受限于可用性', ], pendingConfirmation: true, }; } - src/requirements-check.ts:304-349 (helper)The formatPlan() function that formats a Plan object into a human-readable markdown string with title, steps, risks, and confirmation prompt.
export function formatPlan(plan: Plan): string { const lines: string[] = []; lines.push('# 📋 执行计划'); lines.push(''); lines.push(`## ${plan.title}`); lines.push(''); lines.push(`**需求描述**: ${plan.description}`); lines.push(''); lines.push('## 执行步骤'); lines.push(''); for (const step of plan.steps) { lines.push(`### Step ${step.order}: ${step.action}`); lines.push(''); lines.push(step.details); if (step.estimatedFiles.length > 0) { lines.push(''); lines.push('预计涉及文件:'); for (const f of step.estimatedFiles) { lines.push(`- \`${f}\``); } } lines.push(''); } if (plan.risks.length > 0) { lines.push('## 风险提示'); lines.push(''); for (const risk of plan.risks) { lines.push(`- ⚠️ ${risk}`); } lines.push(''); } lines.push('---'); lines.push(''); lines.push('🟡 **此计划等待你的确认。**'); lines.push(''); lines.push('请确认:'); lines.push('1. 这个计划是否符合你的预期?'); lines.push('2. 是否有需要调整的步骤?'); lines.push('3. 确认后我将开始执行。'); return lines.join('\n'); }