-
Notifications
You must be signed in to change notification settings - Fork 15.7k
添加模型混合模式 #439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加模型混合模式 #439
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| # Claude Code Best V5 (CCB) | ||
|
|
||
| [](https://github.com/claude-code-best/claude-code/stargazers) | ||
| [](https://github.com/claude-code-best/claude-code/graphs/contributors) | ||
| [](https://github.com/claude-code-best/claude-code/issues) | ||
| [](https://github.com/claude-code-best/claude-code/blob/main/LICENSE) | ||
| [](https://github.com/claude-code-best/claude-code/commits/main) | ||
| [](https://github.com/claude-code-best/claude-code-mix/stargazers) | ||
| [](https://github.com/claude-code-best/claude-code-mix/graphs/contributors) | ||
| [](https://github.com/claude-code-best/claude-code-mix/issues) | ||
| [](https://github.com/claude-code-best/claude-code-mix/blob/main/LICENSE) | ||
| [](https://github.com/claude-code-best/claude-code-mix/commits/main) | ||
| [](https://bun.sh/) | ||
| [](https://discord.gg/uApuzJWGKX) | ||
|
|
||
|
|
@@ -27,6 +27,7 @@ | |
| | **Poor Mode** | 穷鬼模式,关闭记忆提取和键入建议,大幅度减少并发请求 | /poor 可以开关 | | ||
| | **Channels 频道通知** | MCP 服务器推送外部消息到会话(飞书/Slack/Discord/微信等),`--channels plugin:name@marketplace` 启用 | [文档](https://ccb.agent-aura.top/docs/features/channels) | | ||
| | **自定义模型供应商** | OpenAI/Anthropic/Gemini/Grok 兼容 (`/login`) | [文档](https://ccb.agent-aura.top/docs/features/all-features-guide) | | ||
| | **/mix 模型混合模式** | `/mix true` 启用独立 `ccbsettings.json`,Opus/Sonnet/Haiku 可分别配置 provider、Base URL、API Key 和模型名 | [使用说明](#mix-模型混合模式) | | ||
| | Voice Mode | 语音输入,支持豆包语言输入(`/voice doubao`) | [文档](https://ccb.agent-aura.top/docs/features/voice-mode) | | ||
| | Computer Use | 屏幕截图、键鼠控制 | [文档](https://ccb.agent-aura.top/docs/features/computer-use) | | ||
| | Chrome Use | 浏览器自动化、表单填写、数据抓取 | [自托管](https://ccb.agent-aura.top/docs/features/chrome-use-mcp) [原生版](https://ccb.agent-aura.top/docs/features/claude-in-chrome-mcp) | | ||
|
|
@@ -123,7 +124,7 @@ powershell -c "irm bun.sh/install.ps1 | iex" | |
| ### 📥 安装 | ||
|
|
||
| ```bash | ||
| cd /path/to/claude-code | ||
| cd /path/to/claude-code-mix | ||
| bun install | ||
| ``` | ||
|
|
||
|
|
@@ -161,6 +162,31 @@ bun run build | |
|
|
||
| - ⌨️ **Tab / Shift+Tab** 切换字段,**Enter** 确认并跳到下一个,最后一个字段按 Enter 保存 | ||
|
|
||
| ### `/mix` 模型混合模式 | ||
|
|
||
| 默认情况下,`/login` 配置会保存到原版共享配置文件 `settings.json`,Opus、Sonnet、Haiku 三种模型共用同一组 provider、API URL 和 API Key。 | ||
|
|
||
| 如果你希望三种模型分别使用不同的 API 地址、密钥或协议,先在 REPL 中开启混合模式: | ||
|
|
||
| ```text | ||
| /mix true | ||
| ``` | ||
|
|
||
| 开启后: | ||
|
|
||
| - 配置会保存到独立的 `ccbsettings.json`,不再写入共享的 `settings.json` | ||
| - 再运行 `/login` 时,会先选择要配置的模型族:`Opus`、`Sonnet` 或 `Haiku` | ||
| - 选择模型族后,再进入原来的 provider 类型选择菜单,例如 Anthropic Compatible、OpenAI Compatible、Gemini API | ||
| - 每个模型族都可以单独保存自己的 provider、Base URL、API Key 和模型名 | ||
|
|
||
| 常用命令: | ||
|
|
||
| ```text | ||
| /mix true # 开启模型混合模式,使用独立 ccbsettings.json | ||
| /mix status # 查看当前是否开启 mix 模式以及正在使用的配置文件 | ||
| /mix false # 关闭模型混合模式,恢复使用原版共享 settings.json | ||
| ``` | ||
|
Comment on lines
+167
to
+188
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 为 这里明确会把 API Key 写入本地配置文件,但缺少防泄漏指引。建议补充:不要提交该文件到 Git、加入 建议补充文案(示例) 开启后:
- 配置会保存到独立的 `ccbsettings.json`,不再写入共享的 `settings.json`
@@
- 每个模型族都可以单独保存自己的 provider、Base URL、API Key 和模型名
+
+> 🔐 安全提示:`ccbsettings.json` 包含 API Key,请勿提交到仓库。
+> 建议将其加入 `.gitignore`,并在类 Unix 系统执行 `chmod 600 ccbsettings.json` 限制读取权限。🤖 Prompt for AI Agents |
||
|
|
||
| > ℹ️ 支持所有 Anthropic API 兼容服务(如 OpenRouter、AWS Bedrock 代理等),只要接口兼容 Messages API 即可。 | ||
|
|
||
| ## Feature Flags | ||
|
|
@@ -217,21 +243,21 @@ TUI (REPL) 模式需要真实终端,无法直接通过 VS Code launch 启动 | |
| ## 相关文档及网站 | ||
|
|
||
| - **在线文档(Mintlify)**: [ccb.agent-aura.top](https://ccb.agent-aura.top/) — 文档源码位于 [`docs/`](docs/) 目录,欢迎投稿 PR | ||
| - **DeepWiki**: [https://deepwiki.com/claude-code-best/claude-code](https://deepwiki.com/claude-code-best/claude-code) | ||
| - **DeepWiki**: [https://deepwiki.com/claude-code-best/claude-code-mix](https://deepwiki.com/claude-code-best/claude-code-mix) | ||
|
|
||
| ## Contributors | ||
|
|
||
| <a href="https://github.com/claude-code-best/claude-code/graphs/contributors"> | ||
| <a href="https://github.com/claude-code-best/claude-code-mix/graphs/contributors"> | ||
| <img src="contributors.svg" alt="Contributors" /> | ||
| </a> | ||
|
|
||
| ## Star History | ||
|
|
||
| <a href="https://www.star-history.com/?repos=claude-code-best%2Fclaude-code&type=date&legend=top-left"> | ||
| <a href="https://www.star-history.com/?repos=claude-code-best%2Fclaude-code-mix&type=date&legend=top-left"> | ||
| <picture> | ||
| <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/image?repos=claude-code-best/claude-code&type=date&theme=dark&legend=top-left" /> | ||
| <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/image?repos=claude-code-best/claude-code&type=date&legend=top-left" /> | ||
| <img alt="Star History Chart" src="https://api.star-history.com/image?repos=claude-code-best/claude-code&type=date&legend=top-left" /> | ||
| <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/image?repos=claude-code-best/claude-code-mix&type=date&theme=dark&legend=top-left" /> | ||
| <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/image?repos=claude-code-best/claude-code-mix&type=date&legend=top-left" /> | ||
| <img alt="Star History Chart" src="https://api.star-history.com/image?repos=claude-code-best/claude-code-mix&type=date&legend=top-left" /> | ||
| </picture> | ||
| </a> | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,10 @@ | ||||||||||||||
| # Claude Code Best V5 (CCB) | ||||||||||||||
|
|
||||||||||||||
| [](https://github.com/claude-code-best/claude-code/stargazers) | ||||||||||||||
| [](https://github.com/claude-code-best/claude-code/graphs/contributors) | ||||||||||||||
| [](https://github.com/claude-code-best/claude-code/issues) | ||||||||||||||
| [](https://github.com/claude-code-best/claude-code/blob/main/LICENSE) | ||||||||||||||
| [](https://github.com/claude-code-best/claude-code/commits/main) | ||||||||||||||
| [](https://github.com/claude-code-best/claude-code-mix/stargazers) | ||||||||||||||
| [](https://github.com/claude-code-best/claude-code-mix/graphs/contributors) | ||||||||||||||
| [](https://github.com/claude-code-best/claude-code-mix/issues) | ||||||||||||||
| [](https://github.com/claude-code-best/claude-code-mix/blob/main/LICENSE) | ||||||||||||||
| [](https://github.com/claude-code-best/claude-code-mix/commits/main) | ||||||||||||||
| [](https://bun.sh/) | ||||||||||||||
|
|
||||||||||||||
| > Which Claude do you like? The open source one is the best. | ||||||||||||||
|
|
@@ -32,6 +32,7 @@ Sponsor placeholder. | |||||||||||||
| - [x] Custom Sentry error reporting support [Docs](https://ccb.agent-aura.top/docs/internals/sentry-setup) | ||||||||||||||
| - [x] Custom GrowthBook support (GB is open source — configure your own feature flag platform) [Docs](https://ccb.agent-aura.top/docs/internals/growthbook-adapter) | ||||||||||||||
| - [x] Custom login mode — configure Claude models your way | ||||||||||||||
| - [x] `/mix` mixed model mode — use an independent `ccbsettings.json` so Opus, Sonnet, and Haiku can each have their own provider, Base URL, API key, and model name | ||||||||||||||
| - [ ] V6: Large-scale refactoring, full modular packaging | ||||||||||||||
| - [ ] V6 will be a new branch; main branch will be archived as a historical version | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -105,7 +106,7 @@ powershell -c "irm bun.sh/install.ps1 | iex" | |||||||||||||
| ### Install | ||||||||||||||
|
|
||||||||||||||
| ```bash | ||||||||||||||
| cd /path/to/claude-code | ||||||||||||||
| cd /path/to/claude-code-mix | ||||||||||||||
| bun install | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -143,6 +144,31 @@ Fields to fill in: | |||||||||||||
| - Model fields auto-fill from current environment variables | ||||||||||||||
| - Configuration saves to `~/.claude/settings.json` under the `env` key, effective immediately | ||||||||||||||
|
|
||||||||||||||
| ### `/mix` Mixed Model Mode | ||||||||||||||
|
|
||||||||||||||
| By default, `/login` saves provider settings to the shared `settings.json` file, so Opus, Sonnet, and Haiku use the same provider, API URL, and API key. | ||||||||||||||
|
|
||||||||||||||
| If you want each model family to use a different API endpoint, key, or protocol, enable mixed model mode in the REPL first: | ||||||||||||||
|
|
||||||||||||||
| ```text | ||||||||||||||
| /mix true | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| After enabling it: | ||||||||||||||
|
|
||||||||||||||
| - Configuration is saved to the independent `ccbsettings.json` file instead of the shared `settings.json` | ||||||||||||||
| - Running `/login` first asks which model family to configure: `Opus`, `Sonnet`, or `Haiku` | ||||||||||||||
| - After selecting the model family, the existing provider menu appears, such as Anthropic Compatible, OpenAI Compatible, or Gemini API | ||||||||||||||
| - Each model family can store its own provider, Base URL, API key, and model name | ||||||||||||||
|
|
||||||||||||||
| Common commands: | ||||||||||||||
|
|
||||||||||||||
| ```text | ||||||||||||||
| /mix true # Enable mixed model mode with independent ccbsettings.json | ||||||||||||||
| /mix status # Show whether mix mode is enabled and which config file is active | ||||||||||||||
| /mix false # Disable mixed model mode and return to shared settings.json | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| You can also edit `~/.claude/settings.json` directly: | ||||||||||||||
|
|
||||||||||||||
| ```json | ||||||||||||||
|
|
@@ -188,21 +214,21 @@ The TUI (REPL) mode requires a real terminal and cannot be launched directly via | |||||||||||||
| ## Documentation & Links | ||||||||||||||
|
|
||||||||||||||
| - **Online docs (Mintlify)**: [ccb.agent-aura.top](https://ccb.agent-aura.top/) — source in [`docs/`](docs/), PR contributions welcome | ||||||||||||||
| - **DeepWiki**: https://deepwiki.com/claude-code-best/claude-code | ||||||||||||||
| - **DeepWiki**: https://deepwiki.com/claude-code-best/claude-code-mix | ||||||||||||||
|
|
||||||||||||||
| ## Contributors | ||||||||||||||
|
|
||||||||||||||
| <a href="https://github.com/claude-code-best/claude-code/graphs/contributors"> | ||||||||||||||
| <img src="https://contrib.rocks/image?repo=claude-code-best/claude-code" /> | ||||||||||||||
| <a href="https://github.com/claude-code-best/claude-code-mix/graphs/contributors"> | ||||||||||||||
| <img src="https://contrib.rocks/image?repo=claude-code-best/claude-code-mix" /> | ||||||||||||||
| </a> | ||||||||||||||
|
Comment on lines
+221
to
223
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add missing alt text for the contributors image (MD045). At Line 222, the Suggested patch <a href="https://github.com/claude-code-best/claude-code-mix/graphs/contributors">
- <img src="https://contrib.rocks/image?repo=claude-code-best/claude-code-mix" />
+ <img alt="Contributors list for claude-code-best/claude-code-mix" src="https://contrib.rocks/image?repo=claude-code-best/claude-code-mix" />
</a>📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.22.1)[warning] 222-222: Images should have alternate text (alt text) (MD045, no-alt-text) 🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| ## Star History | ||||||||||||||
|
|
||||||||||||||
| <a href="https://www.star-history.com/?repos=claude-code-best%2Fclaude-code&type=date&legend=top-left"> | ||||||||||||||
| <a href="https://www.star-history.com/?repos=claude-code-best%2Fclaude-code-mix&type=date&legend=top-left"> | ||||||||||||||
| <picture> | ||||||||||||||
| <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/image?repos=claude-code-best%2Fclaude-code&type=date&theme=dark&legend=top-left" /> | ||||||||||||||
| <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/image?repos=claude-code-best%2Fclaude-code&type=date&legend=top-left" /> | ||||||||||||||
| <img alt="Star History Chart" src="https://api.star-history.com/image?repos=claude-code-best%2Fclaude-code&type=date&legend=top-left" /> | ||||||||||||||
| <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/image?repos=claude-code-best%2Fclaude-code-mix&type=date&theme=dark&legend=top-left" /> | ||||||||||||||
| <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/image?repos=claude-code-best%2Fclaude-code-mix&type=date&legend=top-left" /> | ||||||||||||||
| <img alt="Star History Chart" src="https://api.star-history.com/image?repos=claude-code-best%2Fclaude-code-mix&type=date&legend=top-left" /> | ||||||||||||||
| </picture> | ||||||||||||||
| </a> | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import type { Command } from '../commands.js' | ||
| import type { LocalCommandCall } from '../types/command.js' | ||
| import { MIX_MODE_ENV, isMixModeEnabled } from '../utils/model/mix.js' | ||
| import { | ||
| getSettings_DEPRECATED, | ||
| getSettingsFilePathForSource, | ||
| updateSettingsForSource, | ||
| } from '../utils/settings/settings.js' | ||
|
|
||
| const TRUE_VALUES = new Set(['true', 'on', 'enable', 'enabled', '1', 'yes']) | ||
| const FALSE_VALUES = new Set(['false', 'off', 'disable', 'disabled', '0', 'no']) | ||
|
|
||
| function getMixUsageText( | ||
| enabled: boolean, | ||
| settingsPath: string | undefined, | ||
| ): string { | ||
| return [ | ||
| `Mix mode is ${enabled ? 'enabled' : 'disabled'}.`, | ||
| `Settings file: ${settingsPath ?? 'unknown'}`, | ||
| '', | ||
| 'Usage:', | ||
| ' /mix true Enable mixed model mode', | ||
| ' /mix false Disable mixed model mode', | ||
| ' /mix status Show current mixed model mode status', | ||
| '', | ||
| 'Mixed model mode uses the independent ccbsettings.json config file instead of the shared settings.json.', | ||
| 'When mixed model mode is enabled, Opus, Sonnet, and Haiku can each be configured separately.', | ||
| 'After running /mix true, run /login and choose which model family you want to configure first.', | ||
| 'Each model family stores its own provider, API URL, API key, and model name in ccbsettings.json.', | ||
| ].join('\n') | ||
| } | ||
|
|
||
| const call: LocalCommandCall = async args => { | ||
| const arg = args.trim().toLowerCase() | ||
| const settingsPath = getSettingsFilePathForSource('userSettings') | ||
|
|
||
| if (!arg || arg === 'status') { | ||
| const settings = getSettings_DEPRECATED() || {} | ||
| const enabled = isMixModeEnabled(settings) | ||
| return { | ||
| type: 'text', | ||
| value: getMixUsageText(enabled, settingsPath), | ||
| } | ||
| } | ||
|
|
||
| if (!TRUE_VALUES.has(arg) && !FALSE_VALUES.has(arg)) { | ||
| return { | ||
| type: 'text', | ||
| value: getMixUsageText( | ||
| isMixModeEnabled(getSettings_DEPRECATED() || {}), | ||
| settingsPath, | ||
| ), | ||
| } | ||
| } | ||
|
|
||
| const enabled = TRUE_VALUES.has(arg) | ||
| const previousMixEnv = process.env[MIX_MODE_ENV] | ||
| if (enabled) { | ||
| process.env[MIX_MODE_ENV] = '1' | ||
| } | ||
| const { error } = updateSettingsForSource('userSettings', { mix: enabled }) | ||
| if (error) { | ||
| if (previousMixEnv === undefined) { | ||
| delete process.env[MIX_MODE_ENV] | ||
| } else { | ||
| process.env[MIX_MODE_ENV] = previousMixEnv | ||
| } | ||
| return { | ||
| type: 'text', | ||
| value: `Failed to update mix mode: ${error.message}`, | ||
| } | ||
| } | ||
|
|
||
| process.env[MIX_MODE_ENV] = enabled ? '1' : '0' | ||
| return { | ||
| type: 'text', | ||
| value: enabled | ||
| ? [ | ||
| 'Mix mode enabled.', | ||
| '', | ||
| 'Mixed model mode uses the independent ccbsettings.json config file.', | ||
| 'Next step: run /login, then select Opus, Sonnet, or Haiku to configure that model family.', | ||
| 'Each family can use its own provider, API URL, API key, and model name.', | ||
| ].join('\n') | ||
| : 'Mix mode disabled. /login will use the shared API configuration flow.', | ||
| } | ||
| } | ||
|
|
||
| const mix = { | ||
| type: 'local', | ||
| name: 'mix', | ||
| description: | ||
| 'Enable or disable mixed model mode using an independent config file; Opus, Sonnet, and Haiku can be configured separately', | ||
| argumentHint: '[true|false|status]', | ||
| supportsNonInteractive: true, | ||
| load: () => Promise.resolve({ call }), | ||
| } satisfies Command | ||
|
|
||
| export default mix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确认仓库 slug 是否应统一为
claude-code,避免文档链接失效。当前 PR 目标仓库是
claude-code-best/claude-code,但这些位置都改成了claude-code-mix。如果仓库未实际迁移,会导致徽章、DeepWiki、贡献者页、Star History 和源码安装路径指向错误。建议统一改为当前仓库 slug,或在 README 中明确“这是新仓库地址”。Also applies to: 127-127, 246-246, 250-250, 256-260
🤖 Prompt for AI Agents