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

rUv34cb32d188ba
diff --git a/.claude/checkpoints/1754357081.json b/.claude/checkpoints/1754357081.json
new file mode 100644
index 0000000000..27c09a9a9a
--- /dev/null
+++ b/.claude/checkpoints/1754357081.json
@@ -0,0 +1 @@
+{"branch": "checkpoint/pre-edit-20250805-012441", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/hive-mind.js", "timestamp": "2025-08-05T01:24:41Z", "type": "pre-edit", "original_branch": "alpha-85"}
diff --git a/.claude/checkpoints/1754357083.json b/.claude/checkpoints/1754357083.json
new file mode 100644
index 0000000000..dc629f7eeb
--- /dev/null
+++ b/.claude/checkpoints/1754357083.json
@@ -0,0 +1 @@
+{"tag": "checkpoint-20250805-012443", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/hive-mind.js", "timestamp": "2025-08-05T01:24:43Z", "type": "post-edit", "branch": "alpha-85", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 26 +++++++++++++++++++------- .claude-flow/metrics/task-metrics.json | 8 ++++---- .claude/checkpoints/task-1754357049.json | 1 + claude-flow-wiki | 0 src/cli/simple-commands/hive-mind.js | 7 ++++--- 6 files changed, 29 insertions(+), 15 deletions(-) "}
diff --git a/src/cli/simple-commands/hive-mind.js b/src/cli/simple-commands/hive-mind.js
index c9bd55857e..9e04f2771c 100644
--- a/src/cli/simple-commands/hive-mind.js
+++ b/src/cli/simple-commands/hive-mind.js
@@ -2790,43 +2790,62 @@ async function launchClaudeWithContext(prompt, flags) {
shell: false,
});
- // Set up SIGINT handler for clean termination (no session pausing here since we're resuming)
- const sigintHandler = () => {
- console.log('\n\n' + chalk.yellow('⏹️ Terminating Claude Code...'));
- if (claudeProcess && !claudeProcess.killed) {
- claudeProcess.kill('SIGTERM');
+ // Track child process PID in session (same as initial spawn)
+ const sessionManager = new HiveMindSessionManager();
+ if (claudeProcess.pid) {
+ const sessions = await sessionManager.getActiveSessions();
+ const currentSession = sessions.find(s => s.id === sessionId);
+ if (currentSession) {
+ await sessionManager.addChildPid(currentSession.id, claudeProcess.pid);
+ }
+ }
+
+ // Set up SIGINT handler for automatic session pausing (same as initial spawn)
+ let isExiting = false;
+ const sigintHandler = async () => {
+ if (isExiting) return;
+ isExiting = true;
+
+ console.log('\n\n' + chalk.yellow('⏸️ Pausing session and terminating Claude Code...'));
+
+ try {
+ // Terminate Claude Code process if still running
+ if (claudeProcess && !claudeProcess.killed) {
+ claudeProcess.kill('SIGTERM');
+ }
+
+ // Clean up and close session manager
+ sessionManager.close();
+
+ console.log(chalk.green('✓') + ' Session paused successfully');
+ console.log(chalk.cyan('\nTo resume this session, run:'));
+ console.log(chalk.bold(` claude-flow hive-mind resume ${sessionId}`));
+ console.log();
+
+ process.exit(0);
+ } catch (error) {
+ console.error(chalk.red('Error during shutdown:'), error.message);
+ process.exit(1);
}
- process.exit(0);
};
process.on('SIGINT', sigintHandler);
process.on('SIGTERM', sigintHandler);
- // Handle stdout
- if (claudeProcess.stdout) {
- claudeProcess.stdout.on('data', (data) => {
- console.log(data.toString());
- });
- }
-
- // Handle stderr
- if (claudeProcess.stderr) {
- claudeProcess.stderr.on('data', (data) => {
- console.error(chalk.red(data.toString()));
- });
- }
-
- // Handle process exit
- claudeProcess.on('exit', (code) => {
- if (code === 0) {
- console.log(chalk.green('\n✓ Claude Code completed successfully'));
- } else if (code !== null) {
- console.log(chalk.red(`\n✗ Claude Code exited with code ${code}`));
+ // Handle process exit (same as initial spawn)
+ claudeProcess.on('exit', async (code, signal) => {
+ if (!isExiting) {
+ console.log('\n' + chalk.yellow('Claude Code has exited'));
+
+ // Clean up signal handlers
+ process.removeListener('SIGINT', sigintHandler);
+ process.removeListener('SIGTERM', sigintHandler);
+
+ // Close session manager
+ sessionManager.close();
+
+ process.exit(code || 0);
}
-
- // Clean up signal handlers
- process.removeListener('SIGINT', sigintHandler);
- process.removeListener('SIGTERM', sigintHandler);
});
console.log(chalk.green('\n✓ Claude Code launched with restored session context'));