feat: add FUZZFORGE_USER_DIR env var to override user-global data dir

This commit is contained in:
AFredefon
2026-03-11 02:09:06 +01:00
parent 544569ddbd
commit 976947cf5c
2 changed files with 12 additions and 2 deletions

View File

@@ -177,7 +177,9 @@ def _generate_mcp_config(
# User-global storage paths for FuzzForge containers.
# Kept under ~/.fuzzforge so images are built once and shared across
# all workspaces — regardless of where `fuzzforge mcp install` is run.
fuzzforge_home = Path.home() / ".fuzzforge"
# Override with FUZZFORGE_USER_DIR for isolated testing.
user_dir_env = os.environ.get("FUZZFORGE_USER_DIR")
fuzzforge_home = Path(user_dir_env).resolve() if user_dir_env else Path.home() / ".fuzzforge"
graphroot = fuzzforge_home / "containers" / "storage"
runroot = fuzzforge_home / "containers" / "run"

View File

@@ -9,6 +9,7 @@ and managing linked MCP hub repositories.
from __future__ import annotations
import json
import os
import subprocess
from pathlib import Path
from typing import Any
@@ -37,9 +38,16 @@ def get_fuzzforge_user_dir() -> Path:
repositories, the hub registry, container storage (graphroot/runroot),
and the hub workspace volume.
:return: ``Path.home() / ".fuzzforge"``
Override with the ``FUZZFORGE_USER_DIR`` environment variable to
redirect all user-global data to a custom path — useful for testing
a fresh install without touching the real ``~/.fuzzforge/``.
:return: ``Path.home() / ".fuzzforge"`` or ``$FUZZFORGE_USER_DIR``
"""
env_dir = os.environ.get("FUZZFORGE_USER_DIR")
if env_dir:
return Path(env_dir).resolve()
return Path.home() / ".fuzzforge"