feat: warn when installed plugin lags registry latest#33
Merged
Conversation
opencode caches the @latest plugin install on first use and never re-resolves the dist tag, so users silently stay on stale releases. On plugin init, fetch the registry's latest version (throttled to once per 24h via ~/.cache/opencode-cursor/version-check.json) and print a one-time warning with the cache dir to delete and restart.
…te check
- Inject __PKG_VERSION__ via tsup define: in the published bundle,
createRequire('../package.json') resolved inside dist/ and silently
no-op'd the whole check. Un-bundled runs (tests) fall back to reading
package.json.
- Guard warnIfStale() call with .catch() and validate versions with
semver.valid() before comparing, so invalid registry data can't throw.
- Check res.statusCode === 200 before parsing the registry response.
- Cache failed fetches for 1h instead of 24h.
- Skip the check when CI or NO_UPDATE_NOTIFIER is set (documented in README).
- Emit a platform-appropriate removal command (rmdir /s /q on win32),
matching the README.
- Decouple tests from the real package.json version via injected
__PKG_VERSION__; add tests for malformed JSON, non-200, env skips,
invalid versions, failure TTL, and platform-specific commands; drop
dead lastRequestUrl.
9439958 to
651884d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
opencode caches the @latest plugin install on first use and never re-resolves the dist tag, so users silently stay on stale releases (e.g. the reported case where 0.1.0 was still installed despite 0.4.1 being published).
What
On plugin init, fetch the npm registry's
latestversion (throttled to once per 24h via~/.cache/opencode-cursor/version-check.json) andconsole.warnwhen the installed plugin is behind, with the exact cache dir to delete and a restart instruction.Why not auto-update
opencode's
Npm.add(packages/core/src/npm.ts) early-returns when the cache dir exists, so the plugin cannot self-reinstall. The nudge turns silent staleness into a visible prompt; users on pinned versions are unaffected.Notes
node:https(not global fetch) — context-mode learned that global fetch can hit a WindowsUV_HANDLE_CLOSINGundici assertion on Node v24+.