dsh-cortex-memory 0.2.0 → 0.2.2

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 (3) hide show
  1. package/LICENSE +3 -2
  2. package/README.md +120 -91
  3. package/package.json +14 -2
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- MIT License
1
+ MIT License
2
2
 
3
- Copyright (c) 2026 本鲸 / 凌寒
3
+ Copyright (c) 2026 Lh1314-China / Cortex contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -19,3 +19,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
+
package/README.md CHANGED
@@ -1,99 +1,128 @@
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.2`
13
+ - Optional extractor: `dsh-cortex-extractors@0.3.4`
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.
90
21
 
91
- MIT. External ideas are cited in the research notes; no third-party source
92
- code is copied into this package.
93
-
22
+ ## Install
23
+
24
+ ```powershell
25
+ npm i dsh-cortex-memory
26
+ npm i dsh-cortex-extractors # optional OCR/ASR
27
+ ```
28
+
29
+ Or let DSH add the bundles:
30
+
31
+ ```powershell
32
+ dsh plugin --profile desktop add dsh-cortex-memory
33
+ dsh plugin --profile desktop add dsh-cortex-extractors
34
+ ```
35
+
36
+ Or use the Windows one-click zip from the GitHub Release. The installer
37
+ discovers a desktop DSH installation automatically; `-DshPath` remains available
38
+ for custom installs.
39
+
40
+ After installing, restart DSH or reload the plugin. The Cortex panel is in the
41
+ left sidebar by default.
42
+
43
+ ## What it provides
44
+
45
+ | Layer | Contents |
46
+ |---|---|
47
+ | L0 identity | self-model, values, boundaries, stable traits |
48
+ | working | focus, pins, current goals, turn buffer |
49
+ | episodic | what happened, when, provenance, emotion |
50
+ | semantic | entities, facts with validity windows, preferences |
51
+ | procedural | skills, workflows, preconditions, success/failure stats |
52
+ | reflective | episode summaries, insights, narratives |
53
+ | archive | cold but searchable, wakeable until privacy deletion |
54
+
55
+ Key behavior:
56
+
57
+ - append-only, hash-chained event log
58
+ - temporal facts; old facts are invalidated, not silently overwritten
59
+ - FTS5 BM25 + optional vector + graph activation + recency/importance/feedback
60
+ - DSR/FSRS-inspired stability, difficulty and retrievability
61
+ - reflection, retention plans and explicit-approval evolution
62
+ - scopes, read-only shared scopes and audit
63
+ - guardian backup, validation, offline restore and privacy cascade
64
+ - loopback-only API and sidebar UI
65
+
66
+ ## UI: extract into memory
67
+
68
+ On a trace detail page:
94
69
 
95
- ## Security and privacy
70
+ 1. enter a local `file://` image or audio path
71
+ 2. choose OCR or ASR
72
+ 3. choose a layout: auto, single, two-column or handwriting
73
+ 4. choose a target trace
74
+ 5. run **Extract and write**
75
+
76
+ The extracted text becomes a **derived trace**; the target trace is unchanged.
77
+ Text is never written when extraction returns no text. The extractor is optional;
78
+ without it the button fails closed.
79
+
80
+ ## Permissions and privacy
81
+
82
+ - Local API: loopback-only, token and origin checks
83
+ - Permission changes: explicit confirmation, local override, restart required
84
+ - Feature flags/metrics: read-only snapshot
85
+ - Shared write grants: only for API clients sending `x-cortex-agent`; revoke is immediate
86
+ - Remote LLM/embedding/rerank: off unless configured and permitted
87
+ - Attachment reader: off by default
88
+
89
+ Read [permissions](docs/permissions.md) and [privacy](docs/privacy.md) before
90
+ enabling remote models or shared scopes.
91
+
92
+ ## Optional extractors
93
+
94
+ `dsh-cortex-extractors` adds:
95
+
96
+ - Windows OCR (default on Windows)
97
+ - Tesseract with TSV layout ordering
98
+ - optional local PaddleOCR bridge for layout/handwriting
99
+ - whisper.cpp ASR
100
+ - custom command providers
101
+
102
+ It never downloads a model automatically. See the
103
+ [extractor engine docs](https://github.com/Lh1314-China/dsh-cortex-extractors/blob/main/docs/engines.md)
104
+ for model paths and failure behavior.
105
+
106
+ ## Development
107
+
108
+ ```powershell
109
+ npm test
110
+ npm run bench
111
+ ```
112
+
113
+ The test runner uses `node:test` and the built-in `node:sqlite`; no network is
114
+ required. On Node 24 Windows CI the runner is invoked with explicit test files
115
+ and `--test-isolation=none` to avoid a spurious child-process EPERM.
116
+
117
+ ## Compatibility and limits
118
+
119
+ - Windows is the primary desktop target; the core memory engine is cross-platform.
120
+ - Windows OCR requires an installed Windows OCR language pack.
121
+ - Tesseract and Whisper require local binaries/models.
122
+ - PaddleOCR handwriting is optional and accuracy on cursive is limited.
123
+ - The extractor is a separate package; it is not a dependency of the memory engine.
124
+
125
+ ## License
96
126
 
97
- - [Permissions and scopes](./docs/permissions.md)
98
- - [Privacy notes](./docs/privacy.md)
127
+ MIT.
99
128
 
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.2",
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",
@@ -76,5 +76,17 @@
76
76
  "self-evolving",
77
77
  "sqlite"
78
78
  ],
79
- "license": "MIT"
79
+ "license": "MIT",
80
+ "author": {
81
+ "name": "Lh1314-China",
82
+ "url": "https://github.com/Lh1314-China"
83
+ },
84
+ "homepage": "https://github.com/Lh1314-China/dsh-cortex-memory#readme",
85
+ "repository": {
86
+ "type": "git",
87
+ "url": "git+https://github.com/Lh1314-China/dsh-cortex-memory.git"
88
+ },
89
+ "bugs": {
90
+ "url": "https://github.com/Lh1314-China/dsh-cortex-memory/issues"
91
+ }
80
92
  }