sage-mem 2.15.1 → 2.15.2

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
@@ -12,7 +12,7 @@
12
12
 
13
13
  **Cross-session memory for DeepSeek Harness — plain markdown files, no database, no worker.**
14
14
 
15
- **Current release: `2.15.1`** — the npm badge above is the dynamic source of truth. **Contract baseline: `1.0.0`** — the first stable release, whose public commitments, the capability boundaries and the list of things it explicitly cannot do are frozen in the
15
+ **Current release: `2.15.2`** — the npm badge above is the dynamic source of truth. **Contract baseline: `1.0.0`** — the first stable release, whose public commitments, the capability boundaries and the list of things it explicitly cannot do are frozen in the
16
16
  [frozen contract](https://github.com/gezi-wen/sage-mem/blob/main/docs/1.0.0-contract.md).
17
17
 
18
18
  If it is useful to you, a Star is the most direct feedback.
package/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  > File-based cross-session memory for DeepSeek Harness — every memory is a plain markdown file you can open, edit and delete. No database, no worker, no port.
16
16
 
17
- **当前发布版本:`2.15.1`** —— 顶部 npm 徽章是动态权威。**契约基线:`1.0.0`** —— 第一个稳定版,公开承诺、能力边界与「明确做不到」的清单冻结在
17
+ **当前发布版本:`2.15.2`** —— 顶部 npm 徽章是动态权威。**契约基线:`1.0.0`** —— 第一个稳定版,公开承诺、能力边界与「明确做不到」的清单冻结在
18
18
  [契约冻结](https://github.com/gezi-wen/sage-mem/blob/main/docs/1.0.0-contract.md)。
19
19
 
20
20
  如果它对你有用,给个 Star 是最直接的反馈。
package/lib/client.js CHANGED
@@ -4857,6 +4857,8 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
4857
4857
  "todo.notice.archiveStale": "{count} 条已写进流水,但清单刚被别处改过:清单里那几行**没删**,刷新后再点一次即可(重复会被跳过)",
4858
4858
  "todo.cp.title": "检查点里的未完成(只读)",
4859
4859
  "todo.cp.note": "来自 tasks/*/WORKING.md 的「未完成」节。这里只显示,改动请回到那份检查点。",
4860
+ "todo.cp.truncated": "还有未列出的任务或条目(显示上限所致)",
4861
+ "todo.cp.skipped": "有 {count} 个任务读不出检查点,已跳过",
4860
4862
  "todo.disabled.title": "待办看板已在「实验性」里关闭",
4861
4863
  "todo.disabled.hint": "打开:设置 → 记忆管理 → 实验性 → 待办清单看板",
4862
4864
  "todo.lab.title": "待办清单看板(实验性)",
@@ -5502,6 +5504,8 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
5502
5504
  "todo.disabled.hint": "Turn it on: Settings → Memory management → Lab → To-do board",
5503
5505
  "todo.cp.title": "Open items in checkpoints (read-only)",
5504
5506
  "todo.cp.note": "From the open-work section of tasks/*/WORKING.md. Display only — edit the checkpoint itself.",
5507
+ "todo.cp.truncated": "More tasks or items exist than shown (display cap)",
5508
+ "todo.cp.skipped": "{count} task(s) could not be read and were skipped",
5505
5509
  "todo.lab.title": "To-do board (experimental)",
5506
5510
  "todo.lab.switch": "Enable the to-do board",
5507
5511
  "todo.lab.switch.title": "Adds a To-dos tab to the right sidebar",
@@ -10592,6 +10596,10 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
10592
10596
  ]);
10593
10597
  })) : null,
10594
10598
  open ? h("div", { key: "note", className: "smem-todo-cp-note" }, t("todo.cp.note")) : null,
10599
+ // 2.15.2:宿主说了「被截断 / 有任务读不出来」就必须说出来 ——
10600
+ // 只说「检查点里的未完成」而不提这两件事,等于把不完整的清单当完整的给。
10601
+ props.truncated ? h("div", { key: "trunc", className: "smem-todo-cp-note" }, t("todo.cp.truncated")) : null,
10602
+ props.skipped > 0 ? h("div", { key: "skip", className: "smem-todo-cp-note" }, t("todo.cp.skipped", { count: props.skipped })) : null,
10595
10603
  ]);
10596
10604
  }
10597
10605
 
@@ -10633,7 +10641,12 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
10633
10641
  Promise.resolve(remote.checkpoints()).then(function (res) {
10634
10642
  const data = unwrap(res);
10635
10643
  if (!data || data.ok === false) { setCheckpoints(null); return; }
10636
- setCheckpoints(Array.isArray(data.tasks) ? data.tasks : []);
10644
+ // 2.15.2:把「被截断」与「读不出来被跳过」也带上 —— 否则面板说的「完整」是假的。
10645
+ setCheckpoints({
10646
+ tasks: Array.isArray(data.tasks) ? data.tasks : [],
10647
+ truncated: data.truncated === true,
10648
+ skipped: typeof data.skipped === "number" ? data.skipped : 0,
10649
+ });
10637
10650
  }, function () { /* 读不到就不显示,别在清单旁边堆一条错误 */ });
10638
10651
  }, [remote]);
10639
10652
 
@@ -10908,10 +10921,12 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
10908
10921
  const doneBlock = parsed.sections.find(function (sec) { return sec.kind === "done"; });
10909
10922
  const doneBlockCount = doneBlock ? doneBlock.items.length : 0;
10910
10923
  // 检查点区块的条目总数(只读,来自 tasks/*/WORKING.md)。
10911
- const cpTasks = (checkpoints || []).filter(function (task) {
10924
+ const cpTasks = ((checkpoints && checkpoints.tasks) || []).filter(function (task) {
10912
10925
  return task && Array.isArray(task.items) && task.items.length > 0;
10913
10926
  });
10914
10927
  const cpCount = cpTasks.reduce(function (n, task) { return n + task.items.length; }, 0);
10928
+ const cpTruncated = !!(checkpoints && checkpoints.truncated);
10929
+ const cpSkipped = (checkpoints && checkpoints.skipped) || 0;
10915
10930
 
10916
10931
  return h("div", { className: "smem-todo" }, [
10917
10932
  h("div", { key: "head", className: "smem-todo-head" }, [
@@ -10975,7 +10990,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
10975
10990
  err ? h("div", { key: "err", className: "smem-err" }, "⚠ " + err) : null,
10976
10991
  notice ? h("div", { key: "ok", className: "smem-ok" }, "✓ " + notice) : null,
10977
10992
  cpCount > 0
10978
- ? h(TodoCheckpointBlock, { key: "cp", tasks: cpTasks, count: cpCount })
10993
+ ? h(TodoCheckpointBlock, { key: "cp", tasks: cpTasks, count: cpCount, truncated: cpTruncated, skipped: cpSkipped })
10979
10994
  : null,
10980
10995
  missing
10981
10996
  ? h("div", { key: "miss", className: "smem-todo-empty" }, t("todo.empty.file", { file: TODO_FILE }))
@@ -685,19 +685,40 @@ export async function scanCheckpointOpen(stateRoot) {
685
685
  .sort()
686
686
  const truncated = ids.length > CHECKPOINT_TASK_LIMIT
687
687
  const tasks = []
688
+ let itemsTruncated = false
689
+ let skipped = 0
688
690
  for (const id of ids.slice(0, CHECKPOINT_TASK_LIMIT)) {
691
+ const full = join(dir, id, CHECKPOINT_FILE_NAME)
692
+ // 2.15.2:走别的记忆文件同一套**形状闸门**(符号链接 / 目录联接一律不读,
693
+ // 体积在**读之前**按字节判)。原先这里裸 `readFile` 再比 `text.length`:
694
+ // 链接能被读成任意文件,而且 `length` 是 UTF-16 码元、不是字节(中文差三倍)。
695
+ const gate = await inspectMemoryEntry(full, { limitBytes: CHECKPOINT_READ_LIMIT })
696
+ if (!gate.ok) {
697
+ // 「这个任务没有 WORKING.md」是正常状态;别的失败要出声,否则面板会说「没有欠活」。
698
+ if (gate.code !== 'missing') {
699
+ skipped += 1
700
+ warnLog(`checkpoints: skip ${id}: ${gate.error}`)
701
+ }
702
+ continue
703
+ }
689
704
  let text = ''
690
705
  try {
691
- text = await readFile(join(dir, id, CHECKPOINT_FILE_NAME), 'utf8')
706
+ text = await readVerified(full, gate, 'utf8')
692
707
  } catch (err) {
693
- continue // 目录里没有 WORKING.md、或者读不了:跳过这一条
708
+ skipped += 1
709
+ warnLog(`checkpoints: skip ${id}: ${(err && err.message) || err}`)
710
+ continue
694
711
  }
695
- if (text.length > CHECKPOINT_READ_LIMIT) continue
696
712
  const parsed = parseCheckpoint(text)
697
713
  if (parsed.malformedReason !== '') continue
698
- const items = itemsOf(parsed.sections[TODO_SECTION] || '').slice(0, CHECKPOINT_ITEM_LIMIT)
714
+ const all = itemsOf(parsed.sections[TODO_SECTION] || '')
715
+ const items = all.slice(0, CHECKPOINT_ITEM_LIMIT)
699
716
  if (items.length === 0) continue
717
+ if (all.length > CHECKPOINT_ITEM_LIMIT) itemsTruncated = true
700
718
  tasks.push({ taskId: id, project: parsed.project, revision: parsed.revision, items })
701
719
  }
702
- return { ok: true, tasks, truncated }
720
+ // `truncated` 现在同时表达「任务被截」「某任务的条目被截」—— 面板据此说「还有更多」。
721
+ const out = { ok: true, tasks, truncated: truncated || itemsTruncated }
722
+ if (skipped > 0) out.skipped = skipped
723
+ return out
703
724
  }
@@ -656,7 +656,7 @@ const checkpointTaskSchema = z.object({
656
656
  }).readonly()
657
657
  const checkpointsResultSchema = z.object({
658
658
  'ok': z.boolean().readonly(), 'truncated': z.boolean().readonly(),
659
- 'tasks': z.array(checkpointTaskSchema).readonly(), 'error': z.string().readonly().optional(),
659
+ 'tasks': z.array(checkpointTaskSchema).readonly(), 'skipped': z.number().readonly().optional(), 'error': z.string().readonly().optional(),
660
660
  }).readonly()
661
661
 
662
662
  export const TYPERT = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sage-mem",
3
3
  "description": "Cross-session memory for DeepSeek Harness — plain markdown files, no database, no worker.",
4
- "version": "2.15.1",
4
+ "version": "2.15.2",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "icon": "./icon.png",