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

@lemantorus/opencode-analytics

v1.0.2

Published

Analytics dashboard for OpenCode - visualize your AI coding usage (unofficial)

Readme

OpenCode Analytics

npm version npm downloads

⚠️ Unofficial - This is a community-built dashboard, not affiliated with or endorsed by Anomaly (the creators of OpenCode).

A beautiful, real-time analytics dashboard for OpenCode that visualizes your AI coding usage, token consumption, costs, and model performance.

Dashboard Preview

Mobile Preview

Features

📊 Usage Overview

  • Total messages count
  • Input/Output token breakdown
  • Cache read/write statistics
  • Estimated cost calculation

📈 Daily Usage Trend

  • Interactive line chart showing token usage over time
  • Toggle between Tokens view and Cost view
  • Supports custom date ranges

🤖 Model Breakdown

  • Comprehensive table of all models used
  • Per-model statistics: messages, input/output tokens, cache, cost
  • Visual bar chart comparison
  • Cost distribution doughnut chart

⚡ Models Usage (TPS)

  • Real tokens-per-second calculation using actual response times
  • Select which models to compare (multi-select dropdown)
  • Shows average TPS per day over the last 30 days
  • Tooltip shows tree format with TPS + input/output tokens:
    Model Name
      ├─ TPS: 45.23 tok/s
      └─ In: 12.5K | Out: 8.2K

How TPS is calculated:

Output TPS = outputTokens / ((time.completed - time.created) / 1000)

This uses the actual response start and completion timestamps from each message, providing true generation speed metrics.

🕐 Hourly Activity

  • See your most productive hours
  • Toggle between Messages count and TPS view
  • Visual indication of peak hours (business hours highlighted)

💰 Cost Management

  • Automatic pricing from models.dev API
  • Manual price overrides per model
  • Total estimated cost tracking

🎨 Design

  • Dark theme optimized for developers
  • JetBrains Mono font
  • Smooth animations
  • Responsive layout

Installation

From npm (recommended)

npm install -g @lemantorus/opencode-analytics

From source

git clone https://github.com/lemantorus/opencode_analytics.git
cd opencode_analytics
npm install

Usage

Quick Start

Simply run from anywhere:

opencode-analytics

This will:

  1. Auto-detect your OpenCode database location based on your OS
  2. Start the server on http://localhost:3456
  3. Open the dashboard in your default browser

Command Line Options

| Option | Alias | Description | Default | |--------|-------|-------------|---------| | --port | -p | Port to run server on | 3456 | | --db | - | Path to OpenCode database | Auto-detected | | --no-open | - | Don't open browser automatically | false | | --help | -h | Show help message | - |

Examples

# Run on custom port
opencode-analytics --port 4000

# Use custom database path
opencode-analytics --db /path/to/opencode.db

# Don't open browser
opencode-analytics --no-open

# Combine options
opencode-analytics -p 3000 --db ~/custom/opencode.db --no-open

Environment Variables

# Override database path
OPENCODE_DB_PATH=/custom/path/opencode.db opencode-analytics

# Override port
PORT=4000 opencode-analytics

Database Locations

OpenCode stores its SQLite database in platform-specific locations:

| OS | Path | |----|------| | Linux | ~/.local/share/opencode/opencode.db | | macOS | ~/.local/share/opencode/opencode.db | | Windows | %USERPROFILE%\.local\share\opencode\opencode.db |

The application automatically detects your OS and finds the database. You can override this with the --db flag or OPENCODE_DB_PATH environment variable.

Custom Pricing

The dashboard fetches live pricing from models.dev, but you can override prices for any model:

  1. Click "Edit Pricing" button
  2. Modify prices per 1M tokens
  3. Click "Save" for each model

Your custom prices are stored locally and will persist across sessions.

Development

Running from source

# Clone the repository
git clone https://github.com/lemantorus/opencode_analytics.git
cd opencode_analytics

# Install dependencies
npm install

# Start the server
npm start

Project Structure

opencode-analytics/
├── bin/
│   └── opencode-analytics.js    # CLI entry point
├── server/
│   ├── index.js                # Express server
│   ├── db.js                   # Database queries
│   ├── pricing.json            # Cached pricing data
│   └── user-prices.json        # User overrides
├── public/
│   ├── index.html              # Dashboard HTML
│   ├── app.js                  # Frontend JavaScript
│   └── styles.css              # Dashboard styles
├── package.json
└── README.md

Tech Stack

  • Backend: Node.js, Express
  • Database: SQLite (OpenCode's native DB)
  • Frontend: Vanilla JavaScript, Chart.js
  • Build: No build step required

License

MIT License - feel free to use, modify, and distribute.

Author

Built by Lemantorus - Not affiliated with Anomaly or the official OpenCode project.

Credits

Support

If you encounter any issues or have suggestions:

  1. Check the issues
  2. Open a new issue if needed
  3. Contributions are welcome!