DEV Community

Aadi Jain
Aadi Jain

Posted on

LifeOS: Giving AI Persistent Personal Context with Local Open-Source AI and MCP

Hacktoberfest Weekend Challenge: Build for a Friend Submission 🀝

This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend

What I Built

Most AI coding assistants suffer from severe amnesia. Every time you open a new conversation, context resets completely. You spend the first ten minutes re-explaining your tech stack, your active projects, your career goals, and how you want the AI to talk to you. Worse, when you hit burnout or feel stuck, commercial closed chatbots resort to generic, hollow reassurance: "You're doing great! Keep going!"

I built LifeOS for a close friend and fellow developer who was tired of repeating themselves across coding sessions and wanted an assistant grounded in their actual goals and ground-truth progress.

LifeOS is not another chatbot. It is a local-first personal context and memory layer built on top of the open Model Context Protocol (MCP). It indexes a local vault of plain Markdown files into a local PostgreSQL + pgvector instance using local ONNX embeddings, allowing any MCP-compatible agent (like Antigravity or local open-weight models) to retrieve personal context with strict provenance.

Key features include:

  • The Interaction Policy: Reads an explicit how_i_want_ai_to_treat_me.md user document that instructs the AI to separate emotion from evidence, challenge weak plans, and avoid empty reassurance.
  • Inspectable Provenance: Every retrieved memory returns exact source paths and headings (e.g., [Source: projects/chronolog.md | Heading: Architecture]).
  • Quarantined Memory Writes: Prevents agents from silently hallucinating or overwriting canonical user filesβ€”all agent-authored memories are strictly isolated to vault/memory/ with timestamps and metadata.

Demo

Here is an example interaction showing how LifeOS changes agent behavior:

User: "I feel like I'm wasting my time and making zero progress on my projects."

Standard Chatbot: "Don't be hard on yourself! Coding is tough, you're doing amazing!"

Antigravity with LifeOS:

  1. Agent calls lifeos_get_instructions() and lifeos_get_context().
  2. It identifies the user's explicit rule: Do not give empty reassurance; distinguish feelings from evidence; verify recent project milestones.
  3. Agent calls lifeos_search("recent progress Chronolog PhysioEvidence").
  4. Response: > "Let's separate how you feel right now from what the evidence says. According to projects/chronolog.md, you finalized the backend architecture this week. In learning/ai.md, you completed your embeddings implementation. What specifically stalled todayβ€”was it the auth bug in Chronolog, or are you feeling overwhelmed by context switching? Here is the smallest next action to take..."
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ LIFEOS ARCHITECTURE                          β”‚
β”‚                                              β”‚
β”‚  Markdown Vault (Canonical Truth)            β”‚
β”‚       β”‚                                      β”‚
β”‚       β–Ό                                      β”‚
β”‚  FastEmbed (BAAI/bge-small-en-v1.5)          β”‚
β”‚       β”‚                                      β”‚
β”‚       β–Ό                                      β”‚
β”‚  PostgreSQL + pgvector (Derived Search)      β”‚
β”‚       β”‚                                      β”‚
β”‚       β–Ό                                      β”‚
β”‚  LifeOS MCP Server (stdio protocol purity)   β”‚
β”‚       β”‚                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚
β”‚  β–Ό                                β–Ό          β”‚
β”‚ Antigravity Agent            Local Ollama    β”‚
β”‚ (Cloud Reasoning)          (Gemma 2 / Qwen)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Enter fullscreen mode Exit fullscreen mode

Code

LifeOS β€” Local-First Personal Context Layer for AI Agents

AI agents are powerful, but they have amnesia.
Every new conversation starts with zero knowledge of the person they are helping. Users are forced to re-explain their background, their goals, their active projects, and how they want to be spoken to.
LifeOS solves this by providing a local-first personal context and memory layer that gives AI agents access to the user's canonical knowledge through the Model Context Protocol (MCP).

    +-------------------------------------------------------------+
    |                      AI Reasoning Layer                     |
    |       Google Antigravity Agent  OR  Local Open LLM (Ollama) |
    +-------------------------------------------------------------+
                                   β–²
                          JSON-RPC β”‚ over stdio
                                   β–Ό
    +-------------------------------------------------------------+
    |                      LifeOS MCP Server                      |
    |  - lifeos_get_context()         - lifeos_search()           |
    |  - lifeos_read_file()           - lifeos_get_instructions() |
    |  - lifeos_list_topics()         - lifeos_add_memory()       |
    +-------------------------------------------------------------+
            β”‚                                             β”‚
      Path Validation                               Vector Search
            β–Ό                                             β–Ό
+───────────────────────────+                 +───────────────────────────+
β”‚   Canonical Truth Store   β”‚                 β”‚   Derived Vector Index    β”‚
β”‚   Plain Markdown
…

The repository includes:

  • Complete Python implementation (lifeos/) with strict stdio protocol cleanliness.
  • Fully automated tests (24 passed unit and security tests covering path traversal and memory write isolation).
  • Committed synthetic public sample vault (examples/sample_vault/) with 17 realistic documents so anyone can clone and test it immediately.
  • Antigravity integration configurations (examples/antigravity/mcp_config.json) supporting workspace and global agent setups.
  • Docker Compose configuration for local PostgreSQL + pgvector.

How I Built It

LifeOS is engineered from the ground up around open-source AI and open standards:

  • Local Embedding Engine: FastEmbed running BAAI/bge-small-en-v1.5 locally via ONNX Runtime, generating 384-dimensional dense vectors with zero cloud API dependencies.
  • Vector Indexing: PostgreSQL with the pgvector extension running locally via Docker, using HNSW index lookups for fast cosine similarity search.
  • MCP Protocol Interface: An stdio-based server using the official Python MCP SDK exposing 6 core tools: lifeos_get_context, lifeos_search, lifeos_read_file, lifeos_get_instructions, lifeos_list_topics, and lifeos_add_memory.
  • Optional Local Open-Weight Reasoning: A modular fallback to Ollama running Google's Gemma 2 (gemma2:2b / gemma2:9b), enabling complete offline execution without sending tokens to any cloud API.
  • Real-time Synchronization: Built-in watchdog file observer that monitors vault edits and updates database hashes idempotently.

Why Does Open Innovation Matter?

Open innovation is not just a feature of LifeOS; it is the entire reason the project works:

  • Absolute Privacy for Vulnerable Personal Data: A personal context layer holds journal entries, mental burnout patterns, unfinished project drafts, and career ambitions. Trusting proprietary vector databases and third-party cloud LLM APIs with unencrypted personal journals is unacceptable. Open-weight models and local embeddings guarantee that sensitive user context never leaves local disk.
  • Canonical Truth Inversion (Zero Vendor Lock-in): In closed platforms, your memory is trapped inside a vendor's black-box database. In LifeOS, plain Markdown files on disk are the canonical source of truth. The database is merely a disposable index. If the database is deleted or an embedding model is upgraded, the entire vector store can be regenerated from scratch with python scripts/index.py --rebuild.
  • Model Independence: The user owns their memory layer. Whether Antigravity is using an advanced coding model, or you are running an open-weight Gemma 2 model offline on an RTX GPU on a train with zero Wi-Fi, the user's context remains identical and portable.

Prize Categories

  • Best Use of Gemma ($200 USD): LifeOS provides a dedicated local reasoning path powered by Ollama running Google's open-weight Gemma models (gemma2:2b / gemma2:9b), allowing the entire context-and-reasoning loop to run 100% offline.
  • Best Use of Tiger Data ($100 USD): LifeOS uses PostgreSQL and pgvector with HNSW vector indexing to store high-dimensional embeddings and execute similarity searches over local vault chunks.

Top comments (0)