dsh-zdiary-kit 0.7.3 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/cli.js +6 -3
- package/dist/features/settings/feature.js +1 -1
- package/dist/features/zk-tools/feature.js +12 -3
- package/dist/lib/zk.js +100 -1
- package/docs/features/memory.md +1 -1
- package/docs/features/zk-tools.md +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# dsh-zdiary-kit 0.7.
|
|
1
|
+
# dsh-zdiary-kit 0.7.5
|
|
2
2
|
|
|
3
3
|
> 给 [DSH](https://github.com/deepseek-ai/deepseek-harness) 装一个**内置 [zk](https://github.com/zk-org/zk) 的知识库 / 日记本**:
|
|
4
4
|
> 插件提供一键安装 zk(官方 release;设置页按钮或 `zk-kit install`)、自动建笔记本(zk init + 日记模板 + 日记 group),
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
| `zk_search` | 全文 / 标签 / 日期 / 断链 / 孤立笔记检索,返回标题、路径、标签、摘要 |
|
|
14
14
|
| `zk_query` | 结构化检索:按 type / status / 标签 / 目录 / 日期过滤,默认只看 active 且不含归档;`include_archived` 连归档一起查(此时未显式给 status 则不再默认过滤 active) |
|
|
15
15
|
| `zk_read` | 读一篇全文(按路径,或先按词找最相关的一篇);超长会截断并标注 |
|
|
16
|
-
| `zk_new` | 新建原子笔记(zk
|
|
16
|
+
| `zk_new` | 新建原子笔记(zk 生成文件名、套模板、写索引),可带摘要、标签与双链;`summary` 填进模板的 `## Summary`(正文里已写了这一节就不动,返回 `summaryApplied: false`);`name` 可直接指定短文件名(不给则按标题生成,中文标题得到拼音长名);flat 下按标题查重,重复直接报错;归档里有同名旧结论只警告并带出废弃原因;type / authority 只有 layered 模板会写进 frontmatter;`raw/` 与根目录 meta 文件一律拒写(写进去会被排除出索引 / 被当成人写的工作面) |
|
|
17
17
|
| `zk_append` | 往已有笔记末尾续写(自动补空行,可先起二级标题);根目录 meta 文件拒写 |
|
|
18
18
|
| `zk_daily` | 打开/创建某天的日记,并追加一条带时间的记录(layered 模板写进 `## Events` 的 `### HH:MM`,flat 追加到文件末尾的 `## HH:MM`) |
|
|
19
19
|
| `zk_link` | 在两篇笔记间加 `[[…]]` 双链(已存在不重复加;目标不存在会给出候选;链接追加到文末,已有 Links/链接 小节则不重复起标题);meta 文件不作为来源或目标 |
|
|
@@ -244,6 +244,7 @@ zk-kit doctor # 自检:zk / 笔记本 / 模板 / group
|
|
|
244
244
|
| 双链 | `zk-kit link notes/a.md "某篇标题"` |
|
|
245
245
|
| 指定目录 | `zk-kit new --title 标题 --dir notes/concepts`(layered 下 type 由目录所属 group 决定) |
|
|
246
246
|
| 指定文件名 | `zk-kit new --title 很长的中文结论标题 --name 短文件名`(只换文件名,标题与正文不动;不给就是拼音 slug) |
|
|
247
|
+
| 带摘要 | `zk-kit new --title 标题 --summary "一句话"`(写进模板的 `## Summary`;正文里已写了就不覆盖并告警) |
|
|
247
248
|
| 装 zk | `zk-kit install 0.15.7`(下载约 10 MB → `~/.dsh/zdiary/bin`,不在可跑清单里) |
|
|
248
249
|
|
|
249
250
|
除 `doctor` / `help` / `config set` 外,其余子命令加 `--json` 输出结构化结果。
|
|
@@ -301,7 +302,7 @@ zk-kit doctor # 自检:zk / 笔记本 / 模板 / group
|
|
|
301
302
|
浏览器半边 `client.ts` 零 import,`postbuild` 把 tsc 补的 `export {}` 删掉,并检查没有顶层声明
|
|
302
303
|
(DSH 会把多个插件的 `client.js` 拼进同一个 combo 脚本,顶层 `const` / `function` 会撞名导致插件不激活)。
|
|
303
304
|
- `bun run typecheck` · `bun run build` · `bun run test`(真起 zk)·
|
|
304
|
-
`bun run smoke`(加载 dist
|
|
305
|
+
`bun run smoke`(加载 dist:14 个工具各跑一遍 + 6 条设置路由都发真实请求(`/install` 只验非法版本,不下载),并检查输出 schema 在 DSH 支持的子集内)·
|
|
305
306
|
`bun run docs`(把 README / docs 里 `zk-kit …` 代码块在临时 vault 上逐条真跑;`smoke` 末尾会带上)
|
|
306
307
|
- `bun run test` 会先按插件自己的顺序找 zk(配置 → `ZK_BIN` → PATH → `~/.dsh/zdiary/bin`),跑完要求 **skip = 0**:
|
|
307
308
|
集成测试跳过一律按失败处理,否则「全绿」可能是「什么都没跑」。要换 zk 就 `ZK_BIN=/path/to/zk bun run check`。
|
package/dist/cli.js
CHANGED
|
@@ -17,7 +17,7 @@ const HELP = `zk-kit —— dsh-zdiary-kit 的命令行
|
|
|
17
17
|
zk-kit doctor 自检:zk / 笔记本 / 模板 / group / 索引
|
|
18
18
|
zk-kit install [版本] 安装内置 zk(默认取配置里的版本)
|
|
19
19
|
zk-kit init 建好(或补齐)笔记本
|
|
20
|
-
zk-kit new --title T [--name 文件名] [--body B] [--tags a,b] [--dir notes]
|
|
20
|
+
zk-kit new --title T [--name 文件名] [--summary 摘要] [--body B] [--tags a,b] [--dir notes]
|
|
21
21
|
zk-kit search [词] [--tags a,b] [--since 日期] [--limit 5] [--json]
|
|
22
22
|
zk-kit read <路径> | --query 词 [--max-chars n] [--json]
|
|
23
23
|
zk-kit daily [--entry 一段] [--date yesterday]
|
|
@@ -35,7 +35,7 @@ const HELP = `zk-kit —— dsh-zdiary-kit 的命令行
|
|
|
35
35
|
zk-kit config [get [键]] 看配置(不传键 = 全量;未知键报错)
|
|
36
36
|
zk-kit config set 键=值 [键=值 …] 改配置(只落盘,不建目录;structure 改的是当前笔记本,切完跑 zk-kit init)
|
|
37
37
|
|
|
38
|
-
除 doctor / help 外,其余子命令加 --json 输出结构化结果。`;
|
|
38
|
+
除 doctor / help / config set 外,其余子命令加 --json 输出结构化结果。`;
|
|
39
39
|
function parse(argv) {
|
|
40
40
|
const out = { pos: [], flags: {} };
|
|
41
41
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -297,16 +297,19 @@ async function main() {
|
|
|
297
297
|
case 'new': {
|
|
298
298
|
const title = str(flags.title) || pos[0] || '';
|
|
299
299
|
if (!title)
|
|
300
|
-
throw new ZkError('用法:zk-kit new --title 标题 [--name 文件名] [--body 正文] [--tags a,b]');
|
|
300
|
+
throw new ZkError('用法:zk-kit new --title 标题 [--summary 摘要] [--name 文件名] [--body 正文] [--tags a,b]');
|
|
301
301
|
const tags = [...new Set([...cfg.defaultTags, ...list(flags.tags)])];
|
|
302
302
|
const created = await createNote(cfg, {
|
|
303
303
|
title,
|
|
304
304
|
name: str(flags.name) || undefined,
|
|
305
|
+
summary: str(flags.summary) || undefined,
|
|
305
306
|
content: withTags(str(flags.body), tags),
|
|
306
307
|
dir: str(flags.dir) || cfg.notesDir,
|
|
307
308
|
});
|
|
308
309
|
const archived = created.archived;
|
|
309
310
|
print(json ? { ...created, tags } : `已创建 ${created.path}${tags.length ? ' · ' + tags.map((t) => '#' + t).join(' ') : ''}`, json);
|
|
311
|
+
if (created.summaryWarning)
|
|
312
|
+
console.error('⚠️ ' + created.summaryWarning);
|
|
310
313
|
for (const hit of archived) {
|
|
311
314
|
console.error(`⚠️ 归档里有同名旧结论:${hit.path}${hit.reason ? `(废弃原因:${hit.reason})` : '(没有记录废弃原因)'} —— 先读它,确认不是同一个结论再复用标题`);
|
|
312
315
|
}
|
|
@@ -215,7 +215,7 @@ export function registerSettings({ route, isTrusted }) {
|
|
|
215
215
|
}
|
|
216
216
|
try {
|
|
217
217
|
const result = await installZk(version);
|
|
218
|
-
const detail = `已安装 zk ${result.version} → ${result.path}(源:${sourceLabel(result.mirror)})`;
|
|
218
|
+
const detail = `已安装 zk ${result.version} → ${result.path}(源:${sourceLabel(result.mirror)} · ${result.url})`;
|
|
219
219
|
json(res, 200, { ok: true, result, detail, ...(await snapshot(cfg)) });
|
|
220
220
|
}
|
|
221
221
|
catch (err) {
|
|
@@ -385,7 +385,8 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
|
|
|
385
385
|
properties: {
|
|
386
386
|
title: S.str('笔记标题(会成为一级标题)'),
|
|
387
387
|
name: S.str('文件名(不含扩展名,也不要带目录);不给就由 zk 按标题生成。中文标题建议给一个短名,否则是长拼音'),
|
|
388
|
-
body: S.str('正文 Markdown
|
|
388
|
+
body: S.str('正文 Markdown(可空)。会插在模板的 {{content}} 位置(layered 下在 ## Content 之下、## Links 之前):不要自己再写 ## Content / ## Summary 这类模板小节,会多出重复标题'),
|
|
389
|
+
summary: S.str('一句话摘要(填进模板的 ## Summary;正文里已经写了这一节就不动)'),
|
|
389
390
|
tags: S.arr('标签(不写 #)。与设置里的默认标签合并', S.str('标签名')),
|
|
390
391
|
dir: S.str('放到哪个子目录(相对笔记本),默认用设置里的 notesDir'),
|
|
391
392
|
type: S.enum('笔记类型(写进 frontmatter;layered 结构下决定模板的分节)', ['source', 'concept', 'entity', 'pattern']),
|
|
@@ -403,6 +404,8 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
|
|
|
403
404
|
title: { type: 'string' },
|
|
404
405
|
tags: { type: 'array', items: { type: 'string' } },
|
|
405
406
|
links: { type: 'array', items: { type: 'string' } },
|
|
407
|
+
summaryApplied: { type: 'boolean' },
|
|
408
|
+
summaryWarning: { type: 'string' },
|
|
406
409
|
archived: {
|
|
407
410
|
type: 'array',
|
|
408
411
|
items: objSchema({
|
|
@@ -412,7 +415,7 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
|
|
|
412
415
|
}, ['path', 'title', 'reason']),
|
|
413
416
|
},
|
|
414
417
|
warnings: { type: 'array', items: { type: 'string' } },
|
|
415
|
-
}, ['notebook', 'path', 'title', 'tags', 'links', 'archived', 'warnings']),
|
|
418
|
+
}, ['notebook', 'path', 'title', 'tags', 'links', 'summaryApplied', 'archived', 'warnings']),
|
|
416
419
|
},
|
|
417
420
|
async run(args, env) {
|
|
418
421
|
const cfg = configFor(env.workspace, env.sessionId);
|
|
@@ -421,6 +424,7 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
|
|
|
421
424
|
const created = await createNote(cfg, {
|
|
422
425
|
title: String(args.title),
|
|
423
426
|
name: args.name ? String(args.name) : undefined,
|
|
427
|
+
summary: args.summary ? String(args.summary) : undefined,
|
|
424
428
|
content: withTags(args.body ? String(args.body) : '', tags),
|
|
425
429
|
dir: args.dir ? String(args.dir) : cfg.notesDir,
|
|
426
430
|
group: args.group ? String(args.group) : undefined,
|
|
@@ -442,7 +446,10 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
|
|
|
442
446
|
// 归档同名只是提醒:zk_new 的查重本来就不含 archive,允许复用标题 —— 但要把废弃原因一起交出来
|
|
443
447
|
// (createNote 建之前那次全库扫描已经算好了,这里不再单独跑一次 zk)
|
|
444
448
|
const archived = created.archived;
|
|
445
|
-
return {
|
|
449
|
+
return {
|
|
450
|
+
notebook: cfg.notebook, path: created.path, title: created.title, tags, links,
|
|
451
|
+
summaryApplied: created.summaryApplied, summaryWarning: created.summaryWarning, archived, warnings,
|
|
452
|
+
};
|
|
446
453
|
},
|
|
447
454
|
render(_args, value) {
|
|
448
455
|
const v = value;
|
|
@@ -451,6 +458,8 @@ export function buildTools(workspaceOf = () => processWorkspace()) {
|
|
|
451
458
|
lines.push('标签:' + v.tags.map((t) => '#' + t).join(' '));
|
|
452
459
|
if (v.links.length)
|
|
453
460
|
lines.push('双链:' + v.links.join(' '));
|
|
461
|
+
if (v.summaryWarning)
|
|
462
|
+
lines.push('⚠️ ' + v.summaryWarning);
|
|
454
463
|
if (v.archived.length) {
|
|
455
464
|
lines.push('⚠️ 归档里有同名旧结论:' + v.archived.map((h) => h.path + (h.reason ? `(废弃原因:${h.reason})` : '(没有记录废弃原因)')).join(';') +
|
|
456
465
|
' —— 先读它,确认不是同一个结论再复用标题');
|
package/dist/lib/zk.js
CHANGED
|
@@ -661,7 +661,26 @@ export async function createNote(cfg, input, signal, scan = (c, s) => allNotes(c
|
|
|
661
661
|
// 索引里还是 zk 生成的那个文件名:不刷新的话,紧接着的 search / stats 会读到旧路径
|
|
662
662
|
await refreshIndexQuietly(cfg, signal);
|
|
663
663
|
}
|
|
664
|
-
|
|
664
|
+
// 摘要只能建完之后补:模板里 `## Summary` 天生是空的,`{{content}}` 又落在它下面 —— body 写不进这一节
|
|
665
|
+
let summaryApplied = false;
|
|
666
|
+
let summaryWarning;
|
|
667
|
+
if (input.summary?.trim()) {
|
|
668
|
+
try {
|
|
669
|
+
const text = fs.readFileSync(finalAbs, 'utf8');
|
|
670
|
+
const filled = fillSummary(text, input.summary);
|
|
671
|
+
summaryApplied = filled.applied;
|
|
672
|
+
if (filled.text !== text)
|
|
673
|
+
fs.writeFileSync(finalAbs, filled.text, 'utf8');
|
|
674
|
+
if (!filled.applied) {
|
|
675
|
+
summaryWarning = 'summary 没写进去:正文里已经有一节 Summary(没覆盖它),要改就直接编辑那一节';
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
catch (err) {
|
|
679
|
+
// 笔记已经建好:收尾失败只降级成告警,别让人以为这次写入整个失败了
|
|
680
|
+
summaryWarning = `summary 没写进去:${err instanceof Error ? err.message : String(err)}(文件已建好,可以直接编辑那一节)`;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return { path: relPathOf(cfg, finalAbs), absPath: finalAbs, title, archived, summaryApplied, summaryWarning };
|
|
665
684
|
}
|
|
666
685
|
/** 笔记本相对路径是否在归档目录下(supersede 会把文件搬进去,路径保持不变) */
|
|
667
686
|
function inArchive(cfg, rel) {
|
|
@@ -707,6 +726,86 @@ function sectionRange(content, name) {
|
|
|
707
726
|
}
|
|
708
727
|
return { start: start + 1, end };
|
|
709
728
|
}
|
|
729
|
+
/** 行内 ATX 标题:`## 名称`(收尾井号算装饰,不进食标题) */
|
|
730
|
+
function atxHeading(line) {
|
|
731
|
+
const m = /^(#{1,6})[ \t]+(.*?)[ \t]*$/.exec(line);
|
|
732
|
+
if (!m)
|
|
733
|
+
return null;
|
|
734
|
+
const title = m[2].replace(/[ \t]+#+$/, '').trim();
|
|
735
|
+
return title ? { level: m[1].length, title } : null;
|
|
736
|
+
}
|
|
737
|
+
/** 围栏行标记(``` / ~~~):代码块里的 `## x` 是代码,不是小节 */
|
|
738
|
+
function fencedLines(lines) {
|
|
739
|
+
const mask = [];
|
|
740
|
+
let fence = null;
|
|
741
|
+
for (const line of lines) {
|
|
742
|
+
const m = /^ {0,3}(`{3,}|~{3,})/.exec(line);
|
|
743
|
+
if (fence) {
|
|
744
|
+
mask.push(true);
|
|
745
|
+
if (m && m[1][0] === fence.char && m[1].length >= fence.len)
|
|
746
|
+
fence = null;
|
|
747
|
+
}
|
|
748
|
+
else {
|
|
749
|
+
mask.push(Boolean(m));
|
|
750
|
+
if (m)
|
|
751
|
+
fence = { char: m[1][0], len: m[1].length };
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
return mask;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* 把一句话摘要填进 `## Summary`。
|
|
758
|
+
*
|
|
759
|
+
* 模板里这一节天生是空的,之前没有任何写入路径能填它 —— `{{content}}` 落在 `## Content` 下面,
|
|
760
|
+
* 摘要只能靠人事后手写。这里补上落点,三种情况:
|
|
761
|
+
* · 有空着的 `## Summary`(模板)→ 填进去;
|
|
762
|
+
* · 没有这一节(flat 的笔记只有 `# 标题`)→ 在一级标题下面补一节;
|
|
763
|
+
* · 已经有内容(正文自己写了 Summary)→ 一个字不动,返回 applied=false 让调用方去提醒。
|
|
764
|
+
*
|
|
765
|
+
* 只填不删:正文里多写了一节 `## Content` 属于排版噪音,交给调用方去提醒,不在这里静默改正文。
|
|
766
|
+
*/
|
|
767
|
+
export function fillSummary(content, summary) {
|
|
768
|
+
// 摘要是一段话:换行会在小节里长出第二段,压成一行
|
|
769
|
+
const body = String(summary ?? '').replace(/\s+/g, ' ').trim();
|
|
770
|
+
if (!body)
|
|
771
|
+
return { text: content, applied: false };
|
|
772
|
+
const lines = String(content ?? '').split('\n');
|
|
773
|
+
const fenced = fencedLines(lines);
|
|
774
|
+
const heads = lines.map((line, i) => (fenced[i] ? null : atxHeading(line)));
|
|
775
|
+
const isSummary = (title) => /^(summary|摘要)$/i.test(title.trim());
|
|
776
|
+
const target = heads.findIndex((h) => h !== null && isSummary(h.title));
|
|
777
|
+
if (target >= 0) {
|
|
778
|
+
const head = heads[target];
|
|
779
|
+
let end = lines.length;
|
|
780
|
+
for (let i = target + 1; i < lines.length; i += 1) {
|
|
781
|
+
const next = heads[i];
|
|
782
|
+
if (next && next.level <= head.level) {
|
|
783
|
+
end = i;
|
|
784
|
+
break;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
if (lines.slice(target + 1, end).some((line) => line.trim() !== ''))
|
|
788
|
+
return { text: content, applied: false };
|
|
789
|
+
// 正文自己又写了一份 Summary(模板那一节只是空壳):那一节已经有主,不覆盖、也不在旁边再长一节
|
|
790
|
+
const writtenByContent = heads.some((h, k) => k >= end && h !== null && h.level === head.level && isSummary(h.title));
|
|
791
|
+
if (writtenByContent)
|
|
792
|
+
return { text: content, applied: false };
|
|
793
|
+
const out = [...lines.slice(0, target + 1), '', body, '', ...lines.slice(end)];
|
|
794
|
+
return { text: endDoc(out), applied: true };
|
|
795
|
+
}
|
|
796
|
+
// flat / 自定义模板:一级标题下面补一节;没有一级标题就不猜位置
|
|
797
|
+
const h1 = heads.findIndex((h) => h !== null && h.level === 1);
|
|
798
|
+
if (h1 < 0)
|
|
799
|
+
return { text: content, applied: false };
|
|
800
|
+
const rest = lines.slice(h1 + 1);
|
|
801
|
+
while (rest.length && rest[0].trim() === '')
|
|
802
|
+
rest.shift();
|
|
803
|
+
return { text: endDoc([...lines.slice(0, h1 + 1), '', '## Summary', '', body, '', ...rest]), applied: true };
|
|
804
|
+
}
|
|
805
|
+
/** 结尾只留一个换行(拼完可能多出空行,文件末尾的连续空白没有意义) */
|
|
806
|
+
function endDoc(lines) {
|
|
807
|
+
return lines.join('\n').replace(/\n+$/, '\n');
|
|
808
|
+
}
|
|
710
809
|
/**
|
|
711
810
|
* 往一篇笔记追加(自动补空行;可选先写一个二级标题)。
|
|
712
811
|
*
|
package/docs/features/memory.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
- `lib/agents-template.ts`:`AGENTS.md` 模板(layered 初始化时写入;当前 175 词,占默认 500 词的 35%,因为它在预算里且永不截断)
|
|
12
12
|
与 `WORKFLOW.md` 模板(改已有笔记的清单确认 + 三分类;不注入、不计预算,AGENTS 只留一行指针)
|
|
13
13
|
- `app/plugin.ts`:`ctx.inject(['systemPrompt'])` → 注册两段:`zdiary:notebook`(order 5190,一行当前笔记本名字 / 结构 / 路径 + 其余已配置库名,每步跟随会话 pin;**不进记忆预算**)与 `zdiary:memory`(order 5200,`interpolate: false` —— 记忆是文件原文,
|
|
14
|
-
`{{…}}` 一律原样保留:插值会让未注册变量在装配时抛错、`{{model}}` 这类被静默改写),`text` 是函数,每个 step
|
|
14
|
+
`{{…}}` 一律原样保留:插值会让未注册变量在装配时抛错、`{{model}}` 这类被静默改写),`text` 是函数,每个 step 重新求值(按文件指纹 + 预算 + 日期缓存,变了才重读重算);
|
|
15
15
|
装配上下文带 `agent.id` 时按**会话工作区 + 该会话固定的笔记本**解析(`config/session`,和 `zk_*` 工具同口径);
|
|
16
16
|
别的会话切了默认值不会把已开的会话换库,裸装配才退回进程工作区 + 全局默认
|
|
17
17
|
- `zk_context` 工具:同一份 payload,给「宿主没有 `systemPrompt`」和「人想核对被截断了什么」用;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
**Owns.** 14 个工具定义(`zk_search` / `zk_query` / `zk_read` / `zk_new` / `zk_append` / `zk_daily` / `zk_link` /
|
|
6
6
|
`zk_supersede` / `zk_rename` / `zk_context` / `zk_lint` / `zk_dream` / `zk_stats` / `zk_use`):
|
|
7
7
|
参数 schema、输出 schema、render、每个工具自己的 `ensureNotebook` 与参数校验。
|
|
8
|
-
`zk_context` 例外:它只读根目录三份 meta
|
|
8
|
+
`zk_context` 例外:它只读根目录三份 meta 文件并列出已配置笔记本(另读 `DREAMS.md` 的「上次做梦」一行用于周节奏提醒),**不** `ensureNotebook`(读记忆不该依赖 zk)。
|
|
9
9
|
|
|
10
10
|
**多会话与笔记本归属.** 工具拿配置走 `config/session.ts` 的 `configFor(workspace, sessionId)`,不是直接 `config()`:
|
|
11
11
|
会话第一次调用时把当时的 `active`(默认值)快照成自己的 pin,之后设置页 / CLI / 别的会话切库都不带动它;
|
|
@@ -42,6 +42,10 @@ layered 同目录同名靠 `{{slug title}}` 文件名拦住,不同目录允许
|
|
|
42
42
|
(只换文件名,标题和正文不动)。改名后 zk 的 slug 撞名失效,所以给了 `name` 时会在建之前按「同目录 + 同标题」补查一次。
|
|
43
43
|
老笔记不自动改名;**手工 `mv`** 会断路径式入链,要改名用 `zk_rename`(它会重写入链 / meta 来源 / 自身相对链接)。
|
|
44
44
|
`type` / `authority` 只有 layered 模板(`{{extra.*}}`)会写进 frontmatter;flat 的 `default.md` 没有占位符,传了也不会落盘。
|
|
45
|
+
`summary` 写进模板的 `## Summary`:这一节模板里天生是空的,而 `{{content}}` 落在 `## Content` 下面 —— 不给 `summary`,
|
|
46
|
+
它没有任何写入路径能填。flat / 自定义模板没有这一节时,在一级标题下面补一节;正文里自己写了 Summary 就不覆盖,
|
|
47
|
+
一个字都不改,返回 `summaryApplied: false` 和 `summaryWarning`(工具层与 CLI 都据此告警)。
|
|
48
|
+
只填不删:正文里多写一节 `## Content` 之类属于排版噪音,靠 `body` 的入参说明去避免,不在建完收尾时静默改正文。
|
|
45
49
|
`zk_append` 拒写根目录的 meta 文件(AGENTS / USER / MEMORY / DREAMS / INDEX / WORKFLOW,清单来自 `lib/meta.ts`):追加会把记忆变成流水账,
|
|
46
50
|
也让「这条记忆是谁改的」失去审计线索;子目录里的同名文件是普通笔记,照常可写。
|
|
47
51
|
同一道守卫也覆盖 `zk_new`(不能新建根目录 meta)、`zk_link`(meta 不能作为来源或目标)与 `zk_supersede`(不能废弃 meta,否则会把它搬进 archive/)。
|