wenlan-mcp 0.9.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 (5) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +285 -0
  3. package/install.js +123 -0
  4. package/package.json +55 -0
  5. package/run.js +13 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,285 @@
1
+ <p align="center">
2
+ <img src="./docs/assets/social-preview.png" alt="Wenlan: a living personal knowledge library for the AI-native age." width="100%">
3
+ </p>
4
+
5
+ [![CI](https://github.com/7xuanlu/wenlan/actions/workflows/ci.yml/badge.svg?branch=main&event=push)](https://github.com/7xuanlu/wenlan/actions/workflows/ci.yml?query=branch%3Amain)
6
+ [![Release](https://img.shields.io/github/v/release/7xuanlu/wenlan?sort=semver)](https://github.com/7xuanlu/wenlan/releases/latest)
7
+ [![npm: wenlan](https://img.shields.io/npm/v/wenlan?label=wenlan)](https://www.npmjs.com/package/wenlan)
8
+ [![npm: wenlan-mcp](https://img.shields.io/npm/v/wenlan-mcp?label=wenlan-mcp)](https://www.npmjs.com/package/wenlan-mcp)
9
+ [![MCP Server](https://img.shields.io/badge/MCP-server-blue)](https://modelcontextprotocol.io)
10
+ [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](#license)
11
+
12
+ <p align="center">
13
+ <img alt="macOS" src="https://img.shields.io/badge/macOS-arm64%20%7C%20x64-A2AAAD?logo=apple&logoColor=white">
14
+ <img alt="Linux" src="https://img.shields.io/badge/Linux-x64%20%7C%20arm64-FCC624?logo=linux&logoColor=black">
15
+ <img alt="Windows" src="https://img.shields.io/badge/Windows-x64-0078D6?logo=windows&logoColor=white">
16
+ </p>
17
+
18
+ <p align="center">
19
+ <a href="#claude-code-in-30-seconds"><img alt="Claude Code" src="https://img.shields.io/badge/Claude%20Code-plugin-5D4E75"></a>
20
+ <a href="#mcp-only-setup"><img alt="OpenAI Codex" src="https://img.shields.io/badge/OpenAI%20Codex-MCP-111827"></a>
21
+ <a href="#mcp-only-setup"><img alt="Cursor" src="https://img.shields.io/badge/Cursor-MCP-111111"></a>
22
+ <a href="#mcp-only-setup"><img alt="VS Code" src="https://img.shields.io/badge/VS%20Code-MCP-007ACC"></a>
23
+ <a href="#mcp-only-setup"><img alt="Claude Desktop" src="https://img.shields.io/badge/Claude%20Desktop-MCP-D97757"></a>
24
+ <a href="#mcp-only-setup"><img alt="Gemini CLI" src="https://img.shields.io/badge/Gemini%20CLI-MCP-4285F4"></a>
25
+ <a href="#what-you-get"><img alt="Obsidian" src="https://img.shields.io/badge/Obsidian-Markdown%20pages-7C3AED"></a>
26
+ </p>
27
+
28
+ **A living personal knowledge library for the AI-native age, built by your agents and grounded in its sources.**
29
+
30
+ Wenlan (文瀾) takes its name from an imperial library that held one of China's largest book collections. Your agents capture what they learn as they work, and you add the pages and sources you already trust, so the library grows from the bottom up and the top down. Wenlan keeps it current on its own, distilling both into source-cited wiki pages.
31
+
32
+ Each session opens with a brief and closes with a handoff, so the thread carries forward instead of restarting.
33
+
34
+ Unlike a static llm-wiki, it keeps evolving between sessions. Unlike a black-box memory, every page shows its sources, so you can read, trust, or correct it.
35
+
36
+ [![Watch the Wenlan demo](./docs/assets/demo-preview.gif)](https://youtu.be/k37gjWVPHwI)
37
+
38
+ ---
39
+
40
+ ## What makes Wenlan distinct
41
+
42
+ 1. **Evolves on its own.** Most memory tools just hand back what you put in. Wenlan keeps working between sessions: it dedupes, links, and clusters your captures into source-cited wiki pages that feed retrieval alongside the atomic notes they came from. Unlike a static llm-wiki, the library stays current without you maintaining it.
43
+ 2. **One home, locked to none.** Every MCP client queries the same local daemon, so context built in one tool shows up in the next. Obsidian is one optional view you can symlink in, not where your work lives.
44
+ 3. **Sourced, so you can trust it.** Every page cites the memories it came from, and the daemon refuses unsourced pages rather than letting hallucinated summaries in. Low-confidence captures and contradictions surface for you to confirm or correct, but the everyday flow never stops for approval. Fix something once and Wenlan supersedes the old fact instead of serving both.
45
+ 4. **Real git versioning.** Memory, page, and session writes commit into `~/.wenlan/.git/`, so you can inspect, diff, revert, or branch the Markdown artifacts.
46
+ ```text
47
+ a1b2c3d page: embedding-retrieval refreshed (4 sources)
48
+ 9f8e7d6 session: handoff embedding-work
49
+ 5a4b3c2 capture: decision mem_abc123
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Quickstart
55
+
56
+ ### Claude Code in 30 seconds
57
+
58
+ ```text
59
+ /plugin marketplace add 7xuanlu/claude-plugins
60
+ /plugin install origin@7xuanlu
61
+ /init
62
+ ```
63
+
64
+ If Claude Code asks for a restart after installing, restart once, then run `/init`. The plugin handles daemon setup, MCP wiring, local memory setup, and the first round-trip check.
65
+
66
+ Then try `/brief`, `/capture <decision>`, or `/handoff` inside Claude Code.
67
+
68
+ Plugin details and daily commands: [plugin/](plugin/.claude-plugin/README.md).
69
+
70
+ ### MCP-only setup
71
+
72
+ Use this if you want Wenlan tools in Claude Code without the plugin, or in Codex, Cursor, Claude Desktop, VS Code, or Gemini CLI.
73
+
74
+ ```bash
75
+ npx -y wenlan setup
76
+ ~/.wenlan/bin/wenlan mcp add claude-code # or: codex, cursor, claude-desktop, vscode, gemini
77
+ ```
78
+
79
+ MCP-only gives agents tools for capture, recall, context, doctor, and page distillation. It does not install Claude Code slash skills like `/brief`, `/handoff`, `/distill`, or `/init`.
80
+
81
+ ### Terminal runtime setup
82
+
83
+ Set up the local Wenlan runtime:
84
+
85
+ ```bash
86
+ npx -y wenlan setup
87
+ ```
88
+
89
+ Then start with `~/.origin/bin/origin status`, `~/.origin/bin/origin recall <query>`, or `~/.origin/bin/origin store <text>`. CLI details: [crates/wenlan-cli](crates/wenlan-cli/README.md).
90
+
91
+ Service management:
92
+
93
+ ```bash
94
+ origin install # register + start the daemon (stops a running one first)
95
+ origin restart # stop + start the daemon -- run this after upgrading
96
+ origin status
97
+ origin uninstall
98
+ ```
99
+
100
+ After upgrading Wenlan (`npx -y wenlan setup` or `install.sh`), the new binary is on disk but the already-running daemon keeps serving the old code until you restart it. `wenlan install` now restarts automatically; if you upgraded another way, run `wenlan restart`.
101
+
102
+ ---
103
+
104
+ ## How Wenlan works
105
+
106
+ The same loop runs every session: capture while you work, let the daemon refine between sessions, and return with the knowledge already in context.
107
+
108
+ ```text
109
+ ┌──────── loops back · /handoff closes each pass ─────────┐
110
+ ▼ │
111
+ ┌─────┴─────┐ ┌─────────────┐ ┌────────────────┐ ┌─────┴─────┐
112
+ │ CAPTURE │ │ DAEMON │ │ ONE STORE │ │ RECALL + │
113
+ │ in flow │ ─▶ │ refines │ ─▶ │ (local) │ ─▶ │ BRIEF │
114
+ │ /capture │ │ between │ │ · memories │ │ next │
115
+ │ │ │ sessions │ │ · wiki pages │ │ session │
116
+ │ │ │ dedup·link │ │ · graph │ │ /recall │
117
+ │ │ │ /distill │ │ │ │ /brief │
118
+ └───────────┘ └─────────────┘ └────────────────┘ └───────────┘
119
+ one local daemon · one store · every MCP client reads it
120
+ Claude Code · Cursor · Codex · Claude Desktop · VS Code · Gemini
121
+ ```
122
+
123
+ Each pass leaves the store sharper. Captures that would sit as loose snippets elsewhere get deduped, linked to the people and projects they touch, and distilled into source-citing pages, so the next session brings back knowledge, not raw history. That is the compounding the loop is named for.
124
+
125
+ These five verbs drive it:
126
+
127
+ 1. **Session starts.** `/brief [topic]` loads project status, identity, preferences, and topic-relevant memories so the agent walks in with context.
128
+ 2. **During work.** `/capture <thing>` saves a decision, lesson, gotcha, or project fact in flow. `/recall <query>` looks anything up.
129
+ 3. **Session ends.** `/handoff` writes what changed, what's still open, and where to continue, so the next run picks up cleanly.
130
+ 4. **Between sessions.** The daemon deduplicates overlapping captures and links related ideas in the background. `/distill` synthesizes wiki pages from clusters of related memories when you want a deliberate pass.
131
+ 5. **Next session.** `/brief` brings it back in the Claude Code plugin; MCP-only clients call the `context` tool for the same memory. Recall pulls the relevant slice, not your whole history, so the context window goes to the work.
132
+
133
+ Full skill reference: [plugin/skills](plugin/skills/README.md).
134
+
135
+ Works fully local with no API key, cloud account, or signup. Capture, recall, hybrid search, and graph context need nothing external; add a local model or API key only for automatic page distillation. No telemetry.
136
+
137
+ ---
138
+
139
+ ## What you get
140
+
141
+ - **Atomic memory layer**: every capture is stored first as a typed memory with source agent, confidence, stability, and supersession metadata.
142
+ - **Source-backed pages**: pages keep source memory IDs, stale reasons, and revision state so distillation can refresh them without losing provenance.
143
+ - **Hybrid retrieval on libSQL**: memories, pages, FTS5 text, vector embeddings, and graph context in one local store your MCP clients can query, fused with reciprocal-rank fusion. An optional local cross-encoder reranker sharpens the top results.
144
+ - **Connected recall**: people, projects, tools, and decisions come back linked, so a memory arrives with the context around it instead of alone.
145
+ - **Distill cycles**: run `/distill` manually today, or add a local model/API key for background extraction, page refreshes, recaps, and richer graph links.
146
+ - **Stays fresh on its own**: background passes link entities, grow matching pages, and update each memory's effective confidence from type, access, and age, so recent and load-bearing memories surface while stale ones fade.
147
+ - **Review before trust**: low-confidence captures, pending revisions, contradictions, and supersessions can surface instead of silently entering context.
148
+ - **Explicit spaces**: tag memories, pages, and recalls with `space=work | personal | client-X` so a day-job capture never bleeds into a side-project brief. Auto-detected from the current repo or workspace when no space is set; overridable always.
149
+ - **You own the data**: everything is plain Markdown under `~/.wenlan/`, versioned in git. Grep it, symlink it into Obsidian, or walk away with the files anytime. No lock-in.
150
+
151
+ ### Spaces
152
+
153
+ Memories belong to a **space** like `wenlan`, `career`, or
154
+ `ideas`. Set the active space per shell:
155
+
156
+ WENLAN_SPACE=career claude
157
+
158
+ Or declaratively via `~/.wenlan/spaces.toml` (see
159
+ `plugin/examples/spaces.toml`). To manage spaces from the CLI:
160
+
161
+ wenlan space list
162
+ wenlan space add ideas --default
163
+ wenlan space show ideas
164
+ wenlan space move scratch career
165
+
166
+ `origin doctor` prints the current resolver state so you can see exactly
167
+ which layer chose the active space.
168
+
169
+ ---
170
+
171
+ ## Evaluation
172
+
173
+ **Hybrid retrieval, transparent eval.** BGE-Base-EN-v1.5-Q + FTS5 + Reciprocal Rank Fusion; local BGE-Reranker-Base cross-encoder rerank is the default path when enabled, with BGE-Reranker-V2-M3 available as a higher-quality option. The table below is retrieval-only, not end-to-end answer quality. ~168 tokens per recall query. Eval harness at [`crates/wenlan-core/src/eval/`](crates/wenlan-core/src/eval/). Run it yourself.
174
+
175
+ Update workflow in [docs/eval](docs/eval/README.md).
176
+
177
+
178
+ <!-- EVAL_SNAPSHOT_START -->
179
+ | Benchmark | Recall@5 | MRR | NDCG@10 |
180
+ |---|---:|---:|---:|
181
+ | LongMemEval (oracle, 500 Q) | 93.6% | 0.857 | 0.883 |
182
+ | LoCoMo (locomo10) | 70.0% | 0.647 | 0.684 |
183
+ <!-- EVAL_SNAPSHOT_END -->
184
+
185
+
186
+ ---
187
+
188
+ ## Repo Map
189
+
190
+ Wenlan is daemon-first. `wenlan-server` owns the local database, embeddings, distill cycles, knowledge graph, and HTTP API on `127.0.0.1:7878`. The plugin, MCP server, CLI, and local tools are thin clients over that daemon.
191
+
192
+
193
+ | Path | What lives there |
194
+ | ------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
195
+ | [crates/wenlan-core](crates/wenlan-core/README.md) | Storage, search, embeddings, distill cycles, graph, pages, export, eval. |
196
+ | [crates/wenlan-server](crates/wenlan-server/README.md) | Local daemon and HTTP API. |
197
+ | [crates/wenlan-mcp](crates/wenlan-mcp/README.md) | MCP server, tools, npm package. |
198
+ | [crates/wenlan-cli](crates/wenlan-cli/README.md) | User CLI for setup, service management, search, recall, store, list, agents, model/key setup, and doctor. |
199
+ | [plugin/](plugin/.claude-plugin/README.md) | Claude Code plugin (`plugin.json`, skills, hooks, `.mcp.json`). |
200
+ | [docs/eval](docs/eval/README.md) | Benchmark workflow and methodology. |
201
+
202
+
203
+ Full contributor map: [CLAUDE.md](CLAUDE.md).
204
+
205
+ ---
206
+
207
+ ## Build from source
208
+
209
+ Wenlan builds natively on macOS (Apple Silicon + Intel), Linux (x86_64 + ARM64; glibc), and Windows (x86_64). The npm wrapper (`wenlan`, `wenlan-mcp`) and `install.sh` auto-detect your platform and pull the matching prebuilt release. Most users should install through the Claude Code plugin or `npx`. For local development:
210
+
211
+ ```bash
212
+ git clone https://github.com/7xuanlu/wenlan.git
213
+ cd wenlan
214
+ cargo build --workspace
215
+ cargo run -p wenlan-server
216
+ ```
217
+
218
+ Build details for the daemon, MCP server, CLI, and core crates live in the crate READMEs linked above. Cross-platform specifics (service registration, paths, Windows install limitation) live in [AGENTS.md](AGENTS.md#cross-platform).
219
+
220
+ ---
221
+
222
+ ## Learn more
223
+
224
+ Longer-form writing on AI work memory and how Wenlan compares lives at [useorigin.app/learn](https://useorigin.app/learn):
225
+
226
+ **Concepts**
227
+ - [What is AI work memory?](https://useorigin.app/learn/ai-work-memory): the shape of the problem Wenlan solves
228
+ - [MCP memory server](https://useorigin.app/learn/mcp-memory-server): how Wenlan exposes memory through the Model Context Protocol
229
+ - [Local-first AI memory](https://useorigin.app/learn/local-first-ai-memory): data, privacy, and control
230
+ - [Markdown + local index](https://useorigin.app/learn/markdown-local-index-ai-memory): the storage model
231
+ - [AI agent handoff loop](https://useorigin.app/learn/ai-agent-handoff-loop): session-end discipline that prevents context loss
232
+
233
+ **Comparisons**
234
+ - [Wenlan vs Basic Memory](https://useorigin.app/learn/origin-vs-basic-memory): Markdown knowledge base vs AI work-session memory
235
+ - [Wenlan vs claude-mem](https://useorigin.app/learn/origin-vs-claude-mem): observer-style Claude Code memory vs MCP-first cross-tool memory
236
+ - [Wenlan vs Superlocal Memory](https://useorigin.app/learn/origin-vs-superlocal-memory): includes the honest LoCoMo benchmark concession
237
+
238
+ **Docs**
239
+ - [Get started](https://useorigin.app/docs/get-started): install + verify the first local memory loop
240
+ - [Daily workflow](https://useorigin.app/docs/daily-workflow): capture, handoff, distill
241
+ - [MCP clients](https://useorigin.app/docs/mcp-clients): connect Claude Code, Cursor, Codex, Claude Desktop, Gemini CLI
242
+
243
+ ---
244
+
245
+ ## What Wenlan is NOT
246
+
247
+ - **Not a Life OS.** No habits, calendar, journal, or life-management modules. Wenlan scopes to AI work artifacts only. If you want a full personal OS, look at [PAI](https://github.com/danielmiessler/PAI).
248
+ - **Not a workflow suite.** ~30 MCP tools across one daemon. If you want 30+ skills, 8+ agents, and an auto-research loop bundled, look at [pro-workflow](https://github.com/rohitg00/pro-workflow). Wenlan trades breadth for focus.
249
+ - **Not a memory infrastructure SDK.** For people using AI daily, not as a backend for other apps building memory features.
250
+ - **Not for one-off chats.** Best when work spans sessions, projects, and weeks.
251
+
252
+ ---
253
+
254
+ ## Contributing
255
+
256
+ Bug fixes, eval cases, docs, and features are welcome. Start with [CONTRIBUTING.md](CONTRIBUTING.md). Architecture and development rules are in [CLAUDE.md](CLAUDE.md). Security reports: [SECURITY.md](SECURITY.md). Please also read the [Code of Conduct](CODE_OF_CONDUCT.md).
257
+
258
+ ---
259
+
260
+ ## License
261
+
262
+ Wenlan is licensed under **Apache-2.0**. This includes the local runtime, CLI, MCP server, shared types, and Claude Code plugin files in this repo.
263
+
264
+ The permissive license keeps the daemon boundary usable for MCP clients and downstream local tools.
265
+
266
+ ---
267
+
268
+ ## Acknowledgments
269
+
270
+ Predecessors:
271
+
272
+ - [Karpathy's LLM-wiki note](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f). Raw-to-wiki distillation pattern.
273
+ - Claude Code's `MEMORY.md`. The simplest version of the idea.
274
+
275
+ Peers:
276
+
277
+ - [agentmemory](https://github.com/rohitg00/agentmemory). Agent-side memory framework.
278
+ - [basic-memory](https://github.com/basicmachines-co/basic-memory). Local-first knowledge management for Claude.
279
+ - [obsidian-mind](https://github.com/breferrari/obsidian-mind). Obsidian-native memory and review loop for coding agents.
280
+ - [pro-workflow](https://github.com/rohitg00/pro-workflow). Claude Code productivity suite.
281
+ - [mcp-memory-service](https://github.com/doobidoo/mcp-memory-service). Memory service for MCP.
282
+ - [Memoria](https://github.com/matrixorigin/Memoria). "Git for AI Agent Memory" via Copy-on-Write.
283
+ - [OpenMemory](https://github.com/CaviraOSS/OpenMemory), [claude-memory-compiler](https://github.com/coleam00/claude-memory-compiler), [PAI](https://github.com/danielmiessler/PAI), Palinode. Adjacent shapes.
284
+
285
+ Different shapes of the same problem. Try the one that fits.
package/install.js ADDED
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { existsSync, mkdirSync, chmodSync } = require("fs");
5
+ const { join } = require("path");
6
+ const { spawnSync } = require("child_process");
7
+ const https = require("https");
8
+ const http = require("http");
9
+ const os = require("os");
10
+ const fs = require("fs");
11
+ const path = require("path");
12
+
13
+ const VERSION = require("./package.json").version;
14
+ const REPO = "7xuanlu/wenlan";
15
+
16
+ // Maps Node platform-arch to the release bundle filename shipped by release.yml.
17
+ // Each bundle contains wenlan, wenlan-server, and wenlan-mcp (or .exe on Windows).
18
+ const ASSETS = {
19
+ "darwin-arm64": { file: "wenlan-darwin-arm64.tar.gz", archive: "tar.gz" },
20
+ "linux-arm64": { file: "wenlan-linux-arm64.tar.gz", archive: "tar.gz" },
21
+ "linux-x64": { file: "wenlan-linux-x64.tar.gz", archive: "tar.gz" },
22
+ "win32-x64": { file: "wenlan-windows-x64.zip", archive: "zip" },
23
+ };
24
+
25
+ const key = `${process.platform}-${process.arch}`;
26
+ const asset = ASSETS[key];
27
+
28
+ if (!asset) {
29
+ console.error(`Unsupported platform: ${key}`);
30
+ console.error(`Supported: ${Object.keys(ASSETS).join(", ")}`);
31
+ process.exit(1);
32
+ }
33
+
34
+ const isWindows = process.platform === "win32";
35
+ const binaryName = isWindows ? "wenlan-mcp.exe" : "wenlan-mcp";
36
+ const installName = isWindows ? "wenlan-mcp.exe" : "wenlan-mcp";
37
+
38
+ const binDir = join(__dirname, "bin");
39
+ const dest = join(binDir, installName);
40
+
41
+ mkdirSync(binDir, { recursive: true });
42
+
43
+ const downloadUrl = `https://github.com/${REPO}/releases/download/v${VERSION}/${asset.file}`;
44
+
45
+ console.log(`Downloading wenlan-mcp ${VERSION} for ${key}...`);
46
+
47
+ function download(url, dest, redirects = 0) {
48
+ return new Promise((resolve, reject) => {
49
+ if (redirects > 10) {
50
+ return reject(new Error("Too many redirects"));
51
+ }
52
+ const mod = url.startsWith("https") ? https : http;
53
+ mod.get(url, { headers: { "User-Agent": "wenlan-mcp-npm" } }, (res) => {
54
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
55
+ return download(res.headers.location, dest, redirects + 1).then(resolve, reject);
56
+ }
57
+ if (res.statusCode !== 200) {
58
+ return reject(new Error(`Download failed: HTTP ${res.statusCode}\nURL: ${url}`));
59
+ }
60
+ const file = fs.createWriteStream(dest);
61
+ res.pipe(file);
62
+ file.on("finish", () => {
63
+ file.close();
64
+ resolve();
65
+ });
66
+ file.on("error", reject);
67
+ }).on("error", reject);
68
+ });
69
+ }
70
+
71
+ function extractBinary(archivePath, archiveType, outputDir) {
72
+ if (archiveType === "tar.gz") {
73
+ // tar is available on macOS, all Linux, and Windows 10 1803+ / Server 2019+.
74
+ const result = spawnSync(
75
+ "tar",
76
+ ["-xzf", archivePath, "-C", outputDir, binaryName],
77
+ { stdio: "inherit" }
78
+ );
79
+ if (result.error) throw result.error;
80
+ if (result.status !== 0) throw new Error(`tar exited with status ${result.status}`);
81
+ } else if (archiveType === "zip") {
82
+ // bsdtar ships with Windows 10 1803+ and can read zip files.
83
+ const result = spawnSync(
84
+ "tar",
85
+ ["-xf", archivePath, "-C", outputDir, binaryName],
86
+ { stdio: "inherit" }
87
+ );
88
+ if (result.error) throw result.error;
89
+ if (result.status !== 0) throw new Error(`tar (zip) exited with status ${result.status}`);
90
+ } else {
91
+ throw new Error(`Unknown archive type: ${archiveType}`);
92
+ }
93
+ }
94
+
95
+ async function install() {
96
+ const tmpDir = os.tmpdir();
97
+ const archivePath = path.join(tmpDir, asset.file);
98
+
99
+ try {
100
+ await download(downloadUrl, archivePath);
101
+ extractBinary(archivePath, asset.archive, binDir);
102
+
103
+ if (!isWindows) {
104
+ chmodSync(dest, 0o755);
105
+ }
106
+
107
+ console.log(`wenlan-mcp installed successfully (${key})`);
108
+ } finally {
109
+ // Clean up downloaded archive regardless of success or failure.
110
+ try {
111
+ if (existsSync(archivePath)) {
112
+ fs.unlinkSync(archivePath);
113
+ }
114
+ } catch (_) {
115
+ // Best-effort cleanup; ignore errors.
116
+ }
117
+ }
118
+ }
119
+
120
+ install().catch((err) => {
121
+ console.error(`Failed to install wenlan-mcp: ${err.message}`);
122
+ process.exit(1);
123
+ });
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "wenlan-mcp",
3
+ "version": "0.9.0",
4
+ "description": "Local-first memory layer for AI agents - MCP server",
5
+ "keywords": [
6
+ "mcp",
7
+ "ai-memory",
8
+ "llm-wiki",
9
+ "long-term-memory",
10
+ "local-first",
11
+ "wiki",
12
+ "memory",
13
+ "ai",
14
+ "llm",
15
+ "agents",
16
+ "claude",
17
+ "chatgpt",
18
+ "origin"
19
+ ],
20
+ "homepage": "https://github.com/7xuanlu/wenlan#readme",
21
+ "bugs": {
22
+ "url": "https://github.com/7xuanlu/wenlan/issues"
23
+ },
24
+ "author": "7xuanlu <h164654156465@gmail.com>",
25
+ "license": "Apache-2.0",
26
+ "bin": {
27
+ "wenlan-mcp": "run.js"
28
+ },
29
+ "scripts": {
30
+ "postinstall": "node install.js"
31
+ },
32
+ "engines": {
33
+ "node": ">=18"
34
+ },
35
+ "os": [
36
+ "darwin",
37
+ "linux",
38
+ "win32"
39
+ ],
40
+ "cpu": [
41
+ "arm64",
42
+ "x64"
43
+ ],
44
+ "files": [
45
+ "install.js",
46
+ "run.js",
47
+ "README.md",
48
+ "LICENSE"
49
+ ],
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "https://github.com/7xuanlu/wenlan",
53
+ "directory": "crates/wenlan-mcp/npm"
54
+ }
55
+ }
package/run.js ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawn } = require("child_process");
5
+ const { join } = require("path");
6
+
7
+ const binaryName = process.platform === "win32" ? "wenlan-mcp.exe" : "wenlan-mcp";
8
+ const bin = join(__dirname, "bin", binaryName);
9
+ const child = spawn(bin, process.argv.slice(2), { stdio: "inherit" });
10
+
11
+ child.on("exit", (code) => process.exit(code ?? 1));
12
+ process.on("SIGTERM", () => child.kill("SIGTERM"));
13
+ process.on("SIGINT", () => child.kill("SIGINT"));