New commands: - /remember: Quick shortcut to save to memory (auto-categorizes) - /config: View and manage configuration settings New automation scripts: - memory-add.py: Add items to PA memory with auto-categorization - memory-list.py: List memory items by category The /remember command provides a quick way to save: - "Always use X" → preferences - "Decided to use X" → decisions - "Project at ~/path" → projects - Other → facts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
89 lines
2.3 KiB
Python
Executable File
89 lines
2.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""List items from PA memory.
|
|
|
|
Usage:
|
|
memory-list.py [category] [--all]
|
|
memory-list.py # All active items
|
|
memory-list.py preferences # Just preferences
|
|
memory-list.py --all # Include deprecated items
|
|
"""
|
|
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
MEMORY_DIR = Path.home() / ".claude/state/personal-assistant/memory"
|
|
|
|
CATEGORIES = {
|
|
"preferences": "preferences.json",
|
|
"decisions": "decisions.json",
|
|
"projects": "projects.json",
|
|
"facts": "facts.json",
|
|
}
|
|
|
|
|
|
def load_memory(category: str) -> list:
|
|
"""Load memory items from a category."""
|
|
filepath = MEMORY_DIR / CATEGORIES.get(category, f"{category}.json")
|
|
if filepath.exists():
|
|
with open(filepath) as f:
|
|
data = json.load(f)
|
|
return data.get("items", [])
|
|
return []
|
|
|
|
|
|
def print_items(category: str, items: list, show_all: bool):
|
|
"""Print items in a category."""
|
|
if not items:
|
|
return
|
|
|
|
active = [i for i in items if i.get("status") == "active"]
|
|
deprecated = [i for i in items if i.get("status") == "deprecated"]
|
|
|
|
if not active and not (show_all and deprecated):
|
|
return
|
|
|
|
print(f"\n📁 {category.title()}")
|
|
print("─" * 40)
|
|
|
|
for item in active:
|
|
date = item.get("date", "unknown")
|
|
content = item.get("content", "")
|
|
print(f" [{date}] {content}")
|
|
|
|
if show_all and deprecated:
|
|
print(f"\n (deprecated: {len(deprecated)} items)")
|
|
for item in deprecated[:3]:
|
|
content = item.get("content", "")
|
|
print(f" ✗ {content[:50]}...")
|
|
|
|
|
|
def main():
|
|
show_all = "--all" in sys.argv
|
|
args = [a for a in sys.argv[1:] if not a.startswith("--")]
|
|
|
|
category_filter = args[0] if args else None
|
|
|
|
print("📝 PA Memory")
|
|
|
|
if category_filter:
|
|
# Single category
|
|
if category_filter not in CATEGORIES:
|
|
print(f"Error: Unknown category '{category_filter}'")
|
|
print(f"Valid: {', '.join(CATEGORIES.keys())}")
|
|
sys.exit(1)
|
|
|
|
items = load_memory(category_filter)
|
|
print_items(category_filter, items, show_all)
|
|
else:
|
|
# All categories
|
|
for category in CATEGORIES:
|
|
items = load_memory(category)
|
|
print_items(category, items, show_all)
|
|
|
|
print()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|