Loading...
Loading...
Compare original and translation side by side
--yes-y--yes-y$wave-plan-pipeline "Implement user authentication with OAuth, JWT, and 2FA"
$wave-plan-pipeline -c 4 "Refactor payment module with Stripe and PayPal"
$wave-plan-pipeline -y "Build notification system with email and SMS"
$wave-plan-pipeline --continue "auth-20260228"-y, --yes-c, --concurrency N--continue.workflow/.wave-plan/{session-id}/$wave-plan-pipeline "实现基于OAuth、JWT和2FA的用户认证"
$wave-plan-pipeline -c 4 "基于Stripe和PayPal重构支付模块"
$wave-plan-pipeline -y "构建包含邮件和短信的通知系统"
$wave-plan-pipeline --continue "auth-20260228"-y, --yes-c, --concurrency N--continue.workflow/.wave-plan/{session-id}/spawn_agents_on_csvcontext_fromE*T*┌──────────────────────────────────────────────────────────────────────┐
│ WAVE PLAN PIPELINE │
├──────────────────────────────────────────────────────────────────────┤
│ │
│ Phase 1: Requirement → explore.csv │
│ ├─ Analyze complexity → select exploration angles (1-4) │
│ ├─ Generate explore.csv (1 row per angle) │
│ └─ User validates (skip if -y) │
│ │
│ Phase 2: Wave Explore (spawn_agents_on_csv) │
│ ├─ For each explore wave: │
│ │ ├─ Build wave CSV from explore.csv │
│ │ ├─ spawn_agents_on_csv(explore instruction template) │
│ │ └─ Merge findings/key_files into explore.csv │
│ └─ discoveries.ndjson shared across agents │
│ │
│ Phase 3: Synthesize & Plan → tasks.csv │
│ ├─ Read all explore findings → cross-reference │
│ ├─ Resolve conflicts between angles │
│ ├─ Decompose into execution tasks with context_from: E*;T* │
│ ├─ Compute dependency waves (topological sort) │
│ └─ User validates (skip if -y) │
│ │
│ Phase 4: Wave Execute (spawn_agents_on_csv) │
│ ├─ For each task wave: │
│ │ ├─ Build prev_context from explore.csv + tasks.csv │
│ │ ├─ Build wave CSV with prev_context column │
│ │ ├─ spawn_agents_on_csv(execute instruction template) │
│ │ └─ Merge results into tasks.csv │
│ └─ discoveries.ndjson carries across all waves │
│ │
│ Phase 5: Aggregate │
│ ├─ Export results.csv │
│ ├─ Generate context.md with all findings │
│ └─ Display summary │
│ │
└──────────────────────────────────────────────────────────────────────┘spawn_agents_on_csvcontext_fromE*T*┌──────────────────────────────────────────────────────────────────────┐
│ 波浪式规划流水线 │
├──────────────────────────────────────────────────────────────────────┤
│ │
│ 阶段1: 需求 → explore.csv │
│ ├─ 分析复杂度 → 选择探索维度(1-4个) │
│ ├─ 生成explore.csv(每个维度对应一行) │
│ └─ 用户验证(若使用-y则跳过) │
│ │
│ 阶段2: 波浪式探索(spawn_agents_on_csv) │
│ ├─ 针对每个探索波浪: │
│ │ ├─ 基于explore.csv构建波浪CSV │
│ │ ├─ 调用spawn_agents_on_csv(探索指令模板) │
│ │ └─ 将探索结果/关键文件合并到explore.csv │
│ └─ discoveries.ndjson为所有Agent共享 │
│ │
│ 阶段3: 结果整合与规划 → tasks.csv │
│ ├─ 读取所有探索结果 → 交叉参考 │
│ ├─ 解决不同维度间的冲突 │
│ ├─ 拆解为执行任务,并通过context_from: E*;T*关联上下文 │
│ ├─ 计算依赖波浪(拓扑排序) │
│ └─ 用户验证(若使用-y则跳过) │
│ │
│ 阶段4: 波浪式执行(spawn_agents_on_csv) │
│ ├─ 针对每个任务波浪: │
│ │ ├─ 基于explore.csv + tasks.csv构建prev_context │
│ │ ├─ 构建包含prev_context列的波浪CSV │
│ │ ├─ 调用spawn_agents_on_csv(执行指令模板) │
│ │ └─ 将执行结果合并到tasks.csv │
│ └─ discoveries.ndjson在所有波浪间传递 │
│ │
│ 阶段5: 结果汇总 │
│ ├─ 导出results.csv │
│ ├─ 生成包含所有探索结果的context.md │
│ └─ 显示汇总信息 │
│ │
└──────────────────────────────────────────────────────────────────────┘explore.csv tasks.csv
┌──────────┐ ┌──────────┐
│ E1: arch │──────────→│ T1: setup│ context_from: E1;E2
│ findings │ │ prev_ctx │← E1+E2 findings
├──────────┤ ├──────────┤
│ E2: deps │──────────→│ T2: impl │ context_from: E1;T1
│ findings │ │ prev_ctx │← E1+T1 findings
├──────────┤ ├──────────┤
│ E3: test │──┐ ┌───→│ T3: test │ context_from: E3;T2
│ findings │ └───┘ │ prev_ctx │← E3+T2 findings
└──────────┘ └──────────┘
Two context channels:
1. Directed: context_from → prev_context (CSV findings lookup)
2. Broadcast: discoveries.ndjson (append-only shared board)
context_from prefix: E* → explore.csv lookup, T* → tasks.csv lookupexplore.csv tasks.csv
┌──────────┐ ┌──────────┐
│ E1: 架构 │──────────→│ T1: 搭建│ context_from: E1;E2
│ 探索结果 │ │ 上下文 │← E1+E2探索结果
├──────────┤ ├──────────┤
│ E2: 依赖 │──────────→│ T2: 实现│ context_from: E1;T1
│ 探索结果 │ │ 上下文 │← E1+T1执行结果
├──────────┤ ├──────────┤
│ E3: 测试 │──┐ ┌───→│ T3: 测试│ context_from: E3;T2
│ 探索结果 │ └───┘ │ 上下文 │← E3+T2执行结果
└──────────┘ └──────────┘
两种上下文通道:
1. 定向传递: context_from → prev_context(CSV结果查询)
2. 广播传递: discoveries.ndjson(仅追加的共享看板)
context_from前缀规则: E* → 从explore.csv查询,T* → 从tasks.csv查询id,angle,description,focus,deps,wave,status,findings,key_files,error
"E1","architecture","Explore codebase architecture for: auth system","architecture","","1","pending","","",""
"E2","dependencies","Explore dependency landscape for: auth system","dependencies","","1","pending","","",""
"E3","testing","Explore test infrastructure for: auth system","testing","","1","pending","","",""| Column | Phase | Description |
|---|---|---|
| Input | Exploration ID: E1, E2, ... |
| Input | Exploration angle name |
| Input | What to explore from this angle |
| Input | Keywords and focus areas |
| Input | Semicolon-separated dep IDs (usually empty — all wave 1) |
| Computed | Wave number (usually 1 for all explorations) |
| Output | |
| Output | Discoveries (max 800 chars) |
| Output | Relevant files (semicolon-separated) |
| Output | Error message if failed |
id,angle,description,focus,deps,wave,status,findings,key_files,error
"E1","architecture","探索代码库架构:认证系统","architecture","","1","pending","","",""
"E2","dependencies","探索依赖生态:认证系统","dependencies","","1","pending","","",""
"E3","testing","探索测试基础设施:认证系统","testing","","1","pending","","",""| 列名 | 阶段 | 描述 |
|---|---|---|
| 输入 | 探索ID: E1, E2, ... |
| 输入 | 探索维度名称 |
| 输入 | 该维度的探索目标 |
| 输入 | 关键词和探索重点 |
| 输入 | 分号分隔的依赖ID(通常为空 — 所有探索都在第1波浪) |
| 计算生成 | 波浪编号(所有探索通常为1) |
| 输出 | |
| 输出 | 探索结果(最多800字符) |
| 输出 | 相关文件(分号分隔) |
| 输出 | 执行失败时的错误信息 |
id,title,description,test,acceptance_criteria,scope,hints,execution_directives,deps,context_from,wave,status,findings,files_modified,tests_passed,acceptance_met,error
"T1","Setup types","Create type definitions","Verify types compile with tsc","All interfaces exported","src/types/**","Follow existing patterns || src/types/index.ts","tsc --noEmit","","E1;E2","1","pending","","","","",""
"T2","Implement core","Implement core auth logic","Unit test: login returns token","Login flow works end-to-end","src/auth/**","Reuse BaseService || src/services/Base.ts","npm test -- --grep auth","T1","E1;E2;T1","2","pending","","","","",""| Column | Phase | Description |
|---|---|---|
| Input | Task ID: T1, T2, ... |
| Input | Short task title |
| Input | Self-contained task description — what to implement |
| Input | Test cases: what tests to write and how to verify (unit/integration/edge) |
| Input | Measurable conditions that define "done" |
| Input | Target file/directory glob — constrains agent write area, prevents cross-task file conflicts |
| Input | Implementation tips + reference files. Format: |
| Input | Execution constraints: commands to run for verification, tool restrictions |
| Input | Dependency task IDs: T1;T2 (semicolon-separated) |
| Input | Context source IDs: E1;E2;T1 — |
| Computed | Wave number (computed by topological sort, 1-based) |
| Output | |
| Output | Execution findings (max 500 chars) |
| Output | Semicolon-separated file paths |
| Output | Whether all defined test cases passed (true/false) |
| Output | Summary of which acceptance criteria were met/unmet |
| Output | Error message if failed (empty if success) |
id,title,description,test,acceptance_criteria,scope,hints,execution_directives,deps,context_from,wave,status,findings,files_modified,tests_passed,acceptance_met,error
"T1","类型定义","创建类型定义","验证类型可通过tsc编译","所有接口已导出","src/types/**","遵循现有模式 || src/types/index.ts","tsc --noEmit","","E1;E2","1","pending","","","","",""
"T2","核心实现","实现核心认证逻辑","单元测试:登录返回token","登录流程端到端可用","src/auth/**","复用BaseService || src/services/Base.ts","npm test -- --grep auth","T1","E1;E2;T1","2","pending","","","","",""| 列名 | 阶段 | 描述 |
|---|---|---|
| 输入 | 任务ID: T1, T2, ... |
| 输入 | 简短任务标题 |
| 输入 | 自包含的任务描述 — 需要实现的内容 |
| 输入 | 测试用例:需要编写的测试及验证方式(单元/集成/边界测试) |
| 输入 | 定义“完成”的可衡量条件 |
| 输入 | 目标文件/目录通配符 — 限制Agent的写入范围,避免跨任务文件冲突 |
| 输入 | 实现提示 + 参考文件。格式: |
| 输入 | 执行约束:用于验证的命令、工具限制 |
| 输入 | 依赖任务ID: T1;T2(分号分隔) |
| 输入 | 上下文来源ID: E1;E2;T1 — |
| 计算生成 | 波浪编号(通过拓扑排序计算,从1开始) |
| 输出 | |
| 输出 | 执行结果(最多500字符) |
| 输出 | 分号分隔的文件路径 |
| 输出 | 是否所有定义的测试用例通过(true/false) |
| 输出 | 哪些验收条件已满足/未满足的汇总 |
| 输出 | 执行失败时的错误信息(成功则为空) |
prev_contextexplore-wave-{N}.csvtask-wave-{N}.csvprev_contextid,title,description,test,acceptance_criteria,scope,hints,execution_directives,deps,context_from,wave,prev_context
"T2","Implement core","Implement core auth logic","Unit test: login returns token","Login flow works end-to-end","src/auth/**","Reuse BaseService || src/services/Base.ts","npm test -- --grep auth","T1","E1;E2;T1","2","[Explore architecture] Found BaseService pattern in src/services/\n[Task T1] Created types at src/types/auth.ts"prev_contextcontext_fromfindingsE*T*prev_contextexplore-wave-{N}.csvtask-wave-{N}.csvprev_contextid,title,description,test,acceptance_criteria,scope,hints,execution_directives,deps,context_from,wave,prev_context
"T2","核心实现","实现核心认证逻辑","单元测试:登录返回token","登录流程端到端可用","src/auth/**","复用BaseService || src/services/Base.ts","npm test -- --grep auth","T1","E1;E2;T1","2","[探索架构] 在src/services/中发现BaseService模式\n[任务T1] 在src/types/auth.ts创建了类型定义"prev_contextcontext_fromE*T*findings| File | Purpose | Lifecycle |
|---|---|---|
| Exploration state — angles with findings/key_files | Updated after Phase 2 |
| Execution state — tasks with results | Updated after each wave in Phase 4 |
| Per-wave explore input (temporary) | Created before wave, deleted after |
| Per-wave execute input (temporary) | Created before wave, deleted after |
| Final results export | Created in Phase 5 |
| Shared discovery board (all agents, all phases) | Append-only |
| Human-readable execution report | Created in Phase 5 |
| 文件 | 用途 | 生命周期 |
|---|---|---|
| 探索状态 — 包含各维度的探索结果/关键文件 | 阶段2后更新 |
| 执行状态 — 包含任务的执行结果 | 阶段4中每个波浪后更新 |
| 探索波浪的临时输入文件 | 波浪前创建,波浪后删除 |
| 执行波浪的临时输入文件 | 波浪前创建,波浪后删除 |
| 最终结果导出文件 | 阶段5创建 |
| 所有Agent、所有阶段共享的探索看板 | 仅追加 |
| 人类可读的执行报告 | 阶段5创建 |
.workflow/.wave-plan/{session-id}/
├── explore.csv # Exploration state
├── tasks.csv # Execution state
├── results.csv # Final results export
├── discoveries.ndjson # Shared discovery board
├── context.md # Full context summary
├── explore-wave-{N}.csv # Temporary per-wave explore input (cleaned up)
└── task-wave-{N}.csv # Temporary per-wave execute input (cleaned up).workflow/.wave-plan/{session-id}/
├── explore.csv # 探索状态文件
├── tasks.csv # 执行状态文件
├── results.csv # 最终结果导出文件
├── discoveries.ndjson # 共享探索看板
├── context.md # 完整上下文汇总报告
├── explore-wave-{N}.csv # 探索波浪临时输入文件(已清理)
└── task-wave-{N}.csv # 执行波浪临时输入文件(已清理)const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
// Parse flags
const AUTO_YES = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
const continueMode = $ARGUMENTS.includes('--continue')
const concurrencyMatch = $ARGUMENTS.match(/(?:--concurrency|-c)\s+(\d+)/)
const maxConcurrency = concurrencyMatch ? parseInt(concurrencyMatch[1]) : 4
const requirement = $ARGUMENTS
.replace(/--yes|-y|--continue|--concurrency\s+\d+|-c\s+\d+/g, '')
.trim()
const slug = requirement.toLowerCase()
.replace(/[^a-z0-9\u4e00-\u9fa5]+/g, '-')
.substring(0, 40)
const dateStr = getUtc8ISOString().substring(0, 10).replace(/-/g, '')
const sessionId = `wpp-${slug}-${dateStr}`
const sessionFolder = `.workflow/.wave-plan/${sessionId}`
// Continue mode: find existing session
if (continueMode) {
const existing = Bash(`ls -t .workflow/.wave-plan/ 2>/dev/null | head -1`).trim()
if (existing) {
sessionId = existing
sessionFolder = `.workflow/.wave-plan/${sessionId}`
// Check which phase to resume: if tasks.csv exists → Phase 4, else → Phase 2
}
}
Bash(`mkdir -p ${sessionFolder}`)const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
// 解析参数
const AUTO_YES = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
const continueMode = $ARGUMENTS.includes('--continue')
const concurrencyMatch = $ARGUMENTS.match(/(?:--concurrency|-c)\s+(\d+)/)
const maxConcurrency = concurrencyMatch ? parseInt(concurrencyMatch[1]) : 4
const requirement = $ARGUMENTS
.replace(/--yes|-y|--continue|--concurrency\s+\d+|-c\s+\d+/g, '')
.trim()
const slug = requirement.toLowerCase()
.replace(/[^a-z0-9\u4e00-\u9fa5]+/g, '-')
.substring(0, 40)
const dateStr = getUtc8ISOString().substring(0, 10).replace(/-/g, '')
const sessionId = `wpp-${slug}-${dateStr}`
const sessionFolder = `.workflow/.wave-plan/${sessionId}`
// 恢复模式:查找现有会话
if (continueMode) {
const existing = Bash(`ls -t .workflow/.wave-plan/ 2>/dev/null | head -1`).trim()
if (existing) {
sessionId = existing
sessionFolder = `.workflow/.wave-plan/${sessionId}`
// 检查需要恢复的阶段:若存在tasks.csv → 阶段4,否则 → 阶段2
}
}
Bash(`mkdir -p ${sessionFolder}`)Bash({
command: `ccw cli -p "PURPOSE: Analyze requirement complexity and select 1-4 exploration angles for codebase discovery before implementation.
2. **Generate explore.csv**
```javascript
const header = 'id,angle,description,focus,deps,wave,status,findings,key_files,error'
const rows = angles.map(a =>
[a.id, a.angle, a.description, a.focus, '', '1', 'pending', '', '', '']
.map(v => `"${String(v).replace(/"/g, '""')}"`)
.join(',')
)
Write(`${sessionFolder}/explore.csv`, [header, ...rows].join('\n'))if (!AUTO_YES) {
console.log(`\n## Exploration Plan (${angles.length} angles)\n`)
angles.forEach(a => console.log(` - [${a.id}] ${a.angle}: ${a.focus}`))
const answer = AskUserQuestion({
questions: [{
question: "Approve exploration angles?",
header: "Validation",
multiSelect: false,
options: [
{ label: "Approve", description: "Proceed with wave exploration" },
{ label: "Modify", description: `Edit ${sessionFolder}/explore.csv manually, then --continue` },
{ label: "Cancel", description: "Abort" }
]
}]
})
if (answer.Validation === "Modify") {
console.log(`Edit: ${sessionFolder}/explore.csv\nResume: $wave-plan-pipeline --continue`)
return
} else if (answer.Validation === "Cancel") {
return
}
}Bash({
command: `ccw cli -p "PURPOSE: 分析需求复杂度,在实现前选择1-4个探索维度进行代码库探索。
2. **生成explore.csv**
```javascript
const header = 'id,angle,description,focus,deps,wave,status,findings,key_files,error'
const rows = angles.map(a =>
[a.id, a.angle, a.description, a.focus, '', '1', 'pending', '', '', '']
.map(v => `"${String(v).replace(/"/g, '""')}"`)
.join(',')
)
Write(`${sessionFolder}/explore.csv`, [header, ...rows].join('\n'))if (!AUTO_YES) {
console.log(`\n## 探索计划 (${angles.length}个维度)\n`)
angles.forEach(a => console.log(` - [${a.id}] ${a.angle}: ${a.focus}`))
const answer = AskUserQuestion({
questions: [{
question: "是否批准探索维度?",
header: "验证",
multiSelect: false,
options: [
{ label: "批准", description: "继续执行波浪式探索" },
{ label: "修改", description: `手动编辑${sessionFolder}/explore.csv,然后使用--continue恢复` },
{ label: "取消", description: "终止流程" }
]
}]
})
if (answer.Validation === "修改") {
console.log(`编辑: ${sessionFolder}/explore.csv\n恢复: $wave-plan-pipeline --continue`)
return
} else if (answer.Validation === "取消") {
return
}
}spawn_agents_on_csvconst exploreCSV = parseCsv(Read(`${sessionFolder}/explore.csv`))
const maxExploreWave = Math.max(...exploreCSV.map(r => parseInt(r.wave)))
for (let wave = 1; wave <= maxExploreWave; wave++) {
const waveTasks = exploreCSV.filter(r =>
parseInt(r.wave) === wave && r.status === 'pending'
)
if (waveTasks.length === 0) continue
// Skip rows with failed dependencies
const executableTasks = []
for (const task of waveTasks) {
const deps = (task.deps || '').split(';').filter(Boolean)
if (deps.some(d => {
const dep = exploreCSV.find(r => r.id === d)
return !dep || dep.status !== 'completed'
})) {
task.status = 'skipped'
task.error = 'Dependency failed/skipped'
continue
}
executableTasks.push(task)
}
if (executableTasks.length === 0) continue
// Write explore wave CSV
const waveHeader = 'id,angle,description,focus,deps,wave'
const waveRows = executableTasks.map(t =>
[t.id, t.angle, t.description, t.focus, t.deps, t.wave]
.map(v => `"${String(v).replace(/"/g, '""')}"`)
.join(',')
)
Write(`${sessionFolder}/explore-wave-${wave}.csv`, [waveHeader, ...waveRows].join('\n'))
// Execute explore wave
console.log(` Exploring ${executableTasks.length} angles (wave ${wave})...`)
spawn_agents_on_csv({
csv_path: `${sessionFolder}/explore-wave-${wave}.csv`,
id_column: "id",
instruction: buildExploreInstruction(sessionFolder),
max_concurrency: maxConcurrency,
max_runtime_seconds: 300,
output_csv_path: `${sessionFolder}/explore-wave-${wave}-results.csv`,
output_schema: {
type: "object",
properties: {
id: { type: "string" },
status: { type: "string", enum: ["completed", "failed"] },
findings: { type: "string" },
key_files: { type: "array", items: { type: "string" } },
error: { type: "string" }
},
required: ["id", "status", "findings"]
}
})
// Merge results into explore.csv
const waveResults = parseCsv(Read(`${sessionFolder}/explore-wave-${wave}-results.csv`))
for (const result of waveResults) {
updateMasterCsvRow(`${sessionFolder}/explore.csv`, result.id, {
status: result.status,
findings: result.findings || '',
key_files: Array.isArray(result.key_files) ? result.key_files.join(';') : (result.key_files || ''),
error: result.error || ''
})
}
// Cleanup temporary wave CSV
Bash(`rm -f "${sessionFolder}/explore-wave-${wave}.csv" "${sessionFolder}/explore-wave-${wave}-results.csv"`)
}function buildExploreInstruction(sessionFolder) {
return `spawn_agents_on_csvconst exploreCSV = parseCsv(Read(`${sessionFolder}/explore.csv`))
const maxExploreWave = Math.max(...exploreCSV.map(r => parseInt(r.wave)))
for (let wave = 1; wave <= maxExploreWave; wave++) {
const waveTasks = exploreCSV.filter(r =>
parseInt(r.wave) === wave && r.status === 'pending'
)
if (waveTasks.length === 0) continue
// 跳过依赖失败的任务
const executableTasks = []
for (const task of waveTasks) {
const deps = (task.deps || '').split(';').filter(Boolean)
if (deps.some(d => {
const dep = exploreCSV.find(r => r.id === d)
return !dep || dep.status !== 'completed'
})) {
task.status = 'skipped'
task.error = '依赖失败/被跳过'
continue
}
executableTasks.push(task)
}
if (executableTasks.length === 0) continue
// 写入探索波浪CSV
const waveHeader = 'id,angle,description,focus,deps,wave'
const waveRows = executableTasks.map(t =>
[t.id, t.angle, t.description, t.focus, t.deps, t.wave]
.map(v => `"${String(v).replace(/"/g, '""')}"`)
.join(',')
)
Write(`${sessionFolder}/explore-wave-${wave}.csv`, [waveHeader, ...waveRows].join('\n'))
// 执行探索波浪
console.log(` 正在探索${executableTasks.length}个维度(波浪${wave})...`)
spawn_agents_on_csv({
csv_path: `${sessionFolder}/explore-wave-${wave}.csv`,
id_column: "id",
instruction: buildExploreInstruction(sessionFolder),
max_concurrency: maxConcurrency,
max_runtime_seconds: 300,
output_csv_path: `${sessionFolder}/explore-wave-${wave}-results.csv`,
output_schema: {
type: "object",
properties: {
id: { type: "string" },
status: { type: "string", enum: ["completed", "failed"] },
findings: { type: "string" },
key_files: { type: "array", items: { type: "string" } },
error: { type: "string" }
},
required: ["id", "status", "findings"]
}
})
// 将结果合并到explore.csv
const waveResults = parseCsv(Read(`${sessionFolder}/explore-wave-${wave}-results.csv`))
for (const result of waveResults) {
updateMasterCsvRow(`${sessionFolder}/explore.csv`, result.id, {
status: result.status,
findings: result.findings || '',
key_files: Array.isArray(result.key_files) ? result.key_files.join(';') : (result.key_files || ''),
error: result.error || ''
})
}
// 清理临时波浪CSV
Bash(`rm -f "${sessionFolder}/explore-wave-${wave}.csv" "${sessionFolder}/explore-wave-${wave}-results.csv"`)
}function buildExploreInstruction(sessionFolder) {
return `
**Success Criteria**:
- All explore angles executed
- explore.csv updated with findings and key_files
- discoveries.ndjson accumulated
---
**成功标准**:
- 所有探索维度已执行
- explore.csv已更新探索结果和关键文件
- discoveries.ndjson已积累探索发现
---const exploreCSV = parseCsv(Read(`${sessionFolder}/explore.csv`))
const completed = exploreCSV.filter(r => r.status === 'completed')
// Cross-reference: find shared files across angles
const fileRefs = {}
completed.forEach(r => {
(r.key_files || '').split(';').filter(Boolean).forEach(f => {
if (!fileRefs[f]) fileRefs[f] = []
fileRefs[f].push({ angle: r.angle, id: r.id })
})
})
const sharedFiles = Object.entries(fileRefs).filter(([_, refs]) => refs.length > 1)
// Build synthesis context for task decomposition
const synthesisContext = completed.map(r =>
`[${r.id}: ${r.angle}] ${r.findings}\n Key files: ${r.key_files || 'none'}`
).join('\n\n')
const sharedFilesContext = sharedFiles.length > 0
? `\nShared files (referenced by multiple angles):\n${sharedFiles.map(([f, refs]) =>
` ${f} ← ${refs.map(r => r.id).join(', ')}`
).join('\n')}`
: ''Bash({
command: `ccw cli -p "PURPOSE: Based on exploration findings, decompose requirement into 3-10 atomic execution tasks. Each task must include test cases, acceptance criteria, and link to relevant exploration findings.
3. **Compute Waves & Write tasks.csv**
```javascript
const { waveAssignment, maxWave } = computeWaves(decomposedTasks)
const header = 'id,title,description,test,acceptance_criteria,scope,hints,execution_directives,deps,context_from,wave,status,findings,files_modified,tests_passed,acceptance_met,error'
const rows = decomposedTasks.map(task => {
const wave = waveAssignment.get(task.id)
return [
task.id,
csvEscape(task.title),
csvEscape(task.description),
csvEscape(task.test),
csvEscape(task.acceptance_criteria),
csvEscape(task.scope),
csvEscape(task.hints),
csvEscape(task.execution_directives),
task.deps.join(';'),
task.context_from.join(';'),
wave,
'pending', '', '', '', '', ''
].map(cell => `"${String(cell).replace(/"/g, '""')}"`).join(',')
})
Write(`${sessionFolder}/tasks.csv`, [header, ...rows].join('\n'))if (!AUTO_YES) {
console.log(`const exploreCSV = parseCsv(Read(`${sessionFolder}/explore.csv`))
const completed = exploreCSV.filter(r => r.status === 'completed')
// 交叉参考:找到多个维度共享的文件
const fileRefs = {}
completed.forEach(r => {
(r.key_files || '').split(';').filter(Boolean).forEach(f => {
if (!fileRefs[f]) fileRefs[f] = []
fileRefs[f].push({ angle: r.angle, id: r.id })
})
})
const sharedFiles = Object.entries(fileRefs).filter(([_, refs]) => refs.length > 1)
// 构建任务拆解的整合上下文
const synthesisContext = completed.map(r =>
`[${r.id}: ${r.angle}] ${r.findings}\n 关键文件: ${r.key_files || '无'}`
).join('\n\n')
const sharedFilesContext = sharedFiles.length > 0
? `\n共享文件(被多个维度引用):\n${sharedFiles.map(([f, refs]) =>
` ${f} ← ${refs.map(r => r.id).join(', ')}`
).join('\n')}`
: ''Bash({
command: `ccw cli -p "PURPOSE: 基于探索结果,将需求拆解为3-10个原子执行任务。每个任务必须包含测试用例、验收标准,并关联到相关的探索结果。
3. **计算波浪并写入tasks.csv**
```javascript
const { waveAssignment, maxWave } = computeWaves(decomposedTasks)
const header = 'id,title,description,test,acceptance_criteria,scope,hints,execution_directives,deps,context_from,wave,status,findings,files_modified,tests_passed,acceptance_met,error'
const rows = decomposedTasks.map(task => {
const wave = waveAssignment.get(task.id)
return [
task.id,
csvEscape(task.title),
csvEscape(task.description),
csvEscape(task.test),
csvEscape(task.acceptance_criteria),
csvEscape(task.scope),
csvEscape(task.hints),
csvEscape(task.execution_directives),
task.deps.join(';'),
task.context_from.join(';'),
wave,
'pending', '', '', '', '', ''
].map(cell => `"${String(cell).replace(/"/g, '""')}"`).join(',')
})
Write(`${sessionFolder}/tasks.csv`, [header, ...rows].join('\n'))if (!AUTO_YES) {
console.log(`### Wave ${w} (${wt.length} tasks, concurrent) ${wt.map(t => ).join('\n')} const answer = AskUserQuestion({
questions: [{
question: `Proceed with ${decomposedTasks.length} tasks across ${maxWave} waves?`,
header: "Confirm",
multiSelect: false,
options: [
{ label: "Execute", description: "Proceed with wave execution" },
{ label: "Modify", description: `Edit ${sessionFolder}/tasks.csv then --continue` },
{ label: "Cancel", description: "Abort" }
]
}]
})
if (answer.Confirm === "Modify") {
console.log(`Edit: ${sessionFolder}/tasks.csv\nResume: $wave-plan-pipeline --continue`)
return
} else if (answer.Confirm === "Cancel") {
return
}
**Success Criteria**:
- tasks.csv created with context_from linking to E* rows
- No circular dependencies
- User approved (or AUTO_YES)
---### 波浪${w}(${wt.length}个任务,并发执行) ${wt.map(t => ).join('\n')} const answer = AskUserQuestion({
questions: [{
question: `是否继续执行${decomposedTasks.length}个任务,分布在${maxWave}个波浪中?`,
header: "确认",
multiSelect: false,
options: [
{ label: "执行", description: "继续执行波浪式任务" },
{ label: "修改", description: `编辑${sessionFolder}/tasks.csv然后使用--continue恢复` },
{ label: "取消", description: "终止流程" }
]
}]
})
if (answer.Confirm === "修改") {
console.log(`编辑: ${sessionFolder}/tasks.csv\n恢复: $wave-plan-pipeline --continue`)
return
} else if (answer.Confirm === "取消") {
return
}
**成功标准**:
- 生成包含context_from关联E*行的tasks.csv
- 无循环依赖
- 用户已批准(或使用AUTO_YES)
---spawn_agents_on_csvconst exploreCSV = parseCsv(Read(`${sessionFolder}/explore.csv`))
const failedIds = new Set()
const skippedIds = new Set()
for (let wave = 1; wave <= maxWave; wave++) {
console.log(`\n## Wave ${wave}/${maxWave}\n`)
// Re-read master CSV
const masterCsv = parseCsv(Read(`${sessionFolder}/tasks.csv`))
const waveTasks = masterCsv.filter(row => parseInt(row.wave) === wave)
// Skip tasks whose deps failed
const executableTasks = []
for (const task of waveTasks) {
const deps = (task.deps || '').split(';').filter(Boolean)
if (deps.some(d => failedIds.has(d) || skippedIds.has(d))) {
skippedIds.add(task.id)
updateMasterCsvRow(`${sessionFolder}/tasks.csv`, task.id, {
status: 'skipped',
error: 'Dependency failed or skipped'
})
console.log(` [${task.id}] ${task.title} → SKIPPED (dependency failed)`)
continue
}
executableTasks.push(task)
}
if (executableTasks.length === 0) {
console.log(` No executable tasks in wave ${wave}`)
continue
}
// Build prev_context for each task (cross-phase: E* + T*)
for (const task of executableTasks) {
task.prev_context = buildPrevContext(task.context_from, exploreCSV, masterCsv)
}
// Write wave CSV
const waveHeader = 'id,title,description,test,acceptance_criteria,scope,hints,execution_directives,deps,context_from,wave,prev_context'
const waveRows = executableTasks.map(t =>
[t.id, t.title, t.description, t.test, t.acceptance_criteria, t.scope, t.hints, t.execution_directives, t.deps, t.context_from, t.wave, t.prev_context]
.map(cell => `"${String(cell).replace(/"/g, '""')}"`)
.join(',')
)
Write(`${sessionFolder}/task-wave-${wave}.csv`, [waveHeader, ...waveRows].join('\n'))
// Execute wave
console.log(` Executing ${executableTasks.length} tasks (concurrency: ${maxConcurrency})...`)
spawn_agents_on_csv({
csv_path: `${sessionFolder}/task-wave-${wave}.csv`,
id_column: "id",
instruction: buildExecuteInstruction(sessionFolder, wave),
max_concurrency: maxConcurrency,
max_runtime_seconds: 600,
output_csv_path: `${sessionFolder}/task-wave-${wave}-results.csv`,
output_schema: {
type: "object",
properties: {
id: { type: "string" },
status: { type: "string", enum: ["completed", "failed"] },
findings: { type: "string" },
files_modified: { type: "array", items: { type: "string" } },
tests_passed: { type: "boolean" },
acceptance_met: { type: "string" },
error: { type: "string" }
},
required: ["id", "status", "findings", "tests_passed"]
}
})
// Merge results into master CSV
const waveResults = parseCsv(Read(`${sessionFolder}/task-wave-${wave}-results.csv`))
for (const result of waveResults) {
updateMasterCsvRow(`${sessionFolder}/tasks.csv`, result.id, {
status: result.status,
findings: result.findings || '',
files_modified: Array.isArray(result.files_modified) ? result.files_modified.join(';') : (result.files_modified || ''),
tests_passed: String(result.tests_passed ?? ''),
acceptance_met: result.acceptance_met || '',
error: result.error || ''
})
if (result.status === 'failed') {
failedIds.add(result.id)
console.log(` [${result.id}] → FAILED: ${result.error}`)
} else {
console.log(` [${result.id}] → COMPLETED${result.tests_passed ? ' ✓tests' : ''}`)
}
}
// Cleanup
Bash(`rm -f "${sessionFolder}/task-wave-${wave}.csv" "${sessionFolder}/task-wave-${wave}-results.csv"`)
console.log(` Wave ${wave} done: ${waveResults.filter(r => r.status === 'completed').length} completed, ${waveResults.filter(r => r.status === 'failed').length} failed`)
}function buildPrevContext(contextFrom, exploreCSV, tasksCSV) {
if (!contextFrom) return 'No previous context available'
const ids = contextFrom.split(';').filter(Boolean)
const entries = []
ids.forEach(id => {
if (id.startsWith('E')) {
// ← Look up in explore.csv (cross-phase link)
const row = exploreCSV.find(r => r.id === id)
if (row && row.status === 'completed' && row.findings) {
entries.push(`[Explore ${row.angle}] ${row.findings}`)
if (row.key_files) entries.push(` Key files: ${row.key_files}`)
}
} else if (id.startsWith('T')) {
// ← Look up in tasks.csv (same-phase link)
const row = tasksCSV.find(r => r.id === id)
if (row && row.status === 'completed' && row.findings) {
entries.push(`[Task ${row.id}: ${row.title}] ${row.findings}`)
if (row.files_modified) entries.push(` Modified: ${row.files_modified}`)
}
}
})
return entries.length > 0 ? entries.join('\n') : 'No previous context available'
}function buildExecuteInstruction(sessionFolder, wave) {
return `spawn_agents_on_csvconst exploreCSV = parseCsv(Read(`${sessionFolder}/explore.csv`))
const failedIds = new Set()
const skippedIds = new Set()
for (let wave = 1; wave <= maxWave; wave++) {
console.log(`\n## 波浪${wave}/${maxWave}\n`)
// 重新读取主CSV
const masterCsv = parseCsv(Read(`${sessionFolder}/tasks.csv`))
const waveTasks = masterCsv.filter(row => parseInt(row.wave) === wave)
// 跳过依赖失败的任务
const executableTasks = []
for (const task of waveTasks) {
const deps = (task.deps || '').split(';').filter(Boolean)
if (deps.some(d => failedIds.has(d) || skippedIds.has(d))) {
skippedIds.add(task.id)
updateMasterCsvRow(`${sessionFolder}/tasks.csv`, task.id, {
status: 'skipped',
error: '依赖失败或被跳过'
})
console.log(` [${task.id}] ${task.title} → 已跳过(依赖失败)`)
continue
}
executableTasks.push(task)
}
if (executableTasks.length === 0) {
console.log(` 波浪${wave}中无可执行任务`)
continue
}
// 为每个任务构建prev_context(跨阶段: E* + T*)
for (const task of executableTasks) {
task.prev_context = buildPrevContext(task.context_from, exploreCSV, masterCsv)
}
// 写入波浪CSV
const waveHeader = 'id,title,description,test,acceptance_criteria,scope,hints,execution_directives,deps,context_from,wave,prev_context'
const waveRows = executableTasks.map(t =>
[t.id, t.title, t.description, t.test, t.acceptance_criteria, t.scope, t.hints, t.execution_directives, t.deps, t.context_from, t.wave, t.prev_context]
.map(cell => `"${String(cell).replace(/"/g, '""')}"`)
.join(',')
)
Write(`${sessionFolder}/task-wave-${wave}.csv`, [waveHeader, ...waveRows].join('\n'))
// 执行波浪
console.log(` 正在执行${executableTasks.length}个任务(并发数: ${maxConcurrency})...`)
spawn_agents_on_csv({
csv_path: `${sessionFolder}/task-wave-${wave}.csv`,
id_column: "id",
instruction: buildExecuteInstruction(sessionFolder, wave),
max_concurrency: maxConcurrency,
max_runtime_seconds: 600,
output_csv_path: `${sessionFolder}/task-wave-${wave}-results.csv`,
output_schema: {
type: "object",
properties: {
id: { type: "string" },
status: { type: "string", enum: ["completed", "failed"] },
findings: { type: "string" },
files_modified: { type: "array", items: { type: "string" } },
tests_passed: { type: "boolean" },
acceptance_met: { type: "string" },
error: { type: "string" }
},
required: ["id", "status", "findings", "tests_passed"]
}
})
// 将结果合并到主CSV
const waveResults = parseCsv(Read(`${sessionFolder}/task-wave-${wave}-results.csv`))
for (const result of waveResults) {
updateMasterCsvRow(`${sessionFolder}/tasks.csv`, result.id, {
status: result.status,
findings: result.findings || '',
files_modified: Array.isArray(result.files_modified) ? result.files_modified.join(';') : (result.files_modified || ''),
tests_passed: String(result.tests_passed ?? ''),
acceptance_met: result.acceptance_met || '',
error: result.error || ''
})
if (result.status === 'failed') {
failedIds.add(result.id)
console.log(` [${result.id}] → 失败: ${result.error}`)
} else {
console.log(` [${result.id}] → 完成${result.tests_passed ? ' ✓测试通过' : ''}`)
}
}
// 清理临时文件
Bash(`rm -f "${sessionFolder}/task-wave-${wave}.csv" "${sessionFolder}/task-wave-${wave}-results.csv"`)
console.log(` 波浪${wave}完成: ${waveResults.filter(r => r.status === 'completed').length}个完成,${waveResults.filter(r => r.status === 'failed').length}个失败`)
}function buildPrevContext(contextFrom, exploreCSV, tasksCSV) {
if (!contextFrom) return '无可用的先前上下文'
const ids = contextFrom.split(';').filter(Boolean)
const entries = []
ids.forEach(id => {
if (id.startsWith('E')) {
// ← 从explore.csv查询(跨阶段关联)
const row = exploreCSV.find(r => r.id === id)
if (row && row.status === 'completed' && row.findings) {
entries.push(`[探索${row.angle}] ${row.findings}`)
if (row.key_files) entries.push(` 关键文件: ${row.key_files}`)
}
} else if (id.startsWith('T')) {
// ← 从tasks.csv查询(同阶段关联)
const row = tasksCSV.find(r => r.id === id)
if (row && row.status === 'completed' && row.findings) {
entries.push(`[任务${row.id}: ${row.title}] ${row.findings}`)
if (row.files_modified) entries.push(` 修改文件: ${row.files_modified}`)
}
}
})
return entries.length > 0 ? entries.join('\n') : '无可用的先前上下文'
}function buildExecuteInstruction(sessionFolder, wave) {
return `Format: `tips text || file1;file2`. Read ALL reference files (after ||) before starting. Apply tips (before ||) as guidance.
格式: `提示文本 || 文件1;文件2`。开始前请阅读||后的所有参考文件。遵循||前的提示指导。
Commands to run for verification, tool restrictions, or environment requirements.
用于验证的命令、工具限制或环境要求。
undefinedfunction updateMasterCsvRow(csvPath, taskId, updates) {
const content = Read(csvPath)
const lines = content.split('\n')
const header = lines[0].split(',')
for (let i = 1; i < lines.length; i++) {
const cells = parseCsvLine(lines[i])
if (cells[0] === taskId || cells[0] === `"${taskId}"`) {
for (const [col, val] of Object.entries(updates)) {
const colIdx = header.indexOf(col)
if (colIdx >= 0) {
cells[colIdx] = `"${String(val).replace(/"/g, '""')}"`
}
}
lines[i] = cells.join(',')
break
}
}
Write(csvPath, lines.join('\n'))
}undefinedfunction updateMasterCsvRow(csvPath, taskId, updates) {
const content = Read(csvPath)
const lines = content.split('\n')
const header = lines[0].split(',')
for (let i = 1; i < lines.length; i++) {
const cells = parseCsvLine(lines[i])
if (cells[0] === taskId || cells[0] === `"${taskId}"`) {
for (const [col, val] of Object.entries(updates)) {
const colIdx = header.indexOf(col)
if (colIdx >= 0) {
cells[colIdx] = `"${String(val).replace(/"/g, '""')}"`
}
}
lines[i] = cells.join(',')
break
}
}
Write(csvPath, lines.join('\n'))
}const masterCsv = Read(`${sessionFolder}/tasks.csv`)
Write(`${sessionFolder}/results.csv`, masterCsv)const finalTasks = parseCsv(masterCsv)
const exploreCSV = parseCsv(Read(`${sessionFolder}/explore.csv`))
const completed = finalTasks.filter(t => t.status === 'completed')
const failed = finalTasks.filter(t => t.status === 'failed')
const skipped = finalTasks.filter(t => t.status === 'skipped')
const contextContent = `# Wave Plan Execution Reportconst masterCsv = Read(`${sessionFolder}/tasks.csv`)
Write(`${sessionFolder}/results.csv`, masterCsv)const finalTasks = parseCsv(masterCsv)
const exploreCSV = parseCsv(Read(`${sessionFolder}/explore.csv`))
const completed = finalTasks.filter(t => t.status === 'completed')
const failed = finalTasks.filter(t => t.status === 'failed')
const skipped = finalTasks.filter(t => t.status === 'skipped')
const contextContent = `# 波浪式规划执行报告| Metric | Count |
|---|---|
| Explore Angles | ${exploreCSV.length} |
| Total Tasks | ${finalTasks.length} |
| Completed | ${completed.length} |
| Failed | ${failed.length} |
| Skipped | ${skipped.length} |
| Waves | ${maxWave} |
| 指标 | 数量 |
|---|---|
| 探索维度 | ${exploreCSV.length} |
| 总任务数 | ${finalTasks.length} |
| 已完成 | ${completed.length} |
| 失败 | ${failed.length} |
| 已跳过 | ${skipped.length} |
| 波浪数 | ${maxWave} |
### ${e.id}: ${e.angle} (${e.status}) ${e.findings || 'N/A'} Key files: ${e.key_files || 'none'}### ${e.id}: ${e.angle}(${e.status}) ${e.findings || '无'} 关键文件: ${e.key_files || '无'}| Field | Value |
|---|---|
| Wave | ${t.wave} |
| Scope | ${t.scope |
| Dependencies | ${t.deps |
| Context From | ${t.context_from |
| Tests Passed | ${t.tests_passed |
| Acceptance Met | ${t.acceptance_met |
| Error | ${t.error |
| 字段 | 值 |
|---|---|
| 波浪 | ${t.wave} |
| 范围 | ${t.scope |
| 依赖 | ${t.deps |
| 上下文来源 | ${t.context_from |
| 测试通过 | ${t.tests_passed |
| 验收满足 | ${t.acceptance_met |
| 错误 | ${t.error |
${sessionFolder}/context.md
3. **Display Summary**
```javascript
console.log(`${sessionFolder}/context.md
3. **显示汇总信息**
```javascript
console.log(`
4. **Offer Next Steps** (skip if AUTO_YES)
```javascript
if (!AUTO_YES && failed.length > 0) {
const answer = AskUserQuestion({
questions: [{
question: `${failed.length} tasks failed. Next action?`,
header: "Next Step",
multiSelect: false,
options: [
{ label: "Retry Failed", description: `Re-execute ${failed.length} failed tasks with updated context` },
{ label: "View Report", description: "Display context.md" },
{ label: "Done", description: "Complete session" }
]
}]
})
if (answer['Next Step'] === "Retry Failed") {
for (const task of failed) {
updateMasterCsvRow(`${sessionFolder}/tasks.csv`, task.id, { status: 'pending', error: '' })
}
for (const task of skipped) {
updateMasterCsvRow(`${sessionFolder}/tasks.csv`, task.id, { status: 'pending', error: '' })
}
// Re-execute Phase 4
} else if (answer['Next Step'] === "View Report") {
console.log(Read(`${sessionFolder}/context.md`))
}
}
4. **提供下一步操作**(若使用AUTO_YES则跳过)
```javascript
if (!AUTO_YES && failed.length > 0) {
const answer = AskUserQuestion({
questions: [{
question: `${failed.length}个任务失败。下一步操作?`,
header: "下一步",
multiSelect: false,
options: [
{ label: "重试失败任务", description: `使用更新的上下文重新执行${failed.length}个失败任务` },
{ label: "查看报告", description: "显示context.md" },
{ label: "完成", description: "结束会话" }
]
}]
})
if (answer['下一步'] === "重试失败任务") {
for (const task of failed) {
updateMasterCsvRow(`${sessionFolder}/tasks.csv`, task.id, { status: 'pending', error: '' })
}
for (const task of skipped) {
updateMasterCsvRow(`${sessionFolder}/tasks.csv`, task.id, { status: 'pending', error: '' })
}
// 重新执行阶段4
} else if (answer['下一步'] === "查看报告") {
console.log(Read(`${sessionFolder}/context.md`))
}
}function computeWaves(tasks) {
const taskMap = new Map(tasks.map(t => [t.id, t]))
const inDegree = new Map(tasks.map(t => [t.id, 0]))
const adjList = new Map(tasks.map(t => [t.id, []]))
for (const task of tasks) {
for (const dep of task.deps) {
if (taskMap.has(dep)) {
adjList.get(dep).push(task.id)
inDegree.set(task.id, inDegree.get(task.id) + 1)
}
}
}
const queue = []
const waveAssignment = new Map()
for (const [id, deg] of inDegree) {
if (deg === 0) {
queue.push([id, 1])
waveAssignment.set(id, 1)
}
}
let maxWave = 1
let idx = 0
while (idx < queue.length) {
const [current, depth] = queue[idx++]
for (const next of adjList.get(current)) {
const newDeg = inDegree.get(next) - 1
inDegree.set(next, newDeg)
const nextDepth = Math.max(waveAssignment.get(next) || 0, depth + 1)
waveAssignment.set(next, nextDepth)
if (newDeg === 0) {
queue.push([next, nextDepth])
maxWave = Math.max(maxWave, nextDepth)
}
}
}
for (const task of tasks) {
if (!waveAssignment.has(task.id)) {
throw new Error(`Circular dependency detected involving task ${task.id}`)
}
}
return { waveAssignment, maxWave }
}function computeWaves(tasks) {
const taskMap = new Map(tasks.map(t => [t.id, t]))
const inDegree = new Map(tasks.map(t => [t.id, 0]))
const adjList = new Map(tasks.map(t => [t.id, []]))
for (const task of tasks) {
for (const dep of task.deps) {
if (taskMap.has(dep)) {
adjList.get(dep).push(task.id)
inDegree.set(task.id, inDegree.get(task.id) + 1)
}
}
}
const queue = []
const waveAssignment = new Map()
for (const [id, deg] of inDegree) {
if (deg === 0) {
queue.push([id, 1])
waveAssignment.set(id, 1)
}
}
let maxWave = 1
let idx = 0
while (idx < queue.length) {
const [current, depth] = queue[idx++]
for (const next of adjList.get(current)) {
const newDeg = inDegree.get(next) - 1
inDegree.set(next, newDeg)
const nextDepth = Math.max(waveAssignment.get(next) || 0, depth + 1)
waveAssignment.set(next, nextDepth)
if (newDeg === 0) {
queue.push([next, nextDepth])
maxWave = Math.max(maxWave, nextDepth)
}
}
}
for (const task of tasks) {
if (!waveAssignment.has(task.id)) {
throw new Error(`检测到涉及任务${task.id}的循环依赖`)
}
}
return { waveAssignment, maxWave }
}discoveries.ndjson{"ts":"2026-02-28T10:00:00+08:00","worker":"E1","type":"code_pattern","data":{"name":"repository-pattern","file":"src/repos/Base.ts","description":"Abstract CRUD repository"}}
{"ts":"2026-02-28T10:01:00+08:00","worker":"T2","type":"integration_point","data":{"file":"src/auth/index.ts","description":"Auth module entry","exports":["authenticate","authorize"]}}code_patternintegration_pointconventionblockertech_stacktest_commanddiscoveries.ndjson{"ts":"2026-02-28T10:00:00+08:00","worker":"E1","type":"code_pattern","data":{"name":"repository-pattern","file":"src/repos/Base.ts","description":"抽象CRUD仓库"}}
{"ts":"2026-02-28T10:01:00+08:00","worker":"T2","type":"integration_point","data":{"file":"src/auth/index.ts","description":"认证模块入口","exports":["authenticate","authorize"]}}code_patternintegration_pointconventionblockertech_stacktest_command| Error | Resolution |
|---|---|
| Explore agent failure | Mark as failed in explore.csv, exclude from planning |
| All explores failed | Fallback: plan directly from requirement without exploration |
| Circular dependency | Abort wave computation, report cycle |
| Execute agent timeout | Mark as failed in results, continue with wave |
| Execute agent failed | Mark as failed, skip dependent tasks in later waves |
| CSV parse error | Validate CSV format before execution, show line number |
| discoveries.ndjson corrupt | Ignore malformed lines, continue with valid entries |
| Continue mode: no session | List available sessions, prompt user to select |
| 错误 | 解决方法 |
|---|---|
| 探索Agent失败 | 在explore.csv中标记为失败,规划时排除 |
| 所有探索失败 | 回退方案:不进行探索,直接基于需求规划 |
| 循环依赖 | 终止波浪计算,报告循环 |
| 执行Agent超时 | 在结果中标记为失败,继续执行波浪 |
| 执行Agent失败 | 标记为失败,后续波浪中跳过依赖任务 |
| CSV解析错误 | 执行前验证CSV格式,显示错误行号 |
| discoveries.ndjson损坏 | 忽略格式错误的行,继续使用有效条目 |
| 恢复模式:无会话 | 列出可用会话,提示用户选择 |
context_fromcontext_from-c 1-c 8-c 1-c 8| Scenario | Recommended Approach |
|---|---|
| Complex feature (unclear architecture) | |
| Simple known-pattern task | |
| Independent parallel tasks | |
| Diamond dependency (A→B,C→D) | |
| Unknown codebase | |
| 场景 | 推荐方法 |
|---|---|
| 复杂功能(架构不明确) | |
| 简单已知模式任务 | |
| 独立并行任务 | |
| 菱形依赖(A→B,C→D) | |
| 未知代码库 | |