@synth-coder/memhub 0.2.2 → 0.2.3
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/.eslintrc.cjs +45 -45
- package/.factory/commands/opsx-apply.md +150 -0
- package/.factory/commands/opsx-archive.md +155 -0
- package/.factory/commands/opsx-explore.md +171 -0
- package/.factory/commands/opsx-propose.md +104 -0
- package/.factory/skills/openspec-apply-change/SKILL.md +156 -0
- package/.factory/skills/openspec-archive-change/SKILL.md +114 -0
- package/.factory/skills/openspec-explore/SKILL.md +288 -0
- package/.factory/skills/openspec-propose/SKILL.md +110 -0
- package/.github/workflows/ci.yml +74 -74
- package/.iflow/commands/opsx-apply.md +152 -152
- package/.iflow/commands/opsx-archive.md +157 -157
- package/.iflow/commands/opsx-explore.md +173 -173
- package/.iflow/commands/opsx-propose.md +106 -106
- package/.iflow/skills/openspec-apply-change/SKILL.md +156 -156
- package/.iflow/skills/openspec-archive-change/SKILL.md +114 -114
- package/.iflow/skills/openspec-explore/SKILL.md +288 -288
- package/.iflow/skills/openspec-propose/SKILL.md +110 -110
- package/.prettierrc +11 -11
- package/AGENTS.md +169 -26
- package/README.md +195 -195
- package/README.zh-CN.md +193 -193
- package/dist/src/contracts/mcp.js +34 -34
- package/dist/src/server/mcp-server.d.ts +8 -0
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/server/mcp-server.js +23 -2
- package/dist/src/server/mcp-server.js.map +1 -1
- package/dist/src/services/memory-service.d.ts +1 -0
- package/dist/src/services/memory-service.d.ts.map +1 -1
- package/dist/src/services/memory-service.js +125 -82
- package/dist/src/services/memory-service.js.map +1 -1
- package/docs/architecture-diagrams.md +368 -0
- package/docs/architecture.md +381 -349
- package/docs/contracts.md +190 -119
- package/docs/prompt-template.md +33 -79
- package/docs/proposals/mcp-typescript-sdk-refactor.md +568 -568
- package/docs/proposals/proposal-close-gates.md +58 -58
- package/docs/tool-calling-policy.md +101 -107
- package/docs/vector-search.md +306 -0
- package/package.json +59 -58
- package/src/contracts/index.ts +12 -12
- package/src/contracts/mcp.ts +222 -222
- 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 +185 -161
- package/src/services/embedding-service.ts +114 -114
- package/src/services/index.ts +5 -5
- package/src/services/memory-service.ts +663 -621
- package/src/storage/frontmatter-parser.ts +243 -243
- package/src/storage/index.ts +6 -6
- package/src/storage/markdown-storage.ts +236 -236
- package/src/storage/vector-index.ts +160 -160
- package/src/utils/index.ts +5 -5
- package/src/utils/slugify.ts +63 -63
- 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 +210 -169
- package/test/services/memory-service-edge.test.ts +248 -248
- package/test/services/memory-service.test.ts +278 -278
- package/test/storage/frontmatter-parser.test.ts +222 -222
- package/test/storage/markdown-storage.test.ts +216 -216
- package/test/storage/storage-edge.test.ts +238 -238
- package/test/storage/vector-index.test.ts +153 -153
- package/test/utils/slugify-edge.test.ts +94 -94
- package/test/utils/slugify.test.ts +68 -68
- package/tsconfig.json +25 -25
- package/tsconfig.test.json +8 -8
- package/vitest.config.ts +29 -29
package/README.md
CHANGED
|
@@ -1,195 +1,195 @@
|
|
|
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.
|
|
190
|
-
|
|
191
|
-
---
|
|
192
|
-
|
|
193
|
-
## License
|
|
194
|
-
|
|
195
|
-
MIT
|
|
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
|