From 1fa162c8c4d32629d2b8894b03edea59774795ff Mon Sep 17 00:00:00 2001 From: rUv Date: Wed, 6 Aug 2025 13:26:14 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=96=20Checkpoint:=20Edit=20/workspaces?= =?UTF-8?q?/claude-code-flow/FIX=5FNON=5FINTERACTIVE=5FMODE.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/checkpoints/task-1754486772.json | 1 + FIX_NON_INTERACTIVE_MODE.md | 81 ++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 .claude/checkpoints/task-1754486772.json create mode 100644 FIX_NON_INTERACTIVE_MODE.md diff --git a/.claude/checkpoints/task-1754486772.json b/.claude/checkpoints/task-1754486772.json new file mode 100644 index 0000000000..4af354f881 --- /dev/null +++ b/.claude/checkpoints/task-1754486772.json @@ -0,0 +1 @@ +{"checkpoint": "task-20250806-132611", "task": "You are orchestrating a Claude Flow Swarm with advanced MCP tool coordination. 🎯 OBJECTIVE: test", "timestamp": "2025-08-06T13:26:12Z", "commit": "5cba18143cdc9580c2a357dbe7417afe69a2b88c", "github_release": "true"} diff --git a/FIX_NON_INTERACTIVE_MODE.md b/FIX_NON_INTERACTIVE_MODE.md new file mode 100644 index 0000000000..0791581853 --- /dev/null +++ b/FIX_NON_INTERACTIVE_MODE.md @@ -0,0 +1,81 @@ +# Non-Interactive Mode Fix - Regression from alpha.83 + +## Summary +Fixed a regression where the `--non-interactive` flag was not being properly handled in swarm and hive-mind commands. The issue was that the code was checking for the flag AFTER spawning Claude in interactive mode, instead of BEFORE. + +## Issue +In claude-flow versions after alpha.83 (including alpha.87), the --non-interactive flag was being ignored because: +1. The code would check if Claude CLI exists +2. If it exists, immediately spawn Claude in interactive mode +3. Only THEN check if --non-interactive was specified +4. By that point, Claude was already running interactively + +## Root Cause +The non-interactive flag check was happening too late in the execution flow. + +## Solution +Moved the non-interactive flag check to happen FIRST, before any Claude spawning occurs. + +## Files Modified + +### 1. `/src/cli/simple-commands/swarm.js` +- **Line 842-846**: Added early check for non-interactive mode BEFORE checking for Claude +- **Line 854-870**: Made error messages conditional based on interactive/non-interactive mode +- **Line 875-889**: Made launch messages conditional based on mode +- **Line 770-807**: Fixed --claude flag to always use interactive mode (as intended) + +### 2. `/src/cli/simple-commands/hive-mind.js` +- **Line 1484-1492**: Added early check for non-interactive mode in spawn subcommand +- **Line 426-446**: Added non-interactive check at start of spawnSwarm function + +## Key Changes + +### Before (Broken): +```javascript +// Check if claude exists +execSync('which claude'); +// Launch claude immediately +console.log('Launching...'); +spawn('claude', args); +// Only then check non-interactive (too late!) +if (flags['non-interactive']) { ... } +``` + +### After (Fixed): +```javascript +// Check non-interactive FIRST +const isNonInteractive = flags['non-interactive'] || ...; +// Then check if claude exists +execSync('which claude'); +// Launch with appropriate mode +if (!isNonInteractive) { + console.log('Launching...'); +} +spawn('claude', isNonInteractive ? [..., '-p'] : args); +``` + +## Special Cases + +### --claude Flag +The `--claude` flag is meant to force interactive mode, so it bypasses non-interactive checks: +- `claude-flow swarm "task" --claude` → Always interactive +- `claude-flow swarm "task" --non-interactive` → Non-interactive +- `claude-flow swarm "task"` → Interactive by default + +## Testing + +### Working Commands: +```bash +# Non-interactive mode (fixed) +./claude-flow swarm "Test task" --non-interactive +./claude-flow hive-mind spawn "Test task" --count 2 --non-interactive + +# Interactive mode with --claude flag (preserved) +./claude-flow swarm "Test task" --claude + +# Default interactive mode +./claude-flow swarm "Test task" +``` + +## Compatibility +This fix restores the behavior from alpha.83 where --non-interactive flag was properly respected. \ No newline at end of file