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-codex-quota

v1.0.1

Published

OpenCode plugin to display ChatGPT Plus/Pro Codex subscription quota in the terminal

Readme

opencode-codex-quota

npm MIT License GitHub Issues Node.js SonarQube Cloud

Quality Gate Status Reliability Rating Security Rating Maintainability Rating

OpenCode plugin that displays your ChatGPT Plus/Pro Codex subscription quota directly in the terminal — no browser needed.

Features

  • Single /codex_quota command — a convenient wrapper that asks OpenCode to call the quota tool
  • Rich Markdown output — themed headers, progress bars, tables rendered by OpenCode TUI
  • 5h + Weekly windows — primary 5-hour and secondary weekly usage with local reset clocks
  • Code review quota — shown when applicable to your plan
  • Credits & spend control — balance, approximate message counts, spending status
  • Advisory + warning banners — pacing notes at 50%+, stronger warnings at 80%+, critical at 100%
  • Two display modes — full for /codex_quota, compact for agent/tool usage or /codex_quota compact
  • Auth from OpenCode — reads your existing opencode auth login credentials, no extra setup

Screenshot

OpenCode TUI screenshot showing the Codex quota report

Example full-mode output rendered in the OpenCode TUI.

Install

Via config file (recommended)

Add to your OpenCode config (~/.config/opencode/config.json or project opencode.json):

{
  "plugin": ["opencode-codex-quota"]
}

From source (development)

git clone https://github.com/guyinwonder168/opencode-codex-quota.git
cd opencode-codex-quota
npm install
npm run build

Then point OpenCode at your local package directory:

{
  "plugin": ["./path/to/opencode-codex-quota"]
}

This project is packaged as an npm/path plugin. OpenCode also supports raw local plugin files placed directly in .opencode/plugins/ or ~/.config/opencode/plugins/, but that is a different layout from this repository.

How /codex_quota works

In current OpenCode plugin APIs:

  • the codex_quota tool is exposed to the agent/tool loop
  • the /codex_quota slash command is a wrapper prompt that tells OpenCode to call that tool

That means /codex_quota is convenient and reliable, but it is still LLM-mediated, not a direct no-LLM syscall.

Usage

Wrapper Command (Full Mode)

/codex_quota

Shows complete quota details: plan type, primary 5h window, weekly window, code review quota, credits, spend control, and promotional info.

Under the hood, the wrapper prompt asks OpenCode to call the codex_quota tool and present the result.

You can also pass compact to the slash command when you want the shorter table:

/codex_quota compact

Example output:

# OpenAI Codex Subscription

**Plan:** Plus | **Account:** [email protected]

---

## Quota Limits

| Window | Usage | Progress | Resets At |
|--------|-------|----------|------------|
| **Primary (5h)** | 51% | `██████░░░░░░` 51% | 04:06:26 |
| **Weekly** | 40% | `█████░░░░░░░` 40% | 05:46:54 on 9 Apr |

---

> ⚠️ Primary (5h) at 51% — consider pacing your usage.

---

## Code Review Quota

| Window | Usage | Progress | Resets At |
|--------|-------|----------|------------|
| **Weekly** | 0% | `░░░░░░░░░░░░` 0% | 02:37:12 on 11 Apr |

---

## Spend Control

**Status:** ✅ Within limit

---

*Updated: 2026-03-29T12:00:00.000Z*

Agent / Tool Call (Compact Mode)

The underlying tool supports mode=compact for concise output when called by an AI agent:

codex_quota(mode="compact")

Example output:

### Codex Quota — Plus

| Window | Usage | Progress | Resets At |
|--------|-------|----------|------------|
| 5h | 51% | `██████░░░░░░` | 04:06:26 |
| Weekly | 40% | `█████░░░░░░░` | 05:46:54 on 9 Apr |

**Status**: ✅ Within limits

Conditional Sections

Some sections appear only when relevant:

| Section | When Shown | |---------|-----------| | Code Review Quota | When your plan includes code review limits | | Credits | When you have credits or unlimited balance | | Promotional | When promotional quota is active | | Warning banners | When any window is 80–99% or 100% | | Advisory notes | When any window is 50–79% |

Requirements

  • OpenCode installed and configured
  • ChatGPT Plus or Pro subscription with Codex access
  • OAuth credentials via opencode auth login (select ChatGPT Plus/Pro)

Error Handling

The plugin shows user-friendly Markdown messages for common issues:

| Error | Message | |-------|---------| | Missing auth | Setup instructions with opencode auth login steps | | Wrong auth type | OAuth setup instructions | | Empty token | Re-auth instruction | | Token expired | Re-auth instruction | | Network error | Connection check guidance | | API 401/403 | Token refresh instruction | | API 429 | Rate limited — wait a few seconds | | API 5xx | Service unavailable — try later | | Unexpected response | Partial data with update notice |

Architecture

opencode-codex-quota/
├── src/
│   ├── index.ts              # Plugin entry point, tool definition
│   ├── types.ts              # All TypeScript interfaces
│   ├── services/
│   │   ├── auth-reader.ts    # Read auth.json → parse JWT → extract credentials
│   │   └── api-client.ts     # Call wham/usage → typed QuotaResponse
│   └── formatter/
│       ├── markdown.ts       # QuotaResponse → Markdown string
│       └── errors.ts         # Error codes → Markdown error messages
└── tests/
    ├── auth-reader.test.ts
    ├── api-client.test.ts
    ├── markdown.test.ts
    ├── errors.test.ts
    ├── index.test.ts
    └── integration.test.ts

Data flow:

/codex_quota
  → wrapper prompt tells OpenCode to call tool.codex_quota
  → AuthReader: auth.json → JWT → { token, accountId, email }
  → ApiClient: GET wham/usage → QuotaResponse
  → Formatter: QuotaResponse + mode → Markdown string
  → OpenCode TUI renders via Glamour

Development

Prerequisites

Setup

git clone https://github.com/guyinwonder168/opencode-codex-quota.git
cd opencode-codex-quota
npm install

Commands

npm run build         # TypeScript → dist/
npm run typecheck     # Type checking only
npm test              # Run all tests
npm run test:coverage # Run tests with coverage
npm run lint          # Check code style
npm run lint:fix      # Fix code style issues

Testing

Tests use vitest with the Arrange-Act-Assert pattern. Mocks for fetch and fs are set up per test.

npm test                                   # All tests
npm test -- tests/auth-reader.test.ts      # Specific file
npm run test:coverage                      # With coverage report

Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

License

MIT © 2026 guyinwonder168

Acknowledgments