contextos-dd 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. contextos_dd-0.1.0/.github/workflows/ci.yml +24 -0
  2. contextos_dd-0.1.0/.github/workflows/release.yml +34 -0
  3. contextos_dd-0.1.0/.gitignore +22 -0
  4. contextos_dd-0.1.0/INSTALL.md +233 -0
  5. contextos_dd-0.1.0/LICENSE +19 -0
  6. contextos_dd-0.1.0/PKG-INFO +160 -0
  7. contextos_dd-0.1.0/README.md +115 -0
  8. contextos_dd-0.1.0/contextos/__init__.py +1 -0
  9. contextos_dd-0.1.0/contextos/archive/__init__.py +3 -0
  10. contextos_dd-0.1.0/contextos/archive/store.py +82 -0
  11. contextos_dd-0.1.0/contextos/classifier/__init__.py +3 -0
  12. contextos_dd-0.1.0/contextos/classifier/rules.py +59 -0
  13. contextos_dd-0.1.0/contextos/cli.py +241 -0
  14. contextos_dd-0.1.0/contextos/compactor/__init__.py +3 -0
  15. contextos_dd-0.1.0/contextos/compactor/prompt.py +25 -0
  16. contextos_dd-0.1.0/contextos/compactor/service.py +124 -0
  17. contextos_dd-0.1.0/contextos/daemon.py +51 -0
  18. contextos_dd-0.1.0/contextos/dashboard/__init__.py +0 -0
  19. contextos_dd-0.1.0/contextos/dashboard/app.py +107 -0
  20. contextos_dd-0.1.0/contextos/dashboard/queries.py +121 -0
  21. contextos_dd-0.1.0/contextos/installer/__init__.py +4 -0
  22. contextos_dd-0.1.0/contextos/installer/detector.py +30 -0
  23. contextos_dd-0.1.0/contextos/installer/patcher.py +107 -0
  24. contextos_dd-0.1.0/contextos/ledger/__init__.py +3 -0
  25. contextos_dd-0.1.0/contextos/ledger/db.py +104 -0
  26. contextos_dd-0.1.0/contextos/ledger/schema.sql +43 -0
  27. contextos_dd-0.1.0/contextos/llm/__init__.py +12 -0
  28. contextos_dd-0.1.0/contextos/llm/download.py +25 -0
  29. contextos_dd-0.1.0/contextos/llm/embedder.py +65 -0
  30. contextos_dd-0.1.0/contextos/llm/generator.py +90 -0
  31. contextos_dd-0.1.0/contextos/llm/warmup.py +38 -0
  32. contextos_dd-0.1.0/contextos/pricing.py +30 -0
  33. contextos_dd-0.1.0/contextos/proxy/__init__.py +13 -0
  34. contextos_dd-0.1.0/contextos/proxy/app.py +270 -0
  35. contextos_dd-0.1.0/contextos/proxy/payload.py +36 -0
  36. contextos_dd-0.1.0/contextos/reconstructor/__init__.py +3 -0
  37. contextos_dd-0.1.0/contextos/reconstructor/rebuild.py +49 -0
  38. contextos_dd-0.1.0/contextos/retrieval/__init__.py +3 -0
  39. contextos_dd-0.1.0/contextos/retrieval/triggers.py +49 -0
  40. contextos_dd-0.1.0/contextos/session_memory.py +60 -0
  41. contextos_dd-0.1.0/contextos/settings.py +87 -0
  42. contextos_dd-0.1.0/contextos/tokens.py +38 -0
  43. contextos_dd-0.1.0/pyproject.toml +94 -0
  44. contextos_dd-0.1.0/scripts/smoke_local_llm.py +162 -0
  45. contextos_dd-0.1.0/scripts/smoke_real.py +154 -0
  46. contextos_dd-0.1.0/tests/__init__.py +0 -0
  47. contextos_dd-0.1.0/tests/conftest.py +16 -0
  48. contextos_dd-0.1.0/tests/test_archive.py +20 -0
  49. contextos_dd-0.1.0/tests/test_classifier.py +40 -0
  50. contextos_dd-0.1.0/tests/test_compactor.py +65 -0
  51. contextos_dd-0.1.0/tests/test_dashboard_queries.py +64 -0
  52. contextos_dd-0.1.0/tests/test_e2e_smoke.py +113 -0
  53. contextos_dd-0.1.0/tests/test_installer.py +91 -0
  54. contextos_dd-0.1.0/tests/test_ledger.py +45 -0
  55. contextos_dd-0.1.0/tests/test_proxy.py +99 -0
  56. contextos_dd-0.1.0/tests/test_reconstructor.py +37 -0
  57. contextos_dd-0.1.0/tests/test_retrieval.py +14 -0
  58. contextos_dd-0.1.0/tests/test_session_memory.py +36 -0
  59. contextos_dd-0.1.0/tests/test_tokens.py +23 -0
@@ -0,0 +1,24 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ${{ matrix.os }}
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ os: [ubuntu-latest, macos-latest, windows-latest]
15
+ python-version: ["3.11", "3.12"]
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: actions/setup-python@v5
19
+ with:
20
+ python-version: ${{ matrix.python-version }}
21
+ - run: pip install -e ".[dev]"
22
+ - run: ruff check .
23
+ - run: mypy contextos
24
+ - run: pytest -q
@@ -0,0 +1,34 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.12"
16
+ - run: pip install build
17
+ - run: python -m build
18
+ - uses: actions/upload-artifact@v4
19
+ with:
20
+ name: dist
21
+ path: dist/
22
+
23
+ publish:
24
+ needs: build
25
+ runs-on: ubuntu-latest
26
+ environment: pypi
27
+ permissions:
28
+ id-token: write # OIDC for PyPI trusted publishing
29
+ steps:
30
+ - uses: actions/download-artifact@v4
31
+ with:
32
+ name: dist
33
+ path: dist/
34
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,22 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .venv/
5
+ venv/
6
+ dist/
7
+ build/
8
+ .pytest_cache/
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+ .coverage
12
+ htmlcov/
13
+ *.duckdb
14
+ *.duckdb.wal
15
+ .contextos/
16
+ .smoke/
17
+ .smoke_local/
18
+ contextos.html
19
+ ContextOS_PRD_v1.docx
20
+ .claude/
21
+ .env
22
+ .DS_Store
@@ -0,0 +1,233 @@
1
+ # Installing ContextOS
2
+
3
+ This is the full first-run walkthrough. Most users only need `pip install contextos-dd && contextos install` — but if you want to know exactly what's happening, this is the doc.
4
+
5
+ ---
6
+
7
+ ## Prerequisites
8
+
9
+ - **Python 3.11 or 3.12**
10
+ - **One of the supported IDEs already installed:** Claude Code, Cursor, Codex CLI, Continue, or Aider
11
+ - **An API key already configured in your IDE** for Anthropic or OpenAI. ContextOS doesn't manage API keys; your IDE keeps doing that.
12
+ - **~500 MB of free disk** for the local models
13
+ - **Internet access** during install (for the model download) — unless you use `--skip-models`
14
+
15
+ ContextOS works on Windows, macOS, and Linux.
16
+
17
+ ---
18
+
19
+ ## Step 1 — Install the package
20
+
21
+ ```bash
22
+ pip install contextos-dd
23
+ ```
24
+
25
+ This pulls the package and its dependencies (FastAPI, DuckDB, LanceDB, llama-cpp-python, fastembed, etc.). Takes 30–60 seconds depending on your connection.
26
+
27
+ ### Windows note: prebuilt llama-cpp wheel
28
+
29
+ On Windows, `pip` may try to build `llama-cpp-python` from source and hit Windows' 260-char path limit. Avoid that by installing the prebuilt wheel **first**:
30
+
31
+ ```powershell
32
+ pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
33
+ pip install contextos-dd
34
+ ```
35
+
36
+ ### Old or virtualised CPUs
37
+
38
+ ContextOS pins `llama-cpp-python==0.2.90` because newer wheels include AVX-512 instructions that crash on Intel 12th/13th-gen consumer CPUs (where AVX-512 is microcode-disabled). If your CPU is older than ~2013, even 0.2.90 may not work — open an issue and we'll add a fallback.
39
+
40
+ ---
41
+
42
+ ## Step 2 — Run `contextos install`
43
+
44
+ ```bash
45
+ contextos install
46
+ ```
47
+
48
+ What happens, in order:
49
+
50
+ 1. **IDE detection.** Looks for these files; patches whichever exist:
51
+ - `~/.claude/settings.json` (Claude Code)
52
+ - `~/.cursor/settings.json` (Cursor)
53
+ - `~/.codex/config.json` (Codex CLI)
54
+ - `~/.continue/config.json` (Continue)
55
+ - `~/.aider.conf.yml` (Aider)
56
+ 2. **Backup.** Every file we touch is copied to `~/.contextos/backups/<ide>.<timestamp>.<ext>` first.
57
+ 3. **Patch.** We set the API base URL to `http://127.0.0.1:9137`.
58
+ 4. **Model download (the slow step).** Two files pulled from HuggingFace into `~/.contextos/models/`:
59
+ - `Qwen2.5-0.5B-Instruct-Q4_K_M.gguf` — ~400 MB
60
+ - `BAAI/bge-small-en-v1.5` ONNX bundle — ~30 MB
61
+ 5. **Daemon start.** The proxy starts on `127.0.0.1:9137` and writes its PID to `~/.contextos/daemon.pid`.
62
+
63
+ Total time: **2–5 minutes** depending on connection speed.
64
+
65
+ ### Air-gapped or offline install
66
+
67
+ ```bash
68
+ contextos install --skip-models
69
+ ```
70
+
71
+ The daemon will still start and route IDE traffic correctly. Compaction silently no-ops until models are present — you'll lose narrative summaries but still get **DEAD-turn removal and HOT-window trimming (~25–35% savings)**.
72
+
73
+ To install models later, when you have internet:
74
+
75
+ ```bash
76
+ contextos warmup
77
+ ```
78
+
79
+ Or place the files manually in `~/.contextos/models/` — filenames must match those in step 4.
80
+
81
+ ---
82
+
83
+ ## Step 3 — Verify
84
+
85
+ ```bash
86
+ contextos doctor
87
+ ```
88
+
89
+ Expected output:
90
+
91
+ ```
92
+ Paths
93
+ OK data dir ~/.contextos
94
+ OK log dir ~/.contextos/logs
95
+ OK db file ~/.contextos/ledger.duckdb
96
+ OK model dir ~/.contextos/models
97
+
98
+ Dependencies
99
+ OK llama-cpp-python
100
+ OK fastembed
101
+ OK lancedb
102
+ OK streamlit
103
+
104
+ Network
105
+ OK proxy http://127.0.0.1:9137 daemon running
106
+ OK dashboard port 9138 free
107
+
108
+ IDEs
109
+ OK claude-code ~/.claude/settings.json
110
+ ```
111
+
112
+ Then use your IDE normally. Open the dashboard to see token savings in real time:
113
+
114
+ ```bash
115
+ contextos dashboard
116
+ ```
117
+
118
+ Browser opens `http://127.0.0.1:9138`.
119
+
120
+ ---
121
+
122
+ ## What lives where
123
+
124
+ ```
125
+ ~/.contextos/
126
+ ledger.duckdb session + turn ledger (DuckDB; ~1 MB per long session)
127
+ daemon.pid daemon pid (deleted on clean shutdown)
128
+ backups/
129
+ claude-code.20260515T101500Z.json
130
+ claude-code.latest.json
131
+ cursor.latest.json
132
+ ...
133
+ archive/ LanceDB vector store for retrieval
134
+ models/
135
+ Qwen2.5-0.5B-Instruct-Q4_K_M.gguf ~400 MB
136
+ models--BAAI--bge-small-en-v1.5/ ~30 MB
137
+ logs/
138
+ contextos.log rolling daemon log (UTF-8)
139
+ ```
140
+
141
+ On Windows these paths live under `%LOCALAPPDATA%\DataDojo\contextos\` (typically `C:\Users\<you>\AppData\Local\DataDojo\contextos\`).
142
+
143
+ ---
144
+
145
+ ## Privacy guarantees, plainly
146
+
147
+ **ContextOS does not send your code or conversation to any third party we control.** The only outbound HTTP traffic ContextOS initiates:
148
+
149
+ 1. **Model downloads** during `install` or `warmup` — public files from HuggingFace.
150
+ 2. **Forwarding your IDE's chat request upstream** — to whatever cloud LLM (`api.anthropic.com`, `api.openai.com`, etc.) your IDE was already configured to use.
151
+
152
+ That's it. No telemetry, no usage reporting, no cloud sync, no shared memory, no analytics. The proxy reduces the payload before forwarding; everything else stays on disk in `~/.contextos/`.
153
+
154
+ ---
155
+
156
+ ## Uninstall
157
+
158
+ ```bash
159
+ contextos uninstall
160
+ ```
161
+
162
+ - Restores every IDE config we touched (from `~/.contextos/backups/*.latest.*`).
163
+ - Stops the daemon.
164
+ - **Does not** delete the ledger, archive, models, or logs — they stay in case you reinstall later.
165
+
166
+ To wipe everything:
167
+
168
+ ```bash
169
+ contextos uninstall
170
+ rm -rf ~/.contextos # Linux / macOS
171
+ Remove-Item -Recurse -Force $env:LOCALAPPDATA\DataDojo\contextos # Windows
172
+ ```
173
+
174
+ Then `pip uninstall contextos-dd` to remove the package itself.
175
+
176
+ ---
177
+
178
+ ## Troubleshooting
179
+
180
+ ### `contextos doctor` shows daemon stopped
181
+
182
+ ```bash
183
+ contextos start
184
+ ```
185
+
186
+ If that fails, check `~/.contextos/logs/contextos.log`.
187
+
188
+ ### `llama-cpp-python` install errored with `[WinError -1073741795]` or `STATUS_ILLEGAL_INSTRUCTION`
189
+
190
+ Your CPU doesn't support an instruction the wheel uses (usually AVX-512). ContextOS pins `0.2.90` to avoid this; if it still trips, reinstall:
191
+
192
+ ```bash
193
+ pip install --force-reinstall "llama-cpp-python==0.2.90" --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
194
+ ```
195
+
196
+ ### Pip errored about Windows long paths
197
+
198
+ Install the prebuilt wheel first (see Step 1). Or enable Long Paths globally:
199
+
200
+ ```powershell
201
+ # Run once as Administrator:
202
+ New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
203
+ -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
204
+ ```
205
+
206
+ ### Compaction is too slow / takes ~30s on first batch
207
+
208
+ The first compaction job loads the model into RAM (~5–10s on CPU). Subsequent jobs are 1–2s. If it's still slow, your model file may be corrupt:
209
+
210
+ ```bash
211
+ rm ~/.contextos/models/Qwen2.5-*.gguf
212
+ contextos warmup
213
+ ```
214
+
215
+ ### Model download failed
216
+
217
+ Check connectivity to `huggingface.co`. Behind a corporate proxy? Set `HF_HUB_ENABLE_HF_TRANSFER=0` and/or `HTTPS_PROXY=http://your-proxy:port` in the environment before running `contextos warmup`.
218
+
219
+ ### Streamlit dashboard says "Ledger not found yet"
220
+
221
+ You haven't made any API calls through the proxy yet. Make one call from your IDE; refresh the page.
222
+
223
+ ### IDE still hits the cloud directly after install
224
+
225
+ Restart the IDE. Most IDEs read their settings file at startup and don't notice mid-session changes.
226
+
227
+ ---
228
+
229
+ ## Next steps
230
+
231
+ - Browse the dashboard: `contextos dashboard`
232
+ - Read the [README](./README.md) for the high-level pitch
233
+ - File issues at https://github.com/DataDojo/context-os/issues
@@ -0,0 +1,19 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Copyright 2026 DataDojo
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+
19
+ Full license text: https://www.apache.org/licenses/LICENSE-2.0.txt
@@ -0,0 +1,160 @@
1
+ Metadata-Version: 2.4
2
+ Name: contextos-dd
3
+ Version: 0.1.0
4
+ Summary: Local-first, IDE-agnostic agentic memory lifecycle manager
5
+ Project-URL: Homepage, https://github.com/DataDojo/context-os
6
+ Project-URL: Repository, https://github.com/DataDojo/context-os
7
+ Author: DataDojo
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: claude,context,cursor,llm,proxy,tokens
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Requires-Python: >=3.11
17
+ Requires-Dist: duckdb>=1.1
18
+ Requires-Dist: fastapi>=0.115
19
+ Requires-Dist: fastembed>=0.4
20
+ Requires-Dist: httpx>=0.27
21
+ Requires-Dist: huggingface-hub>=0.26
22
+ Requires-Dist: lancedb>=0.13
23
+ Requires-Dist: llama-cpp-python==0.2.90
24
+ Requires-Dist: numpy>=1.26
25
+ Requires-Dist: platformdirs>=4.3
26
+ Requires-Dist: pyarrow>=17
27
+ Requires-Dist: pydantic-settings>=2.6
28
+ Requires-Dist: pydantic>=2.9
29
+ Requires-Dist: pyyaml>=6.0
30
+ Requires-Dist: rich>=13.9
31
+ Requires-Dist: tiktoken>=0.8
32
+ Requires-Dist: typer>=0.13
33
+ Requires-Dist: uvicorn[standard]>=0.32
34
+ Provides-Extra: dashboard
35
+ Requires-Dist: polars>=1.12; extra == 'dashboard'
36
+ Requires-Dist: streamlit-autorefresh>=1.0; extra == 'dashboard'
37
+ Requires-Dist: streamlit>=1.40; extra == 'dashboard'
38
+ Provides-Extra: dev
39
+ Requires-Dist: mypy>=1.13; extra == 'dev'
40
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
41
+ Requires-Dist: pytest>=8.3; extra == 'dev'
42
+ Requires-Dist: ruff>=0.7; extra == 'dev'
43
+ Requires-Dist: types-pyyaml; extra == 'dev'
44
+ Description-Content-Type: text/markdown
45
+
46
+ # ContextOS
47
+
48
+ **Local-first agentic memory lifecycle manager for Claude Code, Cursor, Codex, Continue, and Aider.**
49
+
50
+ ContextOS runs as a background daemon between your IDE and the cloud LLM. It classifies your conversation history by relevance, compresses stale turns into narrative summaries via a small on-device model, and forwards a clean, minimal payload upstream — cutting input tokens 50–70% on long sessions without quality loss.
51
+
52
+ **Zero bytes of your session content leave your machine** except the request that goes to your chosen cloud LLM (Anthropic, OpenAI) — which is exactly what your IDE was going to send anyway, just smaller.
53
+
54
+ Built by [DataDojo](https://github.com/DataDojo). Apache-2.0.
55
+
56
+ ---
57
+
58
+ ## Install
59
+
60
+ ```bash
61
+ pip install contextos-dd
62
+ contextos install
63
+ ```
64
+
65
+ That's it. `contextos install`:
66
+
67
+ 1. Detects supported IDE configs (Claude Code, Cursor, Codex CLI, Continue, Aider)
68
+ 2. Backs them up to `~/.contextos/backups/`
69
+ 3. Patches them to route through the local proxy on `127.0.0.1:9137`
70
+ 4. **Downloads two small models** (~430 MB total, one time) to `~/.contextos/models/`
71
+ 5. Starts the daemon
72
+
73
+ The model download happens **once** during install so the first long session doesn't pause for it. For air-gapped or offline installs, use `contextos install --skip-models`.
74
+
75
+ See [INSTALL.md](./INSTALL.md) for the full first-run walkthrough, paths, privacy guarantees, troubleshooting, and uninstall semantics.
76
+
77
+ ---
78
+
79
+ ## What gets downloaded
80
+
81
+ | File | Size | Purpose | Where |
82
+ |---|---|---|---|
83
+ | `Qwen2.5-0.5B-Instruct-Q4_K_M.gguf` | ~400 MB | Compaction (summarising stale turns) | `~/.contextos/models/` |
84
+ | `bge-small-en-v1.5` ONNX | ~30 MB | Embeddings (vector recall) | `~/.contextos/models/` |
85
+
86
+ Both download once, then live on disk forever. Subsequent runs use the cache. Re-pull anytime with `contextos warmup`.
87
+
88
+ ---
89
+
90
+ ## Commands
91
+
92
+ | Command | What it does |
93
+ |---|---|
94
+ | `contextos install` | Detect IDEs, back up configs, patch URLs, download models, start daemon |
95
+ | `contextos install --skip-models` | Same as above but skip the model download |
96
+ | `contextos warmup` | Download / refresh local models |
97
+ | `contextos status` | Show daemon health and detected IDEs |
98
+ | `contextos start` / `stop` | Daemon lifecycle |
99
+ | `contextos dashboard` | Launch the Streamlit dashboard at `http://127.0.0.1:9138` |
100
+ | `contextos doctor` | Preflight checks: paths, deps, ports, IDE configs |
101
+ | `contextos uninstall` | Restore original IDE configs, stop daemon |
102
+
103
+ ---
104
+
105
+ ## How it works
106
+
107
+ 1. IDE sends API call → `localhost:9137`
108
+ 2. Proxy parses messages, classifies turns **HOT / WARM / COLD / DEAD**
109
+ 3. **DEAD** (duplicates) dropped, **COLD** runs replaced with a narrative summary from the local Qwen2.5 model
110
+ 4. Clean payload forwarded to `api.anthropic.com` / `api.openai.com`
111
+ 5. Response streamed back unchanged; trigger phrases like *"as we discussed"* fire a vector recall from a local LanceDB archive for the next turn
112
+
113
+ ---
114
+
115
+ ## Privacy
116
+
117
+ - **Your code never goes to a third party.** The only outbound network call ContextOS makes is forwarding your IDE's API request to the cloud LLM you already configured your IDE to use.
118
+ - **No telemetry.** Zero. We do not phone home.
119
+ - **No cloud sync.** Sessions, summaries, embeddings, and logs live in `~/.contextos/` on your machine.
120
+ - **No background uploads.** Ever.
121
+
122
+ The only network traffic ContextOS initiates on its own:
123
+ - Model downloads during `install` or `warmup` — fetched from HuggingFace.
124
+ - Forwarding your IDE's chat requests upstream — exactly the request your IDE built.
125
+
126
+ ---
127
+
128
+ ## Where stuff lives
129
+
130
+ ```
131
+ ~/.contextos/
132
+ ledger.duckdb # session + turn ledger
133
+ daemon.pid # daemon process id
134
+ backups/ # IDE configs we modified (so uninstall is reversible)
135
+ archive/ # LanceDB vector store of compacted turns
136
+ models/ # Qwen2.5 GGUF + bge-small ONNX
137
+ logs/contextos.log # rolling daemon log
138
+ ```
139
+
140
+ `contextos uninstall` restores IDE configs and stops the daemon. By default it **does not** delete the ledger or models — they stay in case you reinstall. To wipe everything, delete `~/.contextos/` manually.
141
+
142
+ ---
143
+
144
+ ## Status
145
+
146
+ **Phase 1 MVP (this package):** proxy, ledger, classifier, compactor, retrieval, Streamlit dashboard, auto-install for 5 IDEs.
147
+
148
+ **`context-os-pro` (separate package, deferred):** MCP server, team / shared memory, cloud rollups, React dashboard, advanced semantic classifier.
149
+
150
+ ---
151
+
152
+ ## Develop
153
+
154
+ ```bash
155
+ git clone https://github.com/DataDojo/context-os
156
+ cd context-os
157
+ pip install -e ".[dev,dashboard]"
158
+ ruff check .
159
+ pytest -q
160
+ ```
@@ -0,0 +1,115 @@
1
+ # ContextOS
2
+
3
+ **Local-first agentic memory lifecycle manager for Claude Code, Cursor, Codex, Continue, and Aider.**
4
+
5
+ ContextOS runs as a background daemon between your IDE and the cloud LLM. It classifies your conversation history by relevance, compresses stale turns into narrative summaries via a small on-device model, and forwards a clean, minimal payload upstream — cutting input tokens 50–70% on long sessions without quality loss.
6
+
7
+ **Zero bytes of your session content leave your machine** except the request that goes to your chosen cloud LLM (Anthropic, OpenAI) — which is exactly what your IDE was going to send anyway, just smaller.
8
+
9
+ Built by [DataDojo](https://github.com/DataDojo). Apache-2.0.
10
+
11
+ ---
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ pip install contextos-dd
17
+ contextos install
18
+ ```
19
+
20
+ That's it. `contextos install`:
21
+
22
+ 1. Detects supported IDE configs (Claude Code, Cursor, Codex CLI, Continue, Aider)
23
+ 2. Backs them up to `~/.contextos/backups/`
24
+ 3. Patches them to route through the local proxy on `127.0.0.1:9137`
25
+ 4. **Downloads two small models** (~430 MB total, one time) to `~/.contextos/models/`
26
+ 5. Starts the daemon
27
+
28
+ The model download happens **once** during install so the first long session doesn't pause for it. For air-gapped or offline installs, use `contextos install --skip-models`.
29
+
30
+ See [INSTALL.md](./INSTALL.md) for the full first-run walkthrough, paths, privacy guarantees, troubleshooting, and uninstall semantics.
31
+
32
+ ---
33
+
34
+ ## What gets downloaded
35
+
36
+ | File | Size | Purpose | Where |
37
+ |---|---|---|---|
38
+ | `Qwen2.5-0.5B-Instruct-Q4_K_M.gguf` | ~400 MB | Compaction (summarising stale turns) | `~/.contextos/models/` |
39
+ | `bge-small-en-v1.5` ONNX | ~30 MB | Embeddings (vector recall) | `~/.contextos/models/` |
40
+
41
+ Both download once, then live on disk forever. Subsequent runs use the cache. Re-pull anytime with `contextos warmup`.
42
+
43
+ ---
44
+
45
+ ## Commands
46
+
47
+ | Command | What it does |
48
+ |---|---|
49
+ | `contextos install` | Detect IDEs, back up configs, patch URLs, download models, start daemon |
50
+ | `contextos install --skip-models` | Same as above but skip the model download |
51
+ | `contextos warmup` | Download / refresh local models |
52
+ | `contextos status` | Show daemon health and detected IDEs |
53
+ | `contextos start` / `stop` | Daemon lifecycle |
54
+ | `contextos dashboard` | Launch the Streamlit dashboard at `http://127.0.0.1:9138` |
55
+ | `contextos doctor` | Preflight checks: paths, deps, ports, IDE configs |
56
+ | `contextos uninstall` | Restore original IDE configs, stop daemon |
57
+
58
+ ---
59
+
60
+ ## How it works
61
+
62
+ 1. IDE sends API call → `localhost:9137`
63
+ 2. Proxy parses messages, classifies turns **HOT / WARM / COLD / DEAD**
64
+ 3. **DEAD** (duplicates) dropped, **COLD** runs replaced with a narrative summary from the local Qwen2.5 model
65
+ 4. Clean payload forwarded to `api.anthropic.com` / `api.openai.com`
66
+ 5. Response streamed back unchanged; trigger phrases like *"as we discussed"* fire a vector recall from a local LanceDB archive for the next turn
67
+
68
+ ---
69
+
70
+ ## Privacy
71
+
72
+ - **Your code never goes to a third party.** The only outbound network call ContextOS makes is forwarding your IDE's API request to the cloud LLM you already configured your IDE to use.
73
+ - **No telemetry.** Zero. We do not phone home.
74
+ - **No cloud sync.** Sessions, summaries, embeddings, and logs live in `~/.contextos/` on your machine.
75
+ - **No background uploads.** Ever.
76
+
77
+ The only network traffic ContextOS initiates on its own:
78
+ - Model downloads during `install` or `warmup` — fetched from HuggingFace.
79
+ - Forwarding your IDE's chat requests upstream — exactly the request your IDE built.
80
+
81
+ ---
82
+
83
+ ## Where stuff lives
84
+
85
+ ```
86
+ ~/.contextos/
87
+ ledger.duckdb # session + turn ledger
88
+ daemon.pid # daemon process id
89
+ backups/ # IDE configs we modified (so uninstall is reversible)
90
+ archive/ # LanceDB vector store of compacted turns
91
+ models/ # Qwen2.5 GGUF + bge-small ONNX
92
+ logs/contextos.log # rolling daemon log
93
+ ```
94
+
95
+ `contextos uninstall` restores IDE configs and stops the daemon. By default it **does not** delete the ledger or models — they stay in case you reinstall. To wipe everything, delete `~/.contextos/` manually.
96
+
97
+ ---
98
+
99
+ ## Status
100
+
101
+ **Phase 1 MVP (this package):** proxy, ledger, classifier, compactor, retrieval, Streamlit dashboard, auto-install for 5 IDEs.
102
+
103
+ **`context-os-pro` (separate package, deferred):** MCP server, team / shared memory, cloud rollups, React dashboard, advanced semantic classifier.
104
+
105
+ ---
106
+
107
+ ## Develop
108
+
109
+ ```bash
110
+ git clone https://github.com/DataDojo/context-os
111
+ cd context-os
112
+ pip install -e ".[dev,dashboard]"
113
+ ruff check .
114
+ pytest -q
115
+ ```
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,3 @@
1
+ from contextos.archive.store import ArchiveStore
2
+
3
+ __all__ = ["ArchiveStore"]