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

cxusage

v0.2.3

Published

Analyze Codex daily usage from session logs (Node CLI)

Readme

cxusage

Analyze Codex daily usage from session logs. Similar to ccusage, this Node.js CLI scans JSONL session logs under ~/.codex/sessions and aggregates token counts by day or by model within each day.

  • Input: JSONL logs (recursively) under ~/.codex/sessions by default
  • Output: Plain table (default), Markdown table (--md), or JSON lines (--json)
  • Grouping: By day (default) or by model-within-day (--by model)
  • Timezone: Local timezone by default, or specify via --tz with an IANA TZ

Quickstart

  • After publish to npm: npx cxusage --help
  • From GitHub (before publish): npx github:Effet/cxusage -- --help
  • Typical commands:
    • npx cxusage daily --from 2025-01-01 --to 2025-01-31 --md
    • npx cxusage daily --by model --json

Usage

The top-level command is cxusage. The primary subcommand is daily.

  • Default root: ~/.codex/sessions
  • Date range: --from YYYY-MM-DD, --to YYYY-MM-DD
  • Grouping: --by day (default) or --by model
  • Output format: --md (Markdown) or --json (JSONL), default is a plain table
  • Empty days: include zero-usage days via --empty

Examples:

  • cxusage daily
  • cxusage daily --from 2025-01-01 --to 2025-01-31 --md
  • cxusage daily --by model --json
  • Use a specific timezone: cxusage daily --tz Asia/Shanghai

Pricing

The CLI automatically fetches model pricing from the public OpenRouter models API and estimates cost based on input/output tokens per model.

  • API: https://openrouter.ai/api/v1/models
  • Fallback: when a model name is missing (unknown), cxusage attempts a fallback chain: openai/gpt-5openai/gpt-4oanthropic/claude-3.5-sonnet. The first available price is used.
  • Disable fallback with --no-fallback. With fallback disabled, unknown models show $0.00.

Notes about token counts: cxusage sums numeric fields commonly used for token counts (e.g., input_tokens, output_tokens, promptTokenCount, completionTokenCount, etc.). If older logs don’t include any of these fields, tokens will appear as zero even though events are counted. Use --by model --debug to inspect which model names are detected in your logs.

Programmatic invocation

This package exposes only a CLI. If you need a library API, please open an issue to discuss the desired interface.

Development

  • Node 18+ required
  • npm i
  • npm run build
  • node dist/cli.js --help

Contribution Guide

  • Issues: https://github.com/Effet/cxusage/issues
  • Pull Requests: welcome! Please read CONTRIBUTING.md

Release

  • CI runs on pushes/PRs to verify install and build.
  • Stable release: create a Git tag like v0.1.0 to publish to npm as latest.
    • The workflow automatically sets package.json version from the Git tag (stripping the leading v).
    • Pre-release tags (containing a hyphen, e.g. v0.2.0-rc.1) publish with the next dist-tag.
  • The release workflow requires a repository secret NPM_TOKEN with publish permissions.