Terraphim is a privacy-first AI assistant that works for you under your complete control and is fully deterministic.
Quick Install (works on Linux, macOS, Windows):
cargo install terraphim-repl # Interactive REPL (11 commands)
cargo install terraphim-cli # Automation CLI (8 commands)Features:
- π Semantic knowledge graph search
- π Smart text linking (markdown/html/wiki)
- πΎ Offline-capable (embedded defaults)
- β‘ Lightweight (15 MB RAM, 13 MB disk)
- π Fast (<200ms operations)
Learn more: v1.0.0 Release Notes | Cross-Platform Guide
You can use it as a local search engine, configured to search for different types of content on StackOverflow, GitHub, and the local filesystem using a predefined folder, which includes your Markdown files.
Terraphim operates on local infrastructure and works exclusively for the owner's benefit.
We're excited to announce Terraphim AI v1.0.0 with comprehensive multi-language support:
- π¦ Rust:
terraphim_agent- Complete CLI and TUI interface via crates.io - π¦ Node.js:
@terraphim/autocomplete- Native npm package with autocomplete and knowledge graph - π Python:
terraphim-automata- High-performance text processing library via PyPI
# Rust CLI (recommended)
cargo install terraphim_agent
# Node.js package
npm install @terraphim/autocomplete
# Python library
pip install terraphim-automataTerraphim.intro.demo.854283350.mp4
There are growing concerns about the privacy of data and the sharing of individuals' data across an ever-growing list of services, some of which have questionable data ethics policies. 1,2,3,4
Individuals struggle to find relevant information in different knowledge repositories:
- Personal ones like Roam Research, Obsidian, Coda, and Notion.
- Team-focused ones like Jira, Confluence, and SharePoint.
- Public sources such as StackOverflow and GitHub.
Terraphim aims to bridge this gap by providing a privacy-first AI assistant that operates locally on the user's hardware, enabling seamless access to various knowledge repositories without compromising privacy. With Terraphim, users can efficiently search personal, team-focused, and public knowledge sources, ensuring that their data remains under their control at all times.
cargo install terraphim_agent
terraphim-agent --helpnpm install @terraphim/autocomplete
# or with Bun
bun add @terraphim/autocompletepip install terraphim-automata-
Clone the repository:
git clone https://github.com/terraphim/terraphim-ai.git cd terraphim-ai -
Set up development environment:
# Install Git hooks for code quality (optional but recommended) ./scripts/install-hooks.sh -
Start the backend server:
cargo run
This starts an API endpoint for indexing and querying documents.
-
Run the frontend (choose one):
Web Frontend:
cd desktop yarn install yarn run devDesktop App (Tauri):
cd desktop yarn install yarn run tauri devTerminal Interface (Agent):
# Build with all features (recommended) cargo build -p terraphim_agent --features repl-full --release ./target/release/terraphim-agent # Or run minimal version cargo run -p terraphim_agent --bin terraphim-agent
(See the desktop README, TUI documentation, and development setup guide for more details.)
# Interactive mode with full features
terraphim-agent
# Search commands
terraphim-agent search "Rust async programming"
terraphim-agent search --role engineer "microservices"
# Chat with AI
terraphim-agent chat "Explain knowledge graphs"
# Commands list
terraphim-agent commands list
terraphim-agent commands search "Rust"
# Auto-update management
terraphim-agent check-update # Check for updates without installing
terraphim-agent update # Update to latest version if available// Import the package
import * as autocomplete from '@terraphim/autocomplete';
// Build autocomplete index from JSON thesaurus
const thesaurus = {
"name": "Engineering",
"data": {
"machine learning": {
"id": 1,
"nterm": "machine learning",
"url": "https://example.com/ml"
}
}
};
const indexBytes = autocomplete.buildAutocompleteIndexFromJson(JSON.stringify(thesaurus));
// Search for terms
const results = autocomplete.autocomplete(indexBytes, "machine", 10);
console.log('Autocomplete results:', results);
// Knowledge graph operations
const graphBytes = autocomplete.buildRoleGraphFromJson("Engineer", JSON.stringify(thesaurus));
const isConnected = autocomplete.areTermsConnected(graphBytes, "machine learning");
console.log('Terms connected:', isConnected);import terraphim_automata as ta
# Create thesaurus
thesaurus = ta.Thesaurus(name="Engineering")
thesaurus.add_term("machine learning", url="https://example.com/ml")
thesaurus.add_term("deep learning", url="https://example.com/dl")
# Build autocomplete index
index = ta.build_autocomplete_index(thesaurus)
print(f"Index size: {len(index)} bytes")
# Search for terms
results = ta.autocomplete(index, "machine", limit=10)
for result in results:
print(f"Found: {result.term} (score: {result.score})")
# Fuzzy search
fuzzy_results = ta.fuzzy_autocomplete_search(index, "machin", min_distance=0.8)
print(f"Fuzzy results: {len(fuzzy_results)}")- Grep.app Integration: Search across 500,000+ GitHub repositories
- Advanced Filtering: Language, repository, and path-based filtering
- Semantic Search: Knowledge graph-powered semantic understanding
- Rust: Native performance with complete CLI/TUI interface
- Node.js: High-performance autocomplete with native bindings
- Python: Fast text processing and autocomplete algorithms
- MCP Server: Model Context Protocol for AI tool integration
- Claude Code Hooks: Automated development workflows
- Knowledge Graphs: Semantic relationship analysis and discovery
- Seamless Updates: Self-updating CLI using GitHub Releases
- Cross-Platform: Works on Linux, macOS, and Windows
- Smart Versioning: Intelligent version comparison and update detection
- Progress Tracking: Real-time download progress and status indicators
Terraphim includes a comprehensive terminal agent that provides both interactive REPL functionality and CLI commands for advanced operations:
- π€ AI Chat Integration: OpenRouter and Ollama support for intelligent conversations
- β‘ Sub-2 Second VM Boot: Advanced VM optimization system with sub-500ms allocation
- π₯οΈ Enhanced VM Management: Firecracker microVM pools with intelligent allocation
- π Markdown Command System: Extensible commands defined in YAML frontmatter
- π Security-First Execution: Three execution modes (Local, Firecracker, Hybrid) with knowledge graph validation
- π Web Operations: Secure web requests through VM sandboxing
- π File Operations: Semantic file analysis and intelligent content management
- π Knowledge Graph: Interactive rolegraph visualization and navigation
- βοΈ Configuration: Real-time role and configuration management
- π Auto-Update: Seamless self-updating mechanism using GitHub Releases
Terraphim-agent includes a built-in auto-update system that keeps your installation current with the latest releases from GitHub.
- π Seamless Updates: Automatic binary replacement without manual intervention
- π Progress Tracking: Real-time download progress and status indicators
- π Secure Verification: GitHub Releases integration ensures authenticated updates
- π Cross-Platform: Works on Linux, macOS, and Windows
- π Version Intelligence: Smart version comparison and update availability detection
# Check for updates without installing
terraphim-agent check-update
# Update to latest version if available
terraphim-agent update
# Get help for update commands
terraphim-agent check-update --help
terraphim-agent update --help- π Checking: "π Checking for terraphim-agent updates..."
- β Up-to-date: "β Already running latest version: X.Y.Z"
- π¦ Update Available: "π¦ Update available: X.Y.Z β A.B.C"
- π Updated: "π Updated from X.Y.Z to A.B.C"
- β Failed: "β Update failed: [error details]"
- Source: GitHub Releases from
terraphim/terraphim-airepository - Mechanism: Rust
self_updatecrate with secure binary verification - Architecture: Async-safe implementation using
tokio::task::spawn_blocking - Compatibility: Requires internet connectivity for update checks
$ terraphim-agent check-update
π Checking for terraphim-agent updates...
π¦ Update available: 1.0.0 β 1.0.1
$ terraphim-agent update
π Updating terraphim-agent...
β
Already running latest version: 1.0.1# Build with all features
cargo build -p terraphim_tui --features repl-full --release
# Launch interactive REPL
./target/release/terraphim-agent
# Available REPL commands:
/help # Show all commands
/search "query" # Semantic search
/chat "message" # AI conversation
/commands list # List available markdown commands
/deploy staging # Execute deployment (Firecracker mode)
/search "TODO" # Execute search command (Local mode)
/vm list # VM management with sub-2s boot
/web get URL # Web operations
/file search # Semantic file operationsFor detailed documentation, see TUI Usage Guide and Auto-Update System.
When configuring or working on Terraphim, you will encounter the following terms and concepts:
- Haystack: A data source that Terraphim can search through. For example, this could be a folder on your computer, a Notion workspace, or your email account.
- Knowledge Graph: A structured graph of information created from a haystack, where nodes represent entities and edges represent relationships between them.
- Profile: An endpoint for persisting user data (e.g. Amazon S3, sled, or rocksdb).
- Role: A role is a set of settings that define the default behavior of the AI assistant. For example, a developer role will search for code-related content, while a "father" role might search for parenting-related content. Each Terraphim role has its own separate knowledge graph that contains relevant concepts, with all synonyms.
- Rolegraph: A structure for ingesting documents into Terraphim. It is a knowledge graph that uses a scoring function (an Aho-Corasick automata build from the knowledge graph) for ranking results.
The term is originally taken from the Relict series of science fiction novels by Vasiliy Golovachev. Terraphim is an artificial intelligence living inside a spacesuit (part of an exocortex), or inside your house or vehicle, and it is designed to help you with your tasks. You can carry it around with you. Similar entities now common in science fiction, for example Destiny 2 has entity called Ghost.
Or in Star Wars Jedi Survivor there is an AI assistant BD-1.
The compactness and mobility of such AI assistant drives the [[Design Decisions]] of Terraphim.
Terraphim is a trademark registered in the UK, US and internationally (WIPO). All other trademarks mentioned above are the property of their respective owners.
Terraphim supports multiple storage backends for different deployment scenarios:
The system uses local storage backends by default, requiring no additional configuration:
- Memory: In-memory storage for testing
- DashMap: High-performance concurrent storage
- SQLite: Local database storage
- ReDB: Embedded key-value database
For production deployments, you can optionally enable cloud storage:
To use AWS S3 storage, set the following environment variables:
export AWS_ACCESS_KEY_ID="your-access-key"
export AWS_SECRET_ACCESS_KEY="your-secret-key"
export TERRAPHIM_PROFILE_S3_REGION="us-east-1"
export TERRAPHIM_PROFILE_S3_ENDPOINT="https://s3.amazonaws.com/"Note: AWS credentials are completely optional. The system will automatically fall back to local storage if AWS credentials are not available, ensuring local development works without any cloud dependencies.
TERRAPHIM_SETTINGS_PATH: Override the settings file pathTERRAPHIM_DATA_PATH: Set the data directory locationLOG_LEVEL: Set logging verbosity (debug, info, warn, error)
brew install terraphim/terraphim-ai/terraphim-aiThis installs the server, terminal agent, and desktop app (macOS only).
# Download from GitHub releases
sudo dpkg -i terraphim-server_*.deb
sudo dpkg -i terraphim-agent_*.deb
sudo dpkg -i terraphim-ai-desktop_*.debdocker run ghcr.io/terraphim/terraphim-server:latestDownload pre-built binaries from GitHub Releases.
For development, see our comprehensive Development Setup Guide which covers:
- Code quality tools and pre-commit hooks
- Multiple installation options (no Python required!)
- IDE integration and troubleshooting
Terraphim provides seamless integration with Claude Code through multiple approaches, enabling intelligent text replacement and codebase quality evaluation.
Use Terraphim's knowledge graph capabilities to automatically replace text patterns in your development workflow:
Claude Code Hooks - Automatic, transparent replacements:
# Example: Automatically replace npm with bun
echo "npm install" | terraphim-tui replace
# Output: bun_installClaude Skills - Context-aware, conversational assistance:
- Works across all Claude platforms
- Provides explanations and reasoning
- Progressive disclosure of functionality
Examples:
- Package manager enforcement (npm/yarn/pnpm β bun)
- Attribution replacement (Claude Code β Terraphim AI)
- Custom domain-specific replacements
π Complete Guide: examples/TERRAPHIM_CLAUDE_INTEGRATION.md
Evaluate whether AI agents (Claude Code, GitHub Copilot, autonomous agents) improve or deteriorate your codebase using deterministic, knowledge graph-based assessment:
Key Features:
- Deterministic: Aho-Corasick automata for consistent scoring
- Privacy-First: All evaluation runs locally
- Multi-Dimensional: Security, performance, quality perspectives
- CI/CD Ready: Automated quality gates with exit codes
Quick Start:
cd examples/codebase-evaluation
./scripts/evaluate-ai-agent.sh /path/to/codebase
# Generates verdict:
# β
IMPROVEMENT: The AI agent improved the codebase quality.
# - Improved metrics: 3
# - Deteriorated metrics: 0Evaluation Metrics:
- Clippy warnings, anti-patterns, TODO counts
- Knowledge graph density and semantic matches
- Test pass rates and code coverage
- Custom domain-specific patterns
Use Cases:
- Evaluate PRs from AI agents before merge
- Continuous quality monitoring in CI/CD pipelines
- Historical trend analysis across evaluations
- Multi-role evaluation (security + performance + quality)
π Complete Documentation: examples/codebase-evaluation/
Example GitHub Actions Integration:
- name: Baseline evaluation
run: ./scripts/baseline-evaluation.sh ${{ github.workspace }}
- name: Apply AI changes
run: # Your AI agent step
- name: Post-change evaluation
run: ./scripts/post-evaluation.sh ${{ github.workspace }}
- name: Generate verdict (fails on deterioration)
run: ./scripts/compare-evaluations.shWe welcome contributions! Here's how to get started:
-
Read our guides:
-
Set up your environment:
git clone https://github.com/terraphim/terraphim-ai.git cd terraphim-ai ./scripts/install-hooks.sh # Sets up code quality tools
-
Code quality standards:
- All commits must follow Conventional Commits
- Rust code is automatically formatted with
cargo fmt - JavaScript/TypeScript uses Biome for linting and formatting
- No secrets or large files allowed in commits
-
Make your changes:
- Create a feature branch:
git checkout -b feat/your-feature - Make your changes with proper tests
- Commit with conventional format:
git commit -m "feat: add amazing feature" - Push and create a Pull Request
- Create a feature branch:
Important: Some dependencies are pinned to specific versions to ensure compatibility:
wiremock = "0.6.4"- Version 0.6.5 uses unstable Rust features requiring nightly compilerschemars = "0.8.22"- Version 1.0+ introduces breaking API changesthiserror = "1.0.x"- Version 2.0+ requires code migration for breaking changes
These constraints are enforced in .github/dependabot.yml to prevent automatic updates that would break CI. Future upgrades require manual code migration work.
This project is licensed under the Apache license.