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-awake

v0.1.0

Published

OpenCode plugin: keeps your computer awake while a session works, even with the laptop lid closed

Readme

opencode-awake

OpenCode plugin that keeps your computer awake while a session works, including with the laptop lid closed.

Other sleep plugins run caffeinate, which stops idle sleep but not lid sleep: close a MacBook on battery and OpenCode pauses mid-task. This plugin also blocks lid sleep, on macOS through pmset and on Linux through systemd-inhibit, and gives it back as soon as every session is idle.

Install

OpenCode 2:

opencode plugin add opencode-awake

OpenCode 1, in opencode.json:

{ "plugin": ["opencode-awake"] }

Without any setup, the plugin keeps the machine from idling to sleep while a session works. The lid needs one more step on macOS.

Closed lid on macOS

macOS always sleeps on lid close unless a root process says otherwise. Allow pmset to toggle that one setting without a password:

echo "$(whoami) ALL=(root) NOPASSWD: /usr/bin/pmset -a disablesleep 0, /usr/bin/pmset -a disablesleep 1" | sudo tee /etc/sudoers.d/opencode-awake
sudo chmod 440 /etc/sudoers.d/opencode-awake

The rule allows exactly those two commands and nothing else. Remove it with sudo rm /etc/sudoers.d/opencode-awake.

While the lid hold is on, the Mac can run hot in a closed bag, so the plugin gives it back early:

  • when every session is idle
  • after lidMaxMinutes (3 hours by default)
  • when the battery drops below lidMinBattery percent (20 by default)
  • when OpenCode exits or crashes: a small watchdog process restores sleep once OpenCode's process is gone

If something else already disabled sleep (you ran pmset disablesleep 1 yourself), the plugin leaves it alone.

Closed lid on Linux

systemd-inhibit --what=idle:sleep:handle-lid-switch blocks lid sleep without root on most desktops. If your polkit rules refuse the lid switch, the plugin falls back to idle:sleep. The inhibitor is tied to OpenCode's process, so it can never outlive it.

Options

{
  "plugins": [
    {
      "package": "opencode-awake",
      "options": {
        "lid": true, // false to only block idle sleep
        "lidMaxMinutes": 180,
        "lidMinBattery": 20,
        "graceSeconds": 60,
      },
    },
  ],
}

graceSeconds covers sessions the plugin saw mid-run, for example after OpenCode reloaded it. Those stay held for that long after their last activity. Sessions it saw start stay held until they finish, however long a tool call takes.

How it works

On OpenCode 2 the plugin reads the server event stream: session.execution.started begins a hold, and succeeded, failed, interrupted or deleted ends it. On OpenCode 1 it reads session.status and session.idle. One hold covers every session, so several sessions in parallel start one caffeinate process.

On macOS, caffeinate -i -s -w <pid> blocks idle sleep, and system sleep on AC power, and exits by itself if OpenCode dies.

Development

pnpm typecheck
pnpm test