返回顶部
o

ontology本体知识图谱

Typed knowledge graph for structured agent memory and composable skills. Use when creating/querying entities (Person, Project, Task, Event, Document), linking related objects, enforcing constraints, planning multi-step actions as graph transformations, or when skills need to share state. Trigger on "remember", "what do I know about", "link X to Y", "show dependencies", entity CRUD, or cross-skill data access.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
154
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

ontology

本体论

一个带类型的词汇表+约束系统,用于将知识表示为可验证的图。

核心概念

一切都是具有类型属性以及与其他实体关系实体。每次变更在提交前都会根据类型约束进行验证。

实体: { id, 类型, 属性, 关系, 创建时间, 更新时间 }
关系: { 来源id, 关系类型, 目标id, 属性 }

使用场景

触发条件操作
记住...创建/更新实体
关于X我知道什么?
查询图 | | 将X链接到Y | 创建关系 | | 显示项目Z的所有任务 | 图遍历 | | 什么依赖于X? | 依赖查询 | | 规划多步骤工作 | 建模为图变换 | | 技能需要共享状态 | 读/写本体对象 |

核心类型

yaml

代理与人员


人员: { 姓名, 邮箱?, 电话?, 备注? }
组织: { 名称, 类型?, 成员[] }

工作

项目: { 名称, 状态, 目标[], 负责人? } 任务: { 标题, 状态, 截止日期?, 优先级?, 执行人?, 阻塞项[] } 目标: { 描述, 目标日期?, 指标[] }

时间与地点

事件: { 标题, 开始时间, 结束时间?, 地点?, 参与者[], 重复规则? } 地点: { 名称, 地址?, 坐标? }

信息

文档: { 标题, 路径?, 网址?, 摘要? } 消息: { 内容, 发送者, 收件人[], 线程? } 线程: { 主题, 参与者[], 消息[] } 笔记: { 内容, 标签[], 引用[] }

资源

账户: { 服务, 用户名, 凭证引用? } 设备: { 名称, 类型, 标识符[] } 凭证: { 服务, 密钥引用 } # 切勿直接存储密钥

元数据

操作: { 类型, 目标, 时间戳, 结果? } 策略: { 范围, 规则, 执行方式 }

存储

默认路径: memory/ontology/graph.jsonl

jsonl
{op:create,entity:{id:p_001,type:Person,properties:{name:Alice}}}
{op:create,entity:{id:proj_001,type:Project,properties:{name:Website Redesign,status:active}}}
{op:relate,from:proj001,rel:hasowner,to:p_001}

通过脚本或直接文件操作进行查询。对于复杂图,可迁移至SQLite。

仅追加规则

处理现有本体数据或模式时,应追加/合并变更而非覆盖文件。这能保留历史记录并避免覆盖先前定义。

工作流程

创建实体

bash
python3 scripts/ontology.py create --type Person --props {name:Alice,email:alice@example.com}

查询

bash
python3 scripts/ontology.py query --type Task --where {status:open}
python3 scripts/ontology.py get --id task_001
python3 scripts/ontology.py related --id proj001 --rel hastask

链接实体

bash
python3 scripts/ontology.py relate --from proj001 --rel hastask --to task_001

验证

bash
python3 scripts/ontology.py validate # 检查所有约束

约束条件

定义在 memory/ontology/schema.yaml 中:

yaml
types:
Task:
required: [title, status]
statusenum: [open, inprogress, blocked, done]

Event:
required: [title, start]
validate: end >= start if end exists

Credential:
required: [service, secret_ref]
forbidden_properties: [password, secret, token] # 强制间接引用

relations:
has_owner:
from_types: [Project, Task]
to_types: [Person]
cardinality: manytoone

blocks:
from_types: [Task]
to_types: [Task]
acyclic: true # 无循环依赖

技能契约

使用本体的技能应声明:

yaml

在 SKILL.md 前置元数据或头部


ontology:
reads: [Task, Project, Person]
writes: [Task, Action]
preconditions:
- Task.assignee must exist
postconditions:
- Created Task has status=open

作为图变换的规划

将多步骤计划建模为一系列图操作:

计划: 安排团队会议并创建后续任务

  1. 1. 创建 事件 { 标题: 团队同步, 参与者: [p001, p002] }
  2. 关联 事件 -> 所属项目 -> proj001
  3. 创建 任务 { 标题: 准备议程, 执行人: p001 }
  4. 关联 任务 -> 所属事件 -> event001
  5. 创建 任务 { 标题: 发送总结, 执行人: p001, 阻塞项: [task_001] }

每一步在执行前都经过验证。违反约束时回滚。

集成模式

与因果推断集成

将本体变更记录为因果动作:

python

创建/更新实体时,同时记录到因果动作日志


action = {
action: create_entity,
domain: ontology,
context: {type: Task, project: proj_001},
outcome: created
}

跨技能通信

python

邮件技能创建承诺


commitment = ontology.create(Commitment, {
sourcemessage: msgid,
description: 周五前发送报告,
due: 2026-01-31
})

任务技能获取承诺

tasks = ontology.query(Commitment, {status: pending}) for c in tasks: ontology.create(Task, { title: c.description, due: c.due, source: c.id })

快速开始

bash

初始化本体存储


mkdir -p memory/ontology
touch memory/ontology/graph.jsonl

创建模式(可选但推荐)

python3 scripts/ontology.py schema-append --data { types: { Task: { required: [title, status] }, Project: { required: [name] }, Person: { required: [name] } } }

开始使用

python3 scripts/ontology.py create --type Person --props {name:Alice} python3 scripts/ontology.py list --type Person

参考资料

  • - references/schema.md — 完整类型定义和约束模式
  • references/queries.md — 查询语言和遍历示例

指令范围

运行时指令操作本地文件(memory/ontology/graph.jsonl 和 memory/ontology/schema.yaml),并提供创建/查询/关联/验证的CLI使用方式;这属于指令范围。该技能可读写工作区文件,并在使用时创建 memory/ontology 目录。验证包括属性/枚举/禁止属性检查、关系类型/基数验证、标记为 acyclic: true 的关系的无环性检查,以及事件 end >= start 检查;其他更高级别的约束可能仍仅作为文档存在,除非在代码中实现。

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 zqtest-1776206703 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 zqtest-1776206703 技能

通过命令行安装

skillhub install zqtest-1776206703

下载

⬇ 下载 ontology v1.0.0(免费)

文件大小: 12.17 KB | 发布时间: 2026-4-17 16:40

v1.0.0 最新 2026-4-17 16:40
- Initial release of the ontology skill: a typed knowledge graph for agent memory and composable skills.
- Supports entity creation, querying, linking, and validation with type constraints.
- Core types include Person, Project, Task, Event, Document, and more.
- Provides CLI workflows for managing entities, relations, and schema validation.
- Designed for cross-skill data sharing and planning as graph transformations.
- Enforces append-only storage to preserve historical data and schema evolution.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部