@daylenjeez/ccm-switch 1.2.4 → 1.2.6

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 CHANGED
@@ -64,6 +64,8 @@ Active: OpenRouter
64
64
 
65
65
  You can also run `ccm sync` at any time to pull the latest cc-switch configurations into `~/.ccm/config.json`.
66
66
 
67
+ > ⚠️ **Known Issue**: After ccm modifies `~/.claude/settings.json`, cc-switch will automatically sync the content back to its database, overwriting the current provider's `settings_config`. If the configurations differ between the two tools, the original configuration stored in cc-switch will be modified.
68
+
67
69
  ## ➕ Adding Configurations
68
70
 
69
71
  ### Interactive wizard (recommended)
package/README.zh-CN.md CHANGED
@@ -64,6 +64,8 @@ $ ccm init
64
64
 
65
65
  你也可以随时运行 `ccm sync` 将最新的 cc-switch 配置同步到 `~/.ccm/config.json`。
66
66
 
67
+ > ⚠️ **已知问题**:ccm 修改 `~/.claude/settings.json` 后,cc-switch 会自动将该内容同步回数据库,覆盖当前 provider 的 `settings_config`。如果两个工具中的配置不一致,cc-switch 中存储的原始配置将被修改。
68
+
67
69
  ## ➕ 添加配置
68
70
 
69
71
  ### 交互式向导(推荐)
package/dist/claude.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export declare function readClaudeSettings(): Record<string, unknown>;
2
- export declare function applyProfile(settingsConfig: Record<string, unknown>): void;
2
+ export declare function applyProfile(_name: string, settingsConfig: Record<string, unknown>): void;
3
3
  export declare function getSettingsPath(): string;
package/dist/claude.js CHANGED
@@ -7,7 +7,7 @@ export function readClaudeSettings() {
7
7
  return {};
8
8
  return JSON.parse(readFileSync(SETTINGS_PATH, "utf-8"));
9
9
  }
10
- export function applyProfile(settingsConfig) {
10
+ export function applyProfile(_name, settingsConfig) {
11
11
  const current = readClaudeSettings();
12
12
  // 保留用户级字段,用 profile 的配置覆盖
13
13
  const preserved = {};
package/dist/index.js CHANGED
@@ -260,8 +260,8 @@ program
260
260
  if (name === current)
261
261
  return;
262
262
  const profile = store.get(name);
263
- applyProfile(profile.settingsConfig);
264
263
  store.setCurrent(profile.name);
264
+ applyProfile(profile.name, profile.settingsConfig);
265
265
  const env = (profile.settingsConfig.env || {});
266
266
  const model = env["ANTHROPIC_MODEL"] || t("common.model_default");
267
267
  console.log(chalk.green(t("use.done", { name: chalk.bold(profile.name) })));
@@ -355,8 +355,8 @@ program
355
355
  const profile = await resolveProfile(store, name);
356
356
  if (!profile)
357
357
  return;
358
- applyProfile(profile.settingsConfig);
359
358
  store.setCurrent(profile.name);
359
+ applyProfile(profile.name, profile.settingsConfig);
360
360
  const env = (profile.settingsConfig.env || {});
361
361
  const model = env["ANTHROPIC_MODEL"] || t("common.model_default");
362
362
  console.log(chalk.green(t("use.done", { name: chalk.bold(profile.name) })));
@@ -414,8 +414,8 @@ async function saveAndSwitch(store, name, settingsConfig) {
414
414
  console.log(chalk.green(t("add.done", { name })));
415
415
  const switchChoice = await ask(t("add.switch_confirm"));
416
416
  if (switchChoice.toLowerCase() !== "n") {
417
- applyProfile(settingsConfig);
418
417
  store.setCurrent(name);
418
+ applyProfile(name, settingsConfig);
419
419
  console.log(chalk.green(t("use.done", { name: chalk.bold(name) })));
420
420
  console.log(chalk.gray(` ${t("use.restart")}`));
421
421
  }
@@ -674,14 +674,14 @@ program
674
674
  if (profile.name !== current) {
675
675
  const switchChoice = await ask(t("add.switch_confirm"));
676
676
  if (switchChoice.toLowerCase() !== "n") {
677
- applyProfile(settingsConfig);
678
677
  store.setCurrent(profile.name);
678
+ applyProfile(profile.name, settingsConfig);
679
679
  console.log(chalk.green(t("use.done", { name: chalk.bold(profile.name) })));
680
680
  console.log(chalk.gray(` ${t("use.restart")}`));
681
681
  }
682
682
  }
683
683
  else {
684
- applyProfile(settingsConfig);
684
+ applyProfile(profile.name, settingsConfig);
685
685
  console.log(chalk.gray(` ${t("use.restart")}`));
686
686
  }
687
687
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daylenjeez/ccm-switch",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "Claude Code Model Switcher - 快速切换 Claude Code 自定义模型配置",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/claude.ts CHANGED
@@ -9,7 +9,7 @@ export function readClaudeSettings(): Record<string, unknown> {
9
9
  return JSON.parse(readFileSync(SETTINGS_PATH, "utf-8"));
10
10
  }
11
11
 
12
- export function applyProfile(settingsConfig: Record<string, unknown>): void {
12
+ export function applyProfile(_name: string, settingsConfig: Record<string, unknown>): void {
13
13
  const current = readClaudeSettings();
14
14
 
15
15
  // 保留用户级字段,用 profile 的配置覆盖
package/src/index.ts CHANGED
@@ -292,8 +292,8 @@ program
292
292
  const switchTo = (name: string) => {
293
293
  if (name === current) return;
294
294
  const profile = store.get(name)!;
295
- applyProfile(profile.settingsConfig);
296
295
  store.setCurrent(profile.name);
296
+ applyProfile(profile.name, profile.settingsConfig);
297
297
  const env = (profile.settingsConfig.env || {}) as Record<string, string>;
298
298
  const model = env["ANTHROPIC_MODEL"] || t("common.model_default");
299
299
  console.log(chalk.green(t("use.done", { name: chalk.bold(profile.name) })));
@@ -394,8 +394,8 @@ program
394
394
  const profile = await resolveProfile(store, name);
395
395
  if (!profile) return;
396
396
 
397
- applyProfile(profile.settingsConfig);
398
397
  store.setCurrent(profile.name);
398
+ applyProfile(profile.name, profile.settingsConfig);
399
399
 
400
400
  const env = (profile.settingsConfig.env || {}) as Record<string, string>;
401
401
  const model = env["ANTHROPIC_MODEL"] || t("common.model_default");
@@ -457,8 +457,8 @@ async function saveAndSwitch(store: ReturnType<typeof ensureStore>, name: string
457
457
 
458
458
  const switchChoice = await ask(t("add.switch_confirm"));
459
459
  if (switchChoice.toLowerCase() !== "n") {
460
- applyProfile(settingsConfig);
461
460
  store.setCurrent(name);
461
+ applyProfile(name, settingsConfig);
462
462
  console.log(chalk.green(t("use.done", { name: chalk.bold(name) })));
463
463
  console.log(chalk.gray(` ${t("use.restart")}`));
464
464
  }
@@ -746,13 +746,13 @@ program
746
746
  if (profile.name !== current) {
747
747
  const switchChoice = await ask(t("add.switch_confirm"));
748
748
  if (switchChoice.toLowerCase() !== "n") {
749
- applyProfile(settingsConfig);
750
749
  store.setCurrent(profile.name);
750
+ applyProfile(profile.name, settingsConfig);
751
751
  console.log(chalk.green(t("use.done", { name: chalk.bold(profile.name) })));
752
752
  console.log(chalk.gray(` ${t("use.restart")}`));
753
753
  }
754
754
  } else {
755
- applyProfile(settingsConfig);
755
+ applyProfile(profile.name, settingsConfig);
756
756
  console.log(chalk.gray(` ${t("use.restart")}`));
757
757
  }
758
758
  });