Built CC's persistent memory system: - memory.json for global context tracking - Session logs for detailed history - Project templates for organization - Helper scripts for easy updates - Full documentation CC can now remember across conversations! 🔥 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
91 lines
2.8 KiB
Python
91 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
||
"""
|
||
CC Memory Update Helper
|
||
Quick script to help CC update memory.json
|
||
"""
|
||
|
||
import json
|
||
from datetime import datetime
|
||
from pathlib import Path
|
||
|
||
# Memory file location
|
||
MEMORY_FILE = Path(__file__).parent / "memory.json"
|
||
|
||
def load_memory():
|
||
"""Load current memory"""
|
||
with open(MEMORY_FILE, 'r') as f:
|
||
return json.load(f)
|
||
|
||
def save_memory(data):
|
||
"""Save memory with pretty formatting"""
|
||
with open(MEMORY_FILE, 'w') as f:
|
||
json.dump(data, f, indent=2)
|
||
|
||
def update_session_end(project_name, accomplishments, next_steps):
|
||
"""Update memory at end of session"""
|
||
memory = load_memory()
|
||
|
||
# Update session info
|
||
memory['last_session'] = datetime.now().strftime('%Y-%m-%d')
|
||
memory['sessions_count'] = memory.get('sessions_count', 0) + 1
|
||
|
||
# Update quick context
|
||
memory['quick_context'] = f"Last worked on: {project_name}"
|
||
|
||
# Update next_up
|
||
memory['next_up'] = next_steps
|
||
|
||
# Update project notes
|
||
if project_name not in memory['project_notes']:
|
||
memory['project_notes'][project_name] = {
|
||
'status': 'in_progress',
|
||
'started': datetime.now().strftime('%Y-%m-%d'),
|
||
'goal': '',
|
||
'key_decisions': []
|
||
}
|
||
|
||
memory['project_notes'][project_name]['last_updated'] = datetime.now().strftime('%Y-%m-%d')
|
||
|
||
save_memory(memory)
|
||
print(f"✅ Memory updated! Session count: {memory['sessions_count']}")
|
||
|
||
def add_learning(learning):
|
||
"""Add a key learning"""
|
||
memory = load_memory()
|
||
if 'key_learnings' not in memory:
|
||
memory['key_learnings'] = []
|
||
|
||
if learning not in memory['key_learnings']:
|
||
memory['key_learnings'].append(learning)
|
||
save_memory(memory)
|
||
print(f"✅ Added learning: {learning}")
|
||
else:
|
||
print("ℹ️ Learning already exists")
|
||
|
||
def show_memory():
|
||
"""Display current memory"""
|
||
memory = load_memory()
|
||
print("\n🧠 CC's Current Memory:")
|
||
print(f"📅 Last session: {memory.get('last_session', 'Unknown')}")
|
||
print(f"📊 Total sessions: {memory.get('sessions_count', 0)}")
|
||
print(f"🚀 Active projects: {', '.join(memory.get('active_projects', []))}")
|
||
print(f"💭 Context: {memory.get('quick_context', 'None')}")
|
||
print(f"\n📝 Next up:")
|
||
for item in memory.get('next_up', []):
|
||
print(f" - {item}")
|
||
|
||
if __name__ == "__main__":
|
||
import sys
|
||
|
||
if len(sys.argv) < 2:
|
||
show_memory()
|
||
elif sys.argv[1] == "show":
|
||
show_memory()
|
||
elif sys.argv[1] == "learn" and len(sys.argv) > 2:
|
||
add_learning(sys.argv[2])
|
||
else:
|
||
print("Usage:")
|
||
print(" python update_memory.py - Show current memory")
|
||
print(" python update_memory.py show - Show current memory")
|
||
print(" python update_memory.py learn 'new learning' - Add learning")
|