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

πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/src/cli/simple-commands/hive-mind.js

rUv4c4e2b88424d
diff --git a/.claude/checkpoints/task-1754357747.json b/.claude/checkpoints/task-1754357747.json
new file mode 100644
index 0000000000..4052157580
--- /dev/null
+++ b/.claude/checkpoints/task-1754357747.json
@@ -0,0 +1 @@
+{"checkpoint": "task-20250805-013546", "task": "{{user_prompt}} ", "timestamp": "2025-08-05T01:35:47Z", "commit": "bcd50b08cef171812f8cfd74319d642e6dfb23f2", "github_release": "true"}
diff --git a/src/cli/simple-commands/hive-mind.js b/src/cli/simple-commands/hive-mind.js
index 6c48d87aca..1a799701c7 100644
--- a/src/cli/simple-commands/hive-mind.js
+++ b/src/cli/simple-commands/hive-mind.js
@@ -2683,67 +2683,161 @@ async function stopSession(args, flags) {
* Generate prompt for restored session
*/
function generateRestoredSessionPrompt(session) {
- const activeAgents = session.agents.filter((a) => a.status === 'active' || a.status === 'busy');
- const pendingTasks = session.tasks.filter(
- (t) => t.status === 'pending' || t.status === 'in_progress',
- );
+ // Get all agents, not just active ones
+ const allAgents = session.agents || [];
+ const activeAgents = allAgents.filter((a) => a.status === 'active' || a.status === 'busy');
+ const idleAgents = allAgents.filter((a) => a.status === 'idle');
+
+ // Get all tasks categorized by status
+ const allTasks = session.tasks || [];
+ const completedTasks = allTasks.filter((t) => t.status === 'completed');
+ const inProgressTasks = allTasks.filter((t) => t.status === 'in_progress');
+ const pendingTasks = allTasks.filter((t) => t.status === 'pending');
+
+ // Calculate session duration
+ const sessionStart = new Date(session.created_at);
+ const sessionPaused = session.paused_at ? new Date(session.paused_at) : new Date();
+ const duration = Math.round((sessionPaused - sessionStart) / 1000 / 60); // minutes
+
+ // Get more checkpoint history
+ const checkpointHistory = session.checkpoints || [];
+
+ // Get more activity logs
+ const activityLogs = session.recentLogs || [];
+
+ // Format agent details with their current tasks
+ const formatAgentDetails = (agents) => {
+ if (!agents.length) return 'No agents found';
+ return agents.map(agent => {
+ const agentTasks = allTasks.filter(t => t.agent_id === agent.id);
+ const currentTask = agentTasks.find(t => t.status === 'in_progress');
+ return `β€’ ${agent.name} (${agent.type}) - ${agent.status}${currentTask ? `\n └─ Working on: ${currentTask.description}` : ''}`;
+ }).join('\n');
+ };
+
+ // Format task details with more information
+ const formatTaskDetails = (tasks, limit = 15) => {
+ if (!tasks.length) return 'No tasks found';
+ const displayTasks = tasks.slice(0, limit);
+ return displayTasks.map(task => {
+ const agent = allAgents.find(a => a.id === task.agent_id);
+ return `β€’ [${task.priority?.toUpperCase() || 'NORMAL'}] ${task.description}${agent ? ` (Assigned to: ${agent.name})` : ''}${task.created_at ? ` - Created: ${new Date(task.created_at).toLocaleTimeString()}` : ''}`;
+ }).join('\n') + (tasks.length > limit ? `\n... and ${tasks.length - limit} more tasks` : '');
+ };
+
+ // Format checkpoint details
+ const formatCheckpoints = (checkpoints, limit = 5) => {
+ if (!checkpoints.length) return 'No checkpoints found';
+ const displayCheckpoints = checkpoints.slice(0, limit);
+ return displayCheckpoints.map(cp =>
+ `β€’ ${cp.checkpoint_name} - ${new Date(cp.created_at).toLocaleString()}`
+ ).join('\n');
+ };
+
+ // Format activity logs with more detail
+ const formatActivityLogs = (logs, limit = 20) => {
+ if (!logs.length) return 'No activity logs found';
+ const displayLogs = logs.slice(0, limit);
+ return displayLogs.map(log => {
+ const timestamp = new Date(log.timestamp).toLocaleTimeString();
+ const agent = log.agent_id ? allAgents.find(a => a.id === log.agent_id) : null;
+ return `[${timestamp}] ${log.message}${agent ? ` (by ${agent.name})` : ''}${log.data ? ` - ${JSON.stringify(log.data)}` : ''}`;
+ }).join('\n');
+ };
+
+ // Extract metadata if available
+ const metadata = session.metadata || {};
+ const metadataStr = Object.keys(metadata).length > 0 ?
+ Object.entries(metadata).map(([k, v]) => `β€’ ${k}: ${typeof v === 'object' ? JSON.stringify(v) : v}`).join('\n') :
+ 'No metadata available';
return `πŸ”„ RESUMING HIVE MIND SESSION
═══════════════════════════════════
-You are resuming a paused Hive Mind session with the following context:
+You are resuming a Hive Mind session with comprehensive context:
-SESSION DETAILS:
+πŸ“‹ SESSION DETAILS:
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
πŸ“Œ Session ID: ${session.id}
+πŸ“Œ Swarm ID: ${session.swarm_id}
πŸ“Œ Swarm Name: ${session.swarm_name}
🎯 Objective: ${session.objective}
-πŸ“Š Progress: ${session.statistics.completionPercentage}% complete
-⏸️ Paused: ${new Date(session.paused_at).toLocaleString()}
+πŸ“Š Overall Progress: ${session.statistics.completionPercentage}% complete
+⏱️ Session Duration: ${duration} minutes
+πŸ“… Created: ${new Date(session.created_at).toLocaleString()}
+⏸️ Paused: ${session.paused_at ? new Date(session.paused_at).toLocaleString() : 'N/A'}
▢️ Resumed: ${new Date().toLocaleString()}
+πŸ”„ Status: ${session.status}
+
+πŸ“Š TASK STATISTICS:
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+β€’ Total Tasks: ${session.statistics.totalTasks}
+β€’ Completed: ${completedTasks.length} (${session.statistics.totalTasks > 0 ? Math.round((completedTasks.length / session.statistics.totalTasks) * 100) : 0}%)
+β€’ In Progress: ${inProgressTasks.length}
+β€’ Pending: ${pendingTasks.length}
+
+πŸ‘₯ SWARM COMPOSITION (${allAgents.length} agents):
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+Active Agents (${activeAgents.length}):
+${formatAgentDetails(activeAgents)}
-CURRENT STATUS:
-β€’ Total Agents: ${session.statistics.totalAgents}
-β€’ Active Agents: ${session.statistics.activeAgents}
-β€’ Completed Tasks: ${session.statistics.completedTasks}/${session.statistics.totalTasks}
-β€’ Pending Tasks: ${pendingTasks.length}
+Idle Agents (${idleAgents.length}):
+${formatAgentDetails(idleAgents)}
-ACTIVE AGENTS:
-${activeAgents.map((agent) => `β€’ ${agent.name} (${agent.type}) - ${agent.status}`).join('\n')}
+πŸ“ COMPLETED TASKS (${completedTasks.length}):
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+${formatTaskDetails(completedTasks, 10)}
-PENDING TASKS:
-${pendingTasks
- .slice(0, 10)
- .map((task) => `β€’ [${task.priority}] ${task.description}`)
- .join('\n')}
-${pendingTasks.length > 10 ? `... and ${pendingTasks.length - 10} more tasks` : ''}
+πŸ”„ IN-PROGRESS TASKS (${inProgressTasks.length}):
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+${formatTaskDetails(inProgressTasks)}
-CHECKPOINT DATA:
+⏳ PENDING TASKS (${pendingTasks.length}):
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+${formatTaskDetails(pendingTasks)}
+
+πŸ’Ύ CHECKPOINT HISTORY (${checkpointHistory.length} total):
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+${formatCheckpoints(checkpointHistory)}
+
+πŸ“Š SESSION METADATA:
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+${metadataStr}
+
+πŸ’Ύ LAST CHECKPOINT DATA:
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
${session.checkpoint_data ? JSON.stringify(session.checkpoint_data, null, 2) : 'No checkpoint data available'}
-RECENT ACTIVITY:
-${session.recentLogs
- .slice(0, 10)
- .map((log) => `[${new Date(log.timestamp).toLocaleTimeString()}] ${log.message}`)
- .join('\n')}
+πŸ“œ ACTIVITY LOG (Last ${Math.min(20, activityLogs.length)} entries):
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+${formatActivityLogs(activityLogs, 20)}
🎯 RESUMPTION PROTOCOL:
-
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1. **RESTORE CONTEXT**:
- - Review the checkpoint data and recent activity
- - Check collective memory for important decisions
- - Verify agent status and reassign if needed
+ - Review all checkpoint data and activity history above
+ - Use mcp__claude-flow__memory_usage to retrieve collective memory
+ - Check agent statuses and reassign tasks if needed
+ - Verify all in-progress tasks are still valid
2. **CONTINUE EXECUTION**:
- - Resume pending tasks based on priority
- - Maintain coordination with existing agents
- - Update progress tracking regularly
-
-3. **COORDINATION**:
- - Use mcp__claude-flow__memory_retrieve to access shared knowledge
- - Continue using consensus mechanisms for decisions
- - Maintain swarm communication protocols
-
-Resume the hive mind operation and continue working towards the objective.`;
+ - Resume in-progress tasks with their assigned agents
+ - Process pending tasks based on priority (CRITICAL > HIGH > NORMAL > LOW)
+ - Maintain agent coordination through memory sharing
+ - Update progress tracking after each task completion
+
+3. **COORDINATION REQUIREMENTS**:
+ - Use mcp__claude-flow__memory_usage for all cross-agent communication
+ - Apply consensus mechanisms for important decisions
+ - Maintain swarm topology: ${session.swarm?.topology || 'unknown'}
+ - Keep session checkpoint data updated regularly
+
+4. **MEMORY CONTEXT**:
+ - Session memory namespace: session-${session.id}
+ - Swarm memory namespace: swarm-${session.swarm_id}
+ - Use these namespaces to access historical decisions and context
+
+Resume the hive mind operation with full context awareness and continue working towards the objective.`;
}
/**