@velvetmonkey/flywheel-memory 2.2.0 → 2.3.0

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 (3) hide show
  1. package/README.md +14 -365
  2. package/dist/index.js +988 -503
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,371 +1,20 @@
1
- <div align="center">
2
- <img src="https://raw.githubusercontent.com/velvetmonkey/flywheel-memory/main/header.png" alt="Flywheel" width="256"/>
3
- <h1>Flywheel</h1>
4
- <p><strong>MCP tools that search, write, and auto-link your Obsidian vault — and learn from your edits.</strong><br/>All local. All yours. A few lines of config.</p>
5
- </div>
1
+ # Flywheel
6
2
 
7
- Flywheel is a local-first MCP server for Obsidian vaults. It indexes your markdown and gives AI clients tools to search notes, write safely, query tasks, follow links, and carry context across sessions. One server can serve multiple vaults with isolated state and cross-vault search.
3
+ > **See the [main README](../../README.md) for documentation, demos, and benchmarks.**
8
4
 
9
- Search returns a *decision surface* — frontmatter, backlinks, outlinks, snippets, section context, extracted dates, entity bridges, and confidence scores — so the model can reason from one call instead of opening file after file.
5
+ ## Quick links
10
6
 
11
- Every write auto-links entities through a deterministic *13-layer scoring algorithm* where every suggestion has a traceable receipt. *Proactive linking* means edits made in Obsidian are scored too — the graph grows whether you're using Claude or not. Links you keep get stronger; links you remove get suppressed. This is the *flywheel effect*: use compounds into structure, structure into intelligence, intelligence into more use.
12
-
13
- [![npm version](https://img.shields.io/npm/v/@velvetmonkey/flywheel-memory.svg)](https://www.npmjs.com/package/@velvetmonkey/flywheel-memory)
14
- [![MCP](https://img.shields.io/badge/MCP-Model%20Context%20Protocol-blueviolet.svg)](https://modelcontextprotocol.io/)
15
- [![CI](https://github.com/velvetmonkey/flywheel-memory/actions/workflows/ci.yml/badge.svg)](https://github.com/velvetmonkey/flywheel-memory/actions/workflows/ci.yml)
16
- [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
17
- [![Platform](https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows-blue.svg)](https://github.com/velvetmonkey/flywheel-memory)
18
- [![Scale](https://img.shields.io/badge/scale-100k--line%20files%20%7C%202.5k%20entities-brightgreen.svg)](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/TESTING.md#performance-benchmarks)
19
- [![Tests](https://img.shields.io/badge/tests-2,482%20passed-brightgreen.svg)](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/TESTING.md)
20
-
21
- | | Grep approach | Flywheel |
22
- |---|---|---|
23
- | "What's overdue?" | Grep + read matches (~500-2,000 tokens) | Indexed metadata query (~50-200 tokens) |
24
- | "What links here?" | Grep for note name (flat list, no graph) | Pre-indexed backlink graph (<10ms) |
25
- | "Add a meeting note" | Raw write, no linking | Structured write + auto-wikilink |
26
- | "What should I link?" | Not possible | 13-layer scoring + semantic search |
27
- | Hubs, orphans, paths? | Not possible | Pre-indexed graph analysis |
28
-
29
- 75 tools across 12 categories. 6-line config. Zero cloud dependencies.
30
-
31
- **Try in 60 seconds:**
32
-
33
- ```bash
34
- git clone https://github.com/velvetmonkey/flywheel-memory.git
35
- cd flywheel-memory/demos/carter-strategy && claude
36
- ```
37
-
38
- Then ask: *"How much have I billed Acme Corp?"*
39
-
40
- ---
41
-
42
- ## See It Work
43
-
44
- ### Read: "How much have I billed Acme Corp?"
45
-
46
- From the [carter-strategy](https://github.com/velvetmonkey/flywheel-memory/tree/main/demos/carter-strategy/) demo -- a solo consultant with 3 clients, 5 projects, and $27K in invoices.
47
-
48
- ```
49
- ❯ How much have I billed Acme Corp?
50
-
51
- ● flywheel › search
52
- query: "Acme Corp"
53
- → clients/Acme Corp.md, invoices/INV-2025-047.md,
54
- invoices/INV-2025-048.md, projects/Acme Data Migration.md
55
-
56
- ● read_file("clients/Acme Corp.md")
57
- ← total_billed: 156000, rate: $300/hr, status: active
58
-
59
- ● read_file("invoices/INV-2025-047.md")
60
- ← amount: 15000, status: paid, period: November 2025
61
-
62
- ● read_file("invoices/INV-2025-048.md")
63
- ← amount: 12000, status: pending, period: December 2025
64
-
65
- ┌─ RESULT ──────────────────────────────────────────────┐
66
- │ Acme Corp: $156K total billed │
67
- │ │
68
- │ Paid: $15,000 — Acme Data Migration (Nov 2025) │
69
- │ Pending: $12,000 — Acme Data Migration (Dec 2025) │
70
- │ │
71
- │ Also: $35K pending proposal (Analytics Add-on) │
72
- └───────────────────────────────────────────────────────┘
73
- ```
74
-
75
- [[Flywheel]]'s indexed search found all Acme-related notes in one call. The AI read the files it needed for billing details. No grepping, no guessing paths.
76
-
77
- Flywheel's search found all related notes in one call. Without it, the AI would grep for "Acme" and scan every matching file.
78
-
79
- The bigger difference isn't just tokens — it's that Flywheel answers structural questions (backlinks, hubs, shortest paths, schema analysis) that file-level access can't answer at all.
80
-
81
- ### Write: Auto-wikilinks on every mutation
82
-
83
- ```
84
- ❯ Log that Stacy Thompson reviewed the API Security Checklist for Acme before the Beta Corp Dashboard kickoff
85
-
86
- ● flywheel › vault_add_to_section
87
- path: "daily-notes/2026-01-04.md"
88
- section: "Log"
89
- content: "[[Stacy Thompson]] reviewed the [[API Security Checklist]] for [[Acme Corp|Acme]] before the [[Beta Corp Dashboard]] kickoff → [[GlobalBank API Audit]], [[Acme Analytics Add-on]], [[Acme Data Migration]]"
90
- ↑ 4 entities auto-linked — "Acme" resolved to Acme Corp via alias
91
- → 3 contextual suggestions appended (scored ≥12 via co-occurrence with linked entities)
92
- ```
93
-
94
- Try it yourself: `cd demos/carter-strategy && claude`
95
-
96
- ---
97
-
98
- ## What Makes Flywheel Different
99
-
100
- **Decision surface** — Search returns frontmatter, backlinks, outlinks, section context, dates, entity bridges, and confidence in one call. The model reasons across structured metadata instead of opening files.
101
-
102
- **Deterministic linking** — A 13-layer scoring algorithm produces a traceable receipt for every suggestion. Same input, same output. See [docs/ALGORITHM.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/ALGORITHM.md) for the full specification.
103
-
104
- ```
105
- Entity Score Match Co-oc Type Context Recency Cross Hub Feedback Semantic Edge
106
- ──────────────────────────────────────────────────────────────────────────────────────────────────────
107
- Marcus Johnson 34 +10 +3 +5 +5 +5 +3 +1 +2 0 0
108
- ```
109
-
110
- **Self-improving graph** — Proactive linking scores edits made anywhere — Obsidian, synced files, external tools. Links you keep accumulate weight; links you remove get suppressed. The graph compounds with use. We prove it: 100% entity precision, stable F1 over 50 generations of noisy feedback. See [Graph Quality](#graph-quality) below.
111
-
112
- **Brief + memory** — `brief` assembles a token-budgeted cold-start summary: recent sessions, active entities, stored memories, corrections, vault pulse. `memory` persists observations with confidence decay. The AI picks up where it left off.
113
-
114
- **Policies** — Repeatable vault workflows defined in YAML — parameterized steps, conditions, variable substitution, optional atomic git commits. Author, preview, validate, execute. See [docs/POLICY_EXAMPLES.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/POLICY_EXAMPLES.md).
115
-
116
- **Hybrid search** — Keyword search (BM25) finds what you said. Semantic search finds what you meant. Both fused via Reciprocal Rank Fusion, running locally. Nothing leaves your machine.
117
-
118
- **Multi-vault** — One server, multiple vaults, isolated state. Search without a vault filter queries all vaults and merges results.
119
-
120
- **Auditable writes** — Every mutation is git-committed, conflict-detected (SHA-256 content hash), and policy-governed. One undo reverts any change.
121
-
122
- ### How It Compares
123
-
124
- | | Pure Vector Search | Pure Keyword Search | Flywheel |
125
- |---|---|---|---|
126
- | "Why was this suggested?" | "Embeddings are close" | "Term frequency" | 13-layer score breakdown |
127
- | Finds synonyms/concepts? | Yes | No | Yes (hybrid search) |
128
- | Exact phrase matching? | Weak | Yes | Yes |
129
- | Same input → same output? | Not guaranteed | Always | Always |
130
- | Runs offline? | Often not | Yes | Yes (local embeddings) |
131
- | Learns from usage? | Retraining | No | Implicit feedback loop |
132
- | Agent memory | No | No | Yes (brief + memory) |
133
-
134
- ---
135
-
136
- ## The Flywheel Effect
137
-
138
- The name is literal. A flywheel is hard to start but once spinning, each push adds to the momentum.
139
-
140
- ### Day 1: Instant Value
141
-
142
- You point Flywheel at your vault. It indexes every note, extracts entities, builds a backlink graph. First query returns in <10ms. First write auto-links three entities you would have missed. No training period. No configuration.
143
-
144
- ### Week 1: Connections Appear
145
-
146
- You have 30 disconnected notes. Auto-wikilinks create 47 connections on your first day of writing through Flywheel. You stop reading files and start querying a graph.
147
-
148
- ### Month 1: Intelligence Emerges
149
-
150
- Hub notes surface. "[[Sarah Mitchell]]" has 23 backlinks -- she's clearly important. When you write about a project, her name appears in suggestions because co-occurrence tracking knows she's relevant. You didn't configure this. The vault structure revealed it.
151
-
152
- ### Month 3: The Graph Is Self-Sustaining
153
-
154
- Every query leverages hundreds of accumulated connections. New content auto-links to the right places. You stop thinking about organization.
155
-
156
- ### What This Looks Like
157
-
158
- ```mermaid
159
- graph LR
160
- W[Write] --> A[Auto-link]
161
- A --> D[Denser Graph]
162
- D --> B[Better Queries]
163
- B --> M[More Use]
164
- M --> W
165
- ```
166
-
167
- ```
168
- Input: "Stacy Thompson finished reviewing the API Security Checklist for the Beta Corp Dashboard"
169
- Output: "[[Stacy Thompson]] finished reviewing the [[API Security Checklist]] for the [[Beta Corp Dashboard]]"
170
- ```
171
-
172
- No manual linking. No broken references. Use compounds into structure, structure compounds into intelligence.
173
-
174
- ---
175
-
176
- ## Battle-Tested
177
-
178
- **2,482 tests. 122 test files. 47,000+ lines of test code.**
179
-
180
- ### Performance
181
-
182
- | Operation | Threshold | Typical |
183
- |---|---|---|
184
- | 1k-line mutation | <100ms | ~15ms |
185
- | 10k-line mutation | <500ms | -- |
186
- | 100k-line mutation | <2s | -- |
187
-
188
- - **100 parallel writes, zero corruption** -- concurrent mutations verified under stress
189
- - **Property-based fuzzing** -- fast-check with 700+ randomized scenarios
190
- - **SQL injection prevention** -- parameterized queries throughout
191
- - **Path traversal blocking** -- all file paths validated against vault root
192
- - **Deterministic output** -- every tool produces the same result given the same input
193
-
194
- Every demo vault is a real test fixture. If it works in the README, it passes in CI.
195
-
196
- ```bash
197
- git clone https://github.com/velvetmonkey/flywheel-memory.git
198
- cd flywheel-memory && npm install && npm test
199
- ```
200
-
201
- See [docs/PROVE-IT.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/PROVE-IT.md) and [docs/TESTING.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/TESTING.md).
202
-
203
- ### Graph Quality
204
-
205
- The feedback loop claim isn't asserted — it's measured. We build a test vault with known-correct links, strip them out, and measure how well the engine rediscovers them. CI locks these baselines and fails if quality regresses.
206
-
207
- | Mode | Strict Precision | Entity Precision | Recall | F1 |
208
- |---|---|---|---|---|
209
- | Conservative | 51.2% | 100% | 71.7% | 59.7% |
210
- | Balanced | 27.5% | 100% | 76.7% | 40.5% |
211
- | Aggressive | 26.1% | 100% | 76.7% | 39.0% |
212
-
213
- **Precision** = "of the links suggested, how many were correct?" (strict: counts all wrong suggestions; entity precision: excludes known-entity suggestions). **Recall** = "of the links that should exist, how many were found?" **F1** = the balance of both — higher is better.
214
-
215
- Measured against a 96-note/61-entity ground truth vault.
216
-
217
- - **50-generation stress test** — suggest → accept/reject (85% correct, 15% noise) → mutate vault → rebuild index → repeat. F1 holds steady — the feedback loop doesn't degrade under realistic noise.
218
- - **7 vault archetypes** — hub-and-spoke, hierarchical, dense-mesh, sparse-orphan, bridge-network, small-world, chaos
219
- - **13 pipeline stages** (scoring layers + filters + suppression) individually ablated, contribution measured
220
- - **Regression gate** — CI fails if any mode's F1/precision/recall drops >5pp from baseline
221
-
222
- See [docs/TESTING.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/TESTING.md) for full methodology. Auto-generated report: [docs/QUALITY_REPORT.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/QUALITY_REPORT.md).
223
-
224
- ### Safe Writes
225
-
226
- Every mutation is:
227
-
228
- - **Git-committed** — one `vault_undo_last_mutation` away from reverting any change
229
- - **Conflict-detected** — content hash check prevents clobbering concurrent edits (SHA-256)
230
- - **Policy-governed** — configurable guardrails with warn/strict/off modes
231
- - **Precise** — auto-wikilinks have 1.0 precision in production (never inserts a wrong link)
232
-
233
- ---
234
-
235
- ## How It Compares
236
-
237
- | Feature | Flywheel Memory | Obsidian CLI (MCP) | Smart Connections | Khoj |
238
- |---------|----------------|-------------------|-------------------|------|
239
- | Backlink graph | Bidirectional | No | No | No |
240
- | Hybrid search | Local (keyword + semantic) | No | Cloud only | Cloud |
241
- | Auto-wikilinks | Yes (alias resolution) | No | No | No |
242
- | Schema intelligence | 6 analysis modes | No | No | No |
243
- | Entity extraction | Auto (18 categories) | No | No | No |
244
- | Learns from usage | Feedback loop + suppression | No | No | No |
245
- | Agent memory | brief + search + memory | No | No | No |
246
- | Safe writes | Git + conflict detection | No | N/A | N/A |
247
- | Test coverage | 2,456 tests | Unknown | Unknown | Unknown |
248
- | Tool count | 75 | ~10 | 0 (plugin) | ~5 |
249
-
250
- ---
251
-
252
- ## Try It
253
-
254
- ### Step 1: Try a demo
255
-
256
- ```bash
257
- git clone https://github.com/velvetmonkey/flywheel-memory.git
258
- cd flywheel-memory/demos/carter-strategy && claude
259
- ```
260
-
261
- | Demo | You are | Ask this |
262
- |------|---------|----------|
263
- | [carter-strategy](https://github.com/velvetmonkey/flywheel-memory/tree/main/demos/carter-strategy/) | Solo consultant | "How much have I billed Acme Corp?" |
264
- | [artemis-rocket](https://github.com/velvetmonkey/flywheel-memory/tree/main/demos/artemis-rocket/) | Rocket engineer | "What's blocking propulsion?" |
265
- | [startup-ops](https://github.com/velvetmonkey/flywheel-memory/tree/main/demos/startup-ops/) | SaaS co-founder | "What's our MRR?" |
266
- | [nexus-lab](https://github.com/velvetmonkey/flywheel-memory/tree/main/demos/nexus-lab/) | PhD researcher | "How does AlphaFold connect to my experiment?" |
267
- | [solo-operator](https://github.com/velvetmonkey/flywheel-memory/tree/main/demos/solo-operator/) | Content creator | "How's revenue this month?" |
268
- | [support-desk](https://github.com/velvetmonkey/flywheel-memory/tree/main/demos/support-desk/) | Support agent | "What's Sarah Chen's situation?" |
269
- | [zettelkasten](https://github.com/velvetmonkey/flywheel-memory/tree/main/demos/zettelkasten/) | Zettelkasten student | "How does spaced repetition connect to active recall?" |
270
-
271
- ### Step 2: Your own vault
272
-
273
- Add `.mcp.json` to your vault root:
274
-
275
- ```json
276
- {
277
- "mcpServers": {
278
- "flywheel": {
279
- "command": "npx",
280
- "args": ["-y", "@velvetmonkey/flywheel-memory"],
281
- "env": {
282
- "FLYWHEEL_PRESET": "default"
283
- }
284
- }
285
- }
286
- }
287
- ```
288
-
289
- ```bash
290
- cd /path/to/your/vault && claude
291
- ```
292
-
293
- Defaults to the `full` preset (77 tools, tiered progressive disclosure). Use `agent` for a minimal 18-tool set. See [docs/CONFIGURATION.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/CONFIGURATION.md) for all options.
294
-
295
- > **Works with any MCP client.** Primarily tested with [[CLAUDE]]. See [Transport Options](#transport-options) for HTTP setup (Cursor, Windsurf, Aider, LangGraph, Ollama, etc.).
296
-
297
- ### Transport Options
298
-
299
- By default, Flywheel uses stdio transport (works with [[Claude Code]] and Claude Desktop). Set `FLYWHEEL_TRANSPORT` to enable HTTP transport for other clients (Cursor, Windsurf, Aider, LangGraph, Ollama):
300
-
301
- | Env Var | Values | Default |
302
- |---------|--------|---------|
303
- | `FLYWHEEL_TRANSPORT` | `stdio`, `http`, `both` | `stdio` |
304
- | `FLYWHEEL_HTTP_PORT` | Port number | `3111` |
305
- | `FLYWHEEL_HTTP_HOST` | Bind address | `127.0.0.1` |
306
-
307
- ```bash
308
- # HTTP only
309
- FLYWHEEL_TRANSPORT=http npx @velvetmonkey/flywheel-memory
310
-
311
- # Both stdio and HTTP simultaneously
312
- FLYWHEEL_TRANSPORT=both npx @velvetmonkey/flywheel-memory
313
-
314
- # Health check
315
- curl http://localhost:3111/health
316
-
317
- # MCP request (JSON-RPC over HTTP)
318
- curl -X POST http://localhost:3111/mcp \
319
- -H "Content-Type: application/json" \
320
- -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
321
- ```
322
-
323
- DNS rebinding protection is automatically enabled when bound to localhost.
324
-
325
- ### Multi-Vault
326
-
327
- Serve multiple Obsidian vaults from a single server:
328
-
329
- ```bash
330
- FLYWHEEL_VAULTS="personal:/path/to/personal,work:/path/to/work" \
331
- FLYWHEEL_TRANSPORT=http npx @velvetmonkey/flywheel-memory
332
- ```
333
-
334
- When multi-vault is active, every tool gains an optional `vault` parameter. The `search` tool automatically searches all vaults when `vault` is omitted, merging results across vaults. Other tools default to the primary vault (first in list).
335
-
336
- ---
337
-
338
- ## Tools Overview
339
-
340
- | Preset | Tools | What you get |
341
- |--------|-------|--------------|
342
- | `default` | 19 | Note-taking essentials — search, read, write, tasks |
343
- | `agent` | 19 | Autonomous AI agents — search, read, write, memory |
344
- | `full` | 69 | Everything — all 12 categories |
345
-
346
- Composable bundles add capabilities to any preset. See [docs/CONFIGURATION.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/CONFIGURATION.md) for all bundles and fine-grained categories.
347
-
348
- The fewer tools you load, the less context the AI needs to pick the right one. See [docs/TOOLS.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/TOOLS.md) for the full reference.
349
-
350
- ---
351
-
352
- ## Documentation
353
-
354
- | Doc | Why read this |
355
- |---|---|
356
- | [PROVE-IT.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/PROVE-IT.md) | See it working in 5 minutes |
357
- | [TOOLS.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/TOOLS.md) | All 75 tools documented |
358
- | [ALGORITHM.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/ALGORITHM.md) | How the scoring works |
359
- | [COOKBOOK.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/COOKBOOK.md) | Example prompts by use case |
360
- | [SETUP.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/SETUP.md) | Full setup guide for your vault |
361
- | [CONFIGURATION.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/CONFIGURATION.md) | Env vars, presets, custom tool sets |
362
- | [ARCHITECTURE.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/ARCHITECTURE.md) | Index strategy, graph, auto-wikilinks |
363
- | [TESTING.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/TESTING.md) | Test methodology and benchmarks |
364
- | [TROUBLESHOOTING.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/TROUBLESHOOTING.md) | Error recovery and diagnostics |
365
- | [VISION.md](https://github.com/velvetmonkey/flywheel-memory/blob/main/docs/VISION.md) | Where this is going |
366
-
367
- ---
7
+ | Doc | What |
8
+ |-----|------|
9
+ | [README](../../README.md) | Overview, demos, get started |
10
+ | [TOOLS.md](../../docs/TOOLS.md) | All tools |
11
+ | [ALGORITHM.md](../../docs/ALGORITHM.md) | Link scoring |
12
+ | [CONFIGURATION.md](../../docs/CONFIGURATION.md) | Env vars, presets |
13
+ | [SETUP.md](../../docs/SETUP.md) | Client setup |
14
+ | [TESTING.md](../../docs/TESTING.md) | Benchmarks, methodology |
15
+ | [ARCHITECTURE.md](../../docs/ARCHITECTURE.md) | Design |
16
+ | [COOKBOOK.md](../../docs/COOKBOOK.md) | Example prompts |
368
17
 
369
18
  ## License
370
19
 
371
- Apache-2.0 — see [LICENSE](https://github.com/velvetmonkey/flywheel-memory/blob/main/LICENSE) for details.
20
+ Apache-2.0