UNPKG

@sethdouglasford/claude-flow

Version:

Claude Code Flow - Advanced AI-powered development workflows with SPARC methodology

264 lines • 11.5 kB
/** * Orchestration Command - AI tool workflow coordination */ import { Command } from "../cliffy-compat.js"; import chalk from "chalk"; // Orchestration Catalog const ORCHESTRATION_FRAMEWORKS = { "mcp-orchestrate": { name: "MCP Orchestration DSL", description: "Simple but powerful DSL for orchestrating AI tool workflows", usage: "/mcp-orchestrate \"[dsl_script]\" [--parallel] [--debug] [--save-results]", features: [ "Simple DSL syntax for workflow definitions", "Parallel execution for efficiency", "Variable management and result reuse", "Conditional logic and loop operations", "Error handling with retry capabilities", "Result aggregation from multiple tools" ], syntax: [ "Sequential: -> tool_name(param=\"value\")", "Parallel: => tool1(param=\"value1\")", "Variables: $result = tool_name(param=\"value\")", "Conditionals: ? $result.status == \"success\" -> action", "Loops: @ item in $results.items -> process_tool(item=$item)" ] }, "swarm-intelligence": { name: "Swarm Intelligence Orchestrator", description: "Deploy specialized AI agents across multiple contexts", usage: "/swarm-intelligence \"[mission_description]\" [agent_count] [coordination_mode] [spawn_specialists]", features: [ "5 specialized agents with distinct capabilities", "3 coordination modes (autonomous, hierarchical, peer-to-peer)", "Dynamic agent spawning for domain expertise", "Memory synchronization and conflict resolution", "Cross-agent learning and collective intelligence", "Emergent coordination patterns" ], agents: [ "🧠 Research Agent - Deep analysis and knowledge synthesis", "šŸ”§ Implementation Agent - Multiple solution strategies", "šŸ” Analysis Agent - System understanding and risk assessment", "šŸš€ Innovation Agent - Cutting-edge solutions and future-proofing", "šŸ”— Integration Agent - System coordination and boundaries" ], modes: [ "Autonomous Swarm - Creative exploration and emergent solutions", "Hierarchical Command - Complex projects with clear structure", "Peer-to-Peer Network - Balanced collaboration with distributed expertise" ] } }; async function orchestrationAction(ctx) { const subcommand = ctx.args[0]; switch (subcommand) { case "list": await listOrchestrationFrameworks(ctx); break; case "info": await showOrchestrationInfo(ctx); break; case "run": await runOrchestration(ctx); break; case "dsl": await showDSLReference(ctx); break; default: await showOrchestrationHelp(); break; } } async function listOrchestrationFrameworks(ctx) { const verbose = ctx.flags.verbose; console.log(chalk.cyan.bold("\nšŸŽ¼ Orchestration Frameworks\n")); console.log(chalk.gray("AI tool workflow coordination with advanced execution patterns\n")); for (const [key, framework] of Object.entries(ORCHESTRATION_FRAMEWORKS)) { console.log(`${chalk.cyan("•")} ${chalk.bold(framework.name)} ${chalk.gray(`(${key})`)}`); console.log(` ${framework.description}`); if (verbose) { console.log(chalk.blue(" Features:")); framework.features.forEach(feature => { console.log(` - ${feature}`); }); if ('agents' in framework) { console.log(chalk.green(" Specialized Agents:")); framework.agents.forEach((agent) => { console.log(` - ${agent}`); }); } if ('modes' in framework) { console.log(chalk.yellow(" Coordination Modes:")); framework.modes.forEach((mode) => { console.log(` - ${mode}`); }); } if ('syntax' in framework) { console.log(chalk.magenta(" DSL Syntax:")); framework.syntax.forEach((syntax) => { console.log(` - ${syntax}`); }); } console.log(chalk.gray(` Usage: ${framework.usage}`)); } console.log(); } if (!verbose) { console.log(chalk.gray("Use --verbose for detailed information")); } } async function showOrchestrationInfo(ctx) { const frameworkName = ctx.args[1]; if (!frameworkName) { console.error(chalk.red("Error: Framework name required")); console.log("Usage: claude-flow orchestration info <framework-name>"); return; } const framework = ORCHESTRATION_FRAMEWORKS[frameworkName]; if (!framework) { console.error(chalk.red(`Error: Framework '${frameworkName}' not found`)); console.log("\nAvailable frameworks:"); Object.keys(ORCHESTRATION_FRAMEWORKS).forEach(key => { console.log(` - ${key}`); }); return; } console.log(chalk.cyan.bold(`\n${framework.name}\n`)); console.log(framework.description); console.log(); console.log(chalk.blue("Usage:")); console.log(` ${framework.usage}`); console.log(); console.log(chalk.green("Key Features:")); framework.features.forEach(feature => { console.log(` • ${feature}`); }); console.log(); if ('agents' in framework) { console.log(chalk.yellow("Specialized Agents:")); framework.agents.forEach((agent) => { console.log(` • ${agent}`); }); console.log(); } if ('modes' in framework) { console.log(chalk.magenta("Coordination Modes:")); framework.modes.forEach((mode) => { console.log(` • ${mode}`); }); console.log(); } if ('syntax' in framework) { console.log(chalk.cyan("DSL Syntax Examples:")); framework.syntax.forEach((syntax) => { console.log(` • ${syntax}`); }); console.log(); } } async function runOrchestration(ctx) { const frameworkName = ctx.args[1]; const objective = ctx.args.slice(2).join(" "); if (!frameworkName) { console.error(chalk.red("Error: Framework name required")); console.log("Usage: claude-flow orchestration run <framework-name> <objective>"); return; } const framework = ORCHESTRATION_FRAMEWORKS[frameworkName]; if (!framework) { console.error(chalk.red(`Error: Framework '${frameworkName}' not found`)); return; } if (!objective) { console.error(chalk.red("Error: Objective required")); console.log(`Usage: ${framework.usage}`); return; } console.log(chalk.cyan(`\nšŸŽ¼ Executing ${framework.name}`)); console.log(chalk.gray(`Objective: ${objective}`)); console.log(); // This would integrate with the actual orchestration system console.log(chalk.yellow("āš ļø Orchestration execution not yet implemented")); console.log(chalk.gray("This will integrate with MCP and swarm coordination systems")); console.log(); // Show what would be executed console.log(chalk.blue("Planned Execution:")); console.log(` Framework: ${framework.name}`); console.log(` Objective: ${objective}`); console.log(` Features: ${framework.features.join(", ")}`); if ('agents' in framework) { console.log(` Agents: ${framework.agents.length} specialized agents`); } } async function showDSLReference(ctx) { console.log(chalk.cyan.bold("\nšŸ”§ MCP Orchestration DSL Reference\n")); console.log(chalk.blue("Basic Syntax:")); console.log(" -> tool_name(param=\"value\") # Sequential execution"); console.log(" => tool1(param=\"value1\") # Parallel execution"); console.log(" $result = tool_name(param=\"value\") # Variable assignment"); console.log(" -> other_tool(input=$result.data) # Variable usage"); console.log(); console.log(chalk.green("Control Flow:")); console.log(" ? $result.status == \"success\" -> action # Conditional execution"); console.log(" @ item in $results.items -> process # Loop operations"); console.log(" $content[] = tool_call() # Array building"); console.log(); console.log(chalk.yellow("Advanced Features:")); console.log(" # Comments and documentation"); console.log(" -> tool_name(param=\"value\") [retry=3] # Error handling"); console.log(" $top_results = $web_data.results[0:5] # Array slicing"); console.log(" $titles = $web_data.results[*].title # Property extraction"); console.log(); console.log(chalk.magenta("Example Workflow:")); console.log(` # Multi-source research pattern => $web = web_search(query=$topic) => $academic = search_papers(topic=$topic) => $code = github_search(query=$topic) -> synthesize_findings(web=$web, academic=$academic, code=$code)`); console.log(); } async function showOrchestrationHelp() { console.log(chalk.cyan.bold("Orchestration")); console.log(); console.log("AI tool workflow coordination with advanced execution patterns,"); console.log("parallel processing, and intelligent agent coordination."); console.log(); console.log(chalk.blue("Commands:")); console.log(" list List all available orchestration frameworks"); console.log(" info <framework> Show detailed framework information"); console.log(" run <framework> <obj> Execute orchestration with given objective"); console.log(" dsl Show MCP Orchestration DSL reference"); console.log(); console.log(chalk.blue("Available Frameworks:")); Object.entries(ORCHESTRATION_FRAMEWORKS).forEach(([key, framework]) => { console.log(` ${chalk.cyan(key.padEnd(20))} ${framework.description}`); }); console.log(); console.log(chalk.blue("Options:")); console.log(" --verbose Show detailed information"); console.log(" --parallel Enable parallel execution"); console.log(" --debug Show detailed execution information"); console.log(); console.log(chalk.blue("Examples:")); console.log(" claude-flow orchestration list --verbose"); console.log(" claude-flow orchestration info mcp-orchestrate"); console.log(" claude-flow orchestration dsl"); console.log(' claude-flow orchestration run swarm-intelligence "Design distributed system"'); } export const orchestrationCommand = new Command() .name("orchestration") .description("AI tool workflow coordination with advanced execution patterns") .arguments("[subcommand] [args...]") .option("--verbose, -v", "Show detailed information") .option("--parallel", "Enable parallel execution") .option("--debug", "Show detailed execution information") .action(async (subcommand, args, options) => { const ctx = { args: [subcommand, ...args].filter(Boolean), flags: options || {}, }; await orchestrationAction(ctx); }); //# sourceMappingURL=orchestration.js.map