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/package.json

rUv51bf28fb9327
diff --git a/.claude/checkpoints/task-1758909345.json b/.claude/checkpoints/task-1758909345.json
new file mode 100644
index 0000000000..1cd76caa9b
--- /dev/null
+++ b/.claude/checkpoints/task-1758909345.json
@@ -0,0 +1 @@
+{"checkpoint": "task-20250926-175544", "task": "{{user_prompt}} ", "timestamp": "2025-09-26T17:55:45Z", "commit": "edd35dc6960cf11a0a4dfe51146b2c41ce049429", "github_release": "true"}
diff --git a/dist-cjs/src/cli/simple-commands/inject-memory-protocol.js b/dist-cjs/src/cli/simple-commands/inject-memory-protocol.js
new file mode 100644
index 0000000000..3514e8d377
--- /dev/null
+++ b/dist-cjs/src/cli/simple-commands/inject-memory-protocol.js
@@ -0,0 +1,200 @@
+import { existsSync } from 'fs';
+import { promises as fs } from 'fs/promises';
+import path from 'path';
+const MEMORY_PROTOCOL = `
+## 🧠 MANDATORY MEMORY COORDINATION PROTOCOL
+
+### 🚨 CRITICAL: Every Agent MUST Write AND Read Memory
+
+**EVERY spawned agent MUST follow this exact pattern:**
+
+\`\`\`javascript
+// 1️⃣ IMMEDIATELY when agent starts - WRITE initial status
+mcp__claude-flow__memory_usage {
+ action: "store",
+ key: "swarm/[agent-name]/status",
+ namespace: "coordination",
+ value: JSON.stringify({
+ agent: "[agent-name]",
+ status: "starting",
+ timestamp: Date.now(),
+ tasks: ["list", "of", "tasks"],
+ progress: 0
+ })
+}
+
+// 2️⃣ AFTER EACH MAJOR STEP - WRITE progress
+mcp__claude-flow__memory_usage {
+ action: "store",
+ key: "swarm/[agent-name]/progress",
+ namespace: "coordination",
+ value: JSON.stringify({
+ completed: ["task1", "task2"],
+ current: "working on task3",
+ progress: 35,
+ files_created: ["file1.js"],
+ interfaces: { "API": "definition" },
+ dependencies_needed: []
+ })
+}
+
+// 3️⃣ SHARE ARTIFACTS - WRITE for others
+mcp__claude-flow__memory_usage {
+ action: "store",
+ key: "swarm/shared/[component]",
+ namespace: "coordination",
+ value: JSON.stringify({
+ type: "interface",
+ definition: "actual code here",
+ created_by: "[agent-name]"
+ })
+}
+
+// 4️⃣ CHECK DEPENDENCIES - READ then WAIT
+const dep = mcp__claude-flow__memory_usage {
+ action: "retrieve",
+ key: "swarm/shared/[component]",
+ namespace: "coordination"
+}
+if (!dep.found) {
+ // Write waiting status
+ mcp__claude-flow__memory_usage {
+ action: "store",
+ key: "swarm/[agent-name]/waiting",
+ namespace: "coordination",
+ value: JSON.stringify({
+ waiting_for: "[component]",
+ from: "[other-agent]"
+ })
+ }
+}
+
+// 5️⃣ SIGNAL COMPLETION
+mcp__claude-flow__memory_usage {
+ action: "store",
+ key: "swarm/[agent-name]/complete",
+ namespace: "coordination",
+ value: JSON.stringify({
+ status: "complete",
+ deliverables: ["list"],
+ integration_points: ["how to use"]
+ })
+}
+\`\`\`
+
+### 📊 MEMORY KEY STRUCTURE
+- Use namespace: "coordination" ALWAYS
+- Keys: swarm/[agent]/status|progress|waiting|complete
+- Shared: swarm/shared/[component]
+
+### ❌ COMMON MISTAKES
+1. Only reading, never writing
+2. Wrong namespace
+3. No progress updates
+4. Missing shared artifacts
+`;
+const AGENT_INSTRUCTION = `
+🚨 MANDATORY MEMORY COORDINATION:
+
+1. START - IMMEDIATELY write status:
+ mcp__claude-flow__memory_usage { action: "store", key: "swarm/[your-name]/status", namespace: "coordination", value: {status: "starting"} }
+
+2. PROGRESS - After EVERY major step:
+ mcp__claude-flow__memory_usage { action: "store", key: "swarm/[your-name]/progress", namespace: "coordination", value: {progress: X%} }
+
+3. SHARE - Write ALL interfaces/APIs:
+ mcp__claude-flow__memory_usage { action: "store", key: "swarm/shared/[component]", namespace: "coordination", value: {definition: "..."} }
+
+4. CHECK - Verify dependencies exist:
+ mcp__claude-flow__memory_usage { action: "retrieve", key: "swarm/shared/[component]", namespace: "coordination" }
+
+5. COMPLETE - Signal when done:
+ mcp__claude-flow__memory_usage { action: "store", key: "swarm/[your-name]/complete", namespace: "coordination", value: {deliverables: [...]} }
+
+REMEMBER: If you don't WRITE to memory, other agents can't coordinate with you!
+`;
+export async function injectMemoryProtocol(projectPath = process.cwd()) {
+ const claudeMdPath = path.join(projectPath, 'CLAUDE.md');
+ try {
+ let content = '';
+ let hasProtocol = false;
+ if (existsSync(claudeMdPath)) {
+ content = await fs.readFile(claudeMdPath, 'utf8');
+ hasProtocol = content.includes('MANDATORY MEMORY COORDINATION PROTOCOL');
+ }
+ if (!hasProtocol) {
+ const injectionPoint = content.indexOf('## Project Overview');
+ if (injectionPoint > -1) {
+ content = content.slice(0, injectionPoint) + MEMORY_PROTOCOL + '\n\n' + content.slice(injectionPoint);
+ } else {
+ content = MEMORY_PROTOCOL + '\n\n' + content;
+ }
+ await fs.writeFile(claudeMdPath, content, 'utf8');
+ console.log('✅ Injected memory coordination protocol into CLAUDE.md');
+ return true;
+ } else {
+ console.log('✓ Memory coordination protocol already present in CLAUDE.md');
+ return false;
+ }
+ } catch (error) {
+ console.error('⚠️ Could not inject memory protocol:', error.message);
+ return false;
+ }
+}
+export function enhanceSwarmPrompt(originalPrompt, agentCount = 5) {
+ const enhancement = `
+CRITICAL: ALL AGENTS MUST COORDINATE THROUGH MEMORY
+
+${AGENT_INSTRUCTION}
+
+Each of the ${agentCount} agents MUST:
+- Write initial status when starting
+- Update progress after each step (with %)
+- Share all interfaces/APIs/configs
+- Check dependencies before using
+- Signal completion when done
+
+ALL memory operations use namespace: "coordination"
+
+Memory monitoring commands:
+- Check status: memory search "swarm/*/status" --namespace coordination
+- View progress: memory search "swarm/*/progress" --namespace coordination
+- Find blockers: memory search "swarm/*/waiting" --namespace coordination
+- List shared: memory search "swarm/shared/*" --namespace coordination
+
+---
+ORIGINAL OBJECTIVE:
+${originalPrompt}`;
+ return enhancement;
+}
+export function enhanceHiveMindPrompt(originalPrompt, workers = []) {
+ const workerInstructions = workers.map((w)=>`Agent ${w.name}: MUST write to swarm/${w.name}/status and swarm/${w.name}/progress`).join('\n');
+ return `
+HIVE MIND COORDINATION REQUIREMENTS:
+
+${AGENT_INSTRUCTION}
+
+${workerInstructions}
+
+Coordination namespace: "coordination"
+Status pattern: swarm/[agent]/status
+Progress pattern: swarm/[agent]/progress
+Shared pattern: swarm/shared/[component]
+
+---
+ORIGINAL OBJECTIVE:
+${originalPrompt}`;
+}
+export function shouldInjectProtocol(flags) {
+ return flags.claude || flags.spawn || flags['auto-spawn'];
+}
+export default {
+ injectMemoryProtocol,
+ enhanceSwarmPrompt,
+ enhanceHiveMindPrompt,
+ shouldInjectProtocol,
+ MEMORY_PROTOCOL,
+ AGENT_INSTRUCTION
+};
+
+//# sourceMappingURL=inject-memory-protocol.js.map
\ No newline at end of file
diff --git a/dist-cjs/src/cli/simple-commands/inject-memory-protocol.js.map b/dist-cjs/src/cli/simple-commands/inject-memory-protocol.js.map
new file mode 100644
index 0000000000..476573c438
--- /dev/null
+++ b/dist-cjs/src/cli/simple-commands/inject-memory-protocol.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["../../../../src/cli/simple-commands/inject-memory-protocol.js"],"sourcesContent":["// inject-memory-protocol.js - Injects memory coordination protocol for swarms\n\nimport { existsSync } from 'fs';\nimport { promises as fs } from 'fs/promises';\nimport path from 'path';\n\n/**\n * Memory coordination protocol to inject\n */\nconst MEMORY_PROTOCOL = `\n## 🧠 MANDATORY MEMORY COORDINATION PROTOCOL\n\n### 🚨 CRITICAL: Every Agent MUST Write AND Read Memory\n\n**EVERY spawned agent MUST follow this exact pattern:**\n\n\\`\\`\\`javascript\n// 1️⃣ IMMEDIATELY when agent starts - WRITE initial status\nmcp__claude-flow__memory_usage {\n action: \"store\",\n key: \"swarm/[agent-name]/status\",\n namespace: \"coordination\",\n value: JSON.stringify({\n agent: \"[agent-name]\",\n status: \"starting\",\n timestamp: Date.now(),\n tasks: [\"list\", \"of\", \"tasks\"],\n progress: 0\n })\n}\n\n// 2️⃣ AFTER EACH MAJOR STEP - WRITE progress\nmcp__claude-flow__memory_usage {\n action: \"store\",\n key: \"swarm/[agent-name]/progress\",\n namespace: \"coordination\",\n value: JSON.stringify({\n completed: [\"task1\", \"task2\"],\n current: \"working on task3\",\n progress: 35,\n files_created: [\"file1.js\"],\n interfaces: { \"API\": \"definition\" },\n dependencies_needed: []\n })\n}\n\n// 3️⃣ SHARE ARTIFACTS - WRITE for others\nmcp__claude-flow__memory_usage {\n action: \"store\",\n key: \"swarm/shared/[component]\",\n namespace: \"coordination\",\n value: JSON.stringify({\n type: \"interface\",\n definition: \"actual code here\",\n created_by: \"[agent-name]\"\n })\n}\n\n// 4️⃣ CHECK DEPENDENCIES - READ then WAIT\nconst dep = mcp__claude-flow__memory_usage {\n action: \"retrieve\",\n key: \"swarm/shared/[component]\",\n namespace: \"coordination\"\n}\nif (!dep.found) {\n // Write waiting status\n mcp__claude-flow__memory_usage {\n action: \"store\",\n key: \"swarm/[agent-name]/waiting\",\n namespace: \"coordination\",\n value: JSON.stringify({\n waiting_for: \"[component]\",\n from: \"[other-agent]\"\n })\n }\n}\n\n// 5️⃣ SIGNAL COMPLETION\nmcp__claude-flow__memory_usage {\n action: \"store\",\n key: \"swarm/[agent-name]/complete\",\n namespace: \"coordination\",\n value: JSON.stringify({\n status: \"complete\",\n deliverables: [\"list\"],\n integration_points: [\"how to use\"]\n })\n}\n\\`\\`\\`\n\n### 📊 MEMORY KEY STRUCTURE\n- Use namespace: \"coordination\" ALWAYS\n- Keys: swarm/[agent]/status|progress|waiting|complete\n- Shared: swarm/shared/[component]\n\n### ❌ COMMON MISTAKES\n1. Only reading, never writing\n2. Wrong namespace\n3. No progress updates\n4. Missing shared artifacts\n`;\n\n/**\n * Agent instruction template with memory requirements\n */\nconst AGENT_INSTRUCTION = `\n🚨 MANDATORY MEMORY COORDINATION:\n\n1. START - IMMEDIATELY write status:\n mcp__claude-flow__memory_usage { action: \"store\", key: \"swarm/[your-name]/status\", namespace: \"coordination\", value: {status: \"starting\"} }\n\n2. PROGRESS - After EVERY major step:\n mcp__claude-flow__memory_usage { action: \"store\", key: \"swarm/[your-name]/progress\", namespace: \"coordination\", value: {progress: X%} }\n\n3. SHARE - Write ALL interfaces/APIs:\n mcp__claude-flow__memory_usage { action: \"store\", key: \"swarm/shared/[component]\", namespace: \"coordination\", value: {definition: \"...\"} }\n\n4. CHECK - Verify dependencies exist:\n mcp__claude-flow__memory_usage { action: \"retrieve\", key: \"swarm/shared/[component]\", namespace: \"coordination\" }\n\n5. COMPLETE - Signal when done:\n mcp__claude-flow__memory_usage { action: \"store\", key: \"swarm/[your-name]/complete\", namespace: \"coordination\", value: {deliverables: [...]} }\n\nREMEMBER: If you don't WRITE to memory, other agents can't coordinate with you!\n`;\n\n/**\n * Inject memory protocol into CLAUDE.md\n */\nexport async function injectMemoryProtocol(projectPath = process.cwd()) {\n const claudeMdPath = path.join(projectPath, 'CLAUDE.md');\n \n try {\n let content = '';\n let hasProtocol = false;\n \n // Check if CLAUDE.md exists\n if (existsSync(claudeMdPath)) {\n content = await fs.readFile(claudeMdPath, 'utf8');\n hasProtocol = content.includes('MANDATORY MEMORY COORDINATION PROTOCOL');\n }\n \n // If protocol not present, inject it\n if (!hasProtocol) {\n // Find a good injection point (after project overview or at start)\n const injectionPoint = content.indexOf('## Project Overview');\n \n if (injectionPoint > -1) {\n // Insert before Project Overview\n content = \n content.slice(0, injectionPoint) + \n MEMORY_PROTOCOL + '\\n\\n' +\n content.slice(injectionPoint);\n } else {\n // Prepend to file\n content = MEMORY_PROTOCOL + '\\n\\n' + content;\n }\n \n await fs.writeFile(claudeMdPath, content, 'utf8');\n console.log('✅ Injected memory coordination protocol into CLAUDE.md');\n return true;\n } else {\n console.log('✓ Memory coordination protocol already present in CLAUDE.md');\n return false;\n }\n } catch (error) {\n console.error('⚠️ Could not inject memory protocol:', error.message);\n return false;\n }\n}\n\n/**\n * Enhance swarm prompt with memory instructions\n */\nexport function enhanceSwarmPrompt(originalPrompt, agentCount = 5) {\n const enhancement = `\nCRITICAL: ALL AGENTS MUST COORDINATE THROUGH MEMORY\n\n${AGENT_INSTRUCTION}\n\nEach of the ${agentCount} agents MUST:\n- Write initial status when starting\n- Update progress after each step (with %)\n- Share all interfaces/APIs/configs\n- Check dependencies before using\n- Signal completion when done\n\nALL memory operations use namespace: \"coordination\"\n\nMemory monitoring commands:\n- Check status: memory search \"swarm/*/status\" --namespace coordination\n- View progress: memory search \"swarm/*/progress\" --namespace coordination\n- Find blockers: memory search \"swarm/*/waiting\" --namespace coordination\n- List shared: memory search \"swarm/shared/*\" --namespace coordination\n\n---\nORIGINAL OBJECTIVE:\n${originalPrompt}`;\n\n return enhancement;\n}\n\n/**\n * Enhance hive-mind prompt with memory instructions\n */\nexport function enhanceHiveMindPrompt(originalPrompt, workers = []) {\n const workerInstructions = workers.map(w => \n `Agent ${w.name}: MUST write to swarm/${w.name}/status and swarm/${w.name}/progress`\n ).join('\\n');\n\n return `\nHIVE MIND COORDINATION REQUIREMENTS:\n\n${AGENT_INSTRUCTION}\n\n${workerInstructions}\n\nCoordination namespace: \"coordination\"\nStatus pattern: swarm/[agent]/status\nProgress pattern: swarm/[agent]/progress \nShared pattern: swarm/shared/[component]\n\n---\nORIGINAL OBJECTIVE:\n${originalPrompt}`;\n}\n\n/**\n * Check if memory protocol should be injected\n */\nexport function shouldInjectProtocol(flags) {\n return flags.claude || flags.spawn || flags['auto-spawn'];\n}\n\nexport default {\n injectMemoryProtocol,\n enhanceSwarmPrompt,\n enhanceHiveMindPrompt,\n shouldInjectProtocol,\n MEMORY_PROTOCOL,\n AGENT_INSTRUCTION\n};"],"names":["existsSync","promises","fs","path","MEMORY_PROTOCOL","AGENT_INSTRUCTION","injectMemoryProtocol","projectPath","process","cwd","claudeMdPath","join","content","hasProtocol","readFile","includes","injectionPoint","indexOf","slice","writeFile","console","log","error","message","enhanceSwarmPrompt","originalPrompt","agentCount","enhancement","enhanceHiveMindPrompt","workers","workerInstructions","map","w","name","shouldInjectProtocol","flags","claude","spawn"],"mappings":"AAEA,SAASA,UAAU,QAAQ,KAAK;AAChC,SAASC,YAAYC,EAAE,QAAQ,cAAc;AAC7C,OAAOC,UAAU,OAAO;AAKxB,MAAMC,kBAAkB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FzB,CAAC;AAKD,MAAMC,oBAAoB,CAAC;;;;;;;;;;;;;;;;;;;AAmB3B,CAAC;AAKD,OAAO,eAAeC,qBAAqBC,cAAcC,QAAQC,GAAG,EAAE;IACpE,MAAMC,eAAeP,KAAKQ,IAAI,CAACJ,aAAa;IAE5C,IAAI;QACF,IAAIK,UAAU;QACd,IAAIC,cAAc;QAGlB,IAAIb,WAAWU,eAAe;YAC5BE,UAAU,MAAMV,GAAGY,QAAQ,CAACJ,cAAc;YAC1CG,cAAcD,QAAQG,QAAQ,CAAC;QACjC;QAGA,IAAI,CAACF,aAAa;YAEhB,MAAMG,iBAAiBJ,QAAQK,OAAO,CAAC;YAEvC,IAAID,iBAAiB,CAAC,GAAG;gBAEvBJ,UACEA,QAAQM,KAAK,CAAC,GAAGF,kBACjBZ,kBAAkB,SAClBQ,QAAQM,KAAK,CAACF;YAClB,OAAO;gBAELJ,UAAUR,kBAAkB,SAASQ;YACvC;YAEA,MAAMV,GAAGiB,SAAS,CAACT,cAAcE,SAAS;YAC1CQ,QAAQC,GAAG,CAAC;YACZ,OAAO;QACT,OAAO;YACLD,QAAQC,GAAG,CAAC;YACZ,OAAO;QACT;IACF,EAAE,OAAOC,OAAO;QACdF,QAAQE,KAAK,CAAC,yCAAyCA,MAAMC,OAAO;QACpE,OAAO;IACT;AACF;AAKA,OAAO,SAASC,mBAAmBC,cAAc,EAAEC,aAAa,CAAC;IAC/D,MAAMC,cAAc,CAAC;;;AAGvB,EAAEtB,kBAAkB;;YAER,EAAEqB,WAAW;;;;;;;;;;;;;;;;;AAiBzB,EAAED,gBAAgB;IAEhB,OAAOE;AACT;AAKA,OAAO,SAASC,sBAAsBH,cAAc,EAAEI,UAAU,EAAE;IAChE,MAAMC,qBAAqBD,QAAQE,GAAG,CAACC,CAAAA,IACrC,CAAC,MAAM,EAAEA,EAAEC,IAAI,CAAC,sBAAsB,EAAED,EAAEC,IAAI,CAAC,kBAAkB,EAAED,EAAEC,IAAI,CAAC,SAAS,CAAC,EACpFtB,IAAI,CAAC;IAEP,OAAO,CAAC;;;AAGV,EAAEN,kBAAkB;;AAEpB,EAAEyB,mBAAmB;;;;;;;;;AASrB,EAAEL,gBAAgB;AAClB;AAKA,OAAO,SAASS,qBAAqBC,KAAK;IACxC,OAAOA,MAAMC,MAAM,IAAID,MAAME,KAAK,IAAIF,KAAK,CAAC,aAAa;AAC3D;AAEA,eAAe;IACb7B;IACAkB;IACAI;IACAM;IACA9B;IACAC;AACF,EAAE"}
\ No newline at end of file
diff --git a/package.json b/package.json
index 2732b74b79..b03d88e51a 100644
--- a/package.json
+++ b/package.json
@@ -15,8 +15,8 @@
"build": "npm run clean && npm run update-version && npm run build:esm && npm run build:cjs && npm run build:binary",
"update-version": "node scripts/update-bin-version.js",
"clean": "rm -rf dist dist-cjs",
- "build:esm": "swc src -d dist --config-file .swcrc --ignore 'src/ui/extension/node_modules/**/*'",
- "build:cjs": "swc src -d dist-cjs --config-file .swcrc --ignore 'src/ui/extension/node_modules/**/*'",
+ "build:esm": "swc src -d dist --config-file .swcrc",
+ "build:cjs": "swc src -d dist-cjs --config-file .swcrc",
"build:ts": "npm run build:esm && npm run build:cjs",
"build:binary": "pkg dist/src/cli/main.js --targets node18-linux-x64,node18-macos-x64,node18-win-x64 --output bin/claude-flow",
"build:simple": "npm run build:ts && pkg dist/cli/simple-cli.js --output bin/claude-flow-simple",