Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 11.3.0
version: 11.8.0
run_install: false

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "22"
node-version: "24"
cache: pnpm

- name: Install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 11.3.0
version: 11.8.0
run_install: false

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "22"
node-version: "24"
cache: pnpm
registry-url: "https://registry.npmjs.org"

Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to `@pi-vault/pi-usage` are documented here.

## v0.5.0

- added `usage.json` provider toggles so you can disable live providers you do not want queried
- added dashboard insights for project, active skill, and MCP server breakdowns
- grouped insight rows by category and cap each insight section with an overflow summary to keep the dashboard readable
- improved offline session parsing to extract project names, active skills, MCP server names, and builtin tool usage more accurately
- fixed dashboard readability around usage statistics spacing and grouped insight rendering
- updated runtime requirements and tooling to Node `>=24.15.0`, refreshed dependencies, and aligned CI with Node 24 and pnpm 11.8.0

## v0.4.0

- reorganized the extension around a dedicated `UsageCore`, with the package entrypoint reduced to a thin Pi adapter
Expand Down
91 changes: 70 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

[![npm version](https://img.shields.io/npm/v/%40pi-vault%2Fpi-usage)](https://www.npmjs.com/package/@pi-vault/pi-usage)
[![Quality](https://github.com/pi-vault/pi-usage/actions/workflows/quality.yml/badge.svg?branch=master)](https://github.com/pi-vault/pi-usage/actions/workflows/quality.yml)
[![Node >= 22.19](https://img.shields.io/badge/node-%3E%3D22.19-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
[![Node >= 24.15.0](https://img.shields.io/badge/node-%3E%3D24.15.0-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
[![License: MIT](https://img.shields.io/badge/license-MIT-yellow.svg)](LICENSE)

Track Pi usage across your sessions in one dashboard. `@pi-vault/pi-usage` combines offline history with live provider snapshots so you can see costs, tokens, session activity, and rolling quota status without leaving Pi.
Track Pi usage across your sessions in one dashboard. `@pi-vault/pi-usage` combines offline history with live provider snapshots so you can review costs, tokens, session activity, current quotas, and usage insights without leaving Pi.

![Pi usage dashboard showing the aggregated usage table for the "All Time" period, current usage quota bars for OpenAI/Codex, and the keyboard navigation hints at the bottom](docs/assets/dashboard-ui.png)

Expand All @@ -26,11 +26,11 @@ Then reload Pi:
- `/usage` opens the dashboard using cached live data when available. Use it for quick inspection.
- `/usage:refresh` forces a live refresh, rescans local history, and then opens the dashboard.

## What You Get
## What the dashboard shows

### Usage statistics

The top section aggregates all local Pi session history for the selected period.
The top section aggregates local Pi session history for the selected period.

- switch between `Today`, `This Week`, `Last Week`, and `All Time`
- expand provider rows to inspect model-level usage
Expand All @@ -39,12 +39,22 @@ The top section aggregates all local Pi session history for the selected period.

### Current usage

The lower section shows live quota and balance information for providers you have already configured in Pi.
The lower section shows the supported providers. Configured providers can return live quota and balance data, while unconfigured ones may show `unavailable` or local fallback states.

- switch between `OpenAI/Codex`, `MiniMax`, `StepFun`, `OpenCode Go`, `Command Code`, and `OpenRouter`
- view rolling-window quota bars like `5h` and weekly usage
- see balance-style fields where the provider exposes them
- get inline status for live, cached, stale, or fallback data
- get inline status for live, cached, stale, local, or unavailable data

### Insights

Press `v` to toggle insights for the selected period.

- review the most expensive projects in your local session history
- see active skill and MCP server breakdowns when that data is present
- keep long sections readable through grouped insight categories and capped lists with overflow summaries

## How to use it

### Keyboard shortcuts

Expand All @@ -55,11 +65,54 @@ The lower section shows live quota and balance information for providers you hav
- `[v]` toggle insights
- `[q/Esc]` close the dashboard

## Provider Setup
## Configuration

### `usage.json`

Create `$PI_CODING_AGENT_DIR/extensions/usage.json` to disable specific live providers.

Default behavior:
- if the file is missing, all providers stay enabled
- if the file is `{}`, all providers stay enabled
- if a provider is omitted, that provider stays enabled
- if the JSON is malformed, `@pi-vault/pi-usage` ignores it and falls back to the default behavior

Default example:

```json
{}
```

Explicit all-providers-enabled example:

```json
{
"providers": {
"openai-codex": { "enabled": true },
"minimax": { "enabled": true },
"stepfun": { "enabled": true },
"opencode-go": { "enabled": true },
"command-code": { "enabled": true },
"openrouter": { "enabled": true }
}
}
```

Offline history works without extra setup. Live provider cards appear only for providers you have already configured.
Disable MiniMax only:

```json
{
"providers": {
"minimax": { "enabled": false }
}
}
```

### OpenAI/Codex
### Provider setup

Offline history works without extra setup. Provider cards appear for every supported live provider unless you disable them in `usage.json`. Providers you configure can return live data; others may show `unavailable` or local fallback states.

#### OpenAI/Codex

Pi usage can reuse existing Pi or Codex auth. Optional overrides:

Expand All @@ -70,7 +123,7 @@ Pi usage can reuse existing Pi or Codex auth. Optional overrides:
- `OPENAI_CODEX_ACCOUNT_ID`
- `CHATGPT_ACCOUNT_ID`

### MiniMax
#### MiniMax

Set one of:

Expand All @@ -81,14 +134,14 @@ Optional override:

- `MINIMAX_API_HOST`

### StepFun
#### StepFun

Set one of:

- `STEPFUN_TOKEN`
- `STEPFUN_USERNAME` and `STEPFUN_PASSWORD`

### OpenCode Go
#### OpenCode Go

Set:

Expand All @@ -97,13 +150,13 @@ Set:

`OPENCODE_GO_WORKSPACE_ID` accepts either the raw `wrk_...` id or the full workspace URL.

### Command Code
#### Command Code

Set:

- `COMMAND_CODE_COOKIE_HEADER`

### OpenRouter
#### OpenRouter

Set:

Expand All @@ -115,14 +168,10 @@ Optional overrides:
- `OPENROUTER_X_TITLE`
- `OPENROUTER_HTTP_REFERER`

## Development
## Changelog

```bash
pnpm install
pnpm check
pnpm pack --dry-run
```
See [`CHANGELOG.md`](CHANGELOG.md) for release-by-release notes.

## License

MIT
MIT — see [`LICENSE`](LICENSE).
28 changes: 21 additions & 7 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.16/schema.json",
"linter": {
"$schema": "https://biomejs.dev/schemas/2.5.0/schema.json",
"vcs": {
"enabled": true,
"rules": {
"recommended": true
}
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"includes": ["src/**/*.ts", "tests/**/*.ts", "!**/node_modules"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100
},
"linter": {
"enabled": true,
"rules": {
"preset": "recommended"
}
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"semicolons": "always"
}
},
"files": {
"includes": ["src/**/*.ts", "tests/**/*.ts", "!**/node_modules"]
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
Loading
Loading