cashew-brain 1.0.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.
- cashew_brain-1.0.0/LICENSE +21 -0
- cashew_brain-1.0.0/PKG-INFO +224 -0
- cashew_brain-1.0.0/README.md +191 -0
- cashew_brain-1.0.0/cashew_brain.egg-info/PKG-INFO +224 -0
- cashew_brain-1.0.0/cashew_brain.egg-info/SOURCES.txt +68 -0
- cashew_brain-1.0.0/cashew_brain.egg-info/dependency_links.txt +1 -0
- cashew_brain-1.0.0/cashew_brain.egg-info/entry_points.txt +2 -0
- cashew_brain-1.0.0/cashew_brain.egg-info/requires.txt +8 -0
- cashew_brain-1.0.0/cashew_brain.egg-info/top_level.txt +4 -0
- cashew_brain-1.0.0/cashew_cli.py +671 -0
- cashew_brain-1.0.0/core/__init__.py +11 -0
- cashew_brain-1.0.0/core/backup.py +309 -0
- cashew_brain-1.0.0/core/config.py +527 -0
- cashew_brain-1.0.0/core/context.py +395 -0
- cashew_brain-1.0.0/core/daemon.py +222 -0
- cashew_brain-1.0.0/core/db.py +262 -0
- cashew_brain-1.0.0/core/decay.py +313 -0
- cashew_brain-1.0.0/core/embedding_cache.py +133 -0
- cashew_brain-1.0.0/core/embedding_service.py +181 -0
- cashew_brain-1.0.0/core/embeddings.py +558 -0
- cashew_brain-1.0.0/core/export.py +346 -0
- cashew_brain-1.0.0/core/extractors.py +266 -0
- cashew_brain-1.0.0/core/graph_utils.py +88 -0
- cashew_brain-1.0.0/core/llm.py +98 -0
- cashew_brain-1.0.0/core/metrics.py +450 -0
- cashew_brain-1.0.0/core/permanence.py +211 -0
- cashew_brain-1.0.0/core/retrieval.py +718 -0
- cashew_brain-1.0.0/core/session.py +1278 -0
- cashew_brain-1.0.0/core/sleep.py +825 -0
- cashew_brain-1.0.0/core/stats.py +170 -0
- cashew_brain-1.0.0/core/traversal.py +471 -0
- cashew_brain-1.0.0/integration/__init__.py +25 -0
- cashew_brain-1.0.0/integration/session.py +432 -0
- cashew_brain-1.0.0/pyproject.toml +54 -0
- cashew_brain-1.0.0/scripts/backfill_referent_time.py +196 -0
- cashew_brain-1.0.0/scripts/brain-metrics.py +474 -0
- cashew_brain-1.0.0/scripts/cashew_context.py +1698 -0
- cashew_brain-1.0.0/scripts/cashew_init.py +652 -0
- cashew_brain-1.0.0/scripts/dashboard_server.py +173 -0
- cashew_brain-1.0.0/scripts/declassify.py +101 -0
- cashew_brain-1.0.0/scripts/export_dashboard.py +166 -0
- cashew_brain-1.0.0/scripts/test_e2e.py +236 -0
- cashew_brain-1.0.0/setup.cfg +4 -0
- cashew_brain-1.0.0/tests/test_backup.py +72 -0
- cashew_brain-1.0.0/tests/test_bug_fixes.py +383 -0
- cashew_brain-1.0.0/tests/test_context.py +158 -0
- cashew_brain-1.0.0/tests/test_daemon.py +147 -0
- cashew_brain-1.0.0/tests/test_db_helper.py +332 -0
- cashew_brain-1.0.0/tests/test_decay.py +341 -0
- cashew_brain-1.0.0/tests/test_domains.py +270 -0
- cashew_brain-1.0.0/tests/test_embedding_cache.py +92 -0
- cashew_brain-1.0.0/tests/test_embedding_daemon_integration.py +122 -0
- cashew_brain-1.0.0/tests/test_embedding_service.py +146 -0
- cashew_brain-1.0.0/tests/test_embeddings.py +310 -0
- cashew_brain-1.0.0/tests/test_extractors.py +595 -0
- cashew_brain-1.0.0/tests/test_graph_utils.py +112 -0
- cashew_brain-1.0.0/tests/test_init.py +342 -0
- cashew_brain-1.0.0/tests/test_integration.py +253 -0
- cashew_brain-1.0.0/tests/test_llm.py +83 -0
- cashew_brain-1.0.0/tests/test_metrics.py +219 -0
- cashew_brain-1.0.0/tests/test_migration.py +348 -0
- cashew_brain-1.0.0/tests/test_permanence.py +301 -0
- cashew_brain-1.0.0/tests/test_prepare_ingest.py +341 -0
- cashew_brain-1.0.0/tests/test_referent_time.py +293 -0
- cashew_brain-1.0.0/tests/test_retrieval.py +411 -0
- cashew_brain-1.0.0/tests/test_session.py +510 -0
- cashew_brain-1.0.0/tests/test_session_integration.py +115 -0
- cashew_brain-1.0.0/tests/test_sleep.py +986 -0
- cashew_brain-1.0.0/tests/test_stats.py +375 -0
- cashew_brain-1.0.0/tests/test_traversal.py +280 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Raj Kripal Danday
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cashew-brain
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Persistent thought-graph memory for AI agents. Provides context generation, knowledge extraction, and autonomous think cycles.
|
|
5
|
+
Author: rajkripal
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/rajkripal/cashew
|
|
8
|
+
Project-URL: Repository, https://github.com/rajkripal/cashew
|
|
9
|
+
Project-URL: Issues, https://github.com/rajkripal/cashew/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/rajkripal/cashew/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: ai,memory,graph,agents,openclaw,llm
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Topic :: Database :: Database Engines/Servers
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: numpy
|
|
26
|
+
Requires-Dist: scikit-learn
|
|
27
|
+
Requires-Dist: sentence-transformers
|
|
28
|
+
Requires-Dist: PyYAML
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# Cashew 🥜
|
|
35
|
+
|
|
36
|
+
**Persistent thought-graph memory for AI agents.**
|
|
37
|
+
|
|
38
|
+
The name comes from asking "do cats eat cashews?" — a question I asked my aunt as a 10-year-old kid in India, because the cashews were left open in the kitchen and I knew stray cats sneak into homes to eat food. My family still brings it up every time I visit. I never stopped asking questions. This system doesn't either — autonomous think cycles find connections you didn't know existed.
|
|
39
|
+
|
|
40
|
+
📝 **Blog post:** [I Built My AI a Brain and It Started Thinking for Itself](https://open.substack.com/pub/rajkripaldanday/p/i-built-my-ai-a-brain-and-it-started)
|
|
41
|
+
|
|
42
|
+
## Architecture
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
## What It Does
|
|
47
|
+
|
|
48
|
+
- **Remembers across sessions.** Decisions, patterns, relationships, and project context survive compaction and restart. Your agent picks up where it left off.
|
|
49
|
+
- **Learns autonomously.** Think cycles find cross-domain connections without prompting. A pattern in your work habits connects to a pattern in your communication style — the brain surfaces it.
|
|
50
|
+
- **Stays fast at scale.** sqlite-vec for O(log N) retrieval, recursive BFS graph walk, constant context cost regardless of graph size. 3,000 nodes costs the same as 300.
|
|
51
|
+
|
|
52
|
+
## What If Forgetting Is the Intelligence?
|
|
53
|
+
|
|
54
|
+
Cashew doesn't hoard everything. Organic decay means low-value knowledge fades naturally while important patterns strengthen through use. No manual curation needed — the graph self-organizes through cross-linking and natural selection. See [PHILOSOPHY.md](PHILOSOPHY.md) for the full manifesto.
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install cashew-brain
|
|
60
|
+
cashew init
|
|
61
|
+
cashew context --hints "test"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
That's it. Your brain is empty but ready. Start extracting knowledge:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
echo "I prefer TypeScript over JavaScript for complex projects" | cashew extract --input -
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Query it back:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
cashew context --hints "programming language preferences"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Integration
|
|
77
|
+
|
|
78
|
+
### Claude Code
|
|
79
|
+
|
|
80
|
+
Copy the skill into your personal skills directory:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# From the cashew repo
|
|
84
|
+
cp -r skills/claude-code/ ~/.claude/skills/cashew/
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This gives you the `/cashew` slash command and automatic context loading. Claude Code will query your brain before answering substantive questions and extract knowledge during conversations.
|
|
88
|
+
|
|
89
|
+
Or if you cloned the repo, just open it in Claude Code — the `.claude/skills/cashew/` directory auto-discovers.
|
|
90
|
+
|
|
91
|
+
### OpenClaw
|
|
92
|
+
|
|
93
|
+
Install as an OpenClaw skill for full automation — cron jobs handle extraction, think cycles, and dashboard deployment without manual intervention. See `skills/openclaw/SKILL.md` for setup instructions.
|
|
94
|
+
|
|
95
|
+
### Ingest Sources
|
|
96
|
+
|
|
97
|
+
Cashew ships with built-in extractors for common knowledge sources. Each one handles checkpointing, incremental updates, and deduplication automatically.
|
|
98
|
+
|
|
99
|
+
**Obsidian vault:**
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
cashew ingest obsidian /path/to/vault
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Parses YAML frontmatter (tags, aliases, dates), follows `[[wikilinks]]` to create edges between related notes, respects `.obsidianignore`, and auto-detects domains from your folder structure. Your second brain becomes your AI's brain.
|
|
106
|
+
|
|
107
|
+
**OpenClaw session logs:**
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
cashew ingest sessions /path/to/sessions/
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Extracts knowledge from conversation history. Tracks how far into each session file it's read, so growing sessions get incrementally processed. Filters out tool calls and system messages.
|
|
114
|
+
|
|
115
|
+
**Markdown directory:**
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
cashew ingest markdown /path/to/notes/
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
General purpose extractor for any directory of `.md` files. Respects `.cashewignore` for excluding files.
|
|
122
|
+
|
|
123
|
+
**Options:**
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
cashew ingest --list # Show available extractors
|
|
127
|
+
cashew ingest obsidian /path --no-llm # Skip LLM, use paragraph splitting fallback
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
All extractors use LLM-based extraction by default for richer, typed knowledge (decisions, insights, facts). Use `--no-llm` for offline or token-free ingestion.
|
|
131
|
+
|
|
132
|
+
### Python API
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from core.context import ContextRetriever
|
|
136
|
+
from core.embeddings import load_embeddings
|
|
137
|
+
|
|
138
|
+
# Query context
|
|
139
|
+
embeddings = load_embeddings("path/to/graph.db")
|
|
140
|
+
retriever = ContextRetriever("path/to/graph.db", embeddings)
|
|
141
|
+
context = retriever.generate_context(hints=["work", "projects"])
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Architecture
|
|
145
|
+
|
|
146
|
+
- **Single SQLite file.** No external servers, no separate indexes. Your entire brain is one portable file.
|
|
147
|
+
- **Local embeddings.** all-MiniLM-L6-v2 (384 dims). Downloads ~500MB on first run, then runs locally forever. No API calls for retrieval.
|
|
148
|
+
- **LLM for intelligence.** Extraction and think cycles need an LLM (Claude, GPT, etc). Retrieval and storage don't. Bring your own via `model_fn` parameter or API key.
|
|
149
|
+
- **Retrieval.** sqlite-vec seeds (O(log N) nearest neighbor) → recursive BFS graph walk (seeds=5, picks_per_hop=3, max_depth=3). The graph's organic connectivity provides implicit hierarchy — no synthetic summary nodes needed.
|
|
150
|
+
- **Organic decay.** Nodes that aren't accessed lose fitness over time. Low-fitness nodes get marked decayed and excluded from retrieval. The graph forgets what doesn't matter.
|
|
151
|
+
|
|
152
|
+
## CLI Reference
|
|
153
|
+
|
|
154
|
+
| Command | Purpose |
|
|
155
|
+
|---------|---------|
|
|
156
|
+
| `cashew init` | Initialize a new brain |
|
|
157
|
+
| `cashew context --hints "..."` | Retrieve relevant context |
|
|
158
|
+
| `cashew extract --input file.md` | Extract knowledge from text |
|
|
159
|
+
| `cashew ingest obsidian /path` | Ingest an Obsidian vault |
|
|
160
|
+
| `cashew ingest sessions /path` | Ingest OpenClaw session logs |
|
|
161
|
+
| `cashew ingest markdown /path` | Ingest a directory of markdown files |
|
|
162
|
+
| `cashew think` | Run a think cycle |
|
|
163
|
+
| `cashew sleep` | Full sleep cycle (consolidation) |
|
|
164
|
+
| `cashew stats` | Graph statistics |
|
|
165
|
+
| `cashew dashboard` | Launch the live dashboard (graph + BFS search visualization) |
|
|
166
|
+
|
|
167
|
+
### Dashboard
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
cashew dashboard --db data/graph.db --port 8765
|
|
171
|
+
# then open http://127.0.0.1:8765
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
A minimalist browser UI over the brain. The full graph renders as a canvas force layout colored by node type. The search box traces a live recursive-BFS walk: seeds arrive first, then each hop lights up in order with hop-colored edges and rings. Works on mobile (bottom sheet, drag-to-resize). Pass `--host 0.0.0.0` to expose on the LAN. Auto-trigger a search via `?q=...` in the URL.
|
|
175
|
+
|
|
176
|
+
## Warm Daemon
|
|
177
|
+
|
|
178
|
+
Every CLI invocation normally loads the sentence-transformer model from scratch (~2s cold start). For a responsive query loop, run the warm daemon once and every call routes through it automatically — no code changes in consumers.
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Foreground (development)
|
|
182
|
+
cashew serve
|
|
183
|
+
|
|
184
|
+
# Persistent (macOS)
|
|
185
|
+
cp packaging/com.cashew.daemon.plist ~/Library/LaunchAgents/
|
|
186
|
+
# edit CASHEW_PATH in the plist to match your clone, then:
|
|
187
|
+
launchctl load ~/Library/LaunchAgents/com.cashew.daemon.plist
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
The daemon listens on `~/.cashew/daemon.sock`. A content-hash embedding cache at `~/.cashew/embedding_cache.db` makes repeat embeds free, keyed by `(model_version, sha256(text))` — deterministic, so no invalidation logic is needed beyond model swaps.
|
|
191
|
+
|
|
192
|
+
Every entry point (`context`, `extract`, `think`, sleep cycles) checks the cache first, then the daemon, then falls back to in-process embedding if the daemon is down. Clients never need to know which path served them.
|
|
193
|
+
|
|
194
|
+
## Requirements
|
|
195
|
+
|
|
196
|
+
- Python 3.10+
|
|
197
|
+
- ~2GB RAM (for embedding model)
|
|
198
|
+
- ~500MB disk (embedding model, downloaded on first use)
|
|
199
|
+
- An LLM API key for extraction and think cycles (optional for retrieval-only use)
|
|
200
|
+
|
|
201
|
+
## Philosophy
|
|
202
|
+
|
|
203
|
+
Cashew ships with a philosophy document that defines how a brain-equipped agent should operate. It covers brain sovereignty, evidence over defaults, the sponge principle, cross-domain vision, and why divergence between instances is the whole point.
|
|
204
|
+
|
|
205
|
+
Read it: [PHILOSOPHY.md](PHILOSOPHY.md)
|
|
206
|
+
|
|
207
|
+
## Development
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
git clone https://github.com/rajkripal/cashew.git
|
|
211
|
+
cd cashew
|
|
212
|
+
pip install -e ".[dev]"
|
|
213
|
+
pytest
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
See [CLAUDE.md](CLAUDE.md) for the developer guide — architecture, schema, conventions, and engineering philosophy.
|
|
217
|
+
|
|
218
|
+
## License
|
|
219
|
+
|
|
220
|
+
MIT — see [LICENSE](LICENSE).
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
Built by [rajkripal](https://github.com/rajkripal).
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# Cashew 🥜
|
|
2
|
+
|
|
3
|
+
**Persistent thought-graph memory for AI agents.**
|
|
4
|
+
|
|
5
|
+
The name comes from asking "do cats eat cashews?" — a question I asked my aunt as a 10-year-old kid in India, because the cashews were left open in the kitchen and I knew stray cats sneak into homes to eat food. My family still brings it up every time I visit. I never stopped asking questions. This system doesn't either — autonomous think cycles find connections you didn't know existed.
|
|
6
|
+
|
|
7
|
+
📝 **Blog post:** [I Built My AI a Brain and It Started Thinking for Itself](https://open.substack.com/pub/rajkripaldanday/p/i-built-my-ai-a-brain-and-it-started)
|
|
8
|
+
|
|
9
|
+
## Architecture
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## What It Does
|
|
14
|
+
|
|
15
|
+
- **Remembers across sessions.** Decisions, patterns, relationships, and project context survive compaction and restart. Your agent picks up where it left off.
|
|
16
|
+
- **Learns autonomously.** Think cycles find cross-domain connections without prompting. A pattern in your work habits connects to a pattern in your communication style — the brain surfaces it.
|
|
17
|
+
- **Stays fast at scale.** sqlite-vec for O(log N) retrieval, recursive BFS graph walk, constant context cost regardless of graph size. 3,000 nodes costs the same as 300.
|
|
18
|
+
|
|
19
|
+
## What If Forgetting Is the Intelligence?
|
|
20
|
+
|
|
21
|
+
Cashew doesn't hoard everything. Organic decay means low-value knowledge fades naturally while important patterns strengthen through use. No manual curation needed — the graph self-organizes through cross-linking and natural selection. See [PHILOSOPHY.md](PHILOSOPHY.md) for the full manifesto.
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install cashew-brain
|
|
27
|
+
cashew init
|
|
28
|
+
cashew context --hints "test"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
That's it. Your brain is empty but ready. Start extracting knowledge:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
echo "I prefer TypeScript over JavaScript for complex projects" | cashew extract --input -
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Query it back:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cashew context --hints "programming language preferences"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Integration
|
|
44
|
+
|
|
45
|
+
### Claude Code
|
|
46
|
+
|
|
47
|
+
Copy the skill into your personal skills directory:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# From the cashew repo
|
|
51
|
+
cp -r skills/claude-code/ ~/.claude/skills/cashew/
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This gives you the `/cashew` slash command and automatic context loading. Claude Code will query your brain before answering substantive questions and extract knowledge during conversations.
|
|
55
|
+
|
|
56
|
+
Or if you cloned the repo, just open it in Claude Code — the `.claude/skills/cashew/` directory auto-discovers.
|
|
57
|
+
|
|
58
|
+
### OpenClaw
|
|
59
|
+
|
|
60
|
+
Install as an OpenClaw skill for full automation — cron jobs handle extraction, think cycles, and dashboard deployment without manual intervention. See `skills/openclaw/SKILL.md` for setup instructions.
|
|
61
|
+
|
|
62
|
+
### Ingest Sources
|
|
63
|
+
|
|
64
|
+
Cashew ships with built-in extractors for common knowledge sources. Each one handles checkpointing, incremental updates, and deduplication automatically.
|
|
65
|
+
|
|
66
|
+
**Obsidian vault:**
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cashew ingest obsidian /path/to/vault
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Parses YAML frontmatter (tags, aliases, dates), follows `[[wikilinks]]` to create edges between related notes, respects `.obsidianignore`, and auto-detects domains from your folder structure. Your second brain becomes your AI's brain.
|
|
73
|
+
|
|
74
|
+
**OpenClaw session logs:**
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
cashew ingest sessions /path/to/sessions/
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Extracts knowledge from conversation history. Tracks how far into each session file it's read, so growing sessions get incrementally processed. Filters out tool calls and system messages.
|
|
81
|
+
|
|
82
|
+
**Markdown directory:**
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
cashew ingest markdown /path/to/notes/
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
General purpose extractor for any directory of `.md` files. Respects `.cashewignore` for excluding files.
|
|
89
|
+
|
|
90
|
+
**Options:**
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
cashew ingest --list # Show available extractors
|
|
94
|
+
cashew ingest obsidian /path --no-llm # Skip LLM, use paragraph splitting fallback
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
All extractors use LLM-based extraction by default for richer, typed knowledge (decisions, insights, facts). Use `--no-llm` for offline or token-free ingestion.
|
|
98
|
+
|
|
99
|
+
### Python API
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from core.context import ContextRetriever
|
|
103
|
+
from core.embeddings import load_embeddings
|
|
104
|
+
|
|
105
|
+
# Query context
|
|
106
|
+
embeddings = load_embeddings("path/to/graph.db")
|
|
107
|
+
retriever = ContextRetriever("path/to/graph.db", embeddings)
|
|
108
|
+
context = retriever.generate_context(hints=["work", "projects"])
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Architecture
|
|
112
|
+
|
|
113
|
+
- **Single SQLite file.** No external servers, no separate indexes. Your entire brain is one portable file.
|
|
114
|
+
- **Local embeddings.** all-MiniLM-L6-v2 (384 dims). Downloads ~500MB on first run, then runs locally forever. No API calls for retrieval.
|
|
115
|
+
- **LLM for intelligence.** Extraction and think cycles need an LLM (Claude, GPT, etc). Retrieval and storage don't. Bring your own via `model_fn` parameter or API key.
|
|
116
|
+
- **Retrieval.** sqlite-vec seeds (O(log N) nearest neighbor) → recursive BFS graph walk (seeds=5, picks_per_hop=3, max_depth=3). The graph's organic connectivity provides implicit hierarchy — no synthetic summary nodes needed.
|
|
117
|
+
- **Organic decay.** Nodes that aren't accessed lose fitness over time. Low-fitness nodes get marked decayed and excluded from retrieval. The graph forgets what doesn't matter.
|
|
118
|
+
|
|
119
|
+
## CLI Reference
|
|
120
|
+
|
|
121
|
+
| Command | Purpose |
|
|
122
|
+
|---------|---------|
|
|
123
|
+
| `cashew init` | Initialize a new brain |
|
|
124
|
+
| `cashew context --hints "..."` | Retrieve relevant context |
|
|
125
|
+
| `cashew extract --input file.md` | Extract knowledge from text |
|
|
126
|
+
| `cashew ingest obsidian /path` | Ingest an Obsidian vault |
|
|
127
|
+
| `cashew ingest sessions /path` | Ingest OpenClaw session logs |
|
|
128
|
+
| `cashew ingest markdown /path` | Ingest a directory of markdown files |
|
|
129
|
+
| `cashew think` | Run a think cycle |
|
|
130
|
+
| `cashew sleep` | Full sleep cycle (consolidation) |
|
|
131
|
+
| `cashew stats` | Graph statistics |
|
|
132
|
+
| `cashew dashboard` | Launch the live dashboard (graph + BFS search visualization) |
|
|
133
|
+
|
|
134
|
+
### Dashboard
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
cashew dashboard --db data/graph.db --port 8765
|
|
138
|
+
# then open http://127.0.0.1:8765
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
A minimalist browser UI over the brain. The full graph renders as a canvas force layout colored by node type. The search box traces a live recursive-BFS walk: seeds arrive first, then each hop lights up in order with hop-colored edges and rings. Works on mobile (bottom sheet, drag-to-resize). Pass `--host 0.0.0.0` to expose on the LAN. Auto-trigger a search via `?q=...` in the URL.
|
|
142
|
+
|
|
143
|
+
## Warm Daemon
|
|
144
|
+
|
|
145
|
+
Every CLI invocation normally loads the sentence-transformer model from scratch (~2s cold start). For a responsive query loop, run the warm daemon once and every call routes through it automatically — no code changes in consumers.
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Foreground (development)
|
|
149
|
+
cashew serve
|
|
150
|
+
|
|
151
|
+
# Persistent (macOS)
|
|
152
|
+
cp packaging/com.cashew.daemon.plist ~/Library/LaunchAgents/
|
|
153
|
+
# edit CASHEW_PATH in the plist to match your clone, then:
|
|
154
|
+
launchctl load ~/Library/LaunchAgents/com.cashew.daemon.plist
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The daemon listens on `~/.cashew/daemon.sock`. A content-hash embedding cache at `~/.cashew/embedding_cache.db` makes repeat embeds free, keyed by `(model_version, sha256(text))` — deterministic, so no invalidation logic is needed beyond model swaps.
|
|
158
|
+
|
|
159
|
+
Every entry point (`context`, `extract`, `think`, sleep cycles) checks the cache first, then the daemon, then falls back to in-process embedding if the daemon is down. Clients never need to know which path served them.
|
|
160
|
+
|
|
161
|
+
## Requirements
|
|
162
|
+
|
|
163
|
+
- Python 3.10+
|
|
164
|
+
- ~2GB RAM (for embedding model)
|
|
165
|
+
- ~500MB disk (embedding model, downloaded on first use)
|
|
166
|
+
- An LLM API key for extraction and think cycles (optional for retrieval-only use)
|
|
167
|
+
|
|
168
|
+
## Philosophy
|
|
169
|
+
|
|
170
|
+
Cashew ships with a philosophy document that defines how a brain-equipped agent should operate. It covers brain sovereignty, evidence over defaults, the sponge principle, cross-domain vision, and why divergence between instances is the whole point.
|
|
171
|
+
|
|
172
|
+
Read it: [PHILOSOPHY.md](PHILOSOPHY.md)
|
|
173
|
+
|
|
174
|
+
## Development
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
git clone https://github.com/rajkripal/cashew.git
|
|
178
|
+
cd cashew
|
|
179
|
+
pip install -e ".[dev]"
|
|
180
|
+
pytest
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
See [CLAUDE.md](CLAUDE.md) for the developer guide — architecture, schema, conventions, and engineering philosophy.
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
MIT — see [LICENSE](LICENSE).
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
Built by [rajkripal](https://github.com/rajkripal).
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cashew-brain
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Persistent thought-graph memory for AI agents. Provides context generation, knowledge extraction, and autonomous think cycles.
|
|
5
|
+
Author: rajkripal
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/rajkripal/cashew
|
|
8
|
+
Project-URL: Repository, https://github.com/rajkripal/cashew
|
|
9
|
+
Project-URL: Issues, https://github.com/rajkripal/cashew/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/rajkripal/cashew/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: ai,memory,graph,agents,openclaw,llm
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Topic :: Database :: Database Engines/Servers
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: numpy
|
|
26
|
+
Requires-Dist: scikit-learn
|
|
27
|
+
Requires-Dist: sentence-transformers
|
|
28
|
+
Requires-Dist: PyYAML
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# Cashew 🥜
|
|
35
|
+
|
|
36
|
+
**Persistent thought-graph memory for AI agents.**
|
|
37
|
+
|
|
38
|
+
The name comes from asking "do cats eat cashews?" — a question I asked my aunt as a 10-year-old kid in India, because the cashews were left open in the kitchen and I knew stray cats sneak into homes to eat food. My family still brings it up every time I visit. I never stopped asking questions. This system doesn't either — autonomous think cycles find connections you didn't know existed.
|
|
39
|
+
|
|
40
|
+
📝 **Blog post:** [I Built My AI a Brain and It Started Thinking for Itself](https://open.substack.com/pub/rajkripaldanday/p/i-built-my-ai-a-brain-and-it-started)
|
|
41
|
+
|
|
42
|
+
## Architecture
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
## What It Does
|
|
47
|
+
|
|
48
|
+
- **Remembers across sessions.** Decisions, patterns, relationships, and project context survive compaction and restart. Your agent picks up where it left off.
|
|
49
|
+
- **Learns autonomously.** Think cycles find cross-domain connections without prompting. A pattern in your work habits connects to a pattern in your communication style — the brain surfaces it.
|
|
50
|
+
- **Stays fast at scale.** sqlite-vec for O(log N) retrieval, recursive BFS graph walk, constant context cost regardless of graph size. 3,000 nodes costs the same as 300.
|
|
51
|
+
|
|
52
|
+
## What If Forgetting Is the Intelligence?
|
|
53
|
+
|
|
54
|
+
Cashew doesn't hoard everything. Organic decay means low-value knowledge fades naturally while important patterns strengthen through use. No manual curation needed — the graph self-organizes through cross-linking and natural selection. See [PHILOSOPHY.md](PHILOSOPHY.md) for the full manifesto.
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install cashew-brain
|
|
60
|
+
cashew init
|
|
61
|
+
cashew context --hints "test"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
That's it. Your brain is empty but ready. Start extracting knowledge:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
echo "I prefer TypeScript over JavaScript for complex projects" | cashew extract --input -
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Query it back:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
cashew context --hints "programming language preferences"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Integration
|
|
77
|
+
|
|
78
|
+
### Claude Code
|
|
79
|
+
|
|
80
|
+
Copy the skill into your personal skills directory:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# From the cashew repo
|
|
84
|
+
cp -r skills/claude-code/ ~/.claude/skills/cashew/
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This gives you the `/cashew` slash command and automatic context loading. Claude Code will query your brain before answering substantive questions and extract knowledge during conversations.
|
|
88
|
+
|
|
89
|
+
Or if you cloned the repo, just open it in Claude Code — the `.claude/skills/cashew/` directory auto-discovers.
|
|
90
|
+
|
|
91
|
+
### OpenClaw
|
|
92
|
+
|
|
93
|
+
Install as an OpenClaw skill for full automation — cron jobs handle extraction, think cycles, and dashboard deployment without manual intervention. See `skills/openclaw/SKILL.md` for setup instructions.
|
|
94
|
+
|
|
95
|
+
### Ingest Sources
|
|
96
|
+
|
|
97
|
+
Cashew ships with built-in extractors for common knowledge sources. Each one handles checkpointing, incremental updates, and deduplication automatically.
|
|
98
|
+
|
|
99
|
+
**Obsidian vault:**
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
cashew ingest obsidian /path/to/vault
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Parses YAML frontmatter (tags, aliases, dates), follows `[[wikilinks]]` to create edges between related notes, respects `.obsidianignore`, and auto-detects domains from your folder structure. Your second brain becomes your AI's brain.
|
|
106
|
+
|
|
107
|
+
**OpenClaw session logs:**
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
cashew ingest sessions /path/to/sessions/
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Extracts knowledge from conversation history. Tracks how far into each session file it's read, so growing sessions get incrementally processed. Filters out tool calls and system messages.
|
|
114
|
+
|
|
115
|
+
**Markdown directory:**
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
cashew ingest markdown /path/to/notes/
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
General purpose extractor for any directory of `.md` files. Respects `.cashewignore` for excluding files.
|
|
122
|
+
|
|
123
|
+
**Options:**
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
cashew ingest --list # Show available extractors
|
|
127
|
+
cashew ingest obsidian /path --no-llm # Skip LLM, use paragraph splitting fallback
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
All extractors use LLM-based extraction by default for richer, typed knowledge (decisions, insights, facts). Use `--no-llm` for offline or token-free ingestion.
|
|
131
|
+
|
|
132
|
+
### Python API
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from core.context import ContextRetriever
|
|
136
|
+
from core.embeddings import load_embeddings
|
|
137
|
+
|
|
138
|
+
# Query context
|
|
139
|
+
embeddings = load_embeddings("path/to/graph.db")
|
|
140
|
+
retriever = ContextRetriever("path/to/graph.db", embeddings)
|
|
141
|
+
context = retriever.generate_context(hints=["work", "projects"])
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Architecture
|
|
145
|
+
|
|
146
|
+
- **Single SQLite file.** No external servers, no separate indexes. Your entire brain is one portable file.
|
|
147
|
+
- **Local embeddings.** all-MiniLM-L6-v2 (384 dims). Downloads ~500MB on first run, then runs locally forever. No API calls for retrieval.
|
|
148
|
+
- **LLM for intelligence.** Extraction and think cycles need an LLM (Claude, GPT, etc). Retrieval and storage don't. Bring your own via `model_fn` parameter or API key.
|
|
149
|
+
- **Retrieval.** sqlite-vec seeds (O(log N) nearest neighbor) → recursive BFS graph walk (seeds=5, picks_per_hop=3, max_depth=3). The graph's organic connectivity provides implicit hierarchy — no synthetic summary nodes needed.
|
|
150
|
+
- **Organic decay.** Nodes that aren't accessed lose fitness over time. Low-fitness nodes get marked decayed and excluded from retrieval. The graph forgets what doesn't matter.
|
|
151
|
+
|
|
152
|
+
## CLI Reference
|
|
153
|
+
|
|
154
|
+
| Command | Purpose |
|
|
155
|
+
|---------|---------|
|
|
156
|
+
| `cashew init` | Initialize a new brain |
|
|
157
|
+
| `cashew context --hints "..."` | Retrieve relevant context |
|
|
158
|
+
| `cashew extract --input file.md` | Extract knowledge from text |
|
|
159
|
+
| `cashew ingest obsidian /path` | Ingest an Obsidian vault |
|
|
160
|
+
| `cashew ingest sessions /path` | Ingest OpenClaw session logs |
|
|
161
|
+
| `cashew ingest markdown /path` | Ingest a directory of markdown files |
|
|
162
|
+
| `cashew think` | Run a think cycle |
|
|
163
|
+
| `cashew sleep` | Full sleep cycle (consolidation) |
|
|
164
|
+
| `cashew stats` | Graph statistics |
|
|
165
|
+
| `cashew dashboard` | Launch the live dashboard (graph + BFS search visualization) |
|
|
166
|
+
|
|
167
|
+
### Dashboard
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
cashew dashboard --db data/graph.db --port 8765
|
|
171
|
+
# then open http://127.0.0.1:8765
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
A minimalist browser UI over the brain. The full graph renders as a canvas force layout colored by node type. The search box traces a live recursive-BFS walk: seeds arrive first, then each hop lights up in order with hop-colored edges and rings. Works on mobile (bottom sheet, drag-to-resize). Pass `--host 0.0.0.0` to expose on the LAN. Auto-trigger a search via `?q=...` in the URL.
|
|
175
|
+
|
|
176
|
+
## Warm Daemon
|
|
177
|
+
|
|
178
|
+
Every CLI invocation normally loads the sentence-transformer model from scratch (~2s cold start). For a responsive query loop, run the warm daemon once and every call routes through it automatically — no code changes in consumers.
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Foreground (development)
|
|
182
|
+
cashew serve
|
|
183
|
+
|
|
184
|
+
# Persistent (macOS)
|
|
185
|
+
cp packaging/com.cashew.daemon.plist ~/Library/LaunchAgents/
|
|
186
|
+
# edit CASHEW_PATH in the plist to match your clone, then:
|
|
187
|
+
launchctl load ~/Library/LaunchAgents/com.cashew.daemon.plist
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
The daemon listens on `~/.cashew/daemon.sock`. A content-hash embedding cache at `~/.cashew/embedding_cache.db` makes repeat embeds free, keyed by `(model_version, sha256(text))` — deterministic, so no invalidation logic is needed beyond model swaps.
|
|
191
|
+
|
|
192
|
+
Every entry point (`context`, `extract`, `think`, sleep cycles) checks the cache first, then the daemon, then falls back to in-process embedding if the daemon is down. Clients never need to know which path served them.
|
|
193
|
+
|
|
194
|
+
## Requirements
|
|
195
|
+
|
|
196
|
+
- Python 3.10+
|
|
197
|
+
- ~2GB RAM (for embedding model)
|
|
198
|
+
- ~500MB disk (embedding model, downloaded on first use)
|
|
199
|
+
- An LLM API key for extraction and think cycles (optional for retrieval-only use)
|
|
200
|
+
|
|
201
|
+
## Philosophy
|
|
202
|
+
|
|
203
|
+
Cashew ships with a philosophy document that defines how a brain-equipped agent should operate. It covers brain sovereignty, evidence over defaults, the sponge principle, cross-domain vision, and why divergence between instances is the whole point.
|
|
204
|
+
|
|
205
|
+
Read it: [PHILOSOPHY.md](PHILOSOPHY.md)
|
|
206
|
+
|
|
207
|
+
## Development
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
git clone https://github.com/rajkripal/cashew.git
|
|
211
|
+
cd cashew
|
|
212
|
+
pip install -e ".[dev]"
|
|
213
|
+
pytest
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
See [CLAUDE.md](CLAUDE.md) for the developer guide — architecture, schema, conventions, and engineering philosophy.
|
|
217
|
+
|
|
218
|
+
## License
|
|
219
|
+
|
|
220
|
+
MIT — see [LICENSE](LICENSE).
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
Built by [rajkripal](https://github.com/rajkripal).
|