memorix 1.0.7 → 1.0.8
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/CHANGELOG.md +36 -9
- package/README.md +469 -409
- package/README.zh-CN.md +468 -415
- package/TEAM.md +106 -0
- package/dist/cli/index.js +31325 -26915
- package/dist/cli/index.js.map +1 -1
- package/dist/dashboard/static/app.js +49 -49
- package/dist/dashboard/static/index.html +2 -2
- package/dist/index.js +1061 -234
- package/dist/index.js.map +1 -1
- package/dist/sdk.d.ts +677 -0
- package/dist/sdk.js +18962 -0
- package/dist/sdk.js.map +1 -0
- package/dist/types.d.ts +10 -10
- package/dist/types.js +10 -10
- package/dist/types.js.map +1 -1
- package/docs/AGENT_OPERATOR_PLAYBOOK.md +684 -0
- package/docs/AI_CONTEXT.md +18 -0
- package/docs/API_REFERENCE.md +687 -0
- package/docs/ARCHITECTURE.md +488 -0
- package/docs/CLOUD_SYNC_AND_MULTI_AGENT_RESEARCH.md +470 -0
- package/docs/CONFIGURATION.md +265 -0
- package/docs/DESIGN_DECISIONS.md +358 -0
- package/docs/DEVELOPMENT.md +317 -0
- package/docs/DOCKER.md +138 -0
- package/docs/GIT_MEMORY.md +221 -0
- package/docs/KNOWN_ISSUES_AND_ROADMAP.md +149 -0
- package/docs/MEMORY_FORMATION_PIPELINE.md +224 -0
- package/docs/MODULES.md +383 -0
- package/docs/PERFORMANCE.md +64 -0
- package/docs/README.md +79 -0
- package/docs/SETUP.md +521 -0
- package/docs/hooks-architecture.md +108 -0
- package/package.json +24 -23
package/docs/SETUP.md
ADDED
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
# Setup Guide
|
|
2
|
+
|
|
3
|
+
Memorix is an open-source cross-agent memory layer for coding agents via MCP, with tiered support for Cursor, Claude Code, Windsurf (★ core), GitHub Copilot, Kiro, Codex (◆ extended), and Gemini CLI, OpenCode, Antigravity, Trae (○ community).
|
|
4
|
+
|
|
5
|
+
Memorix has four common operator entry points:
|
|
6
|
+
|
|
7
|
+
- `memorix` for the interactive local workbench in a TTY
|
|
8
|
+
- `memorix serve` for the default stdio MCP path used by most IDE integrations
|
|
9
|
+
- `memorix background start` for an optional long-lived HTTP control plane
|
|
10
|
+
- `memorix serve-http --port 3211` for foreground HTTP MCP, debugging, and manual supervision
|
|
11
|
+
|
|
12
|
+
The two server runtime modes are:
|
|
13
|
+
|
|
14
|
+
- `memorix serve` for stdio MCP integrations
|
|
15
|
+
- `memorix background start` or `memorix serve-http --port 3211` for HTTP MCP, shared access, and a live dashboard endpoint
|
|
16
|
+
|
|
17
|
+
For most users, start with `memorix` or `memorix serve`. Move to HTTP only when you explicitly want one shared background control plane, multi-client MCP access, or a live dashboard endpoint.
|
|
18
|
+
|
|
19
|
+
## Current Release Context
|
|
20
|
+
|
|
21
|
+
This guide targets the **1.0.8** working release line.
|
|
22
|
+
|
|
23
|
+
If you are setting up Memorix on a fresh machine or upgrading from an older install, the most visible operator-facing changes in 1.0.8 are:
|
|
24
|
+
|
|
25
|
+
- provenance-aware memory fields and layered retrieval surfaces
|
|
26
|
+
- stronger evidence semantics and citation-lite compact output
|
|
27
|
+
- task-line scoping plus secret-safe storage/retrieval behavior
|
|
28
|
+
- attribution auditing, retention explainability, and a cleaner remediation loop
|
|
29
|
+
- OpenCode compaction using structured continuation context and `post_compact`
|
|
30
|
+
- official Docker deployment for the HTTP control plane
|
|
31
|
+
|
|
32
|
+
### Support Tiers
|
|
33
|
+
|
|
34
|
+
| Tier | Clients | Meaning |
|
|
35
|
+
|------|---------|---------|
|
|
36
|
+
| ★ Core | Claude Code, Cursor, Windsurf | Full hook integration + tested MCP + rules sync |
|
|
37
|
+
| ◆ Extended | GitHub Copilot, Kiro, Codex | Hook integration with platform caveats |
|
|
38
|
+
| ○ Community | Gemini CLI, OpenCode, Antigravity, Trae | Best-effort hooks, community-reported compatibility |
|
|
39
|
+
|
|
40
|
+
**Install ≠ runtime-ready.** `memorix hooks install` succeeds when config files are written to disk; whether the agent actually loads and executes those hooks at runtime depends on the agent's own behavior. Core-tier agents are verified end-to-end; extended/community may have gaps.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 1. Install and Initialize
|
|
45
|
+
|
|
46
|
+
Install Memorix globally:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install -g memorix
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Initialize Memorix:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
memorix init
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The init wizard lets you choose between:
|
|
59
|
+
|
|
60
|
+
- `Global defaults` for personal multi-project workflows
|
|
61
|
+
- `Project config` for repo-specific overrides
|
|
62
|
+
|
|
63
|
+
Memorix then creates the two-file setup it is built around:
|
|
64
|
+
|
|
65
|
+
- `memorix.yml` for behavior and project settings
|
|
66
|
+
- `.env` for secrets only
|
|
67
|
+
|
|
68
|
+
See [CONFIGURATION.md](CONFIGURATION.md) for the full model.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 2. Choose a Runtime Mode
|
|
73
|
+
|
|
74
|
+
### Option A: stdio MCP
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
memorix serve
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Use this when your IDE launches Memorix as a local stdio MCP server. This is the default MCP path for most single-IDE setups.
|
|
81
|
+
|
|
82
|
+
Generic stdio MCP config:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"mcpServers": {
|
|
87
|
+
"memorix": {
|
|
88
|
+
"command": "memorix",
|
|
89
|
+
"args": ["serve"]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Option B: HTTP MCP + Dashboard
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
memorix background start
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
This mode gives you:
|
|
102
|
+
|
|
103
|
+
- HTTP MCP endpoint at `http://localhost:3211/mcp`
|
|
104
|
+
- dashboard at `http://localhost:3211`
|
|
105
|
+
- live dashboard with autonomous Agent Team state
|
|
106
|
+
- a single long-lived Memorix process shared by multiple agents
|
|
107
|
+
|
|
108
|
+
Choose this mode when you intentionally want a shared control plane. It is not the default starting point for normal single-IDE memory use.
|
|
109
|
+
|
|
110
|
+
Companion commands:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
memorix background status
|
|
114
|
+
memorix background logs
|
|
115
|
+
memorix background stop
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Startup note:
|
|
119
|
+
|
|
120
|
+
- `serve-http` seeds its default project root from `--cwd` -> `MEMORIX_PROJECT_ROOT` -> `~/.memorix/last-project-root` -> `process.cwd()`
|
|
121
|
+
- this helps the dashboard and control plane start in a sensible project even before any agent binds explicitly
|
|
122
|
+
- in multi-session workflows, agents should still call `memorix_session_start(projectRoot=...)` to avoid cross-project drift
|
|
123
|
+
- HTTP MCP sessions idle out after 30 minutes by default. For clients that do not transparently recover from stale HTTP session IDs, set `MEMORIX_SESSION_TIMEOUT_MS` before starting the control plane, for example `MEMORIX_SESSION_TIMEOUT_MS=86400000` for 24 hours.
|
|
124
|
+
|
|
125
|
+
Use `memorix serve-http --port 3211` when you want the same HTTP control plane in the foreground for debugging, manual supervision, or a custom port.
|
|
126
|
+
|
|
127
|
+
Important for multi-project usage:
|
|
128
|
+
|
|
129
|
+
- In HTTP control-plane mode, agents should call `memorix_session_start` with `projectRoot` set to the **absolute path of the current workspace or repo root** when that path is available.
|
|
130
|
+
- `projectRoot` is a detection anchor only; Git remains the source of truth for the final project identity.
|
|
131
|
+
- If the client cannot provide a reliable workspace path, Memorix should fail closed rather than silently inventing an `untracked/*` project.
|
|
132
|
+
|
|
133
|
+
Recommended when:
|
|
134
|
+
|
|
135
|
+
- you want to use the dashboard regularly
|
|
136
|
+
- you want Team tools to work
|
|
137
|
+
- you want multiple IDEs or agents to talk to one Memorix instance
|
|
138
|
+
|
|
139
|
+
Generic HTTP MCP config:
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"mcpServers": {
|
|
144
|
+
"memorix": {
|
|
145
|
+
"transport": "http",
|
|
146
|
+
"url": "http://localhost:3211/mcp"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Some clients use a different key than `transport`. The per-client examples below show the exact shape where that differs.
|
|
153
|
+
|
|
154
|
+
### Option C: Dockerized HTTP Control Plane
|
|
155
|
+
|
|
156
|
+
If you want Memorix as a long-lived containerized control plane:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
docker compose up --build -d
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
This repo now ships:
|
|
163
|
+
|
|
164
|
+
- an official `Dockerfile`
|
|
165
|
+
- an example `compose.yaml`
|
|
166
|
+
- a healthchecked HTTP deployment on port `3211`
|
|
167
|
+
|
|
168
|
+
Docker mode is for:
|
|
169
|
+
|
|
170
|
+
- `memorix serve-http`
|
|
171
|
+
- dashboard access
|
|
172
|
+
- HTTP MCP clients pointing at `http://localhost:3211/mcp`
|
|
173
|
+
|
|
174
|
+
It is not a containerized form of stdio MCP.
|
|
175
|
+
|
|
176
|
+
Important path truth:
|
|
177
|
+
|
|
178
|
+
- project-scoped Git/config behavior only works when the container can see the repo path it is asked to bind
|
|
179
|
+
- if you run Memorix in Docker on a different machine than your IDE, you must mount the relevant repos into the container or accept reduced project-scoped semantics
|
|
180
|
+
|
|
181
|
+
See [DOCKER.md](DOCKER.md) for the full deployment guide.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 3. MCP Config by Client
|
|
186
|
+
|
|
187
|
+
If you want Memorix to generate IDE-specific dot files, install them explicitly:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
memorix integrate --agent cursor
|
|
191
|
+
memorix integrate --agent windsurf
|
|
192
|
+
memorix integrate --agent opencode
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
This keeps the default experience MCP-first and zero-write until you opt into a specific IDE integration.
|
|
196
|
+
|
|
197
|
+
### Claude Code
|
|
198
|
+
|
|
199
|
+
Recommended:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
claude mcp add memorix -- memorix serve
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Manual config example:
|
|
206
|
+
|
|
207
|
+
```json
|
|
208
|
+
{
|
|
209
|
+
"mcpServers": {
|
|
210
|
+
"memorix": {
|
|
211
|
+
"command": "memorix",
|
|
212
|
+
"args": ["serve"]
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
HTTP example:
|
|
219
|
+
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"mcpServers": {
|
|
223
|
+
"memorix": {
|
|
224
|
+
"transport": "http",
|
|
225
|
+
"url": "http://localhost:3211/mcp"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
If you use the HTTP control plane and your client supports workspace-aware prompts or rules, make sure it calls `memorix_session_start` with the current workspace absolute path as `projectRoot`.
|
|
232
|
+
|
|
233
|
+
### Cursor
|
|
234
|
+
|
|
235
|
+
Project config: `.cursor/mcp.json`
|
|
236
|
+
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
"mcpServers": {
|
|
240
|
+
"memorix": {
|
|
241
|
+
"command": "memorix",
|
|
242
|
+
"args": ["serve"]
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Windsurf
|
|
249
|
+
|
|
250
|
+
Config file: `~/.codeium/windsurf/mcp_config.json`
|
|
251
|
+
|
|
252
|
+
```json
|
|
253
|
+
{
|
|
254
|
+
"mcpServers": {
|
|
255
|
+
"memorix": {
|
|
256
|
+
"command": "memorix",
|
|
257
|
+
"args": ["serve"]
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
HTTP example:
|
|
264
|
+
|
|
265
|
+
```json
|
|
266
|
+
{
|
|
267
|
+
"mcpServers": {
|
|
268
|
+
"memorix": {
|
|
269
|
+
"serverUrl": "http://localhost:3211/mcp"
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
For Windsurf-like HTTP clients, pair the MCP URL with agent instructions that pass the current workspace absolute path as `projectRoot` when starting a Memorix session.
|
|
276
|
+
|
|
277
|
+
### Codex
|
|
278
|
+
|
|
279
|
+
Config file: `~/.codex/config.toml`
|
|
280
|
+
|
|
281
|
+
```toml
|
|
282
|
+
[mcp_servers.memorix]
|
|
283
|
+
command = "memorix"
|
|
284
|
+
args = ["serve"]
|
|
285
|
+
startup_timeout_sec = 30
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
HTTP example:
|
|
289
|
+
|
|
290
|
+
```toml
|
|
291
|
+
[mcp_servers.memorix]
|
|
292
|
+
url = "http://localhost:3211/mcp"
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
For Codex-like HTTP clients, the transport URL alone is not enough for multi-project parallel work. The agent should also call `memorix_session_start` with the current workspace absolute path as `projectRoot`.
|
|
296
|
+
|
|
297
|
+
### GitHub Copilot / VS Code
|
|
298
|
+
|
|
299
|
+
Project config: `.vscode/mcp.json`
|
|
300
|
+
|
|
301
|
+
```json
|
|
302
|
+
{
|
|
303
|
+
"servers": {
|
|
304
|
+
"memorix": {
|
|
305
|
+
"command": "memorix",
|
|
306
|
+
"args": ["serve"]
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Kiro
|
|
313
|
+
|
|
314
|
+
Project config: `.kiro/settings/mcp.json`
|
|
315
|
+
|
|
316
|
+
```json
|
|
317
|
+
{
|
|
318
|
+
"mcpServers": {
|
|
319
|
+
"memorix": {
|
|
320
|
+
"command": "memorix",
|
|
321
|
+
"args": ["serve"]
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### OpenCode
|
|
328
|
+
|
|
329
|
+
OpenCode integration is usually file-based and managed through Memorix hook installers or workspace sync. If you use stdio MCP directly, the same `memorix serve` command applies.
|
|
330
|
+
|
|
331
|
+
### Gemini CLI and similar clients
|
|
332
|
+
|
|
333
|
+
If the client supports stdio MCP:
|
|
334
|
+
|
|
335
|
+
```json
|
|
336
|
+
{
|
|
337
|
+
"mcpServers": {
|
|
338
|
+
"memorix": {
|
|
339
|
+
"command": "memorix",
|
|
340
|
+
"args": ["serve"]
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
If it supports HTTP MCP, prefer:
|
|
347
|
+
|
|
348
|
+
- `http://localhost:3211/mcp`
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
## 4. Dashboard
|
|
353
|
+
|
|
354
|
+
Recommended dashboard entry:
|
|
355
|
+
|
|
356
|
+
- `http://localhost:3211`
|
|
357
|
+
|
|
358
|
+
This is the dashboard served by the HTTP control plane. In normal use, start it with `memorix background start`; use `memorix serve-http` when you want the same service in the foreground.
|
|
359
|
+
|
|
360
|
+
It includes:
|
|
361
|
+
|
|
362
|
+
- Overview
|
|
363
|
+
- Git Memory
|
|
364
|
+
- Graph
|
|
365
|
+
- Observations
|
|
366
|
+
- Retention
|
|
367
|
+
- Sessions
|
|
368
|
+
- Team
|
|
369
|
+
- Config
|
|
370
|
+
- Identity Health
|
|
371
|
+
|
|
372
|
+
There is also a standalone `memorix dashboard` command. It is a local read-mostly dashboard that includes memory, sessions, and autonomous Agent Team state from SQLite. HTTP is optional and only needed for shared MCP access or a live control-plane endpoint.
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
## 5. Agent Team Features
|
|
377
|
+
|
|
378
|
+
Agent Team features are explicit autonomous-agent coordination surfaces. Use the CLI for the normal path:
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
memorix team status
|
|
382
|
+
memorix orchestrate --goal "..."
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
These features include:
|
|
386
|
+
|
|
387
|
+
- agent registry
|
|
388
|
+
- direct messages
|
|
389
|
+
- file locks
|
|
390
|
+
- task board
|
|
391
|
+
|
|
392
|
+
The standalone dashboard can show this state read-only. Start HTTP only when you also want a shared MCP control plane or a live dashboard endpoint.
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
## 6. Common Setup Flows
|
|
397
|
+
|
|
398
|
+
### Minimal local setup
|
|
399
|
+
|
|
400
|
+
```bash
|
|
401
|
+
npm install -g memorix
|
|
402
|
+
memorix init
|
|
403
|
+
memorix serve
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Recommended full setup
|
|
407
|
+
|
|
408
|
+
```bash
|
|
409
|
+
npm install -g memorix
|
|
410
|
+
memorix init
|
|
411
|
+
memorix git-hook --force
|
|
412
|
+
memorix background start
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
Then:
|
|
416
|
+
|
|
417
|
+
- point your IDE MCP client to `memorix serve` or `http://localhost:3211/mcp`
|
|
418
|
+
- open the dashboard at `http://localhost:3211`
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## 7. Troubleshooting
|
|
423
|
+
|
|
424
|
+
### Avoid `npx`
|
|
425
|
+
|
|
426
|
+
Do not launch Memorix with `npx` in normal MCP configs. It adds startup cost and can cause handshake timeouts.
|
|
427
|
+
|
|
428
|
+
Prefer:
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
memorix serve
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
Not:
|
|
435
|
+
|
|
436
|
+
```bash
|
|
437
|
+
npx memorix serve
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### Windsurf says the MCP config file has invalid JSON
|
|
441
|
+
|
|
442
|
+
On Windows, `~/.codeium/windsurf/mcp_config.json` must be valid JSON encoded as UTF-8 **without BOM**. A BOM at the start of the file can make Windsurf reject otherwise valid JSON.
|
|
443
|
+
|
|
444
|
+
### Codex handshake timeout
|
|
445
|
+
|
|
446
|
+
If Codex reports MCP startup timeouts, increase:
|
|
447
|
+
|
|
448
|
+
```toml
|
|
449
|
+
startup_timeout_sec = 30
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
or higher on slower Windows machines.
|
|
453
|
+
|
|
454
|
+
### Codex stale HTTP session after idle time
|
|
455
|
+
|
|
456
|
+
If Codex is connected to `http://localhost:3211/mcp` and fails after a long idle period with a transport/body decoding error, the HTTP session may have expired server-side. Memorix defaults to a 30-minute HTTP session idle timeout. Increase it before starting the background control plane:
|
|
457
|
+
|
|
458
|
+
```powershell
|
|
459
|
+
$env:MEMORIX_SESSION_TIMEOUT_MS = "86400000" # 24h
|
|
460
|
+
memorix background restart
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
This keeps the default safe for normal users while giving long-running Codex HTTP sessions a practical recovery knob.
|
|
464
|
+
|
|
465
|
+
### Project detection is wrong
|
|
466
|
+
|
|
467
|
+
Memorix identifies projects from Git. If an IDE launches from a system directory or does not pass the workspace root correctly:
|
|
468
|
+
|
|
469
|
+
- prefer opening the repository root in the IDE
|
|
470
|
+
- if needed, set `MEMORIX_PROJECT_ROOT`
|
|
471
|
+
- use `memorix status` to inspect the active project identity
|
|
472
|
+
|
|
473
|
+
### Dashboard Agent Team page is empty
|
|
474
|
+
|
|
475
|
+
That usually means no autonomous agent workflow has created tasks, locks, messages, or explicit agent identities for this project yet.
|
|
476
|
+
|
|
477
|
+
Use:
|
|
478
|
+
|
|
479
|
+
```bash
|
|
480
|
+
memorix team status
|
|
481
|
+
memorix task list
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
To create autonomous work, use:
|
|
485
|
+
|
|
486
|
+
```bash
|
|
487
|
+
memorix orchestrate --goal "..."
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
If you specifically want shared HTTP MCP or a live dashboard endpoint, then start:
|
|
491
|
+
|
|
492
|
+
```bash
|
|
493
|
+
memorix background start
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
### Git hook installed but commits are not appearing as memory
|
|
497
|
+
|
|
498
|
+
Check:
|
|
499
|
+
|
|
500
|
+
- the repository has Git initialized
|
|
501
|
+
- the hook file exists
|
|
502
|
+
- the commit was not filtered as noise
|
|
503
|
+
- the active project identity is correct
|
|
504
|
+
|
|
505
|
+
Use:
|
|
506
|
+
|
|
507
|
+
```bash
|
|
508
|
+
memorix status
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
and see [GIT_MEMORY.md](GIT_MEMORY.md).
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
## 8. Related Docs
|
|
516
|
+
|
|
517
|
+
- [Configuration Guide](CONFIGURATION.md)
|
|
518
|
+
- [Git Memory Guide](GIT_MEMORY.md)
|
|
519
|
+
- [Architecture](ARCHITECTURE.md)
|
|
520
|
+
- [API Reference](API_REFERENCE.md)
|
|
521
|
+
- [Development Guide](DEVELOPMENT.md)
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Memorix Hooks Architecture — 无感知自动记忆
|
|
2
|
+
|
|
3
|
+
## 核心目标
|
|
4
|
+
|
|
5
|
+
用户安装 Memorix 后,所有 Agent 的对话、决策、bug 修复、配置变更都**自动记录**,
|
|
6
|
+
切换 Agent/窗口/对话时**自动注入**相关上下文,零操作、无感知。
|
|
7
|
+
|
|
8
|
+
## 各 Agent Hooks 格式对照
|
|
9
|
+
|
|
10
|
+
### 事件映射表
|
|
11
|
+
|
|
12
|
+
| 语义 | VS Code Copilot | Claude Code | Windsurf | Cursor (Beta) | Kiro |
|
|
13
|
+
|------|----------------|-------------|----------|---------------|------|
|
|
14
|
+
| 会话开始 | SessionStart | SessionStart | — | — | — |
|
|
15
|
+
| 用户输入 | UserPromptSubmit | UserPromptSubmit | pre_user_prompt | beforeSubmitPrompt | user prompt |
|
|
16
|
+
| 工具调用前 | PreToolUse | PreToolUse | pre_mcp_tool_use | beforeMCPExecution | — |
|
|
17
|
+
| 工具调用后 | PostToolUse | PostToolUse | post_mcp_tool_use | — | — |
|
|
18
|
+
| 文件编辑后 | PostToolUse(write) | PostToolUse(write) | post_write_code | afterFileEdit | file save |
|
|
19
|
+
| 命令执行后 | PostToolUse(cmd) | PostToolUse(cmd) | post_run_command | — | — |
|
|
20
|
+
| AI 回复后 | — | — | post_cascade_response | — | agent turn |
|
|
21
|
+
| 上下文压缩前 | PreCompact | PreCompact | — | — | — |
|
|
22
|
+
| 会话结束 | Stop | Stop | — | stop | — |
|
|
23
|
+
|
|
24
|
+
### 配置文件位置
|
|
25
|
+
|
|
26
|
+
| Agent | 配置路径 | 格式 |
|
|
27
|
+
|-------|---------|------|
|
|
28
|
+
| VS Code Copilot | `.github/hooks/*.json` | Claude Code 兼容 |
|
|
29
|
+
| Claude Code | `.claude/settings.json` | 原生 |
|
|
30
|
+
| Windsurf | `.windsurf/cascade.json` | Windsurf 格式 |
|
|
31
|
+
| Cursor | `.cursor/hooks.json` | Cursor 格式 |
|
|
32
|
+
| Kiro | `.kiro/hooks/*.hook.md` | Markdown + YAML |
|
|
33
|
+
|
|
34
|
+
### stdin/stdout 通信协议
|
|
35
|
+
|
|
36
|
+
所有 Agent 都用 **stdin JSON → stdout JSON** 通信,但字段名不同:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
// VS Code / Claude Code
|
|
40
|
+
{ "hookEventName": "PostToolUse", "sessionId": "...", "cwd": "...", "tool_name": "write", ... }
|
|
41
|
+
|
|
42
|
+
// Windsurf
|
|
43
|
+
{ "agent_action_name": "post_write_code", "trajectory_id": "...", "tool_info": { "file_path": "..." } }
|
|
44
|
+
|
|
45
|
+
// Cursor
|
|
46
|
+
{ "hook_event_name": "afterFileEdit", "conversation_id": "...", "generation_id": "...", ... }
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Memorix Hook Handler 设计
|
|
50
|
+
|
|
51
|
+
### 统一入口
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
memorix hook <normalized_event> [--agent <agent_name>]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
通过 stdin 接收 Agent 原始 JSON,内部做格式归一化。
|
|
58
|
+
|
|
59
|
+
### 归一化事件
|
|
60
|
+
|
|
61
|
+
| 归一化事件 | 自动记忆行为 |
|
|
62
|
+
|-----------|------------|
|
|
63
|
+
| `session_start` | 搜索相关记忆 → stdout 注入上下文 |
|
|
64
|
+
| `post_edit` | 分析变更 → 记录 what-changed |
|
|
65
|
+
| `post_command` | 分析命令结果 → 记录 problem-solution (如有错误) |
|
|
66
|
+
| `post_tool` | 分析 MCP 工具调用 → 记录相关操作 |
|
|
67
|
+
| `pre_compact` | 压缩前保存当前上下文摘要 |
|
|
68
|
+
| `session_end` | 总结本次会话 → 记录决策和发现 |
|
|
69
|
+
| `user_prompt` | 模式检测 → 判断是否需要注入记忆 |
|
|
70
|
+
|
|
71
|
+
### 智能过滤 — 不是什么都记
|
|
72
|
+
|
|
73
|
+
- **最小内容长度**: 300 字符(避免记录琐碎操作)
|
|
74
|
+
- **去重**: 相似度 > 0.85 的内容不重复记录
|
|
75
|
+
- **冷却时间**: 同类事件 30 秒内不重复触发
|
|
76
|
+
- **模式检测**: 只记录有价值的内容(决策、错误、学习、配置变更)
|
|
77
|
+
|
|
78
|
+
## 一键安装
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
memorix hooks install
|
|
82
|
+
# 自动检测已安装的 Agent → 生成对应配置文件
|
|
83
|
+
# 支持: --agent cursor|windsurf|claude|copilot|kiro|codex
|
|
84
|
+
# 支持: --project (仅当前项目) | --global (全局)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 文件结构
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
memorix/
|
|
91
|
+
src/
|
|
92
|
+
hooks/
|
|
93
|
+
handler.ts # 统一 hook handler 入口
|
|
94
|
+
normalizer.ts # 各 Agent stdin 格式归一化
|
|
95
|
+
analyzers/
|
|
96
|
+
edit-analyzer.ts # 文件变更分析 → what-changed
|
|
97
|
+
command-analyzer.ts # 命令结果分析 → problem-solution
|
|
98
|
+
session-analyzer.ts # 会话总结 → decision/discovery
|
|
99
|
+
pattern-detector.ts # 模式检测 (decision/error/learning)
|
|
100
|
+
installers/
|
|
101
|
+
base.ts # 安装器基类
|
|
102
|
+
claude-installer.ts # Claude Code / VS Code Copilot
|
|
103
|
+
windsurf-installer.ts
|
|
104
|
+
cursor-installer.ts
|
|
105
|
+
kiro-installer.ts
|
|
106
|
+
cli/commands/
|
|
107
|
+
hooks.ts # `memorix hooks install/uninstall/status` 命令
|
|
108
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memorix",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Open-source cross-agent memory layer for coding agents across Cursor, Claude Code, Codex, Windsurf, Gemini CLI, Copilot, Kiro, OpenCode, Antigravity, and Trae via MCP.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -17,30 +17,24 @@
|
|
|
17
17
|
"./types": {
|
|
18
18
|
"import": "./dist/types.js",
|
|
19
19
|
"types": "./dist/types.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./sdk": {
|
|
22
|
+
"import": "./dist/sdk.js",
|
|
23
|
+
"types": "./dist/sdk.d.ts"
|
|
20
24
|
}
|
|
21
25
|
},
|
|
22
|
-
"files": [
|
|
23
|
-
"dist
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
"dist/dashboard/static/style.css",
|
|
35
|
-
"dist/dashboard/static/logo.png",
|
|
36
|
-
"README.md",
|
|
37
|
-
"LICENSE",
|
|
38
|
-
"CHANGELOG.md",
|
|
39
|
-
"CLAUDE.md",
|
|
40
|
-
"llms.txt",
|
|
41
|
-
"llms-full.txt",
|
|
42
|
-
"README.zh-CN.md"
|
|
43
|
-
],
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md",
|
|
29
|
+
"README.zh-CN.md",
|
|
30
|
+
"docs",
|
|
31
|
+
"TEAM.md",
|
|
32
|
+
"LICENSE",
|
|
33
|
+
"CHANGELOG.md",
|
|
34
|
+
"CLAUDE.md",
|
|
35
|
+
"llms.txt",
|
|
36
|
+
"llms-full.txt"
|
|
37
|
+
],
|
|
44
38
|
"scripts": {
|
|
45
39
|
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsup",
|
|
46
40
|
"dev": "tsup --watch",
|
|
@@ -107,6 +101,10 @@
|
|
|
107
101
|
"gpt-tokenizer": "^2.8.0",
|
|
108
102
|
"gray-matter": "^4.0.3",
|
|
109
103
|
"ink": "^6.8.0",
|
|
104
|
+
"ink-big-text": "^2.0.0",
|
|
105
|
+
"ink-gradient": "^4.0.0",
|
|
106
|
+
"ink-scroll-view": "^0.3.6",
|
|
107
|
+
"ink-spinner": "^5.0.0",
|
|
110
108
|
"js-yaml": "^3.13.1",
|
|
111
109
|
"react": "^19.2.4",
|
|
112
110
|
"remark": "^15.0.1",
|
|
@@ -118,6 +116,9 @@
|
|
|
118
116
|
"better-sqlite3": "^11.0.0",
|
|
119
117
|
"fastembed": "^1.14.4"
|
|
120
118
|
},
|
|
119
|
+
"overrides": {
|
|
120
|
+
"tar": "^7.0.0"
|
|
121
|
+
},
|
|
121
122
|
"devDependencies": {
|
|
122
123
|
"@types/better-sqlite3": "^7.6.0",
|
|
123
124
|
"@types/diff": "^7.0.0",
|