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, answers "what was I working on?", and remembers patterns across every project you've ever touched. 100% local. No cloud. No subscriptions.

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


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?"

But it gets worse. Three weeks later in a different project:

"I've solved this exact auth bug before. Where was it? Which repo?"

GitHub Copilot can't help. ChatGPT doesn't know your codebase. And git log --all across 12 repos is not a vibe.

DeepSleep fixes both. It watches your files, dreams while you're idle, and builds a neural link across every project on your machine. Your AI knows what you were doing and what you've done before โ€” everywhere.

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


Evolution โ€” What Each Version Does

timeline
    title DeepSleep โ€” From Tool to Oracle
    section v0.1.0 ยท April 2026
        Project Memory : ds init ยท ds dream ยท ds chat
                       : 3-layer local memory per project
                       : Ollama deepseek-r1 integration
                       : Offline fallback ยท AES-256 encryption
    section v0.2.0 ยท April 2026
        MCP Server : deepsleep-mcp for Cursor ยท Claude Desktop ยท Windsurf
                   : 9 MCP tools ยท 8KB memory ยท 5-file context
                   : Windows path fix ยท Ollama UX improvements
    section v0.2.1 ยท April 2026
        Neural Link : Cross-project memory across entire machine
                    : ds link ยท ds search ยท ds neural
                    : SQLite FTS5 full-text search
                    : 5 new MCP tools ยท personal coding oracle

v0.1 โ€” Project Memory

"What was I working on in this project?"

flowchart TD
    A([๐Ÿง‘โ€๐Ÿ’ป You start coding]) --> B[ds init\nCreates .deepsleep/memory.json]
    B --> C[ds dream\nBackground watcher starts]
    C --> D{Watching for changes...}
    D -->|Files saved| E[๐Ÿ“ Track in SQLite index]
    D -->|5 min idle| F[๐Ÿ’ค Dream Cycle]
    E --> D
    F --> G[Read up to 5 files ยท 4000 chars]
    G --> H[๐Ÿค– Ollama deepseek-r1]
    H --> I[โœ๏ธ Generate session summary]
    I --> J[๐Ÿง  Write to memory.json ยท 8KB]
    J --> K[ds > What was I doing?]
    K --> L[๐Ÿ’ก Instant local answer]

    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 L fill:#14532d,color:#fff,stroke:#22c55e

3-layer memory stack โ€” everything in one 8KB file:

block-beta
  columns 3
  space:1
  title["๐Ÿง  .deepsleep/memory.json ยท โ‰ค 8KB"]:1
  space:1

  project["๐Ÿ“Œ PROJECT LAYER\nโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\nRepo identity ยท Goals\nKey facts & decisions\nUp to 10 facts\n\n(Permanent)"]
  session["๐Ÿ• SESSION LAYER\nโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\nUp to 15 recent files\nDream summary ยท 1200 chars\nRecent tasks ยท 10 items\n\n(Updated each dream)"]
  ephemeral["โšก EPHEMERAL LAYER\nโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\nLast Q&A pair\nOpen questions ยท 8 items\n15 file change events\n\n(Per session)"]

  compact["๐Ÿ—œ๏ธ Smart Compactor โ€” priority squeeze ยท drops low-signal first ยท preserves what matters ยท always under 8KB"]: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

v0.2 โ€” MCP Server

"Open Cursor. Your AI already knows what you were doing."

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

    subgraph MCP["๐Ÿ”Œ MCP ยท stdio"]
        server["deepsleep-mcp"]
    end

    subgraph Local["๐Ÿง  Local Memory"]
        mem["memory.json\n8KB"]
        log["activity.jsonl"]
        idx["index.db\nSQLite"]
    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 Local fill:#14532d,color:#86efac,stroke:#22c55e

One JSON config block in your IDE. Then your AI says:

"You were debugging the JWT middleware 3 hours ago. auth.ts and middleware.py were open. You were stuck on token validation."


v0.2.1 โ€” Neural Link

"You solved this exact bug in backend-api two weeks ago. Want me to show you that snippet?"

flowchart TD
    subgraph Machine["๐Ÿ–ฅ๏ธ Your Machine"]
        subgraph proj1["๐Ÿ“ backend-api"]
            m1["memory.json"]
        end
        subgraph proj2["๐Ÿ“ frontend-app"]
            m2["memory.json"]
        end
        subgraph proj3["๐Ÿ“ auth-service"]
            m3["memory.json"]
        end
        subgraph proj4["๐Ÿ“ mobile-app"]
            m4["memory.json"]
        end
    end

    subgraph NL["๐Ÿ”— Neural Link ยท ~/.deepsleep/neural_link.db"]
        fts["SQLite FTS5\nFull-text search"]
        patterns["Pattern Index\nauth ยท bugfix ยท api\ndatabase ยท refactor\nperformance ยท test"]
        snapshots["Session Snapshots\nTimestamped history\nAll projects ยท All time"]
    end

    m1 -->|ds link| fts
    m2 -->|ds link| fts
    m3 -->|ds link| fts
    m4 -->|ds link| fts

    fts --> patterns
    fts --> snapshots

    patterns -->|ds search 'jwt auth'| Q["๐Ÿ’ก 'You fixed this in\nbackend-api ยท 2 weeks ago'"]
    patterns -->|MCP cross_project_search| IDE["๐Ÿ–ฅ๏ธ Cursor / Claude / Windsurf\nauto-surfaces relevant patterns"]

    style NL fill:#1e1b4b,color:#c4b5fd,stroke:#7c3aed
    style Machine fill:#1a1a2e,color:#94a3b8,stroke:#475569
    style Q fill:#14532d,color:#86efac,stroke:#22c55e
    style IDE fill:#1e3a5f,color:#93c5fd,stroke:#3b82f6

Pattern types DeepSleep recognises automatically:

mindmap
  root((๐Ÿง  Neural Link))
    ๐Ÿ” auth
      JWT tokens
      OAuth flows
      Middleware
      Session handling
    ๐Ÿ› bugfix
      Crashes ยท Nulls
      Exceptions
      Wrong behaviour
    ๐ŸŒ api
      REST endpoints
      Webhooks
      HTTP handlers
    ๐Ÿ—„๏ธ database
      Migrations
      Schema changes
      Query fixes
    โ™ป๏ธ refactor
      Cleanup
      Restructuring
      Renaming
    โšก performance
      Caching
      Bottlenecks
      Optimisation
    ๐Ÿงช test
      Unit ยท Integration
      Mocks ยท Coverage

Security Architecture

flowchart LR
    subgraph SANDBOX["๐Ÿ›ก๏ธ Path Traversal Sandbox"]
        root["๐Ÿ“ Project Root\n(allowed zone)"]
        b1["๐Ÿšซ ~/.ssh"]
        b2["๐Ÿšซ .env / secrets"]
        b3["๐Ÿšซ ../outside"]
    end
    subgraph MEMORY["๐Ÿ” Memory Protection"]
        lock["๐Ÿ”’ FileLock\nAtomic writes"]
        enc["๐Ÿ›ก๏ธ AES-256 GCM\n--encrypt flag"]
    end
    subgraph INDEX["โšก Indexing"]
        sqlite["๐Ÿ“Š SQLite FTS5\nfull-text search"]
        gitignore["๐Ÿ“‚ .gitignore aware\nskips noise"]
    end
    DS["๐Ÿง  DeepSleep"] --> SANDBOX
    DS --> MEMORY
    DS --> INDEX
    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 INDEX fill:#1a1a1a,color:#93c5fd,stroke:#3b82f6

Why Local-First?

graph LR
    A["โ˜๏ธ Cloud Copilots"] -->|"๐Ÿ’ธ $10โ€“20/mo\n๐ŸŒ Code sent to servers\n๐Ÿ“ต Breaks offline\n๐Ÿ”‘ API key juggling\nโ„๏ธ Cold start every session\n๐Ÿ™ˆ No cross-project memory"| X["โŒ"]
    B["๐Ÿง  DeepSleep"] -->|"โœ… $0 forever\nโœ… Code never leaves machine\nโœ… Full offline fallback\nโœ… pip install ยท done\nโœ… Persistent session memory\nโœ… Neural link across all projects"| Y["โœ…"]

    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

Quickstart

Step 1 โ€” Install Ollama (one-time, optional but recommended)

# macOS
brew install ollama

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

# Windows โ€” download from https://ollama.com/download/windows
ollama serve
ollama pull deepseek-r1

No Ollama? DeepSleep still works โ€” it falls back to its local memory snapshot. Ollama just makes answers smarter.

Step 2 โ€” Install DeepSleep

# Core CLI
pip install deepsleep-ai

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

Step 3 โ€” Initialize your project

cd your-project/
ds init

# With AES-256 encrypted memory
ds init --encrypt

Step 4 โ€” Start watching

ds dream
# DeepSleep is running. Go code. It's watching.

Step 5 โ€” Ask it anything

ds
> What was I working on?
> What files did I touch today?
> What's the next step?
> Summarize my session

One-liner:

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

Neural Link โ€” Full Setup Guide

What is the Neural Link?

The Neural Link indexes session memory from every DeepSleep-enabled project on your machine into a single SQLite FTS5 database at ~/.deepsleep/neural_link.db. It powers cross-project search and pattern recognition.

sequenceDiagram
    participant Dev as ๐Ÿ‘จโ€๐Ÿ’ป You
    participant DS as ๐Ÿง  DeepSleep
    participant NL as ๐Ÿ”— Neural Link DB
    participant IDE as ๐Ÿ–ฅ๏ธ Cursor / Windsurf

    Dev->>DS: ds link (in each project)
    DS->>NL: sync patterns + snapshots
    Dev->>DS: ds search "jwt token"
    DS->>NL: FTS5 full-text search
    NL-->>DS: matches from backend-api (2 weeks ago)
    DS-->>Dev: "You fixed this in backend-api ยท here's the pattern"
    IDE->>DS: cross_project_search("jwt") via MCP
    DS->>NL: search exclude current project
    NL-->>IDE: relevant patterns injected into AI context

Step 1 โ€” Link your projects

Run this once in each project you want indexed:

cd ~/projects/backend-api && ds link
cd ~/projects/frontend-app && ds link
cd ~/projects/auth-service && ds link

Step 2 โ€” Search across everything

# Natural language search across all projects
ds search "jwt token validation"
ds search "database migration rollback"
ds search "react component state bug"

# Filter by pattern type
ds search "auth" --type auth
ds search "crash on deploy" --type bugfix

# See global context
ds neural
ds neural --query "oauth middleware"

Step 3 โ€” Keep it updated

# Re-sync after a big session (runs automatically with ds dream too)
ds link --sync

# Remove a project from the index
ds unlink

MCP Server โ€” Full Setup Guide

Install

pip install 'deepsleep-ai[mcp]'

Configure Claude Desktop

~/.claude/config.json:

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

Configure Cursor

.cursor/mcp.json in your project:

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

Configure Windsurf

~/.codeium/windsurf/mcp_config.json:

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

Start manually

ds mcp /path/to/your/project
# or
deepsleep-mcp --path /path/to/your/project

All MCP Tools

Project memory (v0.2.0+)

Tool What it returns
get_context Full 3-layer memory โ€” call this first
get_session_summary Latest dream summary + timestamp
get_recent_files Recently modified files
get_status Project status dict
get_activity_log Filtered activity entries
get_open_questions Unresolved questions
get_project_facts Long-term summary, goals, facts
record_file_opened Tell DeepSleep a file was opened
add_project_note Save a note to long-term memory

Neural Link (v0.2.1+)

Tool What it returns
cross_project_search FTS search across all linked projects
get_neural_context Full cross-project context string
get_similar_patterns Recent patterns of a given type from other projects
get_neural_link_stats Index stats โ€” projects, snapshots, patterns
sync_to_neural_link Push current session into global index

Commands Reference

Command What it does
ds init Initialize project memory
ds init --encrypt AES-256 encrypted memory
ds Interactive chat
ds chat Alias for ds
ds dream Start background file watcher
ds dream --once One dream cycle and exit
ds status Inspect memory snapshot
ds export Markdown standup report
ds export --format json JSON export
ds forget --layer session Wipe session layer
ds forget --all Full reset (with confirmation)
ds doctor Quick health check
ds health Detailed JSON health report
ds mcp [path] Start MCP server
deepsleep-mcp --path /p Standalone MCP entry point
ds link Register + sync project into Neural Link
ds link --no-sync Register without syncing
ds unlink Remove project from Neural Link
ds search "query" Cross-project FTS search
ds search "q" --type auth Filtered pattern search
ds neural Show global Neural Link context
ds neural --query "q" Filtered cross-project context

Feature Overview

Feature v0.1 v0.2 v0.2.1
Per-project memory โœ… โœ… โœ…
Idle-time dreaming โœ… โœ… โœ…
Ollama / offline fallback โœ… โœ… โœ…
AES-256 encryption โœ… โœ… โœ…
8KB memory budget โœ… โœ…
5-file / 4000-char context โœ… โœ…
MCP server โœ… โœ…
Cursor / Windsurf / Claude support โœ… โœ…
Windows path normalization โœ… โœ…
Neural Link cross-project index โœ…
FTS5 full-text search โœ…
Pattern classification โœ…
Neural Link MCP tools โœ…

Troubleshooting

Ollama issues

Problem Fix
Ollama is not running Run ollama serve in a terminal 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 / garbage answers Try a lighter model: ds --model phi3
Slow on first call Normal โ€” model is loading. Subsequent calls are fast.
ds doctor           # quick check
ds health --format json   # full JSON report

Memory issues

Problem Fix
Memory is busy Another ds process is running โ€” wait 3s and retry
Invalid password Wrong password for encrypted memory โ€” no recovery without it
Stale / wrong answers Run ds dream --once to force a fresh summary
Memory looks empty Run ds status to confirm memory path is correct
ds            # then type /memory to inspect
ds forget --layer session     # wipe session layer only
ds forget --all               # nuclear option

MCP issues

Problem Fix
command not found: deepsleep-mcp pip install 'deepsleep-ai[mcp]'
mcp package missing pip install mcp
IDE doesn't pick up context --path must be the exact absolute project root
MCP server crashes Run deepsleep-mcp --path /your/project in terminal to see error
Context is empty Run ds dream --once to populate memory first
# Verify before wiring to IDE
deepsleep-mcp --path /path/to/project
# Should print "DeepSleep MCP server starting..." then block โ€” that's correct

Neural Link issues

Problem Fix
No cross-project matches Run ds link in other projects first
Search finds nothing Memory may be empty โ€” run ds dream --once then ds link --sync
Want to remove a project ds unlink from that project's directory
Index seems stale ds link --sync to push fresh memory
ds neural           # show all linked projects and their last summaries
ds search "test"    # verify search is working

Windows issues

Problem Fix
Watcher misses changes Set WATCHDOG_OBSERVER_IMPL=polling env var
Permission denied on .deepsleep/ Run terminal as Administrator once to create the folder
Paths look wrong v0.2.0+ normalises all paths to forward slashes automatically

Package Layout

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

tests/                 # 51 tests ยท all passing
โ”œโ”€โ”€ test_neural_link.py       # 24 tests for Neural Link
โ”œโ”€โ”€ test_memory_manager.py
โ”œโ”€โ”€ test_cli.py
โ”œโ”€โ”€ test_concurrency.py
โ”œโ”€โ”€ test_doctor.py
โ”œโ”€โ”€ test_encryption.py
โ”œโ”€โ”€ test_export.py
โ”œโ”€โ”€ test_forget.py
โ”œโ”€โ”€ test_llm_client.py
โ”œโ”€โ”€ test_security.py
โ””โ”€โ”€ test_watcher.py

Contributing

  1. Check ROADMAP.md for what's next
  2. Read CONTRIBUTING.md for setup
  3. Open an issue or PR โ€” reviewed fast
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 ยท Neural Link
DeepSleep-Hub Browser extension ยท ChatGPT, Claude & Gemini neural bridge

Trust Signals

  • Live on PyPI: pip install deepsleep-ai
  • MIT licensed โ€” use it anywhere
  • GitHub Actions CI โ€” 51 tests across Python 3.9 / 3.10 / 3.11 / 3.12
  • Atomic memory writes โ€” zero corruption risk
  • No telemetry ยท no analytics ยท no network calls except your local Ollama
  • ds + deepsleep-mcp entry points work immediately after install

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

Built for developers who 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.1.tar.gz (49.8 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.1-py3-none-any.whl (39.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: deepsleep_ai-0.2.1.tar.gz
  • Upload date:
  • Size: 49.8 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.1.tar.gz
Algorithm Hash digest
SHA256 7dd94a6b7706ecb77f1c993060a3c83c38c824677d87d8dcc74406c7dfc4e018
MD5 3b166b1bec491e394fac2b51352c874f
BLAKE2b-256 7701584ef96e44d649538a2d14ffddec47350515aca01bde68d783f862290a53

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepsleep_ai-0.2.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: deepsleep_ai-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 39.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6ce9a662cdd1b5ba630e1c32e5a8470f538ca50ff348f82d53b0e10dc5d85bc5
MD5 5048a6aaac39b411278d3a5b359b5a0d
BLAKE2b-256 b26856f76a291b00b7a73a4b830f43b947416e9d96ce5b0addaa088f8ed6215c

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepsleep_ai-0.2.1-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