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

copilot-credit-usage

v0.1.0

Published

Pi extension that tracks GitHub Copilot AI credit usage by session and project.

Readme

copilot-credit-usage

A Pi extension that monitors GitHub Copilot AI credit usage.

It provides:

  • A footer/status-line indicator for Copilot usage in the current Pi session.
  • A /copilot-credits command that shows Copilot usage grouped by local project, plus a total across all projects.
  • Optional authoritative GitHub Billing API totals for the month.
  • A copilot_credit_usage tool so the assistant can answer usage questions directly.

What it measures

GitHub documents Copilot usage as GitHub AI Credits, where 1 AI credit = $0.01 USD. This extension uses that conversion in two places:

  1. Local Copilot session estimate: Pi stores provider, model, token, and cost metadata on assistant messages. The extension includes only messages whose provider, api, or model matches copilot|github-copilot. If Pi records a non-zero USD cost, the extension converts that cost to AI credits. If Pi records $0, the extension estimates cost from GitHub's published per-token Copilot model pricing and groups it by session/project.

  2. GitHub Billing API total: When credentials are available, the extension calls GitHub's AI credit usage endpoint for the signed-in user:

    GET /users/{username}/settings/billing/ai_credit/usage?year=YYYY&month=M

The GitHub API total is account-level. It does not include your local Pi working directory, so per-project breakdown comes from Copilot-filtered local Pi sessions.

The local per-project report is still an estimate because GitHub's Billing API is account-level and does not expose local working directories. The GitHub Billing API section is the authoritative account total when available.

Install

From this directory:

pi install .

Or add this package to your Pi package list if you manage packages manually.

Usage

Footer/status line

After the extension loads, the bottom status area shows current Copilot session usage:

Copilot 12.3cr · 450.2ktok

If you set a plan or allowance, it also shows the monthly allowance:

export PI_COPILOT_PLAN=pro        # pro, pro+, max
# or
export PI_COPILOT_CREDIT_ALLOWANCE=1500

Status example:

Copilot 12.3cr/1,500cr · 450.2ktok

Monthly report command

/copilot-credits
/copilot-credits 2026-06
/copilot-credits --month 2026-06 --no-github
/copilot-credits --github-only --user monalisa
/copilot-credits --json

Options:

--month YYYY-MM     Month to report. Default: current month.
--local-only        Show local Copilot session estimate only.
--github-only       Show GitHub billing API total only.
--no-github         Skip GitHub billing API lookup.
--user LOGIN        GitHub username for billing endpoint.
--json              Emit JSON details.

GitHub API authentication

For official GitHub Billing API totals, use either:

export GITHUB_TOKEN=github_pat_...

or authenticate the GitHub CLI:

gh auth login

The token must be a fine-grained token with Plan: read user permission for user billing endpoints.

If credentials are missing or the account is not billed as an individual Copilot account, the extension still shows Copilot-filtered local Pi session estimates and prints the GitHub API error.

Notes and limits

  • Local project totals are estimates based on Pi-recorded Copilot provider/model usage only.
  • When Pi records $0 for a Copilot message, the extension estimates cost from GitHub's published per-token pricing for supported Copilot models.
  • Override the local Copilot filter with PI_COPILOT_PROVIDER_PATTERN or COPILOT_PROVIDER_PATTERN if your provider name differs.
  • GitHub Billing API totals are authoritative but account-level.
  • Code completions and next-edit suggestions are not billed in Copilot AI credits for paid plans, per GitHub docs.
  • Local monthly grouping uses calendar month (YYYY-MM). Your GitHub billing cycle may start on a different day.
  • Project rows are capped at 100 to avoid huge command output.