Files
Claude-Code-Workflow/ccw/docs-site/build/assets/js/d550a629.236e0027.js
catlog22 c6093ef741 feat: add CLI Command Node and Prompt Node components for orchestrator
- Implemented CliCommandNode component for executing CLI tools with AI models.
- Implemented PromptNode component for constructing AI prompts with context.
- Added styling for mode and tool badges in both components.
- Enhanced user experience with command and argument previews, execution status, and error handling.

test: add comprehensive tests for ask_question tool

- Created direct test for ask_question tool execution.
- Developed end-to-end tests to validate ask_question tool integration with WebSocket and A2UI surfaces.
- Implemented simple and integrated WebSocket tests to ensure proper message handling and surface reception.
- Added tool registration test to verify ask_question tool is correctly registered.

chore: add WebSocket listener and simulation tests

- Added WebSocket listener for A2UI surfaces to facilitate testing.
- Implemented frontend simulation test to validate complete flow from backend to frontend.
- Created various test scripts to ensure robust testing of ask_question tool functionality.
2026-02-03 23:10:36 +08:00

1 line
18 KiB
JavaScript

"use strict";(globalThis.webpackChunkccw_docs=globalThis.webpackChunkccw_docs||[]).push([[411],{1184(n,e,r){r.d(e,{R:()=>o,x:()=>c});var i=r(3696);const s={},t=i.createContext(s);function o(n){const e=i.useContext(t);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:o(n.components),i.createElement(t.Provider,{value:e},n.children)}},7661(n,e,r){r.r(e),r.d(e,{assets:()=>a,contentTitle:()=>c,default:()=>m,frontMatter:()=>o,metadata:()=>i,toc:()=>l});const i=JSON.parse('{"id":"commands/general/ccw-coordinator","title":"/ccw-coordinator","description":"Generic command orchestration tool for CCW workflows","source":"@site/docs/commands/general/ccw-coordinator.mdx","sourceDirName":"commands/general","slug":"/commands/general/ccw-coordinator","permalink":"/docs/docs/commands/general/ccw-coordinator","draft":false,"unlisted":false,"editUrl":"https://github.com/ccw/docs/tree/main/docs/commands/general/ccw-coordinator.mdx","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{"title":"/ccw-coordinator","sidebar_label":"/ccw-coordinator","sidebar_position":4,"description":"Generic command orchestration tool for CCW workflows"},"sidebar":"docs","previous":{"title":"/ccw-test","permalink":"/docs/docs/commands/general/ccw-test"},"next":{"title":"/ccw-debug","permalink":"/docs/docs/commands/general/ccw-debug"}}');var s=r(2540),t=r(1184);const o={title:"/ccw-coordinator",sidebar_label:"/ccw-coordinator",sidebar_position:4,description:"Generic command orchestration tool for CCW workflows"},c="/ccw-coordinator",a={},l=[{value:"Overview",id:"overview",level:2},{value:"Core Concept: Minimum Execution Units",id:"core-concept-minimum-execution-units",level:2},{value:"Examples of Execution Units",id:"examples-of-execution-units",level:3},{value:"Command Port Mapping",id:"command-port-mapping",level:2},{value:"Usage",id:"usage",level:2},{value:"Execution Flow",id:"execution-flow",level:2},{value:"Phase 1: Analyze Requirements",id:"phase-1-analyze-requirements",level:3},{value:"Phase 2: Recommend Command Chain",id:"phase-2-recommend-command-chain",level:3},{value:"Phase 3: User Confirmation",id:"phase-3-user-confirmation",level:3},{value:"Phase 4: Execute Sequential Command Chain",id:"phase-4-execute-sequential-command-chain",level:3},{value:"Command Chain Examples",id:"command-chain-examples",level:2},{value:"Quick Implementation Unit",id:"quick-implementation-unit",level:3},{value:"Verified Planning Unit",id:"verified-planning-unit",level:3},{value:"Parameter Patterns",id:"parameter-patterns",level:2},{value:"Examples",id:"examples",level:2},{value:"Simple Feature",id:"simple-feature",level:3},{value:"Complex Feature",id:"complex-feature",level:3},{value:"Related Commands",id:"related-commands",level:2},{value:"Notes",id:"notes",level:2}];function d(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"ccw-coordinator",children:"/ccw-coordinator"})}),"\n",(0,s.jsx)(e.p,{children:"Generic command orchestration tool - analyzes requirements, recommends command chains, and executes sequentially with state persistence."}),"\n",(0,s.jsx)(e.h2,{id:"overview",children:"Overview"}),"\n",(0,s.jsxs)(e.p,{children:["The ",(0,s.jsx)(e.code,{children:"/ccw-coordinator"})," command is a generic orchestrator that can handle any CCW workflow by analyzing task requirements and recommending optimal command chains."]}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"Parameters"}),":"]}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.code,{children:"[task description]"}),": Task to orchestrate (required)"]}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"Execution Model"}),": Pseudocode guidance - Claude intelligently executes each phase based on context."]}),"\n",(0,s.jsx)(e.h2,{id:"core-concept-minimum-execution-units",children:"Core Concept: Minimum Execution Units"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"Definition"}),": Commands that must execute together as an atomic group to achieve meaningful workflow milestones."]}),"\n",(0,s.jsx)(e.h3,{id:"examples-of-execution-units",children:"Examples of Execution Units"}),"\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{children:"Unit Name"}),(0,s.jsx)(e.th,{children:"Commands"}),(0,s.jsx)(e.th,{children:"Purpose"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:(0,s.jsx)(e.strong,{children:"Quick Implementation"})}),(0,s.jsxs)(e.td,{children:[(0,s.jsx)(e.code,{children:"/workflow:lite-plan"})," \u2192 ",(0,s.jsx)(e.code,{children:"/workflow:lite-execute"})]}),(0,s.jsx)(e.td,{children:"Lightweight plan and execution"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:(0,s.jsx)(e.strong,{children:"Multi-CLI Planning"})}),(0,s.jsxs)(e.td,{children:[(0,s.jsx)(e.code,{children:"/workflow:multi-cli-plan"})," \u2192 ",(0,s.jsx)(e.code,{children:"/workflow:lite-execute"})]}),(0,s.jsx)(e.td,{children:"Multi-perspective analysis"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:(0,s.jsx)(e.strong,{children:"Bug Fix"})}),(0,s.jsxs)(e.td,{children:[(0,s.jsx)(e.code,{children:"/workflow:lite-fix"})," \u2192 ",(0,s.jsx)(e.code,{children:"/workflow:lite-execute"})]}),(0,s.jsx)(e.td,{children:"Bug diagnosis and fix"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:(0,s.jsx)(e.strong,{children:"Verified Planning"})}),(0,s.jsxs)(e.td,{children:[(0,s.jsx)(e.code,{children:"/workflow:plan"})," \u2192 ",(0,s.jsx)(e.code,{children:"/workflow:plan-verify"})," \u2192 ",(0,s.jsx)(e.code,{children:"/workflow:execute"})]}),(0,s.jsx)(e.td,{children:"Planning with verification"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:(0,s.jsx)(e.strong,{children:"TDD Planning"})}),(0,s.jsxs)(e.td,{children:[(0,s.jsx)(e.code,{children:"/workflow:tdd-plan"})," \u2192 ",(0,s.jsx)(e.code,{children:"/workflow:execute"})]}),(0,s.jsx)(e.td,{children:"Test-driven development"})]})]})]}),"\n",(0,s.jsx)(e.h2,{id:"command-port-mapping",children:"Command Port Mapping"}),"\n",(0,s.jsx)(e.p,{children:"Each workflow command has defined input/output ports for intelligent routing:"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-javascript",children:"const commandPorts = {\r\n // Planning Commands\r\n 'lite-plan': {\r\n name: 'lite-plan',\r\n input: ['task-description'],\r\n output: ['memory-plan'],\r\n tags: ['planning', 'lite']\r\n },\r\n 'plan': {\r\n name: 'plan',\r\n input: ['task-description', 'brainstorm-artifacts'],\r\n output: ['impl-plan', 'tasks-json'],\r\n tags: ['planning', 'full']\r\n },\r\n 'multi-cli-plan': {\r\n name: 'multi-cli-plan',\r\n input: ['decision-topic'],\r\n output: ['comparison-report', 'recommendation'],\r\n tags: ['planning', 'multi-cli', 'analysis']\r\n },\r\n // ... more commands\r\n};\n"})}),"\n",(0,s.jsx)(e.h2,{id:"usage",children:"Usage"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:'# Let coordinator analyze and recommend\r\n/ccw-coordinator "Implement user authentication"\r\n\r\n# The coordinator will:\r\n# 1. Analyze task requirements\r\n# 2. Recommend optimal command chain\r\n# 3. Execute commands sequentially\r\n# 4. Track state throughout\n'})}),"\n",(0,s.jsx)(e.h2,{id:"execution-flow",children:"Execution Flow"}),"\n",(0,s.jsx)(e.h3,{id:"phase-1-analyze-requirements",children:"Phase 1: Analyze Requirements"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-javascript",children:"async function analyzeRequirements(taskDescription) {\r\n const analysis = {\r\n goal: extractGoal(taskDescription),\r\n scope: determineScope(taskDescription),\r\n complexity: calculateComplexity(taskDescription),\r\n task_type: classifyTask(taskDescription),\r\n constraints: identifyConstraints(taskDescription)\r\n };\r\n return analysis;\r\n}\n"})}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"Output"}),":"]}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"Goal: What needs to be accomplished"}),"\n",(0,s.jsx)(e.li,{children:"Scope: Affected modules/components"}),"\n",(0,s.jsx)(e.li,{children:"Complexity: simple/medium/complex"}),"\n",(0,s.jsx)(e.li,{children:"Task type: feature, bugfix, refactor, etc."}),"\n",(0,s.jsx)(e.li,{children:"Constraints: Time, resources, dependencies"}),"\n"]}),"\n",(0,s.jsx)(e.h3,{id:"phase-2-recommend-command-chain",children:"Phase 2: Recommend Command Chain"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-javascript",children:"async function recommendCommandChain(analysis) {\r\n const { inputPort, outputPort } = determinePortFlow(analysis.task_type, analysis.constraints);\r\n const chain = selectChainByPorts(inputPort, outputPort, analysis);\r\n return chain;\r\n}\n"})}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"Output"}),":"]}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"Selected workflow level"}),"\n",(0,s.jsx)(e.li,{children:"Command chain with units"}),"\n",(0,s.jsx)(e.li,{children:"Execution mode (mainprocess/async)"}),"\n",(0,s.jsx)(e.li,{children:"Expected artifacts"}),"\n"]}),"\n",(0,s.jsx)(e.h3,{id:"phase-3-user-confirmation",children:"Phase 3: User Confirmation"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-javascript",children:"async function getUserConfirmation(chain) {\r\n const response = await AskUserQuestion({\r\n questions: [{\r\n question: 'Proceed with this command chain?',\r\n header: 'Confirm',\r\n options: [\r\n { label: 'Confirm and execute', description: 'Proceed with commands' },\r\n { label: 'Show details', description: 'View each command' },\r\n { label: 'Adjust chain', description: 'Remove or reorder' },\r\n { label: 'Cancel', description: 'Abort' }\r\n ]\r\n }]\r\n });\r\n return response;\r\n}\n"})}),"\n",(0,s.jsx)(e.h3,{id:"phase-4-execute-sequential-command-chain",children:"Phase 4: Execute Sequential Command Chain"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-javascript",children:"async function executeCommandChain(chain, analysis) {\r\n const sessionId = `ccw-coord-${Date.now()}`;\r\n const state = {\r\n session_id: sessionId,\r\n status: 'running',\r\n analysis: analysis,\r\n command_chain: chain.map((cmd, idx) => ({ ...cmd, index: idx, status: 'pending' })),\r\n execution_results: []\r\n };\r\n\r\n // Save initial state\r\n Write(`.workflow/.ccw-coordinator/${sessionId}/state.json`, JSON.stringify(state, null, 2));\r\n\r\n for (let i = 0; i < chain.length; i++) {\r\n const cmd = chain[i];\r\n console.log(`[${i+1}/${chain.length}] Executing: ${cmd.command}`);\r\n\r\n // Update status to running\r\n state.command_chain[i].status = 'running';\r\n Write(`.workflow/.ccw-coordinator/${sessionId}/state.json`, JSON.stringify(state, null, 2));\r\n\r\n // Execute command via CLI\r\n const taskId = Bash(\r\n `ccw cli -p \"${escapePrompt(prompt)}\" --tool claude --mode write`,\r\n { run_in_background: true }\r\n ).task_id;\r\n\r\n // Save execution record\r\n state.execution_results.push({\r\n index: i,\r\n command: cmd.command,\r\n status: 'in-progress',\r\n task_id: taskId,\r\n timestamp: new Date().toISOString()\r\n });\r\n }\r\n\r\n return state;\r\n}\n"})}),"\n",(0,s.jsx)(e.h2,{id:"command-chain-examples",children:"Command Chain Examples"}),"\n",(0,s.jsx)(e.h3,{id:"quick-implementation-unit",children:"Quick Implementation Unit"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-javascript",children:"// Commands: 2 | Units: 1 (quick-impl)\r\nconst quickImplChain = [\r\n {\r\n command: '/workflow:lite-plan',\r\n args: '\"{{goal}}\"',\r\n unit: 'quick-impl',\r\n execution: { type: 'slash-command', mode: 'mainprocess' }\r\n },\r\n {\r\n command: '/workflow:lite-execute',\r\n args: '--in-memory',\r\n unit: 'quick-impl',\r\n execution: { type: 'slash-command', mode: 'async' }\r\n }\r\n];\n"})}),"\n",(0,s.jsx)(e.h3,{id:"verified-planning-unit",children:"Verified Planning Unit"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-javascript",children:"// Commands: 3 | Units: 1 (verified-planning-execution)\r\nconst verifiedChain = [\r\n {\r\n command: '/workflow:plan',\r\n args: '\"{{goal}}\"',\r\n unit: 'verified-planning-execution',\r\n execution: { type: 'slash-command', mode: 'mainprocess' }\r\n },\r\n {\r\n command: '/workflow:plan-verify',\r\n args: '',\r\n unit: 'verified-planning-execution',\r\n execution: { type: 'slash-command', mode: 'mainprocess' }\r\n },\r\n {\r\n command: '/workflow:execute',\r\n args: '--resume-session=\"{{session}}\"',\r\n unit: 'verified-planning-execution',\r\n execution: { type: 'slash-command', mode: 'mainprocess' }\r\n }\r\n];\n"})}),"\n",(0,s.jsx)(e.h2,{id:"parameter-patterns",children:"Parameter Patterns"}),"\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{children:"Command Type"}),(0,s.jsx)(e.th,{children:"Parameter Pattern"}),(0,s.jsx)(e.th,{children:"Example"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:(0,s.jsx)(e.strong,{children:"Planning"})}),(0,s.jsx)(e.td,{children:(0,s.jsx)(e.code,{children:'"task description"'})}),(0,s.jsx)(e.td,{children:(0,s.jsx)(e.code,{children:'/workflow:plan -y "Implement OAuth2"'})})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:(0,s.jsx)(e.strong,{children:"Execution (with plan)"})}),(0,s.jsx)(e.td,{children:(0,s.jsx)(e.code,{children:'--resume-session="WFS-xxx"'})}),(0,s.jsx)(e.td,{children:(0,s.jsx)(e.code,{children:'/workflow:execute -y --resume-session="WFS-plan-001"'})})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:(0,s.jsx)(e.strong,{children:"Execution (standalone)"})}),(0,s.jsxs)(e.td,{children:[(0,s.jsx)(e.code,{children:"--in-memory"})," or ",(0,s.jsx)(e.code,{children:'"task"'})]}),(0,s.jsx)(e.td,{children:(0,s.jsx)(e.code,{children:"/workflow:lite-execute -y --in-memory"})})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:(0,s.jsx)(e.strong,{children:"Session-based"})}),(0,s.jsx)(e.td,{children:(0,s.jsx)(e.code,{children:'--session="WFS-xxx"'})}),(0,s.jsx)(e.td,{children:(0,s.jsx)(e.code,{children:'/workflow:test-fix-gen -y --session="WFS-impl-001"'})})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:(0,s.jsx)(e.strong,{children:"Fix/Debug"})}),(0,s.jsx)(e.td,{children:(0,s.jsx)(e.code,{children:'"problem description"'})}),(0,s.jsx)(e.td,{children:(0,s.jsx)(e.code,{children:'/workflow:lite-fix -y "Fix timeout bug"'})})]})]})]}),"\n",(0,s.jsx)(e.h2,{id:"examples",children:"Examples"}),"\n",(0,s.jsx)(e.h3,{id:"simple-feature",children:"Simple Feature"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:'/ccw-coordinator "Add user profile page"\r\n\r\n# Output:\r\n# Analyzing: "Add user profile page"\r\n# Complexity: Low (score: 1)\r\n# Recommended: Level 2 - Rapid Workflow\r\n# Command chain:\r\n# Unit: quick-impl\r\n# 1. /workflow:lite-plan "Add user profile page"\r\n# 2. /workflow:lite-execute --in-memory\r\n# Confirm? (y/n): y\r\n#\r\n# [1/2] Executing: /workflow:lite-plan\r\n# [2/2] Executing: /workflow:lite-execute\r\n# \u2705 Complete! Session: ccw-coord-1738425600000\n'})}),"\n",(0,s.jsx)(e.h3,{id:"complex-feature",children:"Complex Feature"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:'/ccw-coordinator "Refactor authentication system with OAuth2"\r\n\r\n# Output:\r\n# Analyzing: "Refactor authentication system..."\r\n# Complexity: High (score: 6)\r\n# Recommended: Level 3 - Standard Workflow\r\n# Command chain:\r\n# Unit: verified-planning-execution\r\n# 1. /workflow:plan "Refactor authentication..."\r\n# 2. /workflow:plan-verify\r\n# 3. /workflow:execute --resume-session="{session}"\r\n# Confirm? (y/n): y\n'})}),"\n",(0,s.jsx)(e.h2,{id:"related-commands",children:"Related Commands"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.strong,{children:"/ccw"})," - Main workflow coordinator"]}),"\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.strong,{children:"/ccw-plan"})," - Planning coordinator"]}),"\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.strong,{children:"/ccw-test"})," - Test coordinator"]}),"\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.strong,{children:"/ccw-debug"})," - Debug coordinator"]}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"notes",children:"Notes"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.strong,{children:"Atomic execution"})," - Never split minimum execution units"]}),"\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.strong,{children:"State persistence"})," - All state saved to ",(0,s.jsx)(e.code,{children:".workflow/.ccw-coordinator/"})]}),"\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.strong,{children:"User control"})," - Confirmation before execution"]}),"\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.strong,{children:"Context passing"})," - Parameters chain across commands"]}),"\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.strong,{children:"Resume support"})," - Can resume from state.json"]}),"\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.strong,{children:"Intelligent routing"})," - Port-based command matching"]}),"\n"]})]})}function m(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(d,{...n})}):d(n)}}}]);