Metadata-Version: 2.4
Name: ontocore
Version: 1.1.0
Summary: OntoCore — Neuro-symbolic skill compiler. Compiles SKILL.md into validated OWL 2 ontologies.
License: MIT License
        
        Copyright (c) 2026 Marcello Russo
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.1.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: rdflib>=7.0.0
Requires-Dist: anthropic>=0.39.0
Requires-Dist: rich>=13.0.0
Requires-Dist: owlrl>=1.0.0
Requires-Dist: pyshacl>=0.25.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: markdown-it-py>=3.0.0
Requires-Dist: mdit-py-plugins>=0.4.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: pytest-timeout>=2.2.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Provides-Extra: embeddings
Requires-Dist: sentence-transformers>=2.2.0; extra == "embeddings"
Requires-Dist: optimum>=1.12.0; extra == "embeddings"
Requires-Dist: onnx>=1.15.0; extra == "embeddings"
Requires-Dist: onnxruntime>=1.16.0; extra == "embeddings"
Dynamic: license-file

<h1 align="center">
  OntoCore
</h1>

<p align="center">
  <strong>Deterministic AI Skills via OWL 2 Ontologies</strong>
</p>

<p align="center">
  <b>🇬🇧 English</b> • <a href="README_zh.md">🇨🇳 中文</a>
</p>

<p align="center">
  <em>The neuro-symbolic compiler for the <a href="https://ontoskills.sh">OntoSkills</a> platform.</em>
</p>

<p align="center">
  Compile natural language skills into verified, queryable knowledge graphs —<br>
  an alternative to probabilistic agent skills with a lightning-fast Rust MCP.
</p>

<p align="center">
  <a href="https://pypi.org/project/ontocore/"><img src="https://img.shields.io/pypi/v/ontocore.svg?color=blue&style=for-the-badge" alt="PyPI version"></a>
  <img src="https://img.shields.io/pypi/pyversions/ontocore.svg?style=for-the-badge" alt="Python versions">
  <img src="https://img.shields.io/badge/OWL%202-RDF%2FTurtle-green?style=for-the-badge&logo=w3c" alt="OWL 2">
  <a href="https://github.com/mareasw/ontoskills/blob/main/LICENSE"><img src="https://img.shields.io/pypi/l/ontocore.svg?style=for-the-badge" alt="License"></a>
</p>

---

## What is OntoCore?

OntoCore is the Python compiler at the heart of the **OntoSkills** platform. It acts as a **neuro-symbolic compiler** that transforms unstructured, human-readable AI skills (`SKILL.md`) into strictly validated, queryable **OWL 2 ontologies**.

By combining the natural language understanding of LLMs with the deterministic formal logic of RDF and SHACL validation, OntoCore ensures that AI agents operate on exact, verifiable knowledge graphs rather than probabilistic prompts.

### Key Capabilities

- **LLM Knowledge Extraction**: Extracts structured triples (Dependencies, Inputs, Intents, Operations) from markdown files.
- **SHACL Validation**: Ensures the extracted semantic graph strictly adheres to the OntoSkills Core Ontology.
- **Structural Content Preservation**: Extracts code examples, tables, flowcharts, templates, and ordered procedures from markdown — losslessly, via deterministic parsing.
- **OWL 2 Compilation**: Outputs self-contained `.ttl` (Turtle) graphs ready for deterministic SPARQL querying.
- **Local Registry Management**: Handles the installation, enabling, and indexing of distributed skills packages.
- **Security Auditing**: Analyzes the graph for conflicting intents, missing dependencies, or shadowed skills.

---

## Installation

Install the compiler directly from PyPI (requires Python 3.10+):

```bash
pip install ontocore
```

---

## Quick Start

### 1. Initialize the Environment

Create the necessary folder structure (`.ontoskills/`) in your project:

```bash
ontocore init-core
```

### 2. Configure the LLM

OntoCore needs an LLM to extract relationships. Create a `.env` file or export the keys:

```bash
export OPENAI_API_KEY="sk-..."
```
*(Anthropic is also supported via `ANTHROPIC_API_KEY`)*

### 3. Compile Skills

Assuming you have `SKILL.md` files in a `skills/` directory, run the compiler:

```bash
ontocore compile
```
This will read the markdown files, extract knowledge, validate it via SHACL, and generate `.ttl` ontology files in the `.ontoskills/` output directory.

### 4. Query the Knowledge Graph

You can perform exact graph queries using SPARQL directly from the CLI:

```bash
ontocore query "SELECT ?skill WHERE { ?skill oc:resolvesIntent 'create_pdf' }"
```

---

## CLI Reference

The package provides the `ontocore` command-line tool. Here are the main commands:

### Core Commands
- `ontocore compile`: Compile local skills to validated OWL 2 ontologies.
- `ontocore query <sparql_query>`: Execute a SPARQL query against the compiled domain graph.
- `ontocore security-audit`: Run security checks against the knowledge graph to find issues.
- `ontocore init-core`: Initialize an empty OntoSkills registry in the current directory.
- `ontocore list-skills`: List all successfully compiled skills in the domain graph.

### Registry & Packages
- `ontocore install-package <path>`: Install a `.tar.gz` skill package.
- `ontocore import-source-repo <url>`: Import skills directly from a remote Git repository.
- `ontocore install`: Download and install all dependencies declared in the lockfile.
- `ontocore enable <skill_id>`: Enable an installed skill.
- `ontocore disable <skill_id>`: Disable an installed skill.
- `ontocore list-installed`: Show all installed packages and their status.
- `ontocore rebuild-index`: Rebuild the registry index manually.

Run `ontocore --help` or `ontocore <command> --help` for detailed usage.

---

## Documentation & Source

- **[OntoCore docs](https://ontoskills.sh/docs/ontocore/)** — Architecture, compilation pipeline, and SHACL validation
- **[Getting Started](https://ontoskills.sh/docs/getting-started/)** — Full installation and first steps
- **[mareasw/ontoskills](https://github.com/mareasw/ontoskills)** — Source code and contributions

---

*© 2026 [Marea Software](https://marea.software)*
