mentat-wiki 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. mentat_wiki-0.1.1/LICENSE +21 -0
  2. mentat_wiki-0.1.1/MANIFEST.in +2 -0
  3. mentat_wiki-0.1.1/PKG-INFO +320 -0
  4. mentat_wiki-0.1.1/README.md +294 -0
  5. mentat_wiki-0.1.1/mentat_wiki/__init__.py +1 -0
  6. mentat_wiki-0.1.1/mentat_wiki/__main__.py +3 -0
  7. mentat_wiki-0.1.1/mentat_wiki/checkpoint.py +112 -0
  8. mentat_wiki-0.1.1/mentat_wiki/cli.py +572 -0
  9. mentat_wiki-0.1.1/mentat_wiki/config.py +130 -0
  10. mentat_wiki-0.1.1/mentat_wiki/data/skills/idea/SKILL.md +26 -0
  11. mentat_wiki-0.1.1/mentat_wiki/data/skills/keep/SKILL.md +25 -0
  12. mentat_wiki-0.1.1/mentat_wiki/data/skills/wrap/SKILL.md +38 -0
  13. mentat_wiki-0.1.1/mentat_wiki/data/templates/AGENTS.md +10 -0
  14. mentat_wiki-0.1.1/mentat_wiki/data/templates/CLAUDE.md +136 -0
  15. mentat_wiki-0.1.1/mentat_wiki/data/templates/_templates/concept.md +26 -0
  16. mentat_wiki-0.1.1/mentat_wiki/data/templates/_templates/entity.md +22 -0
  17. mentat_wiki-0.1.1/mentat_wiki/data/templates/_templates/idea.md +22 -0
  18. mentat_wiki-0.1.1/mentat_wiki/data/templates/_templates/output.md +22 -0
  19. mentat_wiki-0.1.1/mentat_wiki/data/templates/_templates/project-decisions.md +13 -0
  20. mentat_wiki-0.1.1/mentat_wiki/data/templates/_templates/project-open-threads.md +12 -0
  21. mentat_wiki-0.1.1/mentat_wiki/data/templates/_templates/project-status.md +16 -0
  22. mentat_wiki-0.1.1/mentat_wiki/data/templates/_templates/source.md +31 -0
  23. mentat_wiki-0.1.1/mentat_wiki/data/templates/_templates/thought.md +14 -0
  24. mentat_wiki-0.1.1/mentat_wiki/data/templates/core/MEMORY.md +8 -0
  25. mentat_wiki-0.1.1/mentat_wiki/data/templates/core/SOUL.md +11 -0
  26. mentat_wiki-0.1.1/mentat_wiki/data/templates/core/USER.md +12 -0
  27. mentat_wiki-0.1.1/mentat_wiki/data/templates/core/capture-policy.md +26 -0
  28. mentat_wiki-0.1.1/mentat_wiki/digest.py +87 -0
  29. mentat_wiki-0.1.1/mentat_wiki/doctor.py +127 -0
  30. mentat_wiki-0.1.1/mentat_wiki/hook.py +116 -0
  31. mentat_wiki-0.1.1/mentat_wiki/installer.py +550 -0
  32. mentat_wiki-0.1.1/mentat_wiki/policy.py +178 -0
  33. mentat_wiki-0.1.1/mentat_wiki/search.py +223 -0
  34. mentat_wiki-0.1.1/mentat_wiki/statusline.py +78 -0
  35. mentat_wiki-0.1.1/mentat_wiki/templates.py +50 -0
  36. mentat_wiki-0.1.1/mentat_wiki/util.py +285 -0
  37. mentat_wiki-0.1.1/mentat_wiki/vault.py +708 -0
  38. mentat_wiki-0.1.1/mentat_wiki.egg-info/PKG-INFO +320 -0
  39. mentat_wiki-0.1.1/mentat_wiki.egg-info/SOURCES.txt +60 -0
  40. mentat_wiki-0.1.1/mentat_wiki.egg-info/dependency_links.txt +1 -0
  41. mentat_wiki-0.1.1/mentat_wiki.egg-info/entry_points.txt +2 -0
  42. mentat_wiki-0.1.1/mentat_wiki.egg-info/top_level.txt +1 -0
  43. mentat_wiki-0.1.1/pyproject.toml +45 -0
  44. mentat_wiki-0.1.1/setup.cfg +4 -0
  45. mentat_wiki-0.1.1/tests/test_checkpoint.py +173 -0
  46. mentat_wiki-0.1.1/tests/test_cli_polish.py +78 -0
  47. mentat_wiki-0.1.1/tests/test_cli_wave2.py +284 -0
  48. mentat_wiki-0.1.1/tests/test_concurrency.py +121 -0
  49. mentat_wiki-0.1.1/tests/test_config_safety.py +37 -0
  50. mentat_wiki-0.1.1/tests/test_demo_vault.py +27 -0
  51. mentat_wiki-0.1.1/tests/test_digest.py +39 -0
  52. mentat_wiki-0.1.1/tests/test_doctor_checks.py +112 -0
  53. mentat_wiki-0.1.1/tests/test_hardening.py +172 -0
  54. mentat_wiki-0.1.1/tests/test_hook.py +191 -0
  55. mentat_wiki-0.1.1/tests/test_installer.py +436 -0
  56. mentat_wiki-0.1.1/tests/test_mentat.py +659 -0
  57. mentat_wiki-0.1.1/tests/test_policy.py +618 -0
  58. mentat_wiki-0.1.1/tests/test_portability.py +144 -0
  59. mentat_wiki-0.1.1/tests/test_review_fixes.py +279 -0
  60. mentat_wiki-0.1.1/tests/test_search_recovery.py +431 -0
  61. mentat_wiki-0.1.1/tests/test_templates.py +247 -0
  62. mentat_wiki-0.1.1/tests/test_vault_atomicity.py +204 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mentat-wiki contributors
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,2 @@
1
+ recursive-include mentat_wiki/data *
2
+ include LICENSE README.md
@@ -0,0 +1,320 @@
1
+ Metadata-Version: 2.4
2
+ Name: mentat-wiki
3
+ Version: 0.1.1
4
+ Summary: Project continuity for LLM coding agents, kept in a local Markdown wiki.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/serhat-10/mentat-wiki
7
+ Project-URL: Issues, https://github.com/serhat-10/mentat-wiki/issues
8
+ Project-URL: Changelog, https://github.com/serhat-10/mentat-wiki/blob/main/CHANGELOG.md
9
+ Keywords: llm,claude-code,agents,knowledge-base,wiki,obsidian,markdown,memory
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development
21
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Dynamic: license-file
26
+
27
+ # mentat-wiki
28
+
29
+ **Coding agents forget where you left off when a session ends.** mentat-wiki keeps each
30
+ project's status, next step, decisions, open threads and experiment notes in a local Markdown wiki.
31
+ The next session starts with the status, open threads and recent notes loaded (decisions stay one
32
+ file away), and `/wrap` updates them before you stop.
33
+
34
+ The vault is plain Markdown, best read in Obsidian. Claude Code first; any shell-capable agent
35
+ through `AGENTS.md`. Python 3.10+, standard library only, no services, no network calls, no
36
+ telemetry. MIT. Early release (alpha). Built on Andrej Karpathy's
37
+ [LLM Wiki](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) pattern.
38
+
39
+ ## What a session looks like
40
+
41
+ A fictional project from the [demo vault](https://github.com/serhat-10/mentat-wiki/tree/main/examples/demo-vault);
42
+ real command output, shortened.
43
+
44
+ **Session start.** The SessionStart hook runs `mentat-wiki context`, and the agent sees:
45
+
46
+ ```text
47
+ # trailmap: status
48
+ ## Where we left off
49
+ Parser and text profile work end to end. Five-point smoothing runs with a 3 m climb threshold;
50
+ the coastal test track reports 640 m of gain.
51
+ ## Next step
52
+ - Add --json output for plotting.
53
+
54
+ # trailmap: open threads
55
+ - [ ] Write a regression test that pins the coastal track at 640 m of gain.
56
+ - [ ] Try a nine-point window on the coastal track and compare total gain.
57
+
58
+ Recent experiment notes:
59
+ - 2026-11-20 16:40 [failed] five-point window without edge padding -> first and last elevations dropped 14 m
60
+ - 2026-11-21 11:05 [worked] 3 m climb threshold -> 640 m gain, within 20 m of the sum from the route map
61
+ ```
62
+
63
+ **During the session.** The agent logs what you decide and every attempt, failures included:
64
+
65
+ ```text
66
+ $ mentat-wiki decide --decision "Pad the edges before smoothing" --why "keeps the first and last points" --rejected "nine-point window"
67
+ decision recorded
68
+ $ mentat-wiki note --result worked "edge padding -> first and last elevations within 1 m"
69
+ noted in wiki/projects/trailmap/experiments.md
70
+ ```
71
+
72
+ The Claude Code status line shows the project, what was kept today, proposals waiting for your
73
+ answer, and the short session id (`🔑`):
74
+
75
+ ```text
76
+ 🧠 trailmap · kept 3 today · ❓1 to confirm · 🔑 5f2c9a1e
77
+ ```
78
+
79
+ **Session end.** You type `/wrap`. The agent rewrites the status and open threads, so the next
80
+ session starts from here:
81
+
82
+ ```text
83
+ $ mentat-wiki wrap --where "Smoothing pads the edges now; the coastal track keeps 640 m of gain." --next "Add --json output for plotting." --thread "Pin the coastal track at 640 m in a regression test."
84
+ status updated
85
+ ```
86
+
87
+ **Next session.** It starts from what you wrapped; the nine-point thread you dropped is gone:
88
+
89
+ ```text
90
+ # trailmap: status
91
+ ## Where we left off
92
+ Smoothing pads the edges now; the coastal track keeps 640 m of gain.
93
+ ## Next step
94
+ - Add --json output for plotting.
95
+
96
+ # trailmap: open threads
97
+ - [ ] Pin the coastal track at 640 m in a regression test.
98
+
99
+ Recent experiment notes:
100
+ - 2026-11-24 18:57 [worked] edge padding -> first and last elevations within 1 m
101
+ ```
102
+
103
+ ## Quickstart
104
+
105
+ ```bash
106
+ pipx install git+https://github.com/serhat-10/mentat-wiki # or: pip install git+https://...
107
+ mentat-wiki init ~/vault # creates the vault and remembers its path
108
+ mentat-wiki install claude # shows a diff and asks first; --dry-run only previews
109
+ cd ~/code/my-app # any existing project folder
110
+ mentat-wiki project register # name defaults to the folder: my-app
111
+ mentat-wiki doctor # checks the vault and the Claude Code setup
112
+ ```
113
+
114
+ It is not on PyPI yet, so install from GitHub (this needs git). If `mentat-wiki` is not found after
115
+ a pip install, use `python -m mentat_wiki` in its place; the installer does the same.
116
+
117
+ Then start Claude Code in `~/code/my-app`. The first session says there is nothing recorded yet; from
118
+ the first `/wrap` on, every session starts where the last one stopped.
119
+
120
+ ### What `install claude` changes
121
+
122
+ In `~/.claude/settings.json` (backed up first as `settings.json.bak-<time>`; your existing hooks,
123
+ permissions and status line stay; an older `mentat` entry is upgraded):
124
+
125
+ - a `SessionStart` hook, `mentat-wiki context`: loads your vault's `core/` rules plus this
126
+ project's status, open threads and recent experiment notes;
127
+ - a `UserPromptSubmit` hook, `mentat-wiki hook`: writes a local session checkpoint (session id,
128
+ time, prompt count and transcript path, never prompt text) and, only in registered folders and the vault, may add a short hint
129
+ naming related pages;
130
+ - a status line, only if you have none (`--force-statusline` replaces yours);
131
+ - the permission `Bash(mentat-wiki *)`, so the agent can run the CLI without a prompt each time.
132
+
133
+ It also writes the `/idea`, `/keep` and `/wrap` skills to `~/.claude/skills/`, skipping any you
134
+ already have with that name. If `mentat-wiki` is not on `PATH` for this Python, every entry uses
135
+ `<python> -m mentat_wiki` instead; `mentat-wiki config --command` overrides the choice. A manifest in
136
+ `~/.mentat/install-claude.json` records each entry; `mentat-wiki uninstall claude` removes only
137
+ those.
138
+
139
+ Your repositories are never written to. `project register` maps the folder to a project in
140
+ `~/.mentat/config.json`; all pages live in the vault. The vault's own `CLAUDE.md` and `AGENTS.md`
141
+ are for sessions inside the vault, not for your repos.
142
+
143
+ ## Daily use
144
+
145
+ You:
146
+
147
+ - `/wrap` before you stop.
148
+ - `/keep` or `/idea` to file something right now.
149
+ - `mentat-wiki resume`: how the last session in this folder ended, and how to reopen it.
150
+ - `mentat-wiki handover`: a paste-ready prompt to continue in another tool.
151
+ - `mentat-wiki find "smoothing"` and `mentat-wiki digest` to look things up.
152
+
153
+ The agent:
154
+
155
+ - reads status, open threads and recent notes at session start;
156
+ - logs the decisions you make or approve (`decide`) and each experiment attempt (`note`);
157
+ - checks for an existing page before writing a new one;
158
+ - asks once before saving anything else (next section).
159
+
160
+ ## Better with Obsidian
161
+
162
+ mentat-wiki does not need [Obsidian](https://obsidian.md), but the two work best together:
163
+ mentat-wiki writes the vault, Obsidian shows it. Choose "Open folder as vault", pick the folder you
164
+ gave to `mentat-wiki init`, and leave it open next to your agent. There is no plugin and nothing to
165
+ sync; the CLI writes plain Markdown into that folder, so every save shows up there:
166
+
167
+ | When | What changes in Obsidian |
168
+ |---|---|
169
+ | `/wrap` | the project's `status` and `open-threads` pages, and a line in `wiki/log` |
170
+ | a decision (`decide`) | a row in the project's `decisions` page |
171
+ | an experiment (`note`) | a line in the project's `experiments` page |
172
+ | `/keep`, `/idea` | a new page, listed in `wiki/index` |
173
+ | `inbox` | a line in `inbox/inbox` |
174
+
175
+ What you get from it:
176
+
177
+ - You see what the agent saved while you work, and can correct a page by hand. `status` and
178
+ `open-threads` are the exception: the next `/wrap` rewrites them.
179
+ - Pages link with `[[wikilinks]]`, starting from `wiki/index`, so backlinks and the graph view work
180
+ without setup.
181
+ - Frontmatter such as `type`, `domain` and `status` appears as properties you can search on.
182
+
183
+ To see it filled in, open
184
+ [examples/demo-vault](https://github.com/serhat-10/mentat-wiki/tree/main/examples/demo-vault) in
185
+ Obsidian.
186
+
187
+ ## Ask-first capture (early)
188
+
189
+ When something worth keeping comes up mid-session (an idea, reusable knowledge, a decision the
190
+ agent would log on its own), the agent registers a proposal, the status line shows it, and it asks
191
+ one line:
192
+
193
+ ```text
194
+ Keep as idea "Export the profile as SVG"? y
195
+ kept wiki/ideas/export-the-profile-as-svg.md
196
+ ```
197
+
198
+ `/wrap` also offers up to three unfiled items this way. Each answer (kept, edited, rejected, or
199
+ ignored after 24 h) goes to a local ledger. `mentat-wiki policy` shows acceptance per category, and
200
+ after 10 or more proposals with at least 90% accepted it suggests letting that category save
201
+ without asking. It never changes anything itself: you edit `core/capture-policy.md`.
202
+
203
+ This part is new. Expect a few weeks of normal use before it has enough answers to suggest
204
+ anything. Details: [docs/capture-policy.md](https://github.com/serhat-10/mentat-wiki/blob/main/docs/capture-policy.md).
205
+
206
+ ## Why not CLAUDE.md or built-in memory?
207
+
208
+ `CLAUDE.md` holds the instructions you write, and Claude Code's auto memory keeps facts the model
209
+ picks. Both help, and mentat-wiki runs next to them. It adds:
210
+
211
+ - a fixed project-state shape: where we left off, next step and open threads, which `/wrap`
212
+ rewrites, plus decisions with the alternatives you rejected and experiment notes, appended as
213
+ you go;
214
+ - one vault for all your projects, with idea, knowledge and source pages linked across them;
215
+ - plain files that any agent or editor can read, and `handover` to continue in another tool.
216
+
217
+ Other tools in this space:
218
+
219
+ - **claude-mem** handles automatic session-wide capture and compression for Claude Code. Use it for
220
+ hands-off cross-session memory.
221
+ - **basic-memory** serves local Markdown notes over MCP. Use it for cross-client MCP access to a
222
+ knowledge graph.
223
+ - **claude-obsidian** centers on an Obsidian vault driven by Claude Code. Use it if Obsidian is
224
+ your workflow hub.
225
+
226
+ Choose mentat-wiki for explicit project continuity, a wiki you curate, and zero services: one
227
+ stdlib-only CLI, plain Markdown, and a local SQLite FTS5 index.
228
+
229
+ ## Privacy and safety
230
+
231
+ - Capture commands scan the text they are about to write and refuse common secrets (OpenAI,
232
+ Anthropic, Google, AWS and Stripe keys, GitHub and Slack tokens, JWTs, private keys,
233
+ `password=...`), home-folder paths and real email addresses. Version strings, `example.com` and
234
+ `git@host:path` pass. It is pattern matching, not a guarantee; review what you keep.
235
+ - mentat-wiki does not store chat transcripts: hooks record no prompt text, and capture commands
236
+ write only the text they are given. Captured pages record `origin` and `auto: true|false`.
237
+ - Session-start context is bounded: the body is capped at 6,000 characters (`--max-chars`), and
238
+ `doctor` warns when `core/` grows past 2,200 characters (about 550 tokens).
239
+ - `~/.mentat/config.json` stores local paths on purpose (vault path, folder-to-project map); it
240
+ stays on your machine.
241
+ - The installer backs up `settings.json`, and uninstall reverts only the entries its manifest
242
+ recorded. Without a manifest it changes nothing unless you pass `--legacy`.
243
+
244
+ See [SECURITY.md](https://github.com/serhat-10/mentat-wiki/blob/main/SECURITY.md).
245
+
246
+ ## Other agents
247
+
248
+ Point any shell-capable agent at your vault's `AGENTS.md`, or tell it to run
249
+ `mentat-wiki context --always` at session start and write through the CLI. Only Claude Code gets hooks, the status line and the
250
+ `/idea`, `/keep`, `/wrap` skills today.
251
+
252
+ ## Commands
253
+
254
+ <details>
255
+ <summary>All commands</summary>
256
+
257
+ | Command | Purpose |
258
+ |---|---|
259
+ | `mentat-wiki init ~/vault` | Create a vault with the schema and templates. |
260
+ | `mentat-wiki install claude` | Wire hooks, status line, permission and skills (`--dry-run` previews). |
261
+ | `mentat-wiki uninstall claude` | Revert installer changes (`--legacy` also removes hand-written mentat hooks). |
262
+ | `mentat-wiki project register my-app` | Register this folder (`project list` lists). |
263
+ | `mentat-wiki context` | Print the session-start context (`--always` in unregistered folders). |
264
+ | `mentat-wiki keep --type idea --title "Retry queue" --summary "Queue uploads" --value 4 --effort 2` | File an idea, thought, concept or output. |
265
+ | `mentat-wiki inbox "Check backups"` | Park a one-line item. |
266
+ | `mentat-wiki decide --decision "Use SQLite" --why "Zero deps" --rejected "External index"` | Append a project decision. |
267
+ | `mentat-wiki wrap --where "Cache done" --next "Add queue" --thread "Check timeouts"` | Rewrite status and open threads. |
268
+ | `mentat-wiki note --result worked "1k pages in 12 ms"` | Log an experiment attempt. |
269
+ | `mentat-wiki propose --type idea --title "Retry queue"` | Register a pending proposal. |
270
+ | `mentat-wiki feedback --type idea --title "Retry queue" --outcome rejected` | Record a rejected or edited proposal. |
271
+ | `mentat-wiki find "retry"` | Search pages (`--ideas` ranks parked ideas). |
272
+ | `mentat-wiki policy` | Acceptance per category (`--json` supported). |
273
+ | `mentat-wiki digest` | Recent ideas, top parked ideas, policy summary. |
274
+ | `mentat-wiki resume` | How the last session in this folder ended. |
275
+ | `mentat-wiki handover` | Paste-ready prompt for another tool. |
276
+ | `mentat-wiki doctor` | Check schema, links, index, size, privacy, install. |
277
+ | `mentat-wiki config --vault ~/vault` | Set the vault (`--command` sets the CLI string). |
278
+ | `mentat-wiki --version` | Print the version. |
279
+
280
+ </details>
281
+
282
+ ## FAQ
283
+
284
+ **Do I need Obsidian?** No, any editor works. It is the recommended way to read the vault, though:
285
+ see "Better with Obsidian" above.
286
+
287
+ **Why `mentat-wiki` and not `mentat`?** An unrelated, older PyPI package already installs a
288
+ `mentat` command. A unique name avoids colliding with it.
289
+
290
+ **What if `mentat-wiki` is not on `PATH`?** `install claude` falls back to
291
+ `<python> -m mentat_wiki`. Override with `mentat-wiki config --command "python -m mentat_wiki"`.
292
+
293
+ **Two repos have the same folder name.** `project register` refuses a folder-derived name already
294
+ used by another folder on this machine; pass a name (`mentat-wiki project register api-billing`). Passing an existing name on purpose
295
+ shares it, for example across worktrees of one repo.
296
+
297
+ **Can I change domains or the schema?** Yes. Edit the vault's `CLAUDE.md` (`## Domains`;
298
+ `projects` and `other` are always valid).
299
+
300
+ **When does the agent save without asking?** Project log updates (`/wrap`, decisions you made or
301
+ approved, experiment notes) and any category you set to `auto` in `core/capture-policy.md`.
302
+ Everything else asks once (`chatter` is `never`).
303
+
304
+ ## Uninstall
305
+
306
+ `mentat-wiki uninstall claude`, then `pipx uninstall mentat-wiki` or `pip uninstall mentat-wiki`.
307
+ Your vault stays plain Markdown.
308
+
309
+ ## Documentation
310
+
311
+ [Demo vault](https://github.com/serhat-10/mentat-wiki/tree/main/examples/demo-vault) ·
312
+ [Architecture](https://github.com/serhat-10/mentat-wiki/blob/main/docs/architecture.md) ·
313
+ [Capture policy](https://github.com/serhat-10/mentat-wiki/blob/main/docs/capture-policy.md) ·
314
+ [Contributing](https://github.com/serhat-10/mentat-wiki/blob/main/CONTRIBUTING.md) ·
315
+ [Security](https://github.com/serhat-10/mentat-wiki/blob/main/SECURITY.md) ·
316
+ [Changelog](https://github.com/serhat-10/mentat-wiki/blob/main/CHANGELOG.md)
317
+
318
+ ## License
319
+
320
+ MIT. See [LICENSE](https://github.com/serhat-10/mentat-wiki/blob/main/LICENSE).
@@ -0,0 +1,294 @@
1
+ # mentat-wiki
2
+
3
+ **Coding agents forget where you left off when a session ends.** mentat-wiki keeps each
4
+ project's status, next step, decisions, open threads and experiment notes in a local Markdown wiki.
5
+ The next session starts with the status, open threads and recent notes loaded (decisions stay one
6
+ file away), and `/wrap` updates them before you stop.
7
+
8
+ The vault is plain Markdown, best read in Obsidian. Claude Code first; any shell-capable agent
9
+ through `AGENTS.md`. Python 3.10+, standard library only, no services, no network calls, no
10
+ telemetry. MIT. Early release (alpha). Built on Andrej Karpathy's
11
+ [LLM Wiki](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) pattern.
12
+
13
+ ## What a session looks like
14
+
15
+ A fictional project from the [demo vault](https://github.com/serhat-10/mentat-wiki/tree/main/examples/demo-vault);
16
+ real command output, shortened.
17
+
18
+ **Session start.** The SessionStart hook runs `mentat-wiki context`, and the agent sees:
19
+
20
+ ```text
21
+ # trailmap: status
22
+ ## Where we left off
23
+ Parser and text profile work end to end. Five-point smoothing runs with a 3 m climb threshold;
24
+ the coastal test track reports 640 m of gain.
25
+ ## Next step
26
+ - Add --json output for plotting.
27
+
28
+ # trailmap: open threads
29
+ - [ ] Write a regression test that pins the coastal track at 640 m of gain.
30
+ - [ ] Try a nine-point window on the coastal track and compare total gain.
31
+
32
+ Recent experiment notes:
33
+ - 2026-11-20 16:40 [failed] five-point window without edge padding -> first and last elevations dropped 14 m
34
+ - 2026-11-21 11:05 [worked] 3 m climb threshold -> 640 m gain, within 20 m of the sum from the route map
35
+ ```
36
+
37
+ **During the session.** The agent logs what you decide and every attempt, failures included:
38
+
39
+ ```text
40
+ $ mentat-wiki decide --decision "Pad the edges before smoothing" --why "keeps the first and last points" --rejected "nine-point window"
41
+ decision recorded
42
+ $ mentat-wiki note --result worked "edge padding -> first and last elevations within 1 m"
43
+ noted in wiki/projects/trailmap/experiments.md
44
+ ```
45
+
46
+ The Claude Code status line shows the project, what was kept today, proposals waiting for your
47
+ answer, and the short session id (`🔑`):
48
+
49
+ ```text
50
+ 🧠 trailmap · kept 3 today · ❓1 to confirm · 🔑 5f2c9a1e
51
+ ```
52
+
53
+ **Session end.** You type `/wrap`. The agent rewrites the status and open threads, so the next
54
+ session starts from here:
55
+
56
+ ```text
57
+ $ mentat-wiki wrap --where "Smoothing pads the edges now; the coastal track keeps 640 m of gain." --next "Add --json output for plotting." --thread "Pin the coastal track at 640 m in a regression test."
58
+ status updated
59
+ ```
60
+
61
+ **Next session.** It starts from what you wrapped; the nine-point thread you dropped is gone:
62
+
63
+ ```text
64
+ # trailmap: status
65
+ ## Where we left off
66
+ Smoothing pads the edges now; the coastal track keeps 640 m of gain.
67
+ ## Next step
68
+ - Add --json output for plotting.
69
+
70
+ # trailmap: open threads
71
+ - [ ] Pin the coastal track at 640 m in a regression test.
72
+
73
+ Recent experiment notes:
74
+ - 2026-11-24 18:57 [worked] edge padding -> first and last elevations within 1 m
75
+ ```
76
+
77
+ ## Quickstart
78
+
79
+ ```bash
80
+ pipx install git+https://github.com/serhat-10/mentat-wiki # or: pip install git+https://...
81
+ mentat-wiki init ~/vault # creates the vault and remembers its path
82
+ mentat-wiki install claude # shows a diff and asks first; --dry-run only previews
83
+ cd ~/code/my-app # any existing project folder
84
+ mentat-wiki project register # name defaults to the folder: my-app
85
+ mentat-wiki doctor # checks the vault and the Claude Code setup
86
+ ```
87
+
88
+ It is not on PyPI yet, so install from GitHub (this needs git). If `mentat-wiki` is not found after
89
+ a pip install, use `python -m mentat_wiki` in its place; the installer does the same.
90
+
91
+ Then start Claude Code in `~/code/my-app`. The first session says there is nothing recorded yet; from
92
+ the first `/wrap` on, every session starts where the last one stopped.
93
+
94
+ ### What `install claude` changes
95
+
96
+ In `~/.claude/settings.json` (backed up first as `settings.json.bak-<time>`; your existing hooks,
97
+ permissions and status line stay; an older `mentat` entry is upgraded):
98
+
99
+ - a `SessionStart` hook, `mentat-wiki context`: loads your vault's `core/` rules plus this
100
+ project's status, open threads and recent experiment notes;
101
+ - a `UserPromptSubmit` hook, `mentat-wiki hook`: writes a local session checkpoint (session id,
102
+ time, prompt count and transcript path, never prompt text) and, only in registered folders and the vault, may add a short hint
103
+ naming related pages;
104
+ - a status line, only if you have none (`--force-statusline` replaces yours);
105
+ - the permission `Bash(mentat-wiki *)`, so the agent can run the CLI without a prompt each time.
106
+
107
+ It also writes the `/idea`, `/keep` and `/wrap` skills to `~/.claude/skills/`, skipping any you
108
+ already have with that name. If `mentat-wiki` is not on `PATH` for this Python, every entry uses
109
+ `<python> -m mentat_wiki` instead; `mentat-wiki config --command` overrides the choice. A manifest in
110
+ `~/.mentat/install-claude.json` records each entry; `mentat-wiki uninstall claude` removes only
111
+ those.
112
+
113
+ Your repositories are never written to. `project register` maps the folder to a project in
114
+ `~/.mentat/config.json`; all pages live in the vault. The vault's own `CLAUDE.md` and `AGENTS.md`
115
+ are for sessions inside the vault, not for your repos.
116
+
117
+ ## Daily use
118
+
119
+ You:
120
+
121
+ - `/wrap` before you stop.
122
+ - `/keep` or `/idea` to file something right now.
123
+ - `mentat-wiki resume`: how the last session in this folder ended, and how to reopen it.
124
+ - `mentat-wiki handover`: a paste-ready prompt to continue in another tool.
125
+ - `mentat-wiki find "smoothing"` and `mentat-wiki digest` to look things up.
126
+
127
+ The agent:
128
+
129
+ - reads status, open threads and recent notes at session start;
130
+ - logs the decisions you make or approve (`decide`) and each experiment attempt (`note`);
131
+ - checks for an existing page before writing a new one;
132
+ - asks once before saving anything else (next section).
133
+
134
+ ## Better with Obsidian
135
+
136
+ mentat-wiki does not need [Obsidian](https://obsidian.md), but the two work best together:
137
+ mentat-wiki writes the vault, Obsidian shows it. Choose "Open folder as vault", pick the folder you
138
+ gave to `mentat-wiki init`, and leave it open next to your agent. There is no plugin and nothing to
139
+ sync; the CLI writes plain Markdown into that folder, so every save shows up there:
140
+
141
+ | When | What changes in Obsidian |
142
+ |---|---|
143
+ | `/wrap` | the project's `status` and `open-threads` pages, and a line in `wiki/log` |
144
+ | a decision (`decide`) | a row in the project's `decisions` page |
145
+ | an experiment (`note`) | a line in the project's `experiments` page |
146
+ | `/keep`, `/idea` | a new page, listed in `wiki/index` |
147
+ | `inbox` | a line in `inbox/inbox` |
148
+
149
+ What you get from it:
150
+
151
+ - You see what the agent saved while you work, and can correct a page by hand. `status` and
152
+ `open-threads` are the exception: the next `/wrap` rewrites them.
153
+ - Pages link with `[[wikilinks]]`, starting from `wiki/index`, so backlinks and the graph view work
154
+ without setup.
155
+ - Frontmatter such as `type`, `domain` and `status` appears as properties you can search on.
156
+
157
+ To see it filled in, open
158
+ [examples/demo-vault](https://github.com/serhat-10/mentat-wiki/tree/main/examples/demo-vault) in
159
+ Obsidian.
160
+
161
+ ## Ask-first capture (early)
162
+
163
+ When something worth keeping comes up mid-session (an idea, reusable knowledge, a decision the
164
+ agent would log on its own), the agent registers a proposal, the status line shows it, and it asks
165
+ one line:
166
+
167
+ ```text
168
+ Keep as idea "Export the profile as SVG"? y
169
+ kept wiki/ideas/export-the-profile-as-svg.md
170
+ ```
171
+
172
+ `/wrap` also offers up to three unfiled items this way. Each answer (kept, edited, rejected, or
173
+ ignored after 24 h) goes to a local ledger. `mentat-wiki policy` shows acceptance per category, and
174
+ after 10 or more proposals with at least 90% accepted it suggests letting that category save
175
+ without asking. It never changes anything itself: you edit `core/capture-policy.md`.
176
+
177
+ This part is new. Expect a few weeks of normal use before it has enough answers to suggest
178
+ anything. Details: [docs/capture-policy.md](https://github.com/serhat-10/mentat-wiki/blob/main/docs/capture-policy.md).
179
+
180
+ ## Why not CLAUDE.md or built-in memory?
181
+
182
+ `CLAUDE.md` holds the instructions you write, and Claude Code's auto memory keeps facts the model
183
+ picks. Both help, and mentat-wiki runs next to them. It adds:
184
+
185
+ - a fixed project-state shape: where we left off, next step and open threads, which `/wrap`
186
+ rewrites, plus decisions with the alternatives you rejected and experiment notes, appended as
187
+ you go;
188
+ - one vault for all your projects, with idea, knowledge and source pages linked across them;
189
+ - plain files that any agent or editor can read, and `handover` to continue in another tool.
190
+
191
+ Other tools in this space:
192
+
193
+ - **claude-mem** handles automatic session-wide capture and compression for Claude Code. Use it for
194
+ hands-off cross-session memory.
195
+ - **basic-memory** serves local Markdown notes over MCP. Use it for cross-client MCP access to a
196
+ knowledge graph.
197
+ - **claude-obsidian** centers on an Obsidian vault driven by Claude Code. Use it if Obsidian is
198
+ your workflow hub.
199
+
200
+ Choose mentat-wiki for explicit project continuity, a wiki you curate, and zero services: one
201
+ stdlib-only CLI, plain Markdown, and a local SQLite FTS5 index.
202
+
203
+ ## Privacy and safety
204
+
205
+ - Capture commands scan the text they are about to write and refuse common secrets (OpenAI,
206
+ Anthropic, Google, AWS and Stripe keys, GitHub and Slack tokens, JWTs, private keys,
207
+ `password=...`), home-folder paths and real email addresses. Version strings, `example.com` and
208
+ `git@host:path` pass. It is pattern matching, not a guarantee; review what you keep.
209
+ - mentat-wiki does not store chat transcripts: hooks record no prompt text, and capture commands
210
+ write only the text they are given. Captured pages record `origin` and `auto: true|false`.
211
+ - Session-start context is bounded: the body is capped at 6,000 characters (`--max-chars`), and
212
+ `doctor` warns when `core/` grows past 2,200 characters (about 550 tokens).
213
+ - `~/.mentat/config.json` stores local paths on purpose (vault path, folder-to-project map); it
214
+ stays on your machine.
215
+ - The installer backs up `settings.json`, and uninstall reverts only the entries its manifest
216
+ recorded. Without a manifest it changes nothing unless you pass `--legacy`.
217
+
218
+ See [SECURITY.md](https://github.com/serhat-10/mentat-wiki/blob/main/SECURITY.md).
219
+
220
+ ## Other agents
221
+
222
+ Point any shell-capable agent at your vault's `AGENTS.md`, or tell it to run
223
+ `mentat-wiki context --always` at session start and write through the CLI. Only Claude Code gets hooks, the status line and the
224
+ `/idea`, `/keep`, `/wrap` skills today.
225
+
226
+ ## Commands
227
+
228
+ <details>
229
+ <summary>All commands</summary>
230
+
231
+ | Command | Purpose |
232
+ |---|---|
233
+ | `mentat-wiki init ~/vault` | Create a vault with the schema and templates. |
234
+ | `mentat-wiki install claude` | Wire hooks, status line, permission and skills (`--dry-run` previews). |
235
+ | `mentat-wiki uninstall claude` | Revert installer changes (`--legacy` also removes hand-written mentat hooks). |
236
+ | `mentat-wiki project register my-app` | Register this folder (`project list` lists). |
237
+ | `mentat-wiki context` | Print the session-start context (`--always` in unregistered folders). |
238
+ | `mentat-wiki keep --type idea --title "Retry queue" --summary "Queue uploads" --value 4 --effort 2` | File an idea, thought, concept or output. |
239
+ | `mentat-wiki inbox "Check backups"` | Park a one-line item. |
240
+ | `mentat-wiki decide --decision "Use SQLite" --why "Zero deps" --rejected "External index"` | Append a project decision. |
241
+ | `mentat-wiki wrap --where "Cache done" --next "Add queue" --thread "Check timeouts"` | Rewrite status and open threads. |
242
+ | `mentat-wiki note --result worked "1k pages in 12 ms"` | Log an experiment attempt. |
243
+ | `mentat-wiki propose --type idea --title "Retry queue"` | Register a pending proposal. |
244
+ | `mentat-wiki feedback --type idea --title "Retry queue" --outcome rejected` | Record a rejected or edited proposal. |
245
+ | `mentat-wiki find "retry"` | Search pages (`--ideas` ranks parked ideas). |
246
+ | `mentat-wiki policy` | Acceptance per category (`--json` supported). |
247
+ | `mentat-wiki digest` | Recent ideas, top parked ideas, policy summary. |
248
+ | `mentat-wiki resume` | How the last session in this folder ended. |
249
+ | `mentat-wiki handover` | Paste-ready prompt for another tool. |
250
+ | `mentat-wiki doctor` | Check schema, links, index, size, privacy, install. |
251
+ | `mentat-wiki config --vault ~/vault` | Set the vault (`--command` sets the CLI string). |
252
+ | `mentat-wiki --version` | Print the version. |
253
+
254
+ </details>
255
+
256
+ ## FAQ
257
+
258
+ **Do I need Obsidian?** No, any editor works. It is the recommended way to read the vault, though:
259
+ see "Better with Obsidian" above.
260
+
261
+ **Why `mentat-wiki` and not `mentat`?** An unrelated, older PyPI package already installs a
262
+ `mentat` command. A unique name avoids colliding with it.
263
+
264
+ **What if `mentat-wiki` is not on `PATH`?** `install claude` falls back to
265
+ `<python> -m mentat_wiki`. Override with `mentat-wiki config --command "python -m mentat_wiki"`.
266
+
267
+ **Two repos have the same folder name.** `project register` refuses a folder-derived name already
268
+ used by another folder on this machine; pass a name (`mentat-wiki project register api-billing`). Passing an existing name on purpose
269
+ shares it, for example across worktrees of one repo.
270
+
271
+ **Can I change domains or the schema?** Yes. Edit the vault's `CLAUDE.md` (`## Domains`;
272
+ `projects` and `other` are always valid).
273
+
274
+ **When does the agent save without asking?** Project log updates (`/wrap`, decisions you made or
275
+ approved, experiment notes) and any category you set to `auto` in `core/capture-policy.md`.
276
+ Everything else asks once (`chatter` is `never`).
277
+
278
+ ## Uninstall
279
+
280
+ `mentat-wiki uninstall claude`, then `pipx uninstall mentat-wiki` or `pip uninstall mentat-wiki`.
281
+ Your vault stays plain Markdown.
282
+
283
+ ## Documentation
284
+
285
+ [Demo vault](https://github.com/serhat-10/mentat-wiki/tree/main/examples/demo-vault) ·
286
+ [Architecture](https://github.com/serhat-10/mentat-wiki/blob/main/docs/architecture.md) ·
287
+ [Capture policy](https://github.com/serhat-10/mentat-wiki/blob/main/docs/capture-policy.md) ·
288
+ [Contributing](https://github.com/serhat-10/mentat-wiki/blob/main/CONTRIBUTING.md) ·
289
+ [Security](https://github.com/serhat-10/mentat-wiki/blob/main/SECURITY.md) ·
290
+ [Changelog](https://github.com/serhat-10/mentat-wiki/blob/main/CHANGELOG.md)
291
+
292
+ ## License
293
+
294
+ MIT. See [LICENSE](https://github.com/serhat-10/mentat-wiki/blob/main/LICENSE).
@@ -0,0 +1 @@
1
+ __version__ = "0.1.1"
@@ -0,0 +1,3 @@
1
+ from .cli import main
2
+
3
+ main()