sage-mem 2.15.3 → 2.15.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
@@ -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.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
15
+ **Current release: `2.15.5`** — 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.3`** —— 顶部 npm 徽章是动态权威。**契约基线:`1.0.0`** —— 第一个稳定版,公开承诺、能力边界与「明确做不到」的清单冻结在
17
+ **当前发布版本:`2.15.5`** —— 顶部 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
@@ -2881,6 +2881,9 @@ const StarmapRuntime = (function (require, _react) {
2881
2881
  ".smem-todo-depth-select{width:auto;padding:0 2px;font-size:11.5px;}",
2882
2882
  // 「搬进流水」是待删除块的主动作(清空是丢弃、这条是留档),给品牌色。
2883
2883
  ".smem-todo-archive{font-weight:600;}",
2884
+ // 2.15.5:确认条独占一行,与「搬进流水」那颗按钮不在同一位置(双击打不到它)。
2885
+ ".smem-todo-confirm{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:6px 0 2px;border-top:1px dashed var(--dsw-alias-border-l1);}",
2886
+ ".smem-todo-confirm .smem-todo-archive{color:var(--dsw-alias-state-danger-primary,#ef4444);}",
2884
2887
  // 检查点聚合块:只读、来源是别的文件 —— 用虚线边框和正文色区分开。
2885
2888
  ".smem-todo-group-cp{border-style:dashed;}",
2886
2889
  ".smem-todo-cp-task{display:flex;flex-direction:column;gap:2px;padding:2px 0;}",
@@ -2892,7 +2895,7 @@ const StarmapRuntime = (function (require, _react) {
2892
2895
  ".smem-todo-done-title{font-weight:600;}",
2893
2896
  ].join("\n");
2894
2897
 
2895
- /**
2898
+ /**
2896
2899
  * 把输入框里的一串标签切成数组。
2897
2900
  *
2898
2901
  * 分隔符收半角逗号、全角逗号、顿号三种 —— 中文输入法下这三种都会自然敲出来。
@@ -10505,32 +10508,17 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
10505
10508
  h("span", { key: "n", className: "smem-todo-count" }, countText),
10506
10509
  ]),
10507
10510
  isDone && blockCount > 0
10508
- ? (confirming
10509
- ? h("button", {
10510
- key: "archiveConfirm",
10511
- type: "button",
10512
- className: "smem-todo-mini smem-todo-archive smem-todo-del",
10513
- title: t("todo.action.archiveConfirm.title", { count: blockCount, file: TODO_LOG_FILE }),
10514
- disabled: props.busy,
10515
- onClick: function () { setConfirming(false); props.onArchive(sec); },
10516
- }, t("todo.action.archiveConfirm", { count: blockCount }))
10517
- : h("button", {
10518
- key: "archive",
10519
- type: "button",
10520
- className: "smem-todo-mini smem-todo-archive",
10521
- title: t("todo.action.archive", { count: blockCount, file: TODO_LOG_FILE }),
10522
- disabled: props.busy,
10523
- onClick: function () { setConfirming(true); },
10524
- }, t("todo.action.archive", { count: blockCount, file: TODO_LOG_FILE })))
10525
- : null,
10526
- isDone && blockCount > 0 && confirming
10527
10511
  ? h("button", {
10528
- key: "archiveCancel",
10512
+ key: "archive",
10529
10513
  type: "button",
10530
- className: "smem-todo-mini",
10531
- disabled: props.busy,
10532
- onClick: function () { setConfirming(false); },
10533
- }, t("todo.action.cancel"))
10514
+ className: "smem-todo-mini smem-todo-archive",
10515
+ title: t("todo.action.archive", { count: blockCount, file: TODO_LOG_FILE }),
10516
+ // 2.15.5:进入确认态后**原位那颗按钮只变灰、不再响应**。
10517
+ // 之前是把确认按钮换到同一个位置 —— 双击的第二下正好落在确认上,
10518
+ // 一次误触就把不可逆动作做完了。确认按钮现在固定在**下面一行**。
10519
+ disabled: props.busy || confirming,
10520
+ onClick: function () { setConfirming(true); },
10521
+ }, t("todo.action.archive", { count: blockCount, file: TODO_LOG_FILE }))
10534
10522
  : null,
10535
10523
  isDone && blockCount > 0
10536
10524
  ? h("button", {
@@ -10543,6 +10531,26 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
10543
10531
  }, t("todo.action.clearDone", { count: blockCount }))
10544
10532
  : null,
10545
10533
  ]),
10534
+ // 确认条独占一行:位置与原按钮不同,双击打不到它。
10535
+ isDone && blockCount > 0 && confirming
10536
+ ? h("div", { key: "confirm", className: "smem-todo-confirm" }, [
10537
+ h("button", {
10538
+ key: "yes",
10539
+ type: "button",
10540
+ className: "smem-btn smem-btn-primary smem-todo-mini smem-todo-archive",
10541
+ title: t("todo.action.archiveConfirm.title", { count: blockCount, file: TODO_LOG_FILE }),
10542
+ disabled: props.busy,
10543
+ onClick: function () { setConfirming(false); props.onArchive(sec); },
10544
+ }, t("todo.action.archiveConfirm", { count: blockCount })),
10545
+ h("button", {
10546
+ key: "no",
10547
+ type: "button",
10548
+ className: "smem-todo-mini",
10549
+ disabled: props.busy,
10550
+ onClick: function () { setConfirming(false); },
10551
+ }, t("todo.action.cancel")),
10552
+ ])
10553
+ : null,
10546
10554
  collapsed ? null : h("div", { key: "list", className: "smem-todo-list" }, sec.items.length === 0
10547
10555
  ? [h("div", { key: "empty", className: "smem-todo-empty" }, isDone ? t("todo.empty.done") : t("todo.empty.section"))]
10548
10556
  : sec.items.map(function (it) {
@@ -15,7 +15,7 @@
15
15
  * 就是临时目录),拿模块级常量会写错地方 —— 那是会碰到真实记忆的危险错误。
16
16
  */
17
17
 
18
- import { ARCHIVE_DIR_NAME, addArchiveMeta, inspectDir, inspectMemoryEntry, localStamp, readArchivedMeta, stripArchiveMeta } from './scan.js'
18
+ import { ARCHIVE_DIR_NAME, addArchiveMeta, inspectDir, inspectMemoryEntry, localStamp, readArchivedMeta, shadowsReserved, stripArchiveMeta } from './scan.js'
19
19
  import { isReserved, nameKey, safeName } from './naming.js'
20
20
  import { revisionOf } from './chunks.js'
21
21
  import { retireTaken, returnSource, takeOverSource, writeFileAtomic, writeFileExclusive } from './util.js'
@@ -28,13 +28,31 @@ import { randomUUID } from 'node:crypto'
28
28
  /** 归档区绝对路径(按调用方给的记忆目录算)。 */
29
29
  export const archiveDirOf = (memoryDir) => join(memoryDir, ARCHIVE_DIR_NAME)
30
30
 
31
- /** 名字闸门:保留名 → 非 .md / 带路径成分。返回 { ok:true, safe } 或 { ok:false, code, error }。 */
32
- function checkName(name, verb) {
31
+ /**
32
+ * 名字闸门:保留名 → 非 .md / 带路径成分 → **保留名的另一个名字**(8.3 短名 / 硬链接)。
33
+ *
34
+ * 返回 `{ ok:true, safe }` 或 `{ ok:false, code, error }`。
35
+ *
36
+ * ⚠️ 2.15.4:第三条原先只在 read / write / delete 三条路径上做(`index.js`、`write-protocol.js`),
37
+ * 归档 / 恢复 / 彻底删除这一侧漏了 —— 于是 `archive('MEMORY~1.MD')`(或一个指向索引的硬链接名)
38
+ * 能把**索引本体**搬进归档区,`deleteArchived` 那条更是不可逆。三处入口现在共用这一份判据。
39
+ *
40
+ * @param {string} dir — 名字所在目录(归档时是记忆根,恢复 / 删除时是归档区):
41
+ * 身份判据必须对着**真正要动的那个文件所在目录**算,否则算出来的是另一棵树的保留名身份。
42
+ */
43
+ async function checkName(dir, name, verb) {
33
44
  if (isReserved(name)) {
34
45
  return { ok: false, code: 'reserved', error: `sage-mem: reserved file, refusing to ${verb}: ${nameKey(name)}` }
35
46
  }
36
47
  const safe = safeName(name)
37
48
  if (!safe) return { ok: false, code: 'invalid_name', error: `sage-mem: invalid file name: ${String(name)}` }
49
+ if (await shadowsReserved(join(dir, safe))) {
50
+ return {
51
+ ok: false,
52
+ code: 'reserved',
53
+ error: `sage-mem: reserved file (它的另一个名字是 ${safe}),拒绝${verb}`,
54
+ }
55
+ }
38
56
  return { ok: true, safe }
39
57
  }
40
58
 
@@ -48,7 +66,7 @@ function checkName(name, verb) {
48
66
  * @returns {Promise<{ok:true,file:string,archivedReason:string}|{ok:false,code:string,error:string}>}
49
67
  */
50
68
  export async function archiveMemory(memoryDir, name, reason, at = localStamp()) {
51
- const gate = checkName(name, 'archive')
69
+ const gate = await checkName(memoryDir, name, '归档')
52
70
  if (!gate.ok) return gate
53
71
  const safe = gate.safe
54
72
  /**
@@ -231,7 +249,7 @@ export async function archiveMemory(memoryDir, name, reason, at = localStamp())
231
249
  * 覆盖等于悄悄改掉一条活记忆。
232
250
  */
233
251
  export async function restoreMemory(memoryDir, name) {
234
- const gate = checkName(name, 'restore')
252
+ const gate = await checkName(archiveDirOf(memoryDir), name, '恢复')
235
253
  if (!gate.ok) return gate
236
254
  const safe = gate.safe
237
255
  const dst = join(memoryDir, safe)
@@ -414,7 +432,7 @@ export function archivedRevisionOf(content) {
414
432
  * @returns {Promise<{ok:true,file:string}|{ok:false,code:string,error:string}>}
415
433
  */
416
434
  export async function deleteArchivedMemory(memoryDir, name, expectedArchivedAt = '', expectedRevision = '') {
417
- const gate = checkName(name, 'delete')
435
+ const gate = await checkName(archiveDirOf(memoryDir), name, '彻底删除')
418
436
  if (!gate.ok) return gate
419
437
  const safe = gate.safe
420
438
  const dirGate = await inspectDir(archiveDirOf(memoryDir))
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.3",
4
+ "version": "2.15.5",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "icon": "./icon.png",