fix(core): Anchor config.toml path to manual slop root
This fixes an issue where config.toml was erroneously saved to the current working directory (e.g. project dir) rather than the global manual slop directory.
This commit is contained in:
@@ -342,16 +342,17 @@ def run(config: dict[str, Any]) -> tuple[str, Path, list[dict[str, Any]]]:
|
|||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
# Load global config to find active project
|
# Load global config to find active project
|
||||||
config_path = Path(os.environ.get("SLOP_CONFIG", "config.toml"))
|
from src.paths import get_config_path
|
||||||
|
config_path = get_config_path()
|
||||||
if not config_path.exists():
|
if not config_path.exists():
|
||||||
|
|
||||||
print("config.toml not found.")
|
print(f"{config_path} not found.")
|
||||||
return
|
return
|
||||||
with open(config_path, "rb") as f:
|
with open(config_path, "rb") as f:
|
||||||
global_cfg = tomllib.load(f)
|
global_cfg = tomllib.load(f)
|
||||||
active_path = global_cfg.get("projects", {}).get("active")
|
active_path = global_cfg.get("projects", {}).get("active")
|
||||||
if not active_path:
|
if not active_path:
|
||||||
print("No active project found in config.toml.")
|
print(f"No active project found in {config_path}.")
|
||||||
return
|
return
|
||||||
# Use project_manager to load project (handles history segregation)
|
# Use project_manager to load project (handles history segregation)
|
||||||
proj = project_manager.load_project(active_path)
|
proj = project_manager.load_project(active_path)
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ from typing import Optional
|
|||||||
_RESOLVED: dict[str, Path] = {}
|
_RESOLVED: dict[str, Path] = {}
|
||||||
|
|
||||||
def get_config_path() -> Path:
|
def get_config_path() -> Path:
|
||||||
return Path(os.environ.get("SLOP_CONFIG", "config.toml"))
|
root_dir = Path(__file__).resolve().parent.parent
|
||||||
|
return Path(os.environ.get("SLOP_CONFIG", root_dir / "config.toml"))
|
||||||
|
|
||||||
def _resolve_path(env_var: str, config_key: str, default: str) -> Path:
|
def _resolve_path(env_var: str, config_key: str, default: str) -> Path:
|
||||||
if env_var in os.environ:
|
if env_var in os.environ:
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ def test_default_paths():
|
|||||||
assert paths.get_conductor_dir() == Path("conductor")
|
assert paths.get_conductor_dir() == Path("conductor")
|
||||||
assert paths.get_logs_dir() == Path("logs/sessions")
|
assert paths.get_logs_dir() == Path("logs/sessions")
|
||||||
assert paths.get_scripts_dir() == Path("scripts/generated")
|
assert paths.get_scripts_dir() == Path("scripts/generated")
|
||||||
assert paths.get_config_path() == Path("config.toml")
|
# config path should now be an absolute path relative to src/paths.py
|
||||||
|
root_dir = Path(paths.__file__).resolve().parent.parent
|
||||||
|
assert paths.get_config_path() == root_dir / "config.toml"
|
||||||
assert paths.get_tracks_dir() == Path("conductor/tracks")
|
assert paths.get_tracks_dir() == Path("conductor/tracks")
|
||||||
assert paths.get_archive_dir() == Path("conductor/archive")
|
assert paths.get_archive_dir() == Path("conductor/archive")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user