Cozy Comet
macOS LaunchAgent daemon watching Desktop/Documents — batches file events, classifies changes, sends summaries to local Ollama to predict what you're working on.
Context Lost Between Sessions
When switching between projects, context is lost — which files were you working on, what research were you doing, what was the goal. A developer might have three browser windows, a dozen editor tabs, and two terminal sessions open, each belonging to a different task. Closing a session means abandoning the latent state accumulated over hours of work.
Existing solutions require manual note-taking or explicit check-ins: writing standup notes, tagging files, or maintaining a work log. These approaches fail because they depend on human discipline at exactly the moment people are most focused on their actual work. What's needed is a passive, always-on daemon that observes filesystem activity — the most reliable signal of what you're actually doing — and uses it to maintain a rolling context window across sessions.
The goal: a LaunchAgent that watches Desktop and Documents for file changes, batches events into time windows, classifies each batch by project/domain using a local LLM (Ollama), and maintains a rolling context prediction that surfaces without any user interaction required.
LaunchAgent Pipeline for Passive Context Inference
Cozy Comet is a Python LaunchAgent daemon using watchdog (FSEvents on macOS) for zero-overhead filesystem observation. The daemon runs as a background launchd job, starting at login and staying resident with minimal resource footprint — watchdog uses OS-level event streams, so CPU sits at 0% when no files change.
The pipeline flows: filesystem events are collected from the watched folders (Desktop, Documents) → batched by time window → classified by Ollama running a local LLM (e.g., Llama 3, Mistral) → stored in a rolling context window. The predicted working context — project name, domain, active files — is available via a local API or log file, enabling integration with other tools (IDE, window manager, note-taking app).
class ContextHandler(FileSystemEventHandler):
def on_modified(self, event):
if not event.is_directory:
batch.append(event.src_path)
if time.time() - last_flush > BATCH_WINDOW:
summary = ollama.chat(model="llama3", messages=[
{"role": "user", "content":
f"Classify the working context from: {batch[-5:]}"}
])
context_window.append(summary["message"]["content"])
batch.clear()
Because Ollama runs locally, no file content leaves the machine: only change metadata (file paths, sizes, timestamps) and batched summaries are sent to the model. The daemon itself is configured via a standard plist file at ~/Library/LaunchAgents/, auto-started on login, and requires zero user interaction to operate.
Daemon Lifecycle: File Event → Classify → Predict
Local macOS Daemon Architecture
Lightweight Daemon Stack for On-Device Context
Key Engineering Decisions
Using watchdog with FSEvents provides OS-level filesystem events — zero CPU when idle, instant change detection, no polling overhead. Manual polling (e.g., os.scandir on a timer) would consume CPU continuously, introduce latency between change and detection, and miss short-lived temporary files. watchdog's event-driven model aligns with the daemon's "always on, never notice" design goal.
Running Ollama locally ensures privacy — no file content or contextual summaries ever leave the machine. It also eliminates API costs, works offline (flights, trains, remote areas), and provides sub-100ms inference for batched classifications using smaller models (Llama 3 8B, Mistral 7B). A cloud API would introduce latency, require internet, charge per-token, and leak sensitive work context to a third party.
launchd provides macOS-native daemon lifecycle management: automatic restart on crash (KeepAlive), logging via standard OS channels (console, log stream), and a GUI via launchctl for enable/disable without editing crontab files. cron jobs run with minimal environment and no access to the user's keychain, display server, or accessibility permissions — all of which Cozy Comet needs for filesystem observation and context inference. launchd jobs inherit the user's session environment, start at login before the user's shell scripts run, and provide proper process supervision: if the daemon crashes, launchd restarts it within seconds. The plist configuration is declarative XML checked into version control alongside the code, making deployment reproducible.
Three Sessions from Proof of Concept to Daemon
Passive Context-Aware Computing on macOS
Fully functional LaunchAgent that auto-starts on boot, watches Desktop and Documents for file changes, batches and classifies changes by project/domain via local Ollama, and maintains a rolling context window. The daemon runs with zero user interaction required — install the plist once, and it quietly observes and predicts working context from that point forward.
Industry alignment: Cozy Comet mirrors the trajectory of Apple Intelligence and contextual computing — using local on-device AI to understand user context without sending data to the cloud. The passive observation loop (watch → classify → predict) is an active learning system that improves as more context accumulates, similar to how Apple's on-device intelligence learns user patterns while preserving privacy.