brainstorm-to-cycle

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Brainstorm to Cycle Adapter

Brainstorm to Cycle 适配器

Overview

概述

Bridge workflow that converts brainstorm-with-file output to parallel-dev-cycle input. Reads synthesis.json, allows user to select an idea, and formats it as an enriched TASK description.
Core workflow: Load Session → Select Idea → Format Task → Launch Cycle
这是一个桥接工作流,可将brainstorm-with-file的输出转换为parallel-dev-cycle的输入。它会读取synthesis.json文件,允许用户选择创意,并将其格式化为增强型TASK描述。
核心工作流:加载会话 → 选择创意 → 格式化任务 → 启动Cycle

Inputs

输入参数

ArgumentRequiredDescription
--sessionYesBrainstorm session ID (e.g.,
BS-rate-limiting-2025-01-28
)
--ideaNoPre-select idea by index (0-based, from top_ideas)
--autoNoAuto-select top-scored idea without confirmation
--launchNoAuto-launch parallel-dev-cycle without preview
参数是否必填描述
--session头脑风暴会话ID(例如:
BS-rate-limiting-2025-01-28
--idea通过索引预先选择创意(从0开始,对应top_ideas中的条目)
--auto自动选择得分最高的创意,无需确认
--launch自动启动parallel-dev-cycle,无需预览

Output

输出结果

Launches
/parallel-dev-cycle
with enriched TASK containing:
  • Primary recommendation or selected idea
  • Key strengths and challenges
  • Suggested implementation steps
  • Alternative approaches for reference
启动
/parallel-dev-cycle
,传入包含以下内容的增强型TASK:
  • 主要建议或选中的创意
  • 核心优势与挑战
  • 建议的实施步骤
  • 供参考的替代方案

Execution Process

执行流程

Phase 1: Session Loading
   ├─ Validate session folder exists
   ├─ Read synthesis.json
   ├─ Parse top_ideas and recommendations
   └─ Validate data structure

Phase 2: Idea Selection
   ├─ --auto mode → Select highest scored idea
   ├─ --idea=N → Select specified index
   └─ Interactive → Present options, await selection

Phase 3: Task Formatting
   ├─ Build enriched task description
   ├─ Include context from brainstorm
   └─ Generate parallel-dev-cycle command

Phase 4: Cycle Launch
   ├─ Confirm with user (unless --auto)
   └─ Execute parallel-dev-cycle
Phase 1: Session Loading
   ├─ Validate session folder exists
   ├─ Read synthesis.json
   ├─ Parse top_ideas and recommendations
   └─ Validate data structure

Phase 2: Idea Selection
   ├─ --auto mode → Select highest scored idea
   ├─ --idea=N → Select specified index
   └─ Interactive → Present options, await selection

Phase 3: Task Formatting
   ├─ Build enriched task description
   ├─ Include context from brainstorm
   └─ Generate parallel-dev-cycle command

Phase 4: Cycle Launch
   ├─ Confirm with user (unless --auto)
   └─ Execute parallel-dev-cycle

Implementation

实现细节

Phase 1: Session Loading

阶段1:会话加载

Step 0: Determine Project Root
步骤0:确定项目根目录
检测项目根目录,确保
.workflow/
产物位置正确:
bash
PROJECT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
优先通过 git 获取仓库根目录;非 git 项目回退到
pwd
取当前绝对路径。 存储为
{projectRoot}
,后续所有
.workflow/
路径必须以此为前缀。
javascript
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
const projectRoot = bash('git rev-parse --show-toplevel 2>/dev/null || pwd').trim()

// Parse arguments
const args = "$ARGUMENTS"
const sessionId = "$SESSION"
const ideaIndexMatch = args.match(/--idea=(\d+)/)
const preSelectedIdea = ideaIndexMatch ? parseInt(ideaIndexMatch[1]) : null
const isAutoMode = args.includes('--auto')

// Validate session
const sessionFolder = `${projectRoot}/.workflow/.brainstorm/${sessionId}`
const synthesisPath = `${sessionFolder}/synthesis.json`
const brainstormPath = `${sessionFolder}/brainstorm.md`

function fileExists(p) {
  try { return bash(`test -f "${p}" && echo "yes"`).includes('yes') } catch { return false }
}

if (!fileExists(synthesisPath)) {
  console.error(`
检测项目根目录,确保
.workflow/
产物位置正确:
bash
PROJECT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
优先通过 git 获取仓库根目录;非 git 项目回退到
pwd
取当前绝对路径。 存储为
{projectRoot}
,后续所有
.workflow/
路径必须以此为前缀。
javascript
const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
const projectRoot = bash('git rev-parse --show-toplevel 2>/dev/null || pwd').trim()

// Parse arguments
const args = "$ARGUMENTS"
const sessionId = "$SESSION"
const ideaIndexMatch = args.match(/--idea=(\d+)/)
const preSelectedIdea = ideaIndexMatch ? parseInt(ideaIndexMatch[1]) : null
const isAutoMode = args.includes('--auto')

// Validate session
const sessionFolder = `${projectRoot}/.workflow/.brainstorm/${sessionId}`
const synthesisPath = `${sessionFolder}/synthesis.json`
const brainstormPath = `${sessionFolder}/brainstorm.md`

function fileExists(p) {
  try { return bash(`test -f "${p}" && echo "yes"`).includes('yes') } catch { return false }
}

if (!fileExists(synthesisPath)) {
  console.error(`

Error: Session Not Found

Error: Session Not Found

Session ID: ${sessionId} Expected path: ${synthesisPath}
Available sessions:
)   bash(
ls -1 ${projectRoot}/.workflow/.brainstorm/ 2>/dev/null | head -10`) return { status: 'error', message: 'Session not found' } }
// Load synthesis const synthesis = JSON.parse(Read(synthesisPath))
// Validate structure if (!synthesis.top_ideas || synthesis.top_ideas.length === 0) { console.error(`
Session ID: ${sessionId} Expected path: ${synthesisPath}
Available sessions:
)   bash(
ls -1 ${projectRoot}/.workflow/.brainstorm/ 2>/dev/null | head -10`) return { status: 'error', message: 'Session not found' } }
// Load synthesis const synthesis = JSON.parse(Read(synthesisPath))
// Validate structure if (!synthesis.top_ideas || synthesis.top_ideas.length === 0) { console.error(`

Error: No Ideas Found

Error: No Ideas Found

The brainstorm session has no top_ideas. Please complete the brainstorm workflow first. `) return { status: 'error', message: 'No ideas in synthesis' } }
console.log(`
The brainstorm session has no top_ideas. Please complete the brainstorm workflow first. `) return { status: 'error', message: 'No ideas in synthesis' } }
console.log(`

Brainstorm Session Loaded

Brainstorm Session Loaded

Session: ${sessionId} Topic: ${synthesis.topic} Completed: ${synthesis.completed} Ideas Found: ${synthesis.top_ideas.length} `)

---
Session: ${sessionId} Topic: ${synthesis.topic} Completed: ${synthesis.completed} Ideas Found: ${synthesis.top_ideas.length} `)

---

Phase 2: Idea Selection

阶段2:创意选择

javascript
let selectedIdea = null
let selectionSource = ''

// Auto mode: select highest scored
if (isAutoMode) {
  selectedIdea = synthesis.top_ideas.reduce((best, idea) =>
    idea.score > best.score ? idea : best
  )
  selectionSource = 'auto (highest score)'

  console.log(`
**Auto-selected**: ${selectedIdea.title} (Score: ${selectedIdea.score}/10)
`)
}

// Pre-selected by index
else if (preSelectedIdea !== null) {
  if (preSelectedIdea >= synthesis.top_ideas.length) {
    console.error(`
javascript
let selectedIdea = null
let selectionSource = ''

// Auto mode: select highest scored
if (isAutoMode) {
  selectedIdea = synthesis.top_ideas.reduce((best, idea) =>
    idea.score > best.score ? idea : best
  )
  selectionSource = 'auto (highest score)'

  console.log(`
**Auto-selected**: ${selectedIdea.title} (Score: ${selectedIdea.score}/10)
`)
}

// Pre-selected by index
else if (preSelectedIdea !== null) {
  if (preSelectedIdea >= synthesis.top_ideas.length) {
    console.error(`

Error: Invalid Idea Index

Error: Invalid Idea Index

Requested: --idea=${preSelectedIdea} Available: 0 to ${synthesis.top_ideas.length - 1} `) return { status: 'error', message: 'Invalid idea index' } }
selectedIdea = synthesis.top_ideas[preSelectedIdea] selectionSource =
index ${preSelectedIdea}
console.log(
**Pre-selected**: ${selectedIdea.title} (Index: ${preSelectedIdea})
) }
// Interactive selection else { // Display options console.log(`
Requested: --idea=${preSelectedIdea} Available: 0 to ${synthesis.top_ideas.length - 1} `) return { status: 'error', message: 'Invalid idea index' } }
selectedIdea = synthesis.top_ideas[preSelectedIdea] selectionSource =
index ${preSelectedIdea}
console.log(
**Pre-selected**: ${selectedIdea.title} (Index: ${preSelectedIdea})
) }
// Interactive selection else { // Display options console.log(`

Select Idea for Development

Select Idea for Development

#TitleScoreFeasibility
${synthesis.top_ideas.map((idea, i) =>
`${i}${idea.title.substring(0, 40)}${idea.score}/10
).join('\n')}
Primary Recommendation: ${synthesis.recommendations?.primary?.substring(0, 60) || 'N/A'} `)
// Build options for AskUser const ideaOptions = synthesis.top_ideas.slice(0, 4).map((idea, i) => ({ label:
#${i}: ${idea.title.substring(0, 30)}
, description:
Score: ${idea.score}/10 - ${idea.description?.substring(0, 50) || ''}
}))
// Add primary recommendation option if different if (synthesis.recommendations?.primary) { ideaOptions.unshift({ label: "Primary Recommendation", description: synthesis.recommendations.primary.substring(0, 60) }) }
const selection = ASK_USER([{ id: "idea", type: "select", prompt: "Which idea should be developed?", options: ideaOptions }]) // BLOCKS (wait for user response)
// Parse selection if (selection.idea === "Primary Recommendation") { // Use primary recommendation as task selectedIdea = { title: "Primary Recommendation", description: synthesis.recommendations.primary, key_strengths: synthesis.key_insights || [], main_challenges: [], next_steps: synthesis.follow_up?.filter(f => f.type === 'implementation').map(f => f.summary) || [] } selectionSource = 'primary recommendation' } else { const match = selection.idea.match(/^#(\d+):/) const idx = match ? parseInt(match[1]) : 0 selectedIdea = synthesis.top_ideas[idx] selectionSource =
user selected #${idx}
} }
console.log(`
#TitleScoreFeasibility
${synthesis.top_ideas.map((idea, i) =>
`${i}${idea.title.substring(0, 40)}${idea.score}/10
).join('\n')}
Primary Recommendation: ${synthesis.recommendations?.primary?.substring(0, 60) || 'N/A'} `)
// Build options for AskUser const ideaOptions = synthesis.top_ideas.slice(0, 4).map((idea, i) => ({ label:
#${i}: ${idea.title.substring(0, 30)}
, description:
Score: ${idea.score}/10 - ${idea.description?.substring(0, 50) || ''}
}))
// Add primary recommendation option if different if (synthesis.recommendations?.primary) { ideaOptions.unshift({ label: "Primary Recommendation", description: synthesis.recommendations.primary.substring(0, 60) }) }
const selection = ASK_USER([{ id: "idea", type: "select", prompt: "Which idea should be developed?", options: ideaOptions }]) // BLOCKS (wait for user response)
// Parse selection if (selection.idea === "Primary Recommendation") { // Use primary recommendation as task selectedIdea = { title: "Primary Recommendation", description: synthesis.recommendations.primary, key_strengths: synthesis.key_insights || [], main_challenges: [], next_steps: synthesis.follow_up?.filter(f => f.type === 'implementation').map(f => f.summary) || [] } selectionSource = 'primary recommendation' } else { const match = selection.idea.match(/^#(\d+):/) const idx = match ? parseInt(match[1]) : 0 selectedIdea = synthesis.top_ideas[idx] selectionSource =
user selected #${idx}
} }
console.log(`

Selected Idea

Selected Idea

Title: ${selectedIdea.title} Source: ${selectionSource} Description: ${selectedIdea.description?.substring(0, 200) || 'N/A'} `)

---
Title: ${selectedIdea.title} Source: ${selectionSource} Description: ${selectedIdea.description?.substring(0, 200) || 'N/A'} `)

---

Phase 3: Task Formatting

阶段3:任务格式化

javascript
// Build enriched task description
function formatTask(idea, synthesis) {
  const sections = []

  // Main objective
  sections.push(`# Main Objective\n\n${idea.title}`)

  // Description
  if (idea.description) {
    sections.push(`# Description\n\n${idea.description}`)
  }

  // Key strengths
  if (idea.key_strengths?.length > 0) {
    sections.push(`# Key Strengths\n\n${idea.key_strengths.map(s => `- ${s}`).join('\n')}`)
  }

  // Main challenges (important for RA agent)
  if (idea.main_challenges?.length > 0) {
    sections.push(`# Main Challenges to Address\n\n${idea.main_challenges.map(c => `- ${c}`).join('\n')}`)
  }

  // Recommended steps
  if (idea.next_steps?.length > 0) {
    sections.push(`# Recommended Implementation Steps\n\n${idea.next_steps.map((s, i) => `${i + 1}. ${s}`).join('\n')}`)
  }

  // Alternative approaches (for RA consideration)
  if (synthesis.recommendations?.alternatives?.length > 0) {
    sections.push(`# Alternative Approaches (for reference)\n\n${synthesis.recommendations.alternatives.map(a => `- ${a}`).join('\n')}`)
  }

  // Key insights from brainstorm
  if (synthesis.key_insights?.length > 0) {
    const relevantInsights = synthesis.key_insights.slice(0, 3)
    sections.push(`# Key Insights from Brainstorm\n\n${relevantInsights.map(i => `- ${i}`).join('\n')}`)
  }

  // Source reference
  sections.push(`# Source\n\nBrainstorm Session: ${synthesis.session_id}\nTopic: ${synthesis.topic}`)

  return sections.join('\n\n')
}

const enrichedTask = formatTask(selectedIdea, synthesis)

// Display formatted task
console.log(`
javascript
// Build enriched task description
function formatTask(idea, synthesis) {
  const sections = []

  // Main objective
  sections.push(`# Main Objective\n\n${idea.title}`)

  // Description
  if (idea.description) {
    sections.push(`# Description\n\n${idea.description}`)
  }

  // Key strengths
  if (idea.key_strengths?.length > 0) {
    sections.push(`# Key Strengths\n\n${idea.key_strengths.map(s => `- ${s}`).join('\n')}`)
  }

  // Main challenges (important for RA agent)
  if (idea.main_challenges?.length > 0) {
    sections.push(`# Main Challenges to Address\n\n${idea.main_challenges.map(c => `- ${c}`).join('\n')}`)
  }

  // Recommended steps
  if (idea.next_steps?.length > 0) {
    sections.push(`# Recommended Implementation Steps\n\n${idea.next_steps.map((s, i) => `${i + 1}. ${s}`).join('\n')}`)
  }

  // Alternative approaches (for RA consideration)
  if (synthesis.recommendations?.alternatives?.length > 0) {
    sections.push(`# Alternative Approaches (for reference)\n\n${synthesis.recommendations.alternatives.map(a => `- ${a}`).join('\n')}`)
  }

  // Key insights from brainstorm
  if (synthesis.key_insights?.length > 0) {
    const relevantInsights = synthesis.key_insights.slice(0, 3)
    sections.push(`# Key Insights from Brainstorm\n\n${relevantInsights.map(i => `- ${i}`).join('\n')}`)
  }

  // Source reference
  sections.push(`# Source\n\nBrainstorm Session: ${synthesis.session_id}\nTopic: ${synthesis.topic}`)

  return sections.join('\n\n')
}

const enrichedTask = formatTask(selectedIdea, synthesis)

// Display formatted task
console.log(`

Formatted Task for parallel-dev-cycle

Formatted Task for parallel-dev-cycle

```markdown ${enrichedTask} ``` `)
// Save task to session folder for reference Write(
${sessionFolder}/cycle-task.md
,
# Generated Task\n\n**Generated**: ${getUtc8ISOString()}\n**Idea**: ${selectedIdea.title}\n**Selection**: ${selectionSource}\n\n---\n\n${enrichedTask}
)

---
```markdown ${enrichedTask} ``` `)
// Save task to session folder for reference Write(
${sessionFolder}/cycle-task.md
,
# Generated Task\n\n**Generated**: ${getUtc8ISOString()}\n**Idea**: ${selectedIdea.title}\n**Selection**: ${selectionSource}\n\n---\n\n${enrichedTask}
)

---

Phase 4: Cycle Launch

阶段4:Cycle启动

javascript
// Confirm launch (unless auto mode)
let shouldLaunch = isAutoMode

if (!isAutoMode) {
  const confirmation = ASK_USER([{
    id: "launch", type: "select",
    prompt: "Launch parallel-dev-cycle with this task?",
    options: [
      { label: "Yes, launch cycle (Recommended)", description: "Start parallel-dev-cycle with enriched task" },
      { label: "No, just save task", description: "Save formatted task for manual use" }
    ]
  }])  // BLOCKS (wait for user response)

  shouldLaunch = confirmation.launch.includes("Yes")
}

if (shouldLaunch) {
  console.log(`
javascript
// Confirm launch (unless auto mode)
let shouldLaunch = isAutoMode

if (!isAutoMode) {
  const confirmation = ASK_USER([{
    id: "launch", type: "select",
    prompt: "Launch parallel-dev-cycle with this task?",
    options: [
      { label: "Yes, launch cycle (Recommended)", description: "Start parallel-dev-cycle with enriched task" },
      { label: "No, just save task", description: "Save formatted task for manual use" }
    ]
  }])  // BLOCKS (wait for user response)

  shouldLaunch = confirmation.launch.includes("Yes")
}

if (shouldLaunch) {
  console.log(`

Launching parallel-dev-cycle

Launching parallel-dev-cycle

Task: ${selectedIdea.title} Source Session: ${sessionId} `)
// Escape task for command line const escapedTask = enrichedTask .replace(/\/g, '\\') .replace(/"/g, '\"') .replace(/$/g, '\$') .replace(/
/g, '\\
')
// Launch parallel-dev-cycle // Note: In actual execution, this would invoke the skill console.log(`
Task: ${selectedIdea.title} Source Session: ${sessionId} `)
// Escape task for command line const escapedTask = enrichedTask .replace(/\/g, '\\') .replace(/"/g, '\"') .replace(/$/g, '\$') .replace(/
/g, '\\
')
// Launch parallel-dev-cycle // Note: In actual execution, this would invoke the skill console.log(`

Cycle Command

Cycle Command

```bash /parallel-dev-cycle TASK="${escapedTask.substring(0, 100)}..." ```
Full task saved to: ${sessionFolder}/cycle-task.md `)
// Return success with cycle trigger return { status: 'success', action: 'launch_cycle', session_id: sessionId, idea: selectedIdea.title, task_file:
${sessionFolder}/cycle-task.md
, cycle_command:
/parallel-dev-cycle TASK="${enrichedTask}"
}
} else { console.log(`
```bash /parallel-dev-cycle TASK="${escapedTask.substring(0, 100)}..." ```
Full task saved to: ${sessionFolder}/cycle-task.md `)
// Return success with cycle trigger return { status: 'success', action: 'launch_cycle', session_id: sessionId, idea: selectedIdea.title, task_file:
${sessionFolder}/cycle-task.md
, cycle_command:
/parallel-dev-cycle TASK="${enrichedTask}"
}
} else { console.log(`

Task Saved (Not Launched)

Task Saved (Not Launched)

Task file: ${sessionFolder}/cycle-task.md
To launch manually: ```bash /parallel-dev-cycle TASK="$(cat ${sessionFolder}/cycle-task.md)" ``` `)
return { status: 'success', action: 'saved_only', session_id: sessionId, task_file:
${sessionFolder}/cycle-task.md
} }

---
Task file: ${sessionFolder}/cycle-task.md
To launch manually: ```bash /parallel-dev-cycle TASK="$(cat ${sessionFolder}/cycle-task.md)" ``` `)
return { status: 'success', action: 'saved_only', session_id: sessionId, task_file:
${sessionFolder}/cycle-task.md
} }

---

Session Files

会话文件

After execution:
{projectRoot}/.workflow/.brainstorm/{session-id}/
├── brainstorm.md        # Original brainstorm
├── synthesis.json       # Synthesis data (input)
├── perspectives.json    # Perspectives data
├── ideas/               # Idea deep-dives
└── cycle-task.md        # ⭐ Generated task (output)
执行完成后,文件结构如下:
{projectRoot}/.workflow/.brainstorm/{session-id}/
├── brainstorm.md        # 原始头脑风暴文档
├── synthesis.json       # 合成数据(输入)
├── perspectives.json    # 视角数据
├── ideas/               # 创意深度分析
└── cycle-task.md        # ⭐ 生成的任务(输出)

Task Format

任务格式

The generated task includes:
SectionPurposeUsed By
Main ObjectiveClear goal statementRA: Primary requirement
DescriptionDetailed explanationRA: Requirement context
Key StrengthsWhy this approachRA: Design decisions
Main ChallengesKnown issues to addressRA: Edge cases, risks
Implementation StepsSuggested approachEP: Planning guidance
AlternativesOther valid approachesRA: Fallback options
Key InsightsLearnings from brainstormRA: Domain context
生成的任务包含以下部分:
章节用途使用方
Main Objective清晰的目标陈述RA:主要需求
Description详细说明RA:需求上下文
Key Strengths该方案的优势RA:设计决策依据
Main Challenges需要解决的已知问题RA:边缘情况、风险评估
Implementation Steps建议的实施步骤EP:规划指导
Alternatives其他可行方案RA:备选方案参考
Key Insights头脑风暴中的关键洞见RA:领域上下文

Error Handling

错误处理

SituationAction
Session not foundList available sessions, abort
synthesis.json missingSuggest completing brainstorm first
No top_ideasReport error, abort
Invalid --idea indexShow valid range, abort
Task too longTruncate with reference to file
场景处理方式
会话未找到列出可用会话,终止执行
synthesis.json缺失提示先完成头脑风暴工作流
无top_ideas报告错误,终止执行
--idea索引无效显示有效范围,终止执行
任务内容过长截断内容并提示查看文件

Examples

示例

Auto Mode (Quick Launch)

自动模式(快速启动)

bash
/brainstorm-to-cycle SESSION="BS-rate-limiting-2025-01-28" --auto
bash
/brainstorm-to-cycle SESSION="BS-rate-limiting-2025-01-28" --auto

→ Selects highest-scored idea

→ 选择得分最高的创意

→ Launches parallel-dev-cycle immediately

→ 立即启动parallel-dev-cycle

undefined
undefined

Pre-Selected Idea

预先选择创意

bash
/brainstorm-to-cycle SESSION="BS-auth-system-2025-01-28" --idea=2
bash
/brainstorm-to-cycle SESSION="BS-auth-system-2025-01-28" --idea=2

→ Selects top_ideas[2]

→ 选择top_ideas[2]中的创意

→ Confirms before launch

→ 确认后启动

undefined
undefined

Interactive Selection

交互式选择

bash
/brainstorm-to-cycle SESSION="BS-caching-2025-01-28"
bash
/brainstorm-to-cycle SESSION="BS-caching-2025-01-28"

→ Displays all ideas with scores

→ 显示所有带得分的创意

→ User selects from options

→ 用户选择创意

→ Confirms and launches

→ 确认后启动

undefined
undefined

Integration Flow

集成流程

brainstorm-with-file
   synthesis.json
 brainstorm-to-cycle  ◄─── This command
   enriched TASK
 parallel-dev-cycle
   RA → EP → CD → VAS

Now execute brainstorm-to-cycle with session: $SESSION
brainstorm-with-file
   synthesis.json
 brainstorm-to-cycle  ◄─── 本命令
   增强型TASK
 parallel-dev-cycle
   RA → EP → CD → VAS

请使用会话 $SESSION 执行brainstorm-to-cycle