Metadata-Version: 2.4
Name: savetoken
Version: 0.1.0
Summary: Convert Repomix/repominify output into compact AI-friendly codebase summaries using free LLMs.
License: MIT
Project-URL: Homepage, https://github.com/yourname/savetoken
Project-URL: Issues, https://github.com/yourname/savetoken/issues
Keywords: ai,llm,codebase,repomix,prompt,tokens,summarizer
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Documentation
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: mypy; extra == "dev"

# savetoken 🪙

> Convert your Repomix codebase dump into a **compact semantic summary** — optimized for AI prompts, with zero raw code.

Instead of pasting 50,000 tokens of source code into ChatGPT or Claude, `savetoken` uses a **free LLM** to read the code once and produce a structured `codebrief.md` you reuse forever.

---

## How it fits in your workflow

```
Your project
    ↓
npx repomix              # packs codebase → repomix-output.xml
    ↓
savetoken summarize repomix-output.xml   # translates → codebrief.md  ← you are here
    ↓
Paste codebrief.md into your AI prompt   # ~500 tokens instead of 50k+
```

---

## Install

```bash
pip install savetoken
```

Requires Python 3.10+. Zero dependencies beyond stdlib.

---

## Quick start

```bash
# 1. Pack your codebase with Repomix
npx repomix

# 2. Summarize with Gemini Flash (free tier)
export GEMINI_API_KEY=your_key_here
savetoken summarize repomix-output.xml

# Output: codebrief.md — paste it into any AI prompt!
```

### Python API

```python
from savetoken import SaveToken

st = SaveToken(provider="gemini", api_key="...")
summary = st.summarize("repomix-output.xml")
st.save(summary, "codebrief.md")
```

---

## Providers

| Provider | Free tier | Set env var |
|---|---|---|
| **Gemini Flash 2.0** ⭐ | ✅ Generous | `GEMINI_API_KEY` |
| **Groq (Llama 3.3 70B)** | ✅ Fast | `GROQ_API_KEY` |
| **Mistral Small** | ✅ Available | `MISTRAL_API_KEY` |
| **OpenAI / DeepSeek** | Paid | `OPENAI_API_KEY` |

Gemini is recommended — 1M token context window handles large codebases.

---

## CLI

```bash
savetoken summarize repomix-output.xml
savetoken summarize repomix-output.xml --provider groq --output brief.md --lang pt
savetoken summarize repomix-output.xml --force   # ignore cache, regenerate all
savetoken clear-cache
```

| Flag | Default | Description |
|---|---|---|
| `--provider` | `gemini` | LLM provider |
| `--output` | `codebrief.md` | Output file |
| `--format` | `markdown` | `markdown` or `json` |
| `--lang` | `en` | Description language |
| `--force` | off | Skip cache |
| `--cache-dir` | `.savetoken_cache` | Cache location |

---

## Caching

`savetoken` hashes each file's content. On re-runs, **only changed files are re-summarized**. The cache lives in `.savetoken_cache/` — commit it to git to share across your team.

---

## VS Code Extension

Install the extension and use:
- **Command Palette → SaveToken: Summarize Codebase**
- Right-click `repomix-output.xml` → **SaveToken: Summarize**
- Configure provider and API key in Settings → SaveToken

---

## Example output (`codebrief.md`)

```markdown
# MyShop — savetoken summary

E-commerce backend built with FastAPI and PostgreSQL.

**Stack:** FastAPI, PostgreSQL, SQLAlchemy, Redis
**Architecture:** Layered MVC
**Entry points:** main.py

## Directory Map
- `src/api` — HTTP route handlers (REST)
- `src/services` — Business logic layer
- `src/models` — SQLAlchemy ORM entities

## Files

### `src/services/order.py`
Manages the full lifecycle of customer orders.

**Entities:**
- Order(id, user_id, total, status: enum[pending, paid, cancelled])

**Functions:**
- create_order(user_id, items) → Order: validates stock and creates order
- cancel_order(order_id) → bool: cancels if status allows
- calculate_total(items) → Decimal: applies discounts and rounds
```

---

## License

MIT
