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-permission-guard

v1.0.0

Published

Monitors OpenCode for permission errors (EACCES, EPERM) and sends native OS notifications with focus detection

Readme

opencode-permission-guard

CI npm License: MIT

Monitors OpenCode for permission errors (EACCES, EPERM, "Permission denied", "Access denied") and sends native OS notifications so you never miss a file access issue.

Features

  • Native OS notifications — macOS Notification Center and Linux notify-send
  • Focus detection — skips notifications when your terminal is the active window (macOS)
  • 10-second cooldown — prevents notification spam from repeated errors
  • Configurable — customize messages, sounds, patterns, and behavior via JSON config
  • i18n — English and Spanish notification messages (auto-detected from $LANG)
  • Two install methods — npm OpenCode plugin (native) or shell wrapper (standalone)

Installation

Option 1: OpenCode Plugin (recommended)

Add to your opencode.json:

{
  "plugin": ["opencode-permission-guard"]
}

If the package isn't on npm yet, place src/ in .opencode/plugins/:

mkdir -p .opencode/plugins/permission-guard
cp src/*.ts .opencode/plugins/permission-guard/

Restart your OpenCode session. The plugin loads automatically at startup.

Option 2: Shell Wrapper

Source the wrapper in your shell config:

# zsh
echo "source $(pwd)/shell/opencode-guard.zsh" >> ~/.zshrc
source ~/.zshrc

The wrapper intercepts opencode calls, captures stderr, and fires a notification if permission errors are detected after the command exits.

To bypass the wrapper temporarily:

opencode --no-monitor [args...]

To uninstall:

opencode_permission_guard_uninstall

Configuration (Plugin)

Create ~/.config/opencode/permission-guard.json to customize behavior:

{
  "enabled": true,
  "cooldownMs": 15000,
  "notification": {
    "title": {
      "en": "OpenCode Permission Guard",
      "es": "OpenCode Detenido"
    },
    "body": {
      "en": "Permission denied — check read/write access",
      "es": "Se requieren permisos de lectura/escritura"
    },
    "sound": "Basso"
  },
  "patterns": [
    "permission denied",
    "eacces",
    "eperm",
    "access denied"
  ],
  "focusDetection": true
}

| Key | Default | Description | |-----|---------|-------------| | enabled | true | Enable/disable the plugin | | cooldownMs | 10000 | Minimum ms between notifications | | notification.title | {en, es} | Notification title per locale | | notification.body | {en, es} | Notification body per locale | | notification.sound | "Basso" | macOS alert sound name | | patterns | [...] | Regex patterns to detect (case-insensitive) | | focusDetection | true | Skip notification when terminal is frontmost (macOS) |

Available macOS sounds: Basso, Blow, Bottle, Frog, Funk, Glass, Hero, Morse, Ping, Pop, Purr, Sosumi, Submarine, Tink


How It Works

opencode executes a tool (read, write, bash, edit...)
    │
    ▼
┌──────────────────────────┐
│ Plugin hooks into:        │
│ • tool.execute.after      │  ← tool output scanned for patterns
│ • session.error           │  ← session errors scanned
│ • permission.asked        │  ← proactive notification
│                           │
│ Shell wrapper:            │
│ • captures stderr via tee │
└──────────┬───────────────┘
           │
           ▼
┌──────────────────────────┐
│ Focus detection?          │
│ (macOS: skip if terminal  │
│  is frontmost app)        │
└──────────┬───────────────┘
           │ not focused / disabled
           ▼
┌──────────────────────────┐
│ Cooldown check            │
│ (skip if within 10s of    │
│  last notification)       │
└──────────┬───────────────┘
           │ cooldown clear
           ▼
┌──────────────────────────┐
│ OS Notification           │
│ "⚠️ OpenCode Detenido"    │
│ + sound alert (Basso)     │
└──────────────────────────┘

Detected Patterns

| Pattern | Example error output | |---------|---------------------| | Permission denied | Error: Permission denied (os error 13) | | EACCES | EACCES: permission denied, open '/etc/shadow' | | EPERM | EPERM: operation not permitted, lstat '/root' | | Access denied | Access denied to /private/etc |

Development

bun install          # Install dev dependencies
bun run typecheck    # TypeScript strict type checking

FAQ

Does this add context bloat to OpenCode sessions? No. The plugin is event-driven — no tools are added to conversations, no prompts are injected.

Will I get spammed with notifications? No. The cooldown limits to one notification per 10 seconds (configurable). Focus detection on macOS suppresses notifications when your terminal is the active window.

How do I disable it temporarily? Set "enabled": false in ~/.config/opencode/permission-guard.json, or remove "opencode-permission-guard" from your opencode.json plugin list.

License

MIT