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: Enhanced hooks pre-task exit with timeout protection

rUvd4636e65fe6f
diff --git a/bin/claude-flow b/bin/claude-flow
index 5fa0a04e77..08fe38fee5 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.76"
+VERSION="2.0.0-alpha.77"
# Determine the correct path based on how the script is invoked
if [ -L "$0" ]; then
diff --git a/bin/claude-flow.js b/bin/claude-flow.js
index 7246b5d252..7a24b5c84c 100644
--- a/bin/claude-flow.js
+++ b/bin/claude-flow.js
@@ -11,7 +11,7 @@ import { existsSync } from 'fs';
import { spawn } from 'child_process';
import process from 'process';
-const VERSION = "2.0.0-alpha.76";
+const VERSION = "2.0.0-alpha.77";
// Get script directory and root directory
const __filename = fileURLToPath(import.meta.url);
diff --git a/package.json b/package.json
index ee4177ba79..a6eaf27596 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "claude-flow",
- "version": "2.0.0-alpha.76",
+ "version": "2.0.0-alpha.77",
"description": "Enterprise-grade AI agent orchestration with ruv-swarm integration (Alpha Release)",
"main": "cli.mjs",
"bin": {
diff --git a/src/cli/help-text.js b/src/cli/help-text.js
index 4f7d7bae1f..442f8ca502 100644
--- a/src/cli/help-text.js
+++ b/src/cli/help-text.js
@@ -5,14 +5,14 @@
import { HelpFormatter } from './help-formatter.js';
-export const VERSION = '2.0.0-alpha.76';
+export const VERSION = '2.0.0-alpha.77';
export const MAIN_HELP = `
🌊 Claude-Flow v${VERSION} - Enterprise-Grade AI Agent Orchestration Platform
🎯 ENTERPRISE FEATURES: Complete ruv-swarm integration with 87 MCP tools, neural networking, and production-ready infrastructure
🐝 NEW: Advanced Hive Mind System with Queen-led coordination, collective intelligence, and unlimited scaling
-⚑ ALPHA 76: Fixed hooks pre-task command not exiting properly
+⚑ ALPHA 77: Enhanced hooks pre-task exit handling with timeout protection
USAGE:
claude-flow <command> [options]
diff --git a/src/cli/simple-commands/hooks.js b/src/cli/simple-commands/hooks.js
index 3276b6ef67..93ef3d9233 100644
--- a/src/cli/simple-commands/hooks.js
+++ b/src/cli/simple-commands/hooks.js
@@ -137,29 +137,40 @@ async function preTaskCommand(subArgs, flags) {
console.log(` πŸ’Ύ Saved to .swarm/memory.db`);
- // Execute ruv-swarm hook if available
- const isAvailable = await checkRuvSwarmAvailable();
- if (isAvailable) {
- console.log(`\nπŸ”„ Executing ruv-swarm pre-task hook...`);
- const hookResult = await execRuvSwarmHook('pre-task', {
- description,
- 'task-id': taskId,
- 'auto-spawn-agents': autoSpawnAgents,
- ...(agentId ? { 'agent-id': agentId } : {}),
- });
-
- if (hookResult.success) {
- await store.store(
- `task:${taskId}:ruv-output`,
- {
- output: hookResult.output,
- timestamp: new Date().toISOString(),
- },
- { namespace: 'hooks:ruv-swarm' },
- );
-
- printSuccess(`βœ… Pre-task hook completed successfully`);
+ // Execute ruv-swarm hook if available (with timeout for npx scenarios)
+ try {
+ const checkPromise = checkRuvSwarmAvailable();
+ const timeoutPromise = new Promise((_, reject) =>
+ setTimeout(() => reject(new Error('Timeout')), 3000)
+ );
+
+ const isAvailable = await Promise.race([checkPromise, timeoutPromise]);
+
+ if (isAvailable) {
+ console.log(`\nπŸ”„ Executing ruv-swarm pre-task hook...`);
+ const hookResult = await execRuvSwarmHook('pre-task', {
+ description,
+ 'task-id': taskId,
+ 'auto-spawn-agents': autoSpawnAgents,
+ ...(agentId ? { 'agent-id': agentId } : {}),
+ });
+
+ if (hookResult.success) {
+ await store.store(
+ `task:${taskId}:ruv-output`,
+ {
+ output: hookResult.output,
+ timestamp: new Date().toISOString(),
+ },
+ { namespace: 'hooks:ruv-swarm' },
+ );
+
+ printSuccess(`βœ… Pre-task hook completed successfully`);
+ }
}
+ } catch (err) {
+ // Skip ruv-swarm hook if it times out or fails
+ console.log(`\n⚠️ Skipping ruv-swarm hook (${err.message})`);
}
console.log(`\n🎯 TASK PREPARATION COMPLETE`);
@@ -169,8 +180,10 @@ async function preTaskCommand(subArgs, flags) {
memoryStore.close();
}
- // Ensure the process exits cleanly
- process.exit(0);
+ // Force exit after a short delay to ensure cleanup
+ setTimeout(() => {
+ process.exit(0);
+ }, 100);
} catch (err) {
printError(`Pre-task hook failed: ${err.message}`);
@@ -179,7 +192,10 @@ async function preTaskCommand(subArgs, flags) {
memoryStore.close();
}
- process.exit(1);
+ // Force exit after a short delay to ensure cleanup
+ setTimeout(() => {
+ process.exit(1);
+ }, 100);
}
}