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-baseline-hooks

v0.6.0

Published

Security validation, logging, context monitoring, and Kokoro TTS voice notifications for OpenCode

Readme

opencode-baseline-hooks

Security validation, logging, context monitoring, and Kokoro TTS voice notifications for OpenCode.

Features

  • Security: Block dangerous commands and sensitive file access
  • Logging: Track tool usage, file changes, errors, sessions
  • Context Monitoring: Track token usage, backup before context overflow
  • Pre-Compact Backup: Automatically backup state before context compaction
  • Prompt Logging: Log all user prompts for session recovery
  • Voice: Kokoro TTS announcements for task completion and alerts

Installation

npm install -g opencode-baseline-hooks

CLI Commands

After global installation, these commands are available:

| Command | Description | |---------|-------------| | opencode-pre-tool | Pre-tool validation (security checks) | | opencode-post-tool | Post-tool logging (errors, stats) | | opencode-session-start | Session initialization | | opencode-pre-compact | Pre-compaction backup | | opencode-user-prompt | User prompt logging | | opencode-context-monitor | Context/token monitoring |

Usage in opencode.json

{
  "hooks": {
    "PreToolUse": [{
      "matcher": "",
      "hooks": [{
        "type": "command",
        "command": "opencode-pre-tool"
      }]
    }],
    "PostToolUse": [{
      "matcher": "",
      "hooks": [{
        "type": "command",
        "command": "opencode-post-tool"
      }]
    }],
    "SessionStart": [{
      "matcher": "",
      "hooks": [{
        "type": "command",
        "command": "opencode-session-start"
      }]
    }],
    "PreCompact": [{
      "matcher": "",
      "hooks": [{
        "type": "command",
        "command": "opencode-pre-compact --backup --verbose"
      }]
    }],
    "UserPromptSubmit": [{
      "matcher": "",
      "hooks": [{
        "type": "command",
        "command": "opencode-user-prompt --log-only --store-last-prompt"
      }]
    }],
    "Notification": [{
      "matcher": "",
      "hooks": [{
        "type": "command",
        "command": "opencode-context-monitor"
      }]
    }]
  }
}

Configuration

| Variable | Default | Description | |----------|---------|-------------| | KOKORO_URL | http://localhost:8880 | Kokoro TTS API endpoint | | KOKORO_VOICE | bf_emma | Voice to use | | OPENCODE_VOICE | (enabled) | Set to off to disable voice | | PROJECT_DIR | (current dir) | Project root directory |

Security Patterns Blocked

Dangerous Commands

  • rm -rf /, recursive delete with dangerous paths
  • sudo, su commands
  • chmod 777, world-writable permissions
  • Piping curl/wget to shell
  • Docker system prune
  • Disk formatting commands

Sensitive Files

  • .env (allows .env.example)
  • credentials.json, secrets.json
  • .ssh/ directory, SSH keys
  • .aws/credentials, .kube/config

Secret Detection (in writes)

  • AWS access keys
  • GitHub/GitLab tokens
  • Stripe keys
  • Private keys, JWTs
  • Database URLs with passwords

Context Monitoring

The context monitor tracks cumulative token usage and creates backups at thresholds:

  • 70%: Warning backup created
  • 85%: Critical backup created

Backups include:

  • Current todos
  • Recent prompts
  • Session state
  • Recovery instructions

Backups are stored in .opencode/backup/.

Log Files

All logs are stored in .opencode/logs/:

| File | Contents | |------|----------| | pre_tool_use.json | Tool calls with arguments | | post_tool_use.json | Tool outputs | | blocked.json | Blocked dangerous commands | | errors.json | Detected errors | | sessions.json | Session lifecycle | | daily_stats.json | Daily usage statistics | | user_prompts.json | User prompt history | | context_state.json | Current context state | | messages.jsonl | Message log for token tracking |

Kokoro TTS Setup

Run Kokoro TTS locally with Docker:

docker run -d -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-cpu:latest

Plugin API

The package also exports a plugin for OpenCode's plugin system:

import plugin from "opencode-baseline-hooks"

const hooks = await plugin({ directory: "/path/to/project" })

License

MIT

Repository

github.com/48Nauts-Operator/opencode-baseline