Skip to content

feat: FIGMOG_ROOT env var for stable per-agent stores - #3

Open
AdzeB wants to merge 1 commit into
sanctuarycomputer:mainfrom
AdzeB:figmog-root-env
Open

AdzeB wants to merge 1 commit into
sanctuarycomputer:mainfrom
AdzeB:figmog-root-env

Conversation

@AdzeB

@AdzeB AdzeB commented Sep 8, 2026 •

Copy link
Copy Markdown

Why

Connecting figmog from a global MCP config (Cursor, Codex, pi, Claude Code's user scope, …) launches figmog serve from whatever project the agent happens to be in. The cwd-relative .figmog default then leaves a stray store in every project, and the only workaround is a shell wrapper that cds somewhere stable first.

What

FIGMOG_ROOT sets the default root for both sides:

  • figmog serve — --figmog-root now defaults to $FIGMOG_ROOT, else .figmog
  • CLI read commands / pull / socket routing — <root>/<key>/db, <root>/current, <root>/serve.sock all derive from the same cli::socket::default_root()

Precedence: explicit --figmog-root / --db > FIGMOG_ROOT > .figmog. Unset → byte-identical behaviour to today.

Any MCP client can then use the plain stdio shape with no wrapper:

{ "command": "/path/to/figmog", "args": ["serve"],
  "env": { "FIGMA_TOKEN": "figd_…", "FIGMOG_ROOT": "/Users/you/.figmog" } }

Notes for review

  • No new deps. clap's env feature isn't enabled; the flag uses default_value_os_t = socket::default_root() so serve and CLI share one function by construction rather than two constants that must agree.
  • --figmog-root was hide = true; it's now visible since it has a user-facing default. Happy to keep it hidden if you'd rather.
  • README: new "3c. Or connect it to any other MCP client" block after the Claude Code steps, including the one-serve-per-root caveat for concurrent agents.
  • SPEC 6a: one paragraph on root precedence.
  • Test: figmog_root_env_relocates_default_root — pull under cwd A lands in $FIGMOG_ROOT (and not A/.figmog), pages from cwd B finds it.

Gates: cargo test (244 pass), clippy --all-targets -D warnings, fmt --check, cargo doc --no-deps all clean.

Global MCP configs (Cursor, Codex, pi, ...) launch `figmog serve` from
whatever project the agent is in, so the cwd-relative `.figmog` default
scatters a store per project and forces a wrapper script to `cd` first.

`FIGMOG_ROOT` sets the default root for both `serve --figmog-root` and
the CLI's own root derivation (`<root>/<key>/db`, `<root>/current`,
`<root>/serve.sock`), so one env line in any client's mcp.json gives
each agent a stable store. Precedence: explicit flag > env > `.figmog`.

No new dependencies: clap's `env` feature isn't enabled, so the flag
uses `default_value_os_t` with the same `cli::socket::default_root()`
the CLI reads, keeping serve and CLI on one root by construction.

README gains a generic MCP-client config block; SPEC 6a documents the
precedence; one e2e test pins pull-then-read across two cwds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant