team-uidesign

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Auto Mode

自动模式

When
--yes
or
-y
: Auto-confirm task decomposition, skip interactive validation, use defaults for scope/industry/constraints.
当传入
--yes
-y
参数时:自动确认任务拆分结果,跳过交互式校验,范围/行业/约束项均使用默认值。

Team UI Design

团队UI设计工具

Usage

使用方式

bash
$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"
Flags:
  • -y, --yes
    : Skip all confirmations (auto mode)
  • -c, --concurrency N
    : Max concurrent agents within each wave (default: 3)
  • --continue
    : Resume existing session
Output Directory:
.workflow/.csv-wave/{session-id}/
Core Output:
tasks.csv
(master state) +
results.csv
(final) +
discoveries.ndjson
(shared exploration) +
context.md
(human-readable report)

bash
$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
    : 每个批次内最大并发Agent数量(默认值:3)
  • --continue
    : 恢复已有的会话任务
输出目录:
.workflow/.csv-wave/{session-id}/
核心输出文件:
tasks.csv
(主状态文件) +
results.csv
(最终结果文件) +
discoveries.ndjson
(共享探索记录) +
context.md
(人类可读报告)

Overview

概述

Systematic UI design pipeline: research existing design system, generate design tokens (W3C Design Tokens Format), audit for quality/accessibility, and implement production code. Roles: researcher, designer, reviewer, implementer -- dynamically assigned as CSV wave tasks with dependency ordering. Supports component (4-task), system (7-task), and full-system (8-task) pipeline modes. Designer <-> Reviewer Generator-Critic loop with max 2 rounds.
Execution Model: Hybrid -- CSV wave pipeline (primary) + individual agent spawn (secondary)
+-------------------------------------------------------------------+
|                    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                     |
|                                                                     |
+-------------------------------------------------------------------+

系统化UI设计流水线:调研现有设计系统,生成design tokens(W3C Design Tokens格式),开展质量/无障碍审计,最终实现生产可用代码。角色包括:调研者、设计师、评审者、实现者——会作为CSV批次任务按依赖顺序动态分配。支持组件(4个任务)、系统(7个任务)、全系统(8个任务)三种流水线模式。设计师<->评审者的生成器-评审者(GC)循环最多支持2轮。
执行模型: 混合模式——CSV批次流水线(主) + 独立Agent调度(次)
+-------------------------------------------------------------------+
|                    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                         |
|     +- 展示汇总信息:每个批次的完成/失败/跳过数量            |
|     +- 提供选项:查看结果 | 重试失败任务 | 完成                     |
|                                                                     |
+-------------------------------------------------------------------+

Task Classification Rules

任务分类规则

Each task is classified by
exec_mode
:
exec_modeMechanismCriteria
csv-wave
spawn_agents_on_csv
One-shot, structured I/O, no multi-round interaction
interactive
spawn_agent
/
wait
/
send_input
/
close_agent
Multi-round, revision cycles, user approval
Classification Decision:
Task PropertyClassification
Design system research (researcher)
csv-wave
Token system design (designer)
csv-wave
Component specification (designer)
csv-wave
5-dimension audit (reviewer)
csv-wave
Token/component implementation (implementer)
csv-wave
GC loop fix revision (designer)
csv-wave
GC loop escalation (user decision on audit failure)
interactive
Pipeline completion action
interactive

每个任务通过
exec_mode
分类:
exec_mode执行机制判断标准
csv-wave
spawn_agents_on_csv
单次执行、结构化输入输出、无需多轮交互
interactive
spawn_agent
/
wait
/
send_input
/
close_agent
多轮执行、修改循环、需要用户审批
分类判定规则:
任务类型分类
设计系统调研(调研者)
csv-wave
Token系统设计(设计师)
csv-wave
组件规范设计(设计师)
csv-wave
5维度审计(评审者)
csv-wave
Token/组件实现(实现者)
csv-wave
GC循环修复修改(设计师)
csv-wave
GC循环升级处理(审计失败时用户决策)
interactive
流水线完成操作
interactive

CSV Schema

CSV Schema

tasks.csv (Master State)

tasks.csv(主状态文件)

csv
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","","","","",""
Columns:
ColumnPhaseDescription
id
InputUnique task identifier (PREFIX-NNN: RESEARCH, DESIGN, AUDIT, BUILD)
title
InputShort task title
description
InputDetailed task description with PURPOSE/TASK/CONTEXT/EXPECTED/CONSTRAINTS
role
InputRole name:
researcher
,
designer
,
reviewer
,
implementer
pipeline_mode
InputPipeline:
component
,
system
,
full-system
scope
InputTask scope:
full
,
tokens
,
components
audit_type
InputAudit type:
token-audit
,
component-audit
,
final-audit
(empty for non-reviewer)
deps
InputSemicolon-separated dependency task IDs
context_from
InputSemicolon-separated task IDs whose findings this task needs
exec_mode
Input
csv-wave
or
interactive
wave
ComputedWave number (computed by topological sort, 1-based)
status
Output
pending
->
completed
/
failed
/
skipped
findings
OutputKey discoveries or implementation notes (max 500 chars)
artifacts_produced
OutputSemicolon-separated paths of produced artifacts
audit_score
OutputAudit weighted score (0-10, empty for non-reviewer tasks)
audit_signal
OutputAudit signal:
audit_passed
,
audit_result
,
fix_required
(empty for non-reviewer)
error
OutputError message if failed (empty if success)
csv
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","","","","",""
列说明:
列名所属阶段描述
id
输入唯一任务标识(前缀-编号:RESEARCH, DESIGN, AUDIT, BUILD)
title
输入简短任务标题
description
输入详细任务描述,包含目的/任务/上下文/预期产出/约束
role
输入角色名称:
researcher
,
designer
,
reviewer
,
implementer
pipeline_mode
输入流水线类型:
component
,
system
,
full-system
scope
输入任务范围:
full
,
tokens
,
components
audit_type
输入审计类型:
token-audit
,
component-audit
,
final-audit
(非评审者任务为空)
deps
输入分号分隔的依赖任务ID
context_from
输入分号分隔的任务ID,当前任务需要这些任务的发现结果
exec_mode
输入
csv-wave
interactive
wave
计算生成批次编号(通过拓扑排序计算,从1开始)
status
输出
pending
->
completed
/
failed
/
skipped
findings
输出关键发现或实现说明(最多500字符)
artifacts_produced
输出分号分隔的产出物路径
audit_score
输出审计加权得分(0-10,非评审者任务为空)
audit_signal
输出审计信号:
audit_passed
,
audit_result
,
fix_required
(非评审者任务为空)
error
输出失败时的错误信息(成功时为空)

Per-Wave CSV (Temporary)

单批次CSV(临时文件)

Each wave generates a temporary
wave-{N}.csv
with extra
prev_context
column (csv-wave tasks only).

每个批次会生成临时的
wave-{N}.csv
,额外包含
prev_context
列(仅csv-wave任务)。

Agent Registry (Interactive Agents)

Agent注册中心(交互式Agent)

AgentRole FilePatternResponsibilityPosition
GC Loop Handleragents/gc-loop-handler.md2.3 (send_input cycle)Handle audit GC loop escalation decisionspost-wave
Completion Handleragents/completion-handler.md2.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 immediately
Read
the corresponding agent.md
to reload.

Agent角色文件匹配模式职责执行位置
GC循环处理Agentagents/gc-loop-handler.md2.3 (send_input 循环)处理审计GC循环升级决策批次后
完成处理Agentagents/completion-handler.md2.3 (send_input 循环)处理流水线完成操作(归档/保留/导出)独立执行
精简保护机制: Agent文件是执行文档。当发生上下文压缩时,你必须立即读取对应的agent.md文件重新加载内容。

Output Artifacts

输出产物

FilePurposeLifecycle
tasks.csv
Master state -- all tasks with status/findingsUpdated after each wave
wave-{N}.csv
Per-wave input (temporary, csv-wave tasks only)Created before wave, deleted after
results.csv
Final export of all task resultsCreated in Phase 4
discoveries.ndjson
Shared exploration board (all agents, both modes)Append-only, carries across waves
context.md
Human-readable execution reportCreated in Phase 4
task-analysis.json
Phase 0/1 output: scope, pipeline, industryCreated in Phase 1
role-instructions/
Per-role instruction templates for CSV agentsCreated in Phase 1
artifacts/
All deliverables: research, design, audit, build artifactsCreated by agents
interactive/{id}-result.json
Results from interactive tasksCreated per interactive task

文件名用途生命周期
tasks.csv
主状态文件——所有任务的状态/发现结果每个批次执行完后更新
wave-{N}.csv
单批次输入(临时文件,仅csv-wave任务)批次执行前创建,执行完后删除
results.csv
所有任务结果的最终导出文件阶段4创建
discoveries.ndjson
共享探索看板(所有Agent,两种模式通用)仅追加,跨批次保留
context.md
人类可读的执行报告阶段4创建
task-analysis.json
阶段0/1输出:范围、流水线、行业阶段1创建
role-instructions/
CSV Agent的分角色指令模板阶段1创建
artifacts/
所有交付物:调研、设计、审计、构建产物Agent执行时创建
interactive/{id}-result.json
交互式任务的执行结果每个交互式任务完成后创建

Session Structure

会话目录结构

.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.md

Implementation

实现逻辑

Session Initialization

会话初始化

javascript
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')

javascript
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')

Phase 0: Pre-Wave Interactive (Requirement Clarification)

阶段0: 批次前交互(需求澄清)

Objective: Parse UI design task, clarify scope/industry/constraints, prepare for decomposition.
Workflow:
  1. Parse user task description from $ARGUMENTS
  2. Check for existing sessions (continue mode):
    • Scan
      .workflow/.csv-wave/uds-*/tasks.csv
      for sessions with pending tasks
    • If
      --continue
      : resume the specified or most recent session, skip to Phase 2
    • If active session found: ask user whether to resume or start new
  3. Clarify scope and industry (skip if AUTO_YES):
    Scope Selection:
    OptionPipelineTask Count
    Single componentcomponent4 tasks (linear)
    Component systemsystem7 tasks (dual-track parallel)
    Full design systemfull-system8 tasks (dual-track + final audit)
    Industry Selection:
    OptionStrictness
    SaaS/Techstandard
    E-commerce/Retailstandard
    Healthcare/Financestrict (extra accessibility)
    Education/Contentstandard
    Otherstandard
  4. Signal Detection for pipeline selection:
    SignalKeywordsPipeline Hint
    Componentcomponent, button, card, input, modalcomponent
    Systemdesign system, token, theme, multiple componentssystem
    Fullcomplete, full, all components, redesignfull-system
    Accessibilityaccessibility, a11y, wcagcomponent or system
  5. Complexity Scoring:
    FactorPoints
    Single component+1
    Component system+2
    Full design system+3
    Accessibility required+1
    Multiple industries/constraints+1
    Results: 1-2 component, 3-4 system, 5+ full-system.
  6. Industry Detection:
    KeywordsIndustry
    saas, dashboard, analyticsSaaS/Tech
    shop, cart, checkoutE-commerce
    medical, patient, healthcareHealthcare
    bank, finance, paymentFinance
    edu, course, learningEducation/Content
    DefaultSaaS/Tech
  7. Record: pipeline_mode, industry, complexity
Success Criteria:
  • Scope, industry, constraints determined
  • Pipeline mode selected (component/system/full-system)

目标: 解析UI设计任务,明确范围/行业/约束,为任务拆分做准备。
工作流:
  1. 从$ARGUMENTS中解析用户任务描述
  2. 检查现有会话(继续模式):
    • 扫描
      .workflow/.csv-wave/uds-*/tasks.csv
      ,查找存在待处理任务的会话
    • 如果传入
      --continue
      :恢复指定的或最近的会话,直接跳转到阶段2
    • 如果找到活跃会话:询问用户是否恢复或新建会话
  3. 明确范围和行业(AUTO_YES模式下跳过):
    范围选择:
    选项流水线类型任务数量
    单个组件component4个任务(线性)
    组件系统system7个任务(双轨并行)
    全量设计系统full-system8个任务(双轨+最终审计)
    行业选择:
    选项严格度
    SaaS/科技标准
    电商/零售标准
    医疗/金融严格(额外无障碍要求)
    教育/内容标准
    其他标准
  4. 信号检测,用于选择流水线类型:
    信号关键词流水线建议
    组件component, button, card, input, modalcomponent
    系统design system, token, theme, multiple componentssystem
    全量complete, full, all components, redesignfull-system
    无障碍accessibility, a11y, wcagcomponent 或 system
  5. 复杂度评分:
    因素得分
    单个组件+1
    组件系统+2
    全量设计系统+3
    需要无障碍支持+1
    多个行业/约束+1
    结果判定:1-2分用component模式,3-4分用system模式,5分及以上用full-system模式。
  6. 行业检测:
    关键词行业
    saas, dashboard, analyticsSaaS/科技
    shop, cart, checkout电商
    medical, patient, healthcare医疗
    bank, finance, payment金融
    edu, course, learning教育/内容
    默认SaaS/科技
  7. 记录:pipeline_mode, industry, complexity
成功标准:
  • 已确定范围、行业、约束
  • 已选择流水线模式(component/system/full-system)

Phase 1: Requirement -> CSV + Classification

阶段1: 需求转化为CSV + 任务分类

Objective: Build task dependency graph, generate tasks.csv and per-role instruction templates.
Decomposition Rules:
  1. Pipeline Selection based on scope:
    ScopePipelineTasks
    componentRESEARCH-001 -> DESIGN-001 -> AUDIT-001 -> BUILD-0014
    systemRESEARCH-001 -> DESIGN-001 -> AUDIT-001 -> [DESIGN-002 + BUILD-001] -> AUDIT-002 -> BUILD-0027
    full-systemsystem chain + AUDIT-003 after BUILD-0028
  2. Task Description Template: Every task description uses PURPOSE/TASK/CONTEXT/EXPECTED/CONSTRAINTS format
  3. Role Instruction Generation: Write per-role instruction templates to
    role-instructions/{role}.md
    using the base instruction template customized for each role (researcher, designer, reviewer, implementer)
Classification Rules:
Task Propertyexec_mode
Research analysis pass (researcher)
csv-wave
Token design pass (designer)
csv-wave
Component spec pass (designer)
csv-wave
Audit pass (reviewer)
csv-wave
Implementation pass (implementer)
csv-wave
GC fix revision (designer)
csv-wave
All standard pipeline tasks
csv-wave
Wave Computation: Kahn's BFS topological sort with depth tracking.
javascript
// 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))
User Validation: Display task breakdown with wave + exec_mode assignment (skip if AUTO_YES).
Success Criteria:
  • tasks.csv created with valid schema, wave, and exec_mode assignments
  • Role instruction templates generated in role-instructions/
  • task-analysis.json written
  • No circular dependencies
  • User approved (or AUTO_YES)

目标: 构建任务依赖图,生成tasks.csv和分角色指令模板。
拆分规则:
  1. 基于范围选择流水线:
    范围流水线任务流任务数量
    componentRESEARCH-001 -> DESIGN-001 -> AUDIT-001 -> BUILD-0014
    systemRESEARCH-001 -> DESIGN-001 -> AUDIT-001 -> [DESIGN-002 + BUILD-001] -> AUDIT-002 -> BUILD-0027
    full-systemsystem流水线 + BUILD-002后新增AUDIT-0038
  2. 任务描述模板: 每个任务描述都使用目的/任务/上下文/预期产出/约束的格式
  3. 角色指令生成: 使用基础指令模板为每个角色(调研者、设计师、评审者、实现者)定制内容,写入
    role-instructions/{role}.md
分类规则:
任务类型exec_mode
调研分析(调研者)
csv-wave
Token设计(设计师)
csv-wave
组件规范设计(设计师)
csv-wave
审计(评审者)
csv-wave
实现(实现者)
csv-wave
GC修复修改(设计师)
csv-wave
所有标准流水线任务
csv-wave
批次计算: 使用带深度跟踪的Kahn BFS拓扑排序算法。
javascript
// 生成分角色指令模板
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))
用户确认: 展示带批次和exec_mode分配的任务拆分结果(AUTO_YES模式下跳过)。
成功标准:
  • 已创建符合schema的tasks.csv,包含批次和exec_mode分配
  • 已在role-instructions/目录下生成角色指令模板
  • 已写入task-analysis.json
  • 无循环依赖
  • 已获得用户批准(或AUTO_YES模式)

Phase 2: Wave Execution Engine (Extended)

阶段2: 批次执行引擎(扩展版)

Objective: Execute tasks wave-by-wave with hybrid mechanism support and cross-wave context propagation.
javascript
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`)
}
Success Criteria:
  • All waves executed in order
  • Both csv-wave and interactive tasks handled per wave
  • Each wave's results merged into master CSV before next wave starts
  • Dependent tasks skipped when predecessor failed
  • GC loop (designer <-> reviewer) handled with max 2 rounds
  • discoveries.ndjson accumulated across all waves and mechanisms

目标: 逐批次执行任务,支持混合执行机制和跨批次上下文传递。
javascript
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`)
}
成功标准:
  • 所有批次按顺序执行完成
  • 每个批次的csv-wave和交互式任务都得到处理
  • 下一批次开始前,当前批次的结果已合并到主CSV
  • 前置任务失败时,依赖任务被跳过
  • 设计师<->评审者的GC循环最多执行2轮
  • 所有批次和执行机制的结果都已累计到discoveries.ndjson

Phase 3: Post-Wave Interactive (Completion Action)

阶段3: 批次后交互(完成操作)

Objective: Pipeline completion report with deliverables listing and interactive completion choice.
javascript
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 })
}
Success Criteria:
  • Post-wave interactive processing complete
  • User informed of deliverables and pipeline status

目标: 输出流水线完成报告,附带交付物清单,提供交互式完成选择。
javascript
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 })
}
成功标准:
  • 批次后交互处理完成
  • 用户已获知交付物和流水线状态

Phase 4: Results Aggregation

阶段4: 结果聚合

Objective: Generate final results and human-readable report.
javascript
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`)
Success Criteria:
  • results.csv exported (all tasks, both modes)
  • context.md generated with audit summary
  • Summary displayed to user

目标: 生成最终结果和人类可读报告。
javascript
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`)
成功标准:
  • 已导出results.csv(包含两种模式的所有任务)
  • 已生成带审计汇总的context.md
  • 已向用户展示汇总信息

Shared Discovery Board Protocol

共享探索看板协议

All agents (csv-wave and interactive) share a single
discoveries.ndjson
file for cross-task knowledge exchange.
Format: One JSON object per line (NDJSON):
jsonl
{"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"}}
Discovery Types:
TypeData SchemaDescription
tech_stack_detected
{stack, framework, ui_lib}
Tech stack identified by researcher
design_pattern_found
{pattern_name, location, description}
Existing design pattern in codebase
token_generated
{category, count, supports_dark_mode}
Design token category created
file_modified
{file, change, lines_added}
File change recorded
issue_found
{file, line, severity, description}
Audit issue discovered
anti_pattern_violation
{pattern, file, line, description}
Design anti-pattern detected
artifact_produced
{name, path, producer, type}
Deliverable created
Protocol:
  1. Agents MUST read discoveries.ndjson at start of execution
  2. Agents MUST append relevant discoveries during execution
  3. Agents MUST NOT modify or delete existing entries
  4. Deduplication by
    {type, data.file}
    key

所有Agent(csv-wave和交互式)共享单个
discoveries.ndjson
文件,用于跨任务知识交换。
格式: 每行一个JSON对象(NDJSON):
jsonl
{"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"}}
发现类型:
类型数据结构描述
tech_stack_detected
{stack, framework, ui_lib}
调研者识别的技术栈
design_pattern_found
{pattern_name, location, description}
代码库中已有的设计模式
token_generated
{category, count, supports_dark_mode}
已创建的design token类别
file_modified
{file, change, lines_added}
文件变更记录
issue_found
{file, line, severity, description}
发现的审计问题
anti_pattern_violation
{pattern, file, line, description}
检测到的设计反模式
artifact_produced
{name, path, producer, type}
已创建的交付物
协议规则:
  1. Agent执行开始时必须读取discoveries.ndjson
  2. Agent执行过程中必须追加相关的发现结果
  3. Agent禁止修改或删除已有的条目
  4. {type, data.file}
    键去重

Pipeline Definitions

流水线定义

Component Mode (4 tasks, linear)

组件模式(4个任务,线性)

RESEARCH-001 --> DESIGN-001 --> AUDIT-001 --> BUILD-001
[researcher]     [designer]     [reviewer]    [implementer]
   wave 1          wave 2         wave 3        wave 4
RESEARCH-001 --> DESIGN-001 --> AUDIT-001 --> BUILD-001
[researcher]     [designer]     [reviewer]    [implementer]
   wave 1          wave 2         wave 3        wave 4

System Mode (7 tasks, dual-track parallel)

系统模式(7个任务,双轨并行)

RESEARCH-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 6
RESEARCH-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 6

Full-System Mode (8 tasks, dual-track + final audit)

全系统模式(8个任务,双轨+最终审计)

Same 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 7

Generator-Critic Loop (designer <-> reviewer)

生成器-评审者循环(设计师<->评审者)

designer (Generator) -> design artifacts -> reviewer (Critic)
                      <- audit feedback  <-
                         (max 2 rounds)

Convergence: audit.score >= 8 AND audit.critical_count === 0

designer (Generator) -> design artifacts -> reviewer (Critic)
                      <- audit feedback  <-
                         最多2轮

收敛条件:audit.score >= 8 且 audit.critical_count === 0

Error Handling

错误处理

ErrorResolution
Circular dependencyDetect in wave computation, abort with error message
CSV agent timeoutMark as failed in results, continue with wave
CSV agent failedMark as failed, skip dependent tasks in later waves
Interactive agent timeoutUrge convergence via send_input, then close if still timed out
Interactive agent failedMark as failed, skip dependents
All agents in wave failedLog error, offer retry or abort
CSV parse errorValidate CSV format before execution, show line number
discoveries.ndjson corruptIgnore malformed lines, continue with valid entries
Audit score < 6 over 2 GC roundsEscalate to user for manual intervention
ui-ux-pro-max unavailableDegrade to LLM general design knowledge
Task description too vagueAskUserQuestion for clarification in Phase 0
Continue mode: no session foundList 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中询问用户澄清
继续模式:未找到会话列出可用会话,提示用户选择

Core Rules

核心规则

  1. Start Immediately: First action is session initialization, then Phase 0/1
  2. Wave Order is Sacred: Never execute wave N before wave N-1 completes and results are merged
  3. CSV is Source of Truth: Master tasks.csv holds all state (both csv-wave and interactive)
  4. CSV First: Default to csv-wave for tasks; only use interactive when interaction pattern requires it
  5. Context Propagation: prev_context built from master CSV, not from memory
  6. Discovery Board is Append-Only: Never clear, modify, or recreate discoveries.ndjson
  7. Skip on Failure: If a dependency failed, skip the dependent task
  8. GC Loop Cap: Max 2 generator-critic rounds between designer and reviewer
  9. Cleanup Temp Files: Remove wave-{N}.csv after results are merged
  10. DO NOT STOP: Continuous execution until all waves complete or all remaining tasks are skipped

  1. 立即启动: 第一个动作是会话初始化,然后进入阶段0/1
  2. 批次顺序不可修改: 批次N-1执行完成且结果合并前,绝对不能执行批次N
  3. CSV是唯一可信源: 主tasks.csv保存所有状态(csv-wave和交互式任务通用)
  4. CSV优先: 任务默认使用csv-wave模式,仅当交互模式需要时才使用交互式
  5. 上下文传递: prev_context从主CSV构建,而非内存
  6. 探索看板仅追加: 绝对不能清空、修改或重建discoveries.ndjson
  7. 失败即跳过: 如果依赖任务失败,跳过当前依赖任务
  8. GC循环上限: 设计师和评审者之间最多2轮生成-评审循环
  9. 清理临时文件: 结果合并完成后删除wave-{N}.csv临时文件
  10. 不得停止: 持续执行直到所有批次完成或剩余任务全部被跳过

Coordinator Role Constraints (Main Agent)

协调者角色约束(主Agent)

CRITICAL: The coordinator (main agent executing this skill) is responsible for orchestration only, NOT implementation.
  1. Coordinator Does NOT Execute Code: The main agent MUST NOT write, modify, or implement any code directly. All implementation work is delegated to spawned team agents. The coordinator only:
    • Spawns agents with task assignments
    • Waits for agent callbacks
    • Merges results and coordinates workflow
    • Manages workflow transitions between phases
  2. Patient Waiting is Mandatory: Agent execution takes significant time (typically 10-30 minutes per phase, sometimes longer). The coordinator MUST:
    • Wait patiently for
      wait()
      calls to complete
    • NOT skip workflow steps due to perceived delays
    • NOT assume agents have failed just because they're taking time
    • Trust the timeout mechanisms defined in the skill
  3. Use send_input for Clarification: When agents need guidance or appear stuck, the coordinator MUST:
    • Use
      send_input()
      to ask questions or provide clarification
    • NOT skip the agent or move to next phase prematurely
    • Give agents opportunity to respond before escalating
    • Example:
      send_input({ id: agent_id, message: "Please provide status update or clarify blockers" })
  4. No Workflow Shortcuts: The coordinator MUST NOT:
    • Skip phases or stages defined in the workflow
    • Bypass required approval or review steps
    • Execute dependent tasks before prerequisites complete
    • Assume task completion without explicit agent callback
    • Make up or fabricate agent results
  5. Respect Long-Running Processes: This is a complex multi-agent workflow that requires patience:
    • Total execution time may range from 30-90 minutes or longer
    • Each phase may take 10-30 minutes depending on complexity
    • The coordinator must remain active and attentive throughout the entire process
    • Do not terminate or skip steps due to time concerns
关键: 执行本工具的协调者(主Agent)仅负责编排调度,不负责具体实现。
  1. 协调者不执行代码: 主Agent绝对不能直接编写、修改或实现任何代码。所有实现工作都委派给调度的团队Agent。协调者仅负责:
    • 给Agent分配任务并调度
    • 等待Agent回调结果
    • 合并结果、协调工作流
    • 管理各阶段之间的工作流跳转
  2. 必须耐心等待: Agent执行需要较长时间(通常每个阶段10-30分钟,有时更长)。协调者必须:
    • 耐心等待
      wait()
      调用完成
    • 不能因为感知到延迟就跳过工作流步骤
    • 不能仅因为Agent执行时间长就判定为失败
    • 信任本工具中定义的超时机制
  3. 使用send_input澄清: 当Agent需要指引或看起来卡住时,协调者必须:
    • 使用
      send_input()
      提问或提供澄清信息
    • 不能提前跳过Agent或进入下一个阶段
    • 在升级处理前给Agent响应的机会
    • 示例:
      send_input({ id: agent_id, message: "Please provide status update or clarify blockers" })
  4. 不得简化工作流: 协调者绝对不能:
    • 跳过工作流定义的阶段或步骤
    • 绕过必要的审批或评审步骤
    • 前置条件完成前执行依赖任务
    • 没有明确的Agent回调就假设任务完成
    • 编造或伪造Agent结果
  5. 尊重长时运行流程: 这是复杂的多Agent工作流,需要耐心:
    • 总执行时间可能在30-90分钟或更长
    • 每个阶段根据复杂度可能需要10-30分钟
    • 协调者在整个过程中必须保持活跃和专注
    • 不要因为时间问题终止或跳过步骤