@stardustlc/dsh-dream 0.3.3 → 0.3.5

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.en.md CHANGED
@@ -4,15 +4,19 @@
4
4
 
5
5
  # dsh-dream
6
6
 
7
+ ## 0.3.4 update (2026-09-28)
8
+
9
+ Fixes [#2](https://github.com/STARDUSTLC666/dsh-dream/issues/2): digests now render human excerpts, assistant responses and tool names, skip truly empty sessions, and mask metadata as well as the body. Supports Harness v4 session files while excluding reasoning blocks and injected context from human excerpts.
10
+
7
11
  > **An agent that dreams**: session replay (dream material) → reflection (interpretation) → dream journal (memory consolidation).
8
12
 
9
13
  Humans consolidate memories by replaying the day during sleep — dsh-dream gives DeepSeek Harness agents the same ability. It reads your historical sessions (the official multi-frame zstd session logs, parsed with zero dependencies), distills dream material, lets the agent reflect, and writes permanent dream journal entries that can be recalled later.
10
14
 
11
15
  ## Compatibility
12
16
 
13
- Verified with official `@deepseek-ai/dsh@0.1.5-rc.1` and Node `24.16.0` on 2026-09-11: all 18 components load alongside Modlens, with passing tool-schema, skill-registration and offline read-only invocation checks. Uses the `cordis.patch.yml` + `dsh.bundle.patch` bundle model. Node requirements match this Harness release: 22.19 or later within 22.x, or 24 or later. Live external-service workflows require separate configuration and validation.
17
+ Validation host: Harness `0.2.0-rc.1` built from official sources (commit `407e65c8`) with Node `24.16.0` on 2026-09-28. All 64 plugin tests pass in an isolated environment; all 18 plugins mount together in one host registering 1 skills and 6 tools, with tool schemas and health-check contracts passing. No live ports or external services were exercised in this round.
14
18
 
15
- Reads v0/v1/v2/v3 plaintext JSONL and multi-frame zstd, legacy packed chunks and v2/v3 embedded streams. Only the newest canonical file is selected per session. PTC child calls retain tool names without double counting; system prompts, reasoning, tool arguments and result bodies are excluded.
19
+ Reads v0/v1/v2/v3/v4 plaintext JSONL and multi-frame zstd, legacy packed chunks and embedded streams. Only the newest canonical file is selected per session. PTC child calls retain tool names without double counting; system prompts, reasoning, tool arguments and result bodies are excluded.
16
20
 
17
21
  Default data directories follow `DSH_HOME`: `sessions` for session logs and `.dsh-dream` for the journal. Without `DSH_HOME`, the base is `~/.dsh`. Explicit `sessionsRoot` and `journalDir` settings take precedence.
18
22
 
package/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  # dsh-dream
4
4
 
5
+ ## 0.3.4 更新(2026-09-28)
6
+
7
+ 修复 [#2](https://github.com/STARDUSTLC666/dsh-dream/issues/2):摘要现在实际输出用户原话、助手回应和工具足迹;跳过真正空会话,标题与正文一并脱敏。支持新版 Harness 的 v4 会话文件,并过滤推理内容与自动注入的上下文,避免当作用户原话。
8
+
5
9
  > **会做梦的 agent**:会话回放(梦原料)→ 反思(解梦)→ 梦境日记(记忆巩固)。
6
10
 
7
11
  ![npm](https://img.shields.io/npm/v/@stardustlc/dsh-dream) ![downloads](https://img.shields.io/npm/dm/@stardustlc/dsh-dream) ![license](https://img.shields.io/github/license/STARDUSTLC666/dsh-dream) ![stars](https://img.shields.io/github/stars/STARDUSTLC666/dsh-dream?style=social)
@@ -10,9 +14,9 @@
10
14
 
11
15
  ## 兼容性
12
16
 
13
- 已在官方 `@deepseek-ai/dsh@0.1.5-rc.1`、Node `24.16.0` 上验证(2026-09-11):18 个组件与 Modlens 同载,工具 schema、技能注册及离线只读调用检查通过。采用 `cordis.patch.yml` + `dsh.bundle.patch` 组合包模型。Node 要求与该版本 Harness 一致:22.19 及以上的 22.x,或 24 及以上。外部服务的实际业务操作需按各组件配置单独验证。
17
+ 验证宿主:官方源码构建的 Harness `0.2.0-rc.1`(commit `407e65c8`)+ Node `24.16.0`(2026-09-28)。64 项插件测试在隔离环境全部通过;同一个宿主里 18 个插件共同加载,注册 1 个技能、6 个工具,工具 schema 与健康检查契约通过。本轮未启用真实端口与外部服务。
14
18
 
15
- 支持 v0/v1/v2/v3 的普通 JSONL 与多帧 zstd、旧 packed-chunk 行及 v2/v3 内嵌 stream;升级留下多代文件时只读取每个会话的最新规范文件。PTC 子工具调用保留工具名且不重复计数,不提取系统提示、推理、工具参数或结果正文。
19
+ 支持 v0/v1/v2/v3/v4 的普通 JSONL 与多帧 zstd、旧 packed-chunk 行及内嵌 stream;升级留下多代文件时只读取每个会话的最新规范文件。PTC 子工具调用保留工具名且不重复计数,不提取系统提示、推理、工具参数或结果正文。
16
20
 
17
21
  默认从 `DSH_HOME/sessions` 读取会话、在 `DSH_HOME/.dsh-dream` 保存日记;未设置 `DSH_HOME` 时使用 `~/.dsh`。配置中的 `sessionsRoot`、`journalDir` 始终优先。
18
22
 
package/lib/sessions.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * DSH 会话日志读取:兼容 v0/v1/v2/v3 的 JSONL 与多帧 zstd。
2
+ * DSH 会话日志读取:兼容 v0/v1/v2/v3/v4 的 JSONL 与多帧 zstd。
3
3
  * 首个逻辑行是会话头({ type: 'session', ... }),其后每行一条存储记录({ type, seq, time, data })。
4
4
  * 本模块只读不写;损坏帧/行一律容错跳过。
5
5
  *
@@ -37,20 +37,15 @@ function blockText(value) {
37
37
  return value;
38
38
  if (Array.isArray(value)) {
39
39
  return value
40
- .map((item) => {
41
- if (typeof item === 'string')
42
- return item;
43
- if (typeof item === 'object' && item !== null) {
44
- const rec = item;
45
- return typeof rec.text === 'string' ? rec.text : '';
46
- }
47
- return '';
48
- })
40
+ .map(blockText)
49
41
  .filter((text) => text !== '')
50
42
  .join('');
51
43
  }
52
44
  if (typeof value === 'object' && value !== null) {
53
45
  const rec = value;
46
+ // Assistant content can contain reasoning beside visible text (including v4).
47
+ if (typeof rec.type === 'string' && rec.type !== 'text')
48
+ return '';
54
49
  for (const key of ['text', 'content']) {
55
50
  const inner = blockText(rec[key]);
56
51
  if (inner !== '')
@@ -88,12 +83,14 @@ export function digestSessionFile(filePath, maxUserMessages) {
88
83
  if (lines.length === 0)
89
84
  return null;
90
85
  let header = null;
86
+ let formatVersion = 0;
91
87
  try {
92
88
  const first = JSON.parse(lines[0]);
93
89
  if (first.type !== 'session')
94
90
  return null;
95
- if (first.version !== undefined && ![0, 1, 2, 3].includes(first.version))
91
+ if (first.version !== undefined && ![0, 1, 2, 3, 4].includes(first.version))
96
92
  return null;
93
+ formatVersion = typeof first.version === 'number' ? first.version : 0;
97
94
  header = {
98
95
  id: String(first.id ?? ''),
99
96
  createdAt: typeof first.createdAt === 'number' ? first.createdAt : 0,
@@ -156,7 +153,7 @@ export function digestSessionFile(filePath, maxUserMessages) {
156
153
  const time = typeof rec.time === 'number' ? rec.time : typeof rec.time0 === 'number' ? rec.time0 : null;
157
154
  if (time !== null && (digest.endedAt === null || time > digest.endedAt))
158
155
  digest.endedAt = time;
159
- // v2/v3 把流式片段内嵌进 message/attempt;v0 的独立打包行继续兼容。
156
+ // v2/v3/v4 把流式片段内嵌进 message/attempt;v0 的独立打包行继续兼容。
160
157
  if ((type === 'assistant/message' || type === 'assistant/attempt') && typeof data === 'object' && data !== null) {
161
158
  const stream = data.stream;
162
159
  if (Array.isArray(stream))
@@ -170,6 +167,12 @@ export function digestSessionFile(filePath, maxUserMessages) {
170
167
  digest.turns++;
171
168
  }
172
169
  else if (type === 'user/message') {
170
+ if (formatVersion >= 4 && typeof data === 'object' && data !== null) {
171
+ const source = data.source;
172
+ // User-role injections are context, not the human's original words.
173
+ if (typeof source === 'object' && source !== null && source.kind !== 'user')
174
+ continue;
175
+ }
173
176
  const msg = textOf(data);
174
177
  if (msg !== '' && digest.userMessages.length < maxUserMessages * 2)
175
178
  digest.userMessages.push(msg);
package/lib/tools.js CHANGED
@@ -67,6 +67,9 @@ export function buildDreamTools(config) {
67
67
  for (const item of sessions) {
68
68
  const s = asRecord(item);
69
69
  lines.push('- ' + (s.title !== '' ? s.title : '(无标题)') + ':' + s.turns + ' 轮,目录 ' + s.cwd);
70
+ // execute already masks secrets and applies the full/brief character budget.
71
+ if (typeof s.digestText === 'string' && s.digestText !== '')
72
+ lines.push(s.digestText);
70
73
  }
71
74
  return [{ type: 'text', text: lines.join('\n') }];
72
75
  },
@@ -87,17 +90,20 @@ export function buildDreamTools(config) {
87
90
  continue;
88
91
  if (digest.origin === 'subagent')
89
92
  continue;
93
+ if (digest.turns === 0 && digest.userMessages.length === 0 && digest.assistantTail.length === 0
94
+ && digest.toolCalls.length === 0 && digest.streamTail.trim() === '')
95
+ continue;
90
96
  sessions.push({
91
97
  id: digest.id,
92
- title: digest.title,
98
+ title: mask(digest.title),
93
99
  createdAt: digest.createdAt,
94
100
  endedAt: digest.endedAt,
95
- cwd: digest.cwd,
101
+ cwd: mask(digest.cwd),
96
102
  turns: digest.turns,
97
- agentPreset: digest.agentPreset,
103
+ agentPreset: mask(digest.agentPreset),
98
104
  userMessages: digest.userMessages.map((msg) => clip(mask(msg), 400)),
99
105
  assistantTail: digest.assistantTail.map((msg) => clip(mask(msg), 600)),
100
- toolCalls: [...new Set(digest.toolCalls)],
106
+ toolCalls: [...new Set(digest.toolCalls)].map(mask),
101
107
  digestText: clip(mask(buildDigestText(digest)), mode === 'brief' ? 400 : cfg.maxCharsPerSession),
102
108
  });
103
109
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stardustlc/dsh-dream",
3
- "version": "0.3.3",
4
- "description": "DSH 做梦插件:agent 在会话间隙回放近期对话(dream_digest)、反思并写入梦境日记(dream_save/journal/recall),高频教训幂等桥接进 AGENTS.md(dream_bridge),六工具含健康自检。多帧 zstd 会话读取,默认隐私脱敏,零运行时依赖。",
3
+ "version": "0.3.5",
4
+ "description": "DSH 做梦插件:会话间隙回放近期对话、反思写入梦境日记,并把高频教训幂等桥接进 AGENTS.md;默认隐私脱敏,零运行时依赖。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",