nx-kv 0.50.0 → 0.52.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 +69 -0
- package/README.md +6 -5
- package/assets/nx-kv/SKILL.md +1 -1
- package/assets/nx-kv/references/localtask-commands.md +4 -4
- package/package.json +2 -1
- package/src/core/attachmentdb/bodies.ts +44 -76
- package/src/core/attachmentdb/docs.ts +68 -96
- package/src/core/attachmentdb/resources.ts +3 -3
- package/src/core/attachmentdb.ts +3 -5
- package/src/core/contract-snapshot.ts +24 -0
- package/src/core/contract-types.ts +106 -0
- package/src/core/db/import-json/refs.ts +17 -23
- package/src/core/db/migrations/index.ts +3 -0
- package/src/core/db/migrations/v8-data.ts +497 -0
- package/src/core/db/migrations/v8.sql +12 -0
- package/src/core/db/version.ts +5 -1
- package/src/core/fstree.ts +9 -9
- package/src/modules/docs/actions/_manifest.generated.ts +0 -6
- package/src/modules/docs/actions/doc-get.ts +1 -1
- package/src/modules/docs/actions/doc-remove.ts +1 -1
- package/src/modules/docs/actions/docs-bind.ts +5 -5
- package/src/modules/docs/actions/docs-bindings.ts +20 -26
- package/src/modules/docs/actions/docs-link.ts +3 -2
- package/src/modules/docs/actions/docs-notebind.ts +5 -5
- package/src/modules/docs/attach.ts +21 -35
- package/src/modules/docs/brief.ts +85 -108
- package/src/modules/docs/docref.ts +27 -71
- package/src/modules/docs/knowledge-md.ts +1 -5
- package/src/modules/docs/knowledge.ts +155 -343
- package/src/modules/docs/links.ts +9 -17
- package/src/modules/docs/paths.ts +14 -99
- package/src/modules/docs/ref-sync.ts +37 -76
- package/src/modules/docs/refs.ts +66 -81
- package/src/modules/docs/render.ts +15 -21
- package/src/modules/docs/seed.ts +3 -146
- package/src/modules/docs/service.ts +223 -208
- package/src/modules/docs/store.ts +75 -120
- package/src/modules/localtask/actions/localtask-list.ts +39 -0
- package/src/modules/localtask/board-target.ts +10 -15
- package/src/modules/repos/actions/repo-bind-topics.ts +0 -1
- package/src/modules/repos/actions/repo-doc-add.ts +4 -6
- package/src/modules/repos/actions/repo-doc-list.ts +3 -4
- package/src/modules/repos/boards/core.ts +71 -69
- package/src/modules/repos/boards/docs.ts +39 -29
- package/src/modules/repos/cli/render.ts +4 -4
- package/src/modules/repos/repo/refs.ts +1 -69
- package/src/modules/repos/service/bind-topics.ts +1 -20
- package/src/modules/repos/service/crud.ts +38 -40
- package/src/modules/repos/transfer/diff.ts +12 -12
- package/src/modules/repos/transfer/export.ts +71 -14
- package/src/modules/repos/transfer/import.ts +42 -15
- package/src/modules/repos/transfer/layout.ts +33 -2
- package/src/modules/repos/transfer/render.ts +3 -3
- package/src/modules/system/actions/_manifest.generated.ts +3 -0
- package/src/modules/system/actions/bootstrap.ts +25 -0
- package/src/modules/system/actions/contract.ts +58 -0
- package/src/modules/tasktool/attach-resource.ts +7 -6
- package/src/modules/tasktool/attach.ts +3 -8
- package/src/modules/tasktool/doc-inline.ts +25 -54
- package/src/modules/tasktool/groupctx.ts +7 -7
- package/src/runtime/action-decorator.ts +20 -2
- package/src/runtime/contract.ts +66 -0
- package/src/runtime/dartgen.ts +347 -0
- package/src/runtime/registry.ts +17 -0
- package/src/runtime/zod-bridge.ts +101 -17
- package/src/shared/wikilink.ts +4 -6
- package/src/web/frontend/App.tsx +17 -14
- package/src/web/frontend/api/cli-tree.json +20 -36
- package/src/web/frontend/api/client.generated.ts +14 -26
- package/src/web/frontend/components/Introduction/index.tsx +3 -4
- package/src/web/frontend/components/Introduction/use-intro.ts +48 -91
- package/src/web/frontend/components/layout/breadcrumb.tsx +44 -35
- package/src/web/frontend/components/layout/crumbs.ts +60 -0
- package/src/web/frontend/components/md/attach-common.ts +5 -6
- package/src/web/frontend/components/md/attach-modal.tsx +2 -2
- package/src/web/frontend/components/md/attach-picker.tsx +2 -2
- package/src/web/frontend/components/md/doc-keys.ts +53 -0
- package/src/web/frontend/components/md/md-panes-root.tsx +9 -2
- package/src/web/frontend/components/sidebar/index.tsx +99 -9
- package/src/web/frontend/components/sidebar/model.ts +18 -4
- package/src/web/frontend/components/sidebar/row-menu.tsx +9 -40
- package/src/web/frontend/components/toast/index.tsx +46 -3
- package/src/web/frontend/modules/md/md-render.ts +1 -1
- package/src/web/frontend/page/dir/task-actions.ts +20 -2
- package/src/web/frontend/page/doc/api.ts +20 -23
- package/src/web/frontend/page/doc/bindings.tsx +18 -40
- package/src/web/frontend/page/doc/index.tsx +46 -45
- package/src/web/frontend/page/doc/use-wiki-nav.ts +1 -1
- package/src/web/frontend/page/group/index.tsx +2 -2
- package/src/web/frontend/page/refs/api.ts +3 -4
- package/src/web/frontend/page/refs/index.tsx +15 -26
- package/src/web/frontend/page/repos/api.ts +3 -3
- package/src/web/frontend/page/repos/board-admin.tsx +4 -7
- package/src/web/frontend/page/repos/doc-search-modal.tsx +68 -69
- package/src/web/frontend/page/repos/filters-bar.tsx +1 -1
- package/src/web/frontend/page/repos/index.tsx +26 -21
- package/src/web/frontend/page/repos/repo-form-modal.tsx +2 -2
- package/src/web/frontend/page/repos/repo-table.tsx +15 -14
- package/src/web/frontend/repo-data.ts +49 -0
- package/src/web/frontend/routes/doc-ref.ts +3 -3
- package/src/web/frontend/styles/repos-admin.css +1 -10
- package/src/web/frontend/styles/repos.css +9 -2
- package/src/web/frontend/styles-v2/dag.css +12 -5
- package/src/web/public/assets/app-context-B0QwHGOd.js +1 -0
- package/src/web/public/assets/{bar-C2mfoqmj.js → bar-Di7RK1fB.js} +1 -1
- package/src/web/public/assets/{board-view-aAIEbSQi.js → board-view-BJCwrtHc.js} +1 -1
- package/src/web/public/assets/{composer-launch-eTktHT_f.js → composer-launch-yGr4Ayzx.js} +1 -1
- package/src/web/public/assets/{composer-panel-C0OOIXxz.js → composer-panel-U2jaQLVQ.js} +1 -1
- package/src/web/public/assets/{dag-Gm4RcvEg.js → dag-DISpxumr.js} +1 -1
- package/src/web/public/assets/dir-BY5ibEGY.js +3 -0
- package/src/web/public/assets/doc-DHi__8Em.js +6 -0
- package/src/web/public/assets/frontmatter-b044qTyx.js +2 -0
- package/src/web/public/assets/group-mIIARpRB.js +1 -0
- package/src/web/public/assets/index-DiOQ8kPZ.js +2 -0
- package/src/web/public/assets/index-j44oS8Y3.css +1 -0
- package/src/web/public/assets/md-history-wRTMWb12.js +39 -0
- package/src/web/public/assets/{md-parse-CLyUaUto.js → md-parse-Bqb35k5w.js} +1 -1
- package/src/web/public/assets/{member-picker-XT12VRe6.js → member-picker-CQksP35E.js} +1 -1
- package/src/web/public/assets/model-lEeblPg0.js +2 -0
- package/src/web/public/assets/overview-DPDbuE5d.js +1 -0
- package/src/web/public/assets/{progress-CNam3Wuj.js → progress-BRSLsiPg.js} +2 -2
- package/src/web/public/assets/refs-CZdjVlxE.js +2 -0
- package/src/web/public/assets/repo-form-modal-dO99i73A.js +1 -0
- package/src/web/public/assets/repos-BaE9B1it.js +14 -0
- package/src/web/public/assets/route-crumb-BHZU-2HE.js +1 -0
- package/src/web/public/assets/{settings-BIzumXLD.js → settings-BX78BaLf.js} +2 -2
- package/src/web/public/assets/status-tag-DC7mdpkI.js +1 -0
- package/src/web/public/assets/task-Cxa641GX.js +11 -0
- package/src/web/public/assets/task-row-3OXcmAJb.js +1 -0
- package/src/web/public/assets/{task-utils-DjODjVdc.js → task-utils-DSZKkq5e.js} +1 -1
- package/src/web/public/assets/{templates-j8EzXHXf.js → templates-CExLUDs6.js} +1 -1
- package/src/web/public/assets/{use-rail-drag-DNfz4Gcx.js → use-rail-drag-D-17tqYm.js} +1 -1
- package/src/web/public/assets/{workspace-D_G-B3TX.js → workspace-fCTiC3R4.js} +1 -1
- package/src/web/public/index.html +18 -10
- package/src/modules/docs/actions/doc-add.ts +0 -38
- package/src/modules/docs/actions/docs-seed.ts +0 -31
- package/src/web/frontend/components/repos/desc-modal.tsx +0 -293
- package/src/web/public/assets/Introduction-CohW6Xit.js +0 -6
- package/src/web/public/assets/app-context-BgpTewyA.js +0 -1
- package/src/web/public/assets/button-xyR2UROd.js +0 -1
- package/src/web/public/assets/dir-PjuMRbWo.js +0 -3
- package/src/web/public/assets/group-D94y_Lq6.js +0 -1
- package/src/web/public/assets/index-CBJKsJU3.css +0 -1
- package/src/web/public/assets/index-Crxdmsux.js +0 -2
- package/src/web/public/assets/md-history-CU_1I6ht.js +0 -39
- package/src/web/public/assets/model-CWJ8_2dN.js +0 -2
- package/src/web/public/assets/overview-BQm8BLCG.js +0 -1
- package/src/web/public/assets/refs-ClETk1cj.js +0 -2
- package/src/web/public/assets/repos-BioGejZo.js +0 -14
- package/src/web/public/assets/route-crumb-Fc68LcQ4.js +0 -1
- package/src/web/public/assets/status-tag-CBFf_-ae.js +0 -1
- package/src/web/public/assets/task-CGmO3I2y.js +0 -11
- package/src/web/public/assets/task-row-DRBa11tf.js +0 -1
- package/src/web/public/assets/task-status-BHF-y9Aq.js +0 -2
- package/src/web/public/assets/ui-Y0aL-bGk.js +0 -1
- /package/src/web/public/assets/{Introduction-Iuxssa-b.css → doc-Iuxssa-b.css} +0 -0
- /package/src/web/public/assets/{task-status-BZrdOH46.css → frontmatter-BZrdOH46.css} +0 -0
- /package/src/web/public/assets/{button-DA4lNJeC.css → repo-form-modal-DA4lNJeC.css} +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// 契约快照的发布格子:runtime 在装配完成后 publish,模块侧只读。
|
|
2
|
+
//
|
|
3
|
+
// 与 core/command-table.ts 同一套模式,解决同一个问题:
|
|
4
|
+
// registry → modules → (想读契约的 action)→ registry 成环。
|
|
5
|
+
// 去掉环的代价是「读的是快照」而不是「实时算」——契约在启动后不再变,
|
|
6
|
+
// 这个代价为零;真要实时算,`nx-kv contract` 也一样是读这份。
|
|
7
|
+
import type { ContractSnapshot } from './contract-types.js';
|
|
8
|
+
|
|
9
|
+
let current: ContractSnapshot | null = null;
|
|
10
|
+
|
|
11
|
+
/** 由 runtime/registry 在装配完成后调用(只保留最后一次写入)。 */
|
|
12
|
+
export function publishContractSnapshot(snapshot: ContractSnapshot): void {
|
|
13
|
+
current = snapshot;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** 当前契约快照;尚未发布时返回 null(纯 CLI 早期调用、单测里直接 build 的场景)。 */
|
|
17
|
+
export function contractSnapshot(): ContractSnapshot | null {
|
|
18
|
+
return current;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** 契约指纹(未发布时为 null):端侧启动自检、日志里打版本都用它。 */
|
|
22
|
+
export function contractHash(): string | null {
|
|
23
|
+
return current?.hash ?? null;
|
|
24
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// 契约快照的**数据类型**与纯函数(无 zod、无 fs、无 Node API)。
|
|
2
|
+
//
|
|
3
|
+
// 放在 core 的原因:`modules/system/actions/contract.ts` 要按契约发出快照、
|
|
4
|
+
// 而模块只允许依赖 core/shared(runtime 的装配层对它不可见)。类型与
|
|
5
|
+
// stableStringify/hash 都是纯的,天然属于 core。
|
|
6
|
+
//
|
|
7
|
+
// 谁生成:runtime/contract.ts(那里才有 zod)→ 由 registry 在装配完成后 publish,
|
|
8
|
+
// 模块侧只读 `core/contract-snapshot.ts` 的发布结果(与 command-table 同一套模式)。
|
|
9
|
+
import { createHash } from 'node:crypto';
|
|
10
|
+
|
|
11
|
+
/** 出参类型节点(JSON 安全;模型名内联,便于逐语言发射)。 */
|
|
12
|
+
export type TypeNode =
|
|
13
|
+
| { k: 'string' }
|
|
14
|
+
| { k: 'int' }
|
|
15
|
+
| { k: 'number' }
|
|
16
|
+
| { k: 'bool' }
|
|
17
|
+
| { k: 'unknown' }
|
|
18
|
+
| { k: 'enum'; name: string; values: string[] }
|
|
19
|
+
| { k: 'model'; name: string; fields: ModelField[] }
|
|
20
|
+
| { k: 'list'; of: TypeNode }
|
|
21
|
+
| { k: 'map'; of: TypeNode };
|
|
22
|
+
|
|
23
|
+
export interface ModelField {
|
|
24
|
+
name: string;
|
|
25
|
+
/** 没有 optional / default → 必填(Dart 侧是 `T` 与 `T?` 的差别) */
|
|
26
|
+
required: boolean;
|
|
27
|
+
type: TypeNode;
|
|
28
|
+
hint?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** 入参字段说明(由 runtime/zod-bridge 的 describeInput 产出,形状在这里定)。 */
|
|
32
|
+
export interface FieldDesc {
|
|
33
|
+
name: string;
|
|
34
|
+
kind: 'string' | 'number' | 'boolean' | 'enum' | 'array' | 'kv' | 'raw';
|
|
35
|
+
positional: boolean;
|
|
36
|
+
required: boolean;
|
|
37
|
+
default?: unknown;
|
|
38
|
+
enumValues?: string[];
|
|
39
|
+
hint?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** 快照里的一个 action(只含声明了 output 的——不对外就不在契约里)。 */
|
|
43
|
+
export interface ContractAction {
|
|
44
|
+
id: string;
|
|
45
|
+
/** CLI 路径(多路径别名会有多条) */
|
|
46
|
+
cli: string[][];
|
|
47
|
+
/** `GET /api/x` 形态;纯 CLI 为 null */
|
|
48
|
+
http: string | null;
|
|
49
|
+
summary?: string;
|
|
50
|
+
input: FieldDesc[];
|
|
51
|
+
output: TypeNode;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ContractSnapshot {
|
|
55
|
+
app: string;
|
|
56
|
+
version: string;
|
|
57
|
+
/** sha256(stableStringify({app, actions})) 的前 16 位 */
|
|
58
|
+
hash: string;
|
|
59
|
+
actions: ContractAction[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** 键排序的 JSON:同内容必然同字节(指纹/对账都靠这个性质)。 */
|
|
63
|
+
export function stableStringify(value: unknown): string {
|
|
64
|
+
const walk = (v: unknown): string => {
|
|
65
|
+
if (v === null) return 'null';
|
|
66
|
+
if (Array.isArray(v)) return '[' + v.map(walk).join(',') + ']';
|
|
67
|
+
if (typeof v === 'object') {
|
|
68
|
+
const obj = v as Record<string, unknown>;
|
|
69
|
+
const keys = Object.keys(obj).sort();
|
|
70
|
+
return '{' + keys.map((k) => JSON.stringify(k) + ':' + walk(obj[k])).join(',') + '}';
|
|
71
|
+
}
|
|
72
|
+
return JSON.stringify(v) ?? 'null';
|
|
73
|
+
};
|
|
74
|
+
return walk(value);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** 契约指纹:端侧拿它跟服务端对账。只覆盖 app + actions(改文案/发版不触发全端重建)。 */
|
|
78
|
+
export function hashOf(app: string, actions: readonly ContractAction[]): string {
|
|
79
|
+
// core 允许 node: 内置模块(只要不向上依赖);web 侧永远不会 import 本文件
|
|
80
|
+
return createHash('sha256').update(stableStringify({ app, actions })).digest('hex').slice(0, 16);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** 两份快照的结构化差异(人读;guard 与 PR 正文用它)。 */
|
|
84
|
+
export function diffContracts(
|
|
85
|
+
oldSnap: ContractSnapshot | null,
|
|
86
|
+
newSnap: ContractSnapshot,
|
|
87
|
+
): string[] {
|
|
88
|
+
if (!oldSnap) return [`- 旧快照缺失,按全量新增处理(${newSnap.actions.length} 个 action)`];
|
|
89
|
+
const o = new Map(oldSnap.actions.map((a) => [a.id, a]));
|
|
90
|
+
const n = new Map(newSnap.actions.map((a) => [a.id, a]));
|
|
91
|
+
const lines: string[] = [];
|
|
92
|
+
for (const [id, a] of n) {
|
|
93
|
+
const prev = o.get(id);
|
|
94
|
+
if (!prev) {
|
|
95
|
+
lines.push(`+ ${id}`);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (stableStringify(prev) !== stableStringify(a)) {
|
|
99
|
+
if (prev.http !== a.http) lines.push(`~ ${id}: ${prev.http} → ${a.http}`);
|
|
100
|
+
if (stableStringify(prev.input) !== stableStringify(a.input)) lines.push(`~ ${id}: 入参变化`);
|
|
101
|
+
if (stableStringify(prev.output) !== stableStringify(a.output)) lines.push(`~ ${id}: 出参变化`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
for (const id of o.keys()) if (!n.has(id)) lines.push(`- ${id}`);
|
|
105
|
+
return lines;
|
|
106
|
+
}
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
// 2. `docs/` 树扫描(未被任何 DocRef 指到的 → state='orphan')
|
|
4
4
|
// `ref_relations` 本轮留空。
|
|
5
5
|
import { existsSync, readdirSync } from 'node:fs';
|
|
6
|
-
import {
|
|
7
|
-
import { isAbsolute, join, resolve, sep } from 'node:path';
|
|
6
|
+
import { join, sep } from 'node:path';
|
|
8
7
|
import { groupKeyOf } from '../../keys.js';
|
|
9
8
|
import { refIdOf } from './data.js';
|
|
10
9
|
import type { ImportReport } from './data.js';
|
|
@@ -20,15 +19,8 @@ interface DocRefEntry {
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
/** docs 树的相对路径 → POSIX(库里的地址永远是正斜杠)。 */
|
|
23
|
-
function toPosix(
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** 外部绝对路径 / URL → v6 的逻辑 rel(与 v6-data 同一口径)。 */
|
|
28
|
-
function externalRel(locator: string): string {
|
|
29
|
-
let seed = isAbsolute(locator) ? toPosix(resolve(locator)) : locator;
|
|
30
|
-
if (/^[A-Z]:/.test(seed)) seed = seed.charAt(0).toLowerCase() + seed.slice(1);
|
|
31
|
-
return 'external/' + createHash('sha1').update(seed, 'utf8').digest('hex').slice(0, 16);
|
|
22
|
+
function toPosix(legacyPath: string): string {
|
|
23
|
+
return legacyPath.split(sep).join('/');
|
|
32
24
|
}
|
|
33
25
|
|
|
34
26
|
/** 递归收集旧文档目录里的 .md(返回 POSIX 相对路径)。**仅 legacy JSON 导入用。** */
|
|
@@ -67,12 +59,15 @@ export function importRefs(
|
|
|
67
59
|
): void {
|
|
68
60
|
const files = listDocFiles(docsDir);
|
|
69
61
|
const fileSet = new Set(files);
|
|
62
|
+
const idOfLocator = (locator: string): string => {
|
|
63
|
+
const hit = db.get('SELECT id FROM refs WHERE locator = :loc AND deleted_at IS NULL ORDER BY id LIMIT 1', { loc: locator });
|
|
64
|
+
return hit ? String(hit.id) : refIdOf(locator);
|
|
65
|
+
};
|
|
70
66
|
for (const locator of files) {
|
|
71
67
|
const r = db.run(
|
|
72
|
-
`INSERT INTO refs (id, type,
|
|
73
|
-
VALUES (:id, 'md', :
|
|
74
|
-
|
|
75
|
-
{ id: refIdOf(locator), rel: locator, locator, at: atMs }
|
|
68
|
+
`INSERT OR IGNORE INTO refs (id, type, locator, state, version, deleted_at, created_at, updated_at)
|
|
69
|
+
VALUES (:id, 'md', :locator, 'orphan', 0, NULL, :at, :at)`,
|
|
70
|
+
{ id: refIdOf(locator), locator, at: atMs }
|
|
76
71
|
);
|
|
77
72
|
if (Number(r.changes) > 0) report.imported.refs += 1;
|
|
78
73
|
}
|
|
@@ -107,7 +102,7 @@ export function importRefs(
|
|
|
107
102
|
note: string
|
|
108
103
|
): boolean => {
|
|
109
104
|
if (!fileSet.has(locator)) return false;
|
|
110
|
-
const id =
|
|
105
|
+
const id = idOfLocator(locator);
|
|
111
106
|
db.run(`UPDATE refs SET state = '' WHERE id = :id`, { id });
|
|
112
107
|
// ON CONFLICT 的冲突目标带表达式(COALESCE)在 SQLite 里要写成一模一样的表达式,
|
|
113
108
|
// 这里用 INSERT OR IGNORE:绑定边重复插是幂等的正常情况,不该报错。
|
|
@@ -128,9 +123,10 @@ export function importRefs(
|
|
|
128
123
|
const out: DocRefEntry[] = [];
|
|
129
124
|
const pushRef = (ref: any, note: string = ''): void => {
|
|
130
125
|
if (!ref || typeof ref !== 'object') return;
|
|
131
|
-
|
|
126
|
+
// 旧 JSON 里的键名就叫 rel(v6 之前的字段名);读出来一律当 **locator** 用。
|
|
127
|
+
const legacyPath = String(ref.rel || '').trim();
|
|
132
128
|
const path = String(ref.path || '').trim();
|
|
133
|
-
if (
|
|
129
|
+
if (legacyPath) out.push({ locator: legacyPath, type: 'md', note: String(ref.tag || note || ''), extPath: '' });
|
|
134
130
|
// v2 起 refs 只装文档:外部 .md 绝对路径也是文档,type 统一为 md。
|
|
135
131
|
else if (path) out.push({ locator: path, type: 'md', note: String(ref.tag || note || ''), extPath: path });
|
|
136
132
|
};
|
|
@@ -160,13 +156,11 @@ export function importRefs(
|
|
|
160
156
|
if (d.extPath) {
|
|
161
157
|
// 外部路径(Obsidian 等):只在库里留地址,字节在库外
|
|
162
158
|
db.run(
|
|
163
|
-
`INSERT INTO refs (id, type,
|
|
164
|
-
VALUES (:id, :type, :
|
|
165
|
-
ON CONFLICT(id) DO NOTHING`,
|
|
159
|
+
`INSERT OR IGNORE INTO refs (id, type, locator, origin, state, version, deleted_at, created_at, updated_at)
|
|
160
|
+
VALUES (:id, :type, :locator, 'external', '', 0, NULL, :at, :at)`,
|
|
166
161
|
{
|
|
167
162
|
id: refIdOf(d.locator),
|
|
168
163
|
type: d.type,
|
|
169
|
-
rel: externalRel(d.locator),
|
|
170
164
|
locator: d.locator,
|
|
171
165
|
at: atMs,
|
|
172
166
|
}
|
|
@@ -180,7 +174,7 @@ export function importRefs(
|
|
|
180
174
|
const br = db.run(
|
|
181
175
|
`INSERT OR IGNORE INTO ref_bindings (repo_key, group_key, ref_id, type, position, note, created_at)
|
|
182
176
|
VALUES (:repo, NULL, :ref, 'repo', :pos, :note, :at)`,
|
|
183
|
-
{ repo: key, ref:
|
|
177
|
+
{ repo: key, ref: idOfLocator(d.locator), pos: position, note: d.note, at: atMs }
|
|
184
178
|
);
|
|
185
179
|
if (Number(br.changes) > 0) report.imported.refBindings += 1;
|
|
186
180
|
position += 1;
|
|
@@ -17,6 +17,7 @@ import { readFileSync } from 'node:fs';
|
|
|
17
17
|
import { migrateAttachments } from './v2-data.js';
|
|
18
18
|
import { migrateGroupRefs } from './v4-data.js';
|
|
19
19
|
import { migrateRefsBodies } from './v6-data.js';
|
|
20
|
+
import { migrateRefsRel } from './v8-data.js';
|
|
20
21
|
import { CURRENT_SCHEMA_VERSION } from '../version.js';
|
|
21
22
|
import type { DbApi } from '../driver.js';
|
|
22
23
|
|
|
@@ -56,6 +57,7 @@ export const DIRECT_EDGES: MigrationStep[] = [
|
|
|
56
57
|
{ from: 4, to: 5, file: 'v5.sql', title: '附件新增 mdfile(本地 md 指针)' },
|
|
57
58
|
{ from: 5, to: 6, file: 'v6.sql', title: 'refs 正文入库(rel / ref_bodies / source)', apply: migrateRefsBodies },
|
|
58
59
|
{ from: 6, to: 7, file: 'v7.sql', title: 'refs 描述字段(desc)' },
|
|
60
|
+
{ from: 7, to: 8, file: 'v8.sql', title: '去 rel:ref 只按 id / locator 寻址(bindings 补 tag)', apply: migrateRefsRel },
|
|
59
61
|
];
|
|
60
62
|
|
|
61
63
|
// 人读版本说明(docs/decisions 是决策的唯一权威位置,里面对应一份 date 化的 .md)
|
|
@@ -67,6 +69,7 @@ export const VERSION_NOTES = {
|
|
|
67
69
|
5: 'docs/decisions/versions/2026-11-12-v5.md',
|
|
68
70
|
6: 'docs/decisions/versions/2026-11-12-v6.md',
|
|
69
71
|
7: 'docs/decisions/versions/2026-11-12-v7.md',
|
|
72
|
+
8: 'docs/decisions/versions/2026-11-13-v8.md',
|
|
70
73
|
};
|
|
71
74
|
|
|
72
75
|
const keyOf = (from: number, to: number): string => `${from}->${to}`;
|