Metadata-Version: 2.4
Name: teixido-code-manifold
Version: 3.4.2
Summary: Teixido Inhibition Gate for codebases. Compresses LLM context by 80-95% using Domination Roots. Native MCP server for Claude Code.
Author-email: John Teixido <johnvteixido@gmail.com>
License: Proprietary - All Rights Reserved
Project-URL: Homepage, https://github.com/johnvteixido/TIG
Project-URL: Repository, https://github.com/johnvteixido/TIG
Project-URL: Bug Tracker, https://github.com/johnvteixido/TIG/issues
Keywords: llm,context-compression,codebase-analysis,mcp,claude,ai-tools,devtools,graph-theory,topology,teixido,ast-analysis,blast-radius
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: networkx>=3.0
Requires-Dist: httpx>=0.24.0
Requires-Dist: rich>=13.0.0
Requires-Dist: email-validator>=2.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: fastapi
Requires-Dist: uvicorn
Requires-Dist: stripe
Requires-Dist: supabase
Requires-Dist: requests
Provides-Extra: server
Requires-Dist: uvicorn>=0.23.0; extra == "server"
Requires-Dist: fastapi>=0.103.0; extra == "server"
Requires-Dist: stripe>=6.0.0; extra == "server"
Requires-Dist: supabase>=2.3.0; extra == "server"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: httpx>=0.25.0; extra == "dev"
Requires-Dist: fastapi>=0.103.0; extra == "dev"
Requires-Dist: uvicorn>=0.23.0; extra == "dev"
Dynamic: license-file

# Teixido-Code-Manifold (TIG) v3.4

[![PyPI](https://img.shields.io/pypi/v/teixido-code-manifold)](https://pypi.org/project/teixido-code-manifold/)
[![Tests](https://github.com/johnvteixido/TIG/actions/workflows/test.yml/badge.svg)](https://github.com/johnvteixido/TIG/actions)
[![License: Proprietary](https://img.shields.io/badge/License-Proprietary-red.svg)](LICENSE)

> **Stop sending your entire codebase to Claude. It's causing structural hallucinations and burning your usage limit.**

TIG is a **Teixido Inhibition Gate** for codebases. It intercepts LLM context requests, analyzes your Abstract Syntax Tree, and applies **Topological Analytical Homeostasis (TAH)** to compress your project down to its **"Teixido Skeleton"** — the 3-5% of functions that hold the actual structural load of your application.

The result: **80-95% fewer tokens** sent to Claude per session, which directly stretches your **Claude Code usage limit** by the same factor.

---

## Why TIG Beats Basic Codebase Indexers

Standard tools (like `codeindex`) map everything with regex and give you a "blast score" — still drowning the AI in noise.

TIG applies **Weighted Topological Strain** to mathematically isolate the **Domination Roots**:

```
strain(f) = log1p((in_degree × 0.6 + normalized_complexity × 0.4) × 100)
```

Then applies **Adaptive TIG Gate** (Topological Inhibitory Gating) using dynamic thresholding:

```
threshold = mean(strain) + ε × std_dev(strain)
```

Only nodes above this threshold are fed to Claude. Everything else is structural noise.

| Metric | codeindex | **TIG** |
|---|---|---|
| Parsing | Regex | **Python AST + robust regex** |
| Algorithm | Raw BFS count | **Weighted topological strain** |
| Context compression | ❌ No | **✅ 80-95%** |
| MCP server | ✅ | **✅** |
| PyPI | ❌ | **✅** |
| Tests | ❌ | **✅ CI on every push** |
| Languages | 12 (regex only) | **13+ (AST for Python)** |

---

## Installation

```bash
pip install teixido-code-manifold
```

Or from source:
```bash
git clone https://github.com/johnvteixido/TIG.git
cd TIG
pip install -e ".[dev]"
```

---

## Usage

### CLI

```bash
# Analyze a single file
teixido-extract --file src/main.py

# Analyze a whole project
teixido-extract --dir ./my-project

# Output raw JSON
teixido-extract --file app.py --json

# Adjust TIG sensitivity (higher = fewer roots)
teixido-extract --dir . --epsilon 1.5
```

### Python API

```python
from core.manifold import TeixidoEngine

# Analyze source code string
result = TeixidoEngine.analyze(source_code, language="python")
print(result["domination_roots"])       # ['main', 'process_data', 'connect_sql']
print(result["compression_ratio"])      # 87.5 (%)
print(result["token_savings"])          # {'token_savings_pct': 91.2, ...}

# Analyze a whole directory
result = TeixidoEngine.analyze_directory("./my-project")
print(result["files_analyzed"])         # 47
print(result["domination_roots"])       # top load-bearing functions across all files
```

### FastAPI (Vercel)

```bash
teixido-serve   # starts on http://localhost:8000
# or deploy to Vercel: link this repo, vercel.json handles routing
```

**Endpoints:**
- `GET /` — Health check
- `GET /api/info` — Capabilities + supported languages
- `POST /api/extract` — Analyze source code string
- `POST /api/compress` — Analyze a local directory

---

## 🤖 Claude Code MCP Integration

This is the killer feature. Add TIG as a native MCP server so Claude Code can call it directly during every session — automatically compressing context before Claude reads your code.

### Step 1: Install TIG
```bash
pip install teixido-code-manifold
```

### Step 2: Add to Claude Code MCP config

Edit `~/.claude/claude_desktop_config.json` (or equivalent):

```json
{
  "mcpServers": {
    "teixido": {
      "command": "teixido-mcp",
      "args": []
    }
  }
}
```

### Step 3: Use in Claude Code

Once configured, Claude Code has access to three tools:

| Tool | What it does |
|---|---|
| `extract_manifold` | Analyze a source code string → Domination Roots |
| `compress_codebase` | Analyze your whole project → architectural skeleton |
| `get_token_savings` | Show exactly how many tokens + % you're saving |
| `store_memory` *(Pro)* | Save a durable fact/decision to project-scoped long-term memory |
| `search_memory` *(Pro)* | Recall stored facts across sessions (survives context compaction) |
| `delete_memory` *(Pro)* | Prune outdated memories by id |

**Example Claude Code prompt:**
> "Before we start, run `compress_codebase` on `./src` and tell me the Domination Roots."

Claude will call TIG, get back the 3-5 structurally critical functions, and work only from those — using a fraction of your hourly token budget.

---

## Token Savings & Usage Limit Impact

| Source Size | Without TIG | With TIG | Savings |
|---|---|---|---|
| 500-line file | ~2,000 tokens | ~80 tokens | **96%** |
| 2,000-line file | ~8,000 tokens | ~120 tokens | **98.5%** |
| 50-file project | ~80,000 tokens | ~1,000 tokens | **98.75%** |

If Claude Code limits you to, say, 50,000 tokens/hour — with TIG, that same budget covers the equivalent of 1,000,000+ tokens of raw codebase, effectively making the hourly limit invisible for normal development workflows.

---

## Supported Languages

| Language | Parsing Method |
|---|---|
| Python | ✅ stdlib `ast` (full AST, exact line numbers) |
| JavaScript | Robust multi-pattern regex |
| TypeScript | Robust multi-pattern regex + `///` references |
| Go | Multi-line import block regex |
| Rust | `use`, `mod`, `extern crate` patterns |
| Java | `import` statement regex |
| Kotlin | `import` statement regex |
| Swift | `import` statement regex |
| C / C++ | `#include` directive regex |
| PHP | `require`, `use`, `namespace` regex |
| Ruby | `require`, `require_relative` regex |
| C# | `using` directive regex |

---

## Architecture

```
teixido-code-manifold/
├── core/
│   ├── languages.py      # Multi-language parser (AST + regex)
│   ├── manifold.py       # Weighted Topological Strain engine
│   └── mcp_server.py     # MCP stdio server (Claude Code integration)
├── api/
│   └── index.py          # FastAPI serverless entry point (Vercel)
├── cli.py                # Console entry points
├── tests/                # pytest suite
├── pyproject.toml        # PyPI packaging config
└── vercel.json           # Vercel deployment config
```

---

## License

Proprietary Software - All Rights Reserved.

**Architect & Creator:** John V. Teixido
&copy; 2026 tigcode.app
Unauthorized copying, reverse-engineering, distribution, or commercial use of this file or any part of the TIG codebase (including the client engine and the server nodes) is strictly prohibited.
