npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

apescode

v0.2.0

Published

Multi-provider AI coding agent for the terminal. 4-40× cheaper than Claude Code via smart routing (Anthropic + Moonshot Kimi + xAI Grok + Google Gemini), with MCP, hooks, sandbox, and REPL with branches.

Downloads

129

Readme

🦍 ApesCode

Multi-provider AI coding agent for your terminal. 4-40× cheaper than Claude Code, with smart routing across 4 providers, MCP, sandbox, and REPL with branches.

npm version license node


Why ApesCode?

💰 Massive economy via smart routing

Empirical measurements on equivalent tasks (2026-04, smoke suite):

| Task type | Sonnet 4.6 | Kimi K2.6 | Gemini Flash | Haiku 4.5 | |---|---|---|---|---| | Simple coding | $0.015 | $0.003 (5×) | — | — | | File edit | $0.010 | $0.002 (5×) | — | — | | Trivial prompt | $0.002 | — | $0.0005 (4×) | $0.0002 (10×) | | Orchestration | $0.030 | — | $0.001 (30×) | — |

Classifier Haiku cost per routing decision: ~$0.00015 (negligible).

Monthly cost: 25-45 €/month vs 80 €/month for Claude Pro, measured empirically on a typical agentic workload.

🔌 4 providers integrated

  • Anthropic — Sonnet 4.6 / Opus 4.7 / Haiku 4.5 (orchestration + baseline)
  • Moonshot — Kimi K2.6 (coding sweet spot)
  • xAI — Grok 4.20 non-reasoning (research / fresh facts)
  • Google — Gemini 2.5 Flash (opt-in, cheapest worker; A/B orchestration)

Each provider is opt-in: set the API key env var, enable in settings.json, and the router starts using it.

🛡️ Defense-in-depth security (4 layers)

  1. Denylist — unified dangerous command patterns (rm -rf /, curl | sh, etc.).
  2. Permission gate — interactive prompt on suspect tool calls; cached per-session.
  3. LLM classifier (auto mode) — Haiku pre-approves safe tool calls silently.
  4. OS sandbox — bubblewrap (Linux) / sandbox-exec (macOS) wraps bash; Windows passthrough.

🌲 REPL with branches

/branch, /fork, /retry (Ctrl+R), /compact — explore multiple approaches without losing history. Sessions persist to SQLite; --resume re-enters any previous session.

✅ Feature parity with Claude Code

MCP, hooks (PreToolUse / PostToolUse / UserPromptSubmit / SessionStart / SessionEnd / Stop), subagents via Task tool, plan mode (readonly with approval), slash commands, web_search, web_fetch.


Install

npm install -g apescode

Requires Node.js ≥ 20. Works on macOS, Linux, and Windows.


Quick start

# Set at least one provider API key (Anthropic is the baseline)
export ANTHROPIC_API_KEY="sk-ant-..."

# Launch interactive REPL
apescode

# One-shot mode (runs once, exits)
apescode "Create a hello.txt file"

# Resume a previous session
apescode --list         # shows recent sessions
apescode --resume <id>  # rehydrates by id

Providers setup

Anthropic (required for baseline)

Provision at console.anthropic.com.

export ANTHROPIC_API_KEY="sk-ant-..."

Moonshot Kimi K2.6 (optional — huge economy on coding)

Provision at platform.moonshot.ai.

export MOONSHOT_API_KEY="sk-..."

Enable in .claude/settings.json:

{
  "routing": {
    "enabled": true,
    "specialists": { "simple-coding": "kimi-k2.6" }
  }
}

xAI Grok 4.20 (optional — research / fresh facts)

Provision at console.x.ai.

export XAI_API_KEY="xai-..."

Google Gemini 2.5 Flash (opt-in experimental — cheapest worker)

Provision at aistudio.google.com (free tier 1M tokens/day).

export GOOGLE_API_KEY="AIza..."

Enable the experimental provider in .claude/settings.json:

{
  "routing": {
    "enabled": true,
    "experimentalProviders": { "google": true }
  }
}

Tavily (optional — AI-optimized WebSearch)

Provision at tavily.com (free tier 1000 searches/month).

export TAVILY_API_KEY="tvly-..."

If TAVILY_API_KEY is not set, web_search falls back silently to DuckDuckGo HTML scraping.


Commands & shortcuts

Slash commands

| Command | Description | |---|---| | /help | list commands | | /compact | compact conversation history to save tokens | | /branch <name> | save the current session state as a branch | | /fork <name> | branch from the current state with auto-backup | | /branches | list saved branches | | /retry | re-run the last user turn (Ctrl+R) | | /new | clear session context (fresh conversation) | | /exit, /quit | graceful shutdown |

Custom slash commands (project-level) can be added via .claude/commands/*.md.

REPL keyboard shortcuts

  • Tab — autocomplete slash commands
  • Ctrl+R — retry last user message
  • Ctrl+C — interrupt streaming / graceful shutdown on idle
  • Shift+Enter or Ctrl+J — newline in multiline input
  • Up / Down — history navigation (session-local)

CLI flags

  • -m, --model <id> — override default model for the turn
  • --provider <id> — force-route everything through one provider (anthropic | moonshot | xai | google)
  • --mode <mode>default | acceptEdits | plan | bypassPermissions
  • --resume <id> — rehydrate a previous session
  • --list — list persisted sessions
  • --yes — auto-approve permission prompts (required for non-TTY runs)
  • --one-shot — force one-shot mode even in a TTY

Configuration

Settings are read from ~/.claude/settings.json (user-level) with per-project overrides at <cwd>/.claude/settings.json. Shallow merge; project wins.

Minimal (baseline, no routing)

{
  "sandbox": { "mode": "permission-prompt" }
}

Recommended routing config (save ~60% on LLM costs)

{
  "routing": {
    "enabled": true,
    "orchestrator": "claude-sonnet-4-6",
    "specialists": {
      "trivial": "claude-haiku-4-5",
      "simple-coding": "kimi-k2.6",
      "research": "grok-4.20-0309-non-reasoning",
      "complex-reasoning": "claude-opus-4-7",
      "agentic": "claude-sonnet-4-6"
    },
    "fallbackChain": {
      "simple-coding": ["kimi-k2.6", "claude-sonnet-4-6", "claude-haiku-4-5"],
      "research": ["grok-4.20-0309-non-reasoning", "claude-sonnet-4-6"]
    },
    "classifierThreshold": 0.7
  }
}

Web tools

{
  "webSearchEnabled": true,
  "webFetchEnabled": true,
  "webSearch": { "fallbackEnabled": true },
  "webFetch": {
    "allowedDomains": ["*.github.io", "docs.python.org", "nodejs.org"],
    "maxBodyBytes": 1000000,
    "maxOutputChars": 10000,
    "timeoutMs": 15000
  }
}

Architecture

┌──────────────────────────────────────────────────────────────┐
│  User input                                                   │
└────────────────────────┬─────────────────────────────────────┘
                         ▼
┌──────────────────────────────────────────────────────────────┐
│  Router (3 layers)                                            │
│  1. Heuristic fast path (trivial, coding, research patterns)  │
│  2. Haiku classifier (ambiguous prompts, LRU cache + cost cap)│
│  3. Sonnet orchestrator (AGENTIC, delegates via Task tool)    │
└────────────────────────┬─────────────────────────────────────┘
                         ▼
┌──────────────────────────────────────────────────────────────┐
│  Provider (Anthropic / Moonshot / xAI / Google)               │
│  + Circuit breaker per-provider                               │
│  + Fallback chain per category                                │
└────────────────────────┬─────────────────────────────────────┘
                         ▼
┌──────────────────────────────────────────────────────────────┐
│  Tool use (bash, read, write, edit, grep, glob, ls,           │
│           web_search, web_fetch, Task, MCP tools)             │
│  + 4-layer sandbox (denylist, permission, classifier, OS)     │
└──────────────────────────────────────────────────────────────┘

Project status

Phase 6 complete — multi-provider routing production-ready, 4 providers empirically validated. Phase 7 in progress — polish + distribution (current).

  • 684 unit tests + 38 smoke scenarios green
  • Monthly cost empirically 2-3× lower than Claude Pro on equivalent workload
  • Works on macOS, Linux, Windows (Windows sandbox-exec is passthrough)

See CHANGELOG.md for the commit-by-commit history.


License

MIT — see LICENSE.


Credits

Inspired by Claude Code by Anthropic. Built as a learning project + to optimize multi-provider costs. AI SDK layer by Vercel AI SDK v5.

Contributions welcome — open an issue at https://github.com/stephencvd/apescode/issues.