mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-28 09:23:08 +08:00
feat: Add orchestrator template and roles for executor and planner
- Created a new orchestrator template for Codex skill design, detailing structure and execution phases. - Introduced the executor role with responsibilities for task execution, including routing to backends and handling implementation. - Added the planner role for requirement breakdown, issue creation, and task dispatching, ensuring a structured planning process.
This commit is contained in:
@@ -180,6 +180,83 @@ Final: planner 发送 all_planned → executor 完成剩余 EXEC-* → 结束
|
||||
- executor 持续轮询并消费可用的 EXEC-* 任务
|
||||
- 当 planner 发送 `all_planned` 消息后,executor 完成所有剩余任务即可结束
|
||||
|
||||
## Execution Method Selection
|
||||
|
||||
在编排模式或直接调用 executor 前,**必须先确定执行方式**。支持 3 种执行后端:
|
||||
|
||||
| Executor | 后端 | 适用场景 |
|
||||
|----------|------|----------|
|
||||
| `agent` | code-developer subagent | 简单任务、同步执行 |
|
||||
| `codex` | `ccw cli --tool codex --mode write` | 复杂任务、后台执行 |
|
||||
| `gemini` | `ccw cli --tool gemini --mode write` | 分析类任务、后台执行 |
|
||||
|
||||
### 选择逻辑
|
||||
|
||||
```javascript
|
||||
const autoYes = args.includes('--auto') || args.includes('-y')
|
||||
const explicitExec = args.match(/--exec[=\s]+(agent|codex|gemini|auto)/i)?.[1]
|
||||
|
||||
let executionConfig
|
||||
|
||||
if (explicitExec) {
|
||||
// 显式指定
|
||||
executionConfig = {
|
||||
executionMethod: explicitExec.charAt(0).toUpperCase() + explicitExec.slice(1),
|
||||
codeReviewTool: "Skip"
|
||||
}
|
||||
} else if (autoYes) {
|
||||
// Auto 模式:默认 Agent + Skip review
|
||||
executionConfig = { executionMethod: "Auto", codeReviewTool: "Skip" }
|
||||
} else {
|
||||
// 交互选择
|
||||
executionConfig = AskUserQuestion({
|
||||
questions: [
|
||||
{
|
||||
question: "选择执行方式:",
|
||||
header: "Execution",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Agent", description: "code-developer agent(同步,适合简单任务)" },
|
||||
{ label: "Codex", description: "Codex CLI(后台,适合复杂任务)" },
|
||||
{ label: "Gemini", description: "Gemini CLI(后台,适合分析类任务)" },
|
||||
{ label: "Auto", description: "根据任务复杂度自动选择" }
|
||||
]
|
||||
},
|
||||
{
|
||||
question: "执行后是否进行代码审查?",
|
||||
header: "Code Review",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Skip", description: "不审查" },
|
||||
{ label: "Gemini Review", description: "Gemini CLI 审查" },
|
||||
{ label: "Codex Review", description: "Git-aware review(--uncommitted)" },
|
||||
{ label: "Agent Review", description: "当前 agent 审查" }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
// Auto 解析:根据 solution task_count 决定
|
||||
function resolveExecutor(taskCount) {
|
||||
if (executionConfig.executionMethod === 'Auto') {
|
||||
return taskCount <= 3 ? 'agent' : 'codex'
|
||||
}
|
||||
return executionConfig.executionMethod.toLowerCase()
|
||||
}
|
||||
```
|
||||
|
||||
### 通过 args 指定
|
||||
|
||||
```bash
|
||||
# 显式指定
|
||||
Skill(skill="team-planex", args="--exec=codex ISS-xxx")
|
||||
Skill(skill="team-planex", args="--exec=agent --text '简单功能'")
|
||||
|
||||
# Auto 模式(跳过交互)
|
||||
Skill(skill="team-planex", args="-y --text '添加日志'")
|
||||
```
|
||||
|
||||
## Orchestration Mode
|
||||
|
||||
当不带 `--role` 调用时,SKILL.md 进入轻量编排模式:
|
||||
@@ -195,7 +272,10 @@ const planMatch = args.match(/--plan\s+(\S+)/)
|
||||
|
||||
let plannerInput = args // 透传给 planner
|
||||
|
||||
// 3. 创建初始 PLAN-* 任务
|
||||
// 3. 执行方式选择(见上方 Execution Method Selection)
|
||||
// executionConfig 已确定: { executionMethod, codeReviewTool }
|
||||
|
||||
// 4. 创建初始 PLAN-* 任务
|
||||
TaskCreate({
|
||||
subject: "PLAN-001: 初始规划",
|
||||
description: `规划任务。输入: ${plannerInput}`,
|
||||
@@ -203,7 +283,7 @@ TaskCreate({
|
||||
owner: "planner"
|
||||
})
|
||||
|
||||
// 4. Spawn planner agent
|
||||
// 5. Spawn planner agent
|
||||
Task({
|
||||
subagent_type: "general-purpose",
|
||||
team_name: teamName,
|
||||
@@ -212,10 +292,17 @@ Task({
|
||||
当你收到 PLAN-* 任务时,调用 Skill(skill="team-planex", args="--role=planner") 执行。
|
||||
当前输入: ${plannerInput}
|
||||
|
||||
## 执行配置
|
||||
executor 的执行方式已确定: ${executionConfig.executionMethod}
|
||||
创建 EXEC-* 任务时,在 description 中包含:
|
||||
execution_method: ${executionConfig.executionMethod}
|
||||
code_review: ${executionConfig.codeReviewTool}
|
||||
|
||||
## 角色准则(强制)
|
||||
- 你只能处理 PLAN-* 前缀的任务
|
||||
- 所有输出必须带 [planner] 标识前缀
|
||||
- 完成每个 wave 后立即创建 EXEC-* 任务供 executor 消费
|
||||
- EXEC-* 任务 description 中必须包含 execution_method 字段
|
||||
|
||||
## 消息总线(必须)
|
||||
每次 SendMessage 前,先调用 mcp__ccw-tools__team_msg 记录。
|
||||
@@ -227,7 +314,7 @@ Task({
|
||||
4. TaskUpdate completed → 检查下一个任务`
|
||||
})
|
||||
|
||||
// 5. Spawn executor agent
|
||||
// 6. Spawn executor agent
|
||||
Task({
|
||||
subagent_type: "general-purpose",
|
||||
team_name: teamName,
|
||||
@@ -235,9 +322,15 @@ Task({
|
||||
prompt: `你是 team "${teamName}" 的 EXECUTOR。
|
||||
当你收到 EXEC-* 任务时,调用 Skill(skill="team-planex", args="--role=executor") 执行。
|
||||
|
||||
## 执行配置
|
||||
默认执行方式: ${executionConfig.executionMethod}
|
||||
代码审查: ${executionConfig.codeReviewTool}
|
||||
(每个 EXEC-* 任务 description 中可能包含 execution_method 覆盖)
|
||||
|
||||
## 角色准则(强制)
|
||||
- 你只能处理 EXEC-* 前缀的任务
|
||||
- 所有输出必须带 [executor] 标识前缀
|
||||
- 根据 execution_method 选择执行后端(Agent/Codex/Gemini)
|
||||
- 每个 solution 完成后通知 planner
|
||||
|
||||
## 消息总线(必须)
|
||||
|
||||
Reference in New Issue
Block a user