dsh-memsearch-community 0.2.2 → 0.2.3
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 +9 -0
- package/lib/index.js +17 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,15 @@ computed locally with ONNX.
|
|
|
12
12
|
|
|
13
13
|
## Changes from upstream
|
|
14
14
|
|
|
15
|
+
**0.2.3 — keep reply headings out of the journal structure**
|
|
16
|
+
|
|
17
|
+
The journal uses `### HH:MM` lines as separators and `memsearch index` splits
|
|
18
|
+
markdown on headings. An assistant reply containing `### Something` therefore
|
|
19
|
+
looked like a new journal entry with a heading where the timestamp belongs,
|
|
20
|
+
fragmenting one exchange into several phantom entries. Captured text now escapes
|
|
21
|
+
leading `#` characters (`\###` renders as `###`), so only the plugin's own
|
|
22
|
+
timestamp lines remain headings.
|
|
23
|
+
|
|
15
24
|
**0.2.2 — capture actually runs**
|
|
16
25
|
|
|
17
26
|
DSH's `Session` class exposes its log through `snapshotEvents()`, `ownEvents()`
|
package/lib/index.js
CHANGED
|
@@ -264,6 +264,19 @@ function createStatusMessage(text) {
|
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
+
/**
|
|
268
|
+
* Neutralise markdown headings inside captured text.
|
|
269
|
+
*
|
|
270
|
+
* The journal uses `### HH:MM` lines as its own separators, and `memsearch index`
|
|
271
|
+
* splits markdown on headings. An assistant reply containing `### Something`
|
|
272
|
+
* therefore produced phantom journal entries with a heading where the timestamp
|
|
273
|
+
* belongs. Escaping the leading `#` keeps the text readable (`\### foo` renders
|
|
274
|
+
* as `### foo`) while leaving the heading structure to the journal itself.
|
|
275
|
+
*/
|
|
276
|
+
function defuseHeadings(text) {
|
|
277
|
+
return String(text).replace(/^(#{1,6})(\s)/gm, "\\$1$2");
|
|
278
|
+
}
|
|
279
|
+
|
|
267
280
|
async function captureTurn(config, memoryDir, session, state) {
|
|
268
281
|
try {
|
|
269
282
|
const { userText, assistantText, assistantSeq } = extractExchange(session);
|
|
@@ -272,11 +285,12 @@ async function captureTurn(config, memoryDir, session, state) {
|
|
|
272
285
|
if (state.lastCaptured.get(session.id) === assistantSeq) return; // already captured
|
|
273
286
|
state.lastCaptured.set(session.id, assistantSeq);
|
|
274
287
|
|
|
275
|
-
|
|
288
|
+
const body = `[User]: ${truncate(userText, config.maxCaptureChars)}\n[DSH]: ${truncate(assistantText || "(no text)", config.maxCaptureChars)}`;
|
|
289
|
+
let summary = `=== Final exchange, authoritative for outcome ===\n${defuseHeadings(body)}`;
|
|
276
290
|
|
|
277
291
|
if (config.summarizePlugin && resolveCli()) {
|
|
278
292
|
const res = await runMemsearch(["summarize", "--plugin", config.summarizePlugin, "--agent-name", "DSH"], { input: summary });
|
|
279
|
-
if (!res.err && res.stdout.trim()) summary = res.stdout.trim();
|
|
293
|
+
if (!res.err && res.stdout.trim()) summary = defuseHeadings(res.stdout.trim());
|
|
280
294
|
}
|
|
281
295
|
|
|
282
296
|
mkdirSync(memoryDir, { recursive: true });
|
|
@@ -345,4 +359,4 @@ function apply(ctx, config) {
|
|
|
345
359
|
}
|
|
346
360
|
}
|
|
347
361
|
|
|
348
|
-
export { Config, apply, extractExchange, inject, name };
|
|
362
|
+
export { Config, apply, defuseHeadings, extractExchange, inject, name };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-memsearch-community",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
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",
|