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

@botiverse/cc-switch

v0.1.1

Published

Native Node.js bindings for CC Switch provider management

Readme

@botiverse/cc-switch

Native Node.js bindings for the provider-management core of CC Switch CLI, built with napi-rs.

The source repository is private while the API is being stabilized. Release automation is configured to publish the package from GitHub Releases; no npm package is published merely by pushing a commit.

Supported applications

  • Claude Code
  • Codex
  • Gemini
  • OpenCode
  • Hermes
  • OpenClaw

API

import { CcSwitch } from '@botiverse/cc-switch'

const ccSwitch = new CcSwitch()

ccSwitch.supportedApps()
ccSwitch.listProviders('claude')
ccSwitch.currentProvider('claude')
ccSwitch.addProvider('claude', provider)
ccSwitch.updateProvider('claude', provider)
ccSwitch.duplicateProvider('claude', 'provider-id')
ccSwitch.switchProvider('claude', 'provider-id')
ccSwitch.deleteProvider('claude', 'provider-id')
ccSwitch.importLiveConfig('opencode')
ccSwitch.removeFromLiveConfig('opencode', 'provider-id')
ccSwitch.setDefaultProvider('openclaw', 'provider-id', 'model-id')
ccSwitch.readLiveSettings('codex')
ccSwitch.syncCurrentToLive()
ccSwitch.close()

currentProvider() is meaningful for Claude, Codex, Gemini, and Hermes. The additive OpenCode and OpenClaw stores intentionally return null; use their live settings/default-model operations for active configuration.

Provider values use the JSON shape supported by the pinned CC Switch revision:

type Provider = {
  id: string
  name: string
  settingsConfig: unknown
  websiteUrl?: string
  category?: string
  createdAt?: number
  sortIndex?: number
  notes?: string
  meta?: ProviderMeta
  icon?: string
  iconColor?: string
  inFailoverQueue?: boolean
}

Unknown provider or metadata fields are ignored by the pinned upstream deserializer. Update the vendored revision and these declarations together before relying on newly added upstream fields.

Storage and safety

CC Switch stores state in ~/.cc-switch by default. Set CC_SWITCH_CONFIG_DIR before creating CcSwitch to isolate its database. Live application paths follow the upstream variables, including CLAUDE_CONFIG_DIR and CODEX_HOME.

Those paths are resolved from process-global environment and settings. To prevent stale in-memory snapshots from overwriting each other, the binding allows only one active CcSwitch instance per process. Reuse it for all operations, and call close() when finished to release the native store and allow a new instance. Closing is required before synchronously deleting the store on Windows; garbage collection also releases an unclosed instance eventually. Do not change path-related environment variables while an instance is active. External processes must also avoid writing the same store while the instance is active; the in-memory upstream state is refreshed only at construction. The same caution applies to external writers of live app configuration files while switch/sync operations are running.

Provider switching writes the selected application's live configuration when that application is already initialized (for example, when its config directory exists). This preserves upstream's safe default of not creating new application config files unexpectedly. syncCurrentToLive() is the explicit force-sync operation. Use an isolated HOME/config environment in tests. The constructor opens CC Switch storage but does not import live configuration implicitly.

All bindings are synchronous because they preserve the upstream service API. Calls can perform SQLite and filesystem I/O (and a switch may coordinate a running proxy), so invoke them from a Node worker thread when event-loop latency matters.

Browser and WASI builds are not supported by this native, filesystem-backed binding.

Release artifacts cover macOS arm64/x64, Windows x64, and Linux arm64/x64 glibc plus Linux x64 musl.

Publishing

The release workflow follows the napi-rs package-template flow: each supported target is built independently, the native artifacts are assembled into scoped platform packages, napi prepublish publishes those packages, and npm then publishes @botiverse/cc-switch with matching optional dependencies.

Publishing only runs for a published GitHub Release whose tag is exactly v<package.json version>. The repository must provide an npm automation token as the NPM_TOKEN Actions secret; npm provenance is enabled for the workflow. Normal pushes and pull requests build and test artifacts but never publish.

Development

corepack yarn install
corepack yarn build:debug
corepack yarn test
cargo fmt --check
cargo clippy --all-targets -- -D warnings

The upstream Rust crate is vendored at vendor/cc-switch-cli and pinned in vendor/cc-switch-cli/UPSTREAM.md.

License

MIT. The vendored CC Switch source remains under its upstream MIT notice in vendor/cc-switch-cli/LICENSE.