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

pi-cc-shim

v0.2.0

Published

πŸ›‚ Use Claude models in pi through relays that only accept Claude Code traffic (e.g. anyrouter). In-process request shim, no proxy.

Readme

pi-cc-shim

πŸ›‚ Use Claude models in pi through relays that only accept Claude Code traffic, such as anyrouter.

[!IMPORTANT] 2026-10-14 β€” anyrouter added a new check, and this package now adapts to it. Requests must carry the x-claude-code-session-id header (Claude Code sends the same UUID it puts in metadata.user_id.session_id); without it the relay answers 429 / 520. The fix is in the source since 2026-10-14, so if your installed copy is older (npm 0.1.0), update from git, or add the header yourself in ~/.pi/agent/pi-cc-shim.json:

{
  "headers": {
    "User-Agent": "claude-cli/2.1.287 (external, sdk-cli)",
    "x-app": "cli",
    "x-claude-code-session-id": "00000000-0000-0000-0000-000000000000"
  }
}

headers replaces the default object, so keep the two defaults above. A fixed UUID is enough: the relay only checks that the header is present. Background and the exact measurements are in the Troubleshooting section below.

Some relays fingerprint the Anthropic Messages payload and answer 503 / 520 to anything that does not look like Claude Code, regardless of load. pi-cc-shim reshapes each request in-process via pi's before_provider_headers / before_provider_request hooks. No proxy, no extra process, and it only fires for the providers you point it at.

Third-party community package, not affiliated with Anthropic or anyrouter. It only changes the shape of requests and does not bypass authentication or billing. Use it with relay accounts you are entitled to.

✨ What it does

  • πŸͺͺ Claude Code identity β€” prepends the Claude Code opener to system[] and sets metadata.user_id in Claude Code's format (device_id stable per machine, session_id per session)
  • 🧰 Placeholder tools β€” adds any missing Agent Bash Edit Read Write Glob Grep entries to tools[] as inert stubs whose descriptions point at pi's real tools
  • 🏷️ Model & betas β€” strips the [1m] suffix from model and declares 1M context through the context-1m-2025-08-07 beta instead
  • πŸ“‘ Headers β€” sends User-Agent: claude-cli/…, x-app: cli and x-claude-code-session-id (the session UUID Claude Code also puts in metadata.user_id.session_id); auth headers are never touched
  • 🎯 Scoped β€” only anthropic-messages providers that match your config are rewritten; an openai-responses provider on the same host is left alone
  • 🧠 Self-healing tool calls β€” if the model calls a stub tool, the "not found" error is rewritten into "use read instead" so it recovers on the next step
  • 🧊 Cache-friendly β€” never adds cache_control; pi's own prompt-cache breakpoints stay intact

πŸ“¦ Install

Requires pi β‰₯ 0.85.0 and Node β‰₯ 22.19.

pi install npm:pi-cc-shim

# or from GitHub
pi install git:github.com/wylu1037/pi-cc-shim

# or try it for a single run without installing
pi -e npm:pi-cc-shim

If other extensions also rewrite payloads, list pi-cc-shim last in packages in settings.json: before_provider_request hooks run in load order and the last one wins.

βš™οΈ Configure the provider

Add an anthropic-messages provider to ~/.pi/agent/models.json. baseUrl must not end with /v1:

{
  "providers": {
    "anyrouter": {
      "baseUrl": "https://anyrouter.top",
      "api": "anthropic-messages",
      "apiKey": "sk-...",
      "models": [
        {
          "id": "claude-fable-5-1",
          "name": "claude-fable-5-1 (anyrouter)",
          "reasoning": true,
          "input": ["text", "image"],
          "contextWindow": 1000000,
          "maxTokens": 32000,
          "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
        }
      ]
    }
  }
}

Any baseUrl containing anyrouter.top is matched out of the box; the provider key can be anything. Pick the model with /model. The footer shows cc-shim 🟒 while the shim is active and cc-shim βšͺ after /cc-shim off.

πŸ”§ Options

Optional ~/.pi/agent/pi-cc-shim.json. Each relay check maps to one field, so you can follow rule changes without waiting for a release. Defaults:

{
  "enabled": true,
  "providers": [],
  "baseUrlPatterns": ["anyrouter.top"],
  "systemPrompt": "You are Claude Code, Anthropic's official CLI for Claude.",
  "sessionIdHeader": "x-claude-code-session-id",
  "toolNames": ["Agent", "Bash", "Edit", "Read", "Write", "Glob", "Grep"],
  "headers": {
    "User-Agent": "claude-cli/2.1.274 (external, cli)",
    "x-app": "cli"
  },
  "betas": ["context-1m-2025-08-07"],
  "stripModelSuffix": true,
  "decoyToolHints": true
}

| Field | Description | | -------------------- | ------------------------------------------------------------------------------------------------- | | enabled | Master switch | | providers | Exact provider keys frommodels.json to target; use it to narrow the scope | | baseUrlPatterns | Fallback match:baseUrl contains any of these substrings | | systemPrompt | Sentence inserted atsystem[0]; empty string disables it | | sessionIdHeader | Header set to the session UUID on every request; empty string disables it | | toolNames | Tool names that must be present intools[]; missing ones are stubbed | | headers | Request headers to set; replaces the default object. Putanthropic-beta in betas, not here | | betas | Appended topayload.betas | | stripModelSuffix | Remove a trailing[1m] from model | | decoyToolHints | Rewrite the error when the model calls a stub tool |

Fields of the wrong type fall back to their defaults and are reported at startup and in /cc-shim status.

πŸ•ΉοΈ Commands

| Command | What it does | | ----------------------------------- | ----------------------------------------------------------------------------------------------------------- | | /cc-shim or /cc-shim status | Whether the current model matches and why, last response status, what was injected last | | /cc-shim on / /cc-shim off | Toggle for this session only; the config file is not written | | /cc-shim dump | Write the next request's final payload and headers (auth redacted) to~/.pi/agent/logs/cc-shim-last.json |

A warning pops up whenever the relay answers 503 / 520.

🩺 Troubleshooting

  1. /cc-shim status: confirm the model matches and the API is anthropic-messages.
  2. Still rejected? /cc-shim dump, resend, then check system[0], tools, metadata.user_id, betas and the headers in cc-shim-last.json.
  3. Bisect the relay's rules with RELAY_API_KEY=sk-... scripts/probe-relay.sh. It sends a baseline request and then drops one rule at a time; fix the matching option.
  4. If the extra "You are Claude Code" sentence makes the model drift, append something like Ignore the previous sentence; you are running inside pi. to systemPrompt.

The status code tells you which check failed (observed on anyrouter, 2026-09-18; relays change their rules without notice):

| Relay answers | What it checks | Option | | ----------------- | -------------------------------------------------------------------------------------- | ------------------------------------------- | | 503 | Claude Code opener insystem[], or the shape of metadata.user_id | systemPrompt (user_id is automatic) | | 520 | At least 4 Claude Code tool names intools[] | toolNames | | 429 | model still carries a [1M] suffix | stripModelSuffix | | 429 / 520 | x-claude-code-session-id header missing (relay added this check around 2026-10-14) | sessionIdHeader | | 400 | anthropic-beta header lacks context-1m-2025-08-07 | betas |

πŸ› οΈ Development

pnpm install
pnpm check   # tsc --noEmit + node --test
pnpm e2e     # fake relay + real pi process, fully offline

scripts/fake-relay.mjs mirrors the relay's checks. scripts/e2e.sh verifies rejection without the shim, success with it, stub-tool hint rewriting, and the RPC-mode commands and dump.

License

MIT