Metadata-Version: 2.4
Name: tldrgraph
Version: 0.3.1
Summary: Sub-2ms hybrid file search (SQLite FTS5 + Model2Vec) and anti-spaghetti multi-flow code graphs for humans and coding agents.
License: MIT
Project-URL: Homepage, https://github.com/vikrantd/TLDRGraph
Project-URL: Documentation, https://vikrantd.github.io/TLDRGraph/
Project-URL: Repository, https://github.com/vikrantd/TLDRGraph
Project-URL: Issues, https://github.com/vikrantd/TLDRGraph/issues
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: tabulate>=0.9.0
Requires-Dist: numpy>=1.24
Requires-Dist: model2vec>=0.3
Provides-Extra: embeddings
Requires-Dist: fastembed>=0.3; extra == "embeddings"
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.5.0; extra == "docs"
Requires-Dist: mkdocs-minify-plugin>=0.8.0; extra == "docs"
Dynamic: license-file

<p align="center">
  <img src="assets/tldrgraph_logo.svg" alt="TLDRGraph Logo" width="380" />
</p>

<h1 align="center">TLDRGraph 🌐</h1>

<p align="center">
  <strong>Sub-10ms Hybrid File Search &amp; Anti-Spaghetti Multi-Flow Code Graphs.</strong> ⚡<br>
  <em>SQLite FTS5 + Model2Vec Static Retrieval Embeddings + Separate Execution Flow Graphs for Humans &amp; Coding Agents.</em>
</p>

<p align="center">
  <a href="https://pypi.org/project/tldrgraph/"><img src="https://img.shields.io/badge/pypi-v0.3.0-0ea5e9.svg?logo=pypi&logoColor=white" alt="PyPI version"></a>
  <a href="https://vikrantd.github.io/TLDRGraph/"><img src="https://img.shields.io/badge/docs-GitHub%20Pages-0284c7.svg?logo=materialformkdocs&logoColor=white" alt="Documentation"></a>
  <a href="https://pypi.org/project/tldrgraph/"><img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-3776AB.svg?logo=python&logoColor=white" alt="Python versions"></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-10b981.svg" alt="License: MIT"></a>
</p>

---

## 💡 Why TLDRGraph v0.3?

Whole-repo dependency diagrams turn into unreadable spaghetti hairballs the moment a project passes 30 files, while heavy RAG indexers take minutes to embed and flood agent context windows with noisy chunks.

**TLDRGraph v0.3** solves both problems from the ground up:

1. **Fast Hybrid File Search (`tldrgraph query`)** — Fuses **4-column weighted SQLite FTS5 BM25** (sub-tokenized `CamelCase`, `snake_case`, file paths, and HTTP routes) with **Model2Vec (`minishlab/potion-retrieval-32M`) static retrieval vectors**, **Reciprocal Rank Fusion (RRF)**, and **1-hop dependency graph boosting**. Indexes 160+ files in **`<1 second`** (170× faster than transformer ONNX embeddings) and localizes files in **`~1–8 ms`**.
2. **Separate Flow Graphs Instead of Spaghetti (`tldrgraph ui`)** — Instead of dumping 600 files into one tangled canvas, TLDRGraph isolates each user/system journey into its own **3-to-8 step Layered Flow Graph**, paired with **Subsystem-scoped Layer Swimlanes** (automatically collapsing repetitive clone folders in monorepos) and **1-click file/line navigation** (inline code viewer, live `/__api/file` reader, and `vscode://file` jump links).
3. **Antigravity-Native Incremental Workflow** — Works directly through **Antigravity** (and other `AGENTS.md` / `.agents/skills` coding agents) with zero external API keys: `tldrgraph init` writes `.tldrgraph/agent_brief.json`, the agent reads real hub files to curate `.tldrgraph/architecture.yaml`, and `tldrgraph status` detects added/modified/removed files instantly via SHA-256 hashes.

---

## 📊 SWE-bench Lite & Memory-Recall Benchmark (40 Real GitHub Tasks)

Evaluated on 40 real-world GitHub issues from **SWE-bench Lite**, measuring ground-truth modified file recall, Mean Reciprocal Rank (MRR), prompt token footprint, query latency, and cold index build time:

| Retrieval Method | Recall@1 | Recall@5 | Recall@10 | MRR | Context Tokens | Query Latency | Cold Index Time |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| **Aider Repo-Map (AST PageRank)** | 17.5% | 50.0% | 72.5% | 0.331 | ~8,200 | 2.05 ms | — |
| **Mem0 (Memory Vector Store)** | 42.5% | 72.5% | 80.0% | 0.542 | ~12,000 | 29.14 ms | — |
| **Graphify (AST Knowledge Graph)** | 45.0% | 80.0% | 82.5% | 0.591 | ~9,500 | 1.27 ms | — |
| **Codebase-Memory-MCP** | 50.0% | 70.0% | 75.0% | 0.581 | ~14,200 | 27.21 ms | — |
| **PageIndex (Tree-Based ToC)** | 50.0% | 82.5% | 85.0% | 0.634 | ~11,000 | 1.19 ms | — |
| **BM25 Lexical Keyword Search** | 60.0% | 80.0% | 85.0% | 0.671 | ~28,500 | 19.24 ms | — |
| **Chunked Dense Vector RAG** | 70.0% | 95.0% | 95.0% | 0.797 | ~22,400 | 37.48 ms | 104,652 ms |
| **TLDRGraph (FTS5 Zero-Model)** | 70.0% | 95.0% | **97.5%** | 0.792 | **~600** | **2.56 ms** | **154 ms** |
| **TLDRGraph Hybrid (BGE-small + FTS5)** | 72.5% | 95.0% | **97.5%** | 0.831 | **~600** | 31.05 ms | 164,035 ms |
| **TLDRGraph Hybrid (Model2Vec + FTS5)** | **77.5%** | **95.0%** | 95.0% | **0.836** | **~600** | **8.09 ms** | **964 ms** |

---

## 🚀 Quickstart

### 1. Install
```bash
pip install tldrgraph
```

### 2. Initialize & Build Your Architecture Graph
```bash
tldrgraph init .
```
- Deterministically parses Python, TypeScript, JavaScript, Go, Rust, and Shell modules.
- Links cross-file imports, `@scope/pkg` monorepo aliases, and frontend `fetch('/api/...')` → backend HTTP route seams.
- Builds `.tldrgraph/search.db` (`SQLite FTS5` + SHA-256 content-cached `Model2Vec` slice embeddings).
- Installs Antigravity skill (`.agents/skills/tldrgraph-init/SKILL.md`), `AGENTS.md`, and `.tldrgraph/AGENT_CONTRACT.md`.
- Compiles the zero-CDN standalone visualizer at `.tldrgraph/TLDRGRAPH_VISUALIZER.html`.

Ask **Antigravity** (or run the `tldrgraph-init` skill) to curate `.tldrgraph/architecture.yaml` from `.tldrgraph/agent_brief.json` and your hub source files, then re-run `tldrgraph init .`.

### 3. Localize Files Instantly (`tldrgraph query`)
```bash
tldrgraph query "monthly llm budget quota enforcement"
tldrgraph query "aptitude test grading proctoring" --json
```
Returns a concise ranked file table (file path, subsystem/layer scope, key symbols/routes, 1-line summary, score) so agents open exact target files immediately instead of running blind grep loops.

### 4. Explore Multi-Flow Graphs & Navigate to Code (`tldrgraph ui`)
```bash
tldrgraph ui --serve
```
Opens `http://127.0.0.1:8777/` with three focused views:
1. **Flows**: Separate step-by-step layered DAGs per feature/journey (`LR` / `TB` toggle, keyboard `◀`/`▶` walkthrough, edge labels, zero cross-flow clutter).
2. **Architecture**: High-level **System Overview** across subsystems + scoped **Layer Swimlanes** with 1-click upstream caller / downstream dependency spotlighting.
3. **Files & Code**: Directory tree, global `/` or `⌘K` search modal, full live source viewer with highlighted symbol line ranges, connected flow pills, and 1-click **Open in VS Code / Cursor** (`vscode://file...`).

### 5. Incremental Drift Detection (`tldrgraph status`)
```bash
tldrgraph status
tldrgraph flows
tldrgraph layers
tldrgraph doctor
```
`tldrgraph status` compares live SHA-256 file hashes against `.tldrgraph/graph.json` in milliseconds, listing exact `added_files`, `modified_files`, and `removed_files` so Antigravity updates only what changed.

---

## 📁 Repository State (`.tldrgraph/`)

| File | Tracked in Git? | Purpose |
| :--- | :---: | :--- |
| `.tldrgraph/architecture.yaml` | **Yes** | Human- & Antigravity-editable subsystems, layers, module summaries, and separate Flow Graphs |
| `.tldrgraph/AGENT_CONTRACT.md` | **Yes** | Schema reference for coding agents |
| `.tldrgraph/graph.json` | Ignored | Compiled graph snapshot with SHA-256 module hashes and enriched line ranges |
| `.tldrgraph/search.db` | Ignored | SQLite FTS5 + SHA-256 cached `Model2Vec` vector store |
| `.tldrgraph/agent_brief.json` | Ignored | Ranked hub modules, subsystems, and dirty-file handoff for Antigravity |
| `.tldrgraph/TLDRGRAPH_VISUALIZER.html` | Ignored | Zero-CDN standalone interactive multi-flow visualizer |

---

## 📄 License

Distributed under the [MIT License](LICENSE).
