clear-mind 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.
- clear_mind-0.1.0/.gitignore +28 -0
- clear_mind-0.1.0/LICENSE +21 -0
- clear_mind-0.1.0/PKG-INFO +304 -0
- clear_mind-0.1.0/README.md +268 -0
- clear_mind-0.1.0/README_CN.md +268 -0
- clear_mind-0.1.0/banner.png +0 -0
- clear_mind-0.1.0/clear_mind/__init__.py +1 -0
- clear_mind-0.1.0/clear_mind/agent.py +96 -0
- clear_mind-0.1.0/clear_mind/cli.py +224 -0
- clear_mind-0.1.0/clear_mind/config.py +57 -0
- clear_mind-0.1.0/clear_mind/heartbeat.py +103 -0
- clear_mind-0.1.0/clear_mind/obsidian.py +324 -0
- clear_mind-0.1.0/clear_mind/prompts.py +88 -0
- clear_mind-0.1.0/guide.gif +0 -0
- clear_mind-0.1.0/pyproject.toml +50 -0
- clear_mind-0.1.0/uv.lock +1715 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.so
|
|
5
|
+
*.egg-info/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
*.egg
|
|
9
|
+
|
|
10
|
+
# Virtual environments
|
|
11
|
+
.venv/
|
|
12
|
+
venv/
|
|
13
|
+
|
|
14
|
+
# IDE
|
|
15
|
+
.idea/
|
|
16
|
+
.vscode/
|
|
17
|
+
*.swp
|
|
18
|
+
*.swo
|
|
19
|
+
|
|
20
|
+
# Environment / secrets
|
|
21
|
+
.env
|
|
22
|
+
|
|
23
|
+
# OS
|
|
24
|
+
.DS_Store
|
|
25
|
+
Thumbs.db
|
|
26
|
+
|
|
27
|
+
# Test / dev scripts
|
|
28
|
+
test_growth.py
|
clear_mind-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Darren
|
|
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,304 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clear-mind
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: An AI companion that grows alongside you through your Obsidian notes
|
|
5
|
+
Project-URL: Homepage, https://github.com/slow-coding/clear_mind
|
|
6
|
+
Project-URL: Repository, https://github.com/slow-coding/clear_mind
|
|
7
|
+
Project-URL: Issues, https://github.com/slow-coding/clear_mind/issues
|
|
8
|
+
Author: Clear Mind Contributors
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agent,ai,entropy-reduction,langgraph,local-first,obsidian
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Office/Business
|
|
18
|
+
Classifier: Topic :: Text Processing
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Requires-Dist: deepagents>=0.4.0
|
|
21
|
+
Requires-Dist: langchain-core>=0.3.0
|
|
22
|
+
Requires-Dist: langchain-openai>=0.3.0
|
|
23
|
+
Requires-Dist: langgraph-checkpoint-sqlite>=2.0.0
|
|
24
|
+
Requires-Dist: langgraph>=0.4.0
|
|
25
|
+
Requires-Dist: pydantic-settings>=2.0.0
|
|
26
|
+
Requires-Dist: pydantic>=2.0.0
|
|
27
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
28
|
+
Requires-Dist: rich>=13.0.0
|
|
29
|
+
Requires-Dist: schedule>=1.2.0
|
|
30
|
+
Requires-Dist: typer>=0.15.0
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
34
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
<div align="center">
|
|
38
|
+
<img src="banner.png" alt="Clear Mind Banner" width="100%">
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
# Clear Mind
|
|
42
|
+
|
|
43
|
+
[中文文档](README_CN.md)
|
|
44
|
+
|
|
45
|
+
<div align="center">
|
|
46
|
+
<img src="guide.gif" alt="Clear Mind Demo" width="100%">
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
**You and an AI co-manage one Obsidian vault — with crystal-clear boundaries.**
|
|
50
|
+
|
|
51
|
+
Clear Mind reads your notes, understands who you are, and grows alongside you. It remembers your patterns, tracks your growth, and suggests entropy reduction. But it **never touches your notes** — all its writing is confined to its own folder, enforced at the code level.
|
|
52
|
+
|
|
53
|
+
This is not another AI that dumps files into your vault. Clear Mind is a disciplined co-manager that knows its place.
|
|
54
|
+
|
|
55
|
+
## Core Philosophy: Co-manage, Don't Pollute
|
|
56
|
+
|
|
57
|
+
Most AI tools write files everywhere, cluttering your carefully curated vault. Clear Mind is different:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
Your Obsidian Vault
|
|
61
|
+
├── daily-notes/ ← Your notes. Sacred. Read-only for the agent.
|
|
62
|
+
├── projects/ ← The agent observes, understands, but NEVER modifies.
|
|
63
|
+
├── ideas/ ← Your creative space remains yours.
|
|
64
|
+
│
|
|
65
|
+
└── _clear_mind/ ← Agent's space. Only here it writes.
|
|
66
|
+
├── about_user.md Growing understanding of you
|
|
67
|
+
├── entropy_log.md Entropy reduction observations
|
|
68
|
+
├── reflections/ Daily reflections on what changed
|
|
69
|
+
└── ...
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**The boundary is not just a prompt — it's enforced in code:**
|
|
73
|
+
|
|
74
|
+
- `write_agent_note` and `append_agent_note` validate the path starts with `_clear_mind/`
|
|
75
|
+
- Path traversal attempts are blocked (`../../etc/passwd` → rejected)
|
|
76
|
+
- The agent has zero write tools that operate outside `_clear_mind/`
|
|
77
|
+
- Even if the LLM "decides" to write elsewhere, the tool layer refuses
|
|
78
|
+
|
|
79
|
+
**What the agent DOES do:**
|
|
80
|
+
|
|
81
|
+
- Read your notes to understand your thinking, projects, and patterns
|
|
82
|
+
- Build a growing profile in `_clear_mind/about_user.md` — so it remembers you across sessions
|
|
83
|
+
- Write daily reflections in `_clear_mind/reflections/` — tracking what changed and what it means
|
|
84
|
+
- Log entropy reduction opportunities in `_clear_mind/entropy_log.md` — suggestions, never actions
|
|
85
|
+
|
|
86
|
+
**What the agent NEVER does:**
|
|
87
|
+
|
|
88
|
+
- Modify, delete, or rearrange your notes
|
|
89
|
+
- Create files outside `_clear_mind/`
|
|
90
|
+
- Act on suggestions without your explicit consent
|
|
91
|
+
|
|
92
|
+
## Features
|
|
93
|
+
|
|
94
|
+
- **Local-first** — runs on LM Studio, Ollama, or any OpenAI-compatible API. Zero cloud dependency.
|
|
95
|
+
- **Obsidian CLI integration** — uses the official Obsidian CLI (v1.12+) for all vault operations
|
|
96
|
+
- **Hard boundary enforcement** — the agent physically cannot write outside `_clear_mind/`, enforced at the tool level, not just the prompt
|
|
97
|
+
- **Heartbeat monitoring** — daily vault change detection with zero token cost when nothing changed
|
|
98
|
+
- **Incremental growth** — `about_user.md` grows with every interaction, building real institutional memory
|
|
99
|
+
|
|
100
|
+
## Quick Start
|
|
101
|
+
|
|
102
|
+
### Prerequisites
|
|
103
|
+
|
|
104
|
+
- Python 3.12+
|
|
105
|
+
- [Obsidian](https://obsidian.md) desktop app running (v1.12+ with CLI enabled)
|
|
106
|
+
- A local LLM server (e.g. [LM Studio](https://lmstudio.ai), [Ollama](https://ollama.com))
|
|
107
|
+
|
|
108
|
+
### Install
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
pip install clear-mind
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Setup
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
clear-mind init
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Interactive setup will ask for:
|
|
121
|
+
1. Your Obsidian vault path
|
|
122
|
+
2. LLM API base URL (default: `http://localhost:1234/v1`)
|
|
123
|
+
3. API key (default: `lm-studio`)
|
|
124
|
+
4. Model name (default: `qwen3.5-9b`)
|
|
125
|
+
|
|
126
|
+
This creates a `.env` file and initializes the `_clear_mind/` folder in your vault.
|
|
127
|
+
|
|
128
|
+
#### Example: LM Studio with Qwen 3.5
|
|
129
|
+
|
|
130
|
+
1. Download [LM Studio](https://lmstudio.ai), search and load `unsloth/qwen3.5-35b-a3b`
|
|
131
|
+
2. Start the local server (default port 1234)
|
|
132
|
+
3. Run:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
clear-mind init
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
When prompted:
|
|
139
|
+
```
|
|
140
|
+
Obsidian vault path: /Users/you/MyVault
|
|
141
|
+
LLM base URL [http://localhost:1234/v1]: ← press Enter
|
|
142
|
+
API key [lm-studio]: ← press Enter
|
|
143
|
+
Model name [qwen3.5-9b]: unsloth/qwen3.5-35b-a3b
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Or configure via `.env` directly:
|
|
147
|
+
|
|
148
|
+
```env
|
|
149
|
+
CLEAR_MIND_VAULT_PATH=/Users/you/MyVault
|
|
150
|
+
CLEAR_MIND_BASE_URL=http://localhost:1234/v1
|
|
151
|
+
CLEAR_MIND_API_KEY=lm-studio
|
|
152
|
+
CLEAR_MIND_MODEL_NAME=unsloth/qwen3.5-35b-a3b
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Then start chatting:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
clear-mind chat
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Chat
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
clear-mind chat
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Start an interactive conversation. The agent can read your notes, search your vault, and write reflections — but only within its own folder.
|
|
168
|
+
|
|
169
|
+
### Heartbeat
|
|
170
|
+
|
|
171
|
+
Single run (e.g. via cron):
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
clear-mind heartbeat
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Long-running daemon:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
clear-mind serve
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
The heartbeat scans for vault changes since the last run. If nothing changed, it exits immediately (zero token cost). If changes are detected, the agent reads the changed notes and updates its understanding.
|
|
184
|
+
|
|
185
|
+
### Diagnose
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
clear-mind doctor
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Checks your configuration, vault structure, Obsidian CLI availability, and model connection.
|
|
192
|
+
|
|
193
|
+
## Configuration
|
|
194
|
+
|
|
195
|
+
All settings are loaded from a `.env` file or environment variables with the `CLEAR_MIND_` prefix:
|
|
196
|
+
|
|
197
|
+
| Variable | Default | Description |
|
|
198
|
+
|---|---|---|
|
|
199
|
+
| `CLEAR_MIND_VAULT_PATH` | *(required)* | Path to your Obsidian vault |
|
|
200
|
+
| `CLEAR_MIND_BASE_URL` | `http://localhost:1234/v1` | LLM API base URL |
|
|
201
|
+
| `CLEAR_MIND_API_KEY` | `lm-studio` | API key |
|
|
202
|
+
| `CLEAR_MIND_MODEL_NAME` | `qwen3.5-9b` | Model to use |
|
|
203
|
+
| `CLEAR_MIND_HEARTBEAT_CRON` | `0 9 * * *` | Heartbeat schedule (daily at 9am) |
|
|
204
|
+
| `CLEAR_MIND_CHECKPOINTER_PATH` | `~/_clear_mind_state/checkpoints.db` | State persistence path |
|
|
205
|
+
|
|
206
|
+
## Real-World Example
|
|
207
|
+
|
|
208
|
+
The following is actual output from Clear Mind running with LM Studio + `unsloth/qwen3.5-35b-a3b` on a test vault with 4 notes.
|
|
209
|
+
|
|
210
|
+
### Heartbeat: Automatic Reflection
|
|
211
|
+
|
|
212
|
+
Your notes in the vault:
|
|
213
|
+
```markdown
|
|
214
|
+
daily/2026-03-28.md — "今天开始研究 gRPC,感觉流式传输比 REST 优雅很多。下周做 POC。
|
|
215
|
+
读了《思考快与慢》第 12 章,关于过度自信的偏见。"
|
|
216
|
+
daily/2026-03-29.md — "决定在项目里用 gRPC 替换 REST。流式 API 正好解决了实时推送的需求。
|
|
217
|
+
发现 Obsidian 标签命名不一致,需要统一。"
|
|
218
|
+
|
|
219
|
+
projects/distributed-system.md — notes on CAP theorem, Raft/Paxos, message queues
|
|
220
|
+
projects/decision-framework.md — methodology: boundaries → options → score → POC → rollback
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
After `clear-mind heartbeat`, the agent reads all changed notes and writes:
|
|
224
|
+
|
|
225
|
+
**`_clear_mind/about_user.md`** — Evolving user profile:
|
|
226
|
+
```markdown
|
|
227
|
+
## Technical Focus
|
|
228
|
+
- Studying distributed systems: CAP theorem, consistency models, consensus algorithms
|
|
229
|
+
- Currently focused on gRPC for microservices, particularly streaming RPC
|
|
230
|
+
- Decided to replace REST with gRPC due to real-time push requirements
|
|
231
|
+
- Uses a structured decision framework: define boundaries → list options → score → POC → rollback
|
|
232
|
+
|
|
233
|
+
## Learning Habits
|
|
234
|
+
- Self-reflective about cognitive biases in coding ("this is simple" leading to debugging hell)
|
|
235
|
+
- Plans POCs before full adoption
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**`_clear_mind/reflections/2026-03-29.md`** — Daily reflection:
|
|
239
|
+
```markdown
|
|
240
|
+
## What Changed
|
|
241
|
+
The user made a concrete decision to migrate from REST to gRPC.
|
|
242
|
+
They didn't just switch because gRPC is "cooler" — they followed their
|
|
243
|
+
own methodology: identified the need (streaming), evaluated tradeoffs
|
|
244
|
+
(learning cost acceptable), and planned a POC before full migration.
|
|
245
|
+
|
|
246
|
+
There's a nice parallel between their technical work and personal growth:
|
|
247
|
+
studying overconfidence bias while simultaneously being disciplined enough
|
|
248
|
+
to do a POC rather than diving in headfirst.
|
|
249
|
+
|
|
250
|
+
## No Major Entropy Issues
|
|
251
|
+
The tag naming inconsistency is already on their TODO list — user is
|
|
252
|
+
aware and will address when ready.
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**`_clear_mind/entropy_log.md`** — Entropy tracking:
|
|
256
|
+
```markdown
|
|
257
|
+
## 2026-03-29: Tag Naming Inconsistency (Already Logged)
|
|
258
|
+
User noted tag system has mixed Chinese/English naming conventions.
|
|
259
|
+
Already on their TODO list. No action needed from agent.
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Chat: Interactive Q&A
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
You: 请读一下 daily/2026-03-29.md 然后告诉我你了解到了什么
|
|
266
|
+
|
|
267
|
+
Clear Mind: 从这篇日记中我了解到:
|
|
268
|
+
• 决定在项目里用 gRPC 替换 REST,因为流式 API 能解决实时推送的需求
|
|
269
|
+
• 在整理 Obsidian 的标签系统,发现了中英文混用的问题
|
|
270
|
+
• 计划读《系统之美》第三章
|
|
271
|
+
|
|
272
|
+
看起来你今天做了两个重要的决定:技术架构升级和知识管理系统优化。
|
|
273
|
+
这两个都是熵减的好方向!
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Clear Mind vs Claude Code + Obsidian
|
|
277
|
+
|
|
278
|
+
| | Clear Mind | Claude Code + Obsidian |
|
|
279
|
+
|---|---|---|
|
|
280
|
+
| **Runtime** | Standalone CLI agent, runs locally or as a daemon | IDE extension, requires editor session |
|
|
281
|
+
| **LLM** | Local-first (LM Studio, Ollama) | Cloud API (Anthropic, OpenAI) |
|
|
282
|
+
| **Obsidian integration** | Purpose-built Obsidian CLI tools (14 tools) | Generic file read/write |
|
|
283
|
+
| **Write boundary** | Hard enforced: agent can only write to `_clear_mind/` | No boundary: can write anywhere |
|
|
284
|
+
| **Heartbeat** | Built-in: detects vault changes, runs automatically | No automatic scanning |
|
|
285
|
+
| **State** | Persistent across sessions (SQLite checkpointer) | Per-session, no cross-session memory |
|
|
286
|
+
| **Cost** | Zero after setup (local model) | Per-token API cost |
|
|
287
|
+
|
|
288
|
+
## Architecture
|
|
289
|
+
|
|
290
|
+
```
|
|
291
|
+
clear_mind/
|
|
292
|
+
├── cli.py Typer CLI (init, chat, heartbeat, serve, doctor)
|
|
293
|
+
├── agent.py DeepAgents SDK agent assembly
|
|
294
|
+
├── obsidian.py Obsidian CLI tools (14 tools: read, search, write...)
|
|
295
|
+
├── config.py pydantic-settings configuration
|
|
296
|
+
├── heartbeat.py Vault change scanning + scheduling
|
|
297
|
+
└── prompts.py System prompts (identity, boundaries, heartbeat)
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
The agent is assembled with [DeepAgents SDK](https://github.com/langchain-ai/deepagents) on top of [LangGraph](https://github.com/langchain-ai/langgraph), using a SQLite checkpointer for state persistence across sessions.
|
|
301
|
+
|
|
302
|
+
## License
|
|
303
|
+
|
|
304
|
+
MIT
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="banner.png" alt="Clear Mind Banner" width="100%">
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
# Clear Mind
|
|
6
|
+
|
|
7
|
+
[中文文档](README_CN.md)
|
|
8
|
+
|
|
9
|
+
<div align="center">
|
|
10
|
+
<img src="guide.gif" alt="Clear Mind Demo" width="100%">
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
**You and an AI co-manage one Obsidian vault — with crystal-clear boundaries.**
|
|
14
|
+
|
|
15
|
+
Clear Mind reads your notes, understands who you are, and grows alongside you. It remembers your patterns, tracks your growth, and suggests entropy reduction. But it **never touches your notes** — all its writing is confined to its own folder, enforced at the code level.
|
|
16
|
+
|
|
17
|
+
This is not another AI that dumps files into your vault. Clear Mind is a disciplined co-manager that knows its place.
|
|
18
|
+
|
|
19
|
+
## Core Philosophy: Co-manage, Don't Pollute
|
|
20
|
+
|
|
21
|
+
Most AI tools write files everywhere, cluttering your carefully curated vault. Clear Mind is different:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
Your Obsidian Vault
|
|
25
|
+
├── daily-notes/ ← Your notes. Sacred. Read-only for the agent.
|
|
26
|
+
├── projects/ ← The agent observes, understands, but NEVER modifies.
|
|
27
|
+
├── ideas/ ← Your creative space remains yours.
|
|
28
|
+
│
|
|
29
|
+
└── _clear_mind/ ← Agent's space. Only here it writes.
|
|
30
|
+
├── about_user.md Growing understanding of you
|
|
31
|
+
├── entropy_log.md Entropy reduction observations
|
|
32
|
+
├── reflections/ Daily reflections on what changed
|
|
33
|
+
└── ...
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**The boundary is not just a prompt — it's enforced in code:**
|
|
37
|
+
|
|
38
|
+
- `write_agent_note` and `append_agent_note` validate the path starts with `_clear_mind/`
|
|
39
|
+
- Path traversal attempts are blocked (`../../etc/passwd` → rejected)
|
|
40
|
+
- The agent has zero write tools that operate outside `_clear_mind/`
|
|
41
|
+
- Even if the LLM "decides" to write elsewhere, the tool layer refuses
|
|
42
|
+
|
|
43
|
+
**What the agent DOES do:**
|
|
44
|
+
|
|
45
|
+
- Read your notes to understand your thinking, projects, and patterns
|
|
46
|
+
- Build a growing profile in `_clear_mind/about_user.md` — so it remembers you across sessions
|
|
47
|
+
- Write daily reflections in `_clear_mind/reflections/` — tracking what changed and what it means
|
|
48
|
+
- Log entropy reduction opportunities in `_clear_mind/entropy_log.md` — suggestions, never actions
|
|
49
|
+
|
|
50
|
+
**What the agent NEVER does:**
|
|
51
|
+
|
|
52
|
+
- Modify, delete, or rearrange your notes
|
|
53
|
+
- Create files outside `_clear_mind/`
|
|
54
|
+
- Act on suggestions without your explicit consent
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
- **Local-first** — runs on LM Studio, Ollama, or any OpenAI-compatible API. Zero cloud dependency.
|
|
59
|
+
- **Obsidian CLI integration** — uses the official Obsidian CLI (v1.12+) for all vault operations
|
|
60
|
+
- **Hard boundary enforcement** — the agent physically cannot write outside `_clear_mind/`, enforced at the tool level, not just the prompt
|
|
61
|
+
- **Heartbeat monitoring** — daily vault change detection with zero token cost when nothing changed
|
|
62
|
+
- **Incremental growth** — `about_user.md` grows with every interaction, building real institutional memory
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
### Prerequisites
|
|
67
|
+
|
|
68
|
+
- Python 3.12+
|
|
69
|
+
- [Obsidian](https://obsidian.md) desktop app running (v1.12+ with CLI enabled)
|
|
70
|
+
- A local LLM server (e.g. [LM Studio](https://lmstudio.ai), [Ollama](https://ollama.com))
|
|
71
|
+
|
|
72
|
+
### Install
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install clear-mind
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Setup
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
clear-mind init
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Interactive setup will ask for:
|
|
85
|
+
1. Your Obsidian vault path
|
|
86
|
+
2. LLM API base URL (default: `http://localhost:1234/v1`)
|
|
87
|
+
3. API key (default: `lm-studio`)
|
|
88
|
+
4. Model name (default: `qwen3.5-9b`)
|
|
89
|
+
|
|
90
|
+
This creates a `.env` file and initializes the `_clear_mind/` folder in your vault.
|
|
91
|
+
|
|
92
|
+
#### Example: LM Studio with Qwen 3.5
|
|
93
|
+
|
|
94
|
+
1. Download [LM Studio](https://lmstudio.ai), search and load `unsloth/qwen3.5-35b-a3b`
|
|
95
|
+
2. Start the local server (default port 1234)
|
|
96
|
+
3. Run:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
clear-mind init
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
When prompted:
|
|
103
|
+
```
|
|
104
|
+
Obsidian vault path: /Users/you/MyVault
|
|
105
|
+
LLM base URL [http://localhost:1234/v1]: ← press Enter
|
|
106
|
+
API key [lm-studio]: ← press Enter
|
|
107
|
+
Model name [qwen3.5-9b]: unsloth/qwen3.5-35b-a3b
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Or configure via `.env` directly:
|
|
111
|
+
|
|
112
|
+
```env
|
|
113
|
+
CLEAR_MIND_VAULT_PATH=/Users/you/MyVault
|
|
114
|
+
CLEAR_MIND_BASE_URL=http://localhost:1234/v1
|
|
115
|
+
CLEAR_MIND_API_KEY=lm-studio
|
|
116
|
+
CLEAR_MIND_MODEL_NAME=unsloth/qwen3.5-35b-a3b
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Then start chatting:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
clear-mind chat
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Chat
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
clear-mind chat
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Start an interactive conversation. The agent can read your notes, search your vault, and write reflections — but only within its own folder.
|
|
132
|
+
|
|
133
|
+
### Heartbeat
|
|
134
|
+
|
|
135
|
+
Single run (e.g. via cron):
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
clear-mind heartbeat
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Long-running daemon:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
clear-mind serve
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The heartbeat scans for vault changes since the last run. If nothing changed, it exits immediately (zero token cost). If changes are detected, the agent reads the changed notes and updates its understanding.
|
|
148
|
+
|
|
149
|
+
### Diagnose
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
clear-mind doctor
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Checks your configuration, vault structure, Obsidian CLI availability, and model connection.
|
|
156
|
+
|
|
157
|
+
## Configuration
|
|
158
|
+
|
|
159
|
+
All settings are loaded from a `.env` file or environment variables with the `CLEAR_MIND_` prefix:
|
|
160
|
+
|
|
161
|
+
| Variable | Default | Description |
|
|
162
|
+
|---|---|---|
|
|
163
|
+
| `CLEAR_MIND_VAULT_PATH` | *(required)* | Path to your Obsidian vault |
|
|
164
|
+
| `CLEAR_MIND_BASE_URL` | `http://localhost:1234/v1` | LLM API base URL |
|
|
165
|
+
| `CLEAR_MIND_API_KEY` | `lm-studio` | API key |
|
|
166
|
+
| `CLEAR_MIND_MODEL_NAME` | `qwen3.5-9b` | Model to use |
|
|
167
|
+
| `CLEAR_MIND_HEARTBEAT_CRON` | `0 9 * * *` | Heartbeat schedule (daily at 9am) |
|
|
168
|
+
| `CLEAR_MIND_CHECKPOINTER_PATH` | `~/_clear_mind_state/checkpoints.db` | State persistence path |
|
|
169
|
+
|
|
170
|
+
## Real-World Example
|
|
171
|
+
|
|
172
|
+
The following is actual output from Clear Mind running with LM Studio + `unsloth/qwen3.5-35b-a3b` on a test vault with 4 notes.
|
|
173
|
+
|
|
174
|
+
### Heartbeat: Automatic Reflection
|
|
175
|
+
|
|
176
|
+
Your notes in the vault:
|
|
177
|
+
```markdown
|
|
178
|
+
daily/2026-03-28.md — "今天开始研究 gRPC,感觉流式传输比 REST 优雅很多。下周做 POC。
|
|
179
|
+
读了《思考快与慢》第 12 章,关于过度自信的偏见。"
|
|
180
|
+
daily/2026-03-29.md — "决定在项目里用 gRPC 替换 REST。流式 API 正好解决了实时推送的需求。
|
|
181
|
+
发现 Obsidian 标签命名不一致,需要统一。"
|
|
182
|
+
|
|
183
|
+
projects/distributed-system.md — notes on CAP theorem, Raft/Paxos, message queues
|
|
184
|
+
projects/decision-framework.md — methodology: boundaries → options → score → POC → rollback
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
After `clear-mind heartbeat`, the agent reads all changed notes and writes:
|
|
188
|
+
|
|
189
|
+
**`_clear_mind/about_user.md`** — Evolving user profile:
|
|
190
|
+
```markdown
|
|
191
|
+
## Technical Focus
|
|
192
|
+
- Studying distributed systems: CAP theorem, consistency models, consensus algorithms
|
|
193
|
+
- Currently focused on gRPC for microservices, particularly streaming RPC
|
|
194
|
+
- Decided to replace REST with gRPC due to real-time push requirements
|
|
195
|
+
- Uses a structured decision framework: define boundaries → list options → score → POC → rollback
|
|
196
|
+
|
|
197
|
+
## Learning Habits
|
|
198
|
+
- Self-reflective about cognitive biases in coding ("this is simple" leading to debugging hell)
|
|
199
|
+
- Plans POCs before full adoption
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**`_clear_mind/reflections/2026-03-29.md`** — Daily reflection:
|
|
203
|
+
```markdown
|
|
204
|
+
## What Changed
|
|
205
|
+
The user made a concrete decision to migrate from REST to gRPC.
|
|
206
|
+
They didn't just switch because gRPC is "cooler" — they followed their
|
|
207
|
+
own methodology: identified the need (streaming), evaluated tradeoffs
|
|
208
|
+
(learning cost acceptable), and planned a POC before full migration.
|
|
209
|
+
|
|
210
|
+
There's a nice parallel between their technical work and personal growth:
|
|
211
|
+
studying overconfidence bias while simultaneously being disciplined enough
|
|
212
|
+
to do a POC rather than diving in headfirst.
|
|
213
|
+
|
|
214
|
+
## No Major Entropy Issues
|
|
215
|
+
The tag naming inconsistency is already on their TODO list — user is
|
|
216
|
+
aware and will address when ready.
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**`_clear_mind/entropy_log.md`** — Entropy tracking:
|
|
220
|
+
```markdown
|
|
221
|
+
## 2026-03-29: Tag Naming Inconsistency (Already Logged)
|
|
222
|
+
User noted tag system has mixed Chinese/English naming conventions.
|
|
223
|
+
Already on their TODO list. No action needed from agent.
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Chat: Interactive Q&A
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
You: 请读一下 daily/2026-03-29.md 然后告诉我你了解到了什么
|
|
230
|
+
|
|
231
|
+
Clear Mind: 从这篇日记中我了解到:
|
|
232
|
+
• 决定在项目里用 gRPC 替换 REST,因为流式 API 能解决实时推送的需求
|
|
233
|
+
• 在整理 Obsidian 的标签系统,发现了中英文混用的问题
|
|
234
|
+
• 计划读《系统之美》第三章
|
|
235
|
+
|
|
236
|
+
看起来你今天做了两个重要的决定:技术架构升级和知识管理系统优化。
|
|
237
|
+
这两个都是熵减的好方向!
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Clear Mind vs Claude Code + Obsidian
|
|
241
|
+
|
|
242
|
+
| | Clear Mind | Claude Code + Obsidian |
|
|
243
|
+
|---|---|---|
|
|
244
|
+
| **Runtime** | Standalone CLI agent, runs locally or as a daemon | IDE extension, requires editor session |
|
|
245
|
+
| **LLM** | Local-first (LM Studio, Ollama) | Cloud API (Anthropic, OpenAI) |
|
|
246
|
+
| **Obsidian integration** | Purpose-built Obsidian CLI tools (14 tools) | Generic file read/write |
|
|
247
|
+
| **Write boundary** | Hard enforced: agent can only write to `_clear_mind/` | No boundary: can write anywhere |
|
|
248
|
+
| **Heartbeat** | Built-in: detects vault changes, runs automatically | No automatic scanning |
|
|
249
|
+
| **State** | Persistent across sessions (SQLite checkpointer) | Per-session, no cross-session memory |
|
|
250
|
+
| **Cost** | Zero after setup (local model) | Per-token API cost |
|
|
251
|
+
|
|
252
|
+
## Architecture
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
clear_mind/
|
|
256
|
+
├── cli.py Typer CLI (init, chat, heartbeat, serve, doctor)
|
|
257
|
+
├── agent.py DeepAgents SDK agent assembly
|
|
258
|
+
├── obsidian.py Obsidian CLI tools (14 tools: read, search, write...)
|
|
259
|
+
├── config.py pydantic-settings configuration
|
|
260
|
+
├── heartbeat.py Vault change scanning + scheduling
|
|
261
|
+
└── prompts.py System prompts (identity, boundaries, heartbeat)
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
The agent is assembled with [DeepAgents SDK](https://github.com/langchain-ai/deepagents) on top of [LangGraph](https://github.com/langchain-ai/langgraph), using a SQLite checkpointer for state persistence across sessions.
|
|
265
|
+
|
|
266
|
+
## License
|
|
267
|
+
|
|
268
|
+
MIT
|