Skip to content
/ th0th Public

πŸ›οΈ Ancient knowledge keeper for modern code. Semantic search with 98% token reduction for AI assistants. Features: hybrid search, context compression, persistent memory.

License

Notifications You must be signed in to change notification settings

S1LV4/th0th

Repository files navigation

th0th

th0th

Ancient knowledge keeper for modern code

Semantic search with 98% token reduction for AI assistants.


Quick Start

# 1. Clone and install
git clone <repo-url>
cd th0th
bun install

# 2. Setup (100% offline with Ollama)
./scripts/setup-local-first.sh

# 3. Build and start
bun run build
bun run start:api

Verify: curl http://localhost:3333/health


Integration

OpenCode (recommended)

File: ~/.config/opencode/opencode.json

Via MCP package:

{
  "mcpServers": {
    "th0th": {
      "type": "local",
      "command": ["bunx", "@th0th-ai/mcp-client"],
      "env": {
        "TH0TH_API_URL": "http://localhost:3333"
      },
      "enabled": true
    }
  }
}

Via Plugin:

{
  "plugin": ["@th0th/opencode-plugin"]
}

From source (development):

{
  "mcpServers": {
    "th0th": {
      "type": "local",
      "command": ["bun", "run", "/path/to/th0th/apps/mcp-client/src/index.ts"],
      "enabled": true
    }
  }
}

VSCode / Antigravity

Create .vscode/mcp.json in your workspace:

{
  "servers": {
    "th0th": {
      "command": "bunx",
      "args": ["@th0th-ai/mcp-client"],
      "env": {
        "TH0TH_API_URL": "http://localhost:3333"
      }
    }
  }
}

Or run ./scripts/setup-vscode.sh for automatic configuration.

Docker

{
  "mcpServers": {
    "th0th": {
      "type": "local",
      "command": ["docker", "compose", "run", "--rm", "-i", "mcp"],
      "enabled": true
    }
  }
}

Available Tools

Tool Description
th0th_index Index a project directory for semantic search
th0th_search Semantic + keyword search with filters
th0th_remember Store important information in persistent memory
th0th_recall Search stored memories from previous sessions
th0th_compress Compress context (keeps structure, removes details)
th0th_optimized_context Search + compress in one call (max token efficiency)
th0th_analytics Usage patterns, cache performance, metrics

REST API

# Development
bun run dev:api

# Production
bun run start:api

Swagger docs: http://localhost:3333/swagger

Endpoints

# Index a project
curl -X POST http://localhost:3333/api/v1/project/index \
  -H "Content-Type: application/json" \
  -d '{"projectPath": "/home/user/my-project", "projectId": "my-project"}'

# Search
curl -X POST http://localhost:3333/api/v1/search/project \
  -H "Content-Type: application/json" \
  -d '{"query": "authentication", "projectId": "my-project"}'

# Store memory
curl -X POST http://localhost:3333/api/v1/memory/store \
  -H "Content-Type: application/json" \
  -d '{"content": "Important decision...", "type": "decision"}'

# Compress context
curl -X POST http://localhost:3333/api/v1/context/compress \
  -H "Content-Type: application/json" \
  -d '{"content": "...", "strategy": "code_structure"}'

Configuration

Config file: ~/.config/th0th/config.json (auto-created on first run)

Embedding Providers

Provider Model Cost Quality
Ollama (default) nomic-embed-text, bge-m3 Free Good
Mistral mistral-embed, codestral-embed $$ Great
OpenAI text-embedding-3-small $$ Great

Switch Provider

npx th0th-config init                          # Ollama (default)
npx th0th-config init --mistral your-api-key   # Mistral
npx th0th-config init --openai your-api-key    # OpenAI
npx th0th-config show                          # Show current config

Scripts

Command Description
bun run build Build all packages
bun run dev Development (all apps)
bun run dev:api REST API with hot reload
bun run dev:mcp MCP server with watch
bun run start:api Start REST API
bun run start:mcp Start MCP server
bun run test Run tests
bun run lint Lint code
bun run type-check Type checking

Architecture

th0th/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ mcp-client/           # MCP Server (stdio)
β”‚   β”œβ”€β”€ tools-api/            # REST API (port 3333)
β”‚   └── opencode-plugin/      # OpenCode plugin
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ core/                 # Business logic, search, embeddings, compression
β”‚   └── shared/               # Shared types & utilities
└── scripts/
Component Description
Semantic Search Hybrid vector + keyword with RRF ranking
Embeddings Ollama (local) or Mistral/OpenAI API
Compression Rule-based code structure extraction (70-98% reduction)
Memory Persistent SQLite storage across sessions
Cache Multi-level L1/L2 with TTL

License

MIT

About

πŸ›οΈ Ancient knowledge keeper for modern code. Semantic search with 98% token reduction for AI assistants. Features: hybrid search, context compression, persistent memory.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages