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

v0.1.3

Published

Cursor-style debug agent for OpenCode — inject probes into CLI and browser apps, capture runtime data via HTTP, analyze and fix bugs automatically.

Downloads

94

Readme

opencode-debug

Cursor-style debug agent for OpenCode — inject probes into CLI and browser apps, capture runtime data, analyze and fix bugs automatically.

Why?

Cursor's Debug Mode works by instrumenting code with probes that POST runtime data to a local HTTP server. This plugin gives OpenCode the same capability — plus CLI apps get automatic reproduction via shell access.

Two modes:

  • CLI mode — for Node.js/Python/Go scripts, test suites, server apps. Agent runs the command itself, no user action needed.
  • Browser mode — for React/Vue/Svelte apps. User reproduces the bug in their real browser (extensions, cookies, sessions intact). Probes POST data to the agent's HTTP server.

Architecture

┌──────────────────────────────────────────────────┐
│                    OpenCode                       │
│                                                  │
│  ┌─────────┐    ┌───────────────────────────┐   │
│  │  debug   │    │    debug agent prompt     │   │
│  │  agent   │◄───│    (two-mode workflow)     │   │
│  └────┬─────┘    └───────────────────────────┘   │
│       │                                          │
│  ┌────▼──────────────────────────────────────┐   │
│  │              6 Tools                      │   │
│  │                                           │   │
│  │  debug-quick-check  ──► Fast triage       │   │
│  │  debug-server       ──► HTTP capture      │   │
│  │  debug-instrument   ──► Inject probes     │   │
│  │  debug-run-and-capture ─► Run + log       │   │
│  │  debug-read-capture ──► Filter output     │   │
│  │  debug-cleanup      ──► Remove probes     │   │
│  └───────────────────────────────────────────┘   │
│       │                                          │
│  ┌────▼──────────┐   ┌──────────────────┐        │
│  │ /tmp/opencode- │   │ http://localhost │        │
│  │ debug/*.log    │   │ :9514/capture    │        │
│  │ (CLI mode)     │   │ (browser mode)   │        │
│  └────────────────┘   └──────────────────┘        │
└──────────────────────────────────────────────────┘

Tools

debug-quick-check

Fast triage — runs a command, captures exit code/stderr, detects common error patterns (TypeError, ImportError, ECONNREFUSED, etc.). Use this first before the full workflow.

debug-server

Start/stop the HTTP capture server for browser mode. Probes in your app POST runtime data here. Endpoints: /capture, /status, /sessions, /session/:id, /shutdown. CORS enabled — works with Vite, Next.js dev mode, any dev server.

debug-instrument

Inject debug probes into source files. Two modes:

CLI mode (mode: "cli") — console.log probes captured via stdout:

/* @debug:loop-var:abc123 */
console.log("[DEBUG:loop-var]", JSON.stringify({i: i}))

Browser mode (mode: "browser") — fetch() probes POST to debug server:

// #region opencode-debug: loop-var
(function(){
  var _j = JSON.stringify({t:Date.now(), p:"loop-var", s:"abc123", d:{"i": i}});
  fetch("http://localhost:9514/capture", {method:"POST", body:_j, headers:{"Content-Type":"application/json"}, keepalive:true}).catch(function(){});
})();
// #endregion opencode-debug: loop-var

| Probe Type | What it does | |------------|-------------| | trace | Logs function entry with arguments | | log | Logs variable/expression values | | timer | Measures execution time (start + end) | | watch | Logs expression value at that point |

Supports TypeScript, JavaScript, Python, and Go. Creates .debug.bak backups before modifying files.

debug-run-and-capture

Run a shell command and capture all stdout/stderr to a session-scoped log file. Supports timeout, custom cwd, env vars, session reuse.

debug-read-capture

Read and filter captured output. Two formats:

  • format: "raw" — for CLI mode stdout capture
  • format: "structured" — for browser mode JSON probe data

Supports keyword search, regex, line ranges.

debug-cleanup

Remove all debug probes and stop the server. Handles both /* @debug: */ markers (CLI) and #region blocks (browser). Can restore from .bak, remove logs, stop server, dry-run.

Installation

opencode plugin opencode-debug

That's it. The tools auto-activate when OpenCode sees error messages.

Usage

CLI app debugging (fully automatic)

Just describe the bug:

"Running node server.js crashes with TypeError"

The agent will triage, instrument, reproduce, analyze, fix, and cleanup — no user action needed.

Browser app debugging (user reproduces)

"Clicking submit in src/Form.tsx crashes the app"

The agent will start the debug server, inject fetch() probes, then say:

"Probes injected. Reproduce the bug in your browser."

You use your real browser at localhost:5173 as normal. The probes POST data back. The agent reads it, fixes the bug, cleans up.

Comparison with Cursor Debug Mode

| Feature | Cursor | opencode-debug | |---------|--------|---------------| | Code exploration | ✅ IDE context | ✅ File access | | Hypothesis generation | ✅ LLM | ✅ LLM | | Code instrumentation | ✅ IDE extension | ✅ Comment markers + fetch() probes | | Runtime capture (browser) | ✅ IDE debug server | ✅ HTTP capture server | | Runtime capture (CLI) | ❌ | ✅ Shell pipes to log | | Auto-reproduce (CLI) | ❌ User reproduces | ✅ Agent runs commands | | Multi-language | ✅ VS Code debugger | ✅ TS/JS/Python/Go probes | | Cleanup | ✅ Automatic | ✅ Marker + #region removal | | Real browser (extensions, cookies) | ✅ User's browser | ✅ User's browser |

Project Structure

opencode-debug/
├── src/
│   ├── index.ts              # Plugin entry point
│   └── tools/
│       ├── quick-check.ts    # Fast triage
│       ├── debug-server.ts   # HTTP capture server
│       ├── instrument.ts     # Probe injection (CLI + browser)
│       ├── run-and-capture.ts # Run + capture
│       ├── read-capture.ts   # Log reader (raw + structured)
│       └── cleanup.ts        # Probe removal + server stop
├── agent/
│   └── debug.md              # Debug agent system prompt
├── skill/
│   └── SKILL.md              # Auto-activation skill
├── package.json
├── tsconfig.json
└── README.md

Verified Test Results

Unit tests: 16/16 passing (npm run test)

Integration tests in OpenCode 1.14.39:

  1. ✅ Plugin loading — all 6 tools registered
  2. ✅ Agent selection — --agent debug activates debug agent
  3. ✅ Quick-check tool — detects TypeError, ImportError patterns
  4. ✅ CLI mode workflow — instrument → run-and-capture → read → fix → cleanup
  5. ✅ Browser mode workflow — server start → instrument → simulated POST → read structured data → cleanup + stop server
  6. ✅ Skill auto-activation — default agent uses debug tools on error messages
  7. ✅ Cleanup — removes both /* @debug: */ markers and #region blocks

License

MIT