Repository: farion1231/cc-switch Branch: main Commit: 8ccfbd36d6cb Files: 606 Total size: 5.0 MB Directory structure: gitextract_y5v1mptu/ ├── .gitattributes ├── .gitignore ├── .node-version ├── CHANGELOG.md ├── LICENSE ├── README.md ├── README_JA.md ├── README_ZH.md ├── cc-switch-main/ │ └── src/ │ └── config/ │ └── universalProviderPresets.ts ├── components.json ├── deplink.html ├── docs/ │ ├── proxy-guide-zh.md │ ├── release-notes/ │ │ ├── v3.10.0-en.md │ │ ├── v3.10.0-ja.md │ │ ├── v3.10.0-zh.md │ │ ├── v3.11.0-en.md │ │ ├── v3.11.0-ja.md │ │ ├── v3.11.0-zh.md │ │ ├── v3.11.1-en.md │ │ ├── v3.11.1-ja.md │ │ ├── v3.11.1-zh.md │ │ ├── v3.12.0-en.md │ │ ├── v3.12.0-ja.md │ │ ├── v3.12.0-zh.md │ │ ├── v3.12.1-en.md │ │ ├── v3.12.1-ja.md │ │ ├── v3.12.1-zh.md │ │ ├── v3.12.2-en.md │ │ ├── v3.12.2-ja.md │ │ ├── v3.12.2-zh.md │ │ ├── v3.12.3-en.md │ │ ├── v3.12.3-ja.md │ │ ├── v3.12.3-zh.md │ │ ├── v3.6.0-en.md │ │ ├── v3.6.0-zh.md │ │ ├── v3.6.1-en.md │ │ ├── v3.6.1-zh.md │ │ ├── v3.7.0-en.md │ │ ├── v3.7.0-zh.md │ │ ├── v3.7.1-en.md │ │ ├── v3.7.1-zh.md │ │ ├── v3.8.0-en.md │ │ ├── v3.8.0-ja.md │ │ ├── v3.8.0-zh.md │ │ ├── v3.9.0-en.md │ │ ├── v3.9.0-ja.md │ │ └── v3.9.0-zh.md │ └── user-manual/ │ ├── README.md │ ├── en/ │ │ ├── 1-getting-started/ │ │ │ ├── 1.1-introduction.md │ │ │ ├── 1.2-installation.md │ │ │ ├── 1.3-interface.md │ │ │ ├── 1.4-quickstart.md │ │ │ └── 1.5-settings.md │ │ ├── 2-providers/ │ │ │ ├── 2.1-add.md │ │ │ ├── 2.2-switch.md │ │ │ ├── 2.3-edit.md │ │ │ ├── 2.4-sort-duplicate.md │ │ │ └── 2.5-usage-query.md │ │ ├── 3-extensions/ │ │ │ ├── 3.1-mcp.md │ │ │ ├── 3.2-prompts.md │ │ │ └── 3.3-skills.md │ │ ├── 4-proxy/ │ │ │ ├── 4.1-service.md │ │ │ ├── 4.2-takeover.md │ │ │ ├── 4.3-failover.md │ │ │ ├── 4.4-usage.md │ │ │ └── 4.5-model-test.md │ │ ├── 5-faq/ │ │ │ ├── 5.1-config-files.md │ │ │ ├── 5.2-questions.md │ │ │ ├── 5.3-deeplink.md │ │ │ └── 5.4-env-conflict.md │ │ └── README.md │ ├── ja/ │ │ ├── 1-getting-started/ │ │ │ ├── 1.1-introduction.md │ │ │ ├── 1.2-installation.md │ │ │ ├── 1.3-interface.md │ │ │ ├── 1.4-quickstart.md │ │ │ └── 1.5-settings.md │ │ ├── 2-providers/ │ │ │ ├── 2.1-add.md │ │ │ ├── 2.2-switch.md │ │ │ ├── 2.3-edit.md │ │ │ ├── 2.4-sort-duplicate.md │ │ │ └── 2.5-usage-query.md │ │ ├── 3-extensions/ │ │ │ ├── 3.1-mcp.md │ │ │ ├── 3.2-prompts.md │ │ │ └── 3.3-skills.md │ │ ├── 4-proxy/ │ │ │ ├── 4.1-service.md │ │ │ ├── 4.2-takeover.md │ │ │ ├── 4.3-failover.md │ │ │ ├── 4.4-usage.md │ │ │ └── 4.5-model-test.md │ │ ├── 5-faq/ │ │ │ ├── 5.1-config-files.md │ │ │ ├── 5.2-questions.md │ │ │ ├── 5.3-deeplink.md │ │ │ └── 5.4-env-conflict.md │ │ └── README.md │ └── zh/ │ ├── 1-getting-started/ │ │ ├── 1.1-introduction.md │ │ ├── 1.2-installation.md │ │ ├── 1.3-interface.md │ │ ├── 1.4-quickstart.md │ │ └── 1.5-settings.md │ ├── 2-providers/ │ │ ├── 2.1-add.md │ │ ├── 2.2-switch.md │ │ ├── 2.3-edit.md │ │ ├── 2.4-sort-duplicate.md │ │ └── 2.5-usage-query.md │ ├── 3-extensions/ │ │ ├── 3.1-mcp.md │ │ ├── 3.2-prompts.md │ │ └── 3.3-skills.md │ ├── 4-proxy/ │ │ ├── 4.1-service.md │ │ ├── 4.2-takeover.md │ │ ├── 4.3-failover.md │ │ ├── 4.4-usage.md │ │ └── 4.5-model-test.md │ ├── 5-faq/ │ │ ├── 5.1-config-files.md │ │ ├── 5.2-questions.md │ │ ├── 5.3-deeplink.md │ │ └── 5.4-env-conflict.md │ └── README.md ├── flatpak/ │ ├── README.md │ ├── com.ccswitch.desktop.desktop │ ├── com.ccswitch.desktop.metainfo.xml │ └── com.ccswitch.desktop.yml ├── package.json ├── pnpm-workspace.yaml ├── postcss.config.cjs ├── scripts/ │ ├── extract-icons.js │ ├── filter-icons.js │ └── generate-icon-index.js ├── session-manager.md ├── src/ │ ├── App.tsx │ ├── components/ │ │ ├── AppSwitcher.tsx │ │ ├── BrandIcons.tsx │ │ ├── ColorPicker.tsx │ │ ├── ConfirmDialog.tsx │ │ ├── DeepLinkImportDialog.tsx │ │ ├── IconPicker.tsx │ │ ├── JsonEditor.tsx │ │ ├── MarkdownEditor.tsx │ │ ├── ProviderIcon.tsx │ │ ├── UpdateBadge.tsx │ │ ├── UsageFooter.tsx │ │ ├── UsageScriptModal.tsx │ │ ├── agents/ │ │ │ └── AgentsPanel.tsx │ │ ├── common/ │ │ │ ├── AppCountBar.tsx │ │ │ ├── AppToggleGroup.tsx │ │ │ ├── FullScreenPanel.tsx │ │ │ └── ListItemRow.tsx │ │ ├── deeplink/ │ │ │ ├── McpConfirmation.tsx │ │ │ ├── PromptConfirmation.tsx │ │ │ └── SkillConfirmation.tsx │ │ ├── env/ │ │ │ └── EnvWarningBanner.tsx │ │ ├── icons/ │ │ │ └── TerminalIcons.tsx │ │ ├── mcp/ │ │ │ ├── McpFormModal.tsx │ │ │ ├── McpWizardModal.tsx │ │ │ ├── UnifiedMcpPanel.tsx │ │ │ └── useMcpValidation.ts │ │ ├── mode-toggle.tsx │ │ ├── openclaw/ │ │ │ ├── AgentsDefaultsPanel.tsx │ │ │ ├── EnvPanel.tsx │ │ │ ├── OpenClawHealthBanner.tsx │ │ │ ├── ToolsPanel.tsx │ │ │ ├── hooks/ │ │ │ │ └── useOpenClawModelOptions.ts │ │ │ └── utils.ts │ │ ├── prompts/ │ │ │ ├── PromptFormModal.tsx │ │ │ ├── PromptFormPanel.tsx │ │ │ ├── PromptListItem.tsx │ │ │ ├── PromptPanel.tsx │ │ │ └── PromptToggle.tsx │ │ ├── providers/ │ │ │ ├── AddProviderDialog.tsx │ │ │ ├── EditProviderDialog.tsx │ │ │ ├── FailoverPriorityBadge.tsx │ │ │ ├── HealthStatusIndicator.tsx │ │ │ ├── ProviderActions.tsx │ │ │ ├── ProviderCard.tsx │ │ │ ├── ProviderEmptyState.tsx │ │ │ ├── ProviderHealthBadge.tsx │ │ │ ├── ProviderList.tsx │ │ │ └── forms/ │ │ │ ├── ApiKeyInput.tsx │ │ │ ├── BasicFormFields.tsx │ │ │ ├── ClaudeFormFields.tsx │ │ │ ├── CodexCommonConfigModal.tsx │ │ │ ├── CodexConfigEditor.tsx │ │ │ ├── CodexConfigSections.tsx │ │ │ ├── CodexFormFields.tsx │ │ │ ├── CommonConfigEditor.tsx │ │ │ ├── CopilotAuthSection.tsx │ │ │ ├── EndpointSpeedTest.tsx │ │ │ ├── GeminiCommonConfigModal.tsx │ │ │ ├── GeminiConfigEditor.tsx │ │ │ ├── GeminiConfigSections.tsx │ │ │ ├── GeminiFormFields.tsx │ │ │ ├── OmoFormFields.tsx │ │ │ ├── OpenClawFormFields.tsx │ │ │ ├── OpenCodeFormFields.tsx │ │ │ ├── ProviderAdvancedConfig.tsx │ │ │ ├── ProviderForm.tsx │ │ │ ├── ProviderPresetSelector.tsx │ │ │ ├── helpers/ │ │ │ │ └── opencodeFormUtils.ts │ │ │ ├── hooks/ │ │ │ │ ├── index.ts │ │ │ │ ├── useApiKeyLink.ts │ │ │ │ ├── useApiKeyState.ts │ │ │ │ ├── useBaseUrlState.ts │ │ │ │ ├── useCodexCommonConfig.ts │ │ │ │ ├── useCodexConfigState.ts │ │ │ │ ├── useCodexTomlValidation.ts │ │ │ │ ├── useCommonConfigSnippet.ts │ │ │ │ ├── useCopilotAuth.ts │ │ │ │ ├── useCustomEndpoints.ts │ │ │ │ ├── useGeminiCommonConfig.ts │ │ │ │ ├── useGeminiConfigState.ts │ │ │ │ ├── useManagedAuth.ts │ │ │ │ ├── useModelState.ts │ │ │ │ ├── useOmoDraftState.ts │ │ │ │ ├── useOmoModelSource.ts │ │ │ │ ├── useOpenclawFormState.ts │ │ │ │ ├── useOpencodeFormState.ts │ │ │ │ ├── useProviderCategory.ts │ │ │ │ ├── useSpeedTestEndpoints.ts │ │ │ │ └── useTemplateValues.ts │ │ │ └── shared/ │ │ │ ├── ApiKeySection.tsx │ │ │ ├── EndpointField.tsx │ │ │ └── index.ts │ │ ├── proxy/ │ │ │ ├── AutoFailoverConfigPanel.tsx │ │ │ ├── CircuitBreakerConfigPanel.tsx │ │ │ ├── FailoverQueueManager.tsx │ │ │ ├── FailoverToggle.tsx │ │ │ ├── ProxyPanel.tsx │ │ │ ├── ProxyToggle.tsx │ │ │ └── index.ts │ │ ├── sessions/ │ │ │ ├── SessionItem.tsx │ │ │ ├── SessionManagerPage.tsx │ │ │ ├── SessionMessageItem.tsx │ │ │ ├── SessionToc.tsx │ │ │ └── utils.ts │ │ ├── settings/ │ │ │ ├── AboutSection.tsx │ │ │ ├── AppVisibilitySettings.tsx │ │ │ ├── AuthCenterPanel.tsx │ │ │ ├── BackupListSection.tsx │ │ │ ├── DirectorySettings.tsx │ │ │ ├── GlobalProxySettings.tsx │ │ │ ├── ImportExportSection.tsx │ │ │ ├── LanguageSettings.tsx │ │ │ ├── LogConfigPanel.tsx │ │ │ ├── ProxyTabContent.tsx │ │ │ ├── RectifierConfigPanel.tsx │ │ │ ├── SettingsPage.tsx │ │ │ ├── SkillSyncMethodSettings.tsx │ │ │ ├── TerminalSettings.tsx │ │ │ ├── ThemeSettings.tsx │ │ │ ├── WebdavSyncSection.tsx │ │ │ └── WindowSettings.tsx │ │ ├── skills/ │ │ │ ├── RepoManager.tsx │ │ │ ├── RepoManagerPanel.tsx │ │ │ ├── SkillCard.tsx │ │ │ ├── SkillsPage.tsx │ │ │ └── UnifiedSkillsPanel.tsx │ │ ├── theme-provider.tsx │ │ ├── ui/ │ │ │ ├── accordion.tsx │ │ │ ├── alert.tsx │ │ │ ├── badge.tsx │ │ │ ├── button.tsx │ │ │ ├── card.tsx │ │ │ ├── checkbox.tsx │ │ │ ├── collapsible.tsx │ │ │ ├── command.tsx │ │ │ ├── dialog.tsx │ │ │ ├── dropdown-menu.tsx │ │ │ ├── form.tsx │ │ │ ├── input.tsx │ │ │ ├── label.tsx │ │ │ ├── popover.tsx │ │ │ ├── scroll-area.tsx │ │ │ ├── select.tsx │ │ │ ├── sonner.tsx │ │ │ ├── switch.tsx │ │ │ ├── table.tsx │ │ │ ├── tabs.tsx │ │ │ ├── textarea.tsx │ │ │ ├── toggle-row.tsx │ │ │ └── tooltip.tsx │ │ ├── universal/ │ │ │ ├── UniversalProviderCard.tsx │ │ │ ├── UniversalProviderFormModal.tsx │ │ │ ├── UniversalProviderPanel.tsx │ │ │ └── index.ts │ │ ├── usage/ │ │ │ ├── ModelStatsTable.tsx │ │ │ ├── ModelTestConfigPanel.tsx │ │ │ ├── PricingConfigPanel.tsx │ │ │ ├── PricingEditModal.tsx │ │ │ ├── ProviderStatsTable.tsx │ │ │ ├── RequestDetailPanel.tsx │ │ │ ├── RequestLogTable.tsx │ │ │ ├── UsageDashboard.tsx │ │ │ ├── UsageSummaryCards.tsx │ │ │ ├── UsageTrendChart.tsx │ │ │ └── format.ts │ │ └── workspace/ │ │ ├── DailyMemoryPanel.tsx │ │ ├── WorkspaceFileEditor.tsx │ │ └── WorkspaceFilesPanel.tsx │ ├── config/ │ │ ├── appConfig.tsx │ │ ├── claudeProviderPresets.ts │ │ ├── codexProviderPresets.ts │ │ ├── codexTemplates.ts │ │ ├── constants.ts │ │ ├── geminiProviderPresets.ts │ │ ├── iconInference.ts │ │ ├── mcpPresets.ts │ │ ├── openclawProviderPresets.ts │ │ ├── opencodeProviderPresets.ts │ │ └── universalProviderPresets.ts │ ├── contexts/ │ │ └── UpdateContext.tsx │ ├── hooks/ │ │ ├── useAutoCompact.ts │ │ ├── useBackupManager.ts │ │ ├── useDirectorySettings.ts │ │ ├── useDragSort.ts │ │ ├── useGlobalProxy.ts │ │ ├── useImportExport.ts │ │ ├── useLastValidValue.ts │ │ ├── useMcp.ts │ │ ├── useOpenClaw.ts │ │ ├── usePromptActions.ts │ │ ├── useProviderActions.ts │ │ ├── useProxyConfig.ts │ │ ├── useProxyStatus.ts │ │ ├── useSessionSearch.ts │ │ ├── useSettings.ts │ │ ├── useSettingsForm.ts │ │ ├── useSettingsMetadata.ts │ │ ├── useSkills.ts │ │ └── useStreamCheck.ts │ ├── i18n/ │ │ ├── index.ts │ │ └── locales/ │ │ ├── en.json │ │ ├── ja.json │ │ └── zh.json │ ├── icons/ │ │ └── extracted/ │ │ ├── index.ts │ │ └── metadata.ts │ ├── index.css │ ├── index.html │ ├── lib/ │ │ ├── api/ │ │ │ ├── auth.ts │ │ │ ├── config.ts │ │ │ ├── copilot.ts │ │ │ ├── deeplink.ts │ │ │ ├── env.ts │ │ │ ├── failover.ts │ │ │ ├── globalProxy.ts │ │ │ ├── index.ts │ │ │ ├── mcp.ts │ │ │ ├── model-test.ts │ │ │ ├── omo.ts │ │ │ ├── openclaw.ts │ │ │ ├── prompts.ts │ │ │ ├── providers.ts │ │ │ ├── proxy.ts │ │ │ ├── sessions.ts │ │ │ ├── settings.ts │ │ │ ├── skills.ts │ │ │ ├── types.ts │ │ │ ├── usage.ts │ │ │ ├── vscode.ts │ │ │ └── workspace.ts │ │ ├── authBinding.ts │ │ ├── errors/ │ │ │ └── skillErrorParser.ts │ │ ├── platform.ts │ │ ├── query/ │ │ │ ├── failover.ts │ │ │ ├── index.ts │ │ │ ├── mutations.ts │ │ │ ├── omo.ts │ │ │ ├── proxy.ts │ │ │ ├── queries.ts │ │ │ ├── queryClient.ts │ │ │ └── usage.ts │ │ ├── schemas/ │ │ │ ├── common.ts │ │ │ ├── mcp.ts │ │ │ ├── provider.ts │ │ │ └── settings.ts │ │ ├── updater.ts │ │ ├── utils/ │ │ │ └── base64.ts │ │ └── utils.ts │ ├── main.tsx │ ├── types/ │ │ ├── env.ts │ │ ├── icon.ts │ │ ├── omo.ts │ │ ├── proxy.ts │ │ └── usage.ts │ ├── types.ts │ ├── utils/ │ │ ├── domUtils.ts │ │ ├── errorUtils.ts │ │ ├── formatters.ts │ │ ├── postChangeSync.ts │ │ ├── providerConfigUtils.ts │ │ ├── providerMetaUtils.ts │ │ ├── textNormalization.ts │ │ ├── tomlUtils.ts │ │ └── uuid.ts │ └── vite-env.d.ts ├── src-tauri/ │ ├── .gitignore │ ├── Cargo.toml │ ├── Info.plist │ ├── build.rs │ ├── capabilities/ │ │ └── default.json │ ├── common-controls.manifest │ ├── icons/ │ │ └── icon.icns │ ├── src/ │ │ ├── app_config.rs │ │ ├── app_store.rs │ │ ├── auto_launch.rs │ │ ├── claude_mcp.rs │ │ ├── claude_plugin.rs │ │ ├── codex_config.rs │ │ ├── commands/ │ │ │ ├── auth.rs │ │ │ ├── config.rs │ │ │ ├── copilot.rs │ │ │ ├── deeplink.rs │ │ │ ├── env.rs │ │ │ ├── failover.rs │ │ │ ├── global_proxy.rs │ │ │ ├── import_export.rs │ │ │ ├── mcp.rs │ │ │ ├── misc.rs │ │ │ ├── mod.rs │ │ │ ├── omo.rs │ │ │ ├── openclaw.rs │ │ │ ├── plugin.rs │ │ │ ├── prompt.rs │ │ │ ├── provider.rs │ │ │ ├── proxy.rs │ │ │ ├── session_manager.rs │ │ │ ├── settings.rs │ │ │ ├── skill.rs │ │ │ ├── stream_check.rs │ │ │ ├── sync_support.rs │ │ │ ├── usage.rs │ │ │ ├── webdav_sync.rs │ │ │ └── workspace.rs │ │ ├── config.rs │ │ ├── database/ │ │ │ ├── backup.rs │ │ │ ├── dao/ │ │ │ │ ├── failover.rs │ │ │ │ ├── mcp.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── prompts.rs │ │ │ │ ├── providers.rs │ │ │ │ ├── proxy.rs │ │ │ │ ├── settings.rs │ │ │ │ ├── skills.rs │ │ │ │ ├── stream_check.rs │ │ │ │ ├── universal_providers.rs │ │ │ │ └── usage_rollup.rs │ │ │ ├── migration.rs │ │ │ ├── mod.rs │ │ │ ├── schema.rs │ │ │ └── tests.rs │ │ ├── deeplink/ │ │ │ ├── mcp.rs │ │ │ ├── mod.rs │ │ │ ├── parser.rs │ │ │ ├── prompt.rs │ │ │ ├── provider.rs │ │ │ ├── skill.rs │ │ │ ├── tests.rs │ │ │ └── utils.rs │ │ ├── error.rs │ │ ├── gemini_config.rs │ │ ├── gemini_mcp.rs │ │ ├── init_status.rs │ │ ├── lib.rs │ │ ├── main.rs │ │ ├── mcp/ │ │ │ ├── claude.rs │ │ │ ├── codex.rs │ │ │ ├── gemini.rs │ │ │ ├── mod.rs │ │ │ ├── opencode.rs │ │ │ └── validation.rs │ │ ├── openclaw_config.rs │ │ ├── opencode_config.rs │ │ ├── panic_hook.rs │ │ ├── prompt.rs │ │ ├── prompt_files.rs │ │ ├── provider.rs │ │ ├── provider_defaults.rs │ │ ├── proxy/ │ │ │ ├── body_filter.rs │ │ │ ├── cache_injector.rs │ │ │ ├── circuit_breaker.rs │ │ │ ├── error.rs │ │ │ ├── error_mapper.rs │ │ │ ├── failover_switch.rs │ │ │ ├── forwarder.rs │ │ │ ├── handler_config.rs │ │ │ ├── handler_context.rs │ │ │ ├── handlers.rs │ │ │ ├── health.rs │ │ │ ├── http_client.rs │ │ │ ├── log_codes.rs │ │ │ ├── mod.rs │ │ │ ├── model_mapper.rs │ │ │ ├── provider_router.rs │ │ │ ├── providers/ │ │ │ │ ├── adapter.rs │ │ │ │ ├── auth.rs │ │ │ │ ├── claude.rs │ │ │ │ ├── codex.rs │ │ │ │ ├── copilot_auth.rs │ │ │ │ ├── gemini.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── models/ │ │ │ │ │ ├── anthropic.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── openai.rs │ │ │ │ ├── streaming.rs │ │ │ │ ├── streaming_responses.rs │ │ │ │ ├── transform.rs │ │ │ │ └── transform_responses.rs │ │ │ ├── response_handler.rs │ │ │ ├── response_processor.rs │ │ │ ├── server.rs │ │ │ ├── session.rs │ │ │ ├── thinking_budget_rectifier.rs │ │ │ ├── thinking_optimizer.rs │ │ │ ├── thinking_rectifier.rs │ │ │ ├── types.rs │ │ │ └── usage/ │ │ │ ├── calculator.rs │ │ │ ├── logger.rs │ │ │ ├── mod.rs │ │ │ └── parser.rs │ │ ├── services/ │ │ │ ├── config.rs │ │ │ ├── env_checker.rs │ │ │ ├── env_manager.rs │ │ │ ├── mcp.rs │ │ │ ├── mod.rs │ │ │ ├── omo.rs │ │ │ ├── prompt.rs │ │ │ ├── provider/ │ │ │ │ ├── endpoints.rs │ │ │ │ ├── gemini_auth.rs │ │ │ │ ├── live.rs │ │ │ │ ├── mod.rs │ │ │ │ └── usage.rs │ │ │ ├── proxy.rs │ │ │ ├── skill.rs │ │ │ ├── speedtest.rs │ │ │ ├── stream_check.rs │ │ │ ├── usage_stats.rs │ │ │ ├── webdav.rs │ │ │ ├── webdav_auto_sync.rs │ │ │ ├── webdav_sync/ │ │ │ │ └── archive.rs │ │ │ └── webdav_sync.rs │ │ ├── session_manager/ │ │ │ ├── mod.rs │ │ │ ├── providers/ │ │ │ │ ├── claude.rs │ │ │ │ ├── codex.rs │ │ │ │ ├── gemini.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── openclaw.rs │ │ │ │ ├── opencode.rs │ │ │ │ └── utils.rs │ │ │ └── terminal/ │ │ │ └── mod.rs │ │ ├── settings.rs │ │ ├── store.rs │ │ ├── tray.rs │ │ └── usage_script.rs │ ├── tauri.conf.json │ ├── tauri.windows.conf.json │ ├── tests/ │ │ ├── app_config_load.rs │ │ ├── app_type_parse.rs │ │ ├── deeplink_import.rs │ │ ├── import_export_sync.rs │ │ ├── mcp_commands.rs │ │ ├── provider_commands.rs │ │ ├── provider_service.rs │ │ ├── proxy_commands.rs │ │ ├── skill_sync.rs │ │ └── support.rs │ └── wix/ │ └── per-user-main.wxs ├── tailwind.config.cjs ├── tests/ │ ├── components/ │ │ ├── AddProviderDialog.test.tsx │ │ ├── CommonConfigModalBehavior.test.tsx │ │ ├── GlobalProxySettings.test.tsx │ │ ├── ImportExportSection.test.tsx │ │ ├── McpFormModal.test.tsx │ │ ├── OmoFormFields.mergeCustomModelsIntoStore.test.ts │ │ ├── ProviderList.test.tsx │ │ ├── SessionManagerPage.test.tsx │ │ ├── SettingsDialog.test.tsx │ │ ├── UnifiedSkillsPanel.test.tsx │ │ ├── WebdavSyncSection.test.tsx │ │ └── openclaw.utils.test.ts │ ├── config/ │ │ ├── claudeProviderPresets.test.ts │ │ └── opencodeProviderPresets.test.ts │ ├── hooks/ │ │ ├── useCommonConfigSave.test.tsx │ │ ├── useDirectorySettings.test.tsx │ │ ├── useDragSort.test.tsx │ │ ├── useImportExport.extra.test.tsx │ │ ├── useImportExport.test.tsx │ │ ├── useMcpValidation.test.tsx │ │ ├── useProviderActions.test.tsx │ │ ├── useProxyStatus.test.tsx │ │ ├── useSettings.test.tsx │ │ ├── useSettingsForm.test.tsx │ │ └── useSettingsMetadata.test.tsx │ ├── integration/ │ │ ├── App.test.tsx │ │ └── SettingsDialog.test.tsx │ ├── msw/ │ │ ├── handlers.ts │ │ ├── server.ts │ │ ├── state.ts │ │ └── tauriMocks.ts │ ├── setupGlobals.ts │ ├── setupTests.ts │ └── utils/ │ ├── omoConfig.test.ts │ ├── providerConfigUtils.codex.test.ts │ ├── providerMetaUtils.test.ts │ └── testQueryClient.ts ├── tsconfig.json ├── tsconfig.node.json ├── vite.config.ts └── vitest.config.ts ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitattributes ================================================ # Auto detect text files and perform LF normalization * text=auto # Explicitly declare text files you want to always be normalized and converted # to native line endings on checkout. *.rs text eol=lf *.toml text eol=lf *.json text eol=lf *.md text eol=lf *.yml text eol=lf *.yaml text eol=lf *.txt text eol=lf # TypeScript/JavaScript files *.ts text eol=lf *.tsx text eol=lf *.js text eol=lf *.jsx text eol=lf # HTML/CSS files *.html text eol=lf *.css text eol=lf *.scss text eol=lf # Shell scripts *.sh text eol=lf # Denote all files that are truly binary and should not be modified. *.png binary *.jpg binary *.jpeg binary *.gif binary *.ico binary *.woff binary *.woff2 binary *.ttf binary *.exe binary *.dll binary ================================================ FILE: .gitignore ================================================ node_modules/ dist/ release/ .DS_Store *.log .env .env.local *.tsbuildinfo .npmrc CLAUDE.md # AGENTS.md GEMINI.md /.claude /.codex /.gemini /.cc-switch /.idea /.vscode vitest-report.json nul # Flatpak build artifacts flatpak/cc-switch.deb flatpak-build/ flatpak-repo/ .worktrees/ .spec-workflow/ copilot-api .history CODEBUDDY.md .github ================================================ FILE: .node-version ================================================ 22.12.0 ================================================ FILE: CHANGELOG.md ================================================ # Changelog All notable changes to CC Switch will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [3.12.3] - 2026-03-15 Post-v3.12.2 work adds a Tool Search domain restriction bypass, skill backup/restore lifecycle, proxy compatibility for OpenAI o-series models and gzip compression, and robustness fixes for Skills import, provider forms, and terminal session restore. **Stats**: 17 commits | 61 files changed | +3,335 insertions | -194 deletions ### Added - **Tool Search Domain Bypass**: Added setting to bypass Claude CLI Tool Search domain whitelist via equal-length binary patching; backups stored in `~/.cc-switch/toolsearch-backups/` with auto-reapply on startup when enabled - **Skill Auto-Backup**: Skill files are automatically backed up to `~/.cc-switch/skill-backups/` before uninstall, with metadata preserved in `meta.json`; old backups pruned to keep at most 20 - **Skill Backup Restore & Delete**: Added list/restore/delete commands for skill backups; restore copies files back to SSOT, saves the DB record, and syncs to the current app with rollback on failure ### Changed - **Proxy Gzip Compression**: Non-streaming proxy requests now auto-negotiate gzip compression instead of forcing `identity`; streaming requests conservatively keep `identity` to avoid SSE decompression errors - **o1/o3 Model Compatibility**: Chat Completions proxy forwarding now correctly uses `max_completion_tokens` instead of `max_tokens` for OpenAI o-series models such as o1/o3/o4-mini (#1451) - **OpenCode Model Variants**: Placed OpenCode model variants at top level instead of inside options for better discoverability (#1317) - **Skills Import Flow**: Replaced implicit filesystem-based app inference with explicit `ImportSkillSelection` to prevent incorrect multi-app activation; added reconciliation to remove disabled/orphaned symlinks and MCP servers from live config ### Fixed - **o-series Responses API Tokens**: Kept Responses API on the correct `max_output_tokens` field for o-series models instead of incorrectly injecting `max_completion_tokens` - **Provider Form Double Submit**: Prevented duplicate submissions on rapid button clicks in provider add/edit forms (#1352) - **Ghostty Session Restore**: Fixed Claude session restore in Ghostty terminal (#1506, thanks @canyonsehun) - **Skill ZIP Import Extension**: Added `.skill` file extension support in ZIP import dialog (#1240, #1455) - **Skill ZIP Install Target App**: ZIP skill installs now use the currently active app instead of always defaulting to Claude - **OpenClaw Active Card Highlight**: Fixed active OpenClaw provider card not being highlighted (#1419) - **Responsive Layout with TOC**: Improved responsive design when TOC title exists (#1491) - **Import Skills Dialog White Screen**: Added missing TooltipProvider in ImportSkillsDialog to prevent runtime crash when opening the dialog - **Panel Bottom Blank Area**: Replaced hardcoded `h-[calc(100vh-8rem)]` with `flex-1 min-h-0` across all content panels to eliminate bottom gap caused by mismatched offset values --- ## [3.12.2] - 2026-03-12 Post-v3.12.1 work focuses on Common Config safety during proxy takeover and more reliable Codex TOML editing. **Stats**: 5 commits | 22 files changed | +1,716 insertions | -288 deletions ### Added - **Empty State Guidance**: Improved first-run experience with detailed import instructions and a conditional Common Config snippet hint for Claude/Codex/Gemini providers ### Changed - **Proxy Takeover Restore Flow**: Proxy takeover hot-switch and provider sync now refresh the restore backup instead of overwriting live config files, rebuilding effective provider settings with Common Config applied so rollback preserves the real user configuration - **Codex TOML Editing Engine**: Refactored Codex `config.toml` updates onto shared section-aware TOML helpers in Rust and TypeScript, covering `base_url` and `model` field edits across provider forms and takeover cleanup - **Common Config Initialization Lifecycle**: Startup now auto-extracts Common Config snippets from clean live configs before takeover restoration, tracks explicit "snippet cleared" state, and persists a one-time legacy migration flag to avoid repeated backfills ### Fixed - **Common Config Loss During Takeover**: Fixed cases where proxy takeover could drop Common Config changes, overwrite live configs during sync, or produce incomplete restore snapshots when switching providers - **Codex Restore Snapshot Preservation**: Fixed Codex takeover restore backups so existing `mcp_servers` blocks survive provider hot-switches instead of being discarded; changed MCP backup preservation from wholesale table replacement to per-server-id merge so provider/common-config MCP updates win on conflict while live-only servers are retained - **Cleared Snippet Resurrection**: Fixed startup auto-extraction recreating Common Config snippets that users had intentionally cleared - **Codex `base_url` Misplacement**: Fixed Codex `base_url` extraction and editing to target the active `[model_providers.]` section instead of appending to the file tail or confusing `mcp_servers.*.base_url` entries for provider endpoints --- ## [3.12.1] - 2026-03-12 ### Patch Release Stability-focused patch release fixing the Common Config modal infinite reopen loop, a WebDAV sync foreign key constraint failure, several i18n interpolation issues, and a Windows toolbar compact mode bug. Also adds **StepFun** provider presets, **OpenClaw input type selection** and **authHeader** support, upgrades Gemini to **3.1-pro**, and welcomes four new sponsor partners. **Stats**: 19 commits | 56 files changed | +1,429 insertions | -396 deletions ### Added #### Provider Presets - **StepFun**: Added StepFun (阶跃星辰) provider presets including the step-3.5-flash model across supported applications (#1369, thanks @hengm3467) #### OpenClaw Enhancements - **Input Type Selection**: Added input type selection dropdown for model Advanced Options in OpenClaw configuration form (#1368, thanks @liuxxxu) - **authHeader Field**: Added optional `authHeader` boolean to OpenClawProviderConfig for vendor-specific auth header support (e.g. Longcat), and refactored form state to reuse the shared type #### Sponsor Partners - **Micu API**: Added Micu API as sponsor partner with affiliate links - **XCodeAPI**: Added XCodeAPI as sponsor partner - **SiliconFlow**: Added SiliconFlow (硅基流动) as sponsor partner with affiliate links - **CTok**: Added CTok as sponsor partner ### Changed - **UCloud → Compshare**: Renamed UCloud provider to Compshare (优云智算) with full i18n support across all three locales (EN/ZH/JA) - **Compshare Links**: Updated Compshare sponsor registration links to coding-plan page - **Gemini Model Upgrade**: Upgraded default Gemini model from 2.5-pro to 3.1-pro in provider presets ### Fixed #### Common Config & UI - **Common Config Modal Loop**: Fixed an infinite reopen loop in the Common Config modal and added draft editing support to prevent data loss during edits - **Toolbar Compact Mode (Windows)**: Fixed toolbar compact mode not triggering on Windows due to left-side overflow (#1375, thanks @zuoliangyu) - **Session Search Index**: Fixed session search index not syncing with query data, causing stale list display after session deletion #### Sync & Data - **WebDAV Provider Health FK**: Fixed foreign key constraint failure when restoring `provider_health` table during WebDAV sync #### Provider & Preset - **Longcat authHeader**: Added missing `authHeader: true` to Longcat provider preset (#1377, thanks @wavever) - **OpenClaw Tool Permissions**: Aligned OpenClaw tool permission profiles with upstream schema (#1355, thanks @bigsongeth) - **X-Code API URL**: Corrected X-Code API URL from `www.x-code.cn` to `x-code.cc` #### i18n & Localization - **Stream Check Toast**: Fixed stream check toast i18n interpolation keys not matching translation placeholders - **Proxy Startup Toast**: Fixed proxy startup toast not interpolating address and port values (#1399, thanks @Mason-mengze) - **OpenCode API Format Label**: Renamed OpenCode API format label from "OpenAI" to "OpenAI Responses" for accuracy --- ## [3.12.0] - 2026-03-09 ### Feature Release This release restores the **Model Health Check (Stream Check)** UI, adds **OpenAI Responses API** format conversion, introduces the **Bedrock Optimizer** for thinking + cache injection, expands provider presets (Ucloud, Micu, X-Code API, Novita, Bailian For Coding), overhauls **OpenClaw config panels** with a JSON5 round-trip write engine, enhances **WebDAV sync** with dual-layer versioning, and delivers a comprehensive **i18n audit** fixing 69 missing keys alongside 20+ bug fixes. **Stats**: 56 commits | 221 files changed | +20,582 insertions | -8,026 deletions ### Added #### Stream Check (Model Health Check) - **Restore Stream Check UI**: Brought back the model health check (Stream Check) panel for testing provider endpoint availability with live streaming validation - **First-Run Confirmation**: Added a confirmation dialog on first use of Stream Check to inform users about the feature's purpose and network requests - **OpenAI Chat Format Support**: Stream Check now supports `openai_chat` api_format, enabling health checks for providers using OpenAI-compatible endpoints #### OpenAI Responses API - **Responses API Format Conversion**: New `api_format = "openai_responses"` option enabling Anthropic Messages ↔ OpenAI Responses API bidirectional conversion for providers that implement the Responses API - **Responses API Deduplication**: Deduplicated and improved the Responses API conversion logic, consolidating shared transformation code #### Bedrock Optimizer - **Bedrock Request Optimizer**: PRE-SEND optimizer that injects thinking parameters and cache control blocks into AWS Bedrock requests, enabling extended thinking and prompt caching on Bedrock endpoints (#1301) #### OpenClaw Enhancements - **JSON5 Round-Trip Write Engine**: Overhauled OpenClaw config panels with a JSON5 round-trip write engine that preserves comments, formatting, and ordering when saving configuration changes - **Config Panel Improvements**: Redesigned EnvPanel as a full JSON editor, added `tools.profile` selection to ToolsPanel, introduced OpenClawHealthBanner for config validation warnings, and added legacy timeout migration support in Agents Defaults - **Agent Model Dropdown**: Replaced text inputs with dropdown selects for OpenClaw agent model configuration, offering a curated list of available models - **User-Agent Toggle**: Added a User-Agent header toggle for OpenClaw, defaulting to off to avoid potential compatibility issues with certain providers #### Provider Presets - **Ucloud**: Added Ucloud partner provider preset for Claude, Codex, and OpenClaw with endpointCandidates, unified apiKeyUrl, refreshed model defaults, and OpenClaw `templateValues` / `suggestedDefaults` - **Micu**: Added Micu partner provider preset for Claude, Codex, OpenClaw, and OpenCode with OpenClaw `templateValues` / `suggestedDefaults` - **X-Code API**: Added X-Code API partner provider preset for Claude, Codex, and OpenCode with endpointCandidates - **Novita**: Added Novita provider presets and icon across all supported apps (#1192) - **Bailian For Coding**: Added Bailian For Coding preset configuration (#1263) - **SiliconFlow Partner Badge**: Added partner badge designation for SiliconFlow provider presets - **Model Role Badges**: Added model role badges (e.g., Opus, Sonnet) to provider presets and reordered presets to prioritize Opus models #### WebDAV Sync - **Dual-Layer Versioning**: Added protocol v2 + db-v6 dual-layer versioning to WebDAV sync, enabling backward-compatible sync format evolution and automatic migration detection - **Auto-Sync Confirmation**: Added a confirmation dialog when toggling WebDAV auto-sync on/off to prevent accidental changes #### Usage & Data - **Daily Rollups & Auto-Vacuum**: Added usage daily rollups for aggregated statistics, incremental auto-vacuum for storage management, and sync-aware backup that coordinates with WebDAV sync cycles - **UsageFooter Extra Fields**: Added extra field display in UsageFooter component for normal mode, showing additional usage metadata (#1137) #### Session Management - **Session Deletion**: Added session deletion with per-provider cleanup and path safety validation, allowing users to remove individual conversation sessions #### UI & Config - **Auth Field Selector**: Restored Claude provider auth field selector supporting both AUTH_TOKEN and API_KEY authentication modes - **Failover Toggle**: Moved failover toggle to display independently on the main page with a confirmation dialog for enabling/disabling - **Common Config Auto-Extract**: Auto-extract Common Config Snippets from live configuration files on first run, seeding initial common config without manual setup - **New Provider Page Improvements**: Improved the new provider page with API endpoint and model name fields (#1155) ### Changed #### Architecture - **Common Config Runtime Overlay**: Common Config is now applied as a runtime overlay during provider switching instead of being materialized (merged) into each provider's stored config. This preserves the original provider config in the database and applies common settings dynamically at write time - **First-Run Auto-Extract**: On first run, Common Config Snippets are automatically extracted from the current live configuration files, eliminating the need for manual initial setup ### Fixed #### Proxy & Streaming - **OpenAI Streaming Conversion**: Fixed OpenAI ChatCompletion → Anthropic Messages streaming conversion that could produce malformed events under certain response structures - **Codex /responses/compact Route**: Added support for Codex `/responses/compact` route in proxy forwarding (#1194) - **Codex Common Config TOML Merge**: Fixed Codex Common Config to use structural TOML merge/subset instead of raw string comparison, correctly handling key ordering and formatting differences - **Proxy Forwarder Failure Logs**: Improved proxy forwarder failure logging with more descriptive error messages #### Provider & Preset - **X-Code Rename**: Renamed "X-Code" provider to "X-Code API" for consistency with the official branding - **SSSAiCode Missing /v1**: Added missing `/v1` path to SSSAiCode default endpoint for Codex and OpenCode - **AICoding URL Fix**: Removed `www` prefix from aicoding.sh provider URLs to match the correct domain - **New Provider Page Input Handling**: Fixed the new provider page so API endpoint / model fields handle line-break deletion correctly and added the missing `codexConfig.modelNameHint` i18n key for zh/en/ja #### Platform - **Cache Hit Token Statistics**: Fixed missing token statistics for cache hits in streaming responses (#1244) - **Minimize-to-Tray Auto Exit**: Fixed issue where the application would automatically exit after being minimized to the system tray for a period of time (#1245) #### i18n & Localization - **Comprehensive i18n Audit**: Added 69 missing i18n keys and fixed hardcoded Chinese strings across the application, improving localization coverage for all three languages (zh/en/ja) - **Model Test Panel i18n**: Corrected i18n key paths for model test panel title and description - **JSON5 Slash Escaping**: Normalized JSON5 slash escaping and added i18n support for OpenClaw panel labels #### UI - **Skills Count Display**: Fixed skills count not displaying correctly when adding new skills (#1295) - **Endpoint Speed Test**: Removed HTTP status code display from endpoint speed test results to reduce visual noise - **Outline Button Text Tone**: Aligned outline button text color tone with usage refresh control for visual consistency (#1222) ### Performance - **OpenClaw Config Write Skip**: Skip backup and atomic write when OpenClaw configuration content is unchanged, avoiding unnecessary I/O operations ### Documentation - **User Manual i18n**: Restructured user manual for internationalization and added complete EN/JA translations alongside the existing ZH documentation - **User Manual OpenClaw**: Added OpenClaw coverage and completed settings documentation for the user manual - **UCloud CompShare Sponsor**: Added UCloud CompShare as a sponsor partner - **Docs Directory Reorganization**: Reorganized docs directory structure, added user manual links to all three README files, removed cross-language links from user manual sections, and synced README features across EN/ZH/JA ### Maintenance - **Periodic Maintenance Timer**: Consolidated periodic maintenance timers into a unified scheduler, combining vacuum and rollup operations into a single timer - **OpenClaw Save Toast**: Removed backup path display from OpenClaw save toasts for cleaner notification messages --- ## [3.11.1] - 2026-02-28 ### Hotfix Release This release reverts the Partial Key-Field Merging architecture introduced in v3.11.0, restoring the proven "full config overwrite + Common Config Snippet" mechanism, and fixes several UI and platform compatibility issues. **Stats**: 8 commits | 52 files changed | +3,948 insertions | -1,411 deletions ### Reverted - **Restore Full Config Overwrite + Common Config Snippet** (revert 992dda5c): Reverted the partial key-field merging refactoring from v3.11.0 due to critical issues — non-whitelisted custom fields were lost during provider switching, backfill permanently stripped non-key fields from the database, and the whitelist required constant maintenance. Restores full config snapshot write, Common Config Snippet UI and backend commands, and 6 frontend components/hooks ### Changed - **Proxy Panel Layout**: Moved proxy on/off toggle from accordion header into panel content area, placed directly above app takeover options, ensuring users see takeover configuration immediately after enabling the proxy - **Manual Import for OpenCode/OpenClaw**: Removed auto-import on startup; empty state now shows an "Import Current Config" button, consistent with Claude/Codex/Gemini behavior ### Fixed - **"Follow System" Theme Not Auto-Updating**: Delegated to Tauri's native theme tracking (`set_window_theme(None)`) so the WebView's `prefers-color-scheme` media query stays in sync with OS theme changes - **Compact Mode Cannot Exit**: Restored `flex-1` on `toolbarRef` so `useAutoCompact`'s exit condition triggers correctly based on available width instead of content width - **Proxy Takeover Toast Shows {{app}}**: Added missing `app` interpolation parameter to i18next `t()` calls for proxy takeover enabled/disabled messages - **Windows Protocol Handler Side Effects**: Disabled environment check and one-click install on Windows to prevent unintended protocol handler registration --- ## [3.11.0] - 2026-02-26 ### Feature Release This release introduces **OpenClaw** as the fifth supported application, a full **Session Manager** for browsing conversation history across all apps, an independent **Backup Management** panel, **Oh My OpenCode (OMO)** integration, and 50+ other features, fixes, and improvements across 147 commits. **Stats**: 147 commits | 274 files changed | +32,179 insertions | -5,467 deletions ### Added #### OpenClaw Support (New Application) - **OpenClaw Integration**: Full management support for OpenClaw as the fifth application in CC Switch, including provider switching, configuration panels (Env / Tools / Agents Defaults), Workspace file management (HEARTBEAT / BOOTSTRAP / BOOT), daily memory files, and additive overlay mode - **OpenClaw Provider Presets**: 13+ built-in provider presets with brand icon and complete i18n (zh/en/ja) - **OpenClaw Form Fields**: Dedicated provider form with providerKey input, model allowlist auto-registration, and default model button - **OpenClaw Config Panels**: Env editor, Tools editor, and Agents Defaults editor backed by JSON5 read/write (`openclaw_config.rs`) #### Session Manager - **Session Manager**: Browse and search conversation history for Claude Code, Codex, Gemini CLI, OpenCode, and OpenClaw with table-of-contents navigation and in-session search - **Session App Filter**: Auto-filter sessions by current app when entering the session page - **Session Performance**: Parallel directory scanning and head-tail JSONL reading for faster session list loading #### Backup Management - **Backup Panel**: Independent backup management panel with configurable backup policy (max count, auto-cleanup) and backup rename support - **Periodic Backup**: Hourly automatic backup timer during runtime - **Pre-Migration Backup**: Automatic backup before database schema migrations with backfill warning - **Delete Backup**: Delete individual backup files with confirmation dialog - **Backup Time Fix**: Use local time instead of UTC for backup file names #### Oh My OpenCode (OMO) - **OMO Integration**: Full Oh My OpenCode config file management with agent model selection, category configuration, and recommended model fill - **OMO Slim**: Lightweight oh-my-opencode-slim mode support with OmoVariant parameterization - **OMO Cross-Exclusion**: Enforce OMO ↔ OMO Slim mutual exclusion at the database level #### Workspace - **Daily Memory Search**: Full-text search across daily memory files with date-sorted display - **Clickable Paths**: Directory paths in workspace panels are now clickable; renamed “Today's Note” to “Add Memory” - **Workspace Files Panel**: Manage bootstrap markdown files for OpenClaw (HEARTBEAT / BOOTSTRAP / BOOT types) #### Provider Presets - **AWS Bedrock**: Support for AKSK and API Key authentication modes (Claude and OpenCode) - **SSAI Code**: Partner provider preset across all five apps - **CrazyRouter**: Partner provider preset with custom icon - **AICoding**: Partner provider preset with i18n promotion text - **Bailian**: Renamed from Qwen Coder with new icon; updated domestic model providers to latest versions #### Proxy & Network - **Thinking Budget Rectifier**: New rectifier for thinking budget parameters with dedicated module (`thinking_budget_rectifier.rs`) - **WebDAV Auto Sync**: Automatic periodic sync with large file protection mechanism #### UI & UX - **Theme Animation**: Circular reveal animation when toggling between light and dark themes - **Claude Quick Toggles**: Quick toggle switches in the Claude config JSON editor for common settings - **Dynamic Endpoint Hint**: Context-aware hint text in endpoint input based on API format selection - **AppSwitcher Auto Compact**: Automatically collapse to compact mode based on available width, with smooth transition animation - **App Transition**: Fade-in/fade-out animation when switching between OpenClaw and other apps - **Silent Startup Conditional**: Show silent startup option only when launch-on-startup is enabled #### Settings & Environment - **First-Run Confirmation**: Confirmation dialogs for proxy and usage features on first use - **Local Proxy Toggle**: `enableLocalProxy` setting to control proxy UI visibility on the home page - **Environment Check**: More granular local environment detection (installed CLI tool versions, Volta path detection) #### Usage & Pricing - **Usage Dashboard Enhancement**: Auto-refresh control, robust formatting, and request log table improvements - **New Model Pricing**: Added pricing data for claude-opus-4-6 and gpt-5.3-codex with incremental data seeding ### Changed #### Architecture - **Partial Key-Field Merging (⚠️ Breaking, reverted in v3.11.1)**: Provider switching now uses partial key-field merging instead of full config overwrite, preserving user's non-provider settings (plugins, MCP, permissions). The "Common Config Snippet" feature has been removed as it is no longer needed. Removes 6 frontend files and ~150 lines of backend dead code (#1098) - **Manual Import**: Replaced auto-import on startup with manual “Import Current Config” button in empty state, reducing ~47 lines of startup code - **OMO Variant Parameterization**: Eliminated ~250 lines of OMO/OMO Slim code duplication via `OmoVariant` struct with STANDARD/SLIM constants - **OMO Common Config Removal**: Removed the two-layer merge system for OMO common config (-1,733 lines across 21 files) #### Code Quality - **ProviderForm Decomposition**: Extracted ProviderForm.tsx from 2,227 lines to 1,526 lines by splitting into 5 focused modules (opencodeFormUtils, useOmoModelSource, useOpencodeFormState, useOmoDraftState, useOpenclawFormState) - **Shared MCP/Skills Components**: Extracted AppCountBar, AppToggleGroup, and ListItemRow shared components to eliminate duplication across MCP and Skills panels - **OpenClaw TanStack Query Migration**: Migrated Env, Tools, and AgentsDefaults panels from manual useState/useEffect to centralized TanStack Query hooks #### Settings Layout - **Proxy Tab**: Split Advanced tab into dedicated Proxy tab (local proxy, failover, rectifiers, global outbound proxy); moved pricing config to Usage dashboard as collapsible accordion. SettingsPage reduced from ~716 to ~426 lines with 5-tab layout: General | Proxy | Advanced | Usage | About - **Data Section Split**: Split data accordion into Import/Export and Cloud Sync sections for better discoverability #### Terminal & Config - **Unified Terminal Selection**: Consolidated terminal preference to global settings; added WezTerm support and terminal name mapping (iterm2 → iterm) - **OpenClaw Agents Panel**: Primary model field set to read-only; detailed model fields (context window, max tokens, reasoning, cost) moved to advanced options - **Claude Model Update**: Updated Claude model references from 4.5 to 4.6 across all provider presets ### Fixed #### Critical - **Windows Home Dir Regression**: Restored default home directory resolution on Windows to prevent providers/settings “disappearing” when `HOME` env var differs from the real user profile directory (Git/MSYS environments); auto-detects v3.10.3 legacy database location - **Linux White Screen**: Disabled WebKitGTK hardware acceleration on AMD GPUs (Cezanne/Radeon Vega) to prevent EGL initialization failure causing blank screen on startup - **OpenAI Beta Parameter**: Stopped appending `?beta=true` to OpenAI Chat Completions endpoints, fixing request failures for Nvidia and other `apiFormat=”openai_chat”` providers - **Health Check Auth Mode**: Health check now respects provider's auth_mode setting instead of always using x-api-key header #### Provider & Preset - **OpenClaw /v1 Prefix**: Removed /v1 prefix from OpenClaw anthropic-messages presets to prevent double path (/v1/v1/messages) with Anthropic SDK auto-append - **Opus Pricing**: Corrected Opus pricing from $15/$75 to $5/$25 and upgraded model ID to claude-opus-4-6 - **AIGoCode URLs**: Unified API base URL to https://api.aigocode.com across all apps; removed trailing /v1 suffix - **Zhipu GLM**: Removed outdated partner status from Claude, OpenCode, and OpenClaw presets - **API Key Visibility**: Restored API Key input field when creating new Claude providers (was incorrectly hidden for non-cloud_provider categories) #### OMO / OMO Slim - **OMO Slim Category Checks**: Added missing omo-slim category checks across add/form/mutation paths - **OMO Slim Cache Invalidation**: Invalidate OMO Slim query cache after provider mutations to prevent stale UI state - **OMO Recommended Models**: Synced agent/category recommended models with upstream sources; fixed provider/model format to pure model IDs - **OMO Fill Feedback**: Added toast feedback when “Fill Recommended” button silently fails - **OMO Last-Provider Restriction**: Removed last-provider deletion restriction for OMO/OMO Slim plugins - **OpenCode Model Validation**: Reject saving OpenCode providers without at least one configured model #### OpenClaw - **OpenClaw P0-P3 Fixes**: Fixed 25 missing i18n keys, replaced key={index} with stable crypto.randomUUID(), excluded openclaw from ProxyToggle/FailoverToggle, added deep link merge_additive_config(), unified serde(flatten) naming, added directory existence checks, removed dead code, added duplicate key validation - **OpenClaw Robustness**: Fixed EnvPanel visibleKeys using entry key names instead of array indices; added NaN guards; validated provider ID and model before import - **OpenClaw i18n Dedup**: Merged duplicate openclaw i18n keys to restore provider form translations #### Platform - **Window Flash**: Prevented window flicker on silent startup (Windows) - **Title Bar Theme**: Title bar now follows dark/light mode theme changes - **Skills Path Separator**: Fixed path separator matching for skill installation status on Windows (supports both `/` and `\`) - **WSL Conditional Compilation**: Added `#[cfg(target_os = “windows”)]` to WSL helper functions to eliminate dead_code warnings on non-Windows platforms #### UI - **Toolbar Clipping**: Removed toolbar height limit that was clipping AppSwitcher - **Update Badge**: Show update badge instead of green check when a newer version is available - **Session Button Visibility**: Only show Session Manager button for Claude and Codex apps - **Directory Spacing**: Added vertical spacing between directory setting sections - **Dark Mode Cards**: Unified SQL import/export card styling in dark mode - **OpenClaw Scroll**: Enabled scrolling for OpenClaw configuration panel content #### i18n & Localization - **Session Manager i18n**: Replaced hardcoded Chinese strings with i18n keys for relative time, role labels, and UI elements - **OpenClaw Default Model Label**: Renamed “Enable/Default” to “Set as Default / Current Default” with wider button - **Daily Memory Sort**: Sort daily memory files by filename date (YYYY-MM-DD.md) instead of modification time - **Backup Name i18n**: Use local time for backup file names #### Other - **Skill Doc URL**: Use actual branch from download_repo for documentation URL; switched from /tree/ to /blob/ pointing to SKILL.md - **OpenCode Install Detection**: Added install.sh priority paths (OPENCODE_INSTALL_DIR > XDG_BIN_DIR > ~/bin > ~/.opencode/bin) with path dedup and cross-platform executable candidates - **Provider Auto-Import**: Removed auto-import side effect from useProvidersQuery queryFn; users now trigger import manually via empty state button - **Manual Backup Validation**: Treat missing database file as error during manual backup to prevent false success toast ### Performance - **Session Panel Loading**: Parallel directory scanning and head-tail JSONL reading for Codex, OpenClaw, and OpenCode session providers - **Query Cache Cleanup**: Removed unnecessary TanStack Query cache overhead for Tauri local IPC calls ### Documentation - **Sponsors**: Added/updated SSSAiCode, Crazyrouter, AICoding, Right Code, and MiniMax sponsor entries across all README languages - **User Manual**: Added user manual documentation (#979) ### Maintenance - **Pre-Release Cleanup**: Removed debug logs, fixed clippy warnings, added missing Japanese translations, and formatted code - **UI Exclusions**: Hidden MCP, Skills, proxy/pricing, stream check, and model test panels for OpenClaw where not applicable --- ## [3.10.3] - 2026-01-30 ### Feature Release This release introduces a generic API format selector, pricing configuration enhancements, and multiple UX improvements. ### Added - **API Key Link for OpenCode**: API key link support for OpenCode provider form, enabling quick access to provider key management pages - **AICodeMirror Partner Preset**: Added AICodeMirror partner preset for all apps (Claude, Codex, Gemini, OpenCode) - **API Format Selector**: Generic API format chooser for Claude providers, replacing the OpenRouter-specific toggle. Supports Anthropic Messages (native) and OpenAI Chat Completions format - **API Format Presets**: Allow preset providers to specify API format (anthropic or openai_chat) for third-party proxy services - **Proxy Hint**: Display info toast when switching to OpenAI Chat format provider, reminding users to enable proxy - **Pricing Config Enhancement**: Per-provider cost multiplier, pricing model source (request/response), request model logging, and enriched usage UI (#781) - **Skills ZIP Install**: Install skills directly from local ZIP files with recursive scanning support - **Preferred Terminal**: Choose preferred terminal app per platform (macOS: Terminal.app/iTerm2/Alacritty/Kitty/Ghostty; Windows: cmd/PowerShell/Windows Terminal; Linux: GNOME Terminal/Konsole/Xfce4/Alacritty/Kitty/Ghostty) - **Silent Startup**: Option to prevent window popup on launch (#713) - **OpenCode Environment Check**: Version detection with Go path scanning and one-click install from GitHub Releases - **OpenCode Directory Sync**: Auto-sync all providers to live config on directory change with additive mode support - **NVIDIA NIM Preset**: New provider preset for Claude and OpenCode with nvidia.svg icon - **n1n.ai Preset**: New provider preset (#667) - **Update Badge Icon**: Replace update badge dot with ArrowUpCircle icon - **Linux ARM64**: CI build support for Linux ARM64 architecture ### Changed - **API Format Migration**: Migrate api_format from settings_config to ProviderMeta to prevent polluting ~/.claude/settings.json - **DeepSeek max_tokens**: Remove max_tokens clamp from proxy transform layer - **Terminal Functions**: Consolidate redundant terminal launch functions - **Home Dir Utility**: Consolidate get_home_dir into single public function - **Kimi/Moonshot**: Upgrade provider presets to k2.5 model ### Fixed - **Codex 404 & Timeout**: Fix 404 errors and connection timeout with custom base_url; improve /v1 prefix handling and system proxy detection (#760) - **Proxy URL Building**: Fix duplicate /v1/v1 in URL; extend ?beta=true to /v1/chat/completions endpoint - **OpenRouter Compat Mode**: Improve backward compatibility supporting number and string types - **Gemini Visibility**: Correct Gemini default visibility to true (#818) - **Footer Layout**: Correct footer layout in advanced settings tab - **Claude Code Detection**: Prioritize native install path for detection - **Tray Menu**: Simplify title labels and optimize menu separators (#796) - **Duplicate Skills**: Prevent duplicate skill installation from different repos (#778) - **Windows Tests**: Stabilize test environment (#644) - **i18n**: Update apiFormatOpenAIChat label to mention proxy requirement - **Error Display**: Use extractErrorMessage for complete error display in mutations - **Sponsors**: Add AICodeMirror and reorder sponsor list --- ## [3.10.2] - 2026-01-24 ### Patch Release This maintenance release adds skill sync options and includes important bug fixes. ### Added - **Skills**: Add skill sync method setting with symlink/copy options - **Partners**: Add RightCode as official partner ### Fixed - **Prompts**: Clear prompt file when all prompts are disabled - **OpenCode**: Preserve extra model fields during serialization - **Provider Form**: Backfill model fields when editing Claude provider --- ## [3.10.1] - 2026-01-23 ### Patch Release This maintenance release includes important bug fixes for Windows platform, UI improvements, and code quality enhancements. ### Added - **Provider Icons**: Updated RightCode provider icon with improved visual design ### Changed - **Proxy Rectifier**: Changed rectifier default state to disabled for better stability - **Window Settings**: Reordered window settings and updated default values for improved UX - **UI Layout**: Increased app icon collapse threshold from 3 to 4 icons - **Code Quality**: Simplified `RectifierConfig` implementation using `#[derive(Default)]` ### Fixed - **Windows Platform**: - Fixed terminal window closing immediately after execution on Windows - Corrected OpenCode config path resolution on Windows - **UI Improvements**: - Fixed ProviderIcon color validation to prevent black icons from appearing - Unified layout padding across all panels for consistent spacing - Fixed panel content alignment with header constraints - **Code Quality**: Resolved Rust Clippy warnings and applied consistent formatting --- ## [3.10.0] - 2026-01-21 ### Feature Release This release introduces OpenCode support and brings improvements across proxy, usage tracking, and overall UX. ### Added - **OpenCode Support** - Manage OpenCode providers, MCP servers, and Skills, with first-launch import and full internationalization (#695) - **Global Proxy** - Add global proxy settings for outbound network requests (#596) - **Claude Rectifier** - Add thinking signature rectifier for Claude API (#595) - **Health Check Enhancements** - Configurable prompt and CLI-compatible requests for stream health check (#623) - **Per-Provider Config** - Support provider-specific configuration and persistence (#663) - **App Visibility Controls** - Show/hide apps and keep tray menu in sync (Gemini hidden by default) - **Takeover Compact Mode** - Use a compact AppSwitcher layout when showing 3+ visible apps - **Keyboard Shortcut** - Press `ESC` to quickly go back/close panels (#670) - **Terminal Improvements** - Provider-specific terminal button, `fnm` path support, and safer cross-platform launching (#564) - **WSL Tool Detection** - Detect tool versions in WSL with additional security hardening (#627) - **Skills Presets** - Add `baoyu-skills` preset repo and auto-supplement missing default repos ### Changed - **Proxy Logging** - Simplify proxy log output (#585) - **Pricing Editor UX** - Unify pricing edit modal with `FullScreenPanel` - **Advanced Settings Layout** - Move rectifier section below failover for better flow - **OpenRouter Compat Mode** - Disable OpenRouter compatibility mode by default and hide UI toggle ### Fixed - **Auto Failover** - Switch to P1 immediately when enabling auto failover - **Provider Edit Dialog** - Fix stale data when reopening provider editor after save (#654) - **Deeplink** - Support multiple endpoints and prioritize `GOOGLE_GEMINI_BASE_URL` over `GEMINI_BASE_URL` (#597) - **MCP (WSL)** - Skip `cmd /c` wrapper for WSL target paths (#592) - **Usage Templates** - Add variable hints and validation fixes; prevent config leaking between providers (#628) - **Gemini Timeout Format** - Convert timeout params to Gemini CLI format (#580) - **UI** - Fix Select dropdown rendering in `FullScreenPanel`; auto-apply default icon color when unset - **Usage UI** - Auto-adapt usage block offset based on action buttons width (#613) - **Provider Endpoint** - Persist endpoint auto-select state (#611) - **Provider Form** - Reset baseUrl and apiKey states when switching presets --- ## [3.9.1] - 2026-01-09 ### Bug Fix Release This release focuses on stability improvements and crash prevention. ### Added - **Crash Logging** - Panic hook captures crash info to `~/.cc-switch/crash.log` with full stack traces (#562) - **Release Logging** - Enable logging for release builds with automatic rotation (keeps 2 most recent files) - **AIGoCode Icon** - Added colored icon for AIGoCode provider preset ### Fixed - **Proxy Panic Prevention** - Graceful degradation when HTTP client initialization fails due to invalid proxy settings; falls back to no_proxy mode (#560) - **UTF-8 Safety** - Fix potential panic when masking API keys or truncating logs containing multi-byte characters (Chinese, emoji, etc.) (#560) - **Default Proxy Port** - Change default port from 5000 to 15721 to avoid conflict with macOS AirPlay Receiver (#560) - **Windows Title** - Display "CC Switch" instead of default "Tauri app" in window title - **Windows/Linux Spacing** - Remove extra 28px blank space below native titlebar introduced in v3.9.0 - **Flatpak Tray Icon** - Bundle libayatana-appindicator for tray icon support on Flatpak (#556) - **Provider Preset** - Correct casing from "AiGoCode" to "AIGoCode" to match official branding --- ## [3.9.0] - 2026-01-07 ### Stable Release This stable release includes all changes from `3.9.0-1`, `3.9.0-2`, and `3.9.0-3`. ### Added - **Local API Proxy** - High-performance local HTTP proxy for Claude Code, Codex, and Gemini CLI (Axum-based) - **Per-App Takeover** - Independently route each app through the proxy with automatic live-config backup/redirect - **Auto Failover** - Circuit breaker + smart failover with independent queues and health tracking per app - **Universal Provider** - Shared provider configurations that can sync to Claude/Codex/Gemini (ideal for API gateways like NewAPI) - **Provider Search Filter** - Quick filter to find providers by name (#435) - **Keyboard Shortcut** - Open settings with Command+comma / Ctrl+comma (#436) - **Deeplink Usage Config** - Import usage query config via deeplink (#400) - **Provider Icon Colors** - Customize provider icon colors (#385) - **Skills Multi-App Support** - Skills now support both Claude Code and Codex (#365) - **Closable Toasts** - Close button for switch toast and all success toasts (#350) - **Skip First-Run Confirmation** - Option to skip Claude Code first-run confirmation dialog - **MCP Import** - Import MCP servers from installed apps - **Common Config Snippet Extraction** - Extract reusable common config snippets from the current provider or editor content (Claude/Codex/Gemini) - **Usage Enhancements** - Model extraction, request logging improvements, cache hit/creation metrics, and auto-refresh (#455, #508) - **Error Request Logging** - Detailed logging for proxy requests (#401) - **Linux Packaging** - Added RPM and Flatpak packaging targets - **Provider Presets & Icons** - Added/updated partner presets and icons (e.g., MiMo, DMXAPI, Cubence) ### Changed - **Usage Terminology** - Rename "Cache Read/Write" to "Cache Hit/Creation" across all languages (#508) - **Model Pricing Data** - Refresh built-in model pricing table (Claude full version IDs, GPT-5 series, Gemini ID formats, and Chinese models) (#508) - **Proxy Header Forwarding** - Switch to a blacklist approach and improve header passthrough compatibility (#508) - **Failover Behavior** - Bypass timeout/retry configs when failover is disabled; update default failover timeout and circuit breaker values (#508, #521) - **Provider Presets** - Update default model versions and change the default Qwen base URL (#517) - **Skills Management** - Unify Skills management architecture with SSOT + React Query; improve caching for discoverable skills - **Settings UX** - Reorder items in the Advanced tab for better discoverability - **Proxy Active Theme** - Apply emerald theme when proxy takeover is active ### Fixed - **Security** - Security fixes for JavaScript executor and usage script (#151) - **Usage Timezone & Parsing** - Fix datetime picker timezone handling; improve token parsing/billing for Gemini and Codex formats (#508) - **Windows Compatibility** - Improve MCP export and version check behavior to avoid terminal popups - **Windows Startup** - Use system titlebar to prevent black screen on startup - **WebView Compatibility** - Add fallback for crypto.randomUUID() on older WebViews - **macOS Autostart** - Use `.app` bundle path to prevent terminal window popups - **Database** - Add missing schema migrations; show an error dialog on initialization failure with a retry option - **Import/Export** - Restrict SQL import to CC Switch exported backups only; refresh providers immediately after import - **Prompts** - Allow saving prompts with empty content - **MCP Sync** - Skip sync when the target CLI app is not installed - **Common Config (Codex)** - Preserve MCP server `base_url` during extraction and remove provider-specific `model_providers` blocks - **Proxy** - Improve takeover detection and stability; clean up model override env vars when switching providers in takeover mode (#508) - **Skills** - Skip hidden directories during discovery; fix wrong skill repo branch - **Settings Navigation** - Navigate to About tab when clicking update badge - **UI** - Fix dialogs not opening on first click and improve window dragging area in `FullScreenPanel` --- ## [3.9.0-3] - 2025-12-29 ### Beta Release Third beta release with important bug fixes for Windows compatibility, UI improvements, and new features. ### Added - **Universal Provider** - Support for universal provider configurations (#348) - **Provider Search Filter** - Quick filter to find providers by name (#435) - **Keyboard Shortcut** - Open settings with Command+comma / Ctrl+comma (#436) - **Xiaomi MiMo Icon** - Added MiMo icon and Claude provider configuration (#470) - **Usage Model Extraction** - Extract model info from usage statistics (#455) - **Skip First-Run Confirmation** - Option to skip Claude Code first-run confirmation dialog - **Exit Animations** - Added exit animation to FullScreenPanel dialogs - **Fade Transitions** - Smooth fade transitions for app/view/panel switching ### Fixed #### Windows - Wrap npx/npm commands with `cmd /c` for MCP export - Prevent terminal windows from appearing during version check #### macOS - Use .app bundle path for autostart to prevent terminal window popup #### UI - Resolve Dialog/Modal not opening on first click (#492) - Improve dark mode text contrast for form labels - Reduce header spacing and fix layout shift on view switch - Prevent header layout shift when switching views #### Database & Schema - Add missing base columns migration for proxy_config - Add backward compatibility check for proxy_config seed insert #### Other - Use local timezone and robust DST handling in usage stats (#500) - Remove deprecated `sync_enabled_to_codex` call - Gracefully handle invalid Codex config.toml during MCP sync - Add missing translations for reasoning model and OpenRouter compat mode ### Improved - **macOS Tray** - Use macOS tray template icon - **Header Alignment** - Remove macOS titlebar tint, align custom header - **Shadow Removal** - Cleaner UI by removing shadow styles - **Code Inspector** - Added code-inspector-plugin for development - **i18n** - Complete internationalization for usage panel and settings - **Sponsor Logos** - Made sponsor logos clickable ### Stats - 35 commits since v3.9.0-2 - 5 files changed in test/lint fixes --- ## [3.9.0-2] - 2025-12-20 ### Beta Release Second beta release focusing on proxy stability, import safety, and provider preset polish. ### Added - **DMXAPI Partner** - Added DMXAPI as an official partner provider preset - **Provider Icons** - Added provider icons for OpenRouter, LongCat, ModelScope, and AiHubMix ### Changed - **Proxy (OpenRouter)** - Switched OpenRouter to passthrough mode for native Claude API ### Fixed - **Import/Export** - Restrict SQL import to CC Switch exported backups only; refresh providers immediately after import - **Proxy** - Respect existing Claude token when syncing; add fallback recovery for orphaned takeover state; remove global auto-start flag - **Windows** - Add minimum window size to Windows platform config - **UI** - Improve About section UI (#419) and unify header toolbar styling ### Stats - 13 commits since v3.9.0-1 --- ## [3.9.0-1] - 2025-12-18 ### Beta Release This beta release introduces the **Local API Proxy** feature, along with Skills multi-app support, UI improvements, and numerous bug fixes. ### Major Features #### Local Proxy Server - **Local HTTP Proxy** - High-performance proxy server built on Axum framework - **Multi-app Support** - Unified proxy for Claude Code, Codex, and Gemini CLI API requests - **Per-app Takeover** - Independent control over which apps route through the proxy - **Live Config Takeover** - Automatically backs up and redirects CLI configurations to local proxy #### Auto Failover - **Circuit Breaker** - Automatically detects provider failures and triggers protection - **Smart Failover** - Automatically switches to backup provider when current one is unavailable - **Health Tracking** - Real-time monitoring of provider availability - **Independent Failover Queues** - Each app maintains its own failover queue #### Monitoring - **Request Logging** - Detailed logging of all proxy requests - **Usage Statistics** - Token consumption, latency, success rate metrics - **Real-time Status** - Frontend displays proxy status and statistics #### Skills Multi-App Support - **Multi-app Support** - Skills now support both Claude and Codex (#365) - **Multi-app Migration** - Existing Skills auto-migrate to multi-app structure (#378) - **Installation Path Fix** - Use directory basename for skill installation path (#358) ### Added - **Provider Icon Colors** - Customize provider icon colors (#385) - **Deeplink Usage Config** - Import usage query config via deeplink (#400) - **Error Request Logging** - Detailed logging for proxy requests (#401) - **Closable Toast** - Added close button to switch notification toast (#350) - **Icon Color Component** - ProviderIcon component supports color prop (#384) ### Fixed #### Proxy Related - Takeover Codex base_url via model_provider - Harden crash recovery with fallback detection - Sync UI when active provider differs from current setting - Resolve circuit breaker race condition and error classification - Stabilize live takeover and provider editing - Reset health badges when proxy stops - Retry failover for all HTTP errors including 4xx - Fix HalfOpen counter underflow and config field inconsistencies - Resolve circuit breaker state persistence and HalfOpen deadlock - Auto-recover live config after abnormal exit - Update live backup when hot-switching provider in proxy mode - Wait for server shutdown before exiting app - Disable auto-start on app launch by resetting enabled flag on stop - Sync live config tokens to database before takeover - Resolve 404 error and auto-setup proxy targets #### MCP Related - Skip sync when target CLI app is not installed - Improve upsert and import robustness - Use browser-compatible platform detection for MCP presets #### UI Related - Restore fade transition for Skills button - Add close button to all success toasts - Prevent card jitter when health badge appears - Update SettingsPage tab styles (#342) #### Other - Fix Azure website link (#407) - Add fallback to provider config for usage credentials (#360) - Fix Windows black screen on startup (use system titlebar) - Add fallback for crypto.randomUUID() on older WebViews - Use correct npm package for Codex CLI version check - Security fixes for JavaScript executor and usage script (#151) ### Improved - **Proxy Active Theme** - Apply emerald theme when proxy takeover is active - **Card Animation** - Improved provider card hover animation - **Remove Restart Prompt** - No longer prompts restart when switching providers ### Technical - Implement per-app takeover mode - Proxy module contains 20+ Rust files with complete layered architecture - Add 5 new database tables for proxy functionality - Modularize handlers.rs to reduce code duplication - Remove is_proxy_target in favor of failover_queue ### Stats - 55 commits since v3.8.2 - 164 files changed - +22,164 / -570 lines --- ## [3.8.0] - 2025-11-28 ### Major Updates - **Persistence architecture upgrade** - Moved from single JSON storage to SQLite + JSON dual-layer; added schema versioning, transactions, and SQL import/export; first launch auto-migrates `config.json` to SQLite while keeping originals safe. - **Brand new UI** - Full layout redesign, unified component/ConfirmDialog styles, smoother animations, overscroll disabled; Tailwind CSS downgraded to v3.4 for compatibility. - **Japanese language support** - UI now localized in Chinese/English/Japanese. ### Added - **Skills recursive scanning** - Discovers nested `SKILL.md` files across multi-level directories; same-name skills allowed by full-path dedup. - **Provider icons** - Presets ship with default icons; custom icon colors; icons retained when duplicating providers. - **Auto launch on startup** - One-click enable/disable using Registry/LaunchAgent/XDG autostart. - **Provider preset** - Added MiniMax partner preset. - **Form validation** - Required fields get real-time validation and unified toast messaging. ### Fixed - **Custom endpoints loss** - Switched provider updates to `UPDATE` to avoid cascade deletes from `INSERT OR REPLACE`. - **Gemini config writing** - Correctly writes custom env vars to `.env` and keeps auth configs isolated. - **Provider validation** - Handles missing current provider IDs and preserves icon fields on duplicate. - **Linux rendering** - Fixed WebKitGTK DMA-BUF rendering and preserved user `.desktop` customizations. - **Misc** - Removed redundant usage queries; corrected DMXAPI auth token field; restored missing deeplink translations; fixed usage script template init. ### Technical - **Database modules** - Added `schema`, `backup`, `migration`, and DAO layers for providers/MCP/prompts/skills/settings. - **Service modularization** - Split provider service into live/auth/endpoints/usage modules; deeplink parsing/import logic modularized. - **Code cleanup** - Removed legacy JSON-era import/export, unused MCP types; unified error handling; tests migrated to SQLite backend and MSW handlers updated. ### Migration Notes - First launch auto-migrates data from `config.json` to SQLite and device settings to `settings.json`; originals kept; error dialog on failure; dry-run supported. ### Stats - 51 commits since v3.7.1; 207 files changed; +17,297 / -6,870 lines. See [release-note-v3.8.0](docs/release-notes/v3.8.0-en.md) for details. --- ## [3.7.1] - 2025-11-22 ### Fixed - **Skills third-party repository installation** (#268) - Fixed installation failure for skills repositories with custom subdirectories (e.g., `ComposioHQ/awesome-claude-skills`) - **Gemini configuration persistence** - Resolved issue where settings.json edits were lost when switching providers - **Dialog overlay click protection** - Prevented dialogs from closing when clicking outside, avoiding accidental form data loss (affects 11 dialog components) ### Added - **Gemini configuration directory support** (#255) - Added custom configuration directory option for Gemini in settings - **ArchLinux installation support** (#259) - Added AUR installation via `paru -S cc-switch-bin` ### Improved - **Skills error messages i18n** - Added 28+ detailed error messages (English & Chinese) with specific resolution suggestions - **Download timeout** - Extended from 15s to 60s to reduce network-related false positives - **Code formatting** - Applied unified Rust (`cargo fmt`) and TypeScript (`prettier`) formatting standards ### Reverted - **Auto-launch on system startup** - Temporarily reverted feature pending further testing and optimization --- ## [3.7.0] - 2025-11-19 ### Major Features #### Gemini CLI Integration - **Complete Gemini CLI support** - Third major application added alongside Claude Code and Codex - **Dual-file configuration** - Support for both `.env` and `settings.json` file formats - **Environment variable detection** - Auto-detect `GOOGLE_GEMINI_BASE_URL`, `GEMINI_MODEL`, etc. - **MCP management** - Full MCP configuration capabilities for Gemini - **Provider presets** - Google Official (OAuth authentication) - PackyCode (partner integration) - Custom endpoint support - **Deep link support** - Import Gemini providers via `ccswitch://` protocol - **System tray integration** - Quick-switch Gemini providers from tray menu - **Backend modules** - New `gemini_config.rs` (20KB) and `gemini_mcp.rs` #### MCP v3.7.0 Unified Architecture - **Unified management panel** - Single interface for Claude/Codex/Gemini MCP servers - **SSE transport type** - New Server-Sent Events support alongside stdio/http - **Smart JSON parser** - Fault-tolerant parsing of various MCP config formats - **Extended field support** - Preserve custom fields in Codex TOML conversion - **Codex format correction** - Proper `[mcp_servers]` format (auto-cleanup of incorrect `[mcp.servers]`) - **Import/export system** - Unified import from Claude/Codex/Gemini live configs - **UX improvements** - Default app selection in forms - JSON formatter for config validation - Improved layout and visual hierarchy - Better validation error messages #### Claude Skills Management System - **GitHub repository integration** - Auto-scan and discover skills from GitHub repos - **Pre-configured repositories** - `ComposioHQ/awesome-claude-skills` (curated collection) - `anthropics/skills` (official Anthropic skills) - `cexll/myclaude` (community, with subdirectory scanning) - **Lifecycle management** - One-click install to `~/.claude/skills/` - Safe uninstall with state tracking - Update checking (infrastructure ready) - **Custom repository support** - Add any GitHub repo as a skill source - **Subdirectory scanning** - Optional `skillsPath` for repos with nested skill directories - **Backend architecture** - `SkillService` (526 lines) with GitHub API integration - **Frontend interface** - SkillsPage: Browse and manage skills - SkillCard: Visual skill presentation - RepoManager: Repository management dialog - **State persistence** - Installation state stored in `skills.json` - **Full i18n support** - Complete Chinese/English translations (47+ keys) #### Prompts (System Prompts) Management - **Multi-preset management** - Create, edit, and switch between multiple system prompts - **Cross-app support** - Claude: `~/.claude/CLAUDE.md` - Codex: `~/.codex/AGENTS.md` - Gemini: `~/.gemini/GEMINI.md` - **Markdown editor** - Full-featured CodeMirror 6 editor with syntax highlighting - **Smart synchronization** - Auto-write to live files on enable - Content backfill protection (save current before switching) - First-launch auto-import from live files - **Single-active enforcement** - Only one prompt can be active at a time - **Delete protection** - Cannot delete active prompts - **Backend service** - `PromptService` (213 lines) with CRUD operations - **Frontend components** - PromptPanel: Main management interface (177 lines) - PromptFormModal: Edit dialog with validation (160 lines) - MarkdownEditor: CodeMirror integration (159 lines) - usePromptActions: Business logic hook (152 lines) - **Full i18n support** - Complete Chinese/English translations (41+ keys) #### Deep Link Protocol (ccswitch://) - **Protocol registration** - `ccswitch://` URL scheme for one-click imports - **Provider import** - Import provider configurations from URLs or shared links - **Lifecycle integration** - Deep link handling integrated into app startup - **Cross-platform support** - Works on Windows, macOS, and Linux #### Environment Variable Conflict Detection - **Claude & Codex detection** - Identify conflicting environment variables - **Gemini auto-detection** - Automatic environment variable discovery - **Conflict management** - UI for resolving configuration conflicts - **Prevention system** - Warn before overwriting existing configurations ### New Features #### Provider Management - **DouBaoSeed preset** - Added ByteDance's DouBao provider - **Kimi For Coding** - Moonshot AI coding assistant - **BaiLing preset** - BaiLing AI integration - **Removed AnyRouter preset** - Discontinued provider - **Model configuration** - Support for custom model names in Codex and Gemini - **Provider notes field** - Add custom notes to providers for better organization #### Configuration Management - **Common config migration** - Moved Claude common config snippets from localStorage to `config.json` - **Unified persistence** - Common config snippets now shared across all apps - **Auto-import on first launch** - Automatically import configs from live files on first run - **Backfill priority fix** - Correct priority handling when enabling prompts #### UI/UX Improvements - **macOS native design** - Migrated color scheme to macOS native design system - **Window centering** - Default window position centered on screen - **Password input fixes** - Disabled Edge/IE reveal and clear buttons - **URL overflow prevention** - Fixed overflow in provider cards - **Error notification enhancement** - Copy-to-clipboard for error messages - **Tray menu sync** - Real-time sync after drag-and-drop sorting ### Improvements #### Architecture - **MCP v3.7.0 cleanup** - Removed legacy code and warnings - **Unified structure** - Default initialization with v3.7.0 unified structure - **Backward compatibility** - Compilation fixes for older configs - **Code formatting** - Applied consistent formatting across backend and frontend #### Platform Compatibility - **Windows fix** - Resolved winreg API compatibility issue (v0.52) - **Safe pattern matching** - Replaced `unwrap()` with safe patterns in tray menu #### Configuration - **MCP sync on switch** - Sync MCP configs for all apps when switching providers - **Gemini form sync** - Fixed form fields syncing with environment editor - **Gemini config reading** - Read from both `.env` and `settings.json` - **Validation improvements** - Enhanced input validation and boundary checks #### Internationalization - **JSON syntax fixes** - Resolved syntax errors in locale files - **App name i18n** - Added internationalization support for app names - **Deduplicated labels** - Reused providerForm keys to reduce duplication - **Gemini MCP title** - Added missing Gemini MCP panel title ### Bug Fixes #### Critical Fixes - **Usage script validation** - Added input validation and boundary checks - **Gemini validation** - Relaxed validation when adding providers - **TOML quote normalization** - Handle CJK quotes to prevent parsing errors - **MCP field preservation** - Preserve custom fields in Codex TOML editor - **Password input** - Fixed white screen crash (FormLabel → Label) #### Stability - **Tray menu safety** - Replaced unwrap with safe pattern matching - **Error isolation** - Tray menu update failures don't block main operations - **Import classification** - Set category to custom for imported default configs #### UI Fixes - **Model placeholders** - Removed misleading model input placeholders - **Base URL population** - Auto-fill base URL for non-official providers - **Drag sort sync** - Fixed tray menu order after drag-and-drop ### Technical Improvements #### Code Quality - **Type safety** - Complete TypeScript type coverage across codebase - **Test improvements** - Simplified boolean assertions in tests - **Clippy warnings** - Fixed `uninlined_format_args` warnings - **Code refactoring** - Extracted templates, optimized logic flows #### Dependencies - **Tauri** - Updated to 2.8.x series - **Rust dependencies** - Added `anyhow`, `zip`, `serde_yaml`, `tempfile` for Skills - **Frontend dependencies** - Added CodeMirror 6 packages for Markdown editor - **winreg** - Updated to v0.52 (Windows compatibility) #### Performance - **Startup optimization** - Removed legacy migration scanning - **Lock management** - Improved RwLock usage to prevent deadlocks - **Background query** - Enabled background mode for usage polling ### Statistics - **Total commits**: 85 commits from v3.6.0 to v3.7.0 - **Code changes**: 152 files changed, 18,104 insertions(+), 3,732 deletions(-) - **New modules**: - Skills: 2,034 lines (21 files) - Prompts: 1,302 lines (20 files) - Gemini: ~1,000 lines (multiple files) - MCP refactor: ~3,000 lines (refactored) ### Strategic Positioning v3.7.0 represents a major evolution from "Provider Switcher" to **"All-in-One AI CLI Management Platform"**: 1. **Capability Extension** - Skills provide external ability integration 2. **Behavior Customization** - Prompts enable AI personality presets 3. **Configuration Unification** - MCP v3.7.0 eliminates app silos 4. **Ecosystem Openness** - Deep links enable community sharing 5. **Multi-AI Support** - Claude/Codex/Gemini trinity 6. **Intelligent Detection** - Auto-discovery of environment conflicts ### Notes - Users upgrading from v3.1.0 or earlier should first upgrade to v3.2.x for one-time migration - Skills and Prompts management are new features requiring no migration - Gemini CLI support requires Gemini CLI to be installed separately - MCP v3.7.0 unified structure is backward compatible with previous configs ## [3.6.0] - 2025-11-07 ### ✨ New Features - **Provider Duplicate** - Quick duplicate existing provider configurations for easy variant creation - **Edit Mode Toggle** - Show/hide drag handles to optimize editing experience - **Custom Endpoint Management** - Support multi-endpoint configuration for aggregator providers - **Usage Query Enhancements** - Auto-refresh interval: Support periodic automatic usage query - Test Script API: Validate JavaScript scripts before execution - Template system expansion: Custom blank template, support for access token and user ID parameters - **Configuration Editor Improvements** - Add JSON format button - Real-time TOML syntax validation for Codex configuration - **Auto-sync on Directory Change** - When switching Claude/Codex config directories (e.g., WSL environment), automatically sync current provider to new directory without manual operation - **Load Live Config When Editing Active Provider** - When editing the currently active provider, prioritize displaying the actual effective configuration to protect user manual modifications - **New Provider Presets** - DMXAPI, Azure Codex, AnyRouter, AiHubMix, MiniMax - **Partner Promotion Mechanism** - Support ecosystem partner promotion (e.g., Zhipu GLM Z.ai) ### 🔧 Improvements - **Configuration Directory Switching** - Introduced unified post-change sync utility (`postChangeSync.ts`) - Auto-sync current providers to new directory when changing Claude/Codex config directories - Perfect support for WSL environment switching - Auto-sync after config import to ensure immediate effectiveness - Use Result pattern for graceful error handling without blocking main flow - Distinguish "fully successful" and "partially successful" states for precise user feedback - **UI/UX Enhancements** - Provider cards: Unique icons and color identification - Unified border design system across all components - Drag interaction optimization: Push effect animation, improved handle icons - Enhanced current provider visual feedback - Dialog size standardization and layout consistency - Form experience: Optimized model placeholders, simplified provider hints, category-specific hints - **Complete Internationalization Coverage** - Error messages internationalization - Tray menu internationalization - All UI components internationalization - **Usage Display Moved Inline** - Usage display moved next to enable button ### 🐛 Bug Fixes - **Configuration Sync** - Fixed `apiKeyUrl` priority issue - Fixed MCP sync-to-other-side functionality failure - Fixed sync issues after config import - Prevent silent fallback and data loss on config error - **Usage Query** - Fixed auto-query interval timing issue - Ensure refresh button shows loading animation on click - **UI Issues** - Fixed name collision error (`get_init_error` command) - Fixed language setting rollback after successful save - Fixed language switch state reset (dependency cycle) - Fixed edit mode button alignment - **Configuration Management** - Fixed Codex API Key auto-sync - Fixed endpoint speed test functionality - Fixed provider duplicate insertion position (next to original provider) - Fixed custom endpoint preservation in edit mode - **Startup Issues** - Force exit on config error (no silent fallback) - Eliminate code duplication causing initialization errors ### 🏗️ Technical Improvements (For Developers) **Backend Refactoring (Rust)** - Completed 5-phase refactoring: - **Phase 1**: Unified error handling (`AppError` + i18n error messages) - **Phase 2**: Command layer split by domain (`commands/{provider,mcp,config,settings,plugin,misc}.rs`) - **Phase 3**: Integration tests and transaction mechanism (config snapshot + failure rollback) - **Phase 4**: Extracted Service layer (`services/{provider,mcp,config,speedtest}.rs`) - **Phase 5**: Concurrency optimization (`RwLock` instead of `Mutex`, scoped guard to avoid deadlock) **Frontend Refactoring (React + TypeScript)** - Completed 4-stage refactoring: - **Stage 1**: Test infrastructure (vitest + MSW + @testing-library/react) - **Stage 2**: Extracted custom hooks (`useProviderActions`, `useMcpActions`, `useSettings`, `useImportExport`, etc.) - **Stage 3**: Component splitting and business logic extraction - **Stage 4**: Code cleanup and formatting unification **Testing System**: - Hooks unit tests 100% coverage - Integration tests covering key processes (App, SettingsDialog, MCP Panel) - MSW mocking backend API to ensure test independence **Code Quality**: - Unified parameter format: All Tauri commands migrated to camelCase (Tauri 2 specification) - `AppType` renamed to `AppId`: Semantically clearer - Unified parsing with `FromStr` trait: Centralized `app` parameter parsing - Eliminate code duplication: DRY violations cleanup - Remove unused code: `missing_param` helper function, deprecated `tauri-api.ts`, redundant `KimiModelSelector` component **Internal Optimizations**: - **Removed Legacy Migration Logic**: v3.6 removed v1 config auto-migration and copy file scanning logic - ✅ **Impact**: Improved startup performance, cleaner code - ✅ **Compatibility**: v2 format configs fully compatible, no action required - ⚠️ **Note**: Users upgrading from v3.1.0 or earlier should first upgrade to v3.2.x or v3.5.x for one-time migration, then upgrade to v3.6 - **Command Parameter Standardization**: Backend unified to use `app` parameter (values: `claude` or `codex`) - ✅ **Impact**: More standardized code, friendlier error prompts - ✅ **Compatibility**: Frontend fully adapted, users don't need to care about this change ### 📦 Dependencies - Updated to Tauri 2.8.x - Updated to TailwindCSS 4.x - Updated to TanStack Query v5.90.x - Maintained React 18.2.x and TypeScript 5.3.x ## [3.5.0] - 2025-01-15 ### ⚠ Breaking Changes - Tauri commands only accept the `app` parameter (`claude`/`codex`); removed `app_type`/`appType` compatibility. - Frontend types are standardized to `AppId` (removed `AppType` export); variable naming is standardized to `appId`. ### ✨ New Features - **MCP (Model Context Protocol) Management** - Complete MCP server configuration management system - Add, edit, delete, and toggle MCP servers in `~/.claude.json` - Support for stdio and http server types with command validation - Built-in templates for popular MCP servers (mcp-fetch, etc.) - Real-time enable/disable toggle for MCP servers - Atomic file writing to prevent configuration corruption - **Configuration Import/Export** - Backup and restore your provider configurations - Export all configurations to JSON file with one click - Import configurations with validation and automatic backup - Automatic backup rotation (keeps 10 most recent backups) - Progress modal with detailed status feedback - **Endpoint Speed Testing** - Test API endpoint response times - Measure latency to different provider endpoints - Visual indicators for connection quality - Help users choose the fastest provider ### 🔧 Improvements - Complete internationalization (i18n) coverage for all UI components - Enhanced error handling and user feedback throughout the application - Improved configuration file management with better validation - Added new provider presets: Longcat, kat-coder - Updated GLM provider configurations with latest models - Refined UI/UX with better spacing, icons, and visual feedback - Enhanced tray menu functionality and responsiveness - **Standardized release artifact naming** - All platform releases now use consistent version-tagged filenames: - macOS: `CC-Switch-v{version}-macOS.tar.gz` / `.zip` - Windows: `CC-Switch-v{version}-Windows.msi` / `-Portable.zip` - Linux: `CC-Switch-v{version}-Linux.AppImage` / `.deb` ### 🐛 Bug Fixes - Fixed layout shifts during provider switching - Improved config file path handling across different platforms - Better error messages for configuration validation failures - Fixed various edge cases in configuration import/export ### 📦 Technical Details - Enhanced `import_export.rs` module with backup management - New `claude_mcp.rs` module for MCP configuration handling - Improved state management and lock handling in Rust backend - Better TypeScript type safety across the codebase ## [3.4.0] - 2025-10-01 ### ✨ Features - Enable internationalization via i18next with a Chinese default and English fallback, plus an in-app language switcher - Add Claude plugin sync while retiring the legacy VS Code integration controls (Codex no longer requires settings.json edits) - Extend provider presets with optional API key URLs and updated models, including DeepSeek-V3.1-Terminus and Qwen3-Max - Support portable mode launches and enforce a single running instance to avoid conflicts ### 🔧 Improvements - Allow minimizing the window to the system tray and add macOS Dock visibility management for tray workflows - Refresh the Settings modal with a scrollable layout, save icon, and cleaner language section - Smooth provider toggle states with consistent button widths/icons and prevent layout shifts when switching between Claude and Codex - Adjust the Windows MSI installer to target per-user LocalAppData and improve component tracking reliability ### 🐛 Fixes - Remove the unnecessary OpenAI auth requirement from third-party provider configurations - Fix layout shifts while switching app types with Claude plugin sync enabled - Align Enable/In Use button states to avoid visual jank across app views ## [3.3.0] - 2025-09-22 ### ✨ Features - Add “Apply to VS Code / Remove from VS Code” actions on provider cards, writing settings for Code/Insiders/VSCodium variants _(Removed in 3.4.x)_ - Enable VS Code auto-sync by default with window broadcast and tray hooks so Codex switches sync silently _(Removed in 3.4.x)_ - Extend the Codex provider wizard with display name, dedicated API key URL, and clearer guidance - Introduce shared common config snippets with JSON/TOML reuse, validation, and consistent error surfaces ### 🔧 Improvements - Keep the tray menu responsive when the window is hidden and standardize button styling and copy - Disable modal backdrop blur on Linux (WebKitGTK/Wayland) to avoid freezes; restore the window when clicking the macOS Dock icon - Support overriding config directories on WSL, refine placeholders/descriptions, and fix VS Code button wrapping on Windows - Add a `created_at` timestamp to provider records for future sorting and analytics ### 🐛 Fixes - Correct regex escapes and common snippet trimming in the Codex wizard to prevent validation issues - Harden the VS Code sync flow with more reliable TOML/JSON parsing while reducing layout jank - Bundle `@codemirror/lint` to reinstate live linting in config editors ## [3.2.0] - 2025-09-13 ### ✨ New Features - System tray provider switching with dynamic menu for Claude/Codex - Frontend receives `provider-switched` events and refreshes active app - Built-in update flow via Tauri Updater plugin with dismissible UpdateBadge ### 🔧 Improvements - Single source of truth for provider configs; no duplicate copy files - One-time migration imports existing copies into `config.json` and archives originals - Duplicate provider de-duplication by name + API key at startup - Atomic writes for Codex `auth.json` + `config.toml` with rollback on failure - Logging standardized (Rust): use `log::{info,warn,error}` instead of stdout prints - Tailwind v4 integration and refined dark mode handling ### 🐛 Fixes - Remove/minimize debug console logs in production builds - Fix CSS minifier warnings for scrollbar pseudo-elements - Prettier formatting across codebase for consistent style ### 📦 Dependencies - Tauri: 2.8.x (core, updater, process, opener, log plugins) - React: 18.2.x · TypeScript: 5.3.x · Vite: 5.x ### 🔄 Notes - `connect-src` CSP remains permissive for compatibility; can be tightened later as needed ## [3.1.1] - 2025-09-03 ### 🐛 Bug Fixes - Fixed the default codex config.toml to match the latest modifications - Improved provider configuration UX with custom option ### 📝 Documentation - Updated README with latest information ## [3.1.0] - 2025-09-01 ### ✨ New Features - **Added Codex application support** - Now supports both Claude Code and Codex configuration management - Manage auth.json and config.toml for Codex - Support for backup and restore operations - Preset providers for Codex (Official, PackyCode) - API Key auto-write to auth.json when using presets - **New UI components** - App switcher with segmented control design - Dual editor form for Codex configuration - Pills-style app switcher with consistent button widths - **Enhanced configuration management** - Multi-app config v2 structure (claude/codex) - Automatic v1→v2 migration with backup - OPENAI_API_KEY validation for non-official presets - TOML syntax validation for config.toml ### 🔧 Technical Improvements - Unified Tauri command API with app_type parameter - Backward compatibility for app/appType parameters - Added get_config_status/open_config_folder/open_external commands - Improved error handling for empty config.toml ### 🐛 Bug Fixes - Fixed config path reporting and folder opening for Codex - Corrected default import behavior when main config is missing - Fixed non_snake_case warnings in commands.rs ## [3.0.0] - 2025-08-27 ### 🚀 Major Changes - **Complete migration from Electron to Tauri 2.0** - The application has been completely rewritten using Tauri, resulting in: - **90% reduction in bundle size** (from ~150MB to ~15MB) - **Significantly improved startup performance** - **Native system integration** without Chromium overhead - **Enhanced security** with Rust backend ### ✨ New Features - **Native window controls** with transparent title bar on macOS - **Improved file system operations** using Rust for better performance - **Enhanced security model** with explicit permission declarations - **Better platform detection** using Tauri's native APIs ### 🔧 Technical Improvements - Migrated from Electron IPC to Tauri command system - Replaced Node.js file operations with Rust implementations - Implemented proper CSP (Content Security Policy) for enhanced security - Added TypeScript strict mode for better type safety - Integrated Rust cargo fmt and clippy for code quality ### 🐛 Bug Fixes - Fixed bundle identifier conflict on macOS (changed from .app to .desktop) - Resolved platform detection issues - Improved error handling in configuration management ### 📦 Dependencies - **Tauri**: 2.8.2 - **React**: 18.2.0 - **TypeScript**: 5.3.0 - **Vite**: 5.0.0 ### 🔄 Migration Notes For users upgrading from v2.x (Electron version): - Configuration files remain compatible - no action required - The app will automatically migrate your existing provider configurations - Window position and size preferences have been reset to defaults #### Backup on v1→v2 Migration (cc-switch internal config) - When the app detects an old v1 config structure at `~/.cc-switch/config.json`, it now creates a timestamped backup before writing the new v2 structure. - Backup location: `~/.cc-switch/config.v1.backup..json` - This only concerns cc-switch's own metadata file; your actual provider files under `~/.claude/` and `~/.codex/` are untouched. ### 🛠️ Development - Added `pnpm typecheck` command for TypeScript validation - Added `pnpm format` and `pnpm format:check` for code formatting - Rust code now uses cargo fmt for consistent formatting ## [2.0.0] - Previous Electron Release ### Features - Multi-provider configuration management - Quick provider switching - Import/export configurations - Preset provider templates --- ## [1.0.0] - Initial Release ### Features - Basic provider management - Claude Code integration - Configuration file handling ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2025 Jason Young Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================
# CC Switch ### The All-in-One Manager for Claude Code, Codex, Gemini CLI, OpenCode & OpenClaw [![Version](https://img.shields.io/badge/version-3.12.3-blue.svg)](https://github.com/farion1231/cc-switch/releases) [![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20macOS%20%7C%20Linux-lightgrey.svg)](https://github.com/farion1231/cc-switch/releases) [![Built with Tauri](https://img.shields.io/badge/built%20with-Tauri%202-orange.svg)](https://tauri.app/) [![Downloads](https://img.shields.io/endpoint?url=https://api.pinstudios.net/api/badges/downloads/farion1231/cc-switch/total)](https://github.com/farion1231/cc-switch/releases/latest) farion1231%2Fcc-switch | Trendshift English | [中文](README_ZH.md) | [日本語](README_JA.md) | [Changelog](CHANGELOG.md)
## ❤️Sponsor
Click to collapse [![MiniMax](assets/partners/banners/minimax-en.jpeg)](https://platform.minimax.io/subscribe/coding-plan?code=ClLhgxr2je&source=link) MiniMax-M2.5 is a SOTA large language model designed for real-world productivity. Trained in a diverse range of complex real-world digital working environments, M2.5 builds upon the coding expertise of M2.1 to extend into general office work, reaching fluency in generating and operating Word, Excel, and Powerpoint files, context switching between diverse software environments, and working across different agent and human teams. Scoring 80.2% on SWE-Bench Verified, 51.3% on Multi-SWE-Bench, and 76.3% on BrowseComp, M2.5 is also more token efficient than previous generations, having been trained to optimize its actions and output through planning. [Click](https://platform.minimax.io/subscribe/coding-plan?code=ClLhgxr2je&source=link) to get an exclusive 12% off the MiniMax Coding Plan! ---
PackyCode Thanks to PackyCode for sponsoring this project! PackyCode is a reliable and efficient API relay service provider, offering relay services for Claude Code, Codex, Gemini, and more. PackyCode provides special discounts for our software users: register using this link and enter the "cc-switch" promo code during first recharge to get 10% off.
SiliconFlow Thanks to SiliconFlow for sponsoring this project! SiliconFlow is a high-performance AI infrastructure and model API platform, providing fast and reliable access to language, speech, image, and video models in one place. With pay-as-you-go billing, broad multimodal model support, high-speed inference, and enterprise-grade stability, SiliconFlow helps developers and teams build and scale AI applications more efficiently. Register via this link and complete real-name verification to receive ¥20 in bonus credit, usable across models on the platform. SiliconFlow is also now compatible with OpenClaw, allowing users to connect a SiliconFlow API key and call major AI models for free.
AIGoCode Thanks to AIGoCode for sponsoring this project! AIGoCode is an all-in-one platform that integrates Claude Code, Codex, and the latest Gemini models, providing you with stable, efficient, and highly cost-effective AI coding services. The platform offers flexible subscription plans, zero risk of account suspension, direct access with no VPN required, and lightning-fast responses. AIGoCode has prepared a special benefit for CC Switch users: if you register via this link, you'll receive an extra 10% bonus credit on your first top-up!
AICodeMirror Thanks to AICodeMirror for sponsoring this project! AICodeMirror provides official high-stability relay services for Claude Code / Codex / Gemini CLI, with enterprise-grade concurrency, fast invoicing, and 24/7 dedicated technical support. Claude Code / Codex / Gemini official channels at 38% / 2% / 9% of original price, with extra discounts on top-ups! AICodeMirror offers special benefits for CC Switch users: register via this link to enjoy 20% off your first top-up, and enterprise customers can get up to 25% off!
Cubence Thanks to Cubence for sponsoring this project! Cubence is a reliable and efficient API relay service provider, offering relay services for Claude Code, Codex, Gemini, and more with flexible billing options including pay-as-you-go and monthly plans. Cubence provides special discounts for CC Switch users: register using this link and enter the "CCSWITCH" promo code during recharge to get 10% off every top-up!
DMXAPI Thanks to DMXAPI for sponsoring this project! DMXAPI provides global large model API services to 200+ enterprise users. One API key for all global models. Features include: instant invoicing, unlimited concurrency, starting from $0.15, 24/7 technical support. GPT/Claude/Gemini all at 32% off, domestic models 20-50% off, Claude Code exclusive models at 66% off! Register here
Compshare Thanks to Compshare for sponsoring this project! Compshare is UCloud's AI cloud platform, providing stable and comprehensive domestic and international model APIs with just one key. Featuring cost-effective monthly and pay-as-you-go Coding Plan packages at 60-80% off official prices. Supports Claude Code, Codex, and API access. Enterprise-grade high concurrency, 24/7 technical support, and self-service invoicing. Users who register via this link will receive a free 5 CNY platform trial credit!
RightCode Thank you to Right Code for sponsoring this project! Right Code reliably provides routing services for models such as Claude Code, Codex, and Gemini. It features a highly cost-effective Codex monthly subscription plan and supports quota rollovers—unused quota from one day can be carried over and used the next day. Invoices are available upon top-up. Enterprise and team users can receive dedicated one-on-one support. Right Code also offers an exclusive discount for CC Switch users: register via this link, and with every top-up you will receive pay-as-you-go credit equivalent to 25% of the amount paid.
AICoding Thanks to AICoding.sh for sponsoring this project! AICoding.sh — Global AI Model API Relay Service at Unbeatable Prices! Claude Code at 19% of original price, GPT at just 1%! Trusted by hundreds of enterprises for cost-effective AI services. Supports Claude Code, GPT, Gemini and major domestic models, with enterprise-grade high concurrency, fast invoicing, and 24/7 dedicated technical support. CC Switch users who register via this link get 10% off their first top-up!
Crazyrouter Thanks to Crazyrouter for sponsoring this project! Crazyrouter is a high-performance AI API aggregation platform — one API key for 300+ models including Claude Code, Codex, Gemini CLI, and more. All models at 55% of official pricing with auto-failover, smart routing, and unlimited concurrency. Crazyrouter offers an exclusive deal for CC Switch users: register via this link to get $2 free credit instantly, plus enter promo code `CCSWITCH` on your first top-up for an extra 30% bonus credit!
SSSAiCode Thanks to SSSAiCode for sponsoring this project! SSSAiCode is a stable and reliable API relay service, dedicated to providing stable, reliable, and affordable Claude and Codex model services, offering high cost-effective official Claude service at just ¥0.5/$ equivalent, supporting monthly and pay-as-you-go billing plans with same-day fast invoicing. SSSAiCode offers a special deal for CC Switch users: register via this link to enjoy $10 extra credit on every top-up!
Micu Thanks to Micu API for sponsoring this project! Micu API is a global LLM relay service provider dedicated to delivering the best cost-performance ratio with high stability. Backed by a registered enterprise for core assurance, eliminating any risk of service discontinuation, with fast official invoicing support! We champion "zero cost to try": top up from as low as ¥1 with no minimum, and get fee-free refunds anytime! Micu API offers an exclusive deal for CC Switch users: register via this link and enter promo code "ccswitch" when topping up to enjoy a 10% discount!
XCodeAPI Thanks to XCodeAPI for sponsoring this project! XCodeAPI offers a special benefit for CC Switch users: register via this link and get an extra 10% credit bonus on your first order! (Contact the site admin to claim)
CTok Thanks to CTok.ai for sponsoring this project! CTok.ai is dedicated to building a one-stop AI programming tool service platform. We offer professional Claude Code packages and technical community services, with support for Google Gemini and OpenAI Codex. Through carefully designed plans and a professional tech community, we provide developers with reliable service guarantees and continuous technical support, making AI-assisted programming a true productivity tool. Click here to register!
## Why CC Switch? Modern AI-powered coding relies on CLI tools like Claude Code, Codex, Gemini CLI, OpenCode, and OpenClaw — but each has its own configuration format. Switching API providers means manually editing JSON, TOML, or `.env` files, and there is no unified way to manage MCP and Skills across multiple tools. **CC Switch** gives you a single desktop app to manage all five CLI tools. Instead of editing config files by hand, you get a visual interface to import providers with one click, switch between them instantly, with 50+ built-in provider presets, unified MCP and Skills management, and system tray quick switching — all backed by a reliable SQLite database with atomic writes that protect your configs from corruption. - **One App, Five CLI Tools** — Manage Claude Code, Codex, Gemini CLI, OpenCode, and OpenClaw from a single interface - **No More Manual Editing** — 50+ provider presets including AWS Bedrock, NVIDIA NIM, and community relays; just pick and switch - **Unified MCP & Skills Management** — One panel to manage MCP servers and Skills across four apps with bidirectional sync - **System Tray Quick Switch** — Switch providers instantly from the tray menu, no need to open the full app - **Cloud Sync** — Sync provider data across devices via Dropbox, OneDrive, iCloud, or WebDAV servers - **Cross-Platform** — Native desktop app for Windows, macOS, and Linux, built with Tauri 2 - **Built-in Utilities** — Includes various utilities for first-launch login confirmation, signature bypass, plugin extension sync, and more ## Screenshots | Main Interface | Add Provider | | :-----------------------------------------------: | :--------------------------------------------: | | ![Main Interface](assets/screenshots/main-en.png) | ![Add Provider](assets/screenshots/add-en.png) | ## Features [Full Changelog](CHANGELOG.md) | [Release Notes](docs/release-notes/v3.12.3-en.md) ### Provider Management - **5 CLI tools, 50+ presets** — Claude Code, Codex, Gemini CLI, OpenCode, OpenClaw; copy your key and import with one click - **Universal providers** — One config syncs to multiple apps (OpenCode, OpenClaw) - One-click switching, system tray quick access, drag-and-drop sorting, import/export ### Proxy & Failover - **Local proxy with hot-switching** — Format conversion, auto-failover, circuit breaker, provider health monitoring, and request rectifier - **App-level takeover** — Independently proxy Claude, Codex, or Gemini, down to individual providers ### MCP, Prompts & Skills - **Unified MCP panel** — Manage MCP servers across 4 apps with bidirectional sync and Deep Link import - **Prompts** — Markdown editor with cross-app sync (CLAUDE.md / AGENTS.md / GEMINI.md) and backfill protection - **Skills** — One-click install from GitHub repos or ZIP files, custom repository management, with symlink and file copy support ### Usage & Cost Tracking - **Usage dashboard** — Track spending, requests, and tokens with trend charts, detailed request logs, and custom per-model pricing ### Session Manager & Workspace - Browse, search, and restore conversation history across all apps - **Workspace editor** (OpenClaw) — Edit agent files (AGENTS.md, SOUL.md, etc.) with Markdown preview ### System & Platform - **Cloud sync** — Custom config directory (Dropbox, OneDrive, iCloud, NAS) and WebDAV server sync - **Deep Link** (`ccswitch://`) — Import providers, MCP servers, prompts, and skills via URL - Dark / Light / System theme, auto-launch, auto-updater, atomic writes, auto-backups, i18n (zh/en/ja) ## FAQ
Which AI CLI tools does CC Switch support? CC Switch supports five tools: **Claude Code**, **Codex**, **Gemini CLI**, **OpenCode**, and **OpenClaw**. Each tool has dedicated provider presets and configuration management.
Do I need to restart the terminal after switching providers? For most tools, yes — restart your terminal or the CLI tool for changes to take effect. The exception is **Claude Code**, which currently supports hot-switching of provider data without a restart.
My plugin configuration disappeared after switching providers — what happened? CC Switch provides a "Shared Config Snippet" feature to pass common data (beyond API keys and endpoints) between providers. Go to "Edit Provider" → "Shared Config Panel" → click "Extract from Current Provider" to save all common data. When creating a new provider, check "Write Shared Config" (enabled by default) to include plugin data in the new provider. All your configuration items are preserved in the default provider imported when you first launched the app.
macOS shows "unidentified developer" warning — how do I fix it? The author doesn't have an Apple Developer account yet (registration in progress). Close the warning, then go to **System Settings → Privacy & Security → Open Anyway**. After that, the app will open normally.
Why can't I delete the currently active provider? CC Switch follows a "minimal intrusion" design principle — even if you uninstall the app, your CLI tools will continue to work normally. The system always keeps one active configuration, because deleting all configurations would make the corresponding CLI tool unusable. If you rarely use a specific CLI tool, you can hide it in Settings. To switch back to official login, see the next question.
How do I switch back to official login? Add an official provider from the preset list. After switching to it, run the Log out / Log in flow, and then you can freely switch between the official provider and third-party providers. Codex supports switching between different official providers, making it easy to switch between multiple Plus or Team accounts.
Where is my data stored? - **Database**: `~/.cc-switch/cc-switch.db` (SQLite — providers, MCP, prompts, skills) - **Local settings**: `~/.cc-switch/settings.json` (device-level UI preferences) - **Backups**: `~/.cc-switch/backups/` (auto-rotated, keeps 10 most recent) - **Skills**: `~/.cc-switch/skills/` (symlinked to corresponding apps by default) - **Skill Backups**: `~/.cc-switch/skill-backups/` (created automatically before uninstall, keeps 20 most recent)
## Documentation For detailed guides on every feature, check out the **[User Manual](docs/user-manual/en/README.md)** — covering provider management, MCP/Prompts/Skills, proxy & failover, and more. ## Quick Start ### Basic Usage 1. **Add Provider**: Click "Add Provider" → Choose a preset or create custom configuration 2. **Switch Provider**: - Main UI: Select provider → Click "Enable" - System Tray: Click provider name directly (instant effect) 3. **Takes Effect**: Restart your terminal or the corresponding CLI tool to apply changes (Claude Code does not require a restart) 4. **Back to Official**: Add an "Official Login" preset, restart the CLI tool, then follow its login/OAuth flow ### MCP, Prompts, Skills & Sessions - **MCP**: Click the "MCP" button → Add servers via templates or custom config → Toggle per-app sync - **Prompts**: Click "Prompts" → Create presets with Markdown editor → Activate to sync to live files - **Skills**: Click "Skills" → Browse GitHub repos → One-click install to all apps - **Sessions**: Click "Sessions" → Browse, search, and restore conversation history across all apps > **Note**: On first launch, you can manually import existing CLI tool configs as the default provider. ## Download & Installation ### System Requirements - **Windows**: Windows 10 and above - **macOS**: macOS 12 (Monterey) and above - **Linux**: Ubuntu 22.04+ / Debian 11+ / Fedora 34+ and other mainstream distributions ### Windows Users Download the latest `CC-Switch-v{version}-Windows.msi` installer or `CC-Switch-v{version}-Windows-Portable.zip` portable version from the [Releases](../../releases) page. ### macOS Users **Method 1: Install via Homebrew (Recommended)** ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` Update: ```bash brew upgrade --cask cc-switch ``` **Method 2: Manual Download** Download `CC-Switch-v{version}-macOS.zip` from the [Releases](../../releases) page and extract to use. > **Note**: Since the author doesn't have an Apple Developer account, you may see an "unidentified developer" warning on first launch. Please close it first, then go to "System Settings" → "Privacy & Security" → click "Open Anyway", and you'll be able to open it normally afterwards. ### Arch Linux Users **Install via paru (Recommended)** ```bash paru -S cc-switch-bin ``` ### Linux Users Download the latest Linux build from the [Releases](../../releases) page: - `CC-Switch-v{version}-Linux.deb` (Debian/Ubuntu) - `CC-Switch-v{version}-Linux.rpm` (Fedora/RHEL/openSUSE) - `CC-Switch-v{version}-Linux.AppImage` (Universal) - `CC-Switch-v{version}-Linux.flatpak` (Flatpak) Flatpak install & run: ```bash flatpak install --user ./CC-Switch-v{version}-Linux.flatpak flatpak run com.ccswitch.desktop ```
Architecture Overview ### Design Principles ``` ┌─────────────────────────────────────────────────────────────┐ │ Frontend (React + TS) │ │ ┌─────────────┐ ┌──────────────┐ ┌──────────────────┐ │ │ │ Components │ │ Hooks │ │ TanStack Query │ │ │ │ (UI) │──│ (Bus. Logic) │──│ (Cache/Sync) │ │ │ └─────────────┘ └──────────────┘ └──────────────────┘ │ └────────────────────────┬────────────────────────────────────┘ │ Tauri IPC ┌────────────────────────▼────────────────────────────────────┐ │ Backend (Tauri + Rust) │ │ ┌─────────────┐ ┌──────────────┐ ┌──────────────────┐ │ │ │ Commands │ │ Services │ │ Models/Config │ │ │ │ (API Layer) │──│ (Bus. Layer) │──│ (Data) │ │ │ └─────────────┘ └──────────────┘ └──────────────────┘ │ └─────────────────────────────────────────────────────────────┘ ``` **Core Design Patterns** - **SSOT** (Single Source of Truth): All data stored in `~/.cc-switch/cc-switch.db` (SQLite) - **Dual-layer Storage**: SQLite for syncable data, JSON for device-level settings - **Dual-way Sync**: Write to live files on switch, backfill from live when editing active provider - **Atomic Writes**: Temp file + rename pattern prevents config corruption - **Concurrency Safe**: Mutex-protected database connection avoids race conditions - **Layered Architecture**: Clear separation (Commands → Services → DAO → Database) **Key Components** - **ProviderService**: Provider CRUD, switching, backfill, sorting - **McpService**: MCP server management, import/export, live file sync - **ProxyService**: Local proxy mode with hot-switching and format conversion - **SessionManager**: Claude Code conversation history browsing - **ConfigService**: Config import/export, backup rotation - **SpeedtestService**: API endpoint latency measurement
Development Guide ### Environment Requirements - Node.js 18+ - pnpm 8+ - Rust 1.85+ - Tauri CLI 2.8+ ### Development Commands ```bash # Install dependencies pnpm install # Dev mode (hot reload) pnpm dev # Type check pnpm typecheck # Format code pnpm format # Check code format pnpm format:check # Run frontend unit tests pnpm test:unit # Run tests in watch mode (recommended for development) pnpm test:unit:watch # Build application pnpm build # Build debug version pnpm tauri build --debug ``` ### Rust Backend Development ```bash cd src-tauri # Format Rust code cargo fmt # Run clippy checks cargo clippy # Run backend tests cargo test # Run specific tests cargo test test_name # Run tests with test-hooks feature cargo test --features test-hooks ``` ### Testing Guide **Frontend Testing**: - Uses **vitest** as test framework - Uses **MSW (Mock Service Worker)** to mock Tauri API calls - Uses **@testing-library/react** for component testing **Running Tests**: ```bash # Run all tests pnpm test:unit # Watch mode (auto re-run) pnpm test:unit:watch # With coverage report pnpm test:unit --coverage ``` ### Tech Stack **Frontend**: React 18 · TypeScript · Vite · TailwindCSS 3.4 · TanStack Query v5 · react-i18next · react-hook-form · zod · shadcn/ui · @dnd-kit **Backend**: Tauri 2.8 · Rust · serde · tokio · thiserror · tauri-plugin-updater/process/dialog/store/log **Testing**: vitest · MSW · @testing-library/react
Project Structure ``` ├── src/ # Frontend (React + TypeScript) │ ├── components/ │ │ ├── providers/ # Provider management │ │ ├── mcp/ # MCP panel │ │ ├── prompts/ # Prompts management │ │ ├── skills/ # Skills management │ │ ├── sessions/ # Session Manager │ │ ├── proxy/ # Proxy mode panel │ │ ├── openclaw/ # OpenClaw config panels │ │ ├── settings/ # Settings (Terminal/Backup/About) │ │ ├── deeplink/ # Deep Link import │ │ ├── env/ # Environment variable management │ │ ├── universal/ # Cross-app configuration │ │ ├── usage/ # Usage statistics │ │ └── ui/ # shadcn/ui component library │ ├── hooks/ # Custom hooks (business logic) │ ├── lib/ │ │ ├── api/ # Tauri API wrapper (type-safe) │ │ └── query/ # TanStack Query config │ ├── locales/ # Translations (zh/en/ja) │ ├── config/ # Presets (providers/mcp) │ └── types/ # TypeScript definitions ├── src-tauri/ # Backend (Rust) │ └── src/ │ ├── commands/ # Tauri command layer (by domain) │ ├── services/ # Business logic layer │ ├── database/ # SQLite DAO layer │ ├── proxy/ # Proxy module │ ├── session_manager/ # Session management │ ├── deeplink/ # Deep Link handling │ └── mcp/ # MCP sync module ├── tests/ # Frontend tests └── assets/ # Screenshots & partner resources ```
## Contributing Issues and suggestions are welcome! Before submitting PRs, please ensure: - Pass type check: `pnpm typecheck` - Pass format check: `pnpm format:check` - Pass unit tests: `pnpm test:unit` For new features, please open an issue for discussion before submitting a PR. PRs for features that are not a good fit for the project may be closed. ## Star History [![Star History Chart](https://api.star-history.com/svg?repos=farion1231/cc-switch&type=Date)](https://www.star-history.com/#farion1231/cc-switch&Date) ## License MIT © Jason Young ================================================ FILE: README_JA.md ================================================
# CC Switch ### Claude Code、Codex、Gemini CLI、OpenCode、OpenClaw のオールインワン管理ツール [![Version](https://img.shields.io/badge/version-3.12.3-blue.svg)](https://github.com/farion1231/cc-switch/releases) [![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20macOS%20%7C%20Linux-lightgrey.svg)](https://github.com/farion1231/cc-switch/releases) [![Built with Tauri](https://img.shields.io/badge/built%20with-Tauri%202-orange.svg)](https://tauri.app/) [![Downloads](https://img.shields.io/endpoint?url=https://api.pinstudios.net/api/badges/downloads/farion1231/cc-switch/total)](https://github.com/farion1231/cc-switch/releases/latest) farion1231%2Fcc-switch | Trendshift [English](README.md) | [中文](README_ZH.md) | 日本語 | [Changelog](CHANGELOG.md)
## ❤️スポンサー
クリックで折りたたむ [![MiniMax](assets/partners/banners/minimax-en.jpeg)](https://platform.minimax.io/subscribe/coding-plan?code=ClLhgxr2je&source=link) MiniMax-M2.5 は、実際の生産性向上のために設計された最先端の大規模言語モデルです。多様で複雑な実環境のデジタルワークスペースでトレーニングされた M2.5 は、M2.1 のコーディング能力をベースに一般的なオフィス業務へと拡張し、Word・Excel・PowerPoint ファイルの生成と操作、多様なソフトウェア環境間のコンテキスト切り替え、異なるエージェントや人間チーム間での協働を流暢にこなします。SWE-Bench Verified で 80.2%、Multi-SWE-Bench で 51.3%、BrowseComp で 76.3% を達成し、計画的な行動と出力の最適化トレーニングにより、前世代よりもトークン効率に優れています。 [こちら](https://platform.minimax.io/subscribe/coding-plan?code=ClLhgxr2je&source=link)から MiniMax Coding Plan の限定 12% オフを入手! ---
PackyCode PackyCode のご支援に感謝します!PackyCode は Claude Code、Codex、Gemini などのリレーサービスを提供する信頼性の高い API 中継プラットフォームです。本ソフト利用者向けに特別割引があります:このリンクで登録し、チャージ時に「cc-switch」クーポンを入力すると 10% オフになります。
SiliconFlow SiliconFlow のご支援に感謝します!SiliconFlow は高性能 AI インフラストラクチャおよびモデル API プラットフォームで、言語・音声・画像・動画モデルへの高速かつ信頼性の高いアクセスをワンストップで提供します。従量課金制、豊富なマルチモーダルモデル対応、高速推論、エンタープライズグレードの安定性を備え、開発者やチームがより効率的に AI アプリケーションを構築・拡張できるようサポートします。このリンクから登録し、本人確認を完了すると、プラットフォーム内の全モデルで利用可能な ¥20 のボーナスクレジットが付与されます。SiliconFlow は OpenClaw にも対応しており、SiliconFlow の API キーを接続することで主要な AI モデルを無料で呼び出すことができます。
AIGoCode 本プロジェクトは AIGoCode のスポンサー提供でお届けしています。AIGoCode は、Claude Code・Codex・最新の Gemini モデルを統合したオールインワンのAIコーディングプラットフォームで、安定性・高速性・コストパフォーマンスに優れた開発サービスを提供します。柔軟なサブスクリプションプランを備え、レスポンスも非常に高速です。さらに、CC Switch ユーザー向けの特典として、このリンクから登録すると、初回チャージ時に10%分のボーナスクレジットが付与されます!
AICodeMirror AICodeMirror のご支援に感謝します!AICodeMirror は Claude Code / Codex / Gemini CLI の公式高安定リレーサービスを提供しており、エンタープライズ級の同時接続、迅速な請求書発行、24時間年中無休の専用テクニカルサポートを備えています。 Claude Code / Codex / Gemini 公式チャンネルが最安で元価格の 38% / 2% / 9%、チャージ時にはさらに割引!AICodeMirror は CC Switch ユーザー向けに特別特典を用意:このリンクから登録すると初回チャージ 20% オフ、法人のお客様は最大 25% オフ!
Cubence Cubence のご支援に感謝します!Cubence は Claude Code、Codex、Gemini などのリレーサービスを提供する信頼性の高い API 中継プラットフォームで、従量課金や月額プランなど柔軟な料金体系を提供しています。CC Switch ユーザー向けの特別割引:このリンクで登録し、チャージ時に「CCSWITCH」クーポンを入力すると、毎回 10% オフになります!
DMXAPI DMXAPI のご支援に感謝します!DMXAPI は 200 社以上の企業ユーザーにグローバル大規模モデル API サービスを提供しています。1 つの API キーで全世界のモデルにアクセス可能。即時請求書発行、同時接続数無制限、最低 $0.15 から、24 時間年中無休のテクニカルサポート。GPT/Claude/Gemini が全て 32% オフ、国内モデルは 20〜50% オフ、Claude Code 専用モデルは 66% オフ実施中!登録はこちら
Compshare Compshare のご支援に感謝します!Compshare は UCloud 傘下の AI クラウドプラットフォームで、国内外の安定した包括的なモデル API を 1 つのキーだけで利用可能。月額・従量課金のコストパフォーマンスに優れた Coding Plan パッケージを提供し、公式価格の 60〜80% オフで利用できます。Claude Code、Codex および API アクセスに対応。エンタープライズ級の高同時接続、24 時間年中無休のテクニカルサポート、セルフサービス請求書発行に対応。こちらのリンクから登録すると、無料で 5 元分のプラットフォーム体験クレジットがもらえます!
RightCode 本プロジェクトへのご支援として、Right Code にご協賛いただき誠にありがとうございます。Right Code は、Claude Code、Codex、Gemini などのモデルに対応した中継(プロキシ)サービスを安定して提供しています。特に高いコストパフォーマンスを誇る Codex の月額プランを主力としており、未使用分の利用枠を翌日に繰り越して利用できる(繰越対応)点が特長です。チャージ(入金)後に請求書の発行が可能で、企業・チーム向けには専任担当による個別対応も行っています。さらに CC Switch ユーザー向けの特別優待として、こちらのリンクからご登録いただくと、チャージのたびに実支払額の 25% 相当の従量課金クレジットが付与されます。
AICoding AICoding.sh のご支援に感謝します!AICoding.sh —— グローバル AI モデル API 超お得な中継サービス!Claude Code 81% オフ、GPT 99% オフ!数百社の企業に高コストパフォーマンスの AI サービスを提供。Claude Code、GPT、Gemini および国内主要モデルに対応、エンタープライズ級の高同時接続、迅速な請求書発行、24 時間年中無休の専属テクニカルサポート。こちらのリンクから登録した CC Switch ユーザーは、初回チャージ 10% オフ!
Crazyrouter Crazyrouter のご支援に感謝します!Crazyrouter は高性能 AI API アグリゲーションプラットフォームです。1 つの API キーで Claude Code、Codex、Gemini CLI など 300 以上のモデルにアクセス可能。全モデルが公式価格の 55% で利用でき、自動フェイルオーバー、スマートルーティング、無制限同時接続に対応。CC Switch ユーザー向けの限定特典:こちらのリンクから登録すると $2 の無料クレジット を即時進呈。さらに初回チャージ時にプロモコード `CCSWITCH` を入力すると 30% のボーナスクレジット が追加されます!
SSSAiCode SSSAiCode のご支援に感謝します!SSSAiCode は安定性と信頼性に優れた API 中継サービスで、安定的で信頼性が高く、手頃な価格の Claude・Codex モデルサービスを提供しています。高コストパフォーマンスの公式 Claude サービスを 0.5¥/$ 換算で提供、月額制・Paygo など多様な課金方式に対応し、当日の迅速な請求書発行をサポート。CC Switch ユーザー向けの特別特典:こちらのリンクから登録すると、毎回のチャージで $10 の追加ボーナスを受けられます!
Micu Micu API のご支援に感謝します!Micu API は、最高のコストパフォーマンスと高い安定性を追求するグローバル大規模言語モデル中継サービスプロバイダーです。法人企業がバックアップしており、サービス停止のリスクを排除、迅速な正規請求書発行に対応!「試行コストゼロ」をモットーに、最低 1 元からチャージ可能で手数料無料、いつでも返金可能!CC Switch ユーザー向けの限定特典:こちらのリンクから登録し、チャージ時にプロモコード「ccswitch」を入力すると 10% 割引 が適用されます!
XCodeAPI XCodeAPI のご支援に感謝します!CC Switch ユーザー向けの特別特典:こちらのリンクから登録すると、初回注文で 10% の追加クレジットボーナスがもらえます!(サイト管理者に連絡して受け取りください)
CTok CTok.ai のご支援に感謝します!CTok.ai はワンストップ AI プログラミングツールサービスプラットフォームの構築に取り組んでいます。Claude Code のプロフェッショナルプランと技術コミュニティサービスを提供し、Google Gemini や OpenAI Codex にも対応しています。丁寧に設計されたプランと専門的な技術コミュニティを通じて、開発者に安定したサービス保証と継続的な技術サポートを提供し、AI アシストプログラミングを真の生産性ツールにします。こちらから登録してください!
## CC Switch を選ぶ理由 最新の AI コーディングは Claude Code、Codex、Gemini CLI、OpenCode、OpenClaw などの CLI ツールに依存していますが、各ツールの設定形式はバラバラです。API プロバイダを切り替えるたびに JSON、TOML、`.env` ファイルを手動で編集する必要があり、複数ツール間で MCP や Skills を統一的に管理する手段もありません。 **CC Switch** は、5 つの CLI ツールを 1 つのデスクトップアプリで一元管理できます。設定ファイルを手作業で編集する代わりに、ワンクリックでプロバイダをインポートし、瞬時に切り替えられるビジュアルインターフェースを提供します。50 以上の組み込みプリセット、統一 MCP・Skills 管理、システムトレイからの即時切り替え機能を搭載。すべてはアトミック書き込みによる信頼性の高い SQLite データベースに支えられており、設定の破損を防ぎます。 - **1 つのアプリで 5 つの CLI ツール** -- Claude Code、Codex、Gemini CLI、OpenCode、OpenClaw を単一インターフェースで管理 - **手動編集は不要** -- AWS Bedrock、NVIDIA NIM、コミュニティリレーなど 50 以上のプロバイダプリセットを内蔵。選んで切り替えるだけ - **統一 MCP・Skills 管理** -- 1 つのパネルで 4 つのアプリの MCP サーバーと Skills を双方向同期で管理 - **システムトレイでクイック切り替え** -- トレイメニューから即座にプロバイダを切り替え。アプリを開く必要なし - **クラウド同期** -- Dropbox、OneDrive、iCloud、または WebDAV サーバー経由でデバイス間のプロバイダデータを同期 - **クロスプラットフォーム** -- Tauri 2 で構築された Windows、macOS、Linux 対応のネイティブデスクトップアプリ - **便利ツール内蔵** -- 初回起動時のログイン確認、署名バイパス、プラグイン拡張の同期など、さまざまなユーティリティを搭載 ## スクリーンショット | メイン画面 | プロバイダ追加 | | :-------------------------------------------: | :----------------------------------------------: | | ![メイン画面](assets/screenshots/main-ja.png) | ![プロバイダ追加](assets/screenshots/add-ja.png) | ## 特長 [完全な更新履歴](CHANGELOG.md) | [リリースノート](docs/release-notes/v3.12.3-ja.md) ### プロバイダ管理 - **5 つの CLI ツール、50 以上のプリセット** -- Claude Code、Codex、Gemini CLI、OpenCode、OpenClaw。キーをコピーしてワンクリックでインポート - **ユニバーサルプロバイダ** -- 1 つの設定を複数アプリに同期(OpenCode、OpenClaw) - ワンクリック切り替え、システムトレイクイックアクセス、ドラッグ&ドロップ並び替え、インポート/エクスポート ### プロキシ & フェイルオーバー - **ローカルプロキシのホットスイッチ** -- フォーマット変換、自動フェイルオーバー、サーキットブレーカー、プロバイダヘルスモニタリング、リクエストレクティファイア - **アプリレベルのテイクオーバー** -- Claude、Codex、Gemini を個別にプロキシ経由でルーティング、プロバイダ単位で設定可能 ### MCP、Prompts & Skills - **統一 MCP パネル** -- 4 つのアプリの MCP サーバーを管理、双方向同期、Deep Link インポート対応 - **Prompts** -- Markdown エディタ、クロスアプリ同期(CLAUDE.md / AGENTS.md / GEMINI.md)、バックフィル保護 - **Skills** -- GitHub リポジトリまたは ZIP ファイルからワンクリックインストール、カスタムリポジトリ管理、シンボリックリンクとファイルコピーに対応 ### 使用量 & コストトラッキング - **使用量ダッシュボード** -- プロバイダ横断で支出・リクエスト数・トークン使用量を追跡、トレンドチャート、詳細リクエストログ、カスタムモデル価格設定 ### Session Manager & ワークスペース - すべてのアプリの会話履歴を閲覧・検索・復元 - **ワークスペースエディタ**(OpenClaw)-- エージェントファイル(AGENTS.md、SOUL.md など)を Markdown プレビュー付きで編集 ### システム & プラットフォーム - **クラウド同期** -- カスタム設定ディレクトリ(Dropbox、OneDrive、iCloud、NAS)および WebDAV サーバー同期 - **Deep Link** (`ccswitch://`) -- URL 経由でプロバイダ、MCP サーバー、Prompts、Skills をワンクリックインポート - ダーク / ライト / システムテーマ、自動起動、自動アップデーター、アトミック書き込み、自動バックアップ、多言語対応(中/英/日) ## よくある質問
CC Switch はどの AI CLI ツールに対応していますか? CC Switch は **Claude Code**、**Codex**、**Gemini CLI**、**OpenCode**、**OpenClaw** の 5 つのツールに対応しています。各ツールに専用のプロバイダプリセットと設定管理が用意されています。
プロバイダを切り替えた後、ターミナルの再起動は必要ですか? ほとんどのツールでは、はい。変更を反映するにはターミナルまたは CLI ツールを再起動してください。ただし **Claude Code** は例外で、現在プロバイダデータのホットスイッチに対応しており、再起動は不要です。
プロバイダを切り替えた後、プラグイン設定が消えてしまいました。どうすればよいですか? CC Switch には「共有設定スニペット」機能があり、APIキーやエンドポイント以外の共通データをプロバイダ間で引き継ぐことができます。「プロバイダ編集」→「共有設定パネル」→「現在のプロバイダから抽出」をクリックして、すべての共通データを保存してください。新しいプロバイダを作成する際に「共有設定を書き込む」にチェック(デフォルトで有効)を入れれば、プラグインなどのデータが新しいプロバイダ設定に含まれます。すべての設定項目は、アプリ初回起動時にインポートされたデフォルトプロバイダに保存されており、失われることはありません。
macOS で「開発元を確認できません」と表示されます。どうすればよいですか? 開発者が Apple Developer アカウントをまだ取得していないためです(登録手続き中)。警告を閉じてから、**システム設定 → プライバシーとセキュリティ → このまま開く**をクリックしてください。以降は通常通り起動できます。
現在アクティブなプロバイダを削除できないのはなぜですか? CC Switch は「最小限の介入」という設計原則に従っています。アプリをアンインストールしても、CLI ツールは正常に動作し続けます。すべての設定を削除すると対応する CLI ツールが使用できなくなるため、システムは常にアクティブな設定を 1 つ保持します。特定の CLI ツールをあまり使用しない場合は、設定で非表示にできます。公式ログインに戻す方法は、次の質問をご覧ください。
公式ログインに戻すにはどうすればよいですか? プリセットリストから公式プロバイダを追加してください。切り替え後、ログアウト/ログインのフローを実行すれば、以降は公式プロバイダとサードパーティプロバイダを自由に切り替えられます。Codex では異なる公式プロバイダ間の切り替えに対応しており、複数の Plus アカウントや Team アカウントの切り替えに便利です。
データはどこに保存されますか? - **データベース**: `~/.cc-switch/cc-switch.db`(SQLite -- プロバイダ、MCP、Prompts、Skills) - **ローカル設定**: `~/.cc-switch/settings.json`(デバイスレベルの UI 設定) - **バックアップ**: `~/.cc-switch/backups/`(自動ローテーション、最新 10 件を保持) - **Skills**: `~/.cc-switch/skills/`(デフォルトでシンボリックリンクにより対応アプリに接続) - **Skill バックアップ**: `~/.cc-switch/skill-backups/`(アンインストール前に自動作成、最新 20 件を保持)
## ドキュメント 各機能の詳しい使い方については、**[ユーザーマニュアル](docs/user-manual/ja/README.md)** をご覧ください。プロバイダ管理、MCP/Prompts/Skills、プロキシとフェイルオーバーなど、すべての機能を網羅しています。 ## クイックスタート ### 基本的な使い方 1. **プロバイダ追加**: 「Add Provider」をクリック → プリセットを選ぶかカスタム設定を作成 2. **プロバイダ切り替え**: - メイン UI: プロバイダを選択 → 「Enable」をクリック - システムトレイ: プロバイダ名をクリック(即時反映) 3. **反映**: ターミナルまたは対応する CLI ツールを再起動して適用(Claude Code は再起動不要) 4. **公式設定に戻す**: 「Official Login」プリセットを追加し、CLI ツールを再起動してログイン/OAuth フローを実行 ### MCP、Prompts、Skills & Sessions - **MCP**: 「MCP」ボタンをクリック → テンプレートまたはカスタム設定でサーバーを追加 → アプリごとの同期をトグルで切り替え - **Prompts**: 「Prompts」をクリック → Markdown エディタでプリセットを作成 → 有効化してライブファイルに同期 - **Skills**: 「Skills」をクリック → GitHub リポジトリを閲覧 → ワンクリックですべてのアプリにインストール - **Sessions**: 「Sessions」をクリック → すべてのアプリの会話履歴を閲覧・検索・復元 > **補足**: 初回起動時に、既存の CLI ツール設定を手動でインポートしてデフォルトプロバイダとして使用できます。 ## ダウンロード & インストール ### システム要件 - **Windows**: Windows 10 以上 - **macOS**: macOS 12 (Monterey) 以上 - **Linux**: Ubuntu 22.04+ / Debian 11+ / Fedora 34+ など主要ディストリビューション ### Windows ユーザー [Releases](../../releases) ページから最新版の `CC-Switch-v{version}-Windows.msi` インストーラー、またはポータブル版 `CC-Switch-v{version}-Windows-Portable.zip` をダウンロード。 ### macOS ユーザー **方法 1: Homebrew でインストール(推奨)** ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` アップデート: ```bash brew upgrade --cask cc-switch ``` **方法 2: 手動ダウンロード** [Releases](../../releases) から `CC-Switch-v{version}-macOS.zip` をダウンロードして展開。 > **注意**: 開発者アカウント未登録のため、初回起動時に「開発元を確認できません」と表示される場合があります。一度閉じてから「システム設定」→「プライバシーとセキュリティ」→「このまま開く」をクリックしてください。以降は通常通り起動できます。 ### Arch Linux ユーザー **paru でインストール(推奨)** ```bash paru -S cc-switch-bin ``` ### Linux ユーザー [Releases](../../releases) から最新版の Linux ビルドをダウンロード: - `CC-Switch-v{version}-Linux.deb`(Debian/Ubuntu) - `CC-Switch-v{version}-Linux.rpm`(Fedora/RHEL/openSUSE) - `CC-Switch-v{version}-Linux.AppImage`(汎用) - `CC-Switch-v{version}-Linux.flatpak`(Flatpak) Flatpak のインストールと起動: ```bash flatpak install --user ./CC-Switch-v{version}-Linux.flatpak flatpak run com.ccswitch.desktop ```
アーキテクチャ概要 ### 設計原則 ``` ┌─────────────────────────────────────────────────────────────┐ │ Frontend (React + TS) │ │ ┌─────────────┐ ┌──────────────┐ ┌──────────────────┐ │ │ │ Components │ │ Hooks │ │ TanStack Query │ │ │ │ (UI) │──│ (Bus. Logic) │──│ (Cache/Sync) │ │ │ └─────────────┘ └──────────────┘ └──────────────────┘ │ └────────────────────────┬────────────────────────────────────┘ │ Tauri IPC ┌────────────────────────▼────────────────────────────────────┐ │ Backend (Tauri + Rust) │ │ ┌─────────────┐ ┌──────────────┐ ┌──────────────────┐ │ │ │ Commands │ │ Services │ │ Models/Config │ │ │ │ (API Layer) │──│ (Bus. Layer) │──│ (Data) │ │ │ └─────────────┘ └──────────────┘ └──────────────────┘ │ └─────────────────────────────────────────────────────────────┘ ``` **コア設計パターン** - **SSOT** (Single Source of Truth): すべてのデータを `~/.cc-switch/cc-switch.db`(SQLite)に集約 - **二層ストレージ**: 同期データは SQLite、デバイスデータは JSON - **双方向同期**: 切り替え時はライブファイルへ書き込み、編集時はアクティブプロバイダから逆同期 - **アトミック書き込み**: 一時ファイル + rename パターンで設定破損を防止 - **並行安全**: Mutex で保護された DB 接続でレースコンディションを防止 - **レイヤードアーキテクチャ**: Commands → Services → DAO → Database を明確に分離 **主要コンポーネント** - **ProviderService**: プロバイダの CRUD、切り替え、バックフィル、ソート - **McpService**: MCP サーバー管理、インポート/エクスポート、ライブファイル同期 - **ProxyService**: ローカル Proxy モードのホットスイッチとフォーマット変換 - **SessionManager**: Claude Code の会話履歴閲覧 - **ConfigService**: 設定のインポート/エクスポート、バックアップローテーション - **SpeedtestService**: API エンドポイントの遅延計測
開発ガイド ### 開発環境 - Node.js 18+ - pnpm 8+ - Rust 1.85+ - Tauri CLI 2.8+ ### 開発コマンド ```bash # 依存関係をインストール pnpm install # ホットリロード付き開発モード pnpm dev # 型チェック pnpm typecheck # コード整形 pnpm format # フォーマット検証 pnpm format:check # フロントエンド単体テスト pnpm test:unit # ウォッチモード(開発に推奨) pnpm test:unit:watch # アプリをビルド pnpm build # デバッグビルド pnpm tauri build --debug ``` ### Rust バックエンド開発 ```bash cd src-tauri # Rust コード整形 cargo fmt # clippy チェック cargo clippy # バックエンドテスト cargo test # 特定テストのみ実行 cargo test test_name # test-hooks フィーチャー付きでテスト cargo test --features test-hooks ``` ### テストガイド **フロントエンドテスト**: - テストフレームワークに **vitest** を使用 - **MSW (Mock Service Worker)** で Tauri API 呼び出しをモック - コンポーネントテストに **@testing-library/react** を採用 **テスト実行**: ```bash # 全テストを実行 pnpm test:unit # ウォッチモード(自動再実行) pnpm test:unit:watch # カバレッジレポート付き pnpm test:unit --coverage ``` ### 技術スタック **フロントエンド**: React 18 · TypeScript · Vite · TailwindCSS 3.4 · TanStack Query v5 · react-i18next · react-hook-form · zod · shadcn/ui · @dnd-kit **バックエンド**: Tauri 2.8 · Rust · serde · tokio · thiserror · tauri-plugin-updater/process/dialog/store/log **テスト**: vitest · MSW · @testing-library/react
プロジェクト構成 ``` ├── src/ # フロントエンド (React + TypeScript) │ ├── components/ │ │ ├── providers/ # プロバイダ管理 │ │ ├── mcp/ # MCP パネル │ │ ├── prompts/ # Prompts 管理 │ │ ├── skills/ # Skills 管理 │ │ ├── sessions/ # Session Manager │ │ ├── proxy/ # Proxy モードパネル │ │ ├── openclaw/ # OpenClaw 設定パネル │ │ ├── settings/ # 設定 (Terminal/Backup/About) │ │ ├── deeplink/ # Deep Link インポート │ │ ├── env/ # 環境変数管理 │ │ ├── universal/ # クロスアプリ設定 │ │ ├── usage/ # 使用量統計 │ │ └── ui/ # shadcn/ui コンポーネントライブラリ │ ├── hooks/ # カスタムフック(ビジネスロジック) │ ├── lib/ │ │ ├── api/ # Tauri API ラッパー(型安全) │ │ └── query/ # TanStack Query 設定 │ ├── locales/ # 翻訳 (zh/en/ja) │ ├── config/ # プリセット (providers/mcp) │ └── types/ # TypeScript 型定義 ├── src-tauri/ # バックエンド (Rust) │ └── src/ │ ├── commands/ # Tauri コマンド層(ドメイン別) │ ├── services/ # ビジネスロジック層 │ ├── database/ # SQLite DAO 層 │ ├── proxy/ # Proxy モジュール │ ├── session_manager/ # セッション管理 │ ├── deeplink/ # Deep Link 処理 │ └── mcp/ # MCP 同期モジュール ├── tests/ # フロントエンドテスト └── assets/ # スクリーンショット & パートナーリソース ```
## 貢献 Issue や提案を歓迎します! PR を送る前に以下をご確認ください: - 型チェック: `pnpm typecheck` - フォーマットチェック: `pnpm format:check` - 単体テスト: `pnpm test:unit` 新機能の場合は、PR を送る前に Issue でディスカッションしてください。プロジェクトに合わない機能の PR はクローズされる場合があります。 ## Star History [![Star History Chart](https://api.star-history.com/svg?repos=farion1231/cc-switch&type=Date)](https://www.star-history.com/#farion1231/cc-switch&Date) ## ライセンス MIT © Jason Young ================================================ FILE: README_ZH.md ================================================
# CC Switch ### Claude Code、Codex、Gemini CLI、OpenCode 和 OpenClaw 的全方位管理工具 [![Version](https://img.shields.io/badge/version-3.12.3-blue.svg)](https://github.com/farion1231/cc-switch/releases) [![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20macOS%20%7C%20Linux-lightgrey.svg)](https://github.com/farion1231/cc-switch/releases) [![Built with Tauri](https://img.shields.io/badge/built%20with-Tauri%202-orange.svg)](https://tauri.app/) [![Downloads](https://img.shields.io/endpoint?url=https://api.pinstudios.net/api/badges/downloads/farion1231/cc-switch/total)](https://github.com/farion1231/cc-switch/releases/latest) farion1231%2Fcc-switch | Trendshift [English](README.md) | 中文 | [日本語](README_JA.md) | [更新日志](CHANGELOG.md)
## ❤️赞助商
点击折叠 [![MiniMax](assets/partners/banners/minimax-zh.jpeg)](https://platform.minimaxi.com/subscribe/coding-plan?code=7kYF2VoaCn&source=link) MiniMax M2.5 在编程、工具调用与搜索、办公等核心生产力场景均达到或刷新行业 SOTA,拥有架构师级代码能力与高效任务拆解能力,推理速度较上一代提升 37%、token 消耗更优;100 token/s 连续工作一小时仅需 1 美金,让复杂 Agent 规模化部署经济可行,已在企业多职能场景深度落地,加速全民 Agent 时代到来。 [点击](https://platform.minimaxi.com/subscribe/coding-plan?code=7kYF2VoaCn&source=link)即可领取 MiniMax Coding Plan 专属 88 折优惠! ---
PackyCode 感谢 PackyCode 赞助了本项目!PackyCode 是一家稳定、高效的API中转服务商,提供 Claude Code、Codex、Gemini 等多种中转服务。PackyCode 为本软件的用户提供了特别优惠,使用此链接注册并在充值时填写"cc-switch"优惠码,首次充值可以享受9折优惠!
SiliconFlow 感谢硅基流动赞助了本项目!硅基流动是一个高性能 AI 基础设施与模型 API 平台,一站式提供语言、语音、图像、视频等多模态模型的快速、可靠访问。平台支持按量计费、丰富的多模态模型选择、高速推理和企业级稳定性,帮助开发者和团队更高效地构建和扩展 AI 应用。通过此链接注册并完成实名认证,即可获得 ¥20 奖励金,可在平台内跨模型使用。硅基流动现已兼容 OpenClaw,用户可接入硅基流动 API Key 免费调用主流 AI 模型。
AIGoCode 感谢 AIGoCode 赞助了本项目!AIGoCode 是一个集成了 Claude Code、Codex 以及 Gemini 最新模型的一站式平台,为你提供稳定、高效且高性价比的AI编程服务。本站提供灵活的订阅计划,零封号风险,国内直连,无需魔法,极速响应。AIGoCode 为 CC Switch 的用户提供了特别福利,通过此链接注册的用户首次充值可以获得额外10%奖励额度!
AICodeMirror 感谢 AICodeMirror 赞助了本项目!AICodeMirror 提供 Claude Code / Codex / Gemini CLI 官方高稳定中转服务,支持企业级高并发、极速开票、7×24 专属技术支持。 Claude Code / Codex / Gemini 官方渠道低至 3.8 / 0.2 / 0.9 折,充值更有折上折!AICodeMirror 为 CCSwitch 的用户提供了特别福利,通过此链接注册的用户,可享受首充8折,企业客户最高可享 7.5 折!
Cubence 感谢 Cubence 赞助本项目!Cubence 是一家可靠高效的 API 中继服务提供商,提供对 Claude Code、Codex、Gemini 等模型的中继服务,并提供按量、包月等灵活的计费方式。Cubence 为 CC Switch 的用户提供了特别优惠:使用 此链接 注册,并在充值时输入 "CCSWITCH" 优惠码,每次充值均可享受九折优惠!
DMXAPI 感谢 DMXAPI(大模型API)赞助了本项目! DMXAPI,一个Key用全球大模型。 为200多家企业用户提供全球大模型API服务。· 充值即开票 ·当天开票 ·并发不限制 ·1元起充 · 7x24 在线技术辅导,GPT/Claude/Gemini全部6.8折,国内模型5~8折,Claude Code 专属模型3.4折进行中!点击这里注册
优云智算 感谢优云智算赞助了本项目!优云智算是UCloud旗下AI云平台,提供稳定、全面的国内外模型API,仅一个key即可调用。主打包月、按量的高性价比 Coding Plan 套餐,基于官方2~5折优惠。支持接入 Claude Code、Codex 及 API 调用。支持企业高并发、7*24技术支持、自助开票。通过此链接注册的用户,可得免费5元平台体验金!
RightCode 感谢 Right Code 赞助了本项目!Right Code 稳定提供 Claude Code、Codex、Gemini 等模型的中转服务。主打极高性价比的Codex包月套餐,提供额度转结,套餐当天用不完的额度,第二天还能接着用!充值即可开票,企业、团队用户一对一对接。同时为 CC Switch 的用户提供了特别优惠:通过此链接注册,每次充值均可获得实付金额25%的按量额度!
AICoding 感谢 AICoding.sh 赞助了本项目!AICoding.sh —— 全球大模型 API 超值中转服务!Claude Code 1.9 折,GPT 0.1 折,已为数百家企业提供高性价比 AI 服务。支持 Claude Code、GPT、Gemini 及国内主流模型,企业级高并发、极速开票、7×24 专属技术支持,通过此链接 注册的 CC Switch 用户,首充可享受九折优惠!
Crazyrouter 感谢 Crazyrouter 赞助了本项目!Crazyrouter 是一个高性能 AI API 聚合平台——一个 API Key 即可访问 300+ 模型,包括 Claude Code、Codex、Gemini CLI 等。全部模型低至官方定价的 55%,支持自动故障转移、智能路由和无限并发。Crazyrouter 为 CC Switch 用户提供了专属优惠:通过此链接注册即可获得 $2 免费额度,首次充值时输入优惠码 `CCSWITCH` 还可获得额外 30% 奖励额度
SSSAiCode 感谢 SSSAiCode 赞助了本项目!SSSAiCode 是一家稳定可靠的API中转站,致力于提供稳定、可靠、平价的Claude、CodeX模型服务,提供高性价比折合0.5¥/$的官方Claude服务,支持包月、Paygo多种计费方式、支持当日快速开票,SSSAiCode为本软件的用户提供特别优惠,使用此链接注册每次充值均可享受10$的额外奖励!
Micu 感谢 米醋API 赞助了本项目!米醋API 是一家致力于提供极致性价比与高稳定性的全球大模型中转服务商。米醋API 背后有实体企业做核心保障,杜绝跑路风险,支持极速正规开票!我们主打“试错零成本”:1 元起充低门槛,0 手续费随时退款!米醋API 为本软件的用户提供了特别优惠,使用此链接注册并在充值时填写"ccswitch"优惠码可享九折优惠!
XCodeAPI 感谢 XCodeAPI 赞助了本项目!XCodeAPI 为本软件的用户提供特别福利,使用此链接注册后首单加赠10%的额度!(联系站长领取)
CTok 感谢 CTok.ai 赞助了本项目!CTok.ai 致力于打造一站式 AI 编程工具服务平台。我们提供 Claude Code 专业套餐及技术社群服务,同时支持 Google Gemini 和 OpenAI Codex。通过精心设计的套餐方案和专业的技术社群,为开发者提供稳定的服务保障和持续的技术支持,让 AI 辅助编程真正成为开发者的生产力工具。点击这里注册!
## 为什么选择 CC Switch? 现代 AI 编程依赖于 Claude Code、Codex、Gemini CLI、OpenCode 和 OpenClaw 等 CLI 工具——但每个工具都有自己的配置格式。切换 API 供应商意味着手动编辑 JSON、TOML 或 `.env` 文件,而在多个工具之间缺乏一个统一管理 MCP, SKILLS 的方式。 **CC Switch** 为你提供一个桌面应用来管理所有五个 CLI 工具。无需手动编辑配置文件,你将获得一个可视化界面,一键将供应商导入应用,一键在不同的供应商之间进行切换,内置 50+ 供应商预设、统一的 MCP, SKILLS 管理以及系统托盘即时切换功能——所有操作都基于可靠的 SQLite 数据库和原子写入机制,保护你的配置不被损坏。 - **一个应用,五个 CLI 工具** — 在单一界面中管理 Claude Code、Codex、Gemini CLI、OpenCode 和 OpenClaw - **告别手动编辑** — 50+ 供应商预设,包括 AWS Bedrock、NVIDIA NIM 和社区中转服务;一键即可切换 - **统一 MCP, SKILLS 管理** — 一个面板管理四个应用的 MCP, SKILLS, 支持双向同步 - **系统托盘快速切换** — 从托盘菜单即时切换供应商,无需打开完整应用 - **云同步** — 通过 Dropbox、OneDrive、iCloud 或 WebDAV 服务器在不同设备之间同步供应商数据 - **跨平台** — 基于 Tauri 2 构建的原生桌面应用,支持 Windows、macOS 和 Linux - **小工具** - 内置了多种小工具来解决首次安装登录确认、禁止签名、插件拓展同步等多种功能 ## 界面预览 | 主界面 | 添加供应商 | | :---------------------------------------: | :------------------------------------------: | | ![主界面](assets/screenshots/main-zh.png) | ![添加供应商](assets/screenshots/add-zh.png) | ## 功能特性 [完整更新日志](CHANGELOG.md) | [发布说明](docs/release-notes/v3.12.3-zh.md) ### 供应商管理 - **5 个 CLI 工具,50+ 预设** — Claude Code、Codex、Gemini CLI、OpenCode、OpenClaw;复制 key 即可一键导入 - **通用供应商** — 一份配置同步到多个应用(OpenCode、OpenClaw) - 一键切换、系统托盘快速访问、拖拽排序、导入导出 ### 代理与故障转移 - **本地代理热切换** — 格式转换、自动故障转移、熔断器、供应商健康监控和整流器 - **应用级代理接管** — 独立为 Claude、Codex 或 Gemini 配置代理,具体到单个供应商 ### MCP、Prompts 与 Skills - **统一 MCP 面板** — 管理 4 个应用的 MCP 服务器,双向同步,支持 Deep Link 导入 - **Prompts** — Markdown 编辑器,跨应用同步(CLAUDE.md / AGENTS.md / GEMINI.md),回填保护 - **Skills** — 从 GitHub 仓库或 ZIP 文件一键安装,自定义仓库管理,支持软连接和文件复制 ### 用量与成本追踪 - **用量仪表盘** — 跨供应商追踪支出、请求数和 Token 用量,趋势图表、详细请求日志和自定义模型定价 ### 会话管理器与工作区 - 浏览、搜索和恢复全部应用对话历史 - **工作区编辑器**(OpenClaw)— 编辑 Agent 文件(AGENTS.md、SOUL.md 等),支持 Markdown 预览 ### 系统与平台 - **云同步** — 自定义配置目录(Dropbox、OneDrive、iCloud、坚果云、NAS)及 WebDAV 服务器同步 - **Deep Link** (`ccswitch://`) — 通过 URL 一键导入供应商、MCP 服务器、提示词和技能 - 深色 / 浅色 / 跟随系统主题、开机自启、自动更新、原子写入、自动备份、国际化(中/英/日) ## 常见问题
CC Switch 支持哪些 AI CLI 工具? CC Switch 支持五个工具:**Claude Code**、**Codex**、**Gemini CLI**、**OpenCode** 和 **OpenClaw**。每个工具都有专属的供应商预设和配置管理。
切换供应商后需要重启终端吗? 大多数工具需要重启终端或 CLI 工具才能使更改生效。例外的是 **Claude Code**,它目前支持供应商数据的热切换,无需重启。
切换供应商之后我的插件配置怎么不见了? CC Switch 使用“通用配置片段”功能,在不同的供应商之间传递 Key 和请求地址之外的通用数据,您可以在“编辑供应商”菜单的“通用配置面板”里,点击“从当前供应商提取”,把所有的通用数据提取到通用配置中,之后在新建“供应商”的时候,只要勾选“写入通用配置”(默认勾选),就会把插件等数据写入到新的供应商配置中。您的所有配置项都会保存在运行本软件的时候,第一次导入的默认供应商里面,不会丢失。
macOS 提示"未知开发者"警告 — 如何解决? 这是由于作者没有苹果开发者账号(正在注册中)。关闭警告后,前往**系统设置 → 隐私与安全性 → 仍要打开**。之后应用即可正常打开。
为什么总有一个正在激活中的供应商无法删除? 本软件的设计原则是“最小侵入性”,即使卸载本软件,也不会影响应用的正常使用。 所以系统总会保留一个正在激活中的配置,因为如果将所有配置全部删除,该应用将无法正常使用。如果你不经常使用某个对应的应用,可以在设置中关掉该应用的显示。如果你想切换回官方登录,可以参考下条。
如何切换回官方登录? 可以在预设供应商里面添加一个官方供应商。切换过去之后,执行一遍 Log out / Log in 流程,之后便可以在官方供应商和第三方供应商之间随意切换。CodeX 可以在不同官方供应商之间进行切换,方便多个 Plus 或者 Team 账号之间切换。
我的数据存储在哪里? - **数据库**:`~/.cc-switch/cc-switch.db`(SQLite — 供应商、MCP、提示词、技能) - **本地设置**:`~/.cc-switch/settings.json`(设备级 UI 偏好设置) - **备份**:`~/.cc-switch/backups/`(自动轮换,保留最近 10 个) - **SKILLS**:`~/.cc-switch/skills/`(默认通过软链接连接到对应应用) - **技能备份**:`~/.cc-switch/skill-backups/`(卸载前自动创建,保留最近 20 个)
## 文档 如需了解各项功能的详细使用方法,请查阅 **[用户手册](docs/user-manual/zh/README.md)** — 涵盖供应商管理、MCP/Prompts/Skills、代理与故障转移等全部功能。 ## 快速开始 ### 基本使用 1. **添加供应商**:点击"添加供应商" → 选择预设或创建自定义配置 2. **切换供应商**: - 主界面:选择供应商 → 点击"启用" - 系统托盘:直接点击供应商名称(立即生效) 3. **生效方式**:重启终端或对应的 CLI 工具以应用更改(CLaude Code 无需重启) 4. **恢复官方登录**:添加"官方登录"预设,重启 CLI 工具后按照其登录/OAuth 流程操作 ### MCP、Prompts、Skills 与会话 - **MCP**:点击"MCP"按钮 → 通过模板或自定义配置添加服务器 → 切换各应用同步开关 - **Prompts**:点击"Prompts" → 使用 Markdown 编辑器创建预设 → 激活后同步到 live 文件 - **Skills**:点击"Skills" → 浏览 GitHub 仓库 → 一键安装到全部应用 - **会话**:点击"Sessions" → 浏览和搜索和恢复全部应用对话历史 > **注意**:首次启动可以手动导入现有 CLI 工具配置作为默认供应商。 ## 下载安装 ### 系统要求 - **Windows**:Windows 10 及以上 - **macOS**:macOS 12 (Monterey) 及以上 - **Linux**:Ubuntu 22.04+ / Debian 11+ / Fedora 34+ 等主流发行版 ### Windows 用户 从 [Releases](../../releases) 页面下载最新版本的 `CC-Switch-v{版本号}-Windows.msi` 安装包或 `CC-Switch-v{版本号}-Windows-Portable.zip` 绿色版。 ### macOS 用户 **方式一:通过 Homebrew 安装(推荐)** ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` **方式二:手动下载** 从 [Releases](../../releases) 页面下载 `CC-Switch-v{版本号}-macOS.zip` 解压使用。 > **注意**:由于作者没有苹果开发者账号,首次打开可能出现"未知开发者"警告,请先关闭,然后前往"系统设置" → "隐私与安全性" → 点击"仍要打开",之后便可以正常打开。 ### Arch Linux 用户 **通过 paru 安装(推荐)** ```bash paru -S cc-switch-bin ``` ### Linux 用户 从 [Releases](../../releases) 页面下载最新版本的 Linux 安装包: - `CC-Switch-v{版本号}-Linux.deb`(Debian/Ubuntu) - `CC-Switch-v{版本号}-Linux.rpm`(Fedora/RHEL/openSUSE) - `CC-Switch-v{版本号}-Linux.AppImage`(通用) - `CC-Switch-v{版本号}-Linux.flatpak`(Flatpak) Flatpak 安装与运行: ```bash flatpak install --user ./CC-Switch-v{版本号}-Linux.flatpak flatpak run com.ccswitch.desktop ```
架构总览 ### 设计原则 ``` ┌─────────────────────────────────────────────────────────────┐ │ 前端 (React + TS) │ │ ┌─────────────┐ ┌──────────────┐ ┌──────────────────┐ │ │ │ Components │ │ Hooks │ │ TanStack Query │ │ │ │ (UI) │──│ (业务逻辑) │──│ (缓存/同步) │ │ │ └─────────────┘ └──────────────┘ └──────────────────┘ │ └────────────────────────┬────────────────────────────────────┘ │ Tauri IPC ┌────────────────────────▼────────────────────────────────────┐ │ 后端 (Tauri + Rust) │ │ ┌─────────────┐ ┌──────────────┐ ┌──────────────────┐ │ │ │ Commands │ │ Services │ │ Models/Config │ │ │ │ (API 层) │──│ (业务层) │──│ (数据) │ │ │ └─────────────┘ └──────────────┘ └──────────────────┘ │ └─────────────────────────────────────────────────────────────┘ ``` **核心设计模式** - **SSOT**(单一事实源):所有数据存储在 `~/.cc-switch/cc-switch.db`(SQLite) - **双层存储**:SQLite 存储可同步数据,JSON 存储设备级设置 - **双向同步**:切换时写入 live 文件,编辑当前供应商时从 live 回填 - **原子写入**:临时文件 + 重命名模式防止配置损坏 - **并发安全**:Mutex 保护的数据库连接避免竞态条件 - **分层架构**:清晰分离(Commands → Services → DAO → Database) **核心组件** - **ProviderService**:供应商增删改查、切换、回填、排序 - **McpService**:MCP 服务器管理、导入导出、live 文件同步 - **ProxyService**:本地 Proxy 模式,支持热切换和格式转换 - **SessionManager**:Claude Code 对话历史浏览 - **ConfigService**:配置导入导出、备份轮换 - **SpeedtestService**:API 端点延迟测量
开发指南 ### 环境要求 - Node.js 18+ - pnpm 8+ - Rust 1.85+ - Tauri CLI 2.8+ ### 开发命令 ```bash # 安装依赖 pnpm install # 开发模式(热重载) pnpm dev # 类型检查 pnpm typecheck # 代码格式化 pnpm format # 检查代码格式 pnpm format:check # 运行前端单元测试 pnpm test:unit # 监听模式运行测试(推荐开发时使用) pnpm test:unit:watch # 构建应用 pnpm build # 构建调试版本 pnpm tauri build --debug ``` ### Rust 后端开发 ```bash cd src-tauri # 格式化 Rust 代码 cargo fmt # 运行 clippy 检查 cargo clippy # 运行后端测试 cargo test # 运行特定测试 cargo test test_name # 运行带测试 hooks 的测试 cargo test --features test-hooks ``` ### 测试说明 **前端测试**: - 使用 **vitest** 作为测试框架 - 使用 **MSW (Mock Service Worker)** 模拟 Tauri API 调用 - 使用 **@testing-library/react** 进行组件测试 **运行测试**: ```bash # 运行所有测试 pnpm test:unit # 监听模式(自动重跑) pnpm test:unit:watch # 带覆盖率报告 pnpm test:unit --coverage ``` ### 技术栈 **前端**:React 18 · TypeScript · Vite · TailwindCSS 3.4 · TanStack Query v5 · react-i18next · react-hook-form · zod · shadcn/ui · @dnd-kit **后端**:Tauri 2.8 · Rust · serde · tokio · thiserror · tauri-plugin-updater/process/dialog/store/log **测试**:vitest · MSW · @testing-library/react
项目结构 ``` ├── src/ # 前端 (React + TypeScript) │ ├── components/ │ │ ├── providers/ # 供应商管理 │ │ ├── mcp/ # MCP 面板 │ │ ├── prompts/ # Prompts 管理 │ │ ├── skills/ # Skills 管理 │ │ ├── sessions/ # 会话管理器 │ │ ├── proxy/ # Proxy 模式面板 │ │ ├── openclaw/ # OpenClaw 配置面板 │ │ ├── settings/ # 设置(终端/备份/关于) │ │ ├── deeplink/ # Deep Link 导入 │ │ ├── env/ # 环境变量管理 │ │ ├── universal/ # 跨应用配置 │ │ ├── usage/ # 用量统计 │ │ └── ui/ # shadcn/ui 组件库 │ ├── hooks/ # 自定义 hooks(业务逻辑) │ ├── lib/ │ │ ├── api/ # Tauri API 封装(类型安全) │ │ └── query/ # TanStack Query 配置 │ ├── locales/ # 翻译 (zh/en/ja) │ ├── config/ # 预设 (providers/mcp) │ └── types/ # TypeScript 类型定义 ├── src-tauri/ # 后端 (Rust) │ └── src/ │ ├── commands/ # Tauri 命令层(按领域) │ ├── services/ # 业务逻辑层 │ ├── database/ # SQLite DAO 层 │ ├── proxy/ # Proxy 模块 │ ├── session_manager/ # 会话管理 │ ├── deeplink/ # Deep Link 处理 │ └── mcp/ # MCP 同步模块 ├── tests/ # 前端测试 └── assets/ # 截图 & 合作商资源 ```
## 贡献 欢迎提交 Issue 反馈问题和建议! 提交 PR 前请确保: - 通过类型检查:`pnpm typecheck` - 通过格式检查:`pnpm format:check` - 通过单元测试:`pnpm test:unit` 新功能开发前,欢迎先开 Issue 讨论实现方案,不适合项目的功能性 PR 有可能会被关闭。 ## Star History [![Star History Chart](https://api.star-history.com/svg?repos=farion1231/cc-switch&type=Date)](https://www.star-history.com/#farion1231/cc-switch&Date) ## License MIT © Jason Young ================================================ FILE: cc-switch-main/src/config/universalProviderPresets.ts ================================================ /** * 统一供应商(Universal Provider)预设配置 * * 统一供应商是跨应用共享的配置,修改后会自动同步到 Claude、Codex、Gemini 三个应用。 * 适用于 NewAPI 等支持多种协议的 API 网关。 */ import type { UniversalProvider, UniversalProviderApps, UniversalProviderModels, } from "@/types"; /** * 统一供应商预设接口 */ export interface UniversalProviderPreset { /** 预设名称 */ name: string; /** 供应商类型标识 */ providerType: string; /** 默认启用的应用 */ defaultApps: UniversalProviderApps; /** 默认模型配置 */ defaultModels: UniversalProviderModels; /** 网站链接 */ websiteUrl?: string; /** 图标名称 */ icon?: string; /** 图标颜色 */ iconColor?: string; /** 描述 */ description?: string; /** 是否为自定义模板(允许用户完全自定义) */ isCustomTemplate?: boolean; } /** * NewAPI 默认模型配置 */ const NEWAPI_DEFAULT_MODELS: UniversalProviderModels = { claude: { model: "claude-sonnet-4-20250514", haikuModel: "claude-haiku-4-20250514", sonnetModel: "claude-sonnet-4-20250514", opusModel: "claude-sonnet-4-20250514", }, codex: { model: "gpt-4o", reasoningEffort: "high", }, gemini: { model: "gemini-2.5-pro", }, }; const N1N_DEFAULT_MODELS: UniversalProviderModels = { claude: { model: "claude-3-5-sonnet-20240620", haikuModel: "claude-3-haiku-20240307", sonnetModel: "claude-3-5-sonnet-20240620", opusModel: "claude-3-opus-20240229", }, codex: { model: "gpt-4o", reasoningEffort: "high", }, gemini: { model: "gemini-1.5-pro-latest", }, }; /** * 统一供应商预设列表 */ export const universalProviderPresets: UniversalProviderPreset[] = [ { name: "n1n.ai", providerType: "n1n", defaultApps: { claude: true, codex: true, gemini: true, }, defaultModels: N1N_DEFAULT_MODELS, websiteUrl: "https://n1n.ai", icon: "openai", iconColor: "#000000", description: "n1n.ai - 聚合 OpenAI, Anthropic, Google 等主流大模型的一站式 AI 服务平台", }, { name: "NewAPI", providerType: "newapi", defaultApps: { claude: true, codex: true, gemini: true, }, defaultModels: NEWAPI_DEFAULT_MODELS, websiteUrl: "https://www.newapi.pro", icon: "newapi", iconColor: "#00A67E", description: "NewAPI 是一个可自部署的 API 网关,支持 Anthropic、OpenAI、Gemini 等多种协议", }, { name: "自定义网关", providerType: "custom_gateway", defaultApps: { claude: true, codex: true, gemini: true, }, defaultModels: NEWAPI_DEFAULT_MODELS, icon: "openai", iconColor: "#6366F1", description: "自定义配置的 API 网关", isCustomTemplate: true, }, ]; /** * 根据预设创建统一供应商 */ export function createUniversalProviderFromPreset( preset: UniversalProviderPreset, id: string, baseUrl: string, apiKey: string, customName?: string, ): UniversalProvider { return { id, name: customName || preset.name, providerType: preset.providerType, apps: { ...preset.defaultApps }, baseUrl, apiKey, models: JSON.parse(JSON.stringify(preset.defaultModels)), // Deep copy websiteUrl: preset.websiteUrl, icon: preset.icon, iconColor: preset.iconColor, createdAt: Date.now(), }; } /** * 获取预设的显示名称(用于 UI) */ export function getPresetDisplayName(preset: UniversalProviderPreset): string { return preset.name; } /** * 根据类型查找预设 */ export function findPresetByType( providerType: string, ): UniversalProviderPreset | undefined { return universalProviderPresets.find((p) => p.providerType === providerType); } ================================================ FILE: components.json ================================================ { "$schema": "https://ui.shadcn.com/schema.json", "style": "default", "rsc": false, "tsx": true, "tailwind": { "config": "tailwind.config.cjs", "css": "src/index.css", "baseColor": "neutral", "cssVariables": true, "prefix": "" }, "iconLibrary": "lucide", "aliases": { "components": "@/components", "utils": "@/lib/utils", "ui": "@/components/ui", "lib": "@/lib", "hooks": "@/hooks" } } ================================================ FILE: deplink.html ================================================ CC Switch 深链接测试

🔗 CC Switch 深链接测试

点击下方链接测试深链接导入功能

📦 配置文件导入示例 v3.8+

🔌 MCP Servers 导入 v3.8+

💬 Prompt 导入 v3.8+

🛠️ Skill 仓库导入 v3.8+

🚀 深链接生成器

填写参数信息,自动生成深链接并导入到 CC Switch

🔌 MCP Servers 导入生成器

多个应用用逗号分隔
完整的 MCP 配置 JSON

💬 Prompt 导入生成器

支持 Markdown 格式,自动 Base64 编码

🛠️ Skill 仓库导入生成器

格式: 所有者/仓库名
仓库中技能文件所在的子目录
克隆到本地的目录名(可选)

🔐 Base64 编解码器

编码器 (UTF-8 → Base64)

解码器 (Base64 → UTF-8)

💡 使用建议

  • 编码配置文件:将 JSON 或 TOML 内容编码后用于 config 参数
  • 编码 Prompt:将 Markdown 提示词内容编码后用于 content 参数
  • 验证深链接:解码验证深链接中的配置内容是否正确
  • UTF-8 支持:完整支持中文及其他 Unicode 字符

⚠️ 使用注意事项

  • 首次点击:浏览器会询问是否允许打开 CC Switch,请点击"允许"或"打开"
  • macOS 用户:可能需要在"系统设置" → "隐私与安全性"中允许应用
  • 测试 API Key:示例中的 API Key 仅用于测试格式,无法实际使用
  • 导入确认:点击链接后会弹出确认对话框,API Key 会被掩码显示(前4位+****)
  • 编辑配置:导入后可以在 CC Switch 中随时编辑或删除配置

🔍 深链接解析器

粘贴深链接 URL,查看解析结果

🛠️ 深链接生成器

填写下方表单,生成您自己的深链接

URL 参数模式:直接在 URL 中传递参数 | 配置文件模式:使用 Base64 编码的 JSON/TOML
⚠️ 唯一必填项
主 API 端点地址
多个备用端点用逗号分隔,导入后自动添加为自定义端点
通用模型字段,适用于所有应用类型

📋 Claude 专用模型字段(可选)

可以根据需要设置特定的模型字段,这些字段仅在 Claude 应用中生效

对应环境变量:ANTHROPIC_DEFAULT_HAIKU_MODEL
对应环境变量:ANTHROPIC_DEFAULT_SONNET_MODEL
对应环境变量:ANTHROPIC_DEFAULT_OPUS_MODEL
图标名称,用于在界面中显示

📊 用量查询配置(v3.9+,可选)

配置用量查询脚本,可自动查询 API 余额

用量查询接口的基础地址,必须与脚本中的请求 URL 同源
支持模板变量:{{baseUrl}}、{{apiKey}}、{{accessToken}}、{{userId}}
0 表示禁用自动查询
================================================ FILE: docs/proxy-guide-zh.md ================================================ # CC Switch 代理功能使用指南 ## 功能介绍 CC Switch 的代理功能是一个本地 HTTP 代理服务器,可以统一管理 Claude Code、Codex 和 Gemini CLI 的 API 请求。主要特性包括: - **统一代理入口** - 所有 CLI 应用的请求通过本地代理转发 - **自动故障转移** - 当前供应商故障时自动切换到备用供应商 - **按应用控制** - 可独立控制每个应用是否启用代理 - **配置保护** - 自动备份原始配置,停止代理时安全恢复 ## 快速开始 ### 1. 启动代理 在 CC Switch 主界面,点击右上角的 **Proxy** 按钮,可以看到代理控制面板。 点击 **启动代理** 按钮启动本地代理服务器。代理默认监听 `127.0.0.1:15721`。 ### 2. 启用应用接管 代理启动后,你可以选择让哪些应用的请求通过代理: - **Claude** - 接管 Claude Code 的 API 请求 - **Codex** - 接管 Codex CLI 的 API 请求 - **Gemini** - 接管 Gemini CLI 的 API 请求 点击对应应用的开关即可启用/禁用接管。 > **注意**:启用接管后,CC Switch 会自动修改对应应用的配置文件,将 API 端点指向本地代理。原始配置会被安全备份。 ### 3. 正常使用 CLI 启用接管后,你可以正常使用各个 CLI 工具。所有请求都会经过 CC Switch 代理转发到配置的供应商。 ### 4. 停止代理 当你不再需要代理时,点击 **停止代理** 按钮。CC Switch 会: 1. 安全关闭代理服务器 2. 自动恢复所有应用的原始配置 3. 清除代理状态 ## 自动故障转移 ### 工作原理 代理功能内置了智能故障转移机制: 1. **健康监控** - 实时监控每个供应商的响应状态 2. **熔断器** - 连续失败 5 次后触发熔断,暂停使用该供应商 3. **自动切换** - 熔断后自动切换到列表中的下一个供应商 4. **自动恢复** - 30 秒后尝试恢复熔断的供应商 ### 配置故障转移 要使用故障转移功能,你需要: 1. 在对应应用下添加多个供应商(至少 2 个) 2. 启动代理并启用接管 3. 当主供应商故障时,代理会自动切换到备用供应商 ### 健康状态指示 在供应商卡片上可以看到健康状态指示: - **绿色** - 供应商正常 - **红色** - 供应商故障/熔断中 - **灰色** - 未使用代理或未检测 ## 按应用接管 v3.9.0 新增了按应用分粒度控制功能: - 你可以只接管 Claude,而让 Codex 使用原始配置 - 每个应用的接管状态独立管理 - 启用/禁用不会影响其他应用 ### 接管状态检测 CC Switch 通过检测配置备份来判断接管状态: - 存在备份 = 已接管 - 无备份 = 未接管 这确保了即使 CC Switch 异常退出,重新启动后也能正确识别状态。 ## 代理配置 在代理面板中,你可以配置以下参数: | 参数 | 默认值 | 说明 | |------|--------|------| | 监听地址 | 127.0.0.1 | 代理服务器绑定地址 | | 监听端口 | 15721 | 代理服务器端口 | | 最大重试 | 3 | 请求失败时的最大重试次数 | | 请求超时 | 120 秒 | 单个请求的超时时间 | | 启用日志 | 是 | 是否记录请求日志 | ## 常见问题 ### Q: 代理启动失败,提示端口被占用? A: 默认端口 15721 可能被其他程序占用。你可以: - 关闭占用该端口的程序 - 在代理配置中修改端口号 ### Q: 启用接管后 CLI 无法使用? A: 请检查: 1. 代理服务器是否正常运行(查看代理面板状态) 2. 供应商配置是否正确(API Key 等) 3. 网络连接是否正常 ### Q: 如何恢复原始配置? A: 点击 **停止代理** 按钮,CC Switch 会自动恢复所有应用的原始配置。 如果 CC Switch 异常退出,重新启动后会检测到之前的备份,你可以: - 点击停止代理来恢复配置 - 或继续使用代理功能 ### Q: 故障转移没有生效? A: 请确保: 1. 配置了至少 2 个供应商 2. 代理已启动且接管已启用 3. 故障转移只在代理模式下工作 ### Q: 代理会影响性能吗? A: 本地代理的延迟开销非常小(通常 < 1ms)。但如果启用了请求日志,在高频请求场景下可能会有少量性能影响。 ## 技术细节 ### 配置文件位置 启用接管后,CC Switch 会修改以下配置文件: | 应用 | 配置文件 | 修改内容 | |------|----------|----------| | Claude | `~/.claude/settings.json` | `apiBaseUrl` 指向代理 | | Codex | `~/.codex/config.toml` | `[api] baseUrl` 指向代理 | | Gemini | `~/.gemini/.env` | `GEMINI_BASE_URL` 指向代理 | 原始配置备份在 CC Switch 数据库中,停止代理时自动恢复。 ### 代理模式 代理服务器运行在接管模式下,会: 1. 接收来自 CLI 的 HTTPS 请求 2. 根据当前供应商配置转发到真实 API 端点 3. 返回响应给 CLI 4. 记录请求日志和健康状态 ### 数据库表 代理功能使用以下数据库表: - `proxy_config` - 代理配置 - `provider_health` - 供应商健康状态 - `proxy_request_logs` - 请求日志 - `circuit_breaker_config` - 熔断器配置 - `proxy_live_backup` - Live 配置备份 ================================================ FILE: docs/release-notes/v3.10.0-en.md ================================================ # CC Switch v3.10.0 > OpenCode Support, Global Proxy, Claude Rectifier & Multi-App Experience Enhancements **[中文版 →](v3.10.0-zh.md) | [日本語版 →](v3.10.0-ja.md)** --- ## Overview CC Switch v3.10.0 introduces OpenCode support, becoming the fourth managed CLI application. This release also brings global proxy settings, Claude Rectifier (thinking signature fixer), enhanced health checks, per-provider configuration, and many other important features, along with comprehensive improvements to multi-app workflows and terminal experience. **Release Date**: 2026-01-21 --- ## Highlights - OpenCode Support: Full management of providers, MCP servers, and Skills with auto-import on first launch - Global Proxy: Configure a unified proxy for all outbound network requests - Claude Rectifier: Thinking signature fixer for better compatibility with third-party APIs - Enhanced Health Checks: Configurable prompts and CLI-compatible request format - Per-Provider Config: Persistent provider-specific configuration support - App Visibility Control: Freely show/hide apps with synchronized tray menu updates - Terminal Improvements: Provider-specific terminal buttons, fnm path support, cross-platform safe launch - WSL Tool Detection: Detect tool versions in WSL environment with security hardening --- ## Main Features ### OpenCode Support (New Fourth App) - Complete OpenCode provider management: add, edit, switch, delete - MCP server management: unified architecture with Claude/Codex/Gemini - Skills support: OpenCode can also use Skills functionality - Auto-import on first launch: automatically imports existing OpenCode configuration when detected - Full internationalization: Chinese/English/Japanese support (#695) ### Global Proxy - Configure a unified proxy for all outbound network requests (#596, thanks @yovinchen) - Supports HTTP/HTTPS proxy protocols - Suitable for network environments requiring proxy access to external APIs ### Claude Rectifier (Thinking Signature Fixer) - Automatically fixes Claude API thinking signatures (#595, thanks @yovinchen) - Resolves incompatible thinking block formats returned by some third-party API gateways - Can be enabled/disabled in Advanced Settings ### Enhanced Health Checks - Configurable custom prompts for streaming health checks (#623, thanks @yovinchen) - Supports CLI-compatible request format for better simulation of real usage scenarios - Improves fault detection accuracy ### Per-Provider Config - Support for saving configuration separately for each provider (#663, thanks @yovinchen) - Persistent configuration: provider-specific settings retained after restart - Suitable for scenarios where different providers require different configurations ### App Visibility Control - Freely show/hide any app (Gemini hidden by default) - Tray menu automatically syncs visibility settings - Hidden apps won't appear in the main interface or tray menu ### Takeover Compact Mode - Automatically uses compact layout when 3 or more visible apps are displayed - Optimizes space utilization in multi-app scenarios ### Terminal Improvements - Provider-specific terminal button: one-click to use current provider in terminal (#564, thanks @kkkman22) - `fnm` path support: automatically recognizes Node.js paths managed by fnm - Cross-platform safe launch: improved terminal launch logic for Windows/macOS/Linux ### WSL Tool Detection - Detect tool versions in WSL environment (#627, thanks @yovinchen) - Added security hardening to prevent command injection risks ### Skills Preset Enhancements - Added `baoyu-skills` preset repository - Automatically supplements missing default repositories for out-of-the-box experience --- ## Experience Improvements - Keyboard shortcuts: Press `ESC` to quickly return/close panels (#670, thanks @xxk8) - Simplified proxy logs: cleaner and more readable output (#585, thanks @yovinchen) - Pricing editor UX: unified `FullScreenPanel` style - Advanced settings layout: Rectifier section moved below Failover for better logical flow - OpenRouter compatibility mode: disabled by default, UI toggle hidden (reduces clutter) --- ## Bug Fixes ### Proxy & Failover - Immediately switch to P1 when auto-failover is enabled (instead of waiting for next request) ### Provider Management - Fixed stale data when reopening provider edit dialog after save (#654, thanks @YangYongAn) - Fixed baseUrl and apiKey state not resetting when switching presets - Fixed endpoint auto-selection state not persisting (#611, thanks @yovinchen) - Automatically apply default color when icon color is not set ### Deep Links - Support multi-endpoint import (#597, thanks @yovinchen) - Prefer `GOOGLE_GEMINI_BASE_URL` over `GEMINI_BASE_URL` ### MCP - Skip `cmd /c` wrapper for WSL target paths (#592, thanks @cxyfer) ### Usage Templates - Added variable hints, fixed validation issues (#628, thanks @YangYongAn) - Prevent configuration leakage between providers - Usage block offset automatically adapts to action button width (#613, thanks @yovinchen) ### Gemini - Convert timeout parameters to Gemini CLI format (#580, thanks @cxyfer) ### UI - Fixed Select dropdown rendering issues in `FullScreenPanel` --- ## Notes & Considerations - **OpenCode is a newly supported app**: OpenCode CLI must be installed first to use related features. - **Global proxy affects all outbound requests**: including usage queries, health checks, and other network operations. - **Rectifier is experimental**: can be disabled in Advanced Settings if issues occur. --- ## Special Thanks Thanks to @yovinchen @YangYongAn @cxyfer @xxk8 @kkkman22 @Shuimo03 for their contributions to this release! Thanks to @libukai for designing the elegant failover-related UI! --- ## Download & Installation Visit [Releases](https://github.com/farion1231/cc-switch/releases/latest) to download the appropriate version. ### System Requirements | System | Minimum Version | Architecture | | ------- | ------------------------------ | ----------------------------------- | | Windows | Windows 10 or later | x64 | | macOS | macOS 10.15 (Catalina) or later | Intel (x64) / Apple Silicon (arm64) | | Linux | See table below | x64 | ### Windows | File | Description | | ---------------------------------------- | ---------------------------------------------------- | | `CC-Switch-v3.10.0-Windows.msi` | **Recommended** - MSI installer with auto-update | | `CC-Switch-v3.10.0-Windows-Portable.zip` | Portable version, extract and run, no registry write | ### macOS | File | Description | | -------------------------------- | ------------------------------------------------------------------ | | `CC-Switch-v3.10.0-macOS.zip` | **Recommended** - Extract and drag to Applications, Universal Binary | | `CC-Switch-v3.10.0-macOS.tar.gz` | For Homebrew installation and auto-update | > **Note**: Since the author doesn't have an Apple Developer account, you may see an "unidentified developer" warning on first launch. Please close it, then go to "System Settings" → "Privacy & Security" → click "Open Anyway", and it will open normally afterwards. ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` Update: ```bash brew upgrade --cask cc-switch ``` ### Linux | Distribution | Recommended Format | Installation Method | | --------------------------------------- | ------------------ | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` or `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` or `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | Add execute permission and run directly, or use AUR | | Other distributions / Unsure | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.10.0-ja.md ================================================ # CC Switch v3.10.0 > OpenCode サポート、グローバルプロキシ、Claude Rectifier とマルチアプリ体験の強化 **[中文版 →](v3.10.0-zh.md) | [English →](v3.10.0-en.md)** --- ## 概要 CC Switch v3.10.0 では OpenCode サポートが追加され、4番目の管理対象 CLI アプリケーションとなりました。 また、グローバルプロキシ設定、Claude Rectifier(thinking 署名修正機能)、ヘルスチェックの強化、プロバイダー別設定など、多くの重要な機能が追加され、マルチアプリワークフローとターミナル体験が全面的に改善されました。 **リリース日**: 2026-01-21 --- ## ハイライト - OpenCode サポート:プロバイダー、MCP サーバー、Skills の完全管理、初回起動時の自動インポート - グローバルプロキシ:すべての送信ネットワークリクエストに統一プロキシを設定 - Claude Rectifier:thinking 署名修正機能、サードパーティ API との互換性向上 - ヘルスチェック強化:カスタムプロンプト設定、CLI 互換リクエスト形式 - プロバイダー別設定:プロバイダー固有の設定の永続化をサポート - アプリ表示制御:アプリの表示/非表示を自由に設定、トレイメニューと同期 - ターミナル改善:プロバイダー専用ターミナルボタン、fnm パスサポート、クロスプラットフォーム安全起動 - WSL ツール検出:WSL 環境でのツールバージョン検出とセキュリティ強化 --- ## 主な機能 ### OpenCode サポート(新しい4番目のアプリ) - 完全な OpenCode プロバイダー管理:追加、編集、切り替え、削除 - MCP サーバー管理:Claude/Codex/Gemini と統一されたアーキテクチャ - Skills サポート:OpenCode でも Skills 機能を使用可能 - 初回起動時の自動インポート:既存の OpenCode 設定を検出すると自動的にインポート - 完全な国際化:中国語/英語/日本語サポート (#695) ### グローバルプロキシ - すべての送信ネットワークリクエストに統一プロキシを設定 (#596、@yovinchen に感謝) - HTTP/HTTPS プロキシプロトコルをサポート - 外部 API へのプロキシアクセスが必要なネットワーク環境に適用 ### Claude Rectifier(Thinking 署名修正機能) - Claude API の thinking 署名を自動修正 (#595、@yovinchen に感謝) - 一部のサードパーティ API ゲートウェイが返す互換性のない thinking ブロック形式を解決 - 詳細設定で有効/無効を切り替え可能 ### ヘルスチェック強化 - ストリーミングヘルスチェック用のカスタムプロンプトを設定可能 (#623、@yovinchen に感謝) - CLI 互換リクエスト形式をサポートし、実際の使用シナリオをより良くシミュレート - 障害検出の精度を向上 ### プロバイダー別設定 - 各プロバイダーごとに設定を個別に保存可能 (#663、@yovinchen に感謝) - 設定の永続化:再起動後もプロバイダー固有の設定を保持 - 異なるプロバイダーに異なる設定が必要なシナリオに適用 ### アプリ表示制御 - 任意のアプリを自由に表示/非表示(Gemini はデフォルトで非表示) - トレイメニューは表示設定と自動的に同期 - 非表示のアプリはメインインターフェースとトレイメニューに表示されない ### Takeover コンパクトモード - 3つ以上の表示アプリがある場合、自動的にコンパクトレイアウトを使用 - マルチアプリシナリオでのスペース利用を最適化 ### ターミナル改善 - プロバイダー専用ターミナルボタン:ワンクリックでターミナルで現在のプロバイダーを使用 (#564、@kkkman22 に感謝) - `fnm` パスサポート:fnm で管理された Node.js パスを自動認識 - クロスプラットフォーム安全起動:Windows/macOS/Linux のターミナル起動ロジックを改善 ### WSL ツール検出 - WSL 環境でツールバージョンを検出 (#627、@yovinchen に感謝) - コマンドインジェクションリスクを防ぐためのセキュリティ強化を追加 ### Skills プリセット強化 - `baoyu-skills` プリセットリポジトリを追加 - 不足しているデフォルトリポジトリを自動補完し、すぐに使える状態を確保 --- ## 体験の改善 - キーボードショートカット:`ESC` を押してパネルをすばやく戻る/閉じる (#670、@xxk8 に感謝) - プロキシログの簡素化:より明確で読みやすい出力 (#585、@yovinchen に感謝) - 価格エディター UX:統一された `FullScreenPanel` スタイル - 詳細設定レイアウト:Rectifier セクションを Failover の下に移動し、論理的な流れを改善 - OpenRouter 互換モード:デフォルトで無効、UI トグルを非表示(煩雑さを軽減) --- ## バグ修正 ### プロキシとフェイルオーバー - 自動フェイルオーバーが有効な場合、すぐに P1 に切り替え(次のリクエストを待たずに) ### プロバイダー管理 - 保存後にプロバイダー編集ダイアログを再度開いたときにデータが古い問題を修正 (#654、@YangYongAn に感謝) - プリセット切り替え時に baseUrl と apiKey の状態がリセットされない問題を修正 - エンドポイント自動選択状態が永続化されない問題を修正 (#611、@yovinchen に感謝) - アイコンカラーが設定されていない場合、デフォルトカラーを自動適用 ### ディープリンク - マルチエンドポイントインポートをサポート (#597、@yovinchen に感謝) - `GEMINI_BASE_URL` より `GOOGLE_GEMINI_BASE_URL` を優先 ### MCP - WSL ターゲットパスの `cmd /c` ラッパーをスキップ (#592、@cxyfer に感謝) ### 使用量テンプレート - 変数ヒントを追加、検証の問題を修正 (#628、@YangYongAn に感謝) - プロバイダー間での設定漏洩を防止 - 使用量ブロックのオフセットがアクションボタンの幅に自動適応 (#613、@yovinchen に感謝) ### Gemini - タイムアウトパラメータを Gemini CLI 形式に変換 (#580、@cxyfer に感謝) ### UI - `FullScreenPanel` での Select ドロップダウンのレンダリング問題を修正 --- ## 注意事項 - **OpenCode は新しくサポートされたアプリです**:関連機能を使用するには、まず OpenCode CLI をインストールする必要があります。 - **グローバルプロキシはすべての送信リクエストに影響します**:使用量クエリ、ヘルスチェックなどのネットワーク操作を含みます。 - **Rectifier は実験的機能です**:問題が発生した場合は、詳細設定で無効にできます。 --- ## 特別な感謝 @yovinchen @YangYongAn @cxyfer @xxk8 @kkkman22 @Shuimo03 の皆様、このリリースへの貢献に感謝します! @libukai 様、エレガントなフェイルオーバー関連 UI のデザインに感謝します! --- ## ダウンロードとインストール [Releases](https://github.com/farion1231/cc-switch/releases/latest) から適切なバージョンをダウンロードしてください。 ### システム要件 | システム | 最小バージョン | アーキテクチャ | | -------- | -------------------------------- | ----------------------------------- | | Windows | Windows 10 以降 | x64 | | macOS | macOS 10.15 (Catalina) 以降 | Intel (x64) / Apple Silicon (arm64) | | Linux | 下表参照 | x64 | ### Windows | ファイル | 説明 | | ---------------------------------------- | ---------------------------------------------------- | | `CC-Switch-v3.10.0-Windows.msi` | **推奨** - MSI インストーラー、自動更新対応 | | `CC-Switch-v3.10.0-Windows-Portable.zip` | ポータブル版、解凍して実行、レジストリ書き込みなし | ### macOS | ファイル | 説明 | | -------------------------------- | ----------------------------------------------------------------- | | `CC-Switch-v3.10.0-macOS.zip` | **推奨** - 解凍して Applications にドラッグ、Universal Binary | | `CC-Switch-v3.10.0-macOS.tar.gz` | Homebrew インストールと自動更新用 | > **注意**:作者が Apple Developer アカウントを持っていないため、初回起動時に「開発元を確認できません」という警告が表示される場合があります。一度閉じてから、「システム設定」→「プライバシーとセキュリティ」→「このまま開く」をクリックすると、その後は正常に開けます。 ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | ディストリビューション | 推奨形式 | インストール方法 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` または `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` または `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 実行権限を追加して直接実行、または AUR を使用 | | その他のディストリビューション / 不明 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.10.0-zh.md ================================================ # CC Switch v3.10.0 > OpenCode 支持、全局代理、Claude Rectifier 与多应用体验增强 **[English →](v3.10.0-en.md) | [日本語版 →](v3.10.0-ja.md)** --- ## 概览 CC Switch v3.10.0 新增 OpenCode 支持,成为第四个受管理的 CLI 应用。 同时带来全局代理设置、Claude Rectifier(thinking 签名修正器)、健康检查增强、按供应商配置等多项重要功能,并对多应用工作流与终端体验做了全面改进。 **发布日期**:2026-01-21 --- ## 重点内容 - OpenCode 支持:供应商、MCP 服务器、Skills 全面管理,首次启动自动导入 - 全局代理:为出站网络请求统一配置代理 - Claude Rectifier:thinking 签名修正器,兼容更多第三方 API - 健康检查增强:可配置提示词、CLI 兼容请求 - 按供应商配置:支持供应商特定配置的持久化 - 应用可见性控制:自由显示/隐藏应用,托盘菜单同步更新 - 终端改进:供应商专属终端按钮、fnm 路径支持、跨平台安全启动 - WSL 工具检测:在 WSL 环境检测工具版本,并增加安全加固 --- ## 主要功能 ### OpenCode 支持(新增第四应用) - 完整的 OpenCode 供应商管理:新增、编辑、切换、删除 - MCP 服务器管理:与 Claude/Codex/Gemini 统一架构 - Skills 支持:OpenCode 也可使用 Skills 功能 - 首次启动自动导入:检测到已有 OpenCode 配置时自动导入 - 完整国际化:中/英/日三语支持(#695) ### 全局代理(Global Proxy) - 为所有出站网络请求配置统一代理(#596,感谢 @yovinchen) - 支持 HTTP/HTTPS 代理协议 - 适用于需要代理访问外部 API 的网络环境 ### Claude Rectifier(Thinking 签名修正器) - 自动修正 Claude API 的 thinking 签名(#595,感谢 @yovinchen) - 解决部分第三方 API 网关返回的 thinking 块格式不兼容问题 - 在高级设置中可开启/关闭 ### 健康检查增强 - 可配置自定义提示词(prompt)用于流式健康检查(#623,感谢 @yovinchen) - 支持 CLI 兼容请求格式,更好地模拟真实使用场景 - 提升故障检测的准确性 ### 按供应商配置(Per-Provider Config) - 支持为每个供应商单独保存配置(#663,感谢 @yovinchen) - 配置持久化:重启后保留供应商专属设置 - 适用于不同供应商需要不同配置的场景 ### 应用可见性控制 - 自由显示/隐藏任意应用(Gemini 默认隐藏) - 托盘菜单自动同步可见性设置 - 隐藏的应用不会出现在主界面和托盘菜单中 ### Takeover Compact Mode - 当显示 3 个及以上可见应用时,自动使用紧凑布局 - 优化多应用场景下的空间利用 ### 终端改进 - 供应商专属终端按钮:一键在终端中使用当前供应商(#564,感谢 @kkkman22) - `fnm` 路径支持:自动识别 fnm 管理的 Node.js 路径 - 跨平台安全启动:改进 Windows/macOS/Linux 的终端启动逻辑 ### WSL 工具检测 - 在 WSL 环境中检测工具版本(#627,感谢 @yovinchen) - 增加安全加固,防止命令注入风险 ### Skills 预设增强 - 新增 `baoyu-skills` 预设仓库 - 自动补充缺失的默认仓库,确保开箱即用 --- ## 体验优化 - 键盘快捷键:按 `ESC` 快速返回/关闭面板(#670,感谢 @xxk8) - 代理日志简化:输出更清晰易读(#585,感谢 @yovinchen) - 定价编辑器 UX:统一使用 `FullScreenPanel` 风格 - 高级设置布局:Rectifier 区块移至 Failover 下方,逻辑更顺畅 - OpenRouter 兼容模式:默认禁用,UI 开关隐藏(减少干扰) --- ## Bug 修复 ### 代理与故障切换 - 启用自动故障切换时立即切换到 P1(而非等待下次请求) ### 供应商管理 - 修复供应商编辑对话框保存后重新打开时数据过时的问题(#654,感谢 @YangYongAn) - 修复切换预设时 baseUrl 和 apiKey 状态未重置的问题 - 修复端点自动选择状态未持久化的问题(#611,感谢 @yovinchen) - 未设置图标颜色时自动应用默认颜色 ### 深链接 - 支持多端点导入(#597,感谢 @yovinchen) - 优先使用 `GOOGLE_GEMINI_BASE_URL` 而非 `GEMINI_BASE_URL` ### MCP - WSL 目标路径跳过 `cmd /c` 包裹(#592,感谢 @cxyfer) ### 用量模板 - 新增变量提示,修复验证问题(#628,感谢 @YangYongAn) - 防止配置在供应商之间泄漏 - 用量区块偏移量根据操作按钮宽度自动适应(#613,感谢 @yovinchen) ### Gemini - 超时参数转换为 Gemini CLI 格式(#580,感谢 @cxyfer) ### UI - 修复 `FullScreenPanel` 中 Select 下拉框渲染问题 --- ## 说明与注意事项 - **OpenCode 为新支持的应用**:需要先安装 OpenCode CLI 才能使用相关功能。 - **全局代理会影响所有出站请求**:包括用量查询、健康检查等网络操作。 - **Rectifier 功能为实验性**:如遇问题可在高级设置中关闭。 --- ## 特别感谢 感谢 @yovinchen @YangYongAn @cxyfer @xxk8 @kkkman22 @Shuimo03 为本版本做出的贡献! 感谢 @libukai 设计的故障转移相关 UI,非常优雅! --- ## 下载与安装 访问 [Releases](https://github.com/farion1231/cc-switch/releases/latest) 下载对应版本。 ### 系统要求 | 系统 | 最低版本 | 架构 | | ------- | ----------------------------- | ----------------------------------- | | Windows | Windows 10 及以上 | x64 | | macOS | macOS 10.15 (Catalina) 及以上 | Intel (x64) / Apple Silicon (arm64) | | Linux | 见下表 | x64 | ### Windows | 文件 | 说明 | | ---------------------------------------- | ----------------------------------- | | `CC-Switch-v3.10.0-Windows.msi` | **推荐** - MSI 安装包,支持自动更新 | | `CC-Switch-v3.10.0-Windows-Portable.zip` | 便携版,解压即用,不写入注册表 | ### macOS | 文件 | 说明 | | -------------------------------- | --------------------------------------------------------- | | `CC-Switch-v3.10.0-macOS.zip` | **推荐** - 解压后拖入 Applications 即可,Universal Binary | | `CC-Switch-v3.10.0-macOS.tar.gz` | 用于 Homebrew 安装和自动更新 | > **注意**:由于作者没有苹果开发者账号,首次打开可能出现"未知开发者"警告,请先关闭,然后前往"系统设置" → "隐私与安全性" → 点击"仍要打开",之后便可以正常打开 ### Homebrew(macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | 发行版 | 推荐格式 | 安装方式 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` 或 `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` 或 `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 添加执行权限后直接运行,或使用 AUR | | 其他发行版 / 不确定 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.11.0-en.md ================================================ # CC Switch v3.11.0 > OpenClaw Support, Session Manager, Backup Management & 50+ Improvements **[中文版 →](v3.11.0-zh.md) | [日本語版 →](v3.11.0-ja.md)** --- ## Overview CC Switch v3.11.0 is a major update that adds full management support for **OpenClaw** as the fifth application, introduces a new **Session Manager** and **Backup Management** feature. Additionally, **Oh My OpenCode (OMO) integration**, the **partial key-field merging** architecture upgrade for provider switching, **settings page refactoring**, and many other improvements make the overall experience more polished. **Release Date**: 2026-02-26 **Update Scale**: 147 commits | 274 files changed | +32,179 / -5,467 lines --- ## Highlights - **OpenClaw Support**: Fifth managed application with 13 provider presets, Env/Tools/AgentsDefaults config editors, and Workspace file management - **Session Manager**: Browse conversation history across all five apps with table-of-contents navigation and in-session search - **Backup Management**: Independent backup panel with configurable policies, periodic backups, and pre-migration auto-backup - **Oh My OpenCode Integration**: Full OMO config management with OMO Slim lightweight mode support - **Partial Key-Field Merging (⚠️ Breaking Change)**: Provider switching now only replaces provider-related fields, preserving all other settings; the "Common Config Snippet" feature has been removed - **Settings Page Refactoring**: 5-tab layout with ~40% code reduction - **6 New Provider Presets**: AWS Bedrock, SSAI Code, CrazyRouter, AICoding, and more - **Thinking Budget Rectifier**: Fine-grained thinking budget control - **Theme Switch Animation**: Circular reveal transition animation - **WebDAV Auto Sync**: Automatic sync with large file protection --- ## Main Features ### OpenClaw Support (New Fifth App) Full management support for OpenClaw, the fifth managed application following Claude Code, Codex, Gemini CLI, and OpenCode. - **Provider Management**: Add, edit, switch, and delete OpenClaw providers with 13 built-in presets - **Config Editors**: Three dedicated panels for Env (environment variables), Tools, and AgentsDefaults - **Workspace Panel**: HEARTBEAT/BOOTSTRAP/BOOT file management and daily memory - **Additive Overlay Mode**: Support config overlay instead of overwrite - **Default Model Button**: One-click to fill recommended models; auto-register suggested models to allowlist when adding providers - **Brand & Interaction**: Dedicated brand icon, fade-in/fade-out transition animation when switching apps - **Deep Link Support**: Import OpenClaw provider configurations via URL - **Full Internationalization**: Complete Chinese/English/Japanese support ### Session Manager A brand-new session manager to browse and search conversation history. - Browse conversation history across Claude Code, Codex, Gemini CLI, OpenCode, and OpenClaw (#867, thanks @TinsFox) - Table-of-contents navigation and in-session search - Auto-filter by current app when entering the session page - Parallel directory scanning + head-tail JSONL reading for optimized loading performance ### Backup Management An independent backup management panel for better data safety. - Configurable backup policy: maximum backup count and auto-cleanup rules - Hourly automatic backup timer during runtime - Auto-backup before database schema migrations with backfill warning - Support backup rename and deletion (with confirmation dialog) - Backup filenames use local time for better clarity ### Oh My OpenCode (OMO) Integration Full Oh My OpenCode config file management. - Agent model selection, category configuration, and recommended model fill (#972, thanks @yovinchen) - Improved agent model selection UX with lowercase key fix (#1004, thanks @yovinchen) - OMO Slim lightweight mode support - OMO ↔ OMO Slim mutual exclusion (enforced at database level) ### Workspace - Full-text search across daily memory files, sorted by date - Clickable directory paths for quick file location access ### Toolbar - AppSwitcher auto-collapses to compact mode based on available width - Smooth transition animation for compact mode toggle ### Settings - First-use confirmation dialogs for proxy and usage features to prevent accidental operations - New `enableLocalProxy` switch to control proxy UI visibility on home page - More granular local environment checks: CLI tool version detection (#870, thanks @kv-chiu), Volta path detection (#969, thanks @myjustify) ### Provider Presets - **AWS Bedrock**: Support for AKSK and API Key authentication modes (#1047, thanks @keithyt06) - **SSAI Code**: Partner preset across all five apps - **CrazyRouter**: Partner preset with dedicated icon - **AICoding**: Partner preset with i18n promotion text - Updated domestic model provider presets to latest versions - Renamed Qwen Coder to Bailian (#965, thanks @zhu-jl18) ### Other New Features - **Thinking Budget Rectifier**: Fine-grained thinking budget allocation control (#1005, thanks @yovinchen) - **WebDAV Auto Sync**: Automatic sync with large file protection (#923, thanks @clx20000410; #1043, thanks @SaladDay) - **Theme Switch Animation**: Circular reveal transition for a smoother visual experience (#905, thanks @funnytime75) - **Claude Config Editor Quick Toggles**: Quick toggle switches for common settings (#1012, thanks @JIA-ss) - **Dynamic Endpoint Hint**: Context-aware hint text based on API format selection (#860, thanks @zhu-jl18) - **Usage Dashboard Enhancement**: Auto-refresh control and robust formatting (#942, thanks @yovinchen) - **New Pricing Data**: claude-opus-4-6 and gpt-5.3-codex (#943, thanks @yovinchen) - **Silent Startup Optimization**: Silent startup option only shown when launch-on-startup is enabled --- ## Architecture Improvements ### Partial Key-Field Merging (⚠️ Breaking Change) Provider switching now uses partial key-field merging instead of full config overwrite (#1098). **Before**: Switching providers overwrote the entire `settings_config` to the live config file. This meant that any non-provider settings the user manually added to the live file (plugins, MCP config, permissions, etc.) would be lost on every switch. To work around this, previous versions offered a "Common Config Snippet" feature that let users define shared config to be merged on every switch. **After**: Switching providers now only replaces provider-related key-values (API keys, endpoints, models, etc.), leaving all other settings intact. The "Common Config Snippet" feature is therefore no longer needed and has been removed. **Impact & Migration**: - If you **didn't use** Common Config Snippets, this change is fully transparent — switching just works better now - If you **used** Common Config Snippets to preserve custom settings (MCP config, permissions, etc.), those settings are now automatically preserved during switches — no action needed - If you used Common Config Snippets for other purposes (e.g., injecting extra config on every switch), please manually add those settings to your live config file after upgrading This refactoring removed 6 frontend files (3 components + 3 hooks) and ~150 lines of backend dead code. ### Manual Import Replaces Auto-Import Startup no longer auto-imports external configurations. Users now click "Import Current Config" manually, preventing accidental data overwrites. ### OmoVariant Parameterization Eliminated ~250 lines of duplicated code in the OMO module via `OmoVariant` struct parameterization. ### OMO Common Config Removal Removed the two-layer merge system, reducing ~1,733 lines of code and simplifying the architecture. ### ProviderForm Decomposition Reduced ProviderForm component from 2,227 lines to 1,526 lines by extracting 5 independent modules (opencodeFormUtils, useOmoModelSource, useOpencodeFormState, useOmoDraftState, useOpenclawFormState), significantly improving maintainability. ### Shared MCP/Skills Components Extracted AppCountBar, AppToggleGroup, and ListItemRow shared components to reduce duplication across MCP and Skills panels (#897, thanks @PeanutSplash). ### Settings Page Refactoring Refactored settings page to a 5-tab layout (General | Proxy | Advanced | Usage | About), reducing SettingsPage code from ~716 to ~426 lines. ### Other Improvements - Unified terminal selection via global settings with WezTerm support added - Updated Claude model references from 4.5 to 4.6 --- ## Bug Fixes ### Critical Fixes - **Windows Home Dir Regression**: Restored default home directory resolution to prevent providers/settings "disappearing" when `HOME` env var differs from the real user profile directory in Git/MSYS environments - **Linux White Screen**: Disabled WebKitGTK hardware acceleration on AMD GPUs (Cezanne/Radeon Vega) to prevent blank screen on startup (#986, thanks @ThendCN) - **OpenAI Beta Parameter**: Stopped appending `?beta=true` to `/v1/chat/completions` endpoints, fixing request failures for Nvidia and other `apiFormat="openai_chat"` providers (#1052, thanks @jnorthrup) - **Health Check Auth**: Health check now respects provider's `auth_mode` setting, preventing failures for proxy services that only support Bearer authentication (#824, thanks @Jassy930) ### Provider Preset Fixes - Fixed OpenClaw `/v1` prefix causing double path (/v1/v1/messages) - Corrected Opus pricing ($15/$75 → $5/$25) and upgraded to 4.6 - Unified AIGoCode URL to `https://api.aigocode.com` across all apps - Removed outdated partner status from Zhipu GLM presets - Restored API Key input visibility when creating new Claude providers - Hide quick toggles for non-active providers, show context-aware JSON editor hints ### OMO Fixes - Added missing omo-slim category checks across add/form/mutation paths - Fixed OMO Slim query cache invalidation after provider mutations - Synced OMO agent/category recommended models with upstream sources - Added toast feedback for "Fill Recommended" button silent failures - Removed last-provider deletion restriction for OMO/OMO Slim - Reject saving OpenCode providers without configured models (#932, thanks @yovinchen) ### OpenClaw Fixes - Fixed 25 missing i18n keys, replaced key={index} with stable IDs, added deep link additive merge, and other code review issues - Enhanced EnvPanel robustness (NaN guards, entry key names instead of array indices) - Merged duplicate i18n keys to restore provider form translations ### Platform Fixes - Windows silent startup window flicker (#901, thanks @funnytime75) - Title bar dark mode theme following (#903, thanks @funnytime75) - Windows Skills path separator matching (#868, thanks @stmoonar) - WSL helper functions conditional compilation ### UI Fixes - Toolbar height clipping causing AppSwitcher to be obscured - Show update badge instead of green checkmark when newer version available - Session Manager button only visible for Claude/Codex apps - Unified SQL import/export card dark mode styling (#1067, thanks @SaladDay) ### Other Fixes - Replaced hardcoded Chinese strings in Session Manager with i18n keys - Fixed Skill documentation URL branch and path resolution (#977, thanks @yovinchen) - Added missing OpenCode install.sh installation path detection (#988, thanks @zhu-jl18) - Fixed Skill ZIP symlink resolution (#1040, thanks @yovinchen) - Added missing OpenCode checkbox in MCP add/edit form (#1026, thanks @yovinchen) - Removed auto-import side effect from useProvidersQuery queryFn --- ## Performance - Parallel directory scanning + head-tail JSONL reading for session panel, significantly improving session list loading speed - Removed unnecessary TanStack Query cache overhead for Tauri local IPC calls --- ## Documentation - Sponsor updates: SSSAiCode, Crazyrouter, AICoding, Right Code, MiniMax - Added user manual documentation (#979, thanks @yovinchen) --- ## Notes & Considerations - **OpenClaw is a newly supported app**: OpenClaw CLI must be installed first to use related features. - **⚠️ Common Config Snippet feature has been removed**: Since provider switching now uses partial key-field merging (only replacing API keys, endpoints, models, etc.), user's other settings are automatically preserved, making Common Config Snippets unnecessary. See the "Architecture Improvements" section above for migration details. - **Auto-import changed to manual**: External configurations are no longer auto-imported on startup. Click "Import Current Config" manually when needed. - **OMO and OMO Slim are mutually exclusive**: Only one can be active at a time. Switching to one automatically disables the other. - **Backup is enabled by default**: Automatic hourly backup during runtime. Adjust the policy in the Backup panel. --- ## Special Thanks Thanks to all contributors for their contributions to this release! @TinsFox @keithyt06 @kv-chiu @SaladDay @jnorthrup @JIA-ss @clx20000410 @ThendCN @yovinchen @zhu-jl18 @myjustify @funnytime75 @PeanutSplash @Jassy930 @stmoonar --- ## Download & Installation Visit [Releases](https://github.com/farion1231/cc-switch/releases/latest) to download the appropriate version. ### System Requirements | System | Minimum Version | Architecture | | ------- | ------------------------------- | ----------------------------------- | | Windows | Windows 10 or later | x64 | | macOS | macOS 10.15 (Catalina) or later | Intel (x64) / Apple Silicon (arm64) | | Linux | See table below | x64 | ### Windows | File | Description | | ---------------------------------------- | ---------------------------------------------------- | | `CC-Switch-v3.11.0-Windows.msi` | **Recommended** - MSI installer with auto-update | | `CC-Switch-v3.11.0-Windows-Portable.zip` | Portable version, extract and run, no registry write | ### macOS | File | Description | | -------------------------------- | -------------------------------------------------------------------- | | `CC-Switch-v3.11.0-macOS.zip` | **Recommended** - Extract and drag to Applications, Universal Binary | | `CC-Switch-v3.11.0-macOS.tar.gz` | For Homebrew installation and auto-update | > **Note**: Since the author doesn't have an Apple Developer account, you may see an "unidentified developer" warning on first launch. Please close it, then go to "System Settings" → "Privacy & Security" → click "Open Anyway", and it will open normally afterwards. ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` Update: ```bash brew upgrade --cask cc-switch ``` ### Linux | Distribution | Recommended Format | Installation Method | | --------------------------------------- | ------------------ | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` or `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` or `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | Add execute permission and run directly, or use AUR | | Other distributions / Unsure | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.11.0-ja.md ================================================ # CC Switch v3.11.0 > OpenClaw サポート、セッションマネージャー、バックアップ管理と 50 以上の改善 **[中文版 →](v3.11.0-zh.md) | [English →](v3.11.0-en.md)** --- ## 概要 CC Switch v3.11.0 は大規模なアップデートです。5番目のアプリケーション **OpenClaw** の完全管理サポートを追加し、新しい**セッションマネージャー**と**バックアップ管理**機能を導入しました。さらに、**Oh My OpenCode (OMO) 統合**、プロバイダー切り替えの**部分キーフィールドマージ**アーキテクチャアップグレード、**設定ページのリファクタリング**など、多数の改善により全体的な体験がさらに向上しました。 **リリース日**: 2026-02-26 **更新規模**: 147 commits | 274 files changed | +32,179 / -5,467 lines --- ## ハイライト - **OpenClaw サポート**: 5番目の管理対象アプリ、13 のプロバイダープリセット、Env/Tools/AgentsDefaults 設定エディター、Workspace ファイル管理 - **セッションマネージャー**: 5つのアプリの会話履歴を閲覧、目次ナビゲーションとセッション内検索 - **バックアップ管理**: 独立バックアップパネル、設定可能なポリシー、定期バックアップ、マイグレーション前自動バックアップ - **Oh My OpenCode 統合**: 完全な OMO 設定管理、OMO Slim 軽量モードサポート - **部分キーフィールドマージ(⚠️ 破壊的変更)**: プロバイダー切り替え時にプロバイダー関連フィールドのみ置換し、その他の設定を保持;「共通設定スニペット」機能は削除されました - **設定ページリファクタリング**: 5タブレイアウト、コード量約 40% 削減 - **6つの新プロバイダープリセット**: AWS Bedrock、SSAI Code、CrazyRouter、AICoding など - **Thinking Budget Rectifier**: より精密な thinking budget 制御 - **テーマ切り替えアニメーション**: 円形リビール遷移アニメーション - **WebDAV 自動同期**: 自動同期と大容量ファイル保護 --- ## 主な機能 ### OpenClaw サポート(新しい5番目のアプリ) Claude Code、Codex、Gemini CLI、OpenCode に続く5番目の管理対象アプリケーションとして OpenClaw の完全管理サポートを追加しました。 - **プロバイダー管理**: OpenClaw プロバイダーの追加、編集、切り替え、削除、13 の内蔵プリセット - **設定エディター**: Env(環境変数)、Tools(ツール)、AgentsDefaults(エージェントデフォルト)の3つの専用パネル - **Workspace パネル**: HEARTBEAT/BOOTSTRAP/BOOT ファイル管理とデイリーメモリ - **Additive オーバーレイモード**: 上書きではなく設定の重ね合わせをサポート - **デフォルトモデルボタン**: ワンクリックで推奨モデルを入力、プロバイダー追加時に候補モデルを allowlist に自動登録 - **ブランドとインタラクション**: 専用ブランドアイコン、アプリ切り替えフェード遷移アニメーション - **ディープリンクサポート**: URL 経由で OpenClaw プロバイダー設定をインポート - **完全な国際化**: 中/英/日 三言語完全対応 ### セッションマネージャー 会話履歴を閲覧・検索できる新しいセッションマネージャーです。 - Claude Code、Codex、Gemini CLI、OpenCode、OpenClaw の5つのアプリの会話履歴を閲覧(#867、@TinsFox に感謝) - 目次ナビゲーションとセッション内検索 - セッションページに入ると現在のアプリで自動フィルター - 並列ディレクトリスキャン + ヘッドテール JSONL 読み取りで読み込みパフォーマンスを最適化 ### バックアップ管理 データの安全性を高める独立バックアップ管理パネルです。 - 設定可能なバックアップポリシー: 最大バックアップ数、自動クリーンアップルール - ランタイム中の1時間ごとの定期自動バックアップ - データベースマイグレーション前の自動バックアップ、バックフィル警告プロンプト - バックアップのリネームと削除をサポート(確認ダイアログ付き) - バックアップファイル名にローカルタイムを使用、より直感的に ### Oh My OpenCode (OMO) 統合 完全な Oh My OpenCode 設定ファイル管理です。 - エージェントモデル選択、カテゴリ設定、推奨モデル入力(#972、@yovinchen に感謝) - エージェントモデル選択 UX の改善、lowercase key 問題の修正(#1004、@yovinchen に感謝) - OMO Slim 軽量モードサポート - OMO と OMO Slim の相互排他(データベースレベルで一貫性を保証) ### ワークスペース - デイリーメモリファイルの全文検索、日付順ソート - ディレクトリパスがクリック可能に、ファイル位置をすばやく開く ### ツールバー - AppSwitcher がウィンドウ幅に応じて自動的にコンパクトモードに折りたたみ - コンパクトモード切り替えのスムーズ遷移アニメーション ### 設定 - プロキシと使用量機能に初回使用確認ダイアログを追加、誤操作を防止 - `enableLocalProxy` スイッチを追加、ホーム画面のプロキシ UI 表示を制御 - より詳細なローカル環境チェック: CLI ツールバージョン検出(#870、@kv-chiu に感謝)、Volta パス検出(#969、@myjustify に感謝) ### プロバイダープリセット - **AWS Bedrock**: AKSK と API Key の2種類の認証方式をサポート(#1047、@keithyt06 に感謝) - **SSAI Code**: パートナープリセット、5アプリ対応 - **CrazyRouter**: パートナープリセットと専用アイコン - **AICoding**: パートナープリセットとプロモーションテキスト - 国内モデルプロバイダープリセットを最新版に更新 - Qwen Coder を百炼 (Bailian) にリネーム(#965、@zhu-jl18 に感謝) ### その他の新機能 - **Thinking Budget Rectifier**: より精密な thinking budget 制御(#1005、@yovinchen に感謝) - **WebDAV 自動同期**: 自動同期設定と大容量ファイル保護(#923、@clx20000410 に感謝;#1043、@SaladDay に感謝) - **テーマ切り替えアニメーション**: 円形リビール遷移アニメーション(#905、@funnytime75 に感謝) - **Claude 設定エディタークイックトグル**: よく使う設定項目のクイック切り替え(#1012、@JIA-ss に感謝) - **動的エンドポイントヒント**: API フォーマット選択に基づく動的ヒントテキスト(#860、@zhu-jl18 に感謝) - **使用量ダッシュボード強化**: 自動更新、堅牢なフォーマット(#942、@yovinchen に感謝) - **新しい価格データ**: claude-opus-4-6 と gpt-5.3-codex(#943、@yovinchen に感謝) - **サイレント起動の最適化**: サイレント起動オプションは自動起動が有効な場合のみ表示 --- ## アーキテクチャ改善 ### 部分キーフィールドマージ(⚠️ 破壊的変更) プロバイダー切り替えを完全な設定上書きから部分キーフィールドマージ戦略に変更しました(#1098)。 **変更前**: プロバイダーを切り替えると、`settings_config` 全体がライブ設定ファイルに上書きされていました。つまり、ユーザーがライブファイルに手動で追加した非プロバイダー設定(プラグイン設定、MCP 設定、権限設定など)は、切り替えのたびに失われていました。この問題を補うため、以前のバージョンでは「共通設定スニペット」機能を提供し、毎回の切り替え時にマージされる共通設定を定義できました。 **変更後**: プロバイダー切り替え時に、プロバイダー関連のキー値(API キー、エンドポイント、モデルなど)のみが置換され、その他の設定はそのまま保持されます。そのため「共通設定スニペット」機能は不要となり、削除されました。 **影響と移行**: - 共通設定スニペットを**使用していなかった**場合、この変更は完全に透過的で、切り替え体験が向上するだけです - カスタム設定(MCP 設定、権限など)を保持するために共通設定スニペットを**使用していた**場合、それらの設定は切り替え時に自動的に保持されるようになり、追加の操作は不要です - 共通設定スニペットを他の目的(切り替え時に追加設定を注入するなど)で使用していた場合は、アップグレード後にライブ設定ファイルに手動で設定を追加してください このリファクタリングにより、フロントエンドファイル 6 つ(コンポーネント 3 つ + hooks 3 つ)と約 150 行のバックエンドデッドコードを削除しました。 ### 手動インポートに変更 起動時の自動インポートを廃止し、手動の「現在の設定をインポート」ボタンに変更。意図しないユーザーデータの上書きを防止します。 ### OmoVariant パラメータ化 `OmoVariant` 構造体によるパラメータ化で、OMO モジュールの約250行の重複コードを削除しました。 ### OMO 共通設定の削除 2層マージシステムを削除し、約1,733行のコードを削減、アーキテクチャを簡素化しました。 ### ProviderForm 分割 ProviderForm コンポーネントを2,227行から1,526行に削減し、5つの独立モジュール(opencodeFormUtils、useOmoModelSource、useOpencodeFormState、useOmoDraftState、useOpenclawFormState)に分離。保守性が大幅に向上しました。 ### MCP/Skills 共有コンポーネント AppCountBar、AppToggleGroup、ListItemRow などの共有コンポーネントを抽出し、MCP と Skills パネルの重複コードを削減(#897、@PeanutSplash に感謝)。 ### 設定ページリファクタリング 設定ページを5タブレイアウト(一般 | プロキシ | 詳細 | 使用量 | 情報)にリファクタリング。SettingsPage のコードを約716行から約426行に削減しました。 ### その他の改善 - ターミナル統一: グローバル設定でターミナル選択を統一、WezTerm サポートを追加 - Claude モデル参照を 4.5 から 4.6 に更新 --- ## バグ修正 ### 重大な修正 - **Windows ホームディレクトリ回帰**: デフォルトのホームディレクトリ解決を復元し、Git/MSYS 環境でのデータベースパス変更によるデータ「消失」を防止 - **Linux 白画面**: AMD GPU の WebKitGTK ハードウェアアクセラレーションを無効化し、一部の Linux システムの起動白画面問題を解決(#986、@ThendCN に感謝) - **OpenAI Beta パラメータ**: `/v1/chat/completions` に `?beta=true` を追加しないように修正、Nvidia など OpenAI Chat 形式を使用するプロバイダーのリクエスト失敗を修正(#1052、@jnorthrup に感謝) - **ヘルスチェック認証**: プロバイダーの `auth_mode` 設定を尊重し、Bearer 認証のみをサポートするプロキシサービスのヘルスチェック失敗を回避(#824、@Jassy930 に感謝) ### プロバイダープリセット修正 - OpenClaw `/v1` プレフィックスの二重パス問題を修正 - Opus 価格修正($15/$75 → $5/$25)と 4.6 へのアップグレード - AIGoCode URL を `https://api.aigocode.com` に統一 - Zhipu GLM の古いパートナーステータスを削除 - 新規 Claude プロバイダー作成時の API Key 入力フィールドの表示を復元 - 非アクティブプロバイダーのクイックトグルを非表示、コンテキスト対応の JSON エディターヒントを表示 ### OMO 修正 - omo-slim カテゴリチェックの補完(add/form/mutation パス) - OMO Slim プロバイダー変更後のクエリキャッシュ無効化を修正 - OMO agent/category 推奨モデルをアップストリームソースと同期 - 「推奨を入力」ボタン失敗時の toast フィードバックを追加 - OMO/OMO Slim の最後のプロバイダー削除制限を撤廃 - OpenCode でモデル未設定時の保存を拒否(#932、@yovinchen に感謝) ### OpenClaw 修正 - 25個の欠落 i18n キー、key={index} を安定 ID に置換、ディープリンク additive マージなどのコードレビュー問題を修正 - EnvPanel 堅牢性強化(NaN ガード、配列インデックスではなくエントリーキー名を使用) - i18n 重複キーのマージ、プロバイダーフォーム翻訳を復元 ### プラットフォーム修正 - Windows サイレント起動時のウィンドウフラッシュ(#901、@funnytime75 に感謝) - タイトルバーのダークモード追従(#903、@funnytime75 に感謝) - Windows の Skills パスセパレーターマッチング(#868、@stmoonar に感謝) - WSL ヘルパー関数の条件付きコンパイル ### UI 修正 - ツールバーの高さクリッピングによる AppSwitcher の遮蔽を修正 - 新バージョンがある場合、緑のチェックマークではなく更新バッジを表示 - セッションマネージャーボタンを Claude/Codex アプリでのみ表示 - SQL インポート/エクスポートカードのダークモードスタイルを統一(#1067、@SaladDay に感謝) ### その他の修正 - セッションマネージャーのハードコードされた中国語文字列を i18n キーに置換 - Skill ドキュメント URL のブランチとパスを修正(#977、@yovinchen に感謝) - OpenCode install.sh インストールパス検出の補完(#988、@zhu-jl18 に感謝) - Skill ZIP シンボリックリンク解決の修正(#1040、@yovinchen に感謝) - MCP フォームに OpenCode チェックボックスを追加(#1026、@yovinchen に感謝) - useProvidersQuery の自動インポート副作用を削除 --- ## パフォーマンス最適化 - セッションパネルの並列ディレクトリスキャン + ヘッドテール JSONL 読み取りで、セッションリスト読み込み速度を大幅向上 - Tauri ローカル IPC の不要な query cache を削除し、メモリ使用量を削減 --- ## ドキュメント - スポンサー更新: SSSAiCode、Crazyrouter、AICoding、Right Code、MiniMax - ユーザーマニュアルを追加(#979、@yovinchen に感謝) --- ## 注意事項 - **OpenClaw は新しくサポートされたアプリです**: 関連機能を使用するには、先に OpenClaw CLI をインストールする必要があります。 - **⚠️ 共通設定スニペット機能は削除されました**: プロバイダー切り替えが部分キーフィールドマージ(API キー、エンドポイント、モデルなどのみ置換)に変更されたため、ユーザーのその他の設定は自動的に保持され、共通設定スニペットは不要になりました。移行の詳細は上記「アーキテクチャ改善」セクションを参照してください。 - **自動インポートは手動に変更されました**: 起動時に外部設定を自動インポートしなくなりました。必要に応じて「現在の設定をインポート」を手動でクリックしてください。 - **OMO と OMO Slim は相互排他**: 同時に一つだけ有効にできます。切り替え時にもう一方は自動的に無効になります。 - **バックアップ機能はデフォルトで有効**: ランタイム中に1時間ごとに自動バックアップします。バックアップパネルでポリシーを調整できます。 --- ## 特別な感謝 以下のコントリビューターの皆様、このリリースへの貢献に感謝します! @TinsFox @keithyt06 @kv-chiu @SaladDay @jnorthrup @JIA-ss @clx20000410 @ThendCN @yovinchen @zhu-jl18 @myjustify @funnytime75 @PeanutSplash @Jassy930 @stmoonar --- ## ダウンロードとインストール [Releases](https://github.com/farion1231/cc-switch/releases/latest) から適切なバージョンをダウンロードしてください。 ### システム要件 | システム | 最小バージョン | アーキテクチャ | | -------- | -------------------------------- | ----------------------------------- | | Windows | Windows 10 以降 | x64 | | macOS | macOS 10.15 (Catalina) 以降 | Intel (x64) / Apple Silicon (arm64) | | Linux | 下表参照 | x64 | ### Windows | ファイル | 説明 | | ---------------------------------------- | ---------------------------------------------------- | | `CC-Switch-v3.11.0-Windows.msi` | **推奨** - MSI インストーラー、自動更新対応 | | `CC-Switch-v3.11.0-Windows-Portable.zip` | ポータブル版、解凍して実行、レジストリ書き込みなし | ### macOS | ファイル | 説明 | | -------------------------------- | ----------------------------------------------------------------- | | `CC-Switch-v3.11.0-macOS.zip` | **推奨** - 解凍して Applications にドラッグ、Universal Binary | | `CC-Switch-v3.11.0-macOS.tar.gz` | Homebrew インストールと自動更新用 | > **注意**: 作者が Apple Developer アカウントを持っていないため、初回起動時に「開発元を確認できません」という警告が表示される場合があります。一度閉じてから、「システム設定」→「プライバシーとセキュリティ」→「このまま開く」をクリックすると、その後は正常に開けます。 ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | ディストリビューション | 推奨形式 | インストール方法 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` または `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` または `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 実行権限を追加して直接実行、または AUR を使用 | | その他のディストリビューション / 不明 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.11.0-zh.md ================================================ # CC Switch v3.11.0 > OpenClaw 支持、会话管理器、备份管理与 50+ 项改进 **[English →](v3.11.0-en.md) | [日本語版 →](v3.11.0-ja.md)** --- ## 概览 CC Switch v3.11.0 是一次大规模更新,新增第五个应用 **OpenClaw** 的完整管理支持,同时带来全新的**会话管理器**和**备份管理**功能。此外,**Oh My OpenCode (OMO) 集成**、供应商切换的**部分键值合并**架构升级、**设置页面重构**等多项改进使整体体验更加完善。 **发布日期**:2026-02-26 **更新规模**:147 commits | 274 files changed | +32,179 / -5,467 lines --- ## 重点内容 - **OpenClaw 支持**:第五个受管理应用,含 13 个供应商预设、Env/Tools/AgentsDefaults 配置编辑器、Workspace 文件管理 - **会话管理器**:浏览五个应用的历史会话,支持目录导航和会话内搜索 - **备份管理**:独立备份面板,可配置策略、定时备份、迁移前自动备份 - **Oh My OpenCode 集成**:完整 OMO 配置管理,支持 OMO Slim 轻量模式 - **部分键值合并(⚠️ 破坏性变更)**:供应商切换改为仅替换供应商相关字段,保留用户的其余设置;"通用配置片段"功能因此移除 - **设置页面重构**:5 标签页布局,代码量减少约 40% - **6 组新供应商预设**:AWS Bedrock、SSAI Code、CrazyRouter、AICoding 等 - **Thinking Budget Rectifier**:代理矫正器,更精细的 thinking budget 控制 - **主题切换动画**:圆形揭示过渡动画,视觉体验升级 - **WebDAV 自动同步**:支持自动同步与大文件防护 --- ## 主要功能 ### OpenClaw 支持(新增第五应用) CC Switch 新增对 OpenClaw 的完整管理支持,这是继 Claude Code、Codex、Gemini CLI、OpenCode 之后的第五个受管理应用。 - **供应商管理**:新增、编辑、切换、删除 OpenClaw 供应商,含 13 个内置预设 - **配置编辑器**:Env(环境变量)、Tools(工具)、AgentsDefaults(代理默认值)三个专属配置面板 - **Workspace 面板**:支持 HEARTBEAT/BOOTSTRAP/BOOT 文件管理及每日记忆 - **Additive 叠加模式**:支持配置叠加而非覆盖 - **默认模型按钮**:一键填充推荐模型,添加供应商时自动将建议模型注册到 allowlist - **品牌与交互**:专属品牌图标、应用切换淡入淡出过渡动画 - **深链接支持**:通过 URL 导入 OpenClaw 供应商配置 - **完整国际化**:中/英/日三语全面支持 ### 会话管理器 Sessions 全新的会话管理器,帮助你浏览和检索历史会话记录。 - 支持浏览 Claude Code、Codex、Gemini CLI、OpenCode、OpenClaw 五个应用的历史会话(#867,感谢 @TinsFox) - 目录导航和会话内搜索 - 进入会话页面时默认过滤为当前应用,快速定位 - 并行目录扫描 + 头尾 JSONL 读取,优化加载性能 ### 备份管理 Backup 独立的备份管理面板,让数据安全更有保障。 - 可配置备份策略:最大备份数量、自动清理规则 - 运行时每小时定期自动备份 - 数据库迁移前自动备份,带回填警告提示 - 支持备份重命名和删除(含确认对话框) - 备份文件名使用本地时间,更直观 ### Oh My OpenCode (OMO) 集成 完整的 Oh My OpenCode 配置文件管理。 - Agent 模型选择、Category 配置、推荐模型填充(#972,感谢 @yovinchen) - 改进 Agent 模型选择 UX,修复 lowercase key 问题(#1004,感谢 @yovinchen) - OMO Slim 轻量模式支持 - OMO 与 OMO Slim 互斥切换(数据库层级强制保证一致性) ### 工作空间 Workspace - 每日记忆文件全文搜索,按日期排序 - 目录路径可点击跳转,快速打开文件位置 ### 工具栏 Toolbar - AppSwitcher 根据窗口宽度自动折叠为紧凑模式 - 紧凑模式切换平滑过渡动画 ### 设置 Settings - 代理和用量功能新增首次使用确认对话框,避免误操作 - 新增 `enableLocalProxy` 开关,控制主页代理 UI 显示 - 更精细的本地环境检查:CLI 工具版本检测(#870,感谢 @kv-chiu)、Volta 路径检测(#969,感谢 @myjustify) ### 供应商预设 Preset - **AWS Bedrock**:支持 AKSK 和 API Key 两种认证方式(#1047,感谢 @keithyt06) - **SSAI Code**:合作伙伴预设,覆盖五端 - **CrazyRouter**:合作伙伴预设及专属图标 - **AICoding**:合作伙伴预设及推广文案 - 更新国内模型供应商预设至最新版本 - Qwen Coder 重命名为百炼 (Bailian)(#965,感谢 @zhu-jl18) ### 其他新功能 - **Thinking Budget Rectifier**:代理矫正器,更精细地控制 thinking budget 分配(#1005,感谢 @yovinchen) - **WebDAV 自动同步**:支持自动同步配置,并增加大文件防护(#923,感谢 @clx20000410;#1043,感谢 @SaladDay) - **主题切换动画**:圆形揭示过渡动画,视觉体验更流畅(#905,感谢 @funnytime75) - **Claude 配置编辑器快速开关**:快速切换常用配置项(#1012,感谢 @JIA-ss) - **动态端点提示**:根据 API 格式选择动态显示端点提示文本(#860,感谢 @zhu-jl18) - **用量仪表盘增强**:自动刷新、更强健的数据格式化(#942,感谢 @yovinchen) - **新增定价数据**:claude-opus-4-6 和 gpt-5.3-codex(#943,感谢 @yovinchen) - **静默启动优化**:静默启动选项仅在开机启动开启时显示 --- ## 架构改进 ### 部分键值合并(⚠️ 破坏性变更) 供应商切换从全量配置覆写改为部分键值合并策略(#1098)。 **变更前**:切换供应商时,整个 `settings_config` 会覆写到 live 配置文件。这意味着用户在 live 文件中手动添加的非供应商设置(插件配置、MCP 配置、权限设置等)会在每次切换时丢失。为了弥补这个问题,之前版本提供了"通用配置片段"功能,让用户定义每次切换时都会合并的公共配置。 **变更后**:切换供应商时,仅替换供应商相关的键值(API Key、端点、模型等),用户的其余设置完整保留。因此"通用配置片段"功能不再需要,已被移除。 **影响与迁移**: - 如果你之前**没有使用**通用配置片段功能,此变更对你完全透明,切换体验只会更好 - 如果你之前**使用了**通用配置片段功能来保留自定义设置(如 MCP 配置、权限等),升级后这些设置会在切换时自动保留,无需额外操作 - 如果你利用通用配置片段做其他用途(如在切换时注入额外配置),请在升级后手动将这些配置写入 live 配置文件中 此次重构删除了 6 个前端文件(3 个组件 + 3 个 hooks)、约 150 行后端死代码。 ### 手动导入替代自动导入 启动时不再自动导入外部配置,改为手动点击"导入当前配置"按钮,避免意外覆盖用户数据。 ### OMO Variant 参数化 通过 `OmoVariant` 结构体参数化消除 OMO 模块约 250 行重复代码。 ### OMO 公共配置移除 删除二层合并系统,减少约 1,733 行代码,简化架构。 ### ProviderForm 拆分 ProviderForm 组件从 2,227 行减至 1,526 行,提取 5 个独立模块(opencodeFormUtils、useOmoModelSource、useOpencodeFormState、useOmoDraftState、useOpenclawFormState),可维护性显著提升。 ### MCP/Skills 共享组件 提取 AppCountBar、AppToggleGroup、ListItemRow 等共享组件,减少 MCP 和 Skills 面板的重复代码(#897,感谢 @PeanutSplash)。 ### 设置页面重构 设置页面重构为 5 标签页布局(通用 | 代理 | 高级 | 用量 | 关于),SettingsPage 代码从约 716 行减至约 426 行。 ### 其他改进 - 终端统一:全局设置统一终端选择,新增 WezTerm 支持 - Claude 模型引用从 4.5 更新到 4.6 --- ## Bug 修复 ### 严重修复 - **Windows 主目录回归**:恢复默认主目录解析,防止 Git/MSYS 环境下数据库路径变更导致数据"丢失" - **Linux 白屏**:禁用 AMD GPU 的 WebKitGTK 硬件加速,解决部分 Linux 系统启动白屏问题(#986,感谢 @ThendCN) - **OpenAI Beta 参数**:不再为 `/v1/chat/completions` 添加 `?beta=true`,修复 Nvidia 等使用 OpenAI Chat 格式的供应商请求失败(#1052,感谢 @jnorthrup) - **健康检查认证**:尊重供应商 `auth_mode` 设置,避免仅支持 Bearer 认证的代理服务健康检查失败(#824,感谢 @Jassy930) ### 供应商预设修复 - 修复 OpenClaw `/v1` 前缀双重路径问题 - Opus 定价修正($15/$75 → $5/$25)并升级到 4.6 - AIGoCode URL 统一为 `https://api.aigocode.com` - Zhipu GLM 移除过时合作伙伴状态 - 新建 Claude 供应商时 API Key 输入框可见性恢复 - 非活跃供应商隐藏快速开关,显示上下文感知的 JSON 编辑器提示 ### OMO 修复 - omo-slim 分类检查补齐(add/form/mutation 路径) - OMO Slim 供应商变更后正确失效查询缓存 - OMO agent/category 推荐模型与上游源同步 - "填充推荐"按钮失败时增加 toast 反馈 - 移除 OMO/OMO Slim 最后一个供应商的删除限制 - OpenCode 未配置模型时拒绝保存(#932,感谢 @yovinchen) ### OpenClaw 修复 - 修复 25 个缺失 i18n key、替换 key={index} 为稳定 ID、深链接 additive 合并等代码审查问题 - EnvPanel 健壮性增强(NaN 守卫、使用条目键名而非数组索引) - i18n 重复键合并,恢复供应商表单翻译 ### 平台修复 - Windows 静默启动时窗口闪烁(#901,感谢 @funnytime75) - 标题栏暗黑模式跟随主题(#903,感谢 @funnytime75) - Windows Skills 路径分隔符匹配(#868,感谢 @stmoonar) - WSL 辅助函数条件编译 ### UI 修复 - 工具栏高度裁切导致 AppSwitcher 被遮挡 - 有新版本时显示更新徽章而非绿色对勾 - 仅 Claude/Codex 应用显示会话管理器按钮 - SQL 导入/导出卡片暗黑模式样式统一(#1067,感谢 @SaladDay) ### 其他修复 - 会话管理器硬编码中文字符串替换为 i18n key - Skill 文档 URL 分支和路径修正(#977,感谢 @yovinchen) - OpenCode install.sh 安装路径检测补齐(#988,感谢 @zhu-jl18) - Skill ZIP 符号链接解析修复(#1040,感谢 @yovinchen) - MCP 表单补齐 OpenCode 复选框(#1026,感谢 @yovinchen) - useProvidersQuery 中自动导入副作用移除 --- ## 性能优化 - 会话面板并行目录扫描 + 头尾 JSONL 读取,大幅提升会话列表加载速度 - 移除 Tauri 本地 IPC 不必要的 query cache,减少内存占用 --- ## 文档 - 赞助商更新:SSSAiCode、Crazyrouter、AICoding、Right Code、MiniMax - 新增用户手册(#979,感谢 @yovinchen) --- ## 说明与注意事项 - **OpenClaw 为新支持的应用**:需要先安装 OpenClaw CLI 才能使用相关功能。 - **⚠️ 通用配置片段功能已移除**:由于供应商切换改为部分键值合并(仅替换 API Key、端点、模型等字段),用户的其余设置会自动保留,"通用配置片段"功能不再需要。详见上方"架构改进"章节的迁移说明。 - **自动导入已改为手动**:启动时不再自动导入外部配置,请在需要时手动点击"导入当前配置"。 - **OMO 与 OMO Slim 互斥**:同一时间只能启用其中一个,切换时另一个会自动禁用。 - **备份功能默认开启**:运行时每小时自动备份,可在备份面板调整策略。 --- ## 特别感谢 感谢以下贡献者为本版本做出的贡献! @TinsFox @keithyt06 @kv-chiu @SaladDay @jnorthrup @JIA-ss @clx20000410 @ThendCN @yovinchen @zhu-jl18 @myjustify @funnytime75 @PeanutSplash @Jassy930 @stmoonar --- ## 下载与安装 访问 [Releases](https://github.com/farion1231/cc-switch/releases/latest) 下载对应版本。 ### 系统要求 | 系统 | 最低版本 | 架构 | | ------- | ----------------------------- | ----------------------------------- | | Windows | Windows 10 及以上 | x64 | | macOS | macOS 10.15 (Catalina) 及以上 | Intel (x64) / Apple Silicon (arm64) | | Linux | 见下表 | x64 | ### Windows | 文件 | 说明 | | ---------------------------------------- | ----------------------------------- | | `CC-Switch-v3.11.0-Windows.msi` | **推荐** - MSI 安装包,支持自动更新 | | `CC-Switch-v3.11.0-Windows-Portable.zip` | 便携版,解压即用,不写入注册表 | ### macOS | 文件 | 说明 | | -------------------------------- | --------------------------------------------------------- | | `CC-Switch-v3.11.0-macOS.zip` | **推荐** - 解压后拖入 Applications 即可,Universal Binary | | `CC-Switch-v3.11.0-macOS.tar.gz` | 用于 Homebrew 安装和自动更新 | > **注意**:由于作者没有苹果开发者账号,首次打开可能出现"未知开发者"警告,请先关闭,然后前往"系统设置" → "隐私与安全性" → 点击"仍要打开",之后便可以正常打开 ### Homebrew(macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | 发行版 | 推荐格式 | 安装方式 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` 或 `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` 或 `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 添加执行权限后直接运行,或使用 AUR | | 其他发行版 / 不确定 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.11.1-en.md ================================================ # CC Switch v3.11.1 > Revert Partial Key-Field Merging, Restore Common Config Snippet & Bug Fixes **[中文版 →](v3.11.1-zh.md) | [日本語版 →](v3.11.1-ja.md)** --- ## Overview CC Switch v3.11.1 is a hotfix release that reverts the **Partial Key-Field Merging** architecture introduced in v3.11.0, restoring the proven "**full config overwrite + Common Config Snippet**" mechanism. It also includes several UI and platform compatibility fixes. **Release Date**: 2026-02-28 **Update Scale**: 8 commits | 52 files changed | +3,948 / -1,411 lines --- ## Highlights - **Restore Full Config Overwrite + Common Config Snippet**: Reverted partial key-field merging due to critical data loss issues; restores full config snapshot write and Common Config Snippet UI - **Proxy Panel Improvements**: Proxy toggle moved into panel body for better discoverability of takeover options - **Theme & Compact Mode Fixes**: "Follow System" theme now auto-updates; compact mode exit works correctly - **Windows Compatibility**: Disabled env check and one-click install to prevent protocol handler side effects --- ## Reverted ### Restore Full Config Overwrite + Common Config Snippet Reverted the partial key-field merging refactoring introduced in v3.11.0 (revert 992dda5c). **Why reverted**: The partial key-field merging approach had three critical issues: 1. **Data loss on switch**: Non-whitelisted custom fields were silently dropped during provider switching 2. **Permanent backfill stripping**: Backfill permanently removed non-key fields from the database, causing irreversible data loss 3. **Maintenance burden**: The whitelist of "key fields" required constant maintenance as new config keys were added **What's restored**: - Full config snapshot write on provider switch (predictable, complete overwrite) - Common Config Snippet UI and backend commands - 6 frontend components/hooks (3 components + 3 hooks) **Migration**: - If you upgraded to v3.11.0 and your providers lost custom fields, re-import your config or manually re-add the missing fields - Common Config Snippet is available again — use it to define shared config that should persist across provider switches --- ## Changed - **Proxy Panel Layout**: Moved proxy on/off toggle from accordion header into panel content area, placed directly above app takeover options. This ensures users see takeover configuration immediately after enabling the proxy, avoiding the common mistake of enabling the proxy without configuring takeover - **Manual Import for OpenCode/OpenClaw**: Removed auto-import on startup; empty state now shows an "Import Current Config" button, consistent with Claude/Codex/Gemini behavior --- ## Fixed - **"Follow System" Theme Not Auto-Updating**: Delegated to Tauri's native theme tracking (`set_window_theme(None)`) so the WebView's `prefers-color-scheme` media query stays in sync with OS theme changes - **Compact Mode Cannot Exit**: Restored `flex-1` on `toolbarRef` so `useAutoCompact`'s exit condition triggers correctly based on available width instead of content width - **Proxy Takeover Toast Shows {{app}}**: Added missing `app` interpolation parameter to i18next `t()` calls for proxy takeover enabled/disabled messages - **Windows Protocol Handler Side Effects**: Disabled environment check and one-click install on Windows to prevent unintended protocol handler registration --- ## Notes & Considerations - **Common Config Snippet is back**: If you relied on this feature in v3.10.x and earlier, it works the same way again. Define shared config that should persist across all provider switches. - **v3.11.0 Partial Key-Field Merging users**: If you noticed missing config fields after switching providers in v3.11.0, re-import your config to restore them. --- ## Download & Installation Visit [Releases](https://github.com/farion1231/cc-switch/releases/latest) to download the appropriate version. ### System Requirements | System | Minimum Version | Architecture | | ------- | ------------------------------- | ----------------------------------- | | Windows | Windows 10 or later | x64 | | macOS | macOS 10.15 (Catalina) or later | Intel (x64) / Apple Silicon (arm64) | | Linux | See table below | x64 | ### Windows | File | Description | | ---------------------------------------- | ---------------------------------------------------- | | `CC-Switch-v3.11.1-Windows.msi` | **Recommended** - MSI installer with auto-update | | `CC-Switch-v3.11.1-Windows-Portable.zip` | Portable version, extract and run, no registry write | ### macOS | File | Description | | -------------------------------- | -------------------------------------------------------------------- | | `CC-Switch-v3.11.1-macOS.zip` | **Recommended** - Extract and drag to Applications, Universal Binary | | `CC-Switch-v3.11.1-macOS.tar.gz` | For Homebrew installation and auto-update | > **Note**: Since the author doesn't have an Apple Developer account, you may see an "unidentified developer" warning on first launch. Please close it, then go to "System Settings" → "Privacy & Security" → click "Open Anyway", and it will open normally afterwards. ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` Update: ```bash brew upgrade --cask cc-switch ``` ### Linux | Distribution | Recommended Format | Installation Method | | --------------------------------------- | ------------------ | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` or `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` or `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | Add execute permission and run directly, or use AUR | | Other distributions / Unsure | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.11.1-ja.md ================================================ # CC Switch v3.11.1 > 部分キーフィールドマージの撤回、共通設定スニペットの復元とバグ修正 **[中文版 →](v3.11.1-zh.md) | [English →](v3.11.1-en.md)** --- ## 概要 CC Switch v3.11.1 は修正リリースです。v3.11.0 で導入された**部分キーフィールドマージ**アーキテクチャを撤回し、実績のある「**完全設定上書き + 共通設定スニペット**」メカニズムを復元しました。また、複数の UI とプラットフォーム互換性の問題を修正しています。 **リリース日**: 2026-02-28 **更新規模**: 8 commits | 52 files changed | +3,948 / -1,411 lines --- ## ハイライト - **完全設定上書き + 共通設定スニペットの復元**: 重大なデータ損失問題のため部分キーフィールドマージを撤回、完全設定スナップショット書き込みと共通設定スニペット UI を復元 - **プロキシパネルの改善**: プロキシトグルをパネル本体に移動し、テイクオーバーオプションの発見性を向上 - **テーマとコンパクトモードの修正**: 「システムに従う」テーマが正しく自動更新、コンパクトモードの終了が正常に動作 - **Windows 互換性**: プロトコルハンドラーの副作用を防ぐため、環境チェックとワンクリックインストールを無効化 --- ## 撤回 ### 完全設定上書き + 共通設定スニペットの復元 v3.11.0 で導入された部分キーフィールドマージリファクタリングを撤回しました(revert 992dda5c)。 **撤回理由**: 部分キーフィールドマージのアプローチには3つの重大な問題がありました: 1. **切り替え時のデータ損失**: ホワイトリストにないカスタムフィールドがプロバイダー切り替え時にサイレントに破棄された 2. **バックフィルによる永続的な剥離**: バックフィル操作がデータベースから非キーフィールドを永続的に削除し、不可逆なデータ損失を引き起こした 3. **メンテナンス負担**: 「キーフィールド」のホワイトリストは新しい設定キーが追加されるたびに継続的なメンテナンスが必要 **復元された内容**: - プロバイダー切り替え時の完全設定スナップショット書き込み(予測可能な完全上書き) - 共通設定スニペット UI およびバックエンドコマンド - 6つのフロントエンドファイル(コンポーネント 3つ + hooks 3つ) **移行ガイド**: - v3.11.0 にアップグレードしてプロバイダーのカスタムフィールドが失われた場合は、設定を再インポートするか、欠落したフィールドを手動で追加してください - 共通設定スニペット機能が再び利用可能です — プロバイダー切り替え時に保持すべき共有設定を定義するために使用してください --- ## 変更 - **プロキシパネルレイアウト**: プロキシのオン/オフトグルをアコーディオンヘッダーからパネルのコンテンツエリアに移動し、アプリテイクオーバーオプションの直上に配置。プロキシを有効にした後すぐにテイクオーバー設定が見えるようになり、「プロキシだけ有効にしてテイクオーバーを設定しない」というよくある誤操作を防止 - **OpenCode/OpenClaw の手動インポート**: 起動時の自動インポートを削除。空の状態ページに「現在の設定をインポート」ボタンを表示し、Claude/Codex/Gemini と同じ動作に統一 --- ## 修正 - **「システムに従う」テーマが自動更新されない**: Tauri のネイティブテーマ追跡(`set_window_theme(None)`)に委譲し、WebView の `prefers-color-scheme` メディアクエリが OS テーマの変更に同期するように修正 - **コンパクトモードを終了できない**: `toolbarRef` の `flex-1` を復元し、`useAutoCompact` の終了条件がコンテンツ幅ではなく利用可能な幅に基づいて正しくトリガーされるように修正 - **プロキシテイクオーバー Toast に {{app}} が表示される**: プロキシテイクオーバーの有効/無効メッセージの i18next `t()` 呼び出しに欠落していた `app` 補間パラメータを追加 - **Windows プロトコルハンドラーの副作用**: 意図しないプロトコルハンドラー登録を防ぐため、Windows で環境チェックとワンクリックインストールを無効化 --- ## 注意事項 - **共通設定スニペットが復活しました**: v3.10.x 以前でこの機能を使用していた場合、同じ方法で動作します。プロバイダー切り替え時に保持すべき共有設定を定義するために使用してください。 - **v3.11.0 部分キーフィールドマージユーザーの方へ**: v3.11.0 でプロバイダー切り替え後に設定フィールドが欠落していた場合は、設定を再インポートして復元してください。 --- ## ダウンロードとインストール [Releases](https://github.com/farion1231/cc-switch/releases/latest) から適切なバージョンをダウンロードしてください。 ### システム要件 | システム | 最小バージョン | アーキテクチャ | | -------- | -------------------------------- | ----------------------------------- | | Windows | Windows 10 以降 | x64 | | macOS | macOS 10.15 (Catalina) 以降 | Intel (x64) / Apple Silicon (arm64) | | Linux | 下表参照 | x64 | ### Windows | ファイル | 説明 | | ---------------------------------------- | ---------------------------------------------------- | | `CC-Switch-v3.11.1-Windows.msi` | **推奨** - MSI インストーラー、自動更新対応 | | `CC-Switch-v3.11.1-Windows-Portable.zip` | ポータブル版、解凍して実行、レジストリ書き込みなし | ### macOS | ファイル | 説明 | | -------------------------------- | ----------------------------------------------------------------- | | `CC-Switch-v3.11.1-macOS.zip` | **推奨** - 解凍して Applications にドラッグ、Universal Binary | | `CC-Switch-v3.11.1-macOS.tar.gz` | Homebrew インストールと自動更新用 | > **注意**: 作者が Apple Developer アカウントを持っていないため、初回起動時に「開発元を確認できません」という警告が表示される場合があります。一度閉じてから、「システム設定」→「プライバシーとセキュリティ」→「このまま開く」をクリックすると、その後は正常に開けます。 ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | ディストリビューション | 推奨形式 | インストール方法 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` または `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` または `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 実行権限を追加して直接実行、または AUR を使用 | | その他のディストリビューション / 不明 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.11.1-zh.md ================================================ # CC Switch v3.11.1 > 回退部分键值合并、恢复通用配置片段与多项修复 **[English →](v3.11.1-en.md) | [日本語版 →](v3.11.1-ja.md)** --- ## 概览 CC Switch v3.11.1 是一个修复版本,回退了 v3.11.0 中引入的**部分键值合并**架构,恢复经过验证的「**全量配置覆写 + 通用配置片段**」机制,同时修复了多个 UI 和平台兼容性问题。 **发布日期**:2026-02-28 **更新规模**:8 commits | 52 files changed | +3,948 / -1,411 lines --- ## 重点内容 - **恢复全量配置覆写 + 通用配置片段**:因关键数据丢失问题回退部分键值合并,恢复完整配置快照写入和通用配置片段 UI - **代理面板交互优化**:代理开关移入面板内部,接管选项一目了然 - **主题与紧凑模式修复**:「跟随系统」主题现可正确自动更新,紧凑模式退出恢复正常 - **Windows 兼容性**:禁用环境检查和一键安装,防止协议处理程序副作用 --- ## 回退 ### 恢复全量配置覆写 + 通用配置片段 回退了 v3.11.0 中引入的部分键值合并重构(revert 992dda5c)。 **回退原因**:部分键值合并方案存在三个关键缺陷: 1. **切换时数据丢失**:非白名单的自定义字段在供应商切换时被静默丢弃 2. **回填永久剥离**:回填操作永久移除数据库中的非键字段,造成不可逆的数据丢失 3. **维护成本高**:「键字段」白名单需要随新配置项不断维护,容易遗漏 **恢复的内容**: - 供应商切换时的完整配置快照写入(可预测的全量覆写) - 通用配置片段 UI 及后端命令 - 6 个前端文件(3 个组件 + 3 个 hooks) **迁移说明**: - 如果你在 v3.11.0 中切换供应商后丢失了自定义字段,请重新导入配置或手动补回缺失的字段 - 通用配置片段功能已恢复——用它来定义切换供应商时需要保留的共享配置 --- ## 变更 - **代理面板交互优化**:将代理开关从折叠面板标题移入面板内部,紧邻应用接管选项。确保用户启用代理后能立即看到接管配置,避免「只开代理不接管」的常见误操作 - **OpenCode/OpenClaw 手动导入**:移除启动时自动导入供应商配置的行为,改为在空状态页显示「导入当前配置」按钮,与 Claude/Codex/Gemini 保持一致 --- ## 修复 - **「跟随系统」主题不自动更新**:改用 Tauri 原生主题追踪(`set_window_theme(None)`),使 WebView 的 `prefers-color-scheme` 媒体查询能正确响应 OS 主题切换 - **紧凑模式无法退出**:恢复 `toolbarRef` 上的 `flex-1` class,修复 `useAutoCompact` 的退出条件因宽度计算错误而永远不触发的问题 - **代理接管 Toast 显示 {{app}}**:为 proxy takeover 的 i18next `t()` 调用补充缺失的 `app` 插值参数 - **Windows 协议处理副作用**:在 Windows 上禁用环境检查和一键安装功能,防止协议处理程序注册引发的意外副作用 --- ## 说明与注意事项 - **通用配置片段已恢复**:如果你在 v3.10.x 及更早版本中使用了此功能,它的工作方式与之前完全一致。用它来定义切换供应商时需要保留的共享配置。 - **v3.11.0 部分键值合并用户**:如果你在 v3.11.0 中切换供应商后发现配置字段丢失,请重新导入配置以恢复。 --- ## 下载与安装 访问 [Releases](https://github.com/farion1231/cc-switch/releases/latest) 下载对应版本。 ### 系统要求 | 系统 | 最低版本 | 架构 | | ------- | ----------------------------- | ----------------------------------- | | Windows | Windows 10 及以上 | x64 | | macOS | macOS 10.15 (Catalina) 及以上 | Intel (x64) / Apple Silicon (arm64) | | Linux | 见下表 | x64 | ### Windows | 文件 | 说明 | | ---------------------------------------- | ----------------------------------- | | `CC-Switch-v3.11.1-Windows.msi` | **推荐** - MSI 安装包,支持自动更新 | | `CC-Switch-v3.11.1-Windows-Portable.zip` | 便携版,解压即用,不写入注册表 | ### macOS | 文件 | 说明 | | -------------------------------- | --------------------------------------------------------- | | `CC-Switch-v3.11.1-macOS.zip` | **推荐** - 解压后拖入 Applications 即可,Universal Binary | | `CC-Switch-v3.11.1-macOS.tar.gz` | 用于 Homebrew 安装和自动更新 | > **注意**:由于作者没有苹果开发者账号,首次打开可能出现「未知开发者」警告,请先关闭,然后前往「系统设置」→「隐私与安全性」→ 点击「仍要打开」,之后便可以正常打开 ### Homebrew(macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | 发行版 | 推荐格式 | 安装方式 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` 或 `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` 或 `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 添加执行权限后直接运行,或使用 AUR | | 其他发行版 / 不确定 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.12.0-en.md ================================================ # CC Switch v3.12.0 > Stream Check Returns, OpenAI Responses API Arrives, and OpenClaw / WebDAV Get a Major Upgrade **[中文版 →](v3.12.0-zh.md) | [日本語版 →](v3.12.0-ja.md)** --- ## Overview CC Switch v3.12.0 is a feature release focused on provider compatibility, OpenClaw editing, Common Config usability, and sync/data reliability. It restores the **Model Health Check (Stream Check)** UI with improved stability, adds **OpenAI Responses API** format conversion, expands provider presets for **Ucloud**, **Micu**, **X-Code API**, **Novita**, and **Bailian For Coding**, and upgrades **WebDAV sync** with dual-layer versioning. **Release Date**: 2026-03-09 **Update Scale**: 56 commits | 221 files changed | +20,582 / -8,026 lines --- ## Highlights - **Stream Check returns**: Restored the model health check UI, added first-run confirmation, and fixed `openai_chat` provider support - **OpenAI Responses API**: Added `api_format = "openai_responses"` with bidirectional conversion and shared conversion cleanup — simply select the Responses API format when adding a provider and enable proxy takeover, and you can use GPT-series models in Claude Code! - **OpenClaw overhaul**: Introduced JSON5 round-trip config editing, a config health banner, better agent model selection, and a User-Agent toggle - **Preset expansion**: Added Ucloud, Micu, X-Code API, Novita, and Bailian For Coding updates, plus SiliconFlow partner badge and model-role badges - **Sync and maintenance improvements**: Added WebDAV protocol v2 + db-v6 versioning, daily rollups, incremental auto-vacuum, and sync-aware backup - **Common Config usability improvements**: After updating a Common Config Snippet, it is now automatically applied when switching providers — no more manual checkbox needed --- ## Main Features ### Model Health Check (Stream Check) Restored the Stream Check panel for live provider validation, improving the reliability of provider management. - Restored Stream Check UI panel with single and batch provider availability testing - Added first-run confirmation dialog to prevent unsupported providers from showing misleading errors - Fixed detection compatibility for `openai_chat` API format providers ### OpenAI Responses API Added native support for providers using the OpenAI Responses API with a new `openai_responses` API format. - New `api_format = "openai_responses"` provider format option - Bidirectional Anthropic Messages <-> OpenAI Responses API format conversion - Consolidated shared conversion logic to reduce code duplication ### Bedrock Request Optimizer Added a PRE-SEND phase request optimizer for AWS Bedrock providers to improve compatibility and performance. - PRE-SEND thinking + cache injection optimizer (#1301, thanks @keithyt06) ### OpenClaw Config Enhancements Comprehensive upgrade to the OpenClaw configuration editing experience with richer management capabilities. - JSON5 round-trip write-back: preserves comments and formatting when editing configs - EnvPanel JSON editing mode and `tools.profile` selection support - New config validation warnings and config health status checks - Improved agent model dropdown with recommended model fill from provider presets - User-Agent toggle: optionally append OpenClaw identifier to requests (defaults to off) - Legacy timeout configuration auto-migration ### Provider Presets New and expanded provider presets covering more providers and use cases. - **Ucloud**: Added `endpointCandidates` and OpenClaw defaults, refreshed `templateValues` / `suggestedDefaults` - **Micu**: Added preset defaults and OpenClaw recommended models - **X-Code API**: Added Claude presets and `endpointCandidates` - **Novita**: New provider preset (#1192, thanks @Alex-wuhu) - **Bailian For Coding**: New provider preset (#1263, thanks @suki135246) - **SiliconFlow**: Added partner badge - **Model Role Badges**: Provider presets now support model-role badge display ### WebDAV Sync Enhancements WebDAV sync introduces dual-layer versioning for improved sync reliability and data safety. - New WebDAV protocol v2 + db-v6 dual-layer versioning - Confirmation dialog when toggling WebDAV auto-sync on/off to prevent accidental changes - Sync-aware backup: uses a sync-specific backup variant that skips local-only table data ### Usage & Data Enhanced usage statistics and data maintenance capabilities for finer-grained data management, significantly reducing database growth rate. - Daily rollups: aggregate usage data by day to reduce storage overhead - Auto-vacuum: incremental database cleanup to maintain database health - UsageFooter extra statistics fields (#1137, thanks @bugparty) ### Other New Features - **Session Deletion**: Per-provider session cleanup with path safety validation - **Claude Auth Field Selector**: Restored authentication field selector - **Failover Toggle on Main Page**: Moved the failover toggle to display independently on the main page with a first-use confirmation dialog - **Common Config Auto-Extract**: On first run, automatically extracts common config snippets from live config files - **New Provider Page Improvements**: Improved new provider page experience (#1155, thanks @wugeer) --- ## Architecture Improvements ### Common Config Runtime Overlay Common Config Snippets are now applied as a runtime overlay instead of being materialized into stored provider configs. **Before**: Common Config content was merged directly into each provider's `settings_config` on save or switch. This caused shared configuration to be duplicated across every provider entry, requiring manual sync when changes were needed. **After**: Common Config is only injected as a runtime overlay when switching providers and writing to the live file — provider entries themselves no longer contain shared configuration. This means modifying Common Config takes effect immediately without updating each provider individually. ### Common Config Auto-Extract On first run, if no Common Config Snippet exists in the database, one is automatically extracted from the current live config. This ensures users upgrading from older versions do not lose their existing shared configuration settings. ### Periodic Maintenance Timer Consolidation Consolidated daily rollups and auto-vacuum into a unified periodic maintenance timer, eliminating resource contention and complexity from multiple independent timers. --- ## Bug Fixes ### Proxy & Streaming - Fixed OpenAI ChatCompletion -> Anthropic Messages streaming conversion - Added Codex `/responses/compact` route support (#1194, thanks @Tsukumi233) - Improved TOML config merge logic to prevent key-value loss - Improved proxy forwarder failure logs with additional diagnostic information ### Provider & Preset Fixes - Renamed X-Code to X-Code API for consistent branding - Fixed SSSAiCode `/v1` path issue - Removed incorrect `www` prefix from AICoding URLs - Fixed new provider page line-break deletion issue (#1155, thanks @wugeer) ### Platform Fixes - Fixed cache hit token statistics not being reported (#1244, thanks @a1398394385) - Fixed minimize-to-tray causing auto exit after some time (#1245, thanks @YewFence) ### i18n Fixes - Added 69 missing translation keys and removed remaining hardcoded Chinese strings - Fixed model test panel i18n issues - Normalized JSON5 slash escaping to prevent i18n string parsing errors ### UI Fixes - Fixed Skills count display (#1295, thanks @fzzv) - Removed HTTP status code display from endpoint speed test to reduce visual noise - Fixed outline button styling (#1222, thanks @Sube-py) --- ## Performance - Skip unnecessary OpenClaw config writes when config is unchanged, reducing disk I/O --- ## Documentation - Restructured the user manual for i18n and added complete EN/JA coverage - Added OpenClaw usage documentation and completed settings documentation - Added UCloud sponsor information - Reorganized the docs directory and synced README feature sections across EN/ZH/JA --- ## Notes & Considerations - **Common Config now uses runtime overlay**: Common Config Snippets are no longer materialized into each provider's stored config. They are dynamically applied at switch time. Modifying Common Config takes effect immediately without updating each provider. - **Stream Check requires first-use confirmation**: A confirmation dialog appears when using the model health check for the first time. Testing proceeds only after confirmation. - **OpenClaw User-Agent toggle defaults to off**: The User-Agent identifier must be manually enabled in the OpenClaw configuration. --- ## Special Thanks Thanks to all contributors for their contributions to this release! @keithyt06 @bugparty @Alex-wuhu @suki135246 @Tsukumi233 @wugeer @fzzv @Sube-py @a1398394385 @YewFence --- ## Download & Installation Visit [Releases](https://github.com/farion1231/cc-switch/releases/latest) to download the appropriate version. ### System Requirements | System | Minimum Version | Architecture | | ------- | ------------------------------- | ----------------------------------- | | Windows | Windows 10 or later | x64 | | macOS | macOS 10.15 (Catalina) or later | Intel (x64) / Apple Silicon (arm64) | | Linux | See table below | x64 | ### Windows | File | Description | | ---------------------------------------- | ---------------------------------------------------- | | `CC-Switch-v3.12.0-Windows.msi` | **Recommended** - MSI installer with auto-update | | `CC-Switch-v3.12.0-Windows-Portable.zip` | Portable version, extract and run, no registry write | ### macOS | File | Description | | -------------------------------- | -------------------------------------------------------------------- | | `CC-Switch-v3.12.0-macOS.zip` | **Recommended** - Extract and drag to Applications, Universal Binary | | `CC-Switch-v3.12.0-macOS.tar.gz` | For Homebrew installation and auto-update | > **Note**: Since the author doesn't have an Apple Developer account, you may see an "unidentified developer" warning on first launch. Please close it, then go to "System Settings" -> "Privacy & Security" -> click "Open Anyway", and it will open normally afterwards. ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` Update: ```bash brew upgrade --cask cc-switch ``` ### Linux | Distribution | Recommended Format | Installation Method | | --------------------------------------- | ------------------ | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` or `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` or `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | Add execute permission and run directly, or use AUR | | Other distributions / Unsure | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.12.0-ja.md ================================================ # CC Switch v3.12.0 > Stream Check が復活し、OpenAI Responses API に対応、OpenClaw と WebDAV も大幅強化 **[中文版 →](v3.12.0-zh.md) | [English →](v3.12.0-en.md)** --- ## 概要 CC Switch v3.12.0 は、プロバイダー互換性、OpenClaw の設定編集、共通設定の使い勝手、同期とデータ保守性を強化する機能リリースです。安定性を強化した **Model Health Check (Stream Check)** UI を復元し、**OpenAI Responses API** 形式変換を追加、**Ucloud**、**Micu**、**X-Code API**、**Novita**、**Bailian For Coding** などのプリセットを拡張し、**WebDAV 同期** に二層バージョニングを導入しました。 **リリース日**: 2026-03-09 **更新規模**: 56 commits | 221 files changed | +20,582 / -8,026 lines --- ## ハイライト - **Stream Check 復活**: モデルヘルスチェック UI を復元し、初回確認ダイアログを追加、`openai_chat` プロバイダー対応も修正 - **OpenAI Responses API**: `api_format = "openai_responses"` を追加し、双方向変換と共有変換ロジックの整理を実施 — プロバイダー追加時に Responses API フォーマットを選択してプロキシテイクオーバーを有効にするだけで、Claude Code で GPT シリーズモデルが使えます! - **OpenClaw パネル強化**: JSON5 round-trip 編集、設定ヘルスバナー、改良された Agent Model 選択、User-Agent トグルを導入 - **プリセット拡張**: Ucloud、Micu、X-Code API、Novita、Bailian For Coding を追加・更新し、SiliconFlow partner badge とモデルロールバッジも追加 - **同期と保守の改善**: WebDAV protocol v2 + db-v6、daily rollups、incremental auto-vacuum、sync-aware backup を追加 - **共通設定の使い勝手向上**: 共通設定スニペットを更新すると、プロバイダー切り替え時に自動的に反映されるようになりました。手動でチェックを入れ直す必要はありません --- ## 主な機能 ### モデルヘルスチェック (Stream Check) Stream Check パネルを復元し、プロバイダーの可用性をリアルタイムで検証できるようにしました。 - Stream Check UI パネルを復元し、単一またはバッチでのプロバイダー可用性検出をサポート - 初回使用確認ダイアログを追加、ヘルスチェック非対応プロバイダーの誤検出によるユーザー混乱を防止 - `openai_chat` API フォーマットプロバイダーの検出互換性を修正 ### OpenAI Responses API 新しい `openai_responses` API フォーマットを追加し、OpenAI Responses API を使用するプロバイダーのネイティブサポートを提供します。 - `api_format = "openai_responses"` プロバイダーフォーマットオプションを追加 - Anthropic Messages <-> OpenAI Responses API の双方向フォーマット変換をサポート - 共有変換ロジックを整理し、重複コードを削減 ### Bedrock リクエストオプティマイザー AWS Bedrock プロバイダー向けに PRE-SEND フェーズのリクエスト最適化を追加し、互換性とパフォーマンスを向上させました。 - PRE-SEND thinking + cache injection オプティマイザー(#1301、@keithyt06 に感謝) ### OpenClaw 設定強化 OpenClaw の設定編集体験を全面的にアップグレードし、より豊富な設定管理をサポートします。 - JSON5 round-trip 書き戻し: 編集時にコメントとフォーマットを保持 - EnvPanel の JSON 編集モードと `tools.profile` 選択をサポート - 設定検証バナーと設定ヘルスステータスチェックを追加 - Agent モデルのドロップダウン改善、プロバイダープリセットから推奨モデルを自動入力 - User-Agent トグル: リクエストに OpenClaw 識別子を付加する機能(デフォルトオフ) - Legacy timeout 設定の自動マイグレーション ### プロバイダープリセット 新規および既存のプロバイダープリセットを拡張し、より多くのプロバイダーとユースケースをカバーします。 - **Ucloud**: `endpointCandidates` および OpenClaw デフォルト値を追加、`templateValues` / `suggestedDefaults` を更新 - **Micu**: プリセットデフォルト値および OpenClaw 推奨モデルを追加 - **X-Code API**: Claude プリセットおよび `endpointCandidates` を追加 - **Novita**: プロバイダープリセットを追加(#1192、@Alex-wuhu に感謝) - **Bailian For Coding**: プロバイダープリセットを追加(#1263、@suki135246 に感謝) - **SiliconFlow**: partner badge 識別を追加 - **モデルロールバッジ**: プロバイダープリセットでモデルロール badge 表示をサポート ### WebDAV 同期強化 WebDAV 同期に二層バージョン管理を導入し、同期の信頼性とデータ安全性を向上させました。 - WebDAV protocol v2 + db-v6 二層バージョン管理を追加 - WebDAV auto-sync の切り替え時に確認ダイアログを表示し、誤操作を防止 - sync-aware backup: 同期時にローカル専用テーブルを除外した sync バリアントバックアップを使用 ### 使用量とデータ 使用量統計とデータ保守機能を強化し、より精密なデータ管理を実現、データベースの増加速度を大幅に抑制します。 - Daily rollups: 日次で使用量データを集計し、ストレージ使用量を削減 - Auto-vacuum: インクリメンタルなデータベースクリーンアップ、データベースの健全性を維持 - UsageFooter に追加統計フィールドを追加(#1137、@bugparty に感謝) ### その他の新機能 - **セッション削除**: プロバイダー単位のクリーンアップとパス安全性検証付きのセッション削除 - **Claude auth field selector 復元**: 認証フィールドセレクターを復元 - **Failover トグルをメインページへ移動**: failover toggle を設定パネルからメインページに独立表示し、初回確認ダイアログを追加 - **共通設定の自動抽出**: 初回起動時に live config から共通設定スニペットを自動抽出 - **新規プロバイダーページの改善**: 新規プロバイダーページの体験を最適化(#1155、@wugeer に感謝) --- ## アーキテクチャ改善 ### Common Config ランタイムオーバーレイ 共通設定スニペット(Common Config Snippet)をランタイムオーバーレイ方式に変更し、保存済みプロバイダー設定への物理マージを廃止しました。 **変更前**: Common Config の内容は保存時または切り替え時に各プロバイダーの `settings_config` に直接マージされていました。これにより共通設定が各プロバイダーエントリーにコピーされ、変更時には一つずつ同期する必要がありました。 **変更後**: Common Config はプロバイダー切り替え時に live ファイルへ書き込む際のみ runtime overlay として注入され、プロバイダーエントリー自体には共通設定を含みません。つまり Common Config の変更は即座に反映され、各プロバイダーを個別に更新する必要はありません。 ### Common Config 初回自動抽出 初回起動時にデータベースに Common Config Snippet がまだ存在しない場合、現在の live config から自動抽出します。これにより旧バージョンからアップグレードしたユーザーの既存の共通設定が失われないことを保証します。 ### 定期メンテナンスタイマー統合 daily rollups と auto-vacuum を統一の定期メンテナンスタイマーに統合し、複数の独立タイマーによるリソース競合と複雑さを回避しました。 --- ## バグ修正 ### プロキシとストリーミング - OpenAI ChatCompletion -> Anthropic Messages のストリーミング変換問題を修正 - Codex `/responses/compact` ルーティングをサポート(#1194、@Tsukumi233 に感謝) - TOML 設定マージロジックを改善し、キー値の欠落を回避 - proxy forwarder の失敗ログを改善し、診断情報を追加 ### プロバイダーとプリセットの修正 - X-Code を X-Code API にリネームし、ブランド名称を統一 - SSSAiCode の `/v1` パス問題を修正 - AICoding URL の誤った `www` プレフィックスを削除 - 新規プロバイダーページの改行削除問題を修正(#1155、@wugeer に感謝) ### プラットフォーム修正 - cache hit token の統計欠落を修正(#1244、@a1398394385 に感謝) - 最小化後しばらくすると自動終了する問題を修正(#1245、@YewFence に感謝) ### i18n 修正 - 69 個の欠落翻訳キーを補完し、残りのハードコード中国語を除去 - model test panel の i18n 問題を修正 - JSON5 slash escaping を正規化し、国際化文字列の解析異常を回避 ### UI 修正 - Skills カウント表示の問題を修正(#1295、@fzzv に感謝) - endpoint speed test から HTTP ステータスコード表示を削除し、視覚的ノイズを軽減 - outline button のスタイル問題を修正(#1222、@Sube-py に感謝) --- ## パフォーマンス - OpenClaw 設定が未変更の場合に不要な書き込みをスキップし、ディスク I/O を削減 --- ## ドキュメント - ユーザーマニュアルを i18n 対応で再構成し、EN/JA の内容を拡充 - OpenClaw の説明を追加し、設定ドキュメントを補完 - UCloud スポンサー情報を追加 - docs ディレクトリを再編成し、EN/ZH/JA の README 機能説明を同期 --- ## 注意事項 - **Common Config はランタイムオーバーレイに変更**: 共通設定スニペットは各プロバイダー設定への物理マージではなく、切り替え時に動的にオーバーレイされます。Common Config の変更は即座に反映され、各プロバイダーを個別に更新する必要はありません。 - **Stream Check は初回使用時に確認が必要**: 初回使用時にモデルヘルスチェックの確認ダイアログが表示され、確認後に使用可能になります。 - **OpenClaw の User-Agent トグルはデフォルトオフ**: OpenClaw 設定で User-Agent 識別子の付加機能を手動で有効にする必要があります。 --- ## 謝辞 以下のコントリビューターの皆様、このリリースへの貢献に感謝します! @keithyt06 @bugparty @Alex-wuhu @suki135246 @Tsukumi233 @wugeer @fzzv @Sube-py @a1398394385 @YewFence --- ## ダウンロードとインストール [Releases](https://github.com/farion1231/cc-switch/releases/latest) から適切なバージョンをダウンロードしてください。 ### システム要件 | システム | 最小バージョン | アーキテクチャ | | -------- | -------------------------------- | ----------------------------------- | | Windows | Windows 10 以降 | x64 | | macOS | macOS 10.15 (Catalina) 以降 | Intel (x64) / Apple Silicon (arm64) | | Linux | 下表参照 | x64 | ### Windows | ファイル | 説明 | | ---------------------------------------- | ---------------------------------------------------- | | `CC-Switch-v3.12.0-Windows.msi` | **推奨** - MSI インストーラー、自動更新対応 | | `CC-Switch-v3.12.0-Windows-Portable.zip` | ポータブル版、解凍して実行、レジストリ書き込みなし | ### macOS | ファイル | 説明 | | -------------------------------- | ----------------------------------------------------------------- | | `CC-Switch-v3.12.0-macOS.zip` | **推奨** - 解凍して Applications にドラッグ、Universal Binary | | `CC-Switch-v3.12.0-macOS.tar.gz` | Homebrew インストールと自動更新用 | > **注意**: 作者が Apple Developer アカウントを持っていないため、初回起動時に「開発元を確認できません」という警告が表示される場合があります。一度閉じてから、「システム設定」→「プライバシーとセキュリティ」→「このまま開く」をクリックすると、その後は正常に開けます。 ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | ディストリビューション | 推奨形式 | インストール方法 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` または `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` または `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 実行権限を追加して直接実行、または AUR を使用 | | その他のディストリビューション / 不明 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.12.0-zh.md ================================================ # CC Switch v3.12.0 > Stream Check 回归,OpenAI Responses API 上线,OpenClaw 与 WebDAV 迎来一次大升级 **[English →](v3.12.0-en.md) | [日本語版 →](v3.12.0-ja.md)** --- ## 概览 CC Switch v3.12.0 是一个功能版本,重点提升供应商兼容性、OpenClaw 配置编辑体验、通用配置功能使用体验,以及同步与数据维护能力。本次恢复了增强稳定性后的 **模型健康检查(Stream Check)** UI,新增 **OpenAI Responses API** 格式转换,扩展了 **Ucloud**、**Micu**、**X-Code API**、**Novita**、**Bailian For Coding** 等供应商预设,并为 **WebDAV 同步** 引入双层版本控制。 **发布日期**:2026-03-09 **更新规模**:56 commits | 221 files changed | +20,582 / -8,026 lines --- ## 重点内容 - **Stream Check 回归**:恢复模型健康检查 UI,新增首次使用确认,并修复 `openai_chat` 供应商检测 - **OpenAI Responses API**:新增 `api_format = "openai_responses"`,支持双向格式转换并整理共享转换逻辑,只需要在添加供应商的时候选择 Response 接口格式并开启代理接管,您就可以在 Claude Code 中使用 gpt 系列模型了! - **OpenClaw 面板升级**:引入 JSON5 round-trip 配置编辑、配置健康提示、改进后的 Agent Model 选择和 User-Agent 开关 - **预设扩展**:补充 Ucloud、Micu、X-Code API、Novita、Bailian For Coding 预设,并新增 SiliconFlow partner badge 与模型角色标识 - **同步与维护增强**:新增 WebDAV protocol v2 + db-v6 双层版本、daily rollups、增量 auto-vacuum 和 sync-aware backup - **通用配置功能使用体验优化**:现在通用配置片段更新之后,会在切换供应商时自动同步到新的供应商,不需要再手动勾选。 --- ## 主要功能 ### 模型健康检查 Stream Check 恢复 Stream Check 面板,用于实时验证供应商可用性,增强供应商管理的可靠性。 - 恢复 Stream Check UI 面板,支持单个或批量检测供应商可用性 - 新增首次使用确认对话框,避免不支持健康检查的供应商报错误导用户 - 修复 `openai_chat` API 格式供应商的检测兼容性 ### OpenAI Responses API 新增 `openai_responses` API 格式,为使用 OpenAI Responses API 的供应商提供原生支持。 - 新增 `api_format = "openai_responses"` 供应商格式选项 - 支持 Anthropic Messages <-> OpenAI Responses API 双向格式转换 - 整理共享转换逻辑,减少重复代码 ### Bedrock 请求优化器 为 AWS Bedrock 供应商新增 PRE-SEND 阶段请求优化器,提升兼容性和性能。 - PRE-SEND thinking + cache injection 优化器(#1301,感谢 @keithyt06) ### OpenClaw 配置增强 OpenClaw 配置编辑体验全面升级,支持更丰富的配置管理。 - JSON5 round-trip 写回:编辑配置时保留注释和格式 - EnvPanel 支持 JSON 编辑模式和 `tools.profile` 选择 - 新增配置校验提示和配置健康状态检查 - Agent 模型下拉框改进,支持从供应商预设填充推荐模型 - User-Agent 开关:可选在请求中附加 User-Agent 标识(默认关闭) - Legacy timeout 配置自动迁移 ### 供应商预设 Preset 新增和扩展多组供应商预设,覆盖更多供应商和使用场景。 - **Ucloud**:新增 `endpointCandidates` 以及 OpenClaw 默认值,刷新 `templateValues` / `suggestedDefaults` - **Micu**:新增预设默认值及 OpenClaw 推荐模型 - **X-Code API**:新增 Claude 预设及 `endpointCandidates` - **Novita**:新增供应商预设(#1192,感谢 @Alex-wuhu) - **Bailian For Coding**:新增供应商预设(#1263,感谢 @suki135246) - **SiliconFlow**:新增 partner badge 标识 - **模型角色标识**:供应商预设支持模型角色 badge 显示 ### WebDAV 同步增强 WebDAV 同步引入双层版本控制,提升同步可靠性和数据安全性。 - 新增 WebDAV protocol v2 + db-v6 双层版本控制 - 切换 WebDAV auto-sync 时弹出确认对话框,防止误操作 - sync-aware backup:WebDAV 同步时使用 sync 变体备份,跳过仅本地使用的表数据 ### 用量与数据 用量统计和数据维护能力增强,数据管理更精细,极大降低数据库增长速度。 - Daily rollups:按天汇总用量数据,减少存储占用 - Auto-vacuum:增量式数据库清理,保持数据库健康 - UsageFooter 新增额外统计字段(#1137,感谢 @bugparty) ### 其他新功能 - **会话删除**:按供应商清理会话记录,带路径安全校验 - **Claude auth field selector 恢复**:恢复认证字段选择器 - **Failover 开关独立显示**:将 failover toggle 从设置面板移到主页独立展示,并新增首次确认对话框 - **通用配置自动抽取**:首次运行时自动从 live config 中抽取通用配置片段 - **新供应商页面改进**:优化新建供应商页面体验(#1155,感谢 @wugeer) --- ## 架构改进 ### Common Config 运行时叠加 通用配置片段(Common Config Snippet)改为运行时叠加方式应用,不再物化写入每个供应商配置。 **变更前**:Common Config 内容在保存或切换时直接合并写入每个供应商的 `settings_config`。这导致公共配置被复制到每个供应商条目中,修改时需要逐一同步。 **变更后**:Common Config 仅在切换供应商写入 live 文件时以 runtime overlay 方式注入,供应商条目本身不包含公共配置。这意味着修改 Common Config 后立即生效,无需逐一更新每个供应商。 ### 通用配置首次自动抽取 首次运行时,如果数据库中尚无 Common Config Snippet,会自动从当前 live config 中抽取通用配置。这确保了从旧版本升级的用户不会丢失已有的通用配置设置。 ### 定期维护定时器整合 将 daily rollups 和 auto-vacuum 整合到统一的定期维护定时器中,避免多个独立定时器带来的资源竞争和复杂度。 --- ## Bug 修复 ### 代理与流式转换 - 修复 OpenAI ChatCompletion -> Anthropic Messages 流式转换问题 - 新增 Codex `/responses/compact` 路由支持(#1194,感谢 @Tsukumi233) - 改进 TOML 配置合并逻辑,避免键值丢失 - 改进 proxy forwarder 失败日志,增加更多诊断信息 ### 供应商预设修复 - X-Code 更名为 X-Code API,统一品牌命名 - 修复 SSSAiCode `/v1` 路径问题 - 移除 AICoding URL 错误的 `www` 前缀 - 优化新建供应商页面换行删除问题(#1155,感谢 @wugeer) ### 平台修复 - 修复 cache hit token 统计缺失(#1244,感谢 @a1398394385) - 修复最小化到托盘后一段时间自动退出的问题(#1245,感谢 @YewFence) ### i18n 修复 - 补齐 69 个缺失翻译 key,清理剩余硬编码中文 - 修复 model test panel 的 i18n 问题 - 规范 JSON5 slash escaping,避免国际化字符串解析异常 ### UI 修复 - 修复 Skills 计数显示问题(#1295,感谢 @fzzv) - 移除 endpoint speed test 的 HTTP 状态码显示,减少视觉噪音 - 修复 outline button 样式问题(#1222,感谢 @Sube-py) --- ## 性能优化 - OpenClaw 配置未变化时跳过无意义写入,减少磁盘 I/O --- ## 文档 - 重构用户手册以支持国际化,补齐 EN/JA 完整内容 - 新增 OpenClaw 使用说明,补完设置章节 - 新增 UCloud 赞助商信息 - 重组 docs 目录结构,同步 EN/ZH/JA README 的功能说明 --- ## 说明与注意事项 - **Common Config 改为运行时叠加**:通用配置片段不再物化写入每个供应商配置,而是在切换时动态叠加。修改 Common Config 后立即生效,无需逐一更新供应商。 - **Stream Check 首次使用需确认**:首次使用模型健康检查时会弹出确认对话框,确认后方可使用。 - **OpenClaw User-Agent 开关默认关闭**:需要在 OpenClaw 配置中手动开启 User-Agent 标识附加功能。 --- ## 特别感谢 感谢以下贡献者为本版本做出的贡献! @keithyt06 @bugparty @Alex-wuhu @suki135246 @Tsukumi233 @wugeer @fzzv @Sube-py @a1398394385 @YewFence --- ## 下载与安装 访问 [Releases](https://github.com/farion1231/cc-switch/releases/latest) 下载对应版本。 ### 系统要求 | 系统 | 最低版本 | 架构 | | ------- | ----------------------------- | ----------------------------------- | | Windows | Windows 10 及以上 | x64 | | macOS | macOS 10.15 (Catalina) 及以上 | Intel (x64) / Apple Silicon (arm64) | | Linux | 见下表 | x64 | ### Windows | 文件 | 说明 | | ---------------------------------------- | ----------------------------------- | | `CC-Switch-v3.12.0-Windows.msi` | **推荐** - MSI 安装包,支持自动更新 | | `CC-Switch-v3.12.0-Windows-Portable.zip` | 便携版,解压即用,不写入注册表 | ### macOS | 文件 | 说明 | | -------------------------------- | --------------------------------------------------------- | | `CC-Switch-v3.12.0-macOS.zip` | **推荐** - 解压后拖入 Applications 即可,Universal Binary | | `CC-Switch-v3.12.0-macOS.tar.gz` | 用于 Homebrew 安装和自动更新 | > **注意**:由于作者没有苹果开发者账号,首次打开可能出现"未知开发者"警告,请先关闭,然后前往"系统设置" → "隐私与安全性" → 点击"仍要打开",之后便可以正常打开 ### Homebrew(macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | 发行版 | 推荐格式 | 安装方式 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` 或 `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` 或 `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 添加执行权限后直接运行,或使用 AUR | | 其他发行版 / 不确定 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.12.1-en.md ================================================ # CC Switch v3.12.1 > Stability Fixes, StepFun Presets, OpenClaw authHeader, and New Sponsor Partners **[中文版 →](v3.12.1-zh.md) | [日本語版 →](v3.12.1-ja.md)** --- ## Overview CC Switch v3.12.1 is a patch release focused on stability improvements and bug fixes. It resolves a Common Config modal infinite reopen loop, a WebDAV sync foreign key constraint failure, and several i18n interpolation issues. It also adds **StepFun** provider presets, **OpenClaw input type selection** and **authHeader** support, upgrades the default Gemini model to **3.1-pro**, and welcomes four new sponsor partners. **Release Date**: 2026-03-12 **Update Scale**: 19 commits | 56 files changed | +1,429 / -396 lines --- ## Highlights - **Common Config modal fix**: Resolved an infinite reopen loop in the Common Config modal and added draft editing support - **WebDAV sync reliability**: Fixed a foreign key constraint failure when restoring `provider_health` during WebDAV sync - **StepFun presets**: Added StepFun (阶跃星辰) provider presets including the step-3.5-flash model - **OpenClaw enhancements**: Added input type selection for model Advanced Options and `authHeader` field for vendor-specific auth header support - **Gemini model upgrade**: Upgraded default Gemini model to 3.1-pro in provider presets - **New sponsors**: Welcomed Micu API, XCodeAPI, SiliconFlow, and CTok as sponsor partners --- ## New Features ### StepFun Provider Presets Added provider presets for StepFun (阶跃星辰), a leading Chinese AI model provider. - New preset entries for StepFun across supported applications - Includes the step-3.5-flash model (#1369, thanks @hengm3467) ### OpenClaw Enhancements Enhanced the OpenClaw configuration with more granular control and better vendor compatibility. - Added input type selection dropdown for model Advanced Options (#1368, thanks @liuxxxu) - Added optional `authHeader` boolean to `OpenClawProviderConfig` for vendor-specific auth header support (e.g. Longcat), and refactored form state to reuse the shared type ### Sponsor Partners - **Micu API**: Added Micu API as sponsor partner with affiliate links - **XCodeAPI**: Added XCodeAPI as sponsor partner - **SiliconFlow**: Added SiliconFlow (硅基流动) as sponsor partner with affiliate links - **CTok**: Added CTok as sponsor partner --- ## Changes - **UCloud → Compshare**: Renamed UCloud provider to Compshare (优云智算) with full i18n support across all three locales (EN/ZH/JA) - **Compshare Links**: Updated Compshare sponsor registration links to coding-plan page - **Gemini Model Upgrade**: Upgraded default Gemini model from 2.5-pro to 3.1-pro in provider presets --- ## Bug Fixes ### Common Config & UI - Fixed an infinite reopen loop in the Common Config modal and added draft editing support to prevent data loss during edits - Fixed toolbar compact mode not triggering on Windows due to left-side overflow (#1375, thanks @zuoliangyu) - Fixed session search index not syncing with query data, causing stale list display after session deletion ### Sync & Data - Fixed foreign key constraint failure when restoring `provider_health` table during WebDAV sync ### Provider & Preset - Added missing `authHeader: true` to Longcat provider preset (#1377, thanks @wavever) - Aligned OpenClaw tool permission profiles with upstream schema (#1355, thanks @bigsongeth) - Corrected X-Code API URL from `www.x-code.cn` to `x-code.cc` ### i18n & Localization - Fixed stream check toast i18n interpolation keys not matching translation placeholders - Fixed proxy startup toast not interpolating address and port values (#1399, thanks @Mason-mengze) - Renamed OpenCode API format label from "OpenAI" to "OpenAI Responses" for accuracy --- ## Special Thanks Thanks to all contributors for their contributions to this release! @hengm3467 @liuxxxu @bigsongeth @zuoliangyu @wavever @Mason-mengze --- ## Download & Installation Visit [Releases](https://github.com/farion1231/cc-switch/releases/latest) to download the appropriate version. ### System Requirements | System | Minimum Version | Architecture | | ------- | ------------------------------- | ----------------------------------- | | Windows | Windows 10 or later | x64 | | macOS | macOS 10.15 (Catalina) or later | Intel (x64) / Apple Silicon (arm64) | | Linux | See table below | x64 | ### Windows | File | Description | | ------------------------------------------ | ---------------------------------------------------- | | `CC-Switch-v3.12.1-Windows.msi` | **Recommended** - MSI installer with auto-update | | `CC-Switch-v3.12.1-Windows-Portable.zip` | Portable version, extract and run, no registry write | ### macOS | File | Description | | ---------------------------------- | -------------------------------------------------------------------- | | `CC-Switch-v3.12.1-macOS.zip` | **Recommended** - Extract and drag to Applications, Universal Binary | | `CC-Switch-v3.12.1-macOS.tar.gz` | For Homebrew installation and auto-update | > **Note**: Since the author doesn't have an Apple Developer account, you may see an "unidentified developer" warning on first launch. Please close it, then go to "System Settings" -> "Privacy & Security" -> click "Open Anyway", and it will open normally afterwards. ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` Update: ```bash brew upgrade --cask cc-switch ``` ### Linux | Distribution | Recommended Format | Installation Method | | --------------------------------------- | ------------------ | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` or `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` or `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | Add execute permission and run directly, or use AUR | | Other distributions / Unsure | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.12.1-ja.md ================================================ # CC Switch v3.12.1 > 安定性修正、StepFun プリセット、OpenClaw authHeader 対応、新スポンサーパートナー **[中文版 →](v3.12.1-zh.md) | [English →](v3.12.1-en.md)** --- ## 概要 CC Switch v3.12.1 は、安定性の改善とバグ修正に焦点を当てたパッチリリースです。共通設定モーダルの無限再オープンループ、WebDAV 同期時の外部キー制約エラー、複数の i18n 補間問題を修正しました。また、**StepFun(阶跃星辰)** プロバイダープリセットの追加、OpenClaw の**入力タイプ選択**と **authHeader** サポート、デフォルト Gemini モデルの **3.1-pro** へのアップグレード、4 つの新スポンサーパートナーの追加が含まれます。 **リリース日**: 2026-03-12 **更新規模**: 19 commits | 56 files changed | +1,429 / -396 lines --- ## ハイライト - **共通設定モーダル修正**: 共通設定モーダルの無限再オープンループを解決し、下書き編集サポートを追加 - **WebDAV 同期の信頼性向上**: WebDAV 同期で `provider_health` 復元時の外部キー制約エラーを修正 - **StepFun プリセット**: StepFun(阶跃星辰)プロバイダープリセットを追加、step-3.5-flash モデルを含む - **OpenClaw 強化**: モデル詳細設定に入力タイプ選択を追加、ベンダー固有の認証ヘッダーサポート用 `authHeader` フィールドを追加 - **Gemini モデルアップグレード**: プロバイダープリセットのデフォルト Gemini モデルを 3.1-pro にアップグレード - **新スポンサー**: Micu API、XCodeAPI、SiliconFlow、CTok をスポンサーパートナーとして追加 --- ## 新機能 ### StepFun プロバイダープリセット 中国の主要 AI モデルプロバイダーである StepFun(阶跃星辰)のプロバイダープリセットを追加しました。 - サポート対象アプリケーション全体に StepFun プリセットエントリーを追加 - step-3.5-flash モデルを含む(#1369、@hengm3467 に感謝) ### OpenClaw 強化 OpenClaw 設定をより細かく制御でき、ベンダー互換性を向上させました。 - モデル詳細設定に入力タイプ(input type)選択ドロップダウンを追加(#1368、@liuxxxu に感謝) - `OpenClawProviderConfig` にオプションの `authHeader` ブール値を追加し、ベンダー固有の認証ヘッダー(例: Longcat)をサポート。フォーム状態を共有型の再利用にリファクタリング ### スポンサーパートナー - **Micu API**: Micu API をスポンサーパートナーとして追加、アフィリエイトリンク付き - **XCodeAPI**: XCodeAPI をスポンサーパートナーとして追加 - **SiliconFlow**: SiliconFlow(硅基流动)をスポンサーパートナーとして追加、アフィリエイトリンク付き - **CTok**: CTok をスポンサーパートナーとして追加 --- ## 変更 - **UCloud → Compshare**: UCloud プロバイダーを Compshare(优云智算)にリネームし、3 言語(EN/ZH/JA)の完全な i18n サポートを追加 - **Compshare リンク**: Compshare スポンサー登録リンクを coding-plan ページに更新 - **Gemini モデルアップグレード**: プロバイダープリセットのデフォルト Gemini モデルを 2.5-pro から 3.1-pro にアップグレード --- ## バグ修正 ### 共通設定と UI - 共通設定モーダルの無限再オープンループを修正し、編集中のデータ損失を防ぐための下書き編集サポートを追加 - Windows でツールバーコンパクトモードが左側のオーバーフローにより機能しない問題を修正(#1375、@zuoliangyu に感謝) - セッション削除後にクエリデータと検索インデックスが同期されず、リストが更新されない問題を修正 ### 同期とデータ - WebDAV 同期で `provider_health` テーブルを復元する際の外部キー制約エラーを修正 ### プロバイダーとプリセット - Longcat プロバイダープリセットに欠落していた `authHeader: true` を追加(#1377、@wavever に感謝) - OpenClaw のツール権限プロファイルをアップストリームスキーマに合わせて修正(#1355、@bigsongeth に感謝) - X-Code API の URL を `www.x-code.cn` から `x-code.cc` に修正 ### i18n とローカリゼーション - Stream Check トーストの i18n 補間キーが翻訳プレースホルダーと一致しない問題を修正 - プロキシ起動トーストでアドレスとポート値が補間されない問題を修正(#1399、@Mason-mengze に感謝) - OpenCode の API フォーマットラベルを「OpenAI」から「OpenAI Responses」にリネームし、正確性を向上 --- ## 謝辞 以下のコントリビューターの皆様、このリリースへの貢献に感謝します! @hengm3467 @liuxxxu @bigsongeth @zuoliangyu @wavever @Mason-mengze --- ## ダウンロードとインストール [Releases](https://github.com/farion1231/cc-switch/releases/latest) から適切なバージョンをダウンロードしてください。 ### システム要件 | システム | 最小バージョン | アーキテクチャ | | -------- | -------------------------------- | ----------------------------------- | | Windows | Windows 10 以降 | x64 | | macOS | macOS 10.15 (Catalina) 以降 | Intel (x64) / Apple Silicon (arm64) | | Linux | 下表参照 | x64 | ### Windows | ファイル | 説明 | | ------------------------------------------ | ---------------------------------------------------- | | `CC-Switch-v3.12.1-Windows.msi` | **推奨** - MSI インストーラー、自動更新対応 | | `CC-Switch-v3.12.1-Windows-Portable.zip` | ポータブル版、解凍して実行、レジストリ書き込みなし | ### macOS | ファイル | 説明 | | ---------------------------------- | ----------------------------------------------------------------- | | `CC-Switch-v3.12.1-macOS.zip` | **推奨** - 解凍して Applications にドラッグ、Universal Binary | | `CC-Switch-v3.12.1-macOS.tar.gz` | Homebrew インストールと自動更新用 | > **注意**: 作者が Apple Developer アカウントを持っていないため、初回起動時に「開発元を確認できません」という警告が表示される場合があります。一度閉じてから、「システム設定」→「プライバシーとセキュリティ」→「このまま開く」をクリックすると、その後は正常に開けます。 ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | ディストリビューション | 推奨形式 | インストール方法 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` または `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` または `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 実行権限を追加して直接実行、または AUR を使用 | | その他のディストリビューション / 不明 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.12.1-zh.md ================================================ # CC Switch v3.12.1 > 稳定性修复、StepFun 预设、OpenClaw authHeader 支持,以及新赞助商伙伴 **[English →](v3.12.1-en.md) | [日本語版 →](v3.12.1-ja.md)** --- ## 概览 CC Switch v3.12.1 是一个以稳定性改进和 Bug 修复为主的补丁版本。修复了通用配置弹窗无限重复打开的循环问题、WebDAV 同步时的外键约束失败以及多个 i18n 插值问题。同时新增了 **StepFun(阶跃星辰)** 供应商预设、OpenClaw **输入类型选择** 和 **authHeader** 支持,将默认 Gemini 模型升级到 **3.1-pro**,并欢迎四位新赞助商伙伴加入。 **发布日期**:2026-03-12 **更新规模**:19 commits | 56 files changed | +1,429 / -396 lines --- ## 重点内容 - **通用配置弹窗修复**:解决了通用配置弹窗无限重复打开的循环问题,并新增草稿编辑支持 - **WebDAV 同步可靠性**:修复了 WebDAV 同步恢复 `provider_health` 时的外键约束失败 - **StepFun 预设**:新增 StepFun(阶跃星辰)供应商预设,包含 step-3.5-flash 模型 - **OpenClaw 增强**:新增模型高级选项的输入类型选择和 `authHeader` 字段,支持供应商特定的认证头 - **Gemini 模型升级**:供应商预设中的默认 Gemini 模型升级到 3.1-pro - **新赞助商**:欢迎 Micu API、XCodeAPI、SiliconFlow、CTok 加入赞助伙伴 --- ## 新功能 ### StepFun 供应商预设 新增 StepFun(阶跃星辰)供应商预设,阶跃星辰是领先的中国 AI 模型提供商。 - 在各支持应用中新增 StepFun 预设条目 - 包含 step-3.5-flash 模型(#1369,感谢 @hengm3467) ### OpenClaw 增强 增强 OpenClaw 配置能力,提供更细粒度的控制和更好的供应商兼容性。 - 新增模型高级选项的输入类型(input type)选择下拉框(#1368,感谢 @liuxxxu) - 在 `OpenClawProviderConfig` 中新增可选的 `authHeader` 布尔字段,支持供应商特定的认证头(如 Longcat),并重构表单状态以复用共享类型 ### 赞助商伙伴 - **Micu API**:新增 Micu API 赞助商及推广链接 - **XCodeAPI**:新增 XCodeAPI 赞助商 - **SiliconFlow**:新增 SiliconFlow(硅基流动)赞助商及推广链接 - **CTok**:新增 CTok 赞助商 --- ## 变更 - **UCloud → Compshare**:将 UCloud 供应商更名为 Compshare(优云智算),支持三种语言(中/英/日)的完整国际化 - **Compshare 链接**:更新 Compshare 赞助商注册链接指向 coding-plan 页面 - **Gemini 模型升级**:供应商预设中的默认 Gemini 模型从 2.5-pro 升级到 3.1-pro --- ## Bug 修复 ### 通用配置与 UI - 修复通用配置弹窗无限重复打开的循环问题,并新增草稿编辑支持以防止编辑过程中数据丢失 - 修复 Windows 下因左侧溢出导致工具栏紧凑模式不触发的问题(#1375,感谢 @zuoliangyu) - 修复会话删除后搜索索引未与查询数据同步,导致列表显示过期的问题 ### 同步与数据 - 修复 WebDAV 同步恢复 `provider_health` 表时的外键约束失败 ### 供应商与预设 - 为 Longcat 供应商预设补充缺失的 `authHeader: true`(#1377,感谢 @wavever) - 对齐 OpenClaw 工具权限配置与上游 schema(#1355,感谢 @bigsongeth) - 修正 X-Code API URL,从 `www.x-code.cn` 改为 `x-code.cc` ### i18n 与本地化 - 修复 Stream Check Toast 的 i18n 插值 key 与翻译占位符不匹配 - 修复代理启动 Toast 未正确插值地址和端口的问题(#1399,感谢 @Mason-mengze) - 将 OpenCode API 格式标签从 "OpenAI" 改为 "OpenAI Responses",更准确地反映实际格式 --- ## 特别感谢 感谢以下贡献者为本版本做出的贡献! @hengm3467 @liuxxxu @bigsongeth @zuoliangyu @wavever @Mason-mengze --- ## 下载与安装 访问 [Releases](https://github.com/farion1231/cc-switch/releases/latest) 下载对应版本。 ### 系统要求 | 系统 | 最低版本 | 架构 | | ------- | ----------------------------- | ----------------------------------- | | Windows | Windows 10 及以上 | x64 | | macOS | macOS 10.15 (Catalina) 及以上 | Intel (x64) / Apple Silicon (arm64) | | Linux | 见下表 | x64 | ### Windows | 文件 | 说明 | | ------------------------------------------ | ----------------------------------- | | `CC-Switch-v3.12.1-Windows.msi` | **推荐** - MSI 安装包,支持自动更新 | | `CC-Switch-v3.12.1-Windows-Portable.zip` | 便携版,解压即用,不写入注册表 | ### macOS | 文件 | 说明 | | ---------------------------------- | --------------------------------------------------------- | | `CC-Switch-v3.12.1-macOS.zip` | **推荐** - 解压后拖入 Applications 即可,Universal Binary | | `CC-Switch-v3.12.1-macOS.tar.gz` | 用于 Homebrew 安装和自动更新 | > **注意**:由于作者没有苹果开发者账号,首次打开可能出现"未知开发者"警告,请先关闭,然后前往"系统设置" → "隐私与安全性" → 点击"仍要打开",之后便可以正常打开 ### Homebrew(macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | 发行版 | 推荐格式 | 安装方式 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` 或 `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` 或 `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 添加执行权限后直接运行,或使用 AUR | | 其他发行版 / 不确定 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.12.2-en.md ================================================ # CC Switch v3.12.2 > Common Config Protection During Proxy Takeover, Snippet Lifecycle Stability, Section-Aware Codex TOML Editing **[中文版 →](v3.12.2-zh.md) | [日本語版 →](v3.12.2-ja.md)** --- ## Overview CC Switch v3.12.2 is a reliability-focused patch release that addresses Common Config loss during proxy takeover and improves Codex TOML editing accuracy. Proxy takeover hot-switches and provider sync now update the restore backup instead of overwriting live config files; the startup sequence has been reordered so snippets are extracted from clean live files before takeover state is restored; and Codex `base_url` editing has been refactored into a section-aware model that no longer appends to the end of the file. **Release Date**: 2026-03-12 **Update Scale**: 5 commits | 22 files changed | +1,716 / -288 lines --- ## Highlights - **Empty state guidance**: Provider list empty state now shows detailed import instructions with a conditional Common Config snippet hint for Claude/Codex/Gemini - **Proxy takeover restore flow rework**: Hot-switches and provider sync now refresh the restore backup instead of overwriting live config files, preserving the full user configuration on rollback - **Snippet lifecycle stability**: Introduced a `cleared` flag to prevent auto-extraction from resurrecting cleared snippets, and reordered startup to extract from clean state - **Section-aware Codex TOML editing**: `base_url` and `model` field reads/writes now target the correct `[model_providers.]` section - **Codex MCP config protection**: Existing `mcp_servers` blocks in restore snapshots survive provider hot-switches via per-server-id merge instead of wholesale replacement, with provider/common-config definitions winning on conflict --- ## New Features ### Empty State Guidance Improved the first-run experience with helpful guidance when the provider list is empty. - Empty state page shows step-by-step import instructions - Conditionally displays a Common Config snippet hint for Claude/Codex/Gemini providers (not shown for OpenCode/OpenClaw) --- ## Changes ### Proxy Takeover Restore Flow The proxy takeover hot-switch and provider sync logic has been reworked to protect Common Config throughout the takeover lifecycle. - Provider sync now updates the restore backup instead of writing directly to live config files when takeover is active - Effective provider settings are rebuilt with Common Config applied before saving restore snapshots, so rollback restores the real user configuration - Legacy providers with inferred common config usage are automatically marked with `commonConfigEnabled=true` ### Codex TOML Editing Engine Codex `config.toml` update logic has been refactored onto shared section-aware TOML helpers. - New Rust module `codex_config.rs` with `update_codex_toml_field` and `remove_codex_toml_base_url_if` - New frontend utilities `getTomlSectionRange` / `getCodexProviderSectionName` for section-aware operations - Inline TOML editing logic scattered across `proxy.rs` now delegates to the new module ### Common Config Initialization Lifecycle The startup sequence has been reordered for more robust snippet extraction and migration. - Startup now auto-extracts Common Config snippets from clean live files before restoring proxy takeover state - Introduced a snippet `cleared` flag to track whether a user intentionally cleared a snippet - Persisted a one-time legacy migration flag to avoid repeated `commonConfigEnabled` backfills --- ## Bug Fixes ### Common Config Loss - Fixed multiple scenarios where Common Config could be dropped during proxy takeover: sync overwriting live files, hot-switches producing incomplete restore snapshots, and provider switches losing config changes ### Codex Restore Snapshot Preservation - Fixed Codex takeover restore backups discarding existing `mcp_servers` blocks during provider hot-switches; changed MCP backup preservation from wholesale table replacement to per-server-id merge so provider/common-config MCP updates win on conflict while backup-only servers are retained ### Cleared Snippet Resurrection - Fixed startup auto-extraction recreating Common Config snippets that users had intentionally cleared ### Codex `base_url` Misplacement - Fixed Codex `base_url` extraction and editing not targeting the correct `[model_providers.]` section, causing it to append to the file tail or confuse `mcp_servers.*.base_url` entries for provider endpoints --- ## Download & Installation Visit [Releases](https://github.com/farion1231/cc-switch/releases/latest) to download the appropriate version. ### System Requirements | System | Minimum Version | Architecture | | ------- | ------------------------------- | ----------------------------------- | | Windows | Windows 10 or later | x64 | | macOS | macOS 10.15 (Catalina) or later | Intel (x64) / Apple Silicon (arm64) | | Linux | See table below | x64 | ### Windows | File | Description | | ------------------------------------------ | ---------------------------------------------------- | | `CC-Switch-v3.12.2-Windows.msi` | **Recommended** - MSI installer with auto-update | | `CC-Switch-v3.12.2-Windows-Portable.zip` | Portable version, extract and run, no registry write | ### macOS | File | Description | | ---------------------------------- | -------------------------------------------------------------------- | | `CC-Switch-v3.12.2-macOS.zip` | **Recommended** - Extract and drag to Applications, Universal Binary | | `CC-Switch-v3.12.2-macOS.tar.gz` | For Homebrew installation and auto-update | > **Note**: Since the author doesn't have an Apple Developer account, you may see an "unidentified developer" warning on first launch. Please close it, then go to "System Settings" -> "Privacy & Security" -> click "Open Anyway", and it will open normally afterwards. ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` Update: ```bash brew upgrade --cask cc-switch ``` ### Linux | Distribution | Recommended Format | Installation Method | | --------------------------------------- | ------------------ | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` or `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` or `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | Add execute permission and run directly, or use AUR | | Other distributions / Unsure | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.12.2-ja.md ================================================ # CC Switch v3.12.2 > プロキシテイクオーバー中の共通設定保護、Snippet ライフサイクルの安定化、Codex TOML セクション対応編集 **[中文版 →](v3.12.2-zh.md) | [English →](v3.12.2-en.md)** --- ## 概要 CC Switch v3.12.2 は、信頼性を重視したパッチリリースです。プロキシテイクオーバーモードでの共通設定(Common Config)の消失問題を解決し、Codex TOML 設定の編集精度を改善しました。テイクオーバーのホットスイッチとプロバイダー同期は、ライブ設定ファイルを上書きする代わりにリストアバックアップを更新するようになりました。起動シーケンスを再整理し、テイクオーバー状態を復元する前にクリーンなライブファイルから Snippet を抽出するようにしました。また Codex の `base_url` 編集をセクション対応モデルにリファクタリングし、ファイル末尾への誤追加を防止しました。 **リリース日**: 2026-03-12 **更新規模**: 5 commits | 22 files changed | +1,716 / -288 lines --- ## ハイライト - **空状態ガイダンスの改善**: プロバイダーリストが空の場合に詳細なインポート手順を表示し、Claude/Codex/Gemini には共通設定 Snippet のヒントを条件付きで表示 - **プロキシテイクオーバーリストアフロー刷新**: ホットスイッチとプロバイダー同期がライブ設定ファイルの上書きではなくリストアバックアップの更新を行うようになり、ロールバック時に完全なユーザー設定を保持 - **Snippet ライフサイクルの安定化**: `cleared` フラグを導入し、クリア済み Snippet の自動再抽出を防止。起動順序を調整してクリーンな状態から抽出 - **Codex TOML セクション対応編集**: `base_url` と `model` フィールドの読み書きが正しい `[model_providers.]` セクションを対象にするように改善 - **Codex MCP 設定の保護**: プロバイダーホットスイッチ時にリストアスナップショット内の既存 `mcp_servers` ブロックが保持されるように修正。テーブル全体の置換からサーバー ID ごとのマージに変更し、プロバイダー/共通設定の MCP 定義が競合時に優先 --- ## 新機能 ### 空状態ガイダンスの改善 プロバイダーリストが空の場合の初回利用体験を改善しました。 - 空状態ページにプロバイダーインポートの操作ガイドを表示 - Claude/Codex/Gemini アプリケーションに共通設定 Snippet のヒントを条件付きで表示(OpenCode/OpenClaw には非表示) --- ## 変更 ### プロキシテイクオーバーリストアフロー テイクオーバーのホットスイッチとプロバイダー同期ロジックをリファクタリングし、テイクオーバーライフサイクル全体で共通設定を保護します。 - テイクオーバーがアクティブな場合、プロバイダー同期がライブ設定ファイルへの直接書き込みではなくリストアバックアップを更新 - リストアスナップショットの保存前に共通設定を適用した実効プロバイダー設定を再構築し、ロールバックで実際のユーザー設定を復元 - 共通設定の使用が推測されるレガシープロバイダーに `commonConfigEnabled=true` を自動マーク ### Codex TOML 編集エンジン Codex `config.toml` の更新ロジックを共有のセクション対応 TOML ヘルパーにリファクタリングしました。 - Rust 側に新モジュール `codex_config.rs` を追加(`update_codex_toml_field` と `remove_codex_toml_base_url_if`) - フロントエンドにセクション対応ユーティリティ `getTomlSectionRange` / `getCodexProviderSectionName` を追加 - `proxy.rs` に散在していたインライン TOML 編集ロジックを新モジュールに委譲 ### 共通設定初期化ライフサイクル Snippet の抽出とマイグレーションをより堅牢にするため、起動シーケンスを再整理しました。 - 起動時にプロキシテイクオーバー状態を復元する前に、クリーンなライブファイルから共通設定 Snippet を自動抽出 - Snippet の `cleared` フラグを導入し、ユーザーが意図的にクリアしたかどうかを追跡 - 一回限りのレガシーマイグレーションフラグを永続化し、`commonConfigEnabled` のバックフィルの繰り返しを防止 --- ## バグ修正 ### 共通設定の消失 - プロキシテイクオーバー中に共通設定が消失する複数のシナリオを修正:同期によるライブファイルの上書き、ホットスイッチによる不完全なリストアスナップショット、プロバイダー切り替え時の設定変更の消失 ### Codex リストアスナップショットの保護 - プロバイダーホットスイッチ時に Codex テイクオーバーリストアバックアップが既存の `mcp_servers` ブロックを破棄する問題を修正。MCP バックアップ保持をテーブル全体の置換からサーバー ID ごとのマージに変更し、プロバイダー/共通設定の MCP 更新が競合時に優先され、バックアップのみのサーバーも保持 ### クリア済み Snippet の復活 - 起動時の自動抽出が、ユーザーが意図的にクリアした共通設定 Snippet を再作成する問題を修正 ### Codex `base_url` の配置エラー - Codex `base_url` の抽出と編集が正しい `[model_providers.]` セクションを対象にせず、ファイル末尾に追加されたり `mcp_servers.*.base_url` をプロバイダーエンドポイントと誤認する問題を修正 --- ## ダウンロードとインストール [Releases](https://github.com/farion1231/cc-switch/releases/latest) から適切なバージョンをダウンロードしてください。 ### システム要件 | システム | 最小バージョン | アーキテクチャ | | -------- | -------------------------------- | ----------------------------------- | | Windows | Windows 10 以降 | x64 | | macOS | macOS 10.15 (Catalina) 以降 | Intel (x64) / Apple Silicon (arm64) | | Linux | 下表参照 | x64 | ### Windows | ファイル | 説明 | | ------------------------------------------ | ---------------------------------------------------- | | `CC-Switch-v3.12.2-Windows.msi` | **推奨** - MSI インストーラー、自動更新対応 | | `CC-Switch-v3.12.2-Windows-Portable.zip` | ポータブル版、解凍して実行、レジストリ書き込みなし | ### macOS | ファイル | 説明 | | ---------------------------------- | ----------------------------------------------------------------- | | `CC-Switch-v3.12.2-macOS.zip` | **推奨** - 解凍して Applications にドラッグ、Universal Binary | | `CC-Switch-v3.12.2-macOS.tar.gz` | Homebrew インストールと自動更新用 | > **注意**: 作者が Apple Developer アカウントを持っていないため、初回起動時に「開発元を確認できません」という警告が表示される場合があります。一度閉じてから、「システム設定」→「プライバシーとセキュリティ」→「このまま開く」をクリックすると、その後は正常に開けます。 ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | ディストリビューション | 推奨形式 | インストール方法 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` または `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` または `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 実行権限を追加して直接実行、または AUR を使用 | | その他のディストリビューション / 不明 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.12.2-zh.md ================================================ # CC Switch v3.12.2 > 代理接管期间通用配置保护、Snippet 生命周期稳定性、Codex TOML Section 感知编辑 **[English →](v3.12.2-en.md) | [日本語版 →](v3.12.2-ja.md)** --- ## 概览 CC Switch v3.12.2 是一个以可靠性为核心的补丁版本,重点解决代理(Proxy)接管模式下通用配置(Common Config)丢失的问题,并改进了 Codex TOML 配置的编辑准确性。代理接管的热切换和供应商同步现在会更新恢复备份而非直接覆盖 live 文件;启动流程重新排序,确保先从干净的 live 文件提取 Snippet 再恢复接管状态;Codex 的 `base_url` 编辑重构为 Section 感知模式,不再错误追加到文件末尾。 **发布日期**:2026-03-12 **更新规模**:5 commits | 22 files changed | +1,716 / -288 lines --- ## 重点内容 - **首次使用引导优化**:供应商列表空状态显示详细的导入说明,Claude/Codex/Gemini 还会提示通用配置 Snippet 功能 - **代理接管恢复流程重构**:热切换和供应商同步现在刷新恢复备份,而非覆盖 live 配置文件,回滚时保留完整的用户配置 - **Snippet 生命周期稳定**:引入 `cleared` 标志防止已清除的 Snippet 被自动重新提取,启动顺序调整确保从干净状态提取 - **Codex TOML Section 感知编辑**:`base_url` 和 `model` 字段的读写现在定位到正确的 `[model_providers.]` Section - **Codex MCP 配置保护**:热切换供应商时保留恢复快照中已有的 `mcp_servers` 配置块,按 server id 合并而非整表替换,供应商/通用配置的 MCP 定义优先 --- ## 新功能 ### 空状态引导优化 改善首次使用体验,当供应商列表为空时显示详细的导入说明。 - 空状态页面展示导入供应商的操作指引 - 对 Claude/Codex/Gemini 应用有条件地显示通用配置 Snippet 提示(OpenCode/OpenClaw 不显示) --- ## 变更 ### 代理接管恢复流程 代理接管的热切换和供应商同步逻辑经过重构,确保通用配置在整个接管生命周期中得到保护。 - 接管活跃时,供应商同步更新恢复备份而非直接写入 live 配置文件 - 保存恢复快照前先应用通用配置,使回滚能还原真实的用户配置 - 遗留供应商中推断使用了通用配置的条目自动标记 `commonConfigEnabled=true` ### Codex TOML 编辑引擎 将 Codex `config.toml` 的更新逻辑重构到共享的 Section 感知 TOML 辅助函数上。 - Rust 端新增 `codex_config.rs` 模块,包含 `update_codex_toml_field` 和 `remove_codex_toml_base_url_if` - 前端新增 `getTomlSectionRange` / `getCodexProviderSectionName` 等 Section 感知工具函数 - `proxy.rs` 中散落的 TOML 内联编辑逻辑统一委托给新模块 ### 通用配置初始化生命周期 启动流程重新排序,通用配置 Snippet 的提取和迁移逻辑更加健壮。 - 启动时先从干净的 live 文件自动提取通用配置 Snippet,再恢复代理接管状态 - 引入 Snippet `cleared` 标志,追踪用户是否主动清除了某个 Snippet - 持久化一次性遗留迁移标志,避免重复执行旧版 `commonConfigEnabled` 回填 --- ## Bug 修复 ### 通用配置丢失 - 修复代理接管期间通用配置可能被丢弃的多种场景:同步覆盖 live 文件、热切换产生不完整的恢复快照、供应商切换丢失配置变更 ### Codex 恢复快照保护 - 修复 Codex 接管恢复备份在供应商热切换时丢弃已有 `mcp_servers` 配置块的问题;将 MCP 备份保留策略从整表替换改为按 server id 合并,供应商/通用配置的 MCP 定义在冲突时优先,备份中独有的服务器仍被保留 ### 已清除 Snippet 复活 - 修复启动时自动提取机制重新创建用户已主动清除的通用配置 Snippet 的问题 ### Codex `base_url` 位置错误 - 修复 Codex `base_url` 提取和编辑未定位到正确的 `[model_providers.]` Section,导致追加到文件末尾或误将 `mcp_servers.*.base_url` 识别为供应商端点的问题 --- ## 下载与安装 访问 [Releases](https://github.com/farion1231/cc-switch/releases/latest) 下载对应版本。 ### 系统要求 | 系统 | 最低版本 | 架构 | | ------- | ----------------------------- | ----------------------------------- | | Windows | Windows 10 及以上 | x64 | | macOS | macOS 10.15 (Catalina) 及以上 | Intel (x64) / Apple Silicon (arm64) | | Linux | 见下表 | x64 | ### Windows | 文件 | 说明 | | ------------------------------------------ | ----------------------------------- | | `CC-Switch-v3.12.2-Windows.msi` | **推荐** - MSI 安装包,支持自动更新 | | `CC-Switch-v3.12.2-Windows-Portable.zip` | 便携版,解压即用,不写入注册表 | ### macOS | 文件 | 说明 | | ---------------------------------- | --------------------------------------------------------- | | `CC-Switch-v3.12.2-macOS.zip` | **推荐** - 解压后拖入 Applications 即可,Universal Binary | | `CC-Switch-v3.12.2-macOS.tar.gz` | 用于 Homebrew 安装和自动更新 | > **注意**:由于作者没有苹果开发者账号,首次打开可能出现"未知开发者"警告,请先关闭,然后前往"系统设置" → "隐私与安全性" → 点击"仍要打开",之后便可以正常打开 ### Homebrew(macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | 发行版 | 推荐格式 | 安装方式 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` 或 `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` 或 `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 添加执行权限后直接运行,或使用 AUR | | 其他发行版 / 不确定 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.12.3-en.md ================================================ # CC Switch v3.12.3 > Tool Search Domain Bypass, Skill Backup/Restore Lifecycle, Proxy Gzip & o-Series Compatibility **[中文版 →](v3.12.3-zh.md) | [日本語版 →](v3.12.3-ja.md)** --- ## Overview CC Switch v3.12.3 adds a Tool Search domain restriction bypass via binary patching, introduces a full skill backup/restore lifecycle, improves proxy compatibility for OpenAI o-series models and gzip compression, and delivers robustness fixes for Skills import, provider forms, and terminal session restore. Skills are now automatically backed up before uninstall with restore and delete management, and the import flow has been reworked from implicit filesystem inference to explicit app selection. **Release Date**: 2026-03-16 **Update Scale**: 17 commits | 61 files changed | +3,335 / -194 lines --- ## Highlights - **Tool Search domain bypass**: New setting to remove Claude CLI Tool Search domain whitelist via equal-length binary patching, with automatic backup and reapply on startup - **Skill backup/restore lifecycle**: Skills are automatically backed up before uninstall; backup list with restore and delete management added - **Proxy gzip compression**: Non-streaming proxy requests now auto-negotiate gzip compression, reducing bandwidth usage - **o-series model compatibility**: Chat Completions proxy correctly uses `max_completion_tokens` for o1/o3/o4-mini models; Responses API kept on the correct `max_output_tokens` field - **Skills import rework**: Replaced implicit filesystem-based app inference with explicit `ImportSkillSelection` to prevent incorrect multi-app activation - **Ghostty terminal support**: Fixed Claude session restore in Ghostty terminal --- ## New Features ### Tool Search Domain Bypass Added a setting to bypass Claude CLI Tool Search domain whitelist restrictions. - Resolves the active `claude` command from PATH and applies an equal-length byte patch to remove the domain whitelist check - Backups stored in `~/.cc-switch/toolsearch-backups/` (SHA-256 of path) so they survive Claude Code version upgrades - The patch auto-reapplies on app startup when the setting is enabled - Frontend checks patch result and rolls back the setting on failure ### Skill Auto-Backup on Uninstall Skill files are now automatically backed up before uninstall to prevent accidental data loss. - Backups stored in `~/.cc-switch/skill-backups/` with all skill files and a `meta.json` containing original metadata - Old backups are automatically pruned to keep at most 20 - Backup path is returned to the frontend and shown in the success toast ### Skill Backup Restore & Delete Added management commands for skill backups created during uninstall. - List all available skill backups with metadata - Restore copies files back to SSOT, saves the DB record, and syncs to the current app with rollback on failure - Delete removes the backup directory after a confirmation dialog - ConfirmDialog gains a configurable zIndex prop to support nested dialog stacking --- ## Changes ### Proxy Gzip Compression Non-streaming proxy requests now support gzip compression for reduced bandwidth usage. - Non-streaming requests let reqwest auto-negotiate gzip and transparently decompress responses - Streaming requests conservatively keep `Accept-Encoding: identity` to avoid decompression errors on interrupted SSE streams ### o1/o3 Model Compatibility Proxy forwarding now handles OpenAI o-series model token parameters correctly. - Chat Completions path uses `max_completion_tokens` instead of `max_tokens` for o1/o3/o4-mini models (#1451) - Responses API path kept on the correct `max_output_tokens` field instead of incorrectly injecting `max_completion_tokens` ### OpenCode Model Variants - Placed OpenCode model variants at top level instead of inside options for better discoverability (#1317) ### Skills Import Flow The Skills import flow has been reworked for correctness and cleanup. - Replaced implicit filesystem-based app inference with explicit `ImportSkillSelection` to prevent incorrect multi-app activation when the same skill directory exists under multiple app paths - Added reconciliation to `sync_to_app` to remove disabled/orphaned symlinks - MCP `sync_all_enabled` now removes disabled servers from live config - Schema migration preserves a snapshot of legacy app mappings to avoid lossy reconstruction --- ## Bug Fixes ### Provider Form Double Submit - Prevented duplicate submissions on rapid button clicks in provider add/edit forms (#1352) ### Ghostty Session Restore - Fixed Claude session restore in Ghostty terminal (#1506, thanks @canyonsehun) ### Skill ZIP Import Extension - Added `.skill` file extension support in ZIP import dialog (#1240, #1455) ### Skill ZIP Install Target App - ZIP skill installs now use the currently active app instead of always defaulting to Claude ### OpenClaw Active Card Highlight - Fixed active OpenClaw provider card not being highlighted (#1419) ### Responsive Layout with TOC - Improved responsive design when TOC title exists (#1491) ### Import Skills Dialog White Screen - Added missing TooltipProvider in ImportSkillsDialog to prevent runtime crash when opening the dialog ### Panel Bottom Blank Area - Replaced hardcoded `h-[calc(100vh-8rem)]` with `flex-1 min-h-0` across all content panels to eliminate bottom gap caused by mismatched offset values on different platforms --- ## Download & Installation Visit [Releases](https://github.com/farion1231/cc-switch/releases/latest) to download the appropriate version. ### System Requirements | System | Minimum Version | Architecture | | ------- | ------------------------------- | ----------------------------------- | | Windows | Windows 10 or later | x64 | | macOS | macOS 12 (Monterey) or later | Intel (x64) / Apple Silicon (arm64) | | Linux | See table below | x64 | ### Windows | File | Description | | ------------------------------------------ | ---------------------------------------------------- | | `CC-Switch-v3.12.3-Windows.msi` | **Recommended** - MSI installer with auto-update | | `CC-Switch-v3.12.3-Windows-Portable.zip` | Portable version, extract and run, no registry write | ### macOS | File | Description | | ---------------------------------- | -------------------------------------------------------------------- | | `CC-Switch-v3.12.3-macOS.zip` | **Recommended** - Extract and drag to Applications, Universal Binary | | `CC-Switch-v3.12.3-macOS.tar.gz` | For Homebrew installation and auto-update | > **Note**: Since the author doesn't have an Apple Developer account, you may see an "unidentified developer" warning on first launch. Please close it, then go to "System Settings" -> "Privacy & Security" -> click "Open Anyway", and it will open normally afterwards. ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` Update: ```bash brew upgrade --cask cc-switch ``` ### Linux | Distribution | Recommended Format | Installation Method | | --------------------------------------- | ------------------ | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` or `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` or `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | Add execute permission and run directly, or use AUR | | Other distributions / Unsure | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.12.3-ja.md ================================================ # CC Switch v3.12.3 > Tool Search ドメイン制限バイパス、Skill バックアップ/リストアライフサイクル、プロキシ Gzip 圧縮と o シリーズモデル互換性 **[中文版 →](v3.12.3-zh.md) | [English →](v3.12.3-en.md)** --- ## 概要 CC Switch v3.12.3 は、バイナリパッチによる Tool Search ドメインホワイトリスト制限のバイパス機能を追加し、完全な Skill バックアップ/リストアライフサイクルを導入し、OpenAI o シリーズモデルのプロキシ互換性と gzip 圧縮を改善し、Skills インポート、プロバイダーフォーム、ターミナルセッション復元の堅牢性を修正しました。Skill はアンインストール前に自動バックアップされ、リストアと削除の管理機能が追加されました。インポートフローはファイルシステムベースの暗黙的な推論から明示的なアプリ選択に変更されました。 **リリース日**: 2026-03-16 **更新規模**: 17 commits | 61 files changed | +3,335 / -194 lines --- ## ハイライト - **Tool Search ドメインバイパス**: 等長バイナリパッチで Claude CLI Tool Search のドメインホワイトリストチェックを削除する新設定。起動時に自動バックアップと再適用 - **Skill バックアップ/リストアライフサイクル**: アンインストール前に Skill ファイルを自動バックアップ。バックアップリスト、リストア、削除の管理機能を追加 - **プロキシ Gzip 圧縮**: 非ストリーミングプロキシリクエストが gzip 圧縮を自動ネゴシエーションし、帯域幅消費を削減 - **o シリーズモデル互換性**: Chat Completions プロキシが o1/o3/o4-mini モデルに `max_completion_tokens` を正しく使用。Responses API は正しい `max_output_tokens` フィールドを維持 - **Skills インポートの刷新**: ファイルシステムベースの暗黙的なアプリ推論を明示的な `ImportSkillSelection` に置き換え、複数アプリの誤った有効化を防止 - **Ghostty ターミナルサポート**: Ghostty ターミナルでの Claude セッション復元を修正 --- ## 新機能 ### Tool Search ドメイン制限バイパス Claude CLI Tool Search のドメインホワイトリスト制限をバイパスする設定を追加しました。 - PATH からアクティブな `claude` コマンドを解決し、等長バイトパッチを適用してドメインホワイトリストチェックを削除 - バックアップは `~/.cc-switch/toolsearch-backups/`(パスの SHA-256)に保存され、Claude Code のバージョンアップグレード後も有効 - 設定が有効な場合、アプリ起動時にパッチを自動的に再適用 - フロントエンドがパッチ結果を確認し、失敗時に設定を自動ロールバック ### Skill アンインストール時の自動バックアップ アンインストール前に Skill ファイルを自動バックアップし、意図しないデータ損失を防止します。 - バックアップは `~/.cc-switch/skill-backups/` に保存され、すべての skill ファイルと元のメタデータを含む `meta.json` が含まれます - 古いバックアップは自動的にプルーニングされ、最大 20 個を保持 - バックアップパスはフロントエンドに返され、成功トーストに表示 ### Skill バックアップのリストアと削除 アンインストール時に作成された Skill バックアップの管理コマンドを追加しました。 - すべての利用可能な skill バックアップをメタデータ付きで一覧表示 - リストアはファイルを SSOT にコピーし、DB レコードを保存し、現在のアプリに同期。失敗時は自動ロールバック - 削除は確認ダイアログの後にバックアップディレクトリを削除 - ConfirmDialog にネストされたダイアログスタッキングをサポートする設定可能な zIndex プロパティを追加 --- ## 変更 ### プロキシ Gzip 圧縮 非ストリーミングプロキシリクエストが gzip 圧縮をサポートし、帯域幅消費を削減しました。 - 非ストリーミングリクエストは reqwest が gzip を自動ネゴシエーションし、レスポンスを透過的に解凍 - ストリーミングリクエストは中断された SSE ストリームの解凍エラーを避けるため、保守的に `Accept-Encoding: identity` を維持 ### o1/o3 モデル互換性 プロキシ転送が OpenAI o シリーズモデルのトークンパラメータを正しく処理するようになりました。 - Chat Completions パスが o1/o3/o4-mini モデルに `max_tokens` の代わりに `max_completion_tokens` を使用 (#1451) - Responses API パスが正しい `max_output_tokens` フィールドを維持し、`max_completion_tokens` の誤った注入を防止 ### OpenCode モデルバリアント - OpenCode のモデルバリアントを options 内部ではなくプリセットのトップレベルに配置し、発見しやすさを向上 (#1317) ### Skills インポートフロー Skills インポートフローが正確性とクリーンアップのためにリワークされました。 - ファイルシステムベースの暗黙的なアプリ推論を明示的な `ImportSkillSelection` に置き換え、同じ skill ディレクトリが複数アプリパスに存在する場合の複数アプリ誤有効化を防止 - `sync_to_app` に調整ロジックを追加し、無効化/孤立したシンボリックリンクを削除 - MCP `sync_all_enabled` がライブ設定から無効化されたサーバーを削除するように改善 - スキーママイグレーションがレガシーアプリマッピングのスナップショットを保持し、損失のある再構築を回避 --- ## バグ修正 ### プロバイダーフォームの二重送信 - プロバイダー追加/編集フォームでの高速連続クリックによる重複送信を防止 (#1352) ### Ghostty ターミナルセッション復元 - Ghostty ターミナルでの Claude セッション復元の失敗を修正 (#1506、@canyonsehun に感謝) ### Skill ZIP インポート拡張子 - ZIP インポートダイアログが `.skill` ファイル拡張子をサポートするように修正 (#1240, #1455) ### Skill ZIP インストール対象アプリ - ZIP 方式でインストールされた skill が常に Claude をデフォルトにするのではなく、現在アクティブなアプリを使用するように修正 ### OpenClaw アクティブカードのハイライト - OpenClaw の現在アクティブなプロバイダーカードがハイライト表示されない問題を修正 (#1419) ### TOC 付きレスポンシブレイアウト - TOC タイトルが存在する場合のレスポンシブデザインを改善 (#1491) ### Skills インポートダイアログの白い画面 - ImportSkillsDialog に不足していた TooltipProvider を追加し、ダイアログを開く際のランタイムクラッシュを防止 ### パネル下部の空白エリア - すべてのコンテンツパネルのハードコードされた `h-[calc(100vh-8rem)]` を `flex-1 min-h-0` に置き換え、異なるプラットフォーム間のオフセット値の不一致による下部のギャップを解消 --- ## ダウンロードとインストール [Releases](https://github.com/farion1231/cc-switch/releases/latest) から適切なバージョンをダウンロードしてください。 ### システム要件 | システム | 最小バージョン | アーキテクチャ | | -------- | -------------------------------- | ----------------------------------- | | Windows | Windows 10 以降 | x64 | | macOS | macOS 12 (Monterey) 以降 | Intel (x64) / Apple Silicon (arm64) | | Linux | 下表参照 | x64 | ### Windows | ファイル | 説明 | | ------------------------------------------ | ---------------------------------------------------- | | `CC-Switch-v3.12.3-Windows.msi` | **推奨** - MSI インストーラー、自動更新対応 | | `CC-Switch-v3.12.3-Windows-Portable.zip` | ポータブル版、解凍して実行、レジストリ書き込みなし | ### macOS | ファイル | 説明 | | ---------------------------------- | ----------------------------------------------------------------- | | `CC-Switch-v3.12.3-macOS.zip` | **推奨** - 解凍して Applications にドラッグ、Universal Binary | | `CC-Switch-v3.12.3-macOS.tar.gz` | Homebrew インストールと自動更新用 | > **注意**: 作者が Apple Developer アカウントを持っていないため、初回起動時に「開発元を確認できません」という警告が表示される場合があります。一度閉じてから、「システム設定」→「プライバシーとセキュリティ」→「このまま開く」をクリックすると、その後は正常に開けます。 ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | ディストリビューション | 推奨形式 | インストール方法 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` または `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` または `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 実行権限を追加して直接実行、または AUR を使用 | | その他のディストリビューション / 不明 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.12.3-zh.md ================================================ # CC Switch v3.12.3 > Tool Search 域名限制绕过、Skill 备份/恢复生命周期、代理 Gzip 压缩与 o 系列模型兼容性 **[English →](v3.12.3-en.md) | [日本語版 →](v3.12.3-ja.md)** --- ## 概览 CC Switch v3.12.3 新增了通过二进制补丁绕过 Tool Search 域名白名单限制的功能,引入了完整的 Skill 备份/恢复生命周期,改进了代理对 OpenAI o 系列模型的兼容性和 gzip 压缩支持,并修复了 Skills 导入、供应商表单和终端会话恢复等方面的问题。Skill 卸载前会自动备份并支持恢复和删除管理,导入流程从基于文件系统的隐式推断改为显式应用选择。 **发布日期**:2026-03-16 **更新规模**:17 commits | 61 files changed | +3,335 / -194 lines --- ## 重点内容 - **Tool Search 域名绕过**:新增设置项,通过等长二进制补丁移除 Claude CLI Tool Search 域名白名单检查,启动时自动备份和重新应用 - **Skill 备份/恢复生命周期**:卸载前自动备份 Skill 文件;新增备份列表、恢复和删除管理 - **代理 Gzip 压缩**:非流式代理请求现在自动协商 gzip 压缩,减少带宽消耗 - **o 系列模型兼容性**:Chat Completions 代理正确使用 `max_completion_tokens` 处理 o1/o3/o4-mini 模型;Responses API 保持使用正确的 `max_output_tokens` 字段 - **Skills 导入重构**:将基于文件系统的隐式应用推断替换为显式的 `ImportSkillSelection`,防止多应用错误激活 - **Ghostty 终端支持**:修复在 Ghostty 终端中恢复 Claude 会话的问题 --- ## 新功能 ### Tool Search 域名限制绕过 新增设置项,可绕过 Claude CLI Tool Search 的域名白名单限制。 - 从 PATH 中解析当前活跃的 `claude` 命令,应用等长字节补丁移除域名白名单检查 - 备份存储在 `~/.cc-switch/toolsearch-backups/`(以路径的 SHA-256 为文件名),Claude Code 升级后备份仍然有效 - 设置启用时,应用启动自动重新应用补丁 - 前端检查补丁结果,失败时自动回滚设置 ### Skill 卸载自动备份 卸载 Skill 前自动备份文件,防止数据意外丢失。 - 备份存储在 `~/.cc-switch/skill-backups/`,包含所有 skill 文件和记录原始元数据的 `meta.json` - 旧备份自动清理,最多保留 20 个 - 备份路径返回前端并在成功提示中显示 ### Skill 备份恢复与删除 新增卸载时创建的 Skill 备份的管理功能。 - 列出所有可用的 skill 备份及元数据 - 恢复操作将文件拷回 SSOT,保存数据库记录,并同步到当前应用,失败时自动回滚 - 删除操作在确认对话框后移除备份目录 - ConfirmDialog 新增可配置的 zIndex 属性,支持嵌套对话框堆叠 --- ## 变更 ### 代理 Gzip 压缩 非流式代理请求现在支持 gzip 压缩,减少带宽消耗。 - 非流式请求允许 reqwest 自动协商 gzip 并透明解压响应 - 流式请求保守地保持 `Accept-Encoding: identity`,避免中断的 SSE 流解压出错 ### o1/o3 模型兼容性 代理转发现在正确处理 OpenAI o 系列模型的 token 参数。 - Chat Completions 路径对 o1/o3/o4-mini 模型使用 `max_completion_tokens` 替代 `max_tokens` (#1451) - Responses API 路径保持使用正确的 `max_output_tokens` 字段,不再错误注入 `max_completion_tokens` ### OpenCode 模型变体 - 将 OpenCode 的模型变体放在预设顶层而非嵌套在 options 内部,提升可发现性 (#1317) ### Skills 导入流程 Skills 导入流程经过重构,提升正确性和清理能力。 - 将基于文件系统的隐式应用推断替换为显式的 `ImportSkillSelection`,防止同一 skill 目录存在于多个应用路径下时错误激活多个应用 - 为 `sync_to_app` 增加协调逻辑,移除已禁用/孤立的符号链接 - MCP `sync_all_enabled` 现在会从 live 配置中移除已禁用的服务器 - 数据库迁移保留旧版应用映射快照,避免有损重建 --- ## Bug 修复 ### 供应商表单防重复提交 - 修复快速连续点击按钮时供应商添加/编辑表单重复提交的问题 (#1352) ### Ghostty 终端会话恢复 - 修复在 Ghostty 终端中恢复 Claude 会话失败的问题 (#1506,感谢 @canyonsehun) ### Skill ZIP 导入扩展名 - ZIP 导入对话框现在支持 `.skill` 文件扩展名 (#1240, #1455) ### Skill ZIP 安装目标应用 - ZIP 方式安装的 skill 现在使用当前活跃应用,而非始终默认为 Claude ### OpenClaw 活跃供应商高亮 - 修复 OpenClaw 当前激活的供应商卡片未高亮显示的问题 (#1419) ### 响应式布局与 TOC - 改善存在 TOC 标题时的响应式布局 (#1491) ### Skills 导入对话框白屏 - 在 ImportSkillsDialog 中补充缺失的 TooltipProvider,修复打开对话框时的运行时崩溃 ### 面板底部空白区域 - 将所有内容面板的硬编码 `h-[calc(100vh-8rem)]` 替换为 `flex-1 min-h-0`,消除因不同平台偏移量不匹配导致的底部空白 --- ## 下载与安装 访问 [Releases](https://github.com/farion1231/cc-switch/releases/latest) 下载对应版本。 ### 系统要求 | 系统 | 最低版本 | 架构 | | ------- | ----------------------------- | ----------------------------------- | | Windows | Windows 10 及以上 | x64 | | macOS | macOS 12 (Monterey) 及以上 | Intel (x64) / Apple Silicon (arm64) | | Linux | 见下表 | x64 | ### Windows | 文件 | 说明 | | ------------------------------------------ | ----------------------------------- | | `CC-Switch-v3.12.3-Windows.msi` | **推荐** - MSI 安装包,支持自动更新 | | `CC-Switch-v3.12.3-Windows-Portable.zip` | 便携版,解压即用,不写入注册表 | ### macOS | 文件 | 说明 | | ---------------------------------- | --------------------------------------------------------- | | `CC-Switch-v3.12.3-macOS.zip` | **推荐** - 解压后拖入 Applications 即可,Universal Binary | | `CC-Switch-v3.12.3-macOS.tar.gz` | 用于 Homebrew 安装和自动更新 | > **注意**:由于作者没有苹果开发者账号,首次打开可能出现"未知开发者"警告,请先关闭,然后前往"系统设置" → "隐私与安全性" → 点击"仍要打开",之后便可以正常打开 ### Homebrew(macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | 发行版 | 推荐格式 | 安装方式 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` 或 `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` 或 `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 添加执行权限后直接运行,或使用 AUR | | 其他发行版 / 不确定 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | ================================================ FILE: docs/release-notes/v3.6.0-en.md ================================================ ## Major architecture refactoring with enhanced config sync and data protection **[中文更新说明 Chinese Documentation →](https://github.com/farion1231/cc-switch/blob/main/docs/release-notes/v3.6.0-zh.md)** --- ## What's New ### Edit Mode & Provider Management - **Provider Duplication** - Quickly duplicate existing provider configurations to create variants with one click - **Manual Sorting** - Drag and drop to reorder providers, with visual push effect animations. Thanks to @ZyphrZero - **Edit Mode Toggle** - Show/hide drag handles to optimize editing experience ### Custom Endpoint Management - **Multi-Endpoint Configuration** - Support for aggregator providers with multiple API endpoints - **Endpoint Input Visibility** - Shows endpoint field for all non-official providers automatically ### Usage Query Enhancements - **Auto-Refresh Interval** - Configure periodic automatic usage queries with customizable intervals - **Test Script API** - Validate JavaScript usage query scripts before execution - **Enhanced Templates** - Custom blank templates with access token and user ID parameter support Thanks to @Sirhexs ### Custom Configuration Directory (Cloud Sync) - **Customizable Storage Location** - Customize CC Switch's configuration storage directory - **Cloud Sync Support** - Point to cloud sync folders (Dropbox, OneDrive, iCloud Drive, etc.) to enable automatic config synchronization across devices - **Independent Management** - Managed via Tauri Store for better isolation and reliability Thanks to @ZyphrZero ### Configuration Directory Switching (WSL Support) - **Auto-Sync on Directory Change** - When switching Claude/Codex config directories (e.g., WSL environment), automatically sync current provider to the new directory without manual operation - **Post-Change Sync Utility** - Unified `postChangeSync.ts` utility for graceful error handling without blocking main flow - **Import Config Auto-Sync** - Automatically sync after config import to ensure immediate effectiveness - **Smart Conflict Resolution** - Distinguishes "fully successful" and "partially successful" states for precise user feedback ### Configuration Editor Improvements - **JSON Format Button** - One-click JSON formatting in configuration editors - **Real-Time TOML Validation** - Live syntax validation for Codex configuration with error highlighting ### Load Live Config When Editing - **Protect Manual Modifications** - When editing the currently active provider, prioritize displaying the actual effective configuration from live files - **Dual-Source Strategy** - Automatically loads from live config for active provider, SSOT for inactive ones ### Claude Configuration Data Structure Enhancements - **Granular Model Configuration** - Migrated from dual-key to quad-key system for better model tier differentiation - New fields: `ANTHROPIC_DEFAULT_HAIKU_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_MODEL` - Replaces legacy `ANTHROPIC_SMALL_FAST_MODEL` with automatic migration - Backend normalizes old configs on first read/write with smart fallback chain - UI expanded from 2 to 4 model input fields with intelligent defaults - **ANTHROPIC_API_KEY Support** - Providers can now use `ANTHROPIC_API_KEY` field in addition to `ANTHROPIC_AUTH_TOKEN` - **Template Variable System** - Support for dynamic configuration replacement (e.g., KAT-Coder's `ENDPOINT_ID` parameter) - **Endpoint Candidates** - Predefined endpoint list for speed testing and endpoint management - **Visual Theme Configuration** - Custom icons and colors for provider cards ### Updated Provider Models - **Kimi k2** - Updated to latest `kimi-k2-thinking` model ### New Provider Presets Added 5 new provider presets: - **DMXAPI** - Multi-model aggregation service - **Azure Codex** - Microsoft Azure OpenAI endpoint - **AnyRouter** - None-profit routing service - **AiHubMix** - Multi-model aggregation service - **MiniMax** - Open source AI model provider ### Partner Promotion Mechanism - Support for ecosystem partner promotion (Zhipu GLM Z.ai) - Sponsored banner integration in README --- ## Improvements ### Configuration & Sync - **Unified Error Handling** - AppError with internationalized error messages throughout backend - **Fixed apiKeyUrl Priority** - Correct priority order for API key URL resolution - **Fixed MCP Sync Issues** - Resolved sync-to-other-side functionality failures - **Import Config Sync** - Fixed sync issues after configuration import - **Config Error Handling** - Force exit on config error to prevent silent fallback and data loss ### UI/UX Enhancements - **Unique Provider Icons** - Each provider card now has unique icons and color identification - **Unified Border System** - Consistent border design across all components - **Drag Interaction** - Push effect animation and improved drag handle icons - **Enhanced Visual Feedback** - Better current provider visual indication - **Dialog Standardization** - Unified dialog sizes and layout consistency - **Form Improvements** - Optimized model placeholders, simplified provider hints, category-specific hints - **Usage Display Inline** - Usage info moved next to enable button for better space utilization ### Complete Internationalization - **Error Messages i18n** - All backend error messages support Chinese/English - **Tray Menu i18n** - System tray menu fully internationalized - **UI Components i18n** - 100% coverage across all user-facing components --- ## Bug Fixes ### Configuration Management - Fixed `apiKeyUrl` priority issue - Fixed MCP sync-to-other-side functionality failure - Fixed sync issues after config import - Fixed Codex API Key auto-sync - Fixed endpoint speed test functionality - Fixed provider duplicate insertion position (now inserts next to original) - Fixed custom endpoint preservation in edit mode - Prevent silent fallback and data loss on config error ### Usage Query - Fixed auto-query interval timing issue - Ensured refresh button shows loading animation on click ### UI Issues - Fixed name collision error (`get_init_error` command) - Fixed language setting rollback after successful save - Fixed language switch state reset (dependency cycle) - Fixed edit mode button alignment ### Startup Issues - Force exit on config error (no silent fallback) - Eliminated code duplication causing initialization errors --- ## Architecture Refactoring ### Backend (Rust) - 5 Phase Refactoring 1. **Phase 1**: Unified error handling (`AppError` + i18n error messages) 2. **Phase 2**: Command layer split by domain (`commands/{provider,mcp,config,settings,plugin,misc}.rs`) 3. **Phase 3**: Integration tests and transaction mechanism (config snapshot + failure rollback) 4. **Phase 4**: Extracted Service layer (`services/{provider,mcp,config,speedtest}.rs`) 5. **Phase 5**: Concurrency optimization (`RwLock` instead of `Mutex`, scoped guard to avoid deadlock) ### Frontend (React + TypeScript) - 4 Stage Refactoring 1. **Stage 1**: Test infrastructure (vitest + MSW + @testing-library/react) 2. **Stage 2**: Extracted custom hooks (`useProviderActions`, `useMcpActions`, `useSettings`, `useImportExport`, etc.) 3. **Stage 3**: Component splitting and business logic extraction 4. **Stage 4**: Code cleanup and formatting unification ### Testing System - **Hooks Unit Tests** - 100% coverage for all custom hooks - **Integration Tests** - Coverage for key processes (App, SettingsDialog, MCP Panel) - **MSW Mocking** - Backend API mocking to ensure test independence - **Test Infrastructure** - vitest + MSW + @testing-library/react ### Code Quality - **Unified Parameter Format** - All Tauri commands migrated to camelCase (Tauri 2 specification) - **Semantic Clarity** - `AppType` renamed to `AppId` for better semantics - **Centralized Parsing** - Unified `app` parameter parsing with `FromStr` trait - **DRY Violations Cleanup** - Eliminated code duplication throughout codebase - **Dead Code Removal** - Removed unused `missing_param` helper, deprecated `tauri-api.ts`, redundant `KimiModelSelector` --- ## Internal Optimizations (User Transparent) ### Removed Legacy Migration Logic v3.6.0 removed v1 config auto-migration and copy file scanning logic: - **Impact**: Improved startup performance, cleaner codebase - **Compatibility**: v2 format configs fully compatible, no action required - **Note**: Users upgrading from v3.1.0 or earlier should first upgrade to v3.2.x or v3.5.x for one-time migration, then upgrade to v3.6.0 ### Command Parameter Standardization Backend unified to use `app` parameter (values: `claude` or `codex`): - **Impact**: More standardized code, friendlier error prompts - **Compatibility**: Frontend fully adapted, users don't need to care about this change --- ## Dependencies - Updated to **Tauri 2.8.x** - Updated to **TailwindCSS 4.x** - Updated to **TanStack Query v5.90.x** - Maintained **React 18.2.x** and **TypeScript 5.3.x** --- ## Installation ### macOS **Via Homebrew (Recommended):** ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` **Manual Download:** - Download `CC-Switch-v3.6.0-macOS.zip` from [Assets](#assets) below > **Note**: Due to lack of Apple Developer account, you may see "unidentified developer" warning. Go to System Settings → Privacy & Security → Click "Open Anyway" ### Windows - **Installer**: `CC-Switch-v3.6.0-Windows.msi` - **Portable**: `CC-Switch-v3.6.0-Windows-Portable.zip` ### Linux - **AppImage**: `CC-Switch-v3.6.0-Linux.AppImage` - **Debian**: `CC-Switch-v3.6.0-Linux.deb` --- ## Documentation - [中文文档 (Chinese)](https://github.com/farion1231/cc-switch/blob/main/README_ZH.md) - [English Documentation](https://github.com/farion1231/cc-switch/blob/main/README.md) - [完整更新日志 (Full Changelog)](https://github.com/farion1231/cc-switch/blob/main/CHANGELOG.md) --- ## Acknowledgments Special thanks to **Zhipu AI** for sponsoring this project with their GLM CODING PLAN! --- **Full Changelog**: https://github.com/farion1231/cc-switch/compare/v3.5.1...v3.6.0 ================================================ FILE: docs/release-notes/v3.6.0-zh.md ================================================ # CC Switch v3.6.0 > 全栈架构重构,增强配置同步与数据保护 **[English Version →](v3.6.0-en.md)** --- ## 新增功能 ### 编辑模式与供应商管理 - **供应商复制功能** - 一键快速复制现有供应商配置,轻松创建变体配置 - **手动排序功能** - 通过拖拽对供应商进行重新排序,带有视觉推送效果动画 - **编辑模式切换** - 显示/隐藏拖拽手柄,优化编辑体验 ### 自定义端点管理 - **多端点配置** - 支持聚合类供应商的多 API 端点配置 - **端点输入可见性** - 为所有非官方供应商自动显示端点字段 ### 自定义配置目录(云同步) - **自定义存储位置** - 自定义 CC Switch 的配置存储目录 - **云同步支持** - 指定到云同步文件夹(Dropbox、OneDrive、iCloud Drive、坚果云等)即可实现跨设备配置自动同步 - **独立管理** - 通过 Tauri Store 管理,更好的隔离性和可靠性 ### 使用量查询增强 - **自动刷新间隔** - 配置定时自动使用量查询,支持自定义间隔时间 - **测试脚本 API** - 在执行前验证 JavaScript 使用量查询脚本 - **增强模板系统** - 自定义空白模板,支持 access token 和 user ID 参数 ### 配置目录切换(WSL 支持) - **目录变更自动同步** - 切换 Claude/Codex 配置目录(如 WSL 环境)时,自动同步当前供应商到新目录,无需手动操作 - **后置同步工具** - 统一的 `postChangeSync.ts` 工具,优雅处理错误而不阻塞主流程 - **导入配置自动同步** - 配置导入后自动同步,确保立即生效 - **智能冲突解决** - 区分"完全成功"和"部分成功"状态,提供精确的用户反馈 ### 配置编辑器改进 - **JSON 格式化按钮** - 配置编辑器中一键 JSON 格式化 - **实时 TOML 验证** - Codex 配置的实时语法验证,带有错误高亮 ### 编辑时加载 Live 配置 - **保护手动修改** - 编辑当前激活的供应商时,优先显示来自 live 文件的实际生效配置 - **双源策略** - 活动供应商自动从 live 配置加载,非活动供应商从 SSOT 加载 ### Claude 配置数据结构增强 - **细粒度模型配置** - 从双键系统升级到四键系统,以匹配官方最新数据结构 - 新增字段:`ANTHROPIC_DEFAULT_HAIKU_MODEL`、`ANTHROPIC_DEFAULT_SONNET_MODEL`、`ANTHROPIC_DEFAULT_OPUS_MODEL`、`ANTHROPIC_MODEL` - 替换旧版 `ANTHROPIC_SMALL_FAST_MODEL`,支持自动迁移 - 后端在首次读写时自动规范化旧配置,带有智能回退链 - UI 从 2 个模型输入字段扩展到 4 个,具有智能默认值 - **ANTHROPIC_API_KEY 支持** - 供应商现可使用 `ANTHROPIC_API_KEY` 字段(除 `ANTHROPIC_AUTH_TOKEN` 外) - **模板变量系统** - 支持动态配置替换(如 KAT-Coder 的 `ENDPOINT_ID` 参数) - **端点候选列表** - 预定义端点列表,用于速度测试和端点管理 - **视觉主题配置** - 供应商卡片自定义图标和颜色 ### 供应商模型更新 - **Kimi k2** - 更新到最新的 `kimi-k2-thinking` 模型 ### 新增供应商预设 新增 5 个供应商预设: - **DMXAPI** - 多模型聚合服务 - **Azure Codex** - 微软 Azure OpenAI 端点 - **AnyRouter** - API 路由服务 - **AiHubMix** - AI 模型集合 - **MiniMax** - 国产 AI 模型提供商 ### 合作伙伴推广机制 - 支持生态合作伙伴推广(智谱 GLM Z.ai) - README 中集成赞助商横幅 --- ## 改进优化 ### 配置与同步 - **统一错误处理** - 后端全面使用 AppError 与国际化错误消息 - **修复 apiKeyUrl 优先级** - 修正 API key URL 解析的优先级顺序 - **修复 MCP 同步问题** - 解决同步到另一端功能失效的问题 - **导入配置同步** - 修复配置导入后的同步问题 - **配置错误处理** - 配置错误时强制退出,防止静默回退和数据丢失 ### UI/UX 增强 - **独特的供应商图标** - 每个供应商卡片现在都有独特的图标和颜色识别 - **统一边框系统** - 所有组件采用一致的边框设计 - **拖拽交互** - 推送效果动画和改进的拖拽手柄图标 - **增强视觉反馈** - 更好的当前供应商视觉指示 - **对话框标准化** - 统一的对话框尺寸和布局一致性 - **表单改进** - 优化模型占位符,简化供应商提示,分类特定提示 - **使用量内联显示** - 使用量信息移至启用按钮旁边,更好地利用空间 ### 完整国际化 - **错误消息国际化** - 所有后端错误消息支持中英文 - **托盘菜单国际化** - 系统托盘菜单完全国际化 - **UI 组件国际化** - 所有面向用户的组件 100% 覆盖 --- ## Bug 修复 ### 配置管理 - 修复 `apiKeyUrl` 优先级问题 - 修复 MCP 同步到另一端功能失效 - 修复配置导入后的同步问题 - 修复 Codex API Key 自动同步 - 修复端点速度测试功能 - 修复供应商复制插入位置(现在插入到原供应商旁边) - 修复编辑模式下自定义端点保留问题 - 防止配置错误时的静默回退和数据丢失 ### 使用量查询 - 修复自动查询间隔时间问题 - 确保刷新按钮点击时显示加载动画 ### UI 问题 - 修复名称冲突错误(`get_init_error` 命令) - 修复保存成功后语言设置回滚 - 修复语言切换状态重置(依赖循环) - 修复编辑模式按钮对齐 ### 启动问题 - 配置错误时强制退出(不再静默回退) - 消除导致初始化错误的代码重复 --- ## 架构重构 ### 后端(Rust)- 5 阶段重构 1. **阶段 1**:统一错误处理(`AppError` + 国际化错误消息) 2. **阶段 2**:命令层按领域拆分(`commands/{provider,mcp,config,settings,plugin,misc}.rs`) 3. **阶段 3**:集成测试和事务机制(配置快照 + 失败回滚) 4. **阶段 4**:提取 Service 层(`services/{provider,mcp,config,speedtest}.rs`) 5. **阶段 5**:并发优化(`RwLock` 替代 `Mutex`,作用域 guard 避免死锁) ### 前端(React + TypeScript)- 4 阶段重构 1. **阶段 1**:测试基础设施(vitest + MSW + @testing-library/react) 2. **阶段 2**:提取自定义 hooks(`useProviderActions`、`useMcpActions`、`useSettings`、`useImportExport` 等) 3. **阶段 3**:组件拆分和业务逻辑提取 4. **阶段 4**:代码清理和格式化统一 ### 测试体系 - **Hooks 单元测试** - 所有自定义 hooks 100% 覆盖 - **集成测试** - 关键流程覆盖(App、SettingsDialog、MCP 面板) - **MSW 模拟** - 后端 API 模拟确保测试独立性 - **测试基础设施** - vitest + MSW + @testing-library/react ### 代码质量 - **统一参数格式** - 所有 Tauri 命令迁移到 camelCase(Tauri 2 规范) - **语义清晰** - `AppType` 重命名为 `AppId` 以获得更好的语义 - **集中解析** - 使用 `FromStr` trait 统一 `app` 参数解析 - **DRY 违规清理** - 消除整个代码库中的代码重复 - **死代码移除** - 移除未使用的 `missing_param` 辅助函数、废弃的 `tauri-api.ts`、冗余的 `KimiModelSelector` --- ## 内部优化(用户无感知) ### 移除遗留迁移逻辑 v3.6.0 移除了 v1 配置自动迁移和副本文件扫描逻辑: - **影响**:提升启动性能,代码更简洁 - **兼容性**:v2 格式配置完全兼容,无需任何操作 - **注意**:从 v3.1.0 或更早版本升级的用户,请先升级到 v3.2.x 或 v3.5.x 进行一次性迁移,然后再升级到 v3.6.0 ### 命令参数标准化 后端统一使用 `app` 参数(取值:`claude` 或 `codex`): - **影响**:代码更规范,错误提示更友好 - **兼容性**:前端已完全适配,用户无需关心此变更 --- ## 依赖更新 - 更新到 **Tauri 2.8.x** - 更新到 **TailwindCSS 4.x** - 更新到 **TanStack Query v5.90.x** - 保持 **React 18.2.x** 和 **TypeScript 5.3.x** --- ## 安装方式 ### macOS **通过 Homebrew 安装(推荐):** ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` **手动下载:** - 从下方 [Assets](#assets) 下载 `CC-Switch-v3.6.0-macOS.zip` > **注意**:由于作者没有苹果开发者账号,首次打开可能出现"未知开发者"警告。请前往"系统设置" → "隐私与安全性" → 点击"仍要打开" ### Windows - **安装包**:`CC-Switch-v3.6.0-Windows.msi` - **便携版**:`CC-Switch-v3.6.0-Windows-Portable.zip` ### Linux - **AppImage**:`CC-Switch-v3.6.0-Linux.AppImage` - **Debian**:`CC-Switch-v3.6.0-Linux.deb` --- ## 文档 - [中文文档](https://github.com/farion1231/cc-switch/blob/main/README_ZH.md) - [English Documentation](https://github.com/farion1231/cc-switch/blob/main/README.md) - [完整更新日志](https://github.com/farion1231/cc-switch/blob/main/CHANGELOG.md) --- ## 致谢 特别感谢**智谱 AI** 通过 GLM CODING PLAN 赞助本项目! --- **完整变更记录**: https://github.com/farion1231/cc-switch/compare/v3.5.1...v3.6.0 ================================================ FILE: docs/release-notes/v3.6.1-en.md ================================================ # CC Switch v3.6.1 > Stability improvements and user experience optimization (based on v3.6.0) **[中文更新说明 Chinese Documentation →](https://github.com/farion1231/cc-switch/blob/main/docs/release-notes/v3.6.1-zh.md)** --- ## 📦 What's New in v3.6.1 (2025-11-10) This release focuses on **user experience optimization** and **configuration parsing robustness**, fixing several critical bugs and enhancing the usage query system. ### ✨ New Features #### Usage Query System Enhancements - **Credential Decoupling** - Usage queries can now use independent API Key and Base URL, no longer dependent on provider configuration - Support for different query endpoints and authentication methods - Automatically displays credential input fields based on template type - General template: API Key + Base URL - NewAPI template: Base URL + Access Token + User ID - Custom template: Fully customizable - **UI Component Upgrade** - Replaced native checkbox with shadcn/ui Switch component for modern experience - **Form Unification** - Unified use of shadcn/ui Input components, consistent styling with the application - **Password Visibility Toggle** - Added show/hide password functionality (API Key, Access Token) #### Form Validation Infrastructure - **Common Schema Library** - New JSON/TOML generic validators to reduce code duplication - `jsonConfigSchema`: Generic JSON object validator - `tomlConfigSchema`: Generic TOML format validator - `mcpJsonConfigSchema`: MCP-specific JSON validator - **MCP Conditional Field Validation** - Strict type checking - stdio type requires `command` field - http type requires `url` field #### Partner Integration - **PackyCode** - New official partner - Added to Claude and Codex provider presets - 10% discount promotion support - New logo and partner identification --- ### 🔧 Improvements #### User Experience - **Drag Sort Sync** - Tray menu order now syncs with drag-and-drop sorting in real-time - **Enhanced Error Notifications** - Provider switch failures now display copyable error messages - **Removed Misleading Placeholders** - Deleted example text from model input fields to avoid user confusion - **Auto-fill Base URL** - All non-official provider categories automatically populate the Base URL input field #### Configuration Parsing - **CJK Quote Normalization** - Automatically handles IME-input fullwidth quotes to prevent TOML parsing errors - Supports automatic conversion of Chinese quotes (" " ' ') to ASCII quotes - Applied in TOML input handlers - Disabled browser auto-correction in Textarea component - **Preserve Custom Fields** - Editing Codex MCP TOML configuration now preserves unknown fields - Supports extension fields like timeout_ms, retry_count - Forward compatibility with future MCP protocol extensions --- ### 🐛 Bug Fixes #### Critical Fixes - **Fixed usage script panel white screen crash** - FormLabel component missing FormField context caused entire app to crash - Replaced with standalone Label component - Root cause: FormLabel internally calls useFormField() hook which requires FormFieldContext - **Fixed CJK input quote parsing failure** - IME-input fullwidth quotes caused TOML parsing errors - Added textNormalization utility function - Automatically normalizes quotes before parsing - **Fixed drag sort tray desync** (#179) - Tray menu order not updated after drag-and-drop sorting - Automatically calls updateTrayMenu after sorting completes - Ensures UI and tray menu stay consistent - **Fixed MCP custom field loss** - Custom fields silently dropped when editing Codex MCP configuration - Uses spread operator to retain all fields - Preserves unknown fields in normalizeServerConfig #### Stability Improvements - **Error Isolation** - Tray menu update failures no longer affect main operations - Decoupled tray update errors from main operations - Provides warning when main operation succeeds but tray update fails - **Safe Pattern Matching** - Replaced `unwrap()` with safe pattern matching - Avoids panic-induced app crashes - Tray menu event handling uses match patterns - **Import Config Classification** - Importing from default config now automatically sets category to `custom` - Avoids imported configs being mistaken for official presets - Provides clearer configuration source identification --- ### 📊 Technical Statistics ``` Commits: 17 commits Code Changes: 31 files - Additions: 1,163 lines - Deletions: 811 lines - Net Growth: +352 lines Contributors: Jason (16), ZyphrZero (1) ``` **By Module**: - UI/User Interface: 3 commits - Usage Query System: 3 commits - Configuration Parsing: 2 commits - Form Validation: 1 commit - Other Improvements: 8 commits --- ### 📥 Installation #### macOS **Via Homebrew (Recommended):** ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` **Manual Download:** - Download `CC-Switch-v3.6.1-macOS.zip` from [Assets](#assets) below > **Note**: Due to lack of Apple Developer account, you may see "unidentified developer" warning. Go to System Settings → Privacy & Security → Click "Open Anyway" #### Windows - **Installer**: `CC-Switch-v3.6.1-Windows.msi` - **Portable**: `CC-Switch-v3.6.1-Windows-Portable.zip` #### Linux - **AppImage**: `CC-Switch-v3.6.1-Linux.AppImage` - **Debian**: `CC-Switch-v3.6.1-Linux.deb` --- ### 📚 Documentation - [中文文档 (Chinese)](https://github.com/farion1231/cc-switch/blob/main/README_ZH.md) - [English Documentation](https://github.com/farion1231/cc-switch/blob/main/README.md) - [完整更新日志 (Full Changelog)](https://github.com/farion1231/cc-switch/blob/main/CHANGELOG.md) --- ### 🙏 Acknowledgments Special thanks to: - **Zhipu AI** - For sponsoring this project with GLM CODING PLAN - **PackyCode** - New official partner - **ZyphrZero** - For contributing tray menu sync fix (#179) --- **Full Changelog**: https://github.com/farion1231/cc-switch/compare/v3.6.0...v3.6.1 --- --- ## 📜 v3.6.0 Complete Feature Review > Content below is from v3.6.0 (2025-11-07), helping you understand the complete feature set
Click to expand v3.6.0 detailed content → ## What's New ### Edit Mode & Provider Management - **Provider Duplication** - Quickly duplicate existing provider configurations to create variants with one click - **Manual Sorting** - Drag and drop to reorder providers, with visual push effect animations. Thanks to @ZyphrZero - **Edit Mode Toggle** - Show/hide drag handles to optimize editing experience ### Custom Endpoint Management - **Multi-Endpoint Configuration** - Support for aggregator providers with multiple API endpoints - **Endpoint Input Visibility** - Shows endpoint field for all non-official providers automatically ### Usage Query Enhancements - **Auto-Refresh Interval** - Configure periodic automatic usage queries with customizable intervals - **Test Script API** - Validate JavaScript usage query scripts before execution - **Enhanced Templates** - Custom blank templates with access token and user ID parameter support Thanks to @Sirhexs ### Custom Configuration Directory (Cloud Sync) - **Customizable Storage Location** - Customize CC Switch's configuration storage directory - **Cloud Sync Support** - Point to cloud sync folders (Dropbox, OneDrive, iCloud Drive, etc.) to enable automatic config synchronization across devices - **Independent Management** - Managed via Tauri Store for better isolation and reliability Thanks to @ZyphrZero ### Configuration Directory Switching (WSL Support) - **Auto-Sync on Directory Change** - When switching Claude/Codex config directories (e.g., WSL environment), automatically sync current provider to the new directory without manual operation - **Post-Change Sync Utility** - Unified `postChangeSync.ts` utility for graceful error handling without blocking main flow - **Import Config Auto-Sync** - Automatically sync after config import to ensure immediate effectiveness - **Smart Conflict Resolution** - Distinguishes "fully successful" and "partially successful" states for precise user feedback ### Configuration Editor Improvements - **JSON Format Button** - One-click JSON formatting in configuration editors - **Real-Time TOML Validation** - Live syntax validation for Codex configuration with error highlighting ### Load Live Config When Editing - **Protect Manual Modifications** - When editing the currently active provider, prioritize displaying the actual effective configuration from live files - **Dual-Source Strategy** - Automatically loads from live config for active provider, SSOT for inactive ones ### Claude Configuration Data Structure Enhancements - **Granular Model Configuration** - Migrated from dual-key to quad-key system for better model tier differentiation - New fields: `ANTHROPIC_DEFAULT_HAIKU_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_MODEL` - Replaces legacy `ANTHROPIC_SMALL_FAST_MODEL` with automatic migration - Backend normalizes old configs on first read/write with smart fallback chain - UI expanded from 2 to 4 model input fields with intelligent defaults - **ANTHROPIC_API_KEY Support** - Providers can now use `ANTHROPIC_API_KEY` field in addition to `ANTHROPIC_AUTH_TOKEN` - **Template Variable System** - Support for dynamic configuration replacement (e.g., KAT-Coder's `ENDPOINT_ID` parameter) - **Endpoint Candidates** - Predefined endpoint list for speed testing and endpoint management - **Visual Theme Configuration** - Custom icons and colors for provider cards ### Updated Provider Models - **Kimi k2** - Updated to latest `kimi-k2-thinking` model ### New Provider Presets Added 5 new provider presets: - **DMXAPI** - Multi-model aggregation service - **Azure Codex** - Microsoft Azure OpenAI endpoint - **AnyRouter** - None-profit routing service - **AiHubMix** - Multi-model aggregation service - **MiniMax** - Open source AI model provider ### Partner Promotion Mechanism - Support for ecosystem partner promotion (Zhipu GLM Z.ai) - Sponsored banner integration in README --- ## Improvements ### Configuration & Sync - **Unified Error Handling** - AppError with internationalized error messages throughout backend - **Fixed apiKeyUrl Priority** - Correct priority order for API key URL resolution - **Fixed MCP Sync Issues** - Resolved sync-to-other-side functionality failures - **Import Config Sync** - Fixed sync issues after configuration import - **Config Error Handling** - Force exit on config error to prevent silent fallback and data loss ### UI/UX Enhancements - **Unique Provider Icons** - Each provider card now has unique icons and color identification - **Unified Border System** - Consistent border design across all components - **Drag Interaction** - Push effect animation and improved drag handle icons - **Enhanced Visual Feedback** - Better current provider visual indication - **Dialog Standardization** - Unified dialog sizes and layout consistency - **Form Improvements** - Optimized model placeholders, simplified provider hints, category-specific hints - **Usage Display Inline** - Usage info moved next to enable button for better space utilization ### Complete Internationalization - **Error Messages i18n** - All backend error messages support Chinese/English - **Tray Menu i18n** - System tray menu fully internationalized - **UI Components i18n** - 100% coverage across all user-facing components --- ## Bug Fixes ### Configuration Management - Fixed `apiKeyUrl` priority issue - Fixed MCP sync-to-other-side functionality failure - Fixed sync issues after config import - Fixed Codex API Key auto-sync - Fixed endpoint speed test functionality - Fixed provider duplicate insertion position (now inserts next to original) - Fixed custom endpoint preservation in edit mode - Prevent silent fallback and data loss on config error ### Usage Query - Fixed auto-query interval timing issue - Ensured refresh button shows loading animation on click ### UI Issues - Fixed name collision error (`get_init_error` command) - Fixed language setting rollback after successful save - Fixed language switch state reset (dependency cycle) - Fixed edit mode button alignment ### Startup Issues - Force exit on config error (no silent fallback) - Eliminated code duplication causing initialization errors --- ## Architecture Refactoring ### Backend (Rust) - 5 Phase Refactoring 1. **Phase 1**: Unified error handling (`AppError` + i18n error messages) 2. **Phase 2**: Command layer split by domain (`commands/{provider,mcp,config,settings,plugin,misc}.rs`) 3. **Phase 3**: Integration tests and transaction mechanism (config snapshot + failure rollback) 4. **Phase 4**: Extracted Service layer (`services/{provider,mcp,config,speedtest}.rs`) 5. **Phase 5**: Concurrency optimization (`RwLock` instead of `Mutex`, scoped guard to avoid deadlock) ### Frontend (React + TypeScript) - 4 Stage Refactoring 1. **Stage 1**: Test infrastructure (vitest + MSW + @testing-library/react) 2. **Stage 2**: Extracted custom hooks (`useProviderActions`, `useMcpActions`, `useSettings`, `useImportExport`, etc.) 3. **Stage 3**: Component splitting and business logic extraction 4. **Stage 4**: Code cleanup and formatting unification ### Testing System - **Hooks Unit Tests** - 100% coverage for all custom hooks - **Integration Tests** - Coverage for key processes (App, SettingsDialog, MCP Panel) - **MSW Mocking** - Backend API mocking to ensure test independence - **Test Infrastructure** - vitest + MSW + @testing-library/react ### Code Quality - **Unified Parameter Format** - All Tauri commands migrated to camelCase (Tauri 2 specification) - **Semantic Clarity** - `AppType` renamed to `AppId` for better semantics - **Centralized Parsing** - Unified `app` parameter parsing with `FromStr` trait - **DRY Violations Cleanup** - Eliminated code duplication throughout codebase - **Dead Code Removal** - Removed unused `missing_param` helper, deprecated `tauri-api.ts`, redundant `KimiModelSelector` --- ## Internal Optimizations (User Transparent) ### Removed Legacy Migration Logic v3.6.0 removed v1 config auto-migration and copy file scanning logic: - **Impact**: Improved startup performance, cleaner codebase - **Compatibility**: v2 format configs fully compatible, no action required - **Note**: Users upgrading from v3.1.0 or earlier should first upgrade to v3.2.x or v3.5.x for one-time migration, then upgrade to v3.6.0 ### Command Parameter Standardization Backend unified to use `app` parameter (values: `claude` or `codex`): - **Impact**: More standardized code, friendlier error prompts - **Compatibility**: Frontend fully adapted, users don't need to care about this change --- ## Dependencies - Updated to **Tauri 2.8.x** - Updated to **TailwindCSS 4.x** - Updated to **TanStack Query v5.90.x** - Maintained **React 18.2.x** and **TypeScript 5.3.x**
--- ## 🌟 About CC Switch CC Switch is a cross-platform desktop application for managing and switching between different provider configurations for Claude Code and Codex. Built with Tauri 2.0 + React 18 + TypeScript, supporting Windows, macOS, and Linux. **Core Features**: - 🔄 One-click switching between multiple AI providers - 📦 Support for both Claude Code and Codex applications - 🎨 Modern UI with complete Chinese/English internationalization - 🔐 Local storage, secure and reliable data - ☁️ Support for cloud sync configurations - 🧩 Unified MCP server management --- **Project Repository**: https://github.com/farion1231/cc-switch ================================================ FILE: docs/release-notes/v3.6.1-zh.md ================================================ # CC Switch v3.6.1 > 稳定性提升与用户体验优化(基于 v3.6.0) **[English Version →](v3.6.1-en.md)** --- ## 📦 v3.6.1 新增内容 (2025-11-10) 本次更新主要聚焦于**用户体验优化**和**配置解析健壮性**,修复了多个关键 Bug,并增强了用量查询系统。 ### ✨ 新增功能 #### 用量查询系统增强 - **凭证解耦** - 用量查询可使用独立的 API Key 和 Base URL,不再依赖供应商配置 - 支持不同的查询端点和认证方式 - 根据模板类型自动显示对应的凭证输入框 - General 模板:API Key + Base URL - NewAPI 模板:Base URL + Access Token + User ID - Custom 模板:完全自定义 - **UI 组件升级** - 使用 shadcn/ui Switch 替代原生 checkbox,体验更现代 - **表单统一化** - 统一使用 shadcn/ui 输入组件,样式与应用保持一致 - **密码显示切换** - 添加查看/隐藏密码功能(API Key、Access Token) #### 表单验证基础设施 - **通用 Schema 库** - 新增 JSON/TOML 通用验证器,减少重复代码 - `jsonConfigSchema`:通用 JSON 对象验证器 - `tomlConfigSchema`:通用 TOML 格式验证器 - `mcpJsonConfigSchema`:MCP 专用 JSON 验证器 - **MCP 条件字段验证** - 严格的类型检查 - stdio 类型强制要求 `command` 字段 - http 类型强制要求 `url` 字段 #### 合作伙伴集成 - **PackyCode** - 新增官方合作伙伴 - 添加到 Claude 和 Codex 供应商预设 - 支持 10% 折扣优惠(促销信息集成) - 新增 Logo 和合作伙伴标识 --- ### 🔧 改进优化 #### 用户体验 - **拖拽排序同步** - 托盘菜单顺序实时同步拖拽排序结果 - **错误通知增强** - 切换供应商失败时显示可复制的错误信息 - **移除误导性占位符** - 删除模型输入框的示例文本,避免用户混淆 - **Base URL 自动填充** - 所有非官方供应商类别自动填充 Base URL 输入框 #### 配置解析 - **中文引号规范化** - 自动处理 IME 输入的全角引号,防止 TOML 解析错误 - 支持中文引号(" " ' ')自动转换为 ASCII 引号 - 在 TOML 输入处理器中应用 - Textarea 组件禁用浏览器自动纠正 - **自定义字段保留** - 编辑 Codex MCP TOML 配置时保留未知字段 - 支持 timeout_ms、retry_count 等扩展字段 - 向前兼容未来的 MCP 协议扩展 --- ### 🐛 Bug 修复 #### 关键修复 - **修复用量脚本面板白屏崩溃** - FormLabel 组件缺少 FormField context 导致整个应用崩溃 - 替换为独立的 Label 组件 - 根本原因:FormLabel 内部调用 useFormField() hook 需要 FormFieldContext - **修复中文输入法引号解析失败** - IME 输入的全角引号导致 TOML 解析错误 - 新增 textNormalization 工具函数 - 在解析前自动规范化引号 - **修复拖拽排序托盘不同步** (#179) - 拖拽排序后托盘菜单顺序未更新 - 在排序完成后自动调用 updateTrayMenu - 确保 UI 和托盘菜单保持一致 - **修复 MCP 自定义字段丢失** - 编辑 Codex MCP 配置时自定义字段被静默丢弃 - 使用 spread 操作符保留所有字段 - normalizeServerConfig 中保留未知字段 #### 稳定性改进 - **错误隔离** - 托盘菜单更新失败不再影响主操作流程 - 将托盘更新错误与主操作解耦 - 主操作成功但托盘更新失败时给出警告 - **安全模式匹配** - 替换 `unwrap()` 为安全的 pattern matching - 避免 panic 导致应用崩溃 - 托盘菜单事件处理使用 match 模式 - **导入配置分类** - 从默认配置导入时自动设置 category 为 `custom` - 避免导入的配置被误认为官方预设 - 提供更清晰的配置来源标识 --- ### 📊 技术统计 ``` 提交数: 17 commits 代码变更: 31 个文件 - 新增: 1,163 行 - 删除: 811 行 - 净增长: +352 行 贡献者: Jason (16), ZyphrZero (1) ``` **按模块分类**: - UI/用户界面:3 commits - 用量查询系统:3 commits - 配置解析:2 commits - 表单验证:1 commit - 其他改进:8 commits --- ### 📥 安装方式 #### macOS **通过 Homebrew 安装(推荐):** ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` **手动下载:** - 从下方 [Assets](#assets) 下载 `CC-Switch-v3.6.1-macOS.zip` > **注意**:由于作者没有苹果开发者账号,首次打开可能出现"未知开发者"警告。请前往"系统设置" → "隐私与安全性" → 点击"仍要打开" #### Windows - **安装包**:`CC-Switch-v3.6.1-Windows.msi` - **便携版**:`CC-Switch-v3.6.1-Windows-Portable.zip` #### Linux - **AppImage**:`CC-Switch-v3.6.1-Linux.AppImage` - **Debian**:`CC-Switch-v3.6.1-Linux.deb` --- ### 📚 文档 - [中文文档](https://github.com/farion1231/cc-switch/blob/main/README_ZH.md) - [English Documentation](https://github.com/farion1231/cc-switch/blob/main/README.md) - [完整更新日志](https://github.com/farion1231/cc-switch/blob/main/CHANGELOG.md) --- ### 🙏 致谢 特别感谢: - **智谱 AI** - 通过 GLM CODING PLAN 赞助本项目 - **PackyCode** - 新加入的官方合作伙伴 - **ZyphrZero** - 贡献托盘菜单同步修复 (#179) --- **完整变更记录**: https://github.com/farion1231/cc-switch/compare/v3.6.0...v3.6.1 --- --- ## 📜 v3.6.0 完整功能回顾 > 以下内容来自 v3.6.0 (2025-11-07),帮助您了解完整的功能集
点击展开 v3.6.0 的详细内容 → ## 新增功能 ### 编辑模式与供应商管理 - **供应商复制功能** - 一键快速复制现有供应商配置,轻松创建变体配置 - **手动排序功能** - 通过拖拽对供应商进行重新排序,带有视觉推送效果动画 - **编辑模式切换** - 显示/隐藏拖拽手柄,优化编辑体验 ### 自定义端点管理 - **多端点配置** - 支持聚合类供应商的多 API 端点配置 - **端点输入可见性** - 为所有非官方供应商自动显示端点字段 ### 自定义配置目录(云同步) - **自定义存储位置** - 自定义 CC Switch 的配置存储目录 - **云同步支持** - 指定到云同步文件夹(Dropbox、OneDrive、iCloud Drive、坚果云等)即可实现跨设备配置自动同步 - **独立管理** - 通过 Tauri Store 管理,更好的隔离性和可靠性 ### 使用量查询增强 - **自动刷新间隔** - 配置定时自动使用量查询,支持自定义间隔时间 - **测试脚本 API** - 在执行前验证 JavaScript 使用量查询脚本 - **增强模板系统** - 自定义空白模板,支持 access token 和 user ID 参数 ### 配置目录切换(WSL 支持) - **目录变更自动同步** - 切换 Claude/Codex 配置目录(如 WSL 环境)时,自动同步当前供应商到新目录,无需手动操作 - **后置同步工具** - 统一的 `postChangeSync.ts` 工具,优雅处理错误而不阻塞主流程 - **导入配置自动同步** - 配置导入后自动同步,确保立即生效 - **智能冲突解决** - 区分"完全成功"和"部分成功"状态,提供精确的用户反馈 ### 配置编辑器改进 - **JSON 格式化按钮** - 配置编辑器中一键 JSON 格式化 - **实时 TOML 验证** - Codex 配置的实时语法验证,带有错误高亮 ### 编辑时加载 Live 配置 - **保护手动修改** - 编辑当前激活的供应商时,优先显示来自 live 文件的实际生效配置 - **双源策略** - 活动供应商自动从 live 配置加载,非活动供应商从 SSOT 加载 ### Claude 配置数据结构增强 - **细粒度模型配置** - 从双键系统升级到四键系统,以匹配官方最新数据结构 - 新增字段:`ANTHROPIC_DEFAULT_HAIKU_MODEL`、`ANTHROPIC_DEFAULT_SONNET_MODEL`、`ANTHROPIC_DEFAULT_OPUS_MODEL`、`ANTHROPIC_MODEL` - 替换旧版 `ANTHROPIC_SMALL_FAST_MODEL`,支持自动迁移 - 后端在首次读写时自动规范化旧配置,带有智能回退链 - UI 从 2 个模型输入字段扩展到 4 个,具有智能默认值 - **ANTHROPIC_API_KEY 支持** - 供应商现可使用 `ANTHROPIC_API_KEY` 字段(除 `ANTHROPIC_AUTH_TOKEN` 外) - **模板变量系统** - 支持动态配置替换(如 KAT-Coder 的 `ENDPOINT_ID` 参数) - **端点候选列表** - 预定义端点列表,用于速度测试和端点管理 - **视觉主题配置** - 供应商卡片自定义图标和颜色 ### 供应商模型更新 - **Kimi k2** - 更新到最新的 `kimi-k2-thinking` 模型 ### 新增供应商预设 新增 5 个供应商预设: - **DMXAPI** - 多模型聚合服务 - **Azure Codex** - 微软 Azure OpenAI 端点 - **AnyRouter** - API 路由服务 - **AiHubMix** - AI 模型集合 - **MiniMax** - 国产 AI 模型提供商 ### 合作伙伴推广机制 - 支持生态合作伙伴推广(智谱 GLM Z.ai) - README 中集成赞助商横幅 --- ## 改进优化 ### 配置与同步 - **统一错误处理** - 后端全面使用 AppError 与国际化错误消息 - **修复 apiKeyUrl 优先级** - 修正 API key URL 解析的优先级顺序 - **修复 MCP 同步问题** - 解决同步到另一端功能失效的问题 - **导入配置同步** - 修复配置导入后的同步问题 - **配置错误处理** - 配置错误时强制退出,防止静默回退和数据丢失 ### UI/UX 增强 - **独特的供应商图标** - 每个供应商卡片现在都有独特的图标和颜色识别 - **统一边框系统** - 所有组件采用一致的边框设计 - **拖拽交互** - 推送效果动画和改进的拖拽手柄图标 - **增强视觉反馈** - 更好的当前供应商视觉指示 - **对话框标准化** - 统一的对话框尺寸和布局一致性 - **表单改进** - 优化模型占位符,简化供应商提示,分类特定提示 - **使用量内联显示** - 使用量信息移至启用按钮旁边,更好地利用空间 ### 完整国际化 - **错误消息国际化** - 所有后端错误消息支持中英文 - **托盘菜单国际化** - 系统托盘菜单完全国际化 - **UI 组件国际化** - 所有面向用户的组件 100% 覆盖 --- ## Bug 修复 ### 配置管理 - 修复 `apiKeyUrl` 优先级问题 - 修复 MCP 同步到另一端功能失效 - 修复配置导入后的同步问题 - 修复 Codex API Key 自动同步 - 修复端点速度测试功能 - 修复供应商复制插入位置(现在插入到原供应商旁边) - 修复编辑模式下自定义端点保留问题 - 防止配置错误时的静默回退和数据丢失 ### 使用量查询 - 修复自动查询间隔时间问题 - 确保刷新按钮点击时显示加载动画 ### UI 问题 - 修复名称冲突错误(`get_init_error` 命令) - 修复保存成功后语言设置回滚 - 修复语言切换状态重置(依赖循环) - 修复编辑模式按钮对齐 ### 启动问题 - 配置错误时强制退出(不再静默回退) - 消除导致初始化错误的代码重复 --- ## 架构重构 ### 后端(Rust)- 5 阶段重构 1. **阶段 1**:统一错误处理(`AppError` + 国际化错误消息) 2. **阶段 2**:命令层按领域拆分(`commands/{provider,mcp,config,settings,plugin,misc}.rs`) 3. **阶段 3**:集成测试和事务机制(配置快照 + 失败回滚) 4. **阶段 4**:提取 Service 层(`services/{provider,mcp,config,speedtest}.rs`) 5. **阶段 5**:并发优化(`RwLock` 替代 `Mutex`,作用域 guard 避免死锁) ### 前端(React + TypeScript)- 4 阶段重构 1. **阶段 1**:测试基础设施(vitest + MSW + @testing-library/react) 2. **阶段 2**:提取自定义 hooks(`useProviderActions`、`useMcpActions`、`useSettings`、`useImportExport` 等) 3. **阶段 3**:组件拆分和业务逻辑提取 4. **阶段 4**:代码清理和格式化统一 ### 测试体系 - **Hooks 单元测试** - 所有自定义 hooks 100% 覆盖 - **集成测试** - 关键流程覆盖(App、SettingsDialog、MCP 面板) - **MSW 模拟** - 后端 API 模拟确保测试独立性 - **测试基础设施** - vitest + MSW + @testing-library/react ### 代码质量 - **统一参数格式** - 所有 Tauri 命令迁移到 camelCase(Tauri 2 规范) - **语义清晰** - `AppType` 重命名为 `AppId` 以获得更好的语义 - **集中解析** - 使用 `FromStr` trait 统一 `app` 参数解析 - **DRY 违规清理** - 消除整个代码库中的代码重复 - **死代码移除** - 移除未使用的 `missing_param` 辅助函数、废弃的 `tauri-api.ts`、冗余的 `KimiModelSelector` --- ## 内部优化(用户无感知) ### 移除遗留迁移逻辑 v3.6.0 移除了 v1 配置自动迁移和副本文件扫描逻辑: - **影响**:提升启动性能,代码更简洁 - **兼容性**:v2 格式配置完全兼容,无需任何操作 - **注意**:从 v3.1.0 或更早版本升级的用户,请先升级到 v3.2.x 或 v3.5.x 进行一次性迁移,然后再升级到 v3.6.0 ### 命令参数标准化 后端统一使用 `app` 参数(取值:`claude` 或 `codex`): - **影响**:代码更规范,错误提示更友好 - **兼容性**:前端已完全适配,用户无需关心此变更 --- ## 依赖更新 - 更新到 **Tauri 2.8.x** - 更新到 **TailwindCSS 4.x** - 更新到 **TanStack Query v5.90.x** - 保持 **React 18.2.x** 和 **TypeScript 5.3.x**
--- ## 🌟 关于 CC Switch CC Switch 是一个跨平台桌面应用,用于管理和切换 Claude Code 与 Codex 的不同供应商配置。基于 Tauri 2.0 + React 18 + TypeScript 构建,支持 Windows、macOS、Linux。 **核心特性**: - 🔄 一键切换多个 AI 供应商 - 📦 支持 Claude Code 和 Codex 双应用 - 🎨 现代化 UI,完整的中英文国际化 - 🔐 本地存储,数据安全可靠 - ☁️ 支持云同步配置 - 🧩 MCP 服务器统一管理 --- **项目地址**: https://github.com/farion1231/cc-switch ================================================ FILE: docs/release-notes/v3.7.0-en.md ================================================ # CC Switch v3.7.0 > From Provider Switcher to All-in-One AI CLI Management Platform **[中文更新说明 Chinese Documentation →](v3.7.0-zh.md)** --- ## Overview CC Switch v3.7.0 introduces six major features with over 18,000 lines of new code. **Release Date**: 2025-11-19 **Commits**: 85 from v3.6.0 **Code Changes**: 152 files, +18,104 / -3,732 lines --- ## New Features ### Gemini CLI Integration Complete support for Google Gemini CLI, becoming the third supported application (Claude Code, Codex, Gemini). **Core Capabilities**: - **Dual-file configuration** - Support for both `.env` and `settings.json` formats - **Auto-detection** - Automatically detect `GOOGLE_GEMINI_BASE_URL`, `GEMINI_MODEL`, etc. - **Full MCP support** - Complete MCP server management for Gemini - **Deep link integration** - Import via `ccswitch://` protocol - **System tray** - Quick-switch from tray menu **Provider Presets**: - **Google Official** - OAuth authentication support - **PackyCode** - Partner integration - **Custom** - Full customization support **Technical Implementation**: - New backend modules: `gemini_config.rs` (20KB), `gemini_mcp.rs` - Form synchronization with environment editor - Dual-file atomic writes --- ### MCP v3.7.0 Unified Architecture Complete refactoring of MCP management system for cross-application unification. **Architecture Improvements**: - **Unified panel** - Single interface for Claude/Codex/Gemini MCP servers - **SSE transport** - New Server-Sent Events support - **Smart parser** - Fault-tolerant JSON parsing - **Format correction** - Auto-fix Codex `[mcp_servers]` format - **Extended fields** - Preserve custom TOML fields **User Experience**: - Default app selection in forms - JSON formatter for validation - Improved visual hierarchy - Better error messages **Import/Export**: - Unified import from all three apps - Bidirectional synchronization - State preservation --- ### Claude Skills Management System **Approximately 2,000 lines of code** - A complete skill ecosystem platform. **GitHub Integration**: - Auto-scan skills from GitHub repositories - Pre-configured repos: - `ComposioHQ/awesome-claude-skills` - Curated collection - `anthropics/skills` - Official Anthropic skills - `cexll/myclaude` - Community contributions - Add custom repositories - Subdirectory scanning support (`skillsPath`) **Lifecycle Management**: - **Discover** - Auto-detect `SKILL.md` files - **Install** - One-click to `~/.claude/skills/` - **Uninstall** - Safe removal with tracking - **Update** - Check for updates (infrastructure ready) **Technical Architecture**: - **Backend**: `SkillService` (526 lines) with GitHub API integration - **Frontend**: SkillsPage, SkillCard, RepoManager - **UI Components**: Badge, Card, Table (shadcn/ui) - **State**: Persistent storage in `skills.json` - **i18n**: 47+ translation keys --- ### Prompts Management System **Approximately 1,300 lines of code** - Complete system prompt management. **Multi-Preset Management**: - Create unlimited prompt presets - Quick switch between presets - One active prompt at a time - Delete protection for active prompts **Cross-App Support**: - **Claude**: `~/.claude/CLAUDE.md` - **Codex**: `~/.codex/AGENTS.md` - **Gemini**: `~/.gemini/GEMINI.md` **Markdown Editor**: - Full-featured CodeMirror 6 integration - Syntax highlighting - Dark theme (One Dark) - Real-time preview **Smart Synchronization**: - **Auto-write** - Immediately write to live files - **Backfill protection** - Save current content before switching - **Auto-import** - Import from live files on first launch - **Modification protection** - Preserve manual modifications **Technical Implementation**: - **Backend**: `PromptService` (213 lines) - **Frontend**: PromptPanel (177), PromptFormModal (160), MarkdownEditor (159) - **Hooks**: usePromptActions (152 lines) - **i18n**: 41+ translation keys --- ### Deep Link Protocol (ccswitch://) One-click provider configuration import via URL scheme. **Features**: - Protocol registration on all platforms - Import from shared links - Lifecycle integration - Security validation --- ### Environment Variable Conflict Detection Intelligent detection and management of configuration conflicts. **Detection Scope**: - **Claude & Codex** - Cross-app conflicts - **Gemini** - Auto-discovery - **MCP** - Server configuration conflicts **Management Features**: - Visual conflict indicators - Resolution suggestions - Override warnings - Backup before changes --- ## Improvements ### Provider Management **New Presets**: - **DouBaoSeed** - ByteDance's DouBao - **Kimi For Coding** - Moonshot AI - **BaiLing** - BaiLing AI - **Removed AnyRouter** - To avoid confusion **Enhancements**: - Model name configuration for Codex and Gemini - Provider notes field for organization - Enhanced preset metadata ### Configuration Management - **Common config migration** - From localStorage to `config.json` - **Unified persistence** - Shared across all apps - **Auto-import** - First launch configuration import - **Backfill priority** - Correct handling of live files ### UI/UX Improvements **Design System**: - **macOS native** - System-aligned color scheme - **Window centering** - Default centered position - **Visual polish** - Improved spacing and hierarchy **Interactions**: - **Password input** - Fixed Edge/IE reveal buttons - **URL overflow** - Fixed card overflow - **Error copying** - Copy-to-clipboard errors - **Tray sync** - Real-time drag-and-drop sync --- ## Bug Fixes ### Critical Fixes - **Usage script validation** - Boundary checks - **Gemini validation** - Relaxed constraints - **TOML parsing** - CJK quote handling - **MCP fields** - Custom field preservation - **White screen** - FormLabel crash fix ### Stability - **Tray safety** - Pattern matching instead of unwrap - **Error isolation** - Tray failures don't block operations - **Import classification** - Correct category assignment ### UI Fixes - **Model placeholders** - Removed misleading hints - **Base URL** - Auto-fill for third-party providers - **Drag sort** - Tray menu synchronization --- ## Technical Improvements ### Architecture **MCP v3.7.0**: - Removed legacy code (~1,000 lines) - Unified initialization structure - Backward compatibility maintained - Comprehensive code formatting **Platform Compatibility**: - Windows winreg API fix (v0.52) - Safe pattern matching (no `unwrap()`) - Cross-platform tray handling ### Configuration **Synchronization**: - MCP sync across all apps - Gemini form-editor sync - Dual-file reading (.env + settings.json) **Validation**: - Input boundary checks - TOML quote normalization (CJK) - Custom field preservation - Enhanced error messages ### Code Quality **Type Safety**: - Complete TypeScript coverage - Rust type refinements - API contract validation **Testing**: - Simplified assertions - Better test coverage - Integration test updates **Dependencies**: - Tauri 2.8.x - Rust: `anyhow`, `zip`, `serde_yaml`, `tempfile` - Frontend: CodeMirror 6 packages - winreg 0.52 (Windows) --- ## Technical Statistics ``` Total Changes: - Commits: 85 - Files: 152 changed - Additions: +18,104 lines - Deletions: -3,732 lines New Modules: - Skills Management: 2,034 lines (21 files) - Prompts Management: 1,302 lines (20 files) - Gemini Integration: ~1,000 lines - MCP Refactor: ~3,000 lines refactored Code Distribution: - Backend (Rust): ~4,500 lines new - Frontend (React): ~3,000 lines new - Configuration: ~1,500 lines refactored - Tests: ~500 lines ``` --- ## Strategic Positioning ### From Tool to Platform v3.7.0 represents a shift in CC Switch's positioning: | Aspect | v3.6 | v3.7.0 | | ----------------- | ------------------------ | ---------------------------- | | **Identity** | Provider Switcher | AI CLI Management Platform | | **Scope** | Configuration Management | Ecosystem Management | | **Applications** | Claude + Codex | Claude + Codex + Gemini | | **Capabilities** | Switch configs | Extend capabilities (Skills) | | **Customization** | Manual editing | Visual management (Prompts) | | **Integration** | Isolated apps | Unified management (MCP) | ### Six Pillars of AI CLI Management 1. **Configuration Management** - Provider switching and management 2. **Capability Extension** - Skills installation and lifecycle 3. **Behavior Customization** - System prompt presets 4. **Ecosystem Integration** - Deep links and sharing 5. **Multi-AI Support** - Claude/Codex/Gemini 6. **Intelligent Detection** - Conflict prevention --- ## Download & Installation ### System Requirements - **Windows**: Windows 10+ - **macOS**: macOS 10.15 (Catalina)+ - **Linux**: Ubuntu 22.04+ / Debian 11+ / Fedora 34+ ### Download Links Visit [Releases](https://github.com/farion1231/cc-switch/releases/latest) to download: - **Windows**: `CC-Switch-v3.7.0-Windows.msi` or `-Portable.zip` - **macOS**: `CC-Switch-v3.7.0-macOS.tar.gz` or `.zip` - **Linux**: `CC-Switch-v3.7.0-Linux.AppImage` or `.deb` ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` Update: ```bash brew upgrade --cask cc-switch ``` --- ## Migration Notes ### From v3.6.x **Automatic migration** - No action required, configs are fully compatible ### From v3.1.x or Earlier **Two-step migration required**: 1. First upgrade to v3.2.x (performs one-time migration) 2. Then upgrade to v3.7.0 ### New Features - **Skills**: No migration needed, start fresh - **Prompts**: Auto-import from live files on first launch - **Gemini**: Install Gemini CLI separately if needed - **MCP v3.7.0**: Backward compatible with previous configs --- ## Acknowledgments ### Contributors Thanks to all contributors who made this release possible: - [@YoVinchen](https://github.com/YoVinchen) - Skills & Prompts & Gemini integration implementation - [@farion1231](https://github.com/farion1231) - From developer to issue responder - Community members for testing and feedback ### Sponsors **Z.ai** - GLM CODING PLAN sponsor [Get 10% OFF with this link](https://z.ai/subscribe?ic=8JVLJQFSKB) **PackyCode** - API relay service partner [Register with "cc-switch" code for 10% discount](https://www.packyapi.com/register?aff=cc-switch) --- ## Feedback & Support - **Issues**: [GitHub Issues](https://github.com/farion1231/cc-switch/issues) - **Discussions**: [GitHub Discussions](https://github.com/farion1231/cc-switch/discussions) - **Documentation**: [README](../README.md) - **Changelog**: [CHANGELOG.md](../CHANGELOG.md) --- ## What's Next **v3.8.0 Preview** (Tentative): - Local proxy functionality Stay tuned for more updates! --- **Happy Coding!** ================================================ FILE: docs/release-notes/v3.7.0-zh.md ================================================ # CC Switch v3.7.0 > 从供应商切换器到 AI CLI 一体化管理平台 **[English Version →](v3.7.0-en.md)** --- ## 概览 CC Switch v3.7.0 新增六大核心功能,新增超过 18,000 行代码。 **发布日期**:2025-11-19 **提交数量**:从 v3.6.0 开始 85 个提交 **代码变更**:152 个文件,+18,104 / -3,732 行 --- ## 新增功能 ### Gemini CLI 集成 完整支持 Google Gemini CLI,成为第三个支持的应用(Claude Code、Codex、Gemini)。 **核心能力**: - **双文件配置** - 同时支持 `.env` 和 `settings.json` 格式 - **自动检测** - 自动检测 `GOOGLE_GEMINI_BASE_URL`、`GEMINI_MODEL` 等环境变量 - **完整 MCP 支持** - 为 Gemini 提供完整的 MCP 服务器管理 - **深度链接集成** - 通过 `ccswitch://` 协议导入配置 - **系统托盘** - 从托盘菜单快速切换 **供应商预设**: - **Google Official** - 支持 OAuth 认证 - **PackyCode** - 合作伙伴集成 - **自定义** - 完全自定义支持 **技术实现**: - 新增后端模块:`gemini_config.rs`(20KB)、`gemini_mcp.rs` - 表单与环境编辑器同步 - 双文件原子写入 --- ### MCP v3.7.0 统一架构 MCP 管理系统完整重构,实现跨应用统一管理。 **架构改进**: - **统一管理面板** - 单一界面管理 Claude/Codex/Gemini MCP 服务器 - **SSE 传输类型** - 新增 Server-Sent Events 支持 - **智能解析器** - 容错性 JSON 解析 - **格式修正** - 自动修复 Codex `[mcp_servers]` 格式 - **扩展字段** - 保留自定义 TOML 字段 **用户体验**: - 表单中的默认应用选择 - JSON 格式化器用于验证 - 改进的视觉层次 - 更好的错误消息 **导入/导出**: - 统一从三个应用导入 - 双向同步 - 状态保持 --- ### Claude Skills 管理系统 **约 2,000 行代码** - 完整的技能生态平台。 **GitHub 集成**: - 从 GitHub 仓库自动扫描技能 - 预配置仓库: - `ComposioHQ/awesome-claude-skills` - 精选集合 - `anthropics/skills` - Anthropic 官方技能 - `cexll/myclaude` - 社区贡献 - 添加自定义仓库 - 子目录扫描支持(`skillsPath`) **生命周期管理**: - **发现** - 自动检测 `SKILL.md` 文件 - **安装** - 一键安装到 `~/.claude/skills/` - **卸载** - 安全移除并跟踪状态 - **更新** - 检查更新(基础设施已就绪) **技术架构**: - **后端**:`SkillService`(526 行)集成 GitHub API - **前端**:SkillsPage、SkillCard、RepoManager - **UI 组件**:Badge、Card、Table(shadcn/ui) - **状态**:持久化存储在 `skills.json` - **国际化**:47+ 个翻译键 --- ### Prompts 管理系统 **约 1,300 行代码** - 完整的系统提示词管理。 **多预设管理**: - 创建无限数量的提示词预设 - 快速在预设间切换 - 同时只能激活一个提示词 - 活动提示词删除保护 **跨应用支持**: - **Claude**:`~/.claude/CLAUDE.md` - **Codex**:`~/.codex/AGENTS.md` - **Gemini**:`~/.gemini/GEMINI.md` **Markdown 编辑器**: - 完整的 CodeMirror 6 集成 - 语法高亮 - 暗色主题(One Dark) - 实时预览 **智能同步**: - **自动写入** - 立即写入 live 文件 - **回填保护** - 切换前保存当前内容 - **自动导入** - 首次启动从 live 文件导入 - **修改保护** - 保留手动修改 **技术实现**: - **后端**:`PromptService`(213 行) - **前端**:PromptPanel(177)、PromptFormModal(160)、MarkdownEditor(159) - **Hooks**:usePromptActions(152 行) - **国际化**:41+ 个翻译键 --- ### 深度链接协议(ccswitch://) 通过 URL 方案一键导入供应商配置。 **功能特性**: - 所有平台的协议注册 - 从共享链接导入 - 生命周期集成 - 安全验证 --- ### 环境变量冲突检测 智能检测和管理配置冲突。 **检测范围**: - **Claude & Codex** - 跨应用冲突 - **Gemini** - 自动发现 - **MCP** - 服务器配置冲突 **管理功能**: - 可视化冲突指示器 - 解决建议 - 覆盖警告 - 更改前备份 --- ## 改进优化 ### 供应商管理 **新增预设**: - **DouBaoSeed** - 字节跳动的豆包 - **Kimi For Coding** - 月之暗面 - **BaiLing** - 百灵 AI - **移除 AnyRouter** - 避免误导 **增强功能**: - Codex 和 Gemini 的模型名称配置 - 供应商备注字段用于组织 - 增强的预设元数据 ### 配置管理 - **通用配置迁移** - 从 localStorage 迁移到 `config.json` - **统一持久化** - 跨所有应用共享 - **自动导入** - 首次启动配置导入 - **回填优先级** - 正确处理 live 文件 ### UI/UX 改进 **设计系统**: - **macOS 原生** - 与系统对齐的配色方案 - **窗口居中** - 默认居中位置 - **视觉优化** - 改进的间距和层次 **交互优化**: - **密码输入** - 修复 Edge/IE 显示按钮 - **URL 溢出** - 修复卡片溢出 - **错误复制** - 可复制到剪贴板的错误 - **托盘同步** - 实时拖放同步 --- ## Bug 修复 ### 关键修复 - **用量脚本验证** - 边界检查 - **Gemini 验证** - 放宽约束 - **TOML 解析** - CJK 引号处理 - **MCP 字段** - 自定义字段保留 - **白屏** - FormLabel 崩溃修复 ### 稳定性 - **托盘安全** - 模式匹配替代 unwrap - **错误隔离** - 托盘失败不阻塞操作 - **导入分类** - 正确的类别分配 ### UI 修复 - **模型占位符** - 移除误导性提示 - **Base URL** - 第三方供应商自动填充 - **拖拽排序** - 托盘菜单同步 --- ## 技术改进 ### 架构 **MCP v3.7.0**: - 移除遗留代码(约 1,000 行) - 统一初始化结构 - 保持向后兼容性 - 全面的代码格式化 **平台兼容性**: - Windows winreg API 修复(v0.52) - 安全模式匹配(无 `unwrap()`) - 跨平台托盘处理 ### 配置 **同步机制**: - 跨所有应用的 MCP 同步 - Gemini 表单-编辑器同步 - 双文件读取(.env + settings.json) **验证增强**: - 输入边界检查 - TOML 引号规范化(CJK) - 自定义字段保留 - 增强的错误消息 ### 代码质量 **类型安全**: - 完整的 TypeScript 覆盖 - Rust 类型改进 - API 契约验证 **测试**: - 简化的断言 - 更好的测试覆盖 - 集成测试更新 **依赖项**: - Tauri 2.8.x - Rust:`anyhow`、`zip`、`serde_yaml`、`tempfile` - 前端:CodeMirror 6 包 - winreg 0.52(Windows) --- ## 技术统计 ``` 总体变更: - 提交数:85 - 文件数:152 个文件变更 - 新增:+18,104 行 - 删除:-3,732 行 新增模块: - Skills 管理:2,034 行(21 个文件) - Prompts 管理:1,302 行(20 个文件) - Gemini 集成:约 1,000 行 - MCP 重构:约 3,000 行重构 代码分布: - 后端(Rust):约 4,500 行新增 - 前端(React):约 3,000 行新增 - 配置:约 1,500 行重构 - 测试:约 500 行 ``` --- ## 战略定位 ### 从工具到平台 v3.7.0 代表了 CC Switch 定位的转变: | 方面 | v3.6 | v3.7.0 | | -------- | -------------- | ----------------------- | | **身份** | 供应商切换器 | AI CLI 管理平台 | | **范围** | 配置管理 | 生态系统管理 | | **应用** | Claude + Codex | Claude + Codex + Gemini | | **能力** | 切换配置 | 扩展能力(Skills) | | **定制** | 手动编辑 | 可视化管理(Prompts) | | **集成** | 孤立应用 | 统一管理(MCP) | ### AI CLI 管理六大支柱 1. **配置管理** - 供应商切换和管理 2. **能力扩展** - Skills 安装和生命周期 3. **行为定制** - 系统提示词预设 4. **生态集成** - 深度链接和共享 5. **多 AI 支持** - Claude/Codex/Gemini 6. **智能检测** - 冲突预防 --- ## 下载与安装 ### 系统要求 - **Windows**:Windows 10+ - **macOS**:macOS 10.15(Catalina)+ - **Linux**:Ubuntu 22.04+ / Debian 11+ / Fedora 34+ ### 下载链接 访问 [Releases](https://github.com/farion1231/cc-switch/releases/latest) 下载: - **Windows**:`CC-Switch-v3.7.0-Windows.msi` 或 `-Portable.zip` - **macOS**:`CC-Switch-v3.7.0-macOS.tar.gz` 或 `.zip` - **Linux**:`CC-Switch-v3.7.0-Linux.AppImage` 或 `.deb` ### Homebrew(macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` --- ## 迁移说明 ### 从 v3.6.x 升级 **自动迁移** - 无需任何操作,配置完全兼容 ### 从 v3.1.x 或更早版本升级 **需要两步迁移**: 1. 首先升级到 v3.2.x(执行一次性迁移) 2. 然后升级到 v3.7.0 ### 新功能 - **Skills**:无需迁移,全新开始 - **Prompts**:首次启动时从 live 文件自动导入 - **Gemini**:需要单独安装 Gemini CLI - **MCP v3.7.0**:与之前的配置向后兼容 --- ## 致谢 ### 贡献者 感谢所有让这个版本成为可能的贡献者: - [@YoVinchen](https://github.com/YoVinchen) - Skills & Prompts & Geimini 集成实现 - [@farion1231](https://github.com/farion1231) - 从开发沦为 issue 回复机 - 社区成员的测试和反馈 ### 赞助商 **Z.ai** - GLM CODING PLAN 赞助商 [通过此链接获得 10% 折扣](https://z.ai/subscribe?ic=8JVLJQFSKB) **PackyCode** - API 中继服务合作伙伴 [使用 "cc-switch" 代码注册可享受 10% 折扣](https://www.packyapi.com/register?aff=cc-switch) --- ## 反馈与支持 - **问题反馈**:[GitHub Issues](https://github.com/farion1231/cc-switch/issues) - **讨论**:[GitHub Discussions](https://github.com/farion1231/cc-switch/discussions) - **文档**:[README](../README_ZH.md) - **更新日志**:[CHANGELOG.md](../CHANGELOG.md) --- ## 未来展望 **v3.8.0 预览**(暂定): - 本地代理功能 敬请期待更多更新! ================================================ FILE: docs/release-notes/v3.7.1-en.md ================================================ # CC Switch v3.7.1 > Stability Enhancements and User Experience Improvements **[中文更新说明 Chinese Documentation →](v3.7.1-zh.md)** --- ## v3.7.1 Updates **Release Date**: 2025-11-22 **Code Changes**: 17 files, +524 / -81 lines ### Bug Fixes - **Fix Third-Party Skills Installation Failure** (#268) Fixed installation issues for skills repositories with custom subdirectories, now supports repos like `ComposioHQ/awesome-claude-skills` with subdirectories - **Fix Gemini Configuration Persistence Issue** Resolved the issue where settings.json edits in Gemini form were lost when switching providers - **Prevent Dialogs from Closing on Overlay Click** Added protection against clicking overlay/backdrop, preventing accidental form data loss across all 11 dialog components ### New Features - **Gemini Configuration Directory Support** (#255) Added Gemini configuration directory option in settings, supports customizing `~/.gemini/` path - **ArchLinux Installation Support** (#259) Added AUR installation method: `paru -S cc-switch-bin` ### Improvements - **Skills Error Message i18n Enhancement** Added 28+ detailed error messages (English & Chinese) with specific resolution suggestions, extended download timeout from 15s to 60s - **Code Formatting** Applied unified Rust and TypeScript code formatting standards ### Download Visit [Releases](https://github.com/farion1231/cc-switch/releases/latest) to download the latest version --- ## v3.7.0 Complete Release Notes > From Provider Switcher to All-in-One AI CLI Management Platform **Release Date**: 2025-11-19 **Commits**: 85 from v3.6.0 **Code Changes**: 152 files, +18,104 / -3,732 lines --- ## New Features ### Gemini CLI Integration Complete support for Google Gemini CLI, becoming the third supported application (Claude Code, Codex, Gemini). **Core Capabilities**: - **Dual-file configuration** - Support for both `.env` and `settings.json` formats - **Auto-detection** - Automatically detect `GOOGLE_GEMINI_BASE_URL`, `GEMINI_MODEL`, etc. - **Full MCP support** - Complete MCP server management for Gemini - **Deep link integration** - Import via `ccswitch://` protocol - **System tray** - Quick-switch from tray menu **Provider Presets**: - **Google Official** - OAuth authentication support - **PackyCode** - Partner integration - **Custom** - Full customization support **Technical Implementation**: - New backend modules: `gemini_config.rs` (20KB), `gemini_mcp.rs` - Form synchronization with environment editor - Dual-file atomic writes --- ### MCP v3.7.0 Unified Architecture Complete refactoring of MCP management system for cross-application unification. **Architecture Improvements**: - **Unified panel** - Single interface for Claude/Codex/Gemini MCP servers - **SSE transport** - New Server-Sent Events support - **Smart parser** - Fault-tolerant JSON parsing - **Format correction** - Auto-fix Codex `[mcp_servers]` format - **Extended fields** - Preserve custom TOML fields **User Experience**: - Default app selection in forms - JSON formatter for validation - Improved visual hierarchy - Better error messages **Import/Export**: - Unified import from all three apps - Bidirectional synchronization - State preservation --- ### Claude Skills Management System **Approximately 2,000 lines of code** - A complete skill ecosystem platform. **GitHub Integration**: - Auto-scan skills from GitHub repositories - Pre-configured repos: - `ComposioHQ/awesome-claude-skills` - Curated collection - `anthropics/skills` - Official Anthropic skills - `cexll/myclaude` - Community contributions - Add custom repositories - Subdirectory scanning support (`skillsPath`) **Lifecycle Management**: - **Discover** - Auto-detect `SKILL.md` files - **Install** - One-click to `~/.claude/skills/` - **Uninstall** - Safe removal with tracking - **Update** - Check for updates (infrastructure ready) **Technical Architecture**: - **Backend**: `SkillService` (526 lines) with GitHub API integration - **Frontend**: SkillsPage, SkillCard, RepoManager - **UI Components**: Badge, Card, Table (shadcn/ui) - **State**: Persistent storage in `config.json` - **i18n**: 47+ translation keys --- ### Prompts Management System **Approximately 1,300 lines of code** - Complete system prompt management. **Multi-Preset Management**: - Create unlimited prompt presets - Quick switch between presets - One active prompt at a time - Delete protection for active prompts **Cross-App Support**: - **Claude**: `~/.claude/CLAUDE.md` - **Codex**: `~/.codex/AGENTS.md` - **Gemini**: `~/.gemini/GEMINI.md` **Markdown Editor**: - Full-featured CodeMirror 6 integration - Syntax highlighting - Dark theme (One Dark) - Real-time preview **Smart Synchronization**: - **Auto-write** - Immediately write to live files - **Backfill protection** - Save current content before switching - **Auto-import** - Import from live files on first launch - **Modification protection** - Preserve manual modifications **Technical Implementation**: - **Backend**: `PromptService` (213 lines) - **Frontend**: PromptPanel (177), PromptFormModal (160), MarkdownEditor (159) - **Hooks**: usePromptActions (152 lines) - **i18n**: 41+ translation keys --- ### Deep Link Protocol (ccswitch://) One-click provider configuration import via URL scheme. **Features**: - Protocol registration on all platforms - Import from shared links - Lifecycle integration - Security validation --- ### Environment Variable Conflict Detection Intelligent detection and management of configuration conflicts. **Detection Scope**: - **Claude & Codex** - Cross-app conflicts - **Gemini** - Auto-discovery - **MCP** - Server configuration conflicts **Management Features**: - Visual conflict indicators - Resolution suggestions - Override warnings - Backup before changes --- ## Improvements ### Provider Management **New Presets**: - **DouBaoSeed** - ByteDance's DouBao - **Kimi For Coding** - Moonshot AI - **BaiLing** - BaiLing AI - **Removed AnyRouter** - To avoid confusion **Enhancements**: - Model name configuration for Codex and Gemini - Provider notes field for organization - Enhanced preset metadata ### Configuration Management - **Common config migration** - From localStorage to `config.json` - **Unified persistence** - Shared across all apps - **Auto-import** - First launch configuration import - **Backfill priority** - Correct handling of live files ### UI/UX Improvements **Design System**: - **macOS native** - System-aligned color scheme - **Window centering** - Default centered position - **Visual polish** - Improved spacing and hierarchy **Interactions**: - **Password input** - Fixed Edge/IE reveal buttons - **URL overflow** - Fixed card overflow - **Error copying** - Copy-to-clipboard errors - **Tray sync** - Real-time drag-and-drop sync --- ## Bug Fixes ### Critical Fixes - **Usage script validation** - Boundary checks - **Gemini validation** - Relaxed constraints - **TOML parsing** - CJK quote handling - **MCP fields** - Custom field preservation - **White screen** - FormLabel crash fix ### Stability - **Tray safety** - Pattern matching instead of unwrap - **Error isolation** - Tray failures don't block operations - **Import classification** - Correct category assignment ### UI Fixes - **Model placeholders** - Removed misleading hints - **Base URL** - Auto-fill for third-party providers - **Drag sort** - Tray menu synchronization --- ## Technical Improvements ### Architecture **MCP v3.7.0**: - Removed legacy code (~1,000 lines) - Unified initialization structure - Backward compatibility maintained - Comprehensive code formatting **Platform Compatibility**: - Windows winreg API fix (v0.52) - Safe pattern matching (no `unwrap()`) - Cross-platform tray handling ### Configuration **Synchronization**: - MCP sync across all apps - Gemini form-editor sync - Dual-file reading (.env + settings.json) **Validation**: - Input boundary checks - TOML quote normalization (CJK) - Custom field preservation - Enhanced error messages ### Code Quality **Type Safety**: - Complete TypeScript coverage - Rust type refinements - API contract validation **Testing**: - Simplified assertions - Better test coverage - Integration test updates **Dependencies**: - Tauri 2.8.x - Rust: `anyhow`, `zip`, `serde_yaml`, `tempfile` - Frontend: CodeMirror 6 packages - winreg 0.52 (Windows) --- ## Technical Statistics ``` Total Changes: - Commits: 85 - Files: 152 changed - Additions: +18,104 lines - Deletions: -3,732 lines New Modules: - Skills Management: 2,034 lines (21 files) - Prompts Management: 1,302 lines (20 files) - Gemini Integration: ~1,000 lines - MCP Refactor: ~3,000 lines refactored Code Distribution: - Backend (Rust): ~4,500 lines new - Frontend (React): ~3,000 lines new - Configuration: ~1,500 lines refactored - Tests: ~500 lines ``` --- ## Strategic Positioning ### From Tool to Platform v3.7.0 represents a shift in CC Switch's positioning: | Aspect | v3.6 | v3.7.0 | | ----------------- | ------------------------ | ---------------------------- | | **Identity** | Provider Switcher | AI CLI Management Platform | | **Scope** | Configuration Management | Ecosystem Management | | **Applications** | Claude + Codex | Claude + Codex + Gemini | | **Capabilities** | Switch configs | Extend capabilities (Skills) | | **Customization** | Manual editing | Visual management (Prompts) | | **Integration** | Isolated apps | Unified management (MCP) | ### Six Pillars of AI CLI Management 1. **Configuration Management** - Provider switching and management 2. **Capability Extension** - Skills installation and lifecycle 3. **Behavior Customization** - System prompt presets 4. **Ecosystem Integration** - Deep links and sharing 5. **Multi-AI Support** - Claude/Codex/Gemini 6. **Intelligent Detection** - Conflict prevention --- ## Download & Installation ### System Requirements - **Windows**: Windows 10+ - **macOS**: macOS 10.15 (Catalina)+ - **Linux**: Ubuntu 22.04+ / Debian 11+ / Fedora 34+ / ArchLinux ### Download Links Visit [Releases](https://github.com/farion1231/cc-switch/releases/latest) to download: - **Windows**: `CC-Switch-Windows.msi` or `-Portable.zip` - **macOS**: `CC-Switch-macOS.tar.gz` or `.zip` - **Linux**: `CC-Switch-Linux.AppImage` or `.deb` - **ArchLinux**: `paru -S cc-switch-bin` ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` Update: ```bash brew upgrade --cask cc-switch ``` --- ## Migration Notes ### From v3.6.x **Automatic migration** - No action required, configs are fully compatible ### From v3.1.x or Earlier **Two-step migration required**: 1. First upgrade to v3.2.x (performs one-time migration) 2. Then upgrade to v3.7.0 ### New Features - **Skills**: No migration needed, start fresh - **Prompts**: Auto-import from live files on first launch - **Gemini**: Install Gemini CLI separately if needed - **MCP v3.7.0**: Backward compatible with previous configs --- ## Acknowledgments ### Contributors Thanks to all contributors who made this release possible: - [@YoVinchen](https://github.com/YoVinchen) - Skills & Prompts & Gemini integration implementation - [@farion1231](https://github.com/farion1231) - From developer to issue responder - Community members for testing and feedback ### Sponsors **Z.ai** - GLM CODING PLAN sponsor [Get 10% OFF with this link](https://z.ai/subscribe?ic=8JVLJQFSKB) **PackyCode** - API relay service partner [Register with "cc-switch" code for 10% discount](https://www.packyapi.com/register?aff=cc-switch) **ShanDianShuo** - Local-first AI voice input [Free download](https://shandianshuo.cn) for Mac/Win --- ## Feedback & Support - **Issues**: [GitHub Issues](https://github.com/farion1231/cc-switch/issues) - **Discussions**: [GitHub Discussions](https://github.com/farion1231/cc-switch/discussions) - **Documentation**: [README](../README.md) - **Changelog**: [CHANGELOG.md](../CHANGELOG.md) --- ## What's Next **v3.8.0 Preview** (Tentative): - Local proxy functionality Stay tuned for more updates! --- **Happy Coding!** ================================================ FILE: docs/release-notes/v3.7.1-zh.md ================================================ # CC Switch v3.7.1 > 稳定性增强与用户体验改进 **[English Version →](v3.7.1-en.md)** --- ## v3.7.1 更新内容 **发布日期**:2025-11-22 **代码变更**:17 个文件,+524 / -81 行 ### Bug 修复 - **修复 Skills 第三方仓库安装失败** (#268) 修复使用自定义子目录的 skills 仓库无法安装的问题,支持类似 `ComposioHQ/awesome-claude-skills` 这样带子目录的仓库 - **修复 Gemini 配置持久化问题** 解决在 Gemini 表单中编辑 settings.json 后,切换供应商时修改丢失的问题 - **防止对话框意外关闭** 添加点击遮罩时的保护,避免误操作导致表单数据丢失,影响所有 11 个对话框组件 ### 新增功能 - **Gemini 配置目录支持** (#255) 在设置中添加 Gemini 配置目录选项,支持自定义 `~/.gemini/` 路径 - **ArchLinux 安装支持** (#259) 添加 AUR 安装方式:`paru -S cc-switch-bin` ### 改进 - **Skills 错误消息国际化增强** 新增 28+ 条详细错误消息(中英文),提供具体的解决建议,下载超时从 15 秒延长到 60 秒 - **代码格式化** 应用统一的 Rust 和 TypeScript 代码格式化标准 ### 下载 访问 [Releases](https://github.com/farion1231/cc-switch/releases/latest) 下载最新版本 --- ## v3.7.0 完整更新说明 > 从供应商切换器到 AI CLI 一体化管理平台 **发布日期**:2025-11-19 **提交数量**:从 v3.6.0 开始 85 个提交 **代码变更**:152 个文件,+18,104 / -3,732 行 --- ## 新增功能 ### Gemini CLI 集成 完整支持 Google Gemini CLI,成为第三个支持的应用(Claude Code、Codex、Gemini)。 **核心能力**: - **双文件配置** - 同时支持 `.env` 和 `settings.json` 格式 - **自动检测** - 自动检测 `GOOGLE_GEMINI_BASE_URL`、`GEMINI_MODEL` 等环境变量 - **完整 MCP 支持** - 为 Gemini 提供完整的 MCP 服务器管理 - **深度链接集成** - 通过 `ccswitch://` 协议导入配置 - **系统托盘** - 从托盘菜单快速切换 **供应商预设**: - **Google Official** - 支持 OAuth 认证 - **PackyCode** - 合作伙伴集成 - **自定义** - 完全自定义支持 **技术实现**: - 新增后端模块:`gemini_config.rs`(20KB)、`gemini_mcp.rs` - 表单与环境编辑器同步 - 双文件原子写入 --- ### MCP v3.7.0 统一架构 MCP 管理系统完整重构,实现跨应用统一管理。 **架构改进**: - **统一管理面板** - 单一界面管理 Claude/Codex/Gemini MCP 服务器 - **SSE 传输类型** - 新增 Server-Sent Events 支持 - **智能解析器** - 容错性 JSON 解析 - **格式修正** - 自动修复 Codex `[mcp_servers]` 格式 - **扩展字段** - 保留自定义 TOML 字段 **用户体验**: - 表单中的默认应用选择 - JSON 格式化器用于验证 - 改进的视觉层次 - 更好的错误消息 **导入/导出**: - 统一从三个应用导入 - 双向同步 - 状态保持 --- ### Claude Skills 管理系统 **约 2,000 行代码** - 完整的技能生态平台。 **GitHub 集成**: - 从 GitHub 仓库自动扫描技能 - 预配置仓库: - `ComposioHQ/awesome-claude-skills` - 精选集合 - `anthropics/skills` - Anthropic 官方技能 - `cexll/myclaude` - 社区贡献 - 添加自定义仓库 - 子目录扫描支持(`skillsPath`) **生命周期管理**: - **发现** - 自动检测 `SKILL.md` 文件 - **安装** - 一键安装到 `~/.claude/skills/` - **卸载** - 安全移除并跟踪状态 - **更新** - 检查更新(基础设施已就绪) **技术架构**: - **后端**:`SkillService`(526 行)集成 GitHub API - **前端**:SkillsPage、SkillCard、RepoManager - **UI 组件**:Badge、Card、Table(shadcn/ui) - **状态**:持久化存储在 `config.json` - **国际化**:47+ 个翻译键 --- ### Prompts 管理系统 **约 1,300 行代码** - 完整的系统提示词管理。 **多预设管理**: - 创建无限数量的提示词预设 - 快速在预设间切换 - 同时只能激活一个提示词 - 活动提示词删除保护 **跨应用支持**: - **Claude**:`~/.claude/CLAUDE.md` - **Codex**:`~/.codex/AGENTS.md` - **Gemini**:`~/.gemini/GEMINI.md` **Markdown 编辑器**: - 完整的 CodeMirror 6 集成 - 语法高亮 - 暗色主题(One Dark) - 实时预览 **智能同步**: - **自动写入** - 立即写入 live 文件 - **回填保护** - 切换前保存当前内容 - **自动导入** - 首次启动从 live 文件导入 - **修改保护** - 保留手动修改 **技术实现**: - **后端**:`PromptService`(213 行) - **前端**:PromptPanel(177)、PromptFormModal(160)、MarkdownEditor(159) - **Hooks**:usePromptActions(152 行) - **国际化**:41+ 个翻译键 --- ### 深度链接协议(ccswitch://) 通过 URL 方案一键导入供应商配置。 **功能特性**: - 所有平台的协议注册 - 从共享链接导入 - 生命周期集成 - 安全验证 --- ### 环境变量冲突检测 智能检测和管理配置冲突。 **检测范围**: - **Claude & Codex** - 跨应用冲突 - **Gemini** - 自动发现 - **MCP** - 服务器配置冲突 **管理功能**: - 可视化冲突指示器 - 解决建议 - 覆盖警告 - 更改前备份 --- ## 改进优化 ### 供应商管理 **新增预设**: - **DouBaoSeed** - 字节跳动的豆包 - **Kimi For Coding** - 月之暗面 - **BaiLing** - 百灵 AI - **移除 AnyRouter** - 避免误导 **增强功能**: - Codex 和 Gemini 的模型名称配置 - 供应商备注字段用于组织 - 增强的预设元数据 ### 配置管理 - **通用配置迁移** - 从 localStorage 迁移到 `config.json` - **统一持久化** - 跨所有应用共享 - **自动导入** - 首次启动配置导入 - **回填优先级** - 正确处理 live 文件 ### UI/UX 改进 **设计系统**: - **macOS 原生** - 与系统对齐的配色方案 - **窗口居中** - 默认居中位置 - **视觉优化** - 改进的间距和层次 **交互优化**: - **密码输入** - 修复 Edge/IE 显示按钮 - **URL 溢出** - 修复卡片溢出 - **错误复制** - 可复制到剪贴板的错误 - **托盘同步** - 实时拖放同步 --- ## Bug 修复 ### 关键修复 - **用量脚本验证** - 边界检查 - **Gemini 验证** - 放宽约束 - **TOML 解析** - CJK 引号处理 - **MCP 字段** - 自定义字段保留 - **白屏** - FormLabel 崩溃修复 ### 稳定性 - **托盘安全** - 模式匹配替代 unwrap - **错误隔离** - 托盘失败不阻塞操作 - **导入分类** - 正确的类别分配 ### UI 修复 - **模型占位符** - 移除误导性提示 - **Base URL** - 第三方供应商自动填充 - **拖拽排序** - 托盘菜单同步 --- ## 技术改进 ### 架构 **MCP v3.7.0**: - 移除遗留代码(约 1,000 行) - 统一初始化结构 - 保持向后兼容性 - 全面的代码格式化 **平台兼容性**: - Windows winreg API 修复(v0.52) - 安全模式匹配(无 `unwrap()`) - 跨平台托盘处理 ### 配置 **同步机制**: - 跨所有应用的 MCP 同步 - Gemini 表单-编辑器同步 - 双文件读取(.env + settings.json) **验证增强**: - 输入边界检查 - TOML 引号规范化(CJK) - 自定义字段保留 - 增强的错误消息 ### 代码质量 **类型安全**: - 完整的 TypeScript 覆盖 - Rust 类型改进 - API 契约验证 **测试**: - 简化的断言 - 更好的测试覆盖 - 集成测试更新 **依赖项**: - Tauri 2.8.x - Rust:`anyhow`、`zip`、`serde_yaml`、`tempfile` - 前端:CodeMirror 6 包 - winreg 0.52(Windows) --- ## 技术统计 ``` 总体变更: - 提交数:85 - 文件数:152 个文件变更 - 新增:+18,104 行 - 删除:-3,732 行 新增模块: - Skills 管理:2,034 行(21 个文件) - Prompts 管理:1,302 行(20 个文件) - Gemini 集成:约 1,000 行 - MCP 重构:约 3,000 行重构 代码分布: - 后端(Rust):约 4,500 行新增 - 前端(React):约 3,000 行新增 - 配置:约 1,500 行重构 - 测试:约 500 行 ``` --- ## 战略定位 ### 从工具到平台 v3.7.0 代表了 CC Switch 定位的转变: | 方面 | v3.6 | v3.7.0 | | -------- | -------------- | ----------------------- | | **身份** | 供应商切换器 | AI CLI 管理平台 | | **范围** | 配置管理 | 生态系统管理 | | **应用** | Claude + Codex | Claude + Codex + Gemini | | **能力** | 切换配置 | 扩展能力(Skills) | | **定制** | 手动编辑 | 可视化管理(Prompts) | | **集成** | 孤立应用 | 统一管理(MCP) | ### AI CLI 管理六大支柱 1. **配置管理** - 供应商切换和管理 2. **能力扩展** - Skills 安装和生命周期 3. **行为定制** - 系统提示词预设 4. **生态集成** - 深度链接和共享 5. **多 AI 支持** - Claude/Codex/Gemini 6. **智能检测** - 冲突预防 --- ## 下载与安装 ### 系统要求 - **Windows**:Windows 10+ - **macOS**:macOS 10.15(Catalina)+ - **Linux**:Ubuntu 22.04+ / Debian 11+ / Fedora 34+ / ArchLinux ### 下载链接 访问 [Releases](https://github.com/farion1231/cc-switch/releases/latest) 下载: - **Windows**:`CC-Switch-Windows.msi` 或 `-Portable.zip` - **macOS**:`CC-Switch-macOS.tar.gz` 或 `.zip` - **Linux**:`CC-Switch-Linux.AppImage` 或 `.deb` - **ArchLinux**:`paru -S cc-switch-bin` ### Homebrew(macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` --- ## 迁移说明 ### 从 v3.6.x 升级 **自动迁移** - 无需任何操作,配置完全兼容 ### 从 v3.1.x 或更早版本升级 **需要两步迁移**: 1. 首先升级到 v3.2.x(执行一次性迁移) 2. 然后升级到 v3.7.0 ### 新功能 - **Skills**:无需迁移,全新开始 - **Prompts**:首次启动时从 live 文件自动导入 - **Gemini**:需要单独安装 Gemini CLI - **MCP v3.7.0**:与之前的配置向后兼容 --- ## 致谢 ### 贡献者 感谢所有让这个版本成为可能的贡献者: - [@YoVinchen](https://github.com/YoVinchen) - Skills & Prompts & Gemini 集成实现 - [@farion1231](https://github.com/farion1231) - 从开发沦为 issue 回复机 - 社区成员的测试和反馈 ### 赞助商 **智谱AI** - GLM CODING PLAN 赞助商 [使用此链接购买可享九折优惠](https://www.bigmodel.cn/claude-code?ic=RRVJPB5SII) **PackyCode** - API 中转服务合作伙伴 [使用 "cc-switch" 优惠码注册享 9 折优惠](https://www.packyapi.com/register?aff=cc-switch) **闪电说** - 本地优先的 AI 语音输入法 [免费下载](https://shandianshuo.cn) Mac/Win 双平台 --- ## 反馈与支持 - **问题反馈**:[GitHub Issues](https://github.com/farion1231/cc-switch/issues) - **讨论**:[GitHub Discussions](https://github.com/farion1231/cc-switch/discussions) - **文档**:[README](../README_ZH.md) - **更新日志**:[CHANGELOG.md](../CHANGELOG.md) --- ## 未来展望 **v3.8.0 预览**(暂定): - 本地代理功能 敬请期待更多更新! --- **Happy Coding!** ================================================ FILE: docs/release-notes/v3.8.0-en.md ================================================ # CC Switch v3.8.0 > Persistence Architecture Upgrade, Laying the Foundation for Cloud Sync **[中文版 →](v3.8.0-zh.md) | [日本語版 →](v3.8.0-ja.md)** --- ## Overview CC Switch v3.8.0 is a major architectural upgrade that restructures the data persistence layer and user interface, laying the foundation for future cloud sync and local proxy features. **Release Date**: 2025-11-28 **Commits**: 51 commits since v3.7.1 **Code Changes**: 207 files, +17,297 / -6,870 lines --- ## Major Updates ### Persistence Architecture Upgrade Migrated from single JSON file storage to SQLite + JSON dual-layer architecture for hierarchical data management. **Architecture Changes**: ``` v3.7.x (Old) v3.8.0 (New) ┌─────────────────┐ ┌─────────────────────────────────┐ │ config.json │ │ SQLite (Syncable Data) │ │ ┌───────────┐ │ │ ├─ providers Provider cfg │ │ │ providers │ │ │ ├─ mcp_servers MCP servers │ │ │ mcp │ │ ──> │ ├─ prompts Prompts │ │ │ prompts │ │ │ ├─ skills Skills │ │ │ settings │ │ │ └─ settings General cfg │ │ └───────────┘ │ ├─────────────────────────────────┤ └─────────────────┘ │ JSON (Device-level Data) │ │ └─ settings.json Local settings│ │ ├─ Window position │ │ ├─ Path overrides │ │ └─ Current provider ID │ └─────────────────────────────────┘ ``` **Dual-layer Structure Design**: | Layer | Storage | Data Types | Sync Strategy | | ---------- | ------- | ------------------------------- | --------------- | | Cloud Sync | SQLite | Providers, MCP, Prompts, Skills | Future syncable | | Device | JSON | Window state, local paths | Stays local | **Technical Implementation**: - **Schema Version Management** - Supports database structure upgrade migrations - **SQL Import/Export** - `backup.rs` supports SQL dump for cloud storage - **Transaction Support** - SQLite native transactions ensure data consistency - **Auto Migration** - Automatically migrates from `config.json` on first launch **Modular Refactoring**: ``` database/ ├── mod.rs Core Database struct and initialization ├── schema.rs Table definitions, schema version migrations ├── backup.rs SQL import/export, binary snapshot backup ├── migration.rs JSON → SQLite data migration engine └── dao/ Data Access Object layer ├── providers.rs Provider CRUD ├── mcp.rs MCP server CRUD ├── prompts.rs Prompts CRUD ├── skills.rs Skills CRUD └── settings.rs Key-value settings storage ``` --- ### Brand New User Interface Completely redesigned UI providing a more modern visual experience. **Visual Improvements**: - Redesigned interface layout - Unified component styles - Smoother transition animations - Optimized visual hierarchy **Interaction Enhancements**: - Redesigned header toolbar - Unified ConfirmDialog styling - Disabled overscroll bounce effect on main view - Improved form validation feedback **Compatibility Adjustments**: - Downgraded Tailwind CSS from v4 to v3.4 for better browser compatibility --- ### Japanese Language Support Added Japanese interface support, expanding internationalization to three languages. **Supported Languages**: - Simplified Chinese - English - Japanese (New) --- ## New Features ### Skills Recursive Scanning Skills management system now supports recursive scanning of repository directories, automatically discovering nested skill files. **Improvements**: - Support for multi-level directory structures - Automatic discovery of all `SKILL.md` files - Allow same-named skills from different repositories (using full path for deduplication) --- ### Provider Icon Configuration Provider presets now support custom icon configuration. **Features**: - Preset providers include default icons - Icon settings preserved when duplicating providers - Custom icon colors --- ### Enhanced Form Validation Provider forms now include required field validation with friendlier error messages. **Improvements**: - Real-time validation for required fields - Unified Toast notifications for validation errors - Clearer error messages --- ### Auto Launch on Startup Added auto-launch functionality supporting Windows, macOS, and Linux platforms. **Features**: - One-click enable/disable in settings - Implemented using platform-native APIs - Windows uses Registry, macOS uses LaunchAgent, Linux uses XDG autostart --- ### New Provider Presets - **MiniMax** - Official partner --- ## Bug Fixes ### Critical Fixes **Custom Endpoints Lost Issue** Fixed an issue where custom request URLs were unexpectedly lost when updating providers. - Root Cause: `INSERT OR REPLACE` executes `DELETE + INSERT` under the hood in SQLite, triggering foreign key cascade deletion - Fix: Changed to use `UPDATE` statement for existing providers **Gemini Configuration Issues** - Fixed custom provider environment variables not correctly written to `.env` file - Fixed security auth config incorrectly written to other config files **Provider Validation Issues** - Fixed validation error when current provider ID doesn't exist - Fixed icon fields lost when duplicating providers ### Platform Compatibility **Linux** - Resolved WebKitGTK DMA-BUF rendering issue - Preserve user `.desktop` file customizations ### Other Fixes - Fixed redundant usage queries when switching apps - Fixed DMXAPI preset using wrong auth token field - Fixed missing translation keys in deeplink components - Fixed usage script template initialization logic --- ## Technical Improvements ### Architecture Refactoring **Provider Service Modularization**: ``` services/provider/ ├── mod.rs Core service - add/update/delete/switch/validate ├── live.rs Live config file operations ├── gemini_auth.rs Gemini auth type detection ├── endpoints.rs Custom endpoint management └── usage.rs Usage script execution ``` **Deeplink Modularization**: ``` deeplink/ ├── mod.rs Module exports ├── parser.rs URL parsing ├── provider.rs Provider import logic ├── mcp.rs MCP import logic ├── prompt.rs Prompt import ├── skill.rs Skills import └── utils.rs Utility functions ``` ### Code Quality **Cleanup**: - Removed legacy JSON-era import/export dead code - Removed unused MCP type exports - Unified error handling approach **Test Updates**: - Migrated tests to SQLite database architecture - Updated component tests to match current implementation - Fixed MSW handlers to adapt to new API --- ## Technical Statistics ``` Overall Changes: - Commits: 51 - Files: 207 files changed - Additions: +17,297 lines - Deletions: -6,870 lines - Net: +10,427 lines Commit Type Distribution: - fix: 25 (Bug fixes) - refactor: 11 (Code refactoring) - feat: 9 (New features) - test: 1 (Testing) - other: 5 Change Area Distribution: - Frontend source: 112 files - Rust backend: 63 files - Test files: 20 files - i18n files: 3 files ``` --- ## Migration Guide ### Upgrading from v3.7.x **Auto Migration** - Executes automatically on first launch: 1. Detects if `config.json` exists 2. Migrates all data to SQLite within a transaction 3. Migrates device-level settings to `settings.json` 4. Shows migration success notification **Data Safety**: - Original `config.json` file is preserved (not deleted) - Error dialog displayed on migration failure, `config.json` preserved - Supports Dry-run mode to verify migration logic --- ## Download & Installation ### System Requirements - **Windows**: Windows 10+ - **macOS**: macOS 10.15 (Catalina)+ - **Linux**: Ubuntu 22.04+ / Debian 11+ / Fedora 34+ ### Download Links Visit [Releases](https://github.com/farion1231/cc-switch/releases/latest) to download: - **Windows**: `CC-Switch-v3.8.0-Windows.msi` or `-Portable.zip` - **macOS**: `CC-Switch-v3.8.0-macOS.tar.gz` or `.zip` - **Linux**: `CC-Switch-v3.8.0-Linux.AppImage` or `.deb` ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` Update: ```bash brew upgrade --cask cc-switch ``` ## Acknowledgments ### Contributors Thanks to all contributors who made this release possible: - [@YoVinchen](https://github.com/YoVinchen) - UI and database refactoring - [@farion1231](https://github.com/farion1231) - Bug fixes and feature enhancements - Community members for testing and feedback ### Sponsors **Zhipu AI** - GLM CODING PLAN Sponsor [Get 10% off with this link](https://z.ai/subscribe?ic=8JVLJQFSKB) **PackyCode** - API Relay Service Partner [Use code "cc-switch" for 10% off registration](https://www.packyapi.com/register?aff=cc-switch) **ShandianShuo** - Local-first AI Voice Input [Free download](https://shandianshuo.cn) for Mac/Windows **MiniMax** - MiniMax M2 CODING PLAN Sponsor [Black Friday sale, plans starting at $2](https://platform.minimax.io/subscribe/coding-plan) --- ## Feedback & Support - **Issue Reports**: [GitHub Issues](https://github.com/farion1231/cc-switch/issues) - **Discussions**: [GitHub Discussions](https://github.com/farion1231/cc-switch/discussions) - **Documentation**: [README](../README.md) - **Changelog**: [CHANGELOG.md](../CHANGELOG.md) --- ## Future Roadmap **v3.9.0 Preview** (Tentative): - Local proxy feature Stay tuned for more updates! --- **Happy Coding!** ================================================ FILE: docs/release-notes/v3.8.0-ja.md ================================================ # CC Switch v3.8.0 > 永続化アーキテクチャを刷新し、クラウド同期の土台を構築 **[English →](v3.8.0-en.md) | [中文版 →](v3.8.0-zh.md)** --- ## 概要 CC Switch v3.8.0 はデータ永続化レイヤーと UI を大幅に作り替え、今後のクラウド同期やローカルプロキシ機能に向けた基盤を整えたメジャーアップデートです。 **リリース日**: 2025-11-28 **コミット数**: v3.7.1 以降 51 commits **変更量**: 207 files, +17,297 / -6,870 lines --- ## 主要アップデート ### 永続化アーキテクチャの刷新 単一の JSON 保存から、階層化された SQLite + JSON の二層構造へ移行。 **アーキテクチャ変更**: ``` v3.7.x (旧) v3.8.0 (新) ┌─────────────────┐ ┌─────────────────────────────────┐ │ config.json │ │ SQLite (同期対象データ) │ │ ┌───────────┐ │ │ ├─ providers プロバイダ設定 │ │ │ providers │ │ │ ├─ mcp_servers MCP サーバー │ │ │ mcp │ │ ──> │ ├─ prompts プロンプト │ │ │ prompts │ │ │ ├─ skills Skills │ │ │ settings │ │ │ └─ settings 汎用設定 │ │ └───────────┘ │ ├─────────────────────────────────┤ └─────────────────┘ │ JSON (デバイス固有データ) │ │ └─ settings.json ローカル設定 │ │ ├─ ウィンドウ位置 │ │ ├─ パスの上書き │ │ └─ 現在のプロバイダ ID │ └─────────────────────────────────┘ ``` **二層構造の設計**: | レイヤー | ストレージ | データ種別 | 同期戦略 | | -------- | ---------- | ----------------------------------- | ---------------- | | クラウド | SQLite | Providers, MCP, Prompts, Skills | 将来同期対象 | | デバイス | JSON | ウィンドウ状態、ローカルパス | ローカル保持 | **実装ポイント**: - **スキーマバージョン管理**: DB 構造のマイグレーションに対応 - **SQL インポート/エクスポート**: `backup.rs` が SQL ダンプをサポート - **トランザクション対応**: SQLite ネイティブで整合性を確保 - **自動マイグレーション**: 初回起動で `config.json` から自動移行 **モジュール分割**: ``` database/ ├── mod.rs Database 構造体と初期化 ├── schema.rs テーブル定義とスキーマ移行 ├── backup.rs SQL インポート/エクスポートとスナップショット ├── migration.rs JSON → SQLite 変換エンジン └── dao/ DAO レイヤー ├── providers.rs プロバイダ CRUD ├── mcp.rs MCP CRUD ├── prompts.rs プロンプト CRUD ├── skills.rs Skills CRUD └── settings.rs 設定 Key-Value 保存 ``` --- ### 新しいユーザーインターフェース よりモダンな見た目と操作感に再設計。 - レイアウト全面刷新、コンポーネントスタイルを統一 - トランジションを滑らかにし、視覚的階層を最適化 - メインビューのオーバースクロールバウンスを無効化 - ブラウザ互換性向上のため Tailwind CSS を v4→v3.4 にダウングレード --- ### 日語化 UI が日本語に対応し、国際化が 3 言語(中/英/日)へ拡大。 --- ## 新機能 ### Skills 递帰スキャン Skills 管理がリポジトリを再帰的に走査し、ネストされた `SKILL.md` を自動検出。 - 複数階層のディレクトリに対応 - すべての `SKILL.md` を自動発見 - パスをキーにした重複排除で同名スキルを許容 ### プロバイダアイコン設定 プリセットがデフォルトアイコンを持ち、複製してもアイコンを保持。カスタム色も設定可能。 ### フォームバリデーション強化 必須項目にリアルタイム検証と分かりやすいエラーメッセージを追加し、トースト通知を統一。 ### 自動起動 Windows/macOS/Linux で自動起動をサポート。 - 設定画面からワンクリックで ON/OFF - Registry / LaunchAgent / XDG autostart を使用 ### 新プロバイダプリセット - **MiniMax** - 公式パートナー --- ## バグ修正 ### 重要修正 **カスタムエンドポイント消失** - 原因: SQLite の `INSERT OR REPLACE` が内部で `DELETE + INSERT` を実行し、外部キーのカスケード削除が発生 - 対応: 既存プロバイダ更新を `UPDATE` に変更 **Gemini 設定** - カスタム環境変数が `.env` に正しく書き込まれない問題を修正 - 認証設定が他ファイルに誤って書き込まれる問題を修正 **プロバイダ検証** - 現在プロバイダ ID が欠落している場合のバリデーションエラーを修正 - 複製時にアイコンフィールドが失われる問題を修正 ### プラットフォーム互換性 **Linux** - WebKitGTK の DMA-BUF 描画問題を解消 - ユーザーの `.desktop` カスタマイズを保持 ### その他修正 - アプリ切り替え時の不要な使用量クエリを削減 - DMXAPI プリセットの誤ったトークンフィールドを修正 - Deeplink コンポーネントの欠損翻訳キーを補完 - 使用量スクリプトテンプレート初期化を修正 --- ## 技術的改善 ### アーキテクチャ再編 **Provider Service のモジュール化**: ``` services/provider/ ├── mod.rs 追加/更新/削除/切替/検証の中核 ├── live.rs ライブ設定ファイル操作 ├── gemini_auth.rs Gemini 認証タイプ検出 ├── endpoints.rs カスタムエンドポイント管理 └── usage.rs 使用量スクリプト実行 ``` **Deeplink のモジュール化**: ``` deeplink/ ├── mod.rs エクスポート ├── parser.rs URL パース ├── provider.rs プロバイダ取り込み ├── mcp.rs MCP 取り込み ├── prompt.rs プロンプト取り込み ├── skill.rs Skills 取り込み └── utils.rs ユーティリティ ``` ### コード品質 - レガシーな JSON 時代のインポート/エクスポート死蔵コードを削除 - 使われていない MCP 型を削除し、エラーハンドリングを統一 - テストを SQLite バックエンドに移行し、MSW ハンドラを最新 API に合わせて更新 --- ## 技術統計 ``` 全体変更: - コミット: 51 - 変更ファイル: 207 - 追加: +17,297 行 - 削除: -6,870 行 - 純増: +10,427 行 コミット種別: - fix: 25 - refactor: 11 - feat: 9 - test: 1 - other: 5 変更箇所: - フロントエンド: 112 files - Rust バックエンド: 63 files - テスト: 20 files - i18n: 3 files ``` --- ## マイグレーションガイド ### v3.7.x からのアップグレード **自動マイグレーション**(初回起動時): 1. `config.json` の存在を検出 2. 全データをトランザクションで SQLite に移行 3. デバイス設定を `settings.json` へ移行 4. 移行成功の通知を表示 **データ保護**: - 元の `config.json` は保持(削除しない) - 失敗時はエラーダイアログを表示し、`config.json` を温存 - Dry-run モードで検証可能 --- ## ダウンロード & インストール ### システム要件 - **Windows**: Windows 10+ - **macOS**: macOS 10.15 (Catalina)+ - **Linux**: Ubuntu 22.04+ / Debian 11+ / Fedora 34+ ### ダウンロード [Releases](https://github.com/farion1231/cc-switch/releases/latest) から入手: - **Windows**: `CC-Switch-v3.8.0-Windows.msi` または `-Portable.zip` - **macOS**: `CC-Switch-v3.8.0-macOS.tar.gz` または `.zip` - **Linux**: `CC-Switch-v3.8.0-Linux.AppImage` または `.deb` ### Homebrew (macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` アップデート: ```bash brew upgrade --cask cc-switch ``` --- ## 謝辞 ### コントリビューター - [@YoVinchen](https://github.com/YoVinchen) - UI とデータベースリファクタ - [@farion1231](https://github.com/farion1231) - バグ修正と機能拡張 - コミュニティの皆さん - テストとフィードバック ### スポンサー **Zhipu AI** - GLM CODING PLAN スポンサー [10% オフリンク](https://z.ai/subscribe?ic=8JVLJQFSKB) **PackyCode** - API リレーサービスパートナー [登録時に「cc-switch」で 10% オフ](https://www.packyapi.com/register?aff=cc-switch) **ShandianShuo** - ローカルファースト音声入力 [Mac/Windows 無料ダウンロード](https://shandianshuo.cn) **MiniMax** - MiniMax M2 CODING PLAN スポンサー [ブラックフライデーセール中、$2 から](https://platform.minimax.io/subscribe/coding-plan) --- ## フィードバック & サポート - **Issue**: [GitHub Issues](https://github.com/farion1231/cc-switch/issues) - **Discussions**: [GitHub Discussions](https://github.com/farion1231/cc-switch/discussions) - **ドキュメント**: [README](../README.md) - **更新履歴**: [CHANGELOG.md](../CHANGELOG.md) --- ## 今後のロードマップ **v3.9.0 予告(予定)**: - ローカルプロキシ機能 続報にご期待ください! --- **Happy Coding!** ================================================ FILE: docs/release-notes/v3.8.0-zh.md ================================================ # CC Switch v3.8.0 > 持久化架构升级,为云同步奠定基础 **[English Version →](v3.8.0-en.md)** --- ## 概览 CC Switch v3.8.0 是一次重大的架构升级版本,重构了数据持久化层和用户界面,为未来的云同步和本地代理功能奠定基础。 **发布日期**:2025-11-28 **提交数量**:从 v3.7.1 开始 51 个提交 **代码变更**:207 个文件,+17,297 / -6,870 行 --- ## 重大更新 ### 持久化架构升级 从单一 JSON 文件存储迁移到 SQLite + JSON 双层架构,实现数据分层管理。 **架构变更**: ``` v3.7.x (旧) v3.8.0 (新) ┌─────────────────┐ ┌─────────────────────────────────┐ │ config.json │ │ SQLite (可同步数据) │ │ ┌───────────┐ │ │ ├─ providers 供应商配置 │ │ │ providers │ │ │ ├─ mcp_servers MCP 服务器 │ │ │ mcp │ │ ──> │ ├─ prompts 提示词 │ │ │ prompts │ │ │ ├─ skills 技能 │ │ │ settings │ │ │ └─ settings 通用设置 │ │ └───────────┘ │ ├─────────────────────────────────┤ └─────────────────┘ │ JSON (设备级数据) │ │ └─ settings.json 本地设置 │ │ ├─ 窗口位置 │ │ ├─ 路径覆盖 │ │ └─ 当前选中供应商 ID │ └─────────────────────────────────┘ ``` **双层结构设计**: | 层级 | 存储方式 | 数据类型 | 同步策略 | | -------- | -------- | ---------------------------- | ---------- | | 云同步层 | SQLite | 供应商、MCP、Prompts、Skills | 未来可同步 | | 设备层 | JSON | 窗口状态、本地路径、当前选择 | 保持本地 | **技术实现**: - **Schema 版本管理** - 支持数据库结构升级迁移 - **SQL 导入导出** - `backup.rs` 支持 SQL dump,便于云端存储 - **事务支持** - SQLite 原生事务保证数据一致性 - **自动迁移** - 首次启动自动从 `config.json` 迁移数据 **模块化重构**: ``` database/ ├── mod.rs 核心 Database 结构体和初始化 ├── schema.rs 表结构定义、Schema 版本迁移 ├── backup.rs SQL 导入导出、二进制快照备份 ├── migration.rs JSON → SQLite 数据迁移引擎 └── dao/ 数据访问对象层 ├── providers.rs 供应商 CRUD ├── mcp.rs MCP 服务器 CRUD ├── prompts.rs 提示词 CRUD ├── skills.rs Skills CRUD └── settings.rs 键值对设置存储 ``` --- ### 全新用户界面 完整重构的 UI 设计,提供更现代化的视觉体验。 **视觉改进**: - 重新设计的界面布局 - 统一的组件样式 - 更流畅的过渡动画 - 优化的视觉层次 **交互优化**: - Header toolbar 重新设计 - ConfirmDialog 样式统一 - 禁用主视图 overscroll 弹跳效果 - 改进的表单验证反馈 **兼容性调整**: - Tailwind CSS 从 v4 降级到 v3.4,提升浏览器兼容性 --- ### 日语支持 新增日语(日本語)界面支持,国际化语言扩展到三种。 **支持语言**: - 简体中文 - English - 日本語(新增) --- ## 新增功能 ### Skills 递归扫描 Skills 管理系统支持递归扫描仓库目录,自动发现嵌套的技能文件。 **改进内容**: - 支持多层目录结构 - 自动发现所有 `SKILL.md` 文件 - 允许不同仓库的同名技能(使用完整路径去重) --- ### 供应商图标配置 供应商预设支持自定义图标配置。 **功能特性**: - 预设供应商包含默认图标 - 复制供应商时保留图标设置 - 图标颜色自定义 --- ### 表单验证增强 供应商表单新增必填字段验证,提供更友好的错误提示。 **改进内容**: - 必填字段实时校验 - 统一使用 Toast 通知显示验证错误 - 更清晰的错误信息 --- ### 开机自启 新增开机自动启动功能,支持 Windows、macOS 和 Linux 三个平台。 **功能特性**: - 在设置中一键开启/关闭 - 使用平台原生 API 实现 - Windows 使用注册表、macOS 使用 LaunchAgent、Linux 使用 XDG autostart --- ### 新增供应商预设 - **MiniMax** - 官方合作伙伴 --- ## Bug 修复 ### 关键修复 **自定义端点丢失问题** 修复更新供应商时自定义请求地址意外丢失的问题。 - 根因:`INSERT OR REPLACE` 在 SQLite 底层执行 `DELETE + INSERT`,触发外键级联删除 - 修复:改用 `UPDATE` 语句更新已存在的供应商 **Gemini 配置问题** - 修复自定义供应商环境变量未正确写入 `.env` 文件 - 修复安全认证配置错误写入到其他配置文件 **供应商验证问题** - 修复当前供应商 ID 不存在时的验证错误 - 修复供应商复制时图标字段丢失 ### 平台兼容性 **Linux** - 解决 WebKitGTK DMA-BUF 渲染问题 - 保留用户 `.desktop` 文件自定义 ### 其他修复 - 修复切换应用时的冗余用量查询 - 修复 DMXAPI 预设使用错误的认证令牌字段 - 修复深链接组件缺少翻译键 - 修复用量脚本模板初始化逻辑 --- ## 技术改进 ### 架构重构 **供应商服务模块化**: ``` services/provider/ ├── mod.rs 核心服务 - add/update/delete/switch/validate ├── live.rs Live 配置文件操作 ├── gemini_auth.rs Gemini 认证类型检测 ├── endpoints.rs 自定义端点管理 └── usage.rs 用量脚本执行 ``` **深链接模块化**: ``` deeplink/ ├── mod.rs 模块导出 ├── parser.rs URL 解析 ├── provider.rs 供应商导入逻辑 ├── mcp.rs MCP 导入逻辑 ├── prompt.rs 提示词导入 ├── skill.rs Skills 导入 └── utils.rs 工具函数 ``` ### 代码质量 **清理工作**: - 移除 JSON 时代遗留的导入导出死代码 - 移除未使用的 MCP 类型导出 - 统一错误处理方式 **测试更新**: - 迁移测试到 SQLite 数据库架构 - 更新组件测试匹配当前实现 - 修复 MSW handlers 适配新 API --- ## 技术统计 ``` 总体变更: - 提交数:51 - 文件数:207 个文件变更 - 新增:+17,297 行 - 删除:-6,870 行 - 净增:+10,427 行 提交类型分布: - fix:25 个(Bug 修复) - refactor:11 个(代码重构) - feat:9 个(新功能) - test:1 个(测试) - 其他:5 个 改动区域分布: - 前端源码:112 个文件 - Rust 后端:63 个文件 - 测试文件:20 个文件 - 国际化文件:3 个文件 ``` --- ## 迁移说明 ### 从 v3.7.x 升级 **自动迁移** - 首次启动时自动执行: 1. 检测 `config.json` 是否存在 2. 在事务中迁移所有数据到 SQLite 3. 设备级设置迁移到 `settings.json` 4. 显示迁移成功通知 **数据安全**: - 原 `config.json` 文件保留不删除 - 迁移失败时显示错误对话框,保留`config.json` - 支持 Dry-run 模式验证迁移逻辑 --- ## 下载与安装 ### 系统要求 - **Windows**:Windows 10+ - **macOS**:macOS 10.15(Catalina)+ - **Linux**:Ubuntu 22.04+ / Debian 11+ / Fedora 34+ ### 下载链接 访问 [Releases](https://github.com/farion1231/cc-switch/releases/latest) 下载: - **Windows**:`CC-Switch-v3.8.0-Windows.msi` 或 `-Portable.zip` - **macOS**:`CC-Switch-v3.8.0-macOS.tar.gz` 或 `.zip` - **Linux**:`CC-Switch-v3.8.0-Linux.AppImage` 或 `.deb` ### Homebrew(macOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ## 致谢 ### 贡献者 感谢所有让这个版本成为可能的贡献者: - [@YoVinchen](https://github.com/YoVinchen) - UI 和数据库重构 - [@farion1231](https://github.com/farion1231) - BUG 修复和功能增强 - 社区成员的测试和反馈 ### 赞助商 **智谱AI** - GLM CODING PLAN 赞助商 [使用此链接购买可享九折优惠](https://www.bigmodel.cn/claude-code?ic=RRVJPB5SII) **PackyCode** - API 中转服务合作伙伴 [使用 "cc-switch" 优惠码注册享 9 折优惠](https://www.packyapi.com/register?aff=cc-switch) **闪电说** - 本地优先的 AI 语音输入法 [免费下载](https://shandianshuo.cn) Mac/Win 双平台 **MiniMax** - MiniMax M2 CODING PLAN 赞助商 [黑五优惠进行中,套餐9.9元起](https://platform.minimaxi.com/subscribe/coding-plan) --- ## 反馈与支持 - **问题反馈**:[GitHub Issues](https://github.com/farion1231/cc-switch/issues) - **讨论**:[GitHub Discussions](https://github.com/farion1231/cc-switch/discussions) - **文档**:[README](../README_ZH.md) - **更新日志**:[CHANGELOG.md](../CHANGELOG.md) --- ## 未来展望 **v3.9.0 预览**(暂定): - 本地代理功能 敬请期待更多更新! --- **Happy Coding!** ================================================ FILE: docs/release-notes/v3.9.0-en.md ================================================ # CC Switch v3.9.0 > Local API Proxy, Auto Failover, Universal Provider, and a more complete multi-app workflow **[中文版 →](v3.9.0-zh.md) | [日本語版 →](v3.9.0-ja.md)** --- ## Overview CC Switch v3.9.0 is the stable release of the v3.9 beta series (`3.9.0-1`, `3.9.0-2`, `3.9.0-3`). It introduces a local API proxy with per-app takeover, automatic failover, universal providers, and many stability and UX improvements across Claude Code, Codex, and Gemini CLI. **Release Date**: 2026-01-07 --- ## Highlights - Local API Proxy for Claude Code / Codex / Gemini CLI - Auto Failover with circuit breaker and per-app failover queues - Universal Provider: one shared config synced across apps (ideal for API gateways like NewAPI) - Skills improvements: multi-app support, unified management with SSOT + React Query - Common config snippets: extract reusable snippets from the editor or the current provider - MCP import: import MCP servers from installed apps - Usage improvements: auto-refresh, cache hit/creation metrics, and timezone fixes - Linux packaging: RPM and Flatpak artifacts --- ## Major Features ### Local API Proxy - Runs a local high-performance HTTP proxy server (Axum-based) - Supports Claude Code, Codex, and Gemini CLI with a unified proxy - Per-app takeover: you can independently decide which app routes through the proxy - Live config takeover: backs up and redirects the CLI live config to the local proxy when takeover is enabled - Monitoring: request logging and usage statistics for easier debugging and cost tracking - Error request logging: keep detailed logs for failed proxy requests to simplify debugging (#401, thanks @yovinchen) ### Auto Failover (Circuit Breaker) - Automatically detects provider failures and triggers protection (circuit breaker) - Automatically switches to a backup provider when the current one is unhealthy - Tracks provider health in real time, and keeps independent failover queues per app - When failover is disabled, timeout/retry related settings no longer affect normal request flow ### Skills Management - Multi-app Skills support for Claude Code and Codex, with smoother migration from older skill layouts (#365, #378, thanks @yovinchen) - Unified Skills management architecture (SSOT + React Query) for more consistent state and refresh behavior - Better discovery UX and performance: - Skip hidden directories during discovery - Faster discovery with long-lived caching for discoverable skills - Clear loading indicators and more discoverable header actions (import/refresh) - Fix wrong skill repo branch (#505, thanks @kjasn) ### Universal Provider - Add a shared provider configuration that can sync to Claude/Codex/Gemini (#348, thanks @Calcium-Ion) - Designed for API gateways that support multiple protocols (e.g., NewAPI) - Allows per-app default model mapping under a single provider ### Common Config Snippets (Claude/Codex/Gemini) - Maintain a reusable "common config" snippet and merge/append it into providers that enable it - New extraction workflow: - Extract from the editor content (what you are currently editing) - Or extract from the current active provider when the editor content is not provided - Codex extraction is safer: - Removes provider-specific sections like `model_provider`, `model`, and the entire `model_providers` table - Preserves `base_url` under `[mcp_servers.*]` so MCP configs are not accidentally broken ### MCP Management - Import MCP servers from installed apps - Improve robustness: skip sync when the target CLI app is not installed; handle invalid Codex `config.toml` gracefully (#461, thanks @majiayu000) - Windows compatibility: wrap npx/npm commands with `cmd /c` for MCP export ### Usage & Pricing - Usage & pricing improvements: auto-refresh, cache hit/creation metrics, timezone handling fixes, and refreshed built-in pricing table (#508, thanks @yovinchen) - DeepLink support: import usage query configuration via deeplink (#400, thanks @qyinter) - Model extraction for usage statistics (#455, thanks @yovinchen) - Usage query credentials can fall back to provider config (#360, thanks @Sirhexs) --- ## UX Improvements - Provider search filter: quickly find providers by name (#435, thanks @TinsFox) - Provider icon colors: customize provider icon colors for quicker visual identification (#385, thanks @yovinchen) - Keyboard shortcut: `Cmd/Ctrl + ,` opens Settings (#436, thanks @TinsFox) - Skip Claude Code first-run confirmation dialog (optional) - Closable toasts: close buttons for switch toast and all success toasts (#350, thanks @ForteScarlet) - Update badge navigation: clicking the update badge opens the About tab - Settings page tab style improvements (#342, thanks @wenyuanw) - Smoother transitions: fade transitions for app/view switching and exit animations for panels - Proxy takeover active theme: apply an emerald theme while takeover is active - Dark mode readability improvements for forms and labels - Better window dragging area for full-screen panels (#525, thanks @zerob13) --- ## Platform Notes ### Windows - Prevent terminal windows from appearing during version checks - Improve window sizing defaults (minimum width/height) - Fix black screen on startup by using the system titlebar - Add a fallback for `crypto.randomUUID()` on older WebViews ### macOS - Use `.app` bundle path for autostart to avoid terminal window popups (#462, thanks @majiayu000) - Improve tray/icon behavior and header alignment --- ## Packaging - Linux: RPM and Flatpak packaging targets are now available for building release artifacts --- ## Notes - Security improvements for the JavaScript executor and usage script execution (#151, thanks @luojiyin1987). - SQL import is restricted to CC Switch exported backups to reduce the risk of importing unsafe or incompatible SQL dumps. - Proxy takeover modifies CLI live configs; CC Switch will back up the live config before redirecting it to the local proxy. If you want to revert, disable takeover/stop the proxy and restore from the backup when needed. ## Special Thanks Special thanks to @xunyu @deijing @su-fen for their support and contributions. This release wouldn't be possible without you! ## Download & Installation Visit [Releases](https://github.com/farion1231/cc-switch/releases/latest) to download the appropriate version. ### System Requirements | System | Minimum Version | Architecture | | ------- | ------------------------------- | ----------------------------------- | | Windows | Windows 10 or later | x64 | | macOS | macOS 10.15 (Catalina) or later | Intel (x64) / Apple Silicon (arm64) | | Linux | See table below | x64 | ### Windows | File | Description | | --------------------------------------- | -------------------------------------------------- | | `CC-Switch-v3.9.0-Windows.msi` | **Recommended** - MSI installer with auto-update support | | `CC-Switch-v3.9.0-Windows-Portable.zip` | Portable version, no installation required | ### macOS | File | Description | | ------------------------------- | ----------------------------------------------------------------- | | `CC-Switch-v3.9.0-macOS.zip` | **Recommended** - Extract and drag to Applications, Universal Binary | | `CC-Switch-v3.9.0-macOS.tar.gz` | For Homebrew installation and auto-update | > **Note**: Since the author does not have an Apple Developer account, you may see an "unidentified developer" warning on first launch. Close the app, then go to "System Settings" → "Privacy & Security" → click "Open Anyway", and it will open normally afterwards. ### Homebrew (MacOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` Update: ```bash brew upgrade --cask cc-switch ``` ### Linux | Distribution | Recommended Format | Installation | | --------------------------------------- | ------------------ | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` or `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` or `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | Make executable and run directly, or use AUR | | Other distros / Unsure | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | | Sandboxed installation | `.flatpak` | `flatpak install CC-Switch-*.flatpak` | ================================================ FILE: docs/release-notes/v3.9.0-ja.md ================================================ # CC Switch v3.9.0 > ローカル API プロキシ、自動フェイルオーバー、Universal Provider、多アプリ対応の強化 **[English →](v3.9.0-en.md) | [中文版 →](v3.9.0-zh.md)** --- ## 概要 CC Switch v3.9.0 は v3.9 ベータ(`3.9.0-1`、`3.9.0-2`、`3.9.0-3`)の安定版です。 ローカル API プロキシ(アプリ別テイクオーバー対応)、自動フェイルオーバー、Universal Provider を追加し、Claude Code / Codex / Gemini CLI の安定性と操作性を大きく改善しました。 **リリース日**:2026-01-07 --- ## ハイライト - ローカル API プロキシ:Claude Code / Codex / Gemini CLI を統一的にプロキシ - 自動フェイルオーバー:サーキットブレーカーとアプリ別のフェイルオーバーキュー - Universal Provider:1つの設定を複数アプリへ同期(NewAPI などのゲートウェイ向け) - Skills の改善:マルチアプリ対応、SSOT + React Query による管理の統一 - 共通設定スニペット:エディタ内容または現在のプロバイダから抽出 - MCP インポート:インストール済みアプリから MCP servers を取り込み - 使用量の改善:自動更新、キャッシュ指標、タイムゾーン修正 - Linux パッケージ:RPM / Flatpak の成果物を追加 --- ## 主要機能 ### ローカル API プロキシ(Local API Proxy) - ローカルで高性能な HTTP プロキシサーバーを起動(Axum ベース) - Claude Code / Codex / Gemini CLI の API リクエストを統一的に扱う - アプリ別テイクオーバー:アプリごとにプロキシ経由にするかを個別に切り替え可能 - Live 設定テイクオーバー:有効化時に CLI の live 設定をバックアップし、ローカルプロキシへリダイレクト - 監視:リクエストログと使用量統計でデバッグとコスト把握を支援 - エラーリクエストのログ:失敗したプロキシリクエストも詳細に記録してデバッグを容易に(#401、@yovinchen に感謝) ### 自動フェイルオーバー(Auto Failover / サーキットブレーカー) - 障害を検知して保護(サーキットブレーカー)を自動で発動 - 現在のプロバイダが不調な場合、バックアッププロバイダへ自動切り替え - アプリごとに独立したフェイルオーバーキューとヘルス状態を管理 - フェイルオーバーを無効化している場合、タイムアウト/リトライ関連の設定は通常フローに影響しません ### Skills 管理 - Claude Code と Codex の Skills をマルチアプリで利用可能にし、旧レイアウトからの移行もよりスムーズに(#365、#378、@yovinchen に感謝) - SSOT + React Query による Skills 管理の統一で、状態の一貫性と更新挙動を改善 - Discovery の体験と性能を改善: - スキャン時に隠しディレクトリをスキップ - Discoverable skills に長寿命キャッシュを適用して高速化 - ローディング表示の改善と、インポート/更新などの操作導線を整理 - Skills リポジトリのブランチ設定を修正(#505、@kjasn に感謝) ### Universal Provider - 複数アプリで共有できるプロバイダ設定を追加(Claude/Codex/Gemini へ同期)(#348、@Calcium-Ion に感謝) - NewAPI のような複数プロトコル対応の API ゲートウェイを想定 - 1つのプロバイダ内でアプリ別にデフォルトモデルを割り当て可能 ### 共通設定スニペット(Claude/Codex/Gemini) - 「共通設定スニペット」を保持し、有効化したプロバイダへマージ/追記 - 新しい抽出フロー: - エディタの現在内容から抽出(編集している内容) - エディタ内容がない場合は、現在アクティブなプロバイダから抽出 - Codex の抽出はより安全: - `model_provider`、`model`、および `model_providers` テーブル全体など、プロバイダ固有の設定を除去 - `[mcp_servers.*]` 配下の `base_url` は保持し、MCP 設定を壊しにくくしています ### MCP 管理 - インストール済みアプリから MCP servers をインポート - 安定性向上:対象 CLI が未インストールなら同期をスキップし、無効な Codex `config.toml` も適切に扱います(#461、@majiayu000 に感謝) - Windows 互換性:MCP エクスポート時の npx/npm 呼び出しを `cmd /c` でラップ ### 使用量と価格データ - 使用量/価格の改善:自動更新、キャッシュ指標、タイムゾーン修正、内蔵価格テーブル更新(#508、@yovinchen に感謝) - DeepLink 対応:deeplink から使用量クエリ設定をインポート(#400、@qyinter に感謝) - 使用量統計からモデル情報を抽出(#455、@yovinchen に感謝) - 使用量クエリ資格情報はプロバイダ設定へフォールバック可能(#360、@Sirhexs に感謝) --- ## 使い勝手の改善 - プロバイダ検索フィルター(名前で素早く検索)(#435、@TinsFox に感謝) - プロバイダのアイコン色:アイコンに任意の色を設定して見分けやすく(#385、@yovinchen に感謝) - ショートカット:`Cmd/Ctrl + ,` で設定を開く(#436、@TinsFox に感謝) - Claude Code の初回確認ダイアログをスキップ可能(任意) - トースト通知のクローズボタン:切り替え通知と成功通知を閉じられるように(#350、@ForteScarlet に感謝) - 更新バッジをクリックすると About タブへ移動 - 設定ページのタブスタイル改善(#342、@wenyuanw に感謝) - アプリ/ビュー切り替えのフェードとパネル終了アニメーション - プロキシテイクオーバー中はエメラルド系テーマを適用して状態を分かりやすく - ダークモードの視認性改善 - FullScreenPanel のウィンドウドラッグ領域を改善(#525、@zerob13 に感謝) --- ## プラットフォーム別メモ ### Windows - バージョンチェック時にターミナルが表示されないよう改善 - ウィンドウ最小サイズのデフォルトを調整 - 起動時の黒画面を避けるため、システムタイトルバー方式を採用 - 古い WebView 向けに `crypto.randomUUID()` のフォールバックを追加 ### macOS - 自動起動で `.app` バンドルパスを使用し、ターミナル表示を回避(#462、@majiayu000 に感謝) - トレイとヘッダー周りの体験を改善 --- ## パッケージ - Linux:RPM と Flatpak のパッケージングを追加し、リリース成果物の生成に対応 --- ## 注意事項 - セキュリティ強化:JavaScript 実行器と使用量スクリプト実行に関するセキュリティ問題を修正(#151、@luojiyin1987 に感謝)。 - SQL インポートは CC Switch がエクスポートしたバックアップのみに制限されます(安全性のため)。 - プロキシのテイクオーバーは CLI の live 設定を変更します。CC Switch はリダイレクト前に live 設定をバックアップします。元に戻す場合はテイクオーバー無効化/プロキシ停止を行い、必要に応じてバックアップから復元してください。 ## 特別な謝辞 @xunyu @deijing @su-fen の皆様のサポートと貢献に特別な感謝を申し上げます。皆様なしではこのリリースは実現しませんでした! ## ダウンロード & インストール [Releases](https://github.com/farion1231/cc-switch/releases/latest) から該当するバージョンをダウンロードしてください。 ### システム要件 | システム | 最低バージョン | アーキテクチャ | | -------- | ----------------------------- | ----------------------------------- | | Windows | Windows 10 以降 | x64 | | macOS | macOS 10.15 (Catalina) 以降 | Intel (x64) / Apple Silicon (arm64) | | Linux | 下表参照 | x64 | ### Windows | ファイル | 説明 | | --------------------------------------- | -------------------------------------------- | | `CC-Switch-v3.9.0-Windows.msi` | **推奨** - MSI インストーラー、自動更新対応 | | `CC-Switch-v3.9.0-Windows-Portable.zip` | ポータブル版、インストール不要 | ### macOS | ファイル | 説明 | | ------------------------------- | ----------------------------------------------------------------- | | `CC-Switch-v3.9.0-macOS.zip` | **推奨** - 解凍して Applications へドラッグ、Universal Binary | | `CC-Switch-v3.9.0-macOS.tar.gz` | Homebrew インストールおよび自動更新用 | > **注意**: 作者が Apple Developer アカウントを持っていないため、初回起動時に「開発元が未確認」という警告が表示される場合があります。アプリを閉じてから、「システム設定」→「プライバシーとセキュリティ」→「このまま開く」をクリックすると、正常に開けるようになります。 ### Homebrew (MacOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` アップデート: ```bash brew upgrade --cask cc-switch ``` ### Linux | ディストリビューション | 推奨形式 | インストール方法 | | --------------------------------------- | ----------- | ------------------------------------------------------------------------------ | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` または `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` または `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 実行権限を付与して直接実行、または AUR を使用 | | その他 / 不明 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | | サンドボックスで実行したい場合 | `.flatpak` | `flatpak install CC-Switch-*.flatpak` | ================================================ FILE: docs/release-notes/v3.9.0-zh.md ================================================ # CC Switch v3.9.0 > 本地 API 代理、自动故障切换、统一供应商与多应用工作流增强 **[English →](v3.9.0-en.md) | [日本語版 →](v3.9.0-ja.md)** --- ## 概览 CC Switch v3.9.0 是 v3.9 测试版序列(`3.9.0-1`、`3.9.0-2`、`3.9.0-3`)的稳定版。 本次更新带来本地 API 代理(支持按应用接管)、自动故障切换、统一供应商(Universal Provider),并对 Claude Code / Codex / Gemini CLI 的稳定性与使用体验做了大量改进。 **发布日期**:2026-01-07 --- ## 重点内容 - 本地 API 代理:Claude Code / Codex / Gemini CLI 统一接入 - 自动故障切换:熔断保护 + 每个应用独立的 failover 队列 - 统一供应商:一份配置可同步到多个应用(适合 NewAPI 等网关) - Skills 相关增强:支持多应用、管理架构统一(SSOT + React Query) - 通用配置片段:支持从编辑器内容或当前供应商提取可复用片段 - MCP 导入:支持从已安装应用导入 MCP servers - 用量增强:自动刷新、缓存命中/创建指标、时区修复 - Linux 打包:新增 RPM 与 Flatpak 制品 --- ## 主要功能 ### 本地 API 代理(Local API Proxy) - 运行一个本地高性能 HTTP 代理服务(基于 Axum) - 统一代理 Claude Code、Codex、Gemini CLI 的 API 请求 - 按应用接管:你可以分别控制每个应用是否走本地代理 - Live 配置接管:启用接管时,会备份并重定向 CLI 的 live 配置到本地代理 - 监控能力:记录请求日志与用量统计,便于排错与成本分析 - 错误请求日志:代理会记录失败请求的详细信息,便于定位问题(#401,感谢 @yovinchen) ### 自动故障切换(Auto Failover / 熔断) - 自动检测供应商异常并触发熔断保护 - 当前供应商不可用时自动切换到备用供应商 - 每个应用维护独立的 failover 队列,并实时追踪健康状态 - 当关闭故障切换时,超时/重试相关配置不会影响正常请求流程 ### Skills 管理 - Skills 支持 Claude Code 与 Codex 多应用使用,并提供旧结构到新结构的平滑迁移(#365、#378,感谢 @yovinchen) - Skills 管理架构统一(SSOT + React Query),状态刷新与数据一致性更稳定 - 发现(Discovery)体验与性能改进: - 扫描时跳过隐藏目录 - Discoverable skills 使用长生命周期缓存提升性能 - 增加加载状态提示,导入/刷新等操作入口更显眼 - 修复 Skills 仓库分支配置错误(#505,感谢 @kjasn) ### 统一供应商(Universal Provider) - 新增“跨应用共享”的供应商配置,可同步到 Claude/Codex/Gemini(#348,感谢 @Calcium-Ion) - 适配支持多协议的 API 网关(例如 NewAPI) - 同一个供应商下可按应用分别设置默认模型映射 ### 通用配置片段(Claude/Codex/Gemini) - 维护一段“通用配置片段”,并将其合并/追加到启用该功能的供应商配置中 - 新增“提取通用配置片段”工作流: - 优先从编辑器当前内容提取(你正在编辑的内容) - 若未提供编辑器内容,则从当前激活的供应商提取 - Codex 场景提取更安全: - 自动移除 `model_provider`、`model` 以及整个 `model_providers` 表等供应商相关内容 - 会保留 `[mcp_servers.*]` 下的 `base_url`,避免误伤 MCP 配置 ### MCP 管理 - 支持从已安装应用导入 MCP servers - 同步更稳健:目标 CLI 未安装则跳过;无效的 Codex `config.toml` 可更优雅处理(#461,感谢 @majiayu000) - Windows 兼容性:MCP 导出相关的 npx/npm 调用使用 `cmd /c` 包裹 ### 用量与计费数据 - 用量与计费增强:自动刷新、缓存命中/创建指标、时区修复,以及内置价格表更新(#508,感谢 @yovinchen) - 深链支持:可通过 deeplink 导入用量查询配置(#400,感谢 @qyinter) - 用量统计支持提取模型信息(#455,感谢 @yovinchen) - 用量查询凭证支持从供应商配置回退(#360,感谢 @Sirhexs) --- ## 体验优化 - 供应商搜索过滤:按名称快速查找(#435,感谢 @TinsFox) - 供应商图标颜色:支持为供应商图标设置自定义颜色,便于快速区分(#385,感谢 @yovinchen) - 快捷键:`Cmd/Ctrl + ,` 打开设置(#436,感谢 @TinsFox) - 可跳过 Claude Code 首次确认弹窗(可选) - Toast 通知可关闭:切换提示与成功提示都支持关闭按钮(#350,感谢 @ForteScarlet) - 点击更新徽章会自动跳转到 About 标签页 - 设置页 Tab 样式改进(#342,感谢 @wenyuanw) - 更顺滑的切换动效:应用/视图淡入淡出与面板退出动画 - 代理接管激活时应用翡翠绿主题,便于一眼识别当前状态 - 深色模式可读性增强(表单与标签对比度等) - FullScreenPanel 的窗口拖拽区域优化(#525,感谢 @zerob13) --- ## 平台说明 ### Windows - 版本检查不再弹出终端窗口 - 改进窗口尺寸默认值(最小宽高) - 修复部分设备启动黑屏问题(使用系统标题栏方案) - 兼容旧 WebView:为 `crypto.randomUUID()` 增加降级方案 ### macOS - 自启动使用 `.app bundle` 路径,避免弹出终端窗口(#462,感谢 @majiayu000) - 托盘与标题栏相关体验优化 --- ## 打包 - Linux:新增 RPM 与 Flatpak 打包目标,用于生成发布制品 --- ## 说明与注意事项 - 安全增强:修复 JavaScript 执行器与用量脚本相关的安全问题(#151,感谢 @luojiyin1987)。 - 为降低导入风险,SQL 导入被限制为仅允许导入 CC Switch 自己导出的备份。 - Proxy 接管会修改 CLI 的 live 配置;CC Switch 会在重定向前自动备份 live 配置。如需回退,可关闭接管/停止代理,并在必要时从备份恢复。 ## 特别感谢 特别感谢 @xunyu @deijing @su-fen 做出的支持和贡献,没有你们就没有这个版本! ## 下载与安装 访问 [Releases](https://github.com/farion1231/cc-switch/releases/latest) 下载对应版本。 ### 系统要求 | 系统 | 最低版本 | 架构 | | ------- | ----------------------------- | ----------------------------------- | | Windows | Windows 10 及以上 | x64 | | macOS | macOS 10.15 (Catalina) 及以上 | Intel (x64) / Apple Silicon (arm64) | | Linux | 见下表 | x64 | ### Windows | 文件 | 说明 | | --------------------------------------- | ----------------------------------- | | `CC-Switch-v3.9.0-Windows.msi` | **推荐** - MSI 安装包,支持自动更新 | | `CC-Switch-v3.9.0-Windows-Portable.zip` | 便携版,解压即用,不写入注册表 | ### macOS | 文件 | 说明 | | ------------------------------- | --------------------------------------------------------- | | `CC-Switch-v3.9.0-macOS.zip` | **推荐** - 解压后拖入 Applications 即可,Universal Binary | | `CC-Switch-v3.9.0-macOS.tar.gz` | 用于 Homebrew 安装和自动更新 | > **注意**:由于作者没有苹果开发者账号,首次打开可能出现"未知开发者"警告,请先关闭,然后前往"系统设置" → "隐私与安全性" → 点击"仍要打开",之后便可以正常打开 ### Homebrew(MacOS) ```bash brew tap farion1231/ccswitch brew install --cask cc-switch ``` 更新: ```bash brew upgrade --cask cc-switch ``` ### Linux | 发行版 | 推荐格式 | 安装方式 | | --------------------------------------- | ----------- | ---------------------------------------------------------------------- | | Ubuntu / Debian / Linux Mint / Pop!\_OS | `.deb` | `sudo dpkg -i CC-Switch-*.deb` 或 `sudo apt install ./CC-Switch-*.deb` | | Fedora / RHEL / CentOS / Rocky Linux | `.rpm` | `sudo rpm -i CC-Switch-*.rpm` 或 `sudo dnf install ./CC-Switch-*.rpm` | | openSUSE | `.rpm` | `sudo zypper install ./CC-Switch-*.rpm` | | Arch Linux / Manjaro | `.AppImage` | 添加执行权限后直接运行,或使用 AUR | | 其他发行版 / 不确定 | `.AppImage` | `chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage` | | 沙箱隔离需求 | `.flatpak` | `flatpak install CC-Switch-*.flatpak` | ================================================ FILE: docs/user-manual/README.md ================================================ # CC Switch User Manual / 用户手册 / ユーザーマニュアル > Claude Code / Codex / Gemini CLI / OpenCode / OpenClaw ## Language / 语言 / 言語 | Language | Link | |----------|------| | [中文](./zh/README.md) | 简体中文用户手册 | | [English](./en/README.md) | English User Manual | | [日本語](./ja/README.md) | 日本語ユーザーマニュアル | ## Version / 版本 / バージョン - Documentation version: v3.12.0 - Last updated: 2026-03-09 - Compatible with CC Switch v3.12.0+ ## Links - [GitHub Issues](https://github.com/farion1231/cc-switch/issues) - [GitHub Repository](https://github.com/farion1231/cc-switch) ================================================ FILE: docs/user-manual/en/1-getting-started/1.1-introduction.md ================================================ # 1.1 Introduction ## What is CC Switch CC Switch is a cross-platform desktop application designed for developers who use AI coding tools. It helps you centrally manage configurations for five major AI coding tools: **Claude Code**, **Codex**, **Gemini CLI**, **OpenCode**, and **OpenClaw**. ## What Problems Does It Solve In your daily development workflow, you may encounter these pain points: - **Tedious multi-provider switching**: Using different API providers (official, proxy services) requires manually editing configuration files - **Scattered configurations**: Claude, Codex, Gemini, OpenCode, and OpenClaw each have independent configuration files in different formats - **No usage monitoring**: No visibility into how many API calls were made or how much they cost - **Service instability**: When a single provider goes down, your entire workflow is interrupted CC Switch solves these problems through a unified interface. ## Core Features ### Provider Management - One-click switching between multiple API provider configurations - Preset templates for quickly adding common providers - Universal provider feature for sharing configurations across apps - Usage query and balance display - Endpoint speed testing ### Extensions - **MCP Servers**: Manage Model Context Protocol servers to extend AI capabilities - **Prompts**: Manage system prompt presets for quick scenario switching - **Skills**: Install and manage skill extensions ### Proxy & High Availability - Local proxy service for request logging and usage statistics - Automatic failover that switches to a backup provider when the primary one fails - Circuit breaker mechanism to prevent repeated retries against failing providers - Detailed token usage tracking and cost estimation ## Supported Applications | Application | Description | |-------------|-------------| | **Claude Code** | Anthropic's official AI coding assistant | | **Codex** | OpenAI's code generation tool | | **Gemini CLI** | Google's AI command-line tool | | **OpenCode** | Open-source AI coding terminal tool | | **OpenClaw** | Open-source AI coding assistant (multi-provider gateway) | ## Supported Platforms - **Windows** 10 and above - **macOS** 10.15 (Catalina) and above - **Linux** Ubuntu 22.04+ / Debian 11+ / Fedora 34+ ## Technical Architecture CC Switch is built with a modern technology stack: - **Frontend**: React 18 + TypeScript + Tailwind CSS - **Backend**: Tauri 2 + Rust - **Data Storage**: SQLite (providers, MCP, Prompts) + JSON (device settings) This architecture ensures: - Consistent cross-platform experience - Native-level performance - Secure local data storage ================================================ FILE: docs/user-manual/en/1-getting-started/1.2-installation.md ================================================ # 1.2 Installation Guide ## Prerequisites ### Install Node.js The CLI tools managed by CC Switch (Claude Code, Codex, Gemini CLI) require a Node.js environment. **Recommended version**: Node.js 18 LTS or higher #### Windows 1. Visit the [Node.js official website](https://nodejs.org/) 2. Download the LTS version installer 3. Run the installer and follow the prompts 4. Verify installation: ```bash node --version npm --version ``` #### macOS ```bash # Install with Homebrew brew install node # Or use nvm (recommended) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash nvm install --lts ``` #### Linux ```bash # Ubuntu/Debian curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - sudo apt-get install -y nodejs # Or use nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash nvm install --lts ``` ### Install CLI Tools #### Claude Code **Option 1: Homebrew (recommended for macOS)** ```bash brew install claude-code ``` **Option 2: npm** ```bash npm install -g @anthropic-ai/claude-code ``` #### Codex **Option 1: Homebrew (recommended for macOS)** ```bash brew install codex ``` **Option 2: npm** ```bash npm install -g @openai/codex ``` #### Gemini CLI **Option 1: Homebrew (recommended for macOS)** ```bash brew install gemini-cli ``` **Option 2: npm** ```bash npm install -g @google/gemini-cli ``` --- ## Windows ### Installer 1. Visit the [Releases page](https://github.com/farion1231/cc-switch/releases) 2. Download `CC-Switch-v{version}-Windows.msi` 3. Double-click to run the installer 4. Follow the prompts to complete installation ### Portable Version (No Installation Required) 1. Download `CC-Switch-v{version}-Windows-Portable.zip` 2. Extract to any directory 3. Run `CC-Switch.exe` ## macOS ### Option 1: Homebrew (Recommended) ```bash # Add tap brew tap farion1231/ccswitch # Install brew install --cask cc-switch ``` Update to the latest version: ```bash brew upgrade --cask cc-switch ``` ### Option 2: Manual Download 1. Download `CC-Switch-v{version}-macOS.zip` 2. Extract to get `CC Switch.app` 3. Drag it to the Applications folder ### First Launch Warning Since the developer does not have an Apple Developer account, a "developer cannot be verified" warning may appear on first launch: **Recommended solution**: Open Terminal and run the following command: ```bash sudo xattr -dr com.apple.quarantine /Applications/CC\ Switch.app/ ``` **Alternative solution (via System Settings)**: 1. Close the warning dialog 2. Open "System Settings" > "Privacy & Security" 3. Find the CC Switch prompt and click "Open Anyway" 4. Reopen the app to use it normally ## Linux ### ArchLinux Install using an AUR helper: ```bash # Using paru paru -S cc-switch-bin # Or using yay yay -S cc-switch-bin ``` ### Debian / Ubuntu 1. Download `CC-Switch-v{version}-Linux.deb` 2. Install: ```bash sudo dpkg -i CC-Switch-v{version}-Linux.deb # If there are dependency issues sudo apt-get install -f ``` ### AppImage (Universal) 1. Download `CC-Switch-v{version}-Linux.AppImage` 2. Add execute permission: ```bash chmod +x CC-Switch-v{version}-Linux.AppImage ``` 3. Run: ```bash ./CC-Switch-v{version}-Linux.AppImage ``` ## Verify Installation After installation, launch CC Switch: 1. The app window displays correctly 2. A CC Switch icon appears in the system tray 3. You can switch between Claude / Codex / Gemini apps ## Auto Update CC Switch includes built-in auto-update functionality: - Automatically checks for updates on startup - Displays an update prompt in the UI when a new version is available - Click to download and install You can also manually check for updates in "Settings > About". ## Uninstall ### Windows - Uninstall via "Settings > Apps" - Or run the uninstaller in the installation directory ### macOS - Move `CC Switch.app` to Trash - Optional: Delete the configuration directory `~/.cc-switch/` ### Linux ```bash # Debian/Ubuntu sudo apt remove cc-switch # ArchLinux paru -R cc-switch-bin ``` ================================================ FILE: docs/user-manual/en/1-getting-started/1.3-interface.md ================================================ # 1.3 Interface Overview ## Main Interface Layout ![image-20260108001629138](../../assets/image-20260108001629138.png) ## Top Navigation Bar | # | Element | Description | |---|---------|-------------| | 1 | Logo | Click to visit the GitHub project page | | 2 | Settings Button | Open the settings page (shortcut `Cmd/Ctrl + ,`) | | 3 | Proxy Toggle | Start/stop the local proxy service | | 4 | App Switcher | Switch between Claude / Codex / Gemini / OpenCode / OpenClaw | | 5 | Feature Area | Skills / Prompts / MCP entry points | | 6 | Add Button | Add a new provider | ### App Switcher Click the dropdown menu to switch the currently managed application: - **Claude** - Manage Claude Code configuration - **Codex** - Manage Codex configuration - **Gemini** - Manage Gemini CLI configuration - **OpenCode** - Manage OpenCode configuration - **OpenClaw** - Manage OpenClaw configuration After switching, the provider list displays the configurations for the selected application. ### Feature Area Buttons | Button | Function | Visibility | |--------|----------|------------| | Skills | Skill extension management | Always visible | | Prompts | System prompt management | Always visible | | MCP | MCP server management | Always visible | ## Provider Cards Each provider is displayed as a card, containing the following elements from left to right: ### Card Elements (Left to Right) | # | Element | Icon | Description | |---|---------|------|-------------| | 1 | Drag Handle | ≡ | Hold and drag up/down to reorder providers | | 2 | Provider Icon | - | Displays provider brand icon with customizable color | | 3 | Provider Info | - | Name, notes/endpoint URL (clickable to open website) | | 4 | Usage Info | - | Shows remaining balance; displays plan count for multi-plan | | 5 | Enable Button | - | Switch to this provider | | 6 | Edit Button | - | Edit provider configuration | | 7 | Duplicate Button | - | Duplicate provider (create a copy) | | 8 | Speed Test Button | - | Test model availability and response speed | | 9 | Usage Query | - | Configure usage query script | | 10 | Delete Button | - | Delete provider (disabled when currently active) | > **Tip**: The action buttons area (5-10) appears on hover and is hidden by default to keep the interface clean. ### Button Details | Button | State Changes | Notes | |--------|---------------|-------| | **Enable** | Shows checkmark and disables when active | Changes to "Join/Joined" in failover mode | | **Edit** | Always available | Opens edit panel to modify configuration | | **Duplicate** | Always available | Creates a copy with `copy` suffix | | **Speed Test** | Shows loading animation during test | Only available when proxy service is running | | **Usage Query** | Always available | Configure custom usage query script | | **Delete** | Semi-transparent/disabled when active | Must switch to another provider first | ### Card States | State | Border Color | Description | |-------|--------------|-------------| | **Currently Active** | Blue border | Current provider in normal mode | | **Proxy Active** | Green border | Provider actually in use during proxy takeover mode | | **Normal** | Default border | Inactive provider | | **In Failover** | Shows priority badge | e.g., P1, P2 indicates failover priority | ### Health Status Badges In proxy mode, providers in the failover queue display health status: | Badge | Color | Description | |-------|-------|-------------| | Healthy | Green | 0 consecutive failures | | Warning | Yellow | 1-2 consecutive failures | | Unhealthy | Red | 3+ consecutive failures, may trigger circuit breaker | ## System Tray CC Switch displays an icon in the system tray, providing quick access to operations. ### Tray Menu Structure ![image-20260108002153668](../../assets/image-20260108002153668.png) ### Menu Functions | Menu Item | Function | |-----------|----------| | Open Main Window | Show and focus the main window | | App Groups | Providers grouped by Claude/Codex/Gemini/OpenCode/OpenClaw | | Provider List | Click to switch; currently active one shows a checkmark | | Quit | Fully exit the application | ### Multi-language Support The tray menu supports three languages, automatically switching based on settings: | Language | Open Main Window | Quit | |----------|-----------------|------| | Chinese | Open Main Window | Quit | | English | Open main window | Quit | | Japanese | Open main window | Quit | ### Use Cases Switching providers via the tray menu doesn't require opening the main window, suitable for: - Frequently switching providers - Quick operations when the main window is minimized - Managing configurations while running in the background ## Settings Page The settings page is divided into multiple tabs: ### General Tab - Language settings (Chinese/English/Japanese) - Theme settings (System/Light/Dark) - Window behavior (launch on startup, close behavior) ### Advanced Tab - Configuration directory settings - Proxy service configuration - Failover settings - Pricing configuration - Data import/export ### Usage Tab - Request statistics overview - Trend charts - Request logs - Provider/model statistics ### About Tab - Version information - Update check - Open source license ## Keyboard Shortcuts | Shortcut | Function | |----------|----------| | `Cmd/Ctrl + ,` | Open Settings | | `Cmd/Ctrl + F` | Search providers | | `Esc` | Close dialog/search | ## Search Press `Cmd/Ctrl + F` to open the search bar: - Search by name, notes, or URL - Real-time provider list filtering - Press `Esc` to close search ================================================ FILE: docs/user-manual/en/1-getting-started/1.4-quickstart.md ================================================ # 1.4 Quick Start This section helps you complete the initial setup in 5 minutes. ## Step 1: Add a Provider 1. Click the **+** button in the top-right corner of the main interface 2. Select your provider from the "Preset" dropdown - Common presets: Zhipu GLM, MiniMax, DeepSeek, Kimi, PackyCode - Or select "Custom" for manual configuration 3. Enter your **API Key** 4. Click "Add" ![image-20260108002807657](../../assets/image-20260108002807657.png) > **Tip**: Presets auto-fill the endpoint URL, so you only need to enter your API Key. ## Step 2: Switch Provider After adding, the provider appears in the list. **Option 1: Switch from the main interface** - Click the "Enable" button on the provider card **Option 2: Quick switch via system tray** - Right-click the CC Switch icon in the system tray - Click the provider name directly ## Step 3: Activation After switching providers, each CLI tool activates differently: | Application | Activation Method | |-------------|-------------------| | Claude Code | Instant effect (supports hot reload) | | Codex | Requires closing and reopening the terminal | | Gemini | Instant effect (re-reads config on each request) | ### Claude Code First Launch Prompt If Claude Code prompts you to **log in** or shows an onboarding wizard on first launch, enable the "Skip Claude Code first-run confirmation" option in CC Switch: 1. Open CC Switch "Settings > General" 2. Enable the "Skip Claude Code first-run confirmation" toggle 3. Restart Claude Code ![image-20260108002626389](../../assets/image-20260108002626389.png) > **Note**: This option writes the `skipIntroduction` field to `~/.claude/settings.json`, skipping the official onboarding flow. ## Verify Configuration After restarting, launch the corresponding CLI tool and enter a simple question to test: ```bash # Claude Code - enter a test question after launching claude > Hello, please briefly introduce yourself # Codex - enter a test question after launching codex > Hello, please briefly introduce yourself # Gemini - enter a test question after launching gemini > Hello, please briefly introduce yourself ``` If the AI responds normally, the configuration is successful. ## Next Steps Congratulations! You have completed the basic configuration. Next, you can: - [Add more providers](../2-providers/2.1-add.md) - Configure multiple providers for easy switching - [Configure MCP servers](../3-extensions/3.1-mcp.md) - Extend AI tool capabilities - [Set up system prompts](../3-extensions/3.2-prompts.md) - Customize AI behavior - [Enable proxy service](../4-proxy/4.1-service.md) - Monitor usage and enable automatic failover ## Common Issues ### Not taking effect after switching? Make sure you restarted the terminal or CLI tool. The configuration file is updated at switch time, but running programs do not automatically reload it. ### Can't find a preset? If your provider is not in the preset list, select "Custom" for manual configuration. See [Add Provider](../2-providers/2.1-add.md) for configuration format details. ### How to restore official login? Select the "Official Login" preset (Claude/Codex) or "Google Official" preset (Gemini), restart the client, and follow the login flow. ================================================ FILE: docs/user-manual/en/1-getting-started/1.5-settings.md ================================================ # 1.5 Personalization This section describes how to configure CC Switch according to your preferences. ## Open Settings - Click the **gear** button in the top-left corner - Or use the shortcut `Cmd/Ctrl + ,` ## Language Settings CC Switch supports three languages: | Language | Description | |----------|-------------| | Simplified Chinese | Default language | | English | English interface | | Japanese | Japanese interface | Language changes take effect immediately without restarting. ## Theme Settings | Option | Description | |--------|-------------| | System | Automatically matches the system's dark/light mode | | Light | Always use the light theme | | Dark | Always use the dark theme | ## Window Behavior ### Launch on Startup When enabled, CC Switch automatically runs when the system starts. - **Windows**: Implemented via the registry - **macOS**: Implemented via LaunchAgent - **Linux**: Implemented via XDG autostart ### Close Behavior | Option | Description | |--------|-------------| | Minimize to tray | Clicking the close button hides to the system tray | | Exit directly | Clicking the close button fully exits the app | "Minimize to tray" is recommended for convenient provider switching via the tray. ### Claude Plugin Integration When enabled, CC Switch automatically syncs the configuration to the VS Code Claude Code extension (writes `primaryApiKey` to `~/.claude/config.json`) when switching providers. > **Use case**: If you use both Claude Code CLI and the VS Code extension, enable this option to keep both configurations in sync. ### Skip Claude Onboarding When enabled, skips the Claude Code onboarding flow, suitable for users already familiar with Claude Code. > **Note**: This option writes the `skipIntroduction` field to `~/.claude/settings.json`. ### App Visibility Choose which applications to display in the app switcher. Each app can be toggled independently, but at least one must remain visible. Configurable apps: Claude, Codex, Gemini, OpenCode, OpenClaw. > **Use case**: If you only use Claude Code and Codex CLI, you can hide the other apps to keep the interface clean. ### Skill Sync Method Set the sync method when installing skills to each app's directory: | Method | Description | |--------|-------------| | Symlink | Creates symbolic links pointing to skill source files; saves space, syncs in real-time | | Copy | Copies skill files entirely to the target directory | > **Recommended**: Symlink is the default method. Switch to Copy if you encounter permission issues. ### Terminal Settings Choose the terminal application that CC Switch uses when opening a terminal. Supported terminals (by platform): | Platform | Terminal Options | |----------|-----------------| | macOS | Terminal, iTerm2, Alacritty, Kitty, Ghostty, WezTerm | | Windows | CMD, PowerShell, Windows Terminal | | Linux | GNOME Terminal, Konsole, Xfce4 Terminal, Alacritty, Kitty, Ghostty | ## Directory Configuration ### App Configuration Directory The storage location for CC Switch's own data, defaulting to `~/.cc-switch/`. ### CLI Tool Directories You can customize each CLI tool's configuration directory: | Setting | Default | Description | |---------|---------|-------------| | Claude Directory | `~/.claude/` | Claude Code configuration directory | | Codex Directory | `~/.codex/` | Codex configuration directory | | Gemini Directory | `~/.gemini/` | Gemini CLI configuration directory | | OpenCode Directory | `~/.opencode/` | OpenCode configuration directory | | OpenClaw Directory | `~/.openclaw/` | OpenClaw configuration directory | > **Note**: After changing directories, the app must be restarted, and the corresponding CLI tools must also be configured to use the same directory. ## Data Management ### Export Configuration Click the "Export" button to save a backup file containing: - All provider configurations - MCP server configurations - Prompt presets - App settings The backup file is in JSON format and can be viewed with a text editor. ### Import Configuration 1. Click "Select File" 2. Select a previously exported backup file 3. Click "Import" 4. Confirm to overwrite existing configuration > **Note**: Importing will overwrite existing configuration. It is recommended to export your current configuration as a backup first. ## Proxy Settings Settings > Proxy Tab The Proxy tab centralizes all proxy-related features: ### Local Proxy Start/stop the local proxy service, configure the listen address and port. See [4.1 Proxy Service](../4-proxy/4.1-service.md) for details. ### Failover Configure failover queues and automatic switching strategies by app (Claude/Codex/Gemini). See [4.3 Failover](../4-proxy/4.3-failover.md) for details. ### Pricing Rectifier Configure model pricing correction rules for proxy billing statistics calibration. ### Global Outbound Proxy Configure CC Switch's outbound HTTP/HTTPS proxy, applicable for scenarios where external API access requires a proxy. ## Advanced Settings Settings > Advanced Tab ### Configuration Directories Customize configuration file directories for each app. See the "Directory Configuration" section above for details. ### Data Management Import/export configuration backups. See the "Data Management" section above for details. ### Backup & Restore Manage automatic backups: | Setting | Description | |---------|-------------| | Backup Interval | Time interval for automatic backups (hours) | | Retention Count | Number of backups to retain | Supports viewing the backup list and restoring from backups. ### Cloud Sync (WebDAV) Sync configurations across multiple devices via the WebDAV protocol. | Setting | Description | |---------|-------------| | Service Preset | Jianguoyun / Nextcloud / Synology / Custom | | Server URL | WebDAV server URL | | Username | Login username | | Password | Login password (app-specific password) | | Remote Directory | Remote storage path (default: `cc-switch-sync`) | | Profile Name | Device profile name (default: `default`) | | Auto Sync | Automatically upload changes when enabled | Operations: - **Test Connection**: Verify WebDAV configuration is correct - **Save**: Save configuration and auto-test - **Upload**: Upload local data to the remote server - **Download**: Download data from the remote server to local > **Note**: Upload will overwrite remote data, and download will overwrite local data. Please confirm before proceeding. ### Log Configuration | Setting | Description | |---------|-------------| | Enable Logging | Enable/disable application logging | | Log Level | error / warn / info / debug / trace | Log level descriptions: - **error** - Critical errors only - **warn** - Warnings and errors - **info** - General information (recommended) - **debug** - Detailed debugging information - **trace** - All verbose information ## About Page Settings > About Tab ### Version Information Displays the current CC Switch version number, with support for: - Viewing release notes - Checking for updates - Downloading and installing new versions ### Local Environment Check Automatically detects installed CLI tool versions: | Tool | Detection Contents | |------|-------------------| | Claude | Current version, latest version | | Codex | Current version, latest version | | Gemini | Current version, latest version | | OpenCode | Current version, latest version | | OpenClaw | Current version, latest version | Click the "Refresh" button to re-detect. ### One-click Install Commands Provides quick commands to install/update CLI tools: ```bash npm i -g @anthropic-ai/claude-code@latest npm i -g @openai/codex@latest npm i -g @google/gemini-cli@latest npm i -g opencode@latest npm i -g openclaw@latest ``` Click the "Copy" button to copy to clipboard. ================================================ FILE: docs/user-manual/en/2-providers/2.1-add.md ================================================ # 2.1 Add Provider ## Open the Add Panel Click the **+** button in the top-right corner of the main interface to open the Add Provider panel. The panel has two tabs: - **App-specific Provider**: Only for the currently selected app (Claude/Codex/Gemini/OpenCode/OpenClaw) - **Universal Provider**: Shared configuration across apps ## Add Using Presets Presets are pre-configured provider templates that only require an API Key to use. ### Steps 1. Select a provider from the "Preset" dropdown 2. Name and endpoint are auto-filled 3. Enter your **API Key** 4. (Optional) Add notes 5. Click "Add" ### Common Presets #### Claude Presets | Preset Name | Description | |-------------|-------------| | Claude Official | Log in with an Anthropic official account | | DeepSeek | DeepSeek model | | Zhipu GLM | Zhipu AI GLM model | | Zhipu GLM en | Zhipu AI (English version) | | Bailian | Alibaba Cloud Bailian (Qwen) | | Kimi | Moonshot Kimi model | | Kimi For Coding | Kimi coding-specific model | | StepFun | StepFun model | | ModelScope | ModelScope community | | KAT-Coder | KAT-Coder model | | Longcat | Longcat AI | | MiniMax | MiniMax model | | MiniMax en | MiniMax (English version) | | DouBaoSeed | DouBao Seed model | | BaiLing | BaiLing AI | | AiHubMix | AiHubMix aggregation service | | SiliconFlow | SiliconFlow | | SiliconFlow en | SiliconFlow (English version) | | DMXAPI | DMXAPI proxy service | | PackyCode | PackyCode proxy service | | Cubence | Cubence service | | AIGoCode | AIGoCode service | | RightCode | RightCode service | | AICodeMirror | AICodeMirror service | | OpenRouter | Aggregation routing service | | Nvidia | Nvidia AI service | | Xiaomi MiMo | Xiaomi MiMo model | > The preset list may be updated with new versions. Refer to the actual list shown in the app. #### Codex Presets | Preset Name | Description | |-------------|-------------| | OpenAI Official | Log in with an OpenAI official account | | Azure OpenAI | Azure OpenAI service | | AiHubMix | AiHubMix aggregation service | | DMXAPI | DMXAPI proxy service | | PackyCode | PackyCode proxy service | | Cubence | Cubence service | | AIGoCode | AIGoCode service | | RightCode | RightCode service | | AICodeMirror | AICodeMirror service | | OpenRouter | Aggregation routing service | #### Gemini Presets | Preset Name | Description | |-------------|-------------| | Google Official | Log in with Google OAuth | | PackyCode | PackyCode proxy service | | Cubence | Cubence service | | AIGoCode | AIGoCode service | | AICodeMirror | AICodeMirror service | | OpenRouter | Aggregation routing service | | Custom | Manually configure all parameters | #### OpenCode Presets | Preset Name | Description | |-------------|-------------| | DeepSeek | DeepSeek model | | Zhipu GLM | Zhipu AI GLM model | | Zhipu GLM en | Zhipu AI (English version) | | Bailian | Alibaba Cloud Bailian | | Kimi k2.5 | Moonshot Kimi-k2.5 model | | Kimi For Coding | Kimi coding-specific model | | StepFun | StepFun model | | ModelScope | ModelScope community | | KAT-Coder | KAT-Coder model | | Longcat | Longcat AI | | MiniMax | MiniMax model | | MiniMax en | MiniMax (English version) | | DouBaoSeed | DouBao Seed model | | BaiLing | BaiLing AI | | Xiaomi MiMo | Xiaomi MiMo model | | AiHubMix | AiHubMix aggregation service | | DMXAPI | DMXAPI proxy service | | OpenRouter | Aggregation routing service | | Nvidia | Nvidia AI service | | PackyCode | PackyCode proxy service | | Cubence | Cubence service | | AIGoCode | AIGoCode service | | RightCode | RightCode service | | AICodeMirror | AICodeMirror service | | OpenAI Compatible | OpenAI-compatible interface | | Oh My OpenCode | Oh My OpenCode service | > The preset list is continuously updated. Refer to the actual list shown in the app. #### OpenClaw Presets | Preset Name | Description | |-------------|-------------| | DeepSeek | DeepSeek model | | Zhipu GLM | Zhipu AI GLM model | | Zhipu GLM en | Zhipu AI (English version) | | Qwen Coder | Qwen coding model | | Kimi k2.5 | Moonshot Kimi-k2.5 model | | Kimi For Coding | Kimi coding-specific model | | StepFun | StepFun model | | MiniMax | MiniMax model | | MiniMax en | MiniMax (English version) | | KAT-Coder | KAT-Coder model | | Longcat | Longcat AI | | DouBaoSeed | DouBao Seed model | | BaiLing | BaiLing AI | | Xiaomi MiMo | Xiaomi MiMo model | | AiHubMix | AiHubMix aggregation service | | DMXAPI | DMXAPI proxy service | | OpenRouter | Aggregation routing service | | ModelScope | ModelScope community | | SiliconFlow | SiliconFlow | | SiliconFlow en | SiliconFlow (English version) | | Nvidia | Nvidia AI service | | PackyCode | PackyCode proxy service | | Cubence | Cubence service | | AIGoCode | AIGoCode service | | RightCode | RightCode service | | AICodeMirror | AICodeMirror service | | AICoding | AICoding service | | CrazyRouter | CrazyRouter service | | SSSAiCode | SSSAiCode service | | AWS Bedrock | AWS Bedrock service | | OpenAI Compatible | OpenAI-compatible interface | ## Custom Configuration After selecting the "Custom" preset, you need to manually edit the JSON configuration. ### Claude Configuration Format ```json { "env": { "ANTHROPIC_API_KEY": "your-api-key", "ANTHROPIC_BASE_URL": "https://api.example.com" } } ``` | Field | Required | Description | |-------|----------|-------------| | `ANTHROPIC_API_KEY` | Yes | API key | | `ANTHROPIC_BASE_URL` | No | Custom endpoint URL | | `ANTHROPIC_AUTH_TOKEN` | No | Alternative authentication method to API_KEY | ### Codex Configuration Format Codex uses two configuration files: **1. auth.json** (`~/.codex/auth.json`) - Stores API key: ```json { "OPENAI_API_KEY": "your-api-key" } ``` **2. config.toml** (`~/.codex/config.toml`) - Stores model and endpoint configuration: ```toml # Basic configuration model_provider = "custom" model = "gpt-5.2" model_reasoning_effort = "high" disable_response_storage = true # Custom provider configuration [model_providers.custom] name = "custom" base_url = "https://api.example.com/v1" wire_api = "responses" requires_openai_auth = true ``` **auth.json field descriptions**: | Field | Required | Description | |-------|----------|-------------| | `OPENAI_API_KEY` | Yes | API key | **config.toml field descriptions**: | Field | Required | Description | |-------|----------|-------------| | `model_provider` | Yes | Model provider name (must match `[model_providers.xxx]`) | | `model` | Yes | Model to use (e.g., `gpt-5.2`, `gpt-4o`) | | `model_reasoning_effort` | No | Reasoning effort: `low` / `medium` / `high` | | `disable_response_storage` | No | Whether to disable response storage | | `base_url` | Yes | API endpoint URL | | `wire_api` | No | API protocol type (usually `responses`) | | `requires_openai_auth` | No | Whether to use OpenAI authentication | ### Gemini Configuration Format ```json { "env": { "GEMINI_API_KEY": "your-api-key", "GOOGLE_GEMINI_BASE_URL": "https://api.example.com" } } ``` | Field | Required | Description | |-------|----------|-------------| | `GEMINI_API_KEY` | Yes | API key | | `GOOGLE_GEMINI_BASE_URL` | No | Custom endpoint URL | | `GEMINI_MODEL` | No | Specify model | > Authentication type is automatically detected by CC Switch (PackyCode API proxy / Google OAuth / generic API Key), no manual configuration needed. ## Universal Provider Universal providers can share configurations across Claude/Codex/Gemini/OpenCode/OpenClaw, suitable for proxy services that support multiple API formats. ### Create a Universal Provider 1. Switch to the "Universal Provider" tab 2. Click "Add Universal Provider" 3. Fill in the common configuration: - Name - API Key - Endpoint URL 4. Check the apps to sync to (Claude/Codex/Gemini/OpenCode/OpenClaw) 5. Save ### Sync Mechanism Universal providers automatically sync to the selected apps: - After modifying a universal provider, all linked app configurations are updated - After deleting a universal provider, linked app configurations are also deleted ### Save and Sync When editing a universal provider, you can choose: | Action | Description | |--------|-------------| | Save | Save configuration only, without immediate sync | | Save and Sync | Save configuration and immediately sync to all enabled apps | ### Manual Sync If you need to manually trigger a sync: 1. Click the "Sync" button on the universal provider card 2. Confirm the sync operation 3. Configuration will overwrite the linked provider in each app ## Import Providers CC Switch supports two ways to import provider configurations: ### Option 1: Deep Link Import One-click import via `ccswitch://` protocol links: 1. Click or visit the deep link 2. CC Switch opens automatically and shows the import confirmation 3. Preview the configuration information 4. Click "Confirm Import" **Getting deep links**: - Obtain from shared links by others - Create using the [online generator tool](https://farion1231.github.io/cc-switch/deplink.html) ### Option 2: Database Backup Import Batch import from SQL backup files: 1. Open "Settings > Advanced > Data Management" 2. Click "Select File" 3. Select a previously exported `.sql` backup file 4. Click "Import" 5. Confirm to overwrite existing configuration **Imported contents**: - All provider configurations - MCP server configurations - Prompt presets - Usage logs > **Note**: Importing will overwrite the existing database. It is recommended to export your current configuration as a backup first. The exported file name format is `cc-switch-export-{timestamp}.sql`. ## Advanced Options ### Custom Icon Click the icon area to the left of the name to: - Select a preset icon - Customize icon color ### Website Link Enter the provider's website or console URL for quick access: - Click the link icon on the provider card to open directly - Useful for checking balance, obtaining API keys, etc. ### Notes Add notes such as: - Account purpose (personal/work) - Plan information - Expiration date Notes are displayed on the provider card and are searchable. ### Endpoint Speed Test After adding a provider, you can speed-test API endpoints: 1. Click the "Speed Test" button on the provider card 2. Add multiple endpoint URLs in the speed test panel 3. Click "Test" to run the test 4. Select the endpoint with the lowest latency **Test results**: - Green: Latency < 500ms (Excellent) - Yellow: Latency 500-1000ms (Fair) - Red: Latency > 1000ms (Slow) ![image-20260108005327817](../../assets/image-20260108005327817.png) ================================================ FILE: docs/user-manual/en/2-providers/2.2-switch.md ================================================ # 2.2 Switch Provider ## Switch from Main Interface In the provider list, click the "Enable" button on the target provider card. ### Switching Flow 1. Click the "Enable" button 2. CC Switch updates the configuration file 3. The card status changes to "Currently Active" 4. Claude/Gemini take effect immediately, Codex requires a terminal restart ### Status Indicators | Status | Display | Description | |--------|---------|-------------| | Currently Active | Blue border + label | Current provider in the configuration file | | Proxy Active | Green border | Provider actually in use during proxy mode | | Normal | Default style | Inactive provider | ## Quick Switch via System Tray Quickly switch providers via the system tray without opening the main interface. ### Steps 1. Right-click the CC Switch icon in the system tray 2. Find the corresponding app (Claude/Codex/Gemini/OpenCode) in the menu 3. Click the provider name you want to switch to 4. Switching completes with a brief tray notification ### Tray Menu Structure ![image-20260108004348993](../../assets/image-20260108004348993.png) ## Activation Methods ### Claude Code **Takes effect immediately after switching**, no restart needed. Claude Code supports hot reload and automatically detects configuration file changes and reloads. ### Codex Requires restart after switching: - Close the current terminal window - Reopen the terminal ### Gemini CLI **Takes effect immediately after switching**, no restart needed. Gemini CLI re-reads the `.env` file on each request. ## Configuration File Changes When switching providers, CC Switch modifies the following files: ### Claude ``` ~/.claude/settings.json ``` Modified content: ```json { "env": { "ANTHROPIC_API_KEY": "new API Key", "ANTHROPIC_BASE_URL": "new endpoint" } } ``` ### Codex ``` ~/.codex/auth.json ~/.codex/config.toml (if additional configuration exists) ``` ### Gemini ``` ~/.gemini/.env ~/.gemini/settings.json ``` ## Handling Switch Failures If switching fails, possible reasons: ### Configuration File Is Locked Another program is using the configuration file. **Solution**: Close the running CLI tool and try switching again. ### Insufficient Permissions No write permission to the configuration file. **Solution**: Check the permission settings of the configuration directory. ### Invalid Configuration Format The provider's JSON configuration has format errors. **Solution**: Edit the provider, check and fix the JSON format. ================================================ FILE: docs/user-manual/en/2-providers/2.3-edit.md ================================================ # 2.3 Edit Provider ## Open the Edit Panel 1. Find the provider card you want to edit 2. Hover over the card to reveal action buttons 3. Click the "Edit" button ## Editable Content ### Basic Information | Field | Description | |-------|-------------| | Name | Provider display name | | Notes | Additional notes | | Website Link | Provider website or console URL | | Icon | Custom icon and color | ### Icon Customization CC Switch provides rich icon customization features: #### Icon Picker 1. Click the icon area to open the icon picker 2. Use the search box to search icons by name 3. Click to select the desired icon The icon library includes common AI service provider and technology icons, supporting: - Fuzzy search by name - Icon name tooltips - Real-time preview of selected icon ![image-20260108004734882](../../assets/image-20260108004734882.png) ### Configuration JSON-formatted configuration content, including: - API Key - Endpoint URL - Other environment variables ### Editing the Currently Active Provider When editing the currently active provider, a special "backfill" mechanism applies: 1. When opening the edit panel, the latest content is read from the live configuration file 2. If you manually modified the configuration in the CLI tool, those changes are synced back 3. After saving, modifications are written to the live configuration file This ensures CC Switch and CLI tool configurations stay in sync. ## Modify API Key When editing a provider, you can modify the key directly in the **API Key** input field: 1. Click the "Edit" button on the provider card 2. Enter the new key in the "API Key" input field 3. Click "Save" > **Tip**: The API Key input field supports a show/hide toggle. Click the eye icon on the right to view the full key. ## Modify Endpoint URL When editing a provider, you can modify the URL directly in the **Endpoint URL** input field: 1. Click the "Edit" button on the provider card 2. Enter the new URL in the "Endpoint URL" input field 3. Click "Save" ### Endpoint URL Format | Application | Format Example | |-------------|----------------| | Claude | `https://api.example.com` | | Codex | `https://api.example.com/v1` | | Gemini | `https://api.example.com` | ## Add Custom Endpoints Providers can be configured with multiple endpoints for: - Testing multiple addresses during speed tests - Backup endpoints for failover ### Auto-collection When adding a provider, CC Switch automatically extracts endpoint URLs from the configuration. ### Manual Addition When editing a provider, in the "Endpoint Management" area you can: - Add new endpoints - Delete existing endpoints - Set a default endpoint ## JSON Editor Configuration uses JSON format, and the editor provides: - Syntax highlighting - Format validation - Error messages ### Common Errors **Missing quotes**: ```json // Wrong { env: { KEY: "value" } } // Correct { "env": { "KEY": "value" } } ``` **Trailing comma**: ```json // Wrong { "env": { "KEY": "value", } } // Correct { "env": { "KEY": "value" } } ``` **Unclosed brackets**: ```json // Wrong { "env": { "KEY": "value" } // Correct { "env": { "KEY": "value" } } ``` ## Save and Activate 1. Click the "Save" button 2. If this is the currently active provider, the configuration is immediately written to the live file 3. Restart the CLI tool for changes to take effect ## Cancel Editing Click "Cancel" or press the `Esc` key to close the edit panel. All modifications will be discarded. ================================================ FILE: docs/user-manual/en/2-providers/2.4-sort-duplicate.md ================================================ # 2.4 Sort & Duplicate ## Drag to Reorder Adjust the display order of providers by dragging. ### Steps 1. Move the mouse to the **≡** drag handle on the left side of the provider card 2. Hold the left mouse button 3. Drag up or down to the target position 4. Release the mouse to complete reordering ### Reorder Uses - **Prioritize frequently used**: Place frequently used providers at the top of the list - **Failover order**: Sorting affects the default order of the failover queue ## Duplicate Provider Quickly create a copy of a provider, useful for: - Creating variations based on existing configurations - Backing up current configurations - Creating test configurations ### Steps 1. Hover over the provider card to reveal action buttons 2. Click the "Duplicate" button 3. A copy is automatically created with a `copy` name suffix 4. Edit the copy to modify the configuration ### Duplicated Content Duplication creates a complete copy, including: | Content | Duplicated | |---------|------------| | Name | Yes (with `copy` suffix) | | Configuration | Fully duplicated | | Notes | Yes | | Website Link | Yes | | Icon | Yes | | Endpoint List | Yes | | Sort Position | Inserted below the original provider | ### After Duplication After duplication, you typically need to modify: 1. **Name**: Change to a meaningful name 2. **API Key**: If using a different account 3. **Endpoint**: If using a different service ## Delete Provider ### Steps 1. Hover over the provider card to reveal action buttons 2. Click the "Delete" button 3. Confirm deletion ### Deletion Confirmation A confirmation dialog appears before deletion, showing: - Provider name - Warning that deletion cannot be undone ### Deletion Restrictions - **Currently active provider**: Can be deleted, but it is recommended to switch to another provider first - **Universal provider**: Deleting will also remove linked app configurations ![image-20260108004946288](../../assets/image-20260108004946288.png) ================================================ FILE: docs/user-manual/en/2-providers/2.5-usage-query.md ================================================ # 2.5 Usage Query ## Overview The usage query feature allows you to configure custom scripts to query a provider's remaining balance, used amount, and other information in real time. **Use cases**: - Check API account remaining balance - Monitor plan usage - Multi-plan balance summary display ## Open Configuration 1. Hover over the provider card to reveal action buttons 2. Click the "Usage Query" button (chart icon) 3. Opens the usage query configuration panel ## Enable Usage Query At the top of the configuration panel, enable the "Enable Usage Query" toggle. ## Preset Templates CC Switch provides three preset templates: ### Custom Template Fully customizable request and extraction logic, suitable for special API formats. ### Generic Template Suitable for most providers with standard API formats: ```javascript ({ request: { url: "{{baseUrl}}/user/balance", method: "GET", headers: { "Authorization": "Bearer {{apiKey}}", "User-Agent": "cc-switch/1.0" } }, extractor: function(response) { return { isValid: response.is_active || true, remaining: response.balance, unit: "USD" }; } }) ``` **Configuration parameters**: | Parameter | Description | |-----------|-------------| | API Key | Authentication key (optional, uses provider's key if empty) | | Base URL | API base URL (optional, uses provider's endpoint if empty) | ### New API Template Designed specifically for New API-type proxy services: ```javascript ({ request: { url: "{{baseUrl}}/api/user/self", method: "GET", headers: { "Content-Type": "application/json", "Authorization": "Bearer {{accessToken}}", "New-Api-User": "{{userId}}" }, }, extractor: function (response) { if (response.success && response.data) { return { planName: response.data.group || "Default Plan", remaining: response.data.quota / 500000, used: response.data.used_quota / 500000, total: (response.data.quota + response.data.used_quota) / 500000, unit: "USD", }; } return { isValid: false, invalidMessage: response.message || "Query failed" }; }, }) ``` **Configuration parameters**: | Parameter | Description | |-----------|-------------| | Base URL | New API service URL | | Access Token | Access token | | User ID | User ID | ## General Configuration ### Timeout Request timeout in seconds, default 10 seconds. ### Auto Query Interval Interval for automatically refreshing usage data (minutes): - Set to `0` to disable auto query - Range: 0-1440 minutes (up to 24 hours) - Only effective when the provider is in "Currently Active" status ## Extractor Return Format The extractor function must return an object containing the following fields: | Field | Type | Required | Description | |-------|------|----------|-------------| | `isValid` | boolean | No | Whether the account is valid, defaults to true | | `invalidMessage` | string | No | Message when invalid | | `remaining` | number | Yes | Remaining balance | | `unit` | string | Yes | Unit (e.g., USD, CNY, times) | | `planName` | string | No | Plan name (supports multi-plan) | | `total` | number | No | Total balance | | `used` | number | No | Used amount | | `extra` | object | No | Additional information | ## Test Script After configuration, click the "Test Script" button to verify: 1. Sends a request to the configured URL 2. Executes the extractor function 3. Displays the returned result or error message ## Display After successful configuration, the provider card displays: - **Single plan**: Directly shows remaining balance - **Multi-plan**: Shows plan count, click to expand for details ## Variable Placeholders The following placeholders can be used in scripts and are automatically replaced at runtime: | Placeholder | Description | |-------------|-------------| | `{{apiKey}}` | Configured API Key | | `{{baseUrl}}` | Configured Base URL | | `{{accessToken}}` | Configured Access Token (New API) | | `{{userId}}` | Configured User ID (New API) | ## Common Provider Configuration Examples ### Troubleshooting ### Query Failed **Check**: 1. Is the API Key correct 2. Is the Base URL correct 3. Is the network accessible 4. Is the timeout sufficient ### Empty Response Data **Check**: 1. Does the extractor function have a `return` statement 2. Does the response data structure match the extractor 3. Use "Test Script" to view the raw response ### Format Failed When there is a script syntax error, clicking the "Format" button will indicate the error location. ## Notes - Usage queries consume a small amount of API request quota - Set a reasonable auto query interval to avoid frequent requests - Sensitive information (API Key, Token) is securely stored locally ================================================ FILE: docs/user-manual/en/3-extensions/3.1-mcp.md ================================================ # 3.1 MCP Server Management ## What is MCP MCP (Model Context Protocol) is a protocol that allows AI tools to access external data sources and tools. Through MCP servers, you can enable AI to: - Access file systems - Make network requests - Query databases - Call external APIs ## Open the MCP Panel Click the **MCP** button in the top navigation bar. ## Panel Overview ![image-20260108005723522](../../assets/image-20260108005723522.png) ## Add MCP Server ### Using Preset Templates 1. Click the **+** button in the top-right corner 2. Select a template from the "Preset" dropdown 3. Modify the configuration as needed 4. Click "Save" ![image-20260108005739731](../../assets/image-20260108005739731.png) ### Common Presets | Preset | Package Name | Description | |--------|-------------|-------------| | fetch | mcp-server-fetch | HTTP request tool that enables AI to fetch web content | | time | @modelcontextprotocol/server-time | Time tool that provides current time information | | memory | @modelcontextprotocol/server-memory | Memory tool that enables AI to store and retrieve information | | sequential-thinking | @modelcontextprotocol/server-sequential-thinking | Chain-of-thought tool that enhances AI reasoning | | context7 | @upstash/context7-mcp | Documentation search tool for querying technical docs | ### Custom Configuration After selecting "Custom", fill in: | Field | Required | Description | |-------|----------|-------------| | Server ID | Yes | Unique identifier | | Name | No | Display name | | Description | No | Function description | | Transport Type | Yes | stdio / http / sse | | Command | Yes* | Required for stdio type | | Arguments | No | Command-line arguments | | URL | Yes* | Required for http/sse type | | Headers | No | Request headers for http/sse type | | Environment Variables | No | Environment variables passed to the server | ## Transport Types ### stdio (Standard I/O) The most common type, communicating by launching a local process. ```json { "command": "uvx", "args": ["mcp-server-fetch"], "env": {} } ``` **Requirements**: - The corresponding command must be installed (e.g., `uvx`, `npx`) - The server program must be in PATH ### http Communicates with a remote server via HTTP protocol. ```json { "url": "http://localhost:8080/mcp" } ``` ### sse (Server-Sent Events) Communicates with a server via SSE protocol, supporting real-time push. ```json { "url": "http://localhost:8080/sse" } ``` ## App Binding Each MCP server can independently control which apps it is enabled for. ### Toggle Description | Toggle | Effect | Configuration File Path | |--------|--------|------------------------| | Claude | Sync to Claude Code | `~/.claude.json`'s `mcpServers` | | Codex | Sync to Codex | `~/.codex/config.toml`'s `[mcp_servers]` | | Gemini | Sync to Gemini CLI | `~/.gemini/settings.json`'s `mcpServers` | | OpenCode | Sync to OpenCode | `~/.opencode/config.json`'s `mcpServers` | > **Note**: OpenClaw does not currently support MCP server management. MCP functionality is currently only supported for Claude, Codex, Gemini, and OpenCode. ### Toggle Implementation When enabling an app's toggle, CC Switch will: 1. **Update database**: Set the server's `apps.claude/codex/gemini/opencode` status to `true` 2. **Sync to live configuration**: Write the server configuration to the corresponding app's configuration file 3. **Take effect immediately**: The new MCP server is automatically loaded the next time the CLI tool starts When disabling an app's toggle, CC Switch will: 1. **Update database**: Set the corresponding app status to `false` 2. **Remove from live configuration**: Delete the server from the app's configuration file 3. **Take effect immediately**: The MCP server is no longer loaded the next time the CLI tool starts ### Sync Conditions MCP server sync only executes when the corresponding app is installed: - **Claude**: Requires `~/.claude/` directory or `~/.claude.json` file to exist - **Codex**: Requires `~/.codex/` directory to exist - **Gemini**: Requires `~/.gemini/` directory to exist - **OpenCode**: Requires `~/.opencode/` directory to exist > **Tip**: If a CLI tool is not installed, enabling its toggle will not cause an error, but the configuration will not be written. When the toggle is disabled, the configuration is removed from the file. ## Edit Server 1. Click the "Edit" button on the right side of the server row 2. Modify the configuration 3. Click "Save" Changes are immediately synced to enabled app configuration files. ## Delete Server 1. Click the "Delete" button on the right side of the server row 2. Confirm deletion After deletion, the configuration is removed from all app configuration files. ## Import Existing Configurations If you have already configured MCP servers in CLI tools, you can import them into CC Switch: 1. Click the "Import" button 2. Select the app to import from (Claude/Codex/Gemini/OpenCode) 3. CC Switch reads the existing configuration and imports it ## Configuration File Formats ### Claude (`~/.claude.json`) ```json { "mcpServers": { "mcp-fetch": { "command": "uvx", "args": ["mcp-server-fetch"] } } } ``` ### Codex (`~/.codex/config.toml`) ```toml [mcp_servers.mcp-fetch] command = "uvx" args = ["mcp-server-fetch"] ``` ### Gemini (`~/.gemini/settings.json`) ```json { "mcpServers": { "mcp-fetch": { "command": "uvx", "args": ["mcp-server-fetch"] } } } ``` ## FAQ ### Server Fails to Start Check: - Is the command properly installed (e.g., `uvx`) - Is the command in PATH - Are the arguments correct ### Configuration Not Taking Effect Ensure: - The corresponding app toggle is enabled - The CLI tool has been restarted ================================================ FILE: docs/user-manual/en/3-extensions/3.2-prompts.md ================================================ # 3.2 Prompts Management ## Overview The Prompts feature manages system prompt presets. System prompts influence the AI's behavior and response style. With CC Switch, you can: - Create multiple prompt presets - Quickly switch prompts for different scenarios - Sync prompt configurations across devices ## Open the Prompts Panel Click the **Prompts** button in the top navigation bar. ## Panel Overview ![image-20260108010110382](../../assets/image-20260108010110382.png) ## Create a Preset ### Steps 1. Click the **+** button in the top-right corner 2. Enter a preset name 3. Write the prompt in the Markdown editor 4. Click "Save" ### Markdown Editor The editor provides: - Syntax highlighting - Live preview - Common format shortcuts ### Prompt Writing Tips **Structured format**: ```markdown # Role Definition You are a professional code review expert. ## Core Capabilities - Code quality analysis - Performance optimization suggestions - Security vulnerability detection ## Response Style - Clear and concise - Provide specific examples - Give improvement suggestions ## Notes - Do not modify business logic - Maintain consistent code style ``` ## Activate a Preset ### How to Activate Click the toggle switch on the preset item to change its activation status. ### Single Activation Only one preset can be active at a time. Activating a new preset automatically deactivates the previous one. ### Sync Target After activation, the prompt is written to the corresponding app's file: | Application | File Path | |-------------|-----------| | Claude | `~/.claude/CLAUDE.md` | | Codex | `~/.codex/AGENTS.md` | | Gemini | `~/.gemini/GEMINI.md` | | OpenCode | `~/.opencode/AGENTS.md` | | OpenClaw | `~/.openclaw/AGENTS.md` | ## Edit a Preset 1. Click the "Edit" button on the preset item 2. Modify the name or content 3. Click "Save" If the currently active preset is edited, changes are immediately synced to the configuration file. ## Delete a Preset 1. Click the "Delete" button on the preset item 2. Confirm deletion Active presets cannot be deleted. Deactivate the preset first before deleting. ## Smart Backfill CC Switch provides a smart backfill protection mechanism to ensure your manual modifications are not lost. ### How It Works 1. Before switching presets, automatically reads the current configuration file content 2. Compares file content with the preset in the database 3. If the content differs, it means the user has manually modified it 4. Saves the manually modified content to the current preset 5. Then switches to the new preset ### Protection Scenarios | Scenario | Handling | |----------|----------| | Directly editing `CLAUDE.md` in CLI | Changes auto-saved to current preset | | Modifying config file with external editor | Changes auto-saved to current preset | | Switching to another preset | Current changes saved first, then switched | ### Technical Details The backfill mechanism triggers at these moments: - **When switching presets**: Saves current live file content to the current preset - **When editing the current preset**: Reads latest content from the live file - **On first launch**: Automatically imports existing live file content ### Notes - Backfill only triggers when switching to a different preset - If no preset is currently active, backfill is not triggered - Backfill failure does not affect the switching process ## Cross-app Usage Prompts are managed separately per app: - When switched to Claude, Claude's presets are shown - When switched to Codex, Codex's presets are shown - When switched to Gemini, Gemini's presets are shown - When switched to OpenCode, OpenCode's presets are shown - When switched to OpenClaw, OpenClaw's presets are shown To use the same prompt across multiple apps, you need to create them separately. ## Import & Export ### Share via Deep Link You can generate deep links to share presets: ``` ccswitch://import/prompt?data= ``` ### Via Configuration Export Exporting configuration includes all presets, which can be restored upon import. ================================================ FILE: docs/user-manual/en/3-extensions/3.3-skills.md ================================================ # 3.3 Skills Management ## Overview Skills are reusable capability extensions that give AI tools specialized abilities in specific domains. Skills exist as folders containing: - Prompt templates - Tool definitions - Example code ## Supported Applications Skills are supported across all four applications: - **Claude Code** - **Codex** - **Gemini CLI** - **OpenCode** ## Open the Skills Page Click the **Skills** button in the top navigation bar. > Note: The Skills button is visible in all app modes. ## Page Overview ![image-20260108010253926](../../assets/image-20260108010253926.png) ## Discover Skills ### Pre-configured Repositories CC Switch comes pre-configured with the following GitHub repositories: | Repository | Description | |------------|-------------| | Anthropic Official | Official skills provided by Anthropic | | ComposioHQ | Community-maintained skill collection | | Community Picks | Curated high-quality skills | ![image-20260108010308060](../../assets/image-20260108010308060.png) ### Search & Filter CC Switch provides powerful search and filter features: #### Search Box - Search by skill name - Search by skill description - Search by directory name - Real-time filtering, results update as you type #### Status Filter Use the dropdown menu to filter by installation status: | Option | Description | |--------|-------------| | All | Show all skills | | Installed | Show only installed skills | | Not Installed | Show only uninstalled skills | ![image-20260108010324583](../../assets/image-20260108010324583.png) #### Combined Use Search and filter can be combined: - Select "Installed" filter first - Then enter keywords to search - Results show the match count ### Refresh List Click the "Refresh" button to re-scan repositories for the latest skills. ## Install Skills ### Steps 1. Find the skill card you want to install 2. Click the "Install" button 3. Wait for installation to complete ### Installation Location | Application | Install Directory | |-------------|-------------------| | Claude | `~/.claude/skills/` | | Codex | `~/.codex/skills/` | | Gemini | `~/.gemini/skills/` | | OpenCode | `~/.opencode/skills/` | ### Installation Contents Installation copies the skill folder to your local machine: ``` ~/.claude/skills/ └── skill-name/ ├── README.md ├── prompt.md └── tools/ └── ... ``` ## Uninstall Skills ### Steps 1. Find the installed skill card 2. Click the "Uninstall" button 3. Confirm uninstallation ### Uninstall Effect - Deletes the local skill folder - Updates installation status ## Repository Management ### Open Repository Management Click the "Repository Management" button at the top of the page. ### Add Custom Repository 1. Click "Add Repository" 2. Fill in repository information: - Owner: GitHub username or organization name - Name: Repository name - Branch: Branch name (default: main) - Subdirectory: Subdirectory containing skills (optional) 3. Click "Add" ### Repository Format ``` https://github.com/{owner}/{name}/tree/{branch}/{subdirectory} ``` Example: ``` Owner: anthropics Name: claude-skills Branch: main Subdirectory: skills ``` ### Delete Repository 1. Find the repository in the repository list 2. Click the "Delete" button 3. Confirm deletion After deleting a repository, its skills will not disappear from the list, but they can no longer be updated. ## Skill Card Information Each skill card displays: | Information | Description | |-------------|-------------| | Name | Skill name | | Description | Function description | | Source | Source repository | | Status | Installed / Not Installed | ## Skill Updates Automatic updates are not currently supported. To update a skill: 1. Uninstall the existing skill 2. Refresh the list 3. Reinstall ### Empty Skill List Possible causes: - Network issues preventing GitHub access - Incorrect repository configuration Solutions: - Check network connection - Click "Refresh" to retry - Verify repository configuration ### Installation Failed Possible causes: - Network issues - Insufficient disk space - Permission issues Solutions: - Check network connection - Check disk space - Check directory permissions ================================================ FILE: docs/user-manual/en/4-proxy/4.1-service.md ================================================ # 4.1 Proxy Service ## Overview The proxy service starts a local HTTP proxy through which all API requests are forwarded. **Primary uses**: - Record request logs - Track API usage - Support failover - Centrally manage requests from multiple applications ## Start the Proxy ### Option 1: Main Interface Toggle Click the **Proxy Toggle** button at the top of the main interface. Toggle states: - White: Proxy not running - Green: Proxy running ![image-20260108011353927](../../assets/image-20260108011353927.png) ### Option 2: Settings Page 1. Open "Settings > Advanced > Proxy Service" 2. Click the toggle in the top-right corner ![image-20260108011338922](../../assets/image-20260108011338922.png) ## Proxy Configuration ### Basic Configuration | Setting | Description | Default | |---------|-------------|---------| | Listen Address | IP address the proxy binds to | `127.0.0.1` | | Listen Port | Port the proxy listens on | `15721` | | Enable Logging | Whether to record request logs | Enabled | ### Modify Configuration 1. **Stop the proxy service** (must stop first) 2. Modify the listen address or port 3. Click "Save" 4. Restart the proxy > Modifying address/port requires stopping the proxy service first ### Listen Address Options | Address | Description | |---------|-------------| | `127.0.0.1` | Only accessible from local machine (recommended) | | `0.0.0.0` | Allow LAN access | ## Running Status When the proxy is running, the panel displays the following information: ### Service Address ``` http://127.0.0.1:15721 ``` Click the "Copy" button to copy the address. ### Current Providers Displays the currently used provider for each app: ``` Claude: PackyCode Codex: AIGoCode Gemini: Google Official ``` ### Statistics | Metric | Description | |--------|-------------| | Active Connections | Number of requests currently being processed | | Total Requests | Total number of requests since startup | | Success Rate | Percentage of successful requests (>90% green, <=90% yellow) | | Uptime | How long the proxy has been running | ### Failover Queue The proxy panel displays the failover queue by app type: ``` Claude ├── 1. PackyCode [Currently Using] ● ├── 2. AIGoCode ● └── 3. Backup Provider ○ Codex ├── 1. AIGoCode [Currently Using] ● └── 2. Backup Provider ● ``` Queue details: - Numbers indicate priority order - "Currently Using" label indicates the active provider - Health badges show provider status: - Green: Healthy (0 consecutive failures) - Yellow: Degraded (1-2 consecutive failures) - Red: Unhealthy (3+ consecutive failures) ## How It Works ### Request Flow ```mermaid sequenceDiagram participant CLI as CLI Tool (Claude) participant Proxy as Local Proxy (CC Switch) participant API as API Provider (Anthropic) participant DB as Data Store (Logger) CLI->>Proxy: Send API request Proxy->>DB: Record request log / track usage Proxy->>API: Forward request API-->>Proxy: Return response Proxy-->>CLI: Return response ``` ### Configuration Changes After starting the proxy and enabling app takeover, CC Switch modifies app configurations: **Claude**: ```json { "env": { "ANTHROPIC_BASE_URL": "http://127.0.0.1:15721" } } ``` **Codex**: ```toml base_url = "http://127.0.0.1:15721/v1" ``` **Gemini**: ``` GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:15721 ``` ## Stop the Proxy ### Option 1: Main Interface Toggle Click the proxy toggle button to turn it off. ### Option 2: Settings Page Turn off the toggle in the proxy service panel. ### Post-stop Processing When stopping the proxy, CC Switch will: 1. Restore app configurations to their original state 2. Save request logs 3. Close all connections ## Log Recording ### Enable Logging Enable the "Enable Logging" toggle in the proxy panel. ### Log Contents Each request record includes: | Field | Description | |-------|-------------| | Time | Request time | | App | Claude / Codex / Gemini | | Provider | Provider used | | Model | Requested model | | Tokens | Input/output token count | | Latency | Request duration | | Status | Success/failure | ### View Logs View request logs in the "Settings > Usage" tab. ## FAQ ### Port Already in Use Error message: `Address already in use` Solution: 1. Change the port (e.g., to 5001) 2. Or close the program occupying the port ### Proxy Fails to Start Check: - Is the port occupied - Are there sufficient permissions - Is the firewall blocking it ### Request Timeout Possible causes: - Network issues - Provider server issues - Incorrect proxy configuration Solutions: - Check network connection - Try accessing the provider API directly - Check provider configuration ================================================ FILE: docs/user-manual/en/4-proxy/4.2-takeover.md ================================================ # 4.2 App Takeover ## Overview App takeover means letting CC Switch's proxy intercept and forward a specific application's API requests. When takeover is enabled: - The app's API requests are forwarded through the local proxy - Request logs and usage statistics can be recorded - Failover functionality becomes available ## Prerequisites The proxy service must be started before using the app takeover feature. ## Enable Takeover ### Location Settings > Advanced > Proxy Service > App Takeover area ### Steps 1. Ensure the proxy service is started 2. Find the "App Takeover" area 3. Enable the toggle for the desired apps ### Takeover Toggles | Toggle | Effect | |--------|--------| | Claude Takeover | Intercept Claude Code requests | | Codex Takeover | Intercept Codex requests | | Gemini Takeover | Intercept Gemini CLI requests | Multiple app takeovers can be enabled simultaneously. ## How Takeover Works ### Configuration Changes When takeover is enabled, CC Switch modifies the app's configuration file to point the API endpoint to the local proxy. **Claude configuration change**: ```json // Before takeover { "env": { "ANTHROPIC_BASE_URL": "https://api.anthropic.com" } } // After takeover { "env": { "ANTHROPIC_BASE_URL": "http://127.0.0.1:15721" } } ``` **Codex configuration change**: ```toml # Before takeover base_url = "https://api.openai.com/v1" # After takeover base_url = "http://127.0.0.1:15721/v1" ``` **Gemini configuration change**: ```bash # Before takeover GOOGLE_GEMINI_BASE_URL=https://generativelanguage.googleapis.com # After takeover GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:15721 ``` ### Request Forwarding When the proxy receives a request: 1. Identifies the request source (Claude/Codex/Gemini) 2. Looks up the currently enabled provider for that app 3. Forwards the request to the provider's actual endpoint 4. Records the request log 5. Returns the response to the app ## Takeover Status Indicators ### Main Interface Indicators When takeover is enabled, the main interface shows the following changes: - **Proxy logo color**: Changes from colorless to green - **Provider cards**: The currently active provider shows a green border ### Provider Card States | State | Border Color | Description | |-------|--------------|-------------| | Currently Active | Blue | Provider in the config file (non-proxy mode) | | Proxy Active | Green | Provider actually used by the proxy | | Normal | Default | Unused provider | ## Disable Takeover ### Steps 1. Turn off the corresponding app's takeover toggle in the proxy panel 2. Or directly stop the proxy service ### Configuration Restoration When disabling takeover, CC Switch will: 1. Restore the app configuration to its pre-takeover state 2. Save current request logs ## Takeover and Provider Switching ### Switching Providers in Takeover Mode When switching providers in takeover mode: 1. Click the "Enable" button on a provider in the main interface 2. The proxy immediately uses the new provider to forward requests 3. **No need to restart the CLI tool** This is a major advantage of takeover mode: provider switching takes effect instantly. ### Switching Without Takeover When switching providers without takeover: 1. Configuration file is modified 2. CLI tool must be restarted for changes to take effect ## Multi-app Takeover Multiple apps can be taken over simultaneously, each managed independently: - Independent provider configurations - Independent failover queues - Independent request statistics ## Use Cases ### Scenario 1: Usage Monitoring Enable takeover + log recording to monitor API usage. ### Scenario 2: Quick Switching With takeover enabled, switching providers does not require restarting CLI tools. ### Scenario 3: Failover Enabling takeover is a prerequisite for using the failover feature. ## Notes ### Performance Impact The proxy adds minimal latency (typically < 10ms), negligible for most scenarios. ### Network Requirements In takeover mode, CLI tools must be able to access the local proxy address. ### Configuration Backup Before enabling takeover, CC Switch backs up the original configuration and restores it when disabled. ## FAQ ### Requests Fail After Takeover Check: - Is the proxy service running normally - Is the provider configuration correct - Is the network working properly ### Configuration Not Restored After Disabling Takeover Possible causes: - Proxy exited abnormally - Configuration file was modified by another program Solutions: - Manually edit the provider and re-save - Or re-enable and then disable takeover ================================================ FILE: docs/user-manual/en/4-proxy/4.3-failover.md ================================================ # 4.3 Failover ## Overview The failover feature automatically switches to a backup provider when the primary provider's request fails, ensuring uninterrupted service. **Applicable scenarios**: - Unstable provider services - High availability requirements - Long-running tasks ## Prerequisites Using the failover feature requires: 1. Proxy service started 2. App takeover enabled 3. Failover queue configured 4. Auto failover enabled ## Configure the Failover Queue ### Open Configuration Page Settings > Advanced > Failover ### Select Application Three tabs at the top of the page: - Claude - Codex - Gemini Select the application to configure. ### Add Backup Providers 1. In the "Failover Queue" area 2. Click "Add Provider" 3. Select a provider from the dropdown list 4. The provider is added to the end of the queue ### Adjust Priority Drag providers to adjust their order: - Lower numbers mean higher priority - After the primary provider fails, backup providers are tried in order ### Remove Provider Click the "Remove" button to the right of the provider. ## Main Interface Quick Actions When both proxy and failover are enabled, provider cards display a failover toggle. ### Add to Queue 1. Find the provider card 2. Enable the failover toggle 3. The provider is automatically added to the queue ### Remove from Queue 1. Disable the failover toggle on the provider card 2. The provider is removed from the queue ## Enable Auto Failover ### Steps 1. On the failover configuration page 2. Enable the "Auto Failover" toggle ### Toggle Description | State | Behavior | |-------|----------| | Off | Only records failures, no automatic switching | | On | Automatically switches to the next provider on failure | ## Failover Flow ```mermaid graph TD Start[Request arrives at proxy] --> Send[Send to current provider] Send --> CheckSuccess{Success?} CheckSuccess -- Yes --> Return[Return response] CheckSuccess -- No --> LogFail[Record failure] LogFail --> CheckCircuit{Check circuit breaker} CheckCircuit -- Tripped --> Skip[Skip this provider] CheckCircuit -- Not tripped --> IncFail[Increment failure count] Skip --> Next{Next in queue?} IncFail --> Next Next -- Yes --> Switch[Switch provider] Switch --> Retry[Retry request] Retry --> Send Next -- No --> Error[Return error] ``` ## Circuit Breaker Configuration The circuit breaker prevents frequent retries against failing providers. ### Configuration Items Different apps have independent default configurations. Below are general defaults; Claude has its own relaxed configuration. | Setting | Description | General Default | Claude Default | Range | |---------|-------------|-----------------|----------------|-------| | Failure Threshold | Consecutive failures to trigger circuit breaker | 4 | 8 | 1-20 | | Recovery Success Threshold | Successes needed in half-open state to close breaker | 2 | 3 | 1-10 | | Recovery Wait Time | Time before attempting recovery after tripping (seconds) | 60 | 90 | 0-300 | | Error Rate Threshold | Error rate that opens the circuit breaker | 60% | 70% | 0-100% | | Minimum Requests | Minimum requests before calculating error rate | 10 | 15 | 5-100 | > Claude has more relaxed default settings due to longer request times, tolerating more failures. ### Timeout Configuration | Setting | Description | General Default | Claude Default | Range | |---------|-------------|-----------------|----------------|-------| | Stream First Byte Timeout | Max wait time for first data chunk (seconds) | 60 | 90 | 1-120 | | Stream Idle Timeout | Max interval between data chunks (seconds) | 120 | 180 | 60-600 (0 to disable) | | Non-stream Timeout | Total timeout for non-streaming requests (seconds) | 600 | 600 | 60-1200 | ### Retry Configuration | Setting | Description | General Default | Claude Default | Range | |---------|-------------|-----------------|----------------|-------| | Max Retries | Number of retries on request failure | 3 | 6 | 0-10 | > Gemini's default max retries is 5. ### Circuit Breaker States | State | Description | |-------|-------------| | Closed | Normal state, requests allowed | | Open | Circuit broken, this provider is skipped | | Half-Open | Attempting recovery, sending probe requests | ### State Transitions ```mermaid stateDiagram-v2 [*] --> Closed: Initialize Closed --> Open: Failures >= threshold Open --> HalfOpen: Recovery wait time expires HalfOpen --> Closed: Probe successes >= recovery threshold HalfOpen --> Open: Probe failed ``` ## Health Status Indicators ### Provider Cards Cards display health status badges: | Badge | Status | Description | |-------|--------|-------------| | Green | Healthy | 0 consecutive failures | | Yellow | Warning | Has failures but circuit not tripped | | Red | Circuit Broken | Circuit breaker tripped, temporarily skipped | ### Queue List The failover queue also displays each provider's health status. ## Failover Logs Each failover event records: | Information | Description | |-------------|-------------| | Time | When it occurred | | Original Provider | The provider that failed | | New Provider | The provider switched to | | Failure Reason | Error message | Viewable in the request logs within usage statistics. ## Best Practices ### Queue Configuration Recommendations 1. **Primary provider**: The most stable and fastest provider 2. **First backup**: Second-best choice 3. **Second backup**: Last resort ### Circuit Breaker Configuration Recommendations | Scenario | Failure Threshold | Recovery Wait | |----------|-------------------|---------------| | High availability requirement | 2 | 30 seconds | | General scenario | 3 | 60 seconds | | Tolerant of occasional failures | 5 | 120 seconds | ### Monitoring Recommendations Periodically check: - Health status of each provider - Failover frequency - Circuit breaker trigger frequency ## FAQ ### Failover Not Triggering Check: 1. Is the proxy service running 2. Is app takeover enabled 3. Is auto failover enabled 4. Are there backup providers in the queue ### Failover Triggering Too Frequently Possible causes: - Unstable primary provider - Network issues - Configuration errors Solutions: - Check primary provider status - Adjust circuit breaker parameters - Consider changing the primary provider ### All Providers Circuit-Broken Wait for the recovery wait time to expire for automatic recovery, or: 1. Manually restart the proxy service 2. Reset circuit breaker states ================================================ FILE: docs/user-manual/en/4-proxy/4.4-usage.md ================================================ # 4.4 Usage Statistics ## Overview The usage statistics feature records and analyzes API request data, helping you: - Understand API usage patterns - Estimate cost expenditure - Analyze usage patterns - Troubleshoot issues ## Prerequisites Using the usage statistics feature requires: 1. Proxy service started 2. App takeover enabled 3. Log recording enabled ## Open Usage Statistics Settings > Usage Tab ## Statistics Overview ### Summary Cards Key metrics displayed at the top of the page: | Metric | Description | |--------|-------------| | Total Requests | Total number of requests in the time period | | Total Tokens | Total input + output tokens | | Estimated Cost | Cost calculated based on pricing configuration | | Success Rate | Percentage of successful requests | ### Time Range Select the time range for statistics: | Option | Range | |--------|-------| | Today | From 00:00 today to now | | Last 7 Days | Past 7 days | | Last 30 Days | Past 30 days | ![image-20260108011730105](../../assets/image-20260108011730105.png) ## Trend Charts ### Request Trend Line chart showing the trend of request counts: - X-axis: Time - Y-axis: Request count - Viewable by hour/day - Supports zoom and drag ### Token Trend Shows token usage trends: - Input Tokens (blue) - Prompt content sent by the user - Output Tokens (green) - Response content generated by AI - Cache Creation Tokens (orange) - Tokens consumed when first creating cache - Cache Hit Tokens (purple) - Tokens saved by reusing cache - Cost (red dashed line, right Y-axis) - Estimated cost > **Cache Token explanation**: Anthropic API supports Prompt Caching. Creating cache incurs a higher fee (typically 1.25x input price), but subsequent cache hits only charge 0.1x, significantly reducing costs for repeated requests. ### Time Granularity - **Today**: Displayed by hour (24 data points) - **7 Days/30 Days**: Displayed by day ![image-20260108011742847](../../assets/image-20260108011742847.png) ## Detailed Data Three data tabs at the bottom of the page: ### Request Logs Detailed record of each request: | Field | Description | |-------|-------------| | Time | Request time | | Provider | Provider name used | | Model | Requested model (billing model) | | Input Tokens | Number of input tokens | | Output Tokens | Number of output tokens | | Cache Read | Cache hit token count | | Cache Creation | Cache creation token count | | Total Cost | Estimated cost (USD) | | Timing Info | Request duration, time to first token, streaming/non-streaming | | Status | HTTP status code | #### Timing Information The timing info column displays multiple badges: | Badge | Description | Color Rules | |-------|-------------|-------------| | Total Duration | Total request time (seconds) | <=5s green, <=120s orange, >120s red | | First Token | Time to first token in streaming requests | <=5s green, <=120s orange, >120s red | | Stream/Non-stream | Request type | Streaming blue, non-streaming purple | #### View Details Click a request row to view detailed information: - Complete request parameters - Response content summary - Error messages (if failed) #### Filter Logs Supports filtering by the following criteria: | Filter | Options | |--------|---------| | App Type | All / Claude / Codex / Gemini | | Status Code | All / 200 / 400 / 401 / 429 / 500 | | Provider | Text search | | Model | Text search | | Time Range | Start time - End time (datetime picker) | Action buttons: - **Search**: Apply filter criteria - **Reset**: Restore defaults (past 24 hours) - **Refresh**: Reload data ![image-20260108011859974](../../assets/image-20260108011859974.png) ### Provider Statistics Statistics grouped by provider: | Field | Description | |-------|-------------| | Provider | Provider name | | Requests | Total requests for this provider | | Successes | Number of successful requests | | Failures | Number of failed requests | | Success Rate | Success percentage | | Total Tokens | Total token usage | | Estimated Cost | Cost for this provider | ![image-20260108011907928](../../assets/image-20260108011907928.png) ### Model Statistics Statistics grouped by model: | Field | Description | |-------|-------------| | Model | Model name | | Requests | Total requests for this model | | Input Tokens | Total input tokens | | Output Tokens | Total output tokens | | Avg Latency | Average response time | | Estimated Cost | Cost for this model | ![image-20260108011915381](../../assets/image-20260108011915381.png) ## Pricing Configuration ### Open Pricing Configuration Settings > Advanced > Pricing Configuration ### Configure Model Prices Set prices for each model (per million tokens): | Field | Description | |-------|-------------| | Model ID | Model identifier (e.g., claude-3-sonnet) | | Display Name | Custom display name | | Input Price | Price per million input tokens | | Output Price | Price per million output tokens | | Cache Read Price | Price per million cache hit tokens | | Cache Creation Price | Price per million cache creation tokens | ### Operations - **Add**: Click the "Add" button to add model pricing - **Edit**: Click the edit icon at the end of the row to modify - **Delete**: Click the delete icon at the end of the row to remove ![image-20260108011933565](../../assets/image-20260108011933565.png) ### Preset Prices CC Switch includes preset official prices for common models (per million tokens): **Claude Series (USD)**: | Model | Input | Output | Cache Read | Cache Creation | |-------|-------|--------|------------|----------------| | **Claude 4.5 Series** | | | | | | claude-opus-4-5 | $5 | $25 | $0.50 | $6.25 | | claude-sonnet-4-5 | $3 | $15 | $0.30 | $3.75 | | claude-haiku-4-5 | $1 | $5 | $0.10 | $1.25 | | **Claude 4 Series** | | | | | | claude-opus-4 | $15 | $75 | $1.50 | $18.75 | | claude-opus-4-1 | $15 | $75 | $1.50 | $18.75 | | claude-sonnet-4 | $3 | $15 | $0.30 | $3.75 | | **Claude 3.5 Series** | | | | | | claude-3-5-sonnet | $3 | $15 | $0.30 | $3.75 | | claude-3-5-haiku | $0.80 | $4 | $0.08 | $1.00 | **OpenAI Series / Codex (USD)**: | Model | Input | Output | Cache Read | |-------|-------|--------|------------| | **GPT-5.2 Series** | | | | | gpt-5.2 | $1.75 | $14 | $0.175 | | **GPT-5.1 Series** | | | | | gpt-5.1 | $1.25 | $10 | $0.125 | | **GPT-5 Series** | | | | | gpt-5 | $1.25 | $10 | $0.125 | > Note: Codex presets include low/medium/high variants with prices identical to the base model. **Gemini Series (USD)**: | Model | Input | Output | Cache Read | |-------|-------|--------|------------| | **Gemini 3 Series** | | | | | gemini-3-pro-preview | $2 | $12 | $0.20 | | gemini-3-flash-preview | $0.50 | $3 | $0.05 | | **Gemini 2.5 Series** | | | | | gemini-2.5-pro | $1.25 | $10 | $0.125 | | gemini-2.5-flash | $0.30 | $2.50 | $0.03 | **Chinese Provider Models**: > Note: Currency follows each provider's official pricing page. StepFun is currently listed in USD. | Model | Input | Output | Cache Read | |-------|-------|--------|------------| | **StepFun** | | | | | step-3.5-flash | $0.10 | $0.30 | $0.02 | | **DeepSeek** | | | | | deepseek-v3.2 | ¥2.00 | ¥3.00 | ¥0.40 | | deepseek-v3.1 | ¥4.00 | ¥12.00 | ¥0.80 | | deepseek-v3 | ¥2.00 | ¥8.00 | ¥0.40 | | **Kimi (Moonshot)** | | | | | kimi-k2-thinking | ¥4.00 | ¥16.00 | ¥1.00 | | kimi-k2 | ¥4.00 | ¥16.00 | ¥1.00 | | kimi-k2-turbo | ¥8.00 | ¥58.00 | ¥1.00 | | **MiniMax** | | | | | minimax-m2.1 | ¥2.10 | ¥8.40 | ¥0.21 | | minimax-m2.1-lightning | ¥2.10 | ¥16.80 | ¥0.21 | | **Others** | | | | | glm-4.7 | ¥2.00 | ¥8.00 | ¥0.40 | | doubao-seed-code | ¥1.20 | ¥8.00 | ¥0.24 | | mimo-v2-flash | Free | Free | - | ### Custom Prices If using proxy services, prices may differ: 1. Click the "Edit" button 2. Modify prices 3. Save ## FAQ ### Statistics Data Is Empty Check: - Is the proxy service running - Is app takeover enabled - Is log recording enabled - Have requests been going through the proxy ### Cost Estimates Are Inaccurate Possible causes: - Pricing configuration doesn't match actual prices - Using a proxy service with special pricing Solutions: - Update pricing configuration - Refer to the provider's actual invoices ### Token Count Differs from Provider CC Switch uses its own method to estimate token counts, which may slightly differ from the provider's calculation. Refer to the provider's invoice for authoritative numbers. ================================================ FILE: docs/user-manual/en/4-proxy/4.5-model-test.md ================================================ # 4.5 Model Test ## Overview The model test feature verifies whether a provider's configured model is available by sending actual API requests to test: - Whether the model exists - Whether the API Key is valid - Whether the endpoint responds normally - Whether the response latency is acceptable ## Open Configuration Settings > Advanced > Model Test Config ## Test Model Configuration Configure the model used for testing per application: | Application | Setting | Default | Notes | |-------------|---------|---------|-------| | Claude | Claude Model | System default | Recommend using Haiku series (low cost, fast) | | Codex | Codex Model | System default | Recommend using mini series | | Gemini | Gemini Model | System default | Recommend using Flash series | ### Model Selection Tips When choosing a test model, consider: 1. **Cost**: Choose lower-priced models (e.g., Haiku, Mini, Flash) 2. **Speed**: Choose fast-responding models 3. **Availability**: Choose models supported by the provider ## Test Parameter Configuration ### Timeout | Parameter | Description | Default | Range | |-----------|-------------|---------|-------| | Timeout | Single request timeout | 45 seconds | 10-120 seconds | Setting it too short may cause false negatives; too long delays fault detection. ### Retries | Parameter | Description | Default | Range | |-----------|-------------|---------|-------| | Max Retries | Retries after failure | 2 times | 0-5 times | Increase retries when the network is unstable. ### Degradation Threshold | Parameter | Description | Default | Range | |-----------|-------------|---------|-------| | Degradation Threshold | Responses exceeding this time are marked as degraded | 6000ms | 1000-30000ms | Providers exceeding the threshold are marked as "degraded" but remain usable. ## Execute Model Test ### Manual Test Click the "Test" button on the provider card: 1. Sends a test request to the configured endpoint 2. Uses the configured test model 3. Waits for response or timeout 4. Displays the test result ### Test Content The test request: - Sends a short prompt (e.g., "Hi") - Limits maximum output tokens (typically 10-50) - Uses streaming response to detect time to first byte ## Test Results ### Health Status | Status | Icon | Description | |--------|------|-------------| | Healthy | Green | Normal response, latency within threshold | | Degraded | Yellow | Normal response, but latency exceeds threshold | | Unavailable | Red | Request failed or timed out | ### Result Information After testing completes, displays: - Response latency (milliseconds) - Time to first byte (TTFB) - Error message (if failed) ## Integration with Failover Model testing works in conjunction with the failover feature: ### Health Checks After enabling the proxy service, the system periodically performs health checks on providers in the failover queue: 1. Sends a request using the configured test model 2. Updates health status based on the response 3. Unhealthy providers are temporarily skipped ### Circuit Breaker Recovery When a provider recovers from a circuit-broken state: 1. Performs a model test to verify availability 2. If the test passes, normal status is restored 3. If the test fails, the circuit breaker remains active ## FAQ ### Test Fails But Actually Available **Possible causes**: - The test model differs from the actually used model - The provider doesn't support the configured test model **Solutions**: - Change the test model to one supported by the provider - Check the provider's model list ### High Latency **Possible causes**: - Network latency - High server load on the provider - Slow model response **Solutions**: - Use a faster test model - Adjust the degradation threshold - Consider using mirror endpoints ### Frequent Timeouts **Possible causes**: - Timeout set too short - Unstable network - Unstable provider service **Solutions**: - Increase the timeout - Increase retry count - Check network connection ## Notes - Model testing consumes a small amount of API quota - Recommend using low-cost models for testing - Testing frequency should not be too high to avoid wasting quota - Different providers may support different models ================================================ FILE: docs/user-manual/en/5-faq/5.1-config-files.md ================================================ # 5.1 Configuration Files ## CC Switch Data Storage ### Storage Directory Default location: `~/.cc-switch/` Customizable location in settings (for cloud sync). ### Directory Structure ``` ~/.cc-switch/ ├── cc-switch.db # SQLite database ├── settings.json # Device-level settings └── backups/ # Automatic backups ├── backup-20251230-120000.json ├── backup-20251229-180000.json └── ... ``` ### Database Contents `cc-switch.db` is a SQLite database that stores: | Table | Contents | |-------|----------| | providers | Provider configurations | | provider_endpoints | Provider endpoint candidate list | | mcp_servers | MCP server configurations | | prompts | Prompt presets | | skills | Skill installation status | | skill_repos | Skill repository configurations | | proxy_config | Proxy configuration | | proxy_request_logs | Proxy request logs | | provider_health | Provider health status | | model_pricing | Model pricing | | settings | App settings | ### Device Settings `settings.json` stores device-level settings: ```json { "language": "zh", "theme": "system", "windowBehavior": "minimize", "autoStart": false, "claudeConfigDir": null, "codexConfigDir": null, "geminiConfigDir": null, "opencodeConfigDir": null, "openclawConfigDir": null } ``` These settings are not synced across devices. ### Automatic Backups The `backups/` directory stores automatic backups: - Automatically created before each configuration import - Retains the most recent 10 backups - File names include timestamps ## Claude Code Configuration ### Configuration Directory Default: `~/.claude/` ### Key Files ``` ~/.claude/ ├── settings.json # Main configuration file ├── CLAUDE.md # System prompt └── skills/ # Skills directory └── ... ``` ### settings.json ```json { "env": { "ANTHROPIC_API_KEY": "sk-xxx", "ANTHROPIC_BASE_URL": "https://api.anthropic.com" }, "permissions": { "allow_file_access": true } } ``` | Field | Description | |-------|-------------| | `env.ANTHROPIC_API_KEY` | API key | | `env.ANTHROPIC_BASE_URL` | API endpoint (optional) | | `env.ANTHROPIC_AUTH_TOKEN` | Alternative authentication method | ### MCP Configuration MCP server configuration is in `~/.claude.json`: ```json { "mcpServers": { "mcp-fetch": { "command": "uvx", "args": ["mcp-server-fetch"] } } } ``` ## Codex Configuration ### Configuration Directory Default: `~/.codex/` ### Key Files ``` ~/.codex/ ├── auth.json # Authentication configuration ├── config.toml # Main configuration + MCP └── AGENTS.md # System prompt ``` ### auth.json ```json { "OPENAI_API_KEY": "sk-xxx" } ``` ### config.toml ```toml # Basic configuration base_url = "https://api.openai.com/v1" model = "gpt-4" # MCP servers [mcp_servers.mcp-fetch] command = "uvx" args = ["mcp-server-fetch"] ``` ## Gemini CLI Configuration ### Configuration Directory Default: `~/.gemini/` ### Key Files ``` ~/.gemini/ ├── .env # Environment variables (API Key) ├── settings.json # Main configuration + MCP └── GEMINI.md # System prompt ``` ### .env ```bash GEMINI_API_KEY=xxx GOOGLE_GEMINI_BASE_URL=https://generativelanguage.googleapis.com GEMINI_MODEL=gemini-pro ``` ### settings.json ```json { "mcpServers": { "mcp-fetch": { "command": "uvx", "args": ["mcp-server-fetch"] } } } ``` | Field | Description | |-------|-------------| | `mcpServers` | MCP server configuration | ## OpenCode Configuration ### Configuration Directory Default: `~/.opencode/` ### Key Files ``` ~/.opencode/ ├── config.json # Main configuration file ├── AGENTS.md # System prompt └── skills/ # Skills directory └── ... ``` ## OpenClaw Configuration ### Configuration Directory Default: `~/.openclaw/` ### Key Files ``` ~/.openclaw/ ├── openclaw.json # Main configuration file (JSON5 format) ├── AGENTS.md # System prompt └── skills/ # Skills directory └── ... ``` ### openclaw.json OpenClaw uses a JSON5 format configuration file with the following main sections: ```json5 { // Model provider configuration models: { mode: "merge", providers: { "custom-provider": { baseUrl: "https://api.example.com/v1", apiKey: "your-api-key", api: "openai-completions", models: [{ id: "model-id", name: "Model Name" }] } } }, // Environment variables env: { ANTHROPIC_API_KEY: "sk-..." }, // Agent default model configuration agents: { defaults: { model: { primary: "provider/model" } } }, // Tool configuration tools: {}, // Workspace file configuration workspace: {} } ``` | Field | Description | |-------|-------------| | `models.providers` | Provider configuration (mapped to CC Switch's "providers") | | `env` | Environment variable configuration | | `agents.defaults` | Agent default model settings | | `tools` | Tool configuration | | `workspace` | Workspace file management | ## Configuration Priority CC Switch's priority when modifying configurations: 1. **CC Switch Database** - Single source of truth (SSOT) 2. **Live Configuration Files** - Written when switching providers 3. **Backfill Mechanism** - Reads from live files when editing the current provider ## Manual Configuration Editing ### Safe to Edit Manually - CLI tool configuration files (will be backfilled by CC Switch) - CC Switch's `settings.json` ### Not Recommended to Edit Manually - `cc-switch.db` database file - Backup files ### Sync After Editing If you manually edit CLI tool configurations: 1. Open CC Switch 2. Edit the corresponding provider 3. You will see the manual changes have been backfilled 4. Save to sync to the database ## Configuration Migration ### Migrating from Older Versions CC Switch v3.7.0 migrated from JSON files to SQLite: - Automatic migration on first launch - Displays a notification upon successful migration - Old configuration files are retained as backups ### Cross-device Migration 1. Export configuration on the source device 2. Import configuration on the target device 3. Or use the cloud sync feature ## Configuration Backup Recommendations ### Regular Backups It is recommended to regularly export configurations: 1. Settings > Advanced > Data Management 2. Click "Export" 3. Save to a secure location ### Backup Contents The export file includes: - All provider configurations - MCP server configurations - Prompt presets - App settings ### Not Included - Usage logs (large data volume) - Device-level settings (not suitable for cross-device) ================================================ FILE: docs/user-manual/en/5-faq/5.2-questions.md ================================================ # 5.2 Frequently Asked Questions ## Installation Issues ### macOS Shows "Unidentified Developer" **Problem**: First launch shows "Cannot open because it is from an unidentified developer" **Solution 1**: Via System Settings 1. Close the warning dialog 2. Open "System Settings" > "Privacy & Security" 3. Find the CC Switch prompt 4. Click "Open Anyway" 5. Reopen the app **Solution 2**: Via Terminal command (recommended) ```bash sudo xattr -dr com.apple.quarantine /Applications/CC\ Switch.app/ ``` The app can be opened normally after running this command. ### Windows: App Doesn't Launch After Installation **Possible causes**: - Missing WebView2 runtime - Antivirus software blocking **Solutions**: 1. Install [Microsoft Edge WebView2](https://developer.microsoft.com/en-us/microsoft-edge/webview2/) 2. Add CC Switch to your antivirus software's whitelist ### Linux: Startup Error **Problem**: AppImage won't start **Solution**: ```bash # Add execute permission chmod +x CC-Switch-*.AppImage # If it still fails, try ./CC-Switch-*.AppImage --no-sandbox ``` ## Provider Issues ### Provider Switch Doesn't Take Effect **Cause**: The CLI tool needs to reload its configuration **Solutions**: - Claude Code: Close and reopen the terminal, or restart the IDE - Codex: Close and reopen the terminal - Gemini: Tray switching takes effect immediately, no restart needed ### API Key Invalid **Troubleshooting steps**: 1. Confirm the API Key is copied correctly (no extra spaces) 2. Confirm the API Key hasn't expired 3. Confirm the endpoint URL is correct 4. Use the speed test to verify connectivity ### How to Restore Official Login **Steps**: 1. Select the "Official Login" preset (Claude/Codex) or "Google Official" preset (Gemini) 2. Click "Enable" 3. Restart the corresponding CLI tool 4. Follow the CLI tool's login flow ## Proxy Issues ### Proxy Service Fails to Start **Possible cause**: Port is occupied **Solution**: 1. Check port usage: ```bash # macOS/Linux lsof -i :49152 # Windows netstat -ano | findstr :49152 ``` 2. Close the program occupying the port 3. Or try modifying the configuration to restore the default port: - Open "Settings > Proxy Service" - Click the "Reset to Default" button ### Request Timeout in Proxy Mode **Possible causes**: - Network issues - Provider server issues - Incorrect proxy configuration **Solutions**: 1. Check network connection 2. Try accessing the provider API directly (disable proxy) 3. Check if provider configuration is correct ### Configuration Not Restored After Disabling Proxy **Possible cause**: Proxy exited abnormally **Solution**: 1. Edit the current provider 2. Check if the endpoint URL is correct 3. Save to update the configuration ## Failover Issues ### Failover Not Triggering **Checklist**: - [ ] Is the proxy service running - [ ] Is app takeover enabled - [ ] Is auto failover enabled - [ ] Are there backup providers in the queue ### Failover Triggering Too Frequently **Possible causes**: - Unstable primary provider - Circuit breaker threshold set too low **Solutions**: 1. Check primary provider status 2. Increase the failure threshold (e.g., from 3 to 5) 3. Consider changing the primary provider ### All Providers Are Circuit-Broken **Solutions**: 1. Wait for the recovery wait time to expire (default 60 seconds) 2. Or restart the proxy service to reset states ## Data Issues ### Configuration Lost **Possible causes**: - Configuration directory was deleted - Database corruption **Solutions**: 1. Check if the `~/.cc-switch/` directory exists 2. Restore from backup: `~/.cc-switch/backups/` 3. Or import from a previously exported configuration file ### Import Configuration Failed **Possible causes**: - Incorrect file format - Version incompatibility **Solutions**: 1. Confirm the file was exported by CC Switch 2. Check if the file content is complete 3. Try opening with a text editor to check format ### Usage Statistics Data Is Empty **Checklist**: - [ ] Is the proxy service running - [ ] Is app takeover enabled - [ ] Is log recording enabled - [ ] Have requests been going through the proxy ## Other Issues ### Tray Icon Not Showing **macOS**: - Check menu bar icon settings in System Settings **Windows**: - Check taskbar settings to ensure the CC Switch icon is not hidden **Linux**: - System tray support may need to be installed (e.g., `libappindicator`) ### UI Display Issues **Solutions**: 1. Try switching themes (light/dark) 2. Restart the app 3. Delete `~/.cc-switch/settings.json` to reset settings ### Update Failed **Solutions**: 1. Check network connection 2. Manually download and install the latest version 3. If using Homebrew: `brew upgrade --cask cc-switch` ## Getting Help ### Submit an Issue If none of the above solutions work: 1. Visit [GitHub Issues](https://github.com/farion1231/cc-switch/issues) 2. Search for similar issues 3. If none found, create a new Issue 4. Provide the following information: - Operating system and version - CC Switch version - Problem description and reproduction steps - Error messages (if any) ### Log Files Attach log files when submitting an Issue: - macOS/Linux: `~/.cc-switch/logs/` - Windows: `%APPDATA%\cc-switch\logs\` ================================================ FILE: docs/user-manual/en/5-faq/5.3-deeplink.md ================================================ # 5.3 Deep Link Protocol ## Overview CC Switch supports the `ccswitch://` deep link protocol, enabling one-click configuration import via links. **Use cases**: - Team configuration sharing - One-click setup in tutorials - Quick sync across devices ## Online Generator Tool CC Switch provides an online deep link generator tool: **URL**: [https://farion1231.github.io/cc-switch/deplink.html](https://farion1231.github.io/cc-switch/deplink.html) ### How to Use 1. Open the above URL 2. Select the import type (Provider/MCP/Prompt) 3. Fill in the configuration information 4. Click "Generate Link" 5. Copy the generated deep link 6. Share with others or use on other devices ## Protocol Format ### V1 Protocol Uses URL parameter format, easy to read and generate: ``` ccswitch://v1/import?resource={type}&app={app}&name={name}&... ``` **Common parameters**: | Parameter | Required | Description | |-----------|----------|-------------| | `resource` | Yes | Resource type: `provider` / `mcp` / `prompt` / `skill` | | `app` | Yes | App type: `claude` / `codex` / `gemini` / `opencode` / `openclaw` | | `name` | Yes | Name | **Provider parameters** (resource=provider): | Parameter | Required | Description | |-----------|----------|-------------| | `endpoint` | No | API endpoint URL (supports comma-separated multiple URLs) | | `apiKey` | No | API key | | `homepage` | No | Provider website | | `model` | No | Default model | | `haikuModel` | No | Haiku model (Claude only) | | `sonnetModel` | No | Sonnet model (Claude only) | | `opusModel` | No | Opus model (Claude only) | | `notes` | No | Notes | | `icon` | No | Icon | | `config` | No | Base64-encoded configuration content | | `configFormat` | No | Configuration format: `json` / `toml` | | `configUrl` | No | Remote configuration URL | | `enabled` | No | Whether to enable (boolean) | | `usageScript` | No | Usage query script | | `usageEnabled` | No | Whether to enable usage query (default true) | | `usageApiKey` | No | Usage query API Key | | `usageBaseUrl` | No | Usage query base URL | | `usageAccessToken` | No | Usage query access token | | `usageUserId` | No | Usage query user ID | | `usageAutoInterval` | No | Auto query interval (minutes) | **Prompt parameters** (resource=prompt): | Parameter | Required | Description | |-----------|----------|-------------| | `content` | Yes | Prompt content | | `description` | No | Description | | `enabled` | No | Whether to enable (boolean) | **MCP parameters** (resource=mcp): | Parameter | Required | Description | |-----------|----------|-------------| | `apps` | Yes | App list (comma-separated, e.g., `claude,codex,gemini,opencode`) | | `config` | Yes | MCP server configuration (JSON format) | | `enabled` | No | Whether to enable (boolean) | **Skill parameters** (resource=skill): | Parameter | Required | Description | |-----------|----------|-------------| | `repo` | Yes | Repository (format: `owner/name`) | | `directory` | No | Directory path | | `branch` | No | Git branch | **Example**: ``` ccswitch://v1/import?resource=provider&app=claude&name=My%20Provider&endpoint=https%3A%2F%2Fapi.example.com&apiKey=sk-xxx ``` ## Import Type Examples ### Import Provider ``` ccswitch://v1/import?resource=provider&app=claude&name=My%20Provider&endpoint=https%3A%2F%2Fapi.example.com&apiKey=sk-xxx ``` ### Import MCP Server ``` ccswitch://v1/import?resource=mcp&apps=claude,codex&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22mcp-server-fetch%22%5D%7D&name=mcp-fetch ``` ### Import Prompt Preset ``` ccswitch://v1/import?resource=prompt&app=claude&name=%E4%BB%A3%E7%A0%81%E5%AE%A1%E6%9F%A5&content=%23%20%E8%A7%92%E8%89%B2%0A%E4%BD%A0%E6%98%AF%E4%B8%80%E4%B8%AA%E4%B8%93%E4%B8%9A%E7%9A%84%E4%BB%A3%E7%A0%81%E5%AE%A1%E6%9F%A5%E4%B8%93%E5%AE%B6 ``` ### Import Skill ``` ccswitch://v1/import?resource=skill&name=my-skill&repo=owner/repo&directory=skills/my-skill&branch=main ``` ## Generate Deep Links ### Manual Generation 1. Prepare parameters 2. Assemble the URL following V1 protocol format 3. URL-encode special characters **Example**: ```javascript const params = new URLSearchParams({ resource: 'provider', app: 'claude', name: 'My Provider', endpoint: 'https://api.example.com', apiKey: 'sk-xxx' }); const url = `ccswitch://v1/import?${params.toString()}`; ``` ### Online Tool Using CC Switch's official online deep link generator tool is more convenient. ## Using Deep Links ### Click the Link Click a deep link in a browser or other application: 1. The system asks whether to open CC Switch 2. After confirming, CC Switch opens 3. An import confirmation dialog is displayed 4. Confirm the import ### Import Confirmation A confirmation dialog is shown before import, containing: - Import type - Configuration preview - Confirm/Cancel buttons **Security tip**: Only import configurations from trusted sources. ## Protocol Registration ### Automatic Registration CC Switch automatically registers the `ccswitch://` protocol during installation. ### Manual Registration If the protocol is not registered correctly: **macOS**: Reinstall the app, or run: ```bash /usr/bin/open -a "CC Switch" --args --register-protocol ``` **Windows**: Reinstall the app, or check the registry: ``` HKEY_CLASSES_ROOT\ccswitch ``` **Linux**: Check the `MimeType` configuration in the `.desktop` file. ## Security Considerations ### Sensitive Information Deep links may contain sensitive information (e.g., API Keys): - Do not share links containing API Keys in public - Remove or replace sensitive information before sharing - Use secure channels to transmit links ### Source Verification Before import, CC Switch will: 1. Validate the data format 2. Display a configuration preview 3. Require user confirmation ### Malicious Link Protection CC Switch checks: - Whether the data format is valid - Whether required fields are complete - Whether configuration values are within reasonable ranges ## Example Links ### Example: Import Claude Provider ``` ccswitch://v1/import?resource=provider&app=claude&name=Test%20Provider&apiKey=sk-xxx&endpoint=https%3A%2F%2Fapi.example.com ``` ### Example: Import MCP Server ``` ccswitch://v1/import?resource=mcp&name=mcp-fetch&apps=claude,codex,gemini&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22mcp-server-fetch%22%5D%7D ``` ## Troubleshooting ### Link Won't Open **Check**: 1. Is CC Switch installed 2. Is the protocol registered correctly 3. Is the link format correct ### Import Failed **Possible causes**: - Base64 encoding error - JSON format error - Missing required fields **Solutions**: 1. Check the original JSON format 2. Re-encode in Base64 3. Ensure all required fields are present ================================================ FILE: docs/user-manual/en/5-faq/5.4-env-conflict.md ================================================ # 5.4 Environment Variable Conflicts ## Overview CC Switch automatically detects conflicts between system environment variables and app configurations, preventing configurations from being unexpectedly overridden. **Detected environment variables**: - `ANTHROPIC_API_KEY` - Claude API key - `ANTHROPIC_BASE_URL` - Claude API endpoint - `OPENAI_API_KEY` - OpenAI API key - `GEMINI_API_KEY` - Gemini API key - Other related environment variables ## Conflict Warning When a conflict is detected, a yellow warning banner appears at the top of the interface: ``` Warning: Environment variable conflict detected Found X environment variables that may conflict with CC Switch configuration [Expand] [Dismiss] ``` ## View Conflict Details Click the "Expand" button to view detailed information: | Field | Description | |-------|-------------| | Variable Name | Environment variable name | | Variable Value | Currently set value | | Source | Where the variable originates from | ### Source Types | Source | Description | |--------|-------------| | User Registry | Windows user-level environment variable | | System Registry | Windows system-level environment variable | | Shell Configuration | macOS/Linux shell configuration file | | System Environment | System-level environment variable | ## Resolve Conflicts ### Select Variables to Remove 1. Check the environment variables you want to remove 2. Or click "Select All" to select all conflicting variables ### Remove Variables 1. Click the "Remove Selected" button 2. Confirm the removal operation 3. CC Switch will automatically back up and remove the selected variables ### Automatic Backup A backup is automatically created before removal: - Backup location: `~/.cc-switch/env-backups/` - Backup format: JSON file - Includes variable name, value, source, and other information ## Dismiss Warning If you confirm the conflict does not affect usage, you can: 1. Click the "Dismiss" button on the right side of the warning banner 2. The warning will be temporarily hidden 3. Detection will run again on next launch ## Manual Resolution If you prefer not to use CC Switch to remove variables, you can handle them manually: ### Windows 1. Open "System Properties > Advanced > Environment Variables" 2. Find the conflicting variable in User or System variables 3. Delete or modify the variable ### macOS / Linux 1. Edit the shell configuration file (e.g., `~/.zshrc`, `~/.bashrc`) 2. Delete or comment out the relevant `export` statements 3. Reload the configuration: `source ~/.zshrc` ## Why Do Conflicts Occur Environment variables typically take priority over configuration files, which may cause: - CC Switch provider configurations being overridden - API requests being sent to the wrong endpoint - Using the wrong API key ## Best Practices 1. **Use CC Switch to manage configurations**: Avoid setting API keys in system environment variables 2. **Check regularly**: Pay attention to conflict warnings and address them promptly 3. **Back up important variables**: Confirm backups exist before removal ## Restore Deleted Variables If you accidentally deleted environment variables: 1. Find the backup file: `~/.cc-switch/env-backups/` 2. Open the corresponding JSON file 3. Manually restore the variable to the system environment ================================================ FILE: docs/user-manual/en/README.md ================================================ # CC Switch User Manual > All-in-One Assistant for Claude Code / Codex / Gemini CLI / OpenCode / OpenClaw ## Table of Contents ``` CC Switch User Manual │ ├── 1. Getting Started │ ├── 1.1 Introduction │ ├── 1.2 Installation Guide │ ├── 1.3 Interface Overview │ ├── 1.4 Quick Start │ └── 1.5 Personalization │ ├── 2. Provider Management │ ├── 2.1 Add Provider │ ├── 2.2 Switch Provider │ ├── 2.3 Edit Provider │ ├── 2.4 Sort & Duplicate │ └── 2.5 Usage Query │ ├── 3. Extensions │ ├── 3.1 MCP Server Management │ ├── 3.2 Prompts Management │ └── 3.3 Skills Management │ ├── 4. Proxy & High Availability │ ├── 4.1 Proxy Service │ ├── 4.2 App Takeover │ ├── 4.3 Failover │ ├── 4.4 Usage Statistics │ └── 4.5 Model Test │ └── 5. FAQ ├── 5.1 Configuration Files ├── 5.2 FAQ ├── 5.3 Deep Link Protocol └── 5.4 Environment Variable Conflicts ``` ## File List ### 1. Getting Started | File | Description | |------|-------------| | [1.1-introduction.md](./1-getting-started/1.1-introduction.md) | Introduction, core features, supported platforms | | [1.2-installation.md](./1-getting-started/1.2-installation.md) | Windows/macOS/Linux installation guide | | [1.3-interface.md](./1-getting-started/1.3-interface.md) | Interface layout, navigation bar, provider cards | | [1.4-quickstart.md](./1-getting-started/1.4-quickstart.md) | 5-minute quick start tutorial | | [1.5-settings.md](./1-getting-started/1.5-settings.md) | Language, theme, directories, cloud sync settings | ### 2. Provider Management | File | Description | |------|-------------| | [2.1-add.md](./2-providers/2.1-add.md) | Using presets, custom configuration, universal providers | | [2.2-switch.md](./2-providers/2.2-switch.md) | Main UI switching, tray switching, activation methods | | [2.3-edit.md](./2-providers/2.3-edit.md) | Edit configuration, modify API Key, backfill mechanism | | [2.4-sort-duplicate.md](./2-providers/2.4-sort-duplicate.md) | Drag-to-reorder, duplicate provider, delete | | [2.5-usage-query.md](./2-providers/2.5-usage-query.md) | Usage query, remaining balance, multi-plan display | ### 3. Extensions | File | Description | |------|-------------| | [3.1-mcp.md](./3-extensions/3.1-mcp.md) | MCP protocol, add servers, app binding | | [3.2-prompts.md](./3-extensions/3.2-prompts.md) | Create presets, activate/switch, smart backfill | | [3.3-skills.md](./3-extensions/3.3-skills.md) | Discover skills, install/uninstall, repository management | ### 4. Proxy & High Availability | File | Description | |------|-------------| | [4.1-service.md](./4-proxy/4.1-service.md) | Start proxy, configuration, running status | | [4.2-takeover.md](./4-proxy/4.2-takeover.md) | App takeover, configuration changes, status indicators | | [4.3-failover.md](./4-proxy/4.3-failover.md) | Failover queue, circuit breaker, health status | | [4.4-usage.md](./4-proxy/4.4-usage.md) | Usage statistics, trend charts, pricing configuration | | [4.5-model-test.md](./4-proxy/4.5-model-test.md) | Model test, health check, latency testing | ### 5. FAQ | File | Description | |------|-------------| | [5.1-config-files.md](./5-faq/5.1-config-files.md) | CC Switch storage, CLI configuration file formats | | [5.2-questions.md](./5-faq/5.2-questions.md) | Frequently asked questions | | [5.3-deeplink.md](./5-faq/5.3-deeplink.md) | Deep link protocol, generation and usage | | [5.4-env-conflict.md](./5-faq/5.4-env-conflict.md) | Environment variable conflict detection and resolution | ## Quick Links - **New users**: Start with [1.1 Introduction](./1-getting-started/1.1-introduction.md) - **Installation issues**: See [1.2 Installation Guide](./1-getting-started/1.2-installation.md) - **Configure providers**: See [2.1 Add Provider](./2-providers/2.1-add.md) - **Using proxy**: See [4.1 Proxy Service](./4-proxy/4.1-service.md) - **Having trouble**: See [5.2 FAQ](./5-faq/5.2-questions.md) ## Version Information - Documentation version: v3.12.0 - Last updated: 2026-03-09 - Applicable to CC Switch v3.12.0+ ## Contributing Feel free to submit Issues or PRs to improve the documentation: - [GitHub Issues](https://github.com/farion1231/cc-switch/issues) - [GitHub Repository](https://github.com/farion1231/cc-switch) ================================================ FILE: docs/user-manual/ja/1-getting-started/1.1-introduction.md ================================================ # 1.1 ソフトウェア紹介 ## CC Switch とは CC Switch はクロスプラットフォームのデスクトップアプリケーションで、AI プログラミングツールを使用する開発者向けに設計されています。**Claude Code**、**Codex**、**Gemini CLI**、**OpenCode**、**OpenClaw** の 5 つの AI プログラミングツールの設定を統一的に管理できます。 ## どのような問題を解決するか 日常の開発で、以下のような課題に直面することがあります: - **複数プロバイダーの切り替えが面倒**:異なる API プロバイダー(公式、中継サービスなど)を使用する際、設定ファイルを手動で変更する必要がある - **設定が分散して管理しづらい**:Claude、Codex、Gemini、OpenCode、OpenClaw がそれぞれ独立した設定ファイルを持ち、フォーマットも異なる - **使用量を監視できない**:API をどれだけ呼び出したか、いくらかかったかが分からない - **サービスが不安定**:単一プロバイダーに問題が発生すると、ワークフロー全体が中断する CC Switch は統一されたインターフェースでこれらの問題を解決します。 ## 主要機能 ### プロバイダー管理 - ワンクリックで複数の API プロバイダー設定を切り替え - プリセットテンプレートで一般的なプロバイダーを素早く追加 - 統一プロバイダー機能で、アプリ間で設定を共有 - 使用量クエリと残額表示 - エンドポイント速度テスト ### 拡張機能 - **MCP サーバー**:Model Context Protocol サーバーを管理し、AI の機能を拡張 - **Prompts**:システムプロンプトのプリセットを管理し、さまざまなシーンで素早く切り替え - **Skills**:スキル拡張のインストールと管理 ### プロキシと高可用性 - ローカルプロキシサービスで、リクエストログと使用量統計を記録 - 自動フェイルオーバー、メインプロバイダーの障害時にバックアップへ自動切り替え - サーキットブレーカー機能で、障害プロバイダーへの頻繁なリトライを防止 - 詳細な Token 使用量トラッキングとコスト見積もり ## 対応アプリケーション | アプリ | 説明 | |------|------| | **Claude Code** | Anthropic 公式の AI プログラミングアシスタント | | **Codex** | OpenAI のコード生成ツール | | **Gemini CLI** | Google の AI コマンドラインツール | | **OpenCode** | オープンソース AI プログラミングターミナルツール | | **OpenClaw** | オープンソース AI プログラミングアシスタント(マルチプロバイダーゲートウェイ) | ## 対応プラットフォーム - **Windows** 10 以上 - **macOS** 10.15 (Catalina) 以上 - **Linux** Ubuntu 22.04+ / Debian 11+ / Fedora 34+ ## 技術アーキテクチャ CC Switch はモダンな技術スタックで構築されています: - **フロントエンド**:React 18 + TypeScript + Tailwind CSS - **バックエンド**:Tauri 2 + Rust - **データストレージ**:SQLite(プロバイダー、MCP、Prompts)+ JSON(デバイス設定) このアーキテクチャにより: - クロスプラットフォームでの一貫した体験 - ネイティブレベルのパフォーマンス - 安全なローカルデータストレージ ================================================ FILE: docs/user-manual/ja/1-getting-started/1.2-installation.md ================================================ # 1.2 インストールガイド ## 前提条件 ### Node.js のインストール CC Switch が管理する CLI ツール(Claude Code、Codex、Gemini CLI)には Node.js 環境が必要です。 **推奨バージョン**:Node.js 18 LTS 以上 #### Windows 1. [Node.js 公式サイト](https://nodejs.org/) にアクセス 2. LTS バージョンのインストーラーをダウンロード 3. インストーラーを実行し、指示に従ってインストール 4. インストールの確認: ```bash node --version npm --version ``` #### macOS ```bash # Homebrew でインストール brew install node # または nvm を使用(推奨) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash nvm install --lts ``` #### Linux ```bash # Ubuntu/Debian curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - sudo apt-get install -y nodejs # または nvm を使用 curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash nvm install --lts ``` ### CLI ツールのインストール #### Claude Code **方法 1:Homebrew(macOS 推奨)** ```bash brew install claude-code ``` **方法 2:npm** ```bash npm install -g @anthropic-ai/claude-code ``` #### Codex **方法 1:Homebrew(macOS 推奨)** ```bash brew install codex ``` **方法 2:npm** ```bash npm install -g @openai/codex ``` #### Gemini CLI **方法 1:Homebrew(macOS 推奨)** ```bash brew install gemini-cli ``` **方法 2:npm** ```bash npm install -g @google/gemini-cli ``` --- ## Windows ### インストーラー方式 1. [Releases ページ](https://github.com/farion1231/cc-switch/releases) にアクセス 2. `CC-Switch-v{バージョン}-Windows.msi` をダウンロード 3. インストーラーをダブルクリックして実行 4. 指示に従ってインストール ### ポータブル版(インストール不要) 1. `CC-Switch-v{バージョン}-Windows-Portable.zip` をダウンロード 2. 任意のディレクトリに展開 3. `CC-Switch.exe` を実行 ## macOS ### 方法 1:Homebrew(推奨) ```bash # tap を追加 brew tap farion1231/ccswitch # インストール brew install --cask cc-switch ``` 最新バージョンに更新: ```bash brew upgrade --cask cc-switch ``` ### 方法 2:手動ダウンロード 1. `CC-Switch-v{バージョン}-macOS.zip` をダウンロード 2. 展開して `CC Switch.app` を取得 3. 「アプリケーション」フォルダにドラッグ ### 初回起動時の警告 開発者が Apple 開発者アカウントを持っていないため、初回起動時に「不明な開発者」の警告が表示される場合があります: **推奨される解決方法**: ターミナルで以下のコマンドを実行してください: ```bash sudo xattr -dr com.apple.quarantine /Applications/CC\ Switch.app/ ``` **別の解決方法(システム設定から)**: 1. 警告ダイアログを閉じる 2. 「システム設定」→「プライバシーとセキュリティ」を開く 3. CC Switch に関する表示を見つけ、「このまま開く」をクリック 4. 再度アプリを開くと正常に使用可能 ## Linux ### ArchLinux AUR ヘルパーを使用してインストール: ```bash # paru を使用 paru -S cc-switch-bin # または yay を使用 yay -S cc-switch-bin ``` ### Debian / Ubuntu 1. `CC-Switch-v{バージョン}-Linux.deb` をダウンロード 2. インストール: ```bash sudo dpkg -i CC-Switch-v{バージョン}-Linux.deb # 依存関係に問題がある場合 sudo apt-get install -f ``` ### AppImage(汎用) 1. `CC-Switch-v{バージョン}-Linux.AppImage` をダウンロード 2. 実行権限を追加: ```bash chmod +x CC-Switch-v{バージョン}-Linux.AppImage ``` 3. 実行: ```bash ./CC-Switch-v{バージョン}-Linux.AppImage ``` ## インストールの確認 インストール完了後、CC Switch を起動します: 1. アプリウィンドウが正常に表示される 2. システムトレイに CC Switch のアイコンが表示される 3. Claude / Codex / Gemini の 3 つのアプリを切り替えられる ## 自動更新 CC Switch には自動更新機能が内蔵されています: - 起動時に自動で更新を確認 - 新しいバージョンがある場合、画面に更新通知を表示 - クリックするとダウンロードしてインストール 「設定 → バージョン情報」から手動で更新を確認することもできます。 ## アンインストール ### Windows - 「設定 → アプリ」からアンインストール - またはインストールディレクトリのアンインストーラーを実行 ### macOS - `CC Switch.app` をゴミ箱に移動 - オプション:設定ディレクトリ `~/.cc-switch/` を削除 ### Linux ```bash # Debian/Ubuntu sudo apt remove cc-switch # ArchLinux paru -R cc-switch-bin ``` ================================================ FILE: docs/user-manual/ja/1-getting-started/1.3-interface.md ================================================ # 1.3 インターフェース概要 ## メイン画面のレイアウト ![image-20260108001629138](../../assets/image-20260108001629138.png) ## 上部ナビゲーションバー | 番号 | 要素 | 機能説明 | |------|------|----------| | ① | Logo | クリックで GitHub プロジェクトページにアクセス | | ② | 設定ボタン | 設定ページを開く(ショートカット `Cmd/Ctrl + ,`) | | ③ | プロキシスイッチ | ローカルプロキシサービスの起動/停止 | | ④ | アプリ切り替え | Claude / Codex / Gemini / OpenCode / OpenClaw を切り替え | | ⑤ | 機能エリア | Skills / Prompts / MCP の入口 | | ⑥ | 追加ボタン | 新しいプロバイダーを追加 | ### アプリ切り替え ドロップダウンメニューをクリックして、現在管理するアプリを切り替えます: - **Claude** - Claude Code の設定を管理 - **Codex** - Codex の設定を管理 - **Gemini** - Gemini CLI の設定を管理 - **OpenCode** - OpenCode の設定を管理 - **OpenClaw** - OpenClaw の設定を管理 切り替え後、プロバイダーリストに対応アプリの設定が表示されます。 ### 機能エリアボタン | ボタン | 機能 | 表示条件 | |------|------|----------| | Skills | スキル拡張管理 | 常に表示 | | Prompts | システムプロンプト管理 | 常に表示 | | MCP | MCP サーバー管理 | 常に表示 | ## プロバイダーカード 各プロバイダーはカード形式で表示されます。左から右へ以下の要素が含まれています: ### カード要素(左から右) | 番号 | 要素 | アイコン | 機能説明 | |------|------|------|----------| | ① | ドラッグハンドル | ≡ | 長押しして上下にドラッグしてプロバイダーの順序を調整 | | ② | プロバイダーアイコン | - | プロバイダーのブランドアイコンを表示、カラーのカスタマイズ可能 | | ③ | プロバイダー情報 | - | 名前、メモ/エンドポイントアドレス(クリックで公式サイトを開く) | | ④ | 使用量情報 | - | 残額を表示、複数プランの場合はプラン数を表示 | | ⑤ | 有効化ボタン | ▶ | 現在使用中のプロバイダーに切り替え | | ⑥ | 編集ボタン | ✏️ | プロバイダー設定を編集 | | ⑦ | 複製ボタン | - | プロバイダーを複製(コピーを作成) | | ⑧ | テストボタン | - | モデルの可用性と応答速度をテスト | | ⑨ | 使用量クエリ | - | 使用量クエリスクリプトを設定 | | ⑩ | 削除ボタン | - | プロバイダーを削除(現在有効な場合は無効) | > **ヒント**:操作ボタンエリア(⑤-⑩)はマウスホバー時に表示され、通常は非表示で画面をすっきり保ちます。 ### ボタンの詳細説明 | ボタン | 状態変化 | 説明 | |------|----------|------| | **有効化** | 有効化済みの場合は ✓ を表示して無効化 | フェイルオーバーモードでは「参加/参加済み」に変化 | | **編集** | 常に使用可能 | 編集パネルを開いて設定を変更 | | **複製** | 常に使用可能 | プロバイダーのコピーを作成、名前に `copy` が付加 | | **テスト** | テスト中はローディングアニメーション | プロキシサービス実行中のみ使用可能 | | **使用量クエリ** | 常に使用可能 | カスタム使用量クエリスクリプトを設定 | | **削除** | 現在有効な場合は半透明で無効 | 先に他のプロバイダーに切り替える必要あり | ### カードの状態 | 状態 | 枠の色 | 説明 | |------|----------|------| | **現在有効** | 青い枠 | 通常モードで現在使用中のプロバイダー | | **プロキシアクティブ** | 緑の枠 | プロキシ接管モードで実際に使用中のプロバイダー | | **通常状態** | デフォルトの枠 | 有効化されていないプロバイダー | | **フェイルオーバー中** | 優先度バッジを表示 | P1、P2 などのフェイルオーバー優先度を表示 | ### ヘルスステータスバッジ プロキシモードでは、フェイルオーバーキューに参加しているプロバイダーにヘルスステータスが表示されます: | バッジ | 色 | 説明 | |------|------|------| | 健康 | 緑 | 連続失敗回数 0 | | 警告 | 黄 | 連続失敗回数 1-2 | | 不健康 | 赤 | 連続失敗回数 ≥3、サーキットブレーカーが発動する可能性あり | ## システムトレイ CC Switch はシステムトレイにアイコンを表示し、クイック操作の入口を提供します。 ### トレイメニュー構造 ![image-20260108002153668](../../assets/image-20260108002153668.png) ### メニュー機能 | メニュー項目 | 機能 | |--------|------| | メインウィンドウを開く | メインウィンドウを表示してフォーカス | | アプリグループ | Claude/Codex/Gemini/OpenCode/OpenClaw ごとにプロバイダーを表示 | | プロバイダーリスト | クリックで切り替え、現在有効なものにはチェックマークを表示 | | 終了 | アプリを完全に終了 | ### 多言語対応 トレイメニューは 3 つの言語に対応し、設定に応じて自動的に切り替わります: | 言語 | メインウィンドウを開く | 終了 | |------|-----------|------| | 中文 | 打开主界面 | 退出 | | English | Open main window | Quit | | 日本語 | メインウィンドウを開く | 終了 | ### 使用シーン トレイからのプロバイダー切り替えはメイン画面を開く必要がなく、以下の場面に適しています: - 頻繁にプロバイダーを切り替える場合 - メインウィンドウが最小化されているときの素早い操作 - バックグラウンド実行中の設定管理 ## 設定ページ 設定ページは複数のタブに分かれています: ### 一般タブ - 言語設定(中文/English/日本語) - テーマ設定(システムに合わせる/ライト/ダーク) - ウィンドウ動作(起動時に自動実行、閉じる動作) ### 詳細タブ - 設定ディレクトリの設定 - プロキシサービスの設定 - フェイルオーバーの設定 - 料金設定 - データのインポート/エクスポート ### 使用量タブ - リクエスト統計の概要 - トレンドグラフ - リクエストログ - プロバイダー/モデル統計 ### バージョン情報タブ - バージョン情報 - 更新の確認 - オープンソースライセンス ## ショートカットキー | ショートカット | 機能 | |--------|------| | `Cmd/Ctrl + ,` | 設定を開く | | `Cmd/Ctrl + F` | プロバイダーを検索 | | `Esc` | ダイアログ/検索を閉じる | ## 検索機能 `Cmd/Ctrl + F` で検索ボックスを開きます: - 名前、メモ、URL で検索可能 - プロバイダーリストをリアルタイムでフィルタリング - `Esc` で検索を閉じる ================================================ FILE: docs/user-manual/ja/1-getting-started/1.4-quickstart.md ================================================ # 1.4 クイックスタート このセクションでは、5 分で初回設定を完了する方法を説明します。 ## ステップ 1:プロバイダーの追加 1. メイン画面右上の **+** ボタンをクリック 2. 「プリセット」ドロップダウンからプロバイダーを選択 - よく使われるプリセット:智谱 GLM、MiniMax、DeepSeek、Kimi、PackyCode - または「カスタム」を選択して手動設定 3. **API Key** を入力 4. 「追加」をクリック ![image-20260108002807657](../../assets/image-20260108002807657.png) > **ヒント**:プリセットではエンドポイントアドレスが自動入力されるため、API Key のみ入力すれば使用できます。 ## ステップ 2:プロバイダーの切り替え 追加が完了すると、プロバイダーがリストに表示されます。 **方法 1:メイン画面で切り替え** - プロバイダーカードの「有効化」ボタンをクリック **方法 2:トレイで素早く切り替え** - システムトレイアイコンを右クリック - プロバイダー名を直接クリック ## ステップ 3:反映方法 プロバイダーを切り替えた後、各 CLI ツールの反映方法は異なります: | アプリ | 反映方法 | |------|----------| | Claude Code | 即時反映(ホットリロード対応) | | Codex | ターミナルを閉じて再度開く必要あり | | Gemini | 即時反映(リクエストごとに設定を再読み込み) | ### Claude Code の初回インストール時の注意 Claude Code を初めて起動するときに**ログイン**の要求や初期化ガイドが表示される場合は、CC Switch で「Claude Code の初回確認をスキップ」オプションを有効にしてください: 1. CC Switch の「設定 → 一般」を開く 2. 「Claude Code の初回確認をスキップ」スイッチをオンにする 3. Claude Code を再起動 ![image-20260108002626389](../../assets/image-20260108002626389.png) > **注意**:このオプションは `~/.claude/settings.json` の `skipIntroduction` フィールドに書き込まれ、公式の初回ガイドフローをスキップします。 ## 設定の確認 再起動後、対応する CLI ツールを起動して簡単な質問でテストします: ```bash # Claude Code - 起動後にテスト質問を入力 claude > こんにちは、簡単に自己紹介してください # Codex - 起動後にテスト質問を入力 codex > こんにちは、簡単に自己紹介してください # Gemini - 起動後にテスト質問を入力 gemini > こんにちは、簡単に自己紹介してください ``` AI が正常に回答すれば、設定は成功です。 ## 次のステップ 基本設定が完了しました。次に以下のことができます: - [プロバイダーの追加](../2-providers/2.1-add.md) - 複数のプロバイダーを設定して簡単に切り替え - [MCP サーバーの設定](../3-extensions/3.1-mcp.md) - AI ツールの機能を拡張 - [システムプロンプトの設定](../3-extensions/3.2-prompts.md) - AI の動作をカスタマイズ - [プロキシサービスの有効化](../4-proxy/4.1-service.md) - 使用量の監視と自動フェイルオーバー ## よくある質問 ### 切り替えても反映されない場合 ターミナルまたは CLI ツールを再起動してください。設定ファイルは切り替え時に更新されますが、実行中のプログラムは自動的に設定を再読み込みしません。 ### プリセットが見つからない場合 プロバイダーがプリセットリストにない場合は、「カスタム」を選択して手動設定してください。設定形式については [プロバイダーの追加](../2-providers/2.1-add.md) を参照してください。 ### 公式ログインに戻すには 「公式ログイン」プリセット(Claude/Codex)または「Google 公式」プリセット(Gemini)を選択し、クライアントを再起動してログインフローに従ってください。 ================================================ FILE: docs/user-manual/ja/1-getting-started/1.5-settings.md ================================================ # 1.5 個人設定 このセクションでは、個人の好みに合わせて CC Switch を設定する方法を説明します。 ## 設定を開く - 左上の **⚙️** ボタンをクリック - またはショートカット `Cmd/Ctrl + ,` ## 言語設定 CC Switch は 3 つの言語に対応しています: | 言語 | 説明 | | -------- | -------- | | 簡体中文 | デフォルト言語 | | English | 英語インターフェース | | 日本語 | 日本語インターフェース | 言語を切り替えると即座に反映され、再起動は不要です。 ## テーマ設定 | オプション | 説明 | | -------- | --------------------------- | | システムに合わせる | システムのダーク/ライトモードに自動的に合わせる | | ライト | 常にライトテーマを使用 | | ダーク | 常にダークテーマを使用 | ## ウィンドウ動作 ### 起動時に自動実行 有効にすると、システム起動時に CC Switch が自動的に起動します。 - **Windows**:レジストリを使用 - **macOS**:LaunchAgent を使用 - **Linux**:XDG autostart を使用 ### 閉じる動作 | オプション | 説明 | | ------------ | ---------------------------- | | トレイへ最小化 | 閉じるボタンをクリックするとシステムトレイに隠す | | 直接終了 | 閉じるボタンをクリックするとアプリを完全に終了 | トレイからプロバイダーを素早く切り替えられるため、「トレイへ最小化」の使用を推奨します。 ### Claude プラグイン連携 有効にすると、CC Switch はプロバイダー切り替え時に VS Code の Claude Code 拡張に設定を自動同期します(`~/.claude/config.json` の `primaryApiKey` に書き込み)。 > **使用シーン**:Claude Code CLI と VS Code プラグインを同時に使用する場合、このオプションを有効にすると両方の設定を一致させることができます。 ### Claude 初回ガイドのスキップ 有効にすると、Claude Code の初回ガイドフローをスキップします。Claude Code に慣れているユーザー向けです。 > **注意**:このオプションは `~/.claude/settings.json` の `skipIntroduction` フィールドに書き込まれます。 ### アプリの表示設定 アプリ切り替えに表示するアプリを選択します。各アプリを個別にオン/オフできますが、少なくとも 1 つは有効にする必要があります。 設定可能なアプリ:Claude、Codex、Gemini、OpenCode、OpenClaw。 > **使用シーン**:Claude Code と Codex CLI のみを使用する場合、他のアプリを非表示にしてインターフェースをシンプルに保てます。 ### Skills 同期方式 スキルを各アプリディレクトリにインストールする際の同期方式を設定します: | 方式 | 説明 | | ----------------- | ---------------------------------------------------- | | シンボリックリンク | スキルのソースファイルへのシンボリックリンクを作成、容量が少なく、リアルタイム同期 | | ファイルコピー | スキルファイルをターゲットディレクトリに完全コピー | > **推奨**:デフォルトではシンボリックリンク方式を使用します。権限の問題が発生する場合は、コピー方式に切り替えてください。 ### ターミナル設定 CC Switch がターミナルを開く際に使用するターミナルアプリケーションを選択します。 対応ターミナル(プラットフォーム別): | プラットフォーム | ターミナル選択肢 | | ------- | ------------------------------------------------------------------ | | macOS | Terminal、iTerm2、Alacritty、Kitty、Ghostty、WezTerm | | Windows | CMD、PowerShell、Windows Terminal | | Linux | GNOME Terminal、Konsole、Xfce4 Terminal、Alacritty、Kitty、Ghostty | ## ディレクトリ設定 ### アプリ設定ディレクトリ CC Switch 自体のデータの保存場所で、デフォルトは `~/.cc-switch/` です。 ### CLI ツールディレクトリ 各 CLI ツールの設定ディレクトリをカスタマイズできます: | 設定 | デフォルト値 | 説明 | | ------------- | -------------- | -------------------- | | Claude ディレクトリ | `~/.claude/` | Claude Code 設定ディレクトリ | | Codex ディレクトリ | `~/.codex/` | Codex 設定ディレクトリ | | Gemini ディレクトリ | `~/.gemini/` | Gemini CLI 設定ディレクトリ | | OpenCode ディレクトリ | `~/.opencode/` | OpenCode 設定ディレクトリ | | OpenClaw ディレクトリ | `~/.openclaw/` | OpenClaw 設定ディレクトリ | > **注意**:ディレクトリを変更した後はアプリの再起動が必要で、対応する CLI ツールも同じディレクトリを設定する必要があります。 ## データ管理 ### 設定のエクスポート 「エクスポート」ボタンをクリックして、以下の内容を含むバックアップファイルを保存します: - すべてのプロバイダー設定 - MCP サーバー設定 - Prompts プリセット - アプリ設定 バックアップファイルは JSON 形式で、テキストエディタで確認できます。 ### 設定のインポート 1. 「ファイルを選択」をクリック 2. 以前にエクスポートしたバックアップファイルを選択 3. 「インポート」をクリック 4. 既存の設定の上書きを確認 > **注意**:インポートは既存の設定を上書きするため、事前に現在の設定をエクスポートしてバックアップすることをお勧めします。 ## プロキシ設定 設定 → プロキシ タブ プロキシ タブではすべてのプロキシ関連機能を集中管理します: ### ローカルプロキシ ローカルプロキシサービスの起動/停止、リスニングアドレスとポートの設定。詳しくは [4.1 プロキシサービス](../4-proxy/4.1-service.md) をご覧ください。 ### フェイルオーバー アプリ(Claude/Codex/Gemini)ごとにフェイルオーバーキューと自動切り替え戦略を設定。詳しくは [4.3 フェイルオーバー](../4-proxy/4.3-failover.md) をご覧ください。 ### 料金補正器 モデル料金補正ルールを設定し、プロキシの課金統計を調整します。 ### グローバル送信プロキシ CC Switch の送信 HTTP/HTTPS プロキシを設定します。外部 API にプロキシ経由でアクセスする必要がある場合に使用します。 ## 詳細設定 設定 → 詳細 タブ ### 設定ディレクトリ 各アプリの設定ファイルディレクトリをカスタマイズ。下記の「ディレクトリ設定」セクションを参照してください。 ### データ管理 設定バックアップのインポート/エクスポート。下記の「データ管理」セクションを参照してください。 ### バックアップと復元 自動バックアップの管理: | 設定 | 説明 | | -------- | -------------------------- | | バックアップ間隔 | 自動バックアップの時間間隔(時間) | | 保持数量 | 保持するバックアップの数 | バックアップリストの表示とバックアップからの復元をサポートします。 ### クラウド同期(WebDAV) WebDAV プロトコルを使用して複数のデバイス間で設定を同期します。 | 設定項目 | 説明 | | -------- | ------------------------------------- | | サービスプリセット | 坚果云 / Nextcloud / Synology / カスタム | | サーバー URL | WebDAV サーバー URL | | ユーザー名 | ログインユーザー名 | | パスワード | ログインパスワード(アプリ専用パスワード) | | リモートディレクトリ | リモート保存パス(デフォルト `cc-switch-sync`) | | プロファイル名 | デバイスプロファイル名(デフォルト `default`) | | 自動同期 | 有効にすると変更を自動アップロード | 操作: - **接続テスト**:WebDAV 設定が正しいか確認 - **保存**:設定を保存して自動テスト - **アップロード**:ローカルデータをリモートにアップロード - **ダウンロード**:リモートからローカルにデータをダウンロード > **注意**:アップロードはリモートデータを、ダウンロードはローカルデータを上書きします。操作前にご確認ください。 ### ログ設定 | 設定項目 | 説明 | | -------- | ----------------------------------- | | ログを有効化 | アプリのログ記録のオン/オフ | | ログレベル | error / warn / info / debug / trace | ログレベルの説明: - **error** - エラーのみ記録 - **warn** - 警告とエラーを記録 - **info** - 一般情報を記録(推奨) - **debug** - デバッグ情報を記録 - **trace** - すべての詳細情報を記録 ## バージョン情報ページ 設定 → バージョン情報 タブ ### バージョン情報 現在の CC Switch バージョン番号を表示し、以下をサポートします: - リリースノートの表示 - 更新の確認 - 新バージョンのダウンロードとインストール ### ローカル環境チェック インストール済みの CLI ツールのバージョンを自動検出: | ツール | 検出内容 | | -------- | ------------------ | | Claude | 現在のバージョン、最新バージョン | | Codex | 現在のバージョン、最新バージョン | | Gemini | 現在のバージョン、最新バージョン | | OpenCode | 現在のバージョン、最新バージョン | | OpenClaw | 現在のバージョン、最新バージョン | 「更新」ボタンをクリックして再検出できます。 ### ワンクリックインストールコマンド CLI ツールを素早くインストール/更新するコマンドを提供: ```bash npm i -g @anthropic-ai/claude-code@latest npm i -g @openai/codex@latest npm i -g @google/gemini-cli@latest npm i -g opencode@latest npm i -g openclaw@latest ``` 「コピー」ボタンでクリップボードにコピーできます。 ================================================ FILE: docs/user-manual/ja/2-providers/2.1-add.md ================================================ # 2.1 プロバイダーの追加 ## 追加パネルを開く メイン画面右上の **+** ボタンをクリックして、プロバイダー追加パネルを開きます。 パネルは 2 つのタブに分かれています: - **アプリ専用プロバイダー**:現在選択中のアプリ(Claude/Codex/Gemini/OpenCode/OpenClaw)専用 - **統一プロバイダー**:アプリ間で共有する設定 ## プリセットで追加 プリセットは事前に設定されたプロバイダーテンプレートで、API Key を入力するだけで使用できます。 ### 操作手順 1. 「プリセット」ドロップダウンからプロバイダーを選択 2. 名前とエンドポイントが自動入力される 3. **API Key** を入力 4. (任意)メモを入力 5. 「追加」をクリック ### 主なプリセット #### Claude プリセット | プリセット名 | 説明 | |----------|------| | Claude 公式 | Anthropic 公式アカウントでログイン | | DeepSeek | DeepSeek モデル | | 智谱 GLM | 智谱 AI の GLM モデル | | 智谱 GLM en | 智谱 AI(英語版) | | 百炼 | アリクラウド百炼(通义千問) | | Kimi | Moonshot Kimi モデル | | Kimi For Coding | Kimi プログラミング専用モデル | | StepFun | StepFun モデル | | ModelScope | 魔搭コミュニティ | | KAT-Coder | KAT-Coder モデル | | Longcat | Longcat AI | | MiniMax | MiniMax モデル | | MiniMax en | MiniMax(英語版) | | DouBaoSeed | 豆包 Seed モデル | | BaiLing | 百灵 AI | | AiHubMix | AiHubMix 統合サービス | | SiliconFlow | SiliconFlow | | SiliconFlow en | SiliconFlow(英語版) | | DMXAPI | DMXAPI 中継サービス | | PackyCode | PackyCode 中継サービス ⭐ | | Cubence | Cubence サービス | | AIGoCode | AIGoCode サービス | | RightCode | RightCode サービス | | AICodeMirror | AICodeMirror サービス | | OpenRouter | 統合ルーティングサービス | | Nvidia | Nvidia AI サービス | | Xiaomi MiMo | Xiaomi MiMo モデル | > ⭐ は公式パートナーを示します。プリセットリストはバージョンの更新に伴い変更される場合があります。アプリ内の実際の表示を基準にしてください。 #### Codex プリセット | プリセット名 | 説明 | |----------|------| | OpenAI 公式 | OpenAI 公式アカウントでログイン | | Azure OpenAI | Azure OpenAI サービス | | AiHubMix | AiHubMix 統合サービス | | DMXAPI | DMXAPI 中継サービス | | PackyCode | PackyCode 中継サービス | | Cubence | Cubence サービス | | AIGoCode | AIGoCode サービス | | RightCode | RightCode サービス | | AICodeMirror | AICodeMirror サービス | | OpenRouter | 統合ルーティングサービス | #### Gemini プリセット | プリセット名 | 説明 | |----------|------| | Google 公式 | Google OAuth でログイン | | PackyCode | PackyCode 中継サービス | | Cubence | Cubence サービス | | AIGoCode | AIGoCode サービス | | AICodeMirror | AICodeMirror サービス | | OpenRouter | 統合ルーティングサービス | | カスタム | すべてのパラメータを手動設定 | #### OpenCode プリセット | プリセット名 | 説明 | |----------|------| | DeepSeek | DeepSeek モデル | | 智谱 GLM | 智谱 AI の GLM モデル | | 智谱 GLM en | 智谱 AI(英語版) | | 百炼 | アリクラウド百炼 | | Kimi k2.5 | Moonshot Kimi-k2.5 モデル | | Kimi For Coding | Kimi プログラミング専用モデル | | StepFun | StepFun モデル | | ModelScope | 魔搭コミュニティ | | KAT-Coder | KAT-Coder モデル | | Longcat | Longcat AI | | MiniMax | MiniMax モデル | | MiniMax en | MiniMax(英語版) | | DouBaoSeed | 豆包 Seed モデル | | BaiLing | 百灵 AI | | Xiaomi MiMo | Xiaomi MiMo モデル | | AiHubMix | AiHubMix 統合サービス | | DMXAPI | DMXAPI 中継サービス | | OpenRouter | 統合ルーティングサービス | | Nvidia | Nvidia AI サービス | | PackyCode | PackyCode 中継サービス | | Cubence | Cubence サービス | | AIGoCode | AIGoCode サービス | | RightCode | RightCode サービス | | AICodeMirror | AICodeMirror サービス | | OpenAI Compatible | OpenAI 互換インターフェース | | Oh My OpenCode | Oh My OpenCode サービス | > プリセットリストは継続的に更新されています。アプリ内の実際の表示を基準にしてください。 #### OpenClaw プリセット | プリセット名 | 説明 | |----------|------| | DeepSeek | DeepSeek モデル | | 智谱 GLM | 智谱 AI の GLM モデル | | 智谱 GLM en | 智谱 AI(英語版) | | Qwen Coder | 通义千問コーディングモデル | | Kimi k2.5 | Moonshot Kimi-k2.5 モデル | | Kimi For Coding | Kimi プログラミング専用モデル | | StepFun | StepFun モデル | | MiniMax | MiniMax モデル | | MiniMax en | MiniMax(英語版) | | KAT-Coder | KAT-Coder モデル | | Longcat | Longcat AI | | DouBaoSeed | 豆包 Seed モデル | | BaiLing | 百灵 AI | | Xiaomi MiMo | Xiaomi MiMo モデル | | AiHubMix | AiHubMix 統合サービス | | DMXAPI | DMXAPI 中継サービス | | OpenRouter | 統合ルーティングサービス | | ModelScope | 魔搭コミュニティ | | SiliconFlow | SiliconFlow | | SiliconFlow en | SiliconFlow(英語版) | | Nvidia | Nvidia AI サービス | | PackyCode | PackyCode 中継サービス | | Cubence | Cubence サービス | | AIGoCode | AIGoCode サービス | | RightCode | RightCode サービス | | AICodeMirror | AICodeMirror サービス | | AICoding | AICoding サービス | | CrazyRouter | CrazyRouter サービス | | SSSAiCode | SSSAiCode サービス | | AWS Bedrock | AWS Bedrock サービス | | OpenAI Compatible | OpenAI 互換インターフェース | ## カスタム設定 「カスタム」プリセットを選択した場合、JSON 設定を手動で編集する必要があります。 ### Claude 設定形式 ```json { "env": { "ANTHROPIC_API_KEY": "your-api-key", "ANTHROPIC_BASE_URL": "https://api.example.com" } } ``` | フィールド | 必須 | 説明 | |------|------|------| | `ANTHROPIC_API_KEY` | はい | API キー | | `ANTHROPIC_BASE_URL` | いいえ | カスタムエンドポイントアドレス | | `ANTHROPIC_AUTH_TOKEN` | いいえ | API_KEY の代替認証方式 | ### Codex 設定形式 Codex は 2 つの設定ファイルを使用します: **1. auth.json**(`~/.codex/auth.json`)- API キーを保存: ```json { "OPENAI_API_KEY": "your-api-key" } ``` **2. config.toml**(`~/.codex/config.toml`)- モデルとエンドポイントの設定を保存: ```toml # 基本設定 model_provider = "custom" model = "gpt-5.2" model_reasoning_effort = "high" disable_response_storage = true # カスタムプロバイダー設定 [model_providers.custom] name = "custom" base_url = "https://api.example.com/v1" wire_api = "responses" requires_openai_auth = true ``` **auth.json フィールド説明**: | フィールド | 必須 | 説明 | |------|------|------| | `OPENAI_API_KEY` | はい | API キー | **config.toml フィールド説明**: | フィールド | 必須 | 説明 | |------|------|------| | `model_provider` | はい | モデルプロバイダー名(`[model_providers.xxx]` と一致する必要あり) | | `model` | はい | 使用するモデル(例:`gpt-5.2`、`gpt-4o`) | | `model_reasoning_effort` | いいえ | 推論強度:`low` / `medium` / `high` | | `disable_response_storage` | いいえ | レスポンス保存を無効にするかどうか | | `base_url` | はい | API エンドポイントアドレス | | `wire_api` | いいえ | API プロトコルタイプ(通常 `responses`) | | `requires_openai_auth` | いいえ | OpenAI 認証方式を使用するかどうか | ### Gemini 設定形式 ```json { "env": { "GEMINI_API_KEY": "your-api-key", "GOOGLE_GEMINI_BASE_URL": "https://api.example.com" } } ``` | フィールド | 必須 | 説明 | |------|------|------| | `GEMINI_API_KEY` | はい | API キー | | `GOOGLE_GEMINI_BASE_URL` | いいえ | カスタムエンドポイントアドレス | | `GEMINI_MODEL` | いいえ | モデルの指定 | > 認証タイプは CC Switch が自動的に検出します(PackyCode API プロキシ / Google OAuth / 汎用 API Key)。手動設定は不要です。 ## 統一プロバイダー 統一プロバイダーは Claude/Codex/Gemini/OpenCode/OpenClaw 間で設定を共有でき、複数の API 形式をサポートする中継サービスに適しています。 ### 統一プロバイダーの作成 1. 「統一プロバイダー」タブに切り替え 2. 「統一プロバイダーを追加」をクリック 3. 共通設定を入力: - 名前 - API Key - エンドポイントアドレス 4. 同期するアプリにチェック(Claude/Codex/Gemini/OpenCode/OpenClaw) 5. 保存 ### 同期の仕組み 統一プロバイダーはチェックしたアプリに自動的に同期されます: - 統一プロバイダーを変更すると、関連するすべてのアプリの設定が同期更新される - 統一プロバイダーを削除すると、関連するアプリの設定も削除される ### 保存して同期 統一プロバイダーの編集時に選択できます: | 操作 | 説明 | |------|------| | 保存 | 設定のみ保存、すぐに同期しない | | 保存して同期 | 設定を保存し、有効なすべてのアプリに即座に同期 | ### 手動同期 手動で同期をトリガーする場合: 1. 統一プロバイダーカードの「同期」ボタンをクリック 2. 同期操作を確認 3. 各アプリの関連プロバイダーの設定が上書きされる ## プロバイダーのインポート CC Switch は 2 つの方法でプロバイダー設定をインポートできます: ### 方法 1:ディープリンクでインポート `ccswitch://` プロトコルリンクでワンクリックインポート: 1. ディープリンクをクリックまたはアクセス 2. CC Switch が自動的に開き、インポート確認を表示 3. 設定情報をプレビュー 4. 「インポートを確認」をクリック **ディープリンクの取得方法**: - 他の人からの共有で取得 - [オンライン生成ツール](https://farion1231.github.io/cc-switch/deplink.html) で作成 ### 方法 2:データベースバックアップからインポート SQL バックアップファイルから一括インポート: 1. 「設定 → 詳細 → データ管理」を開く 2. 「ファイルを選択」をクリック 3. 以前にエクスポートした `.sql` バックアップファイルを選択 4. 「インポート」をクリック 5. 既存の設定の上書きを確認 **インポート内容**: - すべてのプロバイダー設定 - MCP サーバー設定 - Prompts プリセット - 使用量ログ > **注意**:インポートは既存のデータベースを上書きするため、事前に現在の設定をエクスポートしてバックアップすることをお勧めします。エクスポートファイル名の形式は `cc-switch-export-{タイムスタンプ}.sql` です。 ## 高度なオプション ### カスタムアイコン 名前の左側にあるアイコンエリアをクリックすると: - プリセットアイコンを選択 - アイコンの色をカスタマイズ ### Web サイトリンク プロバイダーの公式サイトやコンソールのアドレスを入力して、素早くアクセスできます: - プロバイダーカードのリンクアイコンをクリックすると直接開く - 残額の確認や API Key の取得などに使用 ### メモ 以下のようなメモ情報を追加できます: - アカウントの用途(個人/仕事) - プランの情報 - 有効期限 メモはプロバイダーカードに表示され、検索にも対応しています。 ### エンドポイント速度テスト プロバイダーを追加した後、API エンドポイントの速度テストができます: 1. プロバイダーカードの「テスト」ボタンをクリック 2. テストパネルで複数のエンドポイント URL を追加 3. 「テスト」をクリックして実行 4. レイテンシが最も低いエンドポイントを選択 **テスト結果**: - 緑:レイテンシ < 500ms(優秀) - 黄:レイテンシ 500-1000ms(普通) - 赤:レイテンシ > 1000ms(遅い) ![image-20260108005327817](../../assets/image-20260108005327817.png) ================================================ FILE: docs/user-manual/ja/2-providers/2.2-switch.md ================================================ # 2.2 プロバイダーの切り替え ## メイン画面での切り替え プロバイダーリストで、対象のプロバイダーカードの「有効化」ボタンをクリックします。 ### 切り替えフロー 1. 「有効化」ボタンをクリック 2. CC Switch が設定ファイルを更新 3. カードのステータスが「現在有効」に変更 4. Claude/Gemini は即時反映、Codex はターミナルの再起動が必要 ### ステータス表示 | ステータス | 表示 | 説明 | |------|------|------| | 現在有効 | 青い枠 + ラベル | 設定ファイル内の現在のプロバイダー | | プロキシアクティブ | 緑の枠 | プロキシモードで実際に使用中のプロバイダー | | 通常 | デフォルトのスタイル | 有効化されていないプロバイダー | ## トレイでの素早い切り替え システムトレイから素早く切り替えられ、メイン画面を開く必要がありません。 ### 操作手順 1. システムトレイの CC Switch アイコンを右クリック 2. メニューで対応するアプリ(Claude/Codex/Gemini/OpenCode)を見つける 3. 切り替えたいプロバイダー名をクリック 4. 切り替え完了、トレイに短い通知が表示 ### トレイメニュー構造 ![image-20260108004348993](../../assets/image-20260108004348993.png) ## 反映方法 ### Claude Code **切り替え後に即時反映**、再起動は不要です。 Claude Code はホットリロードに対応しており、設定ファイルの変更を自動検出して再読み込みします。 ### Codex 切り替え後は再起動が必要: - 現在のターミナルウィンドウを閉じる - ターミナルを再度開く ### Gemini CLI **切り替え後に即時反映**、再起動は不要です。 Gemini CLI はリクエストごとに `.env` ファイルを再読み込みします。 ## 設定ファイルの変更 プロバイダーを切り替える際、CC Switch は以下のファイルを変更します: ### Claude ``` ~/.claude/settings.json ``` 変更内容: ```json { "env": { "ANTHROPIC_API_KEY": "新しい API Key", "ANTHROPIC_BASE_URL": "新しいエンドポイント" } } ``` ### Codex ``` ~/.codex/auth.json ~/.codex/config.toml(追加設定がある場合) ``` ### Gemini ``` ~/.gemini/.env ~/.gemini/settings.json ``` ## 切り替え失敗時の対処 切り替えに失敗した場合、考えられる原因: ### 設定ファイルがロックされている 他のプログラムが設定ファイルを使用中です。 **解決方法**:実行中の CLI ツールを閉じてから、再度切り替えを試みてください。 ### 権限不足 設定ファイルへの書き込み権限がありません。 **解決方法**:設定ディレクトリの権限設定を確認してください。 ### 設定形式エラー プロバイダー設定の JSON 形式に誤りがあります。 **解決方法**:プロバイダーを編集して、JSON 形式を確認・修正してください。 ================================================ FILE: docs/user-manual/ja/2-providers/2.3-edit.md ================================================ # 2.3 プロバイダーの編集 ## 編集パネルを開く 1. 編集したいプロバイダーカードを見つける 2. カードにマウスをホバーして操作ボタンを表示 3. 「編集」ボタンをクリック ## 編集可能な内容 ### 基本情報 | フィールド | 説明 | |------|------| | 名前 | プロバイダーの表示名 | | メモ | 付加情報 | | Web サイトリンク | プロバイダーの公式サイトまたはコンソールアドレス | | アイコン | カスタムアイコンと色 | ### アイコンのカスタマイズ CC Switch は豊富なアイコンカスタマイズ機能を提供しています: #### アイコン選択画面 1. アイコンエリアをクリックしてアイコン選択画面を開く 2. 検索ボックスで名前からアイコンを検索 3. クリックしてアイコンを選択 アイコンライブラリには一般的な AI サービスプロバイダーと技術アイコンが含まれており、以下をサポートします: - 名前によるあいまい検索 - アイコン名のツールチップ表示 - 選択結果のリアルタイムプレビュー ![image-20260108004734882](../../assets/image-20260108004734882.png) ### 設定情報 JSON 形式の設定内容(以下を含む): - API Key - エンドポイントアドレス - その他の環境変数 ### 現在有効なプロバイダーの編集 現在有効なプロバイダーを編集する場合、特別な「バックフィル」機能があります: 1. 編集パネルを開くと、live 設定ファイルから最新の内容を読み取る 2. CLI ツールで手動で設定を変更した場合、その変更が同期される 3. 保存すると、変更が live 設定ファイルに書き込まれる これにより、CC Switch と CLI ツールの設定が常に同期されます。 ## API Key の変更 プロバイダーの編集時に、**API Key** 入力ボックスから直接変更できます: 1. プロバイダーカードの「編集」ボタンをクリック 2. 「API Key」入力ボックスに新しいキーを入力 3. 「保存」をクリック > **ヒント**:API Key 入力ボックスは表示/非表示の切り替えに対応しています。右側の目のアイコンをクリックするとキーの全文を確認できます。 ## エンドポイントアドレスの変更 プロバイダーの編集時に、**エンドポイントアドレス** 入力ボックスから直接変更できます: 1. プロバイダーカードの「編集」ボタンをクリック 2. 「エンドポイントアドレス」入力ボックスに新しい URL を入力 3. 「保存」をクリック ### エンドポイントアドレスの形式 | アプリ | 形式の例 | |------|----------| | Claude | `https://api.example.com` | | Codex | `https://api.example.com/v1` | | Gemini | `https://api.example.com` | ## カスタムエンドポイントの追加 プロバイダーには複数のエンドポイントを設定でき、以下の用途に使用します: - 速度テスト時に複数のアドレスをテスト - フェイルオーバー時のバックアップエンドポイント ### 自動収集 プロバイダーの追加時に、CC Switch は設定からエンドポイントアドレスを自動抽出します。 ### 手動追加 プロバイダーの編集時に、「エンドポイント管理」エリアで以下の操作が可能です: - 新しいエンドポイントの追加 - 既存のエンドポイントの削除 - デフォルトエンドポイントの設定 ## JSON エディタ 設定は JSON 形式を使用し、エディタは以下を提供します: - シンタックスハイライト - フォーマット検証 - エラー通知 ### よくあるエラー **引用符の欠落**: ```json // ❌ 間違い { env: { KEY: "value" } } // ✅ 正しい { "env": { "KEY": "value" } } ``` **余分なカンマ**: ```json // ❌ 間違い { "env": { "KEY": "value", } } // ✅ 正しい { "env": { "KEY": "value" } } ``` **閉じ括弧の欠落**: ```json // ❌ 間違い { "env": { "KEY": "value" } // ✅ 正しい { "env": { "KEY": "value" } } ``` ## 保存と反映 1. 「保存」ボタンをクリック 2. 現在有効なプロバイダーの場合、設定は即座に live ファイルに書き込まれる 3. CLI ツールを再起動して反映 ## 編集のキャンセル 「キャンセル」ボタンをクリックするか `Esc` キーを押して編集パネルを閉じると、すべての変更は保存されません。 ================================================ FILE: docs/user-manual/ja/2-providers/2.4-sort-duplicate.md ================================================ # 2.4 並べ替えと複製 ## ドラッグで並べ替え ドラッグでプロバイダーの表示順序を調整します。 ### 操作手順 1. プロバイダーカード左側の **≡** ドラッグハンドルにマウスを合わせる 2. マウスの左ボタンを押し続ける 3. 目的の位置まで上下にドラッグ 4. マウスを離して並べ替え完了 ### 並べ替えの用途 - **よく使うものを優先**:よく使うプロバイダーをリストの上部に配置 - **フェイルオーバーの順序**:並び順はフェイルオーバーキューのデフォルト順序に影響 ## プロバイダーの複製 プロバイダーのコピーを素早く作成します。以下のような場面に適しています: - 既存の設定をベースにバリエーションを作成 - 現在の設定をバックアップ - テスト用の設定を作成 ### 操作手順 1. プロバイダーカードにマウスをホバーして操作ボタンを表示 2. 「複製」ボタンをクリック 3. 名前に `copy` が付加されたコピーが自動作成 4. コピーを編集して設定を変更 ### コピーされる内容 コピーは完全な複製が作成され、以下を含みます: | 内容 | コピーされるか | |------|----------| | 名前 | コピーされる(`copy` が付加) | | 設定 | 完全にコピー | | メモ | コピーされる | | Web サイトリンク | コピーされる | | アイコン | コピーされる | | エンドポイントリスト | コピーされる | | 並び順の位置 | 元のプロバイダーの下に挿入 | ### コピー後の編集 コピー完了後、通常は以下を変更します: 1. **名前**:意味のある名前に変更 2. **API Key**:異なるアカウントの場合 3. **エンドポイント**:異なるサービスの場合 ## プロバイダーの削除 ### 操作手順 1. プロバイダーカードにマウスをホバーして操作ボタンを表示 2. 「削除」ボタンをクリック 3. 削除を確認 ### 削除の確認 削除前に確認ダイアログが表示され、以下が表示されます: - プロバイダー名 - 削除後は元に戻せないという注意 ### 削除の制限 - **現在有効なプロバイダー**:削除可能ですが、先に他のプロバイダーに切り替えることをお勧めします - **統一プロバイダー**:削除すると、関連するアプリの設定も削除されます ![image-20260108004946288](../../assets/image-20260108004946288.png) ================================================ FILE: docs/user-manual/ja/2-providers/2.5-usage-query.md ================================================ # 2.5 使用量クエリ ## 機能説明 使用量クエリ機能により、カスタムスクリプトを設定して、プロバイダーの残額や使用量などの情報をリアルタイムでクエリできます。 **使用シーン**: - API アカウントの残額確認 - プランの使用状況の監視 - 複数プランの残額を集約表示 ## 設定を開く 1. プロバイダーカードにマウスをホバーして操作ボタンを表示 2. 「使用量クエリ」ボタンをクリック 3. 使用量クエリ設定パネルが開く ## 使用量クエリの有効化 設定パネル上部の「使用量クエリを有効にする」スイッチをオンにします。 ## プリセットテンプレート CC Switch は 3 種類のプリセットテンプレートを提供しています: ### カスタムテンプレート リクエストと抽出ロジックを完全にカスタマイズします。特殊な API 形式に対応します。 ### 汎用テンプレート ほとんどの標準的な API 形式のプロバイダーに適しています: ```javascript ({ request: { url: "{{baseUrl}}/user/balance", method: "GET", headers: { "Authorization": "Bearer {{apiKey}}", "User-Agent": "cc-switch/1.0" } }, extractor: function(response) { return { isValid: response.is_active || true, remaining: response.balance, unit: "USD" }; } }) ``` **設定パラメータ**: | パラメータ | 説明 | |------|------| | API Key | 認証用のキー(任意、空欄の場合はプロバイダーに設定されたキーを使用) | | Base URL | API ベースアドレス(任意、空欄の場合はプロバイダーのエンドポイントを使用) | ### New API テンプレート New API タイプの中継サービス専用に設計されています: ```javascript ({ request: { url: "{{baseUrl}}/api/user/self", method: "GET", headers: { "Content-Type": "application/json", "Authorization": "Bearer {{accessToken}}", "New-Api-User": "{{userId}}" }, }, extractor: function (response) { if (response.success && response.data) { return { planName: response.data.group || "デフォルトプラン", remaining: response.data.quota / 500000, used: response.data.used_quota / 500000, total: (response.data.quota + response.data.used_quota) / 500000, unit: "USD", }; } return { isValid: false, invalidMessage: response.message || "クエリ失敗" }; }, }) ``` **設定パラメータ**: | パラメータ | 説明 | |------|------| | Base URL | New API サービスアドレス | | Access Token | アクセストークン | | User ID | ユーザー ID | ## 共通設定 ### タイムアウト時間 リクエストのタイムアウト時間(秒)、デフォルトは 10 秒。 ### 自動クエリ間隔 使用量データの自動更新間隔(分): - `0` に設定すると自動クエリを無効化 - 範囲:0-1440 分(最長 24 時間) - プロバイダーが「現在有効」のときのみ動作 ## エクストラクターの戻り値形式 エクストラクター関数は以下のフィールドを含むオブジェクトを返す必要があります: | フィールド | 型 | 必須 | 説明 | |------|------|------|------| | `isValid` | boolean | いいえ | アカウントが有効かどうか、デフォルト true | | `invalidMessage` | string | いいえ | 無効時の通知メッセージ | | `remaining` | number | はい | 残額 | | `unit` | string | はい | 単位(例:USD、CNY、回) | | `planName` | string | いいえ | プラン名(複数プラン対応) | | `total` | number | いいえ | 総額 | | `used` | number | いいえ | 使用済み額 | | `extra` | object | いいえ | 追加情報 | ## スクリプトのテスト 設定完了後、「スクリプトをテスト」ボタンをクリックして確認します: 1. 設定された URL にリクエストを送信 2. エクストラクター関数を実行 3. 結果またはエラー情報を表示 ## 表示効果 設定が成功すると、プロバイダーカードに以下が表示されます: - **単一プラン**:残額を直接表示 - **複数プラン**:プラン数を表示、クリックで詳細を展開 ## 変数プレースホルダー スクリプト内で以下のプレースホルダーを使用でき、実行時に自動的に置換されます: | プレースホルダー | 説明 | |--------|------| | `{{apiKey}}` | 設定された API Key | | `{{baseUrl}}` | 設定された Base URL | | `{{accessToken}}` | 設定された Access Token(New API) | | `{{userId}}` | 設定された User ID(New API) | ## 一般的なプロバイダーの設定例 ### トラブルシューティング ### クエリ失敗 **確認事項**: 1. API Key が正しいか 2. Base URL が正しいか 3. ネットワークがアクセス可能か 4. タイムアウト時間が十分か ### 返却データが空 **確認事項**: 1. エクストラクター関数に `return` 文があるか 2. レスポンスのデータ構造がエクストラクターと一致しているか 3. 「スクリプトをテスト」で生のレスポンスを確認 ### フォーマット失敗 スクリプトに構文エラーがある場合、「フォーマット」ボタンをクリックするとエラー箇所が表示されます。 ## 注意事項 - 使用量クエリは少量の API リクエスト枠を消費します - 頻繁なリクエストを避けるため、適切な自動クエリ間隔を設定してください - 機密情報(API Key、Token)はローカルに安全に保存されます ================================================ FILE: docs/user-manual/ja/3-extensions/3.1-mcp.md ================================================ # 3.1 MCP サーバー管理 ## MCP とは MCP (Model Context Protocol) は、AI ツールが外部データソースやツールにアクセスできるようにするプロトコルです。MCP サーバーにより、AI は以下のことが可能になります: - ファイルシステムへのアクセス - ネットワークリクエストの実行 - データベースのクエリ - 外部 API の呼び出し ## MCP パネルを開く 上部ナビゲーションバーの **MCP** ボタンをクリックします。 ## パネル概要 ![image-20260108005723522](../../assets/image-20260108005723522.png) ## MCP サーバーの追加 ### プリセットテンプレートを使用 1. 右上の **+** ボタンをクリック 2. 「プリセット」ドロップダウンからテンプレートを選択 3. 必要に応じて設定を変更 4. 「保存」をクリック ![image-20260108005739731](../../assets/image-20260108005739731.png) ### 主なプリセット | プリセット | パッケージ名 | 機能説明 | |------|------|----------| | fetch | mcp-server-fetch | HTTP リクエストツール、AI が Web コンテンツを取得可能に | | time | @modelcontextprotocol/server-time | 時間ツール、現在の時刻情報を提供 | | memory | @modelcontextprotocol/server-memory | メモリツール、AI が情報を保存・検索可能に | | sequential-thinking | @modelcontextprotocol/server-sequential-thinking | 思考連鎖ツール、AI の推論能力を強化 | | context7 | @upstash/context7-mcp | ドキュメント検索ツール、技術ドキュメントをクエリ | ### カスタム設定 「カスタム」を選択した場合、以下を入力する必要があります: | フィールド | 必須 | 説明 | |------|------|------| | サーバー ID | はい | 一意な識別子 | | 名前 | いいえ | 表示名 | | 説明 | いいえ | 機能の説明 | | 転送タイプ | はい | stdio / http / sse | | コマンド | はい* | stdio タイプの場合は必須 | | 引数 | いいえ | コマンドライン引数 | | URL | はい* | http/sse タイプの場合は必須 | | Headers | いいえ | http/sse タイプのリクエストヘッダー | | 環境変数 | いいえ | サーバーに渡す環境変数 | ## 転送タイプ ### stdio(標準入出力) 最も一般的なタイプで、ローカルプロセスを起動して通信します。 ```json { "command": "uvx", "args": ["mcp-server-fetch"], "env": {} } ``` **要件**: - 対応するコマンド(例:`uvx`、`npx`)がインストールされている必要あり - サーバープログラムが PATH に含まれている必要あり ### http HTTP プロトコルでリモートサーバーと通信します。 ```json { "url": "http://localhost:8080/mcp" } ``` ### sse(Server-Sent Events) SSE プロトコルでサーバーと通信し、リアルタイムプッシュをサポートします。 ```json { "url": "http://localhost:8080/sse" } ``` ## アプリバインド 各 MCP サーバーは、有効にするアプリを個別に制御できます。 ### スイッチの説明 | スイッチ | 作用 | 設定ファイルパス | |------|------|--------------| | Claude | Claude Code に同期 | `~/.claude.json` の `mcpServers` | | Codex | Codex に同期 | `~/.codex/config.toml` の `[mcp_servers]` | | Gemini | Gemini CLI に同期 | `~/.gemini/settings.json` の `mcpServers` | | OpenCode | OpenCode に同期 | `~/.opencode/config.json` の `mcpServers` | > **注意**:OpenClaw は現在 MCP サーバー管理に対応していません。MCP 機能は現在 Claude、Codex、Gemini、OpenCode の 4 つのアプリのみサポートしています。 ### スイッチの動作 あるアプリのスイッチをオンにすると、CC Switch は以下を実行します: 1. **データベースの更新**:サーバーの `apps.claude/codex/gemini/opencode` のステータスを `true` に設定 2. **Live 設定に同期**:サーバー設定を対応アプリの設定ファイルに書き込み 3. **即時反映**:次回 CLI ツール起動時に新しい MCP サーバーが自動的にロード あるアプリのスイッチをオフにすると、CC Switch は以下を実行します: 1. **データベースの更新**:対応アプリのステータスを `false` に設定 2. **Live 設定から削除**:アプリの設定ファイルからそのサーバーを削除 3. **即時反映**:次回 CLI ツール起動時にその MCP サーバーはロードされない ### 同期条件 MCP サーバーの同期は、対応アプリがインストールされている場合のみ実行されます: - **Claude**:`~/.claude/` ディレクトリまたは `~/.claude.json` ファイルが存在する必要あり - **Codex**:`~/.codex/` ディレクトリが存在する必要あり - **Gemini**:`~/.gemini/` ディレクトリが存在する必要あり - **OpenCode**:`~/.opencode/` ディレクトリが存在する必要あり > **ヒント**:CLI ツールがインストールされていない場合、対応するスイッチをオンにしてもエラーにはなりませんが、設定は書き込まれません。 スイッチをオフにすると、設定はファイルから削除されます。 ## サーバーの編集 1. サーバー行の右側にある「編集」ボタンをクリック 2. 設定を変更 3. 「保存」をクリック 変更は有効になっているアプリの設定ファイルに即座に同期されます。 ## サーバーの削除 1. サーバー行の右側にある「削除」ボタンをクリック 2. 削除を確認 削除後、設定はすべてのアプリの設定ファイルから削除されます。 ## 既存の設定のインポート CLI ツールで既に MCP サーバーを設定している場合、CC Switch にインポートできます: 1. 「インポート」ボタンをクリック 2. インポートするアプリを選択(Claude/Codex/Gemini/OpenCode) 3. CC Switch が既存の設定を読み取ってインポート ## 設定ファイル形式 ### Claude (`~/.claude.json`) ```json { "mcpServers": { "mcp-fetch": { "command": "uvx", "args": ["mcp-server-fetch"] } } } ``` ### Codex (`~/.codex/config.toml`) ```toml [mcp_servers.mcp-fetch] command = "uvx" args = ["mcp-server-fetch"] ``` ### Gemini (`~/.gemini/settings.json`) ```json { "mcpServers": { "mcp-fetch": { "command": "uvx", "args": ["mcp-server-fetch"] } } } ``` ## よくある質問 ### サーバーの起動に失敗する 確認事項: - コマンドが正しくインストールされているか(例:`uvx`) - コマンドが PATH に含まれているか - 引数が正しいか ### 設定が反映されない 確認事項: - 対応するアプリのスイッチがオンになっているか - CLI ツールを再起動したか ================================================ FILE: docs/user-manual/ja/3-extensions/3.2-prompts.md ================================================ # 3.2 Prompts プロンプト管理 ## 機能説明 Prompts 機能は、システムプロンプトのプリセットを管理します。システムプロンプトは AI の動作や回答スタイルに影響します。 CC Switch を使用すると: - 複数のプロンプトプリセットを作成 - さまざまなシーンのプロンプトを素早く切り替え - デバイス間でプロンプト設定を同期 ## Prompts パネルを開く 上部ナビゲーションバーの **Prompts** ボタンをクリックします。 ## パネル概要 ![image-20260108010110382](../../assets/image-20260108010110382.png) ## プリセットの作成 ### 操作手順 1. 右上の **+** ボタンをクリック 2. プリセット名を入力 3. Markdown エディタでプロンプトを作成 4. 「保存」をクリック ### Markdown エディタ エディタは以下を提供します: - シンタックスハイライト - リアルタイムプレビュー - よく使うフォーマットのショートカットキー ### プロンプトの書き方のヒント **構造化フォーマット**: ```markdown # 役割定義 あなたはプロのコードレビュー専門家です。 ## コア能力 - コード品質分析 - パフォーマンス最適化の提案 - セキュリティ脆弱性の検出 ## 回答スタイル - 簡潔明瞭 - 具体的な例を提供 - 改善提案を提示 ## 注意事項 - ビジネスロジックを変更しない - コードスタイルの一貫性を保つ ``` ## プリセットの有効化 ### 操作方法 プリセット項目のスイッチボタンをクリックして、有効/無効を切り替えます。 ### 単一有効化 同時に有効にできるプリセットは 1 つだけです。新しいプリセットを有効にすると、以前のプリセットは自動的に無効になります。 ### 同期先 有効化後、プロンプトは対応するアプリのファイルに書き込まれます: | アプリ | ファイルパス | |------|----------| | Claude | `~/.claude/CLAUDE.md` | | Codex | `~/.codex/AGENTS.md` | | Gemini | `~/.gemini/GEMINI.md` | | OpenCode | `~/.opencode/AGENTS.md` | | OpenClaw | `~/.openclaw/AGENTS.md` | ## プリセットの編集 1. プリセット項目の「編集」ボタンをクリック 2. 名前や内容を変更 3. 「保存」をクリック 現在有効なプリセットを編集した場合、保存後に設定ファイルに即座に同期されます。 ## プリセットの削除 1. プリセット項目の「削除」ボタンをクリック 2. 削除を確認 有効になっているプリセットは削除できません。先に無効にしてから削除してください。 ## スマートバックフィル CC Switch は、手動での変更を失わないようにスマートバックフィル保護機能を提供しています。 ### 動作原理 1. プリセットを切り替える前に、現在の設定ファイルの内容を自動的に読み取る 2. ファイルの内容とデータベース内のプリセットを比較 3. 内容が異なる場合、ユーザーが手動で変更したことを示す 4. 手動変更の内容を現在のプリセットに保存 5. その後、新しいプリセットに切り替え ### 保護シーン | シーン | 処理方法 | |------|----------| | CLI 内で `CLAUDE.md` を直接編集 | 変更が自動的に現在のプリセットに保存 | | 外部エディタで設定ファイルを変更 | 変更が自動的に現在のプリセットに保存 | | 別のプリセットに切り替え | 現在の変更を保存してから切り替え | ### 技術的な詳細 バックフィル機能は以下のタイミングでトリガーされます: - **プリセットの切り替え時**:現在の live ファイルの内容を現在のプリセットに保存 - **現在のプリセットの編集時**:live ファイルから最新の内容を読み取り - **初回起動時**:既存の live ファイルの内容を自動インポート ### 注意事項 - バックフィルは異なるプリセットに切り替えるときにのみトリガーされる - 現在有効なプリセットがない場合、バックフィルはトリガーされない - バックフィルの失敗は切り替えフローに影響しない ## アプリ間での使用 Prompts はアプリごとに個別に管理されます: - Claude に切り替えると、Claude のプリセットが表示 - Codex に切り替えると、Codex のプリセットが表示 - Gemini に切り替えると、Gemini のプリセットが表示 - OpenCode に切り替えると、OpenCode のプリセットが表示 - OpenClaw に切り替えると、OpenClaw のプリセットが表示 複数のアプリで同じプロンプトを使用する場合は、それぞれで作成する必要があります。 ## インポート・エクスポート ### ディープリンクで共有 ディープリンクを生成してプリセットを共有できます: ``` ccswitch://import/prompt?data= ``` ### 設定のエクスポートで共有 設定をエクスポートするとすべてのプリセットが含まれ、インポートで復元できます。 ================================================ FILE: docs/user-manual/ja/3-extensions/3.3-skills.md ================================================ # 3.3 Skills スキル管理 ## 機能説明 Skills は再利用可能な機能拡張で、AI ツールに特定分野の専門的な能力を与えます。 スキルはフォルダ形式で存在し、以下を含みます: - プロンプトテンプレート - ツール定義 - サンプルコード ## 対応アプリ Skills 機能は以下の 4 つのアプリに対応しています: - **Claude Code** - **Codex** - **Gemini CLI** - **OpenCode** ## Skills ページを開く 上部ナビゲーションバーの **Skills** ボタンをクリックします。 > 注意:Skills ボタンはすべてのアプリモードで表示されます。 ## ページ概要 ![image-20260108010253926](../../assets/image-20260108010253926.png) ## スキルの発見 ### プリセットリポジトリ CC Switch は以下の GitHub リポジトリをプリセットとして設定しています: | リポジトリ | 説明 | | -------------- | ------------------------ | | Anthropic 公式 | Anthropic 提供の公式スキル | | ComposioHQ | コミュニティが管理するスキルコレクション | | コミュニティ精選 | 厳選された高品質スキル | ![image-20260108010308060](../../assets/image-20260108010308060.png) ### 検索とフィルタリング CC Switch は強力な検索とフィルタリング機能を提供しています: #### 検索ボックス - スキル名で検索 - スキルの説明で検索 - ディレクトリ名で検索 - リアルタイムフィルタリング、入力と同時に検索 #### ステータスフィルタ ドロップダウンメニューでインストール状態別にフィルタリング: | オプション | 説明 | | ------ | ------------------ | | すべて | すべてのスキルを表示 | | インストール済み | インストール済みのスキルのみ表示 | | 未インストール | 未インストールのスキルのみ表示 | ![image-20260108010324583](../../assets/image-20260108010324583.png) #### 組み合わせて使用 検索とフィルタリングは組み合わせて使用できます: - まず「インストール済み」でフィルタリング - 次にキーワードで検索 - 結果にマッチ数が表示 ### リストの更新 「更新」ボタンをクリックしてリポジトリを再スキャンし、最新のスキルを取得します。 ## スキルのインストール ### 操作手順 1. インストールしたいスキルカードを見つける 2. 「インストール」ボタンをクリック 3. インストール完了を待つ ### インストール先 | アプリ | インストールディレクトリ | | -------- | --------------------- | | Claude | `~/.claude/skills/` | | Codex | `~/.codex/skills/` | | Gemini | `~/.gemini/skills/` | | OpenCode | `~/.opencode/skills/` | ### インストール内容 インストールによりスキルフォルダがローカルにコピーされます: ``` ~/.claude/skills/ └── skill-name/ ├── README.md ├── prompt.md └── tools/ └── ... ``` ## スキルのアンインストール ### 操作手順 1. インストール済みのスキルカードを見つける 2. 「アンインストール」ボタンをクリック 3. アンインストールを確認 ### アンインストールの効果 - ローカルのスキルフォルダを削除 - インストール状態を更新 ## リポジトリ管理 ### リポジトリ管理を開く ページ上部の「リポジトリ管理」ボタンをクリックします。 ### カスタムリポジトリの追加 1. 「リポジトリを追加」をクリック 2. リポジトリ情報を入力: - Owner:GitHub ユーザー名または組織名 - Name:リポジトリ名 - Branch:ブランチ名(デフォルト main) - Subdirectory:スキルがあるサブディレクトリ(任意) 3. 「追加」をクリック ### リポジトリの形式 ``` https://github.com/{owner}/{name}/tree/{branch}/{subdirectory} ``` 例: ``` Owner: anthropics Name: claude-skills Branch: main Subdirectory: skills ``` ### リポジトリの削除 1. リポジトリリストで削除するリポジトリを見つける 2. 「削除」ボタンをクリック 3. 削除を確認 リポジトリを削除しても、そのリポジトリのスキルはリストから消えませんが、更新はできなくなります。 ## スキルカードの情報 各スキルカードには以下が表示されます: | 情報 | 説明 | | ---- | --------------- | | 名前 | スキル名 | | 説明 | 機能の説明 | | ソース | 所属リポジトリ | | ステータス | インストール済み / 未インストール | ## スキルの更新 現在、自動更新には対応していません。スキルを更新するには: 1. 既存のスキルをアンインストール 2. リストを更新 3. 再度インストール ### スキルリストが空の場合 考えられる原因: - ネットワークの問題で GitHub にアクセスできない - リポジトリ設定のエラー 解決方法: - ネットワーク接続を確認 - 「更新」をクリックしてリトライ - リポジトリ設定を確認 ### インストールに失敗する場合 考えられる原因: - ネットワークの問題 - ディスク容量不足 - 権限の問題 解決方法: - ネットワーク接続を確認 - ディスク容量を確認 - ディレクトリの権限を確認 ================================================ FILE: docs/user-manual/ja/4-proxy/4.1-service.md ================================================ # 4.1 プロキシサービス ## 機能説明 プロキシサービスは、ローカルで HTTP プロキシを起動し、すべての API リクエストをプロキシ経由で転送します。 **主な用途**: - リクエストログの記録 - API 使用量の統計 - フェイルオーバーのサポート - 複数アプリのリクエストを一元管理 ## プロキシの起動 ### 方法 1:メイン画面のスイッチ メイン画面上部の **プロキシスイッチ** ボタンをクリックします。 スイッチの状態: - 白:プロキシ停止中 - 緑:プロキシ実行中 ![image-20260108011353927](../../assets/image-20260108011353927.png) ### 方法 2:設定ページ 1. 「設定 → 詳細 → プロキシサービス」を開く 2. 右上のスイッチをクリック ![image-20260108011338922](../../assets/image-20260108011338922.png) ## プロキシ設定 ### 基本設定 | 設定項目 | 説明 | デフォルト値 | |--------|------|--------| | リスニングアドレス | プロキシがバインドする IP アドレス | `127.0.0.1` | | リスニングポート | プロキシがリスニングするポート | `15721` | | ログを有効化 | リクエストログを記録するかどうか | オン | ### 設定の変更 1. **プロキシサービスを停止**(先に停止する必要あり) 2. リスニングアドレスまたはポートを変更 3. 「保存」をクリック 4. プロキシを再起動 > アドレス/ポートの変更には、先にプロキシサービスの停止が必要です ### リスニングアドレスの説明 | アドレス | 説明 | |------|------| | `127.0.0.1` | ローカルマシンのみアクセス可能(推奨) | | `0.0.0.0` | LAN からのアクセスを許可 | ## 実行状態 プロキシ実行中、パネルには以下の情報が表示されます: ### サービスアドレス ``` http://127.0.0.1:15721 ``` 「コピー」ボタンでアドレスをコピーできます。 ### 現在のプロバイダー 各アプリが現在使用しているプロバイダーを表示: ``` Claude: PackyCode Codex: AIGoCode Gemini: Google 公式 ``` ### 統計データ | 指標 | 説明 | |------|------| | アクティブ接続 | 現在処理中のリクエスト数 | | 総リクエスト数 | 起動以来の総リクエスト数 | | 成功率 | リクエスト成功の割合(>90% 緑、≤90% 黄) | | 実行時間 | プロキシの稼働時間 | ### フェイルオーバーキュー プロキシパネルにはアプリタイプごとにフェイルオーバーキューが表示されます: ``` Claude ├── 1. PackyCode [使用中] ● ├── 2. AIGoCode ● └── 3. バックアップ ○ Codex ├── 1. AIGoCode [使用中] ● └── 2. バックアップ ● ``` キューの説明: - 数字は優先順位を示す - 「使用中」ラベルは現在使用しているプロバイダーを示す - ヘルスバッジはプロバイダーの状態を示す: - 緑:健康(連続失敗 0 回) - 黄:低下(連続失敗 1-2 回) - 赤:不健康(連続失敗 ≥3 回) ## 動作原理 ### リクエストフロー ```mermaid sequenceDiagram participant CLI as CLI ツール (Claude) participant Proxy as ローカルプロキシ (CC Switch) participant API as API プロバイダー (Anthropic) participant DB as データストレージ (Logger) CLI->>Proxy: API リクエストを送信 Proxy->>DB: リクエストログの記録/使用量の統計 Proxy->>API: リクエストを転送 API-->>Proxy: レスポンスを返却 Proxy-->>CLI: レスポンスを返却 ``` ### 設定の変更 プロキシを起動してアプリケーション接管を有効にすると、CC Switch はアプリの設定を変更します: **Claude**: ```json { "env": { "ANTHROPIC_BASE_URL": "http://127.0.0.1:15721" } } ``` **Codex**: ```toml base_url = "http://127.0.0.1:15721/v1" ``` **Gemini**: ``` GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:15721 ``` ## プロキシの停止 ### 方法 1:メイン画面のスイッチ プロキシスイッチボタンをクリックしてオフにします。 ### 方法 2:設定ページ プロキシサービスパネルでスイッチをオフにします。 ### 停止後の処理 プロキシの停止時、CC Switch は以下を実行します: 1. アプリの設定を元の状態に復元 2. リクエストログを保存 3. すべての接続を閉じる ## ログ記録 ### ログの有効化 プロキシパネルの「ログを有効化」スイッチをオンにします。 ### ログの内容 各リクエスト記録には以下が含まれます: | フィールド | 説明 | |------|------| | 時間 | リクエスト時刻 | | アプリ | Claude / Codex / Gemini | | プロバイダー | 使用されたプロバイダー | | モデル | リクエストされたモデル | | Token | 入力/出力の Token 数 | | レイテンシ | リクエストにかかった時間 | | ステータス | 成功/失敗 | ### ログの表示 「設定 → 使用量」タブでリクエストログを表示できます。 ## よくある質問 ### ポートが使用中 エラーメッセージ:`Address already in use` 解決方法: 1. ポートを変更する(例:5001) 2. またはそのポートを使用しているプログラムを終了する ### プロキシの起動に失敗する 確認事項: - ポートが使用中でないか - 十分な権限があるか - ファイアウォールがブロックしていないか ### リクエストがタイムアウトする 考えられる原因: - ネットワークの問題 - プロバイダーのサーバーの問題 - プロキシ設定のエラー 解決方法: - ネットワーク接続を確認 - プロバイダーの API に直接アクセスを試みる - プロバイダーの設定を確認 ================================================ FILE: docs/user-manual/ja/4-proxy/4.2-takeover.md ================================================ # 4.2 アプリケーション接管 ## 機能説明 アプリケーション接管とは、CC Switch のプロキシが特定アプリの API リクエストを接管することです。 接管を有効にすると: - アプリの API リクエストがローカルプロキシ経由で転送される - リクエストログと使用量の統計を記録できる - フェイルオーバー機能を使用できる ## 前提条件 アプリケーション接管機能を使用する前に、プロキシサービスを起動する必要があります。 ## 接管の有効化 ### 操作場所 設定 → 詳細 → プロキシサービス → アプリケーション接管エリア ### 操作手順 1. プロキシサービスが起動していることを確認 2. 「アプリケーション接管」エリアを見つける 3. 必要なアプリのスイッチをオンにする ### 接管スイッチ | スイッチ | 作用 | |------|------| | Claude 接管 | Claude Code のリクエストを接管 | | Codex 接管 | Codex のリクエストを接管 | | Gemini 接管 | Gemini CLI のリクエストを接管 | 複数のアプリの接管を同時に有効にできます。 ## 接管の仕組み ### 設定の変更 接管を有効にすると、CC Switch はアプリの設定ファイルを変更し、API エンドポイントをローカルプロキシに向けます。 **Claude 設定の変更**: ```json // 接管前 { "env": { "ANTHROPIC_BASE_URL": "https://api.anthropic.com" } } // 接管後 { "env": { "ANTHROPIC_BASE_URL": "http://127.0.0.1:15721" } } ``` **Codex 設定の変更**: ```toml # 接管前 base_url = "https://api.openai.com/v1" # 接管後 base_url = "http://127.0.0.1:15721/v1" ``` **Gemini 設定の変更**: ```bash # 接管前 GOOGLE_GEMINI_BASE_URL=https://generativelanguage.googleapis.com # 接管後 GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:15721 ``` ### リクエストの転送 プロキシがリクエストを受信すると: 1. リクエスト元を識別(Claude/Codex/Gemini) 2. そのアプリで現在有効なプロバイダーを検索 3. プロバイダーの実際のエンドポイントにリクエストを転送 4. リクエストログを記録 5. アプリにレスポンスを返却 ## 接管ステータスの表示 ### メイン画面の表示 接管を有効にすると、メイン画面に以下の変化があります: - **プロキシ Logo の色**:無色から緑に変化 - **プロバイダーカード**:現在アクティブなプロバイダーに緑の枠が表示 ### プロバイダーカードの状態 | 状態 | 枠の色 | 説明 | |------|----------|------| | 現在有効 | 青 | 設定ファイル内のプロバイダー(非プロキシモード) | | プロキシアクティブ | 緑 | プロキシが実際に使用しているプロバイダー | | 通常 | デフォルト | 使用されていないプロバイダー | ## 接管の無効化 ### 操作手順 1. プロキシパネルで対応するアプリの接管スイッチをオフにする 2. またはプロキシサービスを直接停止 ### 設定の復元 接管を無効にすると、CC Switch は以下を実行します: 1. アプリの設定を接管前の状態に復元 2. 現在のリクエストログを保存 ## 接管とプロバイダーの切り替え ### 接管モードでのプロバイダー切り替え 接管モードでプロバイダーを切り替える場合: 1. メイン画面でプロバイダーの「有効化」ボタンをクリック 2. プロキシが新しいプロバイダーを使用してリクエストを即座に転送 3. **CLI ツールの再起動は不要** これが接管モードの大きなメリットです:プロバイダーの切り替えが即座に反映されます。 ### 非接管モードでのプロバイダー切り替え 非接管モードでプロバイダーを切り替える場合: 1. 設定ファイルを変更 2. CLI ツールの再起動が必要 ## 複数アプリの接管 複数のアプリを同時に接管でき、それぞれ独立して管理されます: - 独立したプロバイダー設定 - 独立したフェイルオーバーキュー - 独立したリクエスト統計 ## 使用シーン ### シーン 1:使用量の監視 接管 + ログ記録を有効にして、API の使用状況を監視します。 ### シーン 2:素早い切り替え 接管を有効にすると、プロバイダーの切り替えに CLI ツールの再起動が不要になります。 ### シーン 3:フェイルオーバー 接管の有効化はフェイルオーバー機能を使用するための前提条件です。 ## 注意事項 ### パフォーマンスへの影響 プロキシにより少量のレイテンシ(通常 < 10ms)が追加されますが、ほとんどのシーンでは無視できます。 ### ネットワーク要件 接管モードでは、CLI ツールがローカルプロキシアドレスにアクセスできる必要があります。 ### 設定のバックアップ 接管を有効にする前に、CC Switch は元の設定をバックアップし、無効化時に復元します。 ## よくある質問 ### 接管後にリクエストが失敗する 確認事項: - プロキシサービスが正常に実行されているか - プロバイダーの設定が正しいか - ネットワークが正常か ### 接管を無効にしても設定が復元されない 考えられる原因: - プロキシの異常終了 - 設定ファイルが他のプログラムに変更された 解決方法: - プロバイダーを手動で編集して保存し直す - または接管を再度有効にしてから無効にする ================================================ FILE: docs/user-manual/ja/4-proxy/4.3-failover.md ================================================ # 4.3 フェイルオーバー ## 機能説明 フェイルオーバー機能は、メインプロバイダーのリクエストが失敗した場合に、自動的にバックアッププロバイダーに切り替えてサービスの中断を防ぎます。 **適用シーン**: - プロバイダーのサービスが不安定な場合 - 高可用性が必要な場合 - 長時間実行するタスク ## 前提条件 フェイルオーバー機能を使用するには: 1. プロキシサービスを起動 2. アプリケーション接管を有効化 3. フェイルオーバーキューを設定 4. 自動フェイルオーバーを有効化 ## フェイルオーバーキューの設定 ### 設定ページを開く 設定 → 詳細 → フェイルオーバー ### アプリの選択 ページ上部に 3 つのタブがあります: - Claude - Codex - Gemini 設定するアプリを選択します。 ### バックアッププロバイダーの追加 1. 「フェイルオーバーキュー」エリアで 2. 「プロバイダーを追加」をクリック 3. ドロップダウンリストからプロバイダーを選択 4. プロバイダーがキューの末尾に追加 ### 優先順位の調整 プロバイダーをドラッグして順序を調整: - 番号が小さいほど優先度が高い - メインプロバイダーが失敗すると、順番にバックアッププロバイダーを試行 ### プロバイダーの削除 プロバイダーの右側にある「削除」ボタンをクリックします。 ## メイン画面でのクイック操作 プロキシとフェイルオーバーがどちらも有効な場合、プロバイダーカードにフェイルオーバースイッチが表示されます。 ### キューに追加 1. プロバイダーカードを見つける 2. フェイルオーバースイッチをオンにする 3. プロバイダーが自動的にキューに追加 ### キューから削除 1. プロバイダーカードのフェイルオーバースイッチをオフにする 2. プロバイダーがキューから削除 ## 自動フェイルオーバーの有効化 ### 操作手順 1. フェイルオーバー設定ページで 2. 「自動フェイルオーバー」スイッチをオンにする ### スイッチの説明 | 状態 | 動作 | |------|------| | オフ | 失敗を記録するのみ、自動切り替えなし | | オン | 失敗時に自動的に次のプロバイダーに切り替え | ## フェイルオーバーのフロー ```mermaid graph TD Start[リクエストがプロキシに到達] --> Send[現在のプロバイダーに送信] Send --> CheckSuccess{成功?} CheckSuccess -- はい --> Return[レスポンスを返却] CheckSuccess -- いいえ --> LogFail[失敗を記録] LogFail --> CheckCircuit{サーキットブレーカーの状態確認} CheckCircuit -- 発動中 --> Skip[このプロバイダーをスキップ] CheckCircuit -- 未発動 --> IncFail[失敗カウントを増加] Skip --> Next{キューに次がある?} IncFail --> Next Next -- あり --> Switch[プロバイダーを切り替え] Switch --> Retry[リクエストをリトライ] Retry --> Send Next -- なし --> Error[エラーを返却] ``` ## サーキットブレーカーの設定 サーキットブレーカーは、失敗したプロバイダーへの頻繁なリトライを防止します。 ### 設定項目 アプリごとに独立したデフォルト設定があります。以下は共通のデフォルト値で、Claude には独自の緩やかな設定があります。 | 設定 | 説明 | 共通デフォルト | Claude デフォルト | 範囲 | |------|------|--------|--------|------| | 失敗閾値 | 連続何回失敗でサーキットブレーカーが発動 | 4 | 8 | 1-20 | | 復旧成功閾値 | ハーフオープン状態で何回成功したら閉じるか | 2 | 3 | 1-10 | | 復旧待機時間 | サーキットブレーカー発動後の復旧試行までの時間(秒) | 60 | 90 | 0-300 | | エラー率閾値 | この値を超えるとサーキットブレーカーが発動 | 60% | 70% | 0-100% | | 最小リクエスト数 | エラー率計算前の最小リクエスト数 | 10 | 15 | 5-100 | > Claude はリクエストに時間がかかるため、デフォルト設定はより緩やかで、多くの失敗を許容します。 ### タイムアウト設定 | 設定 | 説明 | 共通デフォルト | Claude デフォルト | 範囲 | |------|------|--------|--------|------| | ストリーム初バイトタイムアウト | 最初のデータチャンクの最大待機時間(秒) | 60 | 90 | 1-120 | | ストリームサイレントタイムアウト | データチャンク間の最大間隔(秒) | 120 | 180 | 60-600(0 で無効化) | | 非ストリームタイムアウト | 非ストリームリクエストの総タイムアウト時間(秒) | 600 | 600 | 60-1200 | ### リトライ設定 | 設定 | 説明 | 共通デフォルト | Claude デフォルト | 範囲 | |------|------|--------|--------|------| | 最大リトライ回数 | リクエスト失敗時のリトライ回数 | 3 | 6 | 0-10 | > Gemini のデフォルト最大リトライ回数は 5 です。 ### サーキットブレーカーの状態 | 状態 | 説明 | |------|------| | 閉(Closed) | 正常状態、リクエストを許可 | | 開(Open) | サーキットブレーカー発動中、このプロバイダーをスキップ | | 半開(Half-Open) | 復旧試行中、探査リクエストを送信 | ### 状態遷移 ```mermaid stateDiagram-v2 [*] --> Closed: 初期化 Closed --> Open: 失敗回数 >= 閾値 Open --> HalfOpen: サーキットブレーカー期間満了 HalfOpen --> Closed: 探査成功 (>= 復旧閾値) HalfOpen --> Open: 探査失敗 ``` ## ヘルスステータスの表示 ### プロバイダーカード カードにヘルスステータスバッジが表示されます: | バッジ | 状態 | 説明 | |------|------|------| | 緑 | 健康 | 連続失敗回数 0 | | 黄 | 警告 | 失敗はあるがサーキットブレーカー未発動 | | 赤 | サーキットブレーカー発動 | 一時的にスキップ | ### キューリスト フェイルオーバーキューにも各プロバイダーのヘルスステータスが表示されます。 ## フェイルオーバーログ 各フェイルオーバーの記録内容: | 情報 | 説明 | |------|------| | 時間 | 発生時刻 | | 元のプロバイダー | 失敗したプロバイダー | | 新しいプロバイダー | 切り替え先のプロバイダー | | 失敗理由 | エラー情報 | 使用量統計のリクエストログで確認できます。 ## ベストプラクティス ### キュー設定のアドバイス 1. **メインプロバイダー**:最も安定で高速なプロバイダー 2. **第 1 バックアップ**:次善の選択 3. **第 2 バックアップ**:最後の手段 ### サーキットブレーカー設定のアドバイス | シーン | 失敗閾値 | サーキットブレーカー期間 | |------|----------|----------| | 高可用性要件 | 2 | 30 秒 | | 一般的なシーン | 3 | 60 秒 | | 偶発的な失敗を許容 | 5 | 120 秒 | ### 監視のアドバイス 定期的に確認: - 各プロバイダーのヘルスステータス - フェイルオーバーの発生頻度 - サーキットブレーカーの発動状況 ## よくある質問 ### フェイルオーバーがトリガーされない 確認事項: 1. プロキシサービスが実行中か 2. アプリケーション接管が有効か 3. 自動フェイルオーバーが有効か 4. キューにバックアッププロバイダーがあるか ### フェイルオーバーが頻繁にトリガーされる 考えられる原因: - メインプロバイダーが不安定 - ネットワークの問題 - 設定のエラー 解決方法: - メインプロバイダーの状態を確認 - サーキットブレーカーのパラメータを調整 - メインプロバイダーの変更を検討 ### すべてのプロバイダーがサーキットブレーカー発動中 サーキットブレーカー期間満了後に自動復旧を待つか、以下を実行: 1. プロキシサービスを手動で再起動 2. サーキットブレーカーの状態をリセット ================================================ FILE: docs/user-manual/ja/4-proxy/4.4-usage.md ================================================ # 4.4 使用量統計 ## 機能説明 使用量統計機能は、API リクエストデータを記録・分析して、以下をサポートします: - API の使用状況の把握 - 費用支出の見積もり - 使用パターンの分析 - 問題のトラブルシューティング ## 前提条件 使用量統計機能を使用するには: 1. プロキシサービスを起動 2. アプリケーション接管を有効化 3. ログ記録を有効化 ## 使用量統計を開く 設定 → 使用量 タブ ## 統計概要 ### 集計カード ページ上部に主要指標が表示されます: | 指標 | 説明 | |------|------| | 総リクエスト数 | 統計期間内のリクエスト総数 | | 総 Token | 入力 + 出力 Token の合計 | | 推定費用 | 料金設定に基づいて計算された費用 | | 成功率 | 成功したリクエストの割合 | ### 期間 統計の期間を選択できます: | オプション | 範囲 | |------|------| | 今日 | 当日 00:00 から現在まで | | 過去 7 日間 | 直近 7 日間 | | 過去 30 日間 | 直近 30 日間 | ![image-20260108011730105](../../assets/image-20260108011730105.png) ## トレンドグラフ ### リクエストトレンド 折れ線グラフでリクエスト数の変化傾向を表示: - X 軸:時間 - Y 軸:リクエスト数 - 時間単位/日単位で表示可能 - ズームとドラッグに対応 ### Token トレンド Token 使用量の変化を表示: - 入力 Token(青)- ユーザーが送信した prompt の内容 - 出力 Token(緑)- AI が生成した回答の内容 - キャッシュ作成 Token(オレンジ)- 初回キャッシュ作成で消費された Token - キャッシュヒット Token(紫)- キャッシュ再利用で節約された Token - コスト(赤い破線、右側 Y 軸)- 推定費用 > **キャッシュ Token の説明**:Anthropic API は Prompt Caching 機能をサポートしています。キャッシュ作成時は高い料金(通常、入力価格の 1.25 倍)がかかりますが、その後のキャッシュヒット時は 0.1 倍の価格のみで、繰り返しリクエストのコストを大幅に削減できます。 ### 時間粒度 - **今日**:時間単位で表示(24 データポイント) - **7 日間/30 日間**:日単位で表示 ![image-20260108011742847](../../assets/image-20260108011742847.png) ## 詳細データ ページ下部に 3 つのデータタブがあります: ### リクエストログ 各リクエストの詳細記録: | フィールド | 説明 | |------|------| | 時間 | リクエスト時刻 | | プロバイダー | 使用されたプロバイダー名 | | モデル | リクエストされたモデル(課金モデル) | | 入力 Token | 入力の Token 数 | | 出力 Token | 出力の Token 数 | | キャッシュ読取 | キャッシュヒットの Token 数 | | キャッシュ作成 | キャッシュ作成の Token 数 | | 総費用 | 推定費用(ドル) | | 所要時間情報 | リクエスト時間、初回 Token 時間、ストリーム/非ストリーム | | ステータス | HTTP ステータスコード | #### 所要時間情報の説明 所要時間情報列には複数のバッジが表示されます: | バッジ | 説明 | 色のルール | |------|------|----------| | 総所要時間 | リクエストの総時間(秒) | ≤5s 緑、≤120s オレンジ、>120s 赤 | | 初回 Token | ストリームリクエストの最初の Token 時間 | ≤5s 緑、≤120s オレンジ、>120s 赤 | | ストリーム/非ストリーム | リクエストタイプ | ストリーム:青、非ストリーム:紫 | #### 詳細の表示 リクエスト行をクリックすると詳細情報を表示: - 完全なリクエストパラメータ - レスポンス内容のサマリー - エラー情報(失敗した場合) #### ログのフィルタリング 以下の条件でフィルタリングできます: | フィルタ項目 | オプション | |--------|------| | アプリタイプ | すべて / Claude / Codex / Gemini | | ステータスコード | すべて / 200 / 400 / 401 / 429 / 500 | | プロバイダー | テキスト検索 | | モデル | テキスト検索 | | 期間 | 開始時刻 - 終了時刻(日時ピッカー) | 操作ボタン: - **検索**:フィルタ条件を適用 - **リセット**:デフォルトに戻す(過去 24 時間) - **更新**:データを再読み込み ![image-20260108011859974](../../assets/image-20260108011859974.png) ### プロバイダー統計 プロバイダー別の集計データ: | フィールド | 説明 | |------|------| | プロバイダー | プロバイダー名 | | リクエスト数 | そのプロバイダーの総リクエスト数 | | 成功数 | 成功したリクエスト数 | | 失敗数 | 失敗したリクエスト数 | | 成功率 | 成功の割合 | | 総 Token | Token 使用量の合計 | | 推定費用 | そのプロバイダーの費用 | ![image-20260108011907928](../../assets/image-20260108011907928.png) ### モデル統計 モデル別の集計データ: | フィールド | 説明 | |------|------| | モデル | モデル名 | | リクエスト数 | そのモデルの総リクエスト数 | | 入力 Token | 入力 Token の合計 | | 出力 Token | 出力 Token の合計 | | 平均レイテンシ | 平均応答時間 | | 推定費用 | そのモデルの費用 | ![image-20260108011915381](../../assets/image-20260108011915381.png) ## 料金設定 ### 料金設定を開く 設定 → 詳細 → 料金設定 ### モデル価格の設定 各モデルの価格を設定(100 万 Token あたり): | フィールド | 説明 | |------|------| | モデル ID | モデル識別子(例:claude-3-sonnet) | | 表示名 | カスタム表示名 | | 入力価格 | 100 万入力 Token あたりの価格 | | 出力価格 | 100 万出力 Token あたりの価格 | | キャッシュ読取価格 | 100 万キャッシュヒット Token あたりの価格 | | キャッシュ作成価格 | 100 万キャッシュ作成 Token あたりの価格 | ### 操作 - **追加**:「追加」ボタンで新しいモデル価格を追加 - **編集**:行末の編集アイコンで変更 - **削除**:行末の削除アイコンで削除 ![image-20260108011933565](../../assets/image-20260108011933565.png) ### プリセット価格 CC Switch は一般的なモデルの公式価格(100 万 Token あたり)をプリセットしています: **Claude シリーズ(ドル)**: | モデル | 入力 | 出力 | キャッシュ読取 | キャッシュ作成 | |------|------|------|----------|----------| | **Claude 4.5 シリーズ** | | | | | | claude-opus-4-5 | $5 | $25 | $0.50 | $6.25 | | claude-sonnet-4-5 | $3 | $15 | $0.30 | $3.75 | | claude-haiku-4-5 | $1 | $5 | $0.10 | $1.25 | | **Claude 4 シリーズ** | | | | | | claude-opus-4 | $15 | $75 | $1.50 | $18.75 | | claude-opus-4-1 | $15 | $75 | $1.50 | $18.75 | | claude-sonnet-4 | $3 | $15 | $0.30 | $3.75 | | **Claude 3.5 シリーズ** | | | | | | claude-3-5-sonnet | $3 | $15 | $0.30 | $3.75 | | claude-3-5-haiku | $0.80 | $4 | $0.08 | $1.00 | **OpenAI シリーズ / Codex(ドル)**: | モデル | 入力 | 出力 | キャッシュ読取 | |------|------|------|----------| | **GPT-5.2 シリーズ** | | | | | gpt-5.2 | $1.75 | $14 | $0.175 | | **GPT-5.1 シリーズ** | | | | | gpt-5.1 | $1.25 | $10 | $0.125 | | **GPT-5 シリーズ** | | | | | gpt-5 | $1.25 | $10 | $0.125 | > 注:Codex プリセットには low/medium/high などの変種が含まれており、価格はベースモデルと同一です。 **Gemini シリーズ(ドル)**: | モデル | 入力 | 出力 | キャッシュ読取 | |------|------|------|----------| | **Gemini 3 シリーズ** | | | | | gemini-3-pro-preview | $2 | $12 | $0.20 | | gemini-3-flash-preview | $0.50 | $3 | $0.05 | | **Gemini 2.5 シリーズ** | | | | | gemini-2.5-pro | $1.25 | $10 | $0.125 | | gemini-2.5-flash | $0.30 | $2.50 | $0.03 | **中国メーカーのモデル**: > 注: 通貨は各プロバイダーの公式料金ページに従います。StepFun は現在 USD 表記です。 | モデル | 入力 | 出力 | キャッシュ読取 | |------|------|------|----------| | **StepFun** | | | | | step-3.5-flash | $0.10 | $0.30 | $0.02 | | **DeepSeek** | | | | | deepseek-v3.2 | ¥2.00 | ¥3.00 | ¥0.40 | | deepseek-v3.1 | ¥4.00 | ¥12.00 | ¥0.80 | | deepseek-v3 | ¥2.00 | ¥8.00 | ¥0.40 | | **Kimi (月之暗面)** | | | | | kimi-k2-thinking | ¥4.00 | ¥16.00 | ¥1.00 | | kimi-k2 | ¥4.00 | ¥16.00 | ¥1.00 | | kimi-k2-turbo | ¥8.00 | ¥58.00 | ¥1.00 | | **MiniMax** | | | | | minimax-m2.1 | ¥2.10 | ¥8.40 | ¥0.21 | | minimax-m2.1-lightning | ¥2.10 | ¥16.80 | ¥0.21 | | **その他** | | | | | glm-4.7 | ¥2.00 | ¥8.00 | ¥0.40 | | doubao-seed-code | ¥1.20 | ¥8.00 | ¥0.24 | | mimo-v2-flash | 無料 | 無料 | - | ### カスタム価格 中継サービスを使用する場合、価格が異なる場合があります: 1. 「編集」ボタンをクリック 2. 価格を変更 3. 保存 ## よくある質問 ### 統計データが空 確認事項: - プロキシサービスが実行中か - アプリケーション接管が有効か - ログ記録が有効か - プロキシ経由でリクエストがあったか ### 費用の見積もりが不正確 考えられる原因: - 料金設定が実際と異なる - 中継サービスの特別な料金体系を使用 解決方法: - 料金設定を更新 - プロバイダーの実際の請求書を参照 ### Token 数がプロバイダーと一致しない CC Switch は独自の方法で Token 数を推定しており、プロバイダーの計算方法と若干の差異が生じる場合があります。プロバイダーの請求書を基準にしてください。 ================================================ FILE: docs/user-manual/ja/4-proxy/4.5-model-test.md ================================================ # 4.5 モデルテスト ## 機能説明 モデルテスト機能は、プロバイダーに設定されたモデルが使用可能かどうかを確認するために、実際の API リクエストを送信してテストします: - モデルが存在するか - API Key が有効か - エンドポイントが正常に応答するか - 応答レイテンシが正常か ## 設定を開く 設定 → 詳細 → モデルテスト ## テストモデルの設定 各アプリのテスト用モデルを設定します: | アプリ | 設定項目 | デフォルト値 | 説明 | |------|--------|--------|------| | Claude | Claude モデル | システムデフォルト | Haiku シリーズの使用を推奨(低コスト・高速) | | Codex | Codex モデル | システムデフォルト | mini シリーズの使用を推奨 | | Gemini | Gemini モデル | システムデフォルト | Flash シリーズの使用を推奨 | ### モデル選択のアドバイス テストモデルを選択する際の考慮事項: 1. **コスト**:低価格のモデルを選択(例:Haiku、Mini、Flash) 2. **速度**:応答が速いモデルを選択 3. **可用性**:プロバイダーがサポートしているモデルを選択 ## テストパラメータの設定 ### タイムアウト時間 | パラメータ | 説明 | デフォルト値 | 範囲 | |------|------|--------|------| | タイムアウト時間 | 1 回のリクエストのタイムアウト | 45 秒 | 10-120 秒 | 短すぎると誤判定の可能性があり、長すぎると障害検出が遅れます。 ### リトライ回数 | パラメータ | 説明 | デフォルト値 | 範囲 | |------|------|--------|------| | 最大リトライ | 失敗時のリトライ回数 | 2 回 | 0-5 回 | ネットワークが不安定な場合はリトライ回数を増やすことを推奨します。 ### デグレード閾値 | パラメータ | 説明 | デフォルト値 | 範囲 | |------|------|--------|------| | デグレード閾値 | この時間を超えるとデグレードとマーク | 6000ms | 1000-30000ms | 閾値を超えたプロバイダーは「デグレード」状態としてマークされますが、引き続き使用可能です。 ## モデルテストの実行 ### 手動テスト プロバイダーカードの「テスト」ボタンをクリックします: 1. 設定されたエンドポイントにテストリクエストを送信 2. 設定されたテストモデルを使用 3. レスポンスまたはタイムアウトを待機 4. テスト結果を表示 ### テスト内容 テストリクエストは: - 短い prompt(例:"Hi")を送信 - 最大出力 Token を制限(通常 10-50) - ストリームレスポンスで初バイト時間を検出 ## テスト結果 ### ヘルスステータス | ステータス | アイコン | 説明 | |------|------|------| | 健康 | 緑 | レスポンス正常、レイテンシが閾値内 | | デグレード | 黄 | レスポンス正常だが、レイテンシが閾値超過 | | 利用不可 | 赤 | リクエスト失敗またはタイムアウト | ### 結果情報 テスト完了後に表示: - 応答レイテンシ(ミリ秒) - 初バイト時間(TTFB) - エラー情報(失敗した場合) ## フェイルオーバーとの連携 モデルテストはフェイルオーバー機能と連携して使用します: ### ヘルスチェック プロキシサービスを有効にすると、システムはフェイルオーバーキュー内のプロバイダーに対して定期的にヘルスチェックを実行します: 1. 設定されたテストモデルでリクエストを送信 2. レスポンスに基づいてヘルスステータスを更新 3. 不健康なプロバイダーは一時的にスキップ ### サーキットブレーカーからの復旧 プロバイダーがサーキットブレーカー状態から復旧する際: 1. モデルテストで可用性を確認 2. テスト合格後、正常状態に復旧 3. テスト不合格の場合、サーキットブレーカーを継続 ## よくある質問 ### テストは失敗するが実際には使用可能 **考えられる原因**: - テストモデルと実際に使用するモデルが異なる - プロバイダーが設定されたテストモデルをサポートしていない **解決方法**: - テストモデルをプロバイダーがサポートするモデルに変更 - プロバイダーのモデルリストを確認 ### レイテンシが高すぎる **考えられる原因**: - ネットワークレイテンシ - プロバイダーのサーバー負荷が高い - モデルの応答が遅い **解決方法**: - より高速なテストモデルを使用 - デグレード閾値を調整 - ミラーエンドポイントの使用を検討 ### 頻繁にタイムアウトする **考えられる原因**: - タイムアウト時間の設定が短すぎる - ネットワークが不安定 - プロバイダーのサービスが不安定 **解決方法**: - タイムアウト時間を延長 - リトライ回数を増加 - ネットワーク接続を確認 ## 注意事項 - モデルテストは少量の API 枠を消費します - テストには低コストのモデルの使用を推奨 - テスト頻度は高すぎないように、枠の浪費を避けてください - プロバイダーごとにサポートするモデルが異なる場合があります ================================================ FILE: docs/user-manual/ja/5-faq/5.1-config-files.md ================================================ # 5.1 設定ファイルの説明 ## CC Switch のデータストレージ ### ストレージディレクトリ デフォルトの場所:`~/.cc-switch/` 設定で場所をカスタマイズ可能です(クラウド同期用)。 ### ディレクトリ構造 ``` ~/.cc-switch/ ├── cc-switch.db # SQLite データベース ├── settings.json # デバイスレベルの設定 └── backups/ # 自動バックアップ ├── backup-20251230-120000.json ├── backup-20251229-180000.json └── ... ``` ### データベースの内容 `cc-switch.db` は SQLite データベースで、以下を保存しています: | テーブル | 内容 | |-----|------| | providers | プロバイダー設定 | | provider_endpoints | プロバイダーエンドポイント候補リスト | | mcp_servers | MCP サーバー設定 | | prompts | プロンプトプリセット | | skills | スキルのインストール状態 | | skill_repos | スキルリポジトリ設定 | | proxy_config | プロキシ設定 | | proxy_request_logs | プロキシリクエストログ | | provider_health | プロバイダーヘルスステータス | | model_pricing | モデル料金 | | settings | アプリ設定 | ### デバイス設定 `settings.json` はデバイスレベルの設定を保存します: ```json { "language": "zh", "theme": "system", "windowBehavior": "minimize", "autoStart": false, "claudeConfigDir": null, "codexConfigDir": null, "geminiConfigDir": null, "opencodeConfigDir": null, "openclawConfigDir": null } ``` これらの設定はデバイス間で同期されません。 ### 自動バックアップ `backups/` ディレクトリに自動バックアップが保存されます: - 設定インポートのたびに自動作成 - 最新の 10 件のバックアップを保持 - ファイル名にタイムスタンプを含む ## Claude Code の設定 ### 設定ディレクトリ デフォルト:`~/.claude/` ### 主要ファイル ``` ~/.claude/ ├── settings.json # メイン設定ファイル ├── CLAUDE.md # システムプロンプト └── skills/ # スキルディレクトリ └── ... ``` ### settings.json ```json { "env": { "ANTHROPIC_API_KEY": "sk-xxx", "ANTHROPIC_BASE_URL": "https://api.anthropic.com" }, "permissions": { "allow_file_access": true } } ``` | フィールド | 説明 | |------|------| | `env.ANTHROPIC_API_KEY` | API キー | | `env.ANTHROPIC_BASE_URL` | API エンドポイント(任意) | | `env.ANTHROPIC_AUTH_TOKEN` | 代替認証方式 | ### MCP 設定 MCP サーバーの設定は `~/.claude.json` にあります: ```json { "mcpServers": { "mcp-fetch": { "command": "uvx", "args": ["mcp-server-fetch"] } } } ``` ## Codex の設定 ### 設定ディレクトリ デフォルト:`~/.codex/` ### 主要ファイル ``` ~/.codex/ ├── auth.json # 認証設定 ├── config.toml # メイン設定 + MCP └── AGENTS.md # システムプロンプト ``` ### auth.json ```json { "OPENAI_API_KEY": "sk-xxx" } ``` ### config.toml ```toml # 基本設定 base_url = "https://api.openai.com/v1" model = "gpt-4" # MCP サーバー [mcp_servers.mcp-fetch] command = "uvx" args = ["mcp-server-fetch"] ``` ## Gemini CLI の設定 ### 設定ディレクトリ デフォルト:`~/.gemini/` ### 主要ファイル ``` ~/.gemini/ ├── .env # 環境変数(API Key) ├── settings.json # メイン設定 + MCP └── GEMINI.md # システムプロンプト ``` ### .env ```bash GEMINI_API_KEY=xxx GOOGLE_GEMINI_BASE_URL=https://generativelanguage.googleapis.com GEMINI_MODEL=gemini-pro ``` ### settings.json ```json { "mcpServers": { "mcp-fetch": { "command": "uvx", "args": ["mcp-server-fetch"] } } } ``` | フィールド | 説明 | |------|------| | `mcpServers` | MCP サーバー設定 | ## OpenCode の設定 ### 設定ディレクトリ デフォルト:`~/.opencode/` ### 主要ファイル ``` ~/.opencode/ ├── config.json # メイン設定ファイル ├── AGENTS.md # システムプロンプト └── skills/ # スキルディレクトリ └── ... ``` ## OpenClaw の設定 ### 設定ディレクトリ デフォルト:`~/.openclaw/` ### 主要ファイル ``` ~/.openclaw/ ├── openclaw.json # メイン設定ファイル(JSON5 形式) ├── AGENTS.md # システムプロンプト └── skills/ # スキルディレクトリ └── ... ``` ### openclaw.json OpenClaw は JSON5 形式の設定ファイルを使用し、主に以下のセクションを含みます: ```json5 { // モデルプロバイダー設定 models: { mode: "merge", providers: { "custom-provider": { baseUrl: "https://api.example.com/v1", apiKey: "your-api-key", api: "openai-completions", models: [{ id: "model-id", name: "Model Name" }] } } }, // 環境変数 env: { ANTHROPIC_API_KEY: "sk-..." }, // Agent デフォルトモデル設定 agents: { defaults: { model: { primary: "provider/model" } } }, // ツール設定 tools: {}, // ワークスペースファイル設定 workspace: {} } ``` | フィールド | 説明 | |------|------| | `models.providers` | プロバイダー設定(CC Switch の「プロバイダー」にマッピング) | | `env` | 環境変数設定 | | `agents.defaults` | Agent デフォルトモデル設定 | | `tools` | ツール設定 | | `workspace` | ワークスペースファイル管理 | ## 設定の優先順位 CC Switch が設定を変更する際の優先順位: 1. **CC Switch データベース** - 単一事実源 (SSOT) 2. **Live 設定ファイル** - プロバイダー切り替え時に書き込み 3. **バックフィル機能** - 現在のプロバイダーの編集時に Live ファイルから読み取り ## 手動での設定編集 ### 手動編集可能なもの - CLI ツールの設定ファイル(CC Switch がバックフィルする) - CC Switch の `settings.json` ### 手動編集を推奨しないもの - `cc-switch.db` データベースファイル - バックアップファイル ### 編集後の同期 CLI ツールの設定を手動で編集した場合: 1. CC Switch を開く 2. 対応するプロバイダーを編集 3. 手動変更の内容がバックフィルされていることを確認 4. 保存してデータベースに同期 ## 設定の移行 ### 旧バージョンからの移行 CC Switch v3.7.0 で JSON ファイルから SQLite に移行しました: - 初回起動時に自動的に移行 - 移行成功後に通知を表示 - 旧設定ファイルはバックアップとして保持 ### デバイス間の移行 1. 移行元のデバイスで設定をエクスポート 2. 移行先のデバイスで設定をインポート 3. またはクラウド同期機能を使用 ## 設定のバックアップに関するアドバイス ### 定期的なバックアップ 定期的に設定をエクスポートすることを推奨します: 1. 設定 → 詳細 → データ管理 2. 「エクスポート」をクリック 3. 安全な場所に保存 ### バックアップに含まれる内容 エクスポートファイルには以下が含まれます: - すべてのプロバイダー設定 - MCP サーバー設定 - Prompts プリセット - アプリ設定 ### 含まれない内容 - 使用量ログ(データ量が大きいため) - デバイスレベルの設定(デバイス間の移動に適さないため) ================================================ FILE: docs/user-manual/ja/5-faq/5.2-questions.md ================================================ # 5.2 よくある質問 FAQ ## インストールに関する問題 ### macOS で「不明な開発者」と表示される **問題**:初回起動時に「開けません。身元不明の開発者のものです」と表示される **解決方法 1**:システム設定から 1. 警告ダイアログを閉じる 2. 「システム設定」→「プライバシーとセキュリティ」を開く 3. CC Switch に関する表示を見つける 4. 「このまま開く」をクリック 5. 再度アプリを開く **解決方法 2**:ターミナルコマンドから(推奨) ```bash sudo xattr -dr com.apple.quarantine /Applications/CC\ Switch.app/ ``` 実行後、正常にアプリを開けるようになります。 ### Windows でインストール後に起動できない **考えられる原因**: - WebView2 ランタイムが不足 - ウイルス対策ソフトによるブロック **解決方法**: 1. [Microsoft Edge WebView2](https://developer.microsoft.com/en-us/microsoft-edge/webview2/) をインストール 2. CC Switch をウイルス対策ソフトのホワイトリストに追加 ### Linux で起動エラー **問題**:AppImage が起動しない **解決方法**: ```bash # 実行権限を追加 chmod +x CC-Switch-*.AppImage # それでも失敗する場合 ./CC-Switch-*.AppImage --no-sandbox ``` ## プロバイダーに関する問題 ### プロバイダーを切り替えても反映されない **原因**:CLI ツールが設定を再読み込みする必要がある **解決方法**: - Claude Code:ターミナルを閉じて再度開く、または IDE を再起動 - Codex:ターミナルを閉じて再度開く - Gemini:トレイからの切り替えで即時反映、再起動不要 ### API Key が無効 **確認手順**: 1. API Key が正しくコピーされているか(余分なスペースがないか) 2. API Key が期限切れでないか 3. エンドポイントアドレスが正しいか 4. 速度テストで接続を確認 ### 公式ログインに戻すには **操作手順**: 1. 「公式ログイン」プリセット(Claude/Codex)または「Google 公式」プリセット(Gemini)を選択 2. 「有効化」をクリック 3. 対応する CLI ツールを再起動 4. CLI ツールのログインフローに従って操作 ## プロキシに関する問題 ### プロキシサービスの起動に失敗する **考えられる原因**:ポートが使用中 **解決方法**: 1. ポートの使用状況を確認: ```bash # macOS/Linux lsof -i :49152 # Windows netstat -ano | findstr :49152 ``` 2. ポートを使用しているプログラムを終了 3. または設定を変更してデフォルトポートに復旧: - 「設定 → プロキシサービス」を開く - 「デフォルトに戻す」ボタンをクリック ### プロキシモードでリクエストがタイムアウトする **考えられる原因**: - ネットワークの問題 - プロバイダーのサーバーの問題 - プロキシ設定のエラー **解決方法**: 1. ネットワーク接続を確認 2. プロバイダーの API に直接アクセスを試みる(プロキシを無効にして) 3. プロバイダーの設定が正しいか確認 ### プロキシを無効にしても設定が復元されない **考えられる原因**:プロキシの異常終了 **解決方法**: 1. 現在のプロバイダーを編集 2. エンドポイントアドレスが正しいか確認 3. 保存して設定を更新 ## フェイルオーバーに関する問題 ### フェイルオーバーがトリガーされない **チェックリスト**: - [ ] プロキシサービスが実行中か - [ ] アプリケーション接管が有効か - [ ] 自動フェイルオーバーが有効か - [ ] キューにバックアッププロバイダーがあるか ### フェイルオーバーが頻繁にトリガーされる **考えられる原因**: - メインプロバイダーが不安定 - サーキットブレーカーの閾値が低すぎる **解決方法**: 1. メインプロバイダーの状態を確認 2. 失敗閾値を引き上げる(例:3 → 5) 3. メインプロバイダーの変更を検討 ### すべてのプロバイダーがサーキットブレーカー発動中 **解決方法**: 1. サーキットブレーカー期間満了を待つ(デフォルト 60 秒) 2. またはプロキシサービスを再起動して状態をリセット ## データに関する問題 ### 設定が消えた **考えられる原因**: - 設定ディレクトリが削除された - データベースが破損 **解決方法**: 1. `~/.cc-switch/` ディレクトリが存在するか確認 2. バックアップから復元:`~/.cc-switch/backups/` 3. または以前にエクスポートした設定ファイルからインポート ### 設定のインポートに失敗する **考えられる原因**: - ファイル形式のエラー - バージョンの非互換性 **解決方法**: 1. ファイルが CC Switch からエクスポートされた JSON ファイルであることを確認 2. ファイル内容が完全であるか確認 3. テキストエディタで開いてフォーマットを確認 ### 使用量統計のデータが空 **チェックリスト**: - [ ] プロキシサービスが実行中か - [ ] アプリケーション接管が有効か - [ ] ログ記録が有効か - [ ] プロキシ経由でリクエストがあったか ## その他の問題 ### トレイアイコンが表示されない **macOS**: - システム設定のメニューバーアイコン設定を確認 **Windows**: - タスクバーの設定で、CC Switch のアイコンが非表示になっていないか確認 **Linux**: - システムトレイのサポート(例:`libappindicator`)がインストールされている必要あり ### インターフェースの表示が異常 **解決方法**: 1. テーマを切り替えてみる(ライト/ダーク) 2. アプリを再起動 3. `~/.cc-switch/settings.json` を削除して設定をリセット ### 更新に失敗する **解決方法**: 1. ネットワーク接続を確認 2. 最新版を手動でダウンロードしてインストール 3. Homebrew を使用する場合:`brew upgrade --cask cc-switch` ## ヘルプの入手 ### Issue の提出 上記の方法で問題が解決しない場合: 1. [GitHub Issues](https://github.com/farion1231/cc-switch/issues) にアクセス 2. 類似の問題がないか検索 3. なければ新しい Issue を作成 4. 以下の情報を提供: - オペレーティングシステムとバージョン - CC Switch のバージョン - 問題の説明と再現手順 - エラーメッセージ(ある場合) ### ログファイル Issue を提出する際にログファイルを添付できます: - macOS/Linux:`~/.cc-switch/logs/` - Windows:`%APPDATA%\cc-switch\logs\` ================================================ FILE: docs/user-manual/ja/5-faq/5.3-deeplink.md ================================================ # 5.3 ディープリンクプロトコル ## 機能説明 CC Switch は `ccswitch://` ディープリンクプロトコルをサポートしており、リンクからワンクリックで設定をインポートできます。 **使用シーン**: - チーム内での設定共有 - チュートリアルでのワンクリック設定 - デバイス間の素早い同期 ## オンライン生成ツール CC Switch はオンラインのディープリンク生成ツールを提供しています: **アクセス先**:[https://farion1231.github.io/cc-switch/deplink.html](https://farion1231.github.io/cc-switch/deplink.html) ### 使用方法 1. 上記の Web ページを開く 2. インポートタイプを選択(プロバイダー/MCP/Prompt) 3. 設定情報を入力 4. 「リンクを生成」をクリック 5. 生成されたディープリンクをコピー 6. 他の人に共有するか、別のデバイスで使用 ## プロトコル形式 ### V1 プロトコル URL パラメータ形式で、読みやすく生成しやすい形式です: ``` ccswitch://v1/import?resource={type}&app={app}&name={name}&... ``` **共通パラメータ**: | パラメータ | 必須 | 説明 | |------|------|------| | `resource` | はい | リソースタイプ:`provider` / `mcp` / `prompt` / `skill` | | `app` | はい | アプリタイプ:`claude` / `codex` / `gemini` / `opencode` / `openclaw` | | `name` | はい | 名前 | **プロバイダーパラメータ**(resource=provider): | パラメータ | 必須 | 説明 | |------|------|------| | `endpoint` | いいえ | API エンドポイントアドレス(カンマ区切りで複数 URL 対応) | | `apiKey` | いいえ | API キー | | `homepage` | いいえ | プロバイダー公式サイト | | `model` | いいえ | デフォルトモデル | | `haikuModel` | いいえ | Haiku モデル(Claude のみ) | | `sonnetModel` | いいえ | Sonnet モデル(Claude のみ) | | `opusModel` | いいえ | Opus モデル(Claude のみ) | | `notes` | いいえ | メモ | | `icon` | いいえ | アイコン | | `config` | いいえ | Base64 エンコードされた設定内容 | | `configFormat` | いいえ | 設定形式:`json` / `toml` | | `configUrl` | いいえ | リモート設定 URL | | `enabled` | いいえ | 有効にするかどうか(ブール値) | | `usageScript` | いいえ | 使用量クエリスクリプト | | `usageEnabled` | いいえ | 使用量クエリを有効にするか(デフォルト true) | | `usageApiKey` | いいえ | 使用量クエリ専用 API Key | | `usageBaseUrl` | いいえ | 使用量クエリ専用アドレス | | `usageAccessToken` | いいえ | 使用量クエリアクセストークン | | `usageUserId` | いいえ | 使用量クエリユーザー ID | | `usageAutoInterval` | いいえ | 自動クエリ間隔(分) | **プロンプトパラメータ**(resource=prompt): | パラメータ | 必須 | 説明 | |------|------|------| | `content` | はい | プロンプト内容 | | `description` | いいえ | 説明 | | `enabled` | いいえ | 有効にするかどうか(ブール値) | **MCP パラメータ**(resource=mcp): | パラメータ | 必須 | 説明 | |------|------|------| | `apps` | はい | アプリリスト(カンマ区切り、例:`claude,codex,gemini,opencode`) | | `config` | はい | MCP サーバー設定(JSON 形式) | | `enabled` | いいえ | 有効にするかどうか(ブール値) | **Skill パラメータ**(resource=skill): | パラメータ | 必須 | 説明 | |------|------|------| | `repo` | はい | リポジトリ(形式:`owner/name`) | | `directory` | いいえ | ディレクトリパス | | `branch` | いいえ | Git ブランチ | **例**: ``` ccswitch://v1/import?resource=provider&app=claude&name=My%20Provider&endpoint=https%3A%2F%2Fapi.example.com&apiKey=sk-xxx ``` ## インポートタイプの例 ### プロバイダーのインポート ``` ccswitch://v1/import?resource=provider&app=claude&name=My%20Provider&endpoint=https%3A%2F%2Fapi.example.com&apiKey=sk-xxx ``` ### MCP サーバーのインポート ``` ccswitch://v1/import?resource=mcp&apps=claude,codex&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22mcp-server-fetch%22%5D%7D&name=mcp-fetch ``` ### Prompt プリセットのインポート ``` ccswitch://v1/import?resource=prompt&app=claude&name=%E4%BB%A3%E7%A0%81%E5%AE%A1%E6%9F%A5&content=%23%20%E8%A7%92%E8%89%B2%0A%E4%BD%A0%E6%98%AF%E4%B8%80%E4%B8%AA%E4%B8%93%E4%B8%9A%E7%9A%84%E4%BB%A3%E7%A0%81%E5%AE%A1%E6%9F%A5%E4%B8%93%E5%AE%B6 ``` ### Skill のインポート ``` ccswitch://v1/import?resource=skill&name=my-skill&repo=owner/repo&directory=skills/my-skill&branch=main ``` ## ディープリンクの生成 ### 手動生成 1. パラメータを準備 2. V1 プロトコル形式で URL を組み立て 3. 特殊文字を URL エンコード **例**: ```javascript const params = new URLSearchParams({ resource: 'provider', app: 'claude', name: 'My Provider', endpoint: 'https://api.example.com', apiKey: 'sk-xxx' }); const url = `ccswitch://v1/import?${params.toString()}`; ``` ### オンラインツール CC Switch 公式のオンラインディープリンク生成ツールを使用するとより便利です。 ## ディープリンクの使用 ### リンクのクリック ブラウザや他のアプリでディープリンクをクリック: 1. システムが CC Switch を開くかどうかを確認 2. 確認後、CC Switch が起動 3. インポート確認ダイアログを表示 4. インポートを確認 ### インポートの確認 インポート前に確認ダイアログが表示され、以下が含まれます: - インポートタイプ - 設定のプレビュー - 確認/キャンセルボタン **セキュリティ上の注意**:信頼できるソースからの設定のみインポートしてください。 ## プロトコルの登録 ### 自動登録 CC Switch のインストール時に `ccswitch://` プロトコルが自動登録されます。 ### 手動登録 プロトコルが正しく登録されていない場合: **macOS**: アプリを再インストールするか、以下を実行: ```bash /usr/bin/open -a "CC Switch" --args --register-protocol ``` **Windows**: アプリを再インストールするか、レジストリを確認: ``` HKEY_CLASSES_ROOT\ccswitch ``` **Linux**: `.desktop` ファイルの `MimeType` 設定を確認。 ## セキュリティに関する考慮事項 ### 機密情報 ディープリンクには機密情報(API Key など)が含まれる場合があります: - API Key を含むリンクを公開の場で共有しない - 共有前に機密情報を削除または置換 - 安全なチャネルでリンクを送信 ### ソースの確認 インポート前に CC Switch は以下を実行します: 1. データ形式の検証 2. 設定のプレビュー表示 3. ユーザーの確認を要求 ### 悪意のあるリンクからの防護 CC Switch は以下を確認します: - データ形式が正当か - 必須フィールドが揃っているか - 設定値が妥当な範囲内か ## サンプルリンク ### 例:Claude プロバイダーのインポート ``` ccswitch://v1/import?resource=provider&app=claude&name=Test%20Provider&apiKey=sk-xxx&endpoint=https%3A%2F%2Fapi.example.com ``` ### 例:MCP サーバーのインポート ``` ccswitch://v1/import?resource=mcp&name=mcp-fetch&apps=claude,codex,gemini&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22mcp-server-fetch%22%5D%7D ``` ## トラブルシューティング ### リンクが開けない **確認事項**: 1. CC Switch がインストールされているか 2. プロトコルが正しく登録されているか 3. リンクの形式が正しいか ### インポートに失敗する **考えられる原因**: - Base64 エンコードのエラー - JSON 形式のエラー - 必須フィールドの不足 **解決方法**: 1. 元の JSON 形式を確認 2. Base64 エンコードをやり直す 3. すべての必須フィールドが存在することを確認 ================================================ FILE: docs/user-manual/ja/5-faq/5.4-env-conflict.md ================================================ # 5.4 環境変数の競合 ## 機能説明 CC Switch は、システム環境変数とアプリ設定の競合を自動的に検出し、設定が意図せず上書きされるのを防ぎます。 **検出される環境変数**: - `ANTHROPIC_API_KEY` - Claude API キー - `ANTHROPIC_BASE_URL` - Claude API エンドポイント - `OPENAI_API_KEY` - OpenAI API キー - `GEMINI_API_KEY` - Gemini API キー - その他の関連環境変数 ## 競合の警告 競合が検出されると、画面の上部に黄色い警告バナーが表示されます: ``` ⚠️ 環境変数の競合を検出 X 個の環境変数が CC Switch の設定と競合する可能性があります [展開] [閉じる] ``` ## 競合の詳細を確認 「展開」ボタンをクリックして詳細情報を表示します: | フィールド | 説明 | |------|------| | 変数名 | 環境変数名 | | 変数値 | 現在設定されている値 | | ソース | 変数の出処 | ### ソースの種類 | ソース | 説明 | |------|------| | ユーザーレジストリ | Windows のユーザーレベル環境変数 | | システムレジストリ | Windows のシステムレベル環境変数 | | Shell 設定 | macOS/Linux の Shell 設定ファイル | | システム環境 | システムレベルの環境変数 | ## 競合の処理 ### 削除する変数の選択 1. 削除する環境変数にチェックを入れる 2. または「すべて選択」ですべての競合変数を選択 ### 変数の削除 1. 「選択を削除」ボタンをクリック 2. 削除操作を確認 3. CC Switch が自動的にバックアップしてから、選択した変数を削除 ### 自動バックアップ 削除前に自動的にバックアップが作成されます: - バックアップの場所:`~/.cc-switch/env-backups/` - バックアップ形式:JSON ファイル - 変数名、値、ソースなどの情報を含む ## 警告を無視する 競合が使用に影響しないことが確認できる場合: 1. 警告バナーの右側にある「閉じる」ボタンをクリック 2. 警告が一時的に非表示になる 3. 次回の起動時に再度検出が行われる ## 手動での処理 CC Switch 経由で削除したくない場合は、手動で処理できます: ### Windows 1. 「システムのプロパティ → 詳細 → 環境変数」を開く 2. ユーザー変数またはシステム変数で競合する変数を見つける 3. 変数を削除または変更 ### macOS / Linux 1. Shell 設定ファイル(例:`~/.zshrc`、`~/.bashrc`)を編集 2. 関連する `export` 文を削除またはコメントアウト 3. 設定を再読み込み:`source ~/.zshrc` ## なぜ競合が発生するのか 環境変数の優先度は通常、設定ファイルよりも高く、以下の問題を引き起こす可能性があります: - CC Switch で設定したプロバイダー設定が上書きされる - API リクエストが間違ったエンドポイントに送信される - 間違った API キーが使用される ## ベストプラクティス 1. **CC Switch で設定を管理**:システム環境変数に API キーを設定しないようにする 2. **定期的に確認**:競合の警告に注意し、速やかに対処 3. **重要な変数のバックアップ**:削除前にバックアップを確認 ## 削除した変数の復元 環境変数を誤って削除した場合: 1. バックアップファイルを見つける:`~/.cc-switch/env-backups/` 2. 対応する JSON ファイルを開く 3. システム環境に手動で変数を復元 ================================================ FILE: docs/user-manual/ja/README.md ================================================ # CC Switch ユーザーマニュアル > Claude Code / Codex / Gemini CLI / OpenCode / OpenClaw オールインワンアシスタント ## 目次構成 ``` CC Switch ユーザーマニュアル │ ├── 1. はじめに │ ├── 1.1 ソフトウェア紹介 │ ├── 1.2 インストールガイド │ ├── 1.3 インターフェース概要 │ ├── 1.4 クイックスタート │ └── 1.5 個人設定 │ ├── 2. プロバイダー管理 │ ├── 2.1 プロバイダーの追加 │ ├── 2.2 プロバイダーの切り替え │ ├── 2.3 プロバイダーの編集 │ ├── 2.4 並べ替えと複製 │ └── 2.5 使用量クエリ │ ├── 3. 拡張機能 │ ├── 3.1 MCP サーバー管理 │ ├── 3.2 Prompts プロンプト管理 │ └── 3.3 Skills スキル管理 │ ├── 4. プロキシと高可用性 │ ├── 4.1 プロキシサービス │ ├── 4.2 アプリケーション接管 │ ├── 4.3 フェイルオーバー │ ├── 4.4 使用量統計 │ └── 4.5 モデルテスト │ └── 5. よくある質問 ├── 5.1 設定ファイルの説明 ├── 5.2 FAQ ├── 5.3 ディープリンクプロトコル └── 5.4 環境変数の競合 ``` ## ファイル一覧 ### 1. はじめに | ファイル | 内容 | |------|------| | [1.1-introduction.md](./1-getting-started/1.1-introduction.md) | ソフトウェア紹介、主要機能、対応プラットフォーム | | [1.2-installation.md](./1-getting-started/1.2-installation.md) | Windows/macOS/Linux インストールガイド | | [1.3-interface.md](./1-getting-started/1.3-interface.md) | インターフェースレイアウト、ナビゲーションバー、プロバイダーカードの説明 | | [1.4-quickstart.md](./1-getting-started/1.4-quickstart.md) | 5 分でできるクイックスタートチュートリアル | | [1.5-settings.md](./1-getting-started/1.5-settings.md) | 言語、テーマ、ディレクトリ、クラウド同期の設定 | ### 2. プロバイダー管理 | ファイル | 内容 | |------|------| | [2.1-add.md](./2-providers/2.1-add.md) | プリセットの使用、カスタム設定、統一プロバイダー | | [2.2-switch.md](./2-providers/2.2-switch.md) | メイン画面での切り替え、トレイでの切り替え、反映方法 | | [2.3-edit.md](./2-providers/2.3-edit.md) | 設定の編集、API Key の変更、バックフィル機能 | | [2.4-sort-duplicate.md](./2-providers/2.4-sort-duplicate.md) | ドラッグで並べ替え、プロバイダーの複製、削除 | | [2.5-usage-query.md](./2-providers/2.5-usage-query.md) | 使用量クエリ、残額表示、複数プラン表示 | ### 3. 拡張機能 | ファイル | 内容 | |------|------| | [3.1-mcp.md](./3-extensions/3.1-mcp.md) | MCP プロトコル、サーバーの追加、アプリバインド | | [3.2-prompts.md](./3-extensions/3.2-prompts.md) | プリセットの作成、有効化の切り替え、スマートバックフィル | | [3.3-skills.md](./3-extensions/3.3-skills.md) | スキルの発見、インストール・アンインストール、リポジトリ管理 | ### 4. プロキシと高可用性 | ファイル | 内容 | |------|------| | [4.1-service.md](./4-proxy/4.1-service.md) | プロキシの起動、設定項目、実行状態 | | [4.2-takeover.md](./4-proxy/4.2-takeover.md) | アプリケーション接管、設定変更、ステータス表示 | | [4.3-failover.md](./4-proxy/4.3-failover.md) | フェイルオーバーキュー、サーキットブレーカー、ヘルスステータス | | [4.4-usage.md](./4-proxy/4.4-usage.md) | 使用量統計、トレンドグラフ、料金設定 | | [4.5-model-test.md](./4-proxy/4.5-model-test.md) | モデルテスト、ヘルスチェック、レイテンシテスト | ### 5. よくある質問 | ファイル | 内容 | |------|------| | [5.1-config-files.md](./5-faq/5.1-config-files.md) | CC Switch のストレージ、CLI 設定ファイル形式 | | [5.2-questions.md](./5-faq/5.2-questions.md) | よくある質問と回答 | | [5.3-deeplink.md](./5-faq/5.3-deeplink.md) | ディープリンクプロトコル、生成と使用方法 | | [5.4-env-conflict.md](./5-faq/5.4-env-conflict.md) | 環境変数の競合検出と対処 | ## クイックリンク - **初めての方**:[1.1 ソフトウェア紹介](./1-getting-started/1.1-introduction.md) からお読みください - **インストールの問題**:[1.2 インストールガイド](./1-getting-started/1.2-installation.md) をご確認ください - **プロバイダーの設定**:[2.1 プロバイダーの追加](./2-providers/2.1-add.md) をご確認ください - **プロキシの使用**:[4.1 プロキシサービス](./4-proxy/4.1-service.md) をご確認ください - **お困りの方**:[5.2 FAQ](./5-faq/5.2-questions.md) をご確認ください ## バージョン情報 - ドキュメントバージョン:v3.12.0 - 最終更新:2026-03-09 - CC Switch v3.12.0+ 対応 ## コントリビュート Issue や PR でドキュメントの改善にご協力ください: - [GitHub Issues](https://github.com/farion1231/cc-switch/issues) - [GitHub Repository](https://github.com/farion1231/cc-switch) ================================================ FILE: docs/user-manual/zh/1-getting-started/1.1-introduction.md ================================================ # 1.1 软件介绍 ## 什么是 CC Switch CC Switch 是一款跨平台桌面应用,专为使用 AI 编程工具的开发者设计。它帮助你统一管理 **Claude Code**、**Codex**、**Gemini CLI**、**OpenCode** 和 **OpenClaw** 五大 AI 编程工具的配置。 ## 解决什么问题 在日常开发中,你可能会遇到这些痛点: - **多供应商切换麻烦**:使用不同的 API 供应商(官方、中转服务商),需要手动修改配置文件 - **配置分散难管理**:Claude、Codex、Gemini、OpenCode、OpenClaw 各有独立的配置文件,格式不同 - **无法监控用量**:不知道 API 调用了多少次,花了多少钱 - **服务不稳定**:单一供应商出问题时,整个工作流中断 CC Switch 通过统一的界面解决这些问题。 ## 核心功能 ### 供应商管理 - 一键切换多个 API 供应商配置 - 支持预设模板,快速添加常用供应商 - 统一供应商功能,跨应用共享配置 - 用量查询与余额显示 - 端点速度测试 ### 扩展功能 - **MCP 服务器**:管理 Model Context Protocol 服务器,扩展 AI 能力 - **Prompts**:管理系统提示词预设,快速切换不同场景 - **Skills**:安装和管理技能扩展 ### 代理与高可用 - 本地代理服务,记录请求日志和用量统计 - 自动故障转移,主供应商失败时自动切换备用 - 熔断器机制,防止频繁重试失败的供应商 - 详细的 Token 用量追踪与成本估算 ## 支持的应用 | 应用 | 说明 | |------|------| | **Claude Code** | Anthropic 官方的 AI 编程助手 | | **Codex** | OpenAI 的代码生成工具 | | **Gemini CLI** | Google 的 AI 命令行工具 | | **OpenCode** | 开源 AI 编程终端工具 | | **OpenClaw** | 开源 AI 编程助手(多供应商网关) | ## 支持的平台 - **Windows** 10 及以上 - **macOS** 10.15 (Catalina) 及以上 - **Linux** Ubuntu 22.04+ / Debian 11+ / Fedora 34+ ## 技术架构 CC Switch 使用现代化的技术栈构建: - **前端**:React 18 + TypeScript + Tailwind CSS - **后端**:Tauri 2 + Rust - **数据存储**:SQLite(供应商、MCP、Prompts)+ JSON(设备设置) 这种架构确保了: - 跨平台一致的体验 - 原生级别的性能 - 安全的本地数据存储 ================================================ FILE: docs/user-manual/zh/1-getting-started/1.2-installation.md ================================================ # 1.2 安装指南 ## 前置要求 ### 安装 Node.js CC Switch 管理的 CLI 工具(Claude Code、Codex、Gemini CLI)需要 Node.js 环境。 **推荐版本**:Node.js 18 LTS 或更高版本 #### Windows 1. 访问 [Node.js 官网](https://nodejs.org/) 2. 下载 LTS 版本安装包 3. 运行安装程序,按提示完成安装 4. 验证安装: ```bash node --version npm --version ``` #### macOS ```bash # 使用 Homebrew 安装 brew install node # 或使用 nvm(推荐) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash nvm install --lts ``` #### Linux ```bash # Ubuntu/Debian curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - sudo apt-get install -y nodejs # 或使用 nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash nvm install --lts ``` ### 安装 CLI 工具 #### Claude Code **方式一:Homebrew(macOS 推荐)** ```bash brew install claude-code ``` **方式二:npm** ```bash npm install -g @anthropic-ai/claude-code # 国内用户如下载慢,使用镜像源 npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com ``` #### Codex **方式一:Homebrew(macOS 推荐)** ```bash brew install codex ``` **方式二:npm** ```bash npm install -g @openai/codex # 国内用户如下载慢,使用镜像源 npm install -g @openai/codex --registry=https://registry.npmmirror.com ``` #### Gemini CLI **方式一:Homebrew(macOS 推荐)** ```bash brew install gemini-cli ``` **方式二:npm** ```bash npm install -g @google/gemini-cli # 国内用户如下载慢,使用镜像源 npm install -g @google/gemini-cli --registry=https://registry.npmmirror.com ``` > 💡 **提示**:如果经常遇到下载慢的问题,可以全局设置镜像源: > ```bash > npm config set registry https://registry.npmmirror.com > ``` --- ## Windows ### 安装包方式 1. 访问 [Releases 页面](https://github.com/farion1231/cc-switch/releases) 2. 下载 `CC-Switch-v{版本号}-Windows.msi` 3. 双击运行安装程序 4. 按提示完成安装 ### 绿色版(免安装) 1. 下载 `CC-Switch-v{版本号}-Windows-Portable.zip` 2. 解压到任意目录 3. 运行 `CC-Switch.exe` ## macOS ### 方式一:Homebrew(推荐) ```bash # 添加 tap brew tap farion1231/ccswitch # 安装 brew install --cask cc-switch ``` 更新到最新版本: ```bash brew upgrade --cask cc-switch ``` ### 方式二:手动下载 1. 下载 `CC-Switch-v{版本号}-macOS.zip` 2. 解压得到 `CC Switch.app` 3. 拖动到「应用程序」文件夹 ### 首次打开提示 由于开发者没有 Apple 开发者账号,首次打开可能出现「未知开发者」警告: **推荐解决方法**: 打开终端执行以下命令: ```bash sudo xattr -dr com.apple.quarantine /Applications/CC\ Switch.app/ ``` **备选解决方法(通过系统设置)**: 1. 关闭警告弹窗 2. 打开「系统设置」→「隐私与安全性」 3. 找到 CC Switch 相关提示,点击「仍要打开」 4. 再次打开应用即可正常使用 ## Linux ### ArchLinux 使用 AUR 助手安装: ```bash # 使用 paru paru -S cc-switch-bin # 或使用 yay yay -S cc-switch-bin ``` ### Debian / Ubuntu 1. 下载 `CC-Switch-v{版本号}-Linux.deb` 2. 安装: ```bash sudo dpkg -i CC-Switch-v{版本号}-Linux.deb # 如果有依赖问题 sudo apt-get install -f ``` ### AppImage(通用) 1. 下载 `CC-Switch-v{版本号}-Linux.AppImage` 2. 添加执行权限: ```bash chmod +x CC-Switch-v{版本号}-Linux.AppImage ``` 3. 运行: ```bash ./CC-Switch-v{版本号}-Linux.AppImage ``` ## 验证安装 安装完成后,启动 CC Switch: 1. 应用窗口正常显示 2. 系统托盘出现 CC Switch 图标 3. 能够切换 Claude / Codex / Gemini 三个应用 ## 自动更新 CC Switch 内置自动更新功能: - 启动时自动检查更新 - 有新版本时在界面显示更新提示 - 点击即可下载并安装 也可以在「设置 → 关于」中手动检查更新。 ## 卸载 ### Windows - 通过「设置 → 应用」卸载 - 或运行安装目录下的卸载程序 ### macOS - 将 `CC Switch.app` 移到废纸篓 - 可选:删除配置目录 `~/.cc-switch/` ### Linux ```bash # Debian/Ubuntu sudo apt remove cc-switch # ArchLinux paru -R cc-switch-bin ``` ================================================ FILE: docs/user-manual/zh/1-getting-started/1.3-interface.md ================================================ # 1.3 界面概览 ## 主界面布局 ![image-20260108001629138](../../assets/image-20260108001629138.png) ## 顶部导航栏 | 序号 | 元素 | 功能说明 | |------|------|----------| | ① | Logo | 点击访问 GitHub 项目页 | | ② | 设置按钮 | 打开设置页面(快捷键 `Cmd/Ctrl + ,`) | | ③ | 代理开关 | 启动/停止本地代理服务 | | ④ | 应用切换器 | 切换 Claude / Codex / Gemini / OpenCode / OpenClaw | | ⑤ | 功能区 | Skills / Prompts / MCP 入口 | | ⑥ | 添加按钮 | 添加新供应商 | ### 应用切换器 点击下拉菜单切换当前管理的应用: - **Claude** - 管理 Claude Code 配置 - **Codex** - 管理 Codex 配置 - **Gemini** - 管理 Gemini CLI 配置 - **OpenCode** - 管理 OpenCode 配置 - **OpenClaw** - 管理 OpenClaw 配置 切换后,供应商列表会显示对应应用的配置。 ### 功能区按钮 | 按钮 | 功能 | 可见条件 | |------|------|----------| | Skills | 技能扩展管理 | 始终可见 | | Prompts | 系统提示词管理 | 始终可见 | | MCP | MCP 服务器管理 | 始终可见 | ## 供应商卡片 每个供应商以卡片形式展示,从左到右依次包含以下元素: ### 卡片元素(从左到右) | 序号 | 元素 | 图标 | 功能说明 | |------|------|------|----------| | ① | 拖拽手柄 | ≡ | 按住上下拖动调整供应商顺序 | | ② | 供应商图标 | 🔷 | 显示供应商品牌图标,可自定义颜色 | | ③ | 供应商信息 | - | 名称、备注/端点地址(可点击打开官网) | | ④ | 用量信息 | - | 显示剩余额度,多套餐时显示套餐数量 | | ⑤ | 启用按钮 | ▶ | 切换为当前使用的供应商 | | ⑥ | 编辑按钮 | ✏️ | 编辑供应商配置 | | ⑦ | 复制按钮 | 📋 | 复制供应商(创建副本) | | ⑧ | 测速按钮 | 🧪 | 测试模型可用性和响应速度 | | ⑨ | 用量查询 | 📊 | 配置用量查询脚本 | | ⑩ | 删除按钮 | 🗑️ | 删除供应商(当前启用时禁用) | > 💡 **提示**:操作按钮区域(⑤-⑩)在鼠标悬停时显示,平时隐藏以保持界面简洁。 ### 按钮详细说明 | 按钮 | 状态变化 | 说明 | |------|----------|------| | **启用** | 已启用时显示 ✓ 并禁用 | 故障转移模式下变为「加入/已加入」 | | **编辑** | 始终可用 | 打开编辑面板修改配置 | | **复制** | 始终可用 | 创建供应商副本,名称后缀 `copy` | | **测速** | 测试中显示加载动画 | 仅代理服务运行时可用 | | **用量查询** | 始终可用 | 配置自定义用量查询脚本 | | **删除** | 当前启用时半透明禁用 | 需先切换到其他供应商才能删除 | ### 卡片状态 | 状态 | 边框颜色 | 说明 | |------|----------|------| | **当前启用** | 🔵 蓝色边框 | 普通模式下当前使用的供应商 | | **代理活跃** | 🟢 绿色边框 | 代理接管模式下实际使用的供应商 | | **普通状态** | 默认边框 | 未启用的供应商 | | **故障转移中** | 显示优先级徽章 | 如 P1、P2 表示故障转移优先级 | ### 健康状态徽章 在代理模式下,加入故障转移队列的供应商会显示健康状态: | 徽章 | 颜色 | 说明 | |------|------|------| | 健康 | 🟢 绿色 | 连续失败 0 次 | | 警告 | 🟡 黄色 | 连续失败 1-2 次 | | 不健康 | 🔴 红色 | 连续失败 ≥3 次,可能触发熔断 | ## 系统托盘 CC Switch 在系统托盘显示图标,提供快速操作入口。 ### 托盘菜单结构 ![image-20260108002153668](../../assets/image-20260108002153668.png) ### 菜单功能 | 菜单项 | 功能 | |--------|------| | 打开主界面 | 显示主窗口并聚焦 | | 应用分组 | 按 Claude/Codex/Gemini/OpenCode/OpenClaw 分组显示供应商 | | 供应商列表 | 点击切换,当前启用的显示勾选标记 | | 退出 | 完全退出应用 | ### 多语言支持 托盘菜单支持三种语言,根据设置自动切换: | 语言 | 打开主界面 | 退出 | |------|-----------|------| | 中文 | 打开主界面 | 退出 | | English | Open main window | Quit | | 日本語 | メインウィンドウを開く | 終了 | ### 使用场景 托盘切换供应商无需打开主界面,适合: - 频繁切换供应商 - 主窗口最小化时快速操作 - 后台运行时管理配置 ## 设置页面 设置页面分为多个 Tab: ### 通用 Tab - 语言设置(中文/English/日本語) - 主题设置(跟随系统/浅色/深色) - 窗口行为(开机自启、关闭行为) ### 高级 Tab - 配置目录设置 - 代理服务配置 - 故障转移设置 - 定价配置 - 数据导入导出 ### 用量 Tab - 请求统计概览 - 趋势图表 - 请求日志 - 供应商/模型统计 ### 关于 Tab - 版本信息 - 更新检查 - 开源协议 ## 快捷键 | 快捷键 | 功能 | |--------|------| | `Cmd/Ctrl + ,` | 打开设置 | | `Cmd/Ctrl + F` | 搜索供应商 | | `Esc` | 关闭弹窗/搜索 | ## 搜索功能 按 `Cmd/Ctrl + F` 打开搜索框: - 支持按名称、备注、URL 搜索 - 实时过滤供应商列表 - 按 `Esc` 关闭搜索 ================================================ FILE: docs/user-manual/zh/1-getting-started/1.4-quickstart.md ================================================ # 1.4 快速上手 本节帮助你在 5 分钟内完成首次配置。 ## 第一步:添加供应商 1. 点击主界面右上角的 **+** 按钮 2. 在「预设」下拉框中选择你的供应商 - 常用预设:智谱 GLM、MiniMax、DeepSeek、Kimi、PackyCode - 或选择「自定义」手动配置 3. 填写 **API Key** 4. 点击「添加」 ![image-20260108002807657](../../assets/image-20260108002807657.png) > 💡 **提示**:预设会自动填充端点地址,你只需要填写 API Key。 ## 第二步:切换供应商 添加完成后,供应商会出现在列表中。 **方式一:主界面切换** - 点击供应商卡片的「启用」按钮 **方式二:托盘快速切换** - 右键系统托盘图标 - 直接点击供应商名称 ## 第三步:生效方式 切换供应商后,各 CLI 工具的生效方式不同: | 应用 | 生效方式 | |------|----------| | Claude Code | ✅ 即时生效(支持热重载) | | Codex | 需关闭并重新打开终端 | | Gemini | ✅ 即时生效(每次请求重新读取配置) | ### Claude Code 首次安装提示 如果 Claude Code 首次启动时提示需要**登录**或显示初始化引导,请在 CC Switch 中开启「跳过 Claude Code 初次安装确认」选项: 1. 打开 CC Switch「设置 → 通用」 2. 开启「跳过 Claude Code 初次安装确认」开关 3. 重新启动 Claude Code ![image-20260108002626389](../../assets/image-20260108002626389.png) > ⚠️ **注意**:此选项会写入 `~/.claude/settings.json` 的 `skipIntroduction` 字段,跳过官方的新手引导流程。 ## 验证配置 重启后,启动对应的 CLI 工具并输入简单的问题进行测试: ```bash # Claude Code - 启动后输入测试问题 claude > 你好,请简单介绍一下自己 # Codex - 启动后输入测试问题 codex > 你好,请简单介绍一下自己 # Gemini - 启动后输入测试问题 gemini > 你好,请简单介绍一下自己 ``` 如果 AI 能正常回复,说明配置成功。 ## 下一步 恭喜!你已经完成了基础配置。接下来可以: - [添加更多供应商](../2-providers/2.1-add.md) - 配置多个供应商方便切换 - [配置 MCP 服务器](../3-extensions/3.1-mcp.md) - 扩展 AI 工具的能力 - [设置系统提示词](../3-extensions/3.2-prompts.md) - 自定义 AI 的行为 - [开启代理服务](../4-proxy/4.1-service.md) - 监控用量和自动故障转移 ## 常见问题 ### 切换后不生效? 确保重启了终端或 CLI 工具。配置文件在切换时已经更新,但运行中的程序不会自动重新加载。 ### 找不到预设? 如果你的供应商不在预设列表中,选择「自定义」手动配置。参考 [添加供应商](../2-providers/2.1-add.md) 了解配置格式。 ### 如何恢复官方登录? 选择「官方登录」预设(Claude/Codex)或「Google 官方」预设(Gemini),重启客户端后按登录流程操作。 ================================================ FILE: docs/user-manual/zh/1-getting-started/1.5-settings.md ================================================ # 1.5 个性化配置 本节介绍如何根据个人偏好配置 CC Switch。 ## 打开设置 - 点击左上角 **⚙️** 按钮 - 或使用快捷键 `Cmd/Ctrl + ,` ## 语言设置 CC Switch 支持三种语言: | 语言 | 说明 | | -------- | -------- | | 简体中文 | 默认语言 | | English | 英文界面 | | 日本語 | 日文界面 | 切换语言后立即生效,无需重启。 ## 主题设置 | 选项 | 说明 | | -------- | --------------------------- | | 跟随系统 | 自动匹配系统的深色/浅色模式 | | 浅色 | 始终使用浅色主题 | | 深色 | 始终使用深色主题 | ## 窗口行为 ### 开机自启 开启后,系统启动时自动运行 CC Switch。 - **Windows**:通过注册表实现 - **macOS**:通过 LaunchAgent 实现 - **Linux**:通过 XDG autostart 实现 ### 关闭行为 | 选项 | 说明 | | ------------ | ---------------------------- | | 最小化到托盘 | 点击关闭按钮时隐藏到系统托盘 | | 直接退出 | 点击关闭按钮时完全退出应用 | 推荐使用「最小化到托盘」,方便通过托盘快速切换供应商。 ### Claude 插件集成 开启后,CC Switch 在切换供应商时会自动同步配置到 VS Code 中的 Claude Code 插件(写入 `~/.claude/config.json` 的 `primaryApiKey`)。 > 💡 **使用场景**:如果你同时使用 Claude Code CLI 和 VS Code 插件,开启此选项可以保持两者配置一致。 ### 跳过 Claude 引导 开启后,跳过 Claude Code 的新手引导流程,适合已熟悉 Claude Code 的用户。 > ⚠️ **注意**:此选项会写入 `~/.claude/settings.json` 的 `skipIntroduction` 字段。 ### 应用可见性 选择在应用切换器中显示哪些应用。每个应用可以独立开关,但至少保留一个。 可配置的应用:Claude、Codex、Gemini、OpenCode、OpenClaw。 > 💡 **使用场景**:如果你只使用 Claude Code 和 Codex CLI,可以隐藏其他应用,保持界面简洁。 ### Skills 同步方式 设置技能安装到各应用目录时的同步方式: | 方式 | 说明 | | ----------------- | ---------------------------------------------------- | | 软链接(Symlink) | 创建符号链接指向技能源文件,占用空间小,更新实时同步 | | 复制(Copy) | 将技能文件完整复制到目标目录 | > 💡 **推荐**:默认使用软链接方式。如果遇到权限问题,可切换为复制方式。 ### 终端设置 选择 CC Switch 打开终端时使用的终端应用程序。 支持的终端(按平台): | 平台 | 终端选项 | | ------- | ------------------------------------------------------------------ | | macOS | Terminal、iTerm2、Alacritty、Kitty、Ghostty、WezTerm | | Windows | CMD、PowerShell、Windows Terminal | | Linux | GNOME Terminal、Konsole、Xfce4 Terminal、Alacritty、Kitty、Ghostty | ## 目录配置 ### 应用配置目录 CC Switch 自身数据的存储位置,默认为 `~/.cc-switch/`。 ### CLI 工具目录 可以自定义各 CLI 工具的配置目录: | 配置 | 默认值 | 说明 | | ------------- | -------------- | -------------------- | | Claude 目录 | `~/.claude/` | Claude Code 配置目录 | | Codex 目录 | `~/.codex/` | Codex 配置目录 | | Gemini 目录 | `~/.gemini/` | Gemini CLI 配置目录 | | OpenCode 目录 | `~/.opencode/` | OpenCode 配置目录 | | OpenClaw 目录 | `~/.openclaw/` | OpenClaw 配置目录 | > ⚠️ **注意**:修改目录后需要重启应用,且对应的 CLI 工具也需要配置相同的目录。 ## 数据管理 ### 导出配置 点击「导出」按钮,保存包含以下内容的备份文件: - 所有供应商配置 - MCP 服务器配置 - Prompts 预设 - 应用设置 备份文件格式为 JSON,可以用文本编辑器查看。 ### 导入配置 1. 点击「选择文件」 2. 选择之前导出的备份文件 3. 点击「导入」 4. 确认覆盖现有配置 > ⚠️ **注意**:导入会覆盖现有配置,建议先导出当前配置作为备份。 ## 代理设置 设置 → 代理 Tab 代理 Tab 集中管理所有代理相关功能: ### 本地代理 启动/停止本地代理服务,配置监听地址和端口。详见 [4.1 代理服务](../4-proxy/4.1-service.md)。 ### 故障转移 按应用(Claude/Codex/Gemini)配置故障转移队列和自动切换策略。详见 [4.3 故障转移](../4-proxy/4.3-failover.md)。 ### 定价矫正器 配置模型定价矫正规则,用于代理计费统计的校准。 ### 全局出站代理 配置 CC Switch 的出站 HTTP/HTTPS 代理,适用于需要通过代理访问外部 API 的场景。 ## 高级设置 设置 → 高级 Tab ### 配置目录 自定义各应用的配置文件目录。详见下方「目录配置」章节。 ### 数据管理 导入/导出配置备份。详见下方「数据管理」章节。 ### 备份与恢复 管理自动备份: | 配置 | 说明 | | -------- | -------------------------- | | 备份间隔 | 自动备份的时间间隔(小时) | | 保留数量 | 保留的备份份数 | 支持查看备份列表和从备份恢复。 ### 云同步(WebDAV) 通过 WebDAV 协议在多台设备间同步配置。 | 配置项 | 说明 | | -------- | ------------------------------------- | | 服务预设 | 坚果云 / Nextcloud / 群晖 / 自定义 | | 服务地址 | WebDAV 服务器 URL | | 用户名 | 登录用户名 | | 密码 | 登录密码(应用专用密码) | | 远程目录 | 远程存储路径(默认 `cc-switch-sync`) | | 配置名称 | 设备配置文件名(默认 `default`) | | 自动同步 | 开启后自动上传变更 | 操作: - **测试连接**:验证 WebDAV 配置是否正确 - **保存**:保存配置并自动测试 - **上传**:将本地数据上传到远程 - **下载**:从远程下载数据到本地 > ⚠️ **注意**:上传会覆盖远程数据,下载会覆盖本地数据。操作前请确认。 ### 日志配置 | 配置项 | 说明 | | -------- | ----------------------------------- | | 启用日志 | 开启/关闭应用日志记录 | | 日志级别 | error / warn / info / debug / trace | 日志级别说明: - **error** - 仅记录错误 - **warn** - 记录警告和错误 - **info** - 记录一般信息(推荐) - **debug** - 记录调试信息 - **trace** - 记录所有详细信息 ## 关于页面 设置 → 关于 Tab ### 版本信息 显示当前 CC Switch 版本号,支持: - 查看发布说明 - 检查更新 - 下载并安装新版本 ### 本地环境检查 自动检测已安装的 CLI 工具版本: | 工具 | 检测内容 | | -------- | ------------------ | | Claude | 当前版本、最新版本 | | Codex | 当前版本、最新版本 | | Gemini | 当前版本、最新版本 | | OpenCode | 当前版本、最新版本 | | OpenClaw | 当前版本、最新版本 | 点击「刷新」按钮可重新检测。 ### 一键安装命令 提供快速安装/更新 CLI 工具的命令: ```bash npm i -g @anthropic-ai/claude-code@latest npm i -g @openai/codex@latest npm i -g @google/gemini-cli@latest npm i -g opencode@latest npm i -g openclaw@latest ``` 点击「复制」按钮可复制到剪贴板。 ================================================ FILE: docs/user-manual/zh/2-providers/2.1-add.md ================================================ # 2.1 添加供应商 ## 打开添加面板 点击主界面右上角的 **+** 按钮,打开添加供应商面板。 面板分为两个 Tab: - **应用专属供应商**:仅用于当前选中的应用(Claude/Codex/Gemini/OpenCode/OpenClaw) - **统一供应商**:跨应用共享的配置 ## 使用预设添加 预设是预先配置好的供应商模板,只需填写 API Key 即可使用。 ### 操作步骤 1. 在「预设」下拉框中选择供应商 2. 名称和端点会自动填充 3. 填写你的 **API Key** 4. (可选)填写备注 5. 点击「添加」 ### 常用预设 #### Claude 预设 | 预设名称 | 说明 | |----------|------| | Claude 官方 | 使用 Anthropic 官方账号登录 | | DeepSeek | DeepSeek 模型 | | 智谱 GLM | 智谱 AI 的 GLM 模型 | | 智谱 GLM en | 智谱 AI(英文版) | | 百炼 | 阿里云百炼(通义千问) | | Kimi | Moonshot Kimi 模型 | | Kimi For Coding | Kimi 编程专用模型 | | StepFun | 阶跃星辰 Step模型 | | ModelScope | 魔搭社区 | | KAT-Coder | KAT-Coder 模型 | | Longcat | Longcat AI | | MiniMax | MiniMax 模型 | | MiniMax en | MiniMax(英文版) | | DouBaoSeed | 豆包 Seed 模型 | | BaiLing | 百灵 AI | | AiHubMix | AiHubMix 聚合服务 | | SiliconFlow | 硅基流动 | | SiliconFlow en | 硅基流动(英文版) | | DMXAPI | DMXAPI 中转服务 | | PackyCode | PackyCode 中转服务 ⭐ | | Cubence | Cubence 服务 | | AIGoCode | AIGoCode 服务 | | RightCode | RightCode 服务 | | AICodeMirror | AICodeMirror 服务 | | OpenRouter | 聚合路由服务 | | Nvidia | Nvidia AI 服务 | | Xiaomi MiMo | 小米 MiMo 模型 | > ⭐ 标注为官方合作伙伴。预设列表可能随版本更新,以应用内实际显示为准。 #### Codex 预设 | 预设名称 | 说明 | |----------|------| | OpenAI 官方 | 使用 OpenAI 官方账号登录 | | Azure OpenAI | Azure OpenAI 服务 | | AiHubMix | AiHubMix 聚合服务 | | DMXAPI | DMXAPI 中转服务 | | PackyCode | PackyCode 中转服务 | | Cubence | Cubence 服务 | | AIGoCode | AIGoCode 服务 | | RightCode | RightCode 服务 | | AICodeMirror | AICodeMirror 服务 | | OpenRouter | 聚合路由服务 | #### Gemini 预设 | 预设名称 | 说明 | |----------|------| | Google 官方 | 使用 Google OAuth 登录 | | PackyCode | PackyCode 中转服务 | | Cubence | Cubence 服务 | | AIGoCode | AIGoCode 服务 | | AICodeMirror | AICodeMirror 服务 | | OpenRouter | 聚合路由服务 | | 自定义 | 手动配置所有参数 | #### OpenCode 预设 | 预设名称 | 说明 | |----------|------| | DeepSeek | DeepSeek 模型 | | 智谱 GLM | 智谱 AI 的 GLM 模型 | | 智谱 GLM en | 智谱 AI(英文版) | | 百炼 | 阿里云百炼 | | Kimi k2.5 | Moonshot Kimi-k2.5 模型 | | Kimi For Coding | Kimi 编程专用模型 | | StepFun | 阶跃星辰 Step模型 | | ModelScope | 魔搭社区 | | KAT-Coder | KAT-Coder 模型 | | Longcat | Longcat AI | | MiniMax | MiniMax 模型 | | MiniMax en | MiniMax(英文版) | | DouBaoSeed | 豆包 Seed 模型 | | BaiLing | 百灵 AI | | Xiaomi MiMo | 小米 MiMo 模型 | | AiHubMix | AiHubMix 聚合服务 | | DMXAPI | DMXAPI 中转服务 | | OpenRouter | 聚合路由服务 | | Nvidia | Nvidia AI 服务 | | PackyCode | PackyCode 中转服务 | | Cubence | Cubence 服务 | | AIGoCode | AIGoCode 服务 | | RightCode | RightCode 服务 | | AICodeMirror | AICodeMirror 服务 | | OpenAI Compatible | OpenAI 兼容接口 | | Oh My OpenCode | Oh My OpenCode 服务 | > 💡 预设列表持续更新中,以应用内实际显示为准。 #### OpenClaw 预设 | 预设名称 | 说明 | |----------|------| | DeepSeek | DeepSeek 模型 | | 智谱 GLM | 智谱 AI 的 GLM 模型 | | 智谱 GLM en | 智谱 AI(英文版) | | Qwen Coder | 通义千问编码模型 | | Kimi k2.5 | Moonshot Kimi-k2.5 模型 | | Kimi For Coding | Kimi 编程专用模型 | | StepFun | 阶跃星辰 Step模型 | | MiniMax | MiniMax 模型 | | MiniMax en | MiniMax(英文版) | | KAT-Coder | KAT-Coder 模型 | | Longcat | Longcat AI | | DouBaoSeed | 豆包 Seed 模型 | | BaiLing | 百灵 AI | | Xiaomi MiMo | 小米 MiMo 模型 | | AiHubMix | AiHubMix 聚合服务 | | DMXAPI | DMXAPI 中转服务 | | OpenRouter | 聚合路由服务 | | ModelScope | 魔搭社区 | | SiliconFlow | 硅基流动 | | SiliconFlow en | 硅基流动(英文版) | | Nvidia | Nvidia AI 服务 | | PackyCode | PackyCode 中转服务 | | Cubence | Cubence 服务 | | AIGoCode | AIGoCode 服务 | | RightCode | RightCode 服务 | | AICodeMirror | AICodeMirror 服务 | | AICoding | AICoding 服务 | | CrazyRouter | CrazyRouter 服务 | | SSSAiCode | SSSAiCode 服务 | | AWS Bedrock | AWS Bedrock 服务 | | OpenAI Compatible | OpenAI 兼容接口 | ## 自定义配置 选择「自定义」预设后,需要手动编辑 JSON 配置。 ### Claude 配置格式 ```json { "env": { "ANTHROPIC_API_KEY": "your-api-key", "ANTHROPIC_BASE_URL": "https://api.example.com" } } ``` | 字段 | 必填 | 说明 | |------|------|------| | `ANTHROPIC_API_KEY` | 是 | API 密钥 | | `ANTHROPIC_BASE_URL` | 否 | 自定义端点地址 | | `ANTHROPIC_AUTH_TOKEN` | 否 | 替代 API_KEY 的认证方式 | ### Codex 配置格式 Codex 使用两个配置文件: **1. auth.json**(`~/.codex/auth.json`)- 存储 API 密钥: ```json { "OPENAI_API_KEY": "your-api-key" } ``` **2. config.toml**(`~/.codex/config.toml`)- 存储模型和端点配置: ```toml # 基础配置 model_provider = "custom" model = "gpt-5.2" model_reasoning_effort = "high" disable_response_storage = true # 自定义供应商配置 [model_providers.custom] name = "custom" base_url = "https://api.example.com/v1" wire_api = "responses" requires_openai_auth = true ``` **auth.json 字段说明**: | 字段 | 必填 | 说明 | |------|------|------| | `OPENAI_API_KEY` | 是 | API 密钥 | **config.toml 字段说明**: | 字段 | 必填 | 说明 | |------|------|------| | `model_provider` | 是 | 模型提供商名称(需与 `[model_providers.xxx]` 匹配) | | `model` | 是 | 使用的模型(如 `gpt-5.2`、`gpt-4o`) | | `model_reasoning_effort` | 否 | 推理强度:`low` / `medium` / `high` | | `disable_response_storage` | 否 | 是否禁用响应存储 | | `base_url` | 是 | API 端点地址 | | `wire_api` | 否 | API 协议类型(通常为 `responses`) | | `requires_openai_auth` | 否 | 是否使用 OpenAI 认证方式 | ### Gemini 配置格式 ```json { "env": { "GEMINI_API_KEY": "your-api-key", "GOOGLE_GEMINI_BASE_URL": "https://api.example.com" } } ``` | 字段 | 必填 | 说明 | |------|------|------| | `GEMINI_API_KEY` | 是 | API 密钥 | | `GOOGLE_GEMINI_BASE_URL` | 否 | 自定义端点地址 | | `GEMINI_MODEL` | 否 | 指定模型 | > 💡 认证类型由 CC Switch 自动检测(PackyCode API 代理 / Google OAuth / 通用 API Key),无需手动配置。 ## 统一供应商 统一供应商可以跨 Claude/Codex/Gemini/OpenCode/OpenClaw 共享配置,适用于支持多种 API 格式的中转服务。 ### 创建统一供应商 1. 切换到「统一供应商」Tab 2. 点击「添加统一供应商」 3. 填写通用配置: - 名称 - API Key - 端点地址 4. 勾选要同步的应用(Claude/Codex/Gemini/OpenCode/OpenClaw) 5. 保存 ### 同步机制 统一供应商会自动同步到勾选的应用: - 修改统一供应商后,所有关联应用的配置同步更新 - 删除统一供应商后,关联的应用配置也会删除 ### 保存并同步 编辑统一供应商时,可以选择: | 操作 | 说明 | |------|------| | 保存 | 仅保存配置,不立即同步 | | 保存并同步 | 保存配置并立即同步到所有启用的应用 | ### 手动同步 如果需要手动触发同步: 1. 在统一供应商卡片上点击「同步」按钮 2. 确认同步操作 3. 配置会覆盖各应用中关联的供应商 ## 导入供应商 CC Switch 支持两种方式导入供应商配置: ### 方式一:深度链接导入 通过 `ccswitch://` 协议链接一键导入: 1. 点击或访问深度链接 2. CC Switch 自动打开并显示导入确认 3. 预览配置信息 4. 点击「确认导入」 **获取深度链接**: - 从他人分享获取 - 使用 [在线生成工具](https://farion1231.github.io/cc-switch/deplink.html) 创建 ### 方式二:数据库备份导入 从 SQL 备份文件批量导入: 1. 打开「设置 → 高级 → 数据管理」 2. 点击「选择文件」 3. 选择之前导出的 `.sql` 备份文件 4. 点击「导入」 5. 确认覆盖现有配置 **导入内容**: - 所有供应商配置 - MCP 服务器配置 - Prompts 预设 - 用量日志 > ⚠️ **注意**:导入会覆盖现有数据库,建议先导出当前配置作为备份。导出的文件名格式为 `cc-switch-export-{时间戳}.sql`。 ## 高级选项 ### 自定义图标 点击名称左侧的图标区域,可以: - 选择预设图标 - 自定义图标颜色 ### 网站链接 填写供应商的官网或控制台地址,方便快速访问: - 点击供应商卡片的链接图标可直接打开 - 用于查看余额、获取 API Key 等 ### 备注 添加备注信息,如: - 账号用途(个人/工作) - 套餐信息 - 到期时间 备注会显示在供应商卡片上,也支持搜索。 ### 端点测速 添加供应商后,可以对 API 端点进行速度测试: 1. 点击供应商卡片的「测速」按钮 2. 在测速面板中添加多个端点 URL 3. 点击「测速」执行测试 4. 选择延迟最低的端点 **测速结果**: - 🟢 绿色:延迟 < 500ms(优秀) - 🟡 黄色:延迟 500-1000ms(一般) - 🔴 红色:延迟 > 1000ms(较慢) ![image-20260108005327817](../../assets/image-20260108005327817.png) ================================================ FILE: docs/user-manual/zh/2-providers/2.2-switch.md ================================================ # 2.2 切换供应商 ## 主界面切换 在供应商列表中,点击目标供应商卡片的「启用」按钮。 ### 切换流程 1. 点击「启用」按钮 2. CC Switch 更新配置文件 3. 卡片状态变为「当前启用」 4. Claude/Gemini 即时生效,Codex 需重启终端 ### 状态指示 | 状态 | 显示 | 说明 | |------|------|------| | 当前启用 | 蓝色边框 + 标签 | 配置文件中的当前供应商 | | 代理活跃 | 绿色边框 | 代理模式下实际使用的供应商 | | 普通 | 默认样式 | 未启用的供应商 | ## 托盘快速切换 通过系统托盘可以快速切换,无需打开主界面。 ### 操作步骤 1. 右键点击系统托盘的 CC Switch 图标 2. 在菜单中找到对应应用(Claude/Codex/Gemini/OpenCode) 3. 点击要切换的供应商名称 4. 切换完成,托盘会短暂提示 ### 托盘菜单结构 ![image-20260108004348993](../../assets/image-20260108004348993.png) ## 生效方式 ### Claude Code **切换后即时生效**,无需重启。 Claude Code 支持热重载,会自动检测配置文件变更并重新加载。 ### Codex 切换后需要重启: - 关闭当前终端窗口 - 重新打开终端 ### Gemini CLI **切换后即时生效**,无需重启。 Gemini CLI 每次请求都会重新读取 `.env` 文件。 ## 配置文件变更 切换供应商时,CC Switch 会修改以下文件: ### Claude ``` ~/.claude/settings.json ``` 修改内容: ```json { "env": { "ANTHROPIC_API_KEY": "新的 API Key", "ANTHROPIC_BASE_URL": "新的端点" } } ``` ### Codex ``` ~/.codex/auth.json ~/.codex/config.toml(如有额外配置) ``` ### Gemini ``` ~/.gemini/.env ~/.gemini/settings.json ``` ## 切换失败处理 如果切换失败,可能的原因: ### 配置文件被锁定 其他程序正在使用配置文件。 **解决方法**:关闭正在运行的 CLI 工具,再尝试切换。 ### 权限不足 没有写入配置文件的权限。 **解决方法**:检查配置目录的权限设置。 ### 配置格式错误 供应商配置的 JSON 格式有误。 **解决方法**:编辑供应商,检查并修复 JSON 格式。 ================================================ FILE: docs/user-manual/zh/2-providers/2.3-edit.md ================================================ # 2.3 编辑供应商 ## 打开编辑面板 1. 找到要编辑的供应商卡片 2. 鼠标悬停在卡片上,显示操作按钮 3. 点击「编辑」按钮 ## 可编辑内容 ### 基本信息 | 字段 | 说明 | |------|------| | 名称 | 供应商显示名称 | | 备注 | 附加说明信息 | | 网站链接 | 供应商官网或控制台地址 | | 图标 | 自定义图标和颜色 | ### 图标自定义 CC Switch 提供丰富的图标自定义功能: #### 图标选择器 1. 点击图标区域打开图标选择器 2. 使用搜索框按名称搜索图标 3. 点击选择想要的图标 图标库包含常见的 AI 服务商和技术图标,支持: - 按名称模糊搜索 - 显示图标名称提示 - 实时预览选中效果 ![image-20260108004734882](../../assets/image-20260108004734882.png) ### 配置信息 JSON 格式的配置内容,包括: - API Key - 端点地址 - 其他环境变量 ### 编辑当前启用的供应商 编辑当前启用的供应商时,有特殊的「回填」机制: 1. 打开编辑面板时,会从 live 配置文件读取最新内容 2. 如果你在 CLI 工具中手动修改过配置,这些修改会被同步回来 3. 保存后,修改会写入 live 配置文件 这确保了 CC Switch 和 CLI 工具的配置始终同步。 ## 修改 API Key 编辑供应商时,可以直接在 **API Key** 输入框中修改: 1. 点击供应商卡片的「编辑」按钮 2. 在「API Key」输入框中输入新的密钥 3. 点击「保存」 > 💡 **提示**:API Key 输入框支持显示/隐藏切换,点击右侧的眼睛图标可查看完整密钥。 ## 修改端点地址 编辑供应商时,可以直接在 **端点地址** 输入框中修改: 1. 点击供应商卡片的「编辑」按钮 2. 在「端点地址」输入框中输入新的 URL 3. 点击「保存」 ### 端点地址格式 | 应用 | 格式示例 | |------|----------| | Claude | `https://api.example.com` | | Codex | `https://api.example.com/v1` | | Gemini | `https://api.example.com` | ## 添加自定义端点 供应商可以配置多个端点,用于: - 速度测试时测试多个地址 - 故障转移时的备用端点 ### 自动收集 添加供应商时,CC Switch 会自动从配置中提取端点地址。 ### 手动添加 编辑供应商时,在「端点管理」区域可以: - 添加新端点 - 删除现有端点 - 设置默认端点 ## JSON 编辑器 配置使用 JSON 格式,编辑器提供: - 语法高亮 - 格式校验 - 错误提示 ### 常见错误 **缺少引号**: ```json // ❌ 错误 { env: { KEY: "value" } } // ✅ 正确 { "env": { "KEY": "value" } } ``` **多余逗号**: ```json // ❌ 错误 { "env": { "KEY": "value", } } // ✅ 正确 { "env": { "KEY": "value" } } ``` **未闭合括号**: ```json // ❌ 错误 { "env": { "KEY": "value" } // ✅ 正确 { "env": { "KEY": "value" } } ``` ## 保存与生效 1. 点击「保存」按钮 2. 如果是当前启用的供应商,配置立即写入 live 文件 3. 重启 CLI 工具生效 ## 取消编辑 点击「取消」或按 `Esc` 键关闭编辑面板,所有修改都不会保存。 ================================================ FILE: docs/user-manual/zh/2-providers/2.4-sort-duplicate.md ================================================ # 2.4 排序与复制 ## 拖拽排序 通过拖拽调整供应商的显示顺序。 ### 操作步骤 1. 将鼠标移到供应商卡片左侧的 **≡** 拖拽手柄 2. 按住鼠标左键 3. 上下拖动到目标位置 4. 松开鼠标完成排序 ### 排序用途 - **常用优先**:将常用的供应商放在列表顶部 - **故障转移顺序**:排序会影响故障转移队列的默认顺序 ## 复制供应商 快速创建供应商的副本,适用于: - 基于现有配置创建变体 - 备份当前配置 - 创建测试用配置 ### 操作步骤 1. 鼠标悬停在供应商卡片上,显示操作按钮 2. 点击「复制」按钮 3. 自动创建副本,名称后缀 `copy` 4. 编辑副本修改配置 ### 复制内容 复制会创建完整的副本,包括: | 内容 | 是否复制 | |------|----------| | 名称 | ✅ 复制(添加 `copy` 后缀) | | 配置 | ✅ 完整复制 | | 备注 | ✅ 复制 | | 网站链接 | ✅ 复制 | | 图标 | ✅ 复制 | | 端点列表 | ✅ 复制 | | 排序位置 | ✅ 插入到原供应商下方 | ### 复制后编辑 复制完成后,通常需要修改: 1. **名称**:改为有意义的名称 2. **API Key**:如果是不同账号 3. **端点**:如果是不同服务 ## 删除供应商 ### 操作步骤 1. 鼠标悬停在供应商卡片上,显示操作按钮 2. 点击「删除」按钮 3. 确认删除 ### 删除确认 删除前会弹出确认对话框,显示: - 供应商名称 - 删除后无法恢复的提示 ### 删除限制 - **当前启用的供应商**:可以删除,但建议先切换到其他供应商 - **统一供应商**:删除后,关联的应用配置也会被删除 ![image-20260108004946288](../../assets/image-20260108004946288.png) ================================================ FILE: docs/user-manual/zh/2-providers/2.5-usage-query.md ================================================ # 2.5 用量查询 ## 功能说明 用量查询功能允许你配置自定义脚本,实时查询供应商的剩余额度、已用量等信息。 **使用场景**: - 查看 API 账户剩余余额 - 监控套餐使用情况 - 多套餐额度汇总显示 ## 打开配置 1. 鼠标悬停在供应商卡片上,显示操作按钮 2. 点击「用量查询」按钮(📊 图标) 3. 打开用量查询配置面板 ## 启用用量查询 在配置面板顶部,开启「启用用量查询」开关。 ## 预设模板 CC Switch 提供三种预设模板: ### 自定义模板 完全自定义请求和提取逻辑,适用于特殊 API 格式。 ### 通用模板 适用于大多数标准 API 格式的供应商: ```javascript ({ request: { url: "{{baseUrl}}/user/balance", method: "GET", headers: { "Authorization": "Bearer {{apiKey}}", "User-Agent": "cc-switch/1.0" } }, extractor: function(response) { return { isValid: response.is_active || true, remaining: response.balance, unit: "USD" }; } }) ``` **配置参数**: | 参数 | 说明 | |------|------| | API Key | 用于认证的密钥(可选,留空则使用供应商配置的 Key) | | Base URL | API 基础地址(可选,留空则使用供应商端点) | ### New API 模板 专为 New API 类型的中转服务设计: ```javascript ({ request: { url: "{{baseUrl}}/api/user/self", method: "GET", headers: { "Content-Type": "application/json", "Authorization": "Bearer {{accessToken}}", "New-Api-User": "{{userId}}" }, }, extractor: function (response) { if (response.success && response.data) { return { planName: response.data.group || "默认套餐", remaining: response.data.quota / 500000, used: response.data.used_quota / 500000, total: (response.data.quota + response.data.used_quota) / 500000, unit: "USD", }; } return { isValid: false, invalidMessage: response.message || "查询失败" }; }, }) ``` **配置参数**: | 参数 | 说明 | |------|------| | Base URL | New API 服务地址 | | Access Token | 访问令牌 | | User ID | 用户 ID | ## 通用配置 ### 超时时间 请求超时时间(秒),默认 10 秒。 ### 自动查询间隔 自动刷新用量数据的间隔(分钟): - 设为 `0` 表示禁用自动查询 - 范围:0-1440 分钟(最长 24 小时) - 仅当供应商处于「当前启用」状态时生效 ## 提取器返回格式 提取器函数需要返回包含以下字段的对象: | 字段 | 类型 | 必填 | 说明 | |------|------|------|------| | `isValid` | boolean | 否 | 账户是否有效,默认 true | | `invalidMessage` | string | 否 | 无效时的提示信息 | | `remaining` | number | 是 | 剩余额度 | | `unit` | string | 是 | 单位(如 USD、CNY、次) | | `planName` | string | 否 | 套餐名称(支持多套餐) | | `total` | number | 否 | 总额度 | | `used` | number | 否 | 已使用额度 | | `extra` | object | 否 | 额外信息 | ## 测试脚本 配置完成后,点击「测试脚本」按钮验证: 1. 发送请求到配置的 URL 2. 执行提取器函数 3. 显示返回结果或错误信息 ## 显示效果 配置成功后,供应商卡片上会显示: - **单套餐**:直接显示剩余额度 - **多套餐**:显示套餐数量,点击展开查看详情 ## 变量占位符 脚本中可使用以下占位符,运行时自动替换: | 占位符 | 说明 | |--------|------| | `{{apiKey}}` | 配置的 API Key | | `{{baseUrl}}` | 配置的 Base URL | | `{{accessToken}}` | 配置的 Access Token(New API) | | `{{userId}}` | 配置的 User ID(New API) | ## 常见供应商配置示例 ### 故障排除 ### 查询失败 **检查**: 1. API Key 是否正确 2. Base URL 是否正确 3. 网络是否可访问 4. 超时时间是否足够 ### 返回数据为空 **检查**: 1. 提取器函数是否有 `return` 语句 2. 响应数据结构是否与提取器匹配 3. 使用「测试脚本」查看原始响应 ### 格式化失败 脚本语法错误时,点击「格式化」按钮会提示错误位置。 ## 注意事项 - 用量查询会消耗少量 API 请求配额 - 建议设置合理的自动查询间隔,避免频繁请求 - 敏感信息(API Key、Token)会安全存储在本地 ================================================ FILE: docs/user-manual/zh/3-extensions/3.1-mcp.md ================================================ # 3.1 MCP 服务器管理 ## 什么是 MCP MCP (Model Context Protocol) 是一种协议,允许 AI 工具访问外部数据源和工具。通过 MCP 服务器,你可以让 AI: - 访问文件系统 - 执行网络请求 - 查询数据库 - 调用外部 API ## 打开 MCP 面板 点击顶部导航栏的 **MCP** 按钮。 ## 面板概览 ![image-20260108005723522](../../assets/image-20260108005723522.png) ## 添加 MCP 服务器 ### 使用预设模板 1. 点击右上角 **+** 按钮 2. 在「预设」下拉框中选择模板 3. 根据需要修改配置 4. 点击「保存」 ![image-20260108005739731](../../assets/image-20260108005739731.png) ### 常用预设 | 预设 | 包名 | 功能说明 | |------|------|----------| | fetch | mcp-server-fetch | HTTP 请求工具,让 AI 能够获取网页内容 | | time | @modelcontextprotocol/server-time | 时间工具,提供当前时间信息 | | memory | @modelcontextprotocol/server-memory | 记忆工具,让 AI 能够存储和检索信息 | | sequential-thinking | @modelcontextprotocol/server-sequential-thinking | 思维链工具,增强 AI 推理能力 | | context7 | @upstash/context7-mcp | 文档搜索工具,查询技术文档 | ### 自定义配置 选择「自定义」后,需要填写: | 字段 | 必填 | 说明 | |------|------|------| | 服务器 ID | 是 | 唯一标识符 | | 名称 | 否 | 显示名称 | | 描述 | 否 | 功能说明 | | 传输类型 | 是 | stdio / http / sse | | 命令 | 是* | stdio 类型必填 | | 参数 | 否 | 命令行参数 | | URL | 是* | http/sse 类型必填 | | Headers | 否 | http/sse 类型的请求头 | | 环境变量 | 否 | 传递给服务器的环境变量 | ## 传输类型 ### stdio(标准输入输出) 最常用的类型,通过启动本地进程通信。 ```json { "command": "uvx", "args": ["mcp-server-fetch"], "env": {} } ``` **要求**: - 需要安装对应的命令(如 `uvx`、`npx`) - 服务器程序需要在 PATH 中 ### http 通过 HTTP 协议与远程服务器通信。 ```json { "url": "http://localhost:8080/mcp" } ``` ### sse(Server-Sent Events) 通过 SSE 协议与服务器通信,支持实时推送。 ```json { "url": "http://localhost:8080/sse" } ``` ## 应用绑定 每个 MCP 服务器可以独立控制启用的应用。 ### 开关说明 | 开关 | 作用 | 配置文件路径 | |------|------|--------------| | Claude | 同步到 Claude Code | `~/.claude.json` 的 `mcpServers` | | Codex | 同步到 Codex | `~/.codex/config.toml` 的 `[mcp_servers]` | | Gemini | 同步到 Gemini CLI | `~/.gemini/settings.json` 的 `mcpServers` | | OpenCode | 同步到 OpenCode | `~/.opencode/config.json` 的 `mcpServers` | > ⚠️ **注意**:OpenClaw 暂不支持 MCP 服务器管理。MCP 功能目前仅支持 Claude、Codex、Gemini 和 OpenCode 四个应用。 ### 开关实现机制 当开启某个应用的开关时,CC Switch 会: 1. **更新数据库**:将服务器的 `apps.claude/codex/gemini/opencode` 状态设为 `true` 2. **同步到 Live 配置**:将服务器配置写入对应应用的配置文件 3. **即时生效**:下次启动 CLI 工具时自动加载新的 MCP 服务器 当关闭某个应用的开关时,CC Switch 会: 1. **更新数据库**:将对应应用状态设为 `false` 2. **从 Live 配置移除**:从应用配置文件中删除该服务器 3. **即时生效**:下次启动 CLI 工具时不再加载该 MCP 服务器 ### 同步条件 MCP 服务器同步仅在对应应用已安装时执行: - **Claude**:需存在 `~/.claude/` 目录或 `~/.claude.json` 文件 - **Codex**:需存在 `~/.codex/` 目录 - **Gemini**:需存在 `~/.gemini/` 目录 - **OpenCode**:需存在 `~/.opencode/` 目录 > 💡 **提示**:如果某个 CLI 工具未安装,开启对应开关不会报错,但配置不会写入。 关闭开关后,配置会从文件中移除。 ## 编辑服务器 1. 点击服务器行右侧的「编辑」按钮 2. 修改配置 3. 点击「保存」 修改会立即同步到已启用的应用配置文件。 ## 删除服务器 1. 点击服务器行右侧的「删除」按钮 2. 确认删除 删除后,配置会从所有应用的配置文件中移除。 ## 导入现有配置 如果你已经在 CLI 工具中配置了 MCP 服务器,可以导入到 CC Switch: 1. 点击「导入」按钮 2. 选择要导入的应用(Claude/Codex/Gemini/OpenCode) 3. CC Switch 会读取现有配置并导入 ## 配置文件格式 ### Claude (`~/.claude.json`) ```json { "mcpServers": { "mcp-fetch": { "command": "uvx", "args": ["mcp-server-fetch"] } } } ``` ### Codex (`~/.codex/config.toml`) ```toml [mcp_servers.mcp-fetch] command = "uvx" args = ["mcp-server-fetch"] ``` ### Gemini (`~/.gemini/settings.json`) ```json { "mcpServers": { "mcp-fetch": { "command": "uvx", "args": ["mcp-server-fetch"] } } } ``` ## 常见问题 ### 服务器启动失败 检查: - 命令是否正确安装(如 `uvx`) - 命令是否在 PATH 中 - 参数是否正确 ### 配置不生效 确保: - 对应应用的开关已开启 - 重启了 CLI 工具 ================================================ FILE: docs/user-manual/zh/3-extensions/3.2-prompts.md ================================================ # 3.2 Prompts 提示词管理 ## 功能说明 Prompts 功能用于管理系统提示词预设。系统提示词会影响 AI 的行为和回复风格。 通过 CC Switch,你可以: - 创建多个提示词预设 - 快速切换不同场景的提示词 - 跨设备同步提示词配置 ## 打开 Prompts 面板 点击顶部导航栏的 **Prompts** 按钮。 ## 面板概览 ![image-20260108010110382](../../assets/image-20260108010110382.png) ## 创建预设 ### 操作步骤 1. 点击右上角 **+** 按钮 2. 输入预设名称 3. 在 Markdown 编辑器中编写提示词 4. 点击「保存」 ### Markdown 编辑器 编辑器提供: - 语法高亮 - 实时预览 - 常用格式快捷键 ### 提示词编写建议 **结构化格式**: ```markdown # 角色定义 你是一个专业的代码审查专家。 ## 核心能力 - 代码质量分析 - 性能优化建议 - 安全漏洞检测 ## 回复风格 - 简洁明了 - 提供具体示例 - 给出改进建议 ## 注意事项 - 不要修改业务逻辑 - 保持代码风格一致 ``` ## 激活预设 ### 操作方式 点击预设项的开关按钮,切换启用状态。 ### 单一激活 同一时间只能激活一个预设。激活新预设时,之前的预设会自动停用。 ### 同步目标 激活后,提示词会写入对应应用的文件: | 应用 | 文件路径 | |------|----------| | Claude | `~/.claude/CLAUDE.md` | | Codex | `~/.codex/AGENTS.md` | | Gemini | `~/.gemini/GEMINI.md` | | OpenCode | `~/.opencode/AGENTS.md` | | OpenClaw | `~/.openclaw/AGENTS.md` | ## 编辑预设 1. 点击预设项的「编辑」按钮 2. 修改名称或内容 3. 点击「保存」 如果编辑的是当前激活的预设,保存后会立即同步到配置文件。 ## 删除预设 1. 点击预设项的「删除」按钮 2. 确认删除 已启用的预设不允许删除,需先停用后再删除。 ## 智能回填 CC Switch 提供智能回填保护机制,确保你的手动修改不会丢失。 ### 工作原理 1. 切换预设前,自动读取当前配置文件内容 2. 比较文件内容与数据库中的预设 3. 如果内容不同,说明用户手动修改过 4. 将手动修改的内容保存到当前预设 5. 然后再切换到新预设 ### 保护场景 | 场景 | 处理方式 | |------|----------| | CLI 中直接编辑 `CLAUDE.md` | 修改自动保存到当前预设 | | 外部编辑器修改配置文件 | 修改自动保存到当前预设 | | 切换到其他预设 | 先保存当前修改,再切换 | ### 技术细节 回填机制在以下时机触发: - **切换预设时**:保存当前 live 文件内容到当前预设 - **编辑当前预设时**:从 live 文件读取最新内容 - **首次启动时**:自动导入现有 live 文件内容 ### 注意事项 - 回填仅在切换到不同预设时触发 - 如果当前没有激活的预设,不会触发回填 - 回填失败不会影响切换流程 ## 跨应用使用 Prompts 是按应用分开管理的: - 切换到 Claude 时,显示 Claude 的预设 - 切换到 Codex 时,显示 Codex 的预设 - 切换到 Gemini 时,显示 Gemini 的预设 - 切换到 OpenCode 时,显示 OpenCode 的预设 - 切换到 OpenClaw 时,显示 OpenClaw 的预设 如需在多个应用使用相同的提示词,需要分别创建。 ## 导入导出 ### 通过深度链接分享 可以生成深度链接分享预设: ``` ccswitch://import/prompt?data= ``` ### 通过配置导出 导出配置时会包含所有预设,导入后可恢复。 ================================================ FILE: docs/user-manual/zh/3-extensions/3.3-skills.md ================================================ # 3.3 Skills 技能管理 ## 功能说明 Skills 是可复用的能力扩展,让 AI 工具获得特定领域的专业能力。 技能以文件夹形式存在,包含: - 提示词模板 - 工具定义 - 示例代码 ## 支持的应用 Skills 功能支持所有四种应用: - **Claude Code** - **Codex** - **Gemini CLI** - **OpenCode** ## 打开 Skills 页面 点击顶部导航栏的 **Skills** 按钮。 > 注意:Skills 按钮在所有应用模式下均可见。 ## 页面概览 ![image-20260108010253926](../../assets/image-20260108010253926.png) ## 发现技能 ### 预配置仓库 CC Switch 预配置了以下 GitHub 仓库: | 仓库 | 说明 | | -------------- | ------------------------ | | Anthropic 官方 | Anthropic 提供的官方技能 | | ComposioHQ | 社区维护的技能集合 | | 社区精选 | 精选的高质量技能 | ![image-20260108010308060](../../assets/image-20260108010308060.png) ### 搜索过滤 CC Switch 提供强大的搜索和过滤功能: #### 搜索框 - 支持按技能名称搜索 - 支持按技能描述搜索 - 支持按目录名称搜索 - 实时过滤,输入即搜索 #### 状态过滤 使用下拉菜单按安装状态过滤: | 选项 | 说明 | | ------ | ------------------ | | 全部 | 显示所有技能 | | 已安装 | 仅显示已安装的技能 | | 未安装 | 仅显示未安装的技能 | ![image-20260108010324583](../../assets/image-20260108010324583.png) #### 组合使用 搜索和过滤可以组合使用: - 先选择「已安装」过滤 - 再输入关键词搜索 - 结果显示匹配数量 ### 刷新列表 点击「刷新」按钮重新扫描仓库,获取最新技能。 ## 安装技能 ### 操作步骤 1. 找到要安装的技能卡片 2. 点击「安装」按钮 3. 等待安装完成 ### 安装位置 | 应用 | 安装目录 | | -------- | --------------------- | | Claude | `~/.claude/skills/` | | Codex | `~/.codex/skills/` | | Gemini | `~/.gemini/skills/` | | OpenCode | `~/.opencode/skills/` | ### 安装内容 安装会将技能文件夹复制到本地: ``` ~/.claude/skills/ └── skill-name/ ├── README.md ├── prompt.md └── tools/ └── ... ``` ## 卸载技能 ### 操作步骤 1. 找到已安装的技能卡片 2. 点击「卸载」按钮 3. 确认卸载 ### 卸载效果 - 删除本地技能文件夹 - 更新安装状态 ## 仓库管理 ### 打开仓库管理 点击页面顶部的「仓库管理」按钮。 ### 添加自定义仓库 1. 点击「添加仓库」 2. 填写仓库信息: - Owner:GitHub 用户名或组织名 - Name:仓库名称 - Branch:分支名(默认 main) - Subdirectory:技能所在子目录(可选) 3. 点击「添加」 ### 仓库格式 ``` https://github.com/{owner}/{name}/tree/{branch}/{subdirectory} ``` 示例: ``` Owner: anthropics Name: claude-skills Branch: main Subdirectory: skills ``` ### 删除仓库 1. 在仓库列表中找到要删除的仓库 2. 点击「删除」按钮 3. 确认删除 删除仓库后,该仓库的技能不会从列表中消失,但无法再更新。 ## 技能卡片信息 每个技能卡片显示: | 信息 | 说明 | | ---- | --------------- | | 名称 | 技能名称 | | 描述 | 功能说明 | | 来源 | 所属仓库 | | 状态 | 已安装 / 未安装 | ## 技能更新 目前不支持自动更新。如需更新技能: 1. 卸载现有技能 2. 刷新列表 3. 重新安装 ### 技能列表为空 可能原因: - 网络问题,无法访问 GitHub - 仓库配置错误 解决方法: - 检查网络连接 - 点击「刷新」重试 - 检查仓库配置 ### 安装失败 可能原因: - 网络问题 - 磁盘空间不足 - 权限问题 解决方法: - 检查网络连接 - 检查磁盘空间 - 检查目录权限 ================================================ FILE: docs/user-manual/zh/4-proxy/4.1-service.md ================================================ # 4.1 代理服务 ## 功能说明 代理服务在本地启动一个 HTTP 代理,所有 API 请求都通过代理转发。 **主要用途**: - 记录请求日志 - 统计 API 用量 - 支持故障转移 - 集中管理多个应用的请求 ## 启动代理 ### 方式一:主界面开关 点击主界面顶部的 **代理开关** 按钮。 开关状态: - 🔴 白色:代理未运行 - 🟢 绿色:代理运行中 ![image-20260108011353927](../../assets/image-20260108011353927.png) ### 方式二:设置页面 1. 打开「设置 → 高级 → 代理服务」 2. 点击右上角的开关 ![image-20260108011338922](../../assets/image-20260108011338922.png) ## 代理配置 ### 基础配置 | 配置项 | 说明 | 默认值 | |--------|------|--------| | 监听地址 | 代理绑定的 IP 地址 | `127.0.0.1` | | 监听端口 | 代理监听的端口 | `15721` | | 启用日志 | 是否记录请求日志 | 开启 | ### 修改配置 1. **停止代理服务**(必须先停止) 2. 修改监听地址或端口 3. 点击「保存」 4. 重新启动代理 > ⚠️ 修改地址/端口需要先停止代理服务 ### 监听地址说明 | 地址 | 说明 | |------|------| | `127.0.0.1` | 仅本机可访问(推荐) | | `0.0.0.0` | 允许局域网访问 | ## 运行状态 代理运行时,面板显示以下信息: ### 服务地址 ``` http://127.0.0.1:15721 ``` 点击「复制」按钮可复制地址。 ### 当前供应商 显示各应用当前使用的供应商: ``` Claude: PackyCode Codex: AIGoCode Gemini: Google 官方 ``` ### 统计数据 | 指标 | 说明 | |------|------| | 活跃连接 | 当前正在处理的请求数 | | 总请求数 | 启动以来的总请求数 | | 成功率 | 请求成功的百分比(>90% 绿色,≤90% 黄色) | | 运行时间 | 代理已运行的时长 | ### 故障转移队列 代理面板会按应用类型显示故障转移队列: ``` Claude ├── 1. PackyCode [当前使用] ● ├── 2. AIGoCode ● └── 3. 备用供应商 ○ Codex ├── 1. AIGoCode [当前使用] ● └── 2. 备用供应商 ● ``` 队列说明: - 数字表示优先级顺序 - 「当前使用」标签表示正在使用的供应商 - 健康徽章显示供应商状态: - 🟢 绿色:健康(连续失败 0 次) - 🟡 黄色:降级(连续失败 1-2 次) - 🔴 红色:不健康(连续失败 ≥3 次) ## 工作原理 ### 请求流程 ```mermaid sequenceDiagram participant CLI as CLI 工具 (Claude) participant Proxy as 本地代理 (CC Switch) participant API as API 供应商 (Anthropic) participant DB as 数据存储 (Logger) CLI->>Proxy: 发送 API 请求 Proxy->>DB: 记录请求日志/统计用量 Proxy->>API: 转发请求 API-->>Proxy: 返回响应 Proxy-->>CLI: 返回响应 ``` ### 配置修改 启动代理并开启应用接管后,CC Switch 会修改应用配置: **Claude**: ```json { "env": { "ANTHROPIC_BASE_URL": "http://127.0.0.1:15721" } } ``` **Codex**: ```toml base_url = "http://127.0.0.1:15721/v1" ``` **Gemini**: ``` GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:15721 ``` ## 停止代理 ### 方式一:主界面开关 点击代理开关按钮关闭。 ### 方式二:设置页面 在代理服务面板中关闭开关。 ### 停止后的处理 停止代理时,CC Switch 会: 1. 恢复应用配置到原始状态 2. 保存请求日志 3. 关闭所有连接 ## 日志记录 ### 开启日志 在代理面板中开启「启用日志」开关。 ### 日志内容 每条请求记录包含: | 字段 | 说明 | |------|------| | 时间 | 请求时间 | | 应用 | Claude / Codex / Gemini | | 供应商 | 使用的供应商 | | 模型 | 请求的模型 | | Token | 输入/输出 token 数 | | 延迟 | 请求耗时 | | 状态 | 成功/失败 | ### 查看日志 在「设置 → 用量」Tab 中查看请求日志。 ## 常见问题 ### 端口被占用 错误信息:`Address already in use` 解决方法: 1. 更换端口(如 5001) 2. 或关闭占用端口的程序 ### 代理启动失败 检查: - 端口是否被占用 - 是否有足够权限 - 防火墙是否阻止 ### 请求超时 可能原因: - 网络问题 - 供应商服务器问题 - 代理配置错误 解决方法: - 检查网络连接 - 尝试直接访问供应商 API - 检查供应商配置 ================================================ FILE: docs/user-manual/zh/4-proxy/4.2-takeover.md ================================================ # 4.2 应用接管 ## 功能说明 应用接管是指让 CC Switch 代理接管特定应用的 API 请求。 开启接管后: - 应用的 API 请求会通过本地代理转发 - 可以记录请求日志和统计用量 - 可以使用故障转移功能 ## 前提条件 使用应用接管功能前,需要先启动代理服务。 ## 开启接管 ### 操作位置 设置 → 高级 → 代理服务 → 应用接管区域 ### 操作步骤 1. 确保代理服务已启动 2. 找到「应用接管」区域 3. 为需要的应用开启开关 ### 接管开关 | 开关 | 作用 | |------|------| | Claude 接管 | 接管 Claude Code 的请求 | | Codex 接管 | 接管 Codex 的请求 | | Gemini 接管 | 接管 Gemini CLI 的请求 | 可以同时开启多个应用的接管。 ## 接管原理 ### 配置修改 开启接管后,CC Switch 会修改应用的配置文件,将 API 端点指向本地代理。 **Claude 配置变更**: ```json // 接管前 { "env": { "ANTHROPIC_BASE_URL": "https://api.anthropic.com" } } // 接管后 { "env": { "ANTHROPIC_BASE_URL": "http://127.0.0.1:15721" } } ``` **Codex 配置变更**: ```toml # 接管前 base_url = "https://api.openai.com/v1" # 接管后 base_url = "http://127.0.0.1:15721/v1" ``` **Gemini 配置变更**: ```bash # 接管前 GOOGLE_GEMINI_BASE_URL=https://generativelanguage.googleapis.com # 接管后 GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:15721 ``` ### 请求转发 代理收到请求后: 1. 识别请求来源(Claude/Codex/Gemini) 2. 查找该应用当前启用的供应商 3. 将请求转发到供应商的实际端点 4. 记录请求日志 5. 返回响应给应用 ## 接管状态指示 ### 主界面指示 开启接管后,主界面会有以下变化: - **代理 Logo 颜色**:从无色变为绿色 - **供应商卡片**:当前活跃的供应商显示绿色边框 ### 供应商卡片状态 | 状态 | 边框颜色 | 说明 | |------|----------|------| | 当前启用 | 蓝色 | 配置文件中的供应商(非代理模式) | | 代理活跃 | 绿色 | 代理实际使用的供应商 | | 普通 | 默认 | 未使用的供应商 | ## 关闭接管 ### 操作步骤 1. 在代理面板中关闭对应应用的接管开关 2. 或直接停止代理服务 ### 配置恢复 关闭接管时,CC Switch 会: 1. 将应用配置恢复到接管前的状态 2. 保存当前的请求日志 ## 接管与供应商切换 ### 接管模式下切换供应商 在接管模式下切换供应商: 1. 在主界面点击供应商的「启用」按钮 2. 代理立即使用新供应商转发请求 3. **无需重启 CLI 工具** 这是接管模式的一大优势:切换供应商即时生效。 ### 非接管模式下切换 在非接管模式下切换供应商: 1. 修改配置文件 2. 需要重启 CLI 工具才能生效 ## 多应用接管 可以同时接管多个应用,每个应用独立管理: - 独立的供应商配置 - 独立的故障转移队列 - 独立的请求统计 ## 使用场景 ### 场景一:用量监控 开启接管 + 日志记录,监控 API 使用情况。 ### 场景二:快速切换 开启接管后,切换供应商无需重启 CLI 工具。 ### 场景三:故障转移 开启接管是使用故障转移功能的前提。 ## 注意事项 ### 性能影响 代理会增加少量延迟(通常 < 10ms),对于大多数场景可以忽略。 ### 网络要求 接管模式下,CLI 工具需要能够访问本地代理地址。 ### 配置备份 开启接管前,CC Switch 会备份原始配置,关闭时恢复。 ## 常见问题 ### 接管后请求失败 检查: - 代理服务是否正常运行 - 供应商配置是否正确 - 网络是否正常 ### 关闭接管后配置未恢复 可能原因: - 代理异常退出 - 配置文件被其他程序修改 解决方法: - 手动编辑供应商,重新保存 - 或重新启用再关闭接管 ================================================ FILE: docs/user-manual/zh/4-proxy/4.3-failover.md ================================================ # 4.3 故障转移 ## 功能说明 故障转移功能在主供应商请求失败时,自动切换到备用供应商,确保服务不中断。 **适用场景**: - 供应商服务不稳定 - 需要高可用性 - 长时间运行的任务 ## 前提条件 使用故障转移功能需要: 1. ✅ 启动代理服务 2. ✅ 开启应用接管 3. ✅ 配置故障转移队列 4. ✅ 开启自动故障转移 ## 配置故障转移队列 ### 打开配置页面 设置 → 高级 → 故障转移 ### 选择应用 页面顶部有三个 Tab: - Claude - Codex - Gemini 选择要配置的应用。 ### 添加备用供应商 1. 在「故障转移队列」区域 2. 点击「添加供应商」 3. 从下拉列表选择供应商 4. 供应商会添加到队列末尾 ### 调整优先级 拖拽供应商调整顺序: - 序号越小,优先级越高 - 主供应商失败后,按顺序尝试备用供应商 ### 移除供应商 点击供应商右侧的「移除」按钮。 ## 主界面快捷操作 当代理和故障转移都开启时,供应商卡片会显示故障转移开关。 ### 添加到队列 1. 找到供应商卡片 2. 开启故障转移开关 3. 供应商自动添加到队列 ### 从队列移除 1. 关闭供应商卡片的故障转移开关 2. 供应商从队列中移除 ## 开启自动故障转移 ### 操作步骤 1. 在故障转移配置页面 2. 开启「自动故障转移」开关 ### 开关说明 | 状态 | 行为 | |------|------| | 关闭 | 仅记录失败,不自动切换 | | 开启 | 失败时自动切换到下一个供应商 | ## 故障转移流程 ```mermaid graph TD Start[请求到达代理] --> Send[发送到当前供应商] Send --> CheckSuccess{成功?} CheckSuccess -- 是 --> Return[返回响应] CheckSuccess -- 否 --> LogFail[记录失败] LogFail --> CheckCircuit{检查熔断状态} CheckCircuit -- 熔断 --> Skip[跳过此供应商] CheckCircuit -- 未熔断 --> IncFail[增加失败计数] Skip --> Next{队列中下一个?} IncFail --> Next Next -- 有 --> Switch[切换供应商] Switch --> Retry[重试请求] Retry --> Send Next -- 无 --> Error[返回错误] ``` ## 熔断器配置 熔断器防止频繁重试失败的供应商。 ### 配置项 不同应用有独立的默认配置。以下为通用默认值,Claude 有独立的宽松配置。 | 配置 | 说明 | 通用默认值 | Claude 默认值 | 范围 | |------|------|--------|--------|------| | 失败阈值 | 连续失败多少次触发熔断 | 4 | 8 | 1-20 | | 恢复成功阈值 | 半开状态下成功多少次后关闭熔断器 | 2 | 3 | 1-10 | | 恢复等待时间 | 熔断后多久尝试恢复(秒) | 60 | 90 | 0-300 | | 错误率阈值 | 错误率超过此值时打开熔断器 | 60% | 70% | 0-100% | | 最小请求数 | 计算错误率前的最小请求数 | 10 | 15 | 5-100 | > 💡 Claude 由于请求耗时较长,默认配置更为宽松,容忍更多失败次数。 ### 超时配置 | 配置 | 说明 | 通用默认值 | Claude 默认值 | 范围 | |------|------|--------|--------|------| | 流式首字节超时 | 等待首个数据块的最大时间(秒) | 60 | 90 | 1-120 | | 流式静默超时 | 数据块之间的最大间隔(秒) | 120 | 180 | 60-600(填 0 禁用) | | 非流式超时 | 非流式请求的总超时时间(秒) | 600 | 600 | 60-1200 | ### 重试配置 | 配置 | 说明 | 通用默认值 | Claude 默认值 | 范围 | |------|------|--------|--------|------| | 最大重试次数 | 请求失败时的重试次数 | 3 | 6 | 0-10 | > 💡 Gemini 的默认最大重试次数为 5。 ### 熔断状态 | 状态 | 说明 | |------|------| | 关闭 | 正常状态,允许请求 | | 开启 | 熔断状态,跳过此供应商 | | 半开 | 尝试恢复,发送试探请求 | ### 状态转换 ```mermaid stateDiagram-v2 [*] --> Closed: 初始化 Closed --> Open: 失败次数 >= 阈值 Open --> HalfOpen: 熔断时长到期 HalfOpen --> Closed: 试探成功 (>= 恢复阈值) HalfOpen --> Open: 试探失败 ``` ## 健康状态指示 ### 供应商卡片 卡片上显示健康状态徽章: | 徽章 | 状态 | 说明 | |------|------|------| | 🟢 | 健康 | 连续失败次数为 0 | | 🟡 | 警告 | 有失败但未触发熔断 | | 🔴 | 熔断 | 已触发熔断,暂时跳过 | ### 队列列表 故障转移队列中也显示每个供应商的健康状态。 ## 故障转移日志 每次故障转移会记录: | 信息 | 说明 | |------|------| | 时间 | 发生时间 | | 原供应商 | 失败的供应商 | | 新供应商 | 切换到的供应商 | | 失败原因 | 错误信息 | 在用量统计的请求日志中可以查看。 ## 最佳实践 ### 队列配置建议 1. **主供应商**:最稳定、最快的供应商 2. **第一备用**:次优选择 3. **第二备用**:保底选择 ### 熔断器配置建议 | 场景 | 失败阈值 | 熔断时长 | |------|----------|----------| | 高可用要求 | 2 | 30 秒 | | 一般场景 | 3 | 60 秒 | | 容忍偶发失败 | 5 | 120 秒 | ### 监控建议 定期检查: - 各供应商的健康状态 - 故障转移发生频率 - 熔断触发情况 ## 常见问题 ### 故障转移没有触发 检查: 1. 代理服务是否运行 2. 应用接管是否开启 3. 自动故障转移是否开启 4. 队列中是否有备用供应商 ### 频繁触发故障转移 可能原因: - 主供应商不稳定 - 网络问题 - 配置错误 解决方法: - 检查主供应商状态 - 调整熔断器参数 - 考虑更换主供应商 ### 所有供应商都熔断 等待熔断时长到期后自动恢复,或: 1. 手动重启代理服务 2. 重置熔断状态 ================================================ FILE: docs/user-manual/zh/4-proxy/4.4-usage.md ================================================ # 4.4 用量统计 ## 功能说明 用量统计功能记录和分析 API 请求数据,帮助你: - 了解 API 使用情况 - 估算费用支出 - 分析使用模式 - 排查问题 ## 前提条件 使用用量统计功能需要: 1. ✅ 启动代理服务 2. ✅ 开启应用接管 3. ✅ 开启日志记录 ## 打开用量统计 设置 → 用量 Tab ## 统计概览 ### 汇总卡片 页面顶部显示关键指标: | 指标 | 说明 | |------|------| | 总请求数 | 统计周期内的请求总数 | | 总 Token | 输入 + 输出 Token 总数 | | 估算费用 | 基于定价配置计算的费用 | | 成功率 | 成功请求的百分比 | ### 时间范围 可选择统计的时间范围: | 选项 | 范围 | |------|------| | 今日 | 当天 00:00 至今 | | 最近 7 天 | 过去 7 天 | | 最近 30 天 | 过去 30 天 | ![image-20260108011730105](../../assets/image-20260108011730105.png) ## 趋势图表 ### 请求趋势 折线图展示请求数量的变化趋势: - X 轴:时间 - Y 轴:请求数量 - 可按小时/天查看 - 支持缩放和拖拽 ### Token 趋势 展示 Token 使用量的变化: - 输入 Token(蓝色)- 用户发送的 prompt 内容 - 输出 Token(绿色)- AI 生成的回复内容 - 缓存创建 Token(橙色)- 首次创建缓存消耗的 Token - 缓存命中 Token(紫色)- 复用缓存节省的 Token - 成本(红色虚线,右侧 Y 轴)- 估算费用 > 💡 **缓存 Token 说明**:Anthropic API 支持 Prompt Caching 功能。缓存创建时收取较高费用(通常为输入价格的 1.25 倍),但后续命中缓存时只收取 0.1 倍的价格,可大幅降低重复请求的成本。 ### 时间粒度 - **今日**:按小时显示(24 个数据点) - **7 天/30 天**:按天显示 ![image-20260108011742847](../../assets/image-20260108011742847.png) ## 详细数据 页面下方有三个数据 Tab: ### 请求日志 每条请求的详细记录: | 字段 | 说明 | |------|------| | 时间 | 请求时间 | | 供应商 | 使用的供应商名称 | | 模型 | 请求的模型(计费模型) | | 输入 Token | 输入的 Token 数 | | 输出 Token | 输出的 Token 数 | | 缓存读取 | 缓存命中的 Token 数 | | 缓存创建 | 缓存创建的 Token 数 | | 总费用 | 估算费用(美元) | | 耗时信息 | 请求耗时、首 Token 时间、流式/非流式 | | 状态 | HTTP 状态码 | #### 耗时信息说明 耗时信息列显示多个徽章: | 徽章 | 说明 | 颜色规则 | |------|------|----------| | 总耗时 | 请求总时长(秒) | ≤5s 绿色,≤120s 橙色,>120s 红色 | | 首 Token | 流式请求首个 Token 时间 | ≤5s 绿色,≤120s 橙色,>120s 红色 | | 流式/非流式 | 请求类型 | 流式蓝色,非流式紫色 | #### 查看详情 点击请求行可查看详细信息: - 完整的请求参数 - 响应内容摘要 - 错误信息(如果失败) #### 筛选日志 支持按以下条件筛选: | 筛选项 | 选项 | |--------|------| | 应用类型 | 全部 / Claude / Codex / Gemini | | 状态码 | 全部 / 200 / 400 / 401 / 429 / 500 | | 供应商 | 文本搜索 | | 模型 | 文本搜索 | | 时间范围 | 开始时间 - 结束时间(日期时间选择器) | 操作按钮: - **搜索**:应用筛选条件 - **重置**:恢复默认(过去 24 小时) - **刷新**:重新加载数据 ![image-20260108011859974](../../assets/image-20260108011859974.png) ### 供应商统计 按供应商分组的统计数据: | 字段 | 说明 | |------|------| | 供应商 | 供应商名称 | | 请求数 | 该供应商的请求总数 | | 成功数 | 成功的请求数 | | 失败数 | 失败的请求数 | | 成功率 | 成功百分比 | | 总 Token | Token 使用总量 | | 估算费用 | 该供应商的费用 | ![image-20260108011907928](../../assets/image-20260108011907928.png) ### 模型统计 按模型分组的统计数据: | 字段 | 说明 | |------|------| | 模型 | 模型名称 | | 请求数 | 该模型的请求总数 | | 输入 Token | 输入 Token 总量 | | 输出 Token | 输出 Token 总量 | | 平均延迟 | 平均响应时间 | | 估算费用 | 该模型的费用 | ![image-20260108011915381](../../assets/image-20260108011915381.png) ## 定价配置 ### 打开定价配置 设置 → 高级 → 定价配置 ### 配置模型价格 为每个模型设置价格(每百万 Token): | 字段 | 说明 | |------|------| | 模型 ID | 模型标识符(如 claude-3-sonnet) | | 显示名称 | 自定义显示名称 | | 输入价格 | 每百万输入 Token 的价格 | | 输出价格 | 每百万输出 Token 的价格 | | 缓存读取价格 | 每百万缓存命中 Token 的价格 | | 缓存创建价格 | 每百万缓存创建 Token 的价格 | ### 操作 - **添加**:点击「添加」按钮新增模型定价 - **编辑**:点击行末的编辑图标修改 - **删除**:点击行末的删除图标移除 ![image-20260108011933565](../../assets/image-20260108011933565.png) ### 预设价格 CC Switch 预设了常用模型的官方价格(每百万 Token): **Claude 系列(美元)**: | 模型 | 输入 | 输出 | 缓存读取 | 缓存创建 | |------|------|------|----------|----------| | **Claude 4.5 系列** | | | | | | claude-opus-4-5 | $5 | $25 | $0.50 | $6.25 | | claude-sonnet-4-5 | $3 | $15 | $0.30 | $3.75 | | claude-haiku-4-5 | $1 | $5 | $0.10 | $1.25 | | **Claude 4 系列** | | | | | | claude-opus-4 | $15 | $75 | $1.50 | $18.75 | | claude-opus-4-1 | $15 | $75 | $1.50 | $18.75 | | claude-sonnet-4 | $3 | $15 | $0.30 | $3.75 | | **Claude 3.5 系列** | | | | | | claude-3-5-sonnet | $3 | $15 | $0.30 | $3.75 | | claude-3-5-haiku | $0.80 | $4 | $0.08 | $1.00 | **OpenAI 系列 / Codex(美元)**: | 模型 | 输入 | 输出 | 缓存读取 | |------|------|------|----------| | **GPT-5.2 系列** | | | | | gpt-5.2 | $1.75 | $14 | $0.175 | | **GPT-5.1 系列** | | | | | gpt-5.1 | $1.25 | $10 | $0.125 | | **GPT-5 系列** | | | | | gpt-5 | $1.25 | $10 | $0.125 | > 注:Codex 预设包含了 low/medium/high 等变体,价格与基础模型一致。 **Gemini 系列(美元)**: | 模型 | 输入 | 输出 | 缓存读取 | |------|------|------|----------| | **Gemini 3 系列** | | | | | gemini-3-pro-preview | $2 | $12 | $0.20 | | gemini-3-flash-preview | $0.50 | $3 | $0.05 | | **Gemini 2.5 系列** | | | | | gemini-2.5-pro | $1.25 | $10 | $0.125 | | gemini-2.5-flash | $0.30 | $2.50 | $0.03 | **中国厂商模型**: > 注:币种遵循各供应商官方定价页面。StepFun 当前按美元列出。 | 模型 | 输入 | 输出 | 缓存读取 | |------|------|------|----------| | **StepFun** | | | | | step-3.5-flash | $0.10 | $0.30 | $0.02 | | **DeepSeek** | | | | | deepseek-v3.2 | ¥2.00 | ¥3.00 | ¥0.40 | | deepseek-v3.1 | ¥4.00 | ¥12.00 | ¥0.80 | | deepseek-v3 | ¥2.00 | ¥8.00 | ¥0.40 | | **Kimi (月之暗面)** | | | | | kimi-k2-thinking | ¥4.00 | ¥16.00 | ¥1.00 | | kimi-k2 | ¥4.00 | ¥16.00 | ¥1.00 | | kimi-k2-turbo | ¥8.00 | ¥58.00 | ¥1.00 | | **MiniMax** | | | | | minimax-m2.1 | ¥2.10 | ¥8.40 | ¥0.21 | | minimax-m2.1-lightning | ¥2.10 | ¥16.80 | ¥0.21 | | **其他** | | | | | glm-4.7 | ¥2.00 | ¥8.00 | ¥0.40 | | doubao-seed-code | ¥1.20 | ¥8.00 | ¥0.24 | | mimo-v2-flash | 免费 | 免费 | - | ### 自定义价格 如果使用中转服务,价格可能不同: 1. 点击「编辑」按钮 2. 修改价格 3. 保存 ## 常见问题 ### 统计数据为空 检查: - 代理服务是否运行 - 应用接管是否开启 - 日志记录是否开启 - 是否有请求通过代理 ### 费用估算不准确 可能原因: - 定价配置与实际不符 - 使用了中转服务的特殊定价 解决方法: - 更新定价配置 - 参考供应商的实际账单 ### Token 数量与供应商不一致 CC Switch 使用自己的方式估算 Token 数,可能与供应商的计算方式略有差异。以供应商账单为准。 ================================================ FILE: docs/user-manual/zh/4-proxy/4.5-model-test.md ================================================ # 4.5 模型检查 ## 功能说明 模型检查功能用于验证供应商配置的模型是否可用,通过发送实际的 API 请求来测试: - 模型是否存在 - API Key 是否有效 - 端点是否正常响应 - 响应延迟是否正常 ## 打开配置 设置 → 高级 → 模型测试 ## 测试模型配置 为每个应用配置用于测试的模型: | 应用 | 配置项 | 默认值 | 说明 | |------|--------|--------|------| | Claude | Claude 模型 | 系统默认 | 建议使用 Haiku 系列(成本低、速度快) | | Codex | Codex 模型 | 系统默认 | 建议使用 mini 系列 | | Gemini | Gemini 模型 | 系统默认 | 建议使用 Flash 系列 | ### 模型选择建议 选择测试模型时考虑: 1. **成本**:选择价格较低的模型(如 Haiku、Mini、Flash) 2. **速度**:选择响应快的模型 3. **可用性**:选择供应商支持的模型 ## 检查参数配置 ### 超时时间 | 参数 | 说明 | 默认值 | 范围 | |------|------|--------|------| | 超时时间 | 单次请求超时 | 45 秒 | 10-120 秒 | 设置过短可能导致误判,设置过长会延迟故障检测。 ### 重试次数 | 参数 | 说明 | 默认值 | 范围 | |------|------|--------|------| | 最大重试 | 失败后重试次数 | 2 次 | 0-5 次 | 网络不稳定时建议增加重试次数。 ### 降级阈值 | 参数 | 说明 | 默认值 | 范围 | |------|------|--------|------| | 降级阈值 | 响应超过此时间标记为降级 | 6000ms | 1000-30000ms | 超过阈值的供应商会被标记为「降级」状态,但仍可使用。 ## 执行模型检查 ### 手动测试 在供应商卡片上点击「测试」按钮: 1. 发送测试请求到配置的端点 2. 使用配置的测试模型 3. 等待响应或超时 4. 显示测试结果 ### 测试内容 测试请求会: - 发送简短的 prompt(如 "Hi") - 限制最大输出 token(通常 10-50) - 使用流式响应检测首字节时间 ## 测试结果 ### 健康状态 | 状态 | 图标 | 说明 | |------|------|------| | 健康 | 🟢 | 响应正常,延迟在阈值内 | | 降级 | 🟡 | 响应正常,但延迟超过阈值 | | 不可用 | 🔴 | 请求失败或超时 | ### 结果信息 测试完成后显示: - 响应延迟(毫秒) - 首字节时间(TTFB) - 错误信息(如果失败) ## 与故障转移集成 模型检查与故障转移功能配合使用: ### 健康检查 开启代理服务后,系统会定期对故障转移队列中的供应商执行健康检查: 1. 使用配置的测试模型发送请求 2. 根据响应更新健康状态 3. 不健康的供应商会被暂时跳过 ### 熔断恢复 当供应商从熔断状态恢复时: 1. 执行模型检查验证可用性 2. 检查通过后恢复正常状态 3. 检查失败则继续熔断 ## 常见问题 ### 测试失败但实际可用 **可能原因**: - 测试模型与实际使用的模型不同 - 供应商不支持配置的测试模型 **解决方法**: - 修改测试模型为供应商支持的模型 - 检查供应商的模型列表 ### 延迟过高 **可能原因**: - 网络延迟 - 供应商服务器负载高 - 模型响应慢 **解决方法**: - 使用更快的测试模型 - 调整降级阈值 - 考虑使用镜像端点 ### 频繁超时 **可能原因**: - 超时时间设置过短 - 网络不稳定 - 供应商服务不稳定 **解决方法**: - 增加超时时间 - 增加重试次数 - 检查网络连接 ## 注意事项 - 模型检查会消耗少量 API 配额 - 建议使用低成本模型进行测试 - 测试频率不宜过高,避免浪费配额 - 不同供应商支持的模型可能不同 ================================================ FILE: docs/user-manual/zh/5-faq/5.1-config-files.md ================================================ # 5.1 配置文件说明 ## CC Switch 数据存储 ### 存储目录 默认位置:`~/.cc-switch/` 可在设置中自定义位置(用于云同步)。 ### 目录结构 ``` ~/.cc-switch/ ├── cc-switch.db # SQLite 数据库 ├── settings.json # 设备级设置 └── backups/ # 自动备份 ├── backup-20251230-120000.json ├── backup-20251229-180000.json └── ... ``` ### 数据库内容 `cc-switch.db` 是 SQLite 数据库,存储: | 表 | 内容 | |-----|------| | providers | 供应商配置 | | provider_endpoints | 供应商端点候选列表 | | mcp_servers | MCP 服务器配置 | | prompts | 提示词预设 | | skills | 技能安装状态 | | skill_repos | 技能仓库配置 | | proxy_config | 代理配置 | | proxy_request_logs | 代理请求日志 | | provider_health | 供应商健康状态 | | model_pricing | 模型定价 | | settings | 应用设置 | ### 设备设置 `settings.json` 存储设备级设置: ```json { "language": "zh", "theme": "system", "windowBehavior": "minimize", "autoStart": false, "claudeConfigDir": null, "codexConfigDir": null, "geminiConfigDir": null, "opencodeConfigDir": null, "openclawConfigDir": null } ``` 这些设置不会跨设备同步。 ### 自动备份 `backups/` 目录存储自动备份: - 每次导入配置前自动创建 - 保留最近 10 个备份 - 文件名包含时间戳 ## Claude Code 配置 ### 配置目录 默认:`~/.claude/` ### 主要文件 ``` ~/.claude/ ├── settings.json # 主配置文件 ├── CLAUDE.md # 系统提示词 └── skills/ # 技能目录 └── ... ``` ### settings.json ```json { "env": { "ANTHROPIC_API_KEY": "sk-xxx", "ANTHROPIC_BASE_URL": "https://api.anthropic.com" }, "permissions": { "allow_file_access": true } } ``` | 字段 | 说明 | |------|------| | `env.ANTHROPIC_API_KEY` | API 密钥 | | `env.ANTHROPIC_BASE_URL` | API 端点(可选) | | `env.ANTHROPIC_AUTH_TOKEN` | 替代认证方式 | ### MCP 配置 MCP 服务器配置在 `~/.claude.json`: ```json { "mcpServers": { "mcp-fetch": { "command": "uvx", "args": ["mcp-server-fetch"] } } } ``` ## Codex 配置 ### 配置目录 默认:`~/.codex/` ### 主要文件 ``` ~/.codex/ ├── auth.json # 认证配置 ├── config.toml # 主配置 + MCP └── AGENTS.md # 系统提示词 ``` ### auth.json ```json { "OPENAI_API_KEY": "sk-xxx" } ``` ### config.toml ```toml # 基础配置 base_url = "https://api.openai.com/v1" model = "gpt-4" # MCP 服务器 [mcp_servers.mcp-fetch] command = "uvx" args = ["mcp-server-fetch"] ``` ## Gemini CLI 配置 ### 配置目录 默认:`~/.gemini/` ### 主要文件 ``` ~/.gemini/ ├── .env # 环境变量(API Key) ├── settings.json # 主配置 + MCP └── GEMINI.md # 系统提示词 ``` ### .env ```bash GEMINI_API_KEY=xxx GOOGLE_GEMINI_BASE_URL=https://generativelanguage.googleapis.com GEMINI_MODEL=gemini-pro ``` ### settings.json ```json { "mcpServers": { "mcp-fetch": { "command": "uvx", "args": ["mcp-server-fetch"] } } } ``` | 字段 | 说明 | |------|------| | `mcpServers` | MCP 服务器配置 | ## OpenCode 配置 ### 配置目录 默认:`~/.opencode/` ### 主要文件 ``` ~/.opencode/ ├── config.json # 主配置文件 ├── AGENTS.md # 系统提示词 └── skills/ # 技能目录 └── ... ``` ## OpenClaw 配置 ### 配置目录 默认:`~/.openclaw/` ### 主要文件 ``` ~/.openclaw/ ├── openclaw.json # 主配置文件(JSON5 格式) ├── AGENTS.md # 系统提示词 └── skills/ # 技能目录 └── ... ``` ### openclaw.json OpenClaw 使用 JSON5 格式配置文件,主要包含以下部分: ```json5 { // 模型供应商配置 models: { mode: "merge", providers: { "custom-provider": { baseUrl: "https://api.example.com/v1", apiKey: "your-api-key", api: "openai-completions", models: [{ id: "model-id", name: "Model Name" }] } } }, // 环境变量 env: { ANTHROPIC_API_KEY: "sk-..." }, // Agent 默认模型配置 agents: { defaults: { model: { primary: "provider/model" } } }, // 工具配置 tools: {}, // 工作区文件配置 workspace: {} } ``` | 字段 | 说明 | |------|------| | `models.providers` | 供应商配置(映射为 CC Switch 的"供应商") | | `env` | 环境变量配置 | | `agents.defaults` | Agent 默认模型设置 | | `tools` | 工具配置 | | `workspace` | 工作区文件管理 | ## 配置优先级 CC Switch 修改配置时的优先级: 1. **CC Switch 数据库** - 单一事实源 (SSOT) 2. **Live 配置文件** - 切换供应商时写入 3. **回填机制** - 编辑当前供应商时从 Live 文件读取 ## 手动编辑配置 ### 可以手动编辑 - CLI 工具的配置文件(会被 CC Switch 回填) - CC Switch 的 `settings.json` ### 不建议手动编辑 - `cc-switch.db` 数据库文件 - 备份文件 ### 编辑后同步 如果手动编辑了 CLI 工具的配置: 1. 打开 CC Switch 2. 编辑对应的供应商 3. 会看到手动修改的内容已回填 4. 保存以同步到数据库 ## 配置迁移 ### 从旧版本迁移 CC Switch v3.7.0 从 JSON 文件迁移到 SQLite: - 首次启动自动迁移 - 迁移成功后显示提示 - 旧配置文件保留作为备份 ### 跨设备迁移 1. 在源设备导出配置 2. 在目标设备导入配置 3. 或使用云同步功能 ## 配置备份建议 ### 定期备份 建议定期导出配置: 1. 设置 → 高级 → 数据管理 2. 点击「导出」 3. 保存到安全位置 ### 备份内容 导出文件包含: - 所有供应商配置 - MCP 服务器配置 - Prompts 预设 - 应用设置 ### 不包含的内容 - 用量日志(数据量大) - 设备级设置(不适合跨设备) ================================================ FILE: docs/user-manual/zh/5-faq/5.2-questions.md ================================================ # 5.2 常见问题 FAQ ## 安装问题 ### macOS 提示「未知开发者」 **问题**:首次打开时提示「无法打开,因为它来自身份不明的开发者」 **解决方法一**:通过系统设置 1. 关闭警告弹窗 2. 打开「系统设置」→「隐私与安全性」 3. 找到 CC Switch 相关提示 4. 点击「仍要打开」 5. 再次打开应用 **解决方法二**:通过终端命令(推荐) ```bash sudo xattr -dr com.apple.quarantine /Applications/CC\ Switch.app/ ``` 执行后即可正常打开应用。 ### Windows 安装后无法启动 **可能原因**: - 缺少 WebView2 运行时 - 杀毒软件拦截 **解决方法**: 1. 安装 [Microsoft Edge WebView2](https://developer.microsoft.com/en-us/microsoft-edge/webview2/) 2. 将 CC Switch 添加到杀毒软件白名单 ### Linux 启动报错 **问题**:AppImage 无法启动 **解决方法**: ```bash # 添加执行权限 chmod +x CC-Switch-*.AppImage # 如果仍然失败,尝试 ./CC-Switch-*.AppImage --no-sandbox ``` ## 供应商问题 ### 切换供应商后不生效 **原因**:CLI 工具需要重新加载配置 **解决方法**: - Claude Code:关闭并重新打开终端,或重启 IDE - Codex:关闭并重新打开终端 - Gemini:托盘切换可即时生效,无需重启 ### API Key 无效 **检查步骤**: 1. 确认 API Key 正确复制(无多余空格) 2. 确认 API Key 未过期 3. 确认端点地址正确 4. 使用速度测试验证连接 ### 如何恢复官方登录 **操作步骤**: 1. 选择「官方登录」预设(Claude/Codex)或「Google 官方」预设(Gemini) 2. 点击「启用」 3. 重启对应的 CLI 工具 4. 按照 CLI 工具的登录流程操作 ## 代理问题 ### 代理服务启动失败 **可能原因**:端口被占用 **解决方法**: 1. 检查端口占用: ```bash # macOS/Linux lsof -i :49152 # Windows netstat -ano | findstr :49152 ``` 2. 关闭占用端口的程序 3. 或尝试修改配置恢复默认端口: - 打开「设置 → 代理服务」 - 点击「恢复默认」按钮 ### 代理模式下请求超时 **可能原因**: - 网络问题 - 供应商服务器问题 - 代理配置错误 **解决方法**: 1. 检查网络连接 2. 尝试直接访问供应商 API(关闭代理) 3. 检查供应商配置是否正确 ### 关闭代理后配置未恢复 **可能原因**:代理异常退出 **解决方法**: 1. 编辑当前供应商 2. 检查端点地址是否正确 3. 保存以更新配置 ## 故障转移问题 ### 故障转移没有触发 **检查清单**: - [ ] 代理服务是否运行 - [ ] 应用接管是否开启 - [ ] 自动故障转移是否开启 - [ ] 队列中是否有备用供应商 ### 频繁触发故障转移 **可能原因**: - 主供应商不稳定 - 熔断器阈值设置过低 **解决方法**: 1. 检查主供应商状态 2. 调高失败阈值(如从 3 改为 5) 3. 考虑更换主供应商 ### 所有供应商都熔断了 **解决方法**: 1. 等待熔断时长到期(默认 60 秒) 2. 或重启代理服务重置状态 ## 数据问题 ### 配置丢失 **可能原因**: - 配置目录被删除 - 数据库损坏 **解决方法**: 1. 检查 `~/.cc-switch/` 目录是否存在 2. 从备份恢复:`~/.cc-switch/backups/` 3. 或从之前导出的配置文件导入 ### 导入配置失败 **可能原因**: - 文件格式错误 - 版本不兼容 **解决方法**: 1. 确认文件是 CC Switch 导出的 JSON 文件 2. 检查文件内容是否完整 3. 尝试用文本编辑器打开检查格式 ### 用量统计数据为空 **检查清单**: - [ ] 代理服务是否运行 - [ ] 应用接管是否开启 - [ ] 日志记录是否开启 - [ ] 是否有请求通过代理 ## 其他问题 ### 托盘图标不显示 **macOS**: - 检查系统设置中的菜单栏图标设置 **Windows**: - 检查任务栏设置,确保 CC Switch 图标未被隐藏 **Linux**: - 需要安装系统托盘支持(如 `libappindicator`) ### 界面显示异常 **解决方法**: 1. 尝试切换主题(浅色/深色) 2. 重启应用 3. 删除 `~/.cc-switch/settings.json` 重置设置 ### 更新失败 **解决方法**: 1. 检查网络连接 2. 手动下载最新版本安装 3. 如使用 Homebrew:`brew upgrade --cask cc-switch` ## 获取帮助 ### 提交 Issue 如果以上方法都无法解决问题: 1. 访问 [GitHub Issues](https://github.com/farion1231/cc-switch/issues) 2. 搜索是否有类似问题 3. 如果没有,创建新 Issue 4. 提供以下信息: - 操作系统和版本 - CC Switch 版本 - 问题描述和复现步骤 - 错误信息(如有) ### 日志文件 提交 Issue 时可附上日志文件: - macOS/Linux:`~/.cc-switch/logs/` - Windows:`%APPDATA%\cc-switch\logs\` ================================================ FILE: docs/user-manual/zh/5-faq/5.3-deeplink.md ================================================ # 5.3 深度链接协议 ## 功能说明 CC Switch 支持 `ccswitch://` 深度链接协议,可以通过链接一键导入配置。 **使用场景**: - 团队共享配置 - 教程中的一键配置 - 跨设备快速同步 ## 在线生成工具 CC Switch 提供在线深度链接生成工具: **访问地址**:[https://farion1231.github.io/cc-switch/deplink.html](https://farion1231.github.io/cc-switch/deplink.html) ### 使用方法 1. 打开上述网页 2. 选择导入类型(供应商/MCP/Prompt) 3. 填写配置信息 4. 点击「生成链接」 5. 复制生成的深度链接 6. 分享给他人或在其他设备使用 ## 协议格式 ### V1 协议 使用 URL 参数格式,易读易生成: ``` ccswitch://v1/import?resource={type}&app={app}&name={name}&... ``` **通用参数**: | 参数 | 必填 | 说明 | |------|------|------| | `resource` | 是 | 资源类型:`provider` / `mcp` / `prompt` / `skill` | | `app` | 是 | 应用类型:`claude` / `codex` / `gemini` / `opencode` / `openclaw` | | `name` | 是 | 名称 | **供应商参数**(resource=provider): | 参数 | 必填 | 说明 | |------|------|------| | `endpoint` | 否 | API 端点地址(支持逗号分隔多个 URL) | | `apiKey` | 否 | API 密钥 | | `homepage` | 否 | 供应商官网 | | `model` | 否 | 默认模型 | | `haikuModel` | 否 | Haiku 模型(仅 Claude) | | `sonnetModel` | 否 | Sonnet 模型(仅 Claude) | | `opusModel` | 否 | Opus 模型(仅 Claude) | | `notes` | 否 | 备注 | | `icon` | 否 | 图标 | | `config` | 否 | Base64 编码的配置内容 | | `configFormat` | 否 | 配置格式:`json` / `toml` | | `configUrl` | 否 | 远程配置 URL | | `enabled` | 否 | 是否启用(布尔值) | | `usageScript` | 否 | 用量查询脚本 | | `usageEnabled` | 否 | 是否启用用量查询(默认 true) | | `usageApiKey` | 否 | 用量查询专用 API Key | | `usageBaseUrl` | 否 | 用量查询专用地址 | | `usageAccessToken` | 否 | 用量查询访问令牌 | | `usageUserId` | 否 | 用量查询用户 ID | | `usageAutoInterval` | 否 | 自动查询间隔(分钟) | **提示词参数**(resource=prompt): | 参数 | 必填 | 说明 | |------|------|------| | `content` | 是 | 提示词内容 | | `description` | 否 | 描述 | | `enabled` | 否 | 是否启用(布尔值) | **MCP 参数**(resource=mcp): | 参数 | 必填 | 说明 | |------|------|------| | `apps` | 是 | 应用列表(逗号分隔,如 `claude,codex,gemini,opencode`) | | `config` | 是 | MCP 服务器配置(JSON 格式) | | `enabled` | 否 | 是否启用(布尔值) | **Skill 参数**(resource=skill): | 参数 | 必填 | 说明 | |------|------|------| | `repo` | 是 | 仓库(格式:`owner/name`) | | `directory` | 否 | 目录路径 | | `branch` | 否 | Git 分支 | **示例**: ``` ccswitch://v1/import?resource=provider&app=claude&name=My%20Provider&endpoint=https%3A%2F%2Fapi.example.com&apiKey=sk-xxx ``` ## 导入类型示例 ### 导入供应商 ``` ccswitch://v1/import?resource=provider&app=claude&name=My%20Provider&endpoint=https%3A%2F%2Fapi.example.com&apiKey=sk-xxx ``` ### 导入 MCP 服务器 ``` ccswitch://v1/import?resource=mcp&apps=claude,codex&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22mcp-server-fetch%22%5D%7D&name=mcp-fetch ``` ### 导入 Prompt 预设 ``` ccswitch://v1/import?resource=prompt&app=claude&name=%E4%BB%A3%E7%A0%81%E5%AE%A1%E6%9F%A5&content=%23%20%E8%A7%92%E8%89%B2%0A%E4%BD%A0%E6%98%AF%E4%B8%80%E4%B8%AA%E4%B8%93%E4%B8%9A%E7%9A%84%E4%BB%A3%E7%A0%81%E5%AE%A1%E6%9F%A5%E4%B8%93%E5%AE%B6 ``` ### 导入 Skill ``` ccswitch://v1/import?resource=skill&name=my-skill&repo=owner/repo&directory=skills/my-skill&branch=main ``` ## 生成深度链接 ### 手动生成 1. 准备参数 2. 按 V1 协议格式拼接 URL 3. URL 编码特殊字符 **示例**: ```javascript const params = new URLSearchParams({ resource: 'provider', app: 'claude', name: 'My Provider', endpoint: 'https://api.example.com', apiKey: 'sk-xxx' }); const url = `ccswitch://v1/import?${params.toString()}`; ``` ### 在线工具 使用 CC Switch 官方提供的在线深度链接生成工具更方便。 ## 使用深度链接 ### 点击链接 在浏览器或其他应用中点击深度链接: 1. 系统会询问是否打开 CC Switch 2. 确认后 CC Switch 打开 3. 显示导入确认对话框 4. 确认导入 ### 导入确认 导入前会显示确认对话框,包含: - 导入类型 - 配置预览 - 确认/取消按钮 **安全提示**:只导入来自可信来源的配置。 ## 协议注册 ### 自动注册 CC Switch 安装时会自动注册 `ccswitch://` 协议。 ### 手动注册 如果协议未正确注册: **macOS**: 重新安装应用,或运行: ```bash /usr/bin/open -a "CC Switch" --args --register-protocol ``` **Windows**: 重新安装应用,或检查注册表: ``` HKEY_CLASSES_ROOT\ccswitch ``` **Linux**: 检查 `.desktop` 文件中的 `MimeType` 配置。 ## 安全考虑 ### 敏感信息 深度链接中可能包含敏感信息(如 API Key): - 不要在公开场合分享包含 API Key 的链接 - 分享前移除或替换敏感信息 - 使用安全渠道传输链接 ### 验证来源 导入前 CC Switch 会: 1. 验证数据格式 2. 显示配置预览 3. 要求用户确认 ### 恶意链接防护 CC Switch 会检查: - 数据格式是否合法 - 必填字段是否完整 - 配置值是否在合理范围 ## 示例链接 ### 示例:导入 Claude 供应商 ``` ccswitch://v1/import?resource=provider&app=claude&name=Test%20Provider&apiKey=sk-xxx&endpoint=https%3A%2F%2Fapi.example.com ``` ### 示例:导入 MCP 服务器 ``` ccswitch://v1/import?resource=mcp&name=mcp-fetch&apps=claude,codex,gemini&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22mcp-server-fetch%22%5D%7D ``` ## 故障排除 ### 链接无法打开 **检查**: 1. CC Switch 是否已安装 2. 协议是否正确注册 3. 链接格式是否正确 ### 导入失败 **可能原因**: - Base64 编码错误 - JSON 格式错误 - 缺少必填字段 **解决方法**: 1. 检查原始 JSON 格式 2. 重新进行 Base64 编码 3. 确保所有必填字段都存在 ================================================ FILE: docs/user-manual/zh/5-faq/5.4-env-conflict.md ================================================ # 5.4 环境变量冲突 ## 功能说明 CC Switch 会自动检测系统环境变量与应用配置的冲突,避免配置被意外覆盖。 **检测的环境变量**: - `ANTHROPIC_API_KEY` - Claude API 密钥 - `ANTHROPIC_BASE_URL` - Claude API 端点 - `OPENAI_API_KEY` - OpenAI API 密钥 - `GEMINI_API_KEY` - Gemini API 密钥 - 其他相关环境变量 ## 冲突警告 当检测到冲突时,界面顶部会显示黄色警告横幅: ``` ⚠️ 检测到环境变量冲突 发现 X 个环境变量可能与 CC Switch 配置冲突 [展开] [关闭] ``` ## 查看冲突详情 点击「展开」按钮查看详细信息: | 字段 | 说明 | |------|------| | 变量名 | 环境变量名称 | | 变量值 | 当前设置的值 | | 来源 | 变量的来源位置 | ### 来源类型 | 来源 | 说明 | |------|------| | 用户注册表 | Windows 用户级环境变量 | | 系统注册表 | Windows 系统级环境变量 | | Shell 配置 | macOS/Linux 的 shell 配置文件 | | 系统环境 | 系统级环境变量 | ## 处理冲突 ### 选择要删除的变量 1. 勾选要删除的环境变量 2. 或点击「全选」选择所有冲突变量 ### 删除变量 1. 点击「删除选中」按钮 2. 确认删除操作 3. CC Switch 会自动备份并删除选中的变量 ### 自动备份 删除前会自动备份: - 备份位置:`~/.cc-switch/env-backups/` - 备份格式:JSON 文件 - 包含变量名、值、来源等信息 ## 忽略警告 如果确认冲突不影响使用,可以: 1. 点击警告横幅右侧的「关闭」按钮 2. 警告会暂时隐藏 3. 下次启动时会重新检测 ## 手动处理 如果不想通过 CC Switch 删除,可以手动处理: ### Windows 1. 打开「系统属性 → 高级 → 环境变量」 2. 在用户变量或系统变量中找到冲突变量 3. 删除或修改变量 ### macOS / Linux 1. 编辑 shell 配置文件(如 `~/.zshrc`、`~/.bashrc`) 2. 删除或注释掉相关的 `export` 语句 3. 重新加载配置:`source ~/.zshrc` ## 为什么会冲突 环境变量的优先级通常高于配置文件,可能导致: - CC Switch 设置的供应商配置被覆盖 - API 请求发送到错误的端点 - 使用错误的 API 密钥 ## 最佳实践 1. **使用 CC Switch 管理配置**:避免在系统环境变量中设置 API 密钥 2. **定期检查**:关注冲突警告,及时处理 3. **备份重要变量**:删除前确认已备份 ## 恢复已删除的变量 如果误删了环境变量: 1. 找到备份文件:`~/.cc-switch/env-backups/` 2. 打开对应的 JSON 文件 3. 手动恢复变量到系统环境 ================================================ FILE: docs/user-manual/zh/README.md ================================================ # CC Switch 用户手册 > Claude Code / Codex / Gemini CLI / OpenCode / OpenClaw 全方位辅助工具 ## 目录结构 ``` 📚 CC Switch 用户手册 │ ├── 1. 快速入门 │ ├── 1.1 软件介绍 │ ├── 1.2 安装指南 │ ├── 1.3 界面概览 │ ├── 1.4 快速上手 │ └── 1.5 个性化配置 │ ├── 2. 供应商管理 │ ├── 2.1 添加供应商 │ ├── 2.2 切换供应商 │ ├── 2.3 编辑供应商 │ ├── 2.4 排序与复制 │ └── 2.5 用量查询 │ ├── 3. 扩展功能 │ ├── 3.1 MCP 服务器管理 │ ├── 3.2 Prompts 提示词管理 │ └── 3.3 Skills 技能管理 │ ├── 4. 代理与高可用 │ ├── 4.1 代理服务 │ ├── 4.2 应用接管 │ ├── 4.3 故障转移 │ ├── 4.4 用量统计 │ └── 4.5 模型检查 │ └── 5. 常见问题 ├── 5.1 配置文件说明 ├── 5.2 FAQ ├── 5.3 深度链接协议 └── 5.4 环境变量冲突 ``` ## 文件列表 ### 1. 快速入门 | 文件 | 内容 | |------|------| | [1.1-introduction.md](./1-getting-started/1.1-introduction.md) | 软件介绍、核心功能、支持平台 | | [1.2-installation.md](./1-getting-started/1.2-installation.md) | Windows/macOS/Linux 安装指南 | | [1.3-interface.md](./1-getting-started/1.3-interface.md) | 界面布局、导航栏、供应商卡片说明 | | [1.4-quickstart.md](./1-getting-started/1.4-quickstart.md) | 5 分钟快速上手教程 | | [1.5-settings.md](./1-getting-started/1.5-settings.md) | 语言、主题、目录、云同步配置 | ### 2. 供应商管理 | 文件 | 内容 | |------|------| | [2.1-add.md](./2-providers/2.1-add.md) | 使用预设、自定义配置、统一供应商 | | [2.2-switch.md](./2-providers/2.2-switch.md) | 主界面切换、托盘切换、生效方式 | | [2.3-edit.md](./2-providers/2.3-edit.md) | 编辑配置、修改 API Key、回填机制 | | [2.4-sort-duplicate.md](./2-providers/2.4-sort-duplicate.md) | 拖拽排序、复制供应商、删除 | | [2.5-usage-query.md](./2-providers/2.5-usage-query.md) | 用量查询、剩余额度、多套餐显示 | ### 3. 扩展功能 | 文件 | 内容 | |------|------| | [3.1-mcp.md](./3-extensions/3.1-mcp.md) | MCP 协议、添加服务器、应用绑定 | | [3.2-prompts.md](./3-extensions/3.2-prompts.md) | 创建预设、激活切换、智能回填 | | [3.3-skills.md](./3-extensions/3.3-skills.md) | 发现技能、安装卸载、仓库管理 | ### 4. 代理与高可用 | 文件 | 内容 | |------|------| | [4.1-service.md](./4-proxy/4.1-service.md) | 启动代理、配置项、运行状态 | | [4.2-takeover.md](./4-proxy/4.2-takeover.md) | 应用接管、配置修改、状态指示 | | [4.3-failover.md](./4-proxy/4.3-failover.md) | 故障转移队列、熔断器、健康状态 | | [4.4-usage.md](./4-proxy/4.4-usage.md) | 用量统计、趋势图表、定价配置 | | [4.5-model-test.md](./4-proxy/4.5-model-test.md) | 模型检查、健康检测、延迟测试 | ### 5. 常见问题 | 文件 | 内容 | |------|------| | [5.1-config-files.md](./5-faq/5.1-config-files.md) | CC Switch 存储、CLI 配置文件格式 | | [5.2-questions.md](./5-faq/5.2-questions.md) | 常见问题解答 | | [5.3-deeplink.md](./5-faq/5.3-deeplink.md) | 深度链接协议、生成和使用方法 | | [5.4-env-conflict.md](./5-faq/5.4-env-conflict.md) | 环境变量冲突检测与处理 | ## 快速链接 - **新用户**:从 [1.1 软件介绍](./1-getting-started/1.1-introduction.md) 开始 - **安装问题**:查看 [1.2 安装指南](./1-getting-started/1.2-installation.md) - **配置供应商**:查看 [2.1 添加供应商](./2-providers/2.1-add.md) - **使用代理**:查看 [4.1 代理服务](./4-proxy/4.1-service.md) - **遇到问题**:查看 [5.2 FAQ](./5-faq/5.2-questions.md) ## 版本信息 - 文档版本:v3.12.0 - 最后更新:2026-03-09 - 适用于 CC Switch v3.12.0+ ## 贡献 欢迎提交 Issue 或 PR 改进文档: - [GitHub Issues](https://github.com/farion1231/cc-switch/issues) - [GitHub Repository](https://github.com/farion1231/cc-switch) ================================================ FILE: flatpak/README.md ================================================ # Flatpak Build Guide This directory contains the Flatpak manifest (`com.ccswitch.desktop`) for CC Switch, used to convert the generated `.deb` artifact into an installable `.flatpak` package via CI or local builds. ## Dependencies - `flatpak` - `flatpak-builder` - Flathub remote (for installing `org.gnome.Platform//46` runtime) For Ubuntu/Debian: ```bash sudo apt install flatpak flatpak-builder flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo flatpak install -y --user flathub org.gnome.Platform//46 org.gnome.Sdk//46 ``` ## Local Build (Generate .flatpak from .deb) 1) Build the deb on Linux first: ```bash pnpm tauri build -- --bundles deb ``` 2) Copy the generated deb to this directory: ```bash cp "$(find src-tauri/target/release/bundle -name '*.deb' | head -n 1)" flatpak/cc-switch.deb ``` 3) Build the local Flatpak repository and export the `.flatpak`: ```bash flatpak-builder --force-clean --user --disable-cache --repo flatpak-repo flatpak-build flatpak/com.ccswitch.desktop.yml flatpak build-bundle --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo flatpak-repo CC-Switch-Linux.flatpak com.ccswitch.desktop ``` 4) Install and run: ```bash flatpak install --user ./CC-Switch-Linux.flatpak flatpak run com.ccswitch.desktop ``` ## Permissions Note The current manifest uses `--filesystem=home` by default for "download and run" convenience, allowing the app to directly read/write CLI configuration files and app data on the host (and supporting the "directory override" feature). If you prefer minimal permissions (e.g., for Flathub submission or security concerns), you can replace `--filesystem=home` in `flatpak/com.ccswitch.desktop.yml` with more precise grants: ```yaml - --filesystem=~/.cc-switch:create - --filesystem=~/.claude:create - --filesystem=~/.claude.json - --filesystem=~/.codex:create - --filesystem=~/.gemini:create ``` Note: Flatpak's `:create` modifier only works with directories, not files. Therefore, `~/.claude.json` cannot use `:create`. If this file doesn't exist on the user's machine, the app may not be able to create it with restricted permissions. Users should either run Claude Code once to generate it, or manually create an empty JSON file (content: `{}`). If you plan to publish on Flathub or want stricter permission control, adjust the `finish-args` in `flatpak/com.ccswitch.desktop.yml` accordingly. ================================================ FILE: flatpak/com.ccswitch.desktop.desktop ================================================ [Desktop Entry] Type=Application Name=CC Switch Comment=All-in-One Assistant for Claude Code, Codex & Gemini CLI Exec=cc-switch Icon=com.ccswitch.desktop Terminal=false Categories=Utility;Development; StartupNotify=true ================================================ FILE: flatpak/com.ccswitch.desktop.metainfo.xml ================================================ com.ccswitch.desktop CC Switch All-in-One Assistant for Claude Code, Codex & Gemini CLI CC0-1.0 MIT

CC Switch is a cross-platform desktop app for managing and switching provider configurations for Claude Code, Codex, and Gemini CLI.

  • Manage multiple provider configurations and endpoints
  • One-click switch and sync to client live configurations
  • MCP servers and Prompt/Skills management
com.ccswitch.desktop.desktop cc-switch https://github.com/farion1231/cc-switch https://github.com/farion1231/cc-switch/issues
================================================ FILE: flatpak/com.ccswitch.desktop.yml ================================================ id: com.ccswitch.desktop runtime: org.gnome.Platform runtime-version: '46' sdk: org.gnome.Sdk command: cc-switch finish-args: - --share=ipc - --share=network - --socket=wayland - --socket=fallback-x11 - --device=dri # Tray icon permissions (required by Tauri tray-icon) - --talk-name=org.kde.StatusNotifierWatcher - --filesystem=xdg-run/tray-icon:create # GitHub Releases scenario: Users download and install manually. # For "download and run" convenience (needs read/write access to ~/.cc-switch, ~/.claude, ~/.claude.json, ~/.codex, ~/.gemini, # and supports custom directory overrides), we grant full Home access by default. # If you plan to publish on Flathub or prefer minimal permissions, replace this with more precise directory grants (see flatpak/README.md). - --filesystem=home modules: # Required for libdbusmenu build (intltool was removed from GNOME SDK since 2019) - name: intltool cleanup: - "*" sources: - type: archive url: https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz sha256: 67c74d94196b153b774ab9f89b2fa6c6ba79352407037c8c14d5aeb334e959cd # Required for tray icon support - name: libayatana-ido buildsystem: cmake-ninja config-opts: - -DENABLE_TESTS=NO sources: - type: git url: https://github.com/AyatanaIndicators/ayatana-ido.git tag: 0.10.4 - name: libdbusmenu-gtk3 buildsystem: autotools build-options: cflags: -Wno-error config-opts: - --with-gtk=3 - --disable-dumper - --disable-static - --disable-nls sources: - type: archive url: https://launchpad.net/libdbusmenu/16.04/16.04.0/+download/libdbusmenu-16.04.0.tar.gz sha256: b9cc4a2acd74509435892823607d966d424bd9ad5d0b00938f27240a1bfa878a - name: libayatana-indicator buildsystem: cmake-ninja config-opts: - -DENABLE_TESTS=NO - -DENABLE_IDO=YES sources: - type: git url: https://github.com/AyatanaIndicators/libayatana-indicator.git tag: 0.9.4 - name: libayatana-appindicator buildsystem: cmake-ninja config-opts: - -DENABLE_BINDINGS_MONO=NO - -DENABLE_BINDINGS_VALA=NO sources: - type: git url: https://github.com/AyatanaIndicators/libayatana-appindicator.git tag: 0.5.93 - name: cc-switch buildsystem: simple sources: # Placed in flatpak/ directory by CI or local build script - type: file path: cc-switch.deb - type: file path: com.ccswitch.desktop.desktop - type: file path: com.ccswitch.desktop.metainfo.xml - type: file path: ../src-tauri/icons/128x128.png build-commands: - ar -x *.deb - tar -xf data.tar.* - cp -a usr/* /app/ # Use our own desktop/metainfo/icon to align with Flatpak app id - rm -f /app/share/applications/*.desktop - install -Dm644 com.ccswitch.desktop.desktop /app/share/applications/com.ccswitch.desktop.desktop - install -Dm644 com.ccswitch.desktop.metainfo.xml /app/share/metainfo/com.ccswitch.desktop.metainfo.xml - install -Dm644 128x128.png /app/share/icons/hicolor/128x128/apps/com.ccswitch.desktop.png ================================================ FILE: package.json ================================================ { "name": "cc-switch", "version": "3.12.3", "description": "All-in-One Assistant for Claude Code, Codex & Gemini CLI", "type": "module", "scripts": { "dev": "pnpm tauri dev", "build": "pnpm tauri build", "tauri": "tauri", "dev:renderer": "vite", "build:renderer": "vite build", "typecheck": "tsc --noEmit", "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,json}\"", "format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,css,json}\"", "test:unit": "vitest run", "test:unit:watch": "vitest watch" }, "keywords": [], "author": "Jason Young", "license": "MIT", "devDependencies": { "@tauri-apps/cli": "^2.8.0", "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.0.1", "@testing-library/user-event": "^14.5.2", "@types/node": "^20.0.0", "@types/react": "^18.2.0", "@types/react-dom": "^18.2.0", "@vitejs/plugin-react": "^4.2.0", "autoprefixer": "^10.4.20", "code-inspector-plugin": "^1.3.3", "cross-fetch": "^4.1.0", "jsdom": "^25.0.0", "msw": "^2.11.6", "postcss": "^8.4.49", "prettier": "^3.6.2", "tailwindcss": "^3.4.17", "typescript": "^5.3.0", "vite": "^7.3.0", "vitest": "^2.0.5" }, "dependencies": { "@codemirror/lang-javascript": "^6.2.4", "@codemirror/lang-json": "^6.0.2", "@codemirror/lang-markdown": "^6.5.0", "@codemirror/lint": "^6.8.5", "@codemirror/state": "^6.5.2", "@codemirror/theme-one-dark": "^6.1.3", "@codemirror/view": "^6.38.2", "@dnd-kit/core": "^6.3.1", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", "@hookform/resolvers": "^5.2.2", "@lobehub/icons-static-svg": "^1.73.0", "@radix-ui/react-accordion": "^1.2.12", "@radix-ui/react-checkbox": "^1.3.3", "@radix-ui/react-collapsible": "^1.1.12", "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-label": "^2.1.7", "@radix-ui/react-popover": "^1.1.15", "@radix-ui/react-scroll-area": "^1.2.10", "@radix-ui/react-select": "^2.2.6", "@radix-ui/react-slot": "^1.2.3", "@radix-ui/react-switch": "^1.2.6", "@radix-ui/react-tabs": "^1.1.13", "@radix-ui/react-tooltip": "^1.2.8", "@radix-ui/react-visually-hidden": "^1.2.4", "@tanstack/react-query": "^5.90.3", "@tauri-apps/api": "^2.8.0", "@tauri-apps/plugin-dialog": "^2.4.0", "@tauri-apps/plugin-process": "^2.0.0", "@tauri-apps/plugin-store": "^2.0.0", "@tauri-apps/plugin-updater": "^2.0.0", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "^1.1.1", "codemirror": "^6.0.2", "flexsearch": "^0.8.212", "framer-motion": "^12.23.25", "i18next": "^25.5.2", "jsonc-parser": "^3.2.1", "lucide-react": "^0.542.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-hook-form": "^7.65.0", "react-i18next": "^16.0.0", "recharts": "^3.5.1", "smol-toml": "^1.4.2", "sonner": "^2.0.7", "tailwind-merge": "^3.3.1", "zod": "^4.1.12" } } ================================================ FILE: pnpm-workspace.yaml ================================================ packages: [] onlyBuiltDependencies: - '@tailwindcss/oxide' ================================================ FILE: postcss.config.cjs ================================================ module.exports = { plugins: { tailwindcss: {}, autoprefixer: {}, }, }; ================================================ FILE: scripts/extract-icons.js ================================================ const fs = require('fs'); const path = require('path'); // 要提取的图标列表(按分类组织) const ICONS_TO_EXTRACT = { // AI 服务商(必需) aiProviders: [ 'openai', 'anthropic', 'claude', 'google', 'gemini', 'deepseek', 'kimi', 'moonshot', 'stepfun', 'zhipu', 'minimax', 'baidu', 'alibaba', 'tencent', 'meta', 'microsoft', 'cohere', 'perplexity', 'mistral', 'huggingface' ], // 云平台 cloudPlatforms: [ 'aws', 'azure', 'huawei', 'cloudflare' ], // 开发工具 devTools: [ 'github', 'gitlab', 'docker', 'kubernetes', 'vscode' ], // 其他 others: [ 'settings', 'folder', 'file', 'link' ] }; // 合并所有图标 const ALL_ICONS = [ ...ICONS_TO_EXTRACT.aiProviders, ...ICONS_TO_EXTRACT.cloudPlatforms, ...ICONS_TO_EXTRACT.devTools, ...ICONS_TO_EXTRACT.others ]; // 提取逻辑 const OUTPUT_DIR = path.join(__dirname, '../src/icons/extracted'); const SOURCE_DIR = path.join(__dirname, '../node_modules/@lobehub/icons-static-svg/icons'); // 确保输出目录存在 if (!fs.existsSync(OUTPUT_DIR)) { fs.mkdirSync(OUTPUT_DIR, { recursive: true }); } console.log('🎨 CC-Switch Icon Extractor\n'); console.log('========================================'); console.log('📦 Extracting icons...\n'); let extracted = 0; let notFound = []; // 提取图标 ALL_ICONS.forEach(iconName => { const sourceFile = path.join(SOURCE_DIR, `${iconName}.svg`); const targetFile = path.join(OUTPUT_DIR, `${iconName}.svg`); if (fs.existsSync(sourceFile)) { fs.copyFileSync(sourceFile, targetFile); console.log(` ✓ ${iconName}.svg`); extracted++; } else if (fs.existsSync(targetFile)) { console.log(` ✓ ${iconName}.svg (kept local custom icon)`); extracted++; } else { console.log(` ✗ ${iconName}.svg (not found)`); notFound.push(iconName); } }); // 生成索引文件 console.log('\n📝 Generating index file...\n'); const indexContent = `// Auto-generated icon index // Do not edit manually export const icons: Record = { ${ALL_ICONS.filter(name => !notFound.includes(name)) .map(name => { const svg = fs.readFileSync(path.join(OUTPUT_DIR, `${name}.svg`), 'utf-8'); const escaped = svg.replace(/`/g, '\\`').replace(/\$/g, '\\$'); return ` '${name}': \`${escaped}\`,`; }) .join('\n')} }; export const iconList = Object.keys(icons); export function getIcon(name: string): string { return icons[name.toLowerCase()] || ''; } export function hasIcon(name: string): boolean { return name.toLowerCase() in icons; } `; fs.writeFileSync(path.join(OUTPUT_DIR, 'index.ts'), indexContent); console.log('✓ Generated: src/icons/extracted/index.ts'); // 生成图标元数据 const metadataContent = `// Icon metadata for search and categorization import { IconMetadata } from '@/types/icon'; export const iconMetadata: Record = { // AI Providers openai: { name: 'openai', displayName: 'OpenAI', category: 'ai-provider', keywords: ['gpt', 'chatgpt'], defaultColor: '#00A67E' }, anthropic: { name: 'anthropic', displayName: 'Anthropic', category: 'ai-provider', keywords: ['claude'], defaultColor: '#D4915D' }, claude: { name: 'claude', displayName: 'Claude', category: 'ai-provider', keywords: ['anthropic'], defaultColor: '#D4915D' }, google: { name: 'google', displayName: 'Google', category: 'ai-provider', keywords: ['gemini', 'bard'], defaultColor: '#4285F4' }, gemini: { name: 'gemini', displayName: 'Gemini', category: 'ai-provider', keywords: ['google'], defaultColor: '#4285F4' }, deepseek: { name: 'deepseek', displayName: 'DeepSeek', category: 'ai-provider', keywords: ['deep', 'seek'], defaultColor: '#1E88E5' }, moonshot: { name: 'moonshot', displayName: 'Moonshot', category: 'ai-provider', keywords: ['kimi', 'moonshot'], defaultColor: '#6366F1' }, kimi: { name: 'kimi', displayName: 'Kimi', category: 'ai-provider', keywords: ['moonshot'], defaultColor: '#6366F1' }, stepfun: { name: 'stepfun', displayName: 'StepFun', category: 'ai-provider', keywords: ['stepfun', 'step', 'jieyue', '阶跃星辰'], defaultColor: '#005AFF' }, zhipu: { name: 'zhipu', displayName: 'Zhipu AI', category: 'ai-provider', keywords: ['chatglm', 'glm'], defaultColor: '#0F62FE' }, minimax: { name: 'minimax', displayName: 'MiniMax', category: 'ai-provider', keywords: ['minimax'], defaultColor: '#FF6B6B' }, baidu: { name: 'baidu', displayName: 'Baidu', category: 'ai-provider', keywords: ['ernie', 'wenxin'], defaultColor: '#2932E1' }, alibaba: { name: 'alibaba', displayName: 'Alibaba', category: 'ai-provider', keywords: ['qwen', 'tongyi'], defaultColor: '#FF6A00' }, tencent: { name: 'tencent', displayName: 'Tencent', category: 'ai-provider', keywords: ['hunyuan'], defaultColor: '#00A4FF' }, meta: { name: 'meta', displayName: 'Meta', category: 'ai-provider', keywords: ['facebook', 'llama'], defaultColor: '#0081FB' }, microsoft: { name: 'microsoft', displayName: 'Microsoft', category: 'ai-provider', keywords: ['copilot', 'azure'], defaultColor: '#00A4EF' }, cohere: { name: 'cohere', displayName: 'Cohere', category: 'ai-provider', keywords: ['cohere'], defaultColor: '#39594D' }, perplexity: { name: 'perplexity', displayName: 'Perplexity', category: 'ai-provider', keywords: ['perplexity'], defaultColor: '#20808D' }, mistral: { name: 'mistral', displayName: 'Mistral', category: 'ai-provider', keywords: ['mistral'], defaultColor: '#FF7000' }, huggingface: { name: 'huggingface', displayName: 'Hugging Face', category: 'ai-provider', keywords: ['huggingface', 'hf'], defaultColor: '#FFD21E' }, // Cloud Platforms aws: { name: 'aws', displayName: 'AWS', category: 'cloud', keywords: ['amazon', 'cloud'], defaultColor: '#FF9900' }, azure: { name: 'azure', displayName: 'Azure', category: 'cloud', keywords: ['microsoft', 'cloud'], defaultColor: '#0078D4' }, huawei: { name: 'huawei', displayName: 'Huawei', category: 'cloud', keywords: ['huawei', 'cloud'], defaultColor: '#FF0000' }, cloudflare: { name: 'cloudflare', displayName: 'Cloudflare', category: 'cloud', keywords: ['cloudflare', 'cdn'], defaultColor: '#F38020' }, // Dev Tools github: { name: 'github', displayName: 'GitHub', category: 'tool', keywords: ['git', 'version control'], defaultColor: '#181717' }, gitlab: { name: 'gitlab', displayName: 'GitLab', category: 'tool', keywords: ['git', 'version control'], defaultColor: '#FC6D26' }, docker: { name: 'docker', displayName: 'Docker', category: 'tool', keywords: ['container'], defaultColor: '#2496ED' }, kubernetes: { name: 'kubernetes', displayName: 'Kubernetes', category: 'tool', keywords: ['k8s', 'container'], defaultColor: '#326CE5' }, vscode: { name: 'vscode', displayName: 'VS Code', category: 'tool', keywords: ['editor', 'ide'], defaultColor: '#007ACC' }, // Others settings: { name: 'settings', displayName: 'Settings', category: 'other', keywords: ['config', 'preferences'], defaultColor: '#6B7280' }, folder: { name: 'folder', displayName: 'Folder', category: 'other', keywords: ['directory'], defaultColor: '#6B7280' }, file: { name: 'file', displayName: 'File', category: 'other', keywords: ['document'], defaultColor: '#6B7280' }, link: { name: 'link', displayName: 'Link', category: 'other', keywords: ['url', 'hyperlink'], defaultColor: '#6B7280' }, }; export function getIconMetadata(name: string): IconMetadata | undefined { return iconMetadata[name.toLowerCase()]; } export function searchIcons(query: string): string[] { const lowerQuery = query.toLowerCase(); return Object.values(iconMetadata) .filter(meta => meta.name.includes(lowerQuery) || meta.displayName.toLowerCase().includes(lowerQuery) || meta.keywords.some(k => k.includes(lowerQuery)) ) .map(meta => meta.name); } `; fs.writeFileSync(path.join(OUTPUT_DIR, 'metadata.ts'), metadataContent); console.log('✓ Generated: src/icons/extracted/metadata.ts'); // 生成 README const readmeContent = `# Extracted Icons This directory contains extracted icons from @lobehub/icons-static-svg. ## Statistics - Total extracted: ${extracted} icons - Not found: ${notFound.length} icons ## Extracted Icons ${ALL_ICONS.filter(name => !notFound.includes(name)).map(name => `- ${name}`).join('\n')} ${notFound.length > 0 ? `\n## Not Found\n${notFound.map(name => `- ${name}`).join('\n')}` : ''} ## Usage \`\`\`typescript import { getIcon, hasIcon, iconList } from './extracted'; // Get icon SVG const svg = getIcon('openai'); // Check if icon exists if (hasIcon('openai')) { // ... } // Get all available icons console.log(iconList); \`\`\` --- Last updated: ${new Date().toISOString()} Generated by: scripts/extract-icons.js `; fs.writeFileSync(path.join(OUTPUT_DIR, 'README.md'), readmeContent); console.log('✓ Generated: src/icons/extracted/README.md'); console.log('\n========================================'); console.log('✅ Extraction complete!\n'); console.log(` ✓ Extracted: ${extracted} icons`); console.log(` ✗ Not found: ${notFound.length} icons`); console.log(` 📉 Bundle size reduction: ~${Math.round((1 - extracted / 723) * 100)}%`); console.log('========================================\n'); ================================================ FILE: scripts/filter-icons.js ================================================ const fs = require('fs'); const path = require('path'); const ICONS_DIR = path.join(__dirname, '../src/icons/extracted'); // List of "Famous" icons to keep // Based on common AI providers and tools const KEEP_LIST = [ // AI Providers 'openai', 'anthropic', 'claude', 'google', 'gemini', 'gemma', 'palm', 'microsoft', 'azure', 'copilot', 'meta', 'llama', 'alibaba', 'qwen', 'tencent', 'hunyuan', 'baidu', 'wenxin', 'bytedance', 'doubao', 'deepseek', 'moonshot', 'kimi', 'stepfun', 'zhipu', 'chatglm', 'glm', 'minimax', 'mistral', 'cohere', 'perplexity', 'huggingface', 'midjourney', 'stability', 'xai', 'grok', 'yi', 'zeroone', 'ollama', 'packycode', // Cloud/Tools 'aws', 'googlecloud', 'huawei', 'cloudflare', 'github', 'githubcopilot', 'vercel', 'notion', 'discord', 'gitlab', 'docker', 'kubernetes', 'vscode', 'settings', 'folder', 'file', 'link' ]; // Get all SVG files const files = fs.readdirSync(ICONS_DIR).filter(file => file.endsWith('.svg')); console.log(`Scanning ${files.length} files...`); let keptCount = 0; let deletedCount = 0; let renamedCount = 0; // First pass: Identify files to keep and prefer color versions const fileMap = {}; // name -> { hasColor: bool, hasMono: bool } files.forEach(file => { const isColor = file.endsWith('-color.svg'); const baseName = isColor ? file.replace('-color.svg', '') : file.replace('.svg', ''); if (!fileMap[baseName]) { fileMap[baseName] = { hasColor: false, hasMono: false }; } if (isColor) { fileMap[baseName].hasColor = true; } else { fileMap[baseName].hasMono = true; } }); // Second pass: Process files Object.keys(fileMap).forEach(baseName => { const info = fileMap[baseName]; const shouldKeep = KEEP_LIST.includes(baseName); if (!shouldKeep) { // Delete both versions if not in keep list if (info.hasColor) { fs.unlinkSync(path.join(ICONS_DIR, `${baseName}-color.svg`)); deletedCount++; } if (info.hasMono) { fs.unlinkSync(path.join(ICONS_DIR, `${baseName}.svg`)); deletedCount++; } return; } // If keeping, prefer color if (info.hasColor) { // Rename color version to base version (overwrite mono if exists) const colorPath = path.join(ICONS_DIR, `${baseName}-color.svg`); const targetPath = path.join(ICONS_DIR, `${baseName}.svg`); try { // If mono exists, it will be overwritten/replaced fs.renameSync(colorPath, targetPath); renamedCount++; keptCount++; } catch (e) { console.error(`Error renaming ${baseName}:`, e); } } else if (info.hasMono) { // Keep mono if no color version keptCount++; } }); console.log(`\nCleanup complete:`); console.log(`- Kept: ${keptCount}`); console.log(`- Deleted: ${deletedCount}`); console.log(`- Renamed (Color -> Standard): ${renamedCount}`); // Regenerate index and metadata require('./generate-icon-index.js'); ================================================ FILE: scripts/generate-icon-index.js ================================================ const fs = require('fs'); const path = require('path'); const ICONS_DIR = path.join(__dirname, '../src/icons/extracted'); const INDEX_FILE = path.join(ICONS_DIR, 'index.ts'); const METADATA_FILE = path.join(ICONS_DIR, 'metadata.ts'); // Known metadata from previous configuration const KNOWN_METADATA = { openai: { name: 'openai', displayName: 'OpenAI', category: 'ai-provider', keywords: ['gpt', 'chatgpt'], defaultColor: '#00A67E' }, anthropic: { name: 'anthropic', displayName: 'Anthropic', category: 'ai-provider', keywords: ['claude'], defaultColor: '#D4915D' }, claude: { name: 'claude', displayName: 'Claude', category: 'ai-provider', keywords: ['anthropic'], defaultColor: '#D4915D' }, google: { name: 'google', displayName: 'Google', category: 'ai-provider', keywords: ['gemini', 'bard'], defaultColor: '#4285F4' }, gemini: { name: 'gemini', displayName: 'Gemini', category: 'ai-provider', keywords: ['google'], defaultColor: '#4285F4' }, deepseek: { name: 'deepseek', displayName: 'DeepSeek', category: 'ai-provider', keywords: ['deep', 'seek'], defaultColor: '#1E88E5' }, moonshot: { name: 'moonshot', displayName: 'Moonshot', category: 'ai-provider', keywords: ['kimi', 'moonshot'], defaultColor: '#6366F1' }, kimi: { name: 'kimi', displayName: 'Kimi', category: 'ai-provider', keywords: ['moonshot'], defaultColor: '#6366F1' }, stepfun: { name: 'stepfun', displayName: 'StepFun', category: 'ai-provider', keywords: ['stepfun', 'step', 'jieyue', '阶跃星辰'], defaultColor: '#005AFF' }, zhipu: { name: 'zhipu', displayName: 'Zhipu AI', category: 'ai-provider', keywords: ['chatglm', 'glm'], defaultColor: '#0F62FE' }, minimax: { name: 'minimax', displayName: 'MiniMax', category: 'ai-provider', keywords: ['minimax'], defaultColor: '#FF6B6B' }, baidu: { name: 'baidu', displayName: 'Baidu', category: 'ai-provider', keywords: ['ernie', 'wenxin'], defaultColor: '#2932E1' }, alibaba: { name: 'alibaba', displayName: 'Alibaba', category: 'ai-provider', keywords: ['qwen', 'tongyi'], defaultColor: '#FF6A00' }, tencent: { name: 'tencent', displayName: 'Tencent', category: 'ai-provider', keywords: ['hunyuan'], defaultColor: '#00A4FF' }, meta: { name: 'meta', displayName: 'Meta', category: 'ai-provider', keywords: ['facebook', 'llama'], defaultColor: '#0081FB' }, microsoft: { name: 'microsoft', displayName: 'Microsoft', category: 'ai-provider', keywords: ['copilot', 'azure'], defaultColor: '#00A4EF' }, cohere: { name: 'cohere', displayName: 'Cohere', category: 'ai-provider', keywords: ['cohere'], defaultColor: '#39594D' }, perplexity: { name: 'perplexity', displayName: 'Perplexity', category: 'ai-provider', keywords: ['perplexity'], defaultColor: '#20808D' }, packycode: { name: 'packycode', displayName: 'PackyCode', category: 'ai-provider', keywords: ['packycode', 'packy', 'packyapi'], defaultColor: 'currentColor' }, mistral: { name: 'mistral', displayName: 'Mistral', category: 'ai-provider', keywords: ['mistral'], defaultColor: '#FF7000' }, huggingface: { name: 'huggingface', displayName: 'Hugging Face', category: 'ai-provider', keywords: ['huggingface', 'hf'], defaultColor: '#FFD21E' }, aws: { name: 'aws', displayName: 'AWS', category: 'cloud', keywords: ['amazon', 'cloud'], defaultColor: '#FF9900' }, azure: { name: 'azure', displayName: 'Azure', category: 'cloud', keywords: ['microsoft', 'cloud'], defaultColor: '#0078D4' }, huawei: { name: 'huawei', displayName: 'Huawei', category: 'cloud', keywords: ['huawei', 'cloud'], defaultColor: '#FF0000' }, cloudflare: { name: 'cloudflare', displayName: 'Cloudflare', category: 'cloud', keywords: ['cloudflare', 'cdn'], defaultColor: '#F38020' }, github: { name: 'github', displayName: 'GitHub', category: 'tool', keywords: ['git', 'version control'], defaultColor: '#181717' }, gitlab: { name: 'gitlab', displayName: 'GitLab', category: 'tool', keywords: ['git', 'version control'], defaultColor: '#FC6D26' }, docker: { name: 'docker', displayName: 'Docker', category: 'tool', keywords: ['container'], defaultColor: '#2496ED' }, kubernetes: { name: 'kubernetes', displayName: 'Kubernetes', category: 'tool', keywords: ['k8s', 'container'], defaultColor: '#326CE5' }, vscode: { name: 'vscode', displayName: 'VS Code', category: 'tool', keywords: ['editor', 'ide'], defaultColor: '#007ACC' }, settings: { name: 'settings', displayName: 'Settings', category: 'other', keywords: ['config', 'preferences'], defaultColor: '#6B7280' }, folder: { name: 'folder', displayName: 'Folder', category: 'other', keywords: ['directory'], defaultColor: '#6B7280' }, file: { name: 'file', displayName: 'File', category: 'other', keywords: ['document'], defaultColor: '#6B7280' }, link: { name: 'link', displayName: 'Link', category: 'other', keywords: ['url', 'hyperlink'], defaultColor: '#6B7280' }, }; // Get all SVG files const files = fs.readdirSync(ICONS_DIR).filter(file => file.endsWith('.svg')); console.log(`Found ${files.length} SVG files.`); // Generate index.ts const indexContent = `// Auto-generated icon index // Do not edit manually export const icons: Record = { ${files.map(file => { const name = path.basename(file, '.svg'); const svg = fs.readFileSync(path.join(ICONS_DIR, file), 'utf-8'); const escaped = svg.replace(/`/g, '\\`').replace(/\$/g, '\\$'); return ` '${name}': \`${escaped}\`,`; }).join('\n')} }; export const iconList = Object.keys(icons); export function getIcon(name: string): string { return icons[name.toLowerCase()] || ''; } export function hasIcon(name: string): boolean { return name.toLowerCase() in icons; } `; fs.writeFileSync(INDEX_FILE, indexContent); console.log(`Generated ${INDEX_FILE}`); // Generate metadata.ts const metadataEntries = files.map(file => { const name = path.basename(file, '.svg').toLowerCase(); const known = KNOWN_METADATA[name]; if (known) { return ` ${name}: ${JSON.stringify(known)},`; } // Default metadata for unknown icons return ` '${name}': { name: '${name}', displayName: '${name}', category: 'other', keywords: [], defaultColor: 'currentColor' },`; }); const metadataContent = `// Icon metadata for search and categorization import { IconMetadata } from '@/types/icon'; export const iconMetadata: Record = { ${metadataEntries.join('\n')} }; export function getIconMetadata(name: string): IconMetadata | undefined { return iconMetadata[name.toLowerCase()]; } export function searchIcons(query: string): string[] { const lowerQuery = query.toLowerCase(); return Object.values(iconMetadata) .filter(meta => meta.name.includes(lowerQuery) || meta.displayName.toLowerCase().includes(lowerQuery) || meta.keywords.some(k => k.includes(lowerQuery)) ) .map(meta => meta.name); } `; fs.writeFileSync(METADATA_FILE, metadataContent); console.log(`Generated ${METADATA_FILE}`); ================================================ FILE: session-manager.md ================================================ # 会话管理(Session Manager)需求文档(PRD / Markdown) > 目标:对 **Codex / Claude Code** 的本地会话记录进行可视化管理,并提供“一键复制 / 一键终端恢复”能力。 > 范围:**v1 仅 macOS**,但必须预留多平台扩展入口。 --- ## 1. 背景与问题 开发者同时使用 Codex CLI、Claude Code 时,常见痛点: - 会话记录落在本地不同位置,**难以发现/检索** - 找到会话后,恢复命令需要记忆或翻历史,**恢复成本高** - 恢复时经常忘了当时的工作目录,导致命令在错误目录运行 - 希望在常用终端(macOS Terminal、kitty 等)中直接恢复,提高效率 --- ## 2. 目标与非目标 ### 2.1 Goals(v1 必达) 1. 扫描并展示本机所有 Codex / Claude Code 会话:列表 + 详情(会话内容) 2. 支持恢复会话: - 复制恢复命令(按钮) - 复制会话目录(按钮,若能获取/推断) - 可选:直接在终端执行恢复(macOS Terminal、kitty;可扩展) 3. 仅 macOS 支持,但代码结构需支持未来扩展 Windows/Linux ### 2.2 Non-Goals(v1 不做) - 不新增/依赖云端 API;默认不上传任何内容 - 不承诺解析所有 provider 的全部内部格式(尽量兼容、可配置、可降级) - 不做复杂的团队协作/分享/同步(后续版本再考虑) --- ## 3. 用户画像与使用场景 ### 3.1 典型用户 - 高频使用多个 AI 编程工具的工程师/技术负责人/PM - 多项目、多分支并行,频繁“中断—恢复—继续推进” ### 3.2 核心场景(Top) 1. **找回会话**:我记得一个会话讨论过某段逻辑 → 搜索关键词 → 打开详情 2. **快速恢复**:我想继续昨天的会话 → 复制恢复命令 / 一键在终端恢复 3. **回到正确目录**:恢复前先复制目录或自动 cd 到目录 --- ## 4. 产品形态与信息架构 ### 4.1 信息架构 - Session Manager - 会话列表(List) - 会话详情(Detail) - 设置(Settings) - Provider 配置(路径/启用禁用) - 终端集成(默认终端、权限提示、降级策略) - 索引与隐私选项(是否缓存、缓存大小、敏感信息遮罩) --- ## 5. 功能需求(Functional Requirements) ### 5.1 会话发现与索引(Discovery & Indexing) **FR-1** 扫描本地会话数据源,生成统一的 Session 列表 - 支持 Provider:Codex、Claude Code(可扩展) - 支持全量扫描 + 增量更新 - 支持缺失/异常文件的容错(不中断 UI) **FR-2** 本地索引(Cache/DB) - 用于加速列表加载与搜索 - 索引字段至少包含:sessionId、provider、lastActiveAt、projectDir(可空)、summary(可空)、filePath(可空) **FR-3** 数据源路径探测(可配置 + 多候选) - 默认使用常见路径;允许用户在 Settings 覆盖 - 若无法探测到 provider 安装/数据目录:在 UI 显示未启用/不可用状态,但不报错崩溃 --- ### 5.2 会话列表(List) **FR-4** 列表展示字段(建议最小集) - Provider(Codex / Claude) - Session 标识(id/short id) - 最近活跃时间(lastActiveAt) - 目录(projectDir,若未知显示 “Unknown”) - 摘要(summary:最后一条/首条截断或规则生成) **FR-5** 列表交互 - 搜索(跨会话,关键词匹配 transcript/summary/目录) - 过滤:Provider、是否有目录、时间范围 - 排序:最近活跃(默认)、最早、按目录 **FR-6** 空态/异常态 - 未发现任何会话:给出“如何启用/设置路径”的指引 - 发现会话但无法解析内容:列表仍可显示基本信息,并在详情页提示“解析失败” --- ### 5.3 会话详情(Detail) **FR-7** 会话内容展示 - 时间线展示消息(role:user/assistant/tool 等) - 支持在当前会话内搜索 + 高亮 - 展示元信息: - provider、sessionId、创建/最近活跃时间 - projectDir(可空) - 原始文件路径(可选显示,便于 debug) **FR-8** 性能策略 - 默认按需加载(打开详情才加载全文) - 对超长 transcript 支持分页/虚拟列表(防止卡顿) --- ### 5.4 恢复能力(Resume / Restore) #### 5.4.1 复制恢复命令(必做) **FR-9** “复制恢复命令”按钮 - 根据 provider 生成恢复命令(模板可配置) - 点击后写入剪贴板,并 toast 提示成功 > 说明:不同版本 CLI 命令可能略有差异,建议将命令模板做成可配置项(Settings),默认提供推荐模板。 #### 5.4.2 复制会话目录(尽量做) **FR-10** “复制会话目录”按钮 - 当 projectDir 可得时启用;不可得时置灰,并提示原因(无法推断目录) - 复制内容为可直接 `cd` 的绝对路径(或原样) #### 5.4.3 一键终端恢复(可选但强烈建议) **FR-11** “在终端恢复”按钮(或下拉菜单) - 默认目标:macOS Terminal - 支持 kitty(v1 要求) - 执行策略: - `cd "" && `(若 projectDir 为空则仅执行 resumeCommand) - 失败降级: - 无权限/终端不可用 → 自动降级为“仅复制命令”,并提示用户如何修复(例如开启 Automation 权限、kitty remote control) **FR-12** 终端目标选择与记忆 - 下拉选择:Terminal / kitty /(预留 iTerm2)/ 仅复制 - 记住上次选择作为默认 --- ## 6. 平台与扩展性设计(macOS v1 + Future-proof) ### 6.1 Provider Adapter 抽象(必须) 统一接口(示例): - `detect(): boolean` - `scanSessions(): SessionMeta[]` - `loadTranscript(sessionId): Message[]` - `getResumeCommand(sessionId): string` - `getProjectDir(sessionId): string | null` ### 6.2 Terminal Launcher 抽象(必须) - `launch(command: string, cwd?: string, targetTerminal: TerminalKind): Result` - macOS v1 实现:TerminalLauncherMac - Future:TerminalLauncherWindows / TerminalLauncherLinux ### 6.3 Path Resolver(必须) - `resolveProviderDataPaths(providerId): string[]` - v1 返回 macOS 默认候选;允许 Settings 覆盖 --- ## 7. 隐私与安全(Privacy & Security) **默认原则:全本地、只读、不上传。** - transcript 默认不出网 - 本地索引默认仅存必要字段(可选:是否缓存全文内容) - 提供“敏感信息遮罩”(可选): - 简单正则:token/key/password 等 - 提示用户:会话内容可能包含敏感信息,导出/复制时注意 --- ## 8. 非功能需求(Non-Functional Requirements) ### 8.1 性能 - 首次打开:列表可在 1s 内展示(允许先展示缓存,再后台增量刷新) - 搜索:在 1k 会话量级可用(建立索引或增量缓存) - 详情页:打开后 300ms 内渲染骨架屏,内容流式/分段加载 ### 8.2 稳定性 - 任一 provider 数据源损坏不影响整体(隔离失败) - 扫描过程可中断/可重试 ### 8.3 可观测性(可选) - 本地日志:扫描耗时、解析失败原因、终端启动失败原因(便于 debug) --- ## 9. 关键数据结构(建议) ### 9.1 SessionMeta - `providerId: "codex" | "claude" | string` - `sessionId: string` - `title?: string` - `summary?: string` - `projectDir?: string | null` - `createdAt?: number` - `lastActiveAt?: number` - `sourcePath?: string` ### 9.2 Message - `role: "user" | "assistant" | "tool" | "system" | string` - `content: string` - `ts?: number` - `raw?: any`(保留原始字段,便于兼容未来格式) --- ## 10. 交互流程(UX Flows) ### 10.1 Flow A:搜索并查看 1) 打开 Session Manager → 看到列表 2) 输入关键词搜索 → 命中会话 3) 点击会话 → 进入详情 → 浏览内容 / 在会话内搜索 ### 10.2 Flow B:复制恢复命令 1) 列表或详情页点击“复制恢复命令” 2) toast 成功 → 用户粘贴到终端执行 ### 10.3 Flow C:一键终端恢复 1) 详情页点击“在终端恢复”(默认 Terminal) 2) 系统打开终端新窗口/新 tab 3) 自动执行:`cd projectDir && resumeCommand` 4) 失败 → toast 提示,并提供“复制命令”降级路径 --- ## 11. 边界情况与降级策略 - 无法获取 projectDir:仍可恢复(只执行 resume),目录按钮置灰 - 无法解析 transcript:列表仍显示,详情提示“无法解析”,可提供“打开原始文件路径” - CLI 命令模板不匹配:允许 Settings 自定义模板;默认模板可更新 - 终端权限问题(Automation):提示用户在系统设置中开启对应权限,并允许降级为复制命令 - kitty 未开启 remote control:提示如何配置,降级为复制命令 --- ## 12. 里程碑与交付(建议) ### M1(核心可用) - Provider 扫描:Codex / Claude - 列表 + 详情(可读) - 复制恢复命令 - 复制目录(若可得) ### M2(效率提升) - 跨会话搜索、过滤/排序 - 增量索引与文件监听(可选) - “在 macOS Terminal 恢复” ### M3(终端覆盖与可扩展) - “在 kitty 恢复” - 终端目标下拉与记忆 - 插件化接口/扩展点文档 --- ## 13. 后续功能候选(Backlog / Ideas) - 收藏/Pin 会话 - 会话标签(项目/主题/状态) - 会话摘要(本地生成) - Fork 会话继续(避免污染原会话) - 导出 Markdown/JSONL - 按项目聚合(Repo 视图) - 会话清理/归档(磁盘管理) --- ================================================ FILE: src/App.tsx ================================================ import { useEffect, useMemo, useState, useRef } from "react"; import { useTranslation } from "react-i18next"; import { motion, AnimatePresence } from "framer-motion"; import { toast } from "sonner"; import { invoke } from "@tauri-apps/api/core"; import { listen } from "@tauri-apps/api/event"; import { useQueryClient } from "@tanstack/react-query"; import { Plus, Settings, ArrowLeft, Book, Wrench, RefreshCw, History, BarChart2, Download, FolderArchive, Search, FolderOpen, KeyRound, Shield, Cpu, } from "lucide-react"; import type { Provider, VisibleApps } from "@/types"; import type { EnvConflict } from "@/types/env"; import { useProvidersQuery, useSettingsQuery } from "@/lib/query"; import { providersApi, settingsApi, type AppId, type ProviderSwitchEvent, } from "@/lib/api"; import { checkAllEnvConflicts, checkEnvConflicts } from "@/lib/api/env"; import { useProviderActions } from "@/hooks/useProviderActions"; import { openclawKeys, useOpenClawHealth } from "@/hooks/useOpenClaw"; import { useProxyStatus } from "@/hooks/useProxyStatus"; import { useAutoCompact } from "@/hooks/useAutoCompact"; import { useLastValidValue } from "@/hooks/useLastValidValue"; import { extractErrorMessage } from "@/utils/errorUtils"; import { isTextEditableTarget } from "@/utils/domUtils"; import { cn } from "@/lib/utils"; import { isWindows, isLinux } from "@/lib/platform"; import { AppSwitcher } from "@/components/AppSwitcher"; import { ProviderList } from "@/components/providers/ProviderList"; import { AddProviderDialog } from "@/components/providers/AddProviderDialog"; import { EditProviderDialog } from "@/components/providers/EditProviderDialog"; import { ConfirmDialog } from "@/components/ConfirmDialog"; import { SettingsPage } from "@/components/settings/SettingsPage"; import { UpdateBadge } from "@/components/UpdateBadge"; import { EnvWarningBanner } from "@/components/env/EnvWarningBanner"; import { ProxyToggle } from "@/components/proxy/ProxyToggle"; import { FailoverToggle } from "@/components/proxy/FailoverToggle"; import UsageScriptModal from "@/components/UsageScriptModal"; import UnifiedMcpPanel from "@/components/mcp/UnifiedMcpPanel"; import PromptPanel from "@/components/prompts/PromptPanel"; import { SkillsPage } from "@/components/skills/SkillsPage"; import UnifiedSkillsPanel from "@/components/skills/UnifiedSkillsPanel"; import { DeepLinkImportDialog } from "@/components/DeepLinkImportDialog"; import { AgentsPanel } from "@/components/agents/AgentsPanel"; import { UniversalProviderPanel } from "@/components/universal"; import { McpIcon } from "@/components/BrandIcons"; import { Button } from "@/components/ui/button"; import { SessionManagerPage } from "@/components/sessions/SessionManagerPage"; import { useDisableCurrentOmo, useDisableCurrentOmoSlim, } from "@/lib/query/omo"; import WorkspaceFilesPanel from "@/components/workspace/WorkspaceFilesPanel"; import EnvPanel from "@/components/openclaw/EnvPanel"; import ToolsPanel from "@/components/openclaw/ToolsPanel"; import AgentsDefaultsPanel from "@/components/openclaw/AgentsDefaultsPanel"; import OpenClawHealthBanner from "@/components/openclaw/OpenClawHealthBanner"; type View = | "providers" | "settings" | "prompts" | "skills" | "skillsDiscovery" | "mcp" | "agents" | "universal" | "sessions" | "workspace" | "openclawEnv" | "openclawTools" | "openclawAgents"; interface WebDavSyncStatusUpdatedPayload { source?: string; status?: string; error?: string; } const DRAG_BAR_HEIGHT = isWindows() || isLinux() ? 0 : 28; // px const HEADER_HEIGHT = 64; // px const CONTENT_TOP_OFFSET = DRAG_BAR_HEIGHT + HEADER_HEIGHT; const STORAGE_KEY = "cc-switch-last-app"; const VALID_APPS: AppId[] = [ "claude", "codex", "gemini", "opencode", "openclaw", ]; const getInitialApp = (): AppId => { const saved = localStorage.getItem(STORAGE_KEY) as AppId | null; if (saved && VALID_APPS.includes(saved)) { return saved; } return "claude"; }; const VIEW_STORAGE_KEY = "cc-switch-last-view"; const VALID_VIEWS: View[] = [ "providers", "settings", "prompts", "skills", "skillsDiscovery", "mcp", "agents", "universal", "sessions", "workspace", "openclawEnv", "openclawTools", "openclawAgents", ]; const getInitialView = (): View => { const saved = localStorage.getItem(VIEW_STORAGE_KEY) as View | null; if (saved && VALID_VIEWS.includes(saved)) { return saved; } return "providers"; }; function App() { const { t } = useTranslation(); const queryClient = useQueryClient(); const [activeApp, setActiveApp] = useState(getInitialApp); const [currentView, setCurrentView] = useState(getInitialView); const [settingsDefaultTab, setSettingsDefaultTab] = useState("general"); const [isAddOpen, setIsAddOpen] = useState(false); useEffect(() => { localStorage.setItem(VIEW_STORAGE_KEY, currentView); }, [currentView]); const { data: settingsData } = useSettingsQuery(); const visibleApps: VisibleApps = settingsData?.visibleApps ?? { claude: true, codex: true, gemini: true, opencode: true, openclaw: true, }; const getFirstVisibleApp = (): AppId => { if (visibleApps.claude) return "claude"; if (visibleApps.codex) return "codex"; if (visibleApps.gemini) return "gemini"; if (visibleApps.opencode) return "opencode"; if (visibleApps.openclaw) return "openclaw"; return "claude"; // fallback }; useEffect(() => { if (!visibleApps[activeApp]) { setActiveApp(getFirstVisibleApp()); } }, [visibleApps, activeApp]); // Fallback from sessions view when switching to an app without session support useEffect(() => { if ( currentView === "sessions" && activeApp !== "claude" && activeApp !== "codex" && activeApp !== "opencode" && activeApp !== "openclaw" && activeApp !== "gemini" ) { setCurrentView("providers"); } }, [activeApp, currentView]); const [editingProvider, setEditingProvider] = useState(null); const [usageProvider, setUsageProvider] = useState(null); const [confirmAction, setConfirmAction] = useState<{ provider: Provider; action: "remove" | "delete"; } | null>(null); const [envConflicts, setEnvConflicts] = useState([]); const [showEnvBanner, setShowEnvBanner] = useState(false); const effectiveEditingProvider = useLastValidValue(editingProvider); const effectiveUsageProvider = useLastValidValue(usageProvider); const toolbarRef = useRef(null); const isToolbarCompact = useAutoCompact(toolbarRef); const promptPanelRef = useRef(null); const mcpPanelRef = useRef(null); const skillsPageRef = useRef(null); const unifiedSkillsPanelRef = useRef(null); const addActionButtonClass = "bg-orange-500 hover:bg-orange-600 dark:bg-orange-500 dark:hover:bg-orange-600 text-white shadow-lg shadow-orange-500/30 dark:shadow-orange-500/40 rounded-full w-8 h-8"; const { isRunning: isProxyRunning, takeoverStatus, status: proxyStatus, } = useProxyStatus(); const isCurrentAppTakeoverActive = takeoverStatus?.[activeApp] || false; const activeProviderId = useMemo(() => { const target = proxyStatus?.active_targets?.find( (t) => t.app_type === activeApp, ); return target?.provider_id; }, [proxyStatus?.active_targets, activeApp]); const { data, isLoading, refetch } = useProvidersQuery(activeApp, { isProxyRunning, }); const providers = useMemo(() => data?.providers ?? {}, [data]); const currentProviderId = data?.currentProviderId ?? ""; const isOpenClawView = activeApp === "openclaw" && (currentView === "providers" || currentView === "workspace" || currentView === "sessions" || currentView === "openclawEnv" || currentView === "openclawTools" || currentView === "openclawAgents"); const { data: openclawHealthWarnings = [] } = useOpenClawHealth(isOpenClawView); const hasSkillsSupport = true; const hasSessionSupport = activeApp === "claude" || activeApp === "codex" || activeApp === "opencode" || activeApp === "openclaw" || activeApp === "gemini"; const { addProvider, updateProvider, switchProvider, deleteProvider, saveUsageScript, setAsDefaultModel, } = useProviderActions(activeApp); const disableOmoMutation = useDisableCurrentOmo(); const handleDisableOmo = () => { disableOmoMutation.mutate(undefined, { onSuccess: () => { toast.success(t("omo.disabled", { defaultValue: "OMO 已停用" })); }, onError: (error: Error) => { toast.error( t("omo.disableFailed", { defaultValue: "停用 OMO 失败: {{error}}", error: extractErrorMessage(error), }), ); }, }); }; const disableOmoSlimMutation = useDisableCurrentOmoSlim(); const handleDisableOmoSlim = () => { disableOmoSlimMutation.mutate(undefined, { onSuccess: () => { toast.success(t("omo.disabled", { defaultValue: "OMO 已停用" })); }, onError: (error: Error) => { toast.error( t("omo.disableFailed", { defaultValue: "停用 OMO 失败: {{error}}", error: extractErrorMessage(error), }), ); }, }); }; useEffect(() => { let unsubscribe: (() => void) | undefined; const setupListener = async () => { try { unsubscribe = await providersApi.onSwitched( async (event: ProviderSwitchEvent) => { if (event.appType === activeApp) { await refetch(); } }, ); } catch (error) { console.error("[App] Failed to subscribe provider switch event", error); } }; setupListener(); return () => { unsubscribe?.(); }; }, [activeApp, refetch]); useEffect(() => { let unsubscribe: (() => void) | undefined; const setupListener = async () => { try { const { listen } = await import("@tauri-apps/api/event"); unsubscribe = await listen("universal-provider-synced", async () => { await queryClient.invalidateQueries({ queryKey: ["providers"] }); try { await providersApi.updateTrayMenu(); } catch (error) { console.error("[App] Failed to update tray menu", error); } }); } catch (error) { console.error( "[App] Failed to subscribe universal-provider-synced event", error, ); } }; setupListener(); return () => { unsubscribe?.(); }; }, [queryClient]); useEffect(() => { let unsubscribe: (() => void) | undefined; let active = true; const setupListener = async () => { try { const off = await listen( "webdav-sync-status-updated", async (event) => { const payload = (event.payload ?? {}) as WebDavSyncStatusUpdatedPayload; await queryClient.invalidateQueries({ queryKey: ["settings"] }); if (payload.source !== "auto" || payload.status !== "error") { return; } toast.error( t("settings.webdavSync.autoSyncFailedToast", { error: payload.error || t("common.unknown"), }), ); }, ); if (!active) { off(); return; } unsubscribe = off; } catch (error) { console.error( "[App] Failed to subscribe webdav-sync-status-updated event", error, ); } }; void setupListener(); return () => { active = false; unsubscribe?.(); }; }, [queryClient, t]); useEffect(() => { const checkEnvOnStartup = async () => { try { const allConflicts = await checkAllEnvConflicts(); const flatConflicts = Object.values(allConflicts).flat(); if (flatConflicts.length > 0) { setEnvConflicts(flatConflicts); const dismissed = sessionStorage.getItem("env_banner_dismissed"); if (!dismissed) { setShowEnvBanner(true); } } } catch (error) { console.error( "[App] Failed to check environment conflicts on startup:", error, ); } }; checkEnvOnStartup(); }, []); useEffect(() => { const checkMigration = async () => { try { const migrated = await invoke("get_migration_result"); if (migrated) { toast.success( t("migration.success", { defaultValue: "配置迁移成功" }), { closeButton: true }, ); } } catch (error) { console.error("[App] Failed to check migration result:", error); } }; checkMigration(); }, [t]); useEffect(() => { const checkSkillsMigration = async () => { try { const result = await invoke<{ count: number; error?: string } | null>( "get_skills_migration_result", ); if (result?.error) { toast.error(t("migration.skillsFailed"), { description: t("migration.skillsFailedDescription"), closeButton: true, }); console.error("[App] Skills SSOT migration failed:", result.error); return; } if (result && result.count > 0) { toast.success(t("migration.skillsSuccess", { count: result.count }), { closeButton: true, }); await queryClient.invalidateQueries({ queryKey: ["skills"] }); } } catch (error) { console.error("[App] Failed to check skills migration result:", error); } }; checkSkillsMigration(); }, [t, queryClient]); useEffect(() => { const checkEnvOnSwitch = async () => { try { const conflicts = await checkEnvConflicts(activeApp); if (conflicts.length > 0) { setEnvConflicts((prev) => { const existingKeys = new Set( prev.map((c) => `${c.varName}:${c.sourcePath}`), ); const newConflicts = conflicts.filter( (c) => !existingKeys.has(`${c.varName}:${c.sourcePath}`), ); return [...prev, ...newConflicts]; }); const dismissed = sessionStorage.getItem("env_banner_dismissed"); if (!dismissed) { setShowEnvBanner(true); } } } catch (error) { console.error( "[App] Failed to check environment conflicts on app switch:", error, ); } }; checkEnvOnSwitch(); }, [activeApp]); const currentViewRef = useRef(currentView); useEffect(() => { currentViewRef.current = currentView; }, [currentView]); useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { if (event.key === "," && (event.metaKey || event.ctrlKey)) { event.preventDefault(); setCurrentView("settings"); return; } if (event.key !== "Escape" || event.defaultPrevented) return; if (document.body.style.overflow === "hidden") return; const view = currentViewRef.current; if (view === "providers") return; if (isTextEditableTarget(event.target)) return; event.preventDefault(); setCurrentView(view === "skillsDiscovery" ? "skills" : "providers"); }; window.addEventListener("keydown", handleKeyDown); return () => { window.removeEventListener("keydown", handleKeyDown); }; }, []); const handleOpenWebsite = async (url: string) => { try { await settingsApi.openExternal(url); } catch (error) { const detail = extractErrorMessage(error) || t("notifications.openLinkFailed", { defaultValue: "链接打开失败", }); toast.error(detail); } }; const handleEditProvider = async (provider: Provider) => { await updateProvider(provider); setEditingProvider(null); }; const handleConfirmAction = async () => { if (!confirmAction) return; const { provider, action } = confirmAction; if (action === "remove") { // Remove from live config only (for additive mode apps like OpenCode/OpenClaw) // Does NOT delete from database - provider remains in the list await providersApi.removeFromLiveConfig(provider.id, activeApp); // Invalidate queries to refresh the isInConfig state if (activeApp === "opencode") { await queryClient.invalidateQueries({ queryKey: ["opencodeLiveProviderIds"], }); } else if (activeApp === "openclaw") { await queryClient.invalidateQueries({ queryKey: openclawKeys.liveProviderIds, }); await queryClient.invalidateQueries({ queryKey: openclawKeys.health, }); } toast.success( t("notifications.removeFromConfigSuccess", { defaultValue: "已从配置移除", }), { closeButton: true }, ); } else { await deleteProvider(provider.id); } setConfirmAction(null); }; const generateUniqueOpencodeKey = ( originalKey: string, existingKeys: string[], ): string => { const baseKey = `${originalKey}-copy`; if (!existingKeys.includes(baseKey)) { return baseKey; } let counter = 2; while (existingKeys.includes(`${baseKey}-${counter}`)) { counter++; } return `${baseKey}-${counter}`; }; const handleDuplicateProvider = async (provider: Provider) => { const newSortIndex = provider.sortIndex !== undefined ? provider.sortIndex + 1 : undefined; const duplicatedProvider: Omit & { providerKey?: string; } = { name: `${provider.name} copy`, settingsConfig: JSON.parse(JSON.stringify(provider.settingsConfig)), // 深拷贝 websiteUrl: provider.websiteUrl, category: provider.category, sortIndex: newSortIndex, // 复制原 sortIndex + 1 meta: provider.meta ? JSON.parse(JSON.stringify(provider.meta)) : undefined, // 深拷贝 icon: provider.icon, iconColor: provider.iconColor, }; if (activeApp === "opencode") { const existingKeys = Object.keys(providers); duplicatedProvider.providerKey = generateUniqueOpencodeKey( provider.id, existingKeys, ); } if (provider.sortIndex !== undefined) { const updates = Object.values(providers) .filter( (p) => p.sortIndex !== undefined && p.sortIndex >= newSortIndex! && p.id !== provider.id, ) .map((p) => ({ id: p.id, sortIndex: p.sortIndex! + 1, })); if (updates.length > 0) { try { await providersApi.updateSortOrder(updates, activeApp); } catch (error) { console.error("[App] Failed to update sort order", error); toast.error( t("provider.sortUpdateFailed", { defaultValue: "排序更新失败", }), ); return; // 如果排序更新失败,不继续添加 } } } await addProvider(duplicatedProvider); }; const handleOpenTerminal = async (provider: Provider) => { try { await providersApi.openTerminal(provider.id, activeApp); toast.success( t("provider.terminalOpened", { defaultValue: "终端已打开", }), ); } catch (error) { console.error("[App] Failed to open terminal", error); const errorMessage = extractErrorMessage(error); toast.error( t("provider.terminalOpenFailed", { defaultValue: "打开终端失败", }) + (errorMessage ? `: ${errorMessage}` : ""), ); } }; const handleImportSuccess = async () => { try { await queryClient.invalidateQueries({ queryKey: ["providers"], refetchType: "all", }); await queryClient.refetchQueries({ queryKey: ["providers"], type: "all", }); } catch (error) { console.error("[App] Failed to refresh providers after import", error); await refetch(); } try { await providersApi.updateTrayMenu(); } catch (error) { console.error("[App] Failed to refresh tray menu", error); } }; const renderContent = () => { const content = (() => { switch (currentView) { case "settings": return ( setCurrentView("providers")} onImportSuccess={handleImportSuccess} defaultTab={settingsDefaultTab} /> ); case "prompts": return ( setCurrentView("providers")} appId={activeApp} /> ); case "skills": return ( setCurrentView("skillsDiscovery")} currentApp={activeApp === "openclaw" ? "claude" : activeApp} /> ); case "skillsDiscovery": return ( ); case "mcp": return ( setCurrentView("providers")} /> ); case "agents": return ( setCurrentView("providers")} /> ); case "universal": return (
); case "sessions": return ; case "workspace": return ; case "openclawEnv": return ; case "openclawTools": return ; case "openclawAgents": return ; default: return (
{ setEditingProvider(provider); }} onDelete={(provider) => setConfirmAction({ provider, action: "delete" }) } onRemoveFromConfig={ activeApp === "opencode" || activeApp === "openclaw" ? (provider) => setConfirmAction({ provider, action: "remove" }) : undefined } onDisableOmo={ activeApp === "opencode" ? handleDisableOmo : undefined } onDisableOmoSlim={ activeApp === "opencode" ? handleDisableOmoSlim : undefined } onDuplicate={handleDuplicateProvider} onConfigureUsage={setUsageProvider} onOpenWebsite={handleOpenWebsite} onOpenTerminal={ activeApp === "claude" ? handleOpenTerminal : undefined } onCreate={() => setIsAddOpen(true)} onSetAsDefault={ activeApp === "openclaw" ? setAsDefaultModel : undefined } />
); } })(); return ( {content} ); }; return (
{showEnvBanner && envConflicts.length > 0 && ( { setShowEnvBanner(false); sessionStorage.setItem("env_banner_dismissed", "true"); }} onDeleted={async () => { try { const allConflicts = await checkAllEnvConflicts(); const flatConflicts = Object.values(allConflicts).flat(); setEnvConflicts(flatConflicts); if (flatConflicts.length === 0) { setShowEnvBanner(false); } } catch (error) { console.error( "[App] Failed to re-check conflicts after deletion:", error, ); } }} /> )}
{currentView !== "providers" ? (

{currentView === "settings" && t("settings.title")} {currentView === "prompts" && t("prompts.title", { appName: t(`apps.${activeApp}`) })} {currentView === "skills" && t("skills.title")} {currentView === "skillsDiscovery" && t("skills.title")} {currentView === "mcp" && t("mcp.unifiedPanel.title")} {currentView === "agents" && t("agents.title")} {currentView === "universal" && t("universalProvider.title", { defaultValue: "统一供应商", })} {currentView === "sessions" && t("sessionManager.title")} {currentView === "workspace" && t("workspace.title")} {currentView === "openclawEnv" && t("openclaw.env.title")} {currentView === "openclawTools" && t("openclaw.tools.title")} {currentView === "openclawAgents" && t("openclaw.agents.title")}

) : (
{ setSettingsDefaultTab("about"); setCurrentView("settings"); }} /> {isCurrentAppTakeoverActive && ( )}
)}
{currentView === "providers" && activeApp !== "opencode" && activeApp !== "openclaw" && (
{settingsData?.enableLocalProxy && ( )} {settingsData?.enableFailoverToggle && ( )}
)}
{currentView === "prompts" && ( )} {currentView === "mcp" && ( <> )} {currentView === "skills" && ( <> )} {currentView === "skillsDiscovery" && ( <> )} {currentView === "providers" && ( <>
{activeApp === "openclaw" ? ( <> ) : ( <> )}
)}
{isOpenClawView && openclawHealthWarnings.length > 0 && ( )} {renderContent()}
{ if (!open) { setEditingProvider(null); } }} onSubmit={handleEditProvider} appId={activeApp} isProxyTakeover={isProxyRunning && isCurrentAppTakeoverActive} /> {effectiveUsageProvider && ( setUsageProvider(null)} onSave={(script) => { if (usageProvider) { void saveUsageScript(usageProvider, script); } }} /> )} void handleConfirmAction()} onCancel={() => setConfirmAction(null)} />
); } export default App; ================================================ FILE: src/components/AppSwitcher.tsx ================================================ import type { AppId } from "@/lib/api"; import type { VisibleApps } from "@/types"; import { ProviderIcon } from "@/components/ProviderIcon"; import { cn } from "@/lib/utils"; interface AppSwitcherProps { activeApp: AppId; onSwitch: (app: AppId) => void; visibleApps?: VisibleApps; compact?: boolean; } const ALL_APPS: AppId[] = ["claude", "codex", "gemini", "opencode", "openclaw"]; const STORAGE_KEY = "cc-switch-last-app"; export function AppSwitcher({ activeApp, onSwitch, visibleApps, compact, }: AppSwitcherProps) { const handleSwitch = (app: AppId) => { if (app === activeApp) return; localStorage.setItem(STORAGE_KEY, app); onSwitch(app); }; const iconSize = 20; const appIconName: Record = { claude: "claude", codex: "openai", gemini: "gemini", opencode: "opencode", openclaw: "openclaw", }; const appDisplayName: Record = { claude: "Claude", codex: "Codex", gemini: "Gemini", opencode: "OpenCode", openclaw: "OpenClaw", }; // Filter apps based on visibility settings (default all visible) const appsToShow = ALL_APPS.filter((app) => { if (!visibleApps) return true; return visibleApps[app]; }); return (
{appsToShow.map((app) => ( ))}
); } ================================================ FILE: src/components/BrandIcons.tsx ================================================ interface IconProps { size?: number; className?: string; } // 导入本地 SVG 图标 import ClaudeSvg from "@/icons/extracted/claude.svg?url"; import OpenAISvg from "@/icons/extracted/openai.svg?url"; import GeminiSvg from "@/icons/extracted/gemini.svg?url"; import OpenClawSvg from "@/icons/extracted/claw.svg?url"; export function ClaudeIcon({ size = 16, className = "" }: IconProps) { return ( Claude ); } export function CodexIcon({ size = 16, className = "" }: IconProps) { return ( Codex ); } export function GeminiIcon({ size = 16, className = "" }: IconProps) { return ( Gemini ); } export function OpenClawIcon({ size = 16, className = "" }: IconProps) { return ( OpenClaw ); } // MCP icon uses inline SVG to support currentColor for hover effects export function McpIcon({ size = 16, className = "" }: IconProps) { return ( ); } ================================================ FILE: src/components/ColorPicker.tsx ================================================ import React from "react"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { cn } from "@/lib/utils"; import { useTranslation } from "react-i18next"; interface ColorPickerProps { value?: string; onValueChange: (color: string) => void; label?: string; presets?: string[]; } const DEFAULT_PRESETS = [ "#00A67E", "#D4915D", "#4285F4", "#FF6A00", "#00A4FF", "#FF9900", "#0078D4", "#FF0000", "#1E88E5", "#6366F1", "#0F62FE", "#2932E1", ]; export const ColorPicker: React.FC = ({ value = "#4285F4", onValueChange, label, presets = DEFAULT_PRESETS, }) => { const { t } = useTranslation(); const displayLabel = label ?? t("providerIcon.color", "图标颜色"); return (
{/* 颜色预设 */}
{presets.map((color) => (
{/* 自定义颜色输入 */}
onValueChange(e.target.value)} className="w-16 h-10 p-1 cursor-pointer" /> onValueChange(e.target.value)} placeholder="#4285F4" className="flex-1 font-mono" />
); }; ================================================ FILE: src/components/ConfirmDialog.tsx ================================================ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { AlertTriangle, Info } from "lucide-react"; import { useTranslation } from "react-i18next"; interface ConfirmDialogProps { isOpen: boolean; title: string; message: string; confirmText?: string; cancelText?: string; variant?: "destructive" | "info"; zIndex?: "base" | "nested" | "alert" | "top"; onConfirm: () => void; onCancel: () => void; } export function ConfirmDialog({ isOpen, title, message, confirmText, cancelText, variant = "destructive", zIndex = "alert", onConfirm, onCancel, }: ConfirmDialogProps) { const { t } = useTranslation(); const IconComponent = variant === "info" ? Info : AlertTriangle; const iconClass = variant === "info" ? "h-5 w-5 text-blue-500" : "h-5 w-5 text-destructive"; return ( { if (!open) { onCancel(); } }} > {title} {message} ); } ================================================ FILE: src/components/DeepLinkImportDialog.tsx ================================================ import { useState, useEffect, useMemo } from "react"; import { listen } from "@tauri-apps/api/event"; import { DeepLinkImportRequest, deeplinkApi } from "@/lib/api/deeplink"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { toast } from "sonner"; import { useTranslation } from "react-i18next"; import { useQueryClient } from "@tanstack/react-query"; import { PromptConfirmation } from "./deeplink/PromptConfirmation"; import { McpConfirmation } from "./deeplink/McpConfirmation"; import { SkillConfirmation } from "./deeplink/SkillConfirmation"; import { ProviderIcon } from "./ProviderIcon"; interface DeeplinkError { url: string; error: string; } export function DeepLinkImportDialog() { const { t } = useTranslation(); const queryClient = useQueryClient(); const [request, setRequest] = useState(null); const [isImporting, setIsImporting] = useState(false); const [isOpen, setIsOpen] = useState(false); // 容错判断:MCP 导入结果可能缺少 type 字段 const isMcpImportResult = ( value: unknown, ): value is { importedCount: number; importedIds: string[]; failed: Array<{ id: string; error: string }>; type?: "mcp"; } => { if (!value || typeof value !== "object") return false; const v = value as Record; return ( typeof v.importedCount === "number" && Array.isArray(v.importedIds) && Array.isArray(v.failed) ); }; useEffect(() => { // Listen for deep link import events const unlistenImport = listen( "deeplink-import", async (event) => { // If config is present, merge it to get the complete configuration if (event.payload.config || event.payload.configUrl) { try { const mergedRequest = await deeplinkApi.mergeDeeplinkConfig( event.payload, ); setRequest(mergedRequest); } catch (error) { console.error("Failed to merge config:", error); toast.error(t("deeplink.configMergeError"), { description: error instanceof Error ? error.message : String(error), }); // Fall back to original request setRequest(event.payload); } } else { setRequest(event.payload); } setIsOpen(true); }, ); // Listen for deep link error events const unlistenError = listen("deeplink-error", (event) => { console.error("Deep link error:", event.payload); toast.error(t("deeplink.parseError"), { description: event.payload.error, }); }); return () => { unlistenImport.then((fn) => fn()); unlistenError.then((fn) => fn()); }; }, [t]); const handleImport = async () => { if (!request) return; setIsImporting(true); try { const result = await deeplinkApi.importFromDeeplink(request); const refreshMcp = async (summary: { importedCount: number; importedIds: string[]; failed: Array<{ id: string; error: string }>; }) => { // 强制刷新 MCP 相关缓存,确保管理页重新从数据库加载 await queryClient.invalidateQueries({ queryKey: ["mcp", "all"], refetchType: "all", }); await queryClient.refetchQueries({ queryKey: ["mcp", "all"], type: "all", }); if (summary.failed.length > 0) { toast.warning(t("deeplink.mcpPartialSuccess"), { description: t("deeplink.mcpPartialSuccessDescription", { success: summary.importedCount, failed: summary.failed.length, }), }); } else { toast.success(t("deeplink.mcpImportSuccess"), { description: t("deeplink.mcpImportSuccessDescription", { count: summary.importedCount, }), closeButton: true, }); } }; // Handle different result types if ("type" in result) { if (result.type === "provider") { await queryClient.invalidateQueries({ queryKey: ["providers", request.app], }); toast.success(t("deeplink.importSuccess"), { description: t("deeplink.importSuccessDescription", { name: request.name, }), closeButton: true, }); } else if (result.type === "prompt") { // Prompts don't use React Query, trigger a custom event for refresh window.dispatchEvent( new CustomEvent("prompt-imported", { detail: { app: request.app }, }), ); toast.success(t("deeplink.promptImportSuccess"), { description: t("deeplink.promptImportSuccessDescription", { name: request.name, }), closeButton: true, }); } else if (result.type === "mcp") { await refreshMcp(result); } else if (result.type === "skill") { // Refresh Skills with aggressive strategy queryClient.invalidateQueries({ queryKey: ["skills"], refetchType: "all", }); await queryClient.refetchQueries({ queryKey: ["skills"], type: "all", }); toast.success(t("deeplink.skillImportSuccess"), { description: t("deeplink.skillImportSuccessDescription", { repo: request.repo, }), closeButton: true, }); } } else if (isMcpImportResult(result)) { // 兜底处理:旧版本后端可能未返回 type 字段 await refreshMcp(result); } else { // Legacy return type (string ID) - assume provider await queryClient.invalidateQueries({ queryKey: ["providers", request.app], }); toast.success(t("deeplink.importSuccess"), { description: t("deeplink.importSuccessDescription", { name: request.name, }), closeButton: true, }); } // Close dialog after all refreshes complete setIsOpen(false); } catch (error) { console.error("Failed to import from deep link:", error); toast.error(t("deeplink.importError"), { description: error instanceof Error ? error.message : String(error), }); } finally { setIsImporting(false); } }; const handleCancel = () => { setIsOpen(false); }; // Mask API key for display (show first 4 chars + ***) const maskedApiKey = request?.apiKey && request.apiKey.length > 4 ? `${request.apiKey.substring(0, 4)}${"*".repeat(20)}` : "****"; // Check if config file is present const hasConfigFile = !!(request?.config || request?.configUrl); const configSource = request?.config ? "base64" : request?.configUrl ? "url" : null; // Parse config file content for display interface ParsedConfig { type: "claude" | "codex" | "gemini"; env?: Record; auth?: Record; tomlConfig?: string; raw: Record; } // Helper to decode base64 with UTF-8 support const b64ToUtf8 = (str: string): string => { try { const binString = atob(str); const bytes = Uint8Array.from(binString, (m) => m.codePointAt(0) || 0); return new TextDecoder().decode(bytes); } catch (e) { console.error("Failed to decode base64:", e); return atob(str); } }; const parsedConfig = useMemo((): ParsedConfig | null => { if (!request?.config) return null; try { const decoded = b64ToUtf8(request.config); const parsed = JSON.parse(decoded) as Record; if (request.app === "claude") { // Claude 格式: { env: { ANTHROPIC_AUTH_TOKEN: ..., ... } } return { type: "claude", env: (parsed.env as Record) || {}, raw: parsed, }; } else if (request.app === "codex") { // Codex 格式: { auth: { OPENAI_API_KEY: ... }, config: "TOML string" } return { type: "codex", auth: (parsed.auth as Record) || {}, tomlConfig: (parsed.config as string) || "", raw: parsed, }; } else if (request.app === "gemini") { // Gemini 格式: 扁平结构 { GEMINI_API_KEY: ..., GEMINI_BASE_URL: ... } return { type: "gemini", env: parsed as Record, raw: parsed, }; } return null; } catch (e) { console.error("Failed to parse config:", e); return null; } }, [request?.config, request?.app]); // Helper to mask sensitive values const maskValue = (key: string, value: string): string => { const sensitiveKeys = ["TOKEN", "KEY", "SECRET", "PASSWORD"]; const isSensitive = sensitiveKeys.some((k) => key.toUpperCase().includes(k), ); if (isSensitive && value.length > 8) { return `${value.substring(0, 8)}${"*".repeat(12)}`; } return value; }; const getTitle = () => { if (!request) return t("deeplink.confirmImport"); switch (request.resource) { case "prompt": return t("deeplink.importPrompt"); case "mcp": return t("deeplink.importMcp"); case "skill": return t("deeplink.importSkill"); default: return t("deeplink.confirmImport"); } }; const getDescription = () => { if (!request) return t("deeplink.confirmImportDescription"); switch (request.resource) { case "prompt": return t("deeplink.importPromptDescription"); case "mcp": return t("deeplink.importMcpDescription"); case "skill": return t("deeplink.importSkillDescription"); default: return t("deeplink.confirmImportDescription"); } }; return ( {request && ( <> {/* 标题显式左对齐,避免默认居中样式影响 */} {getTitle()} {getDescription()} {/* 主体内容整体右移,略大于标题内边距,让内容看起来不贴边 */}
{request.resource === "prompt" && ( )} {request.resource === "mcp" && ( )} {request.resource === "skill" && ( )} {/* Legacy Provider View */} {(request.resource === "provider" || !request.resource) && ( <> {/* Provider Icon - enlarge and center near the top */} {request.icon && (
)} {/* App Type */}
{t("deeplink.app")}
{request.app}
{/* Provider Name */}
{t("deeplink.providerName")}
{request.name}
{/* Homepage */}
{t("deeplink.homepage")}
{request.homepage}
{/* API Endpoint */}
{t("deeplink.endpoint")}
{request.endpoint?.split(",").map((ep, idx) => (
{idx === 0 ? "🔹 " : "└ "} {ep.trim()} {idx === 0 && request.endpoint?.includes(",") && ( ({t("deeplink.primaryEndpoint")}) )}
))}
{/* API Key (masked) */}
{t("deeplink.apiKey")}
{maskedApiKey}
{/* Model Fields - 根据应用类型显示不同的模型字段 */} {request.app === "claude" ? ( <> {/* Claude 四种模型字段 */} {request.haikuModel && (
{t("deeplink.haikuModel")}
{request.haikuModel}
)} {request.sonnetModel && (
{t("deeplink.sonnetModel")}
{request.sonnetModel}
)} {request.opusModel && (
{t("deeplink.opusModel")}
{request.opusModel}
)} {request.model && (
{t("deeplink.multiModel")}
{request.model}
)} ) : ( <> {/* Codex 和 Gemini 使用通用 model 字段 */} {request.model && (
{t("deeplink.model")}
{request.model}
)} )} {/* Notes (if present) */} {request.notes && (
{t("deeplink.notes")}
{request.notes}
)} {/* Config File Details (v3.8+) */} {hasConfigFile && (
{t("deeplink.configSource")}
{configSource === "base64" ? t("deeplink.configEmbedded") : t("deeplink.configRemote")} {request.configFormat && ( {request.configFormat} )}
{/* Parsed Config Details */} {parsedConfig && (
{t("deeplink.configDetails")}
{/* Claude config */} {parsedConfig.type === "claude" && parsedConfig.env && (
{Object.entries(parsedConfig.env).map( ([key, value]) => (
{key} {maskValue(key, String(value))}
), )}
)} {/* Codex config */} {parsedConfig.type === "codex" && (
{parsedConfig.auth && Object.keys(parsedConfig.auth).length > 0 && (
Auth:
{Object.entries(parsedConfig.auth).map( ([key, value]) => (
{key} {maskValue(key, String(value))}
), )}
)} {parsedConfig.tomlConfig && (
TOML Config:
                                    {parsedConfig.tomlConfig.substring(0, 300)}
                                    {parsedConfig.tomlConfig.length > 300 &&
                                      "..."}
                                  
)}
)} {/* Gemini config */} {parsedConfig.type === "gemini" && parsedConfig.env && (
{Object.entries(parsedConfig.env).map( ([key, value]) => (
{key} {maskValue(key, String(value))}
), )}
)}
)} {/* Config URL (if remote) */} {request.configUrl && (
{t("deeplink.configUrl")}
{request.configUrl}
)}
)} {/* Usage Script Configuration (v3.9+) */} {request.usageScript && (
{t("deeplink.usageScript", { defaultValue: "用量查询", })}
{request.usageEnabled !== false ? t("deeplink.usageScriptEnabled", { defaultValue: "已启用", }) : t("deeplink.usageScriptDisabled", { defaultValue: "未启用", })}
{/* Usage API Key (if different from provider) */} {request.usageApiKey && request.usageApiKey !== request.apiKey && (
{t("deeplink.usageApiKey", { defaultValue: "用量 API Key", })}
{request.usageApiKey.length > 4 ? `${request.usageApiKey.substring(0, 4)}${"*".repeat(12)}` : "****"}
)} {/* Usage Base URL (if different from provider) */} {request.usageBaseUrl && request.usageBaseUrl !== request.endpoint && (
{t("deeplink.usageBaseUrl", { defaultValue: "用量查询地址", })}
{request.usageBaseUrl}
)} {/* Auto Query Interval */} {request.usageAutoInterval && request.usageAutoInterval > 0 && (
{t("deeplink.usageAutoInterval", { defaultValue: "自动查询", })}
{t("deeplink.usageAutoIntervalValue", { defaultValue: "每 {{minutes}} 分钟", minutes: request.usageAutoInterval, })}
)}
)} {/* Warning */}
{t("deeplink.warning")}
)}
)}
); } ================================================ FILE: src/components/IconPicker.tsx ================================================ import React, { useState, useMemo } from "react"; import { useTranslation } from "react-i18next"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { ProviderIcon } from "./ProviderIcon"; import { iconList } from "@/icons/extracted"; import { searchIcons, getIconMetadata } from "@/icons/extracted/metadata"; import { cn } from "@/lib/utils"; interface IconPickerProps { value?: string; // 当前选中的图标 onValueChange: (icon: string) => void; // 选择回调 color?: string; // 预览颜色 } export const IconPicker: React.FC = ({ value, onValueChange, }) => { const { t } = useTranslation(); const [searchQuery, setSearchQuery] = useState(""); // 过滤图标列表 const filteredIcons = useMemo(() => { if (!searchQuery) return iconList; return searchIcons(searchQuery); }, [searchQuery]); return (
setSearchQuery(e.target.value)} className="mt-2" />
{filteredIcons.map((iconName) => { const meta = getIconMetadata(iconName); const isSelected = value === iconName; return ( ); })}
{filteredIcons.length === 0 && (
{t("iconPicker.noResults", { defaultValue: "未找到匹配的图标" })}
)}
); }; ================================================ FILE: src/components/JsonEditor.tsx ================================================ import React, { useRef, useEffect, useMemo } from "react"; import { EditorView, basicSetup } from "codemirror"; import { json } from "@codemirror/lang-json"; import { javascript } from "@codemirror/lang-javascript"; import { oneDark } from "@codemirror/theme-one-dark"; import { EditorState } from "@codemirror/state"; import { placeholder } from "@codemirror/view"; import { linter, Diagnostic } from "@codemirror/lint"; import { useTranslation } from "react-i18next"; import { Wand2 } from "lucide-react"; import { toast } from "sonner"; import { formatJSON } from "@/utils/formatters"; interface JsonEditorProps { id?: string; value: string; onChange: (value: string) => void; placeholder?: string; darkMode?: boolean; rows?: number; showValidation?: boolean; language?: "json" | "javascript"; height?: string | number; showMinimap?: boolean; // 添加此属性以防未来使用 } const JsonEditor: React.FC = ({ value, onChange, placeholder: placeholderText = "", darkMode = false, rows = 12, showValidation = true, language = "json", height, }) => { const { t } = useTranslation(); const editorRef = useRef(null); const viewRef = useRef(null); // JSON linter 函数 const jsonLinter = useMemo( () => linter((view) => { const diagnostics: Diagnostic[] = []; if (!showValidation || language !== "json") return diagnostics; const doc = view.state.doc.toString(); if (!doc.trim()) return diagnostics; try { const parsed = JSON.parse(doc); // 检查是否是JSON对象 if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) { // 格式正确 } else { diagnostics.push({ from: 0, to: doc.length, severity: "error", message: t("jsonEditor.mustBeObject"), }); } } catch (e) { // 简单处理JSON解析错误 const message = e instanceof SyntaxError ? e.message : t("jsonEditor.invalidJson"); diagnostics.push({ from: 0, to: doc.length, severity: "error", message, }); } return diagnostics; }), [showValidation, language, t], ); useEffect(() => { if (!editorRef.current) return; // 创建编辑器扩展 const minHeightPx = height ? undefined : Math.max(1, rows) * 18; // 使用 baseTheme 定义基础样式,优先级低于 oneDark,但可以正确响应主题 const baseTheme = EditorView.baseTheme({ ".cm-editor": { border: "1px solid hsl(var(--border))", borderRadius: "0.5rem", background: "transparent", }, ".cm-editor.cm-focused": { outline: "none", borderColor: "hsl(var(--primary))", }, ".cm-scroller": { background: "transparent", }, ".cm-gutters": { background: "transparent", borderRight: "1px solid hsl(var(--border))", color: "hsl(var(--muted-foreground))", }, ".cm-selectionBackground, .cm-content ::selection": { background: "hsl(var(--primary) / 0.18)", }, ".cm-selectionMatch": { background: "hsl(var(--primary) / 0.12)", }, ".cm-activeLine": { background: "hsl(var(--primary) / 0.08)", }, ".cm-activeLineGutter": { background: "hsl(var(--primary) / 0.08)", }, }); // 使用 theme 定义尺寸和字体样式 const heightValue = height ? typeof height === "number" ? `${height}px` : height : undefined; const sizingTheme = EditorView.theme({ "&": heightValue ? { height: heightValue } : { minHeight: `${minHeightPx}px` }, ".cm-scroller": { overflow: "auto" }, ".cm-content": { fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace", fontSize: "14px", }, }); const extensions = [ basicSetup, language === "javascript" ? javascript() : json(), placeholder(placeholderText || ""), baseTheme, sizingTheme, jsonLinter, EditorView.updateListener.of((update) => { if (update.docChanged) { const newValue = update.state.doc.toString(); onChange(newValue); } }), ]; // 如果启用深色模式,添加深色主题 if (darkMode) { extensions.push(oneDark); // 在 oneDark 之后强制覆盖边框样式 extensions.push( EditorView.theme({ ".cm-editor": { border: "1px solid hsl(var(--border))", borderRadius: "0.5rem", background: "transparent", }, ".cm-editor.cm-focused": { outline: "none", borderColor: "hsl(var(--primary))", }, ".cm-scroller": { background: "transparent", }, ".cm-gutters": { background: "transparent", borderRight: "1px solid hsl(var(--border))", color: "hsl(var(--muted-foreground))", }, ".cm-selectionBackground, .cm-content ::selection": { background: "hsl(var(--primary) / 0.18)", }, ".cm-selectionMatch": { background: "hsl(var(--primary) / 0.12)", }, ".cm-activeLine": { background: "hsl(var(--primary) / 0.08)", }, ".cm-activeLineGutter": { background: "hsl(var(--primary) / 0.08)", }, }), ); } // 创建初始状态 const state = EditorState.create({ doc: value, extensions, }); // 创建编辑器视图 const view = new EditorView({ state, parent: editorRef.current, }); viewRef.current = view; // 清理函数 return () => { view.destroy(); viewRef.current = null; }; }, [darkMode, rows, height, language, jsonLinter]); // 依赖项中不包含 onChange 和 placeholder,避免不必要的重建 // 当 value 从外部改变时更新编辑器内容 useEffect(() => { if (viewRef.current && viewRef.current.state.doc.toString() !== value) { const transaction = viewRef.current.state.update({ changes: { from: 0, to: viewRef.current.state.doc.length, insert: value, }, }); viewRef.current.dispatch(transaction); } }, [value]); // 格式化处理函数 const handleFormat = () => { if (!viewRef.current) return; const currentValue = viewRef.current.state.doc.toString(); if (!currentValue.trim()) return; try { const formatted = formatJSON(currentValue); onChange(formatted); toast.success(t("common.formatSuccess", { defaultValue: "格式化成功" }), { closeButton: true, }); } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); toast.error( t("common.formatError", { defaultValue: "格式化失败:{{error}}", error: errorMessage, }), ); } }; const isFullHeight = height === "100%"; return (
{language === "json" && ( )}
); }; export default JsonEditor; ================================================ FILE: src/components/MarkdownEditor.tsx ================================================ import React, { useRef, useEffect } from "react"; import { EditorView, basicSetup } from "codemirror"; import { markdown } from "@codemirror/lang-markdown"; import { oneDark } from "@codemirror/theme-one-dark"; import { EditorState } from "@codemirror/state"; import { placeholder as placeholderExt } from "@codemirror/view"; interface MarkdownEditorProps { value: string; onChange?: (value: string) => void; placeholder?: string; darkMode?: boolean; readOnly?: boolean; className?: string; minHeight?: string; maxHeight?: string; } const MarkdownEditor: React.FC = ({ value, onChange, placeholder: placeholderText = "", darkMode = false, readOnly = false, className = "", minHeight = "300px", maxHeight, }) => { const editorRef = useRef(null); const viewRef = useRef(null); useEffect(() => { if (!editorRef.current) return; // 定义基础主题 const baseTheme = EditorView.baseTheme({ "&": { height: "100%", minHeight, maxHeight: maxHeight || "none", }, ".cm-scroller": { overflow: "auto", fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace", fontSize: "14px", }, "&light .cm-content, &dark .cm-content": { padding: "12px 0", }, "&light .cm-editor, &dark .cm-editor": { backgroundColor: "transparent", }, "&.cm-focused": { outline: "none", }, }); const extensions = [ basicSetup, markdown(), baseTheme, EditorView.lineWrapping, EditorState.readOnly.of(readOnly), ]; if (!readOnly) { extensions.push( placeholderExt(placeholderText), EditorView.updateListener.of((update) => { if (update.docChanged && onChange) { onChange(update.state.doc.toString()); } }), ); } else { // 只读模式下隐藏光标和高亮行 extensions.push( EditorView.theme({ ".cm-cursor, .cm-dropCursor": { border: "none" }, ".cm-activeLine": { backgroundColor: "transparent !important" }, ".cm-activeLineGutter": { backgroundColor: "transparent !important" }, }), ); } // 如果启用深色模式,添加深色主题 if (darkMode) { extensions.push(oneDark); } else { // 浅色模式下的简单样式调整,使其更融入 UI extensions.push( EditorView.theme( { "&": { backgroundColor: "transparent", }, ".cm-content": { color: "#374151", // text-gray-700 }, ".cm-gutters": { backgroundColor: "#f9fafb", // bg-gray-50 color: "#9ca3af", // text-gray-400 borderRight: "1px solid #e5e7eb", // border-gray-200 }, ".cm-activeLineGutter": { backgroundColor: "#e5e7eb", }, }, { dark: false }, ), ); } // 创建初始状态 const state = EditorState.create({ doc: value, extensions, }); // 创建编辑器视图 const view = new EditorView({ state, parent: editorRef.current, }); viewRef.current = view; return () => { view.destroy(); viewRef.current = null; }; }, [darkMode, readOnly, minHeight, maxHeight, placeholderText]); // 添加 placeholderText 依赖以支持国际化切换 // 当 value 从外部改变时更新编辑器内容 useEffect(() => { if (viewRef.current && viewRef.current.state.doc.toString() !== value) { const transaction = viewRef.current.state.update({ changes: { from: 0, to: viewRef.current.state.doc.length, insert: value, }, }); viewRef.current.dispatch(transaction); } }, [value]); return (
); }; export default MarkdownEditor; ================================================ FILE: src/components/ProviderIcon.tsx ================================================ import React, { useMemo } from "react"; import { getIcon, hasIcon, getIconMetadata } from "@/icons/extracted"; import { cn } from "@/lib/utils"; interface ProviderIconProps { icon?: string; // 图标名称 name: string; // 供应商名称(用于 fallback) color?: string; // 自定义颜色 (Deprecated, kept for compatibility but ignored for SVG) size?: number | string; // 尺寸 className?: string; showFallback?: boolean; // 是否显示 fallback } export const ProviderIcon: React.FC = ({ icon, name, color, size = 32, className, showFallback = true, }) => { // 获取图标 SVG const iconSvg = useMemo(() => { if (icon && hasIcon(icon)) { return getIcon(icon); } return ""; }, [icon]); // 计算尺寸样式 const sizeStyle = useMemo(() => { const sizeValue = typeof size === "number" ? `${size}px` : size; return { width: sizeValue, height: sizeValue, // 内嵌 SVG 使用 1em 作为尺寸基准,这里同步 fontSize 让图标实际跟随 size 放大 fontSize: sizeValue, lineHeight: 1, }; }, [size]); // 获取有效颜色:优先使用传入的有效 color,否则从元数据获取 defaultColor const effectiveColor = useMemo(() => { // 只有当 color 是有效的非空字符串时才使用 if (color && typeof color === "string" && color.trim() !== "") { return color; } // 否则从元数据获取 defaultColor if (icon) { const metadata = getIconMetadata(icon); // 只有当 defaultColor 不是 currentColor 时才使用 if (metadata?.defaultColor && metadata.defaultColor !== "currentColor") { return metadata.defaultColor; } } return undefined; }, [color, icon]); // 如果有图标,显示图标 if (iconSvg) { return ( ); } // Fallback:显示首字母 if (showFallback) { const initials = name .split(" ") .map((word) => word[0]) .join("") .toUpperCase() .slice(0, 2); const fallbackFontSize = typeof size === "number" ? `${Math.max(size * 0.5, 12)}px` : "0.5em"; return ( {initials} ); } return null; }; ================================================ FILE: src/components/UpdateBadge.tsx ================================================ import { useUpdate } from "@/contexts/UpdateContext"; import { useTranslation } from "react-i18next"; import { Button } from "@/components/ui/button"; import { ArrowUpCircle } from "lucide-react"; interface UpdateBadgeProps { className?: string; onClick?: () => void; } export function UpdateBadge({ className = "", onClick }: UpdateBadgeProps) { const { hasUpdate, updateInfo } = useUpdate(); const { t } = useTranslation(); const isActive = hasUpdate && updateInfo; const title = isActive ? t("settings.updateAvailable", { version: updateInfo?.availableVersion ?? "", }) : t("settings.checkForUpdates"); if (!isActive) { return null; } return ( ); } ================================================ FILE: src/components/UsageFooter.tsx ================================================ import React from "react"; import { RefreshCw, AlertCircle, Clock } from "lucide-react"; import { useTranslation } from "react-i18next"; import { type AppId } from "@/lib/api"; import { useUsageQuery } from "@/lib/query/queries"; import { UsageData, Provider } from "@/types"; interface UsageFooterProps { provider: Provider; providerId: string; appId: AppId; usageEnabled: boolean; // 是否启用了用量查询 isCurrent: boolean; // 是否为当前激活的供应商 isInConfig?: boolean; // OpenCode: 是否已添加到配置 inline?: boolean; // 是否内联显示(在按钮左侧) } const UsageFooter: React.FC = ({ provider, providerId, appId, usageEnabled, isCurrent, isInConfig = false, inline = false, }) => { const { t } = useTranslation(); // 统一的用量查询(自动查询仅对当前激活的供应商启用) // OpenCode(累加模式):使用 isInConfig 代替 isCurrent const shouldAutoQuery = appId === "opencode" ? isInConfig : isCurrent; const autoQueryInterval = shouldAutoQuery ? provider.meta?.usage_script?.autoQueryInterval || 0 : 0; const { data: usage, isFetching: loading, lastQueriedAt, refetch, } = useUsageQuery(providerId, appId, { enabled: usageEnabled, autoQueryInterval, }); // 🆕 定期更新当前时间,用于刷新相对时间显示 const [now, setNow] = React.useState(Date.now()); React.useEffect(() => { if (!lastQueriedAt) return; // 每30秒更新一次当前时间,触发相对时间显示的刷新 const interval = setInterval(() => { setNow(Date.now()); }, 30000); // 30秒 return () => clearInterval(interval); }, [lastQueriedAt]); // 只在启用用量查询且有数据时显示 if (!usageEnabled || !usage) return null; // 错误状态 if (!usage.success) { if (inline) { return (
{t("usage.queryFailed")}
); } return (
{usage.error || t("usage.queryFailed")}
{/* 刷新按钮 */}
); } const usageDataList = usage.data || []; // 无数据时不显示 if (usageDataList.length === 0) return null; // 内联模式:仅显示第一个套餐的核心数据(分上下两行) if (inline) { const firstUsage = usageDataList[0]; const isExpired = firstUsage.isValid === false; return (
{/* 第一行:更新时间和刷新按钮 */}
{/* 上次查询时间 */} {lastQueriedAt ? formatRelativeTime(lastQueriedAt, now, t) : t("usage.never", { defaultValue: "从未更新" })} {/* 刷新按钮 */}
{/* 第二行:用量和剩余 */}
{/* 已用 */} {firstUsage.used !== undefined && (
{t("usage.used")} {firstUsage.used.toFixed(2)}
)} {/* 剩余 */} {firstUsage.remaining !== undefined && (
{t("usage.remaining")} {firstUsage.remaining.toFixed(2)}
)} {/* 单位 */} {firstUsage.unit && ( {firstUsage.unit} )} {/* 扩展字段 extra */} {firstUsage.extra && ( {firstUsage.extra} )}
); } return (
{/* 标题行:包含刷新按钮和自动查询时间 */}
{t("usage.planUsage")}
{/* 自动查询时间提示 */} {lastQueriedAt && ( {formatRelativeTime(lastQueriedAt, now, t)} )}
{/* 套餐列表 */}
{usageDataList.map((usageData, index) => ( ))}
); }; // 单个套餐数据展示组件 const UsagePlanItem: React.FC<{ data: UsageData }> = ({ data }) => { const { t } = useTranslation(); const { planName, extra, isValid, invalidMessage, total, used, remaining, unit, } = data; // 判断套餐是否失效(isValid 为 false 或未定义时视为有效) const isExpired = isValid === false; return (
{/* 标题部分:25% */}
{planName ? ( 💰 {planName} ) : ( )}
{/* 扩展字段:30% */}
{extra && ( {extra} )} {isExpired && ( {invalidMessage || t("usage.invalid")} )}
{/* 用量信息:45% */}
{/* 总额度 */} {total !== undefined && ( <> {t("usage.total")} {total === -1 ? "∞" : total.toFixed(2)} | )} {/* 已用额度 */} {used !== undefined && ( <> {t("usage.used")} {used.toFixed(2)} | )} {/* 剩余额度 - 突出显示 */} {remaining !== undefined && ( <> {t("usage.remaining")} {remaining.toFixed(2)} )} {unit && ( {unit} )}
); }; // 格式化相对时间 function formatRelativeTime( timestamp: number, now: number, t: (key: string, options?: { count?: number }) => string, ): string { const diff = Math.floor((now - timestamp) / 1000); // 秒 if (diff < 60) { return t("usage.justNow"); } else if (diff < 3600) { const minutes = Math.floor(diff / 60); return t("usage.minutesAgo", { count: minutes }); } else if (diff < 86400) { const hours = Math.floor(diff / 3600); return t("usage.hoursAgo", { count: hours }); } else { const days = Math.floor(diff / 86400); return t("usage.daysAgo", { count: days }); } } export default UsageFooter; ================================================ FILE: src/components/UsageScriptModal.tsx ================================================ import React, { useState } from "react"; import { Play, Wand2, Eye, EyeOff, Save } from "lucide-react"; import { toast } from "sonner"; import { useTranslation } from "react-i18next"; import { useQueryClient } from "@tanstack/react-query"; import { Provider, UsageScript, UsageData } from "@/types"; import { usageApi, settingsApi, type AppId } from "@/lib/api"; import { copilotGetUsage, copilotGetUsageForAccount } from "@/lib/api/copilot"; import { useSettingsQuery } from "@/lib/query"; import { resolveManagedAccountId } from "@/lib/authBinding"; import { extractCodexBaseUrl } from "@/utils/providerConfigUtils"; import JsonEditor from "./JsonEditor"; import * as prettier from "prettier/standalone"; import * as parserBabel from "prettier/parser-babel"; import * as pluginEstree from "prettier/plugins/estree"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Switch } from "@/components/ui/switch"; import { FullScreenPanel } from "@/components/common/FullScreenPanel"; import { ConfirmDialog } from "@/components/ConfirmDialog"; import { cn } from "@/lib/utils"; import { TEMPLATE_TYPES, PROVIDER_TYPES } from "@/config/constants"; interface UsageScriptModalProps { provider: Provider; appId: AppId; isOpen: boolean; onClose: () => void; onSave: (script: UsageScript) => void; } // 生成预设模板的函数(支持国际化) const generatePresetTemplates = ( t: (key: string) => string, ): Record => ({ [TEMPLATE_TYPES.CUSTOM]: `({ request: { url: "", method: "GET", headers: {} }, extractor: function(response) { return { remaining: 0, unit: "USD" }; } })`, [TEMPLATE_TYPES.GENERAL]: `({ request: { url: "{{baseUrl}}/user/balance", method: "GET", headers: { "Authorization": "Bearer {{apiKey}}", "User-Agent": "cc-switch/1.0" } }, extractor: function(response) { return { isValid: response.is_active || true, remaining: response.balance, unit: "USD" }; } })`, [TEMPLATE_TYPES.NEW_API]: `({ request: { url: "{{baseUrl}}/api/user/self", method: "GET", headers: { "Content-Type": "application/json", "Authorization": "Bearer {{accessToken}}", "New-Api-User": "{{userId}}" }, }, extractor: function (response) { if (response.success && response.data) { return { planName: response.data.group || "${t("usageScript.defaultPlan")}", remaining: response.data.quota / 500000, used: response.data.used_quota / 500000, total: (response.data.quota + response.data.used_quota) / 500000, unit: "USD", }; } return { isValid: false, invalidMessage: response.message || "${t("usageScript.queryFailedMessage")}" }; }, })`, // GitHub Copilot 模板不需要脚本,使用专用 API [TEMPLATE_TYPES.GITHUB_COPILOT]: "", }); // 模板名称国际化键映射 const TEMPLATE_NAME_KEYS: Record = { [TEMPLATE_TYPES.CUSTOM]: "usageScript.templateCustom", [TEMPLATE_TYPES.GENERAL]: "usageScript.templateGeneral", [TEMPLATE_TYPES.NEW_API]: "usageScript.templateNewAPI", [TEMPLATE_TYPES.GITHUB_COPILOT]: "usageScript.templateCopilot", }; const UsageScriptModal: React.FC = ({ provider, appId, isOpen, onClose, onSave, }) => { const { t } = useTranslation(); const queryClient = useQueryClient(); const { data: settingsData } = useSettingsQuery(); const [showUsageConfirm, setShowUsageConfirm] = useState(false); // 生成带国际化的预设模板 const PRESET_TEMPLATES = generatePresetTemplates(t); // 从 provider 的 settingsConfig 中提取 API Key 和 Base URL const getProviderCredentials = (): { apiKey: string | undefined; baseUrl: string | undefined; } => { try { const config = provider.settingsConfig; if (!config) return { apiKey: undefined, baseUrl: undefined }; // 处理不同应用的配置格式 if (appId === "claude") { // Claude: { env: { ANTHROPIC_AUTH_TOKEN | ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL } } const env = (config as any).env || {}; return { apiKey: env.ANTHROPIC_AUTH_TOKEN || env.ANTHROPIC_API_KEY, baseUrl: env.ANTHROPIC_BASE_URL, }; } else if (appId === "codex") { // Codex: { auth: { OPENAI_API_KEY }, config: TOML string with base_url } const auth = (config as any).auth || {}; const configToml = (config as any).config || ""; return { apiKey: auth.OPENAI_API_KEY, baseUrl: extractCodexBaseUrl(configToml), }; } else if (appId === "gemini") { // Gemini: { env: { GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL } } const env = (config as any).env || {}; return { apiKey: env.GEMINI_API_KEY, baseUrl: env.GOOGLE_GEMINI_BASE_URL, }; } return { apiKey: undefined, baseUrl: undefined }; } catch (error) { console.error("Failed to extract provider credentials:", error); return { apiKey: undefined, baseUrl: undefined }; } }; const providerCredentials = getProviderCredentials(); const [script, setScript] = useState(() => { const savedScript = provider.meta?.usage_script; const defaultScript = { enabled: false, language: "javascript" as const, code: PRESET_TEMPLATES[TEMPLATE_TYPES.GENERAL], timeout: 10, }; if (!savedScript) { return defaultScript; } return savedScript; }); const [testing, setTesting] = useState(false); // 🔧 失焦时的验证(严格)- 仅确保有效整数 const validateTimeout = (value: string): number => { const num = Number(value); if (isNaN(num) || value.trim() === "") { return 10; } if (!Number.isInteger(num)) { toast.warning( t("usageScript.timeoutMustBeInteger") || "超时时间必须为整数", ); } if (num < 0) { toast.error( t("usageScript.timeoutCannotBeNegative") || "超时时间不能为负数", ); return 10; } return Math.floor(num); }; // 🔧 失焦时的验证(严格)- 自动查询间隔 const validateAndClampInterval = (value: string): number => { const num = Number(value); if (isNaN(num) || value.trim() === "") { return 0; } if (!Number.isInteger(num)) { toast.warning( t("usageScript.intervalMustBeInteger") || "自动查询间隔必须为整数", ); } if (num < 0) { toast.error( t("usageScript.intervalCannotBeNegative") || "自动查询间隔不能为负数", ); return 0; } const clamped = Math.max(0, Math.min(1440, Math.floor(num))); if (clamped !== num && num > 0) { toast.info( t("usageScript.intervalAdjusted", { value: clamped }) || `自动查询间隔已调整为 ${clamped} 分钟`, ); } return clamped; }; const [selectedTemplate, setSelectedTemplate] = useState( () => { const existingScript = provider.meta?.usage_script; // Copilot 供应商默认使用 Copilot 模板 if (provider.meta?.providerType === PROVIDER_TYPES.GITHUB_COPILOT) { return TEMPLATE_TYPES.GITHUB_COPILOT; } // 优先使用保存的 templateType if (existingScript?.templateType) { return existingScript.templateType; } // 向后兼容:根据字段推断模板类型 // 检测 NEW_API 模板(有 accessToken 或 userId) if (existingScript?.accessToken || existingScript?.userId) { return TEMPLATE_TYPES.NEW_API; } // 检测 GENERAL 模板(有 apiKey 或 baseUrl) if (existingScript?.apiKey || existingScript?.baseUrl) { return TEMPLATE_TYPES.GENERAL; } // 新配置或无凭证:默认使用 GENERAL(与默认代码模板一致) return TEMPLATE_TYPES.GENERAL; }, ); const [showApiKey, setShowApiKey] = useState(false); const [showAccessToken, setShowAccessToken] = useState(false); const handleEnableToggle = (checked: boolean) => { if (checked && !settingsData?.usageConfirmed) { setShowUsageConfirm(true); } else { setScript({ ...script, enabled: checked }); } }; const handleUsageConfirm = async () => { setShowUsageConfirm(false); try { if (settingsData) { await settingsApi.save({ ...settingsData, usageConfirmed: true }); await queryClient.invalidateQueries({ queryKey: ["settings"] }); } } catch (error) { console.error("Failed to save usage confirmed:", error); } setScript({ ...script, enabled: true }); }; const handleSave = () => { // Copilot 模板不需要脚本验证 if (selectedTemplate !== TEMPLATE_TYPES.GITHUB_COPILOT) { if (script.enabled && !script.code.trim()) { toast.error(t("usageScript.scriptEmpty")); return; } if (script.enabled && !script.code.includes("return")) { toast.error(t("usageScript.mustHaveReturn"), { duration: 5000 }); return; } } // 保存时记录当前选择的模板类型 const scriptWithTemplate = { ...script, templateType: selectedTemplate as | "custom" | "general" | "newapi" | "github_copilot" | undefined, }; onSave(scriptWithTemplate); onClose(); }; const handleTest = async () => { setTesting(true); try { // Copilot 模板使用专用 API if (selectedTemplate === TEMPLATE_TYPES.GITHUB_COPILOT) { const accountId = resolveManagedAccountId( provider.meta, PROVIDER_TYPES.GITHUB_COPILOT, ); const usage = accountId ? await copilotGetUsageForAccount(accountId) : await copilotGetUsage(); const premium = usage.quota_snapshots.premium_interactions; const used = premium.entitlement - premium.remaining; const summary = `[${usage.copilot_plan}] ${t("usage.remaining")} ${premium.remaining}/${premium.entitlement} (${t("usageScript.resetDate")}: ${usage.quota_reset_date})`; toast.success(`${t("usageScript.testSuccess")}${summary}`, { duration: 3000, closeButton: true, }); // 更新缓存 queryClient.setQueryData(["usage", provider.id, appId], { success: true, data: [ { planName: usage.copilot_plan, remaining: premium.remaining, total: premium.entitlement, used: used, unit: t("usageScript.premiumRequests"), }, ], }); return; } const result = await usageApi.testScript( provider.id, appId, script.code, script.timeout, script.apiKey, script.baseUrl, script.accessToken, script.userId, selectedTemplate as "custom" | "general" | "newapi" | undefined, ); if (result.success && result.data && result.data.length > 0) { const summary = result.data .map((plan: UsageData) => { const planInfo = plan.planName ? `[${plan.planName}]` : ""; return `${planInfo} ${t("usage.remaining")} ${plan.remaining} ${plan.unit}`; }) .join(", "); toast.success(`${t("usageScript.testSuccess")}${summary}`, { duration: 3000, closeButton: true, }); // 🔧 测试成功后,更新主界面列表的用量查询缓存 queryClient.setQueryData(["usage", provider.id, appId], result); } else { toast.error( `${t("usageScript.testFailed")}: ${result.error || t("endpointTest.noResult")}`, { duration: 5000, }, ); } } catch (error: any) { toast.error( `${t("usageScript.testFailed")}: ${error?.message || t("common.unknown")}`, { duration: 5000, }, ); } finally { setTesting(false); } }; const handleFormat = async () => { try { const formatted = await prettier.format(script.code, { parser: "babel", plugins: [parserBabel as any, pluginEstree as any], semi: true, singleQuote: false, tabWidth: 2, printWidth: 80, }); setScript({ ...script, code: formatted.trim() }); toast.success(t("usageScript.formatSuccess"), { duration: 1000, closeButton: true, }); } catch (error: any) { toast.error( `${t("usageScript.formatFailed")}: ${error?.message || t("jsonEditor.invalidJson")}`, { duration: 3000, }, ); } }; const handleUsePreset = (presetName: string) => { const preset = PRESET_TEMPLATES[presetName]; if (preset) { if (presetName === TEMPLATE_TYPES.CUSTOM) { // 🔧 自定义模式:用户应该在脚本中直接写完整 URL 和凭证,而不是依赖变量替换 // 这样可以避免同源检查导致的问题 // 如果用户想使用变量,需要手动在配置中设置 baseUrl/apiKey setScript({ ...script, code: preset, // 清除凭证,用户可选择手动输入或保持空 apiKey: undefined, baseUrl: undefined, accessToken: undefined, userId: undefined, }); } else if (presetName === TEMPLATE_TYPES.GENERAL) { setScript({ ...script, code: preset, accessToken: undefined, userId: undefined, }); } else if (presetName === TEMPLATE_TYPES.NEW_API) { setScript({ ...script, code: preset, apiKey: undefined, }); } else if (presetName === TEMPLATE_TYPES.GITHUB_COPILOT) { // Copilot 模板不需要脚本和凭证,使用专用 API setScript({ ...script, code: "", apiKey: undefined, baseUrl: undefined, accessToken: undefined, userId: undefined, }); } setSelectedTemplate(presetName); } }; const shouldShowCredentialsConfig = selectedTemplate === TEMPLATE_TYPES.GENERAL || selectedTemplate === TEMPLATE_TYPES.NEW_API; const footer = ( <>
); return (

{t("usageScript.enableUsageQuery")}

{script.enabled && (
{/* 预设模板选择 */}
{Object.keys(PRESET_TEMPLATES) .filter((name) => { const isCopilotProvider = provider.meta?.providerType === "github_copilot"; // Copilot 供应商只显示 copilot 模板,其他供应商不显示 copilot 模板 if (isCopilotProvider) { return name === TEMPLATE_TYPES.GITHUB_COPILOT; } return name !== TEMPLATE_TYPES.GITHUB_COPILOT; }) .map((name) => { const isSelected = selectedTemplate === name; return ( ); })}
{/* 自定义模式:变量提示和具体值 */} {selectedTemplate === TEMPLATE_TYPES.CUSTOM && (

{t("usageScript.supportedVariables")}

{/* baseUrl */}
{"{{baseUrl}}"} = {providerCredentials.baseUrl ? ( {providerCredentials.baseUrl} ) : ( {t("common.notSet") || "未设置"} )}
{/* apiKey */}
{"{{apiKey}}"} = {providerCredentials.apiKey ? ( <> {showApiKey ? ( {providerCredentials.apiKey} ) : ( •••••••• )} ) : ( {t("common.notSet") || "未设置"} )}
)} {/* Copilot 模式:自动认证提示 */} {selectedTemplate === TEMPLATE_TYPES.GITHUB_COPILOT && (

{t("usageScript.copilotAutoAuth")}

)} {/* 凭证配置 */} {shouldShowCredentialsConfig && (

{t("usageScript.credentialsConfig")}

{t("usageScript.credentialsHint")}

{selectedTemplate === TEMPLATE_TYPES.GENERAL && ( <>
setScript({ ...script, apiKey: e.target.value }) } placeholder={t("usageScript.apiKeyPlaceholder")} autoComplete="off" className="border-white/10" /> {script.apiKey && ( )}
setScript({ ...script, baseUrl: e.target.value }) } placeholder={t("usageScript.baseUrlPlaceholder")} autoComplete="off" className="border-white/10" />
)} {selectedTemplate === TEMPLATE_TYPES.NEW_API && ( <>
setScript({ ...script, baseUrl: e.target.value }) } placeholder="https://api.newapi.com" autoComplete="off" className="border-white/10" />
setScript({ ...script, accessToken: e.target.value, }) } placeholder={t( "usageScript.accessTokenPlaceholder", )} autoComplete="off" className="border-white/10" /> {script.accessToken && ( )}
setScript({ ...script, userId: e.target.value }) } placeholder={t("usageScript.userIdPlaceholder")} autoComplete="off" className="border-white/10" />
)}
)} {/* 通用配置(始终显示) */}
{/* 超时时间 */}
setScript({ ...script, timeout: validateTimeout(e.target.value), }) } onBlur={(e) => setScript({ ...script, timeout: validateTimeout(e.target.value), }) } className="border-white/10" />
{/* 自动查询间隔 */}
setScript({ ...script, autoQueryInterval: validateAndClampInterval( e.target.value, ), }) } onBlur={(e) => setScript({ ...script, autoQueryInterval: validateAndClampInterval( e.target.value, ), }) } className="border-white/10" />
{/* 提取器代码 - Copilot 模板不需要 */} {selectedTemplate !== TEMPLATE_TYPES.GITHUB_COPILOT && (
{t("usageScript.extractorHint")}
setScript({ ...script, code: value })} height={480} language="javascript" showMinimap={false} />
)} {/* 帮助信息 - Copilot 模板不需要 */} {selectedTemplate !== TEMPLATE_TYPES.GITHUB_COPILOT && (

{t("usageScript.scriptHelp")}

{t("usageScript.configFormat")}
                    {`({
  request: {
    url: "{{baseUrl}}/api/usage",
    method: "POST",
    headers: {
      "Authorization": "Bearer {{apiKey}}",
      "User-Agent": "cc-switch/1.0"
    }
  },
  extractor: function(response) {
    return {
      isValid: !response.error,
      remaining: response.balance,
      unit: "USD"
    };
  }
})`}
                  
{t("usageScript.extractorFormat")}
  • {t("usageScript.fieldIsValid")}
  • {t("usageScript.fieldInvalidMessage")}
  • {t("usageScript.fieldRemaining")}
  • {t("usageScript.fieldUnit")}
  • {t("usageScript.fieldPlanName")}
  • {t("usageScript.fieldTotal")}
  • {t("usageScript.fieldUsed")}
  • {t("usageScript.fieldExtra")}
{t("usageScript.tips")}
  • {t("usageScript.tip1", { apiKey: "{{apiKey}}", baseUrl: "{{baseUrl}}", })}
  • {t("usageScript.tip2")}
  • {t("usageScript.tip3")}
)}
)} void handleUsageConfirm()} onCancel={() => setShowUsageConfirm(false)} />
); }; export default UsageScriptModal; ================================================ FILE: src/components/agents/AgentsPanel.tsx ================================================ import { Bot } from "lucide-react"; interface AgentsPanelProps { onOpenChange: (open: boolean) => void; } export function AgentsPanel({}: AgentsPanelProps) { return (

Coming Soon

The Agents management feature is currently under development. Stay tuned for powerful autonomous capabilities.

); } ================================================ FILE: src/components/common/AppCountBar.tsx ================================================ import React from "react"; import { Badge } from "@/components/ui/badge"; import type { AppId } from "@/lib/api/types"; import { APP_IDS, APP_ICON_MAP } from "@/config/appConfig"; interface AppCountBarProps { totalLabel: string; counts: Record; appIds?: AppId[]; } export const AppCountBar: React.FC = ({ totalLabel, counts, appIds = APP_IDS, }) => { return (
{totalLabel}
{appIds.map((app) => ( {APP_ICON_MAP[app].label}: {counts[app]} ))}
); }; ================================================ FILE: src/components/common/AppToggleGroup.tsx ================================================ import React from "react"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; import type { AppId } from "@/lib/api/types"; import { APP_IDS, APP_ICON_MAP } from "@/config/appConfig"; interface AppToggleGroupProps { apps: Record; onToggle: (app: AppId, enabled: boolean) => void; appIds?: AppId[]; } export const AppToggleGroup: React.FC = ({ apps, onToggle, appIds = APP_IDS, }) => { return (
{appIds.map((app) => { const { label, icon, activeClass } = APP_ICON_MAP[app]; const enabled = apps[app]; return (

{label} {enabled ? " ✓" : ""}

); })}
); }; ================================================ FILE: src/components/common/FullScreenPanel.tsx ================================================ import React from "react"; import { createPortal } from "react-dom"; import { motion, AnimatePresence } from "framer-motion"; import { ArrowLeft } from "lucide-react"; import { Button } from "@/components/ui/button"; import { isWindows, isLinux } from "@/lib/platform"; import { isTextEditableTarget } from "@/utils/domUtils"; interface FullScreenPanelProps { isOpen: boolean; title: string; onClose: () => void; children: React.ReactNode; footer?: React.ReactNode; } const DRAG_BAR_HEIGHT = isWindows() || isLinux() ? 0 : 28; // px - match App.tsx const HEADER_HEIGHT = 64; // px - match App.tsx /** * Reusable full-screen panel component * Handles portal rendering, header with back button, and footer * Uses solid theme colors without transparency */ export const FullScreenPanel: React.FC = ({ isOpen, title, onClose, children, footer, }) => { React.useEffect(() => { if (isOpen) { document.body.style.overflow = "hidden"; } return () => { document.body.style.overflow = ""; }; }, [isOpen]); // ESC 键关闭面板 const onCloseRef = React.useRef(onClose); React.useEffect(() => { onCloseRef.current = onClose; }, [onClose]); React.useEffect(() => { if (!isOpen) return; const handleKeyDown = (event: KeyboardEvent) => { if (event.key === "Escape") { // 子组件(例如 Radix 的 Select/Dialog/Dropdown)如果已经消费了 ESC,就不要再关闭整个面板 if (event.defaultPrevented) { return; } if (isTextEditableTarget(event.target)) { return; // 让输入框自己处理 ESC(比如清空、失焦等) } event.stopPropagation(); // 阻止事件继续冒泡到 window,避免触发 App.tsx 的全局监听 onCloseRef.current(); } }; // 使用冒泡阶段监听,让子组件(如 Radix UI)优先处理 ESC window.addEventListener("keydown", handleKeyDown, false); return () => { window.removeEventListener("keydown", handleKeyDown, false); }; }, [isOpen]); return createPortal( {isOpen && ( {/* Drag region - match App.tsx */}
{/* Header - match App.tsx */}

{title}

{/* Content */}
{children}
{/* Footer */} {footer && (
{footer}
)} )} , document.body, ); }; ================================================ FILE: src/components/common/ListItemRow.tsx ================================================ import React from "react"; interface ListItemRowProps { isLast?: boolean; children: React.ReactNode; } export const ListItemRow: React.FC = ({ isLast, children, }) => { return (
{children}
); }; ================================================ FILE: src/components/deeplink/McpConfirmation.tsx ================================================ import { useMemo } from "react"; import { useTranslation } from "react-i18next"; import { DeepLinkImportRequest } from "../../lib/api/deeplink"; import { decodeBase64Utf8 } from "../../lib/utils/base64"; export function McpConfirmation({ request, }: { request: DeepLinkImportRequest; }) { const { t } = useTranslation(); const mcpServers = useMemo(() => { if (!request.config) return null; try { const decoded = decodeBase64Utf8(request.config); const parsed = JSON.parse(decoded); return parsed.mcpServers || {}; } catch (e) { console.error("Failed to parse MCP config:", e); return null; } }, [request.config]); const targetApps = request.apps?.split(",") || []; const serverCount = Object.keys(mcpServers || {}).length; return (

{t("deeplink.mcp.title")}

{targetApps.map((app) => ( {app.trim()} ))}
{mcpServers && Object.entries(mcpServers).map(([id, spec]: [string, any]) => (
{id}
{spec.command ? `Command: ${spec.command} ` : `URL: ${spec.url} `}
))}
{request.enabled && (
⚠️ {t("deeplink.mcp.enabledWarning")}
)}
); } ================================================ FILE: src/components/deeplink/PromptConfirmation.tsx ================================================ import { useMemo } from "react"; import { useTranslation } from "react-i18next"; import { DeepLinkImportRequest } from "../../lib/api/deeplink"; import { decodeBase64Utf8 } from "../../lib/utils/base64"; export function PromptConfirmation({ request, }: { request: DeepLinkImportRequest; }) { const { t } = useTranslation(); const decodedContent = useMemo(() => { if (!request.content) return ""; return decodeBase64Utf8(request.content); }, [request.content]); return (

{t("deeplink.prompt.title")}

{request.app}
{request.name}
{request.description && (
{request.description}
)}
          {decodedContent.substring(0, 500)}
          {decodedContent.length > 500 && "..."}
        
{request.enabled && (
⚠️ {t("deeplink.prompt.enabledWarning")}
)}
); } ================================================ FILE: src/components/deeplink/SkillConfirmation.tsx ================================================ import { useTranslation } from "react-i18next"; import { DeepLinkImportRequest } from "../../lib/api/deeplink"; export function SkillConfirmation({ request, }: { request: DeepLinkImportRequest; }) { const { t } = useTranslation(); return (

{t("deeplink.skill.title")}

{request.repo}
{request.directory}
{request.branch || "main"}

ℹ️ {t("deeplink.skill.hint")}

{t("deeplink.skill.hintDetail")}

); } ================================================ FILE: src/components/env/EnvWarningBanner.tsx ================================================ import { useState } from "react"; import { useTranslation } from "react-i18next"; import { AlertTriangle, ChevronDown, ChevronUp, X, Trash2 } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; import type { EnvConflict } from "@/types/env"; import { deleteEnvVars } from "@/lib/api/env"; import { toast } from "sonner"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; interface EnvWarningBannerProps { conflicts: EnvConflict[]; onDismiss: () => void; onDeleted: () => void; } export function EnvWarningBanner({ conflicts, onDismiss, onDeleted, }: EnvWarningBannerProps) { const { t } = useTranslation(); const [isExpanded, setIsExpanded] = useState(false); const [selectedConflicts, setSelectedConflicts] = useState>( new Set(), ); const [isDeleting, setIsDeleting] = useState(false); const [showConfirmDialog, setShowConfirmDialog] = useState(false); if (conflicts.length === 0) { return null; } const toggleSelection = (key: string) => { const newSelection = new Set(selectedConflicts); if (newSelection.has(key)) { newSelection.delete(key); } else { newSelection.add(key); } setSelectedConflicts(newSelection); }; const toggleSelectAll = () => { if (selectedConflicts.size === conflicts.length) { setSelectedConflicts(new Set()); } else { setSelectedConflicts( new Set(conflicts.map((c) => `${c.varName}:${c.sourcePath}`)), ); } }; const handleDelete = async () => { setShowConfirmDialog(false); setIsDeleting(true); try { const conflictsToDelete = conflicts.filter((c) => selectedConflicts.has(`${c.varName}:${c.sourcePath}`), ); if (conflictsToDelete.length === 0) { toast.warning(t("env.error.noSelection")); return; } const backupInfo = await deleteEnvVars(conflictsToDelete); toast.success(t("env.delete.success"), { description: t("env.backup.location", { path: backupInfo.backupPath, }), duration: 5000, closeButton: true, }); // 清空选择并通知父组件 setSelectedConflicts(new Set()); onDeleted(); } catch (error) { console.error("删除环境变量失败:", error); toast.error(t("env.delete.error"), { description: String(error), }); } finally { setIsDeleting(false); } }; const getSourceDescription = (conflict: EnvConflict): string => { if (conflict.sourceType === "system") { if (conflict.sourcePath.includes("HKEY_CURRENT_USER")) { return t("env.source.userRegistry"); } else if (conflict.sourcePath.includes("HKEY_LOCAL_MACHINE")) { return t("env.source.systemRegistry"); } else { return t("env.source.systemEnv"); } } else { return conflict.sourcePath; } }; return ( <>

{t("env.warning.title")}

{t("env.warning.description", { count: conflicts.length })}

{isExpanded && (
{conflicts.map((conflict) => { const key = `${conflict.varName}:${conflict.sourcePath}`; return (
toggleSelection(key)} />

{t("env.field.value")}: {conflict.varValue}

{t("env.field.source")}:{" "} {getSourceDescription(conflict)}

); })}
)}
{t("env.confirm.title")}

{t("env.confirm.message", { count: selectedConflicts.size })}

{t("env.confirm.backupNotice")}

); } ================================================ FILE: src/components/icons/TerminalIcons.tsx ================================================ import { SVGProps } from "react"; export function ITermIcon(props: SVGProps) { return ( iTerm2 ); } export function AlacrittyIcon(props: SVGProps) { return ( Alacritty ); } export function WezTermIcon(props: SVGProps) { return ( WezTerm ); } export function GhosttyIcon(props: SVGProps) { return ( Ghostty ); } export function KittyIcon(props: SVGProps) { // Official icon is complex and has fixed width/height/viewBox in original. // Simplifying viewBox to 0 0 256 256 effectively as original was 240x240 but translated. // Original viewBox="0 0 240 240" with g transform="translate(0 -812.362)" and elements around y=850. // 850 - 812 = 38. So it's confusing. // Let's copy the raw SVG content but adapt it to be a component. // To make it behave like an icon, we should probably set viewBox="0 0 240 240" and keep the transform. // It relies on fill colors. If we want it to be monochrome (currentColor), we should remove fills or set them to currentColor. // However, official icons often have brand colors. The user said "official icon", which implies color. // But usually in a dropdown we might want monochrome or original color. // simple-icons are usually monochrome. // Let's keep Kitty as original color since it's complex, OR mono if it works? // The kitty icon has multiple paths with different colors. I'll preserve them for now as it's "official". // If it looks weird in dark mode/light mode, we might need to adjust. return ( ); } ================================================ FILE: src/components/mcp/McpFormModal.tsx ================================================ import React, { useMemo, useState, useEffect } from "react"; import { useTranslation } from "react-i18next"; import { toast } from "sonner"; import { Save, Plus, AlertCircle, ChevronDown, ChevronUp } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; import { Input } from "@/components/ui/input"; import JsonEditor from "@/components/JsonEditor"; import type { AppId } from "@/lib/api/types"; import { McpServer, McpServerSpec } from "@/types"; import { mcpPresets, getMcpPresetWithDescription } from "@/config/mcpPresets"; import McpWizardModal from "./McpWizardModal"; import { extractErrorMessage, translateMcpBackendError, } from "@/utils/errorUtils"; import { tomlToMcpServer, extractIdFromToml, mcpServerToToml, } from "@/utils/tomlUtils"; import { normalizeTomlText } from "@/utils/textNormalization"; import { parseSmartMcpJson } from "@/utils/formatters"; import { useMcpValidation } from "./useMcpValidation"; import { useUpsertMcpServer } from "@/hooks/useMcp"; import { FullScreenPanel } from "@/components/common/FullScreenPanel"; interface McpFormModalProps { editingId?: string; initialData?: McpServer; onSave: () => Promise; onClose: () => void; existingIds?: string[]; defaultFormat?: "json" | "toml"; defaultEnabledApps?: AppId[]; } const McpFormModal: React.FC = ({ editingId, initialData, onSave, onClose, existingIds = [], defaultFormat = "json", defaultEnabledApps = ["claude", "codex", "gemini"], }) => { const { t } = useTranslation(); const { formatTomlError, validateTomlConfig, validateJsonConfig } = useMcpValidation(); const upsertMutation = useUpsertMcpServer(); const [formId, setFormId] = useState( () => editingId || initialData?.id || "", ); const [formName, setFormName] = useState(initialData?.name || ""); const [formDescription, setFormDescription] = useState( initialData?.description || "", ); const [formHomepage, setFormHomepage] = useState(initialData?.homepage || ""); const [formDocs, setFormDocs] = useState(initialData?.docs || ""); const [formTags, setFormTags] = useState(initialData?.tags?.join(", ") || ""); const [enabledApps, setEnabledApps] = useState<{ claude: boolean; codex: boolean; gemini: boolean; opencode: boolean; openclaw: boolean; }>(() => { if (initialData?.apps) { return { ...initialData.apps }; } return { claude: defaultEnabledApps.includes("claude"), codex: defaultEnabledApps.includes("codex"), gemini: defaultEnabledApps.includes("gemini"), opencode: defaultEnabledApps.includes("opencode"), openclaw: defaultEnabledApps.includes("openclaw"), }; }); const isEditing = !!editingId; const hasAdditionalInfo = !!( initialData?.description || initialData?.tags?.length || initialData?.homepage || initialData?.docs ); const [showMetadata, setShowMetadata] = useState( isEditing ? hasAdditionalInfo : false, ); const useTomlFormat = useMemo(() => { if (initialData?.server) { return defaultFormat === "toml"; } return defaultFormat === "toml"; }, [defaultFormat, initialData]); const [formConfig, setFormConfig] = useState(() => { const spec = initialData?.server; if (!spec) return ""; if (useTomlFormat) { return mcpServerToToml(spec); } return JSON.stringify(spec, null, 2); }); const [configError, setConfigError] = useState(""); const [saving, setSaving] = useState(false); const [isWizardOpen, setIsWizardOpen] = useState(false); const [idError, setIdError] = useState(""); const [isDarkMode, setIsDarkMode] = useState(false); useEffect(() => { setIsDarkMode(document.documentElement.classList.contains("dark")); const observer = new MutationObserver(() => { setIsDarkMode(document.documentElement.classList.contains("dark")); }); observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"], }); return () => observer.disconnect(); }, []); const useToml = useTomlFormat; const wizardInitialSpec = useMemo(() => { const fallback = initialData?.server; if (!formConfig.trim()) { return fallback; } if (useToml) { try { return tomlToMcpServer(formConfig); } catch { return fallback; } } try { const parsed = JSON.parse(formConfig); if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) { return parsed as McpServerSpec; } return fallback; } catch { return fallback; } }, [formConfig, initialData, useToml]); const [selectedPreset, setSelectedPreset] = useState( isEditing ? null : -1, ); const handleIdChange = (value: string) => { setFormId(value); if (!isEditing) { const exists = existingIds.includes(value.trim()); setIdError(exists ? t("mcp.error.idExists") : ""); } }; const ensureUniqueId = (base: string): string => { let candidate = base.trim(); if (!candidate) candidate = "mcp-server"; if (!existingIds.includes(candidate)) return candidate; let i = 1; while (existingIds.includes(`${candidate}-${i}`)) i++; return `${candidate}-${i}`; }; const applyPreset = (index: number) => { if (index < 0 || index >= mcpPresets.length) return; const preset = mcpPresets[index]; const presetWithDesc = getMcpPresetWithDescription(preset, t); const id = ensureUniqueId(presetWithDesc.id); setFormId(id); setFormName(presetWithDesc.name || presetWithDesc.id); setFormDescription(presetWithDesc.description || ""); setFormHomepage(presetWithDesc.homepage || ""); setFormDocs(presetWithDesc.docs || ""); setFormTags(presetWithDesc.tags?.join(", ") || ""); if (useToml) { const toml = mcpServerToToml(presetWithDesc.server); setFormConfig(toml); setConfigError(validateTomlConfig(toml)); } else { const json = JSON.stringify(presetWithDesc.server, null, 2); setFormConfig(json); setConfigError(validateJsonConfig(json)); } setSelectedPreset(index); }; const applyCustom = () => { setSelectedPreset(-1); setFormId(""); setFormName(""); setFormDescription(""); setFormHomepage(""); setFormDocs(""); setFormTags(""); setFormConfig(""); setConfigError(""); }; const handleConfigChange = (value: string) => { const nextValue = useToml ? normalizeTomlText(value) : value; setFormConfig(nextValue); if (useToml) { const err = validateTomlConfig(nextValue); if (err) { setConfigError(err); return; } if (nextValue.trim() && !formId.trim()) { const extractedId = extractIdFromToml(nextValue); if (extractedId) { setFormId(extractedId); } } } else { try { const result = parseSmartMcpJson(value); const configJson = JSON.stringify(result.config); const validationErr = validateJsonConfig(configJson); if (validationErr) { setConfigError(validationErr); return; } if (result.id && !formId.trim() && !isEditing) { const uniqueId = ensureUniqueId(result.id); setFormId(uniqueId); if (!formName.trim()) { setFormName(result.id); } } setConfigError(""); } catch (err: any) { const errorMessage = err?.message || String(err); setConfigError(t("mcp.error.jsonInvalid") + ": " + errorMessage); } } }; const handleWizardApply = (title: string, json: string) => { setFormId(title); if (!formName.trim()) { setFormName(title); } if (useToml) { try { const server = JSON.parse(json) as McpServerSpec; const toml = mcpServerToToml(server); setFormConfig(toml); setConfigError(validateTomlConfig(toml)); } catch (e: any) { setConfigError(t("mcp.error.jsonInvalid")); } } else { setFormConfig(json); setConfigError(validateJsonConfig(json)); } }; const handleSubmit = async () => { const trimmedId = formId.trim(); if (!trimmedId) { toast.error(t("mcp.error.idRequired"), { duration: 3000 }); return; } if (!isEditing && existingIds.includes(trimmedId)) { setIdError(t("mcp.error.idExists")); return; } let serverSpec: McpServerSpec; if (useToml) { const tomlError = validateTomlConfig(formConfig); setConfigError(tomlError); if (tomlError) { toast.error(t("mcp.error.tomlInvalid"), { duration: 3000 }); return; } if (!formConfig.trim()) { serverSpec = { type: "stdio", command: "", args: [], }; } else { try { serverSpec = tomlToMcpServer(formConfig); } catch (e: any) { const msg = e?.message || String(e); setConfigError(formatTomlError(msg)); toast.error(t("mcp.error.tomlInvalid"), { duration: 4000 }); return; } } } else { if (!formConfig.trim()) { serverSpec = { type: "stdio", command: "", args: [], }; } else { try { const result = parseSmartMcpJson(formConfig); serverSpec = result.config as McpServerSpec; } catch (e: any) { const errorMessage = e?.message || String(e); setConfigError(t("mcp.error.jsonInvalid") + ": " + errorMessage); toast.error(t("mcp.error.jsonInvalid"), { duration: 4000 }); return; } } } if (serverSpec?.type === "stdio" && !serverSpec?.command?.trim()) { toast.error(t("mcp.error.commandRequired"), { duration: 3000 }); return; } if ( (serverSpec?.type === "http" || serverSpec?.type === "sse") && !serverSpec?.url?.trim() ) { toast.error(t("mcp.wizard.urlRequired"), { duration: 3000 }); return; } setSaving(true); try { const nameTrimmed = (formName || trimmedId).trim(); const finalName = nameTrimmed || trimmedId; const entry: McpServer = { ...(initialData ? { ...initialData } : {}), id: trimmedId, name: finalName, server: serverSpec, apps: enabledApps, }; const descriptionTrimmed = formDescription.trim(); if (descriptionTrimmed) { entry.description = descriptionTrimmed; } else { delete entry.description; } const homepageTrimmed = formHomepage.trim(); if (homepageTrimmed) { entry.homepage = homepageTrimmed; } else { delete entry.homepage; } const docsTrimmed = formDocs.trim(); if (docsTrimmed) { entry.docs = docsTrimmed; } else { delete entry.docs; } const parsedTags = formTags .split(",") .map((tag) => tag.trim()) .filter((tag) => tag.length > 0); if (parsedTags.length > 0) { entry.tags = parsedTags; } else { delete entry.tags; } await upsertMutation.mutateAsync(entry); toast.success(t("common.success"), { closeButton: true }); await onSave(); } catch (error: any) { const detail = extractErrorMessage(error); const mapped = translateMcpBackendError(detail, t); const msg = mapped || detail || t("mcp.error.saveFailed"); toast.error(msg, { duration: mapped || detail ? 6000 : 4000 }); } finally { setSaving(false); } }; const getFormTitle = () => { return isEditing ? t("mcp.editServer") : t("mcp.addServer"); }; return ( <> {isEditing ? : } {saving ? t("common.saving") : isEditing ? t("common.save") : t("common.add")} } >
{/* 上半部分:表单字段 */}
{/* 预设选择(仅新增时展示) */} {!isEditing && (
{mcpPresets.map((preset, idx) => { const descriptionKey = `mcp.presets.${preset.id}.description`; return ( ); })}
)} {/* ID (标题) */}
{!isEditing && idError && ( {idError} )}
handleIdChange(e.target.value)} disabled={isEditing} />
{/* Name */}
setFormName(e.target.value)} />
{/* 启用到哪些应用 */}
setEnabledApps({ ...enabledApps, claude: checked }) } />
setEnabledApps({ ...enabledApps, codex: checked }) } />
setEnabledApps({ ...enabledApps, gemini: checked }) } />
setEnabledApps({ ...enabledApps, opencode: checked }) } />
{/* 可折叠的附加信息按钮 */}
{/* 附加信息区域(可折叠) */} {showMetadata && ( <>
setFormDescription(e.target.value)} />
setFormTags(e.target.value)} />
setFormHomepage(e.target.value)} />
setFormDocs(e.target.value)} />
)}
{/* 下半部分:JSON 配置编辑器 - 自适应剩余高度 */}
{(isEditing || selectedPreset === -1) && ( )}
{configError && (
{configError}
)}
{/* Wizard Modal */} setIsWizardOpen(false)} onApply={handleWizardApply} initialTitle={formId} initialServer={wizardInitialSpec} /> ); }; export default McpFormModal; ================================================ FILE: src/components/mcp/McpWizardModal.tsx ================================================ import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { toast } from "sonner"; import { Save } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, } from "@/components/ui/dialog"; import { McpServerSpec } from "@/types"; interface McpWizardModalProps { isOpen: boolean; onClose: () => void; onApply: (title: string, json: string) => void; initialTitle?: string; initialServer?: McpServerSpec; } /** * 解析环境变量文本为对象 */ const parseEnvText = (text: string): Record => { const lines = text .split("\n") .map((l) => l.trim()) .filter((l) => l.length > 0); const env: Record = {}; for (const l of lines) { const idx = l.indexOf("="); if (idx > 0) { const k = l.slice(0, idx).trim(); const v = l.slice(idx + 1).trim(); if (k) env[k] = v; } } return env; }; /** * 解析headers文本为对象(支持 KEY: VALUE 或 KEY=VALUE) */ const parseHeadersText = (text: string): Record => { const lines = text .split("\n") .map((l) => l.trim()) .filter((l) => l.length > 0); const headers: Record = {}; for (const l of lines) { // 支持 KEY: VALUE 或 KEY=VALUE const colonIdx = l.indexOf(":"); const equalIdx = l.indexOf("="); let idx = -1; if (colonIdx > 0 && (equalIdx === -1 || colonIdx < equalIdx)) { idx = colonIdx; } else if (equalIdx > 0) { idx = equalIdx; } if (idx > 0) { const k = l.slice(0, idx).trim(); const v = l.slice(idx + 1).trim(); if (k) headers[k] = v; } } return headers; }; /** * MCP 配置向导模态框 * 帮助用户快速生成 MCP JSON 配置 */ const McpWizardModal: React.FC = ({ isOpen, onClose, onApply, initialTitle, initialServer, }) => { const { t } = useTranslation(); const [wizardType, setWizardType] = useState<"stdio" | "http" | "sse">( "stdio", ); const [wizardTitle, setWizardTitle] = useState(""); // stdio 字段 const [wizardCommand, setWizardCommand] = useState(""); const [wizardArgs, setWizardArgs] = useState(""); const [wizardEnv, setWizardEnv] = useState(""); // http 和 sse 字段 const [wizardUrl, setWizardUrl] = useState(""); const [wizardHeaders, setWizardHeaders] = useState(""); // 生成预览 JSON const generatePreview = (): string => { const config: McpServerSpec = { type: wizardType, }; if (wizardType === "stdio") { // stdio 类型必需字段 config.command = wizardCommand.trim(); // 可选字段 if (wizardArgs.trim()) { config.args = wizardArgs .split("\n") .map((s) => s.trim()) .filter((s) => s.length > 0); } if (wizardEnv.trim()) { const env = parseEnvText(wizardEnv); if (Object.keys(env).length > 0) { config.env = env; } } } else { // http 和 sse 类型必需字段 config.url = wizardUrl.trim(); // 可选字段 if (wizardHeaders.trim()) { const headers = parseHeadersText(wizardHeaders); if (Object.keys(headers).length > 0) { config.headers = headers; } } } return JSON.stringify(config, null, 2); }; const handleApply = () => { if (!wizardTitle.trim()) { toast.error(t("mcp.error.idRequired"), { duration: 3000 }); return; } if (wizardType === "stdio" && !wizardCommand.trim()) { toast.error(t("mcp.error.commandRequired"), { duration: 3000 }); return; } if ((wizardType === "http" || wizardType === "sse") && !wizardUrl.trim()) { toast.error(t("mcp.wizard.urlRequired"), { duration: 3000 }); return; } const json = generatePreview(); onApply(wizardTitle.trim(), json); handleClose(); }; const handleClose = () => { // 重置表单 setWizardType("stdio"); setWizardTitle(""); setWizardCommand(""); setWizardArgs(""); setWizardEnv(""); setWizardUrl(""); setWizardHeaders(""); onClose(); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter" && e.metaKey) { e.preventDefault(); handleApply(); } }; useEffect(() => { if (!isOpen) return; const title = initialTitle ?? ""; setWizardTitle(title); const resolvedType = initialServer?.type ?? (initialServer?.url ? "http" : "stdio"); setWizardType(resolvedType); if (resolvedType === "http" || resolvedType === "sse") { setWizardUrl(initialServer?.url ?? ""); const headersCandidate = initialServer?.headers; const headers = headersCandidate && typeof headersCandidate === "object" ? headersCandidate : undefined; setWizardHeaders( headers ? Object.entries(headers) .map(([k, v]) => `${k}: ${v ?? ""}`) .join("\n") : "", ); setWizardCommand(""); setWizardArgs(""); setWizardEnv(""); return; } setWizardCommand(initialServer?.command ?? ""); const argsValue = initialServer?.args; setWizardArgs(Array.isArray(argsValue) ? argsValue.join("\n") : ""); const envCandidate = initialServer?.env; const env = envCandidate && typeof envCandidate === "object" ? envCandidate : undefined; setWizardEnv( env ? Object.entries(env) .map(([k, v]) => `${k}=${v ?? ""}`) .join("\n") : "", ); setWizardUrl(""); setWizardHeaders(""); }, [isOpen]); const preview = generatePreview(); return ( !open && handleClose()}> {t("mcp.wizard.title")} {/* Content */}
{/* Hint */}

{t("mcp.wizard.hint")}

{/* Form Fields */}
{/* Type */}
{/* Title */}
setWizardTitle(e.target.value)} onKeyDown={handleKeyDown} placeholder={t("mcp.form.titlePlaceholder")} className="font-mono" />
{/* Stdio 类型字段 */} {wizardType === "stdio" && ( <> {/* Command */}
setWizardCommand(e.target.value)} onKeyDown={handleKeyDown} placeholder={t("mcp.wizard.commandPlaceholder")} className="font-mono" />
{/* Args */}