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

@johnatas-henrique/opencode-hooks

v0.8.0

Published

TypeScript plugin system for OpenCode AI providing event-driven hooks

Readme

OpenCode Hooks

Codecov CI

A TypeScript plugin system for OpenCode AI that provides event-driven hooks for session lifecycle, tool execution, file operations, and UI notifications (toasts).

Features

  • 28 OpenCode Events — Full coverage of all documented OpenCode events: session, message, tool, file, permission, server, command, LSP, installation, todo, shell, TUI, and experimental events
  • Toast Notifications — Staggered, non-overlapping toasts with configurable title, variant, message, and duration
  • Script Execution — Run shell scripts on any event with per-event and per-tool configuration
  • File Persistence — Save script output and event logs to disk
  • Session Context — Append script output to the active OpenCode session
  • Type-Safe Configuration — Full TypeScript support with autocomplete and compile-time validation
  • Per-Tool Configuration — Different behavior for different tools (e.g., task, chat, git.commit)

Quick Start

Prerequisites

Installation

Via opencode.json (recommended)

Add the plugin to your opencode.json:

{
  "plugins": ["@johnatas-henrique/opencode-hooks@latest"]
}

OpenCode installs and loads the plugin automatically.

Via npm

npm install @johnatas-henrique/opencode-hooks

Create the entry point .opencode/plugins/opencode-hooks.ts:

export { default } from '@johnatas-henrique/opencode-hooks';

OpenCode detects and loads the plugin from this file.

Via git clone (development)

mkdir -p .opencode/plugins
cd .opencode/plugins
git clone <repository-url> opencode-hooks
cd opencode-hooks
npm install
npm run build

First Startup

Zero configuration required. When OpenCode starts with the plugin:

  1. Claude hooks detected — existing hooks from ~/.claude/hooks/ and .claude/hooks/ are loaded and mapped to OpenCode events automatically
  2. Default config created.opencode/opencode-hooks.jsonc is created with sensible defaults if no config exists
  3. Status toast — a notification shows which plugins are active
  4. Scripts directory.opencode/scripts/ is created for your custom scripts
  5. Audit logging — event logs start recording under opencode-hooks/logs/

Everything works out of the box. To customize behavior, edit .opencode/opencode-hooks.jsonc — see Configuration.

Next Steps

  • See Configuration to customize events, tools, scripts, and audit via JSONC
  • See Scripts to learn how to write blocking scripts, async scripts, and Claude-compatible hooks
  • See Events for the full event catalog with available fields

Documentation

| Document | Description | | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | Configuration | Full reference for opencode-hooks.jsonc — all config fields, types, events, tools, audit, and toasts | | Scripts | How to write and run shell scripts — stdin formats, blocking, async, exit codes, Claude Code compatibility | | Events | Event catalog with available fields, descriptions, and recommended toast fields | | Claude Code Compatibility | How Claude Code .sh hooks map to OpenCode events — stdin field comparison, limitations, and migration checklist | | Audit System | Audit logging reference — log files, sanitization, archiving, and migration |

Development

Available Scripts

npm run build          # Compile TypeScript
npm run test:unit      # Run unit tests
npm run test:cov       # Run tests with coverage
npm run test:integration  # Run integration tests
npm run test:e2e       # Run E2E tests
npm run test:all       # Run all tests (unit + integration + e2e)
npm run coverage:report # Full coverage report (HTML)
npm run lint           # Run ESLint
npm run lint:fix       # Fix ESLint errors
npm run format         # Run Prettier
npm run format:check   # Check formatting

Test Coverage

Current coverage: 99%+ statements, 99%+ branches, 99%+ functions, 99%+ lines

npm run test:cov       # Terminal coverage summary
npm run coverage:report # HTML report in coverage/lcov-report/index.html

License

MIT