nx-kv 0.48.2 → 0.49.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/CHANGELOG.md +46 -0
- package/package.json +1 -1
- package/src/core/attachmentdb/bodies.ts +161 -0
- package/src/core/attachmentdb/docs.ts +95 -33
- package/src/core/attachmentdb/ids.ts +27 -1
- package/src/core/attachmentdb/mdfile.ts +249 -0
- package/src/core/attachmentdb/query.ts +14 -1
- package/src/core/attachmentdb/resources.ts +23 -0
- package/src/core/attachmentdb.ts +22 -0
- package/src/core/db/bootstrap.ts +5 -5
- package/src/core/db/import-json/refs.ts +27 -13
- package/src/core/db/migrations/index.ts +7 -0
- package/src/core/db/migrations/v2-data.ts +4 -4
- package/src/core/db/migrations/v5.sql +100 -0
- package/src/core/db/migrations/v6-data.ts +261 -0
- package/src/core/db/migrations/v6.sql +67 -0
- package/src/core/db/version.ts +9 -1
- package/src/core/paths.ts +10 -0
- package/src/modules/docs/actions/_manifest.generated.ts +9 -0
- package/src/modules/docs/actions/doc-attach.ts +2 -1
- package/src/modules/docs/actions/doc-link-file.ts +28 -0
- package/src/modules/docs/actions/doc-mdfile.ts +28 -0
- package/src/modules/docs/actions/doc-mdfiles.ts +29 -0
- package/src/modules/docs/attach.ts +14 -1
- package/src/modules/docs/docref.ts +13 -1
- package/src/modules/docs/knowledge.ts +17 -19
- package/src/modules/docs/mdfile.ts +24 -0
- package/src/modules/docs/paths.ts +6 -9
- package/src/modules/docs/render.ts +24 -4
- package/src/modules/docs/seed.ts +1 -1
- package/src/modules/docs/service.ts +48 -18
- package/src/modules/docs/store.ts +120 -74
- package/src/modules/localtask/action-render.ts +2 -2
- package/src/modules/localtask/actions/localtask-attach.ts +4 -2
- package/src/modules/repos/service/bind-topics.ts +8 -18
- package/src/modules/repos/service.ts +1 -1
- package/src/modules/repos/transfer/export.ts +4 -1
- package/src/modules/tasktool/attach-resource.ts +37 -5
- package/src/modules/tasktool/attach-template.ts +45 -4
- package/src/modules/tasktool/attach.ts +47 -3
- package/src/modules/tasktool/doc-inline.ts +54 -29
- package/src/shared/prompt-blocks.ts +6 -1
- package/src/web/frontend/api/cli-tree.json +47 -2
- package/src/web/frontend/api/client.generated.ts +40 -4
- package/src/web/frontend/components/md/attach-area.tsx +58 -3
- package/src/web/frontend/components/md/attach-common.ts +2 -2
- package/src/web/frontend/modules/md/attach-mention.ts +6 -1
- package/src/web/frontend/modules/md/styles/chrome.css +25 -0
- package/src/web/frontend/page/dir/api.ts +5 -0
- package/src/web/frontend/page/dir/task-dock-panel.tsx +87 -2
- package/src/web/frontend/page/dir/task-status-bar.tsx +14 -1
- package/src/web/frontend/page/dir/task.tsx +2 -0
- package/src/web/frontend/page/doc/index.tsx +16 -15
- package/src/web/frontend/page/repos/doc-search-modal.tsx +7 -0
- package/src/web/public/assets/Introduction-BDS09bo3.js +6 -0
- package/src/web/public/assets/{bar-B52NTf_v.js → bar-DBtVMtRi.js} +1 -1
- package/src/web/public/assets/{cloud-Droja_aT.js → cloud-0AcS7Mtd.js} +1 -1
- package/src/web/public/assets/{composer-panel-DpiU2h50.js → composer-panel-D624x9uT.js} +1 -1
- package/src/web/public/assets/{deleted-panel-K9GgfR8t.js → deleted-panel-BeyVhrAI.js} +1 -1
- package/src/web/public/assets/{dir-DacRpcBt.js → dir-CYGqeYZU.js} +4 -4
- package/src/web/public/assets/{group-TPuU-QVc.js → group-B5cZqWIt.js} +1 -1
- package/src/web/public/assets/{index-BkLkooKe.js → index-BLEuH6mL.js} +2 -2
- package/src/web/public/assets/{index-DP3qBv1o.css → index-ChWwzUrF.css} +1 -1
- package/src/web/public/assets/{md-history-0GBWw4qr.js → md-history-Bpyib4z4.js} +3 -3
- package/src/web/public/assets/{overview-B3kHI66i.js → overview-DrsWuDVi.js} +1 -1
- package/src/web/public/assets/{prompt-blocks-BovFd039.js → prompt-blocks-CO8msDuJ.js} +1 -1
- package/src/web/public/assets/{refs-BDxfuH6R.js → refs-DMVuOOK9.js} +1 -1
- package/src/web/public/assets/{repos-C8jRM7wS.js → repos-C5OwK72H.js} +2 -2
- package/src/web/public/assets/{route-crumb-QvahotvN.js → route-crumb-6q3rIB-_.js} +1 -1
- package/src/web/public/assets/{settings-BBcdGLTc.js → settings-BH_l1Yek.js} +1 -1
- package/src/web/public/assets/{status-tag-BheHByek.js → status-tag-BD6cdnyb.js} +1 -1
- package/src/web/public/assets/task-B7AjuMiC.js +11 -0
- package/src/web/public/assets/task-utils-BNFx9yag.js +12 -0
- package/src/web/public/assets/{templates-CbRyW3PJ.js → templates-G7kHB-xI.js} +1 -1
- package/src/web/public/assets/tool-bar-DIXBM0wv.js +1 -0
- package/src/web/public/index.html +2 -2
- package/src/web/public/assets/Introduction-Du_dycft.js +0 -6
- package/src/web/public/assets/task-CUkQaLBZ.js +0 -11
- package/src/web/public/assets/task-utils-_JAWRAz6.js +0 -12
- package/src/web/public/assets/tool-bar-BAmT-BI-.js +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// 文档侧 mdfile 的读取与巡检(业务编排,核心读写仍在 core/attachmentdb/mdfile)。
|
|
2
|
+
import { getDb } from '../../core/db/index.js';
|
|
3
|
+
import { tx } from '../../core/db/tx.js';
|
|
4
|
+
import { listMdfiles, readMdfile } from '../../core/attachmentdb.js';
|
|
5
|
+
import type { MdfileRow, ReadMdfileResult } from '../../core/attachmentdb.js';
|
|
6
|
+
import { badInput, notFound } from '../../core/errors.js';
|
|
7
|
+
|
|
8
|
+
/** 读一个 mdfile 的正文(读时校验指纹;缺失只标 missing_at)。 */
|
|
9
|
+
export async function readDocMdfile({ attachment }: { attachment?: unknown } = {}): Promise<ReadMdfileResult> {
|
|
10
|
+
const id = String(attachment || '').trim();
|
|
11
|
+
if (!id) throw badInput('需要 --attachment <mdfile 的附件 id>(见 docs mdfiles)');
|
|
12
|
+
const db = getDb();
|
|
13
|
+
let out: ReadMdfileResult | null = null;
|
|
14
|
+
tx((conn) => {
|
|
15
|
+
out = readMdfile(conn, id);
|
|
16
|
+
}, { db, mode: 'IMMEDIATE' });
|
|
17
|
+
if (!out) throw notFound(`没有这条 mdfile 附件: ${id}`);
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** 列出全部已登记的 mdfile(--missing 只看已失效的)。 */
|
|
22
|
+
export async function listDocMdfiles({ missing = false }: { missing?: unknown } = {}): Promise<MdfileRow[]> {
|
|
23
|
+
return listMdfiles(getDb(), { missingOnly: !!missing });
|
|
24
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// docs
|
|
1
|
+
// docs 自有树的路径权威:约定路径与段级 slug。
|
|
2
2
|
// (DocRef / docId 校验在 docref.js——那里刻意不依赖 repos/service,见其文件头。)
|
|
3
3
|
//
|
|
4
4
|
// 目录树承载语义(键位约定,导出 zip 原样带走):
|
|
@@ -7,18 +7,15 @@
|
|
|
7
7
|
// group/<组 slug>/<key 分段>.md 组内描述 group/nx系列/github.com/me/x.md
|
|
8
8
|
// 其余任意 .md 自由文档(同样可索引/双链/绑定)
|
|
9
9
|
//
|
|
10
|
+
// **磁盘不再是文档来源**(v6 + DOCS_DIR 收口):自有文档正文只从 `ref_bodies` 读,
|
|
11
|
+
// mdfile 默认附件目录定义在 core/paths(环境变量名保持不变)。
|
|
12
|
+
// 这里保留的是 **rel 的命名规则**,与文件系统无关。
|
|
13
|
+
//
|
|
10
14
|
// key 全局唯一(repos 模块保证)→ 约定路径不可能互相撞,不需要指纹后缀。
|
|
11
15
|
// 段级 slug 只兜 Windows 的两个坑:段尾点(资源管理器拒绝创建)与保留设备名。
|
|
12
|
-
import { join } from 'node:path';
|
|
13
|
-
import { APP_DIR } from '../../core/paths.js';
|
|
14
16
|
import { normalizeKey } from '../../shared/repo-key.js';
|
|
15
17
|
import { localKeyOf } from '../../core/keys.js';
|
|
16
18
|
|
|
17
|
-
// 允许测试与多实例覆盖文档树根:与 NX_KV_REPOS_STORE 同一模式
|
|
18
|
-
export function docsRoot(): string {
|
|
19
|
-
return process.env.NX_KV_DOCS_DIR || join(APP_DIR, 'docs');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
19
|
// Windows 保留设备名(不分大小写):命中即追加下划线
|
|
23
20
|
const RESERVED = new Set([
|
|
24
21
|
'con', 'prn', 'aux', 'nul',
|
|
@@ -61,7 +58,7 @@ export function groupNoteRel(boardName: unknown, repoKey: unknown): string {
|
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
// DocRef / docId 校验(docref.js):这里转发导出,调用方统一从 paths 拿
|
|
64
|
-
export { assertOwnedRel, assertDocRef, sanitizeDocRef, parseDocId, ownDocId, extDocId } from './docref.js';
|
|
61
|
+
export { assertOwnedRel, assertDocRel, assertDocRef, sanitizeDocRef, parseDocId, ownDocId, extDocId } from './docref.js';
|
|
65
62
|
export type { DocRef, DocRefWithMeta, ParsedDocId } from './docref.js';
|
|
66
63
|
|
|
67
64
|
// ─── 介绍目录(多篇)──────────────────────────────────────────────────
|
|
@@ -10,9 +10,20 @@ function docHead(d: any): string {
|
|
|
10
10
|
return `${addr}${head}${extra}`;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
const KIND_NOTE: Record<string, string> = {
|
|
14
|
+
legacy: '历史空壳',
|
|
15
|
+
external: '外部文件镜像',
|
|
16
|
+
empty: '正文缺失',
|
|
17
|
+
};
|
|
18
|
+
|
|
13
19
|
export const renderList = (d: any): string => {
|
|
14
|
-
const
|
|
15
|
-
|
|
20
|
+
const withBody = (d.docs || []).filter((x: any) => x.hasBody).length;
|
|
21
|
+
const lines = [`自有文档 ${d.count} 个(${withBody} 个有正文;正文只存库内,不落盘)`];
|
|
22
|
+
for (const x of d.docs) {
|
|
23
|
+
// v6:历史空壳 / 外部镜像 / 无正文行必须显式标注,不能看起来像正常文档
|
|
24
|
+
const tag = x.hasBody ? '' : ` (无正文 · ${KIND_NOTE[x.relKind] || '正文缺失'})`;
|
|
25
|
+
lines.push(` ${x.rel} ${x.title || x.name}${tag}`);
|
|
26
|
+
}
|
|
16
27
|
if (d.external?.length) {
|
|
17
28
|
lines.push(`外部文档 ${d.external.length} 个(只读引用):`);
|
|
18
29
|
for (const x of d.external) lines.push(` ${x.path}`);
|
|
@@ -24,7 +35,15 @@ export const renderList = (d: any): string => {
|
|
|
24
35
|
};
|
|
25
36
|
|
|
26
37
|
export const renderGet = (d: any): string => {
|
|
27
|
-
if (d.missing)
|
|
38
|
+
if (d.missing) {
|
|
39
|
+
// 有 relKind = 「条目存在但没有正文」(历史空壳 / 外部镜像 / 正文缺失);
|
|
40
|
+
// 没有 relKind = 外部路径本身不存在。
|
|
41
|
+
if (d.relKind) {
|
|
42
|
+
const kind = KIND_NOTE[d.relKind] ? ` · ${KIND_NOTE[d.relKind]}` : '';
|
|
43
|
+
return `(无正文${kind}: ${d.rel || d.path}${d.reason ? ` — ${d.reason}` : ''})`;
|
|
44
|
+
}
|
|
45
|
+
return `(文档不存在: ${d.rel || d.path})`;
|
|
46
|
+
}
|
|
28
47
|
if (d.dir) return `(外部目录绑定: ${d.path},${d.files.length} 个文档)\n ${d.files.slice(0, 20).join('\n ')}`;
|
|
29
48
|
const head = [`【${d.title || docHead(d)}】`, ` ${d.rel || d.path}${d.external ? ' (外部 · 可写回来源)' : ''}`, ''];
|
|
30
49
|
return head.join('\n') + d.body;
|
|
@@ -61,7 +80,8 @@ export const renderAttachments = (d: any): string => {
|
|
|
61
80
|
const areaOf = (role: unknown): string => (role === 'attach' ? '附件区' : '正文内嵌');
|
|
62
81
|
const lines = [`「${d.locator}」的资源(${d.attachments.length})`];
|
|
63
82
|
for (const a of d.attachments) {
|
|
64
|
-
const where = a.localPath || a.url || (a.kind === '
|
|
83
|
+
const where = a.localPath || a.url || (a.kind === 'mdfile' ? a.absPath
|
|
84
|
+
: a.kind === 'task' ? `task ${a.targetKey}#${a.targetSeq}` : a.targetKey);
|
|
65
85
|
lines.push(` ${a.id} [${a.kind}/${a.role} · ${areaOf(a.role)}] ${a.name || '-'} ${where || ''}`);
|
|
66
86
|
}
|
|
67
87
|
return lines.join('\n');
|
package/src/modules/docs/seed.ts
CHANGED
|
@@ -110,7 +110,7 @@ async function candidateOf(rel: string, field: unknown, owner: RelOwner): Promis
|
|
|
110
110
|
return { rel, title, body: '# ' + title + '\n\n' + clean(field) + '\n' };
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
/**
|
|
113
|
+
/** 种子计划(零副作用):列出所有「字符串有值、文档还没有正文行」的约定路径 */
|
|
114
114
|
export async function seedPlan(): Promise<{ items: SeedItem[]; count: number }> {
|
|
115
115
|
const { loadStore, deriveKey, boardRepoKeys } = await reposBridge();
|
|
116
116
|
const s = await loadStore();
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
// 文档模块的业务逻辑:CRUD + 外部写回。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// 「自有文档的正文权威在 DB」——v6 起正文只存 `ref_bodies`;mdfile 默认目录
|
|
4
|
+
// 只是 mdfile 默认附件目录,不再是文档来源(面板编辑与组详情都从这里取数)。
|
|
5
|
+
// `repo knowledge` 在 repos 模块(它属于 repo.* 命令族),聚合逻辑在 knowledge.js。
|
|
6
6
|
//
|
|
7
7
|
// ─── 读写口径(2026-11 任务 #88「简介文档优化」)───────────────────────
|
|
8
|
-
// rel:
|
|
8
|
+
// rel: 自有树(DB 里的逻辑 rel)——可读可写可删,不落盘
|
|
9
9
|
// path: 外部(Obsidian vault / 任意登记目录)——**登记在册即可写**:
|
|
10
10
|
// 读侧要求路径在绑定闭包内;写侧再校验一次(闭包 + .md + 非目录),
|
|
11
11
|
// 等于「文档集里的每一篇都能就地改」,同时不把 PATCH 变成任意文件写入口。
|
|
12
12
|
// 删除仍不给外部:删除是可恢复性最差的操作,让它回来源做。
|
|
13
|
+
// (外部路径不在 mdfile 默认目录下;后者只允许经 mdfile 附件访问。)
|
|
13
14
|
import * as paths from './paths.js';
|
|
14
15
|
import * as store from './store.js';
|
|
15
16
|
import * as seed from './seed.js';
|
|
@@ -17,7 +18,8 @@ import { reposBridge } from './repos-bridge.js';
|
|
|
17
18
|
import { badInput, blocked } from '../../core/errors.js';
|
|
18
19
|
import { getDb } from '../../core/db/index.js';
|
|
19
20
|
import { tx } from '../../core/db/tx.js';
|
|
20
|
-
import { ensureDocRef, syncRefAttachments } from '../../core/attachmentdb.js';
|
|
21
|
+
import { ensureDocRef, noBodyReason, syncRefAttachments } from '../../core/attachmentdb.js';
|
|
22
|
+
import type { RelKind } from '../../core/attachmentdb.js';
|
|
21
23
|
import { docTitleFromMd } from '../../shared/doc-title.js';
|
|
22
24
|
import fsp from 'node:fs/promises';
|
|
23
25
|
import path from 'node:path';
|
|
@@ -39,6 +41,11 @@ export interface DocSummary {
|
|
|
39
41
|
name: string;
|
|
40
42
|
title: string;
|
|
41
43
|
size: number;
|
|
44
|
+
/** v6:normal | legacy | external | empty(后三类不是正常文档) */
|
|
45
|
+
relKind: RelKind;
|
|
46
|
+
hasBody: boolean;
|
|
47
|
+
missing?: boolean;
|
|
48
|
+
reason?: string;
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
/** docs list 的出参。 */
|
|
@@ -62,6 +69,9 @@ export interface DocGetResult {
|
|
|
62
69
|
dir?: boolean;
|
|
63
70
|
files?: string[];
|
|
64
71
|
external?: boolean;
|
|
72
|
+
/** v6:条目类别;没有正文时与 reason 一起返回 missing 语义 */
|
|
73
|
+
relKind?: RelKind;
|
|
74
|
+
reason?: string;
|
|
65
75
|
}
|
|
66
76
|
|
|
67
77
|
/** doc add / update 的入参(body-file 只给 CLI)。 */
|
|
@@ -88,15 +98,20 @@ export interface DocWriteResult {
|
|
|
88
98
|
// 树索引(零副作用,不播种——agent/前端拿它当双链解析的数据源)
|
|
89
99
|
export async function listDocs({ external }: { external?: boolean } = {}): Promise<ListDocsResult> {
|
|
90
100
|
const docs: DocSummary[] = [];
|
|
91
|
-
|
|
101
|
+
// includeEmpty:历史空壳 / 外部镜像 / 无正文行也要出现在清单里,但必须显式标注,
|
|
102
|
+
// 不能让它们看起来像正常文档(v6 验收项)。
|
|
103
|
+
for (const f of await store.listOwnDocs({ includeEmpty: true })) {
|
|
92
104
|
// #168:标题口径 = 正文**首行**的 `# 标题`(与文档页/附件清单同一口径)
|
|
93
|
-
const title =
|
|
105
|
+
const title = f.hasBody ? docTitleFromMd(f.body ?? '') : '';
|
|
94
106
|
docs.push({
|
|
95
107
|
docId: paths.ownDocId(f.rel),
|
|
96
108
|
rel: f.rel,
|
|
97
109
|
name: f.rel.replace(/\.md$/i, '').split('/').pop() ?? '',
|
|
98
110
|
title,
|
|
99
111
|
size: f.size,
|
|
112
|
+
relKind: f.relKind,
|
|
113
|
+
hasBody: f.hasBody,
|
|
114
|
+
...(f.hasBody ? {} : { missing: true, reason: noBodyReason(f.relKind) }),
|
|
100
115
|
});
|
|
101
116
|
}
|
|
102
117
|
const out: ListDocsResult = { docs, count: docs.length };
|
|
@@ -116,17 +131,31 @@ export async function getDoc({ ref }: { ref?: unknown } = {}): Promise<DocGetRes
|
|
|
116
131
|
if (!clean(ref)) throw badInput('请给文档标识:自有 rel:<路径>(或裸相对路径),外部 path:<绝对路径>');
|
|
117
132
|
const parsed = paths.parseDocId(ref);
|
|
118
133
|
if (parsed.kind === 'own') {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
134
|
+
const state = await store.ownDocState(parsed.rel);
|
|
135
|
+
if (state.exists && state.hasBody) return outOwn(parsed.rel, state.body ?? '', state.relKind);
|
|
136
|
+
// v6:有行但没有正文(历史空壳 / 外部镜像 / 正文缺失)→ 显式 missing + 原因,
|
|
137
|
+
// 不返回空文档成功态,也不把壳行播种成新文档。
|
|
138
|
+
if (state.exists) {
|
|
139
|
+
return {
|
|
140
|
+
docId: paths.ownDocId(parsed.rel),
|
|
141
|
+
rel: parsed.rel,
|
|
142
|
+
missing: true,
|
|
143
|
+
writable: false,
|
|
144
|
+
title: '',
|
|
145
|
+
summary: '',
|
|
146
|
+
body: '',
|
|
147
|
+
relKind: state.relKind,
|
|
148
|
+
reason: state.reason,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
const seeded = await seed.ensureSeedForRel(parsed.rel);
|
|
152
|
+
if (seeded === null) {
|
|
153
|
+
return {
|
|
154
|
+
docId: paths.ownDocId(parsed.rel), rel: parsed.rel, missing: true, writable: true,
|
|
155
|
+
title: '', summary: '', body: '', relKind: 'empty', reason: '文档不存在',
|
|
156
|
+
};
|
|
128
157
|
}
|
|
129
|
-
return outOwn(parsed.rel,
|
|
158
|
+
return outOwn(parsed.rel, seeded, 'normal');
|
|
130
159
|
}
|
|
131
160
|
// 外部:先过绑定闭包,闭包外一律拒绝——doc.get 不能变成任意文件读入口
|
|
132
161
|
const { loadStore } = await reposBridge();
|
|
@@ -225,7 +254,7 @@ export async function removeDoc({ ref }: { ref?: unknown } = {}): Promise<{ docI
|
|
|
225
254
|
|
|
226
255
|
// ─── 出参整形 ──────────────────────────────────────────────────────────
|
|
227
256
|
|
|
228
|
-
function outOwn(rel: string, body: string): DocGetResult {
|
|
257
|
+
function outOwn(rel: string, body: string, relKind: RelKind = 'normal'): DocGetResult {
|
|
229
258
|
const { summaryFromMd } = seed;
|
|
230
259
|
// #168:标题 = 正文**首行**的 `# 标题`(不是「任意位置的首个 # 行」——
|
|
231
260
|
// 那样正文中间插一行 ## 就会改标题;也不是「首个非空行」——那会让正文
|
|
@@ -237,6 +266,7 @@ function outOwn(rel: string, body: string): DocGetResult {
|
|
|
237
266
|
summary: summaryFromMd(body),
|
|
238
267
|
body,
|
|
239
268
|
writable: true,
|
|
269
|
+
relKind,
|
|
240
270
|
};
|
|
241
271
|
}
|
|
242
272
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
//
|
|
1
|
+
// 文档存储原语:自有文档 CRUD(DB 唯一真相)+ 外部绑定闭包。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// **自有文档**(v6 + DOCS_DIR 收口):正文唯一真相在 `ref_bodies`,`refs.rel` 是逻辑名。
|
|
4
|
+
// `~/.nx-kv/docs/`(见 core/paths 的 mdfile 默认目录函数)**不再是文档镜像**,只是 mdfile 默认附件目录;
|
|
5
|
+
// 读入口只认 DB,写入口只写 DB。
|
|
4
6
|
// **外部绑定**:repos.json 里登记的外部绝对路径(文件或目录),只读引用——
|
|
5
7
|
// 「绑定闭包」= 全部外部路径的集合,外部读取只允许落在闭包内:
|
|
6
8
|
// 少了这道闸,`docs get path:D:\任意文件` 就成了任意文件读入口。
|
|
@@ -9,20 +11,32 @@
|
|
|
9
11
|
import { join } from 'node:path';
|
|
10
12
|
import fsp from 'node:fs/promises';
|
|
11
13
|
import type { Stats } from 'node:fs';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
+
import { createHash } from 'node:crypto';
|
|
15
|
+
import { assertOwnedRel, assertDocRel, ownDocId, extDocId } from './paths.js';
|
|
14
16
|
import { notFound } from '../../core/errors.js';
|
|
15
17
|
import { getDb } from '../../core/db/index.js';
|
|
16
18
|
import { tx } from '../../core/db/tx.js';
|
|
17
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
ensureDocRef,
|
|
21
|
+
forgetDocRef,
|
|
22
|
+
noBodyReason,
|
|
23
|
+
refDocByRel,
|
|
24
|
+
relKindOf,
|
|
25
|
+
syncRefAttachments,
|
|
26
|
+
upsertRefBody,
|
|
27
|
+
} from '../../core/attachmentdb.js';
|
|
28
|
+
import type { RelKind } from '../../core/attachmentdb.js';
|
|
18
29
|
|
|
19
|
-
/**
|
|
30
|
+
/** 自有文档的一行(正文可能不在库内:历史空壳 / 外部镜像 / 无正文)。 */
|
|
20
31
|
export interface OwnDocRow {
|
|
21
32
|
rel: string;
|
|
22
|
-
abs: string;
|
|
23
33
|
size: number;
|
|
24
|
-
/**
|
|
34
|
+
/** 正文 md5(列表默认口径需要;没有正文时缺省) */
|
|
25
35
|
md5?: string;
|
|
36
|
+
body?: string;
|
|
37
|
+
hasBody: boolean;
|
|
38
|
+
origin: string;
|
|
39
|
+
relKind: RelKind;
|
|
26
40
|
}
|
|
27
41
|
|
|
28
42
|
/** 介绍目录内的文档(listOwnDocsIn 产出,rel 相对自有树根)。 */
|
|
@@ -30,6 +44,17 @@ export interface OwnDocRowIn extends OwnDocRow {
|
|
|
30
44
|
name: string;
|
|
31
45
|
}
|
|
32
46
|
|
|
47
|
+
/** 自有文档的读状态(docs get / 交付清单区分「无正文」用)。 */
|
|
48
|
+
export interface OwnDocState {
|
|
49
|
+
rel: string;
|
|
50
|
+
exists: boolean;
|
|
51
|
+
hasBody: boolean;
|
|
52
|
+
body: string | null;
|
|
53
|
+
relKind: RelKind;
|
|
54
|
+
origin: string;
|
|
55
|
+
reason: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
33
58
|
/** 外部绑定闭包条目(externalClosure 产出)。 */
|
|
34
59
|
export interface ClosureEntry {
|
|
35
60
|
path: string;
|
|
@@ -42,75 +67,104 @@ export interface ClosureEntry {
|
|
|
42
67
|
// 外部目录枚举的跳过名单(Obsidian vault 里也有 .obsidian / node_modules 这类噪音)
|
|
43
68
|
const SKIP_DIRS = new Set(['node_modules', '.git', '.obsidian', '.trash', 'dist', 'build', '__pycache__', '.venv']);
|
|
44
69
|
|
|
45
|
-
//
|
|
46
|
-
// 串行化避免并发写互相覆盖)。
|
|
47
|
-
let writeQueue: Promise<void> = Promise.resolve();
|
|
48
|
-
function queuedWrite(abs: string, data: string): Promise<void> {
|
|
49
|
-
const run = writeQueue.then(async () => {
|
|
50
|
-
await fsp.mkdir(join(abs, '..'), { recursive: true });
|
|
51
|
-
const tmp = abs + '.tmp';
|
|
52
|
-
await fsp.writeFile(tmp, data, 'utf8');
|
|
53
|
-
for (let i = 0; ; i++) {
|
|
54
|
-
try {
|
|
55
|
-
await fsp.rename(tmp, abs);
|
|
56
|
-
return;
|
|
57
|
-
} catch (err) {
|
|
58
|
-
const e = err as NodeJS.ErrnoException;
|
|
59
|
-
if (i >= 4 || (e.code !== 'EPERM' && e.code !== 'EACCES')) throw err;
|
|
60
|
-
await new Promise((r) => setTimeout(r, 25 * (i + 1)));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
writeQueue = run.then(
|
|
65
|
-
() => {},
|
|
66
|
-
() => {}
|
|
67
|
-
);
|
|
68
|
-
return run;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// ─── 自有树 CRUD ───────────────────────────────────────────────────────
|
|
70
|
+
// ─── 自有文档 CRUD(v6:DB 唯一真相,不落盘)───────────────────────────
|
|
72
71
|
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
/**
|
|
73
|
+
* 自有文档列表。默认只给「有正文且非 legacy/external」的正常文档
|
|
74
|
+
* (导出 / 双链 / 知识聚合的口径);`includeEmpty: true` 连历史空壳、
|
|
75
|
+
* 外部镜像、无正文行一起给(`docs list` 用,调用方必须显式标注)。
|
|
76
|
+
*/
|
|
77
|
+
export async function listOwnDocs({ includeEmpty = false }: { includeEmpty?: boolean } = {}): Promise<OwnDocRow[]> {
|
|
78
|
+
const db = getDb();
|
|
79
|
+
const rows: any[] = db.all(
|
|
80
|
+
`SELECT r.rel, r.origin, r.body_bytes,
|
|
81
|
+
CASE WHEN b.ref_id IS NULL THEN 0 ELSE 1 END AS has_body,
|
|
82
|
+
b.body
|
|
83
|
+
FROM refs r
|
|
84
|
+
LEFT JOIN ref_bodies b ON b.ref_id = r.id
|
|
85
|
+
WHERE r.deleted_at IS NULL AND r.rel <> ''
|
|
86
|
+
ORDER BY r.rel`
|
|
87
|
+
);
|
|
78
88
|
const out: OwnDocRow[] = [];
|
|
79
|
-
for (const
|
|
80
|
-
|
|
81
|
-
|
|
89
|
+
for (const row of rows) {
|
|
90
|
+
const rel = String(row.rel || '');
|
|
91
|
+
const hasBody = Number(row.has_body) === 1;
|
|
92
|
+
const relKind = relKindOf(rel, hasBody);
|
|
93
|
+
if (!includeEmpty && (!hasBody || relKind !== 'normal')) continue;
|
|
94
|
+
const body = hasBody ? String(row.body ?? '') : undefined;
|
|
95
|
+
out.push({
|
|
96
|
+
rel,
|
|
97
|
+
size: Number(row.body_bytes) || 0,
|
|
98
|
+
hasBody,
|
|
99
|
+
origin: String(row.origin || ''),
|
|
100
|
+
relKind,
|
|
101
|
+
...(body === undefined
|
|
102
|
+
? {}
|
|
103
|
+
: { body, md5: createHash('md5').update(body, 'utf8').digest('hex') }),
|
|
104
|
+
});
|
|
82
105
|
}
|
|
83
|
-
return out
|
|
106
|
+
return out;
|
|
84
107
|
}
|
|
85
108
|
|
|
109
|
+
/** 自有文档是否有正文(v6 起存在性 = ref_bodies 有行)。 */
|
|
86
110
|
export async function ownDocExists(rel: string): Promise<boolean> {
|
|
87
|
-
const norm =
|
|
88
|
-
|
|
111
|
+
const norm = assertDocRel(rel);
|
|
112
|
+
const row = getDb().get(
|
|
113
|
+
`SELECT 1 AS x FROM refs r JOIN ref_bodies b ON b.ref_id = r.id
|
|
114
|
+
WHERE r.rel = :rel AND r.deleted_at IS NULL`,
|
|
115
|
+
{ rel: norm }
|
|
116
|
+
);
|
|
117
|
+
return !!row;
|
|
89
118
|
}
|
|
90
119
|
|
|
91
|
-
/**
|
|
92
|
-
export async function
|
|
93
|
-
const norm =
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
120
|
+
/** 自有文档的完整读状态(区分 normal / legacy / external / empty)。 */
|
|
121
|
+
export async function ownDocState(rel: string): Promise<OwnDocState> {
|
|
122
|
+
const norm = assertDocRel(rel);
|
|
123
|
+
const row = refDocByRel(getDb(), norm);
|
|
124
|
+
if (!row) {
|
|
125
|
+
return {
|
|
126
|
+
rel: norm, exists: false, hasBody: false, body: null,
|
|
127
|
+
relKind: 'empty', origin: '', reason: '文档不存在',
|
|
128
|
+
};
|
|
100
129
|
}
|
|
130
|
+
return {
|
|
131
|
+
rel: norm,
|
|
132
|
+
exists: true,
|
|
133
|
+
hasBody: row.hasBody,
|
|
134
|
+
body: row.body,
|
|
135
|
+
relKind: row.relKind,
|
|
136
|
+
origin: row.origin,
|
|
137
|
+
reason: row.hasBody ? '' : noBodyReason(row.relKind),
|
|
138
|
+
};
|
|
101
139
|
}
|
|
102
140
|
|
|
103
|
-
/**
|
|
141
|
+
/** 读自有文档正文(utf8)。没有正文 / 不存在抛 notFound。 */
|
|
142
|
+
export async function readOwnDoc(rel: string): Promise<string> {
|
|
143
|
+
const norm = assertDocRel(rel);
|
|
144
|
+
const row = getDb().get(
|
|
145
|
+
`SELECT b.body AS body FROM refs r JOIN ref_bodies b ON b.ref_id = r.id
|
|
146
|
+
WHERE r.rel = :rel AND r.deleted_at IS NULL`,
|
|
147
|
+
{ rel: norm }
|
|
148
|
+
);
|
|
149
|
+
if (!row) throw notFound('文档不存在: ' + norm);
|
|
150
|
+
return String(row.body ?? '');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 写自有文档:正文进 ref_bodies(唯一真相)。磁盘不落任何副本。
|
|
155
|
+
* 返回归一化 rel,调用方应使用返回值。
|
|
156
|
+
*/
|
|
104
157
|
export async function writeOwnDoc(rel: string, body: unknown): Promise<string> {
|
|
105
158
|
const norm = assertOwnedRel(rel);
|
|
106
159
|
const text = String(body ?? '');
|
|
107
|
-
await queuedWrite(join(docsRoot(), ...norm.split('/')), text);
|
|
108
|
-
// 文档正文里用到的资源立刻进 ref_attach:不论从 CLI、面板还是别的模块写盘,
|
|
109
|
-
// 都在这个唯一落盘口同步,避免「有的入口写了关系、有的没写」。
|
|
110
160
|
const db = getDb();
|
|
111
161
|
tx(
|
|
112
162
|
(conn) => {
|
|
113
|
-
const refId = ensureDocRef(conn, {
|
|
163
|
+
const refId = ensureDocRef(conn, { rel: norm });
|
|
164
|
+
if (!refId) return;
|
|
165
|
+
upsertRefBody(conn, { refId, body: text });
|
|
166
|
+
// 正文里用到的资源立刻进 ref_attach:不论从 CLI、面板还是别的模块写入,
|
|
167
|
+
// 都在这个唯一入口同步,避免「有的入口写了关系、有的没写」。
|
|
114
168
|
syncRefAttachments(conn, { refId, text });
|
|
115
169
|
},
|
|
116
170
|
{ db, mode: 'IMMEDIATE' }
|
|
@@ -118,22 +172,14 @@ export async function writeOwnDoc(rel: string, body: unknown): Promise<string> {
|
|
|
118
172
|
return norm;
|
|
119
173
|
}
|
|
120
174
|
|
|
121
|
-
/**
|
|
175
|
+
/** 删自有文档(DB 行)。没有正文条目抛 notFound。 */
|
|
122
176
|
export async function removeOwnDoc(rel: string): Promise<string> {
|
|
123
177
|
const norm = assertOwnedRel(rel);
|
|
124
|
-
const abs = join(docsRoot(), ...norm.split('/'));
|
|
125
|
-
try {
|
|
126
|
-
await fsp.unlink(abs);
|
|
127
|
-
} catch (err) {
|
|
128
|
-
const e = err as NodeJS.ErrnoException;
|
|
129
|
-
if (e && e.code === 'ENOENT') throw notFound('文档不存在: ' + norm);
|
|
130
|
-
throw err;
|
|
131
|
-
}
|
|
132
|
-
await fsp.unlink(abs + '.tmp').catch(() => {});
|
|
133
|
-
// 文档删除 = refs 行删除(ref_bindings / ref_attach 由 FK CASCADE 跟着走),
|
|
134
|
-
// 它引用过的资源因此变成可列出的孤儿,交给 file orphans / prune 回收。
|
|
135
178
|
const db = getDb();
|
|
136
|
-
|
|
179
|
+
// 文档删除 = refs 行删除(ref_bodies / ref_bindings / ref_attach 由 FK CASCADE 跟着走),
|
|
180
|
+
// 它引用过的资源因此变成可列出的孤儿,交给 file orphans / prune 回收。
|
|
181
|
+
const removed = tx((conn) => forgetDocRef(conn, norm), { db, mode: 'IMMEDIATE' });
|
|
182
|
+
if (!removed) throw notFound('文档不存在: ' + norm);
|
|
137
183
|
return norm;
|
|
138
184
|
}
|
|
139
185
|
|
|
@@ -256,7 +302,7 @@ export async function listOwnDocsIn(dirRel: string): Promise<OwnDocRowIn[]> {
|
|
|
256
302
|
const out: OwnDocRowIn[] = [];
|
|
257
303
|
for (const d of await listOwnDocs()) {
|
|
258
304
|
if (!d.rel.startsWith(prefix)) continue;
|
|
259
|
-
out.push({
|
|
305
|
+
out.push({ ...d, name: d.rel.slice(prefix.length) });
|
|
260
306
|
}
|
|
261
307
|
return out;
|
|
262
308
|
}
|
|
@@ -55,8 +55,8 @@ export function renderTaskAttachments(d: RenderInput): string {
|
|
|
55
55
|
for (const a of rows) {
|
|
56
56
|
const docMark = a.role === 'doc' ? ' 〔进原文〕' : '';
|
|
57
57
|
const noteMark = a.note ? ` # ${a.note}` : '';
|
|
58
|
-
lines.push(` ${a.kind === 'image' ? '图片' : a.kind === 'url' ? '链接' : a.kind === 'task' ? '任务' : a.kind === 'ref' ? '文档' : '附件'} ${a.name} [${a.id}]${docMark}${noteMark}`);
|
|
59
|
-
lines.push(` ${a.localPath || a.url || a.target || '(未同步;nx-kv file sync --ids ' + a.id + ')'}`);
|
|
58
|
+
lines.push(` ${a.kind === 'image' ? '图片' : a.kind === 'url' ? '链接' : a.kind === 'task' ? '任务' : a.kind === 'ref' ? '文档' : a.kind === 'mdfile' ? 'md' : '附件'} ${a.name} [${a.id}]${docMark}${noteMark}`);
|
|
59
|
+
lines.push(` ${a.localPath || a.url || (a.kind === 'mdfile' ? a.absPath : '') || a.target || '(未同步;nx-kv file sync --ids ' + a.id + ')'}${a.kind === 'mdfile' && a.missing ? ' (源文件已不在)' : ''}`);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
return lines.join('\n');
|
|
@@ -15,6 +15,7 @@ const input = z.object({
|
|
|
15
15
|
url: z.string().optional().describe("外部链接(http/https;kind=url)"),
|
|
16
16
|
task: z.string().optional().describe("同主题下的任务编号(kind=task,落 nxkv://task/<id>)"),
|
|
17
17
|
ref: z.string().optional().describe("文档路径或 ref id(kind=ref,落 nxkv://ref/<refId>)"),
|
|
18
|
+
mdfile: z.string().optional().describe("本地 .md 文件路径(kind=mdfile:只登记指针,不复制正文;web 的 md 栏按此过滤)"),
|
|
18
19
|
inline: z.boolean().optional().describe("文档进原文:交付时附全文(截断 2 万字)而不是只给路径;仅 --ref 有效"),
|
|
19
20
|
name: z.string().optional().describe("显示名 / 本地文件名(默认取原名)"),
|
|
20
21
|
kind: z.string().optional().describe("image | file(仅 --path/--fileId 用;不给按扩展名判)"),
|
|
@@ -28,10 +29,10 @@ export class LocaltaskAttachAction extends ActionBase<typeof input> {
|
|
|
28
29
|
id: 'localtask.attach',
|
|
29
30
|
cli: ['localtask', 'attach'],
|
|
30
31
|
http: ['POST', '/api/localtasks/attach'],
|
|
31
|
-
summary: '给任务挂附件:--path 存本机附件仓 / --fileId 引用已有附件 / --url / --task(同主题任务)/ --ref
|
|
32
|
+
summary: '给任务挂附件:--path 存本机附件仓 / --fileId 引用已有附件 / --url / --task(同主题任务)/ --ref(文档)/ --mdfile(本地 md 指针);默认嵌进正文,--no-embed 只挂到附件区(不写正文),--ref 加 --inline 文档进原文(交付带全文)',
|
|
32
33
|
input,
|
|
33
34
|
render: (d: any) =>
|
|
34
|
-
`已附加 ${d.fileId}(${d.kind === 'image' ? '图片' : d.kind === 'url' ? '链接' : d.kind === 'task' ? '任务' : d.kind === 'ref' ? '文档' : '文件'})到主题「${d.name}」#${d.task.id} · ${d.role === 'doc' ? '文档资料(交付进原文)' : d.area === 'area' ? '附件区(未写正文)' : '正文内嵌'}${d.markdown ? `\n嵌入: ${d.markdown}` : ''}`,
|
|
35
|
+
`已附加 ${d.fileId}(${d.kind === 'image' ? '图片' : d.kind === 'url' ? '链接' : d.kind === 'task' ? '任务' : d.kind === 'ref' ? '文档' : d.kind === 'mdfile' ? 'md' : '文件'})到主题「${d.name}」#${d.task.id} · ${d.role === 'doc' ? '文档资料(交付进原文)' : d.area === 'area' ? '附件区(未写正文)' : '正文内嵌'}${d.markdown ? `\n嵌入: ${d.markdown}` : ''}`,
|
|
35
36
|
})
|
|
36
37
|
override async run(ctx: ActionInput<this['_input']>) {
|
|
37
38
|
|
|
@@ -45,6 +46,7 @@ export class LocaltaskAttachAction extends ActionBase<typeof input> {
|
|
|
45
46
|
url: ctx.url,
|
|
46
47
|
task: ctx.task,
|
|
47
48
|
ref: ctx.ref,
|
|
49
|
+
mdfile: ctx.mdfile,
|
|
48
50
|
inline: ctx.inline,
|
|
49
51
|
name: ctx.name,
|
|
50
52
|
kind: ctx.kind,
|
|
@@ -7,12 +7,10 @@
|
|
|
7
7
|
// **顺序:先建 refs 再绑 topic**(裁决原文)。绑定落库前先跑
|
|
8
8
|
// repo/refs.js 的 rebuildRefIndex 把文档索引(约定路径绑定 + 孤儿清单)
|
|
9
9
|
// 补齐 —— 队列绑到仓库后,面板立刻要展示「这个仓库有哪些文档」,索引
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
import { join } from 'node:path';
|
|
13
|
-
import { listDocFiles } from '../../../core/db/import-json.js';
|
|
10
|
+
// 不能等到那时才现建。文档清单与正文从 DB 取(v6 起正文只存 ref_bodies),
|
|
11
|
+
// 事务体内只有写库。
|
|
14
12
|
import { nowMs } from '../../../core/db/time.js';
|
|
15
|
-
import {
|
|
13
|
+
import { listOwnDocs } from '../../docs/store.js';
|
|
16
14
|
import repoLayer from '../repo/index.js';
|
|
17
15
|
import { loadStore } from './store.js';
|
|
18
16
|
import { deriveKey } from './identity.js';
|
|
@@ -48,11 +46,6 @@ export type BindTopicsResult =
|
|
|
48
46
|
refs: { refs: number; bindings: number };
|
|
49
47
|
};
|
|
50
48
|
|
|
51
|
-
/** 文档索引的树根(与 docs/paths 的 NX_KV_DOCS_DIR 覆盖同一口径)。 */
|
|
52
|
-
export function docsIndexRoot(): string {
|
|
53
|
-
return process.env.NX_KV_DOCS_DIR || join(APP_DIR, 'docs');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
49
|
/**
|
|
57
50
|
* 按路径前缀把哨兵上的队列绑到真实仓库。
|
|
58
51
|
*
|
|
@@ -75,16 +68,13 @@ export async function bindTopicsToRepos({ repo: repoLocator = '', apply = false
|
|
|
75
68
|
.map((r) => ({ key: deriveKey(r), name: r.name, prefix: normalizePathKey(r.path) }))
|
|
76
69
|
.filter((x) => x.prefix);
|
|
77
70
|
|
|
78
|
-
//
|
|
79
|
-
const docsFiles =
|
|
71
|
+
// 文档清单与正文都从 DB 取(v6 起正文只存 ref_bodies,不再扫盘)。
|
|
72
|
+
const docsFiles: string[] = [];
|
|
80
73
|
const docsBodies = new Map<string, string>();
|
|
81
74
|
if (apply) {
|
|
82
|
-
for (const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
} catch {
|
|
86
|
-
/* 读不到就跳过资源同步,索引本身仍建 */
|
|
87
|
-
}
|
|
75
|
+
for (const d of await listOwnDocs()) {
|
|
76
|
+
docsFiles.push(d.rel);
|
|
77
|
+
if (d.body !== undefined) docsBodies.set(d.rel, d.body);
|
|
88
78
|
}
|
|
89
79
|
}
|
|
90
80
|
|
|
@@ -241,7 +241,8 @@ export async function repoExportZip(options: RepoExportOptions = {}): Promise<Bu
|
|
|
241
241
|
layout.warnings.push(`文档超过 2MB 未打包: ${f.rel}`);
|
|
242
242
|
continue;
|
|
243
243
|
}
|
|
244
|
-
|
|
244
|
+
// 正文只从 DB 取(v6 起不再有磁盘副本)
|
|
245
|
+
docEntries.push({ name: 'docs/' + f.rel, data: Buffer.from(f.body ?? '', 'utf8') });
|
|
245
246
|
}
|
|
246
247
|
// zip 内清单进 layout(diff 展示用;实际内容就是 zip 条目本身)
|
|
247
248
|
layout.docs = { files: docEntries.map((e) => e.name.slice('docs/'.length)) };
|
|
@@ -262,6 +263,8 @@ export async function repoExportZip(options: RepoExportOptions = {}): Promise<Bu
|
|
|
262
263
|
' - 看板以 board/<名称> 为 key;关系与组内描述都在 layout.json 里',
|
|
263
264
|
' - docs/ 是自有文档树(项目/组介绍、组内描述),导入后原样恢复',
|
|
264
265
|
' - 外部绑定(如 Obsidian vault)只记引用,不在包里——路径缺失会标「待初始化」',
|
|
266
|
+
' - 外部 md 文件(attachments.kind=mdfile)默认不打包:它们只是路径指针,字节不在库内',
|
|
267
|
+
' (条目在本地 attachments 表里,换机后需按原路径重新登记)',
|
|
265
268
|
'',
|
|
266
269
|
`仓库 ${layout.repos.length} 个 / 看板 ${layout.boards.length} 个 / 关系 ${layout.links.length} 条 / 文档 ${docEntries.length} 份`,
|
|
267
270
|
].join('\n');
|