> ## Documentation index
> Fetch the complete documentation index at: https://docs.leantoken.dev/llms.txt
> Ask it with GET https://docs.leantoken.dev/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.

# Ecosystem Enhancements

> Integration patterns and marketplace-style tooling considerations.

# 06. Ecosystem Enhancements & Marketplace Integration Considerations

This document reviews marketplace-style agent tooling and integration considerations, then describes an alternative architectural stack for **LeanToken**. Observations from a particular setup or benchmark may not apply to other products or workloads.

---

## 1. Marketplace-Style Agent Tooling

The tools below illustrate common categories of community and open-source extensions used alongside coding agents:

| Tool | Creator / Repository | Mechanism | Integration Type |
| :--- | :--- | :--- | :--- |
| **Ponytail** (`v4.9.0`) | `DietrichGebert/ponytail` | Enforces YAGNI ladder; prevents over-engineered code and bloat | Third-party plugin wrapper |
| **Caveman** (`v4.2.0`) | `JuliusBrussee/caveman` | Enforces telegraphic caveman-speak; cuts 35%–65% output tokens | Third-party plugin wrapper |
| **Chisle** | `JayPokale/Chisle` | Combines Caveman + Ponytail + basic output trimming | Third-party plugin wrapper |
| **RTK** (`v1.2.0`) | `rtk-ai/rtk` | Rust Token Killer: rewrites bash commands (`git status`, `pytest`) | Third-party CLI hook |
| **Serena** (`v2.1.0`) | `oraios/serena` | MCP server for symbol-level code retrieval (single functions) | Third-party MCP launcher |
| **Codebase Memory** (`v0.12.1`)| `DeusData/codebase-memory-mcp` | Knowledge-graph MCP server for structural repository queries | Third-party MCP launcher |
| **Context7** (`v4.7.1`) | `upstash/context7` | MCP server fetching version-specific library documentation | Third-party MCP launcher |
| **MarkItDown** (`v0.1.9`) | `microsoft/markitdown` | Converts PDF / Office documents to Markdown | Third-party MCP/CLI wrapper |

---

## 2. Integration Observations from One Benchmark Setup

In one 16-day production review, the tested setup reported:
- **RTK recorded 0 commands in its database.**
- **CCR (Compress-Cache-Retrieve) stored only 1 item.**
- **OpenCode/MCP saw zero usage.**
- **Net compression remained at a dismal 1.53%.**

### Possible Factors in the Reviewed Setup:

### 1. The MCP "Schema Tax" (Hidden Context Bloat)
Notice the fine print on Serena: *"adds its tool definitions to every request."*
When an agent loads 4 MCP servers (Serena, Codebase Memory, Context7, MarkItDown), the agent must append the JSON schemas for **15 to 25 tools** to the system prompt on **every single turn**.
- Tool schema overhead: **3,000 to 7,000 tokens per turn**.
- If the agent only calls Serena once in a 20-turn session, the developer paid **60,000 to 140,000 tokens** in tool schema overhead just to save a few thousand tokens on a file read.

### 2. Shell Hook Configuration Across Platforms

RTK relies on a pre-tool execution hook (e.g. rewriting shell calls before the LLM runs them). Hook setup must account for the active shell and agent environment; in the reviewed configuration, the hook did not run and no commands were rewritten.

### 3. Potential Marketplace Conflict & Redundancy

Some extensions overlap in purpose; for example, Chisle's description advises using it instead of Ponytail and Caveman, rather than alongside them. Enabling overlapping tools together may add redundant or competing prompt instructions.
- Multiple formatting plugins can add redundant or competing instructions; the effect depends on their configuration and the agent.

### 4. Availability of Session-Learning Features
Session-learning features can be tied to a particular product or proxy. A standalone implementation can make transcript analysis available independently.

---

## 3. How LeanToken Enhances and Fixes the Stack

LeanToken offers an orchestrated, local-first open-source implementation:

```
┌────────────────────────────────────────────────────────────────────────┐
│                        LeanToken Enhanced Engine                       │
└────────────────────────────────────────────────────────────────────────┘
   │
   ├── 1. Reliable Native Hook (Native RTK + `lean-prune`)
   │      - Robust cross-platform hook (pwsh, bash, zsh)
   │      - Rewrites `git status`, `git log`, `pytest`, `npm test`
   │      - Execution time < 3ms in Rust/Go; full logs spooled to `.lean/logs/`
   │
   ├── 2. Mutually-Exclusive Rule Presets
   │      - Curated Profiles: "Lean Sprint" (Chisle) OR "Modular Max" (Caveman + Ponytail)
   │      - Strict prevention of competing prompt instructions
   │
   ├── 3. Lazy / On-Demand Tool Definitions (Eliminating the MCP Schema Tax)
   │      - Do NOT inject 25 MCP tools into every request
   │      - Use a single meta-tool or dynamic activation: only inject Serena/Context7
   │        when the agent is explicitly in code-exploration or library-doc mode
   │
   ├── 4. Local LSP / Tree-Sitter Bridge (Replacing Heavy Knowledge Graphs)
   │      - Codebase Memory builds heavy graphs; LeanToken leverages local Tree-sitter
   │        and existing IDE language servers (LSP) for instant, token-free symbol resolution
   │
   ├── 5. Standalone Open-Source `lean-learn` CLI
   │      - Runs out-of-band when session ends
   │      - Scrapes session transcripts for files re-read ≥ 3x and failed bash attempts
   │      - Automatically writes memory to `CLAUDE.md` / `MEMORY.md` at 0ms turn latency
```

---

## 4. Evaluation of Additional Free Open-Source Tools to Integrate

Potential complementary tools and integrations include:

1. **Tree-sitter / AST-Grep (`ast-grep`)**:
   - Instead of dumb text search, allows the agent to search for syntactic code patterns (`find all calls to function X matching signature Y`). Cuts search output tokens by 80%.
2. **Repomix / Gitingest**:
   - Generates compact, token-budgeted directory trees and file packings for initial project indexing.
3. **Microsoft MarkItDown**:
   - Retain MarkItDown as an optional converter for documentation and specification tasks (PDF/DOCX $\rightarrow$ Clean Markdown).
4. **Context7 (Upstash)**:
   - Keep as an on-demand documentation fetcher to stop agents from hallucinating outdated API parameters.
