Skip to main content

Zero-cost background coding agent with layered memory, idle-time dreaming, MCP server, and Ollama support.

Project description

๐Ÿง  DeepSleep

Your codebase has a memory now.

A zero-cost background agent that watches your files, dreams while you're away, and answers "what was I working on?" โ€” 100% local, no cloud, no subscriptions.

PyPI version Python versions CI License: MIT PyPI Downloads GitHub Stars MCP


DeepSleep - The coding agent that dreams while you sleep | Product Hunt



DeepSleep social preview


The Problem

You take a coffee break. You come back. You stare at the screen.

"Wait... what was I doing?"

GitHub Copilot can't help you. ChatGPT doesn't know your codebase. Cursor has no idea what you were thinking. And scrolling through git log at 9am is not a vibe.

DeepSleep fixes this. It runs silently in the background, watches your files, and the moment you go idle โ€” it dreams. It reads what changed, writes a compact session summary, and stores it locally. When you're back, just ask:

ds > What was I working on?

And with v0.2.0, your Cursor / Claude Desktop / Windsurf AI already knows โ€” before you even open the terminal.

No cloud. No tokens burned. No subscription. Just memory.


How It Works

flowchart TD
    A([๐Ÿง‘โ€๐Ÿ’ป You start coding]) --> B[ds init\nCreates .deepsleep/memory.json]
    B --> C[ds dream\nBackground watcher starts]
    C --> D{Watching for\nfile changes...}
    D -->|Files saved| E[๐Ÿ“ Track changed files\nSQLite incremental index]
    D -->|5 min idle| F[๐Ÿ’ค Dream Cycle Triggered]
    E --> D
    F --> G[Read file snippets\nup to 5 files ยท 4000 chars each]
    G --> H[๐Ÿค– Send to local Ollama\ndeepseek-r1 by default]
    H --> I[โœ๏ธ Generate session summary]
    I --> J[๐Ÿง  Write to memory.json\nunder 8KB ยท atomic write]
    J --> K{You return\nto keyboard}
    K --> L[ds > What was I doing?]
    K --> M[Cursor / Claude / Windsurf\nMCP auto-context]
    L --> N[๐Ÿ’ก Instant answer from local memory]
    M --> N

    style A fill:#1a1a2e,color:#fff,stroke:#7c3aed
    style F fill:#312e81,color:#fff,stroke:#7c3aed
    style H fill:#1e3a5f,color:#fff,stroke:#3b82f6
    style J fill:#4a1942,color:#fff,stroke:#a855f7
    style N fill:#14532d,color:#fff,stroke:#22c55e
    style M fill:#1e3a5f,color:#fff,stroke:#3b82f6

v0.2.0 โ€” MCP Server

The biggest DeepSleep release yet.

DeepSleep now ships an official Model Context Protocol (MCP) server. Any MCP-compatible AI IDE can query your session memory natively โ€” no copy-pasting, no manual context loading.

flowchart LR
    subgraph IDEs["๐Ÿ–ฅ๏ธ Your AI IDE"]
        cursor["โšก Cursor"]
        claude["๐Ÿค– Claude Desktop"]
        wind["๐ŸŒŠ Windsurf"]
        vscode["๐Ÿ’ป VS Code + Copilot"]
    end

    subgraph MCP["๐Ÿ”Œ MCP Protocol (stdio)"]
        server["deepsleep-mcp\nserver"]
    end

    subgraph Memory["๐Ÿง  DeepSleep Memory"]
        mem["memory.json\n8KB local file"]
        log["activity.jsonl\naudit log"]
        idx["index.db\nSQLite file index"]
    end

    cursor -->|"get_context()"| server
    claude -->|"get_session_summary()"| server
    wind -->|"get_recent_files()"| server
    vscode -->|"add_project_note()"| server

    server --> mem
    server --> log
    server --> idx

    style IDEs fill:#1a1a2e,color:#c4b5fd,stroke:#7c3aed
    style MCP fill:#1e3a5f,color:#93c5fd,stroke:#3b82f6
    style Memory fill:#14532d,color:#86efac,stroke:#22c55e

Open Cursor after a break and your AI already knows:

"You were debugging the JWT middleware 3 hours ago. You had auth.ts and middleware.py open. You were stuck on token validation and left an open question about refresh token expiry."

Zero config. Zero copy-paste. Zero cloud.


Memory Architecture

DeepSleep uses a 3-layer memory stack โ€” all stored in a single .deepsleep/memory.json file kept under 8KB.

block-beta
  columns 3

  space:1
  title["๐Ÿง  .deepsleep/memory.json  โ‰ค 8KB"]:1
  space:1

  project["๐Ÿ“Œ PROJECT LAYER\nโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\nRepo identity\nLong-term goals\nKey facts & decisions\nUp to 10 facts ยท 800 chars\n\n(Permanent)"]
  session["๐Ÿ• SESSION LAYER\nโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\nRecent activity\nUp to 15 active files\nLatest dream summary\n1200 chars summary\n\n(Updated each dream)"]
  ephemeral["โšก EPHEMERAL LAYER\nโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\nCurrent chat turns\nUp to 8 open questions\nUp to 15 file changes\nLast Q&A pair\n\n(Cleared each session)"]

  compact["๐Ÿ—œ๏ธ Smart Compactor โ€” priority squeeze keeps total under 8KB ยท low-signal context dropped first ยท high-signal preserved"]:3

  style title fill:#1e1b4b,color:#c4b5fd,stroke:#7c3aed
  style project fill:#14532d,color:#86efac,stroke:#22c55e
  style session fill:#1e3a5f,color:#93c5fd,stroke:#3b82f6
  style ephemeral fill:#4a1942,color:#f0abfc,stroke:#a855f7
  style compact fill:#1a1a2e,color:#94a3b8,stroke:#475569

Security Architecture

flowchart LR
    subgraph SANDBOX["๐Ÿ›ก๏ธ Path Traversal Sandbox"]
        direction TB
        root["๐Ÿ“ Project Root\n(allowed zone)"]
        blocked1["๐Ÿšซ ~/.ssh"]
        blocked2["๐Ÿšซ .env / secrets"]
        blocked3["๐Ÿšซ ../outside/root"]
    end

    subgraph MEMORY["๐Ÿ” Memory Protection"]
        direction TB
        lock["๐Ÿ”’ FileLock\nAtomic writes only"]
        enc["๐Ÿ›ก๏ธ AES-256 GCM\nds init --encrypt"]
    end

    subgraph INDEXING["โšก Efficient Indexing"]
        direction TB
        sqlite["๐Ÿ“Š SQLite Index\nMillions of files ยท no slowdown"]
        gitignore["๐Ÿ“‚ .gitignore Aware\nSkips node_modules, dist, build"]
    end

    DS["๐Ÿง  DeepSleep Engine"] --> SANDBOX
    DS --> MEMORY
    DS --> INDEXING

    style DS fill:#1e1b4b,color:#c4b5fd,stroke:#7c3aed
    style SANDBOX fill:#1a1a1a,color:#fca5a5,stroke:#ef4444
    style MEMORY fill:#1a1a1a,color:#86efac,stroke:#22c55e
    style INDEXING fill:#1a1a1a,color:#93c5fd,stroke:#3b82f6

Quickstart

Step 1 โ€” Install Ollama (one-time)

# macOS
brew install ollama

# Linux
curl -fsSL https://ollama.com/install.sh | sh

# Windows
# Download from https://ollama.com/download/windows
# Start Ollama and pull the model
ollama serve
ollama pull deepseek-r1

Don't have Ollama? DeepSleep still works โ€” it falls back to its local memory snapshot and gives you deterministic answers. Ollama just makes them smarter.

Step 2 โ€” Install DeepSleep

# Terminal only (no MCP)
pip install deepsleep-ai

# With MCP server (for Cursor, Claude Desktop, Windsurf)
pip install 'deepsleep-ai[mcp]'

Step 3 โ€” Initialize your project

cd your-project/
ds init

# Optional: password-protected memory (AES-256)
ds init --encrypt

Step 4 โ€” Start the background watcher

ds dream
# DeepSleep is now watching. Go code. Come back. It remembered.

Step 5 โ€” Ask it anything

ds
> What was I working on?
> What files did I touch today?
> What's the next thing I should do?
> Summarize my last session
> What open questions do I have?

One-liner demo:

pip install deepsleep-ai && ollama pull deepseek-r1 && ds init && ds dream --once && ds

MCP Server โ€” Full Setup Guide

What is MCP?

Model Context Protocol is an open standard that lets AI IDEs (Cursor, Claude Desktop, Windsurf, VS Code Copilot) pull context from external tools. DeepSleep's MCP server makes your session memory available to any of these IDEs automatically.

sequenceDiagram
    participant IDE as ๐Ÿ–ฅ๏ธ Your IDE (Cursor/Windsurf/Claude)
    participant MCP as ๐Ÿ”Œ deepsleep-mcp
    participant MEM as ๐Ÿง  memory.json

    IDE->>MCP: "What was the dev working on?"
    MCP->>MEM: load() โ†’ read 3-layer memory
    MEM-->>MCP: session summary + recent files + open questions
    MCP-->>IDE: Full context string
    IDE->>IDE: Inject into AI system prompt
    Note over IDE: AI now knows your full session context

Install

pip install 'deepsleep-ai[mcp]'

Configure Claude Desktop

Edit ~/.claude/config.json (create it if it doesn't exist):

{
  "mcpServers": {
    "deepsleep": {
      "command": "deepsleep-mcp",
      "args": ["--path", "/absolute/path/to/your/project"]
    }
  }
}

Restart Claude Desktop. That's it. Your AI now has memory.

Configure Cursor

Create .cursor/mcp.json in your project root (or edit global Cursor settings):

{
  "mcpServers": {
    "deepsleep": {
      "command": "deepsleep-mcp",
      "args": ["--path", "/absolute/path/to/your/project"]
    }
  }
}

Or via Cursor Settings โ†’ MCP โ†’ Add Server.

Configure Windsurf

Edit ~/.codeium/windsurf/mcp_config.json:

{
  "mcpServers": {
    "deepsleep": {
      "command": "deepsleep-mcp",
      "args": ["--path", "/absolute/path/to/your/project"]
    }
  }
}

Manual / Terminal

# Start the server manually
ds mcp /path/to/your/project

# Or use the standalone entry point directly
deepsleep-mcp --path /path/to/your/project

Available MCP Tools

Tool Description
get_context Primary tool โ€” full 3-layer memory. Call this first.
get_session_summary Latest AI-generated dream summary + timestamp
get_recent_files List of recently modified/accessed files
get_status Project status dict (path, memory size, last dream, model)
get_activity_log Filtered activity entries (supports since, limit, event_type)
get_open_questions Unresolved questions from the current session
get_project_facts Long-term project summary, goals, facts
record_file_opened Tell DeepSleep a file was opened in the IDE
add_project_note Save a factual note to long-term memory

Commands Reference

Command What it does
ds init Initialize memory brain for your project
ds init --encrypt Same, with AES-256 GCM password protection
ds Open the interactive chat interface
ds chat Alias for ds
ds dream Start the background file watcher (runs forever)
ds dream --once Run one dream cycle immediately and exit
ds status Inspect current memory snapshot
ds export Export activity log as Markdown standup report
ds export --format json Export as JSON
ds forget --layer session Wipe the session layer
ds forget --all Full memory reset (with confirmation)
ds doctor Quick health check โ€” Ollama, disk, encryption
ds health Detailed system check with JSON output option
ds mcp [path] Start MCP server (for Cursor, Claude Desktop, Windsurf)
deepsleep-mcp --path /p Standalone MCP entry point for IDE config files

Why Local-First?

graph LR
    A["โ˜๏ธ Cloud Copilots\n(Copilot ยท ChatGPT ยท etc)"] -->|"๐Ÿ’ธ $10โ€“20/mo\n๐ŸŒ Your code sent to servers\n๐Ÿ“ต Breaks offline\n๐Ÿ”‘ API key juggling\nโณ Cold start every session"| X["โŒ Not your memory"]
    B["๐Ÿง  DeepSleep"] -->|"โœ… $0 forever\nโœ… Code never leaves machine\nโœ… Full offline fallback\nโœ… pip install ยท done\nโœ… Persistent session memory"| Y["โœ… Your memory"]

    style A fill:#3b0d0d,color:#fca5a5,stroke:#ef4444
    style B fill:#14532d,color:#86efac,stroke:#22c55e
    style X fill:#3b0d0d,color:#fca5a5,stroke:#ef4444
    style Y fill:#14532d,color:#86efac,stroke:#22c55e

Feature Overview

Feature Detail
๐Ÿ”Œ MCP Server Native integration with Cursor, Claude Desktop, Windsurf
๐Ÿง  8KB Memory 4ร— larger than v0.1 โ€” retains far more session context
๐Ÿ“‚ 5-file context Reads up to 5 files ยท 4,000 chars each per chat query
๐Ÿ’ค Idle Dreaming Auto-summarizes your session after 5 min idle
๐Ÿ”’ Atomic Writes FileLock + temp-then-rename โ€” zero memory corruption
๐Ÿ›ก๏ธ Path Sandbox Locked to project root โ€” .ssh, .env never touch the model
๐Ÿ—‚๏ธ Gitignore-Aware Skips node_modules, dist, build artifacts automatically
โšก SQLite Index Handles millions of files with no slowdown
๐Ÿ” AES-256 Encryption Optional password-protected memory at rest
๐Ÿ“ด Offline Fallback Works without Ollama โ€” answers from saved local memory
๐ŸชŸ Windows Support Forward-slash path normalization, thread-safe SQLite
๐Ÿ“Š Activity Log Immutable activity.jsonl audit trail across all sessions

Troubleshooting

Ollama issues

Error Fix
Ollama is not running Run ollama serve in a terminal tab and keep it open
model not found Run ollama pull deepseek-r1
Connection refused Check Ollama is on http://127.0.0.1:11434 โ€” run ds health
Empty response Try a smaller model: ds --model phi3
Slow answers Normal for first call โ€” model is loading. Subsequent calls are fast.
# Full Ollama setup check
ds doctor

# Detailed JSON health report
ds health --format json

Memory issues

Error Fix
Memory is busy Another ds process is running โ€” wait 3 seconds and retry
Invalid password Wrong password for encrypted memory โ€” there is no recovery without the password
Garbage answers Type /memory in chat to inspect memory; use ds forget to selectively clear
Memory looks stale Run ds dream --once to force a fresh summary
# Inspect what DeepSleep knows
ds
> /memory

# Selectively wipe stale data
ds forget --layer session
ds forget --layer ephemeral

# Nuclear option (with confirmation prompt)
ds forget --all

MCP issues

Error Fix
command not found: deepsleep-mcp Run pip install 'deepsleep-ai[mcp]'
mcp package not installed Run pip install mcp or pip install 'deepsleep-ai[mcp]'
IDE doesn't pick up context Make sure --path in config points to the exact project root
MCP server crashes on start Run deepsleep-mcp --path /your/project in terminal to see the error
Context is empty / outdated Run ds dream --once in your project to refresh the session summary
# Verify the MCP server works before wiring it to an IDE
deepsleep-mcp --path /path/to/your/project
# Should print: "DeepSleep MCP server starting for ..." and then block (that's correct)

Windows issues

Issue Fix
Watcher misses file changes Use watchdog polling backend: set WATCHDOG_OBSERVER_IMPL=polling
Permission denied on .deepsleep/ Run terminal as Administrator once to create the folder, then it works normally
Paths look wrong in memory Update to v0.2.0+ โ€” paths are now normalized to forward slashes

Package Layout

src/deepsleep_ai/
โ”œโ”€โ”€ cli.py             # Typer CLI + Prompt Toolkit interactive chat
โ”œโ”€โ”€ mcp_server.py      # MCP server โ€” Cursor, Claude Desktop, Windsurf
โ”œโ”€โ”€ watcher.py         # Watchdog idle watcher + dream loop + SQLite index
โ”œโ”€โ”€ memory_manager.py  # 3-layer memory ยท 8KB compactor ยท AES-256 encryption
โ”œโ”€โ”€ llm_client.py      # Ollama connector + deterministic offline fallback
โ””โ”€โ”€ config.py          # Pydantic-settings configuration

tests/
โ”œโ”€โ”€ test_cli.py
โ”œโ”€โ”€ test_concurrency.py
โ”œโ”€โ”€ test_doctor.py
โ”œโ”€โ”€ test_encryption.py
โ”œโ”€โ”€ test_export.py
โ”œโ”€โ”€ test_forget.py
โ”œโ”€โ”€ test_llm_client.py
โ”œโ”€โ”€ test_memory_manager.py
โ”œโ”€โ”€ test_security.py
โ””โ”€โ”€ test_watcher.py

Contributing

  1. Check ROADMAP.md for what's being built
  2. Read CONTRIBUTING.md for setup
  3. Open an issue or send a PR โ€” reviewed fast
# Local dev setup (includes MCP server)
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest -v

Ecosystem

Project What it is
DeepSleep-beta (you are here) Python CLI + MCP server ยท local coding memory
DeepSleep-Hub Browser extension ยท ChatGPT, Claude & Gemini neural bridge with 3D Visual Cortex

Trust Signals

  • Live on PyPI: pip install deepsleep-ai
  • MIT licensed โ€” use it in anything
  • GitHub Actions CI on every push
  • 10 test modules covering memory, encryption, concurrency, watcher, chat, doctor
  • Atomic memory writes โ€” zero corruption risk
  • ds + deepsleep-mcp console entry points โ€” work immediately after install
  • No telemetry. No analytics. No network calls except to your local Ollama.

If DeepSleep remembered something you forgot, give it a โญ

Built for developers who actually forget things โ€” which is all of us

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepsleep_ai-0.2.0.tar.gz (40.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepsleep_ai-0.2.0-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file deepsleep_ai-0.2.0.tar.gz.

File metadata

  • Download URL: deepsleep_ai-0.2.0.tar.gz
  • Upload date:
  • Size: 40.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for deepsleep_ai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8d65c237ede22677198bd6f6cd539fae7160c782312f4f48b045d55f29349809
MD5 b61f7fe17200f8306ff3f60db5575a4d
BLAKE2b-256 f1617edbbe8b3bd624b91519a51a5bf42083854706167d28a0b11df9962a14dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepsleep_ai-0.2.0.tar.gz:

Publisher: publish.yml on Keshavsharma-code/DeepSleep-beta

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepsleep_ai-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: deepsleep_ai-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 31.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for deepsleep_ai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 129e286bd17a49e4e38a4f7a11819ae908773db2d4519f06ea751dc8cfed578f
MD5 53c7ceb6f728d27ec5a8440abb2d0fa3
BLAKE2b-256 f59de48b50b109d5f53b39be32f5997fc783cd444acec1a11949295aa5097e15

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepsleep_ai-0.2.0-py3-none-any.whl:

Publisher: publish.yml on Keshavsharma-code/DeepSleep-beta

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page