feat(PORT-004A): add workspace bootstrap and scoped settings

This commit is contained in:
Bu5hm4nn
2026-03-24 20:18:12 +01:00
parent 9d1a2f3fe8
commit 75f8e0a282
9 changed files with 335 additions and 17 deletions

View File

@@ -222,12 +222,13 @@ class PortfolioRepository:
CONFIG_PATH = Path("data/portfolio_config.json")
def __init__(self) -> None:
self.CONFIG_PATH.parent.mkdir(parents=True, exist_ok=True)
def __init__(self, config_path: Path | None = None) -> None:
self.config_path = config_path or self.CONFIG_PATH
self.config_path.parent.mkdir(parents=True, exist_ok=True)
def save(self, config: PortfolioConfig) -> None:
"""Save configuration to disk."""
with open(self.CONFIG_PATH, "w") as f:
with open(self.config_path, "w") as f:
json.dump(config.to_dict(), f, indent=2)
def load(self) -> PortfolioConfig:
@@ -235,13 +236,13 @@ class PortfolioRepository:
Returns default configuration if file doesn't exist.
"""
if not self.CONFIG_PATH.exists():
if not self.config_path.exists():
default = PortfolioConfig()
self.save(default)
return default
try:
with open(self.CONFIG_PATH) as f:
with open(self.config_path) as f:
data = json.load(f)
return PortfolioConfig.from_dict(data)
except (json.JSONDecodeError, ValueError) as e: