sage-mem 2.15.1 → 2.15.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.en.md +1 -1
- package/README.md +1 -1
- package/lib/client.js +46 -3
- package/lib/memory/scan.js +26 -5
- package/lib/typert.host.js +1 -1
- package/package.json +1 -1
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.
|
|
15
|
+
**Current release: `2.15.3`** — 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.
|
|
17
|
+
**当前发布版本:`2.15.3`** —— 顶部 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
|
@@ -4837,6 +4837,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
4837
4837
|
"todo.notice.stale": "文件刚被别处改过,已重新加载;这次改动没保存",
|
|
4838
4838
|
"todo.notice.degraded": "宿主还是升级前的版本:这次写入没有版本校验,请确认内容正确",
|
|
4839
4839
|
"todo.notice.undo": "已撤销上一步",
|
|
4840
|
+
"todo.notice.undoStale": "文件刚被别处改过,撤销 / 重做已作废(已重新加载)",
|
|
4840
4841
|
"todo.err.noRemote": "宿主没有记忆 remote,读不了待办文件",
|
|
4841
4842
|
"todo.err.read": "读不到待办文件:{error}",
|
|
4842
4843
|
"todo.err.write": "写入被拒:{error}",
|
|
@@ -4857,6 +4858,8 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
4857
4858
|
"todo.notice.archiveStale": "{count} 条已写进流水,但清单刚被别处改过:清单里那几行**没删**,刷新后再点一次即可(重复会被跳过)",
|
|
4858
4859
|
"todo.cp.title": "检查点里的未完成(只读)",
|
|
4859
4860
|
"todo.cp.note": "来自 tasks/*/WORKING.md 的「未完成」节。这里只显示,改动请回到那份检查点。",
|
|
4861
|
+
"todo.cp.truncated": "还有未列出的任务或条目(显示上限所致)",
|
|
4862
|
+
"todo.cp.skipped": "有 {count} 个任务读不出检查点,已跳过",
|
|
4860
4863
|
"todo.disabled.title": "待办看板已在「实验性」里关闭",
|
|
4861
4864
|
"todo.disabled.hint": "打开:设置 → 记忆管理 → 实验性 → 待办清单看板",
|
|
4862
4865
|
"todo.lab.title": "待办清单看板(实验性)",
|
|
@@ -5480,6 +5483,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
5480
5483
|
"todo.notice.stale": "The file changed elsewhere; reloaded. This edit was not saved.",
|
|
5481
5484
|
"todo.notice.degraded": "Host predates this version: the write had no revision check — verify the content.",
|
|
5482
5485
|
"todo.notice.undo": "Reverted the last edit",
|
|
5486
|
+
"todo.notice.undoStale": "The file changed elsewhere, so undo / redo was cancelled (reloaded)",
|
|
5483
5487
|
"todo.err.noRemote": "This host exposes no memory remote, so the to-do file cannot be read",
|
|
5484
5488
|
"todo.err.read": "Cannot read the to-do file: {error}",
|
|
5485
5489
|
"todo.err.write": "Write rejected: {error}",
|
|
@@ -5502,6 +5506,8 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
5502
5506
|
"todo.disabled.hint": "Turn it on: Settings → Memory management → Lab → To-do board",
|
|
5503
5507
|
"todo.cp.title": "Open items in checkpoints (read-only)",
|
|
5504
5508
|
"todo.cp.note": "From the open-work section of tasks/*/WORKING.md. Display only — edit the checkpoint itself.",
|
|
5509
|
+
"todo.cp.truncated": "More tasks or items exist than shown (display cap)",
|
|
5510
|
+
"todo.cp.skipped": "{count} task(s) could not be read and were skipped",
|
|
5505
5511
|
"todo.lab.title": "To-do board (experimental)",
|
|
5506
5512
|
"todo.lab.switch": "Enable the to-do board",
|
|
5507
5513
|
"todo.lab.switch.title": "Adds a To-dos tab to the right sidebar",
|
|
@@ -9931,6 +9937,19 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
9931
9937
|
try { s.setItem(key, value); } catch (e) { /* 偏好丢了不影响主流程 */ }
|
|
9932
9938
|
}
|
|
9933
9939
|
|
|
9940
|
+
/**
|
|
9941
|
+
* 撤销 / 重做现在还能不能做(2.15.3)。
|
|
9942
|
+
*
|
|
9943
|
+
* 判据:盘上的 revision 必须仍是我们**自己写出的那一版**。否则中间有人(AI、另一个页签)
|
|
9944
|
+
* 改过文件,写回整份快照会把那些改动一起抹掉 —— 那比「撤销失败」严重得多。
|
|
9945
|
+
* 拿不到 revision(老宿主 / 读失败)时按旧行为放行:没有判据可用时,宁可让用户能退回一步。
|
|
9946
|
+
*/
|
|
9947
|
+
function todoUndoAllowed(liveRevision, writtenRevision) {
|
|
9948
|
+
if (typeof writtenRevision !== "string" || writtenRevision === "") return true;
|
|
9949
|
+
if (typeof liveRevision !== "string" || liveRevision === "") return true;
|
|
9950
|
+
return liveRevision === writtenRevision;
|
|
9951
|
+
}
|
|
9952
|
+
|
|
9934
9953
|
/** 撤销步数归一:非数字 / 越界都收进 [3, 5],坏值(含 null / 空串)回默认 5。 */
|
|
9935
9954
|
function todoClampUndoDepth(n) {
|
|
9936
9955
|
if (n === null || n === undefined || n === "") return TODO_UNDO_DEFAULT;
|
|
@@ -10592,6 +10611,10 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10592
10611
|
]);
|
|
10593
10612
|
})) : null,
|
|
10594
10613
|
open ? h("div", { key: "note", className: "smem-todo-cp-note" }, t("todo.cp.note")) : null,
|
|
10614
|
+
// 2.15.2:宿主说了「被截断 / 有任务读不出来」就必须说出来 ——
|
|
10615
|
+
// 只说「检查点里的未完成」而不提这两件事,等于把不完整的清单当完整的给。
|
|
10616
|
+
props.truncated ? h("div", { key: "trunc", className: "smem-todo-cp-note" }, t("todo.cp.truncated")) : null,
|
|
10617
|
+
props.skipped > 0 ? h("div", { key: "skip", className: "smem-todo-cp-note" }, t("todo.cp.skipped", { count: props.skipped })) : null,
|
|
10595
10618
|
]);
|
|
10596
10619
|
}
|
|
10597
10620
|
|
|
@@ -10608,6 +10631,10 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10608
10631
|
const sErr = react.useState(null); const err = sErr[0], setErr = sErr[1];
|
|
10609
10632
|
const sNotice = react.useState(""); const notice = sNotice[0], setNotice = sNotice[1];
|
|
10610
10633
|
const sBusy = react.useState(false); const busy = sBusy[0], setBusy = sBusy[1];
|
|
10634
|
+
// 「我们自己写出的那一版」的 revision:撤销 / 重做只在文件仍停在这一版时才允许,
|
|
10635
|
+
// 否则整份快照会连别人(AI、另一个页签)期间的改动一起抹掉(2.15.3)。
|
|
10636
|
+
const sWritten = react.useState(null);
|
|
10637
|
+
const writtenRev = sWritten[0], setWrittenRev = sWritten[1];
|
|
10611
10638
|
// 撤销 / 重做:元素是写入前的 `{content, revision}`。栈**只在内存里**,
|
|
10612
10639
|
// 深度 3–5 可配(偏好落 localStorage);任何**新**写入都清空 redoStack —— 历史分叉了。
|
|
10613
10640
|
const sDepth = react.useState(function () { return todoClampUndoDepth(todoPrefGet(TODO_PREF_UNDO)); });
|
|
@@ -10633,7 +10660,12 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10633
10660
|
Promise.resolve(remote.checkpoints()).then(function (res) {
|
|
10634
10661
|
const data = unwrap(res);
|
|
10635
10662
|
if (!data || data.ok === false) { setCheckpoints(null); return; }
|
|
10636
|
-
|
|
10663
|
+
// 2.15.2:把「被截断」与「读不出来被跳过」也带上 —— 否则面板说的「完整」是假的。
|
|
10664
|
+
setCheckpoints({
|
|
10665
|
+
tasks: Array.isArray(data.tasks) ? data.tasks : [],
|
|
10666
|
+
truncated: data.truncated === true,
|
|
10667
|
+
skipped: typeof data.skipped === "number" ? data.skipped : 0,
|
|
10668
|
+
});
|
|
10637
10669
|
}, function () { /* 读不到就不显示,别在清单旁边堆一条错误 */ });
|
|
10638
10670
|
}, [remote]);
|
|
10639
10671
|
|
|
@@ -10716,6 +10748,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10716
10748
|
setErr(r.error || t("todo.err.write", { error: String(r.code || "error") }));
|
|
10717
10749
|
return;
|
|
10718
10750
|
}
|
|
10751
|
+
setWrittenRev(typeof r.revision === "string" ? r.revision : null);
|
|
10719
10752
|
setUndoStack(function (prev) { return prev.concat([snapshot]).slice(-undoDepth); });
|
|
10720
10753
|
setRedoStack([]);
|
|
10721
10754
|
setNotice(out.degraded ? t("todo.notice.degraded") : label);
|
|
@@ -10733,6 +10766,12 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10733
10766
|
*/
|
|
10734
10767
|
function writeSnapshot(target, label, onDone) {
|
|
10735
10768
|
if (!target || typeof target.content !== "string") return;
|
|
10769
|
+
// 2.15.3:盘上已经不是我们写出的那一版 → 撤销 / 重做作废(否则会抹掉别人的改动)。
|
|
10770
|
+
if (!todoUndoAllowed(doc.revision, writtenRev)) {
|
|
10771
|
+
setNotice(t("todo.notice.undoStale"));
|
|
10772
|
+
load(false);
|
|
10773
|
+
return;
|
|
10774
|
+
}
|
|
10736
10775
|
const revision = doc.revision;
|
|
10737
10776
|
setBusy(true); setErr(null); setNotice("");
|
|
10738
10777
|
writeWithFallback(remote, "writeFile", [TODO_FILE, target.content], revision ? { expectedRevision: revision } : undefined, null)
|
|
@@ -10744,6 +10783,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10744
10783
|
return;
|
|
10745
10784
|
}
|
|
10746
10785
|
if (typeof onDone === "function") onDone();
|
|
10786
|
+
setWrittenRev(typeof r.revision === "string" ? r.revision : null);
|
|
10747
10787
|
setNotice(label);
|
|
10748
10788
|
return load(false);
|
|
10749
10789
|
}, function (e) { setErr(String((e && e.message) || e)); })
|
|
@@ -10908,10 +10948,12 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10908
10948
|
const doneBlock = parsed.sections.find(function (sec) { return sec.kind === "done"; });
|
|
10909
10949
|
const doneBlockCount = doneBlock ? doneBlock.items.length : 0;
|
|
10910
10950
|
// 检查点区块的条目总数(只读,来自 tasks/*/WORKING.md)。
|
|
10911
|
-
const cpTasks = (checkpoints || []).filter(function (task) {
|
|
10951
|
+
const cpTasks = ((checkpoints && checkpoints.tasks) || []).filter(function (task) {
|
|
10912
10952
|
return task && Array.isArray(task.items) && task.items.length > 0;
|
|
10913
10953
|
});
|
|
10914
10954
|
const cpCount = cpTasks.reduce(function (n, task) { return n + task.items.length; }, 0);
|
|
10955
|
+
const cpTruncated = !!(checkpoints && checkpoints.truncated);
|
|
10956
|
+
const cpSkipped = (checkpoints && checkpoints.skipped) || 0;
|
|
10915
10957
|
|
|
10916
10958
|
return h("div", { className: "smem-todo" }, [
|
|
10917
10959
|
h("div", { key: "head", className: "smem-todo-head" }, [
|
|
@@ -10975,7 +11017,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10975
11017
|
err ? h("div", { key: "err", className: "smem-err" }, "⚠ " + err) : null,
|
|
10976
11018
|
notice ? h("div", { key: "ok", className: "smem-ok" }, "✓ " + notice) : null,
|
|
10977
11019
|
cpCount > 0
|
|
10978
|
-
? h(TodoCheckpointBlock, { key: "cp", tasks: cpTasks, count: cpCount })
|
|
11020
|
+
? h(TodoCheckpointBlock, { key: "cp", tasks: cpTasks, count: cpCount, truncated: cpTruncated, skipped: cpSkipped })
|
|
10979
11021
|
: null,
|
|
10980
11022
|
missing
|
|
10981
11023
|
? h("div", { key: "miss", className: "smem-todo-empty" }, t("todo.empty.file", { file: TODO_FILE }))
|
|
@@ -11170,6 +11212,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
11170
11212
|
PREF_UNDO: TODO_PREF_UNDO,
|
|
11171
11213
|
PREF_OPEN: TODO_PREF_OPEN,
|
|
11172
11214
|
clampDepth: todoClampUndoDepth,
|
|
11215
|
+
undoAllowed: todoUndoAllowed,
|
|
11173
11216
|
filterItems: todoFilterItems,
|
|
11174
11217
|
groupKey: todoGroupKey,
|
|
11175
11218
|
openMapParse: todoOpenMapParse,
|
package/lib/memory/scan.js
CHANGED
|
@@ -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
|
|
706
|
+
text = await readVerified(full, gate, 'utf8')
|
|
692
707
|
} catch (err) {
|
|
693
|
-
|
|
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
|
|
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
|
-
|
|
720
|
+
// `truncated` 现在同时表达「任务被截」「某任务的条目被截」—— 面板据此说「还有更多」。
|
|
721
|
+
const out = { ok: true, tasks, truncated: truncated || itemsTruncated }
|
|
722
|
+
if (skipped > 0) out.skipped = skipped
|
|
723
|
+
return out
|
|
703
724
|
}
|
package/lib/typert.host.js
CHANGED
|
@@ -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