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

fix(3.7.0-alpha.15): #1852 Windows shell-injection, #1853 daemon self-kill, #1854 memory path

Reuvend88c69dde971
diff --git a/package.json b/package.json
index dcdbc49eda..a17a80e42e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "claude-flow",
- "version": "3.7.0-alpha.14",
+ "version": "3.7.0-alpha.15",
"description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
"main": "dist/index.js",
"type": "module",
diff --git a/ruflo/package.json b/ruflo/package.json
index f0ac9f342f..ccfb8a8f34 100644
--- a/ruflo/package.json
+++ b/ruflo/package.json
@@ -1,6 +1,6 @@
{
"name": "ruflo",
- "version": "3.7.0-alpha.14",
+ "version": "3.7.0-alpha.15",
"description": "Ruflo - Enterprise AI agent orchestration platform. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
"main": "bin/ruflo.js",
"type": "module",
diff --git a/v3/@claude-flow/cli/package.json b/v3/@claude-flow/cli/package.json
index e7eacc302e..75aaf196b8 100644
--- a/v3/@claude-flow/cli/package.json
+++ b/v3/@claude-flow/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@claude-flow/cli",
- "version": "3.7.0-alpha.14",
+ "version": "3.7.0-alpha.15",
"type": "module",
"description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
"main": "dist/src/index.js",
diff --git a/v3/@claude-flow/cli/src/memory/memory-initializer.ts b/v3/@claude-flow/cli/src/memory/memory-initializer.ts
index afd1d3b2dc..09c8401d65 100644
--- a/v3/@claude-flow/cli/src/memory/memory-initializer.ts
+++ b/v3/@claude-flow/cli/src/memory/memory-initializer.ts
@@ -13,6 +13,63 @@ import * as fs from 'fs';
import * as path from 'path';
import { readFileMaybeEncrypted, writeFileRestricted } from '../fs-secure.js';
+/**
+ * #1854: previously every site that needed the memory directory hardcoded
+ * `getMemoryRoot()`, so the documented config entry
+ * points (`memory.persistPath` config field, `memory configure --path`,
+ * `CLAUDE_FLOW_MEMORY_PATH` env var) all silently no-op'd. This helper
+ * is the single source of truth β€” every `.swarm/memory.db` resolution in
+ * this file flows through it.
+ *
+ * Precedence (highest β†’ lowest):
+ * 1. CLAUDE_FLOW_MEMORY_PATH env var
+ * 2. memory.persistPath / memory.path in claude-flow.config.json (cwd or
+ * the directory the CLI was invoked from)
+ * 3. Default: cwd/.swarm
+ *
+ * Cached per-process so repeated lookups are cheap; reset only by spawning
+ * a fresh process (which is how config changes already propagate).
+ */
+let _memoryRootCache: string | undefined;
+export function getMemoryRoot(): string {
+ if (_memoryRootCache !== undefined) return _memoryRootCache;
+
+ // 1. Env var
+ const envPath = process.env.CLAUDE_FLOW_MEMORY_PATH;
+ if (envPath && envPath.trim().length > 0) {
+ _memoryRootCache = path.resolve(envPath);
+ return _memoryRootCache;
+ }
+
+ // 2. Config file (claude-flow.config.json)
+ const configCandidates = [
+ path.resolve(process.cwd(), 'claude-flow.config.json'),
+ path.resolve(process.cwd(), '.claude-flow', 'config.json'),
+ ];
+ for (const configPath of configCandidates) {
+ if (!fs.existsSync(configPath)) continue;
+ try {
+ const raw = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
+ const fromConfig: unknown = raw?.memory?.persistPath ?? raw?.memory?.path;
+ if (typeof fromConfig === 'string' && fromConfig.trim().length > 0) {
+ _memoryRootCache = path.resolve(fromConfig);
+ return _memoryRootCache;
+ }
+ } catch {
+ /* malformed config β€” fall through to default */
+ }
+ }
+
+ // 3. Default
+ _memoryRootCache = path.resolve(process.cwd(), '.swarm');
+ return _memoryRootCache;
+}
+
+/** For tests + the `memory configure` flow that mutates the config at runtime. */
+export function _resetMemoryRootCache(): void {
+ _memoryRootCache = undefined;
+}
+
// ADR-053: Lazy import of AgentDB v3 bridge
let _bridge: typeof import('./memory-bridge.js') | null | undefined;
async function getBridge(): Promise<typeof import('./memory-bridge.js') | null> {
@@ -390,7 +447,7 @@ export async function getHNSWIndex(options?: {
const { VectorDb } = ruvectorCore;
// Persistent storage paths β€” resolve to absolute to survive CWD changes
- const swarmDir = path.resolve(process.cwd(), '.swarm');
+ const swarmDir = getMemoryRoot();
if (!fs.existsSync(swarmDir)) {
fs.mkdirSync(swarmDir, { recursive: true });
}
@@ -499,7 +556,7 @@ function saveHNSWMetadata(): void {
if (!hnswIndex?.entries) return;
try {
- const swarmDir = path.join(process.cwd(), '.swarm');
+ const swarmDir = getMemoryRoot();
const metadataPath = path.join(swarmDir, 'hnsw.metadata.json');
const metadata = Array.from(hnswIndex.entries.entries());
fs.writeFileSync(metadataPath, JSON.stringify(metadata));
@@ -1172,7 +1229,7 @@ export async function initializeMemoryDatabase(options: {
migrate = true
} = options;
- const swarmDir = path.join(process.cwd(), '.swarm');
+ const swarmDir = getMemoryRoot();
const dbPath = customPath || path.join(swarmDir, 'memory.db');
const dbDir = path.dirname(dbPath);
@@ -1386,7 +1443,7 @@ export async function checkMemoryInitialization(dbPath?: string): Promise<{
};
tables?: string[];
}> {
- const swarmDir = path.join(process.cwd(), '.swarm');
+ const swarmDir = getMemoryRoot();
const path_ = dbPath || path.join(swarmDir, 'memory.db');
if (!fs.existsSync(path_)) {
@@ -1446,7 +1503,7 @@ export async function applyTemporalDecay(dbPath?: string): Promise<{
patternsDecayed: number;
error?: string;
}> {
- const swarmDir = path.join(process.cwd(), '.swarm');
+ const swarmDir = getMemoryRoot();
const path_ = dbPath || path.join(swarmDir, 'memory.db');
try {
@@ -2102,7 +2159,7 @@ export async function storeEntry(options: {
upsert = false
} = options;
- const swarmDir = path.resolve(process.cwd(), '.swarm');
+ const swarmDir = getMemoryRoot();
const dbPath = customPath ? path.resolve(customPath) : path.join(swarmDir, 'memory.db');
try {
@@ -2231,7 +2288,7 @@ export async function searchEntries(options: {
} = options;
const effectiveNamespace = namespace || 'all';
- const swarmDir = path.resolve(process.cwd(), '.swarm');
+ const swarmDir = getMemoryRoot();
const dbPath = customPath ? path.resolve(customPath) : path.join(swarmDir, 'memory.db');
const startTime = Date.now();
@@ -2448,7 +2505,7 @@ export async function listEntries(options: {
dbPath: customPath
} = options;
- const swarmDir = path.join(process.cwd(), '.swarm');
+ const swarmDir = getMemoryRoot();
const dbPath = customPath || path.join(swarmDir, 'memory.db');
try {
@@ -2576,7 +2633,7 @@ export async function getEntry(options: {
dbPath: customPath
} = options;
- const swarmDir = path.join(process.cwd(), '.swarm');
+ const swarmDir = getMemoryRoot();
const dbPath = customPath || path.join(swarmDir, 'memory.db');
try {
@@ -2710,7 +2767,7 @@ export async function deleteEntry(options: {
dbPath: customPath
} = options;
- const swarmDir = path.join(process.cwd(), '.swarm');
+ const swarmDir = getMemoryRoot();
const dbPath = customPath || path.join(swarmDir, 'memory.db');
try {
diff --git a/v3/@claude-flow/cli/src/services/headless-worker-executor.ts b/v3/@claude-flow/cli/src/services/headless-worker-executor.ts
index ee61910c1a..0f16e5abc3 100644
--- a/v3/@claude-flow/cli/src/services/headless-worker-executor.ts
+++ b/v3/@claude-flow/cli/src/services/headless-worker-executor.ts
@@ -1142,13 +1142,32 @@ Analyze the above codebase context and provide your response following the forma
// Resolve model: user env override > config override > default alias
env.ANTHROPIC_MODEL = process.env.ANTHROPIC_MODEL || MODEL_IDS[options.model];
- // Spawn claude CLI process
- const child = spawn('claude', ['--print', prompt], {
+ // Spawn claude CLI process. #1852: previously the prompt was passed
+ // as a positional CLI arg. On Windows `claude` resolves to
+ // `claude.cmd`, which Node refuses to exec directly (CVE-2024-27980
+ // mitigation) β€” it routes through `cmd.exe /d /s /c`, which then
+ // re-tokenizes the entire command line including the prompt.
+ // Source-code prompts contain `>` `<` `&` `|` (arrow functions,
+ // comparisons, redirections) β€” cmd.exe parses those as redirects
+ // and creates zero-byte files in cwd named after the next token
+ // (`controller.abort()`, `{const`, `0`, `HTTP`, etc.).
+ //
+ // Fix: pipe the prompt via stdin instead. `child.stdin.end(prompt)`
+ // writes the prompt and closes stdin atomically β€” the EOF still
+ // unblocks `claude --print` (the original concern in #1395) but no
+ // shell tokenization touches the prompt.
+ const child = spawn('claude', ['--print'], {
cwd: this.projectRoot,
env,
- stdio: ['ignore', 'pipe', 'pipe'], // 'ignore' closes stdin at spawn β€” fixes #1395 where claude --print blocks on EOF
+ stdio: ['pipe', 'pipe', 'pipe'],
windowsHide: true, // Prevent phantom console windows on Windows
});
+ try {
+ child.stdin?.end(prompt);
+ } catch {
+ // stdin already closed (e.g. spawn failed) β€” `error` handler below
+ // will surface the real cause.
+ }
// Setup timeout
const timeoutHandle = setTimeout(() => {
diff --git a/v3/@claude-flow/cli/src/services/worker-daemon.ts b/v3/@claude-flow/cli/src/services/worker-daemon.ts
index bf26333889..1eb14ca201 100644
--- a/v3/@claude-flow/cli/src/services/worker-daemon.ts
+++ b/v3/@claude-flow/cli/src/services/worker-daemon.ts
@@ -489,12 +489,24 @@ export class WorkerDaemon extends EventEmitter {
/**
* Check if another daemon instance is already running.
* Returns the existing PID if alive, or null if no daemon is running.
+ *
+ * #1853: ignore self-PID matches. The detached-spawn path in
+ * `commands/daemon.ts` writes the child's PID into the file as a
+ * fallback after a 500ms wait. If the child reaches `start()` slower
+ * than the parent's 500ms wait (observed on Node 25 / macOS 26), the
+ * child reads its own PID back from the file and concludes "another
+ * daemon is already running" β€” so it exits before scheduling workers
+ * and `daemon status` reports STOPPED forever. A daemon process is
+ * never "another instance" of itself; treat self-match as absence.
*/
private checkExistingDaemon(): number | null {
if (!existsSync(this.pidFile)) return null;
try {
const pid = parseInt(readFileSync(this.pidFile, 'utf-8').trim(), 10);
if (isNaN(pid)) return null;
+ // #1853: a PID file containing our own PID is not "another daemon".
+ // Treat as absent so the start() path proceeds normally.
+ if (pid === process.pid) return null;
// Check if process is alive (signal 0 = existence check)
process.kill(pid, 0);
return pid; // Process is alive