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

mghc

v1.1.1

Published

GitHub Copilot Account Manager CLI — manage multiple Copilot accounts, check quotas, and switch between them

Readme

mghc — GitHub Copilot Account Manager

A CLI tool for managing multiple GitHub Copilot accounts. Switch between personal, work, and enterprise accounts, monitor quotas, and inspect available models — all from a single interactive menu.

Installation

npm install -g mghc

Requires Node.js 18 or later.

Usage

mghc

The tool opens an interactive menu. On startup it automatically refreshes the quota for every saved account, then shows you the account table and menu.

◆  GitHub Copilot Account Manager
│
◇  Quotas updated
│
┌  Accounts ─────────────────────────────────────────────────────────────
│  Name        Status  Last Used  Premium      Chat         Comp
│  ──────────  ──────  ─────────  ───────────  ───────────  ────────────
│  gh-alice    active  today      450/500      ♾️           ♾️
│  work-bob    —       3d ago     80/500       ♾️           ♾️
└────────────────────────────────────────────────────────────────────────

◆  What would you like to do?
●  Add account (OAuth)         GitHub device flow
○  Add account (manual)        Paste token directly
○  Import from auth.json       Auto-detect from OpenCode
○  Check models                Available & disabled models
○  Refresh identity & quota    Update usernames, orgs & quotas
○  Switch account
○  Remove account
○  Remove all accounts
○  Exit

Use ↑ / ↓ to navigate, Enter to select, Ctrl+C to cancel at any prompt.

Menu Options

Add account (OAuth)

Authenticate via GitHub's device flow. You will be given a URL and a short code — open the URL in your browser, enter the code, and mghc completes the login automatically.

Supports both github.com and GitHub Enterprise Server (you'll be asked for your enterprise hostname).

Add account (manual)

Paste an existing OAuth refresh token (e.g. gho_...) directly. Useful when you already have a token from another tool.

Import from auth.json

Reads tokens from ~/.local/share/opencode/auth.json (or the path you specify) and merges any Copilot entries into the account store. Existing accounts with matching tokens are updated in-place — no duplicates are created.

Check models

Queries the Copilot API for each account and shows which models are available and which are disabled by your plan or policy.

Refresh identity & quota

Re-fetches the GitHub username, email, and organisation membership for every account, renames entries to match, and refreshes quota usage.

Switch account

Picks the active account from a list. Switching writes the chosen account's token to ~/.local/share/opencode/auth.json so that opencode (and compatible tools) pick it up immediately.

Remove account / Remove all accounts

Removes one or all accounts from the store. Removing the active account automatically promotes the next available account.

Account Storage

Accounts are stored at:

${XDG_CONFIG_HOME:-~/.config}/mghc/accounts.json

The file is written with mode 0600 (owner read/write only). Existing account data at ~/.config/opencode/copilot-x.json is migrated automatically on first run and is not used afterward.

When you switch accounts, mghc synchronizes the selected account to these runtime auth targets:

$XDG_DATA_HOME/opencode/auth.json          (default: ~/.local/share/opencode/auth.json)

This file is the shared credential store read by opencode and compatible tools.

PI uses a different GitHub OAuth application from OpenCode, so its ghu_ token cannot be derived from an OpenCode gho_ token. To enable PI switching, use Link PI account (OAuth) once for each account. It opens GitHub's device authorization flow and stores PI's native OAuth credential alongside that account. Link current PI OAuth is available when you have already signed in through pi's /login. When switching, mghc updates PI's credentials at:

${PI_CODING_AGENT_DIR:-~/.pi/agent}/auth.json

PI sessions using Copilot GPT models retain connection-scoped response IDs. Start a new PI session after switching accounts; existing GPT sessions cannot continue safely on a different Copilot account.

Quota Display

The account table shows three quota buckets:

| Column | What it measures | |----------|-----------------------------------| | Premium | Premium model interactions | | Chat | Chat requests | | Comp | Code completion requests |

Remaining quota is colour-coded: green (> 50 %), yellow (20–50 %), red (< 20 %), ♾️ (unlimited).

Environment Variables

| Variable | Purpose | |----------------------------------|--------------------------------------------------| | XDG_CONFIG_HOME | Override config directory (default ~/.config) | | XDG_DATA_HOME | Override data directory (default ~/.local/share) | | PI_CODING_AGENT_DIR | Override PI auth directory (default ~/.pi/agent) | | OPENCODE_COPILOT_RETRY_DEBUG=1 | Enable verbose network-retry debug logging | | OPENCODE_COPILOT_RETRY_DEBUG_FILE | Path for the debug log file |

Development

git clone https://github.com/caravanglory/my-github-copilot.git
cd my-github-copilot
bun install
bun run build      # compile → dist/index.js
bun run test       # 46 unit tests
bun run typecheck  # TypeScript check

To test the CLI locally before publishing:

npm link           # makes `mghc` available globally from this directory
mghc
npm unlink -g mghc  # remove when done

License

MIT