diff --git a/README.md b/README.md index 33021a967a..0f65b55bdb 100644 --- a/README.md +++ b/README.md @@ -822,6 +822,18 @@ npx --y claude-flow@alpha init --force --- +## Star History + + + + + + Star History Chart + + + +--- + **Built with ā¤ļø by [rUv](https://github.com/ruvnet) | Powered by Revolutionary AI** *v2.0.0 Alpha - The Future of AI Orchestration* diff --git a/bin/claude-flow b/bin/claude-flow index 5fd3dca141..aa811e9899 100755 --- a/bin/claude-flow +++ b/bin/claude-flow @@ -1,7 +1,7 @@ #!/bin/sh # Claude-Flow Smart Dispatcher - Detects and uses the best available runtime -VERSION="2.0.0-alpha.27" +VERSION="2.0.0-alpha.37" # Determine the correct path based on how the script is invoked if [ -L "$0" ]; then diff --git a/docker-test/Dockerfile.test b/docker-test/Dockerfile.test new file mode 100644 index 0000000000..09aee75ba9 --- /dev/null +++ b/docker-test/Dockerfile.test @@ -0,0 +1,29 @@ +FROM node:20-alpine + +# Install necessary packages +RUN apk add --no-cache git bash + +# Create test directory +WORKDIR /test + +# Copy package.json to test npm install +COPY package.json . + +# Test installing the alpha version +RUN npm install -g claude-flow@2.0.0-alpha.37 + +# Test the wrapper script +COPY scripts/ruv-swarm-safe.js /usr/local/lib/node_modules/claude-flow/scripts/ + +# Create a test script +RUN echo '#!/bin/bash\n\ +echo "Testing claude-flow MCP server..."\n\ +claude-flow mcp start &\n\ +sleep 5\n\ +echo "MCP server test completed"\n\ +pkill -f "claude-flow mcp"\n\ +echo "\nTesting ruv-swarm safe wrapper..."\n\ +timeout 10s node /usr/local/lib/node_modules/claude-flow/scripts/ruv-swarm-safe.js || true\n\ +echo "\nAll tests completed"' > test.sh && chmod +x test.sh + +CMD ["./test.sh"] \ No newline at end of file diff --git a/docs/known-issues.md b/docs/known-issues.md new file mode 100644 index 0000000000..dccf3e7613 --- /dev/null +++ b/docs/known-issues.md @@ -0,0 +1,48 @@ +# Known Issues + +## ruv-swarm v1.0.8 Logger Error + +### Issue +When running `npx ruv-swarm mcp start`, you may encounter: +``` +āŒ Uncaught Exception: logger.logMemoryUsage is not a function +``` + +### Impact +- The error occurs after successful initialization +- The MCP server continues to work despite the error +- This is a non-critical error that doesn't affect functionality + +### Workaround +Use claude-flow's integrated MCP server instead: + +```bash +# Option 1: Use claude-flow MCP server (recommended) +npx claude-flow@alpha mcp start + +# Option 2: Configure claude-flow with MCP integration +claude mcp add claude-flow npx claude-flow@alpha mcp start +``` + +### Fix Status +- **Affected Version**: ruv-swarm v1.0.8 +- **Status**: Known issue in external package +- **Claude-Flow**: Provides integrated MCP server as alternative + +### Technical Details +The error occurs because ruv-swarm attempts to call `logger.logMemoryUsage()` in a monitoring interval, but the method isn't properly bound to the logger instance in certain contexts. + +## Anthropic API 500 Errors + +### Issue +When Anthropic's API experiences issues, you may see: +``` +API Error: 500 {"type":"error","error":{"type":"api_error","message":"Internal server error"}} +``` + +### Workaround +1. Check https://status.anthropic.com/ for service status +2. Use `--claude` flag to generate commands without API calls +3. Use `--executor` for local execution + +See issue #183 for more details. \ No newline at end of file diff --git a/package.json b/package.json index 57c29db56a..1f48f5945e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "claude-flow", - "version": "2.0.0-alpha.36", + "version": "2.0.0-alpha.37", "description": "Enterprise-grade AI agent orchestration with ruv-swarm integration (Alpha Release)", "main": "cli.mjs", "bin": { diff --git a/scripts/ruv-swarm-safe.js b/scripts/ruv-swarm-safe.js new file mode 100755 index 0000000000..751d9fbf7d --- /dev/null +++ b/scripts/ruv-swarm-safe.js @@ -0,0 +1,74 @@ +#!/usr/bin/env node + +/** + * Safe wrapper for ruv-swarm MCP server + * Handles known logger issue in v1.0.8 + */ + +import { spawn } from 'child_process'; +import { createInterface } from 'readline'; + +console.log('šŸš€ Starting ruv-swarm MCP server with error handling...'); + +const ruvSwarmProcess = spawn('npx', ['ruv-swarm', 'mcp', 'start'], { + stdio: ['pipe', 'pipe', 'pipe'], + env: { + ...process.env, + MCP_MODE: 'stdio', + LOG_LEVEL: 'WARN' + } +}); + +// Forward stdin to ruv-swarm +process.stdin.pipe(ruvSwarmProcess.stdin); + +// Handle stdout (JSON-RPC messages) +ruvSwarmProcess.stdout.pipe(process.stdout); + +// Handle stderr with filtering +const rlErr = createInterface({ + input: ruvSwarmProcess.stderr, + crlfDelay: Infinity +}); + +let errorHandled = false; + +rlErr.on('line', (line) => { + // Filter out the known logger error + if (line.includes('logger.logMemoryUsage is not a function')) { + if (!errorHandled) { + console.error('āš ļø Known ruv-swarm v1.0.8 logger issue detected - continuing normally'); + console.error('šŸ’” This error does not affect functionality'); + errorHandled = true; + } + return; + } + + // Forward other stderr output + process.stderr.write(line + '\n'); +}); + +// Handle process exit +ruvSwarmProcess.on('exit', (code, signal) => { + if (code !== null && code !== 0) { + console.error(`\nāŒ ruv-swarm exited with code ${code}`); + console.error('šŸ’” Try using: npx claude-flow@alpha mcp start'); + } + process.exit(code || 0); +}); + +// Handle errors +ruvSwarmProcess.on('error', (error) => { + console.error('āŒ Failed to start ruv-swarm:', error.message); + console.error('šŸ’” Try using: npx claude-flow@alpha mcp start'); + process.exit(1); +}); + +// Handle termination signals +process.on('SIGTERM', () => { + ruvSwarmProcess.kill('SIGTERM'); +}); + +process.on('SIGINT', () => { + ruvSwarmProcess.kill('SIGINT'); +}); \ No newline at end of file diff --git a/src/cli/help-text.js b/src/cli/help-text.js index 2c5af81a65..33c04187ab 100644 --- a/src/cli/help-text.js +++ b/src/cli/help-text.js @@ -3,7 +3,7 @@ * Provides clear, actionable command documentation */ -export const VERSION = '2.0.0'; +export const VERSION = '2.0.0-alpha.37'; export const MAIN_HELP = ` 🌊 Claude-Flow v${VERSION} - Enterprise-Grade AI Agent Orchestration Platform diff --git a/src/mcp/ruv-swarm-wrapper.js b/src/mcp/ruv-swarm-wrapper.js new file mode 100644 index 0000000000..1f9963c16f --- /dev/null +++ b/src/mcp/ruv-swarm-wrapper.js @@ -0,0 +1,202 @@ +/** + * Wrapper for ruv-swarm MCP server to handle logger issues + * This wrapper ensures compatibility and handles known issues in ruv-swarm + */ + +import { spawn } from 'child_process'; +import { createInterface } from 'readline'; + +export class RuvSwarmWrapper { + constructor(options = {}) { + this.options = { + silent: options.silent || false, + autoRestart: options.autoRestart !== false, + maxRestarts: options.maxRestarts || 3, + restartDelay: options.restartDelay || 1000, + ...options + }; + + this.process = null; + this.restartCount = 0; + this.isShuttingDown = false; + } + + async start() { + if (this.process) { + throw new Error('RuvSwarm MCP server is already running'); + } + + return new Promise((resolve, reject) => { + try { + // Spawn ruv-swarm MCP server + this.process = spawn('npx', ['ruv-swarm', 'mcp', 'start'], { + stdio: ['pipe', 'pipe', 'pipe'], + env: { + ...process.env, + // Ensure stdio mode for MCP + MCP_MODE: 'stdio', + // Set log level to reduce noise + LOG_LEVEL: 'WARN' + } + }); + + let initialized = false; + let initTimeout; + + // Handle stdout (JSON-RPC messages) + const rlOut = createInterface({ + input: this.process.stdout, + crlfDelay: Infinity + }); + + rlOut.on('line', (line) => { + try { + const message = JSON.parse(line); + + // Check for initialization + if (message.method === 'server.initialized' && !initialized) { + initialized = true; + clearTimeout(initTimeout); + resolve({ + process: this.process, + stdout: this.process.stdout, + stdin: this.process.stdin + }); + } + + // Forward JSON-RPC messages + process.stdout.write(line + '\n'); + } catch (err) { + // Not JSON, ignore + } + }); + + // Handle stderr (logs and errors) + const rlErr = createInterface({ + input: this.process.stderr, + crlfDelay: Infinity + }); + + rlErr.on('line', (line) => { + // Filter out known harmless errors + if (line.includes('logger.logMemoryUsage is not a function')) { + // This is a known issue in ruv-swarm v1.0.8 + // The server continues to work despite this error + if (!this.options.silent) { + console.error('āš ļø Known ruv-swarm logger issue detected (continuing normally)'); + } + return; + } + + // Filter out initialization messages if silent + if (this.options.silent) { + if (line.includes('āœ…') || line.includes('🧠') || line.includes('šŸ“Š')) { + return; + } + } + + // Forward other stderr output + if (!this.options.silent) { + process.stderr.write(line + '\n'); + } + }); + + // Handle process errors + this.process.on('error', (error) => { + if (!initialized) { + clearTimeout(initTimeout); + reject(new Error(`Failed to start ruv-swarm: ${error.message}`)); + } else { + console.error('RuvSwarm process error:', error); + this.handleProcessExit(error.code || 1); + } + }); + + // Handle process exit + this.process.on('exit', (code, signal) => { + if (!initialized) { + clearTimeout(initTimeout); + reject(new Error(`RuvSwarm exited before initialization: code ${code}, signal ${signal}`)); + } else { + this.handleProcessExit(code || 0); + } + }); + + // Set initialization timeout + initTimeout = setTimeout(() => { + if (!initialized) { + this.stop(); + reject(new Error('RuvSwarm initialization timeout')); + } + }, 30000); // 30 second timeout + + } catch (error) { + reject(error); + } + }); + } + + handleProcessExit(code) { + this.process = null; + + if (this.isShuttingDown) { + return; + } + + console.error(`RuvSwarm MCP server exited with code ${code}`); + + // Auto-restart if enabled and under limit + if (this.options.autoRestart && this.restartCount < this.options.maxRestarts) { + this.restartCount++; + console.log(`Attempting to restart RuvSwarm (attempt ${this.restartCount}/${this.options.maxRestarts})...`); + + setTimeout(() => { + this.start().catch(err => { + console.error('Failed to restart RuvSwarm:', err); + }); + }, this.options.restartDelay); + } + } + + async stop() { + this.isShuttingDown = true; + + if (!this.process) { + return; + } + + return new Promise((resolve) => { + const killTimeout = setTimeout(() => { + console.warn('RuvSwarm did not exit gracefully, forcing kill...'); + this.process.kill('SIGKILL'); + }, 5000); + + this.process.on('exit', () => { + clearTimeout(killTimeout); + this.process = null; + resolve(); + }); + + // Send graceful shutdown signal + this.process.kill('SIGTERM'); + }); + } + + isRunning() { + return this.process !== null && !this.process.killed; + } +} + +// Export a function to start ruv-swarm with error handling +export async function startRuvSwarmMCP(options = {}) { + const wrapper = new RuvSwarmWrapper(options); + + try { + const result = await wrapper.start(); + console.log('āœ… RuvSwarm MCP server started successfully'); + return { wrapper, ...result }; + } catch (error) { + console.error('āŒ Failed to start RuvSwarm MCP server:', error.message); + throw error; + } +} \ No newline at end of file