Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

fix: Claude Code 1.0.51+ hooks compatibility and migration command (#247)

rUv06f83f1037bd
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 [email protected] --version && \
+ echo "" && \
+ echo "2. Testing init command:" && \
+ npx -y [email protected] init --force --project-name test && \
+ echo "" && \
+ echo "3. Checking created files:" && \
+ ls -la && \
+ echo "" && \
+ echo "4. Testing memory operations:" && \
+ npx -y [email protected] memory store test-key "test-value" && \
+ npx -y [email protected] 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 <command> Performance & usage analytics (3 commands)
automation <command> Intelligent agent & workflow management (3 commands)
hooks <command> Lifecycle event management (5 commands)
+ migrate-hooks Migrate settings.json to Claude Code 1.0.51+ format
monitoring <command> Real-time system monitoring (3 commands)
optimization <command> 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