dsh-context-graph 0.3.0 → 0.6.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 +251 -144
- package/README.zh.md +63 -17
- package/cordis.patch.yml +15 -18
- package/graph.js +155 -109
- package/index.js +413 -424
- package/lib/client.js +12 -4
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +3 -3
- package/store.js +55 -20
package/README.md
CHANGED
|
@@ -1,144 +1,251 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
the
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
dsh
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
`
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
`
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
##
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="icon.svg" width="72" height="72" alt="Context Graph icon">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Context Graph for DeepSeek Harness</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
Memory for your chats, on from the moment you install it.<br>
|
|
9
|
+
Later chats get a few lines that point at what was decided; the model fetches the exact text only when it needs it.
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/dsh-context-graph"><img alt="npm" src="https://img.shields.io/npm/v/dsh-context-graph?label=npm&color=4A65E8"></a>
|
|
14
|
+
<img alt="dsh" src="https://img.shields.io/badge/dsh-0.2.1-7AC2FF">
|
|
15
|
+
<img alt="license" src="https://img.shields.io/badge/license-MIT-lightgrey">
|
|
16
|
+
<a href="README.zh.md"><img alt="中文" src="https://img.shields.io/badge/文档-中文-4A65E8"></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
**The problem.** Every message you send re-sends the whole conversation, and a new chat knows
|
|
22
|
+
nothing about the last one. You re-explain, the model re-reads, and you pay input tokens for both.
|
|
23
|
+
|
|
24
|
+
**What this does.** In every chat (memory is on by default), the plugin indexes what was
|
|
25
|
+
decided into a small graph of topics, each stored together with the original messages. Other
|
|
26
|
+
chats in the same workspace get, at most, a few lines like this appended to your message:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
[context-graph] Related past context from yesterday (by chat). Call recall(id) for the verbatim source.
|
|
30
|
+
- c3n12 builder timeout: builderMaxTokens raised to 8192 after the 524s (2026-11-01)
|
|
31
|
+
- c3n4 publish flow: npm version patch, npm publish (2FA), git push --follow-tags (2026-11-01)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The model calls `recall("c3n12")` when a gist is not precise enough and gets the original turns,
|
|
35
|
+
word for word. Nothing is summarised away, and nothing is sent that you did not ask for.
|
|
36
|
+
|
|
37
|
+
> **First principle:** save input tokens without losing quality. A few lines per message; exact
|
|
38
|
+
> text on demand.
|
|
39
|
+
>
|
|
40
|
+
> **Turning it off.** Plugins page → Context Graph → switch it off: no chat is indexed or gets
|
|
41
|
+
> anything added. To stop only one chat, run `/context-graph off` in it.
|
|
42
|
+
|
|
43
|
+
## Quick start
|
|
44
|
+
|
|
45
|
+
1. **Plugins → Add plugin**, official npm registry, type `dsh-context-graph`, install, then fully
|
|
46
|
+
restart the app (new slash commands need a restart).
|
|
47
|
+
2. Chat as usual. Every chat indexes itself every 4 turns and is shared with the other chats of
|
|
48
|
+
its workspace. Type `/context-graph`, pick it from the menu, then `build` to index one right away.
|
|
49
|
+
3. Open a new chat in the same workspace and ask about something from the first.
|
|
50
|
+
4. To keep one chat out of the others, run `/context-graph unshare` in it.
|
|
51
|
+
|
|
52
|
+
Command line instead of the Plugins page (the desktop app uses the `desktop` profile):
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
dsh plugin --profile desktop add dsh-context-graph
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Commands
|
|
59
|
+
|
|
60
|
+
All commands are `/context-graph <word>`. Type `/context-graph`, pick it from the menu, then type
|
|
61
|
+
the word. Results show in dsh's own command card: a one-line summary that expands to the details.
|
|
62
|
+
No word means `stats`.
|
|
63
|
+
|
|
64
|
+
### `on` — resume memory for this chat
|
|
65
|
+
|
|
66
|
+
Memory is already on in every chat. `on` undoes an earlier `off` and indexes the chat right away.
|
|
67
|
+
|
|
68
|
+
Indexes the chat right away and then again every 4 human turns (one small auxiliary model call
|
|
69
|
+
each time, using the chat's own routed model unless you configure another). Creates
|
|
70
|
+
`.context-graph/chats/<chat>/` with the chat's graph, its verbatim sources and a `meta.json`
|
|
71
|
+
holding its title, dates and flags. From now on every message you send in this chat is matched
|
|
72
|
+
against the other shared chats of the workspace, and the first message of the chat also carries the
|
|
73
|
+
list of those chats, newest first.
|
|
74
|
+
|
|
75
|
+
Card: `Memory on · 7 topics in this chat · 2 shared chats to draw on`
|
|
76
|
+
|
|
77
|
+
### `off` — stop memory for this chat only
|
|
78
|
+
|
|
79
|
+
To stop it in every chat, switch the plugin off on the Plugins page instead.
|
|
80
|
+
|
|
81
|
+
Stops indexing and stops adding anything to your requests. The graph folder stays on disk, so
|
|
82
|
+
`on` later resumes where it left off. Other chats keep seeing this chat if it is shared.
|
|
83
|
+
|
|
84
|
+
### `share` / `unshare` — keep a chat private, or share it again
|
|
85
|
+
|
|
86
|
+
Every chat is shared by default: other chats with memory on can match and recall its topics.
|
|
87
|
+
`unshare` makes this chat private; `share` undoes that. Nothing is copied or merged: the graph stays in its own folder with its own dates, and its
|
|
88
|
+
ids carry the chat number (`c3n12`) so every hit traces back to where it came from. Both take
|
|
89
|
+
effect at once. A chat shared
|
|
90
|
+
before its first index has nothing to offer yet; it fills in every 4 turns or with `build`.
|
|
91
|
+
|
|
92
|
+
Card: `Shared with the workspace · 7 topics`
|
|
93
|
+
|
|
94
|
+
### `stats` — where things stand (default)
|
|
95
|
+
|
|
96
|
+
First line: memory on/off, topics in this chat, shared/private, how many shared chats are
|
|
97
|
+
visible, how many of this chat's turns are waiting to be indexed, and `update available` when a
|
|
98
|
+
newer version is on npm. The body shows the version, the memory folder, and counters since the app
|
|
99
|
+
started: builds and builder tokens, injected blocks and their size, recalls, and the main
|
|
100
|
+
conversation's input split into uncached, cache-read and cache-write with the cache-hit rate. A
|
|
101
|
+
high cache-hit rate is the sign that memory is saving money rather than spending it.
|
|
102
|
+
|
|
103
|
+
Card: `Memory on · 7 topics in this chat · shared · 2 shared chats · 3 turns waiting to be indexed`
|
|
104
|
+
|
|
105
|
+
### `build` — index this chat now
|
|
106
|
+
|
|
107
|
+
Runs the indexing call immediately instead of waiting for the next 4-turn mark. Useful right
|
|
108
|
+
before you switch chats. Needs memory on. If the model's answer cannot be read, the raw output is
|
|
109
|
+
saved to `last-builder-output.txt` in the chat's folder and the card tells you why.
|
|
110
|
+
|
|
111
|
+
Card: `3 topics indexed (2 new) · this chat has 7 topics`
|
|
112
|
+
|
|
113
|
+
### `map` — every chat in the workspace
|
|
114
|
+
|
|
115
|
+
Lists all indexed chats newest first: chat id, start date, title, topic count and flags (`this
|
|
116
|
+
chat`, `memory on`, `shared`/`private`), each followed by its most connected topics with their ids.
|
|
117
|
+
This is the text form of the graph; a visual page is planned.
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
2 chats in C:\Projects\site\.context-graph
|
|
121
|
+
c2 2026-11-02 Fix the login redirect loop · 4 topics · this chat, memory on, private
|
|
122
|
+
- c2n1 redirect loop cause: session cookie set with the wrong path (2026-11-02)
|
|
123
|
+
c1 2026-11-01 Set up CI for the site · 6 topics · memory on, shared
|
|
124
|
+
- c1n3 deploy step: GitHub Pages from the gh-pages branch (2026-11-01)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### `find <words>` — search the shared chats
|
|
128
|
+
|
|
129
|
+
The same matcher the plugin runs on your messages, so you can see what the model would be shown.
|
|
130
|
+
Time words narrow it: `find 524 timeout last week` looks in chats active last week first. Only
|
|
131
|
+
shared chats of other conversations are searched; the current chat's own topics are left out
|
|
132
|
+
because they are already in its context.
|
|
133
|
+
|
|
134
|
+
Card: `2 matching topics`, then `c3n12 builder timeout: ...` per line.
|
|
135
|
+
|
|
136
|
+
## How matching and recall work
|
|
137
|
+
|
|
138
|
+
**Matching is lexical and free.** Your message is split into words, identifiers (`clear_conversation`
|
|
139
|
+
also yields `clear` and `conversation`) and Chinese character pairs. Topic labels and aliases count
|
|
140
|
+
double, gists single, well-connected topics get a small boost, and a topic only counts when a label
|
|
141
|
+
or alias word matched. Up to 5 hits are shown; when one hit is clearly ahead and its source is
|
|
142
|
+
short, the source is included verbatim so no `recall` round trip is needed. A changed decision
|
|
143
|
+
links to its replacement with a `supersedes` edge, so a hit on the old one shows the new one.
|
|
144
|
+
|
|
145
|
+
**Time is the first filter.** If your message names a time, the search runs in that slice first and
|
|
146
|
+
widens only if it finds nothing:
|
|
147
|
+
|
|
148
|
+
| You write | Searched first |
|
|
149
|
+
|---|---|
|
|
150
|
+
| `yesterday`, `昨天` | chats active yesterday |
|
|
151
|
+
| `3 days ago`, `3天前` | that day |
|
|
152
|
+
| `last week`, `上周` / `this week`, `本周` | Monday to Monday |
|
|
153
|
+
| `last month`, `上个月` | that calendar month |
|
|
154
|
+
| `2026-11-01`, `11月1日` | that day |
|
|
155
|
+
|
|
156
|
+
If nothing matches in the slice and nothing matches anywhere, the chats from that time are listed
|
|
157
|
+
instead, so "what did we do yesterday?" still gets a useful answer.
|
|
158
|
+
|
|
159
|
+
**Recall ids.** The model (or you, in a message) can ask for:
|
|
160
|
+
|
|
161
|
+
| Id | Returns |
|
|
162
|
+
|---|---|
|
|
163
|
+
| `c3n12` | Topic 12 of chat 3: label, gist, the original messages word for word, and linked topics |
|
|
164
|
+
| `c3` | Chat 3: title, dates, and its topics most connected first |
|
|
165
|
+
| `2026-11-01` | Every shared chat active that day, each with its topics from that day first |
|
|
166
|
+
| `t7` | Turn 7 of the current chat word for word, including tool calls and results |
|
|
167
|
+
|
|
168
|
+
## What it costs
|
|
169
|
+
|
|
170
|
+
| Moment | Added to the request |
|
|
171
|
+
|---|---|
|
|
172
|
+
| Chats without `on` | nothing |
|
|
173
|
+
| First message of a chat | about 15 tokens per shared chat, 20 chats at most |
|
|
174
|
+
| Every later message | nothing when no topic matches; under about 150 tokens when some do |
|
|
175
|
+
| Indexing | one auxiliary call every 4 turns, off the critical path; roughly the new text in, under 1k tokens out |
|
|
176
|
+
| `recall` | one tool round trip with the exact text |
|
|
177
|
+
|
|
178
|
+
Injected blocks are appended to the end of your newest message, never inserted earlier, so the
|
|
179
|
+
provider's prefix cache keeps working. DeepSeek bills cached input at a small fraction of the
|
|
180
|
+
uncached price; protecting that cache matters more than shaving a few lines.
|
|
181
|
+
|
|
182
|
+
## Configuration
|
|
183
|
+
|
|
184
|
+
Defaults live in [cordis.patch.yml](cordis.patch.yml). A patch replaces the row's whole `config`,
|
|
185
|
+
so restate every key you keep.
|
|
186
|
+
|
|
187
|
+
| Key | Default | Meaning |
|
|
188
|
+
|---|---|---|
|
|
189
|
+
| `dir` | `.context-graph` | Memory folder, relative to the agent workspace or absolute |
|
|
190
|
+
| `buildEveryTurns` | `4` | Index after this many new human turns (chats with memory on) |
|
|
191
|
+
| `buildMinChars` | `400` | ...and at least this much new text |
|
|
192
|
+
| `maxHits` | `5` | Topics shown per human turn |
|
|
193
|
+
| `inlineMaxChars` | `1200` | A single dominant hit this short is shown verbatim |
|
|
194
|
+
| `surfaceMaxChats` | `20` | Shared chats listed on the first message of each chat |
|
|
195
|
+
| `builderMaxTokens` | `8192` | Output cap for the indexing call; thinking models spend part of it reasoning |
|
|
196
|
+
| `provider`, `model` | `''` | Empty: reuse the conversation's routed provider and model. Set both to index with a cheaper or faster model |
|
|
197
|
+
|
|
198
|
+
## Updating
|
|
199
|
+
|
|
200
|
+
dsh 0.2.1 desktop builds have no update check for third-party plugins, so the plugin checks npm
|
|
201
|
+
itself once per app start. When a newer version exists, your next chat reply ends with one line
|
|
202
|
+
saying so, and `/context-graph stats` shows it on its first line. To update: Plugins, open
|
|
203
|
+
dsh-context-graph, **Uninstall**, then **Add plugin** `dsh-context-graph@<new version>` and restart.
|
|
204
|
+
Name the exact version: dsh's pnpm holds back very new releases otherwise. Turn the check off with
|
|
205
|
+
`DSH_CONTEXT_GRAPH_NO_UPDATE_CHECK=1`.
|
|
206
|
+
|
|
207
|
+
Remove with `dsh plugin --profile desktop remove dsh-context-graph`.
|
|
208
|
+
|
|
209
|
+
## On disk
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
.context-graph/chats/<sessionId>/meta.json cid, title, startedAt, lastActiveAt, turns; memoryOff / private only after off / unshare
|
|
213
|
+
.context-graph/chats/<sessionId>/graph.json topics and links; every topic has its time
|
|
214
|
+
.context-graph/chats/<sessionId>/src/<id>.md verbatim messages behind each topic
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Delete a chat's folder to forget it. Delete `.context-graph/` to forget the workspace.
|
|
218
|
+
|
|
219
|
+
## Development
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
index.js dsh plugin: builder, matcher, recall tool, meter, /context-graph command
|
|
223
|
+
graph.js pure core: tokenize, match, time ranges, merge, render, builder prompt and parser
|
|
224
|
+
store.js chats/<chat>/{meta.json, graph.json, src/<id>.md}
|
|
225
|
+
update.js once-per-start check of npm for a newer version
|
|
226
|
+
lib/client.js dsh chat card for /context-graph (DisclosureRow, en/zh titles)
|
|
227
|
+
icon.svg Plugins page icon in dsh's built-in icon style
|
|
228
|
+
locale/ Plugins page title and description (en, zh); zh links README.zh.md
|
|
229
|
+
cordis.patch.yml mounts the plugin at the profile root with default config
|
|
230
|
+
test/ node --test
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Unit tests need nothing: `node --test test/graph.test.js`. The wiring test imports the real dsh
|
|
234
|
+
packages from an existing install: `DSH_NODE_MODULES=/path/to/dsh/node_modules npm test`. Nothing
|
|
235
|
+
here calls a model.
|
|
236
|
+
|
|
237
|
+
Release: `npm test`, `npm version patch`, `npm publish`, `git push --follow-tags`.
|
|
238
|
+
|
|
239
|
+
## Known limits
|
|
240
|
+
|
|
241
|
+
- Not yet verified with a live model; tests run against the published dsh packages.
|
|
242
|
+
- Builds are tracked per process; after a restart the first build of a resumed chat re-reads its
|
|
243
|
+
whole surface. Existing ids are reused, so this costs one larger call, not duplicates.
|
|
244
|
+
- Two agents writing the same chat's graph at once: last writer wins.
|
|
245
|
+
- Subagent sessions are neither indexed nor given memory blocks.
|
|
246
|
+
- Tool outputs are not indexed as topics; `recall("tN")` returns them (each capped at 2000 characters).
|
|
247
|
+
- The chat title is the first message, shortened, until dsh exposes its own titles to plugins.
|
|
248
|
+
- The visual graph page is not built yet; `map` is the text version.
|
|
249
|
+
|
|
250
|
+
Using Claude Code? The Claude version is a separate plugin built for Claude's app:
|
|
251
|
+
[claude-context-graph](https://github.com/William20100221/claude-context-graph).
|
package/README.zh.md
CHANGED
|
@@ -1,25 +1,65 @@
|
|
|
1
1
|
# 上下文图谱(dsh-context-graph)
|
|
2
2
|
|
|
3
|
-
DeepSeek Harness
|
|
3
|
+
DeepSeek Harness 插件:给每个对话一张小型记忆图谱,安装后默认开启。同一工作区里的其他对话会收到几行指向过往结论的提示,模型需要细节时再取回原文。旧消息不再重复发送,结论也不会丢失。
|
|
4
|
+
|
|
5
|
+
第一原则:在不损失质量的前提下减少输入 token。
|
|
6
|
+
|
|
7
|
+
**如何关闭:** 插件页 → 上下文图谱 → 关闭开关,所有对话都不再索引,也不再往请求里加内容。只想停用某个对话,在该对话里运行 `/context-graph off`。
|
|
4
8
|
|
|
5
9
|
## 它做什么
|
|
6
10
|
|
|
11
|
+
每个对话默认开启记忆:
|
|
12
|
+
|
|
7
13
|
| 时机 | 发生了什么 |
|
|
8
14
|
|---|---|
|
|
9
|
-
| 每 4
|
|
10
|
-
|
|
|
11
|
-
| 每条人类消息 |
|
|
12
|
-
|
|
|
13
|
-
| 模型调用 `recall` | `
|
|
15
|
+
| 每个对话 | 每 4 轮人类发言索引一次:一次小型模型调用把主题写进 `.context-graph/chats/<对话>/graph.json`,并原样保存被引用的消息。不会拖慢回复。 |
|
|
16
|
+
| 每个对话的第一条消息 | 附上本工作区已共享的对话列表(最新在前):对话编号、日期、标题、主题数。 |
|
|
17
|
+
| 每条人类消息 | 按词语重合匹配其他已共享对话的主题(不调用模型),把最多 5 个相关主题附在消息末尾。唯一且很短的命中会直接附原文。 |
|
|
18
|
+
| 消息里提到时间 | “昨天”“上周”“11月1日”“2026-11-01”……先搜那个时间段:先按对话,再按主题,最后才搜全部。没有命中时,列出那段时间的对话。 |
|
|
19
|
+
| 模型调用 `recall` | `c3n12`:该主题的原文和相邻主题。`c3`:某个对话的主题列表。`2026-11-01`:那天的全部对话和主题。`t7`:当前对话第 7 轮的原文。 |
|
|
20
|
+
| 共享 | 每个对话默认与同一工作区的其他对话共享。只是一个标记,不复制、不合并。`/context-graph unshare` 让某个对话保持私有。 |
|
|
21
|
+
|
|
22
|
+
设计规则:
|
|
23
|
+
|
|
24
|
+
1. **默认开启,随时可关。** 插件页关闭本插件即全部停用;`/context-graph off` 只停用当前对话。
|
|
25
|
+
2. **没有原文不写入。** 主题只和它来源的原始消息一起保存。要点是指针,不是记录。
|
|
26
|
+
3. **只组织,不合并。** 每个对话的图谱留在自己的文件夹里,带自己的日期。编号带对话号(`c3n12`),每个主题都能追溯到来源对话。
|
|
27
|
+
4. **时间是第一过滤条件。**
|
|
28
|
+
5. **只在末尾追加**,保住服务商的前缀缓存。隐藏或折叠旧轮次不是本插件的工作。
|
|
14
29
|
|
|
15
30
|
## 命令
|
|
16
31
|
|
|
17
|
-
|
|
32
|
+
输入 `/context-graph`,在菜单里选中后再输入后面的词:
|
|
33
|
+
|
|
34
|
+
结果显示在 dsh 自带的命令卡片里:第一行是摘要,展开看详情。不带词等于 `stats`。
|
|
35
|
+
|
|
36
|
+
**`on` — 恢复本对话的记忆。** 记忆默认已开启;`on` 用于撤销之前的 `off`,并立即索引一次;之后每 4 轮人类发言再索引一次(每次一个小型模型调用,默认用本对话的模型)。在 `.context-graph/chats/<对话>/` 下建立图谱、原文和 `meta.json`(标题、日期、标记)。此后你在本对话发的每条消息都会去匹配工作区里其他已共享的对话;开启后的第一条消息还会附上这些对话的列表。
|
|
37
|
+
卡片:`Memory on · 7 topics in this chat · 2 shared chats to draw on`
|
|
38
|
+
|
|
39
|
+
**`off` — 只关闭本对话的记忆。** 要在所有对话里关闭,请在插件页关闭本插件。 停止索引,不再往请求里加任何内容。图谱文件保留,之后 `on` 可以接着用。若本对话已共享,其他对话仍能看到它。
|
|
40
|
+
|
|
41
|
+
**`share` / `unshare` — 共享或设为私有。** 每个对话默认共享;`unshare` 让本对话私有,`share` 撤销私有。共享只是给本对话打一个标记,其他开了记忆的对话就能匹配和取回它的主题。不复制、不合并:图谱留在自己的文件夹,编号带对话号(`c3n12`),每个命中都能追溯来源。`unshare` 立刻恢复私有。尚未索引的对话可以共享,但在索引之前没有内容。
|
|
18
42
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
43
|
+
**`stats` — 当前状态(默认)。** 第一行:记忆开/关、本对话主题数、共享/私有、可见的共享对话数、待索引轮数,以及有新版本时的 `update available`。正文:版本、记忆文件夹,以及应用启动以来的计数:索引次数与 token、附加块数量与大小、recall 次数、主对话输入的未缓存/缓存读/缓存写与缓存命中率。命中率高,说明记忆在省钱而不是花钱。
|
|
44
|
+
|
|
45
|
+
**`build` — 立即索引。** 不等下一个 4 轮节点,适合在切换对话前运行。需要记忆已开启。模型输出无法解析时,原始输出保存到该对话文件夹的 `last-builder-output.txt`,卡片说明原因。
|
|
46
|
+
|
|
47
|
+
**`map` — 工作区的全部对话。** 最新在前:对话编号、开始日期、标题、主题数和标记(`this chat`、`memory on`、`shared`/`private`),下面列出各自连接最多的主题及编号。这是图谱的文字版;可视化页面在计划中。
|
|
48
|
+
|
|
49
|
+
**`find 关键词` — 在已共享对话里查找。** 用的就是插件匹配你消息时的同一套规则,可以看到模型会被展示什么。时间词会缩小范围:`find 524 超时 上周` 先搜上周活跃的对话。只搜其他对话,本对话自己的主题已在上下文里,不重复。
|
|
50
|
+
|
|
51
|
+
### 取回编号
|
|
52
|
+
|
|
53
|
+
| 编号 | 返回 |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `c3n12` | 对话 3 的主题 12:名称、要点、原始消息原文、相邻主题 |
|
|
56
|
+
| `c3` | 对话 3:标题、日期、按连接数排序的主题 |
|
|
57
|
+
| `2026-11-01` | 当天活跃的全部共享对话,各自那天的主题在前 |
|
|
58
|
+
| `t7` | 当前对话第 7 轮的原文,含工具调用与结果 |
|
|
59
|
+
|
|
60
|
+
### 时间词
|
|
61
|
+
|
|
62
|
+
`昨天`/`yesterday`、`前天`、`3天前`、`上周`/`本周`、`上个月`/`本月`、`2026-11-01`、`11月1日`。先搜那段时间活跃的对话,再搜那段时间更新的主题,最后才搜全部;都没有时列出那段时间的对话。
|
|
23
63
|
|
|
24
64
|
## 安装与更新
|
|
25
65
|
|
|
@@ -27,12 +67,18 @@ DeepSeek Harness 插件:把过往对话记成一张小型主题图谱,并把
|
|
|
27
67
|
|
|
28
68
|
有新版本时,你的下一次回复末尾会提示一次,`/context-graph` 的第一行也会显示。更新方法:打开本插件 → 卸载 → 添加插件 `dsh-context-graph@新版本号` → 重启。务必写明版本号:dsh 的 pnpm 默认会暂缓刚发布的版本。
|
|
29
69
|
|
|
30
|
-
##
|
|
31
|
-
|
|
32
|
-
DeepSeek 对重复发送的已缓存输入只收约 1/30 的价格,而每次折叠都会让缓存重新开始一次。所以折叠只在旧内容很大时、并且目录不到原内容一半时才发生。短对话里它什么都不做。最大的收益来自新对话:不用重复解释,图谱已经记得之前的决定。
|
|
70
|
+
## 文件
|
|
33
71
|
|
|
34
|
-
|
|
72
|
+
```
|
|
73
|
+
.context-graph/chats/<对话>/meta.json 编号、标题、开始/最近时间、轮数;执行 off / unshare 后才有 memoryOff / private
|
|
74
|
+
.context-graph/chats/<对话>/graph.json 主题与链接,每个主题带时间
|
|
75
|
+
.context-graph/chats/<对话>/src/<id>.md 每个主题背后的原始消息
|
|
76
|
+
```
|
|
35
77
|
|
|
36
|
-
|
|
78
|
+
## 已知限制
|
|
37
79
|
|
|
38
|
-
|
|
80
|
+
- 重启后,续聊的第一次索引会重读整个对话(编号复用,不会重复)。
|
|
81
|
+
- 两个代理同时写同一个对话的图谱:后写的覆盖先写的。
|
|
82
|
+
- 子代理会话不索引,也不附加记忆。
|
|
83
|
+
- 对话标题暂用第一条消息的缩写。
|
|
84
|
+
- 侧边栏的可视化图谱页面尚未实现,`/context-graph map` 是文字版。
|
package/cordis.patch.yml
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
# Mounted at the profile root so the recall tool, the matcher and the builder are available to
|
|
2
|
-
# every agent. Every value below is the default; restate the whole config block when you change one.
|
|
3
|
-
- insert:
|
|
4
|
-
- id: context-graph
|
|
5
|
-
name: dsh-context-graph
|
|
6
|
-
config:
|
|
7
|
-
dir: .context-graph # relative to the agent workspace, or an absolute path
|
|
8
|
-
buildEveryTurns: 4 # index after this many new human turns
|
|
9
|
-
buildMinChars: 400 # ...and at least this much new text
|
|
10
|
-
maxHits: 5 #
|
|
11
|
-
inlineMaxChars: 1200 # one dominant hit this short is shown verbatim, no recall needed
|
|
12
|
-
|
|
13
|
-
builderMaxTokens: 8192 # thinking models spend part of this on reasoning
|
|
14
|
-
provider: '' # empty: reuse the conversation's routed provider/model
|
|
15
|
-
model: ''
|
|
16
|
-
fold: true # replace old turns of the current chat with a table of contents
|
|
17
|
-
foldAtTokens: 24000 # fold once the foldable part costs this much per request
|
|
18
|
-
keepTurns: 2 # newest human turns always kept word for word
|
|
1
|
+
# Mounted at the profile root so the recall tool, the matcher and the builder are available to
|
|
2
|
+
# every agent. Every value below is the default; restate the whole config block when you change one.
|
|
3
|
+
- insert:
|
|
4
|
+
- id: context-graph
|
|
5
|
+
name: dsh-context-graph
|
|
6
|
+
config:
|
|
7
|
+
dir: .context-graph # relative to the agent workspace, or an absolute path
|
|
8
|
+
buildEveryTurns: 4 # index after this many new human turns (only in chats with memory on)
|
|
9
|
+
buildMinChars: 400 # ...and at least this much new text
|
|
10
|
+
maxHits: 5 # topics shown per human turn
|
|
11
|
+
inlineMaxChars: 1200 # one dominant hit this short is shown verbatim, no recall needed
|
|
12
|
+
surfaceMaxChats: 20 # shared chats listed on the first message of each chat
|
|
13
|
+
builderMaxTokens: 8192 # thinking models spend part of this on reasoning
|
|
14
|
+
provider: '' # empty: reuse the conversation's routed provider/model
|
|
15
|
+
model: ''
|