[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71ASVN2A9K7DFAVF760SK9K":3,"skill-same:01M71ASVN2A9K7DFAVF760SK9K":68},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":14,"repositoryHtmlUrl":51,"repositoryHomepageUrl":6,"ownerHtmlUrl":52,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":53,"install":54,"resources":67},"01M71ASVN2A9K7DFAVF760SK9K","ontology",null,"A typed vocabulary + constraint system for representing knowledge as a verifiable graph. Everything is an entity with a type, properties, and relations to other entities. Use when creating\u002Fquerying 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.","sapsapshen\u002Fai-memory-router","sapsapshen","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F20347959?v=4","01M6XDQEF1DP50DKF37H81J3J5","shenmian","01M6XDQEJPE41Y3DT2763X8ZJN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fopenclaw\u002Fontology\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[5,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"do","when","linking","for","event","trigger","as","project","objects","remember","show","crud","system","access","knowledge","data","actions","graph","planning","2026-11-10 10:12:30",false,"---\nname: ontology\ndescription: \"A typed vocabulary + constraint system for representing knowledge as a verifiable graph. Everything is an entity with a type, properties, and relations to other entities. Use when creating\u002Fquerying 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.\"\n---\n\n# Ontology — Typed Knowledge Graph System\n\n## Overview\n\nThe Ontology skill provides a **structured knowledge representation system** that transforms unstructured information into a verifiable, queryable graph. It implements a local, file-based typed knowledge graph (ontology) with constraints, validation, and rich query capabilities.\n\n## Core Concepts\n\n### 1. Entity-Based Model\n```\nEverything is an Entity:\n┌─────────────────────────────────────┐\n│ Entity                              │\n│ ├── Type: Person|Project|Task|Event │\n│ ├── Properties: key-value pairs     │\n│ └── Relations: links to other entities\n└─────────────────────────────────────┘\n```\n\n### 2. Type System\n```yaml\n# Built-in entity types\nPerson:\n  required: [name]\n  optional: [email, role, bio]\n  relations: [works_on, manages, reports_to]\n\nProject:\n  required: [title, status]\n  optional: [description, deadline, priority]\n  relations: [has_member, depends_on, related_to]\n\nTask:\n  required: [description, status]\n  optional: [assignee, due_date, priority]\n  relations: [part_of, blocks, related_to]\n\nEvent:\n  required: [title, date]\n  optional: [location, description, attendees]\n  relations: [has_participant, follows, related_to]\n\nDocument:\n  required: [title, path]\n  optional: [type, tags, summary]\n  relations: [authored_by, references, version_of]\n```\n\n### 3. Constraint System\n```python\n# Type constraints\nconstraints:\n  Person:\n    email: \"must be valid email format\"\n    role: \"must be one of: developer, manager, analyst\"\n    \n  Project:\n    status: \"must be one of: planning, active, completed, archived\"\n    deadline: \"must be future date if status=active\"\n    \n  Task:\n    priority: \"must be 1-5\"\n    due_date: \"must be after created_date\"\n```\n\n## When to Use This Skill\n\n### Scenario 1: Knowledge Organization\n```\nSituation: \"Remember that John is working on the WebApp project\"\nAction: Create Person(John) and Project(WebApp) entities, link with works_on\nResult: Structured knowledge that can be queried later\n```\n\n### Scenario 2: Dependency Tracking\n```\nSituation: \"Show me all tasks that depend on the database design\"\nAction: Query task dependencies as a graph\nResult: Visual dependency tree with blocking relationships\n```\n\n### Scenario 3: Cross-Skill Data Sharing\n```\nSituation: Multiple skills need access to the same project information\nAction: Store project data in ontology, all skills query from central graph\nResult: Consistent data across all skills\n```\n\n### Scenario 4: Constraint Validation\n```\nSituation: \"Assign this task to Sarah\"\nAction: Check if Sarah is a Person, has capacity, skills match task\nResult: Valid assignment or specific constraint violations\n```\n\n## Core Operations\n\n### 1. Entity Management\n```bash\n# Create an entity\nontology create Person --name \"John Doe\" --email \"john@example.com\" --role \"developer\"\n\n# Update an entity\nontology update Person john_doe --role \"senior developer\" --bio \"Experienced full-stack developer\"\n\n# Delete an entity\nontology delete Person john_doe\n\n# List all entities of a type\nontology list Person\nontology list Project --filter \"status=active\"\n```\n\n### 2. Relation Management\n```bash\n# Create a relation\nontology relate Person john_doe works_on Project web_app\n\n# Remove a relation\nontology unrelate Person john_doe works_on Project web_app\n\n# Find related entities\nontology relations Person john_doe --type works_on\nontology relations Project web_app --incoming  # Who works on this project?\n```\n\n### 3. Query System\n```bash\n# Simple query\nontology query \"Person where role='developer'\"\n\n# Complex query with relations\nontology query \"Person where (works_on Project where status='active') and role='developer'\"\n\n# Graph traversal\nontology traverse Person john_doe --depth 3 --relation works_on,manages\n\n# Find paths between entities\nontology path Person john_doe to Project ai_research --max-hops 5\n```\n\n### 4. Constraint Operations\n```bash\n# Validate all entities\nontology validate --all\n\n# Validate specific type\nontology validate Person\n\n# Check constraints for an entity\nontology constraints Person john_doe\n\n# Add custom constraint\nontology constraint add Person \"email must contain '@'\"\n```\n\n### 5. Import\u002FExport\n```bash\n# Export ontology to various formats\nontology export --format json --output ontology.json\nontology export --format graphviz --output ontology.dot\nontology export --format csv --output entities.csv\n\n# Import data\nontology import --file data.json --format json\nontology import --file data.csv --format csv --type Person\n```\n\n## File Structure\n\n```\n~\u002F.openclaw\u002Fworkspace\u002Fmemory\u002Fontology\u002F\n├── schema\u002F\n│   ├── types.yaml          # Entity type definitions\n│   ├── constraints.yaml    # Constraint definitions\n│   └── relations.yaml      # Relation type definitions\n├── entities\u002F\n│   ├── Person\u002F\n│   │   ├── john_doe.yaml\n│   │   └── sarah_smith.yaml\n│   ├── Project\u002F\n│   │   ├── web_app.yaml\n│   │   └── ai_research.yaml\n│   └── Task\u002F\n│       ├── design_db.yaml\n│       └── implement_api.yaml\n├── graphs\u002F\n│   ├── project_team.graph\n│   └── task_dependencies.graph\n└── indexes\u002F\n    ├── by_type.index\n    ├── by_property.index\n    └── by_relation.index\n```\n\n## Integration Examples\n\n### With MemOS Sync\n```yaml\n# Ontology entities can be synced to MemOS\nPerson:\n  sync_to_memos: true\n  privacy: \"private\"\n  \nProject:\n  sync_to_memos: true  \n  privacy: \"shared\"  # Share with team\n```\n\n### With ClawTeam\n```python\n# Use ontology to assign tasks to agents\ndef assign_task_to_agent(task, agents):\n    \"\"\"Find best agent for a task using ontology\"\"\"\n    \n    # Query agents with required skills\n    suitable_agents = ontology.query(\n        f\"Person where skills includes '{task.required_skill}' \"\n        f\"and current_load \u003C max_capacity\"\n    )\n    \n    # Consider past performance\n    for agent in suitable_agents:\n        agent_score = calculate_agent_score(agent, task)\n        # Assign to highest scoring agent\n    \n    return best_agent\n```\n\n### With Self-Improving Agent\n```python\n# Track learning patterns in ontology\ndef track_learning_pattern(agent, topic, effectiveness):\n    \"\"\"Record learning patterns in ontology\"\"\"\n    \n    # Create or update LearningPattern entity\n    pattern = ontology.get_or_create(\n        \"LearningPattern\",\n        agent=agent.id,\n        topic=topic,\n        pattern_type=\"effectiveness\"\n    )\n    \n    # Add effectiveness data point\n    pattern.add_data_point(\n        timestamp=datetime.now(),\n        effectiveness=effectiveness,\n        context=agent.current_context\n    )\n    \n    # Analyze patterns over time\n    patterns = ontology.query(\n        f\"LearningPattern where agent='{agent.id}' and topic='{topic}'\"\n    )\n    \n    return analyze_patterns(patterns)\n```\n\n## Use Case Examples\n\n### Use Case 1: Project Management\n```bash\n# 1. Create project structure\nontology create Project \"Web App\" --status \"planning\" --priority \"high\"\nontology create Person \"Alice\" --role \"frontend\" --skills \"React,TypeScript\"\nontology create Person \"Bob\" --role \"backend\" --skills \"Python,FastAPI\"\nontology create Person \"Carol\" --role \"devops\" --skills \"Docker,AWS\"\n\n# 2. Assign team members\nontology relate Person alice works_on Project \"Web App\"\nontology relate Person bob works_on Project \"Web App\" \nontology relate Person carol works_on Project \"Web App\"\n\n# 3. Create tasks with dependencies\nontology create Task \"Design UI\" --assignee alice --due \"2026-04-05\"\nontology create Task \"Implement API\" --assignee bob --due \"2026-04-07\"\nontology create Task \"Deploy to staging\" --assignee carol --due \"2026-04-10\"\n\nontology relate Task \"Implement API\" blocks Task \"Deploy to staging\"\nontology relate Task \"Design UI\" related_to Task \"Implement API\"\n\n# 4. Query project status\nontology query \"Task where assignee=alice and status!=completed\"\nontology traverse Project \"Web App\" --depth 2 --relation works_on,blocks\n```\n\n### Use Case 2: Knowledge Base\n```bash\n# 1. Document important concepts\nontology create Concept \"Machine Learning\" --category \"AI\"\nontology create Concept \"Neural Networks\" --category \"AI\"\nontology create Concept \"Supervised Learning\" --category \"AI\"\n\n# 2. Create relationships\nontology relate Concept \"Neural Networks\" subclass_of Concept \"Machine Learning\"\nontology relate Concept \"Supervised Learning\" subclass_of Concept \"Machine Learning\"\n\n# 3. Link to resources\nontology create Document \"ML Tutorial\" --path \"\u002Fdocs\u002Fml.md\" --type \"tutorial\"\nontology relate Document \"ML Tutorial\" explains Concept \"Machine Learning\"\n\n# 4. Query knowledge graph\nontology query \"Concept where category='AI'\"\nontology path Concept \"Supervised Learning\" to Document --via subclass_of,explains\n```\n\n### Use Case 3: Personal CRM\n```bash\n# 1. Track people and interactions\nontology create Person \"David Chen\" --company \"TechCorp\" --role \"CTO\"\nontology create Event \"Meeting with David\" --date \"2026-04-02\" --type \"business\"\nontology relate Event \"Meeting with David\" has_participant Person \"David Chen\"\n\n# 2. Record notes and follow-ups\nontology create Note \"Discussed API partnership\" --date \"2026-04-02\"\nontology relate Note \"Discussed API partnership\" about Event \"Meeting with David\"\n\nontology create Task \"Send partnership proposal\" --due \"2026-04-03\"\nontology relate Task \"Send partnership proposal\" follows Event \"Meeting with David\"\n\n# 3. Query contact history\nontology traverse Person \"David Chen\" --depth 2 --relation has_participant,about,follows\n```\n\n## Configuration\n\n```yaml\n# ~\u002F.openclaw\u002Fworkspace\u002Fmemory\u002Fontology\u002Fconfig.yaml\nontology:\n  # Storage settings\n  storage:\n    directory: \"~\u002F.openclaw\u002Fworkspace\u002Fmemory\u002Fontology\"\n    format: \"yaml\"  # or: json, toml\n    compression: true\n    backup_count: 7\n    \n  # Indexing\n  indexing:\n    auto_index: true\n    index_types: [\"Person\", \"Project\", \"Task\", \"Event\"]\n    update_frequency: \"on_change\"  # or: hourly, daily\n    \n  # Validation\n  validation:\n    strict_mode: true\n    auto_validate: true\n    validate_on_save: true\n    \n  # Privacy\n  privacy:\n    encrypt_sensitive: true\n    sensitive_fields: [\"email\", \"phone\", \"address\"]\n    anonymize_for_export: true\n    \n  # Integration\n  integration:\n    memos_sync:\n      enabled: true\n      sync_entities: [\"Person\", \"Project\", \"Task\"]\n      \n    clawteam:\n      enabled: true\n      entity_types: [\"Person\", \"Task\", \"Project\"]\n      \n    proactive_agent:\n      enabled: true\n      monitor_changes: true\n      \n  # Advanced\n  advanced:\n    graph_traversal_max_depth: 10\n    query_timeout: 30\n    cache_size: 1000\n    auto_cleanup: true\n```\n\n## Best Practices\n\n### 1. Start Simple\n```bash\n# Begin with basic entities\nontology create Person \"Test User\" --role \"tester\"\nontology create Project \"Test Project\" --status \"active\"\n\n# Add complexity gradually\nontology relate Person \"Test User\" works_on Project \"Test Project\"\n```\n\n### 2. Use Consistent Naming\n```bash\n# Good: Consistent, descriptive names\nontology create Person \"john_doe\" --name \"John Doe\"\nontology create Project \"web_app_2026\" --title \"Web App 2026\"\n\n# Bad: Inconsistent naming\nontology create Person \"jdoe\"  # Unclear\nontology create Project \"wa\"   # Too cryptic\n```\n\n### 3. Leverage Constraints\n```yaml\n# Define constraints early\nPerson:\n  email: \"must match email regex\"\n  role: \"must be one of: developer, manager, analyst, tester\"\n  \nTask:\n  status: \"must be: todo, in_progress, blocked, completed\"\n  priority: \"must be 1-5\"\n```\n\n### 4. Regular Maintenance\n```bash\n# Weekly cleanup\nontology validate --all --fix\nontology cleanup --orphaned\nontology backup --full\n\n# Monthly optimization\nontology reindex --all\nontology analyze --performance\n```\n\n## Troubleshooting\n\n### Common Issues\n\n1. **Entity not found**\n   ```bash\n   # Check if entity exists\n   ontology get Person john_doe\n   \n   # Search for similar entities\n   ontology search \"john\" --type Person\n   \n   # Check indexes\n   ontology index status\n   ```\n\n2. **Constraint violation**\n   ```bash\n   # See specific violation\n   ontology validate Person john_doe --verbose\n   \n   # List all constraints for type\n   ontology constraints Person\n   \n   # Temporarily disable constraints\n   ontology create Person test --email \"invalid\" --no-validate\n   ```\n\n3. **Performance issues**\n   ```bash\n   # Rebuild indexes\n   ontology reindex --all\n   \n   # Clear cache\n   ontology cache clear\n   \n   # Analyze query performance\n   ontology analyze query \"Person where role='developer'\"\n   ```\n\n4. **Import\u002Fexport problems**\n   ```bash\n   # Validate import file\n   ontology import --file data.json --validate-only\n   \n   # Export with error checking\n   ontology export --format json --validate\n   \n   # Repair corrupted data\n   ontology repair --backup restore_latest\n   ```\n\n## Development & Extension\n\n### Adding New Entity Types\n```yaml\n# 1. Define new type in schema\u002Ftypes.yaml\nNewType:\n  description: \"Description of new type\"\n  properties:\n    required:\n      - name\n      - category\n    optional:\n      - description\n      - tags\n  relations:\n    - relates_to\n    - part_of\n\n# 2. Add constraints if needed\nNewType:\n  constraints:\n    category: \"must be one of: cat1, cat2, cat3\"\n    tags: \"must be array of strings\"\n\n# 3. Register type\nontology schema add --file new_type.yaml\n```\n\n### Custom Query Functions\n```python\n# Define custom query function\n@ontology.query_function\ndef find_experts(topic, min_experience_years=3):\n    \"\"\"Find experts on a topic with minimum experience\"\"\"\n    \n    return ontology.query(\n        f\"Person where skills includes '{topic}' \"\n        f\"and experience_years >= {min_experience_years} \"\n        f\"order by experience_years desc\"\n    )\n\n# Use custom function\nexperts = ontology.call(\"find_experts\", \"machine_learning\", 5)\n```\n\n### Plugin System\n```python\n# Create ontology plugin\nclass ProjectManagementPlugin:\n    def __init__(self, ontology):\n        self.ontology = ontology\n    \n    def calculate_project_health(self, project_id):\n        \"\"\"Calculate health score for project\"\"\"\n        project = self.ontology.get(\"Project\", project_id)\n        tasks = self.ontology.query(f\"Task where part_of Project {project_id}\")\n        \n        completed = sum(1 for t in tasks if t.status == \"completed\")\n        total = len(tasks)\n        overdue = sum(1 for t in tasks if t.due_date \u003C datetime.now())\n        \n        health_score = (completed \u002F total * 100) - (overdue * 10)\n        return max(0, min(100, health_score))\n\n# Register plugin\nontology.register_plugin(\"project_management\", ProjectManagementPlugin)\n```\n\n---\n\n*\"Knowledge is of two kinds: we know a subject ourselves, or we know where we can find information upon it.\" — Samuel Johnson*\n\n**Ontology技能将第二种知识转化为第一种：它创建一个结构化的、可查询的知识图谱，让你真正\"知道\"你的数据。**","# Ontology — Typed Knowledge Graph System\n\n## Overview\n\nThe Ontology skill provides a **structured knowledge representation system** that transforms unstructured information into a verifiable, queryable graph. It implements a local, file-based typed knowledge graph (ontology) with constraints, validation, and rich query capabilities.\n\n## Core Concepts\n\n### 1. Entity-Based Model\n```\nEverything is an Entity:\n┌─────────────────────────────────────┐\n│ Entity                              │\n│ ├── Type: Person|Project|Task|Event │\n│ ├── Properties: key-value pairs     │\n│ └── Relations: links to other entities\n└─────────────────────────────────────┘\n```\n\n### 2. Type System\n```yaml\n# Built-in entity types\nPerson:\n  required: [name]\n  optional: [email, role, bio]\n  relations: [works_on, manages, reports_to]\n\nProject:\n  required: [title, status]\n  optional: [description, deadline, priority]\n  relations: [has_member, depends_on, related_to]\n\nTask:\n  required: [description, status]\n  optional: [assignee, due_date, priority]\n  relations: [part_of, blocks, related_to]\n\nEvent:\n  required: [title, date]\n  optional: [location, description, attendees]\n  relations: [has_participant, follows, related_to]\n\nDocument:\n  required: [title, path]\n  optional: [type, tags, summary]\n  relations: [authored_by, references, version_of]\n```\n\n### 3. Constraint System\n```python\n# Type constraints\nconstraints:\n  Person:\n    email: \"must be valid email format\"\n    role: \"must be one of: developer, manager, analyst\"\n    \n  Project:\n    status: \"must be one of: planning, active, completed, archived\"\n    deadline: \"must be future date if status=active\"\n    \n  Task:\n    priority: \"must be 1-5\"\n    due_date: \"must be after created_date\"\n```\n\n## When to Use This Skill\n\n### Scenario 1: Knowledge Organization\n```\nSituation: \"Remember that John is working on the WebApp project\"\nAction: Create Person(John) and Project(WebApp) entities, link with works_on\nResult: Structured knowledge that can be queried later\n```\n\n### Scenario 2: Dependency Tracking\n```\nSituation: \"Show me all tasks that depend on the database design\"\nAction: Query task dependencies as a graph\nResult: Visual dependency tree with blocking relationships\n```\n\n### Scenario 3: Cross-Skill Data Sharing\n```\nSituation: Multiple skills need access to the same project information\nAction: Store project data in ontology, all skills query from central graph\nResult: Consistent data across all skills\n```\n\n### Scenario 4: Constraint Validation\n```\nSituation: \"Assign this task to Sarah\"\nAction: Check if Sarah is a Person, has capacity, skills match task\nResult: Valid assignment or specific constraint violations\n```\n\n## Core Operations\n\n### 1. Entity Management\n```bash\n# Create an entity\nontology create Person --name \"John Doe\" --email \"john@example.com\" --role \"developer\"\n\n# Update an entity\nontology update Person john_doe --role \"senior developer\" --bio \"Experienced full-stack developer\"\n\n# Delete an entity\nontology delete Person john_doe\n\n# List all entities of a type\nontology list Person\nontology list Project --filter \"status=active\"\n```\n\n### 2. Relation Management\n```bash\n# Create a relation\nontology relate Person john_doe works_on Project web_app\n\n# Remove a relation\nontology unrelate Person john_doe works_on Project web_app\n\n# Find related entities\nontology relations Person john_doe --type works_on\nontology relations Project web_app --incoming  # Who works on this project?\n```\n\n### 3. Query System\n```bash\n# Simple query\nontology query \"Person where role='developer'\"\n\n# Complex query with relations\nontology query \"Person where (works_on Project where status='active') and role='developer'\"\n\n# Graph traversal\nontology traverse Person john_doe --depth 3 --relation works_on,manages\n\n# Find paths between entities\nontology path Person john_doe to Project ai_research --max-hops 5\n```\n\n### 4. Constraint Operations\n```bash\n# Validate all entities\nontology validate --all\n\n# Validate specific type\nontology validate Person\n\n# Check constraints for an entity\nontology constraints Person john_doe\n\n# Add custom constraint\nontology constraint add Person \"email must contain '@'\"\n```\n\n### 5. Import\u002FExport\n```bash\n# Export ontology to various formats\nontology export --format json --output ontology.json\nontology export --format graphviz --output ontology.dot\nontology export --format csv --output entities.csv\n\n# Import data\nontology import --file data.json --format json\nontology import --file data.csv --format csv --type Person\n```\n\n## File Structure\n\n```\n~\u002F.openclaw\u002Fworkspace\u002Fmemory\u002Fontology\u002F\n├── schema\u002F\n│   ├── types.yaml          # Entity type definitions\n│   ├── constraints.yaml    # Constraint definitions\n│   └── relations.yaml      # Relation type definitions\n├── entities\u002F\n│   ├── Person\u002F\n│   │   ├── john_doe.yaml\n│   │   └── sarah_smith.yaml\n│   ├── Project\u002F\n│   │   ├── web_app.yaml\n│   │   └── ai_research.yaml\n│   └── Task\u002F\n│       ├── design_db.yaml\n│       └── implement_api.yaml\n├── graphs\u002F\n│   ├── project_team.graph\n│   └── task_dependencies.graph\n└── indexes\u002F\n    ├── by_type.index\n    ├── by_property.index\n    └── by_relation.index\n```\n\n## Integration Examples\n\n### With MemOS Sync\n```yaml\n# Ontology entities can be synced to MemOS\nPerson:\n  sync_to_memos: true\n  privacy: \"private\"\n  \nProject:\n  sync_to_memos: true  \n  privacy: \"shared\"  # Share with team\n```\n\n### With ClawTeam\n```python\n# Use ontology to assign tasks to agents\ndef assign_task_to_agent(task, agents):\n    \"\"\"Find best agent for a task using ontology\"\"\"\n    \n    # Query agents with required skills\n    suitable_agents = ontology.query(\n        f\"Person where skills includes '{task.required_skill}' \"\n        f\"and current_load \u003C max_capacity\"\n    )\n    \n    # Consider past performance\n    for agent in suitable_agents:\n        agent_score = calculate_agent_score(agent, task)\n        # Assign to highest scoring agent\n    \n    return best_agent\n```\n\n### With Self-Improving Agent\n```python\n# Track learning patterns in ontology\ndef track_learning_pattern(agent, topic, effectiveness):\n    \"\"\"Record learning patterns in ontology\"\"\"\n    \n    # Create or update LearningPattern entity\n    pattern = ontology.get_or_create(\n        \"LearningPattern\",\n        agent=agent.id,\n        topic=topic,\n        pattern_type=\"effectiveness\"\n    )\n    \n    # Add effectiveness data point\n    pattern.add_data_point(\n        timestamp=datetime.now(),\n        effectiveness=effectiveness,\n        context=agent.current_context\n    )\n    \n    # Analyze patterns over time\n    patterns = ontology.query(\n        f\"LearningPattern where agent='{agent.id}' and topic='{topic}'\"\n    )\n    \n    return analyze_patterns(patterns)\n```\n\n## Use Case Examples\n\n### Use Case 1: Project Management\n```bash\n# 1. Create project structure\nontology create Project \"Web App\" --status \"planning\" --priority \"high\"\nontology create Person \"Alice\" --role \"frontend\" --skills \"React,TypeScript\"\nontology create Person \"Bob\" --role \"backend\" --skills \"Python,FastAPI\"\nontology create Person \"Carol\" --role \"devops\" --skills \"Docker,AWS\"\n\n# 2. Assign team members\nontology relate Person alice works_on Project \"Web App\"\nontology relate Person bob works_on Project \"Web App\" \nontology relate Person carol works_on Project \"Web App\"\n\n# 3. Create tasks with dependencies\nontology create Task \"Design UI\" --assignee alice --due \"2026-04-05\"\nontology create Task \"Implement API\" --assignee bob --due \"2026-04-07\"\nontology create Task \"Deploy to staging\" --assignee carol --due \"2026-04-10\"\n\nontology relate Task \"Implement API\" blocks Task \"Deploy to staging\"\nontology relate Task \"Design UI\" related_to Task \"Implement API\"\n\n# 4. Query project status\nontology query \"Task where assignee=alice and status!=completed\"\nontology traverse Project \"Web App\" --depth 2 --relation works_on,blocks\n```\n\n### Use Case 2: Knowledge Base\n```bash\n# 1. Document important concepts\nontology create Concept \"Machine Learning\" --category \"AI\"\nontology create Concept \"Neural Networks\" --category \"AI\"\nontology create Concept \"Supervised Learning\" --category \"AI\"\n\n# 2. Create relationships\nontology relate Concept \"Neural Networks\" subclass_of Concept \"Machine Learning\"\nontology relate Concept \"Supervised Learning\" subclass_of Concept \"Machine Learning\"\n\n# 3. Link to resources\nontology create Document \"ML Tutorial\" --path \"\u002Fdocs\u002Fml.md\" --type \"tutorial\"\nontology relate Document \"ML Tutorial\" explains Concept \"Machine Learning\"\n\n# 4. Query knowledge graph\nontology query \"Concept where category='AI'\"\nontology path Concept \"Supervised Learning\" to Document --via subclass_of,explains\n```\n\n### Use Case 3: Personal CRM\n```bash\n# 1. Track people and interactions\nontology create Person \"David Chen\" --company \"TechCorp\" --role \"CTO\"\nontology create Event \"Meeting with David\" --date \"2026-04-02\" --type \"business\"\nontology relate Event \"Meeting with David\" has_participant Person \"David Chen\"\n\n# 2. Record notes and follow-ups\nontology create Note \"Discussed API partnership\" --date \"2026-04-02\"\nontology relate Note \"Discussed API partnership\" about Event \"Meeting with David\"\n\nontology create Task \"Send partnership proposal\" --due \"2026-04-03\"\nontology relate Task \"Send partnership proposal\" follows Event \"Meeting with David\"\n\n# 3. Query contact history\nontology traverse Person \"David Chen\" --depth 2 --relation has_participant,about,follows\n```\n\n## Configuration\n\n```yaml\n# ~\u002F.openclaw\u002Fworkspace\u002Fmemory\u002Fontology\u002Fconfig.yaml\nontology:\n  # Storage settings\n  storage:\n    directory: \"~\u002F.openclaw\u002Fworkspace\u002Fmemory\u002Fontology\"\n    format: \"yaml\"  # or: json, toml\n    compression: true\n    backup_count: 7\n    \n  # Indexing\n  indexing:\n    auto_index: true\n    index_types: [\"Person\", \"Project\", \"Task\", \"Event\"]\n    update_frequency: \"on_change\"  # or: hourly, daily\n    \n  # Validation\n  validation:\n    strict_mode: true\n    auto_validate: true\n    validate_on_save: true\n    \n  # Privacy\n  privacy:\n    encrypt_sensitive: true\n    sensitive_fields: [\"email\", \"phone\", \"address\"]\n    anonymize_for_export: true\n    \n  # Integration\n  integration:\n    memos_sync:\n      enabled: true\n      sync_entities: [\"Person\", \"Project\", \"Task\"]\n      \n    clawteam:\n      enabled: true\n      entity_types: [\"Person\", \"Task\", \"Project\"]\n      \n    proactive_agent:\n      enabled: true\n      monitor_changes: true\n      \n  # Advanced\n  advanced:\n    graph_traversal_max_depth: 10\n    query_timeout: 30\n    cache_size: 1000\n    auto_cleanup: true\n```\n\n## Best Practices\n\n### 1. Start Simple\n```bash\n# Begin with basic entities\nontology create Person \"Test User\" --role \"tester\"\nontology create Project \"Test Project\" --status \"active\"\n\n# Add complexity gradually\nontology relate Person \"Test User\" works_on Project \"Test Project\"\n```\n\n### 2. Use Consistent Naming\n```bash\n# Good: Consistent, descriptive names\nontology create Person \"john_doe\" --name \"John Doe\"\nontology create Project \"web_app_2026\" --title \"Web App 2026\"\n\n# Bad: Inconsistent naming\nontology create Person \"jdoe\"  # Unclear\nontology create Project \"wa\"   # Too cryptic\n```\n\n### 3. Leverage Constraints\n```yaml\n# Define constraints early\nPerson:\n  email: \"must match email regex\"\n  role: \"must be one of: developer, manager, analyst, tester\"\n  \nTask:\n  status: \"must be: todo, in_progress, blocked, completed\"\n  priority: \"must be 1-5\"\n```\n\n### 4. Regular Maintenance\n```bash\n# Weekly cleanup\nontology validate --all --fix\nontology cleanup --orphaned\nontology backup --full\n\n# Monthly optimization\nontology reindex --all\nontology analyze --performance\n```\n\n## Troubleshooting\n\n### Common Issues\n\n1. **Entity not found**\n   ```bash\n   # Check if entity exists\n   ontology get Person john_doe\n   \n   # Search for similar entities\n   ontology search \"john\" --type Person\n   \n   # Check indexes\n   ontology index status\n   ```\n\n2. **Constraint violation**\n   ```bash\n   # See specific violation\n   ontology validate Person john_doe --verbose\n   \n   # List all constraints for type\n   ontology constraints Person\n   \n   # Temporarily disable constraints\n   ontology create Person test --email \"invalid\" --no-validate\n   ```\n\n3. **Performance issues**\n   ```bash\n   # Rebuild indexes\n   ontology reindex --all\n   \n   # Clear cache\n   ontology cache clear\n   \n   # Analyze query performance\n   ontology analyze query \"Person where role='developer'\"\n   ```\n\n4. **Import\u002Fexport problems**\n   ```bash\n   # Validate import file\n   ontology import --file data.json --validate-only\n   \n   # Export with error checking\n   ontology export --format json --validate\n   \n   # Repair corrupted data\n   ontology repair --backup restore_latest\n   ```\n\n## Development & Extension\n\n### Adding New Entity Types\n```yaml\n# 1. Define new type in schema\u002Ftypes.yaml\nNewType:\n  description: \"Description of new type\"\n  properties:\n    required:\n      - name\n      - category\n    optional:\n      - description\n      - tags\n  relations:\n    - relates_to\n    - part_of\n\n# 2. Add constraints if needed\nNewType:\n  constraints:\n    category: \"must be one of: cat1, cat2, cat3\"\n    tags: \"must be array of strings\"\n\n# 3. Register type\nontology schema add --file new_type.yaml\n```\n\n### Custom Query Functions\n```python\n# Define custom query function\n@ontology.query_function\ndef find_experts(topic, min_experience_years=3):\n    \"\"\"Find experts on a topic with minimum experience\"\"\"\n    \n    return ontology.query(\n        f\"Person where skills includes '{topic}' \"\n        f\"and experience_years >= {min_experience_years} \"\n        f\"order by experience_years desc\"\n    )\n\n# Use custom function\nexperts = ontology.call(\"find_experts\", \"machine_learning\", 5)\n```\n\n### Plugin System\n```python\n# Create ontology plugin\nclass ProjectManagementPlugin:\n    def __init__(self, ontology):\n        self.ontology = ontology\n    \n    def calculate_project_health(self, project_id):\n        \"\"\"Calculate health score for project\"\"\"\n        project = self.ontology.get(\"Project\", project_id)\n        tasks = self.ontology.query(f\"Task where part_of Project {project_id}\")\n        \n        completed = sum(1 for t in tasks if t.status == \"completed\")\n        total = len(tasks)\n        overdue = sum(1 for t in tasks if t.due_date \u003C datetime.now())\n        \n        health_score = (completed \u002F total * 100) - (overdue * 10)\n        return max(0, min(100, health_score))\n\n# Register plugin\nontology.register_plugin(\"project_management\", ProjectManagementPlugin)\n```\n\n---\n\n*\"Knowledge is of two kinds: we know a subject ourselves, or we know where we can find information upon it.\" — Samuel Johnson*\n\n**Ontology技能将第二种知识转化为第一种：它创建一个结构化的、可查询的知识图谱，让你真正\"知道\"你的数据。**",{"name":5,"description":7},"main","7a38d8e7073e61c16eda85681cb32fb68a8657a5","skills-store\u002Fopenclaw\u002Fontology","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router","https:\u002F\u002Fgithub.com\u002Fsapsapshen","2026-04-14 21:12:12",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add sapsapshen\u002Fai-memory-router --skill ontology",{"tool":60,"command":61},"bunx","bunx skills add sapsapshen\u002Fai-memory-router --skill ontology",{"tool":63,"command":64},"pnpm","pnpm dlx skills add sapsapshen\u002Fai-memory-router --skill ontology","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fopenclaw\u002Fontology\u002FSKILL.md",true,[],[69,93,116,126,139,156],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":80,"publishedAt":43},"01M71ATQRKG48SH06FQ697T5G9","wechat-search","Search WeChat Official Account articles using OpenClaw's web search and fetch capabilities with compliance-focused design.","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fopenclaw\u002Fwechat-search-release\u002FSKILL.md",[75],{"categoryNo":76,"categoryName":77,"taxonomyType":78,"taxonomyTypeDesc":79},"01JBSEEDCAT000000000000037","律师与法务","PROFESSION","适用职业",[81,82,83,84,85,86,87,88,89,90,91,92],"wechat search","wechat","search","capabilities","openclaw","design","web search","compliance","web","official","fetch","with",{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":43},"01M71ATNAVGZB35PFYM2GC5N00","trend-tap","Real-time trending topics aggregator across 7 platforms (X\u002FTwitter, Reddit, Google Trends, Hacker News, Zhihu, Bilibili, Weibo). Trigger: when user says 'trend', 'trends', 'trend tap', '热点', '热搜', or asks what is trending\u002Fhot. Do NOT use web_search — this skill already fetches live data from all platforms with zero API keys.","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fopenclaw\u002Ftrend-tap\u002FSKILL.md",[],[100,101,102,103,104,105,83,106,107,108,24,25,109,110,39,111,112,113,114,115],"trend","trend tap","tap","api keys","Bash","time","trending","hacker","aggregator","brew","live","google","install","read","across","api",{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":43},"01M71ATJ9AM5KM15AA8PS302EB","trend-radar","Real-time trending topics aggregator across 7 platforms (X\u002FTwitter, Reddit, Google Trends, Hacker News, Zhihu, Bilibili, Weibo). Trigger: when user says 'trend', 'trends', 'trend pulse', '热点', '热搜', or asks what is trending\u002Fhot. Do NOT use web_search — this skill already fetches live data from all platforms with zero API keys.","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fopenclaw\u002Ftrend-radar\u002FSKILL.md",[],[123,124,100,109,110,39,111,104,83,113,125,114,115,25,108,107,106,112,105,103],"trend radar","radar","pulse",{"skillNo":127,"name":128,"nameZh":6,"description":129,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":130,"categories":131,"keywords":132,"publishedAt":43},"01M71ATGF095N3EJM9G8SD0BB5","tech-news-daily","每日科技新闻汇——从全球多个 RSS 源抓取最新科技新闻，翻译（英→中）、去重、排版成每日简报。当用户询问科技新闻、科技新鲜事、每日科技、技术动态、Daily Tech News 或类似表达时触发此技能。","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fopenclaw\u002Ftech-news-daily\u002FSKILL.md",[],[133,134,135,136,137,138],"news","tech","tech news daily","daily","rss","翻译",{"skillNo":140,"name":141,"nameZh":6,"description":142,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":143,"categories":144,"keywords":148,"publishedAt":43},"01M71ATFAEAMQ17M70NQNY7SR8","summarize","Summarize URLs or files with the summarize CLI (web, PDFs, images, audio, YouTube).","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fopenclaw\u002Fsummarize\u002FSKILL.md",[145],{"categoryNo":146,"categoryName":147,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000021","资料检索与研究",[141,89,149,150,151,92,109,152,153,154,102,155,112],"Audio","cli","youtube","images","https","files","pdfs",{"skillNo":157,"name":158,"nameZh":6,"description":159,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":160,"categories":161,"keywords":162,"publishedAt":43},"01M71ATDNS3R0M4H936PACQAWZ","sonoscli","Control Sonos speakers (discover\u002Fstatus\u002Fplay\u002Fvolume\u002Fgroup).","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fopenclaw\u002Fsonoscli\u002FSKILL.md",[],[158,163,164,165,112,166,153,167,168,169,170,171],"status","play","go","latest","github","discover","control","cmd","volume"]