diff --git a/RELEASE_NOTES_ALPHA52.md b/RELEASE_NOTES_ALPHA52.md new file mode 100644 index 0000000000..7c91862b0f --- /dev/null +++ b/RELEASE_NOTES_ALPHA52.md @@ -0,0 +1,109 @@ +# Claude Flow v2.0.0-alpha.52 Release Notes + +## ๐ŸŽ‰ Critical Fix for Claude Code 1.0.51+ Compatibility + +This release addresses the breaking changes introduced in Claude Code 1.0.51 that affected hooks configuration and settings validation. + +## โœจ What's New + +### ๐Ÿ”ง Hooks Format Migration + +**New `migrate-hooks` Command** +- Automatically converts old hook format to new Claude Code 1.0.51+ format +- Creates backups before making changes +- Removes unsupported fields (mcpServers, features, performance) +- Searches common locations automatically + +```bash +# Update to latest alpha +npm install -g claude-flow@alpha + +# Run the migration +claude-flow migrate-hooks + +# Or with npx +npx claude-flow@alpha migrate-hooks +``` + +### ๐Ÿ› ๏ธ Fixed Settings Generation + +- Updated `init` command to generate correct hooks format +- New installations now create Claude Code 1.0.51+ compatible settings +- Proper array-based hooks structure with matchers + +### ๐Ÿ“ Hooks Format Changes + +**Old Format (No longer supported):** +```json +"hooks": { + "preEditHook": { "command": "npx", "args": [...] }, + "postEditHook": { "command": "npx", "args": [...] } +} +``` + +**New Format (Required for Claude Code 1.0.51+):** +```json +"hooks": { + "PreToolUse": [{ + "matcher": "Edit|Write", + "hooks": [{ + "type": "command", + "command": "npx claude-flow@alpha hooks pre-edit..." + }] + }] +} +``` + +## ๐Ÿ› Bug Fixes + +- Fixed hooks format incompatibility with Claude Code 1.0.51+ (#235, #236, #237) +- Updated templates to remove unrecognized fields +- Added @alpha tag to hook commands for version consistency + +## ๐Ÿ“š Documentation + +- Added migration instructions for existing users +- Updated documentation to reflect new hooks format +- Added troubleshooting guide for settings validation errors + +## ๐Ÿ™ Acknowledgments + +Special thanks to: +- @bailejl for reporting the issue (#235, #236) +- @jimweller for the detailed analysis and PR #238 +- @guilleojeda, @pnocera, @pksorensen, and @fmal for additional insights + +## ๐Ÿ’ก Upgrade Instructions + +1. **For Existing Users:** + ```bash + npm install -g claude-flow@alpha + claude-flow migrate-hooks + claude mcp add claude-flow npx claude-flow@alpha mcp start + ``` + +2. **For New Users:** + ```bash + npm install -g claude-flow@alpha + claude-flow init --sparc + ``` + +3. **Verify Settings:** + - Run `/doctor` in Claude Code to ensure settings are valid + - Restart Claude Code after migration + +## โš ๏ธ Breaking Changes + +- Removed support for object-based hooks format +- MCP servers must now be added via `claude mcp add` command +- Removed `mcpServers`, `features`, and `performance` fields from settings.json + +## ๐Ÿ”œ Coming Soon + +- `enabledMcpjsonServers` support for trusted MCP servers +- Enhanced version detection for future Claude Code updates +- Improved error messages for configuration issues + +--- + +For questions or issues, please visit: https://github.com/ruvnet/claude-flow/issues \ No newline at end of file diff --git a/bin/claude-flow b/bin/claude-flow index b11470fd73..d9f3bac3a0 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.50" +VERSION="2.0.0-alpha.52" # Determine the correct path based on how the script is invoked if [ -L "$0" ]; then diff --git a/docker-test/test-fallback-alpha51.dockerfile b/docker-test/test-fallback-alpha51.dockerfile new file mode 100644 index 0000000000..12bc8cac49 --- /dev/null +++ b/docker-test/test-fallback-alpha51.dockerfile @@ -0,0 +1,28 @@ +FROM node:20-alpine + +WORKDIR /app + +# Install required packages +RUN apk add --no-cache bash + +# Run test directly in RUN command to see output during build +RUN echo "=== Testing Claude Flow alpha.51 SQLite Fallback ===" && \ + echo "Node version: $(node --version)" && \ + echo "Platform: $(uname -a)" && \ + echo "" && \ + echo "1. Testing npx init command:" && \ + npx -y claude-flow@alpha init --force --project-name test-fallback && \ + echo "" && \ + echo "2. Checking if .swarm directory was created:" && \ + (ls -la .swarm/ || echo "No .swarm directory (indicates in-memory mode)") && \ + echo "" && \ + echo "3. Testing memory operations:" && \ + npx -y claude-flow@alpha memory store test-key "test-value" --namespace test && \ + npx -y claude-flow@alpha memory retrieve test-key --namespace test && \ + echo "" && \ + echo "4. Testing hive-mind commands:" && \ + npx -y claude-flow@alpha hive-mind init && \ + echo "" && \ + echo "=== Test Complete ===" + +CMD ["echo", "Docker test passed"] \ No newline at end of file diff --git a/docker-test/test-ubuntu-fallback.dockerfile b/docker-test/test-ubuntu-fallback.dockerfile new file mode 100644 index 0000000000..d9882da8ea --- /dev/null +++ b/docker-test/test-ubuntu-fallback.dockerfile @@ -0,0 +1,25 @@ +FROM node:20 + +WORKDIR /app + +# Test in Ubuntu where npx should work +RUN echo "=== Testing Claude Flow SQLite Fallback in Ubuntu ===" && \ + echo "Node version: $(node --version)" && \ + echo "NPM version: $(npm --version)" && \ + echo "" && \ + echo "1. Testing with alpha.51:" && \ + npx -y claude-flow@2.0.0-alpha.51 --version && \ + echo "" && \ + echo "2. Testing init command:" && \ + npx -y claude-flow@2.0.0-alpha.51 init --force --project-name test && \ + echo "" && \ + echo "3. Checking created files:" && \ + ls -la && \ + echo "" && \ + echo "4. Testing memory operations:" && \ + npx -y claude-flow@2.0.0-alpha.51 memory store test-key "test-value" && \ + npx -y claude-flow@2.0.0-alpha.51 memory retrieve test-key && \ + echo "" && \ + echo "=== Test Complete ===" + +CMD ["echo", "Ubuntu test passed"] \ No newline at end of file diff --git a/package.json b/package.json index b679858a6b..251f80a292 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "claude-flow", - "version": "2.0.0-alpha.51", + "version": "2.0.0-alpha.52", "description": "Enterprise-grade AI agent orchestration with ruv-swarm integration (Alpha Release)", "main": "cli.mjs", "bin": { diff --git a/src/cli/command-registry.js b/src/cli/command-registry.js index 80e98409e7..0d680fd0ac 100644 --- a/src/cli/command-registry.js +++ b/src/cli/command-registry.js @@ -22,6 +22,7 @@ import { hookSafetyCommand } from './simple-commands/hook-safety.js'; import { hiveMindCommand } from './simple-commands/hive-mind.js'; import hiveMindOptimizeCommand from './simple-commands/hive-mind-optimize.js'; import { showUnifiedMetrics, fixTaskAttribution } from './simple-commands/swarm-metrics-integration.js'; +import { migrateHooksCommand, migrateHooksCommandConfig } from './simple-commands/migrate-hooks.js'; // Note: TypeScript imports commented out for Node.js compatibility // import { ruvSwarmAction } from './commands/ruv-swarm.ts'; // import { configIntegrationAction } from './commands/config-integration.ts'; @@ -468,6 +469,8 @@ SAFE ALTERNATIVES: For more information: https://github.com/ruvnet/claude-flow/issues/166` }); + commandRegistry.set('migrate-hooks', migrateHooksCommandConfig); + commandRegistry.set('hive', { handler: async (args, flags) => { try { diff --git a/src/cli/help-text.js b/src/cli/help-text.js index 7bb2d7cedc..4764a7e7f7 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-alpha.51'; +export const VERSION = '2.0.0-alpha.52'; export const MAIN_HELP = ` ๐ŸŒŠ Claude-Flow v${VERSION} - Enterprise-Grade AI Agent Orchestration Platform @@ -50,6 +50,7 @@ USAGE: analysis Performance & usage analytics (3 commands) automation Intelligent agent & workflow management (3 commands) hooks Lifecycle event management (5 commands) + migrate-hooks Migrate settings.json to Claude Code 1.0.51+ format monitoring Real-time system monitoring (3 commands) optimization Performance & topology optimization (3 commands) diff --git a/src/cli/simple-commands/migrate-hooks.js b/src/cli/simple-commands/migrate-hooks.js new file mode 100644 index 0000000000..f8efa3d36c --- /dev/null +++ b/src/cli/simple-commands/migrate-hooks.js @@ -0,0 +1,64 @@ +#!/usr/bin/env node + +/** + * CLI command wrapper for migrate-hooks script + */ + +import { execSync } from 'child_process'; +import path from 'path'; +import { fileURLToPath } from 'url'; +import { promises as fs } from 'fs'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +export async function migrateHooksCommand(flags, args) { + console.log('๐Ÿ”„ Claude Flow Hooks Migration\n'); + + try { + // Find the migration script + const scriptPath = path.join(__dirname, '../../../scripts/migrate-hooks.js'); + + // Check if script exists + try { + await fs.access(scriptPath); + } catch { + console.error('โŒ Migration script not found. Please ensure you have the latest version.'); + process.exit(1); + } + + // Build command with any additional arguments + const command = ['node', scriptPath]; + if (args.length > 0) { + command.push(...args); + } + + // Execute the migration script + execSync(command.join(' '), { + stdio: 'inherit', + cwd: process.cwd() + }); + + } catch (error) { + console.error('โŒ Migration failed:', error.message); + process.exit(1); + } +} + +// Export the command configuration +export const migrateHooksCommandConfig = { + handler: migrateHooksCommand, + description: 'Migrate settings.json hooks to Claude Code 1.0.51+ format', + usage: 'migrate-hooks [settings-file]', + examples: [ + 'claude-flow migrate-hooks # Migrate all found settings.json files', + 'claude-flow migrate-hooks .claude/settings.json # Migrate specific file' + ], + details: ` +Migrates old hooks format to new Claude Code 1.0.51+ format: + โ€ข Converts object-based hooks to array-based format + โ€ข Creates backup before making changes + โ€ข Removes unsupported fields (mcpServers, features, performance) + โ€ข Searches common locations if no file specified + +The migration is safe and creates backups of original files.` +}; \ No newline at end of file diff --git a/test-fallback-simulation.js b/test-fallback-simulation.js new file mode 100755 index 0000000000..91544f1ea6 --- /dev/null +++ b/test-fallback-simulation.js @@ -0,0 +1,48 @@ +#!/usr/bin/env node + +// Simulate missing better-sqlite3 by intercepting require +const Module = require('module'); +const originalRequire = Module.prototype.require; + +Module.prototype.require = function(id) { + if (id === 'better-sqlite3') { + throw new Error('Cannot find module \'better-sqlite3\''); + } + return originalRequire.apply(this, arguments); +}; + +// Now test the memory system +const { EnhancedMemory } = require('./src/memory/enhanced-memory.js'); + +async function testFallback() { + console.log('๐Ÿงช Testing SQLite Fallback Mechanism\n'); + + const memory = new EnhancedMemory(); + + try { + await memory.initialize(); + console.log('โœ… Memory initialized successfully'); + console.log(`๐Ÿ“Š Using fallback: ${memory.useFallback ? 'YES (in-memory)' : 'NO (SQLite)'}`); + + // Test basic operations + console.log('\n๐Ÿ”ง Testing memory operations:'); + + await memory.store('test-key', 'test-value', { namespace: 'test' }); + console.log('โœ… Store operation successful'); + + const value = await memory.retrieve('test-key', { namespace: 'test' }); + console.log(`โœ… Retrieve operation successful: ${value}`); + + const items = await memory.list({ namespace: 'test' }); + console.log(`โœ… List operation successful: ${items.length} items`); + + console.log('\n๐ŸŽ‰ All operations completed successfully!'); + console.log('๐Ÿ’ก The fallback mechanism is working correctly.'); + + } catch (error) { + console.error('โŒ Error:', error.message); + process.exit(1); + } +} + +testFallback(); \ No newline at end of file diff --git a/test-fallback-simulation.mjs b/test-fallback-simulation.mjs new file mode 100755 index 0000000000..7f02d211ff --- /dev/null +++ b/test-fallback-simulation.mjs @@ -0,0 +1,56 @@ +#!/usr/bin/env node + +import { createRequire } from 'module'; +import { fileURLToPath } from 'url'; +import { dirname, join } from 'path'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +// Create a require function for this ES module +const require = createRequire(import.meta.url); + +// Mock better-sqlite3 to simulate it being missing +const Module = require('module'); +const originalRequire = Module.prototype.require; + +Module.prototype.require = function(id) { + if (id === 'better-sqlite3') { + throw new Error('Cannot find module \'better-sqlite3\' - Simulating missing native module'); + } + return originalRequire.apply(this, arguments); +}; + +// Import after mocking +import('./src/memory/enhanced-memory.js').then(async ({ EnhancedMemory }) => { + console.log('๐Ÿงช Testing SQLite Fallback Mechanism\n'); + + const memory = new EnhancedMemory(); + + try { + await memory.initialize(); + console.log('โœ… Memory initialized successfully'); + console.log(`๐Ÿ“Š Using fallback: ${memory.useFallback ? 'YES (in-memory)' : 'NO (SQLite)'}`); + + // Test basic operations + console.log('\n๐Ÿ”ง Testing memory operations:'); + + await memory.store('test-key', 'test-value', { namespace: 'test' }); + console.log('โœ… Store operation successful'); + + const value = await memory.retrieve('test-key', { namespace: 'test' }); + console.log(`โœ… Retrieve operation successful: ${value}`); + + const items = await memory.list({ namespace: 'test' }); + console.log(`โœ… List operation successful: ${items.length} items`); + + console.log('\n๐ŸŽ‰ All operations completed successfully!'); + console.log('๐Ÿ’ก The fallback mechanism is working correctly.'); + + } catch (error) { + console.error('โŒ Error:', error.message); + process.exit(1); + } +}).catch(err => { + console.error('Failed to import:', err); +}); \ No newline at end of file