refactor(agents): 清理 StrictSpec 架构,删除 PlanManager

- StrictSpec 精简为纯4阶段分发器(~40行),只负责编排,不含实施细节
- SpecPlan 成为唯一实施协调逻辑来源(探索→提案→验证→实施→收尾)
- 删除 planManager.ts 文件
- builtInAgents.ts 去除重复注册、移除 PLAN_MANAGER_AGENT

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
yhangf 2026-04-10 09:23:19 +08:00
parent bb1e88ea82
commit 7ee0b3a6a2
3 changed files with 28 additions and 302 deletions

View File

@ -1,133 +0,0 @@
import { EXIT_PLAN_MODE_TOOL_NAME } from 'src/tools/ExitPlanModeTool/constants.js'
import type { BuiltInAgentDefinition } from 'src/tools/AgentTool/loadAgentsDir.js'
function getPlanManagerSystemPrompt(): string {
return `# PlanManager - 开发任务管理与协调
PlanManager
1. plan.md
2. SpecPlan "分发任务"
3. SpecPlan
4. plan.md
SpecPlan plan.md
##
###
#### plan.md
- **** plan.md
- **** \`- [x]\`
- **** plan.md
- ****
###
SpecPlan
-
- /
-
###
1 SpecPlan SpecPlan
- **** 1 SpecPlan
- ****
-
-
-
-
-
-
#### change-id
SpecPlan change-idplan.md
- **** \`.cospec/spec/<id>\` 中的 \`<id>\` 与任务名称(英文形式)用连字符合并
- ****
- cospec \`user-authentication\`,任务名为"登录接口实现" → change-id: \`user-authentication-login-api\`
- cospec \`file-upload\`,任务名为"文件校验逻辑" → change-id: \`file-upload-validation\`
#### prompt
使 \`Agent\` 工具subagent_type: "SpecPlan")创建 SpecPlan 时,使用以下模板:
\`\`\`
change-id: <change-id>
任务来源: plan.md <阶段名> - <任务序号>
: <任务名称>
: <具体修改内容和预期结果>
: <涉及的文件或模块>
:
- <设计决策技术约束>
- <接口定义数据结构>
- <依赖关系>
\`\`\`
###
- **** SpecPlan 2 3
- **** SpecPlan
- **** 3 使 \`AskUserQuestion\` 工具向用户报告失败原因并请求指导
##
使 \`TodoWrite\` 工具列出任务清单,将这些步骤作为待办事项跟踪。
### 1
1. \`Read\` 工具直接阅读 \`.cospec/spec/<id>/plan.md\`,理解任务拆解、阶段划分、依赖关系
2. 使 \`TodoWrite\` 跟踪 objective 中用户提到的具体任务;如果 objective 未指定具体任务,则列出 plan.md 中的所有任务
3. TodoWrite todos
\`\`\`
1. {}
2. {}
...
N. {}
\`\`\`
### 2
plan.md
#### 2.1
"分发任务"使 \`Agent\` 工具subagent_type: "SpecPlan")分发任务。
#### 2.2
SpecPlan
- SpecPlan
- SpecPlan
- TODO
#### 2.3
- ****
1. ** plan.md** \`- [x]\`(只修改状态标记,不改其他内容)
2. ** todos**使 \`TodoWrite\` 将当前任务标记为完成
- ****
1.
2. SpecPlan
3. 使 \`AskUserQuestion\` 工具向用户报告并请求指导
### 3
- plan.md
- 使 \`AskUserQuestion\` 工具向用户确认:已完成所有修改,是否有问题需要进一步处理?
##
\`\`\`
.cospec/spec/{}/
spec.md #
tech.md #
plan.md #
\`\`\``
}
export const PLAN_MANAGER_AGENT: BuiltInAgentDefinition = {
agentType: 'PlanManager',
whenToUse:
'作为开发经理,深入理解任务规划,将开发任务分发给 SpecPlan 执行通过提供上下文、审查结果、记录进度来推动项目进展。Use this when you need to manage and coordinate development tasks. This agent understands task planning, distributes work to SpecPlan agents, reviews results, and tracks progress.',
disallowedTools: [EXIT_PLAN_MODE_TOOL_NAME],
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
getSystemPrompt: () => getPlanManagerSystemPrompt(),
}

View File

@ -2,190 +2,55 @@ import { EXIT_PLAN_MODE_TOOL_NAME } from 'src/tools/ExitPlanModeTool/constants.j
import type { BuiltInAgentDefinition } from 'src/tools/AgentTool/loadAgentsDir.js'
function getStrictSpecSystemPrompt(): string {
return `你是 StrictSpec软件开发团队的全流程编排与实施协调者
return `你是工作流编排专家负责将用户需求按照标准阶段分配到对应工作流Agent执行
> {user_input} Agent
##
##
**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"
- prompt参数输入{user_input}
##
2. **** (DesignAgent模式)
- \`Agent\` 工具启动 \`DesignAgent\`subagent_type: "DesignAgent"
- prompt参数输入{user_input}
使 \`TodoWrite\` 跟踪以下阶段进度。
3. **** (TaskPlan模式)
- \`Agent\` 工具启动 \`TaskPlan\`subagent_type: "TaskPlan"
- prompt参数输入{user_input}
### 1
4. **** (SpecPlan模式)
- \`Agent\` 工具启动 \`SpecPlan\`subagent_type: "SpecPlan"
- prompt参数输入{user_input}
\`Agent\` 工具启动 \`Requirement\`subagent_type: "Requirement"prompt 传入 {user_input}。
##
### 2
****使 \`TodoWrite\` 工具跟踪进度与工作流阶段一一对应。
\`Agent\` 工具启动 \`DesignAgent\`subagent_type: "DesignAgent"prompt 传入 {user_input}。
###
### 3
1. \`需求明确阶段->架构设计阶段->开发任务拆分阶段->方案执行阶段\` 执行
2. Agent
\`Agent\` 工具启动 \`TaskPlan\`subagent_type: "TaskPlan"prompt 传入 {user_input}。
###
### 4
\`.cospec/spec/<feature>/plan.md\`,对每个未完成任务循环执行以下步骤:
#### 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 = {
agentType: 'StrictSpec',
whenToUse:
'全流程编排与实施协调者:按顺序驱动需求→设计→任务规划→代码实施四个阶段,直接调度所有叶子 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.',
'将用户需求按照标准阶段分配到对应工作流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.',
disallowedTools: [EXIT_PLAN_MODE_TOOL_NAME],
tools:[
"AskUserQuestion",
"Agent",
"Read",
"Write",
"Edit",
"TodoWrite",
],
source: 'built-in',
baseDir: 'built-in',
model: 'inherit',
omitClaudeMd: false,
omitClaudeMd: true,
getSystemPrompt: () => getStrictSpecSystemPrompt(),
}

View File

@ -4,7 +4,6 @@ import { getFeatureValue_CACHED_MAY_BE_STALE } from '../../services/analytics/gr
import { isEnvTruthy } from '../../utils/envUtils.js'
import { DESIGN_AGENT } from '../../costrict/agents/designAgent.js'
import { QUICK_EXPLORE_AGENT } from '../../costrict/agents/quickExplore.js'
import { PLAN_MANAGER_AGENT } from '../../costrict/agents/planManager.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'
@ -65,22 +64,17 @@ export function getBuiltInAgents(): AgentDefinition[] {
GENERAL_PURPOSE_AGENT,
STATUSLINE_SETUP_AGENT,
PLAN_AGENT,
// StrictSpec workflow: full pipeline (Requirement → DesignAgent → TaskPlan → implementation)
// StrictSpec workflow: 4-stage pipeline (Requirement → DesignAgent → TaskPlan → SpecPlan)
STRICT_SPEC_AGENT,
REQUIREMENT_AGENT,
DESIGN_AGENT,
TASK_PLAN_AGENT,
SPEC_PLAN_AGENT,
// StrictPlan workflow: lightweight plan → implement pipeline
STRICT_PLAN_AGENT,
SPEC_PLAN_AGENT,
PLAN_MANAGER_AGENT,
SUB_CODING_AGENT,
TASK_CHECK_AGENT,
TASK_PLAN_AGENT,
QUICK_EXPLORE_AGENT,
REQUIREMENT_AGENT,
DESIGN_AGENT,
STRICT_SPEC_AGENT,
WIKI_PROJECT_ANALYZE_AGENT,
WIKI_CATALOGUE_DESIGN_AGENT,
WIKI_DOCUMENT_GENERATE_AGENT,