stats

package
v0.411.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatStats

func FormatStats(cache *ClaudeStatsCache) string

FormatStats returns a formatted multi-line string suitable for TUI display.

func FormatTokenCount

func FormatTokenCount(n int64) string

FormatTokenCount formats a token count as a human-readable string. Examples: 1234567 → "1.2M", 45000 → "45K", 892 → "892"

func TopModel

func TopModel(modelUsage map[string]ModelTokenUsage) string

TopModel returns the model name with the highest inputTokens. Returns an empty string if modelUsage is nil or empty.

Types

type AllTimeSummary

type AllTimeSummary struct {
	TotalSessions    int
	TotalMessages    int
	FirstSessionDate string
	LongestSession   *SessionStat
	ModelUsage       map[string]ModelTokenUsage
	TopModel         string
}

AllTimeSummary aggregates all historical activity

func GetAllTimeSummary

func GetAllTimeSummary(cache *ClaudeStatsCache) AllTimeSummary

GetAllTimeSummary returns aggregate statistics from the entire cache.

type ClaudeStatsCache

type ClaudeStatsCache struct {
	Version                     int                        `json:"version"`
	LastComputedDate            string                     `json:"lastComputedDate"`
	DailyActivity               []DailyActivity            `json:"dailyActivity"`
	DailyModelTokens            []DailyModelTokens         `json:"dailyModelTokens"`
	ModelUsage                  map[string]ModelTokenUsage `json:"modelUsage"`
	TotalSessions               int                        `json:"totalSessions"`
	TotalMessages               int                        `json:"totalMessages"`
	LongestSession              *SessionStat               `json:"longestSession"`
	FirstSessionDate            string                     `json:"firstSessionDate"`
	HourCounts                  map[string]int             `json:"hourCounts"`
	TotalSpeculationTimeSavedMs int64                      `json:"totalSpeculationTimeSavedMs"`
}

ClaudeStatsCache matches the structure of ~/.claude/stats-cache.json (version 2)

func LoadBestAvailableStats

func LoadBestAvailableStats() (*ClaudeStatsCache, error)

LoadBestAvailableStats tries Pando's stats first, then falls back to Claude Code's stats. Returns an error only if both files fail to load (not if they are simply absent).

func LoadClaudeCodeStats

func LoadClaudeCodeStats() (*ClaudeStatsCache, error)

LoadClaudeCodeStats reads stats from ~/.claude/stats-cache.json. Returns an empty cache if the file does not exist.

func LoadPandoStats

func LoadPandoStats() (*ClaudeStatsCache, error)

LoadPandoStats reads stats from Pando's own stats file. Returns an empty cache if the file does not exist.

type DailyActivity

type DailyActivity struct {
	Date          string `json:"date"` // "YYYY-MM-DD"
	MessageCount  int    `json:"messageCount"`
	SessionCount  int    `json:"sessionCount"`
	ToolCallCount int    `json:"toolCallCount"`
}

DailyActivity holds per-day usage counts

type DailyModelTokens

type DailyModelTokens struct {
	Date          string                     `json:"date"`
	TokensByModel map[string]ModelTokenUsage `json:"tokensByModel"`
}

DailyModelTokens holds per-day token usage broken down by model

type DailySummary

type DailySummary struct {
	Date              string
	MessageCount      int
	SessionCount      int
	ToolCallCount     int
	TotalInputTokens  int64
	TotalOutputTokens int64
	TopModel          string
}

DailySummary aggregates activity for a single day

func GetTodayActivity

func GetTodayActivity(cache *ClaudeStatsCache) DailySummary

GetTodayActivity returns activity data for today.

type ModelTokenUsage

type ModelTokenUsage struct {
	InputTokens              int64 `json:"inputTokens"`
	OutputTokens             int64 `json:"outputTokens"`
	CacheReadInputTokens     int64 `json:"cacheReadInputTokens"`
	CacheCreationInputTokens int64 `json:"cacheCreationInputTokens"`
}

ModelTokenUsage holds token counts for a specific model

type SessionStat

type SessionStat struct {
	Date         string `json:"date"`
	MessageCount int    `json:"messageCount"`
}

SessionStat represents a session with a date and message count

type WeeklySummary

type WeeklySummary struct {
	StartDate         string
	EndDate           string
	TotalMessages     int
	TotalSessions     int
	TotalToolCalls    int
	TotalInputTokens  int64
	TotalOutputTokens int64
	DailyBreakdown    []DailySummary
	TopModel          string
}

WeeklySummary aggregates activity for a 7-day window

func GetWeeklySummary

func GetWeeklySummary(cache *ClaudeStatsCache) WeeklySummary

GetWeeklySummary returns a summary of the last 7 days.

Jump to

Keyboard shortcuts

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