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,247 @@
1
+ # Project Overview: Local Three-Tier Memory for DSH
2
+
3
+ [简体中文](../zh-CN/project-overview.md) | **English** | [Documentation Center](./README.md)
4
+
5
+ > **`dsh-mnemon` deeply integrates [Mnemon](https://github.com/mnemon-dev/mnemon) with DSH, giving DSH comprehensive memory capabilities.**
6
+
7
+ It separates what must be visible every turn, project knowledge that should remain readable as a whole, and long-term history recalled across sessions into three clear tiers. DSH then supplies routing, lifecycle integration, bounded subagents, and the user interface.
8
+
9
+ The central goal is to give an Agent long-term continuity while keeping the current task authoritative, context compact, writes auditable, and original data protected when maintenance fails.
10
+
11
+ [![Mnemon Memory Spaces page showing the Memory Space catalog, activation state, and live multi-space relationship graph](../zh-CN/assets/screenshots/overview-memory-graph.png)](../zh-CN/assets/screenshots/overview-memory-graph.png)
12
+
13
+ *The overview brings the Memory Space catalog, activation state, statistics, and live multi-space graph into one workspace. Select the image for its original resolution. The screenshot uses the Chinese locale; the workspace also supports English.*
14
+
15
+ ## Why It Exists
16
+
17
+ With only the current conversation, an Agent cannot reliably carry forward user preferences, project conventions, and historical decisions. Injecting the entire history into every prompt causes context growth, stale-information interference, and additional cost. One memory tier also cannot satisfy all of these needs well:
18
+
19
+ | Need | Limit of one memory tier | dsh-mnemon approach |
20
+ |---|---|---|
21
+ | Make stable preferences and conventions available next turn | Retrieval adds latency and can miss | Runtime Memory injects compact projections every turn |
22
+ | Read a complete design, investigation, or procedure quickly | Fragmentation destroys narrative structure | Documents preserve searchable Markdown originals |
23
+ | Find cross-session facts, decisions, and relationships | Loading everything pollutes current context | Memory Spaces recall graph-enhanced evidence on demand |
24
+ | Keep infrequently used long-form material traceable | Keeping it hot consumes capacity forever | Create a durable cold reference before moving the original |
25
+ | Let a model judge value without delegating system safety | LLM output cannot guarantee paths, concurrency, or transactions | The LLM owns semantic judgment; the Host owns hard boundaries |
26
+
27
+ Whichever tier produces a hit, current user instructions, live tool results, and repository facts always take precedence over historical memory. The plugin supplies reviewable evidence and continuity; it does not let old content override current facts.
28
+
29
+ To satisfy immediate visibility, complete reading, and durable recall together, the plugin establishes a layered, supervised memory architecture between DSH and local persistence.
30
+
31
+ ## Architecture at a Glance
32
+
33
+ DSH provides the root Agent and extension surfaces, `dsh-mnemon` owns three-tier control, routing, and safety boundaries, and [Mnemon](https://github.com/mnemon-dev/mnemon) supplies the Memory Space capabilities for the durable tier. The plugin manages Runtime projections and Document originals; durable Memory Spaces and archive references are stored and retrieved through Mnemon.
34
+
35
+ [![dsh-mnemon runtime architecture connecting DSH Web, the root Agent, the supervised control layer, and three local storage tiers](./assets/project-architecture.svg)](./assets/project-architecture.svg)
36
+
37
+ The architecture has four useful boundaries:
38
+
39
+ 1. **Interaction boundary**: users reach memory through DSH conversations, `/mnemon` commands, model tools, and the Web workspace.
40
+ 2. **Supervision boundary**: lifecycle hooks provide only short cues; durable recall, semantic writes, and maintenance run in bounded subagents.
41
+ 3. **Deterministic control boundary**: the Host validates inputs, paths, permissions, revisions, UTF-8 capacity, locks, timeouts, and process arguments.
42
+ 4. **Local data boundary**: Runtime, Documents, and Memory Spaces share the selected `storageRoot`; memory persistence does not depend on a remote memory service.
43
+
44
+ See [Architecture](./architecture.md) for detailed module ownership, root/worker dual paths, and RPC trust boundaries.
45
+
46
+ Architecture boundaries determine who may execute an operation, the built-in prompt determines when the LLM should use a capability proactively, and the three-tier model determines the granularity of retained information and when it reaches context.
47
+
48
+ ## Built-in Prompt and Proactive Memory
49
+
50
+ Through the system prompt, dynamically injected `USER.md` / `MEMORY.md`, lifecycle cues, and tool descriptions, the plugin presents every read and write capability across Runtime Memory, Documents, Memory Spaces, relationships, and directory maintenance. This encourages the LLM to invoke the relevant capability whenever the current task may benefit instead of waiting for the user to name individual tools.
51
+
52
+ “Proactive” does not mean unconditional reads and writes on every turn. The current task remains authoritative, work continues without a memory call when none is useful, and a write is complete only with a valid tool receipt. When the user states an explicit intent, the LLM selects a path by information granularity and goal:
53
+
54
+ | User intent or task signal | Preferred capability |
55
+ |---|---|
56
+ | Revisit earlier work, find historical evidence, or recover an exact old detail | Search active Documents first, then use `mnemon_recall` / `mnemon_related` when needed |
57
+ | Remember a preference or stable convention, or correct old information | `mnemon_runtime_memory` with `add` / `replace` / `remove` |
58
+ | Preserve a complete design, investigation, procedure, or handoff | Search Documents, then create or update a managed Document; archive when needed |
59
+ | Retain durable facts or decisions, create relations, forget content, or adjust a Memory Space | Let a bounded worker deduplicate and route before using Memory Space write or maintenance capabilities |
60
+
61
+ Even without the literal words “remember this,” an explicit new reusable fact can justify proactive hot-memory writeback. After completed work reaches the activity-score gate and the root Agent remains idle, a `fork` background review can also conservatively inspect hot memory and project Documents. See [Lifecycle and Core Workflows](./workflows.md) and the [Interface Reference](./interfaces.md) for the complete prompting strategy, gates, and tool permissions.
62
+
63
+ ## The Three-Tier Memory Model
64
+
65
+ ### 1. Runtime Memory: Hot Context Visible Every Turn
66
+
67
+ Runtime Memory contains compact, frequently used stable information:
68
+
69
+ - `target=user`: identity, role, long-term preferences, habits, communication style, and explicit collaboration requirements;
70
+ - `target=memory`: project conventions, environment facts, decisions, tool behavior, and reusable lessons.
71
+
72
+ `runtime/memories.json` is the only source of truth. `USER.md` and `MEMORY.md` are deterministic projections injected into every prompt. USER is limited to 4 KiB, MEMORY to 10 KiB, and a single entry to 8 KiB, all measured as UTF-8 bytes.
73
+
74
+ Ordinary `add`, `replace`, and `remove` operations are handled by the deterministic control layer. Maintenance starts only when an `add` overflows: USER is conservatively compacted by a no-tool local worker, while MEMORY is semantically archived by a bounded worker before hot candidates are compacted. An overflowing `replace` is rejected and does not trigger automatic maintenance.
75
+
76
+ [![Runtime Memory page showing USER and MEMORY hot context, capacity, and edit actions](../zh-CN/assets/screenshots/runtime-memory.png)](../zh-CN/assets/screenshots/runtime-memory.png)
77
+
78
+ *The Runtime page places the USER and MEMORY projections side by side with their capacity, importance, categories, and per-entry edit controls.*
79
+
80
+ ### 2. Project Documents: Complete, Readable Project Knowledge
81
+
82
+ Documents preserve knowledge that is larger than one memory item but still needs fast, complete reading: architecture rationale, investigation findings, operating procedures, incident reviews, and implementation handoffs. Bodies remain Markdown and are searched deterministically by title, description, and content.
83
+
84
+ A body is limited to 2 MiB, and rendered active Documents are limited to 10 MiB in total. When capacity is insufficient or a user archives manually, a bounded worker first writes a Mnemon cold reference containing a summary and SHA-256. The original moves to `archived/` only if its Document revision is still current. This ordering protects the active original, but it is not a rollback-capable distributed transaction across SQLite and the filesystem.
85
+
86
+ Document sharing follows `storageScope`. Under `global` or `custom`, several workspaces may share one Document index. The live session workspace constrains new `sourcePaths`; it does not create separate ownership.
87
+
88
+ [![Project Documents page showing the Document list, metadata, and rendered Markdown original](../zh-CN/assets/screenshots/documents-markdown.png)](../zh-CN/assets/screenshots/documents-markdown.png)
89
+
90
+ *The Documents page preserves both metadata and Markdown structure, combining list selection, search, and complete reading in one view.*
91
+
92
+ ### 3. Memory Spaces: Isolated Long-Term Recall
93
+
94
+ Each Memory Space corresponds to a native named Mnemon Store with its own `mnemon.db`. The plugin adds a stable ID, a human-readable name, a routing description, and an active state.
95
+
96
+ - Reads cover active Memory Spaces only.
97
+ - Writes may target any registered Memory Space.
98
+ - A successful write to an inactive target activates it automatically.
99
+ - When creating a space, the model proposes the semantic name and boundary while the Host generates its stable ID.
100
+ - Merge uses non-destructive import; source databases remain and are inactive by default afterward.
101
+
102
+ The long-term layer retains `temporal`, `semantic`, `causal`, and `entity` relationships. Recall results include their Memory Space provenance and memory ID so the root Agent can traverse related context.
103
+
104
+ See [Storage and the Three-Tier Memory Model](./storage-model.md) for directory layouts, capacity details, and data authorities.
105
+
106
+ The tiers are not isolated repositories. Together they form a near-to-far lookup path that expands only when needed, while explicit writes and controlled maintenance retain information at the appropriate frequency and granularity.
107
+
108
+ ## From the Current Request to Durable Retention
109
+
110
+ ### Read: Start Near and Escalate Only When Needed
111
+
112
+ The plugin follows a near-to-far lookup gradient:
113
+
114
+ 1. Prefer the current request, live tool results, and repository facts.
115
+ 2. The root Agent can already see Runtime Memory injected for the turn.
116
+ 3. Search active Documents deterministically when complete project knowledge is needed.
117
+ 4. Use supervised recall for historical decisions, cross-session facts, or relationships.
118
+ 5. Follow a cold reference to an archived Document only when the complete original is required.
119
+
120
+ When the root Agent calls `mnemon_recall`, the coordinator starts an isolated worker. The worker may only inspect the Memory Space catalog, recall, and traverse related items. It selects active spaces by name and description and returns bounded structured evidence. Raw routing reasoning and the complete catalog do not enter the main conversation.
121
+
122
+ Direct Web search uses the deterministic service. “Agent search” performs the same retrieval first, then starts a no-Mnemon-tool evidence-only worker that can answer solely from the supplied hits and return only valid citations.
123
+
124
+ [![Recall page showing an Agent answer, source memory IDs, and raw recall results](../zh-CN/assets/screenshots/recall-agent-answer.png)](../zh-CN/assets/screenshots/recall-agent-answer.png)
125
+
126
+ *Agent search restricts evidence to the current hits while retaining source memory IDs and raw recall entries so the answer remains reviewable.*
127
+
128
+ In a real conversation, the root Agent can inspect the Memory Space catalog and project Documents before recalling from active spaces. If the current task genuinely needs an inactive space, a controlled workflow can activate it temporarily and restore its prior state after reading. The tool trace keeps lookup order, space selection, and provenance observable.
129
+
130
+ [![Memory recall in a DSH conversation with Document search, multi-space recall, and state restoration](../zh-CN/assets/screenshots/conversation-recall.png)](../zh-CN/assets/screenshots/conversation-recall.png)
131
+
132
+ ### Write: Separate Semantic Judgment from System Guarantees
133
+
134
+ The read path determines when memory is useful. The write path must also define who judges value, who persists data, and how original data is protected when an operation fails.
135
+
136
+ The plugin separates semantic judgment from system guarantees:
137
+
138
+ | LLM / worker responsibility | Hard Host guarantee |
139
+ |---|---|
140
+ | Decide whether content deserves long-term retention | Input schema and operation permissions |
141
+ | Select the narrowest suitable Memory Space | Paths cannot escape workspace boundaries |
142
+ | Identify duplicates, conflicts, and semantic clusters | CLI uses argument arrays with no shell |
143
+ | Produce summaries, routing decisions, and relationship reasons | Timeouts, cancellation, output limits, and process serialization |
144
+ | Decide whether complex work produced a reusable Document | File locks, temporary files, rename, and revision fences |
145
+ | Perform conservative maintenance within its persona | UTF-8 capacity accounting and preservation on failure |
146
+
147
+ Durable recall, semantic writes, and capacity maintenance use isolated `spawn` workers. Background review uses a checkpoint-inheriting `fork` worker only after a completed turn crosses the activity-score gate and the root Agent remains idle. A new turn cancels pending or active review. Worker context, tools, and output remain bounded while the Host retains deterministic validation; see the workflow guide for complete provider requirements and review boundaries.
148
+
149
+ See [Lifecycle and Core Workflows](./workflows.md) for recall, writes, capacity maintenance, archiving, and the scoring formula.
150
+
151
+ When the user explicitly asks to retain stable information, the root Agent selects structured tools by content type and writes individual items while the Host continues to validate the target, capacity, and revision. The final response reports what was actually stored instead of treating internal reasoning as persistence.
152
+
153
+ [![Memory writeback in a DSH conversation with structured Runtime Memory tool calls and receipts](../zh-CN/assets/screenshots/conversation-writeback.png)](../zh-CN/assets/screenshots/conversation-writeback.png)
154
+
155
+ ### Three-Tier Example: Retaining an Architecture Decision
156
+
157
+ Suppose a substantial task establishes that “every external CLI must be launched with an argument array and without a shell,” and also produces a complete threat analysis and migration guide:
158
+
159
+ 1. The frequently used operating rule can enter `MEMORY.md` as a compact fact and become visible from the next turn.
160
+ 2. The complete analysis and migration procedure belong in an active Document, preserving headings, code excerpts, and source files.
161
+ 3. If the decision should remain recallable across projects, a bounded worker selects a suitable Memory Space, checks for duplicates, writes a self-contained decision, and may link it to related security principles.
162
+ 4. When someone later asks why shell command concatenation is forbidden, the Agent sees the hot rule first, searches the Document for rationale, and recalls Mnemon evidence only when cross-session relationships matter.
163
+ 5. If the Document becomes infrequently used and active capacity is needed, the plugin writes a cold reference with its summary and hash before moving the original. The full analysis remains traceable through that reference.
164
+
165
+ The same knowledge can therefore retain complementary expressions at different frequencies and narrative granularity, without copying the entire Document into every prompt or stretching one short rule into a long record.
166
+
167
+ These workflows can be initiated proactively through Agent tools and can also be inspected, verified, and maintained in DSH's Memory workspace.
168
+
169
+ ## User and Integration Surfaces
170
+
171
+ ### Web Workspace
172
+
173
+ The conversation's “Memory System” tab contains eight pages in three divider-separated groups: “Status” stands alone; “Runtime, Memory Spaces, Documents” cover the three storage tiers; “Distill, Recall, Entities, Content” are the read/write tools:
174
+
175
+ | Page | Primary purpose |
176
+ |---|---|
177
+ | Status | CLI, runtime hot memory, storage scope, lifecycle, and subagent diagnostics |
178
+ | Runtime | USER / MEMORY hot context, capacity, and deterministic maintenance |
179
+ | Memory Spaces | Memory Space catalog, activation controls, metadata editing, and a live multi-space graph |
180
+ | Documents | Search, read, edit, and archive managed Documents |
181
+ | Distill | Give a candidate to a bounded worker for deduplication, routing, and writing |
182
+ | Recall | Direct recall, related traversal, and evidence-only Agent search |
183
+ | Entities | Frequent entities and their cross-graph context |
184
+ | Content | Browse, copy, clone, or soft-delete durable memories |
185
+
186
+ The primary Web workspace and settings card support Chinese and English and follow DSH's global light/dark theme. Commands, tool cards, and some backend diagnostics are not yet fully internationalized.
187
+
188
+ [![Entities page showing frequent entities, hit counts, and entity-linked context](../zh-CN/assets/screenshots/entities-context.png)](../zh-CN/assets/screenshots/entities-context.png)
189
+
190
+ *The Entities page ranks names by hit count and retains related memories, category, importance, score, and Memory Space provenance on the right.*
191
+
192
+ [![Content page showing durable-memory filters, tags, relationships, and maintenance actions](../zh-CN/assets/screenshots/memory-content.png)](../zh-CN/assets/screenshots/memory-content.png)
193
+
194
+ *The Content page supports filtering and inspection, then exposes relationship lookup, create-from-current, ID copy, and soft-delete actions.*
195
+
196
+ ### Model Tools and Commands
197
+
198
+ The plugin registers read and write groups of `mnemon_*` model tools and provides:
199
+
200
+ ```text
201
+ /mnemon status
202
+ /mnemon recall <query>
203
+ /mnemon related <full memory ID>
204
+ /mnemon remember <stable, self-contained durable insight>
205
+ /mnemon forget <full memory ID>
206
+ ```
207
+
208
+ Web RPC is an internal bridge between the DSH Host and the plugin client: reads require `trusted-host`, while memory writes and settings require `loopback`. These channels are not a stable external HTTP SDK. See [WebUI, Tools, Commands, and RPC](./interfaces.md) for the complete interface matrix.
209
+
210
+ ## Local-First Reliability Design
211
+
212
+ Beyond visibility, deterministic boundaries constrain paths, capacity, concurrency, and failure recovery.
213
+
214
+ - **Local data**: SQLite, the registry, Runtime JSON, and Documents live under the user-selected root.
215
+ - **No-shell execution**: the Mnemon CLI uses `spawn(command, args, { shell: false })`.
216
+ - **Bounded processes**: each call has a timeout, cancellation, and a 2 MiB combined stdout + stderr limit.
217
+ - **Concurrency control**: Runtime and Documents use in-process queues and cross-instance lock files; CLI calls are serialized within one Runner.
218
+ - **Original-first protection**: revision conflicts, worker failures, and invalid receipts never use stale results to overwrite current hot memory or move an active Document.
219
+ - **Recoverable projections**: a valid `memories.json` can rebuild `USER.md` and `MEMORY.md`.
220
+ - **Least-privilege workers**: every worker has a fixed persona, tool allowlist, structured output, and `maxDepth: 1`.
221
+
222
+ These boundaries are not a secret scanner or a complete backup system. There is no deterministic credential detection, cross-system rollback, built-in consistent snapshot, or general corruption repair tool yet. Production data needs independent backup and recovery rehearsals; see [Operations, Security, and Troubleshooting](./operations.md).
223
+
224
+ “Local-first” describes persistence location and CLI execution. It does not guarantee that selected content never leaves the device. If the DSH root model or subagent provider runs remotely, relevant prompts, candidates, or recalled evidence may still be sent to that provider; the actual data-processing boundary depends on the configured DSH model providers.
225
+
226
+ ## Scope and Version Status
227
+
228
+ `dsh-mnemon` is useful when:
229
+
230
+ - long-running collaboration needs stable user preferences and working conventions;
231
+ - a large project needs design rationale, investigation records, and handoff knowledge;
232
+ - several knowledge domains need isolated storage, selective activation, and cross-space recall;
233
+ - data should remain local while an LLM handles semantic judgment;
234
+ - users need a visible, editable, diagnosable memory experience native to DSH.
235
+
236
+ It is not intended for bulk persistence of secrets, raw logs, short-lived progress, or ordinary facts that can be reconstructed from the repository. It should not be treated as the source of truth, an authorization system, a backup system, or a proactive notification daemon.
237
+
238
+ The current release is an early Beta and continues to evolve. See the [Roadmap](./roadmap.md) for selected planned capabilities and iteration priorities.
239
+
240
+ ## Continue Reading
241
+
242
+ - To run it now: read [Getting Started](./getting-started.md).
243
+ - To understand code boundaries: read [Architecture](./architecture.md).
244
+ - To choose a data scope: read [Storage and the Three-Tier Memory Model](./storage-model.md) and the [Configuration Reference](./configuration.md).
245
+ - To understand transactions and review: read [Lifecycle and Core Workflows](./workflows.md).
246
+ - To deploy or upgrade: read [Operations, Security, and Troubleshooting](./operations.md).
247
+ - To contribute: read [Development and Verification](./development.md).
@@ -0,0 +1,41 @@
1
+ # Roadmap
2
+
3
+ [简体中文](../zh-CN/roadmap.md) | **English** | [Documentation Center](./README.md)
4
+
5
+ The Roadmap records work beyond the current implementation; it is not a commitment to deliver these capabilities. Data safety, recoverability, and verifiability take priority.
6
+
7
+ ## P0: Reliability and Recoverable Scheduling
8
+
9
+ - [ ] **Persist background-review watermarks**: save activity signals, the latest processed checkpoint, scoring version, and run state by root session; restore unprocessed activity after restart or resume.
10
+ - [ ] **Idempotent checkpoints**: assign a stable identifier to each review input to prevent timeouts, retries, or duplicate hooks from producing duplicate Documents.
11
+ - [ ] **Backoff, circuit breaking, and manual retry**: apply bounded backoff after consecutive failures, show the reason on the Status page, and allow explicit recovery.
12
+ - [ ] **Deterministic sensitive-data defenses**: add secret/credential pattern detection, size limits, and audit receipts beyond LLM admission.
13
+ - [ ] **Automated real-WebUI E2E**: isolate DSH_HOME, storageRoot, workspace, and the port; cover light tasks, score-based review, cancellation, and failures without partial writes.
14
+ - [ ] **Correct `tabEnabled` semantics**: have the Host and client use the same switch so the complete Tab capability is actually registered or removed.
15
+ - [ ] **Correct cold-reference paths**: under every storage scope, write resolvable references that match the actual managed path.
16
+
17
+ ## P1: Long-Term Maintenance and Data Operations
18
+
19
+ - [ ] **Long-term organization across sessions**: trigger an independent organization process based on time and the number of new sessions instead of reusing per-turn review.
20
+ - [ ] **Mnemon GC / forget review**: generate candidates for decay, conflicts, obsolete content, and orphaned relationships, then present evidence before deletion.
21
+ - [ ] **Consistent backup and recovery**: provide unified snapshots, checksums, and recovery rehearsals for the registry, multiple databases, Runtime, and Documents.
22
+ - [ ] **Repair and rebuild tools**: detect damaged JSON, missing projections, orphaned Documents, missing databases, and registry/disk inconsistencies.
23
+ - [ ] **Schema migration**: add explicit upgrade and rollback strategies for Runtime, the Documents index, and the Memory Space registry.
24
+ - [ ] **Compatibility matrix**: document and automatically test supported combinations of DSH, the Mnemon CLI, Node, and data formats.
25
+ - [ ] **Explicit Documents workspace ownership**: record the source workspace under shared storage scopes or provide a configurable isolation strategy.
26
+
27
+ ## P2: Observability, Experience, and Release Engineering
28
+
29
+ - [ ] **Background-review history**: show recent scores, checkpoints, waiting/running/failed states, worker receipts, and resulting changes.
30
+ - [ ] **Complete internationalization**: cover commands, tool cards, Host errors, compatibility default metadata, and confirmation copy.
31
+ - [ ] **Multi-Memory-Space E2E**: cover automatic space creation, cross-space recall, one-pass migration routing, multiple relationship types, merge, and controlled forget.
32
+ - [ ] **Capacity and fault injection**: exercise real USER/MEMORY boundaries, Document LRU, revision conflicts, CLI timeouts, and mid-operation Host restarts.
33
+ - [ ] **Documentation consistency checks**: add relative links, external links, bilingual file mirroring, configuration-key matching, and code-block matching to CI.
34
+ - [ ] **Release completion**: establish stable versions, a changelog, upgrade/uninstall/data-retention guides, artifact checksums, and a minimum-support policy.
35
+
36
+ ## Explicitly Out of Scope
37
+
38
+ - A Runtime `daily` target; only `user` and `memory` are currently maintained.
39
+ - A proactive notification daemon without explicit delivery semantics; Mnemon remains an on-demand pull system.
40
+ - Declaring internal RPC or `MnemonClient` to be a stable public SDK.
41
+ - Automatically deleting the source Memory Space database; merge currently preserves the source files.
@@ -0,0 +1,179 @@
1
+ # Storage and the Three-Layer Memory Model
2
+
3
+ [简体中文](../zh-CN/storage-model.md) | **English** | [Documentation Center](./README.md)
4
+
5
+ ## Why Three Layers
6
+
7
+ No single storage form can simultaneously be visible on every turn, preserve complete narratives, and support long-term graph-enhanced recall:
8
+
9
+ | Question | Corresponding layer | Reason |
10
+ |---|---|---|
11
+ | What must be known directly on the next turn? | Runtime Memory | Tiny and injected directly into the prompt |
12
+ | Which design or procedure needs to be read quickly and in full? | active Documents | Preserves Markdown structure without deep recall |
13
+ | Which historical facts and relationships should persist across sessions? | Memory Spaces | Independent databases, graph relationships, and on-demand recall |
14
+ | What happens when a long document is rarely used but must remain traceable? | archived Documents | Mnemon retains an index while the cold layer retains the original text |
15
+
16
+ Recommended query gradient:
17
+
18
+ ```text
19
+ current request and repository facts
20
+ |
21
+ v
22
+ Runtime Memory already in prompt
23
+ |
24
+ v
25
+ search active Documents
26
+ |
27
+ v
28
+ recall active Memory Spaces
29
+ |
30
+ v
31
+ follow an exact cold reference when full text is required
32
+ ```
33
+
34
+ ## Unified Root Directory
35
+
36
+ ```text
37
+ <storageRoot>/
38
+ +-- runtime/
39
+ | +-- memories.json
40
+ | +-- USER.md
41
+ | +-- MEMORY.md
42
+ +-- documents/
43
+ | +-- index.json
44
+ | +-- active/
45
+ | +-- archived/
46
+ +-- data/
47
+ | +-- .dsh-memory-bodies.json
48
+ | +-- <memory-space-id>/
49
+ | +-- mnemon.db
50
+ +-- state/ # reserved; no persistent reviewer yet
51
+ ```
52
+
53
+ `storageScope` determines the entire root, not just the Mnemon databases. `state/` is currently recognized only by the status inspector; scored review watermarks remain in the running Host's memory.
54
+
55
+ ## Runtime Memory
56
+
57
+ ### Semantics
58
+
59
+ - `target=user`: identity, role, long-term preferences, habits, communication style, and explicit collaboration requirements.
60
+ - `target=memory`: projects, environment, decisions, conventions, tool characteristics, and reusable experience.
61
+ - `importance=critical|normal|low`: retention priority during maintenance.
62
+
63
+ There is currently no `daily` target.
64
+
65
+ ### Source of Truth and Projections
66
+
67
+ `runtime/memories.json` is the sole source of truth. Each record contains:
68
+
69
+ ```text
70
+ content
71
+ created_at
72
+ updated_at
73
+ target
74
+ importance
75
+ ```
76
+
77
+ `USER.md` and `MEMORY.md` are deterministic derived files. Each item is normalized to one line, and items are separated by a line containing only `§`; `§` is a reserved character. During startup and prompt assembly, the control layer repairs missing or manually modified projections from the JSON source.
78
+
79
+ ### Operations
80
+
81
+ - `add` writes an independent new fact; exactly identical content is not added twice.
82
+ - `replace` uses a unique substring match on `old_text` to locate and replace an entire item.
83
+ - `remove` uses a unique substring to remove an entire item.
84
+ - Zero or multiple matches are rejected; no fuzzy mutation is performed.
85
+
86
+ ### Capacity
87
+
88
+ | Target | Limit | Maintenance method |
89
+ |---|---:|---|
90
+ | `USER.md` | 4 KiB | A local no-tool worker merges conservatively; content never enters a Memory Space |
91
+ | `MEMORY.md` | 10 KiB | A worker archives committed content first, then returns compaction candidates |
92
+
93
+ Capacity is measured from the actual UTF-8 bytes of the projection body. A single item is limited to 8 KiB. Automatic capacity maintenance is triggered only by an overflowing `add`; an overflowing `replace` fails directly, and the caller should perform explicit maintenance first.
94
+
95
+ ## Project Documents
96
+
97
+ ### Purpose
98
+
99
+ Documents preserve project knowledge that is more complete than a single memory item but should still be quick to read, such as:
100
+
101
+ - architecture designs and rationale;
102
+ - evidence-backed investigation findings;
103
+ - operating procedures, release checklists, and incident reviews;
104
+ - implementation handoffs and long-term maintenance notes.
105
+
106
+ User profiles, ordinary conversation, temporary progress, raw large logs, and secrets should not be stored in Documents.
107
+
108
+ ### Control Plane
109
+
110
+ `documents/index.json` is the metadata source of truth. It manages IDs, titles, descriptions, status, filenames, source paths, sessions, timestamps, revisions, SHA-256 values, sizes, and Memory Space references. Managed Markdown copies include generated frontmatter.
111
+
112
+ `sourcePaths`:
113
+
114
+ - may point only inside the current session workspace;
115
+ - are source references only and are never modified by the plugin;
116
+ - are not required to exist by the current implementation;
117
+ - may not point into the managed `documents/` directory itself.
118
+
119
+ ### Scope
120
+
121
+ The physical sharing scope of Documents is determined by `storageScope`:
122
+
123
+ - `workspace`: normally isolated with the project;
124
+ - `global` / `custom`: multiple workspaces may share the same `documents/index.json`.
125
+
126
+ Therefore, “Project Documents” describes the content type and does not guarantee physical isolation by workspace. The current session workspace constrains only `sourcePaths` on new writes.
127
+
128
+ ### Capacity and Hot/Cold Tiering
129
+
130
+ | Item | Limit |
131
+ |---|---:|
132
+ | One body | 2 MiB maximum |
133
+ | Total active content | 10 MiB maximum, including generated frontmatter |
134
+ | Total archived content | Does not count toward the active limit |
135
+
136
+ The actual rendered size is calculated before creation or update. If capacity is insufficient, the least recently accessed active Document is selected by `lastAccessedAt` and then `updatedAt`; a Mnemon cold reference is written and verified first, and the original text is moved only if its revision remains unchanged.
137
+
138
+ Default search covers only active Documents. Search updates `lastAccessedAt` for matching Documents, so it is read-only with respect to bodies but writes index metadata.
139
+
140
+ ## Memory Spaces
141
+
142
+ Each Memory Space is a native named Mnemon Store with maintainable metadata added in `.dsh-memory-bodies.json`:
143
+
144
+ ```text
145
+ id Host-generated stable UUID or discovered compatible Store name
146
+ name human-readable name
147
+ description routing boundary: what belongs here and when to recall it
148
+ active whether it participates in reads
149
+ mnemon.db independent data plane
150
+ ```
151
+
152
+ ### Read and Write Boundaries
153
+
154
+ - Recall, graph, content, and entity reads use only active Memory Spaces.
155
+ - Reads explicitly targeting an inactive Memory Space are rejected.
156
+ - Writes may target any registered Memory Space.
157
+ - After a successful write to an inactive target, the plugin activates it automatically.
158
+ - Without an explicit target, if the number of active Memory Spaces is not exactly one, the deterministic service requires the caller to choose a target first.
159
+
160
+ ### Creation, Discovery, and Merge
161
+
162
+ - On creation, the model supplies a name and description; the Host generates the ID.
163
+ - An existing `<storageRoot>/data/<store>/mnemon.db` is discovered and registered without moving the database.
164
+ - Merge imports source content into the target through Mnemon; the source database remains in place, and by default only the source is marked inactive.
165
+ - `forget` is a soft delete by exact ID, not deletion of a database file.
166
+
167
+ ## Four Relationship Types
168
+
169
+ The Mnemon long-term layer preserves `temporal`, `semantic`, `causal`, and `entity` relationships. The plugin does not require relationships to be created manually for every memory; they should be created only when they genuinely improve future recall. Overview can aggregate memories, entities, relationships, and space membership across multiple active Memory Spaces.
170
+
171
+ ## Data Authority Table
172
+
173
+ | Data | Authoritative source | Derived/cache |
174
+ |---|---|---|
175
+ | Hot memory | `runtime/memories.json` | `USER.md`, `MEMORY.md` |
176
+ | Documents | `documents/index.json` + managed Markdown | excerpts, search ranking, status aggregation |
177
+ | Memory Space catalog | `data/.dsh-memory-bodies.json` + on-disk Stores | Web status aggregation |
178
+ | Long-term memory | Each Store's `mnemon.db` | parsed HTML/DOT graph results |
179
+ | Review watermark | Host process memory | status-page snapshot; not yet persisted |