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

v2026.3.4

Published

OpenCode plugin — generates interactive HTML analytics reports from your session history.

Readme

OpenCodeInsights

A custom /insights command for OpenCode that generates an interactive HTML analytics report from your session history — same format as Claude Code's /insights.

What It Shows

  • Per-session work summaries and project area classification
  • Tool usage, agent distribution, language breakdown
  • Response time distribution and activity by time of day
  • Wins / friction points / actionable suggestions
  • AGENTS.md recommendations and new workflow patterns

Requirements

  • Python 3.10+ (zero external packages — stdlib only)
  • OpenCode installed with session history (~/.local/share/opencode/opencode.db)

Install

Plugin Install (Recommended)

Add opencode-insights to your opencode.json:

// ~/.config/opencode/opencode.json
{
  "plugin": ["opencode-insights"]
}

Then install the package:

cd ~/.config/opencode && npm install opencode-insights

That's it. The /insights command and tools (insights_collect, insights_generate) are registered automatically.

Script Install

curl -sL https://raw.githubusercontent.com/rapidrabbit76/OpenCodeInsights/main/install.sh | bash

This will clone to ~/.local/share/opencode-insights/, register the /insights command, and set OPENCODE_INSIGHTS_HOME in your shell rc.

Manual Install

git clone https://github.com/rapidrabbit76/OpenCodeInsights.git ~/.local/share/opencode-insights
cp ~/.local/share/opencode-insights/insights.md ~/.config/opencode/command/insights.md
echo 'export OPENCODE_INSIGHTS_HOME="$HOME/.local/share/opencode-insights"' >> ~/.zshrc

Usage

Via OpenCode Command (Recommended)

In an OpenCode session:

/insights

With options:

/insights --days 30
/insights --project <PROJECT_ID>

Manual Execution

Run directly without the OpenCode command:

# 1. Optionally use the helper script (recommended)
#    This still expects narratives.json to exist in the output folder.
./scripts/generate-insights-report.sh --days 14

# 1. Collect metrics
python3 src/collector.py --days 14 -o output/raw_metrics.json

# 2. LLM generates narratives (this step is performed by the AI)
#    Analyze raw_metrics.json and write output/narratives.json

# 3. Merge and generate report
python3 -c "
import json
metrics = json.load(open('output/raw_metrics.json'))
narratives = json.load(open('output/narratives.json'))
with open('output/report_data.json', 'w') as f:
    json.dump({'metrics': metrics, 'narratives': narratives}, f, indent=2, ensure_ascii=False)
"
python3 src/generator.py -i output/report_data.json -o output/report.html

# 4. Open in browser
open output/report.html  # macOS
xdg-open output/report.html  # Linux

Optional helper script output

  • Script: scripts/generate-insights-report.sh
  • Creates/updates:
    • output/raw_metrics.json
    • output/report_data.json
    • output/report.html
  • Keeps manual control over --days, --project, and --narratives paths.

How It Works

flowchart LR
  DB[(opencode.db)] --> C[collector.py]
  C -->|raw_metrics.json| OC{OpenCode}
  OC -->|narratives.json| M[merge]
  C -->|raw_metrics.json| M
  M -->|report_data.json| G[generator.py]
  G --> R([report.html])

  style DB fill:#e2e8f0,stroke:#64748b
  style OC fill:#fef3c7,stroke:#f59e0b
  style R fill:#f0fdf4,stroke:#22c55e

| File | Role | |------|------| | src/collector.py | Extracts session, message, and tool metrics from OpenCode's SQLite DB → JSON | | src/generator.py | Merges metrics + AI narratives → interactive HTML report | | insights.md | OpenCode /insights command definition (AI agent instructions) |

Key point: collector.py and generator.py handle pure data processing. Narratives (analysis, summaries, recommendations) are written by the LLM based on the collected metrics.

Configuration

Plugin Mode

No configuration needed. Paths are resolved automatically at runtime.

Script / Manual Mode

Environment Variables

| Variable | Description | Default | |----------|-------------|---------| | OPENCODE_INSIGHTS_HOME | Installation path of this project | Auto-detected under $HOME (4 levels deep) |

# Add to .bashrc or .zshrc
export OPENCODE_INSIGHTS_HOME="$HOME/.local/share/opencode-insights"

If unset, the /insights command auto-discovers the installation via find under $HOME.

Collector Options

python3 src/collector.py [options]

--db PATH       Path to OpenCode DB (default: ~/.local/share/opencode/opencode.db)
--days N        Only include sessions from the last N days
--project ID    Filter by project ID
--output, -o    Output file path (default: stdout)

Generator Options

python3 src/generator.py [options]

--input, -i     Input JSON file (merged metrics + narratives) [required]
--output, -o    Output HTML file path [required]

Project Structure

OpenCodeInsights/
├── index.ts           # Plugin entry point (registers command + tools)
├── package.json       # npm package config
├── tsconfig.json      # TypeScript build config
├── dist/              # Compiled plugin (built by tsc)
├── src/
│   ├── collector.py   # Metrics collector (SQLite → JSON)
│   └── generator.py   # HTML report generator (JSON → HTML)
├── output/            # Generated files (gitignored)
├── insights.md        # OpenCode command definition
├── install.sh         # One-command installer (script mode)
├── .gitignore
└── README.md

License

MIT