memkin 0.4.0 → 0.4.1

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 (129) hide show
  1. package/README.en.md +108 -836
  2. package/README.md +108 -836
  3. package/README.zh-CN.md +80 -44
  4. package/dist/cli-stores.d.ts +12 -0
  5. package/dist/cli-stores.d.ts.map +1 -1
  6. package/dist/cli-stores.js +15 -1
  7. package/dist/cli-stores.js.map +1 -1
  8. package/dist/cli.js +94 -6
  9. package/dist/cli.js.map +1 -1
  10. package/dist/collectors/agent/claude-code.d.ts.map +1 -1
  11. package/dist/collectors/agent/claude-code.js +10 -29
  12. package/dist/collectors/agent/claude-code.js.map +1 -1
  13. package/dist/collectors/agent/codex.d.ts.map +1 -1
  14. package/dist/collectors/agent/codex.js +24 -10
  15. package/dist/collectors/agent/codex.js.map +1 -1
  16. package/dist/collectors/agent/collector.d.ts +38 -0
  17. package/dist/collectors/agent/collector.d.ts.map +1 -1
  18. package/dist/collectors/agent/collector.js +91 -20
  19. package/dist/collectors/agent/collector.js.map +1 -1
  20. package/dist/collectors/agent/hermes.d.ts.map +1 -1
  21. package/dist/collectors/agent/hermes.js +5 -1
  22. package/dist/collectors/agent/hermes.js.map +1 -1
  23. package/dist/collectors/feishu/sources/calendar.d.ts.map +1 -1
  24. package/dist/collectors/feishu/sources/calendar.js +18 -7
  25. package/dist/collectors/feishu/sources/calendar.js.map +1 -1
  26. package/dist/consolidator/consolidator.d.ts +9 -1
  27. package/dist/consolidator/consolidator.d.ts.map +1 -1
  28. package/dist/consolidator/consolidator.js +7 -0
  29. package/dist/consolidator/consolidator.js.map +1 -1
  30. package/dist/consolidator/entity-merge.d.ts +33 -0
  31. package/dist/consolidator/entity-merge.d.ts.map +1 -0
  32. package/dist/consolidator/entity-merge.js +148 -0
  33. package/dist/consolidator/entity-merge.js.map +1 -0
  34. package/dist/core/agent-session-scanner.d.ts +23 -0
  35. package/dist/core/agent-session-scanner.d.ts.map +1 -0
  36. package/dist/core/agent-session-scanner.js +69 -0
  37. package/dist/core/agent-session-scanner.js.map +1 -0
  38. package/dist/core/canonicalize.d.ts +8 -0
  39. package/dist/core/canonicalize.d.ts.map +1 -1
  40. package/dist/core/canonicalize.js +12 -2
  41. package/dist/core/canonicalize.js.map +1 -1
  42. package/dist/core/config.d.ts +6 -0
  43. package/dist/core/config.d.ts.map +1 -1
  44. package/dist/core/config.js.map +1 -1
  45. package/dist/core/identity-resolver.d.ts +53 -3
  46. package/dist/core/identity-resolver.d.ts.map +1 -1
  47. package/dist/core/identity-resolver.js +112 -17
  48. package/dist/core/identity-resolver.js.map +1 -1
  49. package/dist/core/person-identity.d.ts +38 -3
  50. package/dist/core/person-identity.d.ts.map +1 -1
  51. package/dist/core/person-identity.js +58 -29
  52. package/dist/core/person-identity.js.map +1 -1
  53. package/dist/core/pipeline-factory.d.ts.map +1 -1
  54. package/dist/core/pipeline-factory.js +2 -1
  55. package/dist/core/pipeline-factory.js.map +1 -1
  56. package/dist/core/pipeline.js +3 -3
  57. package/dist/core/pipeline.js.map +1 -1
  58. package/dist/daemon/autostart/daemon-state.d.ts +32 -0
  59. package/dist/daemon/autostart/daemon-state.d.ts.map +1 -1
  60. package/dist/daemon/autostart/daemon-state.js +27 -1
  61. package/dist/daemon/autostart/daemon-state.js.map +1 -1
  62. package/dist/daemon/scheduler.d.ts +10 -0
  63. package/dist/daemon/scheduler.d.ts.map +1 -1
  64. package/dist/daemon/scheduler.js +20 -1
  65. package/dist/daemon/scheduler.js.map +1 -1
  66. package/dist/demo/seed.d.ts +32 -0
  67. package/dist/demo/seed.d.ts.map +1 -0
  68. package/dist/demo/seed.js +185 -0
  69. package/dist/demo/seed.js.map +1 -0
  70. package/dist/embedded-assets.generated.d.ts.map +1 -1
  71. package/dist/embedded-assets.generated.js +2 -2
  72. package/dist/embedded-assets.generated.js.map +1 -1
  73. package/dist/eval/golden.d.ts +107 -0
  74. package/dist/eval/golden.d.ts.map +1 -0
  75. package/dist/eval/golden.js +74 -0
  76. package/dist/eval/golden.js.map +1 -0
  77. package/dist/eval/judge.d.ts +82 -0
  78. package/dist/eval/judge.d.ts.map +1 -0
  79. package/dist/eval/judge.js +130 -0
  80. package/dist/eval/judge.js.map +1 -0
  81. package/dist/eval/manifest.d.ts +107 -0
  82. package/dist/eval/manifest.d.ts.map +1 -0
  83. package/dist/eval/manifest.js +84 -0
  84. package/dist/eval/manifest.js.map +1 -0
  85. package/dist/eval/metrics.d.ts +87 -0
  86. package/dist/eval/metrics.d.ts.map +1 -0
  87. package/dist/eval/metrics.js +97 -0
  88. package/dist/eval/metrics.js.map +1 -0
  89. package/dist/extractors/noise-filter.d.ts +7 -3
  90. package/dist/extractors/noise-filter.d.ts.map +1 -1
  91. package/dist/extractors/noise-filter.js +16 -3
  92. package/dist/extractors/noise-filter.js.map +1 -1
  93. package/dist/extractors/signal-extractor.d.ts.map +1 -1
  94. package/dist/extractors/signal-extractor.js +13 -2
  95. package/dist/extractors/signal-extractor.js.map +1 -1
  96. package/dist/lifecycle/legacy-migration.d.ts +6 -2
  97. package/dist/lifecycle/legacy-migration.d.ts.map +1 -1
  98. package/dist/lifecycle/legacy-migration.js +69 -4
  99. package/dist/lifecycle/legacy-migration.js.map +1 -1
  100. package/dist/server/api.d.ts.map +1 -1
  101. package/dist/server/api.js +18 -7
  102. package/dist/server/api.js.map +1 -1
  103. package/dist/server/backfill-routes.d.ts.map +1 -1
  104. package/dist/server/backfill-routes.js +2 -1
  105. package/dist/server/backfill-routes.js.map +1 -1
  106. package/dist/server/mcp.d.ts +4 -4
  107. package/dist/store/agent-sessions.d.ts +59 -0
  108. package/dist/store/agent-sessions.d.ts.map +1 -0
  109. package/dist/store/agent-sessions.js +119 -0
  110. package/dist/store/agent-sessions.js.map +1 -0
  111. package/dist/store/database.d.ts +20 -1
  112. package/dist/store/database.d.ts.map +1 -1
  113. package/dist/store/database.js +44 -6
  114. package/dist/store/database.js.map +1 -1
  115. package/dist/store/embedding.d.ts +20 -2
  116. package/dist/store/embedding.d.ts.map +1 -1
  117. package/dist/store/embedding.js +20 -5
  118. package/dist/store/embedding.js.map +1 -1
  119. package/dist/store/entity-suggestions.d.ts +62 -0
  120. package/dist/store/entity-suggestions.d.ts.map +1 -0
  121. package/dist/store/entity-suggestions.js +80 -0
  122. package/dist/store/entity-suggestions.js.map +1 -0
  123. package/dist/store/migrations/index.d.ts.map +1 -1
  124. package/dist/store/migrations/index.js +91 -0
  125. package/dist/store/migrations/index.js.map +1 -1
  126. package/dist/store/pages.d.ts.map +1 -1
  127. package/dist/store/pages.js +12 -3
  128. package/dist/store/pages.js.map +1 -1
  129. package/package.json +1 -1
package/README.en.md CHANGED
@@ -1,9 +1,11 @@
1
1
  <p align="center">
2
- <h1 align="center">Memkin</h1>
3
- <p align="center"><em>You are the sum of your working relationships.</em></p>
4
- <p align="center"><strong>A local-first memory system for your work — turning your DMs, group chats, emails, docs, and meetings into a private personal memory, so your AI agents truly know you.</strong></p>
2
+ <img src="docs/assets/memkin-cover.png" alt="Memkin — an AI that finally knows you" width="100%">
5
3
  </p>
6
4
 
5
+ <h1 align="center">An AI that finally knows you</h1>
6
+
7
+ <p align="center"><strong>Your AI agents forget everything between sessions. Memkin turns your Claude Code / Codex sessions — and your work chats, meetings, and email — into a private, local-first memory graph that any agent can tap over MCP.</strong></p>
8
+
7
9
  <p align="center">
8
10
  <a href="README.md">简体中文</a> | English
9
11
  </p>
@@ -13,407 +15,104 @@
13
15
  <a href="https://www.npmjs.com/package/memkin"><img alt="npm" src="https://img.shields.io/npm/v/memkin?color=cb3837&logo=npm"></a>
14
16
  <img alt="Runtime: Bun" src="https://img.shields.io/badge/runtime-Bun-black">
15
17
  <img alt="Language: TypeScript" src="https://img.shields.io/badge/lang-TypeScript-3178c6">
16
- <img alt="Tests: 1000+" src="https://img.shields.io/badge/tests-1000%2B-success">
18
+ <img alt="Tests: 1700+" src="https://img.shields.io/badge/tests-1700%2B-success">
17
19
  </p>
18
20
 
19
21
  <p align="center">
20
- <a href="#quick-start">Quick Start</a>
21
- <a href="#features">Features</a> •
22
- <a href="#use-cases">Use Cases</a> •
23
- <a href="#architecture">Architecture</a> •
24
- <a href="#cli-reference">CLI Reference</a> •
25
- <a href="#roadmap">Roadmap</a>
26
- </p>
27
-
28
- <p align="center">
29
- <img src="https://raw.githubusercontent.com/AndreLYL/memkin/main/docs/assets/web-ui-graph.jpeg" alt="Memkin knowledge graph — entities, decisions, tasks, and knowledge connected across your work" width="850">
22
+ <img src="docs/assets/demo.gif" alt="Asking Memkin inside Claude Code: what did I discuss with Alice about the launch last week? — answered with [n] citations" width="850">
30
23
  <br>
31
- <em>Your work, as a living knowledge graph people, decisions, tasks, and knowledge, connected.</em>
24
+ <em>Ask inside Claude Code Memkin answers over MCP, with citations back to the source.</em>
32
25
  </p>
33
26
 
34
- <!-- TODO(demo): replace with an 8-12s demo GIF — ask Memkin a question inside Claude Code
35
- and watch the agent recall a Feishu meeting decision + linked task over MCP.
36
- Research shows a GIF of "the product actually working" is the single highest-converting
37
- element in a README. -->
38
-
39
27
  ---
40
28
 
41
- ## The Problem
42
-
43
- Your work memory has two homes, and your AI agents can't reach either.
44
-
45
- - **Feishu (Lark)** holds your working relationships — DMs, group chats, emails, meetings, tasks. This is *what* you work on and *who* you work with.
46
- - **AI agents** (Claude Code, Codex, OpenClaw) hold your building process — the decisions, discoveries, and dead-ends from every coding session.
47
-
48
- But every time you open a new agent session, it knows nothing. You re-explain who you are, what the project is, what was decided last week, and why. The context is *somewhere* — buried in chat logs and session transcripts you'll never scroll through again.
49
-
50
- **You don't have a memory problem. You have a fragmentation problem — and your agents pay for it every day.**
51
-
52
- ## The Solution
53
-
54
- Memkin is a **local-first personal memory system built for the Chinese workplace**. Work in China happens inside Feishu, DingTalk, and WeCom — Memkin pulls the DMs, group chats, emails, meetings, and docs out of these tools, together with your AI-agent sessions, and extracts them into structured signals (entities, decisions, tasks, discoveries, knowledge, relationships) — into one searchable knowledge graph on your own machine, then serves that memory back to any agent over **MCP**.
55
-
56
- > The MVP focuses on full **Feishu** capture; **DingTalk, WeCom**, and more Chinese workplace tools are on the roadmap (below).
57
-
58
- The result: your agents both **write to** and **read from** the same memory — so Claude Code, Codex, and any MCP client finally *know you and your work*.
59
-
60
- ```
61
- Feishu work AI-agent sessions
62
- (DMs / groups / email (Claude Code / Codex
63
- meetings / tasks) / OpenClaw)
64
- │ │
65
- └───────────────┬───────────────┘
66
- ▼ collect + extract (local)
67
- ┌──────────────────┐
68
- │ Your core memory │ entities · decisions · tasks
69
- │ (PGLite, local) │ knowledge · timeline · graph
70
- └────────┬─────────┘
71
- ▼ MCP
72
- Your agents know you
73
-
74
- └──── the more agents work, the better it knows you ───┘
75
- ```
76
-
77
- > "I discussed a proposal with a colleague on Feishu yesterday, implemented part of it in Claude Code today, and have a review meeting next week."
78
- >
79
- > Memkin connects these three events automatically — across platforms, across time — and hands the whole thread to your agent on demand.
80
-
81
- ## Three Pillars
82
-
83
- **🔒 Local-first, truly private**
84
- Your data never leaves your machine. PGLite embedded database stores everything, optional local embeddings via Ollama, zero cloud dependency. Dual-track privacy redaction (reversible / irreversible) scrubs sensitive data before it's written.
85
-
86
- **🕸️ An entity knowledge graph, not a pile of vector chunks**
87
- Signals are anchored to entities (people, projects, tools) and linked in a directed graph. You get answers *with context* — who, why, and what it relates to — instead of isolated similar-text fragments.
88
-
89
- **🤖 MCP-native + Feishu capture**
90
- **29 built-in MCP tools** let any agent both query and write back to your memory. Full Feishu capture (7 sources) turns your real work — requirements, proposals, team decisions — into a first-class data source, something neither pure RAG nor note apps can do.
91
-
92
- ## Features
93
-
94
- **🛰️ Full Feishu (Lark) Capture**
95
- Your work lives in Feishu. Memkin collects across **7 sources** — DMs, group chats, email, calendar, docs, tasks, and message search — turning your working relationships into structured memory. Doc capture produces upgradable "summary cards" (DocSource v2).
96
-
97
- **🤖 Agents That Know You (MCP)**
98
- Use Memkin as the memory layer for any MCP agent — Claude Code, Cursor, Claude Desktop, Windsurf. **29 built-in tools** let your agent query your history, read entity pages, and write new knowledge back. Agents are both producers and consumers of your memory.
99
-
100
- **🧠 AI-Powered Signal Extraction**
101
- An LLM pipeline extracts 7 types of structured signals from raw conversations: entities, timeline events, decisions, tasks, discoveries, knowledge, and relationships.
102
-
103
- **🔍 Hybrid Semantic Search**
104
- Full-text search (tsvector, multilingual) + vector retrieval fused with Reciprocal Rank Fusion (RRF). Ask in natural language — powered by PGLite FTS + pgvector.
105
-
106
- **♻️ Memory Consolidation (Dream Cycle)**
107
- A background consolidator automatically runs tier rotation (hot → warm → cold), repairs dead links, and infers preferences — so your memory organizes itself over time.
108
-
109
- **⏰ Resident Daemon + Scheduled Capture**
110
- A built-in daemon collects from your sources on a schedule, with run history and alerts, keeping your memory continuously fresh.
111
-
112
- **🔗 Obsidian Bidirectional Sync**
113
- Export your memory pages to an Obsidian vault (Markdown), edit them, and import them back.
114
-
115
- **🕸️ Knowledge Graph + Web UI**
116
- See the connections between people, projects, and decisions. Browse a built-in web UI with dashboard, timeline, force-directed graph, and search.
117
-
118
- **🔌 REST API**
119
- Full Hono-powered HTTP API for all store operations. Integrate with any client.
120
-
121
- ## Works With
122
-
123
- Memkin is a standard MCP stdio server and plugs into any MCP client:
124
-
125
- **Claude Code** · **Cursor** · **Claude Desktop** · **Windsurf** · and any MCP-compatible agent.
126
-
127
- ## Feature Inventory
128
-
129
- The full capability list (✅ = shipped and included in the package).
130
-
131
- ### 📥 Data Collection
132
- - ✅ Feishu group chats (OpenAPI chat/message)
133
- - ✅ Feishu DMs / recent chats (lark-cli `message_search`, user mode)
134
- - ✅ Feishu email
135
- - ✅ Feishu calendar events
136
- - ✅ Feishu tasks
137
- - ✅ Feishu doc summary cards (DocSource v2: pointer card → upgraded full card on trigger)
138
- - ✅ Claude Code sessions (`~/.claude/projects/`)
139
- - ✅ Codex CLI sessions (`~/.codex/`)
140
- - ✅ OpenClaw Hermes multi-agent sessions (`~/.openclaw/agents/`, auto sub-agent discovery)
141
- - ✅ Incremental collection: per-source cursor + content-hash dedup
142
- - ✅ Historical backfill: coverage stats, start / cancel / reset
143
-
144
- ### 🧠 Signal Extraction Pipeline
145
- - ✅ Collect → Dedup → Block Builder → Noise Filter → Signal Extractor → Privacy
146
- - ✅ Two-layer noise filtering: L1 rules + L2 LLM scoring
147
- - ✅ 7 structured signal types: entities, timeline, decisions, tasks, discoveries, knowledge, relationships
148
- - ✅ LLM providers: OpenAI / Anthropic (plus a mock for testing)
149
- - ✅ Signal scoring and entity extraction
150
- - ✅ JSON / Markdown output formats
151
- - ✅ Output adapters: store (PGLite) / file / gbrain / stdout
152
- - ✅ Provenance: every signal traces back to its source message
153
-
154
- ### 🔒 Privacy & Security
155
- - ✅ Redaction before write; data stays fully local
156
- - ✅ Dual-track modes: reversible / irreversible
157
- - ✅ Built-in redaction: phone, ID card, bank card, with custom replacement token
158
- - ✅ API keys always masked in the config center
159
-
160
- ### 🗄️ Storage & Retrieval
161
- - ✅ PGLite embedded PostgreSQL (in-process, zero external deps)
162
- - ✅ pgvector vector search
163
- - ✅ tsvector full-text search (simple tokenizer, multilingual)
164
- - ✅ RRF hybrid search (FTS + vector fusion) with compiled_truth / backlink boosts
165
- - ✅ Recursive chunking (300 words / 50-word overlap), embedding reuse + stale detection
166
- - ✅ Embeddings: OpenAI / Ollama (local)
167
-
168
- ### 🕸️ Knowledge Graph
169
- - ✅ Directed link graph with link types and context
170
- - ✅ BFS traversal (controllable depth / direction)
171
- - ✅ Backlinks
172
- - ✅ Entity anchoring: signals attach to people / projects / tools
173
- - ✅ Entity profile aggregation (signals + timeline)
174
-
175
- ### 👤 Person Identity
176
- - ✅ Identity resolution and canonicalization
177
- - ✅ Alias / handle linking (Feishu open_id, email, name, nickname, slug)
178
- - ✅ Strong / weak link strength
179
- - ✅ Person merge (re-points links / timeline / tags / aliases)
180
- - ✅ Recanonicalize slug (fix a wrong canonicalization)
181
-
182
- ### ♻️ Memory Lifecycle & Daemon
183
- - ✅ Memory consolidation (dream cycle): hot → warm → cold tier rotation
184
- - ✅ Dead-link repair
185
- - ✅ Preference inference (learns preferences from history)
186
- - ✅ Resident daemon: scheduled per-source capture, scheduling, run history, alerts
187
-
188
- ### 🔗 Sync & Interop
189
- - ✅ Obsidian bidirectional sync (export vault / import back)
190
- - ✅ MCP stdio server (29 tools)
191
- - ✅ REST API (Hono — pages / search / graph / tags / timeline / embed / extract / provenance / event stream)
192
-
193
- ### 🖥️ Web UI (React + Vite)
194
- - ✅ Dashboard overview
195
- - ✅ Timeline view (feed)
196
- - ✅ Force-directed knowledge graph
197
- - ✅ Search interface
198
- - ✅ Entity / page detail
199
- - ✅ In-browser config editing + guided setup wizard
200
-
201
- ### ⚙️ Configuration & Onboarding
202
- - ✅ Interactive config center (full-screen TUI, React + ink)
203
- - ✅ Linear Q&A wizard fallback (`--no-tui`) / fully automatic (`--auto`)
204
- - ✅ Auto-detection: runtime, API keys, existing data sources
205
- - ✅ Hardware assessment → recommends local / remote embeddings
206
- - ✅ Live connection checks (LLM / embedding API key and connectivity)
207
- - ✅ `memkin doctor` environment diagnostics
208
-
209
- ## Use Cases
210
-
211
- > Memkin answers not "what do I know" but "**what should I do**" — every scenario returns a cited, traceable action, not a pile of chunks.
212
-
213
- **🌟 Know how to talk to someone before you meet them (Hero)**
214
- *"I'm meeting Director Zhang tomorrow to negotiate a renewal price increase — what should I keep in mind?"* — `prep_for_person` **passively infers** a communication profile from your real interactions (direct vs. indirect, data-driven vs. relationship-driven, landmines), tailors advice to this goal, and flags gaps (*"nothing new about Zhang in 18 days — the profile may be stale"*). Zero questionnaire; the profile never leaves your machine.
215
-
216
- **📋 Generate a cross-channel daily report in one line**
217
- *"Help me write today's daily report"* — `daily_report` aggregates today's signals scattered across DMs, group chats, email, Feishu Minutes notes, and calendar into 7 sections: decisions / in-progress / my tasks / awaiting-reply·@mentions / relationship updates / tomorrow's reminders. Action items in meeting notes that name you land in "my tasks" automatically.
218
-
219
- **🔧 Troubleshoot by the playbook**
220
- *"Why won't the ADAS engage?"* — `troubleshoot` walks the playbook's diagnostic chain (`precedes`) to give ordered steps and explain what each result means. Playbooks can be authored by hand or auto-extracted (as drafts) from your troubleshooting conversations.
221
-
222
- **⚡ Onboard your agent to a project in seconds**
223
- *"What's the current state of the memkin project?"* — `get_session_context` pulls the aggregated decisions, open tasks, and recent timeline straight from memory, no re-explaining.
224
-
225
- **🔎 Recall a person or a thread**
226
- *"What did I discuss with this colleague last week?"* — stitches Feishu DMs, the meeting, and the follow-up task into one cited answer.
227
-
228
- ## Why Memkin
229
-
230
- | | Memkin | Pure RAG / vector search | Note apps (Obsidian / Notion) | GBrain | OpenHuman |
231
- |---|:---:|:---:|:---:|:---:|:---:|
232
- | Local-first & private | ✅ | depends | depends | ✅ | ✅ |
233
- | Open source | ✅ | varies | partial | partial | ✅ |
234
- | Feishu work capture (DM/group/email/meeting/task) | ✅ | ❌ | manual | ❌ | ❌ |
235
- | AI-agent sessions as a source | ✅ | ❌ | ❌ | ✅ | ✅ |
236
- | Agent-native: read **and** write over MCP | ✅ | ❌ | ❌ | ✅ | partial |
237
- | Entity + relationship knowledge graph | ✅ | ❌ | manual | ✅ | partial |
238
- | Structured signal extraction (not just chunks) | ✅ | ❌ | ❌ | ✅ | ✅ |
239
- | Memory consolidation + scheduled-capture daemon | ✅ | ❌ | ❌ | partial | partial |
240
-
241
- > Pure RAG gives you vectors but no entities or relationships, so answers lack context. Note apps are powerful but rely on manual upkeep. Memkin keeps it local and agent-native — with Feishu work as a first-class source.
242
-
243
- ## Quick Start
244
-
245
- ### Prerequisites
246
-
247
- - [Node.js](https://nodejs.org) >= 18 (for the `npx` / `npm` install)
248
- - (Optional) [Ollama](https://ollama.ai) for local embeddings
249
-
250
- ### One-step launch (recommended)
29
+ ## 30-Second Quick Start
251
30
 
252
31
  ```bash
253
- # Run without installing — no config? it auto-launches the setup wizard,
254
- # then starts the server and opens your browser
255
32
  npx memkin start
256
-
257
- # Running with no subcommand is equivalent to `start`
258
- npx memkin
259
33
  ```
260
34
 
261
- `memkin start` is the single-step path: if there's no `memkin.yaml`, it opens the browser setup wizard first, then starts the HTTP server and auto-opens your browser.
262
-
263
- > The npm package and the command are both `memkin`.
264
-
265
- ### Ports at a glance
266
-
267
- | Service | Default port | Address |
268
- |---------|--------------|---------|
269
- | HTTP API + Web UI | `3927` | `http://localhost:3927` |
270
- | MCP Streamable HTTP (`--mcp-http`) | `3928` | `http://localhost:3928/mcp` |
271
-
272
- > **Exposing on a LAN & auth**: the server binds `127.0.0.1` (loopback only) by default. To expose it on your LAN, use `memkin serve --host 0.0.0.0` (or set `server.host` in `memkin.yaml`) — this **requires an auth token**, or the server refuses to start. The token comes from `server.auth_token` (config) or `MEMKIN_AUTH_TOKEN` (env); once set, every API request must carry an `Authorization: Bearer <token>` header.
273
- >
274
- > ```yaml
275
- > # memkin.yaml
276
- > server:
277
- > host: 0.0.0.0
278
- > auth_token: <your-token> # or export MEMKIN_AUTH_TOKEN=<your-token>
279
- > ```
280
-
281
- ### Install (recommended: npm)
282
-
283
- ```bash
284
- # Run without installing
285
- npx memkin --help
286
-
287
- # Or install globally to get the `memkin` command
288
- npm install -g memkin
289
- ```
35
+ One command does it all: with no config it opens a browser setup wizard, then starts the server and opens the web UI; with an existing config it just starts. Bare `npx memkin` is equivalent.
290
36
 
291
- ### Install from source (development)
37
+ > Prerequisite: [Node.js](https://nodejs.org) >= 18. The npm package and the command are both `memkin`.
292
38
 
293
- ```bash
294
- git clone https://github.com/AndreLYL/memkin.git
295
- cd memkin
296
- bun install
297
- npm link # registers the `memkin` command globally
298
- ```
299
-
300
- ### Initialize Configuration
301
-
302
- `memkin init` launches an **interactive configuration center** — a full-screen TUI (built with React + ink) that lets you generate and edit `memkin.yaml` without hand-writing YAML:
303
-
304
- ```bash
305
- memkin init
306
- ```
307
-
308
- **Config center features:**
309
- - 📋 **Sectioned editing**: Overview, LLM, Embedding, Sources, Privacy, Block Builder, and more
310
- - ⌨️ **Keyboard-driven**: ↑/↓ or Tab to move between fields, Enter to edit, Ctrl+S to save, q / Esc to quit (auto-saves if dirty)
311
- - 🔌 **Live connection checks**: validates your LLM / embedding API key and connectivity as you edit
312
- - 💡 **Smart recommendations**: suggests local (Ollama) vs remote (OpenAI) embedding based on your hardware
313
- - 🔒 **Secret masking**: API keys are always shown masked
314
- - 🧭 **Auto-detection**: finds existing data sources (Claude Code, Codex, Hermes) and registers the `memkin` command
315
-
316
- **Run modes:**
317
-
318
- | Command / environment | Behavior |
319
- |---|---|
320
- | `memkin init` (in a TTY) | Full-screen TUI config center |
321
- | `memkin init --no-tui` | Linear question-and-answer wizard (fallback) |
322
- | `memkin init --auto` | Fully automatic, no prompts, uses detected defaults |
323
- | `memkin init --force` | Overwrite an existing configuration |
324
- | `MEMKIN_NO_TUI=1` | Force-disable the TUI (also auto-falls back in non-TTY environments) |
325
-
326
- > `memkin config init` is equivalent to `memkin init`. A few advanced settings (e.g. Feishu) currently need to be edited directly in `memkin.yaml` (see [Configuration](#configuration)).
327
-
328
- ### Check Environment
329
-
330
- ```bash
331
- memkin doctor
332
- ```
333
-
334
- ### Run Your First Extraction
335
-
336
- ```bash
337
- # Extract from Feishu (your work source)
338
- memkin extract --source feishu --since 3d
339
-
340
- # Extract from Claude Code
341
- memkin extract --source claude-code
342
-
343
- # Extract from all enabled sources
344
- memkin extract --source all
345
-
346
- # Dry run (no LLM calls, just scan data volume)
347
- memkin extract --source claude-code --dry-run
348
- ```
39
+ ## Three Pillars
349
40
 
350
- > Feishu requires a one-time `lark-cli` user login and a `feishu` block in `memkin.yaml`. See [Configuration](#configuration) for the full Feishu setup, including DM vs. group capture paths.
41
+ **🕸️ You are the sum of your working relationships**
42
+ Memory is not a pile of vector chunks. Signals are anchored to entities (people, projects, tools) and linked in a directed knowledge graph — you get answers *with context*: who, why, and what it relates to.
351
43
 
352
- ### Search Your Memory
44
+ **🔒 Your data never leaves your machine**
45
+ Everything lives in an embedded PGLite database on your disk, with optional local embeddings via Ollama — zero cloud dependency. Dual-track privacy redaction (reversible / irreversible) scrubs sensitive data before anything is written.
353
46
 
354
- ```bash
355
- # Hybrid search (FTS + vector)
356
- memkin search "auth middleware decision"
47
+ **🤖 Agents read *and* write**
48
+ A core set of **15 high-intent MCP tools** (`query` / `recall` / `synthesize` / `prep_for_person` / `daily_report` …) lets any agent query your history and write new decisions and discoveries back. The more your agents work, the better your memory knows you.
357
49
 
358
- # FTS-only search
359
- memkin search "JWT token" --mode fts
360
- ```
50
+ ## Give Your Coding Agent a Memory
361
51
 
362
- ### Start the Server
52
+ The fastest way in: turn your Claude Code / Codex sessions into persistent, cross-session, cross-project memory.
363
53
 
364
54
  ```bash
365
- # HTTP API + Web UI (default http://localhost:3927) auto-opens your browser
366
- memkin serve
55
+ # 1. Set up and launch (enable just the claude-code / codex sources in the wizard)
56
+ npx memkin start
367
57
 
368
- # Skip the auto-open (e.g. on a remote/headless host)
369
- memkin serve --no-open
58
+ # 2. Extract your session history into memory
59
+ npx memkin extract --source claude-code
60
+ npx memkin extract --source codex
370
61
 
371
- # MCP stdio (local direct connect for AI agents Claude Code, Cursor, etc.; no browser)
372
- memkin serve --mcp
62
+ # 3. Wire up your agent in one command (writes MCP config + a memory directive)
63
+ npx memkin install --agent claude-code
64
+ npx memkin install --agent codex
373
65
 
374
- # MCP Streamable HTTP (remote / multi-client, default http://localhost:3928/mcp; no browser)
375
- memkin serve --mcp-http
66
+ # 4. (Optional) Automatic recall hooks for Claude Code:
67
+ # new sessions start pre-loaded with recent decisions / open tasks
68
+ npx memkin hooks install
376
69
  ```
377
70
 
378
- > Without a `memkin.yaml`, `serve` tells you to run `memkin start` for one-step setup + launch, or `memkin init --web` to configure first.
71
+ Reopen your client and ask *"what did we decide on this project last week?"* the agent answers from your local memory instead of making you re-explain.
379
72
 
380
- ### Connect Your Agent (MCP)
73
+ Every coding session is full of decisions, discoveries, and dead-ends that evaporate the moment the session ends. Memkin's extraction pipeline distills them into structured signals, so the next session — in any agent — starts where the last one left off.
381
74
 
382
- **One command (recommended)**: `memkin install` writes the MCP config plus a tiny memory directive into your AI client (**global by default**, across all projects). Supports **Claude Code · Claude Desktop · Cursor · Codex · Windsurf**:
75
+ ## How It Works
383
76
 
384
- ```bash
385
- memkin install # detect installed clients and wire them up
386
- memkin install --agent claude-code # target a single client
387
- memkin install --dry-run # preview file changes, write nothing
388
- memkin uninstall # clean removal (idempotent)
389
77
  ```
390
-
391
- Reopen the client and you're set — ask "what did X tell me last week?" or "where is this project at?" and the agent will **proactively query Memkin** per the injected directive (cheap-first: `search` keyword lookup at zero cost, escalating to `query`/`recall` only if thin) instead of guessing.
392
-
393
- > Claude Desktop has no rules file, so it relies on the MCP server's `instructions` field. You can also configure things manually below.
394
-
395
- **Automatic recall on Claude Code (optional · hooks)**: go further on Claude Code so memory arrives with zero effort:
396
-
397
- ```bash
398
- memkin hooks install # SessionStart + UserPromptSubmit read hooks (on by default)
399
- memkin hooks install --write-back # also enable end-of-session auto write-back (opt-in)
400
- memkin hooks uninstall # remove
78
+ AI-agent sessions Work sources
79
+ (Claude Code / Codex (Feishu/Lark: chats,
80
+ / OpenClaw) email, calendar, docs)
81
+ │ │
82
+ └───────────────┬───────────────┘
83
+ ▼ collect + extract (local LLM pipeline)
84
+ ┌──────────────────┐
85
+ │ Your core memory │ entities · decisions · tasks
86
+ │ (PGLite, local) │ knowledge · timeline · graph
87
+ └────────┬─────────┘
88
+ ▼ MCP · CLI · REST · Web UI
89
+ Your agents know you
401
90
  ```
402
91
 
403
- - **SessionStart**: injects an "active projects / decisions / open tasks / key people" digest at the start of each session (the always-on core).
404
- - **UserPromptSubmit**: a **zero-cost FTS** probe before each prompt; injects only on a hit (≤3 items, ≤3000 chars, appended after the user message to preserve prompt cache).
405
- - **SessionEnd** (`--write-back`, off by default): asynchronous incremental extraction back into memory, so it compounds.
92
+ 1. **Collect** incremental collectors pull from your agent sessions (`~/.claude/projects/`, `~/.codex/`, `~/.openclaw/agents/`) and work sources, with per-source cursors and content-hash dedup.
93
+ 2. **Extract** an LLM pipeline (block building → two-layer noise filtering signal extraction privacy redaction) distills raw conversations into **7 core signal types**: entities, timeline events, decisions, tasks, discoveries, knowledge, and relationships (plus derived types like preferences and references).
94
+ 3. **Store** — everything lands in an embedded PGLite (PostgreSQL) database on your machine: pages, chunks, tags, timeline, and a directed entity graph, searchable via hybrid FTS + vector retrieval (RRF fusion).
95
+ 4. **Serve** — agents read and write the memory over MCP (stdio or Streamable HTTP); you browse it via CLI, REST API, or the built-in web UI (dashboard, timeline, force-directed graph, search).
96
+ 5. **Consolidate** — a background memory-consolidation pass rotates tiers (hot → warm → cold), repairs dead links, and infers preferences, while a resident daemon keeps collecting on a schedule.
406
97
 
407
- > Read hooks default on (local, cheap); write-back is explicit `--write-back` (cost + privacy, opt-in). Other clients have no lifecycle hooks and rely on the instruction layer above for model-initiated recall.
98
+ ## MCP Tools
408
99
 
409
- **Let the agent install itself**: for agents that can read a URL, just say "onboard me to Memkin following [`MEMKIN_FOR_AGENTS.md`](MEMKIN_FOR_AGENTS.md)" and it runs the commands above and self-checks. For **OpenClaw / Hermes**, use `memkin install --agent hermes` (writes `mcp_servers` into `config.yaml` + drops the `memkin` skill; run `/reload-mcp` in-session to apply); or scaffold the skill alone with `memkin skill scaffold --dir ~/.hermes/skills`.
100
+ The MCP server exposes a default toolset headlined by **15 high-intent tools**, plus session/entity/identity helpers; 12 low-level legacy tools are hidden by default (`mcp.expose_legacy_tools: true` in `memkin.yaml`), for **36 tools** in total.
410
101
 
411
- Memkin offers two MCP transports — pick by scenario:
102
+ | Category | Tools |
103
+ |----------|-------|
104
+ | **Retrieval (high-intent)** | `query`, `search`, `get_page_context`, `timeline_feed`, `explore_graph` |
105
+ | **Synthesis (high-intent)** | `synthesize`, `recall` (cited, gap-aware composed answers with inline `[n]`), `prep_for_person` (passively inferred communication profile → goal-conditioned strategy), `daily_report` (cross-channel daily digest), `troubleshoot` (playbook-guided diagnosis) |
106
+ | **Write (high-intent)** | `put_page`, `add_timeline_entry`, `manage_links`, `manage_tags` |
107
+ | **Health (high-intent)** | `get_health` |
108
+ | **Session / entity** | `get_session_context`, `get_entity_profile`, `list_signals_by_entity` |
109
+ | **Identity (people)** | `link_person_alias`, `list_person_handles`, `remove_person_alias`, `merge_persons`, `recanonicalize_person` |
110
+ | **Feishu docs** | `ingest_feishu_doc` |
111
+ | **Legacy (hidden by default)** | `get_page`, `list_pages`, `get_chunks`, `add_link`, `remove_link`, `get_links`, `get_backlinks`, `traverse_graph`, `add_tag`, `remove_tag`, `get_tags`, `get_timeline` |
412
112
 
413
- - **stdio (`--mcp`)** local direct connect; the agent spawns `memkin` as a subprocess. Zero network setup; best for a single client on one machine.
414
- - **Streamable HTTP (`--mcp-http`)** — over HTTP (default `3928`); use it for remote access or sharing one memory across multiple clients.
113
+ ### Connect any MCP client
415
114
 
416
- Point any MCP client at Memkin so it can read and write your memory. For Claude Code (stdio, local direct connect):
115
+ `memkin install` wires up **Claude Code · Claude Desktop · Cursor · Codex · Windsurf** automatically. Manual config for any other MCP client (stdio):
417
116
 
418
117
  ```json
419
118
  {
@@ -426,508 +125,81 @@ Point any MCP client at Memkin so it can read and write your memory. For Claude
426
125
  }
427
126
  ```
428
127
 
429
- Then ask your agent things like *"search my memory for the auth refactor decision"* or *"what tasks are still open on project X?"* — it answers from your local memory.
430
-
431
- ### Browse the Web UI
432
-
433
- ```bash
434
- cd web
435
- bun install
436
- bun run dev # dashboard, timeline, knowledge graph, search
437
- ```
438
-
439
- ## Architecture
128
+ For remote access or sharing one memory across multiple clients, use Streamable HTTP: `memkin serve --mcp-http` (default `http://localhost:3928/mcp`).
440
129
 
441
- Memkin is **5 vertical data-flow layers + 3 cross-cutting concerns**. Data flows top-down: sources are collected, extracted into signals, stored as local memory, then read/written through the bottom interfaces. **Person identity**, **consolidation**, and **scheduling** cut across the stack.
130
+ ## Data Sources
442
131
 
443
- <p align="center">
444
- <img src="https://raw.githubusercontent.com/AndreLYL/memkin/main/docs/assets/architecture.png" alt="Memkin architecture — 5 vertical layers + 3 cross-cutting concerns" width="920">
445
- </p>
132
+ | Source | Location | What it captures |
133
+ |--------|----------|------------------|
134
+ | **Claude Code** | `~/.claude/projects/` | Agent conversations, decisions, discoveries, session logs |
135
+ | **Codex** | `~/.codex/` | OpenAI Codex CLI sessions |
136
+ | **OpenClaw Hermes** | `~/.openclaw/agents/` | Multi-agent sessions with automatic sub-agent discovery |
137
+ | **Feishu (Lark)** | API + lark-cli | Feishu/Lark integration for teams in China — 7 sources: DMs, group chats, email, calendar, tasks, docs, and message search |
446
138
 
447
- <details>
448
- <summary>📐 View the editable Mermaid source</summary>
449
-
450
- ```mermaid
451
- flowchart TB
452
- subgraph L1["① Config & Onboarding"]
453
- cfg["TUI config center · Web UI config · memkin.yaml<br/>auto-detect · hardware assessment · connection checks"]
454
- end
455
- subgraph L2["② Collection"]
456
- feishu["Feishu: DMs · groups · email · calendar · tasks · message search · docs"]
457
- agent["AI-agent sessions: Claude Code · Codex · Hermes"]
458
- inc["Incremental (cursor + dedup) · historical Backfill"]
459
- planned1["Planned: DingTalk · WeCom · local documents"]:::planned
460
- end
461
- subgraph L3["③ Extraction Pipeline"]
462
- pipe["Block Builder → Noise Filter (rules+LLM) → Signal Extractor (OpenAI/Anthropic)<br/>→ entity extraction → scoring → privacy redaction → 7 signal types"]
463
- end
464
- subgraph L4["④ Memory Store"]
465
- store["PGLite + pgvector<br/>Page · Chunk · Tag · Timeline · Graph<br/>hybrid search (FTS + vector + RRF)"]
466
- end
467
- subgraph L5["⑤ Interfaces & Consumption"]
468
- cli["CLI"]
469
- mcp["MCP (29 tools)"]
470
- rest["REST API"]
471
- web["Web UI (read-only)"]
472
- obs["Obsidian bidirectional sync"]
473
- end
474
-
475
- L1 --> L2 --> L3 --> L4 --> L5
476
-
477
- subgraph X["Cross-cutting concerns"]
478
- id["🧬 Person Identity<br/>merge same person across platforms"]
479
- cons["♻️ Consolidation / Dream Cycle<br/>tier rotation · dead-link repair · preference inference"]
480
- sched["⏰ Scheduling / AutoFetch<br/>scheduled capture · run history · alerts"]
481
- end
482
-
483
- id -.-> L2
484
- id -.-> L4
485
- cons -.-> L4
486
- sched -.-> L2
487
-
488
- classDef planned stroke-dasharray: 5 5,fill:#f6f6f6,color:#888;
489
- ```
139
+ > Using Feishu/Lark? The [Chinese README](README.md) covers the full Feishu setup — auth modes, DM vs. group capture paths, and doc summary cards. DingTalk and WeCom are on the roadmap.
490
140
 
491
- </details>
492
-
493
- ### Layer Breakdown
494
-
495
- | Layer | Responsibility |
496
- |-------|----------------|
497
- | **① Config & Onboarding** | TUI config center (React + ink), Web UI config, hand-edited `memkin.yaml`; auto-detect runtime / API keys / sources, hardware-aware embedding recommendation, live connection checks |
498
- | **② Collection** | Feishu (DMs / groups / email / calendar / tasks / message search / docs), AI-agent sessions (Claude Code / Codex / Hermes); incremental capture (per-source cursor + content dedup), historical Backfill. **Planned**: DingTalk, WeCom, local documents |
499
- | **③ Extraction Pipeline** | Block Builder → Noise Filter (L1 rules + L2 LLM) → Signal Extractor (OpenAI / Anthropic) → entity extraction → scoring → privacy redaction; emits 7 signal types via output adapters (store / file / gbrain / stdout) |
500
- | **④ Memory Store** | PGLite (in-process embedded PostgreSQL) + pgvector; Page / Chunk / Tag / Timeline / Graph stores; hybrid search (tsvector FTS + vector + RRF) |
501
- | **⑤ Interfaces & Consumption** | CLI, MCP Server (29 tools — agent read / write / maintain), REST API (Hono), Web UI (search / view / graph / timeline, **read-only today**), Obsidian bidirectional sync |
502
-
503
- **Cross-cutting concerns (span layers, not standalone pipeline stages):**
504
-
505
- - **🧬 Person Identity** — spans Collection ↔ Store: recognize and merge the same person across platforms (Feishu open_id, email, nickname), alias linking, canonicalization. The foundation of "the sum of your social relations".
506
- - **♻️ Consolidation (Dream Cycle)** — background pass over the store: hot → warm → cold rotation, dead-link repair, preference inference.
507
- - **⏰ Scheduling / AutoFetch** — background driver of Collection: scheduled capture, run history, alerts. *(Runs inside `serve` today; standalone daemon + autostart is on the roadmap.)*
508
-
509
- > Runs on macOS / Linux / Windows with PGLite (default, embedded — works out of the box) · one-command install (npm / npx) · local-first, self-hosted, zero cloud dependency. The self-managed local Postgres engine (faster, optional) is currently macOS (arm64/x64) only.
510
-
511
- ### Signal Extraction Pipeline
512
-
513
- | Stage | Description |
514
- |-------|-------------|
515
- | **Collector** | Fetches raw messages from configured data sources |
516
- | **Dedup** | Eliminates duplicates via content hashing |
517
- | **Block Builder** | Groups messages into conversation blocks by time and topic |
518
- | **Noise Filter** | Scores block significance using rules (L1) + LLM (L2) |
519
- | **Signal Extractor** | LLM-powered extraction of entities, decisions, tasks, discoveries, knowledge, timeline, links |
520
- | **Privacy Processor** | Dual-track redaction — reversible or irreversible |
521
-
522
- ### Extracted Signal Types
523
-
524
- | Signal | Description | Example |
525
- |--------|-------------|---------|
526
- | **Entities** | People, projects, tools, concepts | `project/memkin`, `tool/claude-code` |
527
- | **Timeline** | Key events with timestamps | "2026-05-19: Completed multi-platform collector refactoring" |
528
- | **Decisions** | Technical choices with reasoning | "Chose PGLite for embedded PostgreSQL with vector support" |
529
- | **Tasks** | Action items with status | `[open] Implement token auto-refresh` |
530
- | **Discoveries** | Insights, root causes, edge cases | "UUID v4 is not lexicographically sortable" |
531
- | **Knowledge** | Reusable facts with provenance | "PGLite runs full Postgres in-process via WASM" |
532
- | **Links** | Relationships between entities | `project/memkin --[depends_on]--> tool/pglite` |
533
-
534
- ### Storage Layer
535
-
536
- | Component | Description |
537
- |-----------|-------------|
538
- | **PageStore** | CRUD for wiki-style pages with YAML frontmatter |
539
- | **ChunkStore** | Recursive text chunking (300 words, 50-word overlap) with embedding reuse |
540
- | **SearchEngine** | FTS via `tsvector` + vector cosine via `pgvector`, fused with RRF scoring |
541
- | **GraphStore** | Directed link graph with BFS traversal, link types, backlinks |
542
- | **TagStore** | Page tagging with conflict-safe upserts |
543
- | **TimelineStore** | Chronological entries per page with dedup |
544
- | **EmbeddingService** | Batch embedding via OpenAI or Ollama, stale-chunk detection |
545
-
546
- ## MCP Tools
547
-
548
- Memkin's MCP server exposes **29 tools** spanning retrieval, synthesis, page CRUD, graph, tags, timeline, identity, and Feishu doc ingestion. Prefer the high-level tools first:
549
-
550
- | Category | Tools |
551
- |----------|-------|
552
- | **Retrieval (high-level)** | `query`, `get_session_context`, `get_entity_profile`, `list_signals_by_entity` |
553
- | **Synthesis** | `synthesize`, `recall` (cited, gap-aware composed answers with inline `[n]`), `prep_for_person` (person communication profile → goal-conditioned strategy; passively inferred, no questionnaire, local-first, ethics-guardrailed), `daily_report` (cross-channel 7-section daily report), `troubleshoot` (one-shot diagnosis along a playbook chain) |
554
- | **Search** | `search` |
555
- | **Pages / content** | `get_page`, `put_page`, `list_pages`, `get_chunks` |
556
- | **Graph** | `add_link`, `remove_link`, `get_links`, `get_backlinks`, `traverse_graph` |
557
- | **Tags** | `add_tag`, `remove_tag`, `get_tags` |
558
- | **Timeline** | `add_timeline_entry`, `get_timeline` |
559
- | **Identity (people)** | `link_person_alias`, `list_person_handles`, `remove_person_alias`, `merge_persons`, `recanonicalize_person` |
560
- | **Feishu docs** | `ingest_feishu_doc` |
561
- | **Health** | `get_health` |
562
-
563
- ## CLI Reference
141
+ ## CLI at a Glance
564
142
 
565
143
  | Command | Description |
566
144
  |---------|-------------|
567
- | `memkin start` | One-step launch: setup if needed, then serve + auto-open browser (bare `memkin` is equivalent) |
568
- | `memkin init` | Interactive config center to generate / edit `memkin.yaml` (`--auto` / `--no-tui` / `--force` / `--web`) |
569
- | `memkin extract` | Extract signals from a data source |
570
- | `memkin search <query>` | Search memory (hybrid / `--mode fts`) |
145
+ | `memkin start` | One-step launch: setup wizard if needed, then serve + auto-open browser (bare `memkin` is equivalent) |
146
+ | `memkin init` | Interactive config center for `memkin.yaml` (`--auto` / `--no-tui` / `--force` / `--web`) |
147
+ | `memkin extract` | Extract signals from a source (`--source claude-code\|codex\|hermes\|feishu\|all`, `--since`, `--dry-run`) |
148
+ | `memkin search <query>` | Search memory (hybrid FTS + vector / `--mode fts`) |
149
+ | `memkin serve` | Start HTTP API + Web UI / `--mcp` stdio / `--mcp-http` |
150
+ | `memkin install` | Wire Memkin into your AI clients (MCP config + memory directive) |
151
+ | `memkin hooks` | Claude Code auto-recall hooks (`install` / `install --write-back` / `uninstall`) |
571
152
  | `memkin embed` | Generate embeddings for stale chunks |
572
- | `memkin serve` | Start HTTP API (auto-opens browser, `--no-open` to skip) / `--mcp` stdio / `--mcp-http` |
573
153
  | `memkin consolidate` | Run memory consolidation (tier rotation hot→warm / warm→cold) |
574
- | `memkin export` | Export memory pages to an Obsidian vault (Markdown) |
575
- | `memkin import` | Import an Obsidian vault back into Memkin |
576
- | `memkin docs` | Feishu doc summary cards: `sync` / `status` / `retry` |
154
+ | `memkin export` / `import` | Bidirectional Obsidian sync (Markdown vault) |
577
155
  | `memkin identity` | Person identity: aliases, merge, rename |
578
- | `memkin sources` | `list` sources / `test <name>` connectivity |
579
156
  | `memkin doctor` | Diagnose configuration and connectivity |
580
- | `memkin config` | `init` (alias of `memkin init`) / `edit` (browser UI) |
581
-
582
- ### `memkin extract`
583
-
584
- Extract signals from data sources.
585
-
586
- ```bash
587
- memkin extract \
588
- --source <name> # feishu, claude-code, codex, hermes, all
589
- --format json|markdown # Output format (default: json)
590
- --adapter store|file|gbrain|stdout # Output target (default: store)
591
- --output <dir> # Output directory for file adapter
592
- --since <date> # Process messages after this date (ISO 8601 or relative: 1d, 2h)
593
- --limit <n> # Max messages to process
594
- --dry-run # Test without LLM calls or writes
595
- ```
596
-
597
- ### `memkin start`
598
-
599
- One-step launch. If no `memkin.yaml` exists, it opens the browser setup wizard first; once configured, it starts the HTTP server and auto-opens your browser. Running `memkin` with no subcommand does the same thing.
600
-
601
- ```bash
602
- memkin start
603
- memkin # equivalent
604
- ```
605
-
606
- ### `memkin serve`
607
-
608
- Start the Memkin server.
609
-
610
- ```bash
611
- # HTTP API + Web UI (default http://localhost:3927) — auto-opens the browser
612
- memkin serve
613
-
614
- # Skip the auto-open
615
- memkin serve --no-open
616
-
617
- # MCP stdio transport (local direct connect for AI agents)
618
- memkin serve --mcp
619
-
620
- # MCP Streamable HTTP transport (remote / multi-client, default http://localhost:3928/mcp)
621
- memkin serve --mcp-http
622
- ```
623
-
624
- ### `memkin search <query>`
625
-
626
- Search your stored memory.
627
-
628
- ```bash
629
- # Hybrid search (FTS + vector, default)
630
- memkin search "authentication middleware"
631
-
632
- # FTS-only search
633
- memkin search "JWT token" --mode fts
634
-
635
- # Limit results
636
- memkin search "deployment" --limit 5
637
- ```
638
-
639
- ### `memkin embed`
640
-
641
- Generate embeddings for unembedded chunks.
642
-
643
- ```bash
644
- # Embed all stale chunks
645
- memkin embed
646
-
647
- # Limit batch size
648
- memkin embed --limit 100
649
- ```
650
-
651
- ### `memkin doctor`
652
-
653
- Diagnose configuration and environment.
654
-
655
- ```bash
656
- memkin doctor
657
- ```
658
-
659
- ### `memkin config init`
660
-
661
- Equivalent to `memkin init` — launches the interactive configuration center to generate / edit `memkin.yaml` (supports `--auto` / `--no-tui` / `--force`).
662
-
663
- ```bash
664
- memkin config init
665
- ```
666
-
667
- ### `memkin sources list`
668
-
669
- List available data sources.
670
-
671
- ```bash
672
- memkin sources list
673
- ```
674
-
675
- ### `memkin sources test <name>`
676
-
677
- Test data source connectivity.
678
-
679
- ```bash
680
- memkin sources test claude-code
681
- ```
682
-
683
- ### `memkin consolidate`
684
-
685
- Run memory lifecycle tier rotation (the "dream cycle").
686
-
687
- ```bash
688
- memkin consolidate # hot→warm and/or warm→cold rotation
689
- ```
690
-
691
- ### `memkin export` / `memkin import`
692
-
693
- Bidirectional Obsidian sync.
694
-
695
- ```bash
696
- memkin export # memory pages → Obsidian vault (Markdown)
697
- memkin import # Obsidian vault → Memkin
698
- ```
699
-
700
- ### `memkin docs`
701
-
702
- Feishu doc summary cards (DocSource v2) — build lightweight pointer cards first, then upgrade triggered docs to full summary cards.
703
-
704
- ```bash
705
- memkin docs sync # scan docs, build pointer cards, upgrade triggered docs
706
- memkin docs status # show card counts by type
707
- memkin docs retry <doc_token> # retry a failed full-card extraction
708
- memkin docs retry --all-failed # retry every failed doc
709
- ```
710
-
711
- Agents can also ingest a single doc directly via the MCP tool `ingest_feishu_doc` (pass a doc URL or token).
712
-
713
- ## Configuration
714
-
715
- ### `memkin.yaml`
716
-
717
- ```yaml
718
- # Privacy
719
- privacy:
720
- enabled: true
721
- mode: reversible # reversible | irreversible
722
- redact_phone: true
723
- redact_id_card: true
724
- redact_bank_card: true
725
- replacement: "[REDACTED]"
726
-
727
- # LLM (for signal extraction)
728
- llm:
729
- provider: openai
730
- model: gpt-4o-mini
731
- api_key: ${OPENAI_API_KEY}
732
-
733
- # Block Builder
734
- block_builder:
735
- block_gap_minutes: 30
736
- max_block_tokens: 4000
737
- max_block_messages: 100
738
-
739
- # Data Sources
740
- sources:
741
- # Feishu (Lark) — your primary work source
742
- feishu:
743
- enabled: true
744
- auth_mode: user # user mode enables DM + message search
745
- app_id: ${FEISHU_APP_ID}
746
- app_secret: ${FEISHU_APP_SECRET}
747
- sources:
748
- messages: # group chats via OpenAPI
749
- enabled: true
750
- chat_ids: []
751
- lookback_days: 3
752
- message_search: # DMs + recent chats via lark-cli
753
- enabled: true
754
- chat_types: [p2p] # add `group` to include groups
755
- lookback_days: 3
756
- calendar: { enabled: true }
757
- docs: { enabled: true }
758
- tasks: { enabled: true }
759
- # AI agent sessions
760
- claude-code:
761
- enabled: true
762
- codex:
763
- enabled: true
764
- hermes:
765
- enabled: true
766
-
767
- # Store (PGLite)
768
- store:
769
- data_dir: ~/.memkin/data
770
-
771
- # Embeddings
772
- embedding:
773
- provider: openai # openai | ollama
774
- model: text-embedding-3-large
775
- dimensions: 1536
776
- api_key: ${OPENAI_API_KEY}
777
-
778
- # Server
779
- server:
780
- http_port: 3927
781
- ```
782
-
783
- > **Feishu DM vs. group capture:** `messages` uses the OpenAPI chat/message endpoints (best for known group `chat_id`s), while `message_search` uses `lark-cli im messages-search` in user mode (required for recent DMs and 1:1 bot chats). Enable both for full coverage, and complete the `lark-cli` user login first.
784
-
785
- ## Supported Sources
786
-
787
- ### Feishu (Lark)
788
-
789
- Your primary work source — group messages, DMs, email, calendar events, docs, and tasks.
790
-
791
- - **Auth**: `lark-cli` user-mode login (for DMs / message search) + app credentials
792
- - **Data**: 7 sources — group chats, DMs, email, calendar, docs, tasks, message search
793
- - **Why first**: Feishu carries the work itself — requirements, technical proposals, team decisions
794
-
795
- ### Claude Code
796
-
797
- Extracts conversation transcripts from Claude Code agent sessions.
798
-
799
- - **Location**: `~/.claude/projects/`
800
- - **Data**: Agent conversations, decisions, discoveries, session logs
801
157
 
802
- ### Codex
158
+ ## Ports & Security
803
159
 
804
- Extracts session data from OpenAI Codex CLI.
805
-
806
- - **Location**: `~/.codex/`
807
- - **Data**: User/assistant messages with system-injection filtering
808
-
809
- ### Hermes
810
-
811
- Extracts session data from OpenClaw Hermes agents.
812
-
813
- - **Location**: `~/.openclaw/agents/`
814
- - **Data**: Multi-agent sessions with automatic sub-agent discovery
815
-
816
- ## Roadmap
817
-
818
- ### Phase 1 — Signal Extraction (Complete)
819
-
820
- - [x] Multi-platform collectors (Claude Code, Codex, Hermes, Feishu)
821
- - [x] LLM-powered noise filtering and signal extraction
822
- - [x] 7 signal types: entities, timeline, decisions, tasks, discoveries, knowledge, links
823
- - [x] Dual-track privacy redaction (reversible + irreversible)
824
- - [x] JSON and Markdown output formatters
825
- - [x] File, GBrain, and Stdout adapters
826
- - [x] CLI with extract, doctor, config, sources commands
827
-
828
- ### Phase 2 — Storage & Server (Complete)
829
-
830
- - [x] PGLite embedded PostgreSQL with pgvector
831
- - [x] PageStore, ChunkStore, TagStore, TimelineStore, GraphStore
832
- - [x] Full-text search with `tsvector` (simple tokenizer for multilingual)
833
- - [x] Vector search with `pgvector` cosine similarity
834
- - [x] Hybrid RRF search fusing FTS + vector results
835
- - [x] EmbeddingService (OpenAI / Ollama)
836
- - [x] StoreAdapter — pipeline writes directly to PGLite
837
- - [x] Hono REST API
838
- - [x] MCP Server with 29 stdio tools
839
- - [x] CLI serve, search, embed commands
840
-
841
- ### Phase 3 — Web UI (Complete)
842
-
843
- - [x] Dashboard
844
- - [x] Timeline view
845
- - [x] Knowledge graph visualization (force-directed)
846
- - [x] Search interface
847
- - [x] Entity / page detail views
848
-
849
- ### Phase 4 — Consolidation & Daemon (Complete)
850
-
851
- - [x] Memory consolidation ("dream cycle"): tier rotation, dead-link repair, preference inference
852
- - [x] Resident daemon with scheduled extraction (scheduler, run history, alerts)
853
- - [x] Person identity management (aliases, merge, rename)
854
- - [x] Feishu doc summary cards (DocSource v2)
855
- - [x] Obsidian bidirectional sync (export / import)
856
-
857
- ### Phase 5 — Self-Hosted Always-On (In Progress · MVP)
858
-
859
- - [ ] Standalone daemon service + autostart (systemd / launchd / Windows service) — "configure once, runs maintenance-free"
860
- - [ ] Agent Hook: auto read/write memory on session end / key decisions
160
+ | Service | Default port | Address |
161
+ |---------|--------------|---------|
162
+ | HTTP API + Web UI | `3927` | `http://localhost:3927` |
163
+ | MCP Streamable HTTP (`--mcp-http`) | `3928` | `http://localhost:3928/mcp` |
861
164
 
862
- ### Phase 6 More Chinese Workplace Sources (Planned)
165
+ The server binds `127.0.0.1` (loopback only) by default. Exposing it on a LAN (`server.host: 0.0.0.0` or `memkin serve --host 0.0.0.0`) **requires an auth token** (`server.auth_token` or `MEMKIN_AUTH_TOKEN`), or the server refuses to start; every API request must then carry `Authorization: Bearer <token>`.
863
166
 
864
- - [ ] DingTalk
865
- - [ ] WeCom (WeChat Work)
866
- - [ ] WeChat chat history
867
- - [ ] Local document source (scan local files, community-driven · low priority)
167
+ ## Platform Support
868
168
 
869
- ### Phase 7Context-Aware Extraction & Q&A (In Progress)
169
+ Runs on **macOS / Linux / Windows** with the default embedded PGLite engine works out of the box, zero external dependencies. The optional self-managed local Postgres engine (faster) is currently **macOS (arm64/x64) only**.
870
170
 
871
- - [x] Synthesis layer (basic): `synthesize` / `recall` — cited composed answers with inline `[n]` + gap analysis, intent-template framework, per-scope caching
872
- - [x] **Person communication profile (Hero)**: `prep_for_person(person, goal?)` — passively infers a communication profile from real interactions (zero-LLM behavior layer + behavior-quadrant trait layer + relation layer + four-color shell) and gives goal-conditioned, `[n]`-cited communication strategy. No questionnaire, local-first, ethics-guardrailed (suggestions, not manipulation); disabled by default, per-person opt-in
873
- - [x] **Cross-channel daily report**: `daily_report(date?)` — aggregates today's signals across DMs/group/email/Feishu Minutes/calendar into 7 sections; meeting notes yield `decisions` and owner-tagged `action_items` (yours land in "my tasks")
874
- - [x] **Troubleshooting Playbooks**: `troubleshoot(query)` — ordered steps along the playbook `precedes` chain with per-result meaning; hierarchical tree (`part_of`) organizes problem domains; playbooks authored by hand or auto-extracted (draft) from conversations
875
- - [x] **Retrieval quality**: best-chunk-per-page pooling (surface on strongest evidence), zero-LLM self-wiring (`[[slug]]`/`[[rel:slug]]` graph edges on write), rule-based query rewrite
876
- - [ ] ContextBuffer — share context across conversation blocks
877
- - [ ] Weighted admission scoring (replaces binary noise filter)
878
- - [ ] Narrative assembler — aggregate signals into per-entity narratives
879
- - [ ] Natural language Q&A over stored memories
171
+ ## Why Memkin
880
172
 
881
- ### Phase 8 Web UI Enhancements (Planned)
173
+ | | Memkin | Pure RAG / vector search | Note apps (Obsidian / Notion) |
174
+ |---|:---:|:---:|:---:|
175
+ | Local-first & private | ✅ | depends | depends |
176
+ | AI-agent sessions as a first-class source | ✅ | ❌ | ❌ |
177
+ | Agent-native: read **and** write over MCP | ✅ | ❌ | ❌ |
178
+ | Entity + relationship knowledge graph | ✅ | ❌ | manual |
179
+ | Structured signal extraction (not just chunks) | ✅ | ❌ | ❌ |
180
+ | Memory consolidation + scheduled-capture daemon | ✅ | ❌ | ❌ |
181
+ | Work-chat capture (Feishu/Lark) | ✅ | ❌ | manual |
882
182
 
883
- - [ ] Memory editing (read-only today)
884
- - [ ] Audit view (signal provenance visualization)
183
+ > Pure RAG gives you vectors but no entities or relationships, so answers lack context. Note apps are powerful but rely on manual upkeep. Memkin keeps it local and agent-native.
885
184
 
886
185
  ## Tech Stack
887
186
 
888
- | Layer | Technology |
889
- |-------|-----------|
890
- | Language | TypeScript |
891
- | Runtime | Bun |
892
- | Database | PGLite (embedded PostgreSQL) |
893
- | Vector Search | pgvector |
894
- | Embeddings | OpenAI / Ollama |
895
- | Web Framework | Hono |
896
- | Web UI | React + Vite |
897
- | MCP | @modelcontextprotocol/sdk |
898
- | Linter | Biome |
899
- | Tests | Vitest (1000+ tests) |
187
+ TypeScript · Bun · PGLite (embedded PostgreSQL) · pgvector · Hono · React + Vite · @modelcontextprotocol/sdk · Vitest (1700+ tests)
900
188
 
901
189
  ## Development
902
190
 
903
191
  ```bash
904
- # Run tests
905
- bun run test
906
-
907
- # Watch mode
908
- bun run test:watch
909
-
910
- # Type-check
911
- bun run typecheck
912
-
913
- # Lint
914
- bun run lint
915
-
916
- # Auto-fix lint issues
917
- bun run lint:fix
192
+ bun run test # full test suite
193
+ bun run typecheck # type-check
194
+ bun run lint # lint (Biome)
918
195
  ```
919
196
 
920
- See [CONTRIBUTING.md](CONTRIBUTING.md) for development workflow and guidelines.
921
-
922
- ## Contributing
923
-
924
- Contributions welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) before submitting a PR.
197
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the development workflow. Contributions welcome!
925
198
 
926
199
  ## Community & Support
927
200
 
928
201
  - 🐛 Found a bug or have a feature request? [Open an issue](https://github.com/AndreLYL/memkin/issues).
929
- - 💡 Questions and ideas are welcome in the issue tracker.
930
- - ⭐ If Memkin helps you, give it a Star — it's the best way to support the project.
202
+ - If Memkin helps you, give it a star — it's the best way to support the project.
931
203
 
932
204
  ## License
933
205