@synth-coder/memhub 0.2.3 → 0.2.5

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 (118) hide show
  1. package/.github/workflows/ci.yml +48 -12
  2. package/.github/workflows/release.yml +70 -0
  3. package/AGENTS.md +71 -73
  4. package/README.md +284 -195
  5. package/README.zh-CN.md +90 -30
  6. package/dist/src/cli/agents/claude-code.d.ts +5 -0
  7. package/dist/src/cli/agents/claude-code.d.ts.map +1 -0
  8. package/dist/src/cli/agents/claude-code.js +14 -0
  9. package/dist/src/cli/agents/claude-code.js.map +1 -0
  10. package/dist/src/cli/agents/cline.d.ts +5 -0
  11. package/dist/src/cli/agents/cline.d.ts.map +1 -0
  12. package/dist/src/cli/agents/cline.js +14 -0
  13. package/dist/src/cli/agents/cline.js.map +1 -0
  14. package/dist/src/cli/agents/cursor.d.ts +5 -0
  15. package/dist/src/cli/agents/cursor.d.ts.map +1 -0
  16. package/dist/src/cli/agents/cursor.js +14 -0
  17. package/dist/src/cli/agents/cursor.js.map +1 -0
  18. package/dist/src/cli/agents/factory-droid.d.ts +5 -0
  19. package/dist/src/cli/agents/factory-droid.d.ts.map +1 -0
  20. package/dist/src/cli/agents/factory-droid.js +14 -0
  21. package/dist/src/cli/agents/factory-droid.js.map +1 -0
  22. package/dist/src/cli/agents/gemini-cli.d.ts +5 -0
  23. package/dist/src/cli/agents/gemini-cli.d.ts.map +1 -0
  24. package/dist/src/cli/agents/gemini-cli.js +14 -0
  25. package/dist/src/cli/agents/gemini-cli.js.map +1 -0
  26. package/dist/src/cli/agents/index.d.ts +13 -0
  27. package/dist/src/cli/agents/index.d.ts.map +1 -0
  28. package/dist/src/cli/agents/index.js +27 -0
  29. package/dist/src/cli/agents/index.js.map +1 -0
  30. package/dist/src/cli/agents/windsurf.d.ts +5 -0
  31. package/dist/src/cli/agents/windsurf.d.ts.map +1 -0
  32. package/dist/src/cli/agents/windsurf.js +14 -0
  33. package/dist/src/cli/agents/windsurf.js.map +1 -0
  34. package/dist/src/cli/index.d.ts +8 -0
  35. package/dist/src/cli/index.d.ts.map +1 -0
  36. package/dist/src/cli/index.js +168 -0
  37. package/dist/src/cli/index.js.map +1 -0
  38. package/dist/src/cli/init.d.ts +34 -0
  39. package/dist/src/cli/init.d.ts.map +1 -0
  40. package/dist/src/cli/init.js +140 -0
  41. package/dist/src/cli/init.js.map +1 -0
  42. package/dist/src/cli/instructions.d.ts +29 -0
  43. package/dist/src/cli/instructions.d.ts.map +1 -0
  44. package/dist/src/cli/instructions.js +141 -0
  45. package/dist/src/cli/instructions.js.map +1 -0
  46. package/dist/src/cli/types.d.ts +22 -0
  47. package/dist/src/cli/types.d.ts.map +1 -0
  48. package/dist/src/cli/types.js +75 -0
  49. package/dist/src/cli/types.js.map +1 -0
  50. package/dist/src/contracts/mcp.js +34 -34
  51. package/dist/src/contracts/schemas.js.map +1 -1
  52. package/dist/src/server/mcp-server.d.ts.map +1 -1
  53. package/dist/src/server/mcp-server.js +7 -14
  54. package/dist/src/server/mcp-server.js.map +1 -1
  55. package/dist/src/services/embedding-service.d.ts.map +1 -1
  56. package/dist/src/services/embedding-service.js +1 -1
  57. package/dist/src/services/embedding-service.js.map +1 -1
  58. package/dist/src/services/memory-service.d.ts.map +1 -1
  59. package/dist/src/services/memory-service.js.map +1 -1
  60. package/dist/src/storage/markdown-storage.d.ts.map +1 -1
  61. package/dist/src/storage/markdown-storage.js +1 -1
  62. package/dist/src/storage/markdown-storage.js.map +1 -1
  63. package/dist/src/storage/vector-index.d.ts.map +1 -1
  64. package/dist/src/storage/vector-index.js +4 -5
  65. package/dist/src/storage/vector-index.js.map +1 -1
  66. package/docs/README.md +21 -0
  67. package/docs/mcp-tools.md +136 -0
  68. package/docs/user-guide.md +184 -0
  69. package/package.json +61 -59
  70. package/src/cli/agents/claude-code.ts +14 -0
  71. package/src/cli/agents/cline.ts +14 -0
  72. package/src/cli/agents/codex.ts +14 -0
  73. package/src/cli/agents/cursor.ts +14 -0
  74. package/src/cli/agents/factory-droid.ts +14 -0
  75. package/src/cli/agents/gemini-cli.ts +14 -0
  76. package/src/cli/agents/index.ts +36 -0
  77. package/src/cli/agents/windsurf.ts +14 -0
  78. package/src/cli/index.ts +192 -0
  79. package/src/cli/init.ts +218 -0
  80. package/src/cli/instructions.ts +156 -0
  81. package/src/cli/types.ts +112 -0
  82. package/src/contracts/index.ts +12 -12
  83. package/src/contracts/mcp.ts +223 -223
  84. package/src/contracts/schemas.ts +307 -307
  85. package/src/contracts/types.ts +410 -410
  86. package/src/index.ts +8 -8
  87. package/src/server/index.ts +5 -5
  88. package/src/server/mcp-server.ts +169 -186
  89. package/src/services/embedding-service.ts +114 -114
  90. package/src/services/index.ts +5 -5
  91. package/src/services/memory-service.ts +656 -663
  92. package/src/storage/frontmatter-parser.ts +243 -243
  93. package/src/storage/index.ts +6 -6
  94. package/src/storage/markdown-storage.ts +228 -236
  95. package/src/storage/vector-index.ts +159 -160
  96. package/src/utils/index.ts +5 -5
  97. package/src/utils/slugify.ts +63 -63
  98. package/test/cli/init.test.ts +402 -0
  99. package/test/contracts/schemas.test.ts +313 -313
  100. package/test/contracts/types.test.ts +21 -21
  101. package/test/frontmatter-parser-more.test.ts +94 -94
  102. package/test/server/mcp-server.test.ts +211 -210
  103. package/test/services/memory-service-edge.test.ts +248 -248
  104. package/test/services/memory-service.test.ts +291 -279
  105. package/test/storage/frontmatter-parser.test.ts +223 -223
  106. package/test/storage/markdown-storage.test.ts +226 -217
  107. package/test/storage/storage-edge.test.ts +238 -238
  108. package/test/storage/vector-index.test.ts +149 -153
  109. package/test/utils/slugify-edge.test.ts +94 -94
  110. package/test/utils/slugify.test.ts +72 -68
  111. package/docs/architecture-diagrams.md +0 -368
  112. package/docs/architecture.md +0 -381
  113. package/docs/contracts.md +0 -190
  114. package/docs/prompt-template.md +0 -33
  115. package/docs/proposals/mcp-typescript-sdk-refactor.md +0 -568
  116. package/docs/proposals/proposal-close-gates.md +0 -58
  117. package/docs/tool-calling-policy.md +0 -101
  118. package/docs/vector-search.md +0 -306
package/README.md CHANGED
@@ -1,195 +1,284 @@
1
- # MemHub
2
-
3
- Git-friendly memory MCP server for coding agents.
4
-
5
- MemHub stores decisions, preferences, and reusable knowledge as plain Markdown files with YAML front matter, so everything is easy to review, diff, and version with Git.
6
-
7
- ---
8
-
9
- ## Why MemHub
10
-
11
- - **Git-native**: all memory is plain text files
12
- - **Agent-friendly**: exposed as MCP tools over stdio
13
- - **Human-readable**: YAML metadata + Markdown body
14
- - **Quality-gated**: lint + typecheck + tests + coverage gate
15
-
16
- ---
17
-
18
- ## Features
19
-
20
- - Markdown-based memory storage (`.md`)
21
- - YAML Front Matter metadata (`id`, `session_id`, `entry_type`, `tags`, `category`, `importance`, timestamps)
22
- - STM-first 2-tool interface: `memory_load` + `memory_update`
23
- - Concurrent CLI-safe storage layout: `YYYY-MM-DD/session_uuid/...`
24
- - MCP stdio server compatible with MCP clients
25
-
26
- ---
27
-
28
- ## Quick Start
29
-
30
- ### 1) Install from npm
31
-
32
- ```bash
33
- npm i @synth-coder/memhub
34
- ```
35
-
36
- ### 2) Or install dependencies for local development
37
-
38
- ```bash
39
- npm install
40
- ```
41
-
42
- ### 3) Build
43
-
44
- ```bash
45
- npm run build
46
- ```
47
-
48
- ### 4) Run quality gate
49
- ```bash
50
- npm run quality
51
- ```
52
-
53
- ---
54
-
55
- ## Use as MCP Server (stdio)
56
-
57
- ### Option A: run directly via npx (recommended)
58
-
59
- ```bash
60
- npx -y @synth-coder/memhub
61
- ```
62
-
63
- > On Windows, do **not** append `memhub` after the package name.
64
- > If a source `.js` file opens in editor, upgrade to latest package version (`0.1.2+`) and retry.
65
-
66
- Example MCP client config:
67
-
68
- ```json
69
- {
70
- "mcpServers": {
71
- "memhub": {
72
- "command": "npx",
73
- "args": ["-y", "@synth-coder/memhub"],
74
- "env": {
75
- "MEMHUB_STORAGE_PATH": "/absolute/path/to/memories",
76
- "MEMHUB_LOG_LEVEL": "info"
77
- }
78
- }
79
- }
80
- }
81
- ```
82
-
83
- ### Option B: local repo run
84
-
85
- ```json
86
- {
87
- "mcpServers": {
88
- "memhub": {
89
- "command": "node",
90
- "args": ["dist/src/server/mcp-server.js"]
91
- }
92
- }
93
- }
94
- ```
95
-
96
- ---
97
-
98
- ## Environment Variables
99
-
100
- - `MEMHUB_STORAGE_PATH` (default: `./memories`)
101
- - `MEMHUB_LOG_LEVEL` (default: `info`, options: `debug|info|warn|error`)
102
-
103
- ---
104
-
105
- ## Memory File Format
106
-
107
- ```markdown
108
- ---
109
- id: "550e8400-e29b-41d4-a716-446655440000"
110
- created_at: "2026-03-03T08:00:00.000Z"
111
- updated_at: "2026-03-03T08:00:00.000Z"
112
- tags:
113
- - architecture
114
- - tdd
115
- category: "engineering"
116
- importance: 4
117
- ---
118
-
119
- # Contract-first MCP design
120
-
121
- Define tool contracts and schemas before implementation.
122
- ```
123
-
124
- Filename format:
125
-
126
- ```text
127
- YYYY-MM-DD-title-slug.md
128
- ```
129
-
130
- ---
131
-
132
- ## MCP Tools
133
-
134
- - `memory_load`
135
- First-turn tool. Load STM context for the current task/session.
136
- - `memory_update`
137
- Final-turn tool. Write back decisions, preferences, knowledge, and task-state updates.
138
-
139
- Calling policy: see `docs/tool-calling-policy.md`.
140
-
141
- ---
142
-
143
- ## Development
144
-
145
- ### Scripts
146
-
147
- ```bash
148
- npm run build
149
- npm run lint
150
- npm run typecheck
151
- npm run test
152
- npm run test:coverage
153
- npm run quality
154
- ```
155
-
156
- ### Engineering Workflow
157
-
158
- - Contract-first (types + schema first)
159
- - TDD (`red -> green -> refactor`)
160
- - Quality gate enforced before merge
161
- - Coverage threshold: **>= 80%**
162
-
163
- ---
164
-
165
- ## Project Structure
166
-
167
- ```text
168
- memhub/
169
- ├── docs/
170
- ├── src/
171
- │ ├── contracts/
172
- │ ├── server/
173
- │ ├── services/
174
- │ ├── storage/
175
- │ └── utils/
176
- ├── test/
177
- └── .github/workflows/
178
- ```
179
-
180
- ---
181
-
182
- ## Roadmap
183
-
184
- - [x] Architecture and contracts
185
- - [x] Core storage/service/server implementation
186
- - [x] Quality gate (lint/typecheck/test/coverage)
187
- - [ ] Integration tests
188
- - [ ] Performance improvements
189
- - [x] npm release (`@synth-coder/memhub@0.2.0`)
190
-
191
- ---
192
-
193
- ## License
194
-
195
- MIT
1
+ # MemHub
2
+
3
+ Git-friendly memory MCP server for coding agents.
4
+
5
+ ---
6
+
7
+ ## Quick Start
8
+
9
+ ### One-Line Setup
10
+
11
+ Configure MemHub for your AI agent with a single command:
12
+
13
+ ```bash
14
+ npx -y @synth-coder/memhub@latest init
15
+ ```
16
+
17
+ This launches an interactive prompt to select your agent. MemHub will:
18
+ 1. Add MCP server config to your agent's configuration file
19
+ 2. Add MemHub usage instructions to your agent's rules file
20
+
21
+ **Supported Agents:**
22
+
23
+ | Agent | Config File | Instructions File |
24
+ |-------|-------------|-------------------|
25
+ | Claude Code | `~/.claude/settings.json` | `~/.claude/CLAUDE.md` |
26
+ | Cursor | `~/.cursor/mcp.json` | `~/.cursorrules` |
27
+ | Cline | `~/.cline/mcp.json` | `~/.clinerules` |
28
+ | Windsurf | `~/.codeium/windsurf/mcp_config.json` | `~/.windsurfrules` |
29
+ | Factory Droid | `~/.factory/mcp.json` | `~/.factory/AGENTS.md` |
30
+ | Gemini CLI | `~/.gemini/settings.json` | `~/.gemini/GEMINI.md` |
31
+ | Codex | `~/.codex/config.toml` | `~/.codex/AGENTS.md` |
32
+
33
+ ### CLI Options
34
+
35
+ ```bash
36
+ # Interactive selection (global - default)
37
+ npx -y @synth-coder/memhub@latest init
38
+
39
+ # Skip interactive prompt
40
+ npx -y @synth-coder/memhub@latest init -a claude-code
41
+
42
+ # Configure for current project only (local)
43
+ npx -y @synth-coder/memhub@latest init -a cursor -l
44
+
45
+ # Update existing configuration
46
+ npx -y @synth-coder/memhub@latest init -a claude-code --force
47
+ ```
48
+
49
+ | Option | Description |
50
+ |--------|-------------|
51
+ | `-a, --agent <name>` | Agent type (skip interactive) |
52
+ | `-l, --local` | Configure for current project (default: global) |
53
+ | `-f, --force` | Update existing configuration |
54
+
55
+ ### Run as MCP Server
56
+
57
+ ```bash
58
+ npx -y @synth-coder/memhub@latest
59
+ ```
60
+
61
+ > On Windows, do **not** append `memhub` after the package name.
62
+
63
+ ### Manual Configuration
64
+
65
+ If you prefer manual setup, add this to your MCP client config:
66
+
67
+ ```json
68
+ {
69
+ "mcpServers": {
70
+ "memhub": {
71
+ "command": "npx",
72
+ "args": ["-y", "@synth-coder/memhub@latest"],
73
+ "env": {
74
+ "MEMHUB_STORAGE_PATH": "/absolute/path/to/memories",
75
+ "MEMHUB_LOG_LEVEL": "info"
76
+ }
77
+ }
78
+ }
79
+ }
80
+ ```
81
+
82
+ For Codex (`~/.codex/config.toml`), use TOML key `mcp_servers`:
83
+
84
+ ```toml
85
+ [mcp_servers.memhub]
86
+ command = "npx"
87
+ args = ["-y", "@synth-coder/memhub@latest"]
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Configure Your Agent
93
+
94
+ Add the following to your coding agent's system prompt to enable persistent memory:
95
+
96
+ ```markdown
97
+ ## Memory System
98
+
99
+ You have access to persistent memory across conversations. Use it wisely:
100
+
101
+ - **Remember preferences** Learn what the user likes and avoid repeating mistakes
102
+ - **Recall decisions** — Build on past reasoning instead of starting from scratch
103
+ - **Store context** — Project knowledge that survives session boundaries
104
+
105
+ ### When to Use
106
+
107
+ #### `memory_load`
108
+
109
+ Call when you need context from past conversations:
110
+ - User references something from before
111
+ - You're unsure about user preferences
112
+ - A decision needs historical context
113
+
114
+ Don't call for simple, self-contained tasks.
115
+
116
+ #### `memory_update`
117
+
118
+ Call when you discover something worth remembering:
119
+ - User expresses a preference
120
+ - You made a significant decision with reasoning
121
+ - Project context changed
122
+
123
+ Don't call for temporary or one-time information.
124
+
125
+ ### Principle
126
+
127
+ Memory should feel natural — triggered by context, not by schedule. When in doubt, ask: "Would future me benefit from knowing this?"
128
+ ```
129
+
130
+ ---
131
+
132
+ ## MCP Tools
133
+
134
+ - `memory_load`
135
+ First-turn tool. Load STM context for the current task/session.
136
+ - `memory_update`
137
+ Final-turn tool. Write back decisions, preferences, knowledge, and task-state updates.
138
+
139
+ See [docs/mcp-tools.md](docs/mcp-tools.md) for detailed API reference.
140
+
141
+ ---
142
+
143
+ ## Why MemHub
144
+
145
+ Most AI memory tools rely on external APIs or simple keyword matching. MemHub is different:
146
+
147
+ ### Semantic Search with Local AI
148
+
149
+ - **Vector Database**: Powered by LanceDB for fast similarity search
150
+ - **Local Embeddings**: Quantized Transformers.js model runs entirely on your machine
151
+ - **Zero API Costs**: No external services, no API keys, no rate limits
152
+ - **Privacy First**: Your memories never leave your computer
153
+
154
+ ### Git-Native Storage
155
+
156
+ - **Plain Text**: All memories are Markdown files with YAML front matter
157
+ - **Version Control**: Commit, branch, review, and revert like any code
158
+ - **Human Readable**: Browse and edit memories with any text editor
159
+ - **Team Friendly**: Share memories via git repository
160
+
161
+ ### How It Works
162
+
163
+ ```
164
+ User Query → Local Embedding Model → Vector Search → Ranked Results
165
+ ↑ ↓
166
+ Runs on CPU LanceDB Index
167
+ (no GPU required) (embedded database)
168
+ ```
169
+
170
+ When you call `memory_load`, MemHub:
171
+ 1. Converts your query to a vector using a local quantized model
172
+ 2. Searches the LanceDB index for semantically similar memories
173
+ 3. Returns ranked results with relevance scores
174
+
175
+ This means "testing framework preference" finds memories about "Vitest vs Jest decision" — even without exact keyword matches.
176
+
177
+ ---
178
+
179
+ ## Features
180
+
181
+ - **Semantic Search** — Vector-based similarity search with LanceDB
182
+ - **Local Embeddings** — Quantized Transformers.js model, runs on CPU
183
+ - **Markdown Storage** — Human-readable `.md` files with YAML front matter
184
+ - **Git-Friendly** Version control, diff, review your memories
185
+ - **MCP Protocol** Works with Claude Code, Cursor, Cline, Windsurf, and more
186
+ - **One-Line Setup** `npx -y @synth-coder/memhub@latest init`
187
+
188
+ ---
189
+
190
+ ## Environment Variables
191
+
192
+ - `MEMHUB_STORAGE_PATH` (default: `~/.memhub`)
193
+ - `MEMHUB_LOG_LEVEL` (default: `info`, options: `debug|info|warn|error`)
194
+
195
+ ---
196
+
197
+ ## Memory File Format
198
+
199
+ ```markdown
200
+ ---
201
+ id: "550e8400-e29b-41d4-a716-446655440000"
202
+ created_at: "2026-03-03T08:00:00.000Z"
203
+ updated_at: "2026-03-03T08:00:00.000Z"
204
+ tags:
205
+ - architecture
206
+ - tdd
207
+ category: "engineering"
208
+ importance: 4
209
+ ---
210
+
211
+ # Contract-first MCP design
212
+
213
+ Define tool contracts and schemas before implementation.
214
+ ```
215
+
216
+ Filename format:
217
+
218
+ ```text
219
+ YYYY-MM-DD-title-slug.md
220
+ ```
221
+
222
+ ---
223
+
224
+ ## Development
225
+
226
+ ### Install & Build
227
+
228
+ ```bash
229
+ npx pnpm install
230
+ npx pnpm run build
231
+ ```
232
+
233
+ ### Scripts
234
+
235
+ ```bash
236
+ npx pnpm run build
237
+ npx pnpm run lint
238
+ npx pnpm run format
239
+ npx pnpm run typecheck
240
+ npx pnpm run test
241
+ npx pnpm run quality
242
+ ```
243
+
244
+ ### Engineering Workflow
245
+
246
+ - Contract-first (types + schema first)
247
+ - TDD (`red -> green -> refactor`)
248
+ - Quality gate enforced before merge
249
+ - Coverage threshold: **>= 80%**
250
+
251
+ ---
252
+
253
+ ## Project Structure
254
+
255
+ ```text
256
+ memhub/
257
+ ├── docs/
258
+ ├── src/
259
+ │ ├── contracts/
260
+ │ ├── server/
261
+ │ ├── services/
262
+ │ ├── storage/
263
+ │ └── utils/
264
+ ├── test/
265
+ └── .github/workflows/
266
+ ```
267
+
268
+ ---
269
+
270
+ ## Roadmap
271
+
272
+ - [x] Architecture and contracts
273
+ - [x] Core storage/service/server implementation
274
+ - [x] Quality gate (lint/typecheck/test/coverage)
275
+ - [x] CLI init command for quick setup
276
+ - [ ] Integration tests
277
+ - [ ] Performance improvements
278
+ - [x] npm release (`@synth-coder/memhub@0.2.5`)
279
+
280
+ ---
281
+
282
+ ## License
283
+
284
+ MIT
package/README.zh-CN.md CHANGED
@@ -8,48 +8,99 @@ MemHub 将“用户决策、长期偏好、可复用知识”保存为 **Markdow
8
8
 
9
9
  ## 为什么用 MemHub
10
10
 
11
- - **Git 原生**:所有记忆都是纯文本文件,天然可 diff / 可回滚
12
- - **面向 Agent**:通过 MCP(stdio)暴露工具,便于模型调用
13
- - **人类可读**:元数据在 YAML,正文在 Markdown
14
- - **质量可控**:内置 lint / typecheck / test / coverage 门禁
11
+ 大多数 AI 记忆工具依赖外部 API 或简单的关键词匹配。MemHub 不同:
12
+
13
+ ### 本地 AI 语义搜索
14
+
15
+ - **向量数据库**:基于 LanceDB 实现快速相似度搜索
16
+ - **本地嵌入模型**:量化版 Transformers.js 模型,完全在本地运行
17
+ - **零 API 成本**:无需外部服务、无需 API 密钥、无速率限制
18
+ - **隐私优先**:你的记忆永远不会离开你的电脑
19
+
20
+ ### Git 原生存储
21
+
22
+ - **纯文本格式**:所有记忆都是带 YAML front matter 的 Markdown 文件
23
+ - **版本控制**:像代码一样提交、分支、审查、回滚
24
+ - **人类可读**:用任何文本编辑器浏览和编辑记忆
25
+ - **团队友好**:通过 git 仓库共享记忆
26
+
27
+ ### 工作原理
28
+
29
+ ```
30
+ 用户查询 → 本地嵌入模型 → 向量搜索 → 排序结果
31
+ ↑ ↓
32
+ 运行在 CPU LanceDB 索引
33
+ (无需 GPU) (嵌入式数据库)
34
+ ```
35
+
36
+ 当你调用 `memory_load` 时,MemHub:
37
+ 1. 使用本地量化模型将查询转换为向量
38
+ 2. 在 LanceDB 索引中搜索语义相似的记忆
39
+ 3. 返回带有相关性分数的排序结果
40
+
41
+ 这意味着"测试框架偏好"可以找到关于"Vitest vs Jest 决策"的记忆——即使没有精确的关键词匹配。
15
42
 
16
43
  ---
17
44
 
18
45
  ## 核心特性
19
46
 
20
- - Markdown 持久化(`.md`)
21
- - YAML Front Matter 元数据(`id / session_id / entry_type / tags / category / importance / 时间戳`)
22
- - STM-first 双工具接口:`memory_load` + `memory_update`
23
- - 并发 CLI 安全目录:`YYYY-MM-DD/session_uuid/...`
24
- - MCP stdio server,可接入主流 MCP 客户端
47
+ - **语义搜索** — 基于 LanceDB 的向量相似度搜索
48
+ - **本地嵌入** 量化版 Transformers.js 模型,CPU 运行
49
+ - **Markdown 存储** — 人类可读的 `.md` 文件,带 YAML front matter
50
+ - **Git 友好** — 版本控制、diff、审查你的记忆
51
+ - **MCP 协议** 支持 Claude Code、Cursor、Cline、Windsurf 等
52
+ - **一键配置** — `npx -y @synth-coder/memhub@latest init`
25
53
 
26
54
  ---
27
55
 
28
56
  ## 快速开始
29
57
 
30
- ### 1)从 npm 安装
58
+ ### 一键配置
59
+
60
+ 使用一条命令为你的 AI 代理配置 MemHub:
31
61
 
32
62
  ```bash
33
- npm i @synth-coder/memhub
63
+ npx -y @synth-coder/memhub@latest init
34
64
  ```
35
65
 
36
- ### 2)本地开发安装依赖
66
+ 这将启动交互式提示选择你的代理。MemHub 会:
67
+ 1. 将 MCP 服务器配置添加到代理的配置文件
68
+ 2. 将 MemHub 使用说明添加到代理的规则文件
37
69
 
38
- ```bash
39
- npm install
40
- ```
70
+ **支持的代理:**
41
71
 
42
- ### 3)构建
72
+ | 代理 | 配置文件 | 指令文件 |
73
+ |------|----------|----------|
74
+ | Claude Code | `~/.claude/settings.json` | `~/.claude/CLAUDE.md` |
75
+ | Cursor | `~/.cursor/mcp.json` | `~/.cursorrules` |
76
+ | Cline | `~/.cline/mcp.json` | `~/.clinerules` |
77
+ | Windsurf | `~/.codeium/windsurf/mcp_config.json` | `~/.windsurfrules` |
78
+ | Factory Droid | `~/.factory/mcp.json` | `~/.factory/AGENTS.md` |
79
+ | Gemini CLI | `~/.gemini/settings.json` | `~/.gemini/GEMINI.md` |
80
+ | Codex | `~/.codex/config.toml` | `~/.codex/AGENTS.md` |
43
81
 
44
- ```bash
45
- npm run build
46
- ```
82
+ ### CLI 选项
47
83
 
48
- ### 4)执行质量门禁
49
84
  ```bash
50
- npm run quality
85
+ # 交互式选择(全局 - 默认)
86
+ npx -y @synth-coder/memhub@latest init
87
+
88
+ # 跳过交互式提示
89
+ npx -y @synth-coder/memhub@latest init -a claude-code
90
+
91
+ # 仅配置当前项目(本地)
92
+ npx -y @synth-coder/memhub@latest init -a cursor -l
93
+
94
+ # 更新现有配置
95
+ npx -y @synth-coder/memhub@latest init -a claude-code --force
51
96
  ```
52
97
 
98
+ | 选项 | 说明 |
99
+ |------|------|
100
+ | `-a, --agent <名称>` | 代理类型(跳过交互式选择) |
101
+ | `-l, --local` | 配置当前项目(默认:全局) |
102
+ | `-f, --force` | 更新现有配置 |
103
+
53
104
  ---
54
105
 
55
106
  ## 作为 MCP Server 使用(stdio)
@@ -57,30 +108,38 @@ npm run quality
57
108
  ### 方式 A:npx 直接运行(推荐)
58
109
 
59
110
  ```bash
60
- npx -y @synth-coder/memhub
111
+ npx -y @synth-coder/memhub@latest
61
112
  ```
62
113
 
63
114
  > Windows 下不要在包名后再加 `memhub` 参数。
64
115
  > 如果出现“弹出源码 .js 文件”的情况,请升级到最新版本(`0.1.2+`)后重试。
65
116
 
66
- 在你的 MCP 客户端配置中添加:
117
+ 在你的 MCP 客户端配置中添加:
67
118
 
68
119
  ```json
69
120
  {
70
121
  "mcpServers": {
71
122
  "memhub": {
72
123
  "command": "npx",
73
- "args": ["-y", "@synth-coder/memhub"],
124
+ "args": ["-y", "@synth-coder/memhub@latest"],
74
125
  "env": {
75
126
  "MEMHUB_STORAGE_PATH": "/绝对路径/你的记忆目录",
76
127
  "MEMHUB_LOG_LEVEL": "info"
77
128
  }
78
129
  }
79
130
  }
80
- }
81
- ```
82
-
83
- ### 方式 B:本地仓库运行
131
+ }
132
+ ```
133
+
134
+ 如果是 Codex(`~/.codex/config.toml`),请使用 TOML 键 `mcp_servers`:
135
+
136
+ ```toml
137
+ [mcp_servers.memhub]
138
+ command = "npx"
139
+ args = ["-y", "@synth-coder/memhub@latest"]
140
+ ```
141
+
142
+ ### 方式 B:本地仓库运行
84
143
 
85
144
  ```json
86
145
  {
@@ -131,7 +190,7 @@ YYYY-MM-DD-title-slug.md
131
190
 
132
191
  ## MCP 工具列表
133
192
 
134
- > 调用策略建议见:`docs/tool-calling-policy.md`(首轮 `memory_load`,末轮 `memory_update`)。
193
+ > 详见 [docs/mcp-tools.md](docs/mcp-tools.md) 获取 API 参考。
135
194
 
136
195
  - `memory_load`:首轮加载短期记忆(STM)上下文
137
196
  - `memory_update`:末轮回写决策/偏好/知识/状态变化
@@ -182,9 +241,10 @@ memhub/
182
241
  - [x] 架构与契约设计
183
242
  - [x] 核心实现(storage/service/server)
184
243
  - [x] 质量门禁(lint/typecheck/test/coverage)
244
+ - [x] CLI init 命令快速配置
185
245
  - [ ] 集成测试
186
246
  - [ ] 性能优化
187
- - [x] npm 发布(`@synth-coder/memhub@0.1.3`)
247
+ - [x] npm 发布(`@synth-coder/memhub@0.2.5`)
188
248
 
189
249
  ---
190
250
 
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Claude Code MCP configuration generator
3
+ */
4
+ export declare function generateClaudeCodeConfig(_memhubPath: string): Record<string, unknown>;
5
+ //# sourceMappingURL=claude-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-code.d.ts","sourceRoot":"","sources":["../../../../src/cli/agents/claude-code.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASrF"}