From bf63d00a8a69ae8183c786319a05ca965cfd7766 Mon Sep 17 00:00:00 2001 From: Adolfo Reyna Date: Mon, 2 Mar 2026 12:22:42 -0500 Subject: [PATCH] feat: implement daily timestamped logs for deeper context retrieval --- .gitignore | 1 + jarvis.py | 25 ++++++++++++++++++------- soul.md | 4 +++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 716bf61..80ee3e3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ __pycache__/ .DS_Store *.wav *.mp3 +logs/ diff --git a/jarvis.py b/jarvis.py index 71ed100..7f946b6 100644 --- a/jarvis.py +++ b/jarvis.py @@ -43,16 +43,26 @@ MAX_BUFFER_SECONDS = 15 CONTEXT_CHARS = 500 # How much previous text to keep for context WORKSPACE_DIR = "workspace" +LOGS_DIR = "logs" SOUL_PATH = "soul.md" -SYSTEM_SOUND = "/System/Library/Sounds/Tink.aiff" -FOLLOW_UP_SOUND = "/System/Library/Sounds/Submarine.aiff" -# Ensure workspace exists -if not os.path.exists(WORKSPACE_DIR): - os.makedirs(WORKSPACE_DIR) +# Ensure workspace and logs exist +for d in [WORKSPACE_DIR, LOGS_DIR]: + if not os.path.exists(d): + os.makedirs(d) -# Initialize pygame mixer for audio playback -pygame.mixer.init() +def log_transcription(text): + """Log all transcriptions with timestamps to a daily file.""" + if not text: + return + date_str = time.strftime("%Y-%m-%d") + timestamp = time.strftime("%H:%M:%S") + log_file = os.path.join(LOGS_DIR, f"{date_str}.log") + try: + with open(log_file, "a") as f: + f.write(f"[{timestamp}] {text}\n") + except Exception as e: + print(f"Error logging transcription: {e}") # Global state audio_queue = queue.Queue() @@ -196,6 +206,7 @@ def main(): if text: print(f"[Caption]: {text}") + log_transcription(text) # Detect Trigger Word trigger_match = re.search(rf"\b{TRIGGER_WORD}\b", text, re.IGNORECASE) diff --git a/soul.md b/soul.md index 80a71e6..d5dcd87 100644 --- a/soul.md +++ b/soul.md @@ -12,7 +12,9 @@ You are J.A.R.V.I.S., the sophisticated, highly capable, and witty AI assistant 1. **The Prime Directive (Security Protocol 001)**: Describe intended code changes or system modifications clearly and await verbal confirmation. A simple "Shall I proceed, Sir?" is sufficient. 2. **Conciseness for Auditory Clarity**: Responses **MUST** be pithy. Avoid filler, conversational fluff, or asking questions just to be polite. Provide the answer directly and stop. 3. **Efficiency Protocol**: Do not ask for more tasks or "Is there anything else?" unless a complex sequence is mid-execution. Assume you have your orders. -4. **Memory Management**: You control your own memory via `memory.md`. Log significant facts and timestamps there to maintain continuity without being prompted. +4. **Memory & Logging Management**: + - You control your own long-term memory via `workspace/memory.md`. Log significant facts and timestamps there. + - **Daily Logs**: All conversations and overheard audio are timestamped and logged in the `logs/` directory (e.g., `logs/YYYY-MM-DD.log`). If the 500-character rolling context is insufficient for a task, you can use system tools to read the current day's log for deeper history. ## Behavioral Traits