usage

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateCost

func CalculateCost(tokens TokenUsage, model string) float64

func ContextPctColor added in v0.7.0

func ContextPctColor(pct float64) lipgloss.Color

ContextPctColor returns a Nord-palette color based on context fill percentage. <60% green, 60-80% yellow, 80%+ red.

func ContextWindowPct added in v0.7.0

func ContextWindowPct(lastInput int64, capacity int64) float64

ContextWindowPct computes how full the context window is based on the last API call's input tokens and the model's capacity.

func ModelContextCapacity added in v0.7.0

func ModelContextCapacity(model string) int64

ModelContextCapacity returns the context window size for a given model string. Uses prefix matching after stripping the "claude-" prefix and date suffix.

func RenderContextGauge added in v0.7.0

func RenderContextGauge(pct float64, width int) string

RenderContextGauge renders a bar gauge like [████░░░░] 67%

Types

type ModelPrice

type ModelPrice struct {
	Input  float64
	Output float64
}

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(projectsDir string) *Parser

func (*Parser) Poll

func (p *Parser) Poll() PollResult

func (*Parser) Reset

func (p *Parser) Reset()

type PollResult added in v0.6.0

type PollResult struct {
	Total      TokenUsage
	Model      string
	PerSession map[string]SessionTokens
}

PollResult contains both aggregate and per-session usage data.

type SessionCost added in v0.6.0

type SessionCost struct {
	Tokens TokenUsage
	Cost   float64
	Model  string
}

SessionCost holds computed cost for a single session.

type SessionTokens added in v0.6.0

type SessionTokens struct {
	Tokens TokenUsage
	Model  string
}

SessionTokens holds per-session token usage and model.

type TokenUsage

type TokenUsage struct {
	InputTokens         int64
	OutputTokens        int64
	CacheCreationTokens int64
	CacheReadTokens     int64
	LastInput           int64 // most recent API call's total input (overwrites, not accumulates)
}

TokenUsage holds aggregated token counts.

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

func NewTracker

func NewTracker(parser *Parser, program *tea.Program) *Tracker

func (*Tracker) Start

func (t *Tracker) Start()

func (*Tracker) Stop

func (t *Tracker) Stop()

type UsageSummary

type UsageSummary struct {
	Tokens     TokenUsage
	Cost       float64
	BurnRate   float64
	PerSession map[string]SessionCost
}

UsageSummary is the aggregate sent to the TUI.

type UsageUpdateMsg

type UsageUpdateMsg struct {
	Summary UsageSummary
}

UsageUpdateMsg is sent to the TUI with updated usage data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL