[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71ASVN2A9K7DFAVF760SK9K":3,"skill-same:01M71ASVN2A9K7DFAVF760SK9K":63},{"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":18,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":14,"repositoryHtmlUrl":46,"repositoryHomepageUrl":6,"ownerHtmlUrl":47,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":48,"install":49,"resources":62},"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",[],[5,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"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":50,"prompt":60,"zipAvailable":61},[51,54,57],{"tool":52,"command":53},"npx","npx skills add sapsapshen\u002Fai-memory-router --skill ontology",{"tool":55,"command":56},"bunx","bunx skills add sapsapshen\u002Fai-memory-router --skill ontology",{"tool":58,"command":59},"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,[],[64,74,81,89,95,103],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":68,"licenseFileUrl":69,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":73},"01M72R8PZX1ABFHJGTYPA4CAF1","webapp-testing","To test local web applications, write native Python Playwright scripts.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fglobal\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fglobal\u002Fwebapp-testing\u002FSKILL.md",[],[],"2026-11-10 22:39:42",{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":73},"01M72QG37MMZNDY7X7GXPAK5W6","python-packaging","Comprehensive guide to creating, structuring, and distributing Python packages using modern packaging tools, pyproject.toml, and publishing to PyPI.","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fglobal\u002Fpython-packaging\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":68,"licenseFileUrl":85,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":73},"01M72NXR0QMP9G46TW6A2DH59C","canvas-design","These are instructions for creating design philosophies - aesthetic movements that are then EXPRESSED VISUALLY. Output only .md files, .pdf files, and .png files.","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fglobal\u002Fcanvas-design\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fglobal\u002Fcanvas-design\u002FSKILL.md",[],[],{"skillNo":90,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":68,"licenseFileUrl":91,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":73},"01M72N55TK3EEQ4QK4AWDC2KZS","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fcursor\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fcursor\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":68,"licenseFileUrl":99,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":73},"01M72MTWC150CFAP4Y5GSNKF80","slack-gif-creator","A toolkit providing utilities and knowledge for creating animated GIFs optimized for Slack.","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fcursor\u002Fslack-gif-creator\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fcursor\u002Fslack-gif-creator\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":68,"licenseFileUrl":107,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":73},"01M72KPT3VVNSP88MNAY466TZT","frontend-design","You are a frontend designer-engineer, not a layout generator.","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fcursor\u002Ffrontend-design\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fcursor\u002Ffrontend-design\u002FSKILL.md",[],[]]