π 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
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
π 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.jsonnew file mode 100644index 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.jsindex 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 valid2. **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.`;}/**