@william-zxs/ccenv
v1.2.2
Published
便捷的命令行工具,用于在不同的 Claude API 配置之间快速切换 | A convenient CLI tool for quickly switching between different Claude API configurations
Maintainers
Readme
ccenv
A convenient command-line tool for quickly switching between different Claude API configurations.
Features
- 🔄 Interactive configuration selection menu
- ⭐ Current active configuration marked with
* - 🎯 Cursor defaults to the currently active configuration
- 🔧 Automatic environment variable management (unset old config, set new config)
- 🚀 Auto-launch
claudecommand after switching - ⚙️ Support for direct configuration name specification for quick switching
- 🌍 Internationalization support (English/中文)
- 🔍 Smart language detection based on system locale
- 📦 npm global installation support, cross-platform compatibility
Installation
Method 1: Install via npm (Recommended)
npm install -g @william-zxs/ccenvMethod 2: Local Development Installation
- Clone or download this project
- Run in the project directory:
npm install -g .
npm installation will automatically:
- Create configuration directory
~/.ccenv/ - Generate default configuration file
~/.ccenv/settings.json - Install
ccenvcommand to global PATH
Usage
Step 1: Configure API Keys (Required)
After installation, you need to configure your API keys first:
ccenv editThis will open the configuration file in an editor. Fill in your API keys for each provider:
- kimi: Get your API key from Moonshot AI
- glm: Get your API key from Zhipu AI
- qwen: Get your API key from Alibaba Cloud
- deepseek: Get your API key from DeepSeek
Replace the empty ANTHROPIC_AUTH_TOKEN values with your actual API keys.
Step 2: Switch Configurations
Interactive Selection
ccenvThis will display the configuration menu with color-coded token status:
- 🟢 Green checkmark: API key configured
- 🔴 Red X: API key missing
Direct Switching
ccenv kimi # Switch to Moonshot AI (Kimi)
ccenv glm # Switch to Zhipu AI (GLM)
ccenv qwen # Switch to Alibaba Qianwen
ccenv deepseek # Switch to DeepSeekList All Configurations
ccenv lsShows all available configurations with their status.
Language Settings
ccenv lang # Show current interface language
ccenv lang zh # Set interface to Chinese
ccenv lang en # Set interface to English
ccenv --lang en ls # Temporarily use English for one commandccenv supports internationalization with:
- Automatic language detection based on system locale
- Persistent language settings saved to configuration file
- Temporary language override using
--langparameter - Supported languages: English (
en), Chinese (zh)
Configuration File
The configuration file is located at ~/.ccenv/settings.json with the following format:
{
"defaultProfile": null,
"profiles": [
{
"name": "kimi",
"env": {
"ANTHROPIC_BASE_URL": "https://api.moonshot.cn/anthropic",
"ANTHROPIC_AUTH_TOKEN": "sk-your-moonshot-api-key",
"ANTHROPIC_MODEL": "kimi-k2-turbo-preview",
"ANTHROPIC_SMALL_FAST_MODEL": "kimi-k2-turbo-preview"
}
},
{
"name": "glm",
"env": {
"ANTHROPIC_BASE_URL": "https://open.bigmodel.cn/api/anthropic",
"ANTHROPIC_AUTH_TOKEN": "your-zhipu-api-key.xxx"
}
},
{
"name": "qwen",
"env": {
"ANTHROPIC_BASE_URL": "https://dashscope.aliyuncs.com/api/v2/apps/claude-code-proxy",
"ANTHROPIC_AUTH_TOKEN": "sk-your-alibaba-api-key"
}
},
{
"name": "deepseek",
"env": {
"ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
"ANTHROPIC_AUTH_TOKEN": "sk-your-deepseek-api-key",
"ANTHROPIC_MODEL": "deepseek-chat",
"ANTHROPIC_SMALL_FAST_MODEL": "deepseek-chat"
}
}
]
}Supported Environment Variables
ANTHROPIC_BASE_URL- API base URLANTHROPIC_AUTH_TOKEN- Authentication tokenANTHROPIC_MODEL- Default modelANTHROPIC_SMALL_FAST_MODEL- Small fast model
Built-in Configurations
The following API configurations are included by default:
- kimi - Moonshot AI (月之暗面)
- glm - Zhipu AI (智谱AI)
- qwen - Alibaba Tongyi Qianwen (阿里通义千问)
- deepseek - DeepSeek AI (深度求索)
How It Works
- Read the
~/.ccenv/settings.jsonconfiguration file - Detect the currently active configuration (via
CCENV_PROFILEenvironment variable) - Display interactive menu with current configuration marked and token status color-coded
- After user selects a new configuration:
- Clear existing related environment variables
- Set new configuration environment variables
- Set
CCENV_PROFILEto track active configuration
Development and Local Testing
If you want to develop or test locally:
# Clone project
git clone <repository-url>
cd ccenv
# Install dependencies
npm install
# Local testing
node src/cli.js
# Or link to global
npm link
ccenvImportant Notes
- Environment variables are scoped to the current shell session only
- Ensure
claudecommand is properly installed - Node.js version requirement: >= 14.0.0
Custom Configuration
You can edit the ~/.ccenv/settings.json file to add or modify configurations. Modified configurations take effect immediately without reinstallation.
Publishing to npm
To publish a new version to npm:
# Update version number
npm version patch # or minor, major
# Publish
npm publish