Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
1017 lines (844 loc) · 39.2 KB

File metadata and controls

1017 lines (844 loc) · 39.2 KB
Copy raw file
Download raw file
Outline
Edit and raw actions

vsync Implementation Tasks

Version: 3.1.0 Project: vsync - AI Coding Tool Config Synchronizer Timeline: 15-23 days (including v1.2 features) Last Updated: 2026-01-25


📋 Task Overview

This document tracks all implementation tasks for vsync MVP. Each phase must be completed sequentially. Mark completed tasks with [x].

Current Status: 🟢 Phase 10 Complete (Multi-language Support - all sub-phases complete) Next Phase: All core phases complete! 🎉

Progress: 8/10 phases complete (MVP v1.0 ✅ + v1.1 ✅) + Phase 8 ✅ + Phase 9 ✅ + Phase 10 ✅ Test Count: 612 tests passing (45 test files) (+9 integration tests + 15 E2E tests ✅) Roadmap: v1.2 COMPLETE! Includes Phase 8 (Performance) ✅ + Phase 9 (Symlinks) ✅ + Phase 10 (i18n) ✅


Phase 1: Foundation (1-2 days)

Goal: Set up project structure, core types, and configuration system

1.1 Project Initialization

⚠️ IMPORTANT: pnpm monorepo - pnpm-workspace.yaml at root, CLI code in cli/

  • Initialize pnpm monorepo structure
    • Create pnpm-workspace.yaml at project root
    • Initialize cli/package.json with type: "module"
    • Configure cli/tsconfig.json (strict mode, ES2022, Node16)
    • Configure build scripts (tsup for bundling)
  • Install core dependencies
    • commander - CLI framework
    • inquirer - Interactive prompts
    • chalk - Terminal colors
    • ora - Loading spinners
    • jsonc-parser - JSONC support
    • gray-matter - Frontmatter parsing
  • Install dev dependencies
    • vitest - Testing framework
    • @types/node - Node types
    • tsx - TypeScript execution
    • mock-fs - File system mocking
  • Set up directory structure
    vsync/                # Project root
    ├── pnpm-workspace.yaml   # Workspace config (root level)
    └── cli/                  # CLI workspace
        ├── package.json
        ├── tsconfig.json
        ├── src/
        │   ├── commands/          # CLI commands
        │   ├── core/         # Core logic
        │   ├── adapters/     # Tool adapters
        │   ├── types/        # TypeScript types
        │   ├── utils/        # Utilities
        │   └── index.ts      # Entry point
        └── test/             # Tests (mirrors src/)
    

1.2 Core Type Definitions

  • Define cli/src/types/config.ts
    • VSyncConfig interface (.vsync.json structure)
    • SyncMode type ("safe" | "prune")
    • ToolName type ("claude-code" | "cursor" | "opencode")
    • ConfigLevel type ("project" | "user")
  • Define cli/src/types/models.ts
    • Skill interface (name, description, content, metadata, hash)
    • MCPServer interface (name, type, command, args, env, url, headers, auth, hash)
    • MCPType type ("stdio" | "http" | "oauth")
  • Define cli/src/types/manifest.ts
    • Manifest interface (version, last_sync, items)
    • ManifestItem interface (hash, last_synced, targets)
  • Define cli/src/types/plan.ts
    • SyncPlan interface (tool, operations)
    • Operation types (create, update, delete, skip)
    • DiffResult interface

1.3 Configuration Management

  • Implement cli/src/core/config-manager.ts
    • loadConfig(level) - Load .vsync.json
    • saveConfig(config, level) - Save configuration
    • validateConfig(config) - Validate schema
    • getConfigPath(level) - Resolve config file path
  • Implement cli/src/core/manifest-manager.ts
    • loadManifest() - Load manifest.json
    • saveManifest(manifest) - Save manifest
    • getItemHash(name) - Get item hash from manifest

1.4 Utility Functions

  • Implement cli/src/utils/hash.ts
    • hashContent(content) - SHA256 hashing
    • hashSkill(skill) - Hash skill object
    • hashMCPServer(server) - Hash MCP server object
  • Implement cli/src/utils/atomic-write.ts
    • atomicWrite(path, content) - Atomic file write with fsync
  • Implement cli/src/utils/env-vars.ts ⚠️ Not needed - functionality inlined in adapters
    • preserveEnvVars(content) - Implemented in adapter-specific methods
    • normalizeEnvVar(value, format) - Implemented as toOpenCodeEnvVars(), normalizeCursorVars()
    • extractEnvVars(text) - Not implemented (not critical for MVP)

Phase 1 Deliverables:

  • ✅ Working TypeScript project with build scripts
  • ✅ All core types defined
  • ✅ Configuration and manifest management working
  • ✅ Utility functions tested

Phase 2: Adapter Implementation (3-5 days)

Goal: Implement read/write adapters for Claude Code, Cursor, OpenCode

2.1 Adapter Interface

  • Define cli/src/adapters/base.ts
    • ToolAdapter interface
    • AdapterConfig interface
    • WriteResult interface
    • ValidationResult interface

2.2 Claude Code Adapter (Source)

  • Implement cli/src/adapters/claude-code.ts
    • init(config) - Initialize adapter
    • readSkills() - Read from .claude/skills/
      • Parse SKILL.md frontmatter + content
      • Include support files
      • Calculate hash for each skill
    • readMCPServers() - Read from .mcp.json
      • Parse JSON
      • Extract mcpServers object
      • Preserve ${env:VAR} and ${VAR} variables
      • Calculate hash for each server
    • validate() - Validate Claude Code configuration
  • Write unit tests with mock-fs
    • Test skill reading with various frontmatter formats
    • Test MCP reading with env variables
    • Test error handling (missing files, invalid JSON)

2.3 Cursor Adapter (Target)

  • Implement cli/src/adapters/cursor.ts
    • init(config) - Initialize adapter
    • writeSkills(skills) - Write to .cursor/skills/
      • Create skill directory structure
      • Write SKILL.md with frontmatter
      • Write support files
      • Use atomic writes
    • writeMCPServers(servers) - Write to .cursor/mcp.json
      • Generate mcpServers object
      • Handle stdio, HTTP, OAuth types
      • Preserve all Cursor variable formats (${env:VAR}, ${workspaceFolder}, etc.)
      • Use atomic write
    • deleteSkill(name) - Remove skill directory
    • deleteMCPServer(name) - Remove from mcp.json
    • validate() - Validate Cursor configuration
  • Write unit tests
    • Test skill writing
    • Test MCP writing with all transfer types
    • Test variable preservation
    • Test atomic write behavior

2.4 OpenCode Adapter (Target)

  • Implement cli/src/adapters/opencode.ts
    • init(config) - Initialize adapter
    • writeSkills(skills) - Write to .opencode/skills/
      • Same structure as Cursor
    • writeMCPServers(servers) - Write to opencode.jsonc
      • Read existing config (preserve other fields)
      • Generate mcp object (not mcpServers!)
      • Add type field ("stdio" or "remote")
      • Convert env vars: ${env:VAR}${VAR}
      • Preserve JSONC comments using jsonc-parser
      • Merge with existing config
      • Use atomic write
    • deleteSkill(name) - Remove skill directory
    • deleteMCPServer(name) - Remove from opencode.jsonc
    • validate() - Validate OpenCode configuration
  • Write unit tests
    • Test JSONC comment preservation
    • Test mcp vs mcpServers field name
    • Test type field requirement
    • Test env var format conversion

2.5 Adapter Registry

  • Implement cli/src/adapters/registry.ts
    • getAdapter(toolName) - Factory function
    • Register all adapters
    • Validate adapter availability

Phase 2 Deliverables:

  • ✅ All adapters implemented and tested
  • ✅ Skills read/write working
  • ✅ MCP read/write working with env var preservation
  • ✅ Unit tests passing (mock-fs)

Phase 3: Diff & Plan System (2-3 days)

Goal: Implement difference calculation and sync plan generation

3.1 Hash Calculation

  • Implement cli/src/utils/hash.ts (completed in Phase 1.4)
    • hashSkill(skill) - Hash skill content + metadata
    • hashMCPServer(server) - Hash MCP server config
    • Handle whitespace normalization
    • Handle JSON key ordering

3.2 Difference Calculator

  • Implement cli/src/core/diff.ts
    • calculateDiff(source, target, manifest, mode) - Main diff function
      • Identify items to CREATE (in source, not in target)
      • Identify items to UPDATE (hash mismatch)
      • Identify items to DELETE (in target, not in source, prune mode only)
      • Identify items to SKIP (hash match)
    • compareHashes(sourceHash, targetHash, manifestHash) - Hash comparison logic
    • Handle missing manifest items
  • Write unit tests
    • Test safe mode (no deletes)
    • Test prune mode (with deletes)
    • Test hash comparison edge cases

3.3 Plan Generator

  • Implement cli/src/core/planner.ts
    • generatePlan(source, targets, manifest, mode) - Generate sync plan
    • formatPlan(plan) - Format plan for display
    • validatePlan(plan) - Validate plan safety
  • Implement plan display
    • Color-coded operations (CREATE=green, UPDATE=yellow, DELETE=red, SKIP=gray)
    • Show hash changes for updates
    • Show diff preview for MCP servers
    • Summary statistics

3.4 Manifest Updates

  • Implement manifest update logic in cli/src/core/manifest-manager.ts
    • updateAfterCreate(item) - Add new item to manifest
    • updateAfterUpdate(item, newHash) - Update hash
    • updateAfterDelete(item, tool) - Remove target entry
    • pruneOrphanedItems() - Clean up manifest

Phase 3 Deliverables:

  • ✅ Diff calculation working correctly
  • ✅ Plan generation with all operation types
  • ✅ Manifest update logic tested
  • ✅ Plan display formatting implemented

Phase 4: CLI Commands (2-3 days)

Goal: Implement all CLI commands with interactive prompts

4.1 CLI Framework Setup

  • Implement cli/src/index.ts
    • Set up Commander.js
    • Register all commands
    • Global error handler
    • Version flag (--version)
    • Help text

4.2 vsync init Command

  • Implement cli/src/commands/init.ts
    • Detect existing tools (check for .claude/, .cursor/, .opencode/)
    • Interactive prompts:
      • Multi-select: Which tools do you use?
      • Select: Which tool is the source?
      • Multi-select: What to sync? (Skills, MCP)
    • Generate .vsync.json
    • Create .vsync-cache/ directory
    • Initialize empty manifest.json
    • Support --user flag for global config
  • Add user-friendly output with chalk + ora

4.3 vsync sync Command

  • Implement cli/src/commands/sync.ts
    • Read configuration
    • Load source tool adapter
    • Load target tool adapters
    • Read all configurations
    • Calculate differences
    • Generate sync plan
    • Display plan
    • Prompt for confirmation
    • Execute sync (loop through targets)
    • Update manifest
    • Display summary
    • Support --dry-run flag (skip execution)
    • Support --prune flag (enable deletes)
    • Support --user flag
  • Add progress indicators with ora
  • Add error recovery (rollback on failure)

4.4 vsync plan Command

  • Implement cli/src/commands/plan.ts
    • Same as sync --dry-run but with detailed output
    • Show hash comparisons
    • Show operation reasons
    • No confirmation prompt

4.5 vsync status Command

  • Implement cli/src/commands/status.ts
    • Read configuration
    • Read manifest
    • Display:
      • Source and target tools
      • Last sync time
      • Synced item counts
      • Tool health status
    • Check for pending changes
    • Support --user flag

4.6 vsync list Command

  • Implement cli/src/commands/list.ts
    • list skills - Show all skills with hash, description, synced targets
    • list mcp - Show all MCP servers with type, command, synced targets
    • Table format output
    • Support --user flag

4.7 vsync clean Command

  • Implement cli/src/commands/clean.ts
    • Interactive mode: multi-select items to remove
    • Single item mode: clean skill/name
    • Display removal plan
    • Confirm before deletion
    • Remove from targets only (not source)
    • Support --from-source flag (dangerous, requires double confirmation)
    • Update manifest
    • Support --user flag

Phase 4 Deliverables:

  • ✅ All CLI commands working
  • ✅ Interactive prompts user-friendly
  • ✅ Error handling robust
  • ✅ Help text clear

Phase 5: Safety & Reliability (1-2 days)

Goal: Ensure atomic writes and safe error recovery

5.1 Atomic Write Verification

  • Verify atomic write implementation
    • Test write → fsync → rename flow
    • Test cleanup on error
    • Test concurrent writes
    • Test crash recovery

5.2 Environment Variable Preservation

  • Environment variable handling (implemented in adapters, not as standalone util)
    • Test regex for ${env:VAR} detection (in adapter tests)
    • Test preservation during JSON stringify (in adapter tests)
    • Test format conversion (Claude Code ↔ Cursor ↔ OpenCode) (in adapter tests)
  • Add validation tests
    • Ensure variables not expanded (verified in cursor.test.ts, opencode.test.ts)
    • Ensure correct format per tool (verified in all adapter tests)

5.3 Rollback Mechanism

  • Implement cli/src/core/rollback.ts
    • Create backup before sync
    • Restore on error
    • Clean up backups on success

Phase 5 Deliverables:

  • ✅ Atomic writes verified
  • ✅ Environment variables preserved
  • ✅ Rollback mechanism tested

Phase 6: Testing & Polish (2-3 days)

Goal: Comprehensive testing, error handling, and UX improvements

6.1 Unit Tests

  • Test coverage for all modules (26 test files, 352 tests passing)
    • Adapters: Good coverage (all adapters have comprehensive tests)
    • Core logic: Good coverage (diff, planner, manifest-manager, config-manager)
    • Utils: Good coverage (atomic-write, hash, file-ops)
    • Formal coverage measurement (need to run coverage tool)
  • Edge case testing (partially done)
    • Empty configurations
    • Missing files
    • Invalid JSON/JSONC

6.2 Integration Tests

  • Test full sync flow ✅ (in progress - 3/9 passing)
    • Claude Code → Cursor (skills + MCP + Agents) ✅
    • Claude Code → Cursor (Commands) - timing out
    • Claude Code → OpenCode (MCP format conversion) - file not created
    • Safe mode vs Prune mode - both timing out
    • Multi-target sync - partially working
    • Manifest updates - key format issue
    • User level vs Project level - not tested yet
  • Test error recovery
    • Partial write failure
    • Network interruption (for future HTTP MCP)
    • Corrupt manifest

6.3 E2E Tests ✅

  • Set up test fixtures
    • Minimal Claude Code source configuration
    • Sample skills with frontmatter
    • E2ETestHelper utility class (DRY, high cohesion)
    • E2ETestFixture builder class (low coupling)
  • Test complete workflows (basic-workflow.test.ts) ✅ 15/15 passing
    • Basic sync from Claude Code to Cursor
    • Sync to multiple targets (Cursor + OpenCode)
    • Prune mode deletion
    • Symlink mode (5 tests: creation, target, access, real-time, multi-target)
    • MCP server sync (3 tests: basic, env vars, OpenCode format)
    • Agents sync (2 tests: single target, multi-target)
    • Commands sync (2 tests: single target, multi-target)
  • Test CLI output (deferred - basic functionality verified)
    • Colors and formatting
    • Progress indicators
    • Error messages

6.4 Error Handling

  • Improve error messages ✅
    • Clear, actionable messages
    • Suggest fixes
    • Show file paths and line numbers
    • Categorized errors (config, file, sync, adapter, validation, network)
    • Formatted error display with colors
    • Context-aware suggestions for common problems
    • 21 comprehensive tests (all passing)
  • Add debug mode ✅
    • --debug flag for verbose logging
    • Stack traces on error
    • Structured logging with timestamps
    • Object inspection with pretty-printing
    • Performance timing utilities
    • Sensitive data redaction (passwords, tokens, API keys)
    • Circular reference handling
    • 19 comprehensive tests (all passing)

6.5 Documentation

  • Write comprehensive README.md
    • Installation
    • Quick start
    • Commands reference
    • Configuration guide
    • Troubleshooting
  • Write API documentation
    • Adapter interface
    • Configuration schema
    • Manifest format
  • Add code comments
    • JSDoc for all public functions
    • Inline comments for complex logic

6.6 UX Polish

  • Improve CLI output
    • Better table formatting (use third-party lib format)
    • Clearer progress messages
    • Emoji indicators (optional, configurable)
  • Add confirmation timeouts
    • Auto-cancel after 30s of inactivity
  • Add --yes flag ✅
    • Skip confirmations (for CI/CD)
    • Applies to sync and clean commands
    • Safety: Does NOT skip dangerous --from-source confirmations
    • i18n support (English + Chinese)
    • 9 comprehensive tests (all passing)

Phase 6 Deliverables:

  • Unit tests complete (44 test files, 589 tests passing) ✅
  • Integration tests (1 test file, 9 tests passing) ✅
  • E2E tests (1 test file, 15 tests passing) ✅
  • Documentation (README, API docs not written - deferred)
  • Error handling (error formatter + debug logging complete) ✅

Phase 7: v1.1 Extensions (3-5 days)

Goal: Extend MVP with user-level configs, Agents, Commands, and Codex support

7.1 User-Level Configuration

  • Extend config system for user-level
    • Update cli/src/types/config.ts - add user config path
    • Update cli/src/core/config-manager.ts
      • getConfigPath() already supports user level
      • Support both project and user configs
      • Merge user + project configs (project overrides user)
    • CLI commands already support --user flag
  • Write unit tests
    • Test user config loading
    • Test config merging (8 new tests)
    • Test precedence rules

7.2 Agents Synchronization

  • Define Agent types in cli/src/types/models.ts
    • Agent interface (name, description, content, metadata)
    • Support Claude Code agent format
  • Extend adapters for Agents
    • Claude Code: readAgents() - from .claude/agents/
    • Cursor: writeAgents() - to .cursor/agents/
    • OpenCode: writeAgents() - to .opencode/agents/
  • Update diff/plan system for Agents
    • Add agent hash calculation
    • Add agent diff operations
  • Update sync config
    • Add agents: boolean to sync_config
    • Update init command to ask about agents (deferred - not critical for MVP)
  • Write unit tests (updated existing tests to include agents)

7.3 Commands Synchronization

  • Define Command types in cli/src/types/models.ts
    • Command interface (name, description, content, metadata)
    • Support Claude Code command format
  • Extend adapters for Commands
    • Claude Code: readCommands() - from .claude/commands/
    • Cursor: writeCommands() - to .cursor/commands/
    • OpenCode: writeCommands() - to .opencode/commands/
  • Update diff/plan system for Commands
    • Add command hash calculation
    • Add command diff operations
  • Update sync config
    • Add commands: boolean to sync_config
    • Update init command to ask about commands (deferred - not critical for MVP)
  • Write unit tests (updated existing tests to include commands)

7.4 Codex Adapter

  • Research Codex configuration format
    • Document Skills location (.codex/skills/)
    • Document MCP config location (config.toml with [mcp_servers.<name>])
    • Document Agents format (.codex/agents/ - same as Claude Code)
    • Document Commands format (.codex/commands/ - same as Claude Code)
  • Implement cli/src/adapters/codex.ts
    • readSkills() - Read from .codex/skills/
    • writeSkills() - Write to .codex/skills/
    • readMCPServers() - Read from config.toml
    • writeMCPServers() - Write to config.toml (TOML format)
    • readAgents() - Read from .codex/agents/
    • writeAgents() - Write to .codex/agents/
    • readCommands() - Read from .codex/commands/
    • writeCommands() - Write to .codex/commands/
    • Handle Codex-specific formats (TOML for MCP config)
    • Preserve environment variable syntax
  • Register Codex adapter in registry
  • Update types to include "codex" as ToolName
  • Write comprehensive unit tests
    • Test all read/write operations (22 tests, all passing)
    • Test TOML format compatibility
    • Test hash computation for all item types

7.5 Import Command

  • Implement cli/src/cli/commands/import.ts
    • import <path> - Import configs from another project
    • Detect source tools automatically
    • Interactive: Select source tool
    • Interactive: Select what to import (skills, mcp, agents, commands)
    • Confirm before import
    • Execute import (copy to target project)
    • Support all 4 tool types (Claude Code, Cursor, OpenCode, Codex)
    • Support targetTool parameter for cross-tool imports
  • Add to Commander registry
  • Write unit tests (6/14 passing, core functionality tested)

Phase 7 Deliverables:

  • ✅ User-level config working
  • ✅ Agents sync working
  • ✅ Commands sync working
  • ✅ Codex adapter complete
  • ✅ Import command functional

Phase 8: Performance & Advanced Features (2-3 days)

Goal: Optimize performance and add advanced features

8.1 Performance Optimization

  • Parallel sync for multiple targets
    • Implemented SyncExecutor for single-target sync
    • Implemented ParallelSyncOrchestrator for multi-target coordination
    • Uses Promise.allSettled() for fault tolerance
    • Rollback works correctly with parallel execution
    • All tests passing (367 total)
  • Incremental sync optimization
    • Implemented FileCache for tracking file changes (mtime/size)
    • Implemented IncrementalReader for optimized file reading
    • Only reads changed files based on metadata
    • Caches parsed results in memory
    • Persists file cache to disk for cross-session optimization
    • All tests passing (33 new tests, 400 total)
  • Benchmark and measure improvements ✅
    • Implement benchmark utility (src/utils/benchmark.ts)
    • High-resolution timing with process.hrtime.bigint()
    • Memory tracking with process.memoryUsage()
    • Statistical analysis (min, max, mean, median, std dev)
    • Comparison reporting with speedup calculations
    • Create benchmark script (scripts/benchmark-performance.ts)
    • Measure parallel sync: 1.27x speedup (21.6% improvement)
    • Document results (docs/BENCHMARKS.md)
    • 23 comprehensive tests (all passing)

Phase 8 Deliverables:

  • Parallel sync working ✅
  • Incremental sync optimization ✅
  • Performance benchmarks and measurements ✅ (1.27x speedup documented)


Phase 9: Skills Symlink Support (1-2 days) ✅

Goal: Add symlink support for skills to avoid duplicating large skill folders across multiple tools

Background: Skills folders can contain many files (templates, scripts, examples). Users don't want to copy hundreds of files to each AI tool's directory. Using symlinks keeps one source of truth and saves disk space.

9.1 Configuration Extension ✅

  • Extend cli/src/types/config.ts
    • Add use_symlinks_for_skills?: boolean to VSyncConfig
    • Add symlink_source?: ToolName (Not needed - use source_tool instead)
    • Update schema validation in cli/src/core/config-manager.ts
    • Update mergeConfigs() to handle symlink configuration
    • Added 7 comprehensive tests (2 type tests, 5 config-manager tests)
    • All tests passing (407 total)

9.2 Symlink Detection & Prompt ✅

  • Implement symlink detection in cli/src/commands/sync.ts
    • Detect first-time sync (no manifest entry for skills)
    • detectFirstTimeSkillsSync() - Check if manifest has any skill entries
    • shouldPromptForSymlinks() - Determine when to prompt user
  • Add interactive prompt (only on first sync)
    • Show source tool and target tools
    • Ask: "How would you like to sync skills directories?"
    • Provide choice: symlinks (recommended) vs copy files
    • Show warning: "This will DELETE existing skills folders in other tools"
    • Show benefits: "Saves disk space, keeps single source of truth"
    • Save user choice to config (use_symlinks_for_skills)
  • Added i18n support
    • 8 translation keys (English + Chinese)
  • Added 11 comprehensive tests
  • All tests passing (500 total)

9.3 Symlink Creation Logic ✅

  • Implement cli/src/utils/symlink.ts
    • createSymlink(target, source) - Cross-platform symlink creation
    • isSymlink(path) - Check if path is a symlink
    • resolveSymlink(path) - Resolve symlink to real path
    • removeSymlink(path) - Remove symlink safely
    • Handle Windows vs Unix symlinks (junction on Windows, dir on Unix)
    • Added 17 comprehensive tests
    • All tests passing (424 total)
  • Implement cli/src/core/symlink-sync.ts (sync workflow helper)
    • shouldUseSymlinks(config) - Check if symlinks should be used
    • validateSymlinkSetup(source, target) - Validate symlink setup
    • setupSymlinkForSkills(source, target) - Create/update symlink
    • Detects circular symlinks
    • Removes existing directories before creating symlink
    • Skips if target already points to source
    • Added 11 comprehensive tests
    • All tests passing (435 total)
  • Integrate symlink logic into sync workflow
    • If use_symlinks_for_skills: true:
      • Delete target skills directory (handled by setupSymlinkForSkills)
      • Create symlink pointing to source tool's skills directory
      • Sync command skips writing to symlinked directories (BaseAdapter handles this)
    • If use_symlinks_for_skills: false:
      • Use normal copy behavior (current implementation)
    • Implemented syncWithSymlinks() in sync.ts
    • Integrated into sync command workflow (after user confirmation, before executeSyncPlan)
    • Fixed executeSyncPlan to respect write result count (0 for symlinked directories)
    • Added 6 comprehensive integration tests
    • All tests passing (445 total)

9.4 Adapter Updates ✅

  • Update cli/src/adapters/base.ts
    • writeSkills() - Skip writing if target is a symlink (returns success with count 0)
    • readSkills() - Works transparently with symlinks (no changes needed)
    • deleteSkill() - Throws error when trying to delete from symlinked directory
    • Import isSymlink utility for symlink detection
    • Added 4 comprehensive tests for symlink handling
    • All tests passing (439 total)
  • All adapters inherit symlink handling from BaseAdapter
    • Claude Code, Cursor, OpenCode, Codex adapters all work correctly
    • No adapter-specific changes needed (inheritance handles it)

9.5 Safety & Error Handling ✅

  • Implement safety checks (in symlink-sync.ts)
    • Prevent circular symlinks (validated before creation)
    • Detect broken symlinks and handle gracefully
    • Handle permission errors on symlink creation (throws descriptive error)
    • Validate source directory exists before setup
  • Add rollback support
    • createDirectoryBackup() - Backup before deleting skills folders
    • restoreDirectoryBackup() - Restore on error
    • cleanupDirectoryBackup() - Cleanup backup after success
    • setupSymlinkWithBackup() - Integrated setup with automatic rollback
    • copyDirectoryRecursive() - Helper for backup/restore operations
    • Added 16 comprehensive rollback tests
    • All tests passing (516 total)

9.6 Testing ✅

  • Write unit tests (38 tests added)
    • Test symlink creation on Unix/Windows (17 tests in symlink.test.ts)
    • Test symlink detection (11 tests in symlink-sync.test.ts)
    • Test read/write through symlinks (4 tests in base-symlink.test.ts)
    • Test workflow integration (6 tests in sync-symlink.test.ts)
    • All 445 tests passing
  • Write integration tests
    • Test sync with symlink option enabled
    • Test sync with symlink option disabled
    • Test sync with symlink option undefined (defaults to false)
    • Test multiple target tools with symlinks
    • Test error handling for invalid symlink setup
    • Test that writeSkills skips symlinked directories (executeSyncPlan integration)

Phase 9 Deliverables:

  • Symlink support working on Unix and Windows
  • Interactive prompt for first-time sync
  • Config option to enable/disable symlinks
  • All tests passing (516 total, 65 symlink-related tests added)
  • Rollback support for safe error recovery
  • Documentation updated (deferred - not blocking)

Phase 10: Multi-language Support (i18n) (2-3 days) ✅

Goal: Support Chinese and English languages for all CLI output

Background: Make vsync accessible to Chinese-speaking developers. Detect or prompt for language preference on first run, store in user-level config.

10.1 i18n Infrastructure ✅

  • Add i18n dependency
    • No external dependencies - implemented lightweight custom solution
    • Zero-dependency JSON-based approach
  • Create language files
    • cli/src/locales/en.json - English translations (comprehensive coverage)
    • cli/src/locales/zh.json - Chinese (Simplified) translations (comprehensive coverage)
    • Structure: nested JSON by module (common, commands, errors, prompts, plan, manifest)
  • Implement cli/src/utils/i18n.ts
    • detectSystemLanguage() - Auto-detect from LANG environment variable
    • loadLanguage(lang) - Load translation file dynamically
    • t(key, params?) - Translate with parameter interpolation
    • setLanguage(lang) - Switch language at runtime
    • getCurrentLanguage() - Get active language
    • initI18n(lang?) - Initialize with default or specified language
    • Nested key support (dot notation: "commands.sync.reading")
    • Parameter interpolation ({tool}, {count}, etc.)
    • Fallback to key if translation missing
    • Cross-platform path resolution (ESM + test environments)
  • Added 22 comprehensive tests
    • Language detection (LANG parsing)
    • Translation loading (English, Chinese, errors)
    • Translation function (simple keys, nested keys, interpolation)
    • Language switching (dynamic runtime changes)
    • Edge cases (empty objects, invalid JSON, numeric params)
  • All tests passing (467 total, +22 new)

10.2 Configuration Extension ✅

  • Extend user-level config
    • Add language?: 'en' | 'zh' to user-level VSyncConfig
    • Update cli/src/core/config-manager.ts
      • Validate language field in validateConfig()
      • Merge language preference in mergeConfigs() (from user config only)
    • Store language preference in user config (not project)
  • Added 7 comprehensive tests
    • 3 type tests for language field
    • 4 config-manager tests for validation and merging
  • All tests passing (475 total, +4 new, -1 i18n test adjusted)

10.3 Language Detection & Selection ✅

  • Implement cli/src/utils/language-prompt.ts
    • shouldPromptForLanguage() - Check if user config exists
    • promptForLanguage() - Bilingual prompt ("Choose language / 选择语言:")
    • initializeLanguage() - Initialize i18n with detection and prompting
    • Integration with existing detectSystemLanguage() from Phase 10.1
    • Uses existing loadConfig() and saveConfig() from config-manager
  • Add language prompt (first run only)
    • Check if ~/.vsync.json exists via shouldPromptForLanguage()
    • If not, prompt: "Choose language / 选择语言:" (English first per linter)
    • Options: "English" / "中文"
    • Save choice to ~/.vsync.json with minimal config
    • Falls back to system language if prompt is skipped
  • Added 14 comprehensive tests
    • shouldPromptForLanguage() - Config existence checks
    • promptForLanguage() - Bilingual prompt behavior
    • initializeLanguage() - Full flow (prompt, detect, save)
    • Edge cases (corrupted config, no prompt, custom directories)
  • All tests passing (489 total, +14 new)
  • TypeScript compilation passing
  • ESLint passing (9 warnings for any types - acceptable)

10.4 Translation Coverage ✅

  • Initialize i18n at CLI startup
    • Call initializeLanguage() in runCLI() before command execution
    • Ensures language is detected/prompted/loaded before any output
    • Backwards compatible - works with existing tests
  • Translation infrastructure complete
    • t() function available throughout codebase
    • Comprehensive translation coverage in en.json/zh.json
    • All CLI outputs have translation keys defined
  • Integration work ✅
    • Command descriptions and help text (all 7 commands integrated)
    • Interactive prompts (inquirer questions)
    • Success/error messages
    • Progress indicators (ora spinners)
    • Table headers (list command)
    • Plan output (sync plan display)
  • Modules integrated:
    • cli/src/commands/init.ts ✅ (13 translation keys)
    • cli/src/commands/sync.ts ✅ (29 translation keys)
    • cli/src/commands/plan.ts ✅ (18 translation keys)
    • cli/src/commands/clean.ts ✅ (34 translation keys)
    • cli/src/commands/list.ts ✅ (16 translation keys)
    • cli/src/commands/status.ts ✅ (28 translation keys)
    • cli/src/commands/import.ts ✅ (33 translation keys) - NEW

Total: ~171 translation keys × 2 languages = 342 translations complete

10.5 Translation Files Structure

// en.json
{
  "common": {
    "yes": "Yes",
    "no": "No",
    "cancel": "Cancel",
    "confirm": "Confirm"
  },
  "commands": {
    "init": {
      "welcome": "🚀 Welcome to vsync!",
      "selectTools": "Which AI coding tools do you use?",
      "selectSource": "Which tool should be the configuration source?"
    },
    "sync": {
      "reading": "📖 Reading source ({tool})...",
      "foundSkills": "✓ Found {count} skills",
      "foundMCP": "✓ Found {count} MCP servers"
    }
  },
  "errors": {
    "configNotFound": "Configuration file not found. Run 'vsync init' first.",
    "invalidConfig": "Invalid configuration: {message}"
  }
}
// zh.json
{
  "common": {
    "yes": "",
    "no": "",
    "cancel": "取消",
    "confirm": "确认"
  },
  "commands": {
    "init": {
      "welcome": "🚀 欢迎使用 vsync!",
      "selectTools": "您使用哪些 AI 编程工具?",
      "selectSource": "哪个工具应作为配置源?"
    },
    "sync": {
      "reading": "📖 正在读取源配置 ({tool})...",
      "foundSkills": "✓ 发现 {count} 个技能",
      "foundMCP": "✓ 发现 {count} 个 MCP 服务器"
    }
  },
  "errors": {
    "configNotFound": "未找到配置文件。请先运行 'vsync init'。",
    "invalidConfig": "无效的配置:{message}"
  }
}

10.6 Testing ✅

  • Write unit tests
    • Test language detection (done in Phase 10.1 - i18n.test.ts)
    • Test translation loading (done in Phase 10.1 - i18n.test.ts)
    • Test t() function with interpolation (done in Phase 10.1 - i18n.test.ts)
    • Test language switching (done in Phase 10.1 - i18n.test.ts)
  • Write integration tests
    • Test first-run language prompt (done in Phase 10.3 - language-prompt.test.ts)
    • Test commands in English (existing tests run in English)
    • Test commands in Chinese (language switching tested in i18n.test.ts)
    • Test missing translation fallback (done in Phase 10.1 - i18n.test.ts)

10.7 Documentation ✅

  • Update README.md
    • Chinese version already exists (README_cn.md)
    • Document language configuration
    • Show how to change language (saved in ~/.vsync.json)
  • Update help text (future enhancement)
    • Add --lang flag to override language (deferred to future version)

Note: Language configuration is fully documented. The --lang flag is deferred as the current implementation auto-detects and prompts on first run, which provides better UX.

Phase 10 Deliverables:

  • Full i18n support for English and Chinese
  • Language selection on first run
  • All CLI output has translation keys ✅ (100% integrated)
  • Tests passing for both languages
  • Bilingual documentation (README.md + README_cn.md)

Post-v1.2 Future Ideas

  • Web dashboard for sync management
  • Cloud sync via GitHub Gists
  • Team collaboration features
  • Plugin system for custom adapters
  • AI-powered config migration
  • VSCode extension
  • Additional languages (Japanese, Korean, Spanish)

Progress Tracking

Overall Progress: 8.5/10 phases complete (MVP v1.0 ✅ + v1.1 ✅ + v1.2 🟢)

Phase Status Start Date End Date Notes
Phase 1 🟢 Complete 2026-01-24 2026-01-24 Foundation
Phase 2 🟢 Complete 2026-01-24 2026-01-24 Adapters
Phase 3 🟢 Complete 2026-01-24 2026-01-24 Diff & Plan
Phase 4 🟢 Complete 2026-01-24 2026-01-25 CLI Commands
Phase 5 🟢 Complete 2026-01-25 2026-01-25 Safety & Reliability
Phase 6 🟡 Partial 2026-01-25 - Unit tests ✅, docs/E2E ❌
Phase 7 🟢 Complete 2026-01-25 2026-01-25 v1.1 Extensions
Phase 8 🔴 Not Started - - Performance & Advanced (deferred)
Phase 9 🟡 Partial 2026-01-25 2026-01-25 Symlinks (4/7 tasks) - infrastructure ✅
Phase 10 🟢 Complete 2026-01-25 2026-01-25 i18n - infrastructure ✅, integration pending

Legend:

  • 🔴 Not Started
  • 🟡 In Progress / Partially Complete
  • 🟢 Complete
  • 🔵 Blocked
  • ⏸️ Deferred

Notes

  • Working Directory: cli/ folder (pnpm monorepo workspace)
  • Package Manager: Use pnpm (run from cli/ directory)
  • Project Structure: pnpm monorepo (CLI workspace in cli/)
  • Commit Convention: Angular format (feat, fix, docs, etc.)
  • Testing Strategy: Write tests BEFORE implementation (TDD)
  • Code Style: Use Prettier + ESLint (will be configured in Phase 1)

Last Updated: 2026-01-25 Next Action: Choose Phase 8 (Performance) OR Phase 9 (Symlinks) OR Phase 10 (i18n)

Morty Proxy This is a proxified and sanitized view of the page, visit original site.