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: File edits

rUvf2b67fe07a19
diff --git a/.claude/helpers/session.js b/.claude/helpers/session.js
new file mode 100644
index 0000000000..4c1b458e6b
--- /dev/null
+++ b/.claude/helpers/session.js
@@ -0,0 +1,123 @@
+#!/usr/bin/env node
+/**
+ * Claude Flow Cross-Platform Session Manager
+ * Works on Windows, macOS, and Linux
+ */
+
+const fs = require('fs');
+const path = require('path');
+const os = require('os');
+
+const platform = os.platform();
+const homeDir = os.homedir();
+
+function getDataDir() {
+ const localDir = path.join(process.cwd(), '.claude-flow', 'sessions');
+ if (fs.existsSync(path.dirname(localDir))) {
+ return localDir;
+ }
+
+ switch (platform) {
+ case 'win32':
+ return path.join(process.env.APPDATA || homeDir, 'claude-flow', 'sessions');
+ case 'darwin':
+ return path.join(homeDir, 'Library', 'Application Support', 'claude-flow', 'sessions');
+ default:
+ return path.join(homeDir, '.claude-flow', 'sessions');
+ }
+}
+
+const SESSION_DIR = getDataDir();
+const SESSION_FILE = path.join(SESSION_DIR, 'current.json');
+
+function ensureDir(dir) {
+ if (!fs.existsSync(dir)) {
+ fs.mkdirSync(dir, { recursive: true });
+ }
+}
+
+const commands = {
+ start: () => {
+ ensureDir(SESSION_DIR);
+ const sessionId = `session-${Date.now()}`;
+ const session = {
+ id: sessionId,
+ startedAt: new Date().toISOString(),
+ platform: platform,
+ cwd: process.cwd(),
+ context: {},
+ metrics: { edits: 0, commands: 0, tasks: 0, errors: 0 }
+ };
+ fs.writeFileSync(SESSION_FILE, JSON.stringify(session, null, 2));
+ console.log(`Session started: ${sessionId}`);
+ return session;
+ },
+
+ restore: () => {
+ if (!fs.existsSync(SESSION_FILE)) {
+ console.log('No session to restore');
+ return null;
+ }
+ const session = JSON.parse(fs.readFileSync(SESSION_FILE, 'utf-8'));
+ session.restoredAt = new Date().toISOString();
+ fs.writeFileSync(SESSION_FILE, JSON.stringify(session, null, 2));
+ console.log(`Session restored: ${session.id}`);
+ return session;
+ },
+
+ end: () => {
+ if (!fs.existsSync(SESSION_FILE)) {
+ console.log('No active session');
+ return null;
+ }
+ const session = JSON.parse(fs.readFileSync(SESSION_FILE, 'utf-8'));
+ session.endedAt = new Date().toISOString();
+ session.duration = Date.now() - new Date(session.startedAt).getTime();
+
+ const archivePath = path.join(SESSION_DIR, `${session.id}.json`);
+ fs.writeFileSync(archivePath, JSON.stringify(session, null, 2));
+ fs.unlinkSync(SESSION_FILE);
+
+ console.log(`Session ended: ${session.id}`);
+ console.log(`Duration: ${Math.round(session.duration / 1000 / 60)} minutes`);
+ return session;
+ },
+
+ status: () => {
+ if (!fs.existsSync(SESSION_FILE)) {
+ console.log('No active session');
+ return null;
+ }
+ const session = JSON.parse(fs.readFileSync(SESSION_FILE, 'utf-8'));
+ const duration = Date.now() - new Date(session.startedAt).getTime();
+ console.log(`Session: ${session.id}`);
+ console.log(`Platform: ${session.platform}`);
+ console.log(`Started: ${session.startedAt}`);
+ console.log(`Duration: ${Math.round(duration / 1000 / 60)} minutes`);
+ return session;
+ },
+
+ metric: (name) => {
+ if (!fs.existsSync(SESSION_FILE)) {
+ return null;
+ }
+ const session = JSON.parse(fs.readFileSync(SESSION_FILE, 'utf-8'));
+ if (session.metrics[name] !== undefined) {
+ session.metrics[name]++;
+ fs.writeFileSync(SESSION_FILE, JSON.stringify(session, null, 2));
+ }
+ return session;
+ }
+};
+
+// CLI
+const [,, command, ...args] = process.argv;
+if (command && commands[command]) {
+ commands[command](...args);
+} else {
+ console.log('Usage: session.js <start|restore|end|status|metric>');
+ console.log(`Platform: ${platform}`);
+ console.log(`Data dir: ${SESSION_DIR}`);
+}
+
+module.exports = commands;