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
package/README.md CHANGED
@@ -156,19 +156,24 @@ HTTP `GET /knowledge/bases` 在返回前先刷新。
156
156
  (同一句话在哪个知识库下说,理解方式不该变),所以它不分库。这样知识、记忆、意图三段
157
157
  都是可以直接备份、直接 diff 的用户文件。
158
158
 
159
- 知识树内部(`domain_knowledge/<知识库 id>/`)现在是**四段**:`00_schema` 与 `04_memory`
160
- 都已不在(后者搬去了 `memory/`)。
159
+ 知识树内部(`domain_knowledge/<知识库 id>/`)现在是**三段**:schema 段与记忆段都已不在
160
+ (后者搬去了 `memory/`)。
161
161
 
162
162
  | 段 | 装什么 | 删掉的后果 |
163
163
  | --- | --- | --- |
164
164
  | `01_source_truth/<source_type>/` | SourceRaw,一级是**来源分类**,二级是文档 | 丢数据 |
165
165
  | `02_wiki/<entity_type>/` | Wiki 卡片,一级是卡片类型 | 丢结论 |
166
- | `03_compiled/` | wikiNotes / 向量 / 知识图谱 | 可重建 |
167
- | `05_diagnosis/` | 智能归因图谱 | 可重建 |
166
+ | `03_compiled/` | wikiNotes / 向量 / 知识图谱 / 归因图谱 | 可重建 |
168
167
 
169
- `00_schema` 已撤掉:它从建出来那天起就是一个**空目录**,分类注册表与 Wiki 类型注册表
168
+ **归因图谱也在这三段里**(v1.1):一次排查的产物是一条来源分类为 `agent_diagnosis_case`
169
+ 的 SourceRaw(落 `01_source_truth/`),模板卡由类型定义派生、不落盘,字段级的归因图
170
+ 落 `03_compiled/diagnosis_graph.json`。旧的 `05_diagnosis/` 撤销了;它里面的 `*.jsonl`
171
+ 如果还在,角色是**只读的迁移输入与历史快照** —— 不再被写,但仍然读得出来(证据与根因
172
+ 就从那里来),所以旧知识根不会因为这次改动而读不出内容。
173
+
174
+ schema 段已撤掉:它从建出来那天起就是一个**空目录**,分类注册表与 Wiki 类型注册表
170
175
  一直住在 `<agentRoot>/resource/knowledge-bases.json`(那是配置,跟着根路径走)。
171
- 启动时会把空的 `00_schema` 删掉 —— **非空则保留**:那就不属于「没用的空文件夹」了,
176
+ 启动时会把空的那个目录删掉 —— **非空则保留**:那就不属于「没用的空文件夹」了,
172
177
  删掉别人的文件比留一个空目录危险得多。
173
178
 
174
179
  `01_source_truth` 按分类分目录(而不是平铺)的理由与 `02_wiki` 一致:分类是每份来源的
@@ -218,13 +223,32 @@ POST /knowledge/bases { name, description?, rootDir? } → { base }
218
223
  PATCH /knowledge/bases/:id { name?, description?, sourceTypes?, wikiTypes?, wikiSchemaMode? } → { base }
219
224
  DELETE /knowledge/bases/:id → { deleted: true }
220
225
  GET /knowledge/documents?kb=&query=&source_type=&limit=&offset= → { documents, total }
221
- GET /knowledge/documents/:docId?kb= → { document }
226
+ GET /knowledge/documents/:docId?kb= → { document }(正文截前 4000 字符)
227
+ GET /knowledge/documents/:docId/content?kb=&offset=&limit= → { text, offset, nextOffset, totalChars, eof }
228
+ GET /knowledge/documents/:docId/view?kb= → 独立整页(HTML,读全文)
222
229
  GET /knowledge/documents/:docId/versions?kb= → { versions }
223
230
  POST /knowledge/documents/:docId/revert?kb= { versionId } → { document }
224
231
  DELETE /knowledge/documents/:docId?kb= → { deleted: true }
225
232
  GET /knowledge/assets/:kb/* → 知识库根目录下的文件流
233
+ GET /knowledge/doc-page.js → 独立整页的脚本(构建产物)
234
+ GET /knowledge/card-proposals?kb=&status= → { total, proposals }(默认只看待审)
235
+ POST /knowledge/card-proposals/review { kb, proposal_id, action, reason? } → { proposalId, status, written }
236
+ POST /diagnosis/run { kb, record } → { sourceId, proposalId }
226
237
  ```
227
238
 
239
+ **`/knowledge/card-proposals/review` 是「人的确认动作」,刻意不做成 Agent 工具。**
240
+ 类型层的写入现在有两段:Agent 与编译只**提议**(`propose_wiki_cards`、Pass 0),
241
+ 未确认的提议不落 `02_wiki/`、不进编译、不参与召回、不在归因图上出现;人在面板上
242
+ 逐条 review(通过并写入 / 仅确认 / 拒绝),确认之后才走 `write_knowledge_card` ——
243
+ 而那个工具现在要求一条**已确认且尚未落卡**的 `proposal_id`,确认凭证是一次性的。
244
+ 提议落在记忆段 `<agentRoot>/memory/<库 id>/card-proposals/`,不在知识树里。
245
+
246
+ **原文预览只发前 4000 个字符。** `GET /knowledge/documents/:docId` 返回的 `content` 是
247
+ 截断过的,全文长度在 `contentChars`、是否截断在 `contentTruncated`。理由是抽屉只有
248
+ 380px 宽,读不完一份几十万字的文档 —— 而把整份正文发过去正是「打开弹层要等半天」的
249
+ 成因。要读全文走 `.../view` 那个独立整页:它按 `offset`/`limit` **一页一段**地取
250
+ (默认 20000 字符一页,切点对齐空行),所以任何一次响应都不与文档大小成正比。
251
+
228
252
  `/knowledge/stats`、`/knowledge/search`、`/knowledge/rebuild`、`/knowledge/cards`、
229
253
  `/knowledge/sources`、`/knowledge/graph`、`/knowledge/embedding/health` 与全部
230
254
  `*_knowledge*` 工具都接受**可选** `kb`(query 或 body 字段)。`docId` 含 `:`
package/cordis.patch.yml CHANGED
@@ -112,11 +112,17 @@
112
112
  3. **Never invent a number.** Every figure you report must come from a tool
113
113
  result in this turn, and you must say which one. "I don't have that data" is
114
114
  a correct answer; a made-up number is not.
115
- 4. **Put it in writing while you still have the evidence.** A definition, a
116
- metric's exact calculation, a process, a diagnosed cause — if it will be
117
- asked again, write it as a card with `write_knowledge_card`, with
118
- `source_refs` that already exist in the store. A card whose refs point
119
- nowhere is rejected, and rightly so.
115
+ 4. **Put it in writing while you still have the evidence — as a proposal, not
116
+ a card.** A definition, a metric's exact calculation, a process, a diagnosed
117
+ cause — if it will be asked again, call `propose_wiki_cards` with the
118
+ `source_id` you just wrote and drafts whose `source_refs` already exist in
119
+ the store. A draft whose refs point nowhere is rejected, and rightly so.
120
+ **You cannot write a card yourself**: `write_knowledge_card` only accepts a
121
+ proposal a human has already confirmed, and unconfirmed proposals never
122
+ reach the wiki — they are not compiled, not recalled and not on the graph.
123
+ So say what you proposed and that it is waiting for review; do not claim the
124
+ card exists. Call `list_card_proposals` first so you do not re-propose
125
+ something a human already turned down.
120
126
  5. **Correct a card, do not quietly overwrite it.** When something in the store
121
127
  is wrong, set its status to `problem` and say what is wrong with it. Cards
122
128
  marked `problem` drop out of recall by default — that is how a wrong