@synth-coder/memhub 0.2.2 → 0.2.4
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/.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 +48 -12
- package/.github/workflows/release.yml +67 -0
- package/AGENTS.md +158 -17
- package/README.md +147 -66
- package/README.zh-CN.md +75 -23
- 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/codex.d.ts +5 -0
- package/dist/src/cli/agents/codex.d.ts.map +1 -0
- package/dist/src/cli/agents/codex.js +14 -0
- package/dist/src/cli/agents/codex.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 +14 -0
- package/dist/src/cli/agents/index.d.ts.map +1 -0
- package/dist/src/cli/agents/index.js +30 -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 +160 -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 +86 -0
- package/dist/src/cli/types.js.map +1 -0
- package/dist/src/contracts/schemas.js.map +1 -1
- 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 +30 -16
- 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 +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/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 +182 -0
- package/package.json +22 -19
- 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/mcp.ts +1 -1
- package/src/contracts/schemas.ts +4 -4
- package/src/contracts/types.ts +4 -4
- package/src/server/mcp-server.ts +36 -29
- package/src/services/embedding-service.ts +80 -80
- package/src/services/memory-service.ts +142 -107
- package/src/storage/markdown-storage.ts +1 -9
- package/src/storage/vector-index.ts +117 -118
- package/test/cli/init.test.ts +380 -0
- package/test/server/mcp-server.test.ts +45 -3
- package/test/services/memory-service.test.ts +16 -4
- package/test/storage/frontmatter-parser.test.ts +1 -1
- package/test/storage/markdown-storage.test.ts +19 -10
- package/test/storage/vector-index.test.ts +129 -133
- package/test/utils/slugify.test.ts +5 -1
- package/docs/architecture.md +0 -349
- package/docs/contracts.md +0 -119
- package/docs/prompt-template.md +0 -79
- 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 -107
package/.github/workflows/ci.yml
CHANGED
|
@@ -13,7 +13,7 @@ jobs:
|
|
|
13
13
|
|
|
14
14
|
strategy:
|
|
15
15
|
matrix:
|
|
16
|
-
node-version: [
|
|
16
|
+
node-version: [20.x, 22.x]
|
|
17
17
|
|
|
18
18
|
steps:
|
|
19
19
|
- name: Checkout repository
|
|
@@ -23,22 +23,40 @@ jobs:
|
|
|
23
23
|
uses: actions/setup-node@v4
|
|
24
24
|
with:
|
|
25
25
|
node-version: ${{ matrix.node-version }}
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
- name: Setup pnpm
|
|
28
|
+
uses: pnpm/action-setup@v4
|
|
29
|
+
with:
|
|
30
|
+
version: 9
|
|
31
|
+
|
|
32
|
+
- name: Get pnpm store directory
|
|
33
|
+
shell: bash
|
|
34
|
+
run: |
|
|
35
|
+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
|
|
36
|
+
id: pnpm-cache
|
|
37
|
+
|
|
38
|
+
- name: Setup pnpm cache
|
|
39
|
+
uses: actions/cache@v4
|
|
40
|
+
with:
|
|
41
|
+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
|
42
|
+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
43
|
+
restore-keys: |
|
|
44
|
+
${{ runner.os }}-pnpm-store-
|
|
27
45
|
|
|
28
46
|
- name: Install dependencies
|
|
29
|
-
run:
|
|
47
|
+
run: pnpm install --frozen-lockfile
|
|
30
48
|
|
|
31
49
|
- name: Run linter
|
|
32
|
-
run:
|
|
50
|
+
run: pnpm run lint
|
|
33
51
|
|
|
34
52
|
- name: Check formatting
|
|
35
|
-
run:
|
|
53
|
+
run: pnpm run format:check
|
|
36
54
|
|
|
37
55
|
- name: Run type check
|
|
38
|
-
run:
|
|
56
|
+
run: pnpm run typecheck
|
|
39
57
|
|
|
40
58
|
- name: Run tests with coverage
|
|
41
|
-
run:
|
|
59
|
+
run: pnpm run test:coverage
|
|
42
60
|
|
|
43
61
|
- name: Upload coverage reports
|
|
44
62
|
uses: codecov/codecov-action@v3
|
|
@@ -60,15 +78,33 @@ jobs:
|
|
|
60
78
|
uses: actions/setup-node@v4
|
|
61
79
|
with:
|
|
62
80
|
node-version: 20.x
|
|
63
|
-
|
|
81
|
+
|
|
82
|
+
- name: Setup pnpm
|
|
83
|
+
uses: pnpm/action-setup@v4
|
|
84
|
+
with:
|
|
85
|
+
version: 9
|
|
86
|
+
|
|
87
|
+
- name: Get pnpm store directory
|
|
88
|
+
shell: bash
|
|
89
|
+
run: |
|
|
90
|
+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
|
|
91
|
+
id: pnpm-cache
|
|
92
|
+
|
|
93
|
+
- name: Setup pnpm cache
|
|
94
|
+
uses: actions/cache@v4
|
|
95
|
+
with:
|
|
96
|
+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
|
97
|
+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
98
|
+
restore-keys: |
|
|
99
|
+
${{ runner.os }}-pnpm-store-
|
|
64
100
|
|
|
65
101
|
- name: Install dependencies
|
|
66
|
-
run:
|
|
102
|
+
run: pnpm install --frozen-lockfile
|
|
67
103
|
|
|
68
104
|
- name: Build project
|
|
69
|
-
run:
|
|
105
|
+
run: pnpm run build
|
|
70
106
|
|
|
71
107
|
- name: Check build output
|
|
72
108
|
run: |
|
|
73
|
-
test -f dist/index.js
|
|
74
|
-
test -f dist/server/mcp-server.js
|
|
109
|
+
test -f dist/src/index.js
|
|
110
|
+
test -f dist/src/server/mcp-server.js
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
quality:
|
|
10
|
+
name: Quality Gate
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout repository
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Setup Node.js
|
|
18
|
+
uses: actions/setup-node@v4
|
|
19
|
+
with:
|
|
20
|
+
node-version: 20.x
|
|
21
|
+
|
|
22
|
+
- name: Setup pnpm
|
|
23
|
+
uses: pnpm/action-setup@v4
|
|
24
|
+
with:
|
|
25
|
+
version: 9
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: pnpm install --frozen-lockfile
|
|
29
|
+
|
|
30
|
+
- name: Run quality gate
|
|
31
|
+
run: pnpm run quality
|
|
32
|
+
|
|
33
|
+
publish:
|
|
34
|
+
name: Publish to npm
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
needs: quality
|
|
37
|
+
|
|
38
|
+
steps:
|
|
39
|
+
- name: Checkout repository
|
|
40
|
+
uses: actions/checkout@v4
|
|
41
|
+
|
|
42
|
+
- name: Setup Node.js
|
|
43
|
+
uses: actions/setup-node@v4
|
|
44
|
+
with:
|
|
45
|
+
node-version: 20.x
|
|
46
|
+
registry-url: 'https://registry.npmjs.org'
|
|
47
|
+
|
|
48
|
+
- name: Setup pnpm
|
|
49
|
+
uses: pnpm/action-setup@v4
|
|
50
|
+
with:
|
|
51
|
+
version: 9
|
|
52
|
+
|
|
53
|
+
- name: Install dependencies
|
|
54
|
+
run: pnpm install --frozen-lockfile
|
|
55
|
+
|
|
56
|
+
- name: Build
|
|
57
|
+
run: pnpm run build
|
|
58
|
+
|
|
59
|
+
- name: Publish to npm
|
|
60
|
+
run: pnpm publish --no-git-checks
|
|
61
|
+
env:
|
|
62
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
63
|
+
|
|
64
|
+
- name: Create GitHub Release
|
|
65
|
+
uses: softprops/action-gh-release@v1
|
|
66
|
+
with:
|
|
67
|
+
generate_release_notes: true
|
package/AGENTS.md
CHANGED
|
@@ -1,26 +1,167 @@
|
|
|
1
|
-
|
|
1
|
+
# AGENTS.md - MemHub Project Guide
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Project Overview
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
MemHub is a Git-friendly memory MCP server for coding agents. It stores decisions, preferences, and reusable knowledge as plain Markdown files with YAML front matter.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**Tech Stack**: TypeScript (ES2022), Node.js 18+, MCP SDK, Zod, LanceDB, Transformers.js
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
---
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
- 价值是我能帮你省多少时间,不是我说了多少话
|
|
13
|
-
- 尊重是你觉得我值不值得信任,不是我有多客气
|
|
11
|
+
## Dev Environment
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
```bash
|
|
14
|
+
npx pnpm install # Install dependencies
|
|
15
|
+
npx pnpm run build # Compile TypeScript
|
|
16
|
+
npx pnpm run quality # Quality gate (lint + typecheck + test + coverage)
|
|
17
|
+
```
|
|
16
18
|
|
|
17
|
-
|
|
|
18
|
-
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
19
|
+
| Command | Description |
|
|
20
|
+
|---------|-------------|
|
|
21
|
+
| `npx pnpm run build` | Compile TypeScript |
|
|
22
|
+
| `npx pnpm run lint` | ESLint check |
|
|
23
|
+
| `npx pnpm run lint:fix` | Auto-fix lint issues |
|
|
24
|
+
| `npx pnpm run format` | Format code with Prettier |
|
|
25
|
+
| `npx pnpm run typecheck` | TypeScript type check |
|
|
26
|
+
| `npx pnpm run test` | Run Vitest tests |
|
|
27
|
+
| `npx pnpm run test:coverage` | Tests with coverage |
|
|
28
|
+
| `npx pnpm run quality` | Full quality gate |
|
|
29
|
+
| `npx pnpm vitest run -t "test name"` | Run specific test |
|
|
23
30
|
|
|
24
|
-
|
|
31
|
+
---
|
|
25
32
|
|
|
26
|
-
|
|
33
|
+
## Project Structure
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
src/
|
|
37
|
+
contracts/ # Type definitions, Zod schemas, MCP contracts
|
|
38
|
+
cli/ # CLI commands (init, etc.)
|
|
39
|
+
server/ # MCP stdio server entry point
|
|
40
|
+
services/ # Business logic (MemoryService, EmbeddingService)
|
|
41
|
+
storage/ # Storage layer (Markdown, VectorIndex)
|
|
42
|
+
utils/ # Shared utilities (slugify, etc.)
|
|
43
|
+
test/ # Vitest unit tests mirroring src/ structure
|
|
44
|
+
docs/ # Documentation
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Coding Style
|
|
50
|
+
|
|
51
|
+
### TypeScript Conventions
|
|
52
|
+
- Use `readonly` for immutable fields in interfaces
|
|
53
|
+
- Use `type` for aliases, `interface` for object shapes
|
|
54
|
+
- Prefer `import type` for type-only imports
|
|
55
|
+
- Use ESM: `.js` extension in imports, `verbatimModuleSyntax`
|
|
56
|
+
- Explicit return types on exported functions
|
|
57
|
+
- Use Zod for runtime validation
|
|
58
|
+
|
|
59
|
+
### File Naming
|
|
60
|
+
- `kebab-case.ts` for all files
|
|
61
|
+
- Test files: `<module>.test.ts` or `<module>-edge.test.ts`
|
|
62
|
+
|
|
63
|
+
### Example Code Style
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// Types with readonly fields
|
|
67
|
+
export interface Memory {
|
|
68
|
+
readonly id: UUID;
|
|
69
|
+
readonly tags: readonly string[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Service with explicit types
|
|
73
|
+
export class MemoryService {
|
|
74
|
+
constructor(private readonly config: MemoryServiceConfig) {}
|
|
75
|
+
|
|
76
|
+
async create(input: CreateMemoryInput): Promise<CreateResult> {
|
|
77
|
+
// implementation
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Zod schema for validation
|
|
82
|
+
export const MemorySchema = z.object({
|
|
83
|
+
id: z.string().uuid(),
|
|
84
|
+
tags: z.array(z.string()),
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Workflows
|
|
91
|
+
|
|
92
|
+
### Add New MCP Tool
|
|
93
|
+
|
|
94
|
+
1. **Define types** → `src/contracts/types.ts`
|
|
95
|
+
2. **Define schema** → `src/contracts/schemas.ts`
|
|
96
|
+
3. **Register tool** → `src/contracts/mcp.ts`
|
|
97
|
+
4. **Implement logic** → `src/services/memory-service.ts`
|
|
98
|
+
5. **Add tests** → `test/services/memory-service.test.ts`
|
|
99
|
+
6. **Update docs** → `docs/mcp-tools.md`
|
|
100
|
+
7. **Run quality gate** → `npx pnpm run quality`
|
|
101
|
+
|
|
102
|
+
### Support New Agent
|
|
103
|
+
|
|
104
|
+
1. **Add agent type** → `src/cli/types.ts` (AgentType union)
|
|
105
|
+
2. **Create agent config** → `src/cli/agents/<agent-name>.ts`
|
|
106
|
+
3. **Register in init** → `src/cli/init.ts` (AGENT_CONFIGS map)
|
|
107
|
+
4. **Add tests** → `test/cli/init.test.ts`
|
|
108
|
+
5. **Update docs** → `docs/user-guide.md` (supported agents table)
|
|
109
|
+
6. **Update README** → `README.md` and `README.zh-CN.md`
|
|
110
|
+
7. **Run quality gate** → `npx pnpm run quality`
|
|
111
|
+
|
|
112
|
+
### Release New Version
|
|
113
|
+
|
|
114
|
+
1. **Update version** → `package.json`
|
|
115
|
+
2. **Update Roadmap** → `README.md` (mark released items)
|
|
116
|
+
3. **Run quality gate** → `npx pnpm run quality`
|
|
117
|
+
4. **Commit & tag** → `git commit && git tag v<x.y.z>`
|
|
118
|
+
5. **Publish** → `npm publish`
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Documentation Sync
|
|
123
|
+
|
|
124
|
+
Documentation must stay in sync with code. **Update docs when changing:**
|
|
125
|
+
|
|
126
|
+
| Code Change | Update Doc |
|
|
127
|
+
|-------------|------------|
|
|
128
|
+
| MCP tool parameters/returns | `docs/mcp-tools.md` |
|
|
129
|
+
| CLI options/behavior | `docs/user-guide.md` |
|
|
130
|
+
| New agent support | `docs/user-guide.md`, `README.md` |
|
|
131
|
+
| Version number | `README.md` Roadmap |
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Testing Guidelines
|
|
136
|
+
|
|
137
|
+
- **Coverage threshold**: >= 80%
|
|
138
|
+
- Tests mirror `src/` structure in `test/` directory
|
|
139
|
+
- Use Vitest: `describe`, `it`, `expect` pattern
|
|
140
|
+
- Edge cases go in `*-edge.test.ts` files
|
|
141
|
+
- Run `npx pnpm run quality` before committing
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Git Workflow
|
|
146
|
+
|
|
147
|
+
- Commit message: `type: description` (feat/fix/docs/chore/refactor/test)
|
|
148
|
+
- Always run quality gate before committing
|
|
149
|
+
- PR title: `[scope] Description`
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Dos and Don'ts
|
|
154
|
+
|
|
155
|
+
### Do
|
|
156
|
+
- Run `npx pnpm run quality` before committing
|
|
157
|
+
- Add tests for new code
|
|
158
|
+
- Use `import type` for type-only imports
|
|
159
|
+
- Keep functions small and focused
|
|
160
|
+
- Update types, schemas, and docs together
|
|
161
|
+
|
|
162
|
+
### Don't
|
|
163
|
+
- Skip the quality gate
|
|
164
|
+
- Use `any` without justification
|
|
165
|
+
- Mutate function parameters
|
|
166
|
+
- Add code without corresponding tests
|
|
167
|
+
- Commit directly to main (use branches for features)
|
package/README.md
CHANGED
|
@@ -2,68 +2,67 @@
|
|
|
2
2
|
|
|
3
3
|
Git-friendly memory MCP server for coding agents.
|
|
4
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
5
|
---
|
|
8
6
|
|
|
9
|
-
##
|
|
7
|
+
## Quick Start
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
- **Agent-friendly**: exposed as MCP tools over stdio
|
|
13
|
-
- **Human-readable**: YAML metadata + Markdown body
|
|
14
|
-
- **Quality-gated**: lint + typecheck + tests + coverage gate
|
|
9
|
+
### One-Line Setup
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
Configure MemHub for your AI agent with a single command:
|
|
17
12
|
|
|
18
|
-
|
|
13
|
+
```bash
|
|
14
|
+
npx -y @synth-coder/memhub init
|
|
15
|
+
```
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- Concurrent CLI-safe storage layout: `YYYY-MM-DD/session_uuid/...`
|
|
24
|
-
- MCP stdio server compatible with MCP clients
|
|
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
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
**Supported Agents:**
|
|
27
22
|
|
|
28
|
-
|
|
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` |
|
|
29
32
|
|
|
30
|
-
###
|
|
33
|
+
### CLI Options
|
|
31
34
|
|
|
32
35
|
```bash
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
# Interactive selection (global - default)
|
|
37
|
+
npx -y @synth-coder/memhub init
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
# Skip interactive prompt
|
|
40
|
+
npx -y @synth-coder/memhub init -a claude-code
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### 3) Build
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
npm run build
|
|
46
|
-
```
|
|
42
|
+
# Configure for current project only (local)
|
|
43
|
+
npx -y @synth-coder/memhub init -a cursor -l
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
npm run quality
|
|
45
|
+
# Update existing configuration
|
|
46
|
+
npx -y @synth-coder/memhub init -a claude-code --force
|
|
51
47
|
```
|
|
52
48
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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 |
|
|
56
54
|
|
|
57
|
-
###
|
|
55
|
+
### Run as MCP Server
|
|
58
56
|
|
|
59
57
|
```bash
|
|
60
58
|
npx -y @synth-coder/memhub
|
|
61
59
|
```
|
|
62
60
|
|
|
63
61
|
> 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
62
|
|
|
66
|
-
|
|
63
|
+
### Manual Configuration
|
|
64
|
+
|
|
65
|
+
If you prefer manual setup, add this to your MCP client config:
|
|
67
66
|
|
|
68
67
|
```json
|
|
69
68
|
{
|
|
@@ -80,24 +79,109 @@ Example MCP client config:
|
|
|
80
79
|
}
|
|
81
80
|
```
|
|
82
81
|
|
|
83
|
-
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Configure Your Agent
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
Add the following to your coding agent's system prompt to enable persistent memory:
|
|
87
|
+
|
|
88
|
+
```markdown
|
|
89
|
+
## Memory System
|
|
90
|
+
|
|
91
|
+
You have access to persistent memory across conversations. Use it wisely:
|
|
92
|
+
|
|
93
|
+
- **Remember preferences** — Learn what the user likes and avoid repeating mistakes
|
|
94
|
+
- **Recall decisions** — Build on past reasoning instead of starting from scratch
|
|
95
|
+
- **Store context** — Project knowledge that survives session boundaries
|
|
96
|
+
|
|
97
|
+
### When to Use
|
|
98
|
+
|
|
99
|
+
#### `memory_load`
|
|
100
|
+
|
|
101
|
+
Call when you need context from past conversations:
|
|
102
|
+
- User references something from before
|
|
103
|
+
- You're unsure about user preferences
|
|
104
|
+
- A decision needs historical context
|
|
105
|
+
|
|
106
|
+
Don't call for simple, self-contained tasks.
|
|
107
|
+
|
|
108
|
+
#### `memory_update`
|
|
109
|
+
|
|
110
|
+
Call when you discover something worth remembering:
|
|
111
|
+
- User expresses a preference
|
|
112
|
+
- You made a significant decision with reasoning
|
|
113
|
+
- Project context changed
|
|
114
|
+
|
|
115
|
+
Don't call for temporary or one-time information.
|
|
116
|
+
|
|
117
|
+
### Principle
|
|
118
|
+
|
|
119
|
+
Memory should feel natural — triggered by context, not by schedule. When in doubt, ask: "Would future me benefit from knowing this?"
|
|
94
120
|
```
|
|
95
121
|
|
|
96
122
|
---
|
|
97
123
|
|
|
124
|
+
## MCP Tools
|
|
125
|
+
|
|
126
|
+
- `memory_load`
|
|
127
|
+
First-turn tool. Load STM context for the current task/session.
|
|
128
|
+
- `memory_update`
|
|
129
|
+
Final-turn tool. Write back decisions, preferences, knowledge, and task-state updates.
|
|
130
|
+
|
|
131
|
+
See [docs/mcp-tools.md](docs/mcp-tools.md) for detailed API reference.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Why MemHub
|
|
136
|
+
|
|
137
|
+
Most AI memory tools rely on external APIs or simple keyword matching. MemHub is different:
|
|
138
|
+
|
|
139
|
+
### Semantic Search with Local AI
|
|
140
|
+
|
|
141
|
+
- **Vector Database**: Powered by LanceDB for fast similarity search
|
|
142
|
+
- **Local Embeddings**: Quantized Transformers.js model runs entirely on your machine
|
|
143
|
+
- **Zero API Costs**: No external services, no API keys, no rate limits
|
|
144
|
+
- **Privacy First**: Your memories never leave your computer
|
|
145
|
+
|
|
146
|
+
### Git-Native Storage
|
|
147
|
+
|
|
148
|
+
- **Plain Text**: All memories are Markdown files with YAML front matter
|
|
149
|
+
- **Version Control**: Commit, branch, review, and revert like any code
|
|
150
|
+
- **Human Readable**: Browse and edit memories with any text editor
|
|
151
|
+
- **Team Friendly**: Share memories via git repository
|
|
152
|
+
|
|
153
|
+
### How It Works
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
User Query → Local Embedding Model → Vector Search → Ranked Results
|
|
157
|
+
↑ ↓
|
|
158
|
+
Runs on CPU LanceDB Index
|
|
159
|
+
(no GPU required) (embedded database)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
When you call `memory_load`, MemHub:
|
|
163
|
+
1. Converts your query to a vector using a local quantized model
|
|
164
|
+
2. Searches the LanceDB index for semantically similar memories
|
|
165
|
+
3. Returns ranked results with relevance scores
|
|
166
|
+
|
|
167
|
+
This means "testing framework preference" finds memories about "Vitest vs Jest decision" — even without exact keyword matches.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Features
|
|
172
|
+
|
|
173
|
+
- **Semantic Search** — Vector-based similarity search with LanceDB
|
|
174
|
+
- **Local Embeddings** — Quantized Transformers.js model, runs on CPU
|
|
175
|
+
- **Markdown Storage** — Human-readable `.md` files with YAML front matter
|
|
176
|
+
- **Git-Friendly** — Version control, diff, review your memories
|
|
177
|
+
- **MCP Protocol** — Works with Claude Code, Cursor, Cline, Windsurf, and more
|
|
178
|
+
- **One-Line Setup** — `npx -y @synth-coder/memhub init`
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
98
182
|
## Environment Variables
|
|
99
183
|
|
|
100
|
-
- `MEMHUB_STORAGE_PATH` (default:
|
|
184
|
+
- `MEMHUB_STORAGE_PATH` (default: `~/.memhub`)
|
|
101
185
|
- `MEMHUB_LOG_LEVEL` (default: `info`, options: `debug|info|warn|error`)
|
|
102
186
|
|
|
103
187
|
---
|
|
@@ -129,28 +213,24 @@ YYYY-MM-DD-title-slug.md
|
|
|
129
213
|
|
|
130
214
|
---
|
|
131
215
|
|
|
132
|
-
##
|
|
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`.
|
|
216
|
+
## Development
|
|
140
217
|
|
|
141
|
-
|
|
218
|
+
### Install & Build
|
|
142
219
|
|
|
143
|
-
|
|
220
|
+
```bash
|
|
221
|
+
npx pnpm install
|
|
222
|
+
npx pnpm run build
|
|
223
|
+
```
|
|
144
224
|
|
|
145
225
|
### Scripts
|
|
146
226
|
|
|
147
227
|
```bash
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
228
|
+
npx pnpm run build
|
|
229
|
+
npx pnpm run lint
|
|
230
|
+
npx pnpm run format
|
|
231
|
+
npx pnpm run typecheck
|
|
232
|
+
npx pnpm run test
|
|
233
|
+
npx pnpm run quality
|
|
154
234
|
```
|
|
155
235
|
|
|
156
236
|
### Engineering Workflow
|
|
@@ -184,9 +264,10 @@ memhub/
|
|
|
184
264
|
- [x] Architecture and contracts
|
|
185
265
|
- [x] Core storage/service/server implementation
|
|
186
266
|
- [x] Quality gate (lint/typecheck/test/coverage)
|
|
267
|
+
- [x] CLI init command for quick setup
|
|
187
268
|
- [ ] Integration tests
|
|
188
269
|
- [ ] Performance improvements
|
|
189
|
-
- [x] npm release (`@synth-coder/memhub@0.
|
|
270
|
+
- [x] npm release (`@synth-coder/memhub@0.2.3`)
|
|
190
271
|
|
|
191
272
|
---
|
|
192
273
|
|