Skip to content

feat: Add Sync Variants feature to copy config between variants #8

@MohMaya

Description

@MohMaya

Summary

Add a "Sync Variants" feature that allows users to copy configuration (skills, MCP servers, permissions, CLAUDE.md) from one source variant to multiple target variants.

Problem

Skills, MCP servers, and CLAUDE.md configured in one variant aren't available in other variants. Users who set up multiple variants need to manually copy configuration between them.

Proposed Solution

Sync Direction

  • One source variant -> multiple target variants (one-to-many)
  • Overwrite target with source (no merge)

What to Sync

  • Skills (entire config/skills/ directory)
  • MCP servers (from .claude.json)
  • Permissions (allow/deny rules from settings.json)
  • CLAUDE.md (if present)

What NOT to Sync

  • Provider-specific settings (API keys, base URLs, model overrides)
  • Theme preferences
  • Team mode configuration
  • Provider env vars (CC_MIRROR_, ANTHROPIC_, etc.)

Backup Strategy

  • Create single backup at ~/.cc-mirror/<variant>/config.backup/ before sync
  • Overwrite previous backup on new sync (only keep one version)

Implementation Plan

Core Module (src/core/sync.ts)

export type SyncItem = 'skills' | 'mcp-servers' | 'permissions' | 'claude-md';

export interface SyncOptions {
  items: SyncItem[];
  createBackup: boolean;
}

export interface SyncResult {
  target: string;
  success: boolean;
  backupPath?: string;
  itemResults: Record<SyncItem, { copied: number; skipped: number; errors: string[] }>;
}

export function syncVariants(sourceDir: string, targetDirs: string[], options: SyncOptions): SyncResult[];
export function createConfigBackup(variantDir: string): string;
export function restoreConfigBackup(variantDir: string): boolean;

TUI Flow

Home -> "Sync Variants" -> sync-source (pick one) -> sync-targets (pick many) -> sync-running -> sync-done

Files to Create/Modify

  • NEW: src/core/sync.ts (~200 lines)
  • NEW: src/tui/hooks/useSync.ts (~100 lines)
  • NEW: src/tui/screens/SyncSourceScreen.tsx
  • NEW: src/tui/screens/SyncTargetsScreen.tsx (multi-select)
  • NEW: src/tui/screens/SyncRunningScreen.tsx
  • NEW: src/tui/screens/SyncDoneScreen.tsx
  • MODIFY: src/tui/screens/HomeScreen.tsx (add menu item)
  • MODIFY: src/tui/app.tsx (add screen handlers)
  • MODIFY: src/core/index.ts (export sync functions)
  • MODIFY: src/tui/hooks/index.ts (export useSync)

Acceptance Criteria

  • User can select one source variant from TUI
  • User can select multiple target variants (excluding source)
  • Backup created before sync (single backup, overwrites previous)
  • Skills directory copied recursively
  • MCP servers merged into target .claude.json
  • Permissions merged into target settings.json
  • CLAUDE.md copied if exists
  • Provider-specific settings NOT overwritten
  • Progress shown during sync
  • Results summary shown after sync

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions