← 返回 Skills 市场
37
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install sipoon-memory-graph
功能描述
基于 SQLite 的实体关系图谱存储,提供 add_entity / add_relation / query / traverse / get_path 等原子操作,供 skill-compounding 沉淀时调用。
使用说明 (SKILL.md)
Memory Graph(知识图谱记忆)
基于 SQLite 实现 Phase 3 图数据库存储和查询,存储位置 knowledge/graph.db。
核心 API(graph_store.py)
from skills.memory-graph.graph_store import add_entity, add_relation, query, traverse, get_path, stats
# 添加实体(type: 项目/技术/决策/日期/人物/技能/工具)
add_entity(type_="skill", name="brainstorming", meta={"trigger": "复杂任务规划", "confidence": 0.9})
add_entity(type_="project", name="JD Reader DRM", meta={"goal": "EPUB解密逆向"})
# 添加关系(weight: 0-1,rel: 因果/包含/依赖/触发/使用/产生)
add_relation(source="brainstorming#skill", rel="used_for", target="JD Reader DRM#project", weight=0.8)
# 搜索实体
query("brainstorming") # name 模糊匹配
query("brainstorming", type_="skill") # type_ 精确过滤
# 图遍历
traverse(start="brainstorming#skill", rel="used_for", direction="out")
# → [{source, rel, target, target_name, target_type, weight}]
# 找路径
get_path(from_="用户", to="JD Reader DRM", max_depth=3)
# 统计
stats()
# → {nodes, edges, by_type, by_rel, db_path}
数据模型
nodes (id=16字符SHA256, type_, name, meta=JSON, updated_at)
id = SHA256("type:name") 取前16位(保证同一 type:name 不重复)
type_ ∈ {项目, 技术, 决策, 日期, 人物, 技能, 工具}
meta 存扩展属性(置信度、来源、标签等)
edges (id=16字符SHA256, source, rel, target, weight, meta, updated_at)
id = SHA256("source|rel|target") 取前16位(保证唯一)
rel ∈ {因果, 包含, 依赖, 触发, 使用, 产生, 导致, 用于, 继承}
source/target 支持 entity_id(16字符)或 name#type 格式
与 skill-compounding 的配合
skill-compounding 沉淀时调用示例:
from skills.memory-graph.graph_store import add_entity, add_relation
def on_skill_compounding(compounding_result: dict):
"""skill-compounding 触发时的实体关系沉淀"""
skill_name = compounding_result["skill_name"]
trigger = compounding_result.get("trigger", "")
decisions = compounding_result.get("decisions", [])
projects = compounding_result.get("projects", [])
# 1. 提取实体
skill_id = add_entity("skill", skill_name, {"trigger": trigger})
for p in projects:
add_entity("project", p)
for d in decisions:
add_entity("decision", d, {"source": "skill-compounding"})
# 2. 建立关系
for p in projects:
add_relation(f"{skill_name}#skill", "用于", f"{p}#project")
for d in decisions:
add_relation(f"{skill_name}#skill", "导致", f"{d}#decision")
if trigger:
add_relation(trigger, "触发", f"{skill_name}#skill")
查询能力
| 查询 | 方法 | 说明 |
|---|---|---|
| "用户最近在做什么项目?" | traverse(user, "参与", "out") | 用户参与的项目 |
| "brainstorming 用于哪些场景?" | traverse("brainstorming#skill", "用于", "out") | 所有应用场景 |
| "决策X的影响链是什么?" | get_path("决策X", "用户", max_depth=4) | 最短因果路径 |
| "某项目用了哪些技术?" | traverse(project, "使用", "out") | 技术栈 |
| "哪些技能受某项目影响?" | traverse(project, "触发", "in") | 受影响技能 |
状态
| 阶段 | 状态 | 说明 |
|---|---|---|
| Phase 1:实体提取 | ✅ 规范已定义 | 正则提取,需 skill-compounding 触发 |
| Phase 2:关系推理 | ✅ 规范已定义 | 规则推断,需 skill-compounding 触发 |
| Phase 3:图数据库 | ✅ 已实现 | SQLite,graph_store.py 提供全套 API |
触发命令
"开启知识图谱"、"记忆关系图"、"实体关系检索"
安全使用建议
Install only if you want a persistent local knowledge graph. Before using it, change the hard-coded database path to a user-controlled workspace path, understand that imported code creates or opens the database, and avoid storing sensitive project or personal details unless you have clear retention and deletion practices.
能力评估
Purpose & Capability
The SQLite entity/relationship graph APIs match the stated memory-graph purpose and there is no evidence of network access, credential access, exfiltration, or destructive behavior.
Instruction Scope
The skill defines broad natural-language trigger phrases for a persistent memory feature and does not specify confirmation, retention, deletion, or boundaries for when stored graph data may be written or queried.
Install Mechanism
The artifact contains only SKILL.md, _meta.json, and a Python module, with no package install steps, dependency downloads, or privileged setup.
Credentials
The documentation says the database is stored at knowledge/graph.db, but the code hard-codes C:\Users\37845\.qclaw\workspace\knowledge\graph.db and initializes it on import, which is not portable and is broader than disclosed.
Persistence & Privilege
The skill persistently stores user/project/decision graph data in SQLite and exposes query/traversal APIs without visible access controls or lifecycle controls.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install sipoon-memory-graph - 安装完成后,直接呼叫该 Skill 的名称或使用
/sipoon-memory-graph触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.0
memory-graph 0.2.0 introduces an SQLite-based entity-relationship graph store with atomic operations for integration and querying.
- Added SQLite-backed storage of knowledge graphs at knowledge/graph.db.
- Implemented core API: add_entity, add_relation, query, traverse, get_path, and stats.
- Defined clear data model for entities (nodes) and relationships (edges) with hashed IDs.
- Provided usage examples and integration guidance with skill-compounding.
- Documented supported graph queries and operational status for each development phase.
元数据
常见问题
Memory Graph 是什么?
基于 SQLite 的实体关系图谱存储,提供 add_entity / add_relation / query / traverse / get_path 等原子操作,供 skill-compounding 沉淀时调用。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 37 次。
如何安装 Memory Graph?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install sipoon-memory-graph」即可一键安装,无需额外配置。
Memory Graph 是免费的吗?
是的,Memory Graph 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Memory Graph 支持哪些平台?
Memory Graph 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Memory Graph?
由 Sipoon(@sipoon)开发并维护,当前版本 v0.1.0。
推荐 Skills