Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Terraphim Knowledge Graph Configuration

This directory contains role-based knowledge graph (KG) configurations for terraphim_grep.

Structure

.terraphim/
├── config.toml              # Role definitions and settings
├── kg/                      # Knowledge graph concept files
│   ├── ai-engineer/         # AI/ML concepts
│   ├── devops/              # DevOps concepts
│   └── rust-engineer/       # Rust concepts
├── thesaurus-*.json         # Auto-generated Aho-Corasick thesauri
└── role-*.json              # Role-specific LLM configurations

Roles

DevOps

  • 6 concepts: Caddy, Docker Compose, GitHub Actions, Monitoring, Secrets
  • 37 synonyms for fast matching

Rust Engineer

  • 9 concepts: Concurrency, Error Handling, Ownership, Performance, Serde, Testing, Tokio, Traits, WebAssembly
  • 92 synonyms for fast matching

AI Engineer

  • 6 concepts: Agent Patterns, Embedding, LLM, Prompt Engineering, Providers, RAG
  • 61 synonyms for fast matching

Thesaurus Generation

Thesaurus JSON files are auto-generated from KG markdown files. Each markdown file contains synonyms:: directives that are extracted and compiled into an Aho-Corasick automaton for fast substring matching.

Manual Regeneration

If you modify KG markdown files, regenerate the thesaurus:

cargo run --bin terraphim-grep -- generate-thesaurus --role rust-engineer

Or manually update the JSON file by extracting synonyms from all markdown files in the role directory.

Format

Thesaurus JSON structure:

{
  "concepts": [
    {
      "name": "Concept Name",
      "synonyms": ["synonym1", "synonym2"],
      "relationships": ["related1", "related2"]
    }
  ]
}

KG Curation (Learning Loop)

When terraphim_grep is run with --kg-path and --answer, the RLM synthesis step extracts new concepts from the LLM response and persists them as markdown files:

terraphim-grep --role rust-engineer --kg-path .terraphim/kg/rust-engineer --answer "how does tokio work"

New concepts are written to kg_path/learned-<slug>.md with synonyms and relationships.

Usage

Search-only (no LLM)

terraphim-grep --role devops --thesaurus .terraphim/thesaurus-devops.json --paths . "pipeline"

Paths are repo-relative — the root of the repository is the default haystack root. Use --paths . to search the entire repository or specify subdirectories relative to the repo root.

With RLM synthesis + KG curation

OPENROUTER_API_KEY=sk-or-... terraphim-grep --role devops \
  --thesaurus .terraphim/thesaurus-devops.json \
  --paths . --answer "pipeline"

Contributing

When adding new concepts:

  1. Create a markdown file in kg/{role}/
  2. Include synonyms using the synonyms:: directive
  3. Regenerate the thesaurus JSON
  4. Test with terraphim-grep --role {role} --answer "your query"

Fleet roles (added 2026-08-08)

Additional Terraphim-AI domain roles (fleet standard §8):

Role shortname KG
Terraphim AI Developer taidev .terraphim/kg-taidev/
Terraphim AI Architect taiarch .terraphim/kg-taiarch/

These coexist with the existing Rust Engineer / kg/<role>/ layout.

python3 .terraphim/scripts/bootstrap.py   # materialize {REPO} + refresh thesauri

Skills manifest: .terraphim/skills.toml (tsm install <name>). Repo agent memory: memory/ at repo root.

Path portability

Fleet roles use repo-relative haystack and KG paths (., crates, memory, …). scripts/bootstrap.py regenerates thesauri and normalizes absolute/{REPO} paths that resolve inside this repo back to relative form. Foreign absolute haystacks are left untouched. The script never writes machine-absolute paths into tracked config.