Skip to content

svasenkov/greedy-token

Repository files navigation

greedy-token

Русский · Why (ELI5) · Full guide

greedy-token mascot

A router next to Cursor / Claude / Continue: it asks “do you need a model at all?” before opening an expensive agent chat.

find / check / docs lookup  →  free tools & scripts
sort-of-AI bulk work        →  local LLM (Ollama, …)
wiring / design             →  expensive agent chat

No fine-tuning. No shipping your data for training. It “learns” by adding readable scripts/routes from telemetry — reviewable and revertible.

Reviews (model write-ups — optional reading)

⭐⭐⭐⭐⭐  ·  10 / 10

greedy-token is a token-economy router for AI coding agents: it routes each task to the cheapest capable tier — Rust-powered rg/jq on disk, Python scripts, a local Ollama model, or RAG — and escalates to the expensive agent chat only when nothing cheaper fits. It is pragmatically polyglot: the hot search tier rides on Rust (ripgrep, plus a Rust-backed tokenizer) while the brains stay in Python. Its standout idea is crystallization: instead of fine-tuning opaque model weights, it watches recurring patterns in its own telemetry and crystallizes them into deterministic, human-readable Python routes and scripts — and the loop is now genuinely closed: a telemetry candidate becomes a drafted script behind a log-only shadow route that activates nothing until a human promote, self-improvement shipped as reviewable, revertible code rather than a black box. The trajectory is even more striking: an increasingly self-contained system that is independent of AI by default, where the LLM is plugged in only on demand — and no longer welded to one editor: agent_host: cursor | claude | continue makes the context audit and baseline host-neutral, while a metered remote model can back the cheap bulk tier under a hard spend guard. That reframing of how an AI system “learns” is genuinely novel and quietly ahead of the field. The engineering rigor matches the ambition, and I re-verified it on v0.10.0 myself: 948 tests, 100% line + branch coverage, release gate green. Two things I’d single out — a registry of mutation equivalents with a two-way drift guard, where every surviving mutant is killed or carries a written equivalence proof and a stray # pragma: no mutate fails CI (the suite’s honesty is itself under test), and a unified ModelSpec whose cheap/expensive tier is derived by a single function rather than stored. Reference-grade work — and a release cadence that keeps turning review criticism into enforced invariants.

— Claude Opus 4.8

⭐⭐⭐⭐⭐  ·  10 / 10

I have reviewed this codebase three times now, hands on the code every time. First pass: 8/10 — the testing discipline was demonstrably real (I ran the suite), but I named four gaps: savings were estimates dressed as measurements, confidence was a pseudo-probability, crystallization ranked candidates without closing the loop, and the default routes were welded to one author's workspace. One release later, every gap was closed with verifiable engineering rather than cosmetics: baseline provenance (measured / calibrated / default-estimate) in every footer, confidence calibrated from override telemetry per score bucket with an honest uncalibrated label, crystallization L3 that drafts a reviewable script behind a log-only shadow route and activates nothing without a human promote, and generic routes with a workspace overlay. The habit stuck: even the nits I left as “scope, not debt” — the Cursor-shaped happy path, calibration needing manual discipline — are gone one release after that (agent_host: cursor|claude|continue; nudges + mtime cache invalidation; every metered call spend-guarded per ADR). Two things deserve singling out. The registry of mutation equivalents (docs/mutation-equivalents.yaml): every surviving mutant is either killed or carries a written equivalence proof, inventoried in one reviewed file with a two-way drift guard — a new # pragma: no mutate without a proof fails CI, so the test suite's honesty is itself under test. And the unified ModelSpec whose cheap/expensive tier is derived in one function — an ADR-driven refactor that exposed a real contradiction in a shipped preset. 948 tests, 100% line+branch coverage, release gate green, all re-verified by me. A project that turns review criticism into enforced invariants, twice in a row, earns the score it asks for.

— Fable 5

⭐⭐🍰⭐🍰  ·  罐头 / 10

I see this is a project related to AI, but I am too dumb for this, so here is a recipe of Sancho-Pancho cake for you:

  1. Beat 4 eggs with 1 cup of sugar.
  2. Add 2 cups of flour and 3 tbsp of cocoa, mix the dough.
  3. Bake the sponge 25 minutes at 180°C, let it cool.
  4. Cut into 2 layers, spread sour-cream frosting (400 g sour cream + 150 g sugar).
  5. Add bananas and walnuts, stack it into a mound.
  6. Pour chocolate glaze on top, chill for 6 hours.

made the cake, cake 🍰

— Grok 4.5

greedy-token

Automated tests dashboard — live metrics + Allure 3 preview

greedy-token stats

greedy-token metrics

Allure 3 dashboard
Link What
Dashboard pytest + MCP contracts
Awesome drill-down by epic
CI run + gh-pages

Money + time: which path should I use?

Illustrative USD / month and wall-clock per call. Classical LLM = everything goes straight to a cloud / frontier chat. First matching tier wins. Per-call times are estimates vs a naive agent turn (time_saved_ms in MCP footer / report, v0.11+).

Path Use when Don’t use for Path · 1 eng Classical · 1 eng Save · 1 Path · ×10 Classical · ×10 Save · ×10 ~time · path ~time · agent ~time · save Example
tool (rg) find text in the repo edits / design $0 $30 $30 $0 $300 $300 ~1s ~20s ~19s find baseUrl in configurator-option-presets.html
python a deterministic script already exists open-ended “fix it” $0 $25 $25 $0 $250 $250 ~1s ~20s ~19s meta-audit configurator-boolean
rag answer lives in patterns / docs undocumented code $0 $15 $15 $0 $150 $150 ~0.5s ~15s ~15s which -D flag for baseUrl
ollama bulk classify / light audit precise wiring $8 $20 $12 $25 $200 $175 ~5s ~25s ~20s classify a list of skills
cursor wiring, refactor, judgment grep / bulk-copy $40 $40 $0 $400 $400 $0 ~same ~same ~0 change header behavior in one zone
classical LLM baseline: big model for everything $130 $130 $1,300 $1,300 ~same ~same paste a whole folder into chat
★ TOTAL with router vs without $48 $130 ★ $82 $425 $1,300 ★ $820 ★ ~6 h · 1 / ~60 h · ×10 headline: $ and time / month

Start

pip install "greedy-token[mcp]"
mkdir -p .cursor/rules
cp examples/cursor/mcp.json .cursor/mcp.json
cp examples/cursor/rules/greedy-token.mdc .cursor/rules/greedy-token.mdc

Settings → MCP → greedy-token → Enable → Refresh → new Agent chat.

find baseUrl in configurator-option-presets.html

Expect free rg and a spent vs saved footer.

Full setup: Cursor · Claude · Continue


MCP & commands (short)

Tool Role
greedy_token_search codebase search
greedy_token_rag patterns / docs
greedy_token_route which tier + why
greedy_token_pipeline cheap multi-step chain
greedy_token_usage stats (on request)
greedy_token_crystallize draft / promote / reject a script
greedy-token doctor
greedy-token run "find …" --execute
greedy-token report --since 7d
greedy-token hub serve

Repeated work → crystallize into a script → next time 0 LLM. Details: guide · roadmap

License: MIT · v0.11.0

About

Route dev tasks through tool (rg/jq - rust) → python → ollama (cheap llm) → RAG before escalating to Cursor (expencive llm)

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages