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.
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.tsandmiddleware.pyopen. 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
- Check ROADMAP.md for what's being built
- Read CONTRIBUTING.md for setup
- 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-mcpconsole 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d65c237ede22677198bd6f6cd539fae7160c782312f4f48b045d55f29349809
|
|
| MD5 |
b61f7fe17200f8306ff3f60db5575a4d
|
|
| BLAKE2b-256 |
f1617edbbe8b3bd624b91519a51a5bf42083854706167d28a0b11df9962a14dd
|
Provenance
The following attestation bundles were made for deepsleep_ai-0.2.0.tar.gz:
Publisher:
publish.yml on Keshavsharma-code/DeepSleep-beta
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deepsleep_ai-0.2.0.tar.gz -
Subject digest:
8d65c237ede22677198bd6f6cd539fae7160c782312f4f48b045d55f29349809 - Sigstore transparency entry: 1336974997
- Sigstore integration time:
-
Permalink:
Keshavsharma-code/DeepSleep-beta@de0c89b41f99fc9c2399bf142d4a2215c052ebf5 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Keshavsharma-code
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@de0c89b41f99fc9c2399bf142d4a2215c052ebf5 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
129e286bd17a49e4e38a4f7a11819ae908773db2d4519f06ea751dc8cfed578f
|
|
| MD5 |
53c7ceb6f728d27ec5a8440abb2d0fa3
|
|
| BLAKE2b-256 |
f59de48b50b109d5f53b39be32f5997fc783cd444acec1a11949295aa5097e15
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deepsleep_ai-0.2.0-py3-none-any.whl -
Subject digest:
129e286bd17a49e4e38a4f7a11819ae908773db2d4519f06ea751dc8cfed578f - Sigstore transparency entry: 1336975266
- Sigstore integration time:
-
Permalink:
Keshavsharma-code/DeepSleep-beta@de0c89b41f99fc9c2399bf142d4a2215c052ebf5 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Keshavsharma-code
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@de0c89b41f99fc9c2399bf142d4a2215c052ebf5 -
Trigger Event:
release
-
Statement type: