From 93cd49ec769d9aa900943204ceedb57d11535f8e Mon Sep 17 00:00:00 2001 From: rUv Date: Wed, 6 Aug 2025 13:23:34 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=96=20Checkpoint:=20Edit=20/workspaces?= =?UTF-8?q?/claude-code-flow/src/cli/simple-commands/swarm.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cli/simple-commands/swarm.js | 59 ++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/src/cli/simple-commands/swarm.js b/src/cli/simple-commands/swarm.js index d9f90534c4..3a3147b702 100644 --- a/src/cli/simple-commands/swarm.js +++ b/src/cli/simple-commands/swarm.js @@ -839,45 +839,60 @@ The swarm should be self-documenting - use memory_store to save all important in return; } + // Check if we're in non-interactive/headless mode FIRST (like alpha.83) + const isNonInteractive = flags['no-interactive'] || + flags['non-interactive'] || + flags['output-format'] === 'stream-json' || + isHeadlessEnvironment(); + // Check if claude command exists let claudeAvailable = false; try { execSync('which claude', { stdio: 'ignore' }); claudeAvailable = true; } catch { - console.log('⚠️ Claude Code CLI not found in PATH'); - console.log('Install it with: npm install -g @anthropic-ai/claude-code'); - console.log('Or use --claude flag to open Claude Code CLI'); - console.log('\nWould spawn Claude Code with swarm objective:'); - console.log(`📋 Objective: ${objective}`); - console.log('\nOptions:'); - console.log(' • Use --executor flag for built-in executor: claude-flow swarm "objective" --executor'); - console.log(' • Use --claude flag to open Claude Code CLI: claude-flow swarm "objective" --claude'); + if (!isNonInteractive) { + console.log('⚠️ Claude Code CLI not found in PATH'); + console.log('Install it with: npm install -g @anthropic-ai/claude-code'); + console.log('Or use --claude flag to open Claude Code CLI'); + console.log('\nWould spawn Claude Code with swarm objective:'); + console.log(`📋 Objective: ${objective}`); + console.log('\nOptions:'); + console.log(' • Use --executor flag for built-in executor: claude-flow swarm "objective" --executor'); + console.log(' • Use --claude flag to open Claude Code CLI: claude-flow swarm "objective" --claude'); + } else { + // In non-interactive mode, output JSON error + console.error(JSON.stringify({ + error: 'Claude Code CLI not found', + message: 'Install with: npm install -g @anthropic-ai/claude-code', + fallback: 'Use --executor flag for built-in executor' + })); + } return; } // Claude is available, use it to run swarm - console.log('🐝 Launching Claude Flow Swarm System...'); - console.log(`📋 Objective: ${objective}`); - console.log(`🎯 Strategy: ${flags.strategy || 'auto'}`); - console.log(`🏗️ Mode: ${flags.mode || 'centralized'}`); - console.log(`🤖 Max Agents: ${flags['max-agents'] || 5}`); - if (isAnalysisMode) { - console.log(`🔍 Analysis Mode: ENABLED (Read-Only - No Code Changes)`); + if (!isNonInteractive) { + console.log('🐝 Launching Claude Flow Swarm System...'); + console.log(`📋 Objective: ${objective}`); + console.log(`🎯 Strategy: ${flags.strategy || 'auto'}`); + console.log(`🏗️ Mode: ${flags.mode || 'centralized'}`); + console.log(`🤖 Max Agents: ${flags['max-agents'] || 5}`); + if (isAnalysisMode) { + console.log(`🔍 Analysis Mode: ENABLED (Read-Only - No Code Changes)`); + } + console.log(); + } else { + // Non-interactive mode output + console.log('🤖 Running in non-interactive mode with Claude'); + console.log('📋 Command: claude [prompt] -p --output-format stream-json --verbose'); } - console.log(); // Continue with the default swarm behavior if not using --claude flag // Pass the prompt directly as an argument to claude const claudeArgs = [swarmPrompt]; - // Check if we're in non-interactive/headless mode - const isNonInteractive = flags['no-interactive'] || - flags['non-interactive'] || - flags['output-format'] === 'stream-json' || - isHeadlessEnvironment(); - // Add auto-permission flag by default for swarm mode (unless explicitly disabled) if (flags['dangerously-skip-permissions'] !== false && !flags['no-auto-permissions']) { claudeArgs.push('--dangerously-skip-permissions');