crates.io Homebrew npm PyPI Discord

Rust Knowledge Graph Engine
for Deterministic AI Search

Terraphim AI is a modular 52-crate Rust workspace for privacy-first knowledge graph search. Aho-Corasick automata match thousands of patterns in O(n) time. Sub-millisecond latency. Zero cloud dependency. Your data never leaves your machine.

Install Documentation Source Code 52 Crates Reference
52
Rust Crates
5-10ns
KG Inference
15 MB
RAM Footprint
0
Cloud Dependencies
4
Language Bindings

Quick Install

Multiple installation methods for every workflow

Universal Installer (recommended)

# Single command, platform detection
curl -fsSL https://raw.githubusercontent.com/terraphim/terraphim-ai/main/scripts/install.sh | bash

# With CLI tools
curl -fsSL https://raw.githubusercontent.com/terraphim/terraphim-ai/main/scripts/install.sh | bash --with-cli

Homebrew (macOS / Linux)

# Add Terraphim tap
brew tap terraphim/terraphim

# Install server + agent
brew install terraphim-server
brew install terraphim-agent

Cargo Install

# Interactive agent (REPL + session search)
cargo install terraphim_agent

# With full features
cargo install terraphim_agent --features repl-full

# Automation CLI (JSON output)
cargo install terraphim-cli

Core Capabilities

What makes Terraphim different from traditional search

Local-First Architecture

All indexing, searching, and graph traversal happens entirely on your device. No cloud dependency, no telemetry, no account required. Privacy by architecture, not by policy.

Knowledge Graph Engine

Aho-Corasick finite state automata match thousands of patterns simultaneously in O(n) time. Lexical extraction, graph traversal, pluggable scorers (BM25, TF-IDF, Jaccard), and similarity re-ranking.

MCP Server

Native Model Context Protocol server connects AI assistants like Claude Code to your local knowledge graphs. Paragraph extraction, semantic search, and token tracking without data leaving your machine.

Rust + WASM Performance

Written in Rust, compiles to WebAssembly. KG inference in 5-10 nanoseconds. Pipeline processing in hundreds of milliseconds. 15 MB RAM. No GPU required.

AI Coding Hooks

Two-stage runtime validation for AI-assisted development. Guard stage blocks dangerous operations. Replacement stage enhances text with KG patterns. Failed commands auto-captured for learning.

KG-Boosted File Search

Find files by semantic relationship to domain concepts, not just keywords. Multi-source search across local filesystem, Obsidian vaults, Atomic Server, and code repositories. Role-specific relevance.

Role-Based Knowledge Graphs

Each role has its own knowledge graph with domain-specific concepts and synonyms. Engineers, project managers, and analysts see the same documents ranked differently based on their role.

AI Dark Factory

OTP-inspired agent orchestration for running autonomous AI coding agents. Supervision trees, message passing, reconciliation loops, and fault-tolerant lifecycle management.


Layered Architecture

52 crates organised in a clean dependency graph

6 User Interfaces terraphim_agent, terraphim-cli, terraphim_server, terraphim_tinyclaw
5 Orchestration terraphim_orchestrator, terraphim_kg_orchestration, terraphim_symphony
4 Agent System terraphim_spawner, terraphim_router, terraphim_agent_supervisor
3 Service Layer terraphim_service, terraphim_middleware, haystack_*
2 Core Engine terraphim_automata, terraphim_rolegraph, terraphim_persistence
1 Types and Config terraphim_types, terraphim_config, terraphim_settings

52 Crates

Each crate has a single responsibility and can be used independently

Core Engine (11 crates)

CrateDescription
terraphim_automataAho-Corasick automata for searching and processing knowledge graphs. The core matching engine.
terraphim_rolegraphRole-based knowledge graph module. Maps search roles to domain-specific graph views.
terraphim_typesCore types crate shared across the entire workspace.
terraphim_configConfiguration loading and management for all Terraphim components.
terraphim_settingsSettings handling library for runtime preferences and defaults.
terraphim_serviceService layer handling user requests and responses for the Terraphim core.
terraphim_middlewareMiddleware for searching haystacks (pluggable data source backends).
terraphim-markdown-parserMarkdown parser for extracting structured content from knowledge base files.
terraphim_persistencePersistence layer with Persistable trait and DeviceStorage backends (memory, SQLite, redb).
terraphim_build_argsBuild argument management for compile-time feature configuration.
terraphim_test_utilsShared test utilities and fixtures for all Terraphim crates.

Binaries and CLIs (5 crates)

CrateDescription
terraphim_agentAI Agent CLI with interactive REPL, session search, learning capture, and ASCII graph visualisation.
terraphim-cliCLI tool for semantic knowledge graph search with JSON output for automation and scripting.
terraphim_serverHTTP server handling the core logic. Provides REST API and knowledge graph backend.
terraphim_updateShared auto-update functionality for all Terraphim AI binaries.
terraphim_validationRelease validation system ensuring binary and asset integrity before publishing.

Agent Orchestration: AI Dark Factory (10 crates)

CrateDescription
terraphim_orchestratorAI Dark Factory orchestrator wiring spawner, router, and supervisor into a reconciliation loop.
terraphim_spawnerAgent spawner with health checking, output capture, and lifecycle management.
terraphim_routerUnified routing engine for LLM and agent providers (keyword routing, tier selection).
terraphim_agent_supervisorOTP-inspired supervision trees for fault-tolerant AI agent management.
terraphim_agent_applicationOTP-style application behaviour for the Terraphim agent system.
terraphim_agent_messagingErlang-style asynchronous message passing system for AI agents.
terraphim_agent_registryKnowledge graph-based agent registry for intelligent agent discovery and capability matching.
terraphim_agent_evolutionAgent evolution and self-improvement tracking.
terraphim_workspaceWorkspace management for agent execution including lifecycle, hooks, and isolation.
terraphim_multi_agentMulti-agent system built on roles with rust-genai integration.

Knowledge Graph Intelligence (8 crates)

CrateDescription
terraphim_kg_orchestrationKnowledge graph-based agent orchestration engine for coordinating multi-agent workflows.
terraphim_kg_agentsSpecialised knowledge graph-based agent implementations.
terraphim_kg_linterLinter for markdown-based Terraphim KG schemas (commands, types, permissions).
terraphim_goal_alignmentKnowledge graph-based goal alignment system for multi-level goal management and conflict resolution.
terraphim_task_decompositionKnowledge graph-based task decomposition for intelligent task analysis and execution planning.
terraphim_rlmRecursive Language Model (RLM) orchestration for structured reasoning chains.
terraphim_hooksUnified hooks infrastructure for knowledge graph-based text replacement and validation.
terraphim_file_searchKnowledge-graph scored file search integration.

Haystack Integrations (5 crates)

CrateDescription
haystack_coreCore traits and types for all Terraphim haystack integrations.
haystack_atlassianAtlassian (Confluence, Jira) integration for searching enterprise knowledge bases.
haystack_discourseDiscourse forum integration for fetching posts and messages.
haystack_grepappGrep.app integration for searching code across GitHub repositories.
haystack_jmapJMAP email protocol integration for searching email (Fastmail, etc.).

Session and Usage Analytics (4 crates)

CrateDescription
terraphim_sessionsSession management for AI coding assistant history. Search across Claude Code, Cursor, and Aider sessions.
terraphim-session-analyzerAnalyse AI coding assistant session logs to identify agent usage patterns.
terraphim_ccusageClaude Code usage tracking and cost analysis.
terraphim_usageGeneral usage telemetry and analytics.

DevOps and Infrastructure (7 crates)

CrateDescription
terraphim_symphonySymphony orchestration service. Reads issues from trackers and dispatches coding agent sessions.
terraphim_trackerIssue tracker abstraction for Gitea and Linear with PageRank-based prioritisation.
terraphim_github_runnerGitHub Actions runner with Firecracker sandbox integration.
terraphim_github_runner_serverHTTP server for the GitHub Actions runner service.
terraphim-firecrackerSub-2-second VM boot optimisation system for sandboxed agent execution.
terraphim_mcp_serverModel Context Protocol (MCP) server exposing Terraphim tools to AI assistants.
terraphim_onepassword_cli1Password CLI integration for secret management.

Chat and Assistants (1 crate)

CrateDescription
terraphim_tinyclawMulti-channel AI assistant for Telegram, Discord, and CLI.

Language Bindings (4 crates) + Browser Extension

CrateDescription
terraphim_automata_pyPython (PyO3) bindings for terraphim_automata. Fast autocomplete and text processing.
terraphim_rolegraph_pyPython bindings for terraphim_rolegraph. Knowledge graph operations for AI agents.
terraphim-automata-node-rsNode.js (NAPI) bindings for Terraphim's Aho-Corasick matcher.
terraphim-automata-wasmWebAssembly bindings for terraphim_automata. Runs in the browser.

Multi-Language Support

Use Terraphim from Rust, Python, Node.js, or the browser

Rust (native)

Full access to all 52 crates. Interactive REPL, CLI automation, HTTP server, and agent orchestration.

cargo install terraphim_agent

Python (PyO3)

High-performance text processing and autocomplete. Native bindings via PyO3.

pip install terraphim-automata

Node.js (NAPI)

Autocomplete and knowledge graph operations with native NAPI bindings.

npm install @terraphim/autocomplete

WebAssembly

Same Rust codebase compiled to WASM. Runs in any modern browser with no installation.

# Browser extension available
# terraphim-automata-wasm on npm

Performance Comparison

From ML pipeline to nanosecond inference

MetricTraditional MLThe PatternTerraphim AI
Data processing6 days6 hoursHundreds of ms
Inference latencySeconds< 2 ms5-10 ns
RAM footprintGigabytesHundreds of MB15-20 MB
GPU requiredYesNoNo

Resources

Documentation

docs.terraphim.ai -- Full technical documentation (mdBook)
Crate Reference -- All 52 crates with descriptions
Installation Guide -- Platform-specific instructions
Quickstart -- Get running in 5 minutes

Community

Discord -- Chat with the team
Discourse -- Long-form discussion
GitHub Issues -- Bug reports and features
Source Code -- MIT + Apache 2.0