59 lines
1.4 KiB
Python
Executable File
59 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Quick note capture - adds timestamped notes to today's memory file.
|
|
"""
|
|
|
|
import sys
|
|
from datetime import datetime
|
|
from pathlib import Path
|
|
|
|
WORKSPACE = Path("/home/wdjones/.openclaw/workspace")
|
|
MEMORY_DIR = WORKSPACE / "memory"
|
|
|
|
def get_today_file() -> Path:
|
|
"""Get path to today's memory file."""
|
|
return MEMORY_DIR / f"{datetime.now().strftime('%Y-%m-%d')}.md"
|
|
|
|
def ensure_today_file():
|
|
"""Create today's file if it doesn't exist."""
|
|
today = get_today_file()
|
|
if not today.exists():
|
|
MEMORY_DIR.mkdir(parents=True, exist_ok=True)
|
|
with open(today, 'w') as f:
|
|
f.write(f"# {datetime.now().strftime('%Y-%m-%d')}\n\n")
|
|
return today
|
|
|
|
def add_note(text: str, section: str = None):
|
|
"""Add a note to today's file."""
|
|
today = ensure_today_file()
|
|
timestamp = datetime.now().strftime("%H:%M")
|
|
|
|
with open(today, 'a') as f:
|
|
if section:
|
|
f.write(f"\n## {section}\n")
|
|
f.write(f"- {timestamp}: {text}\n")
|
|
|
|
print(f"✓ Added to {today.name}")
|
|
|
|
def show_today():
|
|
"""Show today's notes."""
|
|
today = get_today_file()
|
|
if today.exists():
|
|
print(today.read_text())
|
|
else:
|
|
print("No notes for today yet.")
|
|
|
|
def main():
|
|
if len(sys.argv) < 2:
|
|
show_today()
|
|
return
|
|
|
|
if sys.argv[1] == "show":
|
|
show_today()
|
|
else:
|
|
note = " ".join(sys.argv[1:])
|
|
add_note(note)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|