Skip to content

feat: warn when installed plugin lags registry latest#33

Merged
justin-carper merged 2 commits into
mainfrom
update-opencode-latest
Jul 6, 2026
Merged

feat: warn when installed plugin lags registry latest#33
justin-carper merged 2 commits into
mainfrom
update-opencode-latest

Conversation

@justin-carper

Copy link
Copy Markdown
Collaborator

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 latest version (throttled to once per 24h via ~/.cache/opencode-cursor/version-check.json) and console.warn when 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

  • Uses node:https (not global fetch) — context-mode learned that global fetch can hit a Windows UV_HANDLE_CLOSING undici assertion on Node v24+.
  • Registry request has a 5s timeout and never throws.
  • README updated with the cache-clear workaround.

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.
@justin-carper justin-carper force-pushed the update-opencode-latest branch from 9439958 to 651884d Compare July 6, 2026 19:57
@justin-carper justin-carper merged commit 3a18ea4 into main Jul 6, 2026
7 checks passed
@justin-carper justin-carper deleted the update-opencode-latest branch July 6, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant