dsh-ccswitch-sync: Mirror CC Switch's DSH Configuration into dsh-TUI

Introduction

When managing DSH’s LLM Provider and MCP services with CC Switch, configurations are written into profiles like web or desktop. The dsh-TUI runs on an independent dsh-tui profile, and the two profiles do not overlap; the providers and MCPs synced from CC Switch are not visible inside TUI. Manually copying and patching is prone to missing fields, losing comments, and is difficult to judge whether the mirror is up-to-date. The dsh-ccswitch-sync introduced below (maintainer msyzzm) is a client plugin attached to dsh-TUI: it executes the same text concatenation logic as CC Switch inside TUI, writes the mirror into dsh-tui’s patch, and displays freshness in the footer.

What is it

dsh-ccswitch-sync belongs to the DSH community plugin ecosystem (Category: Client). On the premise that CC Switch has written to ~/.dsh/profiles/web/cordis.patch.yml (or falls back to desktop if it doesn’t exist), it mirrors the llm-pi-ai.providers and cc-switch-mcp-* related blocks to ~/.dsh/profiles/dsh-tui/cordis.patch.yml, and displays the number of providers, number of MCPs, and the time elapsed since the patch was written in the footer. The plugin does not replace CC Switch; it only reads the source profile and does not modify credentials or the CC Switch files themselves.

In terms of the ecosystem, DSH advocates “everything is a plugin”; the SkillHub directory page and GitHub repository are community-maintained entry points, with no official affiliation with DeepSeek or Huansuan.

Core Features

Mirror and Display

  • /ccswitch: Outputs the number of providers, number of MCPs, and source patch age.
  • /ccswitch sync: Immediately executes a mirror (this will rewrite the target patch, see the mechanism below).
  • Footer field ccswitch: Consistent with the counts above, refreshes approximately every 60 seconds; can be used with slot options and left-tail / right-head / right-tail layouts.

Example footer semantics (from project documentation):

ccs 3p 4mcp 1m        ← 3 providers, 4 MCPs, patch written 1 minute ago

Sync Trigger Strategy

The plugin does not perform background sync on its own. Installing, activating, reloading, or switching sessions will not move the profile:

  1. Manual: /ccswitch sync.
  2. Optional: DSH_CCSWITCH_SYNC_ON_START=1 mirrors once upon activation.
  3. No file watching, no scheduled disk writes; the only timer refreshes footer text.

The default behavior is because the dsh-TUI profile uses patchReload: live, and rewriting cordis.patch.yml triggers a full composite reload. Since the rows running this plugin are also in the same file, mirroring upon activation easily causes chain reloads. On-demand sync turns the reload into a deliberate operation.

Implementation Details

Management blocks are written at the end of the target patch, wrapped by markers:

# >>> cc-switch sync (managed) >>>
- id: llm-pi-ai
  config:
    providers: { ... }
- insert:
    - id: cc-switch-mcp-context7
      ...
# <<< cc-switch sync (managed) <<<
  • Pure text concatenation, no YAML round-trip, comments and quotes are preserved.
  • Idempotent: if the concatenation result matches the current file bytes, it does not write to disk, avoiding a live reload loop.
  • Atomic write: write to <patch>.candidate.yml then rename.
  • Backup: copy to ~/.dsh-tui/ccswitch-sync/backups/ before rewriting, keeping the latest 20 copies.
  • Source selection: use web if it exists, otherwise use desktop.
  • Duplicate llm-pi-ai lines outside the marker block are cleaned up to avoid duplication after combination; other content outside the marker block is not modified.

Scope Clearly Not Touched

  • ~/.dsh/.credentials.yaml and all credentials; providers only reference CC_SWITCH_DSH_* environment variable names.
  • ~/.dsh/skills (read by profiles via dsh-base’s skill-filesystem, no need to mirror).
  • Other profiles and CC Switch’s own files (read-only source patch).

Declared Permissions

dsh-plugin.json declares three items (can be viewed via /plugin):

Permission Scope
dsh-ccswitch-sync.profile.read ~/.dsh/profiles/{web,desktop}/cordis.patch.yml
dsh-ccswitch-sync.profile.write ~/.dsh/profiles/dsh-tui/cordis.patch.yml
dsh-ccswitch-sync.state.write ~/.dsh-tui/ccswitch-sync/

Permissions are behavioral declarations, not OS sandbox; like other dsh-TUI plugins, the code runs within the terminal process via trusted-in-process. Please read the source code and MIT License before installing.

Installation and Activation

Requires dsh-TUI ≥ 0.20.0 (footer tuiStatus.setField and commands service); if missing, the plugin degrades to a no-op. Current npm package version is 0.1.2, runtime Node ^22.19 || >=24, ESM, zero runtime dependencies.

Execute in terminal (excerpted from official README):

# from npm
dsh plugin --profile dsh-tui add dsh-ccswitch-sync

# or from a local checkout
dsh plugin --profile dsh-tui add link:/path/to/dsh-ccswitch-sync

/plugin install <spec> is also available inside TUI. You need to restart dsh-TUI after installation, as the bundle is only assembled at process startup.

Uninstall:

dsh plugin --profile dsh-tui remove dsh-ccswitch-sync

disable / remove does not delete user data: backups and logs remain in ~/.dsh-tui/ccswitch-sync/, and the management block might still stay in cordis.patch.yml; delete the directory if needed, or remove the content between # >>> / # <<< (the next /ccswitch sync will rebuild the block).

Typical Usage

  1. Configure providers and MCPs in CC Switch as usual, and confirm they are written to the web or desktop patch.
  2. Restart dsh-TUI to ensure the plugin is loaded.
  3. Execute /ccswitch to view the current counts and patch age.
  4. Execute /ccswitch sync when you need to pull the configuration into TUI.
  5. If you want to mirror automatically every activation, set DSH_CCSWITCH_SYNC_ON_START=1 in the environment (be aware that this triggers a profile reload).

Hide or sort footer: adjust statusBar.pluginFields and statusBar.pluginFieldsOrder in /settings; commands remain usable after disabling a field.

Suitable Scenarios and Notes

Suitable: Daily use of CC Switch to manage DSH, while needing the same set of providers and MCPs in dsh-TUI, and wanting visible “mirror expired” hints.

Notes:

  • The mirror will not automatically follow every change in CC Switch; get used to manually running /ccswitch sync after changing CC Switch, or use DSH_CCSWITCH_SYNC_ON_START=1 cautiously.
  • The plugin reads/writes DSH paths under the home directory with the current shell user’s permissions; please review the repository code before installing on enterprise or shared machines.
  • Manifest is Community v0.15, facet v1alpha1; it may silently fail if the version does not match dsh-TUI.

Conclusion

dsh-ccswitch-sync fills the gap between CC Switch and dsh-TUI profiles with repeatable text mirroring, marks freshness in the footer, and leaves the sync timing to user control to avoid accidental live reload triggers. For more information, visit the SkillHub plugin page and GitHub: msyzzm/dsh-ccswitch-sync.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye