sage-mem 2.10.2 → 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/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;}",
@@ -2796,6 +2803,55 @@ const StarmapRuntime = (function (require, _react) {
2796
2803
  ".smem-conf-label{font-size:11.5px;font-weight:600;color:var(--dsw-alias-label-secondary);}",
2797
2804
  ".smem-conf-pre{margin:0;max-height:220px;overflow:auto;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;line-height:1.55;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--dsw-alias-label-primary);}",
2798
2805
  ".smem-conf-warn{font-size:11.5px;color:var(--dsw-alias-state-warn-primary,#d97706);}",
2806
+
2807
+ // ── 2.11.0 待办清单看板(右侧栏页签)──────────────────────────
2808
+ // 宿主把页签正文放进一个 `overflow:hidden` 的固定高度盒子里(实测 797px),
2809
+ // 正文自己不设高度就会长到内容高(1924px)然后被裁掉 —— 手指够不到下面。
2810
+ // 所以根节点必须**自己吃满高度并滚**,不能指望宿主代滚。
2811
+ ".smem-todo{height:100%;max-height:100%;min-height:0;flex:1 1 auto;box-sizing:border-box;overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;gap:8px;padding:0 10px 12px;font-size:12.5px;line-height:1.55;color:var(--dsw-alias-label-primary);}",
2812
+ // 顶部统计条吸顶:滚到第 20 条时仍然知道总数。
2813
+ ".smem-todo-head{position:sticky;top:0;z-index:2;display:flex;align-items:center;gap:8px;flex-wrap:wrap;font-size:11.5px;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-l1);backdrop-filter:blur(8px);padding:10px 0 8px;border-bottom:1px solid var(--dsw-alias-border-l1);}",
2814
+ ".smem-todo-stat{font-variant-numeric:tabular-nums;}",
2815
+ ".smem-todo-head > span[data-spring]{flex:1;}",
2816
+ ".smem-todo-mini{font-size:11.5px;background:none;border:0;padding:0;cursor:pointer;color:var(--dsw-alias-brand-primary,#3b82f6);}",
2817
+ ".smem-todo-mini:disabled{opacity:.45;cursor:default;}",
2818
+ ".smem-todo-groups{display:flex;flex-direction:column;gap:10px;}",
2819
+ ".smem-todo-search-row{display:flex;align-items:center;gap:8px;padding:0 0 2px;}",
2820
+ ".smem-todo-search{flex:1;min-width:0;font-size:12px;}",
2821
+ ".smem-todo-group{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;padding:8px 9px;display:flex;flex-direction:column;gap:6px;flex:0 0 auto;}",
2822
+ // 待删除块整块走红色系:它是**队列**不是结论,看得见的红提醒「这些该搬走了」。
2823
+ ".smem-todo-group-done{border-color:var(--dsw-alias-state-danger-primary,#ef4444);}",
2824
+ ".smem-todo-group-done .smem-todo-group-title{color:var(--dsw-alias-state-danger-primary,#ef4444);}",
2825
+ // 2.11.1:标题行改成「行」—— 右侧要放「清空全部」,按钮不能套按钮。
2826
+ ".smem-todo-group-head{display:flex;align-items:center;gap:6px;width:100%;min-width:0;}",
2827
+ ".smem-todo-group-toggle{flex:1;min-width:0;display:flex;align-items:center;gap:6px;background:none;border:0;padding:0;cursor:pointer;color:inherit;text-align:left;}",
2828
+ ".smem-todo-del{color:var(--dsw-alias-state-danger-primary,#ef4444);}",
2829
+ ".smem-todo-chev{color:var(--dsw-alias-label-secondary);font-size:10px;width:10px;}",
2830
+ ".smem-todo-group-title{font-weight:600;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}",
2831
+ ".smem-todo-count{font-size:11px;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-secondary);}",
2832
+ // 顶部统计条右侧的图标按钮(撤销 / 重做):无边框、跟文字同色、栈空时半透明。
2833
+ ".smem-todo-icon-btn{display:inline-flex;align-items:center;justify-content:center;width:22px;height:20px;padding:0;border:0;border-radius:6px;background:none;color:currentColor;cursor:pointer;}",
2834
+ ".smem-todo-icon-btn:hover:not(:disabled){background:var(--dsw-alias-bg-l2);}",
2835
+ ".smem-todo-icon-btn:disabled{opacity:.35;cursor:default;}",
2836
+ ".smem-todo-list{display:flex;flex-direction:column;gap:6px;}",
2837
+ ".smem-todo-item{display:flex;gap:8px;align-items:flex-start;border-radius:8px;padding:4px 2px;}",
2838
+ ".smem-todo-item:hover{background:var(--dsw-alias-bg-l2);}",
2839
+ ".smem-todo-box{flex:0 0 auto;width:16px;height:16px;margin-top:1px;border-radius:5px;border:1px solid var(--dsw-alias-border-l2);background:transparent;color:transparent;font-size:11px;line-height:1;display:flex;align-items:center;justify-content:center;cursor:pointer;padding:0;}",
2840
+ ".smem-todo-box-on{background:var(--dsw-alias-brand-primary,#3b82f6);border-color:transparent;color:#fff;}",
2841
+ ".smem-todo-body{min-width:0;flex:1;display:flex;flex-direction:column;gap:2px;}",
2842
+ ".smem-todo-title{font-weight:600;overflow-wrap:anywhere;}",
2843
+ ".smem-todo-text{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;white-space:pre-wrap;}",
2844
+ ".smem-todo-ref{border-radius:4px;padding:0 3px;background:var(--dsw-alias-bg-l2);color:var(--dsw-alias-label-secondary);font-size:11.5px;}",
2845
+ ".smem-todo-code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;border-radius:4px;padding:0 3px;background:var(--dsw-alias-bg-l2);}",
2846
+ ".smem-todo-item-done .smem-todo-title{text-decoration:line-through;opacity:.6;}",
2847
+ ".smem-todo-item-done .smem-todo-text{opacity:.6;}",
2848
+ ".smem-todo-actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap;}",
2849
+ ".smem-todo-edit{width:100%;resize:vertical;font-size:12px;}",
2850
+ ".smem-todo-add{padding-top:2px;}",
2851
+ ".smem-todo-add-input{width:100%;font-size:12px;}",
2852
+ ".smem-todo-empty{font-size:11.5px;color:var(--dsw-alias-label-secondary);padding:4px 0;}",
2853
+ ".smem-todo-done-state{display:flex;flex-direction:column;gap:6px;padding:16px 12px;}",
2854
+ ".smem-todo-done-title{font-weight:600;}",
2799
2855
  ].join("\n");
2800
2856
 
2801
2857
  /**
@@ -4672,6 +4728,82 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
4672
4728
  "prompt.copyFailedTitle": "复制没成功 —— 手动复制这段提示词",
4673
4729
  "prompt.copyFailedHint": "点一下文本框全选,再按 Ctrl+C 复制",
4674
4730
  "prompt.close": "关闭",
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
+
4753
+ // ── 2.11.0 待办清单看板(右侧栏页签 + 实验性页那张卡)──
4754
+ "todo.tabTitle": "待办清单",
4755
+ "todo.guide.title": "待办清单",
4756
+ "todo.guide.desc": "跨会话待办:勾选、补一条、改一句",
4757
+ "todo.fallbackSection": "未分节",
4758
+ "todo.stat": "{open} 条未完成 · {done} 条已完成 · {sections} 节",
4759
+ "todo.refresh": "刷新",
4760
+ "todo.expandAll": "全部展开",
4761
+ "todo.search.placeholder": "在清单里搜…",
4762
+ "todo.search.count": "{count} 条匹配",
4763
+ "todo.search.none": "没有匹配的条目",
4764
+ "todo.collapseAll": "全部收起",
4765
+ "todo.more": "展开",
4766
+ "todo.less": "收起",
4767
+ "todo.empty.file": "没找到 {file}。这份看板只读它 —— 先让它在记忆目录里生成。",
4768
+ "todo.empty.section": "这一节还没有条目",
4769
+ "todo.empty.done": "待删除块是空的:勾选一条,它就会搬到这里",
4770
+ "todo.add.placeholder": "加一条,回车保存",
4771
+ "todo.doneGroup": "已完成,待删除",
4772
+ "todo.action.check": "标记完成(搬进「已完成,待删除」块)",
4773
+ "todo.action.uncheck": "取消完成(搬回原组末尾)",
4774
+ "todo.action.edit": "编辑",
4775
+ "todo.action.save": "保存",
4776
+ "todo.action.cancel": "取消",
4777
+ "todo.action.delete": "删除",
4778
+ "todo.action.clearDone": "清空全部({count})",
4779
+ "todo.action.undo": "撤销",
4780
+ "todo.action.redo": "重做",
4781
+ "todo.notice.added": "已添加",
4782
+ "todo.notice.edited": "已保存",
4783
+ "todo.notice.movedToDone": "已完成,已搬进「{group}」",
4784
+ "todo.notice.restored": "已搬回原组",
4785
+ "todo.notice.deleted": "已删除该条",
4786
+ "todo.notice.redone": "已重做",
4787
+ "todo.notice.cleared": "已清空 {count} 条待删除",
4788
+ "todo.notice.stale": "文件刚被别处改过,已重新加载;这次改动没保存",
4789
+ "todo.notice.degraded": "宿主还是升级前的版本:这次写入没有版本校验,请确认内容正确",
4790
+ "todo.notice.undo": "已撤销上一步",
4791
+ "todo.err.noRemote": "宿主没有记忆 remote,读不了待办文件",
4792
+ "todo.err.read": "读不到待办文件:{error}",
4793
+ "todo.err.write": "写入被拒:{error}",
4794
+ "todo.disabled.title": "待办看板已在「实验性」里关闭",
4795
+ "todo.disabled.hint": "打开:设置 → 记忆管理 → 实验性 → 待办清单看板",
4796
+ "todo.lab.title": "待办清单看板(实验性)",
4797
+ "todo.lab.switch": "启用待办清单看板",
4798
+ "todo.lab.switch.title": "在右侧栏加一个「待办清单」页签",
4799
+ "todo.lab.what": "把记忆目录里的 project_session-state.md(跨会话代办清单)画成卡片:勾选 = 把那条搬进「已完成,待删除」块,新增 / 编辑 / 删除只改那一行,别的字节原样不动。",
4800
+ "todo.lab.live": "改完立刻生效,不用重启(与上面的 MMR 不同)。文件本身仍是唯一真相:AI 直接改它,看板 4 秒内跟上。",
4801
+ "todo.lab.unsupported": "当前宿主没有右侧栏(sidebarRightTabs),这个开关在这里不生效。",
4802
+ "todo.lab.status.on": "已开启",
4803
+ "todo.lab.status.off": "关闭(默认)",
4804
+ "todo.lab.onNotice": "已开启:右侧栏「+」里能看到待办清单",
4805
+ "todo.lab.offNotice": "已关闭:卡片已移除,已打开的页签会显示为关闭态",
4806
+ "todo.lab.rejected": "宿主拒绝了这次设置",
4675
4807
  };
4676
4808
 
4677
4809
  const EN = {
@@ -5223,6 +5355,81 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
5223
5355
  "prompt.copyFailedTitle": "Copy failed — copy this prompt by hand",
5224
5356
  "prompt.copyFailedHint": "Click the box to select it all, then press Ctrl+C",
5225
5357
  "prompt.close": "Close",
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
+
5379
+ // ── 2.11.0 to-do board (right-sidebar tab + its lab card) ──
5380
+ "todo.tabTitle": "To-dos",
5381
+ "todo.guide.title": "To-dos",
5382
+ "todo.guide.desc": "Cross-session to-dos: tick, add, edit",
5383
+ "todo.fallbackSection": "Unsorted",
5384
+ "todo.stat": "{open} open · {done} done · {sections} groups",
5385
+ "todo.refresh": "Refresh",
5386
+ "todo.expandAll": "Expand all",
5387
+ "todo.search.placeholder": "Search the list…",
5388
+ "todo.search.count": "{count} match(es)",
5389
+ "todo.search.none": "No matching item",
5390
+ "todo.collapseAll": "Collapse all",
5391
+ "todo.more": "More",
5392
+ "todo.less": "Less",
5393
+ "todo.empty.file": "{file} is not in the memory directory yet — this board reads that one file.",
5394
+ "todo.empty.section": "Nothing in this group yet",
5395
+ "todo.empty.done": "Nothing pending deletion: tick an item and it moves here",
5396
+ "todo.add.placeholder": "Add an item, Enter to save",
5397
+ "todo.doneGroup": "Done, pending deletion",
5398
+ "todo.action.check": "Mark done (moves the item into the pending-deletion block)",
5399
+ "todo.action.uncheck": "Undo done (moves it back to its group)",
5400
+ "todo.action.edit": "Edit",
5401
+ "todo.action.save": "Save",
5402
+ "todo.action.cancel": "Cancel",
5403
+ "todo.action.delete": "Delete",
5404
+ "todo.action.clearDone": "Clear all ({count})",
5405
+ "todo.action.undo": "Undo",
5406
+ "todo.action.redo": "Redo",
5407
+ "todo.notice.added": "Added",
5408
+ "todo.notice.edited": "Saved",
5409
+ "todo.notice.movedToDone": "Done: moved into {group}",
5410
+ "todo.notice.restored": "Moved back to its group",
5411
+ "todo.notice.deleted": "Deleted",
5412
+ "todo.notice.redone": "Redone",
5413
+ "todo.notice.cleared": "Cleared {count} pending-deletion item(s)",
5414
+ "todo.notice.stale": "The file changed elsewhere; reloaded. This edit was not saved.",
5415
+ "todo.notice.degraded": "Host predates this version: the write had no revision check — verify the content.",
5416
+ "todo.notice.undo": "Reverted the last edit",
5417
+ "todo.err.noRemote": "This host exposes no memory remote, so the to-do file cannot be read",
5418
+ "todo.err.read": "Cannot read the to-do file: {error}",
5419
+ "todo.err.write": "Write rejected: {error}",
5420
+ "todo.disabled.title": "The to-do board is switched off in the lab settings",
5421
+ "todo.disabled.hint": "Turn it on: Settings → Memory management → Lab → To-do board",
5422
+ "todo.lab.title": "To-do board (experimental)",
5423
+ "todo.lab.switch": "Enable the to-do board",
5424
+ "todo.lab.switch.title": "Adds a To-dos tab to the right sidebar",
5425
+ "todo.lab.what": "Renders project_session-state.md (the cross-session to-do list) as cards: ticking moves the item into the pending-deletion block; adding, editing and deleting touch that line only — every other byte stays as it is.",
5426
+ "todo.lab.live": "Takes effect immediately, no restart (unlike MMR above). The file stays the only source of truth: edit it directly and the board follows within 4 seconds.",
5427
+ "todo.lab.unsupported": "This host has no right sidebar (sidebarRightTabs), so the switch does nothing here.",
5428
+ "todo.lab.status.on": "On",
5429
+ "todo.lab.status.off": "Off (default)",
5430
+ "todo.lab.onNotice": "On: the to-do board is in the right sidebar's + menu",
5431
+ "todo.lab.offNotice": "Off: the card is gone; an open tab now shows the closed state",
5432
+ "todo.lab.rejected": "The host rejected the setting",
5226
5433
  };
5227
5434
 
5228
5435
  /**
@@ -6749,6 +6956,9 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
6749
6956
  h("div", { key: "c" }, t("lab.declare.default")),
6750
6957
  ]),
6751
6958
 
6959
+ // ── 2.11.0 新增:待办清单看板(界面入口类开关,改完立刻生效)──
6960
+ h(TodoBoardLabCard, { key: "todos", ctx: props.ctx }),
6961
+
6752
6962
  // 错误与回执留在最后:不管在哪按的,结果都得看得见。
6753
6963
  err ? h("div", { className: "smem-err", key: "err" }, "⚠ " + err) : null,
6754
6964
  notice ? h("div", { className: "smem-ok", key: "ok" }, "✓ " + notice) : null,
@@ -7066,6 +7276,204 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
7066
7276
  notice ? h("div", { className: "smem-ok", key: "ok" }, "✓ " + notice) : null,
7067
7277
  ]);
7068
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
+ }
7069
7477
  // ── 文件列表这一屏(1.5.3 从 Section 里抽出;D23 计划的 72 片)──────────
7070
7478
  // 只负责「按状态/筛选把卡片摆出来 + 四种空态」;状态、筛选语义、动作回调全部由 Section 传。
7071
7479
  // 抽出的判据:它是 Section 里最大的一块纯渲染,而卡片组件(Card / ArchivedCard)本来就在 50 共享层。
@@ -7152,7 +7560,13 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
7152
7560
  : list;
7153
7561
  }
7154
7562
 
7155
- 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);
7156
7570
  }
7157
7571
 
7158
7572
  // ── 筛选条(1.5.2 从 Section 里抽出)────────────────────────────────
@@ -7382,6 +7796,10 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
7382
7796
  const toast = sToast[0], setToast = sToast[1];
7383
7797
  const sPromptFallback = react.useState(null);
7384
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];
7385
7803
  // 更新提示:只在**确实有新版本**时才被赋值(查不到/限流/网络错都不赋值)
7386
7804
  const sUpdate = react.useState(null);
7387
7805
  const updateInfo = sUpdate[0], setUpdateInfo = sUpdate[1];
@@ -8419,9 +8837,19 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
8419
8837
  const healthWork = (audit && typeof audit.problems === "number" && audit.problems > 0 ? audit.problems : 0)
8420
8838
  + (conflictOpen > 0 ? conflictOpen : 0);
8421
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
+
8422
8849
  // 「文件列表」这一屏:状态筛选决定看哪一批,灰色卡片与留痕块自带「退役」语义。
8423
8850
  // banner 只在**专门看归档**时出现,切到全部时不重复说一遍。
8424
8851
  const filesView = h(FilesView, {
8852
+ guideCard: guideCard,
8425
8853
  loading: loading, totalCount: totalCount, openAdd: openAdd, createIndexSkeleton: createIndexSkeleton,
8426
8854
  statusFilter: statusFilter, setStatusFilter: setStatusFilter,
8427
8855
  items: items, archiveItems: archiveItems, filtered: filtered,
@@ -8739,6 +9167,8 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
8739
9167
  toast ? h(Toast, { key: "toast", text: toast, closeTitle: t("prompt.close"), onClose: function () { setToast(null); } }) : null,
8740
9168
  // 复制失败时把提示词摊出来手抄;用户手动关(× / 关闭 / 点遮罩)。
8741
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,
8742
9172
  // 底部一行仓库链接(四个 tab 都在,不抢视线)
8743
9173
  h(StarLine, { key: "star-line" }),
8744
9174
  ]);
@@ -9232,6 +9662,953 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
9232
9662
  ]);
9233
9663
  }));
9234
9664
  }
9665
+ // ── 待办清单看板(2.11.0 · 实验性 / 2.11.1 勾选改「搬家」)─────────────
9666
+ //
9667
+ // 数据源**唯一**:`memory/project_session-state.md`(跨会话代办清单,baseline 每场注入)。
9668
+ // 面板只做**行级手术**:勾选 = 把那一行从原组删掉、搬进「已完成,待删除」块;
9669
+ // 新增 / 编辑 / 删除只动那几行,其余字节(frontmatter、引用块、空行、别的节)原样带走。
9670
+ //
9671
+ // 为什么勾选是**搬家**而不是加 `[x]`(2.11.1,用户反馈 2026-11-17):完成项留在原组里,
9672
+ // 原组就越读越长,而「已完成」本来只该是**待清理的队列**。搬进单独一块之后,
9673
+ // agent 收尾时一眼就能看见该搬哪几条进 `session-log.md`、搬完从这块删掉。
9674
+ // 这也把「谁来删」从模型自觉变成了一个显式位置 —— 见 `skills/sage-mem/SKILL.md`。
9675
+ //
9676
+ // 为什么不建自己的存储:用户要的是「AI 直接在 md 里调试」—— 同一个文件是唯一真相,
9677
+ // 面板只是它的另一种视图。第二份状态一定会漂移,而漂移的代价是「看板说做完了、文件里还在」。
9678
+ //
9679
+ // 承载面走**官方**注册表(`sidebarRightTabs`):
9680
+ // 1. 给 tab 类型 `sage-mem:todo` + 一条 guide 条目(开始页卡片自动出现,better-sidebar 也读这张表);
9681
+ // 2. 正文注册进键控槽 `sidebar.right.pane.tab`,标题注册进 `sidebar.right.pane.tab.title`;
9682
+ // 3. **definition + body 常驻,只有 guide 随开关变** —— 关掉开关时已打开的页签不会变成孤儿,
9683
+ // 它只是切到「已关闭」态。热开关靠的就是这条:注销 → 下一拍重注册(Phase 0 已实测)。
9684
+
9685
+ /** 看板认的那一个文件(唯一真相源:改这个名字只改这里)。 */
9686
+ const TODO_FILE = "project_session-state.md";
9687
+ const TODO_TAB_ID = "sage-mem-todo";
9688
+ const TODO_TAB_KIND = "sage-mem:todo";
9689
+ const TODO_GUIDE_ID = "sage-mem-todo";
9690
+ /** 轮询间隔:AI 用普通编辑工具改文件后,面板最多这么久就该跟上。 */
9691
+ const TODO_POLL_MS = 4000;
9692
+ /** 卡片正文折叠阈值(字符数;右栏很窄,两三行就够看了)。 */
9693
+ const TODO_DETAIL_CHARS = 150;
9694
+ /** 没有 `##` 节时条目落进这个兜底组。 */
9695
+ const TODO_SECTION_FALLBACK = "todo.fallbackSection";
9696
+ /** 「已完成,待删除」块:标题匹配它就算 done 组(`kind: "done"`)。 */
9697
+ const TODO_DONE_PATTERN = /已完成|待删除/;
9698
+ /**
9699
+ * 文件里还没有这个块时,第一次勾选按这行标题建块。
9700
+ * **字面量写进文件,不跟界面语言走** —— 它是文件格式的一部分,不是 UI 文案。
9701
+ */
9702
+ const TODO_DONE_HEADING = "## 已完成,待删除";
9703
+ /** 撤销 / 重做各留几步(用户要两步;再多会让人误以为能回滚一整天)。 */
9704
+ const TODO_UNDO_DEPTH = 2;
9705
+
9706
+ /** 开关状态(模块级:设置卡与页签共享)。 */
9707
+ let todoBoardEnabled = false;
9708
+ /** 当前 definition 是否带着 guide 卡片(避免每次 apply 都白重注册一次)。 */
9709
+ let todoBoardGuideShown = false;
9710
+ let todoBoardCtx = null;
9711
+ let todoBoardRegistryDispose = null;
9712
+ let todoBoardBodyDispose = null;
9713
+ let todoBoardTitleDispose = null;
9714
+ const todoBoardListeners = new Set();
9715
+
9716
+ /** 无条件调用的钩子替身(宿主没给 `useTabInfo` 时用,避免条件调 hook)。 */
9717
+ function todoBoardNoTabInfo() { return null; }
9718
+
9719
+ function todoBoardNotify() {
9720
+ todoBoardListeners.forEach(function (fn) {
9721
+ try { fn(); } catch (e) { /* 单个订阅者坏掉不影响别的 */ }
9722
+ });
9723
+ }
9724
+
9725
+ /** 订阅开关变化(页签正文与设置卡都靠它重渲染)。 */
9726
+ function useTodoBoardEnabled() {
9727
+ const s = react.useState(todoBoardEnabled);
9728
+ const setV = s[1];
9729
+ react.useEffect(function () {
9730
+ const fn = function () { setV(todoBoardEnabled); };
9731
+ todoBoardListeners.add(fn);
9732
+ fn();
9733
+ return function () { todoBoardListeners.delete(fn); };
9734
+ }, []);
9735
+ return s[0];
9736
+ }
9737
+
9738
+ // ── 解析:markdown → 节 + 条目(纯函数,不碰 IO)────────────────────
9739
+
9740
+ /**
9741
+ * 条目标题:`**…**` 里的那一截;没有就用 null(渲染时不画标题行,正文自己说话)。
9742
+ * @param {string} text 条目正文(`- ` 之后,已剥掉 `[x]`)
9743
+ */
9744
+ function todoItemTitle(text) {
9745
+ const bold = /\*\*(.+?)\*\*/.exec(text);
9746
+ return bold ? bold[1].trim() : null;
9747
+ }
9748
+
9749
+ /**
9750
+ * 条目正文:去掉开头那段 `**标题**` 与紧随的分隔符 —— 标题已经在上面单独画了一行,
9751
+ * 正文再带一遍就是同一句话说两次(第一次真机截图就是这么发现的)。
9752
+ */
9753
+ function todoItemDetail(text) {
9754
+ const body = String(text == null ? "" : text);
9755
+ const m = /^\s*\*\*(?:.+?)\*\*/.exec(body);
9756
+ if (!m) return body.trim();
9757
+ return body.slice(m[0].length).replace(/^[\s—–\-::、,,。]+/, "").trim();
9758
+ }
9759
+
9760
+ /**
9761
+ * 极简内联渲染:`**加粗**` / `` `代码` `` / `[[记忆]]`。其余原样。
9762
+ * 不引 markdown 解析器:这里只显示,不需要块级语法。
9763
+ */
9764
+ function todoInline(text) {
9765
+ const out = [];
9766
+ const re = /(\*\*[^*]+\*\*|`[^`]+`|\[\[[^\]]+\]\])/g;
9767
+ let last = 0;
9768
+ let m;
9769
+ let i = 0;
9770
+ while ((m = re.exec(text)) !== null) {
9771
+ if (m.index > last) out.push(text.slice(last, m.index));
9772
+ const tok = m[0];
9773
+ if (tok.startsWith("**")) out.push(h("strong", { key: "b" + i }, tok.slice(2, -2)));
9774
+ else if (tok.startsWith("[[")) out.push(h("span", { key: "l" + i, className: "smem-todo-ref" }, tok.slice(2, -2)));
9775
+ else out.push(h("code", { key: "c" + i, className: "smem-todo-code" }, tok.slice(1, -1)));
9776
+ last = m.index + tok.length;
9777
+ i += 1;
9778
+ }
9779
+ if (last < text.length) out.push(text.slice(last));
9780
+ return out;
9781
+ }
9782
+
9783
+ /**
9784
+ * 拆一份代办清单。**只读**:`lines` 原样保留,条目只记「行号 + 内容」,
9785
+ * 写回时按行号替换,所以任何没被操作的字节都不会变。
9786
+ *
9787
+ * @param {string} text
9788
+ * @returns {{lines: string[], sections: Array<object>, open: number, done: number}}
9789
+ */
9790
+ function parseTodoList(text) {
9791
+ const lines = String(text == null ? "" : text).split("\n");
9792
+ const sections = [];
9793
+ let current = null;
9794
+ let lastItem = null;
9795
+ let inFront = false;
9796
+ let seenContent = false;
9797
+ let open = 0;
9798
+ let done = 0;
9799
+ for (let i = 0; i < lines.length; i++) {
9800
+ // 分析用去掉行尾 `\r`(CRLF 文件读得懂);`lines` 本身原样留着,写回不动没碰过的行。
9801
+ const rawLine = lines[i];
9802
+ const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
9803
+ if (!seenContent && /^---\s*$/.test(line)) { inFront = true; seenContent = true; continue; }
9804
+ if (inFront) {
9805
+ if (/^---\s*$/.test(line)) inFront = false;
9806
+ continue;
9807
+ }
9808
+ if (line.trim() !== "") seenContent = true;
9809
+ const heading = /^##\s+(.*)$/.exec(line);
9810
+ if (heading) {
9811
+ const title = heading[1].trim();
9812
+ // 三档:done(「已完成,待删除」块,勾选搬进这里)/ constraint(长期约束,别删)/ 普通待办。
9813
+ const kind = TODO_DONE_PATTERN.test(title) ? "done" : (/长期约束|不是待办|别删/.test(title) ? "constraint" : "todo");
9814
+ current = { title: title, kind: kind, items: [], insertAt: i + 1, headingIndex: i };
9815
+ sections.push(current);
9816
+ lastItem = null;
9817
+ continue;
9818
+ }
9819
+ const bullet = /^(\s*)-\s+(.*)$/.exec(line);
9820
+ if (bullet && bullet[1] !== "" && lastItem !== null) {
9821
+ // 缩进的 `- ` 是上一条的子项(真文件里只有缩进续行):并进 cont,**不**算新条目。
9822
+ let sub = bullet[2];
9823
+ const subBox = /^\[([ xX])\]\s*(.*)$/.exec(sub);
9824
+ if (subBox) sub = subBox[2];
9825
+ lastItem.cont += (lastItem.cont ? " " : "") + sub;
9826
+ continue;
9827
+ }
9828
+ if (bullet) {
9829
+ let body = bullet[2];
9830
+ let isDone = false;
9831
+ const box = /^\[([ xX])\]\s*(.*)$/.exec(body);
9832
+ if (box) { isDone = box[1].toLowerCase() === "x"; body = box[2]; }
9833
+ if (current === null) {
9834
+ current = { title: "", kind: "todo", items: [], insertAt: i, headingIndex: -1 };
9835
+ sections.push(current);
9836
+ }
9837
+ // 待删除块里的条目按语义就是「已完成」,不靠行首 `[x]` 自证(手写的也算)。
9838
+ const inDone = current.kind === "done";
9839
+ const item = {
9840
+ line: i, done: isDone || inDone, inDone: inDone,
9841
+ text: body, title: todoItemTitle(body), detail: todoItemDetail(body), cont: "",
9842
+ };
9843
+ current.items.push(item);
9844
+ // 插入点 = 本条之后:节尾最后一条的下方,不会被后面的空行 / 下一节吃掉。
9845
+ current.insertAt = i + 1;
9846
+ if (item.done) done += 1; else open += 1;
9847
+ lastItem = item;
9848
+ continue;
9849
+ }
9850
+ // 续行(两个空格以上缩进、不是 `- `):并进上一条的正文,只用于显示。
9851
+ if (lastItem !== null && /^\s{2,}\S/.test(line)) {
9852
+ lastItem.cont += (lastItem.cont ? " " : "") + line.trim();
9853
+ } else if (line.trim() !== "") {
9854
+ lastItem = null;
9855
+ }
9856
+ }
9857
+ return { lines: lines, sections: sections, open: open, done: done };
9858
+ }
9859
+
9860
+ // ── 行级手术(纯函数:输入旧全文 → 输出新全文,不改入参)────────────
9861
+
9862
+ /**
9863
+ * 把一行拆成 `- ` 条目的三段。行不认识(不是 `- ` 开头)就回 null。
9864
+ * ⚠️ 先把行尾 `\r` 摘掉再匹配:JS 的 `.` 与 `$` 都不吃 `\r`,
9865
+ * 带着它匹配 `/^(\s*)-\s+(.*)$/` 一律不中 —— CRLF 文件会一条都认不出来。
9866
+ * @returns {{indent: string, body: string, done: boolean}|null} body 已剥掉 `[x]`
9867
+ */
9868
+ function todoBullet(line) {
9869
+ const raw = String(line == null ? "" : line).replace(/\r+$/, "");
9870
+ const m = /^(\s*)-\s+(.*)$/.exec(raw);
9871
+ if (!m) return null;
9872
+ let body = m[2];
9873
+ let done = false;
9874
+ const box = /^\[([ xX])\]\s*(.*)$/.exec(body);
9875
+ if (box) { done = box[1].toLowerCase() === "x"; body = box[2]; }
9876
+ return { indent: m[1], body: body.replace(/\s+$/, ""), done: done };
9877
+ }
9878
+
9879
+ /** 文件用的行尾:CRLF 文件里插的新行也带 `\r`,免得一份文件两种换行。 */
9880
+ function todoEol(text) {
9881
+ return String(text == null ? "" : text).indexOf("\r\n") >= 0 ? "\r" : "";
9882
+ }
9883
+
9884
+ /**
9885
+ * 找「已完成,待删除」块的行区间。
9886
+ * @returns {{start: number, end: number}|null} `[start, end)`:`start` 是标题行,`end` 是下一个 `##` 或文件尾
9887
+ */
9888
+ function todoDoneRange(lines) {
9889
+ const heading = /^##\s+(.*)$/;
9890
+ for (let i = 0; i < lines.length; i++) {
9891
+ // 先摘 `\r`:CRLF 文件里带 `\r` 的行用 `.` / `$` 匹配不到(见 todoBullet 那条注释)。
9892
+ const m = heading.exec(String(lines[i]).replace(/\r+$/, ""));
9893
+ if (!m || !TODO_DONE_PATTERN.test(m[1].trim())) continue;
9894
+ let end = lines.length;
9895
+ for (let j = i + 1; j < lines.length; j++) {
9896
+ if (heading.exec(String(lines[j]).replace(/\r+$/, ""))) { end = j; break; }
9897
+ }
9898
+ return { start: i, end: end };
9899
+ }
9900
+ return null;
9901
+ }
9902
+
9903
+ /**
9904
+ * 勾选 = **搬家**:从原组删掉第 line 行,在「已完成,待删除」块末尾追加 `- [x] <正文>`。
9905
+ *
9906
+ * - 文件里还没有那个块时,在**文件末尾**追加 `\n## 已完成,待删除\n` 再写条目,其余字节不动。
9907
+ * - 只搬**顶层**条目(缩进行是上一条的续行,跟着它自己留在原处,不在此处重构)。
9908
+ * - 正文只带原正文:不带原行首 `- `,也剥掉已有的 `[x]` 前缀。
9909
+ *
9910
+ * @returns {string|null} 新全文;不认识的行 / 空正文回 null(调用方据此不写盘)
9911
+ */
9912
+ function todoMoveToDone(text, line) {
9913
+ const src = String(text == null ? "" : text);
9914
+ const lines = src.split("\n");
9915
+ if (line < 0 || line >= lines.length) return null;
9916
+ const bullet = todoBullet(lines[line]);
9917
+ if (!bullet || bullet.indent !== "" || bullet.body === "") return null;
9918
+ const eol = todoEol(src);
9919
+ const next = lines.slice();
9920
+ next.splice(line, 1);
9921
+ const range = todoDoneRange(next);
9922
+ if (!range) {
9923
+ if (next.length > 0 && next[next.length - 1] === "") next.pop();
9924
+ const tail = next.length > 0 ? [""] : [];
9925
+ return next.concat(tail, [TODO_DONE_HEADING + eol, "- [x] " + bullet.body + eol, ""]).join("\n");
9926
+ }
9927
+ // 块末尾 = 块内**最后一条条目**的下一行;块里一条都没有就紧贴标题。
9928
+ let at = range.start + 1;
9929
+ for (let i = range.start + 1; i < range.end; i++) {
9930
+ if (todoBullet(next[i])) at = i + 1;
9931
+ }
9932
+ next.splice(at, 0, "- [x] " + bullet.body + eol);
9933
+ return next.join("\n");
9934
+ }
9935
+
9936
+ /**
9937
+ * 取消完成 = **反向搬家**:从待删除块删掉第 line 行,回到它原来所在组的末尾。
9938
+ *
9939
+ * 「原来在哪一组」只存在内存里(`rememberTodoOrigin`)—— 文件里不留标记,因为
9940
+ * 那会把看板的私有状态写进用户的数据。记不住时(换了个页面 / 手写的条目)退而求其次:
9941
+ * 第一个普通待办组的末尾,再不行就文件末尾。
9942
+ *
9943
+ * @param {string} originTitle 原组标题(空 = 不知道)
9944
+ */
9945
+ function todoRestore(text, line, originTitle) {
9946
+ const src = String(text == null ? "" : text);
9947
+ const lines = src.split("\n");
9948
+ if (line < 0 || line >= lines.length) return null;
9949
+ const bullet = todoBullet(lines[line]);
9950
+ if (!bullet || bullet.indent !== "" || bullet.body === "") return null;
9951
+ const eol = todoEol(src);
9952
+ const next = lines.slice();
9953
+ next.splice(line, 1);
9954
+ const parsed = parseTodoList(next.join("\n"));
9955
+ const want = String(originTitle == null ? "" : originTitle).trim();
9956
+ const byTitle = want === "" ? null : parsed.sections.find(function (sec) {
9957
+ return sec.kind !== "done" && sec.title === want;
9958
+ });
9959
+ const fallback = byTitle || parsed.sections.find(function (sec) {
9960
+ return sec.kind === "todo" && sec.items.length > 0;
9961
+ }) || parsed.sections.find(function (sec) { return sec.kind === "todo"; });
9962
+ if (!fallback) {
9963
+ if (next.length > 0 && next[next.length - 1] === "") next.pop();
9964
+ return next.concat(["- " + bullet.body + eol, ""]).join("\n");
9965
+ }
9966
+ next.splice(fallback.insertAt, 0, "- " + bullet.body + eol);
9967
+ return next.join("\n");
9968
+ }
9969
+
9970
+ /** 在第 at 行插入一条 `- <body>`。 */
9971
+ function todoInsert(text, at, body) {
9972
+ const lines = String(text).split("\n");
9973
+ const clean = String(body == null ? "" : body).replace(/\r?\n/g, " ").trim();
9974
+ if (clean === "") return null;
9975
+ const index = Math.max(0, Math.min(at, lines.length));
9976
+ lines.splice(index, 0, "- " + clean);
9977
+ return lines.join("\n");
9978
+ }
9979
+
9980
+ /** 替换第 line 行的正文(保留 `[x]` 标记与缩进)。 */
9981
+ function todoReplace(text, line, body) {
9982
+ const lines = String(text).split("\n");
9983
+ const raw = lines[line];
9984
+ if (raw === undefined) return null;
9985
+ const m = /^(\s*)-\s+(.*)$/.exec(raw);
9986
+ if (!m) return null;
9987
+ const clean = String(body == null ? "" : body).replace(/\r?\n/g, " ").trim();
9988
+ if (clean === "") return null;
9989
+ const box = /^\[([ xX])\]\s*/.exec(m[2]);
9990
+ lines[line] = m[1] + "- " + (box ? box[0] : "") + clean;
9991
+ return lines.join("\n");
9992
+ }
9993
+
9994
+ /** 删掉若干行(从大到小删,行号不互相错位)。 */
9995
+ function todoRemove(text, lineNumbers) {
9996
+ const lines = String(text).split("\n");
9997
+ const sorted = lineNumbers.slice().sort(function (a, b) { return b - a; });
9998
+ sorted.forEach(function (n) { if (n >= 0 && n < lines.length) lines.splice(n, 1); });
9999
+ return lines.join("\n");
10000
+ }
10001
+
10002
+ /**
10003
+ * 清空「已完成,待删除」块:删掉块内**全部条目行**,`## 标题` 留着(块还要继续接下一次勾选)。
10004
+ * @returns {{next: string|null, count: number}} count=0 → next 为 null(不白写一次盘)
10005
+ */
10006
+ function todoClearDoneBlock(text) {
10007
+ const src = String(text == null ? "" : text);
10008
+ const lines = src.split("\n");
10009
+ const range = todoDoneRange(lines);
10010
+ if (!range) return { next: null, count: 0 };
10011
+ const hits = [];
10012
+ for (let i = range.start + 1; i < range.end; i++) {
10013
+ if (todoBullet(lines[i])) hits.push(i);
10014
+ }
10015
+ if (hits.length === 0) return { next: null, count: 0 };
10016
+ return { next: todoRemove(src, hits), count: hits.length };
10017
+ }
10018
+
10019
+ /**
10020
+ * 「这条原来在哪一组」的内存账本 —— 取消完成要靠它把条目送回原组。
10021
+ * 只活在这个页面里(不落盘);键是正文归一化后的文本,最多留 200 条。
10022
+ */
10023
+ const todoOrigins = new Map();
10024
+
10025
+ function rememberTodoOrigin(text, title) {
10026
+ const key = String(text == null ? "" : text).trim();
10027
+ if (key === "") return;
10028
+ if (todoOrigins.size > 200) todoOrigins.clear();
10029
+ todoOrigins.set(key, String(title == null ? "" : title));
10030
+ }
10031
+
10032
+ function recallTodoOrigin(text) {
10033
+ return todoOrigins.get(String(text == null ? "" : text).trim()) || "";
10034
+ }
10035
+
10036
+ // ── 视图 ──────────────────────────────────────────────────────────
10037
+
10038
+ /**
10039
+ * 撤销 / 重做图标:**内联 SVG**(不引图标库、不外链、不靠字体)。
10040
+ * 撤销 = 一条水平基线 + 从右上绕回的弧形箭头,箭头尖在左端;重做是它的左右镜像
10041
+ * (x → 16-x,圆弧的 sweep 反过来)。
10042
+ * @param {"undo"|"redo"} dir
10043
+ */
10044
+ function todoArrowIcon(dir) {
10045
+ const paths = dir === "redo"
10046
+ ? ["M13.5 6.5h-7a4 4 0 0 0 0 8h3", "M10.5 3.5l3 3-3 3"]
10047
+ : ["M2.5 6.5h7a4 4 0 0 1 0 8h-3", "M5.5 3.5l-3 3 3 3"];
10048
+ return h("svg", {
10049
+ viewBox: "0 0 16 16", width: 14, height: 14, fill: "none",
10050
+ stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round", strokeLinejoin: "round",
10051
+ "aria-hidden": "true",
10052
+ }, paths.map(function (d, i) { return h("path", { key: "p" + i, d: d }); }));
10053
+ }
10054
+
10055
+ /** 一条待办的卡片:勾选 + 标题 + 折叠正文 + 行内编辑(待删除块里还有「删除」)。 */
10056
+ function TodoItemRow(props) {
10057
+ const item = props.item;
10058
+ const sOpen = react.useState(false);
10059
+ const expanded = sOpen[0], setExpanded = sOpen[1];
10060
+ const sDraft = react.useState(null);
10061
+ const draft = sDraft[0], setDraft = sDraft[1];
10062
+ const editing = draft !== null;
10063
+ const body = item.detail + (item.cont ? " " + item.cont : "");
10064
+ const long = body.length > TODO_DETAIL_CHARS;
10065
+ const shown = long && !expanded ? body.slice(0, TODO_DETAIL_CHARS) + "…" : body;
10066
+ return h("div", { className: "smem-todo-item" + (item.done ? " smem-todo-item-done" : "") }, [
10067
+ h("button", {
10068
+ key: "box",
10069
+ type: "button",
10070
+ className: "smem-todo-box" + (item.done ? " smem-todo-box-on" : ""),
10071
+ title: item.done ? t("todo.action.uncheck") : t("todo.action.check"),
10072
+ disabled: props.busy,
10073
+ onClick: function () { props.onToggle(item, !item.done); },
10074
+ }, item.done ? "✓" : ""),
10075
+ h("div", { key: "body", className: "smem-todo-body" }, [
10076
+ item.title ? h("div", { key: "title", className: "smem-todo-title" }, todoInline(item.title)) : null,
10077
+ editing
10078
+ ? h("textarea", {
10079
+ key: "edit",
10080
+ className: "smem-input smem-todo-edit",
10081
+ value: draft,
10082
+ rows: 3,
10083
+ onChange: function (e) { setDraft(e.target.value); },
10084
+ })
10085
+ : (shown ? h("div", { key: "text", className: "smem-todo-text" }, todoInline(shown)) : null),
10086
+ h("div", { key: "act", className: "smem-todo-actions" }, editing
10087
+ ? [
10088
+ h("button", { key: "s", type: "button", className: "smem-btn smem-btn-primary smem-todo-mini", disabled: props.busy, onClick: function () { props.onEdit(item, draft); setDraft(null); } }, t("todo.action.save")),
10089
+ h("button", { key: "c", type: "button", className: "smem-btn smem-todo-mini", onClick: function () { setDraft(null); } }, t("todo.action.cancel")),
10090
+ ]
10091
+ : [
10092
+ long ? h("button", { key: "m", type: "button", className: "smem-link smem-todo-mini", onClick: function () { setExpanded(!expanded); } }, expanded ? t("todo.less") : t("todo.more")) : null,
10093
+ h("button", { key: "e", type: "button", className: "smem-link smem-todo-mini", disabled: props.busy, onClick: function () { setDraft(item.text); } }, t("todo.action.edit")),
10094
+ // 「删除」只在待删除块里出现:别的位置删条目等于绕过「搬进流水」这一步。
10095
+ props.onDelete
10096
+ ? h("button", { key: "d", type: "button", className: "smem-link smem-todo-mini smem-todo-del", disabled: props.busy, onClick: function () { props.onDelete(item); } }, t("todo.action.delete"))
10097
+ : null,
10098
+ ]),
10099
+ ]),
10100
+ ]);
10101
+ }
10102
+
10103
+ /** 一组(一个 `##` 节):标题 + 计数 + 条目 + 新增框;待删除块另有「清空全部」。 */
10104
+ function TodoSectionGroup(props) {
10105
+ const sec = props.section;
10106
+ const isDone = sec.kind === "done";
10107
+ // 2.11.1(用户 2026-11-17 反馈):**所有组默认收起**,一屏先看见「有几组、各组几条」,
10108
+ // 想看的组自己点开。原来只收「长期约束」,长清单照样一屏铺满。
10109
+ const sCollapsed = react.useState(true);
10110
+ const collapsed = sCollapsed[0], setCollapsed = sCollapsed[1];
10111
+ // 上层「全部展开 / 全部收起」:allOpen 为 null 时不管(各组各管各的)。
10112
+ react.useEffect(function () {
10113
+ if (props.allOpen === null || props.allOpen === undefined) return;
10114
+ setCollapsed(!props.allOpen);
10115
+ }, [props.allOpen]);
10116
+ const sDraft = react.useState("");
10117
+ const draft = sDraft[0], setDraft = sDraft[1];
10118
+ const openCount = sec.items.filter(function (it) { return !it.done; }).length;
10119
+ const doneCount = sec.items.length - openCount;
10120
+ // 「清空全部」清的是**整个块**(不是当前筛出来的这几条),所以按钮上的数字要取块的真实条数。
10121
+ const blockCount = typeof props.doneCount === "number" ? props.doneCount : sec.items.length;
10122
+ return h("section", { className: "smem-todo-group" + (isDone ? " smem-todo-group-done" : "") }, [
10123
+ // 标题行是**行**不是按钮:右边还要放「清空全部」,按钮套按钮在浏览器里会互相吃掉。
10124
+ h("div", { key: "head", className: "smem-todo-group-head" }, [
10125
+ h("button", {
10126
+ key: "toggle",
10127
+ type: "button",
10128
+ className: "smem-todo-group-toggle",
10129
+ onClick: function () { setCollapsed(!collapsed); },
10130
+ }, [
10131
+ h("span", { key: "chev", className: "smem-todo-chev" }, collapsed ? "▸" : "▾"),
10132
+ h("span", { key: "t", className: "smem-todo-group-title" }, sec.title || (isDone ? t("todo.doneGroup") : t(TODO_SECTION_FALLBACK))),
10133
+ h("span", { key: "n", className: "smem-todo-count" }, String(openCount) + (doneCount > 0 ? " / " + String(doneCount) : "")),
10134
+ ]),
10135
+ isDone && blockCount > 0
10136
+ ? h("button", {
10137
+ key: "clear",
10138
+ type: "button",
10139
+ className: "smem-todo-mini smem-todo-del",
10140
+ title: t("todo.action.clearDone", { count: blockCount }),
10141
+ disabled: props.busy,
10142
+ onClick: function () { props.onClearDone(sec); },
10143
+ }, t("todo.action.clearDone", { count: blockCount }))
10144
+ : null,
10145
+ ]),
10146
+ collapsed ? null : h("div", { key: "list", className: "smem-todo-list" }, sec.items.length === 0
10147
+ ? [h("div", { key: "empty", className: "smem-todo-empty" }, isDone ? t("todo.empty.done") : t("todo.empty.section"))]
10148
+ : sec.items.map(function (it) {
10149
+ return h(TodoItemRow, {
10150
+ key: "i" + it.line, item: it, busy: props.busy,
10151
+ onToggle: props.onToggle, onEdit: props.onEdit,
10152
+ onDelete: isDone ? props.onDelete : null,
10153
+ });
10154
+ })),
10155
+ // 待删除块不给「加一条」:那一块只能由勾选搬进来,手写进去等于无来源的条目。
10156
+ collapsed || isDone ? null : h("div", { key: "add", className: "smem-todo-add" }, [
10157
+ h("input", {
10158
+ key: "in",
10159
+ className: "smem-input smem-todo-add-input",
10160
+ placeholder: t("todo.add.placeholder"),
10161
+ value: draft,
10162
+ disabled: props.busy,
10163
+ onChange: function (e) { setDraft(e.target.value); },
10164
+ onKeyDown: function (e) {
10165
+ if (e.key === "Enter") {
10166
+ const body = String(draft).trim();
10167
+ if (body === "") return;
10168
+ props.onAdd(sec, body);
10169
+ setDraft("");
10170
+ }
10171
+ },
10172
+ }),
10173
+ ]),
10174
+ ]);
10175
+ }
10176
+
10177
+ /** 页签正文。承载全部读写状态(宿主只给 ctx / sessionId / 标准 hooks)。 */
10178
+ function TodoBoard(props) {
10179
+ const ctx = props.ctx;
10180
+ const remote = stableRemote(ctx, "remote.memory");
10181
+ const enabled = useTodoBoardEnabled();
10182
+ const useTabInfo = typeof props.useTabInfo === "function" ? props.useTabInfo : todoBoardNoTabInfo;
10183
+ const tabInfo = useTabInfo();
10184
+ const visible = !(tabInfo && tabInfo.tab && tabInfo.tab.visible === false);
10185
+
10186
+ const sDoc = react.useState(null); const doc = sDoc[0], setDoc = sDoc[1];
10187
+ const sErr = react.useState(null); const err = sErr[0], setErr = sErr[1];
10188
+ const sNotice = react.useState(""); const notice = sNotice[0], setNotice = sNotice[1];
10189
+ const sBusy = react.useState(false); const busy = sBusy[0], setBusy = sBusy[1];
10190
+ // 撤销 / 重做:两步栈,元素是写入前的 `{content, revision}`。只在内存里,不落盘。
10191
+ // 任何**新**写入都清空 redoStack —— 从历史里分叉出去之后,原来那条「未来」就不成立了。
10192
+ const sUndo = react.useState([]); const undoStack = sUndo[0], setUndoStack = sUndo[1];
10193
+ const sRedo = react.useState([]); const redoStack = sRedo[0], setRedoStack = sRedo[1];
10194
+ // 「全部展开」是**一次性动作**而不是持久状态:默认 null(各组按自己的默认走 = 收起)。
10195
+ const sAll = react.useState(null); const allOpen = sAll[0], setAllOpen = sAll[1];
10196
+ // 搜索:只过滤**显示**,绝不改文件;有查询时匹配的组强制展开,没匹配的组整组隐掉。
10197
+ const sQuery = react.useState(""); const rawQuery = sQuery[0], setQuery = sQuery[1];
10198
+ const query = String(rawQuery).trim().toLowerCase();
10199
+
10200
+ /** 读一次文件。`quiet` = 轮询调用(出错不弹条,避免每 4 秒闪一次)。 */
10201
+ const load = react.useCallback(function (quiet) {
10202
+ if (!remote || typeof remote.readFile !== "function") {
10203
+ if (!quiet) setErr(t("todo.err.noRemote"));
10204
+ return;
10205
+ }
10206
+ return Promise.resolve(remote.readFile(TODO_FILE)).then(function (res) {
10207
+ const data = unwrap(res);
10208
+ if (data && data.ok === false) {
10209
+ setDoc({ missing: true, content: "", revision: null, parsed: parseTodoList("") });
10210
+ if (!quiet) setErr(data.error || t("todo.err.read", { error: String(data.code || "error") }));
10211
+ return;
10212
+ }
10213
+ const content = (data && data.content) || "";
10214
+ const revision = data && typeof data.revision === "string" ? data.revision : null;
10215
+ // quiet 轮询里 revision 没变就什么都不做 —— 否则每 4 秒整棵树重渲染一次。
10216
+ setDoc(function (prev) {
10217
+ if (quiet && prev && !prev.missing && prev.revision === revision) return prev;
10218
+ return { missing: false, content: content, revision: revision, parsed: parseTodoList(content) };
10219
+ });
10220
+ }, function (e) {
10221
+ if (!quiet) setErr(String((e && e.message) || e));
10222
+ });
10223
+ }, [remote]);
10224
+
10225
+ react.useEffect(function () { load(false); }, [load]);
10226
+
10227
+ // 轮询:只在页签可见时跑;切走(不可见)就停,别在后台白读盘。
10228
+ react.useEffect(function () {
10229
+ if (!visible || !enabled) return undefined;
10230
+ const id = setInterval(function () {
10231
+ if (typeof document !== "undefined" && document.hidden) return;
10232
+ load(true);
10233
+ }, TODO_POLL_MS);
10234
+ return function () { clearInterval(id); };
10235
+ }, [visible, enabled, load]);
10236
+
10237
+ /**
10238
+ * 一次写入:带上读到的 revision(盘上变了宿主回 stale_revision,我们只重读、不覆盖)。
10239
+ * @param {string} label 回执文案(已翻译)
10240
+ * @param {string} next 新全文
10241
+ */
10242
+ function mutate(label, next) {
10243
+ if (!next || next === doc.content) return;
10244
+ // 写入前的快照先抓住:新写入一律清空 redoStack(历史分叉了)。
10245
+ const snapshot = { content: doc.content, revision: doc.revision };
10246
+ setBusy(true); setErr(null); setNotice("");
10247
+ const revision = doc.revision;
10248
+ const opts = revision ? { expectedRevision: revision } : undefined;
10249
+ writeWithFallback(remote, "writeFile", [TODO_FILE, next], opts, null)
10250
+ .then(function (out) {
10251
+ const r = out.result;
10252
+ if (r && r.ok === false) {
10253
+ if (r.code === "stale_revision") {
10254
+ setNotice(t("todo.notice.stale"));
10255
+ return load(false);
10256
+ }
10257
+ setErr(r.error || t("todo.err.write", { error: String(r.code || "error") }));
10258
+ return;
10259
+ }
10260
+ setUndoStack(function (prev) { return prev.concat([snapshot]).slice(-TODO_UNDO_DEPTH); });
10261
+ setRedoStack([]);
10262
+ setNotice(out.degraded ? t("todo.notice.degraded") : label);
10263
+ return load(false);
10264
+ }, function (e) { setErr(String((e && e.message) || e)); })
10265
+ .then(function () { setBusy(false); });
10266
+ }
10267
+
10268
+ /**
10269
+ * 写回一份历史快照(撤销 / 重做共用)。**只有写成功才动栈** ——
10270
+ * 失败时界面不该显示「已经挪过一步」。
10271
+ * @param {{content: string, revision: string|null}} target 要写回的快照
10272
+ * @param {string} label 回执文案
10273
+ * @param {function} onDone 成功后的栈操作
10274
+ */
10275
+ function writeSnapshot(target, label, onDone) {
10276
+ if (!target || typeof target.content !== "string") return;
10277
+ const revision = doc.revision;
10278
+ setBusy(true); setErr(null); setNotice("");
10279
+ writeWithFallback(remote, "writeFile", [TODO_FILE, target.content], revision ? { expectedRevision: revision } : undefined, null)
10280
+ .then(function (out) {
10281
+ const r = out && (out.result || out);
10282
+ if (r && r.ok === false) {
10283
+ if (r.code === "stale_revision") { setNotice(t("todo.notice.stale")); return load(false); }
10284
+ setErr(r.error || t("todo.err.write", { error: String(r.code || "error") }));
10285
+ return;
10286
+ }
10287
+ if (typeof onDone === "function") onDone();
10288
+ setNotice(label);
10289
+ return load(false);
10290
+ }, function (e) { setErr(String((e && e.message) || e)); })
10291
+ .then(function () { setBusy(false); });
10292
+ }
10293
+
10294
+ /** 当前盘上内容的快照(撤销 / 重做要把它推到另一侧的栈里)。 */
10295
+ function currentPoint() {
10296
+ return { content: doc.content, revision: doc.revision };
10297
+ }
10298
+
10299
+ /**
10300
+ * 勾选 / 取消完成:**搬家**与**反向搬家**。
10301
+ * 勾选 → 从原组删行、追加到「已完成,待删除」块;取消 → 删掉、送回原组末尾。
10302
+ */
10303
+ function onToggle(item, done, originTitle) {
10304
+ if (done) {
10305
+ const next = todoMoveToDone(doc.content, item.line);
10306
+ if (!next) return;
10307
+ // 记住它原来在哪一组,取消完成时靠这条回到原位(只在内存里)。
10308
+ rememberTodoOrigin(item.text, originTitle);
10309
+ mutate(t("todo.notice.movedToDone", { group: t("todo.doneGroup") }), next);
10310
+ return;
10311
+ }
10312
+ mutate(t("todo.notice.restored"), todoRestore(doc.content, item.line, recallTodoOrigin(item.text)));
10313
+ }
10314
+
10315
+ function onAdd(section, body) {
10316
+ mutate(t("todo.notice.added"), todoInsert(doc.content, section.insertAt, body));
10317
+ }
10318
+
10319
+ function onEdit(item, body) {
10320
+ mutate(t("todo.notice.edited"), todoReplace(doc.content, item.line, body));
10321
+ }
10322
+
10323
+ /** 删掉待删除块里的一条(只删那一行)。 */
10324
+ function onDelete(item) {
10325
+ mutate(t("todo.notice.deleted"), todoRemove(doc.content, [item.line]));
10326
+ }
10327
+
10328
+ /** 清空待删除块的**全部条目行**,`## 标题` 留着。 */
10329
+ function onClearDone() {
10330
+ const out = todoClearDoneBlock(doc.content);
10331
+ if (out.count === 0) return;
10332
+ mutate(t("todo.notice.cleared", { count: out.count }), out.next);
10333
+ }
10334
+
10335
+ function onUndo() {
10336
+ if (undoStack.length === 0) return;
10337
+ const target = undoStack[undoStack.length - 1];
10338
+ const point = currentPoint();
10339
+ writeSnapshot(target, t("todo.notice.undo"), function () {
10340
+ setUndoStack(function (prev) { return prev.slice(0, -1); });
10341
+ setRedoStack(function (prev) { return prev.concat([point]).slice(-TODO_UNDO_DEPTH); });
10342
+ });
10343
+ }
10344
+
10345
+ function onRedo() {
10346
+ if (redoStack.length === 0) return;
10347
+ const target = redoStack[redoStack.length - 1];
10348
+ const point = currentPoint();
10349
+ writeSnapshot(target, t("todo.notice.redone"), function () {
10350
+ setRedoStack(function (prev) { return prev.slice(0, -1); });
10351
+ setUndoStack(function (prev) { return prev.concat([point]).slice(-TODO_UNDO_DEPTH); });
10352
+ });
10353
+ }
10354
+
10355
+ if (!enabled) {
10356
+ return h("div", { className: "smem-todo-done-state" }, [
10357
+ h("div", { key: "t", className: "smem-todo-done-title" }, t("todo.disabled.title")),
10358
+ h("div", { key: "h", className: "smem-muted" }, t("todo.disabled.hint")),
10359
+ ]);
10360
+ }
10361
+
10362
+ const parsed = doc && doc.parsed ? doc.parsed : parseTodoList("");
10363
+ const missing = doc && doc.missing;
10364
+ // 匹配口径:标题 + 正文 + 续行里任一处包含子串(大小写不敏感;不解释正则,免得用户被自己的输入坑)。
10365
+ const sections = query === "" ? parsed.sections : parsed.sections
10366
+ .map(function (sec) {
10367
+ const hit = sec.items.filter(function (it) {
10368
+ const hay = ((it.title || "") + " " + it.text + " " + (it.cont || "")).toLowerCase();
10369
+ return hay.indexOf(query) >= 0;
10370
+ });
10371
+ return { sec: sec, hit: hit };
10372
+ })
10373
+ .filter(function (row) { return row.hit.length > 0; })
10374
+ .map(function (row) { return Object.assign({}, row.sec, { items: row.hit }); });
10375
+ const matchCount = sections.reduce(function (n, sec) { return n + sec.items.length; }, 0);
10376
+ const stats = t("todo.stat", { open: parsed.open, done: parsed.done, sections: parsed.sections.length });
10377
+ // 「清空全部」清的是整个待删除块,数字取块的真实条数(搜索过滤后也一样)。
10378
+ const doneBlock = parsed.sections.find(function (sec) { return sec.kind === "done"; });
10379
+ const doneBlockCount = doneBlock ? doneBlock.items.length : 0;
10380
+
10381
+ return h("div", { className: "smem-todo" }, [
10382
+ h("div", { key: "head", className: "smem-todo-head" }, [
10383
+ h("span", { key: "s", className: "smem-todo-stat" }, query === "" ? stats : t("todo.search.count", { count: matchCount })),
10384
+ h("span", { key: "sp", "data-spring": "" }),
10385
+ h("button", {
10386
+ key: "u", type: "button", className: "smem-todo-icon-btn",
10387
+ title: t("todo.action.undo"), "aria-label": t("todo.action.undo"),
10388
+ disabled: busy || undoStack.length === 0,
10389
+ onClick: onUndo,
10390
+ }, todoArrowIcon("undo")),
10391
+ h("button", {
10392
+ key: "d", type: "button", className: "smem-todo-icon-btn",
10393
+ title: t("todo.action.redo"), "aria-label": t("todo.action.redo"),
10394
+ disabled: busy || redoStack.length === 0,
10395
+ onClick: onRedo,
10396
+ }, todoArrowIcon("redo")),
10397
+ h("button", { key: "a", type: "button", className: "smem-link smem-todo-mini", onClick: function () { setAllOpen(allOpen === true ? false : true); } }, allOpen === true ? t("todo.collapseAll") : t("todo.expandAll")),
10398
+ h("button", { key: "r", type: "button", className: "smem-link smem-todo-mini", disabled: busy, onClick: function () { load(false); } }, t("todo.refresh")),
10399
+ ]),
10400
+ // 搜索框放统计条下面一行:右栏很窄,塞进同一行会把按钮挤没。
10401
+ h("div", { key: "search", className: "smem-todo-search-row" }, [
10402
+ h("input", {
10403
+ key: "q",
10404
+ className: "smem-input smem-todo-search",
10405
+ type: "search",
10406
+ placeholder: t("todo.search.placeholder"),
10407
+ value: rawQuery,
10408
+ onChange: function (e) { setQuery(e.target.value); },
10409
+ }),
10410
+ rawQuery === "" ? null : h("button", { key: "x", type: "button", className: "smem-link smem-todo-mini", onClick: function () { setQuery(""); } }, t("todo.action.cancel")),
10411
+ ]),
10412
+ err ? h("div", { key: "err", className: "smem-err" }, "⚠ " + err) : null,
10413
+ notice ? h("div", { key: "ok", className: "smem-ok" }, "✓ " + notice) : null,
10414
+ missing
10415
+ ? h("div", { key: "miss", className: "smem-todo-empty" }, t("todo.empty.file", { file: TODO_FILE }))
10416
+ : (query !== "" && sections.length === 0
10417
+ ? h("div", { key: "nomatch", className: "smem-todo-empty" }, t("todo.search.none"))
10418
+ : h("div", { key: "groups", className: "smem-todo-groups" }, sections.map(function (sec, i) {
10419
+ return h(TodoSectionGroup, {
10420
+ key: "s" + i, section: sec, busy: busy, allOpen: query === "" ? allOpen : true,
10421
+ doneCount: doneBlockCount,
10422
+ onToggle: function (it, d) { onToggle(it, d, sec.title); },
10423
+ onAdd: onAdd, onEdit: onEdit, onDelete: onDelete, onClearDone: onClearDone,
10424
+ });
10425
+ }))),
10426
+ ]);
10427
+ }
10428
+
10429
+ // ── 注册与热开关 ──────────────────────────────────────────────────
10430
+
10431
+ /** guide 条目(开始页那张卡片)。关掉开关时整条不给 —— 卡片随之消失。 */
10432
+ function todoBoardGuideEntry() {
10433
+ return {
10434
+ id: TODO_GUIDE_ID,
10435
+ order: 30,
10436
+ title: function () { return t("todo.guide.title"); },
10437
+ description: function () { return t("todo.guide.desc"); },
10438
+ };
10439
+ }
10440
+
10441
+ /**
10442
+ * 注册 / 重注册 tab 定义。**body 与 title 槽不在这里**(它们常驻,见 applyTodoBoard)。
10443
+ * @param {boolean} withGuide 是否带开始页卡片
10444
+ */
10445
+ function registerTodoBoardDefinition(withGuide) {
10446
+ const ctx = todoBoardCtx;
10447
+ const tabs = ctx && typeof ctx.get === "function" ? ctx.get("sidebarRightTabs") : null;
10448
+ if (!tabs || typeof tabs.register !== "function") return false;
10449
+ if (todoBoardRegistryDispose !== null) {
10450
+ try { todoBoardRegistryDispose(); } catch (e) { /* 已经注销过就忽略 */ }
10451
+ todoBoardRegistryDispose = null;
10452
+ }
10453
+ try {
10454
+ todoBoardRegistryDispose = tabs.register({
10455
+ id: TODO_TAB_ID,
10456
+ kind: TODO_TAB_KIND,
10457
+ priority: "extension",
10458
+ title: function () { return t("todo.tabTitle"); },
10459
+ guide: withGuide ? [todoBoardGuideEntry()] : undefined,
10460
+ });
10461
+ return true;
10462
+ } catch (e) {
10463
+ todoBoardRegistryDispose = null;
10464
+ return false;
10465
+ }
10466
+ }
10467
+
10468
+ /** 打开一次页签(失败静默:宿主可能不支持程序化打开,用户点卡片也一样)。 */
10469
+ function openTodoBoardTab() {
10470
+ try {
10471
+ const nav = todoBoardCtx && typeof todoBoardCtx.get === "function" ? todoBoardCtx.get("sidebarRight") : null;
10472
+ if (nav && typeof nav.openTab === "function") nav.openTab(TODO_TAB_KIND);
10473
+ } catch (e) { /* 打不开不是错,卡片还在 */ }
10474
+ }
10475
+
10476
+ /**
10477
+ * 热开关的唯一入口:设置卡拨开关、apply 启动时都走这里。
10478
+ *
10479
+ * - 开:body / title 槽先注册好,再注册 definition(带 guide),最后试着开一次页签;
10480
+ * - 关:**只**重注册 definition(不带 guide)—— body 常驻,已开的页签切到「已关闭」态,
10481
+ * 不会变成孤儿页签,也不需要刷新页面。
10482
+ * @param {boolean} on
10483
+ */
10484
+ function applyTodoBoard(on) {
10485
+ const next = !!on;
10486
+ todoBoardEnabled = next;
10487
+ const ctx = todoBoardCtx;
10488
+ if (ctx === null) { todoBoardNotify(); return; }
10489
+ if (next) {
10490
+ if (todoBoardBodyDispose === null) {
10491
+ try {
10492
+ todoBoardBodyDispose = ctx.slots.inject("sidebar.right.pane.tab", function () {
10493
+ return ctx.slots.register({ name: "sidebar.right.pane.tab", key: TODO_TAB_ID }, function (props) {
10494
+ // 把 ctx 传进正文:正文只用标准 hooks + 我们自己的 remote,不额外依赖宿主内部。
10495
+ return react.createElement(TodoBoard, Object.assign({}, props, { ctx: ctx }));
10496
+ });
10497
+ });
10498
+ todoBoardTitleDispose = ctx.slots.inject("sidebar.right.pane.tab.title", function () {
10499
+ return ctx.slots.register({ name: "sidebar.right.pane.tab.title", key: TODO_TAB_ID }, function () {
10500
+ return h("span", null, t("todo.tabTitle"));
10501
+ });
10502
+ });
10503
+ } catch (e) {
10504
+ todoBoardBodyDispose = null;
10505
+ todoBoardTitleDispose = null;
10506
+ }
10507
+ }
10508
+ if (!todoBoardGuideShown) {
10509
+ if (registerTodoBoardDefinition(true)) {
10510
+ todoBoardGuideShown = true;
10511
+ openTodoBoardTab();
10512
+ }
10513
+ }
10514
+ } else if (todoBoardBodyDispose !== null && todoBoardGuideShown) {
10515
+ // body 常驻、只摘掉 guide:已打开的页签留下,正文切到「已关闭」态。
10516
+ if (registerTodoBoardDefinition(false)) todoBoardGuideShown = false;
10517
+ }
10518
+ todoBoardNotify();
10519
+ }
10520
+
10521
+ /** 宿主有没有右侧栏能力(设置卡据此置灰 / 解释)。 */
10522
+ function todoBoardHostSupported(ctx) {
10523
+ try {
10524
+ const tabs = ctx && typeof ctx.get === "function" ? ctx.get("sidebarRightTabs") : null;
10525
+ return !!(tabs && typeof tabs.register === "function");
10526
+ } catch (e) { return false; }
10527
+ }
10528
+
10529
+ /** 实验性页里的那张卡:开关 + 三句话(这是什么 / 立刻生效 / 宿主不支持时置灰)。 */ function TodoBoardLabCard(props) {
10530
+ const ctx = props.ctx;
10531
+ const remote = stableRemote(ctx, "remote.memory");
10532
+ const supported = todoBoardHostSupported(ctx);
10533
+ const sOn = react.useState(todoBoardEnabled);
10534
+ const on = sOn[0], setOn = sOn[1];
10535
+ const sBusy = react.useState(false); const busy = sBusy[0], setBusy = sBusy[1];
10536
+ const sErr = react.useState(null); const err = sErr[0], setErr = sErr[1];
10537
+ const sNotice = react.useState(""); const notice = sNotice[0], setNotice = sNotice[1];
10538
+
10539
+ // 初次挂载:以宿主设置里的值为准(模块加载时那份 + 待生效那份对 live 开关是一致的)。
10540
+ react.useEffect(function () {
10541
+ const m = stableRemote(ctx, "remote.memory");
10542
+ if (!m || typeof m.getSettings !== "function") return;
10543
+ Promise.resolve(m.getSettings()).then(function (res) {
10544
+ const d = unwrap(res) || {};
10545
+ const value = d.pendingExperimental && typeof d.pendingExperimental.todoBoard === "number"
10546
+ ? d.pendingExperimental.todoBoard
10547
+ : (d.experimental && d.experimental.todoBoard) || 0;
10548
+ setOn(value > 0);
10549
+ applyTodoBoard(value > 0);
10550
+ }, function () { /* 读不到就按当前内存态显示 */ });
10551
+ }, [ctx]);
10552
+
10553
+ function toggle() {
10554
+ const next = on ? 0 : 1;
10555
+ setBusy(true); setErr(null); setNotice("");
10556
+ Promise.resolve(remote.setSettings({ experimental: { todoBoard: next } })).then(function (out) {
10557
+ setBusy(false);
10558
+ // setSettings 自带 {ok, settings, restartRequired}:直接读,不要 unwrap。
10559
+ if (out && out.ok === false) { setErr(out.error || t("todo.lab.rejected")); return; }
10560
+ setOn(next > 0);
10561
+ applyTodoBoard(next > 0);
10562
+ setNotice(t(next > 0 ? "todo.lab.onNotice" : "todo.lab.offNotice"));
10563
+ }, function (e) { setBusy(false); setErr(String((e && e.message) || e)); });
10564
+ }
10565
+
10566
+ return h("div", { className: "smem-todo-lab smem-module-card" }, [
10567
+ h("div", { className: "smem-modcard-head", key: "head" }, [
10568
+ h(Switch, {
10569
+ key: "sw",
10570
+ on: on,
10571
+ label: t("todo.lab.switch"),
10572
+ title: supported ? t("todo.lab.switch.title") : t("todo.lab.unsupported"),
10573
+ disabled: busy || !supported,
10574
+ onClick: toggle,
10575
+ }),
10576
+ h("span", { className: "smem-modcard-title", key: "t" }, t("todo.lab.title")),
10577
+ h("span", { className: "smem-modcard-status", key: "s" }, on ? t("todo.lab.status.on") : t("todo.lab.status.off")),
10578
+ ]),
10579
+ h("div", { className: "smem-autodream-sec", key: "what" }, [
10580
+ h("div", { className: "smem-autodream-note", key: "p1" }, t("todo.lab.what")),
10581
+ h("div", { className: "smem-autodream-note", key: "p2" }, t("todo.lab.live")),
10582
+ supported ? null : h("div", { className: "smem-autodream-note", key: "p3" }, t("todo.lab.unsupported")),
10583
+ ]),
10584
+ err ? h("div", { className: "smem-err", key: "err" }, "⚠ " + err) : null,
10585
+ notice ? h("div", { className: "smem-ok", key: "ok" }, "✓ " + notice) : null,
10586
+ ]);
10587
+ }
10588
+
10589
+ // 测试缝:解析与行级手术是纯函数,而在 factory 闭包里外面拿不到 ——
10590
+ // 只给 `test/todo-board-test.mjs` 用,运行期没有任何代码读它(宿主只认 apply / inject)。
10591
+ exports.todoBoardInternals = {
10592
+ FILE: TODO_FILE,
10593
+ TAB_KIND: TODO_TAB_KIND,
10594
+ DONE_HEADING: TODO_DONE_HEADING,
10595
+ UNDO_DEPTH: TODO_UNDO_DEPTH,
10596
+ parse: parseTodoList,
10597
+ titleOf: todoItemTitle,
10598
+ bullet: todoBullet,
10599
+ doneRange: todoDoneRange,
10600
+ moveToDone: todoMoveToDone,
10601
+ restore: todoRestore,
10602
+ insert: todoInsert,
10603
+ replace: todoReplace,
10604
+ remove: todoRemove,
10605
+ clearDoneBlock: todoClearDoneBlock,
10606
+ rememberOrigin: rememberTodoOrigin,
10607
+ recallOrigin: recallTodoOrigin,
10608
+ arrowIcon: todoArrowIcon,
10609
+ isEnabled: function () { return todoBoardEnabled; },
10610
+ notify: todoBoardNotify,
10611
+ };
9235
10612
  // ⚠️ 不把 `layout` 写进 inject:它是**可选**依赖(官方 inspect:optional access =
9236
10613
  // `ctx.get("layout")` + 判空;hardDependency 才是 inject)。写进 inject 会让旧外壳
9237
10614
  // 缺这个服务时整个 client 插件不 apply —— 连带丢掉设置页。返回会话优先用宿主给的
@@ -9273,6 +10650,24 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
9273
10650
  }
9274
10651
  applyEntryMode(initialMode);
9275
10652
 
10653
+ // ── 2.11.0 实验性「待办清单」看板 ────────────────────────────────
10654
+ // 开关住在设置页「实验性」,但**消费方是 client**(右侧栏注册)→ 启动读一次,
10655
+ // 之后由设置卡调 applyTodoBoard 热切换,不参与 restartRequired
10656
+ // (宿主 `EXPERIMENTAL_SPECS.todoBoard` 标了 `live: true`)。
10657
+ todoBoardCtx = ctx;
10658
+ try {
10659
+ const memBoard = typeof ctx.get === "function" ? ctx.get("remote.memory") : null;
10660
+ let boardOn = false;
10661
+ if (memBoard && typeof memBoard.getSettings === "function") {
10662
+ const loadedBoard = unwrap(await memBoard.getSettings()) || {};
10663
+ const lab = loadedBoard.pendingExperimental || loadedBoard.experimental || {};
10664
+ boardOn = typeof lab.todoBoard === "number" && lab.todoBoard > 0;
10665
+ }
10666
+ applyTodoBoard(boardOn);
10667
+ } catch (e) {
10668
+ applyTodoBoard(false);
10669
+ }
10670
+
9276
10671
  // ── 1.8.2 / 2.7.0 插件详情页的「界面入口」折叠行 ────────────────────
9277
10672
  // `plugins.bundle.config` 是 keyed 槽,key = 本 bundle 的 **package name**(sage-mem)。
9278
10673
  // 宿主在插件页的 description 与「包含的组件」行之间渲染它;ownerProps 形如