An open API service indexing awesome lists of open source software.

https://github.com/profrandom92/comptext-revolution

πŸš€ CompText Revolution β€” token-efficient DSL kernel for LLM agents. DSL compiler + MCP server + SQLite FTS5 index + session memory + sandbox runner in one unified system.
https://github.com/profrandom92/comptext-revolution

Last synced: 26 days ago
JSON representation

πŸš€ CompText Revolution β€” token-efficient DSL kernel for LLM agents. DSL compiler + MCP server + SQLite FTS5 index + session memory + sandbox runner in one unified system.

Awesome Lists containing this project

README

          

```
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•šβ•β•β–ˆβ–ˆβ•”β•β•β•
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β•šβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β• β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘
β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘
β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β•β•šβ•β• β•šβ•β• β•šβ•β•β•β•β•β•β•β•šβ•β• β•šβ•β• β•šβ•β•

β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•— β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β• β•šβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘
β•šβ•β• β•šβ•β•β•šβ•β•β•β•β•β•β• β•šβ•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β•β•β•
```

### The Universal Token Compression Platform for LLMs
*Compress smarter. Remember more. Spend less.*


[![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178C6?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
[![Python](https://img.shields.io/badge/Python-3.10+-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org/)
[![FastAPI](https://img.shields.io/badge/FastAPI-0.100+-009688?style=for-the-badge&logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com/)
[![Kubernetes](https://img.shields.io/badge/Kubernetes-Ready-326CE5?style=for-the-badge&logo=kubernetes&logoColor=white)](./k8s/)
[![MCP](https://img.shields.io/badge/MCP-15%20Tools-FF6B35?style=for-the-badge)](https://modelcontextprotocol.io/)
[![Tests](https://img.shields.io/badge/Tests-84%20Passing-22C55E?style=for-the-badge)](https://vitest.dev/)
[![License: MIT](https://img.shields.io/badge/License-MIT-F59E0B?style=for-the-badge)](LICENSE)


```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ "Please provide comprehensive documentation for all function parameters" β”‚
β”‚ ↓ CompText L5 β”‚
β”‚ "prvd docs fn params" β†’ 58% fewer tokens β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## Table of Contents

- [Why CompText?](#-why-comptext)
- [Architecture](#-architecture)
- [KVTC Compression Engine](#-kvtc-compression-engine)
- [MCP Tools](#-mcp-tools-15-total)
- [Memory Palace](#-memory-palace)
- [Quick Start](#-quick-start)
- [Monorepo Structure](#-monorepo-structure)
- [Python REST API](#-python-rest-api)
- [Test Suite](#-test-suite)
- [Kubernetes Deployment](#-kubernetes-deployment)
- [Performance](#-performance)

---

## ⚑ Why CompText?

Every token costs money. Every token wastes latency. CompText solves both.

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ TOKEN COST REALITY β”‚
β”‚ β”‚
β”‚ Raw prompt: β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 1,200 tokens $0.018β”‚
β”‚ CompText L2: β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 750 tokens $0.011β”‚
β”‚ CompText L5: β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 430 tokens $0.006β”‚
β”‚ β”‚
β”‚ At 10,000 daily requests β†’ save $120/day β†’ $43,800/year β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

**CompText Revolution** is a production-grade, dual-stack platform (TypeScript + Python) that:

- **Compresses** any text through 5 progressive levels (whitespace β†’ skeleton)
- **Remembers** context in a hierarchical `[[Palace:Wing:Room]]` memory system
- **Indexes** documents into SQLite FTS5 with BM25 semantic ranking
- **Exposes** 15 MCP tools to Claude Desktop with Python-first routing + TypeScript fallback
- **Scales** to Kubernetes with Canary rollout, Prometheus metrics, and GitOps

---

## πŸ— Architecture

```
╔═══════════════════════════════════════════════════════════════════════════╗
β•‘ COMPTEXT REVOLUTION β•‘
β•‘ β•‘
β•‘ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β•‘
β•‘ β”‚ Claude Desktop β”‚ ◄──────── MCP Protocol (stdio JSON-RPC) β•‘
β•‘ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β•‘
β•‘ β”‚ β•‘
β•‘ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β•‘
β•‘ β”‚ MCP SERVER (TypeScript) β”‚ β•‘
β•‘ β”‚ β”‚ β•‘
β•‘ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β•‘
β•‘ β”‚ β”‚ Tool Handler │───►│ Python Bridge β”‚ ──► HTTP :8000 β”‚ β•‘
β•‘ β”‚ β”‚ (15 tools) β”‚ β”‚ (HTTP client) β”‚ β”‚ β•‘
β•‘ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β•‘
β•‘ β”‚ β”‚ β”‚ β•‘
β•‘ β”‚ └──► TypeScript Fallback Engine (offline mode) β”‚ β•‘
β•‘ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β•‘
β•‘ β”‚ HTTP/REST β•‘
β•‘ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β•‘
β•‘ β”‚ PYTHON BACKEND (FastAPI) β”‚ β•‘
β•‘ β”‚ β”‚ β•‘
β•‘ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β•‘
β•‘ β”‚ β”‚ KVTC β”‚ β”‚ MemPalace β”‚ β”‚ CAS β”‚ β”‚ Database β”‚ β”‚ β•‘
β•‘ β”‚ β”‚ 5 levels β”‚ β”‚ [[P:W:R]] β”‚ β”‚ SHA-256 β”‚ β”‚ SQLite FTS5 β”‚ β”‚ β•‘
β•‘ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β•‘
β•‘ β”‚ β”‚ β•‘
β•‘ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β•‘
β•‘ β”‚ β”‚ Prometheus Metrics Β· SafetyGate β”‚ β”‚ β•‘
β•‘ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β•‘
β•‘ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β•‘
β•‘ β•‘
β•‘ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β•‘
β•‘ β”‚ @comptext/core (TypeScript Β· tsup) β”‚ β•‘
β•‘ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β•‘
β•‘ β”‚ β”‚ Compiler β”‚ β”‚ LLM Tokenizer β”‚ β”‚ Hybrid DSL Router β”‚ β”‚ β•‘
β•‘ β”‚ β”‚ Levels 1-5 β”‚ β”‚ js-tiktoken β”‚ β”‚ text/query/config/ β”‚ β”‚ β•‘
β•‘ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β•‘
β•‘ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
```

---

## 🧠 KVTC Compression Engine

**Knowledge Vector Token Compression** β€” 5 progressive levels, each building on the last.

```
INPUT: "This is basically a comprehensive documentation system for the configuration parameters."
β”‚
β”œβ”€ Level 1 Whitespace Normalization
β”‚ "This is basically a comprehensive documentation system for the configuration parameters."
β”‚ Trims, collapses spaces, normalizes newlines
β”‚
β”œβ”€ Level 2 Filler Word Removal
β”‚ "comprehensive documentation system configuration parameters."
β”‚ Removes: basically, actually, really, just, very, quite…
β”‚
β”œβ”€ Level 3 Article & Stop Word Removal
β”‚ "comprehensive documentation system configuration parameters."
β”‚ Removes: a, an, the, and, for, of, in, to, with…
β”‚
β”œβ”€ Level 4 Abbreviation Substitution
β”‚ "compr docs sys cfg params."
β”‚ Maps ~200 common words to short codes
β”‚
└─ Level 5 Skeleton Compression (most aggressive)
"cmpr docs sys cfg prms."
Removes vowels from non-essential syllables
```

| Level | Name | Typical Reduction | Best For |
|:-----:|------|:-----------------:|----------|
| 1 | Normalize | ~5% | Always-on baseline |
| 2 | Filler | ~15% | Casual conversation |
| 3 | Articles | ~25% | Technical documentation |
| 4 | Abbreviate | ~35% | Dense code / config |
| 5 | Skeleton | ~45–55% | Maximum token savings |

```python
from ct_vault_core.kvtc import KVTCContextController

kvtc = KVTCContextController()
result = kvtc.compress(
"Please provide comprehensive documentation for all function parameters",
level=5
)
# result.compressed β†’ "prvd docs fn params"
# result.savings_pct β†’ 58.3
# result.tokens_in β†’ 12
# result.tokens_out β†’ 5
```

---

## πŸ”Œ MCP Tools (15 Total)

All tools route to the Python backend first; TypeScript fallback activates automatically if Python is offline.

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ TOOL MAP β”‚
β”‚ β”‚
β”‚ COMPRESSION ──────────────────────────────────────────────────────── β”‚
β”‚ ct_compress Compress a document (level 1-5) β”‚
β”‚ ct_compress_batch Compress multiple docs in one call β”‚
β”‚ ct_encode Encode to [CT:v1:Lx] DSL format with metadata β”‚
β”‚ ct_parse Parse and extract CompText header + content β”‚
β”‚ ct_compress_output Auto-escalate levels until token budget is met β”‚
β”‚ β”‚
β”‚ MEMORY ───────────────────────────────────────────────────────────── β”‚
β”‚ mem_remember Store content in [[Palace:Wing:Room:Drawer]] β”‚
β”‚ mem_recall BM25 search across all memory locations β”‚
β”‚ mem_list List all palace / wing / room locations β”‚
β”‚ mem_delete Prune a specific memory location β”‚
β”‚ β”‚
β”‚ CONTEXT ──────────────────────────────────────────────────────────── β”‚
β”‚ ctx_index Index a document into SQLite FTS5 β”‚
β”‚ ctx_search Full-text search with BM25 ranking β”‚
β”‚ ctx_checkpoint Save current session state snapshot β”‚
β”‚ β”‚
β”‚ STORAGE ──────────────────────────────────────────────────────────── β”‚
β”‚ cas_store Content-addressed store β†’ returns SHA-256 hash β”‚
β”‚ cas_fetch Retrieve blob by SHA-256 hash β”‚
β”‚ β”‚
β”‚ METRICS ──────────────────────────────────────────────────────────── β”‚
β”‚ ct_token_stats Global compression stats & savings report β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

### Claude Desktop Integration

```json
// %APPDATA%\Claude\claude_desktop.json
{
"mcpServers": {
"comptext": {
"command": "node",
"args": ["C:/path/to/comptext-revolution/packages/mcp-server/dist/index.js"],
"env": { "PYTHON_BACKEND_URL": "http://localhost:8000" }
}
}
}
```

---

## πŸ› Memory Palace

Hierarchical, persistent memory with LOCI-style spatial addressing.

```
[[Palace : Wing : Room : Drawer]]
β”‚ β”‚ β”‚ └─ Optional fine-grained slot
β”‚ β”‚ └─ Specific topic within the wing
β”‚ └─ Domain or category
└─ Top-level namespace

[[math:algebra:equations]] β†’ all quadratic notes
[[project:comptext:decisions]] β†’ architectural decisions
[[user:preferences:coding:style]] β†’ personal coding preferences
[[research:papers:attention:notes]] β†’ annotation for a paper
```

```python
# Store
await palace.remember("math", "algebra", "quadratic",
"x = (-b ± √(b²-4ac)) / 2a")

# BM25 semantic search
results = await palace.recall("quadratic formula")
# β†’ [{"location": "[[math:algebra:quadratic]]", "content": "..."}]

# List all locations in a palace
locations = palace.list_all(palace_filter="math")

# Delete a room
palace.delete("math", "algebra", "quadratic")
```

---

## πŸš€ Quick Start

### Prerequisites

```bash
node --version # 18+
pnpm --version # 9+
python3 --version # 3.10+
```

### 1. Clone & Install

```bash
git clone https://github.com/ProfRandom92/comptext-revolution.git
cd comptext-revolution
pnpm install
```

### 2. Build TypeScript

```bash
pnpm build
# Builds all 7 packages via tsup (ESM + CJS + .d.ts)
```

### 3. Install Python Backend

```bash
cd packages-py
pip install -e ".[dev]"
```

### 4. Start Services

```bash
# Terminal A β€” Python REST API (port 8000)
cd packages-py
uvicorn ct_vault_core.rest_api:app --host 0.0.0.0 --port 8000 --reload

# Terminal B β€” MCP Server
node packages/mcp-server/dist/index.js
```

### 5. CLI

```bash
# Compress a file
pnpm cli compress ./my-doc.txt --level 3

# Compress stdin
echo "Hello world this is a verbose sentence" | pnpm cli compress --level 5

# Token savings report
pnpm cli stats
```

---

## πŸ“ Monorepo Structure

```
comptext-revolution/
β”‚
β”œβ”€β”€ packages/ TypeScript (pnpm workspace)
β”‚ β”œβ”€β”€ core/ @comptext/core
β”‚ β”‚ β”œβ”€β”€ src/
β”‚ β”‚ β”‚ β”œβ”€β”€ compiler.ts Levels 1-5 DSL compiler
β”‚ β”‚ β”‚ β”œβ”€β”€ levels.ts applyLevel1..5 implementations
β”‚ β”‚ β”‚ β”œβ”€β”€ hybrid.ts detectInputType + compressHybrid
β”‚ β”‚ β”‚ β”œβ”€β”€ llm-tokenizer.ts js-tiktoken BPE counter
β”‚ β”‚ β”‚ β”œβ”€β”€ decompressor.ts decompress + decompressLevel
β”‚ β”‚ β”‚ └── __tests__/ 52 vitest tests
β”‚ β”‚ └── package.json tsup build, exports map
β”‚ β”‚
β”‚ β”œβ”€β”€ indexer/ SQLite FTS5 + BM25
β”‚ β”œβ”€β”€ session-memory/ Palace/Wing/Room snapshots
β”‚ β”œβ”€β”€ sandbox-runner/ Isolated Python/Bash execution
β”‚ β”œβ”€β”€ mcp-server/
β”‚ β”‚ └── src/
β”‚ β”‚ β”œβ”€β”€ tools.ts 15 tool definitions (JSON Schema)
β”‚ β”‚ β”œβ”€β”€ tool-handler.ts switch router β†’ bridge or fallback
β”‚ β”‚ └── python-bridge.ts HTTP client to :8000
β”‚ └── sdk/ Programmatic TypeScript API
β”‚
β”œβ”€β”€ packages-py/ Python backend
β”‚ β”œβ”€β”€ ct_vault_core/
β”‚ β”‚ β”œβ”€β”€ kvtc.py KVTCContextController (5 levels)
β”‚ β”‚ β”œβ”€β”€ mem_palace.py MemPalaceDB + LOCI addressing
β”‚ β”‚ β”œβ”€β”€ cas.py ContentAddressedStore (SHA-256)
β”‚ β”‚ β”œβ”€β”€ database.py Async SQLite + FTS5
β”‚ β”‚ β”œβ”€β”€ rest_api.py FastAPI app (15 endpoints)
β”‚ β”‚ └── safety_gate.py Risk scoring + rate limiting
β”‚ └── tests/ 32 pytest tests
β”‚
β”œβ”€β”€ apps/cli/ CLI application
β”œβ”€β”€ k8s/ 8 Kubernetes manifests
β”œβ”€β”€ docker-compose.yml Local dev orchestration
β”œβ”€β”€ Dockerfile.python Python backend image
└── Dockerfile.mcp MCP server image
```

---

## 🐍 Python REST API

FastAPI backend on `http://localhost:8000`

| Method | Endpoint | Description |
|:------:|----------|-------------|
| `POST` | `/compress` | Compress text at level 1-5 |
| `POST` | `/remember` | Store in MemPalace |
| `POST` | `/recall` | BM25 search in MemPalace |
| `GET` | `/mem/list` | List all memory locations |
| `POST` | `/mem/delete` | Delete a memory location |
| `POST` | `/cas/store` | Store blob, receive SHA-256 |
| `GET` | `/cas/{sha}` | Retrieve blob by hash |
| `POST` | `/ctx/checkpoint` | Save session snapshot |
| `POST` | `/encode` | Encode to `[CT:v1:Lx]` DSL |
| `POST` | `/parse` | Parse CompText format |
| `POST` | `/compress-output` | Auto-escalate to token budget |
| `GET` | `/token-stats` | Global compression metrics |
| `GET` | `/health` | Health check |
| `GET` | `/metrics` | Prometheus metrics |

```bash
# Compress at level 4
curl -s -X POST http://localhost:8000/compress \
-H "Content-Type: application/json" \
-d '{"text": "Please provide comprehensive documentation", "level": 4}'
# β†’ {"compressed":"prvd compr docs","savings_pct":45.2,"tokens_in":6,"tokens_out":3}

# Interactive API docs
open http://localhost:8000/docs
```

---

## πŸ§ͺ Test Suite

**84 tests β€” all passing**

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ β”‚
β”‚ TypeScript (vitest) 52 / 52 βœ“ β”‚
β”‚ β”œβ”€ compress.test.ts 19 tests β”‚
β”‚ β”œβ”€ compression.integration.test.ts 13 tests β”‚
β”‚ β”œβ”€ hybrid.test.ts 12 tests β”‚
β”‚ └─ llm-tokenizer.test.ts 8 tests β”‚
β”‚ β”‚
β”‚ Python (pytest) 32 / 32 βœ“ β”‚
β”‚ β”œβ”€ test_kvtc.py 6 tests β”‚
β”‚ β”œβ”€ test_mem_palace.py 8 tests β”‚
β”‚ β”œβ”€ test_database.py 5 tests β”‚
β”‚ β”œβ”€ test_safety_gate.py 5 tests β”‚
β”‚ └─ test_integration.py 8 tests β”‚
β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

```bash
# TypeScript
pnpm --filter @comptext/core test run

# Python
cd packages-py && python -m pytest tests/ -v

# Both at once
pnpm test && cd packages-py && python -m pytest tests/ -q
```

---

## ☸️ Kubernetes Deployment

Production-ready manifests with Canary rollout via Flagger.

```
k8s/
β”œβ”€β”€ namespace.yaml comptext-revolution namespace
β”œβ”€β”€ deployment.yaml MCP server (3 replicas Β· HPA 3-10)
β”œβ”€β”€ deployment-python.yaml Python backend (3 replicas)
β”œβ”€β”€ service.yaml ClusterIP services
β”œβ”€β”€ ingress.yaml NGINX ingress + TLS
β”œβ”€β”€ hpa.yaml HorizontalPodAutoscaler
β”œβ”€β”€ pvc.yaml PersistentVolumeClaim (vault data)
└── canary.yaml Flagger Canary β€” 3-phase, 22 days
```

**Canary phases:**

```
Phase 1 (Days 1–7) 10% traffic ── latency p99 < 200ms ──► pass
Phase 2 (Days 8–15) 40% traffic ── error rate < 1% ──► pass
Phase 3 (Days 16–22) 90% traffic ── all metrics green ──► promote
```

```bash
kubectl apply -f k8s/
kubectl get canary -n comptext-revolution -w
```

---

## πŸ“Š Performance

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ BENCHMARK RESULTS β”‚
β”‚ β”‚
β”‚ Compression Latency β”‚
β”‚ β”œβ”€ L1-L3 < 1 ms β–ˆβ–ˆβ–ˆβ–ˆ β”‚
β”‚ β”œβ”€ L4-L5 < 5 ms β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β”‚
β”‚ └─ p99 8 ms β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β”‚
β”‚ β”‚
β”‚ Token Savings (typical prose) β”‚
β”‚ β”œβ”€ Level 2 15-20 % β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β”‚
β”‚ β”œβ”€ Level 3 20-30 % β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β”‚
β”‚ β”œβ”€ Level 4 30-40 % β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β”‚
β”‚ └─ Level 5 40-55 % β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β”‚
β”‚ β”‚
β”‚ Throughput β”‚
β”‚ β”œβ”€ Compress API 5,000 req/s β”‚
β”‚ β”œβ”€ FTS5 index 10,000 docs/min β”‚
β”‚ └─ MemPalace recall O(1) palace lookup β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## πŸ”— Related

| Repo | Role |
|------|------|
| [comptext-codex](https://github.com/ProfRandom92/comptext-codex) | Original Python compression foundation |
| [comptext-mcp-server](https://github.com/ProfRandom92/comptext-mcp-server) | Original MCP integration |
| [comptext-dsl](https://github.com/ProfRandom92/comptext-dsl) | DSL specification |

> This monorepo consolidates all three into a single production platform.

---

## 🀝 Contributing

PRs, issues, and ideas welcome. The codebase is fully typed (TypeScript strict + Python type hints) and test-driven.

```bash
pnpm install && pnpm build
cd packages-py && pip install -e ".[dev]"

# Verify
pnpm --filter @comptext/core test run # 52/52
cd packages-py && python -m pytest # 32/32
```

---

**MIT License Β© 2026 ProfRandom92**

*Built with TypeScript Β· Python Β· FastAPI Β· SQLite Β· Kubernetes*


```
Every token counts.
Compress the revolution.
```