dsh-cortex-memory 0.2.0 → 0.2.1

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 (2) hide show
  1. package/README.md +113 -92
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,99 +1,120 @@
1
- # dsh-cortex
2
-
3
- > 鏈哺鐨勬柊澶ц剳銆傚垎灞傘€佹椂搴忋€佸彲鑷垜宸╁浐鐨勮蹇嗗紩鎿庛€?> 鐘舵€侊細**鍙墦鍖呫€佸彲瀹夎**锛涙湰鏈哄紑鍙戝壇鏈粛鏈畨瑁咃紝涔熸病鏈夋帴 profile銆?> Windows 鐩存帴瀹夎/鍥炴粴瑙?[docs/install-windows.md](docs/install-windows.md)銆?
4
- `dsh-cortex` is a local-first memory engine for DeepSeek Harness. It is designed
5
- as a successor to the `dsh-shiori` + `dsh-shiori-companion` pair, not a patch on
6
- top of them.
7
-
8
- ## Why another memory plugin
9
-
10
- The shiori stack is good at four things: a stable persona, a compact core,
11
- triggered spark cards and on-demand topics. It is weaker at temporal facts,
12
- episodic provenance, procedural learning, consolidation and calibrated
13
- forgetting. `dsh-cortex` keeps the good parts and adds the missing layers:
14
-
15
- | Layer | What it holds | Lifetime |
16
- |---|---|---|
17
- | L0 identity | self-model, values, boundaries, stable traits | long, explicit promotion |
18
- | L1 working | current goals, focus, pinned context, recent turn buffer | minutes鈥揾ours |
19
- | L2 episodic | what happened, when, with whom, provenance, emotion | days鈥搚ears |
20
- | L3 semantic | entities, facts with validity windows, preferences | until invalidated |
21
- | L4 procedural | skills, workflows, preconditions, success/failure stats | until superseded |
22
- | L5 reflective | episode summaries, insights, narratives | derived, regenerable |
23
- | archive | cold but searchable, wake-word recall | until privacy deletion |
24
-
25
- ## Engines
26
-
27
- - **event log** 鈥?append-only, hash-chained, `event_id` / `operation_id`; the
28
- only source of truth.
29
- - **write pipeline** 鈥?scan secrets/injection 鈫?classify 鈫?dedupe 鈫? conflict-resolve 鈫?link 鈫?persist; async jobs with idempotent operation IDs.
30
- - **temporal graph** 鈥?entities, facts and edges with `valid_from` /
31
- `valid_to`; old facts are invalidated, never silently overwritten.
32
- - **hybrid retrieval** 鈥?FTS5 BM25 + optional vector + graph activation +
33
- recency / importance / feedback, fused with RRF, diversified with a greedy
34
- MMR-style marginal-gain pass; query filters (`kind:`, `tag:`, `after:`,
35
- `importance:>`, 鈥?.
36
- - **DSR forgetting** 鈥?FSRS-inspired stability / difficulty / retrievability;
37
- archive instead of delete, revive on successful recall.
38
- - **compression / retention** 鈥?archive only when a derived model covers the
39
- trace, or when a reviewed retention plan says it is old/low-value; important
40
- memories are never auto-archived.
41
- - **reflection** 鈥?episode segmentation, summaries, narrative threads,
42
- duplicate/contradiction detection, optional LLM dream/summary.
43
- - **self model** 鈥?drives, mood, attention, appraisal, relationships,
44
- initiatives, 24-category emotion/affect, identity versions.
45
- - **development** 鈥?maturity/stage from memory depth, feedback, calibration,
46
- skills, narrative and relationships.
47
- - **evolution** 鈥?policy proposals 鈫?replay evaluation 鈫?explicit approval 鈫? rollback; identity changes are separate and approval-only.
48
- - **guardian** 鈥?invariants, circuit breaker, budget, backup/validate/offline
49
- restore, FTS repair, privacy cascade, secret/injection scanner.
50
- - **host runtime** 鈥?`session/event` turn capture + `user/message` /
51
- `agent/pre-step` recall prefetch into the systemPrompt section.
52
- - **API/UI/CLI** 鈥?loopback-only HTTP API, sidebar panel, `bin/cortex.mjs`.
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.
53
9
 
54
10
  ## Status
55
11
 
56
- This is a source-only development tree. `npm test` uses `node:test` and the
57
- built-in `node:sqlite`; no native dependency and no network are required for
58
- the core suite. Profiles install a built tgz explicitly; this tree is not
59
- auto-linked into them.
60
-
61
- - **395** tests passing (unit + integration).
62
- - 21 model-facing tools.
63
- - **`cortex_as_of`**锛歴trict / historical / belief / associative銆?- **`cortex_playbook`**锛歀1.5 宸ヤ綔鍑嗗垯锛屽甫 helpful/harmful銆乿alidTo銆佽繃鏈熶笉娉ㄥ叆銆?- **`cortex_consolidate`**锛歀LM 鍐崇瓥娓呭崟 + 鏍¢獙 + `dream_runs` 鍙洖鏀捐褰曪紱鏃?LLM 鏃惰褰?skipped 骞堕浂鏀瑰姩銆?- **`cortex_search({tiered:true})`**锛歱erm/hot/cold 鍒嗗眰棰勭畻锛宑old 鍙粰绱㈠紩銆?- **寮傛娣峰悎妫€绱?*锛歚GET /search?async=true` / QA 璧?`searchAsync`锛涜繙绋?embedder 鍙储寮曪紝涓嶉樆濉炲啓銆?- 5k synthetic benchmark (needle, vector off): ~2.6-2.8k writes/s, p50 ~20-35ms; 100k migration ~2.3s. These are local numbers, not an official score.
64
- - Source/tests/docs 鈮?33k lines (includes `docs/book/`); source-only, not installed here.
65
- - Windows tgz: `dist/dsh-cortex-0.2.0-rc.11.tgz` (zero runtime deps; Node >= 24).
66
-
67
- ## Design docs
68
-
69
- - [research notes](docs/research/README.md)
70
- - [architecture](docs/architecture.md)
71
- - [Anima: from memory engine to a growing individual](docs/anima.md)
72
- - [modules and invariants](docs/modules.md)
73
- - [operations / CLI / backup](docs/operations.md)
74
- - [security and privacy](docs/security.md)
75
- - [scope isolation and read-only sharing](docs/scopes.md)
76
- - [multimodal attachment metadata](docs/multimodal.md)
77
- - [benchmark](docs/benchmark.md)
78
- - [OpenAPI 3.1](docs/openapi.yaml)
79
- - [API client](src/api/client.js)
80
- - [UI guide](docs/ui.md)
81
- - [design book](docs/book/README.md)
82
- - [four-plugin comparison](docs/comparison-2026-11-11.md)
83
- - [Windows install and rollback](docs/install-windows.md)
84
- - [optional models](docs/models.md)
85
- - [shiori companion review](docs/companion-feature-review.md)
86
- - [ecosystem comparison 2026-11-11](docs/ecosystem-comparison-2026-11-11.md)
87
- - [roadmap](docs/roadmap.md)
12
+ - Stable package: `dsh-cortex-memory@0.2.0`
13
+ - Optional extractor: `dsh-cortex-extractors@0.3.3`
14
+ - DSH: `>=0.2.1-rc.2 <0.4.0`
15
+ - Node: `>=24`
16
+ - Tests: 406/406 (main), 12/12 (extractor)
17
+ - CI: GitHub Actions on Windows, Node 24
88
18
 
89
- ## License
19
+ The npm package is named `dsh-cortex-memory` because `dsh-cortex` was already
20
+ taken; the installed bundle is still the Cortex memory engine.
21
+
22
+ ## Install
23
+
24
+ ```powershell
25
+ npm i dsh-cortex-memory
26
+ npm i dsh-cortex-extractors # optional OCR/ASR
27
+ ```
28
+
29
+ Or use the Windows one-click zip from the GitHub Release. The installer
30
+ discovers a desktop DSH installation automatically; `-DshPath` remains available
31
+ for custom installs.
32
+
33
+ After installing, restart DSH or reload the plugin. The Cortex panel is in the
34
+ left sidebar by default.
35
+
36
+ ## What it provides
37
+
38
+ | Layer | Contents |
39
+ |---|---|
40
+ | L0 identity | self-model, values, boundaries, stable traits |
41
+ | working | focus, pins, current goals, turn buffer |
42
+ | episodic | what happened, when, provenance, emotion |
43
+ | semantic | entities, facts with validity windows, preferences |
44
+ | procedural | skills, workflows, preconditions, success/failure stats |
45
+ | reflective | episode summaries, insights, narratives |
46
+ | archive | cold but searchable, wakeable until privacy deletion |
47
+
48
+ Key behavior:
49
+
50
+ - append-only, hash-chained event log
51
+ - temporal facts; old facts are invalidated, not silently overwritten
52
+ - FTS5 BM25 + optional vector + graph activation + recency/importance/feedback
53
+ - DSR/FSRS-inspired stability, difficulty and retrievability
54
+ - reflection, retention plans and explicit-approval evolution
55
+ - scopes, read-only shared scopes and audit
56
+ - guardian backup, validation, offline restore and privacy cascade
57
+ - loopback-only API and sidebar UI
58
+
59
+ ## UI: extract into memory
60
+
61
+ On a trace detail page:
62
+
63
+ 1. enter a local `file://` image or audio path
64
+ 2. choose OCR or ASR
65
+ 3. choose a layout: auto, single, two-column or handwriting
66
+ 4. choose a target trace
67
+ 5. run **Extract and write**
90
68
 
91
- MIT. External ideas are cited in the research notes; no third-party source
92
- code is copied into this package.
93
-
69
+ The extracted text becomes a **derived trace**; the target trace is unchanged.
70
+ Text is never written when extraction returns no text. The extractor is optional;
71
+ without it the button fails closed.
94
72
 
95
- ## Security and privacy
73
+ ## Permissions and privacy
74
+
75
+ - Local API: loopback-only, token and origin checks
76
+ - Permission changes: explicit confirmation, local override, restart required
77
+ - Feature flags/metrics: read-only snapshot
78
+ - Shared write grants: only for API clients sending `x-cortex-agent`; revoke is immediate
79
+ - Remote LLM/embedding/rerank: off unless configured and permitted
80
+ - Attachment reader: off by default
81
+
82
+ Read [permissions](docs/permissions.md) and [privacy](docs/privacy.md) before
83
+ enabling remote models or shared scopes.
84
+
85
+ ## Optional extractors
86
+
87
+ `dsh-cortex-extractors` adds:
88
+
89
+ - Windows OCR (default on Windows)
90
+ - Tesseract with TSV layout ordering
91
+ - optional local PaddleOCR bridge for layout/handwriting
92
+ - whisper.cpp ASR
93
+ - custom command providers
94
+
95
+ It never downloads a model automatically. See the
96
+ [extractor engine docs](https://github.com/Lh1314-China/dsh-cortex-extractors/blob/main/docs/engines.md)
97
+ for model paths and failure behavior.
98
+
99
+ ## Development
100
+
101
+ ```powershell
102
+ npm test
103
+ npm run bench
104
+ ```
105
+
106
+ The test runner uses `node:test` and the built-in `node:sqlite`; no network is
107
+ required. On Node 24 Windows CI the runner is invoked with explicit test files
108
+ and `--test-isolation=none` to avoid a spurious child-process EPERM.
109
+
110
+ ## Compatibility and limits
111
+
112
+ - Windows is the primary desktop target; the core memory engine is cross-platform.
113
+ - Windows OCR requires an installed Windows OCR language pack.
114
+ - Tesseract and Whisper require local binaries/models.
115
+ - PaddleOCR handwriting is optional and accuracy on cursive is limited.
116
+ - The extractor is a separate package; it is not a dependency of the memory engine.
117
+
118
+ ## License
96
119
 
97
- - [Permissions and scopes](./docs/permissions.md)
98
- - [Privacy notes](./docs/privacy.md)
99
-
120
+ MIT.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-cortex-memory",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A layered, temporal, self-developing memory engine for DeepSeek Harness: working, episodic, semantic, procedural and reflective memory with hybrid retrieval, DSR forgetting, reflection, consolidation, gated self-evolution and guardian.",
5
5
  "type": "module",
6
6
  "main": "./index.js",