knowledge-graph-traversal
Skill0 starsChanged 3 months agoMITView on GitHub
压缩知识图谱遍历 v2:跨层遍历+独立图谱服务。借鉴 CKG "遍历而非检索" + OpenClaw memory-core 独立运行时。
In this repository219 other files it gives its agents.
- agent-doctrineSkill
- agent-evaluation-frameworkSkill
- agent-visualization-flintSkill
- hermes-agentSkill
- bailian-cliSkill
- edge-browser-automationSkill
- computer-useSkill
- jupyter-live-kernelSkill
- backup-strategiesSkill
- browser-automationSkill
- chinese-ai-free-apiSkill
- cicd-pipeline-templatesSkill
- copybaraSkill
- devops-toolkitSkill
- email-deliverabilitySkill
- monitoring-observabilitySkill
- obsidian-maintenanceSkill
- obsidian-troubleshootingSkill
- openclaw-windowsSkill
- openclaw-workerSkill
- webhook-subscriptionsSkill
- windows-dev-environmentSkill
- windows-masterSkill
- zero-downtime-deploySkill
- codebase-inspectionSkill
- github-workflowSkill
- adaptive-communicationSkill
- agent-cost-dashboardSkill
- agent-evolutionSkill
- agent-governanceSkill
- agent-osSkill
- context-efficient-toolsSkill
- context-loss-awarenessSkill
- creative-synthesisSkill
- hermes-desktop-pluginsSkill
- emotional-intelligenceSkill
- graph-engineering-workflowSkill
- hermes-maintenanceSkill
- hermes-voiceSkill
- hermes-hygieneSkill
- identity-coreSkill
- income-loopSkill
- master-synthesisSkill
- meta-cognitionSkill
- reasoning-engineSkill
- self-preservationSkill
- teaching-abilitySkill
- temporal-awarenessSkill
- hermes-themesSkill
- thinking-visualizationSkill
- user-modelingSkill
- voice-full-restoreSkill
- mcp-browser-canvasSkill
- free-api-gatewaySkill
- native-mcpSkill
- web-reverse-apiSkill
- ai-edaSkill
- huggingface-hubSkill
- industrial-ai-siemens-mcpSkill
- industrial-ai-unifiedSkill
- The first 60 shown.
The file
Files
知识图谱遍历 — CKG 模式
核心理念
来自 ckg-nvidia-ai 的洞察:遍历而非检索。 不要用 embedding/RAG/TF-IDF 搜,而是沿着声明好的关系图谱一步步走。
"The fix is not a better model. It is structured context." "Every time your agent calls out to ask what TensorRT-LLM requires, it spends ~2,982 tokens re-inferring a relationship that could be declared once and traversed in 269."
Hermes 知识库现状
- 36 个 Markdown 文档
- 140 个 [[wikilinks]] 双向链接
- 6 大领域中枢节点
- 已有
D:/Hermes/knowledge-base/技能图谱/kb-graph.json
三级遍历策略
L1:入口定位(1 步)
给定查询词,直接命中中枢节点或最近的文档。
"TTS 方案" → [[TTS 语音合成]] (直接命中)
"Agent 调度" → [[02-智能体基础设施]] → [[agent-mesh]]L2:关系遍历(2-3 步)
从命中文档沿 [[wikilinks]] 走出去,找到关联文档。
[[TTS 语音合成]] → [[Hermes 语音闭环]] → [[沟通/郑鑫沟通偏好]]
一步:方案本身 | 二步:集成方式 | 三步:面向谁L3:全图探索(5+ 步)
从任意节点出发,深度遍历整个领域。
[[01-开发流水线]] → 展开全部 28 个开发技能的关系网Token 节省对比
| 方式 | Token | 描述 |
| 全量加载 36 个文档 | ~80,000 | 直接塞上下文 |
| TF-IDF 搜索 Top-5 | ~15,000 | 当前 kb_search.py 方式 |
| 图谱遍历 L1 | ~300 | 只读索引 + 目标文档 |
| 图谱遍历 L2 | ~800 | 目标文档 + 2 步邻居 |
| SigMap 查询 | ~500 | 确定性签名匹配 |
使用方式
手动模式(现有能力)
1. search_files 搜 [[wikilinks]] 关键词 → 找命中文档
2. read_file 读命中文档 → 提取其中的 [[wikilinks]]
3. 沿 [[wikilinks]] 跳到关联文档 → 找到完整答案图谱文件
D:/Hermes/knowledge-base/技能图谱/kb-graph.json— 完整图谱数据D:/Hermes/knowledge-base/技能图谱/dashboard.html— 力导向可视化- SigMap 可对知识库建签名地图:
npx sigmap --query "主题" D:/Hermes/scripts/auto_inject.py— 自动上下文注入脚本(零依赖 TF-IDF + wikilinks 提取)D:/Hermes/knowledge-base/技术/deja-vu与agent-memory-engine设计精华.md— GitHub 项目设计精华提取
自动上下文注入(借鉴 deja-vu SessionStart hook)
deja-vu 的核心设计:会话开始前自动搜索相关记忆并注入上下文,不等用户问。
触发时机
每次新会话启动时(用户发第一条消息后),在回答之前执行:
- 提取关键词:从用户第一条消息中提取 2-3 个核心关键词
- 搜索知识库:用
search_files在D:\Hermes\knowledge-base\搜这些关键词 - 读命中文档:对 Top-2 结果调用
read_file获取内容 - 搜会话历史:用
session_search搜相关历史会话 - 注入上下文:在回答中引用相关知识点和 wikilinks
示例流程
用户: "TTS 播报不工作了"
→ 关键词: TTS, 语音播报, 故障
→ search_files 搜 knowledge-base → 命中 [[TTS 语音合成]]、[[Hermes 语音闭环]]
→ session_search "TTS 问题" → 上一次 TTS 修复记录
→ 回答: "上次修过类似问题(voice.py:835 的 0.5s 重开麦),先检查..."注意
- 只注入 Top-2 文档,避免 token 浪费
- 如果知识库无匹配,直接回答不经注入
- session_search 结果仅供参考,不替代直接检查
设计原则
- 确定性:同一查询永远走同一条遍历路径,可复现可审计
- 声明式:关系写在 [[wikilinks]] 里,不靠模型推理
- 分层访问:从 L1 到 L3 逐步升温,只在必要时多读
- 可组合:与 SigMap(代码签名地图)+ kb-graph.json(知识图谱)互补
- 预注入:会话开始时主动搜索,不等用户问(借鉴 deja-vu)
CKG 层的扩展方向
当前:36 个文档,140 个关系 = 知识层 未来:可叠加更多层——
- 技能层:105 个技能之间的依赖关系
- 配置层:config.yaml 各项之间的影响链
- 项目层:D:/Hermes/ 下项目的依赖关系
每层独立声明关系,Agent 按需跨层遍历。
跨层遍历(v2.0 新增)— 借鉴 OpenClaw memory-core 独立运行时
从单层到多层
v1.0 只在知识层内遍历 wikilinks。v2.0 支持跨层跳转:
知识层: [[TTS 语音合成]]
↓ "需要配置什么?"
配置层: [[config.yaml#tts]] → [[config.yaml#voice]]
↓ "哪个技能用这个配置?"
技能层: [[voice-full-restore]] → [[voice-wake-word]]
↓ "这个技能借鉴了哪个项目?"
外部: [[hermes-lcm]] GitHub独立图谱服务(v2.0 新增)— 借鉴 OpenClaw memory-core split
OpenClaw 将 memory-core 拆分独立运行时——图谱也应该是独立服务:
Agent ← 查询 → Knowledge Graph Service → kb-graph.json
← 结果 ← → wikilinks 索引
→ 跨层关系映射当前实现:D:/Hermes/knowledge-base/技能图谱/kb-graph.json
未来:MCP 端点 mcp__knowledge_graph__traverse(query, depth=2)
三层查询模式
| 模式 | 深度 | Token | 场景 |
| 点查 | 0 跳 | ~300 | "TTS 方案在哪" |
| 邻域 | 2 跳 | ~800 | "TTS 相关的所有配置" |
| 跨层 | 跨 2 层 | ~1200 | "TTS 故障→配置→技能→修复历史" |
参考
- ckg-nvidia-ai: https://github.com/Yarmoluk/ckg-nvidia-ai (3⭐, 4×F1, 11× token savings)
- Graphify.md: https://graphifymd.com (CKG 构建工具)
- deja-vu: https://github.com/vshulcz/deja-vu (281⭐) — SessionStart 自动注入、零依赖索引
- agent-memory-engine: https://github.com/uudam42/agent-memory-engine (122⭐) — 证据链追溯、候选暂存区
- 已有基础:
D:/Hermes/knowledge-base/39 文档 + 140 wikilinks - 借鉴总结:
技术/deja-vu与agent-memory-engine设计精华.md - 自动注入脚本:
D:/Hermes/scripts/auto_inject.py(零依赖 TF-IDF + wikilinks 提取)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

