mcpField
O
ontology

ontology

github.com/sundial-orgエージェントワークフロー6703.7k 回インストール34 週間前に更新
リポジトリ

ontology について

ontologyは、知識を検証可能なグラフとして表す型付き語彙と制約システムです。共有状態を扱うエージェントやスキル向けに、変更の事前検証、クエリ、グラフ探索、計画のモデル化を提供します。

主な機能

  1. 01型付きエンティティと関係
  2. 02制約に基づく変更の検証
  3. 03クエリとグラフ探索
  4. 04JSONLファイルへの保存
  5. 05複数段階の計画のモデル化

活用シーン

  1. 01人物、プロジェクト、タスクの記録と検索
  2. 02プロジェクト、担当者、タスクの関連付け
  3. 03型制約に対するデータの検査
  4. 04計画をグラフ操作として表現

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/sundial-org/awesome-openclaw-skills --skill ontology

インストール後、Claude Code で/ontologyを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

references/
queries.md
schema.md
scripts/
ontology.py

詳細

オントロジー

検証可能なグラフとして知識を表現するための、型付き語彙と制約システムです。

基本概念

すべてはエンティティであり、型、プロパティ、ほかのエンティティとの関係を持ちます。変更を確定する前に、すべての変更が型の制約に照らして検証されます。

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

使用するタイミング

トリガーアクション
「これを覚えておいて……」エンティティを作成/更新する
「Xについて何を知っていますか?」グラフをクエリする
「XとYを関連付けて」関係を作成する
「プロジェクトZのタスクをすべて表示して」グラフをたどる
「Xに依存するものは何ですか?」依存関係をクエリする
複数ステップの作業を計画するグラフ変換としてモデル化する
スキルで共有状態が必要オントロジーオブジェクトを読み書きする

基本型

# 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 }

ストレージ

デフォルト: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"}

スクリプトまたはファイルを直接操作してクエリします。複雑なグラフでは、SQLiteに移行します。

ワークフロー

エンティティの作成
python3 scripts/ontology.py create --type Person --props '{"name":"Alice","email":"[email protected]"}'
クエリ
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
エンティティの関連付け
python3 scripts/ontology.py relate --from proj_001 --rel has_task --to task_001
検証
python3 scripts/ontology.py validate  # Check all constraints

制約

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

スキルの契約

オントロジーを使用するスキルでは、次の項目を宣言します。

# 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"

グラフ変換としての計画

複数ステップの計画を、一連のグラフ操作としてモデル化します。

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] }

各ステップは実行前に検証されます。制約違反があればロールバックします。

統合パターン

因果推論との連携

オントロジーの変更を因果アクションとして記録します。

# When creating/updating entities, also log to causal action log
action = {
    "action": "create_entity",
    "domain": "ontology", 
    "context": {"type": "Task", "project": "proj_001"},
    "outcome": "created"
}
スキル間通信
# 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
    })

クイックスタート

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

# Create schema (optional but recommended)
cat > memory/ontology/schema.yaml << 'EOF'
types:
  Task:
    required: [title, status]
  Project:
    required: [name]
  Person:
    required: [name]
EOF

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

参考資料

  • references/schema.md — 型定義と制約パターンの全容
  • references/queries.md — クエリ言語とグラフをたどる例

コメント