From ad0316b5a4108a0d3d49392bc2cb4e896efafaa2 Mon Sep 17 00:00:00 2001 From: Antigravity Bot Date: Mon, 30 Mar 2026 09:59:21 -0600 Subject: [PATCH] feat: support dynamic OpenRouter models and improve shell integration --- README.md | 13 ++++- README_CN.md | 13 +++++ ccm.sh | 141 ++++++++++++++++++++++++++++----------------------- 3 files changed, 102 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 80efdc4..6ab3700 100644 --- a/README.md +++ b/README.md @@ -188,11 +188,15 @@ ccm open qwen # Qwen via OpenRouter ccm open minimax # MiniMax via OpenRouter ccm open stepfun # StepFun via OpenRouter ccm open sf-free # StepFun free tier + +# Dynamic model support (v2.5.0+) +ccm open google/gemini-2.0-flash-001 # Use any OpenRouter model ID +ccc anthropic/claude-3.5-sonnet # Launch directly with full ID ``` -**Available providers:** `claude`, `glm`, `kimi`, `deepseek`, `qwen`, `minimax`, `stepfun` +**Available shorthands:** `claude`, `glm`, `kimi`, `deepseek`, `qwen`, `minimax`, `stepfun` -**Free tier:** `stepfun-free` or `sf-free` for StepFun's free model +**Dynamic support:** Use any full model ID from OpenRouter (e.g., `provider/model-name`). --- @@ -350,6 +354,11 @@ cd claude-code-switch ## What's New +### v2.5.0 (2026-03) +- **Dynamic OpenRouter Models** - Support for any `provider/model` ID without hardcoding. +- **Improved Shell Integration** - Clean modular loading via `ccm_source.sh`. +- **Enhanced `ccc`** - Direct launching with full model IDs (e.g., `ccc google/gemini-2.0-flash-001`). + ### v2.4.0 (2025-02) - **`ccm user` command** - Write settings directly to `~/.claude/settings.json` (highest priority) - **`ccm update-config` command** - Update outdated model IDs automatically diff --git a/README_CN.md b/README_CN.md index 66d6c25..ee3425f 100644 --- a/README_CN.md +++ b/README_CN.md @@ -183,8 +183,16 @@ ccm open # 显示帮助 ccm open glm # 通过 OpenRouter 使用 GLM ccm open claude # 通过 OpenRouter 使用 Claude ccm open deepseek # 通过 OpenRouter 使用 DeepSeek + +# 动态模型支持 (v2.5.0+) +ccm open google/gemini-2.0-flash-001 # 使用任何 OpenRouter 模型 ID +ccc anthropic/claude-3.5-sonnet # 直接通过完整 ID 启动 ``` +**支持的短语:** `claude`, `glm`, `kimi`, `deepseek`, `qwen`, `minimax`, `stepfun` + +**动态支持:** 支持任何 OpenRouter 完整模型 ID (如 `provider/model-name`)。 + --- ## 进阶功能 @@ -341,6 +349,11 @@ cd claude-code-switch ## 更新日志 +### v2.5.0 (2026-03) +- **OpenRouter 动态模型** - 支持任何 `provider/model` ID,无需硬编码。 +- **改进的 Shell 集成** - 通过 `ccm_source.sh` 进行干净的模块化加载。 +- **增强型 `ccc`** - 支持通过完整 ID 直接启动 (如 `ccc google/gemini-2.0-flash-001`)。 + ### v2.4.0 (2025-02) - **`ccm user` 命令** - 直接写入 `~/.claude/settings.json`(最高优先级) - **`ccm update-config` 命令** - 自动更新过时的模型 ID diff --git a/ccm.sh b/ccm.sh index ccded74..1ef9cfe 100755 --- a/ccm.sh +++ b/ccm.sh @@ -1984,69 +1984,84 @@ emit_openrouter_exports() { local default_opus="" local default_haiku="" - case "$provider" in - "claude"|"anthropic"|"default") - model="anthropic/claude-sonnet-4.5" - small="anthropic/claude-haiku-4.5" - default_sonnet="anthropic/claude-sonnet-4.5" - default_opus="anthropic/claude-opus-4.6" - default_haiku="anthropic/claude-haiku-4.5" - ;; - "kimi") - model="moonshotai/kimi-k2.5" - small="moonshotai/kimi-k2.5" - default_sonnet="$model" - default_opus="$model" - default_haiku="$model" - ;; - "deepseek"|"ds") - model="deepseek/deepseek-v3.2" - small="deepseek/deepseek-v3.2" - default_sonnet="$model" - default_opus="$model" - default_haiku="$model" - ;; - "glm"|"glm5") - model="z-ai/glm-5" - small="z-ai/glm-5" - default_sonnet="$model" - default_opus="$model" - default_haiku="$model" - ;; - "qwen") - model="qwen/qwen3-coder-next" - small="qwen/qwen3-coder-next" - default_sonnet="qwen/qwen3-coder-next" - default_opus="qwen/qwen3-coder-plus" - default_haiku="qwen/qwen3-coder-next" - ;; - "minimax"|"mm") - model="minimax/minimax-m2.5" - small="minimax/minimax-m2.5" - default_sonnet="$model" - default_opus="$model" - default_haiku="$model" - ;; - "stepfun"|"sf") - model="stepfun/step-3.5-flash" - small="stepfun/step-3.5-flash" - default_sonnet="$model" - default_opus="$model" - default_haiku="$model" - ;; - "stepfun-free"|"sf-free") - model="stepfun/step-3.5-flash:free" - small="stepfun/step-3.5-flash:free" - default_sonnet="$model" - default_opus="$model" - default_haiku="$model" - ;; - *) - echo -e "${RED}❌ $(t 'unknown_option'): open $provider${NC}" >&2 - show_open_help >&2 - return 1 - ;; - esac + # If provider contains '/', assume it's a full OpenRouter model ID + # 如果 provider 包含 '/', 假定它是 OpenRouter 的完整模型 ID + if [[ "$provider" == *"/"* ]]; then + model="$provider" + small="$provider" + default_sonnet="$provider" + default_opus="$provider" + default_haiku="$provider" + else + case "$provider" in + "claude"|"anthropic"|"default") + model="anthropic/claude-sonnet-4.5" + small="anthropic/claude-haiku-4.5" + default_sonnet="anthropic/claude-sonnet-4.5" + default_opus="anthropic/claude-opus-4.6" + default_haiku="anthropic/claude-haiku-4.5" + ;; + "kimi") + model="moonshotai/kimi-k2.5" + small="moonshotai/kimi-k2.5" + default_sonnet="$model" + default_opus="$model" + default_haiku="$model" + ;; + "deepseek"|"ds") + model="deepseek/deepseek-v3.2" + small="deepseek/deepseek-v3.2" + default_sonnet="$model" + default_opus="$model" + default_haiku="$model" + ;; + "glm"|"glm5") + model="z-ai/glm-5" + small="z-ai/glm-5" + default_sonnet="$model" + default_opus="$model" + default_haiku="$model" + ;; + "qwen") + model="qwen/qwen3-coder-next" + small="qwen/qwen3-coder-next" + default_sonnet="qwen/qwen3-coder-next" + default_opus="qwen/qwen3-coder-plus" + default_haiku="qwen/qwen3-coder-next" + ;; + "minimax"|"mm") + model="minimax/minimax-m2.5" + small="minimax/minimax-m2.5" + default_sonnet="$model" + default_opus="$model" + default_haiku="$model" + ;; + "stepfun"|"sf") + model="stepfun/step-3.5-flash" + small="stepfun/step-3.5-flash" + default_sonnet="$model" + default_opus="$model" + default_haiku="$model" + ;; + "stepfun-free"|"sf-free") + model="stepfun/step-3.5-flash:free" + small="stepfun/step-3.5-flash:free" + default_sonnet="$model" + default_opus="$model" + default_haiku="$model" + ;; + *) + # If unknown but no '/', allow OpenRouter to try resolving it as simple ID + # 如果未知但没有 '/', 允许 OpenRouter 尝试将其解析为简单 ID + echo -e "${YELLOW}⚠️ Unknown provider, using as literal model ID: $provider${NC}" >&2 + model="$provider" + small="$provider" + default_sonnet="$provider" + default_opus="$provider" + default_haiku="$provider" + ;; + esac + fi local prelude="unset ANTHROPIC_BASE_URL ANTHROPIC_API_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY ANTHROPIC_MODEL ANTHROPIC_SMALL_FAST_MODEL ANTHROPIC_DEFAULT_SONNET_MODEL ANTHROPIC_DEFAULT_OPUS_MODEL ANTHROPIC_DEFAULT_HAIKU_MODEL CLAUDE_CODE_SUBAGENT_MODEL API_TIMEOUT_MS CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC" echo "$prelude"