claude-code-model-switch 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +121 -0
  3. package/README_CN.md +121 -0
  4. package/package.json +8 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Claude Code Model Switch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # Claude Code Model Switch (CCMS)
2
+
3
+ A CLI tool for switching between different AI models in Claude Code.
4
+
5
+ ## 🚀 Features
6
+
7
+ - Quickly switch AI models used by Claude Code
8
+ - Support for multiple pre-configured model environments
9
+ - Automatic handling of model-related environment variables
10
+ - Simple command-line interface
11
+ - Secure configuration management - only modifies model-related settings
12
+
13
+ ## 📦 Installation
14
+
15
+ ```bash
16
+ npm install -g claude-code-model-switch
17
+ ```
18
+
19
+ ## 🛠️ Usage
20
+
21
+ ### Basic Commands
22
+
23
+ ```bash
24
+ # Switch to specified model
25
+ ccms deepseek-chat
26
+
27
+ # Or use switch subcommand
28
+ ccms switch deepseek-chat
29
+
30
+ # List all available models
31
+ ccms list
32
+
33
+ # Show configuration file paths
34
+ ccms config-path
35
+ ```
36
+
37
+ ### Model Configuration
38
+
39
+ Edit the configuration file `~/.claude-code-model-switch/settings.json`:
40
+
41
+ ```json
42
+ {
43
+ "models": {
44
+ "deepseek-chat": {
45
+ "ANTHROPIC_AUTH_TOKEN": "sk-your-token-here",
46
+ "ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
47
+ "ANTHROPIC_MODEL": "deepseek-chat",
48
+ "ANTHROPIC_SMALL_FAST_MODEL": "deepseek-chat",
49
+ "ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-chat",
50
+ "ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-chat",
51
+ "CLAUDE_CODE_MAX_OUTPUT_TOKENS": "8192",
52
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
53
+ },
54
+ "claude-3-5-sonnet": {
55
+ "ANTHROPIC_AUTH_TOKEN": "your-anthropic-token-here",
56
+ "ANTHROPIC_BASE_URL": "https://api.anthropic.com",
57
+ "ANTHROPIC_MODEL": "claude-3-5-sonnet-20241022",
58
+ "ANTHROPIC_SMALL_FAST_MODEL": "claude-3-haiku-20240307",
59
+ "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-3-5-sonnet-20241022",
60
+ "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-3-opus-20240229",
61
+ "CLAUDE_CODE_MAX_OUTPUT_TOKENS": "8192",
62
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "0"
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ ## ⚙️ Configuration
69
+
70
+ ### Environment Variables
71
+
72
+ | Variable | Required | Default | Description |
73
+ |----------|----------|---------|-------------|
74
+ | `ANTHROPIC_AUTH_TOKEN` | ✅ | - | API authentication token |
75
+ | `ANTHROPIC_BASE_URL` | ✅ | - | API base URL |
76
+ | `ANTHROPIC_MODEL` | ✅ | - | Main model name |
77
+ | `ANTHROPIC_SMALL_FAST_MODEL` | ❌ | Same as `ANTHROPIC_MODEL` | Small fast model |
78
+ | `ANTHROPIC_DEFAULT_SONNET_MODEL` | ❌ | Same as `ANTHROPIC_MODEL` | Default Sonnet model |
79
+ | `ANTHROPIC_DEFAULT_OPUS_MODEL` | ❌ | Same as `ANTHROPIC_MODEL` | Default Opus model |
80
+ | `CLAUDE_CODE_MAX_OUTPUT_TOKENS` | ❌ | `8192` | Maximum output tokens |
81
+ | `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | ❌ | `1` | Disable non-essential traffic |
82
+
83
+ ### Special Rules
84
+
85
+ 1. **Secure Configuration**: The tool only modifies model-related environment variables and won't touch other fields in the configuration file
86
+ 2. **Default Values**:
87
+ - `CLAUDE_CODE_MAX_OUTPUT_TOKENS` defaults to `8192`
88
+ - `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` defaults to `1`
89
+ - Unset model fields automatically use the value of `ANTHROPIC_MODEL`
90
+ 3. **Configuration File**: Empty configuration file `{"models": {}}` is automatically created on first run
91
+
92
+ ## 📁 File Locations
93
+
94
+ - Claude settings file: `~/.claude/settings.json`
95
+ - Model configuration file: `~/.claude-code-model-switch/settings.json`
96
+
97
+ ## 🔧 Development
98
+
99
+ ```bash
100
+ # Clone repository
101
+ git clone https://github.com/musnows/claude-code-model-switch.git
102
+ cd claude-code-model-switch
103
+
104
+ # Install dependencies
105
+ npm install
106
+
107
+ # Global link (for development)
108
+ npm link
109
+ ```
110
+
111
+ ## 📄 License
112
+
113
+ MIT License
114
+
115
+ ## 🤝 Contributing
116
+
117
+ Issues and Pull Requests are welcome!
118
+
119
+ ## 🔗 Repository
120
+
121
+ https://github.com/musnows/claude-code-model-switch
package/README_CN.md ADDED
@@ -0,0 +1,121 @@
1
+ # Claude Code Model Switch (CCMS)
2
+
3
+ 一个用于 Claude Code 的模型切换器,可以轻松在不同 AI 模型之间切换。
4
+
5
+ ## 🚀 功能特性
6
+
7
+ - 快速切换 Claude Code 使用的 AI 模型
8
+ - 支持多个预配置模型环境
9
+ - 自动处理模型相关环境变量
10
+ - 命令行界面,操作简单
11
+ - 安全的配置管理,只修改模型相关设置
12
+
13
+ ## 📦 安装
14
+
15
+ ```bash
16
+ npm install -g claude-code-model-switch
17
+ ```
18
+
19
+ ## 🛠️ 使用方法
20
+
21
+ ### 基本命令
22
+
23
+ ```bash
24
+ # 切换到指定模型
25
+ ccms deepseek-chat
26
+
27
+ # 或者使用 switch 子命令
28
+ ccms switch deepseek-chat
29
+
30
+ # 列出所有可用模型
31
+ ccms list
32
+
33
+ # 查看配置文件路径
34
+ ccms config-path
35
+ ```
36
+
37
+ ### 配置模型
38
+
39
+ 编辑配置文件 `~/.claude-code-model-switch/settings.json`:
40
+
41
+ ```json
42
+ {
43
+ "models": {
44
+ "deepseek-chat": {
45
+ "ANTHROPIC_AUTH_TOKEN": "sk-your-token-here",
46
+ "ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
47
+ "ANTHROPIC_MODEL": "deepseek-chat",
48
+ "ANTHROPIC_SMALL_FAST_MODEL": "deepseek-chat",
49
+ "ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-chat",
50
+ "ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-chat",
51
+ "CLAUDE_CODE_MAX_OUTPUT_TOKENS": "8192",
52
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
53
+ },
54
+ "claude-3-5-sonnet": {
55
+ "ANTHROPIC_AUTH_TOKEN": "your-anthropic-token-here",
56
+ "ANTHROPIC_BASE_URL": "https://api.anthropic.com",
57
+ "ANTHROPIC_MODEL": "claude-3-5-sonnet-20241022",
58
+ "ANTHROPIC_SMALL_FAST_MODEL": "claude-3-haiku-20240307",
59
+ "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-3-5-sonnet-20241022",
60
+ "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-3-opus-20240229",
61
+ "CLAUDE_CODE_MAX_OUTPUT_TOKENS": "8192",
62
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "0"
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ ## ⚙️ 配置说明
69
+
70
+ ### 环境变量说明
71
+
72
+ | 变量名 | 必填 | 默认值 | 说明 |
73
+ |--------|------|--------|------|
74
+ | `ANTHROPIC_AUTH_TOKEN` | ✅ | - | API 认证令牌 |
75
+ | `ANTHROPIC_BASE_URL` | ✅ | - | API 基础 URL |
76
+ | `ANTHROPIC_MODEL` | ✅ | - | 主模型名称 |
77
+ | `ANTHROPIC_SMALL_FAST_MODEL` | ❌ | 同 `ANTHROPIC_MODEL` | 小型快速模型 |
78
+ | `ANTHROPIC_DEFAULT_SONNET_MODEL` | ❌ | 同 `ANTHROPIC_MODEL` | 默认 Sonnet 模型 |
79
+ | `ANTHROPIC_DEFAULT_OPUS_MODEL` | ❌ | 同 `ANTHROPIC_MODEL` | 默认 Opus 模型 |
80
+ | `CLAUDE_CODE_MAX_OUTPUT_TOKENS` | ❌ | `8192` | 最大输出令牌数 |
81
+ | `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | ❌ | `1` | 禁用非必要流量 |
82
+
83
+ ### 特殊规则
84
+
85
+ 1. **安全配置**:工具只会修改与模型相关的环境变量,不会触及配置文件中的其他字段
86
+ 2. **默认值处理**:
87
+ - `CLAUDE_CODE_MAX_OUTPUT_TOKENS` 默认为 `8192`
88
+ - `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` 默认为 `1`
89
+ - 未设置的模型字段会自动使用 `ANTHROPIC_MODEL` 的值
90
+ 3. **配置文件**:首次运行时会自动创建空的配置文件 `{"models": {}}`
91
+
92
+ ## 📁 文件位置
93
+
94
+ - Claude 设置文件:`~/.claude/settings.json`
95
+ - 模型配置文件:`~/.claude-code-model-switch/settings.json`
96
+
97
+ ## 🔧 开发
98
+
99
+ ```bash
100
+ # 克隆仓库
101
+ git clone https://github.com/musnows/claude-code-model-switch.git
102
+ cd claude-code-model-switch
103
+
104
+ # 安装依赖
105
+ npm install
106
+
107
+ # 全局链接(开发用)
108
+ npm link
109
+ ```
110
+
111
+ ## 📄 许可证
112
+
113
+ MIT License
114
+
115
+ ## 🤝 贡献
116
+
117
+ 欢迎提交 Issue 和 Pull Request!
118
+
119
+ ## 🔗 开源地址
120
+
121
+ https://github.com/musnows/claude-code-model-switch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-model-switch",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A CLI tool to switch Claude Code models",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -9,10 +9,15 @@
9
9
  "scripts": {
10
10
  "test": "echo \"Error: no test specified\" && exit 1"
11
11
  },
12
- "keywords": ["claude", "code", "model", "switch"],
12
+ "keywords": [
13
+ "claude",
14
+ "code",
15
+ "model",
16
+ "switch"
17
+ ],
13
18
  "author": "",
14
19
  "license": "MIT",
15
20
  "dependencies": {
16
21
  "commander": "^11.1.0"
17
22
  }
18
- }
23
+ }