Metadata-Version: 2.4
Name: slancha-dogfood
Version: 0.5.1
Summary: Put Claude Code on Slancha — MCP delegate for research offload + ccshim that routes /v1/messages through Slancha's OSS-tier routing.
Author: Paul Logan
Requires-Python: >=3.12
Requires-Dist: anthropic>=0.40.0
Requires-Dist: click>=8.1.0
Requires-Dist: httpx>=0.27
Requires-Dist: langfuse>=2.40.0
Requires-Dist: mcp>=1.2.0
Requires-Dist: openai>=1.50.0
Requires-Dist: pydantic>=2.8.0
Requires-Dist: pyyaml>=6.0
Provides-Extra: ccshim
Requires-Dist: starlette>=0.37; extra == 'ccshim'
Requires-Dist: uvicorn>=0.30; extra == 'ccshim'
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.6.0; extra == 'dev'
Description-Content-Type: text/markdown

# slancha-dogfood

**Put Claude Code on Slancha.** Two ways:

- **`slancha-delegate`** — an MCP tool that any Claude Code session can install in one line. Your research-class subagent dispatches (file exploration, multi-source synthesis) route to Slancha's OSS models on your **OpenRouter key** instead of burning Anthropic quota.
- **`claude-slancha`** — a launcher that routes all of Claude Code's inference through a local Starlette shim → Slancha. Your daily `claude` session runs on cheap OSS-tier models, the heavy turns automatically pin a strong tool-caller.

**Status: v0.5.0.** This is the **consumption side** of Slancha — the SaaS product lives in `slancha-api`. Both surfaces here are **BYOK** (Slancha holds no house keys): the Slancha key is yours, the OSS routes bill *your* OpenRouter account, and the funded Anthropic path billing is Slancha-side.

> **Cost honesty (read this first).** Because both surfaces are BYOK on the OSS path, every dispatch lands on *your* OpenRouter dashboard. The convergence work (see numbers below) cut typical Claude Code turn costs ~71% on the OSS path, and the delegate's deep-research convergence rate is 100% on the validation prompt — but **you should set an OpenRouter spend cap before installing.** See `docs/CONSUMING_SLANCHA.md` § Cost expectations.

## What you actually get (benched 2026-05-29, n≥10 each)

| surface | metric | result |
|---|---|---|
| `claude-slancha` (ccshim) | input cost vs unswapped default | **~71% cheaper** ($1.74 → ~$0.50 per Mtok input on most turns) |
| `claude-slancha` (ccshim) | per-turn prefill weight | **~halved** (tool-defs were 66% of a turn; MCP-strip drops ~98 unused tools) |
| `slancha-delegate` (deep Cat C synth) | convergence rate on Slancha | **100%** (was 30% before this session's work) |
| `slancha-delegate` (deep Cat C synth) | mean wall-clock per dispatch | **~172s** (down from ~322s baseline) |

Source: `SESSION_LOG_2026_05_27_CLAUDE_SLANCHA_EMPTY_FIX.md` at repo root. Method: kimi-k2.6 @ 200k budget, fixed Cat C prompt, env-controlled arms, `scripts/bench_convergence.py`.

## Install — 5 minutes

### Prerequisites

- Mac or Linux, Python 3.12+, `uv` (or `pipx`).
- [Claude Code](https://claude.com/claude-code) installed (`claude` on PATH).
- A **Slancha API key** — `SLANCHA_API_KEY`.
- An **OpenRouter API key** — Slancha is BYOK; OSS-tier routes use yours. **Set a spend cap on it** at https://openrouter.ai/settings before continuing.

### Option A — just the `slancha-delegate` MCP tool

This is the lighter install. Your existing Claude Code keeps using Anthropic; only research-class subagent dispatches offload to Slancha.

```bash
uv tool install slancha-dogfood            # or: pipx install slancha-dogfood
claude mcp add slancha-delegate -- slancha-delegate-mcp
```

Then in any Claude Code session, ask it to run a research task — it should call `mcp__slancha-delegate__slancha_delegate` instead of spawning an `Agent` subagent.

### Option B — full `claude-slancha` (CC on Slancha)

This routes **all** of Claude Code's inference through Slancha. Heavier setup; cheaper running cost.

```bash
uv tool install slancha-dogfood
# Run the shim in one terminal (it must stay up):
slancha-ccshim
# In another terminal:
claude-slancha
```

For long-running use, install the shim under launchd — see `docs/CCSHIM.md`.

### Configuration

Both surfaces read from `~/.slancha-test/.env` or env vars:

```bash
SLANCHA_API_KEY=sk-slancha-...
OPENROUTER_API_KEY=sk-or-v1-...
```

For the full env-knob list (model tier overrides, tool-strip allowlist, sampling temperature, convergence thresholds), see **[`docs/CONSUMING_SLANCHA.md`](docs/CONSUMING_SLANCHA.md)**.

## Verify it's working

```bash
# slancha-delegate (MCP) — your usage log should show successes routed to Slancha:
slancha-delegate-mcp --help            # confirms the entry point exists
python -m slancha_dogfood.usage_log    # after a few dispatches, shows route= / cost_usd / by_employee

# claude-slancha (shim) — health probe + a one-turn smoke test:
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8787/    # -> 200
claude-slancha -p "say hi"
```

## Docs map

- **[`docs/CONSUMING_SLANCHA.md`](docs/CONSUMING_SLANCHA.md)** — long-form setup, every env knob, the bench numbers in full, how to override defaults per task.
- **[`docs/CCSHIM.md`](docs/CCSHIM.md)** — shim internals, the launchd plist, the `SLANCHA_CC_*` knobs in depth.
- **[`docs/blog-claude-code-on-slancha.md`](docs/blog-claude-code-on-slancha.md)** — narrative example: a real CC session running on Slancha, what it cost, what it shipped.
- **[`SESSION_LOG_2026_05_27_CLAUDE_SLANCHA_EMPTY_FIX.md`](SESSION_LOG_2026_05_27_CLAUDE_SLANCHA_EMPTY_FIX.md)** — engineering log: the empties fix, the cost-incident diagnoses, the convergence A/B → 100%.

## Development

```bash
git clone https://github.com/SlanchaAi/slancha-dogfood
cd slancha-dogfood
uv venv && source .venv/bin/activate
uv pip install -e ".[dev,ccshim]"
pytest -q                              # 73 tests, all green
uv run ruff check                      # lint
```

## What this is *not*

This repo is **consumption-side tooling for Slancha**. It is not the Slancha product itself (that's `slancha-api`), not an agent framework, and not a hosted service. Non-Claude-Code clients (Cursor, Aider, …) are out of scope for now.

## License

See `LICENSE` (or contact the maintainer — Slancha is currently private-source).
