From 19fb4d86c77b2ee8ace60a5354d617764f220ac4 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Sat, 28 Feb 2026 21:29:38 +0800 Subject: [PATCH] fix: add -y auto mode bypass for all ccw-coordinator referenced skills Harmonize orchestrator files (ccw.md, ccw-coordinator.md) with cross-file consistency fixes, and add missing -y/--yes non-interactive bypass gates to 7 skills that declared auto mode support but had blocking AskUserQuestion calls: team-planex, issue:discover, issue:plan, issue:queue, issue:execute, workflow:debug-with-file, issue:from-brainstorm. --- .claude/commands/ccw-coordinator.md | 814 +++++-------------- .claude/commands/ccw.md | 333 +++----- .claude/commands/issue/discover.md | 11 + .claude/commands/issue/execute.md | 55 +- .claude/commands/issue/from-brainstorm.md | 4 +- .claude/commands/issue/plan.md | 8 + .claude/commands/issue/queue.md | 19 + .claude/commands/workflow/debug-with-file.md | 8 + .claude/skills/team-planex/SKILL.md | 31 +- 9 files changed, 429 insertions(+), 854 deletions(-) diff --git a/.claude/commands/ccw-coordinator.md b/.claude/commands/ccw-coordinator.md index f902877c..8a3f4a2b 100644 --- a/.claude/commands/ccw-coordinator.md +++ b/.claude/commands/ccw-coordinator.md @@ -25,20 +25,12 @@ Interactive orchestration tool: analyze task → discover commands → recommend | `workflow-tdd-plan` | tdd-plan, tdd-verify | | `review-cycle` | review-session-cycle, review-module-cycle, review-cycle-fix | | `brainstorm` | auto-parallel, artifacts, role-analysis, synthesis | +| `spec-generator` | product-brief → PRD → architecture → epics | | `workflow:collaborative-plan-with-file` | understanding agent → parallel agents → plan-note.md | -| `workflow:req-plan-with-file` | requirement decomposition → issue creation → execution-plan.json | +| `workflow:roadmap-with-file` | strategic requirement roadmap → issue creation → execution-plan.json | | `workflow:integration-test-cycle` | explore → test dev → test-fix cycle → reflection | | `workflow:refactor-cycle` | tech debt discovery → prioritize → execute → validate | -| `team-planex` | planner + executor wave pipeline(边规划边执行)| -| `team-iterdev` | 迭代开发团队(planner → developer → reviewer 循环)| -| `team-lifecycle` | 全生命周期团队(spec → impl → test)| -| `team-issue` | issue 解决团队(discover → plan → execute)| -| `team-testing` | 测试团队(strategy → generate → execute → analyze)| -| `team-quality-assurance` | QA 团队(scout → strategist → generator → executor → analyst)| -| `team-brainstorm` | 团队头脑风暴(facilitator → participants → synthesizer)| -| `team-uidesign` | UI 设计团队(designer → implementer dual-track)| - -独立命令(仍使用 colon 格式):workflow:brainstorm-with-file, workflow:debug-with-file, workflow:analyze-with-file, workflow:collaborative-plan-with-file, workflow:req-plan-with-file, workflow:integration-test-cycle, workflow:refactor-cycle, workflow:unified-execute-with-file, workflow:clean, workflow:init, workflow:init-guidelines, workflow:ui-design:*, issue:*, workflow:session:* +| `team-planex` | planner + executor wave pipeline(适合大量零散 issue 或 roadmap 产出的清晰 issue,实现 0→1 开发)| ## Core Concept: Minimum Execution Units (最小执行单元) @@ -65,6 +57,7 @@ Interactive orchestration tool: analyze task → discover commands → recommend | **Replanning + Execution** | replan → execute | Update plan and execute changes | Working code | | **TDD Planning + Execution** | tdd-plan → execute | Test-driven development planning and execution | Working code | | **Test Generation + Execution** | test-gen → execute | Generate test suite and execute | Generated tests | +| **Spec-Driven Full Pipeline** | spec-generator → plan → execute | Specification-driven development | Working code | **Testing Units** (测试单元): @@ -91,11 +84,11 @@ Interactive orchestration tool: analyze task → discover commands → recommend | Unit Name | Commands | Purpose | Output | |-----------|----------|---------|--------| -| **Brainstorm With File** | brainstorm-with-file | Multi-perspective ideation with documentation | brainstorm.md | +| **Analyze to Plan** | analyze-with-file → lite-plan | Collaborative analysis → auto chain to lite-plan | discussion.md + code | +| **Brainstorm to Plan** | brainstorm-with-file → lite-plan | Multi-perspective ideation → auto chain to lite-plan | brainstorm.md + code | | **Debug With File** | debug-with-file | Hypothesis-driven debugging with documentation | understanding.md | -| **Analyze With File** | analyze-with-file | Collaborative analysis with documentation | discussion.md | | **Collaborative Plan** | collaborative-plan-with-file → unified-execute-with-file | Multi-agent collaborative planning and execution | plan-note.md + code | -| **Requirement Plan** | req-plan-with-file → team-planex | Requirement decomposition and wave execution | execution-plan.json + code | +| **Roadmap Plan** | roadmap-with-file → team-planex | Requirement decomposition and wave execution | execution-plan.json + code | **Cycle Units** (循环单元): @@ -104,19 +97,6 @@ Interactive orchestration tool: analyze task → discover commands → recommend | **Integration Test Cycle** | integration-test-cycle | Self-iterating integration test with reflection | Tests passed | | **Refactor Cycle** | refactor-cycle | Tech debt discovery and refactoring | Refactored code | -**Team Units** (团队单元): - -| Unit Name | Commands | Purpose | Output | -|-----------|----------|---------|--------| -| **Team Plan+Execute** | team-planex | Wave pipeline (planner + executor) | Working code | -| **Team Iterative Dev** | team-iterdev | Iterative development (planner → developer → reviewer) | Working code | -| **Team Lifecycle** | team-lifecycle | Full lifecycle (spec → impl → test) | Working code | -| **Team Issue** | team-issue | Multi-role issue resolution | Resolved issues | -| **Team Testing** | team-testing | Comprehensive test pipeline | Tests passed | -| **Team QA** | team-quality-assurance | Quality assurance pipeline | QA report | -| **Team Brainstorm** | team-brainstorm | Multi-role brainstorming | Analysis | -| **Team UI Design** | team-uidesign | Dual-track design + implementation | UI code | - ### Command-to-Unit Mapping (命令与最小单元的映射) | Command | Can Precede | Atomic Units | @@ -128,6 +108,7 @@ Interactive orchestration tool: analyze task → discover commands → recommend | replan | execute | Replanning + Execution | | test-gen | execute | Test Generation + Execution | | tdd-plan | execute | TDD Planning + Execution | +| spec-generator | plan | Spec-Driven Full Pipeline | | review-session-cycle | review-cycle-fix | Code Review (Session) | | review-module-cycle | review-cycle-fix | Code Review (Module) | | test-fix-gen | test-cycle-execute | Test Validation | @@ -136,22 +117,15 @@ Interactive orchestration tool: analyze task → discover commands → recommend | convert-to-plan | issue:queue | Rapid-to-Issue | | issue:queue | issue:execute | Issue Workflow, Rapid-to-Issue, Brainstorm-to-Issue | | issue:from-brainstorm | issue:queue | Brainstorm-to-Issue | -| brainstorm-with-file | issue:from-brainstorm (optional) | Brainstorm With File, Brainstorm-to-Issue | +| analyze-with-file | lite-plan (auto) | Analyze to Plan | +| brainstorm-with-file | lite-plan (auto), issue:from-brainstorm | Brainstorm to Plan, Brainstorm-to-Issue | | collaborative-plan-with-file | unified-execute-with-file | Collaborative Plan | -| req-plan-with-file | team-planex | Requirement Plan | +| roadmap-with-file | team-planex | Roadmap Plan | | unified-execute-with-file | (terminal) | Collaborative Plan | | integration-test-cycle | (standalone) | Integration Test Cycle | | refactor-cycle | (standalone) | Refactor Cycle | -| team-planex | (standalone) | Team Plan+Execute | -| team-iterdev | (standalone) | Team Iterative Dev | -| team-lifecycle | (standalone) | Team Lifecycle | -| team-issue | (standalone) | Team Issue | -| team-testing | (standalone) | Team Testing | -| team-quality-assurance | (standalone) | Team QA | -| team-brainstorm | (standalone) | Team Brainstorm | -| team-uidesign | (standalone) | Team UI Design | +| team-planex | (standalone) | Roadmap Plan (executor) | | debug-with-file | (standalone) | Debug With File | -| analyze-with-file | (standalone) | Analyze With File | ### Atomic Group Rules @@ -176,17 +150,34 @@ Parse task to extract: goal, scope, constraints, complexity, and task type. ```javascript function analyzeRequirements(taskDescription) { return { - goal: extractMainGoal(taskDescription), // e.g., "Implement user registration" - scope: extractScope(taskDescription), // e.g., ["auth", "user_management"] - constraints: extractConstraints(taskDescription), // e.g., ["no breaking changes"] - complexity: determineComplexity(taskDescription), // 'simple' | 'medium' | 'complex' - task_type: detectTaskType(taskDescription) // See task type patterns below + goal: extractMainGoal(taskDescription), + scope: extractScope(taskDescription), + constraints: extractConstraints(taskDescription), + complexity: determineComplexity(taskDescription), + task_type: detectTaskType(taskDescription) }; } -// Task Type Detection Patterns +// Task Type Detection Patterns (harmonized with ccw.md priority order) function detectTaskType(text) { // Priority order (first match wins) + // Urgent bugfix (dual condition - must come first) + if (/urgent|production|critical/.test(text) && /fix|bug/.test(text)) return 'bugfix-hotfix'; + // With-File workflow patterns (specific keywords - must come before generic bugfix) + if (/brainstorm.*issue|头脑风暴.*issue|idea.*issue|想法.*issue|从.*头脑风暴|convert.*brainstorm/.test(text)) return 'brainstorm-to-issue'; + if (/brainstorm|ideation|头脑风暴|创意|发散思维|creative thinking/.test(text)) return 'brainstorm-file'; + if (/debug.*document|hypothesis.*debug|深度调试|假设.*验证|systematic debug/.test(text)) return 'debug-file'; + if (/analyze.*document|collaborative analysis|协作分析|深度.*理解/.test(text)) return 'analyze-file'; + if (/collaborative.*plan|协作.*规划|多人.*规划|multi.*agent.*plan|Plan Note|分工.*规划/.test(text)) return 'collaborative-plan'; + if (/roadmap|需求.*规划|需求.*拆解|requirement.*plan|progressive.*plan|路线.*图/.test(text)) return 'roadmap'; + if (/spec.*gen|specification|PRD|产品需求|产品文档|产品规格/.test(text)) return 'spec-driven'; + // Cycle workflow patterns + if (/integration.*test|集成测试|端到端.*测试|e2e.*test|integration.*cycle/.test(text)) return 'integration-test'; + if (/refactor|重构|tech.*debt|技术债务/.test(text)) return 'refactor'; + // Team workflows (kept: team-planex only) + if (/team.*plan.*exec|team.*planex|团队.*规划.*执行|并行.*规划.*执行|wave.*pipeline/.test(text)) return 'team-planex'; + // Standard workflows + if (/multi.*cli|多.*CLI|多模型.*协作|multi.*model.*collab/.test(text)) return 'multi-cli'; if (/fix|bug|error|crash|fail|debug|diagnose/.test(text)) return 'bugfix'; if (/tdd|test-driven|先写测试|test first/.test(text)) return 'tdd'; if (/测试失败|test fail|fix test|failing test/.test(text)) return 'test-fix'; @@ -195,28 +186,11 @@ function detectTaskType(text) { // Issue workflow patterns if (/issues?.*batch|batch.*issues?|批量.*issue|issue.*批量/.test(text)) return 'issue-batch'; if (/issue workflow|structured workflow|queue|multi-stage|转.*issue|issue.*流程/.test(text)) return 'issue-transition'; - // With-File workflow patterns - if (/brainstorm|ideation|头脑风暴|创意|发散思维|creative thinking/.test(text)) return 'brainstorm-file'; - if (/brainstorm.*issue|头脑风暴.*issue|idea.*issue|想法.*issue|从.*头脑风暴|convert.*brainstorm/.test(text)) return 'brainstorm-to-issue'; - if (/debug.*document|hypothesis.*debug|深度调试|假设.*验证|systematic debug/.test(text)) return 'debug-file'; - if (/analyze.*document|collaborative analysis|协作分析|深度.*理解/.test(text)) return 'analyze-file'; - if (/collaborative.*plan|协作.*规划|多人.*规划|multi.*agent.*plan|Plan Note|分工.*规划/.test(text)) return 'collaborative-plan'; - if (/roadmap|需求.*规划|需求.*拆解|requirement.*plan|req.*plan|progressive.*plan|路线.*图/.test(text)) return 'req-plan'; - // Cycle workflow patterns - if (/integration.*test|集成测试|端到端.*测试|e2e.*test|integration.*cycle/.test(text)) return 'integration-test'; - if (/refactor|重构|tech.*debt|技术债务/.test(text)) return 'refactor'; - // Team workflow patterns (explicit "team" keyword required) - if (/team.*plan.*exec|team.*planex|团队.*规划.*执行|并行.*规划.*执行|wave.*pipeline/.test(text)) return 'team-planex'; - if (/team.*iter|team.*iterdev|迭代.*开发.*团队|iterative.*dev.*team/.test(text)) return 'team-iterdev'; - if (/team.*lifecycle|全生命周期|full.*lifecycle|spec.*impl.*test.*team/.test(text)) return 'team-lifecycle'; - if (/team.*issue.*resolv|团队.*issue|team.*resolve.*issue/.test(text)) return 'team-issue'; - if (/team.*test|测试团队|comprehensive.*test.*team|全面.*测试.*团队/.test(text)) return 'team-testing'; - if (/team.*qa|quality.*assurance.*team|QA.*团队|质量.*保障.*团队|团队.*质量/.test(text)) return 'team-qa'; - if (/team.*brainstorm|团队.*头脑风暴|team.*ideation|多人.*头脑风暴/.test(text)) return 'team-brainstorm'; - if (/team.*ui.*design|UI.*设计.*团队|dual.*track.*design|团队.*UI/.test(text)) return 'team-uidesign'; - // Standard workflows - if (/multi.*cli|多.*CLI|多模型.*协作|multi.*model.*collab/.test(text)) return 'multi-cli'; - if (/不确定|explore|研究|what if|brainstorm|权衡/.test(text)) return 'brainstorm'; + // Additional task types (harmonized with ccw.md) + if (/不确定|explore|研究|what if|权衡/.test(text)) return 'exploration'; + if (/quick|simple|small/.test(text) && /feature|function/.test(text)) return 'quick-task'; + if (/ui|design|component|style/.test(text)) return 'ui-design'; + if (/docs|documentation|readme/.test(text)) return 'documentation'; return 'feature'; // Default } @@ -250,331 +224,272 @@ Dynamic command chain assembly using port-based matching. Each command has input/output ports (tags) for pipeline composition: ```javascript -// Port labels represent data types flowing through the pipeline -// Type classification: -// skill: workflow-lite-plan (lite-plan, lite-execute), -// workflow-plan (plan, plan-verify, replan), -// workflow-execute (execute), -// workflow-multi-cli-plan (multi-cli-plan), -// workflow-test-fix (test-fix-gen, test-cycle-execute), -// workflow-tdd-plan (tdd-plan, tdd-verify), -// review-cycle (review-session-cycle, review-module-cycle, review-cycle-fix) -// command: debug, test-gen, review, workflow:brainstorm-with-file, -// workflow:debug-with-file, workflow:analyze-with-file, issue:* const commandPorts = { 'lite-plan': { name: 'lite-plan', - input: ['requirement'], // 输入端口:需求 - output: ['plan'], // 输出端口:计划 + input: ['requirement', 'discussion-document', 'brainstorm-document'], + output: ['plan'], tags: ['planning'], - atomic_group: 'quick-implementation' // 最小单元:与 lite-execute 绑定 + atomic_group: 'quick-implementation' }, 'lite-execute': { name: 'lite-execute', - input: ['plan', 'multi-cli-plan'], // 输入端口:可接受多种规划输出 - output: ['code'], // 输出端口:代码 + input: ['plan', 'multi-cli-plan'], + output: ['code'], tags: ['execution'], - atomic_groups: [ // 可参与多个最小单元 - 'quick-implementation', // lite-plan → lite-execute - 'multi-cli-planning', // multi-cli-plan → lite-execute - 'bug-fix' // lite-plan (--bugfix) → lite-execute - ] + atomic_groups: ['quick-implementation', 'multi-cli-planning', 'bug-fix'] }, 'plan': { name: 'plan', - input: ['requirement'], + input: ['requirement', 'specification'], output: ['detailed-plan'], tags: ['planning'], - atomic_groups: [ // 可参与多个最小单元 - 'full-planning-execution', // plan → execute - 'verified-planning-execution' // plan → plan-verify → execute - ] + atomic_groups: ['full-planning-execution', 'verified-planning-execution', 'spec-driven'] }, 'plan-verify': { name: 'plan-verify', input: ['detailed-plan'], output: ['verified-plan'], tags: ['planning'], - atomic_group: 'verified-planning-execution' // 最小单元:plan → plan-verify → execute + atomic_group: 'verified-planning-execution' }, 'replan': { name: 'replan', - input: ['session', 'feedback'], // 输入端口:会话或反馈 - output: ['replan'], // 输出端口:更新后的计划(供 execute 执行) + input: ['session', 'feedback'], + output: ['replan'], tags: ['planning'], - atomic_group: 'replanning-execution' // 最小单元:与 execute 绑定 + atomic_group: 'replanning-execution' }, 'execute': { name: 'execute', - input: ['detailed-plan', 'verified-plan', 'replan', 'test-tasks', 'tdd-tasks'], // 可接受多种规划输出 + input: ['detailed-plan', 'verified-plan', 'replan', 'test-tasks', 'tdd-tasks'], output: ['code'], tags: ['execution'], - atomic_groups: [ // 可参与多个最小单元 - 'full-planning-execution', // plan → execute - 'verified-planning-execution', // plan → plan-verify → execute - 'replanning-execution', // replan → execute - 'test-generation-execution', // test-gen → execute - 'tdd-planning-execution' // tdd-plan → execute - ] + atomic_groups: ['full-planning-execution', 'verified-planning-execution', 'replanning-execution', 'test-generation-execution', 'tdd-planning-execution', 'spec-driven'] }, 'test-cycle-execute': { name: 'test-cycle-execute', - input: ['test-tasks'], // 输入端口:测试任务(需先test-fix-gen生成) - output: ['test-passed'], // 输出端口:测试通过 + input: ['test-tasks'], + output: ['test-passed'], tags: ['testing'], - atomic_group: 'test-validation', // 最小单元:与 test-fix-gen 绑定 + atomic_group: 'test-validation', note: '需要先执行test-fix-gen生成测试任务,再由此命令执行测试周期' }, 'tdd-plan': { name: 'tdd-plan', input: ['requirement'], - output: ['tdd-tasks'], // TDD 任务(供 execute 执行) + output: ['tdd-tasks'], tags: ['planning', 'tdd'], - atomic_group: 'tdd-planning-execution' // 最小单元:与 execute 绑定 + atomic_group: 'tdd-planning-execution' }, 'tdd-verify': { name: 'tdd-verify', input: ['code'], output: ['tdd-verified'], - tags: ['testing'] + tags: ['testing'], + note: 'Internal sub-command of workflow-tdd-plan Skill, not in explicit pipelines' }, - // Bug Fix (使用 lite-plan 的 bugfix 变体,lite-fix 已移除) 'lite-plan-bugfix': { name: 'lite-plan', - input: ['bug-report'], // 输入端口:bug 报告 - output: ['plan'], // 输出端口:修复计划(供 lite-execute 执行) + input: ['bug-report'], + output: ['plan'], tags: ['bugfix', 'planning'], - atomic_group: 'bug-fix', // 最小单元:与 lite-execute 绑定 - type: 'skill', // Skill 触发器: workflow-lite-plan + atomic_group: 'bug-fix', + type: 'skill', note: '通过 --bugfix 参数传递 bugfix 语义' }, 'debug': { name: 'debug', input: ['bug-report'], output: ['debug-log'], - tags: ['bugfix'] + tags: ['bugfix'], + note: 'Standalone debug sub-command, used internally by lite-plan --bugfix' }, 'test-gen': { name: 'test-gen', - input: ['code', 'session'], // 可接受代码或会话 - output: ['test-tasks'], // 输出测试任务(IMPL-001,IMPL-002),供 execute 执行 + input: ['code', 'session'], + output: ['test-tasks'], tags: ['testing'], - atomic_group: 'test-generation-execution' // 最小单元:与 execute 绑定 + atomic_group: 'test-generation-execution' }, 'test-fix-gen': { name: 'test-fix-gen', input: ['failing-tests', 'session'], - output: ['test-tasks'], // 输出测试任务,针对特定问题生成测试并在测试中修正 + output: ['test-tasks'], tags: ['testing'], - atomic_group: 'test-validation', // 最小单元:与 test-cycle-execute 绑定 + atomic_group: 'test-validation', note: '生成测试任务供test-cycle-execute执行' }, 'review': { name: 'review', input: ['code', 'session'], output: ['review-findings'], - tags: ['review'] + tags: ['review'], + note: 'Base review command, pipelines use review-session-cycle or review-module-cycle instead' }, 'review-cycle-fix': { name: 'review-cycle-fix', - input: ['review-findings', 'review-verified'], // Accept output from review-session-cycle or review-module-cycle + input: ['review-findings', 'review-verified'], output: ['fixed-code'], tags: ['review'], - atomic_group: 'code-review' // 最小单元:与 review-session-cycle/review-module-cycle 绑定 + atomic_group: 'code-review' }, 'brainstorm': { name: 'brainstorm', - input: ['exploration-topic'], // 输入端口:探索主题 + input: ['exploration-topic'], output: ['brainstorm-analysis'], tags: ['brainstorm'], - type: 'skill' // 统一 Skill:brainstorm (auto-parallel, artifacts, role-analysis, synthesis) + type: 'skill' }, 'multi-cli-plan': { name: 'multi-cli-plan', input: ['requirement'], - output: ['multi-cli-plan'], // 对比分析计划(供 lite-execute 执行) + output: ['multi-cli-plan'], tags: ['planning', 'multi-cli'], - atomic_group: 'multi-cli-planning' // 最小单元:与 lite-execute 绑定 + atomic_group: 'multi-cli-planning' }, 'review-session-cycle': { name: 'review-session-cycle', - input: ['code', 'session'], // 可接受代码或会话 - output: ['review-verified'], // 输出端口:审查通过 + input: ['code', 'session'], + output: ['review-verified'], tags: ['review'], - atomic_group: 'code-review' // 最小单元:与 review-cycle-fix 绑定 + atomic_group: 'code-review' }, 'review-module-cycle': { name: 'review-module-cycle', - input: ['module-pattern'], // 输入端口:模块模式 - output: ['review-verified'], // 输出端口:审查通过 + input: ['module-pattern'], + output: ['review-verified'], tags: ['review'], - atomic_group: 'code-review' // 最小单元:与 review-cycle-fix 绑定 + atomic_group: 'code-review' }, // Issue workflow commands 'issue:discover': { name: 'issue:discover', - input: ['codebase'], // 输入端口:代码库 - output: ['pending-issues'], // 输出端口:待处理 issues + input: ['codebase'], + output: ['pending-issues'], tags: ['issue'], - atomic_group: 'issue-workflow' // 最小单元:discover → plan → queue → execute + atomic_group: 'issue-workflow' }, 'issue:plan': { name: 'issue:plan', - input: ['pending-issues'], // 输入端口:待处理 issues - output: ['issue-plans'], // 输出端口:issue 计划 + input: ['pending-issues'], + output: ['issue-plans'], tags: ['issue'], atomic_group: 'issue-workflow' }, 'issue:queue': { name: 'issue:queue', - input: ['issue-plans', 'converted-plan'], // 可接受 issue:plan 或 convert-to-plan 输出 - output: ['execution-queue'], // 输出端口:执行队列 + input: ['issue-plans', 'converted-plan'], + output: ['execution-queue'], tags: ['issue'], atomic_groups: ['issue-workflow', 'rapid-to-issue'] }, 'issue:execute': { name: 'issue:execute', - input: ['execution-queue'], // 输入端口:执行队列 - output: ['completed-issues'], // 输出端口:已完成 issues + input: ['execution-queue'], + output: ['completed-issues'], tags: ['issue'], atomic_groups: ['issue-workflow', 'rapid-to-issue'] }, 'issue:convert-to-plan': { name: 'issue:convert-to-plan', - input: ['plan'], // 输入端口:lite-plan 输出 - output: ['converted-plan'], // 输出端口:转换后的 issue 计划 + input: ['plan'], + output: ['converted-plan'], tags: ['issue', 'planning'], - atomic_group: 'rapid-to-issue' // 最小单元:lite-plan → convert-to-plan → queue → execute + atomic_group: 'rapid-to-issue' }, - // With-File workflows (documented exploration with multi-CLI collaboration) + // With-File workflows 'brainstorm-with-file': { name: 'brainstorm-with-file', - input: ['exploration-topic'], // 输入端口:探索主题 - output: ['brainstorm-document'], // 输出端口:brainstorm.md + 综合结论 + input: ['exploration-topic'], + output: ['brainstorm-document'], tags: ['brainstorm', 'with-file'], - note: 'Self-contained workflow with multi-round diverge-converge cycles' + atomic_group: 'brainstorm-to-plan', + note: 'Auto chains to lite-plan with brainstorm artifacts' }, 'issue:from-brainstorm': { name: 'issue:from-brainstorm', - input: ['brainstorm-document'], // 输入端口:brainstorm 产物(synthesis.json) - output: ['converted-plan'], // 输出端口:issue + solution + input: ['brainstorm-document'], + output: ['converted-plan'], tags: ['issue', 'brainstorm'], - atomic_group: 'brainstorm-to-issue' // 最小单元:from-brainstorm → queue → execute + atomic_group: 'brainstorm-to-issue' }, 'debug-with-file': { name: 'debug-with-file', - input: ['bug-report'], // 输入端口:bug 报告 - output: ['understanding-document'], // 输出端口:understanding.md + 修复 + input: ['bug-report'], + output: ['understanding-document'], tags: ['bugfix', 'with-file'], note: 'Self-contained workflow with hypothesis-driven iteration' }, 'analyze-with-file': { name: 'analyze-with-file', - input: ['analysis-topic'], // 输入端口:分析主题 - output: ['discussion-document'], // 输出端口:discussion.md + 结论 + input: ['analysis-topic'], + output: ['discussion-document'], tags: ['analysis', 'with-file'], - note: 'Self-contained workflow with multi-round discussion' + atomic_group: 'analyze-to-plan', + note: 'Auto chains to lite-plan with analysis artifacts' }, // Collaborative planning workflows 'collaborative-plan-with-file': { name: 'collaborative-plan-with-file', - input: ['requirement'], // 输入端口:需求 - output: ['plan-note'], // 输出端口:plan-note.md + input: ['requirement'], + output: ['plan-note'], tags: ['planning', 'with-file'], - atomic_group: 'collaborative-plan', // 最小单元:collaborative-plan → unified-execute + atomic_group: 'collaborative-plan', note: 'Multi-agent collaborative planning with Plan Note shared doc' }, 'unified-execute-with-file': { name: 'unified-execute-with-file', - input: ['plan-note', 'brainstorm-document', 'discussion-document'], // 可接受多种规划输出 - output: ['code'], // 输出端口:代码 + input: ['plan-note', 'brainstorm-document', 'discussion-document'], + output: ['code'], tags: ['execution', 'with-file'], - atomic_group: 'collaborative-plan' // 最小单元:与 collaborative-plan-with-file 绑定 + atomic_group: 'collaborative-plan' }, - 'req-plan-with-file': { - name: 'req-plan-with-file', - input: ['requirement'], // 输入端口:需求 - output: ['execution-plan'], // 输出端口:execution-plan.json + issues + 'roadmap-with-file': { + name: 'roadmap-with-file', + input: ['requirement'], + output: ['execution-plan'], tags: ['planning', 'with-file'], - atomic_group: 'requirement-plan', // 最小单元:req-plan → team-planex + atomic_group: 'roadmap-plan', note: 'Requirement decomposition with issue creation' }, + // Spec-driven workflow + 'spec-generator': { + name: 'spec-generator', + input: ['requirement'], + output: ['specification'], + tags: ['planning', 'specification'], + atomic_group: 'spec-driven', + note: '6-phase specification: product-brief → PRD → architecture → epics' + }, + // Cycle workflows (self-iterating with reflection) 'integration-test-cycle': { name: 'integration-test-cycle', - input: ['requirement'], // 输入端口:需求/模块 - output: ['test-passed'], // 输出端口:测试通过 + input: ['requirement'], + output: ['test-passed'], tags: ['testing', 'cycle'], note: 'Self-contained: explore → test dev → test-fix cycle → reflection' }, 'refactor-cycle': { name: 'refactor-cycle', - input: ['codebase'], // 输入端口:代码库 - output: ['refactored-code'], // 输出端口:重构后代码 + input: ['codebase'], + output: ['refactored-code'], tags: ['refactoring', 'cycle'], note: 'Self-contained: tech debt discovery → prioritize → execute → validate' }, - // Team workflows (multi-role collaboration, all self-contained) + // Team workflows (kept: team-planex only) 'team-planex': { name: 'team-planex', - input: ['requirement'], + input: ['requirement', 'execution-plan'], output: ['code'], tags: ['team'], note: 'Self-contained: planner + executor wave pipeline' - }, - 'team-iterdev': { - name: 'team-iterdev', - input: ['requirement'], - output: ['code'], - tags: ['team'], - note: 'Self-contained: planner → developer → reviewer iterative loop' - }, - 'team-lifecycle': { - name: 'team-lifecycle', - input: ['requirement'], - output: ['code'], - tags: ['team'], - note: 'Self-contained: spec → impl → test full lifecycle' - }, - 'team-issue': { - name: 'team-issue', - input: ['pending-issues'], - output: ['completed-issues'], - tags: ['team', 'issue'], - note: 'Self-contained: discover → plan → execute multi-role' - }, - 'team-testing': { - name: 'team-testing', - input: ['code'], - output: ['test-passed'], - tags: ['team', 'testing'], - note: 'Self-contained: strategy → generate → execute → analyze' - }, - 'team-quality-assurance': { - name: 'team-quality-assurance', - input: ['code'], - output: ['quality-report'], - tags: ['team', 'testing'], - note: 'Self-contained: scout → strategist → generator → executor → analyst' - }, - 'team-brainstorm': { - name: 'team-brainstorm', - input: ['exploration-topic'], - output: ['brainstorm-analysis'], - tags: ['team', 'brainstorm'], - note: 'Self-contained: facilitator → participants → synthesizer' - }, - 'team-uidesign': { - name: 'team-uidesign', - input: ['requirement'], - output: ['ui-code'], - tags: ['team', 'ui'], - note: 'Self-contained: designer → implementer dual-track' } }; ``` @@ -583,58 +498,46 @@ const commandPorts = { ```javascript async function recommendCommandChain(analysis) { - // Step 1: 根据任务类型确定起始端口和目标端口 const { inputPort, outputPort } = determinePortFlow(analysis.task_type, analysis.constraints); - - // Step 2: Claude 根据命令端口定义和任务特征,智能选择命令序列 - // 优先级:简单任务 → lite-* 命令,复杂任务 → 完整命令,特殊约束 → 调整流程 const chain = selectChainByPorts(inputPort, outputPort, analysis); - return chain; } -// 任务类型对应的端口流 function determinePortFlow(taskType, constraints) { const flows = { - 'bugfix': { inputPort: 'bug-report', outputPort: constraints?.includes('skip-tests') ? 'fixed-code' : 'test-passed' }, - 'tdd': { inputPort: 'requirement', outputPort: 'tdd-verified' }, - 'test-fix': { inputPort: 'failing-tests', outputPort: 'test-passed' }, - 'test-gen': { inputPort: 'code', outputPort: 'test-passed' }, - 'review': { inputPort: 'code', outputPort: 'review-verified' }, - 'brainstorm': { inputPort: 'exploration-topic', outputPort: 'test-passed' }, - 'multi-cli': { inputPort: 'requirement', outputPort: 'test-passed' }, + 'bugfix': { inputPort: 'bug-report', outputPort: constraints?.includes('skip-tests') ? 'fixed-code' : 'test-passed' }, + 'tdd': { inputPort: 'requirement', outputPort: 'tdd-verified' }, + 'test-fix': { inputPort: 'failing-tests', outputPort: 'test-passed' }, + 'test-gen': { inputPort: 'code', outputPort: 'test-passed' }, + 'review': { inputPort: 'code', outputPort: 'review-verified' }, + 'brainstorm': { inputPort: 'exploration-topic', outputPort: 'test-passed' }, + 'multi-cli': { inputPort: 'requirement', outputPort: 'test-passed' }, // Issue workflow types - 'issue-batch': { inputPort: 'codebase', outputPort: 'completed-issues' }, - 'issue-transition': { inputPort: 'requirement', outputPort: 'completed-issues' }, - // With-File workflow types - 'brainstorm-file': { inputPort: 'exploration-topic', outputPort: 'brainstorm-document' }, - 'brainstorm-to-issue': { inputPort: 'brainstorm-document', outputPort: 'completed-issues' }, - 'debug-file': { inputPort: 'bug-report', outputPort: 'understanding-document' }, - 'analyze-file': { inputPort: 'analysis-topic', outputPort: 'discussion-document' }, - 'collaborative-plan': { inputPort: 'requirement', outputPort: 'code' }, - 'req-plan': { inputPort: 'requirement', outputPort: 'code' }, + 'issue-batch': { inputPort: 'codebase', outputPort: 'completed-issues' }, + 'issue-transition': { inputPort: 'requirement', outputPort: 'completed-issues' }, + // With-File workflow types (auto chain to lite-plan) + 'brainstorm-file': { inputPort: 'exploration-topic', outputPort: 'code' }, + 'brainstorm-to-issue': { inputPort: 'brainstorm-document', outputPort: 'completed-issues' }, + 'debug-file': { inputPort: 'bug-report', outputPort: 'understanding-document' }, + 'analyze-file': { inputPort: 'analysis-topic', outputPort: 'code' }, + 'collaborative-plan': { inputPort: 'requirement', outputPort: 'code' }, + 'roadmap': { inputPort: 'requirement', outputPort: 'code' }, + 'spec-driven': { inputPort: 'requirement', outputPort: 'test-passed' }, // Cycle workflow types - 'integration-test': { inputPort: 'requirement', outputPort: 'test-passed' }, - 'refactor': { inputPort: 'codebase', outputPort: 'refactored-code' }, - // Team workflow types (all self-contained) - 'team-planex': { inputPort: 'requirement', outputPort: 'code' }, - 'team-iterdev': { inputPort: 'requirement', outputPort: 'code' }, - 'team-lifecycle': { inputPort: 'requirement', outputPort: 'code' }, - 'team-issue': { inputPort: 'pending-issues', outputPort: 'completed-issues' }, - 'team-testing': { inputPort: 'code', outputPort: 'test-passed' }, - 'team-qa': { inputPort: 'code', outputPort: 'quality-report' }, - 'team-brainstorm': { inputPort: 'exploration-topic', outputPort: 'brainstorm-analysis' }, - 'team-uidesign': { inputPort: 'requirement', outputPort: 'ui-code' }, - 'feature': { inputPort: 'requirement', outputPort: constraints?.includes('skip-tests') ? 'code' : 'test-passed' } + 'integration-test': { inputPort: 'requirement', outputPort: 'test-passed' }, + 'refactor': { inputPort: 'codebase', outputPort: 'refactored-code' }, + // Team workflows (kept: team-planex only) + 'team-planex': { inputPort: 'requirement', outputPort: 'code' }, + // Additional task types (harmonized with ccw.md) + 'bugfix-hotfix': { inputPort: 'bug-report', outputPort: 'fixed-code' }, + 'exploration': { inputPort: 'exploration-topic', outputPort: 'test-passed' }, + 'quick-task': { inputPort: 'requirement', outputPort: constraints?.includes('skip-tests') ? 'code' : 'test-passed' }, + 'ui-design': { inputPort: 'requirement', outputPort: 'code' }, + 'documentation': { inputPort: 'requirement', outputPort: 'code' }, + 'feature': { inputPort: 'requirement', outputPort: constraints?.includes('skip-tests') ? 'code' : 'test-passed' } }; return flows[taskType] || flows['feature']; } - -// Claude 根据端口流选择命令链 -function selectChainByPorts(inputPort, outputPort, analysis) { - // 参考下面的命令端口定义表和执行示例,Claude 智能选择合适的命令序列 - // 返回值示例: [lite-plan, lite-execute, test-cycle-execute] -} ``` #### Display to User @@ -701,22 +604,17 @@ async function executeCommandChain(chain, analysis) { prompts_used: [] }; - // Save initial state immediately after confirmation Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2)); for (let i = 0; i < chain.length; i++) { const cmd = chain[i]; console.log(`[${i+1}/${chain.length}] ${cmd.command}`); - // Update command_chain status to running state.command_chain[i].status = 'running'; state.updated_at = new Date().toISOString(); Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2)); - // Assemble prompt: Command first, then context let promptContent = formatCommand(cmd, state.execution_results, analysis); - - // Build full prompt: Command → Task → Previous Results let prompt = `${promptContent}\n\nTask: ${analysis.goal}`; if (state.execution_results.length > 0) { prompt += '\n\nPrevious results:\n'; @@ -727,31 +625,17 @@ async function executeCommandChain(chain, analysis) { }); } - // Record prompt used - state.prompts_used.push({ - index: i, - command: cmd.command, - prompt: prompt - }); + state.prompts_used.push({ index: i, command: cmd.command, prompt: prompt }); - // Execute CLI command in background and stop - // Format: ccw cli -p "PROMPT" --tool --mode - // Note: -y is a command parameter INSIDE the prompt, not a ccw cli parameter - // Example prompt: "/workflow-plan -y \"task description here\"" try { const taskId = Bash( `ccw cli -p "${escapePrompt(prompt)}" --tool claude --mode write`, { run_in_background: true } ).task_id; - // Save checkpoint state.execution_results.push({ - index: i, - command: cmd.command, - status: 'in-progress', - task_id: taskId, - session_id: null, - artifacts: [], + index: i, command: cmd.command, status: 'in-progress', + task_id: taskId, session_id: null, artifacts: [], timestamp: new Date().toISOString() }); state.command_chain[i].status = 'running'; @@ -778,34 +662,23 @@ async function executeCommandChain(chain, analysis) { }] }); - if (action.error === 'Retry') { - state.command_chain[i].status = 'pending'; - state.execution_results.pop(); - i--; - } else if (action.error === 'Skip') { - state.execution_results[state.execution_results.length - 1].status = 'skipped'; - } else if (action.error === 'Abort') { - state.status = 'failed'; - break; - } + if (action.error === 'Retry') { state.command_chain[i].status = 'pending'; state.execution_results.pop(); i--; } + else if (action.error === 'Skip') { state.execution_results[state.execution_results.length - 1].status = 'skipped'; } + else if (action.error === 'Abort') { state.status = 'failed'; break; } } Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2)); } - // Hook callbacks handle completion if (state.status !== 'failed') state.status = 'waiting'; state.updated_at = new Date().toISOString(); Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2)); - console.log(`\n📋 Orchestrator paused: ${state.session_id}\n`); return state; } // Smart parameter assembly -// Returns prompt content to be used with: ccw cli -p "RETURNED_VALUE" --tool claude --mode write function formatCommand(cmd, previousResults, analysis) { - // Format: /workflow: -y let prompt = `/workflow:${cmd.name} -y`; const name = cmd.name; @@ -813,123 +686,93 @@ function formatCommand(cmd, previousResults, analysis) { if (['lite-plan', 'plan', 'tdd-plan', 'multi-cli-plan'].includes(name)) { prompt += ` "${analysis.goal}"`; - // Lite execution - use --in-memory if plan exists } else if (name === 'lite-execute') { const hasPlan = previousResults.some(r => r.command.includes('plan')); prompt += hasPlan ? ' --in-memory' : ` "${analysis.goal}"`; - // Standard execution - resume from planning session } else if (name === 'execute') { const plan = previousResults.find(r => r.command.includes('plan')); if (plan?.session_id) prompt += ` --resume-session="${plan.session_id}"`; - // Bug fix commands - use lite-plan with bugfix flag (lite-fix removed) } else if (name === 'lite-plan' && analysis.task_type === 'bugfix') { prompt += ` --bugfix "${analysis.goal}"`; - // Debug commands - take bug description } else if (name === 'debug') { prompt += ` "${analysis.goal}"`; - // Brainstorm - take topic description (unified brainstorm skill) } else if (name === 'brainstorm') { - prompt += ` "${analysis.goal}"`; - prompt = `/brainstorm -y ${prompt.trim()}`; - // Test generation from session - needs source session - } else if (name === 'test-gen') { - const impl = previousResults.find(r => - r.command.includes('execute') || r.command.includes('lite-execute') - ); - if (impl?.session_id) prompt += ` "${impl.session_id}"`; - else prompt += ` "${analysis.goal}"`; + prompt = `/brainstorm -y "${analysis.goal}"`; + + } else if (name === 'spec-generator') { + prompt = `/spec-generator -y "${analysis.goal}"`; + + } else if (name === 'test-gen') { + const impl = previousResults.find(r => r.command.includes('execute') || r.command.includes('lite-execute')); + prompt += impl?.session_id ? ` "${impl.session_id}"` : ` "${analysis.goal}"`; - // Test fix generation - session or description } else if (name === 'test-fix-gen') { const latest = previousResults.filter(r => r.session_id).pop(); - if (latest?.session_id) prompt += ` "${latest.session_id}"`; - else prompt += ` "${analysis.goal}"`; + prompt += latest?.session_id ? ` "${latest.session_id}"` : ` "${analysis.goal}"`; - // Review commands - take session or use latest } else if (name === 'review') { const latest = previousResults.filter(r => r.session_id).pop(); if (latest?.session_id) prompt += ` --session="${latest.session_id}"`; - // Review fix - takes session from review } else if (name === 'review-cycle-fix') { const review = previousResults.find(r => r.command.includes('review')); const latest = review || previousResults.filter(r => r.session_id).pop(); if (latest?.session_id) prompt += ` --session="${latest.session_id}"`; - // TDD verify - takes execution session } else if (name === 'tdd-verify') { const exec = previousResults.find(r => r.command.includes('execute')); if (exec?.session_id) prompt += ` --session="${exec.session_id}"`; - // Session-based commands (test-cycle, review-session, plan-verify) } else if (name.includes('test') || name.includes('review') || name.includes('verify')) { const latest = previousResults.filter(r => r.session_id).pop(); if (latest?.session_id) prompt += ` --session="${latest.session_id}"`; // Issue workflow commands } else if (name === 'issue:discover') { - // No parameters needed - discovers from codebase prompt = `/issue:discover -y`; - } else if (name === 'issue:plan') { prompt = `/issue:plan -y --all-pending`; - } else if (name === 'issue:queue') { prompt = `/issue:queue -y`; - } else if (name === 'issue:execute') { prompt = `/issue:execute -y --queue auto`; - } else if (name === 'issue:convert-to-plan' || name === 'convert-to-plan') { - // Convert latest lite-plan to issue plan prompt = `/issue:convert-to-plan -y --latest-lite-plan`; - // With-File workflows (self-contained) + // With-File workflows } else if (name === 'brainstorm-with-file') { prompt = `/workflow:brainstorm-with-file -y "${analysis.goal}"`; - } else if (name === 'debug-with-file') { prompt = `/workflow:debug-with-file -y "${analysis.goal}"`; - } else if (name === 'analyze-with-file') { prompt = `/workflow:analyze-with-file -y "${analysis.goal}"`; - - // Brainstorm-to-issue bridge } else if (name === 'issue:from-brainstorm' || name === 'from-brainstorm') { - // Extract session ID from analysis.goal or latest brainstorm const sessionMatch = analysis.goal.match(/BS-[\w-]+/); - if (sessionMatch) { - prompt = `/issue:from-brainstorm -y SESSION="${sessionMatch[0]}" --auto`; - } else { - // Find latest brainstorm session - prompt = `/issue:from-brainstorm -y --auto`; - } + prompt = sessionMatch + ? `/issue:from-brainstorm -y SESSION="${sessionMatch[0]}" --auto` + : `/issue:from-brainstorm -y --auto`; // Collaborative planning workflows } else if (name === 'collaborative-plan-with-file') { prompt = `/workflow:collaborative-plan-with-file -y "${analysis.goal}"`; - } else if (name === 'unified-execute-with-file') { prompt = `/workflow:unified-execute-with-file -y`; - - } else if (name === 'req-plan-with-file') { - prompt = `/workflow:req-plan-with-file -y "${analysis.goal}"`; + } else if (name === 'roadmap-with-file') { + prompt = `/workflow:roadmap-with-file -y "${analysis.goal}"`; // Cycle workflows (self-contained) } else if (name === 'integration-test-cycle') { prompt = `/workflow:integration-test-cycle -y "${analysis.goal}"`; - } else if (name === 'refactor-cycle') { prompt = `/workflow:refactor-cycle -y "${analysis.goal}"`; - // Team workflows (all self-contained, use Skill name directly) - } else if (['team-planex', 'team-iterdev', 'team-lifecycle', 'team-issue', - 'team-testing', 'team-quality-assurance', 'team-brainstorm', 'team-uidesign'].includes(name)) { - prompt = `/${name} -y "${analysis.goal}"`; + // Team workflows (kept: team-planex only) + } else if (name === 'team-planex') { + prompt = `/team-planex -y "${analysis.goal}"`; } return prompt; @@ -941,15 +784,11 @@ async function handleCliCompletion(sessionId, taskId, output) { const state = JSON.parse(Read(`${stateDir}/state.json`)); const pendingIdx = state.execution_results.findIndex(r => r.task_id === taskId); - if (pendingIdx === -1) { - console.error(`Unknown task_id: ${taskId}`); - return; - } + if (pendingIdx === -1) return; const parsed = parseOutput(output); const cmdIdx = state.execution_results[pendingIdx].index; - // Update result state.execution_results[pendingIdx] = { ...state.execution_results[pendingIdx], status: parsed.sessionId ? 'completed' : 'failed', @@ -961,24 +800,14 @@ async function handleCliCompletion(sessionId, taskId, output) { state.updated_at = new Date().toISOString(); Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2)); - // Trigger next command or complete const nextIdx = cmdIdx + 1; if (nextIdx < state.command_chain.length) { await resumeChainExecution(sessionId, nextIdx); } else { state.status = 'completed'; Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2)); - console.log(`✅ Completed: ${sessionId}\n`); } } - -// Parse command output -function parseOutput(output) { - const sessionMatch = output.match(/WFS-[\w-]+/); - const artifacts = []; - output.matchAll(/\.workflow\/[^\s]+/g).forEach(m => artifacts.push(m[0])); - return { sessionId: sessionMatch?.[0] || null, artifacts }; -} ``` ## State File Structure @@ -998,66 +827,21 @@ function parseOutput(output) { "complexity": "medium" }, "command_chain": [ - { - "index": 0, - "command": "/workflow-plan", - "name": "plan", - "description": "Detailed planning", - "argumentHint": "[--explore] \"task\"", - "status": "completed" - }, - { - "index": 1, - "command": "/workflow-execute", - "name": "execute", - "description": "Execute with state resume", - "argumentHint": "[--resume-session=\"WFS-xxx\"]", - "status": "completed" - }, - { - "index": 2, - "command": "/workflow-test-fix", - "name": "test-cycle-execute", - "status": "pending" - } + { "index": 0, "command": "/workflow-plan", "name": "plan", "status": "completed" }, + { "index": 1, "command": "/workflow-execute", "name": "execute", "status": "running" } ], "execution_results": [ { - "index": 0, - "command": "/workflow-plan", - "status": "completed", - "task_id": "task-001", - "session_id": "WFS-plan-20250124", - "artifacts": ["IMPL_PLAN.md", "exploration-architecture.json"], - "timestamp": "2025-01-24T14:30:25Z", - "completed_at": "2025-01-24T14:30:45Z" - }, - { - "index": 1, - "command": "/workflow-execute", - "status": "in-progress", - "task_id": "task-002", - "session_id": null, - "artifacts": [], - "timestamp": "2025-01-24T14:32:00Z", - "completed_at": null - } - ], - "prompts_used": [ - { - "index": 0, - "command": "/workflow-plan", - "prompt": "/workflow-plan -y \"Implement user registration...\"\n\nTask: Implement user registration..." - }, - { - "index": 1, - "command": "/workflow-execute", - "prompt": "/workflow-execute -y --resume-session=\"WFS-plan-20250124\"\n\nTask: Implement user registration\n\nPrevious results:\n- /workflow-plan: WFS-plan-20250124 (IMPL_PLAN.md)" + "index": 0, "command": "/workflow-plan", "status": "completed", + "task_id": "task-001", "session_id": "WFS-plan-20250124", + "artifacts": ["IMPL_PLAN.md"], "timestamp": "2025-01-24T14:30:25Z" } ] } ``` +**Status Values**: `running` → `waiting` → `completed` | `failed` + ### Status Flow ``` @@ -1066,30 +850,6 @@ running → waiting → [hook callback] → waiting → [hook callback] → comp failed ←────────────────────────────────────────────────────────────┘ ``` -**Status Values**: -- `running`: Orchestrator actively executing (launching CLI commands) -- `waiting`: Paused, waiting for hook callbacks to trigger continuation -- `completed`: All commands finished successfully -- `failed`: User aborted or unrecoverable error - -### Field Descriptions - -**execution_results[] fields**: -- `index`: Command position in chain (0-indexed) -- `command`: Full command string (e.g., `workflow-plan` skill) -- `status`: `in-progress` | `completed` | `skipped` | `failed` -- `task_id`: Background task identifier (from Bash tool) -- `session_id`: Workflow session ID (e.g., `WFS-*`) or null if failed -- `artifacts`: Generated files/directories -- `timestamp`: Command start time (ISO 8601) -- `completed_at`: Command completion time or null if pending - -**command_chain[] status values**: -- `pending`: Not started yet -- `running`: Currently executing -- `completed`: Successfully finished -- `failed`: Failed to execute - ## Skill & Command Discovery workflow 操作通过 `Skill()` 调用对应的 Skill。 @@ -1099,107 +859,14 @@ workflow 操作通过 `Skill()` 调用对应的 Skill。 Skill({ skill: 'workflow-lite-plan', args: '"task description"' }); Skill({ skill: 'workflow-execute', args: '--resume-session="WFS-xxx"' }); Skill({ skill: 'brainstorm', args: '"exploration topic"' }); +Skill({ skill: 'spec-generator', args: '"product specification"' }); -// 独立命令调用方式 +// 命名空间命令调用方式 Skill({ skill: 'workflow:brainstorm-with-file', args: '"topic"' }); +Skill({ skill: 'workflow:roadmap-with-file', args: '"requirement"' }); Skill({ skill: 'issue:discover', args: '' }); ``` -## Universal Prompt Template - -### Standard Format - -```bash -ccw cli -p "PROMPT_CONTENT" --tool --mode -``` - -### Prompt Content Template - -``` -/workflow: -y - -Task: - - -``` - -### Template Variables - -| Variable | Description | Examples | -|----------|-------------|----------| -| `` | Workflow command name | `plan`, `lite-execute`, `test-cycle-execute` | -| `-y` | Auto-confirm flag (inside prompt) | Always include for automation | -| `` | Command-specific parameters | Task description, session ID, flags | -| `` | Brief task description | "Implement user authentication", "Fix memory leak" | -| `` | Context from previous commands | "Previous results:\n- /workflow-plan: WFS-xxx" | - -### Command Parameter Patterns - -| Command Type | Parameter Pattern | Example | -|--------------|------------------|---------| -| **Planning** | `"task description"` | `/workflow-plan -y "Implement OAuth2"` | -| **Execution (with plan)** | `--resume-session="WFS-xxx"` | `/workflow-execute -y --resume-session="WFS-plan-001"` | -| **Execution (standalone)** | `--in-memory` or `"task"` | `/workflow:lite-execute -y --in-memory` | -| **Session-based** | `--session="WFS-xxx"` | `/workflow-test-fix -y --session="WFS-impl-001"` | -| **Fix/Debug** | `--bugfix "problem description"` | `/workflow-lite-plan -y --bugfix "Fix timeout bug"` | - -### Complete Examples - -**Planning Command**: -```bash -ccw cli -p '/workflow-plan -y "Implement user registration with email validation" - -Task: Implement user registration' --tool claude --mode write -``` - -**Execution with Context**: -```bash -ccw cli -p '/workflow-execute -y --resume-session="WFS-plan-20250124" - -Task: Implement user registration - -Previous results: -- /workflow-plan: WFS-plan-20250124 (IMPL_PLAN.md)' --tool claude --mode write -``` - -**Standalone Lite Execution**: -```bash -ccw cli -p '/workflow-lite-plan -y --bugfix "Fix login timeout in auth module" - -Task: Fix login timeout' --tool claude --mode write -``` - -## Execution Flow - -```javascript -// Main entry point -async function ccwCoordinator(taskDescription) { - // Phase 1 - const analysis = await analyzeRequirements(taskDescription); - - // Phase 2 - const chain = await recommendCommandChain(analysis); - const confirmedChain = await getUserConfirmation(chain); - - // Phase 3 - const state = await executeCommandChain(confirmedChain, analysis); - - console.log(`✅ Complete! Session: ${state.session_id}`); - console.log(`State: .workflow/.ccw-coordinator/${state.session_id}/state.json`); -} -``` - -## Key Design Principles - -1. **No Fixed Logic** - Claude intelligently decides based on analysis -2. **Dynamic Discovery** - CommandRegistry retrieves available commands -3. **Smart Parameters** - Command args assembled based on previous results -4. **Full State Tracking** - All execution recorded to state.json -5. **User Control** - Confirmation + error handling with user choice -6. **Context Passing** - Each prompt includes previous results -7. **Resumable** - Can load state.json to continue -8. **Serial Blocking** - Commands execute one-by-one with hook-based continuation - ## CLI Execution Model ### CLI Invocation Format @@ -1229,27 +896,6 @@ Task: ``` -**Examples**: -```bash -# Planning command -ccw cli -p '/workflow-plan -y "Implement user registration feature" - -Task: Implement user registration' --tool claude --mode write - -# Execution command (with session reference) -ccw cli -p '/workflow-execute -y --resume-session="WFS-plan-20250124" - -Task: Implement user registration - -Previous results: -- /workflow-plan: WFS-plan-20250124' --tool claude --mode write - -# Lite execution (in-memory from previous plan) -ccw cli -p '/workflow:lite-execute -y --in-memory - -Task: Implement user registration' --tool claude --mode write -``` - ### Serial Blocking **CRITICAL**: Commands execute one-by-one. After launching CLI in background: @@ -1257,21 +903,6 @@ Task: Implement user registration' --tool claude --mode write 2. Wait for hook callback - **DO NOT use TaskOutput polling** 3. Hook callback triggers next command -**Prompt Structure**: Command must be first in prompt content - -```javascript -// Example: Execute command and stop -const prompt = '/workflow-plan -y "Implement user authentication"\n\nTask: Implement user auth system'; -const taskId = Bash(`ccw cli -p "${prompt}" --tool claude --mode write`, { run_in_background: true }).task_id; -state.execution_results.push({ status: 'in-progress', task_id: taskId, ... }); -Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2)); -break; // ⚠️ STOP HERE - DO NOT use TaskOutput polling - -// Hook callback will call handleCliCompletion(sessionId, taskId, output) when done -// → Updates state → Triggers next command via resumeChainExecution() -``` - - ## Available Skills & Commands ### Skills @@ -1286,25 +917,18 @@ break; // ⚠️ STOP HERE - DO NOT use TaskOutput polling | `workflow-tdd-plan` | tdd-plan, tdd-verify | | `review-cycle` | review-session-cycle, review-module-cycle, review-cycle-fix | | `brainstorm` | auto-parallel, artifacts, role-analysis, synthesis | +| `spec-generator` | product-brief → PRD → architecture → epics | | `team-planex` | planner + executor wave pipeline | -| `team-iterdev` | planner → developer → reviewer 循环 | -| `team-lifecycle` | spec → impl → test 全流程 | -| `team-issue` | discover → plan → execute 多角色 | -| `team-testing` | strategy → generate → execute → analyze | -| `team-quality-assurance` | scout → strategist → generator → executor → analyst | -| `team-brainstorm` | facilitator → participants → synthesizer | -| `team-uidesign` | designer → implementer dual-track | ### Commands(命名空间 Skill) -**With-File Workflows**: workflow:brainstorm-with-file, workflow:debug-with-file, workflow:analyze-with-file, workflow:collaborative-plan-with-file, workflow:req-plan-with-file +**With-File Workflows**: workflow:brainstorm-with-file, workflow:debug-with-file, workflow:analyze-with-file, workflow:collaborative-plan-with-file, workflow:roadmap-with-file **Cycle Workflows**: workflow:integration-test-cycle, workflow:refactor-cycle **Execution**: workflow:unified-execute-with-file **Design**: workflow:ui-design:* -**Session Management**: workflow:session:start, workflow:session:resume, workflow:session:complete, workflow:session:solidify, workflow:session:list -**Tools**: workflow:tools:context-gather, workflow:tools:test-context-gather, workflow:tools:task-generate-agent, workflow:tools:conflict-resolution -**Utility**: workflow:clean, workflow:init, workflow:init-guidelines -**Issue Workflow**: issue:discover, issue:plan, issue:queue, issue:execute, issue:convert-to-plan, issue:from-brainstorm, issue:new +**Session Management**: workflow:session:start, workflow:session:resume, workflow:session:complete, workflow:session:solidify, workflow:session:list, workflow:session:sync +**Utility**: workflow:clean, workflow:init, workflow:init-guidelines, workflow:status +**Issue Workflow**: issue:discover, issue:discover-by-prompt, issue:plan, issue:queue, issue:execute, issue:convert-to-plan, issue:from-brainstorm, issue:new ### Testing Commands Distinction @@ -1314,10 +938,6 @@ break; // ⚠️ STOP HERE - DO NOT use TaskOutput polling | **test-fix-gen** | 针对特定问题生成测试并在测试中修正 | test-tasks | Skill(workflow-test-fix) → test-cycle-execute | | **test-cycle-execute** | 执行测试周期(迭代测试和修复) | test-passed | N/A (终点) | -**流程说明**: -- **test-gen → Skill(workflow-execute)**: 生成全面的测试套件,execute 执行生成和测试 -- **test-fix-gen → test-cycle-execute**: 同属 Skill(workflow-test-fix),针对特定问题生成修复任务并迭代测试和修复直到通过 - ### Task Type Routing (Pipeline Summary) **Note**: `【 】` marks Minimum Execution Units (最小执行单元) - these commands must execute together. @@ -1333,24 +953,22 @@ break; // ⚠️ STOP HERE - DO NOT use TaskOutput polling | **review** | 代码 →【review-* → review-cycle-fix】→ 修复代码 →【test-fix-gen → test-cycle-execute】→ 测试通过 | Code Review + Testing | | **brainstorm** | 探索主题 → brainstorm → 分析 →【plan → plan-verify】→ execute → test | Exploration + Planning + Execution | | **multi-cli** | 需求 → multi-cli-plan → 对比分析 → lite-execute → test | Multi-Perspective + Testing | +| **spec-driven** | 需求 →【spec-generator → plan → execute】→ 代码 →【test-fix-gen → test-cycle-execute】→ 测试通过 | Spec-Driven + Testing | | **issue-batch** | 代码库 →【discover → plan → queue → execute】→ 完成 issues | Issue Workflow | | **issue-transition** | 需求 →【lite-plan → convert-to-plan → queue → execute】→ 完成 issues | Rapid-to-Issue | -| **brainstorm-file** | 主题 → brainstorm-with-file → brainstorm.md (自包含) | Brainstorm With File | +| **analyze-file** | 分析主题 →【analyze-with-file → lite-plan → lite-execute】→ 代码 | Analyze to Plan | +| **brainstorm-file** | 主题 →【brainstorm-with-file → lite-plan → lite-execute】→ 代码 | Brainstorm to Plan | | **brainstorm-to-issue** | brainstorm.md →【from-brainstorm → queue → execute】→ 完成 issues | Brainstorm to Issue | | **debug-file** | Bug报告 → debug-with-file → understanding.md (自包含) | Debug With File | -| **analyze-file** | 分析主题 → analyze-with-file → discussion.md (自包含) | Analyze With File | | **collaborative-plan** | 需求 →【collaborative-plan-with-file → unified-execute-with-file】→ 代码 | Collaborative Plan | -| **req-plan** | 需求 →【req-plan-with-file → team-planex】→ 代码 | Requirement Plan | -| **multi-cli** | 需求 → multi-cli-plan → 对比分析 → lite-execute → test | Multi-CLI Planning | +| **roadmap** | 需求 →【roadmap-with-file → team-planex】→ 代码 | Roadmap Plan | | **integration-test** | 需求/模块 → integration-test-cycle → 测试通过 (自包含) | Integration Test Cycle | | **refactor** | 代码库 → refactor-cycle → 重构后代码 (自包含) | Refactor Cycle | | **team-planex** | 需求 → team-planex → 代码 (自包含) | Team Plan+Execute | -| **team-iterdev** | 需求 → team-iterdev → 代码 (自包含) | Team Iterative Dev | -| **team-lifecycle** | 需求 → team-lifecycle → 代码 (自包含) | Team Lifecycle | -| **team-issue** | issues → team-issue → 完成 issues (自包含) | Team Issue | -| **team-testing** | 代码 → team-testing → 测试通过 (自包含) | Team Testing | -| **team-qa** | 代码 → team-quality-assurance → 质量报告 (自包含) | Team QA | -| **team-brainstorm** | 主题 → team-brainstorm → 分析 (自包含) | Team Brainstorm | -| **team-uidesign** | 需求 → team-uidesign → UI代码 (自包含) | Team UI Design | +| **bugfix-hotfix** | Bug报告(紧急) → lite-plan (--hotfix) → 修复代码 | Hotfix (skip tests) | +| **exploration** | 探索主题 → brainstorm →【plan → execute】→ 代码 → test | Exploration + Planning | +| **quick-task** | 需求 →【lite-plan → lite-execute】→ 代码 → test | Quick Implementation | +| **ui-design** | UI需求 → ui-design:explore → plan → execute → 代码 | UI Design | +| **documentation** | 文档需求 → lite-plan → lite-execute → 文档 | Documentation | Refer to the Skill 映射 section above for available Skills and Commands. diff --git a/.claude/commands/ccw.md b/.claude/commands/ccw.md index c2c286c3..8a36b0a6 100644 --- a/.claude/commands/ccw.md +++ b/.claude/commands/ccw.md @@ -23,20 +23,12 @@ Main process orchestrator: intent analysis → workflow selection → command ch | `workflow-multi-cli-plan` | ACE context → CLI discussion → plan → execute | | `review-cycle` | session/module review → fix orchestration | | `brainstorm` | auto/single-role → artifacts → analysis → synthesis | +| `spec-generator` | product-brief → PRD → architecture → epics | | `workflow:collaborative-plan-with-file` | understanding agent → parallel agents → plan-note.md | -| `workflow:req-plan-with-file` | requirement decomposition → issue creation → execution-plan.json | +| `workflow:roadmap-with-file` | strategic requirement roadmap → issue creation → execution-plan.json | | `workflow:integration-test-cycle` | explore → test dev → test-fix cycle → reflection | | `workflow:refactor-cycle` | tech debt discovery → prioritize → execute → validate | -| `team-planex` | planner + executor wave pipeline(边规划边执行)| -| `team-iterdev` | 迭代开发团队(planner → developer → reviewer 循环)| -| `team-lifecycle` | 全生命周期团队(spec → impl → test)| -| `team-issue` | issue 解决团队(discover → plan → execute)| -| `team-testing` | 测试团队(strategy → generate → execute → analyze)| -| `team-quality-assurance` | QA 团队(scout → strategist → generator → executor → analyst)| -| `team-brainstorm` | 团队头脑风暴(facilitator → participants → synthesizer)| -| `team-uidesign` | UI 设计团队(designer → implementer dual-track)| - -独立命令(仍使用 colon 格式):workflow:brainstorm-with-file, workflow:debug-with-file, workflow:analyze-with-file, workflow:collaborative-plan-with-file, workflow:req-plan-with-file, workflow:integration-test-cycle, workflow:refactor-cycle, workflow:unified-execute-with-file, workflow:clean, workflow:init, workflow:init-guidelines, workflow:ui-design:*, issue:*, workflow:session:* +| `team-planex` | planner + executor wave pipeline(适合大量零散 issue 或 roadmap 产出的清晰 issue,实现 0→1 开发)| ## Core Concept: Self-Contained Skills (自包含 Skill) @@ -54,21 +46,16 @@ Main process orchestrator: intent analysis → workflow selection → command ch | 轻量 Plan+Execute | `workflow-lite-plan` | 内部完成 plan→execute | | 标准 Planning | `workflow-plan` → `workflow-execute` | plan 和 execute 是独立 Skill | | TDD Planning | `workflow-tdd-plan` → `workflow-execute` | tdd-plan 和 execute 是独立 Skill | +| 规格驱动 | `spec-generator` → `workflow-plan` → `workflow-execute` | 规格文档驱动完整开发 | | 测试流水线 | `workflow-test-fix` | 内部完成 gen→cycle | | 代码审查 | `review-cycle` | 内部完成 review→fix | | 多CLI协作 | `workflow-multi-cli-plan` | ACE context → CLI discussion → plan → execute | -| 协作规划 | `workflow:collaborative-plan-with-file` | 多 agent 协作生成 plan-note.md | -| 需求路线图 | `workflow:req-plan-with-file` | 需求拆解→issue 创建→执行计划 | +| 分析→规划 | `workflow:analyze-with-file` → `workflow-lite-plan` | 协作分析产物自动传递给 lite-plan | +| 头脑风暴→规划 | `workflow:brainstorm-with-file` → `workflow-lite-plan` | 头脑风暴产物自动传递给 lite-plan | +| 协作规划 | `workflow:collaborative-plan-with-file` → `workflow:unified-execute-with-file` | 多 agent 协作规划→通用执行 | +| 需求路线图 | `workflow:roadmap-with-file` → `team-planex` | 需求拆解→issue 创建→wave pipeline 执行 | | 集成测试循环 | `workflow:integration-test-cycle` | 自迭代集成测试闭环 | | 重构循环 | `workflow:refactor-cycle` | 技术债务发现→重构→验证 | -| 团队 Plan+Execute | `team-planex` | 2 人团队 wave pipeline,边规划边执行 | -| 团队迭代开发 | `team-iterdev` | 多角色迭代开发闭环 | -| 团队全生命周期 | `team-lifecycle` | spec→impl→test 全流程 | -| 团队 Issue | `team-issue` | 多角色协作 issue 解决 | -| 团队测试 | `team-testing` | 多角色测试流水线 | -| 团队 QA | `team-quality-assurance` | 多角色质量保障闭环 | -| 团队头脑风暴 | `team-brainstorm` | 多角色协作头脑风暴 | -| 团队 UI 设计 | `team-uidesign` | dual-track 设计+实现 | ## Execution Model @@ -136,27 +123,21 @@ function analyzeIntent(input) { function detectTaskType(text) { const patterns = { 'bugfix-hotfix': /urgent|production|critical/ && /fix|bug/, - // With-File workflows (documented exploration with multi-CLI collaboration) + // With-File workflows (documented exploration → auto chain to lite-plan) 'brainstorm': /brainstorm|ideation|头脑风暴|创意|发散思维|creative thinking|multi-perspective.*think|compare perspectives|探索.*可能/, 'brainstorm-to-issue': /brainstorm.*issue|头脑风暴.*issue|idea.*issue|想法.*issue|从.*头脑风暴|convert.*brainstorm/, 'debug-file': /debug.*document|hypothesis.*debug|troubleshoot.*track|investigate.*log|调试.*记录|假设.*验证|systematic debug|深度调试/, 'analyze-file': /analyze.*document|explore.*concept|understand.*architecture|investigate.*discuss|collaborative analysis|分析.*讨论|深度.*理解|协作.*分析/, 'collaborative-plan': /collaborative.*plan|协作.*规划|多人.*规划|multi.*agent.*plan|Plan Note|分工.*规划/, - 'req-plan': /roadmap|需求.*规划|需求.*拆解|requirement.*plan|req.*plan|progressive.*plan|路线.*图/, + 'roadmap': /roadmap|需求.*规划|需求.*拆解|requirement.*plan|progressive.*plan|路线.*图/, + 'spec-driven': /spec.*gen|specification|PRD|产品需求|产品文档|产品规格/, // Cycle workflows (self-iterating with reflection) 'integration-test': /integration.*test|集成测试|端到端.*测试|e2e.*test|integration.*cycle/, 'refactor': /refactor|重构|tech.*debt|技术债务/, - // Team workflows (multi-role collaboration, explicit "team" keyword required) + // Team workflows (kept: team-planex only) 'team-planex': /team.*plan.*exec|team.*planex|团队.*规划.*执行|并行.*规划.*执行|wave.*pipeline/, - 'team-iterdev': /team.*iter|team.*iterdev|迭代.*开发.*团队|iterative.*dev.*team/, - 'team-lifecycle': /team.*lifecycle|全生命周期|full.*lifecycle|spec.*impl.*test.*team/, - 'team-issue': /team.*issue.*resolv|团队.*issue|team.*resolve.*issue/, - 'team-testing': /team.*test|测试团队|comprehensive.*test.*team|全面.*测试.*团队/, - 'team-qa': /team.*qa|quality.*assurance.*team|QA.*团队|质量.*保障.*团队|团队.*质量/, - 'team-brainstorm': /team.*brainstorm|团队.*头脑风暴|team.*ideation|多人.*头脑风暴/, - 'team-uidesign': /team.*ui.*design|UI.*设计.*团队|dual.*track.*design|团队.*UI/, // Standard workflows - 'multi-cli-plan': /multi.*cli|多.*CLI|多模型.*协作|multi.*model.*collab/, + 'multi-cli': /multi.*cli|多.*CLI|多模型.*协作|multi.*model.*collab/, 'bugfix': /fix|bug|error|crash|fail|debug/, 'issue-batch': /issues?|batch/ && /fix|resolve/, 'issue-transition': /issue workflow|structured workflow|queue|multi-stage/, @@ -165,6 +146,7 @@ function detectTaskType(text) { 'ui-design': /ui|design|component|style/, 'tdd': /tdd|test-driven|test first/, 'test-fix': /test fail|fix test|failing test/, + 'test-gen': /generate test|写测试|add test|补充测试/, 'review': /review|code review/, 'documentation': /docs|documentation|readme/ }; @@ -202,34 +184,29 @@ async function clarifyRequirements(analysis) { function selectWorkflow(analysis) { const levelMap = { 'bugfix-hotfix': { level: 2, flow: 'bugfix.hotfix' }, - // With-File workflows (documented exploration with multi-CLI collaboration) - 'brainstorm': { level: 4, flow: 'brainstorm-with-file' }, // Multi-perspective ideation - 'brainstorm-to-issue': { level: 4, flow: 'brainstorm-to-issue' }, // Brainstorm → Issue workflow - 'debug-file': { level: 3, flow: 'debug-with-file' }, // Hypothesis-driven debugging - 'analyze-file': { level: 3, flow: 'analyze-with-file' }, // Collaborative analysis + // With-File workflows → auto chain to lite-plan + 'brainstorm': { level: 4, flow: 'brainstorm-to-plan' }, // brainstorm-with-file → lite-plan + 'brainstorm-to-issue': { level: 4, flow: 'brainstorm-to-issue' }, // Brainstorm → Issue workflow + 'debug-file': { level: 3, flow: 'debug-with-file' }, // Hypothesis-driven debugging (standalone) + 'analyze-file': { level: 3, flow: 'analyze-to-plan' }, // analyze-with-file → lite-plan 'collaborative-plan': { level: 3, flow: 'collaborative-plan' }, // Multi-agent collaborative planning - 'req-plan': { level: 4, flow: 'req-plan' }, // Requirement-level roadmap planning + 'roadmap': { level: 4, flow: 'roadmap' }, // roadmap → team-planex + 'spec-driven': { level: 4, flow: 'spec-driven' }, // spec-generator → plan → execute // Cycle workflows (self-iterating with reflection) - 'integration-test': { level: 3, flow: 'integration-test-cycle' }, // Self-iterating integration test - 'refactor': { level: 3, flow: 'refactor-cycle' }, // Tech debt discovery and refactoring - // Team workflows (multi-role collaboration) + 'integration-test': { level: 3, flow: 'integration-test-cycle' }, + 'refactor': { level: 3, flow: 'refactor-cycle' }, + // Team workflows (kept: team-planex only) 'team-planex': { level: 'Team', flow: 'team-planex' }, - 'team-iterdev': { level: 'Team', flow: 'team-iterdev' }, - 'team-lifecycle': { level: 'Team', flow: 'team-lifecycle' }, - 'team-issue': { level: 'Team', flow: 'team-issue' }, - 'team-testing': { level: 'Team', flow: 'team-testing' }, - 'team-qa': { level: 'Team', flow: 'team-qa' }, - 'team-brainstorm': { level: 'Team', flow: 'team-brainstorm' }, - 'team-uidesign': { level: 'Team', flow: 'team-uidesign' }, // Standard workflows - 'multi-cli-plan': { level: 3, flow: 'multi-cli-plan' }, // Multi-CLI collaborative planning + 'multi-cli': { level: 3, flow: 'multi-cli-plan' }, 'bugfix': { level: 2, flow: 'bugfix.standard' }, 'issue-batch': { level: 'Issue', flow: 'issue' }, - 'issue-transition': { level: 2.5, flow: 'rapid-to-issue' }, // Bridge workflow + 'issue-transition': { level: 2.5, flow: 'rapid-to-issue' }, 'exploration': { level: 4, flow: 'full' }, 'quick-task': { level: 2, flow: 'rapid' }, 'ui-design': { level: analysis.complexity === 'high' ? 4 : 3, flow: 'ui' }, 'tdd': { level: 3, flow: 'tdd' }, + 'test-gen': { level: 3, flow: 'test-gen' }, 'test-fix': { level: 3, flow: 'test-fix-gen' }, 'review': { level: 3, flow: 'review-cycle-fix' }, 'documentation': { level: 2, flow: 'docs' }, @@ -281,18 +258,15 @@ function buildCommandChain(workflow, analysis) { { cmd: 'workflow-lite-plan', args: `"${analysis.goal}"` } ], - // With-File workflows (documented exploration with multi-CLI collaboration) - 'brainstorm-with-file': [ - { cmd: 'workflow:brainstorm-with-file', args: `"${analysis.goal}"` } - // Note: Has built-in post-completion options (create plan, create issue, deep analysis) + // With-File → Auto Chain to lite-plan + 'analyze-to-plan': [ + { cmd: 'workflow:analyze-with-file', args: `"${analysis.goal}"` }, + { cmd: 'workflow-lite-plan', args: '' } // auto receives analysis artifacts (discussion.md) ], - // Brainstorm-to-Issue workflow (bridge from brainstorm to issue execution) - 'brainstorm-to-issue': [ - // Note: Assumes brainstorm session already exists, or run brainstorm first - { cmd: 'issue:from-brainstorm', args: `SESSION="${extractBrainstormSession(analysis)}" --auto` }, - { cmd: 'issue:queue', args: '' }, - { cmd: 'issue:execute', args: '--queue auto' } + 'brainstorm-to-plan': [ + { cmd: 'workflow:brainstorm-with-file', args: `"${analysis.goal}"` }, + { cmd: 'workflow-lite-plan', args: '' } // auto receives brainstorm artifacts (brainstorm.md) ], 'debug-with-file': [ @@ -300,32 +274,22 @@ function buildCommandChain(workflow, analysis) { // Note: Self-contained with hypothesis-driven iteration and Gemini validation ], - 'analyze-with-file': [ - { cmd: 'workflow:analyze-with-file', args: `"${analysis.goal}"` } - // Note: Self-contained with multi-round discussion and CLI exploration + // Brainstorm-to-Issue workflow (bridge from brainstorm to issue execution) + 'brainstorm-to-issue': [ + { cmd: 'issue:from-brainstorm', args: `SESSION="${extractBrainstormSession(analysis)}" --auto` }, + { cmd: 'issue:queue', args: '' }, + { cmd: 'issue:execute', args: '--queue auto' } ], + // Universal Plan+Execute 'collaborative-plan': [ { cmd: 'workflow:collaborative-plan-with-file', args: `"${analysis.goal}"` }, { cmd: 'workflow:unified-execute-with-file', args: '' } - // Note: Plan Note → unified execution engine ], - 'req-plan': [ - { cmd: 'workflow:req-plan-with-file', args: `"${analysis.goal}"` }, + 'roadmap': [ + { cmd: 'workflow:roadmap-with-file', args: `"${analysis.goal}"` }, { cmd: 'team-planex', args: '' } - // Note: Requirement decomposition → issue creation → team-planex wave execution - ], - - // Cycle workflows (self-iterating with reflection) - 'integration-test-cycle': [ - { cmd: 'workflow:integration-test-cycle', args: `"${analysis.goal}"` } - // Note: Self-contained explore → test → fix cycle with reflection - ], - - 'refactor-cycle': [ - { cmd: 'workflow:refactor-cycle', args: `"${analysis.goal}"` } - // Note: Self-contained tech debt discovery → refactor → validate ], // Level 3 - Standard @@ -338,11 +302,25 @@ function buildCommandChain(workflow, analysis) { ]) ], + // Level 4 - Spec-Driven Full Pipeline + 'spec-driven': [ + { cmd: 'spec-generator', args: `"${analysis.goal}"` }, + { cmd: 'workflow-plan', args: '' }, + { cmd: 'workflow-execute', args: '' }, + ...(analysis.constraints?.includes('skip-tests') ? [] : [ + { cmd: 'workflow-test-fix', args: '' } + ]) + ], + 'tdd': [ { cmd: 'workflow-tdd-plan', args: `"${analysis.goal}"` }, { cmd: 'workflow-execute', args: '' } ], + 'test-gen': [ + { cmd: 'workflow-test-fix', args: `"${analysis.goal}"` } + ], + 'test-fix-gen': [ { cmd: 'workflow-test-fix', args: `"${analysis.goal}"` } ], @@ -360,7 +338,7 @@ function buildCommandChain(workflow, analysis) { { cmd: 'workflow-execute', args: '' } ], - // Level 4 - Full + // Level 4 - Full Exploration 'full': [ { cmd: 'brainstorm', args: `"${analysis.goal}"` }, { cmd: 'workflow-plan', args: '' }, @@ -370,6 +348,15 @@ function buildCommandChain(workflow, analysis) { ]) ], + // Cycle workflows (self-iterating with reflection) + 'integration-test-cycle': [ + { cmd: 'workflow:integration-test-cycle', args: `"${analysis.goal}"` } + ], + + 'refactor-cycle': [ + { cmd: 'workflow:refactor-cycle', args: `"${analysis.goal}"` } + ], + // Issue Workflow 'issue': [ { cmd: 'issue:discover', args: '' }, @@ -378,37 +365,9 @@ function buildCommandChain(workflow, analysis) { { cmd: 'issue:execute', args: '' } ], - // Team Workflows (multi-role collaboration, self-contained) + // Team Workflows (kept: team-planex only) 'team-planex': [ { cmd: 'team-planex', args: `"${analysis.goal}"` } - ], - - 'team-iterdev': [ - { cmd: 'team-iterdev', args: `"${analysis.goal}"` } - ], - - 'team-lifecycle': [ - { cmd: 'team-lifecycle', args: `"${analysis.goal}"` } - ], - - 'team-issue': [ - { cmd: 'team-issue', args: `"${analysis.goal}"` } - ], - - 'team-testing': [ - { cmd: 'team-testing', args: `"${analysis.goal}"` } - ], - - 'team-qa': [ - { cmd: 'team-quality-assurance', args: `"${analysis.goal}"` } - ], - - 'team-brainstorm': [ - { cmd: 'team-brainstorm', args: `"${analysis.goal}"` } - ], - - 'team-uidesign': [ - { cmd: 'team-uidesign', args: `"${analysis.goal}"` } ] }; @@ -607,7 +566,7 @@ Phase 1: Analyze Intent +-- If clarity < 2 -> Phase 1.5: Clarify Requirements | Phase 2: Select Workflow & Build Chain - |-- Map task_type -> Level (1/2/3/4/Issue) + |-- Map task_type -> Level (2/3/4/Issue/Team) |-- Select flow based on complexity +-- Build command chain (Skill-based) | @@ -639,12 +598,13 @@ Phase 5: Execute Command Chain | "Add API endpoint" | feature (low) | 2 | workflow-lite-plan → workflow-test-fix | | "Fix login timeout" | bugfix | 2 | workflow-lite-plan → workflow-test-fix | | "Use issue workflow" | issue-transition | 2.5 | workflow-lite-plan(plan-only) → convert-to-plan → queue → execute | -| "头脑风暴: 通知系统重构" | brainstorm | 4 | workflow:brainstorm-with-file | -| "从头脑风暴创建 issue" | brainstorm-to-issue | 4 | issue:from-brainstorm → issue:queue → issue:execute | +| "协作分析: 认证架构" | analyze-file | 3 | analyze-with-file → workflow-lite-plan | | "深度调试 WebSocket" | debug-file | 3 | workflow:debug-with-file | -| "协作分析: 认证架构优化" | analyze-file | 3 | workflow:analyze-with-file | +| "头脑风暴: 通知系统" | brainstorm | 4 | brainstorm-with-file → workflow-lite-plan | +| "从头脑风暴创建 issue" | brainstorm-to-issue | 4 | issue:from-brainstorm → issue:queue → issue:execute | | "协作规划: 实时通知系统" | collaborative-plan | 3 | collaborative-plan-with-file → unified-execute-with-file | -| "需求规划: OAuth + 2FA" | req-plan | 4 | req-plan-with-file → team-planex | +| "需求路线图: OAuth + 2FA" | roadmap | 4 | roadmap-with-file → team-planex | +| "specification: 用户系统" | spec-driven | 4 | spec-generator → workflow-plan → workflow-execute → workflow-test-fix | | "集成测试: 支付流程" | integration-test | 3 | workflow:integration-test-cycle | | "重构 auth 模块" | refactor | 3 | workflow:refactor-cycle | | "multi-cli plan: API设计" | multi-cli-plan | 3 | workflow-multi-cli-plan → workflow-test-fix | @@ -652,13 +612,6 @@ Phase 5: Execute Command Chain | "Implement with TDD" | tdd | 3 | workflow-tdd-plan → workflow-execute | | "Uncertain: real-time" | exploration | 4 | brainstorm → workflow-plan → workflow-execute → workflow-test-fix | | "team planex: 用户系统" | team-planex | Team | team-planex | -| "迭代开发团队: 支付模块" | team-iterdev | Team | team-iterdev | -| "全生命周期: 通知服务" | team-lifecycle | Team | team-lifecycle | -| "team resolve issue #42" | team-issue | Team | team-issue | -| "测试团队: 全面测试认证" | team-testing | Team | team-testing | -| "QA 团队: 质量保障支付" | team-qa | Team | team-quality-assurance | -| "团队头脑风暴: API 设计" | team-brainstorm | Team | team-brainstorm | -| "团队 UI 设计: 仪表盘" | team-uidesign | Team | team-uidesign | --- @@ -668,10 +621,11 @@ Phase 5: Execute Command Chain 2. **Intent-Driven** - Auto-select workflow based on task intent 3. **Skill-Based Chaining** - Build command chain by composing independent Skills 4. **Self-Contained Skills** - 每个 Skill 内部处理完整流水线,是天然的最小执行单元 -5. **Progressive Clarification** - Low clarity triggers clarification phase -6. **TODO Tracking** - Use CCW prefix to isolate workflow todos -7. **Error Handling** - Retry/skip/abort at Skill level -8. **User Control** - Optional user confirmation at each phase +5. **Auto Chain** - With-File 产物自动传递给下游 Skill(如 analyze → lite-plan) +6. **Progressive Clarification** - Low clarity triggers clarification phase +7. **TODO Tracking** - Use CCW prefix to isolate workflow todos +8. **Error Handling** - Retry/skip/abort at Skill level +9. **User Control** - Optional user confirmation at each phase --- @@ -715,114 +669,51 @@ todos = [ "complexity": "medium" }, "command_chain": [ - { - "index": 0, - "command": "workflow-lite-plan", - "status": "completed" - }, - { - "index": 1, - "command": "workflow-test-fix", - "status": "running" - } + { "index": 0, "command": "workflow-lite-plan", "status": "completed" }, + { "index": 1, "command": "workflow-test-fix", "status": "running" } ], "current_index": 1 } ``` -**Status Values**: -- `running`: Workflow executing commands -- `completed`: All commands finished -- `failed`: User aborted or unrecoverable error -- `error`: Command execution failed (during error handling) - -**Command Status Values**: -- `pending`: Not started -- `running`: Currently executing -- `completed`: Successfully finished -- `failed`: Execution failed +**Status Values**: `running` | `completed` | `failed` | `error` +**Command Status Values**: `pending` | `running` | `completed` | `failed` --- ## With-File Workflows -**With-File workflows** provide documented exploration with multi-CLI collaboration. They are self-contained and generate comprehensive session artifacts. +**With-File workflows** provide documented exploration with multi-CLI collaboration. They generate comprehensive session artifacts and can auto-chain to lite-plan for implementation. -| Workflow | Purpose | Key Features | Output Folder | -|----------|---------|--------------|---------------| -| **brainstorm-with-file** | Multi-perspective ideation | Gemini/Codex/Claude perspectives, diverge-converge cycles | `.workflow/.brainstorm/` | -| **debug-with-file** | Hypothesis-driven debugging | Gemini validation, understanding evolution, NDJSON logging | `.workflow/.debug/` | -| **analyze-with-file** | Collaborative analysis | Multi-round Q&A, CLI exploration, documented discussions | `.workflow/.analysis/` | -| **collaborative-plan-with-file** | Multi-agent collaborative planning | Understanding agent + parallel agents, Plan Note shared doc | `.workflow/.planning/` | -| **req-plan-with-file** | Requirement roadmap planning | Requirement decomposition, issue creation, execution-plan.json | `.workflow/.planning/` | +| Workflow | Purpose | Auto Chain | Output Folder | +|----------|---------|------------|---------------| +| **brainstorm-with-file** | Multi-perspective ideation | → workflow-lite-plan (auto) | `.workflow/.brainstorm/` | +| **debug-with-file** | Hypothesis-driven debugging | Standalone (self-contained) | `.workflow/.debug/` | +| **analyze-with-file** | Collaborative analysis | → workflow-lite-plan (auto) | `.workflow/.analysis/` | +| **collaborative-plan-with-file** | Multi-agent collaborative planning | → unified-execute-with-file | `.workflow/.planning/` | +| **roadmap-with-file** | Strategic requirement roadmap | → team-planex | `.workflow/.planning/` | + +**Auto Chain Mechanism**: When `analyze-with-file` or `brainstorm-with-file` completes, its artifacts (discussion.md / brainstorm.md) are automatically passed to `workflow-lite-plan` as context input. No user intervention needed. **Detection Keywords**: - **brainstorm**: 头脑风暴, 创意, 发散思维, multi-perspective, compare perspectives - **debug-file**: 深度调试, 假设验证, systematic debug, hypothesis debug - **analyze-file**: 协作分析, 深度理解, collaborative analysis, explore concept - **collaborative-plan**: 协作规划, 多人规划, collaborative plan, multi-agent plan, Plan Note -- **req-plan**: roadmap, 需求规划, 需求拆解, requirement plan, progressive plan - -**Characteristics**: -1. **Self-Contained**: Each workflow handles its own iteration loop -2. **Documented Process**: Creates evolving documents (brainstorm.md, understanding.md, discussion.md) -3. **Multi-CLI**: Uses Gemini/Codex/Claude for different perspectives -4. **Built-in Post-Completion**: Offers follow-up options (create plan, issue, etc.) - ---- - -## Team Workflows - -**Team workflows** provide multi-role collaboration for complex tasks. Each team skill is self-contained with internal role routing via `--role=xxx`. - -| Workflow | Roles | Pipeline | Use Case | -|----------|-------|----------|----------| -| **team-planex** | planner + executor | wave pipeline(边规划边执行)| 需要并行规划和执行的任务 | -| **team-iterdev** | planner → developer → reviewer | 迭代开发循环 | 需要多轮迭代的开发任务 | -| **team-lifecycle** | spec → impl → test | 全生命周期 | 从需求到测试的完整流程 | -| **team-issue** | discover → plan → execute | issue 解决 | 多角色协作解决 issue | -| **team-testing** | strategy → generate → execute → analyze | 测试流水线 | 全面测试覆盖 | -| **team-quality-assurance** | scout → strategist → generator → executor → analyst | QA 闭环 | 质量保障全流程 | -| **team-brainstorm** | facilitator → participants → synthesizer | 团队头脑风暴 | 多角色协作头脑风暴 | -| **team-uidesign** | designer → implementer | dual-track 设计+实现 | UI 设计与实现并行 | - -**Detection Keywords**: -- **team-planex**: team planex, 团队规划执行, wave pipeline -- **team-iterdev**: team iterdev, 迭代开发团队, iterative dev team -- **team-lifecycle**: team lifecycle, 全生命周期, full lifecycle -- **team-issue**: team issue, 团队 issue, team resolve issue -- **team-testing**: team test, 测试团队, comprehensive test team -- **team-qa**: team qa, QA 团队, 质量保障团队 -- **team-brainstorm**: team brainstorm, 团队头脑风暴, team ideation -- **team-uidesign**: team ui design, UI 设计团队, dual track design - -**Characteristics**: -1. **Self-Contained**: Each team skill handles internal role coordination -2. **Role-Based Routing**: All roles invoke the same skill with `--role=xxx` -3. **Shared Memory**: Roles communicate via shared-memory.json and message bus -4. **Auto Mode Support**: All team skills support `-y`/`--yes` for skip confirmations +- **roadmap**: roadmap, 需求规划, 需求拆解, requirement plan, progressive plan +- **spec-driven**: specification, PRD, 产品需求, 产品文档 --- ## Cycle Workflows -**Cycle workflows** provide self-iterating development cycles with reflection-driven strategy adjustment. Each cycle is autonomous with built-in test-fix loops and quality gates. +**Cycle workflows** provide self-iterating development cycles with reflection-driven strategy adjustment. | Workflow | Pipeline | Key Features | Output Folder | |----------|----------|--------------|---------------| | **integration-test-cycle** | explore → test dev → test-fix → reflection | Self-iterating with max-iterations, auto continue | `.workflow/.test-cycle/` | | **refactor-cycle** | discover → prioritize → execute → validate | Multi-dimensional analysis, regression validation | `.workflow/.refactor-cycle/` | -**Detection Keywords**: -- **integration-test**: integration test, 集成测试, 端到端测试, e2e test -- **refactor**: refactor, 重构, tech debt, 技术债务 - -**Characteristics**: -1. **Self-Iterating**: Autonomous test-fix loops until quality gate passes -2. **Reflection-Driven**: Strategy adjusts based on previous iteration results -3. **Continue Support**: `--continue` flag to resume interrupted sessions -4. **Auto Mode Support**: `-y`/`--yes` for fully autonomous execution - --- ## Utility Commands @@ -831,10 +722,11 @@ todos = [ | Command | Purpose | |---------|---------| -| `workflow:unified-execute-with-file` | Universal execution engine - consumes plan output from collaborative-plan, req-plan, brainstorm | +| `workflow:unified-execute-with-file` | Universal execution engine - consumes plan output from collaborative-plan, roadmap, brainstorm | | `workflow:clean` | Intelligent code cleanup - mainline detection, stale artifact removal | | `workflow:init` | Initialize `.workflow/project-tech.json` with project analysis | | `workflow:init-guidelines` | Interactive wizard to fill `specs/*.md` | +| `workflow:status` | Generate on-demand views for project overview and workflow tasks | --- @@ -848,9 +740,6 @@ todos = [ /ccw -y "Add user authentication" /ccw --yes "Fix memory leak in WebSocket handler" -# Complex requirement (triggers clarification) -/ccw "Optimize system performance" - # Bug fix /ccw "Fix memory leak in WebSocket handler" @@ -863,35 +752,31 @@ todos = [ # Multi-CLI collaborative planning /ccw "multi-cli plan: 支付网关API设计" # → workflow-multi-cli-plan → workflow-test-fix -# With-File workflows (documented exploration with multi-CLI collaboration) -/ccw "头脑风暴: 用户通知系统重新设计" # → brainstorm-with-file +# With-File workflows → auto chain to lite-plan +/ccw "协作分析: 理解现有认证架构的设计决策" # → analyze-with-file → workflow-lite-plan +/ccw "头脑风暴: 用户通知系统重新设计" # → brainstorm-with-file → workflow-lite-plan +/ccw "深度调试: 系统随机崩溃问题" # → debug-with-file (standalone) /ccw "从头脑风暴 BS-通知系统-2025-01-28 创建 issue" # → brainstorm-to-issue (bridge) -/ccw "深度调试: 系统随机崩溃问题" # → debug-with-file -/ccw "协作分析: 理解现有认证架构的设计决策" # → analyze-with-file -# Team workflows (multi-role collaboration) -/ccw "team planex: 用户认证系统" # → team-planex (planner + executor wave pipeline) -/ccw "迭代开发团队: 支付模块重构" # → team-iterdev (planner → developer → reviewer) -/ccw "全生命周期: 通知服务开发" # → team-lifecycle (spec → impl → test) -/ccw "team resolve issue #42" # → team-issue (discover → plan → execute) -/ccw "测试团队: 全面测试认证模块" # → team-testing (strategy → generate → execute → analyze) -/ccw "QA 团队: 质量保障支付流程" # → team-quality-assurance (scout → strategist → generator → executor → analyst) -/ccw "团队头脑风暴: API 网关设计" # → team-brainstorm (facilitator → participants → synthesizer) -/ccw "团队 UI 设计: 管理后台仪表盘" # → team-uidesign (designer → implementer dual-track) +# Spec-driven full pipeline +/ccw "specification: 用户认证系统产品文档" # → spec-generator → workflow-plan → workflow-execute → workflow-test-fix # Collaborative planning & requirement workflows /ccw "协作规划: 实时通知系统架构" # → collaborative-plan-with-file → unified-execute -/ccw "需求规划: 用户认证 OAuth + 2FA" # → req-plan-with-file → team-planex -/ccw "roadmap: 数据导出功能路线图" # → req-plan-with-file → team-planex +/ccw "需求路线图: 用户认证 OAuth + 2FA" # → roadmap-with-file → team-planex +/ccw "roadmap: 数据导出功能路线图" # → roadmap-with-file → team-planex + +# Team workflows (kept: team-planex) +/ccw "team planex: 用户认证系统" # → team-planex (planner + executor wave pipeline) # Cycle workflows (self-iterating) /ccw "集成测试: 支付流程端到端" # → integration-test-cycle /ccw "重构 auth 模块的技术债务" # → refactor-cycle -/ccw "tech debt: 清理支付服务" # → refactor-cycle # Utility commands (invoked directly, not auto-routed) # /workflow:unified-execute-with-file # 通用执行引擎(消费 plan 输出) # /workflow:clean # 智能代码清理 # /workflow:init # 初始化项目状态 # /workflow:init-guidelines # 交互式填充项目规范 +# /workflow:status # 项目概览和工作流状态 ``` diff --git a/.claude/commands/issue/discover.md b/.claude/commands/issue/discover.md index f0cfab7d..2fdd968c 100644 --- a/.claude/commands/issue/discover.md +++ b/.claude/commands/issue/discover.md @@ -252,6 +252,17 @@ await updateDiscoveryState(outputDir, { const hasHighPriority = issues.some(i => i.priority === 'critical' || i.priority === 'high'); const hasMediumFindings = prioritizedFindings.some(f => f.priority === 'medium'); +// Auto mode: auto-select recommended action +if (autoYes) { + if (hasHighPriority) { + await appendJsonl('.workflow/issues/issues.jsonl', issues); + console.log(`Exported ${issues.length} issues. Run /issue:plan to continue.`); + } else { + console.log('Discovery complete. No significant issues found.'); + } + return; +} + await AskUserQuestion({ questions: [{ question: `Discovery complete: ${issues.length} issues generated, ${prioritizedFindings.length} total findings. What would you like to do next?`, diff --git a/.claude/commands/issue/execute.md b/.claude/commands/issue/execute.md index 87e2783c..8c62d452 100644 --- a/.claude/commands/issue/execute.md +++ b/.claude/commands/issue/execute.md @@ -152,6 +152,12 @@ if (!QUEUE_ID) { return; } + // Auto mode: auto-select if exactly one active queue + if (autoYes && activeQueues.length === 1) { + QUEUE_ID = activeQueues[0].id; + console.log(`Auto-selected queue: ${QUEUE_ID}`); + } else { + // Display and prompt user console.log('\nAvailable Queues:'); console.log('ID'.padEnd(22) + 'Status'.padEnd(12) + 'Progress'.padEnd(12) + 'Issues'); @@ -176,6 +182,7 @@ if (!QUEUE_ID) { }); QUEUE_ID = answer['Queue']; + } // end else (multi-queue prompt) } console.log(`\n## Executing Queue: ${QUEUE_ID}\n`); @@ -203,6 +210,13 @@ console.log(` - Parallel in batch 1: ${dag.parallel_batches[0]?.length || 0} `); +// Auto mode: use recommended defaults (Codex + Execute + Worktree) +if (autoYes) { + var executor = 'codex'; + var isDryRun = false; + var useWorktree = true; +} else { + // Interactive selection via AskUserQuestion const answer = AskUserQuestion({ questions: [ @@ -237,9 +251,10 @@ const answer = AskUserQuestion({ ] }); -const executor = answer['Executor'].toLowerCase().split(' ')[0]; // codex|gemini|agent -const isDryRun = answer['Mode'].includes('Dry-run'); -const useWorktree = answer['Worktree'].includes('Yes'); +var executor = answer['Executor'].toLowerCase().split(' ')[0]; // codex|gemini|agent +var isDryRun = answer['Mode'].includes('Dry-run'); +var useWorktree = answer['Worktree'].includes('Yes'); +} // end else (interactive selection) // Dry run mode if (isDryRun) { @@ -451,27 +466,33 @@ if (refreshedDag.ready_count > 0) { if (useWorktree && refreshedDag.ready_count === 0 && refreshedDag.completed_count === refreshedDag.total) { console.log('\n## All Solutions Completed - Worktree Cleanup'); - const answer = AskUserQuestion({ - questions: [{ - question: `Queue complete. What to do with worktree branch "${worktreeBranch}"?`, - header: 'Merge', - multiSelect: false, - options: [ - { label: 'Create PR (Recommended)', description: 'Push branch and create pull request' }, - { label: 'Merge to main', description: 'Merge all commits and cleanup worktree' }, - { label: 'Keep branch', description: 'Cleanup worktree, keep branch for manual handling' } - ] - }] - }); + // Auto mode: Create PR (recommended) + if (autoYes) { + var mergeAction = 'Create PR'; + } else { + const answer = AskUserQuestion({ + questions: [{ + question: `Queue complete. What to do with worktree branch "${worktreeBranch}"?`, + header: 'Merge', + multiSelect: false, + options: [ + { label: 'Create PR (Recommended)', description: 'Push branch and create pull request' }, + { label: 'Merge to main', description: 'Merge all commits and cleanup worktree' }, + { label: 'Keep branch', description: 'Cleanup worktree, keep branch for manual handling' } + ] + }] + }); + var mergeAction = answer['Merge']; + } const repoRoot = Bash('git rev-parse --show-toplevel').trim(); - if (answer['Merge'].includes('Create PR')) { + if (mergeAction.includes('Create PR')) { Bash(`git -C "${worktreePath}" push -u origin "${worktreeBranch}"`); Bash(`gh pr create --title "Queue ${dag.queue_id}" --body "Issue queue execution - all solutions completed" --head "${worktreeBranch}"`); Bash(`git worktree remove "${worktreePath}"`); console.log(`PR created for branch: ${worktreeBranch}`); - } else if (answer['Merge'].includes('Merge to main')) { + } else if (mergeAction.includes('Merge to main')) { // Check main is clean const mainDirty = Bash('git status --porcelain').trim(); if (mainDirty) { diff --git a/.claude/commands/issue/from-brainstorm.md b/.claude/commands/issue/from-brainstorm.md index 2df7c06c..827f23fd 100644 --- a/.claude/commands/issue/from-brainstorm.md +++ b/.claude/commands/issue/from-brainstorm.md @@ -154,8 +154,8 @@ Phase 6: Bind Solution ├─ Update issue status to 'planned' └─ Returns: SOL-{issue-id}-{uid} -Phase 7: Next Steps - └─ Offer: Form queue | Convert another idea | View details | Done +Phase 7: Next Steps (skip in auto mode) + └─ Auto mode: complete directly | Interactive: Form queue | Convert another | Done ``` ## Context Enrichment Logic diff --git a/.claude/commands/issue/plan.md b/.claude/commands/issue/plan.md index fb57027a..cfc5136f 100644 --- a/.claude/commands/issue/plan.md +++ b/.claude/commands/issue/plan.md @@ -263,6 +263,14 @@ for (let i = 0; i < agentTasks.length; i += MAX_PARALLEL) { for (const pending of pendingSelections) { if (pending.solutions.length === 0) continue; + // Auto mode: auto-bind first (highest-ranked) solution + if (autoYes) { + const solId = pending.solutions[0].id; + Bash(`ccw issue bind ${pending.issue_id} ${solId}`); + console.log(`✓ ${pending.issue_id}: ${solId} bound (auto)`); + continue; + } + const options = pending.solutions.slice(0, 4).map(sol => ({ label: `${sol.id} (${sol.task_count} tasks)`, description: sol.description || sol.approach || 'No description' diff --git a/.claude/commands/issue/queue.md b/.claude/commands/issue/queue.md index 6c2b5cba..caef9c8f 100644 --- a/.claude/commands/issue/queue.md +++ b/.claude/commands/issue/queue.md @@ -273,6 +273,17 @@ const allClarifications = results.flatMap((r, i) => ```javascript if (allClarifications.length > 0) { for (const clarification of allClarifications) { + // Auto mode: use recommended resolution (first option) + if (autoYes) { + const autoAnswer = clarification.options[0]?.label || 'skip'; + Task( + subagent_type="issue-queue-agent", + resume=clarification.agent_id, + prompt=`Conflict ${clarification.conflict_id} resolved: ${autoAnswer}` + ); + continue; + } + // Present to user via AskUserQuestion const answer = AskUserQuestion({ questions: [{ @@ -345,6 +356,14 @@ ccw issue queue list --brief **AskUserQuestion:** ```javascript +// Auto mode: merge into existing queue +if (autoYes) { + Bash(`ccw issue queue merge ${newQueueId} --queue ${activeQueueId}`); + Bash(`ccw issue queue delete ${newQueueId}`); + console.log(`Auto-merged new queue into ${activeQueueId}`); + return; +} + AskUserQuestion({ questions: [{ question: "Active queue exists. How would you like to proceed?", diff --git a/.claude/commands/workflow/debug-with-file.md b/.claude/commands/workflow/debug-with-file.md index a6677bd5..918a38ae 100644 --- a/.claude/commands/workflow/debug-with-file.md +++ b/.claude/commands/workflow/debug-with-file.md @@ -632,6 +632,14 @@ Why is config value None during update? **Auto-sync**: 执行 `/workflow:session:sync -y "{summary}"` 更新 specs/*.md + project-tech。 +```javascript +// Auto mode: skip expansion question, complete session directly +if (autoYes) { + console.log('Debug session complete. Auto mode: skipping expansion.'); + return; +} +``` + 完成后询问用户是否扩展为issue(test/enhance/refactor/doc),选中项调用 `/issue:new "{summary} - {dimension}"` --- diff --git a/.claude/skills/team-planex/SKILL.md b/.claude/skills/team-planex/SKILL.md index 15b44873..d5bc526a 100644 --- a/.claude/skills/team-planex/SKILL.md +++ b/.claude/skills/team-planex/SKILL.md @@ -228,19 +228,24 @@ Beat Cycle (Coordinator Spawn-and-Stop) When the pipeline completes (all tasks done, coordinator Phase 5): -``` -AskUserQuestion({ - questions: [{ - question: "Team pipeline complete. What would you like to do?", - header: "Completion", - multiSelect: false, - options: [ - { label: "Archive & Clean (Recommended)", description: "Archive session, clean up tasks and team resources" }, - { label: "Keep Active", description: "Keep session active for follow-up work or inspection" }, - { label: "Export Results", description: "Export deliverables to a specified location, then clean" } - ] - }] -}) +```javascript +if (autoYes) { + // Auto mode: Archive & Clean without prompting + completionAction = "Archive & Clean"; +} else { + AskUserQuestion({ + questions: [{ + question: "Team pipeline complete. What would you like to do?", + header: "Completion", + multiSelect: false, + options: [ + { label: "Archive & Clean (Recommended)", description: "Archive session, clean up tasks and team resources" }, + { label: "Keep Active", description: "Keep session active for follow-up work or inspection" }, + { label: "Export Results", description: "Export deliverables to a specified location, then clean" } + ] + }] + }) +} ``` | Choice | Action |