feat(mem0-plugin): add /mem0:stats, /mem0:health, /mem0:digest skills (Tier 6)
Observability tier: - /mem0:stats: session + lifetime memory dashboard with category breakdown - /mem0:health: 5-check diagnostic (API key, identity, MCP, write/read, tracker) - /mem0:digest: weekly memory activity summary with time-scoped searches - session_stats.py: add `peek` command (JSON without clearing), per-category counters
This commit is contained in:
@@ -28,7 +28,13 @@ def _load() -> dict:
|
||||
return json.load(f)
|
||||
except (json.JSONDecodeError, OSError):
|
||||
pass
|
||||
return {"adds": 0, "searches": 0, "categories": [], "started": datetime.now().isoformat()}
|
||||
return {
|
||||
"adds": 0,
|
||||
"searches": 0,
|
||||
"categories": [],
|
||||
"category_counts": {},
|
||||
"started": datetime.now().isoformat(),
|
||||
}
|
||||
|
||||
|
||||
def _save(stats: dict) -> None:
|
||||
@@ -37,14 +43,23 @@ def _save(stats: dict) -> None:
|
||||
|
||||
|
||||
def init() -> None:
|
||||
_save({"adds": 0, "searches": 0, "categories": [], "started": datetime.now().isoformat()})
|
||||
_save({
|
||||
"adds": 0,
|
||||
"searches": 0,
|
||||
"categories": [],
|
||||
"category_counts": {},
|
||||
"started": datetime.now().isoformat(),
|
||||
})
|
||||
|
||||
|
||||
def record_add(category: str = "") -> None:
|
||||
stats = _load()
|
||||
stats["adds"] = stats.get("adds", 0) + 1
|
||||
if category and category not in stats.get("categories", []):
|
||||
stats.setdefault("categories", []).append(category)
|
||||
if category:
|
||||
if category not in stats.get("categories", []):
|
||||
stats.setdefault("categories", []).append(category)
|
||||
counts = stats.setdefault("category_counts", {})
|
||||
counts[category] = counts.get(category, 0) + 1
|
||||
_save(stats)
|
||||
|
||||
|
||||
@@ -54,6 +69,12 @@ def record_search() -> None:
|
||||
_save(stats)
|
||||
|
||||
|
||||
def peek() -> str:
|
||||
"""Return current stats as JSON without clearing the file."""
|
||||
stats = _load()
|
||||
return json.dumps(stats)
|
||||
|
||||
|
||||
def report() -> str:
|
||||
stats = _load()
|
||||
adds = stats.get("adds", 0)
|
||||
@@ -90,6 +111,8 @@ def main() -> int:
|
||||
record_add(category)
|
||||
elif cmd == "search":
|
||||
record_search()
|
||||
elif cmd == "peek":
|
||||
print(peek())
|
||||
elif cmd == "report":
|
||||
result = report()
|
||||
if result:
|
||||
|
||||
Reference in New Issue
Block a user