@sparkelf/dsh-knowledge-base 0.1.36 → 0.4.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 (41) hide show
  1. package/README.md +53 -0
  2. package/lib/client.js +2463 -1385
  3. package/lib/client.js.map +1 -1
  4. package/lib/index.js +18210 -7883
  5. package/lib/types/client/KnowledgeMemory.d.ts +127 -0
  6. package/lib/types/client/graph/OriginBadges.d.ts +55 -0
  7. package/lib/types/client/locales.d.ts +64 -0
  8. package/lib/types/ftsIndex.d.ts +32 -0
  9. package/lib/types/graphCanvas.d.ts +1 -1
  10. package/lib/types/graphJsonProjection.d.ts +71 -0
  11. package/lib/types/graphMigration.d.ts +118 -0
  12. package/lib/types/graphModel.d.ts +194 -0
  13. package/lib/types/graphPolicy.d.ts +68 -0
  14. package/lib/types/graphTools.d.ts +30 -5
  15. package/lib/types/graphTypes.d.ts +24 -0
  16. package/lib/types/guardianSession.d.ts +135 -0
  17. package/lib/types/index.d.ts +135 -15
  18. package/lib/types/knowledgeTools.d.ts +50 -2
  19. package/lib/types/memoryBindings.d.ts +119 -0
  20. package/lib/types/memoryContext.d.ts +83 -0
  21. package/lib/types/memoryGraphBootstrap.d.ts +62 -0
  22. package/lib/types/memoryGraphWriter.d.ts +101 -0
  23. package/lib/types/memoryGuardian.d.ts +123 -0
  24. package/lib/types/memoryGuardianTool.d.ts +56 -0
  25. package/lib/types/memoryPolicy.d.ts +106 -0
  26. package/lib/types/memoryRecordTool.d.ts +39 -0
  27. package/lib/types/memoryRoutes.d.ts +85 -0
  28. package/lib/types/memorySettings.d.ts +40 -0
  29. package/lib/types/memorySkillPromotion.d.ts +62 -0
  30. package/lib/types/memoryStore.d.ts +297 -0
  31. package/lib/types/memoryTools.d.ts +71 -0
  32. package/lib/types/memoryTriggers.d.ts +65 -0
  33. package/lib/types/memoryTypes.d.ts +241 -0
  34. package/lib/types/summaryIndex.d.ts +112 -0
  35. package/lib/types/summaryWriteback.d.ts +87 -0
  36. package/lib/types/views.d.ts +25 -0
  37. package/package.json +1 -1
  38. package/skills/knowledge-graph/SKILL.md +37 -8
  39. package/skills/memory-extract/SKILL.md +43 -0
  40. package/skills/memory-guardian/SKILL.md +97 -0
  41. package/skills/memory-sop-evaluate/SKILL.md +43 -0
package/README.md CHANGED
@@ -4,6 +4,40 @@ DeepSeek-Harness knowledge base: a left-sidebar destination, Settings configurat
4
4
  index tooling over a mounted directory. Runs standalone or against a DataOps backend.
5
5
 
6
6
 
7
+ ## 记忆图谱(0.2.0)
8
+
9
+ 图谱的权威拓扑从可见文件夹移到 `<scope>/.graphs/<graphId>/graph.json`:节点正文留在普通
10
+ 分类目录,frontmatter 携带 `id/type/title/authority/internalizable/origin/reviewStatus`;
11
+ 关系正文放在 `.graphs/<graphId>/links/`。旧 `<scope>/知识图谱/` 文件树仍会被扫描,但响应里
12
+ 标记 `format=legacy`、`readOnly=true`;迁移工具见 `scripts/migrate-graphs.mjs` 和
13
+ `docs/migration-knowledge-graphs.md`(在 dataops 仓库)。
14
+
15
+ - 权限:普通成员看本部门非私有;部门管理员看本部门及下级;管理员/超管看管理范围;
16
+ private 仅 owner。加载器在 Host 侧按 `canReadPath` 逐图谱门禁。
17
+ - 个人绑定:`users/<id>/bindings/*.yaml`,`pending / subscribe / internalize`;
18
+ subscribe 是实时读源的代理,不复制正文;internalize 是独立个人分支。
19
+ 守护会话用 `runGuardianPass` 或 `scripts/memory-guardian.mjs` 手动运行。
20
+ - 红线:`authority: redline` 或 `internalizable: false` 在 Host 侧拒绝内化(节点与关系都
21
+ 继承端点策略),只能订阅;运行时注入带 `nonOverridable` 标记。
22
+ - AI 标签:`origin` / `reviewStatus` 在图谱行与选中条显示 `[AI 生成]` / `[已审核]` / `[红线]`。
23
+ - 摘要变更:`src/summaryIndex.ts` 提供 sha256 快照、确定性父目录链 dirty 和只重算 dirty 文档的
24
+ 入口;`src/summaryWriteback.ts` 已接到索引流程,把 changed/added/removed 文档的确定性摘要写回
25
+ `kb_docs`/SQLite 并按需重写 `index/md/<docId>.INDEX.md`(LLM 摘要不降级,快照最后原子写入)。
26
+ - 运行时工具:`memory_context` 实时返回订阅代理、内化分支和红线(`nonOverridable`);
27
+ `memory_guardian_run` 手动跑一次守护会话(需 `kb:config:manage`)。插件同时注册一条常驻
28
+ 系统提示指令,要求模型在依赖部门口径/流程/红线时先调用 `memory_context`。
29
+ - 图谱写入:`kg_get/kg_add/kg_set/kg_del` 对 `format: 'graph-json'` 的图谱读写
30
+ `.graphs/<id>/graph.json` 与节点 frontmatter,validator 失败回滚,删除只移入 `_trash`。
31
+ - 文档级徽标:legacy 图谱的文档行与 topic 卡也显示 `[AI 生成]` / `[已审核]` / `[红线]`。
32
+
33
+ ## 个人记忆(0.3.0)
34
+
35
+ - 五类记忆:`preference` 偏好、`pitfall` 踩坑、`episodic` 情景、`fact` 事实、`sop` 技能草稿;隐私维度 `normal/private/sensitive/secret`,`secret` 只存 `credentialRef`,不存明文。
36
+ - 存储:`个人记忆图谱/记忆日志/YYYY-MM-DD.md`、`偏好.md`、`踩坑.md`、`事实.md`、`SOP/<slug>.md`;写入同时更新 `.graphs/personal-memory/graph.json`,图谱页可见。
37
+ - 触发:普通会话空闲 30 分钟后调 `memory_guardian_send`;压缩时监听 `compaction/start` 发消息;每日 dream。没有插件队列/空闲 cron,消息投递本身就是队列。
38
+ - 守护会话用标准模式(不新增 preset),由 `users/<uid>/guardian.json` 记录 sessionId,懒创建;它读 `memory-guardian` 技能,派 `memory-extract` / `memory-sop-evaluate` 子代理。
39
+ - 写入工具:`memory_record`(仅守护会话)写五类记忆;`memory_promote_sop` 把有效 SOP 晋升为 `$DSH_HOME/skills/<slug>/SKILL.md` 并删除 SOP。
40
+
7
41
  ## 两种部署形态
8
42
 
9
43
  同一个包,一份代码,由**有没有配置 `baseUrl`** 决定跑哪种形态。这不是一个运行期开关,
@@ -40,6 +74,25 @@ index tooling over a mounted directory. Runs standalone or against a DataOps bac
40
74
  路径校验、上传、提取、搜索、预览这些核心链路两种形态共用同一份实现——区别只是权限判据
41
75
  从「问后端」变成「查本地边界」。
42
76
 
77
+ ## 写入即入库(0.4.3)
78
+
79
+ 写入不是「字节落盘」就结束。`kb_file_write` 和 create/edit/upload/approve 路由在写成功后都走
80
+ `afterDocumentWrite`:
81
+
82
+ - PDF/DOCX/XLSX/PPTX 等可提取格式:进入 extractionQueue,worker 写出 `<source>.md` 后再 chunk +
83
+ index;工具结果返回 `extraction` 任务句柄,用 `extract.status` 查终态。overwrite 会先删掉旧
84
+ 的派生 `.md`,避免文档继续按旧正文被检索。
85
+ - Markdown/TXT/CSV 等文本格式:直接增量 index,结果返回 `index: {status, docId, chunks, indexedAt}`。
86
+ - `kb_file_write` 支持 `encoding:"base64"`,因此 AI 可以写真正的 PDF/DOCX/XLSX 字节,而不是把
87
+ 二进制当文本写坏。
88
+ - 只有两种结果:`indexed`(可检索,带行号)或 `pending-extraction`/`indexing`(异步进行中)。
89
+ 写成功但索引失败只作为状态返回,不回滚文件。
90
+
91
+ `kb_sync`/`views.sync` 不再把 view 里的「未注册文件」直接删掉:带写权限的文件先
92
+ `adoptViewFile` 导入 `actualRoot`(copy + hardlink 回 view),再补 extract/index;无写权限或与
93
+ authoritative 同名冲突才按原逻辑 unlink。这修的是「AI 用 shell cp 把 PDF 放进 view,extract 报
94
+ no such document,下一次 sync 把文件清掉」的原因。
95
+
43
96
  ## 工具按权限披露
44
97
 
45
98
  模型看到的工具清单由 `src/toolDisclosure.ts` 的协调器决定,不在每个 `execute()` 里重复查