dsh-trivium 0.2.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/LICENSE +21 -0
- package/README.md +112 -0
- package/cordis.patch.yml +11 -0
- package/lib/client.js +804 -0
- package/lib/embed.js +110 -0
- package/lib/extract.js +454 -0
- package/lib/index.js +388 -0
- package/lib/schema.js +66 -0
- package/lib/server.js +222 -0
- package/lib/settings.js +68 -0
- package/lib/store.js +1042 -0
- package/lib/tokens.js +28 -0
- package/lib/tools.js +216 -0
- package/lib/until.js +85 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-trivium authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE SOFTWARE'S USE OR OTHER
|
|
21
|
+
DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# dsh-trivium
|
|
2
|
+
|
|
3
|
+
In-process **graph memory kernel** for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness), backed by [TriviumDB](https://github.com/YoKONCy/TriviumDB).
|
|
4
|
+
|
|
5
|
+
One `.tdb` file per workspace. No extra server. MIT license.
|
|
6
|
+
|
|
7
|
+
> 进程内图记忆:按节点和边记,按需读。钉死 `@deepseek-ai/dsh@0.1.0-rc.6`。
|
|
8
|
+
|
|
9
|
+
## Status
|
|
10
|
+
|
|
11
|
+
**v0.2.0** — P4 kernel + Settings correction: find with edges/`until`; edit/rename, merge, JSON export/import; recall **off** unless `autoRecall` or entity-name inject (mutually exclusive). Optional remote embedding (manual URL, default off). See [PLAN.md](./PLAN.md).
|
|
12
|
+
|
|
13
|
+
## Tools
|
|
14
|
+
|
|
15
|
+
| Tool | Role |
|
|
16
|
+
|---|---|
|
|
17
|
+
| `ctx_find` | Hybrid / keyword search + edge paths (L0 only) |
|
|
18
|
+
| `ctx_read` | Full payload by node id |
|
|
19
|
+
| `ctx_remember` | Explicit write (`entity` / `preference` / `decision` / `experience`) |
|
|
20
|
+
| `ctx_link` | Directed labelled edge |
|
|
21
|
+
|
|
22
|
+
Default: **no per-step auto-recall**. Session start injects a short map (budget ~400 tokens). Settings can switch recall to **entity-name inject** (1-hop neighbors when the user names a known entity) or full `autoRecall`; the two are mutually exclusive and both default **off**.
|
|
23
|
+
|
|
24
|
+
Optional **remote embedding** (OpenAI-compatible URL + model + key) is off by default. Failures fall back to keyword + graph. There is no local embedding model.
|
|
25
|
+
|
|
26
|
+
## Compared with what (mechanisms, not a bake-off)
|
|
27
|
+
|
|
28
|
+
This is a **kernel**, not a memory workbench. We did **not** run LoCoMo, OpenViking L0/L1/L2 product tests, or a live OV plugin shoot-out. The table is what we chose to win or skip. The only live contrast we ran is **vanilla DSH / empty `.tdb`**: the same `ctx_find("鉴权")` / `ctx_find("AuthGateway")` has no durable preference.
|
|
29
|
+
|
|
30
|
+
| | dsh-trivium | Stock DSH | JSON / FTS memory plugins | Wiki dual-link | OpenViking / PowerContext | Mnemon |
|
|
31
|
+
|---|---|---|---|---|---|---|
|
|
32
|
+
| Extra process | No (napi `.tdb` in-process) | — | Usually no | Often Python / indexer | Often a service + richer stack | Heavier local stack |
|
|
33
|
+
| What is stored | Nodes + labelled edges (entity / preference / decision / experience) | Session only | Documents or snippets | Markdown + `[[links]]` | Layered memory schema | Rich items + UI |
|
|
34
|
+
| How it enters the window | Short map ≤400 tokens; tools to drill; recall **off** (optional auto / entity-name inject) | Prompt / tools | Often dump or search | Follow links | Pre-step / layered load | Sidebar + recall |
|
|
35
|
+
| Graph | Engine edges (`about` / `decided` / `broke` / `fixed`); find returns **path** | None | Rare | Scan `[[slug]]` | Depends on product | UI-first |
|
|
36
|
+
| Human correction | Settings: search, neighbors, edit/rename, merge, archive vs delete, JSON export/import | — | Varies | Edit files | Product UI | Full workbench |
|
|
37
|
+
| First-period non-goals | Graph canvas, fifth tool, default auto-recall, local embedding | — | Feature-list race | 9-tool Python vectors | LoCoMo / parse farm / Skill hub | UI completeness |
|
|
38
|
+
|
|
39
|
+
**Why not a live OV comparison.** OV’s DSH plugin is the right *hook* shape (`inject`, pin rc.6, pending replay). Copying its product thickness (layers, skills, eval farm) is explicitly out of scope. Measuring “who wins LoCoMo” would optimize the wrong thing for a four-tool kernel.
|
|
40
|
+
|
|
41
|
+
## What we actually checked
|
|
42
|
+
|
|
43
|
+
On `@deepseek-ai/dsh@0.1.0-rc.6`, plugin linked into the web profile (not copied into Harness):
|
|
44
|
+
|
|
45
|
+
- Session A writes / extracts; session B `ctx_find` hits with `about` / `decided` / `fixed` paths; `ctx_read` returns `incoming`.
|
|
46
|
+
- Empty workspace: same queries, no durable preference (plugin still loaded).
|
|
47
|
+
- Extract whitelist: chitchat, one-shot “edit this file”, secrets, and the word `鉴权` as an entity stay out.
|
|
48
|
+
- Stale `until` hidden unless the query is about the deadline (`周五` / `下周`).
|
|
49
|
+
- Settings: filter by entity, stale toggle, archive then find misses; edit name/text, merge same-type nodes, export/import JSON.
|
|
50
|
+
- Optional remote embedding stays off until a URL is saved; no local model.
|
|
51
|
+
- Failure isolation: a broken `.tdb` path does not kill the agent loop.
|
|
52
|
+
|
|
53
|
+
Offline: `npm run smoke-p1` / `smoke-p2` / `smoke-p4` / `smoke-p5`.
|
|
54
|
+
|
|
55
|
+
## Strengths
|
|
56
|
+
|
|
57
|
+
- **Durable facts with edges**, not a chat transcript dump. `find("AuthGateway")` can return a neighbor whose text never repeats the name.
|
|
58
|
+
- **Cheap by default.** Short map budget 400; no per-step recall; Trajectory shows `dsh-trivium` as plugin inject.
|
|
59
|
+
- **One file, one process.** Install is a profile junction / `dsh plugin add`; memory is `<workspace>/.dsh/trivium.tdb`.
|
|
60
|
+
- **Visible and reversible.** Settings can edit, merge, archive vs delete, and export/import JSON; find ignores archived nodes.
|
|
61
|
+
- **Honest degradation.** Keyword + graph walk by default. Optional remote embedding; extract / TDB / embed errors log and continue.
|
|
62
|
+
|
|
63
|
+
## Limits (v0.2.0)
|
|
64
|
+
|
|
65
|
+
- **Not a workbench.** No graph canvas, no Mnemon sidebar, no cross-agent share, no PDF/Zotero RAG. Settings can edit, merge, and export/import.
|
|
66
|
+
- **Recall is off by default.** If the model never calls `ctx_find`, the short map is all it gets unless you enable entity-name inject or `autoRecall` (mutually exclusive).
|
|
67
|
+
- **Extract is conservative.** It will miss facts that do not match the whitelist; a real tool-fail→success experience only links when the fail/fix text or a nearby user turn names an entity.
|
|
68
|
+
- **Engine gaps we paper over.** No `expandLabels` / `getIncomingEdges` in the Node binding, so the plugin scans edges itself. Same `.tdb` must not be opened by two Node processes (normal `dsh web` use is one process).
|
|
69
|
+
- **Vectors are optional.** Remote OpenAI-compatible embedding can fill the 1536-d slot; local models are not shipped. Old rows stay zero until you backfill.
|
|
70
|
+
- **Old dirty rows stay.** Settings can edit or archive them; we do not auto-wipe a workspace library.
|
|
71
|
+
|
|
72
|
+
## Install (when testing against local DSH)
|
|
73
|
+
|
|
74
|
+
This repo is **not** copied into `DeepSeek_Harness`. Link it into the web profile:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
cd dsh-trivium
|
|
78
|
+
npm install
|
|
79
|
+
node scripts/link-dsh.mjs
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Restart `dsh web`, pick a workspace, then ask the agent to `ctx_remember` and `ctx_find`.
|
|
83
|
+
|
|
84
|
+
Manual equivalent:
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
dsh plugin --profile web add /absolute/path/to/dsh-trivium
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Memory file: `<workspace>/.dsh/trivium.tdb`.
|
|
91
|
+
|
|
92
|
+
## Layout
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
lib/index.js Cordis apply: tools, session-start map, extract hooks
|
|
96
|
+
lib/store.js TriviumDB open / insert / search / archive / merge / export
|
|
97
|
+
lib/schema.js Node types and edge labels
|
|
98
|
+
lib/embed.js Optional remote OpenAI-compatible embeddings
|
|
99
|
+
lib/settings.js ~/.dsh/trivium.json (recall mode, embed URL)
|
|
100
|
+
lib/tools.js ctx_* tools
|
|
101
|
+
lib/extract.js Rule + small-prompt distill, pending replay
|
|
102
|
+
lib/client.js Settings page 「Trivium 记忆」
|
|
103
|
+
scripts/link-dsh.mjs
|
|
104
|
+
scripts/p2-cases.mjs
|
|
105
|
+
scripts/smoke-p4.mjs
|
|
106
|
+
scripts/smoke-p5.mjs
|
|
107
|
+
PLAN.md
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
MIT. TriviumDB itself is Apache-2.0 and remains a dependency.
|
package/cordis.patch.yml
ADDED