dsh-memsearch-community 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.
- package/README.md +22 -0
- package/lib/index.js +34 -16
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,6 +10,28 @@ computed locally with ONNX.
|
|
|
10
10
|
> This is an **unofficial community fork** of `dsh-memsearch` (upstream 0.1.7,
|
|
11
11
|
> MIT). It is not affiliated with the upstream author or with DeepSeek.
|
|
12
12
|
|
|
13
|
+
## Changes from upstream
|
|
14
|
+
|
|
15
|
+
**0.2.1 — capture the real prompt**
|
|
16
|
+
|
|
17
|
+
DeepSeek Harness delivers injected context as ordinary `user/message` events:
|
|
18
|
+
`runtime-context`, `time-context`, `skill-catalog`, `model-selection` and the
|
|
19
|
+
plugin's own status line. Upstream skipped only `source.kind === "plugin"`, so
|
|
20
|
+
every journal entry began with harness boilerplate such as
|
|
21
|
+
`Time sampled while preparing turn 3, step 1: …` instead of what the user
|
|
22
|
+
actually asked.
|
|
23
|
+
|
|
24
|
+
The extractor now accepts only `source.kind === "user"` (plus messages that
|
|
25
|
+
carry no source at all), rejects text that still looks like an injected block,
|
|
26
|
+
and pairs the prompt with the final assistant reply that follows it.
|
|
27
|
+
|
|
28
|
+
**0.2.0 — installable bundle**
|
|
29
|
+
|
|
30
|
+
Packaged as a DSH bundle: `dsh.bundle.patch`, locale metadata, an icon, and a
|
|
31
|
+
detail document, so the plugin installs by package name instead of a hand-edited
|
|
32
|
+
profile patch. Also: Windows `PATH` handling, and graceful degradation when the
|
|
33
|
+
`memsearch` CLI is missing.
|
|
34
|
+
|
|
13
35
|
## What it does
|
|
14
36
|
|
|
15
37
|
| Behaviour | Detail |
|
package/lib/index.js
CHANGED
|
@@ -169,27 +169,45 @@ function messageOf(data) {
|
|
|
169
169
|
return data;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
/**
|
|
172
|
+
/** Blocks the harness injects into the conversation; never a real user prompt. */
|
|
173
|
+
const INJECTED_TEXT = /^\s*(<system-reminder>|Time sampled while preparing)/;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The last exchange of the session: the newest genuine user prompt plus the
|
|
177
|
+
* final assistant reply that follows it.
|
|
178
|
+
*
|
|
179
|
+
* Injected context reaches the session as ordinary `user/message` events, so
|
|
180
|
+
* `source.kind` decides what counts: only `kind: "user"` (and a message with no
|
|
181
|
+
* source at all) is a real prompt. Everything else — `plugin`, `runtime-context`,
|
|
182
|
+
* `time-context`, `skill-catalog`, `model-selection` — is skipped.
|
|
183
|
+
*/
|
|
173
184
|
function extractExchange(session) {
|
|
174
185
|
let userText = "";
|
|
186
|
+
let userSeq = -1;
|
|
187
|
+
const events = Array.isArray(session.events) ? session.events : [];
|
|
188
|
+
for (let i = 0; i < events.length; i++) {
|
|
189
|
+
const event = events[i];
|
|
190
|
+
if (!event || typeof event !== "object" || event.type !== "user/message") continue;
|
|
191
|
+
const source = event.data && event.data.source;
|
|
192
|
+
if (source && source.kind !== "user") continue; // injected context or our own status line
|
|
193
|
+
const text = textOf(messageOf(event.data));
|
|
194
|
+
if (!text || INJECTED_TEXT.test(text)) continue;
|
|
195
|
+
userText = text;
|
|
196
|
+
userSeq = typeof event.seq === "number" ? event.seq : i;
|
|
197
|
+
}
|
|
198
|
+
if (!userText) return { userText: "", assistantText: "", assistantSeq: undefined };
|
|
199
|
+
|
|
175
200
|
let assistantText = "";
|
|
176
201
|
let assistantSeq;
|
|
177
|
-
const events = Array.isArray(session.events) ? session.events : [];
|
|
178
202
|
for (let i = events.length - 1; i >= 0; i--) {
|
|
179
203
|
const event = events[i];
|
|
180
|
-
if (!event || typeof event !== "object") continue;
|
|
181
|
-
if (event.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (text) {
|
|
188
|
-
assistantText = text;
|
|
189
|
-
assistantSeq = event.seq;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
if (userText && assistantSeq !== undefined) break;
|
|
204
|
+
if (!event || typeof event !== "object" || event.type !== "assistant/message") continue;
|
|
205
|
+
if (typeof event.seq === "number" && typeof userSeq === "number" && event.seq < userSeq) continue;
|
|
206
|
+
const text = textOf(messageOf(event.data));
|
|
207
|
+
if (!text) continue;
|
|
208
|
+
assistantText = text;
|
|
209
|
+
assistantSeq = event.seq;
|
|
210
|
+
break;
|
|
193
211
|
}
|
|
194
212
|
return { userText, assistantText, assistantSeq };
|
|
195
213
|
}
|
|
@@ -307,4 +325,4 @@ function apply(ctx, config) {
|
|
|
307
325
|
}
|
|
308
326
|
}
|
|
309
327
|
|
|
310
|
-
export { Config, apply, inject, name };
|
|
328
|
+
export { Config, apply, extractExchange, inject, name };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-memsearch-community",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Automatic local semantic memory for DeepSeek Harness: journals every turn, indexes it with memsearch, and lets the agent recall earlier sessions. Community fork
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Automatic local semantic memory for DeepSeek Harness: journals every turn, indexes it with memsearch, and lets the agent recall earlier sessions. Community fork that captures only genuine user prompts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|