@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.
- package/.github/workflows/ci.yml +48 -12
- package/.github/workflows/release.yml +70 -0
- package/AGENTS.md +71 -73
- package/README.md +284 -195
- package/README.zh-CN.md +90 -30
- package/dist/src/cli/agents/claude-code.d.ts +5 -0
- package/dist/src/cli/agents/claude-code.d.ts.map +1 -0
- package/dist/src/cli/agents/claude-code.js +14 -0
- package/dist/src/cli/agents/claude-code.js.map +1 -0
- package/dist/src/cli/agents/cline.d.ts +5 -0
- package/dist/src/cli/agents/cline.d.ts.map +1 -0
- package/dist/src/cli/agents/cline.js +14 -0
- package/dist/src/cli/agents/cline.js.map +1 -0
- package/dist/src/cli/agents/cursor.d.ts +5 -0
- package/dist/src/cli/agents/cursor.d.ts.map +1 -0
- package/dist/src/cli/agents/cursor.js +14 -0
- package/dist/src/cli/agents/cursor.js.map +1 -0
- package/dist/src/cli/agents/factory-droid.d.ts +5 -0
- package/dist/src/cli/agents/factory-droid.d.ts.map +1 -0
- package/dist/src/cli/agents/factory-droid.js +14 -0
- package/dist/src/cli/agents/factory-droid.js.map +1 -0
- package/dist/src/cli/agents/gemini-cli.d.ts +5 -0
- package/dist/src/cli/agents/gemini-cli.d.ts.map +1 -0
- package/dist/src/cli/agents/gemini-cli.js +14 -0
- package/dist/src/cli/agents/gemini-cli.js.map +1 -0
- package/dist/src/cli/agents/index.d.ts +13 -0
- package/dist/src/cli/agents/index.d.ts.map +1 -0
- package/dist/src/cli/agents/index.js +27 -0
- package/dist/src/cli/agents/index.js.map +1 -0
- package/dist/src/cli/agents/windsurf.d.ts +5 -0
- package/dist/src/cli/agents/windsurf.d.ts.map +1 -0
- package/dist/src/cli/agents/windsurf.js +14 -0
- package/dist/src/cli/agents/windsurf.js.map +1 -0
- package/dist/src/cli/index.d.ts +8 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/cli/index.js +168 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/cli/init.d.ts +34 -0
- package/dist/src/cli/init.d.ts.map +1 -0
- package/dist/src/cli/init.js +140 -0
- package/dist/src/cli/init.js.map +1 -0
- package/dist/src/cli/instructions.d.ts +29 -0
- package/dist/src/cli/instructions.d.ts.map +1 -0
- package/dist/src/cli/instructions.js +141 -0
- package/dist/src/cli/instructions.js.map +1 -0
- package/dist/src/cli/types.d.ts +22 -0
- package/dist/src/cli/types.d.ts.map +1 -0
- package/dist/src/cli/types.js +75 -0
- package/dist/src/cli/types.js.map +1 -0
- package/dist/src/contracts/mcp.js +34 -34
- package/dist/src/contracts/schemas.js.map +1 -1
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/server/mcp-server.js +7 -14
- package/dist/src/server/mcp-server.js.map +1 -1
- package/dist/src/services/embedding-service.d.ts.map +1 -1
- package/dist/src/services/embedding-service.js +1 -1
- package/dist/src/services/embedding-service.js.map +1 -1
- package/dist/src/services/memory-service.d.ts.map +1 -1
- package/dist/src/services/memory-service.js.map +1 -1
- package/dist/src/storage/markdown-storage.d.ts.map +1 -1
- package/dist/src/storage/markdown-storage.js +1 -1
- package/dist/src/storage/markdown-storage.js.map +1 -1
- package/dist/src/storage/vector-index.d.ts.map +1 -1
- package/dist/src/storage/vector-index.js +4 -5
- package/dist/src/storage/vector-index.js.map +1 -1
- package/docs/README.md +21 -0
- package/docs/mcp-tools.md +136 -0
- package/docs/user-guide.md +184 -0
- package/package.json +61 -59
- package/src/cli/agents/claude-code.ts +14 -0
- package/src/cli/agents/cline.ts +14 -0
- package/src/cli/agents/codex.ts +14 -0
- package/src/cli/agents/cursor.ts +14 -0
- package/src/cli/agents/factory-droid.ts +14 -0
- package/src/cli/agents/gemini-cli.ts +14 -0
- package/src/cli/agents/index.ts +36 -0
- package/src/cli/agents/windsurf.ts +14 -0
- package/src/cli/index.ts +192 -0
- package/src/cli/init.ts +218 -0
- package/src/cli/instructions.ts +156 -0
- package/src/cli/types.ts +112 -0
- package/src/contracts/index.ts +12 -12
- package/src/contracts/mcp.ts +223 -223
- package/src/contracts/schemas.ts +307 -307
- package/src/contracts/types.ts +410 -410
- package/src/index.ts +8 -8
- package/src/server/index.ts +5 -5
- package/src/server/mcp-server.ts +169 -186
- package/src/services/embedding-service.ts +114 -114
- package/src/services/index.ts +5 -5
- package/src/services/memory-service.ts +656 -663
- package/src/storage/frontmatter-parser.ts +243 -243
- package/src/storage/index.ts +6 -6
- package/src/storage/markdown-storage.ts +228 -236
- package/src/storage/vector-index.ts +159 -160
- package/src/utils/index.ts +5 -5
- package/src/utils/slugify.ts +63 -63
- package/test/cli/init.test.ts +402 -0
- package/test/contracts/schemas.test.ts +313 -313
- package/test/contracts/types.test.ts +21 -21
- package/test/frontmatter-parser-more.test.ts +94 -94
- package/test/server/mcp-server.test.ts +211 -210
- package/test/services/memory-service-edge.test.ts +248 -248
- package/test/services/memory-service.test.ts +291 -279
- package/test/storage/frontmatter-parser.test.ts +223 -223
- package/test/storage/markdown-storage.test.ts +226 -217
- package/test/storage/storage-edge.test.ts +238 -238
- package/test/storage/vector-index.test.ts +149 -153
- package/test/utils/slugify-edge.test.ts +94 -94
- package/test/utils/slugify.test.ts +72 -68
- package/docs/architecture-diagrams.md +0 -368
- package/docs/architecture.md +0 -381
- package/docs/contracts.md +0 -190
- package/docs/prompt-template.md +0 -33
- package/docs/proposals/mcp-typescript-sdk-refactor.md +0 -568
- package/docs/proposals/proposal-close-gates.md +0 -58
- package/docs/tool-calling-policy.md +0 -101
- 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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
---
|
|
142
|
-
|
|
143
|
-
##
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
-
|
|
159
|
-
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
-
|
|
185
|
-
-
|
|
186
|
-
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
- 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
|
-
###
|
|
58
|
+
### 一键配置
|
|
59
|
+
|
|
60
|
+
使用一条命令为你的 AI 代理配置 MemHub:
|
|
31
61
|
|
|
32
62
|
```bash
|
|
33
|
-
|
|
63
|
+
npx -y @synth-coder/memhub@latest init
|
|
34
64
|
```
|
|
35
65
|
|
|
36
|
-
|
|
66
|
+
这将启动交互式提示选择你的代理。MemHub 会:
|
|
67
|
+
1. 将 MCP 服务器配置添加到代理的配置文件
|
|
68
|
+
2. 将 MemHub 使用说明添加到代理的规则文件
|
|
37
69
|
|
|
38
|
-
|
|
39
|
-
npm install
|
|
40
|
-
```
|
|
70
|
+
**支持的代理:**
|
|
41
71
|
|
|
42
|
-
|
|
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
|
-
|
|
45
|
-
npm run build
|
|
46
|
-
```
|
|
82
|
+
### CLI 选项
|
|
47
83
|
|
|
48
|
-
### 4)执行质量门禁
|
|
49
84
|
```bash
|
|
50
|
-
|
|
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
|
-
|
|
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
|
-
>
|
|
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.
|
|
247
|
+
- [x] npm 发布(`@synth-coder/memhub@0.2.5`)
|
|
188
248
|
|
|
189
249
|
---
|
|
190
250
|
|
|
@@ -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"}
|