Ontology logo

Ontology

Community
L-LesterYu
ontology

类型化知识图谱——用于结构化 Agent 记忆和可组合技能。适用于创建/查询实体(Person、Project、Task、Event、Document)、关联相关对象、执行约束验证、将多步骤操作建模为图变换,或跨技能共享状态。触发词:"记住"、"我知道关于 X 的什么"、"链接 X 到 Y"、"显示依赖关系"、实体 CRUD 或跨技能数据访问。

Overview

PublisherL-LesterYu
RepositoryOpenClaw-hot-skills-zh
Skill nameontology
Stars
57
Forks
9
Bundled files
4
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 4 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by L-LesterYu on GitHub. Read the source before you install it.

Installation

Install the Ontology AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/L-LesterYu/OpenClaw-hot-skills-zh/tree/main/skills/ontology-v4-zh
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/L-LesterYu/OpenClaw-hot-skills-zh.git /tmp/OpenClaw-hot-skills-zh
mkdir -p .claude/skills
cp -r /tmp/OpenClaw-hot-skills-zh/skills/ontology-v4-zh .claude/skills/ontology
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Ontology in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Ontology on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Ontology is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

本体论(Ontology)

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

核心概念

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

Entity: { id, type, properties, relations, created, updated }
Relation: { from_id, relation_type, to_id, properties }

使用场景

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

核心类型

yaml
# 智能体与人员
Person: { name, email?, phone?, notes? }
Organization: { name, type?, members[] }

# 工作管理
Project: { name, status, goals[], owner? }
Task: { title, status, due?, priority?, assignee?, blockers[] }
Goal: { description, target_date?, metrics[] }

# 时间与地点
Event: { title, start, end?, location?, attendees[], recurrence? }
Location: { name, address?, coordinates? }

# 信息
Document: { title, path?, url?, summary? }
Message: { content, sender, recipients[], thread? }
Thread: { subject, participants[], messages[] }
Note: { content, tags[], refs[] }

# 资源
Account: { service, username, credential_ref? }
Device: { name, type, identifiers[] }
Credential: { service, secret_ref }  # 永远不要直接存储密钥

# 元数据
Action: { type, target, timestamp, outcome? }
Policy: { scope, rule, enforcement }

存储

默认路径: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":"proj_001","rel":"has_owner","to":"p_001"}

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

仅追加规则

在处理现有本体数据或 Schema 时,追加/合并变更而非覆盖文件。这样可以保留历史记录,避免破坏先前的定义。

工作流

创建实体

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 proj_001 --rel has_task

关联实体

bash
python3 scripts/ontology.py relate --from proj_001 --rel has_task --to task_001

验证

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

约束

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

yaml
types:
  Task:
    required: [title, status]
    status_enum: [open, in_progress, 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: many_to_one
  
  blocks:
    from_types: [Task]
    to_types: [Task]
    acyclic: true  # 不允许循环依赖

技能契约

使用本体的技能应声明:

yaml
# 在 SKILL.md 的 frontmatter 或头部中
ontology:
  reads: [Task, Project, Person]
  writes: [Task, Action]
  preconditions:
    - "Task.assignee must exist"
  postconditions:
    - "Created Task has status=open"

将规划建模为图变换

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

Plan: "Schedule team meeting and create follow-up tasks"

1. CREATE Event { title: "Team Sync", attendees: [p_001, p_002] }
2. RELATE Event -> has_project -> proj_001
3. CREATE Task { title: "Prepare agenda", assignee: p_001 }
4. RELATE Task -> for_event -> event_001
5. CREATE Task { title: "Send summary", assignee: p_001, blockers: [task_001] }

每一步在执行前都会被验证。约束违反时自动回滚。

集成模式

与因果推理集成

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

python
# 创建/更新实体时,同时记录到因果动作日志
action = {
    "action": "create_entity",
    "domain": "ontology", 
    "context": {"type": "Task", "project": "proj_001"},
    "outcome": "created"
}

跨技能通信

python
# 邮件技能创建承诺
commitment = ontology.create("Commitment", {
    "source_message": msg_id,
    "description": "Send report by Friday",
    "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

# 创建 Schema(可选但推荐)
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 的关系无环检测,以及 Event 的 end >= start 检查;其他高级约束可能仅为文档说明,除非已在代码中实现。

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Ontology AI skill do?

类型化知识图谱——用于结构化 Agent 记忆和可组合技能。适用于创建/查询实体(Person、Project、Task、Event、Document)、关联相关对象、执行约束验证、将多步骤操作建模为图变换,或跨技能共享状态。触发词:"记住"、"我知道关于 X 的什么"、"链接 X 到 Y"、"显示依赖关系"、实体 CRUD 或跨技能数据访问。

Why use Ontology on TypingMind?

Because you install it once and use it with any model. Ontology is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Ontology in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/L-LesterYu/OpenClaw-hot-skills-zh/tree/main/skills/ontology-v4-zh. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Ontology?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Ontology?

As many as you like. As long as a model supports skills, you can use Ontology with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Ontology AI skill free?

Yes. It is published on GitHub by L-LesterYu under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇