Skip to content

Commit 42a45f4

Browse files
authored
feat(#274): obsidian-sync subcommand with WikiLink backlinks (#280)
Add a first-class `mimir obsidian-sync <vault>` subcommand that surfaces vault export as a one-command Obsidian/Logseq/Notion PKM workflow, plus structured WikiLink backlinks between linked entities. - CLI: ObsidianSync { vault_path, db: Option<String>, --watch } variant + dispatch arm. Opens the DB and runs vault export to vault_path; --watch polls the cheap deterministic state_digest() (#256) on an interval and re-exports on change. No FS-watcher dependency; naturally catches remember writes and decouples from the server write path. - vault_export: parse the MemoryLink JSON array and write a `## Links` section per note (`- [[<id>|<key>]] (<relationship>)`). Two-pass build (id->filename map, then render). Links resolve BY ID for guaranteed Obsidian resolution. Links section is part of the unchanged-content comparison so the skip-optimization still holds. Dangling targets render as best-effort unresolved refs rather than crashing. Backward compatible: link-free notes are byte-identical to the prior format. - README: "Your AI Memory in Obsidian" PKM section (Obsidian/Logseq/Notion). - Tests: linked entities emit a WikiLink in the dependent note; unchanged re-export is a no-op; dangling link id does not crash; digest-change trigger logic (should_resync) tested in isolation; CLI parse tests. Closes #274.
1 parent 198deed commit 42a45f4

3 files changed

Lines changed: 456 additions & 38 deletions

File tree

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ mimir decay --db /data/mimir.db
215215
mimir reindex --db /data/mimir.db
216216
mimir vault-export --db /data/mimir.db --vault-dir ./export/
217217
mimir vault-import --db /data/mimir.db --vault-dir ./export/
218+
mimir obsidian-sync ~/obsidian-vault/Mimir/ # one-shot export to an Obsidian vault
219+
mimir obsidian-sync ~/obsidian-vault/Mimir/ --watch # continuous sync on every memory change
218220

219221
# Key management
220222
mimir keygen --key-file ~/.mimir/secret.key
@@ -237,6 +239,66 @@ mimir keygen --key-file ~/.mimir/secret.key
237239
| `--embedding-endpoint` | OpenAI-compatible embedding endpoint |
238240
| `--connectors-config` | Path to connectors.yaml |
239241

242+
## Your AI Memory in Obsidian
243+
244+
Mimir is your AI agent's long-term memory — and it doubles as **your** second
245+
brain. Every entity your agent remembers exports to a plain Markdown note with
246+
YAML frontmatter, so your AI's memory becomes a navigable personal knowledge
247+
base inside the tools you already use: **Obsidian, Logseq, or Notion.**
248+
249+
```bash
250+
# Export your entire memory to an Obsidian vault as linked Markdown notes
251+
mimir obsidian-sync ~/obsidian-vault/Mimir/
252+
253+
# Keep it live — re-export automatically on every memory change
254+
mimir obsidian-sync ~/obsidian-vault/Mimir/ --watch
255+
```
256+
257+
Open the vault in Obsidian and you get a graph of your agent's knowledge.
258+
259+
**WikiLink backlinks.** When one entity links to another (via `mimir_link` or a
260+
`depends_on` / `implements` / `references` relationship), the exported note gets
261+
a `## Links` section with `[[WikiLink]]` backlinks that resolve natively in
262+
Obsidian's graph view:
263+
264+
```markdown
265+
---
266+
id: cli-de8dfb8364b6
267+
category: architecture
268+
key: api
269+
type: insight
270+
decay_score: 0.5000
271+
---
272+
273+
{"content":"axum service"}
274+
275+
## Links
276+
277+
- [[cli-99756b494c7d|database]] (depends_on)
278+
```
279+
280+
Links resolve **by entity id** (notes are written as `<id>.md`) so they never
281+
break, and Obsidian shows the human-readable `key` as the link label. Open the
282+
graph view and your agent's architecture, decisions, and insights become a
283+
clickable knowledge map.
284+
285+
**`--watch`** polls Mimir's cheap, deterministic state digest on an interval and
286+
re-exports only when memory actually changes. It naturally catches every
287+
`mimir_remember` write with no filesystem-watcher dependency and no coupling to
288+
the server. Tune the interval with `MIMIR_SYNC_INTERVAL_SECS` (default: 2s).
289+
290+
### Other PKM tools
291+
292+
| Tool | How |
293+
|---|---|
294+
| **Obsidian** | `mimir obsidian-sync <vault>` — WikiLinks resolve in the graph view out of the box. |
295+
| **Logseq** | Point `obsidian-sync` at your Logseq graph directory. Logseq reads the same `[[WikiLink]]` syntax and Markdown frontmatter. |
296+
| **Notion** | Run `mimir vault-export`, then use Notion's *Import → Markdown & CSV* to pull the notes in. |
297+
298+
Unlike cloud-only "second brain" tools, Mimir runs **100% local**, is written in
299+
**Rust**, encrypts at rest with **AES-256-GCM**, and applies **decay scoring** so
300+
stale memories fade — your knowledge base stays yours and stays fresh.
301+
240302
## Features
241303

242304
### Hybrid Search

0 commit comments

Comments
 (0)