Under an agent the Bash tool cwd is sticky, and MCP servers and hooks inherit
it, so process.cwd() is often a subdirectory of the project. Memory, autopilot,
neural and metrics state keyed to it was written under the subdirectory and
never read again: loadState() returned defaults and the learning state
silently started over.
- Extract the #2877 daemon marker walk (nearest Ruflo marker, `.git` hard
stop, start dir when nothing matches, read-only) into
cli/src/services/project-root.ts; resolveDaemonProjectRoot and
isRufloProject delegate to it unchanged.
- getProjectRoot()/anchorToProjectRoot() add the home/filesystem-root guard
cli-core already applies, so a ~/.claude/settings.json claudeFlow key never
makes $HOME the project.
- getMemoryRoot(), `memory backup` and `memory distill` resolve memory
against the project root.
- autopilot-state resolves its state, log, swarm-tasks and checklist paths
against the project root per call (exported constants stay relative).
- neural checkpoints/patterns, `.claude-flow/memory` patterns, LoRA weights,
EWC fisher and swarm-activity metrics use the project root.
- cli-core: export isRufloProject/resolveProjectRoot from mcp-tools/types;
getProjectCwd() keeps CLAUDE_FLOW_CWD precedence, else walks up from
process.cwd(), falling back to process.cwd() when no marker is found or
the walk lands on home / a filesystem root. Bump cli-core to 3.7.7.
The CLI pins cli-core 3.7.6, which lacks these exports, so the CLI carries a
copy of the walk; a parity test pins both copies together.
Fixes#2633
Co-Authored-By: RuFlo <ruv@ruv.net>
The ruflo-core MCP launcher spawned `@claude-flow/cli mcp start` with its
own process.cwd() and never consulted the session's project directory, so
MCP tools could read/write .claude-flow state (hive-mind, swarm, memory)
in a different folder than CLI commands, producing split-brain state.
- mcp-launch.cjs: resolve the project dir (CLAUDE_PROJECT_DIR, then
CLAUDE_FLOW_CWD, then launcher cwd; home/root/missing dirs skipped),
spawn the server with that cwd and CLAUDE_FLOW_CWD set, probe local
CLI installs from it, and warn on stderr when there is no project.
- cli-core getProjectCwd(): treat filesystem roots (incl. C:\) and the
home dir (os.homedir(), $HOME, $USERPROFILE; case/trailing-sep
insensitive on win32) as "no project". The old `=== process.env.HOME`
guard was a no-op on Windows where HOME is usually unset.
Tests: node:test end-to-end launcher cases + vitest spec for the guard.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>