claude-code-model-switch 1.0.1 → 1.0.2
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.
- package/README.md +5 -0
- package/README_CN.md +5 -0
- package/index.js +53 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ A CLI tool for switching between different AI models in Claude Code.
|
|
|
9
9
|
- Automatic handling of model-related environment variables
|
|
10
10
|
- Simple command-line interface
|
|
11
11
|
- Secure configuration management - only modifies model-related settings
|
|
12
|
+
- Reset to official models with unset command
|
|
12
13
|
|
|
13
14
|
## 📦 Installation
|
|
14
15
|
|
|
@@ -32,6 +33,9 @@ ccms list
|
|
|
32
33
|
|
|
33
34
|
# Show configuration file paths
|
|
34
35
|
ccms config-path
|
|
36
|
+
|
|
37
|
+
# Remove all model-related configuration and use official models
|
|
38
|
+
ccms unset
|
|
35
39
|
```
|
|
36
40
|
|
|
37
41
|
### Model Configuration
|
|
@@ -88,6 +92,7 @@ Edit the configuration file `~/.claude-code-model-switch/settings.json`:
|
|
|
88
92
|
- `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` defaults to `1`
|
|
89
93
|
- Unset model fields automatically use the value of `ANTHROPIC_MODEL`
|
|
90
94
|
3. **Configuration File**: Empty configuration file `{"models": {}}` is automatically created on first run
|
|
95
|
+
4. **Unset Command**: The `ccms unset` command removes only model-specific variables while preserving `CLAUDE_CODE_MAX_OUTPUT_TOKENS` and `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`
|
|
91
96
|
|
|
92
97
|
## 📁 File Locations
|
|
93
98
|
|
package/README_CN.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
- 自动处理模型相关环境变量
|
|
10
10
|
- 命令行界面,操作简单
|
|
11
11
|
- 安全的配置管理,只修改模型相关设置
|
|
12
|
+
- 使用 unset 命令重置为官方模型
|
|
12
13
|
|
|
13
14
|
## 📦 安装
|
|
14
15
|
|
|
@@ -32,6 +33,9 @@ ccms list
|
|
|
32
33
|
|
|
33
34
|
# 查看配置文件路径
|
|
34
35
|
ccms config-path
|
|
36
|
+
|
|
37
|
+
# 清除所有模型相关配置,恢复使用官方模型
|
|
38
|
+
ccms unset
|
|
35
39
|
```
|
|
36
40
|
|
|
37
41
|
### 配置模型
|
|
@@ -88,6 +92,7 @@ ccms config-path
|
|
|
88
92
|
- `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` 默认为 `1`
|
|
89
93
|
- 未设置的模型字段会自动使用 `ANTHROPIC_MODEL` 的值
|
|
90
94
|
3. **配置文件**:首次运行时会自动创建空的配置文件 `{"models": {}}`
|
|
95
|
+
4. **Unset 命令**:`ccms unset` 命令只删除模型特定的变量,同时保留 `CLAUDE_CODE_MAX_OUTPUT_TOKENS` 和 `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`
|
|
91
96
|
|
|
92
97
|
## 📁 文件位置
|
|
93
98
|
|
package/index.js
CHANGED
|
@@ -73,6 +73,7 @@ function getModelConfig(modelName) {
|
|
|
73
73
|
if (!config.models || !config.models[modelName]) {
|
|
74
74
|
console.error(`Error: Model "${modelName}" not found`);
|
|
75
75
|
console.log('Available models:', Object.keys(config.models || {}).join(', ') || 'None');
|
|
76
|
+
console.log('Run "ccms --help" to see available commands');
|
|
76
77
|
process.exit(1);
|
|
77
78
|
}
|
|
78
79
|
|
|
@@ -81,6 +82,7 @@ function getModelConfig(modelName) {
|
|
|
81
82
|
// Check if model configuration is empty
|
|
82
83
|
if (Object.keys(modelConfig).length === 0) {
|
|
83
84
|
console.error(`Error: Model "${modelName}" configuration is empty`);
|
|
85
|
+
console.log('Run "ccms --help" to see available commands');
|
|
84
86
|
process.exit(1);
|
|
85
87
|
}
|
|
86
88
|
|
|
@@ -184,7 +186,7 @@ function isValidModel(modelName) {
|
|
|
184
186
|
program
|
|
185
187
|
.name('ccms')
|
|
186
188
|
.description('Claude Code Model Switch - Switch Claude Code models')
|
|
187
|
-
.version('1.0.
|
|
189
|
+
.version('1.0.2')
|
|
188
190
|
.argument('[model]', 'Model name to switch to')
|
|
189
191
|
.action((model) => {
|
|
190
192
|
if (model) {
|
|
@@ -206,6 +208,7 @@ program
|
|
|
206
208
|
config.models[name] && Object.keys(config.models[name]).length > 0
|
|
207
209
|
);
|
|
208
210
|
console.log('Available models:', validModels.join(', ') || 'None');
|
|
211
|
+
console.log('Run "ccms --help" to see available commands');
|
|
209
212
|
process.exit(1);
|
|
210
213
|
}
|
|
211
214
|
} else {
|
|
@@ -229,12 +232,60 @@ program
|
|
|
229
232
|
listModels();
|
|
230
233
|
});
|
|
231
234
|
|
|
235
|
+
// Unset all model-related configuration
|
|
236
|
+
function unsetModelConfig() {
|
|
237
|
+
const settings = loadClaudeSettings();
|
|
238
|
+
|
|
239
|
+
// Ensure env object exists
|
|
240
|
+
if (!settings.env) {
|
|
241
|
+
settings.env = {};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Model-related environment variables to remove (excluding some settings)
|
|
245
|
+
const modelEnvVars = [
|
|
246
|
+
'ANTHROPIC_AUTH_TOKEN',
|
|
247
|
+
'ANTHROPIC_BASE_URL',
|
|
248
|
+
'ANTHROPIC_MODEL',
|
|
249
|
+
'ANTHROPIC_SMALL_FAST_MODEL',
|
|
250
|
+
'ANTHROPIC_DEFAULT_SONNET_MODEL',
|
|
251
|
+
'ANTHROPIC_DEFAULT_OPUS_MODEL'
|
|
252
|
+
];
|
|
253
|
+
|
|
254
|
+
let removedCount = 0;
|
|
255
|
+
const removedVars = [];
|
|
256
|
+
|
|
257
|
+
// Remove only existing model-related environment variables
|
|
258
|
+
for (const key of modelEnvVars) {
|
|
259
|
+
if (settings.env.hasOwnProperty(key)) {
|
|
260
|
+
delete settings.env[key];
|
|
261
|
+
removedCount++;
|
|
262
|
+
removedVars.push(key);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
saveClaudeSettings(settings);
|
|
267
|
+
|
|
268
|
+
if (removedCount > 0) {
|
|
269
|
+
console.log(`Removed ${removedCount} model-related configurations: ${removedVars.join(', ')}`);
|
|
270
|
+
console.log('Restored to use claude official models');
|
|
271
|
+
} else {
|
|
272
|
+
console.log('No model-related configurations found to remove');
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
232
276
|
program
|
|
233
277
|
.command('config-path')
|
|
234
278
|
.description('Display configuration file paths')
|
|
235
279
|
.action(() => {
|
|
236
280
|
console.log('Model configuration file path:', MODEL_CONFIG_PATH);
|
|
237
|
-
console.log('Claude settings file path:', CLAUDE_SETTINGS_PATH);
|
|
281
|
+
console.log('Claude Code settings file path:', CLAUDE_SETTINGS_PATH);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
program
|
|
285
|
+
.command('unset')
|
|
286
|
+
.description('Remove all model-related configuration and use official models')
|
|
287
|
+
.action(() => {
|
|
288
|
+
unsetModelConfig();
|
|
238
289
|
});
|
|
239
290
|
|
|
240
291
|
program.parse();
|