DeepSleep is the open-source background agent for local models. It gives developers a ds workflow, a compact 3-layer memory file, and idle-time "dreaming" that summarizes recent work while they are away.
Imagine you're coding. You take a coffee break. You come back and forget what you were doing. DeepSleep was watching your files while you were gone. It "dreamed" about your changes and wrote a summary. Now you just ask ds > What was I working on? and it tells you. It's like a brain for your folder.
- Init: Open your terminal in your project folder and type
ds init. This makes a tiny hidden brain folder (.deepsleep). - Dream: Run
ds dreamin a corner of your screen. It just sits there. When you stop typing for a bit, it writes down what you did. - Chat: Type
dswhenever you want to talk to your code. Ask things like "Where did I leave that API key?" or "What's next?"
- "Ollama not found": You need Ollama running. It's the engine. Download it, run it, and try again.
- "Permission Denied": DeepSleep needs to write its memory file. Make sure you have permission to write in the current folder.
- "Stuck dreaming": If
ds dreamisn't doing anything, make sure you actually saved some files. It only dreams when things change! - "Garbage answers": Local models can be silly. Type
/memoryto see what it actually remembers. If it's wrong, you can just tell it!
We've hardened DeepSleep for enterprise-level monorepos:
- π Atomic Security:
FileLockprevents memory corruption even if you run multipledsinstances. - π‘οΈ Path Traversal Sandbox: DeepSleep is now locked to your project root. It will never leak your
.sshor.envfiles to the AI. - π Gitignore-Aware: It respects your
.gitignoreperfectly. No more indexingnode_modulesordistgarbage. - β‘ Incremental Indexing: Uses a local SQLite index to track millions of files instantly without slowing down your machine.
- π At-Rest Encryption: Use
ds init --encryptto protect your project memory with a password (AES-256). - π Structured Observability: Now with
structlogfor clean, machine-friendly logs and ads healthcommand.
pip install deepsleep-aids initdsds dream
That is the product.
You initialize a repo once, ask natural questions in the terminal, and let DeepSleep update session context after you stop typing.
Zero-cost agent: runs on local Ollama models instead of paid tokensIdle-time dreaming: watches your repo and summarizes after inactivity3-layer memory:project,session, andephemeralTerminal-native: hacker-style interactive UI with file completion
DeepSleep is best described as:
- an open-source AI coding agent
- a local AI developer tool
- a background agent for codebases
- a terminal copilot for Ollama
- a local-model alternative to hosted coding assistants
pip install deepsleep-ai
ollama pull deepseek-r1
ds init
ds dream --once
dsThen ask:
What was I doing?
Refactor src/deepsleep_ai/cli.py
Summarize the recent changes
DeepSleep explicitly implements a 3-layer memory stack:
project: long-term repo identity, goals, and factssession: what you were doing recently, which files were active, and the latest dream summaryephemeral: last turns, open questions, and the most recent file changes
All of it lives in .deepsleep/memory.json, and the compactor keeps that file under 2KB so it stays fast, deterministic, and portable.
DeepSleep is built for Ollama and targets deepseek-r1 by default.
If Ollama is offline, DeepSleep still works with deterministic local fallbacks so demos do not collapse and the tool remains usable on day one.
Run ds dream, leave your editor open, and DeepSleep watches your project for file saves.
After 5 minutes of inactivity, it:
- collects the files you touched
- reads compact local snippets
- writes a fresh session summary into memory
- preserves only the highest-signal context under the 2KB cap
pip install deepsleep-aiQuick check:
ds --version
ds healthpython3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"ollama serve
ollama pull deepseek-r1ds init # Start a new brain for your project
ds init --encrypt # Start a password-protected brain
ds # Start chatting
ds chat # Alias for ds
ds dream # Start the background watcher
ds dream --once # Run one dream cycle right now
ds status # Peek inside the brain
ds health # Check if everything is setup correctlycli.py: Typer entrypoint and Prompt Toolkit UIwatcher.py: Watchdog-based idle watcher and dream loopmemory_manager.py: layered memory store with 2KB compactionllm_client.py: Ollama connector with safe local fallbackconfig.py: Pydantic-powered configuration management
We love builders! If you want to make DeepSleep even better:
- Check the Roadmap: See what we're building in ROADMAP.md.
- Read the Guide: Hop into CONTRIBUTING.md for setup steps.
- Open an Issue: Found a bug? Tell us!
- Pull Requests: Send your code. We're fast at reviewing.
Note: Please ensure all tests pass (pytest) before submitting!
- publishable
pyproject.tomlforpip install deepsleep-ai dsconsole entrypoint- MIT license
- GitHub Actions CI
- tests for memory compaction, watcher behavior, offline fallback, and chat exit flow
- live PyPI package: deepsleep-ai
pytest -v
python -m deepsleep_ai --help
python -m build --no-isolationThere is a practical launch playbook in LAUNCH.md, a contributor guide in CONTRIBUTING.md, release instructions in RELEASING.md, and a project history in CHANGELOG.md.