Squash Odysseus development history

This commit is contained in:
pewdiepie-archdaemon
2026-09-11 06:04:19 +00:00
parent e5c99a5eee
commit 6ee6502010
2050 changed files with 538359 additions and 57745 deletions
+10 -6
View File
@@ -47,8 +47,12 @@ def _manager() -> MemoryManager:
return _mgr
def _memory_entries(entries):
return [e for e in entries or [] if isinstance(e, dict)]
def cmd_list(args):
entries = _manager().load_all()
entries = _memory_entries(_manager().load_all())
if args.category:
entries = [e for e in entries if (e.get("category") or "fact") == args.category]
if args.source:
@@ -62,14 +66,14 @@ def cmd_list(args):
def cmd_search(args):
q = args.query.lower()
entries = _manager().load_all()
entries = _memory_entries(_manager().load_all())
matches = [e for e in entries if q in (e.get("text") or "").lower()]
matches = sorted(matches, key=lambda e: e.get("timestamp", 0), reverse=True)
emit(matches[: args.limit], args)
def cmd_show(args):
for e in _manager().load_all():
for e in _memory_entries(_manager().load_all()):
if e.get("id") == args.id:
emit(e, args)
return
@@ -86,14 +90,14 @@ def cmd_add(args):
# add_entry doesn't save by default — the call in chat does it
# after dedup checks. Persist here so a one-shot CLI add sticks.
all_entries = _manager().load_all()
if not any(e.get("id") == entry.get("id") for e in all_entries):
if not any(isinstance(e, dict) and e.get("id") == entry.get("id") for e in all_entries):
all_entries.append(entry)
_manager().save(all_entries)
emit(entry, args)
def cmd_delete(args):
entries = _manager().load_all()
entries = _memory_entries(_manager().load_all())
target = next((e for e in entries if e.get("id") == args.id), None)
if not target:
fail(f"no memory with id {args.id!r}")
@@ -104,7 +108,7 @@ def cmd_delete(args):
def cmd_categories(args):
counts: dict[str, int] = {}
for e in _manager().load_all():
for e in _memory_entries(_manager().load_all()):
cat = e.get("category") or "fact"
counts[cat] = counts.get(cat, 0) + 1
rows = sorted(counts.items(), key=lambda kv: -kv[1])