# OntoCode
[](https://github.com/eddiethedean/ontocode/actions/workflows/ci.yml)
[](https://github.com/eddiethedean/ontocode/blob/main/LICENSE-MIT)
[](https://github.com/eddiethedean/ontocode/blob/main/Cargo.toml)
[](https://www.rust-lang.org)
[](https://crates.io/search?q=ontoindex)
[](https://crates.io/crates/ontoindex-core)
[](https://crates.io/crates/ontoindex-parser)
[](https://crates.io/crates/ontoindex-catalog)
[](https://crates.io/crates/ontoindex-query)
[](https://crates.io/crates/ontoindex-cli)
[](https://crates.io/crates/ontoindex-lsp)
[](https://crates.io/crates/ontoindex-cli)
**Ontology-as-code for Git and VS Code — v0.2.1 ships today.**
Browse OWL/RDF in VS Code, query and validate in CI, and index workspaces locally with a Rust engine. Editing, diagnostics, reasoning, and semantic diffs are on the [roadmap](#roadmap).
> **Naming:** **OntoCode** is the VS Code extension (product UI). **OntoIndex** is the Rust engine (`ontoindex` CLI, `ontoindex-*` crates, `ontoindex-lsp`). This repo contains both.
## Choose your path
### Use the CLI (OntoIndex)
```bash
cargo install ontoindex-cli
ontoindex query ./fixtures "SELECT * FROM classes"
ontoindex validate .
```
From a clone, `cargo run --` runs the `ontoindex` binary (workspace default-member is `ontoindex-cli`).
### Use VS Code (OntoCode Explorer)
1. Install [OntoCode from the Marketplace](https://marketplace.visualstudio.com/items?itemName=ontocode.ontocode), or download a VSIX from [GitHub Releases](https://github.com/eddiethedean/ontocode/releases).
2. Open a folder with `.ttl`, `.owl`, `.rdf`, or other supported ontology files.
3. Use the **OntoCode** activity bar to browse entities and open the inspector.
Full install and troubleshooting: [docs/vscode-install.md](docs/vscode-install.md).

## Two-layer architecture
OntoCode is designed as two products that ship together:
| **OntoCode** | VS Code extension (explorer, entity inspector, jump-to-source) | **Explorer shipping** — install VSIX or run from `extension/` |
| **OntoIndex** | Rust library + CLI + LSP (scan, parse, catalog, query, validate) | **Shipping now** |
```text
┌─────────────────────────────────────┐
│ OntoCode (v0.2) │
│ VS Code extension + explorer UI │
└─────────────────┬───────────────────┘
│ ontoindex-lsp (stdio)
┌─────────────────▼───────────────────┐
│ OntoIndex (v0.2.1) │
│ Rust index, catalog, query, CLI, LSP │
└─────────────────┬───────────────────┘
│ Oxigraph / RDF parsers
┌─────────────────▼───────────────────┐
│ Your ontology repo │
│ .ttl .owl .rdf .jsonld … │
└─────────────────────────────────────┘
```
OntoIndex is useful on its own today (CLI, CI, local analysis). The extension will call into the same engine via a language server rather than reimplementing ontology logic in TypeScript.
## Why OntoCode?
Protégé is strong for traditional ontology editing, but most engineering teams live in Git, pull requests, and VS Code. OntoCode targets that workflow:
| Browse ontologies in VS Code | Hybrid authoring: forms + Manchester editor |
| Entity inspector and jump-to-source | OWL axiom editing and patch write-back |
| `ontoindex validate` for CI | Query workbench, Rust-native reasoners + explanations |
| SQL-like and SPARQL queries via CLI | OBO format + ROBOT interop |
| Local-first indexing | Semantic Git diff, LSP completion/rename |
Long-term goal: **Protégé-competitive OWL 2 DL + OBO maintenance in VS Code** — see [PROTEGE_PARITY.md](docs/design/PROTEGE_PARITY.md).
## What's in v0.2.1 (OntoCode Explorer)
v0.2 adds the VS Code extension described in the [v0.2 roadmap](https://github.com/eddiethedean/ontocode/blob/main/docs/design/ROADMAP.md):
- **VS Code extension** — OntoCode activity bar with ontology tree views
- **Entity inspector** — IRI, labels, comments, parents, children, axioms
- **Jump to source** — open Turtle/RDF files at entity declarations
- **`ontoindex-lsp`** — language server with custom catalog methods
- **LSP browsing** — hover, document/workspace symbols, go-to-definition
Exit criterion (works today):
1. Open a repo with `.ttl` files in VS Code with the extension loaded
2. Browse ontologies, classes, properties, and individuals in the sidebar
3. Click an entity to inspect it and jump to its source
### Install the extension
See [docs/vscode-install.md](docs/vscode-install.md) (release VSIX, dev build, LSP troubleshooting) and [extension/README.md](extension/README.md).
## What's in v0.1.0 (OntoIndex foundation)
This release delivers the Rust backend described in the [v0.1 roadmap](https://github.com/eddiethedean/ontocode/blob/main/docs/design/ROADMAP.md):
- **Workspace scanner** — recursive discovery, `.gitignore` support, content hashing
- **RDF/OWL parsing** — Turtle, RDF/XML, OWL, JSON-LD, N-Triples, N-Quads, TriG via [Oxigraph](https://github.com/oxigraph/oxigraph)
- **Semantic catalog** — ontologies, classes, properties, individuals, annotations, axioms, namespaces, imports
- **SQL-like queries** — `SELECT`, `FROM`, `WHERE`, projections, CSV/JSON export
- **SPARQL** — query indexed triples directly
- **CLI** — `ontoindex index`, `query`, `sparql`, `validate`, `inspect`
Exit criterion (works today):
```bash
cargo run -- query ./fixtures "SELECT * FROM classes"
```
## Quick start
```bash
# Build
cargo build --release
# Index and inspect a workspace
cargo run -- inspect fixtures
# Query classes
cargo run -- query fixtures "SELECT * FROM classes"
# Filter results
cargo run -- query fixtures "SELECT short_name, labels FROM classes WHERE short_name = 'Person'"
# SPARQL
cargo run -- sparql fixtures "SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 5"
# Validate (non-zero exit on parse errors — CI-friendly)
cargo run -- validate fixtures
# JSON output
cargo run -- query fixtures "SELECT * FROM classes" --format json
```
Install the CLI from crates.io (binary name: `ontoindex`):
```bash
cargo install ontoindex-cli
ontoindex query ./fixtures "SELECT * FROM classes"
```
Or build from source after cloning this repository.
## Planned VS Code experience (v0.3+)
Specs and wireframes live in [docs/design/](https://github.com/eddiethedean/ontocode/tree/main/docs/design). Upcoming OntoCode UI includes:
- Inline diagnostics and validation (v0.3)
- Class/property/individual authoring (v0.4)
- SPARQL and SQL query panels (v0.5+)
- Reasoner integration and graph visualization
- Semantic Git diff viewer
The extension is a thin TypeScript shell over **ontoindex-lsp** and the OntoIndex crates — not a second ontology stack.
## Roadmap
| v0.1 | OntoIndex: scanner, parser, catalog, CLI |
| **v0.2.1** (current) | VS Code extension, explorer, entity inspector, LSP |
| v0.3 | Diagnostics and Problems panel integration |
| v0.4a–b | Simple write-back + Horned-OWL (`ontoindex-owl`) |
| v0.5 | Query workbench + Manchester MVP |
| v0.6 | Reasoners + real unsatisfiability explanations |
| v0.7–v0.7b | Graphs + OBO/ROBOT interop |
| v0.8–v0.9 | Full Manchester, refactoring, semantic diff |
| v1.0 | **Protégé-competitive OWL + OBO in VS Code** ([parity checklist](docs/design/PROTEGE_PARITY.md)) |
See [ROADMAP.md](https://github.com/eddiethedean/ontocode/blob/main/docs/design/ROADMAP.md), [PLAN.md](https://github.com/eddiethedean/ontocode/blob/main/docs/design/PLAN.md), and [PROTEGE_PARITY.md](docs/design/PROTEGE_PARITY.md) for the full product plan.
## Repository layout
```text
crates/
├── ontoindex-core # types, workspace scanner
├── ontoindex-parser # RDF parsing and entity extraction
├── ontoindex-catalog # index builder and semantic catalog
├── ontoindex-query # SQL-like and SPARQL engines
├── ontoindex-cli # `ontoindex` binary
└── ontoindex-lsp # language server for OntoCode
extension/ # VS Code extension (OntoCode Explorer)
fixtures/ # sample ontology for tests
scripts/ # extension packaging helpers
docs/ # user guides (install, SQL, LSP API)
docs/design/ # product specs, ADRs, wireframes, backlog
examples/ # Rust examples and query cookbook
tests/ # integration and golden snapshot tests
```
## Virtual tables
| `ontologies` | Indexed ontology documents |
| `classes` | OWL/RDFS classes |
| `object_properties` | OWL object properties |
| `data_properties` | OWL datatype properties |
| `annotation_properties` | OWL annotation properties |
| `individuals` | OWL named individuals |
| `entities` | All extracted entities |
| `annotations` | Label/comment and other annotation triples |
| `axioms` | Extracted axioms (e.g. SubClassOf) |
| `namespaces` | Namespace prefixes |
| `imports` | Ontology imports |
| `properties` | Union of all property kinds |
Column schemas, SQL limits, and examples: [docs/sql-reference.md](docs/sql-reference.md). LSP methods: [docs/lsp-api.md](docs/lsp-api.md).
## Development
See [CONTRIBUTING.md](CONTRIBUTING.md). Quick checks:
```bash
cargo build -p ontoindex-lsp --bins
cargo test --workspace
cd extension && npm ci && npm test
cargo fmt --all
cargo clippy --all-targets -- -D warnings
```
Update golden snapshots:
```bash
ONTOINDEX_UPDATE_GOLDEN=1 cargo test golden_classes
```
## Releasing
Published crates (v0.2.1):
| `ontoindex-core` | https://crates.io/crates/ontoindex-core |
| `ontoindex-parser` | https://crates.io/crates/ontoindex-parser |
| `ontoindex-catalog` | https://crates.io/crates/ontoindex-catalog |
| `ontoindex-query` | https://crates.io/crates/ontoindex-query |
| `ontoindex-lsp` | https://crates.io/crates/ontoindex-lsp |
| `ontoindex-cli` | https://crates.io/crates/ontoindex-cli |
Push a tag matching `[workspace.package].version` in `Cargo.toml` (e.g. `v0.2.1`):
```bash
git tag v0.2.1
git push origin v0.2.1
```
The [release workflow](https://github.com/eddiethedean/ontocode/blob/main/.github/workflows/release.yml) verifies packages, runs tests, publishes workspace crates to [crates.io](https://crates.io/) in dependency order, and creates a GitHub Release with the `ontoindex` Linux binary, per-platform `ontoindex-lsp` archives, and a **multi-platform VSIX** (Linux, macOS, Windows). Requires the `CARGO_REGISTRY_TOKEN` repository secret.
See [CHANGELOG.md](https://github.com/eddiethedean/ontocode/blob/main/CHANGELOG.md) for release notes. Verify downloads: [docs/release-integrity.md](docs/release-integrity.md). Security: [SECURITY.md](SECURITY.md).
## License
MIT OR Apache-2.0