dsh-memory-palace 1.6.2-alpha.2 → 1.6.2-alpha.4

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 CHANGED
@@ -82,7 +82,7 @@ turn/end ──► 轻量兜底闸门
82
82
 
83
83
  ```bash
84
84
  dsh plugin --profile web add github:lovezi0/dsh-memory-palace
85
- # 锁定版本:dsh plugin --profile web add github:lovezi0/dsh-memory-palace#v1.6.2-alpha.2
85
+ # 锁定版本:dsh plugin --profile web add github:lovezi0/dsh-memory-palace#v1.6.2-alpha.4
86
86
  ```
87
87
 
88
88
  方式二:clone 后本地安装(开发 / 修改源码场景)
@@ -124,6 +124,8 @@ dsh plugin --profile web remove dsh-memory-palace
124
124
  ## 版本历史
125
125
 
126
126
  - **1.6.2**
127
+ - **1.6.2.alpha.4**
128
+ - 🔥适配deepseek harness 0.1.2-alpha.4
127
129
  - **1.6.2.alpha.2**
128
130
  - 原1.6.0发布
129
131
  - **1.6.1**
@@ -0,0 +1,11 @@
1
+ // memory-palace v1.6.2-alpha.4 DSH 0.1.2-alpha.4 兼容层:Session.events getter 已被删除
2
+ // (宿主 27bf1039「distinguish event seqs from log offsets」顺带移除),替代 API 为
3
+ // snapshotEvents(from, toExclusive)——半开区间、from 含、返回冻结数组;运行时 seq 仍是
4
+ // 普通 number,wire/磁盘格式不变。旧版宿主(≤0.1.2-alpha.3)无此方法,回退 events + filter。
5
+ // 统一出口:调用方零分支,语义 =「取 seq >= fromSeq 的事件(升序)」。
6
+ export function eventsFrom(session, fromSeq = 0) {
7
+ if (typeof session?.snapshotEvents === "function") {
8
+ return session.snapshotEvents(fromSeq);
9
+ }
10
+ return (session?.events || []).filter((e) => e.seq >= fromSeq);
11
+ }
package/lib/distill.mjs CHANGED
@@ -5,6 +5,7 @@ import { join, dirname } from "node:path";
5
5
  import { BlockAssembler, createUserMessage } from "@deepseek-ai/dsh-llm";
6
6
  import { SUMMARY_PROMPT, DISTILL_PROMPT } from "./common/prompts.mjs";
7
7
  import { expandHome, readMdSync, toHomeShort, nowStamp, stripSmartTag } from "./common/text.mjs";
8
+ import { eventsFrom } from "./common/session.mjs";
8
9
  import { appendLineDedup, readNumberedMemory, applyMemoryOp } from "./common/records.mjs";
9
10
  import { runWithRetry, RETRY_CONSTANTS } from "./common/retry.mjs";
10
11
 
@@ -114,10 +115,9 @@ export function createDistill({ ctx, getConfig, paths, records, state }) {
114
115
  }
115
116
  const { provider, model } = resolved;
116
117
  // 2. 输入:取 seq >= fromSeq 的 surface 事件,投影成模型视角 Message[]。
118
+ // v1.6.2-alpha.4:eventsFrom 兼容层(宿主 0.1.2-alpha.4 删除 Session.events getter)。
117
119
  const SURFACE = new Set(["user/message", "assistant/message", "tool/result"]);
118
- const newEvents = (session.events || []).filter(
119
- (e) => e.seq >= fromSeq && SURFACE.has(e.type),
120
- );
120
+ const newEvents = eventsFrom(session, fromSeq).filter((e) => SURFACE.has(e.type));
121
121
  dbg("session core entry", { sessionId: session.id, fromSeq, eventsLen: newEvents.length });
122
122
  const hist = [];
123
123
  for (const e of newEvents) {
@@ -125,7 +125,7 @@ export function createDistill({ ctx, getConfig, paths, records, state }) {
125
125
  if (m) hist.push(m);
126
126
  }
127
127
  if (!hist.length) {
128
- dbgFail("no events in range", { fromSeq, eventsLen: (session.events || []).length, newEvents: newEvents.length, hasDerive: !!session.deriveEventMessage });
128
+ dbgFail("no events in range", { fromSeq, eventsLen: eventsFrom(session).length, newEvents: newEvents.length, hasDerive: !!session.deriveEventMessage });
129
129
  return { ok: false };
130
130
  }
131
131
  // 2.5 回喂存量记忆(v1.4.0 特性3):仅当 useFeedback 时,读取项目级 + 用户级 MEMORY.md 全文
@@ -10,6 +10,7 @@ import { writeFile, mkdir } from "node:fs/promises";
10
10
  import { join, dirname } from "node:path";
11
11
  import { BlockAssembler, createUserMessage, createToolResultMessage } from "@deepseek-ai/dsh-llm";
12
12
  import { todayISO, readMdSync } from "../common/text.mjs";
13
+ import { eventsFrom } from "../common/session.mjs";
13
14
  import { appendToSectionText, upsertSectionText, createSectionText, markEntryDeletedText, parseSections, locateSection } from "../common/sections.mjs";
14
15
  import { HYBRID_PROACTIVE, SUBAGENT_SYSTEM } from "./prompts.mjs";
15
16
 
@@ -66,10 +67,11 @@ async function streamTurn(ctx, params, timeoutMs) {
66
67
  }
67
68
 
68
69
  // 把本轮 surface 事件投影为消息数组(seq >= fromSeq;与 distillSessionCore 同源逻辑)。
70
+ // v1.6.2-alpha.4:eventsFrom 兼容层(宿主 0.1.2-alpha.4 删除 Session.events getter)。
69
71
  function projectTurnMessages(session, fromSeq) {
70
72
  const hist = [];
71
- for (const e of session.events || []) {
72
- if (e.seq < fromSeq || !SURFACE.has(e.type)) continue;
73
+ for (const e of eventsFrom(session, fromSeq)) {
74
+ if (!SURFACE.has(e.type)) continue;
73
75
  const m = session.deriveEventMessage ? session.deriveEventMessage(e) : null;
74
76
  if (m) hist.push(m);
75
77
  }
package/lib/index.js CHANGED
@@ -30,6 +30,7 @@ import { todayISO, expandHome, toHomeShort, readMdSync, budgetClip, stripSmartTa
30
30
  import { SCENE_KEYWORDS } from "./common/prompts.mjs";
31
31
  import { createPaths } from "./common/paths.mjs";
32
32
  import { createRecords } from "./common/records.mjs";
33
+ import { eventsFrom } from "./common/session.mjs";
33
34
  import { createDistill } from "./distill.mjs";
34
35
  import { registerTools } from "./tools.mjs";
35
36
  import { registerApi } from "./api.mjs";
@@ -298,10 +299,12 @@ export function apply(ctx, config) {
298
299
  // v1.1.3 修复:turnBuffer 字符上限(30k)仍可能截断超长工具型 request,导致 hasTool 误判为
299
300
  // false(tool 块被裁剪)→ 结算闸门误关 → 记忆整体丢失。智能模式闸门改用 session 事件增量
300
301
  // (真实完整信号,不依赖会被裁剪的 turnBuffer)。
301
- if (!baseGateOpen && state.activeSession && state.activeSession.events) {
302
+ // v1.6.2-alpha.4:宿主 0.1.2-alpha.4 删除 Session.events getter,事件读取统一走
303
+ // eventsFrom 兼容层(snapshotEvents 半开区间,旧宿主回退 events+filter)。
304
+ if (!baseGateOpen && state.activeSession) {
302
305
  const SURFACE = new Set(["user/message", "assistant/message", "tool/result"]);
303
- const newEvents = state.activeSession.events.filter(
304
- (e) => e.seq >= state.lastSummarizedSeq && SURFACE.has(e.type),
306
+ const newEvents = eventsFrom(state.activeSession, state.lastSummarizedSeq).filter(
307
+ (e) => SURFACE.has(e.type),
305
308
  );
306
309
  if (newEvents.some((e) => e.type === "tool/result")) baseGateOpen = true;
307
310
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-memory-palace",
3
- "version": "1.6.2-alpha.2",
3
+ "version": "1.6.2-alpha.4",
4
4
  "description": "把 WorkBuddy 的文件式记忆系统移植进 DeepSeek Harness:用户级 + 工作区的人类可读 Markdown 记忆(~/.deepseek-harness/MEMORY.md 与 <cwd>/.deepseek-harness/memory/)。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",