mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-28 09:23:08 +08:00
feat: add CLI settings export/import functionality
- Implemented exportSettings and importSettings APIs for CLI settings. - Added hooks useExportSettings and useImportSettings for managing export/import operations in the frontend. - Updated SettingsPage to include buttons for exporting and importing CLI settings. - Enhanced backend to handle export and import requests, including validation and conflict resolution. - Introduced new data structures for exported settings and import options. - Updated localization files to support new export/import features. - Refactored CLI tool configurations to remove hardcoded model defaults, allowing dynamic model retrieval.
This commit is contained in:
@@ -6,7 +6,7 @@ allowed-tools: TeamCreate(*), TeamDelete(*), SendMessage(*), TaskCreate(*), Task
|
||||
|
||||
# Team PlanEx
|
||||
|
||||
2 成员边规划边执行团队。通过 Wave Pipeline(波次流水线)实现 planner 和 executor 并行工作:planner 完成一个 wave 的 queue 后立即创建 EXEC-* 任务,同时进入下一 wave 规划。所有成员通过 `--role=xxx` 路由。
|
||||
2 成员边规划边执行团队。通过逐 Issue 节拍流水线实现 planner 和 executor 并行工作:planner 每完成一个 issue 的 solution 后立即创建 EXEC-* 任务(含中间产物文件路径),executor 从文件加载 solution 开始实现。所有成员通过 `--role=xxx` 路由。
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
@@ -63,7 +63,7 @@ Read(VALID_ROLES[role].file)
|
||||
|
||||
| Role | Task Prefix | Responsibility | Reuses Agent | Role File |
|
||||
|------|-------------|----------------|--------------|-----------|
|
||||
| `planner` | PLAN-* | 需求拆解 → issue 创建 → 方案设计 → 队列编排 → EXEC 任务派发 | issue-plan-agent, issue-queue-agent | [roles/planner.md](roles/planner.md) |
|
||||
| `planner` | PLAN-* | 需求拆解 → issue 创建 → 方案设计 → 冲突检查 → EXEC 任务逐个派发 | issue-plan-agent | [roles/planner.md](roles/planner.md) |
|
||||
| `executor` | EXEC-* | 加载 solution → 代码实现 → 测试 → 提交 | code-developer | [roles/executor.md](roles/executor.md) |
|
||||
|
||||
## Input Types
|
||||
@@ -93,7 +93,7 @@ mcp__ccw-tools__team_msg({ summary: `[${role}] ...` })
|
||||
|------|------|
|
||||
| 需求拆解 (issue 创建) | ❌ 直接编写/修改代码 |
|
||||
| 方案设计 (issue-plan-agent) | ❌ 调用 code-developer |
|
||||
| 队列编排 (issue-queue-agent) | ❌ 运行测试 |
|
||||
| 冲突检查 (inline files_touched) | ❌ 运行测试 |
|
||||
| 创建 EXEC-* 任务 | ❌ git commit |
|
||||
| 监控进度 (消息总线) | |
|
||||
|
||||
@@ -113,6 +113,7 @@ mcp__ccw-tools__team_msg({ summary: `[${role}] ...` })
|
||||
const TEAM_CONFIG = {
|
||||
name: "planex",
|
||||
sessionDir: ".workflow/.team/PEX-{slug}-{date}/",
|
||||
artifactsDir: ".workflow/.team/PEX-{slug}-{date}/artifacts/",
|
||||
issueDataDir: ".workflow/issues/"
|
||||
}
|
||||
```
|
||||
@@ -135,7 +136,7 @@ mcp__ccw-tools__team_msg({
|
||||
|
||||
| Role | Types |
|
||||
|------|-------|
|
||||
| planner | `wave_ready`, `queue_ready`, `all_planned`, `error` |
|
||||
| planner | `wave_ready`, `issue_ready`, `all_planned`, `error` |
|
||||
| executor | `impl_complete`, `impl_failed`, `wave_done`, `error` |
|
||||
|
||||
### CLI Fallback
|
||||
@@ -161,22 +162,22 @@ TaskUpdate({ taskId: task.id, status: 'in_progress' })
|
||||
// Phase 5: Report + Loop
|
||||
```
|
||||
|
||||
## Wave Pipeline
|
||||
## Wave Pipeline (逐 Issue 节拍)
|
||||
|
||||
```
|
||||
Wave 1: planner 创建 issues + 规划 solutions + 形成 queue
|
||||
↓ (queue ready → 创建 EXEC-* 任务)
|
||||
Wave 1 执行: executor 开始实现 ←→ planner 继续规划 Wave 2
|
||||
↓
|
||||
Wave 2 执行: executor 实现 Wave 2 ←→ planner 规划 Wave 3
|
||||
...
|
||||
Final: planner 发送 all_planned → executor 完成剩余 EXEC-* → 结束
|
||||
Issue 1: planner 规划 solution → 写中间产物 → 冲突检查 → 创建 EXEC-* → issue_ready
|
||||
↓ (executor 立即开始)
|
||||
Issue 2: planner 规划 solution → 写中间产物 → 冲突检查 → 创建 EXEC-* → issue_ready
|
||||
↓ (executor 并行消费)
|
||||
Issue N: ...
|
||||
Final: planner 发送 all_planned → executor 完成剩余 EXEC-* → 结束
|
||||
```
|
||||
|
||||
**波次规则**:
|
||||
- planner 每完成一个 wave 的 queue 后,立即创建 EXEC-* 任务供 executor 消费
|
||||
- planner 不等待 executor 完成当前 wave,直接进入下一 wave
|
||||
- executor 持续轮询并消费可用的 EXEC-* 任务
|
||||
**节拍规则**:
|
||||
- planner 每完成一个 issue 的 solution 后,**立即**创建 EXEC-* 任务并发送 `issue_ready` 信号
|
||||
- solution 写入中间产物文件(`artifacts/solutions/{issueId}.json`),EXEC-* 任务包含 `solution_file` 路径
|
||||
- executor 从文件加载 solution(无需再调 `ccw issue solution`),fallback 兼容旧模式
|
||||
- planner 不等待 executor,持续推进下一个 issue
|
||||
- 当 planner 发送 `all_planned` 消息后,executor 完成所有剩余任务即可结束
|
||||
|
||||
## Execution Method Selection
|
||||
@@ -265,6 +266,13 @@ Skill(skill="team-planex", args="-y --text '添加日志'")
|
||||
// 1. 创建团队
|
||||
TeamCreate({ team_name: teamName })
|
||||
|
||||
// 1.5 初始化 sessionDir + artifacts 目录
|
||||
const slug = (issueIds[0] || 'batch').replace(/[^a-zA-Z0-9-]/g, '')
|
||||
const dateStr = new Date().toISOString().slice(0,10).replace(/-/g,'')
|
||||
const sessionId = `PEX-${slug}-${dateStr}`
|
||||
const sessionDir = `.workflow/.team/${sessionId}`
|
||||
Bash(`mkdir -p "${sessionDir}/artifacts/solutions"`)
|
||||
|
||||
// 2. 解析输入参数
|
||||
const issueIds = args.match(/ISS-\d{8}-\d{6}/g) || []
|
||||
const textMatch = args.match(/--text\s+['"]([^'"]+)['"]/)
|
||||
@@ -298,11 +306,17 @@ executor 的执行方式已确定: ${executionConfig.executionMethod}
|
||||
execution_method: ${executionConfig.executionMethod}
|
||||
code_review: ${executionConfig.codeReviewTool}
|
||||
|
||||
## 中间产物(必须)
|
||||
sessionDir: ${sessionDir}
|
||||
每个 issue 的 solution 写入: ${sessionDir}/artifacts/solutions/{issueId}.json
|
||||
EXEC-* 任务 description 必须包含 solution_file 字段指向该文件
|
||||
每完成一个 issue 立即发送 issue_ready 消息并创建 EXEC-* 任务
|
||||
|
||||
## 角色准则(强制)
|
||||
- 你只能处理 PLAN-* 前缀的任务
|
||||
- 所有输出必须带 [planner] 标识前缀
|
||||
- 完成每个 wave 后立即创建 EXEC-* 任务供 executor 消费
|
||||
- EXEC-* 任务 description 中必须包含 execution_method 字段
|
||||
- 每完成一个 issue 的 solution 后立即创建 EXEC-* 任务(逐 issue 派发,不等 wave 完成)
|
||||
- EXEC-* 任务 description 中必须包含 execution_method 和 solution_file 字段
|
||||
|
||||
## 消息总线(必须)
|
||||
每次 SendMessage 前,先调用 mcp__ccw-tools__team_msg 记录。
|
||||
@@ -327,6 +341,10 @@ Task({
|
||||
代码审查: ${executionConfig.codeReviewTool}
|
||||
(每个 EXEC-* 任务 description 中可能包含 execution_method 覆盖)
|
||||
|
||||
## Solution 加载
|
||||
优先从 EXEC-* 任务 description 中的 solution_file 路径读取 solution JSON 文件
|
||||
无 solution_file 时 fallback 到 ccw issue solution 命令
|
||||
|
||||
## 角色准则(强制)
|
||||
- 你只能处理 EXEC-* 前缀的任务
|
||||
- 所有输出必须带 [executor] 标识前缀
|
||||
@@ -351,7 +369,7 @@ Task({
|
||||
| Unknown --role value | Error with available role list |
|
||||
| Missing --role arg | Enter orchestration mode |
|
||||
| Role file not found | Error with expected path (roles/{name}.md) |
|
||||
| Planner wave failure | Retry once, then report error and halt pipeline |
|
||||
| Planner issue planning failure | Retry once, then report error and skip to next issue |
|
||||
| Executor impl failure | Report to planner, continue with next EXEC-* task |
|
||||
| No EXEC-* tasks yet | Executor idles, polls for new tasks |
|
||||
| Pipeline stall | Planner monitors — if executor blocked > 2 tasks, escalate to user |
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
```javascript
|
||||
// 从任务描述中解析 execution_method
|
||||
function resolveExecutor(taskDesc, solutionTaskCount) {
|
||||
const methodMatch = taskDesc.match(/execution_method:\s*(Agent|Codex|Gemini|Auto)/i)
|
||||
const methodMatch = taskDesc.match(/execution_method[:\s]*\s*(Agent|Codex|Gemini|Auto)/i)
|
||||
const method = methodMatch ? methodMatch[1] : 'Auto'
|
||||
|
||||
if (method.toLowerCase() === 'auto') {
|
||||
@@ -165,9 +165,20 @@ if (!issueId) {
|
||||
return
|
||||
}
|
||||
|
||||
// Load solution plan
|
||||
const solJson = Bash(`ccw issue solution ${issueId} --json`)
|
||||
const solution = JSON.parse(solJson)
|
||||
// Load solution plan — dual mode: file-first, CLI fallback
|
||||
const solutionFileMatch = task.description.match(/solution_file[:\s]*\s*(\S+\.json)/)
|
||||
|
||||
let solution
|
||||
if (solutionFileMatch) {
|
||||
// 新模式:从中间产物文件加载
|
||||
const solutionData = JSON.parse(Read(solutionFileMatch[1]))
|
||||
// 保持 solution.bound 结构兼容
|
||||
solution = solutionData.bound ? solutionData : { bound: solutionData }
|
||||
} else {
|
||||
// 兼容模式:从 ccw issue solution 加载
|
||||
const solJson = Bash(`ccw issue solution ${issueId} --json`)
|
||||
solution = JSON.parse(solJson)
|
||||
}
|
||||
|
||||
if (!solution.bound) {
|
||||
mcp__ccw-tools__team_msg({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Role: planner
|
||||
|
||||
需求拆解 → issue 创建 → 方案设计 → 队列编排 → EXEC 任务派发。内部调用 issue-plan-agent 和 issue-queue-agent,并通过 Wave Pipeline 持续推进。planner 同时承担 lead 角色(无独立 coordinator)。
|
||||
需求拆解 → issue 创建 → 方案设计 → 冲突检查 → EXEC 任务逐个派发。内部调用 issue-plan-agent(单 issue),通过 inline files_touched 冲突检查替代 issue-queue-agent,每完成一个 issue 立即派发 EXEC-* 任务。planner 同时承担 lead 角色(无独立 coordinator)。
|
||||
|
||||
## Role Identity
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
- 仅处理 `PLAN-*` 前缀的任务
|
||||
- 所有输出必须带 `[planner]` 标识
|
||||
- 完成每个 wave 的 queue 后**立即创建 EXEC-\* 任务**
|
||||
- 不等待 executor 完成当前 wave,直接进入下一 wave 规划
|
||||
- 每完成一个 issue 的 solution 后**立即创建 EXEC-\* 任务**并发送 `issue_ready` 信号
|
||||
- 不等待 executor,持续推进下一个 issue
|
||||
|
||||
### MUST NOT
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
| Type | Direction | Trigger | Description |
|
||||
|------|-----------|---------|-------------|
|
||||
| `wave_ready` | planner → executor | Wave queue 完成 + EXEC 任务已创建 | 新 wave 可执行 |
|
||||
| `queue_ready` | planner → executor | 单个 issue 的 queue 就绪 | 增量通知 |
|
||||
| `issue_ready` | planner → executor | 单个 issue solution + EXEC 任务已创建 | 逐 issue 节拍信号 |
|
||||
| `wave_ready` | planner → executor | 一组 issues 全部派发完毕 | wave 汇总信号 |
|
||||
| `all_planned` | planner → executor | 所有 wave 规划完毕 | 最终信号 |
|
||||
| `error` | planner → executor | 阻塞性错误 | 规划失败 |
|
||||
|
||||
@@ -41,8 +41,7 @@
|
||||
|
||||
| Agent Type | Purpose |
|
||||
|------------|---------|
|
||||
| `issue-plan-agent` | Closed-loop planning: ACE exploration + solution generation + binding |
|
||||
| `issue-queue-agent` | Solution ordering + conflict detection → execution queue |
|
||||
| `issue-plan-agent` | Closed-loop planning: ACE exploration + solution generation + binding (单 issue 粒度) |
|
||||
|
||||
### CLI Capabilities
|
||||
|
||||
@@ -167,188 +166,217 @@ if (inputType === 'plan_file') {
|
||||
|
||||
Issue IDs 已就绪,直接进入 solution 规划。
|
||||
|
||||
#### Path D: execution-plan.json → 波次感知处理
|
||||
#### Path D: execution-plan.json → 波次感知逐 issue 处理
|
||||
|
||||
```javascript
|
||||
if (inputType === 'execution_plan') {
|
||||
const projectRoot = Bash('cd . && pwd').trim()
|
||||
const waves = executionPlan.waves
|
||||
const dispatchedSolutions = []
|
||||
// sessionDir 从 planner prompt 中的 sessionDir 变量获取
|
||||
const execution_method = args.match(/execution_method:\s*(\S+)/)?.[1] || 'Auto'
|
||||
const code_review = args.match(/code_review:\s*(\S+)/)?.[1] || 'Skip'
|
||||
|
||||
let waveNum = 0
|
||||
for (const wave of waves) {
|
||||
waveNum++
|
||||
const waveIssues = wave.issue_ids
|
||||
|
||||
// Step 1: issue-plan-agent 生成 solutions
|
||||
const planResult = Task({
|
||||
subagent_type: "issue-plan-agent",
|
||||
run_in_background: false,
|
||||
description: `Plan solutions for wave ${waveNum}: ${wave.label}`,
|
||||
prompt: `
|
||||
issue_ids: ${JSON.stringify(waveIssues)}
|
||||
for (const issueId of wave.issue_ids) {
|
||||
// Step 1: 单 issue 规划
|
||||
const planResult = Task({
|
||||
subagent_type: "issue-plan-agent",
|
||||
run_in_background: false,
|
||||
description: `Plan solution for ${issueId}`,
|
||||
prompt: `issue_ids: ["${issueId}"]
|
||||
project_root: "${projectRoot}"
|
||||
|
||||
## Requirements
|
||||
- Generate solutions for each issue
|
||||
- Auto-bind single solutions
|
||||
- Generate solution for this issue
|
||||
- Auto-bind single solution
|
||||
- Issues come from req-plan decomposition (tags: req-plan)
|
||||
- Respect inter-issue dependencies: ${JSON.stringify(executionPlan.issue_dependencies)}
|
||||
`
|
||||
- Respect dependencies: ${JSON.stringify(executionPlan.issue_dependencies)}`
|
||||
})
|
||||
|
||||
// Step 2: 获取 solution + 写中间产物
|
||||
const solJson = Bash(`ccw issue solution ${issueId} --json`)
|
||||
const solution = JSON.parse(solJson)
|
||||
const solutionFile = `${sessionDir}/artifacts/solutions/${issueId}.json`
|
||||
Write({
|
||||
file_path: solutionFile,
|
||||
content: JSON.stringify({
|
||||
session_id: sessionId, issue_id: issueId, ...solution,
|
||||
execution_config: { execution_method, code_review },
|
||||
timestamp: new Date().toISOString()
|
||||
}, null, 2)
|
||||
})
|
||||
|
||||
// Step 3: inline 冲突检查
|
||||
const blockedBy = inlineConflictCheck(issueId, solution, dispatchedSolutions)
|
||||
|
||||
// Step 4: 创建 EXEC-* 任务
|
||||
const execTask = TaskCreate({
|
||||
subject: `EXEC-W${waveNum}-${issueId}: 实现 ${solution.bound?.title || issueId}`,
|
||||
description: `## 执行任务\n**Wave**: ${waveNum}\n**Issue**: ${issueId}\n**solution_file**: ${solutionFile}\n**execution_method**: ${execution_method}\n**code_review**: ${code_review}`,
|
||||
activeForm: `实现 ${issueId}`,
|
||||
owner: "executor"
|
||||
})
|
||||
if (blockedBy.length > 0) {
|
||||
TaskUpdate({ taskId: execTask.id, addBlockedBy: blockedBy })
|
||||
}
|
||||
|
||||
// Step 5: 累积 + 节拍信号
|
||||
dispatchedSolutions.push({ issueId, solution, execTaskId: execTask.id })
|
||||
mcp__ccw-tools__team_msg({
|
||||
operation: "log", team: "planex", from: "planner", to: "executor",
|
||||
type: "issue_ready",
|
||||
summary: `[planner] issue_ready: ${issueId}`,
|
||||
ref: solutionFile
|
||||
})
|
||||
SendMessage({
|
||||
type: "message", recipient: "executor",
|
||||
content: `## [planner] Issue Ready: ${issueId}\n**solution_file**: ${solutionFile}\n**EXEC task**: ${execTask.subject}`,
|
||||
summary: `[planner] issue_ready: ${issueId}`
|
||||
})
|
||||
}
|
||||
|
||||
// wave 级汇总
|
||||
mcp__ccw-tools__team_msg({
|
||||
operation: "log", team: "planex", from: "planner", to: "executor",
|
||||
type: "wave_ready",
|
||||
summary: `[planner] Wave ${waveNum} fully dispatched: ${wave.issue_ids.length} issues`
|
||||
})
|
||||
|
||||
// Step 2: issue-queue-agent 形成 queue
|
||||
const queueResult = Task({
|
||||
subagent_type: "issue-queue-agent",
|
||||
run_in_background: false,
|
||||
description: `Form queue for wave ${waveNum}: ${wave.label}`,
|
||||
prompt: `
|
||||
issue_ids: ${JSON.stringify(waveIssues)}
|
||||
project_root: "${projectRoot}"
|
||||
|
||||
## Requirements
|
||||
- Order solutions by dependency (DAG)
|
||||
- Detect conflicts between solutions
|
||||
- Respect wave dependencies: ${JSON.stringify(wave.depends_on_waves)}
|
||||
- Output execution queue
|
||||
`
|
||||
})
|
||||
|
||||
// Step 3: → Phase 4 (Wave Dispatch) - create EXEC-* tasks
|
||||
// Continue to next wave without waiting for executor
|
||||
}
|
||||
// After all waves → Phase 5 (Report + Finalize)
|
||||
}
|
||||
```
|
||||
|
||||
**关键差异**: 波次分组来自 `executionPlan.waves`,而非固定 batch=5。Progressive 模式下 L0(Wave 1) → L1(Wave 2),Direct 模式下 parallel_group 映射为 wave。
|
||||
**关键差异**: 波次分组来自 `executionPlan.waves`,但每个 issue 独立规划 + 即时派发。Progressive 模式下 L0(Wave 1) → L1(Wave 2),Direct 模式下 parallel_group 映射为 wave。
|
||||
|
||||
#### Wave 规划(Path A/B/C 汇聚)
|
||||
#### Wave 规划(Path A/B/C 汇聚)— 逐 issue 派发
|
||||
|
||||
将 issueIds 按波次分组规划(Path D 使用独立的波次逻辑,不走此路径):
|
||||
将 issueIds 逐个规划并即时派发(Path D 使用独立的波次逻辑,不走此路径):
|
||||
|
||||
```javascript
|
||||
if (inputType !== 'execution_plan') {
|
||||
// Path A/B/C: 固定 batch=5 分组
|
||||
const projectRoot = Bash('cd . && pwd').trim()
|
||||
const dispatchedSolutions = []
|
||||
const execution_method = args.match(/execution_method:\s*(\S+)/)?.[1] || 'Auto'
|
||||
const code_review = args.match(/code_review:\s*(\S+)/)?.[1] || 'Skip'
|
||||
let waveNum = 1 // 简化:不再按 WAVE_SIZE=5 分组,全部视为一个逻辑 wave
|
||||
|
||||
// 按批次分组(每 wave 最多 5 个 issues)
|
||||
const WAVE_SIZE = 5
|
||||
const waves = []
|
||||
for (let i = 0; i < issueIds.length; i += WAVE_SIZE) {
|
||||
waves.push(issueIds.slice(i, i + WAVE_SIZE))
|
||||
}
|
||||
|
||||
let waveNum = 0
|
||||
for (const waveIssues of waves) {
|
||||
waveNum++
|
||||
|
||||
// Step 1: 调用 issue-plan-agent 生成 solutions
|
||||
const planResult = Task({
|
||||
subagent_type: "issue-plan-agent",
|
||||
run_in_background: false,
|
||||
description: `Plan solutions for wave ${waveNum}`,
|
||||
prompt: `
|
||||
issue_ids: ${JSON.stringify(waveIssues)}
|
||||
for (const issueId of issueIds) {
|
||||
// Step 1: 单 issue 规划
|
||||
const planResult = Task({
|
||||
subagent_type: "issue-plan-agent",
|
||||
run_in_background: false,
|
||||
description: `Plan solution for ${issueId}`,
|
||||
prompt: `issue_ids: ["${issueId}"]
|
||||
project_root: "${projectRoot}"
|
||||
|
||||
## Requirements
|
||||
- Generate solutions for each issue
|
||||
- Auto-bind single solutions
|
||||
- For multiple solutions, select the most pragmatic one
|
||||
`
|
||||
})
|
||||
- Generate solution for this issue
|
||||
- Auto-bind single solution
|
||||
- For multiple solutions, select the most pragmatic one`
|
||||
})
|
||||
|
||||
// Step 2: 调用 issue-queue-agent 形成 queue
|
||||
const queueResult = Task({
|
||||
subagent_type: "issue-queue-agent",
|
||||
run_in_background: false,
|
||||
description: `Form queue for wave ${waveNum}`,
|
||||
prompt: `
|
||||
issue_ids: ${JSON.stringify(waveIssues)}
|
||||
project_root: "${projectRoot}"
|
||||
// Step 2: 获取 solution + 写中间产物
|
||||
const solJson = Bash(`ccw issue solution ${issueId} --json`)
|
||||
const solution = JSON.parse(solJson)
|
||||
const solutionFile = `${sessionDir}/artifacts/solutions/${issueId}.json`
|
||||
Write({
|
||||
file_path: solutionFile,
|
||||
content: JSON.stringify({
|
||||
session_id: sessionId, issue_id: issueId, ...solution,
|
||||
execution_config: { execution_method, code_review },
|
||||
timestamp: new Date().toISOString()
|
||||
}, null, 2)
|
||||
})
|
||||
|
||||
## Requirements
|
||||
- Order solutions by dependency (DAG)
|
||||
- Detect conflicts between solutions
|
||||
- Output execution queue
|
||||
`
|
||||
})
|
||||
// Step 3: inline 冲突检查
|
||||
const blockedBy = inlineConflictCheck(issueId, solution, dispatchedSolutions)
|
||||
|
||||
// Step 3: → Phase 4 (Wave Dispatch)
|
||||
}
|
||||
// Step 4: 创建 EXEC-* 任务
|
||||
const execTask = TaskCreate({
|
||||
subject: `EXEC-W${waveNum}-${issueId}: 实现 ${solution.bound?.title || issueId}`,
|
||||
description: `## 执行任务\n**Wave**: ${waveNum}\n**Issue**: ${issueId}\n**solution_file**: ${solutionFile}\n**execution_method**: ${execution_method}\n**code_review**: ${code_review}`,
|
||||
activeForm: `实现 ${issueId}`,
|
||||
owner: "executor"
|
||||
})
|
||||
if (blockedBy.length > 0) {
|
||||
TaskUpdate({ taskId: execTask.id, addBlockedBy: blockedBy })
|
||||
}
|
||||
|
||||
// Step 5: 累积 + 节拍信号
|
||||
dispatchedSolutions.push({ issueId, solution, execTaskId: execTask.id })
|
||||
mcp__ccw-tools__team_msg({
|
||||
operation: "log", team: "planex", from: "planner", to: "executor",
|
||||
type: "issue_ready",
|
||||
summary: `[planner] issue_ready: ${issueId}`,
|
||||
ref: solutionFile
|
||||
})
|
||||
SendMessage({
|
||||
type: "message", recipient: "executor",
|
||||
content: `## [planner] Issue Ready: ${issueId}\n**solution_file**: ${solutionFile}\n**EXEC task**: ${execTask.subject}`,
|
||||
summary: `[planner] issue_ready: ${issueId}`
|
||||
})
|
||||
}
|
||||
} // end if (inputType !== 'execution_plan')
|
||||
```
|
||||
|
||||
### Phase 4: Wave Dispatch
|
||||
### Phase 4: Inline Conflict Check + Wave Summary
|
||||
|
||||
每个 wave 的 queue 完成后,**立即创建 EXEC-\* 任务**供 executor 消费。
|
||||
EXEC-* 任务创建已在 Phase 3 逐 issue 完成,Phase 4 仅负责 inline 冲突检查函数定义和 wave 汇总。
|
||||
|
||||
#### Inline Conflict Check 函数
|
||||
|
||||
```javascript
|
||||
// Read the generated queue
|
||||
const queuePath = `.workflow/issues/queue/execution-queue.json`
|
||||
const queue = JSON.parse(Read(queuePath))
|
||||
// Inline conflict check — 替代 issue-queue-agent
|
||||
// 基于 files_touched 重叠检测 + 显式依赖
|
||||
function inlineConflictCheck(issueId, solution, dispatchedSolutions) {
|
||||
const currentFiles = solution.bound?.files_touched
|
||||
|| solution.bound?.affected_files || []
|
||||
const blockedBy = []
|
||||
|
||||
// Create EXEC-* tasks from queue entries
|
||||
const execTasks = []
|
||||
for (const entry of queue.queue) {
|
||||
const execTask = TaskCreate({
|
||||
subject: `EXEC-W${waveNum}-${entry.issue_id}: 实现 ${entry.title || entry.issue_id}`,
|
||||
description: `## 执行任务
|
||||
|
||||
**Wave**: ${waveNum}
|
||||
**Issue**: ${entry.issue_id}
|
||||
**Solution**: ${entry.solution_id}
|
||||
**Priority**: ${entry.priority || 'normal'}
|
||||
**Dependencies**: ${entry.depends_on?.join(', ') || 'none'}
|
||||
|
||||
加载 solution plan 并实现代码。完成后运行测试、提交。`,
|
||||
activeForm: `实现 ${entry.issue_id}`,
|
||||
owner: "executor"
|
||||
})
|
||||
execTasks.push(execTask)
|
||||
}
|
||||
|
||||
// Set up dependency chains between EXEC tasks (based on queue DAG)
|
||||
for (const entry of queue.queue) {
|
||||
if (entry.depends_on?.length > 0) {
|
||||
const thisTask = execTasks.find(t => t.subject.includes(entry.issue_id))
|
||||
const depTasks = entry.depends_on.map(depId =>
|
||||
execTasks.find(t => t.subject.includes(depId))
|
||||
).filter(Boolean)
|
||||
|
||||
if (thisTask && depTasks.length > 0) {
|
||||
TaskUpdate({
|
||||
taskId: thisTask.id,
|
||||
addBlockedBy: depTasks.map(t => t.id)
|
||||
})
|
||||
// 1. 文件冲突检测
|
||||
for (const prev of dispatchedSolutions) {
|
||||
const prevFiles = prev.solution.bound?.files_touched
|
||||
|| prev.solution.bound?.affected_files || []
|
||||
const overlap = currentFiles.filter(f => prevFiles.includes(f))
|
||||
if (overlap.length > 0) {
|
||||
blockedBy.push(prev.execTaskId)
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 显式依赖
|
||||
const explicitDeps = solution.bound?.dependencies?.on_issues || []
|
||||
for (const depId of explicitDeps) {
|
||||
const depTask = dispatchedSolutions.find(d => d.issueId === depId)
|
||||
if (depTask && !blockedBy.includes(depTask.execTaskId)) {
|
||||
blockedBy.push(depTask.execTaskId)
|
||||
}
|
||||
}
|
||||
|
||||
return blockedBy
|
||||
}
|
||||
```
|
||||
|
||||
// Notify executor: wave ready
|
||||
#### Wave Summary Signal
|
||||
|
||||
Phase 3 循环完成后发送汇总信号(Path A/B/C 在全部 issue 完成后,Path D 在每个 wave 完成后):
|
||||
|
||||
```javascript
|
||||
// Wave summary — 已在 Phase 3 循环中由每个 wave 末尾发送
|
||||
// Path A/B/C: 全部 issue 完成后发送一次
|
||||
mcp__ccw-tools__team_msg({
|
||||
operation: "log",
|
||||
team: "planex",
|
||||
from: "planner",
|
||||
to: "executor",
|
||||
operation: "log", team: "planex", from: "planner", to: "executor",
|
||||
type: "wave_ready",
|
||||
summary: `[planner] Wave ${waveNum} ready: ${execTasks.length} EXEC tasks created`
|
||||
summary: `[planner] Wave ${waveNum} fully dispatched: ${issueIds.length} issues`
|
||||
})
|
||||
|
||||
SendMessage({
|
||||
type: "message",
|
||||
recipient: "executor",
|
||||
content: `## [planner] Wave ${waveNum} Ready
|
||||
|
||||
**Issues**: ${waveIssues.join(', ')}
|
||||
**EXEC Tasks Created**: ${execTasks.length}
|
||||
**Queue**: ${queuePath}
|
||||
|
||||
Executor 可以开始实现。`,
|
||||
type: "message", recipient: "executor",
|
||||
content: `## [planner] Wave ${waveNum} Complete\n所有 issues 已逐个派发完毕,共 ${dispatchedSolutions.length} 个 EXEC 任务。`,
|
||||
summary: `[planner] wave_ready: wave ${waveNum}`
|
||||
})
|
||||
|
||||
// 不等待 executor 完成,继续下一 wave → back to Phase 3 loop
|
||||
```
|
||||
|
||||
### Phase 5: Report + Finalize
|
||||
@@ -443,9 +471,10 @@ function parsePlanPhases(planContent) {
|
||||
| No PLAN-* tasks available | Idle, wait for orchestrator |
|
||||
| Issue creation failure | Retry once with simplified text, then report error |
|
||||
| issue-plan-agent failure | Retry once, then report error and skip to next issue |
|
||||
| issue-queue-agent failure | Retry once, then create EXEC tasks without DAG ordering |
|
||||
| Inline conflict check failure | Skip conflict detection, create EXEC task without blockedBy |
|
||||
| Plan file not found | Report error with expected path |
|
||||
| execution-plan.json parse failure | Fallback to plan_file parsing (Path B) |
|
||||
| execution-plan.json missing waves | Report error, suggest re-running req-plan |
|
||||
| Empty input (no issues, no text, no plan) | AskUserQuestion for clarification |
|
||||
| Solution artifact write failure | Log warning, create EXEC task without solution_file (executor fallback) |
|
||||
| Wave partially failed | Report partial success, continue with successful issues |
|
||||
|
||||
Reference in New Issue
Block a user