dsh-data-domain-knowledge 0.1.0-alpha.2 → 0.1.0-alpha.3

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.
Files changed (117) hide show
  1. package/README.md +31 -7
  2. package/cordis.patch.yml +11 -5
  3. package/lib/client.js +5557 -3056
  4. package/lib/doc-page.js +7740 -0
  5. package/lib/types/convert/host.d.ts.map +1 -1
  6. package/lib/types/convert/host.js +36 -9
  7. package/lib/types/convert/host.js.map +1 -1
  8. package/lib/types/diagnosis/cards.d.ts +8 -7
  9. package/lib/types/diagnosis/cards.d.ts.map +1 -1
  10. package/lib/types/diagnosis/cards.js +119 -49
  11. package/lib/types/diagnosis/cards.js.map +1 -1
  12. package/lib/types/diagnosis/run.d.ts +51 -0
  13. package/lib/types/diagnosis/run.d.ts.map +1 -0
  14. package/lib/types/diagnosis/run.js +239 -0
  15. package/lib/types/diagnosis/run.js.map +1 -0
  16. package/lib/types/diagnosis/schema.d.ts +25 -2
  17. package/lib/types/diagnosis/schema.d.ts.map +1 -1
  18. package/lib/types/diagnosis/schema.js +64 -25
  19. package/lib/types/diagnosis/schema.js.map +1 -1
  20. package/lib/types/diagnosis/seed-source.d.ts +17 -2
  21. package/lib/types/diagnosis/seed-source.d.ts.map +1 -1
  22. package/lib/types/diagnosis/seed-source.js +18 -1
  23. package/lib/types/diagnosis/seed-source.js.map +1 -1
  24. package/lib/types/diagnosis/seed.d.ts +32 -42
  25. package/lib/types/diagnosis/seed.d.ts.map +1 -1
  26. package/lib/types/diagnosis/seed.js +187 -51
  27. package/lib/types/diagnosis/seed.js.map +1 -1
  28. package/lib/types/diagnosis/store.d.ts +114 -26
  29. package/lib/types/diagnosis/store.d.ts.map +1 -1
  30. package/lib/types/diagnosis/store.js +336 -167
  31. package/lib/types/diagnosis/store.js.map +1 -1
  32. package/lib/types/diagnosis/types.d.ts +168 -16
  33. package/lib/types/diagnosis/types.d.ts.map +1 -1
  34. package/lib/types/diagnosis/types.js +1 -1
  35. package/lib/types/diagnosis/types.js.map +1 -1
  36. package/lib/types/document-page.d.ts +39 -0
  37. package/lib/types/document-page.d.ts.map +1 -0
  38. package/lib/types/document-page.js +43 -0
  39. package/lib/types/document-page.js.map +1 -0
  40. package/lib/types/fs-atomic.d.ts +12 -0
  41. package/lib/types/fs-atomic.d.ts.map +1 -0
  42. package/lib/types/fs-atomic.js +42 -0
  43. package/lib/types/fs-atomic.js.map +1 -0
  44. package/lib/types/index.d.ts.map +1 -1
  45. package/lib/types/index.js +214 -24
  46. package/lib/types/index.js.map +1 -1
  47. package/lib/types/knowledge-bases.d.ts +10 -2
  48. package/lib/types/knowledge-bases.d.ts.map +1 -1
  49. package/lib/types/knowledge-bases.js +20 -18
  50. package/lib/types/knowledge-bases.js.map +1 -1
  51. package/lib/types/proposals.d.ts +166 -0
  52. package/lib/types/proposals.d.ts.map +1 -0
  53. package/lib/types/proposals.js +238 -0
  54. package/lib/types/proposals.js.map +1 -0
  55. package/lib/types/runtime.d.ts +199 -7
  56. package/lib/types/runtime.d.ts.map +1 -1
  57. package/lib/types/runtime.js +728 -145
  58. package/lib/types/runtime.js.map +1 -1
  59. package/lib/types/settings-schema.d.ts +2 -2
  60. package/lib/types/types.d.ts +61 -10
  61. package/lib/types/types.d.ts.map +1 -1
  62. package/lib/types/types.js +56 -8
  63. package/lib/types/types.js.map +1 -1
  64. package/lib/types/wiki-types.d.ts +8 -1
  65. package/lib/types/wiki-types.d.ts.map +1 -1
  66. package/lib/types/wiki-types.js +16 -25
  67. package/lib/types/wiki-types.js.map +1 -1
  68. package/package.json +4 -3
  69. package/preset/tita-data-agent/agent.cordis.yml +11 -5
  70. package/src/client/DirectoryPicker.tsx +12 -12
  71. package/src/client/InfoHint.tsx +21 -8
  72. package/src/client/IntentTab.tsx +20 -26
  73. package/src/client/KnowledgeBaseTab.tsx +190 -80
  74. package/src/client/KnowledgePanel.tsx +42 -9
  75. package/src/client/KnowledgeStepRail.tsx +3 -0
  76. package/src/client/NodeSettings.tsx +20 -22
  77. package/src/client/PreviewSections.tsx +87 -33
  78. package/src/client/ProposalReview.tsx +313 -0
  79. package/src/client/TypeDefinitionDrawer.tsx +72 -38
  80. package/src/client/WikiTypeEditor.tsx +193 -77
  81. package/src/client/arch/AgentArchitectureGraph.tsx +143 -14
  82. package/src/client/arch/NodeLogicPanel.tsx +6 -3
  83. package/src/client/arch/model.ts +164 -26
  84. package/src/client/architecture.css +29 -9
  85. package/src/client/architecture.tsx +54 -29
  86. package/src/client/attribution/AttributionGraph.tsx +481 -34
  87. package/src/client/attribution/AttributionTab.tsx +507 -106
  88. package/src/client/attribution/CaseView.tsx +9 -14
  89. package/src/client/attribution/GraphStage.tsx +25 -18
  90. package/src/client/attribution/RunView.tsx +27 -9
  91. package/src/client/attribution/StageChrome.tsx +296 -140
  92. package/src/client/attribution/graph-options.ts +611 -47
  93. package/src/client/attribution/model.ts +559 -30
  94. package/src/client/convert/ConvertPanel.tsx +6 -1
  95. package/src/client/doc-page.css +134 -0
  96. package/src/client/doc-page.tsx +263 -0
  97. package/src/client/panel-state.ts +105 -0
  98. package/src/client/request.ts +36 -0
  99. package/src/client/styles.css +317 -43
  100. package/src/client/useFitScale.ts +15 -2
  101. package/src/client/wiki-type-groups.ts +86 -0
  102. package/src/convert/host.ts +41 -7
  103. package/src/diagnosis/cards.ts +120 -50
  104. package/src/diagnosis/run.ts +245 -0
  105. package/src/diagnosis/schema.ts +67 -26
  106. package/src/diagnosis/seed-source.ts +28 -3
  107. package/src/diagnosis/seed.ts +187 -85
  108. package/src/diagnosis/store.ts +358 -174
  109. package/src/diagnosis/types.ts +181 -16
  110. package/src/document-page.ts +51 -0
  111. package/src/fs-atomic.ts +42 -0
  112. package/src/index.ts +209 -22
  113. package/src/knowledge-bases.ts +20 -18
  114. package/src/proposals.ts +337 -0
  115. package/src/runtime.ts +736 -135
  116. package/src/types.ts +113 -19
  117. package/src/wiki-types.ts +17 -27
@@ -1,45 +1,48 @@
1
- import { mkdir, readFile, readdir, writeFile } from 'node:fs/promises'
1
+ import { readFile, readdir } from 'node:fs/promises'
2
2
  import { join } from 'node:path'
3
- import { SEED_CASES, SEED_GRAPH, type AttributionCase } from './seed.js'
3
+ import { SEED_CASES, SEED_GRAPH } from './seed.js'
4
4
  import { seedSources, type SeedSource } from './seed-source.js'
5
- import { DIAGNOSIS_ENTITIES, templateCard, validateDiagnosis, type DiagnosisIssue } from './schema.js'
5
+ import { validateDiagnosis, type DiagnosisIssue } from './schema.js'
6
6
  import {
7
- cardsToGraph, cardPathOf, graphToCards, parseCard, serializeCard,
7
+ cardsToGraph, CARD_EDGE_KINDS, graphToCards, parseCard, serializeCard,
8
8
  RUN_EDGE_KINDS, type DiagnosisCard,
9
9
  } from './cards.js'
10
- import type { AttributionEdge, AttributionGraphData, AttributionNode, AttributionNodeKind } from './types.js'
10
+ import { caseProposalOf, parseRunSource, renderRunSource, runReferenceProblems, runToGraph } from './run.js'
11
+ import type {
12
+ AttributionCase, AttributionEdge, AttributionGraphData, AttributionNode, AttributionNodeKind, DiagnosisRunRecord,
13
+ } from './types.js'
11
14
  import type { KnowledgeRuntime } from '../runtime.js'
15
+ import type { CardProposalStore } from '../proposals.js'
12
16
  import type { SchemaType } from '../types.js'
13
17
 
14
18
  /**
15
- * `05_diagnosis/` 的落盘与读取(v0.7 起:**卡片才是真相,这里只放一次排查的产物**)。
19
+ * 排查知识的读取与写入(v1.1 起:**没有 `05_diagnosis/` 了**)。
16
20
  *
17
- * ## 为什么要改
18
- *
19
- * 改版前这里同时扮演两个角色:既是 seed 写出来的 jsonl 数据集,又被当成图的唯一来源。
20
- * 后果是排查思路**从来没进过 wiki** —— 不在 `01_source_truth`、不是 `02_wiki` 的卡片、
21
- * 编译器不认它的 entity_type,于是不会被 wikiNote 化、不会进向量索引,**永远召不回来**。
22
- * 而 `store.ts` 顶上那句「全部内容都能从 wiki 卡片确定性重建」描述的其实是目标状态,
23
- * 代码走的是相反的路径。
24
- *
25
- * ## 现在的分工
21
+ * ## 三段,各一个答案
26
22
  *
27
23
  * | 目录 | 内容 | 谁是真相 |
28
24
  * | --- | --- | --- |
29
- * | `01_source_truth/` | 手册与复盘原文(`sourceType=question`) | 人写的原始材料 |
30
- * | `02_wiki/diagnosis/` | 五类卡片(三段式) | **知识侧的唯一真相** |
31
- * | `05_diagnosis/` | `evidence` / `cause` / 执行边(`produces` `supports` `refutes` `confirmed_as`)与模板卡 | 一次排查的产物 |
25
+ * | `01_source_truth/question/` | 手册与复盘原文 | 人写的原始材料 |
26
+ * | `01_source_truth/agent_diagnosis_case/` | 一次排查的过程记录(一条 SourceRaw) | Agent 跑出来的原始记录 |
27
+ * | `02_wiki/diagnosis/` | 五类卡片(三段式) | **知识侧的唯一真相**,且必须经人确认才落盘 |
28
+ *
29
+ * `05_diagnosis/` 在 v1.1 撤销了(0021 §0.3)。它同时装着两类东西 —— 「一次排查的产物」
30
+ * (源头)与「五类模板卡」(配置)—— 一个编号段混装两种性质,`rebuild --only` 的语义
31
+ * 立刻含糊。而且它自造的 jsonl 过不了 `source_refs` 那道门:卡片要求引用**真实存在的
32
+ * SourceRaw**,jsonl 不是。
33
+ *
34
+ * 旧的 `05_diagnosis/*.jsonl` 因此降为**只读的迁移输入与历史快照**:还在,还能读,
35
+ * 但不再被写、也不再是任何东西的真相。
36
+ *
37
+ * ## 读取顺序是显式的(`snapshot().source` 会把它报给界面)
32
38
  *
33
- * 读取顺序是显式的:**有卡片就编译卡片;没有卡片但有旧 jsonl 就按旧格式读出来(并尝试
34
- * 前向迁移);两者都没有才灌 seed**。老知识根不会因为这次改动而读不出内容。
39
+ * 1. 有卡片 → 卡片 + 一次排查的 SourceRaw;
40
+ * 2. 没有卡片但有旧 jsonl → 按旧格式读出来(并尝试**无损**前向迁移);
41
+ * 3. 两者都没有 → **什么都不写**:空态 + 「载入内置示例」按钮。
35
42
  */
36
- const DIR = '05_diagnosis'
37
-
38
- /** 一次排查写下的节点:它们不是知识,所以留在这里,不进卡片。 */
39
- const RUN_NODE_SHARDS: Record<string, AttributionNodeKind> = {
40
- 'evidence.jsonl': 'evidence',
41
- 'causes.jsonl': 'cause',
42
- }
43
+ const LEGACY_DIR = '05_diagnosis'
44
+ /** 一次排查的产物:`01_source_truth/<这个分类>/`。 */
45
+ const RUN_SOURCE_TYPE = 'agent_diagnosis_case'
43
46
 
44
47
  /**
45
48
  * 旧版的类型层分片。**只读,不再写**:v0.7 之前它们就是真相,现在它们的角色是
@@ -48,48 +51,60 @@ const RUN_NODE_SHARDS: Record<string, AttributionNodeKind> = {
48
51
  const LEGACY_SHARDS: Record<string, AttributionNodeKind> = {
49
52
  'symptoms.jsonl': 'symptom',
50
53
  'hypotheses.jsonl': 'hypothesis',
51
- 'checks.jsonl': 'check',
52
- 'failure-modes.jsonl': 'failure-mode',
54
+ 'checks.jsonl': 'check_point',
55
+ 'failure-modes.jsonl': 'failure_reason',
53
56
  'assets.jsonl': 'asset',
54
57
  'cases.jsonl': 'case',
55
58
  }
56
59
 
57
- const README = `# 05_diagnosis
58
-
59
- 这个目录**只放一次排查的产物**(\`evidence\` / \`cause\` / 执行边),以及新人照抄的模板卡。
60
-
61
- 排查思路本身(现象 / 假设 / 检查 / 失败模式 / 案例)现在是 **wiki 卡片**,住在
62
- \`02_wiki/diagnosis/\`,出处是 \`01_source_truth/\` 里的手册与复盘。图由卡片编译而来 ——
63
- 所以改知识要改卡片(或改它的来源文档再重新编译),不要改这里。
64
-
65
- \`*.jsonl\` 里若出现 \`symptoms\` / \`hypotheses\` / \`checks\` / \`failure-modes\` / \`assets\`
66
- 等分片,那是 v0.7 之前的历史快照:版本升级时被读出来迁移成了卡片,之后不再更新。
67
- `
60
+ /** 一次排查写下的节点(旧格式)。同样只读。 */
61
+ const LEGACY_RUN_SHARDS: Record<string, AttributionNodeKind> = {
62
+ 'evidence.jsonl': 'evidence',
63
+ 'causes.jsonl': 'cause',
64
+ }
68
65
 
69
66
  /** 读取顺序的显式来源,界面据此说明「现在看到的是哪一份」。 */
70
- export type DiagnosisSource = 'cards' | 'jsonl' | 'seed'
67
+ export type DiagnosisSource = 'cards' | 'jsonl' | 'empty'
71
68
 
72
69
  export interface DiagnosisSnapshot {
73
70
  graph: AttributionGraphData
74
71
  cases: AttributionCase[]
75
72
  issues: DiagnosisIssue[]
76
- /** 数据是不是本次 ensure() 从 seed 写进去的。界面据此说明来源。 */
73
+ /** 数据是不是本次调用从内置示例写进去的(只有 `loadSample()` 会把它变成 true)。 */
77
74
  seeded: boolean
78
75
  /** 旧知识根是否在本次被前向迁移成卡片。 */
79
76
  migrated: boolean
80
77
  /** 读的是哪一份真相。 */
81
78
  source: DiagnosisSource
82
- /** 写卡片 / 迁移过程中发现的问题(写失败、迁移分歧)。必须能显示出来,不能只进日志。 */
79
+ /**
80
+ * 这个库还什么都没有 —— 界面据此显示空态(说什么会有、怎么开始),
81
+ * 而不是画一张空图。
82
+ */
83
+ canLoadSample: boolean
84
+ /** 写卡片 / 迁移 / 读诊断日志过程中发现的问题。必须能显示出来,不能只进日志。 */
83
85
  problems: string[]
86
+ /**
87
+ * 待人确认的提议条数(0021 §7.1)。
88
+ *
89
+ * 它挂在归因这一栏上,是因为**提议多半就是从排查里长出来的**:跑完一次排查,
90
+ * 案例卡片的草案就等在队列里。归因侧只挂一个角标,点它跳到「知识库 → Wiki」的
91
+ * 待办区逐条 review —— review 界面只有一处,不在这里再造一个。
92
+ */
93
+ proposals: { pending: number; rejected: number; confirmed: number }
84
94
  }
85
95
 
86
- /** 只取运行时里真正要用的三件事:读根目录、落 SourceRaw、写卡片。 */
87
- type DiagnosisHost = Pick<KnowledgeRuntime, 'rootDir' | 'addSource' | 'writeCard'>
96
+ /**
97
+ * 只取运行时里真正要用的那几件事:读根目录、落 SourceRaw、写卡片、列来源。
98
+ *
99
+ * `loadSources` 是 v1.1 新增的:一次排查的产物现在是一条 `agent_diagnosis_case`
100
+ * 的 SourceRaw,归因图读的是它,而不是自造的 jsonl。
101
+ */
102
+ type DiagnosisHost = Pick<KnowledgeRuntime, 'rootDir' | 'addSource' | 'writeCard' | 'loadSources'>
88
103
 
89
104
  export class DiagnosisStore {
90
- constructor(private readonly host: DiagnosisHost) {}
105
+ constructor(private readonly host: DiagnosisHost, private readonly proposals?: CardProposalStore) {}
91
106
 
92
- private get dir(): string { return join(this.host.rootDir, DIR) }
107
+ private get legacyDir(): string { return join(this.host.rootDir, LEGACY_DIR) }
93
108
  private get cardsDir(): string { return join(this.host.rootDir, '02_wiki', 'diagnosis') }
94
109
 
95
110
  /**
@@ -99,85 +114,166 @@ export class DiagnosisStore {
99
114
  * 2. 没有卡片但有旧 jsonl → **前向迁移**:把旧图反推成卡片写出去,并**校验迁移无损**
100
115
  * (重新编译一遍与旧图比对,不一致就不认这次迁移,继续按 jsonl 读 —— 宁可留在旧形态,
101
116
  * 也不要静默丢知识);
102
- * 3. 两者都没有 → 首次启动:先落手册与复盘的 SourceRaw,再把 seed 编译成卡片。
117
+ * 3. 两者都没有 → **什么都不写**。这个库还没开始做排查。
118
+ *
119
+ * 第 3 条原来是自动写入内置示例。实跑反馈把它改掉了:那份示例长得像真的业务文档,
120
+ * 而它落在用户自己的 `01_source_truth/` 与 `02_wiki/` 里 —— 新装一台机器,一打开
121
+ * 「智能归因」就凭空多出几份来源和几十张卡片。示例还在(`loadSample()`),
122
+ * 但改成**用户点一下才载入**。
123
+ *
124
+ * **v1.1 起连模板文件也不铺了**:模板卡由类型定义派生(0021 §6.6),落成磁盘文件会
125
+ * 造出「设置里改了、磁盘上那份没改」的第二真源。
103
126
  */
104
127
  async ensure(): Promise<{ seeded: boolean; migrated: boolean; problems: string[] }> {
105
- await mkdir(this.dir, { recursive: true })
106
- const templates = join(this.dir, 'templates')
107
- await mkdir(templates, { recursive: true })
108
- await Promise.all(DIAGNOSIS_ENTITIES.map(spec =>
109
- this.writeIfAbsent(join(templates, `${spec.entityType.replace(/\//g, '-')}.md`), templateCard(spec))))
110
- // 目录角色的说明也要落盘:下一个人只打开 05_diagnosis 时,得知道知识已经搬走了。
111
- await this.writeIfAbsent(join(this.dir, 'README.md'), README)
112
- // 注意:**不要**在这里为一次排查的产物建空占位文件。它们走 `writeIfAbsent`,
113
- // 而「占位」会在首次 seed 之前就把文件创建出来,于是 seed 的真实内容被判为「已存在」
114
- // 而写不进去 —— 结果是图上少了 evidence / cause 五个节点,且没有任何报错。
115
-
116
128
  if ((await this.readCards()).length > 0) return { seeded: false, migrated: false, problems: [] }
117
129
  if ((await this.legacyShardFiles()).length > 0) return await this.migrate()
118
- return await this.seed()
130
+ return { seeded: false, migrated: false, problems: [] }
131
+ }
132
+
133
+ /**
134
+ * 载入**内置示例**:一份排查手册 + 三篇复盘 + 三次排查日志 → SourceRaw → 卡片 → 图。
135
+ *
136
+ * 只有用户明确点了「载入内置示例」才走这里(`ensure()` 不再自动调用)。幂等:
137
+ * `addSource` 按 `externalId`、`writeCard` 按 entityId,点两次不会写出第二份。
138
+ *
139
+ * **它走的是「提议 → 确认」那条门,不是绕过它**(0021 §6.1)。区别只在确认者是谁:
140
+ * 用户点「载入内置示例」这个动作本身就是**对整批示例的确认**,所以这里给每条提议记下
141
+ * `confirmedBy = user:load-sample`,然后照常走 `writeCard`。这样做的两个好处:
142
+ * 待办区里能看到这批卡片是怎么来的;而「未确认不落 `02_wiki/`」这条规则没有被开一个
143
+ * 后门 —— 例外是**确认者的身份**,不是门的缺失。
144
+ */
145
+ async loadSample(): Promise<{ seeded: boolean; migrated: boolean; problems: string[] }> {
146
+ const { problems: sourceProblems, refs } = await this.writeSources(seedSources())
147
+ const cards = withSourceRefs(graphToCards(SEED_GRAPH, SEED_CASES), refs, SEED_CASES)
148
+ const problems = [...sourceProblems, ...await this.writeCards(cards, 'user:load-sample')]
149
+ return { seeded: true, migrated: false, problems }
119
150
  }
120
151
 
121
152
  async snapshot(): Promise<DiagnosisSnapshot> {
122
153
  const { seeded, migrated, problems } = await this.ensure()
123
154
  const cards = await this.readCards()
124
- const run = await this.readRunArtifacts()
155
+ /**
156
+ * 「什么都没有」= 没有卡片、也没有旧 jsonl。它是**可以载入内置示例**的唯一条件:
157
+ * 已经有知识(不管哪一代形态)时不该再往里塞示例 —— 那会变成第二份互相矛盾的知识。
158
+ */
159
+ const canLoadSample = cards.length === 0 && (await this.legacyShardFiles()).length === 0
160
+
161
+ const proposals = await this.proposalCounts()
125
162
 
126
163
  if (cards.length > 0) {
127
- const compiled = cardsToGraph(cards)
128
- const graph: AttributionGraphData = {
129
- nodes: [...compiled.graph.nodes, ...run.nodes],
130
- edges: [...compiled.graph.edges, ...run.edges],
131
- }
164
+ const built = await this.buildGraph(cards)
132
165
  return {
133
- graph,
134
- cases: compiled.cases,
135
- issues: validateDiagnosis(graph),
166
+ graph: built.graph,
167
+ cases: built.cases,
168
+ issues: validateDiagnosis(built.graph),
136
169
  seeded,
137
170
  migrated,
138
171
  source: 'cards',
139
- problems: [...problems, ...compiled.problems],
172
+ canLoadSample: false,
173
+ problems: [...problems, ...built.problems],
174
+ proposals,
140
175
  }
141
176
  }
142
177
 
143
- // 还没有卡片:旧 jsonl(或 seed 刚写下的那份)就是当前可读的来源。
144
- const graph = await this.readGraph()
145
- const cases = await this.readCases()
178
+ // 还没有卡片:旧 jsonl 就是当前可读的来源;两份都没有就是一个空库。
179
+ const graph = await this.readLegacyGraph()
180
+ const cases = await this.readLegacyCases()
146
181
  return {
147
182
  graph,
148
183
  cases,
149
184
  issues: validateDiagnosis(graph),
150
185
  seeded,
151
186
  migrated,
152
- source: (await this.legacyShardFiles()).length > 0 ? 'jsonl' : 'seed',
187
+ source: canLoadSample ? 'empty' : 'jsonl',
188
+ canLoadSample,
153
189
  problems,
190
+ proposals,
191
+ }
192
+ }
193
+
194
+ /** 待审 / 已拒 / 已确认未落卡的条数。没有提议存储时全是 0(诚实,不猜)。 */
195
+ private async proposalCounts(): Promise<{ pending: number; rejected: number; confirmed: number }> {
196
+ if (!this.proposals) return { pending: 0, rejected: 0, confirmed: 0 }
197
+ const all = await this.proposals.list()
198
+ return {
199
+ pending: all.filter(item => item.status === 'pending').length,
200
+ rejected: all.filter(item => item.status === 'rejected').length,
201
+ confirmed: all.filter(item => item.status === 'confirmed' && !item.writtenAt).length,
202
+ }
203
+ }
204
+
205
+ /**
206
+ * 图 = **卡片那张图** + **一次排查的产物**。
207
+ *
208
+ * 两条来源严格分工:类型层与引用层(以及六种卡片边)全部来自卡片;`evidence` / `cause`
209
+ * 与四条执行边全部来自 `agent_diagnosis_case` 的 SourceRaw。合成一张图是**读**的时候
210
+ * 做的,不是写的时候 —— 写的时候合成,等于让一次执行的结果变成可复用的知识。
211
+ */
212
+ private async buildGraph(cards: DiagnosisCard[]): Promise<{ graph: AttributionGraphData; cases: AttributionCase[]; problems: string[] }> {
213
+ const compiled = cardsToGraph(cards)
214
+ const problems = [...compiled.problems]
215
+ const nodes: AttributionNode[] = [...compiled.graph.nodes]
216
+ const edges: AttributionEdge[] = [...compiled.graph.edges]
217
+
218
+ const runs = await this.readRuns()
219
+ problems.push(...runs.problems)
220
+ for (const record of runs.records) {
221
+ const run = runToGraph(record)
222
+ // 引用完整性要**连这次排查自己产出的 id 一起算**:路径里的 `E1` / `C1` 正是它写下的。
223
+ const known = new Set([...compiled.graph.nodes.map(node => node.id), ...run.nodes.map(node => node.id)])
224
+ problems.push(...run.problems, ...runReferenceProblems(record, known))
225
+ nodes.push(...run.nodes)
226
+ edges.push(...run.edges)
154
227
  }
228
+
229
+ /**
230
+ * **旧 jsonl 里的执行产物继续可读。**
231
+ *
232
+ * 它们是只读的历史快照(v0.7 之前一次排查的产物就写在那里),而卡片表达不了它们
233
+ * —— `evidence` / `cause` 与四条执行边不属于任何卡片。所以迁移只搬「卡片能表达的那
234
+ * 部分」,这一部分留在原处继续供读。少了这一段,一次旧知识根迁移之后图会静默地
235
+ * 少掉全部证据与根因,而迁移还报成功。
236
+ */
237
+ const legacyRun = await this.readLegacyRunArtifacts()
238
+ nodes.push(...legacyRun.nodes)
239
+ edges.push(...legacyRun.edges)
240
+
241
+ return { graph: dedupe({ nodes, edges }, problems), cases: compiled.cases, problems }
155
242
  }
156
243
 
157
244
  /**
158
- * 图。
245
+ * 旧 `05_diagnosis/` 里的执行产物:`evidence.jsonl` / `causes.jsonl` / `edges.jsonl`。
159
246
  *
160
- * 有卡片:`cardsToGraph(卡片)` + 一次排查的产物;没有卡片:按旧 jsonl 读。
161
- * 两条路径都返回同一种形状,调用方不需要知道现在是哪一代。
247
+ * 只取**执行边**:卡片边由卡片投影出来,这里再读一遍就会出现重复边。同时按 id 去重
248
+ * —— 已经由 `agent_diagnosis_case` 解析出来的节点不重复加(新旧两代可能描述同一次排查)。
162
249
  */
250
+ private async readLegacyRunArtifacts(): Promise<{ nodes: AttributionNode[]; edges: AttributionEdge[] }> {
251
+ const nodes: AttributionNode[] = []
252
+ for (const file of Object.keys(LEGACY_RUN_SHARDS)) {
253
+ for (const row of await this.readLines(join(this.legacyDir, file))) {
254
+ try { nodes.push(JSON.parse(row) as AttributionNode) } catch { /* 跳过损坏行 */ }
255
+ }
256
+ }
257
+ const edges: AttributionEdge[] = []
258
+ for (const row of await this.readLines(join(this.legacyDir, 'edges.jsonl'))) {
259
+ try {
260
+ const edge = JSON.parse(row) as AttributionEdge
261
+ if (RUN_EDGE_KINDS.includes(edge.kind)) edges.push(edge)
262
+ } catch { /* 同上 */ }
263
+ }
264
+ return { nodes, edges }
265
+ }
266
+
163
267
  async readGraph(): Promise<AttributionGraphData> {
164
268
  const cards = await this.readCards()
165
- if (cards.length > 0) {
166
- const compiled = cardsToGraph(cards)
167
- const run = await this.readRunArtifacts()
168
- return { nodes: [...compiled.graph.nodes, ...run.nodes], edges: [...compiled.graph.edges, ...run.edges] }
169
- }
269
+ if (cards.length > 0) return (await this.buildGraph(cards)).graph
170
270
  return await this.readLegacyGraph()
171
271
  }
172
272
 
173
273
  async readCases(): Promise<AttributionCase[]> {
174
274
  const cards = await this.readCards()
175
275
  if (cards.length > 0) return cardsToGraph(cards).cases
176
- try {
177
- const raw = await readFile(join(this.dir, 'cases.json'), 'utf8')
178
- const parsed = JSON.parse(raw) as AttributionCase[]
179
- return Array.isArray(parsed) ? parsed : []
180
- } catch { return [] }
276
+ return await this.readLegacyCases()
181
277
  }
182
278
 
183
279
  /* ────────────────────────────────────────────── 卡片:读写 ── */
@@ -192,42 +288,70 @@ export class DiagnosisStore {
192
288
  return cards
193
289
  }
194
290
 
195
- /** 写一批卡片。返回写失败的原因(schema 不认、出处不存在等),由调用方决定怎么显示。 */
196
- private async writeCards(cards: DiagnosisCard[]): Promise<string[]> {
291
+ /* ────────────────────────────────────────────── 一次排查的记录 ── */
292
+
293
+ /**
294
+ * 读全部 `agent_diagnosis_case` 来源,解析出排查记录。
295
+ *
296
+ * 块坏了、`runId` 缺了、`symptomId` 缺了就**跳过并如实报问题** —— 不猜。
297
+ * 一条坏日志不该让整张图读不出来,但它也不能被静默吞掉。
298
+ */
299
+ async readRuns(): Promise<{ records: DiagnosisRunRecord[]; problems: string[] }> {
300
+ const records: DiagnosisRunRecord[] = []
197
301
  const problems: string[] = []
198
- for (const card of cards) {
199
- const written = await this.host.writeCard({
200
- entityType: card.entityType as SchemaType,
201
- entityId: card.entityId,
202
- title: card.title,
203
- content: renderBody(card),
204
- sourceRefs: card.sourceRefs,
205
- status: card.status as never,
206
- ...(card.summary ? { summary: card.summary } : {}),
207
- ...(card.owner ? { owner: card.owner } : {}),
208
- })
209
- if (written.ok === false) problems.push(`卡片 ${card.entityId} 写入失败:${written.error.code} ${written.error.message}`)
302
+ for (const source of await this.host.loadSources()) {
303
+ if (source.sourceType !== RUN_SOURCE_TYPE) continue
304
+ const record = parseRunSource(source.content)
305
+ if (record) records.push(record)
306
+ else problems.push(`诊断日志 ${source.sourceId} 里没有可解析的 \`json diagnosis-run\` 块,已跳过`)
210
307
  }
211
- return problems
308
+ return { records, problems }
212
309
  }
213
310
 
214
- /* ────────────────────────────────────────────── 首次 seed ── */
215
-
216
- private async seed(): Promise<{ seeded: boolean; migrated: boolean; problems: string[] }> {
217
- const { problems: sourceProblems, refs } = await this.writeSources(seedSources())
218
- const cards = withSourceRefs(graphToCards(SEED_GRAPH, SEED_CASES), refs, SEED_GRAPH, SEED_CASES)
219
- const problems = [...sourceProblems, ...await this.writeCards(cards)]
220
- // 一次排查的产物照旧落在这里 —— seed 本来就等于「已经发生过的那三次排查」。
221
- await this.writeRunArtifacts(SEED_GRAPH)
222
- await this.writeLegacySnapshot()
223
- return { seeded: true, migrated: false, problems }
311
+ /**
312
+ * 一次排查结束:写一条 `agent_diagnosis_case` 的 SourceRaw,并**提议**一张案例卡片。
313
+ *
314
+ * 两件事分开是有意的:记录是 Agent 的产物,可以直接落(它是实例层的原始记录,不是知识);
315
+ * 案例卡片落在收敛的那一侧,所以只能提议,等人确认。
316
+ *
317
+ * 幂等:`externalId` = runId,同一次排查重跑不会写出第二条来源。
318
+ */
319
+ async recordRun(record: DiagnosisRunRecord): Promise<{ sourceId?: string; proposalId?: string; problems: string[] }> {
320
+ const problems: string[] = []
321
+ const added = await this.host.addSource({
322
+ sourceType: RUN_SOURCE_TYPE,
323
+ title: `AI 诊断日志 · ${record.symptomId} · ${record.runId}`,
324
+ content: renderRunSource(record),
325
+ externalId: record.runId,
326
+ sourceId: `${RUN_SOURCE_TYPE}:${record.runId}`,
327
+ })
328
+ if (added.ok === false) return { problems: [`诊断日志 ${record.runId} 写入失败:${added.error.code} ${added.error.message}`] }
329
+ const sourceId = added.data.sourceId
330
+
331
+ let proposalId: string | undefined
332
+ if (this.proposals) {
333
+ const symptomTitle = (await this.readCards()).find(card => card.entityId === record.symptomId)?.title ?? record.symptomId
334
+ const draft = caseProposalOf(record, symptomTitle)
335
+ const [created] = await this.proposals.upsert([{
336
+ sourceRef: sourceId,
337
+ trigger: 'diagnosis-run',
338
+ action: 'create',
339
+ entityType: draft.entityType,
340
+ entityId: draft.entityId,
341
+ title: draft.title,
342
+ content: renderCardBody(draft),
343
+ sourceRefs: [sourceId],
344
+ }])
345
+ proposalId = created?.id
346
+ }
347
+ return { sourceId, ...(proposalId ? { proposalId } : {}), problems }
224
348
  }
225
349
 
226
350
  /* ────────────────────────────────────────────── 旧知识根迁移 ── */
227
351
 
228
352
  private async migrate(): Promise<{ seeded: boolean; migrated: boolean; problems: string[] }> {
229
353
  const legacy = await this.readLegacyGraph()
230
- const cases = await this.readCases()
354
+ const cases = await this.readLegacyCases()
231
355
 
232
356
  // **先在内存里验证,通过才写盘。**
233
357
  //
@@ -235,19 +359,23 @@ export class DiagnosisStore {
235
359
  // 就宁可留在旧形态,也不要静默丢知识。而「先写再验、失败回滚」会留一个更糟的中间态:
236
360
  // 卡片已经落盘,下一次读就成了卡片来源 —— 于是分歧只在第一次读时被报出来,
237
361
  // 之后再也看不见。所以顺序是:编译 → 比对 → 才写。
238
- const run = await this.readRunArtifacts()
239
362
  const draft = graphToCards(legacy, cases)
240
363
  const compiled = cardsToGraph(draft)
241
- const divergence = compareGraphs(legacy, {
242
- nodes: [...compiled.graph.nodes, ...run.nodes],
243
- edges: [...compiled.graph.edges, ...run.edges],
244
- })
364
+ /**
365
+ * 比对的是**卡片能表达的那部分**。
366
+ *
367
+ * `evidence` / `cause` 与四条执行边不在卡片里(§6.7 的边界表),它们留在
368
+ * `05_diagnosis/` 里继续供读(见 `readLegacyRunArtifacts`)。把它们算进比对,
369
+ * 结果是**任何带排查产物的旧知识根都迁不动** —— 而失败方式是静默的:图少了一半,
370
+ * 迁移还报成功。
371
+ */
372
+ const divergence = compareGraphs(cardExpressible(legacy), compiled.graph)
245
373
  if (divergence) {
246
374
  return { seeded: false, migrated: false, problems: [`迁移未生效(仍按 05_diagnosis/*.jsonl 读):${divergence}`] }
247
375
  }
248
376
 
249
377
  const { problems: sourceProblems, refs } = await this.writeSources(seedSources())
250
- const problems = [...sourceProblems, ...await this.writeCards(withSourceRefs(draft, refs, legacy, cases))]
378
+ const problems = [...sourceProblems, ...await this.writeCards(withSourceRefs(draft, refs, cases), 'migration:05_diagnosis')]
251
379
  return { seeded: false, migrated: problems.length === 0, problems }
252
380
  }
253
381
 
@@ -275,58 +403,75 @@ export class DiagnosisStore {
275
403
  return { problems, refs }
276
404
  }
277
405
 
278
- /* ────────────────────────────────────────────── 一次排查的产物 ── */
406
+ /* ────────────────────────────────────────────── 写卡片 ── */
279
407
 
280
- private async readRunArtifacts(): Promise<{ nodes: AttributionNode[]; edges: AttributionEdge[] }> {
281
- const nodes: AttributionNode[] = []
282
- for (const file of Object.keys(RUN_NODE_SHARDS)) {
283
- for (const row of await this.readLines(join(this.dir, file))) {
284
- try { nodes.push(JSON.parse(row) as AttributionNode) } catch { /* 跳过损坏行,不让一行毁掉整张图 */ }
285
- }
286
- }
287
- const edges: AttributionEdge[] = []
288
- for (const row of await this.readLines(join(this.dir, 'edges.jsonl'))) {
289
- try {
290
- const edge = JSON.parse(row) as AttributionEdge
291
- // 只认执行边:五种卡片边由卡片投影出来,这里再读一遍就会出现重复边。
292
- if (RUN_EDGE_KINDS.includes(edge.kind)) edges.push(edge)
293
- } catch { /* 同上 */ }
294
- }
295
- return { nodes, edges }
296
- }
408
+ /**
409
+ * 写一批卡片。返回写失败的原因(schema 不认、出处不存在等),由调用方决定怎么显示。
410
+ *
411
+ * **它是一条「确认之后」的路径**:调用方必须先有人的确认(`loadSample` 是用户点了按钮、
412
+ * 迁移是搬已有知识、review 面板是逐条点了通过),`confirmedBy` 就是那个凭证。
413
+ * Agent 手里没有这条路径 —— 它只有 `propose_wiki_cards` 与 `write_knowledge_card`
414
+ * (后者要求一条已确认且尚未落卡的提议)。
415
+ *
416
+ * 有提议存储时**先提一条提议再确认再落卡**,而不是直接写:这样待办区里能追溯
417
+ * 「这张卡片是哪一次确认产生的」,而两条路径(这里与 review 面板)共用同一个形状。
418
+ */
419
+ private async writeCards(cards: DiagnosisCard[], confirmedBy: string): Promise<string[]> {
420
+ const problems: string[] = []
421
+ for (const card of cards) {
422
+ const body = renderCardBody(card)
423
+ const proposal = this.proposals
424
+ ? (await this.proposals.upsert([{
425
+ sourceRef: card.sourceRefs[0] ?? `kb:${confirmedBy}`,
426
+ trigger: 'extraction' as const,
427
+ action: 'create' as const,
428
+ entityType: card.entityType,
429
+ entityId: card.entityId,
430
+ title: card.title,
431
+ ...(card.summary ? { summary: card.summary } : {}),
432
+ content: body,
433
+ sourceRefs: card.sourceRefs,
434
+ }]))[0]
435
+ : undefined
436
+ if (proposal) await this.proposals!.confirm(proposal.id, confirmedBy)
297
437
 
298
- private async writeRunArtifacts(graph: AttributionGraphData): Promise<void> {
299
- for (const [file, kind] of Object.entries(RUN_NODE_SHARDS)) {
300
- const rows = graph.nodes.filter(node => node.kind === kind)
301
- await this.writeIfAbsent(join(this.dir, file), rows.map(row => JSON.stringify(row)).join('\n'))
438
+ const written = await this.host.writeCard({
439
+ entityType: card.entityType as SchemaType,
440
+ entityId: card.entityId,
441
+ title: card.title,
442
+ content: body,
443
+ sourceRefs: card.sourceRefs,
444
+ status: card.status as never,
445
+ ...(card.summary ? { summary: card.summary } : {}),
446
+ ...(card.owner ? { owner: card.owner } : {}),
447
+ })
448
+ if (written.ok === false) problems.push(`卡片 ${card.entityId} 写入失败:${written.error.code} ${written.error.message}`)
449
+ else if (proposal) await this.proposals!.markWritten(proposal.id)
302
450
  }
303
- await this.writeIfAbsent(
304
- join(this.dir, 'edges.jsonl'),
305
- graph.edges.filter(edge => RUN_EDGE_KINDS.includes(edge.kind)).map(edge => JSON.stringify(edge)).join('\n'),
306
- )
451
+ return problems
307
452
  }
308
453
 
309
- /** 旧版的类型层快照。首次 seed 时也写一份:它让 `05_diagnosis/` 仍是一份可读的完整快照。 */
310
- private async writeLegacySnapshot(): Promise<void> {
311
- for (const [file, kind] of Object.entries(LEGACY_SHARDS)) {
312
- const rows = SEED_GRAPH.nodes.filter(node => node.kind === kind)
313
- await this.writeIfAbsent(join(this.dir, file), rows.map(row => JSON.stringify(row)).join('\n'))
314
- }
315
- await this.writeIfAbsent(join(this.dir, 'cases.json'), JSON.stringify(SEED_CASES, null, 2))
316
- }
454
+ /* ────────────────────────────────────────────── 旧读法(只读) ── */
317
455
 
318
- /* ────────────────────────────────────────────── 旧读法 ── */
456
+ private async readLegacyCases(): Promise<AttributionCase[]> {
457
+ try {
458
+ const raw = await readFile(join(this.legacyDir, 'cases.json'), 'utf8')
459
+ const parsed = JSON.parse(raw) as AttributionCase[]
460
+ return Array.isArray(parsed) ? parsed : []
461
+ } catch { return [] }
462
+ }
319
463
 
320
464
  private async readLegacyGraph(): Promise<AttributionGraphData> {
321
465
  const nodes: AttributionNode[] = []
322
- for (const [file, kind] of Object.entries({ ...LEGACY_SHARDS, ...RUN_NODE_SHARDS })) {
323
- for (const row of await this.readLines(join(this.dir, file))) {
466
+ for (const file of Object.keys({ ...LEGACY_SHARDS, ...LEGACY_RUN_SHARDS })) {
467
+ for (const row of await this.readLines(join(this.legacyDir, file))) {
324
468
  try { nodes.push(JSON.parse(row) as AttributionNode) } catch { /* 跳过损坏行 */ }
325
469
  }
326
- void kind
327
470
  }
328
471
  const edges: AttributionEdge[] = []
329
- for (const row of await this.readLines(join(this.dir, 'edges.jsonl'))) {
472
+ for (const row of await this.readLines(join(this.legacyDir, 'edges.jsonl'))) {
473
+ // **全部边都读**,不筛:旧文件是**迁移输入**,六种卡片边正是要从这里反推成
474
+ // 卡片字段的。只在读「当前图」时才筛执行边(`readLegacyRunArtifacts`)。
330
475
  try { edges.push(JSON.parse(row) as AttributionEdge) } catch { /* 同上 */ }
331
476
  }
332
477
  return { nodes, edges }
@@ -335,14 +480,13 @@ export class DiagnosisStore {
335
480
  /**
336
481
  * 是否存在**值得迁移的旧知识根**。
337
482
  *
338
- * 只看旧版的**类型层**分片,而且要求它真的有内容:`ensure()` 自己会为一次排查的产物
339
- * (`evidence.jsonl` 等)建空占位文件 —— 若把空文件也算成「旧知识根」,首次启动会走进
340
- * 迁移分支,然后在空图上白跑一趟。
483
+ * 只看旧版的**类型层**分片,而且要求它真的有内容:空文件不算「旧知识根」,
484
+ * 否则首次启动会走进迁移分支,然后在空图上白跑一趟。
341
485
  */
342
486
  private async legacyShardFiles(): Promise<string[]> {
343
487
  const found: string[] = []
344
488
  for (const file of Object.keys(LEGACY_SHARDS)) {
345
- if ((await this.readLines(join(this.dir, file))).length > 0) found.push(file)
489
+ if ((await this.readLines(join(this.legacyDir, file))).length > 0) found.push(file)
346
490
  }
347
491
  return found
348
492
  }
@@ -352,17 +496,10 @@ export class DiagnosisStore {
352
496
  return (await readFile(path, 'utf8')).split('\n').map(line => line.trim()).filter(Boolean)
353
497
  } catch { return [] }
354
498
  }
355
-
356
- private async writeIfAbsent(path: string, content: string): Promise<void> {
357
- try {
358
- await readFile(path)
359
- return
360
- } catch { await writeFile(path, content, 'utf8') }
361
- }
362
499
  }
363
500
 
364
501
  /** 卡片正文:小节 + 结构化块。复用编解码里的同一套序列化,避免两处格式漂移。 */
365
- function renderBody(card: DiagnosisCard): string {
502
+ export function renderCardBody(card: DiagnosisCard): string {
366
503
  const text = serializeCard(card)
367
504
  return text.slice(text.indexOf('\n---\n', 3) + 5).trim()
368
505
  }
@@ -376,7 +513,6 @@ function renderBody(card: DiagnosisCard): string {
376
513
  function withSourceRefs(
377
514
  cards: DiagnosisCard[],
378
515
  refs: Map<string, string>,
379
- graph: AttributionGraphData,
380
516
  cases: AttributionCase[],
381
517
  ): DiagnosisCard[] {
382
518
  const handbook = refs.get('handbook')
@@ -388,7 +524,6 @@ function withSourceRefs(
388
524
  caseOf.set(item.symptomId, ref)
389
525
  for (const step of item.path) if (!caseOf.has(step.nodeId)) caseOf.set(step.nodeId, ref)
390
526
  }
391
- void graph
392
527
  return cards.map(card => {
393
528
  const own = card.entityType === 'diagnosis/case' ? refs.get(card.entityId) : undefined
394
529
  const ref = own ?? caseOf.get(card.entityId) ?? handbook
@@ -396,6 +531,57 @@ function withSourceRefs(
396
531
  })
397
532
  }
398
533
 
534
+ /**
535
+ * 按 id 去重。
536
+ *
537
+ * 新旧两代可能描述**同一次排查**:一条 `agent_diagnosis_case` 的 SourceRaw(v1.1 起)
538
+ * 与 `05_diagnosis/evidence.jsonl`(历史快照)里会有同一个 `E1`。不去重的后果是图上
539
+ * 出现两个 `E1` —— 而画布按 id 建节点,第二个会静默覆盖第一个的位置与样式,
540
+ * 读起来像「这次排查跑了两遍」。
541
+ *
542
+ * 同 id 但 kind 不同是真冲突(同一份知识被两处定义成两样东西),报出来而不是静默取第一个。
543
+ */
544
+ function dedupe(graph: AttributionGraphData, problems: string[]): AttributionGraphData {
545
+ const nodes: AttributionNode[] = []
546
+ const byId = new Map<string, AttributionNode>()
547
+ for (const node of graph.nodes) {
548
+ const previous = byId.get(node.id)
549
+ if (previous) {
550
+ if (previous.kind !== node.kind) problems.push(`节点 ${node.id} 被定义成了两种类型(${previous.kind} / ${node.kind})—— 只保留第一个`)
551
+ continue
552
+ }
553
+ byId.set(node.id, node)
554
+ nodes.push(node)
555
+ }
556
+ const edges: AttributionEdge[] = []
557
+ const seen = new Set<string>()
558
+ for (const edge of graph.edges) {
559
+ const key = `${edge.kind}:${edge.source}->${edge.target}`
560
+ if (seen.has(key)) continue
561
+ seen.add(key)
562
+ edges.push(edge)
563
+ }
564
+ return { nodes, edges }
565
+ }
566
+
567
+ /** 只能由一次排查产出的节点类型。它们不属于任何卡片(§6.7 的边界表)。 */
568
+ const RUN_ONLY_KINDS: AttributionNodeKind[] = ['evidence', 'cause', 'unknown']
569
+
570
+ /**
571
+ * 旧图里**卡片能表达的那部分**:类型层、引用层的资产、案例桩,以及六种卡片边。
572
+ *
573
+ * 执行产物(`evidence` / `cause` / `unknown` 与四条执行边)不在其中 —— 它们的归宿是
574
+ * `agent_diagnosis_case` 的 SourceRaw,而不是卡片。
575
+ */
576
+ function cardExpressible(graph: AttributionGraphData): AttributionGraphData {
577
+ const nodes = graph.nodes.filter(node => !RUN_ONLY_KINDS.includes(node.kind))
578
+ const ids = new Set(nodes.map(node => node.id))
579
+ return {
580
+ nodes,
581
+ edges: graph.edges.filter(edge => CARD_EDGE_KINDS.includes(edge.kind) && ids.has(edge.source) && ids.has(edge.target)),
582
+ }
583
+ }
584
+
399
585
  /**
400
586
  * 两张图是否一致。返回 `undefined` 表示一致,否则返回第一条差异的人话描述。
401
587
  *
@@ -428,5 +614,3 @@ async function walkMarkdown(dir: string): Promise<string[]> {
428
614
  }
429
615
  return found
430
616
  }
431
-
432
- export { cardPathOf }