🌊 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
fix(memory): bridge + doctor honor CLAUDE_FLOW_MEMORY_PATH / config (#1945, #1946) (#1959)
rUv434a8f95bb46
diff --git a/v3/@claude-flow/cli/src/commands/doctor.ts b/v3/@claude-flow/cli/src/commands/doctor.tsindex c3efaa6c7a..485d7f2ec6 100644--- a/v3/@claude-flow/cli/src/commands/doctor.ts+++ b/v3/@claude-flow/cli/src/commands/doctor.ts@@ -153,13 +153,27 @@ async function checkDaemonStatus(): Promise<HealthCheck> {// Check memory databaseasync function checkMemoryDatabase(): Promise<HealthCheck> {- const dbPaths = [- '.claude-flow/memory.db',+ // Authoritative path comes from `getMemoryRoot()` (honors+ // `CLAUDE_FLOW_MEMORY_PATH`, claude-flow.config.json's `memory.persistPath`,+ // then defaults to `.swarm/`). #1946: the previous hard-coded list missed+ // `data/memory/memory.db` (a common config) and ignored the env var+ // entirely, so doctor reported "Not initialized" on perfectly-init'd DBs.+ // Try the configured path first, then fall back to the historic candidates.+ const candidates: string[] = [];+ try {+ const { getMemoryRoot } = await import('../memory/memory-initializer.js');+ candidates.push(join(getMemoryRoot(), 'memory.db'));+ } catch {+ /* memory-initializer not available — fall through to legacy candidates */+ }+ candidates.push('.swarm/memory.db',- 'data/memory.db'- ];+ '.claude-flow/memory.db',+ 'data/memory/memory.db', // matches `CLAUDE_FLOW_MEMORY_PATH=data/memory`+ 'data/memory.db',+ );- for (const dbPath of dbPaths) {+ for (const dbPath of candidates) {if (existsSync(dbPath)) {try {const stats = statSync(dbPath);diff --git a/v3/@claude-flow/cli/src/memory/memory-bridge.ts b/v3/@claude-flow/cli/src/memory/memory-bridge.tsindex cd98dcb91c..a0ad17b891 100644--- a/v3/@claude-flow/cli/src/memory/memory-bridge.ts+++ b/v3/@claude-flow/cli/src/memory/memory-bridge.ts@@ -19,6 +19,7 @@import * as path from 'path';import * as crypto from 'crypto';+import { createRequire } from 'node:module';// ===== Lazy singleton =====@@ -28,18 +29,40 @@ let bridgeAvailable: boolean | null = null;/*** Resolve database path with path traversal protection.- * Only allows paths within or below the project's .swarm directory,+ * Only allows paths within or below the project's working directory,* or the special ':memory:' path.+ *+ * #1945: the previous hard-coded `<cwd>/.swarm/memory.db` default ignored+ * `CLAUDE_FLOW_MEMORY_PATH` / `claude-flow.config.json#memory.persistPath`+ * — so users with non-default memory paths had `memory init` write to e.g.+ * `data/memory/memory.db` while `bridgeStoreEntry()` wrote to+ * `.swarm/memory.db`. CLI store reported success against the wrong file and+ * a fresh process reading the configured path saw nothing.+ *+ * Use `getMemoryRoot()` (from memory-initializer) so the bridge and the+ * initializer agree on the same file. Imported via require() to avoid a+ * circular ESM dep between memory-initializer.ts and memory-bridge.ts.*/function getDbPath(customPath?: string): string {- const swarmDir = path.resolve(process.cwd(), '.swarm');- if (!customPath) return path.join(swarmDir, 'memory.db');+ let defaultDir = path.resolve(process.cwd(), '.swarm');+ try {+ // `getMemoryRoot()` honors $CLAUDE_FLOW_MEMORY_PATH, then the+ // claude-flow.config.json `memory.persistPath`, then defaults to `.swarm`.+ const cjsRequire = createRequire(import.meta.url);+ const mod = cjsRequire('./memory-initializer.js') as { getMemoryRoot?: () => string };+ if (typeof mod.getMemoryRoot === 'function') {+ defaultDir = mod.getMemoryRoot();+ }+ } catch {+ /* memory-initializer not resolvable in this build — keep `.swarm/` default */+ }+ if (!customPath) return path.join(defaultDir, 'memory.db');if (customPath === ':memory:') return ':memory:';const resolved = path.resolve(customPath);- // Ensure the path doesn't escape the working directory+ // Ensure the path doesn't escape the working directory.const cwd = process.cwd();if (!resolved.startsWith(cwd)) {- return path.join(swarmDir, 'memory.db'); // fallback to safe default+ return path.join(defaultDir, 'memory.db'); // fallback to safe default}return resolved;}