sage-mem 2.11.1 → 2.12.0

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.11.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.12.0`** — 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.
@@ -29,6 +29,7 @@ If it is useful to you, a Star is the most direct feedback.
29
29
  - [Write Safety](#write-safety)
30
30
  - [Size Governance: What to Do When a Memory Grows Too Big](#size-governance-what-to-do-when-a-memory-grows-too-big)
31
31
  - [Autodream](#autodream)
32
+ - [Initial memory](#initial-memory-scaffold-the-library-with-an-agent-2120)
32
33
  - [Migrating from Claude Code](#migrating-from-claude-code)
33
34
  - [Configuration Reference](#configuration-reference)
34
35
  - [Stability and Versioning Policy](#stability-and-versioning-policy)
@@ -472,6 +473,20 @@ The two things are moved **differently**, spelled out:
472
473
  - **The file is still the only truth**: the board does line-level surgery only; edit the file with any tool and the board follows within 4 seconds.
473
474
  - **Hot**: flipping the switch takes effect immediately, no restart (unlike MMR).
474
475
  - **Off by default**; no drag-and-drop ordering, no automatic `session-log` archiving — moving those pending-deletion rows into the log is the agent's job at wrap-up. Details in `docs/todo-board.md`.
476
+
477
+ ## Initial memory: scaffold the library with an agent (2.12.0)
478
+
479
+ A freshly installed library is empty, and the agent has no idea how your memories should start — it either writes a diary or writes nothing at all.
480
+
481
+ The **Initial memory** card at the top of Settings → Memory management → Files holds a prompt you can execute directly: **copy** it (or **download the .md**), paste it to the agent in the conversation. It first looks at what your library already contains, then creates the `MEMORY.md` index, the `session-log.md` log and three starter memories (memory discipline / library layout / wrap-up routine).
482
+
483
+ ![Initial memory: copy this prompt to the agent and it scaffolds the library around what you already have](https://raw.githubusercontent.com/gezi-wen/sage-mem/main/docs/images/initial-guide.png)
484
+
485
+ - **The plugin writes no file at all**: the card only hands over text, and the agent does the writing — so "will this overwrite the memories I already have" simply cannot happen, and the prompt itself tells the agent to only add to existing files and to ask when unsure.
486
+ - The prompt only says what to do this time; the mechanics (frontmatter, the four prefixes, retrieval and injection) live in the bundled skill `skills/sage-mem/SKILL.md` and are not repeated.
487
+ - It starts expanded on an empty library and collapsed on a full one; copying pops a reminder — the next step is yours.
488
+ - Why this is not an install-time generator: see `docs/decisions.md` D46.
489
+
475
490
  ## Configuration Reference
476
491
 
477
492
  ### Environment Variables
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.11.1`** —— 顶部 npm 徽章是动态权威。**契约基线:`1.0.0`** —— 第一个稳定版,公开承诺、能力边界与「明确做不到」的清单冻结在
17
+ **当前发布版本:`2.12.0`** —— 顶部 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 是最直接的反馈。
@@ -31,6 +31,7 @@
31
31
  - [写入安全](#写入安全)
32
32
  - [体积治理:超线了怎么办](#体积治理超线了怎么办)
33
33
  - [自动做梦](#自动做梦)
34
+ - [初始记忆](#初始记忆让-agent-建个骨架2120)
34
35
  - [从 Claude Code 迁移](#从-claude-code-迁移)
35
36
  - [配置参考](#配置参考)
36
37
  - [稳定性与版本策略](#稳定性与版本策略)
@@ -472,6 +473,20 @@ sage-mem 给记忆目录的写入加了**版本守卫**:写入前记下当前
472
473
  - **文件仍是唯一真相**:看板只做行级手术,其余字节原样;你用任何编辑器改它,看板 4 秒内跟上。
473
474
  - **热的**:拨开关立刻生效,不用重启(与 MMR 不同)。
474
475
  - **默认关闭**;不做拖拽排序、不代写 `session-log` 留档 —— 把「待删除」搬进流水是 agent 收尾时的活。细节见 `docs/todo-board.md`。
476
+
477
+ ## 初始记忆:让 agent 建个骨架(2.12.0)
478
+
479
+ 新装的库是空的,而 agent 并不知道你的记忆该怎么起 —— 它要么把记忆写成日记,要么一条都不写。
480
+
481
+ 设置 → 记忆管理 → 文件列表顶部那张**初始记忆**卡片里,是一段可以直接执行的提示词:**复制**(或**下载 .md**),粘到会话里发给 agent。它会先看库里已经有什么,再建 `MEMORY.md` 索引、`session-log.md` 流水和三条起步记忆(记忆纪律 / 库结构 / 收尾动作)。
482
+
483
+ ![初始记忆:复制这段提示词粘给 agent,它会先看你已有的记忆再动手](https://raw.githubusercontent.com/gezi-wen/sage-mem/main/docs/images/initial-guide.png)
484
+
485
+ - **插件不写任何文件**:卡片只提供文本,动笔的是会话里的 agent —— 所以「会不会覆盖我已有的记忆」这个问题不存在;提示词本身也要求它「已有文件只做增量、拿不准就问」。
486
+ - 正文只讲「这次要做什么」;机制(frontmatter、四类前缀、检索与注入)在随包技能 `skills/sage-mem/SKILL.md` 里,不复述第二遍。
487
+ - 空库默认展开、老库默认收起;复制成功会弹一句提醒 —— 下一棒在你手里。
488
+ - 为什么不做成「安装时自动写」:取舍记录见 `docs/decisions.md` D46。
489
+
475
490
  ## 配置参考
476
491
 
477
492
  ### 环境变量
package/lib/client.js CHANGED
@@ -2651,6 +2651,13 @@ const StarmapRuntime = (function (require, _react) {
2651
2651
  ".smem-modcard-head{display:flex;align-items:center;gap:8px;margin-bottom:8px;}",
2652
2652
  ".smem-modcard-title{font-weight:600;font-size:13px;}",
2653
2653
  ".smem-modcard-head .smem-modcard-status{margin-left:auto;color:var(--dsw-alias-label-tertiary);font-size:12px;}",
2654
+ // 2.12.0 初始记忆卡片:卡头之后是一段可滚动的提示词正文(等宽、只读、可选中)。
2655
+ // 高度取 24vh 而不是撑满:面板是设置弹窗里的一屏,正文有五十来行,摊开会把
2656
+ // 文件列表挤到看不见 —— 需要看全文的人点「展开」或直接滚这一块。
2657
+ ".smem-guide{margin:0 0 12px;}",
2658
+ ".smem-guide-body{display:flex;flex-direction:column;gap:8px;}",
2659
+ ".smem-guide-preview{margin:0;padding:8px 10px;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:11.5px;line-height:1.5;white-space:pre-wrap;overflow-wrap:anywhere;overflow-y:auto;overflow-x:hidden;height:24vh;min-height:150px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);}",
2660
+ ".smem-guide-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap;}",
2654
2661
  // 关掉时的说明条:只解释「运行被停了」,不暗示设置被锁。
2655
2662
  ".smem-modcard-off{margin:6px 0 10px;padding:7px 10px;border-radius:8px;font-size:12px;line-height:1.6;color:var(--dsw-alias-state-warn-primary,#d97706);background:var(--dsw-alias-bg-layer-2);}",
2656
2663
  ".smem-err{border:1px solid var(--dsw-alias-state-error-primary,#ef4444);color:var(--dsw-alias-state-error-primary,#ef4444);border-radius:8px;padding:6px 10px;font-size:12px;white-space:pre-wrap;overflow-wrap:anywhere;}",
@@ -4722,6 +4729,27 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
4722
4729
  "prompt.copyFailedHint": "点一下文本框全选,再按 Ctrl+C 复制",
4723
4730
  "prompt.close": "关闭",
4724
4731
 
4732
+ // ── 2.12.0 初始记忆(提示词 + 复制提醒)──
4733
+ // 只有界面文案走 i18n;提示词**正文**是中文(与随包技能同一口径,见 66 分片头注)。
4734
+ "guide.title": "初始记忆:让 agent 建个骨架",
4735
+ "guide.status.empty": "库还是空的",
4736
+ "guide.status.filled": "库已有内容",
4737
+ "guide.status.copied": "已复制到剪贴板",
4738
+ "guide.expand": "展开",
4739
+ "guide.collapse": "收起",
4740
+ "guide.why1": "这段提示词只说明「这次要做什么」:索引怎么写、流水怎么记、起步建哪三条。机制(frontmatter、四类前缀、检索与注入)在随包技能里,不重复第二遍。",
4741
+ "guide.why2": "sage-mem 不会替你写任何记忆。复制它、粘到会话里发给 agent,由 agent 先看你库里已有什么,再决定新建还是只补一行 —— 已有文件不会被覆盖。",
4742
+ "guide.copy": "复制提示词",
4743
+ "guide.copy.again": "再复制一次",
4744
+ "guide.download": "下载 .md",
4745
+ "guide.hint": "复制后粘到会话里发给 agent 即可。",
4746
+ "guide.closedNote": "记忆库已经有内容了 —— 需要时展开,把这段提示词交给 agent,让它按现状补骨架。",
4747
+ "guide.notice.title": "已复制 —— 下一步在你手里",
4748
+ "guide.notice.step1": "1. 回到会话,把提示词整段粘进去发给 agent。",
4749
+ "guide.notice.step2": "2. agent 会先列出你已有的记忆,再只补缺的部分:索引、流水、三条起步记忆。",
4750
+ "guide.notice.hint": "它不会覆盖任何已有文件;拿不准时会先问你。",
4751
+ "guide.notice.ok": "知道了",
4752
+
4725
4753
  // ── 2.11.0 待办清单看板(右侧栏页签 + 实验性页那张卡)──
4726
4754
  "todo.tabTitle": "待办清单",
4727
4755
  "todo.guide.title": "待办清单",
@@ -5328,6 +5356,26 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
5328
5356
  "prompt.copyFailedHint": "Click the box to select it all, then press Ctrl+C",
5329
5357
  "prompt.close": "Close",
5330
5358
 
5359
+ // ── 2.12.0 initial memory (the prompt + the copy reminder) ──
5360
+ "guide.title": "Initial memory: let the agent scaffold the library",
5361
+ "guide.status.empty": "the library is still empty",
5362
+ "guide.status.filled": "the library already has content",
5363
+ "guide.status.copied": "copied to the clipboard",
5364
+ "guide.expand": "Expand",
5365
+ "guide.collapse": "Collapse",
5366
+ "guide.why1": "This prompt only says what to do this time: how to write the index, how to keep the log, which three starter memories to create. The mechanics (frontmatter, the four prefixes, retrieval and injection) live in the bundled skill and are not repeated here.",
5367
+ "guide.why2": "sage-mem never writes a memory for you. Copy this, paste it to the agent in the conversation, and let the agent look at what you already have before it decides to create a file or only add a line — existing files are never overwritten.",
5368
+ "guide.copy": "Copy prompt",
5369
+ "guide.copy.again": "Copy again",
5370
+ "guide.download": "Download .md",
5371
+ "guide.hint": "Paste it to the agent in the conversation after copying.",
5372
+ "guide.closedNote": "Your library already has content — expand this when you want the agent to fill in the gaps.",
5373
+ "guide.notice.title": "Copied — the next step is yours",
5374
+ "guide.notice.step1": "1. Go back to the conversation and paste the whole prompt to the agent.",
5375
+ "guide.notice.step2": "2. The agent first lists the memories you already have, then only fills in what is missing: index, log, three starter memories.",
5376
+ "guide.notice.hint": "It never overwrites an existing file, and it asks you when unsure.",
5377
+ "guide.notice.ok": "Got it",
5378
+
5331
5379
  // ── 2.11.0 to-do board (right-sidebar tab + its lab card) ──
5332
5380
  "todo.tabTitle": "To-dos",
5333
5381
  "todo.guide.title": "To-dos",
@@ -7228,6 +7276,204 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
7228
7276
  notice ? h("div", { className: "smem-ok", key: "ok" }, "✓ " + notice) : null,
7229
7277
  ]);
7230
7278
  }
7279
+ // ── 初始记忆:给 agent 的一份「建骨架」提示词(2.12.0)──────────────
7280
+ //
7281
+ // 为什么是**提示词**而不是插件替用户建文件(这是 2.12.0 唯一的设计取舍):
7282
+ // 1. 写盘会把「覆盖用户已有记忆」变成一个必须防的风险 —— 防它要状态文件、要
7283
+ // revision 守卫、要撤销栈,三样都是为「一个本不该有的写动作」付的保险费;
7284
+ // 2. 随包技能 `skills/sage-mem/SKILL.md` 已经把机制讲过了(frontmatter、四类
7285
+ // 前缀、检索与注入)。再来一份「初始记忆」正文,同一件事就有两份真相,
7286
+ // 然后开始漂 —— 这正是仓库里 duplication-test 在防的那类坏法;
7287
+ // 3. 「该建哪几条、用哪种语言、按谁的情况写」只有会话里的 agent 知道(它看得见
7288
+ // 用户、看得见现有库),插件在宿主里只看得见文件名。
7289
+ // 所以插件只负责一件事:给一份**可执行的清单**,复制走、粘给 agent。
7290
+ //
7291
+ // 单一真相源:正文只在本文件定义一次。卡片(`67-initial-guide-card.js`)只渲染与
7292
+ // 复制,不写自己的说法;测试直接对 `buildInitialGuide()` 的字符串断言。
7293
+ // 正文**只出中文**(与 `56-health-prompt.js`、`skills/sage-mem/SKILL.md` 同一口径),
7294
+ // 界面上的按钮与提示走 i18n(`guide.*`)。
7295
+
7296
+ /** 下载时用的文件名(卡片与测试共用一份,别在别处再拼一遍)。 */
7297
+ const INITIAL_GUIDE_FILE = "sage-mem-initial-memory.md";
7298
+
7299
+ /**
7300
+ * 提示词的正文行。
7301
+ *
7302
+ * ⚠️ 这里**不许**出现机制细节(frontmatter 字段表、检索打分、注入预算)——
7303
+ * 那些住随包技能里,写在这儿就是第二份真相。这里只写「这次要做什么、怎么不踩坑」。
7304
+ */
7305
+ function initialGuideLines() {
7306
+ return [
7307
+ "请帮我给这个 sage-mem 记忆库起一个骨架。这份清单只说「这次要做什么」;机制(frontmatter 字段、四类前缀、检索与注入)在随包技能里,下面不复述。",
7308
+ "",
7309
+ "════ 第 0 步 · 先看,别先写 ════",
7310
+ "1. 先读 sage-mem 技能(随包技能 skills/sage-mem/SKILL.md),确认 frontmatter 与四类前缀的写法。",
7311
+ "2. 先列出记忆目录里现在有什么(search_memory 或直接看目录)—— 这一步的结果决定后面每一步是「新建」还是「只补一行」。",
7312
+ "3. 已有文件一律只做增量:`MEMORY.md`、`session-log.md`、以及任何和我打算新建的文件同名或同 `name:` 的,先读全文,只在缺的地方补;不要覆盖、不要重排、不要顺手「整理一下」。拿不准就停下来问我。",
7313
+ "4. 不要为了凑齐清单而建文件:某一条我库里已经有相近内容,就跟我说「已有 X,跳过」,别再写一份。",
7314
+ "",
7315
+ "════ 第 1 步 · 索引 MEMORY.md ════",
7316
+ "文件开头一行写清这个库是什么;正文按四类分区,每类一个 `##` 小标题:用户(user_)、反馈与工作方式(feedback_)、项目与进行中的事(project_)、参考资料(reference_)。",
7317
+ "每类下面一行一条:`- [文件名](文件名) — 一句话它说什么`。",
7318
+ "索引里只留仍然有效的条目,归档的不进索引。",
7319
+ "以后每次新建 / 换类型 / 归档,都要同步这一行 —— 索引和目录对不上,检索就会漏(体检会报「漏索引 / 索引悬空」)。",
7320
+ "",
7321
+ "════ 第 2 步 · 流水 session-log.md ════",
7322
+ "开头一句说明用途(这是流水,不参与检索,也不算长期结论)。每条格式固定:",
7323
+ " ## YYYY-MM-DD HH:MM · 一句话标题",
7324
+ " - 做了什么",
7325
+ " - 决定了什么(以及为什么这么定)",
7326
+ " - 留了什么尾巴",
7327
+ "每场会话收尾追加一条;长期结论不要塞进流水,写进四类记忆。",
7328
+ "",
7329
+ "════ 第 2.5 步 · 三件别做的事 ════",
7330
+ "1. 别把一整场对话原样搬进记忆 —— 那是流水的事,不是记忆的事。",
7331
+ "2. 别为了「看起来完整」补一条以后没人会读的文件;宁可库里少一条。",
7332
+ "3. 别改我的既有写法:库里已经有格式(标题层级、字段顺序、语言)就跟随它,不要另立一套。",
7333
+ "",
7334
+ "════ 第 3 步 · 三条起步记忆 ════",
7335
+ "用 write(有 write_memory 就用它,没有就直接编辑文件)新建,正文按我的实际情况写,每条约 20–40 行。frontmatter 至少 name / description / metadata。",
7336
+ "不要预置我的个人信息,不要写版本号,不要写 `baseline: true`(那会让它每场都无条件注入)。",
7337
+ "",
7338
+ "1. feedback_memory-discipline.md —— 这个库记什么、不记什么。",
7339
+ " 必须写清:靠读代码 / git / 现有文档能推出来的不存;存的是推不出来的上下文(为什么这么定、踩过什么坑、我偏好什么)。四类前缀怎么选。什么时候该归档而不是继续加长。",
7340
+ "2. reference_memory-layout.md —— 库的结构。",
7341
+ " 必须写清:记忆目录在哪、archive/ 放什么、索引与流水各自的作用、可以用哪些工具读写(有 write_memory / search_memory 就写它们,没有就写「直接编辑文件」)。",
7342
+ "3. feedback_session-hygiene.md —— 会话收尾的固定动作。",
7343
+ " 必须写清:写流水;如果启用了待办清单看板,把「已完成,待删除」里的条目搬进流水再从清单删掉;没做完的事留在清单里,别当成结论写进流水。",
7344
+ "",
7345
+ "════ 第 4 步 · 收尾 ════",
7346
+ "1. 列出新建 / 修改了哪些文件,一条一行。",
7347
+ "2. 每条新建的记忆补一句:它为什么是「推不出来的」。",
7348
+ "3. 告诉我以后每场会话收尾要做什么(三行以内)。",
7349
+ "4. 有没做或不确定的,直说 —— 不要静悄悄略过。",
7350
+ ];
7351
+ }
7352
+
7353
+ /**
7354
+ * 组装后的提示词(**全库唯一入口**:卡片复制 / 下载都走它)。
7355
+ *
7356
+ * @returns {{text: string, file: string, lines: number}}
7357
+ */
7358
+ function buildInitialGuide() {
7359
+ const lines = initialGuideLines();
7360
+ return { text: lines.join("\n"), file: INITIAL_GUIDE_FILE, lines: lines.length };
7361
+ }
7362
+ // ── 初始记忆卡片(2.12.0):把 `66-initial-guide.js` 的提示词摊开、复制、下载 ──
7363
+ //
7364
+ // 三条约束(都由这个文件负责,正文不掺和):
7365
+ // 1. **不写盘**:卡片只读提示词,一个记忆文件都不碰 —— 「会不会覆盖我已有的记忆」
7366
+ // 这个问题因此不存在。真正动笔的是会话里的 agent,它能先看见用户库里有什么。
7367
+ // 2. **复制失败不许静默**(D25):剪贴板不可用时走 `PromptFallbackModal` 手抄;
7368
+ // 下载不可用时同样把文本摊出来 —— 那颗按钮点了没反应是最坏的形态。
7369
+ // 3. **提醒弹窗挂在 `.smem-root` 直属层**:`.smem-view` 有进场 transform,
7370
+ // `position:fixed` 会被那个祖先改写定位。所以卡片只**上报**事件,
7371
+ // 弹窗由 Section 在根层渲染(与 2.6.0 的复制提示词同一套壳)。
7372
+ //
7373
+ // 空库自动展开、老库默认收起:卡片是给「刚装完、库还空着」的人用的,
7374
+ // 已经有内容的人不该每次进来都看见一大段说明。
7375
+
7376
+ /** 卡片的展开状态:空库默认展开(这就是他们要做的事),有记忆时默认收起。 */
7377
+ function InitialGuideCard(props) {
7378
+ const empty = props && props.empty === true;
7379
+ const sOpen = react.useState(empty); const open = sOpen[0], setOpen = sOpen[1];
7380
+ const sCopied = react.useState(false); const copied = sCopied[0], setCopied = sCopied[1];
7381
+ const built = buildInitialGuide();
7382
+
7383
+ function copy() {
7384
+ copyPromptText(built.text).then(function (ok) {
7385
+ if (ok) {
7386
+ setCopied(true);
7387
+ if (props && typeof props.onCopied === "function") props.onCopied();
7388
+ return;
7389
+ }
7390
+ // 失败:把文本交回上层摊出来(不在这里渲染模态 —— 见文件头第 3 条)。
7391
+ if (props && typeof props.onCopyFailed === "function") props.onCopyFailed(built.text);
7392
+ });
7393
+ }
7394
+
7395
+ /** 下载成 .md:走 Blob + 临时 `<a download>`;任何一步不可用都退回复制兜底。 */
7396
+ function download() {
7397
+ const fallback = function () {
7398
+ if (props && typeof props.onCopyFailed === "function") props.onCopyFailed(built.text);
7399
+ };
7400
+ try {
7401
+ if (typeof document === "undefined" || !document || typeof document.createElement !== "function" ||
7402
+ typeof Blob !== "function" || typeof URL === "undefined" || typeof URL.createObjectURL !== "function") {
7403
+ fallback();
7404
+ return;
7405
+ }
7406
+ const url = URL.createObjectURL(new Blob([built.text], { type: "text/markdown;charset=utf-8" }));
7407
+ const a = document.createElement("a");
7408
+ a.href = url;
7409
+ a.download = built.file;
7410
+ document.body.appendChild(a);
7411
+ if (typeof a.click === "function") a.click();
7412
+ document.body.removeChild(a);
7413
+ URL.revokeObjectURL(url);
7414
+ } catch (e) {
7415
+ fallback();
7416
+ }
7417
+ }
7418
+
7419
+ const status = copied
7420
+ ? t("guide.status.copied")
7421
+ : (empty ? t("guide.status.empty") : t("guide.status.filled"));
7422
+
7423
+ return h("div", { className: "smem-guide smem-module-card" }, [
7424
+ h("div", { className: "smem-modcard-head", key: "head" }, [
7425
+ h("span", { className: "smem-modcard-title", key: "t" }, t("guide.title")),
7426
+ h("span", { className: "smem-modcard-status", key: "s" }, status),
7427
+ h("button", {
7428
+ type: "button", className: "smem-btn", key: "x",
7429
+ "aria-expanded": open ? "true" : "false",
7430
+ onClick: function () { setOpen(!open); },
7431
+ }, open ? t("guide.collapse") : t("guide.expand")),
7432
+ ]),
7433
+ open
7434
+ ? h("div", { className: "smem-guide-body", key: "body" }, [
7435
+ h("div", { className: "smem-autodream-note", key: "why1" }, t("guide.why1")),
7436
+ h("div", { className: "smem-autodream-note", key: "why2" }, t("guide.why2")),
7437
+ h("pre", { className: "smem-guide-preview", key: "preview" }, built.text),
7438
+ h("div", { className: "smem-guide-actions", key: "act" }, [
7439
+ h("button", {
7440
+ type: "button", className: "smem-btn smem-btn-primary", key: "copy",
7441
+ onClick: copy,
7442
+ }, copied ? t("guide.copy.again") : t("guide.copy")),
7443
+ h("button", { type: "button", className: "smem-btn", key: "dl", onClick: download }, t("guide.download")),
7444
+ h("span", { className: "smem-muted", key: "hint" }, t("guide.hint")),
7445
+ ]),
7446
+ ])
7447
+ : h("div", { className: "smem-autodream-note", key: "closed" }, t("guide.closedNote")),
7448
+ ]);
7449
+ }
7450
+
7451
+ /**
7452
+ * 复制成功后的提醒弹窗(渲染在 `.smem-root` 直属层,由 Section 挂)。
7453
+ *
7454
+ * 为什么要弹一下:复制成功是**没有视觉证据**的动作(剪贴板不可见),而下一步
7455
+ * 「粘到会话里发给 agent」是用户必须自己做的事 —— 不提醒,用户会以为插件已经建好了。
7456
+ */
7457
+ function InitialGuideNotice(props) {
7458
+ return h("div", { className: "smem-modal-host" }, [
7459
+ h("div", { className: "smem-modal-scrim", key: "scrim", onClick: props.onClose }),
7460
+ h("div", {
7461
+ className: "smem-modal", key: "m",
7462
+ role: "dialog", "aria-modal": "true",
7463
+ "aria-label": t("guide.notice.title"),
7464
+ }, [
7465
+ h("div", { className: "smem-modal-title", key: "t" }, t("guide.notice.title")),
7466
+ h("div", { className: "smem-modal-body", key: "b" }, [
7467
+ h("div", { key: "1" }, t("guide.notice.step1")),
7468
+ h("div", { key: "2", style: { marginTop: "6px" } }, t("guide.notice.step2")),
7469
+ h("div", { className: "smem-ar-hint", key: "3", style: { marginTop: "8px" } }, t("guide.notice.hint")),
7470
+ ]),
7471
+ h("div", { className: "smem-modal-foot", key: "f" }, [
7472
+ h("button", { type: "button", className: "smem-btn smem-btn-primary", key: "ok", onClick: props.onClose }, t("guide.notice.ok")),
7473
+ ]),
7474
+ ]),
7475
+ ]);
7476
+ }
7231
7477
  // ── 文件列表这一屏(1.5.3 从 Section 里抽出;D23 计划的 72 片)──────────
7232
7478
  // 只负责「按状态/筛选把卡片摆出来 + 四种空态」;状态、筛选语义、动作回调全部由 Section 传。
7233
7479
  // 抽出的判据:它是 Section 里最大的一块纯渲染,而卡片组件(Card / ArchivedCard)本来就在 50 共享层。
@@ -7314,7 +7560,13 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
7314
7560
  : list;
7315
7561
  }
7316
7562
 
7317
- return filesView;
7563
+ // 2.12.0:初始记忆卡片由**装配层**(Section)造好传进来(`guideCard`)。
7564
+ // 这一屏保持「只吃 props 的纯渲染」:不 import 卡片、也不判断库空不空 ——
7565
+ // 于是它单独被渲染(比如 Q16 那套只拼 05+55+50+72 的量具)时照样成立。
7566
+ // 没有卡片时**原样返回**(不包数组):旧调用点拿到的形状必须与 2.11.1 一致。
7567
+ if (!props.guideCard) return filesView;
7568
+ const body = Array.isArray(filesView) ? filesView : [filesView];
7569
+ return [props.guideCard].concat(body);
7318
7570
  }
7319
7571
 
7320
7572
  // ── 筛选条(1.5.2 从 Section 里抽出)────────────────────────────────
@@ -7544,6 +7796,10 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
7544
7796
  const toast = sToast[0], setToast = sToast[1];
7545
7797
  const sPromptFallback = react.useState(null);
7546
7798
  const promptFallback = sPromptFallback[0], setPromptFallback = sPromptFallback[1];
7799
+ // 2.12.0:初始记忆提示词「复制成功」后的提醒弹窗。状态放在 Section(根层),
7800
+ // 卡片只上报 —— `.smem-view` 的进场 transform 会让 `position:fixed` 失效。
7801
+ const sGuideNotice = react.useState(false);
7802
+ const guideNotice = sGuideNotice[0], setGuideNotice = sGuideNotice[1];
7547
7803
  // 更新提示:只在**确实有新版本**时才被赋值(查不到/限流/网络错都不赋值)
7548
7804
  const sUpdate = react.useState(null);
7549
7805
  const updateInfo = sUpdate[0], setUpdateInfo = sUpdate[1];
@@ -8581,9 +8837,19 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
8581
8837
  const healthWork = (audit && typeof audit.problems === "number" && audit.problems > 0 ? audit.problems : 0)
8582
8838
  + (conflictOpen > 0 ? conflictOpen : 0);
8583
8839
 
8840
+ // 2.12.0:初始记忆卡片(放在文件列表顶部,由装配层决定,FilesView 只负责摆)。
8841
+ // 骨架加载期间不渲染:`totalCount` 此刻还是 0,卡片会误判成空库并展开一次再收起。
8842
+ const guideCard = (loading && totalCount === 0) ? null : h(InitialGuideCard, {
8843
+ key: "guide",
8844
+ empty: totalCount === 0,
8845
+ onCopied: function () { setGuideNotice(true); },
8846
+ onCopyFailed: function (text) { setPromptFallback(text); },
8847
+ });
8848
+
8584
8849
  // 「文件列表」这一屏:状态筛选决定看哪一批,灰色卡片与留痕块自带「退役」语义。
8585
8850
  // banner 只在**专门看归档**时出现,切到全部时不重复说一遍。
8586
8851
  const filesView = h(FilesView, {
8852
+ guideCard: guideCard,
8587
8853
  loading: loading, totalCount: totalCount, openAdd: openAdd, createIndexSkeleton: createIndexSkeleton,
8588
8854
  statusFilter: statusFilter, setStatusFilter: setStatusFilter,
8589
8855
  items: items, archiveItems: archiveItems, filtered: filtered,
@@ -8901,6 +9167,8 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
8901
9167
  toast ? h(Toast, { key: "toast", text: toast, closeTitle: t("prompt.close"), onClose: function () { setToast(null); } }) : null,
8902
9168
  // 复制失败时把提示词摊出来手抄;用户手动关(× / 关闭 / 点遮罩)。
8903
9169
  promptFallback ? h(PromptFallbackModal, { key: "prompt-fallback", text: promptFallback, onClose: function () { setPromptFallback(null); } }) : null,
9170
+ // 2.12.0:初始记忆提示词复制成功的提醒(下一棒在用户手里:粘进会话发给 agent)。
9171
+ guideNotice ? h(InitialGuideNotice, { key: "guide-notice", onClose: function () { setGuideNotice(false); } }) : null,
8904
9172
  // 底部一行仓库链接(四个 tab 都在,不抢视线)
8905
9173
  h(StarLine, { key: "star-line" }),
8906
9174
  ]);
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.11.1",
4
+ "version": "2.12.0",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "icon": "./icon.png",
@@ -219,3 +219,21 @@ node <技能目录>/scripts/memory-audit.cjs [记忆目录]
219
219
  - **改的是记忆内容** → 本技能。
220
220
  - **改的是插件本身**(注入逻辑、检索算法、索引生成)→ 那是代码问题,去读插件仓库的 `lib/`,不是改记忆能修的。
221
221
  - **记忆目录由谁决定** → 环境变量 `SAGE_MEM_DIR`(插件读它)。不确定当前用哪个目录时,看设置页,或读一次 `search_memory` 返回的 `file` 字段路径。
222
+
223
+ ---
224
+
225
+ ## 十二、从零开始:初始记忆提示词(2.12.0)
226
+
227
+ 库是空的、你还不知道该建哪些文件时,别自己发明一套 —— 打开 **设置 → 记忆管理 → 文件列表**,顶上那张「初始记忆」卡片里是一段可以直接执行的清单:**复制提示词**(或**下载 .md**),粘到会话里发给 agent。
228
+
229
+ **这张卡不会写任何记忆文件**,这是设计而不是省略:插件在宿主里只看得见文件名,看不见「这个人已经有了什么、想要什么语言」;而写盘会立刻带出「会不会覆盖已有记忆」的问题。所以插件只负责给清单,动笔的是会话里的 agent。
230
+
231
+ **如果你是收到这段提示词的那个 agent**,按这个顺序做:
232
+
233
+ 1. **先读本技能**(前十一节)—— frontmatter、四类前缀、检索规则都在那儿,提示词不复述。
234
+ 2. **先看库里有什么**:`search_memory` 或直接看目录。这一步决定后面是「新建」还是「只补一行」。
235
+ 3. **已有文件只做增量**:`MEMORY.md`、`session-log.md`、或任何同名 / 同 `name:` 的文件,先读全文,只在缺的地方补;**不要覆盖、不要重排、不要顺手整理**。拿不准就问用户。
236
+ 4. 建索引(`MEMORY.md`)、流水(`session-log.md`)与三条起步记忆(记忆纪律 / 库结构 / 收尾动作)。四类分区的格式见第五节、第七节。
237
+ 5. 收尾列清楚:新建了哪些文件、每条为什么是「推不出来的」、以后每场收尾该做什么。
238
+
239
+ **为什么不是安装时自动生成**:那要防覆盖(状态文件 + revision 守卫 + 撤销栈),而收到提示词的 agent 本来就知道用户库里有什么 —— 用不着为一次没人要求的写动作付这些代价。取舍记录在仓库的 `docs/decisions.md` D46。