fix: allow mining directories without local mempalace.yaml
When no mempalace.yaml or mempal.yaml exists in the source directory, return a default config (wing = directory name, room = general) instead of calling sys.exit(1). This lets users mine any directory into their palace without requiring init first. Closes #14.
This commit is contained in:
committed by
Igor Lins e Silva
parent
4de9e135ce
commit
e8e93b53c0
+17
-5
@@ -264,16 +264,28 @@ def load_config(project_dir: str) -> dict:
|
||||
"""Load mempalace.yaml from project directory (falls back to mempal.yaml)."""
|
||||
import yaml
|
||||
|
||||
config_path = Path(project_dir).expanduser().resolve() / "mempalace.yaml"
|
||||
resolved_project_dir = Path(project_dir).expanduser().resolve()
|
||||
config_path = resolved_project_dir / "mempalace.yaml"
|
||||
if not config_path.exists():
|
||||
# Fallback to legacy name
|
||||
legacy_path = Path(project_dir).expanduser().resolve() / "mempal.yaml"
|
||||
legacy_path = resolved_project_dir / "mempal.yaml"
|
||||
if legacy_path.exists():
|
||||
config_path = legacy_path
|
||||
else:
|
||||
print(f"ERROR: No mempalace.yaml found in {project_dir}")
|
||||
print(f"Run: mempalace init {project_dir}")
|
||||
sys.exit(1)
|
||||
print(
|
||||
f" No mempalace.yaml found in {resolved_project_dir} "
|
||||
"— using auto-detected defaults"
|
||||
)
|
||||
return {
|
||||
"wing": resolved_project_dir.name,
|
||||
"rooms": [
|
||||
{
|
||||
"name": "general",
|
||||
"description": "All project files",
|
||||
"keywords": ["general"],
|
||||
}
|
||||
],
|
||||
}
|
||||
with open(config_path) as f:
|
||||
return yaml.safe_load(f)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user