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

@monks1975/opencode-agent-hooks

v1.0.1

Published

OpenCode plugin that runs Claude Code and Codex hook configs unmodified

Readme

opencode-agent-hooks

OpenCode plugin that runs a project's Claude Code or Codex hook configs unmodified. If your repo already guards, formats, and gates through .claude/settings.json (or the same schema in .codex/hooks.json), this plugin makes those hooks fire inside OpenCode too — same commands, same stdin JSON, same exit-code semantics.

Use

Add the plugin to a project's opencode.json, or to ~/.config/opencode/opencode.json to enable it everywhere:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["@monks1975/[email protected]"]
}

OpenCode installs it on startup. No npm install in the project, no other setup. If the project also carries a copy of this plugin in .opencode/plugins/, remove it — otherwise every hook runs twice.

Config sources

Lowest precedence first; hook arrays are concatenated (later files add hooks, they don't replace):

  1. ~/.claude/settings.json (honours $CLAUDE_CONFIG_DIR)
  2. <project>/.claude/settings.json
  3. <project>/.claude/settings.local.json
  4. <project>/.opencode/hooks.json (same schema; OpenCode-only extras live here)

If neither project .claude file defines hooks, <project>/.codex/hooks.json is read in their place. It is a fallback, not an additional source: a project carrying both configs would otherwise run every hook twice.

Event mapping

| Claude event | OpenCode hook | Notes | | --- | --- | --- | | PreToolUse | tool.execute.before | block (exit 2 / permissionDecision:"deny"), updatedInput | | PostToolUse | tool.execute.after | exit-2 stderr and additionalContext append to the tool output; updatedToolOutput replaces it | | Stop | session.idle event | soft re-prompt loop, see deviations | | UserPromptSubmit | chat.message | stdout / additionalContext injected as a text part | | SessionStart | session.created event | context buffered, delivered with the first message | | PreCompact | experimental.session.compacting | context only |

Matched hooks run in parallel with identical commands deduplicated, as under Claude Code. Tool names are normalized to Claude's (bash -> Bash, mcp__* passes through), so matchers like Write|Edit work as written.

What hooks receive

Each command gets the full Claude-schema payload on stdin: session_id, cwd, hook_event_name, tool_name, snake_case tool_input (OpenCode's filePath becomes file_path), tool_response on PostToolUse, stop_hook_active on Stop, prompt on UserPromptSubmit. Scripts doing jq -r '.tool_input.file_path' work unmodified. transcript_path is present but always empty; transcript synthesis is not implemented.

The JSON output protocol is honoured: hookSpecificOutput.permissionDecision (+ reason), updatedInput, updatedToolOutput, additionalContext, legacy decision/reason, and continue/stopReason.

Deviations from Claude Code

Forced by OpenCode's model, and documented in the source header:

  • session.idle fires after the agent goes idle, so Stop hooks cannot hard-block. A failing Stop hook re-prompts the session with its stderr instead. Re-entry rounds set stop_hook_active: true, exactly like Claude; a per-session round cap is the backstop for hooks that ignore the flag.
  • permissionDecision: "ask" and "allow" are no-ops: OpenCode's own permission flow has already run and cannot be re-opened or bypassed from a plugin.
  • continue: false cannot abort a session. It blocks (PreToolUse), appends the stopReason (PostToolUse), or suppresses the re-prompt chain (Stop).
  • UserPromptSubmit blocking throws from chat.message, which OpenCode does not document as a reject channel. Context injection, the common case, is unaffected.

failClosed

By default a hook that crashes or times out is ignored (fail-open), matching Claude's non-blocking errors. For security guards that is the wrong default. Mark a hook "failClosed": true in .opencode/hooks.json and executor errors become a PreToolUse deny. Re-declaring the identical command string there merges the flag via dedup instead of running the hook twice.

Requirements

  • macOS or Linux: commands run via bash -c with process-group timeout kills.
  • Hook timeouts are per-command, in seconds, from the config ("timeout": 60).

Development

node --test src/index.test.ts

Node 23+ runs the TypeScript directly; Node 22.6+ needs --experimental-strip-types. The suite drives the plugin through its exported entry point with throwaway project fixtures; no build step and no dependencies.

License

MIT