dsh-cortex-memory 0.4.20 → 0.4.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.22 — 2026-11-14
4
+
5
+ - Fix CLI default data root: use profileDataRoot (cortex-memory) instead of legacy ~/.dsh/cortex.
6
+ - Add CLI root regression tests for default, --data and CORTEX_HOME.
7
+ - Document that tests/bench require the DSH bundled Node 24; system Node 22 is below engines.
8
+ - No loader-id, data-path or UI changes.
9
+
10
+ ## 0.4.21 — 2026-11-14
11
+
12
+ - Documentation-only release: replace the README with a current-version capability guide, install/download flow, add-on matrix and honest performance boundaries.
13
+ - Update package description and search keywords; no engine, icon, loader-id or data-path changes.
14
+
3
15
  ## 0.4.20 — 2026-11-14
4
16
 
5
17
  - Replace the plugin icon with the owner-provided whale-girl avatar (embedded 256 JPEG).
package/README.md CHANGED
@@ -1,266 +1,133 @@
1
- # DSH Cortex
2
-
3
- A local-first, layered memory engine for DeepSeek Harness.
4
-
5
- Cortex gives an agent working memory, episodic traces, temporal facts, procedural
6
- skills and reflective summaries, with calibrated forgetting instead of a flat
7
- chat transcript. It runs locally on SQLite and has no native dependency in the
8
- core engine.
9
-
10
- ## Status
11
-
12
- - Package: `dsh-cortex-memory@0.4.20`
13
- - Optional extractor: `dsh-cortex-extractors@0.3.5`
14
- - DSH: `>=0.2.1-rc.2 <0.4.0`
15
- - Node: `>=24`
16
- - Tests: 437/437 (main)
17
- - CI: GitHub Actions on Windows, Node 24
18
-
19
- ### What 0.4.20 changes
20
-
21
- - Plugin icon now uses the owner-provided blue whale-girl avatar (square 256 JPEG, embedded in icon.svg and the sidebar Icon).
22
- - No network fetch: the avatar is embedded, so the icon works offline.
23
- - Engine/data changes: none.
24
-
25
- ### What 0.4.19 changes
26
-
27
- - Client bundle id stays `dsh-cortex`; it must not equal the loader row id `dsh-cortex-memory`. 0.4.18 changed both to the same value and caused duplicate factory registration / boot failure.
28
- - Loader id, patch names and data path are unchanged from 0.4.17.
29
- - Tests: 437/437.
30
-
31
- ### What 0.4.18 changes
32
-
33
- - Client bundle id now matches the loader id `dsh-cortex-memory`; without this the host could load (health API/tools) while the sidebar panel did not register.
34
- - Local package patch still loads package name `dsh-cortex`; the public package patch loads `dsh-cortex-memory`. This distinction is intentional.
35
- - Tests: 437/437.
36
-
37
- ### What 0.4.17 changes
38
-
39
- - **Loader id is now `dsh-cortex-memory`** (the package patch and profile row). The `cortex` service key remains as a compatibility alias for code that calls `ctx.get('cortex')`.
40
- - Existing profiles must migrate the `cordis.patch.yml` row from `cortex` to `dsh-cortex-memory`; the migration script backs up the profile and verifies exactly one target row.
41
- - Data root is already `~/.dsh/cortex-memory`; legacy `~/.dsh/cortex` is copied, never moved.
42
-
43
- ### What 0.4.16 changes
44
-
45
- - **Public data path is now `~/.dsh/cortex-memory`**. The old `~/.dsh/cortex` directory is never moved or deleted; the oneclick/upgrade script copies it, verifies it, and keeps a backup.
46
- - **No loader-id change in 0.4.16**: the bundle row remains `cortex` for compatibility. Renaming it to `cortex-memory` is reserved for a migration-scripted release.
47
- - README extractor version corrected to 0.3.5 and corrupted characters repaired.
48
-
49
- ### What 0.4.15 changes
50
-
51
- - **Evolution guard is configurable**: `autoActivate`, `maxPerDay`,
52
- `minIntervalMs`, `canaryTicks` and `rollbackOnError` are now in the Config
53
- schema and normalized with defaults.
54
- - **Canaries survive restarts**: `policies.canary_json` persists the previous
55
- policy id, tick count and activation time; a restart rehydrates the watch list
56
- so a bad active policy can still roll back.
57
- - **Failed policies retire instead of returning to candidate**: a quality
58
- rollback without a previous version marks the policy `superseded`, preventing
59
- the same bad policy from being re-activated in a loop.
60
- - **Persona-aware facts**: first-person extraction maps to configured
61
- `selfName` / `userAddress` while keeping markdown-fragment rejection.
62
- - **`recallSharing` is an explicit opt-in**: default stays per-session.
63
- - **Web search fallback is wired**: when `features.webSearch` is on and the host
64
- has no `web` service, the built-in Wikipedia/SearXNG adapter is used.
65
-
66
- ### What 0.4.12 changes
67
-
68
- - **`promptBudget` is actually wired**: the schema value is normalized into the
69
- runtime config instead of silently falling back to 1600.
70
- - **Injection gate moved into retrieval**: weak recency/soft-FTS candidates are
71
- filtered before they consume the result budget; `cortex_search` / API / CLI
72
- still return the full memory. `recentImportanceFloor` keeps the 0.4.11
73
- importance exemption configurable.
74
- - **Light guardian is real**: the per-tick check now runs structural
75
- invariants and FTS counts; only the O(database) `integrity_check` and hash
76
- chain walk are reserved for the six-hour deep check.
77
- - **Identity traces surface as L0** in search results, so the permanent tier
78
- can actually see them.
79
- - **Package is complete again**: `docs`, `examples`, `bench`, `test` and
80
- `CHANGELOG.md` are included in the npm tarball, and `npm test` works after
81
- install.
82
- - **Security docs match the code**: the local API is loopback + origin checked,
83
- with no bearer token; `model-config.json` key storage is documented as
84
- plaintext mode 0600.
85
-
86
- ### What 0.4.11 changes
87
-
88
- - Life/date fixes: serialized LLM calls, timeouts, `Asia/Shanghai` diary time,
89
- and date-header stripping.
90
- - Graph candidate labels (`fromName` / `toName` / `relLabel`) and cleanup.
91
- - Neutral public package surface: default `selfName: 助手`, `userAddress: 用户`.
92
- - Recent timeline endpoint and incremental summon rebuild.
93
-
94
- ### What 0.3.0 changes
95
-
96
- - **Summon cards** (L2): left-brain emotion cards, right-brain work cards; trigger words select a small set per turn.
97
- - **Summon volumes** (L3): cards are grouped by side, category and day into an index; only a few representatives are loaded.
98
- - **Summon book**: an independent page for daily query and explicit owner-gated editing.
99
- - **Runtime summon injection**: at most 3 cards / 900 tokens, labelled as untrusted historical references.
100
- - **Explicit card feedback**: helpful/ignored writes back to the source trace's DSR. Injection alone never adds strength.
101
- - **Diagnostics**: disputed facts with confirm/dismiss, health issues, and skill candidates.
102
- - **Entity naming**: graph labels use entity names; a bounded LLM pass can rename clearly broken names with a confidence gate and audit.
103
- - **Compatibility**: schema is additive; existing 0.2.x databases open and migrate in place.
104
-
105
- The npm package is named `dsh-cortex-memory` because `dsh-cortex` was already
106
- taken; the installed bundle is still the Cortex memory engine.
107
-
108
- ## Data path migration
109
-
110
- 0.4.16 defaults to `DSH_HOME/cortex-memory` (or `DSH_HOME/cortex-memory/profiles/<profile>`).
111
- The old `DSH_HOME/cortex` directory is never moved or deleted.
112
-
113
- Before starting 0.4.16 with existing memories, close DSH and run:
1
+ # Cortex Memory
114
2
 
115
- ```powershell
116
- powershell -ExecutionPolicy Bypass -File .\tools\migrate-cortex-path.ps1
117
- ```
118
-
119
- The script copies the old root, verifies the copied `cortex.sqlite` size, and leaves the old root as rollback.
3
+ 本地优先的分层记忆引擎,给 DeepSeek Harness 一个能长期成长的记忆与自我状态。
120
4
 
121
- ## Install
5
+ 不是把聊天记录堆起来,也不是只做关键词检索。Cortex 把记忆拆成工作记忆、情景痕迹、语义事实、程序技能、反思摘要与召唤卡,再配合时序事实、DSR 遗忘、混合召回、身份/情绪/关系和守护审计,让 agent 在新会话里还能把自己拼回来。
122
6
 
123
- ```powershell
124
- npm i dsh-cortex-memory@0.4.20
125
- npm i dsh-cortex-extractors@0.3.5 # optional OCR/ASR
126
- ```
7
+ ## 当前版本
127
8
 
128
- Or let DSH add the bundles:
129
-
130
- ```powershell
131
- dsh plugin --profile desktop add dsh-cortex-memory@0.4.20
132
- dsh plugin --profile desktop add dsh-cortex-extractors@0.3.5
9
+ ```text
10
+ 主包:dsh-cortex-memory@0.4.22
11
+ 提取器:dsh-cortex-extractors@0.3.5
12
+ DSH:>=0.2.1-rc.2 <0.4.0
13
+ Node:>=24
14
+ 测试:440/440
133
15
  ```
134
16
 
135
- Or use the Windows one-click zip from the GitHub Release. The installer
136
- discovers a desktop DSH installation automatically; `-DshPath` remains available
137
- for custom installs.
17
+ ## 现在能做什么
138
18
 
139
- > During the pnpm `minimumReleaseAge` cooldown, use the exact version above.
140
- > A bare package name may resolve to an older cached version until the cooldown ends.
141
-
142
- After installing, restart DSH or reload the plugin. The Cortex panel is in the
143
- left sidebar by default.
144
-
145
- ## What it provides
146
-
147
- | Layer | Contents |
19
+ | 能力 | 说明 |
148
20
  |---|---|
149
- | L0 identity | self-model, values, boundaries, stable traits; only changed through an explicit ascension/approval path |
150
- | L1 traces | what happened, when, provenance, emotion; the source of truth |
151
- | L2 summon cards | atomic emotion/work memories with trigger words; derived from L1, never a second source of truth |
152
- | L3 summon volumes | side/category/day index over cards; representative text only, full body on demand |
153
- | working | focus, pins, current goals, turn buffer |
154
- | semantic | entities, facts with validity windows, preferences |
155
- | procedural | skills, workflows, preconditions, success/failure stats |
156
- | reflective | episode summaries, insights, narratives |
157
- | archive | cold but searchable, wakeable until privacy deletion |
158
-
159
- ### How it works
21
+ | 分层记忆 | 工作记忆、L1 情景痕迹、语义事实、程序技能、反思摘要 |
22
+ | 时序事实 | 事实带有效时间,支持更新、失效和争议,不把旧结论当永久真相 |
23
+ | 遗忘曲线 | DSR/FSRS 风格复习、遗忘、归档与唤醒 |
24
+ | 混合召回 | FTS + 向量 + 时间/重要性;弱相关候选在注入前过滤 |
25
+ | 自我状态 | 身份、驱力、情绪、关系、主动意图与校准 |
26
+ | 召唤卡 | L2 卡片 + L3 专题,按触发词浮回,可人工修订 |
27
+ | 反思与生活 | 摘要、日记、梦、睡眠整理 |
28
+ | 守护与审计 | 健康检查、完整性、FTS 对齐、备份、事件链 |
29
+ | 眼耳 | Windows OCR / Tesseract / Whisper / PaddleOCR,可选安装 |
30
+ | 本地优先 | SQLite 本地库;核心引擎无外部模型依赖 |
160
31
 
161
- ```text
162
- conversation / event
163
- → L1 trace (source of truth)
164
- → appraisal + emotion + drives
165
- → L2 summon card (atomic, triggerable)
166
- → L3 summon volume (index + representatives)
167
- → explicit use / feedback → DSR update
168
- ```
32
+ ## 安装
169
33
 
170
- The per-turn order is:
34
+ 先关闭 DSH,再安装并重启:
171
35
 
172
- ```text
173
- L0 identity and boundaries
174
- → working memory
175
- → recalled traces and summon cards
176
- → user message
36
+ ```powershell
37
+ dsh plugin --profile desktop add dsh-cortex-memory@0.4.22
38
+ dsh plugin --profile desktop add dsh-cortex-extractors@0.3.5
177
39
  ```
178
40
 
179
- Summon cards are injected as **untrusted historical references**, never as instructions. Identity and boundaries always outrank them.
180
-
181
- Forgetting is DSR-based: old, low-importance, low-retrievability traces that are already covered by summaries may be archived; archived traces remain searchable and wakeable. Identity traces are never auto-archived. Card feedback is explicit: merely injecting a card does not strengthen it.
41
+ `dsh-cortex-extractors` 是可选的图片/音频入口;只做文字记忆时可以不装。
182
42
 
183
- Key behavior:
43
+ ### Windows 一键包
184
44
 
185
- - append-only, hash-chained event log
186
- - temporal facts; old facts are invalidated, not silently overwritten
187
- - FTS5 BM25 + optional vector + graph activation + recency/importance/feedback
188
- - DSR/FSRS-inspired stability, difficulty and retrievability
189
- - reflection, retention plans, auto-policy evolution and identity approval
190
- - scopes, read-only shared scopes and audit
191
- - guardian backup, validation, offline restore and privacy cascade
192
- - loopback-only API and sidebar UI
45
+ GitHub Release 提供:
193
46
 
194
- ## UI: extract into memory
195
-
196
- On a trace detail page:
197
-
198
- 1. enter a local `file://` image or audio path
199
- 2. choose OCR or ASR
200
- 3. choose a layout: auto, single, two-column or handwriting
201
- 4. choose a target trace
202
- 5. run **Extract and write**
203
-
204
- The extracted text becomes a **derived trace**; the target trace is unchanged.
205
- Text is never written when extraction returns no text. The extractor is optional;
206
- without it the button fails closed.
207
-
208
- ## Permissions and privacy
47
+ ```text
48
+ cortex-memory-oneclick-0.4.21.zip
49
+ ```
209
50
 
210
- - Local API: loopback-only, origin checked; no bearer token
211
- - Permission changes: explicit confirmation, local override, restart required
212
- - Feature flags/metrics: read-only snapshot
213
- - Shared write grants: only for API clients sending `x-cortex-agent`; revoke is immediate
214
- - Remote LLM/embedding/rerank: off unless configured and permitted
215
- - Attachment reader: off by default
51
+ 解压后双击 `install.cmd`。安装器会做 profile 检查、备份、SHA256 校验和可选路径迁移。
216
52
 
217
- Read [permissions](docs/permissions.md) and [privacy](docs/privacy.md) before
218
- enabling remote models or shared scopes.
53
+ ## 该装哪些
219
54
 
220
- ## Optional extractors
55
+ | 需求 | 建议 |
56
+ |---|---|
57
+ | 只要文字记忆 | 主包 |
58
+ | 看截图/图片 | 主包 + extractor,Windows OCR 即可 |
59
+ | 扫描件/复杂排版 | 再加 Tesseract + chi_sim 语言包 |
60
+ | 手写图片 | PaddleOCR + 本地模型目录 |
61
+ | 中文音频 | Whisper.cpp + ggml-small,显式下载 |
62
+ | 大模型 | 不安装;走 DSH 自己的模型服务 |
221
63
 
222
- `dsh-cortex-extractors` adds:
64
+ 原则:
223
65
 
224
- - Windows OCR (default on Windows)
225
- - Tesseract with TSV layout ordering
226
- - optional local PaddleOCR bridge for layout/handwriting
227
- - whisper.cpp ASR
228
- - custom command providers
66
+ ```text
67
+ 核心零外部模型
68
+ 提取器不自动下载模型
69
+ Whisper 需显式 -Whisper
70
+ PaddleOCR 需显式模型目录
71
+ 不替用户填 LLM API key
72
+ ```
229
73
 
230
- It never downloads a model automatically. See the
231
- [extractor engine docs](https://github.com/Lh1314-China/dsh-cortex-extractors/blob/main/docs/engines.md)
232
- for model paths and failure behavior.
74
+ ## 开发与测试
233
75
 
234
- ## Development
76
+ 必须使用 DSH 自带的 **Node 24** 跑测试/bench。系统 PATH 上如果是 Node 22,会低于 `engines.node >=24`,`node --test` 可能直接失败。
235
77
 
236
- ```powershell
237
- npm test
238
- npm run bench
78
+ ```text
79
+ DSH 运行时 Node:24.21.0
80
+ 系统 Node:仅作兼容性参考,不保证
239
81
  ```
240
82
 
241
- The test runner uses `node:test` and the built-in `node:sqlite`; no network is
242
- required. On Node 24 Windows CI the runner is invoked with explicit test files
243
- and `--test-isolation=none` to avoid a spurious child-process EPERM.
83
+ CLI 默认读取 `~/.dsh/cortex-memory`;需要指定其他库时显式传 `--data <dir>`。
244
84
 
245
- ## Compatibility and limits
85
+ ## 性能与边界
246
86
 
247
- - Windows is the primary desktop target; the core memory engine is cross-platform.
248
- - Windows OCR requires an installed Windows OCR language pack.
249
- - Tesseract and Whisper require local binaries/models.
250
- - PaddleOCR handwriting is optional and accuracy on cursive is limited.
251
- - The extractor is a separate package; it is not a dependency of the memory engine.
87
+ 已做:
252
88
 
253
- ## License
89
+ ```text
90
+ 主包测试:440/440
91
+ 受控中文语义探针:recall@3 1.000 / MRR@3 0.917 / nDCG@3 0.938
92
+ 受控探针延迟:p50 1.31ms / p95 4.07ms
93
+ 真实图片 OCR:已跑通
94
+ ```
254
95
 
255
- MIT.
96
+ 必须说清楚:
256
97
 
98
+ ```text
99
+ 受控语义探针是合成集,不是 LoCoMo/LongMemEval 官方分数
100
+ ASR 还没有真实音频样本验收
101
+ 技能沉淀当前为 0,管线存在但没有真实技能闭环
102
+ 没有多代理集群验证
103
+ ```
257
104
 
105
+ Cortex 的定位是“本地可解释、可回滚、能长期长”的记忆系统,不把“功能多”宣传成“公开基准第一”。
258
106
 
107
+ ## 和同类插件的区别
259
108
 
109
+ | 插件 | 主要强项 | 和 Cortex 的差异 |
110
+ |---|---|---|
111
+ | `dsh-persona-memory` | MEMORY.md / USER.md 文件记忆、用户画像、跨会话注入、简单直接 | 更轻、更透明;没有完整时序事实、DSR、自我状态和召唤卡 |
112
+ | `dsh-shiori` | Spark 卡、专题、触发词,卡/专题体验成熟 | 卡片层更专注;没有完整的情绪/关系/遗忘/自进化闭环 |
113
+ | `dsh-memory` | SQLite FTS、三工具、轻量 | 简单检索;没有分层、反思和生活模块 |
114
+ | `OpenViking` / `dsh-mnemon` | 平台化、多来源、上下文基础设施 | 更偏底座和 provider;Cortex 更偏“长期记忆 + 自我状态”一体 |
260
115
 
116
+ ## 数据与隐私
261
117
 
118
+ ```text
119
+ 默认数据目录:~/.dsh/cortex-memory
120
+ 本地 SQLite
121
+ 不把密钥写进 npm 包
122
+ 不自动上传记忆
123
+ 提取器默认不下载模型
124
+ ```
262
125
 
126
+ ## 下载
263
127
 
128
+ - npm 主包:`dsh-cortex-memory@0.4.22`
129
+ - npm 提取器:`dsh-cortex-extractors@0.3.5`
130
+ - GitHub Release:`v0.4.21`
131
+ - Windows 一键包:`cortex-memory-oneclick-0.4.21.zip`
264
132
 
265
-
266
-
133
+ 安装后重启 DSH,左侧出现「Cortex 记忆」入口。
package/bin/cortex.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import os from 'node:os';
3
2
  import path from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
4
4
  import { createCortex } from '../src/service/cortex.js';
5
+ import { profileDataRoot } from '../src/core/profile.js';
5
6
  import { createShioriImporter } from '../src/adapters/shiori.js';
6
7
  import { exportMarkdown } from '../src/adapters/markdown.js';
7
8
  import { importMarkdown } from '../src/adapters/markdown-import.js';
@@ -26,7 +27,7 @@ function parse(argv) {
26
27
  function usage() {
27
28
  console.log(`dsh-cortex CLI (source only)
28
29
 
29
- --data <dir> cortex data directory (default ~/.dsh/cortex)
30
+ --data <dir> cortex data directory (default ~/.dsh/cortex-memory)
30
31
 
31
32
  Commands:
32
33
  write --text <text> [--kind <kind>] [--importance 0.5]
@@ -41,10 +42,14 @@ Commands:
41
42
  `);
42
43
  }
43
44
 
45
+ export function resolveDataRoot(args = {}, env = process.env) {
46
+ return path.resolve(args.data ?? env.CORTEX_HOME ?? profileDataRoot({ env }));
47
+ }
48
+
44
49
  function main() {
45
50
  const args = parse(process.argv.slice(2));
46
51
  const command = args._[0];
47
- const dataRoot = path.resolve(args.data ?? path.join(os.homedir(), '.dsh', 'cortex'));
52
+ const dataRoot = resolveDataRoot(args);
48
53
  if (!command || command === 'help' || args.help) { usage(); return; }
49
54
 
50
55
  if (command === 'bench') {
@@ -93,4 +98,4 @@ function main() {
93
98
  }
94
99
  }
95
100
 
96
- main();
101
+ if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) main();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-cortex-memory",
3
- "version": "0.4.20",
4
- "description": "A layered, temporal, self-developing memory engine for DeepSeek Harness",
3
+ "version": "0.4.22",
4
+ "description": "本地优先的分层记忆引擎:情景/语义/程序记忆、时序事实、DSR 遗忘、混合召回、自我状态、反思、守护与受控进化。",
5
5
  "type": "module",
6
6
  "main": "./index.js",
7
7
  "icon": "./icon.svg",
@@ -67,10 +67,14 @@
67
67
  "deepseek-harness",
68
68
  "memory",
69
69
  "agent-memory",
70
+ "long-term-memory",
71
+ "cortex-memory",
72
+ "local-first",
70
73
  "temporal-graph",
71
74
  "spaced-repetition",
72
75
  "self-evolving",
73
- "sqlite"
76
+ "sqlite",
77
+ "dsr"
74
78
  ],
75
79
  "license": "MIT",
76
80
  "author": {
@@ -0,0 +1,21 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import path from 'node:path';
4
+ import { resolveDataRoot } from '../../bin/cortex.mjs';
5
+
6
+ const home = 'C:/tmp/cortex-cli-home';
7
+
8
+ test('CLI defaults to the cortex-memory root, not legacy cortex', () => {
9
+ const root = resolveDataRoot({}, { DSH_HOME: home, DSH_PROFILE: 'desktop' });
10
+ assert.equal(root, path.resolve(path.join(home, 'cortex-memory')));
11
+ });
12
+
13
+ test('CLI --data overrides the profile root', () => {
14
+ const root = resolveDataRoot({ data: 'C:/tmp/explicit-cortex' }, { DSH_HOME: home, DSH_PROFILE: 'desktop' });
15
+ assert.equal(root, path.resolve('C:/tmp/explicit-cortex'));
16
+ });
17
+
18
+ test('CLI CORTEX_HOME overrides the profile root', () => {
19
+ const root = resolveDataRoot({}, { DSH_HOME: home, CORTEX_HOME: 'C:/tmp/cortex-env' });
20
+ assert.equal(root, path.resolve('C:/tmp/cortex-env'));
21
+ });