omp packages

pi-agent-budget0.1.6

Pi extension: AI coding cost tracker with widget, budget limits, and CNY pricing for Chinese models.

rex_young Published 4 months ago MIT ~105 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pi-agent-budget

Pi extension: real-time AI coding cost tracking with budget limits and native CNY pricing for Chinese models.

Track token usage and costs as you chat with AI. A live widget sits below the input box showing your spending, with soft/hard budget limits to prevent surprise bills.


Features

  • ๐Ÿ‘๏ธ Real-time cost tracking โ€” every assistant message is recorded: tokens ร— pricing = cost
  • ๐Ÿ“Š Status bar widget โ€” live display below the editor: ยฅ0.16 / ยฅ10.00 โ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘ (model + cost + budget + progress bar)
  • ๐Ÿ‡จ๐Ÿ‡ณ CNY pricing for Chinese models โ€” deepseek / qwen / glm / kimi / doubao priced in RMB with auto FX conversion (1 USD โ‰ˆ 7.2 CNY)
  • ๐Ÿ›ก๏ธ Soft/hard budget limits โ€” 80% triggers a warning card, 100% blocks further input
  • ๐Ÿ“ˆ /budget dashboard โ€” overview + budget settings + pricing table + config, all in a TUI panel
  • ๐Ÿ“‹ /budget report โ€” cost breakdowns by model / tool / session

Install

pi install npm:pi-agent-budget

Depends on better-sqlite3 (native C++ addon). Requires build toolchain on first install: Xcode CLT on macOS (xcode-select --install), build-essential on Linux.


Commands

/budget                     # Dashboard (overview / budget / pricing / settings)
/budget set <amount>        # Set session budget      e.g. /budget set 2
/budget set project <amount> # Set project daily budget
/budget report [range]      # Cost report             e.g. /budget report week
/budget by <dim> [range]    # Slice by model / tool / session
/budget widget              # Widget appearance settings
/budget export              # Export cost data

Configuration

Edit via /budget config or ~/.pi/budget.json:

{
  "session": { "usd": 2.00 },
  "pricingAnchor": "followModel",
  "widget": {
    "placement": "belowEditor",
    "compact": false,
    "showModel": true,
    "showProgressBar": true,
    "showContextWindow": true
  }
}
Setting Description Default
session.usd Session budget in USD Unlimited
pricingAnchor Currency anchor: followModel / cny / usd followModel
widget.placement Widget position: belowEditor / aboveEditor belowEditor
widget.compact Minimal mode (cost only) false
softLimitRatio Soft limit threshold 0.8
hardLimitRatio Hard limit threshold 1.0

Currency handling

  • followModel (default): Chinese models (deepseek/qwen/glm etc.) display in ยฅ, Western models display in $
  • cny: Everything in RMB, budget presets use RMB amounts
  • usd: Everything in USD

Chinese models use RMB price tables internally; all costs are stored in USD for consistent cross-model aggregation, with display-time conversion.


Data storage

File Purpose
~/.pi/budget.db SQLite (costs / budgets / alerts)
~/.pi/budget.json User configuration

Development

npm run check          # TypeScript type check
pi -e ./src/index.ts   # Local dev testing

License

MIT