Skip to content
Merged
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
27 changes: 23 additions & 4 deletions mempalace/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,8 +1188,13 @@ def cmd_purge(args):
where = clauses[0] if len(clauses) == 1 else {"$and": clauses}

backend = ChromaBackend()
from .backends.base import PalaceRef

try:
col = backend.get_collection(palace_path, "mempalace_drawers")
col = backend.get_collection(
palace=PalaceRef(id=palace_path, local_path=palace_path),
collection_name="mempalace_drawers",
)
except Exception as e:
print(f"\n Error reading palace: {e}")
return
Expand Down Expand Up @@ -1278,8 +1283,13 @@ def cmd_mined(args):
return

backend = ChromaBackend()
from .backends.base import PalaceRef

try:
col = backend.get_collection(palace_path, "mempalace_drawers")
col = backend.get_collection(
palace=PalaceRef(id=palace_path, local_path=palace_path),
collection_name="mempalace_drawers",
)
except Exception as e:
print(f"\n Error reading palace: {e}")
return
Expand Down Expand Up @@ -1486,10 +1496,14 @@ def cmd_repair(args):
print(f" Palace: {palace_path}")

backend = ChromaBackend()
from .backends.base import PalaceRef

# Try to read existing drawers
try:
col = backend.get_collection(palace_path, collection_name)
col = backend.get_collection(
palace=PalaceRef(id=palace_path, local_path=palace_path),
collection_name=collection_name,
)
total = col.count()
print(f" Drawers found: {total}")
except Exception as e:
Expand Down Expand Up @@ -1641,8 +1655,13 @@ def cmd_compress(args):

# Connect to palace
backend = ChromaBackend()
from .backends.base import PalaceRef

try:
col = backend.get_collection(palace_path, "mempalace_drawers")
col = backend.get_collection(
palace=PalaceRef(id=palace_path, local_path=palace_path),
collection_name="mempalace_drawers",
)
except Exception:
print(f"\n No palace found at {palace_path}")
print(" Run: mempalace init <dir> then mempalace mine <dir>")
Expand Down
9 changes: 8 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,14 @@ def test_cmd_repair_uses_configured_collection(mock_config_cls, tmp_path, capsys

out = capsys.readouterr().out
assert "Repair complete" in out
mock_backend.get_collection.assert_called_once_with(str(palace_dir), "custom_drawers")
# Migrated to kwargs-only PalaceRef form in #37 — the assertion checks
# call shape, so it has to track the new signature.
from mempalace.backends.base import PalaceRef as _PalaceRef

mock_backend.get_collection.assert_called_once_with(
palace=_PalaceRef(id=str(palace_dir), local_path=str(palace_dir)),
collection_name="custom_drawers",
)
assert mock_backend.create_collection.call_args_list == [
call(str(palace_dir), "custom_drawers__repair_tmp"),
call(str(palace_dir), "custom_drawers"),
Expand Down