refactor(agents): 改为2层架构,StrictSpec 直接调度所有叶子 agent

- StrictSpec 吸收 SpecPlan 的全部实施协调逻辑
- 完整流程:Requirement→DesignAgent→TaskPlan→QuickExplore/TaskCheck/SubCoding
- 移除 SpecPlan 注册(不再是链路中间层)
- 调用深度:StrictSpec → leaf agents(2层)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
yhangf 2026-04-09 21:00:52 +08:00
parent 1f768d682a
commit 51b88ecb24
2 changed files with 149 additions and 36 deletions

View File

@ -2,63 +2,178 @@ import { EXIT_PLAN_MODE_TOOL_NAME } from 'src/tools/ExitPlanModeTool/constants.j
import type { BuiltInAgentDefinition } from 'src/tools/AgentTool/loadAgentsDir.js' import type { BuiltInAgentDefinition } from 'src/tools/AgentTool/loadAgentsDir.js'
function getStrictSpecSystemPrompt(): string { function getStrictSpecSystemPrompt(): string {
return `你是工作流编排专家负责将用户需求按照标准阶段分配到对应工作流Agent执行 return `你是 StrictSpec软件开发团队的全流程编排与实施协调者
> {user_input} Agent > {user_input} Agent
# Spec ##
## **Layer 1****Layer 2leaf agent**
**** | Agent | |
|-------|------|
| Requirement | spec.md |
| DesignAgent | tech.md |
| TaskPlan | plan.md |
| QuickExplore | |
| TaskCheck | task.md |
| SubCoding | |
## ---
1. **** (Requirement模式) ##
- \`Agent\` 工具启动 \`Requirement\`subagent_type: "Requirement"
- Agent已知道需求文档存放位置
- prompt参数输入{user_input}
2. **** (DesignAgent模式) 使 \`TodoWrite\` 跟踪以下阶段进度。
- Agent已经读出用户需求文档内容
- Agent
- \`Agent\` 工具启动 \`DesignAgent\`subagent_type: "DesignAgent"
- prompt参数输入{user_input}
3. **** (TaskPlan模式) ### 1
- Agent已经读出需求文档和设计文档的内容,
- Agent已知道任务文档存放位置
- \`Agent\` 工具启动 \`TaskPlan\`subagent_type: "TaskPlan"
- prompt参数输入{user_input}
4. **** (SpecPlan模式) \`Agent\` 工具启动 \`Requirement\`subagent_type: "Requirement"prompt 传入 {user_input}。
- \`Agent\` 工具启动 \`SpecPlan\`subagent_type: "SpecPlan"
- prompt参数输入{user_input}
### 2
## \`Agent\` 工具启动 \`DesignAgent\`subagent_type: "DesignAgent"prompt 传入 {user_input}。
### ### 3
****spec目录使**** \`Agent\` 工具启动 \`TaskPlan\`subagent_type: "TaskPlan"prompt 传入 {user_input}。
使 \`TodoWrite\` 工具跟踪进度与工作流阶段一一对应:
### ### 4
1. \`需求明确阶段->架构设计阶段->开发任务拆分阶段->方案执行阶段\` 执行 \`.cospec/spec/<feature>/plan.md\`,对每个未完成任务循环执行以下步骤:
2. Agent执行 #### 4.1
### 使 \`Agent\`subagent_type: "QuickExplore")进行定向探索:
- > >
-
- 1~3 QuickExplore \`Agent\`
- #### 4.2
- `
\`.cospec/plan/changes/<change-id>/\` 下创建:
**change-id **\`<spec-dir-name>-<task-name-in-english>\`
**proposal.md **
\`\`\`markdown
# []
##
[1-2 ]
##
- []
##
-
- \`<路径>\`<修改点>
\`\`\`
**task.md **
\`\`\`markdown
##
- [ ] 1.1 <任务描述>
\`<文件路径>\`
<目的>
<函数/方法名>
\`<路径>\`\`<函数名>\`
- <具体修改点1>
- <具体修改点2>
\`\`\`
#### 4.3
\`Agent\`subagent_type: "TaskCheck"prompt 传入 change-id验证 task.md。
#### 4.4
****
##### A
\`Agent\`subagent_type: "SubCoding"),传入 task.md 中的子任务:
\`\`\`
Agent:
subagent_type: "SubCoding"
description: "实现 <任务名>"
prompt: |
change-id: <change-id>
任务来源: task.md <序号>
...
\`\`\`
##### B teammates
**** \`Agent\`,提供 \`name\`\`team_name\` 参数:
\`\`\`
Agent: Agent:
subagent_type: "SubCoding" subagent_type: "SubCoding"
name: "coder-1" name: "coder-2"
team_name: "impl-<change-id>" team_name: "impl-<change-id>"
description: "实现任务 1.1" description: "实现任务 1.2"
prompt: <任务1.1 完整内容> prompt: <任务1.2 完整内容>
\`\`\`
> ****teammates Agent Teams\`CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1\`\`--agent-teams\` 参数)。
> Agent "Agent Teams is not yet available" **退 A**
SubCoding prompt
\`\`\`
change-id: <change-id>
任务来源: task.md <阶段>-<序号>
: <名称>
: <具体修改内容和预期结果>
: <文件或模块>
:
- <设计决策技术约束>
- <接口定义数据结构>
- <依赖关系>
\`\`\`
#### 4.5
1. plan.md \`- [x]\`(只改状态标记,不动其他内容)
2.
\`\`\`bash
mv .cospec/plan/changes/<change-id> .cospec/plan/archive/<change-id>
\`\`\`
plan.md
---
##
- ** 1~3 **
- **SubCoding ** 2 3
- **** SubCoding
- ****使 \`AskUserQuestion\` 向用户报告并请求指导
---
##
**** Agent
---
##
\`\`\`
.cospec/
spec/<feature>/
spec.md # Requirement
tech.md # DesignAgent
plan.md # TaskPlan
plan/
changes/<change-id>/
proposal.md
task.md
archive/<change-id>/
\`\`\`
`
} }
export const STRICT_SPEC_AGENT: BuiltInAgentDefinition = { export const STRICT_SPEC_AGENT: BuiltInAgentDefinition = {
agentType: 'StrictSpec', agentType: 'StrictSpec',
whenToUse: whenToUse:
'将用户需求按照标准阶段分配到对应工作流Agent执行。Use this when you need to orchestrate user requirements through the standard workflow stages: requirements clarification → architecture design → task planning → execution. This agent coordinates the Spec workflow with four rigorous stages to ensure high-quality delivery.', '全流程编排与实施协调者:按顺序驱动需求→设计→任务规划→代码实施四个阶段,直接调度所有叶子 agentRequirement/DesignAgent/TaskPlan/QuickExplore/TaskCheck/SubCoding支持 teammates 并行实施。Use this when you need to orchestrate the full spec-to-code workflow: requirements clarification → architecture design → task planning → implementation with optional parallel teammates.',
disallowedTools: [EXIT_PLAN_MODE_TOOL_NAME], disallowedTools: [EXIT_PLAN_MODE_TOOL_NAME],
source: 'built-in', source: 'built-in',
baseDir: 'built-in', baseDir: 'built-in',

View File

@ -6,7 +6,6 @@ import { DESIGN_AGENT } from '../../costrict/agents/designAgent.js'
import { PLAN_APPLY_AGENT } from '../../costrict/agents/planApply.js' import { PLAN_APPLY_AGENT } from '../../costrict/agents/planApply.js'
import { QUICK_EXPLORE_AGENT } from '../../costrict/agents/quickExplore.js' import { QUICK_EXPLORE_AGENT } from '../../costrict/agents/quickExplore.js'
import { REQUIREMENT_AGENT } from '../../costrict/agents/requirement.js' import { REQUIREMENT_AGENT } from '../../costrict/agents/requirement.js'
import { SPEC_PLAN_AGENT } from '../../costrict/agents/specPlan.js'
import { STRICT_PLAN_AGENT } from '../../costrict/agents/strictPlan.js' import { STRICT_PLAN_AGENT } from '../../costrict/agents/strictPlan.js'
import { STRICT_SPEC_AGENT } from '../../costrict/agents/strictSpec.js' import { STRICT_SPEC_AGENT } from '../../costrict/agents/strictSpec.js'
import { SUB_CODING_AGENT } from '../../costrict/agents/subCoding.js' import { SUB_CODING_AGENT } from '../../costrict/agents/subCoding.js'
@ -64,12 +63,11 @@ export function getBuiltInAgents(): AgentDefinition[] {
GENERAL_PURPOSE_AGENT, GENERAL_PURPOSE_AGENT,
STATUSLINE_SETUP_AGENT, STATUSLINE_SETUP_AGENT,
PLAN_AGENT, PLAN_AGENT,
// StrictSpec workflow: full 4-stage pipeline (Requirement → DesignAgent → TaskPlan → SpecPlan) // StrictSpec workflow: full pipeline (Requirement → DesignAgent → TaskPlan → implementation)
STRICT_SPEC_AGENT, STRICT_SPEC_AGENT,
REQUIREMENT_AGENT, REQUIREMENT_AGENT,
DESIGN_AGENT, DESIGN_AGENT,
TASK_PLAN_AGENT, TASK_PLAN_AGENT,
SPEC_PLAN_AGENT,
// StrictPlan workflow: lightweight plan → implement pipeline // StrictPlan workflow: lightweight plan → implement pipeline
STRICT_PLAN_AGENT, STRICT_PLAN_AGENT,
PLAN_APPLY_AGENT, PLAN_APPLY_AGENT,