dsh-zdiary-kit 3.14.1 → 3.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.
@@ -15,7 +15,7 @@ import { configFor, pinSession, sessionNotebook, sessionState } from '../../conf
15
15
  import { defaultNotebook, expandHome, processWorkspace, resolveInWorkspace } from '../../config/paths.js';
16
16
  import { S, validateArgs } from '../../lib/tool.js';
17
17
  import { ensureNotebook, newNoteDir } from '../../lib/notebook.js';
18
- import { searchNotes, searchNotesDetailed, createNote, appendToNote, ensureDailyNote, appendDaily, linkNotes, withTags, taglessCjkWarning, notebookStats, supersedeNote, renameNote, hasNotebook, isUnderDir, localDate as dateOnly, runAlias, hasCjk, walkFrom, scanNotes, ZkError, } from '../../lib/zk.js';
18
+ import { searchNotes, searchNotesDetailed, createNote, appendToNote, ensureDailyNote, appendDaily, linkNotes, taglessCjkWarning, notebookStats, supersedeNote, renameNote, hasNotebook, isUnderDir, localDate as dateOnly, runAlias, hasCjk, walkFrom, scanNotes, ZkError, } from '../../lib/zk.js';
19
19
  import { configuredAliases, readAliases } from '../../lib/alias.js';
20
20
  import { buildMemoryPayload, memoryCapacity, META_FILES } from '../../lib/memory.js';
21
21
  import { assembleRecall } from '../../lib/recall.js';
@@ -26,7 +26,7 @@ import { bumpRecall } from '../../lib/recall-signal.js';
26
26
  import { wikiIndex } from '../../lib/wikilink.js';
27
27
  import { writeMemory } from '../../lib/memory-write.js';
28
28
  import { META_NAMES } from '../../lib/meta.js';
29
- import { formatLintExtras, formatMemoryLinks, lintNotebook } from '../../lib/lint.js';
29
+ import { formatLintExtras, formatMemoryLinks, formatOneWay, lintNotebook } from '../../lib/lint.js';
30
30
  import { dreamNotebook, STALE_DAYS } from '../../lib/dream.js';
31
31
  const text = (value) => [{ type: 'text', text: value }];
32
32
  /** render 的 args 是 unknown:只取 query 判断要不要给中文 0 命中提示(R7) */
@@ -77,10 +77,21 @@ const LINT_ONE_WAY = objSchema({
77
77
  edges: { type: 'number' },
78
78
  bodyOnly: { type: 'number' },
79
79
  linksOnly: { type: 'boolean' },
80
+ provenance: objSchema({ targets: { type: 'number' }, edges: { type: 'number' } }, ['targets', 'edges']),
81
+ includeProvenance: { type: 'boolean' },
82
+ byType: {
83
+ type: 'array',
84
+ items: objSchema({
85
+ from: { type: 'string' },
86
+ to: { type: 'string' },
87
+ edges: { type: 'number' },
88
+ }, ['from', 'to', 'edges']),
89
+ },
80
90
  edgesTruncated: { type: 'boolean' },
91
+ itemsTruncated: { type: 'boolean' },
81
92
  completeness: { type: 'string', enum: ['complete', 'partial', 'unknown'] },
82
93
  items: { type: 'array', items: LINT_ONE_WAY_ITEM },
83
- }, ['total', 'edges', 'bodyOnly', 'linksOnly', 'edgesTruncated', 'completeness', 'items']);
94
+ }, ['total', 'edges', 'bodyOnly', 'linksOnly', 'provenance', 'includeProvenance', 'byType', 'edgesTruncated', 'itemsTruncated', 'completeness', 'items']);
84
95
  const LINT_STALE = objSchema({
85
96
  total: { type: 'number' },
86
97
  items: {
@@ -95,7 +106,7 @@ const LINT_DUPLICATE = objSchema({
95
106
  items: objSchema({ title: { type: 'string' }, paths: { type: 'array', items: { type: 'string' } } }, ['title', 'paths']),
96
107
  },
97
108
  }, ['total', 'items']);
98
- /** 疑似重复标题(P2-10):只差一两个字 */
109
+ /** 疑似重复标题:只差一两个字 */
99
110
  const LINT_SIMILAR = objSchema({
100
111
  total: { type: 'number' },
101
112
  truncated: { type: 'boolean' },
@@ -196,7 +207,33 @@ const LINT_EMPTY_SECTIONS = objSchema({
196
207
  }, ['path', 'title', 'empty']),
197
208
  },
198
209
  }, ['scanned', 'skipped', 'notes', 'total', 'truncated', 'items']);
199
- /** frontmatter 缺字段(P2-13) */
210
+ /** 正文重复标签:整段只有 #tag、frontmatter 已覆盖(只报告;zk-kit tidy --fix 收掉) */
211
+ const LINT_BODY_TAGS = objSchema({
212
+ scanned: { type: 'number' },
213
+ skipped: { type: 'number' },
214
+ notes: { type: 'number' },
215
+ paragraphs: { type: 'number' },
216
+ driftNotes: { type: 'number' },
217
+ truncated: { type: 'boolean' },
218
+ items: {
219
+ type: 'array',
220
+ items: objSchema({
221
+ path: { type: 'string' },
222
+ title: { type: 'string' },
223
+ paragraphs: { type: 'number' },
224
+ tags: { type: 'array', items: { type: 'string' } },
225
+ }, ['path', 'title', 'paragraphs', 'tags']),
226
+ },
227
+ drift: {
228
+ type: 'array',
229
+ items: objSchema({
230
+ path: { type: 'string' },
231
+ title: { type: 'string' },
232
+ tags: { type: 'array', items: { type: 'string' } },
233
+ }, ['path', 'title', 'tags']),
234
+ },
235
+ }, ['scanned', 'skipped', 'notes', 'paragraphs', 'driftNotes', 'truncated', 'items', 'drift']);
236
+ /** frontmatter 缺字段 */
200
237
  const LINT_INCOMPLETE = objSchema({
201
238
  total: { type: 'number' },
202
239
  truncated: { type: 'boolean' },
@@ -213,7 +250,7 @@ const LINT_INCOMPLETE = objSchema({
213
250
  }, ['path', 'missing']),
214
251
  },
215
252
  }, ['total', 'truncated', 'byField', 'items']);
216
- /** 标签卫生(P2-14) */
253
+ /** 标签卫生 */
217
254
  const LINT_TAGS = objSchema({
218
255
  total: { type: 'number' },
219
256
  reported: { type: 'boolean' },
@@ -229,10 +266,32 @@ const LINT_TAGS = objSchema({
229
266
  }, ['total', 'items']),
230
267
  singletons: objSchema({
231
268
  total: { type: 'number' },
232
- items: { type: 'array', items: { type: 'string' } },
269
+ items: {
270
+ type: 'array',
271
+ items: objSchema({
272
+ tag: { type: 'string' },
273
+ suggest: {
274
+ type: 'array',
275
+ items: objSchema({
276
+ tag: { type: 'string' },
277
+ count: { type: 'number' },
278
+ kind: { type: 'string', enum: ['case', 'similar'] },
279
+ }, ['tag', 'count', 'kind']),
280
+ },
281
+ }, ['tag', 'suggest']),
282
+ },
233
283
  }, ['total', 'items']),
234
284
  }, ['total', 'reported', 'caseVariants', 'singletons']);
235
- /** 模板版本(P2-15) */
285
+ /** INDEX.md 规模行漂移(只核对,不生成) */
286
+ const LINT_INDEX = objSchema({
287
+ present: { type: 'boolean' },
288
+ claimedNotes: { type: 'number' },
289
+ claimedDate: { type: 'string' },
290
+ actualNotes: { type: 'number' },
291
+ ageDays: { type: 'number' },
292
+ drifted: { type: 'boolean' },
293
+ }, ['present', 'actualNotes', 'drifted']);
294
+ /** 模板版本 */
236
295
  const LINT_TEMPLATE = objSchema({
237
296
  present: { type: 'boolean' },
238
297
  version: { type: 'number' },
@@ -241,7 +300,16 @@ const LINT_TEMPLATE = objSchema({
241
300
  mismatch: { type: 'boolean' },
242
301
  mismatchDetail: { type: 'string' },
243
302
  currentText: { type: 'string' },
244
- }, ['present', 'version', 'current', 'stale']);
303
+ workflow: objSchema({
304
+ present: { type: 'boolean' },
305
+ version: { type: 'number' },
306
+ current: { type: 'number' },
307
+ stale: { type: 'boolean' },
308
+ legacyMark: { type: 'boolean' },
309
+ detail: { type: 'string' },
310
+ currentText: { type: 'string' },
311
+ }, ['present', 'version', 'current', 'stale']),
312
+ }, ['present', 'version', 'current', 'stale', 'workflow']);
245
313
  /** 人格体检:缺失 / 旧版 / 比插件新 / 标记与内容不符 / 未填占位符(只报告,不覆盖) */
246
314
  const LINT_PERSONA = objSchema({
247
315
  total: { type: 'number' },
@@ -432,12 +500,9 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
432
500
  const builtins = [
433
501
  t({
434
502
  name: 'zk_search',
435
- description: '在 zk 知识库里搜索笔记(全文 / 标签 / 日期 / 断链 / 孤立笔记),返回标题、相对路径、绝对路径、标签、创建日、摘要与命中片段。' +
503
+ description: '在 zk 知识库里搜索笔记(全文 / 标签 / 日期 / 断链 / 孤立笔记),返回标题、路径、absPath、摘要与命中片段。' +
436
504
  '找到后用原生 read 读全文:notes[].absPath 可以直接传给 read。写笔记前先用它查重。' +
437
- '中文会自动并用子串,多词按覆盖度合并(FTS 不切中文):matchStrategy 说明这次用了 fts / regex / mixed,mixed 表示补到了全文索引漏掉的笔记。' +
438
- '有 query 时默认按 FTS 相关性排序,显式给 sort 才改顺序。' +
439
- '结果还带 entryPoints(MEMORY 的活条目:via=query 表示这条结论跟查询有关,来源可以不在本次结果里)' +
440
- '与 counterEntries(归档里同名旧结论 + 废弃原因,先看它别把废掉的结论重新提出来)。',
505
+ '归档里同名旧结论会一并返回,先看它,别把废掉的结论重新提出来。',
441
506
  parameters: {
442
507
  type: 'object',
443
508
  properties: {
@@ -551,10 +616,8 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
551
616
  }),
552
617
  t({
553
618
  name: 'zk_query',
554
- description: '结构化检索记忆:按 type(daily/source/concept/entity/pattern)、status(active/superseded)、标签、目录、日期、断链、孤立过滤。' +
555
- '默认只看 active 且不含归档;传 include_archived: true 会连归档一起查,此时未显式给 status 就不再默认过滤 active。' +
556
- '中文会自动并用子串,多词按覆盖度合并;有 query 时默认按 FTS 相关性排序。' +
557
- '这是查「记忆里有什么」的主入口。entryPoints / counterEntries 与 zk_search 同口径。',
619
+ description: '结构化检索记忆:按 type / status / 标签 / 目录 / 日期 / 断链 / 孤立过滤。' +
620
+ '默认只看 active 且不含归档;传 include_archived: true 会连归档一起查,此时未显式给 status 就不再默认过滤 active。',
558
621
  parameters: {
559
622
  type: 'object',
560
623
  properties: {
@@ -694,10 +757,8 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
694
757
  }),
695
758
  t({
696
759
  name: 'zk_recall',
697
- description: '召回装配:先按 query / 过滤条件检索(与 zk_search 同一套 R1–R3),再按词数预算把命中笔记拼成一段可直接读的上下文。' +
698
- '每条带标题、路径、absPath 与全文词数,放不下就整条丢弃、不切半句;需要全文仍用原生 read 读 absPath。' +
699
- 'budget 按 countWords 口径(中文 2 字 1 词),used 一定不超过 budget。' +
700
- '不做语义判断 / 重排 / 跨回合去重;completeness 沿用检索三态,装配过的 ≠ 全部命中。',
760
+ description: '召回装配:先按 query / 过滤条件检索,再按词数预算把命中笔记拼成一段可直接读的上下文。' +
761
+ '放不下就整条丢弃、不切半句;需要全文仍用原生 read 读 absPath。',
701
762
  parameters: {
702
763
  type: 'object',
703
764
  properties: {
@@ -804,11 +865,8 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
804
865
  }),
805
866
  t({
806
867
  name: 'zk_walk',
807
- description: '从一篇笔记出发走一跳邻居(只读):direction=both 同时看反链与出链,in=谁链到它,out=它链到谁。' +
808
- '种子写相对笔记本的路径、绝对路径,或精确标题 / 稳定 id([[标题]] / [[id]] 也认);不精确命中就返回空,不会退回全库。' +
809
- '按篇反查、不建全图,成本与库规模基本无关;limit 硬顶 200,触顶 completeness=partial(邻居没列全,不代表没有)。' +
810
- '每条邻居带 section / linkLine:那条边所在的小节与那一行 —— 没有它,同一篇种子的出链只有一串标题。' +
811
- '只回标题 / 路径 / absPath / 摘要 / 那一行,全文仍用原生 read 读 absPath;不改标题、不自动 link、不写任何文件。',
868
+ description: '从一篇笔记出发走一跳邻居(只读):direction 选反链 / 出链 / 双向。' +
869
+ '种子不精确命中就返回空,不会退回全库;全文仍用原生 read 读 absPath。',
812
870
  parameters: {
813
871
  type: 'object',
814
872
  properties: {
@@ -838,7 +896,7 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
838
896
  absPath: { type: 'string' },
839
897
  relation: { type: 'string', enum: ['in', 'out'] },
840
898
  lead: { type: 'string' },
841
- /** 这条边所在的 `##` / `###` 小节;找不到时键不出现(plan §14.1) */
899
+ /** 这条边所在的 `##` / `###` 小节;找不到时键不出现 */
842
900
  section: { type: 'string' },
843
901
  /** 这条边的那一行(压空白、截 160 码点):没有它,同一篇种子的出链长得一模一样 */
844
902
  linkLine: { type: 'string' },
@@ -897,19 +955,12 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
897
955
  }),
898
956
  t({
899
957
  name: 'zk_new',
900
- description: '新建一篇笔记(zk 负责生成文件名、套用模板、写入索引)。适合记下一个概念、决定、来源或想法;' +
901
- '写前先 zk_search 查重。标题重复会直接报错(flat 按标题查重,layered 同目录同名 slug 也会被 zk 拒绝)。' +
902
- 'layered 的文件名默认来自标题({{slug title}}):中文标题会生成很长的拼音文件名。' +
903
- 'layered 不给 dir 就按 type 落到 notes/sources 之类;两者都没有、或给的 dir 不在任何 group 里都会报错,' +
904
- '不会默默建到 notes/ 根(那里不套模板,没有 frontmatter,文件名是随机 id)。' +
905
- '要短文件名就传 name(8–14 字中文短语 / 英文小写短横线名):只换文件名,标题和正文一个字不动。' +
906
- '归档里有同名旧结论不会拦,但会放进 archived(带 supersede-reason):先读它,别把同一个错误结论重新提出来。' +
907
- 'type / authority 只有 layered 模板会写进 frontmatter。tags 会写成 #hashtag;links 里的目标会被追加成 wiki 双链。' +
908
- '中文笔记如果没有任何标签(入参 / 默认值 / 正文 hashtag 都没有),会在 tagWarning 里提示 —— 只提示,不阻断。' +
909
- '同目录里有「改一两个字」的相似标题时会放进 similar(带分数):只提示,不阻断,也不自动建链接。' +
910
- '正文以 ## 开头时,模板的 ## Content 会变成空壳(内容落在它后面):返回值 emptyTemplateSections 会点名,' +
911
- '只提示、不改正文 —— 把正文并进那一节,或删掉那行空标题。' +
912
- '根目录 meta 文件(AGENTS / USER / MEMORY 等)与 raw/ 不能写:前者会被当成人写的工作面,后者会被排除出索引。',
958
+ description: '新建一篇笔记(zk 生成文件名、套模板、写索引)。写前先 zk_search 查重,标题重复会直接报错。' +
959
+ 'layered 不给 dir 就按 type 落到 notes/sources 之类;两者都没有、或 dir 不在任何 group 里都会报错,不会默默建到 notes/ 根。' +
960
+ '中文标题默认生成很长的拼音文件名;要短文件名传 name(8–14 字中文短语 / 英文小写短横线名),只换文件名、不动标题正文。' +
961
+ 'tags 写成 #hashtag;links 里的目标追加成 wiki 双链。' +
962
+ '归档里有同名旧结论不会拦但会一并返回:先读它,别把同一个错误结论重新提出来。' +
963
+ '根目录 meta 文件与 raw/ 不能写。',
913
964
  parameters: {
914
965
  type: 'object',
915
966
  properties: {
@@ -917,7 +968,7 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
917
968
  name: S.str('文件名(不含扩展名,也不要带目录);不给就由 zk 按标题生成。中文标题建议给一个短名,否则是长拼音'),
918
969
  body: S.str('正文 Markdown(可空)。会插在模板的 {{content}} 位置(layered 下在 ## Content 之下、## Links 之前):不要自己再写 ## Content / ## Summary 这类模板小节,会多出重复标题'),
919
970
  summary: S.str('一句话摘要(填进模板的 ## Summary;正文里已经写了这一节就不动)'),
920
- tags: S.arr('标签(不写 #)。与设置里的默认标签合并;正文里已经写过的标签不会再追加一行', S.str('标签名')),
971
+ tags: S.arr('标签(不写 #)。与设置里的默认标签合并;模板有 frontmatter tags 格就写那一格(layered),没有才追加正文 hashtag 行;与库里已有标签近义时在 tagHints 里提示', S.str('标签名')),
921
972
  dir: S.str('放到哪个子目录(相对笔记本)。flat 默认 notesDir;layered 必须落在某个 group(notes/sources 等,子目录也行),不给就按 type 落位;两者都没有、或不在 group 里都会报错'),
922
973
  type: S.enum('笔记类型(写进 frontmatter;layered 结构下决定模板的分节,不给 dir 时也决定目录)', ['source', 'concept', 'entity', 'pattern']),
923
974
  authority: S.enum('可信度(写进 frontmatter,给未来的自己判断该不该引用)', ['official', 'expert', 'informal']),
@@ -939,6 +990,15 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
939
990
  summaryWarning: { type: 'string' },
940
991
  emptyTemplateSections: { type: 'array', items: { type: 'string' } },
941
992
  tagWarning: { type: 'string' },
993
+ tagHints: {
994
+ type: 'array',
995
+ items: objSchema({
996
+ input: { type: 'string' },
997
+ tag: { type: 'string' },
998
+ count: { type: 'number' },
999
+ kind: { type: 'string', enum: ['case', 'similar'] },
1000
+ }, ['input', 'tag', 'count', 'kind']),
1001
+ },
942
1002
  archived: {
943
1003
  type: 'array',
944
1004
  items: objSchema({
@@ -961,20 +1021,24 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
961
1021
  async run(args, env) {
962
1022
  const cfg = configFor(env.workspace, env.sessionId);
963
1023
  await ensureNotebook(cfg, env.signal);
964
- const tags = [...new Set([...(cfg.defaultTags ?? []), ...(Array.isArray(args.tags) ? args.tags.map(String) : [])])];
1024
+ // 标签只留名字:前导 # 去掉、去空、去重(写进 frontmatter 的那份必须是同一个形状)
1025
+ const tags = [...new Set([...(cfg.defaultTags ?? []), ...(Array.isArray(args.tags) ? args.tags.map(String) : [])]
1026
+ .map((t) => t.trim().replace(/^#+/, ''))
1027
+ .filter(Boolean))];
965
1028
  const type = args.type ? String(args.type) : undefined;
966
1029
  const title = String(args.title);
967
1030
  const body = args.body ? String(args.body) : '';
968
- const content = withTags(body, tags);
1031
+ // 标签交给 createNote 落位:模板有 frontmatter `tags` 格就写那一格,没有才追加正文 hashtag 行
969
1032
  const created = await createNote(cfg, {
970
1033
  title,
971
1034
  name: args.name ? String(args.name) : undefined,
972
1035
  summary: args.summary ? String(args.summary) : undefined,
973
- content,
1036
+ content: body,
974
1037
  dir: newNoteDir(cfg, { dir: args.dir ? String(args.dir) : undefined, type }),
975
1038
  group: args.group ? String(args.group) : undefined,
976
1039
  type,
977
1040
  authority: args.authority ? String(args.authority) : undefined,
1041
+ tags,
978
1042
  }, env.signal);
979
1043
  const links = [];
980
1044
  const warnings = [];
@@ -988,8 +1052,8 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
988
1052
  warnings.push(`${target}:${err instanceof Error ? err.message : String(err)}`);
989
1053
  }
990
1054
  }
991
- // 中文没标签:写路径是唯一便宜的修复点(P2-9)。只提示,不阻断。
992
- const tagWarning = taglessCjkWarning(title, content, tags);
1055
+ // 中文没标签:写路径是唯一便宜的修复点。只提示,不阻断。
1056
+ const tagWarning = taglessCjkWarning(title, body, tags);
993
1057
  // 归档同名只是提醒:zk_new 的查重本来就不含 archive,允许复用标题 —— 但要把废弃原因一起交出来
994
1058
  // (createNote 建之前那次全库扫描已经算好了,这里不再单独跑一次 zk)
995
1059
  const archived = created.archived;
@@ -1001,6 +1065,7 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1001
1065
  ...(created.similar.length ? { similar: created.similar } : {}),
1002
1066
  ...(created.summaryWarning ? { summaryWarning: created.summaryWarning } : {}),
1003
1067
  ...(created.emptyTemplateSections.length ? { emptyTemplateSections: created.emptyTemplateSections } : {}),
1068
+ ...(created.tagHints.length ? { tagHints: created.tagHints } : {}),
1004
1069
  ...(tagWarning ? { tagWarning } : {}),
1005
1070
  };
1006
1071
  },
@@ -1017,8 +1082,10 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1017
1082
  lines.push('⚠️ 模板小节空着:' + v.emptyTemplateSections.join('、') +
1018
1083
  ' —— 正文以 ## 开头,内容落在了它后面;把正文并进那一节,或删掉那行空标题(zk_lint 的「空模板小节」会复查)');
1019
1084
  }
1020
- if (v.tagWarning)
1021
- lines.push('⚠️ ' + v.tagWarning);
1085
+ if (v.tagHints?.length) {
1086
+ lines.push('⚠️ 标签近义:' + v.tagHints.map((h) => `${h.kind === 'case' ? '大小写变体' : '近义'}:#${h.input} ≈ #${h.tag}(${h.count} 篇)`).join('、') +
1087
+ ' —— 确认是不是同一个标签;要统一就改这一篇的 tags');
1088
+ }
1022
1089
  if (v.similar?.length) {
1023
1090
  lines.push('⚠️ 疑似已有:' + v.similar.map((s) => `${s.title}(${s.path},${s.score.toFixed(2)})`).join('、') +
1024
1091
  ' —— 先 read 确认是不是同一条;要合并就 zk_supersede,不要直接再写一遍');
@@ -1112,7 +1179,7 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1112
1179
  }),
1113
1180
  t({
1114
1181
  name: 'zk_link',
1115
- description: '在两篇笔记之间建立 wiki 双链:把 [[目标]] 追加到来源笔记末尾(已有「Links」或「链接」小节就不再重复起标题;不保证插进该小节内部),已存在不重复添加。' +
1182
+ description: '在两篇笔记之间建立 wiki 双链:把 [[目标]] 追加到来源笔记末尾,已存在不重复添加。' +
1116
1183
  '目标可以给相对路径,也可以给标题;根目录 meta 文件不作为来源或目标。',
1117
1184
  parameters: {
1118
1185
  type: 'object',
@@ -1145,10 +1212,10 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1145
1212
  }),
1146
1213
  t({
1147
1214
  name: 'zk_supersede',
1148
- description: '废弃一篇笔记:frontmatter 标 superseded、写入替代它的笔记、把能精确匹配的 [[旧路径]] 入链改到归档路径、再把文件搬进 archive/(保留原相对路径;其它写法的入链列进 missingLinks)。' +
1149
- '默认 dry_run: true,只返回受影响清单;确认后传 dry_run: false 才真改。结论变了(不是删掉,是过时)时用它。' +
1150
- 'reason 会写进归档 frontmatter 的 supersede-reason:下次有人建同名笔记时会被带出来,防止同一个错误结论被重新提出。' +
1151
- '根目录 meta 文件不能废弃(否则会把 MEMORY.md 之类搬进 archive/)。',
1215
+ description: '废弃一篇笔记:标 superseded、写入替代它的笔记、把入链改到归档路径、搬进 archive/。' +
1216
+ '默认 dry_run: true,只返回受影响清单;确认后传 dry_run: false 才真改。' +
1217
+ 'reason 会写进归档 frontmatter:下次建同名笔记时会被带出来,防止同一个错误结论被重新提出。' +
1218
+ '根目录 meta 文件不能废弃。',
1152
1219
  parameters: {
1153
1220
  type: 'object',
1154
1221
  properties: {
@@ -1184,7 +1251,7 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1184
1251
  path: String(args.path),
1185
1252
  by: args.by ? String(args.by) : undefined,
1186
1253
  reason: args.reason ? String(args.reason) : undefined,
1187
- // 缺省是预演:一句「更新一下 wiki」不该让全库漂移(计划 D7)
1254
+ // 缺省是预演:一句「更新一下 wiki」不该让全库漂移
1188
1255
  dryRun: args.dry_run !== false,
1189
1256
  }, env.signal);
1190
1257
  return {
@@ -1235,9 +1302,9 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1235
1302
  }),
1236
1303
  t({
1237
1304
  name: 'zk_rename',
1238
- description: '给笔记改名 / 换目录,并修好改名带来的断链:入链([[…]] 与 Markdown 链接,保留 #锚点 与 |别名)按实际解析结果改到新路径,' +
1239
- '根目录 meta 文件与归档笔记里的 [[来源]] 一起改;被搬走那篇自己的相对链接也会按新位置重算。认不出的写法列进 missingLinks,不猜。' +
1240
- '默认 dry_run: true,只返回受影响清单;确认后传 dry_run: false 才真改。改名后 zk_daily 的日记、archive/ 里的笔记、raw/ 与 meta 文件都不许动。',
1305
+ description: '给笔记改名 / 换目录,并修好改名带来的断链(入链、根目录 meta 文件与归档笔记里的来源)。' +
1306
+ '默认 dry_run: true,只返回受影响清单;确认后传 dry_run: false 才真改。' +
1307
+ '改名后 zk_daily 的日记、archive/ 里的笔记、raw/ 与 meta 文件都不许动。',
1241
1308
  parameters: {
1242
1309
  type: 'object',
1243
1310
  properties: {
@@ -1310,12 +1377,8 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1310
1377
  }),
1311
1378
  t({
1312
1379
  name: 'zk_context',
1313
- description: '读知识库根目录的长期约定与记忆(AGENTS.md / USER.md / MEMORY.md),按注入预算截断后返回;' +
1314
- '角色人格(PERSONA.md)单独成段、在记忆段之前、不参与截断。' +
1315
- '同时列出已配置的笔记本(名字 / 路径 / 结构 / 当前)。' +
1316
- '改 MEMORY.md 之前用它看余量:headroom / wouldTruncate / dropCandidates 说明「再加一条会丢谁」,' +
1317
- '给 proposed_entry 或 extra_words 就能预估;同日条目按位置决胜(sameDateCount)。' +
1318
- 'orderDebt 报「新条目没写顶部 / 最旧并列」的位置债,只报告不改条目。' +
1380
+ description: '读知识库根目录的长期约定与记忆(AGENTS.md / USER.md / MEMORY.md),按注入预算截断后返回,并列出已配置的笔记本。' +
1381
+ '改 MEMORY.md 之前用它看余量;给 proposed_entry 或 extra_words 就能预估。' +
1319
1382
  '宿主支持注入时这些内容每轮已自动进入系统提示;宿主不支持、或想核对「被截断了多少」时用它。',
1320
1383
  parameters: {
1321
1384
  type: 'object',
@@ -1336,7 +1399,7 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1336
1399
  tocWords: { type: 'number' },
1337
1400
  totalWords: { type: 'number' },
1338
1401
  overheadWords: { type: 'number' },
1339
- // G1 / G4:写 MEMORY 前的容量(纯增量字段,旧客户端只是多看到几列)
1402
+ // 写 MEMORY 前的容量(纯增量字段,旧客户端只是多看到几列)
1340
1403
  retiredEntries: { type: 'number' },
1341
1404
  headroom: { type: 'number' },
1342
1405
  extraWords: { type: 'number' },
@@ -1439,7 +1502,7 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1439
1502
  ? `笔记本「${current.name}」(${current.structure})→ ${current.path}` +
1440
1503
  (others.length ? `\n另有:${others.map((n) => `${n.name}(${n.structure})`).join('、')} —— zk_use 切换本会话` : '')
1441
1504
  : `笔记本「${v.notebook}」`;
1442
- // G1 / G4:写 MEMORY 前的余量、是否触发截断、同日决胜与「下一条会丢谁」
1505
+ // 写 MEMORY 前的余量、是否触发截断、同日决胜与「下一条会丢谁」
1443
1506
  const capacity = `\n\n容量:余 ${v.headroom} 词(记忆内容 ${v.words}/${v.budget},总载荷 ${v.totalWords})` +
1444
1507
  (v.extraWords > 0 ? ` · 拟新增 ${v.extraWords} 词${v.wouldTruncate ? '(会触发截断)' : ''}` : '') +
1445
1508
  (v.sameDateCount > 1 ? ` · ${v.sameDateCount} 条同日,按位置决胜` : '') +
@@ -1463,13 +1526,9 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1463
1526
  }),
1464
1527
  t({
1465
1528
  name: 'zk_memory_write',
1466
- description: '写记忆的第一个工具:往 MEMORY.md / USER.md 末尾追加一条结论。默认 dry_run: true,只预演、不动盘;' +
1467
- '确认后传 dry_run: false 才真写(可把预演返回的 stamp 放进 expect_stamp,挡住「预演之后有人改过」)。' +
1468
- '调用方给完整条目正文,插件只做机械门:必须是一条带 YYYY-MM-DD 与 [[来源]] 的顶层列表项、来源要解析到活笔记、' +
1469
- '新增不能让注入载荷超预算(超了给结构化错误 + dropCandidates,绝不静默截断)。' +
1470
- 'action: retire 追加 `- [superseded …]` 标记(退役条目不进注入,不做容量门)。' +
1471
- '不替换、不合并、不自动补日期 / 来源、不提议退役哪条 —— 语义判断全归调用方;' +
1472
- '每次真实写入把 pre-image 摘要与一行 diff 追加到 DREAMS.md 供周审复核。' +
1529
+ description: '往 MEMORY.md / USER.md 末尾追加一条结论。默认 dry_run: true,只预演、不动盘;确认后传 dry_run: false 才真写。' +
1530
+ '调用方给完整条目正文,插件只做机械门:必须是一条带 YYYY-MM-DD 与 [[来源]] 的顶层列表项、来源要解析到活笔记、新增不能让注入载荷超预算。' +
1531
+ 'action: retire 追加退役标记,不做容量门;语义判断全归调用方。' +
1473
1532
  '想改已有条目仍用原生 edit;本工具只往末尾追加。',
1474
1533
  parameters: {
1475
1534
  type: 'object',
@@ -1581,34 +1640,16 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1581
1640
  }),
1582
1641
  t({
1583
1642
  name: 'zk_lint',
1584
- description: '给知识库做体检:断链 / 孤儿 / 无标签 / 单向链接 / 陈旧(N 天没改)/ 重名标题,每类最多 50 条并给总数。' +
1585
- 'frontmatter 解析失败的笔记单列一类:它们进不了索引,别的项统计不到,先修它们再看其余。' +
1586
- 'memoryLinks 查 MEMORY.md / USER.md 里的 [[来源链接]] 是否还指向活笔记(已废弃 / 不存在)—— ' +
1587
- 'supersede 不会重写 meta 文件里的链接,这类漂移 broken-links 看不见;另数没附链接(unlinked)、' +
1588
- '没写日期(undated)、新条目没写顶部(outOfOrder / newestAt)、最旧日期并列(oldestTies / oldestDate)、' +
1589
- '已退役(retired)、退役后新结论失效(retiredBroken)与超过 90 天没复核(stale)的条目。' +
1590
- '位置债只报告,不改条目:写工具固定追加末尾,同日并列时按位置决胜。' +
1591
- 'incomplete 是 frontmatter 缺 type / status / authority 的笔记:缺失被索引落成空串,机械门会静默失效。' +
1592
- 'tags 查标签卫生(大小写变体 / 单例,标签总数 ≥ 30 才报);template 说根目录 AGENTS.md 是不是当前版本。' +
1593
- 'similarTitles 是「改一两个字」的疑似重复(同目录、二元组相似度 ≥ 0.6):与全等重名分开,只报告。' +
1594
- 'missingId 是缺稳定 id 的非日记笔记数:zk_new 新建的笔记自动写 id,老笔记只提示、不回填。' +
1595
- 'timeline 是日记时间轴:最近 90 天的空块 / 倒序 / 格式(11:5x)/ 位置(layered 用 ##、或在 ## Events 外)问题,只报告不改文件。' +
1596
- 'total / counts 按全量算,items 里每篇最多 50 条明细,整个桶最多 50 篇;skipped 是过大或读不到而没检查的篇数。' +
1597
- 'indexHint=true 表示笔记(不含日记)已到 150 篇而根目录还没有 INDEX.md(只是提示,不生成静态索引)。' +
1598
- '孤儿与无标签不含日记(按天写的日记天然如此,报出来只会淹没真问题)。' +
1599
- 'oneWayLinks.items 是缺回链的目标 X(不是来源),from 是没被 X 回链的来源 S;' +
1600
- 'edges 是全部单向边数(items 截到 50 条时仍计全量),bodyOnly 是正文引用(不在 ## Links / ## 链接 小节)的单向边数。' +
1601
- 'links_only=true 时只列 Links 小节的单向链接,正文引用只进 bodyOnly,适合把桶当可修清单。' +
1602
- 'S 或 X 是日记的边不算 —— 日记天然是出边,回链它没有意义。' +
1603
- '笔记数触到扫描上限只会漏报;但 oneWayLinks.edgesTruncated=true 表示边集可能不完整(小库建图触顶,' +
1604
- '或大库按篇反查触到 50 目标 / 60 子进程的上限)—— 缺掉的回链边会把双向误判成单向,' +
1605
- '这是唯一可能误报的截断,看到它先缩小排查范围再重跑。' +
1643
+ description: '给知识库做体检:断链 / 孤儿 / 无标签 / 单向链接 / 陈旧 / 重名标题,每类最多 50 条并给总数。' +
1644
+ 'frontmatter 解析失败的笔记单列一类:它们进不了索引,先修它们再看其余。' +
1606
1645
  '只读:不改任何笔记。拿到清单后自己判断先修哪个,再用 zk_link / zk_append / zk_supersede 动手。',
1607
1646
  parameters: {
1608
1647
  type: 'object',
1609
1648
  properties: {
1610
1649
  stale_days: S.num('多少天没修改算陈旧(1-3650,默认 90)'),
1611
1650
  links_only: S.bool('只报 Links 小节的单向链接;正文引用只计数(默认 false)'),
1651
+ include_provenance: S.bool('单向链接里连出处链(concept↔source)一起列;默认只计数(那类边按惯例有向)'),
1652
+ one_way_max: S.num('单向链接清单上限(1-500,默认 50);total 始终是全量'),
1612
1653
  },
1613
1654
  additionalProperties: false,
1614
1655
  },
@@ -1636,9 +1677,11 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1636
1677
  persona: LINT_PERSONA,
1637
1678
  timeline: LINT_TIMELINE,
1638
1679
  emptySections: LINT_EMPTY_SECTIONS,
1680
+ bodyTags: LINT_BODY_TAGS,
1639
1681
  indexHint: { type: 'boolean' },
1682
+ index: LINT_INDEX,
1640
1683
  indexLag: { type: 'string' },
1641
- }, ['notebook', 'notes', 'missingId', 'truncated', 'completeness', 'scanLimit', 'staleDays', 'parseErrors', 'orphans', 'brokenLinks', 'stale', 'tagless', 'oneWayLinks', 'duplicateTitles', 'similarTitles', 'memoryLinks', 'incomplete', 'tags', 'template', 'persona', 'timeline', 'emptySections', 'indexHint', 'indexLag']),
1684
+ }, ['notebook', 'notes', 'missingId', 'truncated', 'completeness', 'scanLimit', 'staleDays', 'parseErrors', 'orphans', 'brokenLinks', 'stale', 'tagless', 'oneWayLinks', 'duplicateTitles', 'similarTitles', 'memoryLinks', 'incomplete', 'tags', 'template', 'persona', 'timeline', 'emptySections', 'bodyTags', 'indexHint', 'index', 'indexLag']),
1642
1685
  },
1643
1686
  async run(args, env) {
1644
1687
  const cfg = configFor(env.workspace, env.sessionId);
@@ -1646,6 +1689,8 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1646
1689
  return lintNotebook(cfg, {
1647
1690
  staleDays: args.stale_days === undefined ? undefined : Number(args.stale_days),
1648
1691
  linksOnly: args.links_only === true,
1692
+ includeProvenance: args.include_provenance === true,
1693
+ oneWayMax: args.one_way_max === undefined ? undefined : Number(args.one_way_max),
1649
1694
  }, env.signal);
1650
1695
  },
1651
1696
  render(_args, value) {
@@ -1666,18 +1711,7 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1666
1711
  lines.push(line('孤儿', v.orphans));
1667
1712
  lines.push(line('无标签', v.tagless));
1668
1713
  const oneWay = v.oneWayLinks;
1669
- const oneWayLabel = oneWay.linksOnly ? '单向链接(Links)' : '单向链接';
1670
- const bodyNote = oneWay.bodyOnly > 0
1671
- ? (oneWay.linksOnly ? '(另有正文引用 ' + oneWay.bodyOnly + ' 条未计)' : '(正文引用 ' + oneWay.bodyOnly + ' 条)')
1672
- : '';
1673
- if (oneWay.total === 0)
1674
- lines.push('✓ ' + oneWayLabel + ':0' + bodyNote);
1675
- else {
1676
- const items = oneWay.items.slice(0, 5).map((i) => i.path + ' ← ' + i.from.join('、'));
1677
- lines.push('✗ ' + oneWayLabel + ':' + oneWay.total + ' 篇 / ' + oneWay.edges + ' 条单向边' +
1678
- bodyNote +
1679
- ' — ' + items.join(';') + (oneWay.total > items.length ? ' …' : ''));
1680
- }
1714
+ lines.push(formatOneWay(oneWay));
1681
1715
  lines.push(v.stale.total === 0
1682
1716
  ? '✓ 陈旧:0'
1683
1717
  : '✗ 陈旧:' + v.stale.total + ' 篇 — ' +
@@ -1714,22 +1748,10 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1714
1748
  }),
1715
1749
  t({
1716
1750
  name: 'zk_dream',
1717
- description: '整理晋升材料:最近 N 天新增的笔记(机械筛掉 authority=informal 与无标签的,其余作为候选)、' +
1718
- 'daily 里没划掉的 Loose ends、被引用最多的笔记。候选带正文摘要(lead)与入链来源(citedBy),方便重放上下文。' +
1719
- 'topCited 先按「被日记提到几天」排(使用信号),入链数只作并列次序;没有日记时退化为原排序。' +
1720
- '会读 MEMORY.md:已经晋升过的(`[[链接]]` 命中或条目里写了标题)移出候选、进 alreadyPromoted —— 不会每周原样重复。' +
1721
- '退役行里的旧标题不再算已晋升,但 `→ [[新结论]]` 仍算。' +
1722
- 'backlog 是窗口外仍未晋升的笔记(按被引数),漏做一次不会永久掉队。' +
1723
- '库超过全图统计上限时不再建全图统计入链(默认 2000 篇,设置页可调;graphBudget 给出生效值):' +
1724
- 'graphSkipped=true,cited / citedBy / topCited 为空 —— 那是「没算」,不是「没人引」。' +
1725
- 'missingId 是缺稳定 id 的非日记笔记数(只提示、不回填);MEMORY 里可以用 [[<id>]] 当来源,改名后仍指向同一篇。' +
1726
- 'memory 给记忆余量(内容词 + 提示 = 总词,余量按总词算,可以为负);retireCandidates 给「可考虑退役」的条目' +
1727
- '(来源归档 / 不存在、超过 ' + STALE_DAYS + ' 天未复核;显式写 archive/ 的有意引用不算)。' +
1728
- 'evidence 把每条现行 MEMORY 结论与它的来源笔记、出处原话 / 外部地址并排摆出来(两跳封顶、零 zk 进程、绝不进注入),' +
1729
- 'unverified 数出「没有可回对原话」的结论 —— 笔记是有损压缩的判断,真值在笔记之外,拿原话回来对才看得见错判断;' +
1730
- '只给材料,不判断结论对不对、不改 MEMORY.md。' +
1731
- 'days 省略时窗口 = 距 DREAMS.md「上次做梦」的天数(没有则 7 天)。' +
1732
- '只返回材料:写 MEMORY.md / DREAMS.md 由你按 AGENTS.md 决定,这个工具不写任何文件。',
1751
+ description: '整理晋升材料:最近 N 天新增的笔记(筛掉 authority=informal 与无标签的)、daily 里没划掉的 Loose ends、被引用最多的笔记。' +
1752
+ '会读 MEMORY.md,已晋升过的不再作为候选。' +
1753
+ 'days 省略时窗口按 DREAMS.md「上次做梦」算。' +
1754
+ '只返回材料、不写任何文件:写 MEMORY.md / DREAMS.md 由调用方按 AGENTS.md 决定。',
1733
1755
  parameters: {
1734
1756
  type: 'object',
1735
1757
  properties: {
@@ -1754,7 +1776,7 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1754
1776
  totalWords: { type: 'number' },
1755
1777
  budget: { type: 'number' },
1756
1778
  headroom: { type: 'number' },
1757
- /** G1:与 zk_lint.memoryLinks 同一口径的格式债 / 退役计数 */
1779
+ /** 与 zk_lint.memoryLinks 同一口径的格式债 / 退役计数 */
1758
1780
  undated: { type: 'number' },
1759
1781
  unlinked: { type: 'number' },
1760
1782
  retired: { type: 'number' },
@@ -1863,7 +1885,7 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1863
1885
  ' = ' + memoryTotal + ' 词(余 ' + v.memory.headroom + ')' +
1864
1886
  (v.memory.personaWords > 0 ? ' · 人格 ' + v.memory.personaWords + ' 词(单独注入,不计入记忆预算)' : ''));
1865
1887
  if (v.missingId > 0)
1866
- lines.push('· 稳定 ID:' + v.missingId + ' 篇没有 id — 新笔记自动写入,老笔记只提示、不回填(§9.2)');
1888
+ lines.push('· 稳定 ID:' + v.missingId + ' 篇没有 id — 新笔记自动写入,老笔记只提示、不回填');
1867
1889
  if (v.retireCandidates.length) {
1868
1890
  lines.push('可考虑退役:');
1869
1891
  for (const c of v.retireCandidates.slice(0, 10)) {
@@ -1960,8 +1982,7 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1960
1982
  }),
1961
1983
  t({
1962
1984
  name: 'zk_stats',
1963
- description: '看一眼知识库现状:笔记数、标签数、断链数、孤立笔记数、已归档(superseded)数,以及顶层目录 / 前 10 个标签的分布(byDir / byTag)。' +
1964
- '适合开始工作前了解上下文规模;笔记多了以后用它判断该先看哪里(不是排行榜)。',
1985
+ description: '看一眼知识库现状:笔记数、标签数、断链数、孤立笔记数、已归档数,以及顶层目录 / 前 10 个标签的分布(byDir / byTag)。',
1965
1986
  parameters: { type: 'object', properties: {}, additionalProperties: false },
1966
1987
  output: {
1967
1988
  schema: objSchema({
@@ -1984,7 +2005,7 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
1984
2005
  },
1985
2006
  completeness: { type: 'string', enum: ['complete', 'partial', 'unknown'] },
1986
2007
  scanLimit: { type: 'number' },
1987
- /** 本地聚合计数(plan §14.4):只看「入口 / 一跳」这条路有没有被用上,不记查询词 */
2008
+ /** 本地聚合计数:只看「入口 / 一跳」这条路有没有被用上,不记查询词 */
1988
2009
  usage: objSchema({
1989
2010
  since: { type: 'string' },
1990
2011
  search: { type: 'number' },
@@ -31,6 +31,31 @@ export function templateVersionOf(body) {
31
31
  const hit = TEMPLATE_MARK_RE.exec(String(body ?? ''));
32
32
  return hit ? Number(hit[1]) : 0;
33
33
  }
34
+ /**
35
+ * WORKFLOW.md 的模板版本:**独立**于 `TEMPLATE_VERSION`。
36
+ *
37
+ * 为什么独立:两份文件各改各的(AGENTS 注入、WORKFLOW 按需读),共用一个号时
38
+ * 「AGENTS 升到 v12、WORKFLOW 内容一字未变」也会让 WORKFLOW 被标成旧版 —— 反过来,
39
+ * 只升 AGENTS 的人不会想到还要动 WORKFLOW,旧号就永远留着。v12 及更早的 WORKFLOW.md
40
+ * 首行用的是 `zdiary-template`,`workflowVersionOf` 对它返回 0(lint 报「旧标记」,不是「v0 模板」)。
41
+ */
42
+ export const WORKFLOW_VERSION = 1;
43
+ export const WORKFLOW_MARK = `<!-- zdiary-workflow: v${WORKFLOW_VERSION} -->`;
44
+ const WORKFLOW_MARK_RE = /<!--\s*zdiary-workflow:\s*v(\d+)\s*-->/;
45
+ /** WORKFLOW.md 的版本;没有新标记返回 0(含 v12 及更早的共用标记) */
46
+ export function workflowVersionOf(body) {
47
+ const hit = WORKFLOW_MARK_RE.exec(String(body ?? ''));
48
+ return hit ? Number(hit[1]) : 0;
49
+ }
50
+ /** 旧版 WORKFLOW.md 首行:与 AGENTS 共用的标记(v12 及更早) */
51
+ export const WORKFLOW_LEGACY_MARK_RE = /<!--\s*zdiary-template:\s*v(\d+)\s*-->/;
52
+ /**
53
+ * WORKFLOW.md 当前版本的正文哨兵:标记已经是新版号、正文却还是旧版时抓出来。
54
+ * 只挑「新版才有 / 旧版已删」的确定文本,不做语义判断。
55
+ */
56
+ export const WORKFLOW_SENTINELS = {
57
+ 1: { required: ['zk_memory_write', 'zk_rename'] },
58
+ };
34
59
  /**
35
60
  * 当前版本的正文哨兵:只查「标记已经是当前版本」的文件,用来发现
36
61
  * 「只把首行数字改成 vN、正文还是旧版」。
@@ -98,7 +123,7 @@ MEMORY.md 每条:结论(YYYY-MM-DD)[[来源路径]],先 read 核对来
98
123
  * 根目录 WORKFLOW.md:只在「要动已有笔记」时才需要读,所以不注入、不计预算。
99
124
  * 放进注入的话,AGENTS.md 一膨胀就会挤掉 MEMORY —— 这些规则低频但重要,适合按需读。
100
125
  */
101
- export const WORKFLOW_TEMPLATE = `${TEMPLATE_MARK}
126
+ export const WORKFLOW_TEMPLATE = `${WORKFLOW_MARK}
102
127
 
103
128
  # 改笔记的工作流(按需读)
104
129
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 死胡同探针:检索命中一篇活笔记时,顺手看归档里有没有**同一条结论**的废弃版本,带出废弃原因。
3
3
  *
4
- * 为什么需要(plan §14.3):`supersede` 的旧结论被 `excludedNames` 排除出检索,
4
+ * 为什么需要:`supersede` 的旧结论被 `excludedNames` 排除出检索,
5
5
  * 只有 `zk_new` 写同名时才提示一次。于是 agent 在读 / 想的阶段看不到「这条路试过、为什么废」,
6
6
  * 只能重新踩一遍 —— 而按 HackerNoon 那条分工,死胡同复现正是最该省掉的工。
7
7
  * 这不是「不查全」的谦逊,是主动隐藏反例。