[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-81166":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":13,"stars7d":15,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":18,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":21,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":16,"starSnapshotCount":16,"syncStatus":13,"lastSyncTime":29,"discoverSource":30},81166,"copilot-cli-cost","DamianEdwards\u002Fcopilot-cli-cost","DamianEdwards","Copilot CLI extension that shows real-time estimated session cost.","",null,"JavaScript",38,2,1,5,0,9,6,48.83,"MIT License",false,"main",true,[25],"copilot-cli","2026-06-12 04:01:32","# Copilot CLI Cost\n\nCopilot CLI Cost adds estimated session-cost reporting to GitHub Copilot CLI.\n\nIt estimates costs across both Copilot billing models:\n\n- Premium request units\n- Usage-based billing with GitHub AI Credits\n\nThe calculator stores canonical cost in USD and converts to a selected display currency with cached exchange rates from Frankfurter or an explicit exchange-rate override.\n\n![Copilot Cost panel showing session estimates and token bucket breakdown](docs\u002Fsession-cost-panel.png)\n\n## Features\n\n- `\u002Fcost` command for active-session estimates\n- `\u002Fcost session \u003Csession-id>` for completed local sessions\n- Native cost panel with token bucket breakdowns\n- What-if subscription comparison for Copilot Free, Pro, Pro+, Max, Business, Enterprise, and Student\n- Display currency selector backed by cached Frankfurter USD exchange rates\n- Statusline cost segment with optional passthrough to another statusline\n- Standalone calculator CLI for sample data, JSON files, completed session events, and live snapshots\n- USD-first cost model with optional display currency conversion\n\n## Install\n\nInstall by executing the install script for your platform.\n\nWindows PowerShell (`install.ps1`):\n\n```powershell\nirm https:\u002F\u002Fraw.githubusercontent.com\u002FDamianEdwards\u002Fcopilot-cli-cost\u002Fmain\u002Finstall.ps1 | iex\n```\n\nmacOS\u002FLinux (`install.sh`):\n\n```bash\nbash -c \"$(curl -fsSL https:\u002F\u002Fraw.githubusercontent.com\u002FDamianEdwards\u002Fcopilot-cli-cost\u002Fmain\u002Finstall.sh)\"\n```\n\nThe remote scripts run in isolation and fetch their helper from the same raw-content base URL before configuring Copilot. To run the installer script from a checkout instead:\n\n```powershell\n.\\install.ps1\n```\n\n```bash\n.\u002Finstall.sh\n```\n\nThe installer:\n\n- On Copilot CLI 1.0.56-0 or newer, registers this repository's marketplace and installs or updates `copilot-cli-cost@copilot-cli-cost-marketplace`. Older Copilot CLI versions use the direct repository install format.\n- Downloads the installer helper from the raw-content base URL.\n- Installs the user-scoped extension shim for `\u002Fcost` and the panel.\n- Enables the Copilot experimental flags needed for extensions and the status line.\n- Configures a stable user-scoped statusline launcher under `~\u002F.copilot\u002Fcopilot-cli-cost\u002F`.\n\nIf you already have a Copilot status line configured, the installer prompts you to replace it, decorate it with the Copilot Cost status line using passthrough mode, or skip statusline configuration. Before changing existing settings that would otherwise be overwritten, it prompts and writes a timestamped `settings.json.bak-*` backup.\n\nInstaller options:\n\n| Option | Description |\n| --- | --- |\n| `--plugin-source \u003Csource>` | Use a fork or alternate plugin source. On Copilot CLI 1.0.56-0 or newer, this must be a marketplace source. |\n| `--marketplace-name \u003Cname>` | Use a custom marketplace name when the marketplace metadata differs from `copilot-cli-cost-marketplace`. |\n| `--plugin-name \u003Cname>` | Use a custom plugin name when the marketplace metadata differs from `copilot-cli-cost`. |\n| `--copilot-home \u003Cpath>` | Use a custom Copilot home directory instead of `~\u002F.copilot`; useful for isolated verification. |\n| `--skip-statusline` | Install the plugin and extension shim without configuring `statusLine`. |\n| `--yes` | Accept installer prompts. Existing status lines are decorated, not replaced. |\n\nSet `COPILOT_COST_PLUGIN_SOURCE` or pass `--plugin-source \u003Csource>` to install from a fork or alternate plugin source. On Copilot CLI 1.0.56-0 or newer, this source is registered as a plugin marketplace; set `COPILOT_COST_MARKETPLACE_NAME` \u002F `--marketplace-name` and `COPILOT_COST_PLUGIN_NAME` \u002F `--plugin-name` if your fork changes those marketplace identifiers. Set `COPILOT_COST_INSTALL_BASE_URL` or pass `--install-base-url \u003Curl>` when running installer scripts from an alternate raw-content location. Set `COPILOT_HOME` or pass `--copilot-home \u003Cpath>` to isolate installer writes.\n\nIf `\u002Fcost` is not available in an active Copilot CLI session after installing, run `\u002Fextensions` and enable `copilot-cli-cost` under **User**.\n\nWhen you run `copilot` inside this repository, Copilot CLI's extension resolver prefers the repo-local `.github\u002Fextensions\u002Fcopilot-cli-cost` extension over the user-installed extension. The user-scoped shim intentionally stays pointed at the installed plugin copy for sessions outside the repository.\n\n### Manual install\n\nThe scripts perform these steps. To do them manually, first install the plugin:\n\n```shell\ncopilot plugin marketplace add DamianEdwards\u002Fcopilot-cli-cost # if not already registered\ncopilot plugin install copilot-cli-cost@copilot-cli-cost-marketplace\n```\n\nThen run the extension shim installer from the installed plugin.\n\nPowerShell terminal:\n\n```powershell\n$installer = Get-ChildItem \"$env:USERPROFILE\\.copilot\\installed-plugins\" -Directory -Recurse |\n  Where-Object { Test-Path (Join-Path $_.FullName \"scripts\\install-extension-shim.mjs\") } |\n  Select-Object -First 1 -ExpandProperty FullName\n\nif (-not $installer) {\n  throw \"Could not find installed copilot-cli-cost plugin.\"\n}\n\nnode (Join-Path $installer \"scripts\\install-extension-shim.mjs\")\n```\n\nBash terminal:\n\n```bash\ninstaller=\"$(find \"$HOME\u002F.copilot\u002Finstalled-plugins\" -type f -path '*\u002Fscripts\u002Finstall-extension-shim.mjs' | head -n 1)\"\nif [ -z \"$installer\" ]; then\n  echo \"Could not find installed copilot-cli-cost plugin.\" >&2\n  exit 1\nfi\nnode \"$installer\"\n```\n\nConfigure `~\u002F.copilot\u002Fsettings.json`. Do not put `statusLine` in `config.json`; that file is managed by Copilot CLI and user settings may be moved or removed during startup. Use your machine's statusline launcher path:\n\n```jsonc\n{\n  \"experimental\": true,\n  \"experimental_flags\": [\"EXTENSIONS\", \"STATUS_LINE\"],\n  \"statusLine\": {\n    \"type\": \"command\",\n    \"command\": \"C:\\\\Users\\\\alex\\\\.copilot\\\\copilot-cli-cost\\\\statusline.cmd\"\n  },\n  \"footer\": {\n    \"showCustom\": true\n  }\n}\n```\n\nmacOS\u002FLinux:\n\n```jsonc\n{\n  \"experimental\": true,\n  \"experimental_flags\": [\"EXTENSIONS\", \"STATUS_LINE\"],\n  \"statusLine\": {\n    \"type\": \"command\",\n    \"command\": \"sh \\\"\u002FUsers\u002Falex\u002F.copilot\u002Fcopilot-cli-cost\u002Fstatusline.sh\\\"\"\n  },\n  \"footer\": {\n    \"showCustom\": true\n  }\n}\n```\n\nThe statusline bridge prints a compact segment:\n\n```text\n💸 Cost ~$0.3059 (30.6 cr, 2% pro) · 7.5 PRU, 2.5% pro · last 42K in\u002F3K out\n```\n\nWhen the SDK extension can detect your current Copilot subscription, the statusline uses that cached plan for allowance percentages. `COPILOT_COST_PLAN` can still override the plan explicitly. If neither is available, the statusline falls back to `assumed pro` so the percentage is not presented as a detected plan.\n\nThe generated statusline launcher is workspace-aware because statusline settings point at a fixed command and do not use the extension resolver. When Copilot sends a statusline payload with `workspace.current_dir` or `cwd` inside a `copilot-cli-cost` checkout or worktree, the launcher runs that checkout's `src\u002Fcli\u002Fstatusline.js`; otherwise it falls back to the installed plugin copy. Set `COPILOT_COST_STATUSLINE_DISABLE_WORKSPACE=true` to always use the installed copy.\n\n## Use\n\n```text\n\u002Fcost\n\u002Fcost help\n\u002Fcost version\n\u002Fcost update\n\u002Fcost panel on\n\u002Fcost panel off\n\u002Fcost panel refresh\n\u002Fcost session \u003Csession-id>\n\u002Fcost live-session \u003Csession-id>\n\u002Fcost --plan pro|pro-plus|max|business|enterprise\n\u002Fcost --billing-model usage-based|premium-requests\n\u002Fcost --currency USD|EUR|GBP|CAD|AUD|JPY|CHF\n```\n\n`\u002Fcost` is handled by extension JavaScript. It does not ask the model to calculate the result.\n\nUse `\u002Fcost update` to force the extension to re-detect your current Copilot subscription and rewrite the shared cache used by the statusline. If the host exposes a statusline refresh hook, the command also requests an immediate refresh; otherwise the updated plan appears on the next normal statusline refresh.\n\nThe panel opens a native window:\n\n```text\n\u002Fcost panel on\n```\n\nThe panel shows:\n\n- Usage-based estimate\n- Premium-request estimate\n- Percentage of the selected plan's allowance used by the session\n- Searchable session picker for current, cached live, and completed sessions\n- Selected session ID and data source\n- Current or assumed subscription\n- Loaded extension version\n- What-if subscription selector\n- Display currency selector\n- Per-model token bucket breakdown\n- Collapsed raw JSON payload\n\n## Data sources\n\nThe SDK extension reads active-session metrics from Copilot CLI's session RPC API:\n\n```js\nawait session.rpc.usage.getMetrics()\n```\n\nThat response includes:\n\n- Per-model request counts\n- Premium request cost\n- Copilot-reported AI credit usage (`totalNanoAiu`) when available\n- Input, cached input, cache write, output, and reasoning token buckets\n- Active model\n- Last-call input\u002Foutput token counts\n- API duration\n- Code-change counters\n\nThe extension normalizes each read and writes a live snapshot to the platform cache folder:\n\n```text\nWindows: %LOCALAPPDATA%\\copilot-cli-cost\\live-sessions\nmacOS:   ~\u002FLibrary\u002FCaches\u002Fcopilot-cli-cost\u002Flive-sessions\nLinux:   ${XDG_CACHE_HOME:-~\u002F.cache}\u002Fcopilot-cli-cost\u002Flive-sessions\n```\n\nCompleted local sessions can be read from:\n\n```text\nWindows: %USERPROFILE%\\.copilot\\session-state\\\u003Csession-id>\\events.jsonl\nmacOS\u002FLinux: ~\u002F.copilot\u002Fsession-state\u002F\u003Csession-id>\u002Fevents.jsonl\n```\n\nThe parser reads the latest metrics event and extracts Copilot-reported AI credit usage, per-model token buckets, and total premium request units.\n\nFor usage-based billing, Copilot-reported AI credits are preferred because they match the CLI's own **AI Credits** counter. Token-rate estimates are retained as a fallback when Copilot does not provide AI credit totals, and the panel labels which method was used.\n\nWhen statusline payloads include `transcript_path`, live snapshots are also grouped into a logical session. This keeps each resumed Copilot CLI instance as its own snapshot while letting `\u002Fcost`, the statusline segment, and the panel show the total cost across resumed instances. If premium request counters look cumulative across a resume, the aggregate uses the latest cumulative value instead of summing and double-counting it.\n\n## Statusline passthrough\n\nSet `COPILOT_COST_STATUSLINE_PASSTHROUGH` to call another statusline command. The default passthrough mode enriches the stdin JSON with `copilot_cost` and lets the inner statusline render all output.\n\nPowerShell:\n\n```powershell\n$env:COPILOT_COST_STATUSLINE_PASSTHROUGH = \"C:\\Users\\alex\\.copilot\\statusline\\statusline.cmd\"\ncopilot\n```\n\nmacOS\u002FLinux:\n\n```sh\nexport COPILOT_COST_STATUSLINE_PASSTHROUGH=\"$HOME\u002F.copilot\u002Fstatusline\u002Fstatusline.sh\"\ncopilot\n```\n\nThe enriched payload includes:\n\n```jsonc\n{\n  \"copilot_cost\": {\n    \"schema_version\": 1,\n    \"status_line\": \"💸 Cost ~$0.3059 (30.6 cr, 2% pro) · 7.5 PRU, 2.5% pro · last 42K in\u002F3K out\",\n    \"aggregate_usage_based\": {\n      \"billingModel\": \"usage-based\",\n      \"totalUsd\": 0.305869,\n      \"aiCredits\": 30.5869,\n      \"creditCalculationSource\": \"copilot-cli-session-aiu\"\n    },\n    \"aggregate_premium_requests\": {\n      \"billingModel\": \"premium-requests\",\n      \"totalPremiumRequests\": 7.5,\n      \"overageEquivalentUsd\": 0.3\n    },\n    \"usage_based\": {\n      \"billingModel\": \"usage-based\",\n      \"totalUsd\": 0.305869,\n      \"aiCredits\": 30.5869,\n      \"creditCalculationSource\": \"copilot-cli-session-aiu\"\n    },\n    \"premium_requests\": {\n      \"billingModel\": \"premium-requests\",\n      \"totalPremiumRequests\": 7.5,\n      \"overageEquivalentUsd\": 0.3\n    }\n  }\n}\n```\n\nSet decorate mode to combine this bridge's output with the passthrough output:\n\nPowerShell:\n\n```powershell\n$env:COPILOT_COST_STATUSLINE_MODE = \"decorate\"\n$env:COPILOT_COST_STATUSLINE_POSITION = \"right\"\ncopilot\n```\n\nmacOS\u002FLinux:\n\n```sh\nexport COPILOT_COST_STATUSLINE_MODE=decorate\nexport COPILOT_COST_STATUSLINE_POSITION=right\ncopilot\n```\n\nStatusline environment variables:\n\n| Variable | Default | Meaning |\n| --- | --- | --- |\n| `COPILOT_COST_STATUSLINE_PASSTHROUGH` | unset | Command to invoke with enriched statusline JSON on stdin. |\n| `COPILOT_COST_STATUSLINE_MODE` | `passthrough` when passthrough is set, otherwise `standalone` | `passthrough`, `decorate`, or `standalone`. |\n| `COPILOT_COST_STATUSLINE_POSITION` | `right` | In `decorate` mode: `right`, `left`, `replace`, or `passthrough`. |\n| `COPILOT_COST_STATUSLINE_SEPARATOR` | ` · ` | In `decorate` mode: text between the passthrough output and cost segment. |\n| `COPILOT_COST_STATUSLINE_PASSTHROUGH_TIMEOUT_MS` | `1000` | Maximum time to wait for the passthrough command. |\n| `COPILOT_COST_STATUSLINE_HIDE_COST` | `false` | Cache live data but do not print the cost segment. |\n| `COPILOT_COST_STATUSLINE_COLOR` | `true` | Set to `false` to disable ANSI color in the rendered cost segment. |\n\n## Configuration\n\nSet these environment variables before launching `copilot`:\n\nPowerShell:\n\n```powershell\n$env:COPILOT_COST_PLAN = \"enterprise\"\n$env:COPILOT_COST_CURRENCY = \"EUR\"\n$env:COPILOT_COST_PROMOTIONAL_ALLOWANCE = \"true\"\ncopilot\n```\n\nmacOS\u002FLinux:\n\n```sh\nexport COPILOT_COST_PLAN=enterprise\nexport COPILOT_COST_CURRENCY=EUR\nexport COPILOT_COST_PROMOTIONAL_ALLOWANCE=true\ncopilot\n```\n\n| Variable | Meaning |\n| --- | --- |\n| `COPILOT_COST_PLAN` | Default plan when subscription detection is unavailable. |\n| `COPILOT_COST_CURRENCY` | Display currency code. USD is canonical. Non-USD values use Frankfurter unless an override is configured. |\n| `COPILOT_COST_EXCHANGE_RATE` | USD-to-display-currency exchange rate override for `COPILOT_COST_CURRENCY`. |\n| `COPILOT_COST_FX_\u003CCODE>` | USD-to-currency exchange rate override for a specific currency, for example `COPILOT_COST_FX_EUR=0.9`. |\n| `COPILOT_COST_FX_CACHE` | Exchange-rate cache folder. Defaults to `%LOCALAPPDATA%\\copilot-cli-cost\\fx-rates` on Windows, `~\u002FLibrary\u002FCaches\u002Fcopilot-cli-cost\u002Ffx-rates` on macOS, or `${XDG_CACHE_HOME:-~\u002F.cache}\u002Fcopilot-cli-cost\u002Ffx-rates` on Linux. |\n| `COPILOT_COST_SUBSCRIPTION_CACHE` | Current subscription cache file used by the statusline. Defaults to `current-subscription.json` under the platform cache root. |\n| `COPILOT_COST_PROMOTIONAL_ALLOWANCE` | Use promotional Business\u002FEnterprise AI Credit allowances. |\n| `COPILOT_COST_BILL_REASONING_TOKENS` | Set to `true` to include reasoning tokens as output-priced cost. By default they are shown as informational only. |\n\nThe live session cache can be overridden with `COPILOT_COST_LIVE_STORE`. By default it uses the same platform cache root as `COPILOT_COST_FX_CACHE`.\n\n### Native panel notes\n\nThe `\u002Fcost` command and calculator are pure Node.js. The native panel uses `@webviewjs\u002Fwebview`, which installs a platform-specific optional package for Windows, macOS, and Linux x64. The extension bootstrap runs `npm install --include=optional --no-audit --no-fund` when those panel dependencies are missing.\n\nOn Linux, the native webview package still depends on system GTK\u002FWebKit libraries supplied by your distribution, such as WebKitGTK and GTK. If `\u002Fcost panel on` fails to open, install your distribution's WebKitGTK\u002FGTK runtime packages and reload the extension.\n\n## Standalone calculator\n\nClone the repository when you want to run tests or use the calculator directly:\n\n```powershell\ngit clone https:\u002F\u002Fgithub.com\u002FDamianEdwards\u002Fcopilot-cli-cost.git\ncd copilot-cli-cost\nnpm test\n```\n\nExamples:\n\n```powershell\nnpm run cost -- --sample\nnpm run cost -- --sample --billing-model premium-requests --plan pro-plus\nnpm run cost -- --premium-requests 12.5 --plan pro --remaining-premium-requests 10\nnpm run cost -- --session \u003Csession-id> --plan pro\nnpm run cost -- --live --plan max\nnpm run cost -- --sample --currency EUR\nnpm run cost -- --sample --currency EUR --exchange-rate 0.9\n```\n\nUsage JSON shape:\n\n```json\n{\n  \"sessionId\": \"sample-session-001\",\n  \"plan\": \"pro\",\n  \"currency\": \"USD\",\n  \"modelUsage\": [\n    {\n      \"model\": \"gpt-5.5\",\n      \"requests\": 3,\n      \"inputTokens\": 600000,\n      \"cachedInputTokens\": 420000,\n      \"cacheWriteTokens\": 0,\n      \"outputTokens\": 36000,\n      \"reasoningTokens\": 1200\n    }\n  ]\n}\n```\n\n## How estimates are calculated\n\nUsage-based billing uses published per-1M-token rates. `inputTokens` is the total input token count from Copilot metrics, and `cachedInputTokens` is the cached subset, so only uncached input tokens use the regular input rate:\n\n```text\nuncachedInputTokens = max(inputTokens - cachedInputTokens, 0)\ninputUsd            = uncachedInputTokens \u002F 1,000,000 * inputPerMillionUsd\ncachedInputUsd      = cachedInputTokens   \u002F 1,000,000 * cachedInputPerMillionUsd\ncacheWriteUsd       = cacheWriteTokens    \u002F 1,000,000 * cacheWritePerMillionUsd\noutputUsd           = outputTokens        \u002F 1,000,000 * outputPerMillionUsd\nreasoningUsd        = 0 unless COPILOT_COST_BILL_REASONING_TOKENS=true\naiCredits           = totalUsd \u002F 0.01\nincludedAiCredits   = baseAiCredits + current flexAiCredits\n```\n\nPremium-request billing uses Copilot-reported premium request units when present. If only model request counts are available, it applies the configured model multiplier table.\n\nFor individual usage-based billing, Pro and Pro+ include a fixed base credit amount plus a variable flex allotment. The calculator reports the current published total as included credits and preserves the base\u002Fflex split in machine-readable output. Copilot Max is usage-based only in this calculator; premium-request support remains for existing request-based plans.\n\nNon-USD currency values are display estimates. USD remains canonical because GitHub model rates and AI Credits are documented in USD. Non-USD `\u002Fcost` and panel requests fetch USD exchange rates from [Frankfurter](https:\u002F\u002Fwww.frankfurter.dev\u002F) and cache them for reuse; explicit environment or CLI exchange-rate overrides take precedence.\n\n## Limitations\n\n- Rate tables are hardcoded in `src\u002Fcore\u002Frates.js` and should be checked against GitHub billing docs.\n- Reasoning tokens are shown as informational only unless `COPILOT_COST_BILL_REASONING_TOKENS=true`, because GitHub's published Copilot pricing table does not list a separate reasoning-token bucket.\n- Business and Enterprise included credits are pooled at the billing entity level, so a session estimate is not always incremental billable spend.\n- Taxes, regional billing rules, and GitHub billing-account currency handling are not modeled.\n- Statusline per-model attribution depends on successive cumulative payloads and the active model at each refresh. Resumed-session aggregation depends on `transcript_path`; without it, live snapshots fall back to the current `session_id` and cannot be linked to previous instances.\n\n## License\n\nMIT. See [LICENSE](LICENSE).\n","Copilot CLI Cost 是一个扩展程序，用于在GitHub Copilot CLI中显示实时估算的会话成本。它支持两种计费模式：高级请求单位和基于使用的计费（使用GitHub AI Credits）。该工具通过存储以美元为单位的标准成本，并利用Frankfurter提供的缓存汇率或用户指定的汇率进行货币转换来实现成本估算。主要功能包括针对活跃及已完成会话的成本估计、原生成本面板展示、订阅方案比较等。适用于需要监控和管理GitHub Copilot使用成本的开发者或团队，在确保透明度的同时帮助合理规划预算。","2026-06-11 04:03:46","CREATED_QUERY"]