sage-mem 2.12.1 → 2.15.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 +9 -6
- package/README.md +10 -7
- package/lib/autodream/audit.js +170 -16
- package/lib/client.js +614 -66
- package/lib/index.js +13 -1
- package/lib/memory/checkpoint.js +3 -2
- package/lib/memory/frontmatter.js +59 -12
- package/lib/memory/scan.js +56 -0
- package/lib/memory/trim-plan.js +34 -14
- package/lib/shared/hash.js +117 -0
- package/lib/typert.host.js +37 -0
- package/package.json +1 -1
- package/skills/sage-mem/SKILL.md +1 -0
package/lib/client.js
CHANGED
|
@@ -65,6 +65,27 @@ window.__ModuleLoader__.load({
|
|
|
65
65
|
return "rgba(" + ((n >> 16) & 255) + "," + ((n >> 8) & 255) + "," + (n & 255) + "," + a.toFixed(3) + ")";
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* 错误详情尽量展开,避免 "[object Object]" 式黑洞。
|
|
70
|
+
*
|
|
71
|
+
* 2.14.0 从 `10-starmap-head.js` 搬到这里:它原本声明在 `StarmapRuntime` 那个
|
|
72
|
+
* IIFE **里面**,而 `60-autodream-panel.js` 的错误分支也在调它 —— 拼接顺序是
|
|
73
|
+
* 先 IIFE 后工厂主体,闭包方向是反的,于是 remote 一失败就抛
|
|
74
|
+
* `ReferenceError: detail is not defined`。危险之处在于**只有失败分支才炸**:
|
|
75
|
+
* 正常路径全绿、界面也不白屏,只是「错误提示变成另一条错误」。
|
|
76
|
+
* `client-scope-test` 第 7 组现在按作用域盯着这一类(不只看这一个名字)。
|
|
77
|
+
*/
|
|
78
|
+
function detail(e) {
|
|
79
|
+
if (!e) return "未知错误";
|
|
80
|
+
if (e instanceof Error) return (e.message || String(e)) + (e.stack ? " · " + e.stack.slice(0, 180) : "");
|
|
81
|
+
try {
|
|
82
|
+
const s = JSON.stringify(e);
|
|
83
|
+
return s && s !== "{}" ? s.slice(0, 200) : String(e);
|
|
84
|
+
} catch (_) {
|
|
85
|
+
return String(e);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
68
89
|
// ── 陈旧宿主(2.1.22 / issue #10)────────────────────────────────
|
|
69
90
|
//
|
|
70
91
|
// `@deepseek-ai/dsh-typert-loader` 把每个包的 TYPERT manifest **按包名缓存、
|
|
@@ -239,17 +260,8 @@ const StarmapRuntime = (function (require, _react) {
|
|
|
239
260
|
let react = _react;
|
|
240
261
|
const h = react.createElement;
|
|
241
262
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
if (!e) return "未知错误";
|
|
245
|
-
if (e instanceof Error) return (e.message || String(e)) + (e.stack ? " · " + e.stack.slice(0, 180) : "");
|
|
246
|
-
try {
|
|
247
|
-
const s = JSON.stringify(e);
|
|
248
|
-
return s && s !== "{}" ? s.slice(0, 200) : String(e);
|
|
249
|
-
} catch (_) {
|
|
250
|
-
return String(e);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
263
|
+
// detail() 2.14.0 已搬到 05-shared.js(工厂作用域):本 IIFE 与 IIFE 外的
|
|
264
|
+
// 60-autodream-panel.js 都要用它,放在 IIFE 里就只对内可见。
|
|
253
265
|
|
|
254
266
|
function preview(v) {
|
|
255
267
|
try {
|
|
@@ -2093,6 +2105,16 @@ const StarmapRuntime = (function (require, _react) {
|
|
|
2093
2105
|
result: { mode: "strict", typeSymbol: "sage-mem/types#AuditReport", schema: objCodec, create: () => objCodec },
|
|
2094
2106
|
sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
|
|
2095
2107
|
},
|
|
2108
|
+
{
|
|
2109
|
+
id: "sage-mem#memory/checkpoints",
|
|
2110
|
+
service: "memory",
|
|
2111
|
+
namespace: "memory",
|
|
2112
|
+
method: "checkpoints",
|
|
2113
|
+
invocation: { kind: "direct" },
|
|
2114
|
+
parameters: [],
|
|
2115
|
+
result: { mode: "strict", typeSymbol: "sage-mem/types#Checkpoints", schema: objCodec, create: () => objCodec },
|
|
2116
|
+
sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
|
|
2117
|
+
},
|
|
2096
2118
|
{
|
|
2097
2119
|
id: "sage-mem#memory/openMemoryDir",
|
|
2098
2120
|
service: "memory",
|
|
@@ -2850,6 +2872,22 @@ const StarmapRuntime = (function (require, _react) {
|
|
|
2850
2872
|
".smem-todo-add{padding-top:2px;}",
|
|
2851
2873
|
".smem-todo-add-input{width:100%;font-size:12px;}",
|
|
2852
2874
|
".smem-todo-empty{font-size:11.5px;color:var(--dsw-alias-label-secondary);padding:4px 0;}",
|
|
2875
|
+
// 2.15.0:筛选 + 撤销步数那一行;步数选择器要窄,别把右栏撑开。
|
|
2876
|
+
".smem-todo-tools{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:0 0 2px;}",
|
|
2877
|
+
".smem-todo-tools > span[data-spring]{flex:1;}",
|
|
2878
|
+
".smem-todo-filter{border:1px solid transparent;border-radius:6px;padding:1px 6px;}",
|
|
2879
|
+
".smem-todo-filter-on{border-color:var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-l2);color:var(--dsw-alias-label-primary);}",
|
|
2880
|
+
".smem-todo-depth{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;color:var(--dsw-alias-label-secondary);}",
|
|
2881
|
+
".smem-todo-depth-select{width:auto;padding:0 2px;font-size:11.5px;}",
|
|
2882
|
+
// 「搬进流水」是待删除块的主动作(清空是丢弃、这条是留档),给品牌色。
|
|
2883
|
+
".smem-todo-archive{font-weight:600;}",
|
|
2884
|
+
// 检查点聚合块:只读、来源是别的文件 —— 用虚线边框和正文色区分开。
|
|
2885
|
+
".smem-todo-group-cp{border-style:dashed;}",
|
|
2886
|
+
".smem-todo-cp-task{display:flex;flex-direction:column;gap:2px;padding:2px 0;}",
|
|
2887
|
+
".smem-todo-cp-head{font-size:11.5px;font-weight:600;color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;}",
|
|
2888
|
+
".smem-todo-cp-items{display:flex;flex-direction:column;gap:2px;}",
|
|
2889
|
+
".smem-todo-cp-item{font-size:12px;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere;padding-left:8px;border-left:2px solid var(--dsw-alias-border-l2);}",
|
|
2890
|
+
".smem-todo-cp-note{font-size:11px;color:var(--dsw-alias-label-secondary);}",
|
|
2853
2891
|
".smem-todo-done-state{display:flex;flex-direction:column;gap:6px;padding:16px 12px;}",
|
|
2854
2892
|
".smem-todo-done-title{font-weight:600;}",
|
|
2855
2893
|
].join("\n");
|
|
@@ -3644,7 +3682,15 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
3644
3682
|
rows(list, render),
|
|
3645
3683
|
])
|
|
3646
3684
|
: null);
|
|
3647
|
-
const hints =
|
|
3685
|
+
const hints = AUDIT_HINTS.map(function (g) {
|
|
3686
|
+
const list = (Array.isArray(r[g.field]) ? r[g.field] : []).filter(function (x) { return x && typeof x === "object"; });
|
|
3687
|
+
if (!list.length) return null;
|
|
3688
|
+
return h("div", { className: "smem-audit-hint", key: "hint-" + g.field }, [
|
|
3689
|
+
h("div", { className: "smem-audit-h", key: "h" }, g.title + " · " + list.length + " 条"),
|
|
3690
|
+
g.note ? h("div", { className: "smem-ar-hint", key: "n" }, g.note) : null,
|
|
3691
|
+
rows(list, g.item),
|
|
3692
|
+
]);
|
|
3693
|
+
}).filter(Boolean);
|
|
3648
3694
|
// 分节表(字段 / 标题 / 条目格式)与「复制修复提示词」共用同一份,定义在
|
|
3649
3695
|
// `client/56-health-prompt.js` 的 `AUDIT_SECTIONS` —— 面板上看到的每一行,
|
|
3650
3696
|
// 就是提示词里读到的那一行。这里只负责把它渲染成「标题(说明)」。
|
|
@@ -3662,18 +3708,21 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
3662
3708
|
standalone ? null : toolClose(props),
|
|
3663
3709
|
]),
|
|
3664
3710
|
r.problems
|
|
3665
|
-
? h("div", { key: "secs" },
|
|
3666
|
-
|
|
3667
|
-
|
|
3711
|
+
? h("div", { key: "secs" }, (function () {
|
|
3712
|
+
const secs = AUDIT_SECTIONS.map(function (s) {
|
|
3713
|
+
return section(sectionTitle(s), r[s.field], s.item);
|
|
3714
|
+
}).filter(Boolean);
|
|
3715
|
+
if (secs.length) return secs;
|
|
3716
|
+
// 2.14.0:`problems` 有数、分类行却一条都渲染不出来 —— 旧版就是在这种状态下
|
|
3717
|
+
// 只亮一颗红徽标、下面留白(`indexConflicts` / `oversize` 都没进分类表)。
|
|
3718
|
+
// 分类表补齐之后这条只是兜底:宁可多一行解释,也不要「有问题但看不见」。
|
|
3719
|
+
return [h("div", { className: "smem-audit-row", key: "unmapped" },
|
|
3720
|
+
"问题 " + r.problems + " 条:本屏分类表还没有对应这一类,先看下面的提示。")];
|
|
3721
|
+
})())
|
|
3668
3722
|
: h("div", { className: "smem-empty smem-empty--ok", key: "ok" },
|
|
3669
3723
|
"没有发现问题 —— 索引、双链、frontmatter 与行尾都对得上。"),
|
|
3670
3724
|
hints.length
|
|
3671
|
-
? h("div", {
|
|
3672
|
-
h("div", { className: "smem-audit-h", key: "h" }, "指向已归档(提示,不计入问题)"),
|
|
3673
|
-
h("div", { className: "smem-ar-hint", key: "n" },
|
|
3674
|
-
"归档不是删除:这些链接的目标还在档案馆里躺着,恢复它链接就活了 —— 不用改。"),
|
|
3675
|
-
rows(hints, AUDIT_ARCHIVED_LINKS.item),
|
|
3676
|
-
])
|
|
3725
|
+
? h("div", { key: "hints" }, hints)
|
|
3677
3726
|
: null,
|
|
3678
3727
|
h("div", { className: "smem-ar-hint", key: "ro" }, "这里只报告、不修改 —— 要改哪条,用那条记忆自己的编辑入口。"),
|
|
3679
3728
|
]);
|
|
@@ -4791,6 +4840,21 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
4791
4840
|
"todo.err.noRemote": "宿主没有记忆 remote,读不了待办文件",
|
|
4792
4841
|
"todo.err.read": "读不到待办文件:{error}",
|
|
4793
4842
|
"todo.err.write": "写入被拒:{error}",
|
|
4843
|
+
"todo.err.noArchive": "宿主没有读写保留名的 remote(readRaw / writeRaw),搬不进流水",
|
|
4844
|
+
"todo.err.archive": "搬进流水失败:{error}",
|
|
4845
|
+
"todo.filter.open": "未完成",
|
|
4846
|
+
"todo.filter.openTitle": "只显示未完成(待删除块照旧显示:它是待清空的队列)",
|
|
4847
|
+
"todo.filter.all": "全部",
|
|
4848
|
+
"todo.filter.allTitle": "连旧文件里遗留的 - [x] 行一起显示",
|
|
4849
|
+
"todo.undoDepth.label": "撤销",
|
|
4850
|
+
"todo.undoDepth.option": "{n} 步",
|
|
4851
|
+
"todo.action.undoTitle": "撤销上一步(栈深 {depth} 步,只在本次页面里有效)",
|
|
4852
|
+
"todo.action.archive": "搬进流水({count})",
|
|
4853
|
+
"todo.notice.archived": "已把 {count} 条搬进 {file},并从清单里删掉(这一步不可撤销)",
|
|
4854
|
+
"todo.notice.archivedDup": "这些条目在 {file} 里都已经有了,只删掉了清单里那几行",
|
|
4855
|
+
"todo.notice.archiveStale": "{count} 条已写进流水,但清单刚被别处改过:清单里那几行**没删**,刷新后再点一次即可(重复会被跳过)",
|
|
4856
|
+
"todo.cp.title": "检查点里的未完成(只读)",
|
|
4857
|
+
"todo.cp.note": "来自 tasks/*/WORKING.md 的「未完成」节。这里只显示,改动请回到那份检查点。",
|
|
4794
4858
|
"todo.disabled.title": "待办看板已在「实验性」里关闭",
|
|
4795
4859
|
"todo.disabled.hint": "打开:设置 → 记忆管理 → 实验性 → 待办清单看板",
|
|
4796
4860
|
"todo.lab.title": "待办清单看板(实验性)",
|
|
@@ -5417,8 +5481,23 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
5417
5481
|
"todo.err.noRemote": "This host exposes no memory remote, so the to-do file cannot be read",
|
|
5418
5482
|
"todo.err.read": "Cannot read the to-do file: {error}",
|
|
5419
5483
|
"todo.err.write": "Write rejected: {error}",
|
|
5484
|
+
"todo.err.noArchive": "This host exposes no readRaw / writeRaw remote, so the log cannot be appended",
|
|
5485
|
+
"todo.err.archive": "Could not move items into the log: {error}",
|
|
5486
|
+
"todo.filter.open": "Open",
|
|
5487
|
+
"todo.filter.openTitle": "Show open items only (the pending-deletion block stays: it is a queue to clear)",
|
|
5488
|
+
"todo.filter.all": "All",
|
|
5489
|
+
"todo.filter.allTitle": "Also show legacy - [x] lines left in the file",
|
|
5490
|
+
"todo.undoDepth.label": "Undo",
|
|
5491
|
+
"todo.undoDepth.option": "{n} steps",
|
|
5492
|
+
"todo.action.undoTitle": "Undo the last edit (stack depth {depth}; in-memory only)",
|
|
5493
|
+
"todo.action.archive": "Move to log ({count})",
|
|
5494
|
+
"todo.notice.archived": "Moved {count} item(s) into {file} and removed them from the list (this cannot be undone)",
|
|
5495
|
+
"todo.notice.archivedDup": "Those items were already in {file}; only the list lines were removed",
|
|
5496
|
+
"todo.notice.archiveStale": "{count} item(s) were appended to the log, but the list changed elsewhere: its lines were NOT removed. Refresh and click again — duplicates are skipped.",
|
|
5420
5497
|
"todo.disabled.title": "The to-do board is switched off in the lab settings",
|
|
5421
5498
|
"todo.disabled.hint": "Turn it on: Settings → Memory management → Lab → To-do board",
|
|
5499
|
+
"todo.cp.title": "Open items in checkpoints (read-only)",
|
|
5500
|
+
"todo.cp.note": "From the open-work section of tasks/*/WORKING.md. Display only — edit the checkpoint itself.",
|
|
5422
5501
|
"todo.lab.title": "To-do board (experimental)",
|
|
5423
5502
|
"todo.lab.switch": "Enable the to-do board",
|
|
5424
5503
|
"todo.lab.switch.title": "Adds a To-dos tab to the right sidebar",
|
|
@@ -5535,6 +5614,13 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
5535
5614
|
fix: "文件在、索引里没有 —— 在索引里补一行 `- [标题](文件.md) — 一句话`",
|
|
5536
5615
|
item: function (x) { return String(x.file == null ? "" : x.file); },
|
|
5537
5616
|
},
|
|
5617
|
+
{
|
|
5618
|
+
// 2.14.0:这一类**已经算进 problems** 却一直没有渲染位置 —— 于是「问题 N」
|
|
5619
|
+
// 徽标亮着、清单里一行都没有(只有大小写敏感的卷上才会出现,但一旦出现就是哑的)。
|
|
5620
|
+
field: "indexConflicts", title: "索引有多份变体", sub: "同一目录里同时存在多个大小写变体",
|
|
5621
|
+
fix: "只保留一份索引(通常是 MEMORY.md),把多余的变体改名或删掉 —— 它们的内容可能不一样,先各自看一眼",
|
|
5622
|
+
item: function (x) { return String(x.file == null ? "" : x.file); },
|
|
5623
|
+
},
|
|
5538
5624
|
{
|
|
5539
5625
|
field: "typeMismatch", title: "type 与前缀对不上", sub: "",
|
|
5540
5626
|
fix: "本库以前缀为准,改 frontmatter 的 type(确实该换类型的再改文件名)",
|
|
@@ -5580,23 +5666,65 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
5580
5666
|
fix: "归档中途崩溃留下的私有名,内容可能还在 —— 先问我,再决定改回 .md 还是删除",
|
|
5581
5667
|
item: function (x) { return String(x.file == null ? "" : x.file); },
|
|
5582
5668
|
},
|
|
5669
|
+
{
|
|
5670
|
+
// 2.14.0:体积这一项原先也不在分节表里 —— force 档计数进了 problems,
|
|
5671
|
+
// 面板却没有位置显示是哪几条(与上面 indexConflicts 同一个缺口)。
|
|
5672
|
+
// warn / force 都列(面板要看见「该处置了」),但只有 force 进 problems。
|
|
5673
|
+
field: "oversize", title: "超线体积", sub: "≥40 KB 必须处置,16 KB 起只提醒",
|
|
5674
|
+
fix: "能拆一节就 archive_segment,拆不开就 write_memory 压缩(正文别为了省行删事实)",
|
|
5675
|
+
item: function (x) {
|
|
5676
|
+
const lv = String(x.level == null ? "" : x.level) === "force" ? "必须处置" : "提醒";
|
|
5677
|
+
return String(x.file == null ? "" : x.file) + " · " + fmtSize(typeof x.bytes === "number" ? x.bytes : 0) + " · " + lv;
|
|
5678
|
+
},
|
|
5679
|
+
},
|
|
5583
5680
|
];
|
|
5584
5681
|
|
|
5585
|
-
/**
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5682
|
+
/**
|
|
5683
|
+
* 体检的**提示类**(不计入 problems)—— 面板与提示词共用同一份(2.6.0 的教训:
|
|
5684
|
+
* 两处各写一份标题,久了就会出现「面板说 8 条、复制出去只有 6 条」)。
|
|
5685
|
+
*
|
|
5686
|
+
* · `note` 给面板的一句「为什么不用管 / 该怎么处置」;
|
|
5687
|
+
* · `fix` 给提示词的行动口径(纪律必须写死:归档不是删除、索引只报不改)。
|
|
5688
|
+
*
|
|
5689
|
+
* 2.14.0 新增两类:孤儿归档件(治理发现的死件)、索引瘦身提案(只报不改)。
|
|
5690
|
+
*/
|
|
5691
|
+
const AUDIT_HINTS = [
|
|
5692
|
+
{
|
|
5693
|
+
field: "archivedLinks",
|
|
5694
|
+
title: "指向已归档(提示,不计入问题)",
|
|
5695
|
+
note: "归档不是删除:这些链接的目标还在档案馆里躺着,恢复它链接就活了 —— 不用改。",
|
|
5696
|
+
fix: "归档不是删除,目标还在档案馆里 —— 能改成指向现有活动记忆就改;改不了就保持原样,不要为此恢复归档,也不要删掉链接所在的记忆",
|
|
5697
|
+
item: function (x) {
|
|
5698
|
+
return String(x.file == null ? "" : x.file) + " → [[" + String(x.target == null ? "" : x.target) + "]]";
|
|
5699
|
+
},
|
|
5590
5700
|
},
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5701
|
+
{
|
|
5702
|
+
field: "orphans",
|
|
5703
|
+
title: "孤儿归档件(提示,不计入问题)",
|
|
5704
|
+
note: "「原件已不在」= 这段旧内容所属的那条记忆没了;「内容相同」= 整理时留了两份 —— 恢复还是删,你定。",
|
|
5705
|
+
fix: "这两类都**先别动手**:no_source 的先确认原件该不该恢复(可能是有意删掉的);duplicate 的两份都要读一遍,可能是「新版 + 旧版」而不是重复。拿不准就原样留着,归档件不影响检索",
|
|
5706
|
+
item: function (x) {
|
|
5707
|
+
const f = String(x.file == null ? "" : x.file);
|
|
5708
|
+
if (String(x.kind == null ? "" : x.kind) === "duplicate") {
|
|
5709
|
+
return f + " 与 " + String(x.with == null ? "?" : x.with) + " 内容完全相同";
|
|
5710
|
+
}
|
|
5711
|
+
return f + " ← 原件 " + String(x.from == null ? "?" : x.from) + " 已不在";
|
|
5712
|
+
},
|
|
5713
|
+
},
|
|
5714
|
+
{
|
|
5715
|
+
field: "indexProposals",
|
|
5716
|
+
title: "索引瘦身提案(只报不改)",
|
|
5717
|
+
note: "MEMORY.md 是每轮注入的入口,插件不自动改它 —— 要动就复制修复提示词,按行号改,改前先落一份 .bak。",
|
|
5718
|
+
// dangling 与上面「索引悬空」是**同一批条目**(这里只是补上行号),不重复算两件事;
|
|
5719
|
+
// 真正只有这里才有的是 long_line(超长行)。
|
|
5720
|
+
fix: "只改**下面点到行号**的地方:dangling 那几行与上面「索引悬空」是同一批,这里多给行号,别当成两件事;long_line 那行压成「一句描述 + 指针」。动 MEMORY.md 之前先把它备份成 MEMORY.md.bak-<时间戳>,改完把改动的行贴给我",
|
|
5721
|
+
item: function (x) {
|
|
5722
|
+
const line = "第 " + String(x.line == null ? "?" : x.line) + " 行";
|
|
5723
|
+
if (String(x.kind == null ? "" : x.kind) === "dangling") return line + " 指向不存在的 " + String(x.target == null ? "?" : x.target);
|
|
5724
|
+
return line + " " + String(x.chars == null ? "?" : x.chars) + " 字:" + String(x.head == null ? "" : x.head);
|
|
5725
|
+
},
|
|
5726
|
+
},
|
|
5727
|
+
];
|
|
5600
5728
|
|
|
5601
5729
|
/** 冲突类型 → 中文标签(提示词正文只出中文,所以不走界面那份 i18n 键)。 */
|
|
5602
5730
|
const CONFLICT_KIND_ZH = {
|
|
@@ -5647,14 +5775,26 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
5647
5775
|
const r = report && typeof report === "object" ? report : null;
|
|
5648
5776
|
if (!r) return null;
|
|
5649
5777
|
const problems = typeof r.problems === "number" && isFinite(r.problems) ? r.problems : 0;
|
|
5650
|
-
|
|
5778
|
+
/**
|
|
5779
|
+
* 提示类(孤儿归档件 / 索引瘦身提案)里有几条。
|
|
5780
|
+
*
|
|
5781
|
+
* 2.14.0 起这段的门槛从「problems > 0」放宽成「problems > 0 **或** 有提案」——
|
|
5782
|
+
* 否则治理发现的死件与索引超长永远走不到这颗按钮上(它们按设计不进 problems)。
|
|
5783
|
+
*/
|
|
5784
|
+
const hintCount = AUDIT_HINTS.reduce(function (n, g) {
|
|
5785
|
+
const list = Array.isArray(r[g.field]) ? r[g.field] : [];
|
|
5786
|
+
return n + list.filter(function (x) { return x && typeof x === "object"; }).length;
|
|
5787
|
+
}, 0);
|
|
5788
|
+
if (problems <= 0 && hintCount === 0) return null;
|
|
5651
5789
|
|
|
5652
5790
|
const lines = [];
|
|
5653
5791
|
// 不在这里写「记忆目录」—— 那是整段提示词的开头(`buildHealthFixPrompt` 统一写一次),
|
|
5654
5792
|
// 两段各写一遍会在合成后的文本里出现两次同样的路径。
|
|
5655
5793
|
lines.push(
|
|
5656
5794
|
"扫描 " + auditPromptNum(r.fileCount) + " 个记忆 · 索引 " + auditPromptNum(r.indexEntries) +
|
|
5657
|
-
" 条 · 档案馆 " + auditPromptNum(r.archivedCount) +
|
|
5795
|
+
" 条 · 档案馆 " + auditPromptNum(r.archivedCount) +
|
|
5796
|
+
(typeof r.archiveReferenced === "number" ? " 条(被活动记忆引用 " + auditPromptNum(r.archiveReferenced) + " 条)" : " 条") +
|
|
5797
|
+
" · 问题合计 " + problems,
|
|
5658
5798
|
);
|
|
5659
5799
|
lines.push("");
|
|
5660
5800
|
lines.push("修复口径:");
|
|
@@ -5664,12 +5804,15 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
5664
5804
|
lines.push("2. 只改清单里指出的那一点:正文与其它 frontmatter 字段不要顺手动,行尾保持 LF。");
|
|
5665
5805
|
lines.push("3. 不删记忆:要下线用归档,不要删文件;「归档残留」这一类先问我再动。");
|
|
5666
5806
|
lines.push("4. 拿不准的(读不出来、type 该怎么统一)先说不确定,不要猜着改。");
|
|
5807
|
+
if (problems <= 0) {
|
|
5808
|
+
lines.push("5. 本屏**没有硬问题**:下面全是提示与提案(只报不改)。没有我点头之前,一个文件都不要动。");
|
|
5809
|
+
}
|
|
5667
5810
|
|
|
5668
|
-
const listed = appendPromptGroups(lines, AUDIT_SECTIONS, r);
|
|
5669
|
-
const hinted = appendPromptGroups(lines,
|
|
5811
|
+
const listed = problems > 0 ? appendPromptGroups(lines, AUDIT_SECTIONS, r) : 0;
|
|
5812
|
+
const hinted = appendPromptGroups(lines, AUDIT_HINTS, r);
|
|
5670
5813
|
lines.push("");
|
|
5671
5814
|
lines.push("改完请自己再核对一遍(能跑 audit_memory 就跑),然后告诉我每条改了什么。");
|
|
5672
|
-
return { lines: lines, count: listed, hints: hinted };
|
|
5815
|
+
return { lines: lines, count: listed + hinted, hard: problems > 0, hints: hinted };
|
|
5673
5816
|
}
|
|
5674
5817
|
|
|
5675
5818
|
/**
|
|
@@ -5722,7 +5865,11 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
5722
5865
|
if (a && b) {
|
|
5723
5866
|
lines.push("这次两部分都有:A 是体检发现的结构问题(**要修**),B 是待裁决的矛盾(**只做判断,不要改盘上的文件**)。");
|
|
5724
5867
|
} else if (a) {
|
|
5725
|
-
|
|
5868
|
+
// 2.14.0:A 段现在也可能是「只有提示与提案」—— 措辞必须跟着分叉,
|
|
5869
|
+
// 不然智能体会把一段只报告的内容当成「按清单修」去改盘。
|
|
5870
|
+
lines.push(a.hard
|
|
5871
|
+
? "这次只有 A:体检发现的结构问题(**要修**);当前没有待裁决的矛盾。"
|
|
5872
|
+
: "这次只有 A 的提示类:体检**没有硬问题**,下面是治理提案(**只报不改**);当前没有待裁决的矛盾。");
|
|
5726
5873
|
} else {
|
|
5727
5874
|
lines.push("这次只有 B:待裁决的矛盾(**只做判断,不要改盘上的文件**);体检没有发现问题。");
|
|
5728
5875
|
}
|
|
@@ -5730,7 +5877,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
5730
5877
|
|
|
5731
5878
|
if (a) {
|
|
5732
5879
|
lines.push("");
|
|
5733
|
-
lines.push("════ A · 体检问题:按下面的清单修 ════");
|
|
5880
|
+
lines.push(a.hard ? "════ A · 体检问题:按下面的清单修 ════" : "════ A · 体检提示与提案:只报不改 ════");
|
|
5734
5881
|
Array.prototype.push.apply(lines, a.lines);
|
|
5735
5882
|
}
|
|
5736
5883
|
if (b) {
|
|
@@ -8463,8 +8610,10 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
8463
8610
|
function conflictErrText(err) {
|
|
8464
8611
|
const code = err && typeof err.code === "string" ? err.code : "";
|
|
8465
8612
|
const key = CONFLICT_CODE_KEY[code] || "conflict.code.unknown";
|
|
8466
|
-
|
|
8467
|
-
|
|
8613
|
+
// 2.14.0:局部量改叫 hostDetail —— 工厂作用域现在有一份共享的 detail()
|
|
8614
|
+
// (错误详情展开),同名会遮蔽它,也让 client-scope-test 的「只此一份」判据读不清。
|
|
8615
|
+
const hostDetail = err && typeof err.error === "string" ? err.error : "";
|
|
8616
|
+
return t(key) + (hostDetail ? t("conflict.code.detail", { detail: hostDetail }) : "");
|
|
8468
8617
|
}
|
|
8469
8618
|
|
|
8470
8619
|
/** 打开「冲突」这一屏。数据没取过才取(挂载时已经取过一次,通常直接有内容)。 */
|
|
@@ -8830,10 +8979,15 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
8830
8979
|
// 冲突徽标数的是**待裁决**(open)条数 —— 与冲突页签里的「N 条待裁决」同源。
|
|
8831
8980
|
// -1 = 还没取到队列(显示「未载」,不假装 0 条)。
|
|
8832
8981
|
const conflictOpen = conf && conf.counts && typeof conf.counts.open === "number" ? conf.counts.open : -1;
|
|
8833
|
-
// 「复制修复提示词」那颗按钮的分母:体检问题 +
|
|
8982
|
+
// 「复制修复提示词」那颗按钮的分母:体检问题 + 待裁决冲突 + **治理提案**。全都没有(=0)时按钮不渲染;
|
|
8834
8983
|
// 冲突队列还没载入(-1)不算进分母 —— 免得按钮先冒出来又消失。
|
|
8984
|
+
// 2.14.0:孤儿归档件与索引瘦身提案按设计不进 problems,只数 problems 会让它们
|
|
8985
|
+
// 永远走不到这颗按钮上(治理看得到、复制不出去)。
|
|
8986
|
+
const proposalCount = (audit && Array.isArray(audit.orphans) ? audit.orphans.length : 0)
|
|
8987
|
+
+ (audit && Array.isArray(audit.indexProposals) ? audit.indexProposals.length : 0);
|
|
8835
8988
|
const healthWork = (audit && typeof audit.problems === "number" && audit.problems > 0 ? audit.problems : 0)
|
|
8836
|
-
+ (conflictOpen > 0 ? conflictOpen : 0)
|
|
8989
|
+
+ (conflictOpen > 0 ? conflictOpen : 0)
|
|
8990
|
+
+ proposalCount;
|
|
8837
8991
|
|
|
8838
8992
|
// 2.12.0(2.12.1 改位置):初始记忆卡片 —— 挂在**实验性**那一屏最上面。
|
|
8839
8993
|
// 放这里的理由(2026-11-17 定):它不是日常动作,是「第一次上手」用的一段材料,
|
|
@@ -9700,8 +9854,21 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
9700
9854
|
* **字面量写进文件,不跟界面语言走** —— 它是文件格式的一部分,不是 UI 文案。
|
|
9701
9855
|
*/
|
|
9702
9856
|
const TODO_DONE_HEADING = "## 已完成,待删除";
|
|
9703
|
-
/**
|
|
9704
|
-
|
|
9857
|
+
/**
|
|
9858
|
+
* 撤销 / 重做步数(2.15.0 起可配 3–5,默认 5)。
|
|
9859
|
+
* 栈本身**只在内存里**(关页面即失效);落 localStorage 的只有「用户选了几步」这个偏好。
|
|
9860
|
+
*/
|
|
9861
|
+
const TODO_UNDO_DEFAULT = 5;
|
|
9862
|
+
const TODO_UNDO_MIN = 3;
|
|
9863
|
+
const TODO_UNDO_MAX = 5;
|
|
9864
|
+
/** 偏好键:撤销步数 / 各组展开状态。localStorage 本身就按 origin 隔离。 */
|
|
9865
|
+
const TODO_PREF_UNDO = "sage-mem.todo.undoDepth";
|
|
9866
|
+
const TODO_PREF_OPEN = "sage-mem.todo.openGroups";
|
|
9867
|
+
/** 筛选两档:默认只看未完成;`全部`才把旧文件里遗留的 `- [x]` 行也画出来。 */
|
|
9868
|
+
const TODO_FILTER_OPEN = "open";
|
|
9869
|
+
const TODO_FILTER_ALL = "all";
|
|
9870
|
+
/** 完成项留档的落点:跨会话流水(保留名,走 readRaw / writeRaw)。 */
|
|
9871
|
+
const TODO_LOG_FILE = "session-log.md";
|
|
9705
9872
|
|
|
9706
9873
|
/** 开关状态(模块级:设置卡与页签共享)。 */
|
|
9707
9874
|
let todoBoardEnabled = false;
|
|
@@ -9735,6 +9902,161 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
9735
9902
|
return s[0];
|
|
9736
9903
|
}
|
|
9737
9904
|
|
|
9905
|
+
// ── 本地偏好(2.15.0):只存「用户怎么选的」,不存任何清单内容 ──────────
|
|
9906
|
+
//
|
|
9907
|
+
// 纪律与「不建自己的存储」一致:清单的唯一真相仍是那份 markdown。
|
|
9908
|
+
// 这里存的只有两件纯界面偏好 —— 撤销留几步、哪几组是展开的。
|
|
9909
|
+
// 读不到(隐私模式 / 配额满 / 无 DOM 的测试环境)一律按默认走,**不报错**。
|
|
9910
|
+
|
|
9911
|
+
function todoStore() {
|
|
9912
|
+
try {
|
|
9913
|
+
if (typeof localStorage === "undefined" || localStorage === null) return null;
|
|
9914
|
+
return localStorage;
|
|
9915
|
+
} catch (e) { return null; }
|
|
9916
|
+
}
|
|
9917
|
+
|
|
9918
|
+
function todoPrefGet(key) {
|
|
9919
|
+
const s = todoStore();
|
|
9920
|
+
if (!s || typeof s.getItem !== "function") return null;
|
|
9921
|
+
try { return s.getItem(key); } catch (e) { return null; }
|
|
9922
|
+
}
|
|
9923
|
+
|
|
9924
|
+
function todoPrefSet(key, value) {
|
|
9925
|
+
const s = todoStore();
|
|
9926
|
+
if (!s || typeof s.setItem !== "function") return;
|
|
9927
|
+
try { s.setItem(key, value); } catch (e) { /* 偏好丢了不影响主流程 */ }
|
|
9928
|
+
}
|
|
9929
|
+
|
|
9930
|
+
/** 撤销步数归一:非数字 / 越界都收进 [3, 5],坏值(含 null / 空串)回默认 5。 */
|
|
9931
|
+
function todoClampUndoDepth(n) {
|
|
9932
|
+
if (n === null || n === undefined || n === "") return TODO_UNDO_DEFAULT;
|
|
9933
|
+
const v = Math.round(Number(n));
|
|
9934
|
+
if (!Number.isFinite(v)) return TODO_UNDO_DEFAULT;
|
|
9935
|
+
return Math.min(TODO_UNDO_MAX, Math.max(TODO_UNDO_MIN, v));
|
|
9936
|
+
}
|
|
9937
|
+
|
|
9938
|
+
/** 组展开偏好的键:就是节标题原文(空标题用同一个兜底键)。 */
|
|
9939
|
+
function todoGroupKey(title) {
|
|
9940
|
+
return String(title == null ? "" : title);
|
|
9941
|
+
}
|
|
9942
|
+
|
|
9943
|
+
/**
|
|
9944
|
+
* 解析 `{组标题: true|false}` 偏好。坏 JSON、数组、别的类型一律当「没有偏好」——
|
|
9945
|
+
* 于是所有组回到默认(收起),而不是让整块看板因为一行坏数据打不开。
|
|
9946
|
+
* @returns {Object<string, boolean>}
|
|
9947
|
+
*/
|
|
9948
|
+
function todoOpenMapParse(raw) {
|
|
9949
|
+
const out = Object.create(null);
|
|
9950
|
+
let value = null;
|
|
9951
|
+
try { value = JSON.parse(String(raw == null ? "" : raw)); } catch (e) { return out; }
|
|
9952
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return out;
|
|
9953
|
+
Object.keys(value).forEach(function (k) {
|
|
9954
|
+
if (value[k] === true || value[k] === false) out[k] = value[k];
|
|
9955
|
+
});
|
|
9956
|
+
return out;
|
|
9957
|
+
}
|
|
9958
|
+
|
|
9959
|
+
/** 序列化展开偏好(只留布尔值,别的键丢掉)。 */
|
|
9960
|
+
function todoOpenMapSerialize(map) {
|
|
9961
|
+
const out = {};
|
|
9962
|
+
Object.keys(map || {}).forEach(function (k) {
|
|
9963
|
+
if (map[k] === true || map[k] === false) out[k] = map[k];
|
|
9964
|
+
});
|
|
9965
|
+
try { return JSON.stringify(out); } catch (e) { return "{}"; }
|
|
9966
|
+
}
|
|
9967
|
+
|
|
9968
|
+
/**
|
|
9969
|
+
* 筛选:`open` 档只留未完成(待删除块里的条目照旧显示 —— 它是**队列**,
|
|
9970
|
+
* 不是「已完成的历史」,藏起来就没法清空 / 留档了)。
|
|
9971
|
+
*/
|
|
9972
|
+
function todoFilterItems(items, filter) {
|
|
9973
|
+
const list = items || [];
|
|
9974
|
+
if (filter === TODO_FILTER_ALL) return list;
|
|
9975
|
+
return list.filter(function (it) { return !it.done || it.inDone; });
|
|
9976
|
+
}
|
|
9977
|
+
|
|
9978
|
+
/** 比较用的归一化正文:连续空白压成一个空格、去首尾。 */
|
|
9979
|
+
function todoLogKey(text) {
|
|
9980
|
+
return String(text == null ? "" : text).replace(/\s+/g, " ").trim();
|
|
9981
|
+
}
|
|
9982
|
+
|
|
9983
|
+
/** 流水里已经记过的条目正文(归一化后)。用于「重复点一次不会写两遍」。 */
|
|
9984
|
+
function todoLogKeys(logText) {
|
|
9985
|
+
const set = new Set();
|
|
9986
|
+
String(logText == null ? "" : logText).split(/\r?\n/).forEach(function (line) {
|
|
9987
|
+
const m = /^\s*[-*+]\s+(.*)$/.exec(line);
|
|
9988
|
+
if (m && m[1].trim() !== "") set.add(todoLogKey(m[1]));
|
|
9989
|
+
});
|
|
9990
|
+
return set;
|
|
9991
|
+
}
|
|
9992
|
+
|
|
9993
|
+
/** `YYYY-MM-DD HH:mm`(本地时区;流水的人读时间,不用 UTC)。 */
|
|
9994
|
+
function todoStamp(now) {
|
|
9995
|
+
const d = now instanceof Date ? now : new Date();
|
|
9996
|
+
const p = function (n) { return String(n).padStart(2, "0"); };
|
|
9997
|
+
return String(d.getFullYear()) + "-" + p(d.getMonth() + 1) + "-" + p(d.getDate()) +
|
|
9998
|
+
" " + p(d.getHours()) + ":" + p(d.getMinutes());
|
|
9999
|
+
}
|
|
10000
|
+
|
|
10001
|
+
/**
|
|
10002
|
+
* 把待删除块里的条目拼成一段流水(纯函数,不碰 IO、不改入参)。
|
|
10003
|
+
*
|
|
10004
|
+
* **逐字照抄条目正文**,不改写成概括 —— 2.14.0 做归档时那条纪律同样适用:
|
|
10005
|
+
* 概化过的流水半年后没人能据此复现。已经在流水里记过的(`existingKeys`)跳过,
|
|
10006
|
+
* 于是「上次写了一半」的失败可以安全重试。
|
|
10007
|
+
*
|
|
10008
|
+
* @param {Array<object>} items 待删除块里的条目(`text` 已剥掉 `[x]`)
|
|
10009
|
+
* @param {Date} now 时间戳
|
|
10010
|
+
* @param {Set<string>} [existingKeys] 流水里已有的正文键
|
|
10011
|
+
* @returns {{text: string, bodies: string[], count: number}}
|
|
10012
|
+
*/
|
|
10013
|
+
function todoArchiveBlock(items, now, existingKeys) {
|
|
10014
|
+
const keys = existingKeys || new Set();
|
|
10015
|
+
const seen = new Set();
|
|
10016
|
+
const bodies = [];
|
|
10017
|
+
(items || []).forEach(function (it) {
|
|
10018
|
+
const body = String(it && it.text != null ? it.text : "").trim();
|
|
10019
|
+
if (body === "") return;
|
|
10020
|
+
const key = todoLogKey(body);
|
|
10021
|
+
if (keys.has(key) || seen.has(key)) return;
|
|
10022
|
+
seen.add(key);
|
|
10023
|
+
bodies.push(body);
|
|
10024
|
+
});
|
|
10025
|
+
if (bodies.length === 0) return { text: "", bodies: [], count: 0 };
|
|
10026
|
+
const head = "## " + todoStamp(now) + " · 待办收尾(" + String(bodies.length) + " 条)";
|
|
10027
|
+
const lines = [
|
|
10028
|
+
head,
|
|
10029
|
+
"",
|
|
10030
|
+
// ⚠️ 这两处字面量进的是**文件内容**(流水),不跟界面语言走 —— 与 TODO_DONE_HEADING 同理。
|
|
10031
|
+
"**来源**:`" + TODO_FILE + "` 的「已完成,待删除」块,由待办看板搬入(正文照抄)。",
|
|
10032
|
+
"",
|
|
10033
|
+
].concat(bodies.map(function (b) { return "- " + b; }));
|
|
10034
|
+
return { text: lines.join("\n"), bodies: bodies, count: bodies.length };
|
|
10035
|
+
}
|
|
10036
|
+
|
|
10037
|
+
/**
|
|
10038
|
+
* 把一段流水接到已有内容末尾:保证「原有内容不动 + 空一行 + 新段 + 以换行结尾」。
|
|
10039
|
+
*
|
|
10040
|
+
* ⚠️ 按**行**拼,别在 `"\r\n"` 后面再补一个裸 `"\r"` —— CRLF 文件会被拼出
|
|
10041
|
+
* `"\r\n\r"` 这种既不是 CRLF 也不是 LF 的东西(2.15.0 的第一版就踩了这条)。
|
|
10042
|
+
*/
|
|
10043
|
+
function todoSessionLogAppend(logText, blockText) {
|
|
10044
|
+
const src = String(logText == null ? "" : logText);
|
|
10045
|
+
const block = String(blockText == null ? "" : blockText);
|
|
10046
|
+
if (block === "") return src;
|
|
10047
|
+
const eol = todoEol(src);
|
|
10048
|
+
const out = src === "" ? [] : src.split("\n");
|
|
10049
|
+
// `split` 的末尾空串代表「文件以换行结尾」,不是一行内容。
|
|
10050
|
+
if (out.length > 0 && out[out.length - 1] === "") out.pop();
|
|
10051
|
+
const body = block.split("\n").filter(function (line, i, arr) {
|
|
10052
|
+
return !(line === "" && i === arr.length - 1);
|
|
10053
|
+
});
|
|
10054
|
+
if (out.length > 0) out.push(eol);
|
|
10055
|
+
body.forEach(function (line) { out.push(line + eol); });
|
|
10056
|
+
out.push("");
|
|
10057
|
+
return out.join("\n");
|
|
10058
|
+
}
|
|
10059
|
+
|
|
9738
10060
|
// ── 解析:markdown → 节 + 条目(纯函数,不碰 IO)────────────────────
|
|
9739
10061
|
|
|
9740
10062
|
/**
|
|
@@ -10100,19 +10422,30 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10100
10422
|
]);
|
|
10101
10423
|
}
|
|
10102
10424
|
|
|
10103
|
-
/** 一组(一个 `##` 节):标题 + 计数 + 条目 +
|
|
10425
|
+
/** 一组(一个 `##` 节):标题 + 计数 + 条目 + 新增框;待删除块另有「清空 / 搬进流水」。 */
|
|
10104
10426
|
function TodoSectionGroup(props) {
|
|
10105
10427
|
const sec = props.section;
|
|
10106
10428
|
const isDone = sec.kind === "done";
|
|
10107
10429
|
// 2.11.1(用户 2026-11-17 反馈):**所有组默认收起**,一屏先看见「有几组、各组几条」,
|
|
10108
10430
|
// 想看的组自己点开。原来只收「长期约束」,长清单照样一屏铺满。
|
|
10109
|
-
|
|
10431
|
+
// 2.15.0:**记住用户点开过哪几组**(localStorage,按节标题)。默认仍收起。
|
|
10432
|
+
const key = todoGroupKey(sec.title);
|
|
10433
|
+
const sCollapsed = react.useState(function () {
|
|
10434
|
+
const map = props.openMap || {};
|
|
10435
|
+
return map[key] !== true;
|
|
10436
|
+
});
|
|
10110
10437
|
const collapsed = sCollapsed[0], setCollapsed = sCollapsed[1];
|
|
10111
|
-
// 上层「全部展开 /
|
|
10438
|
+
// 上层「全部展开 / 全部收起」:一次性动作,**不写偏好**(写了就变成「永远全展开」)。
|
|
10112
10439
|
react.useEffect(function () {
|
|
10113
10440
|
if (props.allOpen === null || props.allOpen === undefined) return;
|
|
10114
10441
|
setCollapsed(!props.allOpen);
|
|
10115
10442
|
}, [props.allOpen]);
|
|
10443
|
+
function toggleGroup() {
|
|
10444
|
+
// 点一下 = 把「收起」反过来;记进偏好的是**点击后的展开态**(不是「收起态」)。
|
|
10445
|
+
const nextOpen = collapsed;
|
|
10446
|
+
setCollapsed(!collapsed);
|
|
10447
|
+
if (typeof props.onGroupToggle === "function") props.onGroupToggle(key, nextOpen);
|
|
10448
|
+
}
|
|
10116
10449
|
const sDraft = react.useState("");
|
|
10117
10450
|
const draft = sDraft[0], setDraft = sDraft[1];
|
|
10118
10451
|
const openCount = sec.items.filter(function (it) { return !it.done; }).length;
|
|
@@ -10126,12 +10459,22 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10126
10459
|
key: "toggle",
|
|
10127
10460
|
type: "button",
|
|
10128
10461
|
className: "smem-todo-group-toggle",
|
|
10129
|
-
onClick:
|
|
10462
|
+
onClick: toggleGroup,
|
|
10130
10463
|
}, [
|
|
10131
10464
|
h("span", { key: "chev", className: "smem-todo-chev" }, collapsed ? "▸" : "▾"),
|
|
10132
10465
|
h("span", { key: "t", className: "smem-todo-group-title" }, sec.title || (isDone ? t("todo.doneGroup") : t(TODO_SECTION_FALLBACK))),
|
|
10133
10466
|
h("span", { key: "n", className: "smem-todo-count" }, String(openCount) + (doneCount > 0 ? " / " + String(doneCount) : "")),
|
|
10134
10467
|
]),
|
|
10468
|
+
isDone && blockCount > 0
|
|
10469
|
+
? h("button", {
|
|
10470
|
+
key: "archive",
|
|
10471
|
+
type: "button",
|
|
10472
|
+
className: "smem-todo-mini smem-todo-archive",
|
|
10473
|
+
title: t("todo.action.archive", { count: blockCount, file: TODO_LOG_FILE }),
|
|
10474
|
+
disabled: props.busy,
|
|
10475
|
+
onClick: function () { props.onArchive(sec); },
|
|
10476
|
+
}, t("todo.action.archive", { count: blockCount, file: TODO_LOG_FILE }))
|
|
10477
|
+
: null,
|
|
10135
10478
|
isDone && blockCount > 0
|
|
10136
10479
|
? h("button", {
|
|
10137
10480
|
key: "clear",
|
|
@@ -10174,6 +10517,46 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10174
10517
|
]);
|
|
10175
10518
|
}
|
|
10176
10519
|
|
|
10520
|
+
/**
|
|
10521
|
+
* 检查点聚合(2.15.0)—— **只读**。
|
|
10522
|
+
*
|
|
10523
|
+
* 把 `<状态根>/tasks/<id>/WORKING.md` 的「未完成」节并到清单上方显示。
|
|
10524
|
+
* **不合并写入**:那些条目在别的文件里、有自己的 revision 与写协议,
|
|
10525
|
+
* 看板只负责让人看见「还有哪些任务没收尾」,动手改仍然回到那份检查点。
|
|
10526
|
+
* 老宿主的 remote 上没有 `checkpoints`,于是整块不出现(不是显示一个空壳)。
|
|
10527
|
+
*/
|
|
10528
|
+
function TodoCheckpointBlock(props) {
|
|
10529
|
+
const sOpen = react.useState(false);
|
|
10530
|
+
const open = sOpen[0], setOpen = sOpen[1];
|
|
10531
|
+
const tasks = props.tasks || [];
|
|
10532
|
+
return h("section", { className: "smem-todo-group smem-todo-group-cp" }, [
|
|
10533
|
+
h("div", { key: "head", className: "smem-todo-group-head" }, [
|
|
10534
|
+
h("button", {
|
|
10535
|
+
key: "toggle",
|
|
10536
|
+
type: "button",
|
|
10537
|
+
className: "smem-todo-group-toggle",
|
|
10538
|
+
title: t("todo.cp.title"),
|
|
10539
|
+
onClick: function () { setOpen(!open); },
|
|
10540
|
+
}, [
|
|
10541
|
+
h("span", { key: "chev", className: "smem-todo-chev" }, open ? "▾" : "▸"),
|
|
10542
|
+
h("span", { key: "t", className: "smem-todo-group-title" }, t("todo.cp.title")),
|
|
10543
|
+
h("span", { key: "n", className: "smem-todo-count" }, String(props.count || 0)),
|
|
10544
|
+
]),
|
|
10545
|
+
]),
|
|
10546
|
+
open ? h("div", { key: "list", className: "smem-todo-list" }, tasks.map(function (task) {
|
|
10547
|
+
const id = String(task && task.taskId ? task.taskId : "");
|
|
10548
|
+
const label = task && task.project ? String(task.project) + " · " + id : id;
|
|
10549
|
+
return h("div", { key: "t" + id, className: "smem-todo-cp-task" }, [
|
|
10550
|
+
h("div", { key: "h", className: "smem-todo-cp-head" }, label),
|
|
10551
|
+
h("div", { key: "i", className: "smem-todo-cp-items" }, (task.items || []).map(function (txt, i) {
|
|
10552
|
+
return h("div", { key: "x" + i, className: "smem-todo-cp-item" }, todoInline(String(txt)));
|
|
10553
|
+
})),
|
|
10554
|
+
]);
|
|
10555
|
+
})) : null,
|
|
10556
|
+
open ? h("div", { key: "note", className: "smem-todo-cp-note" }, t("todo.cp.note")) : null,
|
|
10557
|
+
]);
|
|
10558
|
+
}
|
|
10559
|
+
|
|
10177
10560
|
/** 页签正文。承载全部读写状态(宿主只给 ctx / sessionId / 标准 hooks)。 */
|
|
10178
10561
|
function TodoBoard(props) {
|
|
10179
10562
|
const ctx = props.ctx;
|
|
@@ -10187,15 +10570,50 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10187
10570
|
const sErr = react.useState(null); const err = sErr[0], setErr = sErr[1];
|
|
10188
10571
|
const sNotice = react.useState(""); const notice = sNotice[0], setNotice = sNotice[1];
|
|
10189
10572
|
const sBusy = react.useState(false); const busy = sBusy[0], setBusy = sBusy[1];
|
|
10190
|
-
// 撤销 /
|
|
10191
|
-
//
|
|
10573
|
+
// 撤销 / 重做:元素是写入前的 `{content, revision}`。栈**只在内存里**,
|
|
10574
|
+
// 深度 3–5 可配(偏好落 localStorage);任何**新**写入都清空 redoStack —— 历史分叉了。
|
|
10575
|
+
const sDepth = react.useState(function () { return todoClampUndoDepth(todoPrefGet(TODO_PREF_UNDO)); });
|
|
10576
|
+
const undoDepth = sDepth[0], setUndoDepth = sDepth[1];
|
|
10192
10577
|
const sUndo = react.useState([]); const undoStack = sUndo[0], setUndoStack = sUndo[1];
|
|
10193
10578
|
const sRedo = react.useState([]); const redoStack = sRedo[0], setRedoStack = sRedo[1];
|
|
10194
|
-
// 「全部展开」是**一次性动作**而不是持久状态:默认 null
|
|
10579
|
+
// 「全部展开」是**一次性动作**而不是持久状态:默认 null(各组按自己的默认走)。
|
|
10195
10580
|
const sAll = react.useState(null); const allOpen = sAll[0], setAllOpen = sAll[1];
|
|
10581
|
+
// 各组展开偏好(2.15.0):`{节标题: true|false}`,点开/收起就写回 localStorage。
|
|
10582
|
+
const sOpenMap = react.useState(function () { return todoOpenMapParse(todoPrefGet(TODO_PREF_OPEN)); });
|
|
10583
|
+
const openMap = sOpenMap[0], setOpenMap = sOpenMap[1];
|
|
10584
|
+
// 筛选:默认只看未完成(旧文件里遗留的 `- [x]` 行要先点「全部」才出现)。
|
|
10585
|
+
const sFilter = react.useState(TODO_FILTER_OPEN); const filter = sFilter[0], setFilter = sFilter[1];
|
|
10196
10586
|
// 搜索:只过滤**显示**,绝不改文件;有查询时匹配的组强制展开,没匹配的组整组隐掉。
|
|
10197
10587
|
const sQuery = react.useState(""); const rawQuery = sQuery[0], setQuery = sQuery[1];
|
|
10198
10588
|
const query = String(rawQuery).trim().toLowerCase();
|
|
10589
|
+
// 检查点聚合(2.15.0,只读):老宿主没有 memory/checkpoints,读到就藏起来。
|
|
10590
|
+
const sCps = react.useState(null); const checkpoints = sCps[0], setCheckpoints = sCps[1];
|
|
10591
|
+
|
|
10592
|
+
/** 读一次检查点(宿主没这个方法就保持 null,界面上整块不出现)。 */
|
|
10593
|
+
const loadCheckpoints = react.useCallback(function () {
|
|
10594
|
+
if (!remote || typeof remote.checkpoints !== "function") return;
|
|
10595
|
+
Promise.resolve(remote.checkpoints()).then(function (res) {
|
|
10596
|
+
const data = unwrap(res);
|
|
10597
|
+
if (!data || data.ok === false) { setCheckpoints(null); return; }
|
|
10598
|
+
setCheckpoints(Array.isArray(data.tasks) ? data.tasks : []);
|
|
10599
|
+
}, function () { /* 读不到就不显示,别在清单旁边堆一条错误 */ });
|
|
10600
|
+
}, [remote]);
|
|
10601
|
+
|
|
10602
|
+
function toggleGroupPref(title, next) {
|
|
10603
|
+
const map = Object.assign({}, openMap);
|
|
10604
|
+
map[title] = next;
|
|
10605
|
+
setOpenMap(map);
|
|
10606
|
+
todoPrefSet(TODO_PREF_OPEN, todoOpenMapSerialize(map));
|
|
10607
|
+
}
|
|
10608
|
+
|
|
10609
|
+
/** 改撤销步数:写偏好 + 立刻把两份栈裁到新深度(否则旧的深栈还能退回去)。 */
|
|
10610
|
+
function changeDepth(n) {
|
|
10611
|
+
const next = todoClampUndoDepth(n);
|
|
10612
|
+
setUndoDepth(next);
|
|
10613
|
+
todoPrefSet(TODO_PREF_UNDO, String(next));
|
|
10614
|
+
setUndoStack(function (prev) { return prev.slice(-next); });
|
|
10615
|
+
setRedoStack(function (prev) { return prev.slice(-next); });
|
|
10616
|
+
}
|
|
10199
10617
|
|
|
10200
10618
|
/** 读一次文件。`quiet` = 轮询调用(出错不弹条,避免每 4 秒闪一次)。 */
|
|
10201
10619
|
const load = react.useCallback(function (quiet) {
|
|
@@ -10234,6 +10652,9 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10234
10652
|
return function () { clearInterval(id); };
|
|
10235
10653
|
}, [visible, enabled, load]);
|
|
10236
10654
|
|
|
10655
|
+
// 检查点聚合(只读):进页签读一次;点刷新再读(别的会话可能刚写过 WORKING.md)。
|
|
10656
|
+
react.useEffect(function () { loadCheckpoints(); }, [loadCheckpoints]);
|
|
10657
|
+
|
|
10237
10658
|
/**
|
|
10238
10659
|
* 一次写入:带上读到的 revision(盘上变了宿主回 stale_revision,我们只重读、不覆盖)。
|
|
10239
10660
|
* @param {string} label 回执文案(已翻译)
|
|
@@ -10257,7 +10678,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10257
10678
|
setErr(r.error || t("todo.err.write", { error: String(r.code || "error") }));
|
|
10258
10679
|
return;
|
|
10259
10680
|
}
|
|
10260
|
-
setUndoStack(function (prev) { return prev.concat([snapshot]).slice(-
|
|
10681
|
+
setUndoStack(function (prev) { return prev.concat([snapshot]).slice(-undoDepth); });
|
|
10261
10682
|
setRedoStack([]);
|
|
10262
10683
|
setNotice(out.degraded ? t("todo.notice.degraded") : label);
|
|
10263
10684
|
return load(false);
|
|
@@ -10332,13 +10753,75 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10332
10753
|
mutate(t("todo.notice.cleared", { count: out.count }), out.next);
|
|
10333
10754
|
}
|
|
10334
10755
|
|
|
10756
|
+
/**
|
|
10757
|
+
* 「搬进流水」:把待删除块里的条目搬进跨会话流水(2.15.0)。
|
|
10758
|
+
*
|
|
10759
|
+
* 两次写盘,顺序是刻意的:**先追加流水、再从清单删行**。反过来做,第二步失败就真丢条目;
|
|
10760
|
+
* 这样失败最多在流水里留一份重复,而重复由正文去重挡住(所以重试是安全的)。
|
|
10761
|
+
* 也正因为流水那半没法撤回,搬完**清空撤销栈** —— 留着一个「撤销」只会骗人。
|
|
10762
|
+
*/
|
|
10763
|
+
async function onArchive(section) {
|
|
10764
|
+
const items = (section && section.items) || [];
|
|
10765
|
+
if (items.length === 0) return;
|
|
10766
|
+
if (!remote || typeof remote.readRaw !== "function" || typeof remote.writeRaw !== "function") {
|
|
10767
|
+
setErr(t("todo.err.noArchive"));
|
|
10768
|
+
return;
|
|
10769
|
+
}
|
|
10770
|
+
const revision = doc.revision;
|
|
10771
|
+
const fileContent = doc.content;
|
|
10772
|
+
setBusy(true); setErr(null); setNotice("");
|
|
10773
|
+
let logged = 0;
|
|
10774
|
+
try {
|
|
10775
|
+
let content = "";
|
|
10776
|
+
let logRev = null;
|
|
10777
|
+
const log = unwrap(await remote.readRaw(TODO_LOG_FILE));
|
|
10778
|
+
if (log && log.ok === false) {
|
|
10779
|
+
// 新库还没有流水:当空文件起头。别的读失败照旧报(别把「读坏了」当成「还没有」)。
|
|
10780
|
+
if (!/missing|not.?found|enoent/i.test(String(log.code || ""))) {
|
|
10781
|
+
throw new Error(log.error || String(log.code || "error"));
|
|
10782
|
+
}
|
|
10783
|
+
} else {
|
|
10784
|
+
content = (log && log.content) || "";
|
|
10785
|
+
logRev = log && typeof log.revision === "string" ? log.revision : null;
|
|
10786
|
+
}
|
|
10787
|
+
const block = todoArchiveBlock(items, new Date(), todoLogKeys(content));
|
|
10788
|
+
if (block.count > 0) {
|
|
10789
|
+
const next = todoSessionLogAppend(content, block.text);
|
|
10790
|
+
const out = await remote.writeRaw(TODO_LOG_FILE, next, logRev ? { expectedRevision: logRev } : undefined);
|
|
10791
|
+
const r = out && (out.result || out);
|
|
10792
|
+
if (r && r.ok === false) throw new Error(r.error || String(r.code || "error"));
|
|
10793
|
+
logged = block.count;
|
|
10794
|
+
}
|
|
10795
|
+
const nextTodo = todoRemove(fileContent, items.map(function (it) { return it.line; }));
|
|
10796
|
+
const out2 = await writeWithFallback(remote, "writeFile", [TODO_FILE, nextTodo], revision ? { expectedRevision: revision } : undefined, null);
|
|
10797
|
+
const r2 = out2 && (out2.result || out2);
|
|
10798
|
+
if (r2 && r2.ok === false) {
|
|
10799
|
+
if (r2.code === "stale_revision") {
|
|
10800
|
+
setNotice(t("todo.notice.archiveStale", { count: logged }));
|
|
10801
|
+
await load(false);
|
|
10802
|
+
return;
|
|
10803
|
+
}
|
|
10804
|
+
throw new Error(r2.error || String(r2.code || "error"));
|
|
10805
|
+
}
|
|
10806
|
+
setUndoStack([]); setRedoStack([]);
|
|
10807
|
+
setNotice(logged > 0
|
|
10808
|
+
? t("todo.notice.archived", { count: logged, file: TODO_LOG_FILE })
|
|
10809
|
+
: t("todo.notice.archivedDup", { file: TODO_LOG_FILE }));
|
|
10810
|
+
await load(false);
|
|
10811
|
+
} catch (e) {
|
|
10812
|
+
setErr(t("todo.err.archive", { error: String((e && e.message) || e) }));
|
|
10813
|
+
} finally {
|
|
10814
|
+
setBusy(false);
|
|
10815
|
+
}
|
|
10816
|
+
}
|
|
10817
|
+
|
|
10335
10818
|
function onUndo() {
|
|
10336
10819
|
if (undoStack.length === 0) return;
|
|
10337
10820
|
const target = undoStack[undoStack.length - 1];
|
|
10338
10821
|
const point = currentPoint();
|
|
10339
10822
|
writeSnapshot(target, t("todo.notice.undo"), function () {
|
|
10340
10823
|
setUndoStack(function (prev) { return prev.slice(0, -1); });
|
|
10341
|
-
setRedoStack(function (prev) { return prev.concat([point]).slice(-
|
|
10824
|
+
setRedoStack(function (prev) { return prev.concat([point]).slice(-undoDepth); });
|
|
10342
10825
|
});
|
|
10343
10826
|
}
|
|
10344
10827
|
|
|
@@ -10348,7 +10831,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10348
10831
|
const point = currentPoint();
|
|
10349
10832
|
writeSnapshot(target, t("todo.notice.redone"), function () {
|
|
10350
10833
|
setRedoStack(function (prev) { return prev.slice(0, -1); });
|
|
10351
|
-
setUndoStack(function (prev) { return prev.concat([point]).slice(-
|
|
10834
|
+
setUndoStack(function (prev) { return prev.concat([point]).slice(-undoDepth); });
|
|
10352
10835
|
});
|
|
10353
10836
|
}
|
|
10354
10837
|
|
|
@@ -10361,22 +10844,36 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10361
10844
|
|
|
10362
10845
|
const parsed = doc && doc.parsed ? doc.parsed : parseTodoList("");
|
|
10363
10846
|
const missing = doc && doc.missing;
|
|
10847
|
+
// 两道过滤,顺序固定:先按「未完成 / 全部」筛条目,再按搜索词筛。都只影响**显示**。
|
|
10364
10848
|
// 匹配口径:标题 + 正文 + 续行里任一处包含子串(大小写不敏感;不解释正则,免得用户被自己的输入坑)。
|
|
10365
|
-
const
|
|
10849
|
+
const filtered = parsed.sections
|
|
10366
10850
|
.map(function (sec) {
|
|
10367
|
-
const
|
|
10851
|
+
const kept = todoFilterItems(sec.items, filter);
|
|
10852
|
+
const hit = query === "" ? kept : kept.filter(function (it) {
|
|
10368
10853
|
const hay = ((it.title || "") + " " + it.text + " " + (it.cont || "")).toLowerCase();
|
|
10369
10854
|
return hay.indexOf(query) >= 0;
|
|
10370
10855
|
});
|
|
10371
|
-
return { sec: sec, hit: hit };
|
|
10856
|
+
return { sec: sec, kept: kept, hit: hit };
|
|
10857
|
+
})
|
|
10858
|
+
.filter(function (row) {
|
|
10859
|
+
// 空组:搜索时整组隐掉;只筛「未完成」时,普通组没剩条目也隐掉
|
|
10860
|
+
// (否则一屏「▸ 组名 0 / 3」的空壳),待删除块例外 —— 见 todoFilterItems 的注释。
|
|
10861
|
+
if (row.sec.kind === "done") return true;
|
|
10862
|
+
if (row.hit.length > 0) return true;
|
|
10863
|
+
return row.sec.items.length === 0 && query === "";
|
|
10372
10864
|
})
|
|
10373
|
-
.filter(function (row) { return row.hit.length > 0; })
|
|
10374
10865
|
.map(function (row) { return Object.assign({}, row.sec, { items: row.hit }); });
|
|
10866
|
+
const sections = filtered;
|
|
10375
10867
|
const matchCount = sections.reduce(function (n, sec) { return n + sec.items.length; }, 0);
|
|
10376
10868
|
const stats = t("todo.stat", { open: parsed.open, done: parsed.done, sections: parsed.sections.length });
|
|
10377
10869
|
// 「清空全部」清的是整个待删除块,数字取块的真实条数(搜索过滤后也一样)。
|
|
10378
10870
|
const doneBlock = parsed.sections.find(function (sec) { return sec.kind === "done"; });
|
|
10379
10871
|
const doneBlockCount = doneBlock ? doneBlock.items.length : 0;
|
|
10872
|
+
// 检查点区块的条目总数(只读,来自 tasks/*/WORKING.md)。
|
|
10873
|
+
const cpTasks = (checkpoints || []).filter(function (task) {
|
|
10874
|
+
return task && Array.isArray(task.items) && task.items.length > 0;
|
|
10875
|
+
});
|
|
10876
|
+
const cpCount = cpTasks.reduce(function (n, task) { return n + task.items.length; }, 0);
|
|
10380
10877
|
|
|
10381
10878
|
return h("div", { className: "smem-todo" }, [
|
|
10382
10879
|
h("div", { key: "head", className: "smem-todo-head" }, [
|
|
@@ -10384,7 +10881,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10384
10881
|
h("span", { key: "sp", "data-spring": "" }),
|
|
10385
10882
|
h("button", {
|
|
10386
10883
|
key: "u", type: "button", className: "smem-todo-icon-btn",
|
|
10387
|
-
title: t("todo.action.
|
|
10884
|
+
title: t("todo.action.undoTitle", { depth: undoDepth }), "aria-label": t("todo.action.undo"),
|
|
10388
10885
|
disabled: busy || undoStack.length === 0,
|
|
10389
10886
|
onClick: onUndo,
|
|
10390
10887
|
}, todoArrowIcon("undo")),
|
|
@@ -10395,7 +10892,35 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10395
10892
|
onClick: onRedo,
|
|
10396
10893
|
}, todoArrowIcon("redo")),
|
|
10397
10894
|
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")),
|
|
10895
|
+
h("button", { key: "r", type: "button", className: "smem-link smem-todo-mini", disabled: busy, onClick: function () { load(false); loadCheckpoints(); } }, t("todo.refresh")),
|
|
10896
|
+
]),
|
|
10897
|
+
// 第二行:筛选 + 撤销步数。右栏很窄,搜索框单独一行。
|
|
10898
|
+
h("div", { key: "tools", className: "smem-todo-tools" }, [
|
|
10899
|
+
h("button", {
|
|
10900
|
+
key: "f1", type: "button",
|
|
10901
|
+
className: "smem-todo-mini smem-todo-filter" + (filter === TODO_FILTER_OPEN ? " smem-todo-filter-on" : ""),
|
|
10902
|
+
title: t("todo.filter.openTitle"), "aria-pressed": filter === TODO_FILTER_OPEN,
|
|
10903
|
+
onClick: function () { setFilter(TODO_FILTER_OPEN); },
|
|
10904
|
+
}, t("todo.filter.open")),
|
|
10905
|
+
h("button", {
|
|
10906
|
+
key: "f2", type: "button",
|
|
10907
|
+
className: "smem-todo-mini smem-todo-filter" + (filter === TODO_FILTER_ALL ? " smem-todo-filter-on" : ""),
|
|
10908
|
+
title: t("todo.filter.allTitle"), "aria-pressed": filter === TODO_FILTER_ALL,
|
|
10909
|
+
onClick: function () { setFilter(TODO_FILTER_ALL); },
|
|
10910
|
+
}, t("todo.filter.all")),
|
|
10911
|
+
h("span", { key: "sp2", "data-spring": "" }),
|
|
10912
|
+
h("label", { key: "dep", className: "smem-todo-depth" }, [
|
|
10913
|
+
h("span", { key: "l", className: "smem-todo-depth-label" }, t("todo.undoDepth.label")),
|
|
10914
|
+
h("select", {
|
|
10915
|
+
key: "sel",
|
|
10916
|
+
className: "smem-input smem-todo-depth-select",
|
|
10917
|
+
value: String(undoDepth),
|
|
10918
|
+
disabled: busy,
|
|
10919
|
+
onChange: function (e) { changeDepth(e.target.value); },
|
|
10920
|
+
}, [TODO_UNDO_MIN, TODO_UNDO_MIN + 1, TODO_UNDO_MAX].map(function (n) {
|
|
10921
|
+
return h("option", { key: "o" + n, value: String(n) }, t("todo.undoDepth.option", { n: n }));
|
|
10922
|
+
})),
|
|
10923
|
+
]),
|
|
10399
10924
|
]),
|
|
10400
10925
|
// 搜索框放统计条下面一行:右栏很窄,塞进同一行会把按钮挤没。
|
|
10401
10926
|
h("div", { key: "search", className: "smem-todo-search-row" }, [
|
|
@@ -10411,6 +10936,9 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10411
10936
|
]),
|
|
10412
10937
|
err ? h("div", { key: "err", className: "smem-err" }, "⚠ " + err) : null,
|
|
10413
10938
|
notice ? h("div", { key: "ok", className: "smem-ok" }, "✓ " + notice) : null,
|
|
10939
|
+
cpCount > 0
|
|
10940
|
+
? h(TodoCheckpointBlock, { key: "cp", tasks: cpTasks, count: cpCount })
|
|
10941
|
+
: null,
|
|
10414
10942
|
missing
|
|
10415
10943
|
? h("div", { key: "miss", className: "smem-todo-empty" }, t("todo.empty.file", { file: TODO_FILE }))
|
|
10416
10944
|
: (query !== "" && sections.length === 0
|
|
@@ -10419,8 +10947,11 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10419
10947
|
return h(TodoSectionGroup, {
|
|
10420
10948
|
key: "s" + i, section: sec, busy: busy, allOpen: query === "" ? allOpen : true,
|
|
10421
10949
|
doneCount: doneBlockCount,
|
|
10950
|
+
openMap: openMap,
|
|
10951
|
+
onGroupToggle: toggleGroupPref,
|
|
10422
10952
|
onToggle: function (it, d) { onToggle(it, d, sec.title); },
|
|
10423
|
-
onAdd: onAdd, onEdit: onEdit, onDelete: onDelete,
|
|
10953
|
+
onAdd: onAdd, onEdit: onEdit, onDelete: onDelete,
|
|
10954
|
+
onClearDone: onClearDone, onArchive: onArchive,
|
|
10424
10955
|
});
|
|
10425
10956
|
}))),
|
|
10426
10957
|
]);
|
|
@@ -10590,9 +11121,26 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
10590
11121
|
// 只给 `test/todo-board-test.mjs` 用,运行期没有任何代码读它(宿主只认 apply / inject)。
|
|
10591
11122
|
exports.todoBoardInternals = {
|
|
10592
11123
|
FILE: TODO_FILE,
|
|
11124
|
+
LOG_FILE: TODO_LOG_FILE,
|
|
10593
11125
|
TAB_KIND: TODO_TAB_KIND,
|
|
10594
11126
|
DONE_HEADING: TODO_DONE_HEADING,
|
|
10595
|
-
|
|
11127
|
+
UNDO_MIN: TODO_UNDO_MIN,
|
|
11128
|
+
UNDO_MAX: TODO_UNDO_MAX,
|
|
11129
|
+
UNDO_DEFAULT: TODO_UNDO_DEFAULT,
|
|
11130
|
+
FILTER_OPEN: TODO_FILTER_OPEN,
|
|
11131
|
+
FILTER_ALL: TODO_FILTER_ALL,
|
|
11132
|
+
PREF_UNDO: TODO_PREF_UNDO,
|
|
11133
|
+
PREF_OPEN: TODO_PREF_OPEN,
|
|
11134
|
+
clampDepth: todoClampUndoDepth,
|
|
11135
|
+
filterItems: todoFilterItems,
|
|
11136
|
+
groupKey: todoGroupKey,
|
|
11137
|
+
openMapParse: todoOpenMapParse,
|
|
11138
|
+
openMapSerialize: todoOpenMapSerialize,
|
|
11139
|
+
logKey: todoLogKey,
|
|
11140
|
+
logKeys: todoLogKeys,
|
|
11141
|
+
stamp: todoStamp,
|
|
11142
|
+
archiveBlock: todoArchiveBlock,
|
|
11143
|
+
logAppend: todoSessionLogAppend,
|
|
10596
11144
|
parse: parseTodoList,
|
|
10597
11145
|
titleOf: todoItemTitle,
|
|
10598
11146
|
bullet: todoBullet,
|