claude-code-model-switch 2.2.1 → 2.2.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.
Files changed (2) hide show
  1. package/index.js +40 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -12,6 +12,9 @@ const YOLO_ARGS = ['--dangerously-skip-permissions'];
12
12
 
13
13
  const DEFAULT_MAX_OUTPUT_TOKENS = '8192';
14
14
  const DEFAULT_DISABLE_NONESSENTIAL_TRAFFIC = '1';
15
+ const DEFAULT_ATTRIBUTION_HEADER = '0';
16
+ const DEFAULT_MAX_CONTEXT_TOKENS = '200000';
17
+ const DEFAULT_AUTOCOMPACT_PCT_OVERRIDE = '80';
15
18
 
16
19
  const MODEL_ENV_VARS = [
17
20
  'ANTHROPIC_AUTH_TOKEN',
@@ -22,6 +25,9 @@ const MODEL_ENV_VARS = [
22
25
  'ANTHROPIC_DEFAULT_OPUS_MODEL',
23
26
  'ANTHROPIC_DEFAULT_HAIKU_MODEL',
24
27
  'CLAUDE_CODE_MAX_OUTPUT_TOKENS',
28
+ 'CLAUDE_CODE_MAX_CONTEXT_TOKENS',
29
+ 'CLAUDE_AUTOCOMPACT_PCT_OVERRIDE',
30
+ 'CLAUDE_CODE_ATTRIBUTION_HEADER',
25
31
  'CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC',
26
32
  'CLAUDE_CODE_AUTO_COMPACT_WINDOW',
27
33
  'API_TIMEOUT_MS'
@@ -34,7 +40,14 @@ const UNSET_ENV_VARS = [
34
40
  'ANTHROPIC_SMALL_FAST_MODEL',
35
41
  'ANTHROPIC_DEFAULT_SONNET_MODEL',
36
42
  'ANTHROPIC_DEFAULT_OPUS_MODEL',
37
- 'ANTHROPIC_DEFAULT_HAIKU_MODEL'
43
+ 'ANTHROPIC_DEFAULT_HAIKU_MODEL',
44
+ 'CLAUDE_CODE_MAX_CONTEXT_TOKENS',
45
+ 'CLAUDE_AUTOCOMPACT_PCT_OVERRIDE'
46
+ ];
47
+
48
+ const CONTEXT_ENV_VARS = [
49
+ 'CLAUDE_CODE_MAX_CONTEXT_TOKENS',
50
+ 'CLAUDE_AUTOCOMPACT_PCT_OVERRIDE'
38
51
  ];
39
52
 
40
53
  const DERIVED_MODEL_FIELDS = [
@@ -160,6 +173,10 @@ function mergeModelConfig(modelName) {
160
173
  return { ...shared, ...modelConfig };
161
174
  }
162
175
 
176
+ function hasConfiguredValue(value) {
177
+ return value !== undefined && value !== null && value !== '';
178
+ }
179
+
163
180
  function normalizeModelConfig(modelConfig) {
164
181
  const normalized = { ...modelConfig };
165
182
 
@@ -171,6 +188,19 @@ function normalizeModelConfig(modelConfig) {
171
188
  }
172
189
  }
173
190
 
191
+ normalized.CLAUDE_CODE_ATTRIBUTION_HEADER = DEFAULT_ATTRIBUTION_HEADER;
192
+
193
+ const hasOneMillionContextSuffix = String(normalized.ANTHROPIC_MODEL || '').endsWith('[1m]');
194
+ const hasConfiguredContextTokens = hasConfiguredValue(normalized.CLAUDE_CODE_MAX_CONTEXT_TOKENS);
195
+
196
+ if (!hasOneMillionContextSuffix && !hasConfiguredContextTokens) {
197
+ normalized.CLAUDE_CODE_MAX_CONTEXT_TOKENS = DEFAULT_MAX_CONTEXT_TOKENS;
198
+
199
+ if (!hasConfiguredValue(normalized.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE)) {
200
+ normalized.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE = DEFAULT_AUTOCOMPACT_PCT_OVERRIDE;
201
+ }
202
+ }
203
+
174
204
  return normalized;
175
205
  }
176
206
 
@@ -274,6 +304,12 @@ function applyModelConfig(modelConfig) {
274
304
  settings.env = {};
275
305
  }
276
306
 
307
+ for (const envVar of CONTEXT_ENV_VARS) {
308
+ if (!Object.prototype.hasOwnProperty.call(normalized, envVar)) {
309
+ delete settings.env[envVar];
310
+ }
311
+ }
312
+
277
313
  for (const [key, value] of Object.entries(normalized)) {
278
314
  if (value !== undefined && value !== null) {
279
315
  settings.env[key] = String(value);
@@ -352,6 +388,8 @@ function unsetModelConfig() {
352
388
  settings.env = {};
353
389
  }
354
390
 
391
+ settings.env.CLAUDE_CODE_ATTRIBUTION_HEADER = DEFAULT_ATTRIBUTION_HEADER;
392
+
355
393
  let removedCount = 0;
356
394
  const removedVars = [];
357
395
 
@@ -390,7 +428,7 @@ function listModels() {
390
428
  program
391
429
  .name('ccms')
392
430
  .description('Claude Code Model Switch - Manage and launch Claude Code with configured models')
393
- .version('2.2.0');
431
+ .version('2.2.2');
394
432
 
395
433
  program
396
434
  .command('start <model> [claude-args...]')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-model-switch",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "description": "Launch Claude Code with preconfigured model environments",
5
5
  "main": "index.js",
6
6
  "bin": {