Loading...
Loading...
Compare original and translation side by side
--yes-y--yes-y$team-uidesign "Design a button component with tokens and accessibility"
$team-uidesign -c 3 "Create a complete design system for our SaaS dashboard"
$team-uidesign -y "Full design system redesign for healthcare portal"
$team-uidesign --continue "uds-saas-dashboard-20260308"-y, --yes-c, --concurrency N--continue.workflow/.csv-wave/{session-id}/tasks.csvresults.csvdiscoveries.ndjsoncontext.md$team-uidesign "Design a button component with tokens and accessibility"
$team-uidesign -c 3 "Create a complete design system for our SaaS dashboard"
$team-uidesign -y "Full design system redesign for healthcare portal"
$team-uidesign --continue "uds-saas-dashboard-20260308"-y, --yes-c, --concurrency N--continue.workflow/.csv-wave/{session-id}/tasks.csvresults.csvdiscoveries.ndjsoncontext.md+-------------------------------------------------------------------+
| TEAM UI DESIGN WORKFLOW |
+-------------------------------------------------------------------+
| |
| Phase 0: Pre-Wave Interactive (Requirement Clarification) |
| +- Parse UI design task description |
| +- Select scope (component/system/full-system), industry |
| +- Output: refined requirements for decomposition |
| |
| Phase 1: Requirement -> CSV + Classification |
| +- Signal detection: keyword scan -> pipeline inference |
| +- Pipeline selection (component/system/full-system) |
| +- Dependency graph from pipeline definition |
| +- Classify tasks: csv-wave | interactive (exec_mode) |
| +- Compute dependency waves (topological sort) |
| +- Generate tasks.csv with wave + exec_mode columns |
| +- User validates task breakdown (skip if -y) |
| |
| Phase 2: Wave Execution Engine (Extended) |
| +- For each wave (1..N): |
| | +- Execute pre-wave interactive tasks (if any) |
| | +- Build wave CSV (filter csv-wave tasks for this wave) |
| | +- Inject previous findings into prev_context column |
| | +- spawn_agents_on_csv(wave CSV) |
| | +- Execute post-wave interactive tasks (if any) |
| | +- Merge all results into master tasks.csv |
| | +- Check: any failed? -> skip dependents |
| | +- GC Loop: if audit fails, create DESIGN-fix + AUDIT-re |
| +- discoveries.ndjson shared across all modes (append-only) |
| |
| Phase 3: Post-Wave Interactive (Completion Action) |
| +- Pipeline completion report with deliverables listing |
| +- Interactive completion choice (Archive/Keep/Export) |
| +- Final aggregation / report |
| |
| Phase 4: Results Aggregation |
| +- Export final results.csv |
| +- Generate context.md with all findings |
| +- Display summary: completed/failed/skipped per wave |
| +- Offer: view results | retry failed | done |
| |
+-------------------------------------------------------------------++-------------------------------------------------------------------+
| TEAM UI DESIGN WORKFLOW |
+-------------------------------------------------------------------+
| |
| 阶段0: 批次前交互(需求澄清) |
| +- 解析UI设计任务描述 |
| +- 选择范围(组件/系统/全系统)、行业 |
| +- 输出:经过细化的可拆分需求 |
| |
| 阶段1: 需求转化为CSV + 任务分类 |
| +- 信号检测:关键词扫描 -> 流水线推断 |
| +- 选择流水线类型(组件/系统/全系统) |
| +- 基于流水线定义生成依赖图 |
| +- 任务分类:csv-wave | 交互式(exec_mode) |
| +- 计算依赖批次(拓扑排序) |
| +- 生成带批次和exec_mode列的tasks.csv |
| +- 用户确认任务拆分结果(传入-y参数时跳过) |
| |
| 阶段2: 批次执行引擎(扩展版) |
| +- 遍历每个批次(1..N): |
| | +- 执行批次前的交互式任务(如果存在) |
| | +- 构建批次CSV(筛选当前批次的csv-wave任务) |
| | +- 将之前的发现注入到prev_context列 |
| | +- spawn_agents_on_csv(当前批次CSV) |
| | +- 执行批次后的交互式任务(如果存在) |
| | +- 合并所有结果到主tasks.csv |
| | +- 检查:是否有任务失败? -> 跳过其依赖任务 |
| | +- GC循环:如果审计失败,创建设计修复任务 + 重审计任务 |
| +- discoveries.ndjson在所有模式下共享(仅追加) |
| |
| 阶段3: 批次后交互(完成操作) |
| +- 流水线完成报告,附带交付物清单 |
| +- 交互式完成选择(归档/保留/导出) |
| +- 最终聚合/生成报告 |
| |
| 阶段4: 结果聚合 |
| +- 导出最终results.csv |
| +- 生成包含所有发现的context.md |
| +- 展示汇总信息:每个批次的完成/失败/跳过数量 |
| +- 提供选项:查看结果 | 重试失败任务 | 完成 |
| |
+-------------------------------------------------------------------+exec_mode| exec_mode | Mechanism | Criteria |
|---|---|---|
| | One-shot, structured I/O, no multi-round interaction |
| | Multi-round, revision cycles, user approval |
| Task Property | Classification |
|---|---|
| Design system research (researcher) | |
| Token system design (designer) | |
| Component specification (designer) | |
| 5-dimension audit (reviewer) | |
| Token/component implementation (implementer) | |
| GC loop fix revision (designer) | |
| GC loop escalation (user decision on audit failure) | |
| Pipeline completion action | |
exec_mode| exec_mode | 执行机制 | 判断标准 |
|---|---|---|
| | 单次执行、结构化输入输出、无需多轮交互 |
| | 多轮执行、修改循环、需要用户审批 |
| 任务类型 | 分类 |
|---|---|
| 设计系统调研(调研者) | |
| Token系统设计(设计师) | |
| 组件规范设计(设计师) | |
| 5维度审计(评审者) | |
| Token/组件实现(实现者) | |
| GC循环修复修改(设计师) | |
| GC循环升级处理(审计失败时用户决策) | |
| 流水线完成操作 | |
id,title,description,role,pipeline_mode,scope,audit_type,deps,context_from,exec_mode,wave,status,findings,artifacts_produced,audit_score,audit_signal,error
"RESEARCH-001","Design system analysis","PURPOSE: Analyze existing design system...","researcher","component","full","","","","csv-wave","1","pending","","","","",""
"DESIGN-001","Design tokens + component spec","PURPOSE: Define design tokens...","designer","component","tokens","","RESEARCH-001","RESEARCH-001","csv-wave","2","pending","","","","",""
"AUDIT-001","Design audit","PURPOSE: 5-dimension quality audit...","reviewer","component","full","token-audit","DESIGN-001","DESIGN-001","csv-wave","3","pending","","","","",""| Column | Phase | Description |
|---|---|---|
| Input | Unique task identifier (PREFIX-NNN: RESEARCH, DESIGN, AUDIT, BUILD) |
| Input | Short task title |
| Input | Detailed task description with PURPOSE/TASK/CONTEXT/EXPECTED/CONSTRAINTS |
| Input | Role name: |
| Input | Pipeline: |
| Input | Task scope: |
| Input | Audit type: |
| Input | Semicolon-separated dependency task IDs |
| Input | Semicolon-separated task IDs whose findings this task needs |
| Input | |
| Computed | Wave number (computed by topological sort, 1-based) |
| Output | |
| Output | Key discoveries or implementation notes (max 500 chars) |
| Output | Semicolon-separated paths of produced artifacts |
| Output | Audit weighted score (0-10, empty for non-reviewer tasks) |
| Output | Audit signal: |
| Output | Error message if failed (empty if success) |
id,title,description,role,pipeline_mode,scope,audit_type,deps,context_from,exec_mode,wave,status,findings,artifacts_produced,audit_score,audit_signal,error
"RESEARCH-001","Design system analysis","PURPOSE: Analyze existing design system...","researcher","component","full","","","","csv-wave","1","pending","","","","",""
"DESIGN-001","Design tokens + component spec","PURPOSE: Define design tokens...","designer","component","tokens","","RESEARCH-001","RESEARCH-001","csv-wave","2","pending","","","","",""
"AUDIT-001","Design audit","PURPOSE: 5-dimension quality audit...","reviewer","component","full","token-audit","DESIGN-001","DESIGN-001","csv-wave","3","pending","","","","",""| 列名 | 所属阶段 | 描述 |
|---|---|---|
| 输入 | 唯一任务标识(前缀-编号:RESEARCH, DESIGN, AUDIT, BUILD) |
| 输入 | 简短任务标题 |
| 输入 | 详细任务描述,包含目的/任务/上下文/预期产出/约束 |
| 输入 | 角色名称: |
| 输入 | 流水线类型: |
| 输入 | 任务范围: |
| 输入 | 审计类型: |
| 输入 | 分号分隔的依赖任务ID |
| 输入 | 分号分隔的任务ID,当前任务需要这些任务的发现结果 |
| 输入 | |
| 计算生成 | 批次编号(通过拓扑排序计算,从1开始) |
| 输出 | |
| 输出 | 关键发现或实现说明(最多500字符) |
| 输出 | 分号分隔的产出物路径 |
| 输出 | 审计加权得分(0-10,非评审者任务为空) |
| 输出 | 审计信号: |
| 输出 | 失败时的错误信息(成功时为空) |
wave-{N}.csvprev_contextwave-{N}.csvprev_context| Agent | Role File | Pattern | Responsibility | Position |
|---|---|---|---|---|
| GC Loop Handler | agents/gc-loop-handler.md | 2.3 (send_input cycle) | Handle audit GC loop escalation decisions | post-wave |
| Completion Handler | agents/completion-handler.md | 2.3 (send_input cycle) | Handle pipeline completion action (Archive/Keep/Export) | standalone |
COMPACT PROTECTION: Agent files are execution documents. When context compression occurs, you MUST immediatelythe corresponding agent.md to reload.Read
| Agent | 角色文件 | 匹配模式 | 职责 | 执行位置 |
|---|---|---|---|---|
| GC循环处理Agent | agents/gc-loop-handler.md | 2.3 (send_input 循环) | 处理审计GC循环升级决策 | 批次后 |
| 完成处理Agent | agents/completion-handler.md | 2.3 (send_input 循环) | 处理流水线完成操作(归档/保留/导出) | 独立执行 |
精简保护机制: Agent文件是执行文档。当发生上下文压缩时,你必须立即读取对应的agent.md文件重新加载内容。
| File | Purpose | Lifecycle |
|---|---|---|
| Master state -- all tasks with status/findings | Updated after each wave |
| Per-wave input (temporary, csv-wave tasks only) | Created before wave, deleted after |
| Final export of all task results | Created in Phase 4 |
| Shared exploration board (all agents, both modes) | Append-only, carries across waves |
| Human-readable execution report | Created in Phase 4 |
| Phase 0/1 output: scope, pipeline, industry | Created in Phase 1 |
| Per-role instruction templates for CSV agents | Created in Phase 1 |
| All deliverables: research, design, audit, build artifacts | Created by agents |
| Results from interactive tasks | Created per interactive task |
| 文件名 | 用途 | 生命周期 |
|---|---|---|
| 主状态文件——所有任务的状态/发现结果 | 每个批次执行完后更新 |
| 单批次输入(临时文件,仅csv-wave任务) | 批次执行前创建,执行完后删除 |
| 所有任务结果的最终导出文件 | 阶段4创建 |
| 共享探索看板(所有Agent,两种模式通用) | 仅追加,跨批次保留 |
| 人类可读的执行报告 | 阶段4创建 |
| 阶段0/1输出:范围、流水线、行业 | 阶段1创建 |
| CSV Agent的分角色指令模板 | 阶段1创建 |
| 所有交付物:调研、设计、审计、构建产物 | Agent执行时创建 |
| 交互式任务的执行结果 | 每个交互式任务完成后创建 |
.workflow/.csv-wave/{session-id}/
+-- tasks.csv # Master state (all tasks, both modes)
+-- results.csv # Final results export
+-- discoveries.ndjson # Shared discovery board (all agents)
+-- context.md # Human-readable report
+-- task-analysis.json # Phase 1 analysis output
+-- wave-{N}.csv # Temporary per-wave input (csv-wave only)
+-- role-instructions/ # Per-role instruction templates
| +-- researcher.md
| +-- designer.md
| +-- reviewer.md
| +-- implementer.md
+-- artifacts/ # All deliverables
| +-- research/
| | +-- design-system-analysis.json
| | +-- component-inventory.json
| | +-- accessibility-audit.json
| | +-- design-intelligence.json
| +-- design/
| | +-- design-tokens.json
| | +-- component-specs/
| | +-- layout-specs/
| +-- audit/
| | +-- audit-001.md
| +-- build/
| +-- token-files/
| +-- component-files/
+-- interactive/ # Interactive task artifacts
| +-- {id}-result.json
+-- wisdom/ # Cross-task knowledge
+-- learnings.md
+-- decisions.md.workflow/.csv-wave/{session-id}/
+-- tasks.csv # 主状态文件(所有任务,两种模式通用)
+-- results.csv # 最终结果导出文件
+-- discoveries.ndjson # 共享探索看板(所有Agent)
+-- context.md # 人类可读报告
+-- task-analysis.json # 阶段1分析输出
+-- wave-{N}.csv # 临时单批次输入(仅csv-wave任务)
+-- role-instructions/ # 分角色指令模板
| +-- researcher.md
| +-- designer.md
| +-- reviewer.md
| +-- implementer.md
+-- artifacts/ # 所有交付物
| +-- research/
| | +-- design-system-analysis.json
| | +-- component-inventory.json
| | +-- accessibility-audit.json
| | +-- design-intelligence.json
| +-- design/
| | +-- design-tokens.json
| | +-- component-specs/
| | +-- layout-specs/
| +-- audit/
| | +-- audit-001.md
| +-- build/
| +-- token-files/
| +-- component-files/
+-- interactive/ # 交互式任务产物
| +-- {id}-result.json
+-- wisdom/ # 跨任务知识
+-- learnings.md
+-- decisions.mdconst 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]) : 3
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 = `uds-${slug}-${dateStr}`
const sessionFolder = `.workflow/.csv-wave/${sessionId}`
Bash(`mkdir -p ${sessionFolder}/artifacts/research ${sessionFolder}/artifacts/design/component-specs ${sessionFolder}/artifacts/design/layout-specs ${sessionFolder}/artifacts/audit ${sessionFolder}/artifacts/build/token-files ${sessionFolder}/artifacts/build/component-files ${sessionFolder}/role-instructions ${sessionFolder}/interactive ${sessionFolder}/wisdom`)
Write(`${sessionFolder}/discoveries.ndjson`, '')
Write(`${sessionFolder}/wisdom/learnings.md`, '# Learnings\n')
Write(`${sessionFolder}/wisdom/decisions.md`, '# Decisions\n')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]) : 3
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 = `uds-${slug}-${dateStr}`
const sessionFolder = `.workflow/.csv-wave/${sessionId}`
Bash(`mkdir -p ${sessionFolder}/artifacts/research ${sessionFolder}/artifacts/design/component-specs ${sessionFolder}/artifacts/design/layout-specs ${sessionFolder}/artifacts/audit ${sessionFolder}/artifacts/build/token-files ${sessionFolder}/artifacts/build/component-files ${sessionFolder}/role-instructions ${sessionFolder}/interactive ${sessionFolder}/wisdom`)
Write(`${sessionFolder}/discoveries.ndjson`, '')
Write(`${sessionFolder}/wisdom/learnings.md`, '# Learnings\n')
Write(`${sessionFolder}/wisdom/decisions.md`, '# Decisions\n').workflow/.csv-wave/uds-*/tasks.csv--continue| Option | Pipeline | Task Count |
|---|---|---|
| Single component | component | 4 tasks (linear) |
| Component system | system | 7 tasks (dual-track parallel) |
| Full design system | full-system | 8 tasks (dual-track + final audit) |
| Option | Strictness |
|---|---|
| SaaS/Tech | standard |
| E-commerce/Retail | standard |
| Healthcare/Finance | strict (extra accessibility) |
| Education/Content | standard |
| Other | standard |
| Signal | Keywords | Pipeline Hint |
|---|---|---|
| Component | component, button, card, input, modal | component |
| System | design system, token, theme, multiple components | system |
| Full | complete, full, all components, redesign | full-system |
| Accessibility | accessibility, a11y, wcag | component or system |
| Factor | Points |
|---|---|
| Single component | +1 |
| Component system | +2 |
| Full design system | +3 |
| Accessibility required | +1 |
| Multiple industries/constraints | +1 |
| Keywords | Industry |
|---|---|
| saas, dashboard, analytics | SaaS/Tech |
| shop, cart, checkout | E-commerce |
| medical, patient, healthcare | Healthcare |
| bank, finance, payment | Finance |
| edu, course, learning | Education/Content |
| Default | SaaS/Tech |
.workflow/.csv-wave/uds-*/tasks.csv--continue| 选项 | 流水线类型 | 任务数量 |
|---|---|---|
| 单个组件 | component | 4个任务(线性) |
| 组件系统 | system | 7个任务(双轨并行) |
| 全量设计系统 | full-system | 8个任务(双轨+最终审计) |
| 选项 | 严格度 |
|---|---|
| SaaS/科技 | 标准 |
| 电商/零售 | 标准 |
| 医疗/金融 | 严格(额外无障碍要求) |
| 教育/内容 | 标准 |
| 其他 | 标准 |
| 信号 | 关键词 | 流水线建议 |
|---|---|---|
| 组件 | component, button, card, input, modal | component |
| 系统 | design system, token, theme, multiple components | system |
| 全量 | complete, full, all components, redesign | full-system |
| 无障碍 | accessibility, a11y, wcag | component 或 system |
| 因素 | 得分 |
|---|---|
| 单个组件 | +1 |
| 组件系统 | +2 |
| 全量设计系统 | +3 |
| 需要无障碍支持 | +1 |
| 多个行业/约束 | +1 |
| 关键词 | 行业 |
|---|---|
| saas, dashboard, analytics | SaaS/科技 |
| shop, cart, checkout | 电商 |
| medical, patient, healthcare | 医疗 |
| bank, finance, payment | 金融 |
| edu, course, learning | 教育/内容 |
| 默认 | SaaS/科技 |
| Scope | Pipeline | Tasks |
|---|---|---|
| component | RESEARCH-001 -> DESIGN-001 -> AUDIT-001 -> BUILD-001 | 4 |
| system | RESEARCH-001 -> DESIGN-001 -> AUDIT-001 -> [DESIGN-002 + BUILD-001] -> AUDIT-002 -> BUILD-002 | 7 |
| full-system | system chain + AUDIT-003 after BUILD-002 | 8 |
role-instructions/{role}.md| Task Property | exec_mode |
|---|---|
| Research analysis pass (researcher) | |
| Token design pass (designer) | |
| Component spec pass (designer) | |
| Audit pass (reviewer) | |
| Implementation pass (implementer) | |
| GC fix revision (designer) | |
| All standard pipeline tasks | |
// Generate per-role instruction templates
for (const role of ['researcher', 'designer', 'reviewer', 'implementer']) {
const instruction = generateRoleInstruction(role, sessionFolder)
Write(`${sessionFolder}/role-instructions/${role}.md`, instruction)
}
// Generate tasks.csv from pipeline definition
const tasks = buildTasksCsv(pipelineMode, requirement, sessionFolder, industry, constraints)
Write(`${sessionFolder}/tasks.csv`, toCsv(tasks))
Write(`${sessionFolder}/task-analysis.json`, JSON.stringify(analysisResult, null, 2))| 范围 | 流水线任务流 | 任务数量 |
|---|---|---|
| component | RESEARCH-001 -> DESIGN-001 -> AUDIT-001 -> BUILD-001 | 4 |
| system | RESEARCH-001 -> DESIGN-001 -> AUDIT-001 -> [DESIGN-002 + BUILD-001] -> AUDIT-002 -> BUILD-002 | 7 |
| full-system | system流水线 + BUILD-002后新增AUDIT-003 | 8 |
role-instructions/{role}.md| 任务类型 | exec_mode |
|---|---|
| 调研分析(调研者) | |
| Token设计(设计师) | |
| 组件规范设计(设计师) | |
| 审计(评审者) | |
| 实现(实现者) | |
| GC修复修改(设计师) | |
| 所有标准流水线任务 | |
// 生成分角色指令模板
for (const role of ['researcher', 'designer', 'reviewer', 'implementer']) {
const instruction = generateRoleInstruction(role, sessionFolder)
Write(`${sessionFolder}/role-instructions/${role}.md`, instruction)
}
// 从流水线定义生成tasks.csv
const tasks = buildTasksCsv(pipelineMode, requirement, sessionFolder, industry, constraints)
Write(`${sessionFolder}/tasks.csv`, toCsv(tasks))
Write(`${sessionFolder}/task-analysis.json`, JSON.stringify(analysisResult, null, 2))const masterCsv = Read(`${sessionFolder}/tasks.csv`)
let tasks = parseCsv(masterCsv)
const maxWave = Math.max(...tasks.map(t => t.wave))
let gcRound = 0
const MAX_GC_ROUNDS = 2
for (let wave = 1; wave <= maxWave; wave++) {
console.log(`\nWave ${wave}/${maxWave}`)
// 1. Separate tasks by exec_mode
const waveTasks = tasks.filter(t => t.wave === wave && t.status === 'pending')
const csvTasks = waveTasks.filter(t => t.exec_mode === 'csv-wave')
const interactiveTasks = waveTasks.filter(t => t.exec_mode === 'interactive')
// 2. Check dependencies -- skip tasks whose deps failed
for (const task of waveTasks) {
const depIds = (task.deps || '').split(';').filter(Boolean)
const depStatuses = depIds.map(id => tasks.find(t => t.id === id)?.status)
if (depStatuses.some(s => s === 'failed' || s === 'skipped')) {
task.status = 'skipped'
task.error = `Dependency failed: ${depIds.filter((id, i) =>
['failed','skipped'].includes(depStatuses[i])).join(', ')}`
}
}
// 3. Execute pre-wave interactive tasks (if any)
const preWaveInteractive = interactiveTasks.filter(t => t.status === 'pending')
for (const task of preWaveInteractive) {
Read(`agents/gc-loop-handler.md`)
const agent = spawn_agent({
message: `## TASK ASSIGNMENT\n\n### MANDATORY FIRST STEPS\n1. Read: agents/gc-loop-handler.md\n2. Read: ${sessionFolder}/discoveries.ndjson\n\nGoal: ${task.description}\nScope: ${task.title}\nSession: ${sessionFolder}\n\n### Previous Context\n${buildPrevContext(task, tasks)}`
})
const result = wait({ ids: [agent], timeout_ms: 600000 })
if (result.timed_out) {
send_input({ id: agent, message: "Please finalize and output current findings." })
wait({ ids: [agent], timeout_ms: 120000 })
}
Write(`${sessionFolder}/interactive/${task.id}-result.json`, JSON.stringify({
task_id: task.id, status: "completed", findings: parseFindings(result),
timestamp: getUtc8ISOString()
}))
close_agent({ id: agent })
task.status = 'completed'
task.findings = parseFindings(result)
}
// 4. Build prev_context for csv-wave tasks
const pendingCsvTasks = csvTasks.filter(t => t.status === 'pending')
for (const task of pendingCsvTasks) {
task.prev_context = buildPrevContext(task, tasks)
}
if (pendingCsvTasks.length > 0) {
// 5. Write wave CSV
Write(`${sessionFolder}/wave-${wave}.csv`, toCsv(pendingCsvTasks))
// 6. Build instruction per role group
const waveInstruction = buildWaveInstruction(pendingCsvTasks, sessionFolder, wave)
// 7. Execute wave via spawn_agents_on_csv
spawn_agents_on_csv({
csv_path: `${sessionFolder}/wave-${wave}.csv`,
id_column: "id",
instruction: waveInstruction,
max_concurrency: maxConcurrency,
max_runtime_seconds: 900,
output_csv_path: `${sessionFolder}/wave-${wave}-results.csv`,
output_schema: {
type: "object",
properties: {
id: { type: "string" },
status: { type: "string", enum: ["completed", "failed"] },
findings: { type: "string" },
artifacts_produced: { type: "string" },
audit_score: { type: "string" },
audit_signal: { type: "string" },
error: { type: "string" }
}
}
})
// 8. Merge results into master CSV
const results = parseCsv(Read(`${sessionFolder}/wave-${wave}-results.csv`))
for (const r of results) {
const t = tasks.find(t => t.id === r.id)
if (t) Object.assign(t, r)
}
// 9. GC Loop Check: if a reviewer task returned fix_required
const auditResults = results.filter(r => r.id.startsWith('AUDIT') && r.audit_signal === 'fix_required')
for (const ar of auditResults) {
if (gcRound < MAX_GC_ROUNDS) {
gcRound++
const fixId = `DESIGN-fix-${gcRound}`
const recheckId = `AUDIT-recheck-${gcRound}`
tasks.push({
id: fixId, title: `Fix audit issues (round ${gcRound})`,
description: `PURPOSE: Address audit feedback from ${ar.id} | Success: All critical/high issues resolved\nTASK:\n- Parse audit feedback for specific issues\n- Apply targeted fixes to design tokens/specs\n- Re-validate affected artifacts\nCONTEXT:\n- Session: ${sessionFolder}\n- Upstream: artifacts/audit/\nEXPECTED: Fixed design artifacts\nCONSTRAINTS: Targeted fixes only`,
role: 'designer', pipeline_mode: tasks[0].pipeline_mode, scope: 'full',
audit_type: '', deps: ar.id, context_from: ar.id,
exec_mode: 'csv-wave', wave: wave + 1, status: 'pending',
findings: '', artifacts_produced: '', audit_score: '', audit_signal: '', error: ''
})
tasks.push({
id: recheckId, title: `Audit recheck (round ${gcRound})`,
description: `PURPOSE: Re-audit after fixes | Success: Score >= 8, critical == 0\nTASK:\n- Execute 5-dimension audit on fixed artifacts\n- Focus on previously flagged issues\nCONTEXT:\n- Session: ${sessionFolder}\n- Audit type: token-audit\nEXPECTED: artifacts/audit/audit-recheck-${gcRound}.md`,
role: 'reviewer', pipeline_mode: tasks[0].pipeline_mode, scope: 'full',
audit_type: 'token-audit', deps: fixId, context_from: fixId,
exec_mode: 'csv-wave', wave: wave + 2, status: 'pending',
findings: '', artifacts_produced: '', audit_score: '', audit_signal: '', error: ''
})
}
}
}
// 10. Update master CSV
Write(`${sessionFolder}/tasks.csv`, toCsv(tasks))
// 11. Cleanup temp files
Bash(`rm -f ${sessionFolder}/wave-${wave}.csv ${sessionFolder}/wave-${wave}-results.csv`)
// 12. Display wave summary
const completed = waveTasks.filter(t => t.status === 'completed').length
const failed = waveTasks.filter(t => t.status === 'failed').length
const skipped = waveTasks.filter(t => t.status === 'skipped').length
console.log(`Wave ${wave} Complete: ${completed} completed, ${failed} failed, ${skipped} skipped`)
}const masterCsv = Read(`${sessionFolder}/tasks.csv`)
let tasks = parseCsv(masterCsv)
const maxWave = Math.max(...tasks.map(t => t.wave))
let gcRound = 0
const MAX_GC_ROUNDS = 2
for (let wave = 1; wave <= maxWave; wave++) {
console.log(`\nWave ${wave}/${maxWave}`)
// 1. 按exec_mode拆分任务
const waveTasks = tasks.filter(t => t.wave === wave && t.status === 'pending')
const csvTasks = waveTasks.filter(t => t.exec_mode === 'csv-wave')
const interactiveTasks = waveTasks.filter(t => t.exec_mode === 'interactive')
// 2. 检查依赖——依赖失败的任务直接跳过
for (const task of waveTasks) {
const depIds = (task.deps || '').split(';').filter(Boolean)
const depStatuses = depIds.map(id => tasks.find(t => t.id === id)?.status)
if (depStatuses.some(s => s === 'failed' || s === 'skipped')) {
task.status = 'skipped'
task.error = `Dependency failed: ${depIds.filter((id, i) =>
['failed','skipped'].includes(depStatuses[i])).join(', ')}`
}
}
// 3. 执行批次前的交互式任务(如果存在)
const preWaveInteractive = interactiveTasks.filter(t => t.status === 'pending')
for (const task of preWaveInteractive) {
Read(`agents/gc-loop-handler.md`)
const agent = spawn_agent({
message: `## TASK ASSIGNMENT\n\n### MANDATORY FIRST STEPS\n1. Read: agents/gc-loop-handler.md\n2. Read: ${sessionFolder}/discoveries.ndjson\n\nGoal: ${task.description}\nScope: ${task.title}\nSession: ${sessionFolder}\n\n### Previous Context\n${buildPrevContext(task, tasks)}`
})
const result = wait({ ids: [agent], timeout_ms: 600000 })
if (result.timed_out) {
send_input({ id: agent, message: "Please finalize and output current findings." })
wait({ ids: [agent], timeout_ms: 120000 })
}
Write(`${sessionFolder}/interactive/${task.id}-result.json`, JSON.stringify({
task_id: task.id, status: "completed", findings: parseFindings(result),
timestamp: getUtc8ISOString()
}))
close_agent({ id: agent })
task.status = 'completed'
task.findings = parseFindings(result)
}
// 4. 为csv-wave任务构建prev_context
const pendingCsvTasks = csvTasks.filter(t => t.status === 'pending')
for (const task of pendingCsvTasks) {
task.prev_context = buildPrevContext(task, tasks)
}
if (pendingCsvTasks.length > 0) {
// 5. 写入批次CSV
Write(`${sessionFolder}/wave-${wave}.csv`, toCsv(pendingCsvTasks))
// 6. 按角色组分批构建指令
const waveInstruction = buildWaveInstruction(pendingCsvTasks, sessionFolder, wave)
// 7. 通过spawn_agents_on_csv执行批次任务
spawn_agents_on_csv({
csv_path: `${sessionFolder}/wave-${wave}.csv`,
id_column: "id",
instruction: waveInstruction,
max_concurrency: maxConcurrency,
max_runtime_seconds: 900,
output_csv_path: `${sessionFolder}/wave-${wave}-results.csv`,
output_schema: {
type: "object",
properties: {
id: { type: "string" },
status: { type: "string", enum: ["completed", "failed"] },
findings: { type: "string" },
artifacts_produced: { type: "string" },
audit_score: { type: "string" },
audit_signal: { type: "string" },
error: { type: "string" }
}
}
})
// 8. 合并结果到主CSV
const results = parseCsv(Read(`${sessionFolder}/wave-${wave}-results.csv`))
for (const r of results) {
const t = tasks.find(t => t.id === r.id)
if (t) Object.assign(t, r)
}
// 9. GC循环检查:如果评审任务返回fix_required
const auditResults = results.filter(r => r.id.startsWith('AUDIT') && r.audit_signal === 'fix_required')
for (const ar of auditResults) {
if (gcRound < MAX_GC_ROUNDS) {
gcRound++
const fixId = `DESIGN-fix-${gcRound}`
const recheckId = `AUDIT-recheck-${gcRound}`
tasks.push({
id: fixId, title: `Fix audit issues (round ${gcRound})`,
description: `PURPOSE: Address audit feedback from ${ar.id} | Success: All critical/high issues resolved\nTASK:\n- Parse audit feedback for specific issues\n- Apply targeted fixes to design tokens/specs\n- Re-validate affected artifacts\nCONTEXT:\n- Session: ${sessionFolder}\n- Upstream: artifacts/audit/\nEXPECTED: Fixed design artifacts\nCONSTRAINTS: Targeted fixes only`,
role: 'designer', pipeline_mode: tasks[0].pipeline_mode, scope: 'full',
audit_type: '', deps: ar.id, context_from: ar.id,
exec_mode: 'csv-wave', wave: wave + 1, status: 'pending',
findings: '', artifacts_produced: '', audit_score: '', audit_signal: '', error: ''
})
tasks.push({
id: recheckId, title: `Audit recheck (round ${gcRound})`,
description: `PURPOSE: Re-audit after fixes | Success: Score >= 8, critical == 0\nTASK:\n- Execute 5-dimension audit on fixed artifacts\n- Focus on previously flagged issues\nCONTEXT:\n- Session: ${sessionFolder}\n- Audit type: token-audit\nEXPECTED: artifacts/audit/audit-recheck-${gcRound}.md`,
role: 'reviewer', pipeline_mode: tasks[0].pipeline_mode, scope: 'full',
audit_type: 'token-audit', deps: fixId, context_from: fixId,
exec_mode: 'csv-wave', wave: wave + 2, status: 'pending',
findings: '', artifacts_produced: '', audit_score: '', audit_signal: '', error: ''
})
}
}
}
// 10. 更新主CSV
Write(`${sessionFolder}/tasks.csv`, toCsv(tasks))
// 11. 清理临时文件
Bash(`rm -f ${sessionFolder}/wave-${wave}.csv ${sessionFolder}/wave-${wave}-results.csv`)
// 12. 展示批次汇总信息
const completed = waveTasks.filter(t => t.status === 'completed').length
const failed = waveTasks.filter(t => t.status === 'failed').length
const skipped = waveTasks.filter(t => t.status === 'skipped').length
console.log(`Wave ${wave} Complete: ${completed} completed, ${failed} failed, ${skipped} skipped`)
}const tasks = parseCsv(Read(`${sessionFolder}/tasks.csv`))
const completed = tasks.filter(t => t.status === 'completed')
const failed = tasks.filter(t => t.status === 'failed')
const deliverables = [
{ name: "Design System Analysis", path: `${sessionFolder}/artifacts/research/design-system-analysis.json` },
{ name: "Component Inventory", path: `${sessionFolder}/artifacts/research/component-inventory.json` },
{ name: "Accessibility Audit", path: `${sessionFolder}/artifacts/research/accessibility-audit.json` },
{ name: "Design Intelligence", path: `${sessionFolder}/artifacts/research/design-intelligence.json` },
{ name: "Design Tokens", path: `${sessionFolder}/artifacts/design/design-tokens.json` },
{ name: "Component Specs", path: `${sessionFolder}/artifacts/design/component-specs/` },
{ name: "Audit Reports", path: `${sessionFolder}/artifacts/audit/` },
{ name: "Token Files", path: `${sessionFolder}/artifacts/build/token-files/` },
{ name: "Component Files", path: `${sessionFolder}/artifacts/build/component-files/` }
]
console.log(`
============================================
UI DESIGN TEAM COMPLETE
Pipeline: ${completed.length}/${tasks.length} tasks (${tasks[0]?.pipeline_mode} mode)
GC Rounds: ${gcRound}/${MAX_GC_ROUNDS}
Session: ${sessionFolder}
Deliverables:
${deliverables.map(d => ` - ${d.name}: ${d.path}`).join('\n')}
============================================
`)
if (!AUTO_YES) {
// Spawn completion handler interactive agent
Read(`agents/completion-handler.md`)
const agent = spawn_agent({
message: `## TASK ASSIGNMENT\n\n### MANDATORY FIRST STEPS\n1. Read: agents/completion-handler.md\n2. Read: ${sessionFolder}/tasks.csv\n\nGoal: Handle pipeline completion action\nSession: ${sessionFolder}\nDeliverables: ${JSON.stringify(deliverables)}`
})
const result = wait({ ids: [agent], timeout_ms: 300000 })
close_agent({ id: agent })
}const tasks = parseCsv(Read(`${sessionFolder}/tasks.csv`))
const completed = tasks.filter(t => t.status === 'completed')
const failed = tasks.filter(t => t.status === 'failed')
const deliverables = [
{ name: "Design System Analysis", path: `${sessionFolder}/artifacts/research/design-system-analysis.json` },
{ name: "Component Inventory", path: `${sessionFolder}/artifacts/research/component-inventory.json` },
{ name: "Accessibility Audit", path: `${sessionFolder}/artifacts/research/accessibility-audit.json` },
{ name: "Design Intelligence", path: `${sessionFolder}/artifacts/research/design-intelligence.json` },
{ name: "Design Tokens", path: `${sessionFolder}/artifacts/design/design-tokens.json` },
{ name: "Component Specs", path: `${sessionFolder}/artifacts/design/component-specs/` },
{ name: "Audit Reports", path: `${sessionFolder}/artifacts/audit/` },
{ name: "Token Files", path: `${sessionFolder}/artifacts/build/token-files/` },
{ name: "Component Files", path: `${sessionFolder}/artifacts/build/component-files/` }
]
console.log(`
============================================
UI DESIGN TEAM COMPLETE
Pipeline: ${completed.length}/${tasks.length} tasks (${tasks[0]?.pipeline_mode} mode)
GC Rounds: ${gcRound}/${MAX_GC_ROUNDS}
Session: ${sessionFolder}
Deliverables:
${deliverables.map(d => ` - ${d.name}: ${d.path}`).join('\n')}
============================================
`)
if (!AUTO_YES) {
// 调度完成处理交互式Agent
Read(`agents/completion-handler.md`)
const agent = spawn_agent({
message: `## TASK ASSIGNMENT\n\n### MANDATORY FIRST STEPS\n1. Read: agents/completion-handler.md\n2. Read: ${sessionFolder}/tasks.csv\n\nGoal: Handle pipeline completion action\nSession: ${sessionFolder}\nDeliverables: ${JSON.stringify(deliverables)}`
})
const result = wait({ ids: [agent], timeout_ms: 300000 })
close_agent({ id: agent })
}Bash(`cp ${sessionFolder}/tasks.csv ${sessionFolder}/results.csv`)
const tasks = parseCsv(Read(`${sessionFolder}/tasks.csv`))
let contextMd = `# UI Design Report\n\n`
contextMd += `**Session**: ${sessionId}\n`
contextMd += `**Pipeline**: ${tasks[0]?.pipeline_mode} mode\n`
contextMd += `**Date**: ${getUtc8ISOString().substring(0, 10)}\n\n`
contextMd += `## Summary\n`
contextMd += `| Status | Count |\n|--------|-------|\n`
contextMd += `| Completed | ${tasks.filter(t => t.status === 'completed').length} |\n`
contextMd += `| Failed | ${tasks.filter(t => t.status === 'failed').length} |\n`
contextMd += `| Skipped | ${tasks.filter(t => t.status === 'skipped').length} |\n\n`
const maxWave = Math.max(...tasks.map(t => t.wave))
contextMd += `## Wave Execution\n\n`
for (let w = 1; w <= maxWave; w++) {
const waveTasks = tasks.filter(t => t.wave === w)
contextMd += `### Wave ${w}\n\n`
for (const t of waveTasks) {
const icon = t.status === 'completed' ? '[DONE]' : t.status === 'failed' ? '[FAIL]' : '[SKIP]'
contextMd += `${icon} **${t.title}** [${t.role}]`
if (t.audit_score) contextMd += ` Score: ${t.audit_score}/10 (${t.audit_signal})`
contextMd += ` ${t.findings || ''}\n\n`
}
}
contextMd += `## Audit Summary\n\n`
const auditResults = tasks.filter(t => t.role === 'reviewer' && t.audit_score)
for (const a of auditResults) {
contextMd += `- **${a.id}**: Score ${a.audit_score}/10 - ${a.audit_signal}\n`
}
contextMd += `\n## GC Loop Summary\n`
contextMd += `- Rounds used: ${gcRound}/${MAX_GC_ROUNDS}\n`
Write(`${sessionFolder}/context.md`, contextMd)
console.log(`Results exported to: ${sessionFolder}/results.csv`)
console.log(`Report generated at: ${sessionFolder}/context.md`)Bash(`cp ${sessionFolder}/tasks.csv ${sessionFolder}/results.csv`)
const tasks = parseCsv(Read(`${sessionFolder}/tasks.csv`))
let contextMd = `# UI Design Report\n\n`
contextMd += `**Session**: ${sessionId}\n`
contextMd += `**Pipeline**: ${tasks[0]?.pipeline_mode} mode\n`
contextMd += `**Date**: ${getUtc8ISOString().substring(0, 10)}\n\n`
contextMd += `## Summary\n`
contextMd += `| Status | Count |\n|--------|-------|\n`
contextMd += `| Completed | ${tasks.filter(t => t.status === 'completed').length} |\n`
contextMd += `| Failed | ${tasks.filter(t => t.status === 'failed').length} |\n`
contextMd += `| Skipped | ${tasks.filter(t => t.status === 'skipped').length} |\n\n`
const maxWave = Math.max(...tasks.map(t => t.wave))
contextMd += `## Wave Execution\n\n`
for (let w = 1; w <= maxWave; w++) {
const waveTasks = tasks.filter(t => t.wave === w)
contextMd += `### Wave ${w}\n\n`
for (const t of waveTasks) {
const icon = t.status === 'completed' ? '[DONE]' : t.status === 'failed' ? '[FAIL]' : '[SKIP]'
contextMd += `${icon} **${t.title}** [${t.role}]`
if (t.audit_score) contextMd += ` Score: ${t.audit_score}/10 (${t.audit_signal})`
contextMd += ` ${t.findings || ''}\n\n`
}
}
contextMd += `## Audit Summary\n\n`
const auditResults = tasks.filter(t => t.role === 'reviewer' && t.audit_score)
for (const a of auditResults) {
contextMd += `- **${a.id}**: Score ${a.audit_score}/10 - ${a.audit_signal}\n`
}
contextMd += `\n## GC Loop Summary\n`
contextMd += `- Rounds used: ${gcRound}/${MAX_GC_ROUNDS}\n`
Write(`${sessionFolder}/context.md`, contextMd)
console.log(`Results exported to: ${sessionFolder}/results.csv`)
console.log(`Report generated at: ${sessionFolder}/context.md`)discoveries.ndjson{"ts":"2026-03-08T10:00:00Z","worker":"RESEARCH-001","type":"tech_stack_detected","data":{"stack":"react","framework":"nextjs","ui_lib":"shadcn"}}
{"ts":"2026-03-08T10:05:00Z","worker":"DESIGN-001","type":"token_generated","data":{"category":"color","count":24,"supports_dark_mode":true}}
{"ts":"2026-03-08T10:10:00Z","worker":"BUILD-001","type":"file_modified","data":{"file":"tokens.css","change":"Generated CSS custom properties","lines_added":85}}
{"ts":"2026-03-08T10:15:00Z","worker":"AUDIT-001","type":"issue_found","data":{"file":"design-tokens.json","line":0,"severity":"high","description":"Missing dark mode variant for semantic color tokens"}}| Type | Data Schema | Description |
|---|---|---|
| | Tech stack identified by researcher |
| | Existing design pattern in codebase |
| | Design token category created |
| | File change recorded |
| | Audit issue discovered |
| | Design anti-pattern detected |
| | Deliverable created |
{type, data.file}discoveries.ndjson{"ts":"2026-03-08T10:00:00Z","worker":"RESEARCH-001","type":"tech_stack_detected","data":{"stack":"react","framework":"nextjs","ui_lib":"shadcn"}}
{"ts":"2026-03-08T10:05:00Z","worker":"DESIGN-001","type":"token_generated","data":{"category":"color","count":24,"supports_dark_mode":true}}
{"ts":"2026-03-08T10:10:00Z","worker":"BUILD-001","type":"file_modified","data":{"file":"tokens.css","change":"Generated CSS custom properties","lines_added":85}}
{"ts":"2026-03-08T10:15:00Z","worker":"AUDIT-001","type":"issue_found","data":{"file":"design-tokens.json","line":0,"severity":"high","description":"Missing dark mode variant for semantic color tokens"}}| 类型 | 数据结构 | 描述 |
|---|---|---|
| | 调研者识别的技术栈 |
| | 代码库中已有的设计模式 |
| | 已创建的design token类别 |
| | 文件变更记录 |
| | 发现的审计问题 |
| | 检测到的设计反模式 |
| | 已创建的交付物 |
{type, data.file}RESEARCH-001 --> DESIGN-001 --> AUDIT-001 --> BUILD-001
[researcher] [designer] [reviewer] [implementer]
wave 1 wave 2 wave 3 wave 4RESEARCH-001 --> DESIGN-001 --> AUDIT-001 --> BUILD-001
[researcher] [designer] [reviewer] [implementer]
wave 1 wave 2 wave 3 wave 4RESEARCH-001 --> DESIGN-001 --> AUDIT-001 --> DESIGN-002 --+
[researcher] [designer] [reviewer] [designer] |
BUILD-001 --+--> AUDIT-002 --> BUILD-002
[implementer] [reviewer] [implementer]
wave 1 wave 2 wave 3 wave 4 wave 5 wave 6RESEARCH-001 --> DESIGN-001 --> AUDIT-001 --> DESIGN-002 --+
[researcher] [designer] [reviewer] [designer] |
BUILD-001 --+--> AUDIT-002 --> BUILD-002
[implementer] [reviewer] [implementer]
wave 1 wave 2 wave 3 wave 4 wave 5 wave 6Same as System + AUDIT-003 after BUILD-002
BUILD-002 --> AUDIT-003
[reviewer: final-audit]
wave 6 wave 7和系统模式一致,在BUILD-002后新增AUDIT-003
BUILD-002 --> AUDIT-003
[reviewer: final-audit]
wave 6 wave 7designer (Generator) -> design artifacts -> reviewer (Critic)
<- audit feedback <-
(max 2 rounds)
Convergence: audit.score >= 8 AND audit.critical_count === 0designer (Generator) -> design artifacts -> reviewer (Critic)
<- audit feedback <-
最多2轮
收敛条件:audit.score >= 8 且 audit.critical_count === 0| Error | Resolution |
|---|---|
| Circular dependency | Detect in wave computation, abort with error message |
| CSV agent timeout | Mark as failed in results, continue with wave |
| CSV agent failed | Mark as failed, skip dependent tasks in later waves |
| Interactive agent timeout | Urge convergence via send_input, then close if still timed out |
| Interactive agent failed | Mark as failed, skip dependents |
| All agents in wave failed | Log error, offer retry or abort |
| CSV parse error | Validate CSV format before execution, show line number |
| discoveries.ndjson corrupt | Ignore malformed lines, continue with valid entries |
| Audit score < 6 over 2 GC rounds | Escalate to user for manual intervention |
| ui-ux-pro-max unavailable | Degrade to LLM general design knowledge |
| Task description too vague | AskUserQuestion for clarification in Phase 0 |
| Continue mode: no session found | List available sessions, prompt user to select |
| 错误 | 解决方案 |
|---|---|
| 循环依赖 | 批次计算阶段检测到后,输出错误信息终止执行 |
| CSV Agent超时 | 在结果中标记为失败,继续执行当前批次 |
| CSV Agent执行失败 | 标记为失败,跳过后续批次中依赖该任务的任务 |
| 交互式Agent超时 | 通过send_input催促收敛,若仍超时则关闭 |
| 交互式Agent执行失败 | 标记为失败,跳过依赖任务 |
| 批次内所有Agent都失败 | 记录错误,提供重试或终止选项 |
| CSV解析错误 | 执行前校验CSV格式,展示出错行号 |
| discoveries.ndjson损坏 | 忽略格式错误的行,继续使用有效条目 |
| 2轮GC循环后审计得分仍<6 | 升级到用户手动干预 |
| ui-ux-pro-max不可用 | 降级使用LLM通用设计知识 |
| 任务描述过于模糊 | 阶段0中询问用户澄清 |
| 继续模式:未找到会话 | 列出可用会话,提示用户选择 |
wait()send_input()send_input({ id: agent_id, message: "Please provide status update or clarify blockers" })wait()send_input()send_input({ id: agent_id, message: "Please provide status update or clarify blockers" })