Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions mempalace/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""

import os
import sys
import hashlib
import fnmatch
from pathlib import Path
Expand Down Expand Up @@ -279,16 +278,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)

Expand Down
16 changes: 15 additions & 1 deletion tests/test_miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import chromadb
import yaml

from mempalace.miner import mine, scan_project
from mempalace.miner import load_config, mine, scan_project


def write_file(path: Path, content: str):
Expand Down Expand Up @@ -50,6 +50,20 @@ def test_project_mining():
shutil.rmtree(tmpdir)


def test_load_config_uses_defaults_when_yaml_missing():
tmpdir = tempfile.mkdtemp()
try:
project_root = Path(tmpdir).resolve()
config = load_config(str(project_root))

assert isinstance(config, dict)
assert "wing" in config
assert "rooms" in config
assert config["wing"] == project_root.name
finally:
shutil.rmtree(tmpdir)


def test_scan_project_respects_gitignore():
tmpdir = tempfile.mkdtemp()
try:
Expand Down