From 4d07471f442b7f04e33bddea95f55152abae2348 Mon Sep 17 00:00:00 2001 From: kaitranntt Date: Sat, 22 Nov 2025 19:35:12 -0500 Subject: [PATCH] fix(shared-dirs): add plugins directory to shared structure symlinks Address PR #15 review comments by ensuring plugins directory is properly handled in shared directory symlinking for both Bash and PowerShell implementations. Adds plugins to directory creation and symlink loops. Fixes: - https://github.com/kaitranntt/ccs/pull/15#discussion_r2553557063 - https://github.com/kaitranntt/ccs/pull/15#discussion_r2553557078 --- lib/ccs | 12 ++++++++---- lib/ccs.ps1 | 14 ++++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/ccs b/lib/ccs index a5097863..ab8025fa 100755 --- a/lib/ccs +++ b/lib/ccs @@ -981,10 +981,10 @@ link_shared_directories() { local shared_dir="$HOME/.ccs/shared" # Ensure shared directories exist - mkdir -p "$shared_dir"/{commands,skills,agents} + mkdir -p "$shared_dir"/{commands,skills,agents,plugins} # Create symlinks (remove existing first if present) - for dir in commands skills agents; do + for dir in commands skills agents plugins; do local link_path="$instance_path/$dir" local target_path="$shared_dir/$dir" @@ -1003,7 +1003,7 @@ migrate_to_shared_structure() { # Check if migration is needed (shared dirs exist but are empty) if [[ -d "$shared_dir" ]]; then local needs_migration=false - for dir in commands skills agents; do + for dir in commands skills agents plugins; do if [[ ! -d "$shared_dir/$dir" ]] || [[ -z "$(ls -A "$shared_dir/$dir" 2>/dev/null)" ]]; then needs_migration=true break @@ -1014,7 +1014,7 @@ migrate_to_shared_structure() { fi # Create shared directory - mkdir -p "$shared_dir"/{commands,skills,agents} + mkdir -p "$shared_dir"/{commands,skills,agents,plugins} # Copy from ~/.claude/ (actual Claude CLI directory) local claude_dir="$HOME/.claude" @@ -1031,6 +1031,10 @@ migrate_to_shared_structure() { # Copy agents to shared (if exists) [[ -d "$claude_dir/agents" ]] && \ cp -r "$claude_dir/agents"/* "$shared_dir/agents/" 2>/dev/null || true + + # Copy plugins to shared (if exists) + [[ -d "$claude_dir/plugins" ]] && \ + cp -r "$claude_dir/plugins"/* "$shared_dir/plugins/" 2>/dev/null || true fi # Update all instances to use symlinks diff --git a/lib/ccs.ps1 b/lib/ccs.ps1 index 20a1ff87..347a5460 100644 --- a/lib/ccs.ps1 +++ b/lib/ccs.ps1 @@ -659,7 +659,7 @@ function Link-SharedDirectories { $SharedDir = "$env:USERPROFILE\.ccs\shared" # Ensure shared directories exist - @('commands', 'skills', 'agents') | ForEach-Object { + @('commands', 'skills', 'agents', 'plugins') | ForEach-Object { $Dir = Join-Path $SharedDir $_ if (-not (Test-Path $Dir)) { New-Item -ItemType Directory -Path $Dir -Force | Out-Null @@ -667,7 +667,7 @@ function Link-SharedDirectories { } # Create symlinks (requires Windows Developer Mode or admin) - @('commands', 'skills', 'agents') | ForEach-Object { + @('commands', 'skills', 'agents', 'plugins') | ForEach-Object { $LinkPath = Join-Path $InstancePath $_ $TargetPath = Join-Path $SharedDir $_ @@ -693,7 +693,7 @@ function Migrate-SharedStructure { # Check if migration is needed (shared dirs exist but are empty) if (Test-Path $SharedDir) { $NeedsMigration = $false - foreach ($Dir in @('commands', 'skills', 'agents')) { + foreach ($Dir in @('commands', 'skills', 'agents', 'plugins')) { $DirPath = Join-Path $SharedDir $Dir if (-not (Test-Path $DirPath) -or (Get-ChildItem $DirPath -ErrorAction SilentlyContinue).Count -eq 0) { $NeedsMigration = $true @@ -705,7 +705,7 @@ function Migrate-SharedStructure { } # Create shared directory - @('commands', 'skills', 'agents') | ForEach-Object { + @('commands', 'skills', 'agents', 'plugins') | ForEach-Object { $Dir = Join-Path $SharedDir $_ New-Item -ItemType Directory -Path $Dir -Force | Out-Null } @@ -731,6 +731,12 @@ function Migrate-SharedStructure { if (Test-Path $AgentsPath) { Copy-Item "$AgentsPath\*" -Destination "$SharedDir\agents\" -Recurse -ErrorAction SilentlyContinue } + + # Copy plugins to shared (if exists) + $PluginsPath = Join-Path $ClaudeDir "plugins" + if (Test-Path $PluginsPath) { + Copy-Item "$PluginsPath\*" -Destination "$SharedDir\plugins\" -Recurse -ErrorAction SilentlyContinue + } } # Update all instances to use symlinks