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/README.zh-CN.md CHANGED
@@ -1,435 +1,488 @@
1
- <p align="center">
2
- <img src="https://raw.githubusercontent.com/AVIDS2/memorix/main/assets/readme-logo-bridge.png" alt="Memorix Bridge" width="720">
3
- </p>
4
-
5
- <h1 align="center">Memorix</h1>
6
-
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/AVIDS2/memorix/main/assets/readme-logo-bridge.png" alt="Memorix Bridge" width="720">
3
+ </p>
4
+
5
+ <h1 align="center">Memorix</h1>
6
+
7
7
  <p align="center">
8
8
  <strong>面向 Coding Agent 的开源跨 Agent Memory Layer。</strong><br>
9
- 通过 MCP 为 Cursor、Claude Code、Codex、Windsurf、Gemini CLI、GitHub Copilot、Kiro、OpenCode、Antigravity Trae 提供分级支持。
10
- </p>
11
-
12
- <p align="center">
13
- <a href="https://www.npmjs.com/package/memorix"><img src="https://img.shields.io/npm/v/memorix.svg?style=flat-square&color=cb3837" alt="npm"></a>
14
- <a href="https://www.npmjs.com/package/memorix"><img src="https://img.shields.io/npm/dm/memorix.svg?style=flat-square&color=blue" alt="downloads"></a>
15
- <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-green.svg?style=flat-square" alt="license"></a>
16
- <a href="https://github.com/AVIDS2/memorix/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/AVIDS2/memorix/ci.yml?style=flat-square&label=CI" alt="CI"></a>
17
- <a href="https://github.com/AVIDS2/memorix"><img src="https://img.shields.io/github/stars/AVIDS2/memorix?style=flat-square&color=yellow" alt="stars"></a>
18
- </p>
19
-
20
- <p align="center">
21
- <strong>Git Memory</strong> | <strong>Reasoning Memory</strong> | <strong>跨 Agent 召回</strong> | <strong>Control Plane Dashboard</strong>
9
+ 通过 MCP 为 Cursor、Claude Code、Codex、Windsurf、Gemini CLI、GitHub Copilot、Kiro、OpenCode、Antigravity、Trae 以及其他兼容 MCP 的客户端提供分级支持。
22
10
  </p>
23
-
24
- <p align="center">
25
- <a href="README.md">English</a> |
26
- <a href="#快速开始">快速开始</a> |
27
- <a href="#支持的客户端">支持的客户端</a> |
28
- <a href="#核心工作流">核心工作流</a> |
29
- <a href="#文档导航">文档导航</a> |
30
- <a href="docs/SETUP.md">安装与接入</a>
31
- </p>
32
-
33
- ---
34
-
35
- ## 给 Coding Agent 的说明
36
-
37
- 如果你在用 AI coding agent 帮用户安装、配置或排障 Memorix,请先读 [Agent Operator Playbook](docs/AGENT_OPERATOR_PLAYBOOK.md)。
38
-
39
- 这份文档是给 agent 的正式操作手册,重点说明:
40
-
41
- - 安装与运行模式选择
42
- - Git 与项目绑定规则
43
- - stdio 与 HTTP control plane 的区别
44
- - 各 IDE / Agent 的集成和 hooks
45
- - dot 目录按需生成策略
46
- - 排障顺序和安全操作边界
47
-
48
- ## 为什么是 Memorix
49
-
50
- 大多数 Coding Agent 只记得当前线程。Memorix 提供的是一层共享、持久、可检索的项目记忆,让不同 IDE、不同 Agent、不同会话都能在同一套本地记忆库上继续工作。
51
-
52
- Memorix 的几个关键差异点:
53
-
54
- - **Git Memory**:把 `git commit` 变成可检索的工程记忆,保留提交来源、变更文件和噪音过滤结果。
55
- - **Reasoning Memory**:不只记录“改了什么”,还记录“为什么这么做”。
56
- - **跨 Agent 本地召回**:多个 IDE Agent 可以读取同一套本地记忆,而不是各自形成孤岛。
57
- - **记忆质量管线**:formation、压缩、保留衰减和 source-aware retrieval 协同工作,而不是一堆彼此独立的小功能。
58
-
59
- 一句话说,Memorix 解决的是:让多个 Coding Agent 通过 MCP 共享同一套耐久项目记忆,同时保留 Git 真相、推理上下文和本地控制权。
60
-
61
- ## 1.0.7 更新亮点
62
-
63
- `1.0.7` 这次发布,真正把 Memorix 的记忆语义、检索层次和运维闭环补完整了。
64
-
65
- - **以 provenance 为先的检索模型**:记忆现在会明确区分 `explicit`、`hook`、`git-ingest` 等来源细节,以及 `core`、`contextual`、`ephemeral` 等价值类别。
66
- - **分层披露(Layered Disclosure)**:session start、search、detail、timeline 更清楚地区分了 routing hints、working context 和 deeper evidence。
67
- - **证据语义与 citation-lite**:紧凑输出现在能说明 repository-backed evidence、synthesized analysis,以及“为什么会浮出来 / 它由什么支持”的轻量提示。
68
- - **任务线收束与 secret safety**:检索更不容易在同一个 repo 内串到错误的 workstream,明显的密码、token、credential 也会在写入和读取路径上被拦截或脱敏。
69
- - **归属校验与 cleanup 闭环**:wrong-bucket 审计、retention explainability、stale review 和 remediation hint 现在已经形成一个可操作的清理闭环。
70
- - **OpenCode compaction 改进**:OpenCode 的 compaction 不再暗示会自动调用 MCP 工具,而是使用结构化 continuation prompt,并暴露真实的 `post_compact` 事件。
71
-
72
- ## 支持的客户端
73
-
74
- | 层级 | 客户端 |
75
- |------|--------|
76
- | ★ 核心 | Claude Code, Cursor, Windsurf |
77
- | 扩展 | GitHub Copilot, Kiro, Codex |
78
- | ○ 社区 | Gemini CLI, OpenCode, Antigravity, Trae |
79
-
80
- **核心** = 完整 hook 集成 + 测试过的 MCP + 规则同步。**扩展** = hook 集成但有平台限制。**社区** = 尽力适配,兼容性由社区反馈。
81
-
82
- 如果某个客户端能通过 MCP 连接本地命令或 HTTP 端点,通常也可以接入 Memorix,只是暂时没有单独的适配器或引导页。
83
-
84
- ---
85
-
86
- ## 快速开始
87
-
88
- 全局安装:
89
-
90
- ```bash
91
- npm install -g memorix
92
- ```
93
-
94
- 初始化 Memorix 配置:
95
-
96
- ```bash
97
- memorix init
98
- ```
99
-
100
- `memorix init` 会让你在 `Global defaults` 和 `Project config` 之间选择作用域。
101
-
102
- Memorix 使用两类文件:
103
-
104
- - `memorix.yml`:行为配置和项目设置
105
- - `.env`:API key 等 secrets
106
-
107
- 然后按你的目标选择一条最顺手的路径:
108
-
109
- | 你想做什么 | 运行命令 | 适合场景 |
110
- | --- | --- | --- |
111
- | 先把 Memorix 快速接到一个 IDE 里 | `memorix serve` | Cursor、Claude Code、Codex、Windsurf、Gemini CLI 等 stdio MCP 客户端 |
112
- | 在后台长期运行 HTTP MCP + Dashboard | `memorix background start` | 日常使用、多 Agent、协作、dashboard |
113
- | HTTP 模式放在前台调试或自定义端口 | `memorix serve-http --port 3211` | 调试、手动观察日志、自定义启动方式 |
114
-
115
- 对大多数用户来说,先从下面两条里选一条就够了:
116
-
117
- - `memorix serve`:你只想尽快在 IDE 里用起来
118
- - `memorix background start`:你想要 dashboard 和后台常驻的 HTTP control plane
119
-
120
- 可选的本地交互式界面:
121
-
122
- ```bash
123
- memorix
124
- ```
125
-
126
- 只有在你确实想在 TTY 里直接使用本地 workbench 时,才需要运行裸命令 `memorix`。对大多数用户来说,它不是主安装路径。
127
-
128
- 配套命令:
129
-
130
- ```bash
131
- memorix background status
132
- memorix background logs
133
- memorix background stop
134
- ```
135
-
136
- 如果你确实需要把 HTTP control plane 放在前台运行、做调试、手动观察日志或使用自定义端口,再用:
137
-
138
- ```bash
139
- memorix serve-http --port 3211
140
- ```
141
-
142
- 如果你在多个工作区或多个 Agent 之间共享 HTTP control plane,请让每个 session 都在开始时调用 `memorix_session_start(projectRoot=...)`。
143
-
144
- 更细的启动根路径选择、项目绑定、配置优先级和 agent 操作说明,放在 [docs/SETUP.md](docs/SETUP.md)[Agent Operator Playbook](docs/AGENT_OPERATOR_PLAYBOOK.md) 里。
145
-
146
- 把 Memorix 加进你的 MCP 客户端:
147
-
148
- ### 通用 stdio MCP 配置
149
-
150
- ```json
151
- {
152
- "mcpServers": {
153
- "memorix": {
154
- "command": "memorix",
155
- "args": ["serve"]
156
- }
157
- }
158
- }
159
- ```
160
-
161
- ### 通用 HTTP MCP 配置
162
-
163
- ```json
164
- {
165
- "mcpServers": {
166
- "memorix": {
167
- "transport": "http",
168
- "url": "http://localhost:3211/mcp"
169
- }
170
- }
171
- }
172
- ```
173
-
174
- 如果你用的是 HTTP control plane,并且会跨多个工作区或多个 Agent 共享,请确保客户端或 agent 在每个项目 session 开始时调用 `memorix_session_start(projectRoot=绝对工作区路径)`。
175
-
176
- 下面这些客户端示例展示的是最简单的 stdio 形态。如果你更想使用共享的 HTTP control plane,请沿用上面的通用 HTTP 配置块,并到 [docs/SETUP.md](docs/SETUP.md) 查看各客户端字段差异。
177
-
178
- <details open>
179
- <summary><strong>Cursor</strong> | <code>.cursor/mcp.json</code></summary>
180
-
181
- ```json
182
- {
183
- "mcpServers": {
184
- "memorix": {
185
- "command": "memorix",
186
- "args": ["serve"]
187
- }
188
- }
189
- }
190
- ```
191
- </details>
192
-
193
- <details>
194
- <summary><strong>Claude Code</strong></summary>
195
-
196
- ```bash
197
- claude mcp add memorix -- memorix serve
198
- ```
199
- </details>
200
-
201
- <details>
202
- <summary><strong>Codex</strong> | <code>~/.codex/config.toml</code></summary>
203
-
204
- ```toml
205
- [mcp_servers.memorix]
206
- command = "memorix"
207
- args = ["serve"]
208
- ```
209
- </details>
210
-
211
- 完整 IDE 配置矩阵、Windows 注意事项和排障说明见 [docs/SETUP.md](docs/SETUP.md)。
212
-
213
- ---
214
-
215
- ## 核心工作流
216
-
217
- ### 1. 存储与检索项目记忆
218
-
219
- 常用 MCP 工具包括:
220
-
221
- - `memorix_store`
222
- - `memorix_search`
223
- - `memorix_detail`
224
- - `memorix_timeline`
225
- - `memorix_resolve`
226
-
227
- 这条主链适合沉淀决策、坑点、问题修复和会话交接。
228
-
229
- ### 2. 自动捕获 Git 真相
230
-
231
- 安装 post-commit hook:
232
-
233
- ```bash
234
- memorix git-hook --force
235
- ```
236
-
237
- 或者手动导入:
238
-
239
- ```bash
240
- memorix ingest commit
241
- memorix ingest log --count 20
242
- ```
243
-
244
- Git Memory 会保留 `source='git'`、提交哈希、文件变更和噪音过滤结果。
245
-
246
- ### 3. 运行控制面与 Dashboard
247
-
248
- ```bash
249
- memorix background start
250
- ```
251
-
252
- 然后访问:
253
-
254
- - MCP HTTP 端点:`http://localhost:3211/mcp`
255
- - Dashboard:`http://localhost:3211`
256
-
257
- 配套命令:
258
-
259
- ```bash
260
- memorix background status
261
- memorix background logs
262
- memorix background stop
263
- ```
264
-
265
- 如果你需要把控制面放在前台做调试或手动观察,也可以使用:
266
-
267
- ```bash
268
- memorix serve-http --port 3211
269
- ```
270
-
271
- 这一模式会把 dashboard、配置诊断、项目身份、团队协作和 Git Memory 视图统一到一个控制面入口里。
272
-
273
- 当多个 HTTP session 同时存在时,每个 session 都应先用 `memorix_session_start(projectRoot=...)` 显式绑定当前工作区,再去调用项目级记忆工具。
274
-
275
- ---
276
-
11
+
12
+ <p align="center">
13
+ <a href="https://www.npmjs.com/package/memorix"><img src="https://img.shields.io/npm/v/memorix.svg?style=flat-square&color=cb3837" alt="npm"></a>
14
+ <a href="https://www.npmjs.com/package/memorix"><img src="https://img.shields.io/npm/dm/memorix.svg?style=flat-square&color=blue" alt="downloads"></a>
15
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-green.svg?style=flat-square" alt="license"></a>
16
+ <a href="https://github.com/AVIDS2/memorix/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/AVIDS2/memorix/ci.yml?style=flat-square&label=CI" alt="CI"></a>
17
+ <a href="https://github.com/AVIDS2/memorix"><img src="https://img.shields.io/github/stars/AVIDS2/memorix?style=flat-square&color=yellow" alt="stars"></a>
18
+ </p>
19
+
20
+ <p align="center">
21
+ <strong>三层记忆</strong> | <strong>团队协作</strong> | <strong>工作区同步</strong> | <strong>多 Agent 编排</strong> | <strong>Dashboard</strong>
22
+ </p>
23
+
24
+ <p align="center">
25
+ <a href="README.md">English</a> |
26
+ <a href="#快速开始">快速开始</a> |
27
+ <a href="#docker">Docker</a> |
28
+ <a href="#支持的客户端">支持的客户端</a> |
29
+ <a href="#常用工作流">常用工作流</a> |
30
+ <a href="#文档导航">文档导航</a> |
31
+ <a href="docs/SETUP.md">安装与接入</a>
32
+ </p>
33
+
34
+ ---
35
+
36
+ > 如果你是通过 Cursor、Windsurf、Claude Code、Codex 或其他 AI coding agent 来操作 Memorix,请先读 [Agent Operator Playbook](docs/AGENT_OPERATOR_PLAYBOOK.md)。那份文档是面向 agent 的安装、MCP、hook 和排障手册。
37
+
38
+ ## Memorix 是什么?
39
+
40
+ **Memorix 是一个面向 Coding Agent 的、本地优先的记忆控制面。**
41
+
42
+ 它把项目记忆、推理上下文、Git 导出的工程事实,以及可选的自主 Agent Team 状态放在同一套本地系统里,让你可以在 IDE、终端、不同 session 和自主 agent 运行之间持续推进同一个项目,而不丢失项目真相。
43
+
44
+ 对大多数用户来说,默认路径其实很简单:直接用本地 TUI/CLI,或者把一个 IDE 通过 stdio MCP 接进来。HTTP 更适合作为你主动启用的共享控制面模式,用在长驻后台服务、多个客户端共享 MCP、或需要 live dashboard endpoint 的场景里。
45
+
46
+ ## 为什么选择 Memorix
47
+
48
+ 大多数 Coding Agent 只记得当前线程。Memorix 提供的是一层共享、持久、可检索的项目记忆,让不同 IDE、不同 Agent、不同会话都能在同一套本地记忆库上继续工作。
49
+
50
+ <table>
51
+ <tr><td><b>🧠 三层记忆</b></td><td>Observation(what/how)、Reasoning(why/权衡)、Git Memory(不可变 commit 事实 + 噪音过滤)</td></tr>
52
+ <tr><td><b>🔍 Source-Aware 检索</b></td><td>"改了什么"倾向 Git Memory;"为什么"倾向推理记忆;默认项目作用域,可切全局</td></tr>
53
+ <tr><td><b>⚙️ 记忆质量管线</b></td><td>Formation(LLM 评估)、去重、合并、保留衰减——记忆保持干净,不会越积越噪</td></tr>
54
+ <tr><td><b>🔄 工作区 & 规则同步</b></td><td>一条命令迁移 MCP 配置、工作流、规则、技能到 Cursor/Windsurf/Claude Code/Codex/Copilot/Kiro 等</td></tr>
55
+ <tr><td><b>👥 Agent Team</b></td><td>面向自主 CLI Agent 的显式状态:任务板(角色认领)、Agent 间消息、文件锁、态势感知 poll</td></tr>
56
+ <tr><td><b>🤖 Agent 编排</b></td><td><code>memorix orchestrate</code> 运行结构化协作循环——计划→并行执行→验证→修复→审查——带能力路由和 worktree 隔离</td></tr>
57
+ <tr><td><b>📋 Session 生命周期</b></td><td>Session start/end + 交接摘要、水位线追踪(上次以来的新记忆)、跨 session 上下文恢复</td></tr>
58
+ <tr><td><b>🎯 项目技能</b></td><td>从记忆模式自动生成 SKILL.md;将观察提升为永久 mini-skill,session 启动时自动注入</td></tr>
59
+ <tr><td><b>📊 Dashboard</b></td><td>本地 Web UI:浏览记忆、Git 历史、会话,以及只读自主 Agent Team 状态</td></tr>
60
+ <tr><td><b>🔒 本地 & 私有</b></td><td>SQLite 为权威存储、Orama 为检索引擎、无云依赖——一切留在你的机器上</td></tr>
61
+ </table>
62
+
63
+ ## 支持的客户端
64
+
65
+ | 层级 | 客户端 |
66
+ |------|---------|
67
+ | ★ 核心 | Claude Code, Cursor, Windsurf |
68
+ | 扩展 | GitHub Copilot, Kiro, Codex |
69
+ | ○ 社区 | Gemini CLI, OpenCode, Antigravity, Trae |
70
+
71
+ **核心** = 完整 hook 集成 + 测试过的 MCP + 规则同步。**扩展** = hook 集成但有平台限制。**社区** = 尽力适配,兼容性由社区反馈。
72
+
73
+ 如果某个客户端能通过 MCP 连接本地命令或 HTTP 端点,通常也可以接入 Memorix,即使它暂时不在上面的列表里。
74
+
75
+ ---
76
+
77
+ ## 快速开始
78
+
79
+ 全局安装:
80
+
81
+ ```bash
82
+ npm install -g memorix
83
+ ```
84
+
85
+ 初始化 Memorix 配置:
86
+
87
+ ```bash
88
+ memorix init
89
+ ```
90
+
91
+ `memorix init` 会让你在 `Global defaults` 和 `Project config` 之间选择作用域。
92
+
93
+ Memorix 使用两类文件:
94
+
95
+ - `memorix.yml`:行为配置和项目设置
96
+ - `.env`:API key 等 secrets
97
+
98
+ 然后按你的目标选择一条最顺手的路径:
99
+
100
+ | 你想做什么 | 运行命令 | 适合场景 |
101
+ | --- | --- | --- |
102
+ | 交互式终端工作台 | `memorix` | 默认起手式:本地搜索、聊天、记忆录入、诊断都在一个全屏 TUI 里完成 |
103
+ | 先把 Memorix 快速接到一个 IDE 里 | `memorix serve` | 默认 MCP 路径,适合 Cursor、Claude Code、Codex、Windsurf、Gemini CLI 等 stdio 客户端 |
104
+ | 在后台长期运行 HTTP MCP + Dashboard | `memorix background start` | 当你明确需要共享控制面、多个客户端 MCP 或 live dashboard endpoint 时再启用 |
105
+ | 把 HTTP 模式放在前台调试或自定义端口 | `memorix serve-http --port 3211` | 调试、手动观察日志、自定义启动方式 |
106
+
107
+ 对大多数用户来说,选上面前两条之一就够了。只有在你明确想要共享后台服务、多客户端 MCP 或 live dashboard endpoint 时,再切到 HTTP。
108
+
109
+ 常见路径:
110
+
111
+ | 目标 | 使用 | 原因 |
112
+ | --- | --- | --- |
113
+ | 在终端里直接操作 | `memorix` 或 `memorix <command>` | CLI/TUI 是主要产品入口。 |
114
+ | 通过 MCP 接入 IDE 或 Coding Agent | 优先 `memorix serve`;需要时再用 HTTP + `memorix_session_start` | 启动轻量记忆会话;默认不加入 Agent Team。 |
115
+ | 运行自主多 Agent 执行 | `memorix orchestrate` | 结构化计划→启动→验证→修复→审查循环。 |
116
+ | 在浏览器里观察项目记忆和 Agent Team 状态 | `memorix dashboard` | 独立只读 Dashboard,展示记忆、会话和自主 Agent Team 状态。 |
117
+
118
+ 配套命令:`memorix background status|logs|stop`。多工作区 HTTP session 需用 `memorix_session_start(projectRoot=...)` 绑定。
119
+
120
+ 更细的启动根路径选择、项目绑定、配置优先级和 agent 操作说明:[docs/SETUP.md](docs/SETUP.md) 和 [Agent Operator Playbook](docs/AGENT_OPERATOR_PLAYBOOK.md)。
121
+
122
+ ### TUI 工作台
123
+
124
+ ![Memorix TUI Workbench](https://raw.githubusercontent.com/AVIDS2/memorix/main/assets/readme-tui-workbench.png)
125
+
126
+ 在终端中直接运行 `memorix`(不带参数)即可打开交互式全屏 TUI(需要 TTY)。它适合用于项目记忆问答、搜索、快速存储、诊断、后台服务控制、Dashboard 打开和 IDE 配置。进入 TUI 后用 `/help` 查看当前命令列表。
127
+
128
+ 单次聊天(不进 TUI):`memorix ask "your question"`。
129
+
130
+ ### Operator CLI
131
+
132
+ Memorix 提供了一套 **CLI-first operator 命令面**。当你想直接在终端里检查或控制当前项目时使用。MCP 继续作为 IDE 和 Agent 的集成协议层。
133
+
134
+ ```bash
135
+ memorix session start --agent codex-main --agentType codex
136
+ memorix memory search --query "docker control plane"
137
+ memorix reasoning search --query "why sqlite"
138
+ memorix retention status
139
+ memorix team status
140
+ memorix task list
141
+ memorix audit project
142
+ memorix sync workspace --action scan
143
+ ```
144
+
145
+ 这组 CLI 故意做成**任务导向**的命名空间,而不是把 MCP 工具名原样搬出来。原生能力可以通过这些命名空间进入:`session`、`memory`、`reasoning`、`retention`、`formation`、`audit`、`transfer`、`skills`、`team`、`task`、`message`、`lock`、`handoff`、`poll`、`sync`、`ingest`。MCP 继续保留为 IDE、Agent 和可选 graph-compatibility 工具的接入层。
146
+
147
+ ## Docker
148
+
149
+ Memorix 现在包含了面向 **HTTP control plane** 的官方 Docker 部署路径。
150
+
151
+ 快速启动:
152
+
153
+ ```bash
154
+ docker compose up --build -d
155
+ ```
156
+
157
+ 启动后可访问:
158
+
159
+ - Dashboard:`http://localhost:3211`
160
+ - MCP:`http://localhost:3211/mcp`
161
+ - 健康检查:`http://localhost:3211/health`
162
+
163
+ 需要注意:Docker 支持的是 `serve-http`,不是 `memorix serve`。如果容器看不到你要绑定的仓库路径,那么项目级 Git / 配置语义不会完整生效。
164
+
165
+ 完整 Docker 指南:[docs/DOCKER.md](docs/DOCKER.md)
166
+
167
+ Memorix 添加到你的 MCP 客户端:
168
+
169
+ ### 通用 stdio MCP 配置
170
+
171
+ ```json
172
+ {
173
+ "mcpServers": {
174
+ "memorix": {
175
+ "command": "memorix",
176
+ "args": ["serve"]
177
+ }
178
+ }
179
+ }
180
+ ```
181
+
182
+ ### 通用 HTTP MCP 配置
183
+
184
+ ```json
185
+ {
186
+ "mcpServers": {
187
+ "memorix": {
188
+ "transport": "http",
189
+ "url": "http://localhost:3211/mcp"
190
+ }
191
+ }
192
+ }
193
+ ```
194
+
195
+ 下面这些客户端示例展示的是最简单的 stdio 形态。如果你更想使用共享的 HTTP control plane,请沿用上面的通用 HTTP 配置块,并到 [docs/SETUP.md](docs/SETUP.md) 查看各客户端字段差异。
196
+
197
+ <details open>
198
+ <summary><strong>Cursor</strong> | <code>.cursor/mcp.json</code></summary>
199
+
200
+ ```json
201
+ {
202
+ "mcpServers": {
203
+ "memorix": {
204
+ "command": "memorix",
205
+ "args": ["serve"]
206
+ }
207
+ }
208
+ }
209
+ ```
210
+ </details>
211
+
212
+ <details>
213
+ <summary><strong>Claude Code</strong></summary>
214
+
215
+ ```bash
216
+ claude mcp add memorix -- memorix serve
217
+ ```
218
+ </details>
219
+
220
+ <details>
221
+ <summary><strong>Codex</strong> | <code>~/.codex/config.toml</code></summary>
222
+
223
+ ```toml
224
+ [mcp_servers.memorix]
225
+ command = "memorix"
226
+ args = ["serve"]
227
+ ```
228
+ </details>
229
+
230
+ 完整 IDE 配置矩阵、Windows 注意事项和排障说明见 [docs/SETUP.md](docs/SETUP.md)。
231
+
232
+ ---
233
+
234
+ ## 常用工作流
235
+
236
+ | 你想做什么 | 使用方式 | 详细说明 |
237
+ | --- | --- | --- |
238
+ | 保存和检索项目记忆 | `memorix memory store/search/detail/resolve` 或 MCP `memorix_store/search/detail/resolve` | [API Reference](docs/API_REFERENCE.md#3-core-memory-tools) |
239
+ | 捕获 Git 真相 | `memorix git-hook --force`、`memorix ingest commit`、`memorix ingest log` | [Git Memory Guide](docs/GIT_MEMORY.md) |
240
+ | 运行 Dashboard + HTTP MCP | `memorix background start` | [Setup Guide](docs/SETUP.md)、[Docker](docs/DOCKER.md) |
241
+ | 保持记忆会话轻量 | `memorix_session_start(projectRoot=...)` 或 `memorix session start` | [Agent Operator Playbook](docs/AGENT_OPERATOR_PLAYBOOK.md#8-what-an-agent-should-do-at-session-start) |
242
+ | 显式加入 Agent 团队 | `memorix session start --joinTeam` 或 `memorix team join` | [TEAM.md](TEAM.md)、[API Reference](docs/API_REFERENCE.md#9-agent-team-tools) |
243
+ | 运行自主多 Agent 工作 | `memorix orchestrate --goal "..."` | [API Reference](docs/API_REFERENCE.md) |
244
+ | 同步 Agent 配置/规则 | `memorix sync workspace ...`、`memorix sync rules ...` | [Setup Guide](docs/SETUP.md) |
245
+ | 在代码里直接调用 | `import { createMemoryClient } from 'memorix/sdk'` | [API Reference](docs/API_REFERENCE.md) |
246
+
247
+ 最常见的循环故意保持很小:
248
+
249
+ ```bash
250
+ memorix memory store --text "Auth tokens expire after 24h" --title "Auth token TTL" --entity auth --type decision
251
+ memorix memory search --query "auth token ttl"
252
+ memorix session start --agent codex-main --agentType codex
253
+ ```
254
+
255
+ 当多个 HTTP session 同时存在时,每个 session 都应先用 `memorix_session_start(projectRoot=...)` 显式绑定当前工作区,再去调用项目级记忆工具。
256
+
257
+ HTTP MCP session 默认 30 分钟空闲后过期。如果你的客户端不会自动从陈旧 HTTP session ID 中恢复,可以在启动控制面前设置更长超时:
258
+
259
+ ```bash
260
+ MEMORIX_SESSION_TIMEOUT_MS=86400000 memorix background start # 24h
261
+ ```
262
+
263
+ Team 协作**不是**普通记忆启动路径,也**不是**多个 IDE 对话窗口之间的聊天室。只有需要任务、消息、文件锁,或结构化自主 Agent 工作流时,才加入 team。真正的多 Agent 执行优先使用:
264
+
265
+ ```bash
266
+ memorix orchestrate --goal "Add user authentication" --agents claude-code,cursor,codex
267
+ ```
268
+
269
+ ## 资源占用
270
+
271
+ Memorix 的普通记忆路径设计为轻量运行:
272
+
273
+ - stdio MCP 按需启动,随客户端退出
274
+ - HTTP background 模式是一个本地 Node 进程,加 SQLite/Orama 状态
275
+ - LLM enrichment 是可选能力;没有 API key 时会回退到本地启发式去重和检索
276
+ - 更重的路径主要是 build/test、Docker 镜像构建、Dashboard 浏览、大批量导入和可选 LLM-backed formation
277
+
278
+ 在这台 Windows 开发机上,健康的 HTTP 控制面空闲数小时后观测到约 16 MB working set。这只是本机观测值,不是跨平台承诺。更多旋钮和取舍见 [Performance and Resource Notes](docs/PERFORMANCE.md)。
279
+
280
+ ## 编程 SDK
281
+
282
+ 直接在你自己的 TypeScript/Node.js 项目中 import Memorix —— 无需 MCP 或 CLI:
283
+
284
+ ```ts
285
+ import { createMemoryClient } from 'memorix/sdk';
286
+
287
+ const client = await createMemoryClient({ projectRoot: '/path/to/repo' });
288
+
289
+ // 存储记忆
290
+ await client.store({
291
+ entityName: 'auth-module',
292
+ type: 'decision',
293
+ title: 'Use JWT for API auth',
294
+ narrative: 'Chose JWT over session cookies for stateless API.',
295
+ });
296
+
297
+ // 搜索
298
+ const results = await client.search({ query: 'authentication' });
299
+
300
+ // 查询、归档、计数
301
+ const obs = await client.get(1);
302
+ const all = await client.getAll();
303
+ await client.resolve([1, 2]);
304
+
305
+ await client.close();
306
+ ```
307
+
308
+ 三个子路径导出:
309
+
310
+ | Import | 内容 |
311
+ | --- | --- |
312
+ | `memorix/sdk` | `createMemoryClient`、`createMemorixServer`、`detectProject`、全部类型 |
313
+ | `memorix/types` | 纯类型 —— interface、enum、常量 |
314
+ | `memorix` | MCP stdio 入口(不适合编程使用) |
315
+
316
+ ---
317
+
277
318
  ## 工作原理
278
319
 
279
320
  ```mermaid
280
321
  flowchart LR
281
- subgraph Ingress["入口层"]
282
- A1["Git hooks / ingest"]
283
- A2["MCP tools"]
284
- A3["CLI / TUI"]
285
- A4["HTTP dashboard"]
322
+ subgraph ING["接入入口"]
323
+ A["Git Hooks<br/>commit + ingest"]
324
+ B["MCP Tools<br/>search, store, recall"]
325
+ C["CLI / TUI<br/>operator workflows"]
326
+ D["Dashboard<br/>read-mostly project view"]
286
327
  end
287
328
 
288
- subgraph Runtime["Memorix Runtime"]
289
- B1["stdio MCP server"]
290
- B2["HTTP control plane"]
291
- B3["project binding + config"]
329
+ subgraph RUN["运行时"]
330
+ E["stdio MCP Server<br/>memorix serve"]
331
+ F["HTTP Control Plane<br/>background / serve-http"]
332
+ G["项目绑定<br/>git root + config"]
292
333
  end
293
334
 
294
- subgraph Memory["记忆基底"]
295
- C1["Observation memory"]
296
- C2["Reasoning memory"]
297
- C3["Git memory"]
298
- C4["Session + team state"]
335
+ subgraph MEM["记忆层"]
336
+ H["Observation<br/>事实、坑点、修复"]
337
+ I["Reasoning<br/>原因、权衡、风险"]
338
+ J["Git Memory<br/>commit-derived ground truth"]
339
+ K["Session + Agent Team<br/>显式加入的任务、锁、交接"]
299
340
  end
300
341
 
301
- subgraph Processing["异步处理"]
302
- D1["Formation pipeline"]
303
- D2["Embedding + indexing"]
304
- D3["Graph linking"]
305
- D4["Dedup + retention"]
342
+ subgraph PROC["处理层"]
343
+ L["Formation<br/>质量整理"]
344
+ M["Embedding + Index<br/>混合检索"]
345
+ N["Graph Linking<br/>实体关系"]
346
+ O["Dedup + Retention<br/>长期收敛"]
306
347
  end
307
348
 
308
- subgraph Consumption["消费面"]
309
- E1["Search / detail / timeline"]
310
- E2["Dashboard / team views"]
311
- E3["Agent recall / handoff"]
349
+ subgraph USE["使用面"]
350
+ P["Search / Timeline / Detail"]
351
+ Q["Dashboard / Agent Team View<br/>只读为主的状态面板"]
352
+ R["Recall / Handoff / Resume"]
353
+ S["Skills / Sync / Orchestrate"]
312
354
  end
313
355
 
314
- A1 --> B1
315
- A2 --> B1
316
- A2 --> B2
317
- A3 --> B1
318
- A3 --> B2
319
- A4 --> B2
320
-
321
- B1 --> B3
322
- B2 --> B3
323
-
324
- B3 --> C1
325
- B3 --> C2
326
- B3 --> C3
327
- B3 --> C4
328
-
329
- C1 --> D1
330
- C1 --> D2
331
- C1 --> D3
332
- C1 --> D4
333
- C2 --> D1
334
- C2 --> D3
335
- C3 --> D2
336
- C4 --> D3
337
-
338
- D1 --> E1
339
- D2 --> E1
340
- D3 --> E2
341
- D4 --> E3
342
- C4 --> E3
356
+ A --> E
357
+ B --> E
358
+ C --> E
359
+ D --> F
360
+
361
+ E --> G
362
+ F --> G
363
+
364
+ G --> H
365
+ G --> I
366
+ G --> J
367
+ G --> K
368
+
369
+ H --> L
370
+ H --> M
371
+ I --> L
372
+ I --> N
373
+ J --> M
374
+ J --> N
375
+ K --> O
376
+
377
+ H --> P
378
+ I --> P
379
+ J --> P
380
+ K --> Q
381
+ H --> R
382
+ I --> R
383
+ J --> R
384
+ K --> S
343
385
  ```
344
386
 
345
387
  Memorix 不是一条单线流水线。它从多个入口接收记忆,把内容落到多种记忆基底上,经过异步质量与索引处理,再通过不同的检索和协作界面提供给用户与 agent。
346
-
347
- ### 记忆层
348
-
349
- - **Observation Memory**:记录“改了什么 / 系统怎么工作 / 踩过什么坑”
350
- - **Reasoning Memory**:记录“为什么这么做 / 替代方案 / 权衡 / 风险”
351
- - **Git Memory**:记录从提交中提炼出的工程事实
352
-
353
- ### 检索模型
354
-
355
- - 默认搜索是**当前项目作用域**
356
- - `scope="global"` 可以跨项目搜索
357
- - 全局结果可通过带项目信息的 ref 再展开
358
- - source-aware retrieval 会对“发生了什么”问题偏向 Git Memory,对“为什么”问题偏向 reasoning memory
359
-
360
- ---
361
-
362
- ## 文档导航
363
-
364
- ### 入门
365
-
366
- - [Setup Guide](docs/SETUP.md)
367
- - [Configuration Guide](docs/CONFIGURATION.md)
368
-
369
- ### 产品与架构
370
-
371
- - [Architecture](docs/ARCHITECTURE.md)
372
- - [Memory Formation Pipeline](docs/MEMORY_FORMATION_PIPELINE.md)
373
- - [Design Decisions](docs/DESIGN_DECISIONS.md)
374
-
375
- ### 参考资料
376
-
377
- - [API Reference](docs/API_REFERENCE.md)
378
- - [Git Memory Guide](docs/GIT_MEMORY.md)
379
- - [Modules](docs/MODULES.md)
380
-
381
- ### 开发
382
-
383
- - [Development Guide](docs/DEVELOPMENT.md)
384
- - [Known Issues and Roadmap](docs/KNOWN_ISSUES_AND_ROADMAP.md)
385
-
386
- ### AI / Agent 文档
387
-
388
- - [Agent Operator Playbook](docs/AGENT_OPERATOR_PLAYBOOK.md)
389
- - [AI Context Note](docs/AI_CONTEXT.md)
390
- - [`llms.txt`](llms.txt)
391
- - [`llms-full.txt`](llms-full.txt)
392
-
393
- ---
394
-
395
- ## 开发
396
-
397
- ```bash
398
- git clone https://github.com/AVIDS2/memorix.git
399
- cd memorix
400
- npm install
401
-
402
- npm run dev
403
- npm test
404
- npm run build
405
- ```
406
-
407
- 常用本地命令:
408
-
409
- ```bash
410
- memorix status
411
- memorix dashboard
412
- memorix background start
413
- memorix serve-http --port 3211
414
- memorix git-hook --force
415
- ```
416
-
417
- ---
418
-
419
- ## 鸣谢
420
-
421
- Memorix 借鉴了 [mcp-memory-service](https://github.com/doobidoo/mcp-memory-service)、[MemCP](https://github.com/maydali28/memcp)、[claude-mem](https://github.com/anthropics/claude-code)、[Mem0](https://github.com/mem0ai/mem0) 和整个 MCP 生态中的许多思路。
422
-
423
- ## Star 历史
424
-
425
- <a href="https://star-history.com/#AVIDS2/memorix&Date">
426
- <picture>
427
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=AVIDS2/memorix&type=Date&theme=dark" />
428
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=AVIDS2/memorix&type=Date" />
429
- <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=AVIDS2/memorix&type=Date" width="600" />
430
- </picture>
431
- </a>
432
-
433
- ## License
434
-
435
- [Apache 2.0](LICENSE)
388
+
389
+ ### 记忆层
390
+
391
+ - **Observation Memory**:记录"改了什么 / 系统怎么工作 / 踩过什么坑"
392
+ - **Reasoning Memory**:记录"为什么这么做 / 替代方案 / 权衡 / 风险"
393
+ - **Git Memory**:记录从提交中提炼出的不可变工程事实
394
+
395
+ ### 检索模型
396
+
397
+ - 默认搜索是**当前项目作用域**
398
+ - `scope="global"` 可以跨项目搜索
399
+ - 全局结果可通过带项目信息的 ref 再展开
400
+ - source-aware retrieval 会对"发生了什么"问题偏向 Git Memory,对"为什么"问题偏向 reasoning memory
401
+
402
+ ---
403
+
404
+ ## 文档导航
405
+
406
+ 📖 **[文档地图](docs/README.md)** — 最快找到你需要的文档。
407
+
408
+ | 章节 | 内容 |
409
+ | --- | --- |
410
+ | [安装与接入](docs/SETUP.md) | 安装、stdio vs HTTP control plane、各客户端配置 |
411
+ | [Docker 部署](docs/DOCKER.md) | 官方容器路径、compose、healthcheck 和路径注意事项 |
412
+ | [性能与资源](docs/PERFORMANCE.md) | 资源画像、空闲/运行时成本、优化旋钮 |
413
+ | [配置指南](docs/CONFIGURATION.md) | `memorix.yml`、`.env`、项目覆盖 |
414
+ | [Agent Operator Playbook](docs/AGENT_OPERATOR_PLAYBOOK.md) | AI 面向的正式操作手册:安装、绑定、hooks、排障 |
415
+ | [架构](docs/ARCHITECTURE.md) | 系统形态、记忆层、数据流、模块图 |
416
+ | [API 参考](docs/API_REFERENCE.md) | MCP / HTTP / CLI 命令面 |
417
+ | [Git Memory 指南](docs/GIT_MEMORY.md) | 摄入、噪音过滤、检索语义 |
418
+ | [开发指南](docs/DEVELOPMENT.md) | 贡献者工作流、构建、测试、发布 |
419
+
420
+ 更多深度参考:
421
+
422
+ - [Memory Formation Pipeline](docs/MEMORY_FORMATION_PIPELINE.md)
423
+ - [Design Decisions](docs/DESIGN_DECISIONS.md)
424
+ - [Modules](docs/MODULES.md)
425
+ - [Known Issues and Roadmap](docs/KNOWN_ISSUES_AND_ROADMAP.md)
426
+ - [AI Context Note](docs/AI_CONTEXT.md)
427
+ - [`llms.txt`](llms.txt)
428
+ - [`llms-full.txt`](llms-full.txt)
429
+
430
+ ---
431
+
432
+ ## 1.0.8 更新亮点
433
+
434
+ `1.0.8` 在 1.0.7 的多 Agent 协调 / SQLite / 团队身份基线上,进一步收成了 CLI-first operator surface、官方 Docker 路径、Dashboard 语义分层和大量 Hooks 修复。
435
+
436
+ - **CLI-First 产品面**:所有 Memorix 原生能力都已经有面向人的 CLI 路径 — `session`、`memory`、`reasoning`、`retention`、`formation`、`audit`、`transfer`、`skills`、`team`、`task`、`message`、`lock`、`handoff`、`poll`、`sync`、`ingest`。MCP 保留为标准接入协议和可选 graph-compatibility 层。
437
+ - **Docker 部署**:官方 `Dockerfile`、`compose.yaml`、健康检查、`--host` 绑定,详见 [DOCKER.md](docs/DOCKER.md)。
438
+ - **多 Agent 协调器**:`memorix orchestrate` 运行计划、并行执行、验证、修复、审查和合并循环。支持 Claude、Codex、Gemini CLI、OpenCode,含能力路由、worktree 隔离和 Agent 回退。
439
+ - **SQLite 统一存储**:Observation、mini-skill、session、archive 全部 SQLite。共享 DB 句柄,检索前自动刷新,已删除废弃的 `JsonBackend`。
440
+ - **显式协作空间**:任务板、消息、文件锁、交接产物和协作者心跳状态。`session_start` 默认保持轻量;只有 `joinTeam` 或 `team_manage join` 才会显式加入协作空间。
441
+ - **Dashboard 语义分层**:Team 页面过滤标签(Active / Recent / Historical);历史 Agent 降低显示权重;项目选择器按 真实 / 临时 / 占位 分组;Identity 页面优化。
442
+ - **Hooks 修复**:OpenCode 事件键映射 + `Bun.spawn` → `spawnSync`;Copilot `pwsh` 回退 + 全局 hooks 拦截;hook handler 诊断日志。
443
+ - **编程 SDK**:`import { createMemoryClient } from 'memorix/sdk'` 可直接在代码中 store / search / get / resolve,无需 MCP 或 CLI。同时导出 `createMemorixServer` 和 `detectProject`。
444
+ - **测试稳定化**:E2e 和 live-LLM 测试从默认套件中排除;负载敏感测试隔离运行,让默认验证路径保持确定。
445
+
446
+ ---
447
+
448
+ ## 开发
449
+
450
+ ```bash
451
+ git clone https://github.com/AVIDS2/memorix.git
452
+ cd memorix
453
+ npm install
454
+
455
+ npm run dev
456
+ npm test
457
+ npm run build
458
+ ```
459
+
460
+ 常用本地命令:
461
+
462
+ ```bash
463
+ memorix status
464
+ memorix dashboard
465
+ memorix background start
466
+ memorix serve-http --port 3211
467
+ memorix git-hook --force
468
+ ```
469
+
470
+ ---
471
+
472
+ ## 鸣谢
473
+
474
+ Memorix 借鉴了 [mcp-memory-service](https://github.com/doobidoo/mcp-memory-service)、[MemCP](https://github.com/maydali28/memcp)、[claude-mem](https://github.com/anthropics/claude-code)、[Mem0](https://github.com/mem0ai/mem0) 和整个 MCP 生态中的许多思路。
475
+
476
+ ## Star 历史
477
+
478
+ <a href="https://star-history.com/#AVIDS2/memorix&Date">
479
+ <picture>
480
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=AVIDS2/memorix&type=Date&theme=dark" />
481
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=AVIDS2/memorix&type=Date" />
482
+ <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=AVIDS2/memorix&type=Date" width="600" />
483
+ </picture>
484
+ </a>
485
+
486
+ ## License
487
+
488
+ [Apache 2.0](LICENSE)