opencode
opencode copied to clipboard
perf(bun): cache plugin versions with TTL to avoid reinstalling on every startup
Summary
- Fixes slow startup (~21 seconds) caused by reinstalling plugins on every launch
- When plugins use
@latest, the cache now tracks timestamps and reuses cached versions for 24 hours - Reduces plugin loading time from ~21s to <1s
Problem
The cache check compared 'latest' against the resolved version (e.g., '2.12.2'), which never matched:
if (parsed.dependencies[pkg] === version) return mod // 'latest' !== '2.12.2'
Solution
- Added
_timestampsfield to track when packages were installed - For
@latestrequests, reuse cached version if installed within 24 hours - Still allows periodic updates while avoiding redundant reinstalls