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

@openprojectx/opencode-kimi-auth

v0.3.0

Published

Kimi Code (subscription) OAuth login for opencode — RFC 8628 device flow for the kimi-for-coding provider (Kimi K3 / K2.7 Code)

Readme

@openprojectx/opencode-kimi-auth

OAuth login for Kimi Code (subscription) in opencode — use Kimi K3 / K2.7 Code via opencode auth login browser sign-in, no manual API key needed.

Why

opencode's built-in kimi-for-coding provider only supports API keys. If you have a Kimi Code membership (subscription), your sign-in is OAuth-based — pasting a Moonshot platform key gets you 401 Unauthorized (see docs/kimi-opencode-troubleshooting.md).

This plugin adds the same OAuth device flow that kimi CLI and pi use:

opencode auth login → Kimi For Coding → Sign in with Kimi Code (subscription)
→ open URL, enter code → done

Install

// opencode.jsonc (project) or ~/.config/opencode/opencode.jsonc (global)
{
  "plugin": ["@openprojectx/opencode-kimi-auth"]
}

Then:

opencode auth login   # → Kimi For Coding → "Sign in with Kimi Code (subscription)"
opencode models       # → kimi-for-coding/k3, kimi-for-coding/kimi-for-coding, …

Models

| Model | Description | Context | |---|---|---| | kimi-for-coding/k3 | Kimi K3 — flagship, reasoning (recommended) | 1M tokens | | kimi-for-coding/k3-256k | Kimi K3, smaller context variant | 256K | | kimi-for-coding/kimi-for-coding | Kimi K2.7 Code | 256K | | kimi-for-coding/kimi-for-coding-highspeed | K2.7 Code, faster/more expensive | 256K |

Select interactively with /models in the TUI, or set a default:

{
  "plugin": ["@openprojectx/opencode-kimi-auth"],
  "model": "kimi-for-coding/k3"
}

How it works

| Step | Detail | |---|---| | Login | RFC 8628 device authorization grant against https://auth.kimi.com (/api/oauth/device_authorization → poll /api/oauth/token). Official public client ID (same as MoonshotAI's kimi-cli). | | Token use | Authorization: Bearer <access_token> against https://api.kimi.com/coding/v1 (Anthropic Messages API). The plugin's custom fetch strips the x-api-key placeholder and injects the Bearer header. | | Refresh | Access tokens live ~15 minutes. The plugin refreshes proactively when <5 min remain, single-flights concurrent refreshes, retries 429/5xx with backoff, and persists rotated tokens back to opencode's auth store. | | Expired refresh token | invalid_grant/401/403 → error tells you to run opencode auth login again. |

API keys still work — the plugin registers both login methods, so opencode auth login → Kimi For Coding shows a menu: "Sign in with Kimi Code (subscription)" or "Manually enter API Key". The KIMI_API_KEY env var also keeps working independently of both.

Configuration

| Env var | Default | Purpose | |---|---|---| | KIMI_CODE_OAUTH_HOST | https://auth.kimi.com | Override OAuth host (also reads KIMI_OAUTH_HOST) | | KIMI_API_KEY | — | Built-in API-key auth (unchanged, no plugin needed) |

Develop

bun install
bun test          # unit tests (device flow, polling, refresh retry logic)
bun run typecheck

Release flow: changesets — bunx changeset to add a changeset; merge to master and the release workflow opens a version PR / publishes to npm (requires NPM_TOKEN secret).

References

License

MIT