npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opencode-plugin-update-kit

v0.2.0

Published

Auto-update kit for opencode plugins — detects new versions, installs them, and notifies the user. Handles concurrency when multiple plugins use it.

Downloads

633

Readme

opencode-plugin-update-kit

Auto-update kit for opencode plugins. Drop it in and your plugin auto-updates on startup — no boilerplate.

Install

bun add opencode-plugin-update-kit

Usage

import { autoUpdate } from "opencode-plugin-update-kit"

export default async function MyPlugin(ctx) {
  autoUpdate({
    pkgName: "my-plugin",
    client: ctx.client,
    $: ctx.$,
    importMeta: import.meta,
  })

  // ... rest of your plugin
}

That's it. On every startup it checks npm for a newer version and runs opencode plugin [email protected] --force --global if found.

API

autoUpdate(options)

| Option | Type | Default | Description | |--------|------|---------|-------------| | pkgName | string | — | Your npm package name | | client | OpencodeClient | — | From plugin context | | $ | BunShell | — | From plugin context | | importMeta | ImportMeta | — | Pass import.meta so the kit can find your package.json | | log | (msg, level?) => void | client.app.log with console.log fallback | Custom logger | | registryUrl | string | https://registry.npmjs.org/{pkgName}/latest | Custom npm registry | | opencodeBin | string | OPENCODE_BIN env or ~/.opencode/bin/opencode | Custom opencode binary path | | toastDuration | number | 86_400_000 (24h) | Toast duration in ms. 0 for app default. | | skipToast | boolean | false | Disable toast notification | | checkIntervalMs | number | 5_000 (5s) | Minimum time between npm registry checks. Skips the network request if called again within the window. 0 to check on every startup. |

currentVersion(pkgName, importMeta)

Returns the running plugin version as a string, or null if it can't be determined.

const version = currentVersion("my-plugin", import.meta)

semverGt(a, b)

Semver greater-than comparison (x.y.z only).

if (semverGt("2.0.0", version)) {
  // critical update
}

How it works

  1. Version detection — walks up from the caller's file to find package.json with a matching name
  2. Throttle — skips the registry round-trip if it checked within checkIntervalMs (default 5s); the last-check time is persisted to ~/.cache/opencode/{pkgName}.update-kit.json
  3. Registry check — fetches https://registry.npmjs.org/{pkgName}/latest
  4. Semver compare — if latest > current, proceeds
  5. Install stamp — records the installed version so it doesn't reinstall the same version on every startup while you wait to restart (the running code stays on the old version until then)
  6. Sequential install — all updates queue through a single promise chain, so multiple plugins never race on the config file or npm cache
  7. Notification — logs the result and shows a persistent toast asking the user to restart

Concurrency

When multiple plugins use this kit, updates execute one at a time. If plugin A and plugin B both detect new versions during the same startup, the opencode plugin CLI commands run sequentially — no config corruption, no cache contention.

License

MIT