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/MODULES.md
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
# Memorix 模块详解
|
|
2
|
+
|
|
3
|
+
> 最后更新: 2026-03-09 (v1.0.0)
|
|
4
|
+
> 本文档详细记录每个模块的实现细节、关键算法和注意事项
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. Orama 搜索引擎 (`store/orama-store.ts`)
|
|
9
|
+
|
|
10
|
+
### 概述
|
|
11
|
+
基于 [Orama](https://github.com/orama/orama) 的全文/混合搜索引擎,344行。
|
|
12
|
+
|
|
13
|
+
### Schema 设计
|
|
14
|
+
```typescript
|
|
15
|
+
// 动态 Schema — embedding 可用时自动添加 vector 字段
|
|
16
|
+
const schema = {
|
|
17
|
+
id: 'string',
|
|
18
|
+
observationId: 'number',
|
|
19
|
+
entityName: 'string',
|
|
20
|
+
type: 'string', // 用于 where 过滤
|
|
21
|
+
title: 'string', // 全文搜索
|
|
22
|
+
narrative: 'string', // 全文搜索 (权重最高)
|
|
23
|
+
facts: 'string', // 全文搜索
|
|
24
|
+
filesModified: 'string',
|
|
25
|
+
concepts: 'string', // 全文搜索
|
|
26
|
+
tokens: 'number',
|
|
27
|
+
createdAt: 'string',
|
|
28
|
+
projectId: 'string',
|
|
29
|
+
accessCount: 'number',
|
|
30
|
+
lastAccessedAt: 'string',
|
|
31
|
+
// 条件字段:
|
|
32
|
+
vector: 'vector[384]', // 仅当 embedding provider 可用时存在
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 搜索策略
|
|
37
|
+
1. **纯全文 (BM25)**: 无 embedding 时的默认模式
|
|
38
|
+
2. **混合搜索**: `term` + `vector` 联合搜索,embedding 从查询文本生成
|
|
39
|
+
3. **过滤**: 支持按 `type` 和 `projectId` 进行 where 过滤
|
|
40
|
+
|
|
41
|
+
### 访问追踪
|
|
42
|
+
每次搜索结果返回时,自动更新命中文档的:
|
|
43
|
+
- `accessCount += 1`
|
|
44
|
+
- `lastAccessedAt = now()`
|
|
45
|
+
|
|
46
|
+
这些数据驱动 retention 引擎的衰减计算。
|
|
47
|
+
|
|
48
|
+
### ⚠️ 注意事项
|
|
49
|
+
- Orama 的 where 子句在 `term: '' + number filter` 时可能不可靠,因此 `compactDetail` 使用内存查找而非 Orama 查询
|
|
50
|
+
- 数据库是内存中的,重启后需要通过 `reindexObservations()` 重建
|
|
51
|
+
- `resetDb()` 用于热重载场景 — 先清空再重建
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 2. 持久化层 (`store/persistence.ts`)
|
|
56
|
+
|
|
57
|
+
### 存储目录
|
|
58
|
+
```
|
|
59
|
+
~/.memorix/data/
|
|
60
|
+
├── observations.json # 所有 observation 的 JSON 数组
|
|
61
|
+
├── id-counter.txt # 下一个 observation ID (纯文本数字)
|
|
62
|
+
├── entities.jsonl # 知识图谱节点 (每行一个 JSON)
|
|
63
|
+
├── relations.jsonl # 知识图谱边 (每行一个 JSON)
|
|
64
|
+
├── sessions.json # 会话历史
|
|
65
|
+
├── mini-skills.json # 永久技能
|
|
66
|
+
└── team-state.json # 自主 Agent Team 状态
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### JSONL 格式 (MCP 兼容)
|
|
70
|
+
```jsonl
|
|
71
|
+
{"name":"auth-module","entityType":"component","observations":["JWT 认证实现"]}
|
|
72
|
+
{"name":"port-config","entityType":"config","observations":["默认端口 3001"]}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 设计决策
|
|
76
|
+
- **全局共享目录** (`~/.memorix/data/`): 让不同 Agent 看到同一份数据
|
|
77
|
+
- **JSONL 而非单 JSON**: 与 MCP Official Memory Server 的格式兼容
|
|
78
|
+
- **observations.json 用 JSON 而非 JSONL**: observation 结构更复杂,JSON 更方便整体读写
|
|
79
|
+
- **ID 计数器单独文件**: 避免扫描所有 observation 来确定下一个 ID
|
|
80
|
+
|
|
81
|
+
### ⚠️ 注意事项
|
|
82
|
+
- v0.9.6 后所有数据存储在单一平坦目录 `~/.memorix/data/`,projectId 仅作为元数据
|
|
83
|
+
- 有文件锁机制 (`store/file-lock.ts`) — 使用 `.memorix.lock` 目录锁 + 10s 超时检测
|
|
84
|
+
- 热重载使用 `fs.watchFile` (polling) 监听 `observations.json` 变化
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 3. 知识图谱 (`memory/graph.ts`)
|
|
89
|
+
|
|
90
|
+
### 操作
|
|
91
|
+
| 方法 | 说明 |
|
|
92
|
+
|------|------|
|
|
93
|
+
| `createEntities` | 创建实体,同名跳过 (幂等) |
|
|
94
|
+
| `deleteEntities` | 删除实体 + 关联的关系 |
|
|
95
|
+
| `createRelations` | 创建关系,完全相同则跳过 |
|
|
96
|
+
| `deleteRelations` | 精确匹配删除 |
|
|
97
|
+
| `addObservations` | 追加 observation 文本到实体 |
|
|
98
|
+
| `deleteObservations` | 从实体中移除特定 observation 文本 |
|
|
99
|
+
| `searchNodes` | 大小写不敏感搜索实体名/类型/观察内容 |
|
|
100
|
+
| `openNodes` | 按名称精确查找实体 + 相关关系 |
|
|
101
|
+
| `readGraph` | 返回完整图谱 |
|
|
102
|
+
|
|
103
|
+
### 持久化时机
|
|
104
|
+
- 每次 CRUD 操作后立即写入磁盘
|
|
105
|
+
- `init()` 时从磁盘加载
|
|
106
|
+
|
|
107
|
+
### ⚠️ 注意事项
|
|
108
|
+
- `createEntities` 对同名实体是幂等的 — 不会覆盖已有观察
|
|
109
|
+
- 关系的 `from` 和 `to` 必须引用已存在的实体名
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 4. 记忆保留与衰减 (`memory/retention.ts`)
|
|
114
|
+
|
|
115
|
+
### 核心公式
|
|
116
|
+
```
|
|
117
|
+
relevance = baseImportance × e^(-ageDays / retentionPeriod) × accessBoost
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 参数配置
|
|
121
|
+
```typescript
|
|
122
|
+
// 重要性 → 保留期
|
|
123
|
+
critical: 365天, base=1.0
|
|
124
|
+
high: 180天, base=0.8 (gotcha, decision, trade-off)
|
|
125
|
+
medium: 90天, base=0.5 (problem-solution, how-it-works, etc.)
|
|
126
|
+
low: 30天, base=0.3 (session-request)
|
|
127
|
+
|
|
128
|
+
// 访问加速
|
|
129
|
+
accessBoost = min(2.0, 1 + 0.1 × accessCount)
|
|
130
|
+
|
|
131
|
+
// 免疫条件 (任一满足)
|
|
132
|
+
- importance === 'critical' || 'high'
|
|
133
|
+
- accessCount >= 3
|
|
134
|
+
- concepts 包含 'keep' | 'important' | 'pinned' | 'critical'
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### 生命周期分区
|
|
138
|
+
```
|
|
139
|
+
Active: 7天内被访问 | 免疫 | age < 50% retention
|
|
140
|
+
Stale: age > 50% retention
|
|
141
|
+
Archive-candidate: age > 100% retention & !immune
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### ⚠️ 注意事项
|
|
145
|
+
- 免疫的 observation 最低 relevance 为 0.5
|
|
146
|
+
- `high` 重要性的 observation 也被视为免疫 — 这意味着 `gotcha`, `decision`, `trade-off` 永远不会被自动归档
|
|
147
|
+
- `archiveExpired()` 可自动归档过期记忆,`deferredInit` 启动时自动执行
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## 5. 实体抽取器 (`memory/entity-extractor.ts`)
|
|
152
|
+
|
|
153
|
+
### 正则模式
|
|
154
|
+
```
|
|
155
|
+
文件路径: (?:^|[\s"'(])([.\w/-]+\.\w{1,10})(?:[\s"'),]|$)
|
|
156
|
+
模块路径: (@[\w-]+\/[\w.-]+) 或 (a.b.c.d 格式)
|
|
157
|
+
URL: https?://[^\s"'<>)]+
|
|
158
|
+
@提及: @([a-zA-Z_]\w+)
|
|
159
|
+
CamelCase: ([A-Z][a-z]+(?:[A-Z][a-z]+)+)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 因果语言检测
|
|
163
|
+
```
|
|
164
|
+
because | therefore | due to | caused by | as a result | decided to |
|
|
165
|
+
chosen because | so that | in order to | leads to | results in |
|
|
166
|
+
fixed by | resolved by
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### 概念丰富规则
|
|
170
|
+
- 文件路径 → 取最后一段文件名 (去扩展名) → 概念
|
|
171
|
+
- 模块路径 → 取最后一段 → 概念
|
|
172
|
+
- CamelCase 标识符 → 直接作为概念
|
|
173
|
+
- 所有概念与用户提供的概念去重合并
|
|
174
|
+
|
|
175
|
+
### ⚠️ 注意事项
|
|
176
|
+
- 最小实体长度: 通用3字符, 文件路径5字符
|
|
177
|
+
- 全局正则需要在每次使用前重置 `lastIndex`
|
|
178
|
+
- 支持中文括号标识符 (「」、【】) 和中文因果语言模式 (因为/所以/由于/导致/决定/采用)
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 6. 自动关系创建 (`memory/auto-relations.ts`)
|
|
183
|
+
|
|
184
|
+
### 关系推断逻辑
|
|
185
|
+
```
|
|
186
|
+
有因果语言 → "causes"
|
|
187
|
+
problem-solution → "fixes"
|
|
188
|
+
decision/trade-off → "decides"
|
|
189
|
+
what-changed → "modifies"
|
|
190
|
+
gotcha → "warns_about"
|
|
191
|
+
其他 → "references"
|
|
192
|
+
filesModified 匹配 → "modifies" (始终)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### 匹配流程
|
|
196
|
+
1. 从 extracted entities 中收集候选词 (identifiers + 文件名 + 模块名)
|
|
197
|
+
2. 与知识图谱中所有已有实体进行**大小写不敏感**匹配
|
|
198
|
+
3. 跳过自引用 (entityName === candidate)
|
|
199
|
+
4. 去重后批量创建
|
|
200
|
+
|
|
201
|
+
### ⚠️ 注意事项
|
|
202
|
+
- 每次都读取完整图谱 (`readGraph()`) — 大图谱时可能有性能问题
|
|
203
|
+
- 只能匹配**已存在**的实体 — 不会自动创建新实体
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 7. Embedding 层 (`embedding/`)
|
|
208
|
+
|
|
209
|
+
### 架构
|
|
210
|
+
```
|
|
211
|
+
EmbeddingProvider (接口)
|
|
212
|
+
├── embed(text) → number[384]
|
|
213
|
+
├── embedBatch(texts) → number[384][]
|
|
214
|
+
├── name: string
|
|
215
|
+
└── dimensions: number
|
|
216
|
+
|
|
217
|
+
FastEmbedProvider (实现)
|
|
218
|
+
├── 模型: BAAI/bge-small-en-v1.5
|
|
219
|
+
├── 维度: 384
|
|
220
|
+
├── 大小: ~30MB (首次使用自动下载)
|
|
221
|
+
├── 缓存: 内存 Map, 最多 5000 条, FIFO 淘汰
|
|
222
|
+
└── 批量: batch size = 64
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 优雅降级
|
|
226
|
+
```
|
|
227
|
+
getEmbeddingProvider()
|
|
228
|
+
├── 尝试 import('fastembed') → 成功 → 返回 FastEmbedProvider
|
|
229
|
+
└── 失败 → 返回 null → Orama 退化为纯 BM25 搜索
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### ⚠️ 注意事项
|
|
233
|
+
- `fastembed` 是**可选依赖** — 不在 `dependencies` 中
|
|
234
|
+
- Singleton 模式: 全局只有一个 provider 实例
|
|
235
|
+
- `resetProvider()` 仅用于测试
|
|
236
|
+
- Float32Array → number[] 转换是必要的 (Orama 需要 plain array)
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## 8. Hooks 系统 (`hooks/`)
|
|
241
|
+
|
|
242
|
+
### Normalizer — Agent 格式映射
|
|
243
|
+
|
|
244
|
+
**Claude Code / VS Code Copilot:**
|
|
245
|
+
```json
|
|
246
|
+
{"hookEventName": "PostToolUse", "sessionId": "xxx", "tool_name": "write", ...}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**Windsurf:**
|
|
250
|
+
```json
|
|
251
|
+
{"agent_action_name": "post_write_code", "trajectory_id": "xxx", "tool_info": {...}}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Cursor:**
|
|
255
|
+
```json
|
|
256
|
+
{"hook_event_name": "afterFileEdit", "conversation_id": "xxx", ...}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Pattern Detector — 置信度计算
|
|
260
|
+
```
|
|
261
|
+
confidence = baseConfidence + matchCount × 0.05
|
|
262
|
+
上限: 1.0
|
|
263
|
+
```
|
|
264
|
+
多个关键词匹配 → 置信度更高 → 更可能被记录
|
|
265
|
+
|
|
266
|
+
### Handler — 冷却和过滤机制
|
|
267
|
+
- **全局冷却 Map**: `eventType → lastTimestamp`
|
|
268
|
+
- **冷却期**: 30秒 (同一事件类型不会重复记录)
|
|
269
|
+
- **噪音命令过滤**: ls, cd, pwd, echo 等不记录
|
|
270
|
+
- **最小长度**: 通用 100 字符, 代码编辑 30 字符
|
|
271
|
+
- **内容截断**: 最大 4000 字符
|
|
272
|
+
- **自引用保护**: 跳过 memorix 自己的工具调用
|
|
273
|
+
|
|
274
|
+
### ⚠️ 注意事项
|
|
275
|
+
- Hooks **必须永远不能崩溃** — 所有错误都静默处理
|
|
276
|
+
- `pre_compact` 事件无冷却 — 上下文压缩前抢救式保存
|
|
277
|
+
- `session_end` 也无冷却 — 会话结束总是值得记录
|
|
278
|
+
- handler 通过 **动态 import** 加载 observations 模块以避免循环依赖
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 9. Compact 引擎 (`compact/`)
|
|
283
|
+
|
|
284
|
+
### Token 计数
|
|
285
|
+
使用 `gpt-tokenizer` (OpenAI tiktoken 的 JS 移植)。
|
|
286
|
+
|
|
287
|
+
### 截断策略
|
|
288
|
+
```
|
|
289
|
+
1. 按句子边界截断 (逐句添加直到超出预算)
|
|
290
|
+
2. 无完整句子 → 字符估算 (1 token ≈ 2 chars 混合语言)
|
|
291
|
+
3. 二分递减: 每次保留 90% 直到符合预算
|
|
292
|
+
4. 加 "..." 后缀表示截断
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Index Format — 图标映射
|
|
296
|
+
```
|
|
297
|
+
🎯 session-request 🔴 gotcha 🟡 problem-solution
|
|
298
|
+
🔵 how-it-works 🟢 what-changed 🟣 discovery
|
|
299
|
+
🟠 why-it-exists 🟤 decision ⚖️ trade-off
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## 10. 工作空间同步 (`workspace/`)
|
|
305
|
+
|
|
306
|
+
### MCP 适配器
|
|
307
|
+
| Agent | 配置格式 | 路径 |
|
|
308
|
+
|-------|---------|------|
|
|
309
|
+
| Windsurf | JSON (`mcp_config.json`) | `~/.codeium/windsurf/mcp_config.json` |
|
|
310
|
+
| Cursor | JSON (`mcp.json`) | `.cursor/mcp.json` (项目级) |
|
|
311
|
+
| Claude Code | JSON (`claude_desktop_config.json`) | 平台特定 |
|
|
312
|
+
| Codex | TOML | `codex.toml` |
|
|
313
|
+
| Copilot | JSON | `.github/copilot/mcp.json` |
|
|
314
|
+
| Antigravity | JSON | `~/.gemini/antigravity/mcp_config.json` |
|
|
315
|
+
|
|
316
|
+
### Workflow 同步
|
|
317
|
+
- 扫描 Windsurf 的 `.windsurf/workflows/` 目录
|
|
318
|
+
- 转换为 Codex skills / Cursor rules / CLAUDE.md 格式
|
|
319
|
+
- 保留原始描述和步骤
|
|
320
|
+
|
|
321
|
+
### Skills 同步
|
|
322
|
+
- 扫描各 Agent 的 skills 目录
|
|
323
|
+
- 名字冲突时保留第一个发现的,记录冲突
|
|
324
|
+
- 通过文件系统复制迁移
|
|
325
|
+
|
|
326
|
+
### Apply 流程
|
|
327
|
+
```
|
|
328
|
+
1. 扫描所有 Agent 配置
|
|
329
|
+
2. 生成目标格式文件
|
|
330
|
+
3. 备份已有配置 (.bak)
|
|
331
|
+
4. 写入新配置
|
|
332
|
+
5. 失败时回滚
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## 11. 规则同步 (`rules/`)
|
|
338
|
+
|
|
339
|
+
### UnifiedRule 中间表示
|
|
340
|
+
```typescript
|
|
341
|
+
interface UnifiedRule {
|
|
342
|
+
id: string; // 唯一标识
|
|
343
|
+
content: string; // 规则内容
|
|
344
|
+
description?: string;
|
|
345
|
+
source: RuleSource; // 来源 Agent
|
|
346
|
+
scope: 'global' | 'project' | 'path-specific';
|
|
347
|
+
paths?: string[]; // 适用的文件路径 glob
|
|
348
|
+
alwaysApply?: boolean;
|
|
349
|
+
priority: number; // 0-100
|
|
350
|
+
hash: string; // 内容哈希 (去重用)
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### 去重策略
|
|
355
|
+
- 基于 `hash` (内容的 SHA-256 前8位)
|
|
356
|
+
- 相同内容但不同来源 → 保留优先级最高的
|
|
357
|
+
|
|
358
|
+
### 冲突检测
|
|
359
|
+
- 同一 scope 但内容不同的规则 → 标记为冲突
|
|
360
|
+
- 返回冲突列表供用户决策
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## 12. 项目检测 (`project/detector.ts`)
|
|
365
|
+
|
|
366
|
+
### 检测优先级
|
|
367
|
+
```
|
|
368
|
+
1. Git root (git rev-parse --show-toplevel)
|
|
369
|
+
2. package.json 目录 (向上遍历)
|
|
370
|
+
3. CWD (当前工作目录)
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Git Remote 规范化
|
|
374
|
+
```
|
|
375
|
+
https://github.com/user/repo.git → user/repo
|
|
376
|
+
git@github.com:user/repo.git → user/repo
|
|
377
|
+
ssh://git@github.com/user/repo → user/repo
|
|
378
|
+
无 Git remote → 目录名
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### ⚠️ 注意事项
|
|
382
|
+
- `execSync` 调用 — 阻塞式, 但只在启动时运行一次
|
|
383
|
+
- 非 Git 项目回退为目录名, 可能导致不同机器上 projectId 不同
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Performance and Resource Notes
|
|
2
|
+
|
|
3
|
+
Memorix is designed to be light for everyday memory use and explicit about heavier paths. This document is a practical operator guide, not a benchmark paper.
|
|
4
|
+
|
|
5
|
+
## Runtime Shape
|
|
6
|
+
|
|
7
|
+
| Mode | What Runs | Typical Use |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `memorix serve` | One stdio MCP process, started by the client | Lightweight IDE/agent memory access |
|
|
10
|
+
| `memorix background start` | One long-lived local Node HTTP control-plane process | Dashboard, HTTP MCP, multi-session workflows |
|
|
11
|
+
| `memorix serve-http` | Same HTTP control plane in the foreground | Debugging or supervised launches |
|
|
12
|
+
| `memorix` | Interactive terminal UI | Human operator workbench |
|
|
13
|
+
| `memorix orchestrate` | Supervisor plus spawned CLI agent workers | Autonomous multi-agent loops |
|
|
14
|
+
|
|
15
|
+
The default memory path uses local SQLite as the canonical store and Orama for search/indexing. No cloud service is required.
|
|
16
|
+
|
|
17
|
+
## What Is Lightweight
|
|
18
|
+
|
|
19
|
+
- `memorix_session_start` is lightweight by default. It opens a memory/session context and does not join the Agent Team unless `joinTeam: true` is explicitly set.
|
|
20
|
+
- stdio MCP starts on demand and exits with the client.
|
|
21
|
+
- HTTP background mode idles as a single local process.
|
|
22
|
+
- LLM enrichment is optional. Without `MEMORIX_LLM_API_KEY` or `OPENAI_API_KEY`, Memorix uses local heuristic dedup/search behavior.
|
|
23
|
+
|
|
24
|
+
On the release development machine used for this check, the healthy HTTP control plane was observed at about 16 MB working set after several hours idle. Treat this as a local sanity observation, not a platform-wide guarantee.
|
|
25
|
+
|
|
26
|
+
## What Can Be Heavier
|
|
27
|
+
|
|
28
|
+
- `npm run build`, `npx vitest run`, and Docker image builds can use substantial CPU and disk while they run.
|
|
29
|
+
- Docker image size mostly comes from Node, npm dependencies, build artifacts, and image layers. The container runtime should be judged separately from image size.
|
|
30
|
+
- Dashboard browsing can add browser-side memory and CPU outside the Memorix Node process.
|
|
31
|
+
- Large imports, Git log ingestion, workspace sync, and skill generation can temporarily increase CPU and disk I/O.
|
|
32
|
+
- LLM-backed formation, reranking, extraction, and skill generation add network latency and provider cost when enabled.
|
|
33
|
+
- `memorix orchestrate` intentionally runs multiple agent workers, so its resource profile is closer to a multi-process build/test loop than a memory daemon.
|
|
34
|
+
|
|
35
|
+
## Useful Knobs
|
|
36
|
+
|
|
37
|
+
| Knob | Default | Use When |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| `MEMORIX_SESSION_TIMEOUT_MS` | `1800000` (30 min) | Increase for HTTP MCP clients that do not recover from stale session IDs after idle time |
|
|
40
|
+
| `MEMORIX_FORMATION_TIMEOUT_MS` | `12000` (12 s) | Raise when LLM-backed formation should outlive slow proxy/provider hops |
|
|
41
|
+
| `MEMORIX_LLM_API_KEY` / `OPENAI_API_KEY` | unset | Enable LLM-backed enrichment, extraction, rerank, or skill generation |
|
|
42
|
+
| `MEMORIX_LLM_TIMEOUT_MS` | `30000` (30 s) | Bound a single LLM-backed extraction/resolve call |
|
|
43
|
+
| `MEMORIX_RERANK_TIMEOUT_MS` | provider default | Bound slow LLM rerank calls |
|
|
44
|
+
| `memorix retention status` | report only | Inspect whether memory growth needs cleanup |
|
|
45
|
+
| `memorix retention archive` | explicit | Archive expired memories when the project gets noisy |
|
|
46
|
+
| `memorix memory deduplicate` / `consolidate` | explicit | Reduce duplicate or scattered memory records |
|
|
47
|
+
|
|
48
|
+
## Operator Guidance
|
|
49
|
+
|
|
50
|
+
- For memory-only use, prefer stdio MCP or a lightweight `memorix_session_start`; do not join the Agent Team by default.
|
|
51
|
+
- For long-lived IDE sessions over HTTP, set `MEMORIX_SESSION_TIMEOUT_MS=86400000` before `memorix background start` if your client is stale-session-sensitive.
|
|
52
|
+
- If LLM-backed formation is timing out against a slow proxy/provider, raise `MEMORIX_FORMATION_TIMEOUT_MS` and keep it higher than `MEMORIX_LLM_TIMEOUT_MS`, because the full pipeline can include multiple LLM-backed stages.
|
|
53
|
+
- For Docker, use it when you want a managed HTTP control plane. Do not use image size alone as the runtime memory estimate.
|
|
54
|
+
- For autonomous multi-agent work, expect CPU and disk activity proportional to the spawned agents and verification commands.
|
|
55
|
+
- For release checks, measure build/test/pack separately from idle service cost.
|
|
56
|
+
|
|
57
|
+
## Current Optimization Opportunities
|
|
58
|
+
|
|
59
|
+
These are not release blockers, but they are reasonable future improvements:
|
|
60
|
+
|
|
61
|
+
- Add a lightweight benchmark command that reports startup time, index size, SQLite size, and search latency.
|
|
62
|
+
- Add dashboard-side performance telemetry for API latency and payload sizes.
|
|
63
|
+
- Document recommended retention schedules for large projects.
|
|
64
|
+
- Explore slimmer Docker layers if image size becomes a common pain point.
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Memorix Docs Map
|
|
2
|
+
|
|
3
|
+
Use this page as the shortest path to the right Memorix document.
|
|
4
|
+
|
|
5
|
+
Memorix docs are intentionally split by **user intent**, not by a giant flat list.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Start Here
|
|
10
|
+
|
|
11
|
+
| You want to... | Read this |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| Install Memorix and choose between stdio vs HTTP control-plane mode | [SETUP.md](SETUP.md) |
|
|
14
|
+
| Run Memorix in Docker / compose as an HTTP control plane | [DOCKER.md](DOCKER.md) |
|
|
15
|
+
| Understand resource usage and performance trade-offs | [PERFORMANCE.md](PERFORMANCE.md) |
|
|
16
|
+
| Configure `memorix.yml`, `.env`, and project overrides | [CONFIGURATION.md](CONFIGURATION.md) |
|
|
17
|
+
| Operate Memorix correctly as an AI coding agent | [AGENT_OPERATOR_PLAYBOOK.md](AGENT_OPERATOR_PLAYBOOK.md) |
|
|
18
|
+
| Understand the MCP / HTTP / CLI command surface | [API_REFERENCE.md](API_REFERENCE.md) |
|
|
19
|
+
| Operate sessions, memory, tasks, locks, and team state from a terminal | [API_REFERENCE.md](API_REFERENCE.md) |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Product and Runtime
|
|
24
|
+
|
|
25
|
+
| Topic | Document |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| System shape, control plane, storage, and retrieval architecture | [ARCHITECTURE.md](ARCHITECTURE.md) |
|
|
28
|
+
| Resource profile, heavier paths, and tuning knobs | [PERFORMANCE.md](PERFORMANCE.md) |
|
|
29
|
+
| Memory formation, enrichment, and quality pipeline | [MEMORY_FORMATION_PIPELINE.md](MEMORY_FORMATION_PIPELINE.md) |
|
|
30
|
+
| Git-derived engineering memory | [GIT_MEMORY.md](GIT_MEMORY.md) |
|
|
31
|
+
| Agent Team: autonomous agents, tasks, messages, locks, poll | [API_REFERENCE.md §9](API_REFERENCE.md#9-agent-team-tools) |
|
|
32
|
+
| Multi-agent orchestration loop | [API_REFERENCE.md](API_REFERENCE.md) — `memorix orchestrate` |
|
|
33
|
+
| Workspace & rules sync across agents | [API_REFERENCE.md §8](API_REFERENCE.md#8-workspace-and-rules-tools) |
|
|
34
|
+
| Project skills and mini-skill promotion | [API_REFERENCE.md §7](API_REFERENCE.md#7-skills-and-promotion-tools) |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Development
|
|
39
|
+
|
|
40
|
+
| Topic | Document |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| Contributor workflow and current release baseline | [DEVELOPMENT.md](DEVELOPMENT.md) |
|
|
43
|
+
| Major design choices and ADR-style rationale | [DESIGN_DECISIONS.md](DESIGN_DECISIONS.md) |
|
|
44
|
+
| Module-by-module implementation notes | [MODULES.md](MODULES.md) |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## AI-Facing Context
|
|
49
|
+
|
|
50
|
+
| Topic | Document |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| Canonical operator guidance for coding agents | [AGENT_OPERATOR_PLAYBOOK.md](AGENT_OPERATOR_PLAYBOOK.md) |
|
|
53
|
+
| Compact AI context note | [AI_CONTEXT.md](AI_CONTEXT.md) |
|
|
54
|
+
| LLM-friendly context bundle | [../llms.txt](../llms.txt) |
|
|
55
|
+
| Extended LLM-friendly context bundle | [../llms-full.txt](../llms-full.txt) |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Release Truth vs Historical Reference
|
|
60
|
+
|
|
61
|
+
For `1.0.8`, treat the following as the **release-truth** docs:
|
|
62
|
+
|
|
63
|
+
- [SETUP.md](SETUP.md)
|
|
64
|
+
- [DOCKER.md](DOCKER.md)
|
|
65
|
+
- [PERFORMANCE.md](PERFORMANCE.md)
|
|
66
|
+
- [CONFIGURATION.md](CONFIGURATION.md)
|
|
67
|
+
- [AGENT_OPERATOR_PLAYBOOK.md](AGENT_OPERATOR_PLAYBOOK.md)
|
|
68
|
+
- [API_REFERENCE.md](API_REFERENCE.md)
|
|
69
|
+
- [ARCHITECTURE.md](ARCHITECTURE.md)
|
|
70
|
+
- [DEVELOPMENT.md](DEVELOPMENT.md)
|
|
71
|
+
|
|
72
|
+
The following are still useful, but they are **deeper reference / historical context** rather than the first source of operational truth:
|
|
73
|
+
|
|
74
|
+
- [DESIGN_DECISIONS.md](DESIGN_DECISIONS.md)
|
|
75
|
+
- [MODULES.md](MODULES.md)
|
|
76
|
+
- [KNOWN_ISSUES_AND_ROADMAP.md](KNOWN_ISSUES_AND_ROADMAP.md)
|
|
77
|
+
- [CLOUD_SYNC_AND_MULTI_AGENT_RESEARCH.md](CLOUD_SYNC_AND_MULTI_AGENT_RESEARCH.md)
|
|
78
|
+
|
|
79
|
+
If any deep reference conflicts with the release-truth docs above, prefer the release-truth docs.
|