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(memory): make `memory init` idempotent when DB already exists (#1791.6) (#1801)

rUv0377945c93b7
diff --git a/v3/@claude-flow/cli/src/commands/memory.ts b/v3/@claude-flow/cli/src/commands/memory.ts
index 07a7ad9cc2..a37b4ad79d 100644
--- a/v3/@claude-flow/cli/src/commands/memory.ts
+++ b/v3/@claude-flow/cli/src/commands/memory.ts
@@ -1401,6 +1401,13 @@ const initMemoryCommand: Command = {
return { success: false, exitCode: 1 };
}
+ // #1791.6 — DB already initialized and --force not passed: friendly no-op.
+ if (result.alreadyExists) {
+ spinner.succeed(`Memory database already initialized at ${result.dbPath}`);
+ output.printInfo('Use `--force` to reinitialize from scratch (destructive).');
+ return { success: true, exitCode: 0 };
+ }
+
spinner.succeed('Schema initialized');
// Lazy load or pre-load embedding model
diff --git a/v3/@claude-flow/cli/src/memory/memory-initializer.ts b/v3/@claude-flow/cli/src/memory/memory-initializer.ts
index 187bf9c1f4..afd1d3b2dc 100644
--- a/v3/@claude-flow/cli/src/memory/memory-initializer.ts
+++ b/v3/@claude-flow/cli/src/memory/memory-initializer.ts
@@ -940,6 +940,11 @@ INSERT OR IGNORE INTO vector_indexes (id, name, dimensions) VALUES
*/
export interface MemoryInitResult {
success: boolean;
+ /**
+ * #1791.6 — set when an existing database was found and `force` was not
+ * passed. The call is treated as a successful no-op rather than an error.
+ */
+ alreadyExists?: boolean;
backend: string;
dbPath: string;
schemaVersion: string;
@@ -1186,9 +1191,16 @@ export async function initializeMemoryDatabase(options: {
}
// Check existing database
+ // #1791.6 — Idempotent re-init: if the database already exists and the
+ // caller did not pass --force, treat it as a successful no-op instead of
+ // an error. Callers (CLI, MCP tools, embeddings) can branch on
+ // `alreadyExists` if they want a different message; previous behavior
+ // surfaced an `[ERROR]` and a "Initialization failed" spinner even when
+ // the existing DB was perfectly healthy.
if (fs.existsSync(dbPath) && !force) {
return {
- success: false,
+ success: true,
+ alreadyExists: true,
backend,
dbPath,
schemaVersion: '3.0.0',
@@ -1200,8 +1212,7 @@ export async function initializeMemoryDatabase(options: {
temporalDecay: false,
hnswIndexing: false,
migrationTracking: false
- },
- error: 'Database already exists. Use --force to reinitialize.'
+ }
};
}