refresh-plugins: diff newest cache version dir, not first glob hit

Old version directories linger in the plugin cache after upgrades, and
verify_cache diffed an arbitrary (typically oldest) one against source,
reporting freshly refreshed plugins as STALE.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XaCiJr2hkuRnJZv2eJmoWt
This commit is contained in:
jared 2026-07-17 08:32:44 -04:00
parent cc2f2914c5
commit 4c71f65313
1 changed files with 2 additions and 2 deletions

View File

@ -93,11 +93,11 @@ class PluginRefresher
cache_base = File.expand_path("~/.claude/plugins/cache/#{marketplace_name}/#{plugin_name}") cache_base = File.expand_path("~/.claude/plugins/cache/#{marketplace_name}/#{plugin_name}")
source_full = File.join(source_path, plugin_name) source_full = File.join(source_path, plugin_name)
# Find the version directory in cache # Old version directories linger after upgrades; diff the newest one
versions = Dir.glob(File.join(cache_base, '*')).select { |p| File.directory?(p) } versions = Dir.glob(File.join(cache_base, '*')).select { |p| File.directory?(p) }
return false if versions.empty? return false if versions.empty?
cache_path = versions.first cache_path = versions.max_by { |p| File.mtime(p) }
# Run diff check (exclude plugin manager state files) # Run diff check (exclude plugin manager state files)
output = `diff -rq "#{cache_path}" "#{source_full}" --exclude='.git' --exclude='__pycache__' --exclude='.orphaned_at' 2>&1` output = `diff -rq "#{cache_path}" "#{source_full}" --exclude='.git' --exclude='__pycache__' --exclude='.orphaned_at' 2>&1`