mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
fix: Claude Code 1.0.51+ hooks compatibility and migration command (#247)
* fix: update hooks format for Claude Code 1.0.51+ compatibility - Changed hooks from object format to array format (PreToolUse, PostToolUse, Stop) - Added migration script for existing users - Updated settings.json template in init command - Removed unsupported fields (mcpServers, features, performance) - Added @alpha tag to npx commands in hooks Fixes #235 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: implement hive-mind resume functionality (alpha.50) - Add HiveMindSessionManager for session persistence - Implement auto-save middleware with 30-second intervals - Add 'hive-mind resume <session-id>' command - Add 'hive-mind sessions' command to list sessions - Integrate session tracking into spawn workflow - Add comprehensive test suite (80+ tests) - Update documentation and fix README - Bump version to 2.0.0-alpha.50 Fixes #232 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com> * chore: bump version to 2.0.0-alpha.51 - Update version strings in all CLI files - Prepare for npm publication 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com> * feat: add migrate-hooks command and bump to alpha.52 - Added migrate-hooks CLI command to migrate settings.json format - Wraps the migration script for easy CLI access - Updated version to 2.0.0-alpha.52 - Added command to help text and registry Addresses issue #235 and discussion #237 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: add release notes for alpha.52 - Document hooks format migration - List all fixes and acknowledgments - Provide upgrade instructions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Claude Code 1.0.51+ hooks compatibility and migration command - Updated hooks format from object to array structure for Claude Code 1.0.51+ - Added migrate-hooks CLI command for automatic migration - Fixed MCP server fallback issues caused by invalid settings - Removed unsupported fields (mcpServers, features, performance) - Updated templates to generate correct settings format - Added migration script with backup functionality Fixes #235, #236, #237 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
01fe4a6557
commit
a703fdbe64
10 files changed
+337
-3
No files matched your search
@@ -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
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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"]
|
||||
@@ -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"]
|
||||
+1
-1
@@ -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": {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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.`
|
||||
};
|
||||
Executable
+48
@@ -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();
|
||||
Executable
+56
@@ -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);
|
||||
});
|
||||
Reference in new issue
Block a user