dsh-memvault 0.10.0 → 0.11.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.
- package/README.md +61 -25
- package/README.zh.md +71 -35
- package/cordis.patch.yml +23 -0
- package/docs/CORE-DESIGN.md +10 -1
- package/docs/DEVLOG.md +658 -0
- package/docs/PLAN-0.11.md +421 -0
- package/docs/domains/game-dev.md +67 -0
- package/lib/blocks.js +34 -8
- package/lib/client.js +631 -12
- package/lib/config.js +207 -0
- package/lib/core/block-write.js +70 -17
- package/lib/core/host.js +15 -4
- package/lib/core/knowledge.js +332 -0
- package/lib/core/pipeline.js +13 -4
- package/lib/core/promotion.js +155 -0
- package/lib/core/proposals.js +508 -0
- package/lib/core/schema.js +159 -1
- package/lib/core/store.js +160 -3
- package/lib/core/tools.js +155 -4
- package/lib/domain-host.js +490 -0
- package/lib/domain.js +483 -0
- package/lib/gate.js +201 -0
- package/lib/index.js +412 -7
- package/lib/panel.js +209 -3
- package/package.json +2 -2
- package/scripts/seed-domains.mjs +171 -0
- package/scripts/smoke-package.mjs +23 -6
- package/scripts/smoke-panel.mjs +200 -14
- package/src/client/index.js +629 -10
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<strong>Long-term memory for DeepSeek Harness.</strong><br>
|
|
7
|
-
blocks in the prompt · turns
|
|
7
|
+
blocks in the prompt · turns and tacit knowledge in one SQLite file · domain packs · one board
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
10
|
<p align="center">
|
|
@@ -12,23 +12,25 @@
|
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
14
|
<p align="center">
|
|
15
|
-
<img alt="version" src="https://img.shields.io/badge/version-0.
|
|
15
|
+
<img alt="version" src="https://img.shields.io/badge/version-0.11.0-4a6cf7">
|
|
16
16
|
<img alt="license" src="https://img.shields.io/badge/license-MIT-30a46c">
|
|
17
17
|
<img alt="runtime deps" src="https://img.shields.io/badge/runtime%20deps-zero-888">
|
|
18
|
-
<img alt="node" src="https://img.shields.io/badge/node-%E2%89%
|
|
18
|
+
<img alt="node" src="https://img.shields.io/badge/node-%E2%89%A524.9-339933">
|
|
19
19
|
<img alt="stars" src="https://img.shields.io/github/stars/zhang66633/dsh-memvault?style=flat&color=e3b341">
|
|
20
20
|
</p>
|
|
21
21
|
|
|
22
22
|
---
|
|
23
23
|
|
|
24
|
-
MCP is pull-only, so "memory is already loaded" can never come from a server. This plugin does it inside DSH — and
|
|
24
|
+
MCP is pull-only, so "memory is already loaded" can never come from a server. This plugin does it inside DSH — and it owns the store too: one SQLite file, no Python, no second process.
|
|
25
25
|
|
|
26
26
|
| Half | What | How |
|
|
27
27
|
|---|---|---|
|
|
28
|
-
| **Inject** | core blocks
|
|
29
|
-
| **Extract** | finished turns → one window →
|
|
28
|
+
| **Inject** | core blocks + the domain packs that apply right now, every step | two `ctx.systemPrompt.context()` contributions |
|
|
29
|
+
| **Extract** | finished turns → one window → a fact pass **and** a tacit-knowledge pass | `session/event` → window → `add`/`supersede`/`none` |
|
|
30
30
|
| **Recall** | `memory_search` / `memory_add` | FTS5 trigram + vectors, RRF, answerability guard |
|
|
31
|
-
| **
|
|
31
|
+
| **Evolve** | `memory_propose` / `memory_pending`; a human approves | proposals queue + panel |
|
|
32
|
+
| **Enforce** | a domain gate refuses action tools until evidence is recorded | `ctx.tools.guard()` |
|
|
33
|
+
| **Show** | board / inject / memories / structure / evolution | host routes + conversation tab / settings page |
|
|
32
34
|
|
|
33
35
|
## ✨ Features
|
|
34
36
|
|
|
@@ -36,10 +38,12 @@ MCP is pull-only, so "memory is already loaded" can never come from a server. Th
|
|
|
36
38
|
|---|---|
|
|
37
39
|
| 🗄️ **One store** | prompt, extraction, tools and panel read `~/.dsh/memvault/memvault.db` |
|
|
38
40
|
| 🧠 **No tool call needed** | blocks ride the runtime context, TTL-cached |
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
41
|
+
| 🧬 **Propose, never apply** | the model can draft a core-block change; only a human approves it. There is deliberately no approval tool |
|
|
42
|
+
| 🗂️ **Domain packs** | background for one vertical, injected only while it applies (path + marker files) or when activated; detail is read on demand with `domain_detail` |
|
|
43
|
+
| ✍️ **The model may draft packs** | `domain_draft` writes `draft` only, needs a source, and can never rewrite an approved pack |
|
|
44
|
+
| ⛔ **Gates that actually refuse** | until `domain_gate` records a url + a ≥40-char quote, write/edit/apply_patch/memory_add are refused by the tool pipeline. Read tools are never blocked |
|
|
45
|
+
| 🕸️ **Six tacit classes** | rationale · contract · failure · dependency · solution · persona — own prompt, own budget; repeats become evidence, and promotion ends at a proposal |
|
|
46
|
+
| 📊 **A board** | four numbers, a knowledge map, and the flow that produced them |
|
|
43
47
|
| 🃏 **Native tool cards** | `memory_search` / `memory_add` render their own conversation cards |
|
|
44
48
|
| 🪶 **Zero deps** | `node:sqlite` + hand-written client bundle |
|
|
45
49
|
|
|
@@ -51,7 +55,7 @@ dsh plugin --profile desktop add dsh-memvault
|
|
|
51
55
|
|
|
52
56
|
Self-owned install links a checkout in the profile's `package.json` (`dsh-memvault: link:…`) plus a junction under `node_modules` — see `docs/DEVLOG.md`. A new bundle needs a **DSH restart**; after editing the client run `npm run build`.
|
|
53
57
|
|
|
54
|
-
Requires DSH **0.2.1+**, verified against **0.2.2-rc.
|
|
58
|
+
Requires DSH **0.2.1+**, verified against **0.2.2-rc.5** (`engines.dsh` names the 0.2.2 line explicitly, because a bare `>=0.2.1-0 <0.3.0-0` does not admit `0.2.2-rc.5` for strict semver readers; the `>=0.2.2-0` arm covers the whole 0.2.2 pre-release line). Node **24.9+** is required: that is the runtime floor of DSH 0.2.2, and this plugin uses Node 24's `DatabaseSync` busy-timeout option. The tool cards, the non-interpolated injection, `ctx.tools.guard()` and session-close extraction are 0.2.2 features; on 0.2.1 they degrade to the previous behaviour.
|
|
55
59
|
|
|
56
60
|
## ⚙️ Configuration
|
|
57
61
|
|
|
@@ -60,18 +64,29 @@ Requires DSH **0.2.1+**, verified against **0.2.2-rc.3** (`engines.dsh` names th
|
|
|
60
64
|
| `scopes` | `[{user,lenovo},{agent,claude-code-memory}]` |
|
|
61
65
|
| `labels` / `maxChars` / `refreshMs` | `[]` / `4000` / `30000` |
|
|
62
66
|
| `extract.everyNTurns` / `idleMs` / `windowTurns` | `3` / `20000` / `8` |
|
|
63
|
-
| `extract.timeoutMs` | `60000`
|
|
64
|
-
| `extract.minTranscriptChars` / `maxInputChars` | `40` / `6000` |
|
|
67
|
+
| `extract.timeoutMs` / `minTranscriptChars` / `maxInputChars` | `60000` / `40` / `6000` |
|
|
65
68
|
| `extract.projectDir` / `env` | discovered `.env` directory / `{}` |
|
|
69
|
+
| `extract.knowledge.enabled` | `true` — the six-class channel |
|
|
70
|
+
| `extract.knowledge.includeAssistant` / `includeTools` | `true` / `true` (facts keep them off) |
|
|
71
|
+
| `extract.knowledge.maxInputChars` | `8000` (independent of the fact budget) |
|
|
72
|
+
| `extract.knowledge.promotion.minUsed` / `minEvidence` | `3` / `2` |
|
|
73
|
+
| `domain.enabled` / `maxDomains` | `true` / `2` |
|
|
74
|
+
| `domain.indexChars` / `maxChars` / `refreshMs` | `480` / `1000` / `10000` |
|
|
75
|
+
| `domain.probeDir` | `''` — empty disables file evidence; only keywords, tool args and explicit activation apply |
|
|
76
|
+
| `domain.thresholdPct` | `100` (= score 1.0; path + one marker file scores 1.1) |
|
|
77
|
+
| `domain.gate.enabled` / `tools` / `minQuote` / `maxAgeHours` | `true` / write,edit,apply_patch,memory_add / `40` / `24` |
|
|
78
|
+
| `domain.draftHint` / `maxPacks` | `true` / `20` |
|
|
66
79
|
| `panel.writes` | `true` |
|
|
67
80
|
|
|
68
|
-
The store path is not configurable through this plugin (`~/.dsh/memvault/memvault.db`, or `DSH_MEMVAULT_CORE_DB`). `projectDir` is only where `.env` is read — nothing is spawned
|
|
81
|
+
The store path is not configurable through this plugin (`~/.dsh/memvault/memvault.db`, or `DSH_MEMVAULT_CORE_DB`). `projectDir` is only where `.env` is read — nothing is spawned. The pipeline reads the usual `.env` keys (`OPENAI_*`, `MEMVAULT_EXTRACTOR=rule|llm`, `MEMVAULT_EMBEDDER=local|openai`, `MEMVAULT_ADJUDICATOR=off`).
|
|
69
82
|
|
|
70
|
-
|
|
83
|
+
A stale patch that still sets a removed key (`dbPath`, `extract.pythonPath`, `extract.user/agent/run`) is reported as an ignored key in the panel instead of silently doing nothing. The write scope is derived from `scopes` (first user → `user_id`, first agent → `agent_id`).
|
|
71
84
|
|
|
72
85
|
## 🗄️ Store & migration
|
|
73
86
|
|
|
74
|
-
`~/.dsh/memvault/memvault.db` (override `DSH_MEMVAULT_CORE_DB`).
|
|
87
|
+
`~/.dsh/memvault/memvault.db` (override `DSH_MEMVAULT_CORE_DB`). Schema **v3**: blocks + history, memories (FTS5 + vectors), relations, retrievals, block proposals, knowledge + evidence, domain packs + events.
|
|
88
|
+
|
|
89
|
+
A v1 or v2 store migrates itself on open (`ALTER TABLE ADD COLUMN` only — no table is rebuilt). From the old Python store, once:
|
|
75
90
|
|
|
76
91
|
```bash
|
|
77
92
|
memvault export --from data/memvault.db --out export.json
|
|
@@ -83,26 +98,47 @@ node scripts/backfill-core.mjs ~/.dsh/memvault/memvault.db --project-dir <checko
|
|
|
83
98
|
|
|
84
99
|
```mermaid
|
|
85
100
|
flowchart LR
|
|
86
|
-
T[turn/end] --> W[window]
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
T[turn/end] --> W[window]
|
|
102
|
+
W --> F[fact pass]
|
|
103
|
+
W --> K[six-class pass]
|
|
104
|
+
F --> S[(memories)]
|
|
105
|
+
K --> KB[(knowledge + evidence)]
|
|
106
|
+
S --> P[core blocks → prompt]
|
|
107
|
+
KB --> R[retrieval: used_count]
|
|
108
|
+
R --> PR[promotion → proposal]
|
|
109
|
+
PR --> H{human approves}
|
|
110
|
+
H --> B[(blocks)]
|
|
111
|
+
B --> P
|
|
112
|
+
D[domain packs] --> DS[score: path + markers]
|
|
113
|
+
DS --> P2[domain segment]
|
|
114
|
+
P2 --> G[gate open?]
|
|
115
|
+
G -->|yes| GUARD[guard refuses action tools]
|
|
116
|
+
GUARD --> GE[domain_gate records source]
|
|
117
|
+
GE --> P2
|
|
90
118
|
```
|
|
91
119
|
|
|
92
120
|
## 🧪 Verification
|
|
93
121
|
|
|
94
|
-
`npm test`
|
|
122
|
+
`npm test` — **384 smoke assertions + 124 unit tests**. Live: `/memvault/api/status` shows the last outcomes; `/memvault/api/{proposals,domain,knowledge,timeline}` are read-only views; replay via `POST /memvault/api/replay`; recall via `memory_search`.
|
|
123
|
+
|
|
124
|
+
The panel is rendered in tests too: the built bundle is loaded through the same `window.__ModuleLoader__` path the host uses, so a layout crash fails `npm test` instead of showing a blank tab after a restart.
|
|
95
125
|
|
|
96
126
|
## 🧠 Decisions
|
|
97
127
|
|
|
98
|
-
- **One store
|
|
128
|
+
- **One store** — no "tool saw it, panel didn't".
|
|
99
129
|
- **Supersede, never delete** — history keeps the audit.
|
|
100
|
-
- **
|
|
130
|
+
- **The human is the only approver** — no approval tool exists, and promotion produces a proposal rather than a write. An extractor that could self-approve would make the veto decorative.
|
|
131
|
+
- **Memory must not be able to break a turn** — injection is `interpolate:false`, so a `{{name}}` inside a memory cannot throw during assemble.
|
|
132
|
+
- **Domain packs never squeeze core blocks** — separate contribution and budget; no packs means an empty segment, byte-identical to 0.11 without the feature.
|
|
133
|
+
- **Gates block writes, never reads** — a gate must not block the research it is asking for; and it fails open on cold state, because refusing work over an empty cache is the worse failure.
|
|
134
|
+
- **A fixed-column map over a force layout** — the columns are the pipeline's meaning, and they read the same on every reload.
|
|
101
135
|
|
|
102
136
|
## ⚠️ Limits
|
|
103
137
|
|
|
104
138
|
- Single machine, single store: no sync, no encryption.
|
|
105
|
-
- Extraction quality depends on the extractor (rule is deterministic but narrow; LLM depends on the endpoint).
|
|
139
|
+
- Extraction quality depends on the extractor (rule is deterministic but narrow; LLM depends on the endpoint). The knowledge channel is a second model call per window — halve its frequency rather than folding the two questions into one prompt.
|
|
140
|
+
- A gate cannot stop a model that answers without calling a tool, or that writes through a path this plugin does not recognise as a write (a shell variant, a PTC script). It raises the floor, it is not a sandbox.
|
|
141
|
+
- Domain auto-activation needs `domain.probeDir`; keywords and tool arguments alone can only reach the hint band, never activate.
|
|
106
142
|
|
|
107
143
|
## 📄 License
|
|
108
144
|
|
package/README.zh.md
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
# dsh-memvault
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<strong
|
|
7
|
-
核心块进提示 ·
|
|
6
|
+
<strong>DeepSeek Harness 的长期记忆。</strong><br>
|
|
7
|
+
核心块进提示 · 回合与暗知识进一个 SQLite · 领域包 · 一块看板
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
10
|
<p align="center">
|
|
@@ -12,23 +12,25 @@
|
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
14
|
<p align="center">
|
|
15
|
-
<img alt="version" src="https://img.shields.io/badge/version-0.
|
|
15
|
+
<img alt="version" src="https://img.shields.io/badge/version-0.11.0-4a6cf7">
|
|
16
16
|
<img alt="license" src="https://img.shields.io/badge/license-MIT-30a46c">
|
|
17
17
|
<img alt="runtime deps" src="https://img.shields.io/badge/runtime%20deps-zero-888">
|
|
18
|
-
<img alt="node" src="https://img.shields.io/badge/node-%E2%89%
|
|
18
|
+
<img alt="node" src="https://img.shields.io/badge/node-%E2%89%A524.9-339933">
|
|
19
19
|
<img alt="stars" src="https://img.shields.io/github/stars/zhang66633/dsh-memvault?style=flat&color=e3b341">
|
|
20
20
|
</p>
|
|
21
21
|
|
|
22
22
|
---
|
|
23
23
|
|
|
24
|
-
MCP 只能拉不能推,所以「记忆已经加载好」不可能靠服务端实现。这个插件在 DSH
|
|
24
|
+
MCP 只能拉不能推,所以「记忆已经加载好」不可能靠服务端实现。这个插件在 DSH 内部做到它,并且自己拥有这个库:一个 SQLite 文件,没有 Python,没有第二个进程。
|
|
25
25
|
|
|
26
26
|
| 半边 | 做什么 | 机制 |
|
|
27
27
|
|---|---|---|
|
|
28
|
-
| **注入** |
|
|
29
|
-
| **抽取** |
|
|
28
|
+
| **注入** | 核心块 + 当前适用的领域包,每一步都在 | 两个 `ctx.systemPrompt.context()` 贡献 |
|
|
29
|
+
| **抽取** | 结束的回合 → 一个窗口 → 事实 **与** 暗知识各一次 | `session/event` → 窗口 → `add`/`supersede`/`none` |
|
|
30
30
|
| **召回** | `memory_search` / `memory_add` | FTS5 trigram + 向量,RRF,可答性守卫 |
|
|
31
|
-
|
|
|
31
|
+
| **进化** | `memory_propose` / `memory_pending`,人批准 | 提议队列 + 面板 |
|
|
32
|
+
| **强制** | 领域闸门在记录证据前拒绝动作工具 | `ctx.tools.guard()` |
|
|
33
|
+
| **查看** | 总览 / 注入 / 记忆 / 结构 / 进化 | 宿主路由 + 会话页签 / 设置页 |
|
|
32
34
|
|
|
33
35
|
## ✨ 特性
|
|
34
36
|
|
|
@@ -36,12 +38,14 @@ MCP 只能拉不能推,所以「记忆已经加载好」不可能靠服务端
|
|
|
36
38
|
|---|---|
|
|
37
39
|
| 🗄️ **一个库** | 提示、抽取、工具、面板都读 `~/.dsh/memvault/memvault.db` |
|
|
38
40
|
| 🧠 **不用调工具** | 块随运行时上下文注入,按 TTL 缓存 |
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
41
|
+
| 🧬 **只提议,不落写** | 模型能起草核心块修改,只有人能批准。**刻意不存在批准工具** |
|
|
42
|
+
| 🗂️ **领域包** | 某个垂直领域的背景知识,只在命中(路径 + 标记文件)或被显式激活时注入;详情按需 `domain_detail` |
|
|
43
|
+
| ✍️ **模型可以起草包** | `domain_draft` 只能写 `draft`、必须有来源、永远不能改写已批准的包 |
|
|
44
|
+
| ⛔ **会拒绝的闸门** | 未通过 `domain_gate` 记录 url + ≥40 字符引用前,write/edit/apply_patch/memory_add 被工具管线拒绝;读工具永不拦 |
|
|
45
|
+
| 🕸️ **六类暗知识** | 原因 · 契约 · 失败 · 依赖 · 解法 · 习惯 —— 独立 prompt、独立预算;重复出现变成更强证据,晋升只产出提议 |
|
|
46
|
+
| 📊 **一块看板** | 四个数、一张知识网络、一条流转时间线 |
|
|
47
|
+
| 🃏 **原生工具卡片** | `memory_search` / `memory_add` 在会话里渲染自己的卡片 |
|
|
48
|
+
| 🪶 **零运行时依赖** | `node:sqlite` + 手写客户端 bundle |
|
|
45
49
|
|
|
46
50
|
## 🚀 安装
|
|
47
51
|
|
|
@@ -49,29 +53,40 @@ MCP 只能拉不能推,所以「记忆已经加载好」不可能靠服务端
|
|
|
49
53
|
dsh plugin --profile desktop add dsh-memvault
|
|
50
54
|
```
|
|
51
55
|
|
|
52
|
-
|
|
56
|
+
本地自持安装会在 profile 的 `package.json` 里链接 checkout(`dsh-memvault: link:…`),并在 `node_modules` 下建 junction——见 `docs/DEVLOG.md`。新 bundle 需要 **重启 DSH**;改完客户端先 `npm run build`。
|
|
53
57
|
|
|
54
|
-
要求 DSH **0.2.1
|
|
58
|
+
要求 DSH **0.2.1+**,已在 **0.2.2-rc.5** 上验证(`engines.dsh` 显式写了 0.2.2 这条线,因为对严格 semver 来说,裸的 `>=0.2.1-0 <0.3.0-0` 不含 `0.2.2-rc.5`;`>=0.2.2-0` 覆盖整条 0.2.2 预发布线)。Node 要求 **24.9+**:那是 DSH 0.2.2 的运行时下限,本插件用到 Node 24 的 `DatabaseSync` busy-timeout。工具卡片、非插值注入、`ctx.tools.guard()`、会话关闭时抽取都是 0.2.2 的能力;在 0.2.1 上退化为旧行为。
|
|
55
59
|
|
|
56
60
|
## ⚙️ 配置
|
|
57
61
|
|
|
58
|
-
| 字段 |
|
|
62
|
+
| 字段 | 默认 |
|
|
59
63
|
|---|---|
|
|
60
64
|
| `scopes` | `[{user,lenovo},{agent,claude-code-memory}]` |
|
|
61
65
|
| `labels` / `maxChars` / `refreshMs` | `[]` / `4000` / `30000` |
|
|
62
66
|
| `extract.everyNTurns` / `idleMs` / `windowTurns` | `3` / `20000` / `8` |
|
|
63
|
-
| `extract.timeoutMs` | `60000
|
|
64
|
-
| `extract.minTranscriptChars` / `maxInputChars` | `40` / `6000` |
|
|
67
|
+
| `extract.timeoutMs` / `minTranscriptChars` / `maxInputChars` | `60000` / `40` / `6000` |
|
|
65
68
|
| `extract.projectDir` / `env` | 自动发现的 `.env` 目录 / `{}` |
|
|
69
|
+
| `extract.knowledge.enabled` | `true`——六类暗知识通道 |
|
|
70
|
+
| `extract.knowledge.includeAssistant` / `includeTools` | `true` / `true`(事实通道保持关闭) |
|
|
71
|
+
| `extract.knowledge.maxInputChars` | `8000`(与事实通道预算独立) |
|
|
72
|
+
| `extract.knowledge.promotion.minUsed` / `minEvidence` | `3` / `2` |
|
|
73
|
+
| `domain.enabled` / `maxDomains` | `true` / `2` |
|
|
74
|
+
| `domain.indexChars` / `maxChars` / `refreshMs` | `480` / `1000` / `10000` |
|
|
75
|
+
| `domain.probeDir` | `''`——留空则不做文件探测,只剩关键词、工具参数与显式激活 |
|
|
76
|
+
| `domain.thresholdPct` | `100`(= 分数 1.0;路径 + 一个标记文件 = 1.1) |
|
|
77
|
+
| `domain.gate.enabled` / `tools` / `minQuote` / `maxAgeHours` | `true` / write,edit,apply_patch,memory_add / `40` / `24` |
|
|
78
|
+
| `domain.draftHint` / `maxPacks` | `true` / `20` |
|
|
66
79
|
| `panel.writes` | `true` |
|
|
67
80
|
|
|
68
|
-
|
|
81
|
+
库路径不通过插件配置(`~/.dsh/memvault/memvault.db`,或 `DSH_MEMVAULT_CORE_DB`)。`projectDir` 只用来找 `.env`,不启动任何进程。管线读取常见的 `.env` 键(`OPENAI_*`、`MEMVAULT_EXTRACTOR=rule|llm`、`MEMVAULT_EMBEDDER=local|openai`、`MEMVAULT_ADJUDICATOR=off`)。
|
|
69
82
|
|
|
70
|
-
|
|
83
|
+
过时的 patch 若还设置已删除的键(`dbPath`、`extract.pythonPath`、`extract.user/agent/run`),面板会显示为「未声明的键」而不是静默无效。写入作用域由 `scopes` 推导(第一个 user → `user_id`,第一个 agent → `agent_id`)。
|
|
71
84
|
|
|
72
|
-
## 🗄️
|
|
85
|
+
## 🗄️ 库与迁移
|
|
73
86
|
|
|
74
|
-
`~/.dsh/memvault/memvault.db`(可用 `DSH_MEMVAULT_CORE_DB`
|
|
87
|
+
`~/.dsh/memvault/memvault.db`(可用 `DSH_MEMVAULT_CORE_DB` 覆盖)。Schema **v3**:块 + 历史、记忆(FTS5 + 向量)、关系、检索记录、块提议、知识与证据、领域包与事件。
|
|
88
|
+
|
|
89
|
+
v1/v2 的库在打开时自动迁移(只做 `ALTER TABLE ADD COLUMN`,不重建表)。从旧 Python 库一次性导入:
|
|
75
90
|
|
|
76
91
|
```bash
|
|
77
92
|
memvault export --from data/memvault.db --out export.json
|
|
@@ -83,27 +98,48 @@ node scripts/backfill-core.mjs ~/.dsh/memvault/memvault.db --project-dir <checko
|
|
|
83
98
|
|
|
84
99
|
```mermaid
|
|
85
100
|
flowchart LR
|
|
86
|
-
T[turn/end] --> W[窗口]
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
T[turn/end] --> W[窗口]
|
|
102
|
+
W --> F[事实通道]
|
|
103
|
+
W --> K[六类暗知识通道]
|
|
104
|
+
F --> S[(memories)]
|
|
105
|
+
K --> KB[(knowledge + evidence)]
|
|
106
|
+
S --> P[核心块 → 提示]
|
|
107
|
+
KB --> R[检索命中 used_count]
|
|
108
|
+
R --> PR[晋升 → 提议]
|
|
109
|
+
PR --> H{人批准}
|
|
110
|
+
H --> B[(blocks)]
|
|
111
|
+
B --> P
|
|
112
|
+
D[领域包] --> DS[打分: 路径 + 标记文件]
|
|
113
|
+
DS --> P2[领域段]
|
|
114
|
+
P2 --> G{闸门开?}
|
|
115
|
+
G -->|是| GUARD[守卫拒绝动作工具]
|
|
116
|
+
GUARD --> GE[domain_gate 记录来源]
|
|
117
|
+
GE --> P2
|
|
90
118
|
```
|
|
91
119
|
|
|
92
120
|
## 🧪 验证
|
|
93
121
|
|
|
94
|
-
`npm test
|
|
122
|
+
`npm test` —— **384 条 smoke 断言 + 124 条单测**。运行时:`/memvault/api/status` 显示最近结果;`/memvault/api/{proposals,domain,knowledge,timeline}` 是只读视图;`POST /memvault/api/replay` 重放;`memory_search` 召回。
|
|
123
|
+
|
|
124
|
+
面板也进了测试:用宿主同一条 `window.__ModuleLoader__` 路径加载构建产物并真实渲染,所以布局崩溃会让 `npm test` 失败,而不是重启后看到一个白屏页签。
|
|
95
125
|
|
|
96
|
-
## 🧠
|
|
126
|
+
## 🧠 决策
|
|
97
127
|
|
|
98
|
-
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
128
|
+
- **只有一个库**——不会出现「工具看到了、面板没看到」。
|
|
129
|
+
- **只 supersede,不删除**——历史留着审计。
|
|
130
|
+
- **只有人能批准**——不存在批准工具,晋升产出的是提议而不是写入。能让抽取器自批的设计,会让人否决权变成摆设。
|
|
131
|
+
- **记忆不许搞崩回合**——注入是 `interpolate:false`,块里的 `{{name}}` 不会在 assemble 时抛错。
|
|
132
|
+
- **领域包绝不挤占核心块**——独立贡献、独立预算;没有包时段为空,与未启用该功能时逐字节一致。
|
|
133
|
+
- **闸门只拦写、不拦读**——闸门不能拦住它要求的调研;冷状态放行,因为「缓存空就拒绝一切」是更糟的失败。
|
|
134
|
+
- **固定列地图而不是力导向**——列本身是管线的含义,每次刷新读法一致。
|
|
101
135
|
|
|
102
136
|
## ⚠️ 边界
|
|
103
137
|
|
|
104
|
-
-
|
|
105
|
-
-
|
|
138
|
+
- 单机单库:不同步、不加密。
|
|
139
|
+
- 抽取质量取决于抽取器(规则确定但窄;LLM 取决于端点)。知识通道是每窗口**第二次**模型调用——嫌贵应当降频,而不是把两类问题并回一个 prompt。
|
|
140
|
+
- 闸门拦不住「不调工具直接回答」的模型,也拦不住它用本插件不识别为写入的路径写盘(某条 shell 变体、PTC 脚本)。它抬高下限,不是沙箱。
|
|
141
|
+
- 领域自动激活需要 `domain.probeDir`;只有关键词与工具参数最多进入提示带,永远不会激活。
|
|
106
142
|
|
|
107
|
-
## 📄
|
|
143
|
+
## 📄 License
|
|
108
144
|
|
|
109
145
|
MIT
|
package/cordis.patch.yml
CHANGED
|
@@ -55,3 +55,26 @@
|
|
|
55
55
|
timeoutMs: 60000
|
|
56
56
|
# 含 .env 的目录;留空 = 自动发现(先看 MEMVAULT_DIR,再看库目录与常见位置)
|
|
57
57
|
projectDir: 'D:/Claude_code/memory'
|
|
58
|
+
# 垂直领域包(0.11 P2):只在该领域真的适用时,把一段「背景规则」注入第二个
|
|
59
|
+
# context 段(`memvault:domain`,order 215)。包本身存在库里、要人批准 active 才会注入;
|
|
60
|
+
# 详情永不注入,模型需要时用 `domain_detail` 读。
|
|
61
|
+
domain:
|
|
62
|
+
enabled: true
|
|
63
|
+
maxDomains: 2
|
|
64
|
+
indexChars: 480
|
|
65
|
+
maxChars: 1000
|
|
66
|
+
# 探测哪个目录的标记文件(project.godot / scene.blend / package.json 等)。
|
|
67
|
+
# 留空 = 不做文件探测,只剩关键词、工具参数与显式激活三种信号。
|
|
68
|
+
probeDir: 'D:/_Projects'
|
|
69
|
+
# 自动激活阈值(百分比):路径 + 一个标记文件 = 110,刚好过线;只有关键词永远过不了。
|
|
70
|
+
thresholdPct: 100
|
|
71
|
+
refreshMs: 10000
|
|
72
|
+
# 领域包上限:满了以后模型不能再起草新包,等人先审。
|
|
73
|
+
maxPacks: 20
|
|
74
|
+
# gate:包里声明的「开工前置条件」用 ctx.tools.guard() 硬拦。
|
|
75
|
+
# 这是本插件唯一能真正拒绝调用的机制;只拦动作工具,读工具一律放行。
|
|
76
|
+
gate:
|
|
77
|
+
enabled: true
|
|
78
|
+
blockBashWrites: true
|
|
79
|
+
minQuote: 40
|
|
80
|
+
maxAgeHours: 24
|
package/docs/CORE-DESIGN.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> 目标:Python 引擎退役后,插件自带**存储、抽取、检索**三件事,装一个插件即完整功能。
|
|
4
4
|
> 旧库 `data/memvault.db` 导出成 JSON 后归档,新库按本文结构重建。
|
|
5
|
-
> 状态:**M0–M3 检索 + 工具定义已实现**(`lib/core/`,测试 `test/core*.test.mjs`);M4 对齐 DSH 0.2.2
|
|
5
|
+
> 状态:**M0–M3 检索 + 工具定义已实现**(`lib/core/`,测试 `test/core*.test.mjs`);M4 对齐 DSH 0.2.2,实测目标 **0.2.2-rc.5**(见 DEVLOG §46 / §48)。
|
|
6
6
|
> 注入层的两条硬约束记在这里:注入文本是记忆内容,注册时必须 `interpolate: false`(否则记忆里的 `{{…}}`
|
|
7
7
|
> 会让 `assemble()` 抛错、整次请求失败)且 `required: true`(长时记忆不被 `suppressRuntimeContext()` 静默丢弃)。
|
|
8
8
|
|
|
@@ -84,6 +84,15 @@ erDiagram
|
|
|
84
84
|
| 复核标记在插件状态文件 | `flags` 表 | 队列随数据走,导出即带走 |
|
|
85
85
|
| 无 schema 版本 | `meta.schema_version` | 迁移有据可依 |
|
|
86
86
|
|
|
87
|
+
> **v2(0.11 P0,2026-11-29)**:上面是 v1。v2 **只增不改**,新增 `block_proposals`、
|
|
88
|
+
> `blocks_history`、`knowledge`、`knowledge_evidence`、`retrievals`、`domains`、`domain_events`
|
|
89
|
+
> 七张表,v1 的表与 CHECK 一行未动——`memory_type` 的三值域与 `history.action` 的五值域
|
|
90
|
+
> 装不下新语义,而 SQLite 改不了 CHECK,所以新语义一律住新表。
|
|
91
|
+
> 唯一的数据迁移是给既有块补 `blocks_history(action='migrate')` 的 before-image。
|
|
92
|
+
> 设计与验收见 [PLAN-0.11.md](PLAN-0.11.md),实做记录见 [DEVLOG.md](DEVLOG.md) §49。
|
|
93
|
+
> 已知遗留:`store.flags` 表**零调用方**(面板实际用的是 state 文件),P4 收敛;
|
|
94
|
+
> `relations.kind` 的 `contradicts` / `supersedes` 也还没有写入方。
|
|
95
|
+
|
|
87
96
|
### 2.2 DDL(`node:sqlite` 直接可跑)
|
|
88
97
|
|
|
89
98
|
```sql
|