Files
ruflo/v3/@claude-flow/cli/src/memory
rUv 0377945c93 fix(memory): make memory init idempotent when DB already exists (#1791.6) (#1801)
`ruflo memory init` previously emitted `[ERROR] Database already exists.
Use --force to reinitialize.` and a "Initialization failed" spinner
whenever `.swarm/memory.db` was already on disk — even though the
existing DB was perfectly healthy and there was nothing to fail.

This made the command awkward to script (callers had to either probe
disk first or invoke `--force` and lose data) and confused users who
read `[ERROR]` as something actually being wrong.

Treat the "DB exists, no --force" case as a successful no-op:

- `MemoryInitResult` gains an optional `alreadyExists?: boolean` flag
- The early-return branch now returns `success: true, alreadyExists: true`
- `memory init` CLI prints `Memory database already initialized at <path>`
  with a hint about `--force`, exits 0
- MCP-side callers (`mcp-server.ts`, `mcp-tools/memory-tools.ts`) that
  only check `result.success` continue to work — they previously treated
  this case as a failure, now they see the existing DB as ready, which
  matches their intent

Closes #1791 (sub-bug 6).
2026-05-06 16:52:39 -04:00
..