erudition-mcp 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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ralf090102
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,207 @@
1
+ Metadata-Version: 2.4
2
+ Name: erudition-mcp
3
+ Version: 0.1.0
4
+ Summary: Portable, typed, git-friendly memory for AI agents: an MCP server over a markdown vault.
5
+ Author: Ralf090102
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Ralf090102/Erudition
8
+ Project-URL: Repository, https://github.com/Ralf090102/Erudition
9
+ Project-URL: Issues, https://github.com/Ralf090102/Erudition/issues
10
+ Keywords: mcp,model-context-protocol,claude,agent-memory,markdown,obsidian
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: mcp<2.0.0,>=1.0.0
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=7.0; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # Erudition
28
+
29
+ Portable, typed, git-friendly memory for AI agents.
30
+
31
+ Claude Code's built-in memory is local-only and opaque. It lives inside Claude Code itself, isn't portable across machines, and isn't something you can casually read, diff, or edit by hand. Erudition is an [MCP](https://modelcontextprotocol.io) server that gives an agent read/write access to a memory store that's none of those things: a plain folder of markdown files, organized around a real taxonomy instead of a junk drawer, editable in whatever notes app you already use, and portable across every machine you own via git.
32
+
33
+ This README covers what Erudition does and how to install it. For the reasoning behind why it's built this way, and just as importantly, why it isn't built several other, more obvious ways, see [WHY.md](./WHY.md).
34
+
35
+ ## What it is
36
+
37
+ - **An MCP server.** Works with Claude Code, Claude Desktop, or any other MCP-compatible client, exposing nine tools (see [Tools](#tools) below).
38
+ - **A markdown vault, not a database.** Every memory is a `.md` file with YAML frontmatter, in a folder you fully control. No proprietary format, no service to run, no account to create. Obsidian is a good viewer/editor for it, but Erudition doesn't require Obsidian. Any plain-text editor works.
39
+ - **A taxonomy, not a junk drawer.** Memories are typed (`user` / `feedback` / `project` / `reference` by default), so an agent (and you) can tell "a fact about how I like to work" apart from "a fact about this specific project" at a glance.
40
+
41
+ ## What it isn't
42
+
43
+ - Not a hosted product. It runs locally, wherever your agent runs.
44
+ - Not a "chat with your notes" RAG plugin. Erudition is about agent *memory* (what an agent should remember across sessions), not general document search.
45
+ - Not a replacement for Claude Code (or Claude Code's own memory). It's a layer on top, and it's designed to stay small rather than grow into a competing agent runtime.
46
+
47
+ ## Quickstart
48
+
49
+ ### 1. Install
50
+
51
+ ```bash
52
+ git clone https://github.com/Ralf090102/Erudition.git
53
+ cd Erudition
54
+ pip install -e .
55
+ ```
56
+
57
+ This installs the `erudition` command (the PyPI distribution is named `erudition-mcp`; the import path and CLI command stay `erudition`).
58
+
59
+ ### 2. Point it at a vault
60
+
61
+ Erudition needs to know which folder is your vault:
62
+
63
+ ```bash
64
+ export ERUDITION_VAULT_PATH="/path/to/my-notes"
65
+ ```
66
+
67
+ That's a complete, valid setup on its own. If you want the auto-commit toggle or a custom taxonomy, write an `erudition.toml` instead (or alongside). Copy [`erudition.example.toml`](./erudition.example.toml) and see the [Configuration](#configuration) table below for every option.
68
+
69
+ ### 3. Connect it to your MCP client
70
+
71
+ For Claude Code, add it to your MCP server config:
72
+
73
+ ```json
74
+ {
75
+ "mcpServers": {
76
+ "erudition": {
77
+ "command": "erudition",
78
+ "env": {
79
+ "ERUDITION_VAULT_PATH": "/path/to/my-notes"
80
+ }
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ Restart your client. You should see all nine tools below available.
87
+
88
+ Erudition keeps a small search index at `{vault}/.erudition/`. It's a rebuildable cache, not real content, so add `.erudition/` to the vault's own `.gitignore`.
89
+
90
+ ## Tools
91
+
92
+ | Tool | What it does |
93
+ |---|---|
94
+ | `read_note(path)` | Read a note's contents. |
95
+ | `list_notes(folder="")` | List markdown notes in a folder, recursively (empty string lists the whole vault). |
96
+ | `search_notes(query, folder="")` | Search note contents, backed by a rebuildable SQLite FTS5 index rather than a linear scan. This makes matching token-based, not raw substring: `wid*` matches "widgets," a bare `idget` doesn't the way a plain substring scan would. Supports FTS5 phrase (`"exact phrase"`) and boolean (`AND` / `OR` / `NOT`) syntax. Falls back automatically to a plain linear scan if the local `sqlite3` build lacks FTS5. Returns matching file paths and the lines that matched; if a query is still slow despite the index, the result includes a one-line note suggesting the staleness check itself might be worth revisiting. |
97
+ | `write_note(path, content, overwrite=False, dry_run=False)` | Write a note; refuses to clobber an existing one unless `overwrite=True`. `dry_run=True` writes nothing and returns a preview (new content, or a diff against what's there) instead. |
98
+ | `append_to_note(path, content, dry_run=False)` | Append to a note, creating it (and any parent folders) if it doesn't exist yet. |
99
+ | `list_memory_types()` | List the vault's configured taxonomy: valid `type` values for `save_memory`, and what each is for. |
100
+ | `save_memory(type, name, description, content, overwrite=False, dry_run=False)` | Save a typed memory (validated against the taxonomy), with standard frontmatter, indexed in `MEMORY.md`. |
101
+ | `sync_memory()` | Mirror the vault's memory folder out to a configured local memory directory. |
102
+ | `rebuild_search_index()` | Force a full rebuild of the search index from scratch. Rarely needed, since `search_notes` already self-heals from a cheap per-search staleness check; mostly a manual escape hatch for recovery or peace of mind after a large batch of external edits. |
103
+
104
+ ## The taxonomy
105
+
106
+ Erudition's default memory types, and what each is for:
107
+
108
+ | Type | What goes here |
109
+ |---|---|
110
+ | `user` | Who the person is: their role, goals, expertise. Lets an agent tailor how it explains things. |
111
+ | `feedback` | Corrections and confirmed approaches, like "don't do X, we tried it and it broke Y" or "yes, that approach was right." Stops an agent from repeating a mistake or re-litigating a settled call. |
112
+ | `project` | Ongoing context about *why* (decisions, deadlines, stakeholders) that isn't visible in the code or git history alone. |
113
+ | `reference` | Pointers to where information actually lives, e.g. "bugs are tracked in Linear project X," not a copy of the bugs themselves. |
114
+
115
+ This is a starting point, not a fixed schema. Define your own types under `[taxonomy.*]` in `erudition.toml` if your vault needs a different shape. See `erudition.example.toml`.
116
+
117
+ ## Saving and syncing memories
118
+
119
+ Beyond generic `write_note`, Erudition understands the taxonomy. `save_memory` validates the `type` you pass against the vault's configured types, writes the memory to `Memory/{type}_{slug}.md` with standard frontmatter, and keeps `Memory/MEMORY.md` as a lightweight index, one line per memory:
120
+
121
+ ```python
122
+ save_memory(
123
+ type="feedback",
124
+ name="Prefers terse commit messages",
125
+ description="User wants one-line commit messages, no bullet lists.",
126
+ content="Confirmed after three separate corrections. Applies to this repo only.",
127
+ )
128
+ ```
129
+
130
+ If your agent also keeps its own local memory folder (Claude Code does), `sync_memory()` mirrors everything under the vault's memory folder out to it, so writing a memory once in the vault doesn't also require a manual second write elsewhere. Configure the destination via `local_memory_dir` (see Configuration below). `sync_memory()` errors clearly if it isn't set, rather than silently doing nothing.
131
+
132
+ ## Write safety: a permanent design choice, not a limitation
133
+
134
+ Erudition assumes **one active writer at a time.** Flat markdown files have no locking, so if a human and an agent (or two agent sessions) write to the same note within moments of each other, the later write silently wins. No merge, no conflict marker, no error.
135
+
136
+ This is deliberate, not an oversight. Closing that gap completely would mean row-level locking, which means becoming a database. That trades away the one thing that makes a markdown vault worth using over a SQLite-backed alternative: you can open, read, and edit every memory in any plain-text editor, no tooling required. Instead, Erudition offers durability without locking: an optional `auto_commit` setting that git-commits every write with a distinct, identifiable message (`erudition: write <path>`). It doesn't prevent a collision, but it means a collision is always recoverable via `git log` / `git diff` instead of silently gone.
137
+
138
+ If you run more than one agent session against the same vault at the same time, that's exactly the scenario this boundary is about. Treat "one writer at a time" as a real constraint, the same way you would with any file two processes might edit concurrently.
139
+
140
+ Separately from durability, `write_note`, `append_to_note`, and `save_memory` all accept `dry_run=True`: nothing gets written, and you get back a preview instead, either the full content for a brand-new note, or a unified diff against what's already there for an overwrite. Useful for checking what a change would actually do before committing to it, especially with `overwrite=True`.
141
+
142
+ ## Optional: Claude Code hook integration
143
+
144
+ This is Claude-Code-specific and entirely optional — it's a companion to the core MCP server above, not a change to it, and it doesn't do anything with other MCP clients. If you don't use Claude Code, skip this section.
145
+
146
+ Two problems this solves: remembering to read a "where we left off" note at the start of every session, and remembering to call `sync_memory()` after making changes. Claude Code has its own hook system (separate from MCP) for exactly this: `SessionStart` can inject context automatically when a session begins, and `Stop` runs after every turn.
147
+
148
+ Add this to your project's `.claude/settings.json`:
149
+
150
+ ```json
151
+ {
152
+ "hooks": {
153
+ "SessionStart": [
154
+ {
155
+ "matcher": "*",
156
+ "hooks": [
157
+ {
158
+ "type": "command",
159
+ "command": "erudition hook session-start"
160
+ }
161
+ ]
162
+ }
163
+ ],
164
+ "Stop": [
165
+ {
166
+ "hooks": [
167
+ {
168
+ "type": "command",
169
+ "command": "erudition hook stop"
170
+ }
171
+ ]
172
+ }
173
+ ]
174
+ }
175
+ }
176
+ ```
177
+
178
+ `erudition hook session-start` reads the note at `session_start_note` (defaults to `Memory/CURRENT.md`; see [Configuration](#configuration)) and injects its contents as session context. `erudition hook stop` calls `sync_memory()`. Both are best-effort: a missing note or an unconfigured `sync_memory` is a silent no-op, never an error that could block a session or a turn.
179
+
180
+ ## Configuration
181
+
182
+ | Setting | Env var | `erudition.toml` key | Default |
183
+ |---|---|---|---|
184
+ | Vault path | `ERUDITION_VAULT_PATH` | `vault_path` | *(required, one or the other)* |
185
+ | Auto-commit on write | `ERUDITION_AUTO_COMMIT` | `auto_commit` | `false` |
186
+ | Memory taxonomy | — | `[taxonomy.*]` | the four types above |
187
+ | Memory folder | `ERUDITION_MEMORY_FOLDER` | `memory_folder` | `Memory` |
188
+ | Local memory mirror (for `sync_memory`) | `ERUDITION_LOCAL_MEMORY_DIR` | `local_memory_dir` | unset |
189
+ | Session-start note (for the optional hook) | `ERUDITION_SESSION_START_NOTE` | `session_start_note` | `Memory/CURRENT.md` |
190
+ | Config file location | `ERUDITION_CONFIG` | — | `./erudition.toml` if present |
191
+
192
+ An env var always wins over the config file for the setting it covers. Full example with every option: [`erudition.example.toml`](./erudition.example.toml).
193
+
194
+ ## Development
195
+
196
+ ```bash
197
+ pip install -e ".[dev]"
198
+ pytest
199
+ ```
200
+
201
+ ## Status
202
+
203
+ Early stage. Config-driven vault path, generalized taxonomy, the write-safety toggle (including dry-run previews), the taxonomy-aware memory tools (`save_memory`, `sync_memory`, `list_memory_types`, `append_to_note`), a rebuildable FTS5 search index, and a real, repo-tracked test suite are all done. Not yet on PyPI. Expect breaking changes before a 1.0 release.
204
+
205
+ ## License
206
+
207
+ MIT. See [LICENSE](./LICENSE).
@@ -0,0 +1,181 @@
1
+ # Erudition
2
+
3
+ Portable, typed, git-friendly memory for AI agents.
4
+
5
+ Claude Code's built-in memory is local-only and opaque. It lives inside Claude Code itself, isn't portable across machines, and isn't something you can casually read, diff, or edit by hand. Erudition is an [MCP](https://modelcontextprotocol.io) server that gives an agent read/write access to a memory store that's none of those things: a plain folder of markdown files, organized around a real taxonomy instead of a junk drawer, editable in whatever notes app you already use, and portable across every machine you own via git.
6
+
7
+ This README covers what Erudition does and how to install it. For the reasoning behind why it's built this way, and just as importantly, why it isn't built several other, more obvious ways, see [WHY.md](./WHY.md).
8
+
9
+ ## What it is
10
+
11
+ - **An MCP server.** Works with Claude Code, Claude Desktop, or any other MCP-compatible client, exposing nine tools (see [Tools](#tools) below).
12
+ - **A markdown vault, not a database.** Every memory is a `.md` file with YAML frontmatter, in a folder you fully control. No proprietary format, no service to run, no account to create. Obsidian is a good viewer/editor for it, but Erudition doesn't require Obsidian. Any plain-text editor works.
13
+ - **A taxonomy, not a junk drawer.** Memories are typed (`user` / `feedback` / `project` / `reference` by default), so an agent (and you) can tell "a fact about how I like to work" apart from "a fact about this specific project" at a glance.
14
+
15
+ ## What it isn't
16
+
17
+ - Not a hosted product. It runs locally, wherever your agent runs.
18
+ - Not a "chat with your notes" RAG plugin. Erudition is about agent *memory* (what an agent should remember across sessions), not general document search.
19
+ - Not a replacement for Claude Code (or Claude Code's own memory). It's a layer on top, and it's designed to stay small rather than grow into a competing agent runtime.
20
+
21
+ ## Quickstart
22
+
23
+ ### 1. Install
24
+
25
+ ```bash
26
+ git clone https://github.com/Ralf090102/Erudition.git
27
+ cd Erudition
28
+ pip install -e .
29
+ ```
30
+
31
+ This installs the `erudition` command (the PyPI distribution is named `erudition-mcp`; the import path and CLI command stay `erudition`).
32
+
33
+ ### 2. Point it at a vault
34
+
35
+ Erudition needs to know which folder is your vault:
36
+
37
+ ```bash
38
+ export ERUDITION_VAULT_PATH="/path/to/my-notes"
39
+ ```
40
+
41
+ That's a complete, valid setup on its own. If you want the auto-commit toggle or a custom taxonomy, write an `erudition.toml` instead (or alongside). Copy [`erudition.example.toml`](./erudition.example.toml) and see the [Configuration](#configuration) table below for every option.
42
+
43
+ ### 3. Connect it to your MCP client
44
+
45
+ For Claude Code, add it to your MCP server config:
46
+
47
+ ```json
48
+ {
49
+ "mcpServers": {
50
+ "erudition": {
51
+ "command": "erudition",
52
+ "env": {
53
+ "ERUDITION_VAULT_PATH": "/path/to/my-notes"
54
+ }
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ Restart your client. You should see all nine tools below available.
61
+
62
+ Erudition keeps a small search index at `{vault}/.erudition/`. It's a rebuildable cache, not real content, so add `.erudition/` to the vault's own `.gitignore`.
63
+
64
+ ## Tools
65
+
66
+ | Tool | What it does |
67
+ |---|---|
68
+ | `read_note(path)` | Read a note's contents. |
69
+ | `list_notes(folder="")` | List markdown notes in a folder, recursively (empty string lists the whole vault). |
70
+ | `search_notes(query, folder="")` | Search note contents, backed by a rebuildable SQLite FTS5 index rather than a linear scan. This makes matching token-based, not raw substring: `wid*` matches "widgets," a bare `idget` doesn't the way a plain substring scan would. Supports FTS5 phrase (`"exact phrase"`) and boolean (`AND` / `OR` / `NOT`) syntax. Falls back automatically to a plain linear scan if the local `sqlite3` build lacks FTS5. Returns matching file paths and the lines that matched; if a query is still slow despite the index, the result includes a one-line note suggesting the staleness check itself might be worth revisiting. |
71
+ | `write_note(path, content, overwrite=False, dry_run=False)` | Write a note; refuses to clobber an existing one unless `overwrite=True`. `dry_run=True` writes nothing and returns a preview (new content, or a diff against what's there) instead. |
72
+ | `append_to_note(path, content, dry_run=False)` | Append to a note, creating it (and any parent folders) if it doesn't exist yet. |
73
+ | `list_memory_types()` | List the vault's configured taxonomy: valid `type` values for `save_memory`, and what each is for. |
74
+ | `save_memory(type, name, description, content, overwrite=False, dry_run=False)` | Save a typed memory (validated against the taxonomy), with standard frontmatter, indexed in `MEMORY.md`. |
75
+ | `sync_memory()` | Mirror the vault's memory folder out to a configured local memory directory. |
76
+ | `rebuild_search_index()` | Force a full rebuild of the search index from scratch. Rarely needed, since `search_notes` already self-heals from a cheap per-search staleness check; mostly a manual escape hatch for recovery or peace of mind after a large batch of external edits. |
77
+
78
+ ## The taxonomy
79
+
80
+ Erudition's default memory types, and what each is for:
81
+
82
+ | Type | What goes here |
83
+ |---|---|
84
+ | `user` | Who the person is: their role, goals, expertise. Lets an agent tailor how it explains things. |
85
+ | `feedback` | Corrections and confirmed approaches, like "don't do X, we tried it and it broke Y" or "yes, that approach was right." Stops an agent from repeating a mistake or re-litigating a settled call. |
86
+ | `project` | Ongoing context about *why* (decisions, deadlines, stakeholders) that isn't visible in the code or git history alone. |
87
+ | `reference` | Pointers to where information actually lives, e.g. "bugs are tracked in Linear project X," not a copy of the bugs themselves. |
88
+
89
+ This is a starting point, not a fixed schema. Define your own types under `[taxonomy.*]` in `erudition.toml` if your vault needs a different shape. See `erudition.example.toml`.
90
+
91
+ ## Saving and syncing memories
92
+
93
+ Beyond generic `write_note`, Erudition understands the taxonomy. `save_memory` validates the `type` you pass against the vault's configured types, writes the memory to `Memory/{type}_{slug}.md` with standard frontmatter, and keeps `Memory/MEMORY.md` as a lightweight index, one line per memory:
94
+
95
+ ```python
96
+ save_memory(
97
+ type="feedback",
98
+ name="Prefers terse commit messages",
99
+ description="User wants one-line commit messages, no bullet lists.",
100
+ content="Confirmed after three separate corrections. Applies to this repo only.",
101
+ )
102
+ ```
103
+
104
+ If your agent also keeps its own local memory folder (Claude Code does), `sync_memory()` mirrors everything under the vault's memory folder out to it, so writing a memory once in the vault doesn't also require a manual second write elsewhere. Configure the destination via `local_memory_dir` (see Configuration below). `sync_memory()` errors clearly if it isn't set, rather than silently doing nothing.
105
+
106
+ ## Write safety: a permanent design choice, not a limitation
107
+
108
+ Erudition assumes **one active writer at a time.** Flat markdown files have no locking, so if a human and an agent (or two agent sessions) write to the same note within moments of each other, the later write silently wins. No merge, no conflict marker, no error.
109
+
110
+ This is deliberate, not an oversight. Closing that gap completely would mean row-level locking, which means becoming a database. That trades away the one thing that makes a markdown vault worth using over a SQLite-backed alternative: you can open, read, and edit every memory in any plain-text editor, no tooling required. Instead, Erudition offers durability without locking: an optional `auto_commit` setting that git-commits every write with a distinct, identifiable message (`erudition: write <path>`). It doesn't prevent a collision, but it means a collision is always recoverable via `git log` / `git diff` instead of silently gone.
111
+
112
+ If you run more than one agent session against the same vault at the same time, that's exactly the scenario this boundary is about. Treat "one writer at a time" as a real constraint, the same way you would with any file two processes might edit concurrently.
113
+
114
+ Separately from durability, `write_note`, `append_to_note`, and `save_memory` all accept `dry_run=True`: nothing gets written, and you get back a preview instead, either the full content for a brand-new note, or a unified diff against what's already there for an overwrite. Useful for checking what a change would actually do before committing to it, especially with `overwrite=True`.
115
+
116
+ ## Optional: Claude Code hook integration
117
+
118
+ This is Claude-Code-specific and entirely optional — it's a companion to the core MCP server above, not a change to it, and it doesn't do anything with other MCP clients. If you don't use Claude Code, skip this section.
119
+
120
+ Two problems this solves: remembering to read a "where we left off" note at the start of every session, and remembering to call `sync_memory()` after making changes. Claude Code has its own hook system (separate from MCP) for exactly this: `SessionStart` can inject context automatically when a session begins, and `Stop` runs after every turn.
121
+
122
+ Add this to your project's `.claude/settings.json`:
123
+
124
+ ```json
125
+ {
126
+ "hooks": {
127
+ "SessionStart": [
128
+ {
129
+ "matcher": "*",
130
+ "hooks": [
131
+ {
132
+ "type": "command",
133
+ "command": "erudition hook session-start"
134
+ }
135
+ ]
136
+ }
137
+ ],
138
+ "Stop": [
139
+ {
140
+ "hooks": [
141
+ {
142
+ "type": "command",
143
+ "command": "erudition hook stop"
144
+ }
145
+ ]
146
+ }
147
+ ]
148
+ }
149
+ }
150
+ ```
151
+
152
+ `erudition hook session-start` reads the note at `session_start_note` (defaults to `Memory/CURRENT.md`; see [Configuration](#configuration)) and injects its contents as session context. `erudition hook stop` calls `sync_memory()`. Both are best-effort: a missing note or an unconfigured `sync_memory` is a silent no-op, never an error that could block a session or a turn.
153
+
154
+ ## Configuration
155
+
156
+ | Setting | Env var | `erudition.toml` key | Default |
157
+ |---|---|---|---|
158
+ | Vault path | `ERUDITION_VAULT_PATH` | `vault_path` | *(required, one or the other)* |
159
+ | Auto-commit on write | `ERUDITION_AUTO_COMMIT` | `auto_commit` | `false` |
160
+ | Memory taxonomy | — | `[taxonomy.*]` | the four types above |
161
+ | Memory folder | `ERUDITION_MEMORY_FOLDER` | `memory_folder` | `Memory` |
162
+ | Local memory mirror (for `sync_memory`) | `ERUDITION_LOCAL_MEMORY_DIR` | `local_memory_dir` | unset |
163
+ | Session-start note (for the optional hook) | `ERUDITION_SESSION_START_NOTE` | `session_start_note` | `Memory/CURRENT.md` |
164
+ | Config file location | `ERUDITION_CONFIG` | — | `./erudition.toml` if present |
165
+
166
+ An env var always wins over the config file for the setting it covers. Full example with every option: [`erudition.example.toml`](./erudition.example.toml).
167
+
168
+ ## Development
169
+
170
+ ```bash
171
+ pip install -e ".[dev]"
172
+ pytest
173
+ ```
174
+
175
+ ## Status
176
+
177
+ Early stage. Config-driven vault path, generalized taxonomy, the write-safety toggle (including dry-run previews), the taxonomy-aware memory tools (`save_memory`, `sync_memory`, `list_memory_types`, `append_to_note`), a rebuildable FTS5 search index, and a real, repo-tracked test suite are all done. Not yet on PyPI. Expect breaking changes before a 1.0 release.
178
+
179
+ ## License
180
+
181
+ MIT. See [LICENSE](./LICENSE).
@@ -0,0 +1,3 @@
1
+ """Erudition: portable, typed, git-friendly memory for AI agents."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,115 @@
1
+ """Configuration resolution for Erudition.
2
+
3
+ Replaces eru-mcp's hardcoded `VAULT_PATH` with env var / config file resolution,
4
+ per Erudition's Phase 1 milestone. Resolution order:
5
+
6
+ vault_path ERUDITION_VAULT_PATH env var > `vault_path` in erudition.toml
7
+ auto_commit ERUDITION_AUTO_COMMIT env var > `auto_commit` in erudition.toml > False
8
+ taxonomy `[taxonomy.*]` in erudition.toml > DEFAULT_TAXONOMY
9
+ memory_folder ERUDITION_MEMORY_FOLDER env var > `memory_folder` in erudition.toml > "Memory"
10
+ local_memory_dir ERUDITION_LOCAL_MEMORY_DIR env var > `local_memory_dir` in erudition.toml > None
11
+ session_start_note ERUDITION_SESSION_START_NOTE env var > `session_start_note` in erudition.toml > "Memory/CURRENT.md"
12
+
13
+ The config file itself is located via ERUDITION_CONFIG (explicit path), or
14
+ `erudition.toml` in the current working directory if present. Neither is
15
+ required — an env-var-only setup is valid, matching how MCP clients like
16
+ Claude Desktop/Code typically launch a server with an env block.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import os
22
+ import tomllib
23
+ from dataclasses import dataclass
24
+ from pathlib import Path
25
+
26
+ from erudition.taxonomy import MemoryType, load_taxonomy
27
+
28
+
29
+ class EruditionConfigError(RuntimeError):
30
+ """Raised when Erudition's configuration cannot be resolved."""
31
+
32
+
33
+ @dataclass(frozen=True)
34
+ class EruditionConfig:
35
+ vault_path: Path
36
+ auto_commit: bool
37
+ taxonomy: dict[str, MemoryType]
38
+ memory_folder: str
39
+ local_memory_dir: Path | None
40
+ session_start_note: str
41
+
42
+
43
+ def _find_config_file() -> Path | None:
44
+ explicit = os.environ.get("ERUDITION_CONFIG")
45
+ if explicit:
46
+ path = Path(explicit).expanduser()
47
+ if not path.is_file():
48
+ raise EruditionConfigError(f"ERUDITION_CONFIG points to a missing file: {path}")
49
+ return path
50
+
51
+ default = Path.cwd() / "erudition.toml"
52
+ return default if default.is_file() else None
53
+
54
+
55
+ def _load_toml(path: Path) -> dict:
56
+ with path.open("rb") as f:
57
+ return tomllib.load(f)
58
+
59
+
60
+ def _resolve_bool_env(name: str) -> bool | None:
61
+ raw = os.environ.get(name)
62
+ if raw is None:
63
+ return None
64
+ return raw.strip().lower() in {"1", "true", "yes", "on"}
65
+
66
+
67
+ def load_config() -> EruditionConfig:
68
+ """Resolve Erudition's configuration. Raises EruditionConfigError with a clear
69
+ message if no vault path is configured or the configured path doesn't exist.
70
+ """
71
+ config_file = _find_config_file()
72
+ file_data = _load_toml(config_file) if config_file else {}
73
+
74
+ vault_path_raw = os.environ.get("ERUDITION_VAULT_PATH") or file_data.get("vault_path")
75
+ if not vault_path_raw:
76
+ raise EruditionConfigError(
77
+ "No vault path configured. Set the ERUDITION_VAULT_PATH environment variable, "
78
+ 'or add `vault_path = "..."` to erudition.toml.'
79
+ )
80
+ vault_path = Path(vault_path_raw).expanduser().resolve()
81
+ if not vault_path.is_dir():
82
+ raise EruditionConfigError(
83
+ f"Configured vault path does not exist or is not a directory: {vault_path}"
84
+ )
85
+
86
+ env_auto_commit = _resolve_bool_env("ERUDITION_AUTO_COMMIT")
87
+ auto_commit = env_auto_commit if env_auto_commit is not None else bool(
88
+ file_data.get("auto_commit", False)
89
+ )
90
+
91
+ taxonomy = load_taxonomy(file_data.get("taxonomy"))
92
+
93
+ memory_folder = os.environ.get("ERUDITION_MEMORY_FOLDER") or file_data.get(
94
+ "memory_folder", "Memory"
95
+ )
96
+
97
+ local_memory_dir_raw = os.environ.get("ERUDITION_LOCAL_MEMORY_DIR") or file_data.get(
98
+ "local_memory_dir"
99
+ )
100
+ local_memory_dir = (
101
+ Path(local_memory_dir_raw).expanduser().resolve() if local_memory_dir_raw else None
102
+ )
103
+
104
+ session_start_note = os.environ.get("ERUDITION_SESSION_START_NOTE") or file_data.get(
105
+ "session_start_note", "Memory/CURRENT.md"
106
+ )
107
+
108
+ return EruditionConfig(
109
+ vault_path=vault_path,
110
+ auto_commit=auto_commit,
111
+ taxonomy=taxonomy,
112
+ memory_folder=memory_folder,
113
+ local_memory_dir=local_memory_dir,
114
+ session_start_note=session_start_note,
115
+ )
@@ -0,0 +1,52 @@
1
+ """Best-effort git durability for Erudition writes.
2
+
3
+ When a vault opts into `auto_commit`, every write is followed by a small,
4
+ distinctly-tagged commit — never a blocking or transactional one. A failed
5
+ commit (git not installed, vault isn't a repo, index-lock contention with
6
+ another auto-committer such as obsidian-git) must never fail or roll back
7
+ the write itself; it's surfaced as a warning string appended to the tool's
8
+ return value instead. See WHY.md's "Write safety: durability, not locking"
9
+ section for the full reasoning.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import subprocess
15
+ from pathlib import Path
16
+
17
+ _GIT_TIMEOUT_SECONDS = 10
18
+
19
+
20
+ def commit_write(vault_path: Path, vault_relative_path: str, action: str) -> str | None:
21
+ """Best-effort `git add` + `git commit` for a single written note.
22
+
23
+ Returns None on success, or a short human-readable warning string on failure.
24
+ Never raises — a broken git setup should never block a write from succeeding.
25
+ """
26
+ message = f"erudition: {action} {vault_relative_path}"
27
+ try:
28
+ add = subprocess.run(
29
+ ["git", "-C", str(vault_path), "add", "--", vault_relative_path],
30
+ capture_output=True,
31
+ text=True,
32
+ timeout=_GIT_TIMEOUT_SECONDS,
33
+ )
34
+ if add.returncode != 0:
35
+ return f"auto-commit skipped: git add failed ({add.stderr.strip() or 'unknown error'})"
36
+
37
+ commit = subprocess.run(
38
+ ["git", "-C", str(vault_path), "commit", "-m", message],
39
+ capture_output=True,
40
+ text=True,
41
+ timeout=_GIT_TIMEOUT_SECONDS,
42
+ )
43
+ if commit.returncode != 0:
44
+ stderr = commit.stderr.strip() or commit.stdout.strip() or "unknown error"
45
+ return f"auto-commit skipped: git commit failed ({stderr})"
46
+ return None
47
+ except FileNotFoundError:
48
+ return "auto-commit skipped: git is not installed or not on PATH"
49
+ except subprocess.TimeoutExpired:
50
+ return "auto-commit skipped: git command timed out (possible lock contention)"
51
+ except OSError as exc:
52
+ return f"auto-commit skipped: {exc}"