dsh-mnemon 0.1.0

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.
Files changed (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +169 -0
  3. package/README.md +169 -0
  4. package/cordis.patch.yml +15 -0
  5. package/docs/README.md +8 -0
  6. package/docs/en/README.md +39 -0
  7. package/docs/en/architecture.md +129 -0
  8. package/docs/en/assets/project-architecture.svg +182 -0
  9. package/docs/en/configuration.md +204 -0
  10. package/docs/en/development.md +178 -0
  11. package/docs/en/getting-started.md +147 -0
  12. package/docs/en/interfaces.md +159 -0
  13. package/docs/en/operations.md +151 -0
  14. package/docs/en/project-overview.md +247 -0
  15. package/docs/en/roadmap.md +41 -0
  16. package/docs/en/storage-model.md +179 -0
  17. package/docs/en/workflows.md +290 -0
  18. package/docs/zh-CN/README.md +39 -0
  19. package/docs/zh-CN/architecture.md +129 -0
  20. package/docs/zh-CN/assets/project-architecture.svg +182 -0
  21. package/docs/zh-CN/assets/screenshots/conversation-recall.png +0 -0
  22. package/docs/zh-CN/assets/screenshots/conversation-writeback.png +0 -0
  23. package/docs/zh-CN/assets/screenshots/documents-markdown.png +0 -0
  24. package/docs/zh-CN/assets/screenshots/entities-context.png +0 -0
  25. package/docs/zh-CN/assets/screenshots/memory-content.png +0 -0
  26. package/docs/zh-CN/assets/screenshots/overview-memory-graph.png +0 -0
  27. package/docs/zh-CN/assets/screenshots/recall-agent-answer.png +0 -0
  28. package/docs/zh-CN/assets/screenshots/runtime-memory.png +0 -0
  29. package/docs/zh-CN/configuration.md +204 -0
  30. package/docs/zh-CN/development.md +178 -0
  31. package/docs/zh-CN/getting-started.md +147 -0
  32. package/docs/zh-CN/interfaces.md +159 -0
  33. package/docs/zh-CN/operations.md +151 -0
  34. package/docs/zh-CN/project-overview.md +247 -0
  35. package/docs/zh-CN/roadmap.md +41 -0
  36. package/docs/zh-CN/storage-model.md +179 -0
  37. package/docs/zh-CN/workflows.md +290 -0
  38. package/lib/client.js +6288 -0
  39. package/lib/client.js.map +1 -0
  40. package/lib/index.js +4453 -0
  41. package/lib/types/client/MnemonLogo.d.ts +7 -0
  42. package/lib/types/client/MnemonLogo.d.ts.map +1 -0
  43. package/lib/types/client/MnemonLogo.js +6 -0
  44. package/lib/types/client/MnemonLogo.js.map +1 -0
  45. package/lib/types/client/MnemonSettingsCard.d.ts +9 -0
  46. package/lib/types/client/MnemonSettingsCard.d.ts.map +1 -0
  47. package/lib/types/client/MnemonSettingsCard.js +109 -0
  48. package/lib/types/client/MnemonSettingsCard.js.map +1 -0
  49. package/lib/types/client/MnemonView.d.ts +11 -0
  50. package/lib/types/client/MnemonView.d.ts.map +1 -0
  51. package/lib/types/client/MnemonView.js +1239 -0
  52. package/lib/types/client/MnemonView.js.map +1 -0
  53. package/lib/types/client/api.d.ts +68 -0
  54. package/lib/types/client/api.d.ts.map +1 -0
  55. package/lib/types/client/api.js +80 -0
  56. package/lib/types/client/api.js.map +1 -0
  57. package/lib/types/client/index.d.ts +4 -0
  58. package/lib/types/client/index.d.ts.map +1 -0
  59. package/lib/types/client/index.js +36 -0
  60. package/lib/types/client/index.js.map +1 -0
  61. package/lib/types/client/locales.d.ts +1054 -0
  62. package/lib/types/client/locales.d.ts.map +1 -0
  63. package/lib/types/client/locales.js +1062 -0
  64. package/lib/types/client/locales.js.map +1 -0
  65. package/lib/types/client/settings.d.ts +17 -0
  66. package/lib/types/client/settings.d.ts.map +1 -0
  67. package/lib/types/client/settings.js +49 -0
  68. package/lib/types/client/settings.js.map +1 -0
  69. package/lib/types/commands.d.ts +6 -0
  70. package/lib/types/commands.d.ts.map +1 -0
  71. package/lib/types/commands.js +100 -0
  72. package/lib/types/commands.js.map +1 -0
  73. package/lib/types/config-values.d.ts +4 -0
  74. package/lib/types/config-values.d.ts.map +1 -0
  75. package/lib/types/config-values.js +4 -0
  76. package/lib/types/config-values.js.map +1 -0
  77. package/lib/types/config.d.ts +49 -0
  78. package/lib/types/config.d.ts.map +1 -0
  79. package/lib/types/config.js +55 -0
  80. package/lib/types/config.js.map +1 -0
  81. package/lib/types/contracts.d.ts +272 -0
  82. package/lib/types/contracts.d.ts.map +1 -0
  83. package/lib/types/contracts.js +2 -0
  84. package/lib/types/contracts.js.map +1 -0
  85. package/lib/types/documents.d.ts +149 -0
  86. package/lib/types/documents.d.ts.map +1 -0
  87. package/lib/types/documents.js +503 -0
  88. package/lib/types/documents.js.map +1 -0
  89. package/lib/types/guidance.d.ts +9 -0
  90. package/lib/types/guidance.d.ts.map +1 -0
  91. package/lib/types/guidance.js +18 -0
  92. package/lib/types/guidance.js.map +1 -0
  93. package/lib/types/index.d.ts +15 -0
  94. package/lib/types/index.d.ts.map +1 -0
  95. package/lib/types/index.js +45 -0
  96. package/lib/types/index.js.map +1 -0
  97. package/lib/types/lifecycle.d.ts +75 -0
  98. package/lib/types/lifecycle.d.ts.map +1 -0
  99. package/lib/types/lifecycle.js +380 -0
  100. package/lib/types/lifecycle.js.map +1 -0
  101. package/lib/types/memory-bodies.d.ts +47 -0
  102. package/lib/types/memory-bodies.d.ts.map +1 -0
  103. package/lib/types/memory-bodies.js +160 -0
  104. package/lib/types/memory-bodies.js.map +1 -0
  105. package/lib/types/process.d.ts +14 -0
  106. package/lib/types/process.d.ts.map +1 -0
  107. package/lib/types/process.js +65 -0
  108. package/lib/types/process.js.map +1 -0
  109. package/lib/types/review-activity.d.ts +33 -0
  110. package/lib/types/review-activity.d.ts.map +1 -0
  111. package/lib/types/review-activity.js +37 -0
  112. package/lib/types/review-activity.js.map +1 -0
  113. package/lib/types/rpc.d.ts +12 -0
  114. package/lib/types/rpc.d.ts.map +1 -0
  115. package/lib/types/rpc.js +225 -0
  116. package/lib/types/rpc.js.map +1 -0
  117. package/lib/types/runner.d.ts +29 -0
  118. package/lib/types/runner.d.ts.map +1 -0
  119. package/lib/types/runner.js +150 -0
  120. package/lib/types/runner.js.map +1 -0
  121. package/lib/types/runtime-memory.d.ts +104 -0
  122. package/lib/types/runtime-memory.d.ts.map +1 -0
  123. package/lib/types/runtime-memory.js +415 -0
  124. package/lib/types/runtime-memory.js.map +1 -0
  125. package/lib/types/service.d.ts +173 -0
  126. package/lib/types/service.d.ts.map +1 -0
  127. package/lib/types/service.js +508 -0
  128. package/lib/types/service.js.map +1 -0
  129. package/lib/types/settings.d.ts +6 -0
  130. package/lib/types/settings.d.ts.map +1 -0
  131. package/lib/types/settings.js +75 -0
  132. package/lib/types/settings.js.map +1 -0
  133. package/lib/types/storage-scope.d.ts +39 -0
  134. package/lib/types/storage-scope.d.ts.map +1 -0
  135. package/lib/types/storage-scope.js +179 -0
  136. package/lib/types/storage-scope.js.map +1 -0
  137. package/lib/types/subagent.d.ts +97 -0
  138. package/lib/types/subagent.d.ts.map +1 -0
  139. package/lib/types/subagent.js +619 -0
  140. package/lib/types/subagent.js.map +1 -0
  141. package/lib/types/tools.d.ts +8 -0
  142. package/lib/types/tools.d.ts.map +1 -0
  143. package/lib/types/tools.js +328 -0
  144. package/lib/types/tools.js.map +1 -0
  145. package/package.json +111 -0
@@ -0,0 +1,204 @@
1
+ # 配置参考
2
+
3
+ **简体中文** | [English](../en/configuration.md) | [文档中心](./README.md)
4
+
5
+ ## 配置位置与生效方式
6
+
7
+ 插件在 DSH settings 服务中注册 `mnemon` 命名空间。用户配置位于:
8
+
9
+ ```text
10
+ $DSH_HOME/settings.yaml
11
+ ```
12
+
13
+ 默认通常是 `~/.dsh/settings.yaml`。当前全部配置标记为 `restart` 生效;保存后需要重启 DSH Host。
14
+
15
+ Web 设置卡只编辑 `storageScope` 和 `dataDir`。其他高级项需要直接修改 YAML。
16
+
17
+ ## 完整示例
18
+
19
+ ```yaml
20
+ mnemon:
21
+ storageScope: global # global | workspace | custom
22
+ # dataDir: ~/mnemon-data # custom 时必填
23
+ # cliPath: /opt/homebrew/bin/mnemon
24
+ # store: legacy-store # 兼容发现提示,不是常规路由目标
25
+ timeoutMs: 10000
26
+ defaultRecallLimit: 10
27
+ routingGuidance: true
28
+ lifecycleEnabled: true
29
+ recallMode: guided
30
+ writebackMode: guided
31
+ idleReviewMs: 30000
32
+ tabEnabled: true
33
+ writeEnabled: true
34
+ ```
35
+
36
+ ## 选项
37
+
38
+ | 配置 | 默认值 | 范围 | 实现语义 |
39
+ |---|---:|---|---|
40
+ | `storageScope` | `global` | `global` / `workspace` / `custom` | 统一控制 Runtime、Documents、Memory Spaces 和预留 state 根目录 |
41
+ | `dataDir` | 未设置 | 绝对路径、`~` 或 `~/...` | `custom` 时必填;旧配置只设置它时自动解析为 `custom` |
42
+ | `cliPath` | 自动发现 | 可执行路径 | 显式指定 Mnemon CLI |
43
+ | `store` | 未设置 | `[A-Za-z0-9][A-Za-z0-9_-]*` | 用于旧 Store 的兼容发现/首选提示;语义操作由 Memory Space 路由 |
44
+ | `timeoutMs` | `10000` | 100–120000 ms | 单次 CLI 硬超时 |
45
+ | `defaultRecallLimit` | `10` | 1–50 | 服务和 UI 默认召回条数;不同入口可能再收紧 |
46
+ | `routingGuidance` | `true` | boolean | 是否注册额外的分层路由 system section |
47
+ | `lifecycleEnabled` | `true` | boolean | 是否启用 pre-step cue 和评分后台审查 |
48
+ | `recallMode` | `guided` | `guided` / `off` | 是否注入按需 recall cue;不移除显式召回 |
49
+ | `writebackMode` | `guided` | `guided` / `off` | 是否注入热记忆 cue 并启用评分后台审查;不移除显式写入 |
50
+ | `idleReviewMs` | `30000` | 5000–600000 ms | 达标后需要连续空闲的时间 |
51
+ | `tabEnabled` | `true` | boolean | 当前只门控 Host Mnemon 数据 RPC;客户端 Tab 仍会注册,见下方限制 |
52
+ | `writeEnabled` | `true` | boolean | 是否暴露语义写工具、写 RPC 和写命令 |
53
+
54
+ ## 存储范围
55
+
56
+ ### `global`
57
+
58
+ ```text
59
+ MNEMON_DATA_DIR when non-empty
60
+ otherwise ~/.mnemon
61
+ ```
62
+
63
+ 适合希望多个工作区共享 Runtime、Documents 和 Memory Spaces 的用户。
64
+
65
+ ### `workspace`
66
+
67
+ ```text
68
+ resolve(process.cwd(), ".mnemon")
69
+ ```
70
+
71
+ 这里的 cwd 是 DSH Host 进程启动目录,不是浏览器页面当前目录,也不一定等于每个会话记录的 cwd。应从目标项目目录启动 DSH。
72
+
73
+ ### `custom`
74
+
75
+ ```yaml
76
+ mnemon:
77
+ storageScope: custom
78
+ dataDir: /absolute/path/to/mnemon-data
79
+ ```
80
+
81
+ 也允许 `~` 和 `~/...`。相对路径会被拒绝。
82
+
83
+ ## CLI 发现优先级
84
+
85
+ ```text
86
+ config.cliPath
87
+ -> executable MNEMON_CLI_PATH
88
+ -> each PATH directory
89
+ -> ~/.local/bin/mnemon
90
+ -> /opt/homebrew/bin/mnemon
91
+ -> /usr/local/bin/mnemon
92
+ -> /usr/bin/mnemon
93
+ ```
94
+
95
+ 显式 `cliPath` 会被采用;若它不可执行,实际调用会返回启动错误。
96
+
97
+ ## 兼容 Store 提示优先级
98
+
99
+ ```text
100
+ config.store
101
+ -> MNEMON_STORE
102
+ -> <storageRoot>/active
103
+ -> default
104
+ ```
105
+
106
+ Memory Space 目录建立后,长期语义操作使用明确的记忆体 ID,不依赖全局 active Store 进行路由。
107
+
108
+ ## Provider 要求
109
+
110
+ 普通 worker 会优先选择 `spawn`;如果没有该名称,可以选择另一个具备全部能力的 provider:
111
+
112
+ ```text
113
+ outputSchema = true
114
+ toolFilter = true
115
+ persona = true
116
+ depthLimit = true
117
+ ```
118
+
119
+ 后台审查没有回退:必须存在名为 `fork` 的兼容 provider,并且:
120
+
121
+ ```text
122
+ inheritsParentContext = true
123
+ ```
124
+
125
+ 缺少 `fork` 不会阻止确定性状态或普通 UI 读取,但达到审查门槛时会记录 subagent 失败。
126
+
127
+ ## 只读配置
128
+
129
+ ```yaml
130
+ mnemon:
131
+ writeEnabled: false
132
+ ```
133
+
134
+ 效果:
135
+
136
+ - 不注册模型写工具;
137
+ - 不注册 `/dsh-mnemon-write` RPC;
138
+ - `/mnemon remember` 和 `/mnemon forget` 拒绝;
139
+ - `MnemonService` 的语义 mutation 拒绝。
140
+
141
+ 它是“功能只读”,不是文件系统只读模式:Runtime 控制器仍可能初始化或修复投影,Document 搜索会更新 LRU 访问时间,Mnemon 读命令也可能触发上游数据库迁移。不要把 `writeEnabled=false` 用作只读挂载的安全承诺。
142
+
143
+ ## 开关交互
144
+
145
+ ```text
146
+ writeEnabled=false
147
+ -> overrides all explicit semantic writes
148
+
149
+ writebackMode=off
150
+ -> no write cue, no scored review
151
+ -> explicit writes remain when writeEnabled=true
152
+
153
+ recallMode=off
154
+ -> no recall cue
155
+ -> explicit recall remains
156
+
157
+ lifecycleEnabled=false
158
+ -> no lifecycle cues or review
159
+ -> UI, commands, and explicit tools remain
160
+
161
+ routingGuidance=false
162
+ -> removes only mnemon:routing
163
+ -> runtime-memory prompt section remains
164
+ ```
165
+
166
+ ## `tabEnabled` 当前限制
167
+
168
+ Host 在 `tabEnabled=false` 时不注册 Mnemon read/write RPC,但 Web client 仍无条件注册 conversation view slot。因此当前效果是“Tab 入口仍可能出现但数据接口不可用”,而不是完整隐藏 Tab。这是实现缺口,不应依赖它进行 UI 卸载。
169
+
170
+ ## Profile patch 覆盖
171
+
172
+ 包内 `cordis.patch.yml` 提供默认 config 行。DSH profile 的同 ID 配置可能整体覆盖这行;自定义 patch 时应保留仍需启用的键,而不是假设深合并。
173
+
174
+ ## 常见配置
175
+
176
+ 工作区隔离:
177
+
178
+ ```yaml
179
+ mnemon:
180
+ storageScope: workspace
181
+ ```
182
+
183
+ 自定义数据盘和较长 CLI 超时:
184
+
185
+ ```yaml
186
+ mnemon:
187
+ storageScope: custom
188
+ dataDir: /Volumes/AgentData/mnemon
189
+ timeoutMs: 30000
190
+ ```
191
+
192
+ 保留显式工具、关闭生命周期行为:
193
+
194
+ ```yaml
195
+ mnemon:
196
+ lifecycleEnabled: false
197
+ ```
198
+
199
+ 仅关闭后台写回判断:
200
+
201
+ ```yaml
202
+ mnemon:
203
+ writebackMode: off
204
+ ```
@@ -0,0 +1,178 @@
1
+ # 开发与验证
2
+
3
+ **简体中文** | [English](../en/development.md) | [文档中心](./README.md)
4
+
5
+ ## 环境
6
+
7
+ 仓库没有在 `package.json` 中声明 Node、pnpm、DSH 或 Mnemon 的最低版本。使用当前 DSH 开发环境,并在升级依赖时通过完整验证链路确认兼容性。
8
+
9
+ 安装依赖:
10
+
11
+ ```sh
12
+ pnpm install
13
+ ```
14
+
15
+ ## 标准命令
16
+
17
+ ```sh
18
+ pnpm run typecheck # tsc --noEmit
19
+ pnpm test # vitest run
20
+ pnpm run build # declarations + host/client bundles
21
+ pnpm run verify # typecheck + test + build
22
+ ```
23
+
24
+ ## 目录结构
25
+
26
+ ```text
27
+ src/
28
+ +-- index.ts # Host composition root
29
+ +-- config.ts # settings schema
30
+ +-- process.ts / runner.ts # local CLI execution
31
+ +-- service.ts # durable-memory facade
32
+ +-- memory-bodies.ts # Memory Space registry
33
+ +-- runtime-memory.ts # hot-memory authority
34
+ +-- documents.ts # managed Documents
35
+ +-- subagent.ts # bounded workers
36
+ +-- lifecycle.ts # root-Agent hooks
37
+ +-- review-activity.ts # activity score
38
+ +-- tools.ts / commands.ts # model and human interfaces
39
+ +-- rpc.ts / settings.ts # Web bridges
40
+ +-- storage-scope.ts # storage inventory
41
+ +-- client/ # React workspace and locales
42
+ tests/ # Vitest suites
43
+ lib/ # committed build artifacts
44
+ docs/zh-CN/ # Chinese documentation
45
+ docs/en/ # English mirror
46
+ cordis.patch.yml # DSH profile bundle patch
47
+ ```
48
+
49
+ ## 构建产物
50
+
51
+ ```text
52
+ tsc -p tsconfig.build.json
53
+ -> lib/types/* declarations, maps, intermediate ESM
54
+
55
+ tsdown host bundle
56
+ -> lib/index.js Node ES2024 ESM
57
+
58
+ tsdown client bundle
59
+ -> lib/client.js DSH browser module wrapper
60
+ -> lib/client.js.map
61
+
62
+ lightningcss plugin
63
+ -> CSS Modules compiled and injected as scoped <style>
64
+ ```
65
+
66
+ Host 保持 `cordis` 和 `schemastery` external。Client 保持 React、ReactDOM、JSX runtime 和 Cordis external,其余依赖打入 bundle。
67
+
68
+ `lib/` 是发布输入的一部分。修改 `src/` 后必须重新构建并检查生成 diff;不要手工编辑 `lib/`。
69
+
70
+ ## 测试层次
71
+
72
+ 现有 Vitest 套件覆盖:
73
+
74
+ - 配置解析、CLI 查找、进程串行;
75
+ - Memory Space 发现、激活、路由与合并;
76
+ - recall payload 兼容和图谱解析;
77
+ - Runtime JSON/Markdown 一致性、锁、容量、UTF-8 和 revision;
78
+ - Documents 路径、frontmatter、搜索、LRU、归档与冲突;
79
+ - worker 工具隔离、schema 子集、结构化回执;
80
+ - 生命周期 cue、评分、idle debounce、取消和水位保留;
81
+ - RPC authority、只读行为和设置 revision;
82
+ - Web 工作台、双语文案和关键交互。
83
+
84
+ 这些主要是临时目录、fake runner 和 mock Host 集成测试,不等同于自动化的真实 DSH + Mnemon WebUI E2E。
85
+
86
+ ## 真实 WebUI 验证
87
+
88
+ 发布前使用隔离环境,避免污染个人记忆:
89
+
90
+ ```text
91
+ temporary DSH_HOME
92
+ temporary MNEMON_DATA_DIR or custom storageScope
93
+ temporary workspace
94
+ independent Web port
95
+ local link installation
96
+ ```
97
+
98
+ 建议场景:
99
+
100
+ 1. 空根:UI 不报错,能够创建第一个 Memory Space。
101
+ 2. 普通对话:只出现短 cue,不强制 recall 或写入。
102
+ 3. 历史问题:Agent 自主 recall,并返回正确 space provenance。
103
+ 4. 显式沉淀:worker 查重、选择范围并可被再次召回。
104
+ 5. 多空间:读取只覆盖 active,写入 inactive 后自动激活。
105
+ 6. Runtime:USER / MEMORY add、replace、remove 和投影一致。
106
+ 7. Documents:创建、检索、更新、人工归档和原项目文件不变。
107
+ 8. 评分审查:轻任务不触发;达标后等待 idle;新 turn 能取消并保留水位。
108
+ 9. 只读:写工具、写命令和写 RPC 被拒绝,读取仍可用。
109
+ 10. 状态和浏览器控制台:无未处理错误或警告。
110
+
111
+ 容量极限、CLI 超时、revision 冲突和 Host 重启应在专用故障注入环境验证。
112
+
113
+ ## 修改 subagent schema
114
+
115
+ DSH structured output 只支持一个紧凑 JSON Schema 子集:
116
+
117
+ ```text
118
+ type, oneOf, properties, required, additionalProperties,
119
+ items, enum, const, and annotation keywords
120
+ ```
121
+
122
+ 不要加入 `maxItems` 等不受支持关键字。`assertDshOutputSchema()` 会在启动 worker 前递归拒绝未知 schema 键;结果数量等限制由 persona 和 Host parser 双重实现。
123
+
124
+ ## 修改存储格式
125
+
126
+ Runtime、Documents 和 Memory Space registry 都带版本字段或固定结构。修改时需要:
127
+
128
+ 1. 明确旧格式解析策略;
129
+ 2. 增加迁移或拒绝路径;
130
+ 3. 保证临时文件与原子 rename;
131
+ 4. 补充并发和损坏输入测试;
132
+ 5. 更新中英文存储、运维和 Roadmap 文档;
133
+ 6. 在复制的数据根上完成升级/回退验证。
134
+
135
+ 当前没有正式 schema migration 框架,不应静默改变持久格式。
136
+
137
+ ## 文档国际化维护
138
+
139
+ `docs/zh-CN` 与 `docs/en` 应保持同名文件和相同章节职责。修改默认值、流程或限制时:
140
+
141
+ - 同步两种语言;
142
+ - 保持命令、配置键、路径和代码符号完全一致;
143
+ - 使用相对路径互链对应语言页面;
144
+ - 架构总览优先使用可访问、无脚本和无外部资源的 SVG;目录树、命令、公式与短协议仍使用可复制的 `text` / ASCII;
145
+ - 根 README 只保留摘要,把细节放到单一权威 docs 页面。
146
+
147
+ Web locale 变更时,中文键集合仍是类型事实源;英文词典必须满足 `Record<MnemonKey, string>`,并保持占位符一致。
148
+
149
+ ## 发布检查
150
+
151
+ ```text
152
+ [ ] pnpm run verify
153
+ [ ] review source and generated lib diffs
154
+ [ ] validate package file list includes README.en.md and docs
155
+ [ ] install the built/local bundle into an isolated Web profile
156
+ [ ] run real Mnemon CLI and WebUI smoke tests
157
+ [ ] verify Chinese and English workspaces
158
+ [ ] verify global/workspace/custom paths as applicable
159
+ [ ] record tested DSH and Mnemon versions
160
+ [ ] back up any data root used for upgrade testing
161
+ ```
162
+
163
+ `package.json.files` 当前发布 `lib`、patch、两份根 README、双语公开 docs 和 License;历史研究台账不进入安装包。
164
+
165
+ ## 发布到 npm
166
+
167
+ 发布后 `dsh plugin --profile web add dsh-mnemon` 即按 registry 名称解析(与 dsh-better-sidebar 同路径)。发布步骤:
168
+
169
+ ```sh
170
+ npm pack --dry-run # 检查 tarball 文件清单(含 cordis.patch.yml、lib、docs)
171
+ pnpm publish --access public # prepublishOnly 会先跑 pnpm run verify
172
+ ```
173
+
174
+ 凭据约定:NPM_TOKEN 只写入用户级 `~/.npmrc`(`npm config set "//registry.npmjs.org/:_authToken" "${NPM_TOKEN}" --userconfig ~/.npmrc`),发布后删除。**不要**把凭据行提交进仓库 `.npmrc`:pnpm 11 出于安全会忽略项目级 `.npmrc` 中未展开的环境变量凭据并告警,且该文件会随仓库传播。
175
+
176
+ 2FA 注意:若 npm 账号开启发布级两步验证,交互发布直接执行 `pnpm publish --access public`,按提示输入 OTP;脚本/CI 发布需改用 Classic **Automation** 令牌或允许 bypass 2FA 的 Granular 令牌(`npm login` 生成的普通令牌无法发布,会报 403 Two-factor authentication required)。
177
+
178
+ 发布前核对 `package.json` 的 `repository`/`homepage`/`bugs` 指向 `omdsh-dev/dsh-mnemon`(npm 页面与 GitHub 保持一致),并确认版本号已递增。
@@ -0,0 +1,147 @@
1
+ # 快速开始
2
+
3
+ **简体中文** | [English](../en/getting-started.md) | [文档中心](./README.md)
4
+
5
+ ## 1. 前置条件
6
+
7
+ 你需要:
8
+
9
+ - 一个可以启动的 DSH Web profile;
10
+ - 本地可执行的 `mnemon` CLI;
11
+ - 可用于受限子任务的 DSH subagent provider。
12
+
13
+ provider 的准确要求如下:
14
+
15
+ ```text
16
+ regular semantic operations
17
+ -> prefer provider named "spawn"
18
+ -> may fall back to another compatible provider
19
+
20
+ scored background review
21
+ -> requires provider named "fork"
22
+ -> inheritsParentContext = true
23
+
24
+ both paths require
25
+ -> outputSchema
26
+ -> toolFilter
27
+ -> persona
28
+ -> depthLimit
29
+ ```
30
+
31
+ 插件没有在代码中声明固定的 DSH/Mnemon 最低版本矩阵。升级前应先在隔离数据目录中运行本页的验证步骤。
32
+
33
+ ## 2. 安装 Mnemon
34
+
35
+ macOS 推荐 Homebrew Cask:
36
+
37
+ ```sh
38
+ brew install --cask mnemon-dev/tap/mnemon
39
+ ```
40
+
41
+ macOS 或 Linux 也可以通过 Go 安装:
42
+
43
+ ```sh
44
+ go install github.com/mnemon-dev/mnemon@latest
45
+ ```
46
+
47
+ 验证二进制:
48
+
49
+ ```sh
50
+ mnemon --version
51
+ ```
52
+
53
+ 如果还要直接检查上游 Store,可以运行 `mnemon status`。该命令会打开有效 Store,可能初始化默认数据或执行迁移;不要把它当作完全无副作用的安装探测。
54
+
55
+ 如果 DSH 无法从 `PATH` 找到它,可以设置 `MNEMON_CLI_PATH`,或在 `mnemon.cliPath` 中配置绝对路径。
56
+
57
+ ## 3. 安装插件
58
+
59
+ 安装到 Web profile:
60
+
61
+ ```sh
62
+ dsh plugin --profile web add dsh-mnemon
63
+ ```
64
+
65
+ 未发布到 npm 的预发布版本可从 git 安装:
66
+
67
+ ```sh
68
+ dsh plugin --profile web add "github:omdsh-dev/dsh-mnemon"
69
+ ```
70
+
71
+ 本地开发检出:
72
+
73
+ ```sh
74
+ dsh plugin --profile web add "link:/absolute/path/to/dsh-mnemon"
75
+ ```
76
+
77
+ 插件包中的 `cordis.patch.yml` 会挂载 Host 插件;Web client bundle 会注册会话工作台和插件设置卡。
78
+
79
+ ## 4. 选择存储范围
80
+
81
+ 启动 DSH Web profile:
82
+
83
+ ```sh
84
+ dsh --profile web
85
+ ```
86
+
87
+ 在“设置 -> 插件配置 -> Mnemon”选择:
88
+
89
+ | 范围 | 根目录 | 适合场景 |
90
+ |---|---|---|
91
+ | `global` | `MNEMON_DATA_DIR` 或 `~/.mnemon` | 多个工作区共享同一套记忆 |
92
+ | `workspace` | DSH Host 启动目录下的 `.mnemon` | 项目隔离 |
93
+ | `custom` | `dataDir` | 显式磁盘、挂载卷或专用数据目录 |
94
+
95
+ 设置写入 `$DSH_HOME/settings.yaml`,重启 DSH 后应用。切换范围不会搬运旧数据;需要保留时先停止写入并手工复制整个旧根目录。
96
+
97
+ ## 5. 创建第一个记忆体
98
+
99
+ 进入任意会话的“记忆系统”Tab:
100
+
101
+ 1. 打开“记忆体”页。
102
+ 2. 创建一个主题明确的记忆体,例如“项目决策”。
103
+ 3. description 应说明“哪些内容属于这里,以及什么任务应召回它”。
104
+ 4. 开启读取开关,或在第一次写入后让插件自动激活它。
105
+
106
+ 空白记忆体默认可以保持未激活。激活只控制读取范围;写入可以选择任意已登记记忆体,写入成功后会自动激活目标。
107
+
108
+ ## 6. 验证完整链路
109
+
110
+ 先检查确定性状态:
111
+
112
+ ```text
113
+ /mnemon status
114
+ ```
115
+
116
+ 再在“沉淀”页提交一条稳定、自包含、未来仍有用的内容。worker 会选择记忆体、查重并返回结构化回执。随后验证:
117
+
118
+ ```text
119
+ /mnemon recall <一个能命中新内容的聚焦查询>
120
+ ```
121
+
122
+ 最后检查:
123
+
124
+ - “记忆体”页能看到已激活记忆体和图谱;
125
+ - “内容”能看到写入项及所属记忆体;
126
+ - “状态”中 CLI、运行时、记忆体目录和 subagent 均正常;
127
+ - 召回结果包含完整 `memoryBodyId` 和记忆 ID。
128
+
129
+ ## 7. 推荐的第一次真实对话
130
+
131
+ 选择一个确实依赖历史决策的问题,而不是要求模型无条件调用记忆工具。预期流程是:
132
+
133
+ ```text
134
+ user asks a history-dependent question
135
+ -> pre-step adds a short optional cue
136
+ -> main Agent decides whether history matters
137
+ -> recall worker selects active Memory Spaces
138
+ -> only useful evidence returns to the main Agent
139
+ ```
140
+
141
+ 普通聊天不应强制召回。当前请求、现有源文件和实时工具结果应优先于历史内容。
142
+
143
+ ## 8. 下一步
144
+
145
+ - 阅读[存储模型](./storage-model.md),再决定 `storageScope`。
146
+ - 阅读[配置参考](./configuration.md),配置只读模式或关闭生命周期提示。
147
+ - 阅读[运维指南](./operations.md),建立备份和升级前验证流程。
@@ -0,0 +1,159 @@
1
+ # WebUI、工具、命令与 RPC
2
+
3
+ **简体中文** | [English](../en/interfaces.md) | [文档中心](./README.md)
4
+
5
+ ## Web 工作台
6
+
7
+ 主要 Web 界面跟随 DSH 全局语言和明暗主题。顶部导航分为三组,组间以分隔线呈现:「状态」独立成第一组;「运行时、记忆体、档案」对应三层存储;「沉淀、检索、实体、内容」为读写工具。默认进入「状态」页。
8
+
9
+ | 页面 | 用途 | 调用边界 |
10
+ |---|---|---|
11
+ | 状态 | CLI、运行时热记忆、存储域、记忆体、Documents、生命周期和 worker 诊断 | 聚合读取 |
12
+ | 运行时 | 查看和维护 USER / MEMORY 热记忆及容量 | 普通 mutation 确定性;容量维护可启动 worker |
13
+ | 记忆体 | 记忆体目录、激活开关与元信息编辑、多空间实时图谱、节点检查 | 确定性 RPC 读取;开关与元信息编辑为写 RPC |
14
+ | 档案 | 搜索、阅读、创建、更新、归档 Documents | 搜索/编辑走控制层;归档启动 worker |
15
+ | 沉淀 | 让记忆 worker 选择范围、查重并写入;支持高级约束 | `spawn` 语义写入 |
16
+ | 检索 | smart / keyword / basic 直连召回;可选证据限定 Agent 答案 | 直接服务读取;Agent 答案使用无工具 worker |
17
+ | 实体 | 高频实体和实体相关上下文 | 直接服务读取 |
18
+ | 内容 | 无 recall 副作用地浏览已激活记忆体、复制、克隆或软删除 | 图谱读取;删除走 worker |
19
+
20
+ 图谱每 15 秒同步一次,也可以手动刷新。自然布局、均匀重置、拖拽和键盘微调只影响客户端展示,不修改 Mnemon 数据。
21
+
22
+ ## 模型工具
23
+
24
+ ### 只读工具
25
+
26
+ | 工具 | 用途 | Root Agent 路径 |
27
+ |---|---|---|
28
+ | `mnemon_memory_bodies` | 读取 Memory Space 目录和统计 | 直接服务 |
29
+ | `mnemon_recall` | 从一个或多个 active spaces 召回 | `spawn` recall worker |
30
+ | `mnemon_related` | 从已知 ID 遍历关系 | `spawn` related worker;root 路径固定请求两跳 |
31
+ | `mnemon_status` | CLI、配置和 active spaces 聚合状态 | 直接服务 |
32
+ | `mnemon_document_search` | 确定性搜索受管 Documents | 直接 Documents 控制层 |
33
+
34
+ 这里的“只读”表示不修改受管正文或长期语义内容。`mnemon_document_search` 命中后仍会更新 `lastAccessedAt` 并重写 Document index,用于 LRU 排序。
35
+
36
+ ### `writeEnabled=true` 时的工具
37
+
38
+ | 工具 | 用途 | Root Agent 路径 |
39
+ |---|---|---|
40
+ | `mnemon_runtime_memory` | `add` / `replace` / `remove` 热记忆 | 确定性控制层;add 溢出时 worker |
41
+ | `mnemon_document_manage` | 创建、更新或归档 Document | 创建/更新确定性;归档 worker |
42
+ | `mnemon_remember` | 长期沉淀一条洞察 | `spawn` write worker |
43
+ | `mnemon_link` | 建立 typed relationship | `spawn` write worker |
44
+ | `mnemon_forget` | 按精确 ID 软删除 | `spawn` write worker |
45
+ | `mnemon_memory_body_create` | 创建独立 Memory Space | `spawn` write worker |
46
+ | `mnemon_memory_body_update` | 更新名称、description、active | `spawn` write worker |
47
+ | `mnemon_memory_body_merge` | 非破坏性导入合并 | `spawn` write worker |
48
+
49
+ worker 内调用同名工具时直接到服务层,不再委派。
50
+
51
+ ## 工具准入建议
52
+
53
+ - 热记忆:用户明确偏好、稳定项目约定、环境事实和高频经验。
54
+ - Document:形成完整结构和理由的设计、调查、流程或交接。
55
+ - 长期 Memory Space:明确要求跨任务保留,或适合图关系和深召回的稳定洞察。
56
+ - 跳过:问题、猜测、临时进度、完成日志、原始输出、秘密、可轻易重新发现的仓库事实。
57
+
58
+ `mnemon_forget` 是破坏性语义操作,只有用户明确要求或内容已被验证错误/过时时才应执行。
59
+
60
+ ## `/mnemon` 命令
61
+
62
+ ```text
63
+ /mnemon
64
+ /mnemon status
65
+ /mnemon recall <查询>
66
+ /mnemon related <完整记忆 ID>
67
+ /mnemon remember <内容>
68
+ /mnemon forget <精确 ID>
69
+ ```
70
+
71
+ - 空 `/mnemon` 等价于 `status`。
72
+ - `status` 确定性读取,不启动模型。
73
+ - `recall`、`related`、`remember` 和 `forget` 使用命令所在 live Agent 作为 worker parent。
74
+ - 命令 recall 最多返回 10 条。
75
+ - `forget` 参数必须是一个不含空格的精确 ID。
76
+ - 当前命令帮助和结果主要为中文,尚未跟随 Web locale。
77
+
78
+ ## RPC 通道
79
+
80
+ RPC 是 DSH Host 与本插件 Web client 的内部桥,不是承诺稳定的外部 HTTP API。
81
+
82
+ ### 读通道
83
+
84
+ ```text
85
+ channel: /dsh-mnemon-read
86
+ authority: trusted-host
87
+ ```
88
+
89
+ | Endpoint | 行为 |
90
+ |---|---|
91
+ | `runtime-memory` | Runtime 快照 |
92
+ | `status` | 服务、生命周期、Documents 和存储域聚合状态 |
93
+ | `documents` | Document 目录快照 |
94
+ | `document` | 读取一份 Document |
95
+ | `document-search` | 确定性搜索,命中会更新 LRU 元数据 |
96
+ | `graph` | 聚合 active Memory Spaces 图谱 |
97
+ | `bodies` | Memory Space 目录 |
98
+ | `list` | 内容列表 |
99
+ | `entities` | 实体统计或实体相关上下文 |
100
+ | `search` | 直接 Mnemon 检索 |
101
+ | `agent-search` | 直接检索后做证据限定回答 |
102
+ | `related` | 直接关系遍历 |
103
+
104
+ ### 写通道
105
+
106
+ ```text
107
+ channel: /dsh-mnemon-write
108
+ authority: loopback
109
+ ```
110
+
111
+ | Endpoint | 行为 |
112
+ |---|---|
113
+ | `runtime-memory` | 热记忆 mutation |
114
+ | `supervise` | Tab 候选交给记忆 worker |
115
+ | `document` | create / update / archive |
116
+ | `remember` | 带可选高级约束的语义写入 |
117
+ | `link` | 建立关系 |
118
+ | `forget` | 软删除 |
119
+ | `body-create` | 创建 Memory Space |
120
+ | `body-update` | 更新元数据或 active |
121
+
122
+ `writeEnabled=false` 时整个写通道不注册。
123
+
124
+ ### 设置通道
125
+
126
+ ```text
127
+ channel: /dsh-mnemon-settings
128
+ authority: loopback
129
+ endpoints: get, mutate
130
+ ```
131
+
132
+ mutation 使用 settings revision 防止覆盖并发编辑。
133
+
134
+ ## npm 导出
135
+
136
+ 根包公开 Host 侧组合与核心类:
137
+
138
+ ```text
139
+ apply
140
+ Config / resolveConfig
141
+ createRunner
142
+ MnemonService
143
+ RuntimeMemoryController
144
+ DocumentManager
145
+ StorageScopeInspector
146
+ MnemonSubagentCoordinator
147
+ MnemonLifecycle
148
+ ```
149
+
150
+ `dsh-mnemon/client` 用于 DSH client bundle 的 `apply` 与 `inject`。`MnemonClient` 和 RPC endpoint 当前属于内部实现,不应当作稳定公共 SDK。
151
+
152
+ ## 国际化范围
153
+
154
+ Web 词典保持中文/英文键一一对应,品牌名、工具名和配置键不翻译。尚未完整国际化的表面包括:
155
+
156
+ - `/mnemon` 命令输出;
157
+ - 模型工具展示卡标题;
158
+ - 部分 Host 校验和诊断错误;
159
+ - 兼容发现旧 Store 时写入的默认名称和说明。