首页龙虾技能列表 › Ontology — 知识图谱管理

Ontology — 知识图谱管理

v1.0.4

类型化知识图谱工具,用于结构化代理记忆和可组合技能。支持创建/查询实体(人物、项目、任务、事件、文档),链接关系,模式验证和图遍历。

528· 164,000·1086 当前·1119 累计·💬 7
by @oswalpalash·MIT-0
下载技能包
License
MIT-0
最后更新
2026/3/12
安全扫描
VirusTotal
无害
查看报告
OpenClaw
安全
high confidence
该技能内部一致:实现了基于本地文件的类型化知识图谱(ontology),不请求额外凭证、网络访问或异常安装。
评估建议
该技能似乎是一个本地文件支持的 ontology 实现,与其描述一致。安装前请考虑:1) 它将在您的工作区中写入和追加 memory/ontology/graph.jsonl——确保您接受该存储位置和仅追加历史的保留;2) 代码使用路径解析器将操作限制在工作区根目录(安全功能),但如果需要更强保证,仍请自行审查 scripts/ontology.py;3) 模式强制要求秘密应存储为 secret_ref(而非内联)——如计划引用凭证,请确认您的秘密存储集成;4) 由于该技能可由代理调用,请注意代理可自主读/写 ontology(正常行为),因此仅在信任代理管理本地数据时启用它。...
详细分析 ▾
用途与能力
名称/描述(类型化知识图谱、实体 CRUD、关系、规划)与包含的 SKILL.md 和 Python 脚本匹配。无无关的必需环境变量、二进制文件或配置路径。
指令范围
运行时指令明确操作本地文件(默认 memory/ontology/graph.jsonl)并提供创建/查询/关联/验证命令。SKILL.md 不指示读取无关系统文件或联系外部端点。还记录了不直接存储秘密的策略(使用 secret_ref),与描述的目的一致。
安装机制
未提供安装规范(仅指令)。包含的代码是本地 Python 脚本;除了 memory/ontology 下的图文件外,不会在工作区外下载或写入任何内容,这是预期行为。
凭证需求
该技能声明无必需环境变量或主凭证。设计明确避免直接存储秘密并期望秘密引用;这对于 ontology 工具是合理的。
持久化与权限
always 为 false 且允许模型调用(平台默认)。该技能创建/更新本地仅追加图文件(memory/ontology/graph.jsonl),这与其目的相符,不修改其他技能或系统范围代理设置。
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.0.42026/1/26

- Initial release of the ontology skill for typed, constraint-validated knowledge graphs. - Supports entity and relation CRUD, property and relation validation, and graph traversal for common types such as Person, Project, Task, Event, and Document. - Provides schema-driven constraints including required properties, enums, forbidden fields, cardinality, and acyclicity. - Enables multi-step planning and shared memory across skills via structured ontology objects. - Includes CLI tooling for creating, querying, linking, and validating graph data using JSONL storage.

● 无害

安装命令 点击复制

官方npx clawhub@latest install ontology
镜像加速npx clawhub@latest install ontology --registry https://cn.clawhub-mirror.com

技能文档

A typed vocabulary + constraint system for representing knowledge as a verifiable graph.

Core Concept

Everything is an entity with a type, properties, and relations to other entities. Every mutation is validated against type constraints before committing.

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

When to Use

TriggerAction
"Remember that..."Create/update entity
"What do I know about X?"Query graph
"Link X to Y"Create relation
"Show all tasks for project Z"Graph traversal
"What depends on X?"Dependency query
Planning multi-step workModel as graph transformations
Skill needs shared stateRead/write ontology objects

Core Types

# Agents & People
Person: { name, email?, phone?, notes? }
Organization: { name, type?, members[] }

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

# Time & Place Event: { title, start, end?, location?, attendees[], recurrence? } Location: { name, address?, coordinates? }

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

# Resources Account: { service, username, credential_ref? } Device: { name, type, identifiers[] } Credential: { service, secret_ref } # Never store secrets directly

# Meta Action: { type, target, timestamp, outcome? } Policy: { scope, rule, enforcement }

Storage

Default: memory/ontology/graph.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"}

Query via scripts or direct file ops. For complex graphs, migrate to SQLite.

Append-Only Rule

When working with existing ontology data or schema, append/merge changes instead of overwriting files. This preserves history and avoids clobbering prior definitions.

Workflows

Create Entity

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

Query

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

Link Entities

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

Validate

python3 scripts/ontology.py validate  # Check all constraints

Constraints

Define in memory/ontology/schema.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] # Force indirection

relations: has_owner: from_types: [Project, Task] to_types: [Person] cardinality: many_to_one blocks: from_types: [Task] to_types: [Task] acyclic: true # No circular dependencies

Skill Contract

Skills that use ontology should declare:

# In SKILL.md frontmatter or header
ontology:
  reads: [Task, Project, Person]
  writes: [Task, Action]
  preconditions:
    - "Task.assignee must exist"
  postconditions:
    - "Created Task has status=open"

Planning as Graph Transformation

Model multi-step plans as a sequence of graph operations:

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

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

Each step is validated before execution. Rollback on constraint violation.

Integration Patterns

With Causal Inference

Log ontology mutations as causal actions:

# When creating/updating entities, also log to causal action log
action = {
    "action": "create_entity",
    "domain": "ontology", 
    "context": {"type": "Task", "project": "proj_001"},
    "outcome": "created"
}

Cross-Skill Communication

# Email skill creates commitment
commitment = ontology.create("Commitment", {
    "source_message": msg_id,
    "description": "Send report by Friday",
    "due": "2026-01-31"
})

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

Quick Start

# Initialize ontology storage
mkdir -p memory/ontology
touch memory/ontology/graph.jsonl

# Create schema (optional but recommended) python3 scripts/ontology.py schema-append --data '{ "types": { "Task": { "required": ["title", "status"] }, "Project": { "required": ["name"] }, "Person": { "required": ["name"] } } }'

# Start using python3 scripts/ontology.py create --type Person --props '{"name":"Alice"}' python3 scripts/ontology.py list --type Person

References

  • references/schema.md — Full type definitions and constraint patterns
  • references/queries.md — Query language and traversal examples

Instruction Scope

Runtime instructions operate on local files (memory/ontology/graph.jsonl and memory/ontology/schema.yaml) and provide CLI usage for create/query/relate/validate; this is within scope. The skill reads/writes workspace files and will create the memory/ontology directory when used. Validation includes property/enum/forbidden checks, relation type/cardinality validation, acyclicity for relations marked acyclic: true, and Event end >= start checks; other higher-level constraints may still be documentation-only unless implemented in code.

数据来源:ClawHub ↗ · 中文优化:龙虾技能库
OpenClaw 技能定制 / 插件定制 / 私有工作流定制

免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制

了解定制服务