explain_plan
Describes how a Tech Lead would allocate tasks for a given task description, offering insight into team role assignment and workflow organization.
Instructions
解释 Tech Lead 会如何分配任务(不实际执行)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task | Yes | 要分析的任务描述 |
Implementation Reference
- src/server.ts:289-302 (registration)Tool registration for 'explain_plan' in the ListToolsRequestSchema handler, defining its name, description, and inputSchema (requires 'task' string).
{ name: 'explain_plan', description: '解释 Tech Lead 会如何分配任务(不实际执行)', inputSchema: { type: 'object', properties: { task: { type: 'string', description: '要分析的任务描述', }, }, required: ['task'], }, }, - src/server.ts:683-718 (handler)Handler for 'explain_plan' tool. Calls TechLead.analyze(task) to get a task analysis without executing it, then formats the response as a markdown plan showing workflow type, expert assignments, and execution order.
case 'explain_plan': { const { task } = args as { task: string }; // 让 Tech Lead 分析任务但不执行 const analysis = await techLead.analyze(task); const expertPlan = analysis.experts .map((e: { id: string; name: string; tier: string; role: string }, i: number) => { const subtask = analysis.subtasks.find(t => t.expertId === e.id); return `${i + 1}. **${e.name}** (${e.tier})\n - 角色: ${e.role.slice(0, 100)}...\n - 任务: ${subtask?.description || '待分配'}`; }) .join('\n\n'); const plan = `# 🧠 任务执行计划 ## 任务分析 **原始任务**: ${task} ## Tech Lead 分析结果 ### 工作流类型 \`${analysis.workflow}\` ${analysis.workflow === 'sequential' ? '(顺序执行)' : analysis.workflow === 'parallel' ? '(并行执行)' : '(并行+审查)'} ### 专家分配 (${analysis.experts.length} 个) ${expertPlan} ### 执行顺序 ${analysis.workflow === 'parallel' ? '所有专家将并行执行任务' : analysis.experts.map((e: { name: string }, i: number) => `${i + 1}. ${e.name}`).join(' → ')} --- > 💡 这只是计划预览,使用 \`team_work\` 工具实际执行任务`; return { content: [{ type: 'text', text: plan }], }; } - src/agents/tech-lead.ts:159-173 (helper)TechLead.analyze() - the core AI-driven analysis method called by the explain_plan handler. Sends the task to an LLM with a system prompt asking it to dynamically create experts, decompose tasks, and choose a workflow.
async analyze(task: string, context?: string): Promise<TaskAnalysis> { // 构建消息 const userContent = context ? `用户需求:${task}\n\n额外上下文:${context}` : `用户需求:${task}`; const messages: ChatMessage[] = [ { role: 'system', content: SYSTEM_PROMPT }, { role: 'user', content: userContent }, ]; // 获取分析结果 const response = await this.adapter.chat(messages); return this.parseAnalysis(response); } - src/agents/tech-lead.ts:50-63 (schema)TaskAnalysis interface - the type definition for the analysis result returned by techLead.analyze(), including summary, experts, subtasks, workflow type, and needsReview flag.
export interface TaskAnalysis { /** 需求摘要 */ readonly summary: string; /** 动态生成的专家列表 */ readonly experts: readonly DynamicExpert[]; /** 子任务列表 */ readonly subtasks: readonly SubTask[]; /** 工作流类型 */ readonly workflow: WorkflowType; /** 是否需要最终审查 */ readonly needsReview: boolean; /** 额外说明 */ readonly notes?: string; }